@aura-stack/auth 0.1.0-rc.9 → 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 (153) hide show
  1. package/dist/@types/index.cjs +15 -15
  2. package/dist/@types/index.d.ts +7 -31
  3. package/dist/@types/index.js +1 -1
  4. package/dist/@types/router.d.cjs +1 -1
  5. package/dist/@types/router.d.d.ts +7 -7
  6. package/dist/@types/utility.cjs +15 -15
  7. package/dist/@types/utility.d.ts +4 -8
  8. package/dist/@types/utility.js +1 -1
  9. package/dist/actions/callback/access-token.cjs +176 -155
  10. package/dist/actions/callback/access-token.d.ts +15 -20
  11. package/dist/actions/callback/access-token.js +10 -4
  12. package/dist/actions/callback/callback.cjs +394 -490
  13. package/dist/actions/callback/callback.d.ts +10 -12
  14. package/dist/actions/callback/callback.js +16 -12
  15. package/dist/actions/callback/userinfo.cjs +166 -145
  16. package/dist/actions/callback/userinfo.d.ts +9 -9
  17. package/dist/actions/callback/userinfo.js +12 -6
  18. package/dist/actions/csrfToken/csrfToken.cjs +112 -190
  19. package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
  20. package/dist/actions/csrfToken/csrfToken.js +12 -8
  21. package/dist/actions/index.cjs +652 -814
  22. package/dist/actions/index.d.ts +13 -13
  23. package/dist/actions/index.js +34 -18
  24. package/dist/actions/session/session.cjs +86 -176
  25. package/dist/actions/session/session.d.ts +3 -3
  26. package/dist/actions/session/session.js +10 -7
  27. package/dist/actions/signIn/authorization.cjs +254 -263
  28. package/dist/actions/signIn/authorization.d.ts +12 -18
  29. package/dist/actions/signIn/authorization.js +16 -6
  30. package/dist/actions/signIn/signIn.cjs +320 -456
  31. package/dist/actions/signIn/signIn.d.ts +10 -10
  32. package/dist/actions/signIn/signIn.js +13 -10
  33. package/dist/actions/signOut/signOut.cjs +304 -473
  34. package/dist/actions/signOut/signOut.d.ts +3 -3
  35. package/dist/actions/signOut/signOut.js +14 -11
  36. package/dist/assert.cjs +40 -36
  37. package/dist/assert.d.ts +13 -4
  38. package/dist/assert.js +12 -2
  39. package/dist/chunk-3EUWD5BB.js +63 -0
  40. package/dist/chunk-42XB3YCW.js +19 -17
  41. package/dist/chunk-6R2YZ4AC.js +22 -0
  42. package/dist/chunk-A3N4PVAT.js +70 -0
  43. package/dist/chunk-B737EUJV.js +22 -0
  44. package/dist/chunk-CXLATHS5.js +143 -0
  45. package/dist/chunk-E3OXBRYF.js +19 -17
  46. package/dist/chunk-EIL2FPSS.js +22 -0
  47. package/dist/chunk-EMKJA2GJ.js +89 -0
  48. package/dist/chunk-FIPU4MLT.js +18 -16
  49. package/dist/chunk-FKRDCWBF.js +19 -17
  50. package/dist/chunk-GA2SMTJO.js +58 -0
  51. package/dist/chunk-HP34YGGJ.js +22 -0
  52. package/dist/chunk-HT4YLL7N.js +35 -0
  53. package/dist/chunk-IKHPGFCW.js +11 -9
  54. package/dist/chunk-IUYZQTJV.js +30 -0
  55. package/dist/chunk-IVET23KF.js +58 -0
  56. package/dist/chunk-JVFTCTTE.js +33 -0
  57. package/dist/chunk-KRNOMBXQ.js +19 -17
  58. package/dist/chunk-KSWLO5ZU.js +102 -0
  59. package/dist/chunk-N2APGLXA.js +71 -0
  60. package/dist/chunk-N4SX7TZT.js +96 -0
  61. package/dist/chunk-RRLIF4PQ.js +55 -0
  62. package/dist/chunk-STHEPPUZ.js +8 -6
  63. package/dist/chunk-TLE4PXY3.js +39 -0
  64. package/dist/chunk-W6LG7BFW.js +197 -0
  65. package/dist/chunk-YRCB5FLE.js +79 -0
  66. package/dist/chunk-ZNCZVF6U.js +14 -0
  67. package/dist/cookie.cjs +222 -187
  68. package/dist/cookie.d.ts +39 -76
  69. package/dist/cookie.js +27 -34
  70. package/dist/errors.cjs +85 -0
  71. package/dist/errors.d.ts +49 -0
  72. package/dist/errors.js +18 -0
  73. package/dist/headers.cjs +28 -28
  74. package/dist/headers.d.ts +2 -2
  75. package/dist/headers.js +6 -2
  76. package/dist/index-DkaLJFn8.d.ts +679 -0
  77. package/dist/index.cjs +1074 -1007
  78. package/dist/index.d.ts +10 -31
  79. package/dist/index.js +85 -51
  80. package/dist/jose.cjs +74 -66
  81. package/dist/jose.d.ts +11 -8
  82. package/dist/jose.js +10 -5
  83. package/dist/oauth/bitbucket.cjs +38 -38
  84. package/dist/oauth/bitbucket.d.ts +7 -7
  85. package/dist/oauth/bitbucket.js +6 -2
  86. package/dist/oauth/discord.cjs +47 -48
  87. package/dist/oauth/discord.d.ts +7 -7
  88. package/dist/oauth/discord.js +6 -2
  89. package/dist/oauth/figma.cjs +39 -39
  90. package/dist/oauth/figma.d.ts +7 -7
  91. package/dist/oauth/figma.js +6 -2
  92. package/dist/oauth/github.cjs +31 -31
  93. package/dist/oauth/github.d.ts +7 -7
  94. package/dist/oauth/github.js +6 -2
  95. package/dist/oauth/gitlab.cjs +39 -39
  96. package/dist/oauth/gitlab.d.ts +7 -7
  97. package/dist/oauth/gitlab.js +6 -2
  98. package/dist/oauth/index.cjs +350 -180
  99. package/dist/oauth/index.d.ts +7 -26
  100. package/dist/oauth/index.js +51 -9
  101. package/dist/oauth/mailchimp.cjs +46 -0
  102. package/dist/oauth/mailchimp.d.ts +7 -0
  103. package/dist/oauth/mailchimp.js +6 -0
  104. package/dist/oauth/pinterest.cjs +46 -0
  105. package/dist/oauth/pinterest.d.ts +7 -0
  106. package/dist/oauth/pinterest.js +6 -0
  107. package/dist/oauth/spotify.cjs +39 -39
  108. package/dist/oauth/spotify.d.ts +7 -7
  109. package/dist/oauth/spotify.js +6 -2
  110. package/dist/oauth/strava.cjs +46 -0
  111. package/dist/oauth/strava.d.ts +7 -0
  112. package/dist/oauth/strava.js +6 -0
  113. package/dist/oauth/x.cjs +39 -39
  114. package/dist/oauth/x.d.ts +7 -7
  115. package/dist/oauth/x.js +6 -2
  116. package/dist/request.cjs +38 -0
  117. package/dist/request.d.ts +13 -0
  118. package/dist/request.js +6 -0
  119. package/dist/schemas.cjs +103 -97
  120. package/dist/schemas.d.ts +96 -126
  121. package/dist/schemas.js +20 -18
  122. package/dist/secure.cjs +106 -101
  123. package/dist/secure.d.ts +17 -17
  124. package/dist/secure.js +19 -4
  125. package/dist/utils.cjs +197 -135
  126. package/dist/utils.d.ts +20 -26
  127. package/dist/utils.js +25 -21
  128. package/package.json +8 -7
  129. package/dist/chunk-256KIVJL.js +0 -110
  130. package/dist/chunk-6SM22VVJ.js +0 -15
  131. package/dist/chunk-CAKJT3KS.js +0 -77
  132. package/dist/chunk-EBPE35JT.js +0 -29
  133. package/dist/chunk-FJUDBLCP.js +0 -52
  134. package/dist/chunk-GZU3RBTB.js +0 -51
  135. package/dist/chunk-HGJ4TXY4.js +0 -105
  136. package/dist/chunk-HMRKN75I.js +0 -74
  137. package/dist/chunk-JAPMIE6S.js +0 -8
  138. package/dist/chunk-LLR722CL.js +0 -75
  139. package/dist/chunk-RLT4RFKV.js +0 -36
  140. package/dist/chunk-SJPDVKUS.js +0 -93
  141. package/dist/chunk-SMQO5WD7.js +0 -20
  142. package/dist/chunk-UJJ7R56J.js +0 -42
  143. package/dist/chunk-UTDLUEEG.js +0 -25
  144. package/dist/chunk-VFTYH33W.js +0 -44
  145. package/dist/chunk-XXJKNKGQ.js +0 -27
  146. package/dist/chunk-ZV4BH47P.js +0 -156
  147. package/dist/error.cjs +0 -88
  148. package/dist/error.d.ts +0 -62
  149. package/dist/error.js +0 -9
  150. package/dist/index-DpfbvTZ_.d.ts +0 -597
  151. package/dist/response.cjs +0 -34
  152. package/dist/response.d.ts +0 -10
  153. package/dist/response.js +0 -2
@@ -0,0 +1,679 @@
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';
5
+ import { JWTPayload } from '@aura-stack/jose/jose';
6
+ import { LiteralUnion, Prettify } from './@types/utility.js';
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
+
125
+ /**
126
+ * @see [X - Get my User](https://docs.x.com/x-api/users/get-my-user)
127
+ */
128
+ interface XProfile {
129
+ data: {
130
+ id: string;
131
+ name: string;
132
+ username: string;
133
+ profile_image_url: string;
134
+ };
135
+ }
136
+ /**
137
+ * X (Twitter) OAuth Provider
138
+ * @see [X - Developer Portal](https://developer.x.com/en/portal/projects-and-apps)
139
+ * @see [X - Get my User](https://docs.x.com/x-api/users/get-my-user)
140
+ * @see [X - OAuth 2.0 Authorization Code Flow with PKCE](https://docs.x.com/fundamentals/authentication/oauth-2-0/authorization-code)
141
+ * @see [X - OAuth 2.0 Scopes](https://docs.x.com/fundamentals/authentication/oauth-2-0/authorization-code#scopes)
142
+ * @see [X - OAuth 2.0 Bearer Token](https://docs.x.com/fundamentals/authentication/oauth-2-0/application-only)
143
+ */
144
+ declare const x: OAuthProviderConfig<XProfile>;
145
+
146
+ interface Image {
147
+ url: string;
148
+ height: number;
149
+ width: number;
150
+ }
151
+ /**
152
+ * @see [Spotify - User Object](https://developer.spotify.com/documentation/web-api/reference/object-model/#user-object-private)
153
+ */
154
+ interface SpotifyProfile {
155
+ id: string;
156
+ display_name: string;
157
+ email: string;
158
+ type: string;
159
+ uri: string;
160
+ country: string;
161
+ href: string;
162
+ images: Image[];
163
+ product: string;
164
+ explicit_content: {
165
+ filter_enabled: boolean;
166
+ filter_locked: boolean;
167
+ };
168
+ external_urls: {
169
+ spotify: string;
170
+ };
171
+ followers: {
172
+ href: string;
173
+ total: number;
174
+ };
175
+ }
176
+ /**
177
+ * Spotify OAuth Provider
178
+ *
179
+ * @see [Spotify - Spotify Developer Dashboard](https://developer.spotify.com/dashboard)
180
+ * @see [Spotify - Getting started with Web API](https://developer.spotify.com/documentation/web-api/tutorials/getting-started)
181
+ * @see [Spotify - Get Current User's Profile](https://developer.spotify.com/documentation/web-api/reference/get-current-users-profile)
182
+ * @see [Spotify - Scopes](https://developer.spotify.com/documentation/web-api/concepts/scopes)
183
+ * @see [Spotify - Redirect URIs](https://developer.spotify.com/documentation/web-api/concepts/redirect_uri)
184
+ */
185
+ declare const spotify: OAuthProviderConfig<SpotifyProfile>;
186
+
187
+ /**
188
+ * @see [GitLab - Get the current user](https://docs.gitlab.com/api/users/#get-the-current-user)
189
+ */
190
+ interface GitLabProfile {
191
+ id: number;
192
+ username: string;
193
+ email: string;
194
+ name: string;
195
+ state: string;
196
+ locked: boolean;
197
+ avatar_url: string;
198
+ web_url: string;
199
+ created_at: string;
200
+ bio: string;
201
+ location: string | null;
202
+ public_email: string;
203
+ linkedin: string;
204
+ twitter: string;
205
+ discord: string;
206
+ github: string;
207
+ website_url: string;
208
+ organization: string;
209
+ job_title: string;
210
+ pronouns: string;
211
+ bot: boolean;
212
+ work_information: string | null;
213
+ followers: number;
214
+ following: number;
215
+ local_time: string;
216
+ last_sign_in_at: string;
217
+ confirmed_at: string;
218
+ theme_id: number;
219
+ last_activity_on: string;
220
+ color_scheme_id: number;
221
+ projects_limit: number;
222
+ current_sign_in_at: string;
223
+ identities: {
224
+ provider: string;
225
+ extern_uid: string;
226
+ saml_provider_id: number | null;
227
+ }[];
228
+ can_create_group: boolean;
229
+ can_create_project: boolean;
230
+ two_factor_enabled: boolean;
231
+ external: boolean;
232
+ private_profile: boolean;
233
+ commit_email: string;
234
+ preferred_language: string;
235
+ shared_runners_minutes_limit: number | null;
236
+ extra_shared_runners_minutes_limit: number | null;
237
+ scim_identities: unknown[];
238
+ }
239
+ /**
240
+ * GitLab OAuth Provider
241
+ *
242
+ * @see [GitLab - Applications](https://gitlab.com/-/user_settings/applications)
243
+ * @see [GitLab - OAuth 2.0 identify provider API](https://docs.gitlab.com/api/oauth2/)
244
+ * @see [GitLab - Scopes](https://docs.gitlab.com/integration/oauth_provider/#view-all-authorized-applications)
245
+ * @see [GitLab - Get current user](https://docs.gitlab.com/api/users/#get-the-current-user)
246
+ */
247
+ declare const gitlab: OAuthProviderConfig<GitLabProfile>;
248
+
249
+ /**
250
+ * @see [Discord - Nameplate Object](https://discord.com/developers/docs/resources/user#nameplate-nameplate-structure)
251
+ */
252
+ interface Nameplate {
253
+ sku_id: string;
254
+ asset: string;
255
+ label: string;
256
+ palette: string;
257
+ }
258
+ /**
259
+ * The `snowflake` type is a string type. The attributes defined with this type are:
260
+ * - `id`: The unique identifier for the object.
261
+ * - `primary_guild.identity_guild_id`: The unique identifier for the guild.
262
+ * - `avatar_decoration_data.sku_id`: The unique identifier for the SKU.
263
+ *
264
+ * @see [Discord - User Object](https://discord.com/developers/docs/resources/user#user-object)
265
+ */
266
+ interface DiscordProfile {
267
+ id: string;
268
+ username: string;
269
+ discriminator: string;
270
+ global_name: string | null;
271
+ avatar: string | null;
272
+ bot?: boolean;
273
+ system?: boolean;
274
+ mfa_enabled?: boolean;
275
+ banner?: string | null;
276
+ accent_color?: number | null;
277
+ locale?: string;
278
+ verified?: boolean;
279
+ email?: string | null;
280
+ flags?: number;
281
+ premium_type?: number;
282
+ public_flags?: number;
283
+ avatar_decoration_data?: {
284
+ asset: string;
285
+ sku_id: string;
286
+ };
287
+ collections?: Record<string, Nameplate>;
288
+ primary_guild?: {
289
+ identity_guild_id: string;
290
+ identity_enabled: boolean | null;
291
+ tag: string | null;
292
+ badge: string | null;
293
+ };
294
+ }
295
+ /**
296
+ * Discord OAuth Provider
297
+ *
298
+ * @see [Discord - Applications](https://discord.com/developers/applications)
299
+ * @see [Discord - OAuth2](https://discord.com/developers/docs/topics/oauth2)
300
+ * @see [Discord - Get Current User](https://discord.com/developers/docs/resources/user#get-current-user)
301
+ * @see [Discord - User Object](https://discord.com/developers/docs/resources/user#user-object)
302
+ * @see [Discord - OAuth2 Scopes](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes)
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)
305
+ */
306
+ declare const discord: OAuthProviderConfig<DiscordProfile>;
307
+
308
+ /**
309
+ * @see [Figma API - Users](https://developers.figma.com/docs/rest-api/users-types/)
310
+ */
311
+ interface FigmaProfile {
312
+ id: string;
313
+ handle: string;
314
+ img_url: string;
315
+ email: string;
316
+ }
317
+ /**
318
+ * Figma OAuth Provider
319
+ * @see [Figma - REST API Introduction](https://developers.figma.com/docs/rest-api/)
320
+ * @see [Figma - OAuth App](https://www.figma.com/developers/apps/)
321
+ * @see [Figma - Create an OAuth App](https://developers.figma.com/docs/rest-api/authentication/#create-an-oauth-app)
322
+ * @see [Figma - OAuth Scopes](https://developers.figma.com/docs/rest-api/scopes/)
323
+ */
324
+ declare const figma: OAuthProviderConfig<FigmaProfile>;
325
+
326
+ /**
327
+ * @see [Get current user](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-user-get)
328
+ */
329
+ interface BitbucketProfile {
330
+ display_name: string;
331
+ links: Record<LiteralUnion<"self" | "avatar" | "repositories" | "snippets" | "html" | "hooks">, {
332
+ href?: string;
333
+ }>;
334
+ created_on: string;
335
+ type: string;
336
+ uuid: string;
337
+ has_2fa_enabled: boolean;
338
+ username: string;
339
+ nickname: string;
340
+ is_staff: boolean;
341
+ account_id: string;
342
+ account_status: LiteralUnion<"active" | "inactive" | "closed">;
343
+ location: string | null;
344
+ }
345
+ /**
346
+ * Bitbucket OAuth Provider
347
+ *
348
+ * @see [Bitbucket - Official App](https://bitbucket.org/)
349
+ * @see [Bitbucket - Workspaces](https://bitbucket.org/account/workspaces/)
350
+ * @see [Bitbucket - Workspace Settings](https://bitbucket.org/{workspace-name}/workspace/settings/)
351
+ * @see [Bitbucket - OAuth 2.0](https://developer.atlassian.com/cloud/bitbucket/oauth-2/)
352
+ * @see [Bitbucket - Use OAuth on Bitbucket Cloud](https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/)
353
+ * @see [Bitbucket - Cloud REST API](https://developer.atlassian.com/cloud/bitbucket/rest/intro/)
354
+ * @see [Bitbucket - User Endpoint](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-users-endpoint)
355
+ */
356
+ declare const bitbucket: OAuthProviderConfig<BitbucketProfile>;
357
+
358
+ /**
359
+ * @see [Get the authenticated user](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user)
360
+ */
361
+ interface GitHubProfile {
362
+ login: string;
363
+ id: number;
364
+ user_view_type: string;
365
+ node_id: string;
366
+ avatar_url: string;
367
+ gravatar_id: string | null;
368
+ url: string;
369
+ html_url: string;
370
+ followers_url: string;
371
+ following_url: string;
372
+ gists_url: string;
373
+ starred_url: string;
374
+ subscriptions_url: string;
375
+ organizations_url: string;
376
+ repos_url: string;
377
+ events_url: string;
378
+ received_events_url: string;
379
+ type: string;
380
+ site_admin: boolean;
381
+ name: string | null;
382
+ company: string | null;
383
+ blog: string | null;
384
+ location: string | null;
385
+ email: string | null;
386
+ notification_email: string | null;
387
+ hireable: boolean | null;
388
+ bio: string | null;
389
+ twitter_username?: string | null;
390
+ public_repos: number;
391
+ public_gists: number;
392
+ followers: number;
393
+ following: number;
394
+ created_at: string;
395
+ updated_at: string;
396
+ private_gists?: number;
397
+ total_private_repos?: number;
398
+ owned_private_repos?: number;
399
+ disk_usage?: number;
400
+ collaborators?: number;
401
+ two_factor_authentication: boolean;
402
+ plan?: {
403
+ collaborators: number;
404
+ name: string;
405
+ space: number;
406
+ private_repos: number;
407
+ };
408
+ }
409
+ /**
410
+ * GitHub OAuth Provider
411
+ *
412
+ * @see [GitHub - Creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)
413
+ * @see [GitHub - Authorizing OAuth Apps](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps)
414
+ * @see [GitHub - Configure your GitHub OAuth Apps](https://github.com/settings/developers)
415
+ * @see [Github - Get the authenticated user](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user)
416
+ */
417
+ declare const github: OAuthProviderConfig<GitHubProfile>;
418
+
419
+ declare const builtInOAuthProviders: {
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>;
430
+ };
431
+ /**
432
+ * Constructs OAuth provider configurations from an array of provider names or configurations.
433
+ * It loads the client ID and client secret from environment variables if only the provider name is provided.
434
+ *
435
+ * @param oauth - Array of OAuth provider configurations or provider names to be defined from environment variables
436
+ * @returns A record of OAuth provider configurations
437
+ */
438
+ declare const createBuiltInOAuthProviders: (oauth?: (BuiltInOAuthProvider | OAuthProviderCredentials)[]) => Record<LiteralUnion<BuiltInOAuthProvider>, OAuthProviderCredentials>;
439
+ type BuiltInOAuthProvider = keyof typeof builtInOAuthProviders;
440
+
441
+ /**
442
+ * Standard JWT claims that are managed internally by the token system.
443
+ * These fields are typically filtered out before returning user data.
444
+ */
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
+ };
452
+ /**
453
+ * Standardized user profile returned by OAuth providers after fetching user information
454
+ * and mapping the response to this format by default or via the `profile` custom function.
455
+ */
456
+ interface User {
457
+ sub: string;
458
+ name?: string | null;
459
+ email?: string | null;
460
+ image?: string | null;
461
+ }
462
+ /**
463
+ * Session data returned by the session endpoint.
464
+ */
465
+ interface Session {
466
+ user: User;
467
+ expires: string;
468
+ }
469
+ /**
470
+ * Configuration for an OAuth provider without credentials.
471
+ * Use this type when defining provider metadata and endpoints.
472
+ */
473
+ interface OAuthProviderConfig<Profile extends object = {}> {
474
+ id: string;
475
+ name: string;
476
+ authorizeURL: string;
477
+ accessToken: string;
478
+ userInfo: string;
479
+ scope: string;
480
+ responseType: "code" | "token" | "refresh_token" | "id_token";
481
+ profile?: (profile: Profile) => User | Promise<User>;
482
+ }
483
+ /**
484
+ * OAuth provider configuration with client credentials.
485
+ * Extends OAuthProviderConfig with clientId and clientSecret.
486
+ */
487
+ interface OAuthProviderCredentials<Profile extends object = {}> extends OAuthProviderConfig<Profile> {
488
+ clientId: string;
489
+ clientSecret: string;
490
+ }
491
+ /**
492
+ * Complete OAuth provider type combining configuration and credentials.
493
+ */
494
+ type OAuthProvider<Profile extends object = {}> = OAuthProviderCredentials<Profile>;
495
+ /**
496
+ * Cookie type with __Secure- prefix, must be Secure.
497
+ * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__secure-prefix
498
+ */
499
+ type SecureCookie = {
500
+ strategy: "secure";
501
+ } & Prettify<Omit<SerializeOptions, "secure" | "encode">>;
502
+ /**
503
+ * Cookie type with __Host- prefix, must be Secure, Path=/, no Domain attribute.
504
+ * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__host-prefix
505
+ */
506
+ type HostCookie = {
507
+ strategy: "host";
508
+ } & Prettify<Omit<SerializeOptions, "secure" | "path" | "domain" | "encode">>;
509
+ /**
510
+ * Standard cookie type without security prefixes.
511
+ * Can be sent over both HTTP and HTTPS connections (default in development).
512
+ */
513
+ type StandardCookie = {
514
+ strategy?: "standard";
515
+ } & Prettify<Omit<SerializeOptions, "encode">>;
516
+ /**
517
+ * Union type for cookie options based on the specified strategy.
518
+ * - `secure`: Cookies are only sent over HTTPS connections
519
+ * - `host`: Cookies use the __Host- prefix and are only sent over HTTPS connections
520
+ * - `standard`: Cookies can be sent over both HTTP and HTTPS connections (default in development)
521
+ */
522
+ type CookieStrategyAttributes = StandardCookie | SecureCookie | HostCookie;
523
+ /**
524
+ * Names of cookies used by Aura Auth for session management and OAuth flows.
525
+ * - `sessionToken`: User session JWT
526
+ * - `csrfToken`: CSRF protection token
527
+ * - `state`: OAuth state parameter for CSRF protection
528
+ * - `code_verifier`: PKCE code verifier for authorization code flow
529
+ * - `redirect_uri`: OAuth callback URI
530
+ * - `redirect_to`: Post-authentication redirect path
531
+ * - `nonce`: OpenID Connect nonce parameter
532
+ */
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
+ }
545
+ /**
546
+ * Main configuration interface for Aura Auth.
547
+ * This is the user-facing configuration object passed to `createAuth()`.
548
+ */
549
+ interface AuthConfig {
550
+ /**
551
+ * OAuth providers available in the authentication and authorization flows. It provides a type-inference
552
+ * for the OAuth providers that are supported by Aura Stack Auth; alternatively, you can provide a custom
553
+ * OAuth third-party authorization service by implementing the `OAuthProviderCredentials` interface.
554
+ *
555
+ * Built-in OAuth providers:
556
+ * oauth: ["github", "google"]
557
+ *
558
+ * Custom OAuth providers:
559
+ * oauth: [
560
+ * {
561
+ * id: "oauth-providers",
562
+ * name: "OAuth",
563
+ * authorizeURL: "https://example.com/oauth/authorize",
564
+ * accessToken: "https://example.com/oauth/token",
565
+ * scope: "profile email",
566
+ * responseType: "code",
567
+ * userInfo: "https://example.com/oauth/userinfo",
568
+ * clientId: process.env.AURA_AUTH_OAUTH_PROVIDER_CLIENT_ID!,
569
+ * clientSecret: process.env.AURA_AUTH_OAUTH_PROVIDER_CLIENT_SECRET!,
570
+ * }
571
+ * ]
572
+ */
573
+ oauth: (BuiltInOAuthProvider | OAuthProviderCredentials)[];
574
+ /**
575
+ * Cookie options defines the configuration for cookies used in Aura Auth.
576
+ * It includes a prefix for cookie names and flag options to determine
577
+ * the security and scope of the cookies.
578
+ *
579
+ * **⚠️ WARNING:** Ensure that the cookie options are configured correctly to
580
+ * maintain the security and integrity of the authentication process. `Aura Auth`
581
+ * is not responsible for misconfigured cookies that may lead to security vulnerabilities.
582
+ *
583
+ * - prefix: A string prefix to be added to all cookie names, by default "aura-stack".
584
+ * - flag options (This attributes help to define the security level of the cookies):
585
+ * - secure: Cookies use the __Secure- prefix and are only sent over HTTPS connections.
586
+ * - host: Cookies use the __Host- prefix and are only sent over HTTPS connections.
587
+ * - standard: Cookies can be sent over both HTTP and HTTPS connections. (default in development)
588
+ *
589
+ * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__secure-prefix
590
+ * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__host-prefix
591
+ */
592
+ cookies?: Partial<CookieConfig>;
593
+ /**
594
+ * Secret used to sign and verify JWT tokens for session and csrf protection.
595
+ * If not provided, it will load from the environment variable `AURA_AUTH_SECRET` or `AUTH_SECRET`, but if it
596
+ * doesn't exist, it will throw an error during the initialization of the Auth module.
597
+ */
598
+ secret?: string;
599
+ /**
600
+ * Base path for all authentication routes. Default is `/auth`.
601
+ */
602
+ basePath?: `/${string}`;
603
+ /**
604
+ * Enable trusted proxy headers for scenarios where the application is behind a reverse proxy or load balancer.
605
+ * This setting allows Aura Auth to correctly interpret headers like `X-Forwarded-For` and `X-Forwarded-Proto`
606
+ * to determine the original client IP address and protocol.
607
+ *
608
+ * Default is `false`. Enable this option only if you are certain that your application is behind a trusted proxy.
609
+ * Misconfiguration can lead to security vulnerabilities, such as incorrect handling of secure cookies or
610
+ * inaccurate client IP logging.
611
+ *
612
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
613
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
614
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded
615
+ * @experimental
616
+ */
617
+ trustedProxyHeaders?: boolean;
618
+ }
619
+ interface JoseInstance {
620
+ decodeJWT: (token: string) => Promise<JWTPayload>;
621
+ encodeJWT: (payload: JWTPayload) => Promise<string>;
622
+ signJWS: (payload: JWTPayload) => Promise<string>;
623
+ verifyJWS: (payload: string, options?: JWTVerifyOptions) => Promise<JWTPayload>;
624
+ encryptJWE: (payload: string, options?: EncryptOptions) => Promise<string>;
625
+ decryptJWE: (payload: string, options?: JWTDecryptOptions) => Promise<string>;
626
+ }
627
+ type OAuthProviderRecord = Record<LiteralUnion<BuiltInOAuthProvider>, OAuthProviderCredentials>;
628
+ interface RouterGlobalContext {
629
+ oauth: OAuthProviderRecord;
630
+ cookies: CookieStoreConfig;
631
+ jose: JoseInstance;
632
+ secret?: string;
633
+ basePath: string;
634
+ trustedProxyHeaders: boolean;
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;
641
+ interface AuthInstance {
642
+ handlers: {
643
+ GET: (request: Request) => Response | Promise<Response>;
644
+ POST: (request: Request) => Response | Promise<Response>;
645
+ };
646
+ jose: JoseInstance;
647
+ }
648
+ /**
649
+ * Base OAuth error response structure.
650
+ */
651
+ interface OAuthError<T extends string> {
652
+ error: T;
653
+ error_description?: string;
654
+ }
655
+ /**
656
+ * OAuth 2.0 Authorization Error Response Types
657
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1
658
+ */
659
+ type AuthorizationError = OAuthError<z.infer<typeof OAuthAuthorizationErrorResponse>["error"]>;
660
+ /**
661
+ * OAuth 2.0 Access Token Error Response Types
662
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
663
+ */
664
+ type AccessTokenError = OAuthError<z.infer<typeof OAuthAccessTokenErrorResponse>["error"]>;
665
+ /**
666
+ * OAuth 2.0 Token Revocation Error Response Types
667
+ * @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.2.1
668
+ */
669
+ type TokenRevocationError = OAuthError<"invalid_session_token">;
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
+ }>;
678
+
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 };