@dynamic-labs/utils 0.0.0-exp20240808.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.
- package/CHANGELOG.md +3746 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/_virtual/_tslib.cjs +51 -0
- package/_virtual/_tslib.js +45 -0
- package/package.json +37 -0
- package/src/CancellablePromise/CancellablePromise.cjs +136 -0
- package/src/CancellablePromise/CancellablePromise.d.ts +54 -0
- package/src/CancellablePromise/CancellablePromise.js +132 -0
- package/src/CancellablePromise/index.d.ts +1 -0
- package/src/DeferredPromise/DeferredPromise.cjs +22 -0
- package/src/DeferredPromise/DeferredPromise.d.ts +13 -0
- package/src/DeferredPromise/DeferredPromise.js +18 -0
- package/src/DeferredPromise/index.d.ts +1 -0
- package/src/bufferPolyfill.cjs +15 -0
- package/src/bufferPolyfill.d.ts +1 -0
- package/src/bufferPolyfill.js +13 -0
- package/src/bufferToBase64.cjs +15 -0
- package/src/bufferToBase64.d.ts +2 -0
- package/src/bufferToBase64.js +11 -0
- package/src/ceil/ceil.cjs +11 -0
- package/src/ceil/ceil.d.ts +1 -0
- package/src/ceil/ceil.js +7 -0
- package/src/ceil/index.d.ts +1 -0
- package/src/eip6963/eip6963Provider.cjs +40 -0
- package/src/eip6963/eip6963Provider.d.ts +34 -0
- package/src/eip6963/eip6963Provider.js +35 -0
- package/src/eip6963/index.d.ts +1 -0
- package/src/errors/AccessBlockedError.cjs +11 -0
- package/src/errors/AccessBlockedError.d.ts +3 -0
- package/src/errors/AccessBlockedError.js +7 -0
- package/src/errors/AccountExistsError.cjs +16 -0
- package/src/errors/AccountExistsError.d.ts +14 -0
- package/src/errors/AccountExistsError.js +12 -0
- package/src/errors/ChainalysisError.cjs +15 -0
- package/src/errors/ChainalysisError.d.ts +5 -0
- package/src/errors/ChainalysisError.js +11 -0
- package/src/errors/CookieInvalidError.cjs +14 -0
- package/src/errors/CookieInvalidError.d.ts +4 -0
- package/src/errors/CookieInvalidError.js +10 -0
- package/src/errors/CustomError.cjs +24 -0
- package/src/errors/CustomError.d.ts +11 -0
- package/src/errors/CustomError.js +20 -0
- package/src/errors/CustomFieldNotUniqueError.cjs +14 -0
- package/src/errors/CustomFieldNotUniqueError.d.ts +4 -0
- package/src/errors/CustomFieldNotUniqueError.js +10 -0
- package/src/errors/DynamicError.cjs +11 -0
- package/src/errors/DynamicError.d.ts +3 -0
- package/src/errors/DynamicError.js +7 -0
- package/src/errors/EmailAlreadyExistsError.cjs +14 -0
- package/src/errors/EmailAlreadyExistsError.d.ts +4 -0
- package/src/errors/EmailAlreadyExistsError.js +10 -0
- package/src/errors/EmailProviderError.cjs +14 -0
- package/src/errors/EmailProviderError.d.ts +4 -0
- package/src/errors/EmailProviderError.js +10 -0
- package/src/errors/EmailVerificationError.cjs +14 -0
- package/src/errors/EmailVerificationError.d.ts +4 -0
- package/src/errors/EmailVerificationError.js +10 -0
- package/src/errors/EmbeddedWalletException.cjs +14 -0
- package/src/errors/EmbeddedWalletException.d.ts +4 -0
- package/src/errors/EmbeddedWalletException.js +10 -0
- package/src/errors/ExternalAuthError.cjs +14 -0
- package/src/errors/ExternalAuthError.d.ts +4 -0
- package/src/errors/ExternalAuthError.js +10 -0
- package/src/errors/GateBlockedError.cjs +15 -0
- package/src/errors/GateBlockedError.d.ts +5 -0
- package/src/errors/GateBlockedError.js +11 -0
- package/src/errors/InsufficientFundsError.cjs +25 -0
- package/src/errors/InsufficientFundsError.d.ts +9 -0
- package/src/errors/InsufficientFundsError.js +21 -0
- package/src/errors/InvalidPhoneNumberError.cjs +14 -0
- package/src/errors/InvalidPhoneNumberError.d.ts +4 -0
- package/src/errors/InvalidPhoneNumberError.js +10 -0
- package/src/errors/MergeAccountsConfirmationError.cjs +16 -0
- package/src/errors/MergeAccountsConfirmationError.d.ts +12 -0
- package/src/errors/MergeAccountsConfirmationError.js +12 -0
- package/src/errors/MfaInvalidOtpError.cjs +14 -0
- package/src/errors/MfaInvalidOtpError.d.ts +4 -0
- package/src/errors/MfaInvalidOtpError.js +10 -0
- package/src/errors/MissingEnvironmentIdError.cjs +14 -0
- package/src/errors/MissingEnvironmentIdError.d.ts +4 -0
- package/src/errors/MissingEnvironmentIdError.js +10 -0
- package/src/errors/MissingPublicAddressError.cjs +14 -0
- package/src/errors/MissingPublicAddressError.d.ts +4 -0
- package/src/errors/MissingPublicAddressError.js +10 -0
- package/src/errors/NoAccessError.cjs +19 -0
- package/src/errors/NoAccessError.d.ts +15 -0
- package/src/errors/NoAccessError.js +15 -0
- package/src/errors/NotSupportedError.cjs +11 -0
- package/src/errors/NotSupportedError.d.ts +3 -0
- package/src/errors/NotSupportedError.js +7 -0
- package/src/errors/PasskeyError.d.ts +8 -0
- package/src/errors/SmsVerificationError.cjs +11 -0
- package/src/errors/SmsVerificationError.d.ts +3 -0
- package/src/errors/SmsVerificationError.js +7 -0
- package/src/errors/SocialAccountAlreadyExistsError.cjs +14 -0
- package/src/errors/SocialAccountAlreadyExistsError.d.ts +4 -0
- package/src/errors/SocialAccountAlreadyExistsError.js +10 -0
- package/src/errors/TooManyEmailVerificationsError.cjs +14 -0
- package/src/errors/TooManyEmailVerificationsError.d.ts +4 -0
- package/src/errors/TooManyEmailVerificationsError.js +10 -0
- package/src/errors/TransactionGasCannotBeSponsoredError.cjs +25 -0
- package/src/errors/TransactionGasCannotBeSponsoredError.d.ts +9 -0
- package/src/errors/TransactionGasCannotBeSponsoredError.js +21 -0
- package/src/errors/UserHasAccountWithEmailError.cjs +15 -0
- package/src/errors/UserHasAccountWithEmailError.d.ts +5 -0
- package/src/errors/UserHasAccountWithEmailError.js +11 -0
- package/src/errors/UserRejectedTransactionError.cjs +14 -0
- package/src/errors/UserRejectedTransactionError.d.ts +4 -0
- package/src/errors/UserRejectedTransactionError.js +10 -0
- package/src/errors/UsernameAlreadyExistsError.cjs +14 -0
- package/src/errors/UsernameAlreadyExistsError.d.ts +4 -0
- package/src/errors/UsernameAlreadyExistsError.js +10 -0
- package/src/errors/VerificationDataCollectionError.cjs +15 -0
- package/src/errors/VerificationDataCollectionError.d.ts +5 -0
- package/src/errors/VerificationDataCollectionError.js +11 -0
- package/src/errors/WalletAddressMismatchError.cjs +17 -0
- package/src/errors/WalletAddressMismatchError.d.ts +11 -0
- package/src/errors/WalletAddressMismatchError.js +13 -0
- package/src/errors/WalletNotDeployedError.cjs +14 -0
- package/src/errors/WalletNotDeployedError.d.ts +4 -0
- package/src/errors/WalletNotDeployedError.js +10 -0
- package/src/errors/WalletUsedError.cjs +14 -0
- package/src/errors/WalletUsedError.d.ts +4 -0
- package/src/errors/WalletUsedError.js +10 -0
- package/src/errors/index.d.ts +33 -0
- package/src/formatNumberText/formatNumberText.cjs +20 -0
- package/src/formatNumberText/formatNumberText.d.ts +5 -0
- package/src/formatNumberText/formatNumberText.js +16 -0
- package/src/formatNumberText/index.d.ts +1 -0
- package/src/get/get.cjs +24 -0
- package/src/get/get.d.ts +7 -0
- package/src/get/get.js +20 -0
- package/src/get/index.d.ts +1 -0
- package/src/getProvidersFromWindow.cjs +39 -0
- package/src/getProvidersFromWindow.d.ts +7 -0
- package/src/getProvidersFromWindow.js +35 -0
- package/src/getTLD/getTLD.cjs +12 -0
- package/src/getTLD/getTLD.d.ts +1 -0
- package/src/getTLD/getTLD.js +8 -0
- package/src/getTLD/index.d.ts +1 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +20 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.d.ts +4 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +16 -0
- package/src/handleMobileWalletRedirect/index.d.ts +1 -0
- package/src/hexToString/hexToString.cjs +32 -0
- package/src/hexToString/hexToString.d.ts +12 -0
- package/src/hexToString/hexToString.js +28 -0
- package/src/hexToString/index.d.ts +1 -0
- package/src/index.cjs +151 -0
- package/src/index.d.ts +32 -0
- package/src/index.js +66 -0
- package/src/isFunction/index.d.ts +1 -0
- package/src/isFunction/isFunction.cjs +9 -0
- package/src/isFunction/isFunction.d.ts +1 -0
- package/src/isFunction/isFunction.js +5 -0
- package/src/isHex/index.d.ts +1 -0
- package/src/isHex/isHex.cjs +20 -0
- package/src/isHex/isHex.d.ts +6 -0
- package/src/isHex/isHex.js +16 -0
- package/src/isLedgerAddressViaVerifiedCredentials.cjs +13 -0
- package/src/isLedgerAddressViaVerifiedCredentials.d.ts +2 -0
- package/src/isLedgerAddressViaVerifiedCredentials.js +9 -0
- package/src/isMobile.cjs +146 -0
- package/src/isMobile.d.ts +18 -0
- package/src/isMobile.js +133 -0
- package/src/last.cjs +22 -0
- package/src/last.d.ts +15 -0
- package/src/last.js +18 -0
- package/src/localStorageAsync.cjs +38 -0
- package/src/localStorageAsync.d.ts +3 -0
- package/src/localStorageAsync.js +32 -0
- package/src/logger/index.d.ts +1 -0
- package/src/logger/logger.cjs +10 -0
- package/src/logger/logger.d.ts +2 -0
- package/src/logger/logger.js +6 -0
- package/src/nativeMobileOauthStateParam.cjs +13 -0
- package/src/nativeMobileOauthStateParam.d.ts +14 -0
- package/src/nativeMobileOauthStateParam.js +9 -0
- package/src/parseChainId.cjs +8 -0
- package/src/parseChainId.d.ts +1 -0
- package/src/parseChainId.js +4 -0
- package/src/parseEvmNetworks.cjs +17 -0
- package/src/parseEvmNetworks.d.ts +2 -0
- package/src/parseEvmNetworks.js +13 -0
- package/src/pipe/index.d.ts +1 -0
- package/src/pipe/pipe.cjs +40 -0
- package/src/pipe/pipe.d.ts +27 -0
- package/src/pipe/pipe.js +36 -0
- package/src/retryableFn.cjs +73 -0
- package/src/retryableFn.d.ts +19 -0
- package/src/retryableFn.js +68 -0
- package/src/runSafe/index.d.ts +1 -0
- package/src/runSafe/runSafe.cjs +25 -0
- package/src/runSafe/runSafe.d.ts +8 -0
- package/src/runSafe/runSafe.js +21 -0
- package/src/services/FetchService/FetchService.cjs +29 -0
- package/src/services/FetchService/FetchService.d.ts +10 -0
- package/src/services/FetchService/FetchService.js +25 -0
- package/src/services/FetchService/index.d.ts +2 -0
- package/src/services/FetchService/types.d.ts +3 -0
- package/src/services/Oauth2Service/Oauth2Service.cjs +38 -0
- package/src/services/Oauth2Service/Oauth2Service.d.ts +34 -0
- package/src/services/Oauth2Service/Oauth2Service.js +34 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +192 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.d.ts +2 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +188 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/index.d.ts +1 -0
- package/src/services/Oauth2Service/index.d.ts +2 -0
- package/src/services/PlatformService/PlatformService.cjs +40 -0
- package/src/services/PlatformService/PlatformService.d.ts +11 -0
- package/src/services/PlatformService/PlatformService.js +36 -0
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs +30 -0
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.d.ts +2 -0
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js +26 -0
- package/src/services/PlatformService/createBrowserPlatformService/index.d.ts +1 -0
- package/src/services/PlatformService/index.d.ts +3 -0
- package/src/services/PlatformService/types.d.ts +25 -0
- package/src/sleep/index.d.ts +1 -0
- package/src/sleep/sleep.cjs +13 -0
- package/src/sleep/sleep.d.ts +11 -0
- package/src/sleep/sleep.js +9 -0
- package/src/template/index.d.ts +1 -0
- package/src/template/template.cjs +25 -0
- package/src/template/template.d.ts +18 -0
- package/src/template/template.js +21 -0
- package/src/trimEnd/index.d.ts +1 -0
- package/src/trimEnd/trimEnd.cjs +14 -0
- package/src/trimEnd/trimEnd.d.ts +1 -0
- package/src/trimEnd/trimEnd.js +10 -0
- package/src/uniq/index.d.ts +1 -0
- package/src/uniq/uniq.cjs +33 -0
- package/src/uniq/uniq.d.ts +17 -0
- package/src/uniq/uniq.js +29 -0
- package/src/wrapMethodWithCallback/index.d.ts +1 -0
- package/src/wrapMethodWithCallback/wrapMethodWithCallback.cjs +47 -0
- package/src/wrapMethodWithCallback/wrapMethodWithCallback.d.ts +36 -0
- package/src/wrapMethodWithCallback/wrapMethodWithCallback.js +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Dynamic Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
38
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
39
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
40
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
41
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
45
|
+
var e = new Error(message);
|
|
46
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.__awaiter = __awaiter;
|
|
50
|
+
exports.__classPrivateFieldGet = __classPrivateFieldGet;
|
|
51
|
+
exports.__classPrivateFieldSet = __classPrivateFieldSet;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
28
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
30
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
34
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
35
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
36
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
37
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
41
|
+
var e = new Error(message);
|
|
42
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet };
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs/utils",
|
|
3
|
+
"version": "0.0.0-exp20240808.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
|
+
"directory": "packages/utils"
|
|
8
|
+
},
|
|
9
|
+
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dynamic-labs/DynamicAuth/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/dynamic-labs/DynamicAuth#readme",
|
|
14
|
+
"author": "Dynamic Labs, Inc.",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "./src/index.cjs",
|
|
17
|
+
"module": "./src/index.js",
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./src/index.d.ts",
|
|
23
|
+
"import": "./src/index.js",
|
|
24
|
+
"require": "./src/index.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@dynamic-labs/sdk-api-core": "0.0.509",
|
|
30
|
+
"tldts": "6.0.16",
|
|
31
|
+
"@dynamic-labs/logger": "0.0.0-exp20240808.0",
|
|
32
|
+
"@dynamic-labs/types": "0.0.0-exp20240808.0",
|
|
33
|
+
"buffer": "6.0.3",
|
|
34
|
+
"stream": "0.0.2"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {}
|
|
37
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var logger = require('../logger/logger.cjs');
|
|
7
|
+
|
|
8
|
+
/* eslint-disable multiline-comment-style */
|
|
9
|
+
const defaultCancel = () => {
|
|
10
|
+
logger.logger.error("Tried to cancel CancellablePromise without ever assigning it's '_cancel' method");
|
|
11
|
+
};
|
|
12
|
+
/** An extension of Promise that allows you to explicitly cancel a promise with an external reference to it.
|
|
13
|
+
* Cancelling CancellablePromise causes it to reject with reason set to the parameter passed to the cancel method.
|
|
14
|
+
* When CancellablePromise rejects, it provides a boolean to indicate whether it was cancelled, alongside the reason.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Cancelling this promise
|
|
18
|
+
* const promise = new CancellablePromise(() => {}).onCancel(console.log)
|
|
19
|
+
* promise.cancel('User cancelled')
|
|
20
|
+
*
|
|
21
|
+
* // Setting up listeners for resolve, cancel and reject
|
|
22
|
+
* // (notice calling catch after onCancel prevents catch from being called by cancellation)
|
|
23
|
+
* new CancellablePromise(() => {})
|
|
24
|
+
* .then(() => console.log('Promise resolved'))
|
|
25
|
+
* .onCancel(() => console.log('Promise was cancelled'))
|
|
26
|
+
* .catch(() => console.log('Promise was rejected but NOT cancelled'))
|
|
27
|
+
*
|
|
28
|
+
* // Telling whether catch was cause of cancel or not
|
|
29
|
+
* new CancellablePromise(() => {})
|
|
30
|
+
* .then(() => console.log('Promise resolved'))
|
|
31
|
+
* .catch(({ reason, wasCancelled }) => console.log('Promise was rejected. Cancelled: ' + wasCancelled))
|
|
32
|
+
*/
|
|
33
|
+
class CancellablePromise extends Promise {
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
internalCancel(reason) {
|
|
36
|
+
defaultCancel();
|
|
37
|
+
}
|
|
38
|
+
constructor(executor) {
|
|
39
|
+
let superReject = defaultCancel;
|
|
40
|
+
let superResolve = () => { };
|
|
41
|
+
super((resolve, reject) => {
|
|
42
|
+
superReject = reject;
|
|
43
|
+
superResolve = resolve;
|
|
44
|
+
});
|
|
45
|
+
this.internalIsCancelled = false;
|
|
46
|
+
this.isSettled = false;
|
|
47
|
+
executor((value) => {
|
|
48
|
+
if (!this.isCancelled && !this.isSettled)
|
|
49
|
+
superResolve(value);
|
|
50
|
+
this.isSettled = true;
|
|
51
|
+
}, (reason) => {
|
|
52
|
+
if (!this.isCancelled && !this.isSettled)
|
|
53
|
+
superReject(reason);
|
|
54
|
+
this.isSettled = true;
|
|
55
|
+
});
|
|
56
|
+
this.internalCancel = superReject;
|
|
57
|
+
}
|
|
58
|
+
/** Whether this CancellablePromise was cancelled. */
|
|
59
|
+
get isCancelled() {
|
|
60
|
+
return this.internalIsCancelled;
|
|
61
|
+
}
|
|
62
|
+
/** Cancels the promise. This causes the promise to reject with { wasCancelled: true, reason: reason }
|
|
63
|
+
* where the reason is the provided argument.
|
|
64
|
+
* @returns The cancelled promise.
|
|
65
|
+
*/
|
|
66
|
+
cancel(reason) {
|
|
67
|
+
if (this.isSettled)
|
|
68
|
+
return this;
|
|
69
|
+
this.internalIsCancelled = true;
|
|
70
|
+
this.internalCancel(reason);
|
|
71
|
+
this.isSettled = true;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
internalOnCancel(listener, options) {
|
|
75
|
+
const newPromise = new CancellablePromise((resolve, reject) => {
|
|
76
|
+
this.internalThen(resolve, ({ wasCancelled, reason }) => {
|
|
77
|
+
if (wasCancelled)
|
|
78
|
+
resolve(listener(reason));
|
|
79
|
+
else
|
|
80
|
+
reject(reason);
|
|
81
|
+
}, { ignoreOnCancel: true });
|
|
82
|
+
});
|
|
83
|
+
/** Tie the new promise's cancel to this promise's cancel */
|
|
84
|
+
if (!(options === null || options === void 0 ? void 0 : options.ignoreOnCancel)) {
|
|
85
|
+
newPromise.internalOnCancel((reason) => {
|
|
86
|
+
this.cancel(reason);
|
|
87
|
+
}, { ignoreOnCancel: true });
|
|
88
|
+
}
|
|
89
|
+
return newPromise;
|
|
90
|
+
}
|
|
91
|
+
/** Allows reacting to this CancellablePromise being cancelled */
|
|
92
|
+
onCancel(listener) {
|
|
93
|
+
return this.internalOnCancel(listener);
|
|
94
|
+
}
|
|
95
|
+
internalThen(onFulfilled, onRejected, options) {
|
|
96
|
+
/** Create a catch handler that is undefined if the received callback is undefined */
|
|
97
|
+
const catchHandler = onRejected
|
|
98
|
+
? (reason) => onRejected({ reason, wasCancelled: this.isCancelled })
|
|
99
|
+
: onRejected;
|
|
100
|
+
// /** Create the CancellablePromise we will returned, associated to the then promise */
|
|
101
|
+
const newPromise = CancellablePromise.fromPromise(super.then(onFulfilled, catchHandler));
|
|
102
|
+
/** Tie the new promise's cancel to this promise's cancel */
|
|
103
|
+
if (!(options === null || options === void 0 ? void 0 : options.ignoreOnCancel)) {
|
|
104
|
+
newPromise.internalOnCancel((reason) => {
|
|
105
|
+
this.cancel(reason);
|
|
106
|
+
}, { ignoreOnCancel: true });
|
|
107
|
+
}
|
|
108
|
+
return newPromise;
|
|
109
|
+
}
|
|
110
|
+
then(onFulfilled, onRejected) {
|
|
111
|
+
return this.internalThen(onFulfilled, onRejected);
|
|
112
|
+
}
|
|
113
|
+
catch(onRejected) {
|
|
114
|
+
return this.then(undefined, onRejected);
|
|
115
|
+
}
|
|
116
|
+
finally(onFinally) {
|
|
117
|
+
return this.then((value) => {
|
|
118
|
+
onFinally === null || onFinally === void 0 ? void 0 : onFinally();
|
|
119
|
+
return value;
|
|
120
|
+
}, (reason) => {
|
|
121
|
+
onFinally === null || onFinally === void 0 ? void 0 : onFinally();
|
|
122
|
+
throw reason;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** Generates a CancellablePromise from a Promise. If a CancellablePromise is passed, it's returned unscathed.
|
|
126
|
+
* WARNING: unless you attach a method to reject the original Promise with the "onCancel" param.
|
|
127
|
+
* cancelling the resulting CancellablePromise does NOT affect the original Promise. */
|
|
128
|
+
static fromPromise(promise) {
|
|
129
|
+
if ('internalIsCancelled' in promise)
|
|
130
|
+
return promise;
|
|
131
|
+
const newPromise = new CancellablePromise((resolve, reject) => promise.then(resolve, reject));
|
|
132
|
+
return newPromise;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports.CancellablePromise = CancellablePromise;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
type Executor<T> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void;
|
|
2
|
+
type CancelListener<TResult = never> = (reason?: unknown) => TResult;
|
|
3
|
+
/** An extension of Promise that allows you to explicitly cancel a promise with an external reference to it.
|
|
4
|
+
* Cancelling CancellablePromise causes it to reject with reason set to the parameter passed to the cancel method.
|
|
5
|
+
* When CancellablePromise rejects, it provides a boolean to indicate whether it was cancelled, alongside the reason.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Cancelling this promise
|
|
9
|
+
* const promise = new CancellablePromise(() => {}).onCancel(console.log)
|
|
10
|
+
* promise.cancel('User cancelled')
|
|
11
|
+
*
|
|
12
|
+
* // Setting up listeners for resolve, cancel and reject
|
|
13
|
+
* // (notice calling catch after onCancel prevents catch from being called by cancellation)
|
|
14
|
+
* new CancellablePromise(() => {})
|
|
15
|
+
* .then(() => console.log('Promise resolved'))
|
|
16
|
+
* .onCancel(() => console.log('Promise was cancelled'))
|
|
17
|
+
* .catch(() => console.log('Promise was rejected but NOT cancelled'))
|
|
18
|
+
*
|
|
19
|
+
* // Telling whether catch was cause of cancel or not
|
|
20
|
+
* new CancellablePromise(() => {})
|
|
21
|
+
* .then(() => console.log('Promise resolved'))
|
|
22
|
+
* .catch(({ reason, wasCancelled }) => console.log('Promise was rejected. Cancelled: ' + wasCancelled))
|
|
23
|
+
*/
|
|
24
|
+
export declare class CancellablePromise<T> extends Promise<T> {
|
|
25
|
+
private internalIsCancelled;
|
|
26
|
+
private isSettled;
|
|
27
|
+
private internalCancel;
|
|
28
|
+
constructor(executor: Executor<T>);
|
|
29
|
+
/** Whether this CancellablePromise was cancelled. */
|
|
30
|
+
get isCancelled(): boolean;
|
|
31
|
+
/** Cancels the promise. This causes the promise to reject with { wasCancelled: true, reason: reason }
|
|
32
|
+
* where the reason is the provided argument.
|
|
33
|
+
* @returns The cancelled promise.
|
|
34
|
+
*/
|
|
35
|
+
cancel(reason?: unknown): this;
|
|
36
|
+
private internalOnCancel;
|
|
37
|
+
/** Allows reacting to this CancellablePromise being cancelled */
|
|
38
|
+
onCancel<TResult = never>(listener: CancelListener<TResult>): CancellablePromise<T | TResult>;
|
|
39
|
+
private internalThen;
|
|
40
|
+
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: {
|
|
41
|
+
reason: unknown;
|
|
42
|
+
wasCancelled: boolean;
|
|
43
|
+
}) => TResult2 | PromiseLike<TResult2>) | null): CancellablePromise<TResult1 | TResult2>;
|
|
44
|
+
catch<TResult = never>(onRejected?: ((reason: {
|
|
45
|
+
reason: unknown;
|
|
46
|
+
wasCancelled: boolean;
|
|
47
|
+
}) => TResult | PromiseLike<TResult>) | null): CancellablePromise<T | TResult>;
|
|
48
|
+
finally(onFinally?: (() => void) | null): CancellablePromise<T>;
|
|
49
|
+
/** Generates a CancellablePromise from a Promise. If a CancellablePromise is passed, it's returned unscathed.
|
|
50
|
+
* WARNING: unless you attach a method to reject the original Promise with the "onCancel" param.
|
|
51
|
+
* cancelling the resulting CancellablePromise does NOT affect the original Promise. */
|
|
52
|
+
static fromPromise<T>(promise: Promise<T> | CancellablePromise<T>): CancellablePromise<T>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { logger } from '../logger/logger.js';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable multiline-comment-style */
|
|
5
|
+
const defaultCancel = () => {
|
|
6
|
+
logger.error("Tried to cancel CancellablePromise without ever assigning it's '_cancel' method");
|
|
7
|
+
};
|
|
8
|
+
/** An extension of Promise that allows you to explicitly cancel a promise with an external reference to it.
|
|
9
|
+
* Cancelling CancellablePromise causes it to reject with reason set to the parameter passed to the cancel method.
|
|
10
|
+
* When CancellablePromise rejects, it provides a boolean to indicate whether it was cancelled, alongside the reason.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Cancelling this promise
|
|
14
|
+
* const promise = new CancellablePromise(() => {}).onCancel(console.log)
|
|
15
|
+
* promise.cancel('User cancelled')
|
|
16
|
+
*
|
|
17
|
+
* // Setting up listeners for resolve, cancel and reject
|
|
18
|
+
* // (notice calling catch after onCancel prevents catch from being called by cancellation)
|
|
19
|
+
* new CancellablePromise(() => {})
|
|
20
|
+
* .then(() => console.log('Promise resolved'))
|
|
21
|
+
* .onCancel(() => console.log('Promise was cancelled'))
|
|
22
|
+
* .catch(() => console.log('Promise was rejected but NOT cancelled'))
|
|
23
|
+
*
|
|
24
|
+
* // Telling whether catch was cause of cancel or not
|
|
25
|
+
* new CancellablePromise(() => {})
|
|
26
|
+
* .then(() => console.log('Promise resolved'))
|
|
27
|
+
* .catch(({ reason, wasCancelled }) => console.log('Promise was rejected. Cancelled: ' + wasCancelled))
|
|
28
|
+
*/
|
|
29
|
+
class CancellablePromise extends Promise {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
|
+
internalCancel(reason) {
|
|
32
|
+
defaultCancel();
|
|
33
|
+
}
|
|
34
|
+
constructor(executor) {
|
|
35
|
+
let superReject = defaultCancel;
|
|
36
|
+
let superResolve = () => { };
|
|
37
|
+
super((resolve, reject) => {
|
|
38
|
+
superReject = reject;
|
|
39
|
+
superResolve = resolve;
|
|
40
|
+
});
|
|
41
|
+
this.internalIsCancelled = false;
|
|
42
|
+
this.isSettled = false;
|
|
43
|
+
executor((value) => {
|
|
44
|
+
if (!this.isCancelled && !this.isSettled)
|
|
45
|
+
superResolve(value);
|
|
46
|
+
this.isSettled = true;
|
|
47
|
+
}, (reason) => {
|
|
48
|
+
if (!this.isCancelled && !this.isSettled)
|
|
49
|
+
superReject(reason);
|
|
50
|
+
this.isSettled = true;
|
|
51
|
+
});
|
|
52
|
+
this.internalCancel = superReject;
|
|
53
|
+
}
|
|
54
|
+
/** Whether this CancellablePromise was cancelled. */
|
|
55
|
+
get isCancelled() {
|
|
56
|
+
return this.internalIsCancelled;
|
|
57
|
+
}
|
|
58
|
+
/** Cancels the promise. This causes the promise to reject with { wasCancelled: true, reason: reason }
|
|
59
|
+
* where the reason is the provided argument.
|
|
60
|
+
* @returns The cancelled promise.
|
|
61
|
+
*/
|
|
62
|
+
cancel(reason) {
|
|
63
|
+
if (this.isSettled)
|
|
64
|
+
return this;
|
|
65
|
+
this.internalIsCancelled = true;
|
|
66
|
+
this.internalCancel(reason);
|
|
67
|
+
this.isSettled = true;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
internalOnCancel(listener, options) {
|
|
71
|
+
const newPromise = new CancellablePromise((resolve, reject) => {
|
|
72
|
+
this.internalThen(resolve, ({ wasCancelled, reason }) => {
|
|
73
|
+
if (wasCancelled)
|
|
74
|
+
resolve(listener(reason));
|
|
75
|
+
else
|
|
76
|
+
reject(reason);
|
|
77
|
+
}, { ignoreOnCancel: true });
|
|
78
|
+
});
|
|
79
|
+
/** Tie the new promise's cancel to this promise's cancel */
|
|
80
|
+
if (!(options === null || options === void 0 ? void 0 : options.ignoreOnCancel)) {
|
|
81
|
+
newPromise.internalOnCancel((reason) => {
|
|
82
|
+
this.cancel(reason);
|
|
83
|
+
}, { ignoreOnCancel: true });
|
|
84
|
+
}
|
|
85
|
+
return newPromise;
|
|
86
|
+
}
|
|
87
|
+
/** Allows reacting to this CancellablePromise being cancelled */
|
|
88
|
+
onCancel(listener) {
|
|
89
|
+
return this.internalOnCancel(listener);
|
|
90
|
+
}
|
|
91
|
+
internalThen(onFulfilled, onRejected, options) {
|
|
92
|
+
/** Create a catch handler that is undefined if the received callback is undefined */
|
|
93
|
+
const catchHandler = onRejected
|
|
94
|
+
? (reason) => onRejected({ reason, wasCancelled: this.isCancelled })
|
|
95
|
+
: onRejected;
|
|
96
|
+
// /** Create the CancellablePromise we will returned, associated to the then promise */
|
|
97
|
+
const newPromise = CancellablePromise.fromPromise(super.then(onFulfilled, catchHandler));
|
|
98
|
+
/** Tie the new promise's cancel to this promise's cancel */
|
|
99
|
+
if (!(options === null || options === void 0 ? void 0 : options.ignoreOnCancel)) {
|
|
100
|
+
newPromise.internalOnCancel((reason) => {
|
|
101
|
+
this.cancel(reason);
|
|
102
|
+
}, { ignoreOnCancel: true });
|
|
103
|
+
}
|
|
104
|
+
return newPromise;
|
|
105
|
+
}
|
|
106
|
+
then(onFulfilled, onRejected) {
|
|
107
|
+
return this.internalThen(onFulfilled, onRejected);
|
|
108
|
+
}
|
|
109
|
+
catch(onRejected) {
|
|
110
|
+
return this.then(undefined, onRejected);
|
|
111
|
+
}
|
|
112
|
+
finally(onFinally) {
|
|
113
|
+
return this.then((value) => {
|
|
114
|
+
onFinally === null || onFinally === void 0 ? void 0 : onFinally();
|
|
115
|
+
return value;
|
|
116
|
+
}, (reason) => {
|
|
117
|
+
onFinally === null || onFinally === void 0 ? void 0 : onFinally();
|
|
118
|
+
throw reason;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** Generates a CancellablePromise from a Promise. If a CancellablePromise is passed, it's returned unscathed.
|
|
122
|
+
* WARNING: unless you attach a method to reject the original Promise with the "onCancel" param.
|
|
123
|
+
* cancelling the resulting CancellablePromise does NOT affect the original Promise. */
|
|
124
|
+
static fromPromise(promise) {
|
|
125
|
+
if ('internalIsCancelled' in promise)
|
|
126
|
+
return promise;
|
|
127
|
+
const newPromise = new CancellablePromise((resolve, reject) => promise.then(resolve, reject));
|
|
128
|
+
return newPromise;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { CancellablePromise };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CancellablePromise } from './CancellablePromise';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A DeferredPromise provides methods to manually resolve or reject a Promise.
|
|
8
|
+
* This is useful in scenarios where you need to resolve or reject a Promise
|
|
9
|
+
* outside of the executor function.
|
|
10
|
+
*
|
|
11
|
+
* @template T The type of the value with which the promise will be resolved.
|
|
12
|
+
*/
|
|
13
|
+
class DeferredPromise {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.promise = new Promise((resolve, reject) => {
|
|
16
|
+
this.resolve = resolve;
|
|
17
|
+
this.reject = reject;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.DeferredPromise = DeferredPromise;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A DeferredPromise provides methods to manually resolve or reject a Promise.
|
|
3
|
+
* This is useful in scenarios where you need to resolve or reject a Promise
|
|
4
|
+
* outside of the executor function.
|
|
5
|
+
*
|
|
6
|
+
* @template T The type of the value with which the promise will be resolved.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DeferredPromise<T> {
|
|
9
|
+
promise: Promise<T>;
|
|
10
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
11
|
+
reject: (reason?: any) => void;
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* A DeferredPromise provides methods to manually resolve or reject a Promise.
|
|
4
|
+
* This is useful in scenarios where you need to resolve or reject a Promise
|
|
5
|
+
* outside of the executor function.
|
|
6
|
+
*
|
|
7
|
+
* @template T The type of the value with which the promise will be resolved.
|
|
8
|
+
*/
|
|
9
|
+
class DeferredPromise {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.promise = new Promise((resolve, reject) => {
|
|
12
|
+
this.resolve = resolve;
|
|
13
|
+
this.reject = reject;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { DeferredPromise };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DeferredPromise } from './DeferredPromise';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var _ = require('buffer/');
|
|
5
|
+
|
|
6
|
+
/* eslint-disable */
|
|
7
|
+
/**
|
|
8
|
+
* This is needed for the browser to work with buffer
|
|
9
|
+
*/
|
|
10
|
+
if (typeof window !== 'undefined') {
|
|
11
|
+
window.global = globalThis;
|
|
12
|
+
if (!window.Buffer && typeof window.Buffer === 'undefined') {
|
|
13
|
+
Object.assign(window, { Buffer: _.Buffer });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Buffer } from 'buffer/index.js';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* This is needed for the browser to work with buffer
|
|
7
|
+
*/
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
window.global = globalThis;
|
|
10
|
+
if (!window.Buffer && typeof window.Buffer === 'undefined') {
|
|
11
|
+
Object.assign(window, { Buffer });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('./bufferPolyfill.cjs');
|
|
7
|
+
|
|
8
|
+
const bufferToBase64 = (buf) => {
|
|
9
|
+
const binstr = Array.prototype.map
|
|
10
|
+
.call(buf, (ch) => String.fromCharCode(ch))
|
|
11
|
+
.join('');
|
|
12
|
+
return Buffer.from(binstr, 'binary').toString('base64');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.bufferToBase64 = bufferToBase64;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import './bufferPolyfill.js';
|
|
3
|
+
|
|
4
|
+
const bufferToBase64 = (buf) => {
|
|
5
|
+
const binstr = Array.prototype.map
|
|
6
|
+
.call(buf, (ch) => String.fromCharCode(ch))
|
|
7
|
+
.join('');
|
|
8
|
+
return Buffer.from(binstr, 'binary').toString('base64');
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { bufferToBase64 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const ceil = (value, precision = 0) => {
|
|
7
|
+
const multiplier = Math.pow(10, precision);
|
|
8
|
+
return Math.ceil(value * multiplier) / multiplier;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.ceil = ceil;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ceil: (value: number, precision?: number) => number;
|
package/src/ceil/ceil.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ceil } from './ceil';
|