@getpara/web-sdk 1.8.0 → 2.0.0-alpha.3
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 +1817 -12
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/workers/worker.js +900 -15
- package/dist/workers/worker.js.br +0 -0
- package/dist/workers/worker.js.gz +0 -0
- package/package.json +4 -4
- package/dist/LocalStorage.js +0 -36
- package/dist/ParaWeb.js +0 -22
- package/dist/SessionStorage.js +0 -36
- package/dist/WebUtils.js +0 -109
- package/dist/chunk-M66XENHI.js +0 -25
- package/dist/cryptography/webAuth.js +0 -162
- package/dist/errors.js +0 -12
- package/dist/package.json +0 -6
- package/dist/utils/emailUtils.js +0 -10
- package/dist/utils/formattingUtils.js +0 -37
- package/dist/utils/isMobile.js +0 -47
- package/dist/utils/isPasskeySupported.js +0 -17
- package/dist/utils/truncateEthAddress.js +0 -11
- package/dist/wallet/keygen.js +0 -204
- package/dist/wallet/privateKey.js +0 -31
- package/dist/wallet/signing.js +0 -101
- package/dist/wasm/wasm_exec.js +0 -564
- package/dist/workers/walletUtils.js +0 -337
- package/dist/workers/workerWrapper.js +0 -45
package/dist/wallet/keygen.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../chunk-M66XENHI.js";
|
|
5
|
-
import { setupWorker } from "../workers/workerWrapper.js";
|
|
6
|
-
import { distributeNewShare, waitUntilTrue } from "@getpara/core-sdk";
|
|
7
|
-
function isKeygenComplete(ctx, userId, walletId) {
|
|
8
|
-
return __async(this, null, function* () {
|
|
9
|
-
const wallets = yield ctx.client.getWallets(userId);
|
|
10
|
-
const wallet = wallets.data.wallets.find((w) => w.id === walletId);
|
|
11
|
-
return !!wallet.address;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function isRefreshComplete(ctx, userId, walletId, partnerId, protocolId) {
|
|
15
|
-
return __async(this, null, function* () {
|
|
16
|
-
const { isDone } = yield ctx.client.isRefreshDone(userId, walletId, partnerId, protocolId);
|
|
17
|
-
return isDone;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
|
|
21
|
-
return __async(this, null, function* () {
|
|
22
|
-
const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
|
|
23
|
-
const wallet = wallets.wallets.find((w) => w.id === walletId);
|
|
24
|
-
return !!wallet.address;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, emailProps = {}) {
|
|
28
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
29
|
-
const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
|
|
30
|
-
yield waitUntilTrue(() => __async(this, null, function* () {
|
|
31
|
-
return isKeygenComplete(ctx, userId, res.walletId);
|
|
32
|
-
}), 15e3, 1e3);
|
|
33
|
-
if (skipDistribute) {
|
|
34
|
-
resolve({
|
|
35
|
-
signer: res.signer,
|
|
36
|
-
walletId: res.walletId,
|
|
37
|
-
recoveryShare: null
|
|
38
|
-
});
|
|
39
|
-
worker.terminate();
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const recoveryShare = yield distributeNewShare({
|
|
43
|
-
ctx,
|
|
44
|
-
userId,
|
|
45
|
-
walletId: res.walletId,
|
|
46
|
-
userShare: res.signer,
|
|
47
|
-
emailProps
|
|
48
|
-
});
|
|
49
|
-
resolve({
|
|
50
|
-
signer: res.signer,
|
|
51
|
-
walletId: res.walletId,
|
|
52
|
-
recoveryShare
|
|
53
|
-
});
|
|
54
|
-
worker.terminate();
|
|
55
|
-
}));
|
|
56
|
-
worker.postMessage({
|
|
57
|
-
env: ctx.env,
|
|
58
|
-
apiKey: ctx.apiKey,
|
|
59
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
60
|
-
params: { userId, secretKey, type },
|
|
61
|
-
functionType: "KEYGEN",
|
|
62
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
63
|
-
disableWorkers: ctx.disableWorkers,
|
|
64
|
-
sessionCookie,
|
|
65
|
-
useDKLS: ctx.useDKLS,
|
|
66
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
67
|
-
wasmOverride: ctx.wasmOverride
|
|
68
|
-
});
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
|
|
72
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
73
|
-
const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
|
|
74
|
-
yield waitUntilTrue(
|
|
75
|
-
() => __async(this, null, function* () {
|
|
76
|
-
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
77
|
-
}),
|
|
78
|
-
15e3,
|
|
79
|
-
1e3
|
|
80
|
-
);
|
|
81
|
-
resolve({
|
|
82
|
-
signer: res.signer,
|
|
83
|
-
walletId: res.walletId,
|
|
84
|
-
recoveryShare: null
|
|
85
|
-
});
|
|
86
|
-
worker.terminate();
|
|
87
|
-
}));
|
|
88
|
-
const email = void 0;
|
|
89
|
-
const params = { pregenIdentifier, pregenIdentifierType, type, secretKey, partnerId, email };
|
|
90
|
-
if (pregenIdentifierType === "EMAIL") {
|
|
91
|
-
params.email = pregenIdentifier;
|
|
92
|
-
}
|
|
93
|
-
worker.postMessage({
|
|
94
|
-
env: ctx.env,
|
|
95
|
-
apiKey: ctx.apiKey,
|
|
96
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
97
|
-
params,
|
|
98
|
-
functionType: "PREKEYGEN",
|
|
99
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
100
|
-
disableWorkers: ctx.disableWorkers,
|
|
101
|
-
sessionCookie,
|
|
102
|
-
useDKLS: ctx.useDKLS,
|
|
103
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
104
|
-
wasmOverride: ctx.wasmOverride
|
|
105
|
-
});
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
function refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
|
|
109
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
110
|
-
const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
|
|
111
|
-
if (!(yield waitUntilTrue(() => __async(this, null, function* () {
|
|
112
|
-
return isRefreshComplete(ctx, userId, walletId, newPartnerId);
|
|
113
|
-
}), 15e3, 1e3))) {
|
|
114
|
-
throw new Error("refresh failed");
|
|
115
|
-
}
|
|
116
|
-
const { protocolId, signer } = res;
|
|
117
|
-
resolve({
|
|
118
|
-
signer,
|
|
119
|
-
protocolId
|
|
120
|
-
});
|
|
121
|
-
worker.terminate();
|
|
122
|
-
}));
|
|
123
|
-
worker.postMessage({
|
|
124
|
-
env: ctx.env,
|
|
125
|
-
apiKey: ctx.apiKey,
|
|
126
|
-
params: { userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId },
|
|
127
|
-
functionType: "REFRESH",
|
|
128
|
-
disableWorkers: ctx.disableWorkers,
|
|
129
|
-
sessionCookie,
|
|
130
|
-
useDKLS: ctx.useDKLS,
|
|
131
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
132
|
-
wasmOverride: ctx.wasmOverride,
|
|
133
|
-
returnObject: true
|
|
134
|
-
});
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
|
|
138
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
139
|
-
const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
|
|
140
|
-
yield waitUntilTrue(() => __async(this, null, function* () {
|
|
141
|
-
return isKeygenComplete(ctx, userId, res.walletId);
|
|
142
|
-
}), 15e3, 1e3);
|
|
143
|
-
resolve({
|
|
144
|
-
signer: res.signer,
|
|
145
|
-
walletId: res.walletId,
|
|
146
|
-
recoveryShare: null
|
|
147
|
-
});
|
|
148
|
-
worker.terminate();
|
|
149
|
-
}));
|
|
150
|
-
worker.postMessage({
|
|
151
|
-
env: ctx.env,
|
|
152
|
-
apiKey: ctx.apiKey,
|
|
153
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
154
|
-
params: { userId },
|
|
155
|
-
functionType: "ED25519_KEYGEN",
|
|
156
|
-
disableWorkers: ctx.disableWorkers,
|
|
157
|
-
sessionCookie,
|
|
158
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
159
|
-
wasmOverride: ctx.wasmOverride
|
|
160
|
-
});
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
|
|
164
|
-
return new Promise((resolve) => __async(this, null, function* () {
|
|
165
|
-
const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
|
|
166
|
-
yield waitUntilTrue(
|
|
167
|
-
() => __async(this, null, function* () {
|
|
168
|
-
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
169
|
-
}),
|
|
170
|
-
15e3,
|
|
171
|
-
1e3
|
|
172
|
-
);
|
|
173
|
-
resolve({
|
|
174
|
-
signer: res.signer,
|
|
175
|
-
walletId: res.walletId,
|
|
176
|
-
recoveryShare: null
|
|
177
|
-
});
|
|
178
|
-
worker.terminate();
|
|
179
|
-
}));
|
|
180
|
-
const email = void 0;
|
|
181
|
-
const params = { pregenIdentifier, pregenIdentifierType, email };
|
|
182
|
-
if (pregenIdentifierType === "EMAIL") {
|
|
183
|
-
params.email = pregenIdentifier;
|
|
184
|
-
}
|
|
185
|
-
worker.postMessage({
|
|
186
|
-
env: ctx.env,
|
|
187
|
-
apiKey: ctx.apiKey,
|
|
188
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
189
|
-
params,
|
|
190
|
-
functionType: "ED25519_PREKEYGEN",
|
|
191
|
-
disableWorkers: ctx.disableWorkers,
|
|
192
|
-
sessionCookie,
|
|
193
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
194
|
-
wasmOverride: ctx.wasmOverride
|
|
195
|
-
});
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
|
-
export {
|
|
199
|
-
ed25519Keygen,
|
|
200
|
-
ed25519PreKeygen,
|
|
201
|
-
keygen,
|
|
202
|
-
preKeygen,
|
|
203
|
-
refresh
|
|
204
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../chunk-M66XENHI.js";
|
|
5
|
-
import { setupWorker } from "../workers/workerWrapper.js";
|
|
6
|
-
function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
|
|
7
|
-
return __async(this, null, function* () {
|
|
8
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
9
|
-
const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
|
|
10
|
-
resolve(res);
|
|
11
|
-
worker.terminate();
|
|
12
|
-
}));
|
|
13
|
-
worker.postMessage({
|
|
14
|
-
env: ctx.env,
|
|
15
|
-
apiKey: ctx.apiKey,
|
|
16
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
17
|
-
params: { share, walletId, userId },
|
|
18
|
-
functionType: "GET_PRIVATE_KEY",
|
|
19
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
20
|
-
disableWorkers: ctx.disableWorkers,
|
|
21
|
-
sessionCookie,
|
|
22
|
-
useDKLS: ctx.useDKLS,
|
|
23
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
24
|
-
wasmOverride: ctx.wasmOverride
|
|
25
|
-
});
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
getPrivateKey
|
|
31
|
-
};
|
package/dist/wallet/signing.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../chunk-M66XENHI.js";
|
|
5
|
-
import { setupWorker } from "../workers/workerWrapper.js";
|
|
6
|
-
function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
7
|
-
return __async(this, null, function* () {
|
|
8
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
9
|
-
const worker = yield setupWorker(ctx, (sendTransactionRes) => __async(this, null, function* () {
|
|
10
|
-
resolve(sendTransactionRes);
|
|
11
|
-
worker.terminate();
|
|
12
|
-
}));
|
|
13
|
-
worker.postMessage({
|
|
14
|
-
env: ctx.env,
|
|
15
|
-
apiKey: ctx.apiKey,
|
|
16
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
17
|
-
params: { share, walletId, userId, tx, chainId },
|
|
18
|
-
functionType: "SIGN_TRANSACTION",
|
|
19
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
20
|
-
disableWorkers: ctx.disableWorkers,
|
|
21
|
-
sessionCookie,
|
|
22
|
-
useDKLS: isDKLS,
|
|
23
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
24
|
-
wasmOverride: ctx.wasmOverride
|
|
25
|
-
});
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
|
|
30
|
-
return __async(this, null, function* () {
|
|
31
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
32
|
-
const worker = yield setupWorker(ctx, (sendTransactionRes) => __async(this, null, function* () {
|
|
33
|
-
resolve(sendTransactionRes);
|
|
34
|
-
worker.terminate();
|
|
35
|
-
}));
|
|
36
|
-
worker.postMessage({
|
|
37
|
-
env: ctx.env,
|
|
38
|
-
apiKey: ctx.apiKey,
|
|
39
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
40
|
-
params: { share, walletId, userId, tx, chainId },
|
|
41
|
-
functionType: "SEND_TRANSACTION",
|
|
42
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
43
|
-
disableWorkers: ctx.disableWorkers,
|
|
44
|
-
sessionCookie,
|
|
45
|
-
useDKLS: isDKLS,
|
|
46
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
47
|
-
wasmOverride: ctx.wasmOverride
|
|
48
|
-
});
|
|
49
|
-
}));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
|
|
53
|
-
return __async(this, null, function* () {
|
|
54
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
55
|
-
const worker = yield setupWorker(ctx, (signMessageRes) => __async(this, null, function* () {
|
|
56
|
-
resolve(signMessageRes);
|
|
57
|
-
worker.terminate();
|
|
58
|
-
}));
|
|
59
|
-
worker.postMessage({
|
|
60
|
-
env: ctx.env,
|
|
61
|
-
apiKey: ctx.apiKey,
|
|
62
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
63
|
-
params: { share, walletId, userId, message, cosmosSignDoc },
|
|
64
|
-
functionType: "SIGN_MESSAGE",
|
|
65
|
-
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
66
|
-
disableWorkers: ctx.disableWorkers,
|
|
67
|
-
sessionCookie,
|
|
68
|
-
useDKLS: isDKLS,
|
|
69
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
70
|
-
wasmOverride: ctx.wasmOverride
|
|
71
|
-
});
|
|
72
|
-
}));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
76
|
-
return __async(this, null, function* () {
|
|
77
|
-
return yield new Promise((resolve) => __async(this, null, function* () {
|
|
78
|
-
const worker = yield setupWorker(ctx, (signMessageRes) => __async(this, null, function* () {
|
|
79
|
-
resolve(signMessageRes);
|
|
80
|
-
worker.terminate();
|
|
81
|
-
}));
|
|
82
|
-
worker.postMessage({
|
|
83
|
-
env: ctx.env,
|
|
84
|
-
apiKey: ctx.apiKey,
|
|
85
|
-
cosmosPrefix: ctx.cosmosPrefix,
|
|
86
|
-
params: { share, walletId, userId, base64Bytes },
|
|
87
|
-
functionType: "ED25519_SIGN",
|
|
88
|
-
disableWorkers: ctx.disableWorkers,
|
|
89
|
-
sessionCookie,
|
|
90
|
-
disableWebSockets: ctx.disableWebSockets,
|
|
91
|
-
wasmOverride: ctx.wasmOverride
|
|
92
|
-
});
|
|
93
|
-
}));
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
export {
|
|
97
|
-
ed25519Sign,
|
|
98
|
-
sendTransaction,
|
|
99
|
-
signMessage,
|
|
100
|
-
signTransaction
|
|
101
|
-
};
|