@aura-stack/auth 0.1.0 → 0.2.0-rc.1

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.
Files changed (111) hide show
  1. package/dist/@types/index.d.ts +5 -5
  2. package/dist/@types/router.d.d.ts +5 -5
  3. package/dist/@types/utility.d.ts +1 -5
  4. package/dist/actions/callback/access-token.cjs +95 -74
  5. package/dist/actions/callback/access-token.d.ts +7 -7
  6. package/dist/actions/callback/access-token.js +5 -3
  7. package/dist/actions/callback/callback.cjs +171 -249
  8. package/dist/actions/callback/callback.d.ts +6 -6
  9. package/dist/actions/callback/callback.js +10 -10
  10. package/dist/actions/callback/userinfo.cjs +81 -57
  11. package/dist/actions/callback/userinfo.d.ts +5 -5
  12. package/dist/actions/callback/userinfo.js +7 -5
  13. package/dist/actions/csrfToken/csrfToken.cjs +36 -105
  14. package/dist/actions/csrfToken/csrfToken.js +6 -6
  15. package/dist/actions/index.cjs +309 -444
  16. package/dist/actions/index.d.ts +5 -5
  17. package/dist/actions/index.js +19 -19
  18. package/dist/actions/session/session.cjs +25 -109
  19. package/dist/actions/session/session.js +4 -5
  20. package/dist/actions/signIn/authorization.cjs +96 -87
  21. package/dist/actions/signIn/authorization.d.ts +5 -5
  22. package/dist/actions/signIn/authorization.js +5 -5
  23. package/dist/actions/signIn/signIn.cjs +133 -242
  24. package/dist/actions/signIn/signIn.d.ts +6 -6
  25. package/dist/actions/signIn/signIn.js +8 -9
  26. package/dist/actions/signOut/signOut.cjs +136 -282
  27. package/dist/actions/signOut/signOut.js +8 -9
  28. package/dist/assert.cjs +5 -0
  29. package/dist/assert.d.ts +10 -1
  30. package/dist/assert.js +3 -1
  31. package/dist/chunk-3EUWD5BB.js +63 -0
  32. package/dist/chunk-6R2YZ4AC.js +22 -0
  33. package/dist/chunk-A3N4PVAT.js +70 -0
  34. package/dist/chunk-B737EUJV.js +22 -0
  35. package/dist/{chunk-256KIVJL.js → chunk-CXLATHS5.js} +53 -9
  36. package/dist/{chunk-6SM22VVJ.js → chunk-EIL2FPSS.js} +5 -1
  37. package/dist/{chunk-VFTYH33W.js → chunk-EMKJA2GJ.js} +36 -8
  38. package/dist/{chunk-UJJ7R56J.js → chunk-GA2SMTJO.js} +16 -10
  39. package/dist/chunk-HP34YGGJ.js +22 -0
  40. package/dist/chunk-HT4YLL7N.js +35 -0
  41. package/dist/{chunk-EBPE35JT.js → chunk-IUYZQTJV.js} +0 -1
  42. package/dist/{chunk-RLT4RFKV.js → chunk-IVET23KF.js} +21 -8
  43. package/dist/{chunk-XXJKNKGQ.js → chunk-JVFTCTTE.js} +9 -13
  44. package/dist/chunk-KSWLO5ZU.js +102 -0
  45. package/dist/{chunk-GZU3RBTB.js → chunk-N2APGLXA.js} +19 -10
  46. package/dist/{chunk-CAKJT3KS.js → chunk-N4SX7TZT.js} +21 -17
  47. package/dist/chunk-RRLIF4PQ.js +55 -0
  48. package/dist/chunk-TLE4PXY3.js +39 -0
  49. package/dist/chunk-W6LG7BFW.js +197 -0
  50. package/dist/{chunk-HMRKN75I.js → chunk-YRCB5FLE.js} +14 -9
  51. package/dist/chunk-ZNCZVF6U.js +14 -0
  52. package/dist/cookie.cjs +140 -99
  53. package/dist/cookie.d.ts +35 -44
  54. package/dist/cookie.js +10 -17
  55. package/dist/errors.cjs +85 -0
  56. package/dist/errors.d.ts +49 -0
  57. package/dist/errors.js +18 -0
  58. package/dist/{index-DpfbvTZ_.d.ts → index-DkaLJFn8.d.ts} +192 -61
  59. package/dist/index.cjs +543 -443
  60. package/dist/index.d.ts +6 -6
  61. package/dist/index.js +42 -28
  62. package/dist/jose.cjs +25 -14
  63. package/dist/jose.d.ts +4 -1
  64. package/dist/jose.js +5 -4
  65. package/dist/oauth/bitbucket.d.ts +5 -5
  66. package/dist/oauth/discord.cjs +0 -1
  67. package/dist/oauth/discord.d.ts +5 -5
  68. package/dist/oauth/discord.js +1 -1
  69. package/dist/oauth/figma.d.ts +5 -5
  70. package/dist/oauth/github.d.ts +5 -5
  71. package/dist/oauth/gitlab.d.ts +5 -5
  72. package/dist/oauth/index.cjs +176 -6
  73. package/dist/oauth/index.d.ts +5 -5
  74. package/dist/oauth/index.js +19 -4
  75. package/dist/oauth/mailchimp.cjs +46 -0
  76. package/dist/oauth/mailchimp.d.ts +7 -0
  77. package/dist/oauth/mailchimp.js +6 -0
  78. package/dist/oauth/pinterest.cjs +46 -0
  79. package/dist/oauth/pinterest.d.ts +7 -0
  80. package/dist/oauth/pinterest.js +6 -0
  81. package/dist/oauth/spotify.d.ts +5 -5
  82. package/dist/oauth/strava.cjs +46 -0
  83. package/dist/oauth/strava.d.ts +7 -0
  84. package/dist/oauth/strava.js +6 -0
  85. package/dist/oauth/x.d.ts +5 -5
  86. package/dist/{response.cjs → request.cjs} +14 -10
  87. package/dist/request.d.ts +13 -0
  88. package/dist/request.js +6 -0
  89. package/dist/schemas.cjs +43 -37
  90. package/dist/schemas.d.ts +67 -64
  91. package/dist/schemas.js +3 -1
  92. package/dist/secure.cjs +32 -24
  93. package/dist/secure.d.ts +5 -5
  94. package/dist/secure.js +4 -3
  95. package/dist/utils.cjs +90 -15
  96. package/dist/utils.d.ts +11 -2
  97. package/dist/utils.js +8 -4
  98. package/package.json +8 -7
  99. package/dist/chunk-FJUDBLCP.js +0 -59
  100. package/dist/chunk-HGJ4TXY4.js +0 -137
  101. package/dist/chunk-JAPMIE6S.js +0 -10
  102. package/dist/chunk-LLR722CL.js +0 -96
  103. package/dist/chunk-SJPDVKUS.js +0 -112
  104. package/dist/chunk-SMQO5WD7.js +0 -30
  105. package/dist/chunk-UTDLUEEG.js +0 -31
  106. package/dist/chunk-ZV4BH47P.js +0 -154
  107. package/dist/error.cjs +0 -88
  108. package/dist/error.d.ts +0 -62
  109. package/dist/error.js +0 -16
  110. package/dist/response.d.ts +0 -10
  111. package/dist/response.js +0 -6
@@ -1,9 +1,127 @@
1
- import { z } from 'zod/v4';
1
+ import { z } from 'zod';
2
+ import { OAuthAuthorizationErrorResponse, OAuthAccessTokenErrorResponse, OAuthEnvSchema } from './schemas.js';
3
+ import { SerializeOptions } from '@aura-stack/router/cookie';
4
+ import { JWTVerifyOptions, EncryptOptions, JWTDecryptOptions } from '@aura-stack/jose';
2
5
  import { JWTPayload } from '@aura-stack/jose/jose';
3
- import { OAuthAuthorizationErrorResponse, OAuthAccessTokenErrorResponse } from './schemas.js';
4
- import { SerializeOptions } from 'cookie';
5
6
  import { LiteralUnion, Prettify } from './@types/utility.js';
6
7
 
8
+ /**
9
+ * @see [Pinterest - Get User Account](https://developers.pinterest.com/docs/api/v5/user_account-get)
10
+ */
11
+ interface PinterestProfile {
12
+ account_type: LiteralUnion<"PINNER">;
13
+ id: string;
14
+ profile_image: string;
15
+ website_url: string;
16
+ username: string;
17
+ about: string;
18
+ business_name: string;
19
+ board_count: number;
20
+ pin_count: number;
21
+ follower_count: number;
22
+ following_count: number;
23
+ monthly_views: number;
24
+ }
25
+ /**
26
+ * @see [Pinterest - Connect App](https://developers.pinterest.com/docs/getting-started/connect-app/)
27
+ * @see [Pinterest - My Apps](https://developers.pinterest.com/apps/)
28
+ * @see [Pinterest - Get User Account](https://developers.pinterest.com/docs/api/v5/user_account-get)
29
+ */
30
+ declare const pinterest: OAuthProviderConfig<PinterestProfile>;
31
+
32
+ interface Login {
33
+ email: string;
34
+ avatar: string | null;
35
+ login_id: number;
36
+ login_name: string;
37
+ login_email: string;
38
+ }
39
+ interface MailchimpProfile {
40
+ dc: string;
41
+ role: string;
42
+ accountname: string;
43
+ user_id: string;
44
+ login: Login;
45
+ login_url: string;
46
+ api_endpoint: string;
47
+ }
48
+ /**
49
+ * @see [Mailchimp - Access Data on Behalf of Other Users with OAuth 2](https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/)
50
+ */
51
+ declare const mailchimp: OAuthProviderConfig<MailchimpProfile>;
52
+
53
+ /**
54
+ * @see [Strava - SummaryClub](https://developers.strava.com/docs/reference/#api-models-SummaryClub)
55
+ */
56
+ interface SummaryClub {
57
+ id: number;
58
+ resource_state: number;
59
+ name: string;
60
+ profile_medium: string;
61
+ cover_photo: string;
62
+ cover_photo_small: string;
63
+ sport_type: "cycling" | "running" | "triathlon" | "other";
64
+ activity_types: string[];
65
+ city: string;
66
+ state: string;
67
+ country: string;
68
+ private: boolean;
69
+ member_count: number;
70
+ featured: boolean;
71
+ verified: boolean;
72
+ url: string;
73
+ }
74
+ /**
75
+ * @see [Strava - SummaryGear](https://developers.strava.com/docs/reference/#api-models-SummaryGear)
76
+ */
77
+ interface SummaryGear {
78
+ id: string;
79
+ resource_state: number;
80
+ primary: boolean;
81
+ name: string;
82
+ distance: number;
83
+ }
84
+ /**
85
+ * @see [Strava - DetailedAthlete](https://developers.strava.com/docs/reference/#api-models-DetailedAthlete)
86
+ */
87
+ interface StravaProfile {
88
+ id: number;
89
+ resource_state: number;
90
+ firstname: string;
91
+ lastname: string;
92
+ bio: string | null;
93
+ profile: string;
94
+ profile_medium: string;
95
+ city: string;
96
+ state: string;
97
+ country: string;
98
+ sex: string;
99
+ premium: boolean;
100
+ summit: boolean;
101
+ created_at: Date;
102
+ updated_at: Date;
103
+ badge_type_id: number;
104
+ weight: number;
105
+ friend: null;
106
+ follower: null;
107
+ follower_count: number;
108
+ friend_count: number;
109
+ measurement_preference: string;
110
+ ftp: number;
111
+ clubs: SummaryClub[];
112
+ bikes: SummaryGear[];
113
+ shoes: SummaryGear[];
114
+ }
115
+ /**
116
+ * Strava OAuth Provider
117
+ * @see [Strava - Getting Started with the Strava API](https://developers.strava.com/docs/getting-started/)
118
+ * @see [Strava - My Applications](https://www.strava.com/settings/api)
119
+ * @see [Strava - Authentication](https://developers.strava.com/docs/authentication/)
120
+ * @see [Strava - API Application](https://www.strava.com/settings/api)
121
+ * @see [Strava - API Reference](https://developers.strava.com/docs/reference/)
122
+ */
123
+ declare const strava: OAuthProviderConfig<StravaProfile>;
124
+
7
125
  /**
8
126
  * @see [X - Get my User](https://docs.x.com/x-api/users/get-my-user)
9
127
  */
@@ -16,6 +134,7 @@ interface XProfile {
16
134
  };
17
135
  }
18
136
  /**
137
+ * X (Twitter) OAuth Provider
19
138
  * @see [X - Developer Portal](https://developer.x.com/en/portal/projects-and-apps)
20
139
  * @see [X - Get my User](https://docs.x.com/x-api/users/get-my-user)
21
140
  * @see [X - OAuth 2.0 Authorization Code Flow with PKCE](https://docs.x.com/fundamentals/authentication/oauth-2-0/authorization-code)
@@ -55,6 +174,8 @@ interface SpotifyProfile {
55
174
  };
56
175
  }
57
176
  /**
177
+ * Spotify OAuth Provider
178
+ *
58
179
  * @see [Spotify - Spotify Developer Dashboard](https://developer.spotify.com/dashboard)
59
180
  * @see [Spotify - Getting started with Web API](https://developer.spotify.com/documentation/web-api/tutorials/getting-started)
60
181
  * @see [Spotify - Get Current User's Profile](https://developer.spotify.com/documentation/web-api/reference/get-current-users-profile)
@@ -116,6 +237,8 @@ interface GitLabProfile {
116
237
  scim_identities: unknown[];
117
238
  }
118
239
  /**
240
+ * GitLab OAuth Provider
241
+ *
119
242
  * @see [GitLab - Applications](https://gitlab.com/-/user_settings/applications)
120
243
  * @see [GitLab - OAuth 2.0 identify provider API](https://docs.gitlab.com/api/oauth2/)
121
244
  * @see [GitLab - Scopes](https://docs.gitlab.com/integration/oauth_provider/#view-all-authorized-applications)
@@ -170,12 +293,15 @@ interface DiscordProfile {
170
293
  };
171
294
  }
172
295
  /**
296
+ * Discord OAuth Provider
297
+ *
173
298
  * @see [Discord - Applications](https://discord.com/developers/applications)
174
299
  * @see [Discord - OAuth2](https://discord.com/developers/docs/topics/oauth2)
175
300
  * @see [Discord - Get Current User](https://discord.com/developers/docs/resources/user#get-current-user)
176
301
  * @see [Discord - User Object](https://discord.com/developers/docs/resources/user#user-object)
177
302
  * @see [Discord - OAuth2 Scopes](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes)
178
303
  * @see [Discord - Image Formatting](https://discord.com/developers/docs/reference#image-formatting)
304
+ * @see [Discord - Display Names](https://discord.com/developers/docs/change-log#display-names)
179
305
  */
180
306
  declare const discord: OAuthProviderConfig<DiscordProfile>;
181
307
 
@@ -189,6 +315,7 @@ interface FigmaProfile {
189
315
  email: string;
190
316
  }
191
317
  /**
318
+ * Figma OAuth Provider
192
319
  * @see [Figma - REST API Introduction](https://developers.figma.com/docs/rest-api/)
193
320
  * @see [Figma - OAuth App](https://www.figma.com/developers/apps/)
194
321
  * @see [Figma - Create an OAuth App](https://developers.figma.com/docs/rest-api/authentication/#create-an-oauth-app)
@@ -281,6 +408,7 @@ interface GitHubProfile {
281
408
  }
282
409
  /**
283
410
  * GitHub OAuth Provider
411
+ *
284
412
  * @see [GitHub - Creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)
285
413
  * @see [GitHub - Authorizing OAuth Apps](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps)
286
414
  * @see [GitHub - Configure your GitHub OAuth Apps](https://github.com/settings/developers)
@@ -289,13 +417,16 @@ interface GitHubProfile {
289
417
  declare const github: OAuthProviderConfig<GitHubProfile>;
290
418
 
291
419
  declare const builtInOAuthProviders: {
292
- github: OAuthProviderConfig<GitHubProfile>;
293
- bitbucket: OAuthProviderConfig<BitbucketProfile>;
294
- figma: OAuthProviderConfig<FigmaProfile>;
295
- discord: OAuthProviderConfig<DiscordProfile>;
296
- gitlab: OAuthProviderConfig<GitLabProfile>;
297
- spotify: OAuthProviderConfig<SpotifyProfile>;
298
- x: OAuthProviderConfig<XProfile>;
420
+ readonly github: OAuthProviderConfig<GitHubProfile>;
421
+ readonly bitbucket: OAuthProviderConfig<BitbucketProfile>;
422
+ readonly figma: OAuthProviderConfig<FigmaProfile>;
423
+ readonly discord: OAuthProviderConfig<DiscordProfile>;
424
+ readonly gitlab: OAuthProviderConfig<GitLabProfile>;
425
+ readonly spotify: OAuthProviderConfig<SpotifyProfile>;
426
+ readonly x: OAuthProviderConfig<XProfile>;
427
+ readonly strava: OAuthProviderConfig<StravaProfile>;
428
+ readonly mailchimp: OAuthProviderConfig<MailchimpProfile>;
429
+ readonly pinterest: OAuthProviderConfig<PinterestProfile>;
299
430
  };
300
431
  /**
301
432
  * Constructs OAuth provider configurations from an array of provider names or configurations.
@@ -312,15 +443,21 @@ type BuiltInOAuthProvider = keyof typeof builtInOAuthProviders;
312
443
  * These fields are typically filtered out before returning user data.
313
444
  */
314
445
  type JWTStandardClaims = Pick<JWTPayload, "exp" | "iat" | "jti" | "nbf" | "sub" | "aud" | "iss">;
446
+ /**
447
+ * JWT payload structure that includes a mandatory `token` field used to verify CSRF Tokens
448
+ */
449
+ type JWTPayloadWithToken = JWTPayload & {
450
+ token: string;
451
+ };
315
452
  /**
316
453
  * Standardized user profile returned by OAuth providers after fetching user information
317
454
  * and mapping the response to this format by default or via the `profile` custom function.
318
455
  */
319
456
  interface User {
320
457
  sub: string;
321
- name?: string;
322
- email?: string;
323
- image?: string;
458
+ name?: string | null;
459
+ email?: string | null;
460
+ image?: string | null;
324
461
  }
325
462
  /**
326
463
  * Session data returned by the session endpoint.
@@ -340,70 +477,49 @@ interface OAuthProviderConfig<Profile extends object = {}> {
340
477
  accessToken: string;
341
478
  userInfo: string;
342
479
  scope: string;
343
- responseType: string;
480
+ responseType: "code" | "token" | "refresh_token" | "id_token";
344
481
  profile?: (profile: Profile) => User | Promise<User>;
345
482
  }
346
483
  /**
347
484
  * OAuth provider configuration with client credentials.
348
485
  * Extends OAuthProviderConfig with clientId and clientSecret.
349
486
  */
350
- interface OAuthProviderCredentials extends OAuthProviderConfig {
487
+ interface OAuthProviderCredentials<Profile extends object = {}> extends OAuthProviderConfig<Profile> {
351
488
  clientId: string;
352
489
  clientSecret: string;
353
490
  }
354
491
  /**
355
492
  * Complete OAuth provider type combining configuration and credentials.
356
493
  */
357
- type OAuthProvider<Profile extends Record<string, unknown> = {}> = OAuthProviderConfig<Profile> & OAuthProviderCredentials;
494
+ type OAuthProvider<Profile extends object = {}> = OAuthProviderCredentials<Profile>;
358
495
  /**
359
496
  * Cookie type with __Secure- prefix, must be Secure.
360
497
  * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__secure-prefix
361
498
  */
362
499
  type SecureCookie = {
363
500
  strategy: "secure";
364
- } & {
365
- options?: Prettify<Omit<SerializeOptions, "secure" | "encode">>;
366
- };
501
+ } & Prettify<Omit<SerializeOptions, "secure" | "encode">>;
367
502
  /**
368
503
  * Cookie type with __Host- prefix, must be Secure, Path=/, no Domain attribute.
369
504
  * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__host-prefix
370
505
  */
371
506
  type HostCookie = {
372
507
  strategy: "host";
373
- } & {
374
- options?: Prettify<Omit<SerializeOptions, "secure" | "path" | "domain" | "encode">>;
375
- };
508
+ } & Prettify<Omit<SerializeOptions, "secure" | "path" | "domain" | "encode">>;
376
509
  /**
377
510
  * Standard cookie type without security prefixes.
378
511
  * Can be sent over both HTTP and HTTPS connections (default in development).
379
512
  */
380
513
  type StandardCookie = {
381
514
  strategy?: "standard";
382
- } & {
383
- options?: Prettify<Omit<SerializeOptions, "encode">>;
384
- };
515
+ } & Prettify<Omit<SerializeOptions, "encode">>;
385
516
  /**
386
517
  * Union type for cookie options based on the specified strategy.
387
518
  * - `secure`: Cookies are only sent over HTTPS connections
388
519
  * - `host`: Cookies use the __Host- prefix and are only sent over HTTPS connections
389
520
  * - `standard`: Cookies can be sent over both HTTP and HTTPS connections (default in development)
390
521
  */
391
- type CookieStrategyOptions = StandardCookie | SecureCookie | HostCookie;
392
- /**
393
- * Configuration options for cookies used in Aura Auth.
394
- * @see {@link AuthConfig.cookies}
395
- */
396
- type CookieConfig = Prettify<{
397
- name?: string;
398
- } & CookieStrategyOptions>;
399
- /**
400
- * Internal representation of cookie configuration with all options resolved.
401
- * @internal
402
- */
403
- type CookieConfigInternal = {
404
- name?: string;
405
- prefix?: string;
406
- } & SerializeOptions;
522
+ type CookieStrategyAttributes = StandardCookie | SecureCookie | HostCookie;
407
523
  /**
408
524
  * Names of cookies used by Aura Auth for session management and OAuth flows.
409
525
  * - `sessionToken`: User session JWT
@@ -414,7 +530,18 @@ type CookieConfigInternal = {
414
530
  * - `redirect_to`: Post-authentication redirect path
415
531
  * - `nonce`: OpenID Connect nonce parameter
416
532
  */
417
- type CookieName = "sessionToken" | "csrfToken" | "state" | "nonce" | "code_verifier" | "redirect_to" | "redirect_uri";
533
+ type CookieName = "sessionToken" | "csrfToken" | "state" | "codeVerifier" | "redirectTo" | "redirectURI";
534
+ type CookieStoreConfig = Record<CookieName, {
535
+ name: string;
536
+ attributes: CookieStrategyAttributes;
537
+ }>;
538
+ interface CookieConfig {
539
+ /**
540
+ * Prefix to be added to all cookie names. By default "aura-stack".
541
+ */
542
+ prefix?: string;
543
+ overrides?: Partial<CookieStoreConfig>;
544
+ }
418
545
  /**
419
546
  * Main configuration interface for Aura Auth.
420
547
  * This is the user-facing configuration object passed to `createAuth()`.
@@ -462,10 +589,10 @@ interface AuthConfig {
462
589
  * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__secure-prefix
463
590
  * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__host-prefix
464
591
  */
465
- cookies?: CookieConfig;
592
+ cookies?: Partial<CookieConfig>;
466
593
  /**
467
594
  * Secret used to sign and verify JWT tokens for session and csrf protection.
468
- * If not provided, it will load from the environment variable `AURA_AUTH_SECRET`, but if it
595
+ * If not provided, it will load from the environment variable `AURA_AUTH_SECRET` or `AUTH_SECRET`, but if it
469
596
  * doesn't exist, it will throw an error during the initialization of the Auth module.
470
597
  */
471
598
  secret?: string;
@@ -493,27 +620,24 @@ interface JoseInstance {
493
620
  decodeJWT: (token: string) => Promise<JWTPayload>;
494
621
  encodeJWT: (payload: JWTPayload) => Promise<string>;
495
622
  signJWS: (payload: JWTPayload) => Promise<string>;
496
- verifyJWS: (payload: string) => Promise<JWTPayload>;
497
- }
498
- /**
499
- * Internal runtime configuration used within Aura Auth after initialization.
500
- * All optional fields from AuthConfig are resolved to their default values.
501
- * @internal
502
- * @todo: is this needed?
503
- */
504
- interface AuthRuntimeConfig {
505
- oauth: Record<LiteralUnion<BuiltInOAuthProvider>, OAuthProviderCredentials>;
506
- cookies: CookieConfig;
507
- secret: string;
508
- jose: JoseInstance;
623
+ verifyJWS: (payload: string, options?: JWTVerifyOptions) => Promise<JWTPayload>;
624
+ encryptJWE: (payload: string, options?: EncryptOptions) => Promise<string>;
625
+ decryptJWE: (payload: string, options?: JWTDecryptOptions) => Promise<string>;
509
626
  }
627
+ type OAuthProviderRecord = Record<LiteralUnion<BuiltInOAuthProvider>, OAuthProviderCredentials>;
510
628
  interface RouterGlobalContext {
511
- oauth: Record<LiteralUnion<BuiltInOAuthProvider>, OAuthProviderCredentials>;
512
- cookies: CookieConfigInternal;
629
+ oauth: OAuthProviderRecord;
630
+ cookies: CookieStoreConfig;
513
631
  jose: JoseInstance;
632
+ secret?: string;
514
633
  basePath: string;
515
634
  trustedProxyHeaders: boolean;
516
635
  }
636
+ /**
637
+ * Internal runtime configuration used within Aura Auth after initialization.
638
+ * All optional fields from AuthConfig are resolved to their default values.
639
+ */
640
+ type AuthRuntimeConfig = RouterGlobalContext;
517
641
  interface AuthInstance {
518
642
  handlers: {
519
643
  GET: (request: Request) => Response | Promise<Response>;
@@ -542,7 +666,14 @@ type AccessTokenError = OAuthError<z.infer<typeof OAuthAccessTokenErrorResponse>
542
666
  * OAuth 2.0 Token Revocation Error Response Types
543
667
  * @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.2.1
544
668
  */
545
- type TokenRevocationError = OAuthError<"invalid_session_token" | "invalid_csrf_token" | "invalid_redirect_to">;
669
+ type TokenRevocationError = OAuthError<"invalid_session_token">;
546
670
  type ErrorType = AuthorizationError["error"] | AccessTokenError["error"] | TokenRevocationError["error"];
671
+ type AuthInternalErrorCode = "INVALID_OAUTH_CONFIGURATION" | "INVALID_JWT_TOKEN" | "JOSE_INITIALIZATION_FAILED" | "SESSION_STORE_NOT_INITIALIZED" | "COOKIE_STORE_NOT_INITIALIZED" | "COOKIE_PARSING_FAILED" | "COOKIE_NOT_FOUND" | "INVALID_ENVIRONMENT_CONFIGURATION";
672
+ type AuthSecurityErrorCode = "INVALID_STATE" | "MISMATCHING_STATE" | "POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED" | "CSRF_TOKEN_INVALID" | "CSRF_TOKEN_MISSING" | "SESSION_TOKEN_MISSING";
673
+ type OAuthEnv = z.infer<typeof OAuthEnvSchema>;
674
+ type APIErrorMap = Record<string, {
675
+ code: string;
676
+ message: string;
677
+ }>;
547
678
 
548
- export { type AuthRuntimeConfig as A, type BitbucketProfile as B, type CookieConfig as C, type DiscordProfile as D, type ErrorType as E, type FigmaProfile as F, type GitLabProfile as G, type HostCookie as H, type JoseInstance as J, type Nameplate as N, type OAuthProvider as O, type RouterGlobalContext as R, type Session as S, type TokenRevocationError as T, type User as U, type XProfile as X, type CookieConfigInternal as a, type CookieName as b, type AuthConfig as c, type AuthInstance as d, type OAuthProviderConfig as e, type OAuthProviderCredentials as f, type SpotifyProfile as g, gitlab as h, discord as i, figma as j, bitbucket as k, type GitHubProfile as l, github as m, builtInOAuthProviders as n, createBuiltInOAuthProviders as o, type BuiltInOAuthProvider as p, type JWTStandardClaims as q, type SecureCookie as r, spotify as s, type StandardCookie as t, type CookieStrategyOptions as u, type OAuthError as v, type AuthorizationError as w, x, type AccessTokenError as y };
679
+ export { type AuthorizationError as $, type AuthRuntimeConfig as A, type BitbucketProfile as B, type CookieConfig as C, type DiscordProfile as D, type ErrorType as E, type FigmaProfile as F, type GitLabProfile as G, createBuiltInOAuthProviders as H, type Image as I, type JWTPayloadWithToken as J, type BuiltInOAuthProvider as K, type Login as L, type MailchimpProfile as M, type Nameplate as N, type OAuthProvider as O, type PinterestProfile as P, type JWTStandardClaims as Q, type RouterGlobalContext as R, type Session as S, type SecureCookie as T, type User as U, type HostCookie as V, type StandardCookie as W, type XProfile as X, type CookieStrategyAttributes as Y, type CookieName as Z, type OAuthError as _, type CookieStoreConfig as a, type AccessTokenError as a0, type TokenRevocationError as a1, type OAuthEnv as a2, type AuthInternalErrorCode as b, type AuthSecurityErrorCode as c, type AuthConfig as d, type AuthInstance as e, type JoseInstance as f, type OAuthProviderConfig as g, type OAuthProviderCredentials as h, type APIErrorMap as i, type OAuthProviderRecord as j, type SummaryClub as k, type SummaryGear as l, mailchimp as m, type StravaProfile as n, type SpotifyProfile as o, pinterest as p, spotify as q, gitlab as r, strava as s, discord as t, figma as u, bitbucket as v, type GitHubProfile as w, x, github as y, builtInOAuthProviders as z };