@aura-stack/auth 0.4.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 (179) hide show
  1. package/README.md +36 -1
  2. package/dist/@types/index.cjs +0 -18
  3. package/dist/@types/index.d.ts +2 -8
  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 -0
  8. package/dist/client/index.d.ts +11 -0
  9. package/dist/client/index.js +1 -0
  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 -1839
  19. package/dist/index.d.cts +2 -0
  20. package/dist/index.d.ts +2 -35
  21. package/dist/index.js +1 -132
  22. package/dist/logger-C59_CDMk.js +1 -0
  23. package/dist/logger-UnUhYL2V.cjs +1 -0
  24. package/dist/oauth/atlassian.cjs +1 -0
  25. package/dist/oauth/atlassian.d.ts +2 -0
  26. package/dist/oauth/atlassian.js +1 -0
  27. package/dist/oauth/bitbucket.cjs +1 -49
  28. package/dist/oauth/bitbucket.d.ts +2 -8
  29. package/dist/oauth/bitbucket.js +1 -6
  30. package/dist/oauth/discord.cjs +1 -57
  31. package/dist/oauth/discord.d.ts +2 -8
  32. package/dist/oauth/discord.js +1 -6
  33. package/dist/oauth/dropbox.cjs +1 -0
  34. package/dist/oauth/dropbox.d.ts +2 -0
  35. package/dist/oauth/dropbox.js +1 -0
  36. package/dist/oauth/figma.cjs +1 -49
  37. package/dist/oauth/figma.d.ts +2 -8
  38. package/dist/oauth/figma.js +1 -6
  39. package/dist/oauth/github.cjs +1 -49
  40. package/dist/oauth/github.d.ts +2 -8
  41. package/dist/oauth/github.js +1 -6
  42. package/dist/oauth/gitlab.cjs +1 -49
  43. package/dist/oauth/gitlab.d.ts +2 -8
  44. package/dist/oauth/gitlab.js +1 -6
  45. package/dist/oauth/index.cjs +1 -483
  46. package/dist/oauth/index.d.ts +2 -8
  47. package/dist/oauth/index.js +1 -52
  48. package/dist/oauth/mailchimp.cjs +1 -49
  49. package/dist/oauth/mailchimp.d.ts +2 -8
  50. package/dist/oauth/mailchimp.js +1 -6
  51. package/dist/oauth/notion.cjs +1 -0
  52. package/dist/oauth/notion.d.ts +2 -0
  53. package/dist/oauth/notion.js +1 -0
  54. package/dist/oauth/pinterest.cjs +1 -49
  55. package/dist/oauth/pinterest.d.ts +2 -8
  56. package/dist/oauth/pinterest.js +1 -6
  57. package/dist/oauth/spotify.cjs +1 -49
  58. package/dist/oauth/spotify.d.ts +2 -8
  59. package/dist/oauth/spotify.js +1 -6
  60. package/dist/oauth/strava.cjs +1 -49
  61. package/dist/oauth/strava.d.ts +2 -8
  62. package/dist/oauth/strava.js +1 -6
  63. package/dist/oauth/twitch.cjs +1 -0
  64. package/dist/oauth/twitch.d.ts +2 -0
  65. package/dist/oauth/twitch.js +1 -0
  66. package/dist/oauth/x.cjs +1 -49
  67. package/dist/oauth/x.d.ts +2 -8
  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 +39 -12
  81. package/dist/@types/router.d.cjs +0 -1
  82. package/dist/@types/router.d.d.ts +0 -12
  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 -206
  88. package/dist/actions/callback/access-token.d.ts +0 -29
  89. package/dist/actions/callback/access-token.js +0 -9
  90. package/dist/actions/callback/callback.cjs +0 -649
  91. package/dist/actions/callback/callback.d.ts +0 -13
  92. package/dist/actions/callback/callback.js +0 -19
  93. package/dist/actions/callback/userinfo.cjs +0 -250
  94. package/dist/actions/callback/userinfo.d.ts +0 -21
  95. package/dist/actions/callback/userinfo.js +0 -14
  96. package/dist/actions/csrfToken/csrfToken.cjs +0 -197
  97. package/dist/actions/csrfToken/csrfToken.d.ts +0 -5
  98. package/dist/actions/csrfToken/csrfToken.js +0 -14
  99. package/dist/actions/index.cjs +0 -954
  100. package/dist/actions/index.d.ts +0 -14
  101. package/dist/actions/index.js +0 -36
  102. package/dist/actions/session/session.cjs +0 -136
  103. package/dist/actions/session/session.d.ts +0 -5
  104. package/dist/actions/session/session.js +0 -10
  105. package/dist/actions/signIn/authorization.cjs +0 -322
  106. package/dist/actions/signIn/authorization.d.ts +0 -53
  107. package/dist/actions/signIn/authorization.js +0 -18
  108. package/dist/actions/signIn/signIn.cjs +0 -467
  109. package/dist/actions/signIn/signIn.d.ts +0 -13
  110. package/dist/actions/signIn/signIn.js +0 -15
  111. package/dist/actions/signOut/signOut.cjs +0 -493
  112. package/dist/actions/signOut/signOut.d.ts +0 -8
  113. package/dist/actions/signOut/signOut.js +0 -16
  114. package/dist/assert.cjs +0 -161
  115. package/dist/assert.d.ts +0 -33
  116. package/dist/assert.js +0 -26
  117. package/dist/chunk-4EKY7655.js +0 -123
  118. package/dist/chunk-4MYWAOLG.js +0 -31
  119. package/dist/chunk-4YHJ4IEQ.js +0 -25
  120. package/dist/chunk-54CZPKR4.js +0 -25
  121. package/dist/chunk-5LZ7TOM3.js +0 -25
  122. package/dist/chunk-5W4BRQYG.js +0 -201
  123. package/dist/chunk-6MXFPFR3.js +0 -143
  124. package/dist/chunk-7QF22LHP.js +0 -67
  125. package/dist/chunk-ALG3GIV4.js +0 -95
  126. package/dist/chunk-E6G5YCI6.js +0 -25
  127. package/dist/chunk-EBAMFRB7.js +0 -34
  128. package/dist/chunk-EEE7UM5T.js +0 -25
  129. package/dist/chunk-FRJFWTOY.js +0 -70
  130. package/dist/chunk-FW4W3REU.js +0 -25
  131. package/dist/chunk-ICAZ4OVS.js +0 -37
  132. package/dist/chunk-IPKO6UQN.js +0 -25
  133. package/dist/chunk-ITQ7352M.js +0 -0
  134. package/dist/chunk-KJBAQZX2.js +0 -92
  135. package/dist/chunk-KMMAZFSJ.js +0 -25
  136. package/dist/chunk-LDU7A2JE.js +0 -25
  137. package/dist/chunk-NUDITUKX.js +0 -73
  138. package/dist/chunk-OVHNRULD.js +0 -33
  139. package/dist/chunk-PG7UYFG5.js +0 -0
  140. package/dist/chunk-PHFH2MGS.js +0 -36
  141. package/dist/chunk-QQVSRXGX.js +0 -149
  142. package/dist/chunk-RRLIF4PQ.js +0 -55
  143. package/dist/chunk-TM5IPSNF.js +0 -113
  144. package/dist/chunk-TZB6MUXN.js +0 -78
  145. package/dist/chunk-VNCNJKS2.js +0 -267
  146. package/dist/chunk-XGLBNXL4.js +0 -75
  147. package/dist/chunk-XUP6KKNG.js +0 -106
  148. package/dist/chunk-ZNCZVF6U.js +0 -14
  149. package/dist/cookie.cjs +0 -246
  150. package/dist/cookie.d.ts +0 -85
  151. package/dist/cookie.js +0 -29
  152. package/dist/env.cjs +0 -56
  153. package/dist/env.d.ts +0 -7
  154. package/dist/env.js +0 -6
  155. package/dist/errors.cjs +0 -85
  156. package/dist/errors.d.ts +0 -50
  157. package/dist/errors.js +0 -18
  158. package/dist/headers.cjs +0 -61
  159. package/dist/headers.d.ts +0 -33
  160. package/dist/headers.js +0 -12
  161. package/dist/index-CSyIJmCM.d.ts +0 -1007
  162. package/dist/jose.cjs +0 -128
  163. package/dist/jose.d.ts +0 -25
  164. package/dist/jose.js +0 -12
  165. package/dist/logger.cjs +0 -292
  166. package/dist/logger.d.ts +0 -8
  167. package/dist/logger.js +0 -8
  168. package/dist/request.cjs +0 -38
  169. package/dist/request.d.ts +0 -13
  170. package/dist/request.js +0 -6
  171. package/dist/schemas.cjs +0 -125
  172. package/dist/schemas.d.ts +0 -149
  173. package/dist/schemas.js +0 -24
  174. package/dist/secure.cjs +0 -170
  175. package/dist/secure.d.ts +0 -35
  176. package/dist/secure.js +0 -19
  177. package/dist/utils.cjs +0 -223
  178. package/dist/utils.d.ts +0 -24
  179. package/dist/utils.js +0 -29
@@ -1,206 +0,0 @@
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/actions/callback/access-token.ts
21
- var access_token_exports = {};
22
- __export(access_token_exports, {
23
- createAccessToken: () => createAccessToken
24
- });
25
- module.exports = __toCommonJS(access_token_exports);
26
-
27
- // src/request.ts
28
- var fetchAsync = async (url, options2 = {}, timeout = 5e3) => {
29
- const controller = new AbortController();
30
- const timeoutId = setTimeout(() => controller.abort(), timeout);
31
- const response = await fetch(url, {
32
- ...options2,
33
- signal: controller.signal
34
- }).finally(() => clearTimeout(timeoutId));
35
- return response;
36
- };
37
-
38
- // src/errors.ts
39
- var OAuthProtocolError = class extends Error {
40
- type = "OAUTH_PROTOCOL_ERROR";
41
- error;
42
- errorURI;
43
- constructor(error, description, errorURI, options2) {
44
- super(description, options2);
45
- this.error = error;
46
- this.errorURI = errorURI;
47
- this.name = new.target.name;
48
- Error.captureStackTrace(this, new.target);
49
- }
50
- };
51
- var AuthInternalError = class extends Error {
52
- type = "AUTH_INTERNAL_ERROR";
53
- code;
54
- constructor(code, message, options2) {
55
- super(message, options2);
56
- this.code = code;
57
- this.name = new.target.name;
58
- Error.captureStackTrace(this, new.target);
59
- }
60
- };
61
-
62
- // src/schemas.ts
63
- var import_zod = require("zod");
64
- var OAuthProviderCredentialsSchema = (0, import_zod.object)({
65
- id: (0, import_zod.string)(),
66
- name: (0, import_zod.string)(),
67
- authorizeURL: (0, import_zod.string)().url(),
68
- accessToken: (0, import_zod.string)().url(),
69
- scope: (0, import_zod.string)(),
70
- userInfo: (0, import_zod.string)().url(),
71
- responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
72
- clientId: (0, import_zod.string)(),
73
- clientSecret: (0, import_zod.string)(),
74
- profile: import_zod.z.function().optional()
75
- });
76
- var OAuthProviderConfigSchema = (0, import_zod.object)({
77
- authorizeURL: (0, import_zod.string)().url(),
78
- accessToken: (0, import_zod.string)().url(),
79
- scope: (0, import_zod.string)().optional(),
80
- userInfo: (0, import_zod.string)().url(),
81
- responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
82
- clientId: (0, import_zod.string)(),
83
- clientSecret: (0, import_zod.string)()
84
- });
85
- var OAuthAuthorization = OAuthProviderConfigSchema.extend({
86
- redirectURI: (0, import_zod.string)(),
87
- state: (0, import_zod.string)(),
88
- codeChallenge: (0, import_zod.string)(),
89
- codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
90
- });
91
- var OAuthAuthorizationResponse = (0, import_zod.object)({
92
- state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
93
- code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
94
- });
95
- var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
96
- error: (0, import_zod.enum)([
97
- "invalid_request",
98
- "unauthorized_client",
99
- "access_denied",
100
- "unsupported_response_type",
101
- "invalid_scope",
102
- "server_error",
103
- "temporarily_unavailable"
104
- ]),
105
- error_description: (0, import_zod.string)().optional(),
106
- error_uri: (0, import_zod.string)().optional(),
107
- state: (0, import_zod.string)()
108
- });
109
- var OAuthAccessToken = OAuthProviderConfigSchema.extend({
110
- redirectURI: (0, import_zod.string)(),
111
- code: (0, import_zod.string)(),
112
- codeVerifier: (0, import_zod.string)().min(43).max(128)
113
- });
114
- var OAuthAccessTokenResponse = (0, import_zod.object)({
115
- access_token: (0, import_zod.string)(),
116
- token_type: (0, import_zod.string)().optional(),
117
- expires_in: (0, import_zod.number)().optional(),
118
- refresh_token: (0, import_zod.string)().optional(),
119
- scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
120
- });
121
- var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
122
- error: (0, import_zod.enum)([
123
- "invalid_request",
124
- "invalid_client",
125
- "invalid_grant",
126
- "unauthorized_client",
127
- "unsupported_grant_type",
128
- "invalid_scope"
129
- ]),
130
- error_description: (0, import_zod.string)().optional(),
131
- error_uri: (0, import_zod.string)().optional()
132
- });
133
- var OAuthErrorResponse = (0, import_zod.object)({
134
- error: (0, import_zod.string)(),
135
- error_description: (0, import_zod.string)().optional()
136
- });
137
- var OAuthEnvSchema = (0, import_zod.object)({
138
- clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
139
- clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
140
- });
141
-
142
- // src/actions/callback/access-token.ts
143
- var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier, logger) => {
144
- const parsed = OAuthAccessToken.safeParse({ ...oauthConfig, redirectURI, code, codeVerifier });
145
- if (!parsed.success) {
146
- logger?.log("INVALID_OAUTH_CONFIGURATION");
147
- throw new AuthInternalError("INVALID_OAUTH_CONFIGURATION", "The OAuth provider configuration is invalid.");
148
- }
149
- const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
150
- try {
151
- logger?.log("OAUTH_ACCESS_TOKEN_REQUEST_INITIATED", {
152
- structuredData: {
153
- has_client_id: Boolean(clientId),
154
- redirect_uri: redirectParsed,
155
- grant_type: "authorization_code"
156
- }
157
- });
158
- const response = await fetchAsync(accessToken, {
159
- method: "POST",
160
- headers: {
161
- Accept: "application/json",
162
- "Content-Type": "application/x-www-form-urlencoded"
163
- },
164
- body: new URLSearchParams({
165
- client_id: clientId,
166
- client_secret: clientSecret,
167
- code: codeParsed,
168
- redirect_uri: redirectParsed,
169
- grant_type: "authorization_code",
170
- code_verifier: codeVerifier
171
- }).toString()
172
- });
173
- if (!response.ok) {
174
- logger?.log("INVALID_OAUTH_ACCESS_TOKEN_RESPONSE");
175
- throw new OAuthProtocolError("invalid_request", "Invalid access token response");
176
- }
177
- const json = await response.json();
178
- const token = OAuthAccessTokenResponse.safeParse(json);
179
- if (!token.success) {
180
- const { success, data } = OAuthAccessTokenErrorResponse.safeParse(json);
181
- if (!success) {
182
- logger?.log("INVALID_OAUTH_ACCESS_TOKEN_RESPONSE");
183
- throw new OAuthProtocolError("invalid_request", "Invalid access token response format");
184
- }
185
- logger?.log("OAUTH_ACCESS_TOKEN_ERROR", {
186
- structuredData: {
187
- error: data.error,
188
- error_description: data.error_description ?? ""
189
- }
190
- });
191
- throw new OAuthProtocolError("INVALID_ACCESS_TOKEN", "Failed to retrieve access token");
192
- }
193
- logger?.log("OAUTH_ACCESS_TOKEN_SUCCESS");
194
- return token.data;
195
- } catch (error) {
196
- logger?.log("OAUTH_ACCESS_TOKEN_REQUEST_FAILED");
197
- if (error instanceof Error) {
198
- throw new OAuthProtocolError("server_error", "Failed to communicate with OAuth provider", "", { cause: error });
199
- }
200
- throw error;
201
- }
202
- };
203
- // Annotate the CommonJS export names for ESM import in node:
204
- 0 && (module.exports = {
205
- createAccessToken
206
- });
@@ -1,29 +0,0 @@
1
- import { h as OAuthProviderCredentials, I as InternalLogger } from '../../index-CSyIJmCM.js';
2
- import 'zod';
3
- import '../../schemas.js';
4
- import '../../jose.js';
5
- import '@aura-stack/jose';
6
- import '@aura-stack/jose/jose';
7
- import '@aura-stack/router/cookie';
8
- import '../../@types/utility.js';
9
-
10
- /**
11
- * Make a request to the OAuth provider to the token endpoint to exchange the authorization code provided
12
- * by the authorization server.
13
- *
14
- * @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
15
- * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5
16
- * @param oauthConfig - OAuth provider configuration
17
- * @param redirectURI - The redirect URI registered in the Resource Owner's authorization request and sent in the authorization code exchange
18
- * @param code - The authorization code received from the OAuth server
19
- * @returns The access token response from the OAuth server
20
- */
21
- declare const createAccessToken: (oauthConfig: OAuthProviderCredentials, redirectURI: string, code: string, codeVerifier: string, logger?: InternalLogger) => Promise<{
22
- access_token: string;
23
- token_type?: string | undefined;
24
- expires_in?: number | undefined;
25
- refresh_token?: string | undefined;
26
- scope?: string | null | undefined;
27
- }>;
28
-
29
- export { createAccessToken };
@@ -1,9 +0,0 @@
1
- import {
2
- createAccessToken
3
- } from "../../chunk-TZB6MUXN.js";
4
- import "../../chunk-ZNCZVF6U.js";
5
- import "../../chunk-KJBAQZX2.js";
6
- import "../../chunk-RRLIF4PQ.js";
7
- export {
8
- createAccessToken
9
- };