@kardalum/plugin-sdk 0.0.0-stage → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +108 -0
- package/LICENSE +202 -0
- package/README.md +70 -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 +99 -0
- package/dist/capabilities.js +363 -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 +93 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +22 -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 +408 -0
- package/dist/manifest-schema.js +774 -0
- package/dist/manifest.d.ts +546 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +438 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +75 -0
- package/dist/plugin-context.js +70 -0
- package/dist/plugin-screen-context.d.ts +40 -0
- package/dist/plugin-screen-context.js +16 -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 +387 -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 +5 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -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 +537 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -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 +256 -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 +151 -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 +302 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -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 +36 -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 +296 -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 +102 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +58 -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/marketplace-listing-api.schema.d.ts +381 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -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 +169 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -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 +89 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -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-management-api.schema.d.ts +369 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -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 +306 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -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 +90 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -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/setup-api.schema.d.ts +108 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -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 +43 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -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 +89 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -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/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 +11 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -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/sample-content.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/package.json +49 -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 +86 -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,236 @@
|
|
|
1
|
+
import { createHash, createPrivateKey, createPublicKey, randomBytes, sign, verify } from "node:crypto";
|
|
2
|
+
import { deriveKeyId } from "./envelope.js";
|
|
3
|
+
/** The longest `detail` a verdict may carry. */
|
|
4
|
+
export const LICENSE_VERDICT_DETAIL_MAX = 500;
|
|
5
|
+
const TAMPER_KINDS = ["foreign-package", "sideloaded", "modified-on-disk"];
|
|
6
|
+
/** A cheap SECONDARY bound only — the nonce (see `createLicenseChallenge`'s
|
|
7
|
+
* doc comment) is what actually stops replay, and it does so completely:
|
|
8
|
+
* a captured verdict cannot answer a challenge it never saw, regardless of
|
|
9
|
+
* how wide this window is. This check exists purely to reject an obviously
|
|
10
|
+
* stale or forged `issuedAt`, and it is symmetric (a future-dated
|
|
11
|
+
* `issuedAt` is rejected too) but, on its own, a check against `now` can
|
|
12
|
+
* always be defeated by controlling `now`.
|
|
13
|
+
*
|
|
14
|
+
* Widened from 5 minutes to 24 hours (S209 criticals fix): a five-minute
|
|
15
|
+
* window bought no real security — the nonce already closes the gap this
|
|
16
|
+
* was guarding — but it did fail a paying customer's install outright the
|
|
17
|
+
* moment their clock drifted more than five minutes from real time (a
|
|
18
|
+
* sleeping Docker VM, an un-NTP'd VPS), turning `verifyLicenseVerdict` into
|
|
19
|
+
* `unverifiable: stale` and the whole install into a failure with no
|
|
20
|
+
* security payoff. 24 hours easily survives that kind of drift while still
|
|
21
|
+
* rejecting a genuinely stale or forged envelope. */
|
|
22
|
+
export const MAX_VERDICT_AGE_MS = 24 * 60 * 60_000;
|
|
23
|
+
/** How old a verdict may be before a plugin's own entitlement check stops
|
|
24
|
+
* accepting it: the 14-day grace period (S284b). Measured from the
|
|
25
|
+
* verifier's `now`; the plugin's floor is what keeps a rewound clock from
|
|
26
|
+
* stretching it. */
|
|
27
|
+
export const ENTITLEMENT_MAX_AGE_MS = 14 * 24 * 60 * 60_000;
|
|
28
|
+
export function hashLicenseKey(key) {
|
|
29
|
+
return createHash("sha256").update(key, "utf8").digest("hex");
|
|
30
|
+
}
|
|
31
|
+
/** Consumption tracking for issued challenges. Module-private: the only
|
|
32
|
+
* way to add an entry is to call `verifyLicenseVerdict`, and the only way
|
|
33
|
+
* to obtain a `LicenseChallenge` to add is to call
|
|
34
|
+
* `createLicenseChallenge`. Nothing outside this file can mark a
|
|
35
|
+
* challenge used, unused, or forge a fresh-looking one. */
|
|
36
|
+
const consumedChallenges = new WeakSet();
|
|
37
|
+
/** Starts a licence validation round trip. Returns a challenge carrying
|
|
38
|
+
* both the subject being validated and a freshly generated nonce — the
|
|
39
|
+
* caller sends the whole thing (or at least its `nonce`) to the
|
|
40
|
+
* marketplace, which echoes the nonce into the signed envelope it
|
|
41
|
+
* produces. The caller then passes this same challenge to
|
|
42
|
+
* `verifyLicenseVerdict`, so the subject and the nonce it gets checked
|
|
43
|
+
* against can never come from two different places and drift apart.
|
|
44
|
+
*
|
|
45
|
+
* Each challenge verifies at most once — see `LicenseChallenge`'s doc
|
|
46
|
+
* comment. Call this again for every new validation attempt; do not cache
|
|
47
|
+
* or reuse a challenge (or its nonce) across requests. */
|
|
48
|
+
export function createLicenseChallenge(subject) {
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
keyHash: subject.keyHash,
|
|
51
|
+
pluginId: subject.pluginId,
|
|
52
|
+
domain: subject.domain,
|
|
53
|
+
nonce: randomBytes(16).toString("hex"),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** Explicit field order, exactly like canonicalizeEnvelope — never
|
|
57
|
+
* JSON.stringify of the object itself, whose key order is not guaranteed
|
|
58
|
+
* across producers. `tamper` and then `detail` are appended last and only
|
|
59
|
+
* when present, so an envelope without them produces exactly the bytes it
|
|
60
|
+
* did before the fields existed (pinned by a test): old signatures keep
|
|
61
|
+
* verifying. */
|
|
62
|
+
export function canonicalizeLicenseVerdict(envelope) {
|
|
63
|
+
return Buffer.from(JSON.stringify({
|
|
64
|
+
v: envelope.v,
|
|
65
|
+
alg: envelope.alg,
|
|
66
|
+
typ: envelope.typ,
|
|
67
|
+
keyId: envelope.keyId,
|
|
68
|
+
keyHash: envelope.keyHash,
|
|
69
|
+
pluginId: envelope.pluginId,
|
|
70
|
+
domain: envelope.domain,
|
|
71
|
+
nonce: envelope.nonce,
|
|
72
|
+
status: envelope.status,
|
|
73
|
+
reason: envelope.reason ?? null,
|
|
74
|
+
issuedAt: envelope.issuedAt,
|
|
75
|
+
...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
|
|
76
|
+
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
77
|
+
}), "utf8");
|
|
78
|
+
}
|
|
79
|
+
export function signLicenseVerdict(envelope, privateKeyBase64) {
|
|
80
|
+
const key = createPrivateKey({ key: Buffer.from(privateKeyBase64, "base64"), format: "der", type: "pkcs8" });
|
|
81
|
+
return sign(null, canonicalizeLicenseVerdict(envelope), key).toString("base64");
|
|
82
|
+
}
|
|
83
|
+
function isEnvelope(value) {
|
|
84
|
+
if (typeof value !== "object" || value === null)
|
|
85
|
+
return false;
|
|
86
|
+
const e = value;
|
|
87
|
+
return (e.v === 1 &&
|
|
88
|
+
e.alg === "ed25519" &&
|
|
89
|
+
e.typ === "license-verdict" &&
|
|
90
|
+
typeof e.keyId === "string" &&
|
|
91
|
+
typeof e.keyHash === "string" &&
|
|
92
|
+
typeof e.pluginId === "string" &&
|
|
93
|
+
typeof e.domain === "string" &&
|
|
94
|
+
typeof e.nonce === "string" &&
|
|
95
|
+
(e.status === "valid" || e.status === "invalid" || e.status === "revoked") &&
|
|
96
|
+
// A licence server that naturally serialises `reason: row.reason ??
|
|
97
|
+
// null` must not be misread as malformed — null and "absent" mean the
|
|
98
|
+
// same thing here, and are normalized to undefined below once the
|
|
99
|
+
// signature has been checked.
|
|
100
|
+
(e.reason === undefined || e.reason === null || typeof e.reason === "string") &&
|
|
101
|
+
typeof e.issuedAt === "string" &&
|
|
102
|
+
(e.tamper === undefined || (typeof e.tamper === "string" && TAMPER_KINDS.includes(e.tamper))) &&
|
|
103
|
+
(e.detail === undefined || (typeof e.detail === "string" && e.detail.length <= LICENSE_VERDICT_DETAIL_MAX)));
|
|
104
|
+
}
|
|
105
|
+
function isSigned(value) {
|
|
106
|
+
if (typeof value !== "object" || value === null)
|
|
107
|
+
return false;
|
|
108
|
+
const s = value;
|
|
109
|
+
return typeof s.signature === "string" && s.signature.length > 0 && isEnvelope(s.envelope);
|
|
110
|
+
}
|
|
111
|
+
/** The key lookup and signature check, shared by `verifyLicenseVerdict` and
|
|
112
|
+
* `verifyLicenseVerdictSignature` so there is one definition of "authentic". */
|
|
113
|
+
function checkSignature(envelope, signature, trustedKeys) {
|
|
114
|
+
// Re-derive rather than trust the label, exactly as trusted-keys.ts does:
|
|
115
|
+
// an unauthenticated keyId would otherwise let a signature made by one
|
|
116
|
+
// key be attributed to another.
|
|
117
|
+
const match = trustedKeys.find((k) => {
|
|
118
|
+
try {
|
|
119
|
+
return deriveKeyId(k.publicKey) === envelope.keyId;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
if (!match)
|
|
126
|
+
return "untrusted-key";
|
|
127
|
+
try {
|
|
128
|
+
const ok = verify(null, canonicalizeLicenseVerdict(envelope), createPublicKey({ key: Buffer.from(match.publicKey, "base64"), format: "der", type: "spki" }), Buffer.from(signature, "base64"));
|
|
129
|
+
return ok ? "ok" : "bad-signature";
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return "bad-signature";
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Rebuild from only the signed fields rather than returning the caller's
|
|
136
|
+
* object verbatim, so an extra unsigned property the server happened to
|
|
137
|
+
* attach cannot ride along on a result labelled verified. This also
|
|
138
|
+
* normalizes a `reason: null` producer to `undefined`, matching the type,
|
|
139
|
+
* and leaves `tamper` and `detail` out entirely when the envelope had
|
|
140
|
+
* none. */
|
|
141
|
+
function signedFieldsOnly(envelope) {
|
|
142
|
+
return {
|
|
143
|
+
v: envelope.v,
|
|
144
|
+
alg: envelope.alg,
|
|
145
|
+
typ: envelope.typ,
|
|
146
|
+
keyId: envelope.keyId,
|
|
147
|
+
keyHash: envelope.keyHash,
|
|
148
|
+
pluginId: envelope.pluginId,
|
|
149
|
+
domain: envelope.domain,
|
|
150
|
+
nonce: envelope.nonce,
|
|
151
|
+
status: envelope.status,
|
|
152
|
+
reason: envelope.reason ?? undefined,
|
|
153
|
+
issuedAt: envelope.issuedAt,
|
|
154
|
+
...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
|
|
155
|
+
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Verifies a verdict the way a plugin can: the signature against a trusted
|
|
159
|
+
* key, the shape, the `typ`, and `issuedAt` neither older than `maxAgeMs`
|
|
160
|
+
* (default `ENTITLEMENT_MAX_AGE_MS`) before `now` nor later than
|
|
161
|
+
* `MAX_VERDICT_AGE_MS` after it. It does NOT check the nonce, the domain or
|
|
162
|
+
* the key hash: the nonce guards the host's request to the marketplace, and
|
|
163
|
+
* a plugin re-verifying the host's stored verdict never saw that challenge.
|
|
164
|
+
* An authentic `invalid` or `revoked` verdict is `ok: true`; what `status`
|
|
165
|
+
* means is the caller's decision. An unparseable `issuedAt` is `malformed`. */
|
|
166
|
+
export function verifyLicenseVerdictSignature(signed, trustedKeys, opts = {}) {
|
|
167
|
+
if (!isSigned(signed))
|
|
168
|
+
return { ok: false, reason: "malformed" };
|
|
169
|
+
const { envelope, signature } = signed;
|
|
170
|
+
const authentic = checkSignature(envelope, signature, trustedKeys);
|
|
171
|
+
if (authentic === "untrusted-key")
|
|
172
|
+
return { ok: false, reason: "unknown-key" };
|
|
173
|
+
if (authentic === "bad-signature")
|
|
174
|
+
return { ok: false, reason: "bad-signature" };
|
|
175
|
+
const issued = Date.parse(envelope.issuedAt);
|
|
176
|
+
if (!Number.isFinite(issued))
|
|
177
|
+
return { ok: false, reason: "malformed" };
|
|
178
|
+
const nowMs = (opts.now ?? new Date()).getTime();
|
|
179
|
+
const maxAgeMs = opts.maxAgeMs ?? ENTITLEMENT_MAX_AGE_MS;
|
|
180
|
+
if (issued > nowMs + MAX_VERDICT_AGE_MS)
|
|
181
|
+
return { ok: false, reason: "future" };
|
|
182
|
+
if (nowMs - issued > maxAgeMs)
|
|
183
|
+
return { ok: false, reason: "expired" };
|
|
184
|
+
return { ok: true, envelope: signedFieldsOnly(envelope) };
|
|
185
|
+
}
|
|
186
|
+
export function verifyLicenseVerdict(signedVerdict, challenge, trustedKeys, now = new Date()) {
|
|
187
|
+
// A challenge answers at most one question. Consuming it here (before
|
|
188
|
+
// any other check, and regardless of what this call ultimately returns)
|
|
189
|
+
// means a caller cannot probe the same challenge with a sequence of
|
|
190
|
+
// different candidate verdicts, and a caller that legitimately needs to
|
|
191
|
+
// retry is forced to ask a new question (a new challenge) rather than
|
|
192
|
+
// reuse this one.
|
|
193
|
+
if (consumedChallenges.has(challenge)) {
|
|
194
|
+
return { verdict: "unverifiable", reason: "challenge-reused" };
|
|
195
|
+
}
|
|
196
|
+
consumedChallenges.add(challenge);
|
|
197
|
+
if (!isSigned(signedVerdict))
|
|
198
|
+
return { verdict: "unverifiable", reason: "malformed" };
|
|
199
|
+
const { envelope, signature } = signedVerdict;
|
|
200
|
+
const authentic = checkSignature(envelope, signature, trustedKeys);
|
|
201
|
+
if (authentic === "untrusted-key")
|
|
202
|
+
return { verdict: "unverifiable", reason: "untrusted-key" };
|
|
203
|
+
if (authentic === "bad-signature")
|
|
204
|
+
return { verdict: "unverifiable", reason: "bad-signature" };
|
|
205
|
+
// Subject binding. Without this a single genuine "valid" verdict, once
|
|
206
|
+
// captured, would unlock every plugin on every domain — and without the
|
|
207
|
+
// nonce comparison specifically, it would unlock every future request
|
|
208
|
+
// too, regardless of issuedAt. A verdict answering a different challenge
|
|
209
|
+
// is exactly as wrong as one for a different plugin.
|
|
210
|
+
if (envelope.keyHash !== challenge.keyHash ||
|
|
211
|
+
envelope.pluginId !== challenge.pluginId ||
|
|
212
|
+
envelope.domain !== challenge.domain ||
|
|
213
|
+
envelope.nonce !== challenge.nonce) {
|
|
214
|
+
return { verdict: "unverifiable", reason: "subject-mismatch" };
|
|
215
|
+
}
|
|
216
|
+
// Symmetric on purpose: a future-dated issuedAt is just as much a lie as
|
|
217
|
+
// a stale one, and one-sided staleness checks pass it forever.
|
|
218
|
+
const issued = Date.parse(envelope.issuedAt);
|
|
219
|
+
if (!Number.isFinite(issued) || Math.abs(now.getTime() - issued) > MAX_VERDICT_AGE_MS) {
|
|
220
|
+
return { verdict: "unverifiable", reason: "stale" };
|
|
221
|
+
}
|
|
222
|
+
const verifiedEnvelope = signedFieldsOnly(envelope);
|
|
223
|
+
// Authentication is done; now, and only now, does the envelope's own
|
|
224
|
+
// `status` decide the verdict. `"valid"` is the sole branch a caller can
|
|
225
|
+
// use to unlock something — `"invalid"` and `"revoked"` are just as
|
|
226
|
+
// authentic but must never reach an `unlock()` call.
|
|
227
|
+
if (verifiedEnvelope.status === "valid") {
|
|
228
|
+
return { verdict: "licensed", envelope: verifiedEnvelope };
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
verdict: "unlicensed",
|
|
232
|
+
status: verifiedEnvelope.status,
|
|
233
|
+
reason: verifiedEnvelope.reason,
|
|
234
|
+
envelope: verifiedEnvelope,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const COVER_PATH = "marketplace/cover.png";
|
|
2
|
+
export declare const COVER_WIDTH = 1200;
|
|
3
|
+
export declare const COVER_HEIGHT = 630;
|
|
4
|
+
/** Width/height from a PNG's IHDR, or null when the bytes are not a PNG.
|
|
5
|
+
* Reading the header directly avoids an image dependency for what is two
|
|
6
|
+
* big-endian integers at fixed offsets. */
|
|
7
|
+
export declare function pngSize(bytes: Buffer): {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
} | null;
|
|
11
|
+
export type PackageContractCheck = {
|
|
12
|
+
ok: true;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
reason: string;
|
|
16
|
+
reasons: string[];
|
|
17
|
+
};
|
|
18
|
+
/** The door-level gate's answer: the README, cover and docs verdict, with
|
|
19
|
+
* the docs contract's warnings beside it. A warning never refuses. */
|
|
20
|
+
export type PackageContractResult = PackageContractCheck & {
|
|
21
|
+
warnings: string[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* <dir>/README.md must exist and contain something other than whitespace —
|
|
25
|
+
* a file that exists but says nothing is worse than none: it would render
|
|
26
|
+
* as a blank listing description in the marketplace.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkReadmeContract(dir: string): PackageContractCheck;
|
|
29
|
+
/**
|
|
30
|
+
* <dir>/marketplace/cover.png must exist, be a real PNG, and be exactly
|
|
31
|
+
* COVER_WIDTH x COVER_HEIGHT — the marketplace grid renders every listing's
|
|
32
|
+
* cover at a fixed aspect, so anything else would be cropped or distorted.
|
|
33
|
+
* The failure reason names both the required size and the size found,
|
|
34
|
+
* since "wrong size" without the numbers makes a developer guess.
|
|
35
|
+
*/
|
|
36
|
+
export declare function checkCoverContract(dir: string): PackageContractCheck;
|
|
37
|
+
/**
|
|
38
|
+
* The combined door-level gate. It reports every violation, because an author
|
|
39
|
+
* fixing a package should see the whole list in one run: the README's, the
|
|
40
|
+
* cover's, and, when the package has a manifest.json, the docs contract's
|
|
41
|
+
* (a package with no manifest.json is reported by each caller itself).
|
|
42
|
+
* `reason` is the first of `reasons`, for callers that show one line.
|
|
43
|
+
* It runs on a package nobody has vetted, so a wrong shape (a directory where
|
|
44
|
+
* a file belongs, a file where `docs` belongs) is a violation, never an
|
|
45
|
+
* exception, and the list is capped at MAX_VIOLATIONS lines, the last one
|
|
46
|
+
* counting the rest.
|
|
47
|
+
* Callers that need each rule's independent pass/fail (kardalum plugin's
|
|
48
|
+
* `validate` report) call checkReadmeContract and checkCoverContract directly.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkPackageContract(dir: string): PackageContractResult;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { capViolations, checkDocsContract, isFile, readDocsContractInput } from "./docs-contract.js";
|
|
4
|
+
// S206 Task 4: the marketplace-listing contract — a non-empty README.md
|
|
5
|
+
// plus a fixed-size cover image: used to live only in kardalum plugin's CLI
|
|
6
|
+
// (packages/cli/src/plugin/checks/package-contract.ts), a dev-machine
|
|
7
|
+
// package apps/server can't import from. Moved here because
|
|
8
|
+
// @kardalum/plugin-package is the one package apps/server, apps/marketplace,
|
|
9
|
+
// AND kardalum plugin all already depend on: one implementation, no second
|
|
10
|
+
// place to keep in sync. kardalum plugin's checks/package-contract.ts now
|
|
11
|
+
// delegates to checkReadmeContract/checkCoverContract below rather than
|
|
12
|
+
// keeping its own copy — see that file for why its two exports keep their
|
|
13
|
+
// original names, CheckResult shape, and exact failure messages (its own
|
|
14
|
+
// tests, and `kardalum plugin validate`'s output, depend on them).
|
|
15
|
+
//
|
|
16
|
+
// checkPackageContract is the door-level gate: the server's upload route
|
|
17
|
+
// (apps/server/src/routes/plugin-upload.ts) just needs "does this package
|
|
18
|
+
// qualify, and if not, why" — it has no use for which of the two rules
|
|
19
|
+
// failed independently the way kardalum plugin's per-check report does.
|
|
20
|
+
export const COVER_PATH = "marketplace/cover.png";
|
|
21
|
+
export const COVER_WIDTH = 1200;
|
|
22
|
+
export const COVER_HEIGHT = 630;
|
|
23
|
+
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
24
|
+
/** Width/height from a PNG's IHDR, or null when the bytes are not a PNG.
|
|
25
|
+
* Reading the header directly avoids an image dependency for what is two
|
|
26
|
+
* big-endian integers at fixed offsets. */
|
|
27
|
+
export function pngSize(bytes) {
|
|
28
|
+
if (bytes.length < 24 || !bytes.subarray(0, 8).equals(PNG_SIGNATURE))
|
|
29
|
+
return null;
|
|
30
|
+
return { width: bytes.readUInt32BE(16), height: bytes.readUInt32BE(20) };
|
|
31
|
+
}
|
|
32
|
+
function fail(reasons) {
|
|
33
|
+
return { ok: false, reason: reasons[0], reasons };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* <dir>/README.md must exist and contain something other than whitespace —
|
|
37
|
+
* a file that exists but says nothing is worse than none: it would render
|
|
38
|
+
* as a blank listing description in the marketplace.
|
|
39
|
+
*/
|
|
40
|
+
export function checkReadmeContract(dir) {
|
|
41
|
+
const filePath = join(dir, "README.md");
|
|
42
|
+
if (!existsSync(filePath)) {
|
|
43
|
+
return fail(["README.md is missing: required for the marketplace listing"]);
|
|
44
|
+
}
|
|
45
|
+
// A directory of that name is not a README, and reading it would throw.
|
|
46
|
+
if (!isFile(filePath)) {
|
|
47
|
+
return fail(["README.md is not a file"]);
|
|
48
|
+
}
|
|
49
|
+
const content = readFileSync(filePath, "utf8");
|
|
50
|
+
if (content.trim().length === 0) {
|
|
51
|
+
return fail(["README.md is empty: it would render as a blank listing description"]);
|
|
52
|
+
}
|
|
53
|
+
return { ok: true };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* <dir>/marketplace/cover.png must exist, be a real PNG, and be exactly
|
|
57
|
+
* COVER_WIDTH x COVER_HEIGHT — the marketplace grid renders every listing's
|
|
58
|
+
* cover at a fixed aspect, so anything else would be cropped or distorted.
|
|
59
|
+
* The failure reason names both the required size and the size found,
|
|
60
|
+
* since "wrong size" without the numbers makes a developer guess.
|
|
61
|
+
*/
|
|
62
|
+
export function checkCoverContract(dir) {
|
|
63
|
+
const filePath = join(dir, COVER_PATH);
|
|
64
|
+
if (!existsSync(filePath)) {
|
|
65
|
+
return fail([`${COVER_PATH} is missing: required for the marketplace listing`]);
|
|
66
|
+
}
|
|
67
|
+
if (!isFile(filePath)) {
|
|
68
|
+
return fail([`${COVER_PATH} is not a file`]);
|
|
69
|
+
}
|
|
70
|
+
const bytes = readFileSync(filePath);
|
|
71
|
+
const size = pngSize(bytes);
|
|
72
|
+
if (size === null) {
|
|
73
|
+
return fail([`${COVER_PATH} is not a valid PNG file`]);
|
|
74
|
+
}
|
|
75
|
+
if (size.width !== COVER_WIDTH || size.height !== COVER_HEIGHT) {
|
|
76
|
+
return fail([
|
|
77
|
+
`${COVER_PATH} is ${size.width}x${size.height}, ` +
|
|
78
|
+
`but the marketplace requires exactly ${COVER_WIDTH}x${COVER_HEIGHT}`,
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
return { ok: true };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The combined door-level gate. It reports every violation, because an author
|
|
85
|
+
* fixing a package should see the whole list in one run: the README's, the
|
|
86
|
+
* cover's, and, when the package has a manifest.json, the docs contract's
|
|
87
|
+
* (a package with no manifest.json is reported by each caller itself).
|
|
88
|
+
* `reason` is the first of `reasons`, for callers that show one line.
|
|
89
|
+
* It runs on a package nobody has vetted, so a wrong shape (a directory where
|
|
90
|
+
* a file belongs, a file where `docs` belongs) is a violation, never an
|
|
91
|
+
* exception, and the list is capped at MAX_VIOLATIONS lines, the last one
|
|
92
|
+
* counting the rest.
|
|
93
|
+
* Callers that need each rule's independent pass/fail (kardalum plugin's
|
|
94
|
+
* `validate` report) call checkReadmeContract and checkCoverContract directly.
|
|
95
|
+
*/
|
|
96
|
+
export function checkPackageContract(dir) {
|
|
97
|
+
const reasons = [];
|
|
98
|
+
const warnings = [];
|
|
99
|
+
for (const check of [checkReadmeContract(dir), checkCoverContract(dir)]) {
|
|
100
|
+
if (!check.ok)
|
|
101
|
+
reasons.push(...check.reasons);
|
|
102
|
+
}
|
|
103
|
+
if (existsSync(join(dir, "manifest.json"))) {
|
|
104
|
+
const docs = readDocsContractInput(dir);
|
|
105
|
+
if (!docs.ok)
|
|
106
|
+
reasons.push(...docs.reasons);
|
|
107
|
+
else {
|
|
108
|
+
const found = checkDocsContract(dir, docs.input);
|
|
109
|
+
reasons.push(...found.reasons);
|
|
110
|
+
warnings.push(...found.warnings);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const cappedWarnings = capViolations(warnings);
|
|
114
|
+
return reasons.length === 0 ? { ok: true, warnings: cappedWarnings } : { ...fail(capViolations(reasons)), warnings: cappedWarnings };
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SAMPLE_CONTENT_MEDIA_FILE_PATTERN: RegExp;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// A template plugin's sample-content.json declares media[].file as
|
|
2
|
+
// "media/" plus a flat, traversal-free filename — this is the ONE
|
|
3
|
+
// definition both sides that parse that shape validate against, so they
|
|
4
|
+
// can never drift apart the way two hand-copied literal-twin regexes did
|
|
5
|
+
// (S199 review Minor c). Without this constraint, a `file` of
|
|
6
|
+
// "../../.env" would resolve outside the plugin package and get uploaded
|
|
7
|
+
// as a PUBLIC media record.
|
|
8
|
+
//
|
|
9
|
+
// Consumers:
|
|
10
|
+
// - apps/server/src/plugins/seed-template-content.ts
|
|
11
|
+
// (SampleContentFileSchema's media[].file Zod regex — the host-side
|
|
12
|
+
// seeder that actually uploads the files at install time)
|
|
13
|
+
// - packages/cli/src/plugin/checks/templates.ts
|
|
14
|
+
// (parseSampleContentFile's own check: the author-side `kardalum plugin
|
|
15
|
+
// validate` command that catches this before a plugin is ever
|
|
16
|
+
// packaged)
|
|
17
|
+
export const SAMPLE_CONTENT_MEDIA_FILE_PATTERN = /^media\/[A-Za-z0-9._-]+$/;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The signed payload. Field order here is normative — canonicalizeEnvelope
|
|
2
|
+
* serializes in exactly this order, and signer and verifier must agree byte
|
|
3
|
+
* for byte. */
|
|
4
|
+
export interface SignatureEnvelope {
|
|
5
|
+
v: 1;
|
|
6
|
+
alg: "ed25519";
|
|
7
|
+
/** First 16 hex chars of sha256(raw 32-byte public key). Derived, never
|
|
8
|
+
* assigned, so the marketplace's DB row and the CMS's trusted set cannot
|
|
9
|
+
* drift. */
|
|
10
|
+
keyId: string;
|
|
11
|
+
pluginId: string;
|
|
12
|
+
version: string;
|
|
13
|
+
/** sha256 hex of the .zip artifact this envelope describes. */
|
|
14
|
+
sha256: string;
|
|
15
|
+
}
|
|
16
|
+
/** The contents of the detached `<name>.zip.sig` sidecar, and of
|
|
17
|
+
* PluginVersion.signature. */
|
|
18
|
+
export interface PackageSignatureSidecar {
|
|
19
|
+
envelope: SignatureEnvelope;
|
|
20
|
+
/** base64 Ed25519 signature over canonicalizeEnvelope(envelope). */
|
|
21
|
+
signature: string;
|
|
22
|
+
}
|
|
23
|
+
/** A public key the CMS is configured to trust. publicKey is base64 SPKI
|
|
24
|
+
* DER. */
|
|
25
|
+
export interface TrustedKey {
|
|
26
|
+
keyId: string;
|
|
27
|
+
publicKey: string;
|
|
28
|
+
}
|
|
29
|
+
export type VerifyFailureReason = "malformed-sidecar" | "no-trusted-keys" | "unknown-key" | "bad-signature" | "hash-mismatch" | "identity-mismatch"
|
|
30
|
+
/** The artifact itself could not be read (missing, unreadable, permission
|
|
31
|
+
* denied, or a mid-read failure) — nothing could be verified about it,
|
|
32
|
+
* since hashing never completed. Distinct from hash-mismatch, which
|
|
33
|
+
* requires a hash to have actually been computed and compared. */
|
|
34
|
+
| "artifact-unreadable";
|
|
35
|
+
export type VerifyResult = {
|
|
36
|
+
status: "verified";
|
|
37
|
+
keyId: string;
|
|
38
|
+
envelope: SignatureEnvelope;
|
|
39
|
+
} | {
|
|
40
|
+
status: "unsigned";
|
|
41
|
+
} | {
|
|
42
|
+
status: "failed";
|
|
43
|
+
reason: VerifyFailureReason;
|
|
44
|
+
message: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kardalum/plugin-package",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22.12"
|
|
7
|
+
},
|
|
8
|
+
"description": "Plugin package + signing toolchain for Kardalum CMS",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"!dist/**/*.test.*"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/kardalum/kardalum-starter.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/kardalum/kardalum-starter/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://kardalum.com",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"yauzl": "3.4.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "22.20.1",
|
|
37
|
+
"@types/yauzl": "^3.4.0",
|
|
38
|
+
"@types/yazl": "^3.3.1",
|
|
39
|
+
"typescript": "6.0.3",
|
|
40
|
+
"vitest": "3.2.6",
|
|
41
|
+
"yauzl": "3.4.0",
|
|
42
|
+
"yazl": "^3.3.1",
|
|
43
|
+
"@kardalum/api-schemas": "0.14.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p .",
|
|
47
|
+
"test": "vitest run"
|
|
48
|
+
}
|
|
49
|
+
}
|