@getpara/server-sdk 3.14.0 → 3.15.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.
@@ -90,6 +90,34 @@ function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, wallet
90
90
  return !!(wallet == null ? void 0 : wallet.address);
91
91
  });
92
92
  }
93
+ function requireWalletReadiness(workId, checkReadiness) {
94
+ return __async(this, null, function* () {
95
+ try {
96
+ if (yield (0, import_core_sdk.waitUntilTrue)(checkReadiness, 15e3, 1e3)) {
97
+ return;
98
+ }
99
+ } catch (error) {
100
+ const onboardingError = new import_core_sdk.OnboardingError("Wallet creation could not be confirmed.", {
101
+ code: "WALLET_READINESS_FAILED",
102
+ stage: "wallet-readiness",
103
+ retryable: false,
104
+ retryMode: "start-over",
105
+ correlationId: workId
106
+ });
107
+ if (error instanceof Error) {
108
+ Object.defineProperty(onboardingError, "cause", { value: error });
109
+ }
110
+ throw onboardingError;
111
+ }
112
+ throw new import_core_sdk.OnboardingError("Wallet creation did not become ready before the polling window ended.", {
113
+ code: "WALLET_READINESS_FAILED",
114
+ stage: "wallet-readiness",
115
+ retryable: false,
116
+ retryMode: "start-over",
117
+ correlationId: workId
118
+ });
119
+ });
120
+ }
93
121
  function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
94
122
  return new Promise((resolve, reject) => __async(null, null, function* () {
95
123
  const workId = uuid.v4();
@@ -98,9 +126,9 @@ function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
98
126
  ctx,
99
127
  (res) => __async(null, null, function* () {
100
128
  try {
101
- yield (0, import_core_sdk.waitUntilTrue)(() => __async(null, null, function* () {
129
+ yield requireWalletReadiness(workId, () => __async(null, null, function* () {
102
130
  return isKeygenComplete(ctx, userId, res.walletId);
103
- }), 15e3, 1e3);
131
+ }));
104
132
  resolve({
105
133
  signer: res.signer,
106
134
  walletId: res.walletId,
@@ -154,12 +182,11 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
154
182
  ctx,
155
183
  (res) => __async(null, null, function* () {
156
184
  try {
157
- yield (0, import_core_sdk.waitUntilTrue)(
185
+ yield requireWalletReadiness(
186
+ workId,
158
187
  () => __async(null, null, function* () {
159
188
  return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
160
- }),
161
- 15e3,
162
- 1e3
189
+ })
163
190
  );
164
191
  resolve({
165
192
  signer: res.signer,
@@ -208,9 +235,9 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
208
235
  ctx,
209
236
  (res) => __async(null, null, function* () {
210
237
  try {
211
- yield (0, import_core_sdk.waitUntilTrue)(() => __async(null, null, function* () {
238
+ yield requireWalletReadiness(workId, () => __async(null, null, function* () {
212
239
  return isKeygenComplete(ctx, userId, res.walletId);
213
- }), 15e3, 1e3);
240
+ }));
214
241
  resolve({
215
242
  signer: res.signer,
216
243
  walletId: res.walletId,
@@ -261,12 +288,11 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
261
288
  ctx,
262
289
  (res) => __async(null, null, function* () {
263
290
  try {
264
- yield (0, import_core_sdk.waitUntilTrue)(
291
+ yield requireWalletReadiness(
292
+ workId,
265
293
  () => __async(null, null, function* () {
266
294
  return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
267
- }),
268
- 15e3,
269
- 1e3
295
+ })
270
296
  );
271
297
  resolve({
272
298
  signer: res.signer,
@@ -1,6 +1,6 @@
1
1
  import "../chunk-GM7WFPGG.js";
2
2
  import * as uuid from "uuid";
3
- import { waitUntilTrue } from "@getpara/core-sdk";
3
+ import { waitUntilTrue, OnboardingError } from "@getpara/core-sdk";
4
4
  import { setupWorker } from "../workers/workerWrapper.js";
5
5
  async function isKeygenComplete(ctx, userId, walletId) {
6
6
  const wallets = await ctx.client.getWallets(userId);
@@ -12,6 +12,32 @@ async function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType,
12
12
  const wallet = wallets.wallets.find((w) => w.id === walletId);
13
13
  return !!wallet?.address;
14
14
  }
15
+ async function requireWalletReadiness(workId, checkReadiness) {
16
+ try {
17
+ if (await waitUntilTrue(checkReadiness, 15e3, 1e3)) {
18
+ return;
19
+ }
20
+ } catch (error) {
21
+ const onboardingError = new OnboardingError("Wallet creation could not be confirmed.", {
22
+ code: "WALLET_READINESS_FAILED",
23
+ stage: "wallet-readiness",
24
+ retryable: false,
25
+ retryMode: "start-over",
26
+ correlationId: workId
27
+ });
28
+ if (error instanceof Error) {
29
+ Object.defineProperty(onboardingError, "cause", { value: error });
30
+ }
31
+ throw onboardingError;
32
+ }
33
+ throw new OnboardingError("Wallet creation did not become ready before the polling window ended.", {
34
+ code: "WALLET_READINESS_FAILED",
35
+ stage: "wallet-readiness",
36
+ retryable: false,
37
+ retryMode: "start-over",
38
+ correlationId: workId
39
+ });
40
+ }
15
41
  function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
16
42
  return new Promise(async (resolve, reject) => {
17
43
  const workId = uuid.v4();
@@ -20,7 +46,7 @@ function keygen(ctx, userId, type, secretKey, sessionCookie, _emailProps = {}) {
20
46
  ctx,
21
47
  async (res) => {
22
48
  try {
23
- await waitUntilTrue(async () => isKeygenComplete(ctx, userId, res.walletId), 15e3, 1e3);
49
+ await requireWalletReadiness(workId, async () => isKeygenComplete(ctx, userId, res.walletId));
24
50
  resolve({
25
51
  signer: res.signer,
26
52
  walletId: res.walletId,
@@ -74,10 +100,9 @@ function preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey,
74
100
  ctx,
75
101
  async (res) => {
76
102
  try {
77
- await waitUntilTrue(
78
- async () => isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId),
79
- 15e3,
80
- 1e3
103
+ await requireWalletReadiness(
104
+ workId,
105
+ async () => isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId)
81
106
  );
82
107
  resolve({
83
108
  signer: res.signer,
@@ -127,7 +152,7 @@ function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}, type) {
127
152
  ctx,
128
153
  async (res) => {
129
154
  try {
130
- await waitUntilTrue(async () => isKeygenComplete(ctx, userId, res.walletId), 15e3, 1e3);
155
+ await requireWalletReadiness(workId, async () => isKeygenComplete(ctx, userId, res.walletId));
131
156
  resolve({
132
157
  signer: res.signer,
133
158
  walletId: res.walletId,
@@ -178,10 +203,9 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
178
203
  ctx,
179
204
  async (res) => {
180
205
  try {
181
- await waitUntilTrue(
182
- async () => isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId),
183
- 15e3,
184
- 1e3
206
+ await requireWalletReadiness(
207
+ workId,
208
+ async () => isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId)
185
209
  );
186
210
  resolve({
187
211
  signer: res.signer,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@getpara/server-sdk",
3
- "version": "3.14.0",
3
+ "version": "3.15.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "3.14.0",
6
- "@getpara/user-management-client": "3.14.0",
7
- "@getpara/viem-v2-integration": "3.14.0",
5
+ "@getpara/core-sdk": "3.15.0",
6
+ "@getpara/user-management-client": "3.15.0",
7
+ "@getpara/viem-v2-integration": "3.15.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": "2b83e73b639ad1733d1c03a5e628a92c87b399c1",
19
+ "gitHead": "856f39beedd86c8a49c74a18029f3fffa21d456f",
20
20
  "main": "dist/cjs/index.js",
21
21
  "module": "dist/esm/index.js",
22
22
  "scripts": {