auth0 4.0.0-beta.6 → 4.0.0-beta.7
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 +11 -8
- package/dist/{types → cjs}/auth/base-auth-api.d.ts +9 -2
- package/dist/cjs/auth/base-auth-api.js +32 -4
- package/dist/cjs/auth/base-auth-api.js.map +1 -1
- package/dist/{types → cjs}/auth/client-authentication.d.ts +1 -1
- package/dist/cjs/auth/client-authentication.js +2 -3
- package/dist/cjs/auth/client-authentication.js.map +1 -1
- package/dist/{types → cjs}/auth/database.d.ts +4 -0
- package/dist/cjs/auth/database.js.map +1 -1
- package/dist/{types → cjs}/auth/oauth.d.ts +2 -8
- package/dist/cjs/auth/oauth.js +8 -35
- package/dist/cjs/auth/oauth.js.map +1 -1
- package/dist/{types → cjs}/auth/passwordless.d.ts +1 -1
- package/dist/cjs/auth/passwordless.js +16 -8
- package/dist/cjs/auth/passwordless.js.map +1 -1
- package/dist/{types → cjs}/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/{types → cjs}/lib/retry.d.ts +1 -1
- package/dist/cjs/lib/retry.js +2 -4
- package/dist/cjs/lib/retry.js.map +1 -1
- package/dist/{types → cjs}/lib/runtime.d.ts +1 -10
- package/dist/cjs/lib/runtime.js +3 -23
- package/dist/cjs/lib/runtime.js.map +1 -1
- package/dist/cjs/management/__generated/managers/jobs-manager.js +1 -1
- package/dist/cjs/management/__generated/managers/jobs-manager.js.map +1 -1
- package/dist/{types → cjs}/management/__generated/models/index.d.ts +1 -3
- package/dist/cjs/management/__generated/models/index.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/auth/base-auth-api.d.ts +39 -0
- package/dist/esm/auth/base-auth-api.js +31 -4
- package/dist/esm/auth/base-auth-api.js.map +1 -1
- package/dist/esm/auth/client-authentication.d.ts +26 -0
- package/dist/esm/auth/client-authentication.js +2 -3
- package/dist/esm/auth/client-authentication.js.map +1 -1
- package/dist/esm/auth/database.d.ts +157 -0
- package/dist/esm/auth/database.js.map +1 -1
- package/dist/esm/auth/id-token-validator.d.ts +18 -0
- package/dist/esm/auth/index.d.ts +15 -0
- package/dist/esm/auth/oauth.d.ts +297 -0
- package/dist/esm/auth/oauth.js +10 -37
- package/dist/esm/auth/oauth.js.map +1 -1
- package/dist/esm/auth/passwordless.d.ts +165 -0
- package/dist/esm/auth/passwordless.js +17 -9
- package/dist/esm/auth/passwordless.js.map +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/errors.d.ts +33 -0
- package/dist/esm/lib/index.d.ts +3 -0
- package/dist/esm/lib/middleware/telemetry-middleware.d.ts +12 -0
- package/dist/esm/lib/models.d.ts +123 -0
- package/dist/esm/lib/retry.d.ts +26 -0
- package/dist/esm/lib/retry.js +2 -4
- package/dist/esm/lib/retry.js.map +1 -1
- package/dist/esm/lib/runtime.d.ts +61 -0
- package/dist/esm/lib/runtime.js +2 -21
- package/dist/esm/lib/runtime.js.map +1 -1
- package/dist/esm/management/__generated/index.d.ts +39 -0
- package/dist/esm/management/__generated/managers/actions-manager.d.ts +136 -0
- package/dist/esm/management/__generated/managers/anomaly-manager.d.ts +24 -0
- package/dist/esm/management/__generated/managers/attack-protection-manager.d.ts +58 -0
- package/dist/esm/management/__generated/managers/blacklists-manager.d.ts +28 -0
- package/dist/esm/management/__generated/managers/branding-manager.d.ts +103 -0
- package/dist/esm/management/__generated/managers/client-grants-manager.d.ts +42 -0
- package/dist/esm/management/__generated/managers/clients-manager.d.ts +168 -0
- package/dist/esm/management/__generated/managers/connections-manager.d.ts +87 -0
- package/dist/esm/management/__generated/managers/custom-domains-manager.d.ts +106 -0
- package/dist/esm/management/__generated/managers/device-credentials-manager.d.ts +42 -0
- package/dist/esm/management/__generated/managers/email-templates-manager.d.ts +38 -0
- package/dist/esm/management/__generated/managers/emails-manager.d.ts +40 -0
- package/dist/esm/management/__generated/managers/grants-manager.d.ts +34 -0
- package/dist/esm/management/__generated/managers/guardian-manager.d.ts +240 -0
- package/dist/esm/management/__generated/managers/hooks-manager.d.ts +90 -0
- package/dist/esm/management/__generated/managers/index.d.ts +31 -0
- package/dist/esm/management/__generated/managers/jobs-manager.d.ts +47 -0
- package/dist/esm/management/__generated/managers/jobs-manager.js +1 -1
- package/dist/esm/management/__generated/managers/jobs-manager.js.map +1 -1
- package/dist/esm/management/__generated/managers/keys-manager.d.ts +34 -0
- package/dist/esm/management/__generated/managers/log-streams-manager.d.ts +326 -0
- package/dist/esm/management/__generated/managers/logs-manager.d.ts +56 -0
- package/dist/esm/management/__generated/managers/organizations-manager.d.ts +191 -0
- package/dist/esm/management/__generated/managers/prompts-manager.d.ts +42 -0
- package/dist/esm/management/__generated/managers/resource-servers-manager.d.ts +48 -0
- package/dist/esm/management/__generated/managers/roles-manager.d.ts +110 -0
- package/dist/esm/management/__generated/managers/rules-configs-manager.d.ts +33 -0
- package/dist/esm/management/__generated/managers/rules-manager.d.ts +55 -0
- package/dist/esm/management/__generated/managers/stats-manager.d.ts +24 -0
- package/dist/esm/management/__generated/managers/tenants-manager.d.ts +24 -0
- package/dist/esm/management/__generated/managers/tickets-manager.d.ts +24 -0
- package/dist/esm/management/__generated/managers/user-blocks-manager.d.ts +45 -0
- package/dist/esm/management/__generated/managers/users-by-email-manager.d.ts +22 -0
- package/dist/esm/management/__generated/managers/users-manager.d.ts +329 -0
- package/dist/esm/management/__generated/models/index.d.ts +13201 -0
- package/dist/esm/management/__generated/models/index.js.map +1 -1
- package/dist/esm/management/index.d.ts +3 -0
- package/dist/esm/management/management-client-options.d.ts +17 -0
- package/dist/esm/management/management-client.d.ts +16 -0
- package/dist/esm/management/token-provider-middleware.d.ts +7 -0
- package/dist/esm/management/token-provider.d.ts +21 -0
- package/dist/esm/userinfo/index.d.ts +55 -0
- package/dist/esm/utils.d.ts +10 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +1 -1
- package/package.json +16 -20
- package/dist/types/version.d.ts +0 -1
- /package/dist/{types → cjs}/auth/id-token-validator.d.ts +0 -0
- /package/dist/{types → cjs}/auth/index.d.ts +0 -0
- /package/dist/{types → cjs}/lib/errors.d.ts +0 -0
- /package/dist/{types → cjs}/lib/index.d.ts +0 -0
- /package/dist/{types → cjs}/lib/middleware/telemetry-middleware.d.ts +0 -0
- /package/dist/{types → cjs}/lib/models.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/index.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/actions-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/anomaly-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/attack-protection-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/blacklists-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/branding-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/client-grants-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/clients-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/connections-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/custom-domains-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/device-credentials-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/email-templates-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/emails-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/grants-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/guardian-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/hooks-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/index.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/jobs-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/keys-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/log-streams-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/logs-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/organizations-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/prompts-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/resource-servers-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/roles-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/rules-configs-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/rules-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/stats-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/tenants-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/tickets-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/user-blocks-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/users-by-email-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/__generated/managers/users-manager.d.ts +0 -0
- /package/dist/{types → cjs}/management/index.d.ts +0 -0
- /package/dist/{types → cjs}/management/management-client-options.d.ts +0 -0
- /package/dist/{types → cjs}/management/management-client.d.ts +0 -0
- /package/dist/{types → cjs}/management/token-provider-middleware.d.ts +0 -0
- /package/dist/{types → cjs}/management/token-provider.d.ts +0 -0
- /package/dist/{types → cjs}/userinfo/index.d.ts +0 -0
- /package/dist/{types → cjs}/utils.d.ts +0 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { InitOverride, JSONApiResponse, VoidApiResponse } from '../lib/runtime.js';
|
|
2
|
+
import { BaseAuthAPI, AuthenticationClientOptions } from './base-auth-api.js';
|
|
3
|
+
import { IDTokenValidateOptions } from './id-token-validator.js';
|
|
4
|
+
export interface TokenSet {
|
|
5
|
+
/**
|
|
6
|
+
* The access token.
|
|
7
|
+
*/
|
|
8
|
+
access_token: string;
|
|
9
|
+
/**
|
|
10
|
+
* The refresh token, vavailable with the `offline_access` scope.
|
|
11
|
+
*/
|
|
12
|
+
refresh_token?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The user's ID Token.
|
|
15
|
+
*/
|
|
16
|
+
id_token?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The token type of the access token.
|
|
19
|
+
*/
|
|
20
|
+
token_type: 'Bearer';
|
|
21
|
+
/**
|
|
22
|
+
* The duration in secs that that the access token is valid.
|
|
23
|
+
*/
|
|
24
|
+
expires_in: number;
|
|
25
|
+
}
|
|
26
|
+
export interface GrantOptions {
|
|
27
|
+
idTokenValidateOptions?: Pick<IDTokenValidateOptions, 'organization'>;
|
|
28
|
+
initOverrides?: InitOverride;
|
|
29
|
+
}
|
|
30
|
+
export interface AuthorizationCodeGrantOptions {
|
|
31
|
+
idTokenValidateOptions?: IDTokenValidateOptions;
|
|
32
|
+
initOverrides?: InitOverride;
|
|
33
|
+
}
|
|
34
|
+
export interface ClientCredentials {
|
|
35
|
+
/**
|
|
36
|
+
* Specify this to override the parent class's `clientId`
|
|
37
|
+
*/
|
|
38
|
+
client_id?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Specify this to override the parent class's `clientSecret`
|
|
41
|
+
*/
|
|
42
|
+
client_secret?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Specify this to provide your own client assertion JWT rather than
|
|
45
|
+
* the class creating one for you from the `clientAssertionSigningKey`.
|
|
46
|
+
*/
|
|
47
|
+
client_assertion?: string;
|
|
48
|
+
/**
|
|
49
|
+
* If you provide your own `client_assertion` you should also provide
|
|
50
|
+
* the `client_assertion_type`.
|
|
51
|
+
*/
|
|
52
|
+
client_assertion_type?: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
|
|
53
|
+
}
|
|
54
|
+
export interface AuthorizationCodeGrantRequest extends ClientCredentials {
|
|
55
|
+
/**
|
|
56
|
+
* The Authorization Code received from the initial `/authorize` call.
|
|
57
|
+
*/
|
|
58
|
+
code: string;
|
|
59
|
+
/**
|
|
60
|
+
* This is required only if it was set at the `/authorize` endpoint. The values must match.
|
|
61
|
+
*/
|
|
62
|
+
redirect_uri?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Allow for any custom property to be sent to Auth0
|
|
65
|
+
*/
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
}
|
|
68
|
+
export interface AuthorizationCodeGrantWithPKCERequest extends AuthorizationCodeGrantRequest {
|
|
69
|
+
/**
|
|
70
|
+
* Cryptographically random key that was used to generate the code_challenge passed to `/authorize`.
|
|
71
|
+
*/
|
|
72
|
+
code_verifier: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ClientCredentialsGrantRequest extends ClientCredentials {
|
|
75
|
+
/**
|
|
76
|
+
* The unique identifier of the target API you want to access.
|
|
77
|
+
*/
|
|
78
|
+
audience: string;
|
|
79
|
+
}
|
|
80
|
+
export interface PasswordGrantRequest extends ClientCredentials {
|
|
81
|
+
/**
|
|
82
|
+
* The unique identifier of the target API you want to access.
|
|
83
|
+
*/
|
|
84
|
+
audience?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Resource Owner's identifier, such as a username or email address.
|
|
87
|
+
*/
|
|
88
|
+
username: string;
|
|
89
|
+
/**
|
|
90
|
+
* Resource Owner's secret.
|
|
91
|
+
*/
|
|
92
|
+
password: string;
|
|
93
|
+
/**
|
|
94
|
+
* String value of the different scopes the application is asking for. Multiple scopes are separated with whitespace.
|
|
95
|
+
*/
|
|
96
|
+
scope?: string;
|
|
97
|
+
/**
|
|
98
|
+
* String value of the realm the user belongs. Set this if you want to add realm support at this grant.
|
|
99
|
+
* For more information on what realms are refer to https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow#realm-support.
|
|
100
|
+
*/
|
|
101
|
+
realm?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface DeviceCodeGrantRequest {
|
|
104
|
+
/**
|
|
105
|
+
* Specify this to override the parent class's `clientId`
|
|
106
|
+
*/
|
|
107
|
+
client_id?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The device code previously returned from the `/oauth/device/code` endpoint.
|
|
110
|
+
*/
|
|
111
|
+
device_code: string;
|
|
112
|
+
}
|
|
113
|
+
export interface RefreshTokenGrantRequest extends ClientCredentials {
|
|
114
|
+
/**
|
|
115
|
+
* The Refresh Token to use.
|
|
116
|
+
*/
|
|
117
|
+
refresh_token: string;
|
|
118
|
+
/**
|
|
119
|
+
* A space-delimited list of requested scope permissions.
|
|
120
|
+
* If not sent, the original scopes will be used; otherwise you can request a reduced set of scopes.
|
|
121
|
+
*/
|
|
122
|
+
scope?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Allow for any custom property to be sent to Auth0
|
|
125
|
+
*/
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
}
|
|
128
|
+
export interface RevokeRefreshTokenRequest extends ClientCredentials {
|
|
129
|
+
/**
|
|
130
|
+
* The Refresh Token you want to revoke.
|
|
131
|
+
*/
|
|
132
|
+
token: string;
|
|
133
|
+
}
|
|
134
|
+
export interface TokenExchangeGrantRequest {
|
|
135
|
+
/**
|
|
136
|
+
* Specify this to override the parent class's `clientId`
|
|
137
|
+
*/
|
|
138
|
+
client_id?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Externally-issued identity artifact, representing the user.
|
|
141
|
+
*/
|
|
142
|
+
subject_token: string;
|
|
143
|
+
/**
|
|
144
|
+
* The unique identifier of the target API you want to access.
|
|
145
|
+
*/
|
|
146
|
+
audience?: string;
|
|
147
|
+
/**
|
|
148
|
+
* String value of the different scopes the application is requesting.
|
|
149
|
+
* Multiple scopes are separated with whitespace.
|
|
150
|
+
*/
|
|
151
|
+
scope?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Optional element used for native iOS interactions for which profile updates can occur.
|
|
154
|
+
* Expected parameter value will be JSON in the form of: `{ name: { firstName: 'John', lastName: 'Smith }}`
|
|
155
|
+
*/
|
|
156
|
+
user_profile: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* OAuth 2.0 flows.
|
|
160
|
+
*/
|
|
161
|
+
export declare class OAuth extends BaseAuthAPI {
|
|
162
|
+
private idTokenValidator;
|
|
163
|
+
constructor(options: AuthenticationClientOptions);
|
|
164
|
+
/**
|
|
165
|
+
* This is the flow that regular web apps use to access an API.
|
|
166
|
+
*
|
|
167
|
+
* Use this endpoint to exchange an Authorization Code for a Token.
|
|
168
|
+
*
|
|
169
|
+
* See: https://auth0.com/docs/api/authentication#authorization-code-flow44
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```js
|
|
173
|
+
* const auth0 = new AuthenticationApi({
|
|
174
|
+
* domain: 'my-domain.auth0.com',
|
|
175
|
+
* clientId: 'myClientId',
|
|
176
|
+
* clientSecret: 'myClientSecret'
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* await auth0.oauth.authorizationCodeGrant({ code: 'mycode' });
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
authorizationCodeGrant(bodyParameters: AuthorizationCodeGrantRequest, options?: AuthorizationCodeGrantOptions): Promise<JSONApiResponse<TokenSet>>;
|
|
183
|
+
/**
|
|
184
|
+
* PKCE was originally designed to protect the authorization code flow in mobile apps,
|
|
185
|
+
* but its ability to prevent authorization code injection makes it useful for every type of OAuth client,
|
|
186
|
+
* even web apps that use client authentication.
|
|
187
|
+
*
|
|
188
|
+
* See: https://auth0.com/docs/api/authentication#authorization-code-flow-with-pkce45
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```js
|
|
192
|
+
* const auth0 = new AuthenticationApi({
|
|
193
|
+
* domain: 'my-domain.auth0.com',
|
|
194
|
+
* clientId: 'myClientId',
|
|
195
|
+
* clientSecret: 'myClientSecret'
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* await auth0.oauth.authorizationCodeGrantWithPKCE({
|
|
199
|
+
* code: 'mycode',
|
|
200
|
+
* code_verifier: 'mycodeverifier'
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
authorizationCodeGrantWithPKCE(bodyParameters: AuthorizationCodeGrantWithPKCERequest, options?: AuthorizationCodeGrantOptions): Promise<JSONApiResponse<TokenSet>>;
|
|
205
|
+
/**
|
|
206
|
+
* This is the OAuth 2.0 grant that server processes use to access an API.
|
|
207
|
+
*
|
|
208
|
+
* Use this endpoint to directly request an Access Token by using the Client's credentials
|
|
209
|
+
* (a Client ID and a Client Secret or a Client Assertion).
|
|
210
|
+
*
|
|
211
|
+
* See: https://auth0.com/docs/api/authentication#client-credentials-flow
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```js
|
|
215
|
+
* const auth0 = new AuthenticationApi({
|
|
216
|
+
* domain: 'my-domain.auth0.com',
|
|
217
|
+
* clientId: 'myClientId',
|
|
218
|
+
* clientSecret: 'myClientSecret'
|
|
219
|
+
* });
|
|
220
|
+
*
|
|
221
|
+
* await auth0.oauth.clientCredentialsGrant({ audience: 'myaudience' });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
clientCredentialsGrant(bodyParameters: ClientCredentialsGrantRequest, options?: {
|
|
225
|
+
initOverrides?: InitOverride;
|
|
226
|
+
}): Promise<JSONApiResponse<TokenSet>>;
|
|
227
|
+
/**
|
|
228
|
+
* This information is typically received from a highly trusted public client like a SPA*.
|
|
229
|
+
* (<strong>*Note:</string> For single-page applications and native/mobile apps, we recommend using web flows instead.)
|
|
230
|
+
*
|
|
231
|
+
* See: https://auth0.com/docs/api/authentication#resource-owner-password
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```js
|
|
235
|
+
* const auth0 = new AuthenticationApi({
|
|
236
|
+
* domain: 'my-domain.auth0.com',
|
|
237
|
+
* clientId: 'myClientId'
|
|
238
|
+
* clientSecret: 'myClientSecret'
|
|
239
|
+
* });
|
|
240
|
+
*
|
|
241
|
+
* await auth0.oauth.passwordGrant({
|
|
242
|
+
* username: 'myusername@example.com',
|
|
243
|
+
* password: 'mypassword'
|
|
244
|
+
* },
|
|
245
|
+
* { initOverrides: { headers: { 'auth0-forwarded-for': 'END.USER.IP.123' } } }
|
|
246
|
+
* );
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* Set the'auth0-forwarded-for' header to the end-user IP as a string value if you want
|
|
250
|
+
* brute-force protection to work in server-side scenarios.
|
|
251
|
+
*
|
|
252
|
+
* See https://auth0.com/docs/get-started/authentication-and-authorization-flow/avoid-common-issues-with-resource-owner-password-flow-and-attack-protection
|
|
253
|
+
*
|
|
254
|
+
*/
|
|
255
|
+
passwordGrant(bodyParameters: PasswordGrantRequest, options?: GrantOptions): Promise<JSONApiResponse<TokenSet>>;
|
|
256
|
+
/**
|
|
257
|
+
* Use this endpoint to refresh an Access Token using the Refresh Token you got during authorization.
|
|
258
|
+
*
|
|
259
|
+
* See: https://auth0.com/docs/api/authentication#refresh-token
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```js
|
|
263
|
+
* const auth0 = new AuthenticationApi({
|
|
264
|
+
* domain: 'my-domain.auth0.com',
|
|
265
|
+
* clientId: 'myClientId'
|
|
266
|
+
* clientSecret: 'myClientSecret'
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* await auth0.oauth.refreshTokenGrant({ refresh_token: 'myrefreshtoken' })
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
refreshTokenGrant(bodyParameters: RefreshTokenGrantRequest, options?: GrantOptions): Promise<JSONApiResponse<TokenSet>>;
|
|
273
|
+
/**
|
|
274
|
+
* Use this endpoint to invalidate a Refresh Token if it has been compromised.
|
|
275
|
+
*
|
|
276
|
+
* The behaviour of this endpoint depends on the state of the <a href="https://auth0.com/docs/secure/tokens/refresh-tokens/revoke-refresh-tokens#refresh-tokens-and-grants">Refresh Token Revocation Deletes Grant</a> toggle.
|
|
277
|
+
* If this toggle is enabled, then each revocation request invalidates not only the specific token, but all other tokens based on the same authorization grant.
|
|
278
|
+
* This means that all Refresh Tokens that have been issued for the same user, application, and audience will be revoked.
|
|
279
|
+
* If this toggle is disabled, then only the refresh token is revoked, while the grant is left intact.
|
|
280
|
+
*
|
|
281
|
+
* See: https://auth0.com/docs/api/authentication#revoke-refresh-token
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```js
|
|
285
|
+
* const auth0 = new AuthenticationApi({
|
|
286
|
+
* domain: 'my-domain.auth0.com',
|
|
287
|
+
* clientId: 'myClientId'
|
|
288
|
+
* clientSecret: 'myClientSecret'
|
|
289
|
+
* });
|
|
290
|
+
*
|
|
291
|
+
* await auth0.oauth.revokeRefreshToken({ token: 'myrefreshtoken' })
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
revokeRefreshToken(bodyParameters: RevokeRefreshTokenRequest, options?: {
|
|
295
|
+
initOverrides?: InitOverride;
|
|
296
|
+
}): Promise<VoidApiResponse>;
|
|
297
|
+
}
|
package/dist/esm/auth/oauth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseAuthAPI } from './base-auth-api.js';
|
|
1
|
+
import { VoidApiResponse, validateRequiredRequestParams, } from '../lib/runtime.js';
|
|
2
|
+
import { BaseAuthAPI, grant } from './base-auth-api.js';
|
|
3
3
|
import { IDTokenValidator } from './id-token-validator.js';
|
|
4
4
|
/**
|
|
5
5
|
* OAuth 2.0 flows.
|
|
@@ -9,33 +9,6 @@ export class OAuth extends BaseAuthAPI {
|
|
|
9
9
|
super(options);
|
|
10
10
|
this.idTokenValidator = new IDTokenValidator(options);
|
|
11
11
|
}
|
|
12
|
-
async validateIdToken(tokenSet, idTokenValidateOptions) {
|
|
13
|
-
const { id_token: idToken } = tokenSet;
|
|
14
|
-
if (idToken) {
|
|
15
|
-
await this.idTokenValidator.validate(idToken, idTokenValidateOptions);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Perform an OAuth 2.0 grant.
|
|
20
|
-
* (You should only need this if you can't find the grant you need in this library.)
|
|
21
|
-
*/
|
|
22
|
-
async grant(grantType, bodyParameters, { idTokenValidateOptions, initOverrides } = {}) {
|
|
23
|
-
const response = await this.request({
|
|
24
|
-
path: '/oauth/token',
|
|
25
|
-
method: 'POST',
|
|
26
|
-
headers: {
|
|
27
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
28
|
-
},
|
|
29
|
-
body: new URLSearchParams({
|
|
30
|
-
client_id: this.clientId,
|
|
31
|
-
...bodyParameters,
|
|
32
|
-
grant_type: grantType,
|
|
33
|
-
}),
|
|
34
|
-
}, initOverrides);
|
|
35
|
-
const res = await JSONApiResponse.fromResponse(response);
|
|
36
|
-
await this.validateIdToken(res.data, idTokenValidateOptions);
|
|
37
|
-
return res;
|
|
38
|
-
}
|
|
39
12
|
/**
|
|
40
13
|
* This is the flow that regular web apps use to access an API.
|
|
41
14
|
*
|
|
@@ -56,7 +29,7 @@ export class OAuth extends BaseAuthAPI {
|
|
|
56
29
|
*/
|
|
57
30
|
async authorizationCodeGrant(bodyParameters, options = {}) {
|
|
58
31
|
validateRequiredRequestParams(bodyParameters, ['code']);
|
|
59
|
-
return
|
|
32
|
+
return grant('authorization_code', await this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
60
33
|
}
|
|
61
34
|
/**
|
|
62
35
|
* PKCE was originally designed to protect the authorization code flow in mobile apps,
|
|
@@ -81,7 +54,7 @@ export class OAuth extends BaseAuthAPI {
|
|
|
81
54
|
*/
|
|
82
55
|
async authorizationCodeGrantWithPKCE(bodyParameters, options = {}) {
|
|
83
56
|
validateRequiredRequestParams(bodyParameters, ['code', 'code_verifier']);
|
|
84
|
-
return
|
|
57
|
+
return grant('authorization_code', await this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
85
58
|
}
|
|
86
59
|
/**
|
|
87
60
|
* This is the OAuth 2.0 grant that server processes use to access an API.
|
|
@@ -104,7 +77,7 @@ export class OAuth extends BaseAuthAPI {
|
|
|
104
77
|
*/
|
|
105
78
|
async clientCredentialsGrant(bodyParameters, options = {}) {
|
|
106
79
|
validateRequiredRequestParams(bodyParameters, ['audience']);
|
|
107
|
-
return
|
|
80
|
+
return grant('client_credentials', await this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
108
81
|
}
|
|
109
82
|
/**
|
|
110
83
|
* This information is typically received from a highly trusted public client like a SPA*.
|
|
@@ -120,11 +93,11 @@ export class OAuth extends BaseAuthAPI {
|
|
|
120
93
|
* clientSecret: 'myClientSecret'
|
|
121
94
|
* });
|
|
122
95
|
*
|
|
123
|
-
* await auth0.oauth.
|
|
96
|
+
* await auth0.oauth.passwordGrant({
|
|
124
97
|
* username: 'myusername@example.com',
|
|
125
98
|
* password: 'mypassword'
|
|
126
99
|
* },
|
|
127
|
-
* { headers: { 'auth0-forwarded-for': 'END.USER.IP.123' } }
|
|
100
|
+
* { initOverrides: { headers: { 'auth0-forwarded-for': 'END.USER.IP.123' } } }
|
|
128
101
|
* );
|
|
129
102
|
* ```
|
|
130
103
|
*
|
|
@@ -136,7 +109,7 @@ export class OAuth extends BaseAuthAPI {
|
|
|
136
109
|
*/
|
|
137
110
|
async passwordGrant(bodyParameters, options = {}) {
|
|
138
111
|
validateRequiredRequestParams(bodyParameters, ['username', 'password']);
|
|
139
|
-
return
|
|
112
|
+
return grant(bodyParameters.realm ? 'http://auth0.com/oauth/grant-type/password-realm' : 'password', await this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
140
113
|
}
|
|
141
114
|
/**
|
|
142
115
|
* Use this endpoint to refresh an Access Token using the Refresh Token you got during authorization.
|
|
@@ -156,7 +129,7 @@ export class OAuth extends BaseAuthAPI {
|
|
|
156
129
|
*/
|
|
157
130
|
async refreshTokenGrant(bodyParameters, options = {}) {
|
|
158
131
|
validateRequiredRequestParams(bodyParameters, ['refresh_token']);
|
|
159
|
-
return
|
|
132
|
+
return grant('refresh_token', await this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
160
133
|
}
|
|
161
134
|
/**
|
|
162
135
|
* Use this endpoint to invalidate a Refresh Token if it has been compromised.
|
|
@@ -187,7 +160,7 @@ export class OAuth extends BaseAuthAPI {
|
|
|
187
160
|
headers: {
|
|
188
161
|
'Content-Type': 'application/json',
|
|
189
162
|
},
|
|
190
|
-
body: await this.addClientAuthentication({ client_id: this.clientId, ...bodyParameters }
|
|
163
|
+
body: await this.addClientAuthentication({ client_id: this.clientId, ...bodyParameters }),
|
|
191
164
|
}, options.initOverrides);
|
|
192
165
|
return VoidApiResponse.fromResponse(response);
|
|
193
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/auth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/auth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAA+B,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAA0B,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgLnF;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IAEpC,YAAY,OAAoC;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,sBAAsB,CAC1B,cAA6C,EAC7C,UAAyC,EAAE;QAE3C,6BAA6B,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,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
+
import { BaseAuthAPI, AuthenticationClientOptions } from './base-auth-api.js';
|
|
3
|
+
import { ClientCredentials, GrantOptions, TokenSet } from './oauth.js';
|
|
4
|
+
export interface SendEmailLinkRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The user's email address
|
|
7
|
+
*/
|
|
8
|
+
email: string;
|
|
9
|
+
/**
|
|
10
|
+
* Use `link` to send a link or `code` to send a verification code.
|
|
11
|
+
* If omitted, a `link` will be sent.
|
|
12
|
+
*/
|
|
13
|
+
send?: 'link';
|
|
14
|
+
/**
|
|
15
|
+
* Append or override the link parameters (like `scope`, `redirect_uri`, `protocol`, `response_type`),
|
|
16
|
+
* when you send a link using email.
|
|
17
|
+
*/
|
|
18
|
+
authParams?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface SendEmailCodeRequest {
|
|
21
|
+
/**
|
|
22
|
+
* The user's email address
|
|
23
|
+
*/
|
|
24
|
+
email: string;
|
|
25
|
+
/**
|
|
26
|
+
* Use `link` to send a link or `code` to send a verification code.
|
|
27
|
+
* If omitted, a `link` will be sent.
|
|
28
|
+
*/
|
|
29
|
+
send?: 'code';
|
|
30
|
+
}
|
|
31
|
+
export type SendEmailRequest = SendEmailLinkRequest | SendEmailCodeRequest;
|
|
32
|
+
export interface SendSmsRequest {
|
|
33
|
+
/**
|
|
34
|
+
* The users phone number.
|
|
35
|
+
*/
|
|
36
|
+
phone_number: string;
|
|
37
|
+
}
|
|
38
|
+
export interface LoginWithEmailRequest extends ClientCredentials {
|
|
39
|
+
/**
|
|
40
|
+
* The user's email address.
|
|
41
|
+
*/
|
|
42
|
+
email: string;
|
|
43
|
+
/**
|
|
44
|
+
* The user's verification code.
|
|
45
|
+
*/
|
|
46
|
+
code: string;
|
|
47
|
+
/**
|
|
48
|
+
* API Identifier of the API for which you want to get an Access Token.
|
|
49
|
+
*/
|
|
50
|
+
audience?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Use openid to get an ID Token, or openid profile email to also include user profile information in the ID Token.
|
|
53
|
+
*/
|
|
54
|
+
scope?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface LoginWithSMSRequest extends Omit<LoginWithEmailRequest, 'email'> {
|
|
57
|
+
/**
|
|
58
|
+
* The user's phone number.
|
|
59
|
+
*/
|
|
60
|
+
phone_number: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Handles passwordless flows using Email and SMS.
|
|
64
|
+
*/
|
|
65
|
+
export declare class Passwordless extends BaseAuthAPI {
|
|
66
|
+
private idTokenValidator;
|
|
67
|
+
constructor(configuration: AuthenticationClientOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Start passwordless flow sending an email.
|
|
70
|
+
*
|
|
71
|
+
* Given the user `email` address, it will send an email with:
|
|
72
|
+
*
|
|
73
|
+
* <ul>
|
|
74
|
+
* <li>A link (default, `send:"link"`). You can then authenticate with this
|
|
75
|
+
* user opening the link and he will be automatically logged in to the
|
|
76
|
+
* application. Optionally, you can append/override parameters to the link
|
|
77
|
+
* (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using
|
|
78
|
+
* `authParams` object.
|
|
79
|
+
* </li>
|
|
80
|
+
* <li>
|
|
81
|
+
* A verification code (`send:"code"`). You can then authenticate with
|
|
82
|
+
* this user using the `/oauth/token` endpoint specifying `email` as
|
|
83
|
+
* `username` and `code` as `password`.
|
|
84
|
+
* </li>
|
|
85
|
+
* </ul>
|
|
86
|
+
*
|
|
87
|
+
* See: https://auth0.com/docs/api/authentication#get-code-or-link
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```js
|
|
91
|
+
* const auth0 = new AuthenticationApi({
|
|
92
|
+
* domain: 'my-domain.auth0.com',
|
|
93
|
+
* clientId: 'myClientId',
|
|
94
|
+
* clientSecret: 'myClientSecret'
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* await auth0.passwordless.sendEmail({
|
|
98
|
+
* email: '{EMAIL}',
|
|
99
|
+
* send: 'link',
|
|
100
|
+
* authParams: {} // Optional auth params.
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
sendEmail(bodyParameters: SendEmailRequest, initOverrides?: InitOverride): Promise<VoidApiResponse>;
|
|
105
|
+
/**
|
|
106
|
+
* Start passwordless flow sending an SMS.
|
|
107
|
+
*
|
|
108
|
+
* Given the user `phone_number`, it will send a SMS message with a
|
|
109
|
+
* verification code. You can then authenticate with this user using the
|
|
110
|
+
* `/oauth/token` endpoint specifying `phone_number` as `username` and `code` as
|
|
111
|
+
* `password`:
|
|
112
|
+
*
|
|
113
|
+
* See: https://auth0.com/docs/api/authentication#get-code-or-link
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```js
|
|
117
|
+
* const auth0 = new AuthenticationApi({
|
|
118
|
+
* domain: 'my-domain.auth0.com',
|
|
119
|
+
* clientId: 'myClientId',
|
|
120
|
+
* clientSecret: 'myClientSecret'
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* await auth0.passwordless.sendSMS({
|
|
124
|
+
* phone_number: '{PHONE}'
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
sendSMS(bodyParameters: SendSmsRequest, initOverrides?: InitOverride): Promise<VoidApiResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Once you have a verification code, use this endpoint to login the user with their email and verification code.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```js
|
|
134
|
+
* const auth0 = new AuthenticationApi({
|
|
135
|
+
* domain: 'my-domain.auth0.com',
|
|
136
|
+
* clientId: 'myClientId',
|
|
137
|
+
* clientSecret: 'myClientSecret'
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* await auth0.passwordless.loginWithEmail({
|
|
141
|
+
* email: 'foo@example.com',
|
|
142
|
+
* code: 'ABC123'
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
loginWithEmail(bodyParameters: LoginWithEmailRequest, options?: GrantOptions): Promise<JSONApiResponse<TokenSet>>;
|
|
147
|
+
/**
|
|
148
|
+
* Once you have a verification code, use this endpoint to login the user with their phone number and verification code.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```js
|
|
152
|
+
* const auth0 = new AuthenticationApi({
|
|
153
|
+
* domain: 'my-domain.auth0.com',
|
|
154
|
+
* clientId: 'myClientId',
|
|
155
|
+
* clientSecret: 'myClientSecret'
|
|
156
|
+
* });
|
|
157
|
+
*
|
|
158
|
+
* await auth0.passwordless.loginWithSMS({
|
|
159
|
+
* phone_number: '0777777777',
|
|
160
|
+
* code: 'ABC123'
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
loginWithSMS(bodyParameters: LoginWithSMSRequest, options?: GrantOptions): Promise<JSONApiResponse<TokenSet>>;
|
|
165
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { VoidApiResponse, validateRequiredRequestParams, } from '../lib/runtime.js';
|
|
2
|
-
import { BaseAuthAPI } from './base-auth-api.js';
|
|
3
|
-
import {
|
|
2
|
+
import { BaseAuthAPI, grant } from './base-auth-api.js';
|
|
3
|
+
import { IDTokenValidator } from './id-token-validator.js';
|
|
4
4
|
/**
|
|
5
5
|
* Handles passwordless flows using Email and SMS.
|
|
6
6
|
*/
|
|
7
7
|
export class Passwordless extends BaseAuthAPI {
|
|
8
8
|
constructor(configuration) {
|
|
9
9
|
super(configuration);
|
|
10
|
-
this.
|
|
10
|
+
this.idTokenValidator = new IDTokenValidator(configuration);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Start passwordless flow sending an email.
|
|
@@ -53,7 +53,11 @@ export class Passwordless extends BaseAuthAPI {
|
|
|
53
53
|
headers: {
|
|
54
54
|
'Content-Type': 'application/json',
|
|
55
55
|
},
|
|
56
|
-
body: await this.addClientAuthentication({
|
|
56
|
+
body: await this.addClientAuthentication({
|
|
57
|
+
client_id: this.clientId,
|
|
58
|
+
connection: 'email',
|
|
59
|
+
...bodyParameters,
|
|
60
|
+
}),
|
|
57
61
|
}, initOverrides);
|
|
58
62
|
return VoidApiResponse.fromResponse(response);
|
|
59
63
|
}
|
|
@@ -88,7 +92,11 @@ export class Passwordless extends BaseAuthAPI {
|
|
|
88
92
|
headers: {
|
|
89
93
|
'Content-Type': 'application/json',
|
|
90
94
|
},
|
|
91
|
-
body: await this.addClientAuthentication({
|
|
95
|
+
body: await this.addClientAuthentication({
|
|
96
|
+
client_id: this.clientId,
|
|
97
|
+
connection: 'sms',
|
|
98
|
+
...bodyParameters,
|
|
99
|
+
}),
|
|
92
100
|
}, initOverrides);
|
|
93
101
|
return VoidApiResponse.fromResponse(response);
|
|
94
102
|
}
|
|
@@ -112,12 +120,12 @@ export class Passwordless extends BaseAuthAPI {
|
|
|
112
120
|
async loginWithEmail(bodyParameters, options = {}) {
|
|
113
121
|
validateRequiredRequestParams(bodyParameters, ['email', 'code']);
|
|
114
122
|
const { email: username, code: otp, ...otherParams } = bodyParameters;
|
|
115
|
-
return
|
|
123
|
+
return grant('http://auth0.com/oauth/grant-type/passwordless/otp', await this.addClientAuthentication({
|
|
116
124
|
username,
|
|
117
125
|
otp,
|
|
118
126
|
realm: 'email',
|
|
119
127
|
...otherParams,
|
|
120
|
-
},
|
|
128
|
+
}), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
121
129
|
}
|
|
122
130
|
/**
|
|
123
131
|
* Once you have a verification code, use this endpoint to login the user with their phone number and verification code.
|
|
@@ -139,12 +147,12 @@ export class Passwordless extends BaseAuthAPI {
|
|
|
139
147
|
async loginWithSMS(bodyParameters, options = {}) {
|
|
140
148
|
validateRequiredRequestParams(bodyParameters, ['phone_number', 'code']);
|
|
141
149
|
const { phone_number: username, code: otp, ...otherParams } = bodyParameters;
|
|
142
|
-
return
|
|
150
|
+
return grant('http://auth0.com/oauth/grant-type/passwordless/otp', await this.addClientAuthentication({
|
|
143
151
|
username,
|
|
144
152
|
otp,
|
|
145
153
|
realm: 'sms',
|
|
146
154
|
...otherParams,
|
|
147
|
-
},
|
|
155
|
+
}), options, this.clientId, this.idTokenValidator, this.request.bind(this));
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
//# sourceMappingURL=passwordless.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passwordless.js","sourceRoot":"","sources":["../../../src/auth/passwordless.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAA+B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"passwordless.js","sourceRoot":"","sources":["../../../src/auth/passwordless.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAA+B,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAmE3D;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAE3C,YAAY,aAA0C;QACpD,KAAK,CAAC,aAAa,CAAC,CAAC;QAErB,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,KAAK,CAAC,SAAS,CACb,cAAgC,EAChC,aAA4B;QAE5B,6BAA6B,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAEzD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CACjC;YACE,IAAI,EAAE,qBAAqB;YAC3B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,MAAM,IAAI,CAAC,uB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