@dynamic-labs/bitcoin 5.3.2 → 5.4.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,4 +1,26 @@
1
1
 
2
+ ## [5.4.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.2...v5.4.0) (2026-08-25)
3
+
4
+
5
+ ### Features
6
+
7
+ * **aleo:** wire up signMessage on the WaaS Aleo connector ([#12235](https://github.com/dynamic-labs/dynamic-auth/issues/12235)) ([e56cbf5](https://github.com/dynamic-labs/dynamic-auth/commit/e56cbf5546bdcc21ce916dece43ae36dcea9b808))
8
+ * **waas:** thread isRawScalarImport through importPrivateKey for ed25519 chains ([#12220](https://github.com/dynamic-labs/dynamic-auth/issues/12220)) ([ced9efa](https://github.com/dynamic-labs/dynamic-auth/commit/ced9efac5fa5a4a1280383419f56fe22733722cd))
9
+ * **webview:** add policies message contract and controller ([#12248](https://github.com/dynamic-labs/dynamic-auth/issues/12248)) ([8557c1e](https://github.com/dynamic-labs/dynamic-auth/commit/8557c1ed3861e12f1f06b2bb610184813b577daa))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **bitcoin:** pass the wallet's address type when signing ([#12265](https://github.com/dynamic-labs/dynamic-auth/issues/12265)) ([b8a8eab](https://github.com/dynamic-labs/dynamic-auth/commit/b8a8eab7e4cc294cc307fb10ea6814e76111a274))
15
+ * remediate high-severity tar vulnerability and prune a dead override ([#12268](https://github.com/dynamic-labs/dynamic-auth/issues/12268)) ([6b1b343](https://github.com/dynamic-labs/dynamic-auth/commit/6b1b343e7947e8da30012446677e342ae9bfe14a))
16
+ * **waas-svm:** fix retry-classification and environmentId gaps in [#12240](https://github.com/dynamic-labs/dynamic-auth/issues/12240) ([#12247](https://github.com/dynamic-labs/dynamic-auth/issues/12247)) ([e79cecc](https://github.com/dynamic-labs/dynamic-auth/commit/e79ceccd424c48c3a7f45fdd6ea288c269ac0171))
17
+ * **wallet-connect:** reopen WalletConnect IndexedDB when the browser closes the connection ([#12262](https://github.com/dynamic-labs/dynamic-auth/issues/12262)) ([1a20dde](https://github.com/dynamic-labs/dynamic-auth/commit/1a20ddeaeec590ae3390c9e47ef3c14738379b83))
18
+
19
+
20
+ ### Performance Improvements
21
+
22
+ * **ethereum-gasless-core:** parallel 7702 auth signing and long-poll sponsored-tx status ([#12225](https://github.com/dynamic-labs/dynamic-auth/issues/12225)) ([53ca916](https://github.com/dynamic-labs/dynamic-auth/commit/53ca91668f8dd839c52d55a0e5d7bb5257f7f415))
23
+
2
24
  ### [5.3.2](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.1...v5.3.2) (2026-08-19)
3
25
 
4
26
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "5.3.2";
6
+ var version = "5.4.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "5.3.2";
2
+ var version = "5.4.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/bitcoin",
3
- "version": "5.3.2",
3
+ "version": "5.4.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",
@@ -29,13 +29,13 @@
29
29
  "ecpair": "2.1.0",
30
30
  "sats-connect": "4.2.1",
31
31
  "jsontokens": "4.0.1",
32
- "@dynamic-labs/assert-package-version": "5.3.2",
33
- "@dynamic-labs/logger": "5.3.2",
34
- "@dynamic-labs/types": "5.3.2",
35
- "@dynamic-labs/utils": "5.3.2",
36
- "@dynamic-labs/waas": "5.3.2",
37
- "@dynamic-labs/wallet-book": "5.3.2",
38
- "@dynamic-labs/wallet-connector-core": "5.3.2",
32
+ "@dynamic-labs/assert-package-version": "5.4.0",
33
+ "@dynamic-labs/logger": "5.4.0",
34
+ "@dynamic-labs/types": "5.4.0",
35
+ "@dynamic-labs/utils": "5.4.0",
36
+ "@dynamic-labs/waas": "5.4.0",
37
+ "@dynamic-labs/wallet-book": "5.4.0",
38
+ "@dynamic-labs/wallet-connector-core": "5.4.0",
39
39
  "eventemitter3": "5.0.1"
40
40
  },
41
41
  "peerDependencies": {}
@@ -136,6 +136,32 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
136
136
  : 'mainnet');
137
137
  });
138
138
  }
139
+ /**
140
+ * The address type the wallet's key was derived under, read back from the
141
+ * address itself.
142
+ *
143
+ * `bitcoinConfig.addressType` is the only thing that selects a BTC
144
+ * derivation path downstream (`getMPCChainConfig` throws without it), and a
145
+ * wallet created by an import carries no server-side derivation metadata to
146
+ * fall back on — so signing an imported wallet failed while a
147
+ * Dynamic-created one signed fine. The address already encodes the answer:
148
+ * witness v0 is P2WPKH (native segwit), v1 is P2TR (taproot), which are
149
+ * exactly the two types `importPrivateKey` accepts.
150
+ *
151
+ * Falls back to native segwit for an address that is not bech32 (a legacy
152
+ * P2PKH/P2SH encoding cannot come from this connector's own import or
153
+ * create paths) so a decode failure can never make signing impossible.
154
+ */
155
+ getAddressTypeForSigning(walletAddress) {
156
+ try {
157
+ const { version } = bitcoinjsLib.address.fromBech32(walletAddress);
158
+ return (version === 1 ? 'taproot' : 'native_segwit');
159
+ }
160
+ catch (error) {
161
+ this.logger.warn('Could not read the address type from the wallet address; assuming native segwit', { error, walletAddress });
162
+ return 'native_segwit';
163
+ }
164
+ }
139
165
  supportsNetworkSwitching() {
140
166
  return true;
141
167
  }
@@ -603,10 +629,14 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
603
629
  accountAddress: this.getWalletIdentityAddress(),
604
630
  });
605
631
  const messageString = typeof message === 'string' ? message : message.raw;
632
+ const walletIdentityAddress = this.getWalletIdentityAddress();
606
633
  return walletClient.signMessage({
607
- accountAddress: this.getWalletIdentityAddress(),
634
+ accountAddress: walletIdentityAddress,
608
635
  authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
609
- bitcoinConfig: { network: yield this.getBitcoinNetworkEnum() },
636
+ bitcoinConfig: {
637
+ addressType: this.getAddressTypeForSigning(walletIdentityAddress),
638
+ network: yield this.getBitcoinNetworkEnum(),
639
+ },
610
640
  context,
611
641
  elevatedAccessToken,
612
642
  message: messageString,
@@ -838,6 +868,7 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
838
868
  accountAddress: this.getWalletIdentityAddress(),
839
869
  authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
840
870
  bitcoinConfig: {
871
+ addressType: this.getAddressTypeForSigning(this.getWalletIdentityAddress()),
841
872
  network: yield this.getBitcoinNetworkEnum(),
842
873
  },
843
874
  elevatedAccessToken,
@@ -92,21 +92,20 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
92
92
  }): Promise<{
93
93
  shareSetId: string;
94
94
  }>;
95
- importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, }: {
95
+ importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, isRawScalarImport, }: {
96
96
  privateKey: string;
97
97
  thresholdSignatureScheme?: string | undefined;
98
98
  publicAddressCheck?: string | undefined;
99
99
  addressType?: string | undefined;
100
100
  legacyWalletId?: string | undefined;
101
101
  password?: string | undefined;
102
+ isRawScalarImport?: boolean | undefined;
102
103
  }): Promise<void>;
103
104
  migrateFromFireblocks({ deviceId, jwt, walletPassword, ncwStorage, expectedAddresses, coinTypes, password, }: {
104
105
  deviceId: string;
105
106
  jwt: string;
106
107
  walletPassword: string;
107
- ncwStorage: Record<string, string>; /**
108
- * Gets the current Bitcoin network id (1 mainnet, 2 testnet)
109
- */
108
+ ncwStorage: Record<string, string>;
110
109
  expectedAddresses: Record<string, string>;
111
110
  coinTypes?: Record<string, number> | undefined;
112
111
  password?: string | undefined;
@@ -203,7 +202,18 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
203
202
  generateTraceId(): string;
204
203
  buildErrorInstrumentContext(error: unknown): {
205
204
  errorCode: string | import("@dynamic-labs/utils").ErrorCode;
206
- errorMessage: string;
205
+ errorMessage: string; /**
206
+ * Wallet identity: keyshares/wallet records are keyed by the wallet's
207
+ * primary (mainnet) address. On testnet the active address is the same
208
+ * wallet's per-network encoding — WaaS lookups (password, signing) must use
209
+ * the primary address (the same key signs both encodings).
210
+ *
211
+ * Resolved from the credential that owns the active address, so a user with
212
+ * several Bitcoin wallets gets the identity of the wallet being spent from.
213
+ * Never falls back to another wallet's address: a substituted key produces a
214
+ * signature that looks valid locally and is rejected by the network, so the
215
+ * failure has to surface here instead.
216
+ */
207
217
  errorType: string | undefined;
208
218
  } | {
209
219
  errorCode: string;
@@ -289,6 +299,23 @@ export declare class DynamicWaasBitcoinConnector extends DynamicWaasBitcoinConne
289
299
  * the active address automatically.
290
300
  */
291
301
  private getBitcoinNetworkEnum;
302
+ /**
303
+ * The address type the wallet's key was derived under, read back from the
304
+ * address itself.
305
+ *
306
+ * `bitcoinConfig.addressType` is the only thing that selects a BTC
307
+ * derivation path downstream (`getMPCChainConfig` throws without it), and a
308
+ * wallet created by an import carries no server-side derivation metadata to
309
+ * fall back on — so signing an imported wallet failed while a
310
+ * Dynamic-created one signed fine. The address already encodes the answer:
311
+ * witness v0 is P2WPKH (native segwit), v1 is P2TR (taproot), which are
312
+ * exactly the two types `importPrivateKey` accepts.
313
+ *
314
+ * Falls back to native segwit for an address that is not bech32 (a legacy
315
+ * P2PKH/P2SH encoding cannot come from this connector's own import or
316
+ * create paths) so a decode failure can never make signing impossible.
317
+ */
318
+ private getAddressTypeForSigning;
292
319
  supportsNetworkSwitching(): boolean;
293
320
  /**
294
321
  * Testnet when the testnet network (id 2) is selected — drives the widget's
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
- import { networks, Psbt } from 'bitcoinjs-lib';
3
+ import { address, networks, Psbt } from 'bitcoinjs-lib';
4
4
  import { Logger } from '@dynamic-labs/logger';
5
5
  import { MFAAction, TokenScope } from '@dynamic-labs/sdk-api-core';
6
6
  import { DynamicError } from '@dynamic-labs/utils';
@@ -132,6 +132,32 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
132
132
  : 'mainnet');
133
133
  });
134
134
  }
135
+ /**
136
+ * The address type the wallet's key was derived under, read back from the
137
+ * address itself.
138
+ *
139
+ * `bitcoinConfig.addressType` is the only thing that selects a BTC
140
+ * derivation path downstream (`getMPCChainConfig` throws without it), and a
141
+ * wallet created by an import carries no server-side derivation metadata to
142
+ * fall back on — so signing an imported wallet failed while a
143
+ * Dynamic-created one signed fine. The address already encodes the answer:
144
+ * witness v0 is P2WPKH (native segwit), v1 is P2TR (taproot), which are
145
+ * exactly the two types `importPrivateKey` accepts.
146
+ *
147
+ * Falls back to native segwit for an address that is not bech32 (a legacy
148
+ * P2PKH/P2SH encoding cannot come from this connector's own import or
149
+ * create paths) so a decode failure can never make signing impossible.
150
+ */
151
+ getAddressTypeForSigning(walletAddress) {
152
+ try {
153
+ const { version } = address.fromBech32(walletAddress);
154
+ return (version === 1 ? 'taproot' : 'native_segwit');
155
+ }
156
+ catch (error) {
157
+ this.logger.warn('Could not read the address type from the wallet address; assuming native segwit', { error, walletAddress });
158
+ return 'native_segwit';
159
+ }
160
+ }
135
161
  supportsNetworkSwitching() {
136
162
  return true;
137
163
  }
@@ -599,10 +625,14 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
599
625
  accountAddress: this.getWalletIdentityAddress(),
600
626
  });
601
627
  const messageString = typeof message === 'string' ? message : message.raw;
628
+ const walletIdentityAddress = this.getWalletIdentityAddress();
602
629
  return walletClient.signMessage({
603
- accountAddress: this.getWalletIdentityAddress(),
630
+ accountAddress: walletIdentityAddress,
604
631
  authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
605
- bitcoinConfig: { network: yield this.getBitcoinNetworkEnum() },
632
+ bitcoinConfig: {
633
+ addressType: this.getAddressTypeForSigning(walletIdentityAddress),
634
+ network: yield this.getBitcoinNetworkEnum(),
635
+ },
606
636
  context,
607
637
  elevatedAccessToken,
608
638
  message: messageString,
@@ -834,6 +864,7 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
834
864
  accountAddress: this.getWalletIdentityAddress(),
835
865
  authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
836
866
  bitcoinConfig: {
867
+ addressType: this.getAddressTypeForSigning(this.getWalletIdentityAddress()),
837
868
  network: yield this.getBitcoinNetworkEnum(),
838
869
  },
839
870
  elevatedAccessToken,