@getpara/web-sdk 0.1.0
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/LocalStorage.d.ts +10 -0
- package/dist/LocalStorage.js +34 -0
- package/dist/ParaWeb.d.ts +5 -0
- package/dist/ParaWeb.js +7 -0
- package/dist/SessionStorage.d.ts +14 -0
- package/dist/SessionStorage.js +38 -0
- package/dist/WebUtils.d.ts +47 -0
- package/dist/WebUtils.js +113 -0
- package/dist/cryptography/scripts/prime.worker.min.js +2 -0
- package/dist/cryptography/webAuth.d.ts +12 -0
- package/dist/cryptography/webAuth.js +167 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +7 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/utils/emailUtils.d.ts +1 -0
- package/dist/utils/emailUtils.js +5 -0
- package/dist/utils/formattingUtils.d.ts +11 -0
- package/dist/utils/formattingUtils.js +28 -0
- package/dist/utils/isMobile.d.ts +10 -0
- package/dist/utils/isMobile.js +39 -0
- package/dist/utils/truncateEthAddress.d.ts +1 -0
- package/dist/utils/truncateEthAddress.js +8 -0
- package/dist/wallet/keygen.d.ts +26 -0
- package/dist/wallet/keygen.js +185 -0
- package/dist/wallet/privateKey.d.ts +2 -0
- package/dist/wallet/privateKey.js +33 -0
- package/dist/wallet/signing.d.ts +5 -0
- package/dist/wallet/signing.js +100 -0
- package/dist/wasm/wasm_exec.d.ts +0 -0
- package/dist/wasm/wasm_exec.js +513 -0
- package/dist/workers/walletUtils.d.ts +28 -0
- package/dist/workers/walletUtils.js +244 -0
- package/dist/workers/worker.d.ts +19 -0
- package/dist/workers/worker.js +128 -0
- package/dist/workers/workerWrapper.d.ts +6 -0
- package/dist/workers/workerWrapper.js +50 -0
- package/package.json +39 -0
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Ctx, TPregenIdentifierType } from '@getpara/core-sdk';
|
|
2
|
+
import { BackupKitEmailProps, WalletType } from '@getpara/user-management-client';
|
|
3
|
+
export declare function keygen(ctx: Ctx, userId: string, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, skipDistribute?: boolean, sessionCookie?: string, emailProps?: BackupKitEmailProps): Promise<{
|
|
4
|
+
signer: string;
|
|
5
|
+
walletId: string;
|
|
6
|
+
recoveryShare: string | null;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function preKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, _skipDistribute: boolean, partnerId: string, sessionCookie?: string): Promise<{
|
|
9
|
+
signer: string;
|
|
10
|
+
walletId: string;
|
|
11
|
+
recoveryShare: string | null;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function refresh(ctx: Ctx, sessionCookie: string, userId: string, walletId: string, share: string, oldPartnerId?: string, newPartnerId?: string, keyShareProtocolId?: string): Promise<{
|
|
14
|
+
signer: string;
|
|
15
|
+
protocolId: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function ed25519Keygen(ctx: Ctx, userId: string, sessionCookie?: string, _emailProps?: BackupKitEmailProps): Promise<{
|
|
18
|
+
signer: string;
|
|
19
|
+
walletId: string;
|
|
20
|
+
recoveryShare: string | null;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, sessionCookie?: string): Promise<{
|
|
23
|
+
signer: string;
|
|
24
|
+
walletId: string;
|
|
25
|
+
recoveryShare: string | null;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Ctx, SignatureRes } from '@getpara/core-sdk';
|
|
2
|
+
export declare function signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
3
|
+
export declare function sendTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
4
|
+
export declare function signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie?: string, isDKLS?: boolean, cosmosSignDoc?: string): Promise<SignatureRes>;
|
|
5
|
+
export declare function ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string): Promise<SignatureRes>;
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
}
|
|
File without changes
|