@tktchurch/auth 0.9.1 → 0.9.6
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/CHANGELOG.md +112 -41
- package/PUBLISHING.md +34 -20
- package/README.md +66 -36
- package/SECURITY.md +47 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +80 -25
- package/dist/index.d.ts +80 -25
- package/dist/index.js +1 -1
- package/dist/memory-DNWYyNSB.d.cts +1379 -0
- package/dist/memory-DNWYyNSB.d.ts +1379 -0
- package/dist/storage/memory.d.cts +1 -1
- package/dist/storage/memory.d.ts +1 -1
- package/package.json +1 -1
- package/dist/memory-CVWZvsJ0.d.cts +0 -730
- package/dist/memory-CVWZvsJ0.d.ts +0 -730
|
@@ -1,730 +0,0 @@
|
|
|
1
|
-
interface OAuthAuthorizationServerMetadata {
|
|
2
|
-
issuer: string;
|
|
3
|
-
authorizationEndpoint: string;
|
|
4
|
-
tokenEndpoint: string;
|
|
5
|
-
jwksUri?: string;
|
|
6
|
-
revocationEndpoint?: string;
|
|
7
|
-
introspectionEndpoint?: string;
|
|
8
|
-
registrationEndpoint?: string;
|
|
9
|
-
scopesSupported?: string[];
|
|
10
|
-
responseTypesSupported: string[];
|
|
11
|
-
grantTypesSupported?: string[];
|
|
12
|
-
codeChallengeMethodsSupported?: string[];
|
|
13
|
-
/** RFC 9126 pushed authorization request endpoint. */
|
|
14
|
-
pushedAuthorizationRequestEndpoint?: string;
|
|
15
|
-
/** RFC 9126: whether the server requires PAR. */
|
|
16
|
-
requirePushedAuthorizationRequests?: boolean;
|
|
17
|
-
/** RFC 9396 supported authorization details types. */
|
|
18
|
-
authorizationDetailsTypesSupported?: string[];
|
|
19
|
-
raw: JsonObject;
|
|
20
|
-
}
|
|
21
|
-
interface TokenExchangeRequest {
|
|
22
|
-
subjectToken: string;
|
|
23
|
-
subjectTokenType?: string;
|
|
24
|
-
requestedSubject: string;
|
|
25
|
-
scope?: string;
|
|
26
|
-
audience?: string;
|
|
27
|
-
}
|
|
28
|
-
interface AuthorizationConsentBody {
|
|
29
|
-
username: string;
|
|
30
|
-
password: string;
|
|
31
|
-
approved?: boolean;
|
|
32
|
-
requestedScopes?: string[];
|
|
33
|
-
mfaCode?: string;
|
|
34
|
-
mfaBackupCode?: string;
|
|
35
|
-
}
|
|
36
|
-
interface AuthorizationConsentResponse {
|
|
37
|
-
redirectUri: string;
|
|
38
|
-
code?: string;
|
|
39
|
-
state?: string;
|
|
40
|
-
error?: string;
|
|
41
|
-
errorDescription?: string;
|
|
42
|
-
mfaMethods?: string[];
|
|
43
|
-
accessToken?: string;
|
|
44
|
-
tokenType?: string;
|
|
45
|
-
expiresIn?: number;
|
|
46
|
-
scope?: string;
|
|
47
|
-
idToken?: string;
|
|
48
|
-
}
|
|
49
|
-
interface ConsentWithCredentialsOptions {
|
|
50
|
-
callbackUrl: string;
|
|
51
|
-
username: string;
|
|
52
|
-
password: string;
|
|
53
|
-
approved?: boolean;
|
|
54
|
-
requestedScopes?: string[];
|
|
55
|
-
mfaCode?: string;
|
|
56
|
-
mfaBackupCode?: string;
|
|
57
|
-
}
|
|
58
|
-
interface PublicClientInfo {
|
|
59
|
-
clientId: string;
|
|
60
|
-
name: string;
|
|
61
|
-
description?: string;
|
|
62
|
-
isFirstParty: boolean;
|
|
63
|
-
}
|
|
64
|
-
interface JwksDocument {
|
|
65
|
-
keys: JsonObject[];
|
|
66
|
-
}
|
|
67
|
-
interface InitRecoveryRequest {
|
|
68
|
-
clientId?: string;
|
|
69
|
-
recoveryType?: string;
|
|
70
|
-
redirectUri?: string;
|
|
71
|
-
}
|
|
72
|
-
interface PasswordResetRequestInput {
|
|
73
|
-
email?: string;
|
|
74
|
-
identifier?: string;
|
|
75
|
-
recoveryEmail?: string;
|
|
76
|
-
phoneNumber?: string;
|
|
77
|
-
memberId?: string;
|
|
78
|
-
securityQuestion?: string;
|
|
79
|
-
securityAnswer?: string;
|
|
80
|
-
redirectUri?: string;
|
|
81
|
-
}
|
|
82
|
-
interface PasswordResetRequestResult {
|
|
83
|
-
ok: boolean;
|
|
84
|
-
message: string;
|
|
85
|
-
}
|
|
86
|
-
interface PasswordResetValidationResult {
|
|
87
|
-
ok: boolean;
|
|
88
|
-
valid: boolean;
|
|
89
|
-
expiresAt?: string;
|
|
90
|
-
}
|
|
91
|
-
interface PasswordResetCompleteInput {
|
|
92
|
-
token: string;
|
|
93
|
-
password: string;
|
|
94
|
-
passwordConfirm: string;
|
|
95
|
-
}
|
|
96
|
-
interface PasswordResetCompleteResult {
|
|
97
|
-
ok: boolean;
|
|
98
|
-
message: string;
|
|
99
|
-
}
|
|
100
|
-
interface MfaSetupRequest {
|
|
101
|
-
deviceName: string;
|
|
102
|
-
}
|
|
103
|
-
interface MfaSetupResponse {
|
|
104
|
-
deviceId: string;
|
|
105
|
-
secret: string;
|
|
106
|
-
qrCodeUri: string;
|
|
107
|
-
backupCodes: string[];
|
|
108
|
-
algorithm: string;
|
|
109
|
-
digits: number;
|
|
110
|
-
period: number;
|
|
111
|
-
}
|
|
112
|
-
interface MfaVerifyRequest {
|
|
113
|
-
deviceId: string;
|
|
114
|
-
totpCode: string;
|
|
115
|
-
}
|
|
116
|
-
interface MfaDevice {
|
|
117
|
-
id: string;
|
|
118
|
-
deviceName: string;
|
|
119
|
-
isVerified: boolean;
|
|
120
|
-
isPrimary: boolean;
|
|
121
|
-
createdAt?: string;
|
|
122
|
-
lastUsedAt?: string;
|
|
123
|
-
}
|
|
124
|
-
interface MaintenanceStatus {
|
|
125
|
-
isActive: boolean;
|
|
126
|
-
message?: string;
|
|
127
|
-
scheduledStart?: string;
|
|
128
|
-
scheduledEnd?: string;
|
|
129
|
-
[key: string]: JsonValue | undefined;
|
|
130
|
-
}
|
|
131
|
-
interface RecoveryContact {
|
|
132
|
-
id: string;
|
|
133
|
-
name?: string;
|
|
134
|
-
email?: string;
|
|
135
|
-
phoneNumber?: string;
|
|
136
|
-
relationship?: string;
|
|
137
|
-
isVerified?: boolean;
|
|
138
|
-
[key: string]: JsonValue | undefined;
|
|
139
|
-
}
|
|
140
|
-
interface UserIdentity {
|
|
141
|
-
id: string;
|
|
142
|
-
provider: string;
|
|
143
|
-
providerUserId?: string;
|
|
144
|
-
email?: string;
|
|
145
|
-
isPrimary?: boolean;
|
|
146
|
-
[key: string]: JsonValue | undefined;
|
|
147
|
-
}
|
|
148
|
-
interface AdminEntity {
|
|
149
|
-
id: string;
|
|
150
|
-
[key: string]: JsonValue | undefined;
|
|
151
|
-
}
|
|
152
|
-
interface UserListQuery extends PageQuery {
|
|
153
|
-
search?: string;
|
|
154
|
-
email?: string;
|
|
155
|
-
username?: string;
|
|
156
|
-
isActive?: boolean;
|
|
157
|
-
isVerified?: boolean;
|
|
158
|
-
mfaEnabled?: boolean;
|
|
159
|
-
createdAfter?: string;
|
|
160
|
-
createdBefore?: string;
|
|
161
|
-
sortBy?: string;
|
|
162
|
-
order?: "asc" | "desc";
|
|
163
|
-
}
|
|
164
|
-
interface PasswordResetEndpoints {
|
|
165
|
-
request(input: PasswordResetRequestInput): Promise<PasswordResetRequestResult>;
|
|
166
|
-
validate(token: string): Promise<PasswordResetValidationResult>;
|
|
167
|
-
complete(input: PasswordResetCompleteInput): Promise<PasswordResetCompleteResult>;
|
|
168
|
-
}
|
|
169
|
-
interface MfaEndpoints {
|
|
170
|
-
setup(input: MfaSetupRequest): Promise<MfaSetupResponse>;
|
|
171
|
-
verify(input: MfaVerifyRequest): Promise<JsonObject>;
|
|
172
|
-
devices(): Promise<MfaDevice[]>;
|
|
173
|
-
removeDevice(deviceId: string): Promise<void>;
|
|
174
|
-
regenerateBackupCodes(): Promise<{
|
|
175
|
-
backupCodes: string[];
|
|
176
|
-
}>;
|
|
177
|
-
disable(input?: {
|
|
178
|
-
password?: string;
|
|
179
|
-
}): Promise<void>;
|
|
180
|
-
}
|
|
181
|
-
interface OAuthMetaEndpoints {
|
|
182
|
-
publicClient(clientId: string): Promise<PublicClientInfo>;
|
|
183
|
-
discoverAuthorizationServer(): Promise<OAuthAuthorizationServerMetadata>;
|
|
184
|
-
}
|
|
185
|
-
interface UsersAdminEndpoints {
|
|
186
|
-
list(query?: UserListQuery): Promise<PageResponse<AdminEntity>>;
|
|
187
|
-
create(input: JsonObject): Promise<AdminEntity>;
|
|
188
|
-
get(id: string): Promise<AdminEntity>;
|
|
189
|
-
update(id: string, input: JsonObject): Promise<AdminEntity>;
|
|
190
|
-
delete(id: string): Promise<void>;
|
|
191
|
-
assignRole(userId: string, roleId: string): Promise<void>;
|
|
192
|
-
removeRole(userId: string, roleId: string): Promise<void>;
|
|
193
|
-
setPassword(userId: string, input: JsonObject): Promise<JsonObject>;
|
|
194
|
-
resetMfa(userId: string): Promise<JsonObject>;
|
|
195
|
-
getMfaDevices(userId: string): Promise<MfaDevice[]>;
|
|
196
|
-
getWebAuthnCredentials(userId: string): Promise<unknown[]>;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** JSON primitive value type. */
|
|
200
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
201
|
-
/** JSON value type used in extensible payloads. */
|
|
202
|
-
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
203
|
-
/** JSON object type used in extensible payloads. */
|
|
204
|
-
type JsonObject = {
|
|
205
|
-
[key: string]: JsonValue;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* A single RFC 9396 (Rich Authorization Requests) authorization detail object.
|
|
209
|
-
* `type` is required and identifies the detail type; all other members
|
|
210
|
-
* (`locations`, `actions`, `datatypes`, `identifier`, `privileges`, and any
|
|
211
|
-
* type-specific fields) are open-ended.
|
|
212
|
-
*/
|
|
213
|
-
interface AuthorizationDetail {
|
|
214
|
-
type: string;
|
|
215
|
-
locations?: string[];
|
|
216
|
-
actions?: string[];
|
|
217
|
-
datatypes?: string[];
|
|
218
|
-
identifier?: string;
|
|
219
|
-
privileges?: string[];
|
|
220
|
-
[key: string]: JsonValue | undefined;
|
|
221
|
-
}
|
|
222
|
-
/** Canonical token shape used by SDK storage and endpoint wrappers. */
|
|
223
|
-
interface AuthTokens {
|
|
224
|
-
accessToken: string;
|
|
225
|
-
tokenType: string;
|
|
226
|
-
expiresIn: number;
|
|
227
|
-
refreshToken?: string;
|
|
228
|
-
scope?: string;
|
|
229
|
-
idToken?: string;
|
|
230
|
-
/** RFC 9396 granted authorization details, when returned by the server. */
|
|
231
|
-
authorizationDetails?: AuthorizationDetail[];
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Pluggable token persistence contract.
|
|
235
|
-
*
|
|
236
|
-
* Implementations must:
|
|
237
|
-
* - Never log token values.
|
|
238
|
-
* - Validate payloads on read and write (use `assertValidAuthTokens` / `parseStoredAuthTokens`).
|
|
239
|
-
* - Prefer hardware-backed or server-side storage for refresh tokens in production.
|
|
240
|
-
* - Clear state on unrecoverable auth errors (the client calls `clear()` via `fetchWithAuth`).
|
|
241
|
-
*/
|
|
242
|
-
interface TokenStorage {
|
|
243
|
-
get(): Promise<AuthTokens | null> | AuthTokens | null;
|
|
244
|
-
set(tokens: AuthTokens | null): Promise<void> | void;
|
|
245
|
-
clear(): Promise<void> | void;
|
|
246
|
-
}
|
|
247
|
-
/** Client factory configuration. */
|
|
248
|
-
interface AuthClientConfig {
|
|
249
|
-
clientId: string;
|
|
250
|
-
clientSecret?: string;
|
|
251
|
-
baseUrl?: string;
|
|
252
|
-
fetch?: typeof globalThis.fetch;
|
|
253
|
-
storage?: TokenStorage;
|
|
254
|
-
timeoutMs?: number;
|
|
255
|
-
defaultHeaders?: Record<string, string>;
|
|
256
|
-
autoRefresh?: boolean;
|
|
257
|
-
allowClientSecretInBrowser?: boolean;
|
|
258
|
-
/**
|
|
259
|
-
* Permits `http://` base URLs outside loopback hosts. Default `false`.
|
|
260
|
-
* Use only for trusted local integration tests — never in production.
|
|
261
|
-
*/
|
|
262
|
-
allowInsecureTransport?: boolean;
|
|
263
|
-
}
|
|
264
|
-
/** Resource owner password token request. */
|
|
265
|
-
interface PasswordTokenRequest {
|
|
266
|
-
username?: string;
|
|
267
|
-
email?: string;
|
|
268
|
-
password: string;
|
|
269
|
-
scope?: string;
|
|
270
|
-
mfaCode?: string;
|
|
271
|
-
mfaBackupCode?: string;
|
|
272
|
-
}
|
|
273
|
-
/** Refresh token request. */
|
|
274
|
-
interface RefreshTokenRequest {
|
|
275
|
-
refreshToken?: string;
|
|
276
|
-
scope?: string;
|
|
277
|
-
}
|
|
278
|
-
/** Client credentials request. */
|
|
279
|
-
interface ClientCredentialsRequest {
|
|
280
|
-
scope?: string;
|
|
281
|
-
}
|
|
282
|
-
/** Authorization code token exchange request (with optional PKCE). */
|
|
283
|
-
interface AuthorizationCodeTokenRequest {
|
|
284
|
-
code: string;
|
|
285
|
-
redirectUri: string;
|
|
286
|
-
codeVerifier?: string;
|
|
287
|
-
scope?: string;
|
|
288
|
-
}
|
|
289
|
-
/** Options for building an authorization-code + PKCE redirect request. */
|
|
290
|
-
interface AuthorizationUrlOptions {
|
|
291
|
-
/** Absolute redirect URI registered for this client. */
|
|
292
|
-
redirectUri: string;
|
|
293
|
-
/** Space-delimited scopes. Defaults to `openid profile email offline_access`. */
|
|
294
|
-
scope?: string;
|
|
295
|
-
/** Pre-generated `state`; one is generated (CSPRNG) when omitted. */
|
|
296
|
-
state?: string;
|
|
297
|
-
/** Pre-generated `nonce`; one is generated (CSPRNG) when omitted. */
|
|
298
|
-
nonce?: string;
|
|
299
|
-
/** PKCE challenge method. Defaults to `S256`. */
|
|
300
|
-
codeChallengeMethod?: "S256" | "plain";
|
|
301
|
-
/** OIDC `prompt` parameter (e.g. `login`, `none`, `consent`). */
|
|
302
|
-
prompt?: string;
|
|
303
|
-
/** OIDC `login_hint` to prefill the identifier. */
|
|
304
|
-
loginHint?: string;
|
|
305
|
-
/** OAuth `response_type`. Defaults to `code`. */
|
|
306
|
-
responseType?: string;
|
|
307
|
-
/** Override the authorization endpoint (defaults to `{baseUrl}/oauth/authorize`). */
|
|
308
|
-
authorizationEndpoint?: string;
|
|
309
|
-
/** RFC 9396 rich authorization details to request (serialized as JSON). */
|
|
310
|
-
authorizationDetails?: AuthorizationDetail[];
|
|
311
|
-
/**
|
|
312
|
-
* RFC 9126 pushed-request reference. When set, the SDK builds a slim
|
|
313
|
-
* authorization URL carrying only `client_id` and `request_uri`.
|
|
314
|
-
*/
|
|
315
|
-
requestUri?: string;
|
|
316
|
-
/** Additional non-standard query parameters to append. */
|
|
317
|
-
extraParams?: Record<string, string>;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Everything produced when starting an auth-code flow. The caller MUST persist
|
|
321
|
-
* `state`, `nonce`, `codeVerifier`, and `redirectUri` (e.g. in an httpOnly
|
|
322
|
-
* cookie or server session) and replay them when handling the callback.
|
|
323
|
-
*/
|
|
324
|
-
interface AuthorizationRequest {
|
|
325
|
-
/** Fully-formed authorization URL to redirect the user agent to. */
|
|
326
|
-
url: string;
|
|
327
|
-
/** CSRF anti-forgery token; verify on callback. */
|
|
328
|
-
state: string;
|
|
329
|
-
/** OIDC nonce; bind to the returned ID token. */
|
|
330
|
-
nonce: string;
|
|
331
|
-
/** PKCE verifier; required at token exchange. Treat as a secret. */
|
|
332
|
-
codeVerifier: string;
|
|
333
|
-
/** PKCE challenge that was sent in the URL. */
|
|
334
|
-
codeChallenge: string;
|
|
335
|
-
/** Redirect URI echoed at token exchange. */
|
|
336
|
-
redirectUri: string;
|
|
337
|
-
/** Resolved scope string. */
|
|
338
|
-
scope: string;
|
|
339
|
-
/** RFC 9126 request_uri, present only when the request was pushed via PAR. */
|
|
340
|
-
requestUri?: string;
|
|
341
|
-
}
|
|
342
|
-
/** Options for pushing an authorization request (RFC 9126). */
|
|
343
|
-
interface PushAuthorizationRequestOptions extends AuthorizationUrlOptions {
|
|
344
|
-
}
|
|
345
|
-
/** Result of a successful pushed authorization request (RFC 9126). */
|
|
346
|
-
interface PushedAuthorizationResult {
|
|
347
|
-
/** The `urn:ietf:params:oauth:request_uri:...` reference. */
|
|
348
|
-
requestUri: string;
|
|
349
|
-
/** Lifetime of the request_uri in seconds. */
|
|
350
|
-
expiresIn: number;
|
|
351
|
-
/** The persisted request artefacts (state/nonce/codeVerifier) to replay on callback. */
|
|
352
|
-
request: AuthorizationRequest;
|
|
353
|
-
}
|
|
354
|
-
/** Result of probing `GET /oauth/authorize` with `redirect: manual`. */
|
|
355
|
-
interface AuthorizationProbeResult {
|
|
356
|
-
kind: "redirect" | "json";
|
|
357
|
-
status: number;
|
|
358
|
-
location?: string;
|
|
359
|
-
authorizationUrl?: string;
|
|
360
|
-
payload?: JsonObject;
|
|
361
|
-
}
|
|
362
|
-
/** Parsed authorization-server redirect callback parameters. */
|
|
363
|
-
interface CallbackParams {
|
|
364
|
-
code?: string;
|
|
365
|
-
state?: string;
|
|
366
|
-
error?: string;
|
|
367
|
-
errorDescription?: string;
|
|
368
|
-
errorUri?: string;
|
|
369
|
-
/** Any additional parameters present on the callback URL. */
|
|
370
|
-
raw: Record<string, string>;
|
|
371
|
-
}
|
|
372
|
-
/** Options for the one-call callback handler that validates state and exchanges the code. */
|
|
373
|
-
interface HandleCallbackOptions {
|
|
374
|
-
/** The callback URL, its query string, or pre-parsed params. */
|
|
375
|
-
callback: string | URLSearchParams | Record<string, string> | CallbackParams;
|
|
376
|
-
/** The `state` issued in {@link AuthorizationRequest}; verified constant-time. */
|
|
377
|
-
expectedState: string;
|
|
378
|
-
/** The PKCE verifier issued in {@link AuthorizationRequest}. */
|
|
379
|
-
codeVerifier: string;
|
|
380
|
-
/** The redirect URI issued in {@link AuthorizationRequest}. */
|
|
381
|
-
redirectUri: string;
|
|
382
|
-
/** Optional scope override forwarded to the token exchange. */
|
|
383
|
-
scope?: string;
|
|
384
|
-
}
|
|
385
|
-
/** OIDC discovery document (`/.well-known/openid-configuration`), camelCased subset. */
|
|
386
|
-
interface OidcDiscoveryDocument {
|
|
387
|
-
issuer: string;
|
|
388
|
-
authorizationEndpoint: string;
|
|
389
|
-
tokenEndpoint: string;
|
|
390
|
-
userinfoEndpoint?: string;
|
|
391
|
-
jwksUri: string;
|
|
392
|
-
revocationEndpoint?: string;
|
|
393
|
-
introspectionEndpoint?: string;
|
|
394
|
-
responseTypesSupported: string[];
|
|
395
|
-
grantTypesSupported?: string[];
|
|
396
|
-
scopesSupported?: string[];
|
|
397
|
-
codeChallengeMethodsSupported?: string[];
|
|
398
|
-
/** Raw, unmapped document for fields not surfaced above. */
|
|
399
|
-
raw: JsonObject;
|
|
400
|
-
}
|
|
401
|
-
/** Token revocation request. */
|
|
402
|
-
interface RevokeTokenRequest {
|
|
403
|
-
token?: string;
|
|
404
|
-
tokenTypeHint?: "access_token" | "refresh_token";
|
|
405
|
-
}
|
|
406
|
-
/** Token introspection request. */
|
|
407
|
-
interface IntrospectTokenRequest {
|
|
408
|
-
token: string;
|
|
409
|
-
}
|
|
410
|
-
/** Token introspection response. */
|
|
411
|
-
interface TokenIntrospectionResponse {
|
|
412
|
-
active: boolean;
|
|
413
|
-
scope?: string;
|
|
414
|
-
clientId?: string;
|
|
415
|
-
username?: string;
|
|
416
|
-
tokenType?: string;
|
|
417
|
-
exp?: number;
|
|
418
|
-
iat?: number;
|
|
419
|
-
sub?: string;
|
|
420
|
-
/** RFC 9396 authorization details associated with the token. */
|
|
421
|
-
authorizationDetails?: AuthorizationDetail[];
|
|
422
|
-
}
|
|
423
|
-
/** Individual form field definition required for a flow step. */
|
|
424
|
-
interface StepInputField {
|
|
425
|
-
name: string;
|
|
426
|
-
type: string;
|
|
427
|
-
required: boolean;
|
|
428
|
-
description: string;
|
|
429
|
-
sensitive: boolean;
|
|
430
|
-
}
|
|
431
|
-
/** Input schema definition for a flow step. */
|
|
432
|
-
interface StepInputSchema {
|
|
433
|
-
fields: StepInputField[];
|
|
434
|
-
}
|
|
435
|
-
/** Authentication or registration flow step metadata. */
|
|
436
|
-
interface FlowStep {
|
|
437
|
-
stepId: string;
|
|
438
|
-
stepType: string;
|
|
439
|
-
name: string;
|
|
440
|
-
description?: string;
|
|
441
|
-
order: number;
|
|
442
|
-
isRequired: boolean;
|
|
443
|
-
timeout: number;
|
|
444
|
-
inputSchema?: StepInputSchema;
|
|
445
|
-
}
|
|
446
|
-
/** Auth flow initialization request. */
|
|
447
|
-
interface InitAuthenticationRequest {
|
|
448
|
-
clientId?: string;
|
|
449
|
-
username?: string;
|
|
450
|
-
}
|
|
451
|
-
/** Registration flow initialization request. */
|
|
452
|
-
interface InitRegistrationRequest {
|
|
453
|
-
clientId?: string;
|
|
454
|
-
inviteCode?: string;
|
|
455
|
-
}
|
|
456
|
-
/** Shared response for auth/registration flow initialization. */
|
|
457
|
-
interface FlowInitResponse {
|
|
458
|
-
sessionId: string;
|
|
459
|
-
flowId: string;
|
|
460
|
-
flowName: string;
|
|
461
|
-
currentStep: FlowStep;
|
|
462
|
-
remainingSteps: FlowStep[];
|
|
463
|
-
expiresAt: string;
|
|
464
|
-
}
|
|
465
|
-
/** Execute current flow step request. */
|
|
466
|
-
interface ExecuteStepRequest {
|
|
467
|
-
sessionId: string;
|
|
468
|
-
stepId: string;
|
|
469
|
-
credential: Record<string, string>;
|
|
470
|
-
}
|
|
471
|
-
/** Flow step response when additional steps are still required. */
|
|
472
|
-
interface FlowStepInProgressResult {
|
|
473
|
-
status: "in_progress";
|
|
474
|
-
sessionId: string;
|
|
475
|
-
nextStep: FlowStep;
|
|
476
|
-
completedSteps: string[];
|
|
477
|
-
remainingSteps: FlowStep[];
|
|
478
|
-
}
|
|
479
|
-
/** Flow step response when authentication is complete and tokens are issued. */
|
|
480
|
-
interface FlowStepCompleteResult {
|
|
481
|
-
status: "complete";
|
|
482
|
-
accessToken: string;
|
|
483
|
-
refreshToken?: string;
|
|
484
|
-
tokenType: string;
|
|
485
|
-
expiresIn: number;
|
|
486
|
-
scope?: string;
|
|
487
|
-
amr: string[];
|
|
488
|
-
acr: string;
|
|
489
|
-
}
|
|
490
|
-
/** Discriminated union of flow step execution outcomes. */
|
|
491
|
-
type FlowStepResult = FlowStepInProgressResult | FlowStepCompleteResult;
|
|
492
|
-
/** Full flow session status payload. */
|
|
493
|
-
interface FlowSessionStatus {
|
|
494
|
-
sessionId: string;
|
|
495
|
-
status: string;
|
|
496
|
-
purpose: string;
|
|
497
|
-
currentStep?: FlowStep;
|
|
498
|
-
completedSteps: string[];
|
|
499
|
-
remainingSteps: FlowStep[];
|
|
500
|
-
failedAttempts: number;
|
|
501
|
-
expiresAt: string;
|
|
502
|
-
lastActivityAt: string;
|
|
503
|
-
}
|
|
504
|
-
/** Standard page metadata. */
|
|
505
|
-
interface PageQuery {
|
|
506
|
-
page?: number;
|
|
507
|
-
perPage?: number;
|
|
508
|
-
}
|
|
509
|
-
/** Standard page metadata. */
|
|
510
|
-
interface PageMetadata {
|
|
511
|
-
page: number;
|
|
512
|
-
per: number;
|
|
513
|
-
total: number;
|
|
514
|
-
}
|
|
515
|
-
/** Standard paginated response. */
|
|
516
|
-
interface PageResponse<T> {
|
|
517
|
-
items: T[];
|
|
518
|
-
metadata: PageMetadata;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
/** Session list item. */
|
|
522
|
-
interface SessionSummary {
|
|
523
|
-
id: string;
|
|
524
|
-
deviceName?: string;
|
|
525
|
-
deviceType: string;
|
|
526
|
-
browser?: string;
|
|
527
|
-
os?: string;
|
|
528
|
-
ipAddress: string;
|
|
529
|
-
country?: string;
|
|
530
|
-
city?: string;
|
|
531
|
-
isActive: boolean;
|
|
532
|
-
isCurrent: boolean;
|
|
533
|
-
isTrusted: boolean;
|
|
534
|
-
lastUsedAt?: string;
|
|
535
|
-
createdAt?: string;
|
|
536
|
-
}
|
|
537
|
-
/** Session detail payload. */
|
|
538
|
-
interface SessionDetail {
|
|
539
|
-
id: string;
|
|
540
|
-
deviceId?: string;
|
|
541
|
-
deviceName?: string;
|
|
542
|
-
deviceType: string;
|
|
543
|
-
userAgent?: string;
|
|
544
|
-
browser?: string;
|
|
545
|
-
browserVersion?: string;
|
|
546
|
-
os?: string;
|
|
547
|
-
osVersion?: string;
|
|
548
|
-
ipAddress: string;
|
|
549
|
-
country?: string;
|
|
550
|
-
city?: string;
|
|
551
|
-
isActive: boolean;
|
|
552
|
-
isRevoked: boolean;
|
|
553
|
-
isCurrent: boolean;
|
|
554
|
-
isTrusted: boolean;
|
|
555
|
-
requiresMfa: boolean;
|
|
556
|
-
accessTokenCount: number;
|
|
557
|
-
lastUsedAt?: string;
|
|
558
|
-
expiresAt?: string;
|
|
559
|
-
createdAt?: string;
|
|
560
|
-
revokedAt?: string;
|
|
561
|
-
revocationReason?: string;
|
|
562
|
-
}
|
|
563
|
-
/** Session update payload. */
|
|
564
|
-
interface UpdateSessionRequest {
|
|
565
|
-
deviceName?: string;
|
|
566
|
-
isTrusted?: boolean;
|
|
567
|
-
}
|
|
568
|
-
/** Optional reason payload used during session revocation. */
|
|
569
|
-
interface RevokeSessionRequest {
|
|
570
|
-
reason?: string;
|
|
571
|
-
}
|
|
572
|
-
/** Session/token revocation summary. */
|
|
573
|
-
interface RevocationResponse {
|
|
574
|
-
success: boolean;
|
|
575
|
-
sessionsRevoked: number;
|
|
576
|
-
tokensRevoked: number;
|
|
577
|
-
}
|
|
578
|
-
/** Current user profile payload from `/api/v1/users/me`. */
|
|
579
|
-
interface UserProfile {
|
|
580
|
-
id: string;
|
|
581
|
-
organizationId?: string;
|
|
582
|
-
email?: string;
|
|
583
|
-
username?: string;
|
|
584
|
-
firstName?: string;
|
|
585
|
-
lastName?: string;
|
|
586
|
-
isActive?: boolean;
|
|
587
|
-
isVerified?: boolean;
|
|
588
|
-
mfaEnabled?: boolean;
|
|
589
|
-
[key: string]: JsonValue | undefined;
|
|
590
|
-
}
|
|
591
|
-
/** OIDC UserInfo response payload. */
|
|
592
|
-
interface UserInfoResponse {
|
|
593
|
-
sub: string;
|
|
594
|
-
name?: string;
|
|
595
|
-
givenName?: string;
|
|
596
|
-
familyName?: string;
|
|
597
|
-
middleName?: string;
|
|
598
|
-
nickname?: string;
|
|
599
|
-
preferredUsername?: string;
|
|
600
|
-
profile?: string;
|
|
601
|
-
picture?: string;
|
|
602
|
-
website?: string;
|
|
603
|
-
gender?: string;
|
|
604
|
-
birthdate?: string;
|
|
605
|
-
zoneinfo?: string;
|
|
606
|
-
locale?: string;
|
|
607
|
-
updatedAt?: number;
|
|
608
|
-
email?: string;
|
|
609
|
-
emailVerified?: boolean;
|
|
610
|
-
phoneNumber?: string;
|
|
611
|
-
phoneNumberVerified?: boolean;
|
|
612
|
-
[key: string]: JsonValue | undefined;
|
|
613
|
-
}
|
|
614
|
-
/** WebAuthn endpoint wrappers (browser ceremony intentionally out-of-scope). */
|
|
615
|
-
interface WebAuthnEndpoints {
|
|
616
|
-
registerBegin(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
|
|
617
|
-
registerFinish(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
|
|
618
|
-
authenticateBegin(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
|
|
619
|
-
authenticateFinish(payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
|
|
620
|
-
credentials(): Promise<Record<string, JsonValue>>;
|
|
621
|
-
removeCredential(credentialId: string, input?: {
|
|
622
|
-
password?: string;
|
|
623
|
-
}): Promise<void>;
|
|
624
|
-
renameCredential(credentialId: string, payload: Record<string, JsonValue>): Promise<Record<string, JsonValue>>;
|
|
625
|
-
setPrimaryCredential(credentialId: string): Promise<Record<string, JsonValue>>;
|
|
626
|
-
}
|
|
627
|
-
/** OAuth token endpoint wrappers. */
|
|
628
|
-
interface TokenEndpoints {
|
|
629
|
-
password(input: PasswordTokenRequest): Promise<AuthTokens>;
|
|
630
|
-
refresh(input?: RefreshTokenRequest): Promise<AuthTokens>;
|
|
631
|
-
clientCredentials(input?: ClientCredentialsRequest): Promise<AuthTokens>;
|
|
632
|
-
authorizationCode(input: AuthorizationCodeTokenRequest): Promise<AuthTokens>;
|
|
633
|
-
tokenExchange(input: TokenExchangeRequest): Promise<AuthTokens>;
|
|
634
|
-
revoke(input?: RevokeTokenRequest): Promise<void>;
|
|
635
|
-
introspect(input: IntrospectTokenRequest): Promise<TokenIntrospectionResponse>;
|
|
636
|
-
}
|
|
637
|
-
/** Authentication and registration flow endpoint wrappers. */
|
|
638
|
-
interface FlowEndpoints {
|
|
639
|
-
initAuthentication(input?: InitAuthenticationRequest): Promise<FlowInitResponse>;
|
|
640
|
-
executeStep(input: ExecuteStepRequest): Promise<FlowStepResult>;
|
|
641
|
-
initRegistration(input?: InitRegistrationRequest): Promise<FlowInitResponse>;
|
|
642
|
-
executeRegistrationStep(input: ExecuteStepRequest): Promise<FlowStepResult>;
|
|
643
|
-
initRecovery(input?: InitRecoveryRequest): Promise<FlowInitResponse>;
|
|
644
|
-
executeRecoveryStep(input: ExecuteStepRequest): Promise<FlowStepResult>;
|
|
645
|
-
getStatus(sessionId: string): Promise<FlowSessionStatus>;
|
|
646
|
-
}
|
|
647
|
-
/** OIDC endpoint wrappers. */
|
|
648
|
-
interface OidcEndpoints {
|
|
649
|
-
userInfo(): Promise<UserInfoResponse>;
|
|
650
|
-
discover(): Promise<OidcDiscoveryDocument>;
|
|
651
|
-
jwks(): Promise<JwksDocument>;
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Authorization-code + PKCE redirect-flow helpers. This is the high-level
|
|
655
|
-
* surface that removes per-app duplication of PKCE/state/URL plumbing.
|
|
656
|
-
*/
|
|
657
|
-
interface AuthorizeEndpoints {
|
|
658
|
-
createRequest(options: AuthorizationUrlOptions): Promise<AuthorizationRequest>;
|
|
659
|
-
/**
|
|
660
|
-
* RFC 9126: push the authorization request to the server and return a
|
|
661
|
-
* one-time `request_uri` plus a slim authorization `request` referencing it.
|
|
662
|
-
*/
|
|
663
|
-
pushAuthorizationRequest(options: PushAuthorizationRequestOptions): Promise<PushedAuthorizationResult>;
|
|
664
|
-
parseCallback(input: string | URLSearchParams | Record<string, string>): CallbackParams;
|
|
665
|
-
handleCallback(options: HandleCallbackOptions): Promise<AuthTokens>;
|
|
666
|
-
consent(callbackUrl: string, body: AuthorizationConsentBody): Promise<AuthorizationConsentResponse>;
|
|
667
|
-
consentWithCredentials(options: ConsentWithCredentialsOptions): Promise<AuthorizationConsentResponse>;
|
|
668
|
-
probeAuthorize(url: string): Promise<AuthorizationProbeResult>;
|
|
669
|
-
}
|
|
670
|
-
/** Current-user endpoint wrappers. */
|
|
671
|
-
interface UserEndpoints {
|
|
672
|
-
me(): Promise<UserProfile>;
|
|
673
|
-
updateMe(input: JsonObject): Promise<UserProfile>;
|
|
674
|
-
changePassword(input: {
|
|
675
|
-
currentPassword: string;
|
|
676
|
-
newPassword: string;
|
|
677
|
-
}): Promise<void>;
|
|
678
|
-
uploadAvatar(file: Blob | Buffer, filename?: string): Promise<UserProfile>;
|
|
679
|
-
deleteAvatar(): Promise<UserProfile>;
|
|
680
|
-
verifyPhone(input: JsonObject): Promise<JsonObject>;
|
|
681
|
-
securityOverview(): Promise<JsonObject>;
|
|
682
|
-
recoveryContacts: {
|
|
683
|
-
list(): Promise<RecoveryContact[]>;
|
|
684
|
-
create(input: JsonObject): Promise<RecoveryContact>;
|
|
685
|
-
update(contactId: string, input: JsonObject): Promise<RecoveryContact>;
|
|
686
|
-
delete(contactId: string): Promise<void>;
|
|
687
|
-
};
|
|
688
|
-
identities: {
|
|
689
|
-
list(): Promise<UserIdentity[]>;
|
|
690
|
-
unlink(identityId: string): Promise<void>;
|
|
691
|
-
setPrimary(identityId: string): Promise<JsonObject>;
|
|
692
|
-
};
|
|
693
|
-
deleteMe(input: {
|
|
694
|
-
password: string;
|
|
695
|
-
}): Promise<void>;
|
|
696
|
-
admin: UsersAdminEndpoints;
|
|
697
|
-
}
|
|
698
|
-
/** Session list query parameters. */
|
|
699
|
-
interface SessionListQuery {
|
|
700
|
-
page?: number;
|
|
701
|
-
perPage?: number;
|
|
702
|
-
userId?: string;
|
|
703
|
-
}
|
|
704
|
-
/** Session management endpoint wrappers. */
|
|
705
|
-
interface SessionEndpoints {
|
|
706
|
-
list(input?: SessionListQuery): Promise<PageResponse<SessionSummary>>;
|
|
707
|
-
current(): Promise<SessionDetail>;
|
|
708
|
-
get(id: string): Promise<SessionDetail>;
|
|
709
|
-
update(id: string, input: UpdateSessionRequest): Promise<SessionDetail>;
|
|
710
|
-
revoke(id: string, input?: RevokeSessionRequest): Promise<RevocationResponse>;
|
|
711
|
-
revokeAll(): Promise<RevocationResponse>;
|
|
712
|
-
revokeAllDevices(): Promise<RevocationResponse>;
|
|
713
|
-
}
|
|
714
|
-
/** Token state helper endpoints for direct storage access. */
|
|
715
|
-
interface TokenStateEndpoints {
|
|
716
|
-
get(): Promise<AuthTokens | null>;
|
|
717
|
-
set(tokens: AuthTokens | null): Promise<void>;
|
|
718
|
-
clear(): Promise<void>;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Creates in-memory token storage suitable for Node, edge, and browser runtimes.
|
|
723
|
-
*
|
|
724
|
-
* Tokens are not encrypted and do not survive process restarts. This is the
|
|
725
|
-
* default and the recommended choice for server-side clients (SSR routes,
|
|
726
|
-
* workers) where persistence belongs in HttpOnly cookies or a server session.
|
|
727
|
-
*/
|
|
728
|
-
declare function createMemoryTokenStorage(): TokenStorage;
|
|
729
|
-
|
|
730
|
-
export { type UpdateSessionRequest as $, type AuthorizeEndpoints as A, type PasswordTokenRequest as B, type CallbackParams as C, type PublicClientInfo as D, type ExecuteStepRequest as E, type FlowEndpoints as F, type PushAuthorizationRequestOptions as G, type HandleCallbackOptions as H, type InitAuthenticationRequest as I, type PushedAuthorizationResult as J, type RevocationResponse as K, type RevokeSessionRequest as L, type MfaEndpoints as M, type RevokeTokenRequest as N, type OidcEndpoints as O, type PasswordResetEndpoints as P, type SessionDetail as Q, type RefreshTokenRequest as R, type SessionEndpoints as S, type TokenEndpoints as T, type UserEndpoints as U, type SessionListQuery as V, type WebAuthnEndpoints as W, type SessionSummary as X, type TokenExchangeRequest as Y, type TokenIntrospectionResponse as Z, type TokenStorage as _, type MaintenanceStatus as a, type UserInfoResponse as a0, type UserProfile as a1, createMemoryTokenStorage as a2, type OAuthMetaEndpoints as b, type TokenStateEndpoints as c, type AuthClientConfig as d, type AuthTokens as e, type AuthorizationCodeTokenRequest as f, type AuthorizationConsentBody as g, type AuthorizationConsentResponse as h, type AuthorizationDetail as i, type AuthorizationProbeResult as j, type AuthorizationRequest as k, type AuthorizationUrlOptions as l, type ClientCredentialsRequest as m, type FlowInitResponse as n, type FlowSessionStatus as o, type FlowStep as p, type FlowStepCompleteResult as q, type FlowStepInProgressResult as r, type FlowStepResult as s, type InitRegistrationRequest as t, type IntrospectTokenRequest as u, type MfaDevice as v, type OAuthAuthorizationServerMetadata as w, type OidcDiscoveryDocument as x, type PageQuery as y, type PageResponse as z };
|