@getpara/server-sdk 2.0.0-alpha.26 → 2.0.0-alpha.28
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/workers/walletUtils.js +4 -1
- package/dist/cjs/workers/workerWrapper.js +11 -1
- package/dist/esm/workers/walletUtils.js +4 -1
- package/dist/esm/workers/workerWrapper.js +10 -1
- package/dist/types/ServerUtils.d.ts +0 -2
- package/dist/types/workers/walletUtils.d.ts +1 -3
- package/dist/types/workers/workerWrapper.d.ts +1 -1
- package/package.json +19 -19
|
@@ -163,7 +163,10 @@ function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
}();
|
|
166
|
-
yield preSignMessageRes;
|
|
166
|
+
const { pendingTransactionId } = yield preSignMessageRes;
|
|
167
|
+
if (pendingTransactionId) {
|
|
168
|
+
return { pendingTransactionId };
|
|
169
|
+
}
|
|
167
170
|
return yield signRes;
|
|
168
171
|
});
|
|
169
172
|
}
|
|
@@ -37,6 +37,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
};
|
|
38
38
|
var workerWrapper_exports = {};
|
|
39
39
|
__export(workerWrapper_exports, {
|
|
40
|
+
resetWorker: () => resetWorker,
|
|
40
41
|
setupWorker: () => setupWorker
|
|
41
42
|
});
|
|
42
43
|
module.exports = __toCommonJS(workerWrapper_exports);
|
|
@@ -53,6 +54,12 @@ function removeWorkId(workId, skipClearTimeout) {
|
|
|
53
54
|
}
|
|
54
55
|
clearTimeout(timeoutId);
|
|
55
56
|
}
|
|
57
|
+
function resetWorker() {
|
|
58
|
+
if (worker) {
|
|
59
|
+
worker.terminate();
|
|
60
|
+
worker = void 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
56
63
|
function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
|
|
57
64
|
return __async(this, null, function* () {
|
|
58
65
|
const timeoutId = setTimeout(() => {
|
|
@@ -69,7 +76,9 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
|
|
|
69
76
|
errorContext
|
|
70
77
|
};
|
|
71
78
|
if (!worker || !worker.threadId) {
|
|
72
|
-
const
|
|
79
|
+
const isDeno = typeof (globalThis == null ? void 0 : globalThis.Deno) !== "undefined";
|
|
80
|
+
const workerFileName = isDeno ? "mpcWorkerServer-esm.js" : "mpcWorkerServer-bundle.js";
|
|
81
|
+
const workerRes = yield fetch(`${(0, import_core_sdk.getPortalBaseURL)(ctx)}/static/js/${workerFileName}`);
|
|
73
82
|
worker = new import_worker_threads.Worker(yield workerRes.text(), { eval: true });
|
|
74
83
|
const onmessage = (message) => __async(this, null, function* () {
|
|
75
84
|
const { workId: messageWorkId } = message;
|
|
@@ -116,5 +125,6 @@ function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
|
|
|
116
125
|
}
|
|
117
126
|
// Annotate the CommonJS export names for ESM import in node:
|
|
118
127
|
0 && (module.exports = {
|
|
128
|
+
resetWorker,
|
|
119
129
|
setupWorker
|
|
120
130
|
});
|
|
@@ -90,7 +90,10 @@ async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
|
90
90
|
throw new Error(`error signing for account of type SOLANA with userId ${userId} and walletId ${walletId}`);
|
|
91
91
|
}
|
|
92
92
|
}();
|
|
93
|
-
await preSignMessageRes;
|
|
93
|
+
const { pendingTransactionId } = await preSignMessageRes;
|
|
94
|
+
if (pendingTransactionId) {
|
|
95
|
+
return { pendingTransactionId };
|
|
96
|
+
}
|
|
94
97
|
return await signRes;
|
|
95
98
|
}
|
|
96
99
|
async function keygen(ctx, userId, type, secretKey) {
|
|
@@ -12,6 +12,12 @@ function removeWorkId(workId, skipClearTimeout) {
|
|
|
12
12
|
}
|
|
13
13
|
clearTimeout(timeoutId);
|
|
14
14
|
}
|
|
15
|
+
function resetWorker() {
|
|
16
|
+
if (worker) {
|
|
17
|
+
worker.terminate();
|
|
18
|
+
worker = void 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
async function setupWorker(ctx, resFunction, errorFunction, workId, errorContext) {
|
|
16
22
|
const timeoutId = setTimeout(() => {
|
|
17
23
|
if (resFunctionMap[workId]) {
|
|
@@ -27,7 +33,9 @@ async function setupWorker(ctx, resFunction, errorFunction, workId, errorContext
|
|
|
27
33
|
errorContext
|
|
28
34
|
};
|
|
29
35
|
if (!worker || !worker.threadId) {
|
|
30
|
-
const
|
|
36
|
+
const isDeno = typeof globalThis?.Deno !== "undefined";
|
|
37
|
+
const workerFileName = isDeno ? "mpcWorkerServer-esm.js" : "mpcWorkerServer-bundle.js";
|
|
38
|
+
const workerRes = await fetch(`${getPortalBaseURL(ctx)}/static/js/${workerFileName}`);
|
|
31
39
|
worker = new Worker(await workerRes.text(), { eval: true });
|
|
32
40
|
const onmessage = async (message) => {
|
|
33
41
|
const { workId: messageWorkId } = message;
|
|
@@ -72,5 +80,6 @@ async function setupWorker(ctx, resFunction, errorFunction, workId, errorContext
|
|
|
72
80
|
return worker;
|
|
73
81
|
}
|
|
74
82
|
export {
|
|
83
|
+
resetWorker,
|
|
75
84
|
setupWorker
|
|
76
85
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, TWalletType } from '@getpara/core-sdk';
|
|
4
2
|
import { BackupKitEmailProps, SDKType } from '@getpara/user-management-client';
|
|
5
3
|
import { ServerLocalStorage } from './ServerLocalStorage.js';
|
|
@@ -7,9 +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<
|
|
11
|
-
signature: string;
|
|
12
|
-
}>;
|
|
10
|
+
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string): Promise<SignatureRes>;
|
|
13
11
|
export declare function keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null): Promise<{
|
|
14
12
|
signer: string;
|
|
15
13
|
walletId: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Worker } from 'worker_threads';
|
|
3
2
|
import { Ctx } from '@getpara/core-sdk';
|
|
3
|
+
export declare function resetWorker(): void;
|
|
4
4
|
export declare function setupWorker(ctx: Ctx, resFunction: (arg: any) => Promise<void>, errorFunction: (error: Error) => void, workId: string, errorContext: object): Promise<Worker>;
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/server-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
4
|
-
"main": "dist/cjs/index.js",
|
|
5
|
-
"module": "dist/esm/index.js",
|
|
6
|
-
"types": "dist/types/index.d.ts",
|
|
7
|
-
"typings": "dist/types/index.d.ts",
|
|
8
|
-
"sideEffects": [
|
|
9
|
-
"wasm_exec.js"
|
|
10
|
-
],
|
|
3
|
+
"version": "2.0.0-alpha.28",
|
|
11
4
|
"dependencies": {
|
|
12
|
-
"@getpara/core-sdk": "2.0.0-alpha.
|
|
13
|
-
"@getpara/user-management-client": "2.0.0-alpha.
|
|
5
|
+
"@getpara/core-sdk": "2.0.0-alpha.28",
|
|
6
|
+
"@getpara/user-management-client": "2.0.0-alpha.28",
|
|
14
7
|
"@sentry/node": "^9.1.0",
|
|
15
8
|
"uuid": "^11.1.0",
|
|
16
9
|
"ws": "^8.14.2"
|
|
17
10
|
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/ws": "^8.5.7",
|
|
13
|
+
"typescript": "^5.8.3"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"package.json"
|
|
18
|
+
],
|
|
19
|
+
"gitHead": "1da9f8663f58015a70686f45741fb76ddc671ac7",
|
|
20
|
+
"main": "dist/cjs/index.js",
|
|
21
|
+
"module": "dist/esm/index.js",
|
|
18
22
|
"scripts": {
|
|
19
23
|
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
|
|
20
|
-
"old-build": "yarn build:cjs && yarn build:esm && yarn build:types",
|
|
21
24
|
"build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
22
25
|
"build:esm": "rm -rf dist/esm && tsc --module es2020 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":[\"wasm_exec.js\"]}' > dist/esm/package.json",
|
|
23
26
|
"build:types": "rm -rf dist/types && tsc --module es2020 --declarationDir dist/types --emitDeclarationOnly --declaration",
|
|
27
|
+
"old-build": "yarn build:cjs && yarn build:esm && yarn build:types",
|
|
24
28
|
"test": "vitest run --coverage"
|
|
25
29
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"typescript": "5.1.6"
|
|
29
|
-
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist",
|
|
32
|
-
"package.json"
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"wasm_exec.js"
|
|
33
32
|
],
|
|
34
|
-
"
|
|
33
|
+
"types": "dist/types/index.d.ts",
|
|
34
|
+
"typings": "dist/types/index.d.ts"
|
|
35
35
|
}
|