@arcblock/did 1.28.5 → 1.28.7

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  ## Usage
10
10
 
11
11
  ```terminal
12
- pnpm install @ocap/mcrypto @arcblock/did
12
+ bun install @ocap/mcrypto @arcblock/did
13
13
  ```
14
14
 
15
15
  ```javascript
package/esm/type.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { toBits, toBytes, toStrictHex } from "./util.mjs";
2
2
  import { Hasher, types } from "@ocap/mcrypto";
3
3
  import { BN, isHex, numberToHex, stripHexPrefix, toAddress } from "@ocap/util";
4
- import upperFirst from "lodash/upperFirst.js";
5
4
  import isEqual from "lodash/isEqual.js";
6
5
  import pick from "lodash/pick.js";
6
+ import upperFirst from "lodash/upperFirst.js";
7
7
 
8
8
  //#region src/type.ts
9
9
  const mapping = {
@@ -59,7 +59,7 @@ const isEthereumDid = (did) => {
59
59
  const checkAddressChecksum = (address) => {
60
60
  const origin = address.replace(/^0x/i, "");
61
61
  const addressHash = Hasher.Keccak.hash256(origin.toLowerCase()).replace(/^0x/i, "");
62
- for (let i = 0; i < 40; i++) if (parseInt(addressHash[i], 16) > 7 && origin[i].toUpperCase() !== origin[i] || parseInt(addressHash[i], 16) <= 7 && origin[i].toLowerCase() !== origin[i]) return false;
62
+ for (let i = 0; i < 40; i++) if (Number.parseInt(addressHash[i], 16) > 7 && origin[i].toUpperCase() !== origin[i] || Number.parseInt(addressHash[i], 16) <= 7 && origin[i].toLowerCase() !== origin[i]) return false;
63
63
  return true;
64
64
  };
65
65
  /**
@@ -75,7 +75,7 @@ const toChecksumAddress = (address) => {
75
75
  const lower = address.toLowerCase().replace(/^0x/i, "");
76
76
  const addressHash = Hasher.Keccak.hash256(lower).replace(/^0x/i, "");
77
77
  let checksumAddress = "0x";
78
- for (let i = 0; i < lower.length; i++) if (parseInt(addressHash[i], 16) > 7) checksumAddress += lower[i].toUpperCase();
78
+ for (let i = 0; i < lower.length; i++) if (Number.parseInt(addressHash[i], 16) > 7) checksumAddress += lower[i].toUpperCase();
79
79
  else checksumAddress += lower[i];
80
80
  return checksumAddress;
81
81
  };
@@ -134,7 +134,7 @@ DidType.fromJSON = (json) => Object.keys(json).reduce((acc, x) => {
134
134
  const fromTypeInfo = (type) => {
135
135
  const info = DidType(type);
136
136
  const infoBits = `${toBits(info.role, 6)}${toBits(info.pk, 5)}${toBits(info.hash, 5)}`;
137
- return toStrictHex(stripHexPrefix(numberToHex(parseInt(infoBits, 2))), 4);
137
+ return toStrictHex(stripHexPrefix(numberToHex(Number.parseInt(infoBits, 2))), 4);
138
138
  };
139
139
  /**
140
140
  * Get type info from did
@@ -150,9 +150,9 @@ const toTypeInfo = (did) => {
150
150
  const keyBits = typeBits.slice(6, 11);
151
151
  const hashBits = typeBits.slice(11, 16);
152
152
  type = {
153
- role: parseInt(roleBits, 2),
154
- pk: parseInt(keyBits, 2),
155
- hash: parseInt(hashBits, 2),
153
+ role: Number.parseInt(roleBits, 2),
154
+ pk: Number.parseInt(keyBits, 2),
155
+ hash: Number.parseInt(hashBits, 2),
156
156
  address: isHex(toAddress(did)) ? types.EncodingType.BASE16 : types.EncodingType.BASE58
157
157
  };
158
158
  }
package/lib/type.cjs CHANGED
@@ -2,12 +2,12 @@ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_util = require('./util.cjs');
3
3
  let _ocap_mcrypto = require("@ocap/mcrypto");
4
4
  let _ocap_util = require("@ocap/util");
5
- let lodash_upperFirst = require("lodash/upperFirst");
6
- lodash_upperFirst = require_rolldown_runtime.__toESM(lodash_upperFirst);
7
5
  let lodash_isEqual = require("lodash/isEqual");
8
6
  lodash_isEqual = require_rolldown_runtime.__toESM(lodash_isEqual);
9
7
  let lodash_pick = require("lodash/pick");
10
8
  lodash_pick = require_rolldown_runtime.__toESM(lodash_pick);
9
+ let lodash_upperFirst = require("lodash/upperFirst");
10
+ lodash_upperFirst = require_rolldown_runtime.__toESM(lodash_upperFirst);
11
11
 
12
12
  //#region src/type.ts
13
13
  const mapping = {
@@ -63,7 +63,7 @@ const isEthereumDid = (did) => {
63
63
  const checkAddressChecksum = (address) => {
64
64
  const origin = address.replace(/^0x/i, "");
65
65
  const addressHash = _ocap_mcrypto.Hasher.Keccak.hash256(origin.toLowerCase()).replace(/^0x/i, "");
66
- for (let i = 0; i < 40; i++) if (parseInt(addressHash[i], 16) > 7 && origin[i].toUpperCase() !== origin[i] || parseInt(addressHash[i], 16) <= 7 && origin[i].toLowerCase() !== origin[i]) return false;
66
+ for (let i = 0; i < 40; i++) if (Number.parseInt(addressHash[i], 16) > 7 && origin[i].toUpperCase() !== origin[i] || Number.parseInt(addressHash[i], 16) <= 7 && origin[i].toLowerCase() !== origin[i]) return false;
67
67
  return true;
68
68
  };
69
69
  /**
@@ -79,7 +79,7 @@ const toChecksumAddress = (address) => {
79
79
  const lower = address.toLowerCase().replace(/^0x/i, "");
80
80
  const addressHash = _ocap_mcrypto.Hasher.Keccak.hash256(lower).replace(/^0x/i, "");
81
81
  let checksumAddress = "0x";
82
- for (let i = 0; i < lower.length; i++) if (parseInt(addressHash[i], 16) > 7) checksumAddress += lower[i].toUpperCase();
82
+ for (let i = 0; i < lower.length; i++) if (Number.parseInt(addressHash[i], 16) > 7) checksumAddress += lower[i].toUpperCase();
83
83
  else checksumAddress += lower[i];
84
84
  return checksumAddress;
85
85
  };
@@ -138,7 +138,7 @@ DidType.fromJSON = (json) => Object.keys(json).reduce((acc, x) => {
138
138
  const fromTypeInfo = (type) => {
139
139
  const info = DidType(type);
140
140
  const infoBits = `${require_util.toBits(info.role, 6)}${require_util.toBits(info.pk, 5)}${require_util.toBits(info.hash, 5)}`;
141
- return require_util.toStrictHex((0, _ocap_util.stripHexPrefix)((0, _ocap_util.numberToHex)(parseInt(infoBits, 2))), 4);
141
+ return require_util.toStrictHex((0, _ocap_util.stripHexPrefix)((0, _ocap_util.numberToHex)(Number.parseInt(infoBits, 2))), 4);
142
142
  };
143
143
  /**
144
144
  * Get type info from did
@@ -154,9 +154,9 @@ const toTypeInfo = (did) => {
154
154
  const keyBits = typeBits.slice(6, 11);
155
155
  const hashBits = typeBits.slice(11, 16);
156
156
  type = {
157
- role: parseInt(roleBits, 2),
158
- pk: parseInt(keyBits, 2),
159
- hash: parseInt(hashBits, 2),
157
+ role: Number.parseInt(roleBits, 2),
158
+ pk: Number.parseInt(keyBits, 2),
159
+ hash: Number.parseInt(hashBits, 2),
160
160
  address: (0, _ocap_util.isHex)((0, _ocap_util.toAddress)(did)) ? _ocap_mcrypto.types.EncodingType.BASE16 : _ocap_mcrypto.types.EncodingType.BASE58
161
161
  };
162
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/did",
3
- "version": "1.28.5",
3
+ "version": "1.28.7",
4
4
  "type": "module",
5
5
  "description": "Javascript lib to work with ArcBlock DID",
6
6
  "keywords": [
@@ -48,12 +48,7 @@
48
48
  "esm"
49
49
  ],
50
50
  "devDependencies": {
51
- "@arcblock/eslint-config-ts": "0.3.3",
52
- "@types/jest": "^29.5.13",
53
51
  "@types/node": "^22.7.5",
54
- "eslint": "^8.57.0",
55
- "jest": "^29.7.0",
56
- "ts-jest": "^29.2.5",
57
52
  "tsdown": "^0.18.4",
58
53
  "type-fest": "^3.1.0",
59
54
  "typescript": "^5.6.2"
@@ -62,22 +57,22 @@
62
57
  "type": "git",
63
58
  "url": "git+https://github.com/ArcBlock/blockchain.git"
64
59
  },
60
+ "scripts": {
61
+ "lint": "biome check",
62
+ "lint:fix": "biome check --write",
63
+ "test": "bun test",
64
+ "coverage": "npm run test -- --coverage",
65
+ "build": "tsdown",
66
+ "build:watch": "tsdown -w"
67
+ },
65
68
  "bugs": {
66
69
  "url": "https://github.com/ArcBlock/blockchain/issues"
67
70
  },
68
71
  "dependencies": {
69
- "bn.js": "^5.2.1",
72
+ "@ocap/mcrypto": "1.28.7",
73
+ "@ocap/util": "1.28.7",
74
+ "bn.js": "5.2.2",
70
75
  "debug": "^4.3.6",
71
- "lodash": "^4.17.21",
72
- "@ocap/mcrypto": "1.28.5",
73
- "@ocap/util": "1.28.5"
74
- },
75
- "scripts": {
76
- "lint": "eslint src tests",
77
- "lint:fix": "npm run lint -- --fix",
78
- "test": "jest --forceExit --detectOpenHandles",
79
- "coverage": "npm run test -- --coverage",
80
- "build": "tsdown",
81
- "build:watch": "tsdown -w"
76
+ "lodash": "^4.17.21"
82
77
  }
83
- }
78
+ }