@dynamic-labs/utils 4.8.3 → 4.8.5

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 (24) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +4 -4
  5. package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +2 -2
  6. package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +2 -2
  7. package/src/index.cjs +2 -0
  8. package/src/index.d.ts +1 -0
  9. package/src/index.js +1 -0
  10. package/src/services/PlatformEventsService/PlatformEventsService.cjs +33 -0
  11. package/src/services/PlatformEventsService/PlatformEventsService.d.ts +9 -0
  12. package/src/services/PlatformEventsService/PlatformEventsService.js +29 -0
  13. package/src/services/PlatformEventsService/createBrowserPlatformEventsService/createBrowserPlatformEventsService.cjs +30 -0
  14. package/src/services/PlatformEventsService/createBrowserPlatformEventsService/createBrowserPlatformEventsService.d.ts +2 -0
  15. package/src/services/PlatformEventsService/createBrowserPlatformEventsService/createBrowserPlatformEventsService.js +22 -0
  16. package/src/services/PlatformEventsService/createBrowserPlatformEventsService/index.d.ts +1 -0
  17. package/src/services/PlatformEventsService/index.d.ts +2 -0
  18. package/src/services/PlatformEventsService/types.d.ts +5 -0
  19. package/src/services/PlatformService/PlatformService.cjs +8 -0
  20. package/src/services/PlatformService/PlatformService.d.ts +6 -0
  21. package/src/services/PlatformService/PlatformService.js +8 -0
  22. package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs +1 -0
  23. package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js +1 -0
  24. package/src/services/PlatformService/types.d.ts +6 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,30 @@
1
1
 
2
+ ### [4.8.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.4...v4.8.5) (2025-03-06)
3
+
4
+
5
+ ### Features
6
+
7
+ * evm connector can sign arbitrary transactions ([#8217](https://github.com/dynamic-labs/dynamic-auth/issues/8217)) ([c5b227c](https://github.com/dynamic-labs/dynamic-auth/commit/c5b227c5a5d527f3fc74b8c1c9d0247eaf35a016))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * optimize shadow dom re-renders ([#8193](https://github.com/dynamic-labs/dynamic-auth/issues/8193)) ([c97310c](https://github.com/dynamic-labs/dynamic-auth/commit/c97310c9f3eb73b9f69b0b48a79e6bbd93d2e94a))
13
+ * show multichain wallets with zerodev ([#8220](https://github.com/dynamic-labs/dynamic-auth/issues/8220)) ([a48689d](https://github.com/dynamic-labs/dynamic-auth/commit/a48689da1303512551bdf8114de45493d33221a3))
14
+
15
+ ### [4.8.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.3...v4.8.4) (2025-03-05)
16
+
17
+
18
+ ### Features
19
+
20
+ * add iframe deeplink support for iOS Safari ([#8168](https://github.com/dynamic-labs/dynamic-auth/issues/8168)) ([cc4a6b9](https://github.com/dynamic-labs/dynamic-auth/commit/cc4a6b94b8e1b36b303ea5bf86734ba2e73bcef9))
21
+ * add binance bitcoin wallet support ([#8089](ttps://github.com/dynamic-labs/dynamic-auth/issues/8089)) ([c8a3a41](https://github.com/dynamic-labs/dynamic-auth/commit/c8a3a418e4f431b3442e5bc7332530b777e223c8))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * mobile wallet iframe redirects ([#8213](https://github.com/dynamic-labs/dynamic-auth/issues/8213)) ([96ea428](https://github.com/dynamic-labs/dynamic-auth/commit/96ea428375232e57379faef6e2a61dd818325777))
27
+
2
28
  ### [4.8.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.2...v4.8.3) (2025-03-04)
3
29
 
4
30
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.8.3";
6
+ var version = "4.8.5";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.8.3";
2
+ var version = "4.8.5";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "4.8.3",
3
+ "version": "4.8.5",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -20,9 +20,9 @@
20
20
  "dependencies": {
21
21
  "@dynamic-labs/sdk-api-core": "0.0.638",
22
22
  "tldts": "6.0.16",
23
- "@dynamic-labs/assert-package-version": "4.8.3",
24
- "@dynamic-labs/logger": "4.8.3",
25
- "@dynamic-labs/types": "4.8.3",
23
+ "@dynamic-labs/assert-package-version": "4.8.5",
24
+ "@dynamic-labs/logger": "4.8.5",
25
+ "@dynamic-labs/types": "4.8.5",
26
26
  "buffer": "6.0.3",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
@@ -9,8 +9,8 @@ require('../../_virtual/_tslib.cjs');
9
9
  require('tldts');
10
10
 
11
11
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
12
- const url = encodeURIComponent(window.location.toString());
13
- const ref = encodeURIComponent(window.location.origin);
12
+ const url = encodeURIComponent(PlatformService.PlatformService.getUrl().href);
13
+ const ref = encodeURIComponent(PlatformService.PlatformService.getOrigin());
14
14
  // samsung browser only supports native links, not universal links
15
15
  if (isMobile.isSamsungBrowser()) {
16
16
  PlatformService.PlatformService.openURL(`${nativeLink}/${url}?ref=${ref}`);
@@ -5,8 +5,8 @@ import '../../_virtual/_tslib.js';
5
5
  import 'tldts';
6
6
 
7
7
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
8
- const url = encodeURIComponent(window.location.toString());
9
- const ref = encodeURIComponent(window.location.origin);
8
+ const url = encodeURIComponent(PlatformService.getUrl().href);
9
+ const ref = encodeURIComponent(PlatformService.getOrigin());
10
10
  // samsung browser only supports native links, not universal links
11
11
  if (isSamsungBrowser()) {
12
12
  PlatformService.openURL(`${nativeLink}/${url}?ref=${ref}`);
package/src/index.cjs CHANGED
@@ -91,6 +91,7 @@ var template = require('./template/template.cjs');
91
91
  var phantomRedirect = require('./consts/phantomRedirect.cjs');
92
92
  var PlatformService = require('./services/PlatformService/PlatformService.cjs');
93
93
  var createBrowserPlatformService = require('./services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs');
94
+ var PlatformEventsService = require('./services/PlatformEventsService/PlatformEventsService.cjs');
94
95
  var FetchService = require('./services/FetchService/FetchService.cjs');
95
96
  var Oauth2Service = require('./services/Oauth2Service/Oauth2Service.cjs');
96
97
  var createWindowOauth2Service = require('./services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs');
@@ -211,6 +212,7 @@ exports.template = template.template;
211
212
  exports.PHANTOM_REDIRECT_CONNECTION_TYPE_KEY = phantomRedirect.PHANTOM_REDIRECT_CONNECTION_TYPE_KEY;
212
213
  exports.PlatformService = PlatformService.PlatformService;
213
214
  exports.createBrowserPlatformService = createBrowserPlatformService.createBrowserPlatformService;
215
+ exports.PlatformEventsService = PlatformEventsService.PlatformEventsService;
214
216
  exports.FetchService = FetchService.FetchService;
215
217
  exports.Oauth2Service = Oauth2Service.Oauth2Service;
216
218
  exports.createWindowOauth2Service = createWindowOauth2Service.createWindowOauth2Service;
package/src/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export { runSafe } from './runSafe';
38
38
  export { template } from './template';
39
39
  export { PHANTOM_REDIRECT_CONNECTION_TYPE_KEY, type PhantomRedirectConnectionType, } from './consts/phantomRedirect';
40
40
  export { PlatformService, createBrowserPlatformService, type IPlatformService, } from './services/PlatformService';
41
+ export { PlatformEventsService, type IPlatformEvents, type IPlatformEventsService, } from './services/PlatformEventsService';
41
42
  export { FetchService } from './services/FetchService';
42
43
  export { Oauth2Service, type GetOauthCodeError, type GetOauthCodeProps, type IOauth2Service, createWindowOauth2Service, } from './services/Oauth2Service';
43
44
  export { type IStorageService, type StorageOptions, StorageService, createStorageService, applyPostfixToStorageService, } from './services/StorageService';
package/src/index.js CHANGED
@@ -87,6 +87,7 @@ export { template } from './template/template.js';
87
87
  export { PHANTOM_REDIRECT_CONNECTION_TYPE_KEY } from './consts/phantomRedirect.js';
88
88
  export { PlatformService } from './services/PlatformService/PlatformService.js';
89
89
  export { createBrowserPlatformService } from './services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js';
90
+ export { PlatformEventsService } from './services/PlatformEventsService/PlatformEventsService.js';
90
91
  export { FetchService } from './services/FetchService/FetchService.js';
91
92
  export { Oauth2Service } from './services/Oauth2Service/Oauth2Service.js';
92
93
  export { createWindowOauth2Service } from './services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js';
@@ -0,0 +1,33 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var createBrowserPlatformEventsService = require('./createBrowserPlatformEventsService/createBrowserPlatformEventsService.cjs');
8
+
9
+ var _a, _PlatformEventsService_implementation;
10
+ class PlatformEventsService {
11
+ static get implementation() {
12
+ if (!_tslib.__classPrivateFieldGet(_a, _a, "f", _PlatformEventsService_implementation)) {
13
+ _tslib.__classPrivateFieldSet(_a, _a, createBrowserPlatformEventsService.createBrowserPlatformEventsService(window), "f", _PlatformEventsService_implementation);
14
+ }
15
+ return _tslib.__classPrivateFieldGet(_a, _a, "f", _PlatformEventsService_implementation);
16
+ }
17
+ static set implementation(implementation) {
18
+ _tslib.__classPrivateFieldSet(_a, _a, implementation, "f", _PlatformEventsService_implementation);
19
+ }
20
+ static get on() {
21
+ return _a.implementation.on.bind(_a.implementation);
22
+ }
23
+ static get off() {
24
+ return _a.implementation.off.bind(_a.implementation);
25
+ }
26
+ static get once() {
27
+ return _a.implementation.once.bind(_a.implementation);
28
+ }
29
+ }
30
+ _a = PlatformEventsService;
31
+ _PlatformEventsService_implementation = { value: void 0 };
32
+
33
+ exports.PlatformEventsService = PlatformEventsService;
@@ -0,0 +1,9 @@
1
+ import { IPlatformEventsService } from './types';
2
+ export declare class PlatformEventsService {
3
+ #private;
4
+ static get implementation(): IPlatformEventsService;
5
+ static set implementation(implementation: IPlatformEventsService | undefined);
6
+ static get on(): <T extends "appFocused">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<import("./types").IPlatformEvents>[Extract<T, "appFocused">]) => void, context?: any) => import("eventemitter3").EventEmitter<import("./types").IPlatformEvents, any>;
7
+ static get off(): <T extends "appFocused">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<import("./types").IPlatformEvents>[Extract<T, "appFocused">]) => void) | undefined, context?: any, once?: boolean | undefined) => import("eventemitter3").EventEmitter<import("./types").IPlatformEvents, any>;
8
+ static get once(): <T extends "appFocused">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<import("./types").IPlatformEvents>[Extract<T, "appFocused">]) => void, context?: any) => import("eventemitter3").EventEmitter<import("./types").IPlatformEvents, any>;
9
+ }
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../_virtual/_tslib.js';
3
+ import { createBrowserPlatformEventsService } from './createBrowserPlatformEventsService/createBrowserPlatformEventsService.js';
4
+
5
+ var _a, _PlatformEventsService_implementation;
6
+ class PlatformEventsService {
7
+ static get implementation() {
8
+ if (!__classPrivateFieldGet(_a, _a, "f", _PlatformEventsService_implementation)) {
9
+ __classPrivateFieldSet(_a, _a, createBrowserPlatformEventsService(window), "f", _PlatformEventsService_implementation);
10
+ }
11
+ return __classPrivateFieldGet(_a, _a, "f", _PlatformEventsService_implementation);
12
+ }
13
+ static set implementation(implementation) {
14
+ __classPrivateFieldSet(_a, _a, implementation, "f", _PlatformEventsService_implementation);
15
+ }
16
+ static get on() {
17
+ return _a.implementation.on.bind(_a.implementation);
18
+ }
19
+ static get off() {
20
+ return _a.implementation.off.bind(_a.implementation);
21
+ }
22
+ static get once() {
23
+ return _a.implementation.once.bind(_a.implementation);
24
+ }
25
+ }
26
+ _a = PlatformEventsService;
27
+ _PlatformEventsService_implementation = { value: void 0 };
28
+
29
+ export { PlatformEventsService };
@@ -0,0 +1,30 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var EventEmitter = require('eventemitter3');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
11
+
12
+ const createBrowserPlatformEventsService = (window) => {
13
+ const emitter = new EventEmitter__default["default"]();
14
+ /**
15
+ * This map ensure the when a new value is added to
16
+ * IPlatformEvents it will be required to implement here too
17
+ */
18
+ const mapPlatformEventsToRequestChannel = {
19
+ appFocused: () => {
20
+ window.addEventListener('focus', () => {
21
+ emitter.emit('appFocused');
22
+ });
23
+ },
24
+ };
25
+ // Setup all events
26
+ Object.values(mapPlatformEventsToRequestChannel).forEach((handler) => handler());
27
+ return emitter;
28
+ };
29
+
30
+ exports.createBrowserPlatformEventsService = createBrowserPlatformEventsService;
@@ -0,0 +1,2 @@
1
+ import { IPlatformEventsService } from '../types';
2
+ export declare const createBrowserPlatformEventsService: (window: Window) => IPlatformEventsService;
@@ -0,0 +1,22 @@
1
+ 'use client'
2
+ import EventEmitter from 'eventemitter3';
3
+
4
+ const createBrowserPlatformEventsService = (window) => {
5
+ const emitter = new EventEmitter();
6
+ /**
7
+ * This map ensure the when a new value is added to
8
+ * IPlatformEvents it will be required to implement here too
9
+ */
10
+ const mapPlatformEventsToRequestChannel = {
11
+ appFocused: () => {
12
+ window.addEventListener('focus', () => {
13
+ emitter.emit('appFocused');
14
+ });
15
+ },
16
+ };
17
+ // Setup all events
18
+ Object.values(mapPlatformEventsToRequestChannel).forEach((handler) => handler());
19
+ return emitter;
20
+ };
21
+
22
+ export { createBrowserPlatformEventsService };
@@ -0,0 +1 @@
1
+ export { createBrowserPlatformEventsService } from './createBrowserPlatformEventsService';
@@ -0,0 +1,2 @@
1
+ export { PlatformEventsService } from './PlatformEventsService';
2
+ export { type IPlatformEvents, type IPlatformEventsService } from './types';
@@ -0,0 +1,5 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ export type IPlatformEvents = {
3
+ appFocused: () => void;
4
+ };
5
+ export type IPlatformEventsService = Pick<EventEmitter<IPlatformEvents>, 'on' | 'off' | 'once'>;
@@ -56,6 +56,14 @@ class PlatformService {
56
56
  static get getHostname() {
57
57
  return _a.implementation.getHostname;
58
58
  }
59
+ /**
60
+ * Gets the current URL.
61
+ *
62
+ * @example new URL(window.location.href)
63
+ */
64
+ static get getUrl() {
65
+ return _a.implementation.getUrl;
66
+ }
59
67
  static get getTLD() {
60
68
  return _a.implementation.getTLD;
61
69
  }
@@ -32,6 +32,12 @@ export declare class PlatformService {
32
32
  * @example window.location.hostname
33
33
  */
34
34
  static get getHostname(): () => string;
35
+ /**
36
+ * Gets the current URL.
37
+ *
38
+ * @example new URL(window.location.href)
39
+ */
40
+ static get getUrl(): () => URL;
35
41
  static get getTLD(): () => string | undefined;
36
42
  /**
37
43
  * Opens a URL. If possible, should avoid new windows.
@@ -52,6 +52,14 @@ class PlatformService {
52
52
  static get getHostname() {
53
53
  return _a.implementation.getHostname;
54
54
  }
55
+ /**
56
+ * Gets the current URL.
57
+ *
58
+ * @example new URL(window.location.href)
59
+ */
60
+ static get getUrl() {
61
+ return _a.implementation.getUrl;
62
+ }
55
63
  static get getTLD() {
56
64
  return _a.implementation.getTLD;
57
65
  }
@@ -23,6 +23,7 @@ const createBrowserPlatformService = (window) => ({
23
23
  });
24
24
  return data.domain || undefined;
25
25
  },
26
+ getUrl: () => new URL(window.location.href),
26
27
  isNativeMobile: false,
27
28
  openURL: (url_1, ...args_1) => _tslib.__awaiter(void 0, [url_1, ...args_1], void 0, function* (url, target = 'self', features = '') {
28
29
  if (target === 'blank') {
@@ -19,6 +19,7 @@ const createBrowserPlatformService = (window) => ({
19
19
  });
20
20
  return data.domain || undefined;
21
21
  },
22
+ getUrl: () => new URL(window.location.href),
22
23
  isNativeMobile: false,
23
24
  openURL: (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, target = 'self', features = '') {
24
25
  if (target === 'blank') {
@@ -16,6 +16,12 @@ export interface IPlatformService {
16
16
  * @example window.location.host
17
17
  */
18
18
  getHost(): string;
19
+ /**
20
+ * Gets the current URL.
21
+ *
22
+ * @example new URL(window.location.href)
23
+ */
24
+ getUrl(): URL;
19
25
  /**
20
26
  * Gets the origin of the current location.
21
27
  *