@dynamic-labs/utils 4.0.0-alpha.4 → 4.0.0-alpha.40

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +349 -0
  2. package/package.cjs +8 -0
  3. package/package.js +4 -0
  4. package/package.json +6 -13
  5. package/src/bufferToBase64/index.d.ts +1 -0
  6. package/src/eip6963/eip6963Provider.cjs +15 -4
  7. package/src/eip6963/eip6963Provider.d.ts +8 -3
  8. package/src/eip6963/eip6963Provider.js +14 -5
  9. package/src/eventTimeline/eventTimeline.cjs +41 -0
  10. package/src/eventTimeline/eventTimeline.d.ts +18 -0
  11. package/src/eventTimeline/eventTimeline.js +37 -0
  12. package/src/eventTimeline/index.d.ts +1 -0
  13. package/src/getProvidersFromWindow/index.d.ts +1 -0
  14. package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +1 -1
  15. package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +1 -1
  16. package/src/index.cjs +69 -52
  17. package/src/index.d.ts +30 -25
  18. package/src/index.js +36 -26
  19. package/src/isInIframe/index.d.ts +1 -0
  20. package/src/isInIframe/isInIframe.cjs +8 -0
  21. package/src/isInIframe/isInIframe.d.ts +1 -0
  22. package/src/isInIframe/isInIframe.js +4 -0
  23. package/src/isLedgerAddressViaVerifiedCredentials/index.d.ts +1 -0
  24. package/src/isMobile/index.d.ts +1 -0
  25. package/src/isString/index.d.ts +1 -0
  26. package/src/isString/isString.cjs +8 -0
  27. package/src/isString/isString.d.ts +1 -0
  28. package/src/isString/isString.js +4 -0
  29. package/src/last/index.d.ts +1 -0
  30. package/src/localStorageAsync/index.d.ts +1 -0
  31. package/src/{localStorageAsync.cjs → localStorageAsync/localStorageAsync.cjs} +1 -1
  32. package/src/{localStorageAsync.js → localStorageAsync/localStorageAsync.js} +1 -1
  33. package/src/parseChainId/index.d.ts +1 -0
  34. package/src/parseIntSafe/index.d.ts +1 -0
  35. package/src/parseIntSafe/parseIntSafe.cjs +23 -0
  36. package/src/parseIntSafe/parseIntSafe.d.ts +1 -0
  37. package/src/parseIntSafe/parseIntSafe.js +19 -0
  38. package/src/parseNetworks/index.d.ts +1 -0
  39. package/src/{parseEvmNetworks.cjs → parseNetworks/parseNetworks.cjs} +3 -1
  40. package/src/parseNetworks/parseNetworks.d.ts +3 -0
  41. package/src/{parseEvmNetworks.js → parseNetworks/parseNetworks.js} +3 -2
  42. package/src/retryableFn/index.d.ts +1 -0
  43. package/src/{retryableFn.cjs → retryableFn/retryableFn.cjs} +2 -2
  44. package/src/{retryableFn.js → retryableFn/retryableFn.js} +2 -2
  45. package/src/sanitizeName/index.d.ts +1 -0
  46. package/src/sanitizeName/sanitizeName.cjs +8 -0
  47. package/src/sanitizeName/sanitizeName.d.ts +1 -0
  48. package/src/sanitizeName/sanitizeName.js +4 -0
  49. package/src/services/Oauth2Service/Oauth2Service.d.ts +0 -1
  50. package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +9 -1
  51. package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +9 -1
  52. package/src/services/StorageService/StorageService.d.ts +1 -1
  53. package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.cjs +11 -0
  54. package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.d.ts +7 -0
  55. package/src/services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.js +7 -0
  56. package/src/services/StorageService/applyPostfixToStorageService/index.d.ts +1 -0
  57. package/src/services/StorageService/createStorageService/createStorageService.cjs +4 -5
  58. package/src/services/StorageService/createStorageService/createStorageService.d.ts +1 -2
  59. package/src/services/StorageService/createStorageService/createStorageService.js +4 -5
  60. package/src/services/StorageService/index.d.ts +1 -0
  61. package/src/services/StorageService/types.d.ts +1 -1
  62. package/src/nativeMobileOauthStateParam.cjs +0 -13
  63. package/src/nativeMobileOauthStateParam.d.ts +0 -14
  64. package/src/nativeMobileOauthStateParam.js +0 -9
  65. package/src/parseEvmNetworks.d.ts +0 -2
  66. /package/src/{bufferPolyfill.cjs → bufferToBase64/bufferPolyfill.cjs} +0 -0
  67. /package/src/{bufferPolyfill.d.ts → bufferToBase64/bufferPolyfill.d.ts} +0 -0
  68. /package/src/{bufferPolyfill.js → bufferToBase64/bufferPolyfill.js} +0 -0
  69. /package/src/{bufferToBase64.cjs → bufferToBase64/bufferToBase64.cjs} +0 -0
  70. /package/src/{bufferToBase64.d.ts → bufferToBase64/bufferToBase64.d.ts} +0 -0
  71. /package/src/{bufferToBase64.js → bufferToBase64/bufferToBase64.js} +0 -0
  72. /package/src/{getProvidersFromWindow.cjs → getProvidersFromWindow/getProvidersFromWindow.cjs} +0 -0
  73. /package/src/{getProvidersFromWindow.d.ts → getProvidersFromWindow/getProvidersFromWindow.d.ts} +0 -0
  74. /package/src/{getProvidersFromWindow.js → getProvidersFromWindow/getProvidersFromWindow.js} +0 -0
  75. /package/src/{isLedgerAddressViaVerifiedCredentials.cjs → isLedgerAddressViaVerifiedCredentials/isLedgerAddressViaVerifiedCredentials.cjs} +0 -0
  76. /package/src/{isLedgerAddressViaVerifiedCredentials.d.ts → isLedgerAddressViaVerifiedCredentials/isLedgerAddressViaVerifiedCredentials.d.ts} +0 -0
  77. /package/src/{isLedgerAddressViaVerifiedCredentials.js → isLedgerAddressViaVerifiedCredentials/isLedgerAddressViaVerifiedCredentials.js} +0 -0
  78. /package/src/{isMobile.cjs → isMobile/isMobile.cjs} +0 -0
  79. /package/src/{isMobile.d.ts → isMobile/isMobile.d.ts} +0 -0
  80. /package/src/{isMobile.js → isMobile/isMobile.js} +0 -0
  81. /package/src/{last.cjs → last/last.cjs} +0 -0
  82. /package/src/{last.d.ts → last/last.d.ts} +0 -0
  83. /package/src/{last.js → last/last.js} +0 -0
  84. /package/src/{localStorageAsync.d.ts → localStorageAsync/localStorageAsync.d.ts} +0 -0
  85. /package/src/{parseChainId.cjs → parseChainId/parseChainId.cjs} +0 -0
  86. /package/src/{parseChainId.d.ts → parseChainId/parseChainId.d.ts} +0 -0
  87. /package/src/{parseChainId.js → parseChainId/parseChainId.js} +0 -0
  88. /package/src/{retryableFn.d.ts → retryableFn/retryableFn.d.ts} +0 -0
@@ -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;
@@ -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 {};
@@ -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 = ({ postfix, storage, }) => {
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(getKey(key));
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(getKey(key), packValue(value));
31
+ storage.setItem(key, packValue(value));
33
32
  };
34
33
  const removeItem = (key) => {
35
- storage.removeItem(getKey(key));
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: ({ postfix, storage, }: CreateStorageServiceProps) => IStorageService;
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 = ({ postfix, storage, }) => {
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(getKey(key));
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(getKey(key), packValue(value));
27
+ storage.setItem(key, packValue(value));
29
28
  };
30
29
  const removeItem = (key) => {
31
- storage.removeItem(getKey(key));
30
+ storage.removeItem(key);
32
31
  };
33
32
  const getKeys = () => Object.keys(storage);
34
33
  return {
@@ -1,3 +1,4 @@
1
1
  export { StorageService, type StorageOptions } from './StorageService';
2
2
  export { createStorageService } from './createStorageService';
3
3
  export type { IStorageService } from './types';
4
+ export { applyPostfixToStorageService } from './applyPostfixToStorageService';
@@ -1,5 +1,5 @@
1
1
  export type IStorageService = {
2
- getItem: <T = string>(key: string) => T | undefined;
2
+ getItem: <T = string>(key: string) => T | null;
3
3
  setItem: <T>(key: string, value: T) => void;
4
4
  removeItem: (key: string) => void;
5
5
  getKeys: () => string[];
@@ -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 };
@@ -1,2 +0,0 @@
1
- import { EvmNetwork, GenericNetwork } from '@dynamic-labs/types';
2
- export declare const parseEvmNetworks: (networks: GenericNetwork[]) => EvmNetwork[];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes