@dynamic-labs/utils 3.0.0-alpha.2 → 3.0.0-alpha.4

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 CHANGED
@@ -1,4 +1,19 @@
1
1
 
2
+ ## [3.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) (2024-06-12)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * cache getGenesisHash call to prevent over calling ([#5966](https://github.com/dynamic-labs/DynamicAuth/issues/5966)) ([b4d542f](https://github.com/dynamic-labs/DynamicAuth/commit/b4d542f0a85f5ba8c5b8f02f287caee45b4b6feb))
8
+ * handle raw messages in embedded wallet sign message modal ([#5815](https://github.com/dynamic-labs/DynamicAuth/issues/5815)) ([9adc289](https://github.com/dynamic-labs/DynamicAuth/commit/9adc28993b57c1c7f03c4ce6d500288dcf60881e))
9
+
10
+ ## [3.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.2...v3.0.0-alpha.3) (2024-06-11)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * only navigate to mfa backup codes when needed ([#5965](https://github.com/dynamic-labs/DynamicAuth/issues/5965)) ([edc462f](https://github.com/dynamic-labs/DynamicAuth/commit/edc462f20768885db1883a2c8d005e07044092d5))
16
+
2
17
  ## [3.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.1...v3.0.0-alpha.2) (2024-06-11)
3
18
 
4
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -28,8 +28,8 @@
28
28
  "dependencies": {
29
29
  "@dynamic-labs/sdk-api-core": "0.0.461",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "3.0.0-alpha.2",
32
- "@dynamic-labs/types": "3.0.0-alpha.2",
31
+ "@dynamic-labs/logger": "3.0.0-alpha.4",
32
+ "@dynamic-labs/types": "3.0.0-alpha.4",
33
33
  "buffer": "6.0.3"
34
34
  },
35
35
  "peerDependencies": {
@@ -0,0 +1,32 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Converts a hexadecimal string to a regular string by interpreting each pair of characters in the
8
+ * hexadecimal string as a byte in ASCII. It automatically handles hex strings prefixed with '0x'.
9
+ *
10
+ * @param {string} hexString - The hexadecimal string to convert. It can optionally start with '0x'.
11
+ * @returns {string} The decoded ASCII string.
12
+ *
13
+ * @example
14
+ * hexToString('68656c6c6f'); // returns 'hello'
15
+ * hexToString('0x68656c6c6f'); // also returns 'hello'
16
+ */
17
+ const hexToString = (hexString) => {
18
+ const normalizedHexString = hexString.startsWith('0x')
19
+ ? hexString.substring(2)
20
+ : hexString;
21
+ let text = '';
22
+ // Ensure we only process complete pairs by rounding down to the nearest even length
23
+ const length = normalizedHexString.length - (normalizedHexString.length % 2);
24
+ for (let i = 0; i < length; i += 2) {
25
+ const hexCode = normalizedHexString.substring(i, i + 2);
26
+ const decimal = parseInt(hexCode, 16);
27
+ text += String.fromCharCode(decimal);
28
+ }
29
+ return text;
30
+ };
31
+
32
+ exports.hexToString = hexToString;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Converts a hexadecimal string to a regular string by interpreting each pair of characters in the
3
+ * hexadecimal string as a byte in ASCII. It automatically handles hex strings prefixed with '0x'.
4
+ *
5
+ * @param {string} hexString - The hexadecimal string to convert. It can optionally start with '0x'.
6
+ * @returns {string} The decoded ASCII string.
7
+ *
8
+ * @example
9
+ * hexToString('68656c6c6f'); // returns 'hello'
10
+ * hexToString('0x68656c6c6f'); // also returns 'hello'
11
+ */
12
+ export declare const hexToString: (hexString: string) => string;
@@ -0,0 +1,28 @@
1
+ 'use client'
2
+ /**
3
+ * Converts a hexadecimal string to a regular string by interpreting each pair of characters in the
4
+ * hexadecimal string as a byte in ASCII. It automatically handles hex strings prefixed with '0x'.
5
+ *
6
+ * @param {string} hexString - The hexadecimal string to convert. It can optionally start with '0x'.
7
+ * @returns {string} The decoded ASCII string.
8
+ *
9
+ * @example
10
+ * hexToString('68656c6c6f'); // returns 'hello'
11
+ * hexToString('0x68656c6c6f'); // also returns 'hello'
12
+ */
13
+ const hexToString = (hexString) => {
14
+ const normalizedHexString = hexString.startsWith('0x')
15
+ ? hexString.substring(2)
16
+ : hexString;
17
+ let text = '';
18
+ // Ensure we only process complete pairs by rounding down to the nearest even length
19
+ const length = normalizedHexString.length - (normalizedHexString.length % 2);
20
+ for (let i = 0; i < length; i += 2) {
21
+ const hexCode = normalizedHexString.substring(i, i + 2);
22
+ const decimal = parseInt(hexCode, 16);
23
+ text += String.fromCharCode(decimal);
24
+ }
25
+ return text;
26
+ };
27
+
28
+ export { hexToString };
@@ -0,0 +1 @@
1
+ export { hexToString } from './hexToString';
package/src/index.cjs CHANGED
@@ -61,6 +61,8 @@ var createBrowserPlatformService = require('./services/PlatformService/createBro
61
61
  var FetchService = require('./services/FetchService/FetchService.cjs');
62
62
  var template = require('./template/template.cjs');
63
63
  var get = require('./get/get.cjs');
64
+ var hexToString = require('./hexToString/hexToString.cjs');
65
+ var isHex = require('./isHex/isHex.cjs');
64
66
 
65
67
 
66
68
 
@@ -136,3 +138,5 @@ exports.createBrowserPlatformService = createBrowserPlatformService.createBrowse
136
138
  exports.FetchService = FetchService.FetchService;
137
139
  exports.template = template.template;
138
140
  exports.get = get.get;
141
+ exports.hexToString = hexToString.hexToString;
142
+ exports.isHex = isHex.isHex;
package/src/index.d.ts CHANGED
@@ -26,3 +26,5 @@ export { PlatformService, createBrowserPlatformService, type IPlatformService, }
26
26
  export { FetchService } from './services/FetchService';
27
27
  export { template } from './template';
28
28
  export { get } from './get';
29
+ export { hexToString } from './hexToString';
30
+ export { isHex } from './isHex';
package/src/index.js CHANGED
@@ -57,3 +57,5 @@ export { createBrowserPlatformService } from './services/PlatformService/createB
57
57
  export { FetchService } from './services/FetchService/FetchService.js';
58
58
  export { template } from './template/template.js';
59
59
  export { get } from './get/get.js';
60
+ export { hexToString } from './hexToString/hexToString.js';
61
+ export { isHex } from './isHex/isHex.js';
@@ -0,0 +1 @@
1
+ export { isHex } from './isHex';
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Checks if the provided string is a valid hexadecimal string.
8
+ * @param str The string to check.
9
+ * @returns `true` if the string is a valid hexadecimal string, `false` otherwise.
10
+ */
11
+ const isHex = (str) => {
12
+ if (typeof str !== 'string') {
13
+ throw new Error('Input must be a string');
14
+ }
15
+ const normalizedStr = str.startsWith('0x') ? str.substring(2) : str;
16
+ const regex = /^[0-9a-fA-F]+$/;
17
+ return regex.test(normalizedStr);
18
+ };
19
+
20
+ exports.isHex = isHex;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Checks if the provided string is a valid hexadecimal string.
3
+ * @param str The string to check.
4
+ * @returns `true` if the string is a valid hexadecimal string, `false` otherwise.
5
+ */
6
+ export declare const isHex: (str: string) => boolean;
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ /**
3
+ * Checks if the provided string is a valid hexadecimal string.
4
+ * @param str The string to check.
5
+ * @returns `true` if the string is a valid hexadecimal string, `false` otherwise.
6
+ */
7
+ const isHex = (str) => {
8
+ if (typeof str !== 'string') {
9
+ throw new Error('Input must be a string');
10
+ }
11
+ const normalizedStr = str.startsWith('0x') ? str.substring(2) : str;
12
+ const regex = /^[0-9a-fA-F]+$/;
13
+ return regex.test(normalizedStr);
14
+ };
15
+
16
+ export { isHex };