@logto/js 0.1.1-rc.0
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/LICENSE +373 -0
- package/lib/consts/index.d.ts +30 -0
- package/lib/consts/index.js +33 -0
- package/lib/core/fetch-token.d.ts +36 -0
- package/lib/core/fetch-token.js +103 -0
- package/lib/core/index.d.ts +6 -0
- package/lib/core/index.js +18 -0
- package/lib/core/oidc-config.d.ts +15 -0
- package/lib/core/oidc-config.js +53 -0
- package/lib/core/revoke.d.ts +2 -0
- package/lib/core/revoke.js +54 -0
- package/lib/core/sign-in.d.ts +10 -0
- package/lib/core/sign-in.js +28 -0
- package/lib/core/sign-out.d.ts +7 -0
- package/lib/core/sign-out.js +14 -0
- package/lib/core/user-info.d.ts +5 -0
- package/lib/core/user-info.js +47 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +16 -0
- package/lib/utils/callback-uri.d.ts +2 -0
- package/lib/utils/callback-uri.js +37 -0
- package/lib/utils/errors.d.ts +28 -0
- package/lib/utils/errors.js +68 -0
- package/lib/utils/generators.d.ts +18 -0
- package/lib/utils/generators.js +81 -0
- package/lib/utils/id-token.d.ts +24 -0
- package/lib/utils/id-token.js +101 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +18 -0
- package/lib/utils/requester.d.ts +2 -0
- package/lib/utils/requester.js +69 -0
- package/lib/utils/scopes.d.ts +5 -0
- package/lib/utils/scopes.js +21 -0
- package/package.json +64 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createRequester = void 0;
|
|
40
|
+
var essentials_1 = require("@silverhand/essentials");
|
|
41
|
+
var errors_1 = require("./errors");
|
|
42
|
+
var createRequester = function (fetchFunction) {
|
|
43
|
+
if (!fetchFunction && (0, essentials_1.isNode)()) {
|
|
44
|
+
throw new errors_1.LogtoError('requester.not_provide_fetch');
|
|
45
|
+
}
|
|
46
|
+
return function () {
|
|
47
|
+
var args = [];
|
|
48
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
49
|
+
args[_i] = arguments[_i];
|
|
50
|
+
}
|
|
51
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var response, _a, code, message;
|
|
53
|
+
return __generator(this, function (_b) {
|
|
54
|
+
switch (_b.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, (fetchFunction !== null && fetchFunction !== void 0 ? fetchFunction : fetch).apply(void 0, args)];
|
|
56
|
+
case 1:
|
|
57
|
+
response = _b.sent();
|
|
58
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
59
|
+
return [4 /*yield*/, response.json()];
|
|
60
|
+
case 2:
|
|
61
|
+
_a = _b.sent(), code = _a.code, message = _a.message;
|
|
62
|
+
throw new errors_1.LogtoRequestError(code, message);
|
|
63
|
+
case 3: return [2 /*return*/, response.json()];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
exports.createRequester = createRequester;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.withReservedScopes = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* @param originalScopes
|
|
15
|
+
* @return scopes should contain all reserved scopes ( Logto requires `openid` and `offline_access` )
|
|
16
|
+
*/
|
|
17
|
+
var withReservedScopes = function (originalScopes) {
|
|
18
|
+
var uniqueScopes = new Set(__spreadArray(['openid', 'offline_access'], (originalScopes !== null && originalScopes !== void 0 ? originalScopes : []), true));
|
|
19
|
+
return Array.from(uniqueScopes).join(' ');
|
|
20
|
+
};
|
|
21
|
+
exports.withReservedScopes = withReservedScopes;
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@logto/js",
|
|
3
|
+
"version": "0.1.1-rc.0",
|
|
4
|
+
"main": "./lib/index.js",
|
|
5
|
+
"exports": "./lib/index.js",
|
|
6
|
+
"typings": "./lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
10
|
+
"license": "MPL-2.0",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev:tsc": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
|
|
13
|
+
"preinstall": "npx only-allow pnpm",
|
|
14
|
+
"precommit": "lint-staged",
|
|
15
|
+
"build": "rm -rf lib/ && tsc -p tsconfig.build.json",
|
|
16
|
+
"lint": "eslint --ext .ts src",
|
|
17
|
+
"package": "pnpm build && webpack",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:coverage": "jest --silent --env=jsdom && jest --silent --coverage",
|
|
20
|
+
"prepublish": "pnpm package",
|
|
21
|
+
"report": "WITH_REPORT=true pnpm package",
|
|
22
|
+
"prepack": "pnpm test && pnpm build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@silverhand/essentials": "^1.1.6",
|
|
26
|
+
"camelcase-keys": "^7.0.1",
|
|
27
|
+
"jose": "^4.3.8",
|
|
28
|
+
"js-base64": "^3.7.2",
|
|
29
|
+
"lodash.get": "^4.4.2",
|
|
30
|
+
"superstruct": "^0.15.3"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@jest/types": "^27.5.1",
|
|
34
|
+
"@peculiar/webcrypto": "^1.1.7",
|
|
35
|
+
"@silverhand/eslint-config": "^0.9.1",
|
|
36
|
+
"@silverhand/ts-config": "^0.9.1",
|
|
37
|
+
"@types/jest": "^27.4.1",
|
|
38
|
+
"@types/lodash.get": "^4.4.6",
|
|
39
|
+
"@types/node": "^17.0.19",
|
|
40
|
+
"@types/webpack": "^5.28.0",
|
|
41
|
+
"eslint": "^8.9.0",
|
|
42
|
+
"jest": "^27.5.1",
|
|
43
|
+
"jest-matcher-specific-error": "^1.0.0",
|
|
44
|
+
"lint-staged": "^11.1.2",
|
|
45
|
+
"nock": "^13.1.3",
|
|
46
|
+
"node-fetch": "^2.6.7",
|
|
47
|
+
"prettier": "^2.3.2",
|
|
48
|
+
"text-encoder": "^0.0.4",
|
|
49
|
+
"ts-jest": "^27.0.4",
|
|
50
|
+
"type-fest": "^2.10.0",
|
|
51
|
+
"typescript": "^4.5.5",
|
|
52
|
+
"webpack": "^5.58.2",
|
|
53
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
54
|
+
"webpack-cli": "^4.9.1"
|
|
55
|
+
},
|
|
56
|
+
"eslintConfig": {
|
|
57
|
+
"extends": "@silverhand"
|
|
58
|
+
},
|
|
59
|
+
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"gitHead": "a9e80c6583f48bc56d691e2b837da80cc17aa08a"
|
|
64
|
+
}
|