@arcblock/did-ext 1.6.3 → 1.6.10
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 +2 -2
- package/lib/index.js +10 -4
- package/package.json +18 -15
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
|
> Extensions to work with ArcBlock DID
|
|
8
8
|
|
|
@@ -53,4 +53,4 @@ Will output:
|
|
|
53
53
|
|
|
54
54
|
## Documentation
|
|
55
55
|
|
|
56
|
-
For full documentation, checkout [https://
|
|
56
|
+
For full documentation, checkout [https://asset-chain.netlify.com](https://asset-chain.netlify.com/)
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
2
|
const hdkey = require('@wangshijun/hdkey');
|
|
3
3
|
const Mcrypto = require('@ocap/mcrypto');
|
|
4
|
-
const { fromSecretKey } = require('@ocap/wallet');
|
|
4
|
+
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
5
|
const { isHexStrict, toHex, toBuffer, stripHexPrefix } = require('@ocap/util');
|
|
6
6
|
|
|
7
7
|
const { types } = Mcrypto;
|
|
@@ -37,16 +37,22 @@ const fromAppDid = (appDid, rootSk, type = { role: types.RoleType.ROLE_ACCOUNT }
|
|
|
37
37
|
const derivePath = `m/44'/260'/${n1}'/${n2}'/${index}`;
|
|
38
38
|
const child = master.derive(derivePath);
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const typeObj = WalletType(type);
|
|
41
|
+
const { pk = types.KeyType.ED25519 } = typeObj;
|
|
41
42
|
let sk;
|
|
42
43
|
if (pk === types.KeyType.ED25519) {
|
|
43
44
|
const keyPair = Mcrypto.Signer.Ed25519.genKeyPair(child.privateKey);
|
|
44
45
|
sk = keyPair.secretKey;
|
|
45
46
|
} else {
|
|
46
|
-
sk = child.privateKey;
|
|
47
|
+
sk = toHex(child.privateKey);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
// To keeps things consistent between ocap and ethereum: 32 bytes private key
|
|
51
|
+
if (pk === types.KeyType.ETHEREUM) {
|
|
52
|
+
sk = sk.slice(0, 66);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return fromSecretKey(sk, typeObj);
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
module.exports = { fromAppDid };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-ext",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"description": "Extension to work with ArcBlock DID",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arcblock",
|
|
@@ -15,42 +15,45 @@
|
|
|
15
15
|
"email": "shijun@arcblock.io",
|
|
16
16
|
"url": "https://github.com/wangshijun"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
18
|
+
"contributors": [
|
|
19
|
+
"wangshijun <shijun@arcblock.io> (https://github.com/wangshijun)"
|
|
20
|
+
],
|
|
21
|
+
"homepage": "https://github.com/ArcBlock/asset-chain/tree/master/did/did-ext",
|
|
19
22
|
"license": "Apache-2.0",
|
|
20
23
|
"main": "lib/index.js",
|
|
21
24
|
"files": [
|
|
22
25
|
"lib"
|
|
23
26
|
],
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"jest": "^
|
|
28
|
+
"jest": "^27.3.1"
|
|
26
29
|
},
|
|
27
30
|
"repository": {
|
|
28
31
|
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/ArcBlock/
|
|
32
|
+
"url": "git+https://github.com/ArcBlock/asset-chain.git"
|
|
30
33
|
},
|
|
31
34
|
"scripts": {
|
|
32
35
|
"lint": "eslint tests lib",
|
|
33
36
|
"lint:fix": "eslint --fix tests lib",
|
|
34
37
|
"docs": "yarn gen-dts && yarn gen-docs && yarn cleanup-docs && yarn format-docs",
|
|
35
|
-
"cleanup-docs": "node ../../
|
|
38
|
+
"cleanup-docs": "node ../../scripts/cleanup-docs.js docs/README.md $npm_package_name",
|
|
36
39
|
"gen-docs": "jsdoc2md lib/index.js > docs/README.md",
|
|
37
40
|
"gen-dts": "j2d lib/index.js",
|
|
38
41
|
"format-docs": "remark . -o",
|
|
39
|
-
"test": "
|
|
42
|
+
"test": "jest --forceExit --detectOpenHandles",
|
|
40
43
|
"coverage": "yarn test -- --coverage"
|
|
41
44
|
},
|
|
42
45
|
"bugs": {
|
|
43
|
-
"url": "https://github.com/ArcBlock/
|
|
46
|
+
"url": "https://github.com/ArcBlock/asset-chain/issues"
|
|
44
47
|
},
|
|
45
48
|
"dependencies": {
|
|
46
|
-
"@arcblock/did": "
|
|
47
|
-
"@ocap/mcrypto": "
|
|
48
|
-
"@ocap/util": "
|
|
49
|
-
"@ocap/wallet": "
|
|
49
|
+
"@arcblock/did": "1.6.10",
|
|
50
|
+
"@ocap/mcrypto": "1.6.10",
|
|
51
|
+
"@ocap/util": "1.6.10",
|
|
52
|
+
"@ocap/wallet": "1.6.10",
|
|
50
53
|
"@wangshijun/hdkey": "^2.0.4",
|
|
51
|
-
"bn.js": "^5.
|
|
52
|
-
"debug": "^4.3.
|
|
53
|
-
"lodash": "^4.17.
|
|
54
|
+
"bn.js": "^5.2.0",
|
|
55
|
+
"debug": "^4.3.3",
|
|
56
|
+
"lodash": "^4.17.21"
|
|
54
57
|
},
|
|
55
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ab272e8db3a15c6571cc7fae7cc3d3e0fdd4bdb1"
|
|
56
59
|
}
|