@dynamic-labs/utils 3.0.0-alpha.0 → 3.0.0-alpha.10

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,142 @@
1
1
 
2
+ ## [3.0.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.9...v3.0.0-alpha.10) (2024-06-24)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * clear expiresAt from local storage on logout ([#6110](https://github.com/dynamic-labs/DynamicAuth/issues/6110)) ([cbda893](https://github.com/dynamic-labs/DynamicAuth/commit/cbda893441154b6880a5419ce62a353b80f05e55))
8
+ * show SOL amount for complex transactions and better error display ([#6068](https://github.com/dynamic-labs/DynamicAuth/issues/6068)) ([454a3a0](https://github.com/dynamic-labs/DynamicAuth/commit/454a3a0a50805b3d63f44c2ef8c1dc766617eb2b))
9
+
10
+ ## [3.0.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.8...v3.0.0-alpha.9) (2024-06-21)
11
+
12
+ ## [3.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-06-21)
13
+
14
+
15
+ ### ⚠ BREAKING CHANGES
16
+
17
+ * break out turnkey package into 3 separate packages (#6015)
18
+
19
+ ### Features
20
+
21
+ * add reinitialize hook ([#6098](https://github.com/dynamic-labs/DynamicAuth/issues/6098)) ([d978baa](https://github.com/dynamic-labs/DynamicAuth/commit/d978baa404d34064c36cc549229b1fcea1f20df0))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * always reconnect the wallet provider when calling getAddress ([#6097](https://github.com/dynamic-labs/DynamicAuth/issues/6097)) ([0f3d497](https://github.com/dynamic-labs/DynamicAuth/commit/0f3d497cedb38239fa9ada2bb25c6b4eaa72d7b1))
27
+ * break out turnkey package into 3 separate packages ([#6015](https://github.com/dynamic-labs/DynamicAuth/issues/6015)) ([a86fbef](https://github.com/dynamic-labs/DynamicAuth/commit/a86fbefe97558363b085e6f752af32d2943f91fa)), closes [#6017](https://github.com/dynamic-labs/DynamicAuth/issues/6017) [#6059](https://github.com/dynamic-labs/DynamicAuth/issues/6059)
28
+ * set latest blockhash on solana transactions if tx confirmation ui is disabled ([#6102](https://github.com/dynamic-labs/DynamicAuth/issues/6102)) ([b8035a3](https://github.com/dynamic-labs/DynamicAuth/commit/b8035a328e47409bf0416d3a01b2f17914488748))
29
+ * silently query unisat accounts ([#6101](https://github.com/dynamic-labs/DynamicAuth/issues/6101)) ([#6104](https://github.com/dynamic-labs/DynamicAuth/issues/6104)) ([643e704](https://github.com/dynamic-labs/DynamicAuth/commit/643e7048ff8610b31e6397e10b160ad456a45d11))
30
+ * stop querying magiceden solana accounts ([#6103](https://github.com/dynamic-labs/DynamicAuth/issues/6103)) ([#6108](https://github.com/dynamic-labs/DynamicAuth/issues/6108)) ([3cfdbc3](https://github.com/dynamic-labs/DynamicAuth/commit/3cfdbc3bc82bfe9bf53bf4236f7892a5440fcb86))
31
+ * trigger sign when linking an already linked unknown wallet ([#6105](https://github.com/dynamic-labs/DynamicAuth/issues/6105)) ([9e9c03b](https://github.com/dynamic-labs/DynamicAuth/commit/9e9c03bf615991c4f1183bf85c4d75c9a7773c85))
32
+
33
+ ## [3.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-06-19)
34
+
35
+
36
+ ### ⚠ BREAKING CHANGES
37
+
38
+ * add selectedTabIndex and helpers (#6040)
39
+
40
+ ### Features
41
+
42
+ * add selectedTabIndex and helpers ([#6040](https://github.com/dynamic-labs/DynamicAuth/issues/6040)) ([ae20b80](https://github.com/dynamic-labs/DynamicAuth/commit/ae20b8081376dce97b18fa69c81c9ab73c1ff317))
43
+ * add useRefreshUser to trigger a user state refresh ([#6079](https://github.com/dynamic-labs/DynamicAuth/issues/6079)) ([1236d35](https://github.com/dynamic-labs/DynamicAuth/commit/1236d35fe9fab44ed2114ad9f3c8c6dca7ec27be))
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * always return userWallets when available ([#6080](https://github.com/dynamic-labs/DynamicAuth/issues/6080)) ([#6083](https://github.com/dynamic-labs/DynamicAuth/issues/6083)) ([11992d2](https://github.com/dynamic-labs/DynamicAuth/commit/11992d2af5a401ba4ff1dc6904e2a9f8ef5904ca))
49
+ * less solana rpc calls and improve fee fetching ([#6019](https://github.com/dynamic-labs/DynamicAuth/issues/6019)) ([e2609db](https://github.com/dynamic-labs/DynamicAuth/commit/e2609db962c7708ff5b127cb23260a25bc5032e3))
50
+ * make account change idemopotent ([#6061](https://github.com/dynamic-labs/DynamicAuth/issues/6061)) ([8c87513](https://github.com/dynamic-labs/DynamicAuth/commit/8c8751390ea14888c4889679895e2f06d75717b9))
51
+ * only run multi wallet prompt when user profile or auth flow are open ([#6073](https://github.com/dynamic-labs/DynamicAuth/issues/6073)) ([d48ca10](https://github.com/dynamic-labs/DynamicAuth/commit/d48ca105359018457a78588fd8d9aa8a91583a02))
52
+ * recompute multiwallet state after merging accounts ([#6078](https://github.com/dynamic-labs/DynamicAuth/issues/6078)) ([e08a274](https://github.com/dynamic-labs/DynamicAuth/commit/e08a274c4d848f2a8360be7106cfbfa00b9a8f9b))
53
+ * stop querying okx for accounts while locked ([#6081](https://github.com/dynamic-labs/DynamicAuth/issues/6081)) ([#6084](https://github.com/dynamic-labs/DynamicAuth/issues/6084)) ([34365ac](https://github.com/dynamic-labs/DynamicAuth/commit/34365ac1981fe020b03e666c24535a247645d2ad))
54
+ * update copy for primary wallet not connected modal ([#6069](https://github.com/dynamic-labs/DynamicAuth/issues/6069)) ([4a3f43c](https://github.com/dynamic-labs/DynamicAuth/commit/4a3f43ce5585983f7fea0c5b97e812c0ade80e2c))
55
+
56
+ ## [3.0.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-06-18)
57
+
58
+
59
+ ### Features
60
+
61
+ * implement useExternalAuth hook to signin using external jwt auth ([#6039](https://github.com/dynamic-labs/DynamicAuth/issues/6039)) ([ba90908](https://github.com/dynamic-labs/DynamicAuth/commit/ba90908509ec21f708a4a0782a7f94861fc3b484))
62
+
63
+
64
+ ### Bug Fixes
65
+
66
+ * allow sign-in with different ME BTC wallet after initial connection ([a527b46](https://github.com/dynamic-labs/DynamicAuth/commit/a527b464f321b4fc27730f57c3812e996b5ed878))
67
+ * close sign modal when signing in with a wallet when embedded wallet is enabled ([#6013](https://github.com/dynamic-labs/DynamicAuth/issues/6013)) ([0f4f3c8](https://github.com/dynamic-labs/DynamicAuth/commit/0f4f3c83db162f7a1794a3549b60bbad6b03e2c0))
68
+ * custom network without a valid icon should still display its name in network picker ([#6018](https://github.com/dynamic-labs/DynamicAuth/issues/6018)) ([0b10df6](https://github.com/dynamic-labs/DynamicAuth/commit/0b10df68950bfc9b8492443158a6bb030dc1122c))
69
+ * e2e: remove page pause ([#6045](https://github.com/dynamic-labs/DynamicAuth/issues/6045)) ([55bba00](https://github.com/dynamic-labs/DynamicAuth/commit/55bba0034255055d6ae266b1296542f47ed48e2b))
70
+ * more fixes for connect starknet button ([#6046](https://github.com/dynamic-labs/DynamicAuth/issues/6046)) ([0fb570a](https://github.com/dynamic-labs/DynamicAuth/commit/0fb570a44e65f8dd6d4d2bf5edb2ee54985ec9d4))
71
+ * set verified credentials on embedded wallet creation ([#6044](https://github.com/dynamic-labs/DynamicAuth/issues/6044)) ([b52a96d](https://github.com/dynamic-labs/DynamicAuth/commit/b52a96d321e7efdb30dce9cdb3f6f176c24ceb81))
72
+
73
+ ## [3.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.4...v3.0.0-alpha.5) (2024-06-14)
74
+
75
+
76
+ ### ⚠ BREAKING CHANGES
77
+
78
+ * remove viem dependency from non-evm packages (#5508)
79
+ * move rpc providers into their own packages (#5981)
80
+
81
+ ### Features
82
+
83
+ * add in-app browser navigation support for sats-connect ([#5988](https://github.com/dynamic-labs/DynamicAuth/issues/5988)) ([be27d2d](https://github.com/dynamic-labs/DynamicAuth/commit/be27d2d4030bbe2157e879497d8e6a00b4a3e404))
84
+ * move rpc providers into their own packages ([#5981](https://github.com/dynamic-labs/DynamicAuth/issues/5981)) ([d7a62d6](https://github.com/dynamic-labs/DynamicAuth/commit/d7a62d60e79dfa6d6651b0fa103e90b6f8a9ccf3))
85
+
86
+
87
+ ### Bug Fixes
88
+
89
+ * embedded solana wallets can send SPL tokens and estimate gas ([#5982](https://github.com/dynamic-labs/DynamicAuth/issues/5982)) ([36623eb](https://github.com/dynamic-labs/DynamicAuth/commit/36623eb99d1d1dfebfd8b6f3194eeff31e7de2bf))
90
+ * improve logic related to turnkey and emailVerifcation ([#5946](https://github.com/dynamic-labs/DynamicAuth/issues/5946)) ([dd0b2dc](https://github.com/dynamic-labs/DynamicAuth/commit/dd0b2dc6d93a8bbbcb6eef88732e62b747005bb3))
91
+ * show linked wallets with unavailable providers in user wallets list ([#5992](https://github.com/dynamic-labs/DynamicAuth/issues/5992)) ([996079c](https://github.com/dynamic-labs/DynamicAuth/commit/996079ced360651c7b1eb5273548e0548f6f9f3a))
92
+ * switch network modal not closing after switching to a supported network ([#5979](https://github.com/dynamic-labs/DynamicAuth/issues/5979)) ([f239952](https://github.com/dynamic-labs/DynamicAuth/commit/f2399523dd82bb28046992cac4582688b688bdc0))
93
+
94
+
95
+ * remove viem dependency from non-evm packages ([#5508](https://github.com/dynamic-labs/DynamicAuth/issues/5508)) ([0299dc3](https://github.com/dynamic-labs/DynamicAuth/commit/0299dc3cbb611182d763e9a89d1270c2e2f32df5))
96
+
97
+ ## [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)
98
+
99
+
100
+ ### Bug Fixes
101
+
102
+ * 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))
103
+ * 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))
104
+
105
+ ## [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)
106
+
107
+
108
+ ### Bug Fixes
109
+
110
+ * 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))
111
+
112
+ ## [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)
113
+
114
+
115
+ ### Features
116
+
117
+ * add silent signing ([#5712](https://github.com/dynamic-labs/DynamicAuth/issues/5712)) ([17f06f2](https://github.com/dynamic-labs/DynamicAuth/commit/17f06f24d9f576b4d3d879e14de73dc6e9ab2118)), closes [#5807](https://github.com/dynamic-labs/DynamicAuth/issues/5807) [#5908](https://github.com/dynamic-labs/DynamicAuth/issues/5908) [#5932](https://github.com/dynamic-labs/DynamicAuth/issues/5932) [#5937](https://github.com/dynamic-labs/DynamicAuth/issues/5937) [#5949](https://github.com/dynamic-labs/DynamicAuth/issues/5949)
118
+
119
+
120
+ ### Bug Fixes
121
+
122
+ * ensure backup code acknowledgement can be shown async ([#5955](https://github.com/dynamic-labs/DynamicAuth/issues/5955)) ([6e4d053](https://github.com/dynamic-labs/DynamicAuth/commit/6e4d0536f4d5eafc93fc6986d3ad8dc66bccd143))
123
+ * ensure sign message will not show 2 times ([#5938](https://github.com/dynamic-labs/DynamicAuth/issues/5938)) ([8b5a16b](https://github.com/dynamic-labs/DynamicAuth/commit/8b5a16bab201ff0a74d6f5065d454ba62131a761))
124
+ * process undefined in browser context ([#5920](https://github.com/dynamic-labs/DynamicAuth/issues/5920)) ([02fed81](https://github.com/dynamic-labs/DynamicAuth/commit/02fed811c53f7d14c91aab47d0b69ea2697619a7))
125
+
126
+ ## [3.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.0...v3.0.0-alpha.1) (2024-06-10)
127
+
128
+
129
+ ### Features
130
+
131
+ * hide wallets from wallet list that can't have multiple accounts linked ([#5892](https://github.com/dynamic-labs/DynamicAuth/issues/5892)) ([41f0114](https://github.com/dynamic-labs/DynamicAuth/commit/41f0114633dfdc3f0c27e1859da122e5c96e297d))
132
+ * update mfa backup code acknowledgement ([#5874](https://github.com/dynamic-labs/DynamicAuth/issues/5874)) ([4dea5e4](https://github.com/dynamic-labs/DynamicAuth/commit/4dea5e401c468d830f881bf5268055160a9cfa83))
133
+
134
+
135
+ ### Bug Fixes
136
+
137
+ * init coinbase provider adhoc ([#5907](https://github.com/dynamic-labs/DynamicAuth/issues/5907)) ([f778d97](https://github.com/dynamic-labs/DynamicAuth/commit/f778d974d5e70ac72abe70030cad2b76583e1581))
138
+ * versioned tx needs address lookup table ([#5909](https://github.com/dynamic-labs/DynamicAuth/issues/5909)) ([3daf0bc](https://github.com/dynamic-labs/DynamicAuth/commit/3daf0bc45c19c532a519031a813942df0e929107))
139
+
2
140
  ## [3.0.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.5...v3.0.0-alpha.0) (2024-06-10)
3
141
 
4
142
  ## [2.2.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.4...v2.2.0-alpha.5) (2024-06-08)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -26,13 +26,12 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/sdk-api-core": "0.0.460",
29
+ "@dynamic-labs/sdk-api-core": "0.0.470",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "3.0.0-alpha.0",
32
- "@dynamic-labs/types": "3.0.0-alpha.0",
33
- "buffer": "6.0.3"
31
+ "@dynamic-labs/logger": "3.0.0-alpha.10",
32
+ "@dynamic-labs/types": "3.0.0-alpha.10",
33
+ "buffer": "6.0.3",
34
+ "stream": "0.0.2"
34
35
  },
35
- "peerDependencies": {
36
- "viem": "^2.7.6"
37
- }
36
+ "peerDependencies": {}
38
37
  }
@@ -0,0 +1,40 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isEip9693Event = (event) => event.type === 'eip6963:announceProvider' &&
7
+ event.detail !== undefined;
8
+ class Eip6963Provider {
9
+ constructor() {
10
+ this.providers = [];
11
+ }
12
+ registerProviders() {
13
+ if (typeof window === 'undefined') {
14
+ return;
15
+ }
16
+ window.addEventListener('eip6963:announceProvider', (event) => {
17
+ if (!isEip9693Event(event)) {
18
+ return;
19
+ }
20
+ this.providers.push(event.detail);
21
+ });
22
+ window.dispatchEvent(new Event('eip6963:requestProvider'));
23
+ }
24
+ }
25
+ class Eip6963ProviderSingleton {
26
+ constructor() {
27
+ this.eip6963Provider = new Eip6963Provider();
28
+ }
29
+ static get() {
30
+ var _a;
31
+ if (!((_a = Eip6963ProviderSingleton.instance) === null || _a === void 0 ? void 0 : _a.eip6963Provider)) {
32
+ Eip6963ProviderSingleton.instance = new Eip6963ProviderSingleton();
33
+ Eip6963ProviderSingleton.instance.eip6963Provider.registerProviders();
34
+ }
35
+ return Eip6963ProviderSingleton.instance.eip6963Provider;
36
+ }
37
+ }
38
+
39
+ exports.Eip6963Provider = Eip6963Provider;
40
+ exports.Eip6963ProviderSingleton = Eip6963ProviderSingleton;
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { EventEmitter } from 'stream';
4
+ export type IEthereum = {
5
+ [key: string]: any;
6
+ providers?: object[];
7
+ request: <T extends string>(params: {
8
+ method: T;
9
+ } | object) => Promise<T extends 'eth_requestAccounts' ? [string] : object>;
10
+ } & EventEmitter;
11
+ /**
12
+ * Represents the assets needed to display a wallet
13
+ */
14
+ type Eip6963ProviderInfo = {
15
+ uuid: string;
16
+ name: string;
17
+ icon: string;
18
+ rdns: string;
19
+ };
20
+ type Eip6963ProviderDetail = {
21
+ info: Eip6963ProviderInfo;
22
+ provider: IEthereum;
23
+ };
24
+ export declare class Eip6963Provider {
25
+ providers: Eip6963ProviderDetail[];
26
+ registerProviders(): void;
27
+ }
28
+ export declare class Eip6963ProviderSingleton {
29
+ readonly eip6963Provider: Eip6963Provider;
30
+ private constructor();
31
+ private static instance;
32
+ static get(): Eip6963Provider;
33
+ }
34
+ export {};
@@ -0,0 +1,35 @@
1
+ 'use client'
2
+ const isEip9693Event = (event) => event.type === 'eip6963:announceProvider' &&
3
+ event.detail !== undefined;
4
+ class Eip6963Provider {
5
+ constructor() {
6
+ this.providers = [];
7
+ }
8
+ registerProviders() {
9
+ if (typeof window === 'undefined') {
10
+ return;
11
+ }
12
+ window.addEventListener('eip6963:announceProvider', (event) => {
13
+ if (!isEip9693Event(event)) {
14
+ return;
15
+ }
16
+ this.providers.push(event.detail);
17
+ });
18
+ window.dispatchEvent(new Event('eip6963:requestProvider'));
19
+ }
20
+ }
21
+ class Eip6963ProviderSingleton {
22
+ constructor() {
23
+ this.eip6963Provider = new Eip6963Provider();
24
+ }
25
+ static get() {
26
+ var _a;
27
+ if (!((_a = Eip6963ProviderSingleton.instance) === null || _a === void 0 ? void 0 : _a.eip6963Provider)) {
28
+ Eip6963ProviderSingleton.instance = new Eip6963ProviderSingleton();
29
+ Eip6963ProviderSingleton.instance.eip6963Provider.registerProviders();
30
+ }
31
+ return Eip6963ProviderSingleton.instance.eip6963Provider;
32
+ }
33
+ }
34
+
35
+ export { Eip6963Provider, Eip6963ProviderSingleton };
@@ -0,0 +1 @@
1
+ export * from './eip6963Provider';
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class ExternalAuthError extends DynamicError.DynamicError {
9
+ constructor(code) {
10
+ super('ExternalAuthError', code);
11
+ }
12
+ }
13
+
14
+ exports.ExternalAuthError = ExternalAuthError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class ExternalAuthError extends DynamicError {
3
+ constructor(code: string);
4
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class ExternalAuthError extends DynamicError {
5
+ constructor(code) {
6
+ super('ExternalAuthError', code);
7
+ }
8
+ }
9
+
10
+ export { ExternalAuthError };
@@ -29,3 +29,4 @@ export * from './CookieInvalidError';
29
29
  export * from './AccessBlockedError';
30
30
  export * from './EmbeddedWalletException';
31
31
  export * from './MfaInvalidOtpError';
32
+ export * from './ExternalAuthError';
@@ -9,7 +9,6 @@ require('../logger/logger.cjs');
9
9
  var isMobile = require('../isMobile.cjs');
10
10
  require('../../_virtual/_tslib.cjs');
11
11
  require('../bufferPolyfill.cjs');
12
- require('viem/chains');
13
12
  require('tldts');
14
13
 
15
14
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
@@ -5,7 +5,6 @@ import '../logger/logger.js';
5
5
  import { isSamsungBrowser } from '../isMobile.js';
6
6
  import '../../_virtual/_tslib.js';
7
7
  import '../bufferPolyfill.js';
8
- import 'viem/chains';
9
8
  import 'tldts';
10
9
 
11
10
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
@@ -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
@@ -35,6 +35,7 @@ var CookieInvalidError = require('./errors/CookieInvalidError.cjs');
35
35
  var AccessBlockedError = require('./errors/AccessBlockedError.cjs');
36
36
  var EmbeddedWalletException = require('./errors/EmbeddedWalletException.cjs');
37
37
  var MfaInvalidOtpError = require('./errors/MfaInvalidOtpError.cjs');
38
+ var ExternalAuthError = require('./errors/ExternalAuthError.cjs');
38
39
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
39
40
  var isFunction = require('./isFunction/isFunction.cjs');
40
41
  var isMobile = require('./isMobile.cjs');
@@ -43,7 +44,6 @@ var bufferToBase64 = require('./bufferToBase64.cjs');
43
44
  var last = require('./last.cjs');
44
45
  var getProvidersFromWindow = require('./getProvidersFromWindow.cjs');
45
46
  var sleep = require('./sleep/sleep.cjs');
46
- var getOrMapViemChain = require('./getOrMapViemChain.cjs');
47
47
  var retryableFn = require('./retryableFn.cjs');
48
48
  var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
49
49
  var DeferredPromise = require('./DeferredPromise/DeferredPromise.cjs');
@@ -55,12 +55,15 @@ var formatNumberText = require('./formatNumberText/formatNumberText.cjs');
55
55
  var ceil = require('./ceil/ceil.cjs');
56
56
  var trimEnd = require('./trimEnd/trimEnd.cjs');
57
57
  var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
58
+ var eip6963Provider = require('./eip6963/eip6963Provider.cjs');
58
59
  var runSafe = require('./runSafe/runSafe.cjs');
59
60
  var PlatformService = require('./services/PlatformService/PlatformService.cjs');
60
61
  var createBrowserPlatformService = require('./services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs');
61
62
  var FetchService = require('./services/FetchService/FetchService.cjs');
62
63
  var template = require('./template/template.cjs');
63
64
  var get = require('./get/get.cjs');
65
+ var hexToString = require('./hexToString/hexToString.cjs');
66
+ var isHex = require('./isHex/isHex.cjs');
64
67
 
65
68
 
66
69
 
@@ -96,6 +99,7 @@ exports.CookieInvalidError = CookieInvalidError.CookieInvalidError;
96
99
  exports.AccessBlockedError = AccessBlockedError.AccessBlockedError;
97
100
  exports.EmbeddedWalletException = EmbeddedWalletException.EmbeddedWalletException;
98
101
  exports.MfaInvalidOtpError = MfaInvalidOtpError.MfaInvalidOtpError;
102
+ exports.ExternalAuthError = ExternalAuthError.ExternalAuthError;
99
103
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
100
104
  exports.isFunction = isFunction.isFunction;
101
105
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -115,9 +119,6 @@ exports.bufferToBase64 = bufferToBase64.bufferToBase64;
115
119
  exports.last = last.last;
116
120
  exports.getProvidersFromWindow = getProvidersFromWindow.getProvidersFromWindow;
117
121
  exports.sleep = sleep.sleep;
118
- exports.getChain = getOrMapViemChain.getChain;
119
- exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
120
- exports.mapChain = getOrMapViemChain.mapChain;
121
122
  exports.FALLBACK_UNDEFINED = retryableFn.FALLBACK_UNDEFINED;
122
123
  exports.retryableFn = retryableFn.retryableFn;
123
124
  exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
@@ -130,9 +131,13 @@ exports.formatNumberText = formatNumberText.formatNumberText;
130
131
  exports.ceil = ceil.ceil;
131
132
  exports.trimEnd = trimEnd.trimEnd;
132
133
  exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
134
+ exports.Eip6963Provider = eip6963Provider.Eip6963Provider;
135
+ exports.Eip6963ProviderSingleton = eip6963Provider.Eip6963ProviderSingleton;
133
136
  exports.runSafe = runSafe.runSafe;
134
137
  exports.PlatformService = PlatformService.PlatformService;
135
138
  exports.createBrowserPlatformService = createBrowserPlatformService.createBrowserPlatformService;
136
139
  exports.FetchService = FetchService.FetchService;
137
140
  exports.template = template.template;
138
141
  exports.get = get.get;
142
+ exports.hexToString = hexToString.hexToString;
143
+ exports.isHex = isHex.isHex;
package/src/index.d.ts CHANGED
@@ -9,7 +9,6 @@ export * from './bufferToBase64';
9
9
  export * from './last';
10
10
  export * from './getProvidersFromWindow';
11
11
  export * from './sleep';
12
- export * from './getOrMapViemChain';
13
12
  export * from './retryableFn';
14
13
  export * from './wrapMethodWithCallback';
15
14
  export * from './DeferredPromise';
@@ -21,8 +20,11 @@ export * from './formatNumberText';
21
20
  export * from './ceil';
22
21
  export * from './trimEnd';
23
22
  export * from './isLedgerAddressViaVerifiedCredentials';
23
+ export * from './eip6963';
24
24
  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
28
  export { get } from './get';
29
+ export { hexToString } from './hexToString';
30
+ export { isHex } from './isHex';
package/src/index.js CHANGED
@@ -31,6 +31,7 @@ export { CookieInvalidError } from './errors/CookieInvalidError.js';
31
31
  export { AccessBlockedError } from './errors/AccessBlockedError.js';
32
32
  export { EmbeddedWalletException } from './errors/EmbeddedWalletException.js';
33
33
  export { MfaInvalidOtpError } from './errors/MfaInvalidOtpError.js';
34
+ export { ExternalAuthError } from './errors/ExternalAuthError.js';
34
35
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
35
36
  export { isFunction } from './isFunction/isFunction.js';
36
37
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -39,7 +40,6 @@ export { bufferToBase64 } from './bufferToBase64.js';
39
40
  export { last } from './last.js';
40
41
  export { getProvidersFromWindow } from './getProvidersFromWindow.js';
41
42
  export { sleep } from './sleep/sleep.js';
42
- export { getChain, getOrMapViemChain, mapChain } from './getOrMapViemChain.js';
43
43
  export { FALLBACK_UNDEFINED, retryableFn } from './retryableFn.js';
44
44
  export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.js';
45
45
  export { DeferredPromise } from './DeferredPromise/DeferredPromise.js';
@@ -51,9 +51,12 @@ export { formatNumberText } from './formatNumberText/formatNumberText.js';
51
51
  export { ceil } from './ceil/ceil.js';
52
52
  export { trimEnd } from './trimEnd/trimEnd.js';
53
53
  export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
54
+ export { Eip6963Provider, Eip6963ProviderSingleton } from './eip6963/eip6963Provider.js';
54
55
  export { runSafe } from './runSafe/runSafe.js';
55
56
  export { PlatformService } from './services/PlatformService/PlatformService.js';
56
57
  export { createBrowserPlatformService } from './services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js';
57
58
  export { FetchService } from './services/FetchService/FetchService.js';
58
59
  export { template } from './template/template.js';
59
60
  export { get } from './get/get.js';
61
+ export { hexToString } from './hexToString/hexToString.js';
62
+ 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 };
@@ -9,7 +9,6 @@ require('./errors/TransactionGasCannotBeSponsoredError.cjs');
9
9
  require('./logger/logger.cjs');
10
10
  require('./bufferPolyfill.cjs');
11
11
  var sleep = require('./sleep/sleep.cjs');
12
- require('viem/chains');
13
12
  require('tldts');
14
13
 
15
14
  const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
@@ -5,7 +5,6 @@ import './errors/TransactionGasCannotBeSponsoredError.js';
5
5
  import './logger/logger.js';
6
6
  import './bufferPolyfill.js';
7
7
  import { sleep } from './sleep/sleep.js';
8
- import 'viem/chains';
9
8
  import 'tldts';
10
9
 
11
10
  const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
@@ -1,77 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var chains = require('viem/chains');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n["default"] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- var chains__namespace = /*#__PURE__*/_interopNamespace(chains);
27
-
28
- // eslint-disable-next-line import/no-namespace
29
- /**
30
- * Gets the chain object for the given chain id.
31
- * @param chainId - Chain id of the target EVM chain.
32
- * @returns Viem's chain object.
33
- */
34
- const getChain = (chainId) => {
35
- for (const chain of Object.values(chains__namespace)) {
36
- if ('id' in chain) {
37
- if (chain.id === chainId) {
38
- return chain;
39
- }
40
- }
41
- }
42
- throw new Error(`Chain with id ${chainId} not found`);
43
- };
44
- const mapChain = (network) => {
45
- var _a;
46
- return ({
47
- blockExplorers: ((_a = network.blockExplorerUrls) === null || _a === void 0 ? void 0 : _a[0])
48
- ? {
49
- default: {
50
- name: network.blockExplorerUrls[0],
51
- url: network.blockExplorerUrls[0],
52
- },
53
- }
54
- : undefined,
55
- id: network.chainId,
56
- name: network.vanityName || network.name || network.chainName,
57
- nativeCurrency: network.nativeCurrency,
58
- rpcUrls: {
59
- default: { http: network.rpcUrls },
60
- public: { http: network.rpcUrls },
61
- },
62
- });
63
- };
64
- const getOrMapViemChain = (network) => {
65
- let chain;
66
- try {
67
- chain = getChain(network.chainId);
68
- }
69
- catch (_a) {
70
- chain = mapChain(network);
71
- }
72
- return chain;
73
- };
74
-
75
- exports.getChain = getChain;
76
- exports.getOrMapViemChain = getOrMapViemChain;
77
- exports.mapChain = mapChain;
@@ -1,11 +0,0 @@
1
- import { Chain } from 'viem';
2
- import * as chains from 'viem/chains';
3
- import { EvmNetwork } from '@dynamic-labs/types';
4
- /**
5
- * Gets the chain object for the given chain id.
6
- * @param chainId - Chain id of the target EVM chain.
7
- * @returns Viem's chain object.
8
- */
9
- export declare const getChain: (chainId: number) => chains.Chain;
10
- export declare const mapChain: (network: EvmNetwork) => Chain;
11
- export declare const getOrMapViemChain: (network: EvmNetwork) => Chain;
@@ -1,51 +0,0 @@
1
- 'use client'
2
- import * as chains from 'viem/chains';
3
-
4
- // eslint-disable-next-line import/no-namespace
5
- /**
6
- * Gets the chain object for the given chain id.
7
- * @param chainId - Chain id of the target EVM chain.
8
- * @returns Viem's chain object.
9
- */
10
- const getChain = (chainId) => {
11
- for (const chain of Object.values(chains)) {
12
- if ('id' in chain) {
13
- if (chain.id === chainId) {
14
- return chain;
15
- }
16
- }
17
- }
18
- throw new Error(`Chain with id ${chainId} not found`);
19
- };
20
- const mapChain = (network) => {
21
- var _a;
22
- return ({
23
- blockExplorers: ((_a = network.blockExplorerUrls) === null || _a === void 0 ? void 0 : _a[0])
24
- ? {
25
- default: {
26
- name: network.blockExplorerUrls[0],
27
- url: network.blockExplorerUrls[0],
28
- },
29
- }
30
- : undefined,
31
- id: network.chainId,
32
- name: network.vanityName || network.name || network.chainName,
33
- nativeCurrency: network.nativeCurrency,
34
- rpcUrls: {
35
- default: { http: network.rpcUrls },
36
- public: { http: network.rpcUrls },
37
- },
38
- });
39
- };
40
- const getOrMapViemChain = (network) => {
41
- let chain;
42
- try {
43
- chain = getChain(network.chainId);
44
- }
45
- catch (_a) {
46
- chain = mapChain(network);
47
- }
48
- return chain;
49
- };
50
-
51
- export { getChain, getOrMapViemChain, mapChain };