@getpara/user-management-client 2.17.0 → 2.19.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.
@@ -78,10 +78,12 @@ var client_exports = {};
78
78
  __export(client_exports, {
79
79
  default: () => client_default,
80
80
  handleResponseError: () => handleResponseError,
81
- handleResponseSuccess: () => handleResponseSuccess
81
+ handleResponseSuccess: () => handleResponseSuccess,
82
+ isRetryableError: () => isRetryableError
82
83
  });
83
84
  module.exports = __toCommonJS(client_exports);
84
85
  var import_axios = __toESM(require("axios"));
86
+ var import_axios_retry = __toESM(require("axios-retry"));
85
87
  var import_utils = require("./utils.js");
86
88
  var import_consts = require("./consts.js");
87
89
  var import_error = require("./error.js");
@@ -105,6 +107,10 @@ const handleResponseError = (error) => {
105
107
  }
106
108
  throw new import_error.ParaApiError("Unknown error");
107
109
  };
110
+ const isRetryableError = (error) => {
111
+ var _a, _b, _c, _d;
112
+ return import_axios_retry.default.isNetworkOrIdempotentRequestError(error) || ((_b = (_a = error.response) == null ? void 0 : _a.status) != null ? _b : 0) >= 500 && ((_d = (_c = error.config) == null ? void 0 : _c.method) == null ? void 0 : _d.toUpperCase()) !== "POST";
113
+ };
108
114
  class Client {
109
115
  constructor({
110
116
  userManagementHost,
@@ -578,6 +584,7 @@ class Client {
578
584
  const axiosConfig = {
579
585
  baseURL: userManagementHost,
580
586
  withCredentials: true,
587
+ timeout: 6e4,
581
588
  headers
582
589
  };
583
590
  if (retrieveSessionCookie) {
@@ -630,6 +637,11 @@ class Client {
630
637
  });
631
638
  };
632
639
  }
640
+ (0, import_axios_retry.default)(this.baseRequest, {
641
+ retries: 3,
642
+ retryDelay: import_axios_retry.default.exponentialDelay,
643
+ retryCondition: isRetryableError
644
+ });
633
645
  this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
634
646
  }
635
647
  // DEPRECATED: use uploadUserKeyShares instead
@@ -842,7 +854,9 @@ class Client {
842
854
  }
843
855
  getPendingTransaction(userId, pendingTransactionId) {
844
856
  return __async(this, null, function* () {
845
- const res = yield this.baseRequest.get(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
857
+ const res = yield this.baseRequest.get(
858
+ `/users/${userId}/pending-transactions/${pendingTransactionId}`
859
+ );
846
860
  return res;
847
861
  });
848
862
  }
@@ -1126,5 +1140,6 @@ var client_default = Client;
1126
1140
  // Annotate the CommonJS export names for ESM import in node:
1127
1141
  0 && (module.exports = {
1128
1142
  handleResponseError,
1129
- handleResponseSuccess
1143
+ handleResponseSuccess,
1144
+ isRetryableError
1130
1145
  });
@@ -5,6 +5,7 @@ import {
5
5
  __spreadValues
6
6
  } from "./chunk-BBZEL7EG.js";
7
7
  import axios from "axios";
8
+ import axiosRetry from "axios-retry";
8
9
  import { extractWalletRef, fromAccountMetadata, fromLinkedAccounts } from "./utils.js";
9
10
  import {
10
11
  SESSION_COOKIE_HEADER_NAME,
@@ -34,6 +35,10 @@ const handleResponseError = (error) => {
34
35
  }
35
36
  throw new ParaApiError("Unknown error");
36
37
  };
38
+ const isRetryableError = (error) => {
39
+ var _a, _b, _c, _d;
40
+ return axiosRetry.isNetworkOrIdempotentRequestError(error) || ((_b = (_a = error.response) == null ? void 0 : _a.status) != null ? _b : 0) >= 500 && ((_d = (_c = error.config) == null ? void 0 : _c.method) == null ? void 0 : _d.toUpperCase()) !== "POST";
41
+ };
37
42
  class Client {
38
43
  constructor({
39
44
  userManagementHost,
@@ -507,6 +512,7 @@ class Client {
507
512
  const axiosConfig = {
508
513
  baseURL: userManagementHost,
509
514
  withCredentials: true,
515
+ timeout: 6e4,
510
516
  headers
511
517
  };
512
518
  if (retrieveSessionCookie) {
@@ -559,6 +565,11 @@ class Client {
559
565
  });
560
566
  };
561
567
  }
568
+ axiosRetry(this.baseRequest, {
569
+ retries: 3,
570
+ retryDelay: axiosRetry.exponentialDelay,
571
+ retryCondition: isRetryableError
572
+ });
562
573
  this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
563
574
  }
564
575
  // DEPRECATED: use uploadUserKeyShares instead
@@ -771,7 +782,9 @@ class Client {
771
782
  }
772
783
  getPendingTransaction(userId, pendingTransactionId) {
773
784
  return __async(this, null, function* () {
774
- const res = yield this.baseRequest.get(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
785
+ const res = yield this.baseRequest.get(
786
+ `/users/${userId}/pending-transactions/${pendingTransactionId}`
787
+ );
775
788
  return res;
776
789
  });
777
790
  }
@@ -1055,5 +1068,6 @@ var client_default = Client;
1055
1068
  export {
1056
1069
  client_default as default,
1057
1070
  handleResponseError,
1058
- handleResponseSuccess
1071
+ handleResponseSuccess,
1072
+ isRetryableError
1059
1073
  };
@@ -1,5 +1,5 @@
1
- import { AxiosResponse } from 'axios';
2
- import { AccountMetadata, Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, AuthMethodStatus, PregenIds, PrimaryAuth, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, TWalletScheme, TWalletType, VerifyExternalWalletParams, IssueJwtParams, IssueJwtResponse, LinkAccountParams, LinkedAccounts, ResendVerificationCodeParams, AssetMetadataIndexed, GetProfileBalanceParams, ProfileBalance, LegacyAuthMethod, PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateDone, UserPreferences, EstimateTransactionOpts, EstimateTransactionResult, BroadcastTransactionOpts, BroadcastTransactionResult, TExternalWalletType } from '@getpara/shared';
1
+ import { AxiosError, AxiosResponse } from 'axios';
2
+ import { AccountMetadata, Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, AuthMethodStatus, PregenIds, PrimaryAuth, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, TWalletScheme, TWalletType, VerifyExternalWalletParams, IssueJwtParams, IssueJwtResponse, LinkAccountParams, LinkedAccounts, ResendVerificationCodeParams, AssetMetadataIndexed, GetProfileBalanceParams, ProfileBalance, LegacyAuthMethod, PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateDone, UserPreferences, EstimateTransactionOpts, EstimateTransactionResult, BroadcastTransactionOpts, BroadcastTransactionResult, TExternalWalletType, GetPendingTransactionResponse } from '@getpara/shared';
3
3
  interface ConfigOpts {
4
4
  useFetchAdapter?: boolean;
5
5
  }
@@ -144,6 +144,7 @@ export type VerifyTelegramRes = {
144
144
  };
145
145
  export declare const handleResponseSuccess: (response: AxiosResponse<any, any>) => AxiosResponse<any, any>;
146
146
  export declare const handleResponseError: (error: any) => never;
147
+ export declare const isRetryableError: (error: AxiosError) => boolean;
147
148
  declare class Client {
148
149
  private baseRequest;
149
150
  constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, partnerConfigOverride, }: ClientConfig);
@@ -325,7 +326,7 @@ declare class Client {
325
326
  allAccepted: boolean;
326
327
  }>;
327
328
  acceptScopes(userId: string, walletId: string, body: AcceptScopesBody): Promise<AxiosResponse<any, any>>;
328
- getPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any>>;
329
+ getPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<GetPendingTransactionResponse>>;
329
330
  acceptPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any>>;
330
331
  getOnRampConfig(): Promise<OnRampConfig>;
331
332
  createOnRampPurchase({ userId, params, ...walletParams }: {
@@ -447,6 +448,7 @@ declare class Client {
447
448
  };
448
449
  sdkType: SDKType;
449
450
  userId: string;
451
+ sdkVersion?: string;
450
452
  }) => Promise<void>;
451
453
  trackReactSdkAnalytics: (opts: {
452
454
  props: object;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@getpara/user-management-client",
3
- "version": "2.17.0",
3
+ "version": "2.19.0",
4
4
  "dependencies": {
5
- "@getpara/shared": "^1.11.0",
5
+ "@getpara/shared": "^1.12.0",
6
6
  "axios": "^1.8.4",
7
+ "axios-retry": "^4.5.0",
7
8
  "libphonenumber-js": "^1.11.7"
8
9
  },
9
10
  "devDependencies": {
@@ -20,7 +21,7 @@
20
21
  "dist",
21
22
  "package.json"
22
23
  ],
23
- "gitHead": "3ed1f835b97ae720f1ac747611296e3b86f61138",
24
+ "gitHead": "7dc9400777adb653c0cc28e0d9236424eb384467",
24
25
  "main": "dist/cjs/index.js",
25
26
  "module": "dist/esm/index.js",
26
27
  "scripts": {