Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 Beta #859

Closed
adamjmcgrath opened this issue May 17, 2023 · 20 comments
Closed

v4 Beta #859

adamjmcgrath opened this issue May 17, 2023 · 20 comments

Comments

@adamjmcgrath
Copy link
Contributor

adamjmcgrath commented May 17, 2023

The node-auth0 v4 Beta is now live

Including:

  • Rewritten from the ground up in TypeScript
  • Types for methods, request parameters, bodies, errors and responses
  • Customisable modern networking stack

Install

npm install auth0@beta

Docs

ManagementClient: https://auth0.github.io/node-auth0/beta/classes/management.ManagementClient.html
AuthenticationClient: https://auth0.github.io/node-auth0/beta/classes/auth.AuthenticationClient.html

Sourcecode

/auth0/node-auth0/tree/beta

We invite you to try it out, if you notice any problems with it - please raise an issue.

We expect a beta period of up to a quarter while we iron out any inaccuracies in the types, we will keep you informed of our progress in this thread.

@shellscape
Copy link

Folks, the dist output doesn't match package.json. See https://github.com/auth0/node-auth0/blob/beta/package.json#L12 and https://unpkg.com/browse/auth0@4.0.0-beta.1/dist/

So TS types are not going to work out of the box. Is anyone testing this before publishing? Not a great look.

@adamjmcgrath
Copy link
Contributor Author

adamjmcgrath commented May 18, 2023

Thanks for the feedback @shellscape - this should be resolved in 4.0.0-beta.2

@nextlevelbeard
Copy link

Hi, I'm using custom grant call and despite already passing the client_secret in the constructor for the AuthenticationClient, it's not passed if not included in the body, unlike the client_id, is this by design? As an end-user, not happy about having to repeat myself here.

body: new URLSearchParams({
client_id: this.clientId,
...bodyParameters,
grant_type: grantType,
}),

@frederikprijck
Copy link
Member

frederikprijck commented May 30, 2023

Hey @nextlevelbeard ,

That's by design, as not all grants require a secret. So even though you have configured a secret, you might want to call a grant without a secret.

However, that does rise the question if supporting grants without a client_secret is something this SDK should do or not. /cc @adamjmcgrath as I remember us talking about it, what do you think?

If we don't, we could consider adding the secret in the grant method as well.

@adamjmcgrath
Copy link
Contributor Author

@nextlevelbeard - since all grants that auth0 supports should be covered in the authentication client, there shouldn't be any reason to use the custom grant call (we only expose it so we can re-use it in the Passwordless client)

Could you share your use case for using the custom grant method?

@nextlevelbeard
Copy link

nextlevelbeard commented May 30, 2023

Hi @adamjmcgrath @frederikprijck

I'm currently doing end-to-end test automation for an SPA with Node 18, TypeScript and webdriverIO.

Our backend integrates with auth0. We have configured an SPA Application with a database connection (named for example FOO).

We also configured a separate Machine to Machine application for Test Automation purposes (called Test Automation) that is authorized to talk to both the Management API and our custom API, with limited permissions.

During the tests I am creating users (on our API that talks to auth0 behind the curtain) and logging them in through a custom grant call with a custom realm, it simplifies and speeds up the the authentication process with a single call containing the user credentials. This is solely for our development environment and test automation purposes, easy and simple authentication flow.

AFAIK the custom grant type is the only way to authenticate against a database connection (please confirm!)

import * as auth0 from 'auth0';

const authClient = new auth0.AuthenticationClient({
  domain: "REDACTED",
  clientId: "REDACTED",
  clientSecret: "REDACTED"
})

const response = await authClient
  .oauth
  .grant("http://auth0.com/oauth/grant-type/password-realm", {
    // aka The name of our Database Connection
    realm: "FOO",
    // The original issue, shouldn't be need, auth client should already have this
    client_secret: "REDACTED",
    audience: "REDACTED",
    username: "REDACTED",
    password: "REDACTED"
})

// Take this token update our API client, etc
const token = response!.data.access_token

@frederikprijck
Copy link
Member

frederikprijck commented May 30, 2023

@nextlevelbeard , you should be able to use passwordGrant, see https://github.com/auth0/node-auth0/blob/beta/src/auth/oauth.ts#L349.

import * as auth0 from 'auth0';

const authClient = new auth0.AuthenticationClient({
  domain: "REDACTED",
  clientId: "REDACTED",
  clientSecret: "REDACTED"
})

const response = await authClient
  .oauth
  .passwordGrant({
    // aka The name of our Database Connection
    realm: "FOO",
    audience: "REDACTED",
    username: "REDACTED",
    password: "REDACTED"
})

As you can see in the source code, if you set the realm, it uses the "http://auth0.com/oauth/grant-type/password-realm" grant.

@nextlevelbeard
Copy link

I tried with success, thank you.
I had previously tried and failed with password grant, without specifying realm and google led me to the custom grant call.

@francofantini
Copy link

Hey! Beta doc links seem to be broken for me
image

@Sibz
Copy link

Sibz commented Aug 2, 2023

Still no docs...

Is there a verifyEmail function to resend the verification email?
https://auth0.github.io/node-auth0/ManagementClient.html#sendEmailVerification

@adamjmcgrath
Copy link
Contributor Author

@francofantini - thanks for the heads up - they're back here https://auth0.github.io/node-auth0/beta

@Sibz - it's here https://auth0.github.io/node-auth0/beta/classes/management.JobsManager.html#verifyEmail

@igmoweb
Copy link

igmoweb commented Aug 24, 2023

@adamjmcgrath Seems that the beta docs page is down again returning a 404, thanks.

@frederikprijck
Copy link
Member

Thanks, opened #920 to fix that

@frederikprijck
Copy link
Member

frederikprijck commented Aug 24, 2023

Merged, deployed and fixed. Beta docs are up again. Sorry about that, thanks for reporting.

@GauBen
Copy link

GauBen commented Sep 1, 2023

Hey there, is there an ETA for the stable release? The unofficial type support is really painful DefinitelyTyped/DefinitelyTyped#66393 and having an official type support is a blessing

I can't find a v3 to v4 migration guide, is there one yet?

@frederikprijck
Copy link
Member

You can find the current migration guide here: https://github.com/auth0/node-auth0/blob/beta/v4_MIGRATION_GUIDE.md

This may still be subject to changes.

Regarding ETA, we are working towards getting a stable release as soon as possible.

@GauBen
Copy link

GauBen commented Sep 1, 2023

Thank you @frederikprijck! The API looks much more consistent now and the "no unnecessary dependency" policy is really appealing, looking forward to upgrading to v4

@iyinolu
Copy link

iyinolu commented Sep 11, 2023

I'm testing this using Express and I get this error:

ReferenceError: fetch is not defined
    at new BaseAPI (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/lib/runtime.ts:34:44)
    at new BaseAuthAPI (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/auth/base-auth-api.ts:97:5)
    at new Database (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/auth/database.ts:120:1)
    at new AuthenticationClient (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/auth/index.ts:18:21)
    at new TokenProvider (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/management/token-provider.ts:23:33)
    at new TokenProviderMiddleware (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/management/token-provider-middleware.ts:20:28)
    at new ManagementClient (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/auth0/src/management/management-client.ts:73:9)
    at Object.<anonymous> (/Users/user/guidedlabs/spps-usermanagement-service/src/routes/users.ts:7:15)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Module.m._compile (/Users/user/guidedlabs/spps-usermanagement-service/node_modules/ts-node/src/index.ts:1618:23)

Any thoughts?

@frederikprijck
Copy link
Member

frederikprijck commented Sep 11, 2023

@iyinolu What version of node are u using? We only support Node18 and above with Node 16 going EOL tomorrow (12th september).

@adamjmcgrath
Copy link
Contributor Author

v4 has now been shipped https://github.com/auth0/node-auth0/releases/tag/v4.0.0 🎉

If you notice any problems with the latest release, please raise a new issue

@adamjmcgrath adamjmcgrath unpinned this issue Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants