@getpara/server-sdk 2.0.0-dev.3 → 2.0.0-dev.6
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/ParaServer.js +2 -9
- package/dist/cjs/ServerUtils.js +28 -1
- package/dist/cjs/wallet/keygen.js +34 -0
- package/dist/cjs/workers/worker.js +5 -1
- package/dist/esm/ParaServer.js +3 -12
- package/dist/esm/ServerUtils.js +5 -2
- package/dist/esm/wallet/keygen.js +31 -0
- package/dist/esm/workers/worker.js +12 -2
- package/dist/types/ParaServer.d.ts +3 -2
- package/dist/types/ServerUtils.d.ts +2 -1
- package/dist/types/wallet/keygen.d.ts +1 -0
- package/package.json +4 -5
package/dist/cjs/ParaServer.js
CHANGED
|
@@ -51,17 +51,10 @@ __export(ParaServer_exports, {
|
|
|
51
51
|
});
|
|
52
52
|
module.exports = __toCommonJS(ParaServer_exports);
|
|
53
53
|
var import_core_sdk = __toESM(require("@getpara/core-sdk"));
|
|
54
|
-
var Sentry = __toESM(require("@sentry/node"));
|
|
55
54
|
var import_ServerUtils = require("./ServerUtils.js");
|
|
56
55
|
class Para extends import_core_sdk.default {
|
|
57
|
-
constructor(
|
|
58
|
-
super(
|
|
59
|
-
if (env !== import_core_sdk.Environment.PROD && env !== import_core_sdk.Environment.DEV) {
|
|
60
|
-
Sentry.init({
|
|
61
|
-
environment: env.toLowerCase(),
|
|
62
|
-
dsn: "https://2a26842d951255c2721fde5c1dd2b252@o4504568036720640.ingest.us.sentry.io/4508850906791936"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
56
|
+
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
57
|
+
super(envOrApiKey, apiKeyOrOpts, opts);
|
|
65
58
|
}
|
|
66
59
|
ready() {
|
|
67
60
|
return __async(this, null, function* () {
|
package/dist/cjs/ServerUtils.js
CHANGED
|
@@ -15,6 +15,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
18
38
|
var ServerUtils_exports = {};
|
|
19
39
|
__export(ServerUtils_exports, {
|
|
20
40
|
ServerUtils: () => ServerUtils
|
|
@@ -68,7 +88,14 @@ class ServerUtils {
|
|
|
68
88
|
return (0, import_signing.ed25519Sign)(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
69
89
|
}
|
|
70
90
|
openPopup(_popupUrl) {
|
|
71
|
-
|
|
91
|
+
return __async(this, null, function* () {
|
|
92
|
+
throw new Error("OpenPopup is not implemented in the ServerUtils class.");
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
initializeWorker(ctx) {
|
|
96
|
+
return __async(this, null, function* () {
|
|
97
|
+
return (0, import_keygen.initializeWorker)(ctx);
|
|
98
|
+
});
|
|
72
99
|
}
|
|
73
100
|
}
|
|
74
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -66,6 +66,7 @@ var keygen_exports = {};
|
|
|
66
66
|
__export(keygen_exports, {
|
|
67
67
|
ed25519Keygen: () => ed25519Keygen,
|
|
68
68
|
ed25519PreKeygen: () => ed25519PreKeygen,
|
|
69
|
+
initializeWorker: () => initializeWorker,
|
|
69
70
|
isKeygenComplete: () => isKeygenComplete,
|
|
70
71
|
isPreKeygenComplete: () => isPreKeygenComplete,
|
|
71
72
|
keygen: () => keygen,
|
|
@@ -304,10 +305,43 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
|
|
|
304
305
|
}
|
|
305
306
|
}));
|
|
306
307
|
}
|
|
308
|
+
function initializeWorker(ctx) {
|
|
309
|
+
return __async(this, null, function* () {
|
|
310
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
311
|
+
const workId = uuid.v4();
|
|
312
|
+
try {
|
|
313
|
+
const worker = yield (0, import_workerWrapper.setupWorker)(
|
|
314
|
+
ctx,
|
|
315
|
+
() => __async(this, null, function* () {
|
|
316
|
+
resolve();
|
|
317
|
+
}),
|
|
318
|
+
(error) => {
|
|
319
|
+
reject(error);
|
|
320
|
+
},
|
|
321
|
+
workId,
|
|
322
|
+
{
|
|
323
|
+
functionType: "INIT",
|
|
324
|
+
disableWorkers: ctx.disableWorkers,
|
|
325
|
+
disableWebSockets: ctx.disableWebSockets
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
worker.postMessage({
|
|
329
|
+
env: ctx.env,
|
|
330
|
+
apiKey: ctx.apiKey,
|
|
331
|
+
functionType: "INIT",
|
|
332
|
+
workId
|
|
333
|
+
});
|
|
334
|
+
} catch (error) {
|
|
335
|
+
reject(error);
|
|
336
|
+
}
|
|
337
|
+
}));
|
|
338
|
+
});
|
|
339
|
+
}
|
|
307
340
|
// Annotate the CommonJS export names for ESM import in node:
|
|
308
341
|
0 && (module.exports = {
|
|
309
342
|
ed25519Keygen,
|
|
310
343
|
ed25519PreKeygen,
|
|
344
|
+
initializeWorker,
|
|
311
345
|
isKeygenComplete,
|
|
312
346
|
isPreKeygenComplete,
|
|
313
347
|
keygen,
|
|
@@ -87,6 +87,9 @@ function executeMessage(ctx, message) {
|
|
|
87
87
|
return __async(this, null, function* () {
|
|
88
88
|
const { functionType, params } = message;
|
|
89
89
|
switch (functionType) {
|
|
90
|
+
case "INIT": {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
90
93
|
case "KEYGEN": {
|
|
91
94
|
const { userId, secretKey, type = "EVM" } = params;
|
|
92
95
|
return walletUtils.keygen(ctx, userId, type, secretKey);
|
|
@@ -195,13 +198,14 @@ function handleMessage(e) {
|
|
|
195
198
|
if (!wasmLoaded && (!ctx.offloadMPCComputationURL || ctx.useDKLS)) {
|
|
196
199
|
yield loadWasm(ctx);
|
|
197
200
|
if (global.initWasm) {
|
|
201
|
+
const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
198
202
|
yield new Promise(
|
|
199
203
|
(resolve, reject) => global.initWasm((err, result2) => {
|
|
200
204
|
if (err) {
|
|
201
205
|
reject(err);
|
|
202
206
|
}
|
|
203
207
|
resolve(result2);
|
|
204
|
-
})
|
|
208
|
+
}, serverUrl)
|
|
205
209
|
);
|
|
206
210
|
}
|
|
207
211
|
wasmLoaded = true;
|
package/dist/esm/ParaServer.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import "./chunk-FTA5RKYX.js";
|
|
2
|
-
import ParaCore
|
|
3
|
-
Environment
|
|
4
|
-
} from "@getpara/core-sdk";
|
|
5
|
-
import * as Sentry from "@sentry/node";
|
|
2
|
+
import ParaCore from "@getpara/core-sdk";
|
|
6
3
|
import { ServerUtils } from "./ServerUtils.js";
|
|
7
4
|
class Para extends ParaCore {
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
10
|
-
if (env !== Environment.PROD && env !== Environment.DEV) {
|
|
11
|
-
Sentry.init({
|
|
12
|
-
environment: env.toLowerCase(),
|
|
13
|
-
dsn: "https://2a26842d951255c2721fde5c1dd2b252@o4504568036720640.ingest.us.sentry.io/4508850906791936"
|
|
14
|
-
});
|
|
15
|
-
}
|
|
5
|
+
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
6
|
+
super(envOrApiKey, apiKeyOrOpts, opts);
|
|
16
7
|
}
|
|
17
8
|
async ready() {
|
|
18
9
|
this.isReady = true;
|
package/dist/esm/ServerUtils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./chunk-FTA5RKYX.js";
|
|
2
2
|
import { ServerLocalStorage } from "./ServerLocalStorage.js";
|
|
3
3
|
import { ServerSessionStorage } from "./ServerSessionStorage.js";
|
|
4
|
-
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen } from "./wallet/keygen.js";
|
|
4
|
+
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen, initializeWorker } from "./wallet/keygen.js";
|
|
5
5
|
import { signMessage, sendTransaction, signTransaction, ed25519Sign } from "./wallet/signing.js";
|
|
6
6
|
import { getPrivateKey } from "./wallet/privateKey.js";
|
|
7
7
|
class ServerUtils {
|
|
@@ -46,9 +46,12 @@ class ServerUtils {
|
|
|
46
46
|
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
|
|
47
47
|
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
48
48
|
}
|
|
49
|
-
openPopup(_popupUrl) {
|
|
49
|
+
async openPopup(_popupUrl) {
|
|
50
50
|
throw new Error("OpenPopup is not implemented in the ServerUtils class.");
|
|
51
51
|
}
|
|
52
|
+
async initializeWorker(ctx) {
|
|
53
|
+
return initializeWorker(ctx);
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
export {
|
|
54
57
|
ServerUtils
|
|
@@ -220,9 +220,40 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
|
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
|
+
async function initializeWorker(ctx) {
|
|
224
|
+
return new Promise(async (resolve, reject) => {
|
|
225
|
+
const workId = uuid.v4();
|
|
226
|
+
try {
|
|
227
|
+
const worker = await setupWorker(
|
|
228
|
+
ctx,
|
|
229
|
+
async () => {
|
|
230
|
+
resolve();
|
|
231
|
+
},
|
|
232
|
+
(error) => {
|
|
233
|
+
reject(error);
|
|
234
|
+
},
|
|
235
|
+
workId,
|
|
236
|
+
{
|
|
237
|
+
functionType: "INIT",
|
|
238
|
+
disableWorkers: ctx.disableWorkers,
|
|
239
|
+
disableWebSockets: ctx.disableWebSockets
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
worker.postMessage({
|
|
243
|
+
env: ctx.env,
|
|
244
|
+
apiKey: ctx.apiKey,
|
|
245
|
+
functionType: "INIT",
|
|
246
|
+
workId
|
|
247
|
+
});
|
|
248
|
+
} catch (error) {
|
|
249
|
+
reject(error);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
223
253
|
export {
|
|
224
254
|
ed25519Keygen,
|
|
225
255
|
ed25519PreKeygen,
|
|
256
|
+
initializeWorker,
|
|
226
257
|
isKeygenComplete,
|
|
227
258
|
isPreKeygenComplete,
|
|
228
259
|
keygen,
|
|
@@ -19,7 +19,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
import axios from "axios";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
getBaseMPCNetworkUrl,
|
|
24
|
+
getPortalBaseURL,
|
|
25
|
+
initClient,
|
|
26
|
+
mpcComputationClient,
|
|
27
|
+
paraVersion
|
|
28
|
+
} from "@getpara/core-sdk";
|
|
23
29
|
import * as walletUtils from "./walletUtils.js";
|
|
24
30
|
let rawWasm;
|
|
25
31
|
let wasmLoaded = false;
|
|
@@ -53,6 +59,9 @@ function executeMessage(ctx, message) {
|
|
|
53
59
|
return __async(this, null, function* () {
|
|
54
60
|
const { functionType, params } = message;
|
|
55
61
|
switch (functionType) {
|
|
62
|
+
case "INIT": {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
56
65
|
case "KEYGEN": {
|
|
57
66
|
const { userId, secretKey, type = "EVM" } = params;
|
|
58
67
|
return walletUtils.keygen(ctx, userId, type, secretKey);
|
|
@@ -161,13 +170,14 @@ function handleMessage(e) {
|
|
|
161
170
|
if (!wasmLoaded && (!ctx.offloadMPCComputationURL || ctx.useDKLS)) {
|
|
162
171
|
yield loadWasm(ctx);
|
|
163
172
|
if (global.initWasm) {
|
|
173
|
+
const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
|
|
164
174
|
yield new Promise(
|
|
165
175
|
(resolve, reject) => global.initWasm((err, result2) => {
|
|
166
176
|
if (err) {
|
|
167
177
|
reject(err);
|
|
168
178
|
}
|
|
169
179
|
resolve(result2);
|
|
170
|
-
})
|
|
180
|
+
}, serverUrl)
|
|
171
181
|
);
|
|
172
182
|
}
|
|
173
183
|
wasmLoaded = true;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import ParaCore, { PlatformUtils, ConstructorOpts, Environment, CoreMethodParams, CoreMethodResponse } from '@getpara/core-sdk';
|
|
2
2
|
export declare class Para extends ParaCore {
|
|
3
|
-
constructor(env: Environment, apiKey
|
|
4
|
-
|
|
3
|
+
constructor(env: Environment | undefined, apiKey: string, opts?: ConstructorOpts);
|
|
4
|
+
constructor(apiKey: string, opts?: ConstructorOpts);
|
|
5
|
+
ready(): Promise<void>;
|
|
5
6
|
protected getPlatformUtils(): PlatformUtils;
|
|
6
7
|
isPasskeySupported(): Promise<boolean>;
|
|
7
8
|
/**
|
|
@@ -39,5 +39,6 @@ export declare class ServerUtils implements PlatformUtils {
|
|
|
39
39
|
secureStorage: any;
|
|
40
40
|
isSyncStorage: boolean;
|
|
41
41
|
disableProviderModal: boolean;
|
|
42
|
-
openPopup(_popupUrl: string): Window
|
|
42
|
+
openPopup(_popupUrl: string): Promise<Window>;
|
|
43
|
+
initializeWorker(ctx: Ctx): Promise<void>;
|
|
43
44
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/server-sdk",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.6",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/core-sdk": "2.0.0-dev.
|
|
6
|
-
"@getpara/user-management-client": "2.0.0-dev.
|
|
7
|
-
"@sentry/node": "^9.1.0",
|
|
5
|
+
"@getpara/core-sdk": "2.0.0-dev.6",
|
|
6
|
+
"@getpara/user-management-client": "2.0.0-dev.6",
|
|
8
7
|
"uuid": "^11.1.0",
|
|
9
8
|
"ws": "^8.14.2"
|
|
10
9
|
},
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
"dist",
|
|
17
16
|
"package.json"
|
|
18
17
|
],
|
|
19
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "c2125e37c73a19f11978031f5aa2eab39b978c56",
|
|
20
19
|
"main": "dist/cjs/index.js",
|
|
21
20
|
"module": "dist/esm/index.js",
|
|
22
21
|
"scripts": {
|