@hyper.authio/client 0.8.1 → 0.9.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/dist/index.d.cts CHANGED
@@ -151,6 +151,10 @@ declare const AuthioWebhookEventTypes: {
151
151
  readonly UserSuspensionEnded: "user_suspension_ended";
152
152
  readonly AttackDetected: "attack_detected";
153
153
  readonly CredentialCompromised: "credential_compromised";
154
+ readonly UserAuthenticatorAppEnrolled: "user_authenticator_app_enrolled";
155
+ readonly UserAuthenticatorAppRemoved: "user_authenticator_app_removed";
156
+ readonly UserRecoveryCodesRegenerated: "user_recovery_codes_regenerated";
157
+ readonly UserRecoveryCodeUsed: "user_recovery_code_used";
154
158
  readonly Ping: "ping";
155
159
  };
156
160
  /**
@@ -216,6 +220,8 @@ declare const AuthioDefaults: {
216
220
  readonly CredentialClientIdPrefix: "cred_";
217
221
  readonly ApiKeyHeader: "x-api-key";
218
222
  readonly RequestIdHeader: "X-Request-Id";
223
+ /** The header `typ` of an access token (RFC 9068 §2.1). */
224
+ readonly AccessTokenType: "at+jwt";
219
225
  /** The header `typ` of a back-channel logout token. */
220
226
  readonly LogoutTokenType: "logout+jwt";
221
227
  /** The event a back-channel logout token carries. */
@@ -717,6 +723,15 @@ declare function toTokenValidationError(error: unknown, audiences: readonly stri
717
723
  * digest, base64url-encoded (OpenID Connect Core §3.1.3.6).
718
724
  */
719
725
  declare function computeAuthioTokenHash(value: string, algorithm: string): Promise<string>;
726
+ /**
727
+ * Requires the header `typ` of an access token to be `at+jwt` (or `application/at+jwt`), as RFC 9068 §4 asks a
728
+ * resource server to check, so an ID token or any other JWT is never taken for an access token.
729
+ *
730
+ * @param header The protected header of the verified token.
731
+ * @throws AuthioTokenValidationError with the reason `not_access_token` otherwise.
732
+ * @internal
733
+ */
734
+ declare function requireAccessTokenType(header: Record<string, unknown>): void;
720
735
 
721
736
  /**
722
737
  * The PKCE method (RFC 7636). `S256` is the default; `plain` only when asked for, for a client that cannot hash.
@@ -1169,7 +1184,8 @@ interface AuthioTokenClient {
1169
1184
  } & AuthioCallOptions): Promise<AuthioTokenResponse>;
1170
1185
  /**
1171
1186
  * The `personal_access_token` grant: a `pat_` value presented as `client_secret`, with the consumer's client id for
1172
- * a consumer's token or none for an account's token. The client's own credentials are not sent.
1187
+ * a consumer's token or the platform client (`AuthioDefaults.PlatformClientId`) for an account's token. The client's
1188
+ * own credentials are not sent.
1173
1189
  */
1174
1190
  personalAccessToken(options: {
1175
1191
  token: string;
@@ -1281,7 +1297,8 @@ interface AuthioClient {
1281
1297
  validateFrontChannelLogout(request: string | URL | URLSearchParams | Readonly<Record<string, unknown>>): AuthioFrontChannelLogout;
1282
1298
  /**
1283
1299
  * Reads an access token this client received from Authio: decrypted with `clientEncryptionKey` when it is a JWE,
1284
- * then its signature (with `accessTokenSignedResponseAlg`), `iss` and `exp` checked. Its audience is the API's, so it is not checked. `undefined` for an
1300
+ * then its signature (with `accessTokenSignedResponseAlg`), `iss`, `exp` and the header `typ` `at+jwt` (RFC 9068 §4)
1301
+ * checked. Its audience is the API's, so it is not checked. `undefined` for an
1285
1302
  * opaque token, or an encrypted one without `clientEncryptionKey`.
1286
1303
  *
1287
1304
  * @throws AuthioTokenValidationError naming why it was refused.
@@ -1491,6 +1508,10 @@ interface AuthioWebhookEvent {
1491
1508
  /** Seconds since the epoch. */
1492
1509
  readonly created_at: number;
1493
1510
  readonly realm_id?: string | null;
1511
+ /**
1512
+ * The client the event came through. On a realm endpoint, `null` when there is none, such as a person created in
1513
+ * the realm.
1514
+ */
1494
1515
  readonly client_id?: string | null;
1495
1516
  readonly data: unknown;
1496
1517
  [member: string]: unknown;
@@ -1621,6 +1642,19 @@ interface AuthioWebhookCredentialCompromisedData {
1621
1642
  network_operator?: string | null;
1622
1643
  password_change_required?: boolean | null;
1623
1644
  }
1645
+ /**
1646
+ * `user_authenticator_app_enrolled`, `user_authenticator_app_removed`, `user_recovery_codes_regenerated` and
1647
+ * `user_recovery_code_used`, as delivered: a change to a person's authenticator app, never a code nor the secret.
1648
+ */
1649
+ interface AuthioWebhookAuthenticatorAppData {
1650
+ user_id: string;
1651
+ username?: string | null;
1652
+ email?: string | null;
1653
+ /** Who made the change: `user`, or `administrator` when an administrator reset the app. */
1654
+ actor?: string | null;
1655
+ /** The recovery codes the account has left after the change. */
1656
+ recovery_codes_remaining?: number | null;
1657
+ }
1624
1658
  /** `ping`, as delivered. */
1625
1659
  interface AuthioWebhookPingData {
1626
1660
  message?: string | null;
@@ -1646,6 +1680,10 @@ interface AuthioWebhookDataByType {
1646
1680
  user_suspension_ended: AuthioWebhookUserSuspensionData;
1647
1681
  attack_detected: AuthioWebhookAttackDetectedData;
1648
1682
  credential_compromised: AuthioWebhookCredentialCompromisedData;
1683
+ user_authenticator_app_enrolled: AuthioWebhookAuthenticatorAppData;
1684
+ user_authenticator_app_removed: AuthioWebhookAuthenticatorAppData;
1685
+ user_recovery_codes_regenerated: AuthioWebhookAuthenticatorAppData;
1686
+ user_recovery_code_used: AuthioWebhookAuthenticatorAppData;
1649
1687
  ping: AuthioWebhookPingData;
1650
1688
  }
1651
1689
  /**
@@ -1678,6 +1716,8 @@ type AuthioWebhookUserSuspension = AuthioCamelCased<AuthioWebhookUserSuspensionD
1678
1716
  type AuthioWebhookAttackDetected = AuthioCamelCased<AuthioWebhookAttackDetectedData>;
1679
1717
  /** The data of a compromised credential event, as the typed accessor exposes it. */
1680
1718
  type AuthioWebhookCredentialCompromised = AuthioCamelCased<AuthioWebhookCredentialCompromisedData>;
1719
+ /** The data of an authenticator app event, as the typed accessor exposes it. */
1720
+ type AuthioWebhookAuthenticatorApp = AuthioCamelCased<AuthioWebhookAuthenticatorAppData>;
1681
1721
  /** The data of a ping, as the typed accessor exposes it. */
1682
1722
  type AuthioWebhookPing = AuthioCamelCased<AuthioWebhookPingData>;
1683
1723
  /**
@@ -1741,6 +1781,8 @@ declare const asUserSuspensionEvent: (event: AuthioWebhookEvent) => AuthioCamelC
1741
1781
  declare const asAttackDetectedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookAttackDetectedData> | undefined;
1742
1782
  /** The data of a compromised credential event in camelCase, or `undefined` for any other type. */
1743
1783
  declare const asCredentialCompromisedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookCredentialCompromisedData> | undefined;
1784
+ /** The data of an authenticator app event in camelCase, or `undefined` for any other type. */
1785
+ declare const asAuthenticatorAppEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookAuthenticatorAppData> | undefined;
1744
1786
  /** The data of a ping in camelCase, or `undefined` for any other type. */
1745
1787
  declare const asPingEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookPingData> | undefined;
1746
1788
  /**
@@ -1757,4 +1799,4 @@ declare function readWebhookEventData(event: AuthioWebhookEvent): Record<string,
1757
1799
  */
1758
1800
  declare function toCamelCasedMembers<T extends object>(value: T): AuthioCamelCased<T>;
1759
1801
 
1760
- 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 };
1802
+ 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 AuthioWebhookAuthenticatorApp, type AuthioWebhookAuthenticatorAppData, 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, asAuthenticatorAppEvent, 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, requireAccessTokenType, requireHmacSecretLength, resolveConnection, resolveIssuer, resourceAccessSourceOf, seconds, systemClock, toBasicAuthorization, toCamelCasedMembers, toClientCredentialsToken, toConnectionExchangeResult, toCredentialClientId, toDevicePollOutcome, toScopeString, toTokenValidationError, tryParseWebhookEvent, verifyAuthioJwt, verifyWebhookSignature, withClientSecret };
package/dist/index.d.ts CHANGED
@@ -151,6 +151,10 @@ declare const AuthioWebhookEventTypes: {
151
151
  readonly UserSuspensionEnded: "user_suspension_ended";
152
152
  readonly AttackDetected: "attack_detected";
153
153
  readonly CredentialCompromised: "credential_compromised";
154
+ readonly UserAuthenticatorAppEnrolled: "user_authenticator_app_enrolled";
155
+ readonly UserAuthenticatorAppRemoved: "user_authenticator_app_removed";
156
+ readonly UserRecoveryCodesRegenerated: "user_recovery_codes_regenerated";
157
+ readonly UserRecoveryCodeUsed: "user_recovery_code_used";
154
158
  readonly Ping: "ping";
155
159
  };
156
160
  /**
@@ -216,6 +220,8 @@ declare const AuthioDefaults: {
216
220
  readonly CredentialClientIdPrefix: "cred_";
217
221
  readonly ApiKeyHeader: "x-api-key";
218
222
  readonly RequestIdHeader: "X-Request-Id";
223
+ /** The header `typ` of an access token (RFC 9068 §2.1). */
224
+ readonly AccessTokenType: "at+jwt";
219
225
  /** The header `typ` of a back-channel logout token. */
220
226
  readonly LogoutTokenType: "logout+jwt";
221
227
  /** The event a back-channel logout token carries. */
@@ -717,6 +723,15 @@ declare function toTokenValidationError(error: unknown, audiences: readonly stri
717
723
  * digest, base64url-encoded (OpenID Connect Core §3.1.3.6).
718
724
  */
719
725
  declare function computeAuthioTokenHash(value: string, algorithm: string): Promise<string>;
726
+ /**
727
+ * Requires the header `typ` of an access token to be `at+jwt` (or `application/at+jwt`), as RFC 9068 §4 asks a
728
+ * resource server to check, so an ID token or any other JWT is never taken for an access token.
729
+ *
730
+ * @param header The protected header of the verified token.
731
+ * @throws AuthioTokenValidationError with the reason `not_access_token` otherwise.
732
+ * @internal
733
+ */
734
+ declare function requireAccessTokenType(header: Record<string, unknown>): void;
720
735
 
721
736
  /**
722
737
  * The PKCE method (RFC 7636). `S256` is the default; `plain` only when asked for, for a client that cannot hash.
@@ -1169,7 +1184,8 @@ interface AuthioTokenClient {
1169
1184
  } & AuthioCallOptions): Promise<AuthioTokenResponse>;
1170
1185
  /**
1171
1186
  * The `personal_access_token` grant: a `pat_` value presented as `client_secret`, with the consumer's client id for
1172
- * a consumer's token or none for an account's token. The client's own credentials are not sent.
1187
+ * a consumer's token or the platform client (`AuthioDefaults.PlatformClientId`) for an account's token. The client's
1188
+ * own credentials are not sent.
1173
1189
  */
1174
1190
  personalAccessToken(options: {
1175
1191
  token: string;
@@ -1281,7 +1297,8 @@ interface AuthioClient {
1281
1297
  validateFrontChannelLogout(request: string | URL | URLSearchParams | Readonly<Record<string, unknown>>): AuthioFrontChannelLogout;
1282
1298
  /**
1283
1299
  * Reads an access token this client received from Authio: decrypted with `clientEncryptionKey` when it is a JWE,
1284
- * then its signature (with `accessTokenSignedResponseAlg`), `iss` and `exp` checked. Its audience is the API's, so it is not checked. `undefined` for an
1300
+ * then its signature (with `accessTokenSignedResponseAlg`), `iss`, `exp` and the header `typ` `at+jwt` (RFC 9068 §4)
1301
+ * checked. Its audience is the API's, so it is not checked. `undefined` for an
1285
1302
  * opaque token, or an encrypted one without `clientEncryptionKey`.
1286
1303
  *
1287
1304
  * @throws AuthioTokenValidationError naming why it was refused.
@@ -1491,6 +1508,10 @@ interface AuthioWebhookEvent {
1491
1508
  /** Seconds since the epoch. */
1492
1509
  readonly created_at: number;
1493
1510
  readonly realm_id?: string | null;
1511
+ /**
1512
+ * The client the event came through. On a realm endpoint, `null` when there is none, such as a person created in
1513
+ * the realm.
1514
+ */
1494
1515
  readonly client_id?: string | null;
1495
1516
  readonly data: unknown;
1496
1517
  [member: string]: unknown;
@@ -1621,6 +1642,19 @@ interface AuthioWebhookCredentialCompromisedData {
1621
1642
  network_operator?: string | null;
1622
1643
  password_change_required?: boolean | null;
1623
1644
  }
1645
+ /**
1646
+ * `user_authenticator_app_enrolled`, `user_authenticator_app_removed`, `user_recovery_codes_regenerated` and
1647
+ * `user_recovery_code_used`, as delivered: a change to a person's authenticator app, never a code nor the secret.
1648
+ */
1649
+ interface AuthioWebhookAuthenticatorAppData {
1650
+ user_id: string;
1651
+ username?: string | null;
1652
+ email?: string | null;
1653
+ /** Who made the change: `user`, or `administrator` when an administrator reset the app. */
1654
+ actor?: string | null;
1655
+ /** The recovery codes the account has left after the change. */
1656
+ recovery_codes_remaining?: number | null;
1657
+ }
1624
1658
  /** `ping`, as delivered. */
1625
1659
  interface AuthioWebhookPingData {
1626
1660
  message?: string | null;
@@ -1646,6 +1680,10 @@ interface AuthioWebhookDataByType {
1646
1680
  user_suspension_ended: AuthioWebhookUserSuspensionData;
1647
1681
  attack_detected: AuthioWebhookAttackDetectedData;
1648
1682
  credential_compromised: AuthioWebhookCredentialCompromisedData;
1683
+ user_authenticator_app_enrolled: AuthioWebhookAuthenticatorAppData;
1684
+ user_authenticator_app_removed: AuthioWebhookAuthenticatorAppData;
1685
+ user_recovery_codes_regenerated: AuthioWebhookAuthenticatorAppData;
1686
+ user_recovery_code_used: AuthioWebhookAuthenticatorAppData;
1649
1687
  ping: AuthioWebhookPingData;
1650
1688
  }
1651
1689
  /**
@@ -1678,6 +1716,8 @@ type AuthioWebhookUserSuspension = AuthioCamelCased<AuthioWebhookUserSuspensionD
1678
1716
  type AuthioWebhookAttackDetected = AuthioCamelCased<AuthioWebhookAttackDetectedData>;
1679
1717
  /** The data of a compromised credential event, as the typed accessor exposes it. */
1680
1718
  type AuthioWebhookCredentialCompromised = AuthioCamelCased<AuthioWebhookCredentialCompromisedData>;
1719
+ /** The data of an authenticator app event, as the typed accessor exposes it. */
1720
+ type AuthioWebhookAuthenticatorApp = AuthioCamelCased<AuthioWebhookAuthenticatorAppData>;
1681
1721
  /** The data of a ping, as the typed accessor exposes it. */
1682
1722
  type AuthioWebhookPing = AuthioCamelCased<AuthioWebhookPingData>;
1683
1723
  /**
@@ -1741,6 +1781,8 @@ declare const asUserSuspensionEvent: (event: AuthioWebhookEvent) => AuthioCamelC
1741
1781
  declare const asAttackDetectedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookAttackDetectedData> | undefined;
1742
1782
  /** The data of a compromised credential event in camelCase, or `undefined` for any other type. */
1743
1783
  declare const asCredentialCompromisedEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookCredentialCompromisedData> | undefined;
1784
+ /** The data of an authenticator app event in camelCase, or `undefined` for any other type. */
1785
+ declare const asAuthenticatorAppEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookAuthenticatorAppData> | undefined;
1744
1786
  /** The data of a ping in camelCase, or `undefined` for any other type. */
1745
1787
  declare const asPingEvent: (event: AuthioWebhookEvent) => AuthioCamelCased<AuthioWebhookPingData> | undefined;
1746
1788
  /**
@@ -1757,4 +1799,4 @@ declare function readWebhookEventData(event: AuthioWebhookEvent): Record<string,
1757
1799
  */
1758
1800
  declare function toCamelCasedMembers<T extends object>(value: T): AuthioCamelCased<T>;
1759
1801
 
1760
- 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 };
1802
+ 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 AuthioWebhookAuthenticatorApp, type AuthioWebhookAuthenticatorAppData, 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, asAuthenticatorAppEvent, 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, requireAccessTokenType, requireHmacSecretLength, resolveConnection, resolveIssuer, resourceAccessSourceOf, seconds, systemClock, toBasicAuthorization, toCamelCasedMembers, toClientCredentialsToken, toConnectionExchangeResult, toCredentialClientId, toDevicePollOutcome, toScopeString, toTokenValidationError, tryParseWebhookEvent, verifyAuthioJwt, verifyWebhookSignature, withClientSecret };
package/dist/index.js CHANGED
@@ -127,6 +127,10 @@ var AuthioWebhookEventTypes = {
127
127
  UserSuspensionEnded: "user_suspension_ended",
128
128
  AttackDetected: "attack_detected",
129
129
  CredentialCompromised: "credential_compromised",
130
+ UserAuthenticatorAppEnrolled: "user_authenticator_app_enrolled",
131
+ UserAuthenticatorAppRemoved: "user_authenticator_app_removed",
132
+ UserRecoveryCodesRegenerated: "user_recovery_codes_regenerated",
133
+ UserRecoveryCodeUsed: "user_recovery_code_used",
130
134
  Ping: "ping"
131
135
  };
132
136
  var AuthioWebhookHeaders = {
@@ -162,6 +166,8 @@ var AuthioDefaults = {
162
166
  CredentialClientIdPrefix: "cred_",
163
167
  ApiKeyHeader: "x-api-key",
164
168
  RequestIdHeader: "X-Request-Id",
169
+ /** The header `typ` of an access token (RFC 9068 §2.1). */
170
+ AccessTokenType: "at+jwt",
165
171
  /** The header `typ` of a back-channel logout token. */
166
172
  LogoutTokenType: "logout+jwt",
167
173
  /** The event a back-channel logout token carries. */
@@ -960,6 +966,14 @@ async function validateAuthioIdToken(token, context, expectations = {}) {
960
966
  }
961
967
  return payload;
962
968
  }
969
+ function requireAccessTokenType(header) {
970
+ const type = typeof header.typ === "string" ? header.typ.toLowerCase() : void 0;
971
+ if (type !== AuthioDefaults.AccessTokenType && type !== `application/${AuthioDefaults.AccessTokenType}`)
972
+ throw new AuthioTokenValidationError(
973
+ "not_access_token",
974
+ `Only access tokens are accepted; this token's header typ is '${header.typ ?? ""}', not '${AuthioDefaults.AccessTokenType}'.`
975
+ );
976
+ }
963
977
  async function validateAuthioLogoutToken(token, context) {
964
978
  const signed = isAuthioTokenEncrypted(token) ? await context.decrypt(token) : token;
965
979
  const invalid = (message) => new AuthioTokenValidationError("invalid_logout_token", message);
@@ -1291,12 +1305,13 @@ function createAuthioClient(options) {
1291
1305
  const signed = await decrypt(accessToken);
1292
1306
  if (signed.split(".").length !== 3) return void 0;
1293
1307
  const document = await discovery.get(callOptions.signal);
1294
- const { payload } = await verifyAuthioJwt(signed, withClientSecret(await signingKeys(callOptions.signal), clientSecret), {
1308
+ const { payload, header } = await verifyAuthioJwt(signed, withClientSecret(await signingKeys(callOptions.signal), clientSecret), {
1295
1309
  issuer: connection.issuer,
1296
1310
  algorithms: acceptedSigningAlgorithms(accessTokenAlgorithm, document.id_token_signing_alg_values_supported),
1297
1311
  clockSkew,
1298
1312
  now: connection.clock.now()
1299
1313
  });
1314
+ requireAccessTokenType(header);
1300
1315
  return payload;
1301
1316
  },
1302
1317
  async createEndSessionUrl(request = {}) {
@@ -1709,7 +1724,7 @@ function createAuthioAccountCredential(options) {
1709
1724
  if (cached && clock.now() < cached.refreshAt) return cached;
1710
1725
  pending ??= (async () => {
1711
1726
  const issuedAt = clock.now();
1712
- const answer = kind === "client_secret" ? await client.tokens.clientCredentials({ scopes: scope, signal }) : await client.tokens.personalAccessToken({ token: value, scopes: scope, signal });
1727
+ const answer = kind === "client_secret" ? await client.tokens.clientCredentials({ scopes: scope, signal }) : await client.tokens.personalAccessToken({ token: value, clientId: AuthioDefaults.PlatformClientId, scopes: scope, signal });
1713
1728
  cached = toClientCredentialsToken(answer, issuedAt, refreshSkewMs);
1714
1729
  return cached;
1715
1730
  })().finally(() => {
@@ -2022,6 +2037,13 @@ var asAdminResourceEvent = (event) => dataWhen(
2022
2037
  var asUserSuspensionEvent = (event) => dataWhen(event, AuthioWebhookEventTypes.UserSuspended, AuthioWebhookEventTypes.UserSuspensionEnded);
2023
2038
  var asAttackDetectedEvent = (event) => dataWhen(event, AuthioWebhookEventTypes.AttackDetected);
2024
2039
  var asCredentialCompromisedEvent = (event) => dataWhen(event, AuthioWebhookEventTypes.CredentialCompromised);
2040
+ var asAuthenticatorAppEvent = (event) => dataWhen(
2041
+ event,
2042
+ AuthioWebhookEventTypes.UserAuthenticatorAppEnrolled,
2043
+ AuthioWebhookEventTypes.UserAuthenticatorAppRemoved,
2044
+ AuthioWebhookEventTypes.UserRecoveryCodesRegenerated,
2045
+ AuthioWebhookEventTypes.UserRecoveryCodeUsed
2046
+ );
2025
2047
  var asPingEvent = (event) => dataWhen(event, AuthioWebhookEventTypes.Ping);
2026
2048
  var knownEventTypes = new Set(Object.values(AuthioWebhookEventTypes));
2027
2049
  function isKnownWebhookEventType(type) {
@@ -2075,6 +2097,6 @@ function constantTimeEquals(left, right) {
2075
2097
  return difference === 0;
2076
2098
  }
2077
2099
 
2078
- export { AuthioAdminError, AuthioAsymmetricAlgorithms, AuthioCallbackError, AuthioCallerKinds, AuthioChecks, AuthioClaimTypes, AuthioClientAssertionAlgorithms, AuthioConfigurationError, AuthioContentEncryptionAlgorithms, AuthioDefaults, AuthioDiscoveryError, AuthioError, AuthioGrantTypes, AuthioHmacAlgorithms, AuthioHmacMinimumSecretBytes, AuthioKeyManagementAlgorithms, AuthioLegacyKeyManagementAlgorithms, AuthioOAuthErrors, AuthioPrompts, AuthioProtocolError, AuthioResourceAccess, AuthioResourceAccessClaims, AuthioScopes, AuthioSupportedContentEncryptionAlgorithms, AuthioTokenEndpointAuthMethods, AuthioTokenTypes, AuthioTokenValidationError, AuthioWebhookEventTypes, AuthioWebhookHeaders, 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 };
2100
+ export { AuthioAdminError, AuthioAsymmetricAlgorithms, AuthioCallbackError, AuthioCallerKinds, AuthioChecks, AuthioClaimTypes, AuthioClientAssertionAlgorithms, AuthioConfigurationError, AuthioContentEncryptionAlgorithms, AuthioDefaults, AuthioDiscoveryError, AuthioError, AuthioGrantTypes, AuthioHmacAlgorithms, AuthioHmacMinimumSecretBytes, AuthioKeyManagementAlgorithms, AuthioLegacyKeyManagementAlgorithms, AuthioOAuthErrors, AuthioPrompts, AuthioProtocolError, AuthioResourceAccess, AuthioResourceAccessClaims, AuthioScopes, AuthioSupportedContentEncryptionAlgorithms, AuthioTokenEndpointAuthMethods, AuthioTokenTypes, AuthioTokenValidationError, AuthioWebhookEventTypes, AuthioWebhookHeaders, asAdminResourceEvent, asAttackDetectedEvent, asAuthenticatorAppEvent, 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, requireAccessTokenType, requireHmacSecretLength, resolveConnection, resolveIssuer, resourceAccessSourceOf, seconds, systemClock, toBasicAuthorization, toCamelCasedMembers, toClientCredentialsToken, toConnectionExchangeResult, toCredentialClientId, toDevicePollOutcome, toScopeString, toTokenValidationError, tryParseWebhookEvent, verifyAuthioJwt, verifyWebhookSignature, withClientSecret };
2079
2101
  //# sourceMappingURL=index.js.map
2080
2102
  //# sourceMappingURL=index.js.map