@aura-stack/auth 0.1.0-rc.9 → 0.2.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/dist/@types/index.cjs +15 -15
- package/dist/@types/index.d.ts +6 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +6 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +4 -8
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +159 -149
- package/dist/actions/callback/access-token.d.ts +14 -20
- package/dist/actions/callback/access-token.js +9 -4
- package/dist/actions/callback/callback.cjs +371 -484
- package/dist/actions/callback/callback.d.ts +9 -12
- package/dist/actions/callback/callback.js +15 -12
- package/dist/actions/callback/userinfo.cjs +149 -139
- package/dist/actions/callback/userinfo.d.ts +8 -9
- package/dist/actions/callback/userinfo.js +11 -6
- package/dist/actions/csrfToken/csrfToken.cjs +112 -190
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +12 -8
- package/dist/actions/index.cjs +623 -807
- package/dist/actions/index.d.ts +12 -13
- package/dist/actions/index.js +33 -18
- package/dist/actions/session/session.cjs +86 -176
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +10 -7
- package/dist/actions/signIn/authorization.cjs +248 -257
- package/dist/actions/signIn/authorization.d.ts +11 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +302 -451
- package/dist/actions/signIn/signIn.d.ts +9 -10
- package/dist/actions/signIn/signIn.js +12 -10
- package/dist/actions/signOut/signOut.cjs +299 -468
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +14 -11
- package/dist/assert.cjs +40 -36
- package/dist/assert.d.ts +12 -4
- package/dist/assert.js +12 -2
- package/dist/chunk-2RXNXMCZ.js +55 -0
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-4V4JNXVF.js +55 -0
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-7H3OR6UU.js +81 -0
- package/dist/chunk-CXLATHS5.js +143 -0
- package/dist/chunk-E3OXBRYF.js +19 -17
- package/dist/chunk-EIL2FPSS.js +22 -0
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-IMICRJ5U.js +197 -0
- package/dist/chunk-IUYZQTJV.js +30 -0
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-N2APGLXA.js +71 -0
- package/dist/chunk-NEVKX6K2.js +70 -0
- package/dist/chunk-PTJUYB33.js +33 -0
- package/dist/chunk-QDO2KSRJ.js +35 -0
- package/dist/chunk-QEZL7EYN.js +96 -0
- package/dist/chunk-RRLIF4PQ.js +55 -0
- package/dist/chunk-STHEPPUZ.js +8 -6
- package/dist/chunk-TLE4PXY3.js +39 -0
- package/dist/chunk-UEH3LVON.js +97 -0
- package/dist/chunk-WD7AUHQ5.js +79 -0
- package/dist/chunk-ZLR3LI6X.js +55 -0
- package/dist/cookie.cjs +222 -187
- package/dist/cookie.d.ts +38 -76
- package/dist/cookie.js +27 -34
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.js +18 -0
- package/dist/headers.cjs +28 -28
- package/dist/headers.d.ts +2 -2
- package/dist/headers.js +6 -2
- package/dist/{index-DpfbvTZ_.d.ts → index-EqsoyjrF.d.ts} +351 -318
- package/dist/index.cjs +1006 -1001
- package/dist/index.d.ts +9 -31
- package/dist/index.js +82 -51
- package/dist/jose.cjs +74 -66
- package/dist/jose.d.ts +11 -8
- package/dist/jose.js +10 -5
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +6 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +47 -48
- package/dist/oauth/discord.d.ts +6 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +6 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +6 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +6 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +306 -180
- package/dist/oauth/index.d.ts +6 -26
- package/dist/oauth/index.js +43 -9
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +6 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +6 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +6 -7
- package/dist/oauth/x.js +6 -2
- package/dist/schemas.cjs +97 -91
- package/dist/schemas.d.ts +96 -126
- package/dist/schemas.js +20 -18
- package/dist/secure.cjs +106 -101
- package/dist/secure.d.ts +16 -17
- package/dist/secure.js +19 -4
- package/dist/utils.cjs +197 -135
- package/dist/utils.d.ts +20 -26
- package/dist/utils.js +25 -21
- package/package.json +5 -6
- package/dist/chunk-256KIVJL.js +0 -110
- package/dist/chunk-6SM22VVJ.js +0 -15
- package/dist/chunk-CAKJT3KS.js +0 -77
- package/dist/chunk-EBPE35JT.js +0 -29
- package/dist/chunk-FJUDBLCP.js +0 -52
- package/dist/chunk-GZU3RBTB.js +0 -51
- package/dist/chunk-HGJ4TXY4.js +0 -105
- package/dist/chunk-HMRKN75I.js +0 -74
- package/dist/chunk-JAPMIE6S.js +0 -8
- package/dist/chunk-LLR722CL.js +0 -75
- package/dist/chunk-RLT4RFKV.js +0 -36
- package/dist/chunk-SJPDVKUS.js +0 -93
- package/dist/chunk-SMQO5WD7.js +0 -20
- package/dist/chunk-UJJ7R56J.js +0 -42
- package/dist/chunk-UTDLUEEG.js +0 -25
- package/dist/chunk-VFTYH33W.js +0 -44
- package/dist/chunk-XXJKNKGQ.js +0 -27
- package/dist/chunk-ZV4BH47P.js +0 -156
- package/dist/error.cjs +0 -88
- package/dist/error.d.ts +0 -62
- package/dist/error.js +0 -9
- package/dist/response.cjs +0 -34
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -2
|
@@ -1,535 +1,422 @@
|
|
|
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
|
|
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
8
|
var __export = (target, all) => {
|
|
9
|
-
|
|
10
|
-
}
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
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);
|
|
31
29
|
|
|
32
30
|
// src/actions/callback/callback.ts
|
|
33
|
-
var callback_exports = {}
|
|
31
|
+
var callback_exports = {};
|
|
34
32
|
__export(callback_exports, {
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
module.exports = __toCommonJS(callback_exports)
|
|
38
|
-
var import_zod = __toESM(require("zod"), 1)
|
|
39
|
-
var import_router2 = require("@aura-stack/router")
|
|
33
|
+
callbackAction: () => callbackAction
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(callback_exports);
|
|
36
|
+
var import_zod = __toESM(require("zod"), 1);
|
|
37
|
+
var import_router2 = require("@aura-stack/router");
|
|
40
38
|
|
|
41
39
|
// src/secure.ts
|
|
42
|
-
var import_node_crypto = __toESM(require("crypto"), 1)
|
|
40
|
+
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
43
41
|
|
|
44
42
|
// src/utils.ts
|
|
45
|
-
var import_router = require("@aura-stack/router")
|
|
43
|
+
var import_router = require("@aura-stack/router");
|
|
46
44
|
|
|
47
|
-
// src/
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
// src/errors.ts
|
|
46
|
+
var OAuthProtocolError = class extends Error {
|
|
47
|
+
type = "OAUTH_PROTOCOL_ERROR";
|
|
48
|
+
error;
|
|
49
|
+
errorURI;
|
|
50
|
+
constructor(error, description, errorURI, options2) {
|
|
51
|
+
super(description, options2);
|
|
52
|
+
this.error = error;
|
|
53
|
+
this.errorURI = errorURI;
|
|
54
|
+
this.name = new.target.name;
|
|
55
|
+
Error.captureStackTrace(this, new.target);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var AuthInternalError = class extends Error {
|
|
59
|
+
type = "AUTH_INTERNAL_ERROR";
|
|
60
|
+
code;
|
|
61
|
+
constructor(code, message, options2) {
|
|
62
|
+
super(message, options2);
|
|
63
|
+
this.code = code;
|
|
64
|
+
this.name = new.target.name;
|
|
65
|
+
Error.captureStackTrace(this, new.target);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var AuthSecurityError = class extends Error {
|
|
69
|
+
type = "AUTH_SECURITY_ERROR";
|
|
70
|
+
code;
|
|
71
|
+
constructor(code, message, options2) {
|
|
72
|
+
super(message, options2);
|
|
73
|
+
this.code = code;
|
|
74
|
+
this.name = new.target.name;
|
|
75
|
+
Error.captureStackTrace(this, new.target);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var isNativeError = (error) => {
|
|
79
|
+
return error instanceof Error;
|
|
80
|
+
};
|
|
81
|
+
var isOAuthProtocolError = (error) => {
|
|
82
|
+
return error instanceof OAuthProtocolError;
|
|
83
|
+
};
|
|
85
84
|
|
|
86
85
|
// src/utils.ts
|
|
87
86
|
var equals = (a, b) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
var sanitizeURL = (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
path = path.replace(/\/+$/, "/")
|
|
113
|
-
} else if (path !== "/") {
|
|
114
|
-
path = path.replace(/\/+$/, "")
|
|
115
|
-
}
|
|
116
|
-
return protocol + domain + path
|
|
117
|
-
}
|
|
118
|
-
let sanitized = decodedURL
|
|
119
|
-
.replace(/\/\.\.\//g, "/")
|
|
120
|
-
.replace(/\/\.\.$/, "")
|
|
121
|
-
.replace(/\.{2,}/g, "")
|
|
122
|
-
.replace(/\/{2,}/g, "/")
|
|
123
|
-
if (sanitized !== "/" && sanitized.endsWith("/")) {
|
|
124
|
-
sanitized = sanitized.replace(/\/+$/, "/")
|
|
125
|
-
} else if (sanitized !== "/") {
|
|
126
|
-
sanitized = sanitized.replace(/\/+$/, "")
|
|
127
|
-
}
|
|
128
|
-
return sanitized
|
|
129
|
-
} catch {
|
|
130
|
-
return url2.trim()
|
|
87
|
+
if (a === null || b === null || a === void 0 || b === void 0) return false;
|
|
88
|
+
return a === b;
|
|
89
|
+
};
|
|
90
|
+
var sanitizeURL = (url) => {
|
|
91
|
+
try {
|
|
92
|
+
let decodedURL = decodeURIComponent(url).trim();
|
|
93
|
+
const protocolMatch = decodedURL.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)/);
|
|
94
|
+
let protocol = "";
|
|
95
|
+
let rest = decodedURL;
|
|
96
|
+
if (protocolMatch) {
|
|
97
|
+
protocol = protocolMatch[1];
|
|
98
|
+
rest = decodedURL.slice(protocol.length);
|
|
99
|
+
const slashIndex = rest.indexOf("/");
|
|
100
|
+
if (slashIndex === -1) {
|
|
101
|
+
return protocol + rest;
|
|
102
|
+
}
|
|
103
|
+
const domain = rest.slice(0, slashIndex);
|
|
104
|
+
let path = rest.slice(slashIndex).replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
|
|
105
|
+
if (path !== "/" && path.endsWith("/")) {
|
|
106
|
+
path = path.replace(/\/+$/, "/");
|
|
107
|
+
} else if (path !== "/") {
|
|
108
|
+
path = path.replace(/\/+$/, "");
|
|
109
|
+
}
|
|
110
|
+
return protocol + domain + path;
|
|
131
111
|
}
|
|
132
|
-
}
|
|
112
|
+
let sanitized = decodedURL.replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
|
|
113
|
+
if (sanitized !== "/" && sanitized.endsWith("/")) {
|
|
114
|
+
sanitized = sanitized.replace(/\/+$/, "/");
|
|
115
|
+
} else if (sanitized !== "/") {
|
|
116
|
+
sanitized = sanitized.replace(/\/+$/, "");
|
|
117
|
+
}
|
|
118
|
+
return sanitized;
|
|
119
|
+
} catch {
|
|
120
|
+
return url.trim();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
133
123
|
var isValidRelativePath = (path) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
124
|
+
if (!path || typeof path !== "string") return false;
|
|
125
|
+
if (!path.startsWith("/") || path.includes("://") || path.includes("\r") || path.includes("\n")) return false;
|
|
126
|
+
if (/[\x00-\x1F\x7F]/.test(path) || path.includes("\0")) return false;
|
|
127
|
+
const sanitized = sanitizeURL(path);
|
|
128
|
+
if (sanitized.includes("..")) return false;
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
var formatZodError = (error) => {
|
|
132
|
+
if (!error.issues || error.issues.length === 0) {
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
return error.issues.reduce((previous, issue) => {
|
|
136
|
+
const key = issue.path.join(".");
|
|
137
|
+
return {
|
|
138
|
+
...previous,
|
|
139
|
+
[key]: {
|
|
140
|
+
code: issue.code,
|
|
141
|
+
message: issue.message
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}, {});
|
|
145
|
+
};
|
|
141
146
|
|
|
142
147
|
// src/secure.ts
|
|
143
148
|
var generateSecure = (length = 32) => {
|
|
144
|
-
|
|
145
|
-
}
|
|
149
|
+
return import_node_crypto.default.randomBytes(length).toString("base64url");
|
|
150
|
+
};
|
|
146
151
|
var createCSRF = async (jose, csrfCookie) => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return jose.signJWS({ token })
|
|
154
|
-
} catch {
|
|
155
|
-
const token = generateSecure(32)
|
|
156
|
-
return jose.signJWS({ token })
|
|
152
|
+
try {
|
|
153
|
+
const token = generateSecure(32);
|
|
154
|
+
if (csrfCookie) {
|
|
155
|
+
await jose.verifyJWS(csrfCookie);
|
|
156
|
+
return csrfCookie;
|
|
157
157
|
}
|
|
158
|
-
}
|
|
158
|
+
return jose.signJWS({ token });
|
|
159
|
+
} catch {
|
|
160
|
+
const token = generateSecure(32);
|
|
161
|
+
return jose.signJWS({ token });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
159
164
|
|
|
160
165
|
// src/headers.ts
|
|
161
166
|
var cacheControl = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
+
"Cache-Control": "no-store",
|
|
168
|
+
Pragma: "no-cache",
|
|
169
|
+
Expires: "0",
|
|
170
|
+
Vary: "Cookie"
|
|
171
|
+
};
|
|
167
172
|
|
|
168
173
|
// src/schemas.ts
|
|
169
|
-
var import_v4 = require("zod/v4")
|
|
174
|
+
var import_v4 = require("zod/v4");
|
|
170
175
|
var OAuthProviderConfigSchema = (0, import_v4.object)({
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
})
|
|
176
|
+
authorizeURL: (0, import_v4.httpUrl)(),
|
|
177
|
+
accessToken: (0, import_v4.httpUrl)(),
|
|
178
|
+
scope: (0, import_v4.string)().optional(),
|
|
179
|
+
userInfo: (0, import_v4.httpUrl)(),
|
|
180
|
+
responseType: (0, import_v4.enum)(["code", "token", "id_token"]),
|
|
181
|
+
clientId: (0, import_v4.string)(),
|
|
182
|
+
clientSecret: (0, import_v4.string)()
|
|
183
|
+
});
|
|
179
184
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
})
|
|
185
|
+
redirectURI: (0, import_v4.string)(),
|
|
186
|
+
state: (0, import_v4.string)(),
|
|
187
|
+
codeChallenge: (0, import_v4.string)(),
|
|
188
|
+
codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
|
|
189
|
+
});
|
|
185
190
|
var OAuthAuthorizationResponse = (0, import_v4.object)({
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
})
|
|
191
|
+
state: (0, import_v4.string)("Missing state parameter in the OAuth authorization response."),
|
|
192
|
+
code: (0, import_v4.string)("Missing code parameter in the OAuth authorization response.")
|
|
193
|
+
});
|
|
189
194
|
var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
})
|
|
195
|
+
error: (0, import_v4.enum)([
|
|
196
|
+
"invalid_request",
|
|
197
|
+
"unauthorized_client",
|
|
198
|
+
"access_denied",
|
|
199
|
+
"unsupported_response_type",
|
|
200
|
+
"invalid_scope",
|
|
201
|
+
"server_error",
|
|
202
|
+
"temporarily_unavailable"
|
|
203
|
+
]),
|
|
204
|
+
error_description: (0, import_v4.string)().optional(),
|
|
205
|
+
error_uri: (0, import_v4.string)().optional(),
|
|
206
|
+
state: (0, import_v4.string)()
|
|
207
|
+
});
|
|
203
208
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
})
|
|
209
|
+
redirectURI: (0, import_v4.string)(),
|
|
210
|
+
code: (0, import_v4.string)(),
|
|
211
|
+
codeVerifier: (0, import_v4.string)().min(43).max(128)
|
|
212
|
+
});
|
|
208
213
|
var OAuthAccessTokenResponse = (0, import_v4.object)({
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
214
|
+
access_token: (0, import_v4.string)(),
|
|
215
|
+
token_type: (0, import_v4.string)(),
|
|
216
|
+
expires_in: (0, import_v4.number)().optional(),
|
|
217
|
+
refresh_token: (0, import_v4.string)().optional(),
|
|
218
|
+
scope: (0, import_v4.string)().optional()
|
|
219
|
+
});
|
|
215
220
|
var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
})
|
|
221
|
+
error: (0, import_v4.enum)([
|
|
222
|
+
"invalid_request",
|
|
223
|
+
"invalid_client",
|
|
224
|
+
"invalid_grant",
|
|
225
|
+
"unauthorized_client",
|
|
226
|
+
"unsupported_grant_type",
|
|
227
|
+
"invalid_scope"
|
|
228
|
+
]),
|
|
229
|
+
error_description: (0, import_v4.string)().optional(),
|
|
230
|
+
error_uri: (0, import_v4.string)().optional()
|
|
231
|
+
});
|
|
227
232
|
var OAuthErrorResponse = (0, import_v4.object)({
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
})
|
|
233
|
+
error: (0, import_v4.string)(),
|
|
234
|
+
error_description: (0, import_v4.string)().optional()
|
|
235
|
+
});
|
|
236
|
+
var OAuthEnvSchema = (0, import_v4.object)({
|
|
237
|
+
clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
238
|
+
clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
239
|
+
});
|
|
231
240
|
|
|
232
241
|
// src/actions/callback/userinfo.ts
|
|
233
242
|
var getDefaultUserInfo = (profile) => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
243
|
+
const sub = generateSecure(16);
|
|
244
|
+
return {
|
|
245
|
+
sub: profile?.id ?? profile?.sub ?? sub,
|
|
246
|
+
email: profile?.email,
|
|
247
|
+
name: profile?.name ?? profile?.username ?? profile?.nickname,
|
|
248
|
+
image: profile?.image ?? profile?.picture
|
|
249
|
+
};
|
|
250
|
+
};
|
|
242
251
|
var getUserInfo = async (oauthConfig, accessToken) => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
throw throwAuthError(error, "Failed to retrieve userinfo")
|
|
252
|
+
const userinfoEndpoint = oauthConfig.userInfo;
|
|
253
|
+
try {
|
|
254
|
+
const response = await fetch(userinfoEndpoint, {
|
|
255
|
+
method: "GET",
|
|
256
|
+
headers: {
|
|
257
|
+
Accept: "application/json",
|
|
258
|
+
Authorization: `Bearer ${accessToken}`
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const json = await response.json();
|
|
262
|
+
const { success, data } = OAuthErrorResponse.safeParse(json);
|
|
263
|
+
if (success) {
|
|
264
|
+
throw new OAuthProtocolError(
|
|
265
|
+
data.error,
|
|
266
|
+
data?.error_description ?? "An error occurred while fetching user information."
|
|
267
|
+
);
|
|
260
268
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
static json(body, init) {
|
|
266
|
-
return Response.json(body, init)
|
|
269
|
+
return oauthConfig?.profile ? oauthConfig.profile(json) : getDefaultUserInfo(json);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (isOAuthProtocolError(error)) {
|
|
272
|
+
throw error;
|
|
267
273
|
}
|
|
268
|
-
|
|
274
|
+
if (isNativeError(error)) {
|
|
275
|
+
throw new OAuthProtocolError("invalid_request", error.message, "", { cause: error });
|
|
276
|
+
}
|
|
277
|
+
throw new OAuthProtocolError("invalid_request", "Failed to fetch user information.", "", { cause: error });
|
|
278
|
+
}
|
|
279
|
+
};
|
|
269
280
|
|
|
270
281
|
// src/actions/callback/access-token.ts
|
|
271
282
|
var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return token.data
|
|
303
|
-
} catch (error) {
|
|
304
|
-
throw throwAuthError(error, "Failed to create access token")
|
|
283
|
+
const parsed = OAuthAccessToken.safeParse({ ...oauthConfig, redirectURI, code, codeVerifier });
|
|
284
|
+
if (!parsed.success) {
|
|
285
|
+
const msg = JSON.stringify(formatZodError(parsed.error), null, 2);
|
|
286
|
+
throw new AuthInternalError("INVALID_OAUTH_CONFIGURATION", msg);
|
|
287
|
+
}
|
|
288
|
+
const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
|
|
289
|
+
try {
|
|
290
|
+
const response = await fetch(accessToken, {
|
|
291
|
+
method: "POST",
|
|
292
|
+
headers: {
|
|
293
|
+
Accept: "application/json",
|
|
294
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
295
|
+
},
|
|
296
|
+
body: new URLSearchParams({
|
|
297
|
+
client_id: clientId,
|
|
298
|
+
client_secret: clientSecret,
|
|
299
|
+
code: codeParsed,
|
|
300
|
+
redirect_uri: redirectParsed,
|
|
301
|
+
grant_type: "authorization_code",
|
|
302
|
+
code_verifier: codeVerifier
|
|
303
|
+
}).toString()
|
|
304
|
+
});
|
|
305
|
+
const json = await response.json();
|
|
306
|
+
const token = OAuthAccessTokenResponse.safeParse(json);
|
|
307
|
+
if (!token.success) {
|
|
308
|
+
const { success, data } = OAuthAccessTokenErrorResponse.safeParse(json);
|
|
309
|
+
if (!success) {
|
|
310
|
+
throw new OAuthProtocolError("INVALID_REQUEST", "Invalid access token response format");
|
|
311
|
+
}
|
|
312
|
+
throw new OAuthProtocolError(data.error, data?.error_description ?? "Failed to retrieve access token");
|
|
305
313
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
// src/assert.ts
|
|
312
|
-
var isRequest = (value) => {
|
|
313
|
-
return typeof Request !== "undefined" && value instanceof Request
|
|
314
|
-
}
|
|
314
|
+
return token.data;
|
|
315
|
+
} catch (error) {
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
315
319
|
|
|
316
320
|
// src/cookie.ts
|
|
317
|
-
var
|
|
318
|
-
var COOKIE_NAME = "aura-auth"
|
|
321
|
+
var import_cookie = require("@aura-stack/router/cookie");
|
|
319
322
|
var defaultCookieOptions = {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
var
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const cookieNameWithPrefix = `${prefix}${name}.${cookieName}`
|
|
356
|
-
return (0, import_cookie.serialize)(cookieNameWithPrefix, value, {
|
|
357
|
-
...defaultCookieOptions,
|
|
358
|
-
...options2,
|
|
359
|
-
})
|
|
360
|
-
}
|
|
361
|
-
var getCookie = (petition, cookie, options2, optional = false) => {
|
|
362
|
-
const cookies = isRequest(petition) ? petition.headers.get("Cookie") : petition.headers.getSetCookie().join("; ")
|
|
363
|
-
if (!cookies) {
|
|
364
|
-
if (optional) {
|
|
365
|
-
return ""
|
|
366
|
-
}
|
|
367
|
-
throw new AuthError("invalid_request", "No cookies found. There is no active session")
|
|
368
|
-
}
|
|
369
|
-
const { name, prefix } = defineDefaultCookieOptions(options2)
|
|
370
|
-
const parsedCookies = (0, import_cookie.parse)(cookies)
|
|
371
|
-
const value = parsedCookies[`${prefix}${name}.${cookie}`]
|
|
372
|
-
if (value === void 0) {
|
|
373
|
-
if (optional) {
|
|
374
|
-
return ""
|
|
375
|
-
}
|
|
376
|
-
throw new AuthError("invalid_request", `Cookie "${cookie}" not found. There is no active session`)
|
|
377
|
-
}
|
|
378
|
-
return value
|
|
379
|
-
}
|
|
380
|
-
var createSessionCookie = async (session, cookieOptions, jose) => {
|
|
381
|
-
try {
|
|
382
|
-
const encoded = await jose.encodeJWT(session)
|
|
383
|
-
return setCookie("sessionToken", encoded, cookieOptions)
|
|
384
|
-
} catch (error) {
|
|
385
|
-
throw new AuthError("server_error", "Failed to create session cookie", { cause: error })
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
var secureCookieOptions = (request, cookieOptions, trustedProxyHeaders) => {
|
|
389
|
-
const name = cookieOptions.name ?? COOKIE_NAME
|
|
390
|
-
const isSecure = trustedProxyHeaders
|
|
391
|
-
? request.url.startsWith("https://") ||
|
|
392
|
-
request.headers.get("X-Forwarded-Proto") === "https" ||
|
|
393
|
-
request.headers.get("Forwarded")?.includes("proto=https")
|
|
394
|
-
: request.url.startsWith("https://")
|
|
395
|
-
if (!cookieOptions.options?.httpOnly) {
|
|
396
|
-
console.warn(
|
|
397
|
-
"[WARNING]: Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS risk."
|
|
398
|
-
)
|
|
399
|
-
}
|
|
400
|
-
if (cookieOptions.options?.domain === "*") {
|
|
401
|
-
console.warn("[WARNING]: Cookie 'Domain' is set to '*', which is insecure. Avoid wildcard domains.")
|
|
402
|
-
}
|
|
403
|
-
if (!isSecure) {
|
|
404
|
-
const options2 = cookieOptions.options
|
|
405
|
-
if (options2?.secure) {
|
|
406
|
-
console.warn(
|
|
407
|
-
"[WARNING]: The 'Secure' attribute will be disabled for this cookie. Serve over HTTPS to enforce Secure cookies."
|
|
408
|
-
)
|
|
409
|
-
}
|
|
410
|
-
if (options2?.sameSite == "none") {
|
|
411
|
-
console.warn("[WARNING]: SameSite=None without a secure connection can be blocked by browsers.")
|
|
412
|
-
}
|
|
413
|
-
if (process.env.NODE_ENV === "production") {
|
|
414
|
-
console.warn("[WARNING]: In production, ensure cookies are served over HTTPS to maintain security.")
|
|
415
|
-
}
|
|
416
|
-
return {
|
|
417
|
-
...defaultCookieOptions,
|
|
418
|
-
...cookieOptions.options,
|
|
419
|
-
sameSite: options2?.sameSite === "none" ? "lax" : (options2?.sameSite ?? "lax"),
|
|
420
|
-
...defaultStandardCookieConfig,
|
|
421
|
-
name,
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return cookieOptions.strategy === "host"
|
|
425
|
-
? {
|
|
426
|
-
...defaultCookieOptions,
|
|
427
|
-
...cookieOptions.options,
|
|
428
|
-
...defaultHostCookieConfig,
|
|
429
|
-
name,
|
|
430
|
-
}
|
|
431
|
-
: { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name }
|
|
432
|
-
}
|
|
433
|
-
var expireCookie = (name, options2) => {
|
|
434
|
-
return setCookie(name, "", { ...options2, ...expiredCookieOptions })
|
|
435
|
-
}
|
|
323
|
+
httpOnly: true,
|
|
324
|
+
sameSite: "lax",
|
|
325
|
+
path: "/",
|
|
326
|
+
maxAge: 60 * 60 * 24 * 15
|
|
327
|
+
};
|
|
328
|
+
var oauthCookieOptions = {
|
|
329
|
+
httpOnly: true,
|
|
330
|
+
maxAge: 5 * 60,
|
|
331
|
+
sameSite: "lax",
|
|
332
|
+
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
333
|
+
};
|
|
334
|
+
var expiredCookieAttributes = {
|
|
335
|
+
...defaultCookieOptions,
|
|
336
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
337
|
+
maxAge: 0
|
|
338
|
+
};
|
|
339
|
+
var getCookie = (request, cookieName) => {
|
|
340
|
+
const cookies = request.headers.get("Cookie");
|
|
341
|
+
if (!cookies) {
|
|
342
|
+
throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
|
|
343
|
+
}
|
|
344
|
+
const value = (0, import_cookie.parse)(cookies)[cookieName];
|
|
345
|
+
if (!value) {
|
|
346
|
+
throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found. There is no active session`);
|
|
347
|
+
}
|
|
348
|
+
return value;
|
|
349
|
+
};
|
|
350
|
+
var createSessionCookie = async (jose, session) => {
|
|
351
|
+
try {
|
|
352
|
+
const encoded = await jose.encodeJWT(session);
|
|
353
|
+
return encoded;
|
|
354
|
+
} catch (error) {
|
|
355
|
+
throw new AuthInternalError("INVALID_JWT_TOKEN", "Failed to create session cookie", { cause: error });
|
|
356
|
+
}
|
|
357
|
+
};
|
|
436
358
|
|
|
437
359
|
// src/actions/callback/callback.ts
|
|
438
360
|
var callbackConfig = (oauth) => {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
361
|
+
return (0, import_router2.createEndpointConfig)("/callback/:oauth", {
|
|
362
|
+
schemas: {
|
|
363
|
+
searchParams: OAuthAuthorizationResponse,
|
|
364
|
+
params: import_zod.default.object({
|
|
365
|
+
oauth: import_zod.default.enum(Object.keys(oauth), "The OAuth provider is not supported or invalid.")
|
|
366
|
+
})
|
|
367
|
+
},
|
|
368
|
+
middlewares: [
|
|
369
|
+
(ctx) => {
|
|
370
|
+
const response = OAuthAuthorizationErrorResponse.safeParse(ctx.searchParams);
|
|
371
|
+
if (response.success) {
|
|
372
|
+
const { error, error_description } = response.data;
|
|
373
|
+
throw new OAuthProtocolError(error, error_description ?? "OAuth Authorization Error");
|
|
374
|
+
}
|
|
375
|
+
return ctx;
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
});
|
|
379
|
+
};
|
|
458
380
|
var callbackAction = (oauth) => {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
{
|
|
498
|
-
...cookies,
|
|
499
|
-
strategy: "host",
|
|
500
|
-
},
|
|
501
|
-
trustedProxyHeaders
|
|
502
|
-
)
|
|
503
|
-
)
|
|
504
|
-
headers.set("Set-Cookie", sessionCookie)
|
|
505
|
-
headers.append("Set-Cookie", expireCookie("state", cookieOptions))
|
|
506
|
-
headers.append("Set-Cookie", expireCookie("redirect_uri", cookieOptions))
|
|
507
|
-
headers.append("Set-Cookie", expireCookie("redirect_to", cookieOptions))
|
|
508
|
-
headers.append("Set-Cookie", expireCookie("code_verifier", cookieOptions))
|
|
509
|
-
headers.append("Set-Cookie", csrfCookie)
|
|
510
|
-
return Response.json({ oauth: oauth2 }, { status: 302, headers })
|
|
511
|
-
} catch (error) {
|
|
512
|
-
if (isAuthError(error)) {
|
|
513
|
-
const { type, message } = error
|
|
514
|
-
return AuraResponse.json(
|
|
515
|
-
{ error: type, error_description: message },
|
|
516
|
-
{ status: import_router2.statusCode.BAD_REQUEST }
|
|
517
|
-
)
|
|
518
|
-
}
|
|
519
|
-
return AuraResponse.json(
|
|
520
|
-
{
|
|
521
|
-
error: ERROR_RESPONSE.ACCESS_TOKEN.INVALID_CLIENT,
|
|
522
|
-
error_description: "An unexpected error occurred",
|
|
523
|
-
},
|
|
524
|
-
{ status: import_router2.statusCode.INTERNAL_SERVER_ERROR }
|
|
525
|
-
)
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
callbackConfig(oauth)
|
|
529
|
-
)
|
|
530
|
-
}
|
|
381
|
+
return (0, import_router2.createEndpoint)(
|
|
382
|
+
"GET",
|
|
383
|
+
"/callback/:oauth",
|
|
384
|
+
async (ctx) => {
|
|
385
|
+
const {
|
|
386
|
+
request,
|
|
387
|
+
params: { oauth: oauth2 },
|
|
388
|
+
searchParams: { code, state },
|
|
389
|
+
context: { oauth: providers, cookies, jose }
|
|
390
|
+
} = ctx;
|
|
391
|
+
const oauthConfig = providers[oauth2];
|
|
392
|
+
const cookieState = getCookie(request, cookies.state.name);
|
|
393
|
+
const cookieRedirectTo = getCookie(request, cookies.redirect_to.name);
|
|
394
|
+
const cookieRedirectURI = getCookie(request, cookies.redirect_uri.name);
|
|
395
|
+
const codeVerifier = getCookie(request, cookies.code_verifier.name);
|
|
396
|
+
if (!equals(cookieState, state)) {
|
|
397
|
+
throw new AuthSecurityError(
|
|
398
|
+
"MISMATCHING_STATE",
|
|
399
|
+
"The provided state passed in the OAuth response does not match the stored state."
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
const accessToken = await createAccessToken(oauthConfig, cookieRedirectURI, code, codeVerifier);
|
|
403
|
+
const sanitized = sanitizeURL(cookieRedirectTo);
|
|
404
|
+
if (!isValidRelativePath(sanitized)) {
|
|
405
|
+
throw new AuthSecurityError(
|
|
406
|
+
"POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED",
|
|
407
|
+
"Invalid redirect path. Potential open redirect attack detected."
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
const userInfo = await getUserInfo(oauthConfig, accessToken.access_token);
|
|
411
|
+
const sessionCookie = await createSessionCookie(jose, userInfo);
|
|
412
|
+
const csrfToken = await createCSRF(jose);
|
|
413
|
+
const headers = new import_router2.HeadersBuilder(cacheControl).setHeader("Location", sanitized).setCookie(cookies.sessionToken.name, sessionCookie, cookies.sessionToken.attributes).setCookie(cookies.csrfToken.name, csrfToken, cookies.csrfToken.attributes).setCookie(cookies.state.name, "", expiredCookieAttributes).setCookie(cookies.redirect_uri.name, "", expiredCookieAttributes).setCookie(cookies.redirect_to.name, "", expiredCookieAttributes).setCookie(cookies.code_verifier.name, "", expiredCookieAttributes).toHeaders();
|
|
414
|
+
return Response.json({ oauth: oauth2 }, { status: 302, headers });
|
|
415
|
+
},
|
|
416
|
+
callbackConfig(oauth)
|
|
417
|
+
);
|
|
418
|
+
};
|
|
531
419
|
// Annotate the CommonJS export names for ESM import in node:
|
|
532
|
-
0 &&
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
})
|
|
420
|
+
0 && (module.exports = {
|
|
421
|
+
callbackAction
|
|
422
|
+
});
|