@aura-stack/auth 0.1.0-rc.9 → 0.1.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.cjs +15 -15
- package/dist/@types/index.d.ts +7 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +7 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +6 -6
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +143 -143
- package/dist/actions/callback/access-token.d.ts +15 -20
- package/dist/actions/callback/access-token.js +8 -4
- package/dist/actions/callback/callback.cjs +437 -455
- package/dist/actions/callback/callback.d.ts +10 -12
- package/dist/actions/callback/callback.js +16 -12
- package/dist/actions/callback/userinfo.cjs +131 -134
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +10 -6
- package/dist/actions/csrfToken/csrfToken.cjs +162 -171
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +12 -8
- package/dist/actions/index.cjs +746 -773
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +34 -18
- package/dist/actions/session/session.cjs +149 -155
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +11 -7
- package/dist/actions/signIn/authorization.cjs +231 -249
- package/dist/actions/signIn/authorization.d.ts +12 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +396 -423
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +14 -10
- package/dist/actions/signOut/signOut.cjs +417 -440
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +15 -11
- package/dist/assert.cjs +35 -36
- package/dist/assert.d.ts +4 -4
- package/dist/assert.js +10 -2
- package/dist/chunk-256KIVJL.js +85 -96
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-6SM22VVJ.js +13 -10
- package/dist/chunk-CAKJT3KS.js +84 -69
- package/dist/chunk-E3OXBRYF.js +19 -17
- package/dist/chunk-EBPE35JT.js +28 -26
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FJUDBLCP.js +50 -43
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-GZU3RBTB.js +51 -40
- package/dist/chunk-HGJ4TXY4.js +132 -100
- package/dist/chunk-HMRKN75I.js +63 -63
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-JAPMIE6S.js +7 -5
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-LLR722CL.js +91 -70
- package/dist/chunk-RLT4RFKV.js +39 -30
- package/dist/chunk-SJPDVKUS.js +107 -88
- package/dist/chunk-SMQO5WD7.js +26 -16
- package/dist/chunk-STHEPPUZ.js +8 -6
- package/dist/chunk-UJJ7R56J.js +47 -37
- package/dist/chunk-UTDLUEEG.js +27 -21
- package/dist/chunk-VFTYH33W.js +54 -37
- package/dist/chunk-XXJKNKGQ.js +33 -23
- package/dist/chunk-ZV4BH47P.js +132 -134
- package/dist/cookie.cjs +169 -175
- package/dist/cookie.d.ts +23 -51
- package/dist/cookie.js +34 -34
- package/dist/error.cjs +75 -75
- package/dist/error.d.ts +30 -30
- package/dist/error.js +15 -8
- package/dist/headers.cjs +28 -28
- package/dist/headers.d.ts +2 -2
- package/dist/headers.js +6 -2
- package/dist/index-DpfbvTZ_.d.ts +249 -298
- package/dist/index.cjs +936 -969
- package/dist/index.d.ts +10 -31
- package/dist/index.js +70 -50
- package/dist/jose.cjs +61 -64
- package/dist/jose.d.ts +8 -8
- package/dist/jose.js +9 -5
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +7 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +48 -48
- package/dist/oauth/discord.d.ts +7 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +7 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +7 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +7 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +180 -180
- package/dist/oauth/index.d.ts +7 -26
- package/dist/oauth/index.js +36 -9
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +7 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +6 -2
- package/dist/response.cjs +27 -27
- package/dist/response.d.ts +2 -2
- package/dist/response.js +6 -2
- package/dist/schemas.cjs +91 -91
- package/dist/schemas.d.ts +93 -126
- package/dist/schemas.js +18 -18
- package/dist/secure.cjs +95 -98
- package/dist/secure.d.ts +17 -17
- package/dist/secure.js +18 -4
- package/dist/utils.cjs +119 -132
- package/dist/utils.d.ts +11 -26
- package/dist/utils.js +21 -21
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as _aura_stack_router from
|
|
1
|
+
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
5
5
|
*/
|
|
6
|
-
declare const signOutAction: _aura_stack_router.RouteEndpoint<"POST", "/signOut", {}
|
|
6
|
+
declare const signOutAction: _aura_stack_router.RouteEndpoint<"POST", "/signOut", {}>;
|
|
7
7
|
|
|
8
|
-
export { signOutAction }
|
|
8
|
+
export { signOutAction };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
|
|
1
|
+
import {
|
|
2
|
+
signOutAction
|
|
3
|
+
} from "../../chunk-SJPDVKUS.js";
|
|
4
|
+
import "../../chunk-CAKJT3KS.js";
|
|
5
|
+
import "../../chunk-ZV4BH47P.js";
|
|
6
|
+
import "../../chunk-6SM22VVJ.js";
|
|
7
|
+
import "../../chunk-STHEPPUZ.js";
|
|
8
|
+
import "../../chunk-GZU3RBTB.js";
|
|
9
|
+
import "../../chunk-256KIVJL.js";
|
|
10
|
+
import "../../chunk-FJUDBLCP.js";
|
|
11
|
+
import "../../chunk-JAPMIE6S.js";
|
|
12
|
+
import "../../chunk-HMRKN75I.js";
|
|
13
|
+
export {
|
|
14
|
+
signOutAction
|
|
15
|
+
};
|
package/dist/assert.cjs
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
var __defProp = Object.defineProperty
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
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
6
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
}
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
9
10
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
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);
|
|
18
19
|
|
|
19
20
|
// src/assert.ts
|
|
20
|
-
var assert_exports = {}
|
|
21
|
+
var assert_exports = {};
|
|
21
22
|
__export(assert_exports, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
module.exports = __toCommonJS(assert_exports)
|
|
23
|
+
isFalsy: () => isFalsy,
|
|
24
|
+
isRequest: () => isRequest,
|
|
25
|
+
isValidURL: () => isValidURL
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(assert_exports);
|
|
27
28
|
var isFalsy = (value) => {
|
|
28
|
-
|
|
29
|
-
}
|
|
29
|
+
return value === false || value === 0 || value === "" || value === null || value === void 0 || Number.isNaN(value);
|
|
30
|
+
};
|
|
30
31
|
var isRequest = (value) => {
|
|
31
|
-
|
|
32
|
-
}
|
|
32
|
+
return typeof Request !== "undefined" && value instanceof Request;
|
|
33
|
+
};
|
|
33
34
|
var isValidURL = (value) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
|
|
36
|
+
const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()*+,;=:@-]*)*\/?$/;
|
|
37
|
+
return regex.test(value);
|
|
38
|
+
};
|
|
39
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 &&
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
isFalsy,
|
|
42
|
+
isRequest,
|
|
43
|
+
isValidURL
|
|
44
|
+
});
|
package/dist/assert.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const isFalsy: (value: unknown) => boolean
|
|
2
|
-
declare const isRequest: (value: unknown) => value is Request
|
|
3
|
-
declare const isValidURL: (value: string) => boolean
|
|
1
|
+
declare const isFalsy: (value: unknown) => boolean;
|
|
2
|
+
declare const isRequest: (value: unknown) => value is Request;
|
|
3
|
+
declare const isValidURL: (value: string) => boolean;
|
|
4
4
|
|
|
5
|
-
export { isFalsy, isRequest, isValidURL }
|
|
5
|
+
export { isFalsy, isRequest, isValidURL };
|
package/dist/assert.js
CHANGED
package/dist/chunk-256KIVJL.js
CHANGED
|
@@ -1,110 +1,99 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isAuthError
|
|
3
|
+
} from "./chunk-FJUDBLCP.js";
|
|
2
4
|
|
|
3
5
|
// src/utils.ts
|
|
4
|
-
import { isRouterError } from "@aura-stack/router"
|
|
6
|
+
import { isRouterError } from "@aura-stack/router";
|
|
5
7
|
var toSnakeCase = (str) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
|
|
9
|
-
.toLowerCase()
|
|
10
|
-
.replace(/^_+/, "")
|
|
11
|
-
}
|
|
8
|
+
return str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/^_+/, "");
|
|
9
|
+
};
|
|
12
10
|
var toUpperCase = (str) => {
|
|
13
|
-
|
|
14
|
-
}
|
|
11
|
+
return str.toUpperCase();
|
|
12
|
+
};
|
|
15
13
|
var toCastCase = (obj, type = "snake") => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
return Object.entries(obj).reduce((previous, [key, value]) => {
|
|
15
|
+
const newKey = type === "snake" ? toSnakeCase(key) : toUpperCase(key);
|
|
16
|
+
return { ...previous, [newKey]: value };
|
|
17
|
+
}, {});
|
|
18
|
+
};
|
|
21
19
|
var equals = (a, b) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
20
|
+
if (a === null || b === null || a === void 0 || b === void 0) return false;
|
|
21
|
+
return a === b;
|
|
22
|
+
};
|
|
25
23
|
var sanitizeURL = (url) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
path = path.replace(/\/+$/, "/")
|
|
47
|
-
} else if (path !== "/") {
|
|
48
|
-
path = path.replace(/\/+$/, "")
|
|
49
|
-
}
|
|
50
|
-
return protocol + domain + path
|
|
51
|
-
}
|
|
52
|
-
let sanitized = decodedURL
|
|
53
|
-
.replace(/\/\.\.\//g, "/")
|
|
54
|
-
.replace(/\/\.\.$/, "")
|
|
55
|
-
.replace(/\.{2,}/g, "")
|
|
56
|
-
.replace(/\/{2,}/g, "/")
|
|
57
|
-
if (sanitized !== "/" && sanitized.endsWith("/")) {
|
|
58
|
-
sanitized = sanitized.replace(/\/+$/, "/")
|
|
59
|
-
} else if (sanitized !== "/") {
|
|
60
|
-
sanitized = sanitized.replace(/\/+$/, "")
|
|
61
|
-
}
|
|
62
|
-
return sanitized
|
|
63
|
-
} catch {
|
|
64
|
-
return url.trim()
|
|
24
|
+
try {
|
|
25
|
+
let decodedURL = decodeURIComponent(url).trim();
|
|
26
|
+
const protocolMatch = decodedURL.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)/);
|
|
27
|
+
let protocol = "";
|
|
28
|
+
let rest = decodedURL;
|
|
29
|
+
if (protocolMatch) {
|
|
30
|
+
protocol = protocolMatch[1];
|
|
31
|
+
rest = decodedURL.slice(protocol.length);
|
|
32
|
+
const slashIndex = rest.indexOf("/");
|
|
33
|
+
if (slashIndex === -1) {
|
|
34
|
+
return protocol + rest;
|
|
35
|
+
}
|
|
36
|
+
const domain = rest.slice(0, slashIndex);
|
|
37
|
+
let path = rest.slice(slashIndex).replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
|
|
38
|
+
if (path !== "/" && path.endsWith("/")) {
|
|
39
|
+
path = path.replace(/\/+$/, "/");
|
|
40
|
+
} else if (path !== "/") {
|
|
41
|
+
path = path.replace(/\/+$/, "");
|
|
42
|
+
}
|
|
43
|
+
return protocol + domain + path;
|
|
65
44
|
}
|
|
66
|
-
}
|
|
45
|
+
let sanitized = decodedURL.replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
|
|
46
|
+
if (sanitized !== "/" && sanitized.endsWith("/")) {
|
|
47
|
+
sanitized = sanitized.replace(/\/+$/, "/");
|
|
48
|
+
} else if (sanitized !== "/") {
|
|
49
|
+
sanitized = sanitized.replace(/\/+$/, "");
|
|
50
|
+
}
|
|
51
|
+
return sanitized;
|
|
52
|
+
} catch {
|
|
53
|
+
return url.trim();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
67
56
|
var isValidRelativePath = (path) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
57
|
+
if (!path || typeof path !== "string") return false;
|
|
58
|
+
if (!path.startsWith("/") || path.includes("://") || path.includes("\r") || path.includes("\n")) return false;
|
|
59
|
+
if (/[\x00-\x1F\x7F]/.test(path) || path.includes("\0")) return false;
|
|
60
|
+
const sanitized = sanitizeURL(path);
|
|
61
|
+
if (sanitized.includes("..")) return false;
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
75
64
|
var onErrorHandler = (error) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
65
|
+
if (isRouterError(error)) {
|
|
66
|
+
const { message, status, statusText } = error;
|
|
67
|
+
return Response.json({ error: "invalid_request", error_description: message }, { status, statusText });
|
|
68
|
+
}
|
|
69
|
+
if (isAuthError(error)) {
|
|
70
|
+
const { type, message } = error;
|
|
71
|
+
return Response.json({ error: type, error_description: message }, { status: 400 });
|
|
72
|
+
}
|
|
73
|
+
return Response.json({ error: "server_error", error_description: "An unexpected error occurred" }, { status: 500 });
|
|
74
|
+
};
|
|
86
75
|
var getNormalizedOriginPath = (path) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
76
|
+
try {
|
|
77
|
+
const url = new URL(path);
|
|
78
|
+
url.hash = "";
|
|
79
|
+
url.search = "";
|
|
80
|
+
return `${url.origin}${url.pathname}`;
|
|
81
|
+
} catch {
|
|
82
|
+
return sanitizeURL(path);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
96
85
|
var toISOString = (date) => {
|
|
97
|
-
|
|
98
|
-
}
|
|
86
|
+
return new Date(date).toISOString();
|
|
87
|
+
};
|
|
99
88
|
|
|
100
89
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
90
|
+
toSnakeCase,
|
|
91
|
+
toUpperCase,
|
|
92
|
+
toCastCase,
|
|
93
|
+
equals,
|
|
94
|
+
sanitizeURL,
|
|
95
|
+
isValidRelativePath,
|
|
96
|
+
onErrorHandler,
|
|
97
|
+
getNormalizedOriginPath,
|
|
98
|
+
toISOString
|
|
99
|
+
};
|
package/dist/chunk-42XB3YCW.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
// src/oauth/x.ts
|
|
2
2
|
var x = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
3
|
+
id: "x",
|
|
4
|
+
name: "X",
|
|
5
|
+
authorizeURL: "https://x.com/i/oauth2/authorize",
|
|
6
|
+
accessToken: "https://api.x.com/2/oauth2/token",
|
|
7
|
+
userInfo: "https://api.x.com/2/users/me?user.fields=profile_image_url",
|
|
8
|
+
scope: "users.read users.email tweet.read offline.access",
|
|
9
|
+
responseType: "code",
|
|
10
|
+
profile({ data }) {
|
|
11
|
+
return {
|
|
12
|
+
sub: data.id,
|
|
13
|
+
name: data.name,
|
|
14
|
+
image: data.profile_image_url,
|
|
15
|
+
email: ""
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
x
|
|
22
|
+
};
|
package/dist/chunk-6SM22VVJ.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// src/assert.ts
|
|
2
2
|
var isFalsy = (value) => {
|
|
3
|
-
|
|
4
|
-
}
|
|
3
|
+
return value === false || value === 0 || value === "" || value === null || value === void 0 || Number.isNaN(value);
|
|
4
|
+
};
|
|
5
5
|
var isRequest = (value) => {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
return typeof Request !== "undefined" && value instanceof Request;
|
|
7
|
+
};
|
|
8
8
|
var isValidURL = (value) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
|
|
10
|
+
const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()*+,;=:@-]*)*\/?$/;
|
|
11
|
+
return regex.test(value);
|
|
12
|
+
};
|
|
14
13
|
|
|
15
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
isFalsy,
|
|
16
|
+
isRequest,
|
|
17
|
+
isValidURL
|
|
18
|
+
};
|
package/dist/chunk-CAKJT3KS.js
CHANGED
|
@@ -1,77 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isValidURL
|
|
3
|
+
} from "./chunk-6SM22VVJ.js";
|
|
4
|
+
import {
|
|
5
|
+
equals,
|
|
6
|
+
getNormalizedOriginPath,
|
|
7
|
+
sanitizeURL,
|
|
8
|
+
toCastCase
|
|
9
|
+
} from "./chunk-256KIVJL.js";
|
|
10
|
+
import {
|
|
11
|
+
AuthError,
|
|
12
|
+
ERROR_RESPONSE,
|
|
13
|
+
InvalidRedirectToError,
|
|
14
|
+
isAuthError
|
|
15
|
+
} from "./chunk-FJUDBLCP.js";
|
|
16
|
+
import {
|
|
17
|
+
OAuthAuthorization
|
|
18
|
+
} from "./chunk-HMRKN75I.js";
|
|
5
19
|
|
|
6
20
|
// src/actions/signIn/authorization.ts
|
|
7
21
|
var createAuthorizationURL = (oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
22
|
+
const parsed = OAuthAuthorization.safeParse({ ...oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod });
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
throw new AuthError(ERROR_RESPONSE.AUTHORIZATION.SERVER_ERROR, "Invalid OAuth configuration");
|
|
25
|
+
}
|
|
26
|
+
const { authorizeURL, ...options } = parsed.data;
|
|
27
|
+
const { userInfo, accessToken, clientSecret, ...required } = options;
|
|
28
|
+
const searchParams = new URLSearchParams(toCastCase(required));
|
|
29
|
+
return `${authorizeURL}?${searchParams}`;
|
|
30
|
+
};
|
|
17
31
|
var getOriginURL = (request, trustedProxyHeaders) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} else {
|
|
28
|
-
return new URL(getNormalizedOriginPath(request.url))
|
|
29
|
-
}
|
|
30
|
-
}
|
|
32
|
+
const headers = request.headers;
|
|
33
|
+
if (trustedProxyHeaders) {
|
|
34
|
+
const protocol = headers.get("X-Forwarded-Proto") ?? headers.get("Forwarded")?.match(/proto=([^;]+)/i)?.[1] ?? "http";
|
|
35
|
+
const host = headers.get("X-Forwarded-Host") ?? headers.get("Host") ?? headers.get("Forwarded")?.match(/host=([^;]+)/i)?.[1] ?? null;
|
|
36
|
+
return new URL(`${protocol}://${host}${getNormalizedOriginPath(new URL(request.url).pathname)}`);
|
|
37
|
+
} else {
|
|
38
|
+
return new URL(getNormalizedOriginPath(request.url));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
31
41
|
var createRedirectURI = (request, oauth, basePath, trustedProxyHeaders) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
42
|
+
const url = getOriginURL(request, trustedProxyHeaders);
|
|
43
|
+
return `${url.origin}${basePath}/callback/${oauth}`;
|
|
44
|
+
};
|
|
35
45
|
var createRedirectTo = (request, redirectTo, trustedProxyHeaders) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
throw new AuthError(ERROR_RESPONSE.AUTHORIZATION.INVALID_REQUEST, "Invalid origin (potential CSRF).")
|
|
46
|
+
try {
|
|
47
|
+
const headers = request.headers;
|
|
48
|
+
const origin = headers.get("Origin");
|
|
49
|
+
const referer = headers.get("Referer");
|
|
50
|
+
let hostedURL = getOriginURL(request, trustedProxyHeaders);
|
|
51
|
+
if (redirectTo) {
|
|
52
|
+
if (redirectTo.startsWith("/")) {
|
|
53
|
+
return sanitizeURL(redirectTo);
|
|
54
|
+
}
|
|
55
|
+
const redirectToURL = new URL(sanitizeURL(getNormalizedOriginPath(redirectTo)));
|
|
56
|
+
if (!isValidURL(redirectTo) || !equals(redirectToURL.origin, hostedURL.origin)) {
|
|
57
|
+
throw new InvalidRedirectToError();
|
|
58
|
+
}
|
|
59
|
+
return sanitizeURL(redirectToURL.pathname);
|
|
60
|
+
}
|
|
61
|
+
if (referer) {
|
|
62
|
+
const refererURL = new URL(sanitizeURL(referer));
|
|
63
|
+
if (!isValidURL(referer) || !equals(refererURL.origin, hostedURL.origin)) {
|
|
64
|
+
throw new AuthError(
|
|
65
|
+
ERROR_RESPONSE.AUTHORIZATION.INVALID_REQUEST,
|
|
66
|
+
"The referer of the request does not match the hosted origin."
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return sanitizeURL(refererURL.pathname);
|
|
70
|
+
}
|
|
71
|
+
if (origin) {
|
|
72
|
+
const originURL = new URL(sanitizeURL(getNormalizedOriginPath(origin)));
|
|
73
|
+
if (!isValidURL(origin) || !equals(originURL.origin, hostedURL.origin)) {
|
|
74
|
+
throw new AuthError(ERROR_RESPONSE.AUTHORIZATION.INVALID_REQUEST, "Invalid origin (potential CSRF).");
|
|
75
|
+
}
|
|
76
|
+
return sanitizeURL(originURL.pathname);
|
|
77
|
+
}
|
|
78
|
+
return "/";
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (isAuthError(error)) {
|
|
81
|
+
throw error;
|
|
74
82
|
}
|
|
75
|
-
|
|
83
|
+
throw new AuthError(ERROR_RESPONSE.AUTHORIZATION.INVALID_REQUEST, "Invalid origin (potential CSRF).");
|
|
84
|
+
}
|
|
85
|
+
};
|
|
76
86
|
|
|
77
|
-
export {
|
|
87
|
+
export {
|
|
88
|
+
createAuthorizationURL,
|
|
89
|
+
getOriginURL,
|
|
90
|
+
createRedirectURI,
|
|
91
|
+
createRedirectTo
|
|
92
|
+
};
|
package/dist/chunk-E3OXBRYF.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
// src/oauth/spotify.ts
|
|
2
2
|
var spotify = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
3
|
+
id: "spotify",
|
|
4
|
+
name: "Spotify",
|
|
5
|
+
authorizeURL: "https://accounts.spotify.com/authorize",
|
|
6
|
+
accessToken: "https://accounts.spotify.com/api/token",
|
|
7
|
+
userInfo: "https://api.spotify.com/v1/me",
|
|
8
|
+
scope: "user-read-email user-read-private",
|
|
9
|
+
responseType: "token",
|
|
10
|
+
profile(profile) {
|
|
11
|
+
return {
|
|
12
|
+
sub: profile.id,
|
|
13
|
+
name: profile.display_name,
|
|
14
|
+
email: profile.email,
|
|
15
|
+
image: profile.images?.[0]?.url
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
spotify
|
|
22
|
+
};
|