@dynamic-labs/utils 4.32.1-preview.0 → 4.33.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,10 +1,31 @@
1
1
 
2
- ### [4.32.1-preview.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.32.0...v4.32.1-preview.0) (2025-09-19)
2
+ ## [4.33.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.32.1...v4.33.0) (2025-09-26)
3
+
4
+
5
+ ### Features
6
+
7
+ * add support for signAndExecuteTransactionBlock and signTransactionBlock legacy sui features ([#9574](https://github.com/dynamic-labs/dynamic-auth/issues/9574)) ([316481f](https://github.com/dynamic-labs/dynamic-auth/commit/316481f9255ccc8873d267e85932df3b9d58184b))
8
+ * add viem account for waas wallets ([#9518](https://github.com/dynamic-labs/dynamic-auth/issues/9518)) ([39b6314](https://github.com/dynamic-labs/dynamic-auth/commit/39b631489a5fc38bf8077a91f7dd36d517e42512))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * unable to use backup codes to delete totp method on dynamics ui ([#9575](https://github.com/dynamic-labs/dynamic-auth/issues/9575)) ([db55161](https://github.com/dynamic-labs/dynamic-auth/commit/db5516191103ba00f3d993db28ec0df630e066b0))
14
+
15
+ ### [4.32.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.32.0...v4.32.1) (2025-09-25)
16
+
17
+
18
+ ### Features
19
+
20
+ * allow connecting multiple WC wallets ([#9493](https://github.com/dynamic-labs/dynamic-auth/issues/9493)) ([350c53c](https://github.com/dynamic-labs/dynamic-auth/commit/350c53cfc2198a565e9a324d9d65c3e57883d772))
21
+ * always use redirect inside MM IAB ([#9535](https://github.com/dynamic-labs/dynamic-auth/issues/9535)) ([8aca796](https://github.com/dynamic-labs/dynamic-auth/commit/8aca7968dfa0ef0f3caee043b415f9f76187112e))
3
22
 
4
23
 
5
24
  ### Bug Fixes
6
25
 
7
26
  * correct naming ([#9513](https://github.com/dynamic-labs/dynamic-auth/issues/9513)) ([5b4e31b](https://github.com/dynamic-labs/dynamic-auth/commit/5b4e31b9bbf2401d377201a4cd12edf79eaef75f))
27
+ * correct Safe Wallet App Store ID to prevent misdirect ([#9531](https://github.com/dynamic-labs/dynamic-auth/issues/9531)) ([b58adc5](https://github.com/dynamic-labs/dynamic-auth/commit/b58adc54de8018bf25011b205b94977da9676c2d))
28
+ * prevent social login popup in headless scenarios ([#9541](https://github.com/dynamic-labs/dynamic-auth/issues/9541)) ([a91c0b0](https://github.com/dynamic-labs/dynamic-auth/commit/a91c0b0d1d09210fa149cae80abab6978f4ae998))
8
29
 
9
30
  ## [4.32.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.31.4...v4.32.0) (2025-09-17)
10
31
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.32.1-preview.0";
6
+ var version = "4.33.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.32.1-preview.0";
2
+ var version = "4.33.0";
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.32.1-preview.0",
3
+ "version": "4.33.0",
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.762",
22
22
  "tldts": "6.0.16",
23
- "@dynamic-labs/assert-package-version": "4.32.1-preview.0",
24
- "@dynamic-labs/logger": "4.32.1-preview.0",
25
- "@dynamic-labs/types": "4.32.1-preview.0",
23
+ "@dynamic-labs/assert-package-version": "4.33.0",
24
+ "@dynamic-labs/logger": "4.33.0",
25
+ "@dynamic-labs/types": "4.33.0",
26
26
  "buffer": "6.0.3",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
@@ -4,6 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var cryptoAvailability = require('../cryptoAvailability/cryptoAvailability.cjs');
7
8
 
8
9
  /**
9
10
  * Converts a hexadecimal string representation of a public key into a CryptoKey object
@@ -11,9 +12,11 @@ var _tslib = require('../../../_virtual/_tslib.cjs');
11
12
  * @param hex - The hexadecimal string representation of the public key
12
13
  * @returns A Promise that resolves to a CryptoKey object suitable for ECDH operations
13
14
  * @throws Error if the hex string length is invalid or doesn't represent a valid public key
15
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
14
16
  */
15
17
  const convertPublicKeyHexToCryptoKey = (hex) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
16
18
  var _a, _b;
19
+ cryptoAvailability.assertCryptoSubtleAvailable();
17
20
  // Validate hex string length (65 bytes = 130 hex characters)
18
21
  if (hex.length !== 130) {
19
22
  throw new Error('Invalid public key length. Expected 130 hex characters.');
@@ -4,5 +4,6 @@
4
4
  * @param hex - The hexadecimal string representation of the public key
5
5
  * @returns A Promise that resolves to a CryptoKey object suitable for ECDH operations
6
6
  * @throws Error if the hex string length is invalid or doesn't represent a valid public key
7
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
7
8
  */
8
9
  export declare const convertPublicKeyHexToCryptoKey: (hex: string) => Promise<CryptoKey>;
@@ -1,5 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { assertCryptoSubtleAvailable } from '../cryptoAvailability/cryptoAvailability.js';
3
4
 
4
5
  /**
5
6
  * Converts a hexadecimal string representation of a public key into a CryptoKey object
@@ -7,9 +8,11 @@ import { __awaiter } from '../../../_virtual/_tslib.js';
7
8
  * @param hex - The hexadecimal string representation of the public key
8
9
  * @returns A Promise that resolves to a CryptoKey object suitable for ECDH operations
9
10
  * @throws Error if the hex string length is invalid or doesn't represent a valid public key
11
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
10
12
  */
11
13
  const convertPublicKeyHexToCryptoKey = (hex) => __awaiter(void 0, void 0, void 0, function* () {
12
14
  var _a, _b;
15
+ assertCryptoSubtleAvailable();
13
16
  // Validate hex string length (65 bytes = 130 hex characters)
14
17
  if (hex.length !== 130) {
15
18
  throw new Error('Invalid public key length. Expected 130 hex characters.');
@@ -4,6 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var cryptoAvailability = require('../cryptoAvailability/cryptoAvailability.cjs');
7
8
 
8
9
  /**
9
10
  * Generates an ECDH key pair for cryptographic operations.
@@ -12,8 +13,10 @@ var _tslib = require('../../../_virtual/_tslib.cjs');
12
13
  * @returns {Promise<{publicKey: CryptoKey, privateKey: CryptoKey}>} A promise that resolves to an object containing:
13
14
  * - publicKey: The generated public key
14
15
  * - privateKey: The generated private key
16
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
15
17
  */
16
18
  const createKeyPair = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
19
+ cryptoAvailability.assertCryptoSubtleAvailable();
17
20
  const keyPair = yield crypto.subtle.generateKey({
18
21
  name: 'ECDH',
19
22
  namedCurve: 'P-256',
@@ -5,5 +5,6 @@
5
5
  * @returns {Promise<{publicKey: CryptoKey, privateKey: CryptoKey}>} A promise that resolves to an object containing:
6
6
  * - publicKey: The generated public key
7
7
  * - privateKey: The generated private key
8
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
8
9
  */
9
10
  export declare const createKeyPair: () => Promise<CryptoKeyPair>;
@@ -1,5 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { assertCryptoSubtleAvailable } from '../cryptoAvailability/cryptoAvailability.js';
3
4
 
4
5
  /**
5
6
  * Generates an ECDH key pair for cryptographic operations.
@@ -8,8 +9,10 @@ import { __awaiter } from '../../../_virtual/_tslib.js';
8
9
  * @returns {Promise<{publicKey: CryptoKey, privateKey: CryptoKey}>} A promise that resolves to an object containing:
9
10
  * - publicKey: The generated public key
10
11
  * - privateKey: The generated private key
12
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
11
13
  */
12
14
  const createKeyPair = () => __awaiter(void 0, void 0, void 0, function* () {
15
+ assertCryptoSubtleAvailable();
13
16
  const keyPair = yield crypto.subtle.generateKey({
14
17
  name: 'ECDH',
15
18
  namedCurve: 'P-256',
@@ -0,0 +1,52 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Checks if the Web Crypto API (crypto.subtle) is available in the current environment.
8
+ *
9
+ * The Web Crypto API is only available in secure contexts:
10
+ * - HTTPS environments
11
+ * - localhost (http://localhost or http://127.0.0.1)
12
+ * - file:// protocol
13
+ *
14
+ * @returns {boolean} True if crypto.subtle is available, false otherwise
15
+ */
16
+ const isCryptoSubtleAvailable = () => typeof crypto !== 'undefined' &&
17
+ typeof crypto.subtle !== 'undefined' &&
18
+ crypto.subtle !== null;
19
+ /**
20
+ * Throws a descriptive error if crypto.subtle is not available.
21
+ * Use this at the beginning of functions that require crypto.subtle.
22
+ *
23
+ * @throws {Error} If crypto.subtle is not available
24
+ */
25
+ const assertCryptoSubtleAvailable = () => {
26
+ if (!isCryptoSubtleAvailable()) {
27
+ throw new Error('Web Crypto API (crypto.subtle) is not available. ' +
28
+ 'This functionality requires a secure context. ' +
29
+ 'Please ensure you are using HTTPS or localhost for development. ' +
30
+ 'For testing on external devices, consider using ngrok to create an HTTPS tunnel. ' +
31
+ 'See: https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API#secure_contexts');
32
+ }
33
+ };
34
+ /**
35
+ * Error class for crypto-related failures with better context
36
+ */
37
+ class CryptoNotAvailableError extends Error {
38
+ constructor(operation) {
39
+ var _a, _b;
40
+ super(`Cannot perform ${operation}: Web Crypto API (crypto.subtle) is not available. ` +
41
+ 'This functionality requires a secure context (HTTPS or localhost). ' +
42
+ 'Current protocol: ' +
43
+ (typeof window !== 'undefined'
44
+ ? (_b = (_a = window.location) === null || _a === void 0 ? void 0 : _a.protocol) !== null && _b !== void 0 ? _b : 'unknown'
45
+ : 'unknown'));
46
+ this.name = 'CryptoNotAvailableError';
47
+ }
48
+ }
49
+
50
+ exports.CryptoNotAvailableError = CryptoNotAvailableError;
51
+ exports.assertCryptoSubtleAvailable = assertCryptoSubtleAvailable;
52
+ exports.isCryptoSubtleAvailable = isCryptoSubtleAvailable;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Checks if the Web Crypto API (crypto.subtle) is available in the current environment.
3
+ *
4
+ * The Web Crypto API is only available in secure contexts:
5
+ * - HTTPS environments
6
+ * - localhost (http://localhost or http://127.0.0.1)
7
+ * - file:// protocol
8
+ *
9
+ * @returns {boolean} True if crypto.subtle is available, false otherwise
10
+ */
11
+ export declare const isCryptoSubtleAvailable: () => boolean;
12
+ /**
13
+ * Throws a descriptive error if crypto.subtle is not available.
14
+ * Use this at the beginning of functions that require crypto.subtle.
15
+ *
16
+ * @throws {Error} If crypto.subtle is not available
17
+ */
18
+ export declare const assertCryptoSubtleAvailable: () => void;
19
+ /**
20
+ * Error class for crypto-related failures with better context
21
+ */
22
+ export declare class CryptoNotAvailableError extends Error {
23
+ constructor(operation: string);
24
+ }
@@ -0,0 +1,46 @@
1
+ 'use client'
2
+ /**
3
+ * Checks if the Web Crypto API (crypto.subtle) is available in the current environment.
4
+ *
5
+ * The Web Crypto API is only available in secure contexts:
6
+ * - HTTPS environments
7
+ * - localhost (http://localhost or http://127.0.0.1)
8
+ * - file:// protocol
9
+ *
10
+ * @returns {boolean} True if crypto.subtle is available, false otherwise
11
+ */
12
+ const isCryptoSubtleAvailable = () => typeof crypto !== 'undefined' &&
13
+ typeof crypto.subtle !== 'undefined' &&
14
+ crypto.subtle !== null;
15
+ /**
16
+ * Throws a descriptive error if crypto.subtle is not available.
17
+ * Use this at the beginning of functions that require crypto.subtle.
18
+ *
19
+ * @throws {Error} If crypto.subtle is not available
20
+ */
21
+ const assertCryptoSubtleAvailable = () => {
22
+ if (!isCryptoSubtleAvailable()) {
23
+ throw new Error('Web Crypto API (crypto.subtle) is not available. ' +
24
+ 'This functionality requires a secure context. ' +
25
+ 'Please ensure you are using HTTPS or localhost for development. ' +
26
+ 'For testing on external devices, consider using ngrok to create an HTTPS tunnel. ' +
27
+ 'See: https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API#secure_contexts');
28
+ }
29
+ };
30
+ /**
31
+ * Error class for crypto-related failures with better context
32
+ */
33
+ class CryptoNotAvailableError extends Error {
34
+ constructor(operation) {
35
+ var _a, _b;
36
+ super(`Cannot perform ${operation}: Web Crypto API (crypto.subtle) is not available. ` +
37
+ 'This functionality requires a secure context (HTTPS or localhost). ' +
38
+ 'Current protocol: ' +
39
+ (typeof window !== 'undefined'
40
+ ? (_b = (_a = window.location) === null || _a === void 0 ? void 0 : _a.protocol) !== null && _b !== void 0 ? _b : 'unknown'
41
+ : 'unknown'));
42
+ this.name = 'CryptoNotAvailableError';
43
+ }
44
+ }
45
+
46
+ export { CryptoNotAvailableError, assertCryptoSubtleAvailable, isCryptoSubtleAvailable };
@@ -0,0 +1 @@
1
+ export { isCryptoSubtleAvailable, assertCryptoSubtleAvailable, CryptoNotAvailableError, } from './cryptoAvailability';
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
7
  var assertDefined = require('../../assertDefined/assertDefined.cjs');
8
+ var cryptoAvailability = require('../cryptoAvailability/cryptoAvailability.cjs');
8
9
 
9
10
  /**
10
11
  * Generates an HMAC (Hash-based Message Authentication Code) using SHA-256
@@ -12,6 +13,7 @@ var assertDefined = require('../../assertDefined/assertDefined.cjs');
12
13
  * @param keyData - The secret key used for generating the HMAC
13
14
  * @param data - The data to be authenticated
14
15
  * @returns A hexadecimal string representation of the HMAC
16
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
15
17
  *
16
18
  * @example
17
19
  * const hmac = await generateHMAC('secretKey', 'dataToAuthenticate');
@@ -20,6 +22,7 @@ var assertDefined = require('../../assertDefined/assertDefined.cjs');
20
22
  const generateHMAC = (keyData, data) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
21
23
  assertDefined.assertDefined(keyData, 'Key data must be a non-empty string');
22
24
  assertDefined.assertDefined(data, 'Data must be a non-empty string');
25
+ cryptoAvailability.assertCryptoSubtleAvailable();
23
26
  const textEncoder = new TextEncoder();
24
27
  const encodedKeyData = textEncoder.encode(keyData);
25
28
  const encodedData = textEncoder.encode(data);
@@ -4,6 +4,7 @@
4
4
  * @param keyData - The secret key used for generating the HMAC
5
5
  * @param data - The data to be authenticated
6
6
  * @returns A hexadecimal string representation of the HMAC
7
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
7
8
  *
8
9
  * @example
9
10
  * const hmac = await generateHMAC('secretKey', 'dataToAuthenticate');
@@ -1,6 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
3
  import { assertDefined } from '../../assertDefined/assertDefined.js';
4
+ import { assertCryptoSubtleAvailable } from '../cryptoAvailability/cryptoAvailability.js';
4
5
 
5
6
  /**
6
7
  * Generates an HMAC (Hash-based Message Authentication Code) using SHA-256
@@ -8,6 +9,7 @@ import { assertDefined } from '../../assertDefined/assertDefined.js';
8
9
  * @param keyData - The secret key used for generating the HMAC
9
10
  * @param data - The data to be authenticated
10
11
  * @returns A hexadecimal string representation of the HMAC
12
+ * @throws CryptoNotAvailableError if crypto.subtle is not available (requires secure context)
11
13
  *
12
14
  * @example
13
15
  * const hmac = await generateHMAC('secretKey', 'dataToAuthenticate');
@@ -16,6 +18,7 @@ import { assertDefined } from '../../assertDefined/assertDefined.js';
16
18
  const generateHMAC = (keyData, data) => __awaiter(void 0, void 0, void 0, function* () {
17
19
  assertDefined(keyData, 'Key data must be a non-empty string');
18
20
  assertDefined(data, 'Data must be a non-empty string');
21
+ assertCryptoSubtleAvailable();
19
22
  const textEncoder = new TextEncoder();
20
23
  const encodedKeyData = textEncoder.encode(keyData);
21
24
  const encodedData = textEncoder.encode(data);
@@ -6,3 +6,4 @@ export { decryptMessage } from './decryptMessage';
6
6
  export { encryptMessage, type EncryptedMessage } from './encryptMessage';
7
7
  export { generateHMAC } from './generateHMAC';
8
8
  export { isEncryptedMessage } from './isEncryptedMessage';
9
+ export { isCryptoSubtleAvailable, assertCryptoSubtleAvailable, CryptoNotAvailableError, } from './cryptoAvailability';
package/src/index.cjs CHANGED
@@ -82,6 +82,7 @@ var decryptMessage = require('./encryption/decryptMessage/decryptMessage.cjs');
82
82
  var encryptMessage = require('./encryption/encryptMessage/encryptMessage.cjs');
83
83
  var generateHMAC = require('./encryption/generateHMAC/generateHMAC.cjs');
84
84
  var isEncryptedMessage = require('./encryption/isEncryptedMessage/isEncryptedMessage.cjs');
85
+ var cryptoAvailability = require('./encryption/cryptoAvailability/cryptoAvailability.cjs');
85
86
  var uint8ArrayToBase64 = require('./uint8ArrayToBase64/uint8ArrayToBase64.cjs');
86
87
  var assertDefined = require('./assertDefined/assertDefined.cjs');
87
88
  var cloneObjectWithOverrides = require('./cloneObjectWithOverrides/cloneObjectWithOverrides.cjs');
@@ -208,6 +209,9 @@ exports.decryptMessage = decryptMessage.decryptMessage;
208
209
  exports.encryptMessage = encryptMessage.encryptMessage;
209
210
  exports.generateHMAC = generateHMAC.generateHMAC;
210
211
  exports.isEncryptedMessage = isEncryptedMessage.isEncryptedMessage;
212
+ exports.CryptoNotAvailableError = cryptoAvailability.CryptoNotAvailableError;
213
+ exports.assertCryptoSubtleAvailable = cryptoAvailability.assertCryptoSubtleAvailable;
214
+ exports.isCryptoSubtleAvailable = cryptoAvailability.isCryptoSubtleAvailable;
211
215
  exports.uint8ArrayFromBase64 = uint8ArrayToBase64.uint8ArrayFromBase64;
212
216
  exports.uint8ArrayToBase64 = uint8ArrayToBase64.uint8ArrayToBase64;
213
217
  exports.assertDefined = assertDefined.assertDefined;
package/src/index.js CHANGED
@@ -78,6 +78,7 @@ export { decryptMessage } from './encryption/decryptMessage/decryptMessage.js';
78
78
  export { encryptMessage } from './encryption/encryptMessage/encryptMessage.js';
79
79
  export { generateHMAC } from './encryption/generateHMAC/generateHMAC.js';
80
80
  export { isEncryptedMessage } from './encryption/isEncryptedMessage/isEncryptedMessage.js';
81
+ export { CryptoNotAvailableError, assertCryptoSubtleAvailable, isCryptoSubtleAvailable } from './encryption/cryptoAvailability/cryptoAvailability.js';
81
82
  export { uint8ArrayFromBase64, uint8ArrayToBase64 } from './uint8ArrayToBase64/uint8ArrayToBase64.js';
82
83
  export { assertDefined } from './assertDefined/assertDefined.js';
83
84
  export { cloneObjectWithOverrides } from './cloneObjectWithOverrides/cloneObjectWithOverrides.js';