@getpara/user-management-client 3.5.0 → 3.6.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.
@@ -100,11 +100,25 @@ const handleResponseSuccess = (response) => {
100
100
  throw new import_error.ParaApiError("Invalid status code");
101
101
  };
102
102
  const UNKNOWN_ERROR_MESSAGE = "Unknown error";
103
+ const UNKNOWN_ERROR_CODE = "UNKNOWN";
103
104
  const hasUsableString = (value) => typeof value === "string" && value.trim().length > 0;
104
- const getFallbackErrorMessage = (error) => {
105
- if (hasUsableString(error == null ? void 0 : error.message)) return error.message;
106
- if (hasUsableString(error == null ? void 0 : error.code)) return error.code;
107
- return UNKNOWN_ERROR_MESSAGE;
105
+ const getUnknownErrorData = (error) => {
106
+ if (error === void 0) return void 0;
107
+ if (error instanceof Error) {
108
+ return { originalName: error.name, originalMessage: error.message };
109
+ }
110
+ if (typeof error === "string") {
111
+ return { originalMessage: error };
112
+ }
113
+ if (typeof error === "object" && error !== null) {
114
+ const errorRecord = error;
115
+ const data = {};
116
+ if (hasUsableString(errorRecord.name)) data.originalName = errorRecord.name;
117
+ if (hasUsableString(errorRecord.message)) data.originalMessage = errorRecord.message;
118
+ if (hasUsableString(errorRecord.code)) data.originalCode = errorRecord.code;
119
+ return Object.keys(data).length > 0 ? data : { originalType: Object.prototype.toString.call(error) };
120
+ }
121
+ return { originalType: typeof error, originalMessage: String(error) };
108
122
  };
109
123
  const throwParaApiError = (message, code, status, responseURL, data, cause) => {
110
124
  const paraApiError = new import_error.ParaApiError(message, code, status, responseURL, data);
@@ -116,7 +130,7 @@ const handleResponseError = (error) => {
116
130
  if (error === null) throw new import_error.ParaApiError("Error is null");
117
131
  if (import_axios.default.isAxiosError(error)) {
118
132
  const data = (_a = error.response) == null ? void 0 : _a.data;
119
- let message = hasUsableString(data) ? data : getFallbackErrorMessage(error);
133
+ let message = hasUsableString(data) ? data : UNKNOWN_ERROR_MESSAGE;
120
134
  let serverCode;
121
135
  let serverData;
122
136
  if (data && typeof data === "object") {
@@ -144,7 +158,7 @@ const handleResponseError = (error) => {
144
158
  error
145
159
  );
146
160
  }
147
- throwParaApiError(getFallbackErrorMessage(error), void 0, void 0, void 0, void 0, error);
161
+ throwParaApiError(UNKNOWN_ERROR_MESSAGE, UNKNOWN_ERROR_CODE, void 0, void 0, getUnknownErrorData(error), error);
148
162
  };
149
163
  const isRetryableError = (error) => {
150
164
  var _a, _b, _c, _d;
package/dist/cjs/index.js CHANGED
@@ -26,19 +26,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
31
  SESSION_COOKIE_HEADER_NAME: () => import_consts.SESSION_COOKIE_HEADER_NAME,
32
- default: () => src_default
32
+ default: () => index_default
33
33
  });
34
- module.exports = __toCommonJS(src_exports);
35
- __reExport(src_exports, require("./client.js"), module.exports);
36
- __reExport(src_exports, require("./utils.js"), module.exports);
37
- __reExport(src_exports, require("./error.js"), module.exports);
34
+ module.exports = __toCommonJS(index_exports);
35
+ __reExport(index_exports, require("./client.js"), module.exports);
36
+ __reExport(index_exports, require("./utils.js"), module.exports);
37
+ __reExport(index_exports, require("./error.js"), module.exports);
38
38
  var import_consts = require("./consts.js");
39
- __reExport(src_exports, require("@getpara/shared"), module.exports);
39
+ __reExport(index_exports, require("@getpara/shared"), module.exports);
40
40
  var import_client = __toESM(require("./client.js"));
41
- var src_default = import_client.default;
41
+ var index_default = import_client.default;
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  SESSION_COOKIE_HEADER_NAME,
@@ -31,11 +31,25 @@ const handleResponseSuccess = (response) => {
31
31
  throw new ParaApiError("Invalid status code");
32
32
  };
33
33
  const UNKNOWN_ERROR_MESSAGE = "Unknown error";
34
+ const UNKNOWN_ERROR_CODE = "UNKNOWN";
34
35
  const hasUsableString = (value) => typeof value === "string" && value.trim().length > 0;
35
- const getFallbackErrorMessage = (error) => {
36
- if (hasUsableString(error == null ? void 0 : error.message)) return error.message;
37
- if (hasUsableString(error == null ? void 0 : error.code)) return error.code;
38
- return UNKNOWN_ERROR_MESSAGE;
36
+ const getUnknownErrorData = (error) => {
37
+ if (error === void 0) return void 0;
38
+ if (error instanceof Error) {
39
+ return { originalName: error.name, originalMessage: error.message };
40
+ }
41
+ if (typeof error === "string") {
42
+ return { originalMessage: error };
43
+ }
44
+ if (typeof error === "object" && error !== null) {
45
+ const errorRecord = error;
46
+ const data = {};
47
+ if (hasUsableString(errorRecord.name)) data.originalName = errorRecord.name;
48
+ if (hasUsableString(errorRecord.message)) data.originalMessage = errorRecord.message;
49
+ if (hasUsableString(errorRecord.code)) data.originalCode = errorRecord.code;
50
+ return Object.keys(data).length > 0 ? data : { originalType: Object.prototype.toString.call(error) };
51
+ }
52
+ return { originalType: typeof error, originalMessage: String(error) };
39
53
  };
40
54
  const throwParaApiError = (message, code, status, responseURL, data, cause) => {
41
55
  const paraApiError = new ParaApiError(message, code, status, responseURL, data);
@@ -47,7 +61,7 @@ const handleResponseError = (error) => {
47
61
  if (error === null) throw new ParaApiError("Error is null");
48
62
  if (axios.isAxiosError(error)) {
49
63
  const data = (_a = error.response) == null ? void 0 : _a.data;
50
- let message = hasUsableString(data) ? data : getFallbackErrorMessage(error);
64
+ let message = hasUsableString(data) ? data : UNKNOWN_ERROR_MESSAGE;
51
65
  let serverCode;
52
66
  let serverData;
53
67
  if (data && typeof data === "object") {
@@ -75,7 +89,7 @@ const handleResponseError = (error) => {
75
89
  error
76
90
  );
77
91
  }
78
- throwParaApiError(getFallbackErrorMessage(error), void 0, void 0, void 0, void 0, error);
92
+ throwParaApiError(UNKNOWN_ERROR_MESSAGE, UNKNOWN_ERROR_CODE, void 0, void 0, getUnknownErrorData(error), error);
79
93
  };
80
94
  const isRetryableError = (error) => {
81
95
  var _a, _b, _c, _d;
package/dist/esm/index.js CHANGED
@@ -5,8 +5,8 @@ export * from "./error.js";
5
5
  import { SESSION_COOKIE_HEADER_NAME } from "./consts.js";
6
6
  export * from "@getpara/shared";
7
7
  import Client from "./client.js";
8
- var src_default = Client;
8
+ var index_default = Client;
9
9
  export {
10
10
  SESSION_COOKIE_HEADER_NAME,
11
- src_default as default
11
+ index_default as default
12
12
  };
@@ -192,7 +192,7 @@ export type VerifyTelegramRes = {
192
192
  } | {
193
193
  isValid: false;
194
194
  };
195
- export declare const handleResponseSuccess: (response: AxiosResponse<any, any>) => AxiosResponse<any, any>;
195
+ export declare const handleResponseSuccess: (response: AxiosResponse<any, any>) => AxiosResponse<any, any, {}>;
196
196
  export declare const handleResponseError: (error: any) => void;
197
197
  export declare const isRetryableError: (error: AxiosError) => boolean;
198
198
  declare class Client {
@@ -346,20 +346,20 @@ declare class Client {
346
346
  }>;
347
347
  resendVerificationCodeByPhone({ userId, ...rest }: {
348
348
  userId: string;
349
- } & VerificationEmailProps): Promise<AxiosResponse<any, any>>;
350
- cancelRecoveryAttempt(email: string): Promise<AxiosResponse<any, any>>;
351
- check2FAStatus(userId: string): Promise<AxiosResponse<any, any>>;
352
- enable2FA(userId: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
349
+ } & VerificationEmailProps): Promise<AxiosResponse<any, any, {}>>;
350
+ cancelRecoveryAttempt(email: string): Promise<AxiosResponse<any, any, {}>>;
351
+ check2FAStatus(userId: string): Promise<AxiosResponse<any, any, {}>>;
352
+ enable2FA(userId: string, verificationCode: string): Promise<AxiosResponse<any, any, {}>>;
353
353
  setup2FA(userId: string): Promise<Setup2faResponse>;
354
- initializeRecovery(email: string): Promise<AxiosResponse<any, any>>;
354
+ initializeRecovery(email: string): Promise<AxiosResponse<any, any, {}>>;
355
355
  initializeFarcasterLogin({ appScheme }?: {
356
356
  appScheme?: string;
357
357
  }): Promise<any>;
358
358
  getFarcasterAuthStatus({ sessionLookupId }?: {
359
359
  sessionLookupId?: string;
360
360
  }): Promise<VerifyFarcasterResponse>;
361
- initializeRecoveryForPhone(phone: string, countryCode: string): Promise<AxiosResponse<any, any>>;
362
- finalizeRecovery(userId: string, walletId: string): Promise<AxiosResponse<any, any>>;
361
+ initializeRecoveryForPhone(phone: string, countryCode: string): Promise<AxiosResponse<any, any, {}>>;
362
+ finalizeRecovery(userId: string, walletId: string): Promise<AxiosResponse<any, any, {}>>;
363
363
  recoverUserShares(userId: string, walletId: string): Promise<AxiosResponse<{
364
364
  keyShare: {
365
365
  encryptedShare: string;
@@ -373,23 +373,23 @@ declare class Client {
373
373
  type: string;
374
374
  walletId: string;
375
375
  }[];
376
- }, any>>;
377
- verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
378
- verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
376
+ }, any, {}>>;
377
+ verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any, {}>>;
378
+ verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any, {}>>;
379
379
  verify2FA(auth: VerifiedAuth, verificationCode: string): Promise<any>;
380
380
  /**
381
381
  * @deprecated
382
382
  */
383
- verify2FAForPhone(phone: AuthIdentifier<'phone'>, verificationCode: string): Promise<AxiosResponse<any, any>>;
384
- tempTrasmissionInit(message: string, userId?: string): Promise<AxiosResponse<any, any>>;
385
- tempTrasmission(id: string): Promise<AxiosResponse<any, any>>;
386
- getPartner(partnerId: string): Promise<AxiosResponse<any, any>>;
383
+ verify2FAForPhone(phone: AuthIdentifier<'phone'>, verificationCode: string): Promise<AxiosResponse<any, any, {}>>;
384
+ tempTrasmissionInit(message: string, userId?: string): Promise<AxiosResponse<any, any, {}>>;
385
+ tempTrasmission(id: string): Promise<AxiosResponse<any, any, {}>>;
386
+ getPartner(partnerId: string): Promise<AxiosResponse<any, any, {}>>;
387
387
  getPolicyPermissions(userId: string, policyId: string): Promise<{
388
388
  allAccepted: boolean;
389
389
  }>;
390
- acceptScopes(userId: string, walletId: string, body: AcceptScopesBody): Promise<AxiosResponse<any, any>>;
390
+ acceptScopes(userId: string, walletId: string, body: AcceptScopesBody): Promise<AxiosResponse<any, any, {}>>;
391
391
  getPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<GetPendingTransactionResponse>>;
392
- acceptPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any>>;
392
+ acceptPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any, {}>>;
393
393
  getOnRampConfig(): Promise<OnRampConfig>;
394
394
  createOnRampPurchase({ userId, params, ...walletParams }: {
395
395
  userId: string;
@@ -403,7 +403,7 @@ declare class Client {
403
403
  getOnRampPurchase({ userId, purchaseId, ...params }: {
404
404
  userId: string;
405
405
  purchaseId: string;
406
- } & WalletParams): Promise<AxiosResponse<import("@getpara/shared").IOnRampPurchase, any>>;
406
+ } & WalletParams): Promise<AxiosResponse<import("@getpara/shared").IOnRampPurchase, any, {}>>;
407
407
  signMoonPayUrl(userId: string, { url, type, cosmosPrefix, testMode, walletId, externalWalletAddress, }: {
408
408
  url: string;
409
409
  type: TWalletType;
@@ -413,7 +413,7 @@ declare class Client {
413
413
  externalWalletAddress?: string;
414
414
  }): Promise<AxiosResponse<{
415
415
  signature: string;
416
- }, any>>;
416
+ }, any, {}>>;
417
417
  generateOffRampTx<ReturnType = {
418
418
  tx: string;
419
419
  message?: string;
@@ -444,7 +444,7 @@ declare class Client {
444
444
  userId: string;
445
445
  walletId: string;
446
446
  useDKLS: boolean;
447
- } & BackupKitEmailProps): Promise<AxiosResponse<any, any>>;
447
+ } & BackupKitEmailProps): Promise<AxiosResponse<any, any, {}>>;
448
448
  keepSessionAlive(userId: string): Promise<any>;
449
449
  persistRecoveryPublicKeys(userId: string, publicKeys: string[]): Promise<{
450
450
  recoveryPublicKeys: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/user-management-client",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "dependencies": {
5
5
  "@getpara/shared": "^1.23.0",
6
6
  "@opentelemetry/api": "^1.9.1",
@@ -22,7 +22,7 @@
22
22
  "dist",
23
23
  "package.json"
24
24
  ],
25
- "gitHead": "2e70485f8f206ff50f58b339ebf0922fd259858f",
25
+ "gitHead": "565535ab0cf38d65f6996fc9f1ede52d133ddac0",
26
26
  "main": "dist/cjs/index.js",
27
27
  "module": "dist/esm/index.js",
28
28
  "scripts": {