undici 7.14.0 → 7.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,20 +11,6 @@ const assert = require('node:assert')
11
11
  const { isUint8Array } = require('node:util/types')
12
12
  const { webidl } = require('../webidl')
13
13
 
14
- let supportedHashes = []
15
-
16
- // https://nodejs.org/api/crypto.html#determining-if-crypto-support-is-unavailable
17
- /** @type {import('crypto')} */
18
- let crypto
19
- try {
20
- crypto = require('node:crypto')
21
- const possibleRelevantHashes = ['sha256', 'sha384', 'sha512']
22
- supportedHashes = crypto.getHashes().filter((hash) => possibleRelevantHashes.includes(hash))
23
- /* c8 ignore next 3 */
24
- } catch {
25
-
26
- }
27
-
28
14
  function responseURL (response) {
29
15
  // https://fetch.spec.whatwg.org/#responses
30
16
  // A response has an associated URL. It is a pointer to the last URL
@@ -698,206 +684,6 @@ function isURLPotentiallyTrustworthy (url) {
698
684
  return isOriginPotentiallyTrustworthy(url.origin)
699
685
  }
700
686
 
701
- /**
702
- * @see https://w3c.github.io/webappsec-subresource-integrity/#does-response-match-metadatalist
703
- * @param {Uint8Array} bytes
704
- * @param {string} metadataList
705
- */
706
- function bytesMatch (bytes, metadataList) {
707
- // If node is not built with OpenSSL support, we cannot check
708
- // a request's integrity, so allow it by default (the spec will
709
- // allow requests if an invalid hash is given, as precedence).
710
- /* istanbul ignore if: only if node is built with --without-ssl */
711
- if (crypto === undefined) {
712
- return true
713
- }
714
-
715
- // 1. Let parsedMetadata be the result of parsing metadataList.
716
- const parsedMetadata = parseMetadata(metadataList)
717
-
718
- // 2. If parsedMetadata is no metadata, return true.
719
- if (parsedMetadata === 'no metadata') {
720
- return true
721
- }
722
-
723
- // 3. If response is not eligible for integrity validation, return false.
724
- // TODO
725
-
726
- // 4. If parsedMetadata is the empty set, return true.
727
- if (parsedMetadata.length === 0) {
728
- return true
729
- }
730
-
731
- // 5. Let metadata be the result of getting the strongest
732
- // metadata from parsedMetadata.
733
- const strongest = getStrongestMetadata(parsedMetadata)
734
- const metadata = filterMetadataListByAlgorithm(parsedMetadata, strongest)
735
-
736
- // 6. For each item in metadata:
737
- for (const item of metadata) {
738
- // 1. Let algorithm be the alg component of item.
739
- const algorithm = item.algo
740
-
741
- // 2. Let expectedValue be the val component of item.
742
- const expectedValue = item.hash
743
-
744
- // See https://github.com/web-platform-tests/wpt/commit/e4c5cc7a5e48093220528dfdd1c4012dc3837a0e
745
- // "be liberal with padding". This is annoying, and it's not even in the spec.
746
-
747
- // 3. Let actualValue be the result of applying algorithm to bytes.
748
- let actualValue = crypto.createHash(algorithm).update(bytes).digest('base64')
749
-
750
- if (actualValue[actualValue.length - 1] === '=') {
751
- if (actualValue[actualValue.length - 2] === '=') {
752
- actualValue = actualValue.slice(0, -2)
753
- } else {
754
- actualValue = actualValue.slice(0, -1)
755
- }
756
- }
757
-
758
- // 4. If actualValue is a case-sensitive match for expectedValue,
759
- // return true.
760
- if (compareBase64Mixed(actualValue, expectedValue)) {
761
- return true
762
- }
763
- }
764
-
765
- // 7. Return false.
766
- return false
767
- }
768
-
769
- // https://w3c.github.io/webappsec-subresource-integrity/#grammardef-hash-with-options
770
- // https://www.w3.org/TR/CSP2/#source-list-syntax
771
- // https://www.rfc-editor.org/rfc/rfc5234#appendix-B.1
772
- const parseHashWithOptions = /(?<algo>sha256|sha384|sha512)-((?<hash>[A-Za-z0-9+/]+|[A-Za-z0-9_-]+)={0,2}(?:\s|$)( +[!-~]*)?)?/i
773
-
774
- /**
775
- * @see https://w3c.github.io/webappsec-subresource-integrity/#parse-metadata
776
- * @param {string} metadata
777
- */
778
- function parseMetadata (metadata) {
779
- // 1. Let result be the empty set.
780
- /** @type {{ algo: string, hash: string }[]} */
781
- const result = []
782
-
783
- // 2. Let empty be equal to true.
784
- let empty = true
785
-
786
- // 3. For each token returned by splitting metadata on spaces:
787
- for (const token of metadata.split(' ')) {
788
- // 1. Set empty to false.
789
- empty = false
790
-
791
- // 2. Parse token as a hash-with-options.
792
- const parsedToken = parseHashWithOptions.exec(token)
793
-
794
- // 3. If token does not parse, continue to the next token.
795
- if (
796
- parsedToken === null ||
797
- parsedToken.groups === undefined ||
798
- parsedToken.groups.algo === undefined
799
- ) {
800
- // Note: Chromium blocks the request at this point, but Firefox
801
- // gives a warning that an invalid integrity was given. The
802
- // correct behavior is to ignore these, and subsequently not
803
- // check the integrity of the resource.
804
- continue
805
- }
806
-
807
- // 4. Let algorithm be the hash-algo component of token.
808
- const algorithm = parsedToken.groups.algo.toLowerCase()
809
-
810
- // 5. If algorithm is a hash function recognized by the user
811
- // agent, add the parsed token to result.
812
- if (supportedHashes.includes(algorithm)) {
813
- result.push(parsedToken.groups)
814
- }
815
- }
816
-
817
- // 4. Return no metadata if empty is true, otherwise return result.
818
- if (empty === true) {
819
- return 'no metadata'
820
- }
821
-
822
- return result
823
- }
824
-
825
- /**
826
- * @param {{ algo: 'sha256' | 'sha384' | 'sha512' }[]} metadataList
827
- */
828
- function getStrongestMetadata (metadataList) {
829
- // Let algorithm be the algo component of the first item in metadataList.
830
- // Can be sha256
831
- let algorithm = metadataList[0].algo
832
- // If the algorithm is sha512, then it is the strongest
833
- // and we can return immediately
834
- if (algorithm[3] === '5') {
835
- return algorithm
836
- }
837
-
838
- for (let i = 1; i < metadataList.length; ++i) {
839
- const metadata = metadataList[i]
840
- // If the algorithm is sha512, then it is the strongest
841
- // and we can break the loop immediately
842
- if (metadata.algo[3] === '5') {
843
- algorithm = 'sha512'
844
- break
845
- // If the algorithm is sha384, then a potential sha256 or sha384 is ignored
846
- } else if (algorithm[3] === '3') {
847
- continue
848
- // algorithm is sha256, check if algorithm is sha384 and if so, set it as
849
- // the strongest
850
- } else if (metadata.algo[3] === '3') {
851
- algorithm = 'sha384'
852
- }
853
- }
854
- return algorithm
855
- }
856
-
857
- function filterMetadataListByAlgorithm (metadataList, algorithm) {
858
- if (metadataList.length === 1) {
859
- return metadataList
860
- }
861
-
862
- let pos = 0
863
- for (let i = 0; i < metadataList.length; ++i) {
864
- if (metadataList[i].algo === algorithm) {
865
- metadataList[pos++] = metadataList[i]
866
- }
867
- }
868
-
869
- metadataList.length = pos
870
-
871
- return metadataList
872
- }
873
-
874
- /**
875
- * Compares two base64 strings, allowing for base64url
876
- * in the second string.
877
- *
878
- * @param {string} actualValue always base64
879
- * @param {string} expectedValue base64 or base64url
880
- * @returns {boolean}
881
- */
882
- function compareBase64Mixed (actualValue, expectedValue) {
883
- if (actualValue.length !== expectedValue.length) {
884
- return false
885
- }
886
- for (let i = 0; i < actualValue.length; ++i) {
887
- if (actualValue[i] !== expectedValue[i]) {
888
- if (
889
- (actualValue[i] === '+' && expectedValue[i] === '-') ||
890
- (actualValue[i] === '/' && expectedValue[i] === '_')
891
- ) {
892
- continue
893
- }
894
- return false
895
- }
896
- }
897
-
898
- return true
899
- }
900
-
901
687
  // https://w3c.github.io/webappsec-upgrade-insecure-requests/#upgrade-request
902
688
  function tryUpgradeRequestToAPotentiallyTrustworthyURL (request) {
903
689
  // TODO
@@ -1761,7 +1547,6 @@ module.exports = {
1761
1547
  isValidHeaderValue,
1762
1548
  isErrorLike,
1763
1549
  fullyReadBody,
1764
- bytesMatch,
1765
1550
  readableStreamClose,
1766
1551
  isomorphicEncode,
1767
1552
  urlIsLocal,
@@ -1770,7 +1555,6 @@ module.exports = {
1770
1555
  readAllBytes,
1771
1556
  simpleRangeHeaderValue,
1772
1557
  buildContentRange,
1773
- parseMetadata,
1774
1558
  createInflate,
1775
1559
  extractMimeType,
1776
1560
  getDecodeSplit,
@@ -0,0 +1,9 @@
1
+ # Subresource Integrity
2
+
3
+ based on Editor’s Draft, 12 June 2025
4
+
5
+ This module provides support for Subresource Integrity (SRI) in the context of web fetch operations. SRI is a security feature that allows clients to verify that fetched resources are delivered without unexpected manipulation.
6
+
7
+ ## Links
8
+
9
+ - [Subresource Integrity](https://w3c.github.io/webappsec-subresource-integrity/)
@@ -0,0 +1,306 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+
5
+ /**
6
+ * @typedef {object} Metadata
7
+ * @property {SRIHashAlgorithm} alg - The algorithm used for the hash.
8
+ * @property {string} val - The base64-encoded hash value.
9
+ */
10
+
11
+ /**
12
+ * @typedef {Metadata[]} MetadataList
13
+ */
14
+
15
+ /**
16
+ * @typedef {('sha256' | 'sha384' | 'sha512')} SRIHashAlgorithm
17
+ */
18
+
19
+ /**
20
+ * @type {Map<SRIHashAlgorithm, number>}
21
+ *
22
+ * The valid SRI hash algorithm token set is the ordered set « "sha256",
23
+ * "sha384", "sha512" » (corresponding to SHA-256, SHA-384, and SHA-512
24
+ * respectively). The ordering of this set is meaningful, with stronger
25
+ * algorithms appearing later in the set.
26
+ *
27
+ * @see https://w3c.github.io/webappsec-subresource-integrity/#valid-sri-hash-algorithm-token-set
28
+ */
29
+ const validSRIHashAlgorithmTokenSet = new Map([['sha256', 0], ['sha384', 1], ['sha512', 2]])
30
+
31
+ // https://nodejs.org/api/crypto.html#determining-if-crypto-support-is-unavailable
32
+ /** @type {import('crypto')} */
33
+ let crypto
34
+ try {
35
+ crypto = require('node:crypto')
36
+ const cryptoHashes = crypto.getHashes()
37
+
38
+ // If no hashes are available, we cannot support SRI.
39
+ if (cryptoHashes.length === 0) {
40
+ validSRIHashAlgorithmTokenSet.clear()
41
+ }
42
+
43
+ for (const algorithm of validSRIHashAlgorithmTokenSet.keys()) {
44
+ // If the algorithm is not supported, remove it from the list.
45
+ if (cryptoHashes.includes(algorithm) === false) {
46
+ validSRIHashAlgorithmTokenSet.delete(algorithm)
47
+ }
48
+ }
49
+ /* c8 ignore next 4 */
50
+ } catch {
51
+ // If crypto is not available, we cannot support SRI.
52
+ validSRIHashAlgorithmTokenSet.clear()
53
+ }
54
+
55
+ /**
56
+ * @typedef GetSRIHashAlgorithmIndex
57
+ * @type {(algorithm: SRIHashAlgorithm) => number}
58
+ * @param {SRIHashAlgorithm} algorithm
59
+ * @returns {number} The index of the algorithm in the valid SRI hash algorithm
60
+ * token set.
61
+ */
62
+
63
+ const getSRIHashAlgorithmIndex = /** @type {GetSRIHashAlgorithmIndex} */ (Map.prototype.get.bind(
64
+ validSRIHashAlgorithmTokenSet))
65
+
66
+ /**
67
+ * @typedef IsValidSRIHashAlgorithm
68
+ * @type {(algorithm: string) => algorithm is SRIHashAlgorithm}
69
+ * @param {*} algorithm
70
+ * @returns {algorithm is SRIHashAlgorithm}
71
+ */
72
+
73
+ const isValidSRIHashAlgorithm = /** @type {IsValidSRIHashAlgorithm} */ (
74
+ Map.prototype.has.bind(validSRIHashAlgorithmTokenSet)
75
+ )
76
+
77
+ /**
78
+ * @param {Uint8Array} bytes
79
+ * @param {string} metadataList
80
+ * @returns {boolean}
81
+ *
82
+ * @see https://w3c.github.io/webappsec-subresource-integrity/#does-response-match-metadatalist
83
+ */
84
+ const bytesMatch = crypto === undefined || validSRIHashAlgorithmTokenSet.size === 0
85
+ // If node is not built with OpenSSL support, we cannot check
86
+ // a request's integrity, so allow it by default (the spec will
87
+ // allow requests if an invalid hash is given, as precedence).
88
+ ? () => true
89
+ : (bytes, metadataList) => {
90
+ // 1. Let parsedMetadata be the result of parsing metadataList.
91
+ const parsedMetadata = parseMetadata(metadataList)
92
+
93
+ // 2. If parsedMetadata is empty set, return true.
94
+ if (parsedMetadata.length === 0) {
95
+ return true
96
+ }
97
+
98
+ // 3. Let metadata be the result of getting the strongest
99
+ // metadata from parsedMetadata.
100
+ const metadata = getStrongestMetadata(parsedMetadata)
101
+
102
+ // 4. For each item in metadata:
103
+ for (const item of metadata) {
104
+ // 1. Let algorithm be the item["alg"].
105
+ const algorithm = item.alg
106
+
107
+ // 2. Let expectedValue be the item["val"].
108
+ const expectedValue = item.val
109
+
110
+ // See https://github.com/web-platform-tests/wpt/commit/e4c5cc7a5e48093220528dfdd1c4012dc3837a0e
111
+ // "be liberal with padding". This is annoying, and it's not even in the spec.
112
+
113
+ // 3. Let actualValue be the result of applying algorithm to bytes .
114
+ const actualValue = applyAlgorithmToBytes(algorithm, bytes)
115
+
116
+ // 4. If actualValue is a case-sensitive match for expectedValue,
117
+ // return true.
118
+ if (caseSensitiveMatch(actualValue, expectedValue)) {
119
+ return true
120
+ }
121
+ }
122
+
123
+ // 5. Return false.
124
+ return false
125
+ }
126
+
127
+ /**
128
+ * @param {MetadataList} metadataList
129
+ * @returns {MetadataList} The strongest hash algorithm from the metadata list.
130
+ */
131
+ function getStrongestMetadata (metadataList) {
132
+ // 1. Let result be the empty set and strongest be the empty string.
133
+ const result = []
134
+ /** @type {Metadata|null} */
135
+ let strongest = null
136
+
137
+ // 2. For each item in set:
138
+ for (const item of metadataList) {
139
+ // 1. Assert: item["alg"] is a valid SRI hash algorithm token.
140
+ assert(isValidSRIHashAlgorithm(item.alg), 'Invalid SRI hash algorithm token')
141
+
142
+ // 2. If result is the empty set, then:
143
+ if (result.length === 0) {
144
+ // 1. Append item to result.
145
+ result.push(item)
146
+
147
+ // 2. Set strongest to item.
148
+ strongest = item
149
+
150
+ // 3. Continue.
151
+ continue
152
+ }
153
+
154
+ // 3. Let currentAlgorithm be strongest["alg"], and currentAlgorithmIndex be
155
+ // the index of currentAlgorithm in the valid SRI hash algorithm token set.
156
+ const currentAlgorithm = /** @type {Metadata} */ (strongest).alg
157
+ const currentAlgorithmIndex = getSRIHashAlgorithmIndex(currentAlgorithm)
158
+
159
+ // 4. Let newAlgorithm be the item["alg"], and newAlgorithmIndex be the
160
+ // index of newAlgorithm in the valid SRI hash algorithm token set.
161
+ const newAlgorithm = item.alg
162
+ const newAlgorithmIndex = getSRIHashAlgorithmIndex(newAlgorithm)
163
+
164
+ // 5. If newAlgorithmIndex is less than currentAlgorithmIndex, then continue.
165
+ if (newAlgorithmIndex < currentAlgorithmIndex) {
166
+ continue
167
+
168
+ // 6. Otherwise, if newAlgorithmIndex is greater than
169
+ // currentAlgorithmIndex:
170
+ } else if (newAlgorithmIndex > currentAlgorithmIndex) {
171
+ // 1. Set strongest to item.
172
+ strongest = item
173
+
174
+ // 2. Set result to « item ».
175
+ result[0] = item
176
+ result.length = 1
177
+
178
+ // 7. Otherwise, newAlgorithmIndex and currentAlgorithmIndex are the same
179
+ // value. Append item to result.
180
+ } else {
181
+ result.push(item)
182
+ }
183
+ }
184
+
185
+ // 3. Return result.
186
+ return result
187
+ }
188
+
189
+ /**
190
+ * @param {string} metadata
191
+ * @returns {MetadataList}
192
+ *
193
+ * @see https://w3c.github.io/webappsec-subresource-integrity/#parse-metadata
194
+ */
195
+ function parseMetadata (metadata) {
196
+ // 1. Let result be the empty set.
197
+ /** @type {MetadataList} */
198
+ const result = []
199
+
200
+ // 2. For each item returned by splitting metadata on spaces:
201
+ for (const item of metadata.split(' ')) {
202
+ // 1. Let expression-and-options be the result of splitting item on U+003F (?).
203
+ const expressionAndOptions = item.split('?', 1)
204
+
205
+ // 2. Let algorithm-expression be expression-and-options[0].
206
+ const algorithmExpression = expressionAndOptions[0]
207
+
208
+ // 3. Let base64-value be the empty string.
209
+ let base64Value = ''
210
+
211
+ // 4. Let algorithm-and-value be the result of splitting algorithm-expression on U+002D (-).
212
+ const algorithmAndValue = [algorithmExpression.slice(0, 6), algorithmExpression.slice(7)]
213
+
214
+ // 5. Let algorithm be algorithm-and-value[0].
215
+ const algorithm = algorithmAndValue[0]
216
+
217
+ // 6. If algorithm is not a valid SRI hash algorithm token, then continue.
218
+ if (!isValidSRIHashAlgorithm(algorithm)) {
219
+ continue
220
+ }
221
+
222
+ // 7. If algorithm-and-value[1] exists, set base64-value to
223
+ // algorithm-and-value[1].
224
+ if (algorithmAndValue[1]) {
225
+ base64Value = algorithmAndValue[1]
226
+ }
227
+
228
+ // 8. Let metadata be the ordered map
229
+ // «["alg" → algorithm, "val" → base64-value]».
230
+ const metadata = {
231
+ alg: algorithm,
232
+ val: base64Value
233
+ }
234
+
235
+ // 9. Append metadata to result.
236
+ result.push(metadata)
237
+ }
238
+
239
+ // 3. Return result.
240
+ return result
241
+ }
242
+
243
+ /**
244
+ * Applies the specified hash algorithm to the given bytes
245
+ *
246
+ * @typedef {(algorithm: SRIHashAlgorithm, bytes: Uint8Array) => string} ApplyAlgorithmToBytes
247
+ * @param {SRIHashAlgorithm} algorithm
248
+ * @param {Uint8Array} bytes
249
+ * @returns {string}
250
+ */
251
+ const applyAlgorithmToBytes = (algorithm, bytes) => {
252
+ return crypto.hash(algorithm, bytes, 'base64')
253
+ }
254
+
255
+ /**
256
+ * Compares two base64 strings, allowing for base64url
257
+ * in the second string.
258
+ *
259
+ * @param {string} actualValue base64 encoded string
260
+ * @param {string} expectedValue base64 or base64url encoded string
261
+ * @returns {boolean}
262
+ */
263
+ function caseSensitiveMatch (actualValue, expectedValue) {
264
+ // Ignore padding characters from the end of the strings by
265
+ // decreasing the length by 1 or 2 if the last characters are `=`.
266
+ let actualValueLength = actualValue.length
267
+ if (actualValueLength !== 0 && actualValue[actualValueLength - 1] === '=') {
268
+ actualValueLength -= 1
269
+ }
270
+ if (actualValueLength !== 0 && actualValue[actualValueLength - 1] === '=') {
271
+ actualValueLength -= 1
272
+ }
273
+ let expectedValueLength = expectedValue.length
274
+ if (expectedValueLength !== 0 && expectedValue[expectedValueLength - 1] === '=') {
275
+ expectedValueLength -= 1
276
+ }
277
+ if (expectedValueLength !== 0 && expectedValue[expectedValueLength - 1] === '=') {
278
+ expectedValueLength -= 1
279
+ }
280
+
281
+ if (actualValueLength !== expectedValueLength) {
282
+ return false
283
+ }
284
+
285
+ for (let i = 0; i < actualValueLength; ++i) {
286
+ if (
287
+ actualValue[i] === expectedValue[i] ||
288
+ (actualValue[i] === '+' && expectedValue[i] === '-') ||
289
+ (actualValue[i] === '/' && expectedValue[i] === '_')
290
+ ) {
291
+ continue
292
+ }
293
+ return false
294
+ }
295
+
296
+ return true
297
+ }
298
+
299
+ module.exports = {
300
+ applyAlgorithmToBytes,
301
+ bytesMatch,
302
+ caseSensitiveMatch,
303
+ isValidSRIHashAlgorithm,
304
+ getStrongestMetadata,
305
+ parseMetadata
306
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "7.14.0",
3
+ "version": "7.15.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -69,7 +69,7 @@
69
69
  "lint:fix": "eslint --fix --cache",
70
70
  "test": "npm run test:javascript && cross-env NODE_V8_COVERAGE= npm run test:typescript",
71
71
  "test:javascript": "npm run test:javascript:no-jest && npm run test:jest",
72
- "test:javascript:no-jest": "npm run generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:cache && npm run test:cache-interceptor && npm run test:interceptors && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:cache-tests",
72
+ "test:javascript:no-jest": "npm run generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:cache && npm run test:cache-interceptor && npm run test:interceptors && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:subresource-integrity && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:cache-tests",
73
73
  "test:javascript:without-intl": "npm run test:javascript:no-jest",
74
74
  "test:busboy": "borp -p \"test/busboy/*.js\"",
75
75
  "test:cache": "borp -p \"test/cache/*.js\"",
@@ -79,6 +79,7 @@
79
79
  "test:eventsource": "npm run build:node && borp --expose-gc -p \"test/eventsource/*.js\"",
80
80
  "test:fuzzing": "node test/fuzzing/fuzzing.test.js",
81
81
  "test:fetch": "npm run build:node && borp --timeout 180000 --expose-gc --concurrency 1 -p \"test/fetch/*.js\" && npm run test:webidl && npm run test:busboy",
82
+ "test:subresource-integrity": "borp -p \"test/subresource-integrity/*.js\"",
82
83
  "test:h2": "npm run test:h2:core && npm run test:h2:fetch",
83
84
  "test:h2:core": "borp -p \"test/+(http2|h2)*.js\"",
84
85
  "test:h2:fetch": "npm run build:node && borp -p \"test/fetch/http2*.js\"",
@@ -107,7 +108,7 @@
107
108
  "prepare": "husky && node ./scripts/platform-shell.js"
108
109
  },
109
110
  "devDependencies": {
110
- "@fastify/busboy": "3.1.1",
111
+ "@fastify/busboy": "3.2.0",
111
112
  "@matteo.collina/tspl": "^0.2.0",
112
113
  "@metcoder95/https-pem": "^1.0.0",
113
114
  "@sinonjs/fake-timers": "^12.0.0",
@@ -16,7 +16,6 @@ declare namespace DiagnosticsChannel {
16
16
  statusText: string;
17
17
  headers: Array<Buffer>;
18
18
  }
19
- type Error = unknown
20
19
  interface ConnectParams {
21
20
  host: URL['host'];
22
21
  hostname: URL['hostname'];
@@ -9,6 +9,10 @@ declare namespace Interceptors {
9
9
  export type DumpInterceptorOpts = { maxSize?: number }
10
10
  export type RetryInterceptorOpts = RetryHandler.RetryOptions
11
11
  export type RedirectInterceptorOpts = { maxRedirections?: number }
12
+ export type DecompressInterceptorOpts = {
13
+ skipErrorResponses?: boolean
14
+ skipStatusCodes?: number[]
15
+ }
12
16
 
13
17
  export type ResponseErrorInterceptorOpts = { throwOnError: boolean }
14
18
  export type CacheInterceptorOpts = CacheHandler.CacheOptions
@@ -28,6 +32,7 @@ declare namespace Interceptors {
28
32
  export function dump (opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
29
33
  export function retry (opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
30
34
  export function redirect (opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
35
+ export function decompress (opts?: DecompressInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
31
36
  export function responseError (opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
32
37
  export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
33
38
  export function cache (opts?: CacheInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
@@ -18,9 +18,11 @@ declare class SnapshotRecorder {
18
18
  }
19
19
 
20
20
  declare namespace SnapshotRecorder {
21
+ type SnapshotRecorderMode = 'record' | 'playback' | 'update'
22
+
21
23
  export interface Options {
22
24
  snapshotPath?: string
23
- mode?: 'record' | 'playback' | 'update'
25
+ mode?: SnapshotRecorderMode
24
26
  maxSnapshots?: number
25
27
  autoFlush?: boolean
26
28
  flushInterval?: number
@@ -77,7 +79,7 @@ declare class SnapshotAgent extends MockAgent {
77
79
  saveSnapshots (filePath?: string): Promise<void>
78
80
  loadSnapshots (filePath?: string): Promise<void>
79
81
  getRecorder (): SnapshotRecorder
80
- getMode (): 'record' | 'playback' | 'update'
82
+ getMode (): SnapshotRecorder.SnapshotRecorderMode
81
83
  clearSnapshots (): void
82
84
  resetCallCounts (): void
83
85
  deleteSnapshot (requestOpts: any): boolean
@@ -87,7 +89,7 @@ declare class SnapshotAgent extends MockAgent {
87
89
 
88
90
  declare namespace SnapshotAgent {
89
91
  export interface Options extends MockAgent.Options {
90
- mode?: 'record' | 'playback' | 'update'
92
+ mode?: SnapshotRecorder.SnapshotRecorderMode
91
93
  snapshotPath?: string
92
94
  maxSnapshots?: number
93
95
  autoFlush?: boolean