@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
|
@@ -0,0 +1,229 @@
|
|
|
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 keygen_exports = {};
|
|
49
|
+
__export(keygen_exports, {
|
|
50
|
+
ed25519Keygen: () => ed25519Keygen,
|
|
51
|
+
ed25519PreKeygen: () => ed25519PreKeygen,
|
|
52
|
+
isKeygenComplete: () => isKeygenComplete,
|
|
53
|
+
isPreKeygenComplete: () => isPreKeygenComplete,
|
|
54
|
+
keygen: () => keygen,
|
|
55
|
+
preKeygen: () => preKeygen
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(keygen_exports);
|
|
58
|
+
var uuid = __toESM(require("uuid"));
|
|
59
|
+
var import_core_sdk = require("@getpara/core-sdk");
|
|
60
|
+
var import_workerWrapper = require("../workers/workerWrapper.js");
|
|
61
|
+
function isKeygenComplete(ctx, userId, walletId) {
|
|
62
|
+
return __async(this, null, function* () {
|
|
63
|
+
const wallets = yield ctx.client.getWallets(userId);
|
|
64
|
+
const wallet = wallets.data.wallets.find((w) => w.id === walletId);
|
|
65
|
+
return !!(wallet == null ? void 0 : wallet.address);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
|
|
69
|
+
return __async(this, null, function* () {
|
|
70
|
+
const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
|
|
71
|
+
const wallet = wallets.wallets.find((w) => w.id === walletId);
|
|
72
|
+
return !!(wallet == null ? void 0 : wallet.address);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
76
|
+
return new Promise((resolve) => __async(this, null, function* () {
|
|
77
|
+
const workId = uuid.v4();
|
|
78
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
79
|
+
ctx,
|
|
80
|
+
(res) => __async(this, null, function* () {
|
|
81
|
+
yield (0, import_core_sdk.waitUntilTrue)(() => __async(this, null, function* () {
|
|
82
|
+
return isKeygenComplete(ctx, userId, res.walletId);
|
|
83
|
+
}), 15e3, 1e3);
|
|
84
|
+
resolve({
|
|
85
|
+
signer: res.signer,
|
|
86
|
+
walletId: res.walletId,
|
|
87
|
+
recoveryShare: null
|
|
88
|
+
});
|
|
89
|
+
}),
|
|
90
|
+
workId
|
|
91
|
+
);
|
|
92
|
+
worker.postMessage({
|
|
93
|
+
env: ctx.env,
|
|
94
|
+
apiKey: ctx.apiKey,
|
|
95
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
96
|
+
params: { userId, secretKey, type },
|
|
97
|
+
functionType: "KEYGEN",
|
|
98
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
99
|
+
disableWorkers: ctx.disableWorkers,
|
|
100
|
+
sessionCookie,
|
|
101
|
+
useDKLS: ctx.useDKLS,
|
|
102
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
103
|
+
wasmOverride: ctx.wasmOverride,
|
|
104
|
+
workId
|
|
105
|
+
});
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
109
|
+
return new Promise((resolve) => __async(this, null, function* () {
|
|
110
|
+
const workId = uuid.v4();
|
|
111
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
112
|
+
ctx,
|
|
113
|
+
(res) => __async(this, null, function* () {
|
|
114
|
+
yield (0, import_core_sdk.waitUntilTrue)(
|
|
115
|
+
() => __async(this, null, function* () {
|
|
116
|
+
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
117
|
+
}),
|
|
118
|
+
15e3,
|
|
119
|
+
1e3
|
|
120
|
+
);
|
|
121
|
+
resolve({
|
|
122
|
+
signer: res.signer,
|
|
123
|
+
walletId: res.walletId,
|
|
124
|
+
recoveryShare: null
|
|
125
|
+
});
|
|
126
|
+
}),
|
|
127
|
+
workId
|
|
128
|
+
);
|
|
129
|
+
const email = void 0;
|
|
130
|
+
const params = { pregenIdentifier, pregenIdentifierType, secretKey, partnerId, email, type };
|
|
131
|
+
if (pregenIdentifierType === "EMAIL") {
|
|
132
|
+
params.email = pregenIdentifier;
|
|
133
|
+
}
|
|
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
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
151
|
+
return new Promise((resolve) => __async(this, null, function* () {
|
|
152
|
+
const workId = uuid.v4();
|
|
153
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
154
|
+
ctx,
|
|
155
|
+
(res) => __async(this, null, function* () {
|
|
156
|
+
yield (0, import_core_sdk.waitUntilTrue)(() => __async(this, null, function* () {
|
|
157
|
+
return isKeygenComplete(ctx, userId, res.walletId);
|
|
158
|
+
}), 15e3, 1e3);
|
|
159
|
+
resolve({
|
|
160
|
+
signer: res.signer,
|
|
161
|
+
walletId: res.walletId,
|
|
162
|
+
recoveryShare: null
|
|
163
|
+
});
|
|
164
|
+
}),
|
|
165
|
+
workId
|
|
166
|
+
);
|
|
167
|
+
worker.postMessage({
|
|
168
|
+
env: ctx.env,
|
|
169
|
+
apiKey: ctx.apiKey,
|
|
170
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
171
|
+
params: { userId },
|
|
172
|
+
functionType: "ED25519_KEYGEN",
|
|
173
|
+
disableWorkers: ctx.disableWorkers,
|
|
174
|
+
sessionCookie,
|
|
175
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
176
|
+
wasmOverride: ctx.wasmOverride,
|
|
177
|
+
workId
|
|
178
|
+
});
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
182
|
+
return new Promise((resolve) => __async(this, null, function* () {
|
|
183
|
+
const workId = uuid.v4();
|
|
184
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
185
|
+
ctx,
|
|
186
|
+
(res) => __async(this, null, function* () {
|
|
187
|
+
yield (0, import_core_sdk.waitUntilTrue)(
|
|
188
|
+
() => __async(this, null, function* () {
|
|
189
|
+
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
190
|
+
}),
|
|
191
|
+
15e3,
|
|
192
|
+
1e3
|
|
193
|
+
);
|
|
194
|
+
resolve({
|
|
195
|
+
signer: res.signer,
|
|
196
|
+
walletId: res.walletId,
|
|
197
|
+
recoveryShare: null
|
|
198
|
+
});
|
|
199
|
+
}),
|
|
200
|
+
workId
|
|
201
|
+
);
|
|
202
|
+
const email = void 0;
|
|
203
|
+
const params = { pregenIdentifier, pregenIdentifierType, email };
|
|
204
|
+
if (pregenIdentifierType === "EMAIL") {
|
|
205
|
+
params.email = pregenIdentifier;
|
|
206
|
+
}
|
|
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
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
222
|
+
0 && (module.exports = {
|
|
223
|
+
ed25519Keygen,
|
|
224
|
+
ed25519PreKeygen,
|
|
225
|
+
isKeygenComplete,
|
|
226
|
+
isPreKeygenComplete,
|
|
227
|
+
keygen,
|
|
228
|
+
preKeygen
|
|
229
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
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 yield new Promise((resolve) => __async(this, null, function* () {
|
|
58
|
+
const workId = uuid.v4();
|
|
59
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
60
|
+
ctx,
|
|
61
|
+
(res) => __async(this, null, function* () {
|
|
62
|
+
resolve(res.privateKey);
|
|
63
|
+
}),
|
|
64
|
+
workId
|
|
65
|
+
);
|
|
66
|
+
worker.postMessage({
|
|
67
|
+
env: ctx.env,
|
|
68
|
+
apiKey: ctx.apiKey,
|
|
69
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
70
|
+
params: { share, walletId, userId },
|
|
71
|
+
functionType: "GET_PRIVATE_KEY",
|
|
72
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
73
|
+
disableWorkers: ctx.disableWorkers,
|
|
74
|
+
sessionCookie,
|
|
75
|
+
useDKLS: ctx.useDKLS,
|
|
76
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
77
|
+
wasmOverride: ctx.wasmOverride,
|
|
78
|
+
workId
|
|
79
|
+
});
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
getPrivateKey
|
|
86
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
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 yield new Promise((resolve) => __async(this, null, function* () {
|
|
61
|
+
const workId = uuid.v4();
|
|
62
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
63
|
+
ctx,
|
|
64
|
+
(sendTransactionRes) => __async(this, null, function* () {
|
|
65
|
+
resolve(sendTransactionRes);
|
|
66
|
+
}),
|
|
67
|
+
workId
|
|
68
|
+
);
|
|
69
|
+
worker.postMessage({
|
|
70
|
+
env: ctx.env,
|
|
71
|
+
apiKey: ctx.apiKey,
|
|
72
|
+
cosmosPrefix: ctx.cosmosPrefix,
|
|
73
|
+
params: { share, walletId, userId, tx, chainId },
|
|
74
|
+
functionType: "SIGN_TRANSACTION",
|
|
75
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
76
|
+
disableWorkers: ctx.disableWorkers,
|
|
77
|
+
sessionCookie,
|
|
78
|
+
useDKLS: isDKLS,
|
|
79
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
80
|
+
wasmOverride: ctx.wasmOverride,
|
|
81
|
+
workId
|
|
82
|
+
});
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
87
|
+
return __async(this, null, function* () {
|
|
88
|
+
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
89
|
+
const workId = uuid.v4();
|
|
90
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
91
|
+
ctx,
|
|
92
|
+
(sendTransactionRes) => __async(this, null, function* () {
|
|
93
|
+
resolve(sendTransactionRes);
|
|
94
|
+
}),
|
|
95
|
+
workId
|
|
96
|
+
);
|
|
97
|
+
worker.postMessage({
|
|
98
|
+
env: ctx.env,
|
|
99
|
+
apiKey: ctx.apiKey,
|
|
100
|
+
params: { share, walletId, userId, tx, chainId },
|
|
101
|
+
functionType: "SEND_TRANSACTION",
|
|
102
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
103
|
+
disableWorkers: ctx.disableWorkers,
|
|
104
|
+
sessionCookie,
|
|
105
|
+
useDKLS: isDKLS,
|
|
106
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
107
|
+
wasmOverride: ctx.wasmOverride,
|
|
108
|
+
workId
|
|
109
|
+
});
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
114
|
+
return __async(this, null, function* () {
|
|
115
|
+
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
116
|
+
const workId = uuid.v4();
|
|
117
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
118
|
+
ctx,
|
|
119
|
+
(signMessageRes) => __async(this, null, function* () {
|
|
120
|
+
resolve(signMessageRes);
|
|
121
|
+
}),
|
|
122
|
+
workId
|
|
123
|
+
);
|
|
124
|
+
worker.postMessage({
|
|
125
|
+
env: ctx.env,
|
|
126
|
+
apiKey: ctx.apiKey,
|
|
127
|
+
params: { share, walletId, userId, message },
|
|
128
|
+
functionType: "SIGN_MESSAGE",
|
|
129
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
130
|
+
disableWorkers: ctx.disableWorkers,
|
|
131
|
+
sessionCookie,
|
|
132
|
+
useDKLS: isDKLS,
|
|
133
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
134
|
+
wasmOverride: ctx.wasmOverride,
|
|
135
|
+
workId
|
|
136
|
+
});
|
|
137
|
+
}));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
141
|
+
return __async(this, null, function* () {
|
|
142
|
+
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
143
|
+
const workId = uuid.v4();
|
|
144
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
145
|
+
ctx,
|
|
146
|
+
(signMessageRes) => __async(this, null, function* () {
|
|
147
|
+
resolve(signMessageRes);
|
|
148
|
+
}),
|
|
149
|
+
workId
|
|
150
|
+
);
|
|
151
|
+
worker.postMessage({
|
|
152
|
+
env: ctx.env,
|
|
153
|
+
apiKey: ctx.apiKey,
|
|
154
|
+
params: { share, walletId, userId, base64Bytes },
|
|
155
|
+
functionType: "ED25519_SIGN",
|
|
156
|
+
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
157
|
+
disableWorkers: ctx.disableWorkers,
|
|
158
|
+
sessionCookie,
|
|
159
|
+
disableWebSockets: ctx.disableWebSockets,
|
|
160
|
+
wasmOverride: ctx.wasmOverride,
|
|
161
|
+
workId
|
|
162
|
+
});
|
|
163
|
+
}));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
ed25519Sign,
|
|
169
|
+
sendTransaction,
|
|
170
|
+
signMessage,
|
|
171
|
+
signTransaction
|
|
172
|
+
});
|