@arcblock/did 1.28.8 → 1.29.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/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  ![DID](https://www.arcblock.io/.netlify/functions/badge/?text=DID)
2
2
 
3
- [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
4
3
  [![docs](https://img.shields.io/badge/powered%20by-arcblock-green.svg)](https://docs.arcblock.io)
5
4
  [![Gitter](https://badges.gitter.im/ArcBlock/community.svg)](https://gitter.im/ArcBlock/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6
5
 
package/esm/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from "./type.mjs";
1
+ import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from "./type.mjs";
2
2
  import { DID_PREFIX, toStrictHex } from "./util.mjs";
3
3
  import { types } from "@ocap/mcrypto";
4
4
  import { BytesType, toAddress, toDid } from "@ocap/util";
@@ -58,4 +58,4 @@ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean;
58
58
  */
59
59
  declare const isValid: (did: string) => boolean;
60
60
  //#endregion
61
- export { type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, isEthereumDid, isEthereumType, isFromPublicKey, isValid, toAddress, toDid, toStrictHex, toTypeInfo, toTypeInfoStr, types };
61
+ export { type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, type RequiredDIDType, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, isEthereumDid, isEthereumType, isFromPublicKey, isValid, toAddress, toDid, toStrictHex, toTypeInfo, toTypeInfoStr, types };
package/esm/index.mjs CHANGED
@@ -87,8 +87,8 @@ const isValid = (did) => {
87
87
  if (isEthereumDid(address)) return true;
88
88
  const hashFn = getHasher(hash);
89
89
  const bytes = toBytes(address);
90
- const bytesHex = toStrictHex(Buffer.from(bytes.slice(0, 22)).toString("hex"));
91
- return toStrictHex(Buffer.from(bytes.slice(22, 26)).toString("hex")) === stripHexPrefix(hashFn(`0x${bytesHex}`, 1)).slice(0, 8);
90
+ const bytesHex = toStrictHex(Buffer.from(Uint8Array.from(bytes.slice(0, 22))).toString("hex"));
91
+ return toStrictHex(Buffer.from(Uint8Array.from(bytes.slice(22, 26))).toString("hex")) === stripHexPrefix(hashFn(`0x${bytesHex}`, 1)).slice(0, 8);
92
92
  };
93
93
 
94
94
  //#endregion
package/esm/type.d.mts CHANGED
@@ -4,6 +4,12 @@ import { LiteralUnion } from "type-fest";
4
4
  type DIDTypeKey = LiteralUnion<'role' | 'pk' | 'hash' | 'address', string>;
5
5
  type DIDTypeShortcut = LiteralUnion<'default' | 'arcblock' | 'eth' | 'ethereum' | 'passkey', string>;
6
6
  type DIDType = { [key in DIDTypeKey]?: number };
7
+ type RequiredDIDType = {
8
+ role: number;
9
+ pk: number;
10
+ hash: number;
11
+ address: number;
12
+ };
7
13
  type DIDTypeStr = { [key in DIDTypeKey]?: string };
8
14
  type DIDTypeArg = DIDTypeShortcut | DIDType;
9
15
  declare const DID_TYPE_ARCBLOCK: DIDType;
@@ -29,9 +35,9 @@ declare const toChecksumAddress: (address: string) => string;
29
35
  /**
30
36
  * Create an wallet type object that be used as param to create a new wallet
31
37
  */
32
- declare function DidType(type?: DIDTypeArg): DIDType;
38
+ declare function DidType(type?: DIDTypeArg): RequiredDIDType;
33
39
  declare namespace DidType {
34
- var toJSON: (type: DIDType) => DIDTypeStr;
40
+ var toJSON: (type: RequiredDIDType) => DIDTypeStr;
35
41
  var fromJSON: (json: DIDTypeStr) => DIDType;
36
42
  }
37
43
  /**
@@ -49,4 +55,4 @@ declare const fromTypeInfo: (type: DIDTypeArg) => string;
49
55
  declare const toTypeInfo: (did: string) => DIDType;
50
56
  declare const toTypeInfoStr: (did: string) => DIDTypeStr;
51
57
  //#endregion
52
- export { DIDType, DIDTypeArg, DIDTypeKey, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr };
58
+ export { DIDType, DIDTypeArg, DIDTypeKey, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr };
package/esm/type.mjs CHANGED
@@ -145,7 +145,7 @@ const toTypeInfo = (did) => {
145
145
  if (isEthereumDid(did)) type = DID_TYPE_ETHEREUM;
146
146
  else {
147
147
  const typeBytes = toBytes(did).slice(0, 2);
148
- const typeBits = toBits(new BN(toStrictHex(Buffer.from(typeBytes).toString("hex")), 16), 16);
148
+ const typeBits = toBits(new BN(toStrictHex(Buffer.from(Uint8Array.from(typeBytes)).toString("hex")), 16), 16);
149
149
  const roleBits = typeBits.slice(0, 6);
150
150
  const keyBits = typeBits.slice(6, 11);
151
151
  const hashBits = typeBits.slice(11, 16);
package/esm/util.d.mts CHANGED
@@ -8,7 +8,7 @@ declare const DID_PREFIX = "did:abt:";
8
8
  * @param {string} did
9
9
  * @returns {Buffer}
10
10
  */
11
- declare const toBytes: (did: string) => Buffer;
11
+ declare const toBytes: (did: string) => any;
12
12
  /**
13
13
  * Convert number to bit string with predefined length
14
14
  */
package/esm/util.mjs CHANGED
@@ -13,7 +13,7 @@ const toBytes = (did) => {
13
13
  try {
14
14
  if (isHexStrict(did)) return Buffer.from(stripHexPrefix(did), "hex");
15
15
  let bytes = fromBase58(did.replace(DID_PREFIX, ""));
16
- while (bytes.length < 26) bytes = Buffer.concat([Buffer.from([0]), bytes]);
16
+ while (bytes.length < 26) bytes = Buffer.concat([Uint8Array.from([0]), Uint8Array.from(bytes)]);
17
17
  return bytes;
18
18
  } catch (err) {
19
19
  throw new Error(`Cannot convert DID string to byte array: ${err.message}`);
package/lib/index.cjs CHANGED
@@ -88,8 +88,8 @@ const isValid = (did) => {
88
88
  if (require_type.isEthereumDid(address)) return true;
89
89
  const hashFn = (0, _ocap_mcrypto.getHasher)(hash);
90
90
  const bytes = require_util.toBytes(address);
91
- const bytesHex = require_util.toStrictHex(Buffer.from(bytes.slice(0, 22)).toString("hex"));
92
- return require_util.toStrictHex(Buffer.from(bytes.slice(22, 26)).toString("hex")) === (0, _ocap_util.stripHexPrefix)(hashFn(`0x${bytesHex}`, 1)).slice(0, 8);
91
+ const bytesHex = require_util.toStrictHex(Buffer.from(Uint8Array.from(bytes.slice(0, 22))).toString("hex"));
92
+ return require_util.toStrictHex(Buffer.from(Uint8Array.from(bytes.slice(22, 26))).toString("hex")) === (0, _ocap_util.stripHexPrefix)(hashFn(`0x${bytesHex}`, 1)).slice(0, 8);
93
93
  };
94
94
 
95
95
  //#endregion
package/lib/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from "./type.cjs";
1
+ import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from "./type.cjs";
2
2
  import { DID_PREFIX, toStrictHex } from "./util.cjs";
3
3
  import { types } from "@ocap/mcrypto";
4
4
  import { BytesType, toAddress, toDid } from "@ocap/util";
@@ -58,4 +58,4 @@ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean;
58
58
  */
59
59
  declare const isValid: (did: string) => boolean;
60
60
  //#endregion
61
- export { type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, isEthereumDid, isEthereumType, isFromPublicKey, isValid, toAddress, toDid, toStrictHex, toTypeInfo, toTypeInfoStr, types };
61
+ export { type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, type RequiredDIDType, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, isEthereumDid, isEthereumType, isFromPublicKey, isValid, toAddress, toDid, toStrictHex, toTypeInfo, toTypeInfoStr, types };
package/lib/type.cjs CHANGED
@@ -149,7 +149,7 @@ const toTypeInfo = (did) => {
149
149
  if (isEthereumDid(did)) type = DID_TYPE_ETHEREUM;
150
150
  else {
151
151
  const typeBytes = require_util.toBytes(did).slice(0, 2);
152
- const typeBits = require_util.toBits(new _ocap_util.BN(require_util.toStrictHex(Buffer.from(typeBytes).toString("hex")), 16), 16);
152
+ const typeBits = require_util.toBits(new _ocap_util.BN(require_util.toStrictHex(Buffer.from(Uint8Array.from(typeBytes)).toString("hex")), 16), 16);
153
153
  const roleBits = typeBits.slice(0, 6);
154
154
  const keyBits = typeBits.slice(6, 11);
155
155
  const hashBits = typeBits.slice(11, 16);
package/lib/type.d.cts CHANGED
@@ -4,6 +4,12 @@ import { LiteralUnion } from "type-fest";
4
4
  type DIDTypeKey = LiteralUnion<'role' | 'pk' | 'hash' | 'address', string>;
5
5
  type DIDTypeShortcut = LiteralUnion<'default' | 'arcblock' | 'eth' | 'ethereum' | 'passkey', string>;
6
6
  type DIDType = { [key in DIDTypeKey]?: number };
7
+ type RequiredDIDType = {
8
+ role: number;
9
+ pk: number;
10
+ hash: number;
11
+ address: number;
12
+ };
7
13
  type DIDTypeStr = { [key in DIDTypeKey]?: string };
8
14
  type DIDTypeArg = DIDTypeShortcut | DIDType;
9
15
  declare const DID_TYPE_ARCBLOCK: DIDType;
@@ -29,9 +35,9 @@ declare const toChecksumAddress: (address: string) => string;
29
35
  /**
30
36
  * Create an wallet type object that be used as param to create a new wallet
31
37
  */
32
- declare function DidType(type?: DIDTypeArg): DIDType;
38
+ declare function DidType(type?: DIDTypeArg): RequiredDIDType;
33
39
  declare namespace DidType {
34
- var toJSON: (type: DIDType) => DIDTypeStr;
40
+ var toJSON: (type: RequiredDIDType) => DIDTypeStr;
35
41
  var fromJSON: (json: DIDTypeStr) => DIDType;
36
42
  }
37
43
  /**
@@ -49,4 +55,4 @@ declare const fromTypeInfo: (type: DIDTypeArg) => string;
49
55
  declare const toTypeInfo: (did: string) => DIDType;
50
56
  declare const toTypeInfoStr: (did: string) => DIDTypeStr;
51
57
  //#endregion
52
- export { DIDType, DIDTypeArg, DIDTypeKey, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr };
58
+ export { DIDType, DIDTypeArg, DIDTypeKey, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr };
package/lib/util.cjs CHANGED
@@ -15,7 +15,7 @@ const toBytes = (did) => {
15
15
  try {
16
16
  if ((0, _ocap_util.isHexStrict)(did)) return Buffer.from((0, _ocap_util.stripHexPrefix)(did), "hex");
17
17
  let bytes = (0, _ocap_util.fromBase58)(did.replace(DID_PREFIX, ""));
18
- while (bytes.length < 26) bytes = Buffer.concat([Buffer.from([0]), bytes]);
18
+ while (bytes.length < 26) bytes = Buffer.concat([Uint8Array.from([0]), Uint8Array.from(bytes)]);
19
19
  return bytes;
20
20
  } catch (err) {
21
21
  throw new Error(`Cannot convert DID string to byte array: ${err.message}`);
package/lib/util.d.cts CHANGED
@@ -8,7 +8,7 @@ declare const DID_PREFIX = "did:abt:";
8
8
  * @param {string} did
9
9
  * @returns {Buffer}
10
10
  */
11
- declare const toBytes: (did: string) => Buffer;
11
+ declare const toBytes: (did: string) => any;
12
12
  /**
13
13
  * Convert number to bit string with predefined length
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/did",
3
- "version": "1.28.8",
3
+ "version": "1.29.0",
4
4
  "type": "module",
5
5
  "description": "Javascript lib to work with ArcBlock DID",
6
6
  "keywords": [
@@ -50,8 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.7.5",
52
52
  "tsdown": "^0.18.4",
53
- "type-fest": "^3.1.0",
54
- "typescript": "^5.6.2"
53
+ "type-fest": "^3.1.0"
55
54
  },
56
55
  "repository": {
57
56
  "type": "git",
@@ -69,10 +68,10 @@
69
68
  "url": "https://github.com/ArcBlock/blockchain/issues"
70
69
  },
71
70
  "dependencies": {
72
- "@ocap/mcrypto": "1.28.8",
73
- "@ocap/util": "1.28.8",
71
+ "@ocap/mcrypto": "1.29.0",
72
+ "@ocap/util": "1.29.0",
74
73
  "bn.js": "5.2.2",
75
- "debug": "^4.3.6",
76
- "lodash": "^4.17.21"
74
+ "debug": "^4.4.3",
75
+ "lodash": "^4.17.23"
77
76
  }
78
77
  }