@aura-stack/auth 0.5.0 → 0.6.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-B3iQSYlK.js +3 -0
- package/dist/assert-NJGroSJd.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-Bz8nIciY.js +1 -0
- package/dist/crypto-CoXA5w_4.cjs +1 -0
- package/dist/env-bq387KyP.cjs +1 -0
- package/dist/env-nvh8QBNz.js +1 -0
- package/dist/errors-CCYPHuBO.cjs +1 -0
- package/dist/errors-DFWHOho6.js +1 -0
- package/dist/index-BkpwQ0l4.d.cts +2279 -0
- package/dist/index-nqLV2t91.d.ts +2279 -0
- package/dist/index.cjs +1 -2427
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.js +1 -59
- package/dist/logger-C59_CDMk.js +1 -0
- package/dist/logger-UnUhYL2V.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/discord.cjs +1 -57
- package/dist/oauth/discord.d.ts +2 -12
- package/dist/oauth/discord.js +1 -6
- 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-BntNm6aE.cjs +1 -0
- package/dist/oauth-DmHy9VrB.js +1 -0
- package/dist/shared/crypto.cjs +1 -0
- package/dist/shared/crypto.d.ts +47 -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 +32 -9
- 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
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
|
-
import { z } from 'zod/v4';
|
|
3
|
-
import { O as OAuthProviderRecord } from '../../index-_aXtxb_s.js';
|
|
4
|
-
import 'zod';
|
|
5
|
-
import '../../schemas.js';
|
|
6
|
-
import '@aura-stack/jose';
|
|
7
|
-
import '@aura-stack/jose/jose';
|
|
8
|
-
import '@aura-stack/jose/crypto';
|
|
9
|
-
import '@aura-stack/router/cookie';
|
|
10
|
-
import '../../@types/utility.js';
|
|
11
|
-
import 'jose';
|
|
12
|
-
import 'zod/v4/core';
|
|
13
|
-
|
|
14
|
-
declare const callbackAction: (oauth: OAuthProviderRecord) => _aura_stack_router.RouteEndpoint<"GET", "/callback/:oauth", {
|
|
15
|
-
schemas?: {
|
|
16
|
-
params: z.ZodObject<{
|
|
17
|
-
oauth: z.ZodEnum<{
|
|
18
|
-
[x: string & Record<never, never>]: string & Record<never, never>;
|
|
19
|
-
github: "github";
|
|
20
|
-
bitbucket: "bitbucket";
|
|
21
|
-
figma: "figma";
|
|
22
|
-
discord: "discord";
|
|
23
|
-
gitlab: "gitlab";
|
|
24
|
-
spotify: "spotify";
|
|
25
|
-
x: "x";
|
|
26
|
-
strava: "strava";
|
|
27
|
-
mailchimp: "mailchimp";
|
|
28
|
-
pinterest: "pinterest";
|
|
29
|
-
twitch: "twitch";
|
|
30
|
-
notion: "notion";
|
|
31
|
-
dropbox: "dropbox";
|
|
32
|
-
atlassian: "atlassian";
|
|
33
|
-
}>;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
searchParams: z.ZodObject<{
|
|
36
|
-
code: z.ZodString;
|
|
37
|
-
state: z.ZodString;
|
|
38
|
-
}, z.core.$strip>;
|
|
39
|
-
} | undefined;
|
|
40
|
-
}>;
|
|
41
|
-
|
|
42
|
-
export { callbackAction };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
callbackAction
|
|
3
|
-
} from "../../chunk-NHZBQNRR.js";
|
|
4
|
-
import "../../chunk-GNNBM2WJ.js";
|
|
5
|
-
import "../../chunk-7BE46WWS.js";
|
|
6
|
-
import "../../chunk-LATR3NIV.js";
|
|
7
|
-
import "../../chunk-ZNCZVF6U.js";
|
|
8
|
-
import "../../chunk-V6LLEAR4.js";
|
|
9
|
-
import "../../chunk-2A5B7GWR.js";
|
|
10
|
-
import "../../chunk-UZQJJD6A.js";
|
|
11
|
-
import "../../chunk-LX3TJ2TJ.js";
|
|
12
|
-
import "../../chunk-XY5R3EHH.js";
|
|
13
|
-
import "../../chunk-WHNDRO3N.js";
|
|
14
|
-
import "../../chunk-U5663F2U.js";
|
|
15
|
-
import "../../chunk-EBAMFRB7.js";
|
|
16
|
-
export {
|
|
17
|
-
callbackAction
|
|
18
|
-
};
|
|
@@ -1,283 +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/actions/callback/userinfo.ts
|
|
21
|
-
var userinfo_exports = {};
|
|
22
|
-
__export(userinfo_exports, {
|
|
23
|
-
getUserInfo: () => getUserInfo
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(userinfo_exports);
|
|
26
|
-
|
|
27
|
-
// src/request.ts
|
|
28
|
-
var fetchAsync = async (url, options2 = {}, timeout = 5e3) => {
|
|
29
|
-
const controller = new AbortController();
|
|
30
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
31
|
-
const response = await fetch(url, {
|
|
32
|
-
...options2,
|
|
33
|
-
signal: controller.signal
|
|
34
|
-
}).finally(() => clearTimeout(timeoutId));
|
|
35
|
-
return response;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// src/utils.ts
|
|
39
|
-
var import_router = require("@aura-stack/router");
|
|
40
|
-
|
|
41
|
-
// src/errors.ts
|
|
42
|
-
var OAuthProtocolError = class extends Error {
|
|
43
|
-
type = "OAUTH_PROTOCOL_ERROR";
|
|
44
|
-
error;
|
|
45
|
-
errorURI;
|
|
46
|
-
constructor(error, description, errorURI, options2) {
|
|
47
|
-
super(description, options2);
|
|
48
|
-
this.error = error;
|
|
49
|
-
this.errorURI = errorURI;
|
|
50
|
-
this.name = new.target.name;
|
|
51
|
-
Error.captureStackTrace(this, new.target);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var isNativeError = (error) => {
|
|
55
|
-
return error instanceof Error;
|
|
56
|
-
};
|
|
57
|
-
var isOAuthProtocolError = (error) => {
|
|
58
|
-
return error instanceof OAuthProtocolError;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// src/env.ts
|
|
62
|
-
var import_meta = {};
|
|
63
|
-
var env = new Proxy({}, {
|
|
64
|
-
get(_, prop) {
|
|
65
|
-
if (typeof prop !== "string") return void 0;
|
|
66
|
-
const hasProperty = (process2) => {
|
|
67
|
-
return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
|
|
68
|
-
};
|
|
69
|
-
try {
|
|
70
|
-
if (typeof process !== "undefined" && hasProperty(process.env)) {
|
|
71
|
-
return process.env[prop];
|
|
72
|
-
}
|
|
73
|
-
if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
|
|
74
|
-
return import_meta.env[prop];
|
|
75
|
-
}
|
|
76
|
-
if (typeof Deno !== "undefined" && Deno.env?.get) {
|
|
77
|
-
return Deno.env.get(prop);
|
|
78
|
-
}
|
|
79
|
-
if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
|
|
80
|
-
return Bun.env[prop];
|
|
81
|
-
}
|
|
82
|
-
const globalValue = globalThis[prop];
|
|
83
|
-
return typeof globalValue === "string" ? globalValue : void 0;
|
|
84
|
-
} catch {
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// src/assert.ts
|
|
91
|
-
var import_crypto = require("@aura-stack/jose/crypto");
|
|
92
|
-
|
|
93
|
-
// src/utils.ts
|
|
94
|
-
var AURA_AUTH_VERSION = "0.4.0";
|
|
95
|
-
|
|
96
|
-
// src/jose.ts
|
|
97
|
-
var import_jose = require("@aura-stack/jose");
|
|
98
|
-
var import_jose2 = require("@aura-stack/jose/jose");
|
|
99
|
-
var import_crypto2 = require("@aura-stack/jose/crypto");
|
|
100
|
-
|
|
101
|
-
// src/secure.ts
|
|
102
|
-
var generateSecure = (length = 32) => {
|
|
103
|
-
return import_jose2.base64url.encode((0, import_crypto2.getRandomBytes)(length));
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// src/schemas.ts
|
|
107
|
-
var import_v4 = require("zod/v4");
|
|
108
|
-
var AuthorizeConfigSchema = import_v4.z.union([
|
|
109
|
-
(0, import_v4.string)().url(),
|
|
110
|
-
(0, import_v4.object)({
|
|
111
|
-
url: (0, import_v4.string)().url(),
|
|
112
|
-
params: (0, import_v4.object)({
|
|
113
|
-
responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
|
|
114
|
-
scope: (0, import_v4.string)().optional()
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
]);
|
|
118
|
-
var AccessTokenConfigSchema = import_v4.z.union([
|
|
119
|
-
(0, import_v4.string)().url(),
|
|
120
|
-
(0, import_v4.object)({
|
|
121
|
-
url: (0, import_v4.string)().url(),
|
|
122
|
-
headers: import_v4.z.record((0, import_v4.string)(), (0, import_v4.string)()).optional()
|
|
123
|
-
})
|
|
124
|
-
]);
|
|
125
|
-
var UserInfoConfigSchema = import_v4.z.union([
|
|
126
|
-
(0, import_v4.string)().url(),
|
|
127
|
-
(0, import_v4.object)({
|
|
128
|
-
url: (0, import_v4.string)().url(),
|
|
129
|
-
headers: import_v4.z.record((0, import_v4.string)(), (0, import_v4.string)()).optional(),
|
|
130
|
-
method: (0, import_v4.string)().optional()
|
|
131
|
-
})
|
|
132
|
-
]);
|
|
133
|
-
var OAuthProviderCredentialsSchema = (0, import_v4.object)({
|
|
134
|
-
id: (0, import_v4.string)(),
|
|
135
|
-
name: (0, import_v4.string)(),
|
|
136
|
-
authorize: AuthorizeConfigSchema.optional(),
|
|
137
|
-
/** @deprecated */
|
|
138
|
-
authorizeURL: (0, import_v4.string)().url().optional(),
|
|
139
|
-
accessToken: AccessTokenConfigSchema,
|
|
140
|
-
/** @deprecated */
|
|
141
|
-
scope: (0, import_v4.string)().optional(),
|
|
142
|
-
userInfo: UserInfoConfigSchema,
|
|
143
|
-
/** @deprecated */
|
|
144
|
-
responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
|
|
145
|
-
clientId: (0, import_v4.string)(),
|
|
146
|
-
clientSecret: (0, import_v4.string)(),
|
|
147
|
-
profile: import_v4.z.function().optional()
|
|
148
|
-
});
|
|
149
|
-
var OAuthProviderConfigSchema = (0, import_v4.object)({
|
|
150
|
-
authorize: AuthorizeConfigSchema.optional(),
|
|
151
|
-
/** @deprecated */
|
|
152
|
-
authorizeURL: (0, import_v4.string)().url().optional(),
|
|
153
|
-
accessToken: AccessTokenConfigSchema,
|
|
154
|
-
/** @deprecated */
|
|
155
|
-
scope: (0, import_v4.string)().optional(),
|
|
156
|
-
userInfo: UserInfoConfigSchema,
|
|
157
|
-
/** @deprecated */
|
|
158
|
-
responseType: (0, import_v4.enum)(["code", "token", "id_token", "refresh_token"]).optional(),
|
|
159
|
-
clientId: (0, import_v4.string)(),
|
|
160
|
-
clientSecret: (0, import_v4.string)()
|
|
161
|
-
});
|
|
162
|
-
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
163
|
-
redirectURI: (0, import_v4.string)(),
|
|
164
|
-
state: (0, import_v4.string)(),
|
|
165
|
-
codeChallenge: (0, import_v4.string)(),
|
|
166
|
-
codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
|
|
167
|
-
});
|
|
168
|
-
var OAuthAuthorizationResponse = (0, import_v4.object)({
|
|
169
|
-
state: (0, import_v4.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
170
|
-
code: (0, import_v4.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
171
|
-
});
|
|
172
|
-
var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
173
|
-
error: (0, import_v4.enum)([
|
|
174
|
-
"invalid_request",
|
|
175
|
-
"unauthorized_client",
|
|
176
|
-
"access_denied",
|
|
177
|
-
"unsupported_response_type",
|
|
178
|
-
"invalid_scope",
|
|
179
|
-
"server_error",
|
|
180
|
-
"temporarily_unavailable"
|
|
181
|
-
]),
|
|
182
|
-
error_description: (0, import_v4.string)().optional(),
|
|
183
|
-
error_uri: (0, import_v4.string)().optional(),
|
|
184
|
-
state: (0, import_v4.string)()
|
|
185
|
-
});
|
|
186
|
-
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
187
|
-
redirectURI: (0, import_v4.string)(),
|
|
188
|
-
code: (0, import_v4.string)(),
|
|
189
|
-
codeVerifier: (0, import_v4.string)().min(43).max(128)
|
|
190
|
-
});
|
|
191
|
-
var OAuthAccessTokenResponse = (0, import_v4.object)({
|
|
192
|
-
access_token: (0, import_v4.string)(),
|
|
193
|
-
token_type: (0, import_v4.string)().optional(),
|
|
194
|
-
expires_in: (0, import_v4.number)().optional(),
|
|
195
|
-
refresh_token: (0, import_v4.string)().optional(),
|
|
196
|
-
scope: (0, import_v4.union)([(0, import_v4.string)().optional().or((0, import_v4.null)()), (0, import_v4.array)((0, import_v4.string)()).optional()])
|
|
197
|
-
});
|
|
198
|
-
var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
199
|
-
error: (0, import_v4.enum)([
|
|
200
|
-
"invalid_request",
|
|
201
|
-
"invalid_client",
|
|
202
|
-
"invalid_grant",
|
|
203
|
-
"unauthorized_client",
|
|
204
|
-
"unsupported_grant_type",
|
|
205
|
-
"invalid_scope"
|
|
206
|
-
]),
|
|
207
|
-
error_description: (0, import_v4.string)().optional(),
|
|
208
|
-
error_uri: (0, import_v4.string)().optional()
|
|
209
|
-
});
|
|
210
|
-
var OAuthErrorResponse = (0, import_v4.object)({
|
|
211
|
-
error: (0, import_v4.string)(),
|
|
212
|
-
error_description: (0, import_v4.string)().optional()
|
|
213
|
-
});
|
|
214
|
-
var OAuthEnvSchema = (0, import_v4.object)({
|
|
215
|
-
clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
216
|
-
clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
// src/actions/callback/userinfo.ts
|
|
220
|
-
var getDefaultUserInfo = (profile) => {
|
|
221
|
-
const sub = generateSecure(16);
|
|
222
|
-
return {
|
|
223
|
-
sub: profile?.id ?? profile?.sub ?? sub,
|
|
224
|
-
email: profile?.email,
|
|
225
|
-
name: profile?.name ?? profile?.username ?? profile?.nickname,
|
|
226
|
-
image: profile?.image ?? profile?.picture
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
var getUserInfo = async (oauthConfig, accessToken, logger) => {
|
|
230
|
-
const userInfoConfig = oauthConfig.userInfo;
|
|
231
|
-
const userinfoURL = typeof userInfoConfig === "string" ? userInfoConfig : userInfoConfig.url;
|
|
232
|
-
const extraHeaders = typeof userInfoConfig === "string" ? void 0 : userInfoConfig.headers;
|
|
233
|
-
const method = typeof userInfoConfig === "string" ? "GET" : (userInfoConfig.method ?? "GET").toUpperCase();
|
|
234
|
-
try {
|
|
235
|
-
logger?.log("OAUTH_USERINFO_REQUEST_INITIATED", {
|
|
236
|
-
structuredData: {
|
|
237
|
-
endpoint: userinfoURL
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
const response = await fetchAsync(userinfoURL, {
|
|
241
|
-
method,
|
|
242
|
-
headers: {
|
|
243
|
-
"User-Agent": `Aura Auth/${AURA_AUTH_VERSION}`,
|
|
244
|
-
Accept: "application/json",
|
|
245
|
-
Authorization: `Bearer ${accessToken}`,
|
|
246
|
-
...extraHeaders ?? {}
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
if (!response.ok) {
|
|
250
|
-
logger?.log("OAUTH_USERINFO_INVALID_RESPONSE");
|
|
251
|
-
throw new OAuthProtocolError("INVALID_REQUEST", "Invalid userinfo response format");
|
|
252
|
-
}
|
|
253
|
-
const json = await response.json();
|
|
254
|
-
const { success, data } = OAuthErrorResponse.safeParse(json);
|
|
255
|
-
if (success) {
|
|
256
|
-
logger?.log("OAUTH_USERINFO_ERROR", {
|
|
257
|
-
message: "Error response received from OAuth userinfo endpoint",
|
|
258
|
-
structuredData: {
|
|
259
|
-
error: data.error,
|
|
260
|
-
error_description: data.error_description ?? ""
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
throw new OAuthProtocolError("INVALID_REQUEST", "An error was received from the OAuth userinfo endpoint.");
|
|
264
|
-
}
|
|
265
|
-
logger?.log("OAUTH_USERINFO_SUCCESS");
|
|
266
|
-
return oauthConfig?.profile ? oauthConfig.profile(json) : getDefaultUserInfo(json);
|
|
267
|
-
} catch (error) {
|
|
268
|
-
if (isOAuthProtocolError(error)) {
|
|
269
|
-
throw error;
|
|
270
|
-
}
|
|
271
|
-
logger?.log("OAUTH_USERINFO_REQUEST_FAILED");
|
|
272
|
-
if (isNativeError(error)) {
|
|
273
|
-
throw new OAuthProtocolError("SERVER_ERROR", "Failed to fetch user information from OAuth provider", "", {
|
|
274
|
-
cause: error
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
throw new OAuthProtocolError("SERVER_ERROR", "Failed to fetch user information", "", { cause: error });
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
281
|
-
0 && (module.exports = {
|
|
282
|
-
getUserInfo
|
|
283
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { j as OAuthProviderCredentials, a as InternalLogger, U as User } 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
|
-
/**
|
|
15
|
-
* Get user information from the OAuth provider's userinfo endpoint using the provided access token.
|
|
16
|
-
* The response by default is mapped to the standardized `User` format unless a custom
|
|
17
|
-
* `profile` function is provided in the `oauthConfig`.
|
|
18
|
-
*
|
|
19
|
-
* @param oauthConfig - OAuth provider configuration
|
|
20
|
-
* @param accessToken - Access Token to access the userinfo endpoint
|
|
21
|
-
* @returns The user information retrieved from the userinfo endpoint
|
|
22
|
-
*/
|
|
23
|
-
declare const getUserInfo: (oauthConfig: OAuthProviderCredentials, accessToken: string, logger?: InternalLogger) => Promise<User>;
|
|
24
|
-
|
|
25
|
-
export { getUserInfo };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getUserInfo
|
|
3
|
-
} from "../../chunk-GNNBM2WJ.js";
|
|
4
|
-
import "../../chunk-ZNCZVF6U.js";
|
|
5
|
-
import "../../chunk-V6LLEAR4.js";
|
|
6
|
-
import "../../chunk-2A5B7GWR.js";
|
|
7
|
-
import "../../chunk-UZQJJD6A.js";
|
|
8
|
-
import "../../chunk-LX3TJ2TJ.js";
|
|
9
|
-
import "../../chunk-WHNDRO3N.js";
|
|
10
|
-
import "../../chunk-U5663F2U.js";
|
|
11
|
-
export {
|
|
12
|
-
getUserInfo
|
|
13
|
-
};
|
|
@@ -1,189 +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/actions/csrfToken/csrfToken.ts
|
|
21
|
-
var csrfToken_exports = {};
|
|
22
|
-
__export(csrfToken_exports, {
|
|
23
|
-
csrfTokenAction: () => csrfTokenAction
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(csrfToken_exports);
|
|
26
|
-
var import_router2 = require("@aura-stack/router");
|
|
27
|
-
|
|
28
|
-
// src/utils.ts
|
|
29
|
-
var import_router = require("@aura-stack/router");
|
|
30
|
-
|
|
31
|
-
// src/errors.ts
|
|
32
|
-
var AuthInternalError = class extends Error {
|
|
33
|
-
type = "AUTH_INTERNAL_ERROR";
|
|
34
|
-
code;
|
|
35
|
-
constructor(code, message, options) {
|
|
36
|
-
super(message, options);
|
|
37
|
-
this.code = code;
|
|
38
|
-
this.name = new.target.name;
|
|
39
|
-
Error.captureStackTrace(this, new.target);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/env.ts
|
|
44
|
-
var import_meta = {};
|
|
45
|
-
var env = new Proxy({}, {
|
|
46
|
-
get(_, prop) {
|
|
47
|
-
if (typeof prop !== "string") return void 0;
|
|
48
|
-
const hasProperty = (process2) => {
|
|
49
|
-
return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
if (typeof process !== "undefined" && hasProperty(process.env)) {
|
|
53
|
-
return process.env[prop];
|
|
54
|
-
}
|
|
55
|
-
if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
|
|
56
|
-
return import_meta.env[prop];
|
|
57
|
-
}
|
|
58
|
-
if (typeof Deno !== "undefined" && Deno.env?.get) {
|
|
59
|
-
return Deno.env.get(prop);
|
|
60
|
-
}
|
|
61
|
-
if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
|
|
62
|
-
return Bun.env[prop];
|
|
63
|
-
}
|
|
64
|
-
const globalValue = globalThis[prop];
|
|
65
|
-
return typeof globalValue === "string" ? globalValue : void 0;
|
|
66
|
-
} catch {
|
|
67
|
-
return void 0;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// src/assert.ts
|
|
73
|
-
var import_crypto = require("@aura-stack/jose/crypto");
|
|
74
|
-
|
|
75
|
-
// src/jose.ts
|
|
76
|
-
var import_jose = require("@aura-stack/jose");
|
|
77
|
-
var import_jose2 = require("@aura-stack/jose/jose");
|
|
78
|
-
var import_crypto2 = require("@aura-stack/jose/crypto");
|
|
79
|
-
var jwtVerificationOptions = {
|
|
80
|
-
algorithms: ["HS256"],
|
|
81
|
-
typ: "JWT"
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/secure.ts
|
|
85
|
-
var generateSecure = (length = 32) => {
|
|
86
|
-
return import_jose2.base64url.encode((0, import_crypto2.getRandomBytes)(length));
|
|
87
|
-
};
|
|
88
|
-
var createCSRF = async (jose, csrfCookie) => {
|
|
89
|
-
try {
|
|
90
|
-
const token = generateSecure(32);
|
|
91
|
-
if (csrfCookie) {
|
|
92
|
-
await jose.verifyJWS(csrfCookie, jwtVerificationOptions);
|
|
93
|
-
return csrfCookie;
|
|
94
|
-
}
|
|
95
|
-
return jose.signJWS({ token });
|
|
96
|
-
} catch {
|
|
97
|
-
const token = generateSecure(32);
|
|
98
|
-
return jose.signJWS({ token });
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/headers.ts
|
|
103
|
-
var cacheControl = {
|
|
104
|
-
"Cache-Control": "no-store",
|
|
105
|
-
Pragma: "no-cache",
|
|
106
|
-
Expires: "0",
|
|
107
|
-
Vary: "Cookie"
|
|
108
|
-
};
|
|
109
|
-
var contentSecurityPolicy = {
|
|
110
|
-
"Content-Security-Policy": [
|
|
111
|
-
"default-src 'none'",
|
|
112
|
-
"script-src 'self'",
|
|
113
|
-
"frame-src 'none'",
|
|
114
|
-
"object-src 'none'",
|
|
115
|
-
"frame-ancestors 'none'",
|
|
116
|
-
"base-uri 'none'"
|
|
117
|
-
].join("; ")
|
|
118
|
-
};
|
|
119
|
-
var secureHeaders = {
|
|
120
|
-
"X-Content-Type-Options": "nosniff",
|
|
121
|
-
"X-Frame-Options": "DENY",
|
|
122
|
-
"Referrer-Policy": "strict-origin-when-cross-origin"
|
|
123
|
-
};
|
|
124
|
-
var secureApiHeaders = {
|
|
125
|
-
...cacheControl,
|
|
126
|
-
...contentSecurityPolicy,
|
|
127
|
-
...secureHeaders
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// src/cookie.ts
|
|
131
|
-
var import_cookie = require("@aura-stack/router/cookie");
|
|
132
|
-
var defaultCookieOptions = {
|
|
133
|
-
httpOnly: true,
|
|
134
|
-
sameSite: "lax",
|
|
135
|
-
path: "/",
|
|
136
|
-
maxAge: 60 * 60 * 24 * 15
|
|
137
|
-
};
|
|
138
|
-
var oauthCookieOptions = {
|
|
139
|
-
httpOnly: true,
|
|
140
|
-
maxAge: 5 * 60,
|
|
141
|
-
sameSite: "lax",
|
|
142
|
-
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
143
|
-
};
|
|
144
|
-
var setCookie = (cookieName, value, options) => {
|
|
145
|
-
return (0, import_cookie.serialize)(cookieName, value, options);
|
|
146
|
-
};
|
|
147
|
-
var expiredCookieAttributes = {
|
|
148
|
-
...defaultCookieOptions,
|
|
149
|
-
expires: /* @__PURE__ */ new Date(0),
|
|
150
|
-
maxAge: 0,
|
|
151
|
-
secure: true
|
|
152
|
-
};
|
|
153
|
-
var getCookie = (request, cookieName) => {
|
|
154
|
-
const cookies = request instanceof Request ? request.headers.get("Cookie") : request.get("Cookie");
|
|
155
|
-
if (!cookies) {
|
|
156
|
-
throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
|
|
157
|
-
}
|
|
158
|
-
const value = (0, import_cookie.parse)(cookies)[cookieName];
|
|
159
|
-
if (!value) {
|
|
160
|
-
throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found. There is no active session`);
|
|
161
|
-
}
|
|
162
|
-
return value;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// src/actions/csrfToken/csrfToken.ts
|
|
166
|
-
var getCSRFToken = (request, cookieName) => {
|
|
167
|
-
try {
|
|
168
|
-
return getCookie(request, cookieName);
|
|
169
|
-
} catch {
|
|
170
|
-
return void 0;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var csrfTokenAction = (0, import_router2.createEndpoint)("GET", "/csrfToken", async (ctx) => {
|
|
174
|
-
const {
|
|
175
|
-
request,
|
|
176
|
-
context: { jose, cookies, logger }
|
|
177
|
-
} = ctx;
|
|
178
|
-
const token = getCSRFToken(request, cookies.csrfToken.name);
|
|
179
|
-
logger?.log("CSRF_TOKEN_REQUESTED", { structuredData: { has_token: Boolean(token) } });
|
|
180
|
-
const csrfToken = await createCSRF(jose, token);
|
|
181
|
-
logger?.log("CSRF_TOKEN_ISSUED", { structuredData: { issued: Boolean(csrfToken) } });
|
|
182
|
-
const headers = new Headers(secureApiHeaders);
|
|
183
|
-
headers.append("Set-Cookie", setCookie(cookies.csrfToken.name, csrfToken, cookies.csrfToken.attributes));
|
|
184
|
-
return Response.json({ csrfToken }, { headers });
|
|
185
|
-
});
|
|
186
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
-
0 && (module.exports = {
|
|
188
|
-
csrfTokenAction
|
|
189
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
csrfTokenAction
|
|
3
|
-
} from "../../chunk-FPCVZUVG.js";
|
|
4
|
-
import "../../chunk-V6LLEAR4.js";
|
|
5
|
-
import "../../chunk-UZQJJD6A.js";
|
|
6
|
-
import "../../chunk-LX3TJ2TJ.js";
|
|
7
|
-
import "../../chunk-XY5R3EHH.js";
|
|
8
|
-
import "../../chunk-WHNDRO3N.js";
|
|
9
|
-
import "../../chunk-U5663F2U.js";
|
|
10
|
-
import "../../chunk-EBAMFRB7.js";
|
|
11
|
-
export {
|
|
12
|
-
csrfTokenAction
|
|
13
|
-
};
|