@aura-stack/auth 0.1.0-rc.8 → 0.1.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 +7 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +7 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +6 -6
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +143 -143
- package/dist/actions/callback/access-token.d.ts +15 -20
- package/dist/actions/callback/access-token.js +8 -4
- package/dist/actions/callback/callback.cjs +437 -455
- package/dist/actions/callback/callback.d.ts +10 -12
- package/dist/actions/callback/callback.js +16 -12
- package/dist/actions/callback/userinfo.cjs +131 -134
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +10 -6
- package/dist/actions/csrfToken/csrfToken.cjs +162 -171
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +12 -8
- package/dist/actions/index.cjs +746 -773
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +34 -18
- package/dist/actions/session/session.cjs +149 -155
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +11 -7
- package/dist/actions/signIn/authorization.cjs +231 -249
- package/dist/actions/signIn/authorization.d.ts +12 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +396 -423
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +14 -10
- package/dist/actions/signOut/signOut.cjs +417 -440
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +15 -11
- package/dist/assert.cjs +35 -36
- package/dist/assert.d.ts +4 -4
- package/dist/assert.js +10 -2
- package/dist/chunk-256KIVJL.js +85 -96
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-6SM22VVJ.js +13 -10
- package/dist/chunk-CAKJT3KS.js +84 -69
- package/dist/chunk-E3OXBRYF.js +19 -17
- package/dist/chunk-EBPE35JT.js +28 -26
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FJUDBLCP.js +50 -43
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-GZU3RBTB.js +51 -40
- package/dist/chunk-HGJ4TXY4.js +132 -100
- package/dist/chunk-HMRKN75I.js +63 -63
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-JAPMIE6S.js +7 -5
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-LLR722CL.js +91 -70
- package/dist/chunk-RLT4RFKV.js +39 -30
- package/dist/chunk-SJPDVKUS.js +107 -88
- package/dist/chunk-SMQO5WD7.js +26 -16
- package/dist/chunk-STHEPPUZ.js +8 -6
- package/dist/chunk-UJJ7R56J.js +47 -37
- package/dist/chunk-UTDLUEEG.js +27 -21
- package/dist/chunk-VFTYH33W.js +54 -37
- package/dist/chunk-XXJKNKGQ.js +33 -23
- package/dist/chunk-ZV4BH47P.js +132 -134
- package/dist/cookie.cjs +169 -175
- package/dist/cookie.d.ts +23 -51
- package/dist/cookie.js +34 -34
- package/dist/error.cjs +75 -75
- package/dist/error.d.ts +30 -30
- package/dist/error.js +15 -8
- 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 +249 -298
- package/dist/index.cjs +936 -969
- package/dist/index.d.ts +10 -31
- package/dist/index.js +70 -50
- package/dist/jose.cjs +61 -64
- package/dist/jose.d.ts +8 -8
- package/dist/jose.js +9 -5
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +7 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +48 -48
- package/dist/oauth/discord.d.ts +7 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +7 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +7 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +7 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +180 -180
- package/dist/oauth/index.d.ts +7 -26
- package/dist/oauth/index.js +36 -9
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +7 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +6 -2
- package/dist/response.cjs +27 -27
- package/dist/response.d.ts +2 -2
- package/dist/response.js +6 -2
- package/dist/schemas.cjs +91 -91
- package/dist/schemas.d.ts +93 -126
- package/dist/schemas.js +18 -18
- package/dist/secure.cjs +95 -98
- package/dist/secure.d.ts +17 -17
- package/dist/secure.js +18 -4
- package/dist/utils.cjs +119 -132
- package/dist/utils.d.ts +11 -26
- package/dist/utils.js +21 -21
- package/package.json +2 -2
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { signInAction } from
|
|
2
|
-
export { callbackAction } from
|
|
3
|
-
export { sessionAction } from
|
|
4
|
-
export { signOutAction } from
|
|
5
|
-
export { csrfTokenAction } from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
export { signInAction } from './signIn/signIn.js';
|
|
2
|
+
export { callbackAction } from './callback/callback.js';
|
|
3
|
+
export { sessionAction } from './session/session.js';
|
|
4
|
+
export { signOutAction } from './signOut/signOut.js';
|
|
5
|
+
export { csrfTokenAction } from './csrfToken/csrfToken.js';
|
|
6
|
+
import '@aura-stack/router';
|
|
7
|
+
import '../index-DpfbvTZ_.js';
|
|
8
|
+
import 'zod/v4';
|
|
9
|
+
import '@aura-stack/jose/jose';
|
|
10
|
+
import '../schemas.js';
|
|
11
|
+
import 'zod/v4/core';
|
|
12
|
+
import 'cookie';
|
|
13
|
+
import '../@types/utility.js';
|
package/dist/actions/index.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import "../chunk-ITQ7352M.js"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import "../chunk-ITQ7352M.js";
|
|
2
|
+
import {
|
|
3
|
+
csrfTokenAction
|
|
4
|
+
} from "../chunk-SMQO5WD7.js";
|
|
5
|
+
import {
|
|
6
|
+
sessionAction
|
|
7
|
+
} from "../chunk-XXJKNKGQ.js";
|
|
8
|
+
import {
|
|
9
|
+
signInAction
|
|
10
|
+
} from "../chunk-LLR722CL.js";
|
|
11
|
+
import {
|
|
12
|
+
signOutAction
|
|
13
|
+
} from "../chunk-SJPDVKUS.js";
|
|
14
|
+
import "../chunk-CAKJT3KS.js";
|
|
15
|
+
import {
|
|
16
|
+
callbackAction
|
|
17
|
+
} from "../chunk-HGJ4TXY4.js";
|
|
18
|
+
import "../chunk-RLT4RFKV.js";
|
|
19
|
+
import "../chunk-UJJ7R56J.js";
|
|
20
|
+
import "../chunk-ZV4BH47P.js";
|
|
21
|
+
import "../chunk-6SM22VVJ.js";
|
|
22
|
+
import "../chunk-STHEPPUZ.js";
|
|
23
|
+
import "../chunk-GZU3RBTB.js";
|
|
24
|
+
import "../chunk-256KIVJL.js";
|
|
25
|
+
import "../chunk-FJUDBLCP.js";
|
|
26
|
+
import "../chunk-JAPMIE6S.js";
|
|
27
|
+
import "../chunk-HMRKN75I.js";
|
|
28
|
+
export {
|
|
29
|
+
callbackAction,
|
|
30
|
+
csrfTokenAction,
|
|
31
|
+
sessionAction,
|
|
32
|
+
signInAction,
|
|
33
|
+
signOutAction
|
|
34
|
+
};
|
|
@@ -1,197 +1,191 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
var __defProp = Object.defineProperty
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
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
6
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
}
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
9
10
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
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);
|
|
18
19
|
|
|
19
20
|
// src/actions/session/session.ts
|
|
20
|
-
var session_exports = {}
|
|
21
|
+
var session_exports = {};
|
|
21
22
|
__export(session_exports, {
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
module.exports = __toCommonJS(session_exports)
|
|
25
|
-
var import_router2 = require("@aura-stack/router")
|
|
23
|
+
sessionAction: () => sessionAction
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(session_exports);
|
|
26
|
+
var import_router2 = require("@aura-stack/router");
|
|
26
27
|
|
|
27
28
|
// src/utils.ts
|
|
28
|
-
var import_router = require("@aura-stack/router")
|
|
29
|
+
var import_router = require("@aura-stack/router");
|
|
29
30
|
|
|
30
31
|
// src/error.ts
|
|
31
32
|
var AuthError = class extends Error {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
33
|
+
constructor(type, message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.type = type;
|
|
36
|
+
this.name = "AuthError";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
38
39
|
|
|
39
40
|
// src/utils.ts
|
|
40
41
|
var toISOString = (date) => {
|
|
41
|
-
|
|
42
|
-
}
|
|
42
|
+
return new Date(date).toISOString();
|
|
43
|
+
};
|
|
43
44
|
|
|
44
45
|
// src/headers.ts
|
|
45
46
|
var cacheControl = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
47
|
+
"Cache-Control": "no-store",
|
|
48
|
+
Pragma: "no-cache",
|
|
49
|
+
Expires: "0",
|
|
50
|
+
Vary: "Cookie"
|
|
51
|
+
};
|
|
51
52
|
|
|
52
53
|
// src/cookie.ts
|
|
53
|
-
var import_cookie = require("cookie")
|
|
54
|
+
var import_cookie = require("cookie");
|
|
54
55
|
|
|
55
56
|
// src/assert.ts
|
|
56
57
|
var isRequest = (value) => {
|
|
57
|
-
|
|
58
|
-
}
|
|
58
|
+
return typeof Request !== "undefined" && value instanceof Request;
|
|
59
|
+
};
|
|
59
60
|
|
|
60
61
|
// src/cookie.ts
|
|
61
|
-
var import_cookie2 = require("cookie")
|
|
62
|
-
var COOKIE_NAME = "aura-auth"
|
|
62
|
+
var import_cookie2 = require("cookie");
|
|
63
|
+
var COOKIE_NAME = "aura-auth";
|
|
63
64
|
var defaultCookieOptions = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
65
|
+
httpOnly: true,
|
|
66
|
+
sameSite: "lax",
|
|
67
|
+
path: "/",
|
|
68
|
+
maxAge: 60 * 60 * 24 * 15
|
|
69
|
+
};
|
|
69
70
|
var defaultStandardCookieConfig = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
71
|
+
secure: false,
|
|
72
|
+
httpOnly: true,
|
|
73
|
+
prefix: ""
|
|
74
|
+
};
|
|
74
75
|
var defaultSecureCookieConfig = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
76
|
+
secure: true,
|
|
77
|
+
prefix: "__Secure-"
|
|
78
|
+
};
|
|
78
79
|
var defaultHostCookieConfig = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
80
|
+
secure: true,
|
|
81
|
+
prefix: "__Host-",
|
|
82
|
+
path: "/",
|
|
83
|
+
domain: void 0
|
|
84
|
+
};
|
|
84
85
|
var expiredCookieOptions = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
86
|
+
...defaultCookieOptions,
|
|
87
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
88
|
+
maxAge: 0
|
|
89
|
+
};
|
|
89
90
|
var defineDefaultCookieOptions = (options) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
91
|
+
return {
|
|
92
|
+
name: options?.name ?? COOKIE_NAME,
|
|
93
|
+
prefix: options?.prefix ?? (options?.secure ? "__Secure-" : ""),
|
|
94
|
+
...defaultCookieOptions,
|
|
95
|
+
...options
|
|
96
|
+
};
|
|
97
|
+
};
|
|
97
98
|
var setCookie = (cookieName, value, options) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
99
|
+
const { prefix, name } = defineDefaultCookieOptions(options);
|
|
100
|
+
const cookieNameWithPrefix = `${prefix}${name}.${cookieName}`;
|
|
101
|
+
return (0, import_cookie.serialize)(cookieNameWithPrefix, value, {
|
|
102
|
+
...defaultCookieOptions,
|
|
103
|
+
...options
|
|
104
|
+
});
|
|
105
|
+
};
|
|
105
106
|
var getCookie = (petition, cookie, options, optional = false) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
throw new AuthError("invalid_request", "No cookies found. There is no active session")
|
|
107
|
+
const cookies = isRequest(petition) ? petition.headers.get("Cookie") : petition.headers.getSetCookie().join("; ");
|
|
108
|
+
if (!cookies) {
|
|
109
|
+
if (optional) {
|
|
110
|
+
return "";
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
throw new AuthError("invalid_request", "No cookies found. There is no active session");
|
|
113
|
+
}
|
|
114
|
+
const { name, prefix } = defineDefaultCookieOptions(options);
|
|
115
|
+
const parsedCookies = (0, import_cookie.parse)(cookies);
|
|
116
|
+
const value = parsedCookies[`${prefix}${name}.${cookie}`];
|
|
117
|
+
if (value === void 0) {
|
|
118
|
+
if (optional) {
|
|
119
|
+
return "";
|
|
121
120
|
}
|
|
122
|
-
|
|
123
|
-
}
|
|
121
|
+
throw new AuthError("invalid_request", `Cookie "${cookie}" not found. There is no active session`);
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
};
|
|
124
125
|
var secureCookieOptions = (request, cookieOptions, trustedProxyHeaders) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
const name = cookieOptions.name ?? COOKIE_NAME;
|
|
127
|
+
const isSecure = trustedProxyHeaders ? request.url.startsWith("https://") || request.headers.get("X-Forwarded-Proto") === "https" || request.headers.get("Forwarded")?.includes("proto=https") : request.url.startsWith("https://");
|
|
128
|
+
if (!cookieOptions.options?.httpOnly) {
|
|
129
|
+
console.warn(
|
|
130
|
+
"[WARNING]: Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS risk."
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (cookieOptions.options?.domain === "*") {
|
|
134
|
+
console.warn("[WARNING]: Cookie 'Domain' is set to '*', which is insecure. Avoid wildcard domains.");
|
|
135
|
+
}
|
|
136
|
+
if (!isSecure) {
|
|
137
|
+
const options = cookieOptions.options;
|
|
138
|
+
if (options?.secure) {
|
|
139
|
+
console.warn(
|
|
140
|
+
"[WARNING]: The 'Secure' attribute will be disabled for this cookie. Serve over HTTPS to enforce Secure cookies."
|
|
141
|
+
);
|
|
135
142
|
}
|
|
136
|
-
if (
|
|
137
|
-
|
|
143
|
+
if (options?.sameSite == "none") {
|
|
144
|
+
console.warn("[WARNING]: SameSite=None without a secure connection can be blocked by browsers.");
|
|
138
145
|
}
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
if (options?.secure) {
|
|
142
|
-
console.warn(
|
|
143
|
-
"[WARNING]: The 'Secure' attribute will be disabled for this cookie. Serve over HTTPS to enforce Secure cookies."
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
if (options?.sameSite == "none") {
|
|
147
|
-
console.warn("[WARNING]: SameSite=None without a secure connection can be blocked by browsers.")
|
|
148
|
-
}
|
|
149
|
-
if (process.env.NODE_ENV === "production") {
|
|
150
|
-
console.warn("[WARNING]: In production, ensure cookies are served over HTTPS to maintain security.")
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
...defaultCookieOptions,
|
|
154
|
-
...cookieOptions.options,
|
|
155
|
-
sameSite: options?.sameSite === "none" ? "lax" : (options?.sameSite ?? "lax"),
|
|
156
|
-
...defaultStandardCookieConfig,
|
|
157
|
-
name,
|
|
158
|
-
}
|
|
146
|
+
if (process.env.NODE_ENV === "production") {
|
|
147
|
+
console.warn("[WARNING]: In production, ensure cookies are served over HTTPS to maintain security.");
|
|
159
148
|
}
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
149
|
+
return {
|
|
150
|
+
...defaultCookieOptions,
|
|
151
|
+
...cookieOptions.options,
|
|
152
|
+
sameSite: options?.sameSite === "none" ? "lax" : options?.sameSite ?? "lax",
|
|
153
|
+
...defaultStandardCookieConfig,
|
|
154
|
+
name
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return cookieOptions.strategy === "host" ? {
|
|
158
|
+
...defaultCookieOptions,
|
|
159
|
+
...cookieOptions.options,
|
|
160
|
+
...defaultHostCookieConfig,
|
|
161
|
+
name
|
|
162
|
+
} : { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name };
|
|
163
|
+
};
|
|
169
164
|
var expireCookie = (name, options) => {
|
|
170
|
-
|
|
171
|
-
}
|
|
165
|
+
return setCookie(name, "", { ...options, ...expiredCookieOptions });
|
|
166
|
+
};
|
|
172
167
|
|
|
173
168
|
// src/actions/session/session.ts
|
|
174
169
|
var sessionAction = (0, import_router2.createEndpoint)("GET", "/session", async (ctx) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
})
|
|
170
|
+
const {
|
|
171
|
+
request,
|
|
172
|
+
context: { cookies, jose, trustedProxyHeaders }
|
|
173
|
+
} = ctx;
|
|
174
|
+
const cookieOptions = secureCookieOptions(request, cookies, trustedProxyHeaders);
|
|
175
|
+
try {
|
|
176
|
+
const session = getCookie(request, "sessionToken", cookieOptions);
|
|
177
|
+
const decoded = await jose.decodeJWT(session);
|
|
178
|
+
const { exp, iat, jti, nbf, ...user } = decoded;
|
|
179
|
+
const headers = new Headers(cacheControl);
|
|
180
|
+
return Response.json({ user, expires: toISOString(exp * 1e3) }, { headers });
|
|
181
|
+
} catch {
|
|
182
|
+
const headers = new Headers(cacheControl);
|
|
183
|
+
const sessionCookie = expireCookie("sessionToken", cookieOptions);
|
|
184
|
+
headers.set("Set-Cookie", sessionCookie);
|
|
185
|
+
return Response.json({ authenticated: false, message: "Unauthorized" }, { status: 401, headers });
|
|
186
|
+
}
|
|
187
|
+
});
|
|
193
188
|
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
-
0 &&
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
})
|
|
189
|
+
0 && (module.exports = {
|
|
190
|
+
sessionAction
|
|
191
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as _aura_stack_router from
|
|
1
|
+
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
2
|
|
|
3
|
-
declare const sessionAction: _aura_stack_router.RouteEndpoint<"GET", "/session", {}
|
|
3
|
+
declare const sessionAction: _aura_stack_router.RouteEndpoint<"GET", "/session", {}>;
|
|
4
4
|
|
|
5
|
-
export { sessionAction }
|
|
5
|
+
export { sessionAction };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
sessionAction
|
|
3
|
+
} from "../../chunk-XXJKNKGQ.js";
|
|
4
|
+
import "../../chunk-ZV4BH47P.js";
|
|
5
|
+
import "../../chunk-6SM22VVJ.js";
|
|
6
|
+
import "../../chunk-STHEPPUZ.js";
|
|
7
|
+
import "../../chunk-256KIVJL.js";
|
|
8
|
+
import "../../chunk-FJUDBLCP.js";
|
|
9
|
+
export {
|
|
10
|
+
sessionAction
|
|
11
|
+
};
|