@kardalum/plugin-sdk 0.0.0-stage → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +118 -0
- package/LICENSE +202 -0
- package/README.md +80 -2
- package/dist/admin-section-registry.d.ts +34 -0
- package/dist/admin-section-registry.js +49 -0
- package/dist/built-in-serializers.d.ts +3 -0
- package/dist/built-in-serializers.js +18 -0
- package/dist/built-in-settings-schemas.d.ts +14 -0
- package/dist/built-in-settings-schemas.js +225 -0
- package/dist/built-in-value-schemas.d.ts +4 -0
- package/dist/built-in-value-schemas.js +47 -0
- package/dist/built-ins.d.ts +1 -0
- package/dist/built-ins.js +257 -0
- package/dist/capabilities.d.ts +29 -0
- package/dist/capabilities.js +67 -0
- package/dist/data-type-plugin.d.ts +28 -0
- package/dist/data-type-plugin.js +1 -0
- package/dist/datatype-validation.d.ts +26 -0
- package/dist/datatype-validation.js +110 -0
- package/dist/datatypes-entry.d.ts +4 -0
- package/dist/datatypes-entry.js +18 -0
- package/dist/define-plugin.d.ts +25 -0
- package/dist/define-plugin.js +51 -0
- package/dist/entitlement-entry.d.ts +5 -0
- package/dist/entitlement-entry.js +24 -0
- package/dist/entitlement-gate.d.ts +36 -0
- package/dist/entitlement-gate.js +201 -0
- package/dist/entitlement-types.d.ts +39 -0
- package/dist/entitlement-types.js +1 -0
- package/dist/entitlement.d.ts +57 -0
- package/dist/entitlement.js +170 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +11 -0
- package/dist/icon-name.d.ts +1 -0
- package/dist/icon-name.js +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +94 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +26 -0
- package/dist/local-host.d.ts +3 -0
- package/dist/local-host.js +38 -0
- package/dist/manifest-entry.d.ts +8 -0
- package/dist/manifest-entry.js +13 -0
- package/dist/manifest-schema.d.ts +476 -0
- package/dist/manifest-schema.js +823 -0
- package/dist/manifest.d.ts +611 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +447 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +82 -0
- package/dist/plugin-context.js +77 -0
- package/dist/plugin-screen-context.d.ts +71 -0
- package/dist/plugin-screen-context.js +41 -0
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/register-built-ins.d.ts +1 -0
- package/dist/register-built-ins.js +41 -0
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +17 -0
- package/dist/rendition-eligibility.d.ts +24 -0
- package/dist/rendition-eligibility.js +40 -0
- package/dist/richtext/block-panel.d.ts +27 -0
- package/dist/richtext/block-panel.js +232 -0
- package/dist/richtext/extensions.d.ts +19 -0
- package/dist/richtext/extensions.js +56 -0
- package/dist/richtext/insert-menu.d.ts +24 -0
- package/dist/richtext/insert-menu.js +142 -0
- package/dist/richtext/kardalum-block.d.ts +33 -0
- package/dist/richtext/kardalum-block.js +282 -0
- package/dist/richtext/style-listbox.d.ts +10 -0
- package/dist/richtext/style-listbox.js +69 -0
- package/dist/richtext/text-style-class.d.ts +18 -0
- package/dist/richtext/text-style-class.js +36 -0
- package/dist/simple-storage-value-provider.d.ts +9 -0
- package/dist/simple-storage-value-provider.js +96 -0
- package/dist/structured-storage-types.d.ts +61 -0
- package/dist/structured-storage-types.js +11 -0
- package/dist/tailwind.d.ts +1 -0
- package/dist/tailwind.js +5 -0
- package/dist/tokens/system-dark.css +75 -0
- package/dist/tokens/tokens.css +239 -0
- package/dist/tokens/tokens.json +212 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +11 -0
- package/dist/ui-entry.d.ts +5 -0
- package/dist/ui-entry.js +42 -0
- package/dist/views/content-list-preview.d.ts +1 -0
- package/dist/views/content-list-preview.js +14 -0
- package/dist/views/content-list-settings-view.d.ts +1 -0
- package/dist/views/content-list-settings-view.js +97 -0
- package/dist/views/content-list-view.d.ts +19 -0
- package/dist/views/content-list-view.js +248 -0
- package/dist/views/crop-view.d.ts +55 -0
- package/dist/views/crop-view.js +161 -0
- package/dist/views/date-range-view.d.ts +6 -0
- package/dist/views/date-range-view.js +55 -0
- package/dist/views/file-upload-view.d.ts +43 -0
- package/dist/views/file-upload-view.js +104 -0
- package/dist/views/html-code-editor.d.ts +10 -0
- package/dist/views/html-code-editor.js +101 -0
- package/dist/views/html-view.d.ts +3 -0
- package/dist/views/html-view.js +53 -0
- package/dist/views/image-view.d.ts +3 -0
- package/dist/views/image-view.js +372 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +429 -0
- package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
- package/node_modules/@kardalum/api-schemas/README.md +56 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/package.json +35 -0
- package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
- package/node_modules/@kardalum/design-tokens/README.md +29 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
- package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
- package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
- package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
- package/node_modules/@kardalum/design-tokens/package.json +42 -0
- package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
- package/node_modules/@kardalum/plugin-package/README.md +71 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
- package/node_modules/@kardalum/plugin-package/package.json +54 -0
- package/node_modules/@kardalum/ui/LICENSE +202 -0
- package/node_modules/@kardalum/ui/README.md +35 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
- package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
- package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
- package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
- package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/index.js +18 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
- package/node_modules/@kardalum/ui/package.json +63 -0
- package/package.json +146 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { JSONSchema7 } from "json-schema";
|
|
3
|
+
import type { DataTypeValidateHook } from "./datatype-validation.js";
|
|
4
|
+
export interface DataTypePluginViews {
|
|
5
|
+
input: ComponentType;
|
|
6
|
+
readOnly: ComponentType;
|
|
7
|
+
settings: ComponentType;
|
|
8
|
+
preview?: ComponentType;
|
|
9
|
+
}
|
|
10
|
+
export interface DataTypePlugin {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
icon: string;
|
|
14
|
+
version: string;
|
|
15
|
+
type: "datatype";
|
|
16
|
+
schema: JSONSchema7;
|
|
17
|
+
settingsSchema: JSONSchema7;
|
|
18
|
+
defaultSettings: Record<string, unknown>;
|
|
19
|
+
views: DataTypePluginViews;
|
|
20
|
+
serialize: (value: unknown, settings: Record<string, unknown>) => unknown;
|
|
21
|
+
deserialize: (raw: unknown, settings: Record<string, unknown>) => unknown;
|
|
22
|
+
/** Datatype-intrinsic validation (S198). Pure, synchronous, runtime-only
|
|
23
|
+
* — never serialized into manifest.json (same as PluginHooks). */
|
|
24
|
+
validate?: DataTypeValidateHook;
|
|
25
|
+
/** Optional emptiness predicate for composite values, consulted by the
|
|
26
|
+
* `required` rule so a webmaster never needs to know the value shape. */
|
|
27
|
+
isEmpty?: (value: unknown) => boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type DataTypeIssue = {
|
|
2
|
+
key: string;
|
|
3
|
+
params?: Record<string, unknown>;
|
|
4
|
+
path?: string;
|
|
5
|
+
} | {
|
|
6
|
+
message: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface DataTypeValidateContext {
|
|
10
|
+
settings: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export type DataTypeValidateHook = (value: unknown, ctx: DataTypeValidateContext) => DataTypeIssue[] | undefined;
|
|
13
|
+
export interface DataTypeValidatorEntry {
|
|
14
|
+
/**
|
|
15
|
+
* The datatype's own `defaultSettings`. A DataTypeConfig stores `{}`
|
|
16
|
+
* until a webmaster opens the settings view and changes something, and
|
|
17
|
+
* the admin's resolver already substitutes these defaults in that case
|
|
18
|
+
* — so the hook has to see them too, or it judges a value against
|
|
19
|
+
* different settings than the input view was configured with.
|
|
20
|
+
*/
|
|
21
|
+
defaultSettings?: Record<string, unknown>;
|
|
22
|
+
validate?: DataTypeValidateHook;
|
|
23
|
+
isEmpty?: (value: unknown) => boolean;
|
|
24
|
+
}
|
|
25
|
+
export type DataTypeValidatorLookup = (datatypeId: string) => DataTypeValidatorEntry | undefined;
|
|
26
|
+
export declare const BUILT_IN_DATATYPE_VALIDATORS: Record<string, DataTypeValidatorEntry>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// The datatype validate hook (S198 spec §2). Deliberately React-free and
|
|
2
|
+
// dependency-free: the SERVER imports this module to build its validator
|
|
3
|
+
// lookup, and anything React-shaped here would drag the admin's UI graph
|
|
4
|
+
// into plugin artifacts (the S197 F5 lesson).
|
|
5
|
+
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
6
|
+
// A member reads as its string, as null (absent), or as MALFORMED when it
|
|
7
|
+
// is present but not a string at all. Keeping the two failure modes apart
|
|
8
|
+
// per side is what lets `validate` blame the side actually at fault: a
|
|
9
|
+
// whole-value collapse would report `{ start: "2026-01-01", end: 123 }`
|
|
10
|
+
// against `start`, pointing the form at the input the editor got right.
|
|
11
|
+
const MALFORMED = Symbol("malformed-date-range-member");
|
|
12
|
+
function readDateRange(value) {
|
|
13
|
+
if (typeof value !== "object" || value === null)
|
|
14
|
+
return null;
|
|
15
|
+
const candidate = value;
|
|
16
|
+
const read = (key) => {
|
|
17
|
+
const raw = candidate[key];
|
|
18
|
+
if (raw === null || raw === undefined || raw === "")
|
|
19
|
+
return null;
|
|
20
|
+
return typeof raw === "string" ? raw : MALFORMED;
|
|
21
|
+
};
|
|
22
|
+
return { start: read("start"), end: read("end") };
|
|
23
|
+
}
|
|
24
|
+
function isValidIsoDate(value) {
|
|
25
|
+
if (!ISO_DATE.test(value))
|
|
26
|
+
return false;
|
|
27
|
+
const parsed = new Date(`${value}T00:00:00Z`);
|
|
28
|
+
// Rejects real-looking but impossible dates (2026-02-31 rolls over).
|
|
29
|
+
return !Number.isNaN(parsed.getTime()) && parsed.toISOString().slice(0, 10) === value;
|
|
30
|
+
}
|
|
31
|
+
// Populated by Task 3 (date range). A plain record so the server can build
|
|
32
|
+
// its lookup with a single object read.
|
|
33
|
+
export const BUILT_IN_DATATYPE_VALIDATORS = {
|
|
34
|
+
"com.kardalum.daterange": {
|
|
35
|
+
// `required` asks this, not `validate` — Task 2 only calls `validate`
|
|
36
|
+
// once a value is present, so "empty" for a two-member composite has
|
|
37
|
+
// to be answered here: both members null (or a value that is not an
|
|
38
|
+
// object at all) is empty. A member that is present but malformed is
|
|
39
|
+
// NOT empty — it is a value the editor supplied and got wrong, so it
|
|
40
|
+
// must reach `validate` rather than be reported as a missing field.
|
|
41
|
+
isEmpty(value) {
|
|
42
|
+
const range = readDateRange(value);
|
|
43
|
+
return range === null || (range.start === null && range.end === null);
|
|
44
|
+
},
|
|
45
|
+
validate(value) {
|
|
46
|
+
const range = readDateRange(value);
|
|
47
|
+
if (range === null)
|
|
48
|
+
return [{ key: "dataTypes.dateRange.errors.invalidDate", path: "start" }];
|
|
49
|
+
const issues = [];
|
|
50
|
+
for (const side of ["start", "end"]) {
|
|
51
|
+
const member = range[side];
|
|
52
|
+
if (member === MALFORMED || (member !== null && !isValidIsoDate(member))) {
|
|
53
|
+
issues.push({ key: "dataTypes.dateRange.errors.invalidDate", path: side });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (issues.length > 0)
|
|
57
|
+
return issues;
|
|
58
|
+
const { start, end } = range;
|
|
59
|
+
if (start !== null && end === null) {
|
|
60
|
+
return [{ key: "dataTypes.dateRange.errors.bothOrNeither", path: "end" }];
|
|
61
|
+
}
|
|
62
|
+
if (start === null && end !== null) {
|
|
63
|
+
return [{ key: "dataTypes.dateRange.errors.bothOrNeither", path: "start" }];
|
|
64
|
+
}
|
|
65
|
+
// ISO YYYY-MM-DD strings compare lexicographically as dates.
|
|
66
|
+
if (start !== null && end !== null && end < start) {
|
|
67
|
+
return [{ key: "dataTypes.dateRange.errors.endBeforeStart", path: "end" }];
|
|
68
|
+
}
|
|
69
|
+
return [];
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
// S232. The Content List field holds no value: its table reads the
|
|
73
|
+
// page's children, which live in their own content rows. So it is
|
|
74
|
+
// always empty, and it never validates anything. Marking such a field
|
|
75
|
+
// `required` is a misconfiguration, and this is what makes that visible
|
|
76
|
+
// rather than letting the rule silently pass on a value that can never
|
|
77
|
+
// be filled in.
|
|
78
|
+
"com.kardalum.contentlist": {
|
|
79
|
+
isEmpty: () => true,
|
|
80
|
+
},
|
|
81
|
+
// S234a Task 4c item 3. The file upload field holds no value either: the
|
|
82
|
+
// bytes, filename and size live on the media row, never in `data`. So it
|
|
83
|
+
// is always empty, and it never validates anything. Marking such a field
|
|
84
|
+
// `required` is a misconfiguration, and this is what makes that visible
|
|
85
|
+
// rather than letting the rule silently pass on a value that can never
|
|
86
|
+
// be filled in.
|
|
87
|
+
"com.kardalum.fileupload": {
|
|
88
|
+
isEmpty: () => true,
|
|
89
|
+
},
|
|
90
|
+
// S234c Task 4. A crop field is the opposite case: it DOES hold a value,
|
|
91
|
+
// the rectangle it last cut as fractions of the source, so "empty" is a
|
|
92
|
+
// real question rather than a constant. It means "never cut", which is
|
|
93
|
+
// what lets a webmaster mark a crop `required` and have that mean "this
|
|
94
|
+
// crop must be cut" without knowing the value's internal shape.
|
|
95
|
+
//
|
|
96
|
+
// Only absence counts as empty. A value that is an object but not a
|
|
97
|
+
// rectangle is something a caller wrote and got wrong, and reporting
|
|
98
|
+
// that as a missing field would point the editor at the wrong problem:
|
|
99
|
+
// the same rule com.kardalum.daterange follows above.
|
|
100
|
+
"com.kardalum.crop": {
|
|
101
|
+
isEmpty: (value) => typeof value !== "object" || value === null,
|
|
102
|
+
},
|
|
103
|
+
// A thumbnail holds no value at all: it is automatic, cut whenever bytes
|
|
104
|
+
// arrive, and the rendition row is the record of it. So it is always
|
|
105
|
+
// empty, the same reasoning (and the same misconfiguration warning) as
|
|
106
|
+
// com.kardalum.fileupload above.
|
|
107
|
+
"com.kardalum.thumbnail": {
|
|
108
|
+
isEmpty: () => true,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BUILT_IN_SETTINGS_SCHEMAS } from "./built-in-settings-schemas.js";
|
|
2
|
+
export { BUILT_IN_VALUE_SCHEMAS } from "./built-in-value-schemas.js";
|
|
3
|
+
export { BUILT_IN_SERIALIZERS, identitySerializer, type DataTypeSerializer, } from "./built-in-serializers.js";
|
|
4
|
+
export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "./rendition-eligibility.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// The `@kardalum/plugin-sdk/datatypes` subpath: server-safe DATA and
|
|
2
|
+
// pure predicates about built-in editors only. No React, no side-effect
|
|
3
|
+
// registration, same "no browser weight in the server process" boundary as
|
|
4
|
+
// ./manifest (Session 60). Exists so apps/server's Data Type routes can
|
|
5
|
+
// validate config.settings against a built-in editor's settingsSchema
|
|
6
|
+
// without importing built-ins.tsx (React/@kardalum/ui). Third-party and
|
|
7
|
+
// remote plugin settingsSchemas are NOT coverable here: Module Federation
|
|
8
|
+
// remotes only ever load in the browser, so the server has no way to see
|
|
9
|
+
// one.
|
|
10
|
+
export { BUILT_IN_SETTINGS_SCHEMAS } from "./built-in-settings-schemas.js";
|
|
11
|
+
export { BUILT_IN_VALUE_SCHEMAS } from "./built-in-value-schemas.js";
|
|
12
|
+
export { BUILT_IN_SERIALIZERS, identitySerializer, } from "./built-in-serializers.js";
|
|
13
|
+
// S234c fix wave: the "no GIF, no SVG" rule, read by the cut route so a
|
|
14
|
+
// signed-in caller cannot post a "crop" of a format the browser refuses to
|
|
15
|
+
// offer one for. The set is declared once (rendition-eligibility.ts) and
|
|
16
|
+
// the crop view re-exports the same module, so the tile and the route can
|
|
17
|
+
// never disagree about which formats are cuttable.
|
|
18
|
+
export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "./rendition-eligibility.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataTypePlugin } from "./data-type-plugin.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a plugin definition fails validation — catchable by the
|
|
4
|
+
* registry's install() (Session 62) and `kardalum plugin validate`
|
|
5
|
+
* (Month 7), which want to report rather than crash.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PluginDefinitionError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validate a datatype plugin definition and hand it back. This is the
|
|
12
|
+
* one code path into the registry: built-ins construct their plugin
|
|
13
|
+
* objects through it (see built-ins.tsx), and external plugins do the
|
|
14
|
+
* same — so a missing required view fails LOUDLY at definition time,
|
|
15
|
+
* never silently at render time (plugin-sdk.md).
|
|
16
|
+
*
|
|
17
|
+
* Deliberately does NOT register: Module Federation remotes (Session 66)
|
|
18
|
+
* export the defined plugin object, and the HOST decides when it enters
|
|
19
|
+
* the registry (install/activate lifecycle) — a define-time side effect
|
|
20
|
+
* would take that control away. Pass the result to registerDataType.
|
|
21
|
+
*
|
|
22
|
+
* Returns the ORIGINAL object (not a parsed clone) — a plugin carries
|
|
23
|
+
* React components and closures whose identity should survive.
|
|
24
|
+
*/
|
|
25
|
+
export declare function definePlugin(plugin: DataTypePlugin): DataTypePlugin;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DataTypePluginSchema, formatIssues } from "./manifest-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a plugin definition fails validation — catchable by the
|
|
4
|
+
* registry's install() (Session 62) and `kardalum plugin validate`
|
|
5
|
+
* (Month 7), which want to report rather than crash.
|
|
6
|
+
*/
|
|
7
|
+
export class PluginDefinitionError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "PluginDefinitionError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const REQUIRED_VIEWS = ["input", "readOnly", "settings"];
|
|
14
|
+
/**
|
|
15
|
+
* Validate a datatype plugin definition and hand it back. This is the
|
|
16
|
+
* one code path into the registry: built-ins construct their plugin
|
|
17
|
+
* objects through it (see built-ins.tsx), and external plugins do the
|
|
18
|
+
* same — so a missing required view fails LOUDLY at definition time,
|
|
19
|
+
* never silently at render time (plugin-sdk.md).
|
|
20
|
+
*
|
|
21
|
+
* Deliberately does NOT register: Module Federation remotes (Session 66)
|
|
22
|
+
* export the defined plugin object, and the HOST decides when it enters
|
|
23
|
+
* the registry (install/activate lifecycle) — a define-time side effect
|
|
24
|
+
* would take that control away. Pass the result to registerDataType.
|
|
25
|
+
*
|
|
26
|
+
* Returns the ORIGINAL object (not a parsed clone) — a plugin carries
|
|
27
|
+
* React components and closures whose identity should survive.
|
|
28
|
+
*/
|
|
29
|
+
export function definePlugin(plugin) {
|
|
30
|
+
const id = typeof plugin === "object" && plugin !== null && typeof plugin.id === "string"
|
|
31
|
+
? plugin.id
|
|
32
|
+
: "(unknown id)";
|
|
33
|
+
// Required views first, with purpose-built messages — Zod's generic
|
|
34
|
+
// "expected custom, received undefined" doesn't tell a plugin author
|
|
35
|
+
// what to fix.
|
|
36
|
+
const views = typeof plugin === "object" && plugin !== null ? plugin.views : undefined;
|
|
37
|
+
for (const viewName of REQUIRED_VIEWS) {
|
|
38
|
+
if (!views || views[viewName] == null) {
|
|
39
|
+
throw new PluginDefinitionError(`definePlugin: datatype plugin "${id}" is missing required view "${viewName}" ` +
|
|
40
|
+
`(input, readOnly and settings are required; preview is optional)`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const result = DataTypePluginSchema.safeParse(plugin);
|
|
44
|
+
if (!result.success) {
|
|
45
|
+
throw new PluginDefinitionError(`definePlugin: datatype plugin "${id}" is invalid:\n` +
|
|
46
|
+
formatIssues(result.error.issues)
|
|
47
|
+
.map((line) => ` - ${line}`)
|
|
48
|
+
.join("\n"));
|
|
49
|
+
}
|
|
50
|
+
return plugin;
|
|
51
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EntitlementError, ENTITLEMENT_FLOOR_TABLE, isEntitlementError, requireEntitlement, structuredStorageFloor, type EntitlementFloor, type RequireEntitlementOptions, } from "./entitlement.js";
|
|
2
|
+
export { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
3
|
+
export { isLocalHost } from "./local-host.js";
|
|
4
|
+
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, LicenseVerdictEnvelope, PluginTaskContext, } from "./entitlement-types.js";
|
|
5
|
+
export type { TrustedKey } from "@kardalum/plugin-package";
|
|
@@ -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>;
|