@zuplo/cli 6.73.8 → 6.73.11

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 (229) hide show
  1. package/dist/cli.js +2 -11
  2. package/dist/cli.js.map +1 -1
  3. package/dist/common/cli-dispatcher.d.ts +6 -0
  4. package/dist/common/cli-dispatcher.d.ts.map +1 -0
  5. package/dist/common/cli-dispatcher.js +19 -0
  6. package/dist/common/cli-dispatcher.js.map +1 -0
  7. package/dist/common/cli-dispatcher.test.d.ts +2 -0
  8. package/dist/common/cli-dispatcher.test.d.ts.map +1 -0
  9. package/dist/common/cli-dispatcher.test.js +78 -0
  10. package/dist/common/cli-dispatcher.test.js.map +1 -0
  11. package/dist/tsconfig.tsbuildinfo +1 -1
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/README.md +1 -4
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwks/remote.d.ts +3 -3
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_to_jwk.js +4 -1
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  17. package/node_modules/@posthog/core/dist/posthog-core.d.ts +5 -2
  18. package/node_modules/@posthog/core/dist/posthog-core.d.ts.map +1 -1
  19. package/node_modules/@posthog/core/dist/posthog-core.js +9 -3
  20. package/node_modules/@posthog/core/dist/posthog-core.mjs +9 -3
  21. package/node_modules/@posthog/core/dist/types.d.ts +4 -0
  22. package/node_modules/@posthog/core/dist/types.d.ts.map +1 -1
  23. package/node_modules/@posthog/core/package.json +2 -2
  24. package/node_modules/@posthog/core/src/posthog-core.ts +10 -5
  25. package/node_modules/@posthog/core/src/types.ts +5 -0
  26. package/node_modules/@posthog/types/dist/feature-flags.d.ts +9 -0
  27. package/node_modules/@posthog/types/dist/feature-flags.d.ts.map +1 -1
  28. package/node_modules/@posthog/types/dist/index.d.ts +1 -1
  29. package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
  30. package/node_modules/@posthog/types/dist/posthog.d.ts +6 -2
  31. package/node_modules/@posthog/types/dist/posthog.d.ts.map +1 -1
  32. package/node_modules/@posthog/types/package.json +1 -1
  33. package/node_modules/@posthog/types/src/feature-flags.ts +10 -0
  34. package/node_modules/@posthog/types/src/index.ts +1 -0
  35. package/node_modules/@posthog/types/src/posthog.ts +4 -1
  36. package/node_modules/@zuplo/core/customer.cli.minified.js +253 -253
  37. package/node_modules/@zuplo/core/index.minified.js +259 -259
  38. package/node_modules/@zuplo/core/package.json +1 -1
  39. package/node_modules/@zuplo/graphql/package.json +1 -1
  40. package/node_modules/@zuplo/openapi-tools/package.json +2 -2
  41. package/node_modules/@zuplo/otel/package.json +1 -1
  42. package/node_modules/@zuplo/runtime/out/esm/{chunk-W5A5ADF4.js → chunk-7Z5GGYF5.js} +4 -4
  43. package/node_modules/@zuplo/runtime/out/esm/chunk-7Z5GGYF5.js.map +1 -0
  44. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  45. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  46. package/node_modules/@zuplo/runtime/package.json +1 -1
  47. package/node_modules/js-yaml/README.md +5 -3
  48. package/node_modules/js-yaml/dist/js-yaml.js +3009 -2402
  49. package/node_modules/js-yaml/dist/js-yaml.js.map +1 -1
  50. package/node_modules/js-yaml/dist/js-yaml.min.js +2 -33
  51. package/node_modules/js-yaml/dist/js-yaml.min.js.map +1 -1
  52. package/node_modules/js-yaml/dist/js-yaml.mjs +3073 -2381
  53. package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
  54. package/node_modules/js-yaml/lib/loader.js +7 -11
  55. package/node_modules/js-yaml/lib/type/float.js +1 -1
  56. package/node_modules/js-yaml/lib/type/int.js +4 -4
  57. package/node_modules/js-yaml/package.json +10 -4
  58. package/node_modules/tar/README.md +34 -6
  59. package/node_modules/tar/dist/commonjs/create.d.ts.map +1 -1
  60. package/node_modules/tar/dist/commonjs/create.js +3 -4
  61. package/node_modules/tar/dist/commonjs/create.js.map +1 -1
  62. package/node_modules/tar/dist/commonjs/cwd-error.d.ts +1 -1
  63. package/node_modules/tar/dist/commonjs/cwd-error.d.ts.map +1 -1
  64. package/node_modules/tar/dist/commonjs/cwd-error.js.map +1 -1
  65. package/node_modules/tar/dist/commonjs/extract.js.map +1 -1
  66. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts.map +1 -1
  67. package/node_modules/tar/dist/commonjs/get-write-flag.js +7 -4
  68. package/node_modules/tar/dist/commonjs/get-write-flag.js.map +1 -1
  69. package/node_modules/tar/dist/commonjs/header.d.ts.map +1 -1
  70. package/node_modules/tar/dist/commonjs/header.js +60 -37
  71. package/node_modules/tar/dist/commonjs/header.js.map +1 -1
  72. package/node_modules/tar/dist/commonjs/index.min.js +3 -3
  73. package/node_modules/tar/dist/commonjs/index.min.js.map +3 -3
  74. package/node_modules/tar/dist/commonjs/large-numbers.d.ts.map +1 -1
  75. package/node_modules/tar/dist/commonjs/large-numbers.js.map +1 -1
  76. package/node_modules/tar/dist/commonjs/list.d.ts +1 -1
  77. package/node_modules/tar/dist/commonjs/list.d.ts.map +1 -1
  78. package/node_modules/tar/dist/commonjs/list.js +2 -7
  79. package/node_modules/tar/dist/commonjs/list.js.map +1 -1
  80. package/node_modules/tar/dist/commonjs/make-command.d.ts +2 -2
  81. package/node_modules/tar/dist/commonjs/make-command.d.ts.map +1 -1
  82. package/node_modules/tar/dist/commonjs/make-command.js +3 -12
  83. package/node_modules/tar/dist/commonjs/make-command.js.map +1 -1
  84. package/node_modules/tar/dist/commonjs/mkdir.d.ts.map +1 -1
  85. package/node_modules/tar/dist/commonjs/mkdir.js +5 -6
  86. package/node_modules/tar/dist/commonjs/mkdir.js.map +1 -1
  87. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +1 -1
  88. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts.map +1 -1
  89. package/node_modules/tar/dist/commonjs/normalize-windows-path.js +2 -2
  90. package/node_modules/tar/dist/commonjs/normalize-windows-path.js.map +1 -1
  91. package/node_modules/tar/dist/commonjs/options.d.ts +14 -6
  92. package/node_modules/tar/dist/commonjs/options.d.ts.map +1 -1
  93. package/node_modules/tar/dist/commonjs/options.js.map +1 -1
  94. package/node_modules/tar/dist/commonjs/pack.d.ts +8 -4
  95. package/node_modules/tar/dist/commonjs/pack.d.ts.map +1 -1
  96. package/node_modules/tar/dist/commonjs/pack.js +47 -19
  97. package/node_modules/tar/dist/commonjs/pack.js.map +1 -1
  98. package/node_modules/tar/dist/commonjs/parse.d.ts +11 -4
  99. package/node_modules/tar/dist/commonjs/parse.d.ts.map +1 -1
  100. package/node_modules/tar/dist/commonjs/parse.js +61 -26
  101. package/node_modules/tar/dist/commonjs/parse.js.map +1 -1
  102. package/node_modules/tar/dist/commonjs/path-reservations.d.ts.map +1 -1
  103. package/node_modules/tar/dist/commonjs/path-reservations.js +2 -2
  104. package/node_modules/tar/dist/commonjs/path-reservations.js.map +1 -1
  105. package/node_modules/tar/dist/commonjs/pax.d.ts +1 -1
  106. package/node_modules/tar/dist/commonjs/pax.d.ts.map +1 -1
  107. package/node_modules/tar/dist/commonjs/pax.js +30 -6
  108. package/node_modules/tar/dist/commonjs/pax.js.map +1 -1
  109. package/node_modules/tar/dist/commonjs/read-entry.d.ts +3 -3
  110. package/node_modules/tar/dist/commonjs/read-entry.d.ts.map +1 -1
  111. package/node_modules/tar/dist/commonjs/read-entry.js +2 -6
  112. package/node_modules/tar/dist/commonjs/read-entry.js.map +1 -1
  113. package/node_modules/tar/dist/commonjs/replace.d.ts.map +1 -1
  114. package/node_modules/tar/dist/commonjs/replace.js +5 -10
  115. package/node_modules/tar/dist/commonjs/replace.js.map +1 -1
  116. package/node_modules/tar/dist/commonjs/symlink-error.d.ts +2 -2
  117. package/node_modules/tar/dist/commonjs/symlink-error.d.ts.map +1 -1
  118. package/node_modules/tar/dist/commonjs/symlink-error.js.map +1 -1
  119. package/node_modules/tar/dist/commonjs/types.d.ts +9 -0
  120. package/node_modules/tar/dist/commonjs/types.d.ts.map +1 -1
  121. package/node_modules/tar/dist/commonjs/types.js +21 -1
  122. package/node_modules/tar/dist/commonjs/types.js.map +1 -1
  123. package/node_modules/tar/dist/commonjs/unpack.d.ts +4 -4
  124. package/node_modules/tar/dist/commonjs/unpack.d.ts.map +1 -1
  125. package/node_modules/tar/dist/commonjs/unpack.js +39 -64
  126. package/node_modules/tar/dist/commonjs/unpack.js.map +1 -1
  127. package/node_modules/tar/dist/commonjs/warn-method.d.ts +2 -2
  128. package/node_modules/tar/dist/commonjs/warn-method.d.ts.map +1 -1
  129. package/node_modules/tar/dist/commonjs/warn-method.js.map +1 -1
  130. package/node_modules/tar/dist/commonjs/winchars.js +1 -1
  131. package/node_modules/tar/dist/commonjs/winchars.js.map +1 -1
  132. package/node_modules/tar/dist/commonjs/write-entry.d.ts +11 -11
  133. package/node_modules/tar/dist/commonjs/write-entry.d.ts.map +1 -1
  134. package/node_modules/tar/dist/commonjs/write-entry.js +12 -13
  135. package/node_modules/tar/dist/commonjs/write-entry.js.map +1 -1
  136. package/node_modules/tar/dist/esm/create.d.ts.map +1 -1
  137. package/node_modules/tar/dist/esm/create.js +3 -4
  138. package/node_modules/tar/dist/esm/create.js.map +1 -1
  139. package/node_modules/tar/dist/esm/cwd-error.d.ts +1 -1
  140. package/node_modules/tar/dist/esm/cwd-error.d.ts.map +1 -1
  141. package/node_modules/tar/dist/esm/cwd-error.js.map +1 -1
  142. package/node_modules/tar/dist/esm/extract.js.map +1 -1
  143. package/node_modules/tar/dist/esm/get-write-flag.d.ts.map +1 -1
  144. package/node_modules/tar/dist/esm/get-write-flag.js +7 -4
  145. package/node_modules/tar/dist/esm/get-write-flag.js.map +1 -1
  146. package/node_modules/tar/dist/esm/header.d.ts.map +1 -1
  147. package/node_modules/tar/dist/esm/header.js +60 -37
  148. package/node_modules/tar/dist/esm/header.js.map +1 -1
  149. package/node_modules/tar/dist/esm/index.min.js +3 -3
  150. package/node_modules/tar/dist/esm/index.min.js.map +3 -3
  151. package/node_modules/tar/dist/esm/large-numbers.d.ts.map +1 -1
  152. package/node_modules/tar/dist/esm/large-numbers.js.map +1 -1
  153. package/node_modules/tar/dist/esm/list.d.ts +1 -1
  154. package/node_modules/tar/dist/esm/list.d.ts.map +1 -1
  155. package/node_modules/tar/dist/esm/list.js +2 -7
  156. package/node_modules/tar/dist/esm/list.js.map +1 -1
  157. package/node_modules/tar/dist/esm/make-command.d.ts +2 -2
  158. package/node_modules/tar/dist/esm/make-command.d.ts.map +1 -1
  159. package/node_modules/tar/dist/esm/make-command.js +3 -12
  160. package/node_modules/tar/dist/esm/make-command.js.map +1 -1
  161. package/node_modules/tar/dist/esm/mkdir.d.ts.map +1 -1
  162. package/node_modules/tar/dist/esm/mkdir.js +5 -6
  163. package/node_modules/tar/dist/esm/mkdir.js.map +1 -1
  164. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +1 -1
  165. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts.map +1 -1
  166. package/node_modules/tar/dist/esm/normalize-windows-path.js +2 -2
  167. package/node_modules/tar/dist/esm/normalize-windows-path.js.map +1 -1
  168. package/node_modules/tar/dist/esm/options.d.ts +14 -6
  169. package/node_modules/tar/dist/esm/options.d.ts.map +1 -1
  170. package/node_modules/tar/dist/esm/options.js.map +1 -1
  171. package/node_modules/tar/dist/esm/pack.d.ts +8 -4
  172. package/node_modules/tar/dist/esm/pack.d.ts.map +1 -1
  173. package/node_modules/tar/dist/esm/pack.js +48 -20
  174. package/node_modules/tar/dist/esm/pack.js.map +1 -1
  175. package/node_modules/tar/dist/esm/parse.d.ts +11 -4
  176. package/node_modules/tar/dist/esm/parse.d.ts.map +1 -1
  177. package/node_modules/tar/dist/esm/parse.js +62 -27
  178. package/node_modules/tar/dist/esm/parse.js.map +1 -1
  179. package/node_modules/tar/dist/esm/path-reservations.d.ts.map +1 -1
  180. package/node_modules/tar/dist/esm/path-reservations.js +2 -2
  181. package/node_modules/tar/dist/esm/path-reservations.js.map +1 -1
  182. package/node_modules/tar/dist/esm/pax.d.ts +1 -1
  183. package/node_modules/tar/dist/esm/pax.d.ts.map +1 -1
  184. package/node_modules/tar/dist/esm/pax.js +30 -6
  185. package/node_modules/tar/dist/esm/pax.js.map +1 -1
  186. package/node_modules/tar/dist/esm/read-entry.d.ts +3 -3
  187. package/node_modules/tar/dist/esm/read-entry.d.ts.map +1 -1
  188. package/node_modules/tar/dist/esm/read-entry.js +2 -6
  189. package/node_modules/tar/dist/esm/read-entry.js.map +1 -1
  190. package/node_modules/tar/dist/esm/replace.d.ts.map +1 -1
  191. package/node_modules/tar/dist/esm/replace.js +6 -11
  192. package/node_modules/tar/dist/esm/replace.js.map +1 -1
  193. package/node_modules/tar/dist/esm/symlink-error.d.ts +2 -2
  194. package/node_modules/tar/dist/esm/symlink-error.d.ts.map +1 -1
  195. package/node_modules/tar/dist/esm/symlink-error.js.map +1 -1
  196. package/node_modules/tar/dist/esm/types.d.ts +9 -0
  197. package/node_modules/tar/dist/esm/types.d.ts.map +1 -1
  198. package/node_modules/tar/dist/esm/types.js +20 -0
  199. package/node_modules/tar/dist/esm/types.js.map +1 -1
  200. package/node_modules/tar/dist/esm/unpack.d.ts +4 -4
  201. package/node_modules/tar/dist/esm/unpack.d.ts.map +1 -1
  202. package/node_modules/tar/dist/esm/unpack.js +39 -64
  203. package/node_modules/tar/dist/esm/unpack.js.map +1 -1
  204. package/node_modules/tar/dist/esm/warn-method.d.ts +2 -2
  205. package/node_modules/tar/dist/esm/warn-method.d.ts.map +1 -1
  206. package/node_modules/tar/dist/esm/warn-method.js.map +1 -1
  207. package/node_modules/tar/dist/esm/winchars.js +1 -1
  208. package/node_modules/tar/dist/esm/winchars.js.map +1 -1
  209. package/node_modules/tar/dist/esm/write-entry.d.ts +11 -11
  210. package/node_modules/tar/dist/esm/write-entry.d.ts.map +1 -1
  211. package/node_modules/tar/dist/esm/write-entry.js +14 -15
  212. package/node_modules/tar/dist/esm/write-entry.js.map +1 -1
  213. package/node_modules/tar/package.json +15 -9
  214. package/node_modules/undici/docs/docs/api/Client.md +3 -0
  215. package/node_modules/undici/lib/dispatcher/agent.js +2 -2
  216. package/node_modules/undici/lib/dispatcher/client-h1.js +140 -23
  217. package/node_modules/undici/lib/dispatcher/client.js +3 -2
  218. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +10 -1
  219. package/node_modules/undici/lib/dispatcher/pool-base.js +2 -2
  220. package/node_modules/undici/lib/dispatcher/pool.js +2 -2
  221. package/node_modules/undici/lib/web/cookies/parse.js +16 -23
  222. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
  223. package/node_modules/undici/lib/web/websocket/receiver.js +110 -24
  224. package/node_modules/undici/lib/web/websocket/websocket.js +8 -1
  225. package/node_modules/undici/package.json +1 -1
  226. package/node_modules/undici/types/client.d.ts +17 -0
  227. package/package.json +9 -9
  228. package/node_modules/@zuplo/runtime/out/esm/chunk-W5A5ADF4.js.map +0 -1
  229. /package/node_modules/@zuplo/runtime/out/esm/{chunk-W5A5ADF4.js.LEGAL.txt → chunk-7Z5GGYF5.js.LEGAL.txt} +0 -0
@@ -152,7 +152,7 @@ function State (input, options) {
152
152
  this.json = options['json'] || false
153
153
  this.listener = options['listener'] || null
154
154
  this.maxDepth = typeof options['maxDepth'] === 'number' ? options['maxDepth'] : 100
155
- this.maxMergeSeqLength = typeof options['maxMergeSeqLength'] === 'number' ? options['maxMergeSeqLength'] : 20
155
+ this.maxTotalMergeKeys = typeof options['maxTotalMergeKeys'] === 'number' ? options['maxTotalMergeKeys'] : 10000
156
156
 
157
157
  this.implicitTypes = this.schema.compiledImplicit
158
158
  this.typeMap = this.schema.compiledTypeMap
@@ -163,6 +163,7 @@ function State (input, options) {
163
163
  this.lineStart = 0
164
164
  this.lineIndent = 0
165
165
  this.depth = 0
166
+ this.totalMergeKeys = 0
166
167
 
167
168
  // position of first leading tab in the current line,
168
169
  // used to make sure there are no tabs in the indentation
@@ -380,6 +381,10 @@ function mergeMappings (state, destination, source, overridableKeys) {
380
381
  for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
381
382
  const key = sourceKeys[index]
382
383
 
384
+ if (state.maxTotalMergeKeys !== -1 && ++state.totalMergeKeys > state.maxTotalMergeKeys) {
385
+ throwError(state, 'merge keys exceeded maxTotalMergeKeys (' + state.maxTotalMergeKeys + ')')
386
+ }
387
+
383
388
  if (!_hasOwnProperty.call(destination, key)) {
384
389
  setProperty(destination, key, source[key])
385
390
  overridableKeys[key] = true
@@ -421,17 +426,8 @@ function storeMappingPair (state, _result, overridableKeys, keyTag, keyNode, val
421
426
 
422
427
  if (keyTag === 'tag:yaml.org,2002:merge') {
423
428
  if (Array.isArray(valueNode)) {
424
- if (valueNode.length > state.maxMergeSeqLength) {
425
- throwError(state, 'merge sequence length exceeded maxMergeSeqLength (' + state.maxMergeSeqLength + ')')
426
- }
427
- const seen = new Set()
428
429
  for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
429
- const src = valueNode[index]
430
- // Existing keys are not overridden on merge, so dedupe sources to
431
- // avoid redundant work on repeated aliases.
432
- if (seen.has(src)) continue
433
- seen.add(src)
434
- mergeMappings(state, _result, src, overridableKeys)
430
+ mergeMappings(state, _result, valueNode[index], overridableKeys)
435
431
  }
436
432
  } else {
437
433
  mergeMappings(state, _result, valueNode, overridableKeys)
@@ -28,7 +28,7 @@ function resolveYamlFloat (data) {
28
28
  return false
29
29
  }
30
30
 
31
- if (Number.isFinite(parseFloat(data, 10))) {
31
+ if (isFinite(parseFloat(data, 10))) {
32
32
  return true
33
33
  }
34
34
 
@@ -49,7 +49,7 @@ function resolveYamlInteger (data) {
49
49
  if (ch !== '0' && ch !== '1') return false
50
50
  hasDigits = true
51
51
  }
52
- return hasDigits && Number.isFinite(parseYamlInteger(data))
52
+ return hasDigits && isFinite(parseYamlInteger(data))
53
53
  }
54
54
 
55
55
  if (ch === 'x') {
@@ -60,7 +60,7 @@ function resolveYamlInteger (data) {
60
60
  if (!isHexCode(data.charCodeAt(index))) return false
61
61
  hasDigits = true
62
62
  }
63
- return hasDigits && Number.isFinite(parseYamlInteger(data))
63
+ return hasDigits && isFinite(parseYamlInteger(data))
64
64
  }
65
65
 
66
66
  if (ch === 'o') {
@@ -71,7 +71,7 @@ function resolveYamlInteger (data) {
71
71
  if (!isOctCode(data.charCodeAt(index))) return false
72
72
  hasDigits = true
73
73
  }
74
- return hasDigits && Number.isFinite(parseYamlInteger(data))
74
+ return hasDigits && isFinite(parseYamlInteger(data))
75
75
  }
76
76
  }
77
77
 
@@ -86,7 +86,7 @@ function resolveYamlInteger (data) {
86
86
 
87
87
  if (!hasDigits) return false
88
88
 
89
- return Number.isFinite(parseYamlInteger(data))
89
+ return isFinite(parseYamlInteger(data))
90
90
  }
91
91
 
92
92
  function parseYamlInteger (data) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-yaml",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "YAML 1.2 parser and serializer",
5
5
  "keywords": [
6
6
  "yaml",
@@ -32,6 +32,9 @@
32
32
  "bin/",
33
33
  "dist/"
34
34
  ],
35
+ "publishConfig": {
36
+ "tag": "v4-legacy"
37
+ },
35
38
  "bin": {
36
39
  "js-yaml": "bin/js-yaml.js"
37
40
  },
@@ -53,8 +56,7 @@
53
56
  "build": "node support/build-dist.mjs",
54
57
  "build:demo": "npm run lint && node support/build_demo.mjs",
55
58
  "gh-demo": "npm run build:demo && gh-pages -d demo -f",
56
- "prepack": "npm test && npm run build && npm run build:demo",
57
- "postpublish": "npm run gh-demo"
59
+ "prepack": "npm test && npm run build"
58
60
  },
59
61
  "unpkg": "dist/js-yaml.min.js",
60
62
  "jsdelivr": "dist/js-yaml.min.js",
@@ -62,6 +64,10 @@
62
64
  "argparse": "^2.0.1"
63
65
  },
64
66
  "devDependencies": {
67
+ "@babel/core": "8.0.1",
68
+ "@babel/preset-env": "8.0.1",
69
+ "@rollup/plugin-commonjs": "29.0.3",
70
+ "@rollup/plugin-terser": "0.4.4",
65
71
  "c8": "^11.0.0",
66
72
  "codemirror": "^5.65.21",
67
73
  "eslint": "^9.39.4",
@@ -69,7 +75,7 @@
69
75
  "gh-pages": "^6.3.0",
70
76
  "neostandard": "^0.13.0",
71
77
  "tinybench": "^6.0.2",
72
- "vite": "^8.0.14",
78
+ "vite": "7.3.6",
73
79
  "vite-plugin-node-polyfills": "^0.28.0",
74
80
  "vite-plugin-singlefile": "^2.3.3",
75
81
  "workerpool": "^10.0.2"
@@ -32,10 +32,27 @@ implementation. (Note that most of these are disabled if
32
32
  is set, or the extraction is run as root.
33
33
  - File and directory modes in the archive are ignored, unless
34
34
  the `chmod: true` option is set.
35
-
36
- **However**, care must still be taken when dealing with data from
37
- unknown sources, especially when extracting files, with this or
38
- any library, no matter how hardened it may be.
35
+ - A path-reservation system is used to ensure that even when
36
+ multiple entries are being extracted in parallel, subsequent
37
+ entries with the same filename will not interfere with one
38
+ another (for example, exchanging a file with a symbolic link
39
+ while it is being written to).
40
+ - Unicode characters in path names are fully normalized, to
41
+ prevent evading these protections with unicode equivalences.
42
+
43
+ It is frankly unlikely that any tar implementation in JavaScript
44
+ is going to be as secure as this one, unless a similar amount of
45
+ work is put into it, putting it to the test over many years of
46
+ intensive use and scrutiny. You can vibe-code a tar extractor in
47
+ an afternoon, but you'll regret it.
48
+
49
+ > [!WARNING]
50
+ >
51
+ > **However**, all that being said, _care must still be taken_
52
+ > when dealing with data from unknown sources, especially when
53
+ > extracting files, with this or any library, no matter how
54
+ > hardened it may be. It is _your_ responsibility to use this
55
+ > library safely.
39
56
 
40
57
  1. **NEVER** extract tarball data into a folder that could be
41
58
  potentially controlled by an unknown actor. A clever attacker
@@ -43,8 +60,10 @@ any library, no matter how hardened it may be.
43
60
  link to some location of their choosing, resulting in writing
44
61
  files outside the target folder. There is no reasonable way to
45
62
  harden against this category of attack, and security reports
46
- about it will be closed. TOCTOU exposure is unavoidable when
47
- creating files based on entries in an archive file.
63
+ about it will be closed.
64
+ [TOCTOU](https://cwe.mitre.org/data/definitions/367.html)
65
+ exposure is unavoidable when creating files based on entries
66
+ in an archive file.
48
67
  2. If you are unpacking tarballs that may come from an unknown
49
68
  source, it is **highly recommended** that you use a filter
50
69
  function that rejects all hardlinks and symbolic links. Link
@@ -551,6 +570,9 @@ The following options are supported:
551
570
  defaults to 1024. Anything deeper than the limit will raise a
552
571
  warning and skip the entry. Set to `Infinity` to remove the
553
572
  limitation.
573
+ - `maxDecompressionRatio` Defaults to 1000. The maximum ratio of
574
+ decommpressed bytes to compressed bytes, in a compressed
575
+ archive. Set to `Infinity` to allow explosive decompression.
554
576
 
555
577
  The following options are mostly internal, but can be modified in some
556
578
  advanced use cases, such as re-using caches between runs.
@@ -610,6 +632,9 @@ The following options are supported:
610
632
  complete until the entry data is consumed.
611
633
  - `onwarn` A function that will get called with `(code, message, data)` for
612
634
  any warnings encountered. (See "Warnings and Errors")
635
+ - `maxDecompressionRatio` Defaults to 1000. The maximum ratio of
636
+ decommpressed bytes to compressed bytes, in a compressed
637
+ archive. Set to `Infinity` to allow explosive decompression.
613
638
 
614
639
  ### tar.u(options, fileList, callback) [alias: tar.update]
615
640
 
@@ -885,6 +910,9 @@ Most unpack errors will cause a `warn` event to be emitted. If the
885
910
  defaults to 1024. Anything deeper than the limit will raise a
886
911
  warning and skip the entry. Set to `Infinity` to remove the
887
912
  limitation.
913
+ - `maxDecompressionRatio` Defaults to 1000. The maximum ratio of
914
+ decommpressed bytes to compressed bytes, in a compressed
915
+ archive. Set to `Infinity` to allow explosive decompression.
888
916
 
889
917
  ### class UnpackSync
890
918
 
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/create.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AA8E1C,eAAO,MAAM,MAAM,wDAUlB,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/create.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AA0E1C,eAAO,MAAM,MAAM,wDAUlB,CAAA"}
@@ -28,7 +28,7 @@ const createFile = (opt, files) => {
28
28
  stream.on('close', res);
29
29
  p.on('error', rej);
30
30
  });
31
- addFilesAsync(p, files);
31
+ addFilesAsync(p, files).catch(er => p.emit('error', er));
32
32
  return promise;
33
33
  };
34
34
  const addFilesSync = (p, files) => {
@@ -48,8 +48,7 @@ const addFilesSync = (p, files) => {
48
48
  p.end();
49
49
  };
50
50
  const addFilesAsync = async (p, files) => {
51
- for (let i = 0; i < files.length; i++) {
52
- const file = String(files[i]);
51
+ for (const file of files) {
53
52
  if (file.charAt(0) === '@') {
54
53
  await (0, list_js_1.list)({
55
54
  file: node_path_1.default.resolve(String(p.cwd), file.slice(1)),
@@ -72,7 +71,7 @@ const createSync = (opt, files) => {
72
71
  };
73
72
  const createAsync = (opt, files) => {
74
73
  const p = new pack_js_1.Pack(opt);
75
- addFilesAsync(p, files);
74
+ addFilesAsync(p, files).catch(er => p.emit('error', er));
76
75
  return p;
77
76
  };
78
77
  exports.create = (0, make_command_js_1.makeCommand)(createFileSync, createFile, createSync, createAsync, (_opt, files) => {
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/create.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkE;AAElE,0DAA4B;AAC5B,uCAAgC;AAChC,uDAA+C;AAO/C,uCAA0C;AAE1C,MAAM,cAAc,GAAG,CAAC,GAAuB,EAAE,KAAe,EAAE,EAAE;IAClE,MAAM,CAAC,GAAG,IAAI,kBAAQ,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,MAAM,GAAG,IAAI,6BAAe,CAAC,GAAG,CAAC,IAAI,EAAE;QAC3C,IAAI,EAAE,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EAAE,KAAe,EAAE,EAAE;IACvD,MAAM,CAAC,GAAG,IAAI,cAAI,CAAC,GAAG,CAAC,CAAA;IACvB,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACvB,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAEY,QAAA,MAAM,GAAG,IAAA,6BAAW,EAC/B,cAAc,EACd,UAAU,EACV,UAAU,EACV,WAAW,EACX,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACd,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CACF,CAAA","sourcesContent":["import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass'\nimport { Minipass } from 'minipass'\nimport path from 'node:path'\nimport { list } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport {\n TarOptions,\n TarOptionsFile,\n TarOptionsSync,\n TarOptionsSyncFile,\n} from './options.js'\nimport { Pack, PackSync } from './pack.js'\n\nconst createFileSync = (opt: TarOptionsSyncFile, files: string[]) => {\n const p = new PackSync(opt)\n const stream = new WriteStreamSync(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n addFilesSync(p, files)\n}\n\nconst createFile = (opt: TarOptionsFile, files: string[]) => {\n const p = new Pack(opt)\n const stream = new WriteStream(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n\n const promise = new Promise<void>((res, rej) => {\n stream.on('error', rej)\n stream.on('close', res)\n p.on('error', rej)\n })\n\n addFilesAsync(p, files)\n\n return promise\n}\n\nconst addFilesSync = (p: PackSync, files: string[]) => {\n files.forEach(file => {\n if (file.charAt(0) === '@') {\n list({\n file: path.resolve(p.cwd, file.slice(1)),\n sync: true,\n noResume: true,\n onReadEntry: entry => p.add(entry),\n })\n } else {\n p.add(file)\n }\n })\n p.end()\n}\n\nconst addFilesAsync = async (\n p: Pack,\n files: string[],\n): Promise<void> => {\n for (let i = 0; i < files.length; i++) {\n const file = String(files[i])\n if (file.charAt(0) === '@') {\n await list({\n file: path.resolve(String(p.cwd), file.slice(1)),\n noResume: true,\n onReadEntry: entry => {\n p.add(entry)\n },\n })\n } else {\n p.add(file)\n }\n }\n p.end()\n}\n\nconst createSync = (opt: TarOptionsSync, files: string[]) => {\n const p = new PackSync(opt)\n addFilesSync(p, files)\n return p\n}\n\nconst createAsync = (opt: TarOptions, files: string[]) => {\n const p = new Pack(opt)\n addFilesAsync(p, files)\n return p\n}\n\nexport const create = makeCommand(\n createFileSync,\n createFile,\n createSync,\n createAsync,\n (_opt, files) => {\n if (!files?.length) {\n throw new TypeError('no paths specified to add to archive')\n }\n },\n)\n"]}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/create.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkE;AAElE,0DAA4B;AAC5B,uCAAgC;AAChC,uDAA+C;AAO/C,uCAA0C;AAE1C,MAAM,cAAc,GAAG,CAAC,GAAuB,EAAE,KAAe,EAAE,EAAE;IAClE,MAAM,CAAC,GAAG,IAAI,kBAAQ,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,MAAM,GAAG,IAAI,6BAAe,CAAC,GAAG,CAAC,IAAI,EAAE;QAC3C,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,KAAK;KACxB,CAAC,CAAA;IACF,CAAC,CAAC,IAAI,CAAC,MAAsC,CAAC,CAAA;IAC9C,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,GAAmB,EAAE,KAAe,EAAE,EAAE;IAC1D,MAAM,CAAC,GAAG,IAAI,cAAI,CAAC,GAAG,CAAC,CAAA;IACvB,MAAM,MAAM,GAAG,IAAI,yBAAW,CAAC,GAAG,CAAC,IAAI,EAAE;QACvC,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,K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AM,EAAE,CAAC;QACnB,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CACF,CAAA","sourcesContent":["import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass'\nimport type { Minipass } from 'minipass'\nimport path from 'node:path'\nimport { list } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport type {\n TarOptions,\n TarOptionsFile,\n TarOptionsSync,\n TarOptionsSyncFile,\n} from './options.js'\nimport { Pack, PackSync } from './pack.js'\n\nconst createFileSync = (opt: TarOptionsSyncFile, files: string[]) => {\n const p = new PackSync(opt)\n const stream = new WriteStreamSync(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n addFilesSync(p, files)\n}\n\nconst createFile = (opt: TarOptionsFile, files: string[]) => {\n const p = new Pack(opt)\n const stream = new WriteStream(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n\n const promise = new Promise<void>((res, rej) => {\n stream.on('error', rej)\n stream.on('close', res)\n p.on('error', rej)\n })\n\n addFilesAsync(p, files).catch(er => p.emit('error', er))\n\n return promise\n}\n\nconst addFilesSync = (p: PackSync, files: string[]) => {\n files.forEach(file => {\n if (file.charAt(0) === '@') {\n list({\n file: path.resolve(p.cwd, file.slice(1)),\n sync: true,\n noResume: true,\n onReadEntry: entry => p.add(entry),\n })\n } else {\n p.add(file)\n }\n })\n p.end()\n}\n\nconst addFilesAsync = async (p: Pack, files: string[]): Promise<void> => {\n for (const file of files) {\n if (file.charAt(0) === '@') {\n await list({\n file: path.resolve(String(p.cwd), file.slice(1)),\n noResume: true,\n onReadEntry: entry => {\n p.add(entry)\n },\n })\n } else {\n p.add(file)\n }\n }\n p.end()\n}\n\nconst createSync = (opt: TarOptionsSync, files: string[]) => {\n const p = new PackSync(opt)\n addFilesSync(p, files)\n return p\n}\n\nconst createAsync = (opt: TarOptions, files: string[]) => {\n const p = new Pack(opt)\n addFilesAsync(p, files).catch(er => p.emit('error', er))\n return p\n}\n\nexport const create = makeCommand(\n createFileSync,\n createFile,\n createSync,\n createAsync,\n (_opt, files) => {\n if (!files?.length) {\n throw new TypeError('no paths specified to add to archive')\n }\n },\n)\n"]}
@@ -1,7 +1,7 @@
1
1
  export declare class CwdError extends Error {
2
2
  path: string;
3
3
  code: string;
4
- syscall: 'chdir';
4
+ syscall: "chdir";
5
5
  constructor(path: string, code: string);
6
6
  get name(): string;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cwd-error.d.ts","sourceRoot":"","sources":["../../src/cwd-error.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAU;gBAEd,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMtC,IAAI,IAAI,WAEP;CACF"}
1
+ {"version":3,"file":"cwd-error.d.ts","sourceRoot":"","sources":["../../src/cwd-error.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAG,OAAO,CAAS;gBAEd,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMtC,IAAI,IAAI,WAEP;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"cwd-error.js","sourceRoot":"","sources":["../../src/cwd-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,OAAO,GAAY,OAAO,CAAA;IAE1B,YAAY,IAAY,EAAE,IAAY;QACpC,KAAK,CAAC,GAAG,IAAI,qBAAqB,IAAI,GAAG,CAAC,CAAA;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAdD,4BAcC","sourcesContent":["export class CwdError extends Error {\n path: string\n code: string\n syscall: 'chdir' = 'chdir'\n\n constructor(path: string, code: string) {\n super(`${code}: Cannot cd into '${path}'`)\n this.path = path\n this.code = code\n }\n\n get name() {\n return 'CwdError'\n }\n}\n"]}
1
+ {"version":3,"file":"cwd-error.js","sourceRoot":"","sources":["../../src/cwd-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,OAAO,GAAG,OAAgB,CAAA;IAE1B,YAAY,IAAY,EAAE,IAAY;QACpC,KAAK,CAAC,GAAG,IAAI,qBAAqB,IAAI,GAAG,CAAC,CAAA;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAdD,4BAcC","sourcesContent":["export class CwdError extends Error {\n path: string\n code: string\n syscall = 'chdir' as const\n\n constructor(path: string, code: string) {\n super(`${code}: Cannot cd into '${path}'`)\n this.path = path\n this.code = code\n }\n\n get name() {\n return 'CwdError'\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/extract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,yDAA0C;AAC1C,sDAAwB;AACxB,uCAAuC;AACvC,uDAA+C;AAE/C,2CAAgD;AAEhD,MAAM,eAAe,GAAG,CAAC,GAAuB,EAAE,EAAE;IAClD,MAAM,CAAC,GAAG,IAAI,sBAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IACrB,MAAM,IAA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,MAAM,CAAC,CAAA;gBAC1B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAEY,QAAA,OAAO,GAAG,IAAA,6BAAW,EAChC,eAAe,EACf,WAAW,EACX,GAAG,CAAC,EAAE,CAAC,IAAI,sBAAU,CAAC,GAAG,CAAC,EAC1B,GAAG,CAAC,EAAE,CAAC,IAAI,kBAAM,CAAC,GAAG,CAAC,EACtB,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;IACb,IAAI,KAAK,EAAE,MAAM;QAAE,IAAA,qBAAW,EAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5C,CAAC,CACF,CAAA","sourcesContent":["// tar -x\nimport * as fsm from '@isaacs/fs-minipass'\nimport fs from 'node:fs'\nimport { filesFilter } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport { TarOptionsFile, TarOptionsSyncFile } from './options.js'\nimport { Unpack, UnpackSync } from './unpack.js'\n\nconst extractFileSync = (opt: TarOptionsSyncFile) => {\n const u = new UnpackSync(opt)\n const file = opt.file\n const stat = fs.statSync(file)\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n const stream = new fsm.ReadStreamSync(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.pipe(u)\n}\n\nconst extractFile = (opt: TarOptionsFile, _?: string[]) => {\n const u = new Unpack(opt)\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n\n const file = opt.file\n const p = new Promise<void>((resolve, reject) => {\n u.on('error', reject)\n u.on('close', resolve)\n\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n fs.stat(file, (er, stat) => {\n if (er) {\n reject(er)\n } else {\n const stream = new fsm.ReadStream(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.on('error', reject)\n stream.pipe(u)\n }\n })\n })\n return p\n}\n\nexport const extract = makeCommand<Unpack, UnpackSync>(\n extractFileSync,\n extractFile,\n opt => new UnpackSync(opt),\n opt => new Unpack(opt),\n (opt, files) => {\n if (files?.length) filesFilter(opt, files)\n },\n)\n"]}
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/extract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,yDAA0C;AAC1C,sDAAwB;AACxB,uCAAuC;AACvC,uDAA+C;AAE/C,2CAAgD;AAEhD,MAAM,eAAe,GAAG,CAAC,GAAuB,EAAE,EAAE;IAClD,MAAM,CAAC,GAAG,IAAI,sBAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IACrB,MAAM,IAAI,GAAG,iBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC9B,oDAAoD;IACpD,4DAA4D;IAC5D,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;IACpD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE;QAC1C,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAA;IACF,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,GAAmB,EAAE,CAAY,EAAE,EAAE;IACxD,MAAM,CAAC,GAAG,IAAI,kBAAM,CAAC,GAAG,CAAC,CAAA;IACzB,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;IAEpD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IACrB,MAAM,CAAC,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QACrB,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAEtB,oDAAoD;QACpD,4DAA4D;QAC5D,iBAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;YACzB,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,CAAC,EAAE,CAAC,CAAA;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE;oBACtC,QAAQ,EAAE,QAAQ;oBAClB,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB,CAAC,CAAA;gBACF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;gBAC1B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAEY,QAAA,OAAO,GAAG,IAAA,6BAAW,EAChC,eAAe,EACf,WAAW,EACX,GAAG,CAAC,EAAE,CAAC,IAAI,sBAAU,CAAC,GAAG,CAAC,EAC1B,GAAG,CAAC,EAAE,CAAC,IAAI,kBAAM,CAAC,GAAG,CAAC,EACtB,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;IACb,IAAI,KAAK,EAAE,MAAM;QAAE,IAAA,qBAAW,EAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5C,CAAC,CACF,CAAA","sourcesContent":["// tar -x\nimport * as fsm from '@isaacs/fs-minipass'\nimport fs from 'node:fs'\nimport { filesFilter } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport type { TarOptionsFile, TarOptionsSyncFile } from './options.js'\nimport { Unpack, UnpackSync } from './unpack.js'\n\nconst extractFileSync = (opt: TarOptionsSyncFile) => {\n const u = new UnpackSync(opt)\n const file = opt.file\n const stat = fs.statSync(file)\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n const stream = new fsm.ReadStreamSync(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.pipe(u)\n}\n\nconst extractFile = (opt: TarOptionsFile, _?: string[]) => {\n const u = new Unpack(opt)\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n\n const file = opt.file\n const p = new Promise<void>((resolve, reject) => {\n u.on('error', reject)\n u.on('close', resolve)\n\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n fs.stat(file, (er, stat) => {\n if (er) {\n reject(er)\n } else {\n const stream = new fsm.ReadStream(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.on('error', reject)\n stream.pipe(u)\n }\n })\n })\n return p\n}\n\nexport const extract = makeCommand<Unpack, UnpackSync>(\n extractFileSync,\n extractFile,\n opt => new UnpackSync(opt),\n opt => new Unpack(opt),\n (opt, files) => {\n if (files?.length) filesFilter(opt, files)\n },\n)\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"get-write-flag.d.ts","sourceRoot":"","sources":["../../src/get-write-flag.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,YAAY,2BAGd,MAAM,kBAAwC,CAAA"}
1
+ {"version":3,"file":"get-write-flag.d.ts","sourceRoot":"","sources":["../../src/get-write-flag.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,YAAY,2BAGd,MAAM,kBAAwC,CAAA"}
@@ -15,7 +15,7 @@ const fs_1 = __importDefault(require("fs"));
15
15
  const platform = process.env.__FAKE_PLATFORM__ || process.platform;
16
16
  const isWindows = platform === 'win32';
17
17
  /* c8 ignore start */
18
- const { O_CREAT, O_TRUNC, O_WRONLY } = fs_1.default.constants;
18
+ const { O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY } = fs_1.default.constants;
19
19
  const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) ||
20
20
  fs_1.default.constants.UV_FS_O_FILEMAP ||
21
21
  0;
@@ -23,7 +23,10 @@ const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) ||
23
23
  const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP;
24
24
  const fMapLimit = 512 * 1024;
25
25
  const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
26
- exports.getWriteFlag = !fMapEnabled ?
27
- () => 'w'
28
- : (size) => (size < fMapLimit ? fMapFlag : 'w');
26
+ const noFollowFlag = !isWindows && typeof O_NOFOLLOW === 'number' ?
27
+ O_NOFOLLOW | O_TRUNC | O_CREAT | O_WRONLY
28
+ : null;
29
+ exports.getWriteFlag = noFollowFlag !== null ? () => noFollowFlag
30
+ : !fMapEnabled ? () => 'w'
31
+ : (size) => (size < fMapLimit ? fMapFlag : 'w');
29
32
  //# sourceMappingURL=get-write-flag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-write-flag.js","sourceRoot":"","sources":["../../src/get-write-flag.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,uDAAuD;AACvD,wDAAwD;AACxD,wDAAwD;AACxD,qDAAqD;AACrD,uDAAuD;AACvD,8CAA8C;;;;;;AAE9C,4CAAmB;AAEnB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAA;AAClE,MAAM,SAAS,GAAG,QAAQ,KAAK,OAAO,CAAA;AAEtC,qBAAqB;AACrB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,YAAE,CAAC,SAAS,CAAA;AACnD,MAAM,eAAe,GACnB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC1C,YAAE,CAAC,SAAS,CAAC,eAAe;IAC5B,CAAC,CAAA;AACH,oBAAoB;AAEpB,MAAM,WAAW,GAAG,SAAS,IAAI,CAAC,CAAC,eAAe,CAAA;AAClD,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAA;AAC5B,MAAM,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAClD,QAAA,YAAY,GACvB,CAAC,WAAW,CAAC,CAAC;IACZ,GAAG,EAAE,CAAC,GAAG;IACX,CAAC,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA","sourcesContent":["// Get the appropriate flag to use for creating files\n// We use fmap on Windows platforms for files less than\n// 512kb. This is a fairly low limit, but avoids making\n// things slower in some cases. Since most of what this\n// library is used for is extracting tarballs of many\n// relatively small files in npm packages and the like,\n// it can be a big boost on Windows platforms.\n\nimport fs from 'fs'\n\nconst platform = process.env.__FAKE_PLATFORM__ || process.platform\nconst isWindows = platform === 'win32'\n\n/* c8 ignore start */\nconst { O_CREAT, O_TRUNC, O_WRONLY } = fs.constants\nconst UV_FS_O_FILEMAP =\n Number(process.env.__FAKE_FS_O_FILENAME__) ||\n fs.constants.UV_FS_O_FILEMAP ||\n 0\n/* c8 ignore stop */\n\nconst fMapEnabled = isWindows && !!UV_FS_O_FILEMAP\nconst fMapLimit = 512 * 1024\nconst fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY\nexport const getWriteFlag =\n !fMapEnabled ?\n () => 'w'\n : (size: number) => (size < fMapLimit ? fMapFlag : 'w')\n"]}
1
+ {"version":3,"file":"get-write-flag.js","sourceRoot":"","sources":["../../src/get-write-flag.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,uDAAuD;AACvD,wDAAwD;AACxD,wDAAwD;AACxD,qDAAqD;AACrD,uDAAuD;AACvD,8CAA8C;;;;;;AAE9C,4CAAmB;AAEnB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAA;AAClE,MAAM,SAAS,GAAG,QAAQ,KAAK,OAAO,CAAA;AAEtC,qBAAqB;AACrB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,YAAE,CAAC,SAAS,CAAA;AAC/D,MAAM,eAAe,GACnB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC1C,YAAE,CAAC,SAAS,CAAC,eAAe;IAC5B,CAAC,CAAA;AACH,oBAAoB;AAEpB,MAAM,WAAW,GAAG,SAAS,IAAI,CAAC,CAAC,eAAe,CAAA;AAClD,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAA;AAC5B,MAAM,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAC/D,MAAM,YAAY,GAChB,CAAC,SAAS,IAAI,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC;IAC5C,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ;IAC3C,CAAC,CAAC,IAAI,CAAA;AACK,QAAA,YAAY,GACvB,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY;IAC1C,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG;QAC1B,CAAC,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA","sourcesContent":["// Get the appropriate flag to use for creating files\n// We use fmap on Windows platforms for files less than\n// 512kb. This is a fairly low limit, but avoids making\n// things slower in some cases. Since most of what this\n// library is used for is extracting tarballs of many\n// relatively small files in npm packages and the like,\n// it can be a big boost on Windows platforms.\n\nimport fs from 'fs'\n\nconst platform = process.env.__FAKE_PLATFORM__ || process.platform\nconst isWindows = platform === 'win32'\n\n/* c8 ignore start */\nconst { O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY } = fs.constants\nconst UV_FS_O_FILEMAP =\n Number(process.env.__FAKE_FS_O_FILENAME__) ||\n fs.constants.UV_FS_O_FILEMAP ||\n 0\n/* c8 ignore stop */\n\nconst fMapEnabled = isWindows && !!UV_FS_O_FILEMAP\nconst fMapLimit = 512 * 1024\nconst fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY\nconst noFollowFlag =\n !isWindows && typeof O_NOFOLLOW === 'number' ?\n O_NOFOLLOW | O_TRUNC | O_CREAT | O_WRONLY\n : null\nexport const getWriteFlag =\n noFollowFlag !== null ? () => noFollowFlag\n : !fMapEnabled ? () => 'w'\n : (size: number) => (size < fMapLimit ? fMapFlag : 'w')\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../src/header.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG9D,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,aAAa,GAAG,aAAa,CAAA;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,KAAK,CAAC,EAAE,IA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CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAI;IAClB,MAAM,EAAE,MAAM,CAAI;IAClB,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,KAAK,CAAC,EAAE,IAAI,CAAA;IAEZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;gBAGd,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,EAC1B,GAAG,GAAE,MAAU,EACf,EAAE,CAAC,EAAE,UAAU,EACf,GAAG,CAAC,EAAE,UAAU;IASlB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU;IA+IlE,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU;IAiEpC,IAAI,IAAI,IAAI,aAAa,CAKxB;IAED,IAAI,OAAO,IAAI,aAAa,GAAG,aAAa,CAE3C;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,aAAa,EAS3D;CACF"}
@@ -41,6 +41,7 @@ exports.Header = void 0;
41
41
  const node_path_1 = require("node:path");
42
42
  const large = __importStar(require("./large-numbers.js"));
43
43
  const types = __importStar(require("./types.js"));
44
+ const notNegative = (n) => n === undefined || n < 0 ? undefined : n;
44
45
  class Header {
45
46
  cksumValid = false;
46
47
  needPax = false;
@@ -78,23 +79,44 @@ class Header {
78
79
  if (!buf || !(buf.length >= off + 512)) {
79
80
  throw new Error('need 512 bytes for header');
80
81
  }
81
- this.path = ex?.path ?? decString(buf, off, 100);
82
- this.mode = ex?.mode ?? gex?.mode ?? decNumber(buf, off + 100, 8);
83
- this.uid = ex?.uid ?? gex?.uid ?? decNumber(buf, off + 108, 8);
84
- this.gid = ex?.gid ?? gex?.gid ?? decNumber(buf, off + 116, 8);
85
- this.size = ex?.size ?? gex?.size ?? decNumber(buf, off + 124, 12);
82
+ // Decode the typeflag (independent of any pending PAX/GNU extended header)
83
+ // up front so we can tell whether THIS block is itself an intermediary
84
+ // extension header (PAX `x`/`g`, GNU long-name `L`, GNU long-link `K`).
85
+ // Per POSIX pax, a PAX extended header describes the *next file entry*, not
86
+ // the extension headers that may sit between it and that file. Applying the
87
+ // pending PAX overrides (notably `size`) to an intervening `L`/`K`/`x`/`g`
88
+ // header desynchronizes the stream relative to other tar implementations
89
+ // and enables tar interpretation-conflict / file-smuggling attacks.
90
+ const t = decString(buf, off + 156, 1);
91
+ const isNormalFS = types.normalFsTypes.has(t);
92
+ const exForFields = isNormalFS ? ex : undefined;
93
+ const gexForFields = isNormalFS ? gex : undefined;
94
+ this.path = exForFields?.path ?? decString(buf, off, 100);
95
+ this.mode =
96
+ exForFields?.mode ??
97
+ gexForFields?.mode ??
98
+ decNumber(buf, off + 100, 8);
99
+ this.uid =
100
+ exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8);
101
+ this.gid =
102
+ exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8);
103
+ this.size = notNegative(exForFields?.size ??
104
+ gexForFields?.size ??
105
+ decNumber(buf, off + 124, 12));
86
106
  this.mtime =
87
- ex?.mtime ?? gex?.mtime ?? decDate(buf, off + 136, 12);
107
+ exForFields?.mtime ??
108
+ gexForFields?.mtime ??
109
+ decDate(buf, off + 136, 12);
88
110
  this.cksum = decNumber(buf, off + 148, 12);
89
111
  // if we have extended or global extended headers, apply them now
90
112
  // See https://github.com/npm/node-tar/pull/187
91
- // Apply global before local, so it overrides
92
- if (gex)
93
- this.#slurp(gex, true);
94
- if (ex)
95
- this.#slurp(ex);
113
+ // Apply global before local, so it overrides. Never slurp the pending
114
+ // extended-header fields onto an intermediary extension header.
115
+ if (gexForFields)
116
+ this.#slurp(gexForFields, true);
117
+ if (exForFields)
118
+ this.#slurp(exForFields);
96
119
  // old tar versions marked dirs as a file with a trailing /
97
- const t = decString(buf, off + 156, 1);
98
120
  if (types.isCode(t)) {
99
121
  this.#type = t || '0';
100
122
  }
@@ -110,17 +132,26 @@ class Header {
110
132
  this.size = 0;
111
133
  }
112
134
  this.linkpath = decString(buf, off + 157, 100);
113
- if (buf.subarray(off + 257, off + 265).toString() ===
114
- 'ustar\u000000') {
135
+ if (buf.subarray(off + 257, off + 265).toString() === 'ustar\u000000') {
115
136
  /* c8 ignore start */
116
137
  this.uname =
117
- ex?.uname ?? gex?.uname ?? decString(buf, off + 265, 32);
138
+ exForFields?.uname ??
139
+ gexForFields?.uname ??
140
+ decString(buf, off + 265, 32);
118
141
  this.gname =
119
- ex?.gname ?? gex?.gname ?? decString(buf, off + 297, 32);
142
+ exForFields?.gname ??
143
+ gexForFields?.gname ??
144
+ decString(buf, off + 297, 32);
120
145
  this.devmaj =
121
- ex?.devmaj ?? gex?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0;
146
+ exForFields?.devmaj ??
147
+ gexForFields?.devmaj ??
148
+ decNumber(buf, off + 329, 8) ??
149
+ 0;
122
150
  this.devmin =
123
- ex?.devmin ?? gex?.devmin ?? decNumber(buf, off + 337, 8) ?? 0;
151
+ exForFields?.devmin ??
152
+ gexForFields?.devmin ??
153
+ decNumber(buf, off + 337, 8) ??
154
+ 0;
124
155
  /* c8 ignore stop */
125
156
  if (buf[off + 475] !== 0) {
126
157
  // definitely a prefix, definitely >130 chars.
@@ -133,10 +164,8 @@ class Header {
133
164
  this.path = prefix + '/' + this.path;
134
165
  }
135
166
  /* c8 ignore start */
136
- this.atime =
137
- ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
138
- this.ctime =
139
- ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
167
+ this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
168
+ this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
140
169
  /* c8 ignore stop */
141
170
  }
142
171
  }
@@ -159,6 +188,7 @@ class Header {
159
188
  // null/undefined values are ignored.
160
189
  return !(v === null ||
161
190
  v === undefined ||
191
+ (k === 'size' && Number(v) < 0) ||
162
192
  (k === 'path' && gex) ||
163
193
  (k === 'linkpath' && gex) ||
164
194
  k === 'global');
@@ -180,17 +210,12 @@ class Header {
180
210
  const prefix = split[1];
181
211
  this.needPax = !!split[2];
182
212
  this.needPax = encString(buf, off, 100, path) || this.needPax;
183
- this.needPax =
184
- encNumber(buf, off + 100, 8, this.mode) || this.needPax;
185
- this.needPax =
186
- encNumber(buf, off + 108, 8, this.uid) || this.needPax;
187
- this.needPax =
188
- encNumber(buf, off + 116, 8, this.gid) || this.needPax;
189
- this.needPax =
190
- encNumber(buf, off + 124, 12, this.size) || this.needPax;
191
- this.needPax =
192
- encDate(buf, off + 136, 12, this.mtime) || this.needPax;
193
- buf[off + 156] = this.#type.charCodeAt(0);
213
+ this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax;
214
+ this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax;
215
+ this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax;
216
+ this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax;
217
+ this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax;
218
+ buf[off + 156] = Number(this.#type.codePointAt(0));
194
219
  this.needPax =
195
220
  encString(buf, off + 157, 100, this.linkpath) || this.needPax;
196
221
  buf.write('ustar\u000000', off + 257, 8);
@@ -205,12 +230,10 @@ class Header {
205
230
  this.needPax =
206
231
  encString(buf, off + 345, prefixSize, prefix) || this.needPax;
207
232
  if (buf[off + 475] !== 0) {
208
- this.needPax =
209
- encString(buf, off + 345, 155, prefix) || this.needPax;
233
+ this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax;
210
234
  }
211
235
  else {
212
- this.needPax =
213
- encString(buf, off + 345, 130, prefix) || this.needPax;
236
+ this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax;
214
237
  this.needPax =
215
238
  encDate(buf, off + 476, 12, this.atime) || this.needPax;
216
239
  this.needPax =