@getpara/server-sdk 3.13.0 → 3.15.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/cjs/ServerUtils.js +4 -4
- package/dist/cjs/wallet/keygen.js +38 -12
- package/dist/cjs/wallet/signing.js +4 -4
- package/dist/cjs/workers/walletUtils.js +22 -4
- package/dist/cjs/workers/worker.js +4 -4
- package/dist/esm/ServerUtils.js +4 -4
- package/dist/esm/wallet/keygen.js +35 -11
- package/dist/esm/wallet/signing.js +4 -4
- package/dist/esm/workers/walletUtils.js +25 -5
- package/dist/esm/workers/worker.js +4 -4
- package/dist/types/ServerUtils.d.ts +3 -3
- package/dist/types/wallet/signing.d.ts +3 -3
- package/dist/types/workers/walletUtils.d.ts +3 -3
- package/package.json +5 -5
package/dist/cjs/ServerUtils.js
CHANGED
|
@@ -86,8 +86,8 @@ class ServerUtils {
|
|
|
86
86
|
preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
|
|
87
87
|
return (0, import_keygen.preKeygen)(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
|
|
88
88
|
}
|
|
89
|
-
signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
90
|
-
return (0, import_signing.signMessage)(ctx, userId, walletId, share, message, sessionCookie, isDKLS);
|
|
89
|
+
signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, _cosmosSignDoc, canonicalTransaction) {
|
|
90
|
+
return (0, import_signing.signMessage)(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction);
|
|
91
91
|
}
|
|
92
92
|
signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS) {
|
|
93
93
|
return (0, import_signing.signTransaction)(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS);
|
|
@@ -104,8 +104,8 @@ class ServerUtils {
|
|
|
104
104
|
ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type) {
|
|
105
105
|
return (0, import_keygen.ed25519PreKeygen)(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type);
|
|
106
106
|
}
|
|
107
|
-
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
108
|
-
return (0, import_signing.ed25519Sign)(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
107
|
+
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
|
|
108
|
+
return (0, import_signing.ed25519Sign)(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction);
|
|
109
109
|
}
|
|
110
110
|
openPopup(_popupUrl) {
|
|
111
111
|
return __async(this, null, function* () {
|
|
@@ -90,6 +90,34 @@ function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, wallet
|
|
|
90
90
|
return !!(wallet == null ? void 0 : wallet.address);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
+
function requireWalletReadiness(workId, checkReadiness) {
|
|
94
|
+
return __async(this, null, function* () {
|
|
95
|
+
try {
|
|
96
|
+
if (yield (0, import_core_sdk.waitUntilTrue)(checkReadiness, 15e3, 1e3)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const onboardingError = new import_core_sdk.OnboardingError("Wallet creation could not be confirmed.", {
|
|
101
|
+
code: "WALLET_READINESS_FAILED",
|
|
102
|
+
stage: "wallet-readiness",
|
|
103
|
+
retryable: false,
|
|
104
|
+
retryMode: "start-over",
|
|
105
|
+
correlationId: workId
|
|
106
|
+
});
|
|
107
|
+
if (error instanceof Error) {
|
|
108
|
+
Object.defineProperty(onboardingError, "cause", { value: error });
|
|
109
|
+
}
|
|
110
|
+
throw onboardingError;
|
|
111
|
+
}
|
|
112
|
+
throw new import_core_sdk.OnboardingError("Wallet creation did not become ready before the polling window ended.", {
|
|
113
|
+
code: "WALLET_READINESS_FAILED",
|
|
114
|
+
stage: "wallet-readiness",
|
|
115
|
+
retryable: false,
|
|
116
|
+
retryMode: "start-over",
|
|
117
|
+
correlationId: workId
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
93
121
|
function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
94
122
|
return new Promise((resolve, reject) => __async(null, null, function* () {
|
|
95
123
|
const workId = uuid.v4();
|
|
@@ -98,9 +126,9 @@ function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
|
98
126
|
ctx,
|
|
99
127
|
(res) => __async(null, null, function* () {
|
|
100
128
|
try {
|
|
101
|
-
yield (
|
|
129
|
+
yield requireWalletReadiness(workId, () => __async(null, null, function* () {
|
|
102
130
|
return isKeygenComplete(ctx, userId, res.walletId);
|
|
103
|
-
})
|
|
131
|
+
}));
|
|
104
132
|
resolve({
|
|
105
133
|
signer: res.signer,
|
|
106
134
|
walletId: res.walletId,
|
|
@@ -154,12 +182,11 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
|
|
|
154
182
|
ctx,
|
|
155
183
|
(res) => __async(null, null, function* () {
|
|
156
184
|
try {
|
|
157
|
-
yield (
|
|
185
|
+
yield requireWalletReadiness(
|
|
186
|
+
workId,
|
|
158
187
|
() => __async(null, null, function* () {
|
|
159
188
|
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
160
|
-
})
|
|
161
|
-
15e3,
|
|
162
|
-
1e3
|
|
189
|
+
})
|
|
163
190
|
);
|
|
164
191
|
resolve({
|
|
165
192
|
signer: res.signer,
|
|
@@ -208,9 +235,9 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
|
|
|
208
235
|
ctx,
|
|
209
236
|
(res) => __async(null, null, function* () {
|
|
210
237
|
try {
|
|
211
|
-
yield (
|
|
238
|
+
yield requireWalletReadiness(workId, () => __async(null, null, function* () {
|
|
212
239
|
return isKeygenComplete(ctx, userId, res.walletId);
|
|
213
|
-
})
|
|
240
|
+
}));
|
|
214
241
|
resolve({
|
|
215
242
|
signer: res.signer,
|
|
216
243
|
walletId: res.walletId,
|
|
@@ -261,12 +288,11 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
|
|
|
261
288
|
ctx,
|
|
262
289
|
(res) => __async(null, null, function* () {
|
|
263
290
|
try {
|
|
264
|
-
yield (
|
|
291
|
+
yield requireWalletReadiness(
|
|
292
|
+
workId,
|
|
265
293
|
() => __async(null, null, function* () {
|
|
266
294
|
return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
|
|
267
|
-
})
|
|
268
|
-
15e3,
|
|
269
|
-
1e3
|
|
295
|
+
})
|
|
270
296
|
);
|
|
271
297
|
resolve({
|
|
272
298
|
signer: res.signer,
|
|
@@ -136,7 +136,7 @@ function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCooki
|
|
|
136
136
|
}));
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
139
|
+
function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction) {
|
|
140
140
|
return __async(this, null, function* () {
|
|
141
141
|
return new Promise((resolve, reject) => __async(null, null, function* () {
|
|
142
142
|
const workId = uuid.v4();
|
|
@@ -160,7 +160,7 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
|
|
|
160
160
|
worker.postMessage({
|
|
161
161
|
env: ctx.env,
|
|
162
162
|
apiKey: ctx.apiKey,
|
|
163
|
-
params: { share, walletId, userId, message },
|
|
163
|
+
params: { share, walletId, userId, message, canonicalTransaction },
|
|
164
164
|
functionType: "SIGN_MESSAGE",
|
|
165
165
|
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
166
166
|
disableWorkers: ctx.disableWorkers,
|
|
@@ -176,7 +176,7 @@ function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKL
|
|
|
176
176
|
}));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
179
|
+
function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
|
|
180
180
|
return __async(this, null, function* () {
|
|
181
181
|
return new Promise((resolve, reject) => __async(null, null, function* () {
|
|
182
182
|
const workId = uuid.v4();
|
|
@@ -200,7 +200,7 @@ function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
|
200
200
|
worker.postMessage({
|
|
201
201
|
env: ctx.env,
|
|
202
202
|
apiKey: ctx.apiKey,
|
|
203
|
-
params: { share, walletId, userId, base64Bytes },
|
|
203
|
+
params: { share, walletId, userId, base64Bytes, canonicalTransaction },
|
|
204
204
|
functionType: "ED25519_SIGN",
|
|
205
205
|
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
206
206
|
disableWorkers: ctx.disableWorkers,
|
|
@@ -159,11 +159,20 @@ function withMPCNetworkHost(ctx, share) {
|
|
|
159
159
|
return share;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
162
|
+
function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction) {
|
|
163
163
|
return __async(this, null, function* () {
|
|
164
164
|
const protocolId = uuid.v4();
|
|
165
165
|
const hostedShare = withMPCNetworkHost(ctx, share);
|
|
166
|
-
const preSignMessageRes = ctx.client.preSignMessage(
|
|
166
|
+
const preSignMessageRes = ctx.client.preSignMessage(
|
|
167
|
+
userId,
|
|
168
|
+
walletId,
|
|
169
|
+
base64Bytes,
|
|
170
|
+
"ED25519",
|
|
171
|
+
void 0,
|
|
172
|
+
protocolId,
|
|
173
|
+
void 0,
|
|
174
|
+
canonicalTransaction
|
|
175
|
+
);
|
|
167
176
|
const signRes = (function() {
|
|
168
177
|
return __async(this, null, function* () {
|
|
169
178
|
try {
|
|
@@ -277,10 +286,19 @@ function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type,
|
|
|
277
286
|
}
|
|
278
287
|
});
|
|
279
288
|
}
|
|
280
|
-
function signMessage(ctx, share, walletId, userId, message) {
|
|
289
|
+
function signMessage(ctx, share, walletId, userId, message, canonicalTransaction) {
|
|
281
290
|
return __async(this, null, function* () {
|
|
282
291
|
const protocolId = uuid.v4();
|
|
283
|
-
const preSignMessageRes = ctx.client.preSignMessage(
|
|
292
|
+
const preSignMessageRes = ctx.client.preSignMessage(
|
|
293
|
+
userId,
|
|
294
|
+
walletId,
|
|
295
|
+
message,
|
|
296
|
+
null,
|
|
297
|
+
null,
|
|
298
|
+
protocolId,
|
|
299
|
+
true,
|
|
300
|
+
canonicalTransaction
|
|
301
|
+
);
|
|
284
302
|
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
285
303
|
return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
|
|
286
304
|
}
|
|
@@ -137,8 +137,8 @@ function executeMessage(ctx, message) {
|
|
|
137
137
|
return withRetry(() => walletUtils.sendTransaction(ctx, share, walletId, userId, tx, chainId));
|
|
138
138
|
}
|
|
139
139
|
case "SIGN_MESSAGE": {
|
|
140
|
-
const { share, walletId, userId, message: message2 } = params;
|
|
141
|
-
return withRetry(() => walletUtils.signMessage(ctx, share, walletId, userId, message2));
|
|
140
|
+
const { share, walletId, userId, message: message2, canonicalTransaction } = params;
|
|
141
|
+
return withRetry(() => walletUtils.signMessage(ctx, share, walletId, userId, message2, canonicalTransaction));
|
|
142
142
|
}
|
|
143
143
|
case "REFRESH": {
|
|
144
144
|
const { share, walletId, userId } = params;
|
|
@@ -170,8 +170,8 @@ function executeMessage(ctx, message) {
|
|
|
170
170
|
return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
|
|
171
171
|
}
|
|
172
172
|
case "ED25519_SIGN": {
|
|
173
|
-
const { share, walletId, userId, base64Bytes } = params;
|
|
174
|
-
return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes);
|
|
173
|
+
const { share, walletId, userId, base64Bytes, canonicalTransaction } = params;
|
|
174
|
+
return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction);
|
|
175
175
|
}
|
|
176
176
|
case "ED25519_PREKEYGEN": {
|
|
177
177
|
const { email } = params;
|
package/dist/esm/ServerUtils.js
CHANGED
|
@@ -35,8 +35,8 @@ class ServerUtils {
|
|
|
35
35
|
preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
|
|
36
36
|
return preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
|
|
37
37
|
}
|
|
38
|
-
signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
39
|
-
return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS);
|
|
38
|
+
signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, _cosmosSignDoc, canonicalTransaction) {
|
|
39
|
+
return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction);
|
|
40
40
|
}
|
|
41
41
|
signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS) {
|
|
42
42
|
return signTransaction(ctx, userId, walletId, share, message, chainId, sessionCookie, isDKLS);
|
|
@@ -53,8 +53,8 @@ class ServerUtils {
|
|
|
53
53
|
ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type) {
|
|
54
54
|
return ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie, type);
|
|
55
55
|
}
|
|
56
|
-
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
57
|
-
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
56
|
+
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
|
|
57
|
+
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction);
|
|
58
58
|
}
|
|
59
59
|
async openPopup(_popupUrl) {
|
|
60
60
|
throw new Error("OpenPopup is not implemented in the ServerUtils class.");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../chunk-GM7WFPGG.js";
|
|
2
2
|
import * as uuid from "uuid";
|
|
3
|
-
import { waitUntilTrue } from "@getpara/core-sdk";
|
|
3
|
+
import { waitUntilTrue, OnboardingError } from "@getpara/core-sdk";
|
|
4
4
|
import { setupWorker } from "../workers/workerWrapper.js";
|
|
5
5
|
async function isKeygenComplete(ctx, userId, walletId) {
|
|
6
6
|
const wallets = await ctx.client.getWallets(userId);
|
|
@@ -12,6 +12,32 @@ async function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType,
|
|
|
12
12
|
const wallet = wallets.wallets.find((w) => w.id === walletId);
|
|
13
13
|
return !!wallet?.address;
|
|
14
14
|
}
|
|
15
|
+
async function requireWalletReadiness(workId, checkReadiness) {
|
|
16
|
+
try {
|
|
17
|
+
if (await waitUntilTrue(checkReadiness, 15e3, 1e3)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const onboardingError = new OnboardingError("Wallet creation could not be confirmed.", {
|
|
22
|
+
code: "WALLET_READINESS_FAILED",
|
|
23
|
+
stage: "wallet-readiness",
|
|
24
|
+
retryable: false,
|
|
25
|
+
retryMode: "start-over",
|
|
26
|
+
correlationId: workId
|
|
27
|
+
});
|
|
28
|
+
if (error instanceof Error) {
|
|
29
|
+
Object.defineProperty(onboardingError, "cause", { value: error });
|
|
30
|
+
}
|
|
31
|
+
throw onboardingError;
|
|
32
|
+
}
|
|
33
|
+
throw new OnboardingError("Wallet creation did not become ready before the polling window ended.", {
|
|
34
|
+
code: "WALLET_READINESS_FAILED",
|
|
35
|
+
stage: "wallet-readiness",
|
|
36
|
+
retryable: false,
|
|
37
|
+
retryMode: "start-over",
|
|
38
|
+
correlationId: workId
|
|
39
|
+
});
|
|
40
|
+
}
|
|
15
41
|
function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
16
42
|
return new Promise(async (resolve, reject) => {
|
|
17
43
|
const workId = uuid.v4();
|
|
@@ -20,7 +46,7 @@ function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
|
|
|
20
46
|
ctx,
|
|
21
47
|
async (res) => {
|
|
22
48
|
try {
|
|
23
|
-
await
|
|
49
|
+
await requireWalletReadiness(workId, async () => isKeygenComplete(ctx, userId, res.walletId));
|
|
24
50
|
resolve({
|
|
25
51
|
signer: res.signer,
|
|
26
52
|
walletId: res.walletId,
|
|
@@ -74,10 +100,9 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
|
|
|
74
100
|
ctx,
|
|
75
101
|
async (res) => {
|
|
76
102
|
try {
|
|
77
|
-
await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
1e3
|
|
103
|
+
await requireWalletReadiness(
|
|
104
|
+
workId,
|
|
105
|
+
async () => isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId)
|
|
81
106
|
);
|
|
82
107
|
resolve({
|
|
83
108
|
signer: res.signer,
|
|
@@ -127,7 +152,7 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
|
|
|
127
152
|
ctx,
|
|
128
153
|
async (res) => {
|
|
129
154
|
try {
|
|
130
|
-
await
|
|
155
|
+
await requireWalletReadiness(workId, async () => isKeygenComplete(ctx, userId, res.walletId));
|
|
131
156
|
resolve({
|
|
132
157
|
signer: res.signer,
|
|
133
158
|
walletId: res.walletId,
|
|
@@ -178,10 +203,9 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
|
|
|
178
203
|
ctx,
|
|
179
204
|
async (res) => {
|
|
180
205
|
try {
|
|
181
|
-
await
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
1e3
|
|
206
|
+
await requireWalletReadiness(
|
|
207
|
+
workId,
|
|
208
|
+
async () => isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId)
|
|
185
209
|
);
|
|
186
210
|
resolve({
|
|
187
211
|
signer: res.signer,
|
|
@@ -78,7 +78,7 @@ async function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessio
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
async function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
|
|
81
|
+
async function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, canonicalTransaction) {
|
|
82
82
|
return new Promise(async (resolve, reject) => {
|
|
83
83
|
const workId = uuid.v4();
|
|
84
84
|
try {
|
|
@@ -101,7 +101,7 @@ async function signMessage(ctx, userId, walletId, share, message, sessionCookie,
|
|
|
101
101
|
worker.postMessage({
|
|
102
102
|
env: ctx.env,
|
|
103
103
|
apiKey: ctx.apiKey,
|
|
104
|
-
params: { share, walletId, userId, message },
|
|
104
|
+
params: { share, walletId, userId, message, canonicalTransaction },
|
|
105
105
|
functionType: "SIGN_MESSAGE",
|
|
106
106
|
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
107
107
|
disableWorkers: ctx.disableWorkers,
|
|
@@ -116,7 +116,7 @@ async function signMessage(ctx, userId, walletId, share, message, sessionCookie,
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
async function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
119
|
+
async function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie, canonicalTransaction) {
|
|
120
120
|
return new Promise(async (resolve, reject) => {
|
|
121
121
|
const workId = uuid.v4();
|
|
122
122
|
try {
|
|
@@ -139,7 +139,7 @@ async function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCoo
|
|
|
139
139
|
worker.postMessage({
|
|
140
140
|
env: ctx.env,
|
|
141
141
|
apiKey: ctx.apiKey,
|
|
142
|
-
params: { share, walletId, userId, base64Bytes },
|
|
142
|
+
params: { share, walletId, userId, base64Bytes, canonicalTransaction },
|
|
143
143
|
functionType: "ED25519_SIGN",
|
|
144
144
|
offloadMPCComputationURL: ctx.offloadMPCComputationURL,
|
|
145
145
|
disableWorkers: ctx.disableWorkers,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "../chunk-GM7WFPGG.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getBaseMPCNetworkUrl
|
|
4
|
+
} from "@getpara/core-sdk";
|
|
3
5
|
import * as uuid from "uuid";
|
|
4
6
|
import { wrapMpcError } from "./mpcWorkerError.js";
|
|
5
7
|
const configCGGMPBase = (serverUrl, walletId, id) => `{"ServerUrl":"${serverUrl}", "WalletId": "${walletId}", "Id":"${id}", "Ids":["USER","CAPSULE"], "Threshold":1}`;
|
|
@@ -88,10 +90,19 @@ function withMPCNetworkHost(ctx, share) {
|
|
|
88
90
|
return share;
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
93
|
+
async function ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction) {
|
|
92
94
|
const protocolId = uuid.v4();
|
|
93
95
|
const hostedShare = withMPCNetworkHost(ctx, share);
|
|
94
|
-
const preSignMessageRes = ctx.client.preSignMessage(
|
|
96
|
+
const preSignMessageRes = ctx.client.preSignMessage(
|
|
97
|
+
userId,
|
|
98
|
+
walletId,
|
|
99
|
+
base64Bytes,
|
|
100
|
+
"ED25519",
|
|
101
|
+
void 0,
|
|
102
|
+
protocolId,
|
|
103
|
+
void 0,
|
|
104
|
+
canonicalTransaction
|
|
105
|
+
);
|
|
95
106
|
const signRes = (async function() {
|
|
96
107
|
try {
|
|
97
108
|
const base64Sig = await new Promise(
|
|
@@ -198,9 +209,18 @@ async function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType,
|
|
|
198
209
|
throw wrapMpcError(`error creating account of type ${type} with walletId ${walletId}`, mpcErr, { walletId, protocolId });
|
|
199
210
|
}
|
|
200
211
|
}
|
|
201
|
-
async function signMessage(ctx, share, walletId, userId, message) {
|
|
212
|
+
async function signMessage(ctx, share, walletId, userId, message, canonicalTransaction) {
|
|
202
213
|
const protocolId = uuid.v4();
|
|
203
|
-
const preSignMessageRes = ctx.client.preSignMessage(
|
|
214
|
+
const preSignMessageRes = ctx.client.preSignMessage(
|
|
215
|
+
userId,
|
|
216
|
+
walletId,
|
|
217
|
+
message,
|
|
218
|
+
null,
|
|
219
|
+
null,
|
|
220
|
+
protocolId,
|
|
221
|
+
true,
|
|
222
|
+
canonicalTransaction
|
|
223
|
+
);
|
|
204
224
|
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
205
225
|
return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
|
|
206
226
|
}
|
|
@@ -111,8 +111,8 @@ function executeMessage(ctx, message) {
|
|
|
111
111
|
return withRetry(() => walletUtils.sendTransaction(ctx, share, walletId, userId, tx, chainId));
|
|
112
112
|
}
|
|
113
113
|
case "SIGN_MESSAGE": {
|
|
114
|
-
const { share, walletId, userId, message: message2 } = params;
|
|
115
|
-
return withRetry(() => walletUtils.signMessage(ctx, share, walletId, userId, message2));
|
|
114
|
+
const { share, walletId, userId, message: message2, canonicalTransaction } = params;
|
|
115
|
+
return withRetry(() => walletUtils.signMessage(ctx, share, walletId, userId, message2, canonicalTransaction));
|
|
116
116
|
}
|
|
117
117
|
case "REFRESH": {
|
|
118
118
|
const { share, walletId, userId } = params;
|
|
@@ -144,8 +144,8 @@ function executeMessage(ctx, message) {
|
|
|
144
144
|
return walletUtils.ed25519Keygen(ctx, userId, void 0, void 0, type);
|
|
145
145
|
}
|
|
146
146
|
case "ED25519_SIGN": {
|
|
147
|
-
const { share, walletId, userId, base64Bytes } = params;
|
|
148
|
-
return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes);
|
|
147
|
+
const { share, walletId, userId, base64Bytes, canonicalTransaction } = params;
|
|
148
|
+
return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes, canonicalTransaction);
|
|
149
149
|
}
|
|
150
150
|
case "ED25519_PREKEYGEN": {
|
|
151
151
|
const { email } = params;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import https from 'node:https';
|
|
3
|
-
import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, TWalletType } from '@getpara/core-sdk';
|
|
3
|
+
import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, TWalletType, CanonicalTransactionContext } from '@getpara/core-sdk';
|
|
4
4
|
import { BackupKitEmailProps, SDKType } from '@getpara/user-management-client';
|
|
5
5
|
import { ServerLocalStorage } from './ServerLocalStorage.js';
|
|
6
6
|
import { ServerSessionStorage } from './ServerSessionStorage.js';
|
|
@@ -24,7 +24,7 @@ export declare class ServerUtils implements PlatformUtils {
|
|
|
24
24
|
signer: string;
|
|
25
25
|
walletId: string;
|
|
26
26
|
}>;
|
|
27
|
-
signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
27
|
+
signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie: string, isDKLS?: boolean, _cosmosSignDoc?: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
|
|
28
28
|
signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, message: string, chainId: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
29
29
|
sendTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
30
30
|
signHash(_address: string, _hash: string): Promise<{
|
|
@@ -40,7 +40,7 @@ export declare class ServerUtils implements PlatformUtils {
|
|
|
40
40
|
signer: string;
|
|
41
41
|
walletId: string;
|
|
42
42
|
}>;
|
|
43
|
-
ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string): Promise<SignatureRes>;
|
|
43
|
+
ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
|
|
44
44
|
localStorage: ServerLocalStorage;
|
|
45
45
|
sessionStorage: ServerSessionStorage;
|
|
46
46
|
secureStorage: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Ctx, SignatureRes } from '@getpara/core-sdk';
|
|
1
|
+
import type { CanonicalTransactionContext, Ctx, SignatureRes } from '@getpara/core-sdk';
|
|
2
2
|
export declare function signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
3
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): Promise<SignatureRes>;
|
|
5
|
-
export declare function ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie?: string): Promise<SignatureRes>;
|
|
4
|
+
export declare function signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie?: string, isDKLS?: boolean, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
|
|
5
|
+
export declare function ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie?: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ctx, TPregenIdentifierType, SignatureRes, TWalletType } from '@getpara/core-sdk';
|
|
1
|
+
import { Ctx, TPregenIdentifierType, SignatureRes, TWalletType, type CanonicalTransactionContext } from '@getpara/core-sdk';
|
|
2
2
|
export declare function ed25519Keygen(ctx: Ctx, userId: string, _sessionCookie?: string, _emailProps?: unknown, type?: TWalletType): Promise<{
|
|
3
3
|
signer: string;
|
|
4
4
|
walletId: string;
|
|
@@ -7,7 +7,7 @@ export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pre
|
|
|
7
7
|
signer: string;
|
|
8
8
|
walletId: string;
|
|
9
9
|
}>;
|
|
10
|
-
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string): Promise<SignatureRes>;
|
|
10
|
+
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
|
|
11
11
|
export declare function keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null): Promise<{
|
|
12
12
|
signer: string;
|
|
13
13
|
walletId: string;
|
|
@@ -16,7 +16,7 @@ export declare function preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier:
|
|
|
16
16
|
signer: string;
|
|
17
17
|
walletId: string;
|
|
18
18
|
}>;
|
|
19
|
-
export declare function signMessage(ctx: Ctx, share: string, walletId: string, userId: string, message: string): Promise<SignatureRes>;
|
|
19
|
+
export declare function signMessage(ctx: Ctx, share: string, walletId: string, userId: string, message: string, canonicalTransaction?: CanonicalTransactionContext): Promise<SignatureRes>;
|
|
20
20
|
export declare function signTransaction(ctx: Ctx, share: string, walletId: string, userId: string, tx: string, chainId: string): Promise<SignatureRes>;
|
|
21
21
|
export declare function sendTransaction(ctx: Ctx, share: string, walletId: string, userId: string, tx: string, chainId: string): Promise<SignatureRes>;
|
|
22
22
|
export declare function refresh(ctx: Ctx, share: string, walletId: string, userId: string): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/server-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/core-sdk": "3.
|
|
6
|
-
"@getpara/user-management-client": "3.
|
|
7
|
-
"@getpara/viem-v2-integration": "3.
|
|
5
|
+
"@getpara/core-sdk": "3.15.0",
|
|
6
|
+
"@getpara/user-management-client": "3.15.0",
|
|
7
|
+
"@getpara/viem-v2-integration": "3.15.0",
|
|
8
8
|
"uuid": "^11.1.1",
|
|
9
9
|
"ws": "^8.21.0"
|
|
10
10
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist",
|
|
17
17
|
"package.json"
|
|
18
18
|
],
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "856f39beedd86c8a49c74a18029f3fffa21d456f",
|
|
20
20
|
"main": "dist/cjs/index.js",
|
|
21
21
|
"module": "dist/esm/index.js",
|
|
22
22
|
"scripts": {
|