@getpara/server-sdk 2.0.0-alpha.3 → 2.0.0-alpha.5
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/ParaServer.js +91 -0
- package/dist/cjs/ServerLocalStorage.js +48 -0
- package/dist/cjs/ServerSessionStorage.js +48 -0
- package/dist/cjs/ServerUtils.js +77 -0
- package/dist/cjs/index.js +3 -523
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/wallet/keygen.js +229 -0
- package/dist/cjs/wallet/privateKey.js +86 -0
- package/dist/cjs/wallet/signing.js +172 -0
- package/dist/cjs/wasm/wasm_exec.js +589 -0
- package/dist/cjs/workers/walletUtils.js +367 -0
- package/dist/cjs/workers/worker.js +24 -906
- package/dist/cjs/workers/workerWrapper.js +88 -0
- package/dist/esm/ParaServer.js +39 -0
- package/dist/esm/ServerLocalStorage.js +26 -0
- package/dist/esm/ServerSessionStorage.js +26 -0
- package/dist/esm/ServerUtils.js +55 -0
- package/dist/esm/chunk-FTA5RKYX.js +8 -0
- package/dist/esm/index.js +4 -468
- package/dist/esm/package.json +6 -0
- package/dist/esm/wallet/keygen.js +160 -0
- package/dist/esm/wallet/privateKey.js +32 -0
- package/dist/esm/wallet/signing.js +109 -0
- package/dist/esm/{workers/wasm_exec-CFNSOXDO.js → wasm/wasm_exec.js} +68 -74
- package/dist/esm/workers/walletUtils.js +290 -0
- package/dist/esm/workers/worker.js +41 -336
- package/dist/esm/workers/workerWrapper.js +44 -0
- package/dist/types/ServerUtils.d.ts +5 -4
- package/dist/types/wallet/keygen.d.ts +5 -3
- package/dist/types/workers/walletUtils.d.ts +3 -3
- package/dist/types/workers/worker.d.ts +2 -1
- package/package.json +5 -5
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/cjs/workers/worker.js.br +0 -0
- package/dist/cjs/workers/worker.js.gz +0 -0
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/esm/workers/chunk-ILICZWQV.js +0 -36
- package/dist/esm/workers/chunk-ILICZWQV.js.br +0 -0
- package/dist/esm/workers/chunk-ILICZWQV.js.gz +0 -0
- package/dist/esm/workers/wasm_exec-CFNSOXDO.js.br +0 -0
- package/dist/esm/workers/wasm_exec-CFNSOXDO.js.gz +0 -0
- package/dist/esm/workers/worker.js.br +0 -0
- package/dist/esm/workers/worker.js.gz +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -17,534 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var __async = (__this, __arguments, generator) => {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
var fulfilled = (value) => {
|
|
32
|
-
try {
|
|
33
|
-
step(generator.next(value));
|
|
34
|
-
} catch (e) {
|
|
35
|
-
reject(e);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var rejected = (value) => {
|
|
39
|
-
try {
|
|
40
|
-
step(generator.throw(value));
|
|
41
|
-
} catch (e) {
|
|
42
|
-
reject(e);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/index.ts
|
|
51
19
|
var src_exports = {};
|
|
52
20
|
__export(src_exports, {
|
|
53
|
-
Para: () => Para,
|
|
21
|
+
Para: () => import_ParaServer.Para,
|
|
54
22
|
default: () => src_default
|
|
55
23
|
});
|
|
56
24
|
module.exports = __toCommonJS(src_exports);
|
|
57
25
|
__reExport(src_exports, require("@getpara/core-sdk"), module.exports);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var import_core_sdk3 = __toESM(require("@getpara/core-sdk"));
|
|
61
|
-
var Sentry = __toESM(require("@sentry/node"));
|
|
62
|
-
|
|
63
|
-
// src/ServerLocalStorage.ts
|
|
64
|
-
var ServerLocalStorage = class {
|
|
65
|
-
constructor() {
|
|
66
|
-
this.localStorage = {};
|
|
67
|
-
this.get = (key) => {
|
|
68
|
-
return this.localStorage[key] || null;
|
|
69
|
-
};
|
|
70
|
-
this.set = (key, value) => {
|
|
71
|
-
this.localStorage[key] = value;
|
|
72
|
-
};
|
|
73
|
-
this.removeItem = (key) => {
|
|
74
|
-
delete this.localStorage[key];
|
|
75
|
-
};
|
|
76
|
-
this.clear = (prefix) => {
|
|
77
|
-
const keys = Object.keys(this.localStorage);
|
|
78
|
-
for (let key in keys) {
|
|
79
|
-
if (key && key.startsWith(prefix)) {
|
|
80
|
-
this.removeItem(key);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// src/ServerSessionStorage.ts
|
|
88
|
-
var ServerSessionStorage = class {
|
|
89
|
-
constructor() {
|
|
90
|
-
this.sessionStorage = {};
|
|
91
|
-
this.get = (key) => {
|
|
92
|
-
return this.sessionStorage[key] || null;
|
|
93
|
-
};
|
|
94
|
-
this.set = (key, value) => {
|
|
95
|
-
this.sessionStorage[key] = value;
|
|
96
|
-
};
|
|
97
|
-
this.removeItem = (key) => {
|
|
98
|
-
delete this.sessionStorage[key];
|
|
99
|
-
};
|
|
100
|
-
this.clear = (prefix) => {
|
|
101
|
-
const keys = Object.keys(this.sessionStorage);
|
|
102
|
-
for (let key in keys) {
|
|
103
|
-
if (key && key.startsWith(prefix)) {
|
|
104
|
-
this.removeItem(key);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// src/wallet/keygen.ts
|
|
112
|
-
var uuid = __toESM(require("uuid"));
|
|
113
|
-
var import_core_sdk2 = require("@getpara/core-sdk");
|
|
114
|
-
|
|
115
|
-
// src/workers/workerWrapper.ts
|
|
116
|
-
var import_worker_threads = require("worker_threads");
|
|
117
|
-
var import_core_sdk = require("@getpara/core-sdk");
|
|
118
|
-
var CLEAR_WORKER_TIMEOUT_MS = 1e3 * 90;
|
|
119
|
-
var worker;
|
|
120
|
-
var resFunctionMap = {};
|
|
121
|
-
function removeWorkId(workId, skipClearTimeout) {
|
|
122
|
-
const { timeoutId } = resFunctionMap[workId];
|
|
123
|
-
delete resFunctionMap[workId];
|
|
124
|
-
if (skipClearTimeout) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
clearTimeout(timeoutId);
|
|
128
|
-
}
|
|
129
|
-
function setupWorker(ctx, resFunction, workId) {
|
|
130
|
-
return __async(this, null, function* () {
|
|
131
|
-
const timeoutId = setTimeout(() => {
|
|
132
|
-
removeWorkId(workId, true);
|
|
133
|
-
}, CLEAR_WORKER_TIMEOUT_MS);
|
|
134
|
-
resFunctionMap[workId] = {
|
|
135
|
-
fn: resFunction,
|
|
136
|
-
timeoutId
|
|
137
|
-
};
|
|
138
|
-
if (!worker || !worker.threadId) {
|
|
139
|
-
const workerRes = yield fetch(`${(0, import_core_sdk.getPortalBaseURL)(ctx)}/static/js/mpcWorkerServer-bundle.js`);
|
|
140
|
-
worker = new import_worker_threads.Worker(yield workerRes.text(), { eval: true });
|
|
141
|
-
const onmessage = (message) => __async(this, null, function* () {
|
|
142
|
-
const { workId: messageWorkId } = message;
|
|
143
|
-
delete message.workId;
|
|
144
|
-
yield resFunctionMap[messageWorkId].fn(message);
|
|
145
|
-
removeWorkId(messageWorkId);
|
|
146
|
-
});
|
|
147
|
-
worker.on("message", onmessage);
|
|
148
|
-
worker.on("error", (err) => {
|
|
149
|
-
throw err;
|
|
150
|
-
});
|
|
151
|
-
worker.on("exit", (code) => {
|
|
152
|
-
console.error(`worker stopped with exit code ${code}`);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return worker;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/wallet/keygen.ts
|
|
160
|
-
function isKeygenComplete(ctx, userId, walletId) {
|
|
161
|
-
return __async(this, null, function* () {
|
|
162
|
-
const wallets = yield ctx.client.getWallets(userId);
|
|
163
|
-
const wallet = wallets.data.wallets.find((w) => w.id === walletId);
|
|
164
|
-
return !!wallet.address;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
|
|
168
|
-
return __async(this, null, function* () {
|
|
169
|
-
const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
|
|
170
|
-
const wallet = wallets.wallets.find((w) => w.id === walletId);
|
|
171
|
-
return !!(wallet == null ? void 0 : wallet.address);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, _emailProps = {}) {
|
|
175
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
176
|
-
const workId = uuid.v4();
|
|
177
|
-
const worker2 = yield setupWorker(
|
|
178
|
-
ctx,
|
|
179
|
-
(res) => __async(this, null, function* () {
|
|
180
|
-
yield (0, import_core_sdk2.waitUntilTrue)(() => __async(this, null, function* () {
|
|
181
|
-
return isKeygenComplete(ctx, userId, res.walletId);
|
|
182
|
-
}), 15e3, 1e3);
|
|
183
|
-
if (skipDistribute) {
|
|
184
|
-
resolve({
|
|
185
|
-
signer: res.signer,
|
|
186
|
-
walletId: res.walletId,
|
|
187
|
-
recoveryShare: null
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}),
|
|
191
|
-
workId
|
|
192
|
-
);
|
|
193
|
-
worker2.postMessage({
|
|
194
|
-
env: ctx.env,
|
|
195
|
-
apiKey: ctx.apiKey,
|
|
196
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
197
|
-
params: { userId, secretKey, type },
|
|
198
|
-
functionType: "KEYGEN",
|
|
199
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
200
|
-
disableWorkers: ctx.disableWorkers,
|
|
201
|
-
sessionCookie,
|
|
202
|
-
useDKLS: ctx.useDKLS,
|
|
203
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
204
|
-
wasmOverride: ctx.wasmOverride,
|
|
205
|
-
workId
|
|
206
|
-
});
|
|
207
|
-
}));
|
|
208
|
-
}
|
|
209
|
-
function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
210
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
211
|
-
const workId = uuid.v4();
|
|
212
|
-
const worker2 = yield setupWorker(
|
|
213
|
-
ctx,
|
|
214
|
-
(res) => __async(this, null, function* () {
|
|
215
|
-
yield (0, import_core_sdk2.waitUntilTrue)(
|
|
216
|
-
() => __async(this, null, function* () {
|
|
217
|
-
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
218
|
-
}),
|
|
219
|
-
15e3,
|
|
220
|
-
1e3
|
|
221
|
-
);
|
|
222
|
-
resolve({
|
|
223
|
-
signer: res.signer,
|
|
224
|
-
walletId: res.walletId,
|
|
225
|
-
recoveryShare: null
|
|
226
|
-
});
|
|
227
|
-
}),
|
|
228
|
-
workId
|
|
229
|
-
);
|
|
230
|
-
const email = void 0;
|
|
231
|
-
const params = { pregenIdentifier, pregenIdentifierType, secretKey, partnerId, email, type };
|
|
232
|
-
if (pregenIdentifierType === "EMAIL") {
|
|
233
|
-
params.email = pregenIdentifier;
|
|
234
|
-
}
|
|
235
|
-
worker2.postMessage({
|
|
236
|
-
env: ctx.env,
|
|
237
|
-
apiKey: ctx.apiKey,
|
|
238
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
239
|
-
params,
|
|
240
|
-
functionType: "PREKEYGEN",
|
|
241
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
242
|
-
disableWorkers: ctx.disableWorkers,
|
|
243
|
-
sessionCookie,
|
|
244
|
-
useDKLS: ctx.useDKLS,
|
|
245
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
246
|
-
wasmOverride: ctx.wasmOverride,
|
|
247
|
-
workId
|
|
248
|
-
});
|
|
249
|
-
}));
|
|
250
|
-
}
|
|
251
|
-
function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
252
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
253
|
-
const workId = uuid.v4();
|
|
254
|
-
const worker2 = yield setupWorker(
|
|
255
|
-
ctx,
|
|
256
|
-
(res) => __async(this, null, function* () {
|
|
257
|
-
yield (0, import_core_sdk2.waitUntilTrue)(() => __async(this, null, function* () {
|
|
258
|
-
return isKeygenComplete(ctx, userId, res.walletId);
|
|
259
|
-
}), 15e3, 1e3);
|
|
260
|
-
resolve({
|
|
261
|
-
signer: res.signer,
|
|
262
|
-
walletId: res.walletId,
|
|
263
|
-
recoveryShare: null
|
|
264
|
-
});
|
|
265
|
-
}),
|
|
266
|
-
workId
|
|
267
|
-
);
|
|
268
|
-
worker2.postMessage({
|
|
269
|
-
env: ctx.env,
|
|
270
|
-
apiKey: ctx.apiKey,
|
|
271
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
272
|
-
params: { userId },
|
|
273
|
-
functionType: "ED25519_KEYGEN",
|
|
274
|
-
disableWorkers: ctx.disableWorkers,
|
|
275
|
-
sessionCookie,
|
|
276
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
277
|
-
wasmOverride: ctx.wasmOverride,
|
|
278
|
-
workId
|
|
279
|
-
});
|
|
280
|
-
}));
|
|
281
|
-
}
|
|
282
|
-
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
283
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
284
|
-
const workId = uuid.v4();
|
|
285
|
-
const worker2 = yield setupWorker(
|
|
286
|
-
ctx,
|
|
287
|
-
(res) => __async(this, null, function* () {
|
|
288
|
-
yield (0, import_core_sdk2.waitUntilTrue)(
|
|
289
|
-
() => __async(this, null, function* () {
|
|
290
|
-
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
291
|
-
}),
|
|
292
|
-
15e3,
|
|
293
|
-
1e3
|
|
294
|
-
);
|
|
295
|
-
resolve({
|
|
296
|
-
signer: res.signer,
|
|
297
|
-
walletId: res.walletId,
|
|
298
|
-
recoveryShare: null
|
|
299
|
-
});
|
|
300
|
-
}),
|
|
301
|
-
workId
|
|
302
|
-
);
|
|
303
|
-
const email = void 0;
|
|
304
|
-
const params = { pregenIdentifier, pregenIdentifierType, email };
|
|
305
|
-
if (pregenIdentifierType === "EMAIL") {
|
|
306
|
-
params.email = pregenIdentifier;
|
|
307
|
-
}
|
|
308
|
-
worker2.postMessage({
|
|
309
|
-
env: ctx.env,
|
|
310
|
-
apiKey: ctx.apiKey,
|
|
311
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
312
|
-
params,
|
|
313
|
-
functionType: "ED25519_PREKEYGEN",
|
|
314
|
-
disableWorkers: ctx.disableWorkers,
|
|
315
|
-
sessionCookie,
|
|
316
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
317
|
-
wasmOverride: ctx.wasmOverride,
|
|
318
|
-
workId
|
|
319
|
-
});
|
|
320
|
-
}));
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// src/wallet/signing.ts
|
|
324
|
-
var uuid2 = __toESM(require("uuid"));
|
|
325
|
-
function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
326
|
-
return __async(this, null, function* () {
|
|
327
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
328
|
-
const workId = uuid2.v4();
|
|
329
|
-
const worker2 = yield setupWorker(
|
|
330
|
-
ctx,
|
|
331
|
-
(sendTransactionRes) => __async(this, null, function* () {
|
|
332
|
-
resolve(sendTransactionRes);
|
|
333
|
-
}),
|
|
334
|
-
workId
|
|
335
|
-
);
|
|
336
|
-
worker2.postMessage({
|
|
337
|
-
env: ctx.env,
|
|
338
|
-
apiKey: ctx.apiKey,
|
|
339
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
340
|
-
params: { share, walletId, userId, tx, chainId },
|
|
341
|
-
functionType: "SIGN_TRANSACTION",
|
|
342
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
343
|
-
disableWorkers: ctx.disableWorkers,
|
|
344
|
-
sessionCookie,
|
|
345
|
-
useDKLS: isDKLS,
|
|
346
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
347
|
-
wasmOverride: ctx.wasmOverride,
|
|
348
|
-
workId
|
|
349
|
-
});
|
|
350
|
-
}));
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
354
|
-
return __async(this, null, function* () {
|
|
355
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
356
|
-
const workId = uuid2.v4();
|
|
357
|
-
const worker2 = yield setupWorker(
|
|
358
|
-
ctx,
|
|
359
|
-
(sendTransactionRes) => __async(this, null, function* () {
|
|
360
|
-
resolve(sendTransactionRes);
|
|
361
|
-
}),
|
|
362
|
-
workId
|
|
363
|
-
);
|
|
364
|
-
worker2.postMessage({
|
|
365
|
-
env: ctx.env,
|
|
366
|
-
apiKey: ctx.apiKey,
|
|
367
|
-
params: { share, walletId, userId, tx, chainId },
|
|
368
|
-
functionType: "SEND_TRANSACTION",
|
|
369
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
370
|
-
disableWorkers: ctx.disableWorkers,
|
|
371
|
-
sessionCookie,
|
|
372
|
-
useDKLS: isDKLS,
|
|
373
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
374
|
-
wasmOverride: ctx.wasmOverride,
|
|
375
|
-
workId
|
|
376
|
-
});
|
|
377
|
-
}));
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
381
|
-
return __async(this, null, function* () {
|
|
382
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
383
|
-
const workId = uuid2.v4();
|
|
384
|
-
const worker2 = yield setupWorker(
|
|
385
|
-
ctx,
|
|
386
|
-
(signMessageRes) => __async(this, null, function* () {
|
|
387
|
-
resolve(signMessageRes);
|
|
388
|
-
}),
|
|
389
|
-
workId
|
|
390
|
-
);
|
|
391
|
-
worker2.postMessage({
|
|
392
|
-
env: ctx.env,
|
|
393
|
-
apiKey: ctx.apiKey,
|
|
394
|
-
params: { share, walletId, userId, message },
|
|
395
|
-
functionType: "SIGN_MESSAGE",
|
|
396
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
397
|
-
disableWorkers: ctx.disableWorkers,
|
|
398
|
-
sessionCookie,
|
|
399
|
-
useDKLS: isDKLS,
|
|
400
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
401
|
-
wasmOverride: ctx.wasmOverride,
|
|
402
|
-
workId
|
|
403
|
-
});
|
|
404
|
-
}));
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
408
|
-
return __async(this, null, function* () {
|
|
409
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
410
|
-
const workId = uuid2.v4();
|
|
411
|
-
const worker2 = yield setupWorker(
|
|
412
|
-
ctx,
|
|
413
|
-
(signMessageRes) => __async(this, null, function* () {
|
|
414
|
-
resolve(signMessageRes);
|
|
415
|
-
}),
|
|
416
|
-
workId
|
|
417
|
-
);
|
|
418
|
-
worker2.postMessage({
|
|
419
|
-
env: ctx.env,
|
|
420
|
-
apiKey: ctx.apiKey,
|
|
421
|
-
params: { share, walletId, userId, base64Bytes },
|
|
422
|
-
functionType: "ED25519_SIGN",
|
|
423
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
424
|
-
disableWorkers: ctx.disableWorkers,
|
|
425
|
-
sessionCookie,
|
|
426
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
427
|
-
wasmOverride: ctx.wasmOverride,
|
|
428
|
-
workId
|
|
429
|
-
});
|
|
430
|
-
}));
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// src/wallet/privateKey.ts
|
|
435
|
-
var uuid3 = __toESM(require("uuid"));
|
|
436
|
-
function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
437
|
-
return __async(this, null, function* () {
|
|
438
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
439
|
-
const workId = uuid3.v4();
|
|
440
|
-
const worker2 = yield setupWorker(
|
|
441
|
-
ctx,
|
|
442
|
-
(res) => __async(this, null, function* () {
|
|
443
|
-
resolve(res);
|
|
444
|
-
}),
|
|
445
|
-
workId
|
|
446
|
-
);
|
|
447
|
-
worker2.postMessage({
|
|
448
|
-
env: ctx.env,
|
|
449
|
-
apiKey: ctx.apiKey,
|
|
450
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
451
|
-
params: { share, walletId, userId },
|
|
452
|
-
functionType: "GET_PRIVATE_KEY",
|
|
453
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
454
|
-
disableWorkers: ctx.disableWorkers,
|
|
455
|
-
sessionCookie,
|
|
456
|
-
useDKLS: ctx.useDKLS,
|
|
457
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
458
|
-
wasmOverride: ctx.wasmOverride,
|
|
459
|
-
workId
|
|
460
|
-
});
|
|
461
|
-
}));
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// src/ServerUtils.ts
|
|
466
|
-
var ServerUtils = class {
|
|
467
|
-
constructor() {
|
|
468
|
-
this.localStorage = new ServerLocalStorage();
|
|
469
|
-
this.sessionStorage = new ServerSessionStorage();
|
|
470
|
-
this.secureStorage = void 0;
|
|
471
|
-
this.isSyncStorage = true;
|
|
472
|
-
this.disableProviderModal = true;
|
|
473
|
-
}
|
|
474
|
-
getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
475
|
-
return getPrivateKey(ctx, userId, walletId, share, sessionCookie);
|
|
476
|
-
}
|
|
477
|
-
keygen(ctx, userId, type, secretKey, sessionCookie, emailProps) {
|
|
478
|
-
return keygen(ctx, userId, type, secretKey, true, sessionCookie, emailProps);
|
|
479
|
-
}
|
|
480
|
-
refresh(_ctx, _sessionCookie, _userId, _walletId, _share, _oldPartnerId, _newPartnerId) {
|
|
481
|
-
throw new Error("Refresh function is not implemented in the ServerUtils class.");
|
|
482
|
-
}
|
|
483
|
-
preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
|
|
484
|
-
return preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
|
|
485
|
-
}
|
|
486
|
-
signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
487
|
-
return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS);
|
|
488
|
-
}
|
|
489
|
-
signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS) {
|
|
490
|
-
return signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS);
|
|
491
|
-
}
|
|
492
|
-
sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
493
|
-
return sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS);
|
|
494
|
-
}
|
|
495
|
-
signHash(_address, _hash) {
|
|
496
|
-
throw new Error("SignHash is not implemented in the ServerUtils class.");
|
|
497
|
-
}
|
|
498
|
-
ed25519Keygen(ctx, userId, sessionCookie, emailProps) {
|
|
499
|
-
return ed25519Keygen(ctx, userId, sessionCookie, emailProps);
|
|
500
|
-
}
|
|
501
|
-
ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
502
|
-
return ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie);
|
|
503
|
-
}
|
|
504
|
-
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
505
|
-
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
506
|
-
}
|
|
507
|
-
openPopup(_popupUrl) {
|
|
508
|
-
throw new Error("OpenPopup is not implemented in the ServerUtils class.");
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
// src/ParaServer.ts
|
|
513
|
-
var Para = class extends import_core_sdk3.default {
|
|
514
|
-
constructor(env, apiKey, opts) {
|
|
515
|
-
super(env, apiKey, opts);
|
|
516
|
-
if (env !== import_core_sdk3.Environment.PROD && env !== import_core_sdk3.Environment.DEV) {
|
|
517
|
-
Sentry.init({
|
|
518
|
-
environment: env.toLowerCase(),
|
|
519
|
-
dsn: "https://2a26842d951255c2721fde5c1dd2b252@o4504568036720640.ingest.us.sentry.io/4508850906791936"
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
getPlatformUtils() {
|
|
524
|
-
return new ServerUtils();
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Claims a pregenerated wallet.
|
|
528
|
-
*
|
|
529
|
-
* NOTE: This function is only available on the client side.
|
|
530
|
-
* When called from the server SDK, it throws an error.
|
|
531
|
-
*
|
|
532
|
-
* @param {Object} opts the options object.
|
|
533
|
-
* @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet.
|
|
534
|
-
* @param {TPregenIdentifierType} opts.pregenIdentifierType - the type of the identifier.
|
|
535
|
-
* @returns {Promise<string | undefined>} A promise that rejects with an error.
|
|
536
|
-
*/
|
|
537
|
-
claimPregenWallets(_) {
|
|
538
|
-
return __async(this, null, function* () {
|
|
539
|
-
throw new Error(
|
|
540
|
-
"claimPregenWallets is not available in the server SDK. This function is only supported on the client side. Please ensure you are using the client SDK to call this method."
|
|
541
|
-
);
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
// src/index.ts
|
|
547
|
-
var src_default = Para;
|
|
26
|
+
var import_ParaServer = require("./ParaServer.js");
|
|
27
|
+
var src_default = import_ParaServer.Para;
|
|
548
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
549
29
|
0 && (module.exports = {
|
|
550
30
|
Para,
|