@hfunlabs/hyperliquid 0.30.0-hfunlabs.1 → 0.30.2-hfunlabs.2
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/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +58 -0
- package/esm/_dnt.shims.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +457 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +207 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +555 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1222 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +283 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +241 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +147 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +67 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +90 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +397 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +254 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +243 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +144 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +96 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +98 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +535 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +207 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +298 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +6 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +180 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2001 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.js +704 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +137 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
- package/esm/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
- package/esm/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/_base/_nonce.js +3 -2
- package/esm/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
- package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
- package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/_base/_semaphore.js +34 -47
- package/esm/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
- package/esm/src/api/exchange/_methods/_base/execute.d.ts +14 -3
- package/esm/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/_base/execute.js +44 -10
- package/esm/src/api/exchange/_methods/_base/execute.js.map +1 -1
- package/esm/src/api/exchange/_methods/batchModify.d.ts +6 -6
- package/esm/src/api/exchange/_methods/createVault.d.ts +5 -5
- package/esm/src/api/exchange/_methods/modify.d.ts +5 -5
- package/esm/src/api/exchange/_methods/order.d.ts +13 -13
- package/esm/src/api/exchange/_methods/order.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/order.js +4 -2
- package/esm/src/api/exchange/_methods/order.js.map +1 -1
- package/esm/src/api/exchange/client.d.ts +1 -1
- package/esm/src/api/exchange/client.d.ts.map +1 -1
- package/esm/src/api/exchange/client.js.map +1 -1
- package/esm/src/api/exchange/mod.d.ts +1 -1
- package/esm/src/api/exchange/mod.d.ts.map +1 -1
- package/esm/src/api/exchange/mod.js.map +1 -1
- package/esm/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
- package/esm/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
- package/esm/src/api/info/_methods/historicalOrders.d.ts +4 -4
- package/esm/src/api/info/_methods/l3Orders.d.ts +11 -11
- package/esm/src/api/info/_methods/l4Orders.d.ts +6 -6
- package/esm/src/api/info/_methods/openOrders.d.ts +3 -3
- package/esm/src/api/info/_methods/orderStatus.d.ts +5 -5
- package/esm/src/api/info/_methods/recentTrades.d.ts +2 -2
- package/esm/src/api/info/_methods/twapHistory.d.ts +4 -4
- package/esm/src/api/info/_methods/userFills.d.ts +3 -3
- package/esm/src/api/info/_methods/userFillsByTime.d.ts +4 -4
- package/esm/src/api/info/_methods/userFunding.d.ts +3 -3
- package/esm/src/api/info/_methods/userFunding.js +2 -2
- package/esm/src/api/info/_methods/userFunding.js.map +1 -1
- package/esm/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
- package/esm/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
- package/esm/src/api/info/_methods/webData2.d.ts +9 -9
- package/esm/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
- package/esm/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/assetCtxs.js.map +1 -1
- package/esm/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
- package/esm/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/clearinghouseState.js +2 -0
- package/esm/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
- package/esm/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
- package/esm/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/explorerBlock.js +2 -0
- package/esm/src/api/subscription/_methods/explorerBlock.js.map +1 -1
- package/esm/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
- package/esm/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/explorerTxs.js +2 -0
- package/esm/src/api/subscription/_methods/explorerTxs.js.map +1 -1
- package/esm/src/api/subscription/_methods/openOrders.d.ts +5 -5
- package/esm/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
- package/esm/src/api/subscription/_methods/trades.d.ts +3 -3
- package/esm/src/api/subscription/_methods/twapStates.d.ts +9 -4
- package/esm/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/twapStates.js +6 -1
- package/esm/src/api/subscription/_methods/twapStates.js.map +1 -1
- package/esm/src/api/subscription/_methods/userEvents.d.ts +17 -17
- package/esm/src/api/subscription/_methods/userFills.d.ts +5 -5
- package/esm/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
- package/esm/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
- package/esm/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
- package/esm/src/api/subscription/_methods/webData2.d.ts +11 -11
- package/esm/src/signing/_privateKeySigner.js +1 -1
- package/esm/src/signing/_privateKeySigner.js.map +1 -1
- package/esm/src/signing/mod.js +1 -1
- package/esm/src/signing/mod.js.map +1 -1
- package/package.json +2 -3
- package/script/_dnt.shims.d.ts +2 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +61 -0
- package/script/_dnt.shims.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +468 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +215 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +578 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1232 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +286 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +273 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +153 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +90 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +95 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +439 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +259 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +304 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +182 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +99 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +134 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +576 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +211 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +308 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +21 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +195 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2032 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.js +710 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +141 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
- package/script/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
- package/script/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/_base/_nonce.js +4 -3
- package/script/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
- package/script/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
- package/script/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/_base/_semaphore.js +35 -50
- package/script/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
- package/script/src/api/exchange/_methods/_base/execute.d.ts +14 -3
- package/script/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/_base/execute.js +43 -9
- package/script/src/api/exchange/_methods/_base/execute.js.map +1 -1
- package/script/src/api/exchange/_methods/batchModify.d.ts +6 -6
- package/script/src/api/exchange/_methods/createVault.d.ts +5 -5
- package/script/src/api/exchange/_methods/modify.d.ts +5 -5
- package/script/src/api/exchange/_methods/order.d.ts +13 -13
- package/script/src/api/exchange/_methods/order.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/order.js +4 -2
- package/script/src/api/exchange/_methods/order.js.map +1 -1
- package/script/src/api/exchange/client.d.ts +1 -1
- package/script/src/api/exchange/client.d.ts.map +1 -1
- package/script/src/api/exchange/client.js.map +1 -1
- package/script/src/api/exchange/mod.d.ts +1 -1
- package/script/src/api/exchange/mod.d.ts.map +1 -1
- package/script/src/api/exchange/mod.js.map +1 -1
- package/script/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
- package/script/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
- package/script/src/api/info/_methods/historicalOrders.d.ts +4 -4
- package/script/src/api/info/_methods/l3Orders.d.ts +11 -11
- package/script/src/api/info/_methods/l4Orders.d.ts +6 -6
- package/script/src/api/info/_methods/openOrders.d.ts +3 -3
- package/script/src/api/info/_methods/orderStatus.d.ts +5 -5
- package/script/src/api/info/_methods/recentTrades.d.ts +2 -2
- package/script/src/api/info/_methods/twapHistory.d.ts +4 -4
- package/script/src/api/info/_methods/userFills.d.ts +3 -3
- package/script/src/api/info/_methods/userFillsByTime.d.ts +4 -4
- package/script/src/api/info/_methods/userFunding.d.ts +3 -3
- package/script/src/api/info/_methods/userFunding.js +2 -2
- package/script/src/api/info/_methods/userFunding.js.map +1 -1
- package/script/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
- package/script/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
- package/script/src/api/info/_methods/webData2.d.ts +9 -9
- package/script/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
- package/script/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/assetCtxs.js.map +1 -1
- package/script/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
- package/script/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/clearinghouseState.js +2 -0
- package/script/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
- package/script/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
- package/script/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/explorerBlock.js +2 -0
- package/script/src/api/subscription/_methods/explorerBlock.js.map +1 -1
- package/script/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
- package/script/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/explorerTxs.js +2 -0
- package/script/src/api/subscription/_methods/explorerTxs.js.map +1 -1
- package/script/src/api/subscription/_methods/openOrders.d.ts +5 -5
- package/script/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
- package/script/src/api/subscription/_methods/trades.d.ts +3 -3
- package/script/src/api/subscription/_methods/twapStates.d.ts +9 -4
- package/script/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/twapStates.js +6 -1
- package/script/src/api/subscription/_methods/twapStates.js.map +1 -1
- package/script/src/api/subscription/_methods/userEvents.d.ts +17 -17
- package/script/src/api/subscription/_methods/userFills.d.ts +5 -5
- package/script/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
- package/script/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
- package/script/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
- package/script/src/api/subscription/_methods/webData2.d.ts +11 -11
- package/script/src/signing/_privateKeySigner.js +3 -3
- package/script/src/signing/_privateKeySigner.js.map +1 -1
- package/script/src/signing/mod.js +2 -2
- package/script/src/signing/mod.js.map +1 -1
- package/src/_dnt.shims.ts +60 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.ts +633 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.ts +292 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.ts +621 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.ts +1562 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.ts +327 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/utils.ts +306 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_md.ts +156 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.ts +91 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.ts +94 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.ts +469 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.ts +295 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/utils.ts +340 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.ts +212 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.ts +100 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.ts +104 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.ts +626 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.ts +274 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.ts +391 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.ts +12 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.ts +233 -0
- package/src/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.ts +2196 -0
- package/src/deps/jsr.io/@scure/base/2.0.0/index.ts +857 -0
- package/src/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.ts +146 -0
- package/src/src/api/exchange/_methods/_base/_nonce.ts +3 -2
- package/src/src/api/exchange/_methods/_base/_semaphore.ts +34 -59
- package/src/src/api/exchange/_methods/_base/execute.ts +60 -12
- package/src/src/api/exchange/_methods/order.ts +5 -3
- package/src/src/api/exchange/client.ts +5 -1
- package/src/src/api/exchange/mod.ts +5 -1
- package/src/src/api/info/_methods/userFunding.ts +2 -2
- package/src/src/api/subscription/_methods/assetCtxs.ts +2 -0
- package/src/src/api/subscription/_methods/clearinghouseState.ts +2 -0
- package/src/src/api/subscription/_methods/explorerBlock.ts +2 -0
- package/src/src/api/subscription/_methods/explorerTxs.ts +2 -0
- package/src/src/api/subscription/_methods/twapStates.ts +9 -1
- package/src/src/signing/_privateKeySigner.ts +1 -1
- package/src/src/signing/mod.ts +1 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -292
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -46
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -295
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -62
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
- package/src/deps/jsr.io/@std/msgpack/1.0.3/decode.ts +0 -391
- package/src/deps/jsr.io/@std/msgpack/1.0.3/mod.ts +0 -47
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
3
|
+
* Different from older hashes, the internal state is bigger than output size.
|
|
4
|
+
*
|
|
5
|
+
* Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
|
|
6
|
+
* [Website](https://keccak.team/keccak.html),
|
|
7
|
+
* [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
|
|
8
|
+
*
|
|
9
|
+
* Check out `sha3-addons` module for cSHAKE, k12, and others.
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
import { abytes, aexists, anumber, aoutput, clean, createHasher, oidNist, swap32IfBE, u32 } from './utils.js';
|
|
15
|
+
// No __PURE__ annotations in sha3 header:
|
|
16
|
+
// EVERYTHING is in fact used on every export.
|
|
17
|
+
// Various per round constants calculations
|
|
18
|
+
const _0n = BigInt(0);
|
|
19
|
+
const _1n = BigInt(1);
|
|
20
|
+
const _2n = BigInt(2);
|
|
21
|
+
const _7n = BigInt(7);
|
|
22
|
+
const _256n = BigInt(256);
|
|
23
|
+
const _0x71n = BigInt(0x71);
|
|
24
|
+
const SHA3_PI = [];
|
|
25
|
+
const SHA3_ROTL = [];
|
|
26
|
+
const _SHA3_IOTA = []; // no pure annotation: var is always used
|
|
27
|
+
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
28
|
+
// Pi
|
|
29
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
30
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
31
|
+
// Rotational
|
|
32
|
+
SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
|
|
33
|
+
// Iota
|
|
34
|
+
let t = _0n;
|
|
35
|
+
for (let j = 0; j < 7; j++) {
|
|
36
|
+
R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
|
|
37
|
+
if (R & _2n)
|
|
38
|
+
t ^= _1n << ((_1n << BigInt(j)) - _1n);
|
|
39
|
+
}
|
|
40
|
+
_SHA3_IOTA.push(t);
|
|
41
|
+
}
|
|
42
|
+
const IOTAS = split(_SHA3_IOTA, true);
|
|
43
|
+
const SHA3_IOTA_H = IOTAS[0];
|
|
44
|
+
const SHA3_IOTA_L = IOTAS[1];
|
|
45
|
+
// Left rotation (without 0, 32, 64)
|
|
46
|
+
const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
|
|
47
|
+
const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
|
|
48
|
+
/** `keccakf1600` internal function, additionally allows to adjust round count. */
|
|
49
|
+
export function keccakP(s, rounds = 24) {
|
|
50
|
+
const B = new Uint32Array(5 * 2);
|
|
51
|
+
// NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
|
|
52
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
53
|
+
// Theta θ
|
|
54
|
+
for (let x = 0; x < 10; x++)
|
|
55
|
+
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
56
|
+
for (let x = 0; x < 10; x += 2) {
|
|
57
|
+
const idx1 = (x + 8) % 10;
|
|
58
|
+
const idx0 = (x + 2) % 10;
|
|
59
|
+
const B0 = B[idx0];
|
|
60
|
+
const B1 = B[idx0 + 1];
|
|
61
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
62
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
63
|
+
for (let y = 0; y < 50; y += 10) {
|
|
64
|
+
s[x + y] ^= Th;
|
|
65
|
+
s[x + y + 1] ^= Tl;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Rho (ρ) and Pi (π)
|
|
69
|
+
let curH = s[2];
|
|
70
|
+
let curL = s[3];
|
|
71
|
+
for (let t = 0; t < 24; t++) {
|
|
72
|
+
const shift = SHA3_ROTL[t];
|
|
73
|
+
const Th = rotlH(curH, curL, shift);
|
|
74
|
+
const Tl = rotlL(curH, curL, shift);
|
|
75
|
+
const PI = SHA3_PI[t];
|
|
76
|
+
curH = s[PI];
|
|
77
|
+
curL = s[PI + 1];
|
|
78
|
+
s[PI] = Th;
|
|
79
|
+
s[PI + 1] = Tl;
|
|
80
|
+
}
|
|
81
|
+
// Chi (χ)
|
|
82
|
+
for (let y = 0; y < 50; y += 10) {
|
|
83
|
+
for (let x = 0; x < 10; x++)
|
|
84
|
+
B[x] = s[y + x];
|
|
85
|
+
for (let x = 0; x < 10; x++)
|
|
86
|
+
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
87
|
+
}
|
|
88
|
+
// Iota (ι)
|
|
89
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
90
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
91
|
+
}
|
|
92
|
+
clean(B);
|
|
93
|
+
}
|
|
94
|
+
/** Keccak sponge function. */
|
|
95
|
+
export class Keccak {
|
|
96
|
+
state;
|
|
97
|
+
pos = 0;
|
|
98
|
+
posOut = 0;
|
|
99
|
+
finished = false;
|
|
100
|
+
state32;
|
|
101
|
+
destroyed = false;
|
|
102
|
+
blockLen;
|
|
103
|
+
suffix;
|
|
104
|
+
outputLen;
|
|
105
|
+
enableXOF = false;
|
|
106
|
+
rounds;
|
|
107
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
108
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
109
|
+
this.blockLen = blockLen;
|
|
110
|
+
this.suffix = suffix;
|
|
111
|
+
this.outputLen = outputLen;
|
|
112
|
+
this.enableXOF = enableXOF;
|
|
113
|
+
this.rounds = rounds;
|
|
114
|
+
// Can be passed from user as dkLen
|
|
115
|
+
anumber(outputLen, 'outputLen');
|
|
116
|
+
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
|
117
|
+
// 0 < blockLen < 200
|
|
118
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
119
|
+
throw new Error('only keccak-f1600 function is supported');
|
|
120
|
+
this.state = new Uint8Array(200);
|
|
121
|
+
this.state32 = u32(this.state);
|
|
122
|
+
}
|
|
123
|
+
clone() {
|
|
124
|
+
return this._cloneInto();
|
|
125
|
+
}
|
|
126
|
+
keccak() {
|
|
127
|
+
swap32IfBE(this.state32);
|
|
128
|
+
keccakP(this.state32, this.rounds);
|
|
129
|
+
swap32IfBE(this.state32);
|
|
130
|
+
this.posOut = 0;
|
|
131
|
+
this.pos = 0;
|
|
132
|
+
}
|
|
133
|
+
update(data) {
|
|
134
|
+
aexists(this);
|
|
135
|
+
abytes(data);
|
|
136
|
+
const { blockLen, state } = this;
|
|
137
|
+
const len = data.length;
|
|
138
|
+
for (let pos = 0; pos < len;) {
|
|
139
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
140
|
+
for (let i = 0; i < take; i++)
|
|
141
|
+
state[this.pos++] ^= data[pos++];
|
|
142
|
+
if (this.pos === blockLen)
|
|
143
|
+
this.keccak();
|
|
144
|
+
}
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
finish() {
|
|
148
|
+
if (this.finished)
|
|
149
|
+
return;
|
|
150
|
+
this.finished = true;
|
|
151
|
+
const { state, suffix, pos, blockLen } = this;
|
|
152
|
+
// Do the padding
|
|
153
|
+
state[pos] ^= suffix;
|
|
154
|
+
if ((suffix & 0x80) !== 0 && pos === blockLen - 1)
|
|
155
|
+
this.keccak();
|
|
156
|
+
state[blockLen - 1] ^= 0x80;
|
|
157
|
+
this.keccak();
|
|
158
|
+
}
|
|
159
|
+
writeInto(out) {
|
|
160
|
+
aexists(this, false);
|
|
161
|
+
abytes(out);
|
|
162
|
+
this.finish();
|
|
163
|
+
const bufferOut = this.state;
|
|
164
|
+
const { blockLen } = this;
|
|
165
|
+
for (let pos = 0, len = out.length; pos < len;) {
|
|
166
|
+
if (this.posOut >= blockLen)
|
|
167
|
+
this.keccak();
|
|
168
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
169
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
170
|
+
this.posOut += take;
|
|
171
|
+
pos += take;
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
xofInto(out) {
|
|
176
|
+
// Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
|
|
177
|
+
if (!this.enableXOF)
|
|
178
|
+
throw new Error('XOF is not possible for this instance');
|
|
179
|
+
return this.writeInto(out);
|
|
180
|
+
}
|
|
181
|
+
xof(bytes) {
|
|
182
|
+
anumber(bytes);
|
|
183
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
184
|
+
}
|
|
185
|
+
digestInto(out) {
|
|
186
|
+
aoutput(out, this);
|
|
187
|
+
if (this.finished)
|
|
188
|
+
throw new Error('digest() was already called');
|
|
189
|
+
this.writeInto(out);
|
|
190
|
+
this.destroy();
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
digest() {
|
|
194
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
195
|
+
}
|
|
196
|
+
destroy() {
|
|
197
|
+
this.destroyed = true;
|
|
198
|
+
clean(this.state);
|
|
199
|
+
}
|
|
200
|
+
_cloneInto(to) {
|
|
201
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
202
|
+
to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
|
|
203
|
+
to.state32.set(this.state32);
|
|
204
|
+
to.pos = this.pos;
|
|
205
|
+
to.posOut = this.posOut;
|
|
206
|
+
to.finished = this.finished;
|
|
207
|
+
to.rounds = rounds;
|
|
208
|
+
// Suffix can change in cSHAKE
|
|
209
|
+
to.suffix = suffix;
|
|
210
|
+
to.outputLen = outputLen;
|
|
211
|
+
to.enableXOF = enableXOF;
|
|
212
|
+
to.destroyed = this.destroyed;
|
|
213
|
+
return to;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
|
|
217
|
+
/** SHA3-224 hash function. */
|
|
218
|
+
export const sha3_224 = /* @__PURE__ */ genKeccak(0x06, 144, 28,
|
|
219
|
+
/* @__PURE__ */ oidNist(0x07));
|
|
220
|
+
/** SHA3-256 hash function. Different from keccak-256. */
|
|
221
|
+
export const sha3_256 = /* @__PURE__ */ genKeccak(0x06, 136, 32,
|
|
222
|
+
/* @__PURE__ */ oidNist(0x08));
|
|
223
|
+
/** SHA3-384 hash function. */
|
|
224
|
+
export const sha3_384 = /* @__PURE__ */ genKeccak(0x06, 104, 48,
|
|
225
|
+
/* @__PURE__ */ oidNist(0x09));
|
|
226
|
+
/** SHA3-512 hash function. */
|
|
227
|
+
export const sha3_512 = /* @__PURE__ */ genKeccak(0x06, 72, 64,
|
|
228
|
+
/* @__PURE__ */ oidNist(0x0a));
|
|
229
|
+
/** keccak-224 hash function. */
|
|
230
|
+
export const keccak_224 = /* @__PURE__ */ genKeccak(0x01, 144, 28);
|
|
231
|
+
/** keccak-256 hash function. Different from SHA3-256. */
|
|
232
|
+
export const keccak_256 = /* @__PURE__ */ genKeccak(0x01, 136, 32);
|
|
233
|
+
/** keccak-384 hash function. */
|
|
234
|
+
export const keccak_384 = /* @__PURE__ */ genKeccak(0x01, 104, 48);
|
|
235
|
+
/** keccak-512 hash function. */
|
|
236
|
+
export const keccak_512 = /* @__PURE__ */ genKeccak(0x01, 72, 64);
|
|
237
|
+
const genShake = (suffix, blockLen, outputLen, info = {}) => createHasher((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true), info);
|
|
238
|
+
/** SHAKE128 XOF with 128-bit security. */
|
|
239
|
+
export const shake128 =
|
|
240
|
+
/* @__PURE__ */
|
|
241
|
+
genShake(0x1f, 168, 16, /* @__PURE__ */ oidNist(0x0b));
|
|
242
|
+
/** SHAKE256 XOF with 256-bit security. */
|
|
243
|
+
export const shake256 =
|
|
244
|
+
/* @__PURE__ */
|
|
245
|
+
genShake(0x1f, 136, 32, /* @__PURE__ */ oidNist(0x0c));
|
|
246
|
+
/** SHAKE128 XOF with 256-bit output (NIST version). */
|
|
247
|
+
export const shake128_32 =
|
|
248
|
+
/* @__PURE__ */
|
|
249
|
+
genShake(0x1f, 168, 32, /* @__PURE__ */ oidNist(0x0b));
|
|
250
|
+
/** SHAKE256 XOF with 512-bit output (NIST version). */
|
|
251
|
+
export const shake256_64 =
|
|
252
|
+
/* @__PURE__ */
|
|
253
|
+
genShake(0x1f, 136, 64, /* @__PURE__ */ oidNist(0x0c));
|
|
254
|
+
//# sourceMappingURL=sha3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha3.js","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClE,kBAAkB;AAClB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EACjC,KAAK,EAAE,YAAY,EACnB,OAAO,EACP,UAAU,EACV,GAAG,EAKJ,MAAM,YAAY,CAAC;AAEpB,0CAA0C;AAC1C,8CAA8C;AAC9C,2CAA2C;AAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5B,MAAM,OAAO,GAAa,EAAE,CAAC;AAC7B,MAAM,SAAS,GAAa,EAAE,CAAC;AAC/B,MAAM,UAAU,GAAa,EAAE,CAAC,CAAC,yCAAyC;AAC1E,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CA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C,MAAM,QAAQ;AACnB,eAAe;AACf,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,0CAA0C;AAC1C,MAAM,CAAC,MAAM,QAAQ;AACnB,eAAe;AACf,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAEzD,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW;AACtB,eAAe;AACf,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW;AACtB,eAAe;AACf,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export declare function isBytes(a: unknown): a is Uint8Array;
|
|
2
|
+
/** Asserts something is positive integer. */
|
|
3
|
+
export declare function anumber(n: number, title?: string): void;
|
|
4
|
+
/** Asserts something is Uint8Array. */
|
|
5
|
+
export declare function abytes(value: Uint8Array, length?: number, title?: string): Uint8Array;
|
|
6
|
+
/** Asserts something is hash */
|
|
7
|
+
export declare function ahash(h: CHash): void;
|
|
8
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
9
|
+
export declare function aexists(instance: any, checkFinished?: boolean): void;
|
|
10
|
+
/** Asserts output is properly-sized byte array */
|
|
11
|
+
export declare function aoutput(out: any, instance: any): void;
|
|
12
|
+
/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */
|
|
13
|
+
export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array;
|
|
14
|
+
/** Cast u8 / u16 / u32 to u8. */
|
|
15
|
+
export declare function u8(arr: TypedArray): Uint8Array;
|
|
16
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
17
|
+
export declare function u32(arr: TypedArray): Uint32Array;
|
|
18
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
19
|
+
export declare function clean(...arrays: TypedArray[]): void;
|
|
20
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
21
|
+
export declare function createView(arr: TypedArray): DataView;
|
|
22
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
23
|
+
export declare function rotr(word: number, shift: number): number;
|
|
24
|
+
/** The rotate left (circular left shift) operation for uint32 */
|
|
25
|
+
export declare function rotl(word: number, shift: number): number;
|
|
26
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
27
|
+
export declare const isLE: boolean;
|
|
28
|
+
/** The byte swap operation for uint32 */
|
|
29
|
+
export declare function byteSwap(word: number): number;
|
|
30
|
+
/** Conditionally byte swap if on a big-endian platform */
|
|
31
|
+
export declare const swap8IfBE: (n: number) => number;
|
|
32
|
+
/** In place byte swap for Uint32Array */
|
|
33
|
+
export declare function byteSwap32(arr: Uint32Array): Uint32Array;
|
|
34
|
+
export declare const swap32IfBE: (u: Uint32Array) => Uint32Array;
|
|
35
|
+
/**
|
|
36
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
37
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
38
|
+
*/
|
|
39
|
+
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
40
|
+
/**
|
|
41
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
42
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
43
|
+
*/
|
|
44
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* There is no setImmediate in browser and setTimeout is slow.
|
|
47
|
+
* Call of async fn will return Promise, which will be fullfiled only on
|
|
48
|
+
* next scheduler queue processing step and this is exactly what we need.
|
|
49
|
+
*/
|
|
50
|
+
export declare const nextTick: () => Promise<void>;
|
|
51
|
+
/** Returns control to thread each 'tick' ms to avoid blocking. */
|
|
52
|
+
export declare function asyncLoop(iters: number, tick: number, cb: (i: number) => void): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Converts string to bytes using UTF8 encoding.
|
|
55
|
+
* Built-in doesn't validate input to be string: we do the check.
|
|
56
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
57
|
+
*/
|
|
58
|
+
export declare function utf8ToBytes(str: string): Uint8Array;
|
|
59
|
+
/** KDFs can accept string or Uint8Array for user convenience. */
|
|
60
|
+
export type KDFInput = string | Uint8Array;
|
|
61
|
+
/**
|
|
62
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
63
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
64
|
+
*/
|
|
65
|
+
export declare function kdfInputToBytes(data: KDFInput, errorTitle?: string): Uint8Array;
|
|
66
|
+
/** Copies several Uint8Arrays into one. */
|
|
67
|
+
export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
|
|
68
|
+
type EmptyObj = {};
|
|
69
|
+
/** Merges default options and passed options. */
|
|
70
|
+
export declare function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(defaults: T1, opts?: T2): T1 & T2;
|
|
71
|
+
/** Common interface for all hashes. */
|
|
72
|
+
export interface Hash<T> {
|
|
73
|
+
blockLen: number;
|
|
74
|
+
outputLen: number;
|
|
75
|
+
update(buf: Uint8Array): this;
|
|
76
|
+
digestInto(buf: Uint8Array): void;
|
|
77
|
+
digest(): Uint8Array;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
_cloneInto(to?: T): T;
|
|
80
|
+
clone(): T;
|
|
81
|
+
}
|
|
82
|
+
/** PseudoRandom (number) Generator */
|
|
83
|
+
export interface PRG {
|
|
84
|
+
addEntropy(seed: Uint8Array): void;
|
|
85
|
+
randomBytes(length: number): Uint8Array;
|
|
86
|
+
clean(): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* XOF: streaming API to read digest in chunks.
|
|
90
|
+
* Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.
|
|
91
|
+
* When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot
|
|
92
|
+
* destroy state, next call can require more bytes.
|
|
93
|
+
*/
|
|
94
|
+
export type HashXOF<T extends Hash<T>> = Hash<T> & {
|
|
95
|
+
xof(bytes: number): Uint8Array;
|
|
96
|
+
xofInto(buf: Uint8Array): Uint8Array;
|
|
97
|
+
};
|
|
98
|
+
/** Hash constructor */
|
|
99
|
+
export type HasherCons<T, Opts = undefined> = Opts extends undefined ? () => T : (opts?: Opts) => T;
|
|
100
|
+
/** Optional hash params. */
|
|
101
|
+
export type HashInfo = {
|
|
102
|
+
oid?: Uint8Array;
|
|
103
|
+
};
|
|
104
|
+
/** Hash function */
|
|
105
|
+
export type CHash<T extends Hash<T> = Hash<any>, Opts = undefined> = {
|
|
106
|
+
outputLen: number;
|
|
107
|
+
blockLen: number;
|
|
108
|
+
} & HashInfo & (Opts extends undefined ? {
|
|
109
|
+
(msg: Uint8Array): Uint8Array;
|
|
110
|
+
create(): T;
|
|
111
|
+
} : {
|
|
112
|
+
(msg: Uint8Array, opts?: Opts): Uint8Array;
|
|
113
|
+
create(opts?: Opts): T;
|
|
114
|
+
});
|
|
115
|
+
/** XOF with output */
|
|
116
|
+
export type CHashXOF<T extends HashXOF<T> = HashXOF<any>, Opts = undefined> = CHash<T, Opts>;
|
|
117
|
+
/** Creates function with outputLen, blockLen, create properties from a class constructor. */
|
|
118
|
+
export declare function createHasher<T extends Hash<T>, Opts = undefined>(hashCons: HasherCons<T, Opts>, info?: HashInfo): CHash<T, Opts>;
|
|
119
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
120
|
+
export declare function randomBytes(bytesLength?: number): Uint8Array;
|
|
121
|
+
/** Creates OID opts for NIST hashes, with prefix 06 09 60 86 48 01 65 03 04 02. */
|
|
122
|
+
export declare const oidNist: (suffix: number) => Required<HashInfo>;
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@noble/hashes/2.0.1/src/utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAEnD;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,IAAI,CAK3D;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,UAAU,CAWzF;AAED,gCAAgC;AAChC,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKpC;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,UAAO,GAAG,IAAI,CAGjE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAMrD;AAED,uEAAuE;AAEvE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,UAAU,GACjE,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtD,iCAAiC;AACjC,wBAAgB,EAAE,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE9C;AAED,kCAAkC;AAClC,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAEhD;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,GAAG,MAAM,EAA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,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,KAAG,QAAQ,CAAC,QAAQ,CAExD,CAAC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
7
|
+
import * as dntShim from "../../../../../../_dnt.shims.js";
|
|
8
|
+
export function isBytes(a) {
|
|
9
|
+
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
10
|
+
}
|
|
11
|
+
/** Asserts something is positive integer. */
|
|
12
|
+
export function anumber(n, title = '') {
|
|
13
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
14
|
+
const prefix = title && `"${title}" `;
|
|
15
|
+
throw new Error(`${prefix}expected integer >= 0, got ${n}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Asserts something is Uint8Array. */
|
|
19
|
+
export function abytes(value, length, title = '') {
|
|
20
|
+
const bytes = isBytes(value);
|
|
21
|
+
const len = value?.length;
|
|
22
|
+
const needsLen = length !== undefined;
|
|
23
|
+
if (!bytes || (needsLen && len !== length)) {
|
|
24
|
+
const prefix = title && `"${title}" `;
|
|
25
|
+
const ofLen = needsLen ? ` of length ${length}` : '';
|
|
26
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
27
|
+
throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/** Asserts something is hash */
|
|
32
|
+
export function ahash(h) {
|
|
33
|
+
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
34
|
+
throw new Error('Hash must wrapped by utils.createHasher');
|
|
35
|
+
anumber(h.outputLen);
|
|
36
|
+
anumber(h.blockLen);
|
|
37
|
+
}
|
|
38
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
39
|
+
export function aexists(instance, checkFinished = true) {
|
|
40
|
+
if (instance.destroyed)
|
|
41
|
+
throw new Error('Hash instance has been destroyed');
|
|
42
|
+
if (checkFinished && instance.finished)
|
|
43
|
+
throw new Error('Hash#digest() has already been called');
|
|
44
|
+
}
|
|
45
|
+
/** Asserts output is properly-sized byte array */
|
|
46
|
+
export function aoutput(out, instance) {
|
|
47
|
+
abytes(out, undefined, 'digestInto() output');
|
|
48
|
+
const min = instance.outputLen;
|
|
49
|
+
if (out.length < min) {
|
|
50
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Cast u8 / u16 / u32 to u8. */
|
|
54
|
+
export function u8(arr) {
|
|
55
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
56
|
+
}
|
|
57
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
58
|
+
export function u32(arr) {
|
|
59
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
60
|
+
}
|
|
61
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
62
|
+
export function clean(...arrays) {
|
|
63
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
64
|
+
arrays[i].fill(0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
68
|
+
export function createView(arr) {
|
|
69
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
70
|
+
}
|
|
71
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
72
|
+
export function rotr(word, shift) {
|
|
73
|
+
return (word << (32 - shift)) | (word >>> shift);
|
|
74
|
+
}
|
|
75
|
+
/** The rotate left (circular left shift) operation for uint32 */
|
|
76
|
+
export function rotl(word, shift) {
|
|
77
|
+
return (word << shift) | ((word >>> (32 - shift)) >>> 0);
|
|
78
|
+
}
|
|
79
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
80
|
+
export const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
81
|
+
/** The byte swap operation for uint32 */
|
|
82
|
+
export function byteSwap(word) {
|
|
83
|
+
return (((word << 24) & 0xff000000) |
|
|
84
|
+
((word << 8) & 0xff0000) |
|
|
85
|
+
((word >>> 8) & 0xff00) |
|
|
86
|
+
((word >>> 24) & 0xff));
|
|
87
|
+
}
|
|
88
|
+
/** Conditionally byte swap if on a big-endian platform */
|
|
89
|
+
export const swap8IfBE = isLE
|
|
90
|
+
? (n) => n
|
|
91
|
+
: (n) => byteSwap(n);
|
|
92
|
+
/** In place byte swap for Uint32Array */
|
|
93
|
+
export function byteSwap32(arr) {
|
|
94
|
+
for (let i = 0; i < arr.length; i++) {
|
|
95
|
+
arr[i] = byteSwap(arr[i]);
|
|
96
|
+
}
|
|
97
|
+
return arr;
|
|
98
|
+
}
|
|
99
|
+
export const swap32IfBE = isLE
|
|
100
|
+
? (u) => u
|
|
101
|
+
: byteSwap32;
|
|
102
|
+
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
|
|
103
|
+
const hasHexBuiltin = /* @__PURE__ */ (() =>
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
|
|
106
|
+
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
107
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
108
|
+
/**
|
|
109
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
110
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
111
|
+
*/
|
|
112
|
+
export function bytesToHex(bytes) {
|
|
113
|
+
abytes(bytes);
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
if (hasHexBuiltin)
|
|
116
|
+
return bytes.toHex();
|
|
117
|
+
// pre-caching improves the speed 6x
|
|
118
|
+
let hex = '';
|
|
119
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
120
|
+
hex += hexes[bytes[i]];
|
|
121
|
+
}
|
|
122
|
+
return hex;
|
|
123
|
+
}
|
|
124
|
+
// We use optimized technique to convert hex string to byte array
|
|
125
|
+
const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
126
|
+
function asciiToBase16(ch) {
|
|
127
|
+
if (ch >= asciis._0 && ch <= asciis._9)
|
|
128
|
+
return ch - asciis._0; // '2' => 50-48
|
|
129
|
+
if (ch >= asciis.A && ch <= asciis.F)
|
|
130
|
+
return ch - (asciis.A - 10); // 'B' => 66-(65-10)
|
|
131
|
+
if (ch >= asciis.a && ch <= asciis.f)
|
|
132
|
+
return ch - (asciis.a - 10); // 'b' => 98-(97-10)
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
137
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
138
|
+
*/
|
|
139
|
+
export function hexToBytes(hex) {
|
|
140
|
+
if (typeof hex !== 'string')
|
|
141
|
+
throw new Error('hex string expected, got ' + typeof hex);
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
if (hasHexBuiltin)
|
|
144
|
+
return Uint8Array.fromHex(hex);
|
|
145
|
+
const hl = hex.length;
|
|
146
|
+
const al = hl / 2;
|
|
147
|
+
if (hl % 2)
|
|
148
|
+
throw new Error('hex string expected, got unpadded hex of length ' + hl);
|
|
149
|
+
const array = new Uint8Array(al);
|
|
150
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
151
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
152
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
153
|
+
if (n1 === undefined || n2 === undefined) {
|
|
154
|
+
const char = hex[hi] + hex[hi + 1];
|
|
155
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
156
|
+
}
|
|
157
|
+
array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
|
|
158
|
+
}
|
|
159
|
+
return array;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* There is no setImmediate in browser and setTimeout is slow.
|
|
163
|
+
* Call of async fn will return Promise, which will be fullfiled only on
|
|
164
|
+
* next scheduler queue processing step and this is exactly what we need.
|
|
165
|
+
*/
|
|
166
|
+
export const nextTick = async () => { };
|
|
167
|
+
/** Returns control to thread each 'tick' ms to avoid blocking. */
|
|
168
|
+
export async function asyncLoop(iters, tick, cb) {
|
|
169
|
+
let ts = Date.now();
|
|
170
|
+
for (let i = 0; i < iters; i++) {
|
|
171
|
+
cb(i);
|
|
172
|
+
// Date.now() is not monotonic, so in case if clock goes backwards we return return control too
|
|
173
|
+
const diff = Date.now() - ts;
|
|
174
|
+
if (diff >= 0 && diff < tick)
|
|
175
|
+
continue;
|
|
176
|
+
await nextTick();
|
|
177
|
+
ts += diff;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Converts string to bytes using UTF8 encoding.
|
|
182
|
+
* Built-in doesn't validate input to be string: we do the check.
|
|
183
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
184
|
+
*/
|
|
185
|
+
export function utf8ToBytes(str) {
|
|
186
|
+
if (typeof str !== 'string')
|
|
187
|
+
throw new Error('string expected');
|
|
188
|
+
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
192
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
193
|
+
*/
|
|
194
|
+
export function kdfInputToBytes(data, errorTitle = '') {
|
|
195
|
+
if (typeof data === 'string')
|
|
196
|
+
return utf8ToBytes(data);
|
|
197
|
+
return abytes(data, undefined, errorTitle);
|
|
198
|
+
}
|
|
199
|
+
/** Copies several Uint8Arrays into one. */
|
|
200
|
+
export function concatBytes(...arrays) {
|
|
201
|
+
let sum = 0;
|
|
202
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
203
|
+
const a = arrays[i];
|
|
204
|
+
abytes(a);
|
|
205
|
+
sum += a.length;
|
|
206
|
+
}
|
|
207
|
+
const res = new Uint8Array(sum);
|
|
208
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
209
|
+
const a = arrays[i];
|
|
210
|
+
res.set(a, pad);
|
|
211
|
+
pad += a.length;
|
|
212
|
+
}
|
|
213
|
+
return res;
|
|
214
|
+
}
|
|
215
|
+
/** Merges default options and passed options. */
|
|
216
|
+
export function checkOpts(defaults, opts) {
|
|
217
|
+
if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
|
|
218
|
+
throw new Error('options must be object or undefined');
|
|
219
|
+
const merged = Object.assign(defaults, opts);
|
|
220
|
+
return merged;
|
|
221
|
+
}
|
|
222
|
+
/** Creates function with outputLen, blockLen, create properties from a class constructor. */
|
|
223
|
+
export function createHasher(hashCons, info = {}) {
|
|
224
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
225
|
+
const tmp = hashCons(undefined);
|
|
226
|
+
hashC.outputLen = tmp.outputLen;
|
|
227
|
+
hashC.blockLen = tmp.blockLen;
|
|
228
|
+
hashC.create = (opts) => hashCons(opts);
|
|
229
|
+
Object.assign(hashC, info);
|
|
230
|
+
return Object.freeze(hashC);
|
|
231
|
+
}
|
|
232
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
233
|
+
export function randomBytes(bytesLength = 32) {
|
|
234
|
+
const cr = typeof dntShim.dntGlobalThis === 'object' ? dntShim.dntGlobalThis.crypto : null;
|
|
235
|
+
if (typeof cr?.getRandomValues !== 'function')
|
|
236
|
+
throw new Error('crypto.getRandomValues must be defined');
|
|
237
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
238
|
+
}
|
|
239
|
+
/** Creates OID opts for NIST hashes, with prefix 06 09 60 86 48 01 65 03 04 02. */
|
|
240
|
+
export const oidNist = (suffix) => ({
|
|
241
|
+
oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]),
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=utils.js.map
|