@aura-stack/auth 0.4.0 → 0.5.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.d.ts +6 -2
- package/dist/@types/router.d.d.ts +6 -2
- package/dist/actions/callback/access-token.cjs +103 -59
- package/dist/actions/callback/access-token.d.ts +7 -3
- package/dist/actions/callback/access-token.js +3 -3
- package/dist/actions/callback/callback.cjs +200 -134
- package/dist/actions/callback/callback.d.ts +32 -3
- package/dist/actions/callback/callback.js +11 -12
- package/dist/actions/callback/userinfo.cjs +103 -70
- package/dist/actions/callback/userinfo.d.ts +6 -2
- package/dist/actions/callback/userinfo.js +7 -8
- package/dist/actions/csrfToken/csrfToken.cjs +7 -15
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -1
- package/dist/actions/csrfToken/csrfToken.js +7 -8
- package/dist/actions/index.cjs +502 -295
- package/dist/actions/index.d.ts +5 -2
- package/dist/actions/index.js +23 -20
- package/dist/actions/session/session.cjs +76 -24
- package/dist/actions/session/session.d.ts +3 -1
- package/dist/actions/session/session.js +6 -4
- package/dist/actions/signIn/authorization-url.cjs +288 -0
- package/dist/actions/signIn/authorization-url.d.ts +31 -0
- package/dist/actions/signIn/authorization-url.js +16 -0
- package/dist/actions/signIn/authorization.cjs +91 -132
- package/dist/actions/signIn/authorization.d.ts +17 -16
- package/dist/actions/signIn/authorization.js +8 -7
- package/dist/actions/signIn/signIn.cjs +319 -191
- package/dist/actions/signIn/signIn.d.ts +32 -3
- package/dist/actions/signIn/signIn.js +10 -9
- package/dist/actions/signOut/signOut.cjs +211 -212
- package/dist/actions/signOut/signOut.d.ts +9 -1
- package/dist/actions/signOut/signOut.js +9 -10
- package/dist/api/createApi.cjs +750 -0
- package/dist/api/createApi.d.ts +12 -0
- package/dist/api/createApi.js +19 -0
- package/dist/api/getSession.cjs +141 -0
- package/dist/api/getSession.d.ts +16 -0
- package/dist/api/getSession.js +10 -0
- package/dist/api/signIn.cjs +549 -0
- package/dist/api/signIn.d.ts +26 -0
- package/dist/api/signIn.js +15 -0
- package/dist/api/signOut.cjs +279 -0
- package/dist/api/signOut.d.ts +16 -0
- package/dist/api/signOut.js +13 -0
- package/dist/assert.cjs +42 -9
- package/dist/assert.d.ts +8 -4
- package/dist/assert.js +5 -5
- package/dist/{chunk-KJBAQZX2.js → chunk-2A5B7GWR.js} +44 -11
- package/dist/chunk-2GQLSIJ2.js +40 -0
- package/dist/chunk-2IR674WX.js +44 -0
- package/dist/chunk-3J5TUH2I.js +50 -0
- package/dist/chunk-4RWSYUKX.js +98 -0
- package/dist/chunk-5X7JZMEF.js +0 -0
- package/dist/{chunk-TZB6MUXN.js → chunk-7BE46WWS.js} +21 -11
- package/dist/chunk-7YYXFKLR.js +35 -0
- package/dist/chunk-C3A37LQC.js +33 -0
- package/dist/chunk-CITNGXDA.js +31 -0
- package/dist/chunk-CWX724AG.js +78 -0
- package/dist/chunk-D2CSIUKP.js +74 -0
- package/dist/{chunk-ICAZ4OVS.js → chunk-FPCVZUVG.js} +2 -2
- package/dist/{chunk-XGLBNXL4.js → chunk-GNNBM2WJ.js} +17 -9
- package/dist/chunk-JOCGX3RP.js +59 -0
- package/dist/chunk-KBXWTD6E.js +94 -0
- package/dist/{chunk-XUP6KKNG.js → chunk-LATR3NIV.js} +48 -37
- package/dist/chunk-LAYPUDQF.js +39 -0
- package/dist/chunk-LX3TJ2TJ.js +294 -0
- package/dist/{chunk-6MXFPFR3.js → chunk-NHZBQNRR.js} +19 -19
- package/dist/{chunk-TM5IPSNF.js → chunk-PDP3PHB3.js} +33 -19
- package/dist/chunk-PHYNROD4.js +47 -0
- package/dist/chunk-QQEKY4XP.js +29 -0
- package/dist/{chunk-VNCNJKS2.js → chunk-U4RK4LKJ.js} +82 -1
- package/dist/{chunk-RRLIF4PQ.js → chunk-U5663F2U.js} +16 -1
- package/dist/chunk-UN7X6SU5.js +53 -0
- package/dist/chunk-UZQJJD6A.js +100 -0
- package/dist/{chunk-NUDITUKX.js → chunk-V6LLEAR4.js} +22 -15
- package/dist/{chunk-4MYWAOLG.js → chunk-WHNDRO3N.js} +20 -1
- package/dist/{chunk-5W4BRQYG.js → chunk-XY5R3EHH.js} +6 -3
- package/dist/client/client.cjs +135 -0
- package/dist/client/client.d.ts +85 -0
- package/dist/client/client.js +9 -0
- package/dist/client/index.cjs +135 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.js +10 -0
- package/dist/context.cjs +1237 -0
- package/dist/context.d.ts +16 -0
- package/dist/context.js +28 -0
- package/dist/cookie.cjs +33 -2
- package/dist/cookie.d.ts +9 -5
- package/dist/cookie.js +3 -2
- package/dist/createAuth.cjs +2320 -0
- package/dist/createAuth.d.ts +12 -0
- package/dist/createAuth.js +48 -0
- package/dist/env.cjs +24 -2
- package/dist/env.d.ts +4 -1
- package/dist/env.js +9 -3
- package/dist/errors.cjs +17 -0
- package/dist/errors.d.ts +13 -3
- package/dist/errors.js +5 -1
- package/dist/{index-CSyIJmCM.d.ts → index-_aXtxb_s.d.ts} +383 -13
- package/dist/index.cjs +2135 -1547
- package/dist/index.d.ts +9 -30
- package/dist/index.js +46 -119
- package/dist/jose.cjs +52 -14
- package/dist/jose.d.ts +12 -25
- package/dist/jose.js +11 -3
- package/dist/logger.cjs +132 -0
- package/dist/logger.d.ts +6 -2
- package/dist/logger.js +10 -1
- package/dist/oauth/atlassian.cjs +57 -0
- package/dist/oauth/atlassian.d.ts +12 -0
- package/dist/oauth/atlassian.js +6 -0
- package/dist/oauth/bitbucket.d.ts +6 -2
- package/dist/oauth/discord.d.ts +6 -2
- package/dist/oauth/dropbox.cjs +53 -0
- package/dist/oauth/dropbox.d.ts +12 -0
- package/dist/oauth/dropbox.js +6 -0
- package/dist/oauth/figma.d.ts +6 -2
- package/dist/oauth/github.d.ts +6 -2
- package/dist/oauth/gitlab.d.ts +6 -2
- package/dist/oauth/index.cjs +278 -88
- package/dist/oauth/index.d.ts +6 -2
- package/dist/oauth/index.js +27 -11
- package/dist/oauth/mailchimp.d.ts +6 -2
- package/dist/oauth/notion.cjs +131 -0
- package/dist/oauth/notion.d.ts +12 -0
- package/dist/oauth/notion.js +9 -0
- package/dist/oauth/pinterest.d.ts +6 -2
- package/dist/oauth/spotify.d.ts +6 -2
- package/dist/oauth/strava.d.ts +6 -2
- package/dist/oauth/twitch.cjs +95 -0
- package/dist/oauth/twitch.d.ts +12 -0
- package/dist/oauth/twitch.js +7 -0
- package/dist/oauth/x.d.ts +6 -2
- package/dist/schemas.cjs +84 -51
- package/dist/schemas.d.ts +103 -23
- package/dist/schemas.js +1 -1
- package/dist/secure.cjs +36 -36
- package/dist/secure.d.ts +10 -4
- package/dist/secure.js +7 -6
- package/dist/utils.cjs +109 -3
- package/dist/utils.d.ts +15 -4
- package/dist/utils.js +11 -4
- package/package.json +9 -5
- package/dist/chunk-4EKY7655.js +0 -123
- package/dist/chunk-7QF22LHP.js +0 -67
- package/dist/chunk-ALG3GIV4.js +0 -95
- package/dist/chunk-FRJFWTOY.js +0 -70
- package/dist/chunk-PHFH2MGS.js +0 -36
- package/dist/chunk-QQVSRXGX.js +0 -149
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@aura-stack/router';
|
|
2
|
+
export { az as createAuthAPI } from '../index-_aXtxb_s.js';
|
|
3
|
+
import '../@types/utility.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '../schemas.js';
|
|
6
|
+
import 'zod/v4';
|
|
7
|
+
import '@aura-stack/jose';
|
|
8
|
+
import '@aura-stack/jose/jose';
|
|
9
|
+
import '@aura-stack/jose/crypto';
|
|
10
|
+
import '@aura-stack/router/cookie';
|
|
11
|
+
import 'jose';
|
|
12
|
+
import 'zod/v4/core';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthAPI
|
|
3
|
+
} from "../chunk-LAYPUDQF.js";
|
|
4
|
+
import "../chunk-CITNGXDA.js";
|
|
5
|
+
import "../chunk-JOCGX3RP.js";
|
|
6
|
+
import "../chunk-D2CSIUKP.js";
|
|
7
|
+
import "../chunk-LATR3NIV.js";
|
|
8
|
+
import "../chunk-KBXWTD6E.js";
|
|
9
|
+
import "../chunk-V6LLEAR4.js";
|
|
10
|
+
import "../chunk-2A5B7GWR.js";
|
|
11
|
+
import "../chunk-UZQJJD6A.js";
|
|
12
|
+
import "../chunk-LX3TJ2TJ.js";
|
|
13
|
+
import "../chunk-XY5R3EHH.js";
|
|
14
|
+
import "../chunk-WHNDRO3N.js";
|
|
15
|
+
import "../chunk-U5663F2U.js";
|
|
16
|
+
import "../chunk-EBAMFRB7.js";
|
|
17
|
+
export {
|
|
18
|
+
createAuthAPI
|
|
19
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
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/api/getSession.ts
|
|
21
|
+
var getSession_exports = {};
|
|
22
|
+
__export(getSession_exports, {
|
|
23
|
+
getSession: () => getSession
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(getSession_exports);
|
|
26
|
+
|
|
27
|
+
// src/env.ts
|
|
28
|
+
var import_meta = {};
|
|
29
|
+
var env = new Proxy({}, {
|
|
30
|
+
get(_, prop) {
|
|
31
|
+
if (typeof prop !== "string") return void 0;
|
|
32
|
+
const hasProperty = (process2) => {
|
|
33
|
+
return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
if (typeof process !== "undefined" && hasProperty(process.env)) {
|
|
37
|
+
return process.env[prop];
|
|
38
|
+
}
|
|
39
|
+
if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
|
|
40
|
+
return import_meta.env[prop];
|
|
41
|
+
}
|
|
42
|
+
if (typeof Deno !== "undefined" && Deno.env?.get) {
|
|
43
|
+
return Deno.env.get(prop);
|
|
44
|
+
}
|
|
45
|
+
if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
|
|
46
|
+
return Bun.env[prop];
|
|
47
|
+
}
|
|
48
|
+
const globalValue = globalThis[prop];
|
|
49
|
+
return typeof globalValue === "string" ? globalValue : void 0;
|
|
50
|
+
} catch {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// src/cookie.ts
|
|
57
|
+
var import_cookie = require("@aura-stack/router/cookie");
|
|
58
|
+
|
|
59
|
+
// src/errors.ts
|
|
60
|
+
var AuthInternalError = class extends Error {
|
|
61
|
+
type = "AUTH_INTERNAL_ERROR";
|
|
62
|
+
code;
|
|
63
|
+
constructor(code, message, options) {
|
|
64
|
+
super(message, options);
|
|
65
|
+
this.code = code;
|
|
66
|
+
this.name = new.target.name;
|
|
67
|
+
Error.captureStackTrace(this, new.target);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/cookie.ts
|
|
72
|
+
var defaultCookieOptions = {
|
|
73
|
+
httpOnly: true,
|
|
74
|
+
sameSite: "lax",
|
|
75
|
+
path: "/",
|
|
76
|
+
maxAge: 60 * 60 * 24 * 15
|
|
77
|
+
};
|
|
78
|
+
var oauthCookieOptions = {
|
|
79
|
+
httpOnly: true,
|
|
80
|
+
maxAge: 5 * 60,
|
|
81
|
+
sameSite: "lax",
|
|
82
|
+
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
83
|
+
};
|
|
84
|
+
var expiredCookieAttributes = {
|
|
85
|
+
...defaultCookieOptions,
|
|
86
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
87
|
+
maxAge: 0,
|
|
88
|
+
secure: true
|
|
89
|
+
};
|
|
90
|
+
var getCookie = (request, cookieName) => {
|
|
91
|
+
const cookies = request instanceof Request ? request.headers.get("Cookie") : request.get("Cookie");
|
|
92
|
+
if (!cookies) {
|
|
93
|
+
throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
|
|
94
|
+
}
|
|
95
|
+
const value = (0, import_cookie.parse)(cookies)[cookieName];
|
|
96
|
+
if (!value) {
|
|
97
|
+
throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found. There is no active session`);
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/utils.ts
|
|
103
|
+
var import_router = require("@aura-stack/router");
|
|
104
|
+
|
|
105
|
+
// src/assert.ts
|
|
106
|
+
var import_crypto = require("@aura-stack/jose/crypto");
|
|
107
|
+
|
|
108
|
+
// src/utils.ts
|
|
109
|
+
var toISOString = (date) => {
|
|
110
|
+
return new Date(date).toISOString();
|
|
111
|
+
};
|
|
112
|
+
var getErrorName = (error) => {
|
|
113
|
+
if (error instanceof Error) {
|
|
114
|
+
return error.name;
|
|
115
|
+
}
|
|
116
|
+
return typeof error === "string" ? error : "UnknownError";
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/api/getSession.ts
|
|
120
|
+
var getSession = async ({ ctx, headers }) => {
|
|
121
|
+
try {
|
|
122
|
+
const session = getCookie(new Headers(headers), ctx.cookies.sessionToken.name);
|
|
123
|
+
const decoded = await ctx.jose.decodeJWT(session);
|
|
124
|
+
ctx?.logger?.log("AUTH_SESSION_VALID");
|
|
125
|
+
const { exp, iat, jti, nbf, aud, iss, ...user } = decoded;
|
|
126
|
+
return {
|
|
127
|
+
session: {
|
|
128
|
+
user,
|
|
129
|
+
expires: toISOString(exp * 1e3)
|
|
130
|
+
},
|
|
131
|
+
authenticated: true
|
|
132
|
+
};
|
|
133
|
+
} catch (error) {
|
|
134
|
+
ctx?.logger?.log("AUTH_SESSION_INVALID", { structuredData: { error_type: getErrorName(error) } });
|
|
135
|
+
return { session: null, authenticated: false };
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
getSession
|
|
141
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { F as FunctionAPIContext, G as GetSessionAPIOptions, S as SessionResponse } 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 getSession: ({ ctx, headers }: FunctionAPIContext<GetSessionAPIOptions>) => Promise<SessionResponse>;
|
|
15
|
+
|
|
16
|
+
export { getSession };
|