@kardalum/plugin-sdk 0.0.0-stage → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/LICENSE +202 -0
  3. package/README.md +70 -2
  4. package/dist/admin-section-registry.d.ts +34 -0
  5. package/dist/admin-section-registry.js +49 -0
  6. package/dist/built-in-serializers.d.ts +3 -0
  7. package/dist/built-in-serializers.js +18 -0
  8. package/dist/built-in-settings-schemas.d.ts +14 -0
  9. package/dist/built-in-settings-schemas.js +225 -0
  10. package/dist/built-in-value-schemas.d.ts +4 -0
  11. package/dist/built-in-value-schemas.js +47 -0
  12. package/dist/built-ins.d.ts +1 -0
  13. package/dist/built-ins.js +257 -0
  14. package/dist/capabilities.d.ts +99 -0
  15. package/dist/capabilities.js +363 -0
  16. package/dist/data-type-plugin.d.ts +28 -0
  17. package/dist/data-type-plugin.js +1 -0
  18. package/dist/datatype-validation.d.ts +26 -0
  19. package/dist/datatype-validation.js +110 -0
  20. package/dist/datatypes-entry.d.ts +4 -0
  21. package/dist/datatypes-entry.js +18 -0
  22. package/dist/define-plugin.d.ts +25 -0
  23. package/dist/define-plugin.js +51 -0
  24. package/dist/entitlement-entry.d.ts +5 -0
  25. package/dist/entitlement-entry.js +24 -0
  26. package/dist/entitlement-gate.d.ts +36 -0
  27. package/dist/entitlement-gate.js +201 -0
  28. package/dist/entitlement-types.d.ts +39 -0
  29. package/dist/entitlement-types.js +1 -0
  30. package/dist/entitlement.d.ts +57 -0
  31. package/dist/entitlement.js +170 -0
  32. package/dist/host-entry.d.ts +1 -0
  33. package/dist/host-entry.js +11 -0
  34. package/dist/icon-name.d.ts +1 -0
  35. package/dist/icon-name.js +1 -0
  36. package/dist/icons.d.ts +2 -0
  37. package/dist/icons.js +10 -0
  38. package/dist/index.d.ts +28 -0
  39. package/dist/index.js +93 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +22 -0
  42. package/dist/local-host.d.ts +3 -0
  43. package/dist/local-host.js +38 -0
  44. package/dist/manifest-entry.d.ts +8 -0
  45. package/dist/manifest-entry.js +13 -0
  46. package/dist/manifest-schema.d.ts +408 -0
  47. package/dist/manifest-schema.js +774 -0
  48. package/dist/manifest.d.ts +546 -0
  49. package/dist/manifest.js +86 -0
  50. package/dist/media/media-picker.d.ts +39 -0
  51. package/dist/media/media-picker.js +438 -0
  52. package/dist/media/upload-error.d.ts +12 -0
  53. package/dist/media/upload-error.js +30 -0
  54. package/dist/plugin-context.d.ts +75 -0
  55. package/dist/plugin-context.js +70 -0
  56. package/dist/plugin-screen-context.d.ts +40 -0
  57. package/dist/plugin-screen-context.js +16 -0
  58. package/dist/register-built-ins.d.ts +1 -0
  59. package/dist/register-built-ins.js +41 -0
  60. package/dist/registry.d.ts +4 -0
  61. package/dist/registry.js +17 -0
  62. package/dist/rendition-eligibility.d.ts +24 -0
  63. package/dist/rendition-eligibility.js +40 -0
  64. package/dist/richtext/block-panel.d.ts +27 -0
  65. package/dist/richtext/block-panel.js +232 -0
  66. package/dist/richtext/extensions.d.ts +19 -0
  67. package/dist/richtext/extensions.js +56 -0
  68. package/dist/richtext/insert-menu.d.ts +24 -0
  69. package/dist/richtext/insert-menu.js +142 -0
  70. package/dist/richtext/kardalum-block.d.ts +33 -0
  71. package/dist/richtext/kardalum-block.js +282 -0
  72. package/dist/richtext/style-listbox.d.ts +10 -0
  73. package/dist/richtext/style-listbox.js +69 -0
  74. package/dist/richtext/text-style-class.d.ts +18 -0
  75. package/dist/richtext/text-style-class.js +36 -0
  76. package/dist/simple-storage-value-provider.d.ts +9 -0
  77. package/dist/simple-storage-value-provider.js +96 -0
  78. package/dist/structured-storage-types.d.ts +61 -0
  79. package/dist/structured-storage-types.js +11 -0
  80. package/dist/tailwind.d.ts +1 -0
  81. package/dist/tailwind.js +5 -0
  82. package/dist/tokens/system-dark.css +75 -0
  83. package/dist/tokens/tokens.css +239 -0
  84. package/dist/tokens/tokens.json +212 -0
  85. package/dist/tokens.d.ts +1 -0
  86. package/dist/tokens.js +11 -0
  87. package/dist/ui-entry.d.ts +5 -0
  88. package/dist/ui-entry.js +42 -0
  89. package/dist/views/content-list-preview.d.ts +1 -0
  90. package/dist/views/content-list-preview.js +14 -0
  91. package/dist/views/content-list-settings-view.d.ts +1 -0
  92. package/dist/views/content-list-settings-view.js +97 -0
  93. package/dist/views/content-list-view.d.ts +19 -0
  94. package/dist/views/content-list-view.js +248 -0
  95. package/dist/views/crop-view.d.ts +55 -0
  96. package/dist/views/crop-view.js +161 -0
  97. package/dist/views/date-range-view.d.ts +6 -0
  98. package/dist/views/date-range-view.js +55 -0
  99. package/dist/views/file-upload-view.d.ts +43 -0
  100. package/dist/views/file-upload-view.js +104 -0
  101. package/dist/views/html-code-editor.d.ts +10 -0
  102. package/dist/views/html-code-editor.js +101 -0
  103. package/dist/views/html-view.d.ts +3 -0
  104. package/dist/views/html-view.js +53 -0
  105. package/dist/views/image-view.d.ts +3 -0
  106. package/dist/views/image-view.js +387 -0
  107. package/dist/views/rich-text-view.d.ts +2 -0
  108. package/dist/views/rich-text-view.js +429 -0
  109. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  110. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  111. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  112. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  113. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +5 -0
  114. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -0
  117. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  118. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  121. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  122. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +537 -0
  124. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-path.js +256 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +151 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  137. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +302 -0
  138. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -0
  139. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  140. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  141. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +36 -0
  142. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +296 -0
  146. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  149. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  150. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  151. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  153. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +102 -0
  154. package/node_modules/@kardalum/api-schemas/dist/index.js +58 -0
  155. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  156. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  157. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +381 -0
  158. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
  159. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
  160. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -0
  161. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  162. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  171. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  172. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  173. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  174. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +169 -0
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +89 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +369 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  193. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +306 -0
  194. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -0
  195. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  196. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  197. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  198. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  199. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  200. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  201. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +90 -0
  202. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -0
  203. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  204. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  205. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +108 -0
  206. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -0
  207. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  208. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  209. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +43 -0
  210. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -0
  211. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  212. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  213. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  214. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  215. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  216. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  217. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  218. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  219. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +89 -0
  220. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -0
  221. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  222. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  223. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  224. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  225. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  226. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  227. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  228. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  229. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  230. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  231. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  232. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  233. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  234. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  235. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  236. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  237. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  238. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  239. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  240. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  241. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  242. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  243. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  244. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  247. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  248. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  249. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  250. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  251. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  252. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  253. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  254. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  255. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  256. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  257. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  258. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  259. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  260. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -0
  261. package/node_modules/@kardalum/plugin-package/dist/index.js +7 -0
  262. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  263. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  264. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  265. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  266. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +1 -0
  267. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
  268. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
  269. package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
  270. package/node_modules/@kardalum/plugin-package/package.json +49 -0
  271. package/node_modules/@kardalum/ui/LICENSE +202 -0
  272. package/node_modules/@kardalum/ui/README.md +35 -0
  273. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  274. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  275. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  276. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  277. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  278. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  279. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  280. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  281. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  282. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  283. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  284. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  285. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  286. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  287. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  288. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  289. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  290. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  291. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  292. package/node_modules/@kardalum/ui/dist/components/property-field.js +86 -0
  293. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  294. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  295. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  296. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  297. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  298. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  299. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  300. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  301. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  302. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  303. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  304. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  305. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  306. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  307. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  308. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  309. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  310. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  311. package/node_modules/@kardalum/ui/package.json +63 -0
  312. package/package.json +146 -4
@@ -0,0 +1,24 @@
1
+ // The `@kardalum/plugin-sdk/entitlement` subpath (S284b, design C3): the
2
+ // plugin's own licence check, for plugin SERVER code (API route handlers,
3
+ // hooks, scheduled tasks). It depends on @kardalum/plugin-package and so
4
+ // on node:crypto, which is why it is not on the package index: that index
5
+ // is federation-bundled into the admin for plugin views. Views use
6
+ // `useEntitlement` and `<EntitlementGate>` from the package index instead.
7
+ //
8
+ // Usage, at the top of every route, hook or task that is the paid value:
9
+ //
10
+ // await requireEntitlement(context.entitlement, {
11
+ // pluginId: "com.acme.reports",
12
+ // floor: structuredStorageFloor(context.structuredStorage),
13
+ // requestHost: request.hostname, // in a route; a hook has no request
14
+ // });
15
+ //
16
+ // It resolves to the verified envelope, or to null on a non-production
17
+ // install (`kind: "exempt"`), where nothing is checked; in a route, only
18
+ // when the request arrived on a local host (`isLocalHost`).
19
+ //
20
+ // The host turns a thrown EntitlementError into a 403 for a route and skips
21
+ // a hook that throws it.
22
+ export { EntitlementError, ENTITLEMENT_FLOOR_TABLE, isEntitlementError, requireEntitlement, structuredStorageFloor, } from "./entitlement.js";
23
+ export { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
24
+ export { isLocalHost } from "./local-host.js";
@@ -0,0 +1,36 @@
1
+ import { type JSX, type ReactNode } from "react";
2
+ import type { TrustedKey } from "@kardalum/plugin-package";
3
+ import type { EntitlementErrorCode, LicenseVerdictEnvelope } from "./entitlement-types.js";
4
+ export declare const BROWSER_ENTITLEMENT_MAX_AGE_MS: number;
5
+ export declare const BROWSER_MAX_VERDICT_AGE_MS: number;
6
+ export type EntitlementStatus = "loading" | "entitled" | "locked";
7
+ export interface UseEntitlementResult {
8
+ status: EntitlementStatus;
9
+ reason?: EntitlementErrorCode;
10
+ }
11
+ /** The exact bytes the marketplace signs, built the way
12
+ * @kardalum/plugin-package's `canonicalizeLicenseVerdict` builds them
13
+ * (explicit field order, `reason` null when absent, `tamper` and then
14
+ * `detail` appended only when present). A copy because that function returns a Node Buffer from a
15
+ * module that imports node:crypto; entitlement-gate.test.tsx pins this to
16
+ * its output for the same envelopes, so the two cannot drift silently. */
17
+ export declare function canonicalLicenseVerdictBytes(envelope: LicenseVerdictEnvelope): Uint8Array<ArrayBuffer>;
18
+ /** true or false when this browser could check the signature itself; null
19
+ * when it cannot import an Ed25519 key, and the host's answer stands in. */
20
+ export declare function verifyEntitlementInBrowser(entitlement: {
21
+ envelope: LicenseVerdictEnvelope;
22
+ signature: string;
23
+ }, trustedKeys: TrustedKey[]): Promise<boolean | null>;
24
+ /** `entitled` for `exempt` (a non-production install) on a page served from
25
+ * a local host, and `locked` with `missing` for `exempt` anywhere else and
26
+ * for `none` (no verdict held); a `verdict` is verified as above. A host answer the view cannot read at all (no session, an unknown
27
+ * plugin, the network, an unknown shape) is `locked` with `missing`: a gate
28
+ * that cannot tell does not open. A free plugin never uses the gate. */
29
+ export declare function useEntitlement(pluginId: string): UseEntitlementResult;
30
+ /** Renders `children` when the plugin is entitled (or exempt on a
31
+ * non-production install viewed from a local host), nothing while the answer is loading, and the
32
+ * SDK's locked notice when it is locked. */
33
+ export declare function EntitlementGate({ pluginId, children }: {
34
+ pluginId: string;
35
+ children: ReactNode;
36
+ }): JSX.Element;
@@ -0,0 +1,201 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The entitlement in an admin view (S284b, design 3.2 with correction C3).
3
+ // Browser entry: this file is federation-bundled with the package index, so
4
+ // it never imports node:crypto or @kardalum/plugin-package at runtime.
5
+ // Both imports below that name those types are `import type` and are erased.
6
+ //
7
+ // `useEntitlement` asks the host for the stored verdict through the same
8
+ // fetch every SDK call to the host uses (usePluginApi), verifies the
9
+ // signature itself with WebCrypto Ed25519 where the browser can import an
10
+ // Ed25519 key, and otherwise takes the host's own `valid` answer. It then
11
+ // applies the plugin id, status and 14-day checks. The host's answer is
12
+ // tagged like the server's (S284b fix wave): `exempt` (a non-production
13
+ // install) is entitled with no check when the page is served from a local
14
+ // host (C9) and locked with `missing` anywhere else, `none` (no verdict held) is locked
15
+ // with `missing`; a paid view therefore never opens just because a verdict
16
+ // is absent. There is no floor in the browser: the view gate is the visible
17
+ // half, the server route's `requireEntitlement` is the one that guards the
18
+ // work.
19
+ import { useEffect, useState } from "react";
20
+ import { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
21
+ import { isLocalHost } from "./local-host.js";
22
+ import { usePluginApi } from "./plugin-context.js";
23
+ // Copies of @kardalum/plugin-package's ENTITLEMENT_MAX_AGE_MS and
24
+ // MAX_VERDICT_AGE_MS, which cannot be imported here at runtime. Pinned to
25
+ // the originals by entitlement-gate.test.tsx.
26
+ export const BROWSER_ENTITLEMENT_MAX_AGE_MS = 14 * 24 * 60 * 60_000;
27
+ export const BROWSER_MAX_VERDICT_AGE_MS = 24 * 60 * 60_000;
28
+ /** The exact bytes the marketplace signs, built the way
29
+ * @kardalum/plugin-package's `canonicalizeLicenseVerdict` builds them
30
+ * (explicit field order, `reason` null when absent, `tamper` and then
31
+ * `detail` appended only when present). A copy because that function returns a Node Buffer from a
32
+ * module that imports node:crypto; entitlement-gate.test.tsx pins this to
33
+ * its output for the same envelopes, so the two cannot drift silently. */
34
+ export function canonicalLicenseVerdictBytes(envelope) {
35
+ return new TextEncoder().encode(JSON.stringify({
36
+ v: envelope.v,
37
+ alg: envelope.alg,
38
+ typ: envelope.typ,
39
+ keyId: envelope.keyId,
40
+ keyHash: envelope.keyHash,
41
+ pluginId: envelope.pluginId,
42
+ domain: envelope.domain,
43
+ nonce: envelope.nonce,
44
+ status: envelope.status,
45
+ reason: envelope.reason ?? null,
46
+ issuedAt: envelope.issuedAt,
47
+ ...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
48
+ ...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
49
+ }));
50
+ }
51
+ function base64ToBytes(value) {
52
+ const binary = atob(value);
53
+ const bytes = new Uint8Array(binary.length);
54
+ for (let i = 0; i < binary.length; i++)
55
+ bytes[i] = binary.charCodeAt(i);
56
+ return bytes;
57
+ }
58
+ function toHex(buffer) {
59
+ return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
60
+ }
61
+ function looksLikeVerdict(value) {
62
+ if (typeof value !== "object" || value === null)
63
+ return false;
64
+ const candidate = value;
65
+ if (typeof candidate.signature !== "string" || candidate.signature.length === 0)
66
+ return false;
67
+ const e = candidate.envelope;
68
+ return (typeof e === "object" &&
69
+ e !== null &&
70
+ e.v === 1 &&
71
+ e.alg === "ed25519" &&
72
+ e.typ === "license-verdict" &&
73
+ typeof e.keyId === "string" &&
74
+ typeof e.pluginId === "string" &&
75
+ typeof e.status === "string" &&
76
+ typeof e.issuedAt === "string");
77
+ }
78
+ const ED25519_SPKI_LENGTH = 44;
79
+ /** true or false when this browser could check the signature itself; null
80
+ * when it cannot import an Ed25519 key, and the host's answer stands in. */
81
+ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
82
+ const subtle = globalThis.crypto?.subtle;
83
+ if (!subtle)
84
+ return null;
85
+ try {
86
+ for (const trusted of trustedKeys) {
87
+ let der;
88
+ try {
89
+ der = base64ToBytes(trusted.publicKey);
90
+ }
91
+ catch {
92
+ continue;
93
+ }
94
+ if (der.length !== ED25519_SPKI_LENGTH)
95
+ continue;
96
+ // Re-derive the key id from the raw key, as the server does: the
97
+ // listed keyId is a label, the key is the fact.
98
+ const derivedId = toHex(await subtle.digest("SHA-256", der.slice(12))).slice(0, 16);
99
+ if (derivedId !== entitlement.envelope.keyId)
100
+ continue;
101
+ let key;
102
+ try {
103
+ key = await subtle.importKey("spki", der, { name: "Ed25519" }, false, ["verify"]);
104
+ }
105
+ catch {
106
+ return null;
107
+ }
108
+ let signature;
109
+ try {
110
+ signature = base64ToBytes(entitlement.signature);
111
+ }
112
+ catch {
113
+ return false;
114
+ }
115
+ return await subtle.verify({ name: "Ed25519" }, key, signature, canonicalLicenseVerdictBytes(entitlement.envelope));
116
+ }
117
+ return false;
118
+ }
119
+ catch {
120
+ return null;
121
+ }
122
+ }
123
+ /** The checks after the signature, in the server's order. */
124
+ function decide(entitlement, pluginId, now) {
125
+ const { envelope } = entitlement;
126
+ if (envelope.pluginId !== pluginId)
127
+ return { status: "locked", reason: "wrong-plugin" };
128
+ if (envelope.status !== "valid")
129
+ return { status: "locked", reason: "not-valid" };
130
+ const issuedMs = Date.parse(envelope.issuedAt);
131
+ const nowMs = now.getTime();
132
+ if (!Number.isFinite(issuedMs))
133
+ return { status: "locked", reason: "invalid-signature" };
134
+ if (nowMs - issuedMs > BROWSER_ENTITLEMENT_MAX_AGE_MS)
135
+ return { status: "locked", reason: "expired" };
136
+ if (issuedMs > nowMs + BROWSER_MAX_VERDICT_AGE_MS)
137
+ return { status: "locked", reason: "expired" };
138
+ return { status: "entitled" };
139
+ }
140
+ /** S284b, C9: the host hands `exempt` whenever its site domain is unset or
141
+ * local, which is one environment variable. The view takes it only when the
142
+ * page itself is served from a local host, so a public site cannot open a
143
+ * paid view by that setting alone. */
144
+ function pageIsLocal() {
145
+ return typeof location !== "undefined" && isLocalHost(location.hostname);
146
+ }
147
+ /** `entitled` for `exempt` (a non-production install) on a page served from
148
+ * a local host, and `locked` with `missing` for `exempt` anywhere else and
149
+ * for `none` (no verdict held); a `verdict` is verified as above. A host answer the view cannot read at all (no session, an unknown
150
+ * plugin, the network, an unknown shape) is `locked` with `missing`: a gate
151
+ * that cannot tell does not open. A free plugin never uses the gate. */
152
+ export function useEntitlement(pluginId) {
153
+ const fetchApi = usePluginApi();
154
+ const [result, setResult] = useState({ status: "loading" });
155
+ useEffect(() => {
156
+ let cancelled = false;
157
+ setResult({ status: "loading" });
158
+ (async () => {
159
+ const response = await fetchApi(`/api/plugin-management/entitlement/${encodeURIComponent(pluginId)}`);
160
+ if (!response.ok)
161
+ return { status: "locked", reason: "missing" };
162
+ const body = (await response.json());
163
+ const entitlement = body?.entitlement;
164
+ if (entitlement?.kind === "exempt") {
165
+ return pageIsLocal() ? { status: "entitled" } : { status: "locked", reason: "missing" };
166
+ }
167
+ if (entitlement?.kind !== "verdict")
168
+ return { status: "locked", reason: "missing" };
169
+ if (!looksLikeVerdict(entitlement))
170
+ return { status: "locked", reason: "invalid-signature" };
171
+ const own = await verifyEntitlementInBrowser(entitlement, LICENSE_VERDICT_PUBLIC_KEYS);
172
+ const authentic = own ?? body.valid === true;
173
+ if (!authentic)
174
+ return { status: "locked", reason: "invalid-signature" };
175
+ return decide(entitlement, pluginId, new Date());
176
+ })()
177
+ .catch(() => ({ status: "locked", reason: "missing" }))
178
+ .then((next) => {
179
+ if (!cancelled)
180
+ setResult(next);
181
+ });
182
+ return () => {
183
+ cancelled = true;
184
+ };
185
+ }, [fetchApi, pluginId]);
186
+ return result;
187
+ }
188
+ // Where the admin's installed-plugins screen lives in a production install
189
+ // (the admin is served under /kardalum/).
190
+ const PLUGINS_SCREEN_HREF = "/kardalum/plugin-management/installed";
191
+ /** Renders `children` when the plugin is entitled (or exempt on a
192
+ * non-production install viewed from a local host), nothing while the answer is loading, and the
193
+ * SDK's locked notice when it is locked. */
194
+ export function EntitlementGate({ pluginId, children }) {
195
+ const { status, reason } = useEntitlement(pluginId);
196
+ if (status === "loading")
197
+ return _jsx(_Fragment, {});
198
+ if (status === "entitled")
199
+ return _jsx(_Fragment, { children: children });
200
+ return (_jsxs("div", { role: "status", className: "flex flex-col gap-2 rounded-md border border-border-default p-4 text-text-primary", children: [_jsx("p", { className: "text-sm font-medium", children: "This plugin is locked" }), _jsxs("p", { className: "text-sm text-text-secondary", children: ["Plugin \"", pluginId, "\" is not entitled: ", reason ?? "missing"] }), _jsx("p", { className: "text-sm", children: _jsx("a", { href: PLUGINS_SCREEN_HREF, className: "text-text-primary underline", children: "Open Plugins" }) })] }));
201
+ }
@@ -0,0 +1,39 @@
1
+ import type { LicenseVerdictEnvelope } from "@kardalum/plugin-package";
2
+ import type { ScopedStructuredStorage } from "./structured-storage-types.js";
3
+ export type { LicenseVerdictEnvelope };
4
+ /** The host's latest authentic licence verdict for a plugin, exactly as the
5
+ * marketplace signed it, whatever its status: a revoked or invalid one makes
6
+ * `requireEntitlement` answer `not-valid`. */
7
+ export type EntitlementVerdict = {
8
+ kind: "verdict";
9
+ envelope: LicenseVerdictEnvelope;
10
+ signature: string;
11
+ };
12
+ /** What the host hands a plugin (S284b fix wave: a tagged value, so "no
13
+ * check needed here" and "no verdict" can never be read as each other).
14
+ * - `exempt`: a non-production install (no site domain, or a local one).
15
+ * No licence rule applies there, and `requireEntitlement` resolves
16
+ * without a check, so a paid plugin works on a development site; given a
17
+ * `requestHost` that is not local (a route serving a public host), it
18
+ * refuses with `missing` instead (C9), and `<EntitlementGate>` does the
19
+ * same for a page not served from a local host.
20
+ * - `none`: the host holds no verdict for this plugin (a free plugin, or a
21
+ * paid one whose verdict was never stored). `requireEntitlement` refuses
22
+ * with `missing`. A free plugin never calls it.
23
+ * - `verdict`: check it with `requireEntitlement`. */
24
+ export type Entitlement = {
25
+ kind: "exempt";
26
+ reason: "non-production";
27
+ } | EntitlementVerdict | {
28
+ kind: "none";
29
+ };
30
+ /** Why an entitlement was refused, in the order the checks run. */
31
+ export type EntitlementErrorCode = "missing" | "invalid-signature" | "wrong-plugin" | "not-valid" | "expired";
32
+ /** The context a scheduled task's `run` receives once a host runner exists
33
+ * (design C1). `structuredStorage` is there for a plugin that declares
34
+ * structured storage, so a task can keep the same floor
35
+ * (`structuredStorageFloor`) its routes and hooks keep. */
36
+ export type PluginTaskContext = {
37
+ entitlement: Entitlement;
38
+ structuredStorage?: ScopedStructuredStorage;
39
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ import { type LicenseVerdictEnvelope, type TrustedKey } from "@kardalum/plugin-package";
2
+ import type { Entitlement, EntitlementErrorCode } from "./entitlement-types.js";
3
+ import type { ScopedStructuredStorage } from "./structured-storage-types.js";
4
+ export declare class EntitlementError extends Error {
5
+ readonly code: EntitlementErrorCode;
6
+ readonly pluginId: string;
7
+ constructor(code: EntitlementErrorCode, pluginId: string);
8
+ }
9
+ /** True for an `EntitlementError` from ANY copy of this SDK. The host cannot
10
+ * use `instanceof`: a plugin bundles its own copy of the SDK into its server
11
+ * code, so the class it throws is never the host's class. The name and a
12
+ * known code are the contract instead. */
13
+ export declare function isEntitlementError(value: unknown): value is EntitlementError;
14
+ /** Where a plugin remembers the newest `issuedAt` it accepted, so a replayed
15
+ * older verdict, or a clock set back, does not pass a second time. */
16
+ export interface EntitlementFloor {
17
+ read(): Promise<string | null>;
18
+ write(issuedAt: string): Promise<void>;
19
+ }
20
+ export declare const ENTITLEMENT_FLOOR_TABLE = "kardalum_entitlement_floor";
21
+ /** The floor in the plugin's own structured storage: one table
22
+ * `kardalum_entitlement_floor` with one row `{ id: "floor", issued_at }`.
23
+ * The table is defined on first use; a table already defined (by an
24
+ * earlier process, or an earlier floor object) is fine. */
25
+ export declare function structuredStorageFloor(storage: ScopedStructuredStorage): EntitlementFloor;
26
+ export interface RequireEntitlementOptions {
27
+ pluginId: string;
28
+ now?: Date;
29
+ floor?: EntitlementFloor;
30
+ trustedKeys?: TrustedKey[];
31
+ /** The Host the request being served arrived on (a route passes
32
+ * `request.hostname`). With it, `exempt` is honoured only when that host
33
+ * is local (`isLocalHost`); a hook, which serves no request, leaves it
34
+ * out and `exempt` is honoured as handed. */
35
+ requestHost?: string;
36
+ }
37
+ /**
38
+ * Throws EntitlementError; resolves to the verified envelope, or to null for
39
+ * an `exempt` entitlement (a non-production install, where no licence rule
40
+ * applies, so nothing is checked and the floor is not touched).
41
+ *
42
+ * `exempt` with a `requestHost` that is not local is `missing` (S284b, C9):
43
+ * the host hands `exempt` whenever its own site domain is unset or local,
44
+ * which is one environment variable, so a route serving a public host does
45
+ * not take the host's word for it and refuses as if there were no verdict.
46
+ *
47
+ * `none`, null, undefined or an unknown shape are `missing`. A `verdict` is
48
+ * checked in order: invalid-signature (incl. unknown key, malformed),
49
+ * wrong-plugin, not-valid, expired (issuedAt older than 14 days from
50
+ * max(now, floor), or older than the floor). Writes the floor forward on
51
+ * success when given.
52
+ *
53
+ * A verdict dated more than a day after the effective now is `expired` too:
54
+ * it is a freshness failure, the same answer the host's own verifier gives
55
+ * a future-dated verdict.
56
+ */
57
+ export declare function requireEntitlement(entitlement: Entitlement | null | undefined, opts: RequireEntitlementOptions): Promise<LicenseVerdictEnvelope | null>;
@@ -0,0 +1,170 @@
1
+ // The plugin's own licence check (S284b, design 3.2 with corrections C2 and
2
+ // C3). Server only: it verifies the Ed25519 signature through
3
+ // @kardalum/plugin-package, which imports node:crypto, so it is reachable
4
+ // only through the `@kardalum/plugin-sdk/entitlement` subpath and never
5
+ // from the browser entry a federated view loads.
6
+ //
7
+ // The host hands a plugin its latest verdict unchanged
8
+ // (`context.entitlement`, tagged `verdict`), or tells it no check applies
9
+ // (`exempt`, a non-production install) or that it holds no verdict
10
+ // (`none`). This file is the second trust point: a paid
11
+ // plugin calls `requireEntitlement` at the top of the work that is its paid
12
+ // value, so an operator who flips the host's database still has to patch
13
+ // signed, watermarked plugin code to get that work for free.
14
+ import { ENTITLEMENT_MAX_AGE_MS, MAX_VERDICT_AGE_MS, verifyLicenseVerdictSignature, } from "@kardalum/plugin-package";
15
+ import { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
16
+ import { isLocalHost } from "./local-host.js";
17
+ const ERROR_CODES = ["missing", "invalid-signature", "wrong-plugin", "not-valid", "expired"];
18
+ export class EntitlementError extends Error {
19
+ code;
20
+ pluginId;
21
+ constructor(code, pluginId) {
22
+ super(`Plugin "${pluginId}" is not entitled: ${code}`);
23
+ this.name = "EntitlementError";
24
+ this.code = code;
25
+ this.pluginId = pluginId;
26
+ }
27
+ }
28
+ /** True for an `EntitlementError` from ANY copy of this SDK. The host cannot
29
+ * use `instanceof`: a plugin bundles its own copy of the SDK into its server
30
+ * code, so the class it throws is never the host's class. The name and a
31
+ * known code are the contract instead. */
32
+ export function isEntitlementError(value) {
33
+ if (typeof value !== "object" || value === null)
34
+ return false;
35
+ const candidate = value;
36
+ return (candidate.name === "EntitlementError" &&
37
+ typeof candidate.code === "string" &&
38
+ ERROR_CODES.includes(candidate.code));
39
+ }
40
+ export const ENTITLEMENT_FLOOR_TABLE = "kardalum_entitlement_floor";
41
+ const FLOOR_ROW_ID = "floor";
42
+ /** The floor in the plugin's own structured storage: one table
43
+ * `kardalum_entitlement_floor` with one row `{ id: "floor", issued_at }`.
44
+ * The table is defined on first use; a table already defined (by an
45
+ * earlier process, or an earlier floor object) is fine. */
46
+ export function structuredStorageFloor(storage) {
47
+ let ready = null;
48
+ function ensureTable() {
49
+ if (!ready) {
50
+ ready = storage
51
+ .defineTable({
52
+ tableName: ENTITLEMENT_FLOOR_TABLE,
53
+ columns: [
54
+ { name: "id", type: "text", primaryKey: true },
55
+ { name: "issued_at", type: "text", notNull: true },
56
+ ],
57
+ })
58
+ .catch((err) => {
59
+ // The host's error for a table that exists; matched by name for
60
+ // the same reason as isEntitlementError: no shared class.
61
+ if (err instanceof Error && err.name === "PluginTableAlreadyDefinedError")
62
+ return;
63
+ ready = null;
64
+ throw err;
65
+ });
66
+ }
67
+ return ready;
68
+ }
69
+ async function readRow() {
70
+ const rows = await storage.query(ENTITLEMENT_FLOOR_TABLE).where({ id: FLOOR_ROW_ID });
71
+ const row = rows[0];
72
+ return row && typeof row.issued_at === "string" ? row.issued_at : null;
73
+ }
74
+ return {
75
+ async read() {
76
+ await ensureTable();
77
+ return readRow();
78
+ },
79
+ async write(issuedAt) {
80
+ await ensureTable();
81
+ let current = await readRow();
82
+ if (current === null) {
83
+ try {
84
+ await storage.insert(ENTITLEMENT_FLOOR_TABLE, { id: FLOOR_ROW_ID, issued_at: issuedAt });
85
+ return;
86
+ }
87
+ catch (err) {
88
+ // Two first requests racing each other both read no row and both
89
+ // insert; the loser's primary-key error must not turn a valid
90
+ // entitlement into a 500 (S284b fix wave, M3). Read what the
91
+ // winner wrote and fall through to the forward-only update; an
92
+ // error with no row behind it is a real failure and is thrown.
93
+ current = await readRow();
94
+ if (current === null)
95
+ throw err;
96
+ }
97
+ }
98
+ // Forward only, even if a caller hands an older value.
99
+ const currentMs = Date.parse(current);
100
+ if (Number.isFinite(currentMs) && currentMs >= Date.parse(issuedAt))
101
+ return;
102
+ await storage.update(ENTITLEMENT_FLOOR_TABLE, { id: FLOOR_ROW_ID }, { issued_at: issuedAt });
103
+ },
104
+ };
105
+ }
106
+ // The latest instant a Date can hold. Handed to the signature check as its
107
+ // `now` with an unlimited age so that it decides authenticity alone: the
108
+ // freshness checks run last, after the plugin id and status, in the order
109
+ // the error codes are documented.
110
+ const END_OF_TIME = new Date(8.64e15);
111
+ /**
112
+ * Throws EntitlementError; resolves to the verified envelope, or to null for
113
+ * an `exempt` entitlement (a non-production install, where no licence rule
114
+ * applies, so nothing is checked and the floor is not touched).
115
+ *
116
+ * `exempt` with a `requestHost` that is not local is `missing` (S284b, C9):
117
+ * the host hands `exempt` whenever its own site domain is unset or local,
118
+ * which is one environment variable, so a route serving a public host does
119
+ * not take the host's word for it and refuses as if there were no verdict.
120
+ *
121
+ * `none`, null, undefined or an unknown shape are `missing`. A `verdict` is
122
+ * checked in order: invalid-signature (incl. unknown key, malformed),
123
+ * wrong-plugin, not-valid, expired (issuedAt older than 14 days from
124
+ * max(now, floor), or older than the floor). Writes the floor forward on
125
+ * success when given.
126
+ *
127
+ * A verdict dated more than a day after the effective now is `expired` too:
128
+ * it is a freshness failure, the same answer the host's own verifier gives
129
+ * a future-dated verdict.
130
+ */
131
+ export async function requireEntitlement(entitlement, opts) {
132
+ const { pluginId } = opts;
133
+ if (entitlement === null || entitlement === undefined || typeof entitlement !== "object") {
134
+ throw new EntitlementError("missing", pluginId);
135
+ }
136
+ if (entitlement.kind === "exempt") {
137
+ if (opts.requestHost !== undefined && !isLocalHost(opts.requestHost)) {
138
+ throw new EntitlementError("missing", pluginId);
139
+ }
140
+ return null;
141
+ }
142
+ if (entitlement.kind !== "verdict")
143
+ throw new EntitlementError("missing", pluginId);
144
+ const checked = verifyLicenseVerdictSignature(entitlement, opts.trustedKeys ?? LICENSE_VERDICT_PUBLIC_KEYS, {
145
+ now: END_OF_TIME,
146
+ maxAgeMs: Number.POSITIVE_INFINITY,
147
+ });
148
+ if (!checked.ok)
149
+ throw new EntitlementError("invalid-signature", pluginId);
150
+ const envelope = checked.envelope;
151
+ if (envelope.pluginId !== pluginId)
152
+ throw new EntitlementError("wrong-plugin", pluginId);
153
+ if (envelope.status !== "valid")
154
+ throw new EntitlementError("not-valid", pluginId);
155
+ const issuedMs = Date.parse(envelope.issuedAt);
156
+ const floorValue = opts.floor ? await opts.floor.read() : null;
157
+ const floorMs = floorValue === null ? Number.NaN : Date.parse(floorValue);
158
+ const clockMs = (opts.now ?? new Date()).getTime();
159
+ const effectiveNowMs = Number.isFinite(floorMs) ? Math.max(clockMs, floorMs) : clockMs;
160
+ if (Number.isFinite(floorMs) && issuedMs < floorMs)
161
+ throw new EntitlementError("expired", pluginId);
162
+ if (effectiveNowMs - issuedMs > ENTITLEMENT_MAX_AGE_MS)
163
+ throw new EntitlementError("expired", pluginId);
164
+ if (issuedMs > effectiveNowMs + MAX_VERDICT_AGE_MS)
165
+ throw new EntitlementError("expired", pluginId);
166
+ if (opts.floor && (!Number.isFinite(floorMs) || issuedMs > floorMs)) {
167
+ await opts.floor.write(envelope.issuedAt);
168
+ }
169
+ return envelope;
170
+ }
@@ -0,0 +1 @@
1
+ export { registerPluginSlots, getPluginSection, listPluginSections, listRailEntries, getRailEntry, resetPluginSlotsForTests, type RegisteredSection, type RegisteredRailEntry, } from "./admin-section-registry.js";
@@ -0,0 +1,11 @@
1
+ // The `@kardalum/plugin-sdk/host` subpath: what the admin (the host) uses
2
+ // to register and look up plugin slots. Host-only, and deliberately not on
3
+ // the package index a plugin imports from: a plugin declares its slots in
4
+ // its manifest and the host registers them under the id the plugin was
5
+ // installed as. A plugin that could call these could register slots under
6
+ // another plugin's id before that plugin boots, and nothing about
7
+ // registering belongs in the contract a plugin is written against.
8
+ //
9
+ // Not a stable public API: everything here is @internal and may change in
10
+ // any release without notice.
11
+ export { registerPluginSlots, getPluginSection, listPluginSections, listRailEntries, getRailEntry, resetPluginSlotsForTests, } from "./admin-section-registry.js";
@@ -0,0 +1 @@
1
+ export type { IconName } from "./icons.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "lucide-react";
2
+ export type { IconName } from "lucide-react/dynamic.js";
package/dist/icons.js ADDED
@@ -0,0 +1,10 @@
1
+ // The `@kardalum/plugin-sdk/icons` subpath: the Lucide icon components the
2
+ // admin draws with, plus `IconName`, the valid values for a manifest's
3
+ // `icon` field. A plugin's UI imports its icons from here so it draws from
4
+ // the same set at the same version as the host.
5
+ //
6
+ // Not a federation share key (only the SDK root is shared), and not on the
7
+ // package index: the index stays free of the icon set's weight, because the
8
+ // CLI enforces a bundle-size budget on plugins and a bundler only drops the
9
+ // icons a plugin does not use when it imports them from here by name.
10
+ export * from "lucide-react";
@@ -0,0 +1,28 @@
1
+ export type { DataTypePlugin, DataTypePluginViews } from "./data-type-plugin.js";
2
+ export type { IconName } from "./icon-name.js";
3
+ export type { DataTypeIssue, DataTypeValidateContext, DataTypeValidateHook, DataTypeValidatorEntry, DataTypeValidatorLookup, } from "./datatype-validation.js";
4
+ export type { PluginType, DatabaseDialect, DatabaseCompatibility, PluginAssertion, PluginAssertions, PluginMigrationContext, PluginMigration, PluginMigrationValidation, PluginMigrationHooks, HookEvent, HookHandler, PluginHooks, ContentLifecycleHookPayload, PluginHookContext, AdminSectionContribution, BuiltInRailEntryContribution, BuiltInRailSection, RailEntryContribution, SlotLabel, DashboardWidgetContribution, ApiRouteContribution, ScheduledTaskContribution, MediaProcessorContribution, SettingsPageContribution, ContentTreeActionContribution, EditorToolbarContribution, ExposedServiceContribution, BundledTemplateContribution, SerializerContext, CustomFormatContribution, SerializerContribution, PluginContributions, PluginManifestBase, PluginManifest, } from "./manifest.js";
5
+ export { slotLabel } from "./manifest.js";
6
+ export { CAPABILITY_IDS, CAPABILITY_LABELS, capabilityLabel, deriveCapabilities, isActionGated, type Capability, type CapabilityAudience, type CapabilityLabels, type CapabilityMediation, type CapabilityPayload, } from "./capabilities.js";
7
+ export { BUILT_IN_RAIL_SECTIONS, CMSPluginSchema, DataTypePluginSchema, validatePluginManifest, type ValidatePluginManifestResult, } from "./manifest-schema.js";
8
+ export { definePlugin, PluginDefinitionError } from "./define-plugin.js";
9
+ export { registerDataType, getDataType, listDataTypes } from "./registry.js";
10
+ export { PluginValueProvider, PluginSettingsProvider, PluginApiProvider, ContentHostProvider, usePluginValue, usePluginSettings, usePluginSettingsValue, usePluginApi, useContentHost, type PluginFetch, type ContentHost, type ContentHostPage, type ContentHostDocumentType, } from "./plugin-context.js";
11
+ export { PluginScreenProvider, usePluginScreen, type PluginScreenContext, } from "./plugin-screen-context.js";
12
+ export { SimpleStorageValueProvider } from "./simple-storage-value-provider.js";
13
+ export { EntitlementGate, useEntitlement, type EntitlementStatus, type UseEntitlementResult, } from "./entitlement-gate.js";
14
+ export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, PluginTaskContext } from "./entitlement-types.js";
15
+ export { buildRichtextExtensions, TextStyleClass, KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, type BuildRichtextExtensionsOptions, type RichtextTextStyle, type TextStyleClassAttributes, type KardalumBlockAttributes, type KardalumBlockLocation, type SelectedKardalumBlock, } from "./richtext/extensions.js";
16
+ export { MediaPicker, type MediaPickerItem, type MediaPickerProps } from "./media/media-picker.js";
17
+ export { MediaFileProvider, useMediaFile, useMediaFileReplace, type CurrentMediaFile, type MediaFileProviderProps, type MediaFileReplace, } from "./views/file-upload-view.js";
18
+ export { MediaRenditionProvider, useMediaRendition, isRenditionIneligible, RENDITION_INELIGIBLE_TYPES, type MediaRenditionCut, type MediaRenditionHost, type MediaRenditionProviderProps, } from "./views/crop-view.js";
19
+ export { StyleListbox, type StyleListboxProps } from "./richtext/style-listbox.js";
20
+ export { BlockInsertMenu, defaultBlockParams, useBlockListings, type BlockInsertMenuProps, type BlockListing, type BlockParamSpec, type BlockParamType, type UseBlockListingsResult, } from "./richtext/insert-menu.js";
21
+ export { BlockPanel, BlockPreviewPopover, BlockParamFields, type BlockPanelProps, type BlockPreviewPopoverProps, type BlockParamFieldsProps, } from "./richtext/block-panel.js";
22
+ export { Panel, type PanelProps } from "@kardalum/ui";
23
+ export { PropertyField, usePropertyFieldControl, type PropertyFieldProps, type PropertyFieldControlProps, } from "@kardalum/ui";
24
+ export { Input, type InputProps } from "@kardalum/ui";
25
+ export { Button, type ButtonProps } from "@kardalum/ui";
26
+ export { Switch, type SwitchProps } from "@kardalum/ui";
27
+ export { Badge, type BadgeProps } from "@kardalum/ui";
28
+ export { cn } from "@kardalum/ui";