auth0 6.4.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -15
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/lib/errors.d.ts +0 -18
- package/dist/cjs/lib/errors.js +1 -25
- package/dist/cjs/lib/middleware/auth0-client-telemetry.d.ts +3 -7
- package/dist/cjs/lib/middleware/auth0-client-telemetry.js +1 -25
- package/dist/cjs/lib/models.d.ts +0 -24
- package/dist/cjs/lib/models.js +0 -53
- package/dist/cjs/management/Client.d.ts +5 -5
- package/dist/cjs/management/Client.js +28 -28
- package/dist/cjs/management/api/errors/GatewayTimeoutError.d.ts +5 -0
- package/dist/cjs/management/api/errors/GatewayTimeoutError.js +54 -0
- package/dist/cjs/management/api/errors/index.d.ts +1 -0
- package/dist/cjs/management/api/errors/index.js +1 -0
- package/dist/cjs/management/api/requests/requests.d.ts +112 -88
- package/dist/cjs/management/api/resources/experimentation/client/Client.d.ts +12 -0
- package/dist/cjs/management/api/resources/experimentation/client/Client.js +16 -0
- package/dist/cjs/management/api/resources/experimentation/exports.d.ts +3 -0
- package/dist/cjs/management/api/resources/experimentation/exports.js +22 -0
- package/dist/cjs/management/api/resources/experimentation/index.d.ts +2 -0
- package/dist/cjs/management/api/resources/experimentation/index.js +18 -0
- package/dist/cjs/management/api/resources/experimentation/resources/experiments/client/Client.d.ts +34 -0
- package/dist/cjs/management/api/resources/experimentation/resources/experiments/client/Client.js +131 -0
- package/dist/cjs/management/api/resources/experimentation/resources/experiments/client/index.js +2 -0
- package/dist/cjs/management/api/resources/experimentation/resources/experiments/exports.d.ts +2 -0
- package/dist/cjs/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/exports.js +2 -2
- package/dist/cjs/management/api/resources/experimentation/resources/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/experimentation/resources/index.js +37 -0
- package/dist/cjs/management/api/resources/guardian/client/Client.d.ts +40 -1
- package/dist/cjs/management/api/resources/guardian/client/Client.js +172 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/client/Client.d.ts +3 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/client/Client.js +11 -6
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/client/Client.d.ts +46 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/client/Client.js +181 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/client/index.js +2 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.d.ts +2 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.js +21 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/index.d.ts +1 -0
- package/dist/cjs/{lib → management/api/resources/guardian/resources/factors/resources/email}/index.js +1 -2
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/index.js +2 -1
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/client/Client.d.ts +33 -0
- package/dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/client/Client.js +122 -0
- package/dist/cjs/management/api/resources/index.d.ts +1 -1
- package/dist/cjs/management/api/resources/index.js +2 -2
- package/dist/cjs/management/api/resources/organizations/client/Client.d.ts +36 -0
- package/dist/cjs/management/api/resources/organizations/client/Client.js +104 -0
- package/dist/cjs/management/api/resources/resourceServers/client/Client.d.ts +29 -0
- package/dist/cjs/management/api/resources/resourceServers/client/Client.js +103 -0
- package/dist/cjs/management/api/types/types.d.ts +226 -51
- package/dist/cjs/management/api/types/types.js +37 -36
- package/dist/cjs/management/version.d.ts +1 -1
- package/dist/cjs/management/version.js +1 -1
- package/dist/cjs/management/wrapper/ManagementClient.d.ts +9 -2
- package/dist/cjs/management/wrapper/ManagementClient.js +0 -1
- package/dist/cjs/management/wrapper/token-provider.d.ts +4 -2
- package/dist/cjs/management/wrapper/token-provider.js +142 -11
- package/dist/cjs/utils.d.ts +0 -18
- package/dist/cjs/utils.js +1 -32
- package/dist/esm/index.d.mts +0 -2
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/lib/errors.d.mts +0 -18
- package/dist/esm/lib/errors.mjs +0 -22
- package/dist/esm/lib/middleware/auth0-client-telemetry.d.mts +3 -7
- package/dist/esm/lib/middleware/auth0-client-telemetry.mjs +1 -25
- package/dist/esm/lib/models.d.mts +0 -24
- package/dist/esm/lib/models.mjs +1 -49
- package/dist/esm/management/Client.d.mts +5 -5
- package/dist/esm/management/Client.mjs +7 -7
- package/dist/esm/management/api/errors/GatewayTimeoutError.d.mts +5 -0
- package/dist/esm/management/api/errors/GatewayTimeoutError.mjs +17 -0
- package/dist/esm/management/api/errors/index.d.mts +1 -0
- package/dist/esm/management/api/errors/index.mjs +1 -0
- package/dist/esm/management/api/requests/requests.d.mts +112 -88
- package/dist/esm/management/api/resources/experimentation/client/Client.d.mts +12 -0
- package/dist/esm/management/api/resources/experimentation/client/Client.mjs +12 -0
- package/dist/esm/management/api/resources/experimentation/client/index.d.mts +1 -0
- package/dist/esm/management/api/resources/experimentation/client/index.mjs +1 -0
- package/dist/esm/management/api/resources/experimentation/exports.d.mts +3 -0
- package/dist/esm/management/api/resources/experimentation/exports.mjs +4 -0
- package/dist/esm/management/api/resources/experimentation/index.d.mts +2 -0
- package/dist/esm/management/api/resources/experimentation/index.mjs +2 -0
- package/dist/esm/management/api/resources/experimentation/resources/experiments/client/Client.d.mts +34 -0
- package/dist/esm/management/api/resources/experimentation/resources/experiments/client/Client.mjs +94 -0
- package/dist/esm/management/api/resources/experimentation/resources/experiments/client/index.d.mts +1 -0
- package/dist/esm/management/api/resources/experimentation/resources/experiments/client/index.mjs +1 -0
- package/dist/esm/management/api/resources/experimentation/resources/experiments/exports.d.mts +2 -0
- package/dist/esm/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/exports.mjs +1 -1
- package/dist/esm/management/api/resources/experimentation/resources/index.d.mts +1 -0
- package/dist/esm/management/api/resources/experimentation/resources/index.mjs +1 -0
- package/dist/esm/management/api/resources/guardian/client/Client.d.mts +40 -1
- package/dist/esm/management/api/resources/guardian/client/Client.mjs +139 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/client/Client.d.mts +3 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/client/Client.mjs +5 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/Client.d.mts +46 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/Client.mjs +144 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/index.d.mts +1 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/index.mjs +1 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.d.mts +2 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.mjs +3 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/index.d.mts +1 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/index.mjs +1 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/index.d.mts +1 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/index.mjs +1 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/phone/client/Client.d.mts +33 -0
- package/dist/esm/management/api/resources/guardian/resources/factors/resources/phone/client/Client.mjs +122 -0
- package/dist/esm/management/api/resources/index.d.mts +1 -1
- package/dist/esm/management/api/resources/index.mjs +1 -1
- package/dist/esm/management/api/resources/organizations/client/Client.d.mts +36 -0
- package/dist/esm/management/api/resources/organizations/client/Client.mjs +104 -0
- package/dist/esm/management/api/resources/resourceServers/client/Client.d.mts +29 -0
- package/dist/esm/management/api/resources/resourceServers/client/Client.mjs +103 -0
- package/dist/esm/management/api/types/types.d.mts +226 -51
- package/dist/esm/management/api/types/types.mjs +34 -33
- package/dist/esm/management/version.d.mts +1 -1
- package/dist/esm/management/version.mjs +1 -1
- package/dist/esm/management/wrapper/ManagementClient.d.mts +9 -2
- package/dist/esm/management/wrapper/ManagementClient.mjs +0 -1
- package/dist/esm/management/wrapper/token-provider.d.mts +4 -2
- package/dist/esm/management/wrapper/token-provider.mjs +142 -11
- package/dist/esm/utils.d.mts +0 -18
- package/dist/esm/utils.mjs +0 -30
- package/package.json +45 -23
- package/reference.md +654 -389
- package/dist/cjs/auth/backchannel.d.ts +0 -158
- package/dist/cjs/auth/backchannel.js +0 -135
- package/dist/cjs/auth/base-auth-api.d.ts +0 -41
- package/dist/cjs/auth/base-auth-api.js +0 -109
- package/dist/cjs/auth/client-authentication.d.ts +0 -27
- package/dist/cjs/auth/client-authentication.js +0 -82
- package/dist/cjs/auth/database.d.ts +0 -157
- package/dist/cjs/auth/database.js +0 -94
- package/dist/cjs/auth/id-token-validator.d.ts +0 -18
- package/dist/cjs/auth/id-token-validator.js +0 -158
- package/dist/cjs/auth/index.d.ts +0 -65
- package/dist/cjs/auth/index.js +0 -80
- package/dist/cjs/auth/oauth.d.ts +0 -462
- package/dist/cjs/auth/oauth.js +0 -280
- package/dist/cjs/auth/passwordless.d.ts +0 -165
- package/dist/cjs/auth/passwordless.js +0 -173
- package/dist/cjs/auth/tokenExchange.d.ts +0 -166
- package/dist/cjs/auth/tokenExchange.js +0 -74
- package/dist/cjs/lib/index.d.ts +0 -3
- package/dist/cjs/lib/runtime.d.ts +0 -61
- package/dist/cjs/lib/runtime.js +0 -222
- package/dist/cjs/management/api/resources/organizationTemplates/client/Client.d.ts +0 -106
- package/dist/cjs/management/api/resources/organizationTemplates/client/Client.js +0 -411
- package/dist/cjs/management/api/resources/organizationTemplates/exports.d.ts +0 -2
- package/dist/cjs/userinfo/index.d.ts +0 -87
- package/dist/cjs/userinfo/index.js +0 -104
- package/dist/esm/auth/backchannel.d.mts +0 -158
- package/dist/esm/auth/backchannel.mjs +0 -131
- package/dist/esm/auth/base-auth-api.d.mts +0 -41
- package/dist/esm/auth/base-auth-api.mjs +0 -103
- package/dist/esm/auth/client-authentication.d.mts +0 -27
- package/dist/esm/auth/client-authentication.mjs +0 -45
- package/dist/esm/auth/database.d.mts +0 -157
- package/dist/esm/auth/database.mjs +0 -90
- package/dist/esm/auth/id-token-validator.d.mts +0 -18
- package/dist/esm/auth/id-token-validator.mjs +0 -120
- package/dist/esm/auth/index.d.mts +0 -65
- package/dist/esm/auth/index.mjs +0 -60
- package/dist/esm/auth/oauth.d.mts +0 -462
- package/dist/esm/auth/oauth.mjs +0 -276
- package/dist/esm/auth/passwordless.d.mts +0 -165
- package/dist/esm/auth/passwordless.mjs +0 -169
- package/dist/esm/auth/tokenExchange.d.mts +0 -166
- package/dist/esm/auth/tokenExchange.mjs +0 -70
- package/dist/esm/lib/index.d.mts +0 -3
- package/dist/esm/lib/index.mjs +0 -2
- package/dist/esm/lib/runtime.d.mts +0 -61
- package/dist/esm/lib/runtime.mjs +0 -201
- package/dist/esm/management/api/resources/organizationTemplates/client/Client.d.mts +0 -106
- package/dist/esm/management/api/resources/organizationTemplates/client/Client.mjs +0 -374
- package/dist/esm/management/api/resources/organizationTemplates/exports.d.mts +0 -2
- package/dist/esm/userinfo/index.d.mts +0 -87
- package/dist/esm/userinfo/index.mjs +0 -98
- /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation}/client/index.d.ts +0 -0
- /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation}/client/index.js +0 -0
- /package/dist/{esm/management/api/resources/organizationTemplates/client/index.d.mts → cjs/management/api/resources/experimentation/resources/experiments/client/index.d.ts} +0 -0
- /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.d.ts +0 -0
- /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.js +0 -0
- /package/dist/{esm/management/api/resources/organizationTemplates/client/index.mjs → cjs/management/api/resources/guardian/resources/factors/resources/email/client/index.d.ts} +0 -0
- /package/dist/esm/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.d.mts +0 -0
- /package/dist/esm/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.mjs +0 -0
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { JSONApiResponse, TextApiResponse } from "../lib/models.mjs";
|
|
11
|
-
import { validateRequiredRequestParams } from "../lib/runtime.mjs";
|
|
12
|
-
import { BaseAuthAPI } from "./base-auth-api.mjs";
|
|
13
|
-
/**
|
|
14
|
-
* Sign-up and change-password for Database & Active Directory authentication services.
|
|
15
|
-
*/
|
|
16
|
-
export class Database extends BaseAuthAPI {
|
|
17
|
-
/**
|
|
18
|
-
* Given a user's credentials, and a connection, this endpoint will create a new user using active authentication.
|
|
19
|
-
*
|
|
20
|
-
* This endpoint only works for database connections.
|
|
21
|
-
*
|
|
22
|
-
* See: https://auth0.com/docs/api/authentication#signup
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```js
|
|
26
|
-
* var data = {
|
|
27
|
-
* email: '{EMAIL}',
|
|
28
|
-
* password: '{PASSWORD}',
|
|
29
|
-
* connection: 'Username-Password-Authentication'
|
|
30
|
-
* };
|
|
31
|
-
*
|
|
32
|
-
* await auth0.database.signUp(data);
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
signUp(bodyParameters, initOverrides) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
// TODO: call this `validateRequiredParams` so we can use with bodyParameters in the auth api
|
|
38
|
-
validateRequiredRequestParams(bodyParameters, ["email", "password", "connection"]);
|
|
39
|
-
const response = yield this.request({
|
|
40
|
-
path: "/dbconnections/signup",
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
body: Object.assign({ client_id: this.clientId }, bodyParameters),
|
|
46
|
-
}, initOverrides);
|
|
47
|
-
// Transform the response to ensure id field is always available
|
|
48
|
-
const jsonResponse = yield JSONApiResponse.fromResponse(response);
|
|
49
|
-
if (jsonResponse.data) {
|
|
50
|
-
const data = jsonResponse.data;
|
|
51
|
-
// Map _id or user_id to id
|
|
52
|
-
if (!data.id && (data._id || data.user_id)) {
|
|
53
|
-
data.id = data._id || data.user_id;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return jsonResponse;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Given a user's email address and a connection, Auth0 will send a change password email.
|
|
61
|
-
*
|
|
62
|
-
* This endpoint only works for database connections.
|
|
63
|
-
*
|
|
64
|
-
* See: https://auth0.com/docs/api/authentication#change-password
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```js
|
|
68
|
-
* var data = {
|
|
69
|
-
* email: '{EMAIL}',
|
|
70
|
-
* connection: 'Username-Password-Authentication'
|
|
71
|
-
* };
|
|
72
|
-
*
|
|
73
|
-
* await auth0.database.changePassword(data);
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
changePassword(bodyParameters, initOverrides) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
validateRequiredRequestParams(bodyParameters, ["email", "connection"]);
|
|
79
|
-
const response = yield this.request({
|
|
80
|
-
path: "/dbconnections/change_password",
|
|
81
|
-
method: "POST",
|
|
82
|
-
headers: {
|
|
83
|
-
"Content-Type": "application/json",
|
|
84
|
-
},
|
|
85
|
-
body: Object.assign({ client_id: this.clientId }, bodyParameters),
|
|
86
|
-
}, initOverrides);
|
|
87
|
-
return TextApiResponse.fromResponse(response);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AuthenticationClientOptions } from "./base-auth-api.mjs";
|
|
2
|
-
export declare class IdTokenValidatorError extends Error {
|
|
3
|
-
}
|
|
4
|
-
export interface IDTokenValidateOptions {
|
|
5
|
-
nonce?: string;
|
|
6
|
-
maxAge?: number;
|
|
7
|
-
organization?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class IDTokenValidator {
|
|
10
|
-
private jwks;
|
|
11
|
-
private alg;
|
|
12
|
-
private audience;
|
|
13
|
-
private issuer;
|
|
14
|
-
private clockTolerance;
|
|
15
|
-
private secret;
|
|
16
|
-
constructor({ domain, clientId, clientSecret, headers, timeoutDuration, idTokenSigningAlg, clockTolerance, }: AuthenticationClientOptions);
|
|
17
|
-
validate(idToken: string, { nonce, maxAge, organization }?: IDTokenValidateOptions): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import * as jose from "jose";
|
|
11
|
-
const DEFAULT_CLOCK_TOLERANCE = 60; // secs
|
|
12
|
-
export class IdTokenValidatorError extends Error {
|
|
13
|
-
}
|
|
14
|
-
export class IDTokenValidator {
|
|
15
|
-
constructor({ domain, clientId, clientSecret, headers, timeoutDuration, idTokenSigningAlg = "RS256", clockTolerance = DEFAULT_CLOCK_TOLERANCE, }) {
|
|
16
|
-
this.jwks = jose.createRemoteJWKSet(new URL(`https://${domain}/.well-known/jwks.json`), {
|
|
17
|
-
timeoutDuration,
|
|
18
|
-
headers,
|
|
19
|
-
});
|
|
20
|
-
this.alg = idTokenSigningAlg;
|
|
21
|
-
this.audience = clientId;
|
|
22
|
-
this.secret = new TextEncoder().encode(clientSecret);
|
|
23
|
-
this.issuer = `https://${domain}/`;
|
|
24
|
-
this.clockTolerance = clockTolerance;
|
|
25
|
-
}
|
|
26
|
-
validate(idToken_1) {
|
|
27
|
-
return __awaiter(this, arguments, void 0, function* (idToken, { nonce, maxAge, organization } = {}) {
|
|
28
|
-
const secret = this.alg === "HS256" ? this.secret : this.jwks;
|
|
29
|
-
const header = jose.decodeProtectedHeader(idToken);
|
|
30
|
-
const payload = jose.decodeJwt(idToken);
|
|
31
|
-
// Check algorithm
|
|
32
|
-
if (header.alg !== "RS256" && header.alg !== "HS256") {
|
|
33
|
-
throw new Error(`Signature algorithm of "${header.alg}" is not supported. Expected the ID token to be signed with "RS256" or "HS256".`);
|
|
34
|
-
}
|
|
35
|
-
// Issuer
|
|
36
|
-
if (!payload.iss || typeof payload.iss !== "string") {
|
|
37
|
-
throw new IdTokenValidatorError("Issuer (iss) claim must be a string present in the ID token");
|
|
38
|
-
}
|
|
39
|
-
if (payload.iss !== this.issuer) {
|
|
40
|
-
throw new IdTokenValidatorError(`Issuer (iss) claim mismatch in the ID token; expected "${this.issuer}", found "${payload.iss}"`);
|
|
41
|
-
}
|
|
42
|
-
// Subject
|
|
43
|
-
if (!payload.sub || typeof payload.sub !== "string") {
|
|
44
|
-
throw new IdTokenValidatorError("Subject (sub) claim must be a string present in the ID token");
|
|
45
|
-
}
|
|
46
|
-
// Audience
|
|
47
|
-
if (!payload.aud || !(typeof payload.aud === "string" || Array.isArray(payload.aud))) {
|
|
48
|
-
throw new IdTokenValidatorError("Audience (aud) claim must be a string or array of strings present in the ID token");
|
|
49
|
-
}
|
|
50
|
-
if (Array.isArray(payload.aud) && !payload.aud.includes(this.audience)) {
|
|
51
|
-
throw new IdTokenValidatorError(`Audience (aud) claim mismatch in the ID token; expected "${this.audience}" but was not one of "${payload.aud.join(", ")}"`);
|
|
52
|
-
}
|
|
53
|
-
else if (typeof payload.aud === "string" && payload.aud !== this.audience) {
|
|
54
|
-
throw new IdTokenValidatorError(`Audience (aud) claim mismatch in the ID token; expected "${this.audience}" but found "${payload.aud}"`);
|
|
55
|
-
}
|
|
56
|
-
// Organization
|
|
57
|
-
if (organization) {
|
|
58
|
-
if (organization.indexOf("org_") === 0) {
|
|
59
|
-
if (!payload.org_id || typeof payload.org_id !== "string") {
|
|
60
|
-
throw new Error("Organization Id (org_id) claim must be a string present in the ID token");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (!payload.org_name || typeof payload.org_name !== "string") {
|
|
65
|
-
throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// Time validation (epoch)
|
|
70
|
-
const now = Math.floor(Date.now() / 1000);
|
|
71
|
-
// Expires at
|
|
72
|
-
if (!payload.exp || typeof payload.exp !== "number") {
|
|
73
|
-
throw new IdTokenValidatorError("Expiration Time (exp) claim must be a number present in the ID token");
|
|
74
|
-
}
|
|
75
|
-
const expTime = payload.exp + this.clockTolerance;
|
|
76
|
-
if (now > expTime) {
|
|
77
|
-
throw new IdTokenValidatorError(`Expiration Time (exp) claim error in the ID token; current time (${now}) is after expiration time (${expTime})`);
|
|
78
|
-
}
|
|
79
|
-
// Issued at
|
|
80
|
-
if (!payload.iat || typeof payload.iat !== "number") {
|
|
81
|
-
throw new IdTokenValidatorError("Issued At (iat) claim must be a number present in the ID token");
|
|
82
|
-
}
|
|
83
|
-
// Nonce
|
|
84
|
-
if (nonce || payload.nonce) {
|
|
85
|
-
if (!payload.nonce || typeof payload.nonce !== "string") {
|
|
86
|
-
throw new IdTokenValidatorError("Nonce (nonce) claim must be a string present in the ID token");
|
|
87
|
-
}
|
|
88
|
-
if (payload.nonce !== nonce) {
|
|
89
|
-
throw new IdTokenValidatorError(`Nonce (nonce) claim mismatch in the ID token; expected "${nonce}", found "${payload.nonce}"`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// Authorized party
|
|
93
|
-
if (Array.isArray(payload.aud) && payload.aud.length > 1) {
|
|
94
|
-
if (!payload.azp || typeof payload.azp !== "string") {
|
|
95
|
-
throw new IdTokenValidatorError("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");
|
|
96
|
-
}
|
|
97
|
-
if (payload.azp !== this.audience) {
|
|
98
|
-
throw new IdTokenValidatorError(`Authorized Party (azp) claim mismatch in the ID token; expected "${this.audience}", found "${payload.azp}"`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Authentication time
|
|
102
|
-
if (maxAge) {
|
|
103
|
-
if (!payload.auth_time || typeof payload.auth_time !== "number") {
|
|
104
|
-
throw new IdTokenValidatorError("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");
|
|
105
|
-
}
|
|
106
|
-
const authValidUntil = payload.auth_time + maxAge + this.clockTolerance;
|
|
107
|
-
if (now > authValidUntil) {
|
|
108
|
-
throw new IdTokenValidatorError(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Currrent time (${now}) is after last auth at ${authValidUntil}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
yield jose.jwtVerify(idToken, secret, {
|
|
112
|
-
issuer: this.issuer,
|
|
113
|
-
audience: this.audience,
|
|
114
|
-
clockTolerance: this.clockTolerance,
|
|
115
|
-
maxTokenAge: maxAge,
|
|
116
|
-
algorithms: ["HS256", "RS256"],
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { IBackchannel } from "./backchannel.mjs";
|
|
2
|
-
import { AuthenticationClientOptions } from "./base-auth-api.mjs";
|
|
3
|
-
import { Database } from "./database.mjs";
|
|
4
|
-
import { OAuth } from "./oauth.mjs";
|
|
5
|
-
import { Passwordless } from "./passwordless.mjs";
|
|
6
|
-
import { ICustomTokenExchange } from "./tokenExchange.mjs";
|
|
7
|
-
export * from "./database.mjs";
|
|
8
|
-
export * from "./oauth.mjs";
|
|
9
|
-
export * from "./passwordless.mjs";
|
|
10
|
-
export { IDTokenValidateOptions, IdTokenValidatorError } from "./id-token-validator.mjs";
|
|
11
|
-
export { AuthApiError, AuthenticationClientOptions } from "./base-auth-api.mjs";
|
|
12
|
-
/**
|
|
13
|
-
* Auth0 Authentication API Client
|
|
14
|
-
*
|
|
15
|
-
* Provides access to Auth0's authentication endpoints for login, signup,
|
|
16
|
-
* passwordless authentication, and token exchange operations.
|
|
17
|
-
*
|
|
18
|
-
* @group Authentication API
|
|
19
|
-
*
|
|
20
|
-
* @example Basic setup
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { AuthenticationClient } from 'auth0';
|
|
23
|
-
*
|
|
24
|
-
* const auth0 = new AuthenticationClient({
|
|
25
|
-
* domain: 'your-tenant.auth0.com',
|
|
26
|
-
* clientId: 'your-client-id'
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @example OAuth login
|
|
31
|
-
* ```typescript
|
|
32
|
-
* // Exchange authorization code for tokens
|
|
33
|
-
* const tokenSet = await auth0.oauth.authorizationCodeGrant({
|
|
34
|
-
* code: 'auth-code',
|
|
35
|
-
* redirect_uri: 'https://app.example.com/callback'
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @example Database operations
|
|
40
|
-
* ```typescript
|
|
41
|
-
* // Create user
|
|
42
|
-
* const user = await auth0.database.signUp({
|
|
43
|
-
* connection: 'Username-Password-Authentication',
|
|
44
|
-
* username: 'john@example.com',
|
|
45
|
-
* password: 'secure-password123'
|
|
46
|
-
* });
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare class AuthenticationClient {
|
|
50
|
-
/** Database connection operations (signup, change password) */
|
|
51
|
-
database: Database;
|
|
52
|
-
/** OAuth 2.0 and OIDC operations (authorization, token exchange) */
|
|
53
|
-
oauth: OAuth;
|
|
54
|
-
/** Passwordless authentication (email/SMS) */
|
|
55
|
-
passwordless: Passwordless;
|
|
56
|
-
/** Back-channel authentication (CIBA) */
|
|
57
|
-
backchannel: IBackchannel;
|
|
58
|
-
/** Custom token exchange operations */
|
|
59
|
-
tokenExchange: ICustomTokenExchange;
|
|
60
|
-
/**
|
|
61
|
-
* Create a new Authentication API client
|
|
62
|
-
* @param options - Configuration options for the client
|
|
63
|
-
*/
|
|
64
|
-
constructor(options: AuthenticationClientOptions);
|
|
65
|
-
}
|
package/dist/esm/auth/index.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Backchannel } from "./backchannel.mjs";
|
|
2
|
-
import { Database } from "./database.mjs";
|
|
3
|
-
import { OAuth } from "./oauth.mjs";
|
|
4
|
-
import { Passwordless } from "./passwordless.mjs";
|
|
5
|
-
import { CustomTokenExchange } from "./tokenExchange.mjs";
|
|
6
|
-
export * from "./database.mjs";
|
|
7
|
-
export * from "./oauth.mjs";
|
|
8
|
-
export * from "./passwordless.mjs";
|
|
9
|
-
export { IdTokenValidatorError } from "./id-token-validator.mjs";
|
|
10
|
-
export { AuthApiError } from "./base-auth-api.mjs";
|
|
11
|
-
/**
|
|
12
|
-
* Auth0 Authentication API Client
|
|
13
|
-
*
|
|
14
|
-
* Provides access to Auth0's authentication endpoints for login, signup,
|
|
15
|
-
* passwordless authentication, and token exchange operations.
|
|
16
|
-
*
|
|
17
|
-
* @group Authentication API
|
|
18
|
-
*
|
|
19
|
-
* @example Basic setup
|
|
20
|
-
* ```typescript
|
|
21
|
-
* import { AuthenticationClient } from 'auth0';
|
|
22
|
-
*
|
|
23
|
-
* const auth0 = new AuthenticationClient({
|
|
24
|
-
* domain: 'your-tenant.auth0.com',
|
|
25
|
-
* clientId: 'your-client-id'
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @example OAuth login
|
|
30
|
-
* ```typescript
|
|
31
|
-
* // Exchange authorization code for tokens
|
|
32
|
-
* const tokenSet = await auth0.oauth.authorizationCodeGrant({
|
|
33
|
-
* code: 'auth-code',
|
|
34
|
-
* redirect_uri: 'https://app.example.com/callback'
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @example Database operations
|
|
39
|
-
* ```typescript
|
|
40
|
-
* // Create user
|
|
41
|
-
* const user = await auth0.database.signUp({
|
|
42
|
-
* connection: 'Username-Password-Authentication',
|
|
43
|
-
* username: 'john@example.com',
|
|
44
|
-
* password: 'secure-password123'
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export class AuthenticationClient {
|
|
49
|
-
/**
|
|
50
|
-
* Create a new Authentication API client
|
|
51
|
-
* @param options - Configuration options for the client
|
|
52
|
-
*/
|
|
53
|
-
constructor(options) {
|
|
54
|
-
this.database = new Database(options);
|
|
55
|
-
this.oauth = new OAuth(options);
|
|
56
|
-
this.passwordless = new Passwordless(options);
|
|
57
|
-
this.backchannel = new Backchannel(options);
|
|
58
|
-
this.tokenExchange = new CustomTokenExchange(options);
|
|
59
|
-
}
|
|
60
|
-
}
|