@dynamic-labs-wallet/core 0.0.276 → 0.0.278
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.
- package/index.cjs.js +18 -15
- package/index.esm.js +18 -16
- package/package.json +2 -5
- package/src/services/axiosErrorResponse.d.ts +4 -0
- package/src/services/axiosErrorResponse.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -4,7 +4,6 @@ var uuid = require('uuid');
|
|
|
4
4
|
var logger$1 = require('@dynamic-labs/logger');
|
|
5
5
|
var axios = require('axios');
|
|
6
6
|
var forwardMpcClient = require('@dynamic-labs-wallet/forward-mpc-client');
|
|
7
|
-
var createHttpError = require('http-errors');
|
|
8
7
|
|
|
9
8
|
var ENVIRONMENT_ENUM = /*#__PURE__*/ function(ENVIRONMENT_ENUM) {
|
|
10
9
|
ENVIRONMENT_ENUM["development"] = "development";
|
|
@@ -1236,6 +1235,20 @@ const serializeMessageForForwardMPC = ({ message, isFormatted = false, chainName
|
|
|
1236
1235
|
return serializedMessage;
|
|
1237
1236
|
};
|
|
1238
1237
|
|
|
1238
|
+
class WalletApiError extends Error {
|
|
1239
|
+
constructor(status, message){
|
|
1240
|
+
super(message);
|
|
1241
|
+
this.name = 'WalletApiError';
|
|
1242
|
+
this.status = status;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
const STATUS_MESSAGES = {
|
|
1246
|
+
400: 'Invalid request',
|
|
1247
|
+
401: 'Authorization header or cookie is required',
|
|
1248
|
+
403: 'Forbidden',
|
|
1249
|
+
422: 'Unprocessable content',
|
|
1250
|
+
500: 'Internal server error'
|
|
1251
|
+
};
|
|
1239
1252
|
const handleAxiosError = (error, message, context, logger)=>{
|
|
1240
1253
|
var _error_response, _error_response1, _error_response2;
|
|
1241
1254
|
logger.error('[DynamicWaasWalletClient] Axios error: ', {
|
|
@@ -1244,20 +1257,9 @@ const handleAxiosError = (error, message, context, logger)=>{
|
|
|
1244
1257
|
status: (_error_response1 = error.response) == null ? void 0 : _error_response1.status,
|
|
1245
1258
|
context
|
|
1246
1259
|
});
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
case 401:
|
|
1251
|
-
throw createHttpError(401, 'Authorization header or cookie is required');
|
|
1252
|
-
case 403:
|
|
1253
|
-
throw createHttpError(403, 'Forbidden');
|
|
1254
|
-
case 422:
|
|
1255
|
-
throw createHttpError(422, 'Unprocessable content');
|
|
1256
|
-
case 500:
|
|
1257
|
-
throw createHttpError(500, 'Internal server error');
|
|
1258
|
-
default:
|
|
1259
|
-
throw createHttpError(500, 'Internal server error');
|
|
1260
|
-
}
|
|
1260
|
+
const status = (_error_response2 = error.response) == null ? void 0 : _error_response2.status;
|
|
1261
|
+
const resolvedStatus = status && STATUS_MESSAGES[status] ? status : 500;
|
|
1262
|
+
throw new WalletApiError(resolvedStatus, STATUS_MESSAGES[resolvedStatus]);
|
|
1261
1263
|
};
|
|
1262
1264
|
|
|
1263
1265
|
exports.AuthMode = AuthMode;
|
|
@@ -1312,6 +1314,7 @@ exports.SigningAlgorithm = SigningAlgorithm;
|
|
|
1312
1314
|
exports.SuccessEventType = SuccessEventType;
|
|
1313
1315
|
exports.ThresholdSignatureScheme = ThresholdSignatureScheme;
|
|
1314
1316
|
exports.URL_PATTERNS = URL_PATTERNS;
|
|
1317
|
+
exports.WalletApiError = WalletApiError;
|
|
1315
1318
|
exports.WalletOperation = WalletOperation;
|
|
1316
1319
|
exports.WalletReadyState = WalletReadyState;
|
|
1317
1320
|
exports.chain = chain;
|
package/index.esm.js
CHANGED
|
@@ -2,7 +2,6 @@ import { v4 } from 'uuid';
|
|
|
2
2
|
import { Logger, LogLevel } from '@dynamic-labs/logger';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { ForwardMPCClient } from '@dynamic-labs-wallet/forward-mpc-client';
|
|
5
|
-
import createHttpError from 'http-errors';
|
|
6
5
|
|
|
7
6
|
var ENVIRONMENT_ENUM = /*#__PURE__*/ function(ENVIRONMENT_ENUM) {
|
|
8
7
|
ENVIRONMENT_ENUM["development"] = "development";
|
|
@@ -1234,6 +1233,20 @@ const serializeMessageForForwardMPC = ({ message, isFormatted = false, chainName
|
|
|
1234
1233
|
return serializedMessage;
|
|
1235
1234
|
};
|
|
1236
1235
|
|
|
1236
|
+
class WalletApiError extends Error {
|
|
1237
|
+
constructor(status, message){
|
|
1238
|
+
super(message);
|
|
1239
|
+
this.name = 'WalletApiError';
|
|
1240
|
+
this.status = status;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const STATUS_MESSAGES = {
|
|
1244
|
+
400: 'Invalid request',
|
|
1245
|
+
401: 'Authorization header or cookie is required',
|
|
1246
|
+
403: 'Forbidden',
|
|
1247
|
+
422: 'Unprocessable content',
|
|
1248
|
+
500: 'Internal server error'
|
|
1249
|
+
};
|
|
1237
1250
|
const handleAxiosError = (error, message, context, logger)=>{
|
|
1238
1251
|
var _error_response, _error_response1, _error_response2;
|
|
1239
1252
|
logger.error('[DynamicWaasWalletClient] Axios error: ', {
|
|
@@ -1242,20 +1255,9 @@ const handleAxiosError = (error, message, context, logger)=>{
|
|
|
1242
1255
|
status: (_error_response1 = error.response) == null ? void 0 : _error_response1.status,
|
|
1243
1256
|
context
|
|
1244
1257
|
});
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
case 401:
|
|
1249
|
-
throw createHttpError(401, 'Authorization header or cookie is required');
|
|
1250
|
-
case 403:
|
|
1251
|
-
throw createHttpError(403, 'Forbidden');
|
|
1252
|
-
case 422:
|
|
1253
|
-
throw createHttpError(422, 'Unprocessable content');
|
|
1254
|
-
case 500:
|
|
1255
|
-
throw createHttpError(500, 'Internal server error');
|
|
1256
|
-
default:
|
|
1257
|
-
throw createHttpError(500, 'Internal server error');
|
|
1258
|
-
}
|
|
1258
|
+
const status = (_error_response2 = error.response) == null ? void 0 : _error_response2.status;
|
|
1259
|
+
const resolvedStatus = status && STATUS_MESSAGES[status] ? status : 500;
|
|
1260
|
+
throw new WalletApiError(resolvedStatus, STATUS_MESSAGES[resolvedStatus]);
|
|
1259
1261
|
};
|
|
1260
1262
|
|
|
1261
|
-
export { AuthMode, BITCOIN_ADDRESS_TYPE_CONFIG, BITCOIN_DERIVATION_PATHS, BackupLocation, BitcoinAddressType, BitcoinNetwork, CreateRoomPartiesOptions, DELEGATED_SHARE_COUNT, DYNAMIC_AUTH_BASE_API_URL_MAP, DYNAMIC_AUTH_DEV_BASE_API_URL, DYNAMIC_AUTH_PREPROD_BASE_API_URL, DYNAMIC_AUTH_PROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_REDCOAST_API_KEY_MAP, DYNAMIC_CLIENT_RELAY_REDCOAST_APP_ID_MAP, DYNAMIC_FORWARD_MPC_DEV_ENCLAVE_URL, DYNAMIC_FORWARD_MPC_ENCLAVE_ATTESTATION_CONFIG_MAP, DYNAMIC_FORWARD_MPC_ENCLAVE_URL_MAP, DYNAMIC_FORWARD_MPC_PREPROD_ENCLAVE_URL, DYNAMIC_FORWARD_MPC_PROD_ENCLAVE_URL, DYNAMIC_KEYSHARES_RELAY_MAP, DYNAMIC_KEYSHARES_RELAY_PREPROD_BASE_API_URL, DYNAMIC_KEYSHARES_RELAY_PROD_BASE_API_URL, DynamicApiClient, DynamicClientSessionSignature, DynamicElevatedAccessTokenHeader, DynamicForwardMPCHeader, DynamicMfaTokenHeader, DynamicRequestIdHeader, DynamicTraceElapsedTimeHeader, DynamicTraceIdHeader, ENCRYPTED_SHARES_STORAGE_SUFFIX, ENVIRONMENT_ENUM, FEATURE_FLAGS, IFRAME_DOMAIN_MAP, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_DEV_API_URL, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, MPC_RELAY_URL_MAP, PREPROD_RELAY_API_KEY, PREPROD_RELAY_APP_ID, PROD_RELAY_API_KEY, PROD_RELAY_APP_ID, RELAY_API_KEY_HEADER, RELAY_APP_ID_HEADER, SDK_NAMESPACE, SOLANA_RPC_URL, SigningAlgorithm, SuccessEventType, ThresholdSignatureScheme, URL_PATTERNS, WalletOperation, WalletReadyState, chain, chainEnumToVerifiedCredentialName, formatNamespacedVersion, getBitcoinChainConfig, getClientThreshold, getDynamicServerThreshold, getEnvironmentFromUrl, getMPCChainConfig, getReshareConfig, getServerWalletReshareConfig, getTSSConfig, getVersionNamespace, getVersionWithoutNamespace, handleAxiosError, parseNamespacedVersion, serializeMessageForForwardMPC, verifiedCredentialNameToChainEnum };
|
|
1263
|
+
export { AuthMode, BITCOIN_ADDRESS_TYPE_CONFIG, BITCOIN_DERIVATION_PATHS, BackupLocation, BitcoinAddressType, BitcoinNetwork, CreateRoomPartiesOptions, DELEGATED_SHARE_COUNT, DYNAMIC_AUTH_BASE_API_URL_MAP, DYNAMIC_AUTH_DEV_BASE_API_URL, DYNAMIC_AUTH_PREPROD_BASE_API_URL, DYNAMIC_AUTH_PROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_REDCOAST_API_KEY_MAP, DYNAMIC_CLIENT_RELAY_REDCOAST_APP_ID_MAP, DYNAMIC_FORWARD_MPC_DEV_ENCLAVE_URL, DYNAMIC_FORWARD_MPC_ENCLAVE_ATTESTATION_CONFIG_MAP, DYNAMIC_FORWARD_MPC_ENCLAVE_URL_MAP, DYNAMIC_FORWARD_MPC_PREPROD_ENCLAVE_URL, DYNAMIC_FORWARD_MPC_PROD_ENCLAVE_URL, DYNAMIC_KEYSHARES_RELAY_MAP, DYNAMIC_KEYSHARES_RELAY_PREPROD_BASE_API_URL, DYNAMIC_KEYSHARES_RELAY_PROD_BASE_API_URL, DynamicApiClient, DynamicClientSessionSignature, DynamicElevatedAccessTokenHeader, DynamicForwardMPCHeader, DynamicMfaTokenHeader, DynamicRequestIdHeader, DynamicTraceElapsedTimeHeader, DynamicTraceIdHeader, ENCRYPTED_SHARES_STORAGE_SUFFIX, ENVIRONMENT_ENUM, FEATURE_FLAGS, IFRAME_DOMAIN_MAP, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_DEV_API_URL, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, MPC_RELAY_URL_MAP, PREPROD_RELAY_API_KEY, PREPROD_RELAY_APP_ID, PROD_RELAY_API_KEY, PROD_RELAY_APP_ID, RELAY_API_KEY_HEADER, RELAY_APP_ID_HEADER, SDK_NAMESPACE, SOLANA_RPC_URL, SigningAlgorithm, SuccessEventType, ThresholdSignatureScheme, URL_PATTERNS, WalletApiError, WalletOperation, WalletReadyState, chain, chainEnumToVerifiedCredentialName, formatNamespacedVersion, getBitcoinChainConfig, getClientThreshold, getDynamicServerThreshold, getEnvironmentFromUrl, getMPCChainConfig, getReshareConfig, getServerWalletReshareConfig, getTSSConfig, getVersionNamespace, getVersionWithoutNamespace, handleAxiosError, parseNamespacedVersion, serializeMessageForForwardMPC, verifiedCredentialNameToChainEnum };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.278",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"@dynamic-labs/logger": "^4.25.3",
|
|
9
9
|
"@dynamic-labs/sdk-api-core": "^0.0.875",
|
|
10
10
|
"axios": "1.13.5",
|
|
11
|
-
"http-errors": "2.0.0",
|
|
12
11
|
"uuid": "11.1.0"
|
|
13
12
|
},
|
|
14
13
|
"files": [
|
|
@@ -38,7 +37,5 @@
|
|
|
38
37
|
"default": "./index.esm.js"
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/http-errors": "^2.0.0"
|
|
43
|
-
}
|
|
40
|
+
"devDependencies": {}
|
|
44
41
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { AxiosError } from 'axios';
|
|
2
2
|
import type { Logger } from '@dynamic-labs/logger';
|
|
3
|
+
export declare class WalletApiError extends Error {
|
|
4
|
+
status: number;
|
|
5
|
+
constructor(status: number, message: string);
|
|
6
|
+
}
|
|
3
7
|
export declare const handleAxiosError: (error: AxiosError, message: string, context: Record<string, unknown>, logger: Logger) => never;
|
|
4
8
|
export type { AxiosError } from 'axios';
|
|
5
9
|
//# sourceMappingURL=axiosErrorResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axiosErrorResponse.d.ts","sourceRoot":"","sources":["../../src/services/axiosErrorResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"axiosErrorResponse.d.ts","sourceRoot":"","sources":["../../src/services/axiosErrorResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,cAAe,SAAQ,KAAK;IACvC,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK5C;AAUD,eAAO,MAAM,gBAAgB,UACpB,UAAU,WACR,MAAM,WACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UACxB,MAAM,UAYf,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC"}
|