@blocklet/sdk 1.16.54-beta-20251027-105624-dfa978f8 → 1.16.54-beta-20251028-092308-569763e6
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/service/blocklet.js +1 -1
- package/lib/wallet.d.ts +3 -2
- package/lib/wallet.js +14 -8
- package/package.json +9 -9
package/lib/service/blocklet.js
CHANGED
|
@@ -180,7 +180,7 @@ class BlockletService {
|
|
|
180
180
|
'configBlocklet',
|
|
181
181
|
'configNavigations',
|
|
182
182
|
];
|
|
183
|
-
const teamDid = process.env.
|
|
183
|
+
const teamDid = process.env.BLOCKLET_APP_PID;
|
|
184
184
|
const componentDid = process.env.BLOCKLET_COMPONENT_DID;
|
|
185
185
|
const apiFallback = (fn) => (params = {}, ...args) => fn({ input: { ...params, teamDid }, ...args });
|
|
186
186
|
// const apiConvertDid = (fn: Function) => (did: string) => fn({ input: { user: { did }, teamDid } });
|
package/lib/wallet.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const getWallet: {
|
|
|
26
26
|
getPermanentWallet: () => WalletObject<string>;
|
|
27
27
|
getEthereumWallet: (permanent?: boolean) => WalletObject<string>;
|
|
28
28
|
getPkWallet: (type?: DIDTypeShortcut, appPk?: string) => WalletObject;
|
|
29
|
-
deriveWallet: (sub: string, type?: DIDTypeArg, index?: number) => Promise<WalletObject>;
|
|
29
|
+
deriveWallet: (sub: string, type?: DIDTypeArg, index?: number, keyType?: "sk" | "psk") => Promise<WalletObject>;
|
|
30
30
|
getAccessWallet: () => WalletObject<string>;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -34,9 +34,10 @@ export declare const getWallet: {
|
|
|
34
34
|
* @param sub - Subject identifier (e.g., 'email|user@example.com')
|
|
35
35
|
* @param type - DID type shortcut (e.g., 'ethereum')
|
|
36
36
|
* @param index - Index for deriving wallet (default: 0)
|
|
37
|
+
* @param keyType - Key type to use ('sk' or 'psk', default: 'sk')
|
|
37
38
|
* @returns Wallet object with sign and signJWT methods
|
|
38
39
|
*/
|
|
39
|
-
export declare const deriveWallet: (sub: string, type?: DIDTypeArg, index?: number) => Promise<WalletObject>;
|
|
40
|
+
export declare const deriveWallet: (sub: string, type?: DIDTypeArg, index?: number, keyType?: "sk" | "psk") => Promise<WalletObject>;
|
|
40
41
|
export declare const getPermanentWallet: () => WalletObject<string>;
|
|
41
42
|
export declare const getEthereumWallet: (permanent?: boolean) => WalletObject<string>;
|
|
42
43
|
export declare const getAccessWallet: () => WalletObject<string>;
|
package/lib/wallet.js
CHANGED
|
@@ -47,7 +47,7 @@ const createRemoteWallet = (publicKey, type, keyType = 'sk') => {
|
|
|
47
47
|
// Support full wallet.sign signature: sign(data, encoding?, hashBeforeSign?)
|
|
48
48
|
remoteWallet.sign = async (payload, encoding, hashBeforeSign) => {
|
|
49
49
|
try {
|
|
50
|
-
const { signature } = await (0, signature_1.remoteSign)(payload, { keyType, encoding, hashBeforeSign });
|
|
50
|
+
const { signature } = await (0, signature_1.remoteSign)(payload, { keyType, encoding, hashBeforeSign, type });
|
|
51
51
|
if (!signature) {
|
|
52
52
|
throw new Error('Empty signature returned from blocklet-service');
|
|
53
53
|
}
|
|
@@ -61,7 +61,7 @@ const createRemoteWallet = (publicKey, type, keyType = 'sk') => {
|
|
|
61
61
|
// Match the signature: signJWT(payload?, doSign?, version?)
|
|
62
62
|
remoteWallet.signJWT = async (payload, doSign, version) => {
|
|
63
63
|
try {
|
|
64
|
-
const { token } = await (0, signature_1.remoteSignJWT)(payload, { doSign, version, keyType });
|
|
64
|
+
const { token } = await (0, signature_1.remoteSignJWT)(payload, { doSign, version, keyType, type });
|
|
65
65
|
if (!token) {
|
|
66
66
|
throw new Error('Empty JWT token returned from blocklet-service');
|
|
67
67
|
}
|
|
@@ -74,7 +74,7 @@ const createRemoteWallet = (publicKey, type, keyType = 'sk') => {
|
|
|
74
74
|
// Add remote signETH method
|
|
75
75
|
remoteWallet.signETH = async (data, hashBeforeSign) => {
|
|
76
76
|
try {
|
|
77
|
-
const { signature } = await (0, signature_1.remoteSignETH)(data, { hashBeforeSign, keyType });
|
|
77
|
+
const { signature } = await (0, signature_1.remoteSignETH)(data, { hashBeforeSign, keyType, type: 'ethereum' });
|
|
78
78
|
if (!signature) {
|
|
79
79
|
throw new Error('Empty signature returned from blocklet-service');
|
|
80
80
|
}
|
|
@@ -105,8 +105,13 @@ const getWallet = (type, appSk = process.env.BLOCKLET_APP_SK, keyType = 'sk') =>
|
|
|
105
105
|
? (0, wallet_1.WalletType)(type)
|
|
106
106
|
: (0, wallet_1.WalletType)({ role: mcrypto_1.types.RoleType.ROLE_APPLICATION, pk: mcrypto_1.types.KeyType.ED25519, hash: mcrypto_1.types.HashType.SHA3 });
|
|
107
107
|
if (!appSk) {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
let appPk;
|
|
109
|
+
if ((0, did_1.isEthereumType)((0, did_1.DidType)(type))) {
|
|
110
|
+
appPk = keyType === 'psk' ? process.env.BLOCKLET_APP_PPK_ETH : process.env.BLOCKLET_APP_PK_ETH;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
appPk = keyType === 'psk' ? process.env.BLOCKLET_APP_PPK : process.env.BLOCKLET_APP_PK;
|
|
114
|
+
}
|
|
110
115
|
if (!appPk) {
|
|
111
116
|
throw new Error(`Missing public key for ${keyType.toUpperCase()} wallet: BLOCKLET_APP_P${keyType.toUpperCase()}`);
|
|
112
117
|
}
|
|
@@ -125,16 +130,17 @@ exports.getWallet = getWallet;
|
|
|
125
130
|
* @param sub - Subject identifier (e.g., 'email|user@example.com')
|
|
126
131
|
* @param type - DID type shortcut (e.g., 'ethereum')
|
|
127
132
|
* @param index - Index for deriving wallet (default: 0)
|
|
133
|
+
* @param keyType - Key type to use ('sk' or 'psk', default: 'sk')
|
|
128
134
|
* @returns Wallet object with sign and signJWT methods
|
|
129
135
|
*/
|
|
130
|
-
const deriveWallet = async (sub, type, index) => {
|
|
131
|
-
const appSk = process.env.BLOCKLET_APP_SK;
|
|
136
|
+
const deriveWallet = async (sub, type, index, keyType = 'sk') => {
|
|
137
|
+
const appSk = keyType === 'psk' ? process.env.BLOCKLET_APP_PSK : process.env.BLOCKLET_APP_SK;
|
|
132
138
|
// If we have a secret key, use local fromAppDid
|
|
133
139
|
if (appSk) {
|
|
134
140
|
return (0, did_ext_1.fromAppDid)(sub, appSk, type, index);
|
|
135
141
|
}
|
|
136
142
|
// No secret key available, use remote fromAppDid
|
|
137
|
-
const walletJSON = await (0, signature_1.remoteDeriveWallet)(sub, type, index);
|
|
143
|
+
const walletJSON = await (0, signature_1.remoteDeriveWallet)(sub, type, index, { keyType });
|
|
138
144
|
const wallet = (0, wallet_1.fromJSON)(walletJSON);
|
|
139
145
|
if (!(0, wallet_1.isValid)(wallet, true)) {
|
|
140
146
|
throw new Error('Invalid response from remote fromAppDid: wallet is invalid');
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.54-beta-
|
|
6
|
+
"version": "1.16.54-beta-20251028-092308-569763e6",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"homepage": "https://www.arcblock.io/docs/blocklet-sdk-nodejs",
|
|
9
9
|
"main": "lib/index.js",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@abtnode/constant": "1.16.54-beta-
|
|
32
|
-
"@abtnode/db-cache": "1.16.54-beta-
|
|
33
|
-
"@abtnode/util": "1.16.54-beta-
|
|
31
|
+
"@abtnode/constant": "1.16.54-beta-20251028-092308-569763e6",
|
|
32
|
+
"@abtnode/db-cache": "1.16.54-beta-20251028-092308-569763e6",
|
|
33
|
+
"@abtnode/util": "1.16.54-beta-20251028-092308-569763e6",
|
|
34
34
|
"@arcblock/did": "^1.26.3",
|
|
35
35
|
"@arcblock/did-connect-js": "^1.26.3",
|
|
36
36
|
"@arcblock/did-ext": "^1.26.3",
|
|
37
37
|
"@arcblock/jwt": "^1.26.3",
|
|
38
38
|
"@arcblock/ws": "^1.26.3",
|
|
39
|
-
"@blocklet/constant": "1.16.54-beta-
|
|
40
|
-
"@blocklet/env": "1.16.54-beta-
|
|
39
|
+
"@blocklet/constant": "1.16.54-beta-20251028-092308-569763e6",
|
|
40
|
+
"@blocklet/env": "1.16.54-beta-20251028-092308-569763e6",
|
|
41
41
|
"@blocklet/error": "^0.2.5",
|
|
42
|
-
"@blocklet/meta": "1.16.54-beta-
|
|
43
|
-
"@blocklet/server-js": "1.16.54-beta-
|
|
42
|
+
"@blocklet/meta": "1.16.54-beta-20251028-092308-569763e6",
|
|
43
|
+
"@blocklet/server-js": "1.16.54-beta-20251028-092308-569763e6",
|
|
44
44
|
"@blocklet/theme": "^3.1.51",
|
|
45
45
|
"@did-connect/authenticator": "^2.2.8",
|
|
46
46
|
"@did-connect/handler": "^2.2.8",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"ts-node": "^10.9.1",
|
|
85
85
|
"typescript": "^5.6.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "6143a5fe06862e017da9a2dca2b0ff18c318587b"
|
|
88
88
|
}
|