@aura-stack/auth 0.1.0-rc.9 → 0.2.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 +6 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +6 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +4 -8
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +159 -149
- package/dist/actions/callback/access-token.d.ts +14 -20
- package/dist/actions/callback/access-token.js +9 -4
- package/dist/actions/callback/callback.cjs +371 -484
- package/dist/actions/callback/callback.d.ts +9 -12
- package/dist/actions/callback/callback.js +15 -12
- package/dist/actions/callback/userinfo.cjs +149 -139
- package/dist/actions/callback/userinfo.d.ts +8 -9
- package/dist/actions/callback/userinfo.js +11 -6
- package/dist/actions/csrfToken/csrfToken.cjs +112 -190
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +12 -8
- package/dist/actions/index.cjs +623 -807
- package/dist/actions/index.d.ts +12 -13
- package/dist/actions/index.js +33 -18
- package/dist/actions/session/session.cjs +86 -176
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +10 -7
- package/dist/actions/signIn/authorization.cjs +248 -257
- package/dist/actions/signIn/authorization.d.ts +11 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +302 -451
- package/dist/actions/signIn/signIn.d.ts +9 -10
- package/dist/actions/signIn/signIn.js +12 -10
- package/dist/actions/signOut/signOut.cjs +299 -468
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +14 -11
- package/dist/assert.cjs +40 -36
- package/dist/assert.d.ts +12 -4
- package/dist/assert.js +12 -2
- package/dist/chunk-2RXNXMCZ.js +55 -0
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-4V4JNXVF.js +55 -0
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-7H3OR6UU.js +81 -0
- package/dist/chunk-CXLATHS5.js +143 -0
- package/dist/chunk-E3OXBRYF.js +19 -17
- package/dist/chunk-EIL2FPSS.js +22 -0
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-IMICRJ5U.js +197 -0
- package/dist/chunk-IUYZQTJV.js +30 -0
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-N2APGLXA.js +71 -0
- package/dist/chunk-NEVKX6K2.js +70 -0
- package/dist/chunk-PTJUYB33.js +33 -0
- package/dist/chunk-QDO2KSRJ.js +35 -0
- package/dist/chunk-QEZL7EYN.js +96 -0
- package/dist/chunk-RRLIF4PQ.js +55 -0
- package/dist/chunk-STHEPPUZ.js +8 -6
- package/dist/chunk-TLE4PXY3.js +39 -0
- package/dist/chunk-UEH3LVON.js +97 -0
- package/dist/chunk-WD7AUHQ5.js +79 -0
- package/dist/chunk-ZLR3LI6X.js +55 -0
- package/dist/cookie.cjs +222 -187
- package/dist/cookie.d.ts +38 -76
- package/dist/cookie.js +27 -34
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.js +18 -0
- 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 → index-EqsoyjrF.d.ts} +351 -318
- package/dist/index.cjs +1006 -1001
- package/dist/index.d.ts +9 -31
- package/dist/index.js +82 -51
- package/dist/jose.cjs +74 -66
- package/dist/jose.d.ts +11 -8
- package/dist/jose.js +10 -5
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +6 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +47 -48
- package/dist/oauth/discord.d.ts +6 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +6 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +6 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +6 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +306 -180
- package/dist/oauth/index.d.ts +6 -26
- package/dist/oauth/index.js +43 -9
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +6 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +6 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +6 -7
- package/dist/oauth/x.js +6 -2
- package/dist/schemas.cjs +97 -91
- package/dist/schemas.d.ts +96 -126
- package/dist/schemas.js +20 -18
- package/dist/secure.cjs +106 -101
- package/dist/secure.d.ts +16 -17
- package/dist/secure.js +19 -4
- package/dist/utils.cjs +197 -135
- package/dist/utils.d.ts +20 -26
- package/dist/utils.js +25 -21
- package/package.json +5 -6
- package/dist/chunk-256KIVJL.js +0 -110
- package/dist/chunk-6SM22VVJ.js +0 -15
- package/dist/chunk-CAKJT3KS.js +0 -77
- package/dist/chunk-EBPE35JT.js +0 -29
- package/dist/chunk-FJUDBLCP.js +0 -52
- package/dist/chunk-GZU3RBTB.js +0 -51
- package/dist/chunk-HGJ4TXY4.js +0 -105
- package/dist/chunk-HMRKN75I.js +0 -74
- package/dist/chunk-JAPMIE6S.js +0 -8
- package/dist/chunk-LLR722CL.js +0 -75
- package/dist/chunk-RLT4RFKV.js +0 -36
- package/dist/chunk-SJPDVKUS.js +0 -93
- package/dist/chunk-SMQO5WD7.js +0 -20
- package/dist/chunk-UJJ7R56J.js +0 -42
- package/dist/chunk-UTDLUEEG.js +0 -25
- package/dist/chunk-VFTYH33W.js +0 -44
- package/dist/chunk-XXJKNKGQ.js +0 -27
- package/dist/chunk-ZV4BH47P.js +0 -156
- package/dist/error.cjs +0 -88
- package/dist/error.d.ts +0 -62
- package/dist/error.js +0 -9
- package/dist/response.cjs +0 -34
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -2
|
@@ -1,292 +1,283 @@
|
|
|
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/actions/signIn/authorization.ts
|
|
20
|
-
var authorization_exports = {}
|
|
21
|
+
var authorization_exports = {};
|
|
21
22
|
__export(authorization_exports, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
module.exports = __toCommonJS(authorization_exports)
|
|
23
|
+
createAuthorizationURL: () => createAuthorizationURL,
|
|
24
|
+
createRedirectTo: () => createRedirectTo,
|
|
25
|
+
createRedirectURI: () => createRedirectURI,
|
|
26
|
+
getOriginURL: () => getOriginURL
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(authorization_exports);
|
|
28
29
|
|
|
29
30
|
// src/assert.ts
|
|
30
31
|
var isValidURL = (value) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
|
|
33
|
+
const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()*+,;=:@-]*)*\/?$/;
|
|
34
|
+
return regex.test(value);
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
// src/schemas.ts
|
|
38
|
-
var import_v4 = require("zod/v4")
|
|
38
|
+
var import_v4 = require("zod/v4");
|
|
39
39
|
var OAuthProviderConfigSchema = (0, import_v4.object)({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
40
|
+
authorizeURL: (0, import_v4.httpUrl)(),
|
|
41
|
+
accessToken: (0, import_v4.httpUrl)(),
|
|
42
|
+
scope: (0, import_v4.string)().optional(),
|
|
43
|
+
userInfo: (0, import_v4.httpUrl)(),
|
|
44
|
+
responseType: (0, import_v4.enum)(["code", "token", "id_token"]),
|
|
45
|
+
clientId: (0, import_v4.string)(),
|
|
46
|
+
clientSecret: (0, import_v4.string)()
|
|
47
|
+
});
|
|
48
48
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
49
|
+
redirectURI: (0, import_v4.string)(),
|
|
50
|
+
state: (0, import_v4.string)(),
|
|
51
|
+
codeChallenge: (0, import_v4.string)(),
|
|
52
|
+
codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
|
|
53
|
+
});
|
|
54
54
|
var OAuthAuthorizationResponse = (0, import_v4.object)({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
55
|
+
state: (0, import_v4.string)("Missing state parameter in the OAuth authorization response."),
|
|
56
|
+
code: (0, import_v4.string)("Missing code parameter in the OAuth authorization response.")
|
|
57
|
+
});
|
|
58
58
|
var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
})
|
|
59
|
+
error: (0, import_v4.enum)([
|
|
60
|
+
"invalid_request",
|
|
61
|
+
"unauthorized_client",
|
|
62
|
+
"access_denied",
|
|
63
|
+
"unsupported_response_type",
|
|
64
|
+
"invalid_scope",
|
|
65
|
+
"server_error",
|
|
66
|
+
"temporarily_unavailable"
|
|
67
|
+
]),
|
|
68
|
+
error_description: (0, import_v4.string)().optional(),
|
|
69
|
+
error_uri: (0, import_v4.string)().optional(),
|
|
70
|
+
state: (0, import_v4.string)()
|
|
71
|
+
});
|
|
72
72
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
73
|
+
redirectURI: (0, import_v4.string)(),
|
|
74
|
+
code: (0, import_v4.string)(),
|
|
75
|
+
codeVerifier: (0, import_v4.string)().min(43).max(128)
|
|
76
|
+
});
|
|
77
77
|
var OAuthAccessTokenResponse = (0, import_v4.object)({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
78
|
+
access_token: (0, import_v4.string)(),
|
|
79
|
+
token_type: (0, import_v4.string)(),
|
|
80
|
+
expires_in: (0, import_v4.number)().optional(),
|
|
81
|
+
refresh_token: (0, import_v4.string)().optional(),
|
|
82
|
+
scope: (0, import_v4.string)().optional()
|
|
83
|
+
});
|
|
84
84
|
var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})
|
|
85
|
+
error: (0, import_v4.enum)([
|
|
86
|
+
"invalid_request",
|
|
87
|
+
"invalid_client",
|
|
88
|
+
"invalid_grant",
|
|
89
|
+
"unauthorized_client",
|
|
90
|
+
"unsupported_grant_type",
|
|
91
|
+
"invalid_scope"
|
|
92
|
+
]),
|
|
93
|
+
error_description: (0, import_v4.string)().optional(),
|
|
94
|
+
error_uri: (0, import_v4.string)().optional()
|
|
95
|
+
});
|
|
96
96
|
var OAuthErrorResponse = (0, import_v4.object)({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
error: (0, import_v4.string)(),
|
|
98
|
+
error_description: (0, import_v4.string)().optional()
|
|
99
|
+
});
|
|
100
|
+
var OAuthEnvSchema = (0, import_v4.object)({
|
|
101
|
+
clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
102
|
+
clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
103
|
+
});
|
|
103
104
|
|
|
104
|
-
// src/
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
SERVER_ERROR: "server_error",
|
|
129
|
-
TEMPORARILY_UNAVAILABLE: "temporarily_unavailable",
|
|
130
|
-
},
|
|
131
|
-
ACCESS_TOKEN: {
|
|
132
|
-
INVALID_REQUEST: "invalid_request",
|
|
133
|
-
INVALID_CLIENT: "invalid_client",
|
|
134
|
-
INVALID_GRANT: "invalid_grant",
|
|
135
|
-
UNAUTHORIZED_CLIENT: "unauthorized_client",
|
|
136
|
-
UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type",
|
|
137
|
-
INVALID_SCOPE: "invalid_scope",
|
|
138
|
-
},
|
|
139
|
-
}
|
|
105
|
+
// src/errors.ts
|
|
106
|
+
var AuthInternalError = class extends Error {
|
|
107
|
+
type = "AUTH_INTERNAL_ERROR";
|
|
108
|
+
code;
|
|
109
|
+
constructor(code, message, options2) {
|
|
110
|
+
super(message, options2);
|
|
111
|
+
this.code = code;
|
|
112
|
+
this.name = new.target.name;
|
|
113
|
+
Error.captureStackTrace(this, new.target);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var AuthSecurityError = class extends Error {
|
|
117
|
+
type = "AUTH_SECURITY_ERROR";
|
|
118
|
+
code;
|
|
119
|
+
constructor(code, message, options2) {
|
|
120
|
+
super(message, options2);
|
|
121
|
+
this.code = code;
|
|
122
|
+
this.name = new.target.name;
|
|
123
|
+
Error.captureStackTrace(this, new.target);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var isAuthSecurityError = (error) => {
|
|
127
|
+
return error instanceof AuthSecurityError;
|
|
128
|
+
};
|
|
140
129
|
|
|
141
130
|
// src/utils.ts
|
|
131
|
+
var import_router = require("@aura-stack/router");
|
|
142
132
|
var toSnakeCase = (str) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
|
|
146
|
-
.toLowerCase()
|
|
147
|
-
.replace(/^_+/, "")
|
|
148
|
-
}
|
|
133
|
+
return str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/^_+/, "");
|
|
134
|
+
};
|
|
149
135
|
var toUpperCase = (str) => {
|
|
150
|
-
|
|
151
|
-
}
|
|
136
|
+
return str.toUpperCase();
|
|
137
|
+
};
|
|
152
138
|
var toCastCase = (obj, type = "snake") => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
139
|
+
return Object.entries(obj).reduce((previous, [key, value]) => {
|
|
140
|
+
const newKey = type === "snake" ? toSnakeCase(key) : toUpperCase(key);
|
|
141
|
+
return { ...previous, [newKey]: value };
|
|
142
|
+
}, {});
|
|
143
|
+
};
|
|
158
144
|
var equals = (a, b) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
var sanitizeURL = (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
path = path.replace(/\/+$/, "/")
|
|
184
|
-
} else if (path !== "/") {
|
|
185
|
-
path = path.replace(/\/+$/, "")
|
|
186
|
-
}
|
|
187
|
-
return protocol + domain + path
|
|
188
|
-
}
|
|
189
|
-
let sanitized = decodedURL
|
|
190
|
-
.replace(/\/\.\.\//g, "/")
|
|
191
|
-
.replace(/\/\.\.$/, "")
|
|
192
|
-
.replace(/\.{2,}/g, "")
|
|
193
|
-
.replace(/\/{2,}/g, "/")
|
|
194
|
-
if (sanitized !== "/" && sanitized.endsWith("/")) {
|
|
195
|
-
sanitized = sanitized.replace(/\/+$/, "/")
|
|
196
|
-
} else if (sanitized !== "/") {
|
|
197
|
-
sanitized = sanitized.replace(/\/+$/, "")
|
|
198
|
-
}
|
|
199
|
-
return sanitized
|
|
200
|
-
} catch {
|
|
201
|
-
return url2.trim()
|
|
145
|
+
if (a === null || b === null || a === void 0 || b === void 0) return false;
|
|
146
|
+
return a === b;
|
|
147
|
+
};
|
|
148
|
+
var sanitizeURL = (url) => {
|
|
149
|
+
try {
|
|
150
|
+
let decodedURL = decodeURIComponent(url).trim();
|
|
151
|
+
const protocolMatch = decodedURL.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)/);
|
|
152
|
+
let protocol = "";
|
|
153
|
+
let rest = decodedURL;
|
|
154
|
+
if (protocolMatch) {
|
|
155
|
+
protocol = protocolMatch[1];
|
|
156
|
+
rest = decodedURL.slice(protocol.length);
|
|
157
|
+
const slashIndex = rest.indexOf("/");
|
|
158
|
+
if (slashIndex === -1) {
|
|
159
|
+
return protocol + rest;
|
|
160
|
+
}
|
|
161
|
+
const domain = rest.slice(0, slashIndex);
|
|
162
|
+
let path = rest.slice(slashIndex).replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
|
|
163
|
+
if (path !== "/" && path.endsWith("/")) {
|
|
164
|
+
path = path.replace(/\/+$/, "/");
|
|
165
|
+
} else if (path !== "/") {
|
|
166
|
+
path = path.replace(/\/+$/, "");
|
|
167
|
+
}
|
|
168
|
+
return protocol + domain + path;
|
|
202
169
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
url2.search = ""
|
|
209
|
-
return `${url2.origin}${url2.pathname}`
|
|
210
|
-
} catch {
|
|
211
|
-
return sanitizeURL(path)
|
|
170
|
+
let sanitized = decodedURL.replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
|
|
171
|
+
if (sanitized !== "/" && sanitized.endsWith("/")) {
|
|
172
|
+
sanitized = sanitized.replace(/\/+$/, "/");
|
|
173
|
+
} else if (sanitized !== "/") {
|
|
174
|
+
sanitized = sanitized.replace(/\/+$/, "");
|
|
212
175
|
}
|
|
213
|
-
|
|
176
|
+
return sanitized;
|
|
177
|
+
} catch {
|
|
178
|
+
return url.trim();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var getNormalizedOriginPath = (path) => {
|
|
182
|
+
try {
|
|
183
|
+
const url = new URL(path);
|
|
184
|
+
url.hash = "";
|
|
185
|
+
url.search = "";
|
|
186
|
+
return `${url.origin}${url.pathname}`;
|
|
187
|
+
} catch {
|
|
188
|
+
return sanitizeURL(path);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var formatZodError = (error) => {
|
|
192
|
+
if (!error.issues || error.issues.length === 0) {
|
|
193
|
+
return {};
|
|
194
|
+
}
|
|
195
|
+
return error.issues.reduce((previous, issue) => {
|
|
196
|
+
const key = issue.path.join(".");
|
|
197
|
+
return {
|
|
198
|
+
...previous,
|
|
199
|
+
[key]: {
|
|
200
|
+
code: issue.code,
|
|
201
|
+
message: issue.message
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}, {});
|
|
205
|
+
};
|
|
214
206
|
|
|
215
207
|
// src/actions/signIn/authorization.ts
|
|
216
208
|
var createAuthorizationURL = (oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod) => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
209
|
+
const parsed = OAuthAuthorization.safeParse({ ...oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod });
|
|
210
|
+
if (!parsed.success) {
|
|
211
|
+
const msg = JSON.stringify(formatZodError(parsed.error), null, 2);
|
|
212
|
+
throw new AuthInternalError("INVALID_OAUTH_CONFIGURATION", msg);
|
|
213
|
+
}
|
|
214
|
+
const { authorizeURL, ...options2 } = parsed.data;
|
|
215
|
+
const { userInfo, accessToken, clientSecret, ...required } = options2;
|
|
216
|
+
const searchParams = new URLSearchParams(toCastCase(required));
|
|
217
|
+
return `${authorizeURL}?${searchParams}`;
|
|
218
|
+
};
|
|
226
219
|
var getOriginURL = (request, trustedProxyHeaders) => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} else {
|
|
237
|
-
return new URL(getNormalizedOriginPath(request.url))
|
|
238
|
-
}
|
|
239
|
-
}
|
|
220
|
+
const headers = request.headers;
|
|
221
|
+
if (trustedProxyHeaders) {
|
|
222
|
+
const protocol = headers.get("X-Forwarded-Proto") ?? headers.get("Forwarded")?.match(/proto=([^;]+)/i)?.[1] ?? "http";
|
|
223
|
+
const host = headers.get("X-Forwarded-Host") ?? headers.get("Host") ?? headers.get("Forwarded")?.match(/host=([^;]+)/i)?.[1] ?? null;
|
|
224
|
+
return new URL(`${protocol}://${host}${getNormalizedOriginPath(new URL(request.url).pathname)}`);
|
|
225
|
+
} else {
|
|
226
|
+
return new URL(getNormalizedOriginPath(request.url));
|
|
227
|
+
}
|
|
228
|
+
};
|
|
240
229
|
var createRedirectURI = (request, oauth, basePath, trustedProxyHeaders) => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
230
|
+
const url = getOriginURL(request, trustedProxyHeaders);
|
|
231
|
+
return `${url.origin}${basePath}/callback/${oauth}`;
|
|
232
|
+
};
|
|
244
233
|
var createRedirectTo = (request, redirectTo, trustedProxyHeaders) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
234
|
+
try {
|
|
235
|
+
const headers = request.headers;
|
|
236
|
+
const origin = headers.get("Origin");
|
|
237
|
+
const referer = headers.get("Referer");
|
|
238
|
+
let hostedURL = getOriginURL(request, trustedProxyHeaders);
|
|
239
|
+
if (redirectTo) {
|
|
240
|
+
if (redirectTo.startsWith("/")) {
|
|
241
|
+
return sanitizeURL(redirectTo);
|
|
242
|
+
}
|
|
243
|
+
const redirectToURL = new URL(sanitizeURL(getNormalizedOriginPath(redirectTo)));
|
|
244
|
+
if (!isValidURL(redirectTo) || !equals(redirectToURL.origin, hostedURL.origin)) {
|
|
245
|
+
throw new AuthSecurityError(
|
|
246
|
+
"POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED",
|
|
247
|
+
"The redirectTo parameter does not match the hosted origin."
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return sanitizeURL(redirectToURL.pathname);
|
|
251
|
+
}
|
|
252
|
+
if (referer) {
|
|
253
|
+
const refererURL = new URL(sanitizeURL(referer));
|
|
254
|
+
if (!isValidURL(referer) || !equals(refererURL.origin, hostedURL.origin)) {
|
|
255
|
+
throw new AuthSecurityError(
|
|
256
|
+
"POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED",
|
|
257
|
+
"The referer of the request does not match the hosted origin."
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
return sanitizeURL(refererURL.pathname);
|
|
261
|
+
}
|
|
262
|
+
if (origin) {
|
|
263
|
+
const originURL = new URL(sanitizeURL(getNormalizedOriginPath(origin)));
|
|
264
|
+
if (!isValidURL(origin) || !equals(originURL.origin, hostedURL.origin)) {
|
|
265
|
+
throw new AuthSecurityError("POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED", "Invalid origin (potential CSRF).");
|
|
266
|
+
}
|
|
267
|
+
return sanitizeURL(originURL.pathname);
|
|
268
|
+
}
|
|
269
|
+
return "/";
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (isAuthSecurityError(error)) {
|
|
272
|
+
throw error;
|
|
283
273
|
}
|
|
284
|
-
|
|
274
|
+
throw new AuthSecurityError("POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED", "Invalid origin (potential CSRF).");
|
|
275
|
+
}
|
|
276
|
+
};
|
|
285
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
286
|
-
0 &&
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
})
|
|
278
|
+
0 && (module.exports = {
|
|
279
|
+
createAuthorizationURL,
|
|
280
|
+
createRedirectTo,
|
|
281
|
+
createRedirectURI,
|
|
282
|
+
getOriginURL
|
|
283
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import "../../@types/utility.js"
|
|
1
|
+
import { h as OAuthProviderCredentials } from '../../index-EqsoyjrF.js';
|
|
2
|
+
import 'zod/v4';
|
|
3
|
+
import '../../schemas.js';
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose/jose';
|
|
6
|
+
import '../../@types/utility.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Constructs the request URI for the Authorization Request to the third-party OAuth service. It includes
|
|
@@ -18,14 +17,8 @@ import "../../@types/utility.js"
|
|
|
18
17
|
* @param redirectURI - The redirect URI where the OAuth service will send the user after authorization.
|
|
19
18
|
* @param state - A unique string used to maintain state between the request and callback.
|
|
20
19
|
*/
|
|
21
|
-
declare const createAuthorizationURL: (
|
|
22
|
-
|
|
23
|
-
redirectURI: string,
|
|
24
|
-
state: string,
|
|
25
|
-
codeChallenge: string,
|
|
26
|
-
codeChallengeMethod: string
|
|
27
|
-
) => string
|
|
28
|
-
declare const getOriginURL: (request: Request, trustedProxyHeaders?: boolean) => URL
|
|
20
|
+
declare const createAuthorizationURL: (oauthConfig: OAuthProviderCredentials, redirectURI: string, state: string, codeChallenge: string, codeChallengeMethod: string) => string;
|
|
21
|
+
declare const getOriginURL: (request: Request, trustedProxyHeaders?: boolean) => URL;
|
|
29
22
|
/**
|
|
30
23
|
* Creates the redirect URI for the OAuth callback based on the original request URL and the OAuth provider.
|
|
31
24
|
*
|
|
@@ -33,7 +26,7 @@ declare const getOriginURL: (request: Request, trustedProxyHeaders?: boolean) =>
|
|
|
33
26
|
* @param oauth - OAuth provider name
|
|
34
27
|
* @returns The redirect URI for the OAuth callback.
|
|
35
28
|
*/
|
|
36
|
-
declare const createRedirectURI: (request: Request, oauth: string, basePath: string, trustedProxyHeaders?: boolean) => string
|
|
29
|
+
declare const createRedirectURI: (request: Request, oauth: string, basePath: string, trustedProxyHeaders?: boolean) => string;
|
|
37
30
|
/**
|
|
38
31
|
* Verifies if the request's origin matches the expected origin. It accepts the redirectTo search
|
|
39
32
|
* parameter for redirection. It checks the 'Referer' header of the request with the origin where
|
|
@@ -44,6 +37,6 @@ declare const createRedirectURI: (request: Request, oauth: string, basePath: str
|
|
|
44
37
|
* @param redirectTo Optional redirectTo parameter to override the referer
|
|
45
38
|
* @returns The pathname of the referer URL if origins match
|
|
46
39
|
*/
|
|
47
|
-
declare const createRedirectTo: (request: Request, redirectTo?: string, trustedProxyHeaders?: boolean) => string
|
|
40
|
+
declare const createRedirectTo: (request: Request, redirectTo?: string, trustedProxyHeaders?: boolean) => string;
|
|
48
41
|
|
|
49
|
-
export { createAuthorizationURL, createRedirectTo, createRedirectURI, getOriginURL }
|
|
42
|
+
export { createAuthorizationURL, createRedirectTo, createRedirectURI, getOriginURL };
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
createAuthorizationURL,
|
|
3
|
+
createRedirectTo,
|
|
4
|
+
createRedirectURI,
|
|
5
|
+
getOriginURL
|
|
6
|
+
} from "../../chunk-QEZL7EYN.js";
|
|
7
|
+
import "../../chunk-WD7AUHQ5.js";
|
|
8
|
+
import "../../chunk-CXLATHS5.js";
|
|
9
|
+
import "../../chunk-EIL2FPSS.js";
|
|
10
|
+
import "../../chunk-RRLIF4PQ.js";
|
|
11
|
+
export {
|
|
12
|
+
createAuthorizationURL,
|
|
13
|
+
createRedirectTo,
|
|
14
|
+
createRedirectURI,
|
|
15
|
+
getOriginURL
|
|
16
|
+
};
|