@arcblock/did 1.16.6 → 1.16.9
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 +1 -1
- package/lib/type.d.ts +103 -0
- package/lib/util.d.ts +24 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/prettier/prettier)
|
|
4
4
|
[](https://docs.arcblock.io)
|
|
5
|
-
[](https://gitter.im/ArcBlock/community?utm_source=badge
|
|
5
|
+
[](https://gitter.im/ArcBlock/community?utm_source=badge\&utm_medium=badge\&utm_campaign=pr-badge)
|
|
6
6
|
|
|
7
7
|
> Javascript library to manipulate ArcBlock DID: <https://github.com/ArcBlock/abt-did-spec>
|
|
8
8
|
|
package/lib/type.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structure of a forge wallet type
|
|
3
|
+
*/
|
|
4
|
+
export type DidType = {
|
|
5
|
+
/**
|
|
6
|
+
* - Enum field to identify wallet role type
|
|
7
|
+
*/
|
|
8
|
+
role: number;
|
|
9
|
+
/**
|
|
10
|
+
* - Crypto algorithm to derive publicKey from the secretKey
|
|
11
|
+
*/
|
|
12
|
+
pk: number;
|
|
13
|
+
/**
|
|
14
|
+
* - Hash algorithm used to hash data before sign them
|
|
15
|
+
*/
|
|
16
|
+
hash: number;
|
|
17
|
+
};
|
|
18
|
+
export namespace DID_TYPE_ARCBLOCK {
|
|
19
|
+
const role: any;
|
|
20
|
+
const pk: any;
|
|
21
|
+
const hash: any;
|
|
22
|
+
const address: any;
|
|
23
|
+
}
|
|
24
|
+
export namespace DID_TYPE_ETHEREUM {
|
|
25
|
+
const role_1: any;
|
|
26
|
+
export { role_1 as role };
|
|
27
|
+
const pk_1: any;
|
|
28
|
+
export { pk_1 as pk };
|
|
29
|
+
const hash_1: any;
|
|
30
|
+
export { hash_1 as hash };
|
|
31
|
+
const address_1: any;
|
|
32
|
+
export { address_1 as address };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert type info object to hex string
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @static
|
|
39
|
+
* @param {object} type - wallet type, {@see @arcblock/did#DidType}
|
|
40
|
+
* @returns string
|
|
41
|
+
*/
|
|
42
|
+
export function fromTypeInfo(type: object): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get type info from did (base58 format)
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
* @static
|
|
48
|
+
* @param {string} did - address string
|
|
49
|
+
* @param {boolean} [returnString=true]
|
|
50
|
+
* @returns {object} wallet type {@see @arcblock/did#DidType}
|
|
51
|
+
*/
|
|
52
|
+
export function toTypeInfo(did: string, returnString?: boolean): object;
|
|
53
|
+
export function isEthereumType(type: any): any;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if the given string is an address
|
|
56
|
+
*
|
|
57
|
+
* @method isEthereumDid
|
|
58
|
+
* @param {String} address the given HEX address
|
|
59
|
+
* @return {Boolean}
|
|
60
|
+
*/
|
|
61
|
+
export function isEthereumDid(did: any): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Converts to a checksum address
|
|
64
|
+
*
|
|
65
|
+
* @method toChecksumAddress
|
|
66
|
+
* @param {String} address the given HEX address
|
|
67
|
+
* @return {String}
|
|
68
|
+
*/
|
|
69
|
+
export function toChecksumAddress(address: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* The structure of a forge wallet type
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @static
|
|
75
|
+
* @global
|
|
76
|
+
* @typedef {Object} DidType
|
|
77
|
+
* @prop {number} role - Enum field to identify wallet role type
|
|
78
|
+
* @prop {number} pk - Crypto algorithm to derive publicKey from the secretKey
|
|
79
|
+
* @prop {number} hash - Hash algorithm used to hash data before sign them
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Create an wallet type object that be used as param to create a new wallet
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
* @static
|
|
86
|
+
* @param {DidType|string} [type='default']
|
|
87
|
+
* @returns {object}
|
|
88
|
+
* @example
|
|
89
|
+
* const assert = require('assert');
|
|
90
|
+
* const { DidType } = require('@arcblock/did');
|
|
91
|
+
* const { types } = require('@ocap/mcrypto');
|
|
92
|
+
*
|
|
93
|
+
* const type = DidType({
|
|
94
|
+
* role: types.RoleType.ROLE_APPLICATION,
|
|
95
|
+
* pk: types.KeyType.ED25519,
|
|
96
|
+
* hash: types.HashType.SHA3,
|
|
97
|
+
* });
|
|
98
|
+
*/
|
|
99
|
+
export function DidType(type?: DidType | string): object;
|
|
100
|
+
export namespace DidType {
|
|
101
|
+
function toJSON(type: any): {};
|
|
102
|
+
function fromJSON(json: any): {};
|
|
103
|
+
}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const DID_PREFIX: "did:abt:";
|
|
2
|
+
/**
|
|
3
|
+
* Convert number to bit string with predefined length
|
|
4
|
+
*
|
|
5
|
+
* @param {string} decimal
|
|
6
|
+
* @param {number} length
|
|
7
|
+
* @returns String
|
|
8
|
+
*/
|
|
9
|
+
export function toBits(decimal: string, length: number): any;
|
|
10
|
+
/**
|
|
11
|
+
* Convert did to bytes with length of 26
|
|
12
|
+
*
|
|
13
|
+
* @param {string} did
|
|
14
|
+
* @returns {Buffer}
|
|
15
|
+
*/
|
|
16
|
+
export function toBytes(did: string): Buffer;
|
|
17
|
+
/**
|
|
18
|
+
* Ensure the hex length is even number, 2, 4, 6, 8
|
|
19
|
+
*
|
|
20
|
+
* @param {string} hex
|
|
21
|
+
* @param {number} length
|
|
22
|
+
* @returns {string} hex
|
|
23
|
+
*/
|
|
24
|
+
export function toStrictHex(hex: string, length: number): string;
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.9",
|
|
4
4
|
"description": "Javascript lib to work with ArcBlock DID",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"forge",
|
|
7
6
|
"arcblock",
|
|
8
7
|
"blockchain",
|
|
9
8
|
"did",
|
|
@@ -17,6 +16,9 @@
|
|
|
17
16
|
"email": "shijun@arcblock.io",
|
|
18
17
|
"url": "https://github.com/wangshijun"
|
|
19
18
|
},
|
|
19
|
+
"contributors": [
|
|
20
|
+
"wangshijun <shijun@arcblock.io> (https://github.com/wangshijun)"
|
|
21
|
+
],
|
|
20
22
|
"homepage": "https://github.com/ArcBlock/asset-chain/tree/master/did/did",
|
|
21
23
|
"license": "Apache-2.0",
|
|
22
24
|
"main": "lib/index.js",
|
|
@@ -45,11 +47,11 @@
|
|
|
45
47
|
"url": "https://github.com/ArcBlock/asset-chain/issues"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
|
-
"@ocap/mcrypto": "1.16.
|
|
49
|
-
"@ocap/util": "1.16.
|
|
50
|
+
"@ocap/mcrypto": "1.16.9",
|
|
51
|
+
"@ocap/util": "1.16.9",
|
|
50
52
|
"bn.js": "^5.2.0",
|
|
51
53
|
"debug": "^4.3.3",
|
|
52
54
|
"lodash": "^4.17.21"
|
|
53
55
|
},
|
|
54
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "16fb7ce43033d07f83794914f2d5dda731f80814"
|
|
55
57
|
}
|