@getpara/user-management-client 2.18.0 → 2.20.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,
@@ -508,6 +514,21 @@ class Client {
508
514
  const res = yield this.baseRequest.post("/enclave/key-shares", body);
509
515
  return res.data;
510
516
  });
517
+ /**
518
+ * Migrate a wallet share by sending an ECIES-encrypted payload to the backend
519
+ * @param walletId The wallet whose share is being migrated
520
+ * @param encryptedPayload JSON string containing the encrypted ECIES payload
521
+ */
522
+ this.migrateWalletShare = (walletId, encryptedPayload, secretApiKey) => __async(this, null, function* () {
523
+ const res = yield this.baseRequest.post(
524
+ `/v1/wallets/${walletId}/migrate-share`,
525
+ { encryptedPayload },
526
+ // X-API-Key: consumed by restKeyHeaderAdapter for secret key auth.
527
+ // Null out X-External-API-Key to prevent the default non-secret key from leaking.
528
+ { headers: { "X-API-Key": secretApiKey, [import_consts.API_KEY_HEADER_NAME]: null } }
529
+ );
530
+ return res.data;
531
+ });
511
532
  /**
512
533
  * Retrieve encrypted key shares from the enclave
513
534
  * @param encryptedPayload JSON string containing the encrypted ECIES query
@@ -578,6 +599,7 @@ class Client {
578
599
  const axiosConfig = {
579
600
  baseURL: userManagementHost,
580
601
  withCredentials: true,
602
+ timeout: 6e4,
581
603
  headers
582
604
  };
583
605
  if (retrieveSessionCookie) {
@@ -630,6 +652,11 @@ class Client {
630
652
  });
631
653
  };
632
654
  }
655
+ (0, import_axios_retry.default)(this.baseRequest, {
656
+ retries: 3,
657
+ retryDelay: import_axios_retry.default.exponentialDelay,
658
+ retryCondition: isRetryableError
659
+ });
633
660
  this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
634
661
  }
635
662
  // DEPRECATED: use uploadUserKeyShares instead
@@ -1128,5 +1155,6 @@ var client_default = Client;
1128
1155
  // Annotate the CommonJS export names for ESM import in node:
1129
1156
  0 && (module.exports = {
1130
1157
  handleResponseError,
1131
- handleResponseSuccess
1158
+ handleResponseSuccess,
1159
+ isRetryableError
1132
1160
  });
@@ -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,
@@ -437,6 +442,21 @@ class Client {
437
442
  const res = yield this.baseRequest.post("/enclave/key-shares", body);
438
443
  return res.data;
439
444
  });
445
+ /**
446
+ * Migrate a wallet share by sending an ECIES-encrypted payload to the backend
447
+ * @param walletId The wallet whose share is being migrated
448
+ * @param encryptedPayload JSON string containing the encrypted ECIES payload
449
+ */
450
+ this.migrateWalletShare = (walletId, encryptedPayload, secretApiKey) => __async(this, null, function* () {
451
+ const res = yield this.baseRequest.post(
452
+ `/v1/wallets/${walletId}/migrate-share`,
453
+ { encryptedPayload },
454
+ // X-API-Key: consumed by restKeyHeaderAdapter for secret key auth.
455
+ // Null out X-External-API-Key to prevent the default non-secret key from leaking.
456
+ { headers: { "X-API-Key": secretApiKey, [API_KEY_HEADER_NAME]: null } }
457
+ );
458
+ return res.data;
459
+ });
440
460
  /**
441
461
  * Retrieve encrypted key shares from the enclave
442
462
  * @param encryptedPayload JSON string containing the encrypted ECIES query
@@ -507,6 +527,7 @@ class Client {
507
527
  const axiosConfig = {
508
528
  baseURL: userManagementHost,
509
529
  withCredentials: true,
530
+ timeout: 6e4,
510
531
  headers
511
532
  };
512
533
  if (retrieveSessionCookie) {
@@ -559,6 +580,11 @@ class Client {
559
580
  });
560
581
  };
561
582
  }
583
+ axiosRetry(this.baseRequest, {
584
+ retries: 3,
585
+ retryDelay: axiosRetry.exponentialDelay,
586
+ retryCondition: isRetryableError
587
+ });
562
588
  this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
563
589
  }
564
590
  // DEPRECATED: use uploadUserKeyShares instead
@@ -1057,5 +1083,6 @@ var client_default = Client;
1057
1083
  export {
1058
1084
  client_default as default,
1059
1085
  handleResponseError,
1060
- handleResponseSuccess
1086
+ handleResponseSuccess,
1087
+ isRetryableError
1061
1088
  };
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosError, AxiosResponse } from 'axios';
2
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;
@@ -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);
@@ -471,6 +472,12 @@ declare class Client {
471
472
  }) => Promise<{
472
473
  payload: any;
473
474
  }>;
475
+ /**
476
+ * Migrate a wallet share by sending an ECIES-encrypted payload to the backend
477
+ * @param walletId The wallet whose share is being migrated
478
+ * @param encryptedPayload JSON string containing the encrypted ECIES payload
479
+ */
480
+ migrateWalletShare: (walletId: string, encryptedPayload: string, secretApiKey: string) => Promise<any>;
474
481
  /**
475
482
  * Retrieve encrypted key shares from the enclave
476
483
  * @param encryptedPayload JSON string containing the encrypted ECIES query
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@getpara/user-management-client",
3
- "version": "2.18.0",
3
+ "version": "2.20.0",
4
4
  "dependencies": {
5
- "@getpara/shared": "^1.12.0",
5
+ "@getpara/shared": "^1.14.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": "4481f6f4e108e682d14c74d4433696141c47fc58",
24
+ "gitHead": "a8443bcc4018864f5e582f238ade1bb3b4e121f4",
24
25
  "main": "dist/cjs/index.js",
25
26
  "module": "dist/esm/index.js",
26
27
  "scripts": {