@dynamic-labs/utils 2.2.0-alpha.4 → 2.2.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 CHANGED
@@ -1,44 +1,78 @@
1
1
 
2
- ## [2.2.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.3...v2.2.0-alpha.4) (2024-06-06)
2
+ ## [2.2.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.5...v2.2.0) (2024-06-16)
3
+
4
+
5
+ ### Features
6
+
7
+ * add useSwitchNetwork ([#6027](https://github.com/dynamic-labs/DynamicAuth/issues/6027)) ([671310a](https://github.com/dynamic-labs/DynamicAuth/commit/671310a98aaeca12e02443c824d5d7cad2cdc769))
8
+ * add walletAdded to useDynamicEvents ([#6026](https://github.com/dynamic-labs/DynamicAuth/issues/6026)) ([8b784b7](https://github.com/dynamic-labs/DynamicAuth/commit/8b784b702e242ca279aafae657a076a51d397627))
9
+ * expose selectedTabState and deprecate setDefaultSelectedTab ([#6028](https://github.com/dynamic-labs/DynamicAuth/issues/6028)) ([eb71787](https://github.com/dynamic-labs/DynamicAuth/commit/eb717877cb6604504d10802a3aecc6055f95caa0))
10
+
11
+ ### [2.1.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.4...v2.1.5) (2024-06-16)
12
+
13
+ * Improve handling of unknown wallets, css fixes and copy updates in multi wallet experience
14
+
15
+ ### [2.1.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.3...v2.1.4) (2024-06-14)
3
16
 
4
17
 
5
18
  ### Bug Fixes
6
19
 
7
- * btc getBalance should use ordinal address if payment not available ([#5882](https://github.com/dynamic-labs/DynamicAuth/issues/5882)) ([803a055](https://github.com/dynamic-labs/DynamicAuth/commit/803a05518ae9d2353d50f51b29047dff01136710))
8
- * connect prompt when switching to xverse ([#5888](https://github.com/dynamic-labs/DynamicAuth/issues/5888)) ([181a7c4](https://github.com/dynamic-labs/DynamicAuth/commit/181a7c4af8217dab7ed2776d56ec2e3725a0ee6a))
20
+ * close sign modal when signing in with a wallet when embedded wallet is enabled ([#6012](https://github.com/dynamic-labs/DynamicAuth/issues/6012)) ([d473cc8](https://github.com/dynamic-labs/DynamicAuth/commit/d473cc83ac378b7bc43e2546020c02a297d4595b))
21
+ * display custom network name in network picker even if it doesn't have a valid icon ([#6020](https://github.com/dynamic-labs/DynamicAuth/issues/6020)) ([5e1539e](https://github.com/dynamic-labs/DynamicAuth/commit/5e1539e1e6920fb1fdbf96c938f40e785b3ee680))
9
22
 
10
- ## [2.2.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.2...v2.2.0-alpha.3) (2024-06-05)
23
+ ### [2.1.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2...v2.1.3) (2024-06-14)
11
24
 
12
25
 
13
26
  ### Features
14
27
 
15
- * farcaster linking ([#5869](https://github.com/dynamic-labs/DynamicAuth/issues/5869)) ([191d1d2](https://github.com/dynamic-labs/DynamicAuth/commit/191d1d29e436e7d453d533c9c330ac5cef2e2a1c))
28
+ * add in-app browser navigation support for sats-connect ([#5990](https://github.com/dynamic-labs/DynamicAuth/issues/5990)) ([7ea15b9](https://github.com/dynamic-labs/DynamicAuth/commit/7ea15b93d1864164acb82c1e73aae7f9130e1d44))
16
29
 
17
30
 
18
31
  ### Bug Fixes
19
32
 
20
- * phone number in kyc step ([#5875](https://github.com/dynamic-labs/DynamicAuth/issues/5875)) ([d73f3b1](https://github.com/dynamic-labs/DynamicAuth/commit/d73f3b158e794727e7bed5d558a43d937951ce56))
33
+ * cache getGenesisHash call to prevent over calling ([#5966](https://github.com/dynamic-labs/DynamicAuth/issues/5966)) ([#5970](https://github.com/dynamic-labs/DynamicAuth/issues/5970)) ([b624b2e](https://github.com/dynamic-labs/DynamicAuth/commit/b624b2ea5b398bf464d3098e7d81d83c7b5bf659))
34
+ * improvements to embedded solana wallet ([#6001](https://github.com/dynamic-labs/DynamicAuth/issues/6001)) ([a6437c9](https://github.com/dynamic-labs/DynamicAuth/commit/a6437c93e1946bca609d3d99d282123275022376)) ([#5815](https://github.com/dynamic-labs/DynamicAuth/issues/5815)) ([#5978](https://github.com/dynamic-labs/DynamicAuth/issues/5978)) ([dd92973](https://github.com/dynamic-labs/DynamicAuth/commit/dd9297365f0ccbee1217325328e173ae7ee9a922))
35
+ * show linked wallets with unavailable providers in user wallets list ([#6005](https://github.com/dynamic-labs/DynamicAuth/issues/6005)) ([79796d1](https://github.com/dynamic-labs/DynamicAuth/commit/79796d1b73670265ca9897314252b620afaa2e8a))
36
+ * close switch network modal after switching to a supported network ([#5987](https://github.com/dynamic-labs/DynamicAuth/issues/5987)) ([a7e762e](https://github.com/dynamic-labs/DynamicAuth/commit/a7e762ef63a72492d0c083a344111589a6fbc455))
21
37
 
22
- ## [2.2.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.1...v2.2.0-alpha.2) (2024-06-05)
38
+ ### [2.1.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2-alpha.1...v2.1.2) (2024-06-10)
23
39
 
24
40
 
25
41
  ### Features
26
42
 
27
- * display enabled countries in phone number field ([#5825](https://github.com/dynamic-labs/DynamicAuth/issues/5825)) ([a1ea0e1](https://github.com/dynamic-labs/DynamicAuth/commit/a1ea0e1ac1cf48ec348a243fd986991361b3b54f))
43
+ * hide wallets from wallet list that can't have multiple accounts linked ([#5935](https://github.com/dynamic-labs/DynamicAuth/issues/5935)) ([20f9b15](https://github.com/dynamic-labs/DynamicAuth/commit/20f9b15b145cbc57519155691b3640149eec3689))
28
44
 
29
45
 
30
46
  ### Bug Fixes
31
47
 
32
- * bump @solana/web3.js containing new version of rpc-websockets ([#5853](https://github.com/dynamic-labs/DynamicAuth/issues/5853)) ([dd5bc12](https://github.com/dynamic-labs/DynamicAuth/commit/dd5bc121c35d86dca52f5574ebc30ab30f35b626)), closes [solana-labs/solana-web3.js#2762](https://github.com/solana-labs/solana-web3.js/issues/2762)
48
+ * ensure sign message will not show 2 times ([#5938](https://github.com/dynamic-labs/DynamicAuth/issues/5938)) ([#5941](https://github.com/dynamic-labs/DynamicAuth/issues/5941)) ([2c5a156](https://github.com/dynamic-labs/DynamicAuth/commit/2c5a156ead565bd25067b3bc2b23cbc704f9b314))
49
+ * improve logic related to embedded wallets and emailVerifcation ([#5947](https://github.com/dynamic-labs/DynamicAuth/issues/5947)) ([b885a14](https://github.com/dynamic-labs/DynamicAuth/commit/b885a14dcf200f05233e4ab42b8b518d877d291a))
50
+ * init coinbase provider adhoc ([#5907](https://github.com/dynamic-labs/DynamicAuth/issues/5907)) ([#5933](https://github.com/dynamic-labs/DynamicAuth/issues/5933)) ([2fa1f52](https://github.com/dynamic-labs/DynamicAuth/commit/2fa1f528b27113ee108252ee874ee7f5ead88329))
51
+ * remove force consent and account selection even for returning google users ([#5912](https://github.com/dynamic-labs/DynamicAuth/issues/5912)) ([26a07f2](https://github.com/dynamic-labs/DynamicAuth/commit/26a07f29bdb8bf32a080396906a21d8b084c202f))
52
+ * resolve the default phone country based on enabled countries ([#5](https://github.com/dynamic-labs/DynamicAuth/issues/5)… ([#5916](https://github.com/dynamic-labs/DynamicAuth/issues/5916)) ([8f27c00](https://github.com/dynamic-labs/DynamicAuth/commit/8f27c0082edb77b964b8402cfa75c6a896b061d3)), closes [#5910](https://github.com/dynamic-labs/DynamicAuth/issues/5910)
53
+ * versioned tx needs address lookup table ([#5909](https://github.com/dynamic-labs/DynamicAuth/issues/5909)) ([#5919](https://github.com/dynamic-labs/DynamicAuth/issues/5919)) ([22e3ca2](https://github.com/dynamic-labs/DynamicAuth/commit/22e3ca2d0b27d15efb50e3092a7bc3a0c0d255a5))
54
+
55
+ ### [2.1.2-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2-alpha.0...v2.1.2-alpha.1) (2024-06-07)
33
56
 
34
- ## [2.2.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.0...v2.2.0-alpha.1) (2024-06-04)
35
57
 
36
- ## [2.2.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0...v2.2.0-alpha.0) (2024-06-04)
58
+ ### Bug Fixes
59
+
60
+ * find phantom solana provider when opening dapp on new tab ([#5902](https://github.com/dynamic-labs/DynamicAuth/issues/5902)) ([99daf87](https://github.com/dynamic-labs/DynamicAuth/commit/99daf87f17caed870a76e4f89a257a14da37c7ab)), closes [#5895](https://github.com/dynamic-labs/DynamicAuth/issues/5895) [#5896](https://github.com/dynamic-labs/DynamicAuth/issues/5896) [#5897](https://github.com/dynamic-labs/DynamicAuth/issues/5897)
61
+
62
+ ### [2.1.2-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.1...v2.1.2-alpha.0) (2024-06-07)
37
63
 
38
64
 
39
65
  ### Features
40
66
 
41
- * add multi-asset wallet header ([#5608](https://github.com/dynamic-labs/DynamicAuth/issues/5608)) ([47998b1](https://github.com/dynamic-labs/DynamicAuth/commit/47998b1999ddf786bf88b86248c79fc92f278331)), closes [#5655](https://github.com/dynamic-labs/DynamicAuth/issues/5655) [#5643](https://github.com/dynamic-labs/DynamicAuth/issues/5643) [#5673](https://github.com/dynamic-labs/DynamicAuth/issues/5673) [#5762](https://github.com/dynamic-labs/DynamicAuth/issues/5762) [#5766](https://github.com/dynamic-labs/DynamicAuth/issues/5766) [#5777](https://github.com/dynamic-labs/DynamicAuth/issues/5777)
67
+ * display enabled countries in phone number field ([#5825](https://github.com/dynamic-labs/DynamicAuth/issues/5825)) ([#5868](https://github.com/dynamic-labs/DynamicAuth/issues/5868)) ([640a4a7](https://github.com/dynamic-labs/DynamicAuth/commit/640a4a77c994390ceed759faf186717b38f393a4))
68
+
69
+
70
+ ### Bug Fixes
71
+
72
+ * btc getBalance should use ordinal address if payment not available ([#5883](https://github.com/dynamic-labs/DynamicAuth/issues/5883)) ([bc5ac55](https://github.com/dynamic-labs/DynamicAuth/commit/bc5ac5589e90193d41282d23ce037db360dd23e6))
73
+ * phone number in kyc step ([#5875](https://github.com/dynamic-labs/DynamicAuth/issues/5875)) ([#5879](https://github.com/dynamic-labs/DynamicAuth/issues/5879)) ([3d8a5be](https://github.com/dynamic-labs/DynamicAuth/commit/3d8a5bef35d4a13a1068aaf80d2c39e795b097cd))
74
+
75
+ ### [2.1.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0...v2.1.1) (2024-06-04)
42
76
 
43
77
  ## [2.1.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.32...v2.1.0) (2024-06-04)
44
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "2.2.0-alpha.4",
3
+ "version": "2.2.0",
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.460",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "2.2.0-alpha.4",
32
- "@dynamic-labs/types": "2.2.0-alpha.4",
31
+ "@dynamic-labs/logger": "2.2.0",
32
+ "@dynamic-labs/types": "2.2.0",
33
33
  "buffer": "6.0.3"
34
34
  },
35
35
  "peerDependencies": {
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Retrieves the value at the given path of an object.
8
+ * @param obj - The object from which to extract the value.
9
+ * @param path - The path to the desired value within the object, using dot notation.
10
+ * @returns The value from the specified path, or undefined if the path is not valid.
11
+ */
12
+ const get = (obj, path) => {
13
+ try {
14
+ // Split the path into keys considering special characters as part of the keys
15
+ const keys = path.match(/[^.[\]"']+/g) || [];
16
+ return keys.reduce((acc, key) => acc[key], obj);
17
+ }
18
+ catch (error) {
19
+ // If there is an error accessing the properties, return undefined
20
+ return undefined;
21
+ }
22
+ };
23
+
24
+ exports.get = get;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Retrieves the value at the given path of an object.
3
+ * @param obj - The object from which to extract the value.
4
+ * @param path - The path to the desired value within the object, using dot notation.
5
+ * @returns The value from the specified path, or undefined if the path is not valid.
6
+ */
7
+ export declare const get: <T = any>(obj: Record<string, any>, path: string) => T | undefined;
package/src/get/get.js ADDED
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ /**
3
+ * Retrieves the value at the given path of an object.
4
+ * @param obj - The object from which to extract the value.
5
+ * @param path - The path to the desired value within the object, using dot notation.
6
+ * @returns The value from the specified path, or undefined if the path is not valid.
7
+ */
8
+ const get = (obj, path) => {
9
+ try {
10
+ // Split the path into keys considering special characters as part of the keys
11
+ const keys = path.match(/[^.[\]"']+/g) || [];
12
+ return keys.reduce((acc, key) => acc[key], obj);
13
+ }
14
+ catch (error) {
15
+ // If there is an error accessing the properties, return undefined
16
+ return undefined;
17
+ }
18
+ };
19
+
20
+ export { get };
@@ -0,0 +1 @@
1
+ export { get } from './get';
@@ -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
@@ -60,6 +60,9 @@ var PlatformService = require('./services/PlatformService/PlatformService.cjs');
60
60
  var createBrowserPlatformService = require('./services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs');
61
61
  var FetchService = require('./services/FetchService/FetchService.cjs');
62
62
  var template = require('./template/template.cjs');
63
+ var get = require('./get/get.cjs');
64
+ var hexToString = require('./hexToString/hexToString.cjs');
65
+ var isHex = require('./isHex/isHex.cjs');
63
66
 
64
67
 
65
68
 
@@ -134,3 +137,6 @@ exports.PlatformService = PlatformService.PlatformService;
134
137
  exports.createBrowserPlatformService = createBrowserPlatformService.createBrowserPlatformService;
135
138
  exports.FetchService = FetchService.FetchService;
136
139
  exports.template = template.template;
140
+ exports.get = get.get;
141
+ exports.hexToString = hexToString.hexToString;
142
+ exports.isHex = isHex.isHex;
package/src/index.d.ts CHANGED
@@ -25,3 +25,6 @@ export { runSafe } from './runSafe';
25
25
  export { PlatformService, createBrowserPlatformService, type IPlatformService, } from './services/PlatformService';
26
26
  export { FetchService } from './services/FetchService';
27
27
  export { template } from './template';
28
+ export { get } from './get';
29
+ export { hexToString } from './hexToString';
30
+ export { isHex } from './isHex';
package/src/index.js CHANGED
@@ -56,3 +56,6 @@ export { PlatformService } from './services/PlatformService/PlatformService.js';
56
56
  export { createBrowserPlatformService } from './services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js';
57
57
  export { FetchService } from './services/FetchService/FetchService.js';
58
58
  export { template } from './template/template.js';
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 };