@kardalum/plugin-sdk 0.16.0 → 0.18.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 (274) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +4 -3
  3. package/dist/admin-section-registry.d.ts +14 -5
  4. package/dist/admin-section-registry.js +14 -4
  5. package/dist/assets/asset-picker.d.ts +11 -0
  6. package/dist/assets/asset-picker.js +109 -0
  7. package/dist/assets/asset-tree.d.ts +30 -0
  8. package/dist/assets/asset-tree.js +150 -0
  9. package/dist/built-in-editor-ids.d.ts +1 -0
  10. package/dist/built-in-editor-ids.js +20 -0
  11. package/dist/built-in-settings-schemas.d.ts +2 -0
  12. package/dist/built-in-settings-schemas.js +27 -0
  13. package/dist/built-in-value-schemas.js +3 -0
  14. package/dist/built-ins.js +10 -1
  15. package/dist/capabilities.js +5 -3
  16. package/dist/datatype-validation.js +18 -4
  17. package/dist/datatypes-entry.d.ts +1 -0
  18. package/dist/datatypes-entry.js +1 -0
  19. package/dist/entitlement-entry.d.ts +3 -2
  20. package/dist/entitlement-entry.js +13 -1
  21. package/dist/entitlement-gate.d.ts +18 -0
  22. package/dist/entitlement-gate.js +95 -21
  23. package/dist/entitlement-plan.d.ts +21 -0
  24. package/dist/entitlement-plan.js +26 -0
  25. package/dist/entitlement-types.d.ts +21 -4
  26. package/dist/entitlement.d.ts +29 -1
  27. package/dist/entitlement.js +39 -0
  28. package/dist/grid-arrow-step.d.ts +7 -0
  29. package/dist/grid-arrow-step.js +20 -0
  30. package/dist/host-entry.d.ts +1 -1
  31. package/dist/host-entry.js +1 -1
  32. package/dist/index.d.ts +8 -3
  33. package/dist/index.js +13 -18
  34. package/dist/license-verdict-keys.d.ts +4 -3
  35. package/dist/license-verdict-keys.js +4 -7
  36. package/dist/manifest-entry.d.ts +6 -2
  37. package/dist/manifest-entry.js +5 -1
  38. package/dist/manifest-schema.d.ts +56 -63
  39. package/dist/manifest-schema.js +103 -249
  40. package/dist/manifest.d.ts +61 -73
  41. package/dist/manifest.js +13 -36
  42. package/dist/media/media-picker.js +32 -32
  43. package/dist/notify.d.ts +17 -0
  44. package/dist/notify.js +17 -0
  45. package/dist/plugin-screen-context.d.ts +11 -1
  46. package/dist/richtext/block-panel.js +19 -20
  47. package/dist/richtext/extensions.js +10 -1
  48. package/dist/richtext/insert-menu.js +1 -1
  49. package/dist/richtext/kardalum-block.js +17 -17
  50. package/dist/richtext/style-listbox.js +4 -4
  51. package/dist/richtext-html-entry.d.ts +35 -0
  52. package/dist/richtext-html-entry.js +73 -0
  53. package/dist/structured-storage-types.d.ts +11 -0
  54. package/dist/tailwind.js +10 -3
  55. package/dist/tokens/tailwind-theme.css +176 -0
  56. package/dist/tokens/tokens.css +2 -0
  57. package/dist/tokens/tokens.json +4 -2
  58. package/dist/type-equality.d.ts +2 -0
  59. package/dist/type-equality.js +1 -0
  60. package/dist/vendor-check.d.ts +39 -0
  61. package/dist/vendor-check.js +79 -0
  62. package/dist/vendor-entry.d.ts +3 -0
  63. package/dist/vendor-entry.js +9 -0
  64. package/dist/vendor-service.d.ts +20 -0
  65. package/dist/vendor-service.js +20 -0
  66. package/dist/views/asset-view.d.ts +6 -0
  67. package/dist/views/asset-view.js +55 -0
  68. package/dist/views/content-list-settings-view.js +1 -1
  69. package/dist/views/content-list-view.js +1 -1
  70. package/dist/views/html-code-editor.js +0 -1
  71. package/dist/views/html-view.js +1 -1
  72. package/dist/views/image-view.js +1 -1
  73. package/dist/views/rich-text-view.js +30 -30
  74. package/node_modules/@kardalum/api-schemas/README.md +1 -1
  75. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
  76. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +43 -10
  77. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
  78. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
  79. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +23 -1
  80. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +60 -18
  81. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
  82. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
  83. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
  84. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
  85. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
  86. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +22 -6
  87. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
  88. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
  89. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
  90. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
  91. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +52 -10
  92. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +33 -14
  93. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
  94. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
  95. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
  96. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
  97. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
  98. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
  99. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
  100. package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
  101. package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
  102. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +73 -31
  103. package/node_modules/@kardalum/api-schemas/dist/index.js +47 -17
  104. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
  105. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
  106. package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
  107. package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
  108. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
  109. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
  110. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +216 -63
  111. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +117 -5
  112. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
  113. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
  114. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
  115. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
  116. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
  117. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
  118. package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
  119. package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
  120. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
  121. package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
  122. package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
  123. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
  124. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
  125. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
  126. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
  127. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +8 -18
  128. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
  129. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +3 -19
  130. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -15
  131. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
  132. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
  133. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +1 -1
  134. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +97 -85
  135. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +35 -68
  136. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
  137. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
  138. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +9 -2
  139. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +22 -7
  140. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +240 -6
  141. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +164 -32
  142. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +4 -3
  143. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +1 -1
  144. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +14 -0
  145. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
  146. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
  147. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
  148. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
  149. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
  150. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
  151. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +83 -0
  153. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +152 -0
  154. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
  155. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
  156. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
  157. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +35 -23
  158. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
  159. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
  160. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +11 -0
  161. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +7 -0
  162. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +11 -2
  163. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +21 -3
  164. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
  165. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
  166. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +6 -6
  167. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +58 -25
  168. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +194 -48
  169. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +18 -6
  170. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +14 -0
  171. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +2 -2
  172. package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
  173. package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
  174. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +115 -1
  175. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +65 -10
  176. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +37 -2
  177. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +34 -8
  178. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
  179. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
  180. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +16 -0
  181. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
  182. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
  183. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
  184. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
  185. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
  186. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +32 -0
  187. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +27 -0
  188. package/node_modules/@kardalum/api-schemas/package.json +2 -2
  189. package/node_modules/@kardalum/design-tokens/README.md +1 -1
  190. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
  191. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
  192. package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
  193. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
  194. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
  195. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  196. package/node_modules/@kardalum/design-tokens/dist/tokens.css +2 -0
  197. package/node_modules/@kardalum/design-tokens/dist/tokens.js +4 -0
  198. package/node_modules/@kardalum/design-tokens/dist/tokens.json +4 -2
  199. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -0
  200. package/node_modules/@kardalum/design-tokens/package.json +6 -3
  201. package/node_modules/@kardalum/plugin-package/README.md +5 -2
  202. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +6 -21
  203. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +13 -8
  204. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  205. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +59 -16
  206. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
  207. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
  208. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
  209. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
  210. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
  211. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
  212. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +8 -0
  213. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +77 -0
  214. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
  215. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
  216. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
  217. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
  218. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
  219. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
  220. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
  221. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
  222. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
  223. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
  224. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
  225. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
  226. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
  227. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
  228. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
  229. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +137 -0
  230. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
  231. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
  232. package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
  233. package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
  234. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +7 -0
  235. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +215 -0
  236. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
  237. package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
  238. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
  239. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
  240. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
  241. package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
  242. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -4
  243. package/node_modules/@kardalum/plugin-package/dist/index.js +10 -3
  244. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
  245. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
  246. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
  247. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
  248. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +1 -0
  249. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +1 -0
  250. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +21 -3
  251. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +37 -9
  252. package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
  253. package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
  254. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
  255. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
  256. package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
  257. package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
  258. package/node_modules/@kardalum/plugin-package/package.json +4 -2
  259. package/node_modules/@kardalum/ui/README.md +1 -1
  260. package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
  261. package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
  262. package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
  263. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +3 -3
  264. package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
  265. package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
  266. package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
  267. package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
  268. package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
  269. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
  270. package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
  271. package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
  272. package/node_modules/@kardalum/ui/dist/index.js +1 -0
  273. package/node_modules/@kardalum/ui/package.json +1 -1
  274. package/package.json +19 -6
@@ -1,10 +1,25 @@
1
+ import type { Entry } from "yauzl";
1
2
  export declare const MAX_TOTAL_BYTES: number;
2
3
  export declare const MAX_ENTRY_BYTES: number;
3
4
  export declare const MAX_ENTRIES = 2000;
5
+ /** An entry name as a message quotes it: JSON-escaped, so a control character
6
+ * or a quote cannot break the line, and cut after NAME_SHOWN characters. */
7
+ export declare function quoteEntryName(name: string): string;
8
+ /** The longest name a package may hold: Windows' MAX_PATH, api-schemas'
9
+ * PACKAGE_PATH_MAX, which the template file and asset path caps are drawn
10
+ * from. A path longer than that cannot be written on a Windows host, wherever
11
+ * the package installs, since the install's own folder only adds to it (S311
12
+ * second code fix). */
13
+ export declare const ENTRY_NAME_MAX = 260;
14
+ /** The most segments, folders and a file, one name may have. */
15
+ export declare const ENTRY_SEGMENTS_MAX = 32;
4
16
  /** Pure gate over one entry's (path, type, declaredSize). Returns the
5
17
  * violation message or null. Exported for direct unit testing — a
6
18
  * well-formed writer can't produce hostile names, but attackers hand-craft
7
- * archives directly.
19
+ * archives directly. The path rules are nameViolation's: what a Linux
20
+ * extraction and a Windows or macOS one would read as different files is
21
+ * refused, so every reader of a package (both of the marketplace's, the
22
+ * install's, the watermark's re-pack) admits the same names.
8
23
  *
9
24
  * "OldFile" and "ContiguousFile" are accepted alongside "File" for
10
25
  * historical (tar-era) compatibility with entries this gate has always
@@ -14,10 +29,83 @@ export declare const MAX_ENTRIES = 2000;
14
29
  * behavior and would only risk breaking direct callers of this exported
15
30
  * function. */
16
31
  export declare function entryViolation(path: string, type: string, size: number): string | null;
32
+ /** The key two entry names are compared by: the path's segments, split on "/"
33
+ * and backslash (a Windows extraction reads both as a separator), with empty
34
+ * and "." segments dropped and case folded (a case-insensitive filesystem
35
+ * writes "A.txt" and "a.txt" to one file). Two names with one key land on one
36
+ * path, so "manifest.json", "./manifest.json", ".//manifest.json" and the same
37
+ * name behind a backslash are one name. entryViolation refuses the "." and
38
+ * backslash spellings on their own now; the key still folds case and empty
39
+ * segments. Linear in the name's length. */
40
+ export declare function normalizeEntryName(name: string): string;
41
+ type EntryNameSource = Pick<Entry, "fileNameRaw" | "generalPurposeBitFlag" | "extraFields">;
42
+ /** The one name every reader of a package gives an entry (S311): the header's
43
+ * raw bytes, decoded as UTF-8 when the entry's flag (0x800) says so and as
44
+ * latin1 otherwise. ASCII, the only bytes entryViolation's checks look at,
45
+ * decodes the same either way. An entry that names itself a second time, in an
46
+ * Info-ZIP Unicode Path field, is refused: a reader that honours the field (yauzl
47
+ * with decodeStrings) and one that does not would read different files. Open the
48
+ * archive with `decodeStrings: false`, so yauzl neither prefers the field nor
49
+ * turns a backslash into a slash. */
50
+ export declare function decodeEntryName(entry: EntryNameSource): {
51
+ ok: true;
52
+ name: string;
53
+ } | {
54
+ ok: false;
55
+ reason: string;
56
+ };
57
+ export type AdmittedEntry = {
58
+ ok: true;
59
+ name: string;
60
+ isDirectory: boolean;
61
+ } | {
62
+ ok: false;
63
+ reason: string;
64
+ };
65
+ /** The rule for the paths of one archive (S311 fix wave): each path once, by
66
+ * normalizeEntryName's key, and each path one kind, never a file where another
67
+ * entry needs a folder ("a" beside "a/b", or "public/Logo" beside
68
+ * "public/logo/x.png", which a case-insensitive host cannot write). Returns
69
+ * the reason a name is refused, or null once it is admitted. A folder entry
70
+ * for a folder the files under it already imply is admitted, in either order.
71
+ * The paths are held as a tree of segments, so a name costs time linear in its
72
+ * length. Every caller hands it a name entryViolation admitted, at most
73
+ * ENTRY_NAME_MAX characters in at most ENTRY_SEGMENTS_MAX segments, so an
74
+ * archive of MAX_ENTRIES entries holds at most that many nodes per entry
75
+ * (the S311 second code fix: an uncapped name could make one archive hold
76
+ * gigabytes). createEntryGate applies it to every reader of a package, and the
77
+ * `archive names` check and `kardalum plugin pack` apply it before an archive
78
+ * exists. */
79
+ export declare function createPathKeyGate(): (name: string, isDirectory: boolean) => string | null;
80
+ /** The rules every reader of a package applies to its entries, in central
81
+ * directory order (S311): at most MAX_ENTRIES entries, each name decoded by
82
+ * decodeEntryName and passing entryViolation (which holds MAX_ENTRY_BYTES), each
83
+ * path once and of one kind by createPathKeyGate, and MAX_TOTAL_BYTES declared
84
+ * in all. One gate per archive: it counts what it has admitted. extractArtifact
85
+ * and the marketplace's manifest reader both read through it, so the door's
86
+ * reader refuses exactly what extraction refuses, before a listing exists. */
87
+ export declare function createEntryGate(): (entry: EntryNameSource & Pick<Entry, "uncompressedSize">) => AdmittedEntry;
88
+ /** An entry a packer is about to write: its path with "/" (a folder without
89
+ * the trailing slash the archive gives it) and its size. */
90
+ export interface PlannedEntry {
91
+ name: string;
92
+ isDirectory: boolean;
93
+ size: number;
94
+ }
95
+ /** What createEntryGate would refuse first in `entries`, in order, or null:
96
+ * the rule extraction and the marketplace read an archive by, applied by a
97
+ * packer before it writes one (S311 fix wave), so `kardalum plugin pack` never
98
+ * writes an archive the marketplace or an install would refuse for a name,
99
+ * the entry count or a size. */
100
+ export declare function plannedEntryRefusal(entries: readonly PlannedEntry[]): string | null;
17
101
  /**
18
102
  * Extracts a single ZIP archive into `targetDir`, admitting only entries
19
- * that pass `entryViolation`'s allow-list and the MAX_ENTRIES/
20
- * MAX_TOTAL_BYTES ceilings below. Never throws — every failure mode
103
+ * that pass createEntryGate: `entryViolation`'s allow-list, the MAX_ENTRIES
104
+ * and MAX_TOTAL_BYTES ceilings, one name per entry (no Info-ZIP Unicode Path
105
+ * field) and each path once by `normalizeEntryName`'s segment key (S311). The
106
+ * marketplace's manifest reader reads through the same gate and the same
107
+ * decoder, so the manifest.json it parsed is the one file that lands at
108
+ * manifest.json; the door also compares the two by hash. Never throws: every failure mode
21
109
  * resolves `{ ok: false, reason }`, so a hostile or broken package
22
110
  * degrades with a clear reason at install time instead of an uncaught
23
111
  * rejection bricking (or 500-ing) the host.
@@ -35,3 +123,4 @@ export declare function extractArtifact(archivePath: string, targetDir: string):
35
123
  ok: false;
36
124
  reason: string;
37
125
  }>;
126
+ export {};
@@ -1,14 +1,92 @@
1
1
  import { createWriteStream, mkdirSync } from "node:fs";
2
2
  import { dirname, resolve as resolvePath, sep } from "node:path";
3
3
  import * as yauzl from "yauzl";
4
+ import { FILE_NAME_MAX, PACKAGE_PATH_MAX } from "@kardalum/api-schemas";
4
5
  export const MAX_TOTAL_BYTES = 100 * 1024 * 1024;
5
6
  export const MAX_ENTRY_BYTES = 50 * 1024 * 1024;
6
7
  export const MAX_ENTRIES = 2000;
7
8
  const ALLOWED_ENTRY_TYPES = new Set(["File", "OldFile", "ContiguousFile", "Directory"]);
9
+ /** How much of a name a message quotes: an entry name may be 64 KiB, and a
10
+ * refusal reaches an upload's response and a stored report. */
11
+ const NAME_SHOWN = 120;
12
+ /** An entry name as a message quotes it: JSON-escaped, so a control character
13
+ * or a quote cannot break the line, and cut after NAME_SHOWN characters. */
14
+ export function quoteEntryName(name) {
15
+ return JSON.stringify(name.length > NAME_SHOWN ? `${name.slice(0, NAME_SHOWN)}...` : name);
16
+ }
17
+ /** The longest name a package may hold: Windows' MAX_PATH, api-schemas'
18
+ * PACKAGE_PATH_MAX, which the template file and asset path caps are drawn
19
+ * from. A path longer than that cannot be written on a Windows host, wherever
20
+ * the package installs, since the install's own folder only adds to it (S311
21
+ * second code fix). */
22
+ export const ENTRY_NAME_MAX = PACKAGE_PATH_MAX;
23
+ /** The most segments, folders and a file, one name may have. */
24
+ export const ENTRY_SEGMENTS_MAX = 32;
25
+ /** The names Windows keeps for devices, which no Windows folder can hold as a
26
+ * file or a folder, in any case and with any extension ("nul.txt" and
27
+ * "NUL.tar.gz" are the device too). */
28
+ const WINDOWS_DEVICE_NAME = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i;
29
+ /** Why a name cannot be extracted the same way on every host, or null.
30
+ * The door extracts on Linux, a site may install on Windows or macOS, and a
31
+ * name that is one file on the first can be another file, or the same file
32
+ * as its neighbour, on the second (S311 second fix wave): an NTFS stream
33
+ * ("plugin.js::$DATA" writes plugin.js), an 8.3 short name ("PLUGIN~1.JS"),
34
+ * a trailing dot or space Windows drops, a backslash Windows reads as a
35
+ * separator, and any non-ASCII character a filesystem folds or normalizes
36
+ * ("\u0131", "\u017F", NFD on APFS). Every package path rule (manifest
37
+ * ids, docs, locales, media, templates, assets) is ASCII already, so a
38
+ * package holds only names that read one way everywhere. Since the S311
39
+ * second code fix it also refuses what a Windows host cannot write at all: a
40
+ * name longer than ENTRY_NAME_MAX or deeper than ENTRY_SEGMENTS_MAX, a
41
+ * segment longer than FILE_NAME_MAX (the third code fix), the characters
42
+ * < > " | ? * and the device names. The length and the depth come
43
+ * first, before any pattern reads the name, and they bound every reader that
44
+ * admits it: createPathKeyGate's tree, the folders extraction implies and the
45
+ * marketplace's walks of what it extracted. */
46
+ function nameViolation(path) {
47
+ if (path.length > ENTRY_NAME_MAX)
48
+ return `a name longer than ${ENTRY_NAME_MAX} characters, which Windows cannot write (MAX_PATH)`;
49
+ // A directory entry ends in "/", so its last segment is empty and is not counted.
50
+ let segments = path.endsWith("/") ? 0 : 1;
51
+ for (let i = 0; i < path.length; i++)
52
+ if (path[i] === "/")
53
+ segments++;
54
+ if (segments > ENTRY_SEGMENTS_MAX)
55
+ return `more than ${ENTRY_SEGMENTS_MAX} segments, folders and a file, in one path`;
56
+ if (/[\u0000-\u001f\u007f]/.test(path))
57
+ return "a control character in a name";
58
+ if (/[^\u0020-\u007e]/.test(path))
59
+ return "a character that is not ASCII: every package path is ASCII";
60
+ if (path.startsWith("/"))
61
+ return "an absolute path";
62
+ if (path.includes("\\"))
63
+ return "a backslash, which Windows reads as a separator";
64
+ if (path.includes(":"))
65
+ return "a colon, which names a drive or a stream on Windows";
66
+ if (/[<>"|?*]/.test(path))
67
+ return 'a character Windows refuses in a name: <, >, ", |, ? or *';
68
+ for (const segment of path.split("/")) {
69
+ if (segment.length > FILE_NAME_MAX)
70
+ return `a segment longer than ${FILE_NAME_MAX} characters, longer than a file or folder name may be`;
71
+ if (segment === "..")
72
+ return 'a ".." segment';
73
+ if (segment.endsWith(".") || segment.endsWith(" "))
74
+ return 'a segment that ends in "." or a space, which Windows drops';
75
+ if (/~[0-9]/.test(segment))
76
+ return '"~" and a digit, the shape of a Windows short name';
77
+ if (WINDOWS_DEVICE_NAME.test(segment)) {
78
+ return "a Windows device name (CON, PRN, AUX, NUL, COM1 to COM9 or LPT1 to LPT9, with or without an extension), which no Windows folder can hold";
79
+ }
80
+ }
81
+ return null;
82
+ }
8
83
  /** Pure gate over one entry's (path, type, declaredSize). Returns the
9
84
  * violation message or null. Exported for direct unit testing — a
10
85
  * well-formed writer can't produce hostile names, but attackers hand-craft
11
- * archives directly.
86
+ * archives directly. The path rules are nameViolation's: what a Linux
87
+ * extraction and a Windows or macOS one would read as different files is
88
+ * refused, so every reader of a package (both of the marketplace's, the
89
+ * install's, the watermark's re-pack) admits the same names.
12
90
  *
13
91
  * "OldFile" and "ContiguousFile" are accepted alongside "File" for
14
92
  * historical (tar-era) compatibility with entries this gate has always
@@ -18,24 +96,170 @@ const ALLOWED_ENTRY_TYPES = new Set(["File", "OldFile", "ContiguousFile", "Direc
18
96
  * behavior and would only risk breaking direct callers of this exported
19
97
  * function. */
20
98
  export function entryViolation(path, type, size) {
21
- if (path.startsWith("/") ||
22
- path.startsWith("\\") ||
23
- /^[a-zA-Z]:/.test(path) ||
24
- path.split(/[\\/]/).includes("..")) {
25
- return `unsafe entry path "${path}"`;
26
- }
99
+ const unsafe = nameViolation(path);
100
+ if (unsafe)
101
+ return `unsafe entry path ${quoteEntryName(path)}: ${unsafe}`;
27
102
  if (!ALLOWED_ENTRY_TYPES.has(type)) {
28
- return `unsafe entry type "${type}" for "${path}": only files and directories are allowed`;
103
+ return `unsafe entry type ${JSON.stringify(type)} for ${quoteEntryName(path)}: only files and directories are allowed`;
29
104
  }
30
105
  if (size > MAX_ENTRY_BYTES) {
31
- return `entry "${path}" exceeds the per-file size limit`;
106
+ return `entry ${quoteEntryName(path)} exceeds the per-file size limit`;
107
+ }
108
+ return null;
109
+ }
110
+ /** The key two entry names are compared by: the path's segments, split on "/"
111
+ * and backslash (a Windows extraction reads both as a separator), with empty
112
+ * and "." segments dropped and case folded (a case-insensitive filesystem
113
+ * writes "A.txt" and "a.txt" to one file). Two names with one key land on one
114
+ * path, so "manifest.json", "./manifest.json", ".//manifest.json" and the same
115
+ * name behind a backslash are one name. entryViolation refuses the "." and
116
+ * backslash spellings on their own now; the key still folds case and empty
117
+ * segments. Linear in the name's length. */
118
+ export function normalizeEntryName(name) {
119
+ return name
120
+ .split(/[\\/]/)
121
+ .filter((segment) => segment !== "" && segment !== ".")
122
+ .join("/")
123
+ .toLowerCase();
124
+ }
125
+ /** The Info-ZIP Unicode Path extra field: a second name for an entry, in UTF-8,
126
+ * which yauzl's own decoding prefers to the header's name when its CRC matches. */
127
+ const UNICODE_PATH_FIELD = 0x7075;
128
+ /** The one name every reader of a package gives an entry (S311): the header's
129
+ * raw bytes, decoded as UTF-8 when the entry's flag (0x800) says so and as
130
+ * latin1 otherwise. ASCII, the only bytes entryViolation's checks look at,
131
+ * decodes the same either way. An entry that names itself a second time, in an
132
+ * Info-ZIP Unicode Path field, is refused: a reader that honours the field (yauzl
133
+ * with decodeStrings) and one that does not would read different files. Open the
134
+ * archive with `decodeStrings: false`, so yauzl neither prefers the field nor
135
+ * turns a backslash into a slash. */
136
+ export function decodeEntryName(entry) {
137
+ const isUtf8 = (entry.generalPurposeBitFlag & 0x800) !== 0;
138
+ const name = entry.fileNameRaw.toString(isUtf8 ? "utf8" : "latin1");
139
+ if (entry.extraFields.some((field) => field.id === UNICODE_PATH_FIELD)) {
140
+ return { ok: false, reason: `entry ${quoteEntryName(name)} carries a second name (an Info-ZIP Unicode Path field): an archive names each entry once` };
141
+ }
142
+ return { ok: true, name };
143
+ }
144
+ const newPathNode = () => ({ children: null, file: null, folder: null, folderEntry: false });
145
+ const ONE_KIND = "a path is a file or a folder, not both (paths compare without case)";
146
+ /** The rule for the paths of one archive (S311 fix wave): each path once, by
147
+ * normalizeEntryName's key, and each path one kind, never a file where another
148
+ * entry needs a folder ("a" beside "a/b", or "public/Logo" beside
149
+ * "public/logo/x.png", which a case-insensitive host cannot write). Returns
150
+ * the reason a name is refused, or null once it is admitted. A folder entry
151
+ * for a folder the files under it already imply is admitted, in either order.
152
+ * The paths are held as a tree of segments, so a name costs time linear in its
153
+ * length. Every caller hands it a name entryViolation admitted, at most
154
+ * ENTRY_NAME_MAX characters in at most ENTRY_SEGMENTS_MAX segments, so an
155
+ * archive of MAX_ENTRIES entries holds at most that many nodes per entry
156
+ * (the S311 second code fix: an uncapped name could make one archive hold
157
+ * gigabytes). createEntryGate applies it to every reader of a package, and the
158
+ * `archive names` check and `kardalum plugin pack` apply it before an archive
159
+ * exists. */
160
+ export function createPathKeyGate() {
161
+ const root = newPathNode();
162
+ return (name, isDirectory) => {
163
+ const key = normalizeEntryName(name);
164
+ if (key === "")
165
+ return `entry ${quoteEntryName(name)} names no path`;
166
+ const segments = key.split("/");
167
+ let node = root;
168
+ for (let i = 0; i < segments.length - 1; i++) {
169
+ const segment = segments[i];
170
+ node.children ??= new Map();
171
+ let child = node.children.get(segment);
172
+ if (child === undefined) {
173
+ child = newPathNode();
174
+ child.folder = name;
175
+ node.children.set(segment, child);
176
+ }
177
+ else if (child.file !== null) {
178
+ return `entry ${quoteEntryName(name)} sits under ${quoteEntryName(child.file)}, which the archive holds as a file: ${ONE_KIND}`;
179
+ }
180
+ node = child;
181
+ }
182
+ const last = segments[segments.length - 1];
183
+ node.children ??= new Map();
184
+ const existing = node.children.get(last);
185
+ if (existing === undefined) {
186
+ const created = newPathNode();
187
+ if (isDirectory) {
188
+ created.folder = name;
189
+ created.folderEntry = true;
190
+ }
191
+ else {
192
+ created.file = name;
193
+ }
194
+ node.children.set(last, created);
195
+ return null;
196
+ }
197
+ // S311 (S292): a second entry under a name already admitted would overwrite
198
+ // the first on disk, so the file a reader of the archive's first copy checked
199
+ // (the door's manifest read) is not the one that lands.
200
+ if (existing.file !== null || existing.folderEntry)
201
+ return `repeated entry name ${quoteEntryName(name)}: an archive holds each path once`;
202
+ if (!isDirectory)
203
+ return `entry ${quoteEntryName(name)} is a file where ${quoteEntryName(existing.folder ?? name)} needs a folder: ${ONE_KIND}`;
204
+ existing.folderEntry = true;
205
+ return null;
206
+ };
207
+ }
208
+ /** The rules every reader of a package applies to its entries, in central
209
+ * directory order (S311): at most MAX_ENTRIES entries, each name decoded by
210
+ * decodeEntryName and passing entryViolation (which holds MAX_ENTRY_BYTES), each
211
+ * path once and of one kind by createPathKeyGate, and MAX_TOTAL_BYTES declared
212
+ * in all. One gate per archive: it counts what it has admitted. extractArtifact
213
+ * and the marketplace's manifest reader both read through it, so the door's
214
+ * reader refuses exactly what extraction refuses, before a listing exists. */
215
+ export function createEntryGate() {
216
+ let entries = 0;
217
+ let totalBytes = 0;
218
+ const admitPath = createPathKeyGate();
219
+ return (entry) => {
220
+ entries += 1;
221
+ if (entries > MAX_ENTRIES)
222
+ return { ok: false, reason: `archive has more than ${MAX_ENTRIES} entries` };
223
+ const decoded = decodeEntryName(entry);
224
+ if (!decoded.ok)
225
+ return decoded;
226
+ const name = decoded.name;
227
+ const isDirectory = name.endsWith("/");
228
+ const violation = entryViolation(name, isDirectory ? "Directory" : "File", entry.uncompressedSize);
229
+ if (violation)
230
+ return { ok: false, reason: violation };
231
+ const pathRefusal = admitPath(name, isDirectory);
232
+ if (pathRefusal)
233
+ return { ok: false, reason: pathRefusal };
234
+ totalBytes += entry.uncompressedSize;
235
+ if (totalBytes > MAX_TOTAL_BYTES)
236
+ return { ok: false, reason: `archive expands beyond the ${MAX_TOTAL_BYTES / 1024 / 1024} MiB limit` };
237
+ return { ok: true, name, isDirectory };
238
+ };
239
+ }
240
+ /** What createEntryGate would refuse first in `entries`, in order, or null:
241
+ * the rule extraction and the marketplace read an archive by, applied by a
242
+ * packer before it writes one (S311 fix wave), so `kardalum plugin pack` never
243
+ * writes an archive the marketplace or an install would refuse for a name,
244
+ * the entry count or a size. */
245
+ export function plannedEntryRefusal(entries) {
246
+ const admit = createEntryGate();
247
+ for (const entry of entries) {
248
+ const name = entry.isDirectory ? `${entry.name}/` : entry.name;
249
+ const admitted = admit({ fileNameRaw: Buffer.from(name, "utf8"), generalPurposeBitFlag: 0x800, extraFields: [], uncompressedSize: entry.size });
250
+ if (!admitted.ok)
251
+ return admitted.reason;
32
252
  }
33
253
  return null;
34
254
  }
35
255
  /**
36
256
  * Extracts a single ZIP archive into `targetDir`, admitting only entries
37
- * that pass `entryViolation`'s allow-list and the MAX_ENTRIES/
38
- * MAX_TOTAL_BYTES ceilings below. Never throws — every failure mode
257
+ * that pass createEntryGate: `entryViolation`'s allow-list, the MAX_ENTRIES
258
+ * and MAX_TOTAL_BYTES ceilings, one name per entry (no Info-ZIP Unicode Path
259
+ * field) and each path once by `normalizeEntryName`'s segment key (S311). The
260
+ * marketplace's manifest reader reads through the same gate and the same
261
+ * decoder, so the manifest.json it parsed is the one file that lands at
262
+ * manifest.json; the door also compares the two by hash. Never throws: every failure mode
39
263
  * resolves `{ ok: false, reason }`, so a hostile or broken package
40
264
  * degrades with a clear reason at install time instead of an uncaught
41
265
  * rejection bricking (or 500-ing) the host.
@@ -73,8 +297,10 @@ export function extractArtifact(archivePath, targetDir) {
73
297
  // an 'entry' event, and rejects by emitting 'error' on the whole
74
298
  // zipfile with its own message text. That would make yauzl's built-in
75
299
  // check the real gate for hostile names, not entryViolation. Decoding
76
- // fileNameRaw ourselves below keeps entryViolation authoritative, as
77
- // required — one gate, not two.
300
+ // fileNameRaw ourselves (createEntryGate, through decodeEntryName) keeps
301
+ // entryViolation authoritative, as required: one gate, not two. It also
302
+ // keeps yauzl from preferring an Info-ZIP Unicode Path field to the
303
+ // header's name, which the gate refuses instead.
78
304
  yauzl.open(archivePath, { lazyEntries: true, decodeStrings: false }, (openErr, zipfile) => {
79
305
  if (openErr || !zipfile) {
80
306
  settle({ ok: false, reason: "not a valid .zip archive" });
@@ -94,8 +320,7 @@ export function extractArtifact(archivePath, targetDir) {
94
320
  settle({ ok: false, reason: `archive has more than ${MAX_ENTRIES} entries` });
95
321
  return;
96
322
  }
97
- let entryCount = 0;
98
- let totalBytes = 0;
323
+ const admit = createEntryGate();
99
324
  const fail = (reason) => {
100
325
  zipfile.close();
101
326
  settle({ ok: false, reason });
@@ -104,33 +329,18 @@ export function extractArtifact(archivePath, targetDir) {
104
329
  zipfile.on("entry", (entry) => {
105
330
  if (settled)
106
331
  return;
107
- entryCount += 1;
108
- if (entryCount > MAX_ENTRIES) {
109
- fail(`archive has more than ${MAX_ENTRIES} entries`);
110
- return;
111
- }
112
- // fileNameRaw is always populated regardless of decodeStrings; the
113
- // UTF-8 general-purpose bit (0x800) tells us how to interpret it.
114
- // ASCII bytes (the only ones that matter to entryViolation's own
115
- // checks) decode identically under utf8 or latin1, so a plain
116
- // fallback for non-UTF-8 archives is fine here — full CP437
117
- // fidelity only affects display of non-ASCII names, never safety.
118
- const isUtf8 = (entry.generalPurposeBitFlag & 0x800) !== 0;
119
- const fileName = entry.fileNameRaw.toString(isUtf8 ? "utf8" : "latin1");
120
- const isDirectory = fileName.endsWith("/");
121
- const type = isDirectory ? "Directory" : "File";
122
- const violation = entryViolation(fileName, type, entry.uncompressedSize);
123
- if (violation) {
124
- fail(violation);
125
- return;
126
- }
127
- totalBytes += entry.uncompressedSize;
128
- if (totalBytes > MAX_TOTAL_BYTES) {
129
- fail(`archive expands beyond the ${MAX_TOTAL_BYTES / 1024 / 1024} MB limit`);
332
+ // The gate decodes fileNameRaw itself (the archive is opened with
333
+ // decodeStrings: false), so entryViolation stays the one judge of a
334
+ // hostile name and yauzl never swaps in an Info-ZIP Unicode Path field
335
+ // or turns a backslash into a slash behind it.
336
+ const admitted = admit(entry);
337
+ if (!admitted.ok) {
338
+ fail(admitted.reason);
130
339
  return;
131
340
  }
132
- // This is an assertion, not a second gate: entryViolation above
133
- // already rejects a leading "/" or "\\", a drive letter, and any
341
+ const { name: fileName, isDirectory } = admitted;
342
+ // This is an assertion, not a second gate: entryViolation (inside the
343
+ // gate) already rejects a leading "/" or "\\", a drive letter, and any
134
344
  // ".." segment, so resolving fileName against targetDir can never
135
345
  // land outside it — this branch must be unreachable. It stays
136
346
  // because it is a two-line check against the one failure mode
@@ -139,7 +349,7 @@ export function extractArtifact(archivePath, targetDir) {
139
349
  // regression in entryViolation would cost.
140
350
  const destPath = resolvePath(targetDir, fileName);
141
351
  if (destPath !== resolvedTargetDir && !destPath.startsWith(resolvedTargetDir + sep)) {
142
- fail(`unsafe entry path "${fileName}"`);
352
+ fail(`unsafe entry path ${quoteEntryName(fileName)}`);
143
353
  return;
144
354
  }
145
355
  // The filesystem calls below can throw — most concretely EEXIST
@@ -1,13 +1,22 @@
1
1
  export type { PackageSignatureSidecar, SignatureEnvelope, TrustedKey, VerifyFailureReason, VerifyResult, } from "./types.js";
2
2
  export { VERIFY_FAILURE_REASONS } from "./types.js";
3
3
  export { canonicalizeEnvelope, deriveKeyId, generateSigningKeyPair, signEnvelope, verifyEnvelope, } from "./envelope.js";
4
- export type { LicenseChallenge, LicenseVerdictEnvelope, LicenseVerdictResult, LicenseVerdictSignatureResult, SignedLicenseVerdict, TamperKind, } from "./license-verdict.js";
5
- export { canonicalizeLicenseVerdict, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_VERDICT_DETAIL_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
4
+ export type { LicenseChallenge, LicenseTermState, LicenseVerdictEnvelope, LicenseVerdictResult, LicenseVerdictSignatureResult, LicenseVerdictTerm, SignedLicenseVerdict, TamperKind, } from "./license-verdict.js";
5
+ export { canonicalizeLicenseVerdict, canonicalizeLicenseVerdictTerm, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_TERM_STATES, LICENSE_VERDICT_DETAIL_MAX, LICENSE_VERDICT_PLAN_ID_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, signLicenseVerdictWithTerm, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
6
+ export { VENDOR_TOKEN_LEEWAY_SECONDS, VENDOR_TOKEN_SIGNING_PREFIX, signVendorToken, verifyVendorToken } from "./vendor-token.js";
7
+ export type { VendorTokenFailure, VendorTokenVerifyResult } from "./vendor-token.js";
6
8
  export { hashBuffer, hashArchive, hashDirectories } from "./hash.js";
7
- export { entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "./extract.js";
8
- export { SAMPLE_CONTENT_MAX_BYTES, readShippedInstallFacts, readShippedSampleContent } from "./sample-content.js";
9
+ export type { AdmittedEntry, PlannedEntry } from "./extract.js";
10
+ export { createEntryGate, createPathKeyGate, decodeEntryName, ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES, normalizeEntryName, plannedEntryRefusal, } from "./extract.js";
11
+ export type { ShippedEntry } from "./shipped-files.js";
12
+ export { EXCLUDED_NAMES, createShippedLookup, isExcludedSegment, walkShipped, whyNotShipped } from "./shipped-files.js";
13
+ export { SAMPLE_CONTENT_MAX_BYTES, hasSampleContentConsumer, installFactsOf, readShippedInstallFacts, readShippedSampleContent } from "./sample-content.js";
9
14
  export type { ShippedSampleContent } from "./sample-content.js";
15
+ export { MAX_SHIPPED_LOCALES, readShippedLocales } from "./shipped-locales.js";
10
16
  export type { PackageContractCheck } from "./package-contract.js";
11
17
  export { checkCoverContract, checkPackageContract, checkReadmeContract, COVER_HEIGHT, COVER_PATH, COVER_WIDTH, pngSize, } from "./package-contract.js";
12
18
  export type { DocsContractInput } from "./docs-contract.js";
13
19
  export { capViolations, checkDocsContract, countRemoteImages, docsFilesToShip, MAX_PACKAGE_JSON_BYTES, MAX_VIOLATIONS, packageFilePath, readDocsContractInput } from "./docs-contract.js";
20
+ export { VIEW_BEARING_CONTRIBUTIONS, declaresClientBundle } from "./client-bundle.js";
21
+ export { resolvePluginManifestEntry } from "./manifest-entry.js";
22
+ export * from "./delivery/index.js";
@@ -1,8 +1,15 @@
1
1
  export { VERIFY_FAILURE_REASONS } from "./types.js";
2
2
  export { canonicalizeEnvelope, deriveKeyId, generateSigningKeyPair, signEnvelope, verifyEnvelope, } from "./envelope.js";
3
- export { canonicalizeLicenseVerdict, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_VERDICT_DETAIL_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
3
+ export { canonicalizeLicenseVerdict, canonicalizeLicenseVerdictTerm, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_TERM_STATES, LICENSE_VERDICT_DETAIL_MAX, LICENSE_VERDICT_PLAN_ID_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, signLicenseVerdictWithTerm, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
4
+ // S320: the vendor token (spec 3a).
5
+ export { VENDOR_TOKEN_LEEWAY_SECONDS, VENDOR_TOKEN_SIGNING_PREFIX, signVendorToken, verifyVendorToken } from "./vendor-token.js";
4
6
  export { hashBuffer, hashArchive, hashDirectories } from "./hash.js";
5
- export { entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "./extract.js";
6
- export { SAMPLE_CONTENT_MAX_BYTES, readShippedInstallFacts, readShippedSampleContent } from "./sample-content.js";
7
+ export { createEntryGate, createPathKeyGate, decodeEntryName, ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES, normalizeEntryName, plannedEntryRefusal, } from "./extract.js";
8
+ export { EXCLUDED_NAMES, createShippedLookup, isExcludedSegment, walkShipped, whyNotShipped } from "./shipped-files.js";
9
+ export { SAMPLE_CONTENT_MAX_BYTES, hasSampleContentConsumer, installFactsOf, readShippedInstallFacts, readShippedSampleContent } from "./sample-content.js";
10
+ export { MAX_SHIPPED_LOCALES, readShippedLocales } from "./shipped-locales.js";
7
11
  export { checkCoverContract, checkPackageContract, checkReadmeContract, COVER_HEIGHT, COVER_PATH, COVER_WIDTH, pngSize, } from "./package-contract.js";
8
12
  export { capViolations, checkDocsContract, countRemoteImages, docsFilesToShip, MAX_PACKAGE_JSON_BYTES, MAX_VIOLATIONS, packageFilePath, readDocsContractInput } from "./docs-contract.js";
13
+ export { VIEW_BEARING_CONTRIBUTIONS, declaresClientBundle } from "./client-bundle.js";
14
+ export { resolvePluginManifestEntry } from "./manifest-entry.js";
15
+ export * from "./delivery/index.js";