@getpara/server-sdk 1.2.0 → 1.3.1

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.
Files changed (65) hide show
  1. package/dist/cjs/index.js +1 -21
  2. package/dist/cjs/index.js.br +0 -0
  3. package/dist/cjs/index.js.gz +0 -0
  4. package/dist/cjs/workers/worker.js +2 -154
  5. package/dist/cjs/workers/worker.js.br +0 -0
  6. package/dist/cjs/workers/worker.js.gz +0 -0
  7. package/dist/esm/index.js +1 -4
  8. package/dist/esm/index.js.br +0 -0
  9. package/dist/esm/index.js.gz +0 -0
  10. package/dist/esm/workers/chunk-NEJSZOZX.js +1 -0
  11. package/dist/esm/workers/chunk-NEJSZOZX.js.br +0 -0
  12. package/dist/esm/workers/chunk-NEJSZOZX.js.gz +0 -0
  13. package/dist/esm/workers/wasm_exec-TBSO5IWG.js +2 -0
  14. package/dist/esm/workers/wasm_exec-TBSO5IWG.js.br +0 -0
  15. package/dist/esm/workers/wasm_exec-TBSO5IWG.js.gz +0 -0
  16. package/dist/esm/workers/worker.js +1 -124
  17. package/dist/esm/workers/worker.js.br +0 -0
  18. package/dist/esm/workers/worker.js.gz +0 -0
  19. package/package.json +6 -5
  20. package/dist/cjs/ParaServer.d.ts +0 -4
  21. package/dist/cjs/ParaServer.js +0 -14
  22. package/dist/cjs/ServerLocalStorage.d.ts +0 -12
  23. package/dist/cjs/ServerLocalStorage.js +0 -30
  24. package/dist/cjs/ServerSessionStorage.d.ts +0 -12
  25. package/dist/cjs/ServerSessionStorage.js +0 -30
  26. package/dist/cjs/ServerUtils.d.ts +0 -43
  27. package/dist/cjs/ServerUtils.js +0 -55
  28. package/dist/cjs/index.d.ts +0 -5
  29. package/dist/cjs/package.json +0 -1
  30. package/dist/cjs/wallet/keygen.d.ts +0 -22
  31. package/dist/cjs/wallet/keygen.js +0 -172
  32. package/dist/cjs/wallet/privateKey.d.ts +0 -2
  33. package/dist/cjs/wallet/privateKey.js +0 -62
  34. package/dist/cjs/wallet/signing.d.ts +0 -5
  35. package/dist/cjs/wallet/signing.js +0 -133
  36. package/dist/cjs/wasm/wasm_exec.d.ts +0 -1
  37. package/dist/cjs/wasm/wasm_exec.js +0 -521
  38. package/dist/cjs/workers/walletUtils.d.ts +0 -25
  39. package/dist/cjs/workers/walletUtils.js +0 -247
  40. package/dist/cjs/workers/worker.d.ts +0 -18
  41. package/dist/cjs/workers/workerWrapper.d.ts +0 -4
  42. package/dist/cjs/workers/workerWrapper.js +0 -55
  43. package/dist/esm/ParaServer.d.ts +0 -4
  44. package/dist/esm/ParaServer.js +0 -7
  45. package/dist/esm/ServerLocalStorage.d.ts +0 -12
  46. package/dist/esm/ServerLocalStorage.js +0 -26
  47. package/dist/esm/ServerSessionStorage.d.ts +0 -12
  48. package/dist/esm/ServerSessionStorage.js +0 -26
  49. package/dist/esm/ServerUtils.d.ts +0 -43
  50. package/dist/esm/ServerUtils.js +0 -51
  51. package/dist/esm/index.d.ts +0 -5
  52. package/dist/esm/package.json +0 -1
  53. package/dist/esm/wallet/keygen.d.ts +0 -22
  54. package/dist/esm/wallet/keygen.js +0 -142
  55. package/dist/esm/wallet/privateKey.d.ts +0 -2
  56. package/dist/esm/wallet/privateKey.js +0 -35
  57. package/dist/esm/wallet/signing.d.ts +0 -5
  58. package/dist/esm/wallet/signing.js +0 -103
  59. package/dist/esm/wasm/wasm_exec.d.ts +0 -1
  60. package/dist/esm/wasm/wasm_exec.js +0 -521
  61. package/dist/esm/workers/walletUtils.d.ts +0 -25
  62. package/dist/esm/workers/walletUtils.js +0 -234
  63. package/dist/esm/workers/worker.d.ts +0 -18
  64. package/dist/esm/workers/workerWrapper.d.ts +0 -4
  65. package/dist/esm/workers/workerWrapper.js +0 -51
@@ -1,142 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import * as uuid from 'uuid';
11
- import { waitUntilTrue } from '@getpara/core-sdk';
12
- import { setupWorker } from '../workers/workerWrapper.js';
13
- function isKeygenComplete(ctx, userId, walletId) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const wallets = yield ctx.client.getWallets(userId);
16
- const wallet = wallets.data.wallets.find(w => w.id === walletId);
17
- return !!wallet.address;
18
- });
19
- }
20
- function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
23
- const wallet = wallets.wallets.find(w => w.id === walletId);
24
- return !!(wallet === null || wallet === void 0 ? void 0 : wallet.address);
25
- });
26
- }
27
- export function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, _emailProps = {}) {
28
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
29
- const workId = uuid.v4();
30
- const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
31
- yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isKeygenComplete(ctx, userId, res.walletId); }), 15000, 1000);
32
- if (skipDistribute) {
33
- resolve({
34
- signer: res.signer,
35
- walletId: res.walletId,
36
- recoveryShare: null,
37
- });
38
- }
39
- }), workId);
40
- worker.postMessage({
41
- env: ctx.env,
42
- apiKey: ctx.apiKey,
43
- cosmosPrefix: ctx.cosmosPrefix,
44
- params: { userId, secretKey, type },
45
- functionType: 'KEYGEN',
46
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
47
- disableWorkers: ctx.disableWorkers,
48
- sessionCookie,
49
- useDKLS: ctx.useDKLS,
50
- disableWebSockets: ctx.disableWebSockets,
51
- wasmOverride: ctx.wasmOverride,
52
- workId,
53
- });
54
- }));
55
- }
56
- export function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
57
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
58
- const workId = uuid.v4();
59
- const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
60
- yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId); }), 15000, 1000);
61
- resolve({
62
- signer: res.signer,
63
- walletId: res.walletId,
64
- recoveryShare: null,
65
- });
66
- }), workId);
67
- const email = undefined;
68
- const params = { pregenIdentifier, pregenIdentifierType, secretKey, partnerId, email, type };
69
- if (pregenIdentifierType === 'EMAIL') {
70
- params.email = pregenIdentifier;
71
- }
72
- worker.postMessage({
73
- env: ctx.env,
74
- apiKey: ctx.apiKey,
75
- cosmosPrefix: ctx.cosmosPrefix,
76
- params: params,
77
- functionType: 'PREKEYGEN',
78
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
79
- disableWorkers: ctx.disableWorkers,
80
- sessionCookie,
81
- useDKLS: ctx.useDKLS,
82
- disableWebSockets: ctx.disableWebSockets,
83
- wasmOverride: ctx.wasmOverride,
84
- workId,
85
- });
86
- }));
87
- }
88
- export function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
89
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
90
- const workId = uuid.v4();
91
- const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
92
- yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isKeygenComplete(ctx, userId, res.walletId); }), 15000, 1000);
93
- resolve({
94
- signer: res.signer,
95
- walletId: res.walletId,
96
- recoveryShare: null,
97
- });
98
- }), workId);
99
- worker.postMessage({
100
- env: ctx.env,
101
- apiKey: ctx.apiKey,
102
- cosmosPrefix: ctx.cosmosPrefix,
103
- params: { userId },
104
- functionType: 'ED25519_KEYGEN',
105
- disableWorkers: ctx.disableWorkers,
106
- sessionCookie,
107
- disableWebSockets: ctx.disableWebSockets,
108
- wasmOverride: ctx.wasmOverride,
109
- workId,
110
- });
111
- }));
112
- }
113
- export function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
114
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
115
- const workId = uuid.v4();
116
- const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
117
- yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId); }), 15000, 1000);
118
- resolve({
119
- signer: res.signer,
120
- walletId: res.walletId,
121
- recoveryShare: null,
122
- });
123
- }), workId);
124
- const email = undefined;
125
- const params = { pregenIdentifier, pregenIdentifierType, email };
126
- if (pregenIdentifierType === 'EMAIL') {
127
- params.email = pregenIdentifier;
128
- }
129
- worker.postMessage({
130
- env: ctx.env,
131
- apiKey: ctx.apiKey,
132
- cosmosPrefix: ctx.cosmosPrefix,
133
- params: params,
134
- functionType: 'ED25519_PREKEYGEN',
135
- disableWorkers: ctx.disableWorkers,
136
- sessionCookie,
137
- disableWebSockets: ctx.disableWebSockets,
138
- wasmOverride: ctx.wasmOverride,
139
- workId,
140
- });
141
- }));
142
- }
@@ -1,2 +0,0 @@
1
- import { Ctx } from '@getpara/core-sdk';
2
- export declare function getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie?: string): Promise<string>;
@@ -1,35 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import * as uuid from 'uuid';
11
- import { setupWorker } from '../workers/workerWrapper.js';
12
- export function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
15
- const workId = uuid.v4();
16
- const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
17
- resolve(res);
18
- }), workId);
19
- worker.postMessage({
20
- env: ctx.env,
21
- apiKey: ctx.apiKey,
22
- cosmosPrefix: ctx.cosmosPrefix,
23
- params: { share, walletId, userId },
24
- functionType: 'GET_PRIVATE_KEY',
25
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
26
- disableWorkers: ctx.disableWorkers,
27
- sessionCookie,
28
- useDKLS: ctx.useDKLS,
29
- disableWebSockets: ctx.disableWebSockets,
30
- wasmOverride: ctx.wasmOverride,
31
- workId,
32
- });
33
- }));
34
- });
35
- }
@@ -1,5 +0,0 @@
1
- import type { Ctx, SignatureRes } from '@getpara/core-sdk';
2
- export declare function signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, tx: string, chainId: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
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>;
@@ -1,103 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import * as uuid from 'uuid';
11
- import { setupWorker } from '../workers/workerWrapper.js';
12
- export function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
15
- const workId = uuid.v4();
16
- const worker = yield setupWorker(ctx, (sendTransactionRes) => __awaiter(this, void 0, void 0, function* () {
17
- resolve(sendTransactionRes);
18
- }), workId);
19
- worker.postMessage({
20
- env: ctx.env,
21
- apiKey: ctx.apiKey,
22
- cosmosPrefix: ctx.cosmosPrefix,
23
- params: { share, walletId, userId, tx, chainId },
24
- functionType: 'SIGN_TRANSACTION',
25
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
26
- disableWorkers: ctx.disableWorkers,
27
- sessionCookie,
28
- useDKLS: isDKLS,
29
- disableWebSockets: ctx.disableWebSockets,
30
- wasmOverride: ctx.wasmOverride,
31
- workId,
32
- });
33
- }));
34
- });
35
- }
36
- export function sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
39
- const workId = uuid.v4();
40
- const worker = yield setupWorker(ctx, (sendTransactionRes) => __awaiter(this, void 0, void 0, function* () {
41
- resolve(sendTransactionRes);
42
- }), workId);
43
- worker.postMessage({
44
- env: ctx.env,
45
- apiKey: ctx.apiKey,
46
- params: { share, walletId, userId, tx, chainId },
47
- functionType: 'SEND_TRANSACTION',
48
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
49
- disableWorkers: ctx.disableWorkers,
50
- sessionCookie,
51
- useDKLS: isDKLS,
52
- disableWebSockets: ctx.disableWebSockets,
53
- wasmOverride: ctx.wasmOverride,
54
- workId,
55
- });
56
- }));
57
- });
58
- }
59
- export function signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
62
- const workId = uuid.v4();
63
- const worker = yield setupWorker(ctx, (signMessageRes) => __awaiter(this, void 0, void 0, function* () {
64
- resolve(signMessageRes);
65
- }), workId);
66
- worker.postMessage({
67
- env: ctx.env,
68
- apiKey: ctx.apiKey,
69
- params: { share, walletId, userId, message },
70
- functionType: 'SIGN_MESSAGE',
71
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
72
- disableWorkers: ctx.disableWorkers,
73
- sessionCookie,
74
- useDKLS: isDKLS,
75
- disableWebSockets: ctx.disableWebSockets,
76
- wasmOverride: ctx.wasmOverride,
77
- workId,
78
- });
79
- }));
80
- });
81
- }
82
- export function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
85
- const workId = uuid.v4();
86
- const worker = yield setupWorker(ctx, (signMessageRes) => __awaiter(this, void 0, void 0, function* () {
87
- resolve(signMessageRes);
88
- }), workId);
89
- worker.postMessage({
90
- env: ctx.env,
91
- apiKey: ctx.apiKey,
92
- params: { share, walletId, userId, base64Bytes },
93
- functionType: 'ED25519_SIGN',
94
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
95
- disableWorkers: ctx.disableWorkers,
96
- sessionCookie,
97
- disableWebSockets: ctx.disableWebSockets,
98
- wasmOverride: ctx.wasmOverride,
99
- workId,
100
- });
101
- }));
102
- });
103
- }
@@ -1 +0,0 @@
1
- export const globalThisCopy: typeof globalThis;