@aura-stack/auth 0.1.0-rc.9 → 0.2.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.cjs +15 -15
- package/dist/@types/index.d.ts +7 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +7 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +4 -8
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +176 -155
- package/dist/actions/callback/access-token.d.ts +15 -20
- package/dist/actions/callback/access-token.js +10 -4
- package/dist/actions/callback/callback.cjs +394 -490
- package/dist/actions/callback/callback.d.ts +10 -12
- package/dist/actions/callback/callback.js +16 -12
- package/dist/actions/callback/userinfo.cjs +166 -145
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +12 -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 +652 -814
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +34 -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 +254 -263
- package/dist/actions/signIn/authorization.d.ts +12 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +320 -456
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +13 -10
- package/dist/actions/signOut/signOut.cjs +304 -473
- 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 +13 -4
- package/dist/assert.js +12 -2
- package/dist/chunk-3EUWD5BB.js +63 -0
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-A3N4PVAT.js +70 -0
- package/dist/chunk-B737EUJV.js +22 -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-EMKJA2GJ.js +89 -0
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-GA2SMTJO.js +58 -0
- package/dist/chunk-HP34YGGJ.js +22 -0
- package/dist/chunk-HT4YLL7N.js +35 -0
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-IUYZQTJV.js +30 -0
- package/dist/chunk-IVET23KF.js +58 -0
- package/dist/chunk-JVFTCTTE.js +33 -0
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-KSWLO5ZU.js +102 -0
- package/dist/chunk-N2APGLXA.js +71 -0
- package/dist/chunk-N4SX7TZT.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-W6LG7BFW.js +197 -0
- package/dist/chunk-YRCB5FLE.js +79 -0
- package/dist/chunk-ZNCZVF6U.js +14 -0
- package/dist/cookie.cjs +222 -187
- package/dist/cookie.d.ts +39 -76
- package/dist/cookie.js +27 -34
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +49 -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-DkaLJFn8.d.ts +679 -0
- package/dist/index.cjs +1074 -1007
- package/dist/index.d.ts +10 -31
- package/dist/index.js +85 -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 +7 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +47 -48
- package/dist/oauth/discord.d.ts +7 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +7 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +7 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +7 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +350 -180
- package/dist/oauth/index.d.ts +7 -26
- package/dist/oauth/index.js +51 -9
- 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.cjs +39 -39
- package/dist/oauth/spotify.d.ts +7 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +7 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +6 -2
- package/dist/request.cjs +38 -0
- package/dist/request.d.ts +13 -0
- package/dist/request.js +6 -0
- package/dist/schemas.cjs +103 -97
- package/dist/schemas.d.ts +96 -126
- package/dist/schemas.js +20 -18
- package/dist/secure.cjs +106 -101
- package/dist/secure.d.ts +17 -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 +8 -7
- 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/index-DpfbvTZ_.d.ts +0 -597
- package/dist/response.cjs +0 -34
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -2
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import * as _aura_stack_router from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
|
+
import { j as OAuthProviderRecord } from '../../index-DkaLJFn8.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
import '../../schemas.js';
|
|
5
|
+
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
7
|
+
import '@aura-stack/jose/jose';
|
|
8
|
+
import '../../@types/utility.js';
|
|
9
9
|
|
|
10
|
-
declare const callbackAction: (
|
|
11
|
-
oauth: AuthRuntimeConfig["oauth"]
|
|
12
|
-
) => _aura_stack_router.RouteEndpoint<"GET", "/callback/:oauth", {}>
|
|
10
|
+
declare const callbackAction: (oauth: OAuthProviderRecord) => _aura_stack_router.RouteEndpoint<"GET", "/callback/:oauth", {}>;
|
|
13
11
|
|
|
14
|
-
export { callbackAction }
|
|
12
|
+
export { callbackAction };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
|
|
1
|
+
import {
|
|
2
|
+
callbackAction
|
|
3
|
+
} from "../../chunk-KSWLO5ZU.js";
|
|
4
|
+
import "../../chunk-GA2SMTJO.js";
|
|
5
|
+
import "../../chunk-IVET23KF.js";
|
|
6
|
+
import "../../chunk-W6LG7BFW.js";
|
|
7
|
+
import "../../chunk-STHEPPUZ.js";
|
|
8
|
+
import "../../chunk-N2APGLXA.js";
|
|
9
|
+
import "../../chunk-CXLATHS5.js";
|
|
10
|
+
import "../../chunk-EIL2FPSS.js";
|
|
11
|
+
import "../../chunk-RRLIF4PQ.js";
|
|
12
|
+
import "../../chunk-ZNCZVF6U.js";
|
|
13
|
+
import "../../chunk-YRCB5FLE.js";
|
|
14
|
+
export {
|
|
15
|
+
callbackAction
|
|
16
|
+
};
|
|
@@ -1,168 +1,189 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
var __create = Object.create
|
|
3
|
-
var __defProp = Object.defineProperty
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
|
|
10
|
-
}
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
29
|
|
|
32
30
|
// src/actions/callback/userinfo.ts
|
|
33
|
-
var userinfo_exports = {}
|
|
31
|
+
var userinfo_exports = {};
|
|
34
32
|
__export(userinfo_exports, {
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
module.exports = __toCommonJS(userinfo_exports)
|
|
33
|
+
getUserInfo: () => getUserInfo
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(userinfo_exports);
|
|
36
|
+
|
|
37
|
+
// src/request.ts
|
|
38
|
+
var fetchAsync = async (url, options2 = {}, timeout = 5e3) => {
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
41
|
+
const response = await fetch(url, {
|
|
42
|
+
...options2,
|
|
43
|
+
signal: controller.signal
|
|
44
|
+
}).finally(() => clearTimeout(timeoutId));
|
|
45
|
+
return response;
|
|
46
|
+
};
|
|
38
47
|
|
|
39
48
|
// src/secure.ts
|
|
40
|
-
var
|
|
49
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
41
50
|
|
|
42
51
|
// src/utils.ts
|
|
43
|
-
var import_router = require("@aura-stack/router")
|
|
52
|
+
var import_router = require("@aura-stack/router");
|
|
44
53
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
54
|
+
// src/errors.ts
|
|
55
|
+
var OAuthProtocolError = class extends Error {
|
|
56
|
+
type = "OAUTH_PROTOCOL_ERROR";
|
|
57
|
+
error;
|
|
58
|
+
errorURI;
|
|
59
|
+
constructor(error, description, errorURI, options2) {
|
|
60
|
+
super(description, options2);
|
|
61
|
+
this.error = error;
|
|
62
|
+
this.errorURI = errorURI;
|
|
63
|
+
this.name = new.target.name;
|
|
64
|
+
Error.captureStackTrace(this, new.target);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var isNativeError = (error) => {
|
|
68
|
+
return error instanceof Error;
|
|
69
|
+
};
|
|
70
|
+
var isOAuthProtocolError = (error) => {
|
|
71
|
+
return error instanceof OAuthProtocolError;
|
|
72
|
+
};
|
|
64
73
|
|
|
65
74
|
// src/secure.ts
|
|
66
75
|
var generateSecure = (length = 32) => {
|
|
67
|
-
|
|
68
|
-
}
|
|
76
|
+
return import_crypto.default.randomBytes(length).toString("base64url");
|
|
77
|
+
};
|
|
69
78
|
|
|
70
79
|
// src/schemas.ts
|
|
71
|
-
var
|
|
72
|
-
var OAuthProviderConfigSchema = (0,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
80
|
+
var import_zod = require("zod");
|
|
81
|
+
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
82
|
+
authorizeURL: (0, import_zod.string)().url(),
|
|
83
|
+
accessToken: (0, import_zod.string)().url(),
|
|
84
|
+
scope: (0, import_zod.string)().optional(),
|
|
85
|
+
userInfo: (0, import_zod.string)().url(),
|
|
86
|
+
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
87
|
+
clientId: (0, import_zod.string)(),
|
|
88
|
+
clientSecret: (0, import_zod.string)()
|
|
89
|
+
});
|
|
81
90
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
})
|
|
87
|
-
var OAuthAuthorizationResponse = (0,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
91
|
-
var OAuthAuthorizationErrorResponse = (0,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
91
|
+
redirectURI: (0, import_zod.string)(),
|
|
92
|
+
state: (0, import_zod.string)(),
|
|
93
|
+
codeChallenge: (0, import_zod.string)(),
|
|
94
|
+
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
95
|
+
});
|
|
96
|
+
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
97
|
+
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
98
|
+
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
99
|
+
});
|
|
100
|
+
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
101
|
+
error: (0, import_zod.enum)([
|
|
102
|
+
"invalid_request",
|
|
103
|
+
"unauthorized_client",
|
|
104
|
+
"access_denied",
|
|
105
|
+
"unsupported_response_type",
|
|
106
|
+
"invalid_scope",
|
|
107
|
+
"server_error",
|
|
108
|
+
"temporarily_unavailable"
|
|
109
|
+
]),
|
|
110
|
+
error_description: (0, import_zod.string)().optional(),
|
|
111
|
+
error_uri: (0, import_zod.string)().optional(),
|
|
112
|
+
state: (0, import_zod.string)()
|
|
113
|
+
});
|
|
105
114
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})
|
|
110
|
-
var OAuthAccessTokenResponse = (0,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
})
|
|
117
|
-
var OAuthAccessTokenErrorResponse = (0,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
var OAuthErrorResponse = (0,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})
|
|
115
|
+
redirectURI: (0, import_zod.string)(),
|
|
116
|
+
code: (0, import_zod.string)(),
|
|
117
|
+
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
118
|
+
});
|
|
119
|
+
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
120
|
+
access_token: (0, import_zod.string)(),
|
|
121
|
+
token_type: (0, import_zod.string)().optional(),
|
|
122
|
+
expires_in: (0, import_zod.number)().optional(),
|
|
123
|
+
refresh_token: (0, import_zod.string)().optional(),
|
|
124
|
+
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
125
|
+
});
|
|
126
|
+
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
127
|
+
error: (0, import_zod.enum)([
|
|
128
|
+
"invalid_request",
|
|
129
|
+
"invalid_client",
|
|
130
|
+
"invalid_grant",
|
|
131
|
+
"unauthorized_client",
|
|
132
|
+
"unsupported_grant_type",
|
|
133
|
+
"invalid_scope"
|
|
134
|
+
]),
|
|
135
|
+
error_description: (0, import_zod.string)().optional(),
|
|
136
|
+
error_uri: (0, import_zod.string)().optional()
|
|
137
|
+
});
|
|
138
|
+
var OAuthErrorResponse = (0, import_zod.object)({
|
|
139
|
+
error: (0, import_zod.string)(),
|
|
140
|
+
error_description: (0, import_zod.string)().optional()
|
|
141
|
+
});
|
|
142
|
+
var OAuthEnvSchema = (0, import_zod.object)({
|
|
143
|
+
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
144
|
+
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
145
|
+
});
|
|
133
146
|
|
|
134
147
|
// src/actions/callback/userinfo.ts
|
|
135
148
|
var getDefaultUserInfo = (profile) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
149
|
+
const sub = generateSecure(16);
|
|
150
|
+
return {
|
|
151
|
+
sub: profile?.id ?? profile?.sub ?? sub,
|
|
152
|
+
email: profile?.email,
|
|
153
|
+
name: profile?.name ?? profile?.username ?? profile?.nickname,
|
|
154
|
+
image: profile?.image ?? profile?.picture
|
|
155
|
+
};
|
|
156
|
+
};
|
|
144
157
|
var getUserInfo = async (oauthConfig, accessToken) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
const userinfoEndpoint = oauthConfig.userInfo;
|
|
159
|
+
try {
|
|
160
|
+
const response = await fetchAsync(userinfoEndpoint, {
|
|
161
|
+
method: "GET",
|
|
162
|
+
headers: {
|
|
163
|
+
Accept: "application/json",
|
|
164
|
+
Authorization: `Bearer ${accessToken}`
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const json = await response.json();
|
|
168
|
+
const { success, data } = OAuthErrorResponse.safeParse(json);
|
|
169
|
+
if (success) {
|
|
170
|
+
throw new OAuthProtocolError(
|
|
171
|
+
data.error,
|
|
172
|
+
data?.error_description ?? "An error occurred while fetching user information."
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return oauthConfig?.profile ? oauthConfig.profile(json) : getDefaultUserInfo(json);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
if (isOAuthProtocolError(error)) {
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
if (isNativeError(error)) {
|
|
181
|
+
throw new OAuthProtocolError("invalid_request", error.message, "", { cause: error });
|
|
162
182
|
}
|
|
163
|
-
}
|
|
183
|
+
throw new OAuthProtocolError("invalid_request", "Failed to fetch user information.", "", { cause: error });
|
|
184
|
+
}
|
|
185
|
+
};
|
|
164
186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
-
0 &&
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
})
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
getUserInfo
|
|
189
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { h as OAuthProviderCredentials, U as User } from '../../index-DkaLJFn8.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '../../schemas.js';
|
|
4
|
+
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
6
|
+
import '@aura-stack/jose/jose';
|
|
7
|
+
import '../../@types/utility.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Get user information from the OAuth provider's userinfo endpoint using the provided access token.
|
|
@@ -15,6 +15,6 @@ import "../../@types/utility.js"
|
|
|
15
15
|
* @param accessToken - Access Token to access the userinfo endpoint
|
|
16
16
|
* @returns The user information retrieved from the userinfo endpoint
|
|
17
17
|
*/
|
|
18
|
-
declare const getUserInfo: (oauthConfig: OAuthProviderCredentials, accessToken: string) => Promise<User
|
|
18
|
+
declare const getUserInfo: (oauthConfig: OAuthProviderCredentials, accessToken: string) => Promise<User>;
|
|
19
19
|
|
|
20
|
-
export { getUserInfo }
|
|
20
|
+
export { getUserInfo };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
getUserInfo
|
|
3
|
+
} from "../../chunk-IVET23KF.js";
|
|
4
|
+
import "../../chunk-N2APGLXA.js";
|
|
5
|
+
import "../../chunk-CXLATHS5.js";
|
|
6
|
+
import "../../chunk-EIL2FPSS.js";
|
|
7
|
+
import "../../chunk-RRLIF4PQ.js";
|
|
8
|
+
import "../../chunk-ZNCZVF6U.js";
|
|
9
|
+
import "../../chunk-YRCB5FLE.js";
|
|
10
|
+
export {
|
|
11
|
+
getUserInfo
|
|
12
|
+
};
|