@arcblock/jwt 1.29.27 → 1.30.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/esm/index.mjs +1 -1
- package/lib/index.cjs +8 -8
- package/package.json +5 -7
package/esm/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { extractMethod, isFromPublicKey, isValid, toDid, toStrictHex, toTypeInfo
|
|
|
2
2
|
import { Hasher, getSigner, types } from "@ocap/mcrypto";
|
|
3
3
|
import { fromBase64, scopeMatchAny, toBase64, toHex } from "@ocap/util";
|
|
4
4
|
import Debug from "debug";
|
|
5
|
-
import stringify from "json-stable-stringify";
|
|
5
|
+
import stringify from "fast-json-stable-stringify";
|
|
6
6
|
|
|
7
7
|
//#region src/index.ts
|
|
8
8
|
const debug = Debug("@arcblock/jwt");
|
package/lib/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
|
4
4
|
let _ocap_util = require("@ocap/util");
|
|
5
5
|
let debug = require("debug");
|
|
6
6
|
debug = require_rolldown_runtime.__toESM(debug);
|
|
7
|
-
let
|
|
8
|
-
|
|
7
|
+
let fast_json_stable_stringify = require("fast-json-stable-stringify");
|
|
8
|
+
fast_json_stable_stringify = require_rolldown_runtime.__toESM(fast_json_stable_stringify);
|
|
9
9
|
|
|
10
10
|
//#region src/index.ts
|
|
11
11
|
const debug$1 = (0, debug.default)("@arcblock/jwt");
|
|
@@ -57,7 +57,7 @@ async function sign(signer, sk, payload = {}, doSign = true, version = "1.0.0")
|
|
|
57
57
|
};
|
|
58
58
|
if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
|
|
59
59
|
const header = headers[type.pk];
|
|
60
|
-
const headerB64 = (0, _ocap_util.toBase64)((0,
|
|
60
|
+
const headerB64 = (0, _ocap_util.toBase64)((0, fast_json_stable_stringify.default)(header));
|
|
61
61
|
const signerMethod = (0, _arcblock_did.extractMethod)(signer) || "abt";
|
|
62
62
|
const now = Math.floor(Date.now() / 1e3);
|
|
63
63
|
const body = {
|
|
@@ -71,7 +71,7 @@ async function sign(signer, sk, payload = {}, doSign = true, version = "1.0.0")
|
|
|
71
71
|
Object.keys(body).forEach((x) => {
|
|
72
72
|
if (typeof body[x] === "undefined" || body[x] == null || body[x] === "") delete body[x];
|
|
73
73
|
});
|
|
74
|
-
const bodyB64 = (0, _ocap_util.toBase64)((0,
|
|
74
|
+
const bodyB64 = (0, _ocap_util.toBase64)((0, fast_json_stable_stringify.default)(body));
|
|
75
75
|
debug$1("sign.body", body);
|
|
76
76
|
const msgHex = (0, _ocap_util.toHex)(`${headerB64}.${bodyB64}`);
|
|
77
77
|
const coercedVersion = coerceVersion(version);
|
|
@@ -254,7 +254,7 @@ async function signDelegationToken(signer, sk, payload) {
|
|
|
254
254
|
const type = (0, _arcblock_did.toTypeInfo)(signer);
|
|
255
255
|
if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
|
|
256
256
|
const header = delegationTokenHeaders[type.pk];
|
|
257
|
-
const headerB64 = (0, _ocap_util.toBase64)((0,
|
|
257
|
+
const headerB64 = (0, _ocap_util.toBase64)((0, fast_json_stable_stringify.default)(header));
|
|
258
258
|
const delegationSignerMethod = (0, _arcblock_did.extractMethod)(signer) || "abt";
|
|
259
259
|
const now = Math.floor(Date.now() / 1e3);
|
|
260
260
|
const body = {
|
|
@@ -272,7 +272,7 @@ async function signDelegationToken(signer, sk, payload) {
|
|
|
272
272
|
body.deny = payload.deny;
|
|
273
273
|
}
|
|
274
274
|
if (payload.delegation) body.delegation = payload.delegation;
|
|
275
|
-
const bodyB64 = (0, _ocap_util.toBase64)((0,
|
|
275
|
+
const bodyB64 = (0, _ocap_util.toBase64)((0, fast_json_stable_stringify.default)(body));
|
|
276
276
|
const msgHash = hasher((0, _ocap_util.toHex)(`${headerB64}.${bodyB64}`));
|
|
277
277
|
return [
|
|
278
278
|
headerB64,
|
|
@@ -289,7 +289,7 @@ async function signDelegationTokenUnsigned(signer, pk, payload) {
|
|
|
289
289
|
const type = (0, _arcblock_did.toTypeInfo)(signer);
|
|
290
290
|
if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
|
|
291
291
|
const header = delegationTokenHeaders[type.pk];
|
|
292
|
-
const headerB64 = (0, _ocap_util.toBase64)((0,
|
|
292
|
+
const headerB64 = (0, _ocap_util.toBase64)((0, fast_json_stable_stringify.default)(header));
|
|
293
293
|
const delegationSignerMethod = (0, _arcblock_did.extractMethod)(signer) || "abt";
|
|
294
294
|
const now = Math.floor(Date.now() / 1e3);
|
|
295
295
|
const pkHex = typeof pk === "string" ? pk : (0, _ocap_util.toHex)(pk);
|
|
@@ -308,7 +308,7 @@ async function signDelegationTokenUnsigned(signer, pk, payload) {
|
|
|
308
308
|
body.deny = payload.deny;
|
|
309
309
|
}
|
|
310
310
|
if (payload.delegation) body.delegation = payload.delegation;
|
|
311
|
-
return `${headerB64}.${(0, _ocap_util.toBase64)((0,
|
|
311
|
+
return `${headerB64}.${(0, _ocap_util.toBase64)((0, fast_json_stable_stringify.default)(body))}`;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* Assemble a complete delegation token from an unsigned token and a passkey assertion.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@arcblock/jwt",
|
|
3
3
|
"description": "JSON Web Token variant for arcblock DID solutions",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.30.1",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "wangshijun",
|
|
8
8
|
"email": "shijun@arcblock.io",
|
|
@@ -19,15 +19,13 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@arcblock/did": "1.
|
|
23
|
-
"@ocap/mcrypto": "1.
|
|
24
|
-
"@ocap/util": "1.
|
|
22
|
+
"@arcblock/did": "1.30.1",
|
|
23
|
+
"@ocap/mcrypto": "1.30.1",
|
|
24
|
+
"@ocap/util": "1.30.1",
|
|
25
25
|
"debug": "^4.4.3",
|
|
26
|
-
"json-stable-stringify": "^1.0
|
|
26
|
+
"fast-json-stable-stringify": "^2.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@ocap/wallet": "1.29.27",
|
|
30
|
-
"@types/json-stable-stringify": "^1.0.36",
|
|
31
29
|
"@types/node": "^22.7.5",
|
|
32
30
|
"tsdown": "^0.18.4",
|
|
33
31
|
"tslib": "^2.4.0"
|