@arcblock/did 1.17.0 → 1.17.3
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/lib/index.d.ts +2 -2
- package/lib/type.d.ts +7 -12
- package/lib/type.js +2 -6
- package/lib/util.d.ts +1 -1
- package/package.json +6 -5
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { types } from '@ocap/mcrypto';
|
|
2
2
|
import { toAddress, toDid, BytesType } from '@ocap/util';
|
|
3
|
-
import { DidType, DIDType, DIDTypeStr, DIDTypeArg, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from './type';
|
|
3
|
+
import { DidType, DIDType, DIDTypeShortcut, DIDTypeStr, DIDTypeArg, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from './type';
|
|
4
4
|
import { toStrictHex } from './util';
|
|
5
5
|
/**
|
|
6
6
|
* Gen DID from private key and type config
|
|
@@ -54,4 +54,4 @@ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean;
|
|
|
54
54
|
* @returns {boolean}
|
|
55
55
|
*/
|
|
56
56
|
declare const isValid: (did: string) => boolean;
|
|
57
|
-
export { DIDType, DIDTypeStr, DIDTypeArg, types, toStrictHex, fromSecretKey, fromPublicKey, fromPublicKeyHash, fromHash, toAddress, toDid, isFromPublicKey, isValid, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr, fromTypeInfo, DidType, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, };
|
|
57
|
+
export { DIDType, DIDTypeStr, DIDTypeArg, DIDTypeShortcut, types, toStrictHex, fromSecretKey, fromPublicKey, fromPublicKeyHash, fromHash, toAddress, toDid, isFromPublicKey, isValid, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr, fromTypeInfo, DidType, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, };
|
package/lib/type.d.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
export declare type DIDTypeKey = LiteralUnion<'role' | 'pk' | 'hash' | 'address', string>;
|
|
3
|
+
export declare type DIDTypeShortcut = LiteralUnion<'default' | 'arcblock' | 'eth' | 'ethereum', string>;
|
|
1
4
|
export declare type DIDType = {
|
|
2
|
-
|
|
3
|
-
pk?: number;
|
|
4
|
-
hash?: number;
|
|
5
|
-
address?: number;
|
|
6
|
-
[key: string]: number;
|
|
5
|
+
[key in DIDTypeKey]?: number;
|
|
7
6
|
};
|
|
8
7
|
export declare type DIDTypeStr = {
|
|
9
|
-
|
|
10
|
-
pk?: string;
|
|
11
|
-
hash?: string;
|
|
12
|
-
address?: string;
|
|
13
|
-
[key: string]: string;
|
|
8
|
+
[key in DIDTypeKey]?: string;
|
|
14
9
|
};
|
|
15
|
-
export declare type DIDTypeArg =
|
|
10
|
+
export declare type DIDTypeArg = DIDTypeShortcut | DIDType;
|
|
16
11
|
declare const DID_TYPE_ARCBLOCK: DIDType;
|
|
17
12
|
declare const DID_TYPE_ETHEREUM: DIDType;
|
|
18
|
-
declare const isEthereumType: (type: DIDType) =>
|
|
13
|
+
declare const isEthereumType: (type: DIDType) => any;
|
|
19
14
|
/**
|
|
20
15
|
* Checks if the given string is an address
|
|
21
16
|
*
|
package/lib/type.js
CHANGED
|
@@ -109,8 +109,8 @@ exports.toChecksumAddress = toChecksumAddress;
|
|
|
109
109
|
* Create an wallet type object that be used as param to create a new wallet
|
|
110
110
|
*/
|
|
111
111
|
function DidType(type = {}) {
|
|
112
|
-
let input =
|
|
113
|
-
if (['default', '
|
|
112
|
+
let input = {};
|
|
113
|
+
if (['default', 'arcblock'].includes(type)) {
|
|
114
114
|
input = DID_TYPE_ARCBLOCK;
|
|
115
115
|
}
|
|
116
116
|
else if (['eth', 'ethereum'].includes(type)) {
|
|
@@ -121,11 +121,9 @@ function DidType(type = {}) {
|
|
|
121
121
|
}
|
|
122
122
|
const { role, pk, hash, address } = input;
|
|
123
123
|
Object.keys(input).forEach((x) => {
|
|
124
|
-
// @ts-ignore
|
|
125
124
|
const key = (0, upperFirst_1.default)(`${mapping[x] || x}Type`);
|
|
126
125
|
// @ts-ignore
|
|
127
126
|
if (Object.values(mcrypto_1.types[key]).includes(input[x]) === false) {
|
|
128
|
-
// @ts-ignore
|
|
129
127
|
throw new Error(`Unsupported ${x} type: ${input[x]}`);
|
|
130
128
|
}
|
|
131
129
|
});
|
|
@@ -146,7 +144,6 @@ function DidType(type = {}) {
|
|
|
146
144
|
}
|
|
147
145
|
exports.DidType = DidType;
|
|
148
146
|
DidType.toJSON = (type) => Object.keys(type).reduce((acc, x) => {
|
|
149
|
-
// @ts-ignore
|
|
150
147
|
const key = (0, upperFirst_1.default)(`${mapping[x] || x}Type`);
|
|
151
148
|
// @ts-ignore
|
|
152
149
|
const typeStr = Object.keys(mcrypto_1.types[key]);
|
|
@@ -157,7 +154,6 @@ DidType.toJSON = (type) => Object.keys(type).reduce((acc, x) => {
|
|
|
157
154
|
return acc;
|
|
158
155
|
}, {});
|
|
159
156
|
DidType.fromJSON = (json) => Object.keys(json).reduce((acc, x) => {
|
|
160
|
-
// @ts-ignore
|
|
161
157
|
const key = (0, upperFirst_1.default)(`${mapping[x] || x}Type`);
|
|
162
158
|
// @ts-ignore
|
|
163
159
|
const typeStr = Object.keys(mcrypto_1.types[key]);
|
package/lib/util.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ declare const toBits: (number: string | number | BN, length: number) => string;
|
|
|
19
19
|
* @param {number} length
|
|
20
20
|
* @returns {string} hex
|
|
21
21
|
*/
|
|
22
|
-
declare const toStrictHex: (hex: string, length?: number) =>
|
|
22
|
+
declare const toStrictHex: (hex: string, length?: number) => any;
|
|
23
23
|
export { DID_PREFIX, toBits, toBytes, toStrictHex };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.3",
|
|
4
4
|
"description": "Javascript lib to work with ArcBlock DID",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arcblock",
|
|
@@ -53,11 +53,12 @@
|
|
|
53
53
|
"url": "https://github.com/ArcBlock/asset-chain/issues"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@ocap/mcrypto": "1.17.
|
|
57
|
-
"@ocap/util": "1.17.
|
|
56
|
+
"@ocap/mcrypto": "1.17.3",
|
|
57
|
+
"@ocap/util": "1.17.3",
|
|
58
58
|
"bn.js": "^5.2.1",
|
|
59
59
|
"debug": "^4.3.4",
|
|
60
|
-
"lodash": "^4.17.21"
|
|
60
|
+
"lodash": "^4.17.21",
|
|
61
|
+
"type-fest": "^2.13.1"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "7a74e4e2b362a6e6ea8d14617f0480966c3363d5"
|
|
63
64
|
}
|