@getpara/server-sdk 2.0.0-alpha.15 → 2.0.0-alpha.17
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/wallet/keygen.js +214 -128
- package/dist/cjs/wallet/privateKey.js +35 -22
- package/dist/cjs/wallet/signing.js +136 -84
- package/dist/cjs/workers/workerWrapper.js +38 -6
- package/dist/esm/wallet/keygen.js +190 -120
- package/dist/esm/wallet/privateKey.js +35 -22
- package/dist/esm/wallet/signing.js +136 -84
- package/dist/esm/workers/workerWrapper.js +38 -6
- package/dist/types/workers/workerWrapper.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
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));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -73,149 +90,218 @@ function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, wallet
|
|
|
73
90
|
});
|
|
74
91
|
}
|
|
75
92
|
function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
76
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
93
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
77
94
|
const workId = uuid.v4();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
+
}
|
|
106
141
|
}));
|
|
107
142
|
}
|
|
108
143
|
function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
109
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
144
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
110
145
|
const workId = uuid.v4();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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);
|
|
133
199
|
}
|
|
134
|
-
worker.postMessage({
|
|
135
|
-
env: ctx.env,
|
|
136
|
-
apiKey: ctx.apiKey,
|
|
137
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
138
|
-
params,
|
|
139
|
-
functionType: "PREKEYGEN",
|
|
140
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
141
|
-
disableWorkers: ctx.disableWorkers,
|
|
142
|
-
sessionCookie,
|
|
143
|
-
useDKLS: ctx.useDKLS,
|
|
144
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
145
|
-
wasmOverride: ctx.wasmOverride,
|
|
146
|
-
workId
|
|
147
|
-
});
|
|
148
200
|
}));
|
|
149
201
|
}
|
|
150
202
|
function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
151
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
203
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
152
204
|
const workId = uuid.v4();
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
+
}
|
|
179
248
|
}));
|
|
180
249
|
}
|
|
181
250
|
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
182
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
251
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
183
252
|
const workId = uuid.v4();
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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);
|
|
206
304
|
}
|
|
207
|
-
worker.postMessage({
|
|
208
|
-
env: ctx.env,
|
|
209
|
-
apiKey: ctx.apiKey,
|
|
210
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
211
|
-
params,
|
|
212
|
-
functionType: "ED25519_PREKEYGEN",
|
|
213
|
-
disableWorkers: ctx.disableWorkers,
|
|
214
|
-
sessionCookie,
|
|
215
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
216
|
-
wasmOverride: ctx.wasmOverride,
|
|
217
|
-
workId
|
|
218
|
-
});
|
|
219
305
|
}));
|
|
220
306
|
}
|
|
221
307
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -54,29 +54,42 @@ var uuid = __toESM(require("uuid"));
|
|
|
54
54
|
var import_workerWrapper = require("../workers/workerWrapper.js");
|
|
55
55
|
function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
56
56
|
return __async(this, null, function* () {
|
|
57
|
-
return
|
|
57
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
58
58
|
const workId = uuid.v4();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
}
|
|
80
93
|
}));
|
|
81
94
|
});
|
|
82
95
|
}
|