@kardalum/plugin-sdk 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/README.md +4 -3
- package/dist/admin-section-registry.d.ts +14 -5
- package/dist/admin-section-registry.js +14 -4
- package/dist/assets/asset-picker.d.ts +11 -0
- package/dist/assets/asset-picker.js +109 -0
- package/dist/assets/asset-tree.d.ts +30 -0
- package/dist/assets/asset-tree.js +150 -0
- package/dist/built-in-editor-ids.d.ts +1 -0
- package/dist/built-in-editor-ids.js +20 -0
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +27 -0
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +10 -1
- package/dist/capabilities.js +5 -3
- package/dist/datatype-validation.js +18 -4
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/entitlement-entry.d.ts +3 -2
- package/dist/entitlement-entry.js +13 -1
- package/dist/entitlement-gate.d.ts +18 -0
- package/dist/entitlement-gate.js +95 -21
- package/dist/entitlement-plan.d.ts +21 -0
- package/dist/entitlement-plan.js +26 -0
- package/dist/entitlement-types.d.ts +21 -4
- package/dist/entitlement.d.ts +29 -1
- package/dist/entitlement.js +39 -0
- package/dist/grid-arrow-step.d.ts +7 -0
- package/dist/grid-arrow-step.js +20 -0
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +13 -18
- package/dist/license-verdict-keys.d.ts +4 -3
- package/dist/license-verdict-keys.js +4 -7
- package/dist/manifest-entry.d.ts +6 -2
- package/dist/manifest-entry.js +5 -1
- package/dist/manifest-schema.d.ts +56 -63
- package/dist/manifest-schema.js +103 -249
- package/dist/manifest.d.ts +61 -73
- package/dist/manifest.js +13 -36
- package/dist/media/media-picker.js +32 -32
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- package/dist/plugin-screen-context.d.ts +11 -1
- package/dist/richtext/block-panel.js +19 -20
- package/dist/richtext/extensions.js +10 -1
- package/dist/richtext/insert-menu.js +1 -1
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +4 -4
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/structured-storage-types.d.ts +11 -0
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +2 -0
- package/dist/tokens/tokens.json +4 -2
- package/dist/type-equality.d.ts +2 -0
- package/dist/type-equality.js +1 -0
- package/dist/vendor-check.d.ts +39 -0
- package/dist/vendor-check.js +79 -0
- package/dist/vendor-entry.d.ts +3 -0
- package/dist/vendor-entry.js +9 -0
- package/dist/vendor-service.d.ts +20 -0
- package/dist/vendor-service.js +20 -0
- package/dist/views/asset-view.d.ts +6 -0
- package/dist/views/asset-view.js +55 -0
- package/dist/views/content-list-settings-view.js +1 -1
- package/dist/views/content-list-view.js +1 -1
- package/dist/views/html-code-editor.js +0 -1
- package/dist/views/html-view.js +1 -1
- package/dist/views/image-view.js +1 -1
- package/dist/views/rich-text-view.js +30 -30
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +43 -10
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +60 -18
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +22 -6
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +52 -10
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +33 -14
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
- package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +73 -31
- package/node_modules/@kardalum/api-schemas/dist/index.js +47 -17
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +216 -63
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +117 -5
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +8 -18
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +3 -19
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -15
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +97 -85
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +35 -68
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +9 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +22 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +240 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +164 -32
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +4 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +152 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +35 -23
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +11 -2
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +21 -3
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +6 -6
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +58 -25
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +194 -48
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +18 -6
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +115 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +65 -10
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +37 -2
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +34 -8
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +16 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -2
- package/node_modules/@kardalum/design-tokens/README.md +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +4 -2
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -0
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- package/node_modules/@kardalum/plugin-package/README.md +5 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +6 -21
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +13 -8
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +59 -16
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +77 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +137 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +215 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -4
- package/node_modules/@kardalum/plugin-package/dist/index.js +10 -3
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +21 -3
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +37 -9
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
- package/node_modules/@kardalum/plugin-package/package.json +4 -2
- package/node_modules/@kardalum/ui/README.md +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
- package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
- package/node_modules/@kardalum/ui/dist/index.js +1 -0
- package/node_modules/@kardalum/ui/package.json +1 -1
- package/package.json +19 -6
package/dist/capabilities.js
CHANGED
|
@@ -35,9 +35,10 @@ export const CAPABILITY_LABELS = {
|
|
|
35
35
|
"admin.section": { operator: "Admin sections", shopper: "Adds admin screens" },
|
|
36
36
|
"admin.railEntry": { operator: "Admin rail entries", shopper: "Adds screens to built-in sections" },
|
|
37
37
|
"admin.dashboardWidget": { operator: "Dashboard widgets", shopper: "Adds dashboard widgets" },
|
|
38
|
-
"admin.
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
"admin.notifications": {
|
|
39
|
+
operator: "Notifications",
|
|
40
|
+
shopper: "Sends notifications to people in the admin, for example to everyone who may publish.",
|
|
41
|
+
},
|
|
41
42
|
"render.template": { operator: "Render templates", shopper: "Ships render templates" },
|
|
42
43
|
"render.asset": { operator: "Editable assets", shopper: "Ships editable assets" },
|
|
43
44
|
"theme.tokens": { operator: "Theme tokens", shopper: "Restyles the admin" },
|
|
@@ -52,6 +53,7 @@ export const CAPABILITY_LABELS = {
|
|
|
52
53
|
"bundle.plugin": { operator: "Bundled plugins", shopper: "Installs other plugins with it" },
|
|
53
54
|
"bundle.template": { operator: "Bundled starter", shopper: "Comes with a frontend starter" },
|
|
54
55
|
"network.external": { operator: "External network", shopper: "Reaches the network" },
|
|
56
|
+
"network.vendorService": { operator: "Vendor service", shopper: "Serves its paid features from the author's server" },
|
|
55
57
|
"filesystem.access": { operator: "Filesystem access", shopper: "Reads or writes files" },
|
|
56
58
|
};
|
|
57
59
|
/**
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// dependency-free: the SERVER imports this module to build its validator
|
|
3
|
-
// lookup, and anything React-shaped here would drag the admin's UI graph
|
|
4
|
-
// into plugin artifacts (the S197 F5 lesson).
|
|
1
|
+
import { AssetPathSchema, assetPathAccepted } from "@kardalum/api-schemas";
|
|
5
2
|
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
6
3
|
// A member reads as its string, as null (absent), or as MALFORMED when it
|
|
7
4
|
// is present but not a string at all. Keeping the two failure modes apart
|
|
@@ -107,4 +104,21 @@ export const BUILT_IN_DATATYPE_VALIDATORS = {
|
|
|
107
104
|
"com.kardalum.thumbnail": {
|
|
108
105
|
isEmpty: () => true,
|
|
109
106
|
},
|
|
107
|
+
// S314p (D3). An Asset field holds a path under public/, the way Settings, Assets names a file.
|
|
108
|
+
// Its form is AssetPathSchema's (no "..", no hidden file, no reserved root); a type that takes
|
|
109
|
+
// images only also wants one of the image extensions. Whether the file exists is not asked
|
|
110
|
+
// (spec C6): a script may write the page before it uploads the kit's files, and the field shows a
|
|
111
|
+
// missing file instead.
|
|
112
|
+
"com.kardalum.asset": {
|
|
113
|
+
defaultSettings: { accepts: "images", startFolder: null },
|
|
114
|
+
isEmpty: (value) => value === null || value === undefined || value === "",
|
|
115
|
+
validate(value, { settings }) {
|
|
116
|
+
if (typeof value !== "string" || !AssetPathSchema.safeParse(value).success) {
|
|
117
|
+
return [{ key: "dataTypes.asset.errors.invalidPath" }];
|
|
118
|
+
}
|
|
119
|
+
if (!assetPathAccepted(value, settings.accepts))
|
|
120
|
+
return [{ key: "dataTypes.asset.errors.notAnImage" }];
|
|
121
|
+
return [];
|
|
122
|
+
},
|
|
123
|
+
},
|
|
110
124
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BUILT_IN_SETTINGS_SCHEMAS } from "./built-in-settings-schemas.js";
|
|
2
2
|
export { BUILT_IN_VALUE_SCHEMAS } from "./built-in-value-schemas.js";
|
|
3
|
+
export { BUILT_IN_EDITOR_IDS } from "./built-in-editor-ids.js";
|
|
3
4
|
export { BUILT_IN_SERIALIZERS, identitySerializer, type DataTypeSerializer, } from "./built-in-serializers.js";
|
|
4
5
|
export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "./rendition-eligibility.js";
|
package/dist/datatypes-entry.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// one.
|
|
10
10
|
export { BUILT_IN_SETTINGS_SCHEMAS } from "./built-in-settings-schemas.js";
|
|
11
11
|
export { BUILT_IN_VALUE_SCHEMAS } from "./built-in-value-schemas.js";
|
|
12
|
+
export { BUILT_IN_EDITOR_IDS } from "./built-in-editor-ids.js";
|
|
12
13
|
export { BUILT_IN_SERIALIZERS, identitySerializer, } from "./built-in-serializers.js";
|
|
13
14
|
// S234c fix wave: the "no GIF, no SVG" rule, read by the cut route so a
|
|
14
15
|
// signed-in caller cannot post a "crop" of a format the browser refuses to
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { EntitlementError, ENTITLEMENT_FLOOR_TABLE, isEntitlementError, requireEntitlement, structuredStorageFloor, type EntitlementFloor, type RequireEntitlementOptions, } from "./entitlement.js";
|
|
1
|
+
export { EntitlementError, ENTITLEMENT_FLOOR_TABLE, entitlementPlan, isEntitlementError, requireEntitlement, structuredStorageFloor, type EntitlementFloor, type EntitlementPlanOptions, type RequireEntitlementOptions, } from "./entitlement.js";
|
|
2
|
+
export { highestListingPlan, UNKNOWN_TERM, type EntitlementPlan } from "./entitlement-plan.js";
|
|
2
3
|
export { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
3
4
|
export { isLocalHost } from "./local-host.js";
|
|
4
|
-
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, LicenseVerdictEnvelope, PluginTaskContext, } from "./entitlement-types.js";
|
|
5
|
+
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, LicenseVerdictEnvelope, LicenseVerdictTerm, ListingPlanSummary, PluginTaskContext, } from "./entitlement-types.js";
|
|
5
6
|
export type { TrustedKey } from "@kardalum/plugin-package";
|
|
@@ -19,6 +19,18 @@
|
|
|
19
19
|
//
|
|
20
20
|
// The host turns a thrown EntitlementError into a 403 for a route and skips
|
|
21
21
|
// a hook that throws it.
|
|
22
|
-
|
|
22
|
+
//
|
|
23
|
+
// S317: the plan and the term, after the check passed:
|
|
24
|
+
//
|
|
25
|
+
// const plan = entitlementPlan(context.entitlement, { pluginId: "com.acme.reports" });
|
|
26
|
+
// if (plan?.planId === "pro") { ... }
|
|
27
|
+
// if (plan?.term.state === "lapsed") { refuse writes, keep reads }
|
|
28
|
+
//
|
|
29
|
+
// S318: while the term is lapsed the host itself refuses the plugin's writes
|
|
30
|
+
// (403 plugin_read_only), and tells a route or hook so:
|
|
31
|
+
//
|
|
32
|
+
// if (context.readOnly) { skip writes }
|
|
33
|
+
export { EntitlementError, ENTITLEMENT_FLOOR_TABLE, entitlementPlan, isEntitlementError, requireEntitlement, structuredStorageFloor, } from "./entitlement.js";
|
|
34
|
+
export { highestListingPlan, UNKNOWN_TERM } from "./entitlement-plan.js";
|
|
23
35
|
export { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
24
36
|
export { isLocalHost } from "./local-host.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type JSX, type ReactNode } from "react";
|
|
2
2
|
import type { TrustedKey } from "@kardalum/plugin-package";
|
|
3
|
+
import type { EntitlementPlan } from "./entitlement-plan.js";
|
|
3
4
|
import type { EntitlementErrorCode, LicenseVerdictEnvelope } from "./entitlement-types.js";
|
|
4
5
|
export declare const BROWSER_ENTITLEMENT_MAX_AGE_MS: number;
|
|
5
6
|
export declare const BROWSER_MAX_VERDICT_AGE_MS: number;
|
|
@@ -7,6 +8,10 @@ export type EntitlementStatus = "loading" | "entitled" | "locked";
|
|
|
7
8
|
export interface UseEntitlementResult {
|
|
8
9
|
status: EntitlementStatus;
|
|
9
10
|
reason?: EntitlementErrorCode;
|
|
11
|
+
/** S317: the plan and term, when entitled; plan unknown when this browser cannot verify the term (plan P9). */
|
|
12
|
+
plan?: EntitlementPlan;
|
|
13
|
+
/** S318: true when the verified term is lapsed: the host refuses writes, so disable Save actions. */
|
|
14
|
+
readOnly: boolean;
|
|
10
15
|
}
|
|
11
16
|
/** The exact bytes the marketplace signs, built the way
|
|
12
17
|
* @kardalum/plugin-package's `canonicalizeLicenseVerdict` builds them
|
|
@@ -15,12 +20,25 @@ export interface UseEntitlementResult {
|
|
|
15
20
|
* module that imports node:crypto; entitlement-gate.test.tsx pins this to
|
|
16
21
|
* its output for the same envelopes, so the two cannot drift silently. */
|
|
17
22
|
export declare function canonicalLicenseVerdictBytes(envelope: LicenseVerdictEnvelope): Uint8Array<ArrayBuffer>;
|
|
23
|
+
/** S317: the bytes `termSignature` covers, built the way
|
|
24
|
+
* @kardalum/plugin-package's `canonicalizeLicenseVerdictTerm` builds them
|
|
25
|
+
* (the version 1 fields, then `planId` and `term`, null when absent). A
|
|
26
|
+
* copy for the same reason as above; entitlement-gate.test.tsx pins it. */
|
|
27
|
+
export declare function canonicalLicenseVerdictTermBytes(envelope: LicenseVerdictEnvelope): Uint8Array<ArrayBuffer>;
|
|
18
28
|
/** true or false when this browser could check the signature itself; null
|
|
19
29
|
* when it cannot import an Ed25519 key, and the host's answer stands in. */
|
|
20
30
|
export declare function verifyEntitlementInBrowser(entitlement: {
|
|
21
31
|
envelope: LicenseVerdictEnvelope;
|
|
22
32
|
signature: string;
|
|
23
33
|
}, trustedKeys: TrustedKey[]): Promise<boolean | null>;
|
|
34
|
+
/** S317: true when the envelope carries a well-formed plan or term and its
|
|
35
|
+
* `termSignature` verifies; false when it carries none or the signature is
|
|
36
|
+
* wrong; null when this browser cannot check it (plan P9: the plan then
|
|
37
|
+
* reads as unknown). */
|
|
38
|
+
export declare function verifyTermInBrowser(entitlement: {
|
|
39
|
+
envelope: LicenseVerdictEnvelope;
|
|
40
|
+
termSignature?: string;
|
|
41
|
+
}, trustedKeys: TrustedKey[]): Promise<boolean | null>;
|
|
24
42
|
/** `entitled` for `exempt` (a non-production install) on a page served from
|
|
25
43
|
* a local host, and `locked` with `missing` for `exempt` anywhere else and
|
|
26
44
|
* for `none` (no verdict held); a `verdict` is verified as above. A host answer the view cannot read at all (no session, an unknown
|
package/dist/entitlement-gate.js
CHANGED
|
@@ -16,7 +16,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
16
16
|
// is absent. There is no floor in the browser: the view gate is the visible
|
|
17
17
|
// half, the server route's `requireEntitlement` is the one that guards the
|
|
18
18
|
// work.
|
|
19
|
+
//
|
|
20
|
+
// Since S317 the result carries `plan` beside the status: the signed plan
|
|
21
|
+
// and term when this browser verified their `termSignature`, otherwise plan
|
|
22
|
+
// unknown, term active.
|
|
19
23
|
import { useEffect, useState } from "react";
|
|
24
|
+
import { highestListingPlan, planFromEnvelope, UNKNOWN_TERM } from "./entitlement-plan.js";
|
|
20
25
|
import { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
21
26
|
import { isLocalHost } from "./local-host.js";
|
|
22
27
|
import { usePluginApi } from "./plugin-context.js";
|
|
@@ -48,6 +53,32 @@ export function canonicalLicenseVerdictBytes(envelope) {
|
|
|
48
53
|
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
49
54
|
}));
|
|
50
55
|
}
|
|
56
|
+
/** S317: the bytes `termSignature` covers, built the way
|
|
57
|
+
* @kardalum/plugin-package's `canonicalizeLicenseVerdictTerm` builds them
|
|
58
|
+
* (the version 1 fields, then `planId` and `term`, null when absent). A
|
|
59
|
+
* copy for the same reason as above; entitlement-gate.test.tsx pins it. */
|
|
60
|
+
export function canonicalLicenseVerdictTermBytes(envelope) {
|
|
61
|
+
const term = envelope.term;
|
|
62
|
+
return new TextEncoder().encode(JSON.stringify({
|
|
63
|
+
v: envelope.v,
|
|
64
|
+
alg: envelope.alg,
|
|
65
|
+
typ: envelope.typ,
|
|
66
|
+
keyId: envelope.keyId,
|
|
67
|
+
keyHash: envelope.keyHash,
|
|
68
|
+
pluginId: envelope.pluginId,
|
|
69
|
+
domain: envelope.domain,
|
|
70
|
+
nonce: envelope.nonce,
|
|
71
|
+
status: envelope.status,
|
|
72
|
+
reason: envelope.reason ?? null,
|
|
73
|
+
issuedAt: envelope.issuedAt,
|
|
74
|
+
...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
|
|
75
|
+
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
76
|
+
planId: envelope.planId ?? null,
|
|
77
|
+
term: term === undefined
|
|
78
|
+
? null
|
|
79
|
+
: { state: term.state, endsAt: term.endsAt, renewalAmountCents: term.renewalAmountCents, cancelAtPeriodEnd: term.cancelAtPeriodEnd },
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
51
82
|
function base64ToBytes(value) {
|
|
52
83
|
const binary = atob(value);
|
|
53
84
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -76,9 +107,9 @@ function looksLikeVerdict(value) {
|
|
|
76
107
|
typeof e.issuedAt === "string");
|
|
77
108
|
}
|
|
78
109
|
const ED25519_SPKI_LENGTH = 44;
|
|
79
|
-
/** true or false when this browser could check
|
|
80
|
-
* when it cannot import an Ed25519 key
|
|
81
|
-
|
|
110
|
+
/** true or false when this browser could check `signature` over `bytes`
|
|
111
|
+
* itself; null when it cannot import an Ed25519 key. */
|
|
112
|
+
async function verifyBytesInBrowser(keyId, signatureB64, bytes, trustedKeys) {
|
|
82
113
|
const subtle = globalThis.crypto?.subtle;
|
|
83
114
|
if (!subtle)
|
|
84
115
|
return null;
|
|
@@ -96,7 +127,7 @@ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
|
96
127
|
// Re-derive the key id from the raw key, as the server does: the
|
|
97
128
|
// listed keyId is a label, the key is the fact.
|
|
98
129
|
const derivedId = toHex(await subtle.digest("SHA-256", der.slice(12))).slice(0, 16);
|
|
99
|
-
if (derivedId !==
|
|
130
|
+
if (derivedId !== keyId)
|
|
100
131
|
continue;
|
|
101
132
|
let key;
|
|
102
133
|
try {
|
|
@@ -107,12 +138,12 @@ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
|
107
138
|
}
|
|
108
139
|
let signature;
|
|
109
140
|
try {
|
|
110
|
-
signature = base64ToBytes(
|
|
141
|
+
signature = base64ToBytes(signatureB64);
|
|
111
142
|
}
|
|
112
143
|
catch {
|
|
113
144
|
return false;
|
|
114
145
|
}
|
|
115
|
-
return await subtle.verify({ name: "Ed25519" }, key, signature,
|
|
146
|
+
return await subtle.verify({ name: "Ed25519" }, key, signature, bytes);
|
|
116
147
|
}
|
|
117
148
|
return false;
|
|
118
149
|
}
|
|
@@ -120,22 +151,56 @@ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
|
120
151
|
return null;
|
|
121
152
|
}
|
|
122
153
|
}
|
|
154
|
+
/** true or false when this browser could check the signature itself; null
|
|
155
|
+
* when it cannot import an Ed25519 key, and the host's answer stands in. */
|
|
156
|
+
export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
157
|
+
return verifyBytesInBrowser(entitlement.envelope.keyId, entitlement.signature, canonicalLicenseVerdictBytes(entitlement.envelope), trustedKeys);
|
|
158
|
+
}
|
|
159
|
+
const TERM_STATES = ["active", "renewing", "past_due", "lapsed"];
|
|
160
|
+
function termShapeOk(envelope) {
|
|
161
|
+
const planId = envelope.planId;
|
|
162
|
+
const term = envelope.term;
|
|
163
|
+
if (planId === undefined && term === undefined)
|
|
164
|
+
return false;
|
|
165
|
+
if (planId !== undefined && (typeof planId !== "string" || planId.length === 0 || planId.length > 64))
|
|
166
|
+
return false;
|
|
167
|
+
if (term === undefined)
|
|
168
|
+
return true;
|
|
169
|
+
if (typeof term !== "object" || term === null)
|
|
170
|
+
return false;
|
|
171
|
+
const t = term;
|
|
172
|
+
return (typeof t.state === "string" && TERM_STATES.includes(t.state) &&
|
|
173
|
+
(t.endsAt === null || (typeof t.endsAt === "string" && Number.isFinite(Date.parse(t.endsAt)))) &&
|
|
174
|
+
(t.renewalAmountCents === null || (typeof t.renewalAmountCents === "number" && Number.isInteger(t.renewalAmountCents) && t.renewalAmountCents >= 0)) &&
|
|
175
|
+
typeof t.cancelAtPeriodEnd === "boolean");
|
|
176
|
+
}
|
|
177
|
+
/** S317: true when the envelope carries a well-formed plan or term and its
|
|
178
|
+
* `termSignature` verifies; false when it carries none or the signature is
|
|
179
|
+
* wrong; null when this browser cannot check it (plan P9: the plan then
|
|
180
|
+
* reads as unknown). */
|
|
181
|
+
export async function verifyTermInBrowser(entitlement, trustedKeys) {
|
|
182
|
+
if (!termShapeOk(entitlement.envelope))
|
|
183
|
+
return false;
|
|
184
|
+
if (typeof entitlement.termSignature !== "string" || entitlement.termSignature.length === 0)
|
|
185
|
+
return false;
|
|
186
|
+
return verifyBytesInBrowser(entitlement.envelope.keyId, entitlement.termSignature, canonicalLicenseVerdictTermBytes(entitlement.envelope), trustedKeys);
|
|
187
|
+
}
|
|
123
188
|
/** The checks after the signature, in the server's order. */
|
|
124
189
|
function decide(entitlement, pluginId, now) {
|
|
125
190
|
const { envelope } = entitlement;
|
|
126
191
|
if (envelope.pluginId !== pluginId)
|
|
127
|
-
return { status: "locked", reason: "wrong-plugin" };
|
|
192
|
+
return { status: "locked", reason: "wrong-plugin", readOnly: false };
|
|
128
193
|
if (envelope.status !== "valid")
|
|
129
|
-
return { status: "locked", reason: "not-valid" };
|
|
194
|
+
return { status: "locked", reason: "not-valid", readOnly: false };
|
|
130
195
|
const issuedMs = Date.parse(envelope.issuedAt);
|
|
131
196
|
const nowMs = now.getTime();
|
|
132
197
|
if (!Number.isFinite(issuedMs))
|
|
133
|
-
return { status: "locked", reason: "invalid-signature" };
|
|
198
|
+
return { status: "locked", reason: "invalid-signature", readOnly: false };
|
|
134
199
|
if (nowMs - issuedMs > BROWSER_ENTITLEMENT_MAX_AGE_MS)
|
|
135
|
-
return { status: "locked", reason: "expired" };
|
|
200
|
+
return { status: "locked", reason: "expired", readOnly: false };
|
|
136
201
|
if (issuedMs > nowMs + BROWSER_MAX_VERDICT_AGE_MS)
|
|
137
|
-
return { status: "locked", reason: "expired" };
|
|
138
|
-
return { status: "entitled" };
|
|
202
|
+
return { status: "locked", reason: "expired", readOnly: false };
|
|
203
|
+
return { status: "entitled", readOnly: false };
|
|
139
204
|
}
|
|
140
205
|
/** S284b, C9: the host hands `exempt` whenever its site domain is unset or
|
|
141
206
|
* local, which is one environment variable. The view takes it only when the
|
|
@@ -151,30 +216,39 @@ function pageIsLocal() {
|
|
|
151
216
|
* that cannot tell does not open. A free plugin never uses the gate. */
|
|
152
217
|
export function useEntitlement(pluginId) {
|
|
153
218
|
const fetchApi = usePluginApi();
|
|
154
|
-
const [result, setResult] = useState({ status: "loading" });
|
|
219
|
+
const [result, setResult] = useState({ status: "loading", readOnly: false });
|
|
155
220
|
useEffect(() => {
|
|
156
221
|
let cancelled = false;
|
|
157
|
-
setResult({ status: "loading" });
|
|
222
|
+
setResult({ status: "loading", readOnly: false });
|
|
158
223
|
(async () => {
|
|
159
224
|
const response = await fetchApi(`/api/plugin-management/entitlement/${encodeURIComponent(pluginId)}`);
|
|
160
225
|
if (!response.ok)
|
|
161
|
-
return { status: "locked", reason: "missing" };
|
|
226
|
+
return { status: "locked", reason: "missing", readOnly: false };
|
|
162
227
|
const body = (await response.json());
|
|
163
228
|
const entitlement = body?.entitlement;
|
|
229
|
+
// S318: the host's answer counts even where this browser cannot verify the term.
|
|
230
|
+
const hostReadOnly = body?.readOnly !== undefined && body?.readOnly !== null;
|
|
164
231
|
if (entitlement?.kind === "exempt") {
|
|
165
|
-
return pageIsLocal()
|
|
232
|
+
return pageIsLocal()
|
|
233
|
+
? { status: "entitled", plan: { planId: highestListingPlan(entitlement.listingPlans), term: { ...UNKNOWN_TERM } }, readOnly: hostReadOnly }
|
|
234
|
+
: { status: "locked", reason: "missing", readOnly: hostReadOnly };
|
|
166
235
|
}
|
|
167
236
|
if (entitlement?.kind !== "verdict")
|
|
168
|
-
return { status: "locked", reason: "missing" };
|
|
237
|
+
return { status: "locked", reason: "missing", readOnly: hostReadOnly };
|
|
169
238
|
if (!looksLikeVerdict(entitlement))
|
|
170
|
-
return { status: "locked", reason: "invalid-signature" };
|
|
239
|
+
return { status: "locked", reason: "invalid-signature", readOnly: hostReadOnly };
|
|
171
240
|
const own = await verifyEntitlementInBrowser(entitlement, LICENSE_VERDICT_PUBLIC_KEYS);
|
|
172
241
|
const authentic = own ?? body.valid === true;
|
|
173
242
|
if (!authentic)
|
|
174
|
-
return { status: "locked", reason: "invalid-signature" };
|
|
175
|
-
|
|
243
|
+
return { status: "locked", reason: "invalid-signature", readOnly: hostReadOnly };
|
|
244
|
+
const decided = decide(entitlement, pluginId, new Date());
|
|
245
|
+
if (decided.status !== "entitled")
|
|
246
|
+
return { ...decided, readOnly: hostReadOnly };
|
|
247
|
+
const termOk = await verifyTermInBrowser(entitlement, LICENSE_VERDICT_PUBLIC_KEYS);
|
|
248
|
+
const plan = planFromEnvelope(entitlement.envelope, termOk === true);
|
|
249
|
+
return { ...decided, plan, readOnly: hostReadOnly || plan.term.state === "lapsed" };
|
|
176
250
|
})()
|
|
177
|
-
.catch(() => ({ status: "locked", reason: "missing" }))
|
|
251
|
+
.catch(() => ({ status: "locked", reason: "missing", readOnly: false }))
|
|
178
252
|
.then((next) => {
|
|
179
253
|
if (!cancelled)
|
|
180
254
|
setResult(next);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LicenseVerdictEnvelope, LicenseVerdictTerm } from "@kardalum/plugin-package";
|
|
2
|
+
import type { ListingPlanSummary } from "./entitlement-types.js";
|
|
3
|
+
/** What a plugin knows about its licence's plan. `planId` is the plan's key
|
|
4
|
+
* on the listing, or null when unknown (a verdict from before S317, a host
|
|
5
|
+
* that could not verify the term, or a local install whose listing plans
|
|
6
|
+
* are not known). */
|
|
7
|
+
export interface EntitlementPlan {
|
|
8
|
+
planId: string | null;
|
|
9
|
+
term: LicenseVerdictTerm;
|
|
10
|
+
}
|
|
11
|
+
/** The term of a verdict that carries none: active, nothing known (S315
|
|
12
|
+
* section 9: an old verdict reads as plan unknown, term active). */
|
|
13
|
+
export declare const UNKNOWN_TERM: Readonly<LicenseVerdictTerm>;
|
|
14
|
+
/** S315 section 9: on a local install a plugin sees its listing's highest
|
|
15
|
+
* plan, the one with the highest yearly equivalent (the later position on
|
|
16
|
+
* a tie). Null with no plans. */
|
|
17
|
+
export declare function highestListingPlan(plans: readonly ListingPlanSummary[] | undefined): string | null;
|
|
18
|
+
/** The plan and term of an envelope whose base signature verified.
|
|
19
|
+
* `termVerified` says whether its `termSignature` did too; without it the
|
|
20
|
+
* fields are not trusted and the plan reads as unknown. */
|
|
21
|
+
export declare function planFromEnvelope(envelope: LicenseVerdictEnvelope, termVerified: boolean): EntitlementPlan;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The term of a verdict that carries none: active, nothing known (S315
|
|
2
|
+
* section 9: an old verdict reads as plan unknown, term active). */
|
|
3
|
+
export const UNKNOWN_TERM = Object.freeze({ state: "active", endsAt: null, renewalAmountCents: null, cancelAtPeriodEnd: false });
|
|
4
|
+
function yearlyEquivalentCents(plan) {
|
|
5
|
+
return plan.shape === "monthly" ? plan.priceCents * 12 : plan.priceCents;
|
|
6
|
+
}
|
|
7
|
+
/** S315 section 9: on a local install a plugin sees its listing's highest
|
|
8
|
+
* plan, the one with the highest yearly equivalent (the later position on
|
|
9
|
+
* a tie). Null with no plans. */
|
|
10
|
+
export function highestListingPlan(plans) {
|
|
11
|
+
let best = null;
|
|
12
|
+
for (const plan of plans ?? []) {
|
|
13
|
+
if (!best || yearlyEquivalentCents(plan) > yearlyEquivalentCents(best) || (yearlyEquivalentCents(plan) === yearlyEquivalentCents(best) && plan.position > best.position)) {
|
|
14
|
+
best = plan;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return best?.key ?? null;
|
|
18
|
+
}
|
|
19
|
+
/** The plan and term of an envelope whose base signature verified.
|
|
20
|
+
* `termVerified` says whether its `termSignature` did too; without it the
|
|
21
|
+
* fields are not trusted and the plan reads as unknown. */
|
|
22
|
+
export function planFromEnvelope(envelope, termVerified) {
|
|
23
|
+
if (!termVerified)
|
|
24
|
+
return { planId: null, term: { ...UNKNOWN_TERM } };
|
|
25
|
+
return { planId: envelope.planId ?? null, term: envelope.term ? { ...envelope.term } : { ...UNKNOWN_TERM } };
|
|
26
|
+
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import type { LicenseVerdictEnvelope } from "@kardalum/plugin-package";
|
|
1
|
+
import type { LicenseVerdictEnvelope, LicenseVerdictTerm } from "@kardalum/plugin-package";
|
|
2
2
|
import type { ScopedStructuredStorage } from "./structured-storage-types.js";
|
|
3
|
-
|
|
3
|
+
import type { PluginVendorService } from "./vendor-service.js";
|
|
4
|
+
export type { LicenseVerdictEnvelope, LicenseVerdictTerm };
|
|
5
|
+
/** A live plan of the plugin's marketplace listing, as the listing API
|
|
6
|
+
* names it (S316). `shape` is "free", "one_time", "monthly" or "yearly". */
|
|
7
|
+
export interface ListingPlanSummary {
|
|
8
|
+
key: string;
|
|
9
|
+
shape: string;
|
|
10
|
+
priceCents: number;
|
|
11
|
+
position: number;
|
|
12
|
+
}
|
|
4
13
|
/** The host's latest authentic licence verdict for a plugin, exactly as the
|
|
5
14
|
* marketplace signed it, whatever its status: a revoked or invalid one makes
|
|
6
|
-
* `requireEntitlement` answer `not-valid`.
|
|
15
|
+
* `requireEntitlement` answer `not-valid`. `termSignature` (S317) covers the
|
|
16
|
+
* envelope's `planId` and `term`; a host built before S317 hands none, and
|
|
17
|
+
* the plan then reads as unknown. */
|
|
7
18
|
export type EntitlementVerdict = {
|
|
8
19
|
kind: "verdict";
|
|
9
20
|
envelope: LicenseVerdictEnvelope;
|
|
10
21
|
signature: string;
|
|
22
|
+
termSignature?: string;
|
|
11
23
|
};
|
|
12
24
|
/** What the host hands a plugin (S284b fix wave: a tagged value, so "no
|
|
13
25
|
* check needed here" and "no verdict" can never be read as each other).
|
|
@@ -20,10 +32,14 @@ export type EntitlementVerdict = {
|
|
|
20
32
|
* - `none`: the host holds no verdict for this plugin (a free plugin, or a
|
|
21
33
|
* paid one whose verdict was never stored). `requireEntitlement` refuses
|
|
22
34
|
* with `missing`. A free plugin never calls it.
|
|
23
|
-
* - `verdict`: check it with `requireEntitlement`.
|
|
35
|
+
* - `verdict`: check it with `requireEntitlement`.
|
|
36
|
+
*
|
|
37
|
+
* `listingPlans` (S317) are the listing's live plans when the host knows
|
|
38
|
+
* them, so `entitlementPlan` can give a local evaluation the highest plan. */
|
|
24
39
|
export type Entitlement = {
|
|
25
40
|
kind: "exempt";
|
|
26
41
|
reason: "non-production";
|
|
42
|
+
listingPlans?: ListingPlanSummary[];
|
|
27
43
|
} | EntitlementVerdict | {
|
|
28
44
|
kind: "none";
|
|
29
45
|
};
|
|
@@ -36,4 +52,5 @@ export type EntitlementErrorCode = "missing" | "invalid-signature" | "wrong-plug
|
|
|
36
52
|
export type PluginTaskContext = {
|
|
37
53
|
entitlement: Entitlement;
|
|
38
54
|
structuredStorage?: ScopedStructuredStorage;
|
|
55
|
+
vendorService?: PluginVendorService;
|
|
39
56
|
};
|
package/dist/entitlement.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type LicenseVerdictEnvelope, type TrustedKey } from "@kardalum/plugin-package";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntitlementPlan } from "./entitlement-plan.js";
|
|
3
|
+
import type { Entitlement, EntitlementErrorCode, ListingPlanSummary } from "./entitlement-types.js";
|
|
3
4
|
import type { ScopedStructuredStorage } from "./structured-storage-types.js";
|
|
4
5
|
export declare class EntitlementError extends Error {
|
|
5
6
|
readonly code: EntitlementErrorCode;
|
|
@@ -55,3 +56,30 @@ export interface RequireEntitlementOptions {
|
|
|
55
56
|
* a future-dated verdict.
|
|
56
57
|
*/
|
|
57
58
|
export declare function requireEntitlement(entitlement: Entitlement | null | undefined, opts: RequireEntitlementOptions): Promise<LicenseVerdictEnvelope | null>;
|
|
59
|
+
/** S318: what `entitlementPlan` needs beside the entitlement. */
|
|
60
|
+
export interface EntitlementPlanOptions {
|
|
61
|
+
/** The plugin's own id: a verdict issued for another plugin reads as null. */
|
|
62
|
+
pluginId: string;
|
|
63
|
+
listingPlans?: readonly ListingPlanSummary[];
|
|
64
|
+
trustedKeys?: TrustedKey[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* S317 (spec 3d): the plan and the term beside `requireEntitlement`, never
|
|
68
|
+
* instead of it. It does not decide entitlement: call it after
|
|
69
|
+
* `requireEntitlement` resolved, to choose what the plan unlocks.
|
|
70
|
+
*
|
|
71
|
+
* - `verdict`: the signed `planId` and `term` when the verdict's signature
|
|
72
|
+
* and its `termSignature` verify; a verdict without them (one from before
|
|
73
|
+
* S317, or a host that hands no term signature) reads as plan unknown,
|
|
74
|
+
* term active. A verdict that does not verify is null.
|
|
75
|
+
* - `exempt` (a non-production install): the highest plan of
|
|
76
|
+
* `listingPlans`, or of the plans the host handed, term active; plan
|
|
77
|
+
* unknown when neither is known.
|
|
78
|
+
* - `none`, null or undefined: null.
|
|
79
|
+
* - A verdict of another plugin id, or whose status is not `valid`: null,
|
|
80
|
+
* as `requireEntitlement` would refuse it.
|
|
81
|
+
*
|
|
82
|
+
* A lapsed or past-due term still comes with a `valid` verdict (S317 D4):
|
|
83
|
+
* reads go on working, and the term is the signal for what to refuse.
|
|
84
|
+
*/
|
|
85
|
+
export declare function entitlementPlan(entitlement: Entitlement | null | undefined, opts: EntitlementPlanOptions): EntitlementPlan | null;
|
package/dist/entitlement.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// value, so an operator who flips the host's database still has to patch
|
|
13
13
|
// signed, watermarked plugin code to get that work for free.
|
|
14
14
|
import { ENTITLEMENT_MAX_AGE_MS, MAX_VERDICT_AGE_MS, verifyLicenseVerdictSignature, } from "@kardalum/plugin-package";
|
|
15
|
+
import { highestListingPlan, planFromEnvelope, UNKNOWN_TERM } from "./entitlement-plan.js";
|
|
15
16
|
import { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
16
17
|
import { isLocalHost } from "./local-host.js";
|
|
17
18
|
const ERROR_CODES = ["missing", "invalid-signature", "wrong-plugin", "not-valid", "expired"];
|
|
@@ -168,3 +169,41 @@ export async function requireEntitlement(entitlement, opts) {
|
|
|
168
169
|
}
|
|
169
170
|
return envelope;
|
|
170
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* S317 (spec 3d): the plan and the term beside `requireEntitlement`, never
|
|
174
|
+
* instead of it. It does not decide entitlement: call it after
|
|
175
|
+
* `requireEntitlement` resolved, to choose what the plan unlocks.
|
|
176
|
+
*
|
|
177
|
+
* - `verdict`: the signed `planId` and `term` when the verdict's signature
|
|
178
|
+
* and its `termSignature` verify; a verdict without them (one from before
|
|
179
|
+
* S317, or a host that hands no term signature) reads as plan unknown,
|
|
180
|
+
* term active. A verdict that does not verify is null.
|
|
181
|
+
* - `exempt` (a non-production install): the highest plan of
|
|
182
|
+
* `listingPlans`, or of the plans the host handed, term active; plan
|
|
183
|
+
* unknown when neither is known.
|
|
184
|
+
* - `none`, null or undefined: null.
|
|
185
|
+
* - A verdict of another plugin id, or whose status is not `valid`: null,
|
|
186
|
+
* as `requireEntitlement` would refuse it.
|
|
187
|
+
*
|
|
188
|
+
* A lapsed or past-due term still comes with a `valid` verdict (S317 D4):
|
|
189
|
+
* reads go on working, and the term is the signal for what to refuse.
|
|
190
|
+
*/
|
|
191
|
+
export function entitlementPlan(entitlement, opts) {
|
|
192
|
+
if (entitlement === null || entitlement === undefined || typeof entitlement !== "object")
|
|
193
|
+
return null;
|
|
194
|
+
if (entitlement.kind === "exempt") {
|
|
195
|
+
return { planId: highestListingPlan(opts.listingPlans ?? entitlement.listingPlans), term: { ...UNKNOWN_TERM } };
|
|
196
|
+
}
|
|
197
|
+
if (entitlement.kind !== "verdict")
|
|
198
|
+
return null;
|
|
199
|
+
const checked = verifyLicenseVerdictSignature(entitlement, opts.trustedKeys ?? LICENSE_VERDICT_PUBLIC_KEYS, { now: END_OF_TIME, maxAgeMs: Number.POSITIVE_INFINITY });
|
|
200
|
+
if (!checked.ok)
|
|
201
|
+
return null;
|
|
202
|
+
// verifyLicenseVerdictSignature keeps planId and term only under a
|
|
203
|
+
// verified termSignature, so their presence is the verification.
|
|
204
|
+
const envelope = checked.envelope;
|
|
205
|
+
// S318 (S317 rider): the same plugin id and status checks requireEntitlement makes.
|
|
206
|
+
if (envelope.pluginId !== opts.pluginId || envelope.status !== "valid")
|
|
207
|
+
return null;
|
|
208
|
+
return planFromEnvelope(envelope, envelope.planId !== undefined || envelope.term !== undefined);
|
|
209
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S314c4 (D4): how far an arrow key moves focus in a picker's option grid,
|
|
3
|
+
* read in the page's direction. Right goes forward in a left-to-right page and
|
|
4
|
+
* back in a right-to-left one, as the row reads; Down and Up keep moving one
|
|
5
|
+
* option forward and back in both.
|
|
6
|
+
*/
|
|
7
|
+
export declare function gridArrowStep(key: string, rtl: boolean): -1 | 0 | 1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S314c4 (D4): how far an arrow key moves focus in a picker's option grid,
|
|
3
|
+
* read in the page's direction. Right goes forward in a left-to-right page and
|
|
4
|
+
* back in a right-to-left one, as the row reads; Down and Up keep moving one
|
|
5
|
+
* option forward and back in both.
|
|
6
|
+
*/
|
|
7
|
+
export function gridArrowStep(key, rtl) {
|
|
8
|
+
switch (key) {
|
|
9
|
+
case "ArrowDown":
|
|
10
|
+
return 1;
|
|
11
|
+
case "ArrowUp":
|
|
12
|
+
return -1;
|
|
13
|
+
case "ArrowRight":
|
|
14
|
+
return rtl ? -1 : 1;
|
|
15
|
+
case "ArrowLeft":
|
|
16
|
+
return rtl ? 1 : -1;
|
|
17
|
+
default:
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/host-entry.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { registerPluginSlots, getPluginSection, listPluginSections, listRailEntries, getRailEntry, resetPluginSlotsForTests, type RegisteredSection, type RegisteredRailEntry, } from "./admin-section-registry.js";
|
|
1
|
+
export { registerPluginSlots, getPluginSection, listPluginSections, listRailEntries, getRailEntry, listDashboardWidgets, resetPluginSlotsForTests, type RegisteredSection, type RegisteredRailEntry, type RegisteredDashboardWidget, } from "./admin-section-registry.js";
|
package/dist/host-entry.js
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
//
|
|
9
9
|
// Not a stable public API: everything here is @internal and may change in
|
|
10
10
|
// any release without notice.
|
|
11
|
-
export { registerPluginSlots, getPluginSection, listPluginSections, listRailEntries, getRailEntry, resetPluginSlotsForTests, } from "./admin-section-registry.js";
|
|
11
|
+
export { registerPluginSlots, getPluginSection, listPluginSections, listRailEntries, getRailEntry, listDashboardWidgets, resetPluginSlotsForTests, } from "./admin-section-registry.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
export type { DataTypePlugin, DataTypePluginViews } from "./data-type-plugin.js";
|
|
2
2
|
export type { IconName } from "./icon-name.js";
|
|
3
3
|
export type { DataTypeIssue, DataTypeValidateContext, DataTypeValidateHook, DataTypeValidatorEntry, DataTypeValidatorLookup, } from "./datatype-validation.js";
|
|
4
|
-
export type { PluginType, DatabaseDialect, DatabaseCompatibility, PluginAssertion, PluginAssertions, PluginMigrationContext, PluginMigration, PluginMigrationValidation, PluginMigrationHooks, PluginInstallContext, PluginUpdateContext, PluginInstallDeclaration, InstallStep, InstallOption, InstallChoice, ResolvedInstallAnswers, HookEvent, HookHandler, PluginHooks, ContentLifecycleHookPayload, PluginHookContext, AdminSectionContribution, BuiltInRailEntryContribution, BuiltInRailSection, RailEntryContribution, SlotLabel, DashboardWidgetContribution, ApiRouteContribution, ScheduledTaskContribution, MediaProcessorContribution,
|
|
4
|
+
export type { PluginType, DatabaseDialect, DatabaseCompatibility, PluginAssertion, PluginAssertions, PluginMigrationContext, PluginMigration, PluginMigrationValidation, PluginMigrationHooks, PluginInstallContext, PluginUpdateContext, PluginInstallDeclaration, InstallStep, InstallOption, InstallChoice, ResolvedInstallAnswers, HookEvent, HookHandler, PluginHooks, ContentLifecycleHookPayload, PluginHookContext, AdminSectionContribution, BuiltInRailEntryContribution, BuiltInRailSection, RailEntryContribution, SlotLabel, DashboardWidgetContribution, ApiRouteContribution, ScheduledTaskContribution, MediaProcessorContribution, ExposedServiceContribution, BundledTemplateContribution, SerializerContext, CustomFormatContribution, SerializerContribution, PluginContributions, PluginManifestBase, PluginManifest, } from "./manifest.js";
|
|
5
5
|
export { slotLabel } from "./manifest.js";
|
|
6
6
|
export { CAPABILITY_IDS, CAPABILITY_LABELS, capabilityLabel, PROMISED_CAPABILITY_SENTENCE, deriveCapabilities, isActionGated, type Capability, type CapabilityAudience, type CapabilityLabels, type CapabilityMediation, type CapabilityPayload, } from "./capabilities.js";
|
|
7
|
-
export { BUILT_IN_RAIL_SECTIONS, CMSPluginSchema, DataTypePluginSchema, validatePluginManifest, type ValidatePluginManifestResult, } from "./manifest-schema.js";
|
|
7
|
+
export { BUILT_IN_RAIL_SECTIONS, DATABASE_DIALECTS, PLUGIN_TYPES, TIER1_DIALECTS, CMSPluginSchema, DataTypePluginSchema, validatePluginManifest, type ValidatePluginManifestResult, } from "./manifest-schema.js";
|
|
8
8
|
export { definePlugin, PluginDefinitionError } from "./define-plugin.js";
|
|
9
9
|
export { registerDataType, getDataType, listDataTypes } from "./registry.js";
|
|
10
10
|
export { PluginValueProvider, PluginSettingsProvider, PluginApiProvider, ContentHostProvider, usePluginValue, usePluginSettings, usePluginSettingsValue, usePluginApi, useContentHost, MANAGE_API, type PluginFetch, type ContentHost, type ContentHostPage, type ContentHostDocumentType, } from "./plugin-context.js";
|
|
11
11
|
export { PluginScreenProvider, PluginTranslateProvider, usePluginScreen, usePluginTranslate, type PluginScreenContext, type PluginTranslate, } from "./plugin-screen-context.js";
|
|
12
12
|
export { SimpleStorageValueProvider } from "./simple-storage-value-provider.js";
|
|
13
13
|
export { EntitlementGate, useEntitlement, type EntitlementStatus, type UseEntitlementResult, } from "./entitlement-gate.js";
|
|
14
|
-
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, PluginTaskContext } from "./entitlement-types.js";
|
|
14
|
+
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, PluginTaskContext, ListingPlanSummary, LicenseVerdictTerm } from "./entitlement-types.js";
|
|
15
|
+
export { highestListingPlan, planFromEnvelope, UNKNOWN_TERM, type EntitlementPlan } from "./entitlement-plan.js";
|
|
15
16
|
export { buildRichtextExtensions, TextStyleClass, KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, type BuildRichtextExtensionsOptions, type RichtextTextStyle, type TextStyleClassAttributes, type KardalumBlockAttributes, type KardalumBlockLocation, type SelectedKardalumBlock, } from "./richtext/extensions.js";
|
|
16
17
|
export { MediaPicker, type MediaPickerItem, type MediaPickerProps } from "./media/media-picker.js";
|
|
18
|
+
export { gridArrowStep } from "./grid-arrow-step.js";
|
|
17
19
|
export { MediaFileProvider, useMediaFile, useMediaFileReplace, type CurrentMediaFile, type MediaFileProviderProps, type MediaFileReplace, } from "./views/file-upload-view.js";
|
|
18
20
|
export { MediaRenditionProvider, useMediaRendition, isRenditionIneligible, RENDITION_INELIGIBLE_TYPES, type MediaRenditionCut, type MediaRenditionHost, type MediaRenditionProviderProps, } from "./views/crop-view.js";
|
|
19
21
|
export { StyleListbox, type StyleListboxProps } from "./richtext/style-listbox.js";
|
|
@@ -26,3 +28,6 @@ export { Button, type ButtonProps } from "@kardalum/ui";
|
|
|
26
28
|
export { Switch, type SwitchProps } from "@kardalum/ui";
|
|
27
29
|
export { Badge, type BadgeProps } from "@kardalum/ui";
|
|
28
30
|
export { cn } from "@kardalum/ui";
|
|
31
|
+
export type { NotificationRefusalReason, PluginNotify, PluginNotifyInput, PluginNotifyResult } from "./notify.js";
|
|
32
|
+
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
|
33
|
+
export type { PluginVendorService, VendorServiceErrorCode, VendorServiceRequestInit } from "./vendor-service.js";
|