@openclaw/fs-safe 0.14.0 → 0.16.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.
Files changed (370) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +38 -10
  3. package/dist/advanced.d.ts +2 -1
  4. package/dist/advanced.d.ts.map +1 -1
  5. package/dist/advanced.js +2 -1
  6. package/dist/archive-kind.d.ts +0 -1
  7. package/dist/archive-kind.d.ts.map +1 -1
  8. package/dist/archive-kind.js +5 -17
  9. package/dist/archive-merge.d.ts.map +1 -1
  10. package/dist/archive-merge.js +113 -46
  11. package/dist/archive-parser.wasm +0 -0
  12. package/dist/archive-read.d.ts.map +1 -1
  13. package/dist/archive-read.js +10 -11
  14. package/dist/archive-tar-stream.d.ts +3 -0
  15. package/dist/archive-tar-stream.d.ts.map +1 -1
  16. package/dist/archive-tar-stream.js +56 -37
  17. package/dist/archive-tar-wasm.d.ts +16 -4
  18. package/dist/archive-tar-wasm.d.ts.map +1 -1
  19. package/dist/archive-tar-wasm.js +134 -34
  20. package/dist/archive-zip-directory.d.ts +4 -0
  21. package/dist/archive-zip-directory.d.ts.map +1 -1
  22. package/dist/archive-zip-directory.js +2 -0
  23. package/dist/archive-zip-entry.d.ts +6 -2
  24. package/dist/archive-zip-entry.d.ts.map +1 -1
  25. package/dist/archive-zip-entry.js +23 -8
  26. package/dist/archive-zip-integrity.d.ts.map +1 -1
  27. package/dist/archive-zip-integrity.js +3 -4
  28. package/dist/archive-zip-loader.d.ts.map +1 -1
  29. package/dist/archive-zip-loader.js +107 -31
  30. package/dist/archive-zip-names.d.ts +1 -0
  31. package/dist/archive-zip-names.d.ts.map +1 -1
  32. package/dist/archive-zip-names.js +6 -0
  33. package/dist/archive.d.ts.map +1 -1
  34. package/dist/archive.js +11 -11
  35. package/dist/bounded-read-stream.d.ts +0 -1
  36. package/dist/bounded-read-stream.d.ts.map +1 -1
  37. package/dist/bounded-read-stream.js +0 -6
  38. package/dist/clone-metadata.d.ts +1 -0
  39. package/dist/clone-metadata.d.ts.map +1 -1
  40. package/dist/clone-metadata.js +6 -2
  41. package/dist/copy-publication.d.ts +6 -0
  42. package/dist/copy-publication.d.ts.map +1 -1
  43. package/dist/copy-publication.js +3 -0
  44. package/dist/copy-tree-portable.d.ts.map +1 -1
  45. package/dist/copy-tree-portable.js +44 -24
  46. package/dist/copy.d.ts.map +1 -1
  47. package/dist/copy.js +29 -11
  48. package/dist/create-directory.d.ts +20 -0
  49. package/dist/create-directory.d.ts.map +1 -0
  50. package/dist/create-directory.js +130 -0
  51. package/dist/create-file-async.d.ts +7 -0
  52. package/dist/create-file-async.d.ts.map +1 -0
  53. package/dist/create-file-async.js +121 -0
  54. package/dist/create-file.d.ts +8 -0
  55. package/dist/create-file.d.ts.map +1 -0
  56. package/dist/create-file.js +190 -0
  57. package/dist/create-owned-file.d.ts +8 -0
  58. package/dist/create-owned-file.d.ts.map +1 -0
  59. package/dist/create-owned-file.js +16 -0
  60. package/dist/create.d.ts +4 -0
  61. package/dist/create.d.ts.map +1 -0
  62. package/dist/create.js +2 -0
  63. package/dist/creation-darwin.d.ts +7 -0
  64. package/dist/creation-darwin.d.ts.map +1 -0
  65. package/dist/creation-darwin.js +79 -0
  66. package/dist/creation-file-state.d.ts +19 -0
  67. package/dist/creation-file-state.d.ts.map +1 -0
  68. package/dist/creation-file-state.js +118 -0
  69. package/dist/creation-path.d.ts +21 -0
  70. package/dist/creation-path.d.ts.map +1 -0
  71. package/dist/creation-path.js +71 -0
  72. package/dist/creation-permissions.d.ts +19 -0
  73. package/dist/creation-permissions.d.ts.map +1 -0
  74. package/dist/creation-permissions.js +125 -0
  75. package/dist/directory-durability.d.ts +1 -1
  76. package/dist/directory-durability.d.ts.map +1 -1
  77. package/dist/directory-durability.js +22 -80
  78. package/dist/directory-guard.d.ts +3 -0
  79. package/dist/directory-guard.d.ts.map +1 -1
  80. package/dist/directory-mode-node.d.ts +2 -0
  81. package/dist/directory-mode-node.d.ts.map +1 -1
  82. package/dist/directory-mode-node.js +8 -0
  83. package/dist/directory-mode-owner.js +5 -5
  84. package/dist/directory-receipt.d.ts +24 -0
  85. package/dist/directory-receipt.d.ts.map +1 -0
  86. package/dist/directory-receipt.js +127 -0
  87. package/dist/file-cleanup.d.ts +19 -0
  88. package/dist/file-cleanup.d.ts.map +1 -0
  89. package/dist/file-cleanup.js +78 -0
  90. package/dist/file-handle-transfer.d.ts +2 -0
  91. package/dist/file-handle-transfer.d.ts.map +1 -1
  92. package/dist/file-handle-transfer.js +57 -2
  93. package/dist/file-identity.d.ts.map +1 -1
  94. package/dist/file-identity.js +18 -4
  95. package/dist/file-lock-sync-admission.d.ts +19 -0
  96. package/dist/file-lock-sync-admission.d.ts.map +1 -0
  97. package/dist/file-lock-sync-admission.js +93 -0
  98. package/dist/file-lock-sync-root-acquire.d.ts +4 -0
  99. package/dist/file-lock-sync-root-acquire.d.ts.map +1 -0
  100. package/dist/file-lock-sync-root-acquire.js +370 -0
  101. package/dist/file-lock-sync-root-arbitration.d.ts +18 -0
  102. package/dist/file-lock-sync-root-arbitration.d.ts.map +1 -0
  103. package/dist/file-lock-sync-root-arbitration.js +66 -0
  104. package/dist/file-lock-sync-root-held.d.ts +34 -0
  105. package/dist/file-lock-sync-root-held.d.ts.map +1 -0
  106. package/dist/file-lock-sync-root-held.js +393 -0
  107. package/dist/file-lock-sync-root-io.d.ts +44 -0
  108. package/dist/file-lock-sync-root-io.d.ts.map +1 -0
  109. package/dist/file-lock-sync-root-io.js +209 -0
  110. package/dist/file-lock-sync-root-mutation.d.ts +17 -0
  111. package/dist/file-lock-sync-root-mutation.d.ts.map +1 -0
  112. package/dist/file-lock-sync-root-mutation.js +277 -0
  113. package/dist/file-lock-sync-root-options.d.ts +20 -0
  114. package/dist/file-lock-sync-root-options.d.ts.map +1 -0
  115. package/dist/file-lock-sync-root-options.js +58 -0
  116. package/dist/file-lock-sync-root-registration.d.ts +2 -0
  117. package/dist/file-lock-sync-root-registration.d.ts.map +1 -0
  118. package/dist/file-lock-sync-root-registration.js +90 -0
  119. package/dist/file-lock-sync-root.d.ts +36 -0
  120. package/dist/file-lock-sync-root.d.ts.map +1 -0
  121. package/dist/file-lock-sync-root.js +361 -0
  122. package/dist/file-lock-sync-stale-admission.d.ts +24 -0
  123. package/dist/file-lock-sync-stale-admission.d.ts.map +1 -0
  124. package/dist/file-lock-sync-stale-admission.js +205 -0
  125. package/dist/file-lock-sync.d.ts.map +1 -1
  126. package/dist/file-lock-sync.js +245 -205
  127. package/dist/file-observation.d.ts +1 -1
  128. package/dist/file-observation.d.ts.map +1 -1
  129. package/dist/file-store-boundary.d.ts +2 -6
  130. package/dist/file-store-boundary.d.ts.map +1 -1
  131. package/dist/file-store-boundary.js +3 -9
  132. package/dist/file-store-prune.d.ts.map +1 -1
  133. package/dist/file-store-prune.js +5 -1
  134. package/dist/file-store-sync-write.d.ts.map +1 -1
  135. package/dist/file-store-sync-write.js +5 -8
  136. package/dist/file-store.d.ts.map +1 -1
  137. package/dist/file-store.js +47 -12
  138. package/dist/guarded-mkdir.d.ts +1 -0
  139. package/dist/guarded-mkdir.d.ts.map +1 -1
  140. package/dist/guarded-mkdir.js +36 -7
  141. package/dist/json-document-store.d.ts.map +1 -1
  142. package/dist/json-document-store.js +22 -15
  143. package/dist/json-durable-queue-ownership.d.ts +0 -1
  144. package/dist/json-durable-queue-ownership.d.ts.map +1 -1
  145. package/dist/json-durable-queue-ownership.js +0 -6
  146. package/dist/move-path.js +1 -1
  147. package/dist/native-binding.d.ts +13 -1
  148. package/dist/native-binding.d.ts.map +1 -1
  149. package/dist/native-fallback-warning.d.ts +4 -0
  150. package/dist/native-fallback-warning.d.ts.map +1 -0
  151. package/dist/native-fallback-warning.js +11 -0
  152. package/dist/native-operations.d.ts +0 -2
  153. package/dist/native-operations.d.ts.map +1 -1
  154. package/dist/native-operations.js +0 -24
  155. package/dist/native-parent-admission.d.ts +5 -2
  156. package/dist/native-parent-admission.d.ts.map +1 -1
  157. package/dist/native-parent-admission.js +27 -7
  158. package/dist/native-pinned-write-windows.d.ts +1 -1
  159. package/dist/native-pinned-write-windows.d.ts.map +1 -1
  160. package/dist/native-pinned-write-windows.js +174 -29
  161. package/dist/native-pinned-write.d.ts.map +1 -1
  162. package/dist/native-pinned-write.js +26 -14
  163. package/dist/native-policy-parent-windows.d.ts +14 -0
  164. package/dist/native-policy-parent-windows.d.ts.map +1 -0
  165. package/dist/native-policy-parent-windows.js +209 -0
  166. package/dist/native-rename-outcome.d.ts +4 -0
  167. package/dist/native-rename-outcome.d.ts.map +1 -0
  168. package/dist/native-rename-outcome.js +8 -0
  169. package/dist/native-staged-file.d.ts +3 -2
  170. package/dist/native-staged-file.d.ts.map +1 -1
  171. package/dist/native-staged-file.js +121 -72
  172. package/dist/output.d.ts.map +1 -1
  173. package/dist/output.js +12 -8
  174. package/dist/owner-dacl.d.ts.map +1 -1
  175. package/dist/owner-dacl.js +10 -4
  176. package/dist/path-prefix.d.ts.map +1 -1
  177. package/dist/path-prefix.js +30 -8
  178. package/dist/path-suffix-aliases.d.ts +2 -0
  179. package/dist/path-suffix-aliases.d.ts.map +1 -1
  180. package/dist/path-suffix-aliases.js +25 -17
  181. package/dist/permission-exec.d.ts +2 -0
  182. package/dist/permission-exec.d.ts.map +1 -1
  183. package/dist/permission-exec.js +150 -21
  184. package/dist/permissions-windows.js +1 -1
  185. package/dist/pinned-mutation-admission.d.ts.map +1 -1
  186. package/dist/pinned-mutation-admission.js +10 -5
  187. package/dist/pinned-mutation-observation.d.ts +0 -1
  188. package/dist/pinned-mutation-observation.d.ts.map +1 -1
  189. package/dist/pinned-mutation-observation.js +0 -19
  190. package/dist/pinned-mutation-shared-route.d.ts +1 -0
  191. package/dist/pinned-mutation-shared-route.d.ts.map +1 -1
  192. package/dist/pinned-mutation-shared-route.js +1 -1
  193. package/dist/pinned-write-input.d.ts +4 -0
  194. package/dist/pinned-write-input.d.ts.map +1 -0
  195. package/dist/pinned-write-input.js +25 -0
  196. package/dist/pinned-write-mode.d.ts +5 -0
  197. package/dist/pinned-write-mode.d.ts.map +1 -0
  198. package/dist/pinned-write-mode.js +24 -0
  199. package/dist/pinned-write-staged.d.ts +6 -0
  200. package/dist/pinned-write-staged.d.ts.map +1 -0
  201. package/dist/pinned-write-staged.js +187 -0
  202. package/dist/pinned-write-types.d.ts +5 -0
  203. package/dist/pinned-write-types.d.ts.map +1 -1
  204. package/dist/pinned-write.d.ts.map +1 -1
  205. package/dist/pinned-write.js +35 -145
  206. package/dist/private-directory.d.ts.map +1 -1
  207. package/dist/private-directory.js +18 -4
  208. package/dist/private-producer-handoff-sync.d.ts +14 -0
  209. package/dist/private-producer-handoff-sync.d.ts.map +1 -0
  210. package/dist/private-producer-handoff-sync.js +114 -0
  211. package/dist/private-producer-handoff.d.ts +22 -4
  212. package/dist/private-producer-handoff.d.ts.map +1 -1
  213. package/dist/private-producer-handoff.js +140 -77
  214. package/dist/private-temp-workspace.d.ts.map +1 -1
  215. package/dist/private-temp-workspace.js +75 -121
  216. package/dist/publish-copy-stage.d.ts +2 -1
  217. package/dist/publish-copy-stage.d.ts.map +1 -1
  218. package/dist/publish-copy-stage.js +16 -7
  219. package/dist/publish-file.d.ts.map +1 -1
  220. package/dist/publish-file.js +2 -2
  221. package/dist/regular-file.d.ts.map +1 -1
  222. package/dist/regular-file.js +1 -15
  223. package/dist/replace-directory.d.ts.map +1 -1
  224. package/dist/replace-directory.js +256 -18
  225. package/dist/replace-file-copy-fallback.d.ts.map +1 -1
  226. package/dist/replace-file-copy-fallback.js +62 -70
  227. package/dist/replace-file-copy-source.d.ts.map +1 -1
  228. package/dist/replace-file-copy-source.js +10 -12
  229. package/dist/replace-file-temp-owner.d.ts +5 -9
  230. package/dist/replace-file-temp-owner.d.ts.map +1 -1
  231. package/dist/replace-file-temp-owner.js +56 -72
  232. package/dist/replace-file.js +6 -6
  233. package/dist/retained-directory-replacement.d.ts +26 -0
  234. package/dist/retained-directory-replacement.d.ts.map +1 -0
  235. package/dist/retained-directory-replacement.js +193 -0
  236. package/dist/root-boundary.d.ts +1 -0
  237. package/dist/root-boundary.d.ts.map +1 -1
  238. package/dist/root-boundary.js +4 -0
  239. package/dist/root-context.d.ts +0 -8
  240. package/dist/root-context.d.ts.map +1 -1
  241. package/dist/root-context.js +0 -3
  242. package/dist/root-create-input.d.ts +8 -1
  243. package/dist/root-create-input.d.ts.map +1 -1
  244. package/dist/root-create-input.js +17 -4
  245. package/dist/root-directory-creation.d.ts +3 -3
  246. package/dist/root-directory-creation.d.ts.map +1 -1
  247. package/dist/root-directory-creation.js +15 -3
  248. package/dist/root-directory-list.d.ts +1 -0
  249. package/dist/root-directory-list.d.ts.map +1 -1
  250. package/dist/root-directory-list.js +1 -0
  251. package/dist/root-impl.d.ts.map +1 -1
  252. package/dist/root-impl.js +46 -17
  253. package/dist/root-move-noreplace.d.ts.map +1 -1
  254. package/dist/root-move-noreplace.js +24 -15
  255. package/dist/root-options.d.ts +12 -4
  256. package/dist/root-options.d.ts.map +1 -1
  257. package/dist/root-path-errors.d.ts +1 -0
  258. package/dist/root-path-errors.d.ts.map +1 -1
  259. package/dist/root-path-errors.js +11 -2
  260. package/dist/root-path-existing.d.ts.map +1 -1
  261. package/dist/root-path-existing.js +11 -35
  262. package/dist/root-path-stat.d.ts.map +1 -1
  263. package/dist/root-path-stat.js +59 -7
  264. package/dist/root-path.js +1 -13
  265. package/dist/root-remove.d.ts +1 -0
  266. package/dist/root-remove.d.ts.map +1 -1
  267. package/dist/root-remove.js +4 -0
  268. package/dist/root-walk.d.ts +1 -1
  269. package/dist/root-walk.d.ts.map +1 -1
  270. package/dist/root-walk.js +17 -2
  271. package/dist/root-write-admission.d.ts +0 -2
  272. package/dist/root-write-admission.d.ts.map +1 -1
  273. package/dist/root-write-admission.js +1 -15
  274. package/dist/root-write-complete-parent.d.ts.map +1 -1
  275. package/dist/root-write-complete-parent.js +7 -23
  276. package/dist/root-write-publication.js +1 -1
  277. package/dist/root-write-verification.d.ts.map +1 -1
  278. package/dist/root-write-verification.js +29 -42
  279. package/dist/secret-file.d.ts.map +1 -1
  280. package/dist/secret-file.js +3 -24
  281. package/dist/secret-read-async.d.ts.map +1 -1
  282. package/dist/secret-read-async.js +3 -24
  283. package/dist/secret-read-policy.d.ts +6 -2
  284. package/dist/secret-read-policy.d.ts.map +1 -1
  285. package/dist/secret-read-policy.js +26 -2
  286. package/dist/secure-file-windows.d.ts +6 -0
  287. package/dist/secure-file-windows.d.ts.map +1 -1
  288. package/dist/secure-file-windows.js +34 -117
  289. package/dist/secure-file.js +2 -2
  290. package/dist/sibling-temp.d.ts.map +1 -1
  291. package/dist/sibling-temp.js +23 -12
  292. package/dist/sidecar-lock-acquire.d.ts +2 -28
  293. package/dist/sidecar-lock-acquire.d.ts.map +1 -1
  294. package/dist/sidecar-lock-acquire.js +288 -199
  295. package/dist/sidecar-lock-admission-context.d.ts +19 -0
  296. package/dist/sidecar-lock-admission-context.d.ts.map +1 -0
  297. package/dist/sidecar-lock-admission-context.js +60 -0
  298. package/dist/sidecar-lock-admission-parser.d.ts +43 -0
  299. package/dist/sidecar-lock-admission-parser.d.ts.map +1 -0
  300. package/dist/sidecar-lock-admission-parser.js +113 -0
  301. package/dist/sidecar-lock-admission.d.ts +35 -0
  302. package/dist/sidecar-lock-admission.d.ts.map +1 -0
  303. package/dist/sidecar-lock-admission.js +7 -0
  304. package/dist/sidecar-lock-reclaim.d.ts +9 -4
  305. package/dist/sidecar-lock-reclaim.d.ts.map +1 -1
  306. package/dist/sidecar-lock-reclaim.js +80 -25
  307. package/dist/sidecar-lock-root.d.ts.map +1 -1
  308. package/dist/sidecar-lock-root.js +2 -1
  309. package/dist/sidecar-lock-stale-admission.d.ts +39 -0
  310. package/dist/sidecar-lock-stale-admission.d.ts.map +1 -0
  311. package/dist/sidecar-lock-stale-admission.js +232 -0
  312. package/dist/sidecar-lock-target.d.ts +8 -0
  313. package/dist/sidecar-lock-target.d.ts.map +1 -0
  314. package/dist/sidecar-lock-target.js +55 -0
  315. package/dist/sidecar-lock.d.ts.map +1 -1
  316. package/dist/sidecar-lock.js +100 -16
  317. package/dist/staged-directory.d.ts.map +1 -1
  318. package/dist/staged-directory.js +6 -6
  319. package/dist/staged-file-settlement.d.ts +17 -0
  320. package/dist/staged-file-settlement.d.ts.map +1 -0
  321. package/dist/staged-file-settlement.js +57 -0
  322. package/dist/temp-workspace-descriptor.d.ts.map +1 -1
  323. package/dist/temp-workspace-descriptor.js +9 -27
  324. package/dist/temp-workspace-owner.d.ts.map +1 -1
  325. package/dist/temp-workspace-owner.js +8 -8
  326. package/dist/walk.d.ts +5 -1
  327. package/dist/walk.d.ts.map +1 -1
  328. package/dist/walk.js +19 -6
  329. package/dist/windows-owner.d.ts.map +1 -1
  330. package/dist/windows-owner.js +4 -3
  331. package/dist/windows-security-bridge.cs +336 -0
  332. package/dist/windows-security-bridge.ps1 +15 -0
  333. package/dist/windows-security-command.d.ts +26 -0
  334. package/dist/windows-security-command.d.ts.map +1 -0
  335. package/dist/windows-security-command.js +363 -0
  336. package/dist/windows-security-facts.d.ts +6 -0
  337. package/dist/windows-security-facts.d.ts.map +1 -0
  338. package/dist/windows-security-facts.js +108 -0
  339. package/docs/advanced.md +4 -2
  340. package/docs/archive.md +97 -46
  341. package/docs/atomic.md +85 -8
  342. package/docs/config.md +6 -2
  343. package/docs/contributing.md +44 -4
  344. package/docs/copy.md +37 -0
  345. package/docs/creation.md +128 -0
  346. package/docs/durability.md +24 -0
  347. package/docs/file-store.md +19 -0
  348. package/docs/install.md +31 -7
  349. package/docs/json-store.md +5 -0
  350. package/docs/migrating-to-0.5.md +15 -6
  351. package/docs/migrating-to-0.6.md +9 -4
  352. package/docs/native-helper.md +32 -12
  353. package/docs/native.md +38 -7
  354. package/docs/output.md +6 -0
  355. package/docs/path-prefix.md +10 -0
  356. package/docs/path-suffix-aliases.md +51 -6
  357. package/docs/permissions.md +50 -14
  358. package/docs/public-api.md +3 -2
  359. package/docs/root.md +56 -3
  360. package/docs/secret-file.md +11 -2
  361. package/docs/secure-file.md +9 -4
  362. package/docs/sidecar-lock.md +114 -8
  363. package/docs/staged-file.md +12 -3
  364. package/docs/temp.md +20 -3
  365. package/docs/walk.md +67 -1
  366. package/docs/writing.md +76 -6
  367. package/package.json +19 -16
  368. package/dist/darwin-acl.d.ts +0 -4
  369. package/dist/darwin-acl.d.ts.map +0 -1
  370. package/dist/darwin-acl.js +0 -24
@@ -1,6 +1,9 @@
1
1
  import { normalizeMaxBytes } from "./byte-budget.js";
2
2
  import { resolveHomeRelativePath } from "./home-dir.js";
3
+ import fs, {} from "node:fs";
4
+ import { assertNoUnsafeDeviceReadPath } from "./device-path.js";
3
5
  import { FsSafeError } from "./errors.js";
6
+ import { inspectFileIdentitySync } from "./strict-file-identity.js";
4
7
  import { assertNoWindowsPathAlias } from "./windows-path-alias.js";
5
8
  export const DEFAULT_SECRET_FILE_MAX_BYTES = 16 * 1024;
6
9
  export function secretPathErrorCode(error) {
@@ -29,7 +32,7 @@ export function trimSecretFileContent(raw, label, resolvedPath) {
29
32
  }
30
33
  return secret;
31
34
  }
32
- export function resolveSecretReadPolicy(filePath, label, options) {
35
+ export function prepareSecretRead(filePath, label, options) {
33
36
  const trimmedPath = filePath.trim();
34
37
  assertNoWindowsPathAlias(trimmedPath, "filesystem", `${label} file path uses a Windows filesystem namespace alias`);
35
38
  const resolvedPath = resolveHomeRelativePath(trimmedPath);
@@ -40,5 +43,26 @@ export function resolveSecretReadPolicy(filePath, label, options) {
40
43
  const maxBytes = normalizeMaxBytes(options.maxBytes, {
41
44
  defaultValue: DEFAULT_SECRET_FILE_MAX_BYTES,
42
45
  });
43
- return { resolvedPath, maxBytes };
46
+ let rejectSymlink;
47
+ let previewStat;
48
+ try {
49
+ assertNoUnsafeDeviceReadPath(resolvedPath);
50
+ rejectSymlink = Boolean(options.rejectSymlink);
51
+ previewStat = inspectFileIdentitySync(() => inspectInput(`${label} file at ${resolvedPath} must not be a symlink.`));
52
+ }
53
+ catch (error) {
54
+ throw secretReadError(error instanceof FsSafeError ? error.code : secretPathErrorCode(error), "inspect", label, resolvedPath, error);
55
+ }
56
+ function inspectInput(symlinkMessage) {
57
+ const stat = rejectSymlink
58
+ ? fs.lstatSync(resolvedPath, { bigint: true })
59
+ : fs.statSync(resolvedPath, { bigint: true });
60
+ if (rejectSymlink && stat.isSymbolicLink()) {
61
+ throw new FsSafeError("symlink", symlinkMessage);
62
+ }
63
+ return stat;
64
+ }
65
+ const rejectHardlinks = options.rejectHardlinks !== false;
66
+ assertSecretFilePreview(previewStat, label, resolvedPath, maxBytes, rejectHardlinks);
67
+ return { resolvedPath, maxBytes, rejectSymlink, rejectHardlinks, previewStat, inspectInput };
44
68
  }
@@ -6,5 +6,11 @@ export declare function inspectSecureWindowsDescriptor(params: {
6
6
  identity: ExactIdentity;
7
7
  stat: Stats;
8
8
  }): PermissionCheck;
9
+ /** Both mechanisms inspect the same borrowed handle; the caller owns its lifetime. */
10
+ export declare function inspectSecureWindowsFile(params: {
11
+ fd: number;
12
+ identity: ExactIdentity;
13
+ stat: Stats;
14
+ }): Promise<PermissionCheck>;
9
15
  export {};
10
16
  //# sourceMappingURL=secure-file-windows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secure-file-windows.d.ts","sourceRoot":"","sources":["../src/secure-file-windows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AASlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA4BxD,KAAK,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC;AAuHtD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,KAAK,CAAC;CACb,GAAG,eAAe,CA0ClB"}
1
+ {"version":3,"file":"secure-file-windows.d.ts","sourceRoot":"","sources":["../src/secure-file-windows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAOlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOxD,KAAK,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC;AA0BtD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,KAAK,CAAC;CACb,GAAG,eAAe,CAkBlB;AAgCD,sFAAsF;AACtF,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,KAAK,CAAC;CACb,GAAG,OAAO,CAAC,eAAe,CAAC,CAiB3B"}
@@ -1,30 +1,12 @@
1
1
  import { FsSafeError } from "./errors.js";
2
2
  import { recordFileObservationFailure } from "./file-observation.js";
3
3
  import { getNativeBinding } from "./native.js";
4
+ import { getFsSafeNativeConfig } from "./native-config.js";
5
+ import { warnNativeFallback } from "./native-fallback-warning.js";
6
+ import { inspectWindowsDescriptorCommand } from "./windows-security-command.js";
7
+ import { validateSecureWindowsSecurityFacts } from "./windows-security-facts.js";
4
8
  const IDENTITY_RE = /^([0-9a-f]{8}):([0-9a-f]{16})$/;
5
- const SID_RE = /^s-\d+-\d+(?:-\d+)+$/;
6
- const OWNER_CLASSES = new Set(["current-user", "system", "administrators", "foreign"]);
7
9
  const TRUSTED_OWNER_CLASSES = new Set(["current-user", "system", "administrators"]);
8
- const SYSTEM_SID = "s-1-5-18";
9
- const ADMINISTRATORS_SID = "s-1-5-32-544";
10
- const WORLD_SIDS = new Set([
11
- "s-1-1-0", "s-1-5-11", "s-1-5-32-545", "s-1-5-7",
12
- "s-1-5-32-546", "s-1-5-4", "s-1-5-2",
13
- ]);
14
- const GENERIC_READ = 0x8000_0000;
15
- const GENERIC_WRITE = 0x4000_0000;
16
- const GENERIC_ALL = 0x1000_0000;
17
- const DELETE_ACCESS = 0x0001_0000;
18
- const WRITE_DAC = 0x0004_0000;
19
- const WRITE_OWNER = 0x0008_0000;
20
- const FILE_READ_DATA = 0x0000_0001;
21
- const FILE_WRITE_DATA = 0x0000_0002;
22
- const FILE_APPEND_DATA = 0x0000_0004;
23
- const FILE_READ_EA = 0x0000_0008;
24
- const FILE_WRITE_EA = 0x0000_0010;
25
- const FILE_DELETE_CHILD = 0x0000_0040;
26
- const FILE_READ_ATTRIBUTES = 0x0000_0080;
27
- const FILE_WRITE_ATTRIBUTES = 0x0000_0100;
28
10
  function permissionUnverified(message, cause) {
29
11
  throw new FsSafeError("permission-unverified", message, cause === undefined ? {} : { cause });
30
12
  }
@@ -36,9 +18,6 @@ function identityMismatch() {
36
18
  function isRecord(value) {
37
19
  return typeof value === "object" && value !== null;
38
20
  }
39
- function isUint32(value) {
40
- return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 0xffff_ffff;
41
- }
42
21
  function parseIdentity(value) {
43
22
  if (typeof value !== "string")
44
23
  identityMismatch();
@@ -50,95 +29,6 @@ function parseIdentity(value) {
50
29
  ino: BigInt(`0x${match[2]}`),
51
30
  };
52
31
  }
53
- function validateFlags(value) {
54
- if (!isRecord(value))
55
- return false;
56
- const raw = value.raw;
57
- if (!isUint32(raw) || (raw & ~0xdf) !== 0)
58
- return false;
59
- const fields = [
60
- ["objectInherit", 0x01], ["containerInherit", 0x02],
61
- ["noPropagateInherit", 0x04], ["inheritOnly", 0x08], ["inherited", 0x10],
62
- ["successfulAccess", 0x40], ["failedAccess", 0x80],
63
- ];
64
- return fields.every(([field, bit]) => typeof value[field] === "boolean" && value[field] === ((raw & bit) !== 0));
65
- }
66
- function validateAce(value) {
67
- return isRecord(value) && typeof value.sid === "string" && SID_RE.test(value.sid) &&
68
- isUint32(value.mask) && (value.aceType === "allow" || value.aceType === "deny") &&
69
- validateFlags(value.flags);
70
- }
71
- function canRead(mask) {
72
- return (mask & (GENERIC_ALL | GENERIC_READ | FILE_READ_DATA | FILE_READ_EA |
73
- FILE_READ_ATTRIBUTES)) !== 0;
74
- }
75
- function canWrite(mask) {
76
- return (mask & (GENERIC_ALL | GENERIC_WRITE | FILE_WRITE_DATA | FILE_APPEND_DATA |
77
- FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES | FILE_DELETE_CHILD | DELETE_ACCESS |
78
- WRITE_DAC | WRITE_OWNER)) !== 0;
79
- }
80
- function expectedOwnerClass(facts) {
81
- if (facts.ownerSid === facts.currentUserSid)
82
- return "current-user";
83
- if (facts.ownerSid === SYSTEM_SID)
84
- return "system";
85
- if (facts.ownerSid === ADMINISTRATORS_SID)
86
- return "administrators";
87
- return "foreign";
88
- }
89
- function validateSecurity(value) {
90
- if (!isRecord(value))
91
- permissionUnverified("Windows descriptor ACL facts were malformed");
92
- const facts = value;
93
- const booleans = [
94
- "worldWritable", "groupWritable", "worldReadable", "groupReadable",
95
- "fallbackRequired", "daclPresent", "isLocal", "aceListComplete",
96
- ];
97
- if (!booleans.every((field) => typeof facts[field] === "boolean") ||
98
- typeof facts.ownerSid !== "string" || !SID_RE.test(facts.ownerSid) ||
99
- typeof facts.currentUserSid !== "string" || !SID_RE.test(facts.currentUserSid) ||
100
- typeof facts.ownerClass !== "string" || !OWNER_CLASSES.has(facts.ownerClass) ||
101
- !Array.isArray(facts.unsupportedAceTypes) ||
102
- !facts.unsupportedAceTypes.every(isUint32) ||
103
- !Array.isArray(facts.aces) || !facts.aces.every(validateAce)) {
104
- permissionUnverified("Windows descriptor ACL facts were malformed");
105
- }
106
- if (facts.ownerClass !== expectedOwnerClass(facts)) {
107
- permissionUnverified("Windows descriptor owner facts were inconsistent");
108
- }
109
- if (facts.fallbackRequired || !facts.isLocal || !facts.aceListComplete ||
110
- facts.unsupportedAceTypes.length !== 0) {
111
- permissionUnverified("Windows descriptor ACL facts were incomplete or unsupported");
112
- }
113
- if (!facts.daclPresent && facts.aces.length !== 0) {
114
- permissionUnverified("Windows descriptor DACL facts were inconsistent");
115
- }
116
- return facts;
117
- }
118
- function validatePermissionSummary(facts) {
119
- let worldReadable = !facts.daclPresent;
120
- let worldWritable = !facts.daclPresent;
121
- let groupReadable = false;
122
- let groupWritable = false;
123
- const trustedSids = new Set([facts.currentUserSid, SYSTEM_SID, ADMINISTRATORS_SID]);
124
- for (const ace of facts.aces) {
125
- if (ace.aceType !== "allow" || ace.flags.inheritOnly || trustedSids.has(ace.sid))
126
- continue;
127
- const world = WORLD_SIDS.has(ace.sid);
128
- if (world) {
129
- worldReadable ||= canRead(ace.mask);
130
- worldWritable ||= canWrite(ace.mask);
131
- }
132
- else {
133
- groupReadable ||= canRead(ace.mask);
134
- groupWritable ||= canWrite(ace.mask);
135
- }
136
- }
137
- if (facts.worldReadable !== worldReadable || facts.worldWritable !== worldWritable ||
138
- facts.groupReadable !== groupReadable || facts.groupWritable !== groupWritable) {
139
- permissionUnverified("Windows descriptor ACL summary was inconsistent");
140
- }
141
- }
142
32
  export function inspectSecureWindowsDescriptor(params) {
143
33
  let native;
144
34
  try {
@@ -158,14 +48,16 @@ export function inspectSecureWindowsDescriptor(params) {
158
48
  catch (cause) {
159
49
  permissionUnverified("Windows descriptor ACL verification failed", cause);
160
50
  }
51
+ return inspectDescriptorResult(params, result, "native");
52
+ }
53
+ function inspectDescriptorResult(params, result, mechanism) {
161
54
  if (!isRecord(result))
162
55
  permissionUnverified("Windows descriptor ACL facts were malformed");
163
56
  const observed = parseIdentity(result.identity);
164
57
  if (observed.dev !== params.identity.dev || observed.ino !== params.identity.ino) {
165
58
  identityMismatch();
166
59
  }
167
- const facts = validateSecurity(result.security);
168
- validatePermissionSummary(facts);
60
+ const facts = validateSecureWindowsSecurityFacts(result.security);
169
61
  return {
170
62
  ok: true,
171
63
  isSymlink: false,
@@ -179,8 +71,33 @@ export function inspectSecureWindowsDescriptor(params) {
179
71
  groupReadable: facts.groupReadable,
180
72
  ownerSid: facts.ownerSid,
181
73
  ownerTrusted: TRUSTED_OWNER_CLASSES.has(facts.ownerClass),
182
- aclSummary: `native descriptor owner=${facts.ownerClass} world=` +
74
+ aclSummary: `${mechanism} descriptor owner=${facts.ownerClass} world=` +
183
75
  `${facts.worldReadable ? "r" : "-"}${facts.worldWritable ? "w" : "-"} ` +
184
76
  `group=${facts.groupReadable ? "r" : "-"}${facts.groupWritable ? "w" : "-"}`,
185
77
  };
186
78
  }
79
+ /** Both mechanisms inspect the same borrowed handle; the caller owns its lifetime. */
80
+ export async function inspectSecureWindowsFile(params) {
81
+ let native;
82
+ try {
83
+ native = getNativeBinding();
84
+ }
85
+ catch (cause) {
86
+ permissionUnverified("Windows descriptor ACL verification requires the matching native helper", cause);
87
+ }
88
+ if (typeof native?.inspectWindowsSecureFileHandle === "function") {
89
+ return inspectSecureWindowsDescriptor(params);
90
+ }
91
+ if (getFsSafeNativeConfig().mode === "require") {
92
+ permissionUnverified("Windows descriptor ACL verification requires an up-to-date native helper");
93
+ }
94
+ warnNativeFallback("windows-secure-file", "Windows descriptor ACL inspection uses a slower built-in system command.");
95
+ let result;
96
+ try {
97
+ result = await inspectWindowsDescriptorCommand(params.fd);
98
+ }
99
+ catch (cause) {
100
+ permissionUnverified("Windows descriptor ACL verification failed", cause);
101
+ }
102
+ return inspectDescriptorResult(params, result, "system-command");
103
+ }
@@ -13,7 +13,7 @@ import { resolveReadOpenFlags } from "./read-open-flags.js";
13
13
  import { realpathSync } from "./realpath.js";
14
14
  import { inspectPathPermissions, isGroupReadable, isGroupWritable, isWorldReadable, isWorldWritable, modeBits, } from "./permissions.js";
15
15
  import { inspectFileIdentity } from "./strict-file-identity.js";
16
- import { inspectSecureWindowsDescriptor } from "./secure-file-windows.js";
16
+ import { inspectSecureWindowsFile } from "./secure-file-windows.js";
17
17
  import { scheduleTimeout } from "./timing.js";
18
18
  import { anchorWindowsDriveRelativePath, assertNoWindowsPathAlias, resolvePathPreservingWindowsRoot, } from "./windows-path-alias.js";
19
19
  function snapshotTrustedDirs(dirs) {
@@ -209,7 +209,7 @@ async function assertSecurePermissions(options, stat, realPath, identity, fd) {
209
209
  const platform = options.inject?.platform ?? process.platform;
210
210
  const permissions = platform === "win32"
211
211
  ? process.platform === "win32"
212
- ? inspectSecureWindowsDescriptor({ fd, identity, stat })
212
+ ? await inspectSecureWindowsFile({ fd, identity, stat })
213
213
  : await inspectPathPermissions(realPath, options.inject)
214
214
  : inspectOpenedPermissions(stat, platform);
215
215
  const reason = permissions.error ? `: ${formatPermissionErrorDetail(permissions.error)}` : "";
@@ -1 +1 @@
1
- {"version":3,"file":"sibling-temp.d.ts","sourceRoot":"","sources":["../src/sibling-temp.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5C,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,mBAAmB,CAAC;IACxC,gBAAgB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AASF,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,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AAC,CAkCxC;AAwBD,wBAAsB,uBAAuB,CAAC,MAAM,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyDhB"}
@@ -25,25 +25,33 @@ export async function writeSiblingTempFile(options) {
25
25
  const dir = resolvePathPreservingWindowsRoot(dirInput);
26
26
  assertNoWindowsPathAlias(dir, "filesystem", "sibling temp directory uses a Windows filesystem namespace alias");
27
27
  const producerIsolation = options.producerIsolation;
28
- await fs.mkdir(recursiveMkdirPath(dir), { recursive: true, mode: options.dirMode ?? 0o700 });
29
- if (options.chmodDir !== false) {
28
+ const dirMode = options.dirMode ?? 0o700;
29
+ const chmodDir = options.chmodDir !== false;
30
+ const tempPrefix = options.tempPrefix;
31
+ const writeTemp = options.writeTemp;
32
+ const resolveFinalPath = options.resolveFinalPath;
33
+ const mode = options.mode;
34
+ const syncTempFile = options.syncTempFile === true;
35
+ const syncParentDir = options.syncParentDir === true;
36
+ await fs.mkdir(recursiveMkdirPath(dir), { recursive: true, mode: dirMode });
37
+ if (chmodDir) {
30
38
  await applyDirectoryMode({
31
39
  fsModule: fs,
32
40
  dirPath: dir,
33
- mode: options.dirMode ?? 0o700,
41
+ mode: dirMode,
34
42
  ignoreChmodError: true,
35
43
  });
36
44
  }
37
45
  return await writeCallbackSibling({
38
46
  tempDir: dir,
39
- tempName: buildTempName(options.tempPrefix),
40
- write: options.writeTemp,
47
+ tempName: buildTempName(tempPrefix),
48
+ write: writeTemp,
41
49
  producerIsolation,
42
- resolveFinalPath: options.resolveFinalPath,
43
- mode: options.mode,
50
+ resolveFinalPath,
51
+ mode,
44
52
  ignoreModeError: true,
45
- syncTempFile: options.syncTempFile === true,
46
- syncParentDir: options.syncParentDir === true,
53
+ syncTempFile,
54
+ syncParentDir,
47
55
  });
48
56
  }
49
57
  function buildSiblingTempName(params) {
@@ -91,6 +99,9 @@ export async function writeViaSiblingTempPath(params) {
91
99
  path.isAbsolute(relativeTargetPath)) {
92
100
  throw new Error("Target path is outside the allowed root");
93
101
  }
102
+ const writeTemp = params.writeTemp;
103
+ const fallbackFileName = params.fallbackFileName;
104
+ const tempPrefix = params.tempPrefix;
94
105
  const rootGuard = await createAsyncDirectoryGuard(rootDir);
95
106
  const workspace = await tempFile({
96
107
  rootDir: resolveSecureTempRoot({
@@ -104,12 +115,12 @@ export async function writeViaSiblingTempPath(params) {
104
115
  try {
105
116
  const tempName = buildSiblingTempName({
106
117
  targetPath: path.join(workspace.dir, path.basename(targetPath)),
107
- fallbackFileName: params.fallbackFileName ?? "output.bin",
108
- tempPrefix: params.tempPrefix ?? ".fs-safe-output-",
118
+ fallbackFileName: fallbackFileName ?? "output.bin",
119
+ tempPrefix: tempPrefix ?? ".fs-safe-output-",
109
120
  });
110
121
  const tempPath = resolveCallbackTempPath(workspace.dir, tempName);
111
122
  await getFsSafeTestHooks()?.beforeSiblingTempWrite?.(tempPath);
112
- await params.writeTemp(tempPath);
123
+ await Function.prototype.call.call(writeTemp, params, tempPath);
113
124
  await assertAsyncDirectoryGuard(rootGuard);
114
125
  const targetRoot = await root(rootDir);
115
126
  await targetRoot.copyIn(relativeTargetPath, tempPath, { mkdir: false });
@@ -1,31 +1,5 @@
1
- import { type NativeFileHandle } from "./native-operations.js";
2
- import type { Root } from "./root-impl.js";
3
- import { type SidecarLockSnapshot } from "./sidecar-lock-reclaim.js";
4
1
  import type { SidecarLockAcquireOptions, SidecarLockHandle } from "./sidecar-lock-types.js";
5
- type SidecarFileHandle = Pick<NativeFileHandle, "fd" | "close" | "stat" | "writeFile">;
6
- export type HeldSidecarLock = {
7
- refCount: number;
8
- reentrantOwner?: string;
9
- handle: SidecarFileHandle;
10
- lockPath: string;
11
- snapshot: SidecarLockSnapshot;
12
- acquiredAt: number;
13
- metadata: Record<string, unknown>;
14
- releasePromise?: Promise<void>;
15
- lockRoot?: Root;
16
- retainOnExit?: boolean;
17
- parsePayload?: (raw: string) => unknown;
18
- compromiseTimer?: NodeJS.Timeout;
19
- };
20
- type SidecarLockAcquisitionContext = {
21
- held: Map<string, HeldSidecarLock>;
22
- reclaimGuards: Set<string>;
23
- ensureExitCleanupRegistered(): void;
24
- handleForHeldLock(normalizedTargetPath: string, held: HeldSidecarLock): SidecarLockHandle;
25
- releaseHeldLock(normalizedTargetPath: string, held: HeldSidecarLock, options?: {
26
- force?: boolean;
27
- }): Promise<boolean>;
28
- };
2
+ import { type SidecarLockAcquisitionContext } from "./sidecar-lock-admission.js";
3
+ export type { HeldSidecarLock } from "./sidecar-lock-admission.js";
29
4
  export declare function acquireSidecarLock<TPayload extends Record<string, unknown>>(options: SidecarLockAcquireOptions<TPayload>, context: SidecarLockAcquisitionContext): Promise<SidecarLockHandle>;
30
- export {};
31
5
  //# sourceMappingURL=sidecar-lock-acquire.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidecar-lock-acquire.d.ts","sourceRoot":"","sources":["../src/sidecar-lock-acquire.ts"],"names":[],"mappings":"AAUA,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAW3C,OAAO,EAWL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK5F,KAAK,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC;AAEvF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MA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