@bsv/sdk 1.1.13 → 1.1.14

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.
Files changed (136) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/primitives/Point.js +28 -8
  3. package/dist/cjs/src/primitives/Point.js.map +1 -1
  4. package/dist/cjs/src/primitives/Polynomial.js +81 -0
  5. package/dist/cjs/src/primitives/Polynomial.js.map +1 -0
  6. package/dist/cjs/src/primitives/PrivateKey.js +165 -0
  7. package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
  8. package/dist/cjs/src/primitives/PublicKey.js +16 -2
  9. package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
  10. package/dist/cjs/src/primitives/index.js +5 -1
  11. package/dist/cjs/src/primitives/index.js.map +1 -1
  12. package/dist/cjs/src/script/templates/P2PKH.js.map +1 -1
  13. package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
  14. package/dist/cjs/src/transaction/broadcasters/ARC.js +4 -4
  15. package/dist/cjs/src/transaction/broadcasters/ARC.js.map +1 -1
  16. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  17. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +3 -3
  18. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
  19. package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
  20. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js +2 -2
  21. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
  22. package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
  23. package/dist/cjs/src/transaction/http/DefaultHttpClient.js +2 -2
  24. package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
  25. package/dist/cjs/src/transaction/http/FetchHttpClient.js +2 -2
  26. package/dist/cjs/src/transaction/http/FetchHttpClient.js.map +1 -1
  27. package/dist/cjs/src/transaction/http/NodejsHttpClient.js +2 -2
  28. package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -1
  29. package/dist/cjs/src/transaction/http/index.js.map +1 -1
  30. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  31. package/dist/esm/src/primitives/Point.js +28 -8
  32. package/dist/esm/src/primitives/Point.js.map +1 -1
  33. package/dist/esm/src/primitives/Polynomial.js +77 -0
  34. package/dist/esm/src/primitives/Polynomial.js.map +1 -0
  35. package/dist/esm/src/primitives/PrivateKey.js +143 -0
  36. package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
  37. package/dist/esm/src/primitives/PublicKey.js +16 -2
  38. package/dist/esm/src/primitives/PublicKey.js.map +1 -1
  39. package/dist/esm/src/primitives/index.js +2 -1
  40. package/dist/esm/src/primitives/index.js.map +1 -1
  41. package/dist/esm/src/script/templates/P2PKH.js.map +1 -1
  42. package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
  43. package/dist/esm/src/transaction/broadcasters/ARC.js +7 -7
  44. package/dist/esm/src/transaction/broadcasters/ARC.js.map +1 -1
  45. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js +1 -1
  46. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  47. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +4 -4
  48. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
  49. package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js +1 -1
  50. package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
  51. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js +3 -3
  52. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
  53. package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
  54. package/dist/esm/src/transaction/http/DefaultHttpClient.js +2 -2
  55. package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
  56. package/dist/esm/src/transaction/http/FetchHttpClient.js +2 -2
  57. package/dist/esm/src/transaction/http/FetchHttpClient.js.map +1 -1
  58. package/dist/esm/src/transaction/http/NodejsHttpClient.js +2 -2
  59. package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -1
  60. package/dist/esm/src/transaction/http/index.js.map +1 -1
  61. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  62. package/dist/types/src/primitives/Point.d.ts +19 -1
  63. package/dist/types/src/primitives/Point.d.ts.map +1 -1
  64. package/dist/types/src/primitives/Polynomial.d.ts +32 -0
  65. package/dist/types/src/primitives/Polynomial.d.ts.map +1 -0
  66. package/dist/types/src/primitives/PrivateKey.d.ts +72 -0
  67. package/dist/types/src/primitives/PrivateKey.d.ts.map +1 -1
  68. package/dist/types/src/primitives/PublicKey.d.ts +12 -1
  69. package/dist/types/src/primitives/PublicKey.d.ts.map +1 -1
  70. package/dist/types/src/primitives/index.d.ts +2 -1
  71. package/dist/types/src/primitives/index.d.ts.map +1 -1
  72. package/dist/types/src/script/templates/P2PKH.d.ts.map +1 -1
  73. package/dist/types/src/transaction/broadcasters/ARC.d.ts +1 -1
  74. package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +1 -1
  75. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts +1 -1
  76. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts.map +1 -1
  77. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts +1 -1
  78. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts.map +1 -1
  79. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts +1 -1
  80. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts.map +1 -1
  81. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts +2 -2
  82. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts.map +1 -1
  83. package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts.map +1 -1
  84. package/dist/types/src/transaction/http/DefaultHttpClient.d.ts.map +1 -1
  85. package/dist/types/src/transaction/http/FetchHttpClient.d.ts +7 -9
  86. package/dist/types/src/transaction/http/FetchHttpClient.d.ts.map +1 -1
  87. package/dist/types/src/transaction/http/HttpClient.d.ts +5 -5
  88. package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -1
  89. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts +5 -6
  90. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts.map +1 -1
  91. package/dist/types/src/transaction/http/index.d.ts.map +1 -1
  92. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  93. package/docs/primitives.md +231 -16
  94. package/docs/transaction.md +38 -37
  95. package/package.json +1 -1
  96. package/src/compat/__tests/BSM.test.ts +37 -37
  97. package/src/compat/__tests/ECIES.test.ts +71 -71
  98. package/src/compat/__tests/HD.test.ts +362 -362
  99. package/src/compat/__tests/Mnemonic.test.ts +147 -148
  100. package/src/compat/__tests/Mnemonic.vectors.ts +170 -170
  101. package/src/messages/__tests/EncryptedMessage.test.ts +16 -16
  102. package/src/primitives/Point.ts +29 -10
  103. package/src/primitives/Polynomial.ts +89 -0
  104. package/src/primitives/PrivateKey.ts +147 -1
  105. package/src/primitives/PublicKey.ts +17 -2
  106. package/src/primitives/__tests/AESGCM.test.ts +20 -20
  107. package/src/primitives/__tests/Hash.test.ts +2 -2
  108. package/src/primitives/__tests/PBKDF2.vectors.ts +93 -93
  109. package/src/primitives/__tests/PrivateKey.split.test.ts +70 -0
  110. package/src/primitives/__tests/PublicKey.test.ts +14 -1
  111. package/src/primitives/__tests/bug-31.test.ts +24 -26
  112. package/src/primitives/__tests/utils.test.ts +13 -13
  113. package/src/primitives/index.ts +2 -1
  114. package/src/script/__tests/Script.test.ts +1 -1
  115. package/src/script/__tests/SpendComplex.test.ts +6 -6
  116. package/src/script/__tests/script.invalid.vectors.ts +1464 -1464
  117. package/src/script/__tests/script.valid.vectors.ts +1962 -1962
  118. package/src/script/__tests/spend.valid.vectors.ts +1369 -1369
  119. package/src/script/templates/P2PKH.ts +6 -6
  120. package/src/script/templates/RPuzzle.ts +1 -1
  121. package/src/transaction/__tests/Transaction.test.ts +5 -5
  122. package/src/transaction/__tests/bump.invalid.vectors.ts +1 -1
  123. package/src/transaction/__tests/bump.valid.vectors.ts +3 -3
  124. package/src/transaction/broadcasters/ARC.ts +20 -21
  125. package/src/transaction/broadcasters/DefaultBroadcaster.ts +3 -3
  126. package/src/transaction/broadcasters/WhatsOnChainBroadcaster.ts +10 -10
  127. package/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.ts +7 -10
  128. package/src/transaction/chaintrackers/DefaultChainTracker.ts +3 -3
  129. package/src/transaction/chaintrackers/WhatsOnChain.ts +10 -12
  130. package/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.ts +13 -17
  131. package/src/transaction/fee-models/SatoshisPerKilobyte.ts +2 -2
  132. package/src/transaction/http/DefaultHttpClient.ts +13 -13
  133. package/src/transaction/http/FetchHttpClient.ts +14 -16
  134. package/src/transaction/http/HttpClient.ts +22 -23
  135. package/src/transaction/http/NodejsHttpClient.ts +23 -25
  136. package/src/transaction/http/index.ts +6 -6
@@ -21,7 +21,7 @@ export default class P2PKH implements ScriptTemplate {
21
21
  * @param {number[] | string} pubkeyhash or address - An array or address representing the public key hash.
22
22
  * @returns {LockingScript} - A P2PKH locking script.
23
23
  */
24
- lock(pubkeyhash: string | number[]): LockingScript {
24
+ lock (pubkeyhash: string | number[]): LockingScript {
25
25
  let data: number[]
26
26
  if (typeof pubkeyhash === 'string') {
27
27
  const hash = fromBase58Check(pubkeyhash)
@@ -54,16 +54,16 @@ export default class P2PKH implements ScriptTemplate {
54
54
  * @param {Script} lockingScript - Optional. The lockinScript. Otherwise the input.sourceTransaction is required.
55
55
  * @returns {Object} - An object containing the `sign` and `estimateLength` functions.
56
56
  */
57
- unlock(
57
+ unlock (
58
58
  privateKey: PrivateKey,
59
59
  signOutputs: 'all' | 'none' | 'single' = 'all',
60
60
  anyoneCanPay: boolean = false,
61
61
  sourceSatoshis?: number,
62
62
  lockingScript?: Script
63
63
  ): {
64
- sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>
65
- estimateLength: () => Promise<106>
66
- } {
64
+ sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>
65
+ estimateLength: () => Promise<106>
66
+ } {
67
67
  return {
68
68
  sign: async (tx: Transaction, inputIndex: number) => {
69
69
  let signatureScope = TransactionSignature.SIGHASH_FORKID
@@ -84,7 +84,7 @@ export default class P2PKH implements ScriptTemplate {
84
84
 
85
85
  const otherInputs = tx.inputs.filter((_, index) => index !== inputIndex)
86
86
 
87
- const sourceTXID = input.sourceTXID ? input.sourceTXID : input.sourceTransaction?.id('hex') as string
87
+ const sourceTXID = input.sourceTXID ? input.sourceTXID : input.sourceTransaction?.id('hex')
88
88
  if (!sourceTXID) {
89
89
  throw new Error(
90
90
  'The input sourceTXID or sourceTransaction is required for transaction signing.'
@@ -105,7 +105,7 @@ export default class RPuzzle implements ScriptTemplate {
105
105
  )
106
106
  }
107
107
  const preimage = TransactionSignature.format({
108
- sourceTXID: input.sourceTransaction.id('hex') as string,
108
+ sourceTXID: input.sourceTransaction.id('hex'),
109
109
  sourceOutputIndex: input.sourceOutputIndex,
110
110
  sourceSatoshis: input.sourceTransaction.outputs[input.sourceOutputIndex].satoshis,
111
111
  transactionVersion: tx.version,
@@ -238,7 +238,7 @@ describe('Transaction', () => {
238
238
  it('Throws an Error if signing before the fee is computed', async () => {
239
239
  const privateKey = new PrivateKey(1)
240
240
  const publicKey = new Curve().g.mul(privateKey)
241
- const publicKeyHash = hash160(publicKey.encode(true)) as number[]
241
+ const publicKeyHash = hash160(publicKey.encode(true), 'hex') as unknown as number[]
242
242
  const p2pkh = new P2PKH()
243
243
  const sourceTx = new Transaction(1, [], [{
244
244
  lockingScript: p2pkh.lock(publicKeyHash),
@@ -392,7 +392,7 @@ describe('Transaction', () => {
392
392
  tx_pos: 0,
393
393
  tx_hash: 'f33505acf37a7726cc37d391bc6f889b8684ac2a2d581c4be2a4b1c8b46609bc',
394
394
  value: 10000
395
- },
395
+ }
396
396
  ]
397
397
  const priv = PrivateKey.fromRandom()
398
398
  const tx = new Transaction()
@@ -422,7 +422,7 @@ describe('Transaction', () => {
422
422
  status: 200,
423
423
  statusText: 'OK',
424
424
  headers: {
425
- get(key: string) {
425
+ get (key: string) {
426
426
  if (key === 'Content-Type') {
427
427
  return 'application/json'
428
428
  }
@@ -501,14 +501,14 @@ describe('Transaction', () => {
501
501
  status: 200,
502
502
  statusText: 'OK',
503
503
  headers: {
504
- get(key: string) {
504
+ get (key: string) {
505
505
  if (key === 'Content-Type') {
506
506
  return 'application/json'
507
507
  }
508
508
  }
509
509
  },
510
510
  json: async () => ({
511
- merkleroot: MerkleRootFromBEEF,
511
+ merkleroot: MerkleRootFromBEEF
512
512
  })
513
513
  });
514
514
  (global as any).window = { fetch: mockFetch }
@@ -5,4 +5,4 @@ export default [
5
5
  { error: 'Missing hash for index 923 at height 0', bump: 'feb39d0c000c01fd9b030012f77e65627c341a3aaea3a0ed645c0082ef53995f446ab9901a27e4622fd1cc01fdcc010074026299a4ba40fbcf33cc0c64b384f0bb2fb17c61125609a666b546539c221c01e700730f99f8cf10fccd30730474449172c5f97cde6a6cf65163359e778463e9f2b9017200a202c78dee487cf96e1a6a04d51faec4debfad09eea28cc624483f2d6fa53d54013800b51ecabaa590b6bd1805baf4f19fc0eae0dedb533302603579d124059b374b1e011d00a0f36640f32a43d790bb4c3e7877011aa8ae25e433b2b83c952a16f8452b6b79010f005d68efab62c6c457ce0bb526194cc16b27f93f8a4899f6d59ffffdddc06e345c01060099f66a0ef693d151bbe9aeb10392ac5a7712243406f9e821219fd13d1865f569010200201fa17c98478675a96703ded42629a3c7bf32b45d0bff25f8be6849d02889ae010000367765c2d68e0c926d81ecdf9e3c86991ccf5a52e97c49ad5cf584c8ab030427010100237b58d3217709b6ebc3bdc093413ba788739f052a0b5b3a413e65444b146bc1' },
6
6
  { error: 'Missing hash for index 1844 at height 6', bump: 'feb39d0c000c02fd340700ed4cb1fdd81916dabb69b63bcd378559cf40916205cd004e7f5381cc2b1ea6acfd350702957998e38434782b1c40c63a4aca0ffaf4d5d9bc3385f0e9e396f4dd3238f0df01fd9b030012f77e65627c341a3aaea3a0ed645c0082ef53995f446ab9901a27e4622fd1cc01fdcc010074026299a4ba40fbcf33cc0c64b384f0bb2fb17c61125609a666b546539c221c01e700730f99f8cf10fccd30730474449172c5f97cde6a6cf65163359e778463e9f2b9017200a202c78dee487cf96e1a6a04d51faec4debfad09eea28cc624483f2d6fa53d54013800b51ecabaa590b6bd1805baf4f19fc0eae0dedb533302603579d124059b374b1e00010f005d68efab62c6c457ce0bb526194cc16b27f93f8a4899f6d59ffffdddc06e345c01060099f66a0ef693d151bbe9aeb10392ac5a7712243406f9e821219fd13d1865f569010200201fa17c98478675a96703ded42629a3c7bf32b45d0bff25f8be6849d02889ae010000367765c2d68e0c926d81ecdf9e3c86991ccf5a52e97c49ad5cf584c8ab030427010100237b58d3217709b6ebc3bdc093413ba788739f052a0b5b3a413e65444b146bc1' },
7
7
  { error: 'Mismatched roots', bump: 'fed79f0c000c04fd3803029b490d9c8358ff11afaf45628417c9eb52c1a1fd404078a101b4f71dbba06aa9fd390300fe82f2768edc3d0cfe4d06b7f390dcb0b7e61cca7f70117d83be0f023204d8effd3a03007fd48b1d2b678907ba045b07132003db8116468cd6a3d4764e0df4a644ea0a22fd3b03009bb8ffc1a6ed2ba80ea1b09ff797387115a7129d19e93c003a74e3a20ed6ce5902fd9d010060893ac65c8a8e6b9ef7ed5e05dc3bd25aa904812c09853c5dbf423b58a75d0efd9c01002eea60ed9ca5ed2ba80ea1b09ff797387115a79bb8ffc176fe4337129d393e0101cf0012c3c76d9c332e4701b27bfe7013e7963b92d1851d59c56955b35aecabbc8bae0166000894384f86a5c4d0d294f9b9441c3ee3d13afa094cca4515d32813b3fa4fdf3601320002aac507f74c9ff2676705eee1e70897a8baeecaf30c5f49bb22a0c5ce5fda9a01180021f7e27a08d61245be893a238853d72340881cbd47e0a390895231fa1cc44db9010d004d7a12738a1654777867182ee6f6efc4d692209badfa5ba9bb126d08da18ed880107004f8e96b4ee6154bd44b7709f3fb4041bf4426d5f5a594408345605e254af7cdd010200ec7d8b185bc7c096b9b88de6f63ab22baf738d5fc4cbc328f2e00644749acf520100007fd48b1d2b678907ba045b07132003db8116468cd6a3d4764e0df4a644ea0a220101009bb8ffc1a6ed2ba80ea1b09ff797387115a7129d19e93c003a74e3a20ed6ce590101001106e6ece3f70a16de42d0f87b459c71a2440201728bd8541334933726807921' }
8
- ]
8
+ ]
@@ -1,4 +1,4 @@
1
1
  export default [
2
- { bump: 'fed79f0c000c02fd3803029b490d9c8358ff11afaf45628417c9eb52c1a1fd404078a101b4f71dbba06aa9fd390300fe82f2768edc3d0cfe4d06b7f390dcb0b7e61cca7f70117d83be0f023204d8ef01fd9d010060893ac65c8a8e6b9ef7ed5e05dc3bd25aa904812c09853c5dbf423b58a75d0e01cf0012c3c76d9c332e4701b27bfe7013e7963b92d1851d59c56955b35aecabbc8bae0166000894384f86a5c4d0d294f9b9441c3ee3d13afa094cca4515d32813b3fa4fdf3601320002aac507f74c9ff2676705eee1e70897a8baeecaf30c5f49bb22a0c5ce5fda9a01180021f7e27a08d61245be893a238853d72340881cbd47e0a390895231fa1cc44db9010d004d7a12738a1654777867182ee6f6efc4d692209badfa5ba9bb126d08da18ed880107004f8e96b4ee6154bd44b7709f3fb4041bf4426d5f5a594408345605e254af7cdd010200ec7d8b185bc7c096b9b88de6f63ab22baf738d5fc4cbc328f2e00644749acf520100007fd48b1d2b678907ba045b07132003db8116468cd6a3d4764e0df4a644ea0a220101009bb8ffc1a6ed2ba80ea1b09ff797387115a7129d19e93c003a74e3a20ed6ce590101001106e6ece3f70a16de42d0f87b459c71a2440201728bd8541334933726807921' },
3
- { bump: 'feb39d0c000c02fd340700ed4cb1fdd81916dabb69b63bcd378559cf40916205cd004e7f5381cc2b1ea6acfd350702957998e38434782b1c40c63a4aca0ffaf4d5d9bc3385f0e9e396f4dd3238f0df01fd9b030012f77e65627c341a3aaea3a0ed645c0082ef53995f446ab9901a27e4622fd1cc01fdcc010074026299a4ba40fbcf33cc0c64b384f0bb2fb17c61125609a666b546539c221c01e700730f99f8cf10fccd30730474449172c5f97cde6a6cf65163359e778463e9f2b9017200a202c78dee487cf96e1a6a04d51faec4debfad09eea28cc624483f2d6fa53d54013800b51ecabaa590b6bd1805baf4f19fc0eae0dedb533302603579d124059b374b1e011d00a0f36640f32a43d790bb4c3e7877011aa8ae25e433b2b83c952a16f8452b6b79010f005d68efab62c6c457ce0bb526194cc16b27f93f8a4899f6d59ffffdddc06e345c01060099f66a0ef693d151bbe9aeb10392ac5a7712243406f9e821219fd13d1865f569010200201fa17c98478675a96703ded42629a3c7bf32b45d0bff25f8be6849d02889ae010000367765c2d68e0c926d81ecdf9e3c86991ccf5a52e97c49ad5cf584c8ab030427010100237b58d3217709b6ebc3bdc093413ba788739f052a0b5b3a413e65444b146bc1' }
4
- ]
2
+ { bump: 'fed79f0c000c02fd3803029b490d9c8358ff11afaf45628417c9eb52c1a1fd404078a101b4f71dbba06aa9fd390300fe82f2768edc3d0cfe4d06b7f390dcb0b7e61cca7f70117d83be0f023204d8ef01fd9d010060893ac65c8a8e6b9ef7ed5e05dc3bd25aa904812c09853c5dbf423b58a75d0e01cf0012c3c76d9c332e4701b27bfe7013e7963b92d1851d59c56955b35aecabbc8bae0166000894384f86a5c4d0d294f9b9441c3ee3d13afa094cca4515d32813b3fa4fdf3601320002aac507f74c9ff2676705eee1e70897a8baeecaf30c5f49bb22a0c5ce5fda9a01180021f7e27a08d61245be893a238853d72340881cbd47e0a390895231fa1cc44db9010d004d7a12738a1654777867182ee6f6efc4d692209badfa5ba9bb126d08da18ed880107004f8e96b4ee6154bd44b7709f3fb4041bf4426d5f5a594408345605e254af7cdd010200ec7d8b185bc7c096b9b88de6f63ab22baf738d5fc4cbc328f2e00644749acf520100007fd48b1d2b678907ba045b07132003db8116468cd6a3d4764e0df4a644ea0a220101009bb8ffc1a6ed2ba80ea1b09ff797387115a7129d19e93c003a74e3a20ed6ce590101001106e6ece3f70a16de42d0f87b459c71a2440201728bd8541334933726807921' },
3
+ { bump: 'feb39d0c000c02fd340700ed4cb1fdd81916dabb69b63bcd378559cf40916205cd004e7f5381cc2b1ea6acfd350702957998e38434782b1c40c63a4aca0ffaf4d5d9bc3385f0e9e396f4dd3238f0df01fd9b030012f77e65627c341a3aaea3a0ed645c0082ef53995f446ab9901a27e4622fd1cc01fdcc010074026299a4ba40fbcf33cc0c64b384f0bb2fb17c61125609a666b546539c221c01e700730f99f8cf10fccd30730474449172c5f97cde6a6cf65163359e778463e9f2b9017200a202c78dee487cf96e1a6a04d51faec4debfad09eea28cc624483f2d6fa53d54013800b51ecabaa590b6bd1805baf4f19fc0eae0dedb533302603579d124059b374b1e011d00a0f36640f32a43d790bb4c3e7877011aa8ae25e433b2b83c952a16f8452b6b79010f005d68efab62c6c457ce0bb526194cc16b27f93f8a4899f6d59ffffdddc06e345c01060099f66a0ef693d151bbe9aeb10392ac5a7712243406f9e821219fd13d1865f569010200201fa17c98478675a96703ded42629a3c7bf32b45d0bff25f8be6849d02889ae010000367765c2d68e0c926d81ecdf9e3c86991ccf5a52e97c49ad5cf584c8ab030427010100237b58d3217709b6ebc3bdc093413ba788739f052a0b5b3a413e65444b146bc1' }
4
+ ]
@@ -1,9 +1,9 @@
1
- import {BroadcastResponse, BroadcastFailure, Broadcaster} from '../Broadcaster.js'
1
+ import { BroadcastResponse, BroadcastFailure, Broadcaster } from '../Broadcaster.js'
2
2
  import Transaction from '../Transaction.js'
3
- import {HttpClient, HttpClientRequestOptions} from "../http/HttpClient.js";
4
- import {defaultHttpClient} from "../http/DefaultHttpClient.js";
5
- import Random from "../../primitives/Random.js";
6
- import {toHex} from "../../primitives/utils.js";
3
+ import { HttpClient, HttpClientRequestOptions } from '../http/HttpClient.js'
4
+ import { defaultHttpClient } from '../http/DefaultHttpClient.js'
5
+ import Random from '../../primitives/Random.js'
6
+ import { toHex } from '../../primitives/utils.js'
7
7
 
8
8
  /** Configuration options for the ARC broadcaster. */
9
9
  export interface ArcConfig {
@@ -21,9 +21,8 @@ export interface ArcConfig {
21
21
  headers?: Record<string, string>
22
22
  }
23
23
 
24
-
25
- function defaultDeploymentId() {
26
- return `ts-sdk-${toHex(Random(16))}`;
24
+ function defaultDeploymentId () {
25
+ return `ts-sdk-${toHex(Random(16))}`
27
26
  }
28
27
 
29
28
  /**
@@ -36,7 +35,7 @@ export default class ARC implements Broadcaster {
36
35
  readonly callbackUrl: string | undefined
37
36
  readonly callbackToken: string | undefined
38
37
  readonly headers: Record<string, string> | undefined
39
- private readonly httpClient: HttpClient;
38
+ private readonly httpClient: HttpClient
40
39
 
41
40
  /**
42
41
  * Constructs an instance of the ARC broadcaster.
@@ -44,16 +43,16 @@ export default class ARC implements Broadcaster {
44
43
  * @param {string} URL - The URL endpoint for the ARC API.
45
44
  * @param {ArcConfig} config - Configuration options for the ARC broadcaster.
46
45
  */
47
- constructor(URL: string, config?: ArcConfig)
46
+ constructor (URL: string, config?: ArcConfig)
48
47
  /**
49
48
  * Constructs an instance of the ARC broadcaster.
50
49
  *
51
50
  * @param {string} URL - The URL endpoint for the ARC API.
52
51
  * @param {string} apiKey - The API key used for authorization with the ARC API.
53
52
  */
54
- constructor(URL: string, apiKey?: string)
53
+ constructor (URL: string, apiKey?: string)
55
54
 
56
- constructor(URL: string, config?: string | ArcConfig) {
55
+ constructor (URL: string, config?: string | ArcConfig) {
57
56
  this.URL = URL
58
57
  if (typeof config === 'string') {
59
58
  this.apiKey = config
@@ -62,7 +61,7 @@ export default class ARC implements Broadcaster {
62
61
  this.callbackToken = undefined
63
62
  this.callbackUrl = undefined
64
63
  } else {
65
- const {apiKey, deploymentId, httpClient, callbackToken, callbackUrl, headers } = config ?? {} as ArcConfig
64
+ const { apiKey, deploymentId, httpClient, callbackToken, callbackUrl, headers } = config ?? {} as ArcConfig
66
65
  this.apiKey = apiKey
67
66
  this.httpClient = httpClient ?? defaultHttpClient()
68
67
  this.deploymentId = deploymentId ?? defaultDeploymentId()
@@ -78,7 +77,7 @@ export default class ARC implements Broadcaster {
78
77
  * @param {Transaction} tx - The transaction to be broadcasted.
79
78
  * @returns {Promise<BroadcastResponse | BroadcastFailure>} A promise that resolves to either a success or failure response.
80
79
  */
81
- async broadcast(tx: Transaction): Promise<BroadcastResponse | BroadcastFailure> {
80
+ async broadcast (tx: Transaction): Promise<BroadcastResponse | BroadcastFailure> {
82
81
  let rawTx
83
82
  try {
84
83
  rawTx = tx.toHexEF()
@@ -93,16 +92,16 @@ export default class ARC implements Broadcaster {
93
92
  const requestOptions: HttpClientRequestOptions = {
94
93
  method: 'POST',
95
94
  headers: this.requestHeaders(),
96
- data: {rawTx}
95
+ data: { rawTx }
97
96
  }
98
97
 
99
98
  try {
100
99
  const response = await this.httpClient.request<ArcResponse>(`${this.URL}/v1/tx`, requestOptions)
101
100
  if (response.ok) {
102
- const {txid, extraInfo, txStatus} = response.data
101
+ const { txid, extraInfo, txStatus } = response.data
103
102
  return {
104
103
  status: 'success',
105
- txid: txid,
104
+ txid,
106
105
  message: `${txStatus} ${extraInfo}`
107
106
  }
108
107
  } else {
@@ -140,14 +139,14 @@ export default class ARC implements Broadcaster {
140
139
  }
141
140
  }
142
141
 
143
- private requestHeaders() {
142
+ private requestHeaders () {
144
143
  const headers: Record<string, string> = {
145
144
  'Content-Type': 'application/json',
146
- 'XDeployment-ID': this.deploymentId,
145
+ 'XDeployment-ID': this.deploymentId
147
146
  }
148
147
 
149
148
  if (this.apiKey) {
150
- headers['Authorization'] = `Bearer ${this.apiKey}`
149
+ headers.Authorization = `Bearer ${this.apiKey}`
151
150
  }
152
151
 
153
152
  if (this.callbackUrl) {
@@ -158,7 +157,7 @@ export default class ARC implements Broadcaster {
158
157
  headers['X-CallbackToken'] = this.callbackToken
159
158
  }
160
159
 
161
- if (!!this.headers) {
160
+ if (this.headers) {
162
161
  for (const key in this.headers) {
163
162
  headers[key] = this.headers[key]
164
163
  }
@@ -1,6 +1,6 @@
1
- import {Broadcaster} from "../Broadcaster.js";
2
- import ARC from "./ARC.js";
1
+ import { Broadcaster } from '../Broadcaster.js'
2
+ import ARC from './ARC.js'
3
3
 
4
- export function defaultBroadcaster(): Broadcaster {
4
+ export function defaultBroadcaster (): Broadcaster {
5
5
  return new ARC('https://arc.taal.com')
6
6
  }
@@ -1,7 +1,7 @@
1
- import {BroadcastResponse, BroadcastFailure, Broadcaster} from '../Broadcaster.js'
1
+ import { BroadcastResponse, BroadcastFailure, Broadcaster } from '../Broadcaster.js'
2
2
  import Transaction from '../Transaction.js'
3
- import {HttpClient} from "../http/HttpClient.js";
4
- import {defaultHttpClient} from "../http/DefaultHttpClient.js";
3
+ import { HttpClient } from '../http/HttpClient.js'
4
+ import { defaultHttpClient } from '../http/DefaultHttpClient.js'
5
5
 
6
6
  /**
7
7
  * Represents an WhatsOnChain transaction broadcaster.
@@ -9,7 +9,7 @@ import {defaultHttpClient} from "../http/DefaultHttpClient.js";
9
9
  export default class WhatsOnChainBroadcaster implements Broadcaster {
10
10
  readonly network: string
11
11
  private readonly URL: string
12
- private readonly httpClient: HttpClient;
12
+ private readonly httpClient: HttpClient
13
13
 
14
14
  /**
15
15
  * Constructs an instance of the WhatsOnChain broadcaster.
@@ -17,7 +17,7 @@ export default class WhatsOnChainBroadcaster implements Broadcaster {
17
17
  * @param {'main' | 'test' | 'stn'} network - The BSV network to use when calling the WhatsOnChain API.
18
18
  * @param {HttpClient} httpClient - The HTTP client used to make requests to the API.
19
19
  */
20
- constructor(network: 'main' | 'test' | 'stn' = 'main', httpClient: HttpClient = defaultHttpClient()) {
20
+ constructor (network: 'main' | 'test' | 'stn' = 'main', httpClient: HttpClient = defaultHttpClient()) {
21
21
  this.network = network
22
22
  this.URL = `https://api.whatsonchain.com/v1/bsv/${network}/tx/raw`
23
23
  this.httpClient = httpClient
@@ -29,16 +29,16 @@ export default class WhatsOnChainBroadcaster implements Broadcaster {
29
29
  * @param {Transaction} tx - The transaction to be broadcasted.
30
30
  * @returns {Promise<BroadcastResponse | BroadcastFailure>} A promise that resolves to either a success or failure response.
31
31
  */
32
- async broadcast(tx: Transaction): Promise<BroadcastResponse | BroadcastFailure> {
33
- let rawTx = tx.toHex()
32
+ async broadcast (tx: Transaction): Promise<BroadcastResponse | BroadcastFailure> {
33
+ const rawTx = tx.toHex()
34
34
 
35
35
  const requestOptions = {
36
36
  method: 'POST',
37
37
  headers: {
38
38
  'Content-Type': 'application/json',
39
- 'Accept': 'text/plain'
39
+ Accept: 'text/plain'
40
40
  },
41
- data: {txhex: rawTx}
41
+ data: { txhex: rawTx }
42
42
  }
43
43
 
44
44
  try {
@@ -47,7 +47,7 @@ export default class WhatsOnChainBroadcaster implements Broadcaster {
47
47
  const txid = response.data
48
48
  return {
49
49
  status: 'success',
50
- txid: txid,
50
+ txid,
51
51
  message: 'broadcast successful'
52
52
  }
53
53
  } else {
@@ -1,7 +1,7 @@
1
1
  import Transaction from '../../../../dist/cjs/src/transaction/Transaction.js'
2
- import {NodejsHttpClient} from "../../../../dist/cjs/src/transaction/http/NodejsHttpClient.js";
3
- import WhatsOnChainBroadcaster from "../../../../dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js";
4
- import {FetchHttpClient} from "../../../../dist/cjs/src/transaction/http/FetchHttpClient.js";
2
+ import { NodejsHttpClient } from '../../../../dist/cjs/src/transaction/http/NodejsHttpClient.js'
3
+ import WhatsOnChainBroadcaster from '../../../../dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js'
4
+ import { FetchHttpClient } from '../../../../dist/cjs/src/transaction/http/FetchHttpClient.js'
5
5
 
6
6
  // Mock Transaction
7
7
  jest.mock('../../Transaction', () => {
@@ -59,7 +59,6 @@ describe('WhatsOnChainBroadcaster', () => {
59
59
  })
60
60
 
61
61
  it('should broadcast successfully using provided fetch', async () => {
62
-
63
62
  const mockFetch = mockedFetch(successResponse)
64
63
 
65
64
  const broadcaster = new WhatsOnChainBroadcaster(network, new FetchHttpClient(mockFetch))
@@ -74,7 +73,6 @@ describe('WhatsOnChainBroadcaster', () => {
74
73
  })
75
74
 
76
75
  it('should broadcast successfully using provided https', async () => {
77
-
78
76
  const mockHttps = mockedHttps(successResponse)
79
77
  const broadcaster = new WhatsOnChainBroadcaster(network, new NodejsHttpClient(mockHttps))
80
78
 
@@ -120,23 +118,23 @@ describe('WhatsOnChainBroadcaster', () => {
120
118
  })
121
119
  })
122
120
 
123
- function mockedFetch(response) {
121
+ function mockedFetch (response) {
124
122
  return jest.fn().mockResolvedValue({
125
123
  ok: response.status === 200,
126
124
  status: response.status,
127
125
  statusText: response.status === 200 ? 'OK' : 'Bad request',
128
126
  headers: {
129
- get(key: string) {
127
+ get (key: string) {
130
128
  if (key === 'Content-Type') {
131
129
  return 'text/plain'
132
130
  }
133
131
  }
134
132
  },
135
133
  text: async () => response.data
136
- });
134
+ })
137
135
  }
138
136
 
139
- function mockedHttps(response) {
137
+ function mockedHttps (response) {
140
138
  const https = {
141
139
  request: (url, options, callback) => {
142
140
  // eslint-disable-next-line
@@ -162,4 +160,3 @@ describe('WhatsOnChainBroadcaster', () => {
162
160
  return https
163
161
  }
164
162
  })
165
-
@@ -1,6 +1,6 @@
1
- import WhatsOnChain from "./WhatsOnChain.js";
2
- import ChainTracker from "../ChainTracker.js";
1
+ import WhatsOnChain from './WhatsOnChain.js'
2
+ import ChainTracker from '../ChainTracker.js'
3
3
 
4
- export function defaultChainTracker(): ChainTracker {
4
+ export function defaultChainTracker (): ChainTracker {
5
5
  return new WhatsOnChain()
6
6
  }
@@ -1,6 +1,6 @@
1
- import ChainTracker from "../ChainTracker.js";
2
- import {HttpClient} from "../http/HttpClient.js";
3
- import {defaultHttpClient} from "../http/DefaultHttpClient.js";
1
+ import ChainTracker from '../ChainTracker.js'
2
+ import { HttpClient } from '../http/HttpClient.js'
3
+ import { defaultHttpClient } from '../http/DefaultHttpClient.js'
4
4
 
5
5
  /** Configuration options for the WhatsOnChain ChainTracker. */
6
6
  export interface WhatsOnChainConfig {
@@ -29,15 +29,15 @@ export default class WhatsOnChain implements ChainTracker {
29
29
  * @param {'main' | 'test' | 'stn'} network - The BSV network to use when calling the WhatsOnChain API.
30
30
  * @param {WhatsOnChainConfig} config - Configuration options for the WhatsOnChain ChainTracker.
31
31
  */
32
- constructor(network: 'main' | 'test' | 'stn' = 'main', config: WhatsOnChainConfig = {}) {
33
- const {apiKey, httpClient} = config
32
+ constructor (network: 'main' | 'test' | 'stn' = 'main', config: WhatsOnChainConfig = {}) {
33
+ const { apiKey, httpClient } = config
34
34
  this.network = network
35
35
  this.URL = `https://api.whatsonchain.com/v1/bsv/${network}`
36
36
  this.httpClient = httpClient ?? defaultHttpClient()
37
37
  this.apiKey = apiKey
38
38
  }
39
39
 
40
- async isValidRootForHeight(root: string, height: number): Promise<boolean> {
40
+ async isValidRootForHeight (root: string, height: number): Promise<boolean> {
41
41
  const requestOptions = {
42
42
  method: 'GET',
43
43
  headers: this.getHeaders()
@@ -45,7 +45,7 @@ export default class WhatsOnChain implements ChainTracker {
45
45
 
46
46
  const response = await this.httpClient.request<WhatsOnChainBlockHeader>(`${this.URL}/block/${height}/header`, requestOptions)
47
47
  if (response.ok) {
48
- const { merkleroot} = response.data
48
+ const { merkleroot } = response.data
49
49
  return merkleroot === root
50
50
  } else if (response.status === 404) {
51
51
  return false
@@ -54,17 +54,15 @@ export default class WhatsOnChain implements ChainTracker {
54
54
  }
55
55
  }
56
56
 
57
- private getHeaders() {
57
+ private getHeaders () {
58
58
  const headers: Record<string, string> = {
59
- 'Accept': 'application/json',
59
+ Accept: 'application/json'
60
60
  }
61
61
 
62
62
  if (this.apiKey) {
63
- headers['Authorization'] = this.apiKey
63
+ headers.Authorization = this.apiKey
64
64
  }
65
65
 
66
66
  return headers
67
67
  }
68
68
  }
69
-
70
-
@@ -1,7 +1,6 @@
1
- import {NodejsHttpClient} from "../../../../dist/cjs/src/transaction/http/NodejsHttpClient.js";
2
- import WhatsOnChain from "../../../../dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js";
3
- import {FetchHttpClient} from "../../../../dist/cjs/src/transaction/http/FetchHttpClient.js";
4
-
1
+ import { NodejsHttpClient } from '../../../../dist/cjs/src/transaction/http/NodejsHttpClient.js'
2
+ import WhatsOnChain from '../../../../dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js'
3
+ import { FetchHttpClient } from '../../../../dist/cjs/src/transaction/http/FetchHttpClient.js'
5
4
 
6
5
  describe('WhatsOnChain ChainTracker', () => {
7
6
  const network = 'main'
@@ -15,8 +14,6 @@ describe('WhatsOnChain ChainTracker', () => {
15
14
  }
16
15
  }
17
16
 
18
-
19
-
20
17
  it('should verify merkleroot successfully using window.fetch', async () => {
21
18
  // Mocking window.fetch
22
19
  const mockFetch = mockedFetch(successResponse)
@@ -43,7 +40,7 @@ describe('WhatsOnChain ChainTracker', () => {
43
40
  it('should verify merkleroot successfully using provided window.fetch', async () => {
44
41
  const mockFetch = mockedFetch(successResponse)
45
42
 
46
- const chainTracker = new WhatsOnChain(network, {httpClient: new FetchHttpClient(mockFetch)})
43
+ const chainTracker = new WhatsOnChain(network, { httpClient: new FetchHttpClient(mockFetch) })
47
44
  const response = await chainTracker.isValidRootForHeight(merkleroot, height)
48
45
 
49
46
  expect(mockFetch).toHaveBeenCalled()
@@ -53,7 +50,7 @@ describe('WhatsOnChain ChainTracker', () => {
53
50
  it('should verify merkleroot successfully using provided Node.js https', async () => {
54
51
  const mockHttps = mockedHttps(successResponse)
55
52
 
56
- const chainTracker = new WhatsOnChain(network, {httpClient: new NodejsHttpClient(mockHttps)})
53
+ const chainTracker = new WhatsOnChain(network, { httpClient: new NodejsHttpClient(mockHttps) })
57
54
  const response = await chainTracker.isValidRootForHeight(merkleroot, height)
58
55
 
59
56
  expect(response).toEqual(true)
@@ -62,10 +59,10 @@ describe('WhatsOnChain ChainTracker', () => {
62
59
  it('should respond with invalid root for height when block for height is not found', async () => {
63
60
  const mockFetch = mockedFetch({
64
61
  status: 404,
65
- data: "not found"
62
+ data: 'not found'
66
63
  })
67
64
 
68
- const chainTracker = new WhatsOnChain(network, {httpClient: new FetchHttpClient(mockFetch)})
65
+ const chainTracker = new WhatsOnChain(network, { httpClient: new FetchHttpClient(mockFetch) })
69
66
  const response = await chainTracker.isValidRootForHeight(merkleroot, height)
70
67
 
71
68
  expect(response).toEqual(false)
@@ -74,7 +71,7 @@ describe('WhatsOnChain ChainTracker', () => {
74
71
  it('should handle network errors', async () => {
75
72
  const mockFetch = jest.fn().mockRejectedValue(new Error('Network error'))
76
73
 
77
- const chainTracker = new WhatsOnChain(network, {httpClient: new FetchHttpClient(mockFetch)})
74
+ const chainTracker = new WhatsOnChain(network, { httpClient: new FetchHttpClient(mockFetch) })
78
75
 
79
76
  await expect(chainTracker.isValidRootForHeight(merkleroot, height)).rejects.toThrow('Network error')
80
77
  })
@@ -85,28 +82,28 @@ describe('WhatsOnChain ChainTracker', () => {
85
82
  data: { error: 'Unauthorized' }
86
83
  })
87
84
 
88
- const chainTracker = new WhatsOnChain(network, {httpClient: new FetchHttpClient(mockFetch)})
85
+ const chainTracker = new WhatsOnChain(network, { httpClient: new FetchHttpClient(mockFetch) })
89
86
 
90
87
  await expect(chainTracker.isValidRootForHeight(merkleroot, height)).rejects.toThrow(/Failed to verify merkleroot for height \d+ because of an error: .*/)
91
88
  })
92
89
 
93
- function mockedFetch(response) {
90
+ function mockedFetch (response) {
94
91
  return jest.fn().mockResolvedValue({
95
92
  ok: response.status === 200,
96
93
  status: response.status,
97
94
  statusText: response.status === 200 ? 'OK' : 'Bad request',
98
95
  headers: {
99
- get(key: string) {
96
+ get (key: string) {
100
97
  if (key === 'Content-Type') {
101
98
  return 'application/json'
102
99
  }
103
100
  }
104
101
  },
105
102
  json: async () => response.data
106
- });
103
+ })
107
104
  }
108
105
 
109
- function mockedHttps(response) {
106
+ function mockedHttps (response) {
110
107
  const https = {
111
108
  request: (url, options, callback) => {
112
109
  // eslint-disable-next-line
@@ -132,4 +129,3 @@ describe('WhatsOnChain ChainTracker', () => {
132
129
  return https
133
130
  }
134
131
  })
135
-
@@ -17,7 +17,7 @@ export default class SatoshisPerKilobyte implements FeeModel {
17
17
  *
18
18
  * @param {number} value - The number of satoshis per kilobyte to charge as a fee.
19
19
  */
20
- constructor(value: number) {
20
+ constructor (value: number) {
21
21
  this.value = value
22
22
  }
23
23
 
@@ -27,7 +27,7 @@ export default class SatoshisPerKilobyte implements FeeModel {
27
27
  * @param tx The transaction for which a fee is to be computed.
28
28
  * @returns The fee in satoshis for the transaction, as a BigNumber.
29
29
  */
30
- async computeFee(tx: Transaction): Promise<number> {
30
+ async computeFee (tx: Transaction): Promise<number> {
31
31
  const getVarIntSize = (i: number): number => {
32
32
  if (i > 2 ** 32) {
33
33
  return 9
@@ -1,32 +1,32 @@
1
- import { HttpClient, HttpClientResponse } from './HttpClient.js';
2
- import { NodejsHttpClient } from './NodejsHttpClient.js';
3
- import { FetchHttpClient } from './FetchHttpClient.js';
1
+ import { HttpClient, HttpClientResponse } from './HttpClient.js'
2
+ import { NodejsHttpClient } from './NodejsHttpClient.js'
3
+ import { FetchHttpClient } from './FetchHttpClient.js'
4
4
 
5
5
  /**
6
6
  * Returns a default HttpClient implementation based on the environment that it is run on.
7
7
  * This method will attempt to use `window.fetch` if available (in browser environments).
8
8
  * If running in a Node.js environment, it falls back to using the Node.js `https` module
9
9
  */
10
- export function defaultHttpClient(): HttpClient {
10
+ export function defaultHttpClient (): HttpClient {
11
11
  const noHttpClient: HttpClient = {
12
- request(..._): Promise<HttpClientResponse> {
13
- throw new Error('No method available to perform HTTP request');
14
- },
15
- };
12
+ async request (..._): Promise<HttpClientResponse> {
13
+ throw new Error('No method available to perform HTTP request')
14
+ }
15
+ }
16
16
 
17
17
  if (typeof window !== 'undefined' && typeof window.fetch === 'function') {
18
18
  // Use fetch in a browser environment
19
- return new FetchHttpClient(window.fetch);
19
+ return new FetchHttpClient(window.fetch)
20
20
  } else if (typeof require !== 'undefined') {
21
21
  // Use Node.js https module
22
22
  // eslint-disable-next-line
23
23
  try {
24
- const https = require('https');
25
- return new NodejsHttpClient(https);
24
+ const https = require('https')
25
+ return new NodejsHttpClient(https)
26
26
  } catch (e) {
27
- return noHttpClient;
27
+ return noHttpClient
28
28
  }
29
29
  } else {
30
- return noHttpClient;
30
+ return noHttpClient
31
31
  }
32
32
  }