@aura-stack/auth 0.1.0-rc.7 → 0.1.0-rc.8
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 +31 -7
- 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 +20 -15
- package/dist/actions/callback/access-token.js +4 -8
- package/dist/actions/callback/callback.cjs +455 -437
- package/dist/actions/callback/callback.d.ts +12 -10
- package/dist/actions/callback/callback.js +12 -16
- package/dist/actions/callback/userinfo.cjs +134 -131
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +6 -10
- package/dist/actions/csrfToken/csrfToken.cjs +171 -162
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +8 -12
- package/dist/actions/index.cjs +773 -746
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +18 -34
- package/dist/actions/session/session.cjs +155 -149
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +7 -11
- package/dist/actions/signIn/authorization.cjs +249 -231
- package/dist/actions/signIn/authorization.d.ts +18 -12
- package/dist/actions/signIn/authorization.js +6 -16
- package/dist/actions/signIn/signIn.cjs +423 -396
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +10 -14
- package/dist/actions/signOut/signOut.cjs +440 -417
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +11 -15
- package/dist/assert.cjs +36 -35
- package/dist/assert.d.ts +4 -4
- package/dist/assert.js +2 -10
- package/dist/chunk-256KIVJL.js +96 -85
- package/dist/chunk-42XB3YCW.js +17 -19
- package/dist/chunk-6SM22VVJ.js +10 -13
- package/dist/chunk-CAKJT3KS.js +69 -84
- package/dist/chunk-E3OXBRYF.js +17 -19
- package/dist/chunk-EBPE35JT.js +26 -28
- package/dist/chunk-FIPU4MLT.js +16 -18
- package/dist/chunk-FJUDBLCP.js +43 -50
- package/dist/chunk-FKRDCWBF.js +17 -19
- package/dist/chunk-GZU3RBTB.js +40 -51
- package/dist/chunk-HGJ4TXY4.js +100 -132
- package/dist/chunk-HMRKN75I.js +63 -63
- package/dist/chunk-IKHPGFCW.js +9 -11
- package/dist/chunk-JAPMIE6S.js +5 -7
- package/dist/chunk-KRNOMBXQ.js +17 -19
- package/dist/chunk-LLR722CL.js +70 -91
- package/dist/chunk-RLT4RFKV.js +30 -39
- package/dist/chunk-SJPDVKUS.js +88 -107
- package/dist/chunk-SMQO5WD7.js +16 -26
- package/dist/chunk-STHEPPUZ.js +6 -8
- package/dist/chunk-UJJ7R56J.js +37 -47
- package/dist/chunk-UTDLUEEG.js +25 -0
- package/dist/chunk-VFTYH33W.js +37 -54
- package/dist/chunk-XXJKNKGQ.js +23 -33
- package/dist/chunk-ZV4BH47P.js +134 -132
- package/dist/cookie.cjs +175 -169
- package/dist/cookie.d.ts +51 -23
- package/dist/cookie.js +34 -34
- package/dist/error.cjs +75 -75
- package/dist/error.d.ts +30 -30
- package/dist/error.js +8 -15
- package/dist/headers.cjs +28 -28
- package/dist/headers.d.ts +2 -2
- package/dist/headers.js +2 -6
- package/dist/index-DpfbvTZ_.d.ts +298 -249
- package/dist/index.cjs +969 -933
- package/dist/index.d.ts +31 -10
- package/dist/index.js +50 -70
- package/dist/jose.cjs +67 -52
- package/dist/jose.d.ts +8 -8
- package/dist/jose.js +5 -9
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +7 -7
- package/dist/oauth/bitbucket.js +2 -6
- package/dist/oauth/discord.cjs +48 -48
- package/dist/oauth/discord.d.ts +7 -7
- package/dist/oauth/discord.js +2 -6
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +7 -7
- package/dist/oauth/figma.js +2 -6
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +7 -7
- package/dist/oauth/github.js +2 -6
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +7 -7
- package/dist/oauth/gitlab.js +2 -6
- package/dist/oauth/index.cjs +180 -180
- package/dist/oauth/index.d.ts +26 -7
- package/dist/oauth/index.js +9 -36
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +7 -7
- package/dist/oauth/spotify.js +2 -6
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +2 -6
- package/dist/response.cjs +27 -27
- package/dist/response.d.ts +2 -2
- package/dist/response.js +2 -6
- package/dist/schemas.cjs +91 -91
- package/dist/schemas.d.ts +126 -93
- package/dist/schemas.js +18 -18
- package/dist/secure.cjs +98 -95
- package/dist/secure.d.ts +17 -17
- package/dist/secure.js +4 -18
- package/dist/utils.cjs +132 -119
- package/dist/utils.d.ts +26 -11
- package/dist/utils.js +21 -21
- package/package.json +1 -1
- package/dist/chunk-X7M4CQTN.js +0 -25
package/dist/chunk-HMRKN75I.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
// src/schemas.ts
|
|
2
|
-
import { object, string, enum as options, number, url } from "zod/v4"
|
|
2
|
+
import { object, string, enum as options, number, url } from "zod/v4"
|
|
3
3
|
var OAuthProviderConfigSchema = object({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})
|
|
4
|
+
authorizeURL: url(),
|
|
5
|
+
accessToken: url(),
|
|
6
|
+
scope: string().optional(),
|
|
7
|
+
userInfo: url(),
|
|
8
|
+
responseType: options(["code", "token", "id_token"]),
|
|
9
|
+
clientId: string(),
|
|
10
|
+
clientSecret: string(),
|
|
11
|
+
})
|
|
12
12
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
13
|
+
redirectURI: string(),
|
|
14
|
+
state: string(),
|
|
15
|
+
codeChallenge: string(),
|
|
16
|
+
codeChallengeMethod: options(["plain", "S256"]),
|
|
17
|
+
})
|
|
18
18
|
var OAuthAuthorizationResponse = object({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
19
|
+
state: string(),
|
|
20
|
+
code: string(),
|
|
21
|
+
})
|
|
22
22
|
var OAuthAuthorizationErrorResponse = object({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
23
|
+
error: options([
|
|
24
|
+
"invalid_request",
|
|
25
|
+
"unauthorized_client",
|
|
26
|
+
"access_denied",
|
|
27
|
+
"unsupported_response_type",
|
|
28
|
+
"invalid_scope",
|
|
29
|
+
"server_error",
|
|
30
|
+
"temporarily_unavailable",
|
|
31
|
+
]),
|
|
32
|
+
error_description: string().optional(),
|
|
33
|
+
error_uri: string().optional(),
|
|
34
|
+
state: string(),
|
|
35
|
+
})
|
|
36
36
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
37
|
+
redirectURI: string(),
|
|
38
|
+
code: string(),
|
|
39
|
+
codeVerifier: string().min(43).max(128),
|
|
40
|
+
})
|
|
41
41
|
var OAuthAccessTokenResponse = object({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
42
|
+
access_token: string(),
|
|
43
|
+
token_type: string(),
|
|
44
|
+
expires_in: number().optional(),
|
|
45
|
+
refresh_token: string().optional(),
|
|
46
|
+
scope: string().optional(),
|
|
47
|
+
})
|
|
48
48
|
var OAuthAccessTokenErrorResponse = object({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
49
|
+
error: options([
|
|
50
|
+
"invalid_request",
|
|
51
|
+
"invalid_client",
|
|
52
|
+
"invalid_grant",
|
|
53
|
+
"unauthorized_client",
|
|
54
|
+
"unsupported_grant_type",
|
|
55
|
+
"invalid_scope",
|
|
56
|
+
]),
|
|
57
|
+
error_description: string().optional(),
|
|
58
|
+
error_uri: string().optional(),
|
|
59
|
+
})
|
|
60
60
|
var OAuthErrorResponse = object({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
61
|
+
error: string(),
|
|
62
|
+
error_description: string().optional(),
|
|
63
|
+
})
|
|
64
64
|
|
|
65
65
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
66
|
+
OAuthProviderConfigSchema,
|
|
67
|
+
OAuthAuthorization,
|
|
68
|
+
OAuthAuthorizationResponse,
|
|
69
|
+
OAuthAuthorizationErrorResponse,
|
|
70
|
+
OAuthAccessToken,
|
|
71
|
+
OAuthAccessTokenResponse,
|
|
72
|
+
OAuthAccessTokenErrorResponse,
|
|
73
|
+
OAuthErrorResponse,
|
|
74
|
+
}
|
package/dist/chunk-IKHPGFCW.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// src/oauth/github.ts
|
|
2
2
|
var github = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
3
|
+
id: "github",
|
|
4
|
+
name: "GitHub",
|
|
5
|
+
authorizeURL: "https://github.com/login/oauth/authorize",
|
|
6
|
+
accessToken: "https://github.com/login/oauth/access_token",
|
|
7
|
+
userInfo: "https://api.github.com/user",
|
|
8
|
+
scope: "read:user user:email",
|
|
9
|
+
responseType: "code",
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
export {
|
|
13
|
-
github
|
|
14
|
-
};
|
|
12
|
+
export { github }
|
package/dist/chunk-JAPMIE6S.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// src/response.ts
|
|
2
2
|
var AuraResponse = class extends Response {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
static json(body, init) {
|
|
4
|
+
return Response.json(body, init)
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
export {
|
|
9
|
-
AuraResponse
|
|
10
|
-
};
|
|
8
|
+
export { AuraResponse }
|
package/dist/chunk-KRNOMBXQ.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
// src/oauth/gitlab.ts
|
|
2
2
|
var gitlab = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
3
|
+
id: "gitlab",
|
|
4
|
+
name: "GitLab",
|
|
5
|
+
authorizeURL: "https://gitlab.com/oauth/authorize",
|
|
6
|
+
accessToken: "https://gitlab.com/oauth/token",
|
|
7
|
+
userInfo: "https://gitlab.com/api/v4/user",
|
|
8
|
+
scope: "read_user",
|
|
9
|
+
responseType: "code",
|
|
10
|
+
profile(profile) {
|
|
11
|
+
return {
|
|
12
|
+
sub: profile.id.toString(),
|
|
13
|
+
name: profile.name ?? profile.username,
|
|
14
|
+
email: profile.email,
|
|
15
|
+
avatar: profile.avatar_url,
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
export {
|
|
21
|
-
gitlab
|
|
22
|
-
};
|
|
20
|
+
export { gitlab }
|
package/dist/chunk-LLR722CL.js
CHANGED
|
@@ -1,96 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
oauthCookie,
|
|
8
|
-
secureCookieOptions,
|
|
9
|
-
setCookie
|
|
10
|
-
} from "./chunk-ZV4BH47P.js";
|
|
11
|
-
import {
|
|
12
|
-
createPKCE,
|
|
13
|
-
generateSecure
|
|
14
|
-
} from "./chunk-GZU3RBTB.js";
|
|
15
|
-
import {
|
|
16
|
-
ERROR_RESPONSE,
|
|
17
|
-
isAuthError
|
|
18
|
-
} from "./chunk-FJUDBLCP.js";
|
|
19
|
-
import {
|
|
20
|
-
AuraResponse
|
|
21
|
-
} from "./chunk-JAPMIE6S.js";
|
|
1
|
+
import { createAuthorizationURL, createRedirectTo, createRedirectURI } from "./chunk-CAKJT3KS.js"
|
|
2
|
+
import { oauthCookie, secureCookieOptions, setCookie } from "./chunk-ZV4BH47P.js"
|
|
3
|
+
import { createPKCE, generateSecure } from "./chunk-GZU3RBTB.js"
|
|
4
|
+
import { ERROR_RESPONSE, isAuthError } from "./chunk-FJUDBLCP.js"
|
|
5
|
+
import { AuraResponse } from "./chunk-JAPMIE6S.js"
|
|
22
6
|
|
|
23
7
|
// src/actions/signIn/signIn.ts
|
|
24
|
-
import z from "zod"
|
|
25
|
-
import { createEndpoint, createEndpointConfig, statusCode } from "@aura-stack/router"
|
|
8
|
+
import z from "zod"
|
|
9
|
+
import { createEndpoint, createEndpointConfig, statusCode } from "@aura-stack/router"
|
|
26
10
|
var signInConfig = (oauth) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
11
|
+
return createEndpointConfig("/signIn/:oauth", {
|
|
12
|
+
schemas: {
|
|
13
|
+
params: z.object({
|
|
14
|
+
oauth: z.enum(Object.keys(oauth)),
|
|
15
|
+
redirectTo: z.string().optional(),
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
36
20
|
var signInAction = (oauth) => {
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
signInConfig(oauth)
|
|
91
|
-
);
|
|
92
|
-
};
|
|
21
|
+
return createEndpoint(
|
|
22
|
+
"GET",
|
|
23
|
+
"/signIn/:oauth",
|
|
24
|
+
async (ctx) => {
|
|
25
|
+
const {
|
|
26
|
+
request,
|
|
27
|
+
params: { oauth: oauth2, redirectTo },
|
|
28
|
+
context: { oauth: providers, cookies, trustedProxyHeaders, basePath },
|
|
29
|
+
} = ctx
|
|
30
|
+
try {
|
|
31
|
+
const cookieOptions = secureCookieOptions(request, cookies, trustedProxyHeaders)
|
|
32
|
+
const state = generateSecure()
|
|
33
|
+
const redirectURI = createRedirectURI(request, oauth2, basePath, trustedProxyHeaders)
|
|
34
|
+
const stateCookie = setCookie("state", state, oauthCookie(cookieOptions))
|
|
35
|
+
const redirectURICookie = setCookie("redirect_uri", redirectURI, oauthCookie(cookieOptions))
|
|
36
|
+
const redirectToCookie = setCookie(
|
|
37
|
+
"redirect_to",
|
|
38
|
+
createRedirectTo(request, redirectTo, trustedProxyHeaders),
|
|
39
|
+
oauthCookie(cookieOptions)
|
|
40
|
+
)
|
|
41
|
+
const { codeVerifier, codeChallenge, method } = await createPKCE()
|
|
42
|
+
const codeVerifierCookie = setCookie("code_verifier", codeVerifier, oauthCookie(cookieOptions))
|
|
43
|
+
const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method)
|
|
44
|
+
const headers = new Headers()
|
|
45
|
+
headers.set("Location", authorization)
|
|
46
|
+
headers.append("Set-Cookie", stateCookie)
|
|
47
|
+
headers.append("Set-Cookie", redirectURICookie)
|
|
48
|
+
headers.append("Set-Cookie", redirectToCookie)
|
|
49
|
+
headers.append("Set-Cookie", codeVerifierCookie)
|
|
50
|
+
return Response.json(
|
|
51
|
+
{ oauth: oauth2 },
|
|
52
|
+
{
|
|
53
|
+
status: 302,
|
|
54
|
+
headers,
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (isAuthError(error)) {
|
|
59
|
+
const { type, message } = error
|
|
60
|
+
return AuraResponse.json({ error: type, error_description: message }, { status: statusCode.BAD_REQUEST })
|
|
61
|
+
}
|
|
62
|
+
return AuraResponse.json(
|
|
63
|
+
{
|
|
64
|
+
error: ERROR_RESPONSE.AUTHORIZATION.SERVER_ERROR,
|
|
65
|
+
error_description: "An unexpected error occurred",
|
|
66
|
+
},
|
|
67
|
+
{ status: statusCode.INTERNAL_SERVER_ERROR }
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
signInConfig(oauth)
|
|
72
|
+
)
|
|
73
|
+
}
|
|
93
74
|
|
|
94
|
-
export {
|
|
95
|
-
signInAction
|
|
96
|
-
};
|
|
75
|
+
export { signInAction }
|
package/dist/chunk-RLT4RFKV.js
CHANGED
|
@@ -1,45 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
AuthError,
|
|
6
|
-
throwAuthError
|
|
7
|
-
} from "./chunk-FJUDBLCP.js";
|
|
8
|
-
import {
|
|
9
|
-
OAuthErrorResponse
|
|
10
|
-
} from "./chunk-HMRKN75I.js";
|
|
1
|
+
import { generateSecure } from "./chunk-GZU3RBTB.js"
|
|
2
|
+
import { AuthError, throwAuthError } from "./chunk-FJUDBLCP.js"
|
|
3
|
+
import { OAuthErrorResponse } from "./chunk-HMRKN75I.js"
|
|
11
4
|
|
|
12
5
|
// src/actions/callback/userinfo.ts
|
|
13
6
|
var getDefaultUserInfo = (profile) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
7
|
+
const sub = generateSecure(16)
|
|
8
|
+
return {
|
|
9
|
+
sub: profile?.id ?? profile?.sub ?? sub,
|
|
10
|
+
email: profile?.email,
|
|
11
|
+
name: profile?.name ?? profile?.username ?? profile?.nickname,
|
|
12
|
+
image: profile?.image ?? profile?.picture,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
22
15
|
var getUserInfo = async (oauthConfig, accessToken) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
const userinfoEndpoint = oauthConfig.userInfo
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(userinfoEndpoint, {
|
|
19
|
+
method: "GET",
|
|
20
|
+
headers: {
|
|
21
|
+
Accept: "application/json",
|
|
22
|
+
Authorization: `Bearer ${accessToken}`,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
const json = await response.json()
|
|
26
|
+
const { success, data } = OAuthErrorResponse.safeParse(json)
|
|
27
|
+
if (success) {
|
|
28
|
+
throw new AuthError(data.error, data?.error_description ?? "An error occurred while fetching user information.")
|
|
29
|
+
}
|
|
30
|
+
return oauthConfig?.profile ? oauthConfig.profile(json) : getDefaultUserInfo(json)
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw throwAuthError(error, "Failed to retrieve userinfo")
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
} catch (error) {
|
|
39
|
-
throw throwAuthError(error, "Failed to retrieve userinfo");
|
|
40
|
-
}
|
|
41
|
-
};
|
|
34
|
+
}
|
|
42
35
|
|
|
43
|
-
export {
|
|
44
|
-
getUserInfo
|
|
45
|
-
};
|
|
36
|
+
export { getUserInfo }
|