auth0 6.3.0 → 7.0.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.
Files changed (160) hide show
  1. package/README.md +20 -15
  2. package/dist/cjs/index.d.ts +0 -2
  3. package/dist/cjs/index.js +0 -2
  4. package/dist/cjs/lib/errors.d.ts +0 -18
  5. package/dist/cjs/lib/errors.js +1 -25
  6. package/dist/cjs/lib/middleware/auth0-client-telemetry.d.ts +3 -7
  7. package/dist/cjs/lib/middleware/auth0-client-telemetry.js +1 -25
  8. package/dist/cjs/lib/models.d.ts +0 -24
  9. package/dist/cjs/lib/models.js +0 -53
  10. package/dist/cjs/management/Client.d.ts +3 -0
  11. package/dist/cjs/management/Client.js +45 -40
  12. package/dist/cjs/management/api/errors/UnprocessableEntityError.d.ts +5 -0
  13. package/dist/cjs/management/api/errors/UnprocessableEntityError.js +54 -0
  14. package/dist/cjs/management/api/errors/index.d.ts +1 -0
  15. package/dist/cjs/management/api/errors/index.js +1 -0
  16. package/dist/cjs/management/api/requests/requests.d.ts +91 -0
  17. package/dist/cjs/management/api/resources/connections/client/Client.d.ts +2 -0
  18. package/dist/cjs/management/api/resources/connections/client/Client.js +6 -0
  19. package/dist/cjs/management/api/resources/connections/resources/scimConfiguration/client/Client.d.ts +1 -0
  20. package/dist/cjs/management/api/resources/connections/resources/scimConfiguration/client/Client.js +3 -0
  21. package/dist/cjs/management/api/resources/index.d.ts +1 -0
  22. package/dist/cjs/management/api/resources/index.js +2 -1
  23. package/dist/cjs/management/api/resources/keys/resources/networkAcls/client/Client.d.ts +17 -0
  24. package/dist/cjs/management/api/resources/keys/resources/networkAcls/client/Client.js +60 -0
  25. package/dist/cjs/management/api/resources/organizationTemplates/client/Client.d.ts +106 -0
  26. package/dist/cjs/management/api/resources/organizationTemplates/client/Client.js +411 -0
  27. package/dist/cjs/management/api/resources/organizationTemplates/client/index.d.ts +1 -0
  28. package/dist/cjs/management/api/resources/organizationTemplates/client/index.js +2 -0
  29. package/dist/cjs/management/api/resources/organizationTemplates/exports.d.ts +2 -0
  30. package/dist/cjs/management/api/resources/organizationTemplates/exports.js +21 -0
  31. package/dist/cjs/management/api/resources/organizationTemplates/index.d.ts +1 -0
  32. package/dist/cjs/{lib → management/api/resources/organizationTemplates}/index.js +1 -2
  33. package/dist/cjs/management/api/resources/organizations/client/Client.d.ts +3 -0
  34. package/dist/cjs/management/api/resources/organizations/client/Client.js +7 -2
  35. package/dist/cjs/management/api/resources/organizations/resources/index.d.ts +1 -0
  36. package/dist/cjs/management/api/resources/organizations/resources/index.js +2 -1
  37. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/Client.d.ts +63 -0
  38. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/Client.js +232 -0
  39. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/index.d.ts +1 -0
  40. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/index.js +2 -0
  41. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/exports.d.ts +2 -0
  42. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/exports.js +21 -0
  43. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/index.d.ts +1 -0
  44. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/index.js +17 -0
  45. package/dist/cjs/management/api/resources/users/resources/organizations/client/Client.d.ts +17 -0
  46. package/dist/cjs/management/api/resources/users/resources/organizations/client/Client.js +19 -0
  47. package/dist/cjs/management/api/types/types.d.ts +8896 -2027
  48. package/dist/cjs/management/api/types/types.js +1455 -166
  49. package/dist/cjs/management/version.d.ts +1 -1
  50. package/dist/cjs/management/version.js +1 -1
  51. package/dist/cjs/management/wrapper/ManagementClient.d.ts +9 -2
  52. package/dist/cjs/management/wrapper/ManagementClient.js +0 -1
  53. package/dist/cjs/management/wrapper/token-provider.d.ts +4 -2
  54. package/dist/cjs/management/wrapper/token-provider.js +142 -11
  55. package/dist/cjs/utils.d.ts +0 -18
  56. package/dist/cjs/utils.js +1 -32
  57. package/dist/esm/index.d.mts +0 -2
  58. package/dist/esm/index.mjs +0 -2
  59. package/dist/esm/lib/errors.d.mts +0 -18
  60. package/dist/esm/lib/errors.mjs +0 -22
  61. package/dist/esm/lib/middleware/auth0-client-telemetry.d.mts +3 -7
  62. package/dist/esm/lib/middleware/auth0-client-telemetry.mjs +1 -25
  63. package/dist/esm/lib/models.d.mts +0 -24
  64. package/dist/esm/lib/models.mjs +1 -49
  65. package/dist/esm/management/Client.d.mts +3 -0
  66. package/dist/esm/management/Client.mjs +5 -0
  67. package/dist/esm/management/api/errors/UnprocessableEntityError.d.mts +5 -0
  68. package/dist/esm/management/api/errors/UnprocessableEntityError.mjs +17 -0
  69. package/dist/esm/management/api/errors/index.d.mts +1 -0
  70. package/dist/esm/management/api/errors/index.mjs +1 -0
  71. package/dist/esm/management/api/requests/requests.d.mts +91 -0
  72. package/dist/esm/management/api/resources/connections/client/Client.d.mts +2 -0
  73. package/dist/esm/management/api/resources/connections/client/Client.mjs +6 -0
  74. package/dist/esm/management/api/resources/connections/resources/scimConfiguration/client/Client.d.mts +1 -0
  75. package/dist/esm/management/api/resources/connections/resources/scimConfiguration/client/Client.mjs +3 -0
  76. package/dist/esm/management/api/resources/index.d.mts +1 -0
  77. package/dist/esm/management/api/resources/index.mjs +1 -0
  78. package/dist/esm/management/api/resources/keys/resources/networkAcls/client/Client.d.mts +17 -0
  79. package/dist/esm/management/api/resources/keys/resources/networkAcls/client/Client.mjs +60 -0
  80. package/dist/esm/management/api/resources/organizationTemplates/client/Client.d.mts +106 -0
  81. package/dist/esm/management/api/resources/organizationTemplates/client/Client.mjs +374 -0
  82. package/dist/esm/management/api/resources/organizationTemplates/client/index.d.mts +1 -0
  83. package/dist/esm/management/api/resources/organizationTemplates/client/index.mjs +1 -0
  84. package/dist/esm/management/api/resources/organizationTemplates/exports.d.mts +2 -0
  85. package/dist/esm/management/api/resources/organizationTemplates/exports.mjs +3 -0
  86. package/dist/esm/management/api/resources/organizationTemplates/index.d.mts +1 -0
  87. package/dist/esm/management/api/resources/organizationTemplates/index.mjs +1 -0
  88. package/dist/esm/management/api/resources/organizations/client/Client.d.mts +3 -0
  89. package/dist/esm/management/api/resources/organizations/client/Client.mjs +5 -0
  90. package/dist/esm/management/api/resources/organizations/resources/index.d.mts +1 -0
  91. package/dist/esm/management/api/resources/organizations/resources/index.mjs +1 -0
  92. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/Client.d.mts +63 -0
  93. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/Client.mjs +195 -0
  94. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/index.d.mts +1 -0
  95. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/index.mjs +1 -0
  96. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/exports.d.mts +2 -0
  97. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/exports.mjs +3 -0
  98. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/index.d.mts +1 -0
  99. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/index.mjs +1 -0
  100. package/dist/esm/management/api/resources/users/resources/organizations/client/Client.d.mts +17 -0
  101. package/dist/esm/management/api/resources/users/resources/organizations/client/Client.mjs +19 -0
  102. package/dist/esm/management/api/types/types.d.mts +8896 -2027
  103. package/dist/esm/management/api/types/types.mjs +1434 -150
  104. package/dist/esm/management/version.d.mts +1 -1
  105. package/dist/esm/management/version.mjs +1 -1
  106. package/dist/esm/management/wrapper/ManagementClient.d.mts +9 -2
  107. package/dist/esm/management/wrapper/ManagementClient.mjs +0 -1
  108. package/dist/esm/management/wrapper/token-provider.d.mts +4 -2
  109. package/dist/esm/management/wrapper/token-provider.mjs +142 -11
  110. package/dist/esm/utils.d.mts +0 -18
  111. package/dist/esm/utils.mjs +0 -30
  112. package/package.json +23 -2
  113. package/reference.md +688 -28
  114. package/dist/cjs/auth/backchannel.d.ts +0 -158
  115. package/dist/cjs/auth/backchannel.js +0 -135
  116. package/dist/cjs/auth/base-auth-api.d.ts +0 -41
  117. package/dist/cjs/auth/base-auth-api.js +0 -109
  118. package/dist/cjs/auth/client-authentication.d.ts +0 -27
  119. package/dist/cjs/auth/client-authentication.js +0 -82
  120. package/dist/cjs/auth/database.d.ts +0 -157
  121. package/dist/cjs/auth/database.js +0 -94
  122. package/dist/cjs/auth/id-token-validator.d.ts +0 -18
  123. package/dist/cjs/auth/id-token-validator.js +0 -158
  124. package/dist/cjs/auth/index.d.ts +0 -65
  125. package/dist/cjs/auth/index.js +0 -80
  126. package/dist/cjs/auth/oauth.d.ts +0 -462
  127. package/dist/cjs/auth/oauth.js +0 -280
  128. package/dist/cjs/auth/passwordless.d.ts +0 -165
  129. package/dist/cjs/auth/passwordless.js +0 -173
  130. package/dist/cjs/auth/tokenExchange.d.ts +0 -166
  131. package/dist/cjs/auth/tokenExchange.js +0 -74
  132. package/dist/cjs/lib/index.d.ts +0 -3
  133. package/dist/cjs/lib/runtime.d.ts +0 -61
  134. package/dist/cjs/lib/runtime.js +0 -222
  135. package/dist/cjs/userinfo/index.d.ts +0 -87
  136. package/dist/cjs/userinfo/index.js +0 -104
  137. package/dist/esm/auth/backchannel.d.mts +0 -158
  138. package/dist/esm/auth/backchannel.mjs +0 -131
  139. package/dist/esm/auth/base-auth-api.d.mts +0 -41
  140. package/dist/esm/auth/base-auth-api.mjs +0 -103
  141. package/dist/esm/auth/client-authentication.d.mts +0 -27
  142. package/dist/esm/auth/client-authentication.mjs +0 -45
  143. package/dist/esm/auth/database.d.mts +0 -157
  144. package/dist/esm/auth/database.mjs +0 -90
  145. package/dist/esm/auth/id-token-validator.d.mts +0 -18
  146. package/dist/esm/auth/id-token-validator.mjs +0 -120
  147. package/dist/esm/auth/index.d.mts +0 -65
  148. package/dist/esm/auth/index.mjs +0 -60
  149. package/dist/esm/auth/oauth.d.mts +0 -462
  150. package/dist/esm/auth/oauth.mjs +0 -276
  151. package/dist/esm/auth/passwordless.d.mts +0 -165
  152. package/dist/esm/auth/passwordless.mjs +0 -169
  153. package/dist/esm/auth/tokenExchange.d.mts +0 -166
  154. package/dist/esm/auth/tokenExchange.mjs +0 -70
  155. package/dist/esm/lib/index.d.mts +0 -3
  156. package/dist/esm/lib/index.mjs +0 -2
  157. package/dist/esm/lib/runtime.d.mts +0 -61
  158. package/dist/esm/lib/runtime.mjs +0 -201
  159. package/dist/esm/userinfo/index.d.mts +0 -87
  160. package/dist/esm/userinfo/index.mjs +0 -98
@@ -1,157 +0,0 @@
1
- import { InitOverride, JSONApiResponse, TextApiResponse } from "../lib/models.mjs";
2
- import { BaseAuthAPI } from "./base-auth-api.mjs";
3
- export interface SignUpRequest {
4
- /**
5
- * The client_id of your client.
6
- * Use if you want to override the class's `clientId`
7
- */
8
- client_id?: string;
9
- /**
10
- * The user's email address.
11
- */
12
- email: string;
13
- /**
14
- * The user's desired password.
15
- */
16
- password: string;
17
- /**
18
- * The name of the database configured to your client.
19
- */
20
- connection: string;
21
- /**
22
- * The user's username. Only valid if the connection requires a username.
23
- */
24
- username?: string;
25
- /**
26
- * The user's given name(s).
27
- */
28
- given_name?: string;
29
- /**
30
- * The user's family name(s).
31
- */
32
- family_name?: string;
33
- /**
34
- * The user's full name.
35
- */
36
- name?: string;
37
- /**
38
- *The user's nickname.
39
- */
40
- nickname?: string;
41
- /**
42
- * A URI pointing to the user's picture.
43
- */
44
- picture?: string;
45
- /**
46
- * The user metadata to be associated with the user. If set, the field must be an object containing no more than ten properties. Property names can have a maximum of 100 characters, and property values must be strings of no more than 500 characters.
47
- */
48
- user_metadata?: {
49
- [key: string]: unknown;
50
- };
51
- }
52
- export interface SignUpResponse {
53
- /**
54
- * Email address of the new user.
55
- */
56
- email: string;
57
- /**
58
- * Indicates whether the email has been verified or not.
59
- */
60
- email_verified: boolean;
61
- /**
62
- * The server can return `_id`, `id` or `user_id` depending on various factors.
63
- * For convenience we expose it here as just `id`.
64
- */
65
- id: string;
66
- /**
67
- * Username of this user.
68
- */
69
- username?: string;
70
- /**
71
- * The user's given name(s).
72
- */
73
- given_name?: string;
74
- /**
75
- * The user's family name(s).
76
- */
77
- family_name?: string;
78
- /**
79
- * The user's full name.
80
- */
81
- name?: string;
82
- /**
83
- *The user's nickname.
84
- */
85
- nickname?: string;
86
- /**
87
- * A URI pointing to the user's picture.
88
- */
89
- picture?: string;
90
- /**
91
- * The user metadata to be associated with the user. If set, the field must be an object containing no more than ten properties. Property names can have a maximum of 100 characters, and property values must be strings of no more than 500 characters.
92
- */
93
- user_metadata?: {
94
- [key: string]: unknown;
95
- };
96
- }
97
- export interface ChangePasswordRequest {
98
- /**
99
- * The client_id of your client.
100
- * Use if you want to override the class's `clientId`
101
- */
102
- client_id?: string;
103
- /**
104
- * The user's email address.
105
- */
106
- email: string;
107
- /**
108
- * The name of the database configured to your client.
109
- */
110
- connection: string;
111
- /**
112
- * The organization_id of the Organization associated with the user.
113
- */
114
- organization?: string;
115
- }
116
- /**
117
- * Sign-up and change-password for Database & Active Directory authentication services.
118
- */
119
- export declare class Database extends BaseAuthAPI {
120
- /**
121
- * Given a user's credentials, and a connection, this endpoint will create a new user using active authentication.
122
- *
123
- * This endpoint only works for database connections.
124
- *
125
- * See: https://auth0.com/docs/api/authentication#signup
126
- *
127
- * @example
128
- * ```js
129
- * var data = {
130
- * email: '{EMAIL}',
131
- * password: '{PASSWORD}',
132
- * connection: 'Username-Password-Authentication'
133
- * };
134
- *
135
- * await auth0.database.signUp(data);
136
- * ```
137
- */
138
- signUp(bodyParameters: SignUpRequest, initOverrides?: InitOverride): Promise<JSONApiResponse<SignUpResponse>>;
139
- /**
140
- * Given a user's email address and a connection, Auth0 will send a change password email.
141
- *
142
- * This endpoint only works for database connections.
143
- *
144
- * See: https://auth0.com/docs/api/authentication#change-password
145
- *
146
- * @example
147
- * ```js
148
- * var data = {
149
- * email: '{EMAIL}',
150
- * connection: 'Username-Password-Authentication'
151
- * };
152
- *
153
- * await auth0.database.changePassword(data);
154
- * ```
155
- */
156
- changePassword(bodyParameters: ChangePasswordRequest, initOverrides?: InitOverride): Promise<TextApiResponse>;
157
- }
@@ -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
- }
@@ -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
- }