@getpara/server-sdk 1.12.0 → 2.0.0-alpha.5
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 +9 -2
- package/dist/cjs/workers/walletUtils.js +8 -8
- package/dist/cjs/workers/worker.js +2 -2
- package/dist/esm/ParaServer.js +11 -2
- package/dist/esm/workers/walletUtils.js +9 -9
- package/dist/esm/workers/worker.js +3 -9
- package/dist/types/ParaServer.d.ts +2 -5
- package/dist/types/ServerUtils.d.ts +3 -3
- package/dist/types/wallet/keygen.d.ts +3 -3
- package/dist/types/workers/walletUtils.d.ts +3 -3
- package/dist/types/workers/worker.d.ts +1 -1
- package/package.json +5 -4
package/dist/cjs/ParaServer.js
CHANGED
|
@@ -51,10 +51,17 @@ __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"));
|
|
54
55
|
var import_ServerUtils = require("./ServerUtils.js");
|
|
55
56
|
class Para extends import_core_sdk.default {
|
|
56
57
|
constructor(env, apiKey, opts) {
|
|
57
58
|
super(env, apiKey, opts);
|
|
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
|
+
}
|
|
58
65
|
}
|
|
59
66
|
getPlatformUtils() {
|
|
60
67
|
return new import_ServerUtils.ServerUtils();
|
|
@@ -70,8 +77,8 @@ class Para extends import_core_sdk.default {
|
|
|
70
77
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - the type of the identifier.
|
|
71
78
|
* @returns {Promise<string | undefined>} A promise that rejects with an error.
|
|
72
79
|
*/
|
|
73
|
-
claimPregenWallets() {
|
|
74
|
-
return __async(this,
|
|
80
|
+
claimPregenWallets(_) {
|
|
81
|
+
return __async(this, null, function* () {
|
|
75
82
|
throw new Error(
|
|
76
83
|
"claimPregenWallets is not available in the server SDK. This function is only supported on the client side. Please ensure you are using the client SDK to call this method."
|
|
77
84
|
);
|
|
@@ -88,8 +88,8 @@ function sendTransactionRequest(ctx, userId, walletId, protocolId, transaction,
|
|
|
88
88
|
function ed25519Keygen(ctx, userId) {
|
|
89
89
|
return __async(this, null, function* () {
|
|
90
90
|
const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
|
|
91
|
-
scheme:
|
|
92
|
-
type:
|
|
91
|
+
scheme: "ED25519",
|
|
92
|
+
type: "SOLANA"
|
|
93
93
|
});
|
|
94
94
|
const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
95
95
|
try {
|
|
@@ -112,8 +112,8 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType) {
|
|
|
112
112
|
const { walletId, protocolId } = yield ctx.client.createPregenWallet({
|
|
113
113
|
pregenIdentifier,
|
|
114
114
|
pregenIdentifierType,
|
|
115
|
-
scheme:
|
|
116
|
-
type:
|
|
115
|
+
scheme: "ED25519",
|
|
116
|
+
type: "SOLANA"
|
|
117
117
|
});
|
|
118
118
|
const serverUrl = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets);
|
|
119
119
|
try {
|
|
@@ -133,7 +133,7 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType) {
|
|
|
133
133
|
}
|
|
134
134
|
function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
135
135
|
return __async(this, null, function* () {
|
|
136
|
-
const { protocolId } = yield ctx.client.preSignMessage(userId, walletId, base64Bytes,
|
|
136
|
+
const { protocolId } = yield ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519");
|
|
137
137
|
try {
|
|
138
138
|
const base64Sig = yield new Promise(
|
|
139
139
|
(resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
|
|
@@ -153,9 +153,9 @@ function keygen(ctx, userId, type, secretKey) {
|
|
|
153
153
|
return __async(this, null, function* () {
|
|
154
154
|
const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
|
|
155
155
|
useTwoSigners: true,
|
|
156
|
-
scheme: ctx.useDKLS ?
|
|
156
|
+
scheme: ctx.useDKLS ? "DKLS" : "CGGMP",
|
|
157
157
|
type,
|
|
158
|
-
cosmosPrefix: type ===
|
|
158
|
+
cosmosPrefix: type === "COSMOS" ? ctx.cosmosPrefix : void 0
|
|
159
159
|
});
|
|
160
160
|
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
161
161
|
return {
|
|
@@ -196,7 +196,7 @@ function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type,
|
|
|
196
196
|
pregenIdentifier,
|
|
197
197
|
pregenIdentifierType,
|
|
198
198
|
type,
|
|
199
|
-
cosmosPrefix: type ===
|
|
199
|
+
cosmosPrefix: type === "COSMOS" ? ctx.cosmosPrefix : void 0
|
|
200
200
|
});
|
|
201
201
|
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
202
202
|
return {
|
|
@@ -86,7 +86,7 @@ function executeMessage(ctx, message) {
|
|
|
86
86
|
const { functionType, params } = message;
|
|
87
87
|
switch (functionType) {
|
|
88
88
|
case "KEYGEN": {
|
|
89
|
-
const { userId, secretKey, type =
|
|
89
|
+
const { userId, secretKey, type = "EVM" } = params;
|
|
90
90
|
return walletUtils.keygen(ctx, userId, type, secretKey);
|
|
91
91
|
}
|
|
92
92
|
case "SIGN_TRANSACTION": {
|
|
@@ -107,7 +107,7 @@ function executeMessage(ctx, message) {
|
|
|
107
107
|
return { signer };
|
|
108
108
|
}
|
|
109
109
|
case "PREKEYGEN": {
|
|
110
|
-
const { email, partnerId, secretKey, type =
|
|
110
|
+
const { email, partnerId, secretKey, type = "EVM" } = params;
|
|
111
111
|
let { pregenIdentifier, pregenIdentifierType } = params;
|
|
112
112
|
if (email !== "null" && email !== "undefined" && email !== "" && email != null) {
|
|
113
113
|
pregenIdentifier = email;
|
package/dist/esm/ParaServer.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import "./chunk-FTA5RKYX.js";
|
|
2
|
-
import ParaCore
|
|
2
|
+
import ParaCore, {
|
|
3
|
+
Environment
|
|
4
|
+
} from "@getpara/core-sdk";
|
|
5
|
+
import * as Sentry from "@sentry/node";
|
|
3
6
|
import { ServerUtils } from "./ServerUtils.js";
|
|
4
7
|
class Para extends ParaCore {
|
|
5
8
|
constructor(env, apiKey, opts) {
|
|
6
9
|
super(env, apiKey, opts);
|
|
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
|
+
}
|
|
7
16
|
}
|
|
8
17
|
getPlatformUtils() {
|
|
9
18
|
return new ServerUtils();
|
|
@@ -19,7 +28,7 @@ class Para extends ParaCore {
|
|
|
19
28
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - the type of the identifier.
|
|
20
29
|
* @returns {Promise<string | undefined>} A promise that rejects with an error.
|
|
21
30
|
*/
|
|
22
|
-
async claimPregenWallets(
|
|
31
|
+
async claimPregenWallets(_) {
|
|
23
32
|
throw new Error(
|
|
24
33
|
"claimPregenWallets is not available in the server SDK. This function is only supported on the client side. Please ensure you are using the client SDK to call this method."
|
|
25
34
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../chunk-FTA5RKYX.js";
|
|
2
|
-
import { getBaseMPCNetworkUrl
|
|
2
|
+
import { getBaseMPCNetworkUrl } from "@getpara/core-sdk";
|
|
3
3
|
const configCGGMPBase = (serverUrl, walletId, id) => `{"ServerUrl":"${serverUrl}", "WalletId": "${walletId}", "Id":"${id}", "Ids":["USER","CAPSULE"], "Threshold":1}`;
|
|
4
4
|
const configDKLSBase = (walletId, id, disableWebSockets) => `{"walletId": "${walletId}", "id":"${id}", "otherId":"CAPSULE", "isReceiver": false, "disableWebSockets": ${disableWebSockets}}`;
|
|
5
5
|
async function keygenRequest(ctx, userId, walletId, protocolId) {
|
|
@@ -31,8 +31,8 @@ async function sendTransactionRequest(ctx, userId, walletId, protocolId, transac
|
|
|
31
31
|
}
|
|
32
32
|
async function ed25519Keygen(ctx, userId) {
|
|
33
33
|
const { walletId, protocolId } = await ctx.client.createWallet(userId, {
|
|
34
|
-
scheme:
|
|
35
|
-
type:
|
|
34
|
+
scheme: "ED25519",
|
|
35
|
+
type: "SOLANA"
|
|
36
36
|
});
|
|
37
37
|
const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
|
|
38
38
|
try {
|
|
@@ -53,8 +53,8 @@ async function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType) {
|
|
|
53
53
|
const { walletId, protocolId } = await ctx.client.createPregenWallet({
|
|
54
54
|
pregenIdentifier,
|
|
55
55
|
pregenIdentifierType,
|
|
56
|
-
scheme:
|
|
57
|
-
type:
|
|
56
|
+
scheme: "ED25519",
|
|
57
|
+
type: "SOLANA"
|
|
58
58
|
});
|
|
59
59
|
const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
|
|
60
60
|
try {
|
|
@@ -72,7 +72,7 @@ async function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
75
|
-
const { protocolId } = await ctx.client.preSignMessage(userId, walletId, base64Bytes,
|
|
75
|
+
const { protocolId } = await ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519");
|
|
76
76
|
try {
|
|
77
77
|
const base64Sig = await new Promise(
|
|
78
78
|
(resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
|
|
@@ -90,9 +90,9 @@ async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
|
|
|
90
90
|
async function keygen(ctx, userId, type, secretKey) {
|
|
91
91
|
const { walletId, protocolId } = await ctx.client.createWallet(userId, {
|
|
92
92
|
useTwoSigners: true,
|
|
93
|
-
scheme: ctx.useDKLS ?
|
|
93
|
+
scheme: ctx.useDKLS ? "DKLS" : "CGGMP",
|
|
94
94
|
type,
|
|
95
|
-
cosmosPrefix: type ===
|
|
95
|
+
cosmosPrefix: type === "COSMOS" ? ctx.cosmosPrefix : void 0
|
|
96
96
|
});
|
|
97
97
|
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
98
98
|
return {
|
|
@@ -131,7 +131,7 @@ async function preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType,
|
|
|
131
131
|
pregenIdentifier,
|
|
132
132
|
pregenIdentifierType,
|
|
133
133
|
type,
|
|
134
|
-
cosmosPrefix: type ===
|
|
134
|
+
cosmosPrefix: type === "COSMOS" ? ctx.cosmosPrefix : void 0
|
|
135
135
|
});
|
|
136
136
|
if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
|
|
137
137
|
return {
|
|
@@ -19,13 +19,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
import axios from "axios";
|
|
22
|
-
import {
|
|
23
|
-
getPortalBaseURL,
|
|
24
|
-
initClient,
|
|
25
|
-
mpcComputationClient,
|
|
26
|
-
paraVersion,
|
|
27
|
-
WalletType
|
|
28
|
-
} from "@getpara/core-sdk";
|
|
22
|
+
import { getPortalBaseURL, initClient, mpcComputationClient, paraVersion } from "@getpara/core-sdk";
|
|
29
23
|
import * as walletUtils from "./walletUtils.js";
|
|
30
24
|
let rawWasm;
|
|
31
25
|
function requestWasmWithRetries(ctx, retries = 3) {
|
|
@@ -59,7 +53,7 @@ function executeMessage(ctx, message) {
|
|
|
59
53
|
const { functionType, params } = message;
|
|
60
54
|
switch (functionType) {
|
|
61
55
|
case "KEYGEN": {
|
|
62
|
-
const { userId, secretKey, type =
|
|
56
|
+
const { userId, secretKey, type = "EVM" } = params;
|
|
63
57
|
return walletUtils.keygen(ctx, userId, type, secretKey);
|
|
64
58
|
}
|
|
65
59
|
case "SIGN_TRANSACTION": {
|
|
@@ -80,7 +74,7 @@ function executeMessage(ctx, message) {
|
|
|
80
74
|
return { signer };
|
|
81
75
|
}
|
|
82
76
|
case "PREKEYGEN": {
|
|
83
|
-
const { email, partnerId, secretKey, type =
|
|
77
|
+
const { email, partnerId, secretKey, type = "EVM" } = params;
|
|
84
78
|
let { pregenIdentifier, pregenIdentifierType } = params;
|
|
85
79
|
if (email !== "null" && email !== "undefined" && email !== "" && email != null) {
|
|
86
80
|
pregenIdentifier = email;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ParaCore, { PlatformUtils, ConstructorOpts, Environment,
|
|
1
|
+
import ParaCore, { PlatformUtils, ConstructorOpts, Environment, CoreMethodParams, CoreMethodResponse } from '@getpara/core-sdk';
|
|
2
2
|
export declare class Para extends ParaCore {
|
|
3
3
|
constructor(env: Environment, apiKey?: string, opts?: ConstructorOpts);
|
|
4
4
|
protected getPlatformUtils(): PlatformUtils;
|
|
@@ -13,8 +13,5 @@ export declare class Para extends ParaCore {
|
|
|
13
13
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - the type of the identifier.
|
|
14
14
|
* @returns {Promise<string | undefined>} A promise that rejects with an error.
|
|
15
15
|
*/
|
|
16
|
-
claimPregenWallets(
|
|
17
|
-
pregenIdentifier?: string;
|
|
18
|
-
pregenIdentifierType?: TPregenIdentifierType;
|
|
19
|
-
}): Promise<string | undefined>;
|
|
16
|
+
claimPregenWallets(_: CoreMethodParams<'claimPregenWallets'>): CoreMethodResponse<'claimPregenWallets'>;
|
|
20
17
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType,
|
|
3
|
+
import type { Ctx, SignatureRes, PlatformUtils, TPregenIdentifierType, TWalletType } 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';
|
|
7
7
|
export declare class ServerUtils implements PlatformUtils {
|
|
8
8
|
sdkType: SDKType;
|
|
9
9
|
getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
10
|
-
keygen(ctx: Ctx, userId: string, type: Exclude<
|
|
10
|
+
keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null, sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
|
|
11
11
|
signer: string;
|
|
12
12
|
walletId: string;
|
|
13
13
|
}>;
|
|
14
14
|
refresh(_ctx: Ctx, _sessionCookie: string, _userId: string, _walletId: string, _share: string, _oldPartnerId?: string, _newPartnerId?: string): Promise<{
|
|
15
15
|
signer: string;
|
|
16
16
|
}>;
|
|
17
|
-
preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: Exclude<
|
|
17
|
+
preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
|
|
18
18
|
sessionCookie: string): Promise<{
|
|
19
19
|
signer: string;
|
|
20
20
|
walletId: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Ctx, TPregenIdentifierType } from '@getpara/core-sdk';
|
|
2
|
-
import { BackupKitEmailProps,
|
|
2
|
+
import { BackupKitEmailProps, TWalletType } from '@getpara/user-management-client';
|
|
3
3
|
export declare function isKeygenComplete(ctx: Ctx, userId: string, walletId: string): Promise<boolean>;
|
|
4
4
|
export declare function isPreKeygenComplete(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, walletId: string): Promise<boolean>;
|
|
5
|
-
export declare function keygen(ctx: Ctx, userId: string, type:
|
|
5
|
+
export declare function keygen(ctx: Ctx, userId: string, type: TWalletType, secretKey: string | null, sessionCookie?: string, _emailProps?: BackupKitEmailProps): Promise<{
|
|
6
6
|
signer: string;
|
|
7
7
|
walletId: string;
|
|
8
8
|
recoveryShare: string | null;
|
|
9
9
|
}>;
|
|
10
|
-
export declare function preKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type:
|
|
10
|
+
export declare function preKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: TWalletType, secretKey: string | null, _skipDistribute: boolean, partnerId: string, sessionCookie?: string): Promise<{
|
|
11
11
|
signer: string;
|
|
12
12
|
walletId: string;
|
|
13
13
|
recoveryShare: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ctx, TPregenIdentifierType, SignatureRes,
|
|
1
|
+
import { Ctx, TPregenIdentifierType, SignatureRes, TWalletType } from '@getpara/core-sdk';
|
|
2
2
|
export declare function ed25519Keygen(ctx: Ctx, userId: string): Promise<{
|
|
3
3
|
signer: string;
|
|
4
4
|
walletId: string;
|
|
@@ -10,11 +10,11 @@ export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pre
|
|
|
10
10
|
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string): Promise<{
|
|
11
11
|
signature: string;
|
|
12
12
|
}>;
|
|
13
|
-
export declare function keygen(ctx: Ctx, userId: string, type: Exclude<
|
|
13
|
+
export declare function keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null): Promise<{
|
|
14
14
|
signer: string;
|
|
15
15
|
walletId: string;
|
|
16
16
|
}>;
|
|
17
|
-
export declare function preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: Exclude<
|
|
17
|
+
export declare function preKeygen(ctx: Ctx, partnerId: string, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null): Promise<{
|
|
18
18
|
signer: string;
|
|
19
19
|
walletId: string;
|
|
20
20
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/server-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"wasm_exec.js"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@getpara/core-sdk": "
|
|
13
|
-
"@getpara/user-management-client": "
|
|
12
|
+
"@getpara/core-sdk": "2.0.0-alpha.5",
|
|
13
|
+
"@getpara/user-management-client": "2.0.0-alpha.5",
|
|
14
|
+
"@sentry/node": "^9.1.0",
|
|
14
15
|
"uuid": "^11.1.0",
|
|
15
16
|
"ws": "^8.14.2"
|
|
16
17
|
},
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"dist",
|
|
31
32
|
"package.json"
|
|
32
33
|
],
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "3ecfca088f24489f2e8fa5493d0f4459b08880e1"
|
|
34
35
|
}
|