@blocklet/sdk 1.16.0-beta-b16cb035 → 1.16.0-beta-8ee536d7
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/connect/shared.js +3 -3
- package/lib/wallet.d.ts +7 -1
- package/lib/wallet.js +18 -5
- package/package.json +12 -11
package/lib/connect/shared.js
CHANGED
|
@@ -5,23 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getAuthenticatorProps = exports.getDelegatee = exports.getDelegator = exports.getDelegation = void 0;
|
|
7
7
|
const url_join_1 = __importDefault(require("url-join"));
|
|
8
|
-
const wallet_1 = __importDefault(require("@blocklet/meta/lib/wallet"));
|
|
9
8
|
const jwt_1 = require("@arcblock/jwt");
|
|
10
9
|
const util_1 = require("@blocklet/meta/lib/util");
|
|
11
10
|
const constants_1 = require("../util/constants");
|
|
11
|
+
const wallet_1 = __importDefault(require("../wallet"));
|
|
12
12
|
// wraps value in closure or returns closure
|
|
13
13
|
const closure = (value) => (typeof value === 'function' ? value : () => value);
|
|
14
14
|
const getDelegator = () => {
|
|
15
15
|
const { BLOCKLET_APP_SK, BLOCKLET_APP_PSK, BLOCKLET_WALLET_TYPE } = process.env;
|
|
16
16
|
if (BLOCKLET_APP_SK && BLOCKLET_APP_PSK && BLOCKLET_APP_SK !== BLOCKLET_APP_PSK) {
|
|
17
|
-
return (0, wallet_1.default)(
|
|
17
|
+
return (0, wallet_1.default)(BLOCKLET_WALLET_TYPE, BLOCKLET_APP_PSK);
|
|
18
18
|
}
|
|
19
19
|
return null;
|
|
20
20
|
};
|
|
21
21
|
exports.getDelegator = getDelegator;
|
|
22
22
|
const getDelegatee = () => {
|
|
23
23
|
const { BLOCKLET_APP_SK, BLOCKLET_WALLET_TYPE } = process.env;
|
|
24
|
-
return (0, wallet_1.default)(
|
|
24
|
+
return (0, wallet_1.default)(BLOCKLET_WALLET_TYPE, BLOCKLET_APP_SK);
|
|
25
25
|
};
|
|
26
26
|
exports.getDelegatee = getDelegatee;
|
|
27
27
|
const getDelegation = (delegator, delegatee) => {
|
package/lib/wallet.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { WalletObject } from '@ocap/wallet';
|
|
2
|
-
|
|
2
|
+
import { DIDTypeShortcut } from '@arcblock/did';
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} [type=process.env.BLOCKLET_WALLET_TYPE] can only be 'eth|ethereum' or 'default|arcblock'
|
|
5
|
+
* @param {string} [appSk=process.env.BLOCKLET_APP_SK] must be hex
|
|
6
|
+
* @return {WalletObject} {WalletObject}
|
|
7
|
+
*/
|
|
8
|
+
declare const getWallet: (type?: DIDTypeShortcut, appSk?: string) => WalletObject;
|
|
3
9
|
export = getWallet;
|
package/lib/wallet.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const wallet_1 = require("@ocap/wallet");
|
|
3
3
|
const mcrypto_1 = require("@ocap/mcrypto");
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const did_1 = require("@arcblock/did");
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} [type=process.env.BLOCKLET_WALLET_TYPE] can only be 'eth|ethereum' or 'default|arcblock'
|
|
7
|
+
* @param {string} [appSk=process.env.BLOCKLET_APP_SK] must be hex
|
|
8
|
+
* @return {WalletObject} {WalletObject}
|
|
9
|
+
*/
|
|
10
|
+
const getWallet = (type = process.env.BLOCKLET_WALLET_TYPE, appSk = process.env.BLOCKLET_APP_SK) => {
|
|
11
|
+
let t;
|
|
12
|
+
let sk;
|
|
13
|
+
if ((0, did_1.isEthereumType)((0, did_1.DidType)(type))) {
|
|
14
|
+
sk = appSk.slice(0, 66);
|
|
15
|
+
t = (0, wallet_1.WalletType)(type);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
sk = appSk;
|
|
19
|
+
t = (0, wallet_1.WalletType)({ role: mcrypto_1.types.RoleType.ROLE_APPLICATION, pk: mcrypto_1.types.KeyType.ED25519, hash: mcrypto_1.types.HashType.SHA3 });
|
|
20
|
+
}
|
|
21
|
+
return (0, wallet_1.fromSecretKey)(sk, t);
|
|
9
22
|
};
|
|
10
23
|
module.exports = getWallet;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.0-beta-
|
|
6
|
+
"version": "1.16.0-beta-8ee536d7",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -26,18 +26,19 @@
|
|
|
26
26
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@abtnode/client": "1.16.0-beta-
|
|
30
|
-
"@abtnode/constant": "1.16.0-beta-
|
|
31
|
-
"@arcblock/did
|
|
32
|
-
"@arcblock/
|
|
33
|
-
"@arcblock/
|
|
34
|
-
"@
|
|
35
|
-
"@blocklet/
|
|
29
|
+
"@abtnode/client": "1.16.0-beta-8ee536d7",
|
|
30
|
+
"@abtnode/constant": "1.16.0-beta-8ee536d7",
|
|
31
|
+
"@arcblock/did": "1.18.62",
|
|
32
|
+
"@arcblock/did-auth": "1.18.62",
|
|
33
|
+
"@arcblock/jwt": "1.18.62",
|
|
34
|
+
"@arcblock/ws": "1.18.62",
|
|
35
|
+
"@blocklet/constant": "1.16.0-beta-8ee536d7",
|
|
36
|
+
"@blocklet/meta": "1.16.0-beta-8ee536d7",
|
|
36
37
|
"@did-connect/authenticator": "^2.1.44",
|
|
37
38
|
"@did-connect/handler": "^2.1.44",
|
|
38
39
|
"@nedb/core": "^2.1.5",
|
|
39
|
-
"@ocap/mcrypto": "1.18.
|
|
40
|
-
"@ocap/wallet": "1.18.
|
|
40
|
+
"@ocap/mcrypto": "1.18.62",
|
|
41
|
+
"@ocap/wallet": "1.18.62",
|
|
41
42
|
"axios": "^0.27.2",
|
|
42
43
|
"cheerio": "^1.0.0-rc.12",
|
|
43
44
|
"fs-extra": "^10.1.0",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"ts-node": "^10.9.1",
|
|
71
72
|
"typescript": "^4.8.4"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "57d0c45be311a5fbc1c0fffa2814b62c1a3ee34c"
|
|
74
75
|
}
|