@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.
- package/README.md +36 -1
- package/dist/@types/index.cjs +0 -18
- package/dist/@types/index.d.ts +2 -8
- package/dist/@types/index.js +0 -1
- package/dist/assert-B3iQSYlK.js +3 -0
- package/dist/assert-NJGroSJd.cjs +3 -0
- package/dist/client/index.cjs +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.js +1 -0
- package/dist/crypto-Bz8nIciY.js +1 -0
- package/dist/crypto-CoXA5w_4.cjs +1 -0
- package/dist/env-bq387KyP.cjs +1 -0
- package/dist/env-nvh8QBNz.js +1 -0
- package/dist/errors-CCYPHuBO.cjs +1 -0
- package/dist/errors-DFWHOho6.js +1 -0
- package/dist/index-BkpwQ0l4.d.cts +2279 -0
- package/dist/index-nqLV2t91.d.ts +2279 -0
- package/dist/index.cjs +1 -1839
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -35
- package/dist/index.js +1 -132
- package/dist/logger-C59_CDMk.js +1 -0
- package/dist/logger-UnUhYL2V.cjs +1 -0
- package/dist/oauth/atlassian.cjs +1 -0
- package/dist/oauth/atlassian.d.ts +2 -0
- package/dist/oauth/atlassian.js +1 -0
- package/dist/oauth/bitbucket.cjs +1 -49
- package/dist/oauth/bitbucket.d.ts +2 -8
- package/dist/oauth/bitbucket.js +1 -6
- package/dist/oauth/discord.cjs +1 -57
- package/dist/oauth/discord.d.ts +2 -8
- package/dist/oauth/discord.js +1 -6
- package/dist/oauth/dropbox.cjs +1 -0
- package/dist/oauth/dropbox.d.ts +2 -0
- package/dist/oauth/dropbox.js +1 -0
- package/dist/oauth/figma.cjs +1 -49
- package/dist/oauth/figma.d.ts +2 -8
- package/dist/oauth/figma.js +1 -6
- package/dist/oauth/github.cjs +1 -49
- package/dist/oauth/github.d.ts +2 -8
- package/dist/oauth/github.js +1 -6
- package/dist/oauth/gitlab.cjs +1 -49
- package/dist/oauth/gitlab.d.ts +2 -8
- package/dist/oauth/gitlab.js +1 -6
- package/dist/oauth/index.cjs +1 -483
- package/dist/oauth/index.d.ts +2 -8
- package/dist/oauth/index.js +1 -52
- package/dist/oauth/mailchimp.cjs +1 -49
- package/dist/oauth/mailchimp.d.ts +2 -8
- package/dist/oauth/mailchimp.js +1 -6
- package/dist/oauth/notion.cjs +1 -0
- package/dist/oauth/notion.d.ts +2 -0
- package/dist/oauth/notion.js +1 -0
- package/dist/oauth/pinterest.cjs +1 -49
- package/dist/oauth/pinterest.d.ts +2 -8
- package/dist/oauth/pinterest.js +1 -6
- package/dist/oauth/spotify.cjs +1 -49
- package/dist/oauth/spotify.d.ts +2 -8
- package/dist/oauth/spotify.js +1 -6
- package/dist/oauth/strava.cjs +1 -49
- package/dist/oauth/strava.d.ts +2 -8
- package/dist/oauth/strava.js +1 -6
- package/dist/oauth/twitch.cjs +1 -0
- package/dist/oauth/twitch.d.ts +2 -0
- package/dist/oauth/twitch.js +1 -0
- package/dist/oauth/x.cjs +1 -49
- package/dist/oauth/x.d.ts +2 -8
- package/dist/oauth/x.js +1 -6
- package/dist/oauth-BntNm6aE.cjs +1 -0
- package/dist/oauth-DmHy9VrB.js +1 -0
- package/dist/shared/crypto.cjs +1 -0
- package/dist/shared/crypto.d.ts +47 -0
- package/dist/shared/crypto.js +1 -0
- package/dist/shared/identity.cjs +1 -0
- package/dist/shared/identity.d.ts +2 -0
- package/dist/shared/identity.js +1 -0
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +1 -0
- package/package.json +39 -12
- package/dist/@types/router.d.cjs +0 -1
- package/dist/@types/router.d.d.ts +0 -12
- package/dist/@types/router.d.js +0 -0
- package/dist/@types/utility.cjs +0 -18
- package/dist/@types/utility.d.ts +0 -6
- package/dist/@types/utility.js +0 -1
- package/dist/actions/callback/access-token.cjs +0 -206
- package/dist/actions/callback/access-token.d.ts +0 -29
- package/dist/actions/callback/access-token.js +0 -9
- package/dist/actions/callback/callback.cjs +0 -649
- package/dist/actions/callback/callback.d.ts +0 -13
- package/dist/actions/callback/callback.js +0 -19
- package/dist/actions/callback/userinfo.cjs +0 -250
- package/dist/actions/callback/userinfo.d.ts +0 -21
- package/dist/actions/callback/userinfo.js +0 -14
- package/dist/actions/csrfToken/csrfToken.cjs +0 -197
- package/dist/actions/csrfToken/csrfToken.d.ts +0 -5
- package/dist/actions/csrfToken/csrfToken.js +0 -14
- package/dist/actions/index.cjs +0 -954
- package/dist/actions/index.d.ts +0 -14
- package/dist/actions/index.js +0 -36
- package/dist/actions/session/session.cjs +0 -136
- package/dist/actions/session/session.d.ts +0 -5
- package/dist/actions/session/session.js +0 -10
- package/dist/actions/signIn/authorization.cjs +0 -322
- package/dist/actions/signIn/authorization.d.ts +0 -53
- package/dist/actions/signIn/authorization.js +0 -18
- package/dist/actions/signIn/signIn.cjs +0 -467
- package/dist/actions/signIn/signIn.d.ts +0 -13
- package/dist/actions/signIn/signIn.js +0 -15
- package/dist/actions/signOut/signOut.cjs +0 -493
- package/dist/actions/signOut/signOut.d.ts +0 -8
- package/dist/actions/signOut/signOut.js +0 -16
- package/dist/assert.cjs +0 -161
- package/dist/assert.d.ts +0 -33
- package/dist/assert.js +0 -26
- package/dist/chunk-4EKY7655.js +0 -123
- package/dist/chunk-4MYWAOLG.js +0 -31
- package/dist/chunk-4YHJ4IEQ.js +0 -25
- package/dist/chunk-54CZPKR4.js +0 -25
- package/dist/chunk-5LZ7TOM3.js +0 -25
- package/dist/chunk-5W4BRQYG.js +0 -201
- package/dist/chunk-6MXFPFR3.js +0 -143
- package/dist/chunk-7QF22LHP.js +0 -67
- package/dist/chunk-ALG3GIV4.js +0 -95
- package/dist/chunk-E6G5YCI6.js +0 -25
- package/dist/chunk-EBAMFRB7.js +0 -34
- package/dist/chunk-EEE7UM5T.js +0 -25
- package/dist/chunk-FRJFWTOY.js +0 -70
- package/dist/chunk-FW4W3REU.js +0 -25
- package/dist/chunk-ICAZ4OVS.js +0 -37
- package/dist/chunk-IPKO6UQN.js +0 -25
- package/dist/chunk-ITQ7352M.js +0 -0
- package/dist/chunk-KJBAQZX2.js +0 -92
- package/dist/chunk-KMMAZFSJ.js +0 -25
- package/dist/chunk-LDU7A2JE.js +0 -25
- package/dist/chunk-NUDITUKX.js +0 -73
- package/dist/chunk-OVHNRULD.js +0 -33
- package/dist/chunk-PG7UYFG5.js +0 -0
- package/dist/chunk-PHFH2MGS.js +0 -36
- package/dist/chunk-QQVSRXGX.js +0 -149
- package/dist/chunk-RRLIF4PQ.js +0 -55
- package/dist/chunk-TM5IPSNF.js +0 -113
- package/dist/chunk-TZB6MUXN.js +0 -78
- package/dist/chunk-VNCNJKS2.js +0 -267
- package/dist/chunk-XGLBNXL4.js +0 -75
- package/dist/chunk-XUP6KKNG.js +0 -106
- package/dist/chunk-ZNCZVF6U.js +0 -14
- package/dist/cookie.cjs +0 -246
- package/dist/cookie.d.ts +0 -85
- package/dist/cookie.js +0 -29
- package/dist/env.cjs +0 -56
- package/dist/env.d.ts +0 -7
- package/dist/env.js +0 -6
- package/dist/errors.cjs +0 -85
- package/dist/errors.d.ts +0 -50
- package/dist/errors.js +0 -18
- package/dist/headers.cjs +0 -61
- package/dist/headers.d.ts +0 -33
- package/dist/headers.js +0 -12
- package/dist/index-CSyIJmCM.d.ts +0 -1007
- package/dist/jose.cjs +0 -128
- package/dist/jose.d.ts +0 -25
- package/dist/jose.js +0 -12
- package/dist/logger.cjs +0 -292
- package/dist/logger.d.ts +0 -8
- package/dist/logger.js +0 -8
- package/dist/request.cjs +0 -38
- package/dist/request.d.ts +0 -13
- package/dist/request.js +0 -6
- package/dist/schemas.cjs +0 -125
- package/dist/schemas.d.ts +0 -149
- package/dist/schemas.js +0 -24
- package/dist/secure.cjs +0 -170
- package/dist/secure.d.ts +0 -35
- package/dist/secure.js +0 -19
- package/dist/utils.cjs +0 -223
- package/dist/utils.d.ts +0 -24
- 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 };
|