@logto/js 0.1.5 → 0.1.11
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.
|
@@ -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) => {
|
|
@@ -8,18 +9,16 @@ const parseUriParameters = (uri) => {
|
|
|
8
9
|
return new URLSearchParams(queryString);
|
|
9
10
|
};
|
|
10
11
|
exports.parseUriParameters = parseUriParameters;
|
|
12
|
+
// eslint-disable-next-line complexity
|
|
11
13
|
const verifyAndParseCodeFromCallbackUri = (callbackUri, redirectUri, state) => {
|
|
12
14
|
if (!callbackUri.startsWith(redirectUri)) {
|
|
13
15
|
throw new errors_1.LogtoError('callback_uri_verification.redirect_uri_mismatched');
|
|
14
16
|
}
|
|
15
17
|
const uriParameters = (0, exports.parseUriParameters)(callbackUri);
|
|
16
|
-
const error = uriParameters.get(consts_1.QueryKey.Error);
|
|
17
|
-
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));
|
|
18
20
|
if (error) {
|
|
19
|
-
throw new errors_1.LogtoError('callback_uri_verification.error_found',
|
|
20
|
-
error,
|
|
21
|
-
errorDescription,
|
|
22
|
-
});
|
|
21
|
+
throw new errors_1.LogtoError('callback_uri_verification.error_found', new errors_1.OidcError(error, errorDescription));
|
|
23
22
|
}
|
|
24
23
|
const stateFromCallbackUri = uriParameters.get(consts_1.QueryKey.State);
|
|
25
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"exports": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jest/types": "^27.5.1",
|
|
36
36
|
"@peculiar/webcrypto": "^1.1.7",
|
|
37
|
-
"@silverhand/eslint-config": "^0.
|
|
38
|
-
"@silverhand/ts-config": "^0.
|
|
37
|
+
"@silverhand/eslint-config": "^0.14.0",
|
|
38
|
+
"@silverhand/ts-config": "^0.14.0",
|
|
39
39
|
"@types/jest": "^27.4.1",
|
|
40
40
|
"@types/lodash.get": "^4.4.6",
|
|
41
41
|
"@types/node": "^17.0.19",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "fb6df238f56049607af2c3b88bee07ba2aa45dae"
|
|
62
62
|
}
|