@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,104 @@
|
|
|
1
|
+
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify } from "node:crypto";
|
|
2
|
+
/** Ed25519 SPKI DER is always 44 bytes: a 12-byte header followed by the
|
|
3
|
+
* raw 32-byte key. keyId is derived from the RAW key so it stays stable if
|
|
4
|
+
* the stored encoding ever changes. */
|
|
5
|
+
const SPKI_DER_LENGTH = 44;
|
|
6
|
+
const RAW_PUBLIC_KEY_LENGTH = 32;
|
|
7
|
+
function rawPublicKey(publicKeyBase64) {
|
|
8
|
+
const der = Buffer.from(publicKeyBase64, "base64");
|
|
9
|
+
if (der.length !== SPKI_DER_LENGTH) {
|
|
10
|
+
throw new Error(`expected a ${SPKI_DER_LENGTH}-byte Ed25519 SPKI DER public key, got ${der.length} bytes`);
|
|
11
|
+
}
|
|
12
|
+
return der.subarray(der.length - RAW_PUBLIC_KEY_LENGTH);
|
|
13
|
+
}
|
|
14
|
+
export function deriveKeyId(publicKeyBase64) {
|
|
15
|
+
return createHash("sha256").update(rawPublicKey(publicKeyBase64)).digest("hex").slice(0, 16);
|
|
16
|
+
}
|
|
17
|
+
export function generateSigningKeyPair() {
|
|
18
|
+
const pair = generateKeyPairSync("ed25519");
|
|
19
|
+
const privateKey = pair.privateKey.export({ format: "der", type: "pkcs8" }).toString("base64");
|
|
20
|
+
const publicKey = pair.publicKey.export({ format: "der", type: "spki" }).toString("base64");
|
|
21
|
+
return { privateKey, publicKey, keyId: deriveKeyId(publicKey) };
|
|
22
|
+
}
|
|
23
|
+
/** Deterministic serialization. Deliberately NOT full JCS — we own both
|
|
24
|
+
* ends, and a fixed-order literal is the entire requirement. */
|
|
25
|
+
export function canonicalizeEnvelope(envelope) {
|
|
26
|
+
return Buffer.from(JSON.stringify({
|
|
27
|
+
v: envelope.v,
|
|
28
|
+
alg: envelope.alg,
|
|
29
|
+
keyId: envelope.keyId,
|
|
30
|
+
pluginId: envelope.pluginId,
|
|
31
|
+
version: envelope.version,
|
|
32
|
+
sha256: envelope.sha256,
|
|
33
|
+
}), "utf8");
|
|
34
|
+
}
|
|
35
|
+
export function signEnvelope(envelope, privateKeyBase64) {
|
|
36
|
+
const key = createPrivateKey({
|
|
37
|
+
key: Buffer.from(privateKeyBase64, "base64"),
|
|
38
|
+
format: "der",
|
|
39
|
+
type: "pkcs8",
|
|
40
|
+
});
|
|
41
|
+
return sign(null, canonicalizeEnvelope(envelope), key).toString("base64");
|
|
42
|
+
}
|
|
43
|
+
function isSidecar(value) {
|
|
44
|
+
if (typeof value !== "object" || value === null)
|
|
45
|
+
return false;
|
|
46
|
+
const { envelope, signature } = value;
|
|
47
|
+
if (typeof signature !== "string" || signature.length === 0)
|
|
48
|
+
return false;
|
|
49
|
+
if (typeof envelope !== "object" || envelope === null)
|
|
50
|
+
return false;
|
|
51
|
+
const e = envelope;
|
|
52
|
+
return (e.v === 1 &&
|
|
53
|
+
e.alg === "ed25519" &&
|
|
54
|
+
typeof e.keyId === "string" &&
|
|
55
|
+
typeof e.pluginId === "string" &&
|
|
56
|
+
typeof e.version === "string" &&
|
|
57
|
+
typeof e.sha256 === "string");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check order is deliberate and produces better diagnostics than the
|
|
61
|
+
* reverse: authenticate the envelope FIRST (bad-signature = forged or
|
|
62
|
+
* corrupt), then compare it to the artifact we actually have
|
|
63
|
+
* (hash-mismatch = authentic envelope, tampered bytes — the flipped-byte
|
|
64
|
+
* case). Never throws.
|
|
65
|
+
*/
|
|
66
|
+
export function verifyEnvelope(sidecar, tarballSha256, trustedKeys) {
|
|
67
|
+
if (!isSidecar(sidecar)) {
|
|
68
|
+
return { status: "failed", reason: "malformed-sidecar", message: "signature sidecar is not a valid envelope" };
|
|
69
|
+
}
|
|
70
|
+
if (trustedKeys.length === 0) {
|
|
71
|
+
return {
|
|
72
|
+
status: "failed",
|
|
73
|
+
reason: "no-trusted-keys",
|
|
74
|
+
message: "no trusted signing keys are configured: nothing can be verified",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const trusted = trustedKeys.find((key) => key.keyId === sidecar.envelope.keyId);
|
|
78
|
+
if (!trusted) {
|
|
79
|
+
return {
|
|
80
|
+
status: "failed",
|
|
81
|
+
reason: "unknown-key",
|
|
82
|
+
message: `signed by unknown key "${sidecar.envelope.keyId}"`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
let signatureValid = false;
|
|
86
|
+
try {
|
|
87
|
+
const key = createPublicKey({ key: Buffer.from(trusted.publicKey, "base64"), format: "der", type: "spki" });
|
|
88
|
+
signatureValid = verify(null, canonicalizeEnvelope(sidecar.envelope), key, Buffer.from(sidecar.signature, "base64"));
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
signatureValid = false;
|
|
92
|
+
}
|
|
93
|
+
if (!signatureValid) {
|
|
94
|
+
return { status: "failed", reason: "bad-signature", message: "signature does not verify against the envelope" };
|
|
95
|
+
}
|
|
96
|
+
if (sidecar.envelope.sha256 !== tarballSha256) {
|
|
97
|
+
return {
|
|
98
|
+
status: "failed",
|
|
99
|
+
reason: "hash-mismatch",
|
|
100
|
+
message: `envelope describes sha256 ${sidecar.envelope.sha256} but the artifact hashes to ${tarballSha256}`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return { status: "verified", keyId: trusted.keyId, envelope: sidecar.envelope };
|
|
104
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const MAX_TOTAL_BYTES: number;
|
|
2
|
+
export declare const MAX_ENTRY_BYTES: number;
|
|
3
|
+
export declare const MAX_ENTRIES = 2000;
|
|
4
|
+
/** Pure gate over one entry's (path, type, declaredSize). Returns the
|
|
5
|
+
* violation message or null. Exported for direct unit testing — a
|
|
6
|
+
* well-formed writer can't produce hostile names, but attackers hand-craft
|
|
7
|
+
* archives directly.
|
|
8
|
+
*
|
|
9
|
+
* "OldFile" and "ContiguousFile" are accepted alongside "File" for
|
|
10
|
+
* historical (tar-era) compatibility with entries this gate has always
|
|
11
|
+
* allowed; the ZIP reader below only ever derives "File" or "Directory"
|
|
12
|
+
* for an entry, so those two never occur in practice post-migration — the
|
|
13
|
+
* allow-list simply isn't narrowed, since narrowing it wouldn't change zip
|
|
14
|
+
* behavior and would only risk breaking direct callers of this exported
|
|
15
|
+
* function. */
|
|
16
|
+
export declare function entryViolation(path: string, type: string, size: number): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts a single ZIP archive into `targetDir`, admitting only entries
|
|
19
|
+
* that pass `entryViolation`'s allow-list and the MAX_ENTRIES/
|
|
20
|
+
* MAX_TOTAL_BYTES ceilings below. Never throws — every failure mode
|
|
21
|
+
* resolves `{ ok: false, reason }`, so a hostile or broken package
|
|
22
|
+
* degrades with a clear reason at install time instead of an uncaught
|
|
23
|
+
* rejection bricking (or 500-ing) the host.
|
|
24
|
+
*
|
|
25
|
+
* IMPORTANT: `{ ok: false }` does not mean nothing was written. Entries are
|
|
26
|
+
* written to disk incrementally as the archive streams in, so anything
|
|
27
|
+
* admitted before the violation was detected is already sitting under
|
|
28
|
+
* `targetDir`. Callers MUST treat `{ ok: false }` as fatal and delete
|
|
29
|
+
* `targetDir` themselves — this function does not roll back a partial
|
|
30
|
+
* extraction.
|
|
31
|
+
*/
|
|
32
|
+
export declare function extractArtifact(archivePath: string, targetDir: string): Promise<{
|
|
33
|
+
ok: true;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
reason: string;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { createWriteStream, mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve as resolvePath, sep } from "node:path";
|
|
3
|
+
import * as yauzl from "yauzl";
|
|
4
|
+
export const MAX_TOTAL_BYTES = 100 * 1024 * 1024;
|
|
5
|
+
export const MAX_ENTRY_BYTES = 50 * 1024 * 1024;
|
|
6
|
+
export const MAX_ENTRIES = 2000;
|
|
7
|
+
const ALLOWED_ENTRY_TYPES = new Set(["File", "OldFile", "ContiguousFile", "Directory"]);
|
|
8
|
+
/** Pure gate over one entry's (path, type, declaredSize). Returns the
|
|
9
|
+
* violation message or null. Exported for direct unit testing — a
|
|
10
|
+
* well-formed writer can't produce hostile names, but attackers hand-craft
|
|
11
|
+
* archives directly.
|
|
12
|
+
*
|
|
13
|
+
* "OldFile" and "ContiguousFile" are accepted alongside "File" for
|
|
14
|
+
* historical (tar-era) compatibility with entries this gate has always
|
|
15
|
+
* allowed; the ZIP reader below only ever derives "File" or "Directory"
|
|
16
|
+
* for an entry, so those two never occur in practice post-migration — the
|
|
17
|
+
* allow-list simply isn't narrowed, since narrowing it wouldn't change zip
|
|
18
|
+
* behavior and would only risk breaking direct callers of this exported
|
|
19
|
+
* function. */
|
|
20
|
+
export function entryViolation(path, type, size) {
|
|
21
|
+
if (path.startsWith("/") ||
|
|
22
|
+
path.startsWith("\\") ||
|
|
23
|
+
/^[a-zA-Z]:/.test(path) ||
|
|
24
|
+
path.split(/[\\/]/).includes("..")) {
|
|
25
|
+
return `unsafe entry path "${path}"`;
|
|
26
|
+
}
|
|
27
|
+
if (!ALLOWED_ENTRY_TYPES.has(type)) {
|
|
28
|
+
return `unsafe entry type "${type}" for "${path}": only files and directories are allowed`;
|
|
29
|
+
}
|
|
30
|
+
if (size > MAX_ENTRY_BYTES) {
|
|
31
|
+
return `entry "${path}" exceeds the per-file size limit`;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extracts a single ZIP archive into `targetDir`, admitting only entries
|
|
37
|
+
* that pass `entryViolation`'s allow-list and the MAX_ENTRIES/
|
|
38
|
+
* MAX_TOTAL_BYTES ceilings below. Never throws — every failure mode
|
|
39
|
+
* resolves `{ ok: false, reason }`, so a hostile or broken package
|
|
40
|
+
* degrades with a clear reason at install time instead of an uncaught
|
|
41
|
+
* rejection bricking (or 500-ing) the host.
|
|
42
|
+
*
|
|
43
|
+
* IMPORTANT: `{ ok: false }` does not mean nothing was written. Entries are
|
|
44
|
+
* written to disk incrementally as the archive streams in, so anything
|
|
45
|
+
* admitted before the violation was detected is already sitting under
|
|
46
|
+
* `targetDir`. Callers MUST treat `{ ok: false }` as fatal and delete
|
|
47
|
+
* `targetDir` themselves — this function does not roll back a partial
|
|
48
|
+
* extraction.
|
|
49
|
+
*/
|
|
50
|
+
export function extractArtifact(archivePath, targetDir) {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
// Guards resolve() against firing twice (e.g. a stray 'readEntry'
|
|
53
|
+
// continuation racing an already-settled violation). Harmless —
|
|
54
|
+
// Promise settlement is idempotent regardless — but noted since it's
|
|
55
|
+
// not load-bearing for the contract, just defensive.
|
|
56
|
+
let settled = false;
|
|
57
|
+
const settle = (value) => {
|
|
58
|
+
if (!settled) {
|
|
59
|
+
settled = true;
|
|
60
|
+
resolve(value);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
mkdirSync(targetDir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
settle({ ok: false, reason: "could not prepare the extraction directory" });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const resolvedTargetDir = resolvePath(targetDir);
|
|
71
|
+
// decodeStrings: false — yauzl's own string decoding path runs its own
|
|
72
|
+
// absolute-path/".."/backslash filename validation before ever emitting
|
|
73
|
+
// an 'entry' event, and rejects by emitting 'error' on the whole
|
|
74
|
+
// zipfile with its own message text. That would make yauzl's built-in
|
|
75
|
+
// check the real gate for hostile names, not entryViolation. Decoding
|
|
76
|
+
// fileNameRaw ourselves below keeps entryViolation authoritative, as
|
|
77
|
+
// required — one gate, not two.
|
|
78
|
+
yauzl.open(archivePath, { lazyEntries: true, decodeStrings: false }, (openErr, zipfile) => {
|
|
79
|
+
if (openErr || !zipfile) {
|
|
80
|
+
settle({ ok: false, reason: "not a valid .zip archive" });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Fast upfront rejection: ZIP's central directory declares its entry
|
|
84
|
+
// count in the end-of-central-directory record, read during open()
|
|
85
|
+
// itself — unlike tar's PAX/meta-entry bypass, there is no way for a
|
|
86
|
+
// zip to hide entries from this count (yauzl only ever iterates
|
|
87
|
+
// exactly this many central directory records). Checking it here
|
|
88
|
+
// means a too-many-entries archive is rejected before writing a
|
|
89
|
+
// single byte to disk, rather than after extracting MAX_ENTRIES
|
|
90
|
+
// files first. The per-entry counter below still enforces the same
|
|
91
|
+
// ceiling independently, as defense in depth.
|
|
92
|
+
if (zipfile.entryCount > MAX_ENTRIES) {
|
|
93
|
+
zipfile.close();
|
|
94
|
+
settle({ ok: false, reason: `archive has more than ${MAX_ENTRIES} entries` });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let entryCount = 0;
|
|
98
|
+
let totalBytes = 0;
|
|
99
|
+
const fail = (reason) => {
|
|
100
|
+
zipfile.close();
|
|
101
|
+
settle({ ok: false, reason });
|
|
102
|
+
};
|
|
103
|
+
zipfile.on("error", () => fail("not a valid .zip archive"));
|
|
104
|
+
zipfile.on("entry", (entry) => {
|
|
105
|
+
if (settled)
|
|
106
|
+
return;
|
|
107
|
+
entryCount += 1;
|
|
108
|
+
if (entryCount > MAX_ENTRIES) {
|
|
109
|
+
fail(`archive has more than ${MAX_ENTRIES} entries`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// fileNameRaw is always populated regardless of decodeStrings; the
|
|
113
|
+
// UTF-8 general-purpose bit (0x800) tells us how to interpret it.
|
|
114
|
+
// ASCII bytes (the only ones that matter to entryViolation's own
|
|
115
|
+
// checks) decode identically under utf8 or latin1, so a plain
|
|
116
|
+
// fallback for non-UTF-8 archives is fine here — full CP437
|
|
117
|
+
// fidelity only affects display of non-ASCII names, never safety.
|
|
118
|
+
const isUtf8 = (entry.generalPurposeBitFlag & 0x800) !== 0;
|
|
119
|
+
const fileName = entry.fileNameRaw.toString(isUtf8 ? "utf8" : "latin1");
|
|
120
|
+
const isDirectory = fileName.endsWith("/");
|
|
121
|
+
const type = isDirectory ? "Directory" : "File";
|
|
122
|
+
const violation = entryViolation(fileName, type, entry.uncompressedSize);
|
|
123
|
+
if (violation) {
|
|
124
|
+
fail(violation);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
totalBytes += entry.uncompressedSize;
|
|
128
|
+
if (totalBytes > MAX_TOTAL_BYTES) {
|
|
129
|
+
fail(`archive expands beyond the ${MAX_TOTAL_BYTES / 1024 / 1024} MB limit`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// This is an assertion, not a second gate: entryViolation above
|
|
133
|
+
// already rejects a leading "/" or "\\", a drive letter, and any
|
|
134
|
+
// ".." segment, so resolving fileName against targetDir can never
|
|
135
|
+
// land outside it — this branch must be unreachable. It stays
|
|
136
|
+
// because it is a two-line check against the one failure mode
|
|
137
|
+
// (zip-slip) that would actually write files outside targetDir, so
|
|
138
|
+
// the cost of keeping it is negligible next to what a silent
|
|
139
|
+
// regression in entryViolation would cost.
|
|
140
|
+
const destPath = resolvePath(targetDir, fileName);
|
|
141
|
+
if (destPath !== resolvedTargetDir && !destPath.startsWith(resolvedTargetDir + sep)) {
|
|
142
|
+
fail(`unsafe entry path "${fileName}"`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// The filesystem calls below can throw — most concretely EEXIST
|
|
146
|
+
// from mkdirSync when a hostile or malformed archive declares a
|
|
147
|
+
// file entry and a directory entry at the same path (e.g. "a" then
|
|
148
|
+
// "a/b", or a directory entry "a/" arriving after a file "a"). An
|
|
149
|
+
// uncaught throw here would escape yauzl's internal fs.read
|
|
150
|
+
// callback as an uncaught exception and kill the process, which
|
|
151
|
+
// breaks this function's never-throws contract. Route every
|
|
152
|
+
// filesystem failure through fail() instead.
|
|
153
|
+
try {
|
|
154
|
+
if (isDirectory) {
|
|
155
|
+
mkdirSync(destPath, { recursive: true });
|
|
156
|
+
zipfile.readEntry();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
mkdirSync(dirname(destPath), { recursive: true });
|
|
160
|
+
zipfile.openReadStream(entry, (streamErr, readStream) => {
|
|
161
|
+
if (settled)
|
|
162
|
+
return;
|
|
163
|
+
if (streamErr || !readStream) {
|
|
164
|
+
fail("could not read entry");
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const writeStream = createWriteStream(destPath);
|
|
169
|
+
readStream.on("error", () => {
|
|
170
|
+
writeStream.destroy();
|
|
171
|
+
readStream.destroy();
|
|
172
|
+
fail("could not read entry");
|
|
173
|
+
});
|
|
174
|
+
writeStream.on("error", () => {
|
|
175
|
+
writeStream.destroy();
|
|
176
|
+
readStream.destroy();
|
|
177
|
+
fail("could not write entry");
|
|
178
|
+
});
|
|
179
|
+
writeStream.on("close", () => {
|
|
180
|
+
if (!settled)
|
|
181
|
+
zipfile.readEntry();
|
|
182
|
+
});
|
|
183
|
+
readStream.pipe(writeStream);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
readStream.destroy();
|
|
187
|
+
fail("could not write entry");
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
fail("could not write entry");
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
zipfile.on("end", () => settle({ ok: true }));
|
|
196
|
+
zipfile.readEntry();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** One definition of "the artifact's hash" for signer and verifier alike —
|
|
2
|
+
* the same value S126 records as PluginVersion.artifactSha256. */
|
|
3
|
+
export declare function hashBuffer(buffer: Buffer): string;
|
|
4
|
+
export declare function hashArchive(path: string): Promise<string>;
|
|
5
|
+
/** sha256 over the sorted relative paths and contents of every file under
|
|
6
|
+
* `dirs` that exist; "" when none exists. Each file is keyed by the index of
|
|
7
|
+
* its directory in `dirs` and its posix relative path ("0/plugin.js"), the
|
|
8
|
+
* keys are sorted by plain string comparison, and the hash is fed, per file,
|
|
9
|
+
* the key's UTF-8 byte length as an 8-byte big-endian integer, the key, the
|
|
10
|
+
* file's byte length the same way, and the file's bytes. The lengths make
|
|
11
|
+
* the framing unambiguous: a file body may contain any byte, so a separator
|
|
12
|
+
* byte alone would let bytes move from one file into the tail of another
|
|
13
|
+
* behind a forged separator and keep the hash (S284b fix wave). No mtimes, no
|
|
14
|
+
* platform separators, so the same tree hashes the same everywhere. Symbolic
|
|
15
|
+
* links are neither followed nor hashed: a package extracted by
|
|
16
|
+
* `extractArtifact` contains none. (S284b: the host's `currentSha256`.) */
|
|
17
|
+
export declare function hashDirectories(dirs: string[]): Promise<string>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
/** One definition of "the artifact's hash" for signer and verifier alike —
|
|
6
|
+
* the same value S126 records as PluginVersion.artifactSha256. */
|
|
7
|
+
export function hashBuffer(buffer) {
|
|
8
|
+
return createHash("sha256").update(buffer).digest("hex");
|
|
9
|
+
}
|
|
10
|
+
export function hashArchive(path) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const hash = createHash("sha256");
|
|
13
|
+
createReadStream(path)
|
|
14
|
+
.on("error", reject)
|
|
15
|
+
.on("data", (chunk) => hash.update(chunk))
|
|
16
|
+
.on("end", () => resolve(hash.digest("hex")));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** sha256 over the sorted relative paths and contents of every file under
|
|
20
|
+
* `dirs` that exist; "" when none exists. Each file is keyed by the index of
|
|
21
|
+
* its directory in `dirs` and its posix relative path ("0/plugin.js"), the
|
|
22
|
+
* keys are sorted by plain string comparison, and the hash is fed, per file,
|
|
23
|
+
* the key's UTF-8 byte length as an 8-byte big-endian integer, the key, the
|
|
24
|
+
* file's byte length the same way, and the file's bytes. The lengths make
|
|
25
|
+
* the framing unambiguous: a file body may contain any byte, so a separator
|
|
26
|
+
* byte alone would let bytes move from one file into the tail of another
|
|
27
|
+
* behind a forged separator and keep the hash (S284b fix wave). No mtimes, no
|
|
28
|
+
* platform separators, so the same tree hashes the same everywhere. Symbolic
|
|
29
|
+
* links are neither followed nor hashed: a package extracted by
|
|
30
|
+
* `extractArtifact` contains none. (S284b: the host's `currentSha256`.) */
|
|
31
|
+
export async function hashDirectories(dirs) {
|
|
32
|
+
const files = [];
|
|
33
|
+
let anyExists = false;
|
|
34
|
+
for (const [index, dir] of dirs.entries()) {
|
|
35
|
+
const info = await stat(dir).catch(() => null);
|
|
36
|
+
if (!info?.isDirectory())
|
|
37
|
+
continue;
|
|
38
|
+
anyExists = true;
|
|
39
|
+
await collectFiles(dir, String(index), files);
|
|
40
|
+
}
|
|
41
|
+
if (!anyExists)
|
|
42
|
+
return "";
|
|
43
|
+
files.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
44
|
+
const hash = createHash("sha256");
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
const key = Buffer.from(file.key, "utf8");
|
|
47
|
+
const content = await readFile(file.absolute);
|
|
48
|
+
hash.update(byteLength(key.length));
|
|
49
|
+
hash.update(key);
|
|
50
|
+
hash.update(byteLength(content.length));
|
|
51
|
+
hash.update(content);
|
|
52
|
+
}
|
|
53
|
+
return hash.digest("hex");
|
|
54
|
+
}
|
|
55
|
+
function byteLength(length) {
|
|
56
|
+
const prefix = Buffer.alloc(8);
|
|
57
|
+
prefix.writeBigUInt64BE(BigInt(length));
|
|
58
|
+
return prefix;
|
|
59
|
+
}
|
|
60
|
+
async function collectFiles(dir, prefix, out) {
|
|
61
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
62
|
+
const absolute = join(dir, entry.name);
|
|
63
|
+
const key = `${prefix}/${entry.name}`;
|
|
64
|
+
if (entry.isDirectory())
|
|
65
|
+
await collectFiles(absolute, key, out);
|
|
66
|
+
else if (entry.isFile())
|
|
67
|
+
out.push({ key, absolute });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { PackageSignatureSidecar, SignatureEnvelope, TrustedKey, VerifyFailureReason, VerifyResult, } from "./types.js";
|
|
2
|
+
export { VERIFY_FAILURE_REASONS } from "./types.js";
|
|
3
|
+
export { canonicalizeEnvelope, deriveKeyId, generateSigningKeyPair, signEnvelope, verifyEnvelope, } from "./envelope.js";
|
|
4
|
+
export type { LicenseChallenge, LicenseVerdictEnvelope, LicenseVerdictResult, LicenseVerdictSignatureResult, SignedLicenseVerdict, TamperKind, } from "./license-verdict.js";
|
|
5
|
+
export { canonicalizeLicenseVerdict, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_VERDICT_DETAIL_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
|
|
6
|
+
export { hashBuffer, hashArchive, hashDirectories } from "./hash.js";
|
|
7
|
+
export { entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "./extract.js";
|
|
8
|
+
export { SAMPLE_CONTENT_MAX_BYTES, readShippedInstallFacts, readShippedSampleContent } from "./sample-content.js";
|
|
9
|
+
export type { ShippedSampleContent } from "./sample-content.js";
|
|
10
|
+
export type { PackageContractCheck } from "./package-contract.js";
|
|
11
|
+
export { checkCoverContract, checkPackageContract, checkReadmeContract, COVER_HEIGHT, COVER_PATH, COVER_WIDTH, pngSize, } from "./package-contract.js";
|
|
12
|
+
export type { DocsContractInput } from "./docs-contract.js";
|
|
13
|
+
export { capViolations, checkDocsContract, countRemoteImages, docsFilesToShip, MAX_PACKAGE_JSON_BYTES, MAX_VIOLATIONS, packageFilePath, readDocsContractInput } from "./docs-contract.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { VERIFY_FAILURE_REASONS } from "./types.js";
|
|
2
|
+
export { canonicalizeEnvelope, deriveKeyId, generateSigningKeyPair, signEnvelope, verifyEnvelope, } from "./envelope.js";
|
|
3
|
+
export { canonicalizeLicenseVerdict, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_VERDICT_DETAIL_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
|
|
4
|
+
export { hashBuffer, hashArchive, hashDirectories } from "./hash.js";
|
|
5
|
+
export { entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "./extract.js";
|
|
6
|
+
export { SAMPLE_CONTENT_MAX_BYTES, readShippedInstallFacts, readShippedSampleContent } from "./sample-content.js";
|
|
7
|
+
export { checkCoverContract, checkPackageContract, checkReadmeContract, COVER_HEIGHT, COVER_PATH, COVER_WIDTH, pngSize, } from "./package-contract.js";
|
|
8
|
+
export { capViolations, checkDocsContract, countRemoteImages, docsFilesToShip, MAX_PACKAGE_JSON_BYTES, MAX_VIOLATIONS, packageFilePath, readDocsContractInput } from "./docs-contract.js";
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { TrustedKey } from "./types.js";
|
|
2
|
+
/** A licence verdict is a different thing from a package signature, so it
|
|
3
|
+
* gets its own envelope rather than bending SignatureEnvelope. It reuses
|
|
4
|
+
* the same Ed25519 primitives and the same trusted-key set, which is what
|
|
5
|
+
* makes a fake licence server unable to produce one the CMS accepts. A
|
|
6
|
+
* captured verdict is not a durable unlock: `nonce` (bound per request via
|
|
7
|
+
* a `LicenseChallenge`) is what actually prevents replay, since a
|
|
8
|
+
* verifier's own clock cannot be trusted to bound freshness — see
|
|
9
|
+
* `createLicenseChallenge`'s doc comment below. */
|
|
10
|
+
export interface LicenseVerdictEnvelope {
|
|
11
|
+
v: 1;
|
|
12
|
+
alg: "ed25519";
|
|
13
|
+
/** Fixed literal that domain-separates this envelope from
|
|
14
|
+
* SignatureEnvelope. Both are signed by the same trusted keys, so
|
|
15
|
+
* without an explicit discriminator, telling the two apart would rest
|
|
16
|
+
* on "the field names happen to differ" rather than being a property of
|
|
17
|
+
* the design. */
|
|
18
|
+
typ: "license-verdict";
|
|
19
|
+
/** First 16 hex of sha256(raw public key) — derived, never assigned. */
|
|
20
|
+
keyId: string;
|
|
21
|
+
/** sha256 of the licence key. The key itself never travels in a verdict:
|
|
22
|
+
* a captured verdict must not be a working credential. */
|
|
23
|
+
keyHash: string;
|
|
24
|
+
pluginId: string;
|
|
25
|
+
domain: string;
|
|
26
|
+
/** Echoes the nonce carried by the `LicenseChallenge` the CMS sent with
|
|
27
|
+
* its validation request (see `createLicenseChallenge`). This is not
|
|
28
|
+
* redundant with `issuedAt` / staleness. The CMS's own clock is not
|
|
29
|
+
* trustworthy input to a check meant to defeat the CMS: the process
|
|
30
|
+
* being verified runs on the customer's machine, and they can capture a
|
|
31
|
+
* single genuine "valid" verdict once, then replay it forever by
|
|
32
|
+
* running the process under a clock pinned near `issuedAt` — no source
|
|
33
|
+
* edit, survives updates, shareable as a recipe. No time-based check can
|
|
34
|
+
* close that, however tight the window. A fresh unpredictable nonce
|
|
35
|
+
* chosen by the verifier and checked for an exact match closes it,
|
|
36
|
+
* because a captured verdict cannot answer a challenge it never saw. Do
|
|
37
|
+
* not remove this as "covered by issuedAt" — it is the only check here a
|
|
38
|
+
* replay cannot pass. */
|
|
39
|
+
nonce: string;
|
|
40
|
+
status: "valid" | "invalid" | "revoked";
|
|
41
|
+
reason?: string;
|
|
42
|
+
issuedAt: string;
|
|
43
|
+
/** The marketplace's classification of the installed package when it
|
|
44
|
+
* differs from what it delivered for this licence (S284b). Absent when
|
|
45
|
+
* clean, and its absence is canonical (see `canonicalizeLicenseVerdict`),
|
|
46
|
+
* so every verdict signed before this field existed still verifies. It is
|
|
47
|
+
* evidence for a human to read, never a reason to lock anything. */
|
|
48
|
+
tamper?: TamperKind;
|
|
49
|
+
/** A human sentence that explains `reason` (S284b fix wave): today the
|
|
50
|
+
* operator's reason for a `domain_blocked` answer, shown to the blocked
|
|
51
|
+
* site. Absent unless there is something to say, and canonical like
|
|
52
|
+
* `tamper` (appended after it, only when present), so every verdict
|
|
53
|
+
* signed before this field existed still verifies. At most
|
|
54
|
+
* LICENSE_VERDICT_DETAIL_MAX characters. */
|
|
55
|
+
detail?: string;
|
|
56
|
+
}
|
|
57
|
+
/** The longest `detail` a verdict may carry. */
|
|
58
|
+
export declare const LICENSE_VERDICT_DETAIL_MAX = 500;
|
|
59
|
+
/** How an installed package differs from the marketplace's delivery:
|
|
60
|
+
* another licence's (or version's) delivery, a package the marketplace never
|
|
61
|
+
* delivered, or the right delivery changed on disk since its first report. */
|
|
62
|
+
export type TamperKind = "foreign-package" | "sideloaded" | "modified-on-disk";
|
|
63
|
+
export interface SignedLicenseVerdict {
|
|
64
|
+
envelope: LicenseVerdictEnvelope;
|
|
65
|
+
signature: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A `LicenseChallenge` is the only way to obtain a nonce, and the only
|
|
69
|
+
* shape `verifyLicenseVerdict` accepts in place of a separately-typed
|
|
70
|
+
* "expected subject". Folding subject and nonce into one object the module
|
|
71
|
+
* itself produces means they can never disagree — there is no way to hand
|
|
72
|
+
* `verifyLicenseVerdict` a nonce that was not the one generated for this
|
|
73
|
+
* exact subject.
|
|
74
|
+
*
|
|
75
|
+
* A challenge is single-use: `verifyLicenseVerdict` consumes it on first
|
|
76
|
+
* use (success or failure) and returns `"challenge-reused"` on any second
|
|
77
|
+
* use of the same object. A caller that needs to retry a validation round
|
|
78
|
+
* trip must call `createLicenseChallenge` again — a retry is a new
|
|
79
|
+
* question, and asking it again with the same nonce is exactly the
|
|
80
|
+
* caller-side mistake (caching one nonce and reusing it across requests)
|
|
81
|
+
* that collapses replay protection back to "one captured verdict unlocks
|
|
82
|
+
* until restart". Consumption is tracked in a module-private `WeakSet` so
|
|
83
|
+
* nothing outside this file can mark a challenge used, or unused.
|
|
84
|
+
*/
|
|
85
|
+
export interface LicenseChallenge {
|
|
86
|
+
readonly keyHash: string;
|
|
87
|
+
readonly pluginId: string;
|
|
88
|
+
readonly domain: string;
|
|
89
|
+
/** Hex-encoded, at least 16 random bytes. Exposed only so the caller can
|
|
90
|
+
* transmit it to the marketplace alongside the rest of the validation
|
|
91
|
+
* request — it plays no other role on the caller's side. */
|
|
92
|
+
readonly nonce: string;
|
|
93
|
+
}
|
|
94
|
+
/** Verification authenticates a signed envelope; it does not decide
|
|
95
|
+
* whether to unlock anything. `"licensed"` is the only branch that should
|
|
96
|
+
* ever lead to unlocking a plugin. `"unlicensed"` means the marketplace
|
|
97
|
+
* gave an authentic, fresh, correctly subject-bound answer and that answer
|
|
98
|
+
* says no (`invalid` or `revoked`) — a real verdict, safe to show the
|
|
99
|
+
* user. `"unverifiable"` means no answer this caller can trust was
|
|
100
|
+
* obtained at all (malformed input, an untrusted or forged signature, a
|
|
101
|
+
* verdict for a different subject, a stale or reused challenge) — the
|
|
102
|
+
* caller must treat this exactly like an unreachable licence server and
|
|
103
|
+
* change nothing, never as a soft "no". There is no boolean here to
|
|
104
|
+
* misread: unlike a `{ ok: boolean }` shape, `if (result.ok) unlock()`
|
|
105
|
+
* cannot compile against this type, because "authentic" and "licensed"
|
|
106
|
+
* are different questions with different answers for a revoked licence. */
|
|
107
|
+
export type LicenseVerdictResult = {
|
|
108
|
+
verdict: "licensed";
|
|
109
|
+
envelope: LicenseVerdictEnvelope;
|
|
110
|
+
} | {
|
|
111
|
+
verdict: "unlicensed";
|
|
112
|
+
status: "invalid" | "revoked";
|
|
113
|
+
reason?: string;
|
|
114
|
+
envelope: LicenseVerdictEnvelope;
|
|
115
|
+
} | {
|
|
116
|
+
verdict: "unverifiable";
|
|
117
|
+
reason: "malformed" | "untrusted-key" | "bad-signature" | "subject-mismatch" | "stale" | "challenge-reused";
|
|
118
|
+
};
|
|
119
|
+
/** A cheap SECONDARY bound only — the nonce (see `createLicenseChallenge`'s
|
|
120
|
+
* doc comment) is what actually stops replay, and it does so completely:
|
|
121
|
+
* a captured verdict cannot answer a challenge it never saw, regardless of
|
|
122
|
+
* how wide this window is. This check exists purely to reject an obviously
|
|
123
|
+
* stale or forged `issuedAt`, and it is symmetric (a future-dated
|
|
124
|
+
* `issuedAt` is rejected too) but, on its own, a check against `now` can
|
|
125
|
+
* always be defeated by controlling `now`.
|
|
126
|
+
*
|
|
127
|
+
* Widened from 5 minutes to 24 hours (S209 criticals fix): a five-minute
|
|
128
|
+
* window bought no real security — the nonce already closes the gap this
|
|
129
|
+
* was guarding — but it did fail a paying customer's install outright the
|
|
130
|
+
* moment their clock drifted more than five minutes from real time (a
|
|
131
|
+
* sleeping Docker VM, an un-NTP'd VPS), turning `verifyLicenseVerdict` into
|
|
132
|
+
* `unverifiable: stale` and the whole install into a failure with no
|
|
133
|
+
* security payoff. 24 hours easily survives that kind of drift while still
|
|
134
|
+
* rejecting a genuinely stale or forged envelope. */
|
|
135
|
+
export declare const MAX_VERDICT_AGE_MS: number;
|
|
136
|
+
/** How old a verdict may be before a plugin's own entitlement check stops
|
|
137
|
+
* accepting it: the 14-day grace period (S284b). Measured from the
|
|
138
|
+
* verifier's `now`; the plugin's floor is what keeps a rewound clock from
|
|
139
|
+
* stretching it. */
|
|
140
|
+
export declare const ENTITLEMENT_MAX_AGE_MS: number;
|
|
141
|
+
export declare function hashLicenseKey(key: string): string;
|
|
142
|
+
/** Starts a licence validation round trip. Returns a challenge carrying
|
|
143
|
+
* both the subject being validated and a freshly generated nonce — the
|
|
144
|
+
* caller sends the whole thing (or at least its `nonce`) to the
|
|
145
|
+
* marketplace, which echoes the nonce into the signed envelope it
|
|
146
|
+
* produces. The caller then passes this same challenge to
|
|
147
|
+
* `verifyLicenseVerdict`, so the subject and the nonce it gets checked
|
|
148
|
+
* against can never come from two different places and drift apart.
|
|
149
|
+
*
|
|
150
|
+
* Each challenge verifies at most once — see `LicenseChallenge`'s doc
|
|
151
|
+
* comment. Call this again for every new validation attempt; do not cache
|
|
152
|
+
* or reuse a challenge (or its nonce) across requests. */
|
|
153
|
+
export declare function createLicenseChallenge(subject: {
|
|
154
|
+
keyHash: string;
|
|
155
|
+
pluginId: string;
|
|
156
|
+
domain: string;
|
|
157
|
+
}): LicenseChallenge;
|
|
158
|
+
/** Explicit field order, exactly like canonicalizeEnvelope — never
|
|
159
|
+
* JSON.stringify of the object itself, whose key order is not guaranteed
|
|
160
|
+
* across producers. `tamper` and then `detail` are appended last and only
|
|
161
|
+
* when present, so an envelope without them produces exactly the bytes it
|
|
162
|
+
* did before the fields existed (pinned by a test): old signatures keep
|
|
163
|
+
* verifying. */
|
|
164
|
+
export declare function canonicalizeLicenseVerdict(envelope: LicenseVerdictEnvelope): Buffer;
|
|
165
|
+
export declare function signLicenseVerdict(envelope: LicenseVerdictEnvelope, privateKeyBase64: string): string;
|
|
166
|
+
export type LicenseVerdictSignatureResult = {
|
|
167
|
+
ok: true;
|
|
168
|
+
envelope: LicenseVerdictEnvelope;
|
|
169
|
+
} | {
|
|
170
|
+
ok: false;
|
|
171
|
+
reason: "malformed" | "unknown-key" | "bad-signature" | "expired" | "future";
|
|
172
|
+
};
|
|
173
|
+
/** Verifies a verdict the way a plugin can: the signature against a trusted
|
|
174
|
+
* key, the shape, the `typ`, and `issuedAt` neither older than `maxAgeMs`
|
|
175
|
+
* (default `ENTITLEMENT_MAX_AGE_MS`) before `now` nor later than
|
|
176
|
+
* `MAX_VERDICT_AGE_MS` after it. It does NOT check the nonce, the domain or
|
|
177
|
+
* the key hash: the nonce guards the host's request to the marketplace, and
|
|
178
|
+
* a plugin re-verifying the host's stored verdict never saw that challenge.
|
|
179
|
+
* An authentic `invalid` or `revoked` verdict is `ok: true`; what `status`
|
|
180
|
+
* means is the caller's decision. An unparseable `issuedAt` is `malformed`. */
|
|
181
|
+
export declare function verifyLicenseVerdictSignature(signed: unknown, trustedKeys: TrustedKey[], opts?: {
|
|
182
|
+
now?: Date;
|
|
183
|
+
maxAgeMs?: number;
|
|
184
|
+
}): LicenseVerdictSignatureResult;
|
|
185
|
+
export declare function verifyLicenseVerdict(signedVerdict: unknown, challenge: LicenseChallenge, trustedKeys: TrustedKey[], now?: Date): LicenseVerdictResult;
|