@getpara/server-sdk 3.7.0 → 3.8.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.
@@ -147,15 +147,28 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _sessionC
147
147
  }
148
148
  });
149
149
  }
150
+ function withMPCNetworkHost(ctx, share) {
151
+ try {
152
+ const signer = JSON.parse(atob(share));
153
+ if (signer.Host) {
154
+ return share;
155
+ }
156
+ signer.Host = (0, import_core_sdk.getBaseMPCNetworkUrl)(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
157
+ return btoa(JSON.stringify(signer));
158
+ } catch (e) {
159
+ return share;
160
+ }
161
+ }
150
162
  function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
151
163
  return __async(this, null, function* () {
152
164
  const protocolId = uuid.v4();
165
+ const hostedShare = withMPCNetworkHost(ctx, share);
153
166
  const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519", void 0, protocolId);
154
167
  const signRes = (function() {
155
168
  return __async(this, null, function* () {
156
169
  try {
157
170
  const base64Sig = yield new Promise(
158
- (resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
171
+ (resolve, reject) => global.ed25519Sign(hostedShare, protocolId, base64Bytes, (err, result) => {
159
172
  if (err) {
160
173
  reject(err);
161
174
  }
@@ -76,13 +76,26 @@ async function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _se
76
76
  throw wrapMpcError(`error creating ED25519 account with walletId ${walletId}`, mpcErr, { walletId, protocolId });
77
77
  }
78
78
  }
79
+ function withMPCNetworkHost(ctx, share) {
80
+ try {
81
+ const signer = JSON.parse(atob(share));
82
+ if (signer.Host) {
83
+ return share;
84
+ }
85
+ signer.Host = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets, ctx.mpcNetworkUrlOverride);
86
+ return btoa(JSON.stringify(signer));
87
+ } catch {
88
+ return share;
89
+ }
90
+ }
79
91
  async function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
80
92
  const protocolId = uuid.v4();
93
+ const hostedShare = withMPCNetworkHost(ctx, share);
81
94
  const preSignMessageRes = ctx.client.preSignMessage(userId, walletId, base64Bytes, "ED25519", void 0, protocolId);
82
95
  const signRes = (async function() {
83
96
  try {
84
97
  const base64Sig = await new Promise(
85
- (resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
98
+ (resolve, reject) => global.ed25519Sign(hostedShare, protocolId, base64Bytes, (err, result) => {
86
99
  if (err) {
87
100
  reject(err);
88
101
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@getpara/server-sdk",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "3.7.0",
6
- "@getpara/user-management-client": "3.7.0",
7
- "@getpara/viem-v2-integration": "3.7.0",
5
+ "@getpara/core-sdk": "3.8.0",
6
+ "@getpara/user-management-client": "3.8.0",
7
+ "@getpara/viem-v2-integration": "3.8.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": "ab8876230a5d00b2c620bd23a4e3ed69762fc192",
19
+ "gitHead": "fc722e9eaa7a9cae9fd631b748fe70fab24d7956",
20
20
  "main": "dist/cjs/index.js",
21
21
  "module": "dist/esm/index.js",
22
22
  "scripts": {