@dynamic-labs-wallet/core 0.0.84 → 0.0.86
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 +30 -2
- package/index.esm.js +28 -4
- package/package.json +5 -1
- package/src/api/axiosErrorResponse.d.ts +4 -0
- package/src/api/axiosErrorResponse.d.ts.map +1 -0
- package/src/api/index.d.ts +1 -0
- package/src/api/index.d.ts.map +1 -1
- package/src/eventStream/utils.d.ts +1 -1
- package/src/eventStream/utils.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
var uuid = require('uuid');
|
|
5
|
+
var createHttpError = require('http-errors');
|
|
5
6
|
|
|
6
7
|
const DYNAMIC_AUTH_PROD_BASE_API_URL = 'https://app.dynamicauth.com';
|
|
7
8
|
const DYNAMIC_AUTH_PREPROD_BASE_API_URL = 'https://app.dynamic-preprod.xyz';
|
|
@@ -457,6 +458,24 @@ var SuccessEventType = /*#__PURE__*/ function(SuccessEventType) {
|
|
|
457
458
|
}({});
|
|
458
459
|
// iframe communication types end
|
|
459
460
|
|
|
461
|
+
const handleAxiosError = (error)=>{
|
|
462
|
+
var _error_response;
|
|
463
|
+
switch((_error_response = error.response) == null ? void 0 : _error_response.status){
|
|
464
|
+
case 400:
|
|
465
|
+
throw createHttpError(400, 'Invalid request');
|
|
466
|
+
case 401:
|
|
467
|
+
throw createHttpError(401, 'Authorization header or cookie is required');
|
|
468
|
+
case 403:
|
|
469
|
+
throw createHttpError(403, 'Forbidden');
|
|
470
|
+
case 422:
|
|
471
|
+
throw createHttpError(422, 'Unprocessable content');
|
|
472
|
+
case 500:
|
|
473
|
+
throw createHttpError(500, 'Internal server error');
|
|
474
|
+
default:
|
|
475
|
+
throw createHttpError(500, 'Internal server error');
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
460
479
|
/**
|
|
461
480
|
* Creates a promise that resolves when a specific event is received from an event stream.
|
|
462
481
|
* Adds a timeout to prevent hanging and races the two promises.
|
|
@@ -528,8 +547,12 @@ var SuccessEventType = /*#__PURE__*/ function(SuccessEventType) {
|
|
|
528
547
|
onCeremonyComplete == null ? void 0 : onCeremonyComplete(accountAddress, walletId);
|
|
529
548
|
}
|
|
530
549
|
if (event.type === 'error') {
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
const error = createErrorFromEventData(event.data);
|
|
551
|
+
if (error instanceof axios.AxiosError) {
|
|
552
|
+
handleAxiosError(error);
|
|
553
|
+
}
|
|
554
|
+
reject(error);
|
|
555
|
+
onError == null ? void 0 : onError(error);
|
|
533
556
|
}
|
|
534
557
|
}
|
|
535
558
|
processStream();
|
|
@@ -771,6 +794,10 @@ class DynamicApiClient extends BaseClient {
|
|
|
771
794
|
}
|
|
772
795
|
}
|
|
773
796
|
|
|
797
|
+
Object.defineProperty(exports, "AxiosError", {
|
|
798
|
+
enumerable: true,
|
|
799
|
+
get: function () { return axios.AxiosError; }
|
|
800
|
+
});
|
|
774
801
|
exports.BITCOIN_DERIVATION_PATHS = BITCOIN_DERIVATION_PATHS;
|
|
775
802
|
exports.BackupLocation = BackupLocation;
|
|
776
803
|
exports.ChainEnumToVerifiedCredentialName = ChainEnumToVerifiedCredentialName;
|
|
@@ -808,3 +835,4 @@ exports.getMPCChainConfig = getMPCChainConfig;
|
|
|
808
835
|
exports.getReshareConfig = getReshareConfig;
|
|
809
836
|
exports.getServerWalletReshareConfig = getServerWalletReshareConfig;
|
|
810
837
|
exports.getTSSConfig = getTSSConfig;
|
|
838
|
+
exports.handleAxiosError = handleAxiosError;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
1
|
+
import axios, { AxiosError } from 'axios';
|
|
2
|
+
export { AxiosError } from 'axios';
|
|
2
3
|
import { v4 } from 'uuid';
|
|
4
|
+
import createHttpError from 'http-errors';
|
|
3
5
|
|
|
4
6
|
const DYNAMIC_AUTH_PROD_BASE_API_URL = 'https://app.dynamicauth.com';
|
|
5
7
|
const DYNAMIC_AUTH_PREPROD_BASE_API_URL = 'https://app.dynamic-preprod.xyz';
|
|
@@ -455,6 +457,24 @@ var SuccessEventType = /*#__PURE__*/ function(SuccessEventType) {
|
|
|
455
457
|
}({});
|
|
456
458
|
// iframe communication types end
|
|
457
459
|
|
|
460
|
+
const handleAxiosError = (error)=>{
|
|
461
|
+
var _error_response;
|
|
462
|
+
switch((_error_response = error.response) == null ? void 0 : _error_response.status){
|
|
463
|
+
case 400:
|
|
464
|
+
throw createHttpError(400, 'Invalid request');
|
|
465
|
+
case 401:
|
|
466
|
+
throw createHttpError(401, 'Authorization header or cookie is required');
|
|
467
|
+
case 403:
|
|
468
|
+
throw createHttpError(403, 'Forbidden');
|
|
469
|
+
case 422:
|
|
470
|
+
throw createHttpError(422, 'Unprocessable content');
|
|
471
|
+
case 500:
|
|
472
|
+
throw createHttpError(500, 'Internal server error');
|
|
473
|
+
default:
|
|
474
|
+
throw createHttpError(500, 'Internal server error');
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
|
|
458
478
|
/**
|
|
459
479
|
* Creates a promise that resolves when a specific event is received from an event stream.
|
|
460
480
|
* Adds a timeout to prevent hanging and races the two promises.
|
|
@@ -526,8 +546,12 @@ var SuccessEventType = /*#__PURE__*/ function(SuccessEventType) {
|
|
|
526
546
|
onCeremonyComplete == null ? void 0 : onCeremonyComplete(accountAddress, walletId);
|
|
527
547
|
}
|
|
528
548
|
if (event.type === 'error') {
|
|
529
|
-
|
|
530
|
-
|
|
549
|
+
const error = createErrorFromEventData(event.data);
|
|
550
|
+
if (error instanceof AxiosError) {
|
|
551
|
+
handleAxiosError(error);
|
|
552
|
+
}
|
|
553
|
+
reject(error);
|
|
554
|
+
onError == null ? void 0 : onError(error);
|
|
531
555
|
}
|
|
532
556
|
}
|
|
533
557
|
processStream();
|
|
@@ -769,4 +793,4 @@ class DynamicApiClient extends BaseClient {
|
|
|
769
793
|
}
|
|
770
794
|
}
|
|
771
795
|
|
|
772
|
-
export { BITCOIN_DERIVATION_PATHS, BackupLocation, ChainEnumToVerifiedCredentialName, CreateRoomPartiesOptions, 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_DEV_BASE_API_URL, DYNAMIC_CLIENT_RELAY_MAP, DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_PROD_BASE_API_URL, DynamicApiClient, DynamicClientSessionSignature, DynamicRequestIdHeader, ENVIRONMENT_ENUM, IFRAME_DOMAIN_MAP, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_DEV_API_URL, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, SOLANA_RPC_URL, SigningAlgorithm, SuccessEventType, ThresholdSignatureScheme, URL_PATTERNS, VerifiedCredentialNameToChainEnum, WalletOperation, chain, getClientThreshold, getDynamicServerThreshold, getEnvironmentFromUrl, getMPCChainConfig, getReshareConfig, getServerWalletReshareConfig, getTSSConfig };
|
|
796
|
+
export { BITCOIN_DERIVATION_PATHS, BackupLocation, ChainEnumToVerifiedCredentialName, CreateRoomPartiesOptions, 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_DEV_BASE_API_URL, DYNAMIC_CLIENT_RELAY_MAP, DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_PROD_BASE_API_URL, DynamicApiClient, DynamicClientSessionSignature, DynamicRequestIdHeader, ENVIRONMENT_ENUM, IFRAME_DOMAIN_MAP, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_DEV_API_URL, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, SOLANA_RPC_URL, SigningAlgorithm, SuccessEventType, ThresholdSignatureScheme, URL_PATTERNS, VerifiedCredentialNameToChainEnum, WalletOperation, chain, getClientThreshold, getDynamicServerThreshold, getEnvironmentFromUrl, getMPCChainConfig, getReshareConfig, getServerWalletReshareConfig, getTSSConfig, handleAxiosError };
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.86",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"axios": "1.9.0",
|
|
7
|
+
"http-errors": "2.0.0",
|
|
7
8
|
"uuid": "11.1.0"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
@@ -29,5 +30,8 @@
|
|
|
29
30
|
"require": "./index.cjs.js",
|
|
30
31
|
"default": "./index.cjs.js"
|
|
31
32
|
}
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/http-errors": "^2.0.0"
|
|
32
36
|
}
|
|
33
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiosErrorResponse.d.ts","sourceRoot":"","sources":["../../src/api/axiosErrorResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,eAAO,MAAM,gBAAgB,UAAW,UAAU,UAejD,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/src/api/index.d.ts
CHANGED
package/src/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/eventStream/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/eventStream/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,4GASvC;IACD,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC1C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzE,KAAG,OAAO,CAAC,CAAC,CAiCZ,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oCAAoC,GAAI,CAAC,uEAMnD;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzE,gBACmB;IAChB,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM;YACf,IAAI,EAAE,MAAM,OAAO,CAAC;gBAAE,KAAK,EAAE,UAAU,CAAC;gBAAC,IAAI,EAAE,OAAO,CAAA;aAAE,CAAC,CAAC;SAC3D,CAAC;KACH,CAAC;CACH,SA4CF,CAAC"}
|