@authrim/core 0.1.2 → 0.1.3
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.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +594 -6
- package/dist/index.d.ts +594 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +59 -59
package/dist/index.d.cts
CHANGED
|
@@ -51,6 +51,14 @@ interface HttpClient {
|
|
|
51
51
|
*/
|
|
52
52
|
fetch<T = unknown>(url: string, options?: HttpOptions): Promise<HttpResponse<T>>;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* HTTP error response body (OAuth 2.0 / OIDC standard)
|
|
56
|
+
*/
|
|
57
|
+
interface OAuthErrorResponse {
|
|
58
|
+
error: string;
|
|
59
|
+
error_description?: string;
|
|
60
|
+
error_uri?: string;
|
|
61
|
+
}
|
|
54
62
|
|
|
55
63
|
/**
|
|
56
64
|
* Crypto Provider Interface
|
|
@@ -614,7 +622,7 @@ interface AuthrimErrorMeta {
|
|
|
614
622
|
/**
|
|
615
623
|
* Error codes used by the SDK
|
|
616
624
|
*/
|
|
617
|
-
type AuthrimErrorCode = 'invalid_request' | 'unauthorized_client' | 'access_denied' | 'unsupported_response_type' | 'invalid_scope' | 'server_error' | 'temporarily_unavailable' | 'invalid_grant' | 'invalid_token' | 'invalid_state' | 'expired_state' | 'invalid_nonce' | 'nonce_mismatch' | 'session_expired' | 'session_check_failed' | 'network_error' | 'timeout_error' | 'discovery_error' | 'discovery_mismatch' | 'configuration_error' | 'storage_error' | 'flow_engine_error' | 'no_tokens' | 'token_expired' | 'token_error' | 'refresh_error' | 'token_exchange_error' | 'oauth_error' | 'missing_code' | 'missing_state' | 'not_initialized' | 'no_discovery' | 'no_userinfo_endpoint' | 'userinfo_error' | 'introspection_error' | 'revocation_error' | 'no_introspection_endpoint' | 'no_revocation_endpoint' | 'login_required' | 'interaction_required' | 'consent_required' | 'account_selection_required' | 'dom_not_ready' | 'state_mismatch' | 'popup_blocked' | 'popup_closed' | 'invalid_response';
|
|
625
|
+
type AuthrimErrorCode = 'invalid_request' | 'unauthorized_client' | 'access_denied' | 'unsupported_response_type' | 'invalid_scope' | 'server_error' | 'temporarily_unavailable' | 'invalid_grant' | 'invalid_token' | 'invalid_state' | 'expired_state' | 'invalid_nonce' | 'nonce_mismatch' | 'session_expired' | 'session_check_failed' | 'network_error' | 'timeout_error' | 'discovery_error' | 'discovery_mismatch' | 'configuration_error' | 'storage_error' | 'flow_engine_error' | 'no_tokens' | 'token_expired' | 'token_error' | 'refresh_error' | 'token_exchange_error' | 'oauth_error' | 'missing_code' | 'missing_state' | 'not_initialized' | 'no_discovery' | 'no_userinfo_endpoint' | 'userinfo_error' | 'introspection_error' | 'revocation_error' | 'no_introspection_endpoint' | 'no_revocation_endpoint' | 'login_required' | 'interaction_required' | 'consent_required' | 'account_selection_required' | 'dom_not_ready' | 'state_mismatch' | 'popup_blocked' | 'popup_closed' | 'invalid_response' | 'passkey_not_found' | 'passkey_verification_failed' | 'passkey_not_supported' | 'passkey_cancelled' | 'passkey_invalid_credential' | 'email_code_invalid' | 'email_code_expired' | 'email_code_too_many_attempts' | 'challenge_expired' | 'challenge_invalid' | 'auth_code_invalid' | 'auth_code_expired' | 'pkce_mismatch' | 'origin_not_allowed' | 'mfa_required' | 'email_verification_required' | 'consent_required_direct' | 'rate_limited' | 'event_handler_error';
|
|
618
626
|
/**
|
|
619
627
|
* Options for creating an AuthrimError
|
|
620
628
|
*/
|
|
@@ -685,7 +693,8 @@ interface TokenErrorEvent {
|
|
|
685
693
|
*/
|
|
686
694
|
interface TokenExchangedEvent {
|
|
687
695
|
tokens: TokenSet;
|
|
688
|
-
|
|
696
|
+
/** Issued token type URI (RFC 8693 standard or custom URI) */
|
|
697
|
+
issuedTokenType: TokenTypeUri | string;
|
|
689
698
|
}
|
|
690
699
|
/**
|
|
691
700
|
* Session started event data
|
|
@@ -808,6 +817,8 @@ declare class StateManager {
|
|
|
808
817
|
private readonly clientIdHash;
|
|
809
818
|
/** Default TTL: 10 minutes */
|
|
810
819
|
private static readonly DEFAULT_TTL_SECONDS;
|
|
820
|
+
/** Entropy bytes for state/nonce generation (256 bits = 32 bytes) */
|
|
821
|
+
private static readonly ENTROPY_BYTES;
|
|
811
822
|
constructor(crypto: CryptoProvider, storage: AuthrimStorage, issuerHash: string, clientIdHash: string);
|
|
812
823
|
/**
|
|
813
824
|
* Generate and store auth state
|
|
@@ -980,7 +991,9 @@ declare class AuthorizationCodeFlow {
|
|
|
980
991
|
*
|
|
981
992
|
* @param callbackUrl - Callback URL or query string
|
|
982
993
|
* @returns Parsed code and state
|
|
983
|
-
* @throws AuthrimError
|
|
994
|
+
* @throws AuthrimError with code 'oauth_error' if OAuth error response is present
|
|
995
|
+
* @throws AuthrimError with code 'missing_code' if authorization code is not found
|
|
996
|
+
* @throws AuthrimError with code 'missing_state' if state parameter is not found
|
|
984
997
|
*/
|
|
985
998
|
parseCallback(callbackUrl: string): {
|
|
986
999
|
code: string;
|
|
@@ -992,7 +1005,9 @@ declare class AuthorizationCodeFlow {
|
|
|
992
1005
|
* @param discovery - OIDC discovery document
|
|
993
1006
|
* @param options - Exchange options
|
|
994
1007
|
* @returns Token set
|
|
995
|
-
* @throws AuthrimError
|
|
1008
|
+
* @throws AuthrimError with code 'network_error' if token request fails
|
|
1009
|
+
* @throws AuthrimError with code 'token_error' if token exchange fails
|
|
1010
|
+
* @throws AuthrimError with code 'nonce_mismatch' if ID token nonce validation fails
|
|
996
1011
|
*/
|
|
997
1012
|
exchangeCode(discovery: OIDCDiscoveryDocument, options: ExchangeCodeOptions): Promise<TokenSet>;
|
|
998
1013
|
}
|
|
@@ -1811,7 +1826,7 @@ declare class TokenManager {
|
|
|
1811
1826
|
* Perform refresh with single retry for network errors
|
|
1812
1827
|
*
|
|
1813
1828
|
* @param refreshToken - Refresh token to use
|
|
1814
|
-
* @param attemptedRetry -
|
|
1829
|
+
* @param attemptedRetry - Internal flag to prevent infinite recursion (do not pass externally)
|
|
1815
1830
|
* @returns New token set
|
|
1816
1831
|
*/
|
|
1817
1832
|
private doRefreshWithRetry;
|
|
@@ -1975,6 +1990,7 @@ declare function base64urlEncode(data: Uint8Array): string;
|
|
|
1975
1990
|
*
|
|
1976
1991
|
* @param str - Base64URL encoded string
|
|
1977
1992
|
* @returns Decoded bytes
|
|
1993
|
+
* @throws Error if the input contains invalid characters
|
|
1978
1994
|
*/
|
|
1979
1995
|
declare function base64urlDecode(str: string): Uint8Array;
|
|
1980
1996
|
/**
|
|
@@ -2087,4 +2103,576 @@ declare function getIdTokenNonce(idToken: string): string | undefined;
|
|
|
2087
2103
|
*/
|
|
2088
2104
|
declare function calculateDsHash(deviceSecret: string, crypto: CryptoProvider): Promise<string>;
|
|
2089
2105
|
|
|
2090
|
-
|
|
2106
|
+
/**
|
|
2107
|
+
* Timing-Safe Comparison Utilities
|
|
2108
|
+
*
|
|
2109
|
+
* Provides constant-time string comparison to prevent timing attacks.
|
|
2110
|
+
* Used for comparing security-sensitive values like nonces and states.
|
|
2111
|
+
*/
|
|
2112
|
+
/**
|
|
2113
|
+
* Compare two strings in constant time
|
|
2114
|
+
*
|
|
2115
|
+
* This function always takes the same amount of time regardless of
|
|
2116
|
+
* where the strings differ, preventing timing attacks.
|
|
2117
|
+
*
|
|
2118
|
+
* @param a - First string
|
|
2119
|
+
* @param b - Second string
|
|
2120
|
+
* @returns true if strings are equal, false otherwise
|
|
2121
|
+
*/
|
|
2122
|
+
declare function timingSafeEqual(a: string, b: string): boolean;
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* Direct Authentication API Types
|
|
2126
|
+
*
|
|
2127
|
+
* Simple and intuitive BetterAuth-style API type definitions
|
|
2128
|
+
* for calling Authrim API directly from custom login pages.
|
|
2129
|
+
*/
|
|
2130
|
+
/**
|
|
2131
|
+
* Authenticator transport type
|
|
2132
|
+
*/
|
|
2133
|
+
type AuthenticatorTransportType = 'usb' | 'nfc' | 'ble' | 'internal' | 'hybrid';
|
|
2134
|
+
/**
|
|
2135
|
+
* User verification requirement
|
|
2136
|
+
*/
|
|
2137
|
+
type UserVerificationRequirementType = 'required' | 'preferred' | 'discouraged';
|
|
2138
|
+
/**
|
|
2139
|
+
* Authenticator attachment
|
|
2140
|
+
*/
|
|
2141
|
+
type AuthenticatorAttachmentType = 'platform' | 'cross-platform';
|
|
2142
|
+
/**
|
|
2143
|
+
* Resident key requirement
|
|
2144
|
+
*/
|
|
2145
|
+
type ResidentKeyRequirementType = 'required' | 'preferred' | 'discouraged';
|
|
2146
|
+
/**
|
|
2147
|
+
* Attestation conveyance preference
|
|
2148
|
+
*/
|
|
2149
|
+
type AttestationConveyancePreferenceType = 'none' | 'indirect' | 'direct' | 'enterprise';
|
|
2150
|
+
/**
|
|
2151
|
+
* Public key credential type
|
|
2152
|
+
*/
|
|
2153
|
+
type PublicKeyCredentialType = 'public-key';
|
|
2154
|
+
/**
|
|
2155
|
+
* COSE algorithm identifier
|
|
2156
|
+
*/
|
|
2157
|
+
type COSEAlgorithmIdentifier = -7 | -257 | -8 | -35 | -36 | -37 | -38 | -39 | number;
|
|
2158
|
+
/**
|
|
2159
|
+
* Public key credential parameters
|
|
2160
|
+
*/
|
|
2161
|
+
interface PublicKeyCredentialParametersType {
|
|
2162
|
+
type: PublicKeyCredentialType;
|
|
2163
|
+
alg: COSEAlgorithmIdentifier;
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Relying party entity
|
|
2167
|
+
*/
|
|
2168
|
+
interface PublicKeyCredentialRpEntityType {
|
|
2169
|
+
id?: string;
|
|
2170
|
+
name: string;
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Authenticator selection criteria
|
|
2174
|
+
*/
|
|
2175
|
+
interface AuthenticatorSelectionCriteriaType {
|
|
2176
|
+
authenticatorAttachment?: AuthenticatorAttachmentType;
|
|
2177
|
+
residentKey?: ResidentKeyRequirementType;
|
|
2178
|
+
requireResidentKey?: boolean;
|
|
2179
|
+
userVerification?: UserVerificationRequirementType;
|
|
2180
|
+
}
|
|
2181
|
+
/**
|
|
2182
|
+
* Authentication extensions client inputs
|
|
2183
|
+
*/
|
|
2184
|
+
interface AuthenticationExtensionsClientInputsType {
|
|
2185
|
+
credProps?: boolean;
|
|
2186
|
+
appid?: string;
|
|
2187
|
+
[key: string]: unknown;
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Social login provider
|
|
2191
|
+
*/
|
|
2192
|
+
type SocialProvider = 'google' | 'github' | 'apple' | 'microsoft' | 'facebook';
|
|
2193
|
+
/**
|
|
2194
|
+
* MFA method
|
|
2195
|
+
*/
|
|
2196
|
+
type MfaMethod = 'totp' | 'sms' | 'email' | 'passkey';
|
|
2197
|
+
/**
|
|
2198
|
+
* User information
|
|
2199
|
+
*/
|
|
2200
|
+
interface User {
|
|
2201
|
+
/** User ID */
|
|
2202
|
+
id: string;
|
|
2203
|
+
/** Email address */
|
|
2204
|
+
email?: string;
|
|
2205
|
+
/** Whether email is verified */
|
|
2206
|
+
emailVerified?: boolean;
|
|
2207
|
+
/** Display name */
|
|
2208
|
+
name?: string;
|
|
2209
|
+
/** Profile picture URL */
|
|
2210
|
+
picture?: string;
|
|
2211
|
+
/** Username */
|
|
2212
|
+
username?: string;
|
|
2213
|
+
/** Additional claims */
|
|
2214
|
+
[key: string]: unknown;
|
|
2215
|
+
}
|
|
2216
|
+
/**
|
|
2217
|
+
* Session information
|
|
2218
|
+
*/
|
|
2219
|
+
interface Session {
|
|
2220
|
+
/** Session ID */
|
|
2221
|
+
id: string;
|
|
2222
|
+
/** User ID */
|
|
2223
|
+
userId: string;
|
|
2224
|
+
/** Session creation time (ISO 8601) */
|
|
2225
|
+
createdAt: string;
|
|
2226
|
+
/** Session expiration time (ISO 8601) */
|
|
2227
|
+
expiresAt: string;
|
|
2228
|
+
/** Last activity time (ISO 8601) */
|
|
2229
|
+
lastActiveAt?: string;
|
|
2230
|
+
/** User agent that created the session */
|
|
2231
|
+
userAgent?: string;
|
|
2232
|
+
/** IP address (for display purposes only, not for security) */
|
|
2233
|
+
ipAddress?: string;
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Next action required after authentication
|
|
2237
|
+
*/
|
|
2238
|
+
type NextAction = {
|
|
2239
|
+
type: 'mfa_required';
|
|
2240
|
+
methods: MfaMethod[];
|
|
2241
|
+
} | {
|
|
2242
|
+
type: 'consent_required';
|
|
2243
|
+
scopes: string[];
|
|
2244
|
+
} | {
|
|
2245
|
+
type: 'email_verification_required';
|
|
2246
|
+
};
|
|
2247
|
+
/**
|
|
2248
|
+
* Authentication result (tokens are not returned directly for security)
|
|
2249
|
+
*/
|
|
2250
|
+
interface AuthResult {
|
|
2251
|
+
/** Authentication success flag */
|
|
2252
|
+
success: boolean;
|
|
2253
|
+
/** Session information (on success) */
|
|
2254
|
+
session?: Session;
|
|
2255
|
+
/** User information (on success) */
|
|
2256
|
+
user?: User;
|
|
2257
|
+
/** Error information (on failure) */
|
|
2258
|
+
error?: DirectAuthError;
|
|
2259
|
+
/** Additional action required */
|
|
2260
|
+
nextAction?: NextAction;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Direct Auth error structure (OAuth 2.0 extension)
|
|
2264
|
+
*/
|
|
2265
|
+
interface DirectAuthError {
|
|
2266
|
+
/** OAuth 2.0 error code */
|
|
2267
|
+
error: string;
|
|
2268
|
+
/** Human-readable error description */
|
|
2269
|
+
error_description?: string;
|
|
2270
|
+
/** URI with more information about the error */
|
|
2271
|
+
error_uri?: string;
|
|
2272
|
+
/** Authrim error code (AR000001 format) */
|
|
2273
|
+
code: string;
|
|
2274
|
+
/** Error metadata */
|
|
2275
|
+
meta: {
|
|
2276
|
+
/** Whether the error can be retried */
|
|
2277
|
+
retryable: boolean;
|
|
2278
|
+
/** Whether the error is transient */
|
|
2279
|
+
transient?: boolean;
|
|
2280
|
+
/** Suggested user action */
|
|
2281
|
+
user_action?: 'login' | 'reauth' | 'retry' | 'contact_admin';
|
|
2282
|
+
/** Error severity */
|
|
2283
|
+
severity: 'info' | 'warn' | 'error' | 'critical';
|
|
2284
|
+
/** Retry after (seconds) */
|
|
2285
|
+
retry_after?: number;
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Passkey login options
|
|
2290
|
+
*/
|
|
2291
|
+
interface PasskeyLoginOptions {
|
|
2292
|
+
/** Use conditional UI (autofill) */
|
|
2293
|
+
conditional?: boolean;
|
|
2294
|
+
/** Mediation preference */
|
|
2295
|
+
mediation?: 'conditional' | 'optional' | 'required' | 'silent';
|
|
2296
|
+
/** Abort signal for cancellation */
|
|
2297
|
+
signal?: AbortSignal;
|
|
2298
|
+
}
|
|
2299
|
+
/**
|
|
2300
|
+
* Passkey sign-up options
|
|
2301
|
+
*/
|
|
2302
|
+
interface PasskeySignUpOptions {
|
|
2303
|
+
/** User email */
|
|
2304
|
+
email: string;
|
|
2305
|
+
/** User display name */
|
|
2306
|
+
displayName?: string;
|
|
2307
|
+
/** Preferred authenticator type */
|
|
2308
|
+
authenticatorType?: 'platform' | 'cross-platform' | 'any';
|
|
2309
|
+
/** Resident key requirement */
|
|
2310
|
+
residentKey?: 'required' | 'preferred' | 'discouraged';
|
|
2311
|
+
/** User verification requirement */
|
|
2312
|
+
userVerification?: 'required' | 'preferred' | 'discouraged';
|
|
2313
|
+
/** Abort signal for cancellation */
|
|
2314
|
+
signal?: AbortSignal;
|
|
2315
|
+
}
|
|
2316
|
+
/**
|
|
2317
|
+
* Passkey register options (for adding to existing account)
|
|
2318
|
+
*/
|
|
2319
|
+
interface PasskeyRegisterOptions {
|
|
2320
|
+
/** Passkey display name */
|
|
2321
|
+
displayName?: string;
|
|
2322
|
+
/** Preferred authenticator type */
|
|
2323
|
+
authenticatorType?: 'platform' | 'cross-platform' | 'any';
|
|
2324
|
+
/** Resident key requirement */
|
|
2325
|
+
residentKey?: 'required' | 'preferred' | 'discouraged';
|
|
2326
|
+
/** User verification requirement */
|
|
2327
|
+
userVerification?: 'required' | 'preferred' | 'discouraged';
|
|
2328
|
+
/** Abort signal for cancellation */
|
|
2329
|
+
signal?: AbortSignal;
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Passkey credential (returned after registration)
|
|
2333
|
+
*/
|
|
2334
|
+
interface PasskeyCredential {
|
|
2335
|
+
/** Credential ID (base64url) */
|
|
2336
|
+
credentialId: string;
|
|
2337
|
+
/** Public key (COSE format, base64url) */
|
|
2338
|
+
publicKey: string;
|
|
2339
|
+
/** Authenticator type */
|
|
2340
|
+
authenticatorType: 'platform' | 'cross-platform';
|
|
2341
|
+
/** Transports (usb, nfc, ble, internal, etc.) */
|
|
2342
|
+
transports?: AuthenticatorTransportType[];
|
|
2343
|
+
/** When the credential was created */
|
|
2344
|
+
createdAt: string;
|
|
2345
|
+
/** User-friendly name */
|
|
2346
|
+
displayName?: string;
|
|
2347
|
+
}
|
|
2348
|
+
/**
|
|
2349
|
+
* Email code send options
|
|
2350
|
+
*/
|
|
2351
|
+
interface EmailCodeSendOptions {
|
|
2352
|
+
/** Email locale for the message */
|
|
2353
|
+
locale?: string;
|
|
2354
|
+
/** Code length (default: 6) */
|
|
2355
|
+
codeLength?: 6 | 8;
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Email code send result
|
|
2359
|
+
*/
|
|
2360
|
+
interface EmailCodeSendResult {
|
|
2361
|
+
/** Attempt ID for verification */
|
|
2362
|
+
attemptId: string;
|
|
2363
|
+
/** Code expiration time (seconds) */
|
|
2364
|
+
expiresIn: number;
|
|
2365
|
+
/** Masked email for display */
|
|
2366
|
+
maskedEmail: string;
|
|
2367
|
+
/** Whether this is a new user */
|
|
2368
|
+
isNewUser?: boolean;
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Email code verify options
|
|
2372
|
+
*/
|
|
2373
|
+
interface EmailCodeVerifyOptions {
|
|
2374
|
+
/** Create account if user doesn't exist */
|
|
2375
|
+
createAccountIfNotExists?: boolean;
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Social login options
|
|
2379
|
+
*/
|
|
2380
|
+
interface SocialLoginOptions {
|
|
2381
|
+
/** Redirect URI after authentication */
|
|
2382
|
+
redirectUri?: string;
|
|
2383
|
+
/** Additional OAuth scopes */
|
|
2384
|
+
scopes?: string[];
|
|
2385
|
+
/** Custom state parameter */
|
|
2386
|
+
state?: string;
|
|
2387
|
+
/** Login hint (e.g., email address) */
|
|
2388
|
+
loginHint?: string;
|
|
2389
|
+
/** Popup window features */
|
|
2390
|
+
popupFeatures?: {
|
|
2391
|
+
width?: number;
|
|
2392
|
+
height?: number;
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
/**
|
|
2396
|
+
* Logout options
|
|
2397
|
+
*/
|
|
2398
|
+
interface DirectAuthLogoutOptions {
|
|
2399
|
+
/** Revoke refresh tokens */
|
|
2400
|
+
revokeTokens?: boolean;
|
|
2401
|
+
/** Post-logout redirect URI */
|
|
2402
|
+
redirectUri?: string;
|
|
2403
|
+
}
|
|
2404
|
+
/**
|
|
2405
|
+
* Passkey login start request
|
|
2406
|
+
*/
|
|
2407
|
+
interface PasskeyLoginStartRequest {
|
|
2408
|
+
client_id: string;
|
|
2409
|
+
code_challenge: string;
|
|
2410
|
+
code_challenge_method: 'S256';
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Passkey login start response
|
|
2414
|
+
*/
|
|
2415
|
+
interface PasskeyLoginStartResponse {
|
|
2416
|
+
/** Challenge ID (5 min TTL) */
|
|
2417
|
+
challenge_id: string;
|
|
2418
|
+
/** WebAuthn options */
|
|
2419
|
+
options: PublicKeyCredentialRequestOptionsJSON;
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Passkey login finish request
|
|
2423
|
+
*/
|
|
2424
|
+
interface PasskeyLoginFinishRequest {
|
|
2425
|
+
challenge_id: string;
|
|
2426
|
+
credential: AuthenticatorAssertionResponseJSON;
|
|
2427
|
+
code_verifier: string;
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* Passkey login finish response
|
|
2431
|
+
*/
|
|
2432
|
+
interface PasskeyLoginFinishResponse {
|
|
2433
|
+
/** Authorization code (60s TTL, single-use) */
|
|
2434
|
+
auth_code: string;
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* Passkey signup start request
|
|
2438
|
+
*/
|
|
2439
|
+
interface PasskeySignupStartRequest {
|
|
2440
|
+
client_id: string;
|
|
2441
|
+
email: string;
|
|
2442
|
+
display_name?: string;
|
|
2443
|
+
code_challenge: string;
|
|
2444
|
+
code_challenge_method: 'S256';
|
|
2445
|
+
authenticator_type?: 'platform' | 'cross-platform' | 'any';
|
|
2446
|
+
resident_key?: 'required' | 'preferred' | 'discouraged';
|
|
2447
|
+
user_verification?: 'required' | 'preferred' | 'discouraged';
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Passkey signup start response
|
|
2451
|
+
*/
|
|
2452
|
+
interface PasskeySignupStartResponse {
|
|
2453
|
+
/** Challenge ID (5 min TTL) */
|
|
2454
|
+
challenge_id: string;
|
|
2455
|
+
/** WebAuthn creation options */
|
|
2456
|
+
options: PublicKeyCredentialCreationOptionsJSON;
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Passkey signup finish request
|
|
2460
|
+
*/
|
|
2461
|
+
interface PasskeySignupFinishRequest {
|
|
2462
|
+
challenge_id: string;
|
|
2463
|
+
credential: AuthenticatorAttestationResponseJSON;
|
|
2464
|
+
code_verifier: string;
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Passkey signup finish response
|
|
2468
|
+
*/
|
|
2469
|
+
interface PasskeySignupFinishResponse {
|
|
2470
|
+
/** Authorization code (60s TTL, single-use) */
|
|
2471
|
+
auth_code: string;
|
|
2472
|
+
/** Whether the user was newly created */
|
|
2473
|
+
is_new_user: boolean;
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* Email code send request
|
|
2477
|
+
*/
|
|
2478
|
+
interface EmailCodeSendRequest {
|
|
2479
|
+
client_id: string;
|
|
2480
|
+
email: string;
|
|
2481
|
+
code_challenge: string;
|
|
2482
|
+
code_challenge_method: 'S256';
|
|
2483
|
+
locale?: string;
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Email code send response
|
|
2487
|
+
*/
|
|
2488
|
+
interface EmailCodeSendResponse {
|
|
2489
|
+
/** Attempt ID (5 min TTL) */
|
|
2490
|
+
attempt_id: string;
|
|
2491
|
+
/** Code expiration (seconds) */
|
|
2492
|
+
expires_in: number;
|
|
2493
|
+
/** Masked email */
|
|
2494
|
+
masked_email: string;
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Email code verify request
|
|
2498
|
+
*/
|
|
2499
|
+
interface EmailCodeVerifyRequest {
|
|
2500
|
+
attempt_id: string;
|
|
2501
|
+
code: string;
|
|
2502
|
+
code_verifier: string;
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Email code verify response
|
|
2506
|
+
*/
|
|
2507
|
+
interface EmailCodeVerifyResponse {
|
|
2508
|
+
/** Authorization code (60s TTL, single-use) */
|
|
2509
|
+
auth_code: string;
|
|
2510
|
+
/** Whether the user was newly created */
|
|
2511
|
+
is_new_user: boolean;
|
|
2512
|
+
}
|
|
2513
|
+
/**
|
|
2514
|
+
* Token exchange request (Direct Auth)
|
|
2515
|
+
*/
|
|
2516
|
+
interface DirectAuthTokenRequest {
|
|
2517
|
+
grant_type: 'authorization_code';
|
|
2518
|
+
code: string;
|
|
2519
|
+
client_id: string;
|
|
2520
|
+
code_verifier: string;
|
|
2521
|
+
/** Whether to request refresh token (for SPA opt-in) */
|
|
2522
|
+
request_refresh_token?: boolean;
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Token exchange response (OAuth 2.0 extension)
|
|
2526
|
+
*
|
|
2527
|
+
* Unified structure for Web/Mobile, differentiated by flags.
|
|
2528
|
+
*/
|
|
2529
|
+
interface DirectAuthTokenResponse {
|
|
2530
|
+
/** Token type (always 'Bearer') */
|
|
2531
|
+
token_type: 'Bearer';
|
|
2532
|
+
/** Access token */
|
|
2533
|
+
access_token: string;
|
|
2534
|
+
/** Token expiration (seconds) */
|
|
2535
|
+
expires_in: number;
|
|
2536
|
+
/** Refresh token (Mobile, or SPA with opt-in) */
|
|
2537
|
+
refresh_token?: string;
|
|
2538
|
+
/** ID token */
|
|
2539
|
+
id_token?: string;
|
|
2540
|
+
/** Granted scopes */
|
|
2541
|
+
scope?: string;
|
|
2542
|
+
/** Whether session is established via Cookie (Web) */
|
|
2543
|
+
session_established: boolean;
|
|
2544
|
+
/** Session information */
|
|
2545
|
+
session?: Session;
|
|
2546
|
+
/** User information */
|
|
2547
|
+
user?: User;
|
|
2548
|
+
}
|
|
2549
|
+
/**
|
|
2550
|
+
* PublicKeyCredentialRequestOptions as JSON
|
|
2551
|
+
*/
|
|
2552
|
+
interface PublicKeyCredentialRequestOptionsJSON {
|
|
2553
|
+
challenge: string;
|
|
2554
|
+
timeout?: number;
|
|
2555
|
+
rpId?: string;
|
|
2556
|
+
allowCredentials?: PublicKeyCredentialDescriptorJSON[];
|
|
2557
|
+
userVerification?: UserVerificationRequirementType;
|
|
2558
|
+
extensions?: AuthenticationExtensionsClientInputsType;
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* PublicKeyCredentialCreationOptions as JSON
|
|
2562
|
+
*/
|
|
2563
|
+
interface PublicKeyCredentialCreationOptionsJSON {
|
|
2564
|
+
rp: PublicKeyCredentialRpEntityType;
|
|
2565
|
+
user: PublicKeyCredentialUserEntityJSON;
|
|
2566
|
+
challenge: string;
|
|
2567
|
+
pubKeyCredParams: PublicKeyCredentialParametersType[];
|
|
2568
|
+
timeout?: number;
|
|
2569
|
+
excludeCredentials?: PublicKeyCredentialDescriptorJSON[];
|
|
2570
|
+
authenticatorSelection?: AuthenticatorSelectionCriteriaType;
|
|
2571
|
+
attestation?: AttestationConveyancePreferenceType;
|
|
2572
|
+
extensions?: AuthenticationExtensionsClientInputsType;
|
|
2573
|
+
}
|
|
2574
|
+
/**
|
|
2575
|
+
* PublicKeyCredentialDescriptor as JSON
|
|
2576
|
+
*/
|
|
2577
|
+
interface PublicKeyCredentialDescriptorJSON {
|
|
2578
|
+
type: PublicKeyCredentialType;
|
|
2579
|
+
id: string;
|
|
2580
|
+
transports?: AuthenticatorTransportType[];
|
|
2581
|
+
}
|
|
2582
|
+
/**
|
|
2583
|
+
* PublicKeyCredentialUserEntity as JSON
|
|
2584
|
+
*/
|
|
2585
|
+
interface PublicKeyCredentialUserEntityJSON {
|
|
2586
|
+
id: string;
|
|
2587
|
+
name: string;
|
|
2588
|
+
displayName: string;
|
|
2589
|
+
}
|
|
2590
|
+
/**
|
|
2591
|
+
* AuthenticatorAssertionResponse as JSON
|
|
2592
|
+
*/
|
|
2593
|
+
interface AuthenticatorAssertionResponseJSON {
|
|
2594
|
+
clientDataJSON: string;
|
|
2595
|
+
authenticatorData: string;
|
|
2596
|
+
signature: string;
|
|
2597
|
+
userHandle?: string;
|
|
2598
|
+
}
|
|
2599
|
+
/**
|
|
2600
|
+
* AuthenticatorAttestationResponse as JSON
|
|
2601
|
+
*/
|
|
2602
|
+
interface AuthenticatorAttestationResponseJSON {
|
|
2603
|
+
clientDataJSON: string;
|
|
2604
|
+
attestationObject: string;
|
|
2605
|
+
transports?: AuthenticatorTransportType[];
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Direct Auth client configuration
|
|
2609
|
+
*/
|
|
2610
|
+
interface DirectAuthClientConfig {
|
|
2611
|
+
/** Authrim IdP URL */
|
|
2612
|
+
issuer: string;
|
|
2613
|
+
/** OAuth client ID */
|
|
2614
|
+
clientId: string;
|
|
2615
|
+
/** Default redirect URI */
|
|
2616
|
+
redirectUri?: string;
|
|
2617
|
+
}
|
|
2618
|
+
/**
|
|
2619
|
+
* Passkey authentication interface
|
|
2620
|
+
*/
|
|
2621
|
+
interface PasskeyAuth {
|
|
2622
|
+
/** Login with Passkey */
|
|
2623
|
+
login(options?: PasskeyLoginOptions): Promise<AuthResult>;
|
|
2624
|
+
/** Sign up with Passkey (create account + register Passkey) */
|
|
2625
|
+
signUp(options: PasskeySignUpOptions): Promise<AuthResult>;
|
|
2626
|
+
/** Register a Passkey to existing account (requires authentication) */
|
|
2627
|
+
register(options?: PasskeyRegisterOptions): Promise<PasskeyCredential>;
|
|
2628
|
+
/** Check if WebAuthn is supported */
|
|
2629
|
+
isSupported(): boolean;
|
|
2630
|
+
/** Check if conditional UI (autofill) is available */
|
|
2631
|
+
isConditionalUIAvailable(): Promise<boolean>;
|
|
2632
|
+
}
|
|
2633
|
+
/**
|
|
2634
|
+
* Email code authentication interface
|
|
2635
|
+
*/
|
|
2636
|
+
interface EmailCodeAuth {
|
|
2637
|
+
/** Send verification code to email */
|
|
2638
|
+
send(email: string, options?: EmailCodeSendOptions): Promise<EmailCodeSendResult>;
|
|
2639
|
+
/** Verify code and authenticate */
|
|
2640
|
+
verify(email: string, code: string, options?: EmailCodeVerifyOptions): Promise<AuthResult>;
|
|
2641
|
+
}
|
|
2642
|
+
/**
|
|
2643
|
+
* Social login interface
|
|
2644
|
+
*/
|
|
2645
|
+
interface SocialAuth {
|
|
2646
|
+
/** Login with social provider (popup) */
|
|
2647
|
+
loginWithPopup(provider: SocialProvider, options?: SocialLoginOptions): Promise<AuthResult>;
|
|
2648
|
+
/** Login with social provider (redirect) */
|
|
2649
|
+
loginWithRedirect(provider: SocialProvider, options?: SocialLoginOptions): Promise<void>;
|
|
2650
|
+
/** Handle callback from social provider (redirect) */
|
|
2651
|
+
handleCallback(): Promise<AuthResult>;
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* Session management interface
|
|
2655
|
+
*/
|
|
2656
|
+
interface SessionAuth {
|
|
2657
|
+
/** Get current session */
|
|
2658
|
+
get(): Promise<Session | null>;
|
|
2659
|
+
/** Validate session */
|
|
2660
|
+
validate(): Promise<boolean>;
|
|
2661
|
+
/** Logout */
|
|
2662
|
+
logout(options?: DirectAuthLogoutOptions): Promise<void>;
|
|
2663
|
+
}
|
|
2664
|
+
/**
|
|
2665
|
+
* Direct Auth client interface (BetterAuth style)
|
|
2666
|
+
*/
|
|
2667
|
+
interface DirectAuthClient {
|
|
2668
|
+
/** Passkey authentication */
|
|
2669
|
+
passkey: PasskeyAuth;
|
|
2670
|
+
/** Email code authentication */
|
|
2671
|
+
emailCode: EmailCodeAuth;
|
|
2672
|
+
/** Social login */
|
|
2673
|
+
social: SocialAuth;
|
|
2674
|
+
/** Session management */
|
|
2675
|
+
session: SessionAuth;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
export { type AddressClaim, type AttestationConveyancePreferenceType, type AuthCallbackEvent, type AuthRedirectingEvent, type AuthResult, type AuthState, type AuthenticationExtensionsClientInputsType, type AuthenticatorAssertionResponseJSON, type AuthenticatorAttachmentType, type AuthenticatorAttestationResponseJSON, type AuthenticatorSelectionCriteriaType, type AuthenticatorTransportType, AuthorizationCodeFlow, type AuthorizationContext, type AuthorizationUrlResult, AuthrimClient, type AuthrimClientConfig, AuthrimError, type AuthrimErrorCode, type AuthrimErrorMeta, type AuthrimErrorOptions, type AuthrimErrorSeverity, type AuthrimErrorUserAction, type AuthrimEventHandler, type AuthrimEventName, type AuthrimEvents, type AuthrimStorage, type BuildAuthorizationUrlOptions, type COSEAlgorithmIdentifier, type CodeChallengeMethod, type CryptoProvider, type DecodedJwt, type DirectAuthClient, type DirectAuthClientConfig, type DirectAuthError, type DirectAuthLogoutOptions, type DirectAuthTokenRequest, type DirectAuthTokenResponse, DiscoveryClient, type EmailCodeAuth, type EmailCodeSendOptions, type EmailCodeSendRequest, type EmailCodeSendResponse, type EmailCodeSendResult, type EmailCodeVerifyOptions, type EmailCodeVerifyRequest, type EmailCodeVerifyResponse, type EndpointOverrides, type ErrorEvent, EventEmitter, type ExchangeCodeOptions, type GenerateAuthStateOptions, type HashOptions, type HttpClient, type HttpOptions, type HttpResponse, type IntrospectTokenOptions, type IntrospectionResponse, type IntrospectionTokenTypeHint, type JwtHeader, LogoutHandler, type LogoutHandlerOptions, type LogoutOptions, type LogoutResult, type MfaMethod, type NextAction, type OAuthErrorResponse, type OIDCDiscoveryDocument, PKCEHelper, type PKCEPair, type PasskeyAuth, type PasskeyCredential, type PasskeyLoginFinishRequest, type PasskeyLoginFinishResponse, type PasskeyLoginOptions, type PasskeyLoginStartRequest, type PasskeyLoginStartResponse, type PasskeyRegisterOptions, type PasskeySignUpOptions, type PasskeySignupFinishRequest, type PasskeySignupFinishResponse, type PasskeySignupStartRequest, type PasskeySignupStartResponse, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialDescriptorJSON, type PublicKeyCredentialParametersType, type PublicKeyCredentialRequestOptionsJSON, type PublicKeyCredentialRpEntityType, type PublicKeyCredentialType, type PublicKeyCredentialUserEntityJSON, type ResidentKeyRequirementType, type ResolvedConfig, type RevokeTokenOptions, STORAGE_KEYS, type Session, type SessionAuth, type SessionCheckResult, type SessionEndedEvent, SessionManager, type SessionManagerOptions, type SessionStartedEvent, SilentAuthHandler, type SilentAuthOptions, type SilentAuthResult, type SilentAuthUrlResult, type SocialAuth, type SocialLoginOptions, type SocialProvider, type StandardClaims, StateManager, TOKEN_TYPE_URIS, TokenApiClient, type TokenApiClientOptions, type TokenErrorEvent, type TokenExchangeRequest, type TokenExchangeResponse, type TokenExchangeResult, type TokenExchangedEvent, type TokenExpiredEvent, TokenIntrospector, type TokenIntrospectorOptions, TokenManager, type TokenManagerOptions, type TokenRefreshedEvent, type TokenResponse, TokenRevoker, type TokenRevokerOptions, type TokenSet, type TokenTypeHint, type TokenTypeUri, type User, type UserInfo, type UserVerificationRequirementType, base64urlDecode, base64urlEncode, base64urlToString, calculateDsHash, createAuthrimClient, decodeIdToken, decodeJwt, getErrorMeta, getIdTokenNonce, isJwtExpired, normalizeIssuer, resolveConfig, stringToBase64url, timingSafeEqual };
|