@getpara/server-sdk 1.1.0 → 1.3.0
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/dist/cjs/index.js +1 -21
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/cjs/workers/worker.js +2 -154
- package/dist/cjs/workers/worker.js.br +0 -0
- package/dist/cjs/workers/worker.js.gz +0 -0
- package/dist/esm/index.js +1 -4
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/esm/workers/chunk-NEJSZOZX.js +1 -0
- package/dist/esm/workers/chunk-NEJSZOZX.js.br +0 -0
- package/dist/esm/workers/chunk-NEJSZOZX.js.gz +0 -0
- package/dist/esm/workers/wasm_exec-TBSO5IWG.js +2 -0
- package/dist/esm/workers/wasm_exec-TBSO5IWG.js.br +0 -0
- package/dist/esm/workers/wasm_exec-TBSO5IWG.js.gz +0 -0
- package/dist/esm/workers/worker.js +1 -124
- package/dist/esm/workers/worker.js.br +0 -0
- package/dist/esm/workers/worker.js.gz +0 -0
- package/package.json +6 -5
- package/dist/cjs/ParaServer.d.ts +0 -4
- package/dist/cjs/ParaServer.js +0 -14
- package/dist/cjs/ServerLocalStorage.d.ts +0 -12
- package/dist/cjs/ServerLocalStorage.js +0 -30
- package/dist/cjs/ServerSessionStorage.d.ts +0 -12
- package/dist/cjs/ServerSessionStorage.js +0 -30
- package/dist/cjs/ServerUtils.d.ts +0 -43
- package/dist/cjs/ServerUtils.js +0 -55
- package/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/wallet/keygen.d.ts +0 -22
- package/dist/cjs/wallet/keygen.js +0 -172
- package/dist/cjs/wallet/privateKey.d.ts +0 -2
- package/dist/cjs/wallet/privateKey.js +0 -62
- package/dist/cjs/wallet/signing.d.ts +0 -5
- package/dist/cjs/wallet/signing.js +0 -133
- package/dist/cjs/wasm/wasm_exec.d.ts +0 -1
- package/dist/cjs/wasm/wasm_exec.js +0 -521
- package/dist/cjs/workers/walletUtils.d.ts +0 -25
- package/dist/cjs/workers/walletUtils.js +0 -247
- package/dist/cjs/workers/worker.d.ts +0 -18
- package/dist/cjs/workers/workerWrapper.d.ts +0 -4
- package/dist/cjs/workers/workerWrapper.js +0 -55
- package/dist/esm/ParaServer.d.ts +0 -4
- package/dist/esm/ParaServer.js +0 -7
- package/dist/esm/ServerLocalStorage.d.ts +0 -12
- package/dist/esm/ServerLocalStorage.js +0 -26
- package/dist/esm/ServerSessionStorage.d.ts +0 -12
- package/dist/esm/ServerSessionStorage.js +0 -26
- package/dist/esm/ServerUtils.d.ts +0 -43
- package/dist/esm/ServerUtils.js +0 -51
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/package.json +0 -1
- package/dist/esm/wallet/keygen.d.ts +0 -22
- package/dist/esm/wallet/keygen.js +0 -142
- package/dist/esm/wallet/privateKey.d.ts +0 -2
- package/dist/esm/wallet/privateKey.js +0 -35
- package/dist/esm/wallet/signing.d.ts +0 -5
- package/dist/esm/wallet/signing.js +0 -103
- package/dist/esm/wasm/wasm_exec.d.ts +0 -1
- package/dist/esm/wasm/wasm_exec.js +0 -521
- package/dist/esm/workers/walletUtils.d.ts +0 -25
- package/dist/esm/workers/walletUtils.js +0 -234
- package/dist/esm/workers/worker.d.ts +0 -18
- package/dist/esm/workers/workerWrapper.d.ts +0 -4
- package/dist/esm/workers/workerWrapper.js +0 -51
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getPrivateKey = exports.refresh = exports.sendTransaction = exports.signTransaction = exports.signMessage = exports.preKeygen = exports.keygen = exports.ed25519Sign = exports.ed25519PreKeygen = exports.ed25519Keygen = void 0;
|
|
13
|
-
const core_sdk_1 = require("@getpara/core-sdk");
|
|
14
|
-
const configCGGMPBase = (serverUrl, walletId, id) => `{"ServerUrl":"${serverUrl}", "WalletId": "${walletId}", "Id":"${id}", "Ids":["USER","CAPSULE"], "Threshold":1}`;
|
|
15
|
-
const configDKLSBase = (walletId, id, disableWebSockets) => `{"walletId": "${walletId}", "id":"${id}", "otherId":"CAPSULE", "isReceiver": false, "disableWebSockets": ${disableWebSockets}}`;
|
|
16
|
-
function keygenRequest(ctx, userId, walletId, protocolId) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const { data } = yield ctx.mpcComputationClient.post('/wallets', {
|
|
19
|
-
userId,
|
|
20
|
-
walletId,
|
|
21
|
-
protocolId,
|
|
22
|
-
});
|
|
23
|
-
return data;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function signMessageRequest(ctx, userId, walletId, protocolId, message, signer) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const { data } = yield ctx.mpcComputationClient.post(`/wallets/${walletId}/messages/sign`, {
|
|
29
|
-
userId,
|
|
30
|
-
protocolId,
|
|
31
|
-
message,
|
|
32
|
-
signer,
|
|
33
|
-
});
|
|
34
|
-
return data;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function sendTransactionRequest(ctx, userId, walletId, protocolId, transaction, signer, chainId) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const { data } = yield ctx.mpcComputationClient.post(`/wallets/${walletId}/transactions/send`, {
|
|
40
|
-
userId,
|
|
41
|
-
protocolId,
|
|
42
|
-
transaction,
|
|
43
|
-
signer,
|
|
44
|
-
chainId,
|
|
45
|
-
});
|
|
46
|
-
return data;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function ed25519Keygen(ctx, userId) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
|
|
52
|
-
scheme: core_sdk_1.WalletScheme.ED25519,
|
|
53
|
-
type: core_sdk_1.WalletType.SOLANA,
|
|
54
|
-
});
|
|
55
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
56
|
-
const newSigner = (yield new Promise((resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
|
|
57
|
-
if (err) {
|
|
58
|
-
reject(err);
|
|
59
|
-
}
|
|
60
|
-
resolve(result);
|
|
61
|
-
})));
|
|
62
|
-
return { signer: newSigner, walletId };
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
exports.ed25519Keygen = ed25519Keygen;
|
|
66
|
-
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const { walletId, protocolId } = yield ctx.client.createPregenWallet({
|
|
69
|
-
pregenIdentifier,
|
|
70
|
-
pregenIdentifierType,
|
|
71
|
-
scheme: core_sdk_1.WalletScheme.ED25519,
|
|
72
|
-
type: core_sdk_1.WalletType.SOLANA,
|
|
73
|
-
});
|
|
74
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
75
|
-
const newSigner = (yield new Promise((resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
|
|
76
|
-
if (err) {
|
|
77
|
-
reject(err);
|
|
78
|
-
}
|
|
79
|
-
resolve(result);
|
|
80
|
-
})));
|
|
81
|
-
return { signer: newSigner, walletId };
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
exports.ed25519PreKeygen = ed25519PreKeygen;
|
|
85
|
-
function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const { protocolId } = yield ctx.client.preSignMessage(userId, walletId, base64Bytes, core_sdk_1.WalletScheme.ED25519);
|
|
88
|
-
const base64Sig = (yield new Promise((resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
|
|
89
|
-
if (err) {
|
|
90
|
-
reject(err);
|
|
91
|
-
}
|
|
92
|
-
resolve(result);
|
|
93
|
-
})));
|
|
94
|
-
return { signature: base64Sig };
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
exports.ed25519Sign = ed25519Sign;
|
|
98
|
-
function keygen(ctx, userId, type, secretKey) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
|
|
101
|
-
useTwoSigners: true,
|
|
102
|
-
scheme: ctx.useDKLS ? core_sdk_1.WalletScheme.DKLS : core_sdk_1.WalletScheme.CGGMP,
|
|
103
|
-
type,
|
|
104
|
-
cosmosPrefix: type === core_sdk_1.WalletType.COSMOS ? ctx.cosmosPrefix : undefined,
|
|
105
|
-
});
|
|
106
|
-
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
107
|
-
return {
|
|
108
|
-
signer: (yield keygenRequest(ctx, userId, walletId, protocolId)).signer,
|
|
109
|
-
walletId,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
113
|
-
const signerConfigUser = ctx.useDKLS
|
|
114
|
-
? configDKLSBase(walletId, 'USER', ctx.disableWebSockets)
|
|
115
|
-
: configCGGMPBase(serverUrl, walletId, 'USER');
|
|
116
|
-
const createAccountFn = ctx.useDKLS ? global.dklsCreateAccount : global.createAccountV2;
|
|
117
|
-
const newSigner = (yield new Promise((resolve, reject) => createAccountFn(signerConfigUser, serverUrl, protocolId, secretKey, () => { }, // no-op for deprecated callback to update progress percentage
|
|
118
|
-
(err, result) => {
|
|
119
|
-
if (err) {
|
|
120
|
-
reject(err);
|
|
121
|
-
}
|
|
122
|
-
resolve(result);
|
|
123
|
-
})));
|
|
124
|
-
return { signer: newSigner, walletId };
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
exports.keygen = keygen;
|
|
128
|
-
function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const { walletId, protocolId } = yield ctx.client.createPregenWallet({
|
|
131
|
-
pregenIdentifier,
|
|
132
|
-
pregenIdentifierType,
|
|
133
|
-
type,
|
|
134
|
-
cosmosPrefix: type === core_sdk_1.WalletType.COSMOS ? ctx.cosmosPrefix : undefined,
|
|
135
|
-
});
|
|
136
|
-
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
137
|
-
return {
|
|
138
|
-
signer: (yield keygenRequest(ctx, partnerId, walletId, protocolId)).signer,
|
|
139
|
-
walletId,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
143
|
-
const signerConfigUser = ctx.useDKLS
|
|
144
|
-
? configDKLSBase(walletId, 'USER', ctx.disableWebSockets)
|
|
145
|
-
: configCGGMPBase(serverUrl, walletId, 'USER');
|
|
146
|
-
const createAccountFn = ctx.useDKLS ? global.dklsCreateAccount : global.createAccountV2;
|
|
147
|
-
const newSigner = (yield new Promise((resolve, reject) => createAccountFn(signerConfigUser, serverUrl, protocolId, secretKey, () => { }, // no-op for deprecated callback to update progress percentage
|
|
148
|
-
(err, result) => {
|
|
149
|
-
if (err) {
|
|
150
|
-
reject(err);
|
|
151
|
-
}
|
|
152
|
-
resolve(result);
|
|
153
|
-
})));
|
|
154
|
-
return { signer: newSigner, walletId };
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
exports.preKeygen = preKeygen;
|
|
158
|
-
function signMessage(ctx, share, walletId, userId, message) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
const { protocolId, pendingTransactionId } = yield ctx.client.preSignMessage(userId, walletId, message);
|
|
161
|
-
if (pendingTransactionId) {
|
|
162
|
-
return { pendingTransactionId };
|
|
163
|
-
}
|
|
164
|
-
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
165
|
-
return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
|
|
166
|
-
}
|
|
167
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
168
|
-
const signMessageFn = ctx.useDKLS ? global.dklsSignMessage : global.signMessage;
|
|
169
|
-
return new Promise((resolve, reject) => signMessageFn(share, serverUrl, message, protocolId, (err, result) => {
|
|
170
|
-
if (err) {
|
|
171
|
-
reject(err);
|
|
172
|
-
}
|
|
173
|
-
resolve({ signature: result });
|
|
174
|
-
}));
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
exports.signMessage = signMessage;
|
|
178
|
-
function signTransaction(ctx, share, walletId, userId, tx, chainId) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const { data: { protocolId, pendingTransactionId }, } = yield ctx.client.signTransaction(userId, walletId, { transaction: tx, chainId });
|
|
181
|
-
if (pendingTransactionId) {
|
|
182
|
-
return { pendingTransactionId };
|
|
183
|
-
}
|
|
184
|
-
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
185
|
-
return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
|
|
186
|
-
}
|
|
187
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
188
|
-
const signTransactionFn = ctx.useDKLS ? global.dklsSendTransaction : global.sendTransaction;
|
|
189
|
-
return new Promise((resolve, reject) => signTransactionFn(share, serverUrl, tx, chainId, protocolId, (err, result) => {
|
|
190
|
-
if (err) {
|
|
191
|
-
reject(err);
|
|
192
|
-
}
|
|
193
|
-
resolve({ signature: result });
|
|
194
|
-
}));
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
exports.signTransaction = signTransaction;
|
|
198
|
-
function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
|
|
199
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const { data: { protocolId, pendingTransactionId }, } = yield ctx.client.sendTransaction(userId, walletId, { transaction: tx, chainId });
|
|
201
|
-
if (pendingTransactionId) {
|
|
202
|
-
return { pendingTransactionId };
|
|
203
|
-
}
|
|
204
|
-
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
205
|
-
return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
|
|
206
|
-
}
|
|
207
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
208
|
-
const sendTransactionFn = ctx.useDKLS ? global.dklsSendTransaction : global.sendTransaction;
|
|
209
|
-
return new Promise((resolve, reject) => sendTransactionFn(share, serverUrl, tx, chainId, protocolId, (err, result) => {
|
|
210
|
-
if (err) {
|
|
211
|
-
reject(err);
|
|
212
|
-
}
|
|
213
|
-
resolve({ signature: result });
|
|
214
|
-
}));
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
exports.sendTransaction = sendTransaction;
|
|
218
|
-
function refresh(ctx, share, walletId, userId) {
|
|
219
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
const { data: { protocolId }, } = yield ctx.client.refreshKeys(userId, walletId);
|
|
221
|
-
const serverUrl = (0, core_sdk_1.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
222
|
-
const refreshFn = ctx.useDKLS ? global.dklsRefresh : global.refresh;
|
|
223
|
-
return new Promise((resolve, reject) => refreshFn(share, serverUrl, protocolId, (err, result) => {
|
|
224
|
-
if (err) {
|
|
225
|
-
reject(err);
|
|
226
|
-
}
|
|
227
|
-
resolve(result);
|
|
228
|
-
}));
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
exports.refresh = refresh;
|
|
232
|
-
function getPrivateKey(ctx, share, walletId, userId) {
|
|
233
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
const paraShare = yield ctx.client.getParaShare(userId, walletId);
|
|
235
|
-
if (!paraShare) {
|
|
236
|
-
console.error('unable to retrieve Para share');
|
|
237
|
-
return '';
|
|
238
|
-
}
|
|
239
|
-
return new Promise((resolve, reject) => global.getPrivateKey(share, paraShare, (err, result) => {
|
|
240
|
-
if (err) {
|
|
241
|
-
reject(err);
|
|
242
|
-
}
|
|
243
|
-
resolve(result);
|
|
244
|
-
}));
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
exports.getPrivateKey = getPrivateKey;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Environment } from '@getpara/core-sdk';
|
|
2
|
-
interface Message {
|
|
3
|
-
env: Environment;
|
|
4
|
-
apiKey?: string;
|
|
5
|
-
cosmosPrefix?: string;
|
|
6
|
-
offloadMPCComputationURL?: string;
|
|
7
|
-
disableWorkers?: boolean;
|
|
8
|
-
functionType: string;
|
|
9
|
-
params: Record<string, any>;
|
|
10
|
-
sessionCookie?: string;
|
|
11
|
-
useDKLS?: boolean;
|
|
12
|
-
disableWebSockets?: boolean;
|
|
13
|
-
workId: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function handleMessage(e: {
|
|
16
|
-
data: Message;
|
|
17
|
-
}): Promise<any>;
|
|
18
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.setupWorker = void 0;
|
|
13
|
-
const worker_threads_1 = require("worker_threads");
|
|
14
|
-
const core_sdk_1 = require("@getpara/core-sdk");
|
|
15
|
-
const CLEAR_WORKER_TIMEOUT_MS = 1000 * 90;
|
|
16
|
-
let worker;
|
|
17
|
-
const resFunctionMap = {};
|
|
18
|
-
function removeWorkId(workId, skipClearTimeout) {
|
|
19
|
-
const { timeoutId } = resFunctionMap[workId];
|
|
20
|
-
delete resFunctionMap[workId];
|
|
21
|
-
if (skipClearTimeout) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
clearTimeout(timeoutId);
|
|
25
|
-
}
|
|
26
|
-
function setupWorker(ctx, resFunction, workId) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const timeoutId = setTimeout(() => {
|
|
29
|
-
removeWorkId(workId, true);
|
|
30
|
-
}, CLEAR_WORKER_TIMEOUT_MS);
|
|
31
|
-
resFunctionMap[workId] = {
|
|
32
|
-
fn: resFunction,
|
|
33
|
-
timeoutId,
|
|
34
|
-
};
|
|
35
|
-
if (!worker || !worker.threadId) {
|
|
36
|
-
const workerRes = yield fetch(`${(0, core_sdk_1.getPortalBaseURL)(ctx)}/static/js/mpcWorkerServer-bundle.js`);
|
|
37
|
-
worker = new worker_threads_1.Worker(yield workerRes.text(), { eval: true });
|
|
38
|
-
const onmessage = (message) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const { workId: messageWorkId } = message;
|
|
40
|
-
delete message.workId;
|
|
41
|
-
yield resFunctionMap[messageWorkId].fn(message);
|
|
42
|
-
removeWorkId(messageWorkId);
|
|
43
|
-
});
|
|
44
|
-
worker.on('message', onmessage);
|
|
45
|
-
worker.on('error', err => {
|
|
46
|
-
throw err;
|
|
47
|
-
});
|
|
48
|
-
worker.on('exit', code => {
|
|
49
|
-
console.error(`worker stopped with exit code ${code}`);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return worker;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
exports.setupWorker = setupWorker;
|
package/dist/esm/ParaServer.d.ts
DELETED
package/dist/esm/ParaServer.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StorageUtils } from '@getpara/core-sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Implements `StorageUtils`
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare class ServerLocalStorage implements StorageUtils {
|
|
7
|
-
private localStorage;
|
|
8
|
-
get: (key: string) => string | null;
|
|
9
|
-
set: (key: string, value: string) => void;
|
|
10
|
-
removeItem: (key: string) => void;
|
|
11
|
-
clear: (prefix: string) => void;
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements `StorageUtils`
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export class ServerLocalStorage {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.localStorage = {};
|
|
8
|
-
this.get = (key) => {
|
|
9
|
-
return this.localStorage[key] || null;
|
|
10
|
-
};
|
|
11
|
-
this.set = (key, value) => {
|
|
12
|
-
this.localStorage[key] = value;
|
|
13
|
-
};
|
|
14
|
-
this.removeItem = (key) => {
|
|
15
|
-
delete this.localStorage[key];
|
|
16
|
-
};
|
|
17
|
-
this.clear = (prefix) => {
|
|
18
|
-
const keys = Object.keys(this.localStorage);
|
|
19
|
-
for (let key in keys) {
|
|
20
|
-
if (key && key.startsWith(prefix)) {
|
|
21
|
-
this.removeItem(key);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StorageUtils } from '@getpara/core-sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Implements `StorageUtils` using a JavaScript object.
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare class ServerSessionStorage implements StorageUtils {
|
|
7
|
-
private sessionStorage;
|
|
8
|
-
get: (key: string) => string | null;
|
|
9
|
-
set: (key: string, value: string) => void;
|
|
10
|
-
removeItem: (key: string) => void;
|
|
11
|
-
clear: (prefix: string) => void;
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements `StorageUtils` using a JavaScript object.
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export class ServerSessionStorage {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.sessionStorage = {};
|
|
8
|
-
this.get = (key) => {
|
|
9
|
-
return this.sessionStorage[key] || null;
|
|
10
|
-
};
|
|
11
|
-
this.set = (key, value) => {
|
|
12
|
-
this.sessionStorage[key] = value;
|
|
13
|
-
};
|
|
14
|
-
this.removeItem = (key) => {
|
|
15
|
-
delete this.sessionStorage[key];
|
|
16
|
-
};
|
|
17
|
-
this.clear = (prefix) => {
|
|
18
|
-
const keys = Object.keys(this.sessionStorage);
|
|
19
|
-
for (let key in keys) {
|
|
20
|
-
if (key && key.startsWith(prefix)) {
|
|
21
|
-
this.removeItem(key);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, WalletType } from '@getpara/core-sdk';
|
|
3
|
-
import { BackupKitEmailProps } from '@getpara/user-management-client';
|
|
4
|
-
import { ServerLocalStorage } from './ServerLocalStorage.js';
|
|
5
|
-
import { ServerSessionStorage } from './ServerSessionStorage.js';
|
|
6
|
-
export declare class ServerUtils implements PlatformUtils {
|
|
7
|
-
getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
8
|
-
keygen(ctx: Ctx, userId: string, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
|
|
9
|
-
signer: string;
|
|
10
|
-
walletId: string;
|
|
11
|
-
}>;
|
|
12
|
-
refresh(_ctx: Ctx, _sessionCookie: string, _userId: string, _walletId: string, _share: string, _oldPartnerId?: string, _newPartnerId?: string): Promise<{
|
|
13
|
-
signer: string;
|
|
14
|
-
}>;
|
|
15
|
-
preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
|
|
16
|
-
sessionCookie: string): Promise<{
|
|
17
|
-
signer: string;
|
|
18
|
-
walletId: string;
|
|
19
|
-
}>;
|
|
20
|
-
signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
21
|
-
signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, message: string, chainId: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
22
|
-
sendTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
23
|
-
signHash(_address: string, _hash: string): Promise<{
|
|
24
|
-
v: number;
|
|
25
|
-
r: Buffer;
|
|
26
|
-
s: Buffer;
|
|
27
|
-
}>;
|
|
28
|
-
ed25519Keygen(ctx: Ctx, userId: string, sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
|
|
29
|
-
signer: string;
|
|
30
|
-
walletId: string;
|
|
31
|
-
}>;
|
|
32
|
-
ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, sessionCookie: string): Promise<{
|
|
33
|
-
signer: string;
|
|
34
|
-
walletId: string;
|
|
35
|
-
}>;
|
|
36
|
-
ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string): Promise<SignatureRes>;
|
|
37
|
-
localStorage: ServerLocalStorage;
|
|
38
|
-
sessionStorage: ServerSessionStorage;
|
|
39
|
-
secureStorage: any;
|
|
40
|
-
isSyncStorage: boolean;
|
|
41
|
-
disableProviderModal: boolean;
|
|
42
|
-
openPopup(_popupUrl: string): Window;
|
|
43
|
-
}
|
package/dist/esm/ServerUtils.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ServerLocalStorage } from './ServerLocalStorage.js';
|
|
2
|
-
import { ServerSessionStorage } from './ServerSessionStorage.js';
|
|
3
|
-
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen } from './wallet/keygen.js';
|
|
4
|
-
import { signMessage, sendTransaction, signTransaction, ed25519Sign } from './wallet/signing.js';
|
|
5
|
-
import { getPrivateKey } from './wallet/privateKey.js';
|
|
6
|
-
export class ServerUtils {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.localStorage = new ServerLocalStorage();
|
|
9
|
-
this.sessionStorage = new ServerSessionStorage();
|
|
10
|
-
this.secureStorage = undefined;
|
|
11
|
-
this.isSyncStorage = true;
|
|
12
|
-
this.disableProviderModal = true;
|
|
13
|
-
}
|
|
14
|
-
getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
15
|
-
return getPrivateKey(ctx, userId, walletId, share, sessionCookie);
|
|
16
|
-
}
|
|
17
|
-
keygen(ctx, userId, type, secretKey, sessionCookie, emailProps) {
|
|
18
|
-
return keygen(ctx, userId, type, secretKey, true, sessionCookie, emailProps);
|
|
19
|
-
}
|
|
20
|
-
refresh(_ctx, _sessionCookie, _userId, _walletId, _share, _oldPartnerId, _newPartnerId) {
|
|
21
|
-
throw new Error('not implemented');
|
|
22
|
-
}
|
|
23
|
-
preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, // should be acceptable as null in RN as we don't pre-gen them
|
|
24
|
-
sessionCookie) {
|
|
25
|
-
return preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
|
|
26
|
-
}
|
|
27
|
-
signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
28
|
-
return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS);
|
|
29
|
-
}
|
|
30
|
-
signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS) {
|
|
31
|
-
return signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS);
|
|
32
|
-
}
|
|
33
|
-
sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
34
|
-
return sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS);
|
|
35
|
-
}
|
|
36
|
-
signHash(_address, _hash) {
|
|
37
|
-
throw new Error('not implemented');
|
|
38
|
-
}
|
|
39
|
-
ed25519Keygen(ctx, userId, sessionCookie, emailProps) {
|
|
40
|
-
return ed25519Keygen(ctx, userId, sessionCookie, emailProps);
|
|
41
|
-
}
|
|
42
|
-
ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
43
|
-
return ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie);
|
|
44
|
-
}
|
|
45
|
-
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
46
|
-
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
47
|
-
}
|
|
48
|
-
openPopup(_popupUrl) {
|
|
49
|
-
throw new Error('not implemented');
|
|
50
|
-
}
|
|
51
|
-
}
|
package/dist/esm/index.d.ts
DELETED
package/dist/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module","sideEffects":["wasm_exec.js"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Ctx, TPregenIdentifierType } from '@getpara/core-sdk';
|
|
2
|
-
import { BackupKitEmailProps, WalletType } from '@getpara/user-management-client';
|
|
3
|
-
export declare function keygen(ctx: Ctx, userId: string, type: WalletType, secretKey: string | null, skipDistribute?: boolean, sessionCookie?: string, _emailProps?: BackupKitEmailProps): Promise<{
|
|
4
|
-
signer: string;
|
|
5
|
-
walletId: string;
|
|
6
|
-
recoveryShare: string | null;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function preKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: WalletType, secretKey: string | null, _skipDistribute: boolean, partnerId: string, sessionCookie?: string): Promise<{
|
|
9
|
-
signer: string;
|
|
10
|
-
walletId: string;
|
|
11
|
-
recoveryShare: string | null;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function ed25519Keygen(ctx: Ctx, userId: string, sessionCookie?: string, _emailProps?: BackupKitEmailProps): Promise<{
|
|
14
|
-
signer: string;
|
|
15
|
-
walletId: string;
|
|
16
|
-
recoveryShare: string | null;
|
|
17
|
-
}>;
|
|
18
|
-
export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, sessionCookie?: string): Promise<{
|
|
19
|
-
signer: string;
|
|
20
|
-
walletId: string;
|
|
21
|
-
recoveryShare: string | null;
|
|
22
|
-
}>;
|