question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@types - AuthCallback: Incorrect definition

See original GitHub issue

https://github.com/verdaccio/monorepo/blob/9.x/core/types/index.d.ts defines

type AuthAccessCallback = (error: string | null, access: boolean) => void;

interface IPluginAuth<T> extends IPlugin<T> {
  authenticate(user: string, password: string, cb: AuthCallback): void;
  adduser?(user: string, password: string, cb: AuthCallback): void;
  changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
  allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
  allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
  allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
  allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
  allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
  allow_unpublish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
  apiJWTmiddleware?(helpers: any): Function;
}

However, the server seems to be expecting an object when there is an error for the callback, not a string.

When I try to pass an error: string the server throws an error, it seems to be expecting an object. I have to pass null to prevent the server from throwing an error.

Example Code

public authenticate(username: string, password: string, cb: AuthCallback): void {

  // fetch the user and set validPassword

  return validPassword ? cb(null, fetchedUser.groups) : cb('user not found', false);
}

Output from server

npm ERR! Unexpected token u in JSON at position 0 while parsing near 'user not found'

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
haquezameercommented, Sep 19, 2021

I would like to take this up @juanpicado

0reactions
juanpicadocommented, Sep 19, 2021

@haquezameer awesome, my comment from 2020, back then the master branch did not have the current structure. In master branch you can find all the modules and this file https://github.com/verdaccio/monorepo/blob/9.x/core/types/index.d.ts is located here https://github.com/verdaccio/verdaccio/tree/master/packages/types so you have all required pieces on this repo.

Feel free to ask me all you need to know to move this on.

tip: @verdaccio/types are used in most of the packages, thus after change to verify all types are correct, run from the root. pnpm build if any module fails you will see why and where should be adapted. As far I know this might affect all auth plugins on this repo, which are like 3.

Reminder, breaking changes are allowed, in such case any breaking change should be documented properly here https://github.com/verdaccio/verdaccio/blob/master/docs/migration-v5-to-v6.md

Read more comments on GitHub >

github_iconTop Results From Across the Web

@verdaccio/types | Yarn - Package Manager
This monorepo contains all the packages that composes the Verdaccio architecture, except Verdaccio itself and UI. Deprecated project. Any future change has to ......
Read more >
Callbacks | NextAuth.js
Callbacks are asynchronous functions you can use to control what happens when an action is performed.
Read more >
Authentication | Community Connectors - Google Developers
The following table indicates which functions you must define depending on the authentication type of your connector.
Read more >
TroubleShoot: WebSphere WS-Security General Errors - IBM
When you receive this error on a client, it means that the webservices.unify.faults JVM custom property is set to true on the service...
Read more >
Solved: Receiving a "redirect_uri_mismatch" error when aut...
Can you tell me what is wrong with the redirect_uri value I'm using? ... the API can be tweaked to allow this type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found