@aura-stack/auth 0.2.0 → 0.4.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 +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 +26 -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.d.ts +3 -1
- 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.d.ts +3 -1
- 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 +25 -3
- package/dist/actions/signIn/signIn.js +4 -3
- package/dist/actions/signOut/signOut.cjs +66 -66
- package/dist/actions/signOut/signOut.d.ts +9 -1
- 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-B8jeIElf.d.ts} +57 -8
- package/dist/index.cjs +159 -95
- package/dist/index.d.ts +66 -5
- package/dist/index.js +23 -19
- 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 +7 -5
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OAuthAccessToken,
|
|
3
|
-
OAuthAccessTokenErrorResponse,
|
|
4
|
-
OAuthAccessTokenResponse
|
|
5
|
-
} from "./chunk-WD7AUHQ5.js";
|
|
6
1
|
import {
|
|
7
2
|
formatZodError
|
|
8
3
|
} from "./chunk-CXLATHS5.js";
|
|
@@ -10,6 +5,14 @@ import {
|
|
|
10
5
|
AuthInternalError,
|
|
11
6
|
OAuthProtocolError
|
|
12
7
|
} from "./chunk-RRLIF4PQ.js";
|
|
8
|
+
import {
|
|
9
|
+
fetchAsync
|
|
10
|
+
} from "./chunk-ZNCZVF6U.js";
|
|
11
|
+
import {
|
|
12
|
+
OAuthAccessToken,
|
|
13
|
+
OAuthAccessTokenErrorResponse,
|
|
14
|
+
OAuthAccessTokenResponse
|
|
15
|
+
} from "./chunk-YRCB5FLE.js";
|
|
13
16
|
|
|
14
17
|
// src/actions/callback/access-token.ts
|
|
15
18
|
var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) => {
|
|
@@ -20,7 +23,7 @@ var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) =>
|
|
|
20
23
|
}
|
|
21
24
|
const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
|
|
22
25
|
try {
|
|
23
|
-
const response = await
|
|
26
|
+
const response = await fetchAsync(accessToken, {
|
|
24
27
|
method: "POST",
|
|
25
28
|
headers: {
|
|
26
29
|
Accept: "application/json",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/oauth/pinterest.ts
|
|
2
|
+
var pinterest = {
|
|
3
|
+
id: "pinterest",
|
|
4
|
+
name: "Pinterest",
|
|
5
|
+
authorizeURL: "https://api.pinterest.com/oauth/",
|
|
6
|
+
accessToken: "https://api.pinterest.com/v5/oauth/token",
|
|
7
|
+
userInfo: "https://api.pinterest.com/v5/user_account",
|
|
8
|
+
scope: "user_accounts:read",
|
|
9
|
+
responseType: "code",
|
|
10
|
+
profile(profile) {
|
|
11
|
+
return {
|
|
12
|
+
sub: profile.id,
|
|
13
|
+
name: profile.username,
|
|
14
|
+
email: null,
|
|
15
|
+
image: profile.profile_image
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
pinterest
|
|
22
|
+
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OAuthErrorResponse
|
|
3
|
-
} from "./chunk-WD7AUHQ5.js";
|
|
4
1
|
import {
|
|
5
2
|
generateSecure
|
|
6
3
|
} from "./chunk-N2APGLXA.js";
|
|
@@ -9,6 +6,12 @@ import {
|
|
|
9
6
|
isNativeError,
|
|
10
7
|
isOAuthProtocolError
|
|
11
8
|
} from "./chunk-RRLIF4PQ.js";
|
|
9
|
+
import {
|
|
10
|
+
fetchAsync
|
|
11
|
+
} from "./chunk-ZNCZVF6U.js";
|
|
12
|
+
import {
|
|
13
|
+
OAuthErrorResponse
|
|
14
|
+
} from "./chunk-YRCB5FLE.js";
|
|
12
15
|
|
|
13
16
|
// src/actions/callback/userinfo.ts
|
|
14
17
|
var getDefaultUserInfo = (profile) => {
|
|
@@ -23,7 +26,7 @@ var getDefaultUserInfo = (profile) => {
|
|
|
23
26
|
var getUserInfo = async (oauthConfig, accessToken) => {
|
|
24
27
|
const userinfoEndpoint = oauthConfig.userInfo;
|
|
25
28
|
try {
|
|
26
|
-
const response = await
|
|
29
|
+
const response = await fetchAsync(userinfoEndpoint, {
|
|
27
30
|
method: "GET",
|
|
28
31
|
headers: {
|
|
29
32
|
Accept: "application/json",
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getUserInfo
|
|
3
|
-
} from "./chunk-ZLR3LI6X.js";
|
|
4
1
|
import {
|
|
5
2
|
createAccessToken
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GA2SMTJO.js";
|
|
4
|
+
import {
|
|
5
|
+
getUserInfo
|
|
6
|
+
} from "./chunk-IVET23KF.js";
|
|
7
7
|
import {
|
|
8
8
|
createSessionCookie,
|
|
9
9
|
expiredCookieAttributes,
|
|
10
10
|
getCookie
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-W6LG7BFW.js";
|
|
12
12
|
import {
|
|
13
13
|
cacheControl
|
|
14
14
|
} from "./chunk-STHEPPUZ.js";
|
|
15
|
-
import {
|
|
16
|
-
OAuthAuthorizationErrorResponse,
|
|
17
|
-
OAuthAuthorizationResponse
|
|
18
|
-
} from "./chunk-WD7AUHQ5.js";
|
|
19
15
|
import {
|
|
20
16
|
createCSRF
|
|
21
17
|
} from "./chunk-N2APGLXA.js";
|
|
@@ -28,16 +24,25 @@ import {
|
|
|
28
24
|
AuthSecurityError,
|
|
29
25
|
OAuthProtocolError
|
|
30
26
|
} from "./chunk-RRLIF4PQ.js";
|
|
27
|
+
import {
|
|
28
|
+
OAuthAuthorizationErrorResponse
|
|
29
|
+
} from "./chunk-YRCB5FLE.js";
|
|
31
30
|
|
|
32
31
|
// src/actions/callback/callback.ts
|
|
33
|
-
import z from "zod";
|
|
32
|
+
import { z } from "zod";
|
|
34
33
|
import { createEndpoint, createEndpointConfig, HeadersBuilder } from "@aura-stack/router";
|
|
35
34
|
var callbackConfig = (oauth) => {
|
|
36
35
|
return createEndpointConfig("/callback/:oauth", {
|
|
37
36
|
schemas: {
|
|
38
|
-
searchParams: OAuthAuthorizationResponse,
|
|
39
37
|
params: z.object({
|
|
40
|
-
oauth: z.enum(
|
|
38
|
+
oauth: z.enum(
|
|
39
|
+
Object.keys(oauth),
|
|
40
|
+
"The OAuth provider is not supported or invalid."
|
|
41
|
+
)
|
|
42
|
+
}),
|
|
43
|
+
searchParams: z.object({
|
|
44
|
+
code: z.string("Missing code parameter in the OAuth authorization response."),
|
|
45
|
+
state: z.string("Missing state parameter in the OAuth authorization response.")
|
|
41
46
|
})
|
|
42
47
|
},
|
|
43
48
|
middlewares: [
|
|
@@ -65,9 +70,9 @@ var callbackAction = (oauth) => {
|
|
|
65
70
|
} = ctx;
|
|
66
71
|
const oauthConfig = providers[oauth2];
|
|
67
72
|
const cookieState = getCookie(request, cookies.state.name);
|
|
68
|
-
const cookieRedirectTo = getCookie(request, cookies.
|
|
69
|
-
const cookieRedirectURI = getCookie(request, cookies.
|
|
70
|
-
const codeVerifier = getCookie(request, cookies.
|
|
73
|
+
const cookieRedirectTo = getCookie(request, cookies.redirectTo.name);
|
|
74
|
+
const cookieRedirectURI = getCookie(request, cookies.redirectURI.name);
|
|
75
|
+
const codeVerifier = getCookie(request, cookies.codeVerifier.name);
|
|
71
76
|
if (!equals(cookieState, state)) {
|
|
72
77
|
throw new AuthSecurityError(
|
|
73
78
|
"MISMATCHING_STATE",
|
|
@@ -85,7 +90,7 @@ var callbackAction = (oauth) => {
|
|
|
85
90
|
const userInfo = await getUserInfo(oauthConfig, accessToken.access_token);
|
|
86
91
|
const sessionCookie = await createSessionCookie(jose, userInfo);
|
|
87
92
|
const csrfToken = await createCSRF(jose);
|
|
88
|
-
const headers = new 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.
|
|
93
|
+
const headers = new 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();
|
|
89
94
|
return Response.json({ oauth: oauth2 }, { status: 302, headers });
|
|
90
95
|
},
|
|
91
96
|
callbackConfig(oauth)
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OAuthAuthorization
|
|
3
|
-
} from "./chunk-WD7AUHQ5.js";
|
|
4
1
|
import {
|
|
5
2
|
equals,
|
|
6
3
|
formatZodError,
|
|
@@ -16,6 +13,9 @@ import {
|
|
|
16
13
|
AuthSecurityError,
|
|
17
14
|
isAuthSecurityError
|
|
18
15
|
} from "./chunk-RRLIF4PQ.js";
|
|
16
|
+
import {
|
|
17
|
+
OAuthAuthorization
|
|
18
|
+
} from "./chunk-YRCB5FLE.js";
|
|
19
19
|
|
|
20
20
|
// src/actions/signIn/authorization.ts
|
|
21
21
|
var createAuthorizationURL = (oauthConfig, redirectURI, state, codeChallenge, codeChallengeMethod) => {
|
|
@@ -113,7 +113,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
113
113
|
const hostPrefix = useSecure ? "__Host-" : "";
|
|
114
114
|
return {
|
|
115
115
|
sessionToken: {
|
|
116
|
-
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "
|
|
116
|
+
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "session_token"}`,
|
|
117
117
|
attributes: defineSecureCookieOptions(
|
|
118
118
|
useSecure,
|
|
119
119
|
{
|
|
@@ -135,7 +135,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
135
135
|
)
|
|
136
136
|
},
|
|
137
137
|
csrfToken: {
|
|
138
|
-
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "
|
|
138
|
+
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "csrf_token"}`,
|
|
139
139
|
attributes: defineSecureCookieOptions(
|
|
140
140
|
useSecure,
|
|
141
141
|
{
|
|
@@ -145,37 +145,37 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
145
145
|
overrides?.csrfToken?.attributes?.strategy ?? "host"
|
|
146
146
|
)
|
|
147
147
|
},
|
|
148
|
-
|
|
149
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
148
|
+
redirectTo: {
|
|
149
|
+
name: `${securePrefix}${prefix}.${overrides?.redirectTo?.name ?? "redirect_to"}`,
|
|
150
150
|
attributes: defineSecureCookieOptions(
|
|
151
151
|
useSecure,
|
|
152
152
|
{
|
|
153
153
|
...oauthCookieOptions,
|
|
154
|
-
...overrides?.
|
|
154
|
+
...overrides?.redirectTo?.attributes
|
|
155
155
|
},
|
|
156
|
-
overrides?.
|
|
156
|
+
overrides?.redirectTo?.attributes?.strategy ?? "secure"
|
|
157
157
|
)
|
|
158
158
|
},
|
|
159
|
-
|
|
160
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
159
|
+
redirectURI: {
|
|
160
|
+
name: `${securePrefix}${prefix}.${overrides?.redirectURI?.name ?? "redirect_uri"}`,
|
|
161
161
|
attributes: defineSecureCookieOptions(
|
|
162
162
|
useSecure,
|
|
163
163
|
{
|
|
164
164
|
...oauthCookieOptions,
|
|
165
|
-
...overrides?.
|
|
165
|
+
...overrides?.redirectURI?.attributes
|
|
166
166
|
},
|
|
167
|
-
overrides?.
|
|
167
|
+
overrides?.redirectURI?.attributes?.strategy ?? "secure"
|
|
168
168
|
)
|
|
169
169
|
},
|
|
170
|
-
|
|
171
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
170
|
+
codeVerifier: {
|
|
171
|
+
name: `${securePrefix}${prefix}.${overrides?.codeVerifier?.name ?? "code_verifier"}`,
|
|
172
172
|
attributes: defineSecureCookieOptions(
|
|
173
173
|
useSecure,
|
|
174
174
|
{
|
|
175
175
|
...oauthCookieOptions,
|
|
176
|
-
...overrides?.
|
|
176
|
+
...overrides?.codeVerifier?.attributes
|
|
177
177
|
},
|
|
178
|
-
overrides?.
|
|
178
|
+
overrides?.codeVerifier?.attributes?.strategy ?? "secure"
|
|
179
179
|
)
|
|
180
180
|
}
|
|
181
181
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/schemas.ts
|
|
2
|
-
import { object, string, enum as options, number,
|
|
2
|
+
import { object, string, enum as options, number, z, null as nullable } from "zod";
|
|
3
3
|
var OAuthProviderConfigSchema = object({
|
|
4
|
-
authorizeURL:
|
|
5
|
-
accessToken:
|
|
4
|
+
authorizeURL: string().url(),
|
|
5
|
+
accessToken: string().url(),
|
|
6
6
|
scope: string().optional(),
|
|
7
|
-
userInfo:
|
|
7
|
+
userInfo: string().url(),
|
|
8
8
|
responseType: options(["code", "token", "id_token"]),
|
|
9
9
|
clientId: string(),
|
|
10
10
|
clientSecret: string()
|
|
@@ -16,8 +16,8 @@ var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
|
16
16
|
codeChallengeMethod: options(["plain", "S256"])
|
|
17
17
|
});
|
|
18
18
|
var OAuthAuthorizationResponse = object({
|
|
19
|
-
state: string("Missing state parameter in the OAuth authorization response."),
|
|
20
|
-
code: string("Missing code parameter in the OAuth authorization response.")
|
|
19
|
+
state: string({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
20
|
+
code: string({ message: "Missing code parameter in the OAuth authorization response." })
|
|
21
21
|
});
|
|
22
22
|
var OAuthAuthorizationErrorResponse = object({
|
|
23
23
|
error: options([
|
|
@@ -40,10 +40,10 @@ var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
|
40
40
|
});
|
|
41
41
|
var OAuthAccessTokenResponse = object({
|
|
42
42
|
access_token: string(),
|
|
43
|
-
token_type: string(),
|
|
43
|
+
token_type: string().optional(),
|
|
44
44
|
expires_in: number().optional(),
|
|
45
45
|
refresh_token: string().optional(),
|
|
46
|
-
scope: string().optional()
|
|
46
|
+
scope: string().optional().or(nullable())
|
|
47
47
|
});
|
|
48
48
|
var OAuthAccessTokenErrorResponse = object({
|
|
49
49
|
error: options([
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/request.ts
|
|
2
|
+
var fetchAsync = async (url, options = {}, timeout = 5e3) => {
|
|
3
|
+
const controller = new AbortController();
|
|
4
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
5
|
+
const response = await fetch(url, {
|
|
6
|
+
...options,
|
|
7
|
+
signal: controller.signal
|
|
8
|
+
}).finally(() => clearTimeout(timeoutId));
|
|
9
|
+
return response;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
fetchAsync
|
|
14
|
+
};
|
package/dist/cookie.cjs
CHANGED
|
@@ -158,7 +158,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
158
158
|
const hostPrefix = useSecure ? "__Host-" : "";
|
|
159
159
|
return {
|
|
160
160
|
sessionToken: {
|
|
161
|
-
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "
|
|
161
|
+
name: `${securePrefix}${prefix}.${overrides?.sessionToken?.name ?? "session_token"}`,
|
|
162
162
|
attributes: defineSecureCookieOptions(
|
|
163
163
|
useSecure,
|
|
164
164
|
{
|
|
@@ -180,7 +180,7 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
180
180
|
)
|
|
181
181
|
},
|
|
182
182
|
csrfToken: {
|
|
183
|
-
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "
|
|
183
|
+
name: `${hostPrefix}${prefix}.${overrides?.csrfToken?.name ?? "csrf_token"}`,
|
|
184
184
|
attributes: defineSecureCookieOptions(
|
|
185
185
|
useSecure,
|
|
186
186
|
{
|
|
@@ -190,37 +190,37 @@ var createCookieStore = (useSecure, prefix, overrides) => {
|
|
|
190
190
|
overrides?.csrfToken?.attributes?.strategy ?? "host"
|
|
191
191
|
)
|
|
192
192
|
},
|
|
193
|
-
|
|
194
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
193
|
+
redirectTo: {
|
|
194
|
+
name: `${securePrefix}${prefix}.${overrides?.redirectTo?.name ?? "redirect_to"}`,
|
|
195
195
|
attributes: defineSecureCookieOptions(
|
|
196
196
|
useSecure,
|
|
197
197
|
{
|
|
198
198
|
...oauthCookieOptions,
|
|
199
|
-
...overrides?.
|
|
199
|
+
...overrides?.redirectTo?.attributes
|
|
200
200
|
},
|
|
201
|
-
overrides?.
|
|
201
|
+
overrides?.redirectTo?.attributes?.strategy ?? "secure"
|
|
202
202
|
)
|
|
203
203
|
},
|
|
204
|
-
|
|
205
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
204
|
+
redirectURI: {
|
|
205
|
+
name: `${securePrefix}${prefix}.${overrides?.redirectURI?.name ?? "redirect_uri"}`,
|
|
206
206
|
attributes: defineSecureCookieOptions(
|
|
207
207
|
useSecure,
|
|
208
208
|
{
|
|
209
209
|
...oauthCookieOptions,
|
|
210
|
-
...overrides?.
|
|
210
|
+
...overrides?.redirectURI?.attributes
|
|
211
211
|
},
|
|
212
|
-
overrides?.
|
|
212
|
+
overrides?.redirectURI?.attributes?.strategy ?? "secure"
|
|
213
213
|
)
|
|
214
214
|
},
|
|
215
|
-
|
|
216
|
-
name: `${securePrefix}${prefix}.${overrides?.
|
|
215
|
+
codeVerifier: {
|
|
216
|
+
name: `${securePrefix}${prefix}.${overrides?.codeVerifier?.name ?? "code_verifier"}`,
|
|
217
217
|
attributes: defineSecureCookieOptions(
|
|
218
218
|
useSecure,
|
|
219
219
|
{
|
|
220
220
|
...oauthCookieOptions,
|
|
221
|
-
...overrides?.
|
|
221
|
+
...overrides?.codeVerifier?.attributes
|
|
222
222
|
},
|
|
223
|
-
overrides?.
|
|
223
|
+
overrides?.codeVerifier?.attributes?.strategy ?? "secure"
|
|
224
224
|
)
|
|
225
225
|
}
|
|
226
226
|
};
|
package/dist/cookie.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SerializeOptions } from '@aura-stack/router/cookie';
|
|
2
2
|
import { JWTPayload } from '@aura-stack/jose/jose';
|
|
3
|
-
import { A as AuthRuntimeConfig, C as CookieConfig, a as CookieStoreConfig } from './index-
|
|
4
|
-
import 'zod
|
|
3
|
+
import { A as AuthRuntimeConfig, C as CookieConfig, a as CookieStoreConfig } from './index-B8jeIElf.js';
|
|
4
|
+
import 'zod';
|
|
5
5
|
import './schemas.js';
|
|
6
|
+
import '@aura-stack/jose';
|
|
6
7
|
import './@types/utility.js';
|
|
7
8
|
|
|
8
9
|
/**
|
package/dist/cookie.js
CHANGED
package/dist/errors.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { E as ErrorType, b as AuthInternalErrorCode, c as AuthSecurityErrorCode } from './index-
|
|
1
|
+
import { E as ErrorType, b as AuthInternalErrorCode, c as AuthSecurityErrorCode } from './index-B8jeIElf.js';
|
|
2
2
|
import { LiteralUnion } from './@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';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -1,9 +1,55 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import { OAuthAuthorizationErrorResponse, OAuthAccessTokenErrorResponse, OAuthEnvSchema } from './schemas.js';
|
|
3
3
|
import { SerializeOptions } from '@aura-stack/router/cookie';
|
|
4
|
+
import { JWTVerifyOptions, EncryptOptions, JWTDecryptOptions } from '@aura-stack/jose';
|
|
4
5
|
import { JWTPayload } from '@aura-stack/jose/jose';
|
|
5
6
|
import { LiteralUnion, Prettify } from './@types/utility.js';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @see [Pinterest - Get User Account](https://developers.pinterest.com/docs/api/v5/user_account-get)
|
|
10
|
+
*/
|
|
11
|
+
interface PinterestProfile {
|
|
12
|
+
account_type: LiteralUnion<"PINNER">;
|
|
13
|
+
id: string;
|
|
14
|
+
profile_image: string;
|
|
15
|
+
website_url: string;
|
|
16
|
+
username: string;
|
|
17
|
+
about: string;
|
|
18
|
+
business_name: string;
|
|
19
|
+
board_count: number;
|
|
20
|
+
pin_count: number;
|
|
21
|
+
follower_count: number;
|
|
22
|
+
following_count: number;
|
|
23
|
+
monthly_views: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @see [Pinterest - Connect App](https://developers.pinterest.com/docs/getting-started/connect-app/)
|
|
27
|
+
* @see [Pinterest - My Apps](https://developers.pinterest.com/apps/)
|
|
28
|
+
* @see [Pinterest - Get User Account](https://developers.pinterest.com/docs/api/v5/user_account-get)
|
|
29
|
+
*/
|
|
30
|
+
declare const pinterest: OAuthProviderConfig<PinterestProfile>;
|
|
31
|
+
|
|
32
|
+
interface Login {
|
|
33
|
+
email: string;
|
|
34
|
+
avatar: string | null;
|
|
35
|
+
login_id: number;
|
|
36
|
+
login_name: string;
|
|
37
|
+
login_email: string;
|
|
38
|
+
}
|
|
39
|
+
interface MailchimpProfile {
|
|
40
|
+
dc: string;
|
|
41
|
+
role: string;
|
|
42
|
+
accountname: string;
|
|
43
|
+
user_id: string;
|
|
44
|
+
login: Login;
|
|
45
|
+
login_url: string;
|
|
46
|
+
api_endpoint: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @see [Mailchimp - Access Data on Behalf of Other Users with OAuth 2](https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/)
|
|
50
|
+
*/
|
|
51
|
+
declare const mailchimp: OAuthProviderConfig<MailchimpProfile>;
|
|
52
|
+
|
|
7
53
|
/**
|
|
8
54
|
* @see [Strava - SummaryClub](https://developers.strava.com/docs/reference/#api-models-SummaryClub)
|
|
9
55
|
*/
|
|
@@ -379,6 +425,8 @@ declare const builtInOAuthProviders: {
|
|
|
379
425
|
readonly spotify: OAuthProviderConfig<SpotifyProfile>;
|
|
380
426
|
readonly x: OAuthProviderConfig<XProfile>;
|
|
381
427
|
readonly strava: OAuthProviderConfig<StravaProfile>;
|
|
428
|
+
readonly mailchimp: OAuthProviderConfig<MailchimpProfile>;
|
|
429
|
+
readonly pinterest: OAuthProviderConfig<PinterestProfile>;
|
|
382
430
|
};
|
|
383
431
|
/**
|
|
384
432
|
* Constructs OAuth provider configurations from an array of provider names or configurations.
|
|
@@ -482,7 +530,7 @@ type CookieStrategyAttributes = StandardCookie | SecureCookie | HostCookie;
|
|
|
482
530
|
* - `redirect_to`: Post-authentication redirect path
|
|
483
531
|
* - `nonce`: OpenID Connect nonce parameter
|
|
484
532
|
*/
|
|
485
|
-
type CookieName = "sessionToken" | "csrfToken" | "state" | "
|
|
533
|
+
type CookieName = "sessionToken" | "csrfToken" | "state" | "codeVerifier" | "redirectTo" | "redirectURI";
|
|
486
534
|
type CookieStoreConfig = Record<CookieName, {
|
|
487
535
|
name: string;
|
|
488
536
|
attributes: CookieStrategyAttributes;
|
|
@@ -544,7 +592,7 @@ interface AuthConfig {
|
|
|
544
592
|
cookies?: Partial<CookieConfig>;
|
|
545
593
|
/**
|
|
546
594
|
* Secret used to sign and verify JWT tokens for session and csrf protection.
|
|
547
|
-
* If not provided, it will load from the environment variable `AURA_AUTH_SECRET`, but if it
|
|
595
|
+
* If not provided, it will load from the environment variable `AURA_AUTH_SECRET` or `AUTH_SECRET`, but if it
|
|
548
596
|
* doesn't exist, it will throw an error during the initialization of the Auth module.
|
|
549
597
|
*/
|
|
550
598
|
secret?: string;
|
|
@@ -572,12 +620,13 @@ interface JoseInstance {
|
|
|
572
620
|
decodeJWT: (token: string) => Promise<JWTPayload>;
|
|
573
621
|
encodeJWT: (payload: JWTPayload) => Promise<string>;
|
|
574
622
|
signJWS: (payload: JWTPayload) => Promise<string>;
|
|
575
|
-
verifyJWS: (payload: string) => Promise<JWTPayload>;
|
|
576
|
-
encryptJWE: (payload: string) => Promise<string>;
|
|
577
|
-
decryptJWE: (payload: string) => Promise<string>;
|
|
623
|
+
verifyJWS: (payload: string, options?: JWTVerifyOptions) => Promise<JWTPayload>;
|
|
624
|
+
encryptJWE: (payload: string, options?: EncryptOptions) => Promise<string>;
|
|
625
|
+
decryptJWE: (payload: string, options?: JWTDecryptOptions) => Promise<string>;
|
|
578
626
|
}
|
|
627
|
+
type OAuthProviderRecord = Record<LiteralUnion<BuiltInOAuthProvider>, OAuthProviderCredentials>;
|
|
579
628
|
interface RouterGlobalContext {
|
|
580
|
-
oauth:
|
|
629
|
+
oauth: OAuthProviderRecord;
|
|
581
630
|
cookies: CookieStoreConfig;
|
|
582
631
|
jose: JoseInstance;
|
|
583
632
|
secret?: string;
|
|
@@ -627,4 +676,4 @@ type APIErrorMap = Record<string, {
|
|
|
627
676
|
message: string;
|
|
628
677
|
}>;
|
|
629
678
|
|
|
630
|
-
export { type AuthRuntimeConfig as A, type BitbucketProfile as B, type CookieConfig as C, type DiscordProfile as D, type ErrorType as E, type FigmaProfile as F, type GitLabProfile as G,
|
|
679
|
+
export { type AuthorizationError as $, type AuthRuntimeConfig as A, type BitbucketProfile as B, type CookieConfig as C, type DiscordProfile as D, type ErrorType as E, type FigmaProfile as F, type GitLabProfile as G, createBuiltInOAuthProviders as H, type Image as I, type JWTPayloadWithToken as J, type BuiltInOAuthProvider as K, type Login as L, type MailchimpProfile as M, type Nameplate as N, type OAuthProvider as O, type PinterestProfile as P, type JWTStandardClaims as Q, type RouterGlobalContext as R, type Session as S, type SecureCookie as T, type User as U, type HostCookie as V, type StandardCookie as W, type XProfile as X, type CookieStrategyAttributes as Y, type CookieName as Z, type OAuthError as _, type CookieStoreConfig as a, type AccessTokenError as a0, type TokenRevocationError as a1, type OAuthEnv as a2, type AuthInternalErrorCode as b, type AuthSecurityErrorCode as c, type AuthConfig as d, type JoseInstance as e, type AuthInstance as f, type OAuthProviderConfig as g, type OAuthProviderCredentials as h, type APIErrorMap as i, type OAuthProviderRecord as j, type SummaryClub as k, type SummaryGear as l, mailchimp as m, type StravaProfile as n, type SpotifyProfile as o, pinterest as p, spotify as q, gitlab as r, strava as s, discord as t, figma as u, bitbucket as v, type GitHubProfile as w, x, github as y, builtInOAuthProviders as z };
|