@getpara/web-sdk 1.2.0 → 1.3.1
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/index.js +4 -9
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/workers/worker.js +3 -128
- package/dist/workers/worker.js.br +0 -0
- package/dist/workers/worker.js.gz +0 -0
- package/package.json +7 -5
- package/dist/LocalStorage.js +0 -34
- package/dist/ParaWeb.js +0 -7
- package/dist/SessionStorage.js +0 -38
- package/dist/WebUtils.js +0 -113
- package/dist/cryptography/webAuth.js +0 -167
- package/dist/errors.js +0 -7
- package/dist/utils/emailUtils.js +0 -5
- package/dist/utils/formattingUtils.js +0 -28
- package/dist/utils/isMobile.js +0 -39
- package/dist/utils/truncateEthAddress.js +0 -8
- package/dist/wallet/keygen.js +0 -185
- package/dist/wallet/privateKey.js +0 -33
- package/dist/wallet/signing.js +0 -100
- package/dist/wasm/wasm_exec.js +0 -513
- package/dist/workers/walletUtils.js +0 -244
- package/dist/workers/workerWrapper.js +0 -50
package/dist/errors.js
DELETED
package/dist/utils/emailUtils.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export function getMailtoLink(email, recoveryShare) {
|
|
2
|
-
const emailBody = `Hello,%0D%0DBelow is your Para Recovery Secret. Keep this safe!%0D%0D${recoveryShare}%0D%0DPlease get in touch via support@getpara.com if you have any questions`;
|
|
3
|
-
const mailText = `mailto:${email}?subject=Para%20Recovery%20Secret&body=${emailBody}`;
|
|
4
|
-
return mailText;
|
|
5
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export function hexStringToBase64(hexString) {
|
|
2
|
-
if (hexString.substring(0, 2) === '0x') {
|
|
3
|
-
hexString = hexString.substring(2);
|
|
4
|
-
}
|
|
5
|
-
return Buffer.from(hexString, 'hex').toString('base64');
|
|
6
|
-
}
|
|
7
|
-
export function hexToSignature(hexSig) {
|
|
8
|
-
return {
|
|
9
|
-
r: `0x${hexSig.slice(2, 66)}`,
|
|
10
|
-
s: `0x${hexSig.slice(66, 130)}`,
|
|
11
|
-
v: BigInt(hexSig.slice(130, 132)),
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function hexToUint8Array(hex) {
|
|
15
|
-
if (hex.startsWith('0x')) {
|
|
16
|
-
hex = hex.slice(2);
|
|
17
|
-
}
|
|
18
|
-
return new Uint8Array(Buffer.from(hex, 'hex'));
|
|
19
|
-
}
|
|
20
|
-
export function hexToDecimal(hex) {
|
|
21
|
-
if (hex.startsWith('0x')) {
|
|
22
|
-
hex = hex.slice(2);
|
|
23
|
-
}
|
|
24
|
-
return `${parseInt(hex, 16)}`;
|
|
25
|
-
}
|
|
26
|
-
export function decimalToHex(decimal) {
|
|
27
|
-
return `0x${parseInt(decimal).toString(16)}`;
|
|
28
|
-
}
|
package/dist/utils/isMobile.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export function isAndroid() {
|
|
2
|
-
return typeof navigator !== 'undefined' && /android/i.test(navigator.userAgent);
|
|
3
|
-
}
|
|
4
|
-
export function isSmallIOS() {
|
|
5
|
-
return typeof navigator !== 'undefined' && /iPhone|iPod/.test(navigator.userAgent);
|
|
6
|
-
}
|
|
7
|
-
export function isLargeIOS() {
|
|
8
|
-
return (typeof navigator !== 'undefined' &&
|
|
9
|
-
(/iPad/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)));
|
|
10
|
-
}
|
|
11
|
-
export function isTablet() {
|
|
12
|
-
return (typeof navigator !== 'undefined' &&
|
|
13
|
-
/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(navigator.userAgent));
|
|
14
|
-
}
|
|
15
|
-
export function isIOS() {
|
|
16
|
-
return isSmallIOS() || isLargeIOS();
|
|
17
|
-
}
|
|
18
|
-
export function isMobile() {
|
|
19
|
-
return isAndroid() || isIOS();
|
|
20
|
-
}
|
|
21
|
-
export function isSafari() {
|
|
22
|
-
return (typeof navigator !== 'undefined' &&
|
|
23
|
-
/AppleWebKit/i.test(navigator.userAgent) &&
|
|
24
|
-
!/CriOS/i.test(navigator.userAgent) &&
|
|
25
|
-
!/Chrome/i.test(navigator.userAgent));
|
|
26
|
-
}
|
|
27
|
-
export function isIOSWebview() {
|
|
28
|
-
const isStandalone = typeof navigator !== 'undefined' && !navigator.standalone;
|
|
29
|
-
return typeof navigator !== 'undefined' && isIOS() && !isStandalone && !/safari/i.test(navigator.userAgent.toLowerCase());
|
|
30
|
-
}
|
|
31
|
-
export function isMobileSafari() {
|
|
32
|
-
return isMobile() && isSafari();
|
|
33
|
-
}
|
|
34
|
-
export function isTelegram() {
|
|
35
|
-
return (typeof window !== 'undefined' &&
|
|
36
|
-
(Boolean(window.TelegramWebviewProxy) ||
|
|
37
|
-
Boolean(window.Telegram) ||
|
|
38
|
-
Boolean(window.TelegramWebviewProxyProto)));
|
|
39
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Captures 0x + 4 characters, then the last 4 characters.
|
|
2
|
-
const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/;
|
|
3
|
-
export const truncateEthAddress = (address) => {
|
|
4
|
-
const match = address.match(truncateRegex);
|
|
5
|
-
if (!match)
|
|
6
|
-
return address;
|
|
7
|
-
return `${match[1]}…${match[2]}`;
|
|
8
|
-
};
|
package/dist/wallet/keygen.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { setupWorker } from '../workers/workerWrapper.js';
|
|
11
|
-
import { distributeNewShare, waitUntilTrue } from '@getpara/core-sdk';
|
|
12
|
-
function isKeygenComplete(ctx, userId, walletId) {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
const wallets = yield ctx.client.getWallets(userId);
|
|
15
|
-
const wallet = wallets.data.wallets.find(w => w.id === walletId);
|
|
16
|
-
return !!wallet.address;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function isRefreshComplete(ctx, userId, walletId, partnerId, protocolId) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const { isDone } = yield ctx.client.isRefreshDone(userId, walletId, partnerId, protocolId);
|
|
22
|
-
return isDone;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
|
|
28
|
-
const wallet = wallets.wallets.find(w => w.id === walletId);
|
|
29
|
-
return !!wallet.address;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
export function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, emailProps = {}) {
|
|
33
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isKeygenComplete(ctx, userId, res.walletId); }), 15000, 1000);
|
|
36
|
-
if (skipDistribute) {
|
|
37
|
-
resolve({
|
|
38
|
-
signer: res.signer,
|
|
39
|
-
walletId: res.walletId,
|
|
40
|
-
recoveryShare: null,
|
|
41
|
-
});
|
|
42
|
-
worker.terminate();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const recoveryShare = yield distributeNewShare({
|
|
46
|
-
ctx,
|
|
47
|
-
userId,
|
|
48
|
-
walletId: res.walletId,
|
|
49
|
-
userShare: res.signer,
|
|
50
|
-
emailProps,
|
|
51
|
-
});
|
|
52
|
-
resolve({
|
|
53
|
-
signer: res.signer,
|
|
54
|
-
walletId: res.walletId,
|
|
55
|
-
recoveryShare,
|
|
56
|
-
});
|
|
57
|
-
worker.terminate();
|
|
58
|
-
}));
|
|
59
|
-
worker.postMessage({
|
|
60
|
-
env: ctx.env,
|
|
61
|
-
apiKey: ctx.apiKey,
|
|
62
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
63
|
-
params: { userId, secretKey, type },
|
|
64
|
-
functionType: 'KEYGEN',
|
|
65
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
66
|
-
disableWorkers: ctx.disableWorkers,
|
|
67
|
-
sessionCookie,
|
|
68
|
-
useDKLS: ctx.useDKLS,
|
|
69
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
70
|
-
wasmOverride: ctx.wasmOverride,
|
|
71
|
-
});
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
export function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
75
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId); }), 15000, 1000);
|
|
78
|
-
resolve({
|
|
79
|
-
signer: res.signer,
|
|
80
|
-
walletId: res.walletId,
|
|
81
|
-
recoveryShare: null,
|
|
82
|
-
});
|
|
83
|
-
worker.terminate();
|
|
84
|
-
}));
|
|
85
|
-
const email = undefined;
|
|
86
|
-
const params = { pregenIdentifier, pregenIdentifierType, type, secretKey, partnerId, email };
|
|
87
|
-
if (pregenIdentifierType === 'EMAIL') {
|
|
88
|
-
params.email = pregenIdentifier;
|
|
89
|
-
}
|
|
90
|
-
worker.postMessage({
|
|
91
|
-
env: ctx.env,
|
|
92
|
-
apiKey: ctx.apiKey,
|
|
93
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
94
|
-
params: params,
|
|
95
|
-
functionType: 'PREKEYGEN',
|
|
96
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
97
|
-
disableWorkers: ctx.disableWorkers,
|
|
98
|
-
sessionCookie,
|
|
99
|
-
useDKLS: ctx.useDKLS,
|
|
100
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
101
|
-
wasmOverride: ctx.wasmOverride,
|
|
102
|
-
});
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
export function refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
|
|
106
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
/* v8 ignore next 3 */
|
|
109
|
-
if (!(yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isRefreshComplete(ctx, userId, walletId, newPartnerId); }), 15000, 1000))) {
|
|
110
|
-
throw new Error('refresh failed');
|
|
111
|
-
}
|
|
112
|
-
const { protocolId, signer } = res;
|
|
113
|
-
resolve({
|
|
114
|
-
signer,
|
|
115
|
-
protocolId,
|
|
116
|
-
});
|
|
117
|
-
worker.terminate();
|
|
118
|
-
}));
|
|
119
|
-
worker.postMessage({
|
|
120
|
-
env: ctx.env,
|
|
121
|
-
apiKey: ctx.apiKey,
|
|
122
|
-
params: { userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId },
|
|
123
|
-
functionType: 'REFRESH',
|
|
124
|
-
disableWorkers: ctx.disableWorkers,
|
|
125
|
-
sessionCookie,
|
|
126
|
-
useDKLS: ctx.useDKLS,
|
|
127
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
128
|
-
wasmOverride: ctx.wasmOverride,
|
|
129
|
-
returnObject: true,
|
|
130
|
-
});
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
export function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
134
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isKeygenComplete(ctx, userId, res.walletId); }), 15000, 1000);
|
|
137
|
-
resolve({
|
|
138
|
-
signer: res.signer,
|
|
139
|
-
walletId: res.walletId,
|
|
140
|
-
recoveryShare: null,
|
|
141
|
-
});
|
|
142
|
-
worker.terminate();
|
|
143
|
-
}));
|
|
144
|
-
worker.postMessage({
|
|
145
|
-
env: ctx.env,
|
|
146
|
-
apiKey: ctx.apiKey,
|
|
147
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
148
|
-
params: { userId },
|
|
149
|
-
functionType: 'ED25519_KEYGEN',
|
|
150
|
-
disableWorkers: ctx.disableWorkers,
|
|
151
|
-
sessionCookie,
|
|
152
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
153
|
-
wasmOverride: ctx.wasmOverride,
|
|
154
|
-
});
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
export function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
158
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId); }), 15000, 1000);
|
|
161
|
-
resolve({
|
|
162
|
-
signer: res.signer,
|
|
163
|
-
walletId: res.walletId,
|
|
164
|
-
recoveryShare: null,
|
|
165
|
-
});
|
|
166
|
-
worker.terminate();
|
|
167
|
-
}));
|
|
168
|
-
const email = undefined;
|
|
169
|
-
const params = { pregenIdentifier, pregenIdentifierType, email };
|
|
170
|
-
if (pregenIdentifierType === 'EMAIL') {
|
|
171
|
-
params.email = pregenIdentifier;
|
|
172
|
-
}
|
|
173
|
-
worker.postMessage({
|
|
174
|
-
env: ctx.env,
|
|
175
|
-
apiKey: ctx.apiKey,
|
|
176
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
177
|
-
params: params,
|
|
178
|
-
functionType: 'ED25519_PREKEYGEN',
|
|
179
|
-
disableWorkers: ctx.disableWorkers,
|
|
180
|
-
sessionCookie,
|
|
181
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
182
|
-
wasmOverride: ctx.wasmOverride,
|
|
183
|
-
});
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { setupWorker } from '../workers/workerWrapper.js';
|
|
11
|
-
export function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
12
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
resolve(res);
|
|
16
|
-
worker.terminate();
|
|
17
|
-
}));
|
|
18
|
-
worker.postMessage({
|
|
19
|
-
env: ctx.env,
|
|
20
|
-
apiKey: ctx.apiKey,
|
|
21
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
22
|
-
params: { share, walletId, userId },
|
|
23
|
-
functionType: 'GET_PRIVATE_KEY',
|
|
24
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
25
|
-
disableWorkers: ctx.disableWorkers,
|
|
26
|
-
sessionCookie,
|
|
27
|
-
useDKLS: ctx.useDKLS,
|
|
28
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
29
|
-
wasmOverride: ctx.wasmOverride,
|
|
30
|
-
});
|
|
31
|
-
}));
|
|
32
|
-
});
|
|
33
|
-
}
|
package/dist/wallet/signing.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { setupWorker } from '../workers/workerWrapper.js';
|
|
11
|
-
export function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
12
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
const worker = yield setupWorker(ctx, (sendTransactionRes) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
resolve(sendTransactionRes);
|
|
16
|
-
worker.terminate();
|
|
17
|
-
}));
|
|
18
|
-
worker.postMessage({
|
|
19
|
-
env: ctx.env,
|
|
20
|
-
apiKey: ctx.apiKey,
|
|
21
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
22
|
-
params: { share, walletId, userId, tx, chainId },
|
|
23
|
-
functionType: 'SIGN_TRANSACTION',
|
|
24
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
25
|
-
disableWorkers: ctx.disableWorkers,
|
|
26
|
-
sessionCookie,
|
|
27
|
-
useDKLS: isDKLS,
|
|
28
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
29
|
-
wasmOverride: ctx.wasmOverride,
|
|
30
|
-
});
|
|
31
|
-
}));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
export function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const worker = yield setupWorker(ctx, (sendTransactionRes) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
resolve(sendTransactionRes);
|
|
39
|
-
worker.terminate();
|
|
40
|
-
}));
|
|
41
|
-
worker.postMessage({
|
|
42
|
-
env: ctx.env,
|
|
43
|
-
apiKey: ctx.apiKey,
|
|
44
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
45
|
-
params: { share, walletId, userId, tx, chainId },
|
|
46
|
-
functionType: 'SEND_TRANSACTION',
|
|
47
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
48
|
-
disableWorkers: ctx.disableWorkers,
|
|
49
|
-
sessionCookie,
|
|
50
|
-
useDKLS: isDKLS,
|
|
51
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
52
|
-
wasmOverride: ctx.wasmOverride,
|
|
53
|
-
});
|
|
54
|
-
}));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
export function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const worker = yield setupWorker(ctx, (signMessageRes) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
resolve(signMessageRes);
|
|
62
|
-
worker.terminate();
|
|
63
|
-
}));
|
|
64
|
-
worker.postMessage({
|
|
65
|
-
env: ctx.env,
|
|
66
|
-
apiKey: ctx.apiKey,
|
|
67
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
68
|
-
params: { share, walletId, userId, message, cosmosSignDoc },
|
|
69
|
-
functionType: 'SIGN_MESSAGE',
|
|
70
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
71
|
-
disableWorkers: ctx.disableWorkers,
|
|
72
|
-
sessionCookie,
|
|
73
|
-
useDKLS: isDKLS,
|
|
74
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
75
|
-
wasmOverride: ctx.wasmOverride,
|
|
76
|
-
});
|
|
77
|
-
}));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
export function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const worker = yield setupWorker(ctx, (signMessageRes) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
resolve(signMessageRes);
|
|
85
|
-
worker.terminate();
|
|
86
|
-
}));
|
|
87
|
-
worker.postMessage({
|
|
88
|
-
env: ctx.env,
|
|
89
|
-
apiKey: ctx.apiKey,
|
|
90
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
91
|
-
params: { share, walletId, userId, base64Bytes },
|
|
92
|
-
functionType: 'ED25519_SIGN',
|
|
93
|
-
disableWorkers: ctx.disableWorkers,
|
|
94
|
-
sessionCookie,
|
|
95
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
96
|
-
wasmOverride: ctx.wasmOverride,
|
|
97
|
-
});
|
|
98
|
-
}));
|
|
99
|
-
});
|
|
100
|
-
}
|