@dynamic-labs/utils 4.0.0-alpha.5 → 4.0.0-alpha.50
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 +460 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +6 -13
- package/src/bufferToBase64/index.d.ts +1 -0
- package/src/eip6963/eip6963Provider.cjs +15 -4
- package/src/eip6963/eip6963Provider.d.ts +8 -3
- package/src/eip6963/eip6963Provider.js +14 -5
- package/src/encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.cjs +31 -0
- package/src/encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.d.ts +11 -0
- package/src/encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.js +27 -0
- package/src/encryption/convertPublicKeyCryptoKeyToHex/index.d.ts +1 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.cjs +35 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.d.ts +8 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.js +31 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/index.d.ts +1 -0
- package/src/encryption/createKeyPair/createKeyPair.cjs +27 -0
- package/src/encryption/createKeyPair/createKeyPair.d.ts +9 -0
- package/src/encryption/createKeyPair/createKeyPair.js +23 -0
- package/src/encryption/createKeyPair/index.d.ts +1 -0
- package/src/encryption/decryptMessage/decryptMessage.cjs +48 -0
- package/src/encryption/decryptMessage/decryptMessage.d.ts +9 -0
- package/src/encryption/decryptMessage/decryptMessage.js +44 -0
- package/src/encryption/decryptMessage/index.d.ts +1 -0
- package/src/encryption/deriveSharedSecret/deriveSharedSecret.cjs +28 -0
- package/src/encryption/deriveSharedSecret/deriveSharedSecret.d.ts +10 -0
- package/src/encryption/deriveSharedSecret/deriveSharedSecret.js +24 -0
- package/src/encryption/deriveSharedSecret/index.d.ts +1 -0
- package/src/encryption/encryptMessage/encryptMessage.cjs +42 -0
- package/src/encryption/encryptMessage/encryptMessage.d.ts +13 -0
- package/src/encryption/encryptMessage/encryptMessage.js +38 -0
- package/src/encryption/encryptMessage/index.d.ts +1 -0
- package/src/encryption/index.d.ts +7 -0
- package/src/encryption/isEncryptedMessage/index.d.ts +1 -0
- package/src/encryption/isEncryptedMessage/isEncryptedMessage.cjs +28 -0
- package/src/encryption/isEncryptedMessage/isEncryptedMessage.d.ts +7 -0
- package/src/encryption/isEncryptedMessage/isEncryptedMessage.js +24 -0
- package/src/eventTimeline/eventTimeline.cjs +41 -0
- package/src/eventTimeline/eventTimeline.d.ts +18 -0
- package/src/eventTimeline/eventTimeline.js +37 -0
- package/src/eventTimeline/index.d.ts +1 -0
- package/src/getProvidersFromWindow/index.d.ts +1 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +1 -1
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +1 -1
- package/src/index.cjs +85 -52
- package/src/index.d.ts +32 -25
- package/src/index.js +44 -26
- package/src/isInIframe/index.d.ts +1 -0
- package/src/isInIframe/isInIframe.cjs +8 -0
- package/src/isInIframe/isInIframe.d.ts +1 -0
- package/src/isInIframe/isInIframe.js +4 -0
- package/src/isLedgerAddressViaVerifiedCredentials/index.d.ts +1 -0
- package/src/isMobile/index.d.ts +1 -0
- package/src/isString/index.d.ts +1 -0
- package/src/isString/isString.cjs +8 -0
- package/src/isString/isString.d.ts +1 -0
- package/src/isString/isString.js +4 -0
- package/src/last/index.d.ts +1 -0
- package/src/localStorageAsync/index.d.ts +1 -0
- package/src/{localStorageAsync.cjs → localStorageAsync/localStorageAsync.cjs} +1 -1
- package/src/{localStorageAsync.js → localStorageAsync/localStorageAsync.js} +1 -1
- package/src/parseChainId/index.d.ts +1 -0
- package/src/parseIntSafe/index.d.ts +1 -0
- package/src/parseIntSafe/parseIntSafe.cjs +23 -0
- package/src/parseIntSafe/parseIntSafe.d.ts +1 -0
- package/src/parseIntSafe/parseIntSafe.js +19 -0
- package/src/parseNetworks/index.d.ts +1 -0
- package/src/{parseEvmNetworks.cjs → parseNetworks/parseNetworks.cjs} +3 -1
- package/src/parseNetworks/parseNetworks.d.ts +3 -0
- package/src/{parseEvmNetworks.js → parseNetworks/parseNetworks.js} +3 -2
- package/src/retryableFn/index.d.ts +1 -0
- package/src/{retryableFn.cjs → retryableFn/retryableFn.cjs} +3 -18
- package/src/{retryableFn.d.ts → retryableFn/retryableFn.d.ts} +0 -3
- package/src/{retryableFn.js → retryableFn/retryableFn.js} +3 -18
- package/src/sanitizeName/index.d.ts +1 -0
- package/src/sanitizeName/sanitizeName.cjs +8 -0
- package/src/sanitizeName/sanitizeName.d.ts +1 -0
- package/src/sanitizeName/sanitizeName.js +4 -0
- package/src/services/Oauth2Service/Oauth2Service.d.ts +0 -1
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +9 -1
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +9 -1
- package/src/services/StorageService/StorageService.d.ts +1 -1
- package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.cjs +11 -0
- package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.d.ts +7 -0
- package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.js +7 -0
- package/src/services/StorageService/applyPostfixToStorageService/index.d.ts +1 -0
- package/src/services/StorageService/createStorageService/createStorageService.cjs +4 -5
- package/src/services/StorageService/createStorageService/createStorageService.d.ts +1 -2
- package/src/services/StorageService/createStorageService/createStorageService.js +4 -5
- package/src/services/StorageService/index.d.ts +1 -0
- package/src/services/StorageService/types.d.ts +1 -1
- package/src/solToLamports/index.d.ts +1 -0
- package/src/solToLamports/solToLamports.cjs +11 -0
- package/src/solToLamports/solToLamports.d.ts +1 -0
- package/src/solToLamports/solToLamports.js +7 -0
- package/src/nativeMobileOauthStateParam.cjs +0 -13
- package/src/nativeMobileOauthStateParam.d.ts +0 -14
- package/src/nativeMobileOauthStateParam.js +0 -9
- package/src/parseEvmNetworks.d.ts +0 -2
- /package/src/{bufferPolyfill.cjs → bufferToBase64/bufferPolyfill.cjs} +0 -0
- /package/src/{bufferPolyfill.d.ts → bufferToBase64/bufferPolyfill.d.ts} +0 -0
- /package/src/{bufferPolyfill.js → bufferToBase64/bufferPolyfill.js} +0 -0
- /package/src/{bufferToBase64.cjs → bufferToBase64/bufferToBase64.cjs} +0 -0
- /package/src/{bufferToBase64.d.ts → bufferToBase64/bufferToBase64.d.ts} +0 -0
- /package/src/{bufferToBase64.js → bufferToBase64/bufferToBase64.js} +0 -0
- /package/src/{getProvidersFromWindow.cjs → getProvidersFromWindow/getProvidersFromWindow.cjs} +0 -0
- /package/src/{getProvidersFromWindow.d.ts → getProvidersFromWindow/getProvidersFromWindow.d.ts} +0 -0
- /package/src/{getProvidersFromWindow.js → getProvidersFromWindow/getProvidersFromWindow.js} +0 -0
- /package/src/{isLedgerAddressViaVerifiedCredentials.cjs → isLedgerAddressViaVerifiedCredentials/isLedgerAddressViaVerifiedCredentials.cjs} +0 -0
- /package/src/{isLedgerAddressViaVerifiedCredentials.d.ts → isLedgerAddressViaVerifiedCredentials/isLedgerAddressViaVerifiedCredentials.d.ts} +0 -0
- /package/src/{isLedgerAddressViaVerifiedCredentials.js → isLedgerAddressViaVerifiedCredentials/isLedgerAddressViaVerifiedCredentials.js} +0 -0
- /package/src/{isMobile.cjs → isMobile/isMobile.cjs} +0 -0
- /package/src/{isMobile.d.ts → isMobile/isMobile.d.ts} +0 -0
- /package/src/{isMobile.js → isMobile/isMobile.js} +0 -0
- /package/src/{last.cjs → last/last.cjs} +0 -0
- /package/src/{last.d.ts → last/last.d.ts} +0 -0
- /package/src/{last.js → last/last.js} +0 -0
- /package/src/{localStorageAsync.d.ts → localStorageAsync/localStorageAsync.d.ts} +0 -0
- /package/src/{parseChainId.cjs → parseChainId/parseChainId.cjs} +0 -0
- /package/src/{parseChainId.d.ts → parseChainId/parseChainId.d.ts} +0 -0
- /package/src/{parseChainId.js → parseChainId/parseChainId.js} +0 -0
|
@@ -3,19 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
7
|
-
var sleep = require('
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var sleep = require('../sleep/sleep.cjs');
|
|
8
8
|
|
|
9
9
|
const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
|
|
10
10
|
const retryableFn = (fn_1, ...args_1) => _tslib.__awaiter(void 0, [fn_1, ...args_1], void 0, function* (fn, options = {}) {
|
|
11
|
-
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0,
|
|
12
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
|
|
13
|
-
currentRetry,
|
|
14
|
-
fallbackValue,
|
|
15
|
-
maxRetries,
|
|
16
|
-
retryStrategy,
|
|
17
|
-
timeoutMs,
|
|
18
|
-
});
|
|
11
|
+
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, } = options;
|
|
19
12
|
const timeoutPromise = new Promise((_, reject) => {
|
|
20
13
|
setTimeout(() => {
|
|
21
14
|
reject(new Error('Timeout'));
|
|
@@ -26,9 +19,7 @@ const retryableFn = (fn_1, ...args_1) => _tslib.__awaiter(void 0, [fn_1, ...args
|
|
|
26
19
|
return result;
|
|
27
20
|
}
|
|
28
21
|
catch (err) {
|
|
29
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err);
|
|
30
22
|
if (currentRetry >= maxRetries) {
|
|
31
|
-
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue);
|
|
32
23
|
if (fallbackValue instanceof Error) {
|
|
33
24
|
throw fallbackValue;
|
|
34
25
|
}
|
|
@@ -41,18 +32,13 @@ const retryableFn = (fn_1, ...args_1) => _tslib.__awaiter(void 0, [fn_1, ...args
|
|
|
41
32
|
const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
|
|
42
33
|
(retryStrategy === 'timeout-only' && isTimeout) ||
|
|
43
34
|
(retryStrategy === 'rejection-only' && !isTimeout);
|
|
44
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry);
|
|
45
35
|
if (!shouldRetry) {
|
|
46
36
|
if (fallbackValue instanceof Error) {
|
|
47
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue);
|
|
48
37
|
throw err;
|
|
49
38
|
}
|
|
50
39
|
else if (fallbackValue === FALLBACK_UNDEFINED) {
|
|
51
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined');
|
|
52
40
|
return undefined;
|
|
53
41
|
}
|
|
54
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue);
|
|
55
|
-
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
|
|
56
42
|
return fallbackValue;
|
|
57
43
|
}
|
|
58
44
|
if (retryIntervalMs)
|
|
@@ -60,7 +46,6 @@ const retryableFn = (fn_1, ...args_1) => _tslib.__awaiter(void 0, [fn_1, ...args
|
|
|
60
46
|
return retryableFn(fn, {
|
|
61
47
|
currentRetry: currentRetry + 1,
|
|
62
48
|
fallbackValue,
|
|
63
|
-
logger,
|
|
64
49
|
maxRetries,
|
|
65
50
|
retryIntervalMs,
|
|
66
51
|
retryStrategy,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Logger } from '@dynamic-labs/logger';
|
|
2
1
|
export declare const FALLBACK_UNDEFINED = "FALLBACK_UNDEFINED";
|
|
3
2
|
export type RetryableFnOptions<T> = {
|
|
4
3
|
/** Maximum number of retry attempts before returning fallbackValue */
|
|
@@ -11,8 +10,6 @@ export type RetryableFnOptions<T> = {
|
|
|
11
10
|
fallbackValue?: T | Error | typeof FALLBACK_UNDEFINED;
|
|
12
11
|
/** Configure whether the fn should be retried only on timeout, only on rejection, or both */
|
|
13
12
|
retryStrategy?: 'timeout-only' | 'rejection-only' | 'timeout-and-rejection';
|
|
14
|
-
/** Set the logger to be used */
|
|
15
|
-
logger?: Logger | typeof console;
|
|
16
13
|
/** Ms to wait before a retry */
|
|
17
14
|
retryIntervalMs?: number;
|
|
18
15
|
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '
|
|
3
|
-
import { sleep } from '
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { sleep } from '../sleep/sleep.js';
|
|
4
4
|
|
|
5
5
|
const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
|
|
6
6
|
const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], void 0, function* (fn, options = {}) {
|
|
7
|
-
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0,
|
|
8
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
|
|
9
|
-
currentRetry,
|
|
10
|
-
fallbackValue,
|
|
11
|
-
maxRetries,
|
|
12
|
-
retryStrategy,
|
|
13
|
-
timeoutMs,
|
|
14
|
-
});
|
|
7
|
+
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, } = options;
|
|
15
8
|
const timeoutPromise = new Promise((_, reject) => {
|
|
16
9
|
setTimeout(() => {
|
|
17
10
|
reject(new Error('Timeout'));
|
|
@@ -22,9 +15,7 @@ const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], vo
|
|
|
22
15
|
return result;
|
|
23
16
|
}
|
|
24
17
|
catch (err) {
|
|
25
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err);
|
|
26
18
|
if (currentRetry >= maxRetries) {
|
|
27
|
-
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue);
|
|
28
19
|
if (fallbackValue instanceof Error) {
|
|
29
20
|
throw fallbackValue;
|
|
30
21
|
}
|
|
@@ -37,18 +28,13 @@ const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], vo
|
|
|
37
28
|
const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
|
|
38
29
|
(retryStrategy === 'timeout-only' && isTimeout) ||
|
|
39
30
|
(retryStrategy === 'rejection-only' && !isTimeout);
|
|
40
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry);
|
|
41
31
|
if (!shouldRetry) {
|
|
42
32
|
if (fallbackValue instanceof Error) {
|
|
43
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue);
|
|
44
33
|
throw err;
|
|
45
34
|
}
|
|
46
35
|
else if (fallbackValue === FALLBACK_UNDEFINED) {
|
|
47
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined');
|
|
48
36
|
return undefined;
|
|
49
37
|
}
|
|
50
|
-
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue);
|
|
51
|
-
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
|
|
52
38
|
return fallbackValue;
|
|
53
39
|
}
|
|
54
40
|
if (retryIntervalMs)
|
|
@@ -56,7 +42,6 @@ const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], vo
|
|
|
56
42
|
return retryableFn(fn, {
|
|
57
43
|
currentRetry: currentRetry + 1,
|
|
58
44
|
fallbackValue,
|
|
59
|
-
logger,
|
|
60
45
|
maxRetries,
|
|
61
46
|
retryIntervalMs,
|
|
62
47
|
retryStrategy,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sanitizeName } from './sanitizeName';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sanitizeName: (name: string) => string;
|
|
@@ -7,7 +7,7 @@ var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var types = require('@dynamic-labs/types');
|
|
8
8
|
var logger = require('../../../logger/logger.cjs');
|
|
9
9
|
var connectWithAppleId = require('../utils/connectWithAppleId/connectWithAppleId.cjs');
|
|
10
|
-
var isMobile = require('../../../isMobile.cjs');
|
|
10
|
+
var isMobile = require('../../../isMobile/isMobile.cjs');
|
|
11
11
|
|
|
12
12
|
let authWindowInterval;
|
|
13
13
|
const createWindowOauth2Service = () => ({
|
|
@@ -46,6 +46,14 @@ const createWindowOauth2Service = () => ({
|
|
|
46
46
|
clearInterval(authWindowInterval);
|
|
47
47
|
const providersWaitingOauthMessage = {};
|
|
48
48
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
49
|
+
if (authWindow === null || typeof authWindow === 'undefined') {
|
|
50
|
+
// Pop-ups are blocked
|
|
51
|
+
typedReject({
|
|
52
|
+
code: types.SocialOAuthErrorCode.OAUTH_WINDOW_BLOCKED,
|
|
53
|
+
message: 'Please allow popups and try again.',
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
49
57
|
const clearListeners = () => {
|
|
50
58
|
window.removeEventListener('message', handleWindowMessage);
|
|
51
59
|
providersWaitingOauthMessage[provider] = false;
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { ProviderEnum, SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
4
4
|
import { logger } from '../../../logger/logger.js';
|
|
5
5
|
import { connectWithAppleId } from '../utils/connectWithAppleId/connectWithAppleId.js';
|
|
6
|
-
import { isSafariBrowser, isIOS } from '../../../isMobile.js';
|
|
6
|
+
import { isSafariBrowser, isIOS } from '../../../isMobile/isMobile.js';
|
|
7
7
|
|
|
8
8
|
let authWindowInterval;
|
|
9
9
|
const createWindowOauth2Service = () => ({
|
|
@@ -42,6 +42,14 @@ const createWindowOauth2Service = () => ({
|
|
|
42
42
|
clearInterval(authWindowInterval);
|
|
43
43
|
const providersWaitingOauthMessage = {};
|
|
44
44
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
45
|
+
if (authWindow === null || typeof authWindow === 'undefined') {
|
|
46
|
+
// Pop-ups are blocked
|
|
47
|
+
typedReject({
|
|
48
|
+
code: SocialOAuthErrorCode.OAUTH_WINDOW_BLOCKED,
|
|
49
|
+
message: 'Please allow popups and try again.',
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
45
53
|
const clearListeners = () => {
|
|
46
54
|
window.removeEventListener('message', handleWindowMessage);
|
|
47
55
|
providersWaitingOauthMessage[provider] = false;
|
|
@@ -20,7 +20,7 @@ export declare class StorageService {
|
|
|
20
20
|
static registerSourceStorage(source: StorageSource, implementation: IStorageService): void;
|
|
21
21
|
static getSourceStorage(source: StorageSource): IStorageService | undefined;
|
|
22
22
|
static resolveStorage(options?: StorageOptions): IStorageService;
|
|
23
|
-
static getItem<T = string>(key: string, options?: StorageOptions): T |
|
|
23
|
+
static getItem<T = string>(key: string, options?: StorageOptions): T | null;
|
|
24
24
|
static setItem<T>(key: string, value: T, options?: StorageOptions): void;
|
|
25
25
|
static removeItem(key: string, options?: StorageOptions): void;
|
|
26
26
|
static getKeys(options?: StorageOptions): string[];
|
package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const applyPostfixToStorageService = ({ storage, postfix, }) => {
|
|
7
|
+
const getKeyWithPostfix = (key) => postfix ? `${key}_${postfix}` : key;
|
|
8
|
+
return Object.assign(Object.assign({}, storage), { getItem: (key) => storage.getItem(getKeyWithPostfix(key)), removeItem: (key) => storage.removeItem(getKeyWithPostfix(key)), setItem: (key, data) => storage.setItem(getKeyWithPostfix(key), data) });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.applyPostfixToStorageService = applyPostfixToStorageService;
|
package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IStorageService } from '../types';
|
|
2
|
+
type ApplyPostfixToStorageServiceProps<T extends IStorageService> = {
|
|
3
|
+
storage: T;
|
|
4
|
+
postfix: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const applyPostfixToStorageService: <T extends IStorageService>({ storage, postfix, }: ApplyPostfixToStorageServiceProps<T>) => T;
|
|
7
|
+
export {};
|
package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const applyPostfixToStorageService = ({ storage, postfix, }) => {
|
|
3
|
+
const getKeyWithPostfix = (key) => postfix ? `${key}_${postfix}` : key;
|
|
4
|
+
return Object.assign(Object.assign({}, storage), { getItem: (key) => storage.getItem(getKeyWithPostfix(key)), removeItem: (key) => storage.removeItem(getKeyWithPostfix(key)), setItem: (key, data) => storage.setItem(getKeyWithPostfix(key), data) });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { applyPostfixToStorageService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { applyPostfixToStorageService } from './applyPostfixToStorageService';
|
|
@@ -6,13 +6,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var logger = require('../../../logger/logger.cjs');
|
|
7
7
|
var StorageService = require('../StorageService.cjs');
|
|
8
8
|
|
|
9
|
-
const createStorageService = ({
|
|
10
|
-
const getKey = (key) => (postfix ? `${key}_${postfix}` : key);
|
|
9
|
+
const createStorageService = ({ storage, }) => {
|
|
11
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
11
|
const packValue = (value) => JSON.stringify(value);
|
|
13
12
|
const unpackValue = (value) => JSON.parse(value);
|
|
14
13
|
const getItem = (key) => {
|
|
15
|
-
const value = storage.getItem(
|
|
14
|
+
const value = storage.getItem(key);
|
|
16
15
|
if (!value) {
|
|
17
16
|
return undefined;
|
|
18
17
|
}
|
|
@@ -29,10 +28,10 @@ const createStorageService = ({ postfix, storage, }) => {
|
|
|
29
28
|
return undefined;
|
|
30
29
|
};
|
|
31
30
|
const setItem = (key, value) => {
|
|
32
|
-
storage.setItem(
|
|
31
|
+
storage.setItem(key, packValue(value));
|
|
33
32
|
};
|
|
34
33
|
const removeItem = (key) => {
|
|
35
|
-
storage.removeItem(
|
|
34
|
+
storage.removeItem(key);
|
|
36
35
|
};
|
|
37
36
|
const getKeys = () => Object.keys(storage);
|
|
38
37
|
return {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IStorageService } from '../types';
|
|
2
2
|
type CreateStorageServiceProps = {
|
|
3
|
-
postfix?: string;
|
|
4
3
|
storage: Storage;
|
|
5
4
|
};
|
|
6
|
-
export declare const createStorageService: ({
|
|
5
|
+
export declare const createStorageService: ({ storage, }: CreateStorageServiceProps) => IStorageService;
|
|
7
6
|
export {};
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
import { logger } from '../../../logger/logger.js';
|
|
3
3
|
import { StorageService } from '../StorageService.js';
|
|
4
4
|
|
|
5
|
-
const createStorageService = ({
|
|
6
|
-
const getKey = (key) => (postfix ? `${key}_${postfix}` : key);
|
|
5
|
+
const createStorageService = ({ storage, }) => {
|
|
7
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
7
|
const packValue = (value) => JSON.stringify(value);
|
|
9
8
|
const unpackValue = (value) => JSON.parse(value);
|
|
10
9
|
const getItem = (key) => {
|
|
11
|
-
const value = storage.getItem(
|
|
10
|
+
const value = storage.getItem(key);
|
|
12
11
|
if (!value) {
|
|
13
12
|
return undefined;
|
|
14
13
|
}
|
|
@@ -25,10 +24,10 @@ const createStorageService = ({ postfix, storage, }) => {
|
|
|
25
24
|
return undefined;
|
|
26
25
|
};
|
|
27
26
|
const setItem = (key, value) => {
|
|
28
|
-
storage.setItem(
|
|
27
|
+
storage.setItem(key, packValue(value));
|
|
29
28
|
};
|
|
30
29
|
const removeItem = (key) => {
|
|
31
|
-
storage.removeItem(
|
|
30
|
+
storage.removeItem(key);
|
|
32
31
|
};
|
|
33
32
|
const getKeys = () => Object.keys(storage);
|
|
34
33
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { solToLamports } from './solToLamports';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const solToLamports = (solAmount) => {
|
|
7
|
+
const lamportsPerSol = 1000000000; // 1 SOL = 1,000,000,000 Lamports
|
|
8
|
+
return solAmount * lamportsPerSol;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.solToLamports = solToLamports;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const solToLamports: (solAmount: number) => number;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Represents the value that separates the random string from the
|
|
8
|
-
* mobile deeplink URL in the state param from the oauth messages
|
|
9
|
-
* emitted from native mobile apps.
|
|
10
|
-
*/
|
|
11
|
-
const nativeMobileOauthStateParam = '_client-redirect:';
|
|
12
|
-
|
|
13
|
-
exports.nativeMobileOauthStateParam = nativeMobileOauthStateParam;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the value that separates the random string from the
|
|
3
|
-
* mobile deeplink URL in the state param from the oauth messages
|
|
4
|
-
* emitted from native mobile apps.
|
|
5
|
-
*/
|
|
6
|
-
export declare const nativeMobileOauthStateParam = "_client-redirect:";
|
|
7
|
-
/**
|
|
8
|
-
* Represents the format of the state variable exchanged in oauth2 messages
|
|
9
|
-
* by native mobile devices.
|
|
10
|
-
*
|
|
11
|
-
* It has a random state string followed byt the client redirect URL as configured
|
|
12
|
-
* in the Client.
|
|
13
|
-
*/
|
|
14
|
-
export type NativeMobileOauthState = `${string}${typeof nativeMobileOauthStateParam}${string}`;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
/**
|
|
3
|
-
* Represents the value that separates the random string from the
|
|
4
|
-
* mobile deeplink URL in the state param from the oauth messages
|
|
5
|
-
* emitted from native mobile apps.
|
|
6
|
-
*/
|
|
7
|
-
const nativeMobileOauthStateParam = '_client-redirect:';
|
|
8
|
-
|
|
9
|
-
export { nativeMobileOauthStateParam };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{getProvidersFromWindow.cjs → getProvidersFromWindow/getProvidersFromWindow.cjs}
RENAMED
|
File without changes
|
/package/src/{getProvidersFromWindow.d.ts → getProvidersFromWindow/getProvidersFromWindow.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|