@arcblock/vc 1.30.0 → 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.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { WalletObject } from "@ocap/wallet";
2
- import stringify from "json-stable-stringify";
2
+ import stringify from "fast-json-stable-stringify";
3
3
 
4
4
  //#region src/index.d.ts
5
+
5
6
  interface Proof {
6
7
  type: string;
7
8
  created: string;
package/esm/index.mjs CHANGED
@@ -4,8 +4,8 @@ import { types } from "@ocap/mcrypto";
4
4
  import { fromBase58, fromBase64, toBase58, toBase64 } from "@ocap/util";
5
5
  import { fromPublicKey } from "@ocap/wallet";
6
6
  import Debug from "debug";
7
+ import stringify from "fast-json-stable-stringify";
7
8
  import isAbsoluteUrl from "is-absolute-url";
8
- import stringify from "json-stable-stringify";
9
9
  import cloneDeep from "lodash/cloneDeep.js";
10
10
 
11
11
  //#region src/index.ts
package/lib/index.cjs CHANGED
@@ -6,10 +6,10 @@ let _ocap_util = require("@ocap/util");
6
6
  let _ocap_wallet = require("@ocap/wallet");
7
7
  let debug = require("debug");
8
8
  debug = require_rolldown_runtime.__toESM(debug);
9
+ let fast_json_stable_stringify = require("fast-json-stable-stringify");
10
+ fast_json_stable_stringify = require_rolldown_runtime.__toESM(fast_json_stable_stringify);
9
11
  let is_absolute_url = require("is-absolute-url");
10
12
  is_absolute_url = require_rolldown_runtime.__toESM(is_absolute_url);
11
- let json_stable_stringify = require("json-stable-stringify");
12
- json_stable_stringify = require_rolldown_runtime.__toESM(json_stable_stringify);
13
13
  let lodash_cloneDeep = require("lodash/cloneDeep");
14
14
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
15
15
 
@@ -56,7 +56,7 @@ async function create({ type, subject, issuer, issuanceDate, expirationDate, tag
56
56
  ...typeInfo,
57
57
  role: _ocap_mcrypto.types.RoleType.ROLE_VC
58
58
  };
59
- const vcDid = (0, _arcblock_did.fromPublicKeyHash)(wallet.hash((0, json_stable_stringify.default)(subject)), vcType);
59
+ const vcDid = (0, _arcblock_did.fromPublicKeyHash)(wallet.hash((0, fast_json_stable_stringify.default)(subject)), vcType);
60
60
  const pkType = typeInfo.pk;
61
61
  if (!proofTypes[pkType]) throw new Error("Unsupported signer type when create verifiable credential");
62
62
  const issuanceDateValue = issuanceDate || (/* @__PURE__ */ new Date()).toISOString();
@@ -80,7 +80,7 @@ async function create({ type, subject, issuer, issuanceDate, expirationDate, tag
80
80
  type: "NFTStatusList2021",
81
81
  scope: endpointScope || "public"
82
82
  };
83
- const signature = await wallet.sign((0, json_stable_stringify.default)(vcObj));
83
+ const signature = await wallet.sign((0, fast_json_stable_stringify.default)(vcObj));
84
84
  const result = {
85
85
  proof: {
86
86
  type: proofTypes[pkType],
@@ -140,7 +140,7 @@ async function verify({ vc, ownerDid, trustedIssuers, ignoreExpired = false }) {
140
140
  if (matchingProofs.length !== prevIds.length) throw new Error("Referenced previous proof not found");
141
141
  clone.proof = matchingProofs;
142
142
  } else delete clone.proof;
143
- const signedContent = (0, json_stable_stringify.default)(clone);
143
+ const signedContent = (0, fast_json_stable_stringify.default)(clone);
144
144
  if (await (0, _ocap_wallet.fromPublicKey)(proofPk, (0, _arcblock_did.toTypeInfo)(proofSigner)).verify(signedContent, (0, _ocap_util.fromBase64)(proof.jws)) !== true) throw Error("Verifiable credential signature not valid");
145
145
  }
146
146
  return true;
@@ -183,7 +183,7 @@ async function counterSign({ vc, wallet, mode = "set" }) {
183
183
  const prevIds = proofsWithIds.map((p) => p.id);
184
184
  newProof.previousProof = prevIds.length === 1 ? prevIds[0] : prevIds;
185
185
  } else delete clone.proof;
186
- const signedContent = (0, json_stable_stringify.default)(clone);
186
+ const signedContent = (0, fast_json_stable_stringify.default)(clone);
187
187
  newProof.jws = (0, _ocap_util.toBase64)(await wallet.sign(signedContent));
188
188
  return {
189
189
  ...vc,
@@ -214,7 +214,7 @@ async function verifyPresentation({ presentation, trustedIssuers, challenge, ign
214
214
  const proof = proofList.find((x) => (0, _arcblock_did.isFromPublicKey)(vcObj.credentialSubject.id, x.pk));
215
215
  if (!proof) throw Error(`VC does not have corresponding proof: ${vcStr}`);
216
216
  const signatureStr = proof.jws;
217
- if (await (0, _ocap_wallet.fromPublicKey)((0, _ocap_util.fromBase58)(proof.pk), (0, _arcblock_did.toTypeInfo)(vcObj.credentialSubject.id)).verify((0, json_stable_stringify.default)(clone), (0, _ocap_util.fromBase64)(signatureStr)) !== true) throw Error("Presentation signature invalid");
217
+ if (await (0, _ocap_wallet.fromPublicKey)((0, _ocap_util.fromBase58)(proof.pk), (0, _arcblock_did.toTypeInfo)(vcObj.credentialSubject.id)).verify((0, fast_json_stable_stringify.default)(clone), (0, _ocap_util.fromBase64)(signatureStr)) !== true) throw Error("Presentation signature invalid");
218
218
  await verify({
219
219
  vc: vcObj,
220
220
  ownerDid: vcObj.credentialSubject.id,
@@ -240,14 +240,14 @@ async function createCredentialList({ claims, issuer, issuanceDate }) {
240
240
  const issuerPk = (0, _ocap_util.toBase58)(wallet.publicKey);
241
241
  return await Promise.all(claims.map(async (x) => {
242
242
  const vc = { claim: x };
243
- vc.id = (0, _arcblock_did.fromPublicKeyHash)(wallet.hash((0, json_stable_stringify.default)(vc.claim)), vcType);
243
+ vc.id = (0, _arcblock_did.fromPublicKeyHash)(wallet.hash((0, fast_json_stable_stringify.default)(vc.claim)), vcType);
244
244
  vc.issued = issued;
245
245
  vc.issuer = {
246
246
  id: issuerDid,
247
247
  pk: issuerPk,
248
248
  name: name$1 || issuerDid
249
249
  };
250
- const signature = await wallet.sign((0, json_stable_stringify.default)(vc));
250
+ const signature = await wallet.sign((0, fast_json_stable_stringify.default)(vc));
251
251
  vc.proof = {
252
252
  type: proofTypes[pkType],
253
253
  created: issued,
@@ -271,7 +271,7 @@ async function verifyCredentialList({ credentials, trustedIssuers }) {
271
271
  if (proofList.length === 0 || proofList.some((p) => !p || !p.jws)) throw new Error("Invalid credential proof");
272
272
  const clone = (0, lodash_cloneDeep.default)(x);
273
273
  delete clone.proof;
274
- const signedContent = (0, json_stable_stringify.default)(clone);
274
+ const signedContent = (0, fast_json_stable_stringify.default)(clone);
275
275
  for (const proof of proofList) {
276
276
  const proofPk = proof.pk || x.issuer.pk;
277
277
  const proofSigner = proof.signer || x.issuer.id;
@@ -282,7 +282,7 @@ async function verifyCredentialList({ credentials, trustedIssuers }) {
282
282
  return x.claim;
283
283
  }));
284
284
  }
285
- const stableStringify = json_stable_stringify.default;
285
+ const stableStringify = fast_json_stable_stringify.default;
286
286
 
287
287
  //#endregion
288
288
  exports.counterSign = counterSign;
package/lib/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { WalletObject } from "@ocap/wallet";
2
- import stringify from "json-stable-stringify";
2
+ import stringify from "fast-json-stable-stringify";
3
3
 
4
4
  //#region src/index.d.ts
5
+
5
6
  interface Proof {
6
7
  type: string;
7
8
  created: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/vc",
3
- "version": "1.30.0",
3
+ "version": "1.30.1",
4
4
  "description": "TypeScript lib to work with ArcBlock Verifiable Credentials",
5
5
  "keywords": [
6
6
  "arcblock",
@@ -48,7 +48,6 @@
48
48
  ],
49
49
  "devDependencies": {
50
50
  "@types/debug": "^4.1.12",
51
- "@types/json-stable-stringify": "^1.1.0",
52
51
  "@types/lodash": "^4.17.0"
53
52
  },
54
53
  "repository": {
@@ -72,13 +71,13 @@
72
71
  "url": "https://github.com/ArcBlock/blockchain/issues"
73
72
  },
74
73
  "dependencies": {
75
- "@arcblock/did": "1.30.0",
76
- "@ocap/mcrypto": "1.30.0",
77
- "@ocap/util": "1.30.0",
78
- "@ocap/wallet": "1.30.0",
74
+ "@arcblock/did": "1.30.1",
75
+ "@ocap/mcrypto": "1.30.1",
76
+ "@ocap/util": "1.30.1",
77
+ "@ocap/wallet": "1.30.1",
79
78
  "debug": "^4.4.3",
80
79
  "is-absolute-url": "^3.0.3",
81
- "json-stable-stringify": "^1.0.1",
80
+ "fast-json-stable-stringify": "^2.1.0",
82
81
  "lodash": "^4.17.23"
83
82
  }
84
83
  }