@aura-stack/auth 0.1.0-rc.9 → 0.2.0-rc.1
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 +4 -8
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +176 -155
- package/dist/actions/callback/access-token.d.ts +15 -20
- package/dist/actions/callback/access-token.js +10 -4
- package/dist/actions/callback/callback.cjs +394 -490
- package/dist/actions/callback/callback.d.ts +10 -12
- package/dist/actions/callback/callback.js +16 -12
- package/dist/actions/callback/userinfo.cjs +166 -145
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +12 -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 +652 -814
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +34 -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 +254 -263
- package/dist/actions/signIn/authorization.d.ts +12 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +320 -456
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +13 -10
- package/dist/actions/signOut/signOut.cjs +304 -473
- 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 +13 -4
- package/dist/assert.js +12 -2
- package/dist/chunk-3EUWD5BB.js +63 -0
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-A3N4PVAT.js +70 -0
- package/dist/chunk-B737EUJV.js +22 -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-EMKJA2GJ.js +89 -0
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-GA2SMTJO.js +58 -0
- package/dist/chunk-HP34YGGJ.js +22 -0
- package/dist/chunk-HT4YLL7N.js +35 -0
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-IUYZQTJV.js +30 -0
- package/dist/chunk-IVET23KF.js +58 -0
- package/dist/chunk-JVFTCTTE.js +33 -0
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-KSWLO5ZU.js +102 -0
- package/dist/chunk-N2APGLXA.js +71 -0
- package/dist/chunk-N4SX7TZT.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-W6LG7BFW.js +197 -0
- package/dist/chunk-YRCB5FLE.js +79 -0
- package/dist/chunk-ZNCZVF6U.js +14 -0
- package/dist/cookie.cjs +222 -187
- package/dist/cookie.d.ts +39 -76
- package/dist/cookie.js +27 -34
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +49 -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-DkaLJFn8.d.ts +679 -0
- package/dist/index.cjs +1074 -1007
- package/dist/index.d.ts +10 -31
- package/dist/index.js +85 -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 +7 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +47 -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 +350 -180
- package/dist/oauth/index.d.ts +7 -26
- package/dist/oauth/index.js +51 -9
- package/dist/oauth/mailchimp.cjs +46 -0
- package/dist/oauth/mailchimp.d.ts +7 -0
- package/dist/oauth/mailchimp.js +6 -0
- package/dist/oauth/pinterest.cjs +46 -0
- package/dist/oauth/pinterest.d.ts +7 -0
- package/dist/oauth/pinterest.js +6 -0
- 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/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +7 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +6 -2
- package/dist/request.cjs +38 -0
- package/dist/request.d.ts +13 -0
- package/dist/request.js +6 -0
- package/dist/schemas.cjs +103 -97
- package/dist/schemas.d.ts +96 -126
- package/dist/schemas.js +20 -18
- package/dist/secure.cjs +106 -101
- package/dist/secure.d.ts +17 -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 +8 -7
- 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/index-DpfbvTZ_.d.ts +0 -597
- package/dist/response.cjs +0 -34
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -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-DkaLJFn8.js';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import '../schemas.js';
|
|
10
|
+
import '@aura-stack/router/cookie';
|
|
11
|
+
import '@aura-stack/jose';
|
|
12
|
+
import '@aura-stack/jose/jose';
|
|
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 "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import "../chunk-ITQ7352M.js";
|
|
2
|
+
import {
|
|
3
|
+
signOutAction
|
|
4
|
+
} from "../chunk-A3N4PVAT.js";
|
|
5
|
+
import {
|
|
6
|
+
callbackAction
|
|
7
|
+
} from "../chunk-KSWLO5ZU.js";
|
|
8
|
+
import "../chunk-GA2SMTJO.js";
|
|
9
|
+
import "../chunk-IVET23KF.js";
|
|
10
|
+
import {
|
|
11
|
+
csrfTokenAction
|
|
12
|
+
} from "../chunk-HT4YLL7N.js";
|
|
13
|
+
import {
|
|
14
|
+
sessionAction
|
|
15
|
+
} from "../chunk-JVFTCTTE.js";
|
|
16
|
+
import {
|
|
17
|
+
signInAction
|
|
18
|
+
} from "../chunk-3EUWD5BB.js";
|
|
19
|
+
import "../chunk-N4SX7TZT.js";
|
|
20
|
+
import "../chunk-W6LG7BFW.js";
|
|
21
|
+
import "../chunk-STHEPPUZ.js";
|
|
22
|
+
import "../chunk-N2APGLXA.js";
|
|
23
|
+
import "../chunk-CXLATHS5.js";
|
|
24
|
+
import "../chunk-EIL2FPSS.js";
|
|
25
|
+
import "../chunk-RRLIF4PQ.js";
|
|
26
|
+
import "../chunk-ZNCZVF6U.js";
|
|
27
|
+
import "../chunk-YRCB5FLE.js";
|
|
28
|
+
export {
|
|
29
|
+
callbackAction,
|
|
30
|
+
csrfTokenAction,
|
|
31
|
+
sessionAction,
|
|
32
|
+
signInAction,
|
|
33
|
+
signOutAction
|
|
34
|
+
};
|
|
@@ -1,197 +1,107 @@
|
|
|
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
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
// src/errors.ts
|
|
32
|
+
var AuthInternalError = class extends Error {
|
|
33
|
+
type = "AUTH_INTERNAL_ERROR";
|
|
34
|
+
code;
|
|
35
|
+
constructor(code, message, options) {
|
|
36
|
+
super(message, options);
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.name = new.target.name;
|
|
39
|
+
Error.captureStackTrace(this, new.target);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
38
42
|
|
|
39
43
|
// src/utils.ts
|
|
40
44
|
var toISOString = (date) => {
|
|
41
|
-
|
|
42
|
-
}
|
|
45
|
+
return new Date(date).toISOString();
|
|
46
|
+
};
|
|
43
47
|
|
|
44
48
|
// src/headers.ts
|
|
45
49
|
var cacheControl = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
50
|
+
"Cache-Control": "no-store",
|
|
51
|
+
Pragma: "no-cache",
|
|
52
|
+
Expires: "0",
|
|
53
|
+
Vary: "Cookie"
|
|
54
|
+
};
|
|
51
55
|
|
|
52
56
|
// src/cookie.ts
|
|
53
|
-
var import_cookie = require("cookie")
|
|
54
|
-
|
|
55
|
-
// src/assert.ts
|
|
56
|
-
var isRequest = (value) => {
|
|
57
|
-
return typeof Request !== "undefined" && value instanceof Request
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// src/cookie.ts
|
|
61
|
-
var import_cookie2 = require("cookie")
|
|
62
|
-
var COOKIE_NAME = "aura-auth"
|
|
57
|
+
var import_cookie = require("@aura-stack/router/cookie");
|
|
63
58
|
var defaultCookieOptions = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
name: options?.name ?? COOKIE_NAME,
|
|
92
|
-
prefix: options?.prefix ?? (options?.secure ? "__Secure-" : ""),
|
|
93
|
-
...defaultCookieOptions,
|
|
94
|
-
...options,
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
var setCookie = (cookieName, value, options) => {
|
|
98
|
-
const { prefix, name } = defineDefaultCookieOptions(options)
|
|
99
|
-
const cookieNameWithPrefix = `${prefix}${name}.${cookieName}`
|
|
100
|
-
return (0, import_cookie.serialize)(cookieNameWithPrefix, value, {
|
|
101
|
-
...defaultCookieOptions,
|
|
102
|
-
...options,
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
var getCookie = (petition, cookie, options, optional = false) => {
|
|
106
|
-
const cookies = isRequest(petition) ? petition.headers.get("Cookie") : petition.headers.getSetCookie().join("; ")
|
|
107
|
-
if (!cookies) {
|
|
108
|
-
if (optional) {
|
|
109
|
-
return ""
|
|
110
|
-
}
|
|
111
|
-
throw new AuthError("invalid_request", "No cookies found. There is no active session")
|
|
112
|
-
}
|
|
113
|
-
const { name, prefix } = defineDefaultCookieOptions(options)
|
|
114
|
-
const parsedCookies = (0, import_cookie.parse)(cookies)
|
|
115
|
-
const value = parsedCookies[`${prefix}${name}.${cookie}`]
|
|
116
|
-
if (value === void 0) {
|
|
117
|
-
if (optional) {
|
|
118
|
-
return ""
|
|
119
|
-
}
|
|
120
|
-
throw new AuthError("invalid_request", `Cookie "${cookie}" not found. There is no active session`)
|
|
121
|
-
}
|
|
122
|
-
return value
|
|
123
|
-
}
|
|
124
|
-
var secureCookieOptions = (request, cookieOptions, trustedProxyHeaders) => {
|
|
125
|
-
const name = cookieOptions.name ?? COOKIE_NAME
|
|
126
|
-
const isSecure = trustedProxyHeaders
|
|
127
|
-
? request.url.startsWith("https://") ||
|
|
128
|
-
request.headers.get("X-Forwarded-Proto") === "https" ||
|
|
129
|
-
request.headers.get("Forwarded")?.includes("proto=https")
|
|
130
|
-
: request.url.startsWith("https://")
|
|
131
|
-
if (!cookieOptions.options?.httpOnly) {
|
|
132
|
-
console.warn(
|
|
133
|
-
"[WARNING]: Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS risk."
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
if (cookieOptions.options?.domain === "*") {
|
|
137
|
-
console.warn("[WARNING]: Cookie 'Domain' is set to '*', which is insecure. Avoid wildcard domains.")
|
|
138
|
-
}
|
|
139
|
-
if (!isSecure) {
|
|
140
|
-
const options = cookieOptions.options
|
|
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
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return cookieOptions.strategy === "host"
|
|
161
|
-
? {
|
|
162
|
-
...defaultCookieOptions,
|
|
163
|
-
...cookieOptions.options,
|
|
164
|
-
...defaultHostCookieConfig,
|
|
165
|
-
name,
|
|
166
|
-
}
|
|
167
|
-
: { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name }
|
|
168
|
-
}
|
|
169
|
-
var expireCookie = (name, options) => {
|
|
170
|
-
return setCookie(name, "", { ...options, ...expiredCookieOptions })
|
|
171
|
-
}
|
|
59
|
+
httpOnly: true,
|
|
60
|
+
sameSite: "lax",
|
|
61
|
+
path: "/",
|
|
62
|
+
maxAge: 60 * 60 * 24 * 15
|
|
63
|
+
};
|
|
64
|
+
var oauthCookieOptions = {
|
|
65
|
+
httpOnly: true,
|
|
66
|
+
maxAge: 5 * 60,
|
|
67
|
+
sameSite: "lax",
|
|
68
|
+
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
69
|
+
};
|
|
70
|
+
var expiredCookieAttributes = {
|
|
71
|
+
...defaultCookieOptions,
|
|
72
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
73
|
+
maxAge: 0
|
|
74
|
+
};
|
|
75
|
+
var getCookie = (request, cookieName) => {
|
|
76
|
+
const cookies = request.headers.get("Cookie");
|
|
77
|
+
if (!cookies) {
|
|
78
|
+
throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
|
|
79
|
+
}
|
|
80
|
+
const value = (0, import_cookie.parse)(cookies)[cookieName];
|
|
81
|
+
if (!value) {
|
|
82
|
+
throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found. There is no active session`);
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
};
|
|
172
86
|
|
|
173
87
|
// src/actions/session/session.ts
|
|
174
88
|
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
|
-
return Response.json({ authenticated: false, message: "Unauthorized" }, { status: 401, headers })
|
|
191
|
-
}
|
|
192
|
-
})
|
|
89
|
+
const {
|
|
90
|
+
request,
|
|
91
|
+
context: { jose, cookies }
|
|
92
|
+
} = ctx;
|
|
93
|
+
try {
|
|
94
|
+
const session = getCookie(request, cookies.sessionToken.name);
|
|
95
|
+
const decoded = await jose.decodeJWT(session);
|
|
96
|
+
const { exp, iat, jti, nbf, ...user } = decoded;
|
|
97
|
+
const headers = new Headers(cacheControl);
|
|
98
|
+
return Response.json({ user, expires: toISOString(exp * 1e3) }, { headers });
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const headers = new import_router2.HeadersBuilder(cacheControl).setCookie(cookies.sessionToken.name, "", expiredCookieAttributes).toHeaders();
|
|
101
|
+
return Response.json({ authenticated: false, message: "Unauthorized" }, { status: 401, headers });
|
|
102
|
+
}
|
|
103
|
+
});
|
|
193
104
|
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
-
0 &&
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
})
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
sessionAction
|
|
107
|
+
});
|
|
@@ -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,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
sessionAction
|
|
3
|
+
} from "../../chunk-JVFTCTTE.js";
|
|
4
|
+
import "../../chunk-W6LG7BFW.js";
|
|
5
|
+
import "../../chunk-STHEPPUZ.js";
|
|
6
|
+
import "../../chunk-CXLATHS5.js";
|
|
7
|
+
import "../../chunk-RRLIF4PQ.js";
|
|
8
|
+
export {
|
|
9
|
+
sessionAction
|
|
10
|
+
};
|