@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,135 @@
|
|
|
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/client/index.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
createAuthClient: () => createAuthClient,
|
|
24
|
+
createClient: () => createClient
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(client_exports);
|
|
27
|
+
|
|
28
|
+
// src/errors.ts
|
|
29
|
+
var AuthClientError = class extends Error {
|
|
30
|
+
type = "AUTH_CLIENT_ERROR";
|
|
31
|
+
code;
|
|
32
|
+
constructor(code, message, options) {
|
|
33
|
+
super(message, options);
|
|
34
|
+
this.code = code;
|
|
35
|
+
this.name = new.target.name;
|
|
36
|
+
Error.captureStackTrace(this, new.target);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var isNativeError = (error) => {
|
|
40
|
+
return error instanceof Error;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/client/client.ts
|
|
44
|
+
var import_router = require("@aura-stack/router");
|
|
45
|
+
var createClient = import_router.createClient;
|
|
46
|
+
var createAuthClient = (options) => {
|
|
47
|
+
if (typeof window === "undefined" && !options.baseURL) {
|
|
48
|
+
throw new AuthClientError("`baseURL` is required when createAuthClient is used outside the browser.");
|
|
49
|
+
}
|
|
50
|
+
const client = createClient({
|
|
51
|
+
cache: "no-store",
|
|
52
|
+
credentials: "include",
|
|
53
|
+
baseURL: options.baseURL ?? window.location.origin,
|
|
54
|
+
...options
|
|
55
|
+
});
|
|
56
|
+
const getCSRFToken = async () => {
|
|
57
|
+
try {
|
|
58
|
+
const response = await client.get("/csrfToken");
|
|
59
|
+
if (!response.ok) return null;
|
|
60
|
+
const data = await response.json();
|
|
61
|
+
return data.csrfToken;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error("Error fetching CSRF token:", error);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const getSession = async () => {
|
|
68
|
+
try {
|
|
69
|
+
const response = await client.get("/session");
|
|
70
|
+
if (!response.ok) return null;
|
|
71
|
+
const session = await response.json();
|
|
72
|
+
if (!session?.authenticated) return null;
|
|
73
|
+
return session.session;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error("Error fetching session:", error);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const signIn = async (oauth, options2) => {
|
|
80
|
+
try {
|
|
81
|
+
const response = await client.get("/signIn/:oauth", {
|
|
82
|
+
params: {
|
|
83
|
+
oauth
|
|
84
|
+
},
|
|
85
|
+
searchParams: {
|
|
86
|
+
...options2,
|
|
87
|
+
redirect: false
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const json = await response.json();
|
|
91
|
+
if ((options2?.redirect ?? true) && typeof window !== "undefined" && json?.signInURL) {
|
|
92
|
+
window.location.assign(json.signInURL);
|
|
93
|
+
}
|
|
94
|
+
return json;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error("Error during sign-in:", error);
|
|
97
|
+
return { redirect: false, signInURL: "/" };
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const signOut = async (options2) => {
|
|
101
|
+
try {
|
|
102
|
+
const csrfToken = await getCSRFToken();
|
|
103
|
+
if (!csrfToken) {
|
|
104
|
+
throw new AuthClientError("Failed to fetch CSRF token for sign-out.");
|
|
105
|
+
}
|
|
106
|
+
const response = await client.post("/signOut", {
|
|
107
|
+
searchParams: {
|
|
108
|
+
redirectTo: options2?.redirectTo ?? "/",
|
|
109
|
+
token_type_hint: "session_token"
|
|
110
|
+
},
|
|
111
|
+
headers: {
|
|
112
|
+
"X-CSRF-Token": csrfToken
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const json = await response.json();
|
|
116
|
+
if ((options2?.redirect ?? true) && typeof window !== "undefined" && json?.url) {
|
|
117
|
+
window.location.assign(json.url);
|
|
118
|
+
}
|
|
119
|
+
return json;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("Error during sign-out:", error);
|
|
122
|
+
throw isNativeError(error) ? error : new AuthClientError("Sign-out failed.", "The sign-out request failed.", { cause: error });
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
getSession,
|
|
127
|
+
signIn,
|
|
128
|
+
signOut
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
createAuthClient,
|
|
134
|
+
createClient
|
|
135
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { createAuthClient, createClient } from './client.js';
|
|
2
|
+
export { p as AuthClient, l as AuthClientOptions, n as SignInOptions, o as SignOutOptions } from '../index-_aXtxb_s.js';
|
|
3
|
+
export { Client, ClientOptions } from '@aura-stack/router/types';
|
|
4
|
+
import 'zod/v4/core';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '@aura-stack/router';
|
|
7
|
+
import '../@types/utility.js';
|
|
8
|
+
import '../schemas.js';
|
|
9
|
+
import 'zod/v4';
|
|
10
|
+
import '@aura-stack/jose';
|
|
11
|
+
import '@aura-stack/jose/jose';
|
|
12
|
+
import '@aura-stack/jose/crypto';
|
|
13
|
+
import '@aura-stack/router/cookie';
|
|
14
|
+
import 'jose';
|