@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/cookie.cjs
CHANGED
|
@@ -1,207 +1,201 @@
|
|
|
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/cookie.ts
|
|
20
|
-
var cookie_exports = {}
|
|
21
|
+
var cookie_exports = {};
|
|
21
22
|
__export(cookie_exports, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
module.exports = __toCommonJS(cookie_exports)
|
|
39
|
-
var import_cookie = require("cookie")
|
|
23
|
+
COOKIE_NAME: () => COOKIE_NAME,
|
|
24
|
+
createSessionCookie: () => createSessionCookie,
|
|
25
|
+
defaultCookieConfig: () => defaultCookieConfig,
|
|
26
|
+
defaultCookieOptions: () => defaultCookieOptions,
|
|
27
|
+
defaultHostCookieConfig: () => defaultHostCookieConfig,
|
|
28
|
+
defaultSecureCookieConfig: () => defaultSecureCookieConfig,
|
|
29
|
+
defaultStandardCookieConfig: () => defaultStandardCookieConfig,
|
|
30
|
+
defineDefaultCookieOptions: () => defineDefaultCookieOptions,
|
|
31
|
+
expireCookie: () => expireCookie,
|
|
32
|
+
expiredCookieOptions: () => expiredCookieOptions,
|
|
33
|
+
getCookie: () => getCookie,
|
|
34
|
+
oauthCookie: () => oauthCookie,
|
|
35
|
+
parse: () => import_cookie2.parse,
|
|
36
|
+
secureCookieOptions: () => secureCookieOptions,
|
|
37
|
+
setCookie: () => setCookie
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(cookie_exports);
|
|
40
|
+
var import_cookie = require("cookie");
|
|
40
41
|
|
|
41
42
|
// src/error.ts
|
|
42
43
|
var AuthError = class extends Error {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
44
|
+
constructor(type, message) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.type = type;
|
|
47
|
+
this.name = "AuthError";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
49
50
|
|
|
50
51
|
// src/assert.ts
|
|
51
52
|
var isRequest = (value) => {
|
|
52
|
-
|
|
53
|
-
}
|
|
53
|
+
return typeof Request !== "undefined" && value instanceof Request;
|
|
54
|
+
};
|
|
54
55
|
|
|
55
56
|
// src/cookie.ts
|
|
56
|
-
var import_cookie2 = require("cookie")
|
|
57
|
-
var COOKIE_NAME = "aura-auth"
|
|
57
|
+
var import_cookie2 = require("cookie");
|
|
58
|
+
var COOKIE_NAME = "aura-auth";
|
|
58
59
|
var defaultCookieOptions = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
60
|
+
httpOnly: true,
|
|
61
|
+
sameSite: "lax",
|
|
62
|
+
path: "/",
|
|
63
|
+
maxAge: 60 * 60 * 24 * 15
|
|
64
|
+
};
|
|
64
65
|
var defaultCookieConfig = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
66
|
+
strategy: "standard",
|
|
67
|
+
name: COOKIE_NAME,
|
|
68
|
+
options: defaultCookieOptions
|
|
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 createSessionCookie = async (session, cookieOptions, jose) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
126
|
+
try {
|
|
127
|
+
const encoded = await jose.encodeJWT(session);
|
|
128
|
+
return setCookie("sessionToken", encoded, cookieOptions);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
throw new AuthError("server_error", "Failed to create session cookie", { cause: error });
|
|
131
|
+
}
|
|
132
|
+
};
|
|
132
133
|
var secureCookieOptions = (request, cookieOptions, trustedProxyHeaders) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
const name = cookieOptions.name ?? COOKIE_NAME;
|
|
135
|
+
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://");
|
|
136
|
+
if (!cookieOptions.options?.httpOnly) {
|
|
137
|
+
console.warn(
|
|
138
|
+
"[WARNING]: Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS risk."
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
if (cookieOptions.options?.domain === "*") {
|
|
142
|
+
console.warn("[WARNING]: Cookie 'Domain' is set to '*', which is insecure. Avoid wildcard domains.");
|
|
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
|
+
);
|
|
143
150
|
}
|
|
144
|
-
if (
|
|
145
|
-
|
|
151
|
+
if (options?.sameSite == "none") {
|
|
152
|
+
console.warn("[WARNING]: SameSite=None without a secure connection can be blocked by browsers.");
|
|
146
153
|
}
|
|
147
|
-
if (
|
|
148
|
-
|
|
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
|
-
}
|
|
154
|
+
if (process.env.NODE_ENV === "production") {
|
|
155
|
+
console.warn("[WARNING]: In production, ensure cookies are served over HTTPS to maintain security.");
|
|
167
156
|
}
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
157
|
+
return {
|
|
158
|
+
...defaultCookieOptions,
|
|
159
|
+
...cookieOptions.options,
|
|
160
|
+
sameSite: options?.sameSite === "none" ? "lax" : options?.sameSite ?? "lax",
|
|
161
|
+
...defaultStandardCookieConfig,
|
|
162
|
+
name
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return cookieOptions.strategy === "host" ? {
|
|
166
|
+
...defaultCookieOptions,
|
|
167
|
+
...cookieOptions.options,
|
|
168
|
+
...defaultHostCookieConfig,
|
|
169
|
+
name
|
|
170
|
+
} : { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name };
|
|
171
|
+
};
|
|
177
172
|
var expireCookie = (name, options) => {
|
|
178
|
-
|
|
179
|
-
}
|
|
173
|
+
return setCookie(name, "", { ...options, ...expiredCookieOptions });
|
|
174
|
+
};
|
|
180
175
|
var oauthCookie = (options) => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
176
|
+
return {
|
|
177
|
+
...options,
|
|
178
|
+
secure: options.secure,
|
|
179
|
+
httpOnly: options.httpOnly,
|
|
180
|
+
maxAge: 5 * 60,
|
|
181
|
+
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
182
|
+
};
|
|
183
|
+
};
|
|
189
184
|
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
-
0 &&
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
})
|
|
185
|
+
0 && (module.exports = {
|
|
186
|
+
COOKIE_NAME,
|
|
187
|
+
createSessionCookie,
|
|
188
|
+
defaultCookieConfig,
|
|
189
|
+
defaultCookieOptions,
|
|
190
|
+
defaultHostCookieConfig,
|
|
191
|
+
defaultSecureCookieConfig,
|
|
192
|
+
defaultStandardCookieConfig,
|
|
193
|
+
defineDefaultCookieOptions,
|
|
194
|
+
expireCookie,
|
|
195
|
+
expiredCookieOptions,
|
|
196
|
+
getCookie,
|
|
197
|
+
oauthCookie,
|
|
198
|
+
parse,
|
|
199
|
+
secureCookieOptions,
|
|
200
|
+
setCookie
|
|
201
|
+
});
|
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,12 +52,7 @@ 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: (
|
|
56
|
-
petition: Request | Response,
|
|
57
|
-
cookie: LiteralUnion<CookieName>,
|
|
58
|
-
options?: CookieConfigInternal,
|
|
59
|
-
optional?: boolean
|
|
60
|
-
) => string
|
|
55
|
+
declare const getCookie: (petition: Request | Response, cookie: LiteralUnion<CookieName>, options?: CookieConfigInternal, optional?: boolean) => string;
|
|
61
56
|
/**
|
|
62
57
|
* Create a session cookie containing a signed and encrypted JWT, using the
|
|
63
58
|
* `@aura-stack/jose` package for the encoding.
|
|
@@ -65,11 +60,7 @@ declare const getCookie: (
|
|
|
65
60
|
* @param session - The JWT payload to be encoded in the session cookie
|
|
66
61
|
* @returns The serialized session cookie string
|
|
67
62
|
*/
|
|
68
|
-
declare const createSessionCookie: (
|
|
69
|
-
session: JWTPayload,
|
|
70
|
-
cookieOptions: CookieConfigInternal,
|
|
71
|
-
jose: AuthRuntimeConfig["jose"]
|
|
72
|
-
) => Promise<string>
|
|
63
|
+
declare const createSessionCookie: (session: JWTPayload, cookieOptions: CookieConfigInternal, jose: AuthRuntimeConfig["jose"]) => Promise<string>;
|
|
73
64
|
/**
|
|
74
65
|
* Defines the cookie configuration based on the request security and cookie options passed
|
|
75
66
|
* in the Aura Auth configuration (`createAuth` function). This function ensures the correct
|
|
@@ -82,11 +73,7 @@ declare const createSessionCookie: (
|
|
|
82
73
|
* @param cookieOptions Cookie options from the Aura Auth configuration
|
|
83
74
|
* @returns The finalized cookie options to be used for setting cookies
|
|
84
75
|
*/
|
|
85
|
-
declare const secureCookieOptions: (
|
|
86
|
-
request: Request,
|
|
87
|
-
cookieOptions: CookieConfig,
|
|
88
|
-
trustedProxyHeaders?: boolean
|
|
89
|
-
) => CookieConfigInternal
|
|
76
|
+
declare const secureCookieOptions: (request: Request, cookieOptions: CookieConfig, trustedProxyHeaders?: boolean) => CookieConfigInternal;
|
|
90
77
|
/**
|
|
91
78
|
* Expire a cookie by setting its value to an empty string and applying expired cookie options.
|
|
92
79
|
*
|
|
@@ -94,28 +81,13 @@ declare const secureCookieOptions: (
|
|
|
94
81
|
* @param options cookie options obtained from secureCookieOptions
|
|
95
82
|
* @returns formatted cookie options for an expired cookie
|
|
96
83
|
*/
|
|
97
|
-
declare const expireCookie: (name: LiteralUnion<CookieName>, options: CookieConfigInternal) => string
|
|
84
|
+
declare const expireCookie: (name: LiteralUnion<CookieName>, options: CookieConfigInternal) => string;
|
|
98
85
|
/**
|
|
99
86
|
* Set OAuth-specific cookie options, including a short maxAge of 5 minutes.
|
|
100
87
|
*
|
|
101
88
|
* @param options cookie options obtained from secureCookieOptions
|
|
102
89
|
* @returns formatted cookie options for OAuth cookies
|
|
103
90
|
*/
|
|
104
|
-
declare const oauthCookie: (options: CookieConfigInternal) => CookieConfigInternal
|
|
91
|
+
declare const oauthCookie: (options: CookieConfigInternal) => CookieConfigInternal;
|
|
105
92
|
|
|
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
|
-
}
|
|
93
|
+
export { COOKIE_NAME, createSessionCookie, defaultCookieConfig, defaultCookieOptions, defaultHostCookieConfig, defaultSecureCookieConfig, defaultStandardCookieConfig, defineDefaultCookieOptions, expireCookie, expiredCookieOptions, getCookie, oauthCookie, secureCookieOptions, setCookie };
|
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
|
+
};
|