@arcblock/did 1.27.16 → 1.28.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.ts +9 -5
- package/esm/index.js +78 -106
- package/esm/lodash.d.ts +4 -0
- package/esm/type.d.ts +13 -14
- package/esm/type.js +143 -194
- package/esm/util.d.ts +6 -3
- package/esm/util.js +33 -38
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/index.d.ts +9 -5
- package/lib/index.js +98 -128
- package/lib/lodash.d.ts +4 -0
- package/lib/type.d.ts +13 -14
- package/lib/type.js +156 -209
- package/lib/util.d.ts +6 -3
- package/lib/util.js +38 -47
- package/package.json +21 -10
package/esm/util.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { BN } from
|
|
1
|
+
import { BN } from "@ocap/util";
|
|
2
|
+
|
|
3
|
+
//#region src/util.d.ts
|
|
2
4
|
declare const DID_PREFIX = "did:abt:";
|
|
3
5
|
/**
|
|
4
6
|
* Convert did to bytes with length of 26
|
|
@@ -18,5 +20,6 @@ declare const toBits: (number: string | number | BN, length: number) => string;
|
|
|
18
20
|
* @param {number} length
|
|
19
21
|
* @returns {string} hex
|
|
20
22
|
*/
|
|
21
|
-
declare const toStrictHex: (hex: string, length?: number) =>
|
|
22
|
-
|
|
23
|
+
declare const toStrictHex: (hex: string, length?: number) => string;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { DID_PREFIX, toBits, toBytes, toStrictHex };
|
package/esm/util.js
CHANGED
|
@@ -1,45 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import padStart from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { fromBase58, isHexStrict, stripHexPrefix, toBN } from "@ocap/util";
|
|
2
|
+
import padStart from "lodash/padStart.js";
|
|
3
|
+
|
|
4
|
+
//#region src/util.ts
|
|
5
|
+
const DID_PREFIX = "did:abt:";
|
|
5
6
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
* Convert did to bytes with length of 26
|
|
8
|
+
*
|
|
9
|
+
* @param {string} did
|
|
10
|
+
* @returns {Buffer}
|
|
11
|
+
*/
|
|
11
12
|
const toBytes = (did) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return bytes;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
throw new Error(`Cannot convert DID string to byte array: ${err.message}`);
|
|
25
|
-
}
|
|
13
|
+
try {
|
|
14
|
+
if (isHexStrict(did)) return Buffer.from(stripHexPrefix(did), "hex");
|
|
15
|
+
let bytes = fromBase58(did.replace(DID_PREFIX, ""));
|
|
16
|
+
while (bytes.length < 26) bytes = Buffer.concat([Buffer.from([0]), bytes]);
|
|
17
|
+
return bytes;
|
|
18
|
+
} catch (err) {
|
|
19
|
+
throw new Error(`Cannot convert DID string to byte array: ${err.message}`);
|
|
20
|
+
}
|
|
26
21
|
};
|
|
27
22
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const toBits = (number, length) => padStart(toBN(number).toString(2), length,
|
|
23
|
+
* Convert number to bit string with predefined length
|
|
24
|
+
*/
|
|
25
|
+
const toBits = (number, length) => padStart(toBN(number).toString(2), length, "0");
|
|
31
26
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
* Ensure the hex length is even number, 2, 4, 6, 8
|
|
28
|
+
*
|
|
29
|
+
* @param {string} hex
|
|
30
|
+
* @param {number} length
|
|
31
|
+
* @returns {string} hex
|
|
32
|
+
*/
|
|
38
33
|
const toStrictHex = (hex, length) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
return str.length % 2 === 0 ? str : `0${str}`;
|
|
34
|
+
const str = hex.replace(/^0x/i, "");
|
|
35
|
+
if (typeof length === "number" && length % 2 === 0) return padStart(hex, length, "0");
|
|
36
|
+
return str.length % 2 === 0 ? str : `0${str}`;
|
|
44
37
|
};
|
|
45
|
-
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { DID_PREFIX, toBits, toBytes, toStrictHex };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from "./type.js";
|
|
2
|
+
import { DID_PREFIX, toStrictHex } from "./util.js";
|
|
3
|
+
import { types } from "@ocap/mcrypto";
|
|
4
|
+
import { BytesType, toAddress, toDid } from "@ocap/util";
|
|
5
|
+
|
|
6
|
+
//#region src/index.d.ts
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Gen DID from private key and type config
|
|
7
10
|
*
|
|
@@ -54,4 +57,5 @@ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean;
|
|
|
54
57
|
* @returns {boolean}
|
|
55
58
|
*/
|
|
56
59
|
declare const isValid: (did: string) => boolean;
|
|
57
|
-
|
|
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 };
|
package/lib/index.js
CHANGED
|
@@ -1,145 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const util_1 = require("@ocap/util");
|
|
9
|
-
Object.defineProperty(exports, "toAddress", { enumerable: true, get: function () { return util_1.toAddress; } });
|
|
10
|
-
Object.defineProperty(exports, "toDid", { enumerable: true, get: function () { return util_1.toDid; } });
|
|
11
|
-
const type_1 = require("./type");
|
|
12
|
-
Object.defineProperty(exports, "DidType", { enumerable: true, get: function () { return type_1.DidType; } });
|
|
13
|
-
Object.defineProperty(exports, "DID_TYPE_ARCBLOCK", { enumerable: true, get: function () { return type_1.DID_TYPE_ARCBLOCK; } });
|
|
14
|
-
Object.defineProperty(exports, "DID_TYPE_ETHEREUM", { enumerable: true, get: function () { return type_1.DID_TYPE_ETHEREUM; } });
|
|
15
|
-
Object.defineProperty(exports, "DID_TYPE_PASSKEY", { enumerable: true, get: function () { return type_1.DID_TYPE_PASSKEY; } });
|
|
16
|
-
Object.defineProperty(exports, "fromTypeInfo", { enumerable: true, get: function () { return type_1.fromTypeInfo; } });
|
|
17
|
-
Object.defineProperty(exports, "isEthereumDid", { enumerable: true, get: function () { return type_1.isEthereumDid; } });
|
|
18
|
-
Object.defineProperty(exports, "isEthereumType", { enumerable: true, get: function () { return type_1.isEthereumType; } });
|
|
19
|
-
Object.defineProperty(exports, "toTypeInfo", { enumerable: true, get: function () { return type_1.toTypeInfo; } });
|
|
20
|
-
Object.defineProperty(exports, "toTypeInfoStr", { enumerable: true, get: function () { return type_1.toTypeInfoStr; } });
|
|
21
|
-
const util_2 = require("./util");
|
|
22
|
-
Object.defineProperty(exports, "DID_PREFIX", { enumerable: true, get: function () { return util_2.DID_PREFIX; } });
|
|
23
|
-
Object.defineProperty(exports, "toStrictHex", { enumerable: true, get: function () { return util_2.toStrictHex; } });
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_util = require('./util.js');
|
|
3
|
+
const require_type = require('./type.js');
|
|
4
|
+
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
5
|
+
let _ocap_util = require("@ocap/util");
|
|
6
|
+
|
|
7
|
+
//#region src/index.ts
|
|
24
8
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
* Gen DID from private key and type config
|
|
10
|
+
*
|
|
11
|
+
* Spec: https://github.com/ArcBlock/ABT-DID-Protocol#create-did
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @static
|
|
15
|
+
* @param {string} sk - hex encoded secret key string
|
|
16
|
+
* @param {object} type - wallet type, {@see @ocap/wallet#WalletType}
|
|
17
|
+
* @returns {string} DID string
|
|
18
|
+
*/
|
|
35
19
|
const fromSecretKey = (sk, type) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
const info = require_type.DidType(type);
|
|
21
|
+
const pub = (0, _ocap_mcrypto.getSigner)(info.pk).getPublicKey(sk);
|
|
22
|
+
return fromPublicKey(pub.indexOf("0x") === 0 ? pub : `0x${pub}`, info);
|
|
39
23
|
};
|
|
40
|
-
exports.fromSecretKey = fromSecretKey;
|
|
41
24
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
* Gen DID from public key and type config
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @static
|
|
29
|
+
* @param {string} pk - hex encoded public key
|
|
30
|
+
* @param {object} type - wallet type, {@see @ocap/wallet#WalletType}
|
|
31
|
+
* @returns {string} DID string
|
|
32
|
+
*/
|
|
50
33
|
const fromPublicKey = (pk, type) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const pkHash = hashFn(pk, 1);
|
|
54
|
-
return fromPublicKeyHash(pkHash, info);
|
|
34
|
+
const info = require_type.DidType(type);
|
|
35
|
+
return fromPublicKeyHash((0, _ocap_mcrypto.getHasher)(info.hash)(pk, 1), info);
|
|
55
36
|
};
|
|
56
|
-
exports.fromPublicKey = fromPublicKey;
|
|
57
37
|
const fromPublicKeyHash = (buffer, type) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if ((0, type_1.isEthereumType)(info)) {
|
|
67
|
-
return (0, type_1.toChecksumAddress)(`0x${buffer.slice(-40)}`);
|
|
68
|
-
}
|
|
69
|
-
// default forge-compatible did
|
|
70
|
-
if (info.address === mcrypto_1.types.EncodingType.BASE58) {
|
|
71
|
-
return (0, util_1.toBase58)(didHash);
|
|
72
|
-
}
|
|
73
|
-
// fallback base16 encoding
|
|
74
|
-
return didHash;
|
|
38
|
+
const info = require_type.DidType(type);
|
|
39
|
+
const pkHash = (0, _ocap_util.stripHexPrefix)(buffer).slice(0, 40);
|
|
40
|
+
const hashFn = (0, _ocap_mcrypto.getHasher)(info.hash);
|
|
41
|
+
const typeHex = require_type.fromTypeInfo(info);
|
|
42
|
+
const didHash = `0x${typeHex}${pkHash}${(0, _ocap_util.stripHexPrefix)(hashFn(`0x${typeHex}${pkHash}`, 1)).slice(0, 8)}`;
|
|
43
|
+
if (require_type.isEthereumType(info)) return require_type.toChecksumAddress(`0x${buffer.slice(-40)}`);
|
|
44
|
+
if (info.address === _ocap_mcrypto.types.EncodingType.BASE58) return (0, _ocap_util.toBase58)(didHash);
|
|
45
|
+
return didHash;
|
|
75
46
|
};
|
|
76
|
-
exports.fromPublicKeyHash = fromPublicKeyHash;
|
|
77
47
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const fromHash = (hash, role =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
const type = (0, type_1.DidType)({
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
role: mcrypto_1.types.RoleType[roleKeys[roleValues.indexOf(role)]],
|
|
95
|
-
});
|
|
96
|
-
return fromPublicKeyHash(hash, type);
|
|
48
|
+
* Gen DID from an hex encoded hash and role type
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
* @static
|
|
52
|
+
* @param {string} hash - hex encoded hash
|
|
53
|
+
* @param {enum} role - role type, {@see @ocap/mcrypto#types}
|
|
54
|
+
* @returns {string} DID string
|
|
55
|
+
*/
|
|
56
|
+
const fromHash = (hash, role = _ocap_mcrypto.types.RoleType.ROLE_ACCOUNT) => {
|
|
57
|
+
const roleKeys = Object.keys(_ocap_mcrypto.types.RoleType);
|
|
58
|
+
const roleValues = Object.values(_ocap_mcrypto.types.RoleType);
|
|
59
|
+
if (roleValues.indexOf(role) === -1) throw new Error(`Unsupported role type ${role} when gen ddi from hash`);
|
|
60
|
+
return fromPublicKeyHash(hash, require_type.DidType({ role: _ocap_mcrypto.types.RoleType[roleKeys[roleValues.indexOf(role)]] }));
|
|
97
61
|
};
|
|
98
|
-
exports.fromHash = fromHash;
|
|
99
62
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
63
|
+
* Check if an DID is generated from a publicKey
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
* @static
|
|
67
|
+
* @param {string} did - string of the did, usually base58btc format
|
|
68
|
+
* @param {string} pk - hex encoded publicKey string
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
108
71
|
const isFromPublicKey = (did, pk) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
const type = (0, type_1.toTypeInfo)(did);
|
|
113
|
-
const didNew = fromPublicKey(pk, type);
|
|
114
|
-
const didClean = did.replace(util_2.DID_PREFIX, '');
|
|
115
|
-
return didNew === didClean;
|
|
72
|
+
if (isValid(did) === false) return false;
|
|
73
|
+
return fromPublicKey(pk, require_type.toTypeInfo(did)) === did.replace(require_util.DID_PREFIX, "");
|
|
116
74
|
};
|
|
117
|
-
exports.isFromPublicKey = isFromPublicKey;
|
|
118
75
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
76
|
+
* Check if a DID string is valid
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
* @static
|
|
80
|
+
* @param {string} did - address string
|
|
81
|
+
* @returns {boolean}
|
|
82
|
+
*/
|
|
126
83
|
const isValid = (did) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
const hashFn = (0, mcrypto_1.getHasher)(hash);
|
|
139
|
-
const bytes = (0, util_2.toBytes)(address);
|
|
140
|
-
const bytesHex = (0, util_2.toStrictHex)(Buffer.from(bytes.slice(0, 22)).toString('hex'));
|
|
141
|
-
const didChecksum = (0, util_2.toStrictHex)(Buffer.from(bytes.slice(22, 26)).toString('hex'));
|
|
142
|
-
const checksum = (0, util_1.stripHexPrefix)(hashFn(`0x${bytesHex}`, 1)).slice(0, 8);
|
|
143
|
-
return didChecksum === checksum;
|
|
84
|
+
if (!did) return false;
|
|
85
|
+
const address = (0, _ocap_util.toAddress)(String(did));
|
|
86
|
+
const { hash } = require_type.toTypeInfo(address);
|
|
87
|
+
if (typeof hash === "undefined") return false;
|
|
88
|
+
if (require_type.isEthereumDid(address)) return true;
|
|
89
|
+
const hashFn = (0, _ocap_mcrypto.getHasher)(hash);
|
|
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);
|
|
144
93
|
};
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
exports.DID_PREFIX = require_util.DID_PREFIX;
|
|
97
|
+
exports.DID_TYPE_ARCBLOCK = require_type.DID_TYPE_ARCBLOCK;
|
|
98
|
+
exports.DID_TYPE_ETHEREUM = require_type.DID_TYPE_ETHEREUM;
|
|
99
|
+
exports.DID_TYPE_PASSKEY = require_type.DID_TYPE_PASSKEY;
|
|
100
|
+
exports.DidType = require_type.DidType;
|
|
101
|
+
exports.fromHash = fromHash;
|
|
102
|
+
exports.fromPublicKey = fromPublicKey;
|
|
103
|
+
exports.fromPublicKeyHash = fromPublicKeyHash;
|
|
104
|
+
exports.fromSecretKey = fromSecretKey;
|
|
105
|
+
exports.fromTypeInfo = require_type.fromTypeInfo;
|
|
106
|
+
exports.isEthereumDid = require_type.isEthereumDid;
|
|
107
|
+
exports.isEthereumType = require_type.isEthereumType;
|
|
108
|
+
exports.isFromPublicKey = isFromPublicKey;
|
|
145
109
|
exports.isValid = isValid;
|
|
110
|
+
exports.toAddress = _ocap_util.toAddress;
|
|
111
|
+
exports.toDid = _ocap_util.toDid;
|
|
112
|
+
exports.toStrictHex = require_util.toStrictHex;
|
|
113
|
+
exports.toTypeInfo = require_type.toTypeInfo;
|
|
114
|
+
exports.toTypeInfoStr = require_type.toTypeInfoStr;
|
|
115
|
+
exports.types = _ocap_mcrypto.types;
|
package/lib/lodash.d.ts
ADDED
package/lib/type.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export type DIDTypeArg = DIDTypeShortcut | DIDType;
|
|
1
|
+
import { LiteralUnion } from "type-fest";
|
|
2
|
+
|
|
3
|
+
//#region src/type.d.ts
|
|
4
|
+
type DIDTypeKey = LiteralUnion<'role' | 'pk' | 'hash' | 'address', string>;
|
|
5
|
+
type DIDTypeShortcut = LiteralUnion<'default' | 'arcblock' | 'eth' | 'ethereum' | 'passkey', string>;
|
|
6
|
+
type DIDType = { [key in DIDTypeKey]?: number };
|
|
7
|
+
type DIDTypeStr = { [key in DIDTypeKey]?: string };
|
|
8
|
+
type DIDTypeArg = DIDTypeShortcut | DIDType;
|
|
11
9
|
declare const DID_TYPE_ARCBLOCK: DIDType;
|
|
12
10
|
declare const DID_TYPE_PASSKEY: DIDType;
|
|
13
11
|
declare const DID_TYPE_ETHEREUM: DIDType;
|
|
14
|
-
declare const isEthereumType: (type: DIDType) =>
|
|
12
|
+
declare const isEthereumType: (type: DIDType) => boolean;
|
|
15
13
|
/**
|
|
16
14
|
* Checks if the given string is an address
|
|
17
15
|
*
|
|
@@ -33,8 +31,8 @@ declare const toChecksumAddress: (address: string) => string;
|
|
|
33
31
|
*/
|
|
34
32
|
declare function DidType(type?: DIDTypeArg): DIDType;
|
|
35
33
|
declare namespace DidType {
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
var toJSON: (type: DIDType) => DIDTypeStr;
|
|
35
|
+
var fromJSON: (json: DIDTypeStr) => DIDType;
|
|
38
36
|
}
|
|
39
37
|
/**
|
|
40
38
|
* Convert type info object to hex string
|
|
@@ -50,4 +48,5 @@ declare const fromTypeInfo: (type: DIDTypeArg) => string;
|
|
|
50
48
|
*/
|
|
51
49
|
declare const toTypeInfo: (did: string) => DIDType;
|
|
52
50
|
declare const toTypeInfoStr: (did: string) => DIDTypeStr;
|
|
53
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
export { DIDType, DIDTypeArg, DIDTypeKey, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr };
|