@hyper.authio/client 0.1.1 → 0.8.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 +139 -11
- package/dist/index.cjs +919 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +880 -117
- package/dist/index.d.ts +880 -117
- package/dist/index.js +888 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JWK, CryptoKey } from 'jose';
|
|
1
|
+
import { JWK, CryptoKey, JWTPayload, JWTVerifyGetKey } from 'jose';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Claim names Authio writes into its tokens.
|
|
@@ -20,6 +20,8 @@ declare const AuthioClaimTypes: {
|
|
|
20
20
|
readonly AuthenticationMethods: "amr";
|
|
21
21
|
readonly IdentityProvider: "idp";
|
|
22
22
|
readonly Nonce: "nonce";
|
|
23
|
+
readonly AccessTokenHash: "at_hash";
|
|
24
|
+
readonly Events: "events";
|
|
23
25
|
readonly OrganizationId: "org_id";
|
|
24
26
|
readonly OrganizationAlias: "org_alias";
|
|
25
27
|
readonly AccountId: "account_id";
|
|
@@ -39,6 +41,12 @@ declare const AuthioClaimTypes: {
|
|
|
39
41
|
readonly ConsumerName: "consumer_name";
|
|
40
42
|
readonly CredentialId: "credential_id";
|
|
41
43
|
readonly CredentialType: "credential_type";
|
|
44
|
+
readonly CredentialName: "credential_name";
|
|
45
|
+
readonly CredentialRealm: "credential_realm";
|
|
46
|
+
readonly CredentialClient: "credential_client";
|
|
47
|
+
readonly ActorType: "actor_type";
|
|
48
|
+
readonly OwnerUserId: "owner_user_id";
|
|
49
|
+
readonly OwnerUsername: "owner_username";
|
|
42
50
|
readonly UserResourceAccess: "user_resource_access";
|
|
43
51
|
readonly RealmResourceAccess: "realm_resource_access";
|
|
44
52
|
readonly ClientResourceAccess: "client_resource_access";
|
|
@@ -116,6 +124,12 @@ declare const AuthioOAuthErrors: {
|
|
|
116
124
|
readonly ConnectionPolicyViolation: "connection_policy_violation";
|
|
117
125
|
readonly ServerError: "server_error";
|
|
118
126
|
readonly TemporarilyUnavailable: "temporarily_unavailable";
|
|
127
|
+
readonly LoginRequired: "login_required";
|
|
128
|
+
readonly InteractionRequired: "interaction_required";
|
|
129
|
+
readonly ConsentRequired: "consent_required";
|
|
130
|
+
readonly AccountSelectionRequired: "account_selection_required";
|
|
131
|
+
readonly InsufficientScope: "insufficient_scope";
|
|
132
|
+
readonly InsufficientUserAuthentication: "insufficient_user_authentication";
|
|
119
133
|
};
|
|
120
134
|
/**
|
|
121
135
|
* Webhook event types.
|
|
@@ -135,6 +149,8 @@ declare const AuthioWebhookEventTypes: {
|
|
|
135
149
|
readonly AdminResourceDeleted: "admin_resource_deleted";
|
|
136
150
|
readonly UserSuspended: "user_suspended";
|
|
137
151
|
readonly UserSuspensionEnded: "user_suspension_ended";
|
|
152
|
+
readonly AttackDetected: "attack_detected";
|
|
153
|
+
readonly CredentialCompromised: "credential_compromised";
|
|
138
154
|
readonly Ping: "ping";
|
|
139
155
|
};
|
|
140
156
|
/**
|
|
@@ -145,21 +161,67 @@ declare const AuthioWebhookHeaders: {
|
|
|
145
161
|
readonly Event: "X-Authio-Event";
|
|
146
162
|
readonly EventId: "X-Authio-Event-Id";
|
|
147
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* Who called an API, read from the access token (see `conformance/callers.json`).
|
|
166
|
+
*
|
|
167
|
+
* - `user`: a person signed in (the token carries `auth_time`).
|
|
168
|
+
* - `client`: a client authenticated as itself.
|
|
169
|
+
* - `consumer`: a machine consumer of a client (`credential_type` `client_consumer`).
|
|
170
|
+
* - `account_credential`: a credential of an Authio account (`credential_type` `account_secret`).
|
|
171
|
+
*/
|
|
172
|
+
type AuthioCallerKind = "user" | "client" | "consumer" | "account_credential";
|
|
173
|
+
/**
|
|
174
|
+
* How a machine caller proved who it is.
|
|
175
|
+
*/
|
|
176
|
+
type AuthioCredentialForm = "client_secret" | "personal_access_token" | "api_key" | "consumer_api_key";
|
|
177
|
+
/**
|
|
178
|
+
* The caller kinds.
|
|
179
|
+
*/
|
|
180
|
+
declare const AuthioCallerKinds: readonly ["user", "client", "consumer", "account_credential"];
|
|
181
|
+
/**
|
|
182
|
+
* The values of `prompt` Authio honours.
|
|
183
|
+
*/
|
|
184
|
+
declare const AuthioPrompts: readonly ["none", "login", "select_account", "consent"];
|
|
185
|
+
/**
|
|
186
|
+
* A value of `prompt`.
|
|
187
|
+
*/
|
|
188
|
+
type AuthioPrompt = (typeof AuthioPrompts)[number];
|
|
148
189
|
/**
|
|
149
190
|
* Asymmetric signing algorithms Authio issues tokens with and accepts in client assertions.
|
|
150
191
|
*/
|
|
151
192
|
declare const AuthioAsymmetricAlgorithms: readonly ["RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512"];
|
|
193
|
+
/**
|
|
194
|
+
* Symmetric algorithms Authio may sign a client's tokens with. A client verifies them with its own client secret
|
|
195
|
+
* (OpenID Connect Core §10.1), and only when `idTokenSignedResponseAlg` names one.
|
|
196
|
+
*/
|
|
197
|
+
declare const AuthioHmacAlgorithms: readonly ["HS256", "HS384", "HS512"];
|
|
198
|
+
/**
|
|
199
|
+
* The shortest client secret, in bytes of its UTF-8 form, each HS* algorithm is verified with: the size of the hash
|
|
200
|
+
* output (RFC 7518 §3.2). Authio refuses a shorter secret for the algorithm, and so do the SDKs.
|
|
201
|
+
*/
|
|
202
|
+
declare const AuthioHmacMinimumSecretBytes: Readonly<Record<(typeof AuthioHmacAlgorithms)[number], number>>;
|
|
152
203
|
/**
|
|
153
204
|
* Defaults shared by every Authio SDK.
|
|
154
205
|
*/
|
|
155
206
|
declare const AuthioDefaults: {
|
|
156
207
|
readonly DiscoveryPath: "/.well-known/openid-configuration";
|
|
208
|
+
readonly ProtectedResourceMetadataPath: "/.well-known/oauth-protected-resource";
|
|
157
209
|
readonly RedactedValue: "[redacted]";
|
|
158
210
|
readonly PlatformRealm: "authio";
|
|
159
211
|
readonly PlatformClientId: "authio";
|
|
160
212
|
readonly ApiKeyPrefix: "ak_";
|
|
161
213
|
readonly ClientSecretPrefix: "cs_";
|
|
162
214
|
readonly PersonalAccessTokenPrefix: "pat_";
|
|
215
|
+
/** The `client_id` an account credential's client secret is exchanged with: `cred_` and the credential id (format N). */
|
|
216
|
+
readonly CredentialClientIdPrefix: "cred_";
|
|
217
|
+
readonly ApiKeyHeader: "x-api-key";
|
|
218
|
+
readonly RequestIdHeader: "X-Request-Id";
|
|
219
|
+
/** The header `typ` of a back-channel logout token. */
|
|
220
|
+
readonly LogoutTokenType: "logout+jwt";
|
|
221
|
+
/** The event a back-channel logout token carries. */
|
|
222
|
+
readonly BackchannelLogoutEvent: "http://schemas.openid.net/event/backchannel-logout";
|
|
223
|
+
/** Seconds. */
|
|
224
|
+
readonly ClockSkew: 30;
|
|
163
225
|
/** Seconds. */
|
|
164
226
|
readonly ClientAssertionLifetime: 120;
|
|
165
227
|
/** Seconds. */
|
|
@@ -220,6 +282,65 @@ declare class AuthioDiscoveryError extends AuthioError {
|
|
|
220
282
|
*/
|
|
221
283
|
declare class AuthioConfigurationError extends AuthioError {
|
|
222
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Why a token was refused, with the outcome names of `conformance/tokens.json`.
|
|
287
|
+
*/
|
|
288
|
+
type AuthioTokenFailure = "not_access_token" | "not_id_token" | "invalid_audience" | "invalid_issuer" | "expired" | "not_yet_valid" | "invalid_signature" | "invalid_algorithm" | "reference_token" | "malformed" | "decryption_failed" | "legacy_algorithm" | "invalid_nonce" | "invalid_at_hash" | "authentication_too_old" | "invalid_logout_token" | "signing_keys_unavailable";
|
|
289
|
+
/**
|
|
290
|
+
* A token (ID token, logout token, signed UserInfo, encrypted token) did not pass validation.
|
|
291
|
+
*/
|
|
292
|
+
declare class AuthioTokenValidationError extends AuthioError {
|
|
293
|
+
/** Why, as a stable code. */
|
|
294
|
+
readonly reason: AuthioTokenFailure;
|
|
295
|
+
constructor(reason: AuthioTokenFailure, message: string, options?: {
|
|
296
|
+
cause?: unknown;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Why an authorization callback was refused before any code was exchanged.
|
|
301
|
+
*/
|
|
302
|
+
type AuthioCallbackFailure = "state_mismatch" | "issuer_mismatch" | "missing_issuer" | "missing_code";
|
|
303
|
+
/**
|
|
304
|
+
* The authorization callback does not belong to the request this client made: `state` differs, the `iss` parameter
|
|
305
|
+
* (RFC 9207) names another issuer or is missing where Authio sends it, or there is no code.
|
|
306
|
+
*/
|
|
307
|
+
declare class AuthioCallbackError extends AuthioError {
|
|
308
|
+
/** Why, as a stable code. */
|
|
309
|
+
readonly reason: AuthioCallbackFailure;
|
|
310
|
+
constructor(reason: AuthioCallbackFailure, message: string);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* One message of an Admin API error, optionally tied to a field of the request.
|
|
314
|
+
*/
|
|
315
|
+
interface AuthioAdminNotification {
|
|
316
|
+
readonly message: string;
|
|
317
|
+
readonly field?: string;
|
|
318
|
+
readonly code?: string;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* The Admin API refused a request. `errorCode` is the envelope's top-level `errorCode`; the HTTP status is read from
|
|
322
|
+
* the response, never from the envelope's numeric `statusCode`.
|
|
323
|
+
*/
|
|
324
|
+
declare class AuthioAdminError extends AuthioError {
|
|
325
|
+
/** The HTTP status. */
|
|
326
|
+
readonly status: number;
|
|
327
|
+
/** Authio's error code, such as `ValidationFailed` or `RealmNotFound`. */
|
|
328
|
+
readonly errorCode: string | undefined;
|
|
329
|
+
/** The messages, with the field each one is about. */
|
|
330
|
+
readonly notifications: readonly AuthioAdminNotification[];
|
|
331
|
+
/** The request id, from the envelope or the `X-Request-Id` header. */
|
|
332
|
+
readonly requestId: string | undefined;
|
|
333
|
+
/** Seconds to wait before retrying, from `Retry-After` (`429` and `503`). */
|
|
334
|
+
readonly retryAfterSeconds: number | undefined;
|
|
335
|
+
constructor(details: {
|
|
336
|
+
status: number;
|
|
337
|
+
errorCode?: string;
|
|
338
|
+
notifications?: readonly AuthioAdminNotification[];
|
|
339
|
+
requestId?: string;
|
|
340
|
+
retryAfterSeconds?: number;
|
|
341
|
+
cause?: unknown;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
223
344
|
|
|
224
345
|
/**
|
|
225
346
|
* Time as the SDK sees it. Replace it in tests to control expiry, caching and device polling.
|
|
@@ -235,7 +356,7 @@ interface AuthioClock {
|
|
|
235
356
|
*/
|
|
236
357
|
declare const systemClock: AuthioClock;
|
|
237
358
|
/**
|
|
238
|
-
* Where Authio is and how to reach it. Shared by the client
|
|
359
|
+
* Where Authio is and how to reach it. Shared by the client and the API verifier.
|
|
239
360
|
*/
|
|
240
361
|
interface AuthioConnectionOptions {
|
|
241
362
|
/**
|
|
@@ -262,9 +383,14 @@ interface AuthioConnectionOptions {
|
|
|
262
383
|
clock?: AuthioClock;
|
|
263
384
|
}
|
|
264
385
|
/**
|
|
265
|
-
* How the client authenticates to the token, introspection, revocation and device endpoints
|
|
386
|
+
* How the client authenticates to the token, introspection, revocation and device endpoints: the client's
|
|
387
|
+
* `token_endpoint_auth_method` in Authio, which Authio matches exactly.
|
|
266
388
|
*/
|
|
267
|
-
type
|
|
389
|
+
type AuthioTokenEndpointAuthMethod = "client_secret_basic" | "client_secret_post" | "private_key_jwt" | "none";
|
|
390
|
+
/**
|
|
391
|
+
* The values of `tokenEndpointAuthMethod`.
|
|
392
|
+
*/
|
|
393
|
+
declare const AuthioTokenEndpointAuthMethods: readonly ["client_secret_basic", "client_secret_post", "private_key_jwt", "none"];
|
|
268
394
|
/**
|
|
269
395
|
* The connection settings, resolved once.
|
|
270
396
|
*/
|
|
@@ -324,6 +450,7 @@ interface AuthioDiscoveryDocument {
|
|
|
324
450
|
grant_types_supported?: string[];
|
|
325
451
|
subject_types_supported?: string[];
|
|
326
452
|
id_token_signing_alg_values_supported?: string[];
|
|
453
|
+
userinfo_signing_alg_values_supported?: string[];
|
|
327
454
|
token_endpoint_auth_methods_supported?: string[];
|
|
328
455
|
token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
329
456
|
introspection_endpoint_auth_methods_supported?: string[];
|
|
@@ -332,6 +459,8 @@ interface AuthioDiscoveryDocument {
|
|
|
332
459
|
claims_supported?: string[];
|
|
333
460
|
prompt_values_supported?: string[];
|
|
334
461
|
authorization_response_iss_parameter_supported?: boolean;
|
|
462
|
+
frontchannel_logout_supported?: boolean;
|
|
463
|
+
frontchannel_logout_session_supported?: boolean;
|
|
335
464
|
[member: string]: unknown;
|
|
336
465
|
}
|
|
337
466
|
/**
|
|
@@ -387,19 +516,27 @@ type AuthioPrivateKeyInput = string | JWK | CryptoKey;
|
|
|
387
516
|
*/
|
|
388
517
|
declare const AuthioClientAssertionAlgorithms: readonly ["RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512"];
|
|
389
518
|
|
|
519
|
+
/**
|
|
520
|
+
* The client secret, or a function returning the current one, called for every request so a rotated secret is used
|
|
521
|
+
* without a restart.
|
|
522
|
+
*/
|
|
523
|
+
type AuthioSecretSource = string | (() => string | Promise<string>);
|
|
390
524
|
/**
|
|
391
525
|
* How the client proves who it is.
|
|
392
526
|
*/
|
|
393
527
|
interface AuthioClientCredentialsSettings {
|
|
394
528
|
/** The client id. */
|
|
395
529
|
clientId: string;
|
|
396
|
-
/** The client secret, for `client_secret_basic` and `client_secret_post`. */
|
|
397
|
-
clientSecret?: string;
|
|
398
530
|
/**
|
|
399
|
-
*
|
|
400
|
-
*
|
|
531
|
+
* The client secret, for `client_secret_basic` and `client_secret_post`; or a function returning the current one,
|
|
532
|
+
* called for every request.
|
|
401
533
|
*/
|
|
402
|
-
|
|
534
|
+
clientSecret?: AuthioSecretSource;
|
|
535
|
+
/**
|
|
536
|
+
* How the client authenticates, as registered in Authio (which matches it exactly). Defaults to
|
|
537
|
+
* `client_secret_basic` with a `clientSecret`, `private_key_jwt` with only a private key, and `none` with neither.
|
|
538
|
+
*/
|
|
539
|
+
tokenEndpointAuthMethod?: AuthioTokenEndpointAuthMethod;
|
|
403
540
|
/** The private key for `private_key_jwt`. */
|
|
404
541
|
clientPrivateKey?: AuthioPrivateKeyInput;
|
|
405
542
|
/** A PEM file holding the private key for `private_key_jwt` (Node only); re-read when it changes. */
|
|
@@ -421,18 +558,54 @@ declare function toBasicAuthorization(clientId: string, clientSecret: string): s
|
|
|
421
558
|
* Authio hands over when it generates the pair (object or JSON text), or a PEM private key (PKCS#8 or PKCS#1 RSA).
|
|
422
559
|
*/
|
|
423
560
|
type AuthioEncryptionKey = string | JWK;
|
|
561
|
+
/**
|
|
562
|
+
* Where the encryption key comes from: the key itself, or a function returning it (read again on every new
|
|
563
|
+
* algorithm, so a rotated key is picked up).
|
|
564
|
+
*/
|
|
565
|
+
type AuthioEncryptionKeySource = AuthioEncryptionKey | (() => AuthioEncryptionKey | Promise<AuthioEncryptionKey>);
|
|
424
566
|
/**
|
|
425
567
|
* Opens a compact JWE and returns its plaintext; a token that is not a JWE comes back unchanged.
|
|
568
|
+
*
|
|
569
|
+
* @throws AuthioTokenValidationError with `legacy_algorithm` for RSA1_5 and `decryption_failed` when the key cannot
|
|
570
|
+
* open it.
|
|
426
571
|
*/
|
|
427
572
|
type AuthioTokenDecrypter = (token: string) => Promise<string>;
|
|
428
573
|
/**
|
|
429
|
-
* The key management algorithms Authio encrypts with.
|
|
574
|
+
* The key management algorithms Authio encrypts with, and this SDK decrypts.
|
|
430
575
|
*/
|
|
431
576
|
declare const AuthioKeyManagementAlgorithms: readonly ["RSA-OAEP", "RSA-OAEP-256"];
|
|
432
577
|
/**
|
|
433
|
-
*
|
|
578
|
+
* Key management algorithms Authio may still use for clients registered long ago. Node and WebCrypto cannot decrypt
|
|
579
|
+
* RSA1_5 (PKCS#1 v1.5), so this SDK refuses it even with `allowLegacyEncryptionAlgorithms`.
|
|
580
|
+
*/
|
|
581
|
+
declare const AuthioLegacyKeyManagementAlgorithms: readonly ["RSA1_5"];
|
|
582
|
+
/**
|
|
583
|
+
* The content encryption algorithms Authio encrypts with to a client's own key, the default `encryptionMethods`.
|
|
434
584
|
*/
|
|
435
585
|
declare const AuthioContentEncryptionAlgorithms: readonly ["A128CBC-HS256", "A192CBC-HS384", "A256CBC-HS512"];
|
|
586
|
+
/**
|
|
587
|
+
* Every content encryption algorithm `encryptionMethods` may list: the CBC-HS ones and AES-GCM.
|
|
588
|
+
*/
|
|
589
|
+
declare const AuthioSupportedContentEncryptionAlgorithms: readonly ["A128CBC-HS256", "A192CBC-HS384", "A256CBC-HS512", "A128GCM", "A192GCM", "A256GCM"];
|
|
590
|
+
/**
|
|
591
|
+
* Options of the decrypter.
|
|
592
|
+
*/
|
|
593
|
+
interface AuthioTokenDecrypterOptions {
|
|
594
|
+
/** The setting the key came from, named in errors. Defaults to `clientEncryptionKey`. */
|
|
595
|
+
setting?: string;
|
|
596
|
+
/**
|
|
597
|
+
* Accepted for parity with the other Authio SDKs. RSA1_5 stays refused here, with an error saying so, because
|
|
598
|
+
* neither Node nor WebCrypto can decrypt PKCS#1 v1.5.
|
|
599
|
+
*/
|
|
600
|
+
allowLegacyEncryptionAlgorithms?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* The key management algorithms (`alg`) accepted, as registered for the client in Authio. Defaults to RSA-OAEP and
|
|
603
|
+
* RSA-OAEP-256. RSA1_5 cannot be listed: neither Node nor WebCrypto can decrypt it.
|
|
604
|
+
*/
|
|
605
|
+
encryptionAlgorithms?: readonly string[];
|
|
606
|
+
/** The content encryption algorithms (`enc`) accepted. Defaults to A128CBC-HS256, A192CBC-HS384 and A256CBC-HS512. */
|
|
607
|
+
encryptionMethods?: readonly string[];
|
|
608
|
+
}
|
|
436
609
|
/**
|
|
437
610
|
* Whether a value is a compact JWE (five segments).
|
|
438
611
|
*/
|
|
@@ -440,10 +613,249 @@ declare function isAuthioTokenEncrypted(token: unknown): token is string;
|
|
|
440
613
|
/**
|
|
441
614
|
* Creates a decrypter for the client's own encryption key. Keys are imported once per algorithm.
|
|
442
615
|
*
|
|
443
|
-
* @param key The key, or `undefined` when none is configured: an encrypted token then throws.
|
|
444
|
-
* @param
|
|
616
|
+
* @param key The key, a function returning it, or `undefined` when none is configured: an encrypted token then throws.
|
|
617
|
+
* @param options The setting name for errors, and the legacy algorithm switch. A string is taken as the setting name.
|
|
618
|
+
*/
|
|
619
|
+
declare function createAuthioTokenDecrypter(key: AuthioEncryptionKeySource | undefined, options?: AuthioTokenDecrypterOptions | string): AuthioTokenDecrypter;
|
|
620
|
+
/**
|
|
621
|
+
* Reads the client's encryption key from a PEM or JWK file (Node only), again whenever the file changes.
|
|
622
|
+
*
|
|
623
|
+
* @internal
|
|
624
|
+
*/
|
|
625
|
+
declare function encryptionKeyFromFile(path: string, setting?: string): () => Promise<AuthioEncryptionKey>;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* The claims of a validated ID token. Authio writes `typ` = `ID`, `sid`, `auth_time`, `acr`, `amr`, `nonce` and
|
|
629
|
+
* `at_hash`, besides the profile claims of the granted scopes.
|
|
630
|
+
*/
|
|
631
|
+
interface AuthioIdTokenClaims extends JWTPayload {
|
|
632
|
+
sub: string;
|
|
633
|
+
sid?: string;
|
|
634
|
+
nonce?: string;
|
|
635
|
+
auth_time?: number;
|
|
636
|
+
acr?: string;
|
|
637
|
+
amr?: string[];
|
|
638
|
+
at_hash?: string;
|
|
639
|
+
[claim: string]: unknown;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* A validated back-channel logout token: end the sessions of `subject`, or the one session `sessionId` names.
|
|
643
|
+
*/
|
|
644
|
+
interface AuthioLogoutToken {
|
|
645
|
+
/** `sub`, when the token names the person. */
|
|
646
|
+
readonly subject: string | undefined;
|
|
647
|
+
/** `sid`, when the token names one session. */
|
|
648
|
+
readonly sessionId: string | undefined;
|
|
649
|
+
/** `jti`. */
|
|
650
|
+
readonly tokenId: string | undefined;
|
|
651
|
+
/** Every claim. */
|
|
652
|
+
readonly claims: Readonly<JWTPayload>;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* The realm's signing keys, read from the discovery document's `jwks_uri` and cached; an unknown `kid` makes it read
|
|
656
|
+
* them again (at most once every 30 seconds).
|
|
657
|
+
*
|
|
658
|
+
* @internal
|
|
659
|
+
*/
|
|
660
|
+
type AuthioSigningKeys = (signal?: AbortSignal) => Promise<JWTVerifyGetKey>;
|
|
661
|
+
/**
|
|
662
|
+
* What a JWT is checked against.
|
|
663
|
+
*
|
|
664
|
+
* @internal
|
|
665
|
+
*/
|
|
666
|
+
interface AuthioJwtExpectations {
|
|
667
|
+
readonly issuer: string;
|
|
668
|
+
/** The accepted audiences; `aud` is not checked when absent. */
|
|
669
|
+
readonly audiences?: readonly string[];
|
|
670
|
+
readonly algorithms?: readonly string[];
|
|
671
|
+
/** Seconds. */
|
|
672
|
+
readonly clockSkew?: number;
|
|
673
|
+
/** Milliseconds since the epoch. */
|
|
674
|
+
readonly now: number;
|
|
675
|
+
readonly requiredClaims?: readonly string[];
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Creates the cached reader of the realm's signing keys.
|
|
679
|
+
*
|
|
680
|
+
* @internal
|
|
445
681
|
*/
|
|
446
|
-
declare function
|
|
682
|
+
declare function createAuthioSigningKeys(connection: AuthioConnection, discovery: AuthioDiscoveryClient): AuthioSigningKeys;
|
|
683
|
+
/**
|
|
684
|
+
* Verifies a signed JWT: signature by a realm key with an accepted algorithm, `iss`, `aud`, `exp` (required) and
|
|
685
|
+
* `nbf` with the clock skew.
|
|
686
|
+
*
|
|
687
|
+
* @throws AuthioTokenValidationError naming why the token was refused.
|
|
688
|
+
* @internal
|
|
689
|
+
*/
|
|
690
|
+
declare function verifyAuthioJwt(token: string, keys: JWTVerifyGetKey, expected: AuthioJwtExpectations): Promise<{
|
|
691
|
+
payload: JWTPayload;
|
|
692
|
+
header: Record<string, unknown>;
|
|
693
|
+
}>;
|
|
694
|
+
/**
|
|
695
|
+
* Wraps the realm's keys so an HS256, HS384 or HS512 signature is verified with the client secret instead (OpenID
|
|
696
|
+
* Connect Core §10.1: the octets of its UTF-8 form). Only reached for an algorithm the allowlist accepts, so an HS*
|
|
697
|
+
* token is verified with the secret only when `idTokenSignedResponseAlg` names that algorithm.
|
|
698
|
+
*
|
|
699
|
+
* @internal
|
|
700
|
+
*/
|
|
701
|
+
declare function withClientSecret(keys: JWTVerifyGetKey, secret: (() => Promise<string>) | undefined): JWTVerifyGetKey;
|
|
702
|
+
/**
|
|
703
|
+
* Refuses a client secret shorter than the HS* algorithm's hash output (RFC 7518 §3.2).
|
|
704
|
+
*
|
|
705
|
+
* @throws AuthioConfigurationError naming the algorithm and both lengths.
|
|
706
|
+
* @internal
|
|
707
|
+
*/
|
|
708
|
+
declare function requireHmacSecretLength(algorithm: string, length: number): void;
|
|
709
|
+
/**
|
|
710
|
+
* Turns a `jose` failure into the refusal it stands for, worded as ASP.NET Core's bearer handler words it.
|
|
711
|
+
*
|
|
712
|
+
* @internal
|
|
713
|
+
*/
|
|
714
|
+
declare function toTokenValidationError(error: unknown, audiences: readonly string[], token: string): AuthioTokenValidationError;
|
|
715
|
+
/**
|
|
716
|
+
* The `at_hash` / `c_hash` of a value for a signing algorithm: the left half of its SHA-256, SHA-384 or SHA-512
|
|
717
|
+
* digest, base64url-encoded (OpenID Connect Core §3.1.3.6).
|
|
718
|
+
*/
|
|
719
|
+
declare function computeAuthioTokenHash(value: string, algorithm: string): Promise<string>;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* The PKCE method (RFC 7636). `S256` is the default; `plain` only when asked for, for a client that cannot hash.
|
|
723
|
+
*/
|
|
724
|
+
type AuthioCodeChallengeMethod = "S256" | "plain";
|
|
725
|
+
/**
|
|
726
|
+
* What the client checks on an authorization round trip, as the client is registered in Authio: `pkce` sends a code
|
|
727
|
+
* challenge and redeems the code with its verifier, `state` binds the callback to the request, `nonce` binds the ID
|
|
728
|
+
* token to it. `none` is the same as an empty list. Nothing is checked unless listed.
|
|
729
|
+
*/
|
|
730
|
+
type AuthioCheck = "pkce" | "state" | "nonce" | "none";
|
|
731
|
+
/**
|
|
732
|
+
* How Authio answers the authorization request: `query` (a redirect) or `web_message` (posted to the opener window).
|
|
733
|
+
*/
|
|
734
|
+
type AuthioResponseMode = "query" | "web_message";
|
|
735
|
+
/**
|
|
736
|
+
* The checks every Authio library accepts.
|
|
737
|
+
*/
|
|
738
|
+
declare const AuthioChecks: readonly ["pkce", "state", "nonce", "none"];
|
|
739
|
+
/**
|
|
740
|
+
* A PKCE pair: send `codeChallenge` with the authorization request and `codeVerifier` with the code exchange.
|
|
741
|
+
*/
|
|
742
|
+
interface AuthioPkcePair {
|
|
743
|
+
readonly codeVerifier: string;
|
|
744
|
+
readonly codeChallenge: string;
|
|
745
|
+
readonly codeChallengeMethod: AuthioCodeChallengeMethod;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* What an authorization request asks Authio for. Every member is optional; `redirectUri` falls back to the client's.
|
|
749
|
+
*/
|
|
750
|
+
interface AuthioAuthorizationRequest {
|
|
751
|
+
/** Where Authio sends the person back. Defaults to the client's `redirectUri`. */
|
|
752
|
+
redirectUri?: string;
|
|
753
|
+
/** Defaults to `openid`. */
|
|
754
|
+
scopes?: Iterable<string> | string;
|
|
755
|
+
/** The resource server the access token is for (RFC 8707). */
|
|
756
|
+
resource?: string;
|
|
757
|
+
/** The organization (its handle) the sign-in is for. Authoritative: the person cannot switch to another one. */
|
|
758
|
+
organization?: string;
|
|
759
|
+
/** `none` (silent), `login`, `select_account`, `consent`; several are joined with spaces. */
|
|
760
|
+
prompt?: AuthioPrompt | readonly AuthioPrompt[];
|
|
761
|
+
/** Seconds the person's sign-in may be old; Authio asks again past it, and the ID token's `auth_time` is checked. */
|
|
762
|
+
maxAge?: number;
|
|
763
|
+
/** Authentication context classes asked for: `1` one factor, `2` several, `3` one of them phishing-resistant. */
|
|
764
|
+
acrValues?: string | readonly string[];
|
|
765
|
+
/** Pre-fills the identifier on the sign-in screen. */
|
|
766
|
+
loginHint?: string;
|
|
767
|
+
/** A previously issued ID token, naming the person whose session is renewed. */
|
|
768
|
+
idTokenHint?: string;
|
|
769
|
+
/** Languages of the hosted screens, most preferred first. */
|
|
770
|
+
uiLocales?: string | readonly string[];
|
|
771
|
+
/** `page` (default) or `popup`, the layout of the hosted screens. */
|
|
772
|
+
display?: "page" | "popup";
|
|
773
|
+
/** `query` or `web_message` (the answer posted to the opener window). Defaults to the client's `responseMode`. */
|
|
774
|
+
responseMode?: AuthioResponseMode;
|
|
775
|
+
/** Shorthand for `display: "popup"` with `responseMode: "web_message"`. */
|
|
776
|
+
popup?: boolean;
|
|
777
|
+
/** The alias of the identity provider to go straight to, skipping Authio's sign-in screen. */
|
|
778
|
+
idpHint?: string;
|
|
779
|
+
/** The checks of this request. Defaults to the client's `checks`. */
|
|
780
|
+
checks?: readonly AuthioCheck[];
|
|
781
|
+
/** The PKCE method, when `checks` holds `pkce`. Defaults to the client's `codeChallengeMethod`, else `S256`. */
|
|
782
|
+
codeChallengeMethod?: AuthioCodeChallengeMethod;
|
|
783
|
+
/** A `state` of your own for the `state` check (a random one otherwise); without the check it is sent unchecked. */
|
|
784
|
+
state?: string;
|
|
785
|
+
/** A `nonce` of your own for the `nonce` check (a random one otherwise); without the check it is sent unchecked. */
|
|
786
|
+
nonce?: string;
|
|
787
|
+
/** Further parameters, sent as given. */
|
|
788
|
+
extraParameters?: Record<string, string | undefined>;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* What the application keeps between the authorization request and the callback (in its session, a cookie, …), to
|
|
792
|
+
* check the callback and redeem the code.
|
|
793
|
+
*/
|
|
794
|
+
interface AuthioAuthorizationTransaction {
|
|
795
|
+
/** The checks the request was made with; the callback checks exactly these. */
|
|
796
|
+
readonly checks: readonly Exclude<AuthioCheck, "none">[];
|
|
797
|
+
/** With the `state` check. */
|
|
798
|
+
readonly state?: string;
|
|
799
|
+
/** With the `nonce` check. */
|
|
800
|
+
readonly nonce?: string;
|
|
801
|
+
/** With the `pkce` check. */
|
|
802
|
+
readonly codeVerifier?: string;
|
|
803
|
+
/** With the `pkce` check. */
|
|
804
|
+
readonly codeChallengeMethod?: AuthioCodeChallengeMethod;
|
|
805
|
+
readonly redirectUri: string;
|
|
806
|
+
readonly resource?: string;
|
|
807
|
+
readonly maxAge?: number;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* An authorization URL and the transaction to keep until the callback.
|
|
811
|
+
*/
|
|
812
|
+
interface AuthioAuthorizationUrl {
|
|
813
|
+
readonly url: string;
|
|
814
|
+
readonly transaction: AuthioAuthorizationTransaction;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* A `WWW-Authenticate` bearer challenge, as an API answers it (RFC 6750, RFC 9470, RFC 9728).
|
|
818
|
+
*/
|
|
819
|
+
interface AuthioBearerChallenge {
|
|
820
|
+
readonly error: string | undefined;
|
|
821
|
+
readonly errorDescription: string | undefined;
|
|
822
|
+
/** `insufficient_scope`: the scopes required. */
|
|
823
|
+
readonly scope: string | undefined;
|
|
824
|
+
/** `insufficient_user_authentication`: the context classes to ask for. */
|
|
825
|
+
readonly acrValues: string | undefined;
|
|
826
|
+
/** `insufficient_user_authentication`: how old the sign-in may be, in seconds. */
|
|
827
|
+
readonly maxAge: number | undefined;
|
|
828
|
+
/** RFC 9728: where the API's protected resource metadata is. */
|
|
829
|
+
readonly resourceMetadata: string | undefined;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Creates a PKCE pair: a 256-bit random verifier and its S256 (or plain) challenge.
|
|
833
|
+
*/
|
|
834
|
+
declare function createAuthioPkce(method?: AuthioCodeChallengeMethod): Promise<AuthioPkcePair>;
|
|
835
|
+
/**
|
|
836
|
+
* A random, URL-safe value of `bytes` random bytes, for `state` and `nonce`.
|
|
837
|
+
*/
|
|
838
|
+
declare function randomValue(bytes?: number): string;
|
|
839
|
+
/**
|
|
840
|
+
* A front-channel logout request (OpenID Connect Front-Channel Logout 1.0): Authio loads the client's
|
|
841
|
+
* `frontchannel_logout_uri` in an iframe, with `iss` and `sid` when the client requires the session.
|
|
842
|
+
*/
|
|
843
|
+
interface AuthioFrontChannelLogout {
|
|
844
|
+
/** `sid`: the Authio session that ended, when Authio sent it. */
|
|
845
|
+
readonly sessionId: string | undefined;
|
|
846
|
+
/** `iss`, when Authio sent it; always this client's issuer. */
|
|
847
|
+
readonly issuer: string | undefined;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Reads a front-channel logout request: `iss` and `sid` come together, and `iss` must be the issuer.
|
|
851
|
+
*
|
|
852
|
+
* @throws AuthioCallbackError with `issuer_mismatch` for another issuer, `missing_issuer` for a `sid` without `iss`.
|
|
853
|
+
*/
|
|
854
|
+
declare function readAuthioFrontChannelLogout(request: string | URL | URLSearchParams | Readonly<Record<string, unknown>>, issuer: string): AuthioFrontChannelLogout;
|
|
855
|
+
/**
|
|
856
|
+
* Parses a `WWW-Authenticate` bearer challenge, or `undefined` when the header holds none.
|
|
857
|
+
*/
|
|
858
|
+
declare function parseAuthioBearerChallenge(header: string | null | undefined): AuthioBearerChallenge | undefined;
|
|
447
859
|
|
|
448
860
|
/**
|
|
449
861
|
* A token endpoint answer, as Authio sends it.
|
|
@@ -529,9 +941,10 @@ interface AuthioClientCredentialsToken {
|
|
|
529
941
|
* One of the person's connected accounts at a provider.
|
|
530
942
|
*/
|
|
531
943
|
interface AuthioConnectionChoice {
|
|
532
|
-
id: string;
|
|
533
|
-
label?: string;
|
|
534
|
-
|
|
944
|
+
readonly id: string;
|
|
945
|
+
readonly label?: string;
|
|
946
|
+
/** The account's login at the provider. */
|
|
947
|
+
readonly externalLogin?: string;
|
|
535
948
|
}
|
|
536
949
|
/**
|
|
537
950
|
* The account at the provider a connection token belongs to.
|
|
@@ -540,6 +953,7 @@ interface AuthioExternalAccount {
|
|
|
540
953
|
id?: string;
|
|
541
954
|
login?: string;
|
|
542
955
|
email?: string;
|
|
956
|
+
[member: string]: unknown;
|
|
543
957
|
}
|
|
544
958
|
/**
|
|
545
959
|
* The outcome of exchanging a user's token for the token of one of their connected accounts.
|
|
@@ -551,15 +965,17 @@ type AuthioConnectionExchangeResult = AuthioConnectionGranted | AuthioConnection
|
|
|
551
965
|
interface AuthioConnectionGranted {
|
|
552
966
|
readonly status: "granted";
|
|
553
967
|
readonly accessToken: string;
|
|
554
|
-
|
|
555
|
-
readonly providerType?: string;
|
|
556
|
-
readonly connectionId?: string;
|
|
557
|
-
readonly tokenType?: string;
|
|
968
|
+
/** `urn:authio:params:oauth:token-type:connection-access-token`. */
|
|
558
969
|
readonly issuedTokenType?: string;
|
|
559
|
-
readonly
|
|
560
|
-
readonly externalAccount?: AuthioExternalAccount;
|
|
970
|
+
readonly tokenType?: string;
|
|
561
971
|
/** Seconds. */
|
|
562
972
|
readonly expiresIn?: number;
|
|
973
|
+
readonly scope?: string;
|
|
974
|
+
readonly connectionId?: string;
|
|
975
|
+
readonly provider: string;
|
|
976
|
+
/** The kind of provider, such as `GitHubApp`. */
|
|
977
|
+
readonly providerType?: string;
|
|
978
|
+
readonly externalAccount?: AuthioExternalAccount;
|
|
563
979
|
}
|
|
564
980
|
/**
|
|
565
981
|
* The person has not connected an account at the provider yet; send them to `connectUri`.
|
|
@@ -567,15 +983,19 @@ interface AuthioConnectionGranted {
|
|
|
567
983
|
interface AuthioConnectionRequired {
|
|
568
984
|
readonly status: "required";
|
|
569
985
|
readonly connectUri?: string;
|
|
570
|
-
readonly
|
|
986
|
+
readonly provider: string;
|
|
987
|
+
readonly errorCode?: string;
|
|
988
|
+
readonly errorDescription: string;
|
|
571
989
|
}
|
|
572
990
|
/**
|
|
573
991
|
* The person has several accounts at the provider; ask again with one `connectionId`.
|
|
574
992
|
*/
|
|
575
993
|
interface AuthioConnectionSelectionRequired {
|
|
576
994
|
readonly status: "selection_required";
|
|
995
|
+
readonly provider: string;
|
|
577
996
|
readonly connections: readonly AuthioConnectionChoice[];
|
|
578
|
-
readonly
|
|
997
|
+
readonly errorCode?: string;
|
|
998
|
+
readonly errorDescription: string;
|
|
579
999
|
}
|
|
580
1000
|
/**
|
|
581
1001
|
* Authio refused the exchange.
|
|
@@ -583,10 +1003,20 @@ interface AuthioConnectionSelectionRequired {
|
|
|
583
1003
|
interface AuthioConnectionRefused {
|
|
584
1004
|
readonly status: "refused";
|
|
585
1005
|
readonly error: string;
|
|
586
|
-
readonly
|
|
587
|
-
readonly
|
|
1006
|
+
readonly errorCode?: string;
|
|
1007
|
+
readonly errorDescription: string;
|
|
588
1008
|
readonly connectUri?: string;
|
|
589
1009
|
}
|
|
1010
|
+
/**
|
|
1011
|
+
* What one poll of the device flow's token endpoint means (RFC 8628 §3.5).
|
|
1012
|
+
*/
|
|
1013
|
+
type AuthioDevicePollOutcome = {
|
|
1014
|
+
readonly outcome: "keep_polling";
|
|
1015
|
+
readonly intervalIncrease: number;
|
|
1016
|
+
} | {
|
|
1017
|
+
readonly outcome: "failed";
|
|
1018
|
+
readonly error: string;
|
|
1019
|
+
};
|
|
590
1020
|
|
|
591
1021
|
/**
|
|
592
1022
|
* Everything the Authio client needs: where Authio is, and the client's credentials.
|
|
@@ -596,8 +1026,78 @@ interface AuthioClientOptions extends AuthioConnectionOptions, AuthioClientCrede
|
|
|
596
1026
|
* Seconds before expiry a cached token is renewed (capped at half its lifetime). Defaults to 60.
|
|
597
1027
|
*/
|
|
598
1028
|
tokenRefreshSkew?: number;
|
|
599
|
-
/**
|
|
600
|
-
|
|
1029
|
+
/**
|
|
1030
|
+
* What the authorization round trip checks, as the client is registered in Authio: `pkce`, `state`, `nonce`, or
|
|
1031
|
+
* `none`. Only the listed checks are made; omitted, none is (a client that requires PKCE needs `["pkce"]`).
|
|
1032
|
+
*/
|
|
1033
|
+
checks?: readonly AuthioCheck[];
|
|
1034
|
+
/** The PKCE method, when `checks` holds `pkce`: one of the client's allowed methods. Defaults to `S256`. */
|
|
1035
|
+
codeChallengeMethod?: AuthioCodeChallengeMethod;
|
|
1036
|
+
/** The `response_mode` sent with every authorization request: `query` or `web_message`. Omitted, none is sent. */
|
|
1037
|
+
responseMode?: AuthioResponseMode;
|
|
1038
|
+
/**
|
|
1039
|
+
* The algorithm the client's ID tokens are signed with, as registered in Authio, which signs the client's logout
|
|
1040
|
+
* tokens with it too. HS256, HS384 and HS512 are verified with `clientSecret` (OpenID Connect Core
|
|
1041
|
+
* §10.1). Omitted, the asymmetric algorithms the discovery document announces are accepted (RS*, PS*, ES*).
|
|
1042
|
+
*/
|
|
1043
|
+
idTokenSignedResponseAlg?: string;
|
|
1044
|
+
/** The algorithm a signed UserInfo answer is signed with. Defaults to `idTokenSignedResponseAlg`. */
|
|
1045
|
+
userinfoSignedResponseAlg?: string;
|
|
1046
|
+
/**
|
|
1047
|
+
* The algorithm the client's access tokens are signed with (Authio's second signing setting), for
|
|
1048
|
+
* `readAccessTokenClaims`. HS* is verified with `clientSecret`. Omitted, the asymmetric algorithms the discovery
|
|
1049
|
+
* document announces are accepted, and never HS*.
|
|
1050
|
+
*/
|
|
1051
|
+
accessTokenSignedResponseAlg?: string;
|
|
1052
|
+
/**
|
|
1053
|
+
* The private half of the client's own encryption key, to read ID tokens, UserInfo and logout tokens Authio
|
|
1054
|
+
* encrypts to the client; or a function returning it. Without it, nothing is decrypted.
|
|
1055
|
+
*/
|
|
1056
|
+
clientEncryptionKey?: AuthioEncryptionKeySource;
|
|
1057
|
+
/** A PEM or JWK file holding `clientEncryptionKey` (Node only), read on first use. */
|
|
1058
|
+
clientEncryptionKeyPath?: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* The key management algorithms (`alg`) decrypted, as registered for the client. Defaults to RSA-OAEP and
|
|
1061
|
+
* RSA-OAEP-256; RSA1_5 cannot be listed, because Node and WebCrypto cannot decrypt it.
|
|
1062
|
+
*/
|
|
1063
|
+
encryptionAlgorithms?: readonly string[];
|
|
1064
|
+
/** The content encryption algorithms (`enc`) decrypted. Defaults to A128CBC-HS256, A192CBC-HS384, A256CBC-HS512. */
|
|
1065
|
+
encryptionMethods?: readonly string[];
|
|
1066
|
+
/**
|
|
1067
|
+
* Accepted for parity with the other Authio SDKs; RSA1_5 stays refused here, because Node and WebCrypto cannot
|
|
1068
|
+
* decrypt it. Defaults to `false`.
|
|
1069
|
+
*/
|
|
1070
|
+
allowLegacyEncryptionAlgorithms?: boolean;
|
|
1071
|
+
/** Where Authio sends the person back after signing in, unless a request names another. */
|
|
1072
|
+
redirectUri?: string;
|
|
1073
|
+
/** Where Authio sends the person after signing out, unless a request names another. */
|
|
1074
|
+
postLogoutRedirectUri?: string;
|
|
1075
|
+
/** Seconds of clock skew tolerated on ID tokens, logout tokens and signed UserInfo. Defaults to 30. */
|
|
1076
|
+
clockSkew?: number;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* What a completed sign-in yields.
|
|
1080
|
+
*/
|
|
1081
|
+
interface AuthioAuthorizationResult {
|
|
1082
|
+
/** The token endpoint's answer: access token, refresh token, ID token. */
|
|
1083
|
+
readonly tokens: AuthioTokenResponse;
|
|
1084
|
+
/** The validated ID token's claims, when Authio issued one (the `openid` scope). */
|
|
1085
|
+
readonly idToken: AuthioIdTokenClaims | undefined;
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* What the end-session URL carries (OpenID Connect RP-Initiated Logout).
|
|
1089
|
+
*/
|
|
1090
|
+
interface AuthioEndSessionRequest {
|
|
1091
|
+
/** The ID token of the session to end. */
|
|
1092
|
+
idTokenHint?: string;
|
|
1093
|
+
/** Where to send the person afterwards; must be registered. Defaults to the client's `postLogoutRedirectUri`. */
|
|
1094
|
+
postLogoutRedirectUri?: string;
|
|
1095
|
+
/** Echoed back to `postLogoutRedirectUri`. */
|
|
1096
|
+
state?: string;
|
|
1097
|
+
/** The language of the signed-out screen. */
|
|
1098
|
+
uiLocales?: string | readonly string[];
|
|
1099
|
+
/** Sends the client id unless `false`, so Authio knows the client without an ID token. */
|
|
1100
|
+
includeClientId?: boolean;
|
|
601
1101
|
}
|
|
602
1102
|
/**
|
|
603
1103
|
* Per-call options.
|
|
@@ -622,10 +1122,14 @@ interface AuthioTokenClient {
|
|
|
622
1122
|
codeVerifier?: string;
|
|
623
1123
|
resource?: string;
|
|
624
1124
|
} & AuthioCallOptions): Promise<AuthioTokenResponse>;
|
|
625
|
-
/**
|
|
1125
|
+
/**
|
|
1126
|
+
* Refreshes; the answer carries the rotated refresh token, which must be stored. `scopes` may only narrow the
|
|
1127
|
+
* granted ones; `resource` (RFC 8707) asks for an access token addressed to that resource server.
|
|
1128
|
+
*/
|
|
626
1129
|
refresh(options: {
|
|
627
1130
|
refreshToken: string;
|
|
628
1131
|
scopes?: Iterable<string> | string;
|
|
1132
|
+
resource?: string;
|
|
629
1133
|
} & AuthioCallOptions): Promise<AuthioTokenResponse>;
|
|
630
1134
|
/** Exchanges a user's access token for one addressed to another resource (RFC 8693, on-behalf-of). */
|
|
631
1135
|
exchange(options: {
|
|
@@ -661,6 +1165,16 @@ interface AuthioTokenClient {
|
|
|
661
1165
|
password: string;
|
|
662
1166
|
scopes?: Iterable<string> | string;
|
|
663
1167
|
} & AuthioCallOptions): Promise<AuthioTokenResponse>;
|
|
1168
|
+
/**
|
|
1169
|
+
* The `personal_access_token` grant: a `pat_` value presented as `client_secret`, with the consumer's client id for
|
|
1170
|
+
* a consumer's token or none for an account's token. The client's own credentials are not sent.
|
|
1171
|
+
*/
|
|
1172
|
+
personalAccessToken(options: {
|
|
1173
|
+
token: string;
|
|
1174
|
+
clientId?: string;
|
|
1175
|
+
scopes?: Iterable<string> | string;
|
|
1176
|
+
resource?: string;
|
|
1177
|
+
} & AuthioCallOptions): Promise<AuthioTokenResponse>;
|
|
664
1178
|
}
|
|
665
1179
|
/**
|
|
666
1180
|
* Client-credentials tokens, cached per scopes and resource.
|
|
@@ -721,6 +1235,65 @@ interface AuthioClient {
|
|
|
721
1235
|
resource?: string;
|
|
722
1236
|
fetch?: typeof fetch;
|
|
723
1237
|
}): typeof fetch;
|
|
1238
|
+
/**
|
|
1239
|
+
* Builds the authorization URL (the parameters of the configured `checks`, and Authio's parameters) and the
|
|
1240
|
+
* transaction to keep until the callback.
|
|
1241
|
+
*/
|
|
1242
|
+
createAuthorizationUrl(request?: AuthioAuthorizationRequest & AuthioCallOptions): Promise<AuthioAuthorizationUrl>;
|
|
1243
|
+
/**
|
|
1244
|
+
* Completes a sign-in: checks `state` (with the `state` check) and the `iss` parameter (RFC 9207), throws the OAuth
|
|
1245
|
+
* error Authio sent back, redeems the code (with the PKCE verifier, with the `pkce` check), and validates the ID
|
|
1246
|
+
* token (`nonce` with the `nonce` check, `at_hash`, `max_age`). A `state` the transaction did not ask for is ignored.
|
|
1247
|
+
*
|
|
1248
|
+
* @param callback The callback URL, its query, or its parameters (a `web_message` answer, a parsed query).
|
|
1249
|
+
* @param transaction What `createAuthorizationUrl` returned with the URL.
|
|
1250
|
+
* @throws AuthioCallbackError when the callback is not for this transaction.
|
|
1251
|
+
* @throws AuthioProtocolError for an OAuth error.
|
|
1252
|
+
* @throws AuthioTokenValidationError when the ID token does not validate.
|
|
1253
|
+
*/
|
|
1254
|
+
handleAuthorizationCallback(callback: string | URL | URLSearchParams | Readonly<Record<string, unknown>>, transaction: AuthioAuthorizationTransaction, options?: AuthioCallOptions): Promise<AuthioAuthorizationResult>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Validates an ID token: decrypted with `clientEncryptionKey` when it is a JWE, then signature (cached JWKS), `iss`,
|
|
1257
|
+
* `aud` = the client id, `exp` with the skew, payload `typ` = `ID`, and `nonce`, `at_hash` and `auth_time` when
|
|
1258
|
+
* given.
|
|
1259
|
+
*
|
|
1260
|
+
* @throws AuthioTokenValidationError naming why it was refused.
|
|
1261
|
+
*/
|
|
1262
|
+
validateIdToken(idToken: string, expectations?: {
|
|
1263
|
+
nonce?: string;
|
|
1264
|
+
accessToken?: string;
|
|
1265
|
+
maxAge?: number;
|
|
1266
|
+
} & AuthioCallOptions): Promise<AuthioIdTokenClaims>;
|
|
1267
|
+
/**
|
|
1268
|
+
* Validates a back-channel logout token Authio posted as `logout_token`.
|
|
1269
|
+
*
|
|
1270
|
+
* @throws AuthioTokenValidationError naming why it was refused (`invalid_logout_token` for the logout-specific rules).
|
|
1271
|
+
*/
|
|
1272
|
+
validateLogoutToken(logoutToken: string, options?: AuthioCallOptions): Promise<AuthioLogoutToken>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Reads a front-channel logout request Authio loaded in an iframe: `iss` must be the issuer, and `sid` comes with
|
|
1275
|
+
* it. End the sessions of `sessionId`, or the browser's own session when Authio sent none.
|
|
1276
|
+
*
|
|
1277
|
+
* @throws AuthioCallbackError when `iss` names another issuer, or `sid` comes without `iss`.
|
|
1278
|
+
*/
|
|
1279
|
+
validateFrontChannelLogout(request: string | URL | URLSearchParams | Readonly<Record<string, unknown>>): AuthioFrontChannelLogout;
|
|
1280
|
+
/**
|
|
1281
|
+
* Reads an access token this client received from Authio: decrypted with `clientEncryptionKey` when it is a JWE,
|
|
1282
|
+
* then its signature (with `accessTokenSignedResponseAlg`), `iss` and `exp` checked. Its audience is the API's, so it is not checked. `undefined` for an
|
|
1283
|
+
* opaque token, or an encrypted one without `clientEncryptionKey`.
|
|
1284
|
+
*
|
|
1285
|
+
* @throws AuthioTokenValidationError naming why it was refused.
|
|
1286
|
+
*/
|
|
1287
|
+
readAccessTokenClaims(accessToken: string, options?: AuthioCallOptions): Promise<JWTPayload | undefined>;
|
|
1288
|
+
/** Builds the end-session URL (RP-Initiated Logout). */
|
|
1289
|
+
createEndSessionUrl(request?: AuthioEndSessionRequest & AuthioCallOptions): Promise<string>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Builds an authorization URL that satisfies an API's `insufficient_user_authentication` challenge (RFC 9470): its
|
|
1292
|
+
* `acr_values` and `max_age`, with `prompt=login` when the challenge asks for a sign-in made just now (`max_age=0`).
|
|
1293
|
+
*
|
|
1294
|
+
* @param challenge The `WWW-Authenticate` header value, or the challenge already parsed.
|
|
1295
|
+
*/
|
|
1296
|
+
createStepUpAuthorizationUrl(challenge: string | AuthioBearerChallenge, request?: AuthioAuthorizationRequest & AuthioCallOptions): Promise<AuthioAuthorizationUrl>;
|
|
724
1297
|
}
|
|
725
1298
|
/**
|
|
726
1299
|
* Creates the Authio client.
|
|
@@ -733,6 +1306,102 @@ declare function createAuthioClient(options: AuthioClientOptions): AuthioClient;
|
|
|
733
1306
|
* renewed `refreshSkewMs` before that, at most half its lifetime.
|
|
734
1307
|
*/
|
|
735
1308
|
declare function toClientCredentialsToken(response: AuthioTokenResponse, issuedAt: number, refreshSkewMs: number): AuthioClientCredentialsToken;
|
|
1309
|
+
/**
|
|
1310
|
+
* Reads the answer of a connected-account token exchange (see `conformance/oauth-responses.json`).
|
|
1311
|
+
*
|
|
1312
|
+
* @internal
|
|
1313
|
+
*/
|
|
1314
|
+
declare function toConnectionExchangeResult(body: string, status: number, provider: string): AuthioConnectionExchangeResult;
|
|
1315
|
+
/**
|
|
1316
|
+
* What a device-flow poll's OAuth error means: keep polling (5 seconds slower after `slow_down`), or stop with it.
|
|
1317
|
+
*/
|
|
1318
|
+
declare function toDevicePollOutcome(error: string): AuthioDevicePollOutcome;
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* A successful Admin API answer: the envelope's `data` (one object, or a listing's page `{ items, totalCount,
|
|
1322
|
+
* pageNumber, pageSize }`), nothing for `204`.
|
|
1323
|
+
*/
|
|
1324
|
+
interface AuthioAdminSuccess<T = unknown> {
|
|
1325
|
+
readonly ok: true;
|
|
1326
|
+
readonly data?: T;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* A refused Admin API answer.
|
|
1330
|
+
*/
|
|
1331
|
+
interface AuthioAdminFailure {
|
|
1332
|
+
readonly ok: false;
|
|
1333
|
+
readonly error: AuthioAdminError;
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* An Admin API answer, read.
|
|
1337
|
+
*/
|
|
1338
|
+
type AuthioAdminEnvelope<T = unknown> = AuthioAdminSuccess<T> | AuthioAdminFailure;
|
|
1339
|
+
/**
|
|
1340
|
+
* How an account credential is presented: `ak_` (API key), `cs_` (client secret, exchanged first) or `pat_`
|
|
1341
|
+
* (personal access token).
|
|
1342
|
+
*/
|
|
1343
|
+
type AuthioAccountCredentialKind = "api_key" | "client_secret" | "personal_access_token";
|
|
1344
|
+
/**
|
|
1345
|
+
* Options of `createAuthioAccountCredential`.
|
|
1346
|
+
*/
|
|
1347
|
+
interface AuthioAccountCredentialOptions extends Omit<AuthioConnectionOptions, "issuer" | "realm"> {
|
|
1348
|
+
/** Authio's base URL, such as `https://auth.example.com`. Required. */
|
|
1349
|
+
authority?: string;
|
|
1350
|
+
/** The credential's value: `ak_…`, `cs_…` or `pat_…`. */
|
|
1351
|
+
credential: string;
|
|
1352
|
+
/** The credential's id, needed to exchange a `cs_` secret (its `client_id` is `cred_` and the id without dashes). */
|
|
1353
|
+
credentialId?: string;
|
|
1354
|
+
/** How an `ak_` or `pat_` value is sent directly: `Authorization: Bearer` (default) or `x-api-key`. */
|
|
1355
|
+
presentAs?: "bearer" | "x-api-key";
|
|
1356
|
+
/** Exchanges a `pat_` value with the `personal_access_token` grant instead of sending it directly. */
|
|
1357
|
+
exchangePersonalAccessToken?: boolean;
|
|
1358
|
+
/** Narrows an exchanged token to these `admin:{permission}:{method}` scopes. */
|
|
1359
|
+
scopes?: Iterable<string> | string;
|
|
1360
|
+
/** Seconds before expiry an exchanged token is renewed (at most half its lifetime). Defaults to 60. */
|
|
1361
|
+
tokenRefreshSkew?: number;
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* An account credential ready to call the Admin API with.
|
|
1365
|
+
*/
|
|
1366
|
+
interface AuthioAccountCredential {
|
|
1367
|
+
/** How the credential is presented. */
|
|
1368
|
+
readonly kind: AuthioAccountCredentialKind;
|
|
1369
|
+
/** Whether it is exchanged at the `authio` realm's token endpoint before use. */
|
|
1370
|
+
readonly exchanged: boolean;
|
|
1371
|
+
/** The headers that authenticate a request: `Authorization` or `x-api-key`. */
|
|
1372
|
+
headers(signal?: AbortSignal): Promise<Record<string, string>>;
|
|
1373
|
+
/** Drops an exchanged token, so the next request exchanges again. */
|
|
1374
|
+
invalidate(): void;
|
|
1375
|
+
/**
|
|
1376
|
+
* A `fetch` that authenticates every request; on `401` with an exchanged token it exchanges again and retries once;
|
|
1377
|
+
* on `429` or `503` it waits `Retry-After` and retries an idempotent request (`GET`, `HEAD`, `PUT`, `DELETE`) once.
|
|
1378
|
+
*/
|
|
1379
|
+
readonly fetch: typeof fetch;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Reads an Admin API answer (see `conformance/admin-envelopes.json`). The status is the HTTP one, never the
|
|
1383
|
+
* envelope's numeric `statusCode`; `requestId` falls back to `X-Request-Id`, and `retryAfterSeconds` comes from
|
|
1384
|
+
* `Retry-After`.
|
|
1385
|
+
*/
|
|
1386
|
+
declare function parseAuthioAdminEnvelope<T = unknown>(status: number, body: string | null | undefined, headers?: Headers | Readonly<Record<string, string | undefined>>): AuthioAdminEnvelope<T>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Reads an Admin API response, throwing `AuthioAdminError` when it is not a success.
|
|
1389
|
+
*/
|
|
1390
|
+
declare function readAuthioAdminResponse<T = unknown>(response: Response): Promise<AuthioAdminSuccess<T>>;
|
|
1391
|
+
/**
|
|
1392
|
+
* Prepares an account credential for the Admin API: `ak_` and `pat_` go directly as `Authorization: Bearer` (or
|
|
1393
|
+
* `x-api-key`); a `cs_` secret is exchanged at `{authority}/realms/authio` with `client_credentials` and the
|
|
1394
|
+
* `client_id` `cred_{id}`; a `pat_` may be exchanged with the `personal_access_token` grant instead. Exchanged tokens
|
|
1395
|
+
* are cached and renewed before expiry.
|
|
1396
|
+
*
|
|
1397
|
+
* @throws AuthioConfigurationError when the value has no known prefix or a `cs_` secret comes without its id.
|
|
1398
|
+
*/
|
|
1399
|
+
declare function createAuthioAccountCredential(options: AuthioAccountCredentialOptions): AuthioAccountCredential;
|
|
1400
|
+
/**
|
|
1401
|
+
* The `client_id` an account credential's client secret is exchanged with: `cred_` and the id in format N (no dashes,
|
|
1402
|
+
* lower case). An id already starting with `cred_` is kept.
|
|
1403
|
+
*/
|
|
1404
|
+
declare function toCredentialClientId(credentialId: string): string;
|
|
736
1405
|
|
|
737
1406
|
/**
|
|
738
1407
|
* One role read from a `*_resource_access` claim, with the permissions it grants.
|
|
@@ -811,109 +1480,152 @@ type AuthioWebhookVerificationResult = {
|
|
|
811
1480
|
readonly timestamp?: Date;
|
|
812
1481
|
};
|
|
813
1482
|
/**
|
|
814
|
-
* A webhook event. `data` holds the event-specific payload; read it typed
|
|
1483
|
+
* A webhook event. `data` holds the event-specific payload as delivered (snake_case); read it typed, in camelCase,
|
|
1484
|
+
* with the `as…` helpers.
|
|
815
1485
|
*/
|
|
816
1486
|
interface AuthioWebhookEvent {
|
|
817
1487
|
readonly id: string;
|
|
818
1488
|
readonly type: string;
|
|
819
1489
|
/** Seconds since the epoch. */
|
|
820
1490
|
readonly created_at: number;
|
|
821
|
-
readonly realm_id?: string;
|
|
822
|
-
readonly client_id?: string;
|
|
1491
|
+
readonly realm_id?: string | null;
|
|
1492
|
+
readonly client_id?: string | null;
|
|
823
1493
|
readonly data: unknown;
|
|
824
1494
|
[member: string]: unknown;
|
|
825
1495
|
}
|
|
826
|
-
/** `user_created`, `user_updated`, `user_deleted
|
|
1496
|
+
/** `user_created`, `user_updated`, `user_deleted`, as delivered. */
|
|
827
1497
|
interface AuthioWebhookUserData {
|
|
828
1498
|
id: string;
|
|
829
|
-
username?: string;
|
|
830
|
-
email?: string;
|
|
831
|
-
first_name?: string;
|
|
832
|
-
last_name?: string;
|
|
1499
|
+
username?: string | null;
|
|
1500
|
+
email?: string | null;
|
|
1501
|
+
first_name?: string | null;
|
|
1502
|
+
last_name?: string | null;
|
|
833
1503
|
email_confirmed: boolean;
|
|
834
|
-
status?: string;
|
|
835
|
-
realm_id?: string;
|
|
836
|
-
client_id?: string;
|
|
1504
|
+
status?: string | null;
|
|
1505
|
+
realm_id?: string | null;
|
|
1506
|
+
client_id?: string | null;
|
|
837
1507
|
}
|
|
838
|
-
/** `login_succeeded`, `login_failed
|
|
1508
|
+
/** `login_succeeded`, `login_failed`, as delivered. */
|
|
839
1509
|
interface AuthioWebhookLoginData {
|
|
840
|
-
grant_type?: string;
|
|
841
|
-
user_id?: string;
|
|
842
|
-
username?: string;
|
|
843
|
-
email?: string;
|
|
844
|
-
ip_address?: string;
|
|
845
|
-
user_agent?: string;
|
|
846
|
-
session_id?: string;
|
|
847
|
-
failure_reason?: string;
|
|
848
|
-
resource?: string;
|
|
849
|
-
scopes?: string;
|
|
1510
|
+
grant_type?: string | null;
|
|
1511
|
+
user_id?: string | null;
|
|
1512
|
+
username?: string | null;
|
|
1513
|
+
email?: string | null;
|
|
1514
|
+
ip_address?: string | null;
|
|
1515
|
+
user_agent?: string | null;
|
|
1516
|
+
session_id?: string | null;
|
|
1517
|
+
failure_reason?: string | null;
|
|
1518
|
+
resource?: string | null;
|
|
1519
|
+
scopes?: string[] | null;
|
|
1520
|
+
authentication_methods?: string[] | null;
|
|
1521
|
+
acr?: string | null;
|
|
1522
|
+
identity_provider?: string | null;
|
|
1523
|
+
consumer_id?: string | null;
|
|
1524
|
+
consumer_name?: string | null;
|
|
850
1525
|
}
|
|
851
|
-
/** `user_locked_out
|
|
1526
|
+
/** `user_locked_out`, as delivered. */
|
|
852
1527
|
interface AuthioWebhookUserLockedOutData {
|
|
853
1528
|
user_id: string;
|
|
854
|
-
username?: string;
|
|
855
|
-
email?: string;
|
|
856
|
-
lockout_end?: string;
|
|
1529
|
+
username?: string | null;
|
|
1530
|
+
email?: string | null;
|
|
1531
|
+
lockout_end?: string | null;
|
|
857
1532
|
access_failed_count: number;
|
|
858
1533
|
}
|
|
859
|
-
/** `token_revoked
|
|
1534
|
+
/** `token_revoked`, as delivered. */
|
|
860
1535
|
interface AuthioWebhookTokenRevokedData {
|
|
861
|
-
token_id?: string;
|
|
862
|
-
subject?: string;
|
|
863
|
-
session_id?: string;
|
|
864
|
-
token_type_hint?: string;
|
|
1536
|
+
token_id?: string | null;
|
|
1537
|
+
subject?: string | null;
|
|
1538
|
+
session_id?: string | null;
|
|
1539
|
+
token_type_hint?: string | null;
|
|
865
1540
|
}
|
|
866
|
-
/**
|
|
1541
|
+
/**
|
|
1542
|
+
* `keys_rotated`, as delivered: `rotation_days` and `automatic` on a scheduled rotation, `revoked_keys_count` on a
|
|
1543
|
+
* manual one.
|
|
1544
|
+
*/
|
|
867
1545
|
interface AuthioWebhookKeysRotatedData {
|
|
868
|
-
signing_key_id?: string;
|
|
869
|
-
encryption_key_id?: string;
|
|
870
|
-
revoked_keys_count?: number;
|
|
871
|
-
rotation_days?: number;
|
|
872
|
-
automatic?: boolean;
|
|
1546
|
+
signing_key_id?: string | null;
|
|
1547
|
+
encryption_key_id?: string | null;
|
|
1548
|
+
revoked_keys_count?: number | null;
|
|
1549
|
+
rotation_days?: number | null;
|
|
1550
|
+
automatic?: boolean | null;
|
|
873
1551
|
}
|
|
874
|
-
/** `token_reuse_detected
|
|
1552
|
+
/** `token_reuse_detected`, as delivered. */
|
|
875
1553
|
interface AuthioWebhookTokenReuseDetectedData {
|
|
876
|
-
token_id?: string;
|
|
877
|
-
subject?: string;
|
|
878
|
-
session_id?: string;
|
|
879
|
-
ip_address?: string;
|
|
880
|
-
user_agent?: string;
|
|
1554
|
+
token_id?: string | null;
|
|
1555
|
+
subject?: string | null;
|
|
1556
|
+
session_id?: string | null;
|
|
1557
|
+
ip_address?: string | null;
|
|
1558
|
+
user_agent?: string | null;
|
|
881
1559
|
}
|
|
882
|
-
/** `admin_resource_created`, `admin_resource_updated`, `admin_resource_deleted
|
|
1560
|
+
/** `admin_resource_created`, `admin_resource_updated`, `admin_resource_deleted`, as delivered. */
|
|
883
1561
|
interface AuthioWebhookAdminResourceData {
|
|
884
|
-
action?: string;
|
|
885
|
-
resource_type?: string;
|
|
886
|
-
resource_id?: string;
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1562
|
+
action?: string | null;
|
|
1563
|
+
resource_type?: string | null;
|
|
1564
|
+
resource_id?: string | null;
|
|
1565
|
+
parent_id?: string | null;
|
|
1566
|
+
realm_id?: string | null;
|
|
1567
|
+
client_id?: string | null;
|
|
1568
|
+
/** `User` or `Credential`. */
|
|
1569
|
+
actor_type?: string | null;
|
|
1570
|
+
actor_user_id?: string | null;
|
|
1571
|
+
actor_username?: string | null;
|
|
1572
|
+
actor_email?: string | null;
|
|
1573
|
+
actor_credential_id?: string | null;
|
|
1574
|
+
actor_credential_name?: string | null;
|
|
1575
|
+
actor_platform_operator?: boolean | null;
|
|
1576
|
+
ip_address?: string | null;
|
|
1577
|
+
method?: string | null;
|
|
1578
|
+
path?: string | null;
|
|
1579
|
+
/** What changed, by resource type; kept as delivered. */
|
|
1580
|
+
details?: Record<string, unknown> | null;
|
|
1581
|
+
}
|
|
1582
|
+
/** `user_suspended`, `user_suspension_ended`, as delivered. */
|
|
897
1583
|
interface AuthioWebhookUserSuspensionData {
|
|
898
1584
|
id: string;
|
|
899
1585
|
user_id: string;
|
|
900
|
-
level?: string;
|
|
901
|
-
status?: string;
|
|
902
|
-
starts_at?: string;
|
|
903
|
-
ends_at?: string;
|
|
1586
|
+
level?: string | null;
|
|
1587
|
+
status?: string | null;
|
|
1588
|
+
starts_at?: string | null;
|
|
1589
|
+
ends_at?: string | null;
|
|
904
1590
|
restricted_scopes: string[];
|
|
905
1591
|
revokes_every_role: boolean;
|
|
906
1592
|
revoked_role_ids: string[];
|
|
907
|
-
sessions_terminated_at?: string;
|
|
908
|
-
lifted_at?: string;
|
|
1593
|
+
sessions_terminated_at?: string | null;
|
|
1594
|
+
lifted_at?: string | null;
|
|
1595
|
+
}
|
|
1596
|
+
/** `attack_detected`, as delivered: an attack on the realm and the measure Authio took. */
|
|
1597
|
+
interface AuthioWebhookAttackDetectedData {
|
|
1598
|
+
incident_id: string;
|
|
1599
|
+
/** Such as `credential_stuffing`. */
|
|
1600
|
+
kind?: string | null;
|
|
1601
|
+
severity?: string | null;
|
|
1602
|
+
/** Such as `source_blocked`. */
|
|
1603
|
+
measure?: string | null;
|
|
1604
|
+
ip_address?: string | null;
|
|
1605
|
+
country?: string | null;
|
|
1606
|
+
asn?: number | null;
|
|
1607
|
+
network_operator?: string | null;
|
|
1608
|
+
user_id?: string | null;
|
|
1609
|
+
started_at?: string | null;
|
|
1610
|
+
}
|
|
1611
|
+
/** `credential_compromised`, as delivered: a person's password was used by an attacker. */
|
|
1612
|
+
interface AuthioWebhookCredentialCompromisedData {
|
|
1613
|
+
incident_id: string;
|
|
1614
|
+
user_id?: string | null;
|
|
1615
|
+
username?: string | null;
|
|
1616
|
+
ip_address?: string | null;
|
|
1617
|
+
country?: string | null;
|
|
1618
|
+
asn?: number | null;
|
|
1619
|
+
network_operator?: string | null;
|
|
1620
|
+
password_change_required?: boolean | null;
|
|
909
1621
|
}
|
|
910
|
-
/** `ping
|
|
1622
|
+
/** `ping`, as delivered. */
|
|
911
1623
|
interface AuthioWebhookPingData {
|
|
912
|
-
message?: string;
|
|
913
|
-
subscription?: string;
|
|
1624
|
+
message?: string | null;
|
|
1625
|
+
subscription?: string | null;
|
|
914
1626
|
}
|
|
915
1627
|
/**
|
|
916
|
-
* The data shape of each event type.
|
|
1628
|
+
* The data shape of each event type, as delivered (snake_case).
|
|
917
1629
|
*/
|
|
918
1630
|
interface AuthioWebhookDataByType {
|
|
919
1631
|
user_created: AuthioWebhookUserData;
|
|
@@ -930,10 +1642,44 @@ interface AuthioWebhookDataByType {
|
|
|
930
1642
|
admin_resource_deleted: AuthioWebhookAdminResourceData;
|
|
931
1643
|
user_suspended: AuthioWebhookUserSuspensionData;
|
|
932
1644
|
user_suspension_ended: AuthioWebhookUserSuspensionData;
|
|
1645
|
+
attack_detected: AuthioWebhookAttackDetectedData;
|
|
1646
|
+
credential_compromised: AuthioWebhookCredentialCompromisedData;
|
|
933
1647
|
ping: AuthioWebhookPingData;
|
|
934
1648
|
}
|
|
935
1649
|
/**
|
|
936
|
-
*
|
|
1650
|
+
* A snake_case name in camelCase.
|
|
1651
|
+
*/
|
|
1652
|
+
type AuthioCamelCase<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<AuthioCamelCase<Tail>>}` : S;
|
|
1653
|
+
/**
|
|
1654
|
+
* An object whose top-level member names are turned into camelCase, values unchanged.
|
|
1655
|
+
*/
|
|
1656
|
+
type AuthioCamelCased<T> = {
|
|
1657
|
+
[K in keyof T as K extends string ? AuthioCamelCase<K> : K]: T[K];
|
|
1658
|
+
};
|
|
1659
|
+
/** The data of a user event, as the typed accessor exposes it. */
|
|
1660
|
+
type AuthioWebhookUser = AuthioCamelCased<AuthioWebhookUserData>;
|
|
1661
|
+
/** The data of a login event, as the typed accessor exposes it. */
|
|
1662
|
+
type AuthioWebhookLogin = AuthioCamelCased<AuthioWebhookLoginData>;
|
|
1663
|
+
/** The data of a lockout event, as the typed accessor exposes it. */
|
|
1664
|
+
type AuthioWebhookUserLockedOut = AuthioCamelCased<AuthioWebhookUserLockedOutData>;
|
|
1665
|
+
/** The data of a revocation event, as the typed accessor exposes it. */
|
|
1666
|
+
type AuthioWebhookTokenRevoked = AuthioCamelCased<AuthioWebhookTokenRevokedData>;
|
|
1667
|
+
/** The data of a key rotation event, as the typed accessor exposes it. */
|
|
1668
|
+
type AuthioWebhookKeysRotated = AuthioCamelCased<AuthioWebhookKeysRotatedData>;
|
|
1669
|
+
/** The data of a refresh token reuse event, as the typed accessor exposes it. */
|
|
1670
|
+
type AuthioWebhookTokenReuseDetected = AuthioCamelCased<AuthioWebhookTokenReuseDetectedData>;
|
|
1671
|
+
/** The data of an admin resource event, as the typed accessor exposes it. */
|
|
1672
|
+
type AuthioWebhookAdminResource = AuthioCamelCased<AuthioWebhookAdminResourceData>;
|
|
1673
|
+
/** The data of a suspension event, as the typed accessor exposes it. */
|
|
1674
|
+
type AuthioWebhookUserSuspension = AuthioCamelCased<AuthioWebhookUserSuspensionData>;
|
|
1675
|
+
/** The data of an attack event, as the typed accessor exposes it. */
|
|
1676
|
+
type AuthioWebhookAttackDetected = AuthioCamelCased<AuthioWebhookAttackDetectedData>;
|
|
1677
|
+
/** The data of a compromised credential event, as the typed accessor exposes it. */
|
|
1678
|
+
type AuthioWebhookCredentialCompromised = AuthioCamelCased<AuthioWebhookCredentialCompromisedData>;
|
|
1679
|
+
/** The data of a ping, as the typed accessor exposes it. */
|
|
1680
|
+
type AuthioWebhookPing = AuthioCamelCased<AuthioWebhookPingData>;
|
|
1681
|
+
/**
|
|
1682
|
+
* An event narrowed to one type, with its data typed as delivered.
|
|
937
1683
|
*/
|
|
938
1684
|
type AuthioTypedWebhookEvent<T extends keyof AuthioWebhookDataByType> = AuthioWebhookEvent & {
|
|
939
1685
|
readonly type: T;
|
|
@@ -973,23 +1719,40 @@ declare function tryParseWebhookEvent(rawBody: string | Uint8Array | null | unde
|
|
|
973
1719
|
* Whether the event is of one of the given types, narrowing its data.
|
|
974
1720
|
*/
|
|
975
1721
|
declare function isWebhookEventOfType<T extends keyof AuthioWebhookDataByType>(event: AuthioWebhookEvent, ...types: T[]): event is AuthioTypedWebhookEvent<T>;
|
|
976
|
-
/** The data of a user event, or `undefined` for any other type. */
|
|
977
|
-
declare const asUserEvent: (event: AuthioWebhookEvent) => AuthioWebhookUserData | undefined;
|
|
978
|
-
/** The data of a login event, or `undefined` for any other type. */
|
|
979
|
-
declare const asLoginEvent: (event: AuthioWebhookEvent) => AuthioWebhookLoginData | undefined;
|
|
980
|
-
/** The data of a lockout event, or `undefined` for any other type. */
|
|
981
|
-
declare const asUserLockedOutEvent: (event: AuthioWebhookEvent) => AuthioWebhookUserLockedOutData | undefined;
|
|
982
|
-
/** The data of a revocation event, or `undefined` for any other type. */
|
|
983
|
-
declare const asTokenRevokedEvent: (event: AuthioWebhookEvent) => AuthioWebhookTokenRevokedData | undefined;
|
|
984
|
-
/** The data of a key rotation event, or `undefined` for any other type. */
|
|
985
|
-
declare const asKeysRotatedEvent: (event: AuthioWebhookEvent) => AuthioWebhookKeysRotatedData | undefined;
|
|
986
|
-
/** The data of a refresh token reuse event, or `undefined` for any other type. */
|
|
987
|
-
declare const asTokenReuseDetectedEvent: (event: AuthioWebhookEvent) => AuthioWebhookTokenReuseDetectedData | undefined;
|
|
988
|
-
/** The data of an admin resource event, or `undefined` for any other type. */
|
|
989
|
-
declare const asAdminResourceEvent: (event: AuthioWebhookEvent) => AuthioWebhookAdminResourceData | undefined;
|
|
990
|
-
/** The data of a suspension event, or `undefined` for any other type. */
|
|
991
|
-
declare const asUserSuspensionEvent: (event: AuthioWebhookEvent) => AuthioWebhookUserSuspensionData | undefined;
|
|
992
|
-
/** The data of
|
|
993
|
-
declare const
|
|
1722
|
+
/** The data of a user event in camelCase, or `undefined` for any other type. */
|
|
1723
|
+
declare const asUserEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookUserData> | undefined;
|
|
1724
|
+
/** The data of a login event in camelCase, or `undefined` for any other type. */
|
|
1725
|
+
declare const asLoginEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookLoginData> | undefined;
|
|
1726
|
+
/** The data of a lockout event in camelCase, or `undefined` for any other type. */
|
|
1727
|
+
declare const asUserLockedOutEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookUserLockedOutData> | undefined;
|
|
1728
|
+
/** The data of a revocation event in camelCase, or `undefined` for any other type. */
|
|
1729
|
+
declare const asTokenRevokedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookTokenRevokedData> | undefined;
|
|
1730
|
+
/** The data of a key rotation event in camelCase, or `undefined` for any other type. */
|
|
1731
|
+
declare const asKeysRotatedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookKeysRotatedData> | undefined;
|
|
1732
|
+
/** The data of a refresh token reuse event in camelCase, or `undefined` for any other type. */
|
|
1733
|
+
declare const asTokenReuseDetectedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookTokenReuseDetectedData> | undefined;
|
|
1734
|
+
/** The data of an admin resource event in camelCase, or `undefined` for any other type. */
|
|
1735
|
+
declare const asAdminResourceEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookAdminResourceData> | undefined;
|
|
1736
|
+
/** The data of a suspension event in camelCase, or `undefined` for any other type. */
|
|
1737
|
+
declare const asUserSuspensionEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookUserSuspensionData> | undefined;
|
|
1738
|
+
/** The data of an attack event in camelCase, or `undefined` for any other type. */
|
|
1739
|
+
declare const asAttackDetectedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookAttackDetectedData> | undefined;
|
|
1740
|
+
/** The data of a compromised credential event in camelCase, or `undefined` for any other type. */
|
|
1741
|
+
declare const asCredentialCompromisedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookCredentialCompromisedData> | undefined;
|
|
1742
|
+
/** The data of a ping in camelCase, or `undefined` for any other type. */
|
|
1743
|
+
declare const asPingEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookPingData> | undefined;
|
|
1744
|
+
/**
|
|
1745
|
+
* Whether Authio documents the event type. An unknown type still parses; read its `data` as delivered.
|
|
1746
|
+
*/
|
|
1747
|
+
declare function isKnownWebhookEventType(type: string): type is keyof AuthioWebhookDataByType;
|
|
1748
|
+
/**
|
|
1749
|
+
* The data of any known event in camelCase (what the typed accessor of its type returns), or `undefined` for an
|
|
1750
|
+
* unknown type.
|
|
1751
|
+
*/
|
|
1752
|
+
declare function readWebhookEventData(event: AuthioWebhookEvent): Record<string, unknown> | undefined;
|
|
1753
|
+
/**
|
|
1754
|
+
* Turns the top-level member names of an object from snake_case into camelCase, leaving the values as they are.
|
|
1755
|
+
*/
|
|
1756
|
+
declare function toCamelCasedMembers<T extends object>(value: T): AuthioCamelCased<T>;
|
|
994
1757
|
|
|
995
|
-
export { AuthioAsymmetricAlgorithms, type AuthioCallOptions,
|
|
1758
|
+
export { type AuthioAccountCredential, type AuthioAccountCredentialKind, type AuthioAccountCredentialOptions, type AuthioAdminEnvelope, AuthioAdminError, type AuthioAdminFailure, type AuthioAdminNotification, type AuthioAdminSuccess, AuthioAsymmetricAlgorithms, type AuthioAuthorizationRequest, type AuthioAuthorizationResult, type AuthioAuthorizationTransaction, type AuthioAuthorizationUrl, type AuthioBearerChallenge, type AuthioCallOptions, AuthioCallbackError, type AuthioCallbackFailure, type AuthioCallerKind, AuthioCallerKinds, type AuthioCamelCase, type AuthioCamelCased, type AuthioCheck, AuthioChecks, AuthioClaimTypes, type AuthioClient, AuthioClientAssertionAlgorithms, type AuthioClientCredentialsCache, type AuthioClientCredentialsSettings, type AuthioClientCredentialsToken, type AuthioClientOptions, type AuthioClock, type AuthioCodeChallengeMethod, AuthioConfigurationError, type AuthioConnection, type AuthioConnectionChoice, type AuthioConnectionExchangeResult, type AuthioConnectionGranted, type AuthioConnectionOptions, type AuthioConnectionRefused, type AuthioConnectionRequired, type AuthioConnectionSelectionRequired, AuthioContentEncryptionAlgorithms, type AuthioCredentialForm, AuthioDefaults, type AuthioDeviceAuthorization, type AuthioDevicePollOutcome, type AuthioDiscoveryClient, type AuthioDiscoveryDocument, AuthioDiscoveryError, type AuthioEncryptionKey, type AuthioEncryptionKeySource, type AuthioEndSessionRequest, AuthioError, type AuthioErrorResponse, type AuthioExternalAccount, type AuthioFrontChannelLogout, AuthioGrantTypes, AuthioHmacAlgorithms, AuthioHmacMinimumSecretBytes, type AuthioIdTokenClaims, type AuthioIntrospectionResult, type AuthioJwtExpectations, AuthioKeyManagementAlgorithms, AuthioLegacyKeyManagementAlgorithms, type AuthioLogoutToken, AuthioOAuthErrors, type AuthioPkcePair, type AuthioPrivateKeyInput, type AuthioPrompt, AuthioPrompts, AuthioProtocolError, AuthioResourceAccess, AuthioResourceAccessClaims, type AuthioResourceAccessRole, type AuthioResourceAccessSource, type AuthioResponseMode, AuthioScopes, type AuthioSecretSource, type AuthioSigningKeys, AuthioSupportedContentEncryptionAlgorithms, type AuthioTokenClient, type AuthioTokenDecrypter, type AuthioTokenDecrypterOptions, type AuthioTokenEndpointAuthMethod, AuthioTokenEndpointAuthMethods, type AuthioTokenFailure, type AuthioTokenResponse, AuthioTokenTypes, AuthioTokenValidationError, type AuthioTypedWebhookEvent, type AuthioUserInfo, type AuthioWebhookAdminResource, type AuthioWebhookAdminResourceData, type AuthioWebhookAttackDetected, type AuthioWebhookAttackDetectedData, type AuthioWebhookCredentialCompromised, type AuthioWebhookCredentialCompromisedData, type AuthioWebhookDataByType, type AuthioWebhookEvent, AuthioWebhookEventTypes, AuthioWebhookHeaders, type AuthioWebhookKeysRotated, type AuthioWebhookKeysRotatedData, type AuthioWebhookLogin, type AuthioWebhookLoginData, type AuthioWebhookPing, type AuthioWebhookPingData, type AuthioWebhookTokenReuseDetected, type AuthioWebhookTokenReuseDetectedData, type AuthioWebhookTokenRevoked, type AuthioWebhookTokenRevokedData, type AuthioWebhookUser, type AuthioWebhookUserData, type AuthioWebhookUserLockedOut, type AuthioWebhookUserLockedOutData, type AuthioWebhookUserSuspension, type AuthioWebhookUserSuspensionData, type AuthioWebhookVerificationFailure, type AuthioWebhookVerificationResult, asAdminResourceEvent, asAttackDetectedEvent, asCredentialCompromisedEvent, asKeysRotatedEvent, asLoginEvent, asPingEvent, asTokenReuseDetectedEvent, asTokenRevokedEvent, asUserEvent, asUserLockedOutEvent, asUserSuspensionEvent, computeAuthioTokenHash, computeWebhookSignatureHeader, createAuthioAccountCredential, createAuthioClient, createAuthioDiscoveryClient, createAuthioPkce, createAuthioSigningKeys, createAuthioTokenDecrypter, encryptionKeyFromFile, escapeDataString, isAllowedUrl, isAuthioTokenEncrypted, isKnownWebhookEventType, isWebhookEventOfType, parseAuthioAdminEnvelope, parseAuthioBearerChallenge, parseResourceAccess, parseResourceAccessClaim, parseWebhookEvent, randomValue, readAuthioAdminResponse, readAuthioFrontChannelLogout, readWebhookEventData, requireHmacSecretLength, resolveConnection, resolveIssuer, resourceAccessSourceOf, seconds, systemClock, toBasicAuthorization, toCamelCasedMembers, toClientCredentialsToken, toConnectionExchangeResult, toCredentialClientId, toDevicePollOutcome, toScopeString, toTokenValidationError, tryParseWebhookEvent, verifyAuthioJwt, verifyWebhookSignature, withClientSecret };
|