@aura-stack/auth 0.1.0 → 0.2.0-rc.1
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 +5 -5
- package/dist/@types/router.d.d.ts +5 -5
- package/dist/@types/utility.d.ts +1 -5
- package/dist/actions/callback/access-token.cjs +95 -74
- package/dist/actions/callback/access-token.d.ts +7 -7
- package/dist/actions/callback/access-token.js +5 -3
- package/dist/actions/callback/callback.cjs +171 -249
- package/dist/actions/callback/callback.d.ts +6 -6
- package/dist/actions/callback/callback.js +10 -10
- package/dist/actions/callback/userinfo.cjs +81 -57
- package/dist/actions/callback/userinfo.d.ts +5 -5
- package/dist/actions/callback/userinfo.js +7 -5
- package/dist/actions/csrfToken/csrfToken.cjs +36 -105
- package/dist/actions/csrfToken/csrfToken.js +6 -6
- package/dist/actions/index.cjs +309 -444
- package/dist/actions/index.d.ts +5 -5
- package/dist/actions/index.js +19 -19
- package/dist/actions/session/session.cjs +25 -109
- package/dist/actions/session/session.js +4 -5
- package/dist/actions/signIn/authorization.cjs +96 -87
- package/dist/actions/signIn/authorization.d.ts +5 -5
- package/dist/actions/signIn/authorization.js +5 -5
- package/dist/actions/signIn/signIn.cjs +133 -242
- package/dist/actions/signIn/signIn.d.ts +6 -6
- package/dist/actions/signIn/signIn.js +8 -9
- package/dist/actions/signOut/signOut.cjs +136 -282
- package/dist/actions/signOut/signOut.js +8 -9
- package/dist/assert.cjs +5 -0
- package/dist/assert.d.ts +10 -1
- package/dist/assert.js +3 -1
- package/dist/chunk-3EUWD5BB.js +63 -0
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-A3N4PVAT.js +70 -0
- package/dist/chunk-B737EUJV.js +22 -0
- package/dist/{chunk-256KIVJL.js → chunk-CXLATHS5.js} +53 -9
- package/dist/{chunk-6SM22VVJ.js → chunk-EIL2FPSS.js} +5 -1
- package/dist/{chunk-VFTYH33W.js → chunk-EMKJA2GJ.js} +36 -8
- package/dist/{chunk-UJJ7R56J.js → chunk-GA2SMTJO.js} +16 -10
- package/dist/chunk-HP34YGGJ.js +22 -0
- package/dist/chunk-HT4YLL7N.js +35 -0
- package/dist/{chunk-EBPE35JT.js → chunk-IUYZQTJV.js} +0 -1
- package/dist/{chunk-RLT4RFKV.js → chunk-IVET23KF.js} +21 -8
- package/dist/{chunk-XXJKNKGQ.js → chunk-JVFTCTTE.js} +9 -13
- package/dist/chunk-KSWLO5ZU.js +102 -0
- package/dist/{chunk-GZU3RBTB.js → chunk-N2APGLXA.js} +19 -10
- package/dist/{chunk-CAKJT3KS.js → chunk-N4SX7TZT.js} +21 -17
- package/dist/chunk-RRLIF4PQ.js +55 -0
- package/dist/chunk-TLE4PXY3.js +39 -0
- package/dist/chunk-W6LG7BFW.js +197 -0
- package/dist/{chunk-HMRKN75I.js → chunk-YRCB5FLE.js} +14 -9
- package/dist/chunk-ZNCZVF6U.js +14 -0
- package/dist/cookie.cjs +140 -99
- package/dist/cookie.d.ts +35 -44
- package/dist/cookie.js +10 -17
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +49 -0
- package/dist/errors.js +18 -0
- package/dist/{index-DpfbvTZ_.d.ts → index-DkaLJFn8.d.ts} +192 -61
- package/dist/index.cjs +543 -443
- package/dist/index.d.ts +6 -6
- package/dist/index.js +42 -28
- package/dist/jose.cjs +25 -14
- package/dist/jose.d.ts +4 -1
- package/dist/jose.js +5 -4
- package/dist/oauth/bitbucket.d.ts +5 -5
- package/dist/oauth/discord.cjs +0 -1
- package/dist/oauth/discord.d.ts +5 -5
- package/dist/oauth/discord.js +1 -1
- package/dist/oauth/figma.d.ts +5 -5
- package/dist/oauth/github.d.ts +5 -5
- package/dist/oauth/gitlab.d.ts +5 -5
- package/dist/oauth/index.cjs +176 -6
- package/dist/oauth/index.d.ts +5 -5
- package/dist/oauth/index.js +19 -4
- package/dist/oauth/mailchimp.cjs +46 -0
- package/dist/oauth/mailchimp.d.ts +7 -0
- package/dist/oauth/mailchimp.js +6 -0
- package/dist/oauth/pinterest.cjs +46 -0
- package/dist/oauth/pinterest.d.ts +7 -0
- package/dist/oauth/pinterest.js +6 -0
- package/dist/oauth/spotify.d.ts +5 -5
- package/dist/oauth/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +7 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.d.ts +5 -5
- package/dist/{response.cjs → request.cjs} +14 -10
- package/dist/request.d.ts +13 -0
- package/dist/request.js +6 -0
- package/dist/schemas.cjs +43 -37
- package/dist/schemas.d.ts +67 -64
- package/dist/schemas.js +3 -1
- package/dist/secure.cjs +32 -24
- package/dist/secure.d.ts +5 -5
- package/dist/secure.js +4 -3
- package/dist/utils.cjs +90 -15
- package/dist/utils.d.ts +11 -2
- package/dist/utils.js +8 -4
- package/package.json +8 -7
- package/dist/chunk-FJUDBLCP.js +0 -59
- package/dist/chunk-HGJ4TXY4.js +0 -137
- package/dist/chunk-JAPMIE6S.js +0 -10
- package/dist/chunk-LLR722CL.js +0 -96
- package/dist/chunk-SJPDVKUS.js +0 -112
- package/dist/chunk-SMQO5WD7.js +0 -30
- package/dist/chunk-UTDLUEEG.js +0 -31
- package/dist/chunk-ZV4BH47P.js +0 -154
- package/dist/error.cjs +0 -88
- package/dist/error.d.ts +0 -62
- package/dist/error.js +0 -16
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -6
|
@@ -0,0 +1,46 @@
|
|
|
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/oauth/pinterest.ts
|
|
21
|
+
var pinterest_exports = {};
|
|
22
|
+
__export(pinterest_exports, {
|
|
23
|
+
pinterest: () => pinterest
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(pinterest_exports);
|
|
26
|
+
var pinterest = {
|
|
27
|
+
id: "pinterest",
|
|
28
|
+
name: "Pinterest",
|
|
29
|
+
authorizeURL: "https://api.pinterest.com/oauth/",
|
|
30
|
+
accessToken: "https://api.pinterest.com/v5/oauth/token",
|
|
31
|
+
userInfo: "https://api.pinterest.com/v5/user_account",
|
|
32
|
+
scope: "user_accounts:read",
|
|
33
|
+
responseType: "code",
|
|
34
|
+
profile(profile) {
|
|
35
|
+
return {
|
|
36
|
+
sub: profile.id,
|
|
37
|
+
name: profile.username,
|
|
38
|
+
email: null,
|
|
39
|
+
image: profile.profile_image
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
pinterest
|
|
46
|
+
});
|
package/dist/oauth/spotify.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
export { I as Image, o as SpotifyProfile, q as spotify } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import '../schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import '../@types/utility.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
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/oauth/strava.ts
|
|
21
|
+
var strava_exports = {};
|
|
22
|
+
__export(strava_exports, {
|
|
23
|
+
strava: () => strava
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(strava_exports);
|
|
26
|
+
var strava = {
|
|
27
|
+
id: "strava",
|
|
28
|
+
name: "Strava",
|
|
29
|
+
authorizeURL: "https://www.strava.com/oauth/authorize",
|
|
30
|
+
accessToken: "https://www.strava.com/oauth/token",
|
|
31
|
+
userInfo: "https://www.strava.com/api/v3/athlete",
|
|
32
|
+
scope: "read",
|
|
33
|
+
responseType: "code",
|
|
34
|
+
profile(profile) {
|
|
35
|
+
return {
|
|
36
|
+
sub: profile.id.toString(),
|
|
37
|
+
name: `${profile.firstname} ${profile.lastname}`,
|
|
38
|
+
image: profile.profile,
|
|
39
|
+
email: ""
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
strava
|
|
46
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { n as StravaProfile, k as SummaryClub, l as SummaryGear, s as strava } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '../schemas.js';
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
|
+
import '../@types/utility.js';
|
package/dist/oauth/x.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { X as XProfile, x } from '../index-
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
export { X as XProfile, x } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import '../schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import '../@types/utility.js';
|
|
@@ -17,18 +17,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
20
|
+
// src/request.ts
|
|
21
|
+
var request_exports = {};
|
|
22
|
+
__export(request_exports, {
|
|
23
|
+
fetchAsync: () => fetchAsync
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
module.exports = __toCommonJS(request_exports);
|
|
26
|
+
var fetchAsync = async (url, options = {}, timeout = 5e3) => {
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
29
|
+
const response = await fetch(url, {
|
|
30
|
+
...options,
|
|
31
|
+
signal: controller.signal
|
|
32
|
+
}).finally(() => clearTimeout(timeoutId));
|
|
33
|
+
return response;
|
|
30
34
|
};
|
|
31
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
36
|
0 && (module.exports = {
|
|
33
|
-
|
|
37
|
+
fetchAsync
|
|
34
38
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches a resource with a timeout mechanism.
|
|
3
|
+
*
|
|
4
|
+
* @param url - The URL or Request object to fetch
|
|
5
|
+
* @param options - Optional RequestInit configuration object
|
|
6
|
+
* @param timeout - Timeout duration in milliseconds (default: 5000ms)
|
|
7
|
+
* @returns A promise that resolves to the Response object
|
|
8
|
+
* @example
|
|
9
|
+
* const response = await fetchAsync('https://api.example.com/data', {}, 3000);
|
|
10
|
+
*/
|
|
11
|
+
declare const fetchAsync: (url: string | Request, options?: RequestInit, timeout?: number) => Promise<Response>;
|
|
12
|
+
|
|
13
|
+
export { fetchAsync };
|
package/dist/request.js
ADDED
package/dist/schemas.cjs
CHANGED
|
@@ -26,32 +26,33 @@ __export(schemas_exports, {
|
|
|
26
26
|
OAuthAuthorization: () => OAuthAuthorization,
|
|
27
27
|
OAuthAuthorizationErrorResponse: () => OAuthAuthorizationErrorResponse,
|
|
28
28
|
OAuthAuthorizationResponse: () => OAuthAuthorizationResponse,
|
|
29
|
+
OAuthEnvSchema: () => OAuthEnvSchema,
|
|
29
30
|
OAuthErrorResponse: () => OAuthErrorResponse,
|
|
30
31
|
OAuthProviderConfigSchema: () => OAuthProviderConfigSchema
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(schemas_exports);
|
|
33
|
-
var
|
|
34
|
-
var OAuthProviderConfigSchema = (0,
|
|
35
|
-
authorizeURL: (0,
|
|
36
|
-
accessToken: (0,
|
|
37
|
-
scope: (0,
|
|
38
|
-
userInfo: (0,
|
|
39
|
-
responseType: (0,
|
|
40
|
-
clientId: (0,
|
|
41
|
-
clientSecret: (0,
|
|
34
|
+
var import_zod = require("zod");
|
|
35
|
+
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
36
|
+
authorizeURL: (0, import_zod.string)().url(),
|
|
37
|
+
accessToken: (0, import_zod.string)().url(),
|
|
38
|
+
scope: (0, import_zod.string)().optional(),
|
|
39
|
+
userInfo: (0, import_zod.string)().url(),
|
|
40
|
+
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
41
|
+
clientId: (0, import_zod.string)(),
|
|
42
|
+
clientSecret: (0, import_zod.string)()
|
|
42
43
|
});
|
|
43
44
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
44
|
-
redirectURI: (0,
|
|
45
|
-
state: (0,
|
|
46
|
-
codeChallenge: (0,
|
|
47
|
-
codeChallengeMethod: (0,
|
|
45
|
+
redirectURI: (0, import_zod.string)(),
|
|
46
|
+
state: (0, import_zod.string)(),
|
|
47
|
+
codeChallenge: (0, import_zod.string)(),
|
|
48
|
+
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
48
49
|
});
|
|
49
|
-
var OAuthAuthorizationResponse = (0,
|
|
50
|
-
state: (0,
|
|
51
|
-
code: (0,
|
|
50
|
+
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
51
|
+
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
52
|
+
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
52
53
|
});
|
|
53
|
-
var OAuthAuthorizationErrorResponse = (0,
|
|
54
|
-
error: (0,
|
|
54
|
+
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
55
|
+
error: (0, import_zod.enum)([
|
|
55
56
|
"invalid_request",
|
|
56
57
|
"unauthorized_client",
|
|
57
58
|
"access_denied",
|
|
@@ -60,24 +61,24 @@ var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
|
60
61
|
"server_error",
|
|
61
62
|
"temporarily_unavailable"
|
|
62
63
|
]),
|
|
63
|
-
error_description: (0,
|
|
64
|
-
error_uri: (0,
|
|
65
|
-
state: (0,
|
|
64
|
+
error_description: (0, import_zod.string)().optional(),
|
|
65
|
+
error_uri: (0, import_zod.string)().optional(),
|
|
66
|
+
state: (0, import_zod.string)()
|
|
66
67
|
});
|
|
67
68
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
68
|
-
redirectURI: (0,
|
|
69
|
-
code: (0,
|
|
70
|
-
codeVerifier: (0,
|
|
69
|
+
redirectURI: (0, import_zod.string)(),
|
|
70
|
+
code: (0, import_zod.string)(),
|
|
71
|
+
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
71
72
|
});
|
|
72
|
-
var OAuthAccessTokenResponse = (0,
|
|
73
|
-
access_token: (0,
|
|
74
|
-
token_type: (0,
|
|
75
|
-
expires_in: (0,
|
|
76
|
-
refresh_token: (0,
|
|
77
|
-
scope: (0,
|
|
73
|
+
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
74
|
+
access_token: (0, import_zod.string)(),
|
|
75
|
+
token_type: (0, import_zod.string)().optional(),
|
|
76
|
+
expires_in: (0, import_zod.number)().optional(),
|
|
77
|
+
refresh_token: (0, import_zod.string)().optional(),
|
|
78
|
+
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
78
79
|
});
|
|
79
|
-
var OAuthAccessTokenErrorResponse = (0,
|
|
80
|
-
error: (0,
|
|
80
|
+
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
81
|
+
error: (0, import_zod.enum)([
|
|
81
82
|
"invalid_request",
|
|
82
83
|
"invalid_client",
|
|
83
84
|
"invalid_grant",
|
|
@@ -85,12 +86,16 @@ var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
|
85
86
|
"unsupported_grant_type",
|
|
86
87
|
"invalid_scope"
|
|
87
88
|
]),
|
|
88
|
-
error_description: (0,
|
|
89
|
-
error_uri: (0,
|
|
89
|
+
error_description: (0, import_zod.string)().optional(),
|
|
90
|
+
error_uri: (0, import_zod.string)().optional()
|
|
90
91
|
});
|
|
91
|
-
var OAuthErrorResponse = (0,
|
|
92
|
-
error: (0,
|
|
93
|
-
error_description: (0,
|
|
92
|
+
var OAuthErrorResponse = (0, import_zod.object)({
|
|
93
|
+
error: (0, import_zod.string)(),
|
|
94
|
+
error_description: (0, import_zod.string)().optional()
|
|
95
|
+
});
|
|
96
|
+
var OAuthEnvSchema = (0, import_zod.object)({
|
|
97
|
+
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
98
|
+
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
94
99
|
});
|
|
95
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
101
|
0 && (module.exports = {
|
|
@@ -100,6 +105,7 @@ var OAuthErrorResponse = (0, import_v4.object)({
|
|
|
100
105
|
OAuthAuthorization,
|
|
101
106
|
OAuthAuthorizationErrorResponse,
|
|
102
107
|
OAuthAuthorizationResponse,
|
|
108
|
+
OAuthEnvSchema,
|
|
103
109
|
OAuthErrorResponse,
|
|
104
110
|
OAuthProviderConfigSchema
|
|
105
111
|
});
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,63 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as zod_v4 from 'zod/v4';
|
|
1
|
+
import { z } from 'zod';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Schema for OAuth Provider Configuration
|
|
6
5
|
*/
|
|
7
|
-
declare const OAuthProviderConfigSchema:
|
|
8
|
-
authorizeURL:
|
|
9
|
-
accessToken:
|
|
10
|
-
scope:
|
|
11
|
-
userInfo:
|
|
12
|
-
responseType:
|
|
6
|
+
declare const OAuthProviderConfigSchema: z.ZodObject<{
|
|
7
|
+
authorizeURL: z.ZodString;
|
|
8
|
+
accessToken: z.ZodString;
|
|
9
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
10
|
+
userInfo: z.ZodString;
|
|
11
|
+
responseType: z.ZodEnum<{
|
|
13
12
|
token: "token";
|
|
14
13
|
code: "code";
|
|
15
14
|
id_token: "id_token";
|
|
16
15
|
}>;
|
|
17
|
-
clientId:
|
|
18
|
-
clientSecret:
|
|
19
|
-
},
|
|
16
|
+
clientId: z.ZodString;
|
|
17
|
+
clientSecret: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
20
19
|
/**
|
|
21
20
|
* Schema used to create the authorization URL for the OAuth flow and verify the
|
|
22
21
|
* OAuth configuration.
|
|
23
22
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.1
|
|
24
23
|
*/
|
|
25
|
-
declare const OAuthAuthorization:
|
|
26
|
-
authorizeURL:
|
|
27
|
-
accessToken:
|
|
28
|
-
scope:
|
|
29
|
-
userInfo:
|
|
30
|
-
responseType:
|
|
24
|
+
declare const OAuthAuthorization: z.ZodObject<{
|
|
25
|
+
authorizeURL: z.ZodString;
|
|
26
|
+
accessToken: z.ZodString;
|
|
27
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
28
|
+
userInfo: z.ZodString;
|
|
29
|
+
responseType: z.ZodEnum<{
|
|
31
30
|
token: "token";
|
|
32
31
|
code: "code";
|
|
33
32
|
id_token: "id_token";
|
|
34
33
|
}>;
|
|
35
|
-
clientId:
|
|
36
|
-
clientSecret:
|
|
37
|
-
redirectURI:
|
|
38
|
-
state:
|
|
39
|
-
codeChallenge:
|
|
40
|
-
codeChallengeMethod:
|
|
41
|
-
S256: "S256";
|
|
34
|
+
clientId: z.ZodString;
|
|
35
|
+
clientSecret: z.ZodString;
|
|
36
|
+
redirectURI: z.ZodString;
|
|
37
|
+
state: z.ZodString;
|
|
38
|
+
codeChallenge: z.ZodString;
|
|
39
|
+
codeChallengeMethod: z.ZodEnum<{
|
|
42
40
|
plain: "plain";
|
|
41
|
+
S256: "S256";
|
|
43
42
|
}>;
|
|
44
|
-
},
|
|
43
|
+
}, z.core.$strip>;
|
|
45
44
|
/**
|
|
46
45
|
* Schema used in the callback action to validate the authorization response when the resource owner
|
|
47
46
|
* has granted.
|
|
48
47
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2
|
|
49
48
|
*/
|
|
50
|
-
declare const OAuthAuthorizationResponse:
|
|
51
|
-
state:
|
|
52
|
-
code:
|
|
53
|
-
},
|
|
49
|
+
declare const OAuthAuthorizationResponse: z.ZodObject<{
|
|
50
|
+
state: z.ZodString;
|
|
51
|
+
code: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
54
53
|
/**
|
|
55
54
|
* Schema used in the callback action to validate the authorization error response when the resource owner
|
|
56
55
|
* has denied the authorization request.
|
|
57
56
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1
|
|
58
57
|
*/
|
|
59
|
-
declare const OAuthAuthorizationErrorResponse:
|
|
60
|
-
error:
|
|
58
|
+
declare const OAuthAuthorizationErrorResponse: z.ZodObject<{
|
|
59
|
+
error: z.ZodEnum<{
|
|
61
60
|
invalid_request: "invalid_request";
|
|
62
61
|
unauthorized_client: "unauthorized_client";
|
|
63
62
|
access_denied: "access_denied";
|
|
@@ -66,48 +65,48 @@ declare const OAuthAuthorizationErrorResponse: zod_v4.ZodObject<{
|
|
|
66
65
|
server_error: "server_error";
|
|
67
66
|
temporarily_unavailable: "temporarily_unavailable";
|
|
68
67
|
}>;
|
|
69
|
-
error_description:
|
|
70
|
-
error_uri:
|
|
71
|
-
state:
|
|
72
|
-
},
|
|
68
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
69
|
+
error_uri: z.ZodOptional<z.ZodString>;
|
|
70
|
+
state: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
73
72
|
/**
|
|
74
73
|
* Schema for OAuth Access Token Request and OAuth Configuration
|
|
75
74
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
|
|
76
75
|
*/
|
|
77
|
-
declare const OAuthAccessToken:
|
|
78
|
-
authorizeURL:
|
|
79
|
-
accessToken:
|
|
80
|
-
scope:
|
|
81
|
-
userInfo:
|
|
82
|
-
responseType:
|
|
76
|
+
declare const OAuthAccessToken: z.ZodObject<{
|
|
77
|
+
authorizeURL: z.ZodString;
|
|
78
|
+
accessToken: z.ZodString;
|
|
79
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
80
|
+
userInfo: z.ZodString;
|
|
81
|
+
responseType: z.ZodEnum<{
|
|
83
82
|
token: "token";
|
|
84
83
|
code: "code";
|
|
85
84
|
id_token: "id_token";
|
|
86
85
|
}>;
|
|
87
|
-
clientId:
|
|
88
|
-
clientSecret:
|
|
89
|
-
redirectURI:
|
|
90
|
-
code:
|
|
91
|
-
codeVerifier:
|
|
92
|
-
},
|
|
86
|
+
clientId: z.ZodString;
|
|
87
|
+
clientSecret: z.ZodString;
|
|
88
|
+
redirectURI: z.ZodString;
|
|
89
|
+
code: z.ZodString;
|
|
90
|
+
codeVerifier: z.ZodString;
|
|
91
|
+
}, z.core.$strip>;
|
|
93
92
|
/**
|
|
94
93
|
* Schema for OAuth Access Token Response
|
|
95
94
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
|
|
96
95
|
* @see https://datatracker.ietf.org/doc/html/rfc7636#section-4
|
|
97
96
|
*/
|
|
98
|
-
declare const OAuthAccessTokenResponse:
|
|
99
|
-
access_token:
|
|
100
|
-
token_type:
|
|
101
|
-
expires_in:
|
|
102
|
-
refresh_token:
|
|
103
|
-
scope:
|
|
104
|
-
},
|
|
97
|
+
declare const OAuthAccessTokenResponse: z.ZodObject<{
|
|
98
|
+
access_token: z.ZodString;
|
|
99
|
+
token_type: z.ZodOptional<z.ZodString>;
|
|
100
|
+
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
102
|
+
scope: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodNull]>;
|
|
103
|
+
}, z.core.$strip>;
|
|
105
104
|
/**
|
|
106
105
|
* Schema for OAuth Access Token Error Response
|
|
107
106
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
108
107
|
*/
|
|
109
|
-
declare const OAuthAccessTokenErrorResponse:
|
|
110
|
-
error:
|
|
108
|
+
declare const OAuthAccessTokenErrorResponse: z.ZodObject<{
|
|
109
|
+
error: z.ZodEnum<{
|
|
111
110
|
invalid_request: "invalid_request";
|
|
112
111
|
unauthorized_client: "unauthorized_client";
|
|
113
112
|
invalid_scope: "invalid_scope";
|
|
@@ -115,16 +114,20 @@ declare const OAuthAccessTokenErrorResponse: zod_v4.ZodObject<{
|
|
|
115
114
|
invalid_grant: "invalid_grant";
|
|
116
115
|
unsupported_grant_type: "unsupported_grant_type";
|
|
117
116
|
}>;
|
|
118
|
-
error_description:
|
|
119
|
-
error_uri:
|
|
120
|
-
},
|
|
117
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
118
|
+
error_uri: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>;
|
|
121
120
|
/**
|
|
122
121
|
* @todo: verify if this schema is still needed
|
|
123
122
|
* @deprecated
|
|
124
123
|
*/
|
|
125
|
-
declare const OAuthErrorResponse:
|
|
126
|
-
error:
|
|
127
|
-
error_description:
|
|
128
|
-
},
|
|
124
|
+
declare const OAuthErrorResponse: z.ZodObject<{
|
|
125
|
+
error: z.ZodString;
|
|
126
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
declare const OAuthEnvSchema: z.ZodObject<{
|
|
129
|
+
clientId: z.ZodString;
|
|
130
|
+
clientSecret: z.ZodString;
|
|
131
|
+
}, z.core.$strip>;
|
|
129
132
|
|
|
130
|
-
export { OAuthAccessToken, OAuthAccessTokenErrorResponse, OAuthAccessTokenResponse, OAuthAuthorization, OAuthAuthorizationErrorResponse, OAuthAuthorizationResponse, OAuthErrorResponse, OAuthProviderConfigSchema };
|
|
133
|
+
export { OAuthAccessToken, OAuthAccessTokenErrorResponse, OAuthAccessTokenResponse, OAuthAuthorization, OAuthAuthorizationErrorResponse, OAuthAuthorizationResponse, OAuthEnvSchema, OAuthErrorResponse, OAuthProviderConfigSchema };
|
package/dist/schemas.js
CHANGED
|
@@ -5,9 +5,10 @@ import {
|
|
|
5
5
|
OAuthAuthorization,
|
|
6
6
|
OAuthAuthorizationErrorResponse,
|
|
7
7
|
OAuthAuthorizationResponse,
|
|
8
|
+
OAuthEnvSchema,
|
|
8
9
|
OAuthErrorResponse,
|
|
9
10
|
OAuthProviderConfigSchema
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YRCB5FLE.js";
|
|
11
12
|
export {
|
|
12
13
|
OAuthAccessToken,
|
|
13
14
|
OAuthAccessTokenErrorResponse,
|
|
@@ -15,6 +16,7 @@ export {
|
|
|
15
16
|
OAuthAuthorization,
|
|
16
17
|
OAuthAuthorizationErrorResponse,
|
|
17
18
|
OAuthAuthorizationResponse,
|
|
19
|
+
OAuthEnvSchema,
|
|
18
20
|
OAuthErrorResponse,
|
|
19
21
|
OAuthProviderConfigSchema
|
|
20
22
|
};
|
package/dist/secure.cjs
CHANGED
|
@@ -38,23 +38,20 @@ __export(secure_exports, {
|
|
|
38
38
|
verifyCSRF: () => verifyCSRF
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(secure_exports);
|
|
41
|
-
var
|
|
41
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
42
42
|
|
|
43
43
|
// src/utils.ts
|
|
44
44
|
var import_router = require("@aura-stack/router");
|
|
45
45
|
|
|
46
|
-
// src/
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
constructor(message = "The provided CSRF token is invalid or has expired") {
|
|
56
|
-
super("invalid_csrf_token", message);
|
|
57
|
-
this.name = "InvalidCsrfTokenError";
|
|
46
|
+
// src/errors.ts
|
|
47
|
+
var AuthSecurityError = class extends Error {
|
|
48
|
+
type = "AUTH_SECURITY_ERROR";
|
|
49
|
+
code;
|
|
50
|
+
constructor(code, message, options) {
|
|
51
|
+
super(message, options);
|
|
52
|
+
this.code = code;
|
|
53
|
+
this.name = new.target.name;
|
|
54
|
+
Error.captureStackTrace(this, new.target);
|
|
58
55
|
}
|
|
59
56
|
};
|
|
60
57
|
|
|
@@ -64,12 +61,17 @@ var equals = (a, b) => {
|
|
|
64
61
|
return a === b;
|
|
65
62
|
};
|
|
66
63
|
|
|
64
|
+
// src/assert.ts
|
|
65
|
+
var isJWTPayloadWithToken = (payload) => {
|
|
66
|
+
return typeof payload === "object" && payload !== null && "token" in payload && typeof payload?.token === "string";
|
|
67
|
+
};
|
|
68
|
+
|
|
67
69
|
// src/secure.ts
|
|
68
70
|
var generateSecure = (length = 32) => {
|
|
69
|
-
return
|
|
71
|
+
return import_crypto.default.randomBytes(length).toString("base64url");
|
|
70
72
|
};
|
|
71
73
|
var createHash = (data, base = "hex") => {
|
|
72
|
-
return
|
|
74
|
+
return import_crypto.default.createHash("sha256").update(data).digest().toString(base);
|
|
73
75
|
};
|
|
74
76
|
var createPKCE = async (verifier) => {
|
|
75
77
|
const codeVerifier = verifier ?? generateSecure(86);
|
|
@@ -91,23 +93,29 @@ var createCSRF = async (jose, csrfCookie) => {
|
|
|
91
93
|
};
|
|
92
94
|
var verifyCSRF = async (jose, cookie, header) => {
|
|
93
95
|
try {
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const cookiePayload = await jose.verifyJWS(cookie);
|
|
97
|
+
const headerPayload = await jose.verifyJWS(header);
|
|
98
|
+
if (!isJWTPayloadWithToken(cookiePayload)) {
|
|
99
|
+
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "Cookie payload missing token field.");
|
|
100
|
+
}
|
|
101
|
+
if (!isJWTPayloadWithToken(headerPayload)) {
|
|
102
|
+
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "Header payload missing token field.");
|
|
103
|
+
}
|
|
104
|
+
const cookieBuffer = Buffer.from(cookiePayload.token);
|
|
105
|
+
const headerBuffer = Buffer.from(headerPayload.token);
|
|
98
106
|
if (!equals(headerBuffer.length, cookieBuffer.length)) {
|
|
99
|
-
throw new
|
|
107
|
+
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
100
108
|
}
|
|
101
|
-
if (!
|
|
102
|
-
throw new
|
|
109
|
+
if (!import_crypto.default.timingSafeEqual(cookieBuffer, headerBuffer)) {
|
|
110
|
+
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
103
111
|
}
|
|
104
112
|
return true;
|
|
105
113
|
} catch {
|
|
106
|
-
throw new
|
|
114
|
+
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
107
115
|
}
|
|
108
116
|
};
|
|
109
117
|
var createDerivedSalt = (secret) => {
|
|
110
|
-
return
|
|
118
|
+
return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
|
|
111
119
|
};
|
|
112
120
|
// Annotate the CommonJS export names for ESM import in node:
|
|
113
121
|
0 && (module.exports = {
|
package/dist/secure.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as AuthRuntimeConfig } from './index-
|
|
2
|
-
import 'zod
|
|
3
|
-
import '@aura-stack/jose/jose';
|
|
1
|
+
import { A as AuthRuntimeConfig } from './index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
4
3
|
import './schemas.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
7
|
import './@types/utility.js';
|
|
8
8
|
|
|
9
9
|
declare const generateSecure: (length?: number) => string;
|