@getpara/server-sdk 2.0.0-dev.0 → 2.0.0-dev.2
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 +101 -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 +315 -0
- package/dist/cjs/wallet/privateKey.js +99 -0
- package/dist/cjs/wallet/signing.js +224 -0
- package/dist/cjs/wasm/wasm_exec.js +589 -0
- package/dist/cjs/workers/walletUtils.js +409 -0
- package/dist/cjs/workers/worker.js +62 -907
- package/dist/cjs/workers/workerWrapper.js +130 -0
- package/dist/esm/ParaServer.js +45 -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 -466
- package/dist/esm/package.json +6 -0
- package/dist/esm/wallet/keygen.js +230 -0
- package/dist/esm/wallet/privateKey.js +45 -0
- package/dist/esm/wallet/signing.js +161 -0
- package/dist/esm/{workers/wasm_exec-CFNSOXDO.js → wasm/wasm_exec.js} +68 -74
- package/dist/esm/workers/walletUtils.js +314 -0
- package/dist/esm/workers/worker.js +78 -337
- package/dist/esm/workers/workerWrapper.js +85 -0
- package/dist/types/ParaServer.d.ts +4 -5
- package/dist/types/ServerUtils.d.ts +5 -6
- package/dist/types/wallet/keygen.d.ts +5 -3
- package/dist/types/workers/walletUtils.d.ts +4 -6
- package/dist/types/workers/worker.d.ts +10 -1
- package/dist/types/workers/workerWrapper.d.ts +2 -2
- package/package.json +20 -20
- 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
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
+
mod
|
|
43
|
+
));
|
|
44
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
var __async = (__this, __arguments, generator) => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
var fulfilled = (value) => {
|
|
48
|
+
try {
|
|
49
|
+
step(generator.next(value));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var rejected = (value) => {
|
|
55
|
+
try {
|
|
56
|
+
step(generator.throw(value));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
62
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
var keygen_exports = {};
|
|
66
|
+
__export(keygen_exports, {
|
|
67
|
+
ed25519Keygen: () => ed25519Keygen,
|
|
68
|
+
ed25519PreKeygen: () => ed25519PreKeygen,
|
|
69
|
+
isKeygenComplete: () => isKeygenComplete,
|
|
70
|
+
isPreKeygenComplete: () => isPreKeygenComplete,
|
|
71
|
+
keygen: () => keygen,
|
|
72
|
+
preKeygen: () => preKeygen
|
|
73
|
+
});
|
|
74
|
+
module.exports = __toCommonJS(keygen_exports);
|
|
75
|
+
var uuid = __toESM(require("uuid"));
|
|
76
|
+
var import_core_sdk = require("@getpara/core-sdk");
|
|
77
|
+
var import_workerWrapper = require("../workers/workerWrapper.js");
|
|
78
|
+
function isKeygenComplete(ctx, userId, walletId) {
|
|
79
|
+
return __async(this, null, function* () {
|
|
80
|
+
const wallets = yield ctx.client.getWallets(userId);
|
|
81
|
+
const wallet = wallets.data.wallets.find((w) => w.id === walletId);
|
|
82
|
+
return !!(wallet == null ? void 0 : wallet.address);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
|
|
86
|
+
return __async(this, null, function* () {
|
|
87
|
+
const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
|
|
88
|
+
const wallet = wallets.wallets.find((w) => w.id === walletId);
|
|
89
|
+
return !!(wallet == null ? void 0 : wallet.address);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
93
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
94
|
+
const workId = uuid.v4();
|
|
95
|
+
try {
|
|
96
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
97
|
+
ctx,
|
|
98
|
+
(res) => __async(this, null, function* () {
|
|
99
|
+
try {
|
|
100
|
+
yield (0, import_core_sdk.waitUntilTrue)(() => __async(this, null, function* () {
|
|
101
|
+
return isKeygenComplete(ctx, userId, res.walletId);
|
|
102
|
+
}), 15e3, 1e3);
|
|
103
|
+
resolve({
|
|
104
|
+
signer: res.signer,
|
|
105
|
+
walletId: res.walletId,
|
|
106
|
+
recoveryShare: null
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
reject(error);
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
(error) => {
|
|
113
|
+
reject(error);
|
|
114
|
+
},
|
|
115
|
+
workId,
|
|
116
|
+
{
|
|
117
|
+
userId,
|
|
118
|
+
type,
|
|
119
|
+
functionType: "KEYGEN",
|
|
120
|
+
disableWorkers: ctx.disableWorkers,
|
|
121
|
+
disableWebSockets: ctx.disableWebSockets
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
worker.postMessage({
|
|
125
|
+
env: ctx.env,
|
|
126
|
+
apiKey: ctx.apiKey,
|
|
127
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
128
|
+
params: { userId, secretKey, type },
|
|
129
|
+
functionType: "KEYGEN",
|
|
130
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
131
|
+
disableWorkers: ctx.disableWorkers,
|
|
132
|
+
sessionCookie,
|
|
133
|
+
useDKLS: ctx.useDKLS,
|
|
134
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
135
|
+
wasmOverride: ctx.wasmOverride,
|
|
136
|
+
workId
|
|
137
|
+
});
|
|
138
|
+
} catch (error) {
|
|
139
|
+
reject(error);
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
144
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
145
|
+
const workId = uuid.v4();
|
|
146
|
+
try {
|
|
147
|
+
const email = void 0;
|
|
148
|
+
const params = { pregenIdentifier, pregenIdentifierType, secretKey, partnerId, email, type };
|
|
149
|
+
if (pregenIdentifierType === "EMAIL") {
|
|
150
|
+
params.email = pregenIdentifier;
|
|
151
|
+
}
|
|
152
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
153
|
+
ctx,
|
|
154
|
+
(res) => __async(this, null, function* () {
|
|
155
|
+
try {
|
|
156
|
+
yield (0, import_core_sdk.waitUntilTrue)(
|
|
157
|
+
() => __async(this, null, function* () {
|
|
158
|
+
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
159
|
+
}),
|
|
160
|
+
15e3,
|
|
161
|
+
1e3
|
|
162
|
+
);
|
|
163
|
+
resolve({
|
|
164
|
+
signer: res.signer,
|
|
165
|
+
walletId: res.walletId,
|
|
166
|
+
recoveryShare: null
|
|
167
|
+
});
|
|
168
|
+
} catch (error) {
|
|
169
|
+
reject(error);
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
(error) => {
|
|
173
|
+
reject(error);
|
|
174
|
+
},
|
|
175
|
+
workId,
|
|
176
|
+
__spreadProps(__spreadValues({}, params), {
|
|
177
|
+
secretKey: null,
|
|
178
|
+
functionType: "PREKEYGEN",
|
|
179
|
+
disableWorkers: ctx.disableWorkers,
|
|
180
|
+
disableWebSockets: ctx.disableWebSockets
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
worker.postMessage({
|
|
184
|
+
env: ctx.env,
|
|
185
|
+
apiKey: ctx.apiKey,
|
|
186
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
187
|
+
params,
|
|
188
|
+
functionType: "PREKEYGEN",
|
|
189
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
190
|
+
disableWorkers: ctx.disableWorkers,
|
|
191
|
+
sessionCookie,
|
|
192
|
+
useDKLS: ctx.useDKLS,
|
|
193
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
194
|
+
wasmOverride: ctx.wasmOverride,
|
|
195
|
+
workId
|
|
196
|
+
});
|
|
197
|
+
} catch (error) {
|
|
198
|
+
reject(error);
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
203
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
204
|
+
const workId = uuid.v4();
|
|
205
|
+
try {
|
|
206
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
207
|
+
ctx,
|
|
208
|
+
(res) => __async(this, null, function* () {
|
|
209
|
+
try {
|
|
210
|
+
yield (0, import_core_sdk.waitUntilTrue)(() => __async(this, null, function* () {
|
|
211
|
+
return isKeygenComplete(ctx, userId, res.walletId);
|
|
212
|
+
}), 15e3, 1e3);
|
|
213
|
+
resolve({
|
|
214
|
+
signer: res.signer,
|
|
215
|
+
walletId: res.walletId,
|
|
216
|
+
recoveryShare: null
|
|
217
|
+
});
|
|
218
|
+
} catch (error) {
|
|
219
|
+
reject(error);
|
|
220
|
+
}
|
|
221
|
+
}),
|
|
222
|
+
(error) => {
|
|
223
|
+
reject(error);
|
|
224
|
+
},
|
|
225
|
+
workId,
|
|
226
|
+
{
|
|
227
|
+
userId,
|
|
228
|
+
functionType: "ED25519_KEYGEN",
|
|
229
|
+
disableWorkers: ctx.disableWorkers,
|
|
230
|
+
disableWebSockets: ctx.disableWebSockets
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
worker.postMessage({
|
|
234
|
+
env: ctx.env,
|
|
235
|
+
apiKey: ctx.apiKey,
|
|
236
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
237
|
+
params: { userId },
|
|
238
|
+
functionType: "ED25519_KEYGEN",
|
|
239
|
+
disableWorkers: ctx.disableWorkers,
|
|
240
|
+
sessionCookie,
|
|
241
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
242
|
+
wasmOverride: ctx.wasmOverride,
|
|
243
|
+
workId
|
|
244
|
+
});
|
|
245
|
+
} catch (error) {
|
|
246
|
+
reject(error);
|
|
247
|
+
}
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
251
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
252
|
+
const workId = uuid.v4();
|
|
253
|
+
try {
|
|
254
|
+
const email = void 0;
|
|
255
|
+
const params = { pregenIdentifier, pregenIdentifierType, email };
|
|
256
|
+
if (pregenIdentifierType === "EMAIL") {
|
|
257
|
+
params.email = pregenIdentifier;
|
|
258
|
+
}
|
|
259
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
260
|
+
ctx,
|
|
261
|
+
(res) => __async(this, null, function* () {
|
|
262
|
+
try {
|
|
263
|
+
yield (0, import_core_sdk.waitUntilTrue)(
|
|
264
|
+
() => __async(this, null, function* () {
|
|
265
|
+
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
266
|
+
}),
|
|
267
|
+
15e3,
|
|
268
|
+
1e3
|
|
269
|
+
);
|
|
270
|
+
resolve({
|
|
271
|
+
signer: res.signer,
|
|
272
|
+
walletId: res.walletId,
|
|
273
|
+
recoveryShare: null
|
|
274
|
+
});
|
|
275
|
+
} catch (error) {
|
|
276
|
+
reject(error);
|
|
277
|
+
}
|
|
278
|
+
}),
|
|
279
|
+
(error) => {
|
|
280
|
+
reject(error);
|
|
281
|
+
},
|
|
282
|
+
workId,
|
|
283
|
+
{
|
|
284
|
+
params,
|
|
285
|
+
functionType: "ED25519_PREKEYGEN",
|
|
286
|
+
disableWorkers: ctx.disableWorkers,
|
|
287
|
+
disableWebSockets: ctx.disableWebSockets
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
worker.postMessage({
|
|
291
|
+
env: ctx.env,
|
|
292
|
+
apiKey: ctx.apiKey,
|
|
293
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
294
|
+
params,
|
|
295
|
+
functionType: "ED25519_PREKEYGEN",
|
|
296
|
+
disableWorkers: ctx.disableWorkers,
|
|
297
|
+
sessionCookie,
|
|
298
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
299
|
+
wasmOverride: ctx.wasmOverride,
|
|
300
|
+
workId
|
|
301
|
+
});
|
|
302
|
+
} catch (error) {
|
|
303
|
+
reject(error);
|
|
304
|
+
}
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
308
|
+
0 && (module.exports = {
|
|
309
|
+
ed25519Keygen,
|
|
310
|
+
ed25519PreKeygen,
|
|
311
|
+
isKeygenComplete,
|
|
312
|
+
isPreKeygenComplete,
|
|
313
|
+
keygen,
|
|
314
|
+
preKeygen
|
|
315
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var privateKey_exports = {};
|
|
49
|
+
__export(privateKey_exports, {
|
|
50
|
+
getPrivateKey: () => getPrivateKey
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(privateKey_exports);
|
|
53
|
+
var uuid = __toESM(require("uuid"));
|
|
54
|
+
var import_workerWrapper = require("../workers/workerWrapper.js");
|
|
55
|
+
function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
56
|
+
return __async(this, null, function* () {
|
|
57
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
58
|
+
const workId = uuid.v4();
|
|
59
|
+
try {
|
|
60
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
61
|
+
ctx,
|
|
62
|
+
(res) => __async(this, null, function* () {
|
|
63
|
+
resolve(res.privateKey);
|
|
64
|
+
}),
|
|
65
|
+
(error) => {
|
|
66
|
+
reject(error);
|
|
67
|
+
},
|
|
68
|
+
workId,
|
|
69
|
+
{
|
|
70
|
+
params: { walletId, userId },
|
|
71
|
+
functionType: "GET_PRIVATE_KEY",
|
|
72
|
+
disableWorkers: ctx.disableWorkers,
|
|
73
|
+
disableWebSockets: ctx.disableWebSockets
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
worker.postMessage({
|
|
77
|
+
env: ctx.env,
|
|
78
|
+
apiKey: ctx.apiKey,
|
|
79
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
80
|
+
params: { share, walletId, userId },
|
|
81
|
+
functionType: "GET_PRIVATE_KEY",
|
|
82
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
83
|
+
disableWorkers: ctx.disableWorkers,
|
|
84
|
+
sessionCookie,
|
|
85
|
+
useDKLS: ctx.useDKLS,
|
|
86
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
87
|
+
wasmOverride: ctx.wasmOverride,
|
|
88
|
+
workId
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
reject(error);
|
|
92
|
+
}
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
getPrivateKey
|
|
99
|
+
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var signing_exports = {};
|
|
49
|
+
__export(signing_exports, {
|
|
50
|
+
ed25519Sign: () => ed25519Sign,
|
|
51
|
+
sendTransaction: () => sendTransaction,
|
|
52
|
+
signMessage: () => signMessage,
|
|
53
|
+
signTransaction: () => signTransaction
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(signing_exports);
|
|
56
|
+
var uuid = __toESM(require("uuid"));
|
|
57
|
+
var import_workerWrapper = require("../workers/workerWrapper.js");
|
|
58
|
+
function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
59
|
+
return __async(this, null, function* () {
|
|
60
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
61
|
+
const workId = uuid.v4();
|
|
62
|
+
try {
|
|
63
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
64
|
+
ctx,
|
|
65
|
+
(sendTransactionRes) => __async(this, null, function* () {
|
|
66
|
+
resolve(sendTransactionRes);
|
|
67
|
+
}),
|
|
68
|
+
(error) => {
|
|
69
|
+
reject(error);
|
|
70
|
+
},
|
|
71
|
+
workId,
|
|
72
|
+
{
|
|
73
|
+
params: { walletId, userId, tx, chainId },
|
|
74
|
+
functionType: "SIGN_TRANSACTION",
|
|
75
|
+
disableWorkers: ctx.disableWorkers,
|
|
76
|
+
disableWebSockets: ctx.disableWebSockets
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
worker.postMessage({
|
|
80
|
+
env: ctx.env,
|
|
81
|
+
apiKey: ctx.apiKey,
|
|
82
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
83
|
+
params: { share, walletId, userId, tx, chainId },
|
|
84
|
+
functionType: "SIGN_TRANSACTION",
|
|
85
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
86
|
+
disableWorkers: ctx.disableWorkers,
|
|
87
|
+
sessionCookie,
|
|
88
|
+
useDKLS: isDKLS,
|
|
89
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
90
|
+
wasmOverride: ctx.wasmOverride,
|
|
91
|
+
workId
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
reject(error);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
100
|
+
return __async(this, null, function* () {
|
|
101
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
102
|
+
const workId = uuid.v4();
|
|
103
|
+
try {
|
|
104
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
105
|
+
ctx,
|
|
106
|
+
(sendTransactionRes) => __async(this, null, function* () {
|
|
107
|
+
resolve(sendTransactionRes);
|
|
108
|
+
}),
|
|
109
|
+
(error) => {
|
|
110
|
+
reject(error);
|
|
111
|
+
},
|
|
112
|
+
workId,
|
|
113
|
+
{
|
|
114
|
+
params: { walletId, userId, tx, chainId },
|
|
115
|
+
functionType: "SEND_TRANSACTION",
|
|
116
|
+
disableWorkers: ctx.disableWorkers,
|
|
117
|
+
disableWebSockets: ctx.disableWebSockets
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
worker.postMessage({
|
|
121
|
+
env: ctx.env,
|
|
122
|
+
apiKey: ctx.apiKey,
|
|
123
|
+
params: { share, walletId, userId, tx, chainId },
|
|
124
|
+
functionType: "SEND_TRANSACTION",
|
|
125
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
126
|
+
disableWorkers: ctx.disableWorkers,
|
|
127
|
+
sessionCookie,
|
|
128
|
+
useDKLS: isDKLS,
|
|
129
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
130
|
+
wasmOverride: ctx.wasmOverride,
|
|
131
|
+
workId
|
|
132
|
+
});
|
|
133
|
+
} catch (error) {
|
|
134
|
+
reject(error);
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
140
|
+
return __async(this, null, function* () {
|
|
141
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
142
|
+
const workId = uuid.v4();
|
|
143
|
+
try {
|
|
144
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
145
|
+
ctx,
|
|
146
|
+
(signMessageRes) => __async(this, null, function* () {
|
|
147
|
+
resolve(signMessageRes);
|
|
148
|
+
}),
|
|
149
|
+
(error) => {
|
|
150
|
+
reject(error);
|
|
151
|
+
},
|
|
152
|
+
workId,
|
|
153
|
+
{
|
|
154
|
+
params: { walletId, userId, message },
|
|
155
|
+
functionType: "SIGN_MESSAGE",
|
|
156
|
+
disableWorkers: ctx.disableWorkers,
|
|
157
|
+
disableWebSockets: ctx.disableWebSockets
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
worker.postMessage({
|
|
161
|
+
env: ctx.env,
|
|
162
|
+
apiKey: ctx.apiKey,
|
|
163
|
+
params: { share, walletId, userId, message },
|
|
164
|
+
functionType: "SIGN_MESSAGE",
|
|
165
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
166
|
+
disableWorkers: ctx.disableWorkers,
|
|
167
|
+
sessionCookie,
|
|
168
|
+
useDKLS: isDKLS,
|
|
169
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
170
|
+
wasmOverride: ctx.wasmOverride,
|
|
171
|
+
workId
|
|
172
|
+
});
|
|
173
|
+
} catch (error) {
|
|
174
|
+
reject(error);
|
|
175
|
+
}
|
|
176
|
+
}));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
180
|
+
return __async(this, null, function* () {
|
|
181
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
182
|
+
const workId = uuid.v4();
|
|
183
|
+
try {
|
|
184
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
185
|
+
ctx,
|
|
186
|
+
(signMessageRes) => __async(this, null, function* () {
|
|
187
|
+
resolve(signMessageRes);
|
|
188
|
+
}),
|
|
189
|
+
(error) => {
|
|
190
|
+
reject(error);
|
|
191
|
+
},
|
|
192
|
+
workId,
|
|
193
|
+
{
|
|
194
|
+
params: { walletId, userId, base64Bytes },
|
|
195
|
+
functionType: "ED25519_SIGN",
|
|
196
|
+
disableWorkers: ctx.disableWorkers,
|
|
197
|
+
disableWebSockets: ctx.disableWebSockets
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
worker.postMessage({
|
|
201
|
+
env: ctx.env,
|
|
202
|
+
apiKey: ctx.apiKey,
|
|
203
|
+
params: { share, walletId, userId, base64Bytes },
|
|
204
|
+
functionType: "ED25519_SIGN",
|
|
205
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
206
|
+
disableWorkers: ctx.disableWorkers,
|
|
207
|
+
sessionCookie,
|
|
208
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
209
|
+
wasmOverride: ctx.wasmOverride,
|
|
210
|
+
workId
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
reject(error);
|
|
214
|
+
}
|
|
215
|
+
}));
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
ed25519Sign,
|
|
221
|
+
sendTransaction,
|
|
222
|
+
signMessage,
|
|
223
|
+
signTransaction
|
|
224
|
+
});
|