@aura-stack/auth 0.5.0 → 0.6.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 (215) hide show
  1. package/README.md +36 -1
  2. package/dist/@types/index.cjs +0 -18
  3. package/dist/@types/index.d.ts +2 -12
  4. package/dist/@types/index.js +0 -1
  5. package/dist/assert-B3iQSYlK.js +3 -0
  6. package/dist/assert-NJGroSJd.cjs +3 -0
  7. package/dist/client/index.cjs +1 -135
  8. package/dist/client/index.d.ts +11 -14
  9. package/dist/client/index.js +1 -10
  10. package/dist/crypto-Bz8nIciY.js +1 -0
  11. package/dist/crypto-CoXA5w_4.cjs +1 -0
  12. package/dist/env-bq387KyP.cjs +1 -0
  13. package/dist/env-nvh8QBNz.js +1 -0
  14. package/dist/errors-CCYPHuBO.cjs +1 -0
  15. package/dist/errors-DFWHOho6.js +1 -0
  16. package/dist/index-BkpwQ0l4.d.cts +2279 -0
  17. package/dist/index-nqLV2t91.d.ts +2279 -0
  18. package/dist/index.cjs +1 -2427
  19. package/dist/index.d.cts +2 -0
  20. package/dist/index.d.ts +2 -14
  21. package/dist/index.js +1 -59
  22. package/dist/logger-C59_CDMk.js +1 -0
  23. package/dist/logger-UnUhYL2V.cjs +1 -0
  24. package/dist/oauth/atlassian.cjs +1 -57
  25. package/dist/oauth/atlassian.d.ts +2 -12
  26. package/dist/oauth/atlassian.js +1 -6
  27. package/dist/oauth/bitbucket.cjs +1 -49
  28. package/dist/oauth/bitbucket.d.ts +2 -12
  29. package/dist/oauth/bitbucket.js +1 -6
  30. package/dist/oauth/discord.cjs +1 -57
  31. package/dist/oauth/discord.d.ts +2 -12
  32. package/dist/oauth/discord.js +1 -6
  33. package/dist/oauth/dropbox.cjs +1 -53
  34. package/dist/oauth/dropbox.d.ts +2 -12
  35. package/dist/oauth/dropbox.js +1 -6
  36. package/dist/oauth/figma.cjs +1 -49
  37. package/dist/oauth/figma.d.ts +2 -12
  38. package/dist/oauth/figma.js +1 -6
  39. package/dist/oauth/github.cjs +1 -49
  40. package/dist/oauth/github.d.ts +2 -12
  41. package/dist/oauth/github.js +1 -6
  42. package/dist/oauth/gitlab.cjs +1 -49
  43. package/dist/oauth/gitlab.d.ts +2 -12
  44. package/dist/oauth/gitlab.js +1 -6
  45. package/dist/oauth/index.cjs +1 -673
  46. package/dist/oauth/index.d.ts +2 -12
  47. package/dist/oauth/index.js +1 -68
  48. package/dist/oauth/mailchimp.cjs +1 -49
  49. package/dist/oauth/mailchimp.d.ts +2 -12
  50. package/dist/oauth/mailchimp.js +1 -6
  51. package/dist/oauth/notion.cjs +1 -131
  52. package/dist/oauth/notion.d.ts +2 -12
  53. package/dist/oauth/notion.js +1 -9
  54. package/dist/oauth/pinterest.cjs +1 -49
  55. package/dist/oauth/pinterest.d.ts +2 -12
  56. package/dist/oauth/pinterest.js +1 -6
  57. package/dist/oauth/spotify.cjs +1 -49
  58. package/dist/oauth/spotify.d.ts +2 -12
  59. package/dist/oauth/spotify.js +1 -6
  60. package/dist/oauth/strava.cjs +1 -49
  61. package/dist/oauth/strava.d.ts +2 -12
  62. package/dist/oauth/strava.js +1 -6
  63. package/dist/oauth/twitch.cjs +1 -95
  64. package/dist/oauth/twitch.d.ts +2 -12
  65. package/dist/oauth/twitch.js +1 -7
  66. package/dist/oauth/x.cjs +1 -49
  67. package/dist/oauth/x.d.ts +2 -12
  68. package/dist/oauth/x.js +1 -6
  69. package/dist/oauth-BntNm6aE.cjs +1 -0
  70. package/dist/oauth-DmHy9VrB.js +1 -0
  71. package/dist/shared/crypto.cjs +1 -0
  72. package/dist/shared/crypto.d.ts +47 -0
  73. package/dist/shared/crypto.js +1 -0
  74. package/dist/shared/identity.cjs +1 -0
  75. package/dist/shared/identity.d.ts +2 -0
  76. package/dist/shared/identity.js +1 -0
  77. package/dist/shared/index.cjs +1 -0
  78. package/dist/shared/index.d.ts +5 -0
  79. package/dist/shared/index.js +1 -0
  80. package/package.json +32 -9
  81. package/dist/@types/router.d.cjs +0 -1
  82. package/dist/@types/router.d.d.ts +0 -16
  83. package/dist/@types/router.d.js +0 -0
  84. package/dist/@types/utility.cjs +0 -18
  85. package/dist/@types/utility.d.ts +0 -6
  86. package/dist/@types/utility.js +0 -1
  87. package/dist/actions/callback/access-token.cjs +0 -250
  88. package/dist/actions/callback/access-token.d.ts +0 -33
  89. package/dist/actions/callback/access-token.js +0 -9
  90. package/dist/actions/callback/callback.cjs +0 -715
  91. package/dist/actions/callback/callback.d.ts +0 -42
  92. package/dist/actions/callback/callback.js +0 -18
  93. package/dist/actions/callback/userinfo.cjs +0 -283
  94. package/dist/actions/callback/userinfo.d.ts +0 -25
  95. package/dist/actions/callback/userinfo.js +0 -13
  96. package/dist/actions/csrfToken/csrfToken.cjs +0 -189
  97. package/dist/actions/csrfToken/csrfToken.d.ts +0 -7
  98. package/dist/actions/csrfToken/csrfToken.js +0 -13
  99. package/dist/actions/index.cjs +0 -1161
  100. package/dist/actions/index.d.ts +0 -17
  101. package/dist/actions/index.js +0 -39
  102. package/dist/actions/session/session.cjs +0 -188
  103. package/dist/actions/session/session.d.ts +0 -7
  104. package/dist/actions/session/session.js +0 -12
  105. package/dist/actions/signIn/authorization-url.cjs +0 -288
  106. package/dist/actions/signIn/authorization-url.d.ts +0 -31
  107. package/dist/actions/signIn/authorization-url.js +0 -16
  108. package/dist/actions/signIn/authorization.cjs +0 -281
  109. package/dist/actions/signIn/authorization.d.ts +0 -54
  110. package/dist/actions/signIn/authorization.js +0 -19
  111. package/dist/actions/signIn/signIn.cjs +0 -595
  112. package/dist/actions/signIn/signIn.d.ts +0 -42
  113. package/dist/actions/signIn/signIn.js +0 -16
  114. package/dist/actions/signOut/signOut.cjs +0 -492
  115. package/dist/actions/signOut/signOut.d.ts +0 -16
  116. package/dist/actions/signOut/signOut.js +0 -15
  117. package/dist/api/createApi.cjs +0 -750
  118. package/dist/api/createApi.d.ts +0 -12
  119. package/dist/api/createApi.js +0 -19
  120. package/dist/api/getSession.cjs +0 -141
  121. package/dist/api/getSession.d.ts +0 -16
  122. package/dist/api/getSession.js +0 -10
  123. package/dist/api/signIn.cjs +0 -549
  124. package/dist/api/signIn.d.ts +0 -26
  125. package/dist/api/signIn.js +0 -15
  126. package/dist/api/signOut.cjs +0 -279
  127. package/dist/api/signOut.d.ts +0 -16
  128. package/dist/api/signOut.js +0 -13
  129. package/dist/assert.cjs +0 -194
  130. package/dist/assert.d.ts +0 -37
  131. package/dist/assert.js +0 -26
  132. package/dist/chunk-2A5B7GWR.js +0 -125
  133. package/dist/chunk-2GQLSIJ2.js +0 -40
  134. package/dist/chunk-2IR674WX.js +0 -44
  135. package/dist/chunk-3J5TUH2I.js +0 -50
  136. package/dist/chunk-4RWSYUKX.js +0 -98
  137. package/dist/chunk-4YHJ4IEQ.js +0 -25
  138. package/dist/chunk-54CZPKR4.js +0 -25
  139. package/dist/chunk-5LZ7TOM3.js +0 -25
  140. package/dist/chunk-5X7JZMEF.js +0 -0
  141. package/dist/chunk-7BE46WWS.js +0 -88
  142. package/dist/chunk-7YYXFKLR.js +0 -35
  143. package/dist/chunk-C3A37LQC.js +0 -33
  144. package/dist/chunk-CITNGXDA.js +0 -31
  145. package/dist/chunk-CWX724AG.js +0 -78
  146. package/dist/chunk-D2CSIUKP.js +0 -74
  147. package/dist/chunk-E6G5YCI6.js +0 -25
  148. package/dist/chunk-EBAMFRB7.js +0 -34
  149. package/dist/chunk-EEE7UM5T.js +0 -25
  150. package/dist/chunk-FPCVZUVG.js +0 -37
  151. package/dist/chunk-FW4W3REU.js +0 -25
  152. package/dist/chunk-GNNBM2WJ.js +0 -83
  153. package/dist/chunk-IPKO6UQN.js +0 -25
  154. package/dist/chunk-ITQ7352M.js +0 -0
  155. package/dist/chunk-JOCGX3RP.js +0 -59
  156. package/dist/chunk-KBXWTD6E.js +0 -94
  157. package/dist/chunk-KMMAZFSJ.js +0 -25
  158. package/dist/chunk-LATR3NIV.js +0 -117
  159. package/dist/chunk-LAYPUDQF.js +0 -39
  160. package/dist/chunk-LDU7A2JE.js +0 -25
  161. package/dist/chunk-LX3TJ2TJ.js +0 -294
  162. package/dist/chunk-NHZBQNRR.js +0 -143
  163. package/dist/chunk-OVHNRULD.js +0 -33
  164. package/dist/chunk-PDP3PHB3.js +0 -127
  165. package/dist/chunk-PG7UYFG5.js +0 -0
  166. package/dist/chunk-PHYNROD4.js +0 -47
  167. package/dist/chunk-QQEKY4XP.js +0 -29
  168. package/dist/chunk-U4RK4LKJ.js +0 -348
  169. package/dist/chunk-U5663F2U.js +0 -70
  170. package/dist/chunk-UN7X6SU5.js +0 -53
  171. package/dist/chunk-UZQJJD6A.js +0 -100
  172. package/dist/chunk-V6LLEAR4.js +0 -80
  173. package/dist/chunk-WHNDRO3N.js +0 -50
  174. package/dist/chunk-XY5R3EHH.js +0 -204
  175. package/dist/chunk-ZNCZVF6U.js +0 -14
  176. package/dist/client/client.cjs +0 -135
  177. package/dist/client/client.d.ts +0 -85
  178. package/dist/client/client.js +0 -9
  179. package/dist/context.cjs +0 -1237
  180. package/dist/context.d.ts +0 -16
  181. package/dist/context.js +0 -28
  182. package/dist/cookie.cjs +0 -277
  183. package/dist/cookie.d.ts +0 -89
  184. package/dist/cookie.js +0 -30
  185. package/dist/createAuth.cjs +0 -2320
  186. package/dist/createAuth.d.ts +0 -12
  187. package/dist/createAuth.js +0 -48
  188. package/dist/env.cjs +0 -78
  189. package/dist/env.d.ts +0 -10
  190. package/dist/env.js +0 -12
  191. package/dist/errors.cjs +0 -102
  192. package/dist/errors.d.ts +0 -60
  193. package/dist/errors.js +0 -22
  194. package/dist/headers.cjs +0 -61
  195. package/dist/headers.d.ts +0 -33
  196. package/dist/headers.js +0 -12
  197. package/dist/index-_aXtxb_s.d.ts +0 -1377
  198. package/dist/jose.cjs +0 -166
  199. package/dist/jose.d.ts +0 -12
  200. package/dist/jose.js +0 -20
  201. package/dist/logger.cjs +0 -424
  202. package/dist/logger.d.ts +0 -12
  203. package/dist/logger.js +0 -17
  204. package/dist/request.cjs +0 -38
  205. package/dist/request.d.ts +0 -13
  206. package/dist/request.js +0 -6
  207. package/dist/schemas.cjs +0 -158
  208. package/dist/schemas.d.ts +0 -229
  209. package/dist/schemas.js +0 -24
  210. package/dist/secure.cjs +0 -170
  211. package/dist/secure.d.ts +0 -41
  212. package/dist/secure.js +0 -20
  213. package/dist/utils.cjs +0 -329
  214. package/dist/utils.d.ts +0 -35
  215. package/dist/utils.js +0 -36
@@ -1,673 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/oauth/index.ts
21
- var oauth_exports = {};
22
- __export(oauth_exports, {
23
- atlassian: () => atlassian,
24
- bitbucket: () => bitbucket,
25
- builtInOAuthProviders: () => builtInOAuthProviders,
26
- createBuiltInOAuthProviders: () => createBuiltInOAuthProviders,
27
- discord: () => discord,
28
- dropbox: () => dropbox,
29
- figma: () => figma,
30
- github: () => github,
31
- gitlab: () => gitlab,
32
- mailchimp: () => mailchimp,
33
- notion: () => notion,
34
- pinterest: () => pinterest,
35
- spotify: () => spotify,
36
- strava: () => strava,
37
- twitch: () => twitch,
38
- x: () => x
39
- });
40
- module.exports = __toCommonJS(oauth_exports);
41
-
42
- // src/env.ts
43
- var import_meta = {};
44
- var env = new Proxy({}, {
45
- get(_, prop) {
46
- if (typeof prop !== "string") return void 0;
47
- const hasProperty = (process2) => {
48
- return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
49
- };
50
- try {
51
- if (typeof process !== "undefined" && hasProperty(process.env)) {
52
- return process.env[prop];
53
- }
54
- if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
55
- return import_meta.env[prop];
56
- }
57
- if (typeof Deno !== "undefined" && Deno.env?.get) {
58
- return Deno.env.get(prop);
59
- }
60
- if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
61
- return Bun.env[prop];
62
- }
63
- const globalValue = globalThis[prop];
64
- return typeof globalValue === "string" ? globalValue : void 0;
65
- } catch {
66
- return void 0;
67
- }
68
- }
69
- });
70
- var getEnv = (key) => {
71
- const keys = [`AURA_AUTH_${key.toUpperCase()}`, `AURA_${key.toUpperCase()}`, `AUTH_${key.toUpperCase()}`, key.toUpperCase()];
72
- return env[keys.find((k) => env[k]) ?? ""];
73
- };
74
-
75
- // src/oauth/github.ts
76
- var github = (options2) => {
77
- return {
78
- id: "github",
79
- name: "GitHub",
80
- authorizeURL: "https://github.com/login/oauth/authorize",
81
- accessToken: "https://github.com/login/oauth/access_token",
82
- userInfo: "https://api.github.com/user",
83
- scope: "read:user user:email",
84
- responseType: "code",
85
- profile: (profile) => {
86
- return {
87
- sub: profile.id.toString(),
88
- name: profile.name ?? profile.login,
89
- email: profile.email ?? void 0,
90
- image: profile.avatar_url
91
- };
92
- },
93
- ...options2
94
- };
95
- };
96
-
97
- // src/oauth/bitbucket.ts
98
- var bitbucket = (options2) => {
99
- return {
100
- id: "bitbucket",
101
- name: "Bitbucket",
102
- authorizeURL: "https://bitbucket.org/site/oauth2/authorize",
103
- accessToken: "https://bitbucket.org/site/oauth2/access_token",
104
- userInfo: "https://api.bitbucket.org/2.0/user",
105
- scope: "account email",
106
- responseType: "code",
107
- profile(profile) {
108
- return {
109
- sub: profile.uuid ?? profile.account_id,
110
- name: profile.display_name ?? profile.nickname,
111
- image: profile.links.avatar?.href,
112
- email: void 0
113
- };
114
- },
115
- ...options2
116
- };
117
- };
118
-
119
- // src/oauth/figma.ts
120
- var figma = (options2) => {
121
- return {
122
- id: "figma",
123
- name: "Figma",
124
- authorizeURL: "https://www.figma.com/oauth",
125
- accessToken: "https://api.figma.com/v1/oauth/token",
126
- userInfo: "https://api.figma.com/v1/me",
127
- scope: "current_user:read",
128
- responseType: "code",
129
- profile(profile) {
130
- return {
131
- sub: profile.id,
132
- name: profile.handle,
133
- email: profile.email,
134
- image: profile.img_url
135
- };
136
- },
137
- ...options2
138
- };
139
- };
140
-
141
- // src/oauth/discord.ts
142
- var discord = (options2) => {
143
- return {
144
- id: "discord",
145
- name: "Discord",
146
- authorizeURL: "https://discord.com/oauth2/authorize",
147
- accessToken: "https://discord.com/api/oauth2/token",
148
- userInfo: "https://discord.com/api/users/@me",
149
- scope: "identify email",
150
- responseType: "code",
151
- profile(profile) {
152
- let image = "";
153
- if (profile.avatar === null) {
154
- const index = profile.discriminator === "0" ? (BigInt(profile.id) >> 22n) % 6n : Number(profile.discriminator) % 5;
155
- image = `https://cdn.discordapp.com/embed/avatars/${index}.png`;
156
- } else {
157
- const format = profile.avatar.startsWith("a_") ? "gif" : "png";
158
- image = `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.${format}`;
159
- }
160
- return {
161
- sub: profile.id,
162
- name: profile.global_name ?? profile.username,
163
- email: profile.email ?? "",
164
- image
165
- };
166
- },
167
- ...options2
168
- };
169
- };
170
-
171
- // src/oauth/gitlab.ts
172
- var gitlab = (options2) => {
173
- return {
174
- id: "gitlab",
175
- name: "GitLab",
176
- authorizeURL: "https://gitlab.com/oauth/authorize",
177
- accessToken: "https://gitlab.com/oauth/token",
178
- userInfo: "https://gitlab.com/api/v4/user",
179
- scope: "read_user",
180
- responseType: "code",
181
- profile(profile) {
182
- return {
183
- sub: profile.id.toString(),
184
- name: profile.name ?? profile.username,
185
- email: profile.email,
186
- image: profile.avatar_url
187
- };
188
- },
189
- ...options2
190
- };
191
- };
192
-
193
- // src/oauth/spotify.ts
194
- var spotify = (options2) => {
195
- return {
196
- id: "spotify",
197
- name: "Spotify",
198
- authorizeURL: "https://accounts.spotify.com/authorize",
199
- accessToken: "https://accounts.spotify.com/api/token",
200
- userInfo: "https://api.spotify.com/v1/me",
201
- scope: "user-read-private user-read-email",
202
- responseType: "code",
203
- profile(profile) {
204
- return {
205
- sub: profile.id,
206
- name: profile.display_name,
207
- email: profile.email,
208
- image: profile.images[0]?.url ?? void 0
209
- };
210
- },
211
- ...options2
212
- };
213
- };
214
-
215
- // src/oauth/x.ts
216
- var x = (options2) => {
217
- return {
218
- id: "x",
219
- name: "X",
220
- authorizeURL: "https://twitter.com/i/oauth2/authorize",
221
- accessToken: "https://api.twitter.com/2/oauth2/token",
222
- userInfo: "https://api.twitter.com/2/users/me?user.fields=profile_image_url",
223
- scope: "tweet.read users.read offline.access",
224
- responseType: "code",
225
- profile(profile) {
226
- return {
227
- sub: profile.data.id,
228
- name: profile.data.name,
229
- image: profile.data.profile_image_url,
230
- email: void 0
231
- };
232
- },
233
- ...options2
234
- };
235
- };
236
-
237
- // src/oauth/strava.ts
238
- var strava = (options2) => {
239
- return {
240
- id: "strava",
241
- name: "Strava",
242
- authorizeURL: "https://www.strava.com/oauth/authorize",
243
- accessToken: "https://www.strava.com/oauth/token",
244
- userInfo: "https://www.strava.com/api/v3/athlete",
245
- scope: "read",
246
- responseType: "code",
247
- profile(profile) {
248
- return {
249
- sub: profile.id.toString(),
250
- name: `${profile.firstname} ${profile.lastname}`,
251
- image: profile.profile,
252
- email: void 0
253
- };
254
- },
255
- ...options2
256
- };
257
- };
258
-
259
- // src/oauth/mailchimp.ts
260
- var mailchimp = (options2) => {
261
- return {
262
- id: "mailchimp",
263
- name: "Mailchimp",
264
- authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
265
- accessToken: "https://login.mailchimp.com/oauth2/token",
266
- userInfo: "https://login.mailchimp.com/oauth2/metadata",
267
- scope: "",
268
- responseType: "code",
269
- profile(profile) {
270
- return {
271
- sub: profile.user_id,
272
- name: profile.accountname,
273
- email: profile.login.email,
274
- image: profile.login.avatar
275
- };
276
- },
277
- ...options2
278
- };
279
- };
280
-
281
- // src/oauth/pinterest.ts
282
- var pinterest = (options2) => {
283
- return {
284
- id: "pinterest",
285
- name: "Pinterest",
286
- authorizeURL: "https://www.pinterest.com/oauth",
287
- accessToken: "https://api.pinterest.com/v5/oauth/token",
288
- userInfo: "https://api.pinterest.com/v5/user_account",
289
- scope: "user_accounts:read",
290
- responseType: "code",
291
- profile(profile) {
292
- return {
293
- sub: profile.id,
294
- name: profile.username,
295
- image: profile.profile_image,
296
- email: void 0
297
- };
298
- },
299
- ...options2
300
- };
301
- };
302
-
303
- // src/oauth/twitch.ts
304
- var twitch = (options2) => {
305
- const clientId = options2?.clientId ?? getEnv("TWITCH_CLIENT_ID");
306
- return {
307
- id: "twitch",
308
- name: "Twitch",
309
- authorize: {
310
- url: "https://id.twitch.tv/oauth2/authorize",
311
- params: { scope: "user:read:email", responseType: "code" }
312
- },
313
- accessToken: "https://id.twitch.tv/oauth2/token",
314
- userInfo: {
315
- url: "https://api.twitch.tv/helix/users",
316
- headers: {
317
- "Client-ID": clientId
318
- }
319
- },
320
- profile(profile) {
321
- const user = profile.data[0];
322
- if (!user) {
323
- throw new Error("No user data found in Twitch profile response");
324
- }
325
- return {
326
- sub: user.id,
327
- name: user.display_name,
328
- email: user.email,
329
- picture: user.profile_image_url
330
- };
331
- },
332
- ...options2
333
- };
334
- };
335
-
336
- // src/utils.ts
337
- var import_router = require("@aura-stack/router");
338
-
339
- // src/errors.ts
340
- var AuthInternalError = class extends Error {
341
- type = "AUTH_INTERNAL_ERROR";
342
- code;
343
- constructor(code, message, options2) {
344
- super(message, options2);
345
- this.code = code;
346
- this.name = new.target.name;
347
- Error.captureStackTrace(this, new.target);
348
- }
349
- };
350
-
351
- // src/assert.ts
352
- var import_crypto = require("@aura-stack/jose/crypto");
353
-
354
- // src/utils.ts
355
- var formatZodError = (error) => {
356
- if (!error.issues || error.issues.length === 0) {
357
- return {};
358
- }
359
- return error.issues.reduce((previous, issue) => {
360
- const key = issue.path.join(".");
361
- return {
362
- ...previous,
363
- [key]: {
364
- code: issue.code,
365
- message: issue.message
366
- }
367
- };
368
- }, {});
369
- };
370
- var createBasicAuthHeader = (username, password) => {
371
- const getUsername = getEnv(username.toUpperCase()) ?? username;
372
- const getPassword = getEnv(password.toUpperCase()) ?? password;
373
- if (!getUsername || !getPassword) {
374
- throw new AuthInternalError("INVALID_OAUTH_CONFIGURATION", "Missing client credentials for OAuth provider configuration.");
375
- }
376
- const credentials = `${getUsername}:${getPassword}`;
377
- return `Basic ${btoa(credentials)}`;
378
- };
379
-
380
- // src/oauth/notion.ts
381
- var notion = (options2) => {
382
- return {
383
- id: "notion",
384
- name: "Notion",
385
- authorize: {
386
- url: "https://api.notion.com/v1/oauth/authorize",
387
- params: {
388
- owner: "user",
389
- scope: "user:read",
390
- responseType: "code"
391
- }
392
- },
393
- accessToken: {
394
- url: "https://api.notion.com/v1/oauth/token",
395
- headers: {
396
- Authorization: createBasicAuthHeader(
397
- options2?.clientId ?? "NOTION_CLIENT_ID",
398
- options2?.clientSecret ?? "NOTION_CLIENT_SECRET"
399
- )
400
- }
401
- },
402
- userInfo: {
403
- url: "https://api.notion.com/v1/users/me",
404
- headers: {
405
- "Notion-Version": "2022-06-28"
406
- }
407
- },
408
- profile(profile) {
409
- return {
410
- sub: profile.id,
411
- name: profile.name,
412
- image: profile.avatar_url ?? "",
413
- email: profile?.bot?.owner?.user?.person?.email
414
- };
415
- },
416
- ...options2
417
- };
418
- };
419
-
420
- // src/oauth/dropbox.ts
421
- var dropbox = (options2) => {
422
- return {
423
- id: "dropbox",
424
- name: "Dropbox",
425
- authorize: {
426
- url: "https://www.dropbox.com/oauth2/authorize",
427
- params: { scope: "account_info.read" }
428
- },
429
- accessToken: "https://api.dropboxapi.com/oauth2/token",
430
- userInfo: {
431
- method: "POST",
432
- url: "https://api.dropboxapi.com/2/users/get_current_account"
433
- },
434
- profile(profile) {
435
- return {
436
- sub: profile.account_id,
437
- name: profile.name.display_name,
438
- email: profile.email,
439
- image: profile.profile_photo_url
440
- };
441
- },
442
- ...options2
443
- };
444
- };
445
-
446
- // src/oauth/atlassian.ts
447
- var atlassian = (options2) => {
448
- return {
449
- id: "atlassian",
450
- name: "Atlassian",
451
- authorize: {
452
- url: "https://auth.atlassian.com/authorize",
453
- params: {
454
- audience: "api.atlassian.com",
455
- scope: "read:me read:account",
456
- prompt: "consent"
457
- }
458
- },
459
- authorizeURL: "https://auth.atlassian.com/authorize",
460
- accessToken: "https://auth.atlassian.com/oauth/token",
461
- userInfo: "https://api.atlassian.com/me",
462
- scope: "read:me read:account",
463
- responseType: "code",
464
- profile(profile) {
465
- return {
466
- sub: profile.account_id,
467
- name: profile.name,
468
- email: profile.email,
469
- image: profile.picture
470
- };
471
- },
472
- ...options2
473
- };
474
- };
475
-
476
- // src/schemas.ts
477
- var import_v4 = require("zod/v4");
478
- var AuthorizeConfigSchema = import_v4.z.union([
479
- (0, import_v4.string)().url(),
480
- (0, import_v4.object)({
481
- url: (0, import_v4.string)().url(),
482
- params: (0, import_v4.object)({
483
- responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
484
- scope: (0, import_v4.string)().optional()
485
- })
486
- })
487
- ]);
488
- var AccessTokenConfigSchema = import_v4.z.union([
489
- (0, import_v4.string)().url(),
490
- (0, import_v4.object)({
491
- url: (0, import_v4.string)().url(),
492
- headers: import_v4.z.record((0, import_v4.string)(), (0, import_v4.string)()).optional()
493
- })
494
- ]);
495
- var UserInfoConfigSchema = import_v4.z.union([
496
- (0, import_v4.string)().url(),
497
- (0, import_v4.object)({
498
- url: (0, import_v4.string)().url(),
499
- headers: import_v4.z.record((0, import_v4.string)(), (0, import_v4.string)()).optional(),
500
- method: (0, import_v4.string)().optional()
501
- })
502
- ]);
503
- var OAuthProviderCredentialsSchema = (0, import_v4.object)({
504
- id: (0, import_v4.string)(),
505
- name: (0, import_v4.string)(),
506
- authorize: AuthorizeConfigSchema.optional(),
507
- /** @deprecated */
508
- authorizeURL: (0, import_v4.string)().url().optional(),
509
- accessToken: AccessTokenConfigSchema,
510
- /** @deprecated */
511
- scope: (0, import_v4.string)().optional(),
512
- userInfo: UserInfoConfigSchema,
513
- /** @deprecated */
514
- responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
515
- clientId: (0, import_v4.string)(),
516
- clientSecret: (0, import_v4.string)(),
517
- profile: import_v4.z.function().optional()
518
- });
519
- var OAuthProviderConfigSchema = (0, import_v4.object)({
520
- authorize: AuthorizeConfigSchema.optional(),
521
- /** @deprecated */
522
- authorizeURL: (0, import_v4.string)().url().optional(),
523
- accessToken: AccessTokenConfigSchema,
524
- /** @deprecated */
525
- scope: (0, import_v4.string)().optional(),
526
- userInfo: UserInfoConfigSchema,
527
- /** @deprecated */
528
- responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
529
- clientId: (0, import_v4.string)(),
530
- clientSecret: (0, import_v4.string)()
531
- });
532
- var OAuthAuthorization = OAuthProviderConfigSchema.extend({
533
- redirectURI: (0, import_v4.string)(),
534
- state: (0, import_v4.string)(),
535
- codeChallenge: (0, import_v4.string)(),
536
- codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
537
- });
538
- var OAuthAuthorizationResponse = (0, import_v4.object)({
539
- state: (0, import_v4.string)({ message: "Missing state parameter in the OAuth authorization response." }),
540
- code: (0, import_v4.string)({ message: "Missing code parameter in the OAuth authorization response." })
541
- });
542
- var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
543
- error: (0, import_v4.enum)([
544
- "invalid_request",
545
- "unauthorized_client",
546
- "access_denied",
547
- "unsupported_response_type",
548
- "invalid_scope",
549
- "server_error",
550
- "temporarily_unavailable"
551
- ]),
552
- error_description: (0, import_v4.string)().optional(),
553
- error_uri: (0, import_v4.string)().optional(),
554
- state: (0, import_v4.string)()
555
- });
556
- var OAuthAccessToken = OAuthProviderConfigSchema.extend({
557
- redirectURI: (0, import_v4.string)(),
558
- code: (0, import_v4.string)(),
559
- codeVerifier: (0, import_v4.string)().min(43).max(128)
560
- });
561
- var OAuthAccessTokenResponse = (0, import_v4.object)({
562
- access_token: (0, import_v4.string)(),
563
- token_type: (0, import_v4.string)().optional(),
564
- expires_in: (0, import_v4.number)().optional(),
565
- refresh_token: (0, import_v4.string)().optional(),
566
- scope: (0, import_v4.union)([(0, import_v4.string)().optional().or((0, import_v4.null)()), (0, import_v4.array)((0, import_v4.string)()).optional()])
567
- });
568
- var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
569
- error: (0, import_v4.enum)([
570
- "invalid_request",
571
- "invalid_client",
572
- "invalid_grant",
573
- "unauthorized_client",
574
- "unsupported_grant_type",
575
- "invalid_scope"
576
- ]),
577
- error_description: (0, import_v4.string)().optional(),
578
- error_uri: (0, import_v4.string)().optional()
579
- });
580
- var OAuthErrorResponse = (0, import_v4.object)({
581
- error: (0, import_v4.string)(),
582
- error_description: (0, import_v4.string)().optional()
583
- });
584
- var OAuthEnvSchema = (0, import_v4.object)({
585
- clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
586
- clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
587
- });
588
-
589
- // src/oauth/index.ts
590
- var builtInOAuthProviders = {
591
- github,
592
- bitbucket,
593
- figma,
594
- discord,
595
- gitlab,
596
- spotify,
597
- x,
598
- strava,
599
- mailchimp,
600
- pinterest,
601
- twitch,
602
- notion,
603
- dropbox,
604
- atlassian
605
- };
606
- var defineOAuthEnvironment = (oauth) => {
607
- const loadEnvs = OAuthEnvSchema.safeParse({
608
- clientId: getEnv(`${oauth.toUpperCase()}_CLIENT_ID`),
609
- clientSecret: getEnv(`${oauth.toUpperCase()}_CLIENT_SECRET`)
610
- });
611
- if (!loadEnvs.success) {
612
- const msg = JSON.stringify({ [oauth]: formatZodError(loadEnvs.error) }, null, 2);
613
- throw new AuthInternalError("INVALID_ENVIRONMENT_CONFIGURATION", msg);
614
- }
615
- return loadEnvs.data;
616
- };
617
- var defineOAuthProviderConfig = (config) => {
618
- if (typeof config === "string") {
619
- const definition = defineOAuthEnvironment(config);
620
- const oauthConfig = builtInOAuthProviders[config]();
621
- const parsed2 = OAuthProviderCredentialsSchema.safeParse({ ...oauthConfig, ...definition });
622
- if (!parsed2.success) {
623
- const details = JSON.stringify({ [config]: formatZodError(parsed2.error) }, null, 2);
624
- throw new AuthInternalError(
625
- "INVALID_OAUTH_PROVIDER_CONFIGURATION",
626
- `Invalid configuration for OAuth provider "${config}": ${details}`
627
- );
628
- }
629
- return parsed2.data;
630
- }
631
- const hasCredentials = config.clientId && config.clientSecret;
632
- const envConfig = hasCredentials ? {} : defineOAuthEnvironment(config.id);
633
- const parsed = OAuthProviderCredentialsSchema.safeParse({ ...envConfig, ...config });
634
- if (!parsed.success) {
635
- const details = JSON.stringify({ [config.id]: formatZodError(parsed.error) }, null, 2);
636
- throw new AuthInternalError(
637
- "INVALID_OAUTH_PROVIDER_CONFIGURATION",
638
- `Invalid configuration for OAuth provider "${config.id}": ${details}`
639
- );
640
- }
641
- return parsed.data;
642
- };
643
- var createBuiltInOAuthProviders = (oauth = []) => {
644
- return oauth.reduce((previous, config) => {
645
- const oauthConfig = defineOAuthProviderConfig(config);
646
- if (oauthConfig.id in previous) {
647
- throw new AuthInternalError(
648
- "DUPLICATED_OAUTH_PROVIDER_ID",
649
- `Duplicate OAuth provider id "${oauthConfig.id}" found. Each provider must have a unique id.`
650
- );
651
- }
652
- return { ...previous, [oauthConfig.id]: oauthConfig };
653
- }, {});
654
- };
655
- // Annotate the CommonJS export names for ESM import in node:
656
- 0 && (module.exports = {
657
- atlassian,
658
- bitbucket,
659
- builtInOAuthProviders,
660
- createBuiltInOAuthProviders,
661
- discord,
662
- dropbox,
663
- figma,
664
- github,
665
- gitlab,
666
- mailchimp,
667
- notion,
668
- pinterest,
669
- spotify,
670
- strava,
671
- twitch,
672
- x
673
- });
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../oauth-BntNm6aE.cjs`),t=require(`./github.cjs`),n=require(`./bitbucket.cjs`),r=require(`./figma.cjs`),i=require(`./discord.cjs`),a=require(`./gitlab.cjs`),o=require(`./spotify.cjs`),s=require(`./x.cjs`),c=require(`./strava.cjs`),l=require(`./mailchimp.cjs`),u=require(`./pinterest.cjs`),d=require(`./twitch.cjs`),f=require(`./notion.cjs`),p=require(`./dropbox.cjs`),m=require(`./atlassian.cjs`);exports.atlassian=m.atlassian,exports.bitbucket=n.bitbucket,exports.builtInOAuthProviders=e.t,exports.createBuiltInOAuthProviders=e.n,exports.discord=i.discord,exports.dropbox=p.dropbox,exports.figma=r.figma,exports.github=t.github,exports.gitlab=a.gitlab,exports.mailchimp=l.mailchimp,exports.notion=f.notion,exports.pinterest=u.pinterest,exports.spotify=o.spotify,exports.strava=c.strava,exports.twitch=d.twitch,exports.x=s.x;
@@ -1,12 +1,2 @@
1
- export { W as AccountType, P as AtlassianProfile, at as BitbucketProfile, a0 as Bot, B as BuiltInOAuthProvider, ao as DiscordProfile, X as DropboxProfile, Q as ExtendedProfile, ar as FigmaProfile, Y as FullTeam, av as GitHubProfile, am as GitLabProfile, aa as Login, ab as MailchimpProfile, Z as Name, ap as Nameplate, a1 as NotionProfile, a2 as Owner, a3 as Person, a8 as PinterestProfile, _ as RootInfo, aj as SpotifyImage, ak as SpotifyProfile, ad as StravaProfile, ae as SummaryClub, af as SummaryGear, a6 as TwitchProfile, a4 as User, ah as XProfile, V as atlassian, au as bitbucket, v as builtInOAuthProviders, ax as createBuiltInOAuthProviders, aq as discord, $ as dropbox, as as figma, aw as github, an as gitlab, ac as mailchimp, a5 as notion, a9 as pinterest, al as spotify, ag as strava, a7 as twitch, ai as x } from '../index-_aXtxb_s.js';
2
- import '../@types/utility.js';
3
- import 'zod';
4
- import '../schemas.js';
5
- import 'zod/v4';
6
- import '@aura-stack/jose';
7
- import '@aura-stack/jose/jose';
8
- import '@aura-stack/jose/crypto';
9
- import '@aura-stack/router/cookie';
10
- import 'jose';
11
- import '@aura-stack/router';
12
- import 'zod/v4/core';
1
+ import { $t as atlassian, An as DiscordProfile, Cn as XProfile, Dn as spotify, En as SpotifyProfile, Fn as BitbucketProfile, In as bitbucket, Jt as BuiltInOAuthProvider, Ln as GitHubProfile, Mn as discord, Nn as FigmaProfile, On as GitLabProfile, Pn as figma, Qt as ExtendedProfile, Rn as github, Sn as strava, Tn as SpotifyImage, Xt as createBuiltInOAuthProviders, Yt as builtInOAuthProviders, Zt as AtlassianProfile, _n as MailchimpProfile, an as dropbox, bn as SummaryClub, cn as NotionUser, dn as notion, en as AccountType, fn as TwitchProfile, gn as Login, hn as pinterest, in as RootInfo, jn as Nameplate, kn as gitlab, ln as Owner, mn as PinterestProfile, nn as FullTeam, on as Bot, pn as twitch, rn as Name, sn as NotionProfile, tn as DropboxProfile, un as Person, vn as mailchimp, wn as x, xn as SummaryGear, yn as StravaProfile } from "../index-nqLV2t91.js";
2
+ export { AccountType, AtlassianProfile, BitbucketProfile, Bot, BuiltInOAuthProvider, DiscordProfile, DropboxProfile, ExtendedProfile, FigmaProfile, FullTeam, GitHubProfile, GitLabProfile, Login, MailchimpProfile, Name, Nameplate, NotionProfile, NotionUser, Owner, Person, PinterestProfile, RootInfo, SpotifyImage, SpotifyProfile, StravaProfile, SummaryClub, SummaryGear, TwitchProfile, XProfile, atlassian, bitbucket, builtInOAuthProviders, createBuiltInOAuthProviders, discord, dropbox, figma, github, gitlab, mailchimp, notion, pinterest, spotify, strava, twitch, x };