@dynamic-labs-wallet/browser-wallet-client 1.1.70 → 1.1.71

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/index.cjs CHANGED
@@ -2402,6 +2402,7 @@ const isTransactionIntent = (intent)=>intent.operation.kind === 'transaction';
2402
2402
  const isSvmTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'SVM';
2403
2403
  const isEvmTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'EVM';
2404
2404
  const isTronTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'TRON';
2405
+ const isBtcTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'BTC';
2405
2406
  const assertMatches = (matches, message)=>{
2406
2407
  if (!matches) throw new Error(message);
2407
2408
  };
@@ -2437,6 +2438,16 @@ const assertTronTransactionMatchesRequest = (intent, request)=>{
2437
2438
  // the approved operation, so the contract fields are not re-derived here.
2438
2439
  assertMatches(request.chainName === 'TRON' && Boolean(request.chainId) && operation.chainId === toDecimalChainId(request.chainId) && request.refreshLimits === undefined && !request.refreshableNonce && intent.limits === undefined && hasLifetime(intent.lifetime, 'expiration') && operation.from === request.accountAddress, 'Prepared TRON transaction signing intent is malformed');
2439
2440
  };
2441
+ const BTC_HASH = /^[0-9a-f]{64}$/;
2442
+ const DECIMAL = /^(0|[1-9]\d*)$/;
2443
+ const HEX_BYTES = /^(?:[0-9a-f]{2})*$/;
2444
+ const hasValidBtcOperationFields = ({ operation })=>BTC_HASH.test(operation.txid) && DECIMAL.test(operation.feeSats) && Array.isArray(operation.outputs) && operation.outputs.length > 0 && operation.outputs.every(({ script, valueSats })=>HEX_BYTES.test(script) && DECIMAL.test(valueSats)) && Array.isArray(operation.sighashes) && operation.sighashes.length > 0 && operation.sighashes.every((sighash)=>BTC_HASH.test(sighash));
2445
+ const assertBtcTransactionMatchesRequest = (intent, request)=>{
2446
+ var _request_bitcoinConfig;
2447
+ // Wallet-service re-derives the transaction from the PSBT it signs and rejects any
2448
+ // mismatch with the approved operation, so the outputs and hashes are not re-derived here.
2449
+ assertMatches(request.chainName === 'BTC' && intent.operation.chainId === (((_request_bitcoinConfig = request.bitcoinConfig) == null ? void 0 : _request_bitcoinConfig.network) === 'testnet' ? '2' : '1') && request.refreshLimits === undefined && !request.refreshableNonce && intent.limits === undefined && hasLifetime(intent.lifetime, undefined) && hasValidBtcOperationFields(intent), 'Prepared BTC transaction signing intent is malformed');
2450
+ };
2440
2451
  const assertEvmTransactionMatchesRequest = (intent, request)=>{
2441
2452
  if (request.chainName !== 'EVM') throw new Error('Unsupported transaction signing intent');
2442
2453
  const { operation, limits } = intent;
@@ -2457,6 +2468,7 @@ const assertTransactionIntentMatchesRequest = (intent, request)=>{
2457
2468
  }
2458
2469
  if (isSvmTransactionIntent(intent)) return assertSvmTransactionMatchesRequest(intent, request);
2459
2470
  if (isTronTransactionIntent(intent)) return assertTronTransactionMatchesRequest(intent, request);
2471
+ if (isBtcTransactionIntent(intent)) return assertBtcTransactionMatchesRequest(intent, request);
2460
2472
  if (!isEvmTransactionIntent(intent)) {
2461
2473
  throw new Error('Unsupported transaction signing intent');
2462
2474
  }
package/index.esm.js CHANGED
@@ -2401,6 +2401,7 @@ const isTransactionIntent = (intent)=>intent.operation.kind === 'transaction';
2401
2401
  const isSvmTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'SVM';
2402
2402
  const isEvmTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'EVM';
2403
2403
  const isTronTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'TRON';
2404
+ const isBtcTransactionIntent = (intent)=>intent.operation.kind === 'transaction' && intent.operation.chainName === 'BTC';
2404
2405
  const assertMatches = (matches, message)=>{
2405
2406
  if (!matches) throw new Error(message);
2406
2407
  };
@@ -2436,6 +2437,16 @@ const assertTronTransactionMatchesRequest = (intent, request)=>{
2436
2437
  // the approved operation, so the contract fields are not re-derived here.
2437
2438
  assertMatches(request.chainName === 'TRON' && Boolean(request.chainId) && operation.chainId === toDecimalChainId(request.chainId) && request.refreshLimits === undefined && !request.refreshableNonce && intent.limits === undefined && hasLifetime(intent.lifetime, 'expiration') && operation.from === request.accountAddress, 'Prepared TRON transaction signing intent is malformed');
2438
2439
  };
2440
+ const BTC_HASH = /^[0-9a-f]{64}$/;
2441
+ const DECIMAL = /^(0|[1-9]\d*)$/;
2442
+ const HEX_BYTES = /^(?:[0-9a-f]{2})*$/;
2443
+ const hasValidBtcOperationFields = ({ operation })=>BTC_HASH.test(operation.txid) && DECIMAL.test(operation.feeSats) && Array.isArray(operation.outputs) && operation.outputs.length > 0 && operation.outputs.every(({ script, valueSats })=>HEX_BYTES.test(script) && DECIMAL.test(valueSats)) && Array.isArray(operation.sighashes) && operation.sighashes.length > 0 && operation.sighashes.every((sighash)=>BTC_HASH.test(sighash));
2444
+ const assertBtcTransactionMatchesRequest = (intent, request)=>{
2445
+ var _request_bitcoinConfig;
2446
+ // Wallet-service re-derives the transaction from the PSBT it signs and rejects any
2447
+ // mismatch with the approved operation, so the outputs and hashes are not re-derived here.
2448
+ assertMatches(request.chainName === 'BTC' && intent.operation.chainId === (((_request_bitcoinConfig = request.bitcoinConfig) == null ? void 0 : _request_bitcoinConfig.network) === 'testnet' ? '2' : '1') && request.refreshLimits === undefined && !request.refreshableNonce && intent.limits === undefined && hasLifetime(intent.lifetime, undefined) && hasValidBtcOperationFields(intent), 'Prepared BTC transaction signing intent is malformed');
2449
+ };
2439
2450
  const assertEvmTransactionMatchesRequest = (intent, request)=>{
2440
2451
  if (request.chainName !== 'EVM') throw new Error('Unsupported transaction signing intent');
2441
2452
  const { operation, limits } = intent;
@@ -2456,6 +2467,7 @@ const assertTransactionIntentMatchesRequest = (intent, request)=>{
2456
2467
  }
2457
2468
  if (isSvmTransactionIntent(intent)) return assertSvmTransactionMatchesRequest(intent, request);
2458
2469
  if (isTronTransactionIntent(intent)) return assertTronTransactionMatchesRequest(intent, request);
2470
+ if (isBtcTransactionIntent(intent)) return assertBtcTransactionMatchesRequest(intent, request);
2459
2471
  if (!isEvmTransactionIntent(intent)) {
2460
2472
  throw new Error('Unsupported transaction signing intent');
2461
2473
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/browser-wallet-client",
3
- "version": "1.1.70",
3
+ "version": "1.1.71",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/core": "1.1.70",
7
+ "@dynamic-labs-wallet/core": "1.1.71",
8
8
  "@dynamic-labs/logger": "^5.9.4",
9
9
  "@dynamic-labs/message-transport": "^5.9.1"
10
10
  },
@@ -1 +1 @@
1
- {"version":3,"file":"assertPreparedSigningIntentMatchesRequest.d.ts","sourceRoot":"","sources":["../../packages/src/assertPreparedSigningIntentMatchesRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,2BAA2B,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAiNhH,eAAO,MAAM,yCAAyC,0CAInD;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,2BAA2B,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,KAAG,IAQH,CAAC"}
1
+ {"version":3,"file":"assertPreparedSigningIntentMatchesRequest.d.ts","sourceRoot":"","sources":["../../packages/src/assertPreparedSigningIntentMatchesRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,2BAA2B,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmPhH,eAAO,MAAM,yCAAyC,0CAInD;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,2BAA2B,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,KAAG,IAQH,CAAC"}