@logto/js 0.1.7 → 0.1.14
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/lib/core/user-info.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Requester } from '../utils';
|
|
2
2
|
export declare type UserInfoResponse = {
|
|
3
3
|
sub: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
username?: string;
|
|
6
|
+
avatar?: string;
|
|
7
|
+
role_names?: string[];
|
|
4
8
|
};
|
|
5
9
|
export declare const fetchUserInfo: (userInfoEndpoint: string, accessToken: string, requester: Requester) => Promise<UserInfoResponse>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyAndParseCodeFromCallbackUri = exports.parseUriParameters = void 0;
|
|
4
|
+
const essentials_1 = require("@silverhand/essentials");
|
|
4
5
|
const consts_1 = require("../consts");
|
|
5
6
|
const errors_1 = require("./errors");
|
|
6
7
|
const parseUriParameters = (uri) => {
|
|
@@ -14,13 +15,10 @@ const verifyAndParseCodeFromCallbackUri = (callbackUri, redirectUri, state) => {
|
|
|
14
15
|
throw new errors_1.LogtoError('callback_uri_verification.redirect_uri_mismatched');
|
|
15
16
|
}
|
|
16
17
|
const uriParameters = (0, exports.parseUriParameters)(callbackUri);
|
|
17
|
-
const error = uriParameters.get(consts_1.QueryKey.Error);
|
|
18
|
-
const errorDescription = uriParameters.get(consts_1.QueryKey.ErrorDescription);
|
|
18
|
+
const error = (0, essentials_1.conditional)(uriParameters.get(consts_1.QueryKey.Error));
|
|
19
|
+
const errorDescription = (0, essentials_1.conditional)(uriParameters.get(consts_1.QueryKey.ErrorDescription));
|
|
19
20
|
if (error) {
|
|
20
|
-
throw new errors_1.LogtoError('callback_uri_verification.error_found',
|
|
21
|
-
error,
|
|
22
|
-
errorDescription,
|
|
23
|
-
});
|
|
21
|
+
throw new errors_1.LogtoError('callback_uri_verification.error_found', new errors_1.OidcError(error, errorDescription));
|
|
24
22
|
}
|
|
25
23
|
const stateFromCallbackUri = uriParameters.get(consts_1.QueryKey.State);
|
|
26
24
|
if (!stateFromCallbackUri) {
|
package/lib/utils/errors.d.ts
CHANGED
|
@@ -25,4 +25,9 @@ export declare class LogtoRequestError extends Error {
|
|
|
25
25
|
code: string;
|
|
26
26
|
constructor(code: string, message: string);
|
|
27
27
|
}
|
|
28
|
+
export declare class OidcError {
|
|
29
|
+
error: string;
|
|
30
|
+
errorDescription?: string;
|
|
31
|
+
constructor(error: string, errorDescription?: string);
|
|
32
|
+
}
|
|
28
33
|
export {};
|
package/lib/utils/errors.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LogtoRequestError = exports.LogtoError = void 0;
|
|
6
|
+
exports.OidcError = exports.LogtoRequestError = exports.LogtoError = void 0;
|
|
7
7
|
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
8
8
|
const logtoErrorCodes = Object.freeze({
|
|
9
9
|
id_token: {
|
|
@@ -45,3 +45,10 @@ class LogtoRequestError extends Error {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
exports.LogtoRequestError = LogtoRequestError;
|
|
48
|
+
class OidcError {
|
|
49
|
+
constructor(error, errorDescription) {
|
|
50
|
+
this.error = error;
|
|
51
|
+
this.errorDescription = errorDescription;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.OidcError = OidcError;
|
package/lib/utils/scopes.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.withReservedScopes = void 0;
|
|
|
6
6
|
* @return scopes should contain all reserved scopes ( Logto requires `openid` and `offline_access` )
|
|
7
7
|
*/
|
|
8
8
|
const withReservedScopes = (originalScopes) => {
|
|
9
|
-
const uniqueScopes = new Set(['openid', 'offline_access', ...(originalScopes ?? [])]);
|
|
9
|
+
const uniqueScopes = new Set(['openid', 'offline_access', 'profile', ...(originalScopes ?? [])]);
|
|
10
10
|
return Array.from(uniqueScopes).join(' ');
|
|
11
11
|
};
|
|
12
12
|
exports.withReservedScopes = withReservedScopes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"exports": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"eslint": "^8.9.0",
|
|
43
43
|
"jest": "^27.5.1",
|
|
44
44
|
"jest-matcher-specific-error": "^1.0.0",
|
|
45
|
-
"lint-staged": "^
|
|
45
|
+
"lint-staged": "^13.0.0",
|
|
46
46
|
"nock": "^13.1.3",
|
|
47
47
|
"node-fetch": "^2.6.7",
|
|
48
48
|
"prettier": "^2.3.2",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "5d05c6bd23dc35d7217031edccc01db2bae33b7b"
|
|
62
62
|
}
|