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,158 +0,0 @@
|
|
|
1
|
-
import { BaseAuthAPI } from "./base-auth-api.js";
|
|
2
|
-
/**
|
|
3
|
-
* The response from the authorize endpoint.
|
|
4
|
-
*/
|
|
5
|
-
export type AuthorizeResponse = {
|
|
6
|
-
/**
|
|
7
|
-
* The authorization request ID.
|
|
8
|
-
*/
|
|
9
|
-
auth_req_id: string;
|
|
10
|
-
/**
|
|
11
|
-
* The duration in seconds until the authentication request expires.
|
|
12
|
-
*/
|
|
13
|
-
expires_in: number;
|
|
14
|
-
/**
|
|
15
|
-
* The interval in seconds to wait between poll requests.
|
|
16
|
-
*/
|
|
17
|
-
interval: number;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Options for the authorize request.
|
|
21
|
-
*/
|
|
22
|
-
export type AuthorizeOptions = {
|
|
23
|
-
/**
|
|
24
|
-
* A human-readable string intended to be displayed on both the device calling /bc-authorize and the user’s authentication device.
|
|
25
|
-
*/
|
|
26
|
-
binding_message: string;
|
|
27
|
-
/**
|
|
28
|
-
* A space-separated list of OIDC and custom API scopes.
|
|
29
|
-
*/
|
|
30
|
-
scope: string;
|
|
31
|
-
/**
|
|
32
|
-
* Unique identifier of the audience for an issued token.
|
|
33
|
-
*/
|
|
34
|
-
audience?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Custom expiry time in seconds for this request.
|
|
37
|
-
* @deprecated Use {@link AuthorizeOptions.requested_expiry} instead.
|
|
38
|
-
*/
|
|
39
|
-
request_expiry?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Custom expiry time in seconds for this request.
|
|
42
|
-
*/
|
|
43
|
-
requested_expiry?: string;
|
|
44
|
-
/**
|
|
45
|
-
* The user ID.
|
|
46
|
-
*/
|
|
47
|
-
userId: string;
|
|
48
|
-
/**
|
|
49
|
-
* Optional parameter for subject issuer context.
|
|
50
|
-
*/
|
|
51
|
-
subjectIssuerContext?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Optional authorization details to use Rich Authorization Requests (RAR).
|
|
54
|
-
* @see https://auth0.com/docs/get-started/apis/configure-rich-authorization-requests
|
|
55
|
-
*/
|
|
56
|
-
authorization_details?: string;
|
|
57
|
-
} & Record<string, string>;
|
|
58
|
-
export interface AuthorizationDetails {
|
|
59
|
-
readonly type: string;
|
|
60
|
-
readonly [parameter: string]: unknown;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The response from the token endpoint.
|
|
64
|
-
*/
|
|
65
|
-
export type TokenResponse = {
|
|
66
|
-
/**
|
|
67
|
-
* The access token.
|
|
68
|
-
*/
|
|
69
|
-
access_token: string;
|
|
70
|
-
/**
|
|
71
|
-
* The refresh token, available with the `offline_access` scope.
|
|
72
|
-
*/
|
|
73
|
-
refresh_token?: string;
|
|
74
|
-
/**
|
|
75
|
-
* The user's ID Token.
|
|
76
|
-
*/
|
|
77
|
-
id_token: string;
|
|
78
|
-
/**
|
|
79
|
-
* The token type of the access token.
|
|
80
|
-
*/
|
|
81
|
-
token_type?: string;
|
|
82
|
-
/**
|
|
83
|
-
* The duration in seconds that the access token is valid.
|
|
84
|
-
*/
|
|
85
|
-
expires_in: number;
|
|
86
|
-
/**
|
|
87
|
-
* The scopes associated with the token.
|
|
88
|
-
*/
|
|
89
|
-
scope: string;
|
|
90
|
-
/**
|
|
91
|
-
* Optional authorization details when using Rich Authorization Requests (RAR).
|
|
92
|
-
* @see https://auth0.com/docs/get-started/apis/configure-rich-authorization-requests
|
|
93
|
-
*/
|
|
94
|
-
authorization_details?: AuthorizationDetails[];
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Options for the token request.
|
|
98
|
-
*/
|
|
99
|
-
export type TokenOptions = {
|
|
100
|
-
/**
|
|
101
|
-
* The authorization request ID.
|
|
102
|
-
*/
|
|
103
|
-
auth_req_id: string;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Interface for the backchannel authentication.
|
|
107
|
-
*/
|
|
108
|
-
export interface IBackchannel {
|
|
109
|
-
authorize: (options: AuthorizeOptions) => Promise<AuthorizeResponse>;
|
|
110
|
-
backchannelGrant: (options: TokenOptions) => Promise<TokenResponse>;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Class implementing the backchannel authentication flow.
|
|
114
|
-
*/
|
|
115
|
-
export declare class Backchannel extends BaseAuthAPI implements IBackchannel {
|
|
116
|
-
/**
|
|
117
|
-
* Initiates a CIBA authorization request.
|
|
118
|
-
*
|
|
119
|
-
* @param {AuthorizeOptions} options - The options for the request.
|
|
120
|
-
* @returns {Promise<AuthorizeResponse>} - The authorization response.
|
|
121
|
-
*
|
|
122
|
-
* @throws {Error} - If the request fails.
|
|
123
|
-
*/
|
|
124
|
-
authorize({ userId, ...options }: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
125
|
-
/**
|
|
126
|
-
* Handles the backchannel grant flow for authentication. Client can poll this method at regular intervals to check if the backchannel auth request has been approved.
|
|
127
|
-
*
|
|
128
|
-
* @param {string} auth_req_id - The authorization request ID. This value is returned from the call to /bc-authorize. Once you have exchanged an auth_req_id for an ID and access token, it is no longer usable.
|
|
129
|
-
* @returns {Promise<TokenResponse>} - A promise that resolves to the token response.
|
|
130
|
-
*
|
|
131
|
-
* @throws {Error} - Throws an error if the request fails.
|
|
132
|
-
*
|
|
133
|
-
* If the authorizing user has not yet approved or rejected the request, you will receive a response like this:
|
|
134
|
-
* ```json
|
|
135
|
-
* {
|
|
136
|
-
* "error": "authorization_pending",
|
|
137
|
-
* "error_description": "The end-user authorization is pending"
|
|
138
|
-
* }
|
|
139
|
-
* ```
|
|
140
|
-
*
|
|
141
|
-
* If the authorizing user rejects the request, you will receive a response like this:
|
|
142
|
-
* ```json
|
|
143
|
-
* {
|
|
144
|
-
* "error": "access_denied",
|
|
145
|
-
* "error_description": "The end-user denied the authorization request or it has been expired"
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*
|
|
149
|
-
* If you are polling too quickly (faster than the interval value returned from /bc-authorize), you will receive a response like this:
|
|
150
|
-
* ```json
|
|
151
|
-
* {
|
|
152
|
-
* "error": "slow_down",
|
|
153
|
-
* "error_description": "You are polling faster than allowed. Try again in 10 seconds."
|
|
154
|
-
* }
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
backchannelGrant({ auth_req_id }: TokenOptions): Promise<TokenResponse>;
|
|
158
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Wednesday, 8 January, 2025
|
|
3
|
-
// Client Initiated Backchannel Authentication (CIBA)
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Backchannel = void 0;
|
|
26
|
-
// CIBA is an OpenID Foundation standard for a decoupled authentication flow. It enables
|
|
27
|
-
// solution developers to build authentication flows where the user logging in does not do so
|
|
28
|
-
// directly on the device that receives the ID or access tokens (the “Consumption Device”), but
|
|
29
|
-
// instead on a separate “Authorization Device”.
|
|
30
|
-
const models_js_1 = require("../lib/models.js");
|
|
31
|
-
const base_auth_api_js_1 = require("./base-auth-api.js");
|
|
32
|
-
/**
|
|
33
|
-
* Generates the login hint for the user.
|
|
34
|
-
*
|
|
35
|
-
* @param {string} userId - The user ID.
|
|
36
|
-
* @param {string} domain - The tenant domain.
|
|
37
|
-
* @returns {string} - The login hint as a JSON string.
|
|
38
|
-
*/
|
|
39
|
-
const getLoginHint = (userId, domain) => {
|
|
40
|
-
// remove trailing '/' from domain, added later for uniformity
|
|
41
|
-
const trimmedDomain = domain.endsWith("/") ? domain.slice(0, -1) : domain;
|
|
42
|
-
const loginHint = {
|
|
43
|
-
format: "iss_sub",
|
|
44
|
-
iss: `https://${trimmedDomain}/`,
|
|
45
|
-
sub: `${userId}`,
|
|
46
|
-
};
|
|
47
|
-
return JSON.stringify(loginHint);
|
|
48
|
-
};
|
|
49
|
-
const CIBA_GRANT_TYPE = "urn:openid:params:grant-type:ciba";
|
|
50
|
-
const CIBA_AUTHORIZE_URL = "/bc-authorize";
|
|
51
|
-
const CIBA_TOKEN_URL = "/oauth/token";
|
|
52
|
-
/**
|
|
53
|
-
* Class implementing the backchannel authentication flow.
|
|
54
|
-
*/
|
|
55
|
-
class Backchannel extends base_auth_api_js_1.BaseAuthAPI {
|
|
56
|
-
/**
|
|
57
|
-
* Initiates a CIBA authorization request.
|
|
58
|
-
*
|
|
59
|
-
* @param {AuthorizeOptions} options - The options for the request.
|
|
60
|
-
* @returns {Promise<AuthorizeResponse>} - The authorization response.
|
|
61
|
-
*
|
|
62
|
-
* @throws {Error} - If the request fails.
|
|
63
|
-
*/
|
|
64
|
-
authorize(_a) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
var { userId } = _a, options = __rest(_a, ["userId"]);
|
|
67
|
-
const body = Object.assign(Object.assign({}, options), { login_hint: getLoginHint(userId, this.domain), client_id: this.clientId });
|
|
68
|
-
// The correct parameter is `requested_expiry`, but we also accept the deprecated `request_expiry` for backwards compatibility
|
|
69
|
-
const requestedExpiry = options.requested_expiry || options.request_expiry;
|
|
70
|
-
if (requestedExpiry) {
|
|
71
|
-
body.requested_expiry = requestedExpiry;
|
|
72
|
-
}
|
|
73
|
-
yield this.addClientAuthentication(body);
|
|
74
|
-
const response = yield this.request.bind(this)({
|
|
75
|
-
path: CIBA_AUTHORIZE_URL,
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
78
|
-
body: new URLSearchParams(body),
|
|
79
|
-
}, {});
|
|
80
|
-
const r = yield models_js_1.JSONApiResponse.fromResponse(response);
|
|
81
|
-
return r.data;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Handles the backchannel grant flow for authentication. Client can poll this method at regular intervals to check if the backchannel auth request has been approved.
|
|
86
|
-
*
|
|
87
|
-
* @param {string} auth_req_id - The authorization request ID. This value is returned from the call to /bc-authorize. Once you have exchanged an auth_req_id for an ID and access token, it is no longer usable.
|
|
88
|
-
* @returns {Promise<TokenResponse>} - A promise that resolves to the token response.
|
|
89
|
-
*
|
|
90
|
-
* @throws {Error} - Throws an error if the request fails.
|
|
91
|
-
*
|
|
92
|
-
* If the authorizing user has not yet approved or rejected the request, you will receive a response like this:
|
|
93
|
-
* ```json
|
|
94
|
-
* {
|
|
95
|
-
* "error": "authorization_pending",
|
|
96
|
-
* "error_description": "The end-user authorization is pending"
|
|
97
|
-
* }
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* If the authorizing user rejects the request, you will receive a response like this:
|
|
101
|
-
* ```json
|
|
102
|
-
* {
|
|
103
|
-
* "error": "access_denied",
|
|
104
|
-
* "error_description": "The end-user denied the authorization request or it has been expired"
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* If you are polling too quickly (faster than the interval value returned from /bc-authorize), you will receive a response like this:
|
|
109
|
-
* ```json
|
|
110
|
-
* {
|
|
111
|
-
* "error": "slow_down",
|
|
112
|
-
* "error_description": "You are polling faster than allowed. Try again in 10 seconds."
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
backchannelGrant(_a) {
|
|
117
|
-
return __awaiter(this, arguments, void 0, function* ({ auth_req_id }) {
|
|
118
|
-
const body = {
|
|
119
|
-
client_id: this.clientId,
|
|
120
|
-
auth_req_id,
|
|
121
|
-
grant_type: CIBA_GRANT_TYPE,
|
|
122
|
-
};
|
|
123
|
-
yield this.addClientAuthentication(body);
|
|
124
|
-
const response = yield this.request.bind(this)({
|
|
125
|
-
path: CIBA_TOKEN_URL,
|
|
126
|
-
method: "POST",
|
|
127
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
128
|
-
body: new URLSearchParams(body),
|
|
129
|
-
}, {});
|
|
130
|
-
const r = yield models_js_1.JSONApiResponse.fromResponse(response);
|
|
131
|
-
return r.data;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.Backchannel = Backchannel;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { BaseAPI, ClientOptions, InitOverrideFunction, JSONApiResponse, RequestOpts } from "../lib/runtime.js";
|
|
2
|
-
import { AddClientAuthenticationPayload } from "./client-authentication.js";
|
|
3
|
-
import { IDTokenValidator } from "./id-token-validator.js";
|
|
4
|
-
import { GrantOptions, TokenSet } from "./oauth.js";
|
|
5
|
-
export interface AuthenticationClientOptions extends ClientOptions {
|
|
6
|
-
domain: string;
|
|
7
|
-
clientId: string;
|
|
8
|
-
clientSecret?: string;
|
|
9
|
-
clientAssertionSigningKey?: string;
|
|
10
|
-
clientAssertionSigningAlg?: string;
|
|
11
|
-
idTokenSigningAlg?: string;
|
|
12
|
-
clockTolerance?: number;
|
|
13
|
-
useMTLS?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare class AuthApiError extends Error {
|
|
16
|
-
error: string;
|
|
17
|
-
error_description: string;
|
|
18
|
-
statusCode: number;
|
|
19
|
-
body: string;
|
|
20
|
-
headers: Headers;
|
|
21
|
-
name: "AuthApiError";
|
|
22
|
-
constructor(error: string, error_description: string, statusCode: number, body: string, headers: Headers);
|
|
23
|
-
}
|
|
24
|
-
export declare class BaseAuthAPI extends BaseAPI {
|
|
25
|
-
domain: string;
|
|
26
|
-
clientId: string;
|
|
27
|
-
clientSecret?: string;
|
|
28
|
-
clientAssertionSigningKey?: string;
|
|
29
|
-
clientAssertionSigningAlg?: string;
|
|
30
|
-
useMTLS?: boolean;
|
|
31
|
-
constructor(options: AuthenticationClientOptions);
|
|
32
|
-
/**
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
protected addClientAuthentication(payload: AddClientAuthenticationPayload): Promise<AddClientAuthenticationPayload>;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @private
|
|
39
|
-
* Perform an OAuth 2.0 grant.
|
|
40
|
-
*/
|
|
41
|
-
export declare function grant(grantType: string, bodyParameters: Record<string, any>, { idTokenValidateOptions, initOverrides }: GrantOptions | undefined, clientId: string, idTokenValidator: IDTokenValidator, request: (context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) => Promise<Response>): Promise<JSONApiResponse<TokenSet>>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.BaseAuthAPI = exports.AuthApiError = void 0;
|
|
13
|
-
exports.grant = grant;
|
|
14
|
-
const errors_js_1 = require("../lib/errors.js");
|
|
15
|
-
const runtime_js_1 = require("../lib/runtime.js");
|
|
16
|
-
const client_authentication_js_1 = require("./client-authentication.js");
|
|
17
|
-
const auth0_client_telemetry_js_1 = require("../lib/middleware/auth0-client-telemetry.js");
|
|
18
|
-
class AuthApiError extends Error {
|
|
19
|
-
constructor(error, error_description, statusCode, body, headers) {
|
|
20
|
-
super(error_description || error);
|
|
21
|
-
this.error = error;
|
|
22
|
-
this.error_description = error_description;
|
|
23
|
-
this.statusCode = statusCode;
|
|
24
|
-
this.body = body;
|
|
25
|
-
this.headers = headers;
|
|
26
|
-
this.name = "AuthApiError";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.AuthApiError = AuthApiError;
|
|
30
|
-
function parseErrorBody(body) {
|
|
31
|
-
const rawData = JSON.parse(body);
|
|
32
|
-
let data;
|
|
33
|
-
if (rawData.error) {
|
|
34
|
-
data = rawData;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
data = {
|
|
38
|
-
error: rawData.code,
|
|
39
|
-
error_description: rawData.description,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return data;
|
|
43
|
-
}
|
|
44
|
-
function parseError(response) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
// Errors typically have a specific format:
|
|
47
|
-
// {
|
|
48
|
-
// error: 'invalid_body',
|
|
49
|
-
// error_description: 'Bad Request',
|
|
50
|
-
// }
|
|
51
|
-
const body = yield response.text();
|
|
52
|
-
try {
|
|
53
|
-
const data = parseErrorBody(body);
|
|
54
|
-
return new AuthApiError(data.error, data.error_description, response.status, body, response.headers);
|
|
55
|
-
}
|
|
56
|
-
catch (_a) {
|
|
57
|
-
return new errors_js_1.ResponseError(response.status, body, response.headers, "Response returned an error code");
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
class BaseAuthAPI extends runtime_js_1.BaseAPI {
|
|
62
|
-
constructor(options) {
|
|
63
|
-
super(Object.assign(Object.assign({}, options), { baseUrl: `https://${options.domain}`, middleware: options.telemetry !== false ? [new auth0_client_telemetry_js_1.Auth0ClientTelemetry(options)] : [], parseError, retry: Object.assign({ enabled: false }, options.retry) }));
|
|
64
|
-
this.domain = options.domain;
|
|
65
|
-
this.clientId = options.clientId;
|
|
66
|
-
this.clientSecret = options.clientSecret;
|
|
67
|
-
this.clientAssertionSigningKey = options.clientAssertionSigningKey;
|
|
68
|
-
this.clientAssertionSigningAlg = options.clientAssertionSigningAlg;
|
|
69
|
-
this.useMTLS = options.useMTLS;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @private
|
|
73
|
-
*/
|
|
74
|
-
addClientAuthentication(payload) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
return (0, client_authentication_js_1.addClientAuthentication)({
|
|
77
|
-
payload,
|
|
78
|
-
domain: this.domain,
|
|
79
|
-
clientId: this.clientId,
|
|
80
|
-
clientSecret: this.clientSecret,
|
|
81
|
-
clientAssertionSigningKey: this.clientAssertionSigningKey,
|
|
82
|
-
clientAssertionSigningAlg: this.clientAssertionSigningAlg,
|
|
83
|
-
useMTLS: this.useMTLS,
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.BaseAuthAPI = BaseAuthAPI;
|
|
89
|
-
/**
|
|
90
|
-
* @private
|
|
91
|
-
* Perform an OAuth 2.0 grant.
|
|
92
|
-
*/
|
|
93
|
-
function grant(grantType_1, bodyParameters_1) {
|
|
94
|
-
return __awaiter(this, arguments, void 0, function* (grantType, bodyParameters, { idTokenValidateOptions, initOverrides } = {}, clientId, idTokenValidator, request) {
|
|
95
|
-
const response = yield request({
|
|
96
|
-
path: "/oauth/token",
|
|
97
|
-
method: "POST",
|
|
98
|
-
headers: {
|
|
99
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
100
|
-
},
|
|
101
|
-
body: new URLSearchParams(Object.assign(Object.assign({ client_id: clientId }, bodyParameters), { grant_type: grantType })),
|
|
102
|
-
}, initOverrides);
|
|
103
|
-
const res = yield runtime_js_1.JSONApiResponse.fromResponse(response);
|
|
104
|
-
if (res.data.id_token) {
|
|
105
|
-
yield idTokenValidator.validate(res.data.id_token, idTokenValidateOptions);
|
|
106
|
-
}
|
|
107
|
-
return res;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface AddClientAuthenticationPayload {
|
|
2
|
-
client_id?: string;
|
|
3
|
-
client_secret?: string;
|
|
4
|
-
client_assertion?: string;
|
|
5
|
-
client_assertion_type?: string;
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
}
|
|
8
|
-
interface AddClientAuthenticationOptions {
|
|
9
|
-
payload: AddClientAuthenticationPayload;
|
|
10
|
-
domain: string;
|
|
11
|
-
clientId: string;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
clientAssertionSigningKey?: string;
|
|
14
|
-
clientAssertionSigningAlg?: string;
|
|
15
|
-
clientSecret?: string;
|
|
16
|
-
useMTLS?: boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Adds client authentication, if available, to the provided payload.
|
|
20
|
-
*
|
|
21
|
-
* Adds `client_secret` for Client Secret Post token endpoint auth method (the SDK doesn't use Client Secret Basic)
|
|
22
|
-
* Adds `client_assertion` and `client_assertion_type` for Private Key JWT token endpoint auth method.
|
|
23
|
-
*
|
|
24
|
-
* If `clientAssertionSigningKey` is provided it takes precedent over `clientSecret` .
|
|
25
|
-
*/
|
|
26
|
-
export declare const addClientAuthentication: ({ payload, domain, clientId, clientAssertionSigningKey, clientAssertionSigningAlg, clientSecret, useMTLS, }: AddClientAuthenticationOptions) => Promise<Record<string, unknown>>;
|
|
27
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.addClientAuthentication = void 0;
|
|
46
|
-
const jose = __importStar(require("jose"));
|
|
47
|
-
const uuid_1 = require("uuid");
|
|
48
|
-
/**
|
|
49
|
-
* Adds client authentication, if available, to the provided payload.
|
|
50
|
-
*
|
|
51
|
-
* Adds `client_secret` for Client Secret Post token endpoint auth method (the SDK doesn't use Client Secret Basic)
|
|
52
|
-
* Adds `client_assertion` and `client_assertion_type` for Private Key JWT token endpoint auth method.
|
|
53
|
-
*
|
|
54
|
-
* If `clientAssertionSigningKey` is provided it takes precedent over `clientSecret` .
|
|
55
|
-
*/
|
|
56
|
-
const addClientAuthentication = (_a) => __awaiter(void 0, [_a], void 0, function* ({ payload, domain, clientId, clientAssertionSigningKey, clientAssertionSigningAlg, clientSecret, useMTLS, }) {
|
|
57
|
-
const cid = payload.client_id || clientId;
|
|
58
|
-
if (clientAssertionSigningKey && !payload.client_assertion) {
|
|
59
|
-
const alg = clientAssertionSigningAlg || "RS256";
|
|
60
|
-
const privateKey = yield jose.importPKCS8(clientAssertionSigningKey, alg);
|
|
61
|
-
payload.client_assertion = yield new jose.SignJWT({})
|
|
62
|
-
.setProtectedHeader({ alg })
|
|
63
|
-
.setIssuedAt()
|
|
64
|
-
.setSubject(cid)
|
|
65
|
-
.setJti((0, uuid_1.v4)())
|
|
66
|
-
.setIssuer(cid)
|
|
67
|
-
.setAudience(`https://${domain}/`)
|
|
68
|
-
.setExpirationTime("2mins")
|
|
69
|
-
.sign(privateKey);
|
|
70
|
-
payload.client_assertion_type = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
|
|
71
|
-
}
|
|
72
|
-
else if (clientSecret && !payload.client_secret) {
|
|
73
|
-
payload.client_secret = clientSecret;
|
|
74
|
-
}
|
|
75
|
-
if ((!payload.client_secret || payload.client_secret.trim().length === 0) &&
|
|
76
|
-
(!payload.client_assertion || payload.client_assertion.trim().length === 0) &&
|
|
77
|
-
!useMTLS) {
|
|
78
|
-
throw new Error("The client_secret or client_assertion field is required, or it should be mTLS request.");
|
|
79
|
-
}
|
|
80
|
-
return payload;
|
|
81
|
-
});
|
|
82
|
-
exports.addClientAuthentication = addClientAuthentication;
|