@dynamic-labs/utils 4.0.0-alpha.11 → 4.0.0-alpha.13

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,29 @@
1
1
 
2
+ ## [4.0.0-alpha.13](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.12...v4.0.0-alpha.13) (2024-10-18)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * improve displayed chain name in network switcher ([#7153](https://github.com/dynamic-labs/dynamic-auth/issues/7153)) ([55d2e5a](https://github.com/dynamic-labs/dynamic-auth/commit/55d2e5a9954bf0255b5caf7aba7a6f1f2e215967))
8
+
9
+ ## [4.0.0-alpha.12](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.11...v4.0.0-alpha.12) (2024-10-18)
10
+
11
+
12
+ ### Features
13
+
14
+ * add support for xverse account change event ([#7114](https://github.com/dynamic-labs/dynamic-auth/issues/7114)) ([79df047](https://github.com/dynamic-labs/dynamic-auth/commit/79df04775edb297a339e2d74adcc873584a6d8af))
15
+ * solana embedded signall headless ([#7132](https://github.com/dynamic-labs/dynamic-auth/issues/7132)) ([fe16b71](https://github.com/dynamic-labs/dynamic-auth/commit/fe16b71a4c0ad775f8de87ca899cfdd1071f11d6))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bug where embeddedWalletCreated event was fired before listener … ([#7151](https://github.com/dynamic-labs/dynamic-auth/issues/7151)) ([ae9da56](https://github.com/dynamic-labs/dynamic-auth/commit/ae9da56850130491384a2d5f47c1617815dcce5b))
21
+ * edge case where wallet book fails to load ([#7148](https://github.com/dynamic-labs/dynamic-auth/issues/7148)) ([805dc6d](https://github.com/dynamic-labs/dynamic-auth/commit/805dc6d7cc4cdf0b23748d82b3bd8216d88d55b5))
22
+ * issues where native currency icons were incorrect ([#7126](https://github.com/dynamic-labs/dynamic-auth/issues/7126)) ([8b8891a](https://github.com/dynamic-labs/dynamic-auth/commit/8b8891a52397e17cc127ea3a09ade14c4b70a8ee))
23
+ * remove now-unused sessionTimeout from useSocial ([#7123](https://github.com/dynamic-labs/dynamic-auth/issues/7123)) ([7959a8a](https://github.com/dynamic-labs/dynamic-auth/commit/7959a8a4c8ceb76c5c4f1ae91af204bf9c5cae7b))
24
+ * Revert: Update Exodus extension version " ([#7130](https://github.com/dynamic-labs/dynamic-auth/issues/7130)) ([f2274ae](https://github.com/dynamic-labs/dynamic-auth/commit/f2274aefd29bb9f3fb6de8493e4a5f73946a5600)), closes [#7129](https://github.com/dynamic-labs/dynamic-auth/issues/7129)
25
+ * use embedded primaryChain when passing undefined chains list to createTurnkeyWallet ([#7149](https://github.com/dynamic-labs/dynamic-auth/issues/7149)) ([c73a3ae](https://github.com/dynamic-labs/dynamic-auth/commit/c73a3aeeda8045b936d218f7078ad79967c321ef))
26
+
2
27
  ## [4.0.0-alpha.11](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.10...v4.0.0-alpha.11) (2024-10-15)
3
28
 
4
29
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.0-alpha.11";
6
+ var version = "4.0.0-alpha.13";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.0.0-alpha.11";
2
+ var version = "4.0.0-alpha.13";
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.0.0-alpha.11",
3
+ "version": "4.0.0-alpha.13",
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",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/sdk-api-core": "0.0.545",
21
+ "@dynamic-labs/sdk-api-core": "0.0.547",
22
22
  "tldts": "6.0.16",
23
- "@dynamic-labs/assert-package-version": "4.0.0-alpha.11",
24
- "@dynamic-labs/logger": "4.0.0-alpha.11",
25
- "@dynamic-labs/types": "4.0.0-alpha.11",
23
+ "@dynamic-labs/assert-package-version": "4.0.0-alpha.13",
24
+ "@dynamic-labs/logger": "4.0.0-alpha.13",
25
+ "@dynamic-labs/types": "4.0.0-alpha.13",
26
26
  "buffer": "6.0.3",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
package/src/index.cjs CHANGED
@@ -76,8 +76,10 @@ var hexToString = require('./hexToString/hexToString.cjs');
76
76
  var isHex = require('./isHex/isHex.cjs');
77
77
  var StorageService = require('./services/StorageService/StorageService.cjs');
78
78
  var createStorageService = require('./services/StorageService/createStorageService/createStorageService.cjs');
79
+ var applyPostfixToStorageService = require('./services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.cjs');
79
80
  var cloneObjectWithOverrides = require('./cloneObjectWithOverrides/cloneObjectWithOverrides.cjs');
80
81
  var promiseWithTimeout = require('./promiseWithTimeout/promiseWithTimeout.cjs');
82
+ var isInIframe = require('./isInIframe/isInIframe.cjs');
81
83
 
82
84
  assertPackageVersion.assertPackageVersion('@dynamic-labs/utils', _package.version);
83
85
 
@@ -166,5 +168,7 @@ exports.hexToString = hexToString.hexToString;
166
168
  exports.isHex = isHex.isHex;
167
169
  exports.StorageService = StorageService.StorageService;
168
170
  exports.createStorageService = createStorageService.createStorageService;
171
+ exports.applyPostfixToStorageService = applyPostfixToStorageService.applyPostfixToStorageService;
169
172
  exports.cloneObjectWithOverrides = cloneObjectWithOverrides.cloneObjectWithOverrides;
170
173
  exports.promiseWithTimeout = promiseWithTimeout.promiseWithTimeout;
174
+ exports.isInIframe = isInIframe.isInIframe;
package/src/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { template } from './template';
29
29
  export { get } from './get';
30
30
  export { hexToString } from './hexToString';
31
31
  export { isHex } from './isHex';
32
- export { type IStorageService, type StorageOptions, StorageService, createStorageService, } from './services/StorageService';
32
+ export { type IStorageService, type StorageOptions, StorageService, createStorageService, applyPostfixToStorageService, } from './services/StorageService';
33
33
  export { cloneObjectWithOverrides } from './cloneObjectWithOverrides';
34
34
  export { promiseWithTimeout } from './promiseWithTimeout';
35
+ export { isInIframe } from './isInIframe';
package/src/index.js CHANGED
@@ -72,7 +72,9 @@ export { hexToString } from './hexToString/hexToString.js';
72
72
  export { isHex } from './isHex/isHex.js';
73
73
  export { StorageService } from './services/StorageService/StorageService.js';
74
74
  export { createStorageService } from './services/StorageService/createStorageService/createStorageService.js';
75
+ export { applyPostfixToStorageService } from './services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.js';
75
76
  export { cloneObjectWithOverrides } from './cloneObjectWithOverrides/cloneObjectWithOverrides.js';
76
77
  export { promiseWithTimeout } from './promiseWithTimeout/promiseWithTimeout.js';
78
+ export { isInIframe } from './isInIframe/isInIframe.js';
77
79
 
78
80
  assertPackageVersion('@dynamic-labs/utils', version);
@@ -0,0 +1 @@
1
+ export { isInIframe } from './isInIframe';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isInIframe = () => window.self !== window.top;
7
+
8
+ exports.isInIframe = isInIframe;
@@ -0,0 +1 @@
1
+ export declare const isInIframe: () => boolean;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isInIframe = () => window.self !== window.top;
3
+
4
+ export { isInIframe };
@@ -15,7 +15,6 @@ export type GetOauthCodeProps = {
15
15
  * The preferred strategy to use for the OAuth2 flow.
16
16
  */
17
17
  strategy: 'popup' | 'redirect';
18
- sessionTimeout: number;
19
18
  /**
20
19
  * Overrides the default redirectUrl coming from the DynamicContextProvider
21
20
  */
@@ -46,6 +46,14 @@ const createWindowOauth2Service = () => ({
46
46
  clearInterval(authWindowInterval);
47
47
  const providersWaitingOauthMessage = {};
48
48
  const authWindow = window.open('', '_blank', 'width=500,height=600');
49
+ if (authWindow === null || typeof authWindow === 'undefined') {
50
+ // Pop-ups are blocked
51
+ typedReject({
52
+ code: types.SocialOAuthErrorCode.OAUTH_WINDOW_BLOCKED,
53
+ message: 'Please allow popups and try again.',
54
+ });
55
+ return;
56
+ }
49
57
  const clearListeners = () => {
50
58
  window.removeEventListener('message', handleWindowMessage);
51
59
  providersWaitingOauthMessage[provider] = false;
@@ -42,6 +42,14 @@ const createWindowOauth2Service = () => ({
42
42
  clearInterval(authWindowInterval);
43
43
  const providersWaitingOauthMessage = {};
44
44
  const authWindow = window.open('', '_blank', 'width=500,height=600');
45
+ if (authWindow === null || typeof authWindow === 'undefined') {
46
+ // Pop-ups are blocked
47
+ typedReject({
48
+ code: SocialOAuthErrorCode.OAUTH_WINDOW_BLOCKED,
49
+ message: 'Please allow popups and try again.',
50
+ });
51
+ return;
52
+ }
45
53
  const clearListeners = () => {
46
54
  window.removeEventListener('message', handleWindowMessage);
47
55
  providersWaitingOauthMessage[provider] = false;
@@ -20,7 +20,7 @@ export declare class StorageService {
20
20
  static registerSourceStorage(source: StorageSource, implementation: IStorageService): void;
21
21
  static getSourceStorage(source: StorageSource): IStorageService | undefined;
22
22
  static resolveStorage(options?: StorageOptions): IStorageService;
23
- static getItem<T = string>(key: string, options?: StorageOptions): T | undefined;
23
+ static getItem<T = string>(key: string, options?: StorageOptions): T | null;
24
24
  static setItem<T>(key: string, value: T, options?: StorageOptions): void;
25
25
  static removeItem(key: string, options?: StorageOptions): void;
26
26
  static getKeys(options?: StorageOptions): string[];
@@ -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[];