@dynamic-labs/utils 4.0.0-alpha.0 → 4.0.0-alpha.2
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/CHANGELOG.md +25 -0
- package/package.json +4 -4
- package/src/cloneObjectWithOverrides/cloneObjectWithOverrides.cjs +10 -1
- package/src/cloneObjectWithOverrides/cloneObjectWithOverrides.js +10 -1
- package/src/errors/InvalidEmbeddedWalletSessionKeyError.cjs +14 -0
- package/src/errors/InvalidEmbeddedWalletSessionKeyError.d.ts +4 -0
- package/src/errors/InvalidEmbeddedWalletSessionKeyError.js +10 -0
- package/src/errors/RequestChannelNotHandledError.cjs +11 -0
- package/src/errors/RequestChannelNotHandledError.d.ts +3 -0
- package/src/errors/RequestChannelNotHandledError.js +7 -0
- package/src/errors/index.d.ts +2 -0
- package/src/index.cjs +6 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/promiseWithTimeout/index.d.ts +1 -0
- package/src/promiseWithTimeout/promiseWithTimeout.cjs +19 -0
- package/src/promiseWithTimeout/promiseWithTimeout.d.ts +5 -0
- package/src/promiseWithTimeout/promiseWithTimeout.js +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2024-09-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add iconVariant prop to DynamicBridgeWidget ([#6915](https://github.com/dynamic-labs/DynamicAuth/issues/6915)) ([8aa0f3d](https://github.com/dynamic-labs/DynamicAuth/commit/8aa0f3d8d8c41c7b5c4796106f611f208010cb6d))
|
|
8
|
+
* allow to create extra embedded wallets in react-native ([#6923](https://github.com/dynamic-labs/DynamicAuth/issues/6923)) ([ba22f7b](https://github.com/dynamic-labs/DynamicAuth/commit/ba22f7bcf41a444a4df0aff9b6aec257457e9402))
|
|
9
|
+
* **client:** add hide method for auth and userProfile ui modules ([#6928](https://github.com/dynamic-labs/DynamicAuth/issues/6928)) ([a11a4a5](https://github.com/dynamic-labs/DynamicAuth/commit/a11a4a5d6e25ce2a916ebd52f0b341020dc1a7e5))
|
|
10
|
+
|
|
11
|
+
## [4.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.0...v4.0.0-alpha.1) (2024-09-17)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* blockaid website scanning for global connectivity ([#6874](https://github.com/dynamic-labs/DynamicAuth/issues/6874)) ([f8cbabd](https://github.com/dynamic-labs/DynamicAuth/commit/f8cbabd92fd4b5b096f47ff8e24c572ad7720dd8))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* deeplinking on ethereum and bitcoin sats connector ([#6917](https://github.com/dynamic-labs/DynamicAuth/issues/6917)) ([3896c3a](https://github.com/dynamic-labs/DynamicAuth/commit/3896c3a97819459da74dc5b4771796d7991c1f07))
|
|
22
|
+
* emit walletAdded event when createEmbeddedWalletAccount called ([#6922](https://github.com/dynamic-labs/DynamicAuth/issues/6922)) ([2a8bdd6](https://github.com/dynamic-labs/DynamicAuth/commit/2a8bdd68c50efd946c6f9b398dfae2b3585db34f))
|
|
23
|
+
* interface for sendBitcoin on unisat ([37a1bc2](https://github.com/dynamic-labs/DynamicAuth/commit/37a1bc216f43eef817c40e23b9161327f9d29c59))
|
|
24
|
+
* remove ballet crypto and duplicate keplr entry ([#6906](https://github.com/dynamic-labs/DynamicAuth/issues/6906)) ([14aeeea](https://github.com/dynamic-labs/DynamicAuth/commit/14aeeeaa8d906344f4aeddf9e73527df346b9ea0))
|
|
25
|
+
* solana and cosmos signers not working properly ([#6898](https://github.com/dynamic-labs/DynamicAuth/issues/6898)) ([6f07981](https://github.com/dynamic-labs/DynamicAuth/commit/6f079811c0d7e45b97d2dae72f4141268ab4fe0c))
|
|
26
|
+
|
|
2
27
|
## [4.0.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0...v4.0.0-alpha.0) (2024-09-13)
|
|
3
28
|
|
|
4
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
29
|
+
"@dynamic-labs/sdk-api-core": "0.0.530",
|
|
30
30
|
"tldts": "6.0.16",
|
|
31
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
32
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
31
|
+
"@dynamic-labs/logger": "4.0.0-alpha.2",
|
|
32
|
+
"@dynamic-labs/types": "4.0.0-alpha.2",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
34
|
"eventemitter3": "5.0.1",
|
|
35
35
|
"stream": "0.0.2"
|
|
@@ -18,7 +18,7 @@ const cloneObjectWithOverrides = (original, overrides = {}) => {
|
|
|
18
18
|
// Get the property descriptors from the original object
|
|
19
19
|
const descriptors = Object.getOwnPropertyDescriptors(original);
|
|
20
20
|
// Create a new object using the same prototype as the original
|
|
21
|
-
const clone = Object.create(Object.getPrototypeOf(original)
|
|
21
|
+
const clone = Object.create(Object.getPrototypeOf(original));
|
|
22
22
|
// // Loop through the overrides to redefine any read-only methods
|
|
23
23
|
for (const [key, value] of Object.entries(overrides)) {
|
|
24
24
|
// Redefine the method even if it was read-only on the original object
|
|
@@ -31,6 +31,15 @@ const cloneObjectWithOverrides = (original, overrides = {}) => {
|
|
|
31
31
|
writable: true, // Preserve enumerability
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
const overridesKeys = Object.keys(overrides);
|
|
35
|
+
// add properties from original object if they're not in overrides
|
|
36
|
+
// if we add all of them, read-only props/methods might not get properly overwritten
|
|
37
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
38
|
+
// if has not been overwritten, add original
|
|
39
|
+
if (!overridesKeys.includes(key)) {
|
|
40
|
+
Object.defineProperty(clone, key, descriptor);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
34
43
|
return clone;
|
|
35
44
|
};
|
|
36
45
|
|
|
@@ -14,7 +14,7 @@ const cloneObjectWithOverrides = (original, overrides = {}) => {
|
|
|
14
14
|
// Get the property descriptors from the original object
|
|
15
15
|
const descriptors = Object.getOwnPropertyDescriptors(original);
|
|
16
16
|
// Create a new object using the same prototype as the original
|
|
17
|
-
const clone = Object.create(Object.getPrototypeOf(original)
|
|
17
|
+
const clone = Object.create(Object.getPrototypeOf(original));
|
|
18
18
|
// // Loop through the overrides to redefine any read-only methods
|
|
19
19
|
for (const [key, value] of Object.entries(overrides)) {
|
|
20
20
|
// Redefine the method even if it was read-only on the original object
|
|
@@ -27,6 +27,15 @@ const cloneObjectWithOverrides = (original, overrides = {}) => {
|
|
|
27
27
|
writable: true, // Preserve enumerability
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
const overridesKeys = Object.keys(overrides);
|
|
31
|
+
// add properties from original object if they're not in overrides
|
|
32
|
+
// if we add all of them, read-only props/methods might not get properly overwritten
|
|
33
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
34
|
+
// if has not been overwritten, add original
|
|
35
|
+
if (!overridesKeys.includes(key)) {
|
|
36
|
+
Object.defineProperty(clone, key, descriptor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
30
39
|
return clone;
|
|
31
40
|
};
|
|
32
41
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var DynamicError = require('./DynamicError.cjs');
|
|
7
|
+
|
|
8
|
+
class InvalidEmbeddedWalletSessionKeyError extends DynamicError.DynamicError {
|
|
9
|
+
constructor(error) {
|
|
10
|
+
super(error !== null && error !== void 0 ? error : 'Invalid embedded wallet session key.');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.InvalidEmbeddedWalletSessionKeyError = InvalidEmbeddedWalletSessionKeyError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { DynamicError } from './DynamicError.js';
|
|
3
|
+
|
|
4
|
+
class InvalidEmbeddedWalletSessionKeyError extends DynamicError {
|
|
5
|
+
constructor(error) {
|
|
6
|
+
super(error !== null && error !== void 0 ? error : 'Invalid embedded wallet session key.');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { InvalidEmbeddedWalletSessionKeyError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var DynamicError = require('./DynamicError.cjs');
|
|
7
|
+
|
|
8
|
+
class RequestChannelNotHandledError extends DynamicError.DynamicError {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.RequestChannelNotHandledError = RequestChannelNotHandledError;
|
package/src/errors/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from './InvalidPhoneNumberError';
|
|
|
27
27
|
export * from './MergeAccountsConfirmationError';
|
|
28
28
|
export * from './CustomFieldNotUniqueError';
|
|
29
29
|
export * from './CookieInvalidError';
|
|
30
|
+
export * from './RequestChannelNotHandledError';
|
|
30
31
|
export * from './AccessBlockedError';
|
|
31
32
|
export * from './EmbeddedWalletException';
|
|
32
33
|
export * from './MfaInvalidOtpError';
|
|
@@ -34,3 +35,4 @@ export * from './MfaRateLimitedError';
|
|
|
34
35
|
export * from './ExternalAuthError';
|
|
35
36
|
export * from './WalletAddressMismatchError';
|
|
36
37
|
export * from './UserRejectedRequestError';
|
|
38
|
+
export * from './InvalidEmbeddedWalletSessionKeyError';
|
package/src/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ var InvalidPhoneNumberError = require('./errors/InvalidPhoneNumberError.cjs');
|
|
|
33
33
|
var MergeAccountsConfirmationError = require('./errors/MergeAccountsConfirmationError.cjs');
|
|
34
34
|
var CustomFieldNotUniqueError = require('./errors/CustomFieldNotUniqueError.cjs');
|
|
35
35
|
var CookieInvalidError = require('./errors/CookieInvalidError.cjs');
|
|
36
|
+
var RequestChannelNotHandledError = require('./errors/RequestChannelNotHandledError.cjs');
|
|
36
37
|
var AccessBlockedError = require('./errors/AccessBlockedError.cjs');
|
|
37
38
|
var EmbeddedWalletException = require('./errors/EmbeddedWalletException.cjs');
|
|
38
39
|
var MfaInvalidOtpError = require('./errors/MfaInvalidOtpError.cjs');
|
|
@@ -40,6 +41,7 @@ var MfaRateLimitedError = require('./errors/MfaRateLimitedError.cjs');
|
|
|
40
41
|
var ExternalAuthError = require('./errors/ExternalAuthError.cjs');
|
|
41
42
|
var WalletAddressMismatchError = require('./errors/WalletAddressMismatchError.cjs');
|
|
42
43
|
var UserRejectedRequestError = require('./errors/UserRejectedRequestError.cjs');
|
|
44
|
+
var InvalidEmbeddedWalletSessionKeyError = require('./errors/InvalidEmbeddedWalletSessionKeyError.cjs');
|
|
43
45
|
var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
|
|
44
46
|
var isFunction = require('./isFunction/isFunction.cjs');
|
|
45
47
|
var isMobile = require('./isMobile.cjs');
|
|
@@ -74,6 +76,7 @@ var isHex = require('./isHex/isHex.cjs');
|
|
|
74
76
|
var StorageService = require('./services/StorageService/StorageService.cjs');
|
|
75
77
|
var createStorageService = require('./services/StorageService/createStorageService/createStorageService.cjs');
|
|
76
78
|
var cloneObjectWithOverrides = require('./cloneObjectWithOverrides/cloneObjectWithOverrides.cjs');
|
|
79
|
+
var promiseWithTimeout = require('./promiseWithTimeout/promiseWithTimeout.cjs');
|
|
77
80
|
|
|
78
81
|
|
|
79
82
|
|
|
@@ -107,6 +110,7 @@ exports.InvalidPhoneNumberError = InvalidPhoneNumberError.InvalidPhoneNumberErro
|
|
|
107
110
|
exports.MergeAccountsConfirmationError = MergeAccountsConfirmationError.MergeAccountsConfirmationError;
|
|
108
111
|
exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError.CustomFieldNotUniqueError;
|
|
109
112
|
exports.CookieInvalidError = CookieInvalidError.CookieInvalidError;
|
|
113
|
+
exports.RequestChannelNotHandledError = RequestChannelNotHandledError.RequestChannelNotHandledError;
|
|
110
114
|
exports.AccessBlockedError = AccessBlockedError.AccessBlockedError;
|
|
111
115
|
exports.EmbeddedWalletException = EmbeddedWalletException.EmbeddedWalletException;
|
|
112
116
|
exports.MfaInvalidOtpError = MfaInvalidOtpError.MfaInvalidOtpError;
|
|
@@ -114,6 +118,7 @@ exports.MfaRateLimitedError = MfaRateLimitedError.MfaRateLimitedError;
|
|
|
114
118
|
exports.ExternalAuthError = ExternalAuthError.ExternalAuthError;
|
|
115
119
|
exports.WalletAddressMismatchError = WalletAddressMismatchError.WalletAddressMismatchError;
|
|
116
120
|
exports.UserRejectedRequestError = UserRejectedRequestError.UserRejectedRequestError;
|
|
121
|
+
exports.InvalidEmbeddedWalletSessionKeyError = InvalidEmbeddedWalletSessionKeyError.InvalidEmbeddedWalletSessionKeyError;
|
|
117
122
|
exports.CancellablePromise = CancellablePromise.CancellablePromise;
|
|
118
123
|
exports.isFunction = isFunction.isFunction;
|
|
119
124
|
exports.getAndroidVersion = isMobile.getAndroidVersion;
|
|
@@ -162,3 +167,4 @@ exports.isHex = isHex.isHex;
|
|
|
162
167
|
exports.StorageService = StorageService.StorageService;
|
|
163
168
|
exports.createStorageService = createStorageService.createStorageService;
|
|
164
169
|
exports.cloneObjectWithOverrides = cloneObjectWithOverrides.cloneObjectWithOverrides;
|
|
170
|
+
exports.promiseWithTimeout = promiseWithTimeout.promiseWithTimeout;
|
package/src/index.d.ts
CHANGED
|
@@ -32,3 +32,4 @@ export { hexToString } from './hexToString';
|
|
|
32
32
|
export { isHex } from './isHex';
|
|
33
33
|
export { type IStorageService, type StorageOptions, StorageService, createStorageService, } from './services/StorageService';
|
|
34
34
|
export { cloneObjectWithOverrides } from './cloneObjectWithOverrides';
|
|
35
|
+
export { promiseWithTimeout } from './promiseWithTimeout';
|
package/src/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { InvalidPhoneNumberError } from './errors/InvalidPhoneNumberError.js';
|
|
|
29
29
|
export { MergeAccountsConfirmationError } from './errors/MergeAccountsConfirmationError.js';
|
|
30
30
|
export { CustomFieldNotUniqueError } from './errors/CustomFieldNotUniqueError.js';
|
|
31
31
|
export { CookieInvalidError } from './errors/CookieInvalidError.js';
|
|
32
|
+
export { RequestChannelNotHandledError } from './errors/RequestChannelNotHandledError.js';
|
|
32
33
|
export { AccessBlockedError } from './errors/AccessBlockedError.js';
|
|
33
34
|
export { EmbeddedWalletException } from './errors/EmbeddedWalletException.js';
|
|
34
35
|
export { MfaInvalidOtpError } from './errors/MfaInvalidOtpError.js';
|
|
@@ -36,6 +37,7 @@ export { MfaRateLimitedError } from './errors/MfaRateLimitedError.js';
|
|
|
36
37
|
export { ExternalAuthError } from './errors/ExternalAuthError.js';
|
|
37
38
|
export { WalletAddressMismatchError } from './errors/WalletAddressMismatchError.js';
|
|
38
39
|
export { UserRejectedRequestError } from './errors/UserRejectedRequestError.js';
|
|
40
|
+
export { InvalidEmbeddedWalletSessionKeyError } from './errors/InvalidEmbeddedWalletSessionKeyError.js';
|
|
39
41
|
export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
|
|
40
42
|
export { isFunction } from './isFunction/isFunction.js';
|
|
41
43
|
export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSafariBrowser, isSamsungBrowser, isWindows } from './isMobile.js';
|
|
@@ -70,3 +72,4 @@ export { isHex } from './isHex/isHex.js';
|
|
|
70
72
|
export { StorageService } from './services/StorageService/StorageService.js';
|
|
71
73
|
export { createStorageService } from './services/StorageService/createStorageService/createStorageService.js';
|
|
72
74
|
export { cloneObjectWithOverrides } from './cloneObjectWithOverrides/cloneObjectWithOverrides.js';
|
|
75
|
+
export { promiseWithTimeout } from './promiseWithTimeout/promiseWithTimeout.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { promiseWithTimeout } from './promiseWithTimeout';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const promiseWithTimeout = (promise, ms, { timeoutMessage = 'Operation timed out' } = {}) => {
|
|
7
|
+
let timerId;
|
|
8
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
9
|
+
timerId = setTimeout(() => {
|
|
10
|
+
reject(new Error(timeoutMessage));
|
|
11
|
+
}, ms);
|
|
12
|
+
});
|
|
13
|
+
const wrappedPromise = promise.finally(() => {
|
|
14
|
+
clearTimeout(timerId);
|
|
15
|
+
});
|
|
16
|
+
return Promise.race([wrappedPromise, timeoutPromise]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.promiseWithTimeout = promiseWithTimeout;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const promiseWithTimeout = (promise, ms, { timeoutMessage = 'Operation timed out' } = {}) => {
|
|
3
|
+
let timerId;
|
|
4
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
5
|
+
timerId = setTimeout(() => {
|
|
6
|
+
reject(new Error(timeoutMessage));
|
|
7
|
+
}, ms);
|
|
8
|
+
});
|
|
9
|
+
const wrappedPromise = promise.finally(() => {
|
|
10
|
+
clearTimeout(timerId);
|
|
11
|
+
});
|
|
12
|
+
return Promise.race([wrappedPromise, timeoutPromise]);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { promiseWithTimeout };
|