@dynamic-labs-wallet/core 1.0.80 → 1.0.81

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 CHANGED
@@ -951,7 +951,7 @@ const getRequiredExternalKeyShareId = (ks)=>{
951
951
  * before it is posted and surfaces in Datadog exactly as the recovery path does.
952
952
  */ const assertDynamicLocationsHaveExternalKeyShareId = (locations)=>locations.filter((location)=>location.location === BackupLocation.DYNAMIC).forEach((location)=>getRequiredExternalKeyShareId(location));
953
953
 
954
- var version = "1.0.80";
954
+ var version = "1.0.81";
955
955
 
956
956
  class BaseClient {
957
957
  /**
@@ -2361,13 +2361,53 @@ class WalletApiError extends Error {
2361
2361
  this.status = status;
2362
2362
  }
2363
2363
  }
2364
+ const INTERNAL_SERVER_ERROR_MESSAGE = 'Internal server error';
2364
2365
  const STATUS_MESSAGES = {
2365
2366
  400: 'Invalid request',
2366
- 401: 'Authorization header or cookie is required',
2367
2367
  403: 'Forbidden',
2368
2368
  422: 'Unprocessable content',
2369
2369
  429: 'Rate limited',
2370
- 500: 'Internal server error'
2370
+ 500: INTERNAL_SERVER_ERROR_MESSAGE
2371
+ };
2372
+ const MISSING_AUTH_MESSAGE = 'Authorization header or cookie missing';
2373
+ // A 401 can mean the request carried no credentials, or carried credentials the
2374
+ // backend rejected — the two need different messages. The Authorization header
2375
+ // is readable so we can confirm its presence; the auth cookie is httpOnly, so we
2376
+ // can only report whether cookie mode was enabled (`withCredentials`), not that a
2377
+ // cookie was actually attached.
2378
+ const getRequestCredentials = (error)=>{
2379
+ var _error_config, _error_config1;
2380
+ const requestHeaders = (_error_config = error.config) == null ? void 0 : _error_config.headers;
2381
+ var _requestHeaders_Authorization;
2382
+ const hasAuthorizationHeader = Boolean((_requestHeaders_Authorization = requestHeaders == null ? void 0 : requestHeaders['Authorization']) != null ? _requestHeaders_Authorization : requestHeaders == null ? void 0 : requestHeaders['authorization']);
2383
+ const usesCookieAuth = Boolean((_error_config1 = error.config) == null ? void 0 : _error_config1.withCredentials);
2384
+ return {
2385
+ hasAuthorizationHeader,
2386
+ usesCookieAuth
2387
+ };
2388
+ };
2389
+ const resolveUnauthorizedMessage = (error)=>{
2390
+ const { hasAuthorizationHeader, usesCookieAuth } = getRequestCredentials(error);
2391
+ if (!hasAuthorizationHeader && !usesCookieAuth) {
2392
+ return MISSING_AUTH_MESSAGE;
2393
+ }
2394
+ const credentialDescriptions = [];
2395
+ if (hasAuthorizationHeader) {
2396
+ credentialDescriptions.push('Authorization header present');
2397
+ }
2398
+ if (usesCookieAuth) {
2399
+ credentialDescriptions.push('withCredentials enabled (cookie auth)');
2400
+ }
2401
+ return `Unauthorized (${credentialDescriptions.join(', ')})`;
2402
+ };
2403
+ const resolveStatusMessage = (status, error)=>{
2404
+ if (status === 401) {
2405
+ return resolveUnauthorizedMessage(error);
2406
+ }
2407
+ if (status && STATUS_MESSAGES[status]) {
2408
+ return STATUS_MESSAGES[status];
2409
+ }
2410
+ return undefined;
2371
2411
  };
2372
2412
  const handleAxiosError = (error, message, context, _logger)=>{
2373
2413
  var _error_config, _error_config1, _error_response, _error_response1, _error_response2, _error_response3;
@@ -2391,8 +2431,10 @@ const handleAxiosError = (error, message, context, _logger)=>{
2391
2431
  const logLevel = ((_error_response2 = error.response) == null ? void 0 : _error_response2.status) === 429 ? 'warn' : 'error';
2392
2432
  Logger[logLevel]('[DynamicWaasWalletClient] Axios error: ', logPayload);
2393
2433
  const status = (_error_response3 = error.response) == null ? void 0 : _error_response3.status;
2394
- const resolvedStatus = status && STATUS_MESSAGES[status] ? status : 500;
2395
- throw new WalletApiError(resolvedStatus, STATUS_MESSAGES[resolvedStatus]);
2434
+ const statusMessage = resolveStatusMessage(status, error);
2435
+ const resolvedStatus = status && statusMessage ? status : 500;
2436
+ const resolvedMessage = statusMessage != null ? statusMessage : INTERNAL_SERVER_ERROR_MESSAGE;
2437
+ throw new WalletApiError(resolvedStatus, resolvedMessage);
2396
2438
  };
2397
2439
 
2398
2440
  Object.defineProperty(exports, "SigningAlgorithm", {
package/index.esm.js CHANGED
@@ -951,7 +951,7 @@ const getRequiredExternalKeyShareId = (ks)=>{
951
951
  * before it is posted and surfaces in Datadog exactly as the recovery path does.
952
952
  */ const assertDynamicLocationsHaveExternalKeyShareId = (locations)=>locations.filter((location)=>location.location === BackupLocation.DYNAMIC).forEach((location)=>getRequiredExternalKeyShareId(location));
953
953
 
954
- var version = "1.0.80";
954
+ var version = "1.0.81";
955
955
 
956
956
  class BaseClient {
957
957
  /**
@@ -2361,13 +2361,53 @@ class WalletApiError extends Error {
2361
2361
  this.status = status;
2362
2362
  }
2363
2363
  }
2364
+ const INTERNAL_SERVER_ERROR_MESSAGE = 'Internal server error';
2364
2365
  const STATUS_MESSAGES = {
2365
2366
  400: 'Invalid request',
2366
- 401: 'Authorization header or cookie is required',
2367
2367
  403: 'Forbidden',
2368
2368
  422: 'Unprocessable content',
2369
2369
  429: 'Rate limited',
2370
- 500: 'Internal server error'
2370
+ 500: INTERNAL_SERVER_ERROR_MESSAGE
2371
+ };
2372
+ const MISSING_AUTH_MESSAGE = 'Authorization header or cookie missing';
2373
+ // A 401 can mean the request carried no credentials, or carried credentials the
2374
+ // backend rejected — the two need different messages. The Authorization header
2375
+ // is readable so we can confirm its presence; the auth cookie is httpOnly, so we
2376
+ // can only report whether cookie mode was enabled (`withCredentials`), not that a
2377
+ // cookie was actually attached.
2378
+ const getRequestCredentials = (error)=>{
2379
+ var _error_config, _error_config1;
2380
+ const requestHeaders = (_error_config = error.config) == null ? void 0 : _error_config.headers;
2381
+ var _requestHeaders_Authorization;
2382
+ const hasAuthorizationHeader = Boolean((_requestHeaders_Authorization = requestHeaders == null ? void 0 : requestHeaders['Authorization']) != null ? _requestHeaders_Authorization : requestHeaders == null ? void 0 : requestHeaders['authorization']);
2383
+ const usesCookieAuth = Boolean((_error_config1 = error.config) == null ? void 0 : _error_config1.withCredentials);
2384
+ return {
2385
+ hasAuthorizationHeader,
2386
+ usesCookieAuth
2387
+ };
2388
+ };
2389
+ const resolveUnauthorizedMessage = (error)=>{
2390
+ const { hasAuthorizationHeader, usesCookieAuth } = getRequestCredentials(error);
2391
+ if (!hasAuthorizationHeader && !usesCookieAuth) {
2392
+ return MISSING_AUTH_MESSAGE;
2393
+ }
2394
+ const credentialDescriptions = [];
2395
+ if (hasAuthorizationHeader) {
2396
+ credentialDescriptions.push('Authorization header present');
2397
+ }
2398
+ if (usesCookieAuth) {
2399
+ credentialDescriptions.push('withCredentials enabled (cookie auth)');
2400
+ }
2401
+ return `Unauthorized (${credentialDescriptions.join(', ')})`;
2402
+ };
2403
+ const resolveStatusMessage = (status, error)=>{
2404
+ if (status === 401) {
2405
+ return resolveUnauthorizedMessage(error);
2406
+ }
2407
+ if (status && STATUS_MESSAGES[status]) {
2408
+ return STATUS_MESSAGES[status];
2409
+ }
2410
+ return undefined;
2371
2411
  };
2372
2412
  const handleAxiosError = (error, message, context, _logger)=>{
2373
2413
  var _error_config, _error_config1, _error_response, _error_response1, _error_response2, _error_response3;
@@ -2391,8 +2431,10 @@ const handleAxiosError = (error, message, context, _logger)=>{
2391
2431
  const logLevel = ((_error_response2 = error.response) == null ? void 0 : _error_response2.status) === 429 ? 'warn' : 'error';
2392
2432
  Logger[logLevel]('[DynamicWaasWalletClient] Axios error: ', logPayload);
2393
2433
  const status = (_error_response3 = error.response) == null ? void 0 : _error_response3.status;
2394
- const resolvedStatus = status && STATUS_MESSAGES[status] ? status : 500;
2395
- throw new WalletApiError(resolvedStatus, STATUS_MESSAGES[resolvedStatus]);
2434
+ const statusMessage = resolveStatusMessage(status, error);
2435
+ const resolvedStatus = status && statusMessage ? status : 500;
2436
+ const resolvedMessage = statusMessage != null ? statusMessage : INTERNAL_SERVER_ERROR_MESSAGE;
2437
+ throw new WalletApiError(resolvedStatus, resolvedMessage);
2396
2438
  };
2397
2439
 
2398
2440
  export { AuthMode, BITCOIN_ADDRESS_TYPE_CONFIG, BITCOIN_DERIVATION_PATHS, BROWSER_SDK_ROUTE_PREFIX, BackupLocation, BitcoinAddressType, BitcoinNetwork, BusinessAccountClient, BusinessAccountMemberRole, BusinessAccountSignerType, 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, DynamicServerApiClient, DynamicSessionPublicKeyHeader, DynamicTraceElapsedTimeHeader, DynamicTraceIdHeader, ENCRYPTED_SHARES_STORAGE_SUFFIX, ENVIRONMENT_ENUM, EVM_COMPATIBLE_CHAINS, FEATURE_FLAGS, IFRAME_DOMAIN_MAP, Logger, MIDNIGHT_DERIVATION_PATHS, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_DEV_API_URL, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, MPC_RELAY_URL_MAP, NoopLogger, 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, SERVER_SDK_ROUTE_PREFIX, SOLANA_RPC_URL, SuccessEventType, ThresholdSignatureScheme, URL_PATTERNS, WalletApiError, WalletOperation, WalletReadyState, assertDynamicLocationsHaveExternalKeyShareId, chain, chainEnumToVerifiedCredentialName, formatNamespacedVersion, getBitcoinChainConfig, getClientThreshold, getDynamicServerThreshold, getEnvironmentFromUrl, getMPCChainConfig, getRequiredExternalKeyShareId, getReshareConfig, getServerWalletReshareConfig, getTSSConfig, getVersionNamespace, getVersionWithoutNamespace, handleAxiosError, isEvmCompatibleChain, isRecoveredForwardMpcConnectionChurn, parseNamespacedVersion, serializeError, serializeMessageForForwardMPC, verifiedCredentialNameToChainEnum };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/core",
3
- "version": "1.0.80",
3
+ "version": "1.0.81",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@dynamic-labs/sdk-api-core": "^0.0.1083",
8
- "@dynamic-labs-wallet/primitives": "1.0.80",
8
+ "@dynamic-labs-wallet/primitives": "1.0.81",
9
9
  "axios": "1.16.0",
10
10
  "uuid": "11.1.0"
11
11
  },
@@ -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;AAGxC,qBAAa,cAAe,SAAQ,KAAK;IACvC,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK5C;AAWD,eAAO,MAAM,gBAAgB,UACpB,UAAU,WACR,MAAM,WACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACtB,OAAO,UAsBlB,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,YAAY,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;AAGxC,qBAAa,cAAe,SAAQ,KAAK;IACvC,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK5C;AAsDD,eAAO,MAAM,gBAAgB,UACpB,UAAU,WACR,MAAM,WACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACtB,OAAO,UAwBlB,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC"}