@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,467 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/actions/signIn/signIn.ts
|
|
31
|
-
var signIn_exports = {};
|
|
32
|
-
__export(signIn_exports, {
|
|
33
|
-
signInAction: () => signInAction
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(signIn_exports);
|
|
36
|
-
var import_zod2 = require("zod");
|
|
37
|
-
var import_router2 = require("@aura-stack/router");
|
|
38
|
-
|
|
39
|
-
// src/headers.ts
|
|
40
|
-
var cacheControl = {
|
|
41
|
-
"Cache-Control": "no-store",
|
|
42
|
-
Pragma: "no-cache",
|
|
43
|
-
Expires: "0",
|
|
44
|
-
Vary: "Cookie"
|
|
45
|
-
};
|
|
46
|
-
var contentSecurityPolicy = {
|
|
47
|
-
"Content-Security-Policy": [
|
|
48
|
-
"default-src 'none'",
|
|
49
|
-
"script-src 'self'",
|
|
50
|
-
"frame-src 'none'",
|
|
51
|
-
"object-src 'none'",
|
|
52
|
-
"frame-ancestors 'none'",
|
|
53
|
-
"base-uri 'none'"
|
|
54
|
-
].join("; ")
|
|
55
|
-
};
|
|
56
|
-
var secureHeaders = {
|
|
57
|
-
"X-Content-Type-Options": "nosniff",
|
|
58
|
-
"X-Frame-Options": "DENY",
|
|
59
|
-
"Referrer-Policy": "strict-origin-when-cross-origin"
|
|
60
|
-
};
|
|
61
|
-
var secureApiHeaders = {
|
|
62
|
-
...cacheControl,
|
|
63
|
-
...contentSecurityPolicy,
|
|
64
|
-
...secureHeaders
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// src/secure.ts
|
|
68
|
-
var import_crypto = __toESM(require("crypto"), 1);
|
|
69
|
-
|
|
70
|
-
// src/utils.ts
|
|
71
|
-
var import_router = require("@aura-stack/router");
|
|
72
|
-
|
|
73
|
-
// src/errors.ts
|
|
74
|
-
var AuthInternalError = class extends Error {
|
|
75
|
-
type = "AUTH_INTERNAL_ERROR";
|
|
76
|
-
code;
|
|
77
|
-
constructor(code, message, options2) {
|
|
78
|
-
super(message, options2);
|
|
79
|
-
this.code = code;
|
|
80
|
-
this.name = new.target.name;
|
|
81
|
-
Error.captureStackTrace(this, new.target);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
var AuthSecurityError = class extends Error {
|
|
85
|
-
type = "AUTH_SECURITY_ERROR";
|
|
86
|
-
code;
|
|
87
|
-
constructor(code, message, options2) {
|
|
88
|
-
super(message, options2);
|
|
89
|
-
this.code = code;
|
|
90
|
-
this.name = new.target.name;
|
|
91
|
-
Error.captureStackTrace(this, new.target);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// src/utils.ts
|
|
96
|
-
var toSnakeCase = (str) => {
|
|
97
|
-
return str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/^_+/, "");
|
|
98
|
-
};
|
|
99
|
-
var toUpperCase = (str) => {
|
|
100
|
-
return str.toUpperCase();
|
|
101
|
-
};
|
|
102
|
-
var toCastCase = (obj, type = "snake") => {
|
|
103
|
-
return Object.entries(obj).reduce((previous, [key, value]) => {
|
|
104
|
-
const newKey = type === "snake" ? toSnakeCase(key) : toUpperCase(key);
|
|
105
|
-
return { ...previous, [newKey]: value };
|
|
106
|
-
}, {});
|
|
107
|
-
};
|
|
108
|
-
var equals = (a, b) => {
|
|
109
|
-
if (a === null || b === null || a === void 0 || b === void 0) return false;
|
|
110
|
-
return a === b;
|
|
111
|
-
};
|
|
112
|
-
var extractPath = (url) => {
|
|
113
|
-
const pathRegex = /^https?:\/\/[a-zA-Z0-9_\-\.]+(:\d+)?(\/.*)$/;
|
|
114
|
-
const match = url.match(pathRegex);
|
|
115
|
-
return match && match[2] ? match[2] : "/";
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// src/assert.ts
|
|
119
|
-
var unsafeChars = [
|
|
120
|
-
"<",
|
|
121
|
-
">",
|
|
122
|
-
'"',
|
|
123
|
-
"`",
|
|
124
|
-
" ",
|
|
125
|
-
"\r",
|
|
126
|
-
"\n",
|
|
127
|
-
" ",
|
|
128
|
-
"\\",
|
|
129
|
-
"%2F",
|
|
130
|
-
"%5C",
|
|
131
|
-
"%2f",
|
|
132
|
-
"%5c",
|
|
133
|
-
"\r\n",
|
|
134
|
-
"%0A",
|
|
135
|
-
"%0D",
|
|
136
|
-
"%0a",
|
|
137
|
-
"%0d",
|
|
138
|
-
"..",
|
|
139
|
-
"//",
|
|
140
|
-
"///",
|
|
141
|
-
"...",
|
|
142
|
-
"%20",
|
|
143
|
-
"\0"
|
|
144
|
-
];
|
|
145
|
-
var isValidURL = (value) => {
|
|
146
|
-
if (!new RegExp(/^https?:\/\/[^/]/).test(value)) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
const match = value.match(/^(https?:\/\/)(.*)$/);
|
|
150
|
-
if (!match) return false;
|
|
151
|
-
const rest = match[2];
|
|
152
|
-
for (const char of unsafeChars) {
|
|
153
|
-
if (rest.includes(char)) return false;
|
|
154
|
-
}
|
|
155
|
-
const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()?#*+,;=:@-]*)*\/?$/;
|
|
156
|
-
return regex.test(match[0]);
|
|
157
|
-
};
|
|
158
|
-
var isRelativeURL = (value) => {
|
|
159
|
-
if (value.length > 100) return false;
|
|
160
|
-
for (const char of unsafeChars) {
|
|
161
|
-
if (value.includes(char)) return false;
|
|
162
|
-
}
|
|
163
|
-
const regex = /^\/[a-zA-Z0-9\-_\/.?&=#]*\/?$/;
|
|
164
|
-
return regex.test(value);
|
|
165
|
-
};
|
|
166
|
-
var isSameOrigin = (origin, expected) => {
|
|
167
|
-
const originURL = new URL(origin);
|
|
168
|
-
const expectedURL = new URL(expected);
|
|
169
|
-
return equals(originURL.origin, expectedURL.origin);
|
|
170
|
-
};
|
|
171
|
-
var patternToRegex = (pattern) => {
|
|
172
|
-
try {
|
|
173
|
-
if (pattern.length > 2048) return null;
|
|
174
|
-
pattern = pattern.replace(/\\/g, "");
|
|
175
|
-
const match = pattern.match(/^(https?):\/\/([a-zA-Z0-9.*-]{1,253})(?::(\d{1,5}|\*))?(?:\/.*)?$/);
|
|
176
|
-
if (!match) return null;
|
|
177
|
-
const [, protocol, host, port] = match;
|
|
178
|
-
const hasWildcard = host.includes("*");
|
|
179
|
-
if (hasWildcard && !host.startsWith("*.")) return null;
|
|
180
|
-
if (hasWildcard && host.slice(2).includes("*")) return null;
|
|
181
|
-
const domain = hasWildcard ? host.slice(2) : host;
|
|
182
|
-
const escapedDomain = domain.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
183
|
-
const hostRegex = hasWildcard ? `[^.]+\\.${escapedDomain}` : escapedDomain;
|
|
184
|
-
const portRegex = port === "*" ? ":\\d{1,5}" : port ? `:${port}` : "";
|
|
185
|
-
return new RegExp(`^${protocol}:\\/\\/${hostRegex}${portRegex}$`);
|
|
186
|
-
} catch {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
var isTrustedOrigin = (url, trustedOrigins) => {
|
|
191
|
-
if (!isValidURL(url) || trustedOrigins.length === 0) return false;
|
|
192
|
-
try {
|
|
193
|
-
const urlOrigin = new URL(url).origin;
|
|
194
|
-
for (const pattern of trustedOrigins) {
|
|
195
|
-
const regex = patternToRegex(pattern);
|
|
196
|
-
if (regex?.test(urlOrigin)) return true;
|
|
197
|
-
try {
|
|
198
|
-
if (isValidURL(pattern) && equals(new URL(pattern).origin, urlOrigin)) return true;
|
|
199
|
-
} catch {
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
} catch {
|
|
203
|
-
}
|
|
204
|
-
return false;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
// src/env.ts
|
|
208
|
-
var import_meta = {};
|
|
209
|
-
var env = new Proxy({}, {
|
|
210
|
-
get(_, prop) {
|
|
211
|
-
if (typeof prop !== "string") return void 0;
|
|
212
|
-
const hasProperty = (process2) => {
|
|
213
|
-
return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
|
|
214
|
-
};
|
|
215
|
-
try {
|
|
216
|
-
if (typeof process !== "undefined" && hasProperty(process.env)) {
|
|
217
|
-
return process.env[prop];
|
|
218
|
-
}
|
|
219
|
-
if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
|
|
220
|
-
return import_meta.env[prop];
|
|
221
|
-
}
|
|
222
|
-
if (typeof Deno !== "undefined" && Deno.env?.get) {
|
|
223
|
-
return Deno.env.get(prop);
|
|
224
|
-
}
|
|
225
|
-
if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
|
|
226
|
-
return Bun.env[prop];
|
|
227
|
-
}
|
|
228
|
-
const globalValue = globalThis[prop];
|
|
229
|
-
return typeof globalValue === "string" ? globalValue : void 0;
|
|
230
|
-
} catch {
|
|
231
|
-
return void 0;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
// src/jose.ts
|
|
237
|
-
var import_jose = require("@aura-stack/jose");
|
|
238
|
-
|
|
239
|
-
// src/secure.ts
|
|
240
|
-
var generateSecure = (length = 32) => {
|
|
241
|
-
return import_crypto.default.randomBytes(length).toString("base64url");
|
|
242
|
-
};
|
|
243
|
-
var createHash = (data, base = "hex") => {
|
|
244
|
-
return import_crypto.default.createHash("sha256").update(data).digest().toString(base);
|
|
245
|
-
};
|
|
246
|
-
var createPKCE = async (verifier) => {
|
|
247
|
-
const byteLength = verifier ? void 0 : Math.floor(Math.random() * (96 - 32 + 1) + 32);
|
|
248
|
-
const codeVerifier = verifier ?? generateSecure(byteLength ?? 64);
|
|
249
|
-
if (codeVerifier.length < 43 || codeVerifier.length > 128) {
|
|
250
|
-
throw new AuthSecurityError("PKCE_VERIFIER_INVALID", "The code verifier must be between 43 and 128 characters in length.");
|
|
251
|
-
}
|
|
252
|
-
const codeChallenge = createHash(codeVerifier, "base64url");
|
|
253
|
-
return { codeVerifier, codeChallenge, method: "S256" };
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
// src/schemas.ts
|
|
257
|
-
var import_zod = require("zod");
|
|
258
|
-
var OAuthProviderCredentialsSchema = (0, import_zod.object)({
|
|
259
|
-
id: (0, import_zod.string)(),
|
|
260
|
-
name: (0, import_zod.string)(),
|
|
261
|
-
authorizeURL: (0, import_zod.string)().url(),
|
|
262
|
-
accessToken: (0, import_zod.string)().url(),
|
|
263
|
-
scope: (0, import_zod.string)(),
|
|
264
|
-
userInfo: (0, import_zod.string)().url(),
|
|
265
|
-
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
266
|
-
clientId: (0, import_zod.string)(),
|
|
267
|
-
clientSecret: (0, import_zod.string)(),
|
|
268
|
-
profile: import_zod.z.function().optional()
|
|
269
|
-
});
|
|
270
|
-
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
271
|
-
authorizeURL: (0, import_zod.string)().url(),
|
|
272
|
-
accessToken: (0, import_zod.string)().url(),
|
|
273
|
-
scope: (0, import_zod.string)().optional(),
|
|
274
|
-
userInfo: (0, import_zod.string)().url(),
|
|
275
|
-
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
276
|
-
clientId: (0, import_zod.string)(),
|
|
277
|
-
clientSecret: (0, import_zod.string)()
|
|
278
|
-
});
|
|
279
|
-
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
280
|
-
redirectURI: (0, import_zod.string)(),
|
|
281
|
-
state: (0, import_zod.string)(),
|
|
282
|
-
codeChallenge: (0, import_zod.string)(),
|
|
283
|
-
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
284
|
-
});
|
|
285
|
-
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
286
|
-
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
287
|
-
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
288
|
-
});
|
|
289
|
-
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
290
|
-
error: (0, import_zod.enum)([
|
|
291
|
-
"invalid_request",
|
|
292
|
-
"unauthorized_client",
|
|
293
|
-
"access_denied",
|
|
294
|
-
"unsupported_response_type",
|
|
295
|
-
"invalid_scope",
|
|
296
|
-
"server_error",
|
|
297
|
-
"temporarily_unavailable"
|
|
298
|
-
]),
|
|
299
|
-
error_description: (0, import_zod.string)().optional(),
|
|
300
|
-
error_uri: (0, import_zod.string)().optional(),
|
|
301
|
-
state: (0, import_zod.string)()
|
|
302
|
-
});
|
|
303
|
-
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
304
|
-
redirectURI: (0, import_zod.string)(),
|
|
305
|
-
code: (0, import_zod.string)(),
|
|
306
|
-
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
307
|
-
});
|
|
308
|
-
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
309
|
-
access_token: (0, import_zod.string)(),
|
|
310
|
-
token_type: (0, import_zod.string)().optional(),
|
|
311
|
-
expires_in: (0, import_zod.number)().optional(),
|
|
312
|
-
refresh_token: (0, import_zod.string)().optional(),
|
|
313
|
-
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
314
|
-
});
|
|
315
|
-
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
316
|
-
error: (0, import_zod.enum)([
|
|
317
|
-
"invalid_request",
|
|
318
|
-
"invalid_client",
|
|
319
|
-
"invalid_grant",
|
|
320
|
-
"unauthorized_client",
|
|
321
|
-
"unsupported_grant_type",
|
|
322
|
-
"invalid_scope"
|
|
323
|
-
]),
|
|
324
|
-
error_description: (0, import_zod.string)().optional(),
|
|
325
|
-
error_uri: (0, import_zod.string)().optional()
|
|
326
|
-
});
|
|
327
|
-
var OAuthErrorResponse = (0, import_zod.object)({
|
|
328
|
-
error: (0, import_zod.string)(),
|
|
329
|
-
error_description: (0, import_zod.string)().optional()
|
|
330
|
-
});
|
|
331
|
-
var OAuthEnvSchema = (0, import_zod.object)({
|
|
332
|
-
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
333
|
-
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
// src/actions/signIn/authorization.ts
|
|
337
|
-
var createAuthorizationURL = (oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod, logger) => {
|
|
338
|
-
const parsed = OAuthAuthorization.safeParse({ ...oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod });
|
|
339
|
-
if (!parsed.success) {
|
|
340
|
-
logger?.log("INVALID_OAUTH_CONFIGURATION", {
|
|
341
|
-
structuredData: {
|
|
342
|
-
scope: oauthConfig.scope,
|
|
343
|
-
redirect_uri: redirectURI,
|
|
344
|
-
has_state: Boolean(state),
|
|
345
|
-
has_code_challenge: Boolean(codeChallenge),
|
|
346
|
-
code_challenge_method: codeChallengeMethod
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
throw new AuthInternalError("INVALID_OAUTH_CONFIGURATION", "The OAuth provider configuration is invalid.");
|
|
350
|
-
}
|
|
351
|
-
const { authorizeURL, ...options2 } = parsed.data;
|
|
352
|
-
const { userInfo, accessToken, clientSecret, ...required } = options2;
|
|
353
|
-
const searchParams = new URLSearchParams(toCastCase(required));
|
|
354
|
-
return `${authorizeURL}?${searchParams}`;
|
|
355
|
-
};
|
|
356
|
-
var getTrustedOrigins = async (request, trustedOrigins) => {
|
|
357
|
-
if (!trustedOrigins) return [];
|
|
358
|
-
const raw = typeof trustedOrigins === "function" ? await trustedOrigins(request) : trustedOrigins;
|
|
359
|
-
return Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : [];
|
|
360
|
-
};
|
|
361
|
-
var getOriginURL = async (request, context) => {
|
|
362
|
-
const headers = request.headers;
|
|
363
|
-
let origin = new URL(request.url).origin;
|
|
364
|
-
const trustedOrigins = await getTrustedOrigins(request, context?.trustedOrigins);
|
|
365
|
-
trustedOrigins.push(origin);
|
|
366
|
-
if (context?.trustedProxyHeaders) {
|
|
367
|
-
const protocol = headers.get("Forwarded")?.match(/proto=([^;]+)/i)?.[1] ?? headers.get("X-Forwarded-Proto") ?? "http";
|
|
368
|
-
const host = headers.get("Host") ?? headers.get("Forwarded")?.match(/host=([^;]+)/i)?.[1] ?? headers.get("X-Forwarded-Host") ?? null;
|
|
369
|
-
origin = `${protocol}://${host}`;
|
|
370
|
-
}
|
|
371
|
-
if (!isTrustedOrigin(origin, trustedOrigins)) {
|
|
372
|
-
context?.logger?.log("UNTRUSTED_ORIGIN", { structuredData: { origin } });
|
|
373
|
-
throw new AuthInternalError("UNTRUSTED_ORIGIN", "The constructed origin URL is not trusted.");
|
|
374
|
-
}
|
|
375
|
-
return origin;
|
|
376
|
-
};
|
|
377
|
-
var createRedirectURI = async (request, oauth, context) => {
|
|
378
|
-
const origin = await getOriginURL(request, context);
|
|
379
|
-
return `${origin}${context.basePath}/callback/${oauth}`;
|
|
380
|
-
};
|
|
381
|
-
var createRedirectTo = async (request, redirectTo, context) => {
|
|
382
|
-
try {
|
|
383
|
-
const headers = request.headers;
|
|
384
|
-
const requestOrigin = await getOriginURL(request, context);
|
|
385
|
-
const origins = await getTrustedOrigins(request, context?.trustedOrigins);
|
|
386
|
-
const validateURL = (url) => {
|
|
387
|
-
if (!isRelativeURL(url) && !isValidURL(url)) return "/";
|
|
388
|
-
if (isRelativeURL(url)) return url;
|
|
389
|
-
if (origins.length > 0) {
|
|
390
|
-
if (isTrustedOrigin(url, origins)) {
|
|
391
|
-
const urlOrigin = new URL(url).origin;
|
|
392
|
-
for (const pattern of origins) {
|
|
393
|
-
const regex = patternToRegex(pattern);
|
|
394
|
-
if (regex?.test(urlOrigin)) {
|
|
395
|
-
return isSameOrigin(url, request.url) ? extractPath(url) : url;
|
|
396
|
-
}
|
|
397
|
-
if (isValidURL(pattern) && equals(new URL(pattern).origin, urlOrigin)) return url;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
context?.logger?.log("OPEN_REDIRECT_ATTACK");
|
|
401
|
-
return "/";
|
|
402
|
-
}
|
|
403
|
-
if (isSameOrigin(url, requestOrigin)) {
|
|
404
|
-
return extractPath(url);
|
|
405
|
-
}
|
|
406
|
-
context?.logger?.log("OPEN_REDIRECT_ATTACK");
|
|
407
|
-
return "/";
|
|
408
|
-
};
|
|
409
|
-
return validateURL(redirectTo ?? headers.get("Referer") ?? headers.get("Origin") ?? "/");
|
|
410
|
-
} catch (error) {
|
|
411
|
-
context?.logger?.log("POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED");
|
|
412
|
-
return "/";
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
// src/actions/signIn/signIn.ts
|
|
417
|
-
var signInConfig = (oauth) => {
|
|
418
|
-
return (0, import_router2.createEndpointConfig)("/signIn/:oauth", {
|
|
419
|
-
schemas: {
|
|
420
|
-
params: import_zod2.z.object({
|
|
421
|
-
oauth: import_zod2.z.enum(
|
|
422
|
-
Object.keys(oauth),
|
|
423
|
-
"The OAuth provider is not supported or invalid."
|
|
424
|
-
)
|
|
425
|
-
}),
|
|
426
|
-
searchParams: import_zod2.z.object({
|
|
427
|
-
redirectTo: import_zod2.z.string().optional()
|
|
428
|
-
})
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
};
|
|
432
|
-
var signInAction = (oauth) => {
|
|
433
|
-
return (0, import_router2.createEndpoint)(
|
|
434
|
-
"GET",
|
|
435
|
-
"/signIn/:oauth",
|
|
436
|
-
async (ctx) => {
|
|
437
|
-
const {
|
|
438
|
-
request,
|
|
439
|
-
params: { oauth: oauth2 },
|
|
440
|
-
searchParams: { redirectTo },
|
|
441
|
-
context
|
|
442
|
-
} = ctx;
|
|
443
|
-
const { oauth: providers, cookies, logger } = context;
|
|
444
|
-
const state = generateSecure();
|
|
445
|
-
const redirectURI = await createRedirectURI(request, oauth2, context);
|
|
446
|
-
const redirectToValue = await createRedirectTo(request, redirectTo, context);
|
|
447
|
-
const { codeVerifier, codeChallenge, method } = await createPKCE();
|
|
448
|
-
const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method, logger);
|
|
449
|
-
logger?.log("SIGN_IN_INITIATED", {
|
|
450
|
-
structuredData: { oauth_provider: oauth2, code_challenge_method: method }
|
|
451
|
-
});
|
|
452
|
-
const headers = new import_router2.HeadersBuilder(cacheControl).setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirectURI.name, redirectURI, cookies.redirectURI.attributes).setCookie(cookies.redirectTo.name, redirectToValue, cookies.redirectTo.attributes).setCookie(cookies.codeVerifier.name, codeVerifier, cookies.codeVerifier.attributes).toHeaders();
|
|
453
|
-
return Response.json(
|
|
454
|
-
{ oauth: oauth2 },
|
|
455
|
-
{
|
|
456
|
-
status: 302,
|
|
457
|
-
headers
|
|
458
|
-
}
|
|
459
|
-
);
|
|
460
|
-
},
|
|
461
|
-
signInConfig(oauth)
|
|
462
|
-
);
|
|
463
|
-
};
|
|
464
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
465
|
-
0 && (module.exports = {
|
|
466
|
-
signInAction
|
|
467
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
|
-
import { k as OAuthProviderRecord } from '../../index-CSyIJmCM.js';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '../../schemas.js';
|
|
5
|
-
import '../../jose.js';
|
|
6
|
-
import '@aura-stack/jose';
|
|
7
|
-
import '@aura-stack/jose/jose';
|
|
8
|
-
import '@aura-stack/router/cookie';
|
|
9
|
-
import '../../@types/utility.js';
|
|
10
|
-
|
|
11
|
-
declare const signInAction: (oauth: OAuthProviderRecord) => _aura_stack_router.RouteEndpoint<"GET", "/signIn/:oauth", {}>;
|
|
12
|
-
|
|
13
|
-
export { signInAction };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
signInAction
|
|
3
|
-
} from "../../chunk-7QF22LHP.js";
|
|
4
|
-
import "../../chunk-XUP6KKNG.js";
|
|
5
|
-
import "../../chunk-KJBAQZX2.js";
|
|
6
|
-
import "../../chunk-NUDITUKX.js";
|
|
7
|
-
import "../../chunk-4EKY7655.js";
|
|
8
|
-
import "../../chunk-QQVSRXGX.js";
|
|
9
|
-
import "../../chunk-EBAMFRB7.js";
|
|
10
|
-
import "../../chunk-FRJFWTOY.js";
|
|
11
|
-
import "../../chunk-4MYWAOLG.js";
|
|
12
|
-
import "../../chunk-RRLIF4PQ.js";
|
|
13
|
-
export {
|
|
14
|
-
signInAction
|
|
15
|
-
};
|