@dynamic-labs/utils 4.0.0-alpha.4 → 4.0.0-alpha.41
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 +361 -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/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 +69 -52
- package/src/index.d.ts +30 -25
- package/src/index.js +36 -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} +2 -2
- package/src/{retryableFn.js → retryableFn/retryableFn.js} +2 -2
- 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/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
- /package/src/{retryableFn.d.ts → retryableFn/retryableFn.d.ts} +0 -0
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 {
|
|
@@ -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
|
|
File without changes
|