@babylonlabs-io/ts-sdk 6.2.0 → 6.3.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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./verifyScriptPathSchnorrSignature-p3sVoWQi.cjs"),O=require("./secp256k1-DDHQ1_za.cjs"),o=require("./tbv/core/wasm/index.cjs"),R=require("./verifyKeyPathSchnorrSignature-B7Za6aa1.cjs"),E=require("./challengeAssert-DlzX_kjF.cjs"),y=require("./verifyPeginHashlockSpend-CisfqMuT.cjs"),r=require("./bitcoin-D-O2GjbC.cjs"),F=require("./abortSignals-msbmbqFe.cjs"),I=require("./signing-DvISftFk.cjs"),d=require("./validation-C6XTfZak.cjs"),N=require("./tbv/core/utils/eth/index.cjs"),_=require("./PeginManager-BNJUATq2.cjs"),P=require("./PayoutManager-PQqeqX41.cjs"),s=require("./tbv/core/clients/mempool/index.cjs"),l=require("./registration-records-CKc0OVuK.cjs"),C=require("./signer-set-reader-C8xSyTMb.cjs"),A=require("./pegin-registration-client-JtZkosZQ.cjs"),h=require("./types-Bt1FM6d8.cjs"),V=require("./ApplicationRegistry.abi-sMiTWmnL.cjs"),M=require("./BTCVaultRegistry.abi-C4bQi-H9.cjs"),u=require("./BTCVaultRegistryKeyEpochs.abi-CReWFJdu.cjs"),b=require("./ProtocolParams.abi-DzjpPHcl.cjs"),v=require("./VaultErrors.abi-BV0qeG6M.cjs"),D=require("./buildVaultContextInputForClaim-9XZaqIiw.cjs"),S=require("./deriveVaultRoot-C3uqnJto.cjs"),B=require("./parseFundingOutpoints-C_-PT9BT.cjs"),U=require("./shared/index.cjs"),f=require("./btcTxHash-CGb5BqFL.cjs"),c=require("./psbtInputFields-BrV_ZfL_.cjs"),i=require("./fundPeginTransaction-54-Rwb2k.cjs"),T=require("./reservation-D9ftyiwP.cjs"),m=require("./index-Dn7RlsKK.cjs"),a=require("./state-C4WoNCy1.cjs"),p=require("./primeVpAuth-Ch-ig2My.cjs"),t=require("./toRefundInputs-CzZujjq-.cjs"),e=require("./buildAndBroadcastReclaim-Blxt7B0K.cjs"),g=require("./peginState-B4t_PDgj.cjs");exports.PEGIN_DEPOSITOR_CLAIM_VOUT=n.PEGIN_DEPOSITOR_CLAIM_VOUT;exports.PsbtSubstitutionError=n.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=n.assertPsbtUnsignedTxMatches;exports.assertScriptPathSchnorrSignature=n.assertScriptPathSchnorrSignature;exports.buildPayoutPsbt=n.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=n.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=n.buildPrePeginPsbt;exports.computeNumLocalChallengers=n.computeNumLocalChallengers;exports.createPayoutScript=n.createPayoutScript;exports.deriveDepositorClaimDescriptor=n.deriveDepositorClaimDescriptor;exports.deriveDepositorClaimScriptPubKey=n.deriveDepositorClaimScriptPubKey;exports.extractPayoutSignature=n.extractPayoutSignature;exports.assertValidVaultCoreVersion=O.assertValidVaultCoreVersion;exports.attachFinalizedAssert=o.attachFinalizedAssert;exports.computeMinClaimValue=o.computeMinClaimValue;exports.computeMinPeginFee=o.computeMinPeginFee;exports.deriveVaultId=o.deriveVaultId;exports.expandAuthAnchor=o.expandAuthAnchor;exports.expandHashlockSecret=o.expandHashlockSecret;exports.expandWotsSeed=o.expandWotsSeed;exports.finalizePayout=o.finalizePayout;exports.finalizeWronglyChallenged=o.finalizeWronglyChallenged;exports.peginP2aAnchorOutput=o.peginP2aAnchorOutput;exports.pinPegoutProof=o.pinPegoutProof;exports.supportedTxGraphVersions=o.supportedTxGraphVersions;exports.validatePeginP2aAnchor=o.validatePeginP2aAnchor;exports.assertKeyPathSchnorrSignature=R.assertKeyPathSchnorrSignature;exports.assertReturnedKeyPathSignatures=R.assertReturnedKeyPathSignatures;exports.buildPeginInputPsbt=R.buildPeginInputPsbt;exports.extractPeginInputSignature=R.extractPeginInputSignature;exports.finalizePeginInputPsbt=R.finalizePeginInputPsbt;exports.buildChallengeAssertPsbt=E.buildChallengeAssertPsbt;exports.buildNoPayoutPsbt=E.buildNoPayoutPsbt;exports.buildReclaimPsbt=E.buildReclaimPsbt;exports.buildRefundPsbt=E.buildRefundPsbt;exports.estimateReclaimFeeSats=E.estimateReclaimFeeSats;exports.finalizeScriptPathWithSignatures=E.finalizeScriptPathWithSignatures;exports.reclaimVsize=E.reclaimVsize;exports.verifyPeginHashlockSpend=y.verifyPeginHashlockSpend;exports.canonicalizeBtcPubkey=r.canonicalizeBtcPubkey;exports.deriveBip86ScriptPubKeyHex=r.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=r.deriveNativeSegwitAddress;exports.deriveTaprootAddress=r.deriveTaprootAddress;exports.ensureHexPrefix=r.ensureHexPrefix;exports.formatSatoshisToBtc=r.formatSatoshisToBtc;exports.getNetwork=r.getNetwork;exports.getSortedXOnlyPubkeys=r.getSortedXOnlyPubkeys;exports.hexToUint8Array=r.hexToUint8Array;exports.isAddressFromPublicKey=r.isAddressFromPublicKey;exports.isValidHex=r.isValidHex;exports.processPublicKeyToXOnly=r.processPublicKeyToXOnly;exports.stripHexPrefix=r.stripHexPrefix;exports.toXOnly=r.toXOnly;exports.uint8ArrayToHex=r.uint8ArrayToHex;exports.validateWalletPubkey=r.validateWalletPubkey;exports.combineAbortSignals=F.combineAbortSignals;exports.createTaprootScriptPathSignOptions=I.createTaprootScriptPathSignOptions;exports.createTaprootScriptPathSignOptionsForInput=I.createTaprootScriptPathSignOptionsForInput;exports.BITCOIN_ADDRESS_RE=d.BITCOIN_ADDRESS_RE;exports.COMPRESSED_PUBKEY_HEX_LEN=d.COMPRESSED_PUBKEY_HEX_LEN;exports.HEX_RE=d.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=d.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=d.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=d.TXID_RE;exports.X_ONLY_PUBKEY_HEX_LEN=d.X_ONLY_PUBKEY_HEX_LEN;exports.waitForTransactionReceiptSmartAware=N.waitForTransactionReceiptSmartAware;exports.PeginManager=_.PeginManager;exports.buildDepositTerms=_.buildDepositTerms;exports.computeWotsBlockPublicKeysHash=_.computeWotsBlockPublicKeysHash;exports.deriveWotsBlocksFromSeed=_.deriveWotsBlocksFromSeed;exports.ensurePrePeginTermsApproval=_.ensurePrePeginTermsApproval;exports.PayoutManager=P.PayoutManager;exports.computeHashlock=P.computeHashlock;exports.forwardDepositApproval=P.forwardDepositApproval;exports.requireChangeAddress=P.requireChangeAddress;exports.supportsDepositApproval=P.supportsDepositApproval;exports.validateSecretAgainstHashlock=P.validateSecretAgainstHashlock;exports.MEMPOOL_API_URLS=s.MEMPOOL_API_URLS;exports.MempoolNotFoundError=s.MempoolNotFoundError;exports.getAddressTxs=s.getAddressTxs;exports.getAddressUtxos=s.getAddressUtxos;exports.getMempoolApiUrl=s.getMempoolApiUrl;exports.getNetworkFees=s.getNetworkFees;exports.getOutspend=s.getOutspend;exports.getTipHeight=s.getTipHeight;exports.getTxHex=s.getTxHex;exports.getTxInfo=s.getTxInfo;exports.getUtxoInfo=s.getUtxoInfo;exports.pushTx=s.pushTx;exports.RegistrationLogsUnavailableError=l.RegistrationLogsUnavailableError;exports.VaultClaimableByNotFoundError=l.VaultClaimableByNotFoundError;exports.assertOnChainBtcPubkey=l.assertOnChainBtcPubkey;exports.assertRegisteredPayoutScriptBounds=l.assertRegisteredPayoutScriptBounds;exports.derivePeginVaultId=l.derivePeginVaultId;exports.findRegistrationRecord=l.findRegistrationRecord;exports.isRegistrationLogsUnavailableError=l.isRegistrationLogsUnavailableError;exports.isVaultClaimableByNotFoundError=l.isVaultClaimableByNotFoundError;exports.registrationPrePeginTxHash=l.registrationPrePeginTxHash;exports.validateOffchainParams=l.validateOffchainParams;exports.validatePegInConfiguration=l.validatePegInConfiguration;exports.validateTBVProtocolParams=l.validateTBVProtocolParams;exports.ViemOperationKeyReader=C.ViemOperationKeyReader;exports.ViemUniversalChallengerReader=C.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=C.ViemVaultKeeperReader;exports.resolveProtocolAddresses=C.resolveProtocolAddresses;exports.COMMISSION_BPS_HEADROOM=A.COMMISSION_BPS_HEADROOM;exports.MAX_ACCEPTABLE_COMMISSION_BPS_CAP=A.MAX_ACCEPTABLE_COMMISSION_BPS_CAP;exports.ViemPeginRegistrationClient=A.ViemPeginRegistrationClient;exports.ViemVaultRegistryReader=A.ViemVaultRegistryReader;exports.capMaxAcceptableCommissionBps=A.capMaxAcceptableCommissionBps;exports.OnChainBtcVaultStatus=h.OnChainBtcVaultStatus;exports.ViemProtocolParamsReader=h.ViemProtocolParamsReader;exports.ApplicationRegistryABI=V.ApplicationRegistryABI;exports.BTCVaultRegistryABI=M.BTCVaultRegistryABI;exports.BTCVaultRegistryKeyEpochsABI=u.BTCVaultRegistryKeyEpochsABI;exports.CONTRACT_ERRORS=u.CONTRACT_ERRORS;exports.EMPTY_REVERT_MESSAGE=u.EMPTY_REVERT_MESSAGE;exports.PEGIN_FINGERPRINT_CHANGED_SELECTOR=u.PEGIN_FINGERPRINT_CHANGED_SELECTOR;exports.PeginFingerprintChangedError=u.PeginFingerprintChangedError;exports.extractErrorData=u.extractErrorData;exports.getContractErrorMessage=u.getContractErrorMessage;exports.handleContractError=u.handleContractError;exports.isKnownContractError=u.isKnownContractError;exports.isPeginFingerprintChangedError=u.isPeginFingerprintChangedError;exports.ProtocolParamsABI=b.ProtocolParamsABI;exports.VAULT_ERROR_ABI=v.VAULT_ERROR_ABI;exports.buildVaultContextInputForClaim=D.buildVaultContextInputForClaim;exports.VAULT_APP_NAME=S.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=S.buildFundingOutpointsCommitment;exports.buildVaultContext=S.buildVaultContext;exports.deriveVaultRoot=S.deriveVaultRoot;exports.forwardDeriveContextHash=S.forwardDeriveContextHash;exports.parseFundingOutpointsFromTx=B.parseFundingOutpointsFromTx;exports.BitcoinNetworks=U.BitcoinNetworks;exports.calculateBtcTxHash=f.calculateBtcTxHash;exports.BitcoinScriptType=c.BitcoinScriptType;exports.applyChangeOutputPolicy=c.applyChangeOutputPolicy;exports.computeChangeOutputFeeSats=c.computeChangeOutputFeeSats;exports.computeMaxDeposit=c.computeMaxDeposit;exports.computePeginBaseFeeSats=c.computePeginBaseFeeSats;exports.getDustThreshold=c.getDustThreshold;exports.getPsbtInputFields=c.getPsbtInputFields;exports.getScriptType=c.getScriptType;exports.selectUtxosForPegin=c.selectUtxosForPegin;exports.shouldAddChangeOutput=c.shouldAddChangeOutput;exports.BTC_DUST_SAT=i.BTC_DUST_SAT;exports.DUST_THRESHOLD=i.DUST_THRESHOLD;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=i.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=i.MAX_NON_LEGACY_OUTPUT_SIZE;exports.MAX_REASONABLE_PEGIN_VBYTES=i.MAX_REASONABLE_PEGIN_VBYTES;exports.P2TR_INPUT_SIZE=i.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=i.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=i.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=i.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=i.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=i.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=i.fundPeginTransaction;exports.parseUnfundedWasmTransaction=i.parseUnfundedWasmTransaction;exports.peginOutputCount=i.peginOutputCount;exports.rateBasedTxBufferFee=i.rateBasedTxBufferFee;exports.UtxoNotAvailableError=T.UtxoNotAvailableError;exports.assertUtxosAvailable=T.assertUtxosAvailable;exports.extractInputsFromTransaction=T.extractInputsFromTransaction;exports.findOverlappingPendingVaults=T.findOverlappingPendingVaults;exports.validateUtxosAvailable=T.validateUtxosAvailable;exports.VaultProviderRpcClient=m.VaultProviderRpcClient;exports.VpResponseValidationError=m.VpResponseValidationError;exports.batchPollByProvider=m.batchPollByProvider;exports.isUnrecognizedDaemonStatusError=m.isUnrecognizedDaemonStatusError;exports.validateRequestDepositorClaimerArtifactsResponse=m.validateRequestDepositorClaimerArtifactsResponse;exports.AUTH_REJECTED_RPC_CODE=a.AUTH_REJECTED_RPC_CODE;exports.ClaimerPegoutStatusValue=a.ClaimerPegoutStatusValue;exports.DaemonStatus=a.DaemonStatus;exports.JSON_RPC_ERROR_CODES=a.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=a.JsonRpcClient;exports.JsonRpcError=a.JsonRpcError;exports.POST_WOTS_STATUSES=a.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=a.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=a.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=a.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=a.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=a.VP_TRANSIENT_STATUSES;exports.isAuthRejectedError=a.isAuthRejectedError;exports.isPegoutTerminalStatus=a.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=a.isRecognizedPegoutStatus;exports.ServerIdentityError=p.ServerIdentityError;exports.VpTokenRegistry=p.VpTokenRegistry;exports.createAuthenticatedVpClient=p.createAuthenticatedVpClient;exports.primeVpTokenRegistry=p.primeVpTokenRegistry;exports.verifyServerIdentity=p.verifyServerIdentity;exports.vpTokenRegistry=p.vpTokenRegistry;exports.DEPOSIT_TERMS_REJECTED_ERROR_NAME=t.DEPOSIT_TERMS_REJECTED_ERROR_NAME;exports.DepositTermsRejectedError=t.DepositTermsRejectedError;exports.PEGIN_FINGERPRINT_DOMAIN=t.PEGIN_FINGERPRINT_DOMAIN;exports.PEGIN_FINGERPRINT_DOMAIN_PREIMAGE=t.PEGIN_FINGERPRINT_DOMAIN_PREIMAGE;exports.PeginFingerprintInputError=t.PeginFingerprintInputError;exports.PeginParamsAmbiguousError=t.PeginParamsAmbiguousError;exports.PeginParamsIncompleteSpaceError=t.PeginParamsIncompleteSpaceError;exports.PeginParamsNotFoundError=t.PeginParamsNotFoundError;exports.PeginSizingIntegrityError=t.PeginSizingIntegrityError;exports.UnanchoredPrePeginError=t.UnanchoredPrePeginError;exports.VaultRootMismatchError=t.VaultRootMismatchError;exports.assertClaimBatchHomogeneous=t.assertClaimBatchHomogeneous;exports.buildPeginParamsCandidates=t.buildPeginParamsCandidates;exports.computeFundedPrePeginFee=t.computeFundedPrePeginFee;exports.computePeginFingerprint=t.computePeginFingerprint;exports.deriveHashlocksFromPrePegin=t.deriveHashlocksFromPrePegin;exports.describePeginParamsCandidate=t.describePeginParamsCandidate;exports.describeUnresolvedVersion=t.describeUnresolvedVersion;exports.encodePeginFingerprintPreimage=t.encodePeginFingerprintPreimage;exports.isDepositTermsRejectedError=t.isDepositTermsRejectedError;exports.isPeginFingerprintInputError=t.isPeginFingerprintInputError;exports.isWotsMismatchError=t.isWotsMismatchError;exports.orderClaimBatchByHtlcVout=t.orderClaimBatchByHtlcVout;exports.rebuildDepositTermsCore=t.rebuildDepositTermsCore;exports.rebuildDepositTermsForClaim=t.rebuildDepositTermsForClaim;exports.reconstructPeginParams=t.reconstructPeginParams;exports.selectSiblingRegistrations=t.selectSiblingRegistrations;exports.toRefundInputs=t.toRefundInputs;exports.ApplicationEntryPointMismatchError=e.ApplicationEntryPointMismatchError;exports.ArtifactsVaultMismatchError=e.ArtifactsVaultMismatchError;exports.AssertBindingError=e.AssertBindingError;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ChallengerSetMismatchError=e.ChallengerSetMismatchError;exports.DELEGATED_CLAIM_TX_GRAPH_VERSION=e.DELEGATED_CLAIM_TX_GRAPH_VERSION;exports.DelegatedClaimSigningIncompleteError=e.DelegatedClaimSigningIncompleteError;exports.GraphFingerprintError=e.GraphFingerprintError;exports.PEGIN_ETH_CONFIRMATIONS=e.PEGIN_ETH_CONFIRMATIONS;exports.ParticipantKeyDriftError=e.ParticipantKeyDriftError;exports.PayoutDestinationError=e.PayoutDestinationError;exports.PayoutInputLeafError=e.PayoutInputLeafError;exports.PeginRegistrationMissingError=e.PeginRegistrationMissingError;exports.PeginRegistrationNotFinalError=e.PeginRegistrationNotFinalError;exports.RECLAIM_MAX_FEE_FRACTION_DENOMINATOR=e.RECLAIM_MAX_FEE_FRACTION_DENOMINATOR;exports.RECLAIM_MAX_FEE_FRACTION_NUMERATOR=e.RECLAIM_MAX_FEE_FRACTION_NUMERATOR;exports.RECLAIM_MAX_FEE_RATE_SATS_VB=e.RECLAIM_MAX_FEE_RATE_SATS_VB;exports.RECLAIM_WARN_FEE_FRACTION_NUMERATOR=e.RECLAIM_WARN_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.ReclaimUneconomicalError=e.ReclaimUneconomicalError;exports.RefundBroadcastRejectedError=e.RefundBroadcastRejectedError;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.SigningPlanMismatchError=e.SigningPlanMismatchError;exports.UnsupportedPayoutScriptError=e.UnsupportedPayoutScriptError;exports.VaultIdBindingError=e.VaultIdBindingError;exports.activateVault=e.activateVault;exports.activateVaultAndRedeem=e.activateVaultAndRedeem;exports.assembleWatchtowerArtifacts=e.assembleWatchtowerArtifacts;exports.assembleWatchtowerArtifactsFromSignatures=e.assembleWatchtowerArtifactsFromSignatures;exports.assertArtifactsUsableForVault=e.assertArtifactsUsableForVault;exports.assertAssertBindsClaimAndPayout=e.assertAssertBindsClaimAndPayout;exports.assertChallengerSetMatchesVault=e.assertChallengerSetMatchesVault;exports.assertClaimSpendsVault=e.assertClaimSpendsVault;exports.assertPayoutPaysRegisteredScript=e.assertPayoutPaysRegisteredScript;exports.assertReturnedGraphMatchesFingerprint=e.assertReturnedGraphMatchesFingerprint;exports.assertStandardPayoutScriptsAtEpochs=e.assertStandardPayoutScriptsAtEpochs;exports.assertTermsMatchVault=e.assertTermsMatchVault;exports.assertVaultProviderHintAccepted=e.assertVaultProviderHintAccepted;exports.buildAndBroadcastReclaim=e.buildAndBroadcastReclaim;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.claimExpiredVault=e.claimExpiredVault;exports.copyAssertConnectorLeaf=e.copyAssertConnectorLeaf;exports.deriveClaimerWotsKeypair=e.deriveClaimerWotsKeypair;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.fingerprintReturnedGraph=e.fingerprintReturnedGraph;exports.isApplicationEntryPointMismatchError=e.isApplicationEntryPointMismatchError;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isHintAccepted=e.isHintAccepted;exports.isParticipantKeyDriftError=e.isParticipantKeyDriftError;exports.isPeginRegistrationMissingError=e.isPeginRegistrationMissingError;exports.isPeginRegistrationNotFinalError=e.isPeginRegistrationNotFinalError;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.isUnsupportedPayoutScriptError=e.isUnsupportedPayoutScriptError;exports.matchKeyHint=e.matchKeyHint;exports.matchKeySetHint=e.matchKeySetHint;exports.planDelegatedClaimSigning=e.planDelegatedClaimSigning;exports.readDelegatedClaimVaultContext=e.readDelegatedClaimVaultContext;exports.readRefundPrePeginContext=e.readRefundPrePeginContext;exports.readStampedParticipantKeys=e.readStampedParticipantKeys;exports.resolveCurrentParticipantKeys=e.resolveCurrentParticipantKeys;exports.resolveParticipantKeysAtEpochs=e.resolveParticipantKeysAtEpochs;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDelegatedClaimPlan=e.signDelegatedClaimPlan;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.summarizeWatchtowerArtifacts=e.summarizeWatchtowerArtifacts;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredParticipantKeys=e.verifyRegisteredParticipantKeys;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginRegistrationDepth=e.waitForPeginRegistrationDepth;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=g.ContractStatus;exports.PeginAction=g.PeginAction;exports.activationDeadlineBlocksRemaining=g.activationDeadlineBlocksRemaining;exports.canPerformAction=g.canPerformAction;exports.getPeginProtocolState=g.getPeginProtocolState;exports.isActivationDeadlinePassedOnChain=g.isActivationDeadlinePassedOnChain;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./verifyScriptPathSchnorrSignature-p3sVoWQi.cjs"),O=require("./secp256k1-DDHQ1_za.cjs"),o=require("./tbv/core/wasm/index.cjs"),R=require("./verifyKeyPathSchnorrSignature-B7Za6aa1.cjs"),E=require("./challengeAssert-DlzX_kjF.cjs"),y=require("./verifyPeginHashlockSpend-CisfqMuT.cjs"),r=require("./bitcoin-D-O2GjbC.cjs"),F=require("./abortSignals-msbmbqFe.cjs"),I=require("./signing-DvISftFk.cjs"),d=require("./validation-C6XTfZak.cjs"),N=require("./tbv/core/utils/eth/index.cjs"),_=require("./PeginManager-BNJUATq2.cjs"),P=require("./PayoutManager-PQqeqX41.cjs"),s=require("./tbv/core/clients/mempool/index.cjs"),l=require("./registration-records-CKc0OVuK.cjs"),C=require("./signer-set-reader-C8xSyTMb.cjs"),A=require("./pegin-registration-client-JtZkosZQ.cjs"),h=require("./types-Bt1FM6d8.cjs"),V=require("./ApplicationRegistry.abi-sMiTWmnL.cjs"),M=require("./BTCVaultRegistry.abi-C4bQi-H9.cjs"),u=require("./BTCVaultRegistryKeyEpochs.abi-CReWFJdu.cjs"),b=require("./ProtocolParams.abi-DzjpPHcl.cjs"),v=require("./VaultErrors.abi-BV0qeG6M.cjs"),D=require("./buildVaultContextInputForClaim-9XZaqIiw.cjs"),S=require("./deriveVaultRoot-C3uqnJto.cjs"),B=require("./parseFundingOutpoints-C_-PT9BT.cjs"),U=require("./shared/index.cjs"),f=require("./btcTxHash-CGb5BqFL.cjs"),c=require("./psbtInputFields-BrV_ZfL_.cjs"),i=require("./fundPeginTransaction-54-Rwb2k.cjs"),T=require("./reservation-D9ftyiwP.cjs"),m=require("./index-Dn7RlsKK.cjs"),a=require("./state-C4WoNCy1.cjs"),p=require("./primeVpAuth-36ayVa21.cjs"),t=require("./toRefundInputs-CzZujjq-.cjs"),e=require("./buildAndBroadcastReclaim-Blxt7B0K.cjs"),g=require("./peginState-B4t_PDgj.cjs");exports.PEGIN_DEPOSITOR_CLAIM_VOUT=n.PEGIN_DEPOSITOR_CLAIM_VOUT;exports.PsbtSubstitutionError=n.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=n.assertPsbtUnsignedTxMatches;exports.assertScriptPathSchnorrSignature=n.assertScriptPathSchnorrSignature;exports.buildPayoutPsbt=n.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=n.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=n.buildPrePeginPsbt;exports.computeNumLocalChallengers=n.computeNumLocalChallengers;exports.createPayoutScript=n.createPayoutScript;exports.deriveDepositorClaimDescriptor=n.deriveDepositorClaimDescriptor;exports.deriveDepositorClaimScriptPubKey=n.deriveDepositorClaimScriptPubKey;exports.extractPayoutSignature=n.extractPayoutSignature;exports.assertValidVaultCoreVersion=O.assertValidVaultCoreVersion;exports.attachFinalizedAssert=o.attachFinalizedAssert;exports.computeMinClaimValue=o.computeMinClaimValue;exports.computeMinPeginFee=o.computeMinPeginFee;exports.deriveVaultId=o.deriveVaultId;exports.expandAuthAnchor=o.expandAuthAnchor;exports.expandHashlockSecret=o.expandHashlockSecret;exports.expandWotsSeed=o.expandWotsSeed;exports.finalizePayout=o.finalizePayout;exports.finalizeWronglyChallenged=o.finalizeWronglyChallenged;exports.peginP2aAnchorOutput=o.peginP2aAnchorOutput;exports.pinPegoutProof=o.pinPegoutProof;exports.supportedTxGraphVersions=o.supportedTxGraphVersions;exports.validatePeginP2aAnchor=o.validatePeginP2aAnchor;exports.assertKeyPathSchnorrSignature=R.assertKeyPathSchnorrSignature;exports.assertReturnedKeyPathSignatures=R.assertReturnedKeyPathSignatures;exports.buildPeginInputPsbt=R.buildPeginInputPsbt;exports.extractPeginInputSignature=R.extractPeginInputSignature;exports.finalizePeginInputPsbt=R.finalizePeginInputPsbt;exports.buildChallengeAssertPsbt=E.buildChallengeAssertPsbt;exports.buildNoPayoutPsbt=E.buildNoPayoutPsbt;exports.buildReclaimPsbt=E.buildReclaimPsbt;exports.buildRefundPsbt=E.buildRefundPsbt;exports.estimateReclaimFeeSats=E.estimateReclaimFeeSats;exports.finalizeScriptPathWithSignatures=E.finalizeScriptPathWithSignatures;exports.reclaimVsize=E.reclaimVsize;exports.verifyPeginHashlockSpend=y.verifyPeginHashlockSpend;exports.canonicalizeBtcPubkey=r.canonicalizeBtcPubkey;exports.deriveBip86ScriptPubKeyHex=r.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=r.deriveNativeSegwitAddress;exports.deriveTaprootAddress=r.deriveTaprootAddress;exports.ensureHexPrefix=r.ensureHexPrefix;exports.formatSatoshisToBtc=r.formatSatoshisToBtc;exports.getNetwork=r.getNetwork;exports.getSortedXOnlyPubkeys=r.getSortedXOnlyPubkeys;exports.hexToUint8Array=r.hexToUint8Array;exports.isAddressFromPublicKey=r.isAddressFromPublicKey;exports.isValidHex=r.isValidHex;exports.processPublicKeyToXOnly=r.processPublicKeyToXOnly;exports.stripHexPrefix=r.stripHexPrefix;exports.toXOnly=r.toXOnly;exports.uint8ArrayToHex=r.uint8ArrayToHex;exports.validateWalletPubkey=r.validateWalletPubkey;exports.combineAbortSignals=F.combineAbortSignals;exports.createTaprootScriptPathSignOptions=I.createTaprootScriptPathSignOptions;exports.createTaprootScriptPathSignOptionsForInput=I.createTaprootScriptPathSignOptionsForInput;exports.BITCOIN_ADDRESS_RE=d.BITCOIN_ADDRESS_RE;exports.COMPRESSED_PUBKEY_HEX_LEN=d.COMPRESSED_PUBKEY_HEX_LEN;exports.HEX_RE=d.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=d.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=d.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=d.TXID_RE;exports.X_ONLY_PUBKEY_HEX_LEN=d.X_ONLY_PUBKEY_HEX_LEN;exports.waitForTransactionReceiptSmartAware=N.waitForTransactionReceiptSmartAware;exports.PeginManager=_.PeginManager;exports.buildDepositTerms=_.buildDepositTerms;exports.computeWotsBlockPublicKeysHash=_.computeWotsBlockPublicKeysHash;exports.deriveWotsBlocksFromSeed=_.deriveWotsBlocksFromSeed;exports.ensurePrePeginTermsApproval=_.ensurePrePeginTermsApproval;exports.PayoutManager=P.PayoutManager;exports.computeHashlock=P.computeHashlock;exports.forwardDepositApproval=P.forwardDepositApproval;exports.requireChangeAddress=P.requireChangeAddress;exports.supportsDepositApproval=P.supportsDepositApproval;exports.validateSecretAgainstHashlock=P.validateSecretAgainstHashlock;exports.MEMPOOL_API_URLS=s.MEMPOOL_API_URLS;exports.MempoolNotFoundError=s.MempoolNotFoundError;exports.getAddressTxs=s.getAddressTxs;exports.getAddressUtxos=s.getAddressUtxos;exports.getMempoolApiUrl=s.getMempoolApiUrl;exports.getNetworkFees=s.getNetworkFees;exports.getOutspend=s.getOutspend;exports.getTipHeight=s.getTipHeight;exports.getTxHex=s.getTxHex;exports.getTxInfo=s.getTxInfo;exports.getUtxoInfo=s.getUtxoInfo;exports.pushTx=s.pushTx;exports.RegistrationLogsUnavailableError=l.RegistrationLogsUnavailableError;exports.VaultClaimableByNotFoundError=l.VaultClaimableByNotFoundError;exports.assertOnChainBtcPubkey=l.assertOnChainBtcPubkey;exports.assertRegisteredPayoutScriptBounds=l.assertRegisteredPayoutScriptBounds;exports.derivePeginVaultId=l.derivePeginVaultId;exports.findRegistrationRecord=l.findRegistrationRecord;exports.isRegistrationLogsUnavailableError=l.isRegistrationLogsUnavailableError;exports.isVaultClaimableByNotFoundError=l.isVaultClaimableByNotFoundError;exports.registrationPrePeginTxHash=l.registrationPrePeginTxHash;exports.validateOffchainParams=l.validateOffchainParams;exports.validatePegInConfiguration=l.validatePegInConfiguration;exports.validateTBVProtocolParams=l.validateTBVProtocolParams;exports.ViemOperationKeyReader=C.ViemOperationKeyReader;exports.ViemUniversalChallengerReader=C.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=C.ViemVaultKeeperReader;exports.resolveProtocolAddresses=C.resolveProtocolAddresses;exports.COMMISSION_BPS_HEADROOM=A.COMMISSION_BPS_HEADROOM;exports.MAX_ACCEPTABLE_COMMISSION_BPS_CAP=A.MAX_ACCEPTABLE_COMMISSION_BPS_CAP;exports.ViemPeginRegistrationClient=A.ViemPeginRegistrationClient;exports.ViemVaultRegistryReader=A.ViemVaultRegistryReader;exports.capMaxAcceptableCommissionBps=A.capMaxAcceptableCommissionBps;exports.OnChainBtcVaultStatus=h.OnChainBtcVaultStatus;exports.ViemProtocolParamsReader=h.ViemProtocolParamsReader;exports.ApplicationRegistryABI=V.ApplicationRegistryABI;exports.BTCVaultRegistryABI=M.BTCVaultRegistryABI;exports.BTCVaultRegistryKeyEpochsABI=u.BTCVaultRegistryKeyEpochsABI;exports.CONTRACT_ERRORS=u.CONTRACT_ERRORS;exports.EMPTY_REVERT_MESSAGE=u.EMPTY_REVERT_MESSAGE;exports.PEGIN_FINGERPRINT_CHANGED_SELECTOR=u.PEGIN_FINGERPRINT_CHANGED_SELECTOR;exports.PeginFingerprintChangedError=u.PeginFingerprintChangedError;exports.extractErrorData=u.extractErrorData;exports.getContractErrorMessage=u.getContractErrorMessage;exports.handleContractError=u.handleContractError;exports.isKnownContractError=u.isKnownContractError;exports.isPeginFingerprintChangedError=u.isPeginFingerprintChangedError;exports.ProtocolParamsABI=b.ProtocolParamsABI;exports.VAULT_ERROR_ABI=v.VAULT_ERROR_ABI;exports.buildVaultContextInputForClaim=D.buildVaultContextInputForClaim;exports.VAULT_APP_NAME=S.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=S.buildFundingOutpointsCommitment;exports.buildVaultContext=S.buildVaultContext;exports.deriveVaultRoot=S.deriveVaultRoot;exports.forwardDeriveContextHash=S.forwardDeriveContextHash;exports.parseFundingOutpointsFromTx=B.parseFundingOutpointsFromTx;exports.BitcoinNetworks=U.BitcoinNetworks;exports.calculateBtcTxHash=f.calculateBtcTxHash;exports.BitcoinScriptType=c.BitcoinScriptType;exports.applyChangeOutputPolicy=c.applyChangeOutputPolicy;exports.computeChangeOutputFeeSats=c.computeChangeOutputFeeSats;exports.computeMaxDeposit=c.computeMaxDeposit;exports.computePeginBaseFeeSats=c.computePeginBaseFeeSats;exports.getDustThreshold=c.getDustThreshold;exports.getPsbtInputFields=c.getPsbtInputFields;exports.getScriptType=c.getScriptType;exports.selectUtxosForPegin=c.selectUtxosForPegin;exports.shouldAddChangeOutput=c.shouldAddChangeOutput;exports.BTC_DUST_SAT=i.BTC_DUST_SAT;exports.DUST_THRESHOLD=i.DUST_THRESHOLD;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=i.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=i.MAX_NON_LEGACY_OUTPUT_SIZE;exports.MAX_REASONABLE_PEGIN_VBYTES=i.MAX_REASONABLE_PEGIN_VBYTES;exports.P2TR_INPUT_SIZE=i.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=i.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=i.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=i.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=i.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=i.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=i.fundPeginTransaction;exports.parseUnfundedWasmTransaction=i.parseUnfundedWasmTransaction;exports.peginOutputCount=i.peginOutputCount;exports.rateBasedTxBufferFee=i.rateBasedTxBufferFee;exports.UtxoNotAvailableError=T.UtxoNotAvailableError;exports.assertUtxosAvailable=T.assertUtxosAvailable;exports.extractInputsFromTransaction=T.extractInputsFromTransaction;exports.findOverlappingPendingVaults=T.findOverlappingPendingVaults;exports.validateUtxosAvailable=T.validateUtxosAvailable;exports.VaultProviderRpcClient=m.VaultProviderRpcClient;exports.VpResponseValidationError=m.VpResponseValidationError;exports.batchPollByProvider=m.batchPollByProvider;exports.isUnrecognizedDaemonStatusError=m.isUnrecognizedDaemonStatusError;exports.validateRequestDepositorClaimerArtifactsResponse=m.validateRequestDepositorClaimerArtifactsResponse;exports.AUTH_REJECTED_RPC_CODE=a.AUTH_REJECTED_RPC_CODE;exports.ClaimerPegoutStatusValue=a.ClaimerPegoutStatusValue;exports.DaemonStatus=a.DaemonStatus;exports.JSON_RPC_ERROR_CODES=a.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=a.JsonRpcClient;exports.JsonRpcError=a.JsonRpcError;exports.POST_WOTS_STATUSES=a.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=a.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=a.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=a.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=a.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=a.VP_TRANSIENT_STATUSES;exports.isAuthRejectedError=a.isAuthRejectedError;exports.isPegoutTerminalStatus=a.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=a.isRecognizedPegoutStatus;exports.ServerIdentityError=p.ServerIdentityError;exports.VpTokenRegistry=p.VpTokenRegistry;exports.createAuthenticatedVpClient=p.createAuthenticatedVpClient;exports.primeVpTokenRegistry=p.primeVpTokenRegistry;exports.verifyServerIdentity=p.verifyServerIdentity;exports.vpTokenRegistry=p.vpTokenRegistry;exports.DEPOSIT_TERMS_REJECTED_ERROR_NAME=t.DEPOSIT_TERMS_REJECTED_ERROR_NAME;exports.DepositTermsRejectedError=t.DepositTermsRejectedError;exports.PEGIN_FINGERPRINT_DOMAIN=t.PEGIN_FINGERPRINT_DOMAIN;exports.PEGIN_FINGERPRINT_DOMAIN_PREIMAGE=t.PEGIN_FINGERPRINT_DOMAIN_PREIMAGE;exports.PeginFingerprintInputError=t.PeginFingerprintInputError;exports.PeginParamsAmbiguousError=t.PeginParamsAmbiguousError;exports.PeginParamsIncompleteSpaceError=t.PeginParamsIncompleteSpaceError;exports.PeginParamsNotFoundError=t.PeginParamsNotFoundError;exports.PeginSizingIntegrityError=t.PeginSizingIntegrityError;exports.UnanchoredPrePeginError=t.UnanchoredPrePeginError;exports.VaultRootMismatchError=t.VaultRootMismatchError;exports.assertClaimBatchHomogeneous=t.assertClaimBatchHomogeneous;exports.buildPeginParamsCandidates=t.buildPeginParamsCandidates;exports.computeFundedPrePeginFee=t.computeFundedPrePeginFee;exports.computePeginFingerprint=t.computePeginFingerprint;exports.deriveHashlocksFromPrePegin=t.deriveHashlocksFromPrePegin;exports.describePeginParamsCandidate=t.describePeginParamsCandidate;exports.describeUnresolvedVersion=t.describeUnresolvedVersion;exports.encodePeginFingerprintPreimage=t.encodePeginFingerprintPreimage;exports.isDepositTermsRejectedError=t.isDepositTermsRejectedError;exports.isPeginFingerprintInputError=t.isPeginFingerprintInputError;exports.isWotsMismatchError=t.isWotsMismatchError;exports.orderClaimBatchByHtlcVout=t.orderClaimBatchByHtlcVout;exports.rebuildDepositTermsCore=t.rebuildDepositTermsCore;exports.rebuildDepositTermsForClaim=t.rebuildDepositTermsForClaim;exports.reconstructPeginParams=t.reconstructPeginParams;exports.selectSiblingRegistrations=t.selectSiblingRegistrations;exports.toRefundInputs=t.toRefundInputs;exports.ApplicationEntryPointMismatchError=e.ApplicationEntryPointMismatchError;exports.ArtifactsVaultMismatchError=e.ArtifactsVaultMismatchError;exports.AssertBindingError=e.AssertBindingError;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ChallengerSetMismatchError=e.ChallengerSetMismatchError;exports.DELEGATED_CLAIM_TX_GRAPH_VERSION=e.DELEGATED_CLAIM_TX_GRAPH_VERSION;exports.DelegatedClaimSigningIncompleteError=e.DelegatedClaimSigningIncompleteError;exports.GraphFingerprintError=e.GraphFingerprintError;exports.PEGIN_ETH_CONFIRMATIONS=e.PEGIN_ETH_CONFIRMATIONS;exports.ParticipantKeyDriftError=e.ParticipantKeyDriftError;exports.PayoutDestinationError=e.PayoutDestinationError;exports.PayoutInputLeafError=e.PayoutInputLeafError;exports.PeginRegistrationMissingError=e.PeginRegistrationMissingError;exports.PeginRegistrationNotFinalError=e.PeginRegistrationNotFinalError;exports.RECLAIM_MAX_FEE_FRACTION_DENOMINATOR=e.RECLAIM_MAX_FEE_FRACTION_DENOMINATOR;exports.RECLAIM_MAX_FEE_FRACTION_NUMERATOR=e.RECLAIM_MAX_FEE_FRACTION_NUMERATOR;exports.RECLAIM_MAX_FEE_RATE_SATS_VB=e.RECLAIM_MAX_FEE_RATE_SATS_VB;exports.RECLAIM_WARN_FEE_FRACTION_NUMERATOR=e.RECLAIM_WARN_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.ReclaimUneconomicalError=e.ReclaimUneconomicalError;exports.RefundBroadcastRejectedError=e.RefundBroadcastRejectedError;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.SigningPlanMismatchError=e.SigningPlanMismatchError;exports.UnsupportedPayoutScriptError=e.UnsupportedPayoutScriptError;exports.VaultIdBindingError=e.VaultIdBindingError;exports.activateVault=e.activateVault;exports.activateVaultAndRedeem=e.activateVaultAndRedeem;exports.assembleWatchtowerArtifacts=e.assembleWatchtowerArtifacts;exports.assembleWatchtowerArtifactsFromSignatures=e.assembleWatchtowerArtifactsFromSignatures;exports.assertArtifactsUsableForVault=e.assertArtifactsUsableForVault;exports.assertAssertBindsClaimAndPayout=e.assertAssertBindsClaimAndPayout;exports.assertChallengerSetMatchesVault=e.assertChallengerSetMatchesVault;exports.assertClaimSpendsVault=e.assertClaimSpendsVault;exports.assertPayoutPaysRegisteredScript=e.assertPayoutPaysRegisteredScript;exports.assertReturnedGraphMatchesFingerprint=e.assertReturnedGraphMatchesFingerprint;exports.assertStandardPayoutScriptsAtEpochs=e.assertStandardPayoutScriptsAtEpochs;exports.assertTermsMatchVault=e.assertTermsMatchVault;exports.assertVaultProviderHintAccepted=e.assertVaultProviderHintAccepted;exports.buildAndBroadcastReclaim=e.buildAndBroadcastReclaim;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.claimExpiredVault=e.claimExpiredVault;exports.copyAssertConnectorLeaf=e.copyAssertConnectorLeaf;exports.deriveClaimerWotsKeypair=e.deriveClaimerWotsKeypair;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.fingerprintReturnedGraph=e.fingerprintReturnedGraph;exports.isApplicationEntryPointMismatchError=e.isApplicationEntryPointMismatchError;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isHintAccepted=e.isHintAccepted;exports.isParticipantKeyDriftError=e.isParticipantKeyDriftError;exports.isPeginRegistrationMissingError=e.isPeginRegistrationMissingError;exports.isPeginRegistrationNotFinalError=e.isPeginRegistrationNotFinalError;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.isUnsupportedPayoutScriptError=e.isUnsupportedPayoutScriptError;exports.matchKeyHint=e.matchKeyHint;exports.matchKeySetHint=e.matchKeySetHint;exports.planDelegatedClaimSigning=e.planDelegatedClaimSigning;exports.readDelegatedClaimVaultContext=e.readDelegatedClaimVaultContext;exports.readRefundPrePeginContext=e.readRefundPrePeginContext;exports.readStampedParticipantKeys=e.readStampedParticipantKeys;exports.resolveCurrentParticipantKeys=e.resolveCurrentParticipantKeys;exports.resolveParticipantKeysAtEpochs=e.resolveParticipantKeysAtEpochs;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDelegatedClaimPlan=e.signDelegatedClaimPlan;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.summarizeWatchtowerArtifacts=e.summarizeWatchtowerArtifacts;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredParticipantKeys=e.verifyRegisteredParticipantKeys;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginRegistrationDepth=e.waitForPeginRegistrationDepth;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=g.ContractStatus;exports.PeginAction=g.PeginAction;exports.activationDeadlineBlocksRemaining=g.activationDeadlineBlocksRemaining;exports.canPerformAction=g.canPerformAction;exports.getPeginProtocolState=g.getPeginProtocolState;exports.isActivationDeadlinePassedOnChain=g.isActivationDeadlinePassedOnChain;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import { B as us, D as gs, L as ms, M as Rs, c as As, P as _s, b as Ss, a as Ts,
31
31
  import { U as Fs, a as Ns, e as ys, f as Ms, v as vs } from "./reservation-BAj5n-H_.js";
32
32
  import { V as Bs, a as Us, b as Hs, i as Ls, v as Ks } from "./index-B-9aXMxk.js";
33
33
  import { A as ks, C as Gs, D as Ws, J as ws, a as zs, b as Ys, d as js, P as Js, R as Zs, e as qs, c as Qs, V as $s, i as ar, g as er, f as sr } from "./state-CFn1rT74.js";
34
- import { S as tr, V as ir, c as or, p as nr, v as lr, a as pr } from "./primeVpAuth-B0noJdcy.js";
34
+ import { S as tr, V as ir, c as or, p as nr, v as lr, a as pr } from "./primeVpAuth-P-KTmNKb.js";
35
35
  import { D as cr, g as Er, P as dr, a as ur, b as gr, u as mr, v as Rr, t as Ar, w as _r, U as Sr, V as Tr, f as Cr, m as fr, j as Ir, c as hr, l as Vr, p as xr, n as Or, e as br, h as Fr, d as Nr, i as yr, o as Mr, r as vr, k as Dr, q as Br, s as Ur, x as Hr } from "./toRefundInputs-CZ9aqp2o.js";
36
36
  import { J as Kr, l as Xr, A as kr, ab as Gr, C as Wr, D as wr, n as zr, G as Yr, u as jr, W as Jr, P as Zr, j as qr, v as Qr, w as $r, am as at, an as et, ao as st, ap as rt, af as tt, ag as it, ah as ot, ai as nt, ak as lt, ac as pt, a0 as Pt, S as ct, X as Et, V as dt, a as ut, b as gt, d as mt, e as Rt, m as At, f as _t, g as St, t as Tt, i as Ct, B as ft, Y as It, o as ht, a4 as Vt, al as xt, ad as Ot, c as bt, k as Ft, h as Nt, ae as yt, E as Mt, K as vt, M as Dt, a5 as Bt, Z as Ut, x as Ht, y as Lt, a1 as Kt, _ as Xt, a6 as kt, a7 as Gt, p as Wt, r as wt, aj as zt, a8 as Yt, a9 as jt, aa as Jt, F as Zt, q as qt, H as Qt, I as $t, s as ai, N as ei, O as si, L as ri, Q as ti, R as ii, T as oi, U as ni, $ as li, a2 as pi, z as Pi, a3 as ci } from "./buildAndBroadcastReclaim-C2CkzCVn.js";
37
37
  import { C as di, P as ui, a as gi, c as mi, g as Ri, i as Ai } from "./peginState-CXdbSit3.js";
@@ -1,2 +1,2 @@
1
- "use strict";var z=Object.defineProperty;var Q=(r,e,t)=>e in r?z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>Q(r,typeof e!="symbol"?e+"":e,t);const _=require("./bitcoin-D-O2GjbC.cjs"),Z=require("./index-Dn7RlsKK.cjs"),ee=require("./state-C4WoNCy1.cjs"),te=require("@bitcoin-js/tiny-secp256k1-asmjs"),y=require("./validation-C6XTfZak.cjs"),re=require("./bip322Verify-DLxJR9CQ.cjs"),ne=require("./sha2-Ce6KewYx.cjs");function ie(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const J=ie(te);function k(r,e){const t=(r&7)<<5,n=typeof e=="bigint"?e:BigInt(e);if(n<0n)throw new Error("cborHead: negative argument");if(n<24n)return new Uint8Array([t|Number(n)]);if(n<0x100n)return new Uint8Array([t|24,Number(n)]);if(n<0x10000n){const i=Number(n);return new Uint8Array([t|25,i>>>8&255,i&255])}if(n<0x100000000n){const i=Number(n);return new Uint8Array([t|26,i>>>24&255,i>>>16&255,i>>>8&255,i&255])}const s=new Uint8Array(9);s[0]=t|27;for(let i=7;i>=0;i--)s[1+i]=Number(n>>BigInt((7-i)*8))&255;return s}function V(...r){const e=r.reduce((s,i)=>s+i.length,0),t=new Uint8Array(e);let n=0;for(const s of r)t.set(s,n),n+=s.length;return t}function I(r){const t=[k(4,r.length)];for(const n of r)t.push(k(0,n));return V(...t)}function se(r,e,t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`);const n=k(4,3),s=I(r),i=I(e),o=k(0,t);return V(n,s,i,o)}const oe=new TextEncoder().encode("btc-auth.server-identity.v1"),ce=2*3600;class h extends Error{constructor(e,t){super(e),this.reason=t,this.name="ServerIdentityError"}}function v(r){const e=new Uint8Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}function D(r){const{proof:e,pinnedServerPubkey:t,now:n}=r,s=r.maxLifetimeSecs??ce,i=_.stripHexPrefix(t).toLowerCase();if(i.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(i))throw new h(`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,"invalid_pubkey_encoding");const o=_.stripHexPrefix(e.server_pubkey).toLowerCase();if(o.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(o))throw new h(`server_pubkey must be 32-byte hex; got ${o.length} chars`,"invalid_pubkey_encoding");if(o!==i)throw new h(`server_pubkey does not match pinned value: expected ${i}, got ${o}`,"pinned_pubkey_mismatch");if(!Number.isSafeInteger(e.expires_at))throw new h(`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,"invalid_expires_at");if(!Number.isSafeInteger(n))throw new h(`now must be a finite integer; got ${JSON.stringify(n)}`,"invalid_expires_at");if(e.expires_at<=n)throw new h(`server identity proof expired at ${e.expires_at}, now ${n}`,"expired");if(!Number.isSafeInteger(s)||s<=0)throw new h(`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,"invalid_max_lifetime");if(e.expires_at-n>s)throw new h(`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${s}s`,"expires_too_far");const a=_.stripHexPrefix(e.ephemeral_pubkey).toLowerCase();if(a.length!==y.COMPRESSED_PUBKEY_HEX_LEN||!y.HEX_RE.test(a))throw new h(`ephemeral_pubkey must be 33-byte compressed hex; got ${a.length} chars`,"invalid_ephemeral_pubkey");const g=a.slice(0,2);if(g!=="02"&&g!=="03")throw new h(`ephemeral_pubkey must be compressed (prefix 02/03); got ${g}`,"invalid_ephemeral_pubkey");const l=v(a);if(!J.isPoint(l))throw new h("ephemeral_pubkey is not a valid secp256k1 point","invalid_ephemeral_pubkey");const p=_.stripHexPrefix(e.signature).toLowerCase();if(p.length!==_.SCHNORR_SIG_HEX_LEN||!y.HEX_RE.test(p))throw new h(`signature must be 64-byte Schnorr hex; got ${p.length} chars`,"invalid_signature_encoding");const b=se(oe,v(a),e.expires_at);if(!re.verifyBip322Simple(b,v(o),v(p)))throw new h("BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey","signature_verification_failed")}const ae=new Set(["vaultProvider_submitDepositorWotsKey","vaultProvider_submitDepositorPresignatures","vaultProvider_requestDepositorPresignTransactions"]),de=new Set(["vaultProvider_requestDepositorClaimerArtifacts"]),ue=6e4,T="auth_createDepositorToken",C="auth_createDepositorTokenGrpc";function j(r,e){return new ee.JsonRpcClient({baseUrl:r,timeout:ue,headers:e,retryableFor:t=>t===T||t===C})}const pe=0,he=1,A=2,le=3,ye=4,ge=5,_e=6,fe=7,H=24,be=28,xe=20,we=21,ve=22,N=256;class f extends Error{constructor(e){super(`CBOR decode: ${e}`),this.name="CborDecodeError"}}class K{constructor(e){u(this,"buf");u(this,"pos",0);this.buf=e}nextByte(){if(this.pos>=this.buf.length)throw new f("unexpected end of input");return this.buf[this.pos++]}readHead(){const e=this.nextByte(),t=e>>5,n=e&31;if(n<H)return{major:t,arg:n};if(n>=be)throw new f(`unsupported additional info ${n} (indefinite-length or reserved)`);const s=1<<n-H;let i=0n;for(let o=0;o<s;o++)i=i<<8n|BigInt(this.nextByte());if(i>BigInt(Number.MAX_SAFE_INTEGER))throw new f(`argument ${i} exceeds safe integer range`);return{major:t,arg:Number(i)}}readBytes(e){if(this.pos+e>this.buf.length)throw new f("length overruns end of input");const t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}readByteString(){const e=this.readHead();if(e.major!==A)throw new f(`expected byte string (major ${A}), got major ${e.major}`);return this.readBytes(e.arg)}readValue(e=0){if(e>N)throw new f(`nesting exceeds maximum depth ${N}`);const t=this.readHead();switch(t.major){case pe:return t.arg;case he:return-1-t.arg;case A:return this.readBytes(t.arg);case le:return new TextDecoder("utf-8",{fatal:!0}).decode(this.readBytes(t.arg));case ye:{const n=[];for(let s=0;s<t.arg;s++)n.push(this.readValue(e+1));return n}case ge:{const n=new Map;for(let s=0;s<t.arg;s++){const i=this.readValue(e+1),o=this.readValue(e+1);n.set(i,o)}return n}case _e:return{tag:t.arg,value:this.readValue(e+1)};case fe:if(t.arg===xe)return!1;if(t.arg===we)return!0;if(t.arg===ve)return null;throw new f(`unsupported simple/float value ${t.arg}`);default:throw new f(`unsupported major type ${t.major}`)}}}function F(r){const e=new K(r),t=e.readValue();if(e.pos!==r.length)throw new f("trailing bytes after top-level item");return t}const ke="vaultd-jsonrpc",Pe="vaultd-grpc",L=18,R=4,X=-47,Se=1,M=64,Ae=128,Ee=96,me=64,Te=1,Ce=2,Re=3,Oe=4,$e=5,Ie=6,He=7,B=new TextEncoder().encode("Signature1");class c extends Error{constructor(e,t){super(e),this.reason=t,this.name="CwtVerificationError"}}function Ne(r){const e=G(r.expectedIssuerXOnlyPubkey,"expectedIssuerXOnlyPubkey"),t=G(r.expectedAudienceXOnlyPubkey,"expectedAudienceXOnlyPubkey"),n=Ge(r.ephemeralPubkeyHex),s=Je(r.token),i=new K(s),o=i.readHead();if(o.major!==6||o.arg!==L)throw new c(`token is not a COSE Sign1 tagged value (tag ${L})`,"invalid_token_structure");const a=i.readHead();if(a.major!==4||a.arg!==R)throw new c(`COSE Sign1 must be a ${R}-element array`,"invalid_token_structure");const g=i.pos,l=i.readByteString(),p=s.subarray(g,i.pos);i.readValue();const b=i.pos,x=i.readByteString(),P=s.subarray(b,i.pos),S=i.readByteString();if(S.length!==M)throw new c(`COSE signature must be ${M} bytes, got ${S.length}`,"invalid_token_structure");if(i.pos!==s.length)throw new c("COSE Sign1 token has trailing bytes after the signature","invalid_token_structure");const $=Le(l);if($!==X)throw new c(`unexpected COSE algorithm ${$} (expected ES256K ${X})`,"unexpected_algorithm");const Y=Xe(p,P),W=ne.sha256(Y);if(!J.verify(W,n,S,!0))throw new c("COSE signature does not verify against the server's ephemeral key","signature_verification_failed");const d=Me(x),w=d.audience.toLowerCase();if(w.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(w))throw new c("token `aud` is not a 32-byte x-only pubkey hex","invalid_claims");if(d.issuedAt>d.expiresAt)throw new c(`token iat (${d.issuedAt}) is after exp (${d.expiresAt})`,"invalid_claims");if(d.issuer.toLowerCase()!==e)throw new c(`token issuer does not match pinned server pubkey: expected ${e}, got ${d.issuer.toLowerCase()}`,"issuer_mismatch");if(d.subject!==r.expectedSubject)throw new c(`token subject mismatch: expected ${r.expectedSubject}, got ${d.subject}`,"subject_mismatch");if(w!==t)throw new c(`token audience does not match depositor pubkey: expected ${t}, got ${w}`,"audience_mismatch");if(d.expiresAt<=r.now)throw new c(`token expired: exp ${d.expiresAt} <= now ${r.now}`,"token_expired");if(r.responseExpiresAt!==d.expiresAt)throw new c(`response expires_at (${r.responseExpiresAt}) does not equal token exp (${d.expiresAt})`,"expiry_mismatch");if(r.serverIdentityExpiresAt<d.expiresAt)throw new c(`server identity expires (${r.serverIdentityExpiresAt}) before token exp (${d.expiresAt})`,"server_identity_expires_before_token");return{issuer:d.issuer,subject:d.subject,audience:w,expiresAt:d.expiresAt,notBefore:d.notBefore,issuedAt:d.issuedAt}}function Le(r){if(r.length===0)throw new c("empty COSE protected header (no algorithm)","unexpected_algorithm");const e=F(r);if(!(e instanceof Map))throw new c("COSE protected header is not a map","invalid_token_structure");const t=e.get(Se);if(typeof t!="number")throw new c("COSE protected header missing integer algorithm label","unexpected_algorithm");return t}function Xe(r,e){return Ve(Uint8Array.of(Ae|R),Uint8Array.of(Ee|B.length),B,r,Uint8Array.of(me),e)}function Me(r){const e=F(r);if(!(e instanceof Map))throw new c("CWT claims root is not a map","invalid_claims");if(Be(e,He,"cti").length===0)throw new c("token cti is empty","invalid_claims");return{issuer:E(e,Te,"iss"),subject:E(e,Ce,"sub"),audience:E(e,Re,"aud"),expiresAt:m(e,Oe,"exp"),notBefore:m(e,$e,"nbf"),issuedAt:m(e,Ie,"iat")}}function E(r,e,t){const n=r.get(e);if(typeof n!="string")throw new c(`token claim ${t} is missing or not a text string`,"invalid_claims");return n}function Be(r,e,t){const n=r.get(e);if(!(n instanceof Uint8Array))throw new c(`token claim ${t} is missing or not a byte string`,"invalid_claims");return n}function m(r,e,t){const n=r.get(e);if(typeof n!="number"||!Number.isSafeInteger(n)||n<0)throw new c(`token claim ${t} is missing or not a non-negative integer timestamp`,"invalid_claims");return n}function G(r,e){const t=_.stripHexPrefix(r).toLowerCase();if(t.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(t))throw new c(`${e} must be 32-byte x-only hex; got ${t.length} chars`,"invalid_input");return t}function Ge(r){const e=_.stripHexPrefix(r).toLowerCase(),t=e.slice(0,2);if(e.length!==y.COMPRESSED_PUBKEY_HEX_LEN||!y.HEX_RE.test(e)||t!=="02"&&t!=="03")throw new c("ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)","invalid_input");return _.hexToUint8Array(e)}const Ue=(()=>{const r=new Int16Array(128).fill(-1),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(let t=0;t<e.length;t++)r[e.charCodeAt(t)]=t;return r})();function Je(r){const e=r.length,t=Math.floor(e/4),n=e%4;if(n===1)throw new c("invalid base64url length","invalid_token_structure");const s=t*3+(n===0?0:n-1),i=new Uint8Array(s),o=l=>{const p=l<128?Ue[l]:-1;if(p<0)throw new c("invalid base64url character","invalid_token_structure");return p};let a=0,g=0;for(let l=0;l<t;l++){const p=o(r.charCodeAt(a++)),b=o(r.charCodeAt(a++)),x=o(r.charCodeAt(a++)),P=o(r.charCodeAt(a++));i[g++]=p<<2|b>>4,i[g++]=(b&15)<<4|x>>2,i[g++]=(x&3)<<6|P}if(n===2){const l=o(r.charCodeAt(a++)),p=o(r.charCodeAt(a++));i[g++]=l<<2|p>>4}else if(n===3){const l=o(r.charCodeAt(a++)),p=o(r.charCodeAt(a++)),b=o(r.charCodeAt(a++));i[g++]=l<<2|p>>4,i[g++]=(p&15)<<4|b>>2}return i}function Ve(...r){const e=r.reduce((s,i)=>s+i.length,0),t=new Uint8Array(e);let n=0;for(const s of r)t.set(s,n),n+=s.length;return t}const U=4102444800,De=30;class je{constructor(e){u(this,"client");u(this,"peginTxid");u(this,"authAnchorHex");u(this,"jsonRpcPinnedServerPubkey");u(this,"grpcPinnedServerPubkey");u(this,"refreshJsonRpcPinnedServerPubkey");u(this,"expectedAudienceXOnlyPubkey");u(this,"authGatedMethods");u(this,"grpcGatedMethods");u(this,"refreshSkewSecs");u(this,"now");u(this,"cachedJsonRpc",null);u(this,"inFlightJsonRpc",null);u(this,"cachedGrpc",null);u(this,"inFlightGrpc",null);this.client=e.client,this.peginTxid=e.peginTxid,this.authAnchorHex=e.authAnchorHex,this.jsonRpcPinnedServerPubkey=e.pinnedServerPubkey,this.grpcPinnedServerPubkey=e.grpcPinnedServerPubkey,this.refreshJsonRpcPinnedServerPubkey=e.refreshJsonRpcPinnedServerPubkey,this.expectedAudienceXOnlyPubkey=e.expectedAudienceXOnlyPubkey,this.authGatedMethods=e.authGatedMethods,this.grpcGatedMethods=e.grpcGatedMethods,this.refreshSkewSecs=e.refreshSkewSecs??De,this.now=e.now??(()=>Math.floor(Date.now()/1e3))}async getToken(e){return e===T||e===C?null:this.grpcGatedMethods.has(e)?this.getTokenForSubject("grpc"):this.authGatedMethods.has(e)?this.getTokenForSubject("jsonrpc"):null}invalidate(){this.cachedJsonRpc=null,this.cachedGrpc=null}async getTokenForSubject(e){const t=e==="grpc"?this.cachedGrpc:this.cachedJsonRpc;return t&&this.now()+this.refreshSkewSecs<t.expiresAt?t.token:(await this.acquireSingleFlight(e)).token}setClient(e){this.client=e}getPinnedServerPubkey(e){return e==="grpc"?this.grpcPinnedServerPubkey:this.jsonRpcPinnedServerPubkey}acquireSingleFlight(e){const t=e==="grpc"?this.inFlightGrpc:this.inFlightJsonRpc;if(t)return t;const n=e==="grpc"?C:T,s=(async()=>{try{const i=await this.acquireAndVerify(e,n,!0);return e==="grpc"?this.cachedGrpc=i:this.cachedJsonRpc=i,i}finally{e==="grpc"?this.inFlightGrpc=null:this.inFlightJsonRpc=null}})();return e==="grpc"?this.inFlightGrpc=s:this.inFlightJsonRpc=s,s}async acquireAndVerify(e,t,n){const s=await this.client.call(t,{pegin_txid:this.peginTxid,auth_anchor:this.authAnchorHex}),i=this.getPinnedServerPubkey(e);try{if(D({proof:s.server_identity,pinnedServerPubkey:i,now:this.now()}),typeof s.token!="string"||s.token.length===0)throw new Error(`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`);const o=this.now();if(!Number.isSafeInteger(s.expires_at)||s.expires_at<=o||s.expires_at>U)throw new Error(`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${o}, ${U}])`);return Ne({token:s.token,ephemeralPubkeyHex:s.server_identity.ephemeral_pubkey,expectedIssuerXOnlyPubkey:i,expectedSubject:e==="grpc"?Pe:ke,expectedAudienceXOnlyPubkey:this.expectedAudienceXOnlyPubkey,responseExpiresAt:s.expires_at,serverIdentityExpiresAt:s.server_identity.expires_at,now:o}),{token:s.token,expiresAt:s.expires_at}}catch(o){if(n&&e==="jsonrpc"&&this.refreshJsonRpcPinnedServerPubkey&&Ke(o)){const a=await this.refreshJsonRpcPinnedServerPubkey();if(a!==this.jsonRpcPinnedServerPubkey)return this.jsonRpcPinnedServerPubkey=a,this.acquireAndVerify(e,t,!1)}throw o}}}function Ke(r){return r instanceof h&&r.reason==="pinned_pubkey_mismatch"||r instanceof c&&r.reason==="issuer_mismatch"}class q{constructor(){u(this,"entries",new Map)}getOrCreate(e){const t=this.entries.get(e.peginTxid);if(t){if(t.authAnchorHex!==e.authAnchorHex)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${t.authAnchorHex.slice(0,8)}…; got ${e.authAnchorHex.slice(0,8)}…`);if(t.providerAddress.toLowerCase()!==e.providerAddress.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to providerAddress ${t.providerAddress}; got ${e.providerAddress}`);if(t.provider.getPinnedServerPubkey("jsonrpc")!==e.pinnedServerPubkey)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to JSON-RPC pinnedServerPubkey ${t.provider.getPinnedServerPubkey("jsonrpc").slice(0,8)}…; got ${e.pinnedServerPubkey.slice(0,8)}…`);if(t.provider.getPinnedServerPubkey("grpc")!==e.grpcPinnedServerPubkey)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to gRPC pinnedServerPubkey ${t.provider.getPinnedServerPubkey("grpc").slice(0,8)}…; got ${e.grpcPinnedServerPubkey.slice(0,8)}…`);if(t.grpcKeyEpoch!==e.grpcKeyEpoch)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to gRPC key epoch ${t.grpcKeyEpoch.toString()}; got ${e.grpcKeyEpoch.toString()}`);if(t.expectedAudienceXOnlyPubkey.toLowerCase()!==e.expectedAudienceXOnlyPubkey.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to expectedAudienceXOnlyPubkey ${t.expectedAudienceXOnlyPubkey.slice(0,8)}…; got ${e.expectedAudienceXOnlyPubkey.slice(0,8)}…`);return t.provider.setClient(e.client),t.provider}const n=new je({client:e.client,peginTxid:e.peginTxid,authAnchorHex:e.authAnchorHex,pinnedServerPubkey:e.pinnedServerPubkey,grpcPinnedServerPubkey:e.grpcPinnedServerPubkey,refreshJsonRpcPinnedServerPubkey:e.refreshJsonRpcPinnedServerPubkey,expectedAudienceXOnlyPubkey:e.expectedAudienceXOnlyPubkey,authGatedMethods:ae,grpcGatedMethods:de});return this.entries.set(e.peginTxid,{provider:n,authAnchorHex:e.authAnchorHex,providerAddress:e.providerAddress,grpcKeyEpoch:e.grpcKeyEpoch,expectedAudienceXOnlyPubkey:e.expectedAudienceXOnlyPubkey}),n}peek(e){const t=this.entries.get(e.peginTxid);if(t){if(t.providerAddress.toLowerCase()!==e.providerAddress.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to providerAddress ${t.providerAddress}; got ${e.providerAddress}`);if(t.expectedAudienceXOnlyPubkey.toLowerCase()!==e.expectedAudienceXOnlyPubkey.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to expectedAudienceXOnlyPubkey ${t.expectedAudienceXOnlyPubkey.slice(0,8)}…; got ${e.expectedAudienceXOnlyPubkey.slice(0,8)}…`);return t.provider}}release(e){this.entries.delete(e)}clear(){this.entries.clear()}get size(){return this.entries.size}}const O=new q;function Fe(r){var n;const e=j(r.baseUrl,(n=r.options)==null?void 0:n.headers),t=O.getOrCreate({client:e,peginTxid:r.peginTxid,authAnchorHex:r.authAnchorHex,providerAddress:r.providerAddress,pinnedServerPubkey:r.pinnedServerPubkey,grpcPinnedServerPubkey:r.grpcPinnedServerPubkey,grpcKeyEpoch:r.grpcKeyEpoch,refreshJsonRpcPinnedServerPubkey:r.refreshJsonRpcPinnedServerPubkey,expectedAudienceXOnlyPubkey:_.processPublicKeyToXOnly(r.depositorBtcPubkey)});return new Z.VaultProviderRpcClient(r.baseUrl,{...r.options,tokenProvider:t})}function qe(r){O.getOrCreate({client:j(r.baseUrl,r.headers),peginTxid:r.peginTxid,authAnchorHex:r.authAnchorHex,providerAddress:r.providerAddress,pinnedServerPubkey:r.pinnedServerPubkey,grpcPinnedServerPubkey:r.grpcPinnedServerPubkey,grpcKeyEpoch:r.grpcKeyEpoch,refreshJsonRpcPinnedServerPubkey:r.refreshJsonRpcPinnedServerPubkey,expectedAudienceXOnlyPubkey:_.processPublicKeyToXOnly(r.depositorBtcPubkey)})}exports.ServerIdentityError=h;exports.VpTokenRegistry=q;exports.createAuthenticatedVpClient=Fe;exports.primeVpTokenRegistry=qe;exports.verifyServerIdentity=D;exports.vpTokenRegistry=O;
2
- //# sourceMappingURL=primeVpAuth-Ch-ig2My.cjs.map
1
+ "use strict";var z=Object.defineProperty;var Q=(r,e,t)=>e in r?z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>Q(r,typeof e!="symbol"?e+"":e,t);const _=require("./bitcoin-D-O2GjbC.cjs"),Z=require("./index-Dn7RlsKK.cjs"),ee=require("./state-C4WoNCy1.cjs"),te=require("@bitcoin-js/tiny-secp256k1-asmjs"),y=require("./validation-C6XTfZak.cjs"),re=require("./bip322Verify-DLxJR9CQ.cjs"),ne=require("./sha2-Ce6KewYx.cjs");function ie(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const J=ie(te);function k(r,e){const t=(r&7)<<5,n=typeof e=="bigint"?e:BigInt(e);if(n<0n)throw new Error("cborHead: negative argument");if(n<24n)return new Uint8Array([t|Number(n)]);if(n<0x100n)return new Uint8Array([t|24,Number(n)]);if(n<0x10000n){const i=Number(n);return new Uint8Array([t|25,i>>>8&255,i&255])}if(n<0x100000000n){const i=Number(n);return new Uint8Array([t|26,i>>>24&255,i>>>16&255,i>>>8&255,i&255])}const s=new Uint8Array(9);s[0]=t|27;for(let i=7;i>=0;i--)s[1+i]=Number(n>>BigInt((7-i)*8))&255;return s}function V(...r){const e=r.reduce((s,i)=>s+i.length,0),t=new Uint8Array(e);let n=0;for(const s of r)t.set(s,n),n+=s.length;return t}function I(r){const t=[k(4,r.length)];for(const n of r)t.push(k(0,n));return V(...t)}function se(r,e,t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`);const n=k(4,3),s=I(r),i=I(e),o=k(0,t);return V(n,s,i,o)}const oe=new TextEncoder().encode("btc-auth.server-identity.v1"),ce=2*3600;class h extends Error{constructor(e,t){super(e),this.reason=t,this.name="ServerIdentityError"}}function v(r){const e=new Uint8Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}function D(r){const{proof:e,pinnedServerPubkey:t,now:n}=r,s=r.maxLifetimeSecs??ce,i=_.stripHexPrefix(t).toLowerCase();if(i.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(i))throw new h(`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,"invalid_pubkey_encoding");const o=_.stripHexPrefix(e.server_pubkey).toLowerCase();if(o.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(o))throw new h(`server_pubkey must be 32-byte hex; got ${o.length} chars`,"invalid_pubkey_encoding");if(o!==i)throw new h(`server_pubkey does not match pinned value: expected ${i}, got ${o}`,"pinned_pubkey_mismatch");if(!Number.isSafeInteger(e.expires_at))throw new h(`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,"invalid_expires_at");if(!Number.isSafeInteger(n))throw new h(`now must be a finite integer; got ${JSON.stringify(n)}`,"invalid_expires_at");if(e.expires_at<=n)throw new h(`server identity proof expired at ${e.expires_at}, now ${n}`,"expired");if(!Number.isSafeInteger(s)||s<=0)throw new h(`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,"invalid_max_lifetime");if(e.expires_at-n>s)throw new h(`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${s}s`,"expires_too_far");const a=_.stripHexPrefix(e.ephemeral_pubkey).toLowerCase();if(a.length!==y.COMPRESSED_PUBKEY_HEX_LEN||!y.HEX_RE.test(a))throw new h(`ephemeral_pubkey must be 33-byte compressed hex; got ${a.length} chars`,"invalid_ephemeral_pubkey");const g=a.slice(0,2);if(g!=="02"&&g!=="03")throw new h(`ephemeral_pubkey must be compressed (prefix 02/03); got ${g}`,"invalid_ephemeral_pubkey");const l=v(a);if(!J.isPoint(l))throw new h("ephemeral_pubkey is not a valid secp256k1 point","invalid_ephemeral_pubkey");const p=_.stripHexPrefix(e.signature).toLowerCase();if(p.length!==_.SCHNORR_SIG_HEX_LEN||!y.HEX_RE.test(p))throw new h(`signature must be 64-byte Schnorr hex; got ${p.length} chars`,"invalid_signature_encoding");const b=se(oe,v(a),e.expires_at);if(!re.verifyBip322Simple(b,v(o),v(p)))throw new h("BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey","signature_verification_failed")}const ae=new Set(["vaultProvider_submitDepositorWotsKey","vaultProvider_submitDepositorPresignatures","vaultProvider_requestDepositorPresignTransactions"]),de=new Set(["vaultProvider_requestDepositorClaimerArtifacts"]),ue=6e4,T="auth_createDepositorToken",C="auth_createDepositorTokenGrpc";function j(r,e){return new ee.JsonRpcClient({baseUrl:r,timeout:ue,headers:e,retryableFor:t=>t===T||t===C})}const pe=0,he=1,A=2,le=3,ye=4,ge=5,_e=6,fe=7,H=24,be=28,xe=20,we=21,ve=22,N=256;class f extends Error{constructor(e){super(`CBOR decode: ${e}`),this.name="CborDecodeError"}}class K{constructor(e){u(this,"buf");u(this,"pos",0);this.buf=e}nextByte(){if(this.pos>=this.buf.length)throw new f("unexpected end of input");return this.buf[this.pos++]}readHead(){const e=this.nextByte(),t=e>>5,n=e&31;if(n<H)return{major:t,arg:n};if(n>=be)throw new f(`unsupported additional info ${n} (indefinite-length or reserved)`);const s=1<<n-H;let i=0n;for(let o=0;o<s;o++)i=i<<8n|BigInt(this.nextByte());if(i>BigInt(Number.MAX_SAFE_INTEGER))throw new f(`argument ${i} exceeds safe integer range`);return{major:t,arg:Number(i)}}readBytes(e){if(this.pos+e>this.buf.length)throw new f("length overruns end of input");const t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}readByteString(){const e=this.readHead();if(e.major!==A)throw new f(`expected byte string (major ${A}), got major ${e.major}`);return this.readBytes(e.arg)}readValue(e=0){if(e>N)throw new f(`nesting exceeds maximum depth ${N}`);const t=this.readHead();switch(t.major){case pe:return t.arg;case he:return-1-t.arg;case A:return this.readBytes(t.arg);case le:return new TextDecoder("utf-8",{fatal:!0}).decode(this.readBytes(t.arg));case ye:{const n=[];for(let s=0;s<t.arg;s++)n.push(this.readValue(e+1));return n}case ge:{const n=new Map;for(let s=0;s<t.arg;s++){const i=this.readValue(e+1),o=this.readValue(e+1);n.set(i,o)}return n}case _e:return{tag:t.arg,value:this.readValue(e+1)};case fe:if(t.arg===xe)return!1;if(t.arg===we)return!0;if(t.arg===ve)return null;throw new f(`unsupported simple/float value ${t.arg}`);default:throw new f(`unsupported major type ${t.major}`)}}}function F(r){const e=new K(r),t=e.readValue();if(e.pos!==r.length)throw new f("trailing bytes after top-level item");return t}const ke="vaultd-jsonrpc",Pe="vaultd-grpc",L=18,R=4,X=-47,Se=1,M=64,Ae=128,Ee=96,me=64,Te=1,Ce=2,Re=3,Oe=4,$e=5,Ie=6,He=7,B=new TextEncoder().encode("Signature1");class c extends Error{constructor(e,t){super(e),this.reason=t,this.name="CwtVerificationError"}}function Ne(r){const e=G(r.expectedIssuerXOnlyPubkey,"expectedIssuerXOnlyPubkey"),t=G(r.expectedAudienceXOnlyPubkey,"expectedAudienceXOnlyPubkey"),n=Ge(r.ephemeralPubkeyHex),s=Je(r.token),i=new K(s),o=i.readHead();if(o.major!==6||o.arg!==L)throw new c(`token is not a COSE Sign1 tagged value (tag ${L})`,"invalid_token_structure");const a=i.readHead();if(a.major!==4||a.arg!==R)throw new c(`COSE Sign1 must be a ${R}-element array`,"invalid_token_structure");const g=i.pos,l=i.readByteString(),p=s.subarray(g,i.pos);i.readValue();const b=i.pos,x=i.readByteString(),P=s.subarray(b,i.pos),S=i.readByteString();if(S.length!==M)throw new c(`COSE signature must be ${M} bytes, got ${S.length}`,"invalid_token_structure");if(i.pos!==s.length)throw new c("COSE Sign1 token has trailing bytes after the signature","invalid_token_structure");const $=Le(l);if($!==X)throw new c(`unexpected COSE algorithm ${$} (expected ES256K ${X})`,"unexpected_algorithm");const Y=Xe(p,P),W=ne.sha256(Y);if(!J.verify(W,n,S,!0))throw new c("COSE signature does not verify against the server's ephemeral key","signature_verification_failed");const d=Me(x),w=d.audience.toLowerCase();if(w.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(w))throw new c("token `aud` is not a 32-byte x-only pubkey hex","invalid_claims");if(d.issuedAt>d.expiresAt)throw new c(`token iat (${d.issuedAt}) is after exp (${d.expiresAt})`,"invalid_claims");if(d.issuer.toLowerCase()!==e)throw new c(`token issuer does not match pinned server pubkey: expected ${e}, got ${d.issuer.toLowerCase()}`,"issuer_mismatch");if(d.subject!==r.expectedSubject)throw new c(`token subject mismatch: expected ${r.expectedSubject}, got ${d.subject}`,"subject_mismatch");if(w!==t)throw new c(`token audience does not match depositor pubkey: expected ${t}, got ${w}`,"audience_mismatch");if(d.expiresAt<=r.now)throw new c(`token expired: exp ${d.expiresAt} <= now ${r.now}`,"token_expired");if(r.responseExpiresAt!==d.expiresAt)throw new c(`response expires_at (${r.responseExpiresAt}) does not equal token exp (${d.expiresAt})`,"expiry_mismatch");if(r.serverIdentityExpiresAt<d.expiresAt)throw new c(`server identity expires (${r.serverIdentityExpiresAt}) before token exp (${d.expiresAt})`,"server_identity_expires_before_token");return{issuer:d.issuer,subject:d.subject,audience:w,expiresAt:d.expiresAt,notBefore:d.notBefore,issuedAt:d.issuedAt}}function Le(r){if(r.length===0)throw new c("empty COSE protected header (no algorithm)","unexpected_algorithm");const e=F(r);if(!(e instanceof Map))throw new c("COSE protected header is not a map","invalid_token_structure");const t=e.get(Se);if(typeof t!="number")throw new c("COSE protected header missing integer algorithm label","unexpected_algorithm");return t}function Xe(r,e){return Ve(Uint8Array.of(Ae|R),Uint8Array.of(Ee|B.length),B,r,Uint8Array.of(me),e)}function Me(r){const e=F(r);if(!(e instanceof Map))throw new c("CWT claims root is not a map","invalid_claims");if(Be(e,He,"cti").length===0)throw new c("token cti is empty","invalid_claims");return{issuer:E(e,Te,"iss"),subject:E(e,Ce,"sub"),audience:E(e,Re,"aud"),expiresAt:m(e,Oe,"exp"),notBefore:m(e,$e,"nbf"),issuedAt:m(e,Ie,"iat")}}function E(r,e,t){const n=r.get(e);if(typeof n!="string")throw new c(`token claim ${t} is missing or not a text string`,"invalid_claims");return n}function Be(r,e,t){const n=r.get(e);if(!(n instanceof Uint8Array))throw new c(`token claim ${t} is missing or not a byte string`,"invalid_claims");return n}function m(r,e,t){const n=r.get(e);if(typeof n!="number"||!Number.isSafeInteger(n)||n<0)throw new c(`token claim ${t} is missing or not a non-negative integer timestamp`,"invalid_claims");return n}function G(r,e){const t=_.stripHexPrefix(r).toLowerCase();if(t.length!==y.X_ONLY_PUBKEY_HEX_LEN||!y.HEX_RE.test(t))throw new c(`${e} must be 32-byte x-only hex; got ${t.length} chars`,"invalid_input");return t}function Ge(r){const e=_.stripHexPrefix(r).toLowerCase(),t=e.slice(0,2);if(e.length!==y.COMPRESSED_PUBKEY_HEX_LEN||!y.HEX_RE.test(e)||t!=="02"&&t!=="03")throw new c("ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)","invalid_input");return _.hexToUint8Array(e)}const Ue=(()=>{const r=new Int16Array(128).fill(-1),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(let t=0;t<e.length;t++)r[e.charCodeAt(t)]=t;return r})();function Je(r){const e=r.length,t=Math.floor(e/4),n=e%4;if(n===1)throw new c("invalid base64url length","invalid_token_structure");const s=t*3+(n===0?0:n-1),i=new Uint8Array(s),o=l=>{const p=l<128?Ue[l]:-1;if(p<0)throw new c("invalid base64url character","invalid_token_structure");return p};let a=0,g=0;for(let l=0;l<t;l++){const p=o(r.charCodeAt(a++)),b=o(r.charCodeAt(a++)),x=o(r.charCodeAt(a++)),P=o(r.charCodeAt(a++));i[g++]=p<<2|b>>4,i[g++]=(b&15)<<4|x>>2,i[g++]=(x&3)<<6|P}if(n===2){const l=o(r.charCodeAt(a++)),p=o(r.charCodeAt(a++));i[g++]=l<<2|p>>4}else if(n===3){const l=o(r.charCodeAt(a++)),p=o(r.charCodeAt(a++)),b=o(r.charCodeAt(a++));i[g++]=l<<2|p>>4,i[g++]=(p&15)<<4|b>>2}return i}function Ve(...r){const e=r.reduce((s,i)=>s+i.length,0),t=new Uint8Array(e);let n=0;for(const s of r)t.set(s,n),n+=s.length;return t}const U=4102444800,De=30;class je{constructor(e){u(this,"client");u(this,"peginTxid");u(this,"authAnchorHex");u(this,"jsonRpcPinnedServerPubkey");u(this,"grpcPinnedServerPubkey");u(this,"refreshJsonRpcPinnedServerPubkey");u(this,"expectedAudienceXOnlyPubkey");u(this,"authGatedMethods");u(this,"grpcGatedMethods");u(this,"refreshSkewSecs");u(this,"now");u(this,"cachedJsonRpc",null);u(this,"inFlightJsonRpc",null);u(this,"cachedGrpc",null);u(this,"inFlightGrpc",null);this.client=e.client,this.peginTxid=e.peginTxid,this.authAnchorHex=e.authAnchorHex,this.jsonRpcPinnedServerPubkey=e.pinnedServerPubkey,this.grpcPinnedServerPubkey=e.grpcPinnedServerPubkey,this.refreshJsonRpcPinnedServerPubkey=e.refreshJsonRpcPinnedServerPubkey,this.expectedAudienceXOnlyPubkey=e.expectedAudienceXOnlyPubkey,this.authGatedMethods=e.authGatedMethods,this.grpcGatedMethods=e.grpcGatedMethods,this.refreshSkewSecs=e.refreshSkewSecs??De,this.now=e.now??(()=>Math.floor(Date.now()/1e3))}async getToken(e){return e===T||e===C?null:this.grpcGatedMethods.has(e)?this.getTokenForSubject("grpc"):this.authGatedMethods.has(e)?this.getTokenForSubject("jsonrpc"):null}getJsonRpcToken(){return this.getTokenForSubject("jsonrpc")}invalidate(){this.cachedJsonRpc=null,this.cachedGrpc=null}async getTokenForSubject(e){const t=e==="grpc"?this.cachedGrpc:this.cachedJsonRpc;return t&&this.now()+this.refreshSkewSecs<t.expiresAt?t.token:(await this.acquireSingleFlight(e)).token}setClient(e){this.client=e}getPinnedServerPubkey(e){return e==="grpc"?this.grpcPinnedServerPubkey:this.jsonRpcPinnedServerPubkey}acquireSingleFlight(e){const t=e==="grpc"?this.inFlightGrpc:this.inFlightJsonRpc;if(t)return t;const n=e==="grpc"?C:T,s=(async()=>{try{const i=await this.acquireAndVerify(e,n,!0);return e==="grpc"?this.cachedGrpc=i:this.cachedJsonRpc=i,i}finally{e==="grpc"?this.inFlightGrpc=null:this.inFlightJsonRpc=null}})();return e==="grpc"?this.inFlightGrpc=s:this.inFlightJsonRpc=s,s}async acquireAndVerify(e,t,n){const s=await this.client.call(t,{pegin_txid:this.peginTxid,auth_anchor:this.authAnchorHex}),i=this.getPinnedServerPubkey(e);try{if(D({proof:s.server_identity,pinnedServerPubkey:i,now:this.now()}),typeof s.token!="string"||s.token.length===0)throw new Error(`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`);const o=this.now();if(!Number.isSafeInteger(s.expires_at)||s.expires_at<=o||s.expires_at>U)throw new Error(`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${o}, ${U}])`);return Ne({token:s.token,ephemeralPubkeyHex:s.server_identity.ephemeral_pubkey,expectedIssuerXOnlyPubkey:i,expectedSubject:e==="grpc"?Pe:ke,expectedAudienceXOnlyPubkey:this.expectedAudienceXOnlyPubkey,responseExpiresAt:s.expires_at,serverIdentityExpiresAt:s.server_identity.expires_at,now:o}),{token:s.token,expiresAt:s.expires_at}}catch(o){if(n&&e==="jsonrpc"&&this.refreshJsonRpcPinnedServerPubkey&&Ke(o)){const a=await this.refreshJsonRpcPinnedServerPubkey();if(a!==this.jsonRpcPinnedServerPubkey)return this.jsonRpcPinnedServerPubkey=a,this.acquireAndVerify(e,t,!1)}throw o}}}function Ke(r){return r instanceof h&&r.reason==="pinned_pubkey_mismatch"||r instanceof c&&r.reason==="issuer_mismatch"}class q{constructor(){u(this,"entries",new Map)}getOrCreate(e){const t=this.entries.get(e.peginTxid);if(t){if(t.authAnchorHex!==e.authAnchorHex)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${t.authAnchorHex.slice(0,8)}…; got ${e.authAnchorHex.slice(0,8)}…`);if(t.providerAddress.toLowerCase()!==e.providerAddress.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to providerAddress ${t.providerAddress}; got ${e.providerAddress}`);if(t.provider.getPinnedServerPubkey("jsonrpc")!==e.pinnedServerPubkey)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to JSON-RPC pinnedServerPubkey ${t.provider.getPinnedServerPubkey("jsonrpc").slice(0,8)}…; got ${e.pinnedServerPubkey.slice(0,8)}…`);if(t.provider.getPinnedServerPubkey("grpc")!==e.grpcPinnedServerPubkey)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to gRPC pinnedServerPubkey ${t.provider.getPinnedServerPubkey("grpc").slice(0,8)}…; got ${e.grpcPinnedServerPubkey.slice(0,8)}…`);if(t.grpcKeyEpoch!==e.grpcKeyEpoch)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to gRPC key epoch ${t.grpcKeyEpoch.toString()}; got ${e.grpcKeyEpoch.toString()}`);if(t.expectedAudienceXOnlyPubkey.toLowerCase()!==e.expectedAudienceXOnlyPubkey.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to expectedAudienceXOnlyPubkey ${t.expectedAudienceXOnlyPubkey.slice(0,8)}…; got ${e.expectedAudienceXOnlyPubkey.slice(0,8)}…`);return t.provider.setClient(e.client),t.provider}const n=new je({client:e.client,peginTxid:e.peginTxid,authAnchorHex:e.authAnchorHex,pinnedServerPubkey:e.pinnedServerPubkey,grpcPinnedServerPubkey:e.grpcPinnedServerPubkey,refreshJsonRpcPinnedServerPubkey:e.refreshJsonRpcPinnedServerPubkey,expectedAudienceXOnlyPubkey:e.expectedAudienceXOnlyPubkey,authGatedMethods:ae,grpcGatedMethods:de});return this.entries.set(e.peginTxid,{provider:n,authAnchorHex:e.authAnchorHex,providerAddress:e.providerAddress,grpcKeyEpoch:e.grpcKeyEpoch,expectedAudienceXOnlyPubkey:e.expectedAudienceXOnlyPubkey}),n}peek(e){const t=this.entries.get(e.peginTxid);if(t){if(t.providerAddress.toLowerCase()!==e.providerAddress.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to providerAddress ${t.providerAddress}; got ${e.providerAddress}`);if(t.expectedAudienceXOnlyPubkey.toLowerCase()!==e.expectedAudienceXOnlyPubkey.toLowerCase())throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to expectedAudienceXOnlyPubkey ${t.expectedAudienceXOnlyPubkey.slice(0,8)}…; got ${e.expectedAudienceXOnlyPubkey.slice(0,8)}…`);return t.provider}}release(e){this.entries.delete(e)}clear(){this.entries.clear()}get size(){return this.entries.size}}const O=new q;function Fe(r){var n;const e=j(r.baseUrl,(n=r.options)==null?void 0:n.headers),t=O.getOrCreate({client:e,peginTxid:r.peginTxid,authAnchorHex:r.authAnchorHex,providerAddress:r.providerAddress,pinnedServerPubkey:r.pinnedServerPubkey,grpcPinnedServerPubkey:r.grpcPinnedServerPubkey,grpcKeyEpoch:r.grpcKeyEpoch,refreshJsonRpcPinnedServerPubkey:r.refreshJsonRpcPinnedServerPubkey,expectedAudienceXOnlyPubkey:_.processPublicKeyToXOnly(r.depositorBtcPubkey)});return new Z.VaultProviderRpcClient(r.baseUrl,{...r.options,tokenProvider:t})}function qe(r){O.getOrCreate({client:j(r.baseUrl,r.headers),peginTxid:r.peginTxid,authAnchorHex:r.authAnchorHex,providerAddress:r.providerAddress,pinnedServerPubkey:r.pinnedServerPubkey,grpcPinnedServerPubkey:r.grpcPinnedServerPubkey,grpcKeyEpoch:r.grpcKeyEpoch,refreshJsonRpcPinnedServerPubkey:r.refreshJsonRpcPinnedServerPubkey,expectedAudienceXOnlyPubkey:_.processPublicKeyToXOnly(r.depositorBtcPubkey)})}exports.ServerIdentityError=h;exports.VpTokenRegistry=q;exports.createAuthenticatedVpClient=Fe;exports.primeVpTokenRegistry=qe;exports.verifyServerIdentity=D;exports.vpTokenRegistry=O;
2
+ //# sourceMappingURL=primeVpAuth-36ayVa21.cjs.map