@aura-stack/auth 0.1.0-rc.7 → 0.1.0-rc.9
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 +31 -7
- 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 +20 -15
- package/dist/actions/callback/access-token.js +4 -8
- package/dist/actions/callback/callback.cjs +455 -437
- package/dist/actions/callback/callback.d.ts +12 -10
- package/dist/actions/callback/callback.js +12 -16
- package/dist/actions/callback/userinfo.cjs +134 -131
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +6 -10
- package/dist/actions/csrfToken/csrfToken.cjs +171 -162
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +8 -12
- package/dist/actions/index.cjs +773 -746
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +18 -34
- package/dist/actions/session/session.cjs +155 -149
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +7 -11
- package/dist/actions/signIn/authorization.cjs +249 -231
- package/dist/actions/signIn/authorization.d.ts +18 -12
- package/dist/actions/signIn/authorization.js +6 -16
- package/dist/actions/signIn/signIn.cjs +423 -396
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +10 -14
- package/dist/actions/signOut/signOut.cjs +440 -417
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +11 -15
- package/dist/assert.cjs +36 -35
- package/dist/assert.d.ts +4 -4
- package/dist/assert.js +2 -10
- package/dist/chunk-256KIVJL.js +96 -85
- package/dist/chunk-42XB3YCW.js +17 -19
- package/dist/chunk-6SM22VVJ.js +10 -13
- package/dist/chunk-CAKJT3KS.js +69 -84
- package/dist/chunk-E3OXBRYF.js +17 -19
- package/dist/chunk-EBPE35JT.js +26 -28
- package/dist/chunk-FIPU4MLT.js +16 -18
- package/dist/chunk-FJUDBLCP.js +43 -50
- package/dist/chunk-FKRDCWBF.js +17 -19
- package/dist/chunk-GZU3RBTB.js +40 -51
- package/dist/chunk-HGJ4TXY4.js +100 -132
- package/dist/chunk-HMRKN75I.js +63 -63
- package/dist/chunk-IKHPGFCW.js +9 -11
- package/dist/chunk-JAPMIE6S.js +5 -7
- package/dist/chunk-KRNOMBXQ.js +17 -19
- package/dist/chunk-LLR722CL.js +70 -91
- package/dist/chunk-RLT4RFKV.js +30 -39
- package/dist/chunk-SJPDVKUS.js +88 -107
- package/dist/chunk-SMQO5WD7.js +16 -26
- package/dist/chunk-STHEPPUZ.js +6 -8
- package/dist/chunk-UJJ7R56J.js +37 -47
- package/dist/chunk-UTDLUEEG.js +25 -0
- package/dist/chunk-VFTYH33W.js +37 -54
- package/dist/chunk-XXJKNKGQ.js +23 -33
- package/dist/chunk-ZV4BH47P.js +134 -132
- package/dist/cookie.cjs +175 -169
- package/dist/cookie.d.ts +51 -23
- package/dist/cookie.js +34 -34
- package/dist/error.cjs +75 -75
- package/dist/error.d.ts +30 -30
- package/dist/error.js +8 -15
- package/dist/headers.cjs +28 -28
- package/dist/headers.d.ts +2 -2
- package/dist/headers.js +2 -6
- package/dist/index-DpfbvTZ_.d.ts +298 -249
- package/dist/index.cjs +969 -933
- package/dist/index.d.ts +31 -10
- package/dist/index.js +50 -70
- package/dist/jose.cjs +67 -52
- package/dist/jose.d.ts +8 -8
- package/dist/jose.js +5 -9
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +7 -7
- package/dist/oauth/bitbucket.js +2 -6
- package/dist/oauth/discord.cjs +48 -48
- package/dist/oauth/discord.d.ts +7 -7
- package/dist/oauth/discord.js +2 -6
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +7 -7
- package/dist/oauth/figma.js +2 -6
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +7 -7
- package/dist/oauth/github.js +2 -6
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +7 -7
- package/dist/oauth/gitlab.js +2 -6
- package/dist/oauth/index.cjs +180 -180
- package/dist/oauth/index.d.ts +26 -7
- package/dist/oauth/index.js +9 -36
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +7 -7
- package/dist/oauth/spotify.js +2 -6
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +2 -6
- package/dist/response.cjs +27 -27
- package/dist/response.d.ts +2 -2
- package/dist/response.js +2 -6
- package/dist/schemas.cjs +91 -91
- package/dist/schemas.d.ts +126 -93
- package/dist/schemas.js +18 -18
- package/dist/secure.cjs +98 -95
- package/dist/secure.d.ts +17 -17
- package/dist/secure.js +4 -18
- package/dist/utils.cjs +132 -119
- package/dist/utils.d.ts +26 -11
- package/dist/utils.js +21 -21
- package/package.json +1 -1
- package/dist/chunk-X7M4CQTN.js +0 -25
package/dist/cookie.cjs
CHANGED
|
@@ -1,201 +1,207 @@
|
|
|
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
|
-
|
|
9
|
-
};
|
|
7
|
+
for (var name in all) __defProp(target, name, { get: all[name], enumerable: true })
|
|
8
|
+
}
|
|
10
9
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
10
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
|
|
14
|
+
}
|
|
15
|
+
return to
|
|
16
|
+
}
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
19
18
|
|
|
20
19
|
// src/cookie.ts
|
|
21
|
-
var cookie_exports = {}
|
|
20
|
+
var cookie_exports = {}
|
|
22
21
|
__export(cookie_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
39
|
-
module.exports = __toCommonJS(cookie_exports)
|
|
40
|
-
var import_cookie = require("cookie")
|
|
22
|
+
COOKIE_NAME: () => COOKIE_NAME,
|
|
23
|
+
createSessionCookie: () => createSessionCookie,
|
|
24
|
+
defaultCookieConfig: () => defaultCookieConfig,
|
|
25
|
+
defaultCookieOptions: () => defaultCookieOptions,
|
|
26
|
+
defaultHostCookieConfig: () => defaultHostCookieConfig,
|
|
27
|
+
defaultSecureCookieConfig: () => defaultSecureCookieConfig,
|
|
28
|
+
defaultStandardCookieConfig: () => defaultStandardCookieConfig,
|
|
29
|
+
defineDefaultCookieOptions: () => defineDefaultCookieOptions,
|
|
30
|
+
expireCookie: () => expireCookie,
|
|
31
|
+
expiredCookieOptions: () => expiredCookieOptions,
|
|
32
|
+
getCookie: () => getCookie,
|
|
33
|
+
oauthCookie: () => oauthCookie,
|
|
34
|
+
parse: () => import_cookie2.parse,
|
|
35
|
+
secureCookieOptions: () => secureCookieOptions,
|
|
36
|
+
setCookie: () => setCookie,
|
|
37
|
+
})
|
|
38
|
+
module.exports = __toCommonJS(cookie_exports)
|
|
39
|
+
var import_cookie = require("cookie")
|
|
41
40
|
|
|
42
41
|
// src/error.ts
|
|
43
42
|
var AuthError = class extends Error {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
43
|
+
constructor(type, message) {
|
|
44
|
+
super(message)
|
|
45
|
+
this.type = type
|
|
46
|
+
this.name = "AuthError"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
50
49
|
|
|
51
50
|
// src/assert.ts
|
|
52
51
|
var isRequest = (value) => {
|
|
53
|
-
|
|
54
|
-
}
|
|
52
|
+
return typeof Request !== "undefined" && value instanceof Request
|
|
53
|
+
}
|
|
55
54
|
|
|
56
55
|
// src/cookie.ts
|
|
57
|
-
var import_cookie2 = require("cookie")
|
|
58
|
-
var COOKIE_NAME = "aura-auth"
|
|
56
|
+
var import_cookie2 = require("cookie")
|
|
57
|
+
var COOKIE_NAME = "aura-auth"
|
|
59
58
|
var defaultCookieOptions = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
59
|
+
httpOnly: true,
|
|
60
|
+
sameSite: "lax",
|
|
61
|
+
path: "/",
|
|
62
|
+
maxAge: 60 * 60 * 24 * 15,
|
|
63
|
+
}
|
|
65
64
|
var defaultCookieConfig = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
65
|
+
strategy: "standard",
|
|
66
|
+
name: COOKIE_NAME,
|
|
67
|
+
options: defaultCookieOptions,
|
|
68
|
+
}
|
|
70
69
|
var defaultStandardCookieConfig = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
70
|
+
secure: false,
|
|
71
|
+
httpOnly: true,
|
|
72
|
+
prefix: "",
|
|
73
|
+
}
|
|
75
74
|
var defaultSecureCookieConfig = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
75
|
+
secure: true,
|
|
76
|
+
prefix: "__Secure-",
|
|
77
|
+
}
|
|
79
78
|
var defaultHostCookieConfig = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
79
|
+
secure: true,
|
|
80
|
+
prefix: "__Host-",
|
|
81
|
+
path: "/",
|
|
82
|
+
domain: void 0,
|
|
83
|
+
}
|
|
85
84
|
var expiredCookieOptions = {
|
|
86
|
-
...defaultCookieOptions,
|
|
87
|
-
expires: /* @__PURE__ */ new Date(0),
|
|
88
|
-
maxAge: 0
|
|
89
|
-
};
|
|
90
|
-
var defineDefaultCookieOptions = (options) => {
|
|
91
|
-
return {
|
|
92
|
-
name: options?.name ?? COOKIE_NAME,
|
|
93
|
-
prefix: options?.prefix ?? (options?.secure ? "__Secure-" : ""),
|
|
94
85
|
...defaultCookieOptions,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
86
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
87
|
+
maxAge: 0,
|
|
88
|
+
}
|
|
89
|
+
var defineDefaultCookieOptions = (options) => {
|
|
90
|
+
return {
|
|
91
|
+
name: options?.name ?? COOKIE_NAME,
|
|
92
|
+
prefix: options?.prefix ?? (options?.secure ? "__Secure-" : ""),
|
|
93
|
+
...defaultCookieOptions,
|
|
94
|
+
...options,
|
|
95
|
+
}
|
|
96
|
+
}
|
|
98
97
|
var setCookie = (cookieName, value, options) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
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
|
+
}
|
|
106
105
|
var getCookie = (petition, cookie, options, optional = false) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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")
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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`)
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return value;
|
|
124
|
-
};
|
|
122
|
+
return value
|
|
123
|
+
}
|
|
125
124
|
var createSessionCookie = async (session, cookieOptions, jose) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
125
|
+
try {
|
|
126
|
+
const encoded = await jose.encodeJWT(session)
|
|
127
|
+
return setCookie("sessionToken", encoded, cookieOptions)
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw new AuthError("server_error", "Failed to create session cookie", { cause: error })
|
|
130
|
+
}
|
|
131
|
+
}
|
|
133
132
|
var secureCookieOptions = (request, cookieOptions, trustedProxyHeaders) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (!isSecure) {
|
|
145
|
-
const options = cookieOptions.options;
|
|
146
|
-
if (options?.secure) {
|
|
147
|
-
console.warn(
|
|
148
|
-
"[WARNING]: The 'Secure' attribute will be disabled for this cookie. Serve over HTTPS to enforce Secure cookies."
|
|
149
|
-
);
|
|
133
|
+
const name = cookieOptions.name ?? COOKIE_NAME
|
|
134
|
+
const isSecure = trustedProxyHeaders
|
|
135
|
+
? request.url.startsWith("https://") ||
|
|
136
|
+
request.headers.get("X-Forwarded-Proto") === "https" ||
|
|
137
|
+
request.headers.get("Forwarded")?.includes("proto=https")
|
|
138
|
+
: request.url.startsWith("https://")
|
|
139
|
+
if (!cookieOptions.options?.httpOnly) {
|
|
140
|
+
console.warn(
|
|
141
|
+
"[WARNING]: Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS risk."
|
|
142
|
+
)
|
|
150
143
|
}
|
|
151
|
-
if (options?.
|
|
152
|
-
|
|
144
|
+
if (cookieOptions.options?.domain === "*") {
|
|
145
|
+
console.warn("[WARNING]: Cookie 'Domain' is set to '*', which is insecure. Avoid wildcard domains.")
|
|
153
146
|
}
|
|
154
|
-
if (
|
|
155
|
-
|
|
147
|
+
if (!isSecure) {
|
|
148
|
+
const options = cookieOptions.options
|
|
149
|
+
if (options?.secure) {
|
|
150
|
+
console.warn(
|
|
151
|
+
"[WARNING]: The 'Secure' attribute will be disabled for this cookie. Serve over HTTPS to enforce Secure cookies."
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
if (options?.sameSite == "none") {
|
|
155
|
+
console.warn("[WARNING]: SameSite=None without a secure connection can be blocked by browsers.")
|
|
156
|
+
}
|
|
157
|
+
if (process.env.NODE_ENV === "production") {
|
|
158
|
+
console.warn("[WARNING]: In production, ensure cookies are served over HTTPS to maintain security.")
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
...defaultCookieOptions,
|
|
162
|
+
...cookieOptions.options,
|
|
163
|
+
sameSite: options?.sameSite === "none" ? "lax" : (options?.sameSite ?? "lax"),
|
|
164
|
+
...defaultStandardCookieConfig,
|
|
165
|
+
name,
|
|
166
|
+
}
|
|
156
167
|
}
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
...defaultCookieOptions,
|
|
167
|
-
...cookieOptions.options,
|
|
168
|
-
...defaultHostCookieConfig,
|
|
169
|
-
name
|
|
170
|
-
} : { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name };
|
|
171
|
-
};
|
|
168
|
+
return cookieOptions.strategy === "host"
|
|
169
|
+
? {
|
|
170
|
+
...defaultCookieOptions,
|
|
171
|
+
...cookieOptions.options,
|
|
172
|
+
...defaultHostCookieConfig,
|
|
173
|
+
name,
|
|
174
|
+
}
|
|
175
|
+
: { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name }
|
|
176
|
+
}
|
|
172
177
|
var expireCookie = (name, options) => {
|
|
173
|
-
|
|
174
|
-
}
|
|
178
|
+
return setCookie(name, "", { ...options, ...expiredCookieOptions })
|
|
179
|
+
}
|
|
175
180
|
var oauthCookie = (options) => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
181
|
+
return {
|
|
182
|
+
...options,
|
|
183
|
+
secure: options.secure,
|
|
184
|
+
httpOnly: options.httpOnly,
|
|
185
|
+
maxAge: 5 * 60,
|
|
186
|
+
expires: new Date(Date.now() + 5 * 60 * 1e3),
|
|
187
|
+
}
|
|
188
|
+
}
|
|
184
189
|
// Annotate the CommonJS export names for ESM import in node:
|
|
185
|
-
0 &&
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
190
|
+
0 &&
|
|
191
|
+
(module.exports = {
|
|
192
|
+
COOKIE_NAME,
|
|
193
|
+
createSessionCookie,
|
|
194
|
+
defaultCookieConfig,
|
|
195
|
+
defaultCookieOptions,
|
|
196
|
+
defaultHostCookieConfig,
|
|
197
|
+
defaultSecureCookieConfig,
|
|
198
|
+
defaultStandardCookieConfig,
|
|
199
|
+
defineDefaultCookieOptions,
|
|
200
|
+
expireCookie,
|
|
201
|
+
expiredCookieOptions,
|
|
202
|
+
getCookie,
|
|
203
|
+
oauthCookie,
|
|
204
|
+
parse,
|
|
205
|
+
secureCookieOptions,
|
|
206
|
+
setCookie,
|
|
207
|
+
})
|
package/dist/cookie.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { SerializeOptions } from
|
|
2
|
-
export { parse } from
|
|
3
|
-
import { JWTPayload } from
|
|
4
|
-
import { C as CookieConfig, a as CookieConfigInternal, b as CookieName, A as AuthRuntimeConfig } from
|
|
5
|
-
import { LiteralUnion } from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { SerializeOptions } from "cookie"
|
|
2
|
+
export { parse } from "cookie"
|
|
3
|
+
import { JWTPayload } from "@aura-stack/jose/jose"
|
|
4
|
+
import { C as CookieConfig, a as CookieConfigInternal, b as CookieName, A as AuthRuntimeConfig } from "./index-DpfbvTZ_.js"
|
|
5
|
+
import { LiteralUnion } from "./@types/utility.js"
|
|
6
|
+
import "zod/v4"
|
|
7
|
+
import "./schemas.js"
|
|
8
|
+
import "zod/v4/core"
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Prefix for all cookies set by Aura Auth.
|
|
12
12
|
*/
|
|
13
|
-
declare const COOKIE_NAME = "aura-auth"
|
|
13
|
+
declare const COOKIE_NAME = "aura-auth"
|
|
14
14
|
/**
|
|
15
15
|
* Default cookie options used by Aura Auth.
|
|
16
16
|
*/
|
|
17
|
-
declare const defaultCookieOptions: SerializeOptions
|
|
17
|
+
declare const defaultCookieOptions: SerializeOptions
|
|
18
18
|
/**
|
|
19
19
|
* Default cookie options for "standard" cookies.
|
|
20
20
|
*/
|
|
21
|
-
declare const defaultCookieConfig: CookieConfig
|
|
22
|
-
declare const defaultStandardCookieConfig: CookieConfigInternal
|
|
21
|
+
declare const defaultCookieConfig: CookieConfig
|
|
22
|
+
declare const defaultStandardCookieConfig: CookieConfigInternal
|
|
23
23
|
/**
|
|
24
24
|
* Default cookie options for "secure" cookies.
|
|
25
25
|
* @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__secure-prefix
|
|
26
26
|
*/
|
|
27
|
-
declare const defaultSecureCookieConfig: CookieConfigInternal
|
|
27
|
+
declare const defaultSecureCookieConfig: CookieConfigInternal
|
|
28
28
|
/**
|
|
29
29
|
* Default cookie options for "host" cookies.
|
|
30
30
|
* @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__host-prefix
|
|
31
31
|
*/
|
|
32
|
-
declare const defaultHostCookieConfig: CookieConfigInternal
|
|
32
|
+
declare const defaultHostCookieConfig: CookieConfigInternal
|
|
33
33
|
/**
|
|
34
34
|
* Cookie options for expired cookies.
|
|
35
35
|
*/
|
|
36
|
-
declare const expiredCookieOptions: SerializeOptions
|
|
37
|
-
declare const defineDefaultCookieOptions: (options?: CookieConfigInternal) => CookieConfigInternal
|
|
36
|
+
declare const expiredCookieOptions: SerializeOptions
|
|
37
|
+
declare const defineDefaultCookieOptions: (options?: CookieConfigInternal) => CookieConfigInternal
|
|
38
38
|
/**
|
|
39
39
|
* Set a cookie with the given name, value and `CookieOptionsInternal`; supports secure
|
|
40
40
|
* cookies with the `__Secure-` and `__Host-` prefixes.
|
|
@@ -42,7 +42,7 @@ declare const defineDefaultCookieOptions: (options?: CookieConfigInternal) => Co
|
|
|
42
42
|
* Cookie attributes are serialized in the following order:
|
|
43
43
|
* Expires, Max-Age, Domain, Path, Secure, HttpOnly, SameSite, Partitioned, Priority.
|
|
44
44
|
*/
|
|
45
|
-
declare const setCookie: (cookieName: LiteralUnion<CookieName>, value: string, options?: CookieConfigInternal) => string
|
|
45
|
+
declare const setCookie: (cookieName: LiteralUnion<CookieName>, value: string, options?: CookieConfigInternal) => string
|
|
46
46
|
/**
|
|
47
47
|
* Get a cookie by name from the request.
|
|
48
48
|
*
|
|
@@ -52,7 +52,12 @@ declare const setCookie: (cookieName: LiteralUnion<CookieName>, value: string, o
|
|
|
52
52
|
* @param optional If true, returns an empty string instead of throwing an error when the cookie is not found
|
|
53
53
|
* @returns The value of the cookie or undefined if not found
|
|
54
54
|
*/
|
|
55
|
-
declare const getCookie: (
|
|
55
|
+
declare const getCookie: (
|
|
56
|
+
petition: Request | Response,
|
|
57
|
+
cookie: LiteralUnion<CookieName>,
|
|
58
|
+
options?: CookieConfigInternal,
|
|
59
|
+
optional?: boolean
|
|
60
|
+
) => string
|
|
56
61
|
/**
|
|
57
62
|
* Create a session cookie containing a signed and encrypted JWT, using the
|
|
58
63
|
* `@aura-stack/jose` package for the encoding.
|
|
@@ -60,7 +65,11 @@ declare const getCookie: (petition: Request | Response, cookie: LiteralUnion<Coo
|
|
|
60
65
|
* @param session - The JWT payload to be encoded in the session cookie
|
|
61
66
|
* @returns The serialized session cookie string
|
|
62
67
|
*/
|
|
63
|
-
declare const createSessionCookie: (
|
|
68
|
+
declare const createSessionCookie: (
|
|
69
|
+
session: JWTPayload,
|
|
70
|
+
cookieOptions: CookieConfigInternal,
|
|
71
|
+
jose: AuthRuntimeConfig["jose"]
|
|
72
|
+
) => Promise<string>
|
|
64
73
|
/**
|
|
65
74
|
* Defines the cookie configuration based on the request security and cookie options passed
|
|
66
75
|
* in the Aura Auth configuration (`createAuth` function). This function ensures the correct
|
|
@@ -73,7 +82,11 @@ declare const createSessionCookie: (session: JWTPayload, cookieOptions: CookieCo
|
|
|
73
82
|
* @param cookieOptions Cookie options from the Aura Auth configuration
|
|
74
83
|
* @returns The finalized cookie options to be used for setting cookies
|
|
75
84
|
*/
|
|
76
|
-
declare const secureCookieOptions: (
|
|
85
|
+
declare const secureCookieOptions: (
|
|
86
|
+
request: Request,
|
|
87
|
+
cookieOptions: CookieConfig,
|
|
88
|
+
trustedProxyHeaders?: boolean
|
|
89
|
+
) => CookieConfigInternal
|
|
77
90
|
/**
|
|
78
91
|
* Expire a cookie by setting its value to an empty string and applying expired cookie options.
|
|
79
92
|
*
|
|
@@ -81,13 +94,28 @@ declare const secureCookieOptions: (request: Request, cookieOptions: CookieConfi
|
|
|
81
94
|
* @param options cookie options obtained from secureCookieOptions
|
|
82
95
|
* @returns formatted cookie options for an expired cookie
|
|
83
96
|
*/
|
|
84
|
-
declare const expireCookie: (name: LiteralUnion<CookieName>, options: CookieConfigInternal) => string
|
|
97
|
+
declare const expireCookie: (name: LiteralUnion<CookieName>, options: CookieConfigInternal) => string
|
|
85
98
|
/**
|
|
86
99
|
* Set OAuth-specific cookie options, including a short maxAge of 5 minutes.
|
|
87
100
|
*
|
|
88
101
|
* @param options cookie options obtained from secureCookieOptions
|
|
89
102
|
* @returns formatted cookie options for OAuth cookies
|
|
90
103
|
*/
|
|
91
|
-
declare const oauthCookie: (options: CookieConfigInternal) => CookieConfigInternal
|
|
104
|
+
declare const oauthCookie: (options: CookieConfigInternal) => CookieConfigInternal
|
|
92
105
|
|
|
93
|
-
export {
|
|
106
|
+
export {
|
|
107
|
+
COOKIE_NAME,
|
|
108
|
+
createSessionCookie,
|
|
109
|
+
defaultCookieConfig,
|
|
110
|
+
defaultCookieOptions,
|
|
111
|
+
defaultHostCookieConfig,
|
|
112
|
+
defaultSecureCookieConfig,
|
|
113
|
+
defaultStandardCookieConfig,
|
|
114
|
+
defineDefaultCookieOptions,
|
|
115
|
+
expireCookie,
|
|
116
|
+
expiredCookieOptions,
|
|
117
|
+
getCookie,
|
|
118
|
+
oauthCookie,
|
|
119
|
+
secureCookieOptions,
|
|
120
|
+
setCookie,
|
|
121
|
+
}
|
package/dist/cookie.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./chunk-ZV4BH47P.js"
|
|
18
|
-
import "./chunk-6SM22VVJ.js"
|
|
19
|
-
import "./chunk-FJUDBLCP.js"
|
|
2
|
+
COOKIE_NAME,
|
|
3
|
+
createSessionCookie,
|
|
4
|
+
defaultCookieConfig,
|
|
5
|
+
defaultCookieOptions,
|
|
6
|
+
defaultHostCookieConfig,
|
|
7
|
+
defaultSecureCookieConfig,
|
|
8
|
+
defaultStandardCookieConfig,
|
|
9
|
+
defineDefaultCookieOptions,
|
|
10
|
+
expireCookie,
|
|
11
|
+
expiredCookieOptions,
|
|
12
|
+
getCookie,
|
|
13
|
+
oauthCookie,
|
|
14
|
+
parse,
|
|
15
|
+
secureCookieOptions,
|
|
16
|
+
setCookie,
|
|
17
|
+
} from "./chunk-ZV4BH47P.js"
|
|
18
|
+
import "./chunk-6SM22VVJ.js"
|
|
19
|
+
import "./chunk-FJUDBLCP.js"
|
|
20
20
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
21
|
+
COOKIE_NAME,
|
|
22
|
+
createSessionCookie,
|
|
23
|
+
defaultCookieConfig,
|
|
24
|
+
defaultCookieOptions,
|
|
25
|
+
defaultHostCookieConfig,
|
|
26
|
+
defaultSecureCookieConfig,
|
|
27
|
+
defaultStandardCookieConfig,
|
|
28
|
+
defineDefaultCookieOptions,
|
|
29
|
+
expireCookie,
|
|
30
|
+
expiredCookieOptions,
|
|
31
|
+
getCookie,
|
|
32
|
+
oauthCookie,
|
|
33
|
+
parse,
|
|
34
|
+
secureCookieOptions,
|
|
35
|
+
setCookie,
|
|
36
|
+
}
|