@aura-stack/auth 0.4.0-rc.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/@types/index.d.ts +4 -3
  2. package/dist/@types/router.d.cjs +0 -17
  3. package/dist/@types/router.d.d.ts +3 -2
  4. package/dist/@types/router.d.js +0 -1
  5. package/dist/actions/callback/access-token.cjs +40 -25
  6. package/dist/actions/callback/access-token.d.ts +4 -3
  7. package/dist/actions/callback/access-token.js +3 -4
  8. package/dist/actions/callback/callback.cjs +287 -77
  9. package/dist/actions/callback/callback.d.ts +5 -26
  10. package/dist/actions/callback/callback.js +13 -10
  11. package/dist/actions/callback/userinfo.cjs +68 -7
  12. package/dist/actions/callback/userinfo.d.ts +4 -3
  13. package/dist/actions/callback/userinfo.js +8 -6
  14. package/dist/actions/csrfToken/csrfToken.cjs +63 -4
  15. package/dist/actions/csrfToken/csrfToken.d.ts +1 -3
  16. package/dist/actions/csrfToken/csrfToken.js +8 -6
  17. package/dist/actions/index.cjs +400 -175
  18. package/dist/actions/index.d.ts +3 -2
  19. package/dist/actions/index.js +21 -19
  20. package/dist/actions/session/session.cjs +40 -11
  21. package/dist/actions/session/session.d.ts +1 -3
  22. package/dist/actions/session/session.js +4 -4
  23. package/dist/actions/signIn/authorization.cjs +171 -132
  24. package/dist/actions/signIn/authorization.d.ts +21 -11
  25. package/dist/actions/signIn/authorization.js +8 -6
  26. package/dist/actions/signIn/signIn.cjs +220 -113
  27. package/dist/actions/signIn/signIn.d.ts +5 -25
  28. package/dist/actions/signIn/signIn.js +9 -7
  29. package/dist/actions/signOut/signOut.cjs +268 -119
  30. package/dist/actions/signOut/signOut.d.ts +1 -9
  31. package/dist/actions/signOut/signOut.js +10 -8
  32. package/dist/assert.cjs +117 -5
  33. package/dist/assert.d.ts +22 -3
  34. package/dist/assert.js +17 -3
  35. package/dist/chunk-4EKY7655.js +123 -0
  36. package/dist/chunk-4MYWAOLG.js +31 -0
  37. package/dist/chunk-4YHJ4IEQ.js +25 -0
  38. package/dist/chunk-54CZPKR4.js +25 -0
  39. package/dist/chunk-5LZ7TOM3.js +25 -0
  40. package/dist/{chunk-W6LG7BFW.js → chunk-5W4BRQYG.js} +24 -20
  41. package/dist/chunk-6MXFPFR3.js +143 -0
  42. package/dist/{chunk-3EUWD5BB.js → chunk-7QF22LHP.js} +13 -9
  43. package/dist/chunk-ALG3GIV4.js +95 -0
  44. package/dist/chunk-E6G5YCI6.js +25 -0
  45. package/dist/chunk-EBAMFRB7.js +34 -0
  46. package/dist/chunk-EEE7UM5T.js +25 -0
  47. package/dist/{chunk-TLE4PXY3.js → chunk-FRJFWTOY.js} +38 -7
  48. package/dist/chunk-FW4W3REU.js +25 -0
  49. package/dist/{chunk-HT4YLL7N.js → chunk-ICAZ4OVS.js} +10 -8
  50. package/dist/chunk-IPKO6UQN.js +25 -0
  51. package/dist/{chunk-YRCB5FLE.js → chunk-KJBAQZX2.js} +13 -0
  52. package/dist/chunk-KMMAZFSJ.js +25 -0
  53. package/dist/chunk-LDU7A2JE.js +25 -0
  54. package/dist/{chunk-N2APGLXA.js → chunk-NUDITUKX.js} +18 -16
  55. package/dist/chunk-OVHNRULD.js +33 -0
  56. package/dist/{chunk-JVFTCTTE.js → chunk-PHFH2MGS.js} +12 -9
  57. package/dist/chunk-QQVSRXGX.js +149 -0
  58. package/dist/chunk-TM5IPSNF.js +113 -0
  59. package/dist/{chunk-GA2SMTJO.js → chunk-TZB6MUXN.js} +33 -13
  60. package/dist/chunk-VNCNJKS2.js +267 -0
  61. package/dist/{chunk-IVET23KF.js → chunk-XGLBNXL4.js} +31 -14
  62. package/dist/chunk-XUP6KKNG.js +106 -0
  63. package/dist/cookie.cjs +24 -20
  64. package/dist/cookie.d.ts +4 -3
  65. package/dist/cookie.js +1 -1
  66. package/dist/env.cjs +56 -0
  67. package/dist/env.d.ts +7 -0
  68. package/dist/env.js +6 -0
  69. package/dist/errors.d.ts +4 -3
  70. package/dist/headers.cjs +28 -2
  71. package/dist/headers.d.ts +25 -1
  72. package/dist/headers.js +9 -3
  73. package/dist/{index-DkaLJFn8.d.ts → index-CSyIJmCM.d.ts} +373 -45
  74. package/dist/index.cjs +1128 -483
  75. package/dist/index.d.ts +6 -10
  76. package/dist/index.js +83 -42
  77. package/dist/jose.cjs +62 -25
  78. package/dist/jose.d.ts +7 -5
  79. package/dist/jose.js +8 -6
  80. package/dist/logger.cjs +292 -0
  81. package/dist/logger.d.ts +8 -0
  82. package/dist/logger.js +8 -0
  83. package/dist/oauth/bitbucket.cjs +19 -15
  84. package/dist/oauth/bitbucket.d.ts +3 -2
  85. package/dist/oauth/bitbucket.js +1 -1
  86. package/dist/oauth/discord.cjs +27 -24
  87. package/dist/oauth/discord.d.ts +3 -2
  88. package/dist/oauth/discord.js +1 -1
  89. package/dist/oauth/figma.cjs +19 -16
  90. package/dist/oauth/figma.d.ts +3 -2
  91. package/dist/oauth/figma.js +1 -1
  92. package/dist/oauth/github.cjs +19 -8
  93. package/dist/oauth/github.d.ts +3 -2
  94. package/dist/oauth/github.js +1 -1
  95. package/dist/oauth/gitlab.cjs +19 -16
  96. package/dist/oauth/gitlab.d.ts +3 -2
  97. package/dist/oauth/gitlab.js +1 -1
  98. package/dist/oauth/index.cjs +266 -166
  99. package/dist/oauth/index.d.ts +3 -2
  100. package/dist/oauth/index.js +22 -21
  101. package/dist/oauth/mailchimp.cjs +19 -16
  102. package/dist/oauth/mailchimp.d.ts +3 -2
  103. package/dist/oauth/mailchimp.js +1 -1
  104. package/dist/oauth/pinterest.cjs +19 -16
  105. package/dist/oauth/pinterest.d.ts +3 -2
  106. package/dist/oauth/pinterest.js +1 -1
  107. package/dist/oauth/spotify.cjs +19 -16
  108. package/dist/oauth/spotify.d.ts +3 -2
  109. package/dist/oauth/spotify.js +1 -1
  110. package/dist/oauth/strava.cjs +19 -16
  111. package/dist/oauth/strava.d.ts +3 -2
  112. package/dist/oauth/strava.js +1 -1
  113. package/dist/oauth/x.cjs +19 -16
  114. package/dist/oauth/x.d.ts +3 -2
  115. package/dist/oauth/x.js +1 -1
  116. package/dist/schemas.cjs +16 -2
  117. package/dist/schemas.d.ts +17 -1
  118. package/dist/schemas.js +5 -3
  119. package/dist/secure.cjs +58 -16
  120. package/dist/secure.d.ts +4 -10
  121. package/dist/secure.js +5 -5
  122. package/dist/utils.cjs +94 -87
  123. package/dist/utils.d.ts +9 -39
  124. package/dist/utils.js +11 -9
  125. package/package.json +3 -4
  126. package/dist/chunk-42XB3YCW.js +0 -22
  127. package/dist/chunk-6R2YZ4AC.js +0 -22
  128. package/dist/chunk-A3N4PVAT.js +0 -70
  129. package/dist/chunk-B737EUJV.js +0 -22
  130. package/dist/chunk-CXLATHS5.js +0 -143
  131. package/dist/chunk-DIVDFNAP.js +0 -0
  132. package/dist/chunk-E3OXBRYF.js +0 -22
  133. package/dist/chunk-EIL2FPSS.js +0 -22
  134. package/dist/chunk-EMKJA2GJ.js +0 -89
  135. package/dist/chunk-FIPU4MLT.js +0 -21
  136. package/dist/chunk-FKRDCWBF.js +0 -22
  137. package/dist/chunk-HP34YGGJ.js +0 -22
  138. package/dist/chunk-IKHPGFCW.js +0 -14
  139. package/dist/chunk-IUYZQTJV.js +0 -30
  140. package/dist/chunk-KRNOMBXQ.js +0 -22
  141. package/dist/chunk-KSWLO5ZU.js +0 -102
  142. package/dist/chunk-N4SX7TZT.js +0 -96
  143. package/dist/chunk-STHEPPUZ.js +0 -11
@@ -35,197 +35,277 @@ __export(oauth_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(oauth_exports);
37
37
 
38
+ // src/env.ts
39
+ var import_meta = {};
40
+ var env = new Proxy({}, {
41
+ get(_, prop) {
42
+ if (typeof prop !== "string") return void 0;
43
+ const hasProperty = (process2) => {
44
+ return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
45
+ };
46
+ try {
47
+ if (typeof process !== "undefined" && hasProperty(process.env)) {
48
+ return process.env[prop];
49
+ }
50
+ if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
51
+ return import_meta.env[prop];
52
+ }
53
+ if (typeof Deno !== "undefined" && Deno.env?.get) {
54
+ return Deno.env.get(prop);
55
+ }
56
+ if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
57
+ return Bun.env[prop];
58
+ }
59
+ const globalValue = globalThis[prop];
60
+ return typeof globalValue === "string" ? globalValue : void 0;
61
+ } catch {
62
+ return void 0;
63
+ }
64
+ }
65
+ });
66
+
38
67
  // src/oauth/github.ts
39
- var github = {
40
- id: "github",
41
- name: "GitHub",
42
- authorizeURL: "https://github.com/login/oauth/authorize",
43
- accessToken: "https://github.com/login/oauth/access_token",
44
- userInfo: "https://api.github.com/user",
45
- scope: "read:user user:email",
46
- responseType: "code"
68
+ var github = (options2) => {
69
+ return {
70
+ id: "github",
71
+ name: "GitHub",
72
+ authorizeURL: "https://github.com/login/oauth/authorize",
73
+ accessToken: "https://github.com/login/oauth/access_token",
74
+ userInfo: "https://api.github.com/user",
75
+ scope: "read:user user:email",
76
+ responseType: "code",
77
+ profile: (profile) => {
78
+ return {
79
+ sub: profile.id.toString(),
80
+ name: profile.name ?? profile.login,
81
+ email: profile.email ?? void 0,
82
+ image: profile.avatar_url
83
+ };
84
+ },
85
+ ...options2
86
+ };
47
87
  };
48
88
 
49
89
  // src/oauth/bitbucket.ts
50
- var bitbucket = {
51
- id: "bitbucket",
52
- name: "Bitbucket",
53
- authorizeURL: "https://bitbucket.org/site/oauth2/authorize",
54
- accessToken: "https://bitbucket.org/site/oauth2/access_token",
55
- userInfo: "https://api.bitbucket.org/2.0/user",
56
- scope: "account email",
57
- responseType: "code",
58
- profile(profile) {
59
- return {
60
- sub: profile.uuid ?? profile.account_id,
61
- name: profile.display_name ?? profile.nickname,
62
- image: profile.links.avatar.href
63
- };
64
- }
90
+ var bitbucket = (options2) => {
91
+ return {
92
+ id: "bitbucket",
93
+ name: "Bitbucket",
94
+ authorizeURL: "https://bitbucket.org/site/oauth2/authorize",
95
+ accessToken: "https://bitbucket.org/site/oauth2/access_token",
96
+ userInfo: "https://api.bitbucket.org/2.0/user",
97
+ scope: "account email",
98
+ responseType: "code",
99
+ profile(profile) {
100
+ return {
101
+ sub: profile.uuid ?? profile.account_id,
102
+ name: profile.display_name ?? profile.nickname,
103
+ image: profile.links.avatar?.href,
104
+ email: void 0
105
+ };
106
+ },
107
+ ...options2
108
+ };
65
109
  };
66
110
 
67
111
  // src/oauth/figma.ts
68
- var figma = {
69
- id: "figma",
70
- name: "Figma",
71
- authorizeURL: "https://www.figma.com/oauth",
72
- accessToken: "https://api.figma.com/v1/oauth/token",
73
- userInfo: "https://api.figma.com/v1/me",
74
- scope: "current_user:read",
75
- responseType: "code",
76
- profile(profile) {
77
- return {
78
- sub: profile.id,
79
- name: profile.handle,
80
- email: profile.email,
81
- image: profile.img_url
82
- };
83
- }
112
+ var figma = (options2) => {
113
+ return {
114
+ id: "figma",
115
+ name: "Figma",
116
+ authorizeURL: "https://www.figma.com/oauth",
117
+ accessToken: "https://api.figma.com/v1/oauth/token",
118
+ userInfo: "https://api.figma.com/v1/me",
119
+ scope: "current_user:read",
120
+ responseType: "code",
121
+ profile(profile) {
122
+ return {
123
+ sub: profile.id,
124
+ name: profile.handle,
125
+ email: profile.email,
126
+ image: profile.img_url
127
+ };
128
+ },
129
+ ...options2
130
+ };
84
131
  };
85
132
 
86
133
  // src/oauth/discord.ts
87
- var discord = {
88
- id: "discord",
89
- name: "Discord",
90
- authorizeURL: "https://discord.com/oauth2/authorize",
91
- accessToken: "https://discord.com/api/oauth2/token",
92
- userInfo: "https://discord.com/api/users/@me",
93
- scope: "identify email",
94
- responseType: "code",
95
- profile(profile) {
96
- let image = "";
97
- if (profile.avatar === null) {
98
- const index = profile.discriminator === "0" ? (BigInt(profile.id) >> 22n) % 6n : Number(profile.discriminator) % 5;
99
- image = `https://cdn.discordapp.com/embed/avatars/${index}.png`;
100
- } else {
101
- const format = profile.avatar.startsWith("a_") ? "gif" : "png";
102
- image = `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.${format}`;
103
- }
104
- return {
105
- sub: profile.id,
106
- name: profile.global_name ?? profile.username,
107
- email: profile.email ?? "",
108
- image
109
- };
110
- }
134
+ var discord = (options2) => {
135
+ return {
136
+ id: "discord",
137
+ name: "Discord",
138
+ authorizeURL: "https://discord.com/oauth2/authorize",
139
+ accessToken: "https://discord.com/api/oauth2/token",
140
+ userInfo: "https://discord.com/api/users/@me",
141
+ scope: "identify email",
142
+ responseType: "code",
143
+ profile(profile) {
144
+ let image = "";
145
+ if (profile.avatar === null) {
146
+ const index = profile.discriminator === "0" ? (BigInt(profile.id) >> 22n) % 6n : Number(profile.discriminator) % 5;
147
+ image = `https://cdn.discordapp.com/embed/avatars/${index}.png`;
148
+ } else {
149
+ const format = profile.avatar.startsWith("a_") ? "gif" : "png";
150
+ image = `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.${format}`;
151
+ }
152
+ return {
153
+ sub: profile.id,
154
+ name: profile.global_name ?? profile.username,
155
+ email: profile.email ?? "",
156
+ image
157
+ };
158
+ },
159
+ ...options2
160
+ };
111
161
  };
112
162
 
113
163
  // src/oauth/gitlab.ts
114
- var gitlab = {
115
- id: "gitlab",
116
- name: "GitLab",
117
- authorizeURL: "https://gitlab.com/oauth/authorize",
118
- accessToken: "https://gitlab.com/oauth/token",
119
- userInfo: "https://gitlab.com/api/v4/user",
120
- scope: "read_user",
121
- responseType: "code",
122
- profile(profile) {
123
- return {
124
- sub: profile.id.toString(),
125
- name: profile.name ?? profile.username,
126
- email: profile.email,
127
- avatar: profile.avatar_url
128
- };
129
- }
164
+ var gitlab = (options2) => {
165
+ return {
166
+ id: "gitlab",
167
+ name: "GitLab",
168
+ authorizeURL: "https://gitlab.com/oauth/authorize",
169
+ accessToken: "https://gitlab.com/oauth/token",
170
+ userInfo: "https://gitlab.com/api/v4/user",
171
+ scope: "read_user",
172
+ responseType: "code",
173
+ profile(profile) {
174
+ return {
175
+ sub: profile.id.toString(),
176
+ name: profile.name ?? profile.username,
177
+ email: profile.email,
178
+ image: profile.avatar_url
179
+ };
180
+ },
181
+ ...options2
182
+ };
130
183
  };
131
184
 
132
185
  // src/oauth/spotify.ts
133
- var spotify = {
134
- id: "spotify",
135
- name: "Spotify",
136
- authorizeURL: "https://accounts.spotify.com/authorize",
137
- accessToken: "https://accounts.spotify.com/api/token",
138
- userInfo: "https://api.spotify.com/v1/me",
139
- scope: "user-read-email user-read-private",
140
- responseType: "token",
141
- profile(profile) {
142
- return {
143
- sub: profile.id,
144
- name: profile.display_name,
145
- email: profile.email,
146
- image: profile.images?.[0]?.url
147
- };
148
- }
186
+ var spotify = (options2) => {
187
+ return {
188
+ id: "spotify",
189
+ name: "Spotify",
190
+ authorizeURL: "https://accounts.spotify.com/authorize",
191
+ accessToken: "https://accounts.spotify.com/api/token",
192
+ userInfo: "https://api.spotify.com/v1/me",
193
+ scope: "user-read-private user-read-email",
194
+ responseType: "code",
195
+ profile(profile) {
196
+ return {
197
+ sub: profile.id,
198
+ name: profile.display_name,
199
+ email: profile.email,
200
+ image: profile.images[0]?.url ?? void 0
201
+ };
202
+ },
203
+ ...options2
204
+ };
149
205
  };
150
206
 
151
207
  // src/oauth/x.ts
152
- var x = {
153
- id: "x",
154
- name: "X",
155
- authorizeURL: "https://x.com/i/oauth2/authorize",
156
- accessToken: "https://api.x.com/2/oauth2/token",
157
- userInfo: "https://api.x.com/2/users/me?user.fields=profile_image_url",
158
- scope: "users.read users.email tweet.read offline.access",
159
- responseType: "code",
160
- profile({ data }) {
161
- return {
162
- sub: data.id,
163
- name: data.name,
164
- image: data.profile_image_url,
165
- email: ""
166
- };
167
- }
208
+ var x = (options2) => {
209
+ return {
210
+ id: "x",
211
+ name: "X",
212
+ authorizeURL: "https://twitter.com/i/oauth2/authorize",
213
+ accessToken: "https://api.twitter.com/2/oauth2/token",
214
+ userInfo: "https://api.twitter.com/2/users/me?user.fields=profile_image_url",
215
+ scope: "tweet.read users.read offline.access",
216
+ responseType: "code",
217
+ profile(profile) {
218
+ return {
219
+ sub: profile.data.id,
220
+ name: profile.data.name,
221
+ image: profile.data.profile_image_url,
222
+ email: void 0
223
+ };
224
+ },
225
+ ...options2
226
+ };
168
227
  };
169
228
 
170
229
  // src/oauth/strava.ts
171
- var strava = {
172
- id: "strava",
173
- name: "Strava",
174
- authorizeURL: "https://www.strava.com/oauth/authorize",
175
- accessToken: "https://www.strava.com/oauth/token",
176
- userInfo: "https://www.strava.com/api/v3/athlete",
177
- scope: "read",
178
- responseType: "code",
179
- profile(profile) {
180
- return {
181
- sub: profile.id.toString(),
182
- name: `${profile.firstname} ${profile.lastname}`,
183
- image: profile.profile,
184
- email: ""
185
- };
186
- }
230
+ var strava = (options2) => {
231
+ return {
232
+ id: "strava",
233
+ name: "Strava",
234
+ authorizeURL: "https://www.strava.com/oauth/authorize",
235
+ accessToken: "https://www.strava.com/oauth/token",
236
+ userInfo: "https://www.strava.com/api/v3/athlete",
237
+ scope: "read",
238
+ responseType: "code",
239
+ profile(profile) {
240
+ return {
241
+ sub: profile.id.toString(),
242
+ name: `${profile.firstname} ${profile.lastname}`,
243
+ image: profile.profile,
244
+ email: void 0
245
+ };
246
+ },
247
+ ...options2
248
+ };
187
249
  };
188
250
 
189
251
  // src/oauth/mailchimp.ts
190
- var mailchimp = {
191
- id: "mailchimp",
192
- name: "Mailchimp",
193
- authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
194
- accessToken: "https://login.mailchimp.com/oauth2/token",
195
- userInfo: "https://login.mailchimp.com/oauth2/metadata",
196
- scope: "",
197
- responseType: "code",
198
- profile(profile) {
199
- return {
200
- sub: profile.user_id,
201
- name: profile.accountname,
202
- email: profile.login.login_email,
203
- image: null
204
- };
205
- }
252
+ var mailchimp = (options2) => {
253
+ return {
254
+ id: "mailchimp",
255
+ name: "Mailchimp",
256
+ authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
257
+ accessToken: "https://login.mailchimp.com/oauth2/token",
258
+ userInfo: "https://login.mailchimp.com/oauth2/metadata",
259
+ scope: "",
260
+ responseType: "code",
261
+ profile(profile) {
262
+ return {
263
+ sub: profile.user_id,
264
+ name: profile.accountname,
265
+ email: profile.login.email,
266
+ image: profile.login.avatar
267
+ };
268
+ },
269
+ ...options2
270
+ };
206
271
  };
207
272
 
208
273
  // src/oauth/pinterest.ts
209
- var pinterest = {
210
- id: "pinterest",
211
- name: "Pinterest",
212
- authorizeURL: "https://api.pinterest.com/oauth/",
213
- accessToken: "https://api.pinterest.com/v5/oauth/token",
214
- userInfo: "https://api.pinterest.com/v5/user_account",
215
- scope: "user_accounts:read",
216
- responseType: "code",
217
- profile(profile) {
218
- return {
219
- sub: profile.id,
220
- name: profile.username,
221
- email: null,
222
- image: profile.profile_image
223
- };
224
- }
274
+ var pinterest = (options2) => {
275
+ return {
276
+ id: "pinterest",
277
+ name: "Pinterest",
278
+ authorizeURL: "https://www.pinterest.com/oauth",
279
+ accessToken: "https://api.pinterest.com/v5/oauth/token",
280
+ userInfo: "https://api.pinterest.com/v5/user_account",
281
+ scope: "user_accounts:read",
282
+ responseType: "code",
283
+ profile(profile) {
284
+ return {
285
+ sub: profile.id,
286
+ name: profile.username,
287
+ image: profile.profile_image,
288
+ email: void 0
289
+ };
290
+ },
291
+ ...options2
292
+ };
225
293
  };
226
294
 
227
295
  // src/schemas.ts
228
296
  var import_zod = require("zod");
297
+ var OAuthProviderCredentialsSchema = (0, import_zod.object)({
298
+ id: (0, import_zod.string)(),
299
+ name: (0, import_zod.string)(),
300
+ authorizeURL: (0, import_zod.string)().url(),
301
+ accessToken: (0, import_zod.string)().url(),
302
+ scope: (0, import_zod.string)(),
303
+ userInfo: (0, import_zod.string)().url(),
304
+ responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
305
+ clientId: (0, import_zod.string)(),
306
+ clientSecret: (0, import_zod.string)(),
307
+ profile: import_zod.z.function().optional()
308
+ });
229
309
  var OAuthProviderConfigSchema = (0, import_zod.object)({
230
310
  authorizeURL: (0, import_zod.string)().url(),
231
311
  accessToken: (0, import_zod.string)().url(),
@@ -336,7 +416,6 @@ var builtInOAuthProviders = {
336
416
  pinterest
337
417
  };
338
418
  var defineOAuthEnvironment = (oauth) => {
339
- const env = process.env;
340
419
  const clientIdSuffix = `${oauth.toUpperCase()}_CLIENT_ID`;
341
420
  const clientSecretSuffix = `${oauth.toUpperCase()}_CLIENT_SECRET`;
342
421
  const loadEnvs = OAuthEnvSchema.safeParse({
@@ -352,17 +431,38 @@ var defineOAuthEnvironment = (oauth) => {
352
431
  var defineOAuthProviderConfig = (config) => {
353
432
  if (typeof config === "string") {
354
433
  const definition = defineOAuthEnvironment(config);
355
- const oauthConfig = builtInOAuthProviders[config];
356
- return {
357
- ...oauthConfig,
358
- ...definition
359
- };
434
+ const oauthConfig = builtInOAuthProviders[config]();
435
+ const parsed2 = OAuthProviderCredentialsSchema.safeParse({ ...oauthConfig, ...definition });
436
+ if (!parsed2.success) {
437
+ const details = JSON.stringify(formatZodError(parsed2.error), null, 2);
438
+ throw new AuthInternalError(
439
+ "INVALID_OAUTH_PROVIDER_CONFIGURATION",
440
+ `Invalid configuration for OAuth provider "${config}": ${details}`
441
+ );
442
+ }
443
+ return parsed2.data;
444
+ }
445
+ const hasCredentials = config.clientId && config.clientSecret;
446
+ const envConfig = hasCredentials ? {} : defineOAuthEnvironment(config.id);
447
+ const parsed = OAuthProviderCredentialsSchema.safeParse({ ...envConfig, ...config });
448
+ if (!parsed.success) {
449
+ const details = JSON.stringify(formatZodError(parsed.error), null, 2);
450
+ throw new AuthInternalError(
451
+ "INVALID_OAUTH_PROVIDER_CONFIGURATION",
452
+ `Invalid configuration for OAuth provider "${config.id}": ${details}`
453
+ );
360
454
  }
361
- return config;
455
+ return parsed.data;
362
456
  };
363
457
  var createBuiltInOAuthProviders = (oauth = []) => {
364
458
  return oauth.reduce((previous, config) => {
365
459
  const oauthConfig = defineOAuthProviderConfig(config);
460
+ if (oauthConfig.id in previous) {
461
+ throw new AuthInternalError(
462
+ "DUPLICATED_OAUTH_PROVIDER_ID",
463
+ `Duplicate OAuth provider id "${oauthConfig.id}" found. Each provider must have a unique id.`
464
+ );
465
+ }
366
466
  return { ...previous, [oauthConfig.id]: oauthConfig };
367
467
  }, {});
368
468
  };
@@ -1,7 +1,8 @@
1
- export { B as BitbucketProfile, K as BuiltInOAuthProvider, D as DiscordProfile, F as FigmaProfile, w as GitHubProfile, G as GitLabProfile, I as Image, L as Login, M as MailchimpProfile, N as Nameplate, P as PinterestProfile, o as SpotifyProfile, n as StravaProfile, k as SummaryClub, l as SummaryGear, X as XProfile, v as bitbucket, z as builtInOAuthProviders, H as createBuiltInOAuthProviders, t as discord, u as figma, y as github, r as gitlab, m as mailchimp, p as pinterest, q as spotify, s as strava, x } from '../index-DkaLJFn8.js';
1
+ export { H as BitbucketProfile, Z as BuiltInOAuthProvider, D as DiscordProfile, F as FigmaProfile, Q as GitHubProfile, G as GitLabProfile, n as Login, M as MailchimpProfile, N as Nameplate, P as PinterestProfile, u as SpotifyImage, v as SpotifyProfile, s as StravaProfile, q as SummaryClub, r as SummaryGear, X as XProfile, K as bitbucket, W as builtInOAuthProviders, Y as createBuiltInOAuthProviders, z as discord, B as figma, V as github, y as gitlab, o as mailchimp, p as pinterest, w as spotify, t as strava, x } from '../index-CSyIJmCM.js';
2
2
  import '../@types/utility.js';
3
3
  import 'zod';
4
4
  import '../schemas.js';
5
- import '@aura-stack/router/cookie';
5
+ import '../jose.js';
6
6
  import '@aura-stack/jose';
7
7
  import '@aura-stack/jose/jose';
8
+ import '@aura-stack/router/cookie';
@@ -1,40 +1,41 @@
1
1
  import {
2
2
  builtInOAuthProviders,
3
3
  createBuiltInOAuthProviders
4
- } from "../chunk-EMKJA2GJ.js";
4
+ } from "../chunk-TM5IPSNF.js";
5
+ import {
6
+ spotify
7
+ } from "../chunk-IPKO6UQN.js";
8
+ import {
9
+ strava
10
+ } from "../chunk-54CZPKR4.js";
5
11
  import {
6
12
  x
7
- } from "../chunk-42XB3YCW.js";
13
+ } from "../chunk-EEE7UM5T.js";
14
+ import {
15
+ bitbucket
16
+ } from "../chunk-4YHJ4IEQ.js";
17
+ import {
18
+ discord
19
+ } from "../chunk-OVHNRULD.js";
8
20
  import {
9
21
  figma
10
- } from "../chunk-FKRDCWBF.js";
22
+ } from "../chunk-KMMAZFSJ.js";
11
23
  import {
12
24
  github
13
- } from "../chunk-IKHPGFCW.js";
25
+ } from "../chunk-FW4W3REU.js";
14
26
  import {
15
27
  gitlab
16
- } from "../chunk-KRNOMBXQ.js";
28
+ } from "../chunk-5LZ7TOM3.js";
17
29
  import {
18
30
  mailchimp
19
- } from "../chunk-B737EUJV.js";
31
+ } from "../chunk-LDU7A2JE.js";
20
32
  import {
21
33
  pinterest
22
- } from "../chunk-HP34YGGJ.js";
23
- import {
24
- spotify
25
- } from "../chunk-E3OXBRYF.js";
26
- import {
27
- strava
28
- } from "../chunk-6R2YZ4AC.js";
29
- import {
30
- bitbucket
31
- } from "../chunk-FIPU4MLT.js";
32
- import {
33
- discord
34
- } from "../chunk-IUYZQTJV.js";
35
- import "../chunk-CXLATHS5.js";
34
+ } from "../chunk-E6G5YCI6.js";
35
+ import "../chunk-KJBAQZX2.js";
36
+ import "../chunk-QQVSRXGX.js";
37
+ import "../chunk-4MYWAOLG.js";
36
38
  import "../chunk-RRLIF4PQ.js";
37
- import "../chunk-YRCB5FLE.js";
38
39
  export {
39
40
  bitbucket,
40
41
  builtInOAuthProviders,
@@ -23,22 +23,25 @@ __export(mailchimp_exports, {
23
23
  mailchimp: () => mailchimp
24
24
  });
25
25
  module.exports = __toCommonJS(mailchimp_exports);
26
- var mailchimp = {
27
- id: "mailchimp",
28
- name: "Mailchimp",
29
- authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
30
- accessToken: "https://login.mailchimp.com/oauth2/token",
31
- userInfo: "https://login.mailchimp.com/oauth2/metadata",
32
- scope: "",
33
- responseType: "code",
34
- profile(profile) {
35
- return {
36
- sub: profile.user_id,
37
- name: profile.accountname,
38
- email: profile.login.login_email,
39
- image: null
40
- };
41
- }
26
+ var mailchimp = (options) => {
27
+ return {
28
+ id: "mailchimp",
29
+ name: "Mailchimp",
30
+ authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
31
+ accessToken: "https://login.mailchimp.com/oauth2/token",
32
+ userInfo: "https://login.mailchimp.com/oauth2/metadata",
33
+ scope: "",
34
+ responseType: "code",
35
+ profile(profile) {
36
+ return {
37
+ sub: profile.user_id,
38
+ name: profile.accountname,
39
+ email: profile.login.email,
40
+ image: profile.login.avatar
41
+ };
42
+ },
43
+ ...options
44
+ };
42
45
  };
43
46
  // Annotate the CommonJS export names for ESM import in node:
44
47
  0 && (module.exports = {
@@ -1,7 +1,8 @@
1
- export { L as Login, M as MailchimpProfile, m as mailchimp } from '../index-DkaLJFn8.js';
1
+ export { n as Login, M as MailchimpProfile, o as mailchimp } from '../index-CSyIJmCM.js';
2
2
  import 'zod';
3
3
  import '../schemas.js';
4
- import '@aura-stack/router/cookie';
4
+ import '../jose.js';
5
5
  import '@aura-stack/jose';
6
6
  import '@aura-stack/jose/jose';
7
+ import '@aura-stack/router/cookie';
7
8
  import '../@types/utility.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mailchimp
3
- } from "../chunk-B737EUJV.js";
3
+ } from "../chunk-LDU7A2JE.js";
4
4
  export {
5
5
  mailchimp
6
6
  };