@aura-stack/auth 0.5.0 → 0.7.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/README.md +36 -1
- package/dist/@types/index.cjs +0 -18
- package/dist/@types/index.d.ts +2 -12
- package/dist/@types/index.js +0 -1
- package/dist/assert-_fBNnaOk.js +3 -0
- package/dist/assert-hDwQ_SPO.cjs +3 -0
- package/dist/client/index.cjs +1 -135
- package/dist/client/index.d.ts +11 -14
- package/dist/client/index.js +1 -10
- package/dist/crypto-D6_SoGMH.cjs +1 -0
- package/dist/crypto-DyrRzBSQ.js +1 -0
- package/dist/env-7as-tgzO.cjs +1 -0
- package/dist/env-CJtSi1eX.js +1 -0
- package/dist/errors-Czt_w1t_.js +1 -0
- package/dist/errors-DcK2ELlk.cjs +1 -0
- package/dist/identity-b8FCr0Oa.cjs +1 -0
- package/dist/index-C9U6ICDT.d.ts +2796 -0
- package/dist/index.cjs +1 -2427
- package/dist/index.d.ts +2 -14
- package/dist/index.js +1 -59
- package/dist/logger-DjXkgSn5.js +1 -0
- package/dist/logger-G5PinyEc.cjs +1 -0
- package/dist/oauth/atlassian.cjs +1 -57
- package/dist/oauth/atlassian.d.ts +2 -12
- package/dist/oauth/atlassian.js +1 -6
- package/dist/oauth/bitbucket.cjs +1 -49
- package/dist/oauth/bitbucket.d.ts +2 -12
- package/dist/oauth/bitbucket.js +1 -6
- package/dist/oauth/click-up.cjs +1 -0
- package/dist/oauth/click-up.d.ts +2 -0
- package/dist/oauth/click-up.js +1 -0
- package/dist/oauth/discord.cjs +1 -57
- package/dist/oauth/discord.d.ts +2 -12
- package/dist/oauth/discord.js +1 -6
- package/dist/oauth/dribbble.cjs +1 -0
- package/dist/oauth/dribbble.d.ts +2 -0
- package/dist/oauth/dribbble.js +1 -0
- package/dist/oauth/dropbox.cjs +1 -53
- package/dist/oauth/dropbox.d.ts +2 -12
- package/dist/oauth/dropbox.js +1 -6
- package/dist/oauth/figma.cjs +1 -49
- package/dist/oauth/figma.d.ts +2 -12
- package/dist/oauth/figma.js +1 -6
- package/dist/oauth/github.cjs +1 -49
- package/dist/oauth/github.d.ts +2 -12
- package/dist/oauth/github.js +1 -6
- package/dist/oauth/gitlab.cjs +1 -49
- package/dist/oauth/gitlab.d.ts +2 -12
- package/dist/oauth/gitlab.js +1 -6
- package/dist/oauth/index.cjs +1 -673
- package/dist/oauth/index.d.ts +2 -12
- package/dist/oauth/index.js +1 -68
- package/dist/oauth/mailchimp.cjs +1 -49
- package/dist/oauth/mailchimp.d.ts +2 -12
- package/dist/oauth/mailchimp.js +1 -6
- package/dist/oauth/notion.cjs +1 -131
- package/dist/oauth/notion.d.ts +2 -12
- package/dist/oauth/notion.js +1 -9
- package/dist/oauth/pinterest.cjs +1 -49
- package/dist/oauth/pinterest.d.ts +2 -12
- package/dist/oauth/pinterest.js +1 -6
- package/dist/oauth/spotify.cjs +1 -49
- package/dist/oauth/spotify.d.ts +2 -12
- package/dist/oauth/spotify.js +1 -6
- package/dist/oauth/strava.cjs +1 -49
- package/dist/oauth/strava.d.ts +2 -12
- package/dist/oauth/strava.js +1 -6
- package/dist/oauth/twitch.cjs +1 -95
- package/dist/oauth/twitch.d.ts +2 -12
- package/dist/oauth/twitch.js +1 -7
- package/dist/oauth/x.cjs +1 -49
- package/dist/oauth/x.d.ts +2 -12
- package/dist/oauth/x.js +1 -6
- package/dist/oauth-D3_mnBOx.js +1 -0
- package/dist/oauth-gPiWxjBd.cjs +1 -0
- package/dist/shared/crypto.cjs +1 -0
- package/dist/shared/crypto.d.ts +71 -0
- package/dist/shared/crypto.js +1 -0
- package/dist/shared/identity.cjs +1 -0
- package/dist/shared/identity.d.ts +2 -0
- package/dist/shared/identity.js +1 -0
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +1 -0
- package/package.json +37 -11
- package/dist/@types/router.d.cjs +0 -1
- package/dist/@types/router.d.d.ts +0 -16
- package/dist/@types/router.d.js +0 -0
- package/dist/@types/utility.cjs +0 -18
- package/dist/@types/utility.d.ts +0 -6
- package/dist/@types/utility.js +0 -1
- package/dist/actions/callback/access-token.cjs +0 -250
- package/dist/actions/callback/access-token.d.ts +0 -33
- package/dist/actions/callback/access-token.js +0 -9
- package/dist/actions/callback/callback.cjs +0 -715
- package/dist/actions/callback/callback.d.ts +0 -42
- package/dist/actions/callback/callback.js +0 -18
- package/dist/actions/callback/userinfo.cjs +0 -283
- package/dist/actions/callback/userinfo.d.ts +0 -25
- package/dist/actions/callback/userinfo.js +0 -13
- package/dist/actions/csrfToken/csrfToken.cjs +0 -189
- package/dist/actions/csrfToken/csrfToken.d.ts +0 -7
- package/dist/actions/csrfToken/csrfToken.js +0 -13
- package/dist/actions/index.cjs +0 -1161
- package/dist/actions/index.d.ts +0 -17
- package/dist/actions/index.js +0 -39
- package/dist/actions/session/session.cjs +0 -188
- package/dist/actions/session/session.d.ts +0 -7
- package/dist/actions/session/session.js +0 -12
- package/dist/actions/signIn/authorization-url.cjs +0 -288
- package/dist/actions/signIn/authorization-url.d.ts +0 -31
- package/dist/actions/signIn/authorization-url.js +0 -16
- package/dist/actions/signIn/authorization.cjs +0 -281
- package/dist/actions/signIn/authorization.d.ts +0 -54
- package/dist/actions/signIn/authorization.js +0 -19
- package/dist/actions/signIn/signIn.cjs +0 -595
- package/dist/actions/signIn/signIn.d.ts +0 -42
- package/dist/actions/signIn/signIn.js +0 -16
- package/dist/actions/signOut/signOut.cjs +0 -492
- package/dist/actions/signOut/signOut.d.ts +0 -16
- package/dist/actions/signOut/signOut.js +0 -15
- package/dist/api/createApi.cjs +0 -750
- package/dist/api/createApi.d.ts +0 -12
- package/dist/api/createApi.js +0 -19
- package/dist/api/getSession.cjs +0 -141
- package/dist/api/getSession.d.ts +0 -16
- package/dist/api/getSession.js +0 -10
- package/dist/api/signIn.cjs +0 -549
- package/dist/api/signIn.d.ts +0 -26
- package/dist/api/signIn.js +0 -15
- package/dist/api/signOut.cjs +0 -279
- package/dist/api/signOut.d.ts +0 -16
- package/dist/api/signOut.js +0 -13
- package/dist/assert.cjs +0 -194
- package/dist/assert.d.ts +0 -37
- package/dist/assert.js +0 -26
- package/dist/chunk-2A5B7GWR.js +0 -125
- package/dist/chunk-2GQLSIJ2.js +0 -40
- package/dist/chunk-2IR674WX.js +0 -44
- package/dist/chunk-3J5TUH2I.js +0 -50
- package/dist/chunk-4RWSYUKX.js +0 -98
- package/dist/chunk-4YHJ4IEQ.js +0 -25
- package/dist/chunk-54CZPKR4.js +0 -25
- package/dist/chunk-5LZ7TOM3.js +0 -25
- package/dist/chunk-5X7JZMEF.js +0 -0
- package/dist/chunk-7BE46WWS.js +0 -88
- package/dist/chunk-7YYXFKLR.js +0 -35
- package/dist/chunk-C3A37LQC.js +0 -33
- package/dist/chunk-CITNGXDA.js +0 -31
- package/dist/chunk-CWX724AG.js +0 -78
- package/dist/chunk-D2CSIUKP.js +0 -74
- package/dist/chunk-E6G5YCI6.js +0 -25
- package/dist/chunk-EBAMFRB7.js +0 -34
- package/dist/chunk-EEE7UM5T.js +0 -25
- package/dist/chunk-FPCVZUVG.js +0 -37
- package/dist/chunk-FW4W3REU.js +0 -25
- package/dist/chunk-GNNBM2WJ.js +0 -83
- package/dist/chunk-IPKO6UQN.js +0 -25
- package/dist/chunk-ITQ7352M.js +0 -0
- package/dist/chunk-JOCGX3RP.js +0 -59
- package/dist/chunk-KBXWTD6E.js +0 -94
- package/dist/chunk-KMMAZFSJ.js +0 -25
- package/dist/chunk-LATR3NIV.js +0 -117
- package/dist/chunk-LAYPUDQF.js +0 -39
- package/dist/chunk-LDU7A2JE.js +0 -25
- package/dist/chunk-LX3TJ2TJ.js +0 -294
- package/dist/chunk-NHZBQNRR.js +0 -143
- package/dist/chunk-OVHNRULD.js +0 -33
- package/dist/chunk-PDP3PHB3.js +0 -127
- package/dist/chunk-PG7UYFG5.js +0 -0
- package/dist/chunk-PHYNROD4.js +0 -47
- package/dist/chunk-QQEKY4XP.js +0 -29
- package/dist/chunk-U4RK4LKJ.js +0 -348
- package/dist/chunk-U5663F2U.js +0 -70
- package/dist/chunk-UN7X6SU5.js +0 -53
- package/dist/chunk-UZQJJD6A.js +0 -100
- package/dist/chunk-V6LLEAR4.js +0 -80
- package/dist/chunk-WHNDRO3N.js +0 -50
- package/dist/chunk-XY5R3EHH.js +0 -204
- package/dist/chunk-ZNCZVF6U.js +0 -14
- package/dist/client/client.cjs +0 -135
- package/dist/client/client.d.ts +0 -85
- package/dist/client/client.js +0 -9
- package/dist/context.cjs +0 -1237
- package/dist/context.d.ts +0 -16
- package/dist/context.js +0 -28
- package/dist/cookie.cjs +0 -277
- package/dist/cookie.d.ts +0 -89
- package/dist/cookie.js +0 -30
- package/dist/createAuth.cjs +0 -2320
- package/dist/createAuth.d.ts +0 -12
- package/dist/createAuth.js +0 -48
- package/dist/env.cjs +0 -78
- package/dist/env.d.ts +0 -10
- package/dist/env.js +0 -12
- package/dist/errors.cjs +0 -102
- package/dist/errors.d.ts +0 -60
- package/dist/errors.js +0 -22
- package/dist/headers.cjs +0 -61
- package/dist/headers.d.ts +0 -33
- package/dist/headers.js +0 -12
- package/dist/index-_aXtxb_s.d.ts +0 -1377
- package/dist/jose.cjs +0 -166
- package/dist/jose.d.ts +0 -12
- package/dist/jose.js +0 -20
- package/dist/logger.cjs +0 -424
- package/dist/logger.d.ts +0 -12
- package/dist/logger.js +0 -17
- package/dist/request.cjs +0 -38
- package/dist/request.d.ts +0 -13
- package/dist/request.js +0 -6
- package/dist/schemas.cjs +0 -158
- package/dist/schemas.d.ts +0 -229
- package/dist/schemas.js +0 -24
- package/dist/secure.cjs +0 -170
- package/dist/secure.d.ts +0 -41
- package/dist/secure.js +0 -20
- package/dist/utils.cjs +0 -329
- package/dist/utils.d.ts +0 -35
- package/dist/utils.js +0 -36
package/dist/context.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { A as AuthConfig, I as InternalContext } from './index-_aXtxb_s.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import './schemas.js';
|
|
4
|
-
import 'zod/v4';
|
|
5
|
-
import '@aura-stack/jose';
|
|
6
|
-
import '@aura-stack/jose/jose';
|
|
7
|
-
import '@aura-stack/jose/crypto';
|
|
8
|
-
import '@aura-stack/router/cookie';
|
|
9
|
-
import './@types/utility.js';
|
|
10
|
-
import 'jose';
|
|
11
|
-
import '@aura-stack/router';
|
|
12
|
-
import 'zod/v4/core';
|
|
13
|
-
|
|
14
|
-
declare const createContext: (config?: AuthConfig) => InternalContext;
|
|
15
|
-
|
|
16
|
-
export { createContext };
|
package/dist/context.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext
|
|
3
|
-
} from "./chunk-2IR674WX.js";
|
|
4
|
-
import "./chunk-PDP3PHB3.js";
|
|
5
|
-
import "./chunk-LDU7A2JE.js";
|
|
6
|
-
import "./chunk-PHYNROD4.js";
|
|
7
|
-
import "./chunk-E6G5YCI6.js";
|
|
8
|
-
import "./chunk-IPKO6UQN.js";
|
|
9
|
-
import "./chunk-54CZPKR4.js";
|
|
10
|
-
import "./chunk-2GQLSIJ2.js";
|
|
11
|
-
import "./chunk-EEE7UM5T.js";
|
|
12
|
-
import "./chunk-C3A37LQC.js";
|
|
13
|
-
import "./chunk-4YHJ4IEQ.js";
|
|
14
|
-
import "./chunk-OVHNRULD.js";
|
|
15
|
-
import "./chunk-QQEKY4XP.js";
|
|
16
|
-
import "./chunk-KMMAZFSJ.js";
|
|
17
|
-
import "./chunk-FW4W3REU.js";
|
|
18
|
-
import "./chunk-5LZ7TOM3.js";
|
|
19
|
-
import "./chunk-U4RK4LKJ.js";
|
|
20
|
-
import "./chunk-2A5B7GWR.js";
|
|
21
|
-
import "./chunk-UZQJJD6A.js";
|
|
22
|
-
import "./chunk-LX3TJ2TJ.js";
|
|
23
|
-
import "./chunk-XY5R3EHH.js";
|
|
24
|
-
import "./chunk-WHNDRO3N.js";
|
|
25
|
-
import "./chunk-U5663F2U.js";
|
|
26
|
-
export {
|
|
27
|
-
createContext
|
|
28
|
-
};
|
package/dist/cookie.cjs
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
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
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/cookie.ts
|
|
21
|
-
var cookie_exports = {};
|
|
22
|
-
__export(cookie_exports, {
|
|
23
|
-
COOKIE_NAME: () => COOKIE_NAME,
|
|
24
|
-
createCookieStore: () => createCookieStore,
|
|
25
|
-
createSessionCookie: () => createSessionCookie,
|
|
26
|
-
defaultCookieOptions: () => defaultCookieOptions,
|
|
27
|
-
defaultHostCookieConfig: () => defaultHostCookieConfig,
|
|
28
|
-
defaultSecureCookieConfig: () => defaultSecureCookieConfig,
|
|
29
|
-
defaultStandardCookieConfig: () => defaultStandardCookieConfig,
|
|
30
|
-
defineSecureCookieOptions: () => defineSecureCookieOptions,
|
|
31
|
-
expiredCookieAttributes: () => expiredCookieAttributes,
|
|
32
|
-
getCookie: () => getCookie,
|
|
33
|
-
getSetCookie: () => getSetCookie,
|
|
34
|
-
setCookie: () => setCookie
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(cookie_exports);
|
|
37
|
-
|
|
38
|
-
// src/env.ts
|
|
39
|
-
var import_meta = {};
|
|
40
|
-
var env = new Proxy({}, {
|
|
41
|
-
get(_, prop) {
|
|
42
|
-
if (typeof prop !== "string") return void 0;
|
|
43
|
-
const hasProperty = (process2) => {
|
|
44
|
-
return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
|
|
45
|
-
};
|
|
46
|
-
try {
|
|
47
|
-
if (typeof process !== "undefined" && hasProperty(process.env)) {
|
|
48
|
-
return process.env[prop];
|
|
49
|
-
}
|
|
50
|
-
if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
|
|
51
|
-
return import_meta.env[prop];
|
|
52
|
-
}
|
|
53
|
-
if (typeof Deno !== "undefined" && Deno.env?.get) {
|
|
54
|
-
return Deno.env.get(prop);
|
|
55
|
-
}
|
|
56
|
-
if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
|
|
57
|
-
return Bun.env[prop];
|
|
58
|
-
}
|
|
59
|
-
const globalValue = globalThis[prop];
|
|
60
|
-
return typeof globalValue === "string" ? globalValue : void 0;
|
|
61
|
-
} catch {
|
|
62
|
-
return void 0;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// src/cookie.ts
|
|
68
|
-
var import_cookie = require("@aura-stack/router/cookie");
|
|
69
|
-
|
|
70
|
-
// src/errors.ts
|
|
71
|
-
var AuthInternalError = class extends Error {
|
|
72
|
-
type = "AUTH_INTERNAL_ERROR";
|
|
73
|
-
code;
|
|
74
|
-
constructor(code, message, options) {
|
|
75
|
-
super(message, options);
|
|
76
|
-
this.code = code;
|
|
77
|
-
this.name = new.target.name;
|
|
78
|
-
Error.captureStackTrace(this, new.target);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/cookie.ts
|
|
83
|
-
var COOKIE_NAME = "aura-auth";
|
|
84
|
-
var defaultCookieOptions = {
|
|
85
|
-
httpOnly: true,
|
|
86
|
-
sameSite: "lax",
|
|
87
|
-
path: "/",
|
|
88
|
-
maxAge: 60 * 60 * 24 * 15
|
|
89
|
-
};
|
|
90
|
-
var defaultStandardCookieConfig = {
|
|
91
|
-
secure: false,
|
|
92
|
-
httpOnly: true
|
|
93
|
-
};
|
|
94
|
-
var defaultSecureCookieConfig = {
|
|
95
|
-
secure: true,
|
|
96
|
-
httpOnly: true
|
|
97
|
-
};
|
|
98
|
-
var defaultHostCookieConfig = {
|
|
99
|
-
secure: true,
|
|
100
|
-
httpOnly: true,
|
|
101
|
-
path: "/",
|
|
102
|
-
domain: void 0
|
|
103
|
-
};
|
|
104
|
-
var oauthCookieOptions = {
|
|
105
|
-
httpOnly: true,
|
|
106
|
-
maxAge: 5 * 60,
|
|
107
|
-
sameSite: "lax",
|
|
108
|
-
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
109
|
-
};
|
|
110
|
-
var setCookie = (cookieName, value, options) => {
|
|
111
|
-
return (0, import_cookie.serialize)(cookieName, value, options);
|
|
112
|
-
};
|
|
113
|
-
var expiredCookieAttributes = {
|
|
114
|
-
...defaultCookieOptions,
|
|
115
|
-
expires: /* @__PURE__ */ new Date(0),
|
|
116
|
-
maxAge: 0,
|
|
117
|
-
secure: true
|
|
118
|
-
};
|
|
119
|
-
var getCookie = (request, cookieName) => {
|
|
120
|
-
const cookies = request instanceof Request ? request.headers.get("Cookie") : request.get("Cookie");
|
|
121
|
-
if (!cookies) {
|
|
122
|
-
throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
|
|
123
|
-
}
|
|
124
|
-
const value = (0, import_cookie.parse)(cookies)[cookieName];
|
|
125
|
-
if (!value) {
|
|
126
|
-
throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found. There is no active session`);
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
};
|
|
130
|
-
var getSetCookie = (response, cookieName) => {
|
|
131
|
-
const cookies = response.headers.getSetCookie();
|
|
132
|
-
if (!cookies) {
|
|
133
|
-
throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found in response.");
|
|
134
|
-
}
|
|
135
|
-
const strCookie = cookies.find((cookie) => cookie.startsWith(`${cookieName}=`));
|
|
136
|
-
if (!strCookie) {
|
|
137
|
-
throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found in response.`);
|
|
138
|
-
}
|
|
139
|
-
return (0, import_cookie.parseSetCookie)(strCookie).value;
|
|
140
|
-
};
|
|
141
|
-
var createSessionCookie = async (jose, session) => {
|
|
142
|
-
try {
|
|
143
|
-
const encoded = await jose.encodeJWT(session);
|
|
144
|
-
return encoded;
|
|
145
|
-
} catch (error) {
|
|
146
|
-
throw new AuthInternalError("INVALID_JWT_TOKEN", "Failed to create session cookie", { cause: error });
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
var defineSecureCookieOptions = (useSecure, attributes, strategy, logger) => {
|
|
150
|
-
if (!attributes.httpOnly) {
|
|
151
|
-
logger?.log("COOKIE_HTTPONLY_DISABLED");
|
|
152
|
-
}
|
|
153
|
-
if (attributes.domain === "*") {
|
|
154
|
-
attributes.domain = void 0;
|
|
155
|
-
logger?.log("COOKIE_WILDCARD_DOMAIN");
|
|
156
|
-
}
|
|
157
|
-
if (!useSecure) {
|
|
158
|
-
if (attributes.secure) {
|
|
159
|
-
logger?.log("COOKIE_SECURE_DISABLED");
|
|
160
|
-
}
|
|
161
|
-
if (attributes.sameSite == "none") {
|
|
162
|
-
attributes.sameSite = "lax";
|
|
163
|
-
logger?.log("COOKIE_SAMESITE_NONE_WITHOUT_SECURE");
|
|
164
|
-
}
|
|
165
|
-
if (env.NODE_ENV === "production") {
|
|
166
|
-
logger?.log("COOKIE_INSECURE_IN_PRODUCTION");
|
|
167
|
-
}
|
|
168
|
-
if (strategy === "host") {
|
|
169
|
-
logger?.log("COOKIE_HOST_STRATEGY_INSECURE");
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
...defaultCookieOptions,
|
|
173
|
-
...attributes,
|
|
174
|
-
...defaultStandardCookieConfig
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return strategy === "host" ? {
|
|
178
|
-
...defaultCookieOptions,
|
|
179
|
-
...attributes,
|
|
180
|
-
...defaultHostCookieConfig
|
|
181
|
-
} : { ...defaultCookieOptions, ...attributes, ...defaultSecureCookieConfig };
|
|
182
|
-
};
|
|
183
|
-
var createCookieStore = (useSecure, prefix, overrides, logger) => {
|
|
184
|
-
prefix ??= COOKIE_NAME;
|
|
185
|
-
const securePrefix = useSecure ? "__Secure-" : "";
|
|
186
|
-
const hostPrefix = useSecure ? "__Host-" : "";
|
|
187
|
-
return {
|
|
188
|
-
sessionToken: {
|
|
189
|
-
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "session_token"}`,
|
|
190
|
-
attributes: defineSecureCookieOptions(
|
|
191
|
-
useSecure,
|
|
192
|
-
{
|
|
193
|
-
...defaultCookieOptions,
|
|
194
|
-
...overrides?.sessionToken?.attributes
|
|
195
|
-
},
|
|
196
|
-
overrides?.sessionToken?.attributes?.strategy ?? "secure",
|
|
197
|
-
logger
|
|
198
|
-
)
|
|
199
|
-
},
|
|
200
|
-
state: {
|
|
201
|
-
name: `${securePrefix}${prefix}.${overrides?.state?.name ?? "state"}`,
|
|
202
|
-
attributes: defineSecureCookieOptions(
|
|
203
|
-
useSecure,
|
|
204
|
-
{
|
|
205
|
-
...oauthCookieOptions,
|
|
206
|
-
...overrides?.state?.attributes
|
|
207
|
-
},
|
|
208
|
-
overrides?.state?.attributes?.strategy ?? "secure",
|
|
209
|
-
logger
|
|
210
|
-
)
|
|
211
|
-
},
|
|
212
|
-
csrfToken: {
|
|
213
|
-
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "csrf_token"}`,
|
|
214
|
-
attributes: defineSecureCookieOptions(
|
|
215
|
-
useSecure,
|
|
216
|
-
{
|
|
217
|
-
...overrides?.csrfToken?.attributes,
|
|
218
|
-
...defaultHostCookieConfig,
|
|
219
|
-
sameSite: "strict"
|
|
220
|
-
},
|
|
221
|
-
overrides?.csrfToken?.attributes?.strategy ?? "host",
|
|
222
|
-
logger
|
|
223
|
-
)
|
|
224
|
-
},
|
|
225
|
-
redirectTo: {
|
|
226
|
-
name: `${securePrefix}${prefix}.${overrides?.redirectTo?.name ?? "redirect_to"}`,
|
|
227
|
-
attributes: defineSecureCookieOptions(
|
|
228
|
-
useSecure,
|
|
229
|
-
{
|
|
230
|
-
...oauthCookieOptions,
|
|
231
|
-
...overrides?.redirectTo?.attributes
|
|
232
|
-
},
|
|
233
|
-
overrides?.redirectTo?.attributes?.strategy ?? "secure",
|
|
234
|
-
logger
|
|
235
|
-
)
|
|
236
|
-
},
|
|
237
|
-
redirectURI: {
|
|
238
|
-
name: `${securePrefix}${prefix}.${overrides?.redirectURI?.name ?? "redirect_uri"}`,
|
|
239
|
-
attributes: defineSecureCookieOptions(
|
|
240
|
-
useSecure,
|
|
241
|
-
{
|
|
242
|
-
...oauthCookieOptions,
|
|
243
|
-
...overrides?.redirectURI?.attributes
|
|
244
|
-
},
|
|
245
|
-
overrides?.redirectURI?.attributes?.strategy ?? "secure",
|
|
246
|
-
logger
|
|
247
|
-
)
|
|
248
|
-
},
|
|
249
|
-
codeVerifier: {
|
|
250
|
-
name: `${securePrefix}${prefix}.${overrides?.codeVerifier?.name ?? "code_verifier"}`,
|
|
251
|
-
attributes: defineSecureCookieOptions(
|
|
252
|
-
useSecure,
|
|
253
|
-
{
|
|
254
|
-
...oauthCookieOptions,
|
|
255
|
-
...overrides?.codeVerifier?.attributes
|
|
256
|
-
},
|
|
257
|
-
overrides?.codeVerifier?.attributes?.strategy ?? "secure",
|
|
258
|
-
logger
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
264
|
-
0 && (module.exports = {
|
|
265
|
-
COOKIE_NAME,
|
|
266
|
-
createCookieStore,
|
|
267
|
-
createSessionCookie,
|
|
268
|
-
defaultCookieOptions,
|
|
269
|
-
defaultHostCookieConfig,
|
|
270
|
-
defaultSecureCookieConfig,
|
|
271
|
-
defaultStandardCookieConfig,
|
|
272
|
-
defineSecureCookieOptions,
|
|
273
|
-
expiredCookieAttributes,
|
|
274
|
-
getCookie,
|
|
275
|
-
getSetCookie,
|
|
276
|
-
setCookie
|
|
277
|
-
});
|
package/dist/cookie.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { SerializeOptions } from '@aura-stack/router/cookie';
|
|
2
|
-
import { C as CookieConfig, a as InternalLogger, b as CookieStoreConfig, c as AuthRuntimeConfig, U as User } from './index-_aXtxb_s.js';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import './schemas.js';
|
|
5
|
-
import 'zod/v4';
|
|
6
|
-
import '@aura-stack/jose';
|
|
7
|
-
import '@aura-stack/jose/jose';
|
|
8
|
-
import '@aura-stack/jose/crypto';
|
|
9
|
-
import './@types/utility.js';
|
|
10
|
-
import 'jose';
|
|
11
|
-
import '@aura-stack/router';
|
|
12
|
-
import 'zod/v4/core';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Prefix for all cookies set by Aura Auth.
|
|
16
|
-
*/
|
|
17
|
-
declare const COOKIE_NAME = "aura-auth";
|
|
18
|
-
/**
|
|
19
|
-
* Default cookie options used by Aura Auth.
|
|
20
|
-
*/
|
|
21
|
-
declare const defaultCookieOptions: SerializeOptions;
|
|
22
|
-
declare const defaultStandardCookieConfig: SerializeOptions;
|
|
23
|
-
/**
|
|
24
|
-
* Default cookie options for "__Secure-" cookies.
|
|
25
|
-
* @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__secure-prefix
|
|
26
|
-
*/
|
|
27
|
-
declare const defaultSecureCookieConfig: SerializeOptions;
|
|
28
|
-
/**
|
|
29
|
-
* Default cookie options for "__Host-" cookies.
|
|
30
|
-
* @see https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-the-__host-prefix
|
|
31
|
-
*/
|
|
32
|
-
declare const defaultHostCookieConfig: SerializeOptions;
|
|
33
|
-
/**
|
|
34
|
-
* Set a cookie with the given name, value and `SerializeOptions`; supports secure
|
|
35
|
-
* cookies with the `__Secure-` and `__Host-` prefixes.
|
|
36
|
-
*
|
|
37
|
-
* Cookie attributes are serialized in the following order:
|
|
38
|
-
* Expires, Max-Age, Domain, Path, Secure, HttpOnly, SameSite, Partitioned, Priority.
|
|
39
|
-
*/
|
|
40
|
-
declare const setCookie: (cookieName: string, value: string, options?: SerializeOptions) => string;
|
|
41
|
-
declare const expiredCookieAttributes: SerializeOptions;
|
|
42
|
-
/**
|
|
43
|
-
* Get a cookie by name from the request.
|
|
44
|
-
*
|
|
45
|
-
* @param request The incoming request object
|
|
46
|
-
* @param cookie Cookie name to retrieve
|
|
47
|
-
* @returns The value of the cookie or throw an error if not found
|
|
48
|
-
*/
|
|
49
|
-
declare const getCookie: (request: Request | Headers, cookieName: string) => string;
|
|
50
|
-
/**
|
|
51
|
-
* Get a Set-Cookie header value by cookie name from the response.
|
|
52
|
-
*
|
|
53
|
-
* @param response The response object
|
|
54
|
-
* @param cookieName Cookie name to retrieve
|
|
55
|
-
* @returns The value of the Set-Cookie header or throw an error if not found
|
|
56
|
-
*/
|
|
57
|
-
declare const getSetCookie: (response: Response, cookieName: string) => string | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Create a session cookie containing a signed and encrypted JWT, using the
|
|
60
|
-
* `@aura-stack/jose` package for the encoding.
|
|
61
|
-
*
|
|
62
|
-
* @param jose - Jose Instance
|
|
63
|
-
* @param session - The JWT payload to be encoded in the session cookie
|
|
64
|
-
* @returns The serialized session cookie string
|
|
65
|
-
*/
|
|
66
|
-
declare const createSessionCookie: (jose: AuthRuntimeConfig["jose"], session: User) => Promise<string>;
|
|
67
|
-
/**
|
|
68
|
-
* Defines the cookie configuration based on the request security and cookie options passed
|
|
69
|
-
* in the Aura Auth configuration (`createAuth` function). This function ensures the correct
|
|
70
|
-
* cookie prefixes and security attributes are applied based on whether the request is secure
|
|
71
|
-
* (HTTPS) or not.
|
|
72
|
-
*
|
|
73
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Proto
|
|
74
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Forwarded
|
|
75
|
-
* @param useSecure Whether the request is secure (HTTPS)
|
|
76
|
-
* @param attributes The cookie attributes to be applied
|
|
77
|
-
* @param strategy The cookie strategy: "host", "secure", or "standard"
|
|
78
|
-
* @returns The finalized cookie options to be used for setting cookies
|
|
79
|
-
*/
|
|
80
|
-
declare const defineSecureCookieOptions: (useSecure: boolean, attributes: SerializeOptions, strategy: "host" | "secure" | "standard", logger?: InternalLogger) => SerializeOptions;
|
|
81
|
-
/**
|
|
82
|
-
* @param useSecure Whether the request is secure (HTTPS)
|
|
83
|
-
* @param prefix Optional prefix added to all cookie names
|
|
84
|
-
* @param overrides Optional overrides for individual cookie configurations
|
|
85
|
-
* @returns The complete cookie store configuration
|
|
86
|
-
*/
|
|
87
|
-
declare const createCookieStore: (useSecure: boolean, prefix?: string, overrides?: CookieConfig["overrides"], logger?: InternalLogger) => CookieStoreConfig;
|
|
88
|
-
|
|
89
|
-
export { COOKIE_NAME, createCookieStore, createSessionCookie, defaultCookieOptions, defaultHostCookieConfig, defaultSecureCookieConfig, defaultStandardCookieConfig, defineSecureCookieOptions, expiredCookieAttributes, getCookie, getSetCookie, setCookie };
|
package/dist/cookie.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COOKIE_NAME,
|
|
3
|
-
createCookieStore,
|
|
4
|
-
createSessionCookie,
|
|
5
|
-
defaultCookieOptions,
|
|
6
|
-
defaultHostCookieConfig,
|
|
7
|
-
defaultSecureCookieConfig,
|
|
8
|
-
defaultStandardCookieConfig,
|
|
9
|
-
defineSecureCookieOptions,
|
|
10
|
-
expiredCookieAttributes,
|
|
11
|
-
getCookie,
|
|
12
|
-
getSetCookie,
|
|
13
|
-
setCookie
|
|
14
|
-
} from "./chunk-XY5R3EHH.js";
|
|
15
|
-
import "./chunk-WHNDRO3N.js";
|
|
16
|
-
import "./chunk-U5663F2U.js";
|
|
17
|
-
export {
|
|
18
|
-
COOKIE_NAME,
|
|
19
|
-
createCookieStore,
|
|
20
|
-
createSessionCookie,
|
|
21
|
-
defaultCookieOptions,
|
|
22
|
-
defaultHostCookieConfig,
|
|
23
|
-
defaultSecureCookieConfig,
|
|
24
|
-
defaultStandardCookieConfig,
|
|
25
|
-
defineSecureCookieOptions,
|
|
26
|
-
expiredCookieAttributes,
|
|
27
|
-
getCookie,
|
|
28
|
-
getSetCookie,
|
|
29
|
-
setCookie
|
|
30
|
-
};
|