@aura-stack/auth 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/index.d.ts +3 -2
- package/dist/@types/router.d.d.ts +3 -2
- package/dist/actions/callback/access-token.cjs +52 -41
- package/dist/actions/callback/access-token.d.ts +5 -4
- package/dist/actions/callback/access-token.js +3 -2
- package/dist/actions/callback/callback.cjs +69 -52
- package/dist/actions/callback/callback.d.ts +4 -3
- package/dist/actions/callback/callback.js +6 -5
- package/dist/actions/callback/userinfo.cjs +54 -43
- package/dist/actions/callback/userinfo.d.ts +3 -2
- package/dist/actions/callback/userinfo.js +3 -2
- package/dist/actions/csrfToken/csrfToken.cjs +2 -2
- package/dist/actions/csrfToken/csrfToken.js +2 -2
- package/dist/actions/index.cjs +93 -71
- package/dist/actions/index.d.ts +3 -2
- package/dist/actions/index.js +15 -14
- package/dist/actions/session/session.js +2 -2
- package/dist/actions/signIn/authorization.cjs +40 -40
- package/dist/actions/signIn/authorization.d.ts +3 -2
- package/dist/actions/signIn/authorization.js +2 -2
- package/dist/actions/signIn/signIn.cjs +63 -50
- package/dist/actions/signIn/signIn.d.ts +4 -3
- package/dist/actions/signIn/signIn.js +4 -3
- package/dist/actions/signOut/signOut.cjs +66 -66
- package/dist/actions/signOut/signOut.js +4 -4
- package/dist/assert.d.ts +3 -2
- package/dist/{chunk-2RXNXMCZ.js → chunk-3EUWD5BB.js} +15 -7
- package/dist/{chunk-NEVKX6K2.js → chunk-A3N4PVAT.js} +3 -3
- package/dist/chunk-B737EUJV.js +22 -0
- package/dist/{chunk-7H3OR6UU.js → chunk-EMKJA2GJ.js} +18 -10
- package/dist/{chunk-4V4JNXVF.js → chunk-GA2SMTJO.js} +9 -6
- package/dist/chunk-HP34YGGJ.js +22 -0
- package/dist/{chunk-QDO2KSRJ.js → chunk-HT4YLL7N.js} +1 -1
- package/dist/{chunk-ZLR3LI6X.js → chunk-IVET23KF.js} +7 -4
- package/dist/{chunk-PTJUYB33.js → chunk-JVFTCTTE.js} +1 -1
- package/dist/{chunk-UEH3LVON.js → chunk-KSWLO5ZU.js} +21 -16
- package/dist/{chunk-QEZL7EYN.js → chunk-N4SX7TZT.js} +3 -3
- package/dist/{chunk-IMICRJ5U.js → chunk-W6LG7BFW.js} +14 -14
- package/dist/{chunk-WD7AUHQ5.js → chunk-YRCB5FLE.js} +8 -8
- package/dist/chunk-ZNCZVF6U.js +14 -0
- package/dist/cookie.cjs +14 -14
- package/dist/cookie.d.ts +3 -2
- package/dist/cookie.js +1 -1
- package/dist/errors.d.ts +3 -2
- package/dist/{index-EqsoyjrF.d.ts → index-DkaLJFn8.d.ts} +57 -8
- package/dist/index.cjs +155 -93
- package/dist/index.d.ts +4 -3
- package/dist/index.js +20 -17
- package/dist/jose.cjs +2 -2
- package/dist/oauth/bitbucket.d.ts +3 -2
- package/dist/oauth/discord.d.ts +3 -2
- package/dist/oauth/figma.d.ts +3 -2
- package/dist/oauth/github.d.ts +3 -2
- package/dist/oauth/gitlab.d.ts +3 -2
- package/dist/oauth/index.cjs +85 -41
- package/dist/oauth/index.d.ts +3 -2
- package/dist/oauth/index.js +16 -8
- 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 +3 -2
- package/dist/oauth/strava.d.ts +3 -2
- package/dist/oauth/x.d.ts +3 -2
- package/dist/request.cjs +38 -0
- package/dist/request.d.ts +13 -0
- package/dist/request.js +6 -0
- package/dist/schemas.cjs +40 -40
- package/dist/schemas.d.ts +15 -15
- package/dist/schemas.js +1 -1
- package/dist/secure.cjs +5 -5
- package/dist/secure.d.ts +3 -2
- package/dist/utils.d.ts +3 -3
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
36
|
var import_config2 = require("dotenv/config");
|
|
37
37
|
var import_router7 = require("@aura-stack/router");
|
|
38
38
|
|
|
39
|
+
// src/jose.ts
|
|
40
|
+
var import_config = require("dotenv/config");
|
|
41
|
+
var import_jose = require("@aura-stack/jose");
|
|
42
|
+
|
|
43
|
+
// src/secure.ts
|
|
44
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
45
|
+
|
|
39
46
|
// src/utils.ts
|
|
40
47
|
var import_router = require("@aura-stack/router");
|
|
41
48
|
|
|
@@ -208,13 +215,6 @@ var formatZodError = (error) => {
|
|
|
208
215
|
}, {});
|
|
209
216
|
};
|
|
210
217
|
|
|
211
|
-
// src/jose.ts
|
|
212
|
-
var import_config = require("dotenv/config");
|
|
213
|
-
var import_jose = require("@aura-stack/jose");
|
|
214
|
-
|
|
215
|
-
// src/secure.ts
|
|
216
|
-
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
217
|
-
|
|
218
218
|
// src/assert.ts
|
|
219
219
|
var isValidURL = (value) => {
|
|
220
220
|
if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
|
|
@@ -227,10 +227,10 @@ var isJWTPayloadWithToken = (payload) => {
|
|
|
227
227
|
|
|
228
228
|
// src/secure.ts
|
|
229
229
|
var generateSecure = (length = 32) => {
|
|
230
|
-
return
|
|
230
|
+
return import_crypto.default.randomBytes(length).toString("base64url");
|
|
231
231
|
};
|
|
232
232
|
var createHash = (data, base = "hex") => {
|
|
233
|
-
return
|
|
233
|
+
return import_crypto.default.createHash("sha256").update(data).digest().toString(base);
|
|
234
234
|
};
|
|
235
235
|
var createPKCE = async (verifier) => {
|
|
236
236
|
const codeVerifier = verifier ?? generateSecure(86);
|
|
@@ -265,7 +265,7 @@ var verifyCSRF = async (jose, cookie, header) => {
|
|
|
265
265
|
if (!equals(headerBuffer.length, cookieBuffer.length)) {
|
|
266
266
|
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
267
267
|
}
|
|
268
|
-
if (!
|
|
268
|
+
if (!import_crypto.default.timingSafeEqual(cookieBuffer, headerBuffer)) {
|
|
269
269
|
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
270
270
|
}
|
|
271
271
|
return true;
|
|
@@ -274,7 +274,7 @@ var verifyCSRF = async (jose, cookie, header) => {
|
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
276
|
var createDerivedSalt = (secret) => {
|
|
277
|
-
return
|
|
277
|
+
return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
// src/jose.ts
|
|
@@ -404,7 +404,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
404
404
|
const hostPrefix = useSecure ? "__Host-" : "";
|
|
405
405
|
return {
|
|
406
406
|
sessionToken: {
|
|
407
|
-
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "
|
|
407
|
+
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "session_token"}`,
|
|
408
408
|
attributes: defineSecureCookieOptions(
|
|
409
409
|
useSecure,
|
|
410
410
|
{
|
|
@@ -426,7 +426,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
426
426
|
)
|
|
427
427
|
},
|
|
428
428
|
csrfToken: {
|
|
429
|
-
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "
|
|
429
|
+
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "csrf_token"}`,
|
|
430
430
|
attributes: defineSecureCookieOptions(
|
|
431
431
|
useSecure,
|
|
432
432
|
{
|
|
@@ -436,37 +436,37 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
436
436
|
overrides?.csrfToken?.attributes?.strategy ?? "host"
|
|
437
437
|
)
|
|
438
438
|
},
|
|
439
|
-
|
|
440
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
439
|
+
redirectTo: {
|
|
440
|
+
name: `${securePrefix}${prefix}.${overrides?.redirectTo?.name ?? "redirect_to"}`,
|
|
441
441
|
attributes: defineSecureCookieOptions(
|
|
442
442
|
useSecure,
|
|
443
443
|
{
|
|
444
444
|
...oauthCookieOptions,
|
|
445
|
-
...overrides?.
|
|
445
|
+
...overrides?.redirectTo?.attributes
|
|
446
446
|
},
|
|
447
|
-
overrides?.
|
|
447
|
+
overrides?.redirectTo?.attributes?.strategy ?? "secure"
|
|
448
448
|
)
|
|
449
449
|
},
|
|
450
|
-
|
|
451
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
450
|
+
redirectURI: {
|
|
451
|
+
name: `${securePrefix}${prefix}.${overrides?.redirectURI?.name ?? "redirect_uri"}`,
|
|
452
452
|
attributes: defineSecureCookieOptions(
|
|
453
453
|
useSecure,
|
|
454
454
|
{
|
|
455
455
|
...oauthCookieOptions,
|
|
456
|
-
...overrides?.
|
|
456
|
+
...overrides?.redirectURI?.attributes
|
|
457
457
|
},
|
|
458
|
-
overrides?.
|
|
458
|
+
overrides?.redirectURI?.attributes?.strategy ?? "secure"
|
|
459
459
|
)
|
|
460
460
|
},
|
|
461
|
-
|
|
462
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
461
|
+
codeVerifier: {
|
|
462
|
+
name: `${securePrefix}${prefix}.${overrides?.codeVerifier?.name ?? "code_verifier"}`,
|
|
463
463
|
attributes: defineSecureCookieOptions(
|
|
464
464
|
useSecure,
|
|
465
465
|
{
|
|
466
466
|
...oauthCookieOptions,
|
|
467
|
-
...overrides?.
|
|
467
|
+
...overrides?.codeVerifier?.attributes
|
|
468
468
|
},
|
|
469
|
-
overrides?.
|
|
469
|
+
overrides?.codeVerifier?.attributes?.strategy ?? "secure"
|
|
470
470
|
)
|
|
471
471
|
}
|
|
472
472
|
};
|
|
@@ -623,29 +623,67 @@ var strava = {
|
|
|
623
623
|
}
|
|
624
624
|
};
|
|
625
625
|
|
|
626
|
+
// src/oauth/mailchimp.ts
|
|
627
|
+
var mailchimp = {
|
|
628
|
+
id: "mailchimp",
|
|
629
|
+
name: "Mailchimp",
|
|
630
|
+
authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
|
|
631
|
+
accessToken: "https://login.mailchimp.com/oauth2/token",
|
|
632
|
+
userInfo: "https://login.mailchimp.com/oauth2/metadata",
|
|
633
|
+
scope: "",
|
|
634
|
+
responseType: "code",
|
|
635
|
+
profile(profile) {
|
|
636
|
+
return {
|
|
637
|
+
sub: profile.user_id,
|
|
638
|
+
name: profile.accountname,
|
|
639
|
+
email: profile.login.login_email,
|
|
640
|
+
image: null
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
// src/oauth/pinterest.ts
|
|
646
|
+
var pinterest = {
|
|
647
|
+
id: "pinterest",
|
|
648
|
+
name: "Pinterest",
|
|
649
|
+
authorizeURL: "https://api.pinterest.com/oauth/",
|
|
650
|
+
accessToken: "https://api.pinterest.com/v5/oauth/token",
|
|
651
|
+
userInfo: "https://api.pinterest.com/v5/user_account",
|
|
652
|
+
scope: "user_accounts:read",
|
|
653
|
+
responseType: "code",
|
|
654
|
+
profile(profile) {
|
|
655
|
+
return {
|
|
656
|
+
sub: profile.id,
|
|
657
|
+
name: profile.username,
|
|
658
|
+
email: null,
|
|
659
|
+
image: profile.profile_image
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
|
|
626
664
|
// src/schemas.ts
|
|
627
|
-
var
|
|
628
|
-
var OAuthProviderConfigSchema = (0,
|
|
629
|
-
authorizeURL: (0,
|
|
630
|
-
accessToken: (0,
|
|
631
|
-
scope: (0,
|
|
632
|
-
userInfo: (0,
|
|
633
|
-
responseType: (0,
|
|
634
|
-
clientId: (0,
|
|
635
|
-
clientSecret: (0,
|
|
665
|
+
var import_zod = require("zod");
|
|
666
|
+
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
667
|
+
authorizeURL: (0, import_zod.string)().url(),
|
|
668
|
+
accessToken: (0, import_zod.string)().url(),
|
|
669
|
+
scope: (0, import_zod.string)().optional(),
|
|
670
|
+
userInfo: (0, import_zod.string)().url(),
|
|
671
|
+
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
672
|
+
clientId: (0, import_zod.string)(),
|
|
673
|
+
clientSecret: (0, import_zod.string)()
|
|
636
674
|
});
|
|
637
675
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
638
|
-
redirectURI: (0,
|
|
639
|
-
state: (0,
|
|
640
|
-
codeChallenge: (0,
|
|
641
|
-
codeChallengeMethod: (0,
|
|
676
|
+
redirectURI: (0, import_zod.string)(),
|
|
677
|
+
state: (0, import_zod.string)(),
|
|
678
|
+
codeChallenge: (0, import_zod.string)(),
|
|
679
|
+
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
642
680
|
});
|
|
643
|
-
var OAuthAuthorizationResponse = (0,
|
|
644
|
-
state: (0,
|
|
645
|
-
code: (0,
|
|
681
|
+
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
682
|
+
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
683
|
+
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
646
684
|
});
|
|
647
|
-
var OAuthAuthorizationErrorResponse = (0,
|
|
648
|
-
error: (0,
|
|
685
|
+
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
686
|
+
error: (0, import_zod.enum)([
|
|
649
687
|
"invalid_request",
|
|
650
688
|
"unauthorized_client",
|
|
651
689
|
"access_denied",
|
|
@@ -654,24 +692,24 @@ var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
|
654
692
|
"server_error",
|
|
655
693
|
"temporarily_unavailable"
|
|
656
694
|
]),
|
|
657
|
-
error_description: (0,
|
|
658
|
-
error_uri: (0,
|
|
659
|
-
state: (0,
|
|
695
|
+
error_description: (0, import_zod.string)().optional(),
|
|
696
|
+
error_uri: (0, import_zod.string)().optional(),
|
|
697
|
+
state: (0, import_zod.string)()
|
|
660
698
|
});
|
|
661
699
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
662
|
-
redirectURI: (0,
|
|
663
|
-
code: (0,
|
|
664
|
-
codeVerifier: (0,
|
|
700
|
+
redirectURI: (0, import_zod.string)(),
|
|
701
|
+
code: (0, import_zod.string)(),
|
|
702
|
+
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
665
703
|
});
|
|
666
|
-
var OAuthAccessTokenResponse = (0,
|
|
667
|
-
access_token: (0,
|
|
668
|
-
token_type: (0,
|
|
669
|
-
expires_in: (0,
|
|
670
|
-
refresh_token: (0,
|
|
671
|
-
scope: (0,
|
|
704
|
+
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
705
|
+
access_token: (0, import_zod.string)(),
|
|
706
|
+
token_type: (0, import_zod.string)().optional(),
|
|
707
|
+
expires_in: (0, import_zod.number)().optional(),
|
|
708
|
+
refresh_token: (0, import_zod.string)().optional(),
|
|
709
|
+
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
672
710
|
});
|
|
673
|
-
var OAuthAccessTokenErrorResponse = (0,
|
|
674
|
-
error: (0,
|
|
711
|
+
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
712
|
+
error: (0, import_zod.enum)([
|
|
675
713
|
"invalid_request",
|
|
676
714
|
"invalid_client",
|
|
677
715
|
"invalid_grant",
|
|
@@ -679,16 +717,16 @@ var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
|
679
717
|
"unsupported_grant_type",
|
|
680
718
|
"invalid_scope"
|
|
681
719
|
]),
|
|
682
|
-
error_description: (0,
|
|
683
|
-
error_uri: (0,
|
|
720
|
+
error_description: (0, import_zod.string)().optional(),
|
|
721
|
+
error_uri: (0, import_zod.string)().optional()
|
|
684
722
|
});
|
|
685
|
-
var OAuthErrorResponse = (0,
|
|
686
|
-
error: (0,
|
|
687
|
-
error_description: (0,
|
|
723
|
+
var OAuthErrorResponse = (0, import_zod.object)({
|
|
724
|
+
error: (0, import_zod.string)(),
|
|
725
|
+
error_description: (0, import_zod.string)().optional()
|
|
688
726
|
});
|
|
689
|
-
var OAuthEnvSchema = (0,
|
|
690
|
-
clientId:
|
|
691
|
-
clientSecret:
|
|
727
|
+
var OAuthEnvSchema = (0, import_zod.object)({
|
|
728
|
+
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
729
|
+
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
692
730
|
});
|
|
693
731
|
|
|
694
732
|
// src/oauth/index.ts
|
|
@@ -700,7 +738,9 @@ var builtInOAuthProviders = {
|
|
|
700
738
|
gitlab,
|
|
701
739
|
spotify,
|
|
702
740
|
x,
|
|
703
|
-
strava
|
|
741
|
+
strava,
|
|
742
|
+
mailchimp,
|
|
743
|
+
pinterest
|
|
704
744
|
};
|
|
705
745
|
var defineOAuthEnvironment = (oauth) => {
|
|
706
746
|
const env = process.env;
|
|
@@ -735,9 +775,17 @@ var createBuiltInOAuthProviders = (oauth = []) => {
|
|
|
735
775
|
};
|
|
736
776
|
|
|
737
777
|
// src/actions/signIn/signIn.ts
|
|
738
|
-
var
|
|
778
|
+
var import_zod2 = require("zod");
|
|
739
779
|
var import_router2 = require("@aura-stack/router");
|
|
740
780
|
|
|
781
|
+
// src/headers.ts
|
|
782
|
+
var cacheControl = {
|
|
783
|
+
"Cache-Control": "no-store",
|
|
784
|
+
Pragma: "no-cache",
|
|
785
|
+
Expires: "0",
|
|
786
|
+
Vary: "Cookie"
|
|
787
|
+
};
|
|
788
|
+
|
|
741
789
|
// src/actions/signIn/authorization.ts
|
|
742
790
|
var createAuthorizationURL = (oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod) => {
|
|
743
791
|
const parsed = OAuthAuthorization.safeParse({ ...oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod });
|
|
@@ -813,9 +861,14 @@ var createRedirectTo = (request, redirectTo, trustedProxyHeaders) => {
|
|
|
813
861
|
var signInConfig = (oauth) => {
|
|
814
862
|
return (0, import_router2.createEndpointConfig)("/signIn/:oauth", {
|
|
815
863
|
schemas: {
|
|
816
|
-
params:
|
|
817
|
-
oauth:
|
|
818
|
-
|
|
864
|
+
params: import_zod2.z.object({
|
|
865
|
+
oauth: import_zod2.z.enum(
|
|
866
|
+
Object.keys(oauth),
|
|
867
|
+
"The OAuth provider is not supported or invalid."
|
|
868
|
+
)
|
|
869
|
+
}),
|
|
870
|
+
searchParams: import_zod2.z.object({
|
|
871
|
+
redirectTo: import_zod2.z.string().optional()
|
|
819
872
|
})
|
|
820
873
|
}
|
|
821
874
|
});
|
|
@@ -827,8 +880,8 @@ var signInAction = (oauth) => {
|
|
|
827
880
|
async (ctx) => {
|
|
828
881
|
const {
|
|
829
882
|
request,
|
|
830
|
-
|
|
831
|
-
|
|
883
|
+
params: { oauth: oauth2 },
|
|
884
|
+
searchParams: { redirectTo },
|
|
832
885
|
context: { oauth: providers, cookies, trustedProxyHeaders, basePath }
|
|
833
886
|
} = ctx;
|
|
834
887
|
const state = generateSecure();
|
|
@@ -836,7 +889,7 @@ var signInAction = (oauth) => {
|
|
|
836
889
|
const redirectToValue = createRedirectTo(request, redirectTo, trustedProxyHeaders);
|
|
837
890
|
const { codeVerifier, codeChallenge, method } = await createPKCE();
|
|
838
891
|
const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method);
|
|
839
|
-
const headers =
|
|
892
|
+
const headers = new import_router2.HeadersBuilder(cacheControl).setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirectURI.name, redirectURI, cookies.redirectURI.attributes).setCookie(cookies.redirectTo.name, redirectToValue, cookies.redirectTo.attributes).setCookie(cookies.codeVerifier.name, codeVerifier, cookies.codeVerifier.attributes).toHeaders();
|
|
840
893
|
return Response.json(
|
|
841
894
|
{ oauth: oauth2 },
|
|
842
895
|
{
|
|
@@ -850,15 +903,18 @@ var signInAction = (oauth) => {
|
|
|
850
903
|
};
|
|
851
904
|
|
|
852
905
|
// src/actions/callback/callback.ts
|
|
853
|
-
var
|
|
906
|
+
var import_zod3 = require("zod");
|
|
854
907
|
var import_router3 = require("@aura-stack/router");
|
|
855
908
|
|
|
856
|
-
// src/
|
|
857
|
-
var
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
909
|
+
// src/request.ts
|
|
910
|
+
var fetchAsync = async (url, options2 = {}, timeout = 5e3) => {
|
|
911
|
+
const controller = new AbortController();
|
|
912
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
913
|
+
const response = await fetch(url, {
|
|
914
|
+
...options2,
|
|
915
|
+
signal: controller.signal
|
|
916
|
+
}).finally(() => clearTimeout(timeoutId));
|
|
917
|
+
return response;
|
|
862
918
|
};
|
|
863
919
|
|
|
864
920
|
// src/actions/callback/userinfo.ts
|
|
@@ -874,7 +930,7 @@ var getDefaultUserInfo = (profile) => {
|
|
|
874
930
|
var getUserInfo = async (oauthConfig, accessToken) => {
|
|
875
931
|
const userinfoEndpoint = oauthConfig.userInfo;
|
|
876
932
|
try {
|
|
877
|
-
const response = await
|
|
933
|
+
const response = await fetchAsync(userinfoEndpoint, {
|
|
878
934
|
method: "GET",
|
|
879
935
|
headers: {
|
|
880
936
|
Accept: "application/json",
|
|
@@ -910,7 +966,7 @@ var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) =>
|
|
|
910
966
|
}
|
|
911
967
|
const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
|
|
912
968
|
try {
|
|
913
|
-
const response = await
|
|
969
|
+
const response = await fetchAsync(accessToken, {
|
|
914
970
|
method: "POST",
|
|
915
971
|
headers: {
|
|
916
972
|
Accept: "application/json",
|
|
@@ -944,9 +1000,15 @@ var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) =>
|
|
|
944
1000
|
var callbackConfig = (oauth) => {
|
|
945
1001
|
return (0, import_router3.createEndpointConfig)("/callback/:oauth", {
|
|
946
1002
|
schemas: {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1003
|
+
params: import_zod3.z.object({
|
|
1004
|
+
oauth: import_zod3.z.enum(
|
|
1005
|
+
Object.keys(oauth),
|
|
1006
|
+
"The OAuth provider is not supported or invalid."
|
|
1007
|
+
)
|
|
1008
|
+
}),
|
|
1009
|
+
searchParams: import_zod3.z.object({
|
|
1010
|
+
code: import_zod3.z.string("Missing code parameter in the OAuth authorization response."),
|
|
1011
|
+
state: import_zod3.z.string("Missing state parameter in the OAuth authorization response.")
|
|
950
1012
|
})
|
|
951
1013
|
},
|
|
952
1014
|
middlewares: [
|
|
@@ -974,9 +1036,9 @@ var callbackAction = (oauth) => {
|
|
|
974
1036
|
} = ctx;
|
|
975
1037
|
const oauthConfig = providers[oauth2];
|
|
976
1038
|
const cookieState = getCookie(request, cookies.state.name);
|
|
977
|
-
const cookieRedirectTo = getCookie(request, cookies.
|
|
978
|
-
const cookieRedirectURI = getCookie(request, cookies.
|
|
979
|
-
const codeVerifier = getCookie(request, cookies.
|
|
1039
|
+
const cookieRedirectTo = getCookie(request, cookies.redirectTo.name);
|
|
1040
|
+
const cookieRedirectURI = getCookie(request, cookies.redirectURI.name);
|
|
1041
|
+
const codeVerifier = getCookie(request, cookies.codeVerifier.name);
|
|
980
1042
|
if (!equals(cookieState, state)) {
|
|
981
1043
|
throw new AuthSecurityError(
|
|
982
1044
|
"MISMATCHING_STATE",
|
|
@@ -994,7 +1056,7 @@ var callbackAction = (oauth) => {
|
|
|
994
1056
|
const userInfo = await getUserInfo(oauthConfig, accessToken.access_token);
|
|
995
1057
|
const sessionCookie = await createSessionCookie(jose, userInfo);
|
|
996
1058
|
const csrfToken = await createCSRF(jose);
|
|
997
|
-
const headers = new import_router3.HeadersBuilder(cacheControl).setHeader("Location", sanitized).setCookie(cookies.sessionToken.name, sessionCookie, cookies.sessionToken.attributes).setCookie(cookies.csrfToken.name, csrfToken, cookies.csrfToken.attributes).setCookie(cookies.state.name, "", expiredCookieAttributes).setCookie(cookies.
|
|
1059
|
+
const headers = new import_router3.HeadersBuilder(cacheControl).setHeader("Location", sanitized).setCookie(cookies.sessionToken.name, sessionCookie, cookies.sessionToken.attributes).setCookie(cookies.csrfToken.name, csrfToken, cookies.csrfToken.attributes).setCookie(cookies.state.name, "", expiredCookieAttributes).setCookie(cookies.redirectURI.name, "", expiredCookieAttributes).setCookie(cookies.redirectTo.name, "", expiredCookieAttributes).setCookie(cookies.codeVerifier.name, "", expiredCookieAttributes).toHeaders();
|
|
998
1060
|
return Response.json({ oauth: oauth2 }, { status: 302, headers });
|
|
999
1061
|
},
|
|
1000
1062
|
callbackConfig(oauth)
|
|
@@ -1021,13 +1083,13 @@ var sessionAction = (0, import_router4.createEndpoint)("GET", "/session", async
|
|
|
1021
1083
|
});
|
|
1022
1084
|
|
|
1023
1085
|
// src/actions/signOut/signOut.ts
|
|
1024
|
-
var
|
|
1086
|
+
var import_zod4 = require("zod");
|
|
1025
1087
|
var import_router5 = require("@aura-stack/router");
|
|
1026
1088
|
var config = (0, import_router5.createEndpointConfig)({
|
|
1027
1089
|
schemas: {
|
|
1028
|
-
searchParams:
|
|
1029
|
-
token_type_hint:
|
|
1030
|
-
redirectTo:
|
|
1090
|
+
searchParams: import_zod4.z.object({
|
|
1091
|
+
token_type_hint: import_zod4.z.literal("session_token"),
|
|
1092
|
+
redirectTo: import_zod4.z.string().optional()
|
|
1031
1093
|
})
|
|
1032
1094
|
}
|
|
1033
1095
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { d as AuthConfig, e as AuthInstance } from './index-
|
|
2
|
-
export { C as CookieConfig, E as ErrorType, f as JoseInstance, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, U as User } from './index-
|
|
3
|
-
import 'zod
|
|
1
|
+
import { d as AuthConfig, e as AuthInstance } from './index-DkaLJFn8.js';
|
|
2
|
+
export { C as CookieConfig, E as ErrorType, f as JoseInstance, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, U as User } from './index-DkaLJFn8.js';
|
|
3
|
+
import 'zod';
|
|
4
4
|
import './schemas.js';
|
|
5
5
|
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
6
7
|
import '@aura-stack/jose/jose';
|
|
7
8
|
import './@types/utility.js';
|
|
8
9
|
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createBuiltInOAuthProviders
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EMKJA2GJ.js";
|
|
4
|
+
import "./chunk-42XB3YCW.js";
|
|
5
|
+
import "./chunk-FKRDCWBF.js";
|
|
4
6
|
import "./chunk-IKHPGFCW.js";
|
|
5
7
|
import "./chunk-KRNOMBXQ.js";
|
|
8
|
+
import "./chunk-B737EUJV.js";
|
|
9
|
+
import "./chunk-HP34YGGJ.js";
|
|
6
10
|
import "./chunk-E3OXBRYF.js";
|
|
7
11
|
import "./chunk-6R2YZ4AC.js";
|
|
8
|
-
import "./chunk-42XB3YCW.js";
|
|
9
12
|
import "./chunk-ITQ7352M.js";
|
|
13
|
+
import {
|
|
14
|
+
signOutAction
|
|
15
|
+
} from "./chunk-A3N4PVAT.js";
|
|
10
16
|
import {
|
|
11
17
|
csrfTokenAction
|
|
12
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HT4YLL7N.js";
|
|
13
19
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
20
|
+
callbackAction
|
|
21
|
+
} from "./chunk-KSWLO5ZU.js";
|
|
22
|
+
import "./chunk-GA2SMTJO.js";
|
|
23
|
+
import "./chunk-IVET23KF.js";
|
|
16
24
|
import {
|
|
17
25
|
sessionAction
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
signOutAction
|
|
21
|
-
} from "./chunk-NEVKX6K2.js";
|
|
22
|
-
import "./chunk-QEZL7EYN.js";
|
|
26
|
+
} from "./chunk-JVFTCTTE.js";
|
|
23
27
|
import {
|
|
24
|
-
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-4V4JNXVF.js";
|
|
28
|
+
signInAction
|
|
29
|
+
} from "./chunk-3EUWD5BB.js";
|
|
30
|
+
import "./chunk-N4SX7TZT.js";
|
|
28
31
|
import "./chunk-FIPU4MLT.js";
|
|
29
32
|
import "./chunk-IUYZQTJV.js";
|
|
30
|
-
import "./chunk-FKRDCWBF.js";
|
|
31
33
|
import {
|
|
32
34
|
createCookieStore
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-W6LG7BFW.js";
|
|
34
36
|
import "./chunk-STHEPPUZ.js";
|
|
35
37
|
import {
|
|
36
38
|
createJoseInstance
|
|
37
39
|
} from "./chunk-TLE4PXY3.js";
|
|
38
|
-
import "./chunk-WD7AUHQ5.js";
|
|
39
40
|
import "./chunk-N2APGLXA.js";
|
|
40
41
|
import {
|
|
41
42
|
onErrorHandler,
|
|
@@ -43,6 +44,8 @@ import {
|
|
|
43
44
|
} from "./chunk-CXLATHS5.js";
|
|
44
45
|
import "./chunk-EIL2FPSS.js";
|
|
45
46
|
import "./chunk-RRLIF4PQ.js";
|
|
47
|
+
import "./chunk-ZNCZVF6U.js";
|
|
48
|
+
import "./chunk-YRCB5FLE.js";
|
|
46
49
|
|
|
47
50
|
// src/index.ts
|
|
48
51
|
import "dotenv/config";
|
package/dist/jose.cjs
CHANGED
|
@@ -37,7 +37,7 @@ var import_config = require("dotenv/config");
|
|
|
37
37
|
var import_jose = require("@aura-stack/jose");
|
|
38
38
|
|
|
39
39
|
// src/secure.ts
|
|
40
|
-
var
|
|
40
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
41
41
|
|
|
42
42
|
// src/utils.ts
|
|
43
43
|
var import_router = require("@aura-stack/router");
|
|
@@ -56,7 +56,7 @@ var AuthInternalError = class extends Error {
|
|
|
56
56
|
|
|
57
57
|
// src/secure.ts
|
|
58
58
|
var createDerivedSalt = (secret) => {
|
|
59
|
-
return
|
|
59
|
+
return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/jose.ts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { B as BitbucketProfile,
|
|
1
|
+
export { B as BitbucketProfile, v as bitbucket } from '../index-DkaLJFn8.js';
|
|
2
2
|
import '../@types/utility.js';
|
|
3
|
-
import 'zod
|
|
3
|
+
import 'zod';
|
|
4
4
|
import '../schemas.js';
|
|
5
5
|
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
6
7
|
import '@aura-stack/jose/jose';
|
package/dist/oauth/discord.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { D as DiscordProfile, N as Nameplate,
|
|
2
|
-
import 'zod
|
|
1
|
+
export { D as DiscordProfile, N as Nameplate, t as discord } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
3
3
|
import '../schemas.js';
|
|
4
4
|
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
5
6
|
import '@aura-stack/jose/jose';
|
|
6
7
|
import '../@types/utility.js';
|
package/dist/oauth/figma.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { F as FigmaProfile,
|
|
2
|
-
import 'zod
|
|
1
|
+
export { F as FigmaProfile, u as figma } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
3
3
|
import '../schemas.js';
|
|
4
4
|
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
5
6
|
import '@aura-stack/jose/jose';
|
|
6
7
|
import '../@types/utility.js';
|
package/dist/oauth/github.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import 'zod
|
|
1
|
+
export { w as GitHubProfile, y as github } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
3
3
|
import '../schemas.js';
|
|
4
4
|
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
5
6
|
import '@aura-stack/jose/jose';
|
|
6
7
|
import '../@types/utility.js';
|
package/dist/oauth/gitlab.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { G as GitLabProfile,
|
|
2
|
-
import 'zod
|
|
1
|
+
export { G as GitLabProfile, r as gitlab } from '../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
3
3
|
import '../schemas.js';
|
|
4
4
|
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
5
6
|
import '@aura-stack/jose/jose';
|
|
6
7
|
import '../@types/utility.js';
|