@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
|
@@ -5,7 +5,7 @@ import type { TrustedKey } from "./types.js";
|
|
|
5
5
|
* makes a fake licence server unable to produce one the CMS accepts. A
|
|
6
6
|
* captured verdict is not a durable unlock: `nonce` (bound per request via
|
|
7
7
|
* a `LicenseChallenge`) is what actually prevents replay, since a
|
|
8
|
-
* verifier's own clock cannot be trusted to bound freshness
|
|
8
|
+
* verifier's own clock cannot be trusted to bound freshness; see
|
|
9
9
|
* `createLicenseChallenge`'s doc comment below. */
|
|
10
10
|
export interface LicenseVerdictEnvelope {
|
|
11
11
|
v: 1;
|
|
@@ -16,7 +16,7 @@ export interface LicenseVerdictEnvelope {
|
|
|
16
16
|
* on "the field names happen to differ" rather than being a property of
|
|
17
17
|
* the design. */
|
|
18
18
|
typ: "license-verdict";
|
|
19
|
-
/** First 16 hex of sha256(raw public key)
|
|
19
|
+
/** First 16 hex of sha256(raw public key): derived, never assigned. */
|
|
20
20
|
keyId: string;
|
|
21
21
|
/** sha256 of the licence key. The key itself never travels in a verdict:
|
|
22
22
|
* a captured verdict must not be a working credential. */
|
|
@@ -29,12 +29,12 @@ export interface LicenseVerdictEnvelope {
|
|
|
29
29
|
* trustworthy input to a check meant to defeat the CMS: the process
|
|
30
30
|
* being verified runs on the customer's machine, and they can capture a
|
|
31
31
|
* single genuine "valid" verdict once, then replay it forever by
|
|
32
|
-
* running the process under a clock pinned near `issuedAt
|
|
32
|
+
* running the process under a clock pinned near `issuedAt`: no source
|
|
33
33
|
* edit, survives updates, shareable as a recipe. No time-based check can
|
|
34
34
|
* close that, however tight the window. A fresh unpredictable nonce
|
|
35
35
|
* chosen by the verifier and checked for an exact match closes it,
|
|
36
36
|
* because a captured verdict cannot answer a challenge it never saw. Do
|
|
37
|
-
* not remove this as "covered by issuedAt"
|
|
37
|
+
* not remove this as "covered by issuedAt": it is the only check here a
|
|
38
38
|
* replay cannot pass. */
|
|
39
39
|
nonce: string;
|
|
40
40
|
status: "valid" | "invalid" | "revoked";
|
|
@@ -53,6 +53,15 @@ export interface LicenseVerdictEnvelope {
|
|
|
53
53
|
* signed before this field existed still verifies. At most
|
|
54
54
|
* LICENSE_VERDICT_DETAIL_MAX characters. */
|
|
55
55
|
detail?: string;
|
|
56
|
+
/** S317: the key of the plan the licence holds. Covered by
|
|
57
|
+
* `termSignature` only, never by `signature`, so a verifier built before
|
|
58
|
+
* S317 checks the bytes it always did and ignores this field. The
|
|
59
|
+
* validation route keeps it absent on a verdict that is not `valid`; the
|
|
60
|
+
* verifiers do not check that. */
|
|
61
|
+
planId?: string;
|
|
62
|
+
/** S317: the licence's term, covered by `termSignature` like `planId`. A
|
|
63
|
+
* verdict without it reads as plan unknown, term active. */
|
|
64
|
+
term?: LicenseVerdictTerm;
|
|
56
65
|
}
|
|
57
66
|
/** The longest `detail` a verdict may carry. */
|
|
58
67
|
export declare const LICENSE_VERDICT_DETAIL_MAX = 500;
|
|
@@ -60,22 +69,42 @@ export declare const LICENSE_VERDICT_DETAIL_MAX = 500;
|
|
|
60
69
|
* another licence's (or version's) delivery, a package the marketplace never
|
|
61
70
|
* delivered, or the right delivery changed on disk since its first report. */
|
|
62
71
|
export type TamperKind = "foreign-package" | "sideloaded" | "modified-on-disk";
|
|
72
|
+
/** A licence's term on the marketplace (S317; the states of S315 section 4):
|
|
73
|
+
* `active` (paid, or a free or one-time plan), `renewing` (the renewal is
|
|
74
|
+
* being charged), `past_due` (the renewal failed; 14 days of grace),
|
|
75
|
+
* `lapsed` (grace ended unpaid, or a cancelled term ended). */
|
|
76
|
+
export type LicenseTermState = "active" | "renewing" | "past_due" | "lapsed";
|
|
77
|
+
export declare const LICENSE_TERM_STATES: readonly LicenseTermState[];
|
|
78
|
+
/** The term a verdict carries. `endsAt` is the end of the term paid for
|
|
79
|
+
* (null for a free or one-time plan); `renewalAmountCents` the next charge
|
|
80
|
+
* in USD cents (null when nothing renews); `cancelAtPeriodEnd` true for a
|
|
81
|
+
* term the buyer cancelled. */
|
|
82
|
+
export interface LicenseVerdictTerm {
|
|
83
|
+
state: LicenseTermState;
|
|
84
|
+
endsAt: string | null;
|
|
85
|
+
renewalAmountCents: number | null;
|
|
86
|
+
cancelAtPeriodEnd: boolean;
|
|
87
|
+
}
|
|
88
|
+
/** The longest plan key a verdict carries. */
|
|
89
|
+
export declare const LICENSE_VERDICT_PLAN_ID_MAX = 64;
|
|
63
90
|
export interface SignedLicenseVerdict {
|
|
64
91
|
envelope: LicenseVerdictEnvelope;
|
|
65
92
|
signature: string;
|
|
93
|
+
/** S317: base64 Ed25519 over canonicalizeLicenseVerdictTerm; present only when the envelope carries planId or term. */
|
|
94
|
+
termSignature?: string;
|
|
66
95
|
}
|
|
67
96
|
/**
|
|
68
97
|
* A `LicenseChallenge` is the only way to obtain a nonce, and the only
|
|
69
98
|
* shape `verifyLicenseVerdict` accepts in place of a separately-typed
|
|
70
99
|
* "expected subject". Folding subject and nonce into one object the module
|
|
71
|
-
* itself produces means they can never disagree
|
|
100
|
+
* itself produces means they can never disagree: there is no way to hand
|
|
72
101
|
* `verifyLicenseVerdict` a nonce that was not the one generated for this
|
|
73
102
|
* exact subject.
|
|
74
103
|
*
|
|
75
104
|
* A challenge is single-use: `verifyLicenseVerdict` consumes it on first
|
|
76
105
|
* use (success or failure) and returns `"challenge-reused"` on any second
|
|
77
106
|
* use of the same object. A caller that needs to retry a validation round
|
|
78
|
-
* trip must call `createLicenseChallenge` again
|
|
107
|
+
* trip must call `createLicenseChallenge` again: a retry is a new
|
|
79
108
|
* question, and asking it again with the same nonce is exactly the
|
|
80
109
|
* caller-side mistake (caching one nonce and reusing it across requests)
|
|
81
110
|
* that collapses replay protection back to "one captured verdict unlocks
|
|
@@ -88,17 +117,17 @@ export interface LicenseChallenge {
|
|
|
88
117
|
readonly domain: string;
|
|
89
118
|
/** Hex-encoded, at least 16 random bytes. Exposed only so the caller can
|
|
90
119
|
* transmit it to the marketplace alongside the rest of the validation
|
|
91
|
-
* request
|
|
120
|
+
* request; it plays no other role on the caller's side. */
|
|
92
121
|
readonly nonce: string;
|
|
93
122
|
}
|
|
94
123
|
/** Verification authenticates a signed envelope; it does not decide
|
|
95
124
|
* whether to unlock anything. `"licensed"` is the only branch that should
|
|
96
125
|
* ever lead to unlocking a plugin. `"unlicensed"` means the marketplace
|
|
97
126
|
* gave an authentic, fresh, correctly subject-bound answer and that answer
|
|
98
|
-
* says no (`invalid` or `revoked`)
|
|
127
|
+
* says no (`invalid` or `revoked`): a real verdict, safe to show the
|
|
99
128
|
* user. `"unverifiable"` means no answer this caller can trust was
|
|
100
129
|
* obtained at all (malformed input, an untrusted or forged signature, a
|
|
101
|
-
* verdict for a different subject, a stale or reused challenge)
|
|
130
|
+
* verdict for a different subject, a stale or reused challenge). The
|
|
102
131
|
* caller must treat this exactly like an unreachable licence server and
|
|
103
132
|
* change nothing, never as a soft "no". There is no boolean here to
|
|
104
133
|
* misread: unlike a `{ ok: boolean }` shape, `if (result.ok) unlock()`
|
|
@@ -116,7 +145,7 @@ export type LicenseVerdictResult = {
|
|
|
116
145
|
verdict: "unverifiable";
|
|
117
146
|
reason: "malformed" | "untrusted-key" | "bad-signature" | "subject-mismatch" | "stale" | "challenge-reused";
|
|
118
147
|
};
|
|
119
|
-
/** A cheap SECONDARY bound only
|
|
148
|
+
/** A cheap SECONDARY bound only. The nonce (see `createLicenseChallenge`'s
|
|
120
149
|
* doc comment) is what actually stops replay, and it does so completely:
|
|
121
150
|
* a captured verdict cannot answer a challenge it never saw, regardless of
|
|
122
151
|
* how wide this window is. This check exists purely to reject an obviously
|
|
@@ -125,8 +154,8 @@ export type LicenseVerdictResult = {
|
|
|
125
154
|
* always be defeated by controlling `now`.
|
|
126
155
|
*
|
|
127
156
|
* Widened from 5 minutes to 24 hours (S209 criticals fix): a five-minute
|
|
128
|
-
* window bought no real security
|
|
129
|
-
* was guarding
|
|
157
|
+
* window bought no real security (the nonce already closes the gap this
|
|
158
|
+
* was guarding) but it did fail a paying customer's install outright the
|
|
130
159
|
* moment their clock drifted more than five minutes from real time (a
|
|
131
160
|
* sleeping Docker VM, an un-NTP'd VPS), turning `verifyLicenseVerdict` into
|
|
132
161
|
* `unverifiable: stale` and the whole install into a failure with no
|
|
@@ -140,14 +169,14 @@ export declare const MAX_VERDICT_AGE_MS: number;
|
|
|
140
169
|
export declare const ENTITLEMENT_MAX_AGE_MS: number;
|
|
141
170
|
export declare function hashLicenseKey(key: string): string;
|
|
142
171
|
/** Starts a licence validation round trip. Returns a challenge carrying
|
|
143
|
-
* both the subject being validated and a freshly generated nonce
|
|
172
|
+
* both the subject being validated and a freshly generated nonce. The
|
|
144
173
|
* caller sends the whole thing (or at least its `nonce`) to the
|
|
145
174
|
* marketplace, which echoes the nonce into the signed envelope it
|
|
146
175
|
* produces. The caller then passes this same challenge to
|
|
147
176
|
* `verifyLicenseVerdict`, so the subject and the nonce it gets checked
|
|
148
177
|
* against can never come from two different places and drift apart.
|
|
149
178
|
*
|
|
150
|
-
* Each challenge verifies at most once
|
|
179
|
+
* Each challenge verifies at most once; see `LicenseChallenge`'s doc
|
|
151
180
|
* comment. Call this again for every new validation attempt; do not cache
|
|
152
181
|
* or reuse a challenge (or its nonce) across requests. */
|
|
153
182
|
export declare function createLicenseChallenge(subject: {
|
|
@@ -155,14 +184,22 @@ export declare function createLicenseChallenge(subject: {
|
|
|
155
184
|
pluginId: string;
|
|
156
185
|
domain: string;
|
|
157
186
|
}): LicenseChallenge;
|
|
158
|
-
/** Explicit field order, exactly like canonicalizeEnvelope
|
|
187
|
+
/** Explicit field order, exactly like canonicalizeEnvelope, never
|
|
159
188
|
* JSON.stringify of the object itself, whose key order is not guaranteed
|
|
160
|
-
* across producers.
|
|
161
|
-
* when present, so an envelope without them produces exactly the bytes it
|
|
162
|
-
* did before the fields existed (pinned by a test): old signatures keep
|
|
163
|
-
* verifying. */
|
|
189
|
+
* across producers. What `signature` covers: unchanged since S284b. */
|
|
164
190
|
export declare function canonicalizeLicenseVerdict(envelope: LicenseVerdictEnvelope): Buffer;
|
|
191
|
+
/** S317: what `termSignature` covers: the version 1 fields, then `planId`
|
|
192
|
+
* and `term` always (null when absent), in this order. These bytes always
|
|
193
|
+
* hold a `planId` key, which the version 1 bytes never do, so neither
|
|
194
|
+
* signature can stand in for the other. */
|
|
195
|
+
export declare function canonicalizeLicenseVerdictTerm(envelope: LicenseVerdictEnvelope): Buffer;
|
|
165
196
|
export declare function signLicenseVerdict(envelope: LicenseVerdictEnvelope, privateKeyBase64: string): string;
|
|
197
|
+
/** S317: what the marketplace's validation route returns. `signature` is
|
|
198
|
+
* signLicenseVerdict's, byte for byte (Ed25519 is deterministic), so every
|
|
199
|
+
* verifier built before S317 accepts it; `termSignature` is added only when
|
|
200
|
+
* the envelope carries a plan or a term. Throws RangeError for a malformed
|
|
201
|
+
* plan or term: the marketplace never signs one. */
|
|
202
|
+
export declare function signLicenseVerdictWithTerm(envelope: LicenseVerdictEnvelope, privateKeyBase64: string): SignedLicenseVerdict;
|
|
166
203
|
export type LicenseVerdictSignatureResult = {
|
|
167
204
|
ok: true;
|
|
168
205
|
envelope: LicenseVerdictEnvelope;
|
|
@@ -3,7 +3,10 @@ import { deriveKeyId } from "./envelope.js";
|
|
|
3
3
|
/** The longest `detail` a verdict may carry. */
|
|
4
4
|
export const LICENSE_VERDICT_DETAIL_MAX = 500;
|
|
5
5
|
const TAMPER_KINDS = ["foreign-package", "sideloaded", "modified-on-disk"];
|
|
6
|
-
|
|
6
|
+
export const LICENSE_TERM_STATES = ["active", "renewing", "past_due", "lapsed"];
|
|
7
|
+
/** The longest plan key a verdict carries. */
|
|
8
|
+
export const LICENSE_VERDICT_PLAN_ID_MAX = 64;
|
|
9
|
+
/** A cheap SECONDARY bound only. The nonce (see `createLicenseChallenge`'s
|
|
7
10
|
* doc comment) is what actually stops replay, and it does so completely:
|
|
8
11
|
* a captured verdict cannot answer a challenge it never saw, regardless of
|
|
9
12
|
* how wide this window is. This check exists purely to reject an obviously
|
|
@@ -12,8 +15,8 @@ const TAMPER_KINDS = ["foreign-package", "sideloaded", "modified-on-disk"];
|
|
|
12
15
|
* always be defeated by controlling `now`.
|
|
13
16
|
*
|
|
14
17
|
* Widened from 5 minutes to 24 hours (S209 criticals fix): a five-minute
|
|
15
|
-
* window bought no real security
|
|
16
|
-
* was guarding
|
|
18
|
+
* window bought no real security (the nonce already closes the gap this
|
|
19
|
+
* was guarding) but it did fail a paying customer's install outright the
|
|
17
20
|
* moment their clock drifted more than five minutes from real time (a
|
|
18
21
|
* sleeping Docker VM, an un-NTP'd VPS), turning `verifyLicenseVerdict` into
|
|
19
22
|
* `unverifiable: stale` and the whole install into a failure with no
|
|
@@ -35,14 +38,14 @@ export function hashLicenseKey(key) {
|
|
|
35
38
|
* challenge used, unused, or forge a fresh-looking one. */
|
|
36
39
|
const consumedChallenges = new WeakSet();
|
|
37
40
|
/** Starts a licence validation round trip. Returns a challenge carrying
|
|
38
|
-
* both the subject being validated and a freshly generated nonce
|
|
41
|
+
* both the subject being validated and a freshly generated nonce. The
|
|
39
42
|
* caller sends the whole thing (or at least its `nonce`) to the
|
|
40
43
|
* marketplace, which echoes the nonce into the signed envelope it
|
|
41
44
|
* produces. The caller then passes this same challenge to
|
|
42
45
|
* `verifyLicenseVerdict`, so the subject and the nonce it gets checked
|
|
43
46
|
* against can never come from two different places and drift apart.
|
|
44
47
|
*
|
|
45
|
-
* Each challenge verifies at most once
|
|
48
|
+
* Each challenge verifies at most once; see `LicenseChallenge`'s doc
|
|
46
49
|
* comment. Call this again for every new validation attempt; do not cache
|
|
47
50
|
* or reuse a challenge (or its nonce) across requests. */
|
|
48
51
|
export function createLicenseChallenge(subject) {
|
|
@@ -53,14 +56,12 @@ export function createLicenseChallenge(subject) {
|
|
|
53
56
|
nonce: randomBytes(16).toString("hex"),
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export function canonicalizeLicenseVerdict(envelope) {
|
|
63
|
-
return Buffer.from(JSON.stringify({
|
|
59
|
+
/** The version 1 fields in their signed order. `tamper` and then `detail`
|
|
60
|
+
* are appended only when present, so an envelope without them produces
|
|
61
|
+
* exactly the bytes it did before they existed (pinned by a test). `planId`
|
|
62
|
+
* and `term` are never part of these bytes (S317, plan P1). */
|
|
63
|
+
function canonicalFields(envelope) {
|
|
64
|
+
return {
|
|
64
65
|
v: envelope.v,
|
|
65
66
|
alg: envelope.alg,
|
|
66
67
|
typ: envelope.typ,
|
|
@@ -74,12 +75,79 @@ export function canonicalizeLicenseVerdict(envelope) {
|
|
|
74
75
|
issuedAt: envelope.issuedAt,
|
|
75
76
|
...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
|
|
76
77
|
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Explicit field order, exactly like canonicalizeEnvelope, never
|
|
81
|
+
* JSON.stringify of the object itself, whose key order is not guaranteed
|
|
82
|
+
* across producers. What `signature` covers: unchanged since S284b. */
|
|
83
|
+
export function canonicalizeLicenseVerdict(envelope) {
|
|
84
|
+
return Buffer.from(JSON.stringify(canonicalFields(envelope)), "utf8");
|
|
85
|
+
}
|
|
86
|
+
/** S317: what `termSignature` covers: the version 1 fields, then `planId`
|
|
87
|
+
* and `term` always (null when absent), in this order. These bytes always
|
|
88
|
+
* hold a `planId` key, which the version 1 bytes never do, so neither
|
|
89
|
+
* signature can stand in for the other. */
|
|
90
|
+
export function canonicalizeLicenseVerdictTerm(envelope) {
|
|
91
|
+
const term = envelope.term;
|
|
92
|
+
return Buffer.from(JSON.stringify({
|
|
93
|
+
...canonicalFields(envelope),
|
|
94
|
+
planId: envelope.planId ?? null,
|
|
95
|
+
term: term === undefined
|
|
96
|
+
? null
|
|
97
|
+
: { state: term.state, endsAt: term.endsAt, renewalAmountCents: term.renewalAmountCents, cancelAtPeriodEnd: term.cancelAtPeriodEnd },
|
|
77
98
|
}), "utf8");
|
|
78
99
|
}
|
|
100
|
+
/** S319 (S317 rider): an instant exactly as `toISOString` writes it, so a
|
|
101
|
+
* term end has one spelling and the bytes a signature covers are the bytes
|
|
102
|
+
* every verifier reads. */
|
|
103
|
+
function isCanonicalInstant(value) {
|
|
104
|
+
const time = Date.parse(value);
|
|
105
|
+
return Number.isFinite(time) && new Date(time).toISOString() === value;
|
|
106
|
+
}
|
|
107
|
+
function isTerm(value) {
|
|
108
|
+
if (typeof value !== "object" || value === null)
|
|
109
|
+
return false;
|
|
110
|
+
const t = value;
|
|
111
|
+
return (typeof t.state === "string" &&
|
|
112
|
+
LICENSE_TERM_STATES.includes(t.state) &&
|
|
113
|
+
(t.endsAt === null || (typeof t.endsAt === "string" && isCanonicalInstant(t.endsAt))) &&
|
|
114
|
+
// S319 (S317 rider): a whole number of cents a JSON reader keeps exactly,
|
|
115
|
+
// never negative, and never -0 (which JSON writes as 0, so the signed
|
|
116
|
+
// bytes and the signer's value would disagree).
|
|
117
|
+
(t.renewalAmountCents === null ||
|
|
118
|
+
(typeof t.renewalAmountCents === "number" &&
|
|
119
|
+
Number.isSafeInteger(t.renewalAmountCents) &&
|
|
120
|
+
!Object.is(t.renewalAmountCents, -0) &&
|
|
121
|
+
t.renewalAmountCents >= 0)) &&
|
|
122
|
+
typeof t.cancelAtPeriodEnd === "boolean");
|
|
123
|
+
}
|
|
124
|
+
function hasTermFields(envelope) {
|
|
125
|
+
return envelope.planId !== undefined || envelope.term !== undefined;
|
|
126
|
+
}
|
|
127
|
+
/** Both fields, when present, in the shapes a verifier keeps. */
|
|
128
|
+
function termFieldsWellFormed(envelope) {
|
|
129
|
+
const planId = envelope.planId;
|
|
130
|
+
return ((planId === undefined || (typeof planId === "string" && planId.length >= 1 && planId.length <= LICENSE_VERDICT_PLAN_ID_MAX)) &&
|
|
131
|
+
(envelope.term === undefined || isTerm(envelope.term)));
|
|
132
|
+
}
|
|
79
133
|
export function signLicenseVerdict(envelope, privateKeyBase64) {
|
|
80
134
|
const key = createPrivateKey({ key: Buffer.from(privateKeyBase64, "base64"), format: "der", type: "pkcs8" });
|
|
81
135
|
return sign(null, canonicalizeLicenseVerdict(envelope), key).toString("base64");
|
|
82
136
|
}
|
|
137
|
+
/** S317: what the marketplace's validation route returns. `signature` is
|
|
138
|
+
* signLicenseVerdict's, byte for byte (Ed25519 is deterministic), so every
|
|
139
|
+
* verifier built before S317 accepts it; `termSignature` is added only when
|
|
140
|
+
* the envelope carries a plan or a term. Throws RangeError for a malformed
|
|
141
|
+
* plan or term: the marketplace never signs one. */
|
|
142
|
+
export function signLicenseVerdictWithTerm(envelope, privateKeyBase64) {
|
|
143
|
+
const signature = signLicenseVerdict(envelope, privateKeyBase64);
|
|
144
|
+
if (!hasTermFields(envelope))
|
|
145
|
+
return { envelope, signature };
|
|
146
|
+
if (!termFieldsWellFormed(envelope))
|
|
147
|
+
throw new RangeError("signLicenseVerdictWithTerm: the plan or term is malformed");
|
|
148
|
+
const key = createPrivateKey({ key: Buffer.from(privateKeyBase64, "base64"), format: "der", type: "pkcs8" });
|
|
149
|
+
return { envelope, signature, termSignature: sign(null, canonicalizeLicenseVerdictTerm(envelope), key).toString("base64") };
|
|
150
|
+
}
|
|
83
151
|
function isEnvelope(value) {
|
|
84
152
|
if (typeof value !== "object" || value === null)
|
|
85
153
|
return false;
|
|
@@ -94,7 +162,7 @@ function isEnvelope(value) {
|
|
|
94
162
|
typeof e.nonce === "string" &&
|
|
95
163
|
(e.status === "valid" || e.status === "invalid" || e.status === "revoked") &&
|
|
96
164
|
// A licence server that naturally serialises `reason: row.reason ??
|
|
97
|
-
// null` must not be misread as malformed
|
|
165
|
+
// null` must not be misread as malformed: null and "absent" mean the
|
|
98
166
|
// same thing here, and are normalized to undefined below once the
|
|
99
167
|
// signature has been checked.
|
|
100
168
|
(e.reason === undefined || e.reason === null || typeof e.reason === "string") &&
|
|
@@ -108,15 +176,15 @@ function isSigned(value) {
|
|
|
108
176
|
const s = value;
|
|
109
177
|
return typeof s.signature === "string" && s.signature.length > 0 && isEnvelope(s.envelope);
|
|
110
178
|
}
|
|
111
|
-
/** The key lookup and signature check, shared by
|
|
112
|
-
*
|
|
113
|
-
function
|
|
179
|
+
/** The key lookup and signature check over given bytes, shared by the base
|
|
180
|
+
* and the term signature so there is one definition of "authentic". */
|
|
181
|
+
function checkBytes(keyId, bytes, signature, trustedKeys) {
|
|
114
182
|
// Re-derive rather than trust the label, exactly as trusted-keys.ts does:
|
|
115
183
|
// an unauthenticated keyId would otherwise let a signature made by one
|
|
116
184
|
// key be attributed to another.
|
|
117
185
|
const match = trustedKeys.find((k) => {
|
|
118
186
|
try {
|
|
119
|
-
return deriveKeyId(k.publicKey) ===
|
|
187
|
+
return deriveKeyId(k.publicKey) === keyId;
|
|
120
188
|
}
|
|
121
189
|
catch {
|
|
122
190
|
return false;
|
|
@@ -125,20 +193,35 @@ function checkSignature(envelope, signature, trustedKeys) {
|
|
|
125
193
|
if (!match)
|
|
126
194
|
return "untrusted-key";
|
|
127
195
|
try {
|
|
128
|
-
const ok = verify(null,
|
|
196
|
+
const ok = verify(null, bytes, createPublicKey({ key: Buffer.from(match.publicKey, "base64"), format: "der", type: "spki" }), Buffer.from(signature, "base64"));
|
|
129
197
|
return ok ? "ok" : "bad-signature";
|
|
130
198
|
}
|
|
131
199
|
catch {
|
|
132
200
|
return "bad-signature";
|
|
133
201
|
}
|
|
134
202
|
}
|
|
203
|
+
function checkSignature(envelope, signature, trustedKeys) {
|
|
204
|
+
return checkBytes(envelope.keyId, canonicalizeLicenseVerdict(envelope), signature, trustedKeys);
|
|
205
|
+
}
|
|
206
|
+
/** S317: true when the envelope's plan and term are well formed and
|
|
207
|
+
* `termSignature` verifies over them with the same key as the base
|
|
208
|
+
* signature. Anything else reads the verdict as one without them. */
|
|
209
|
+
function termVerified(signed, envelope, trustedKeys) {
|
|
210
|
+
if (!hasTermFields(envelope) || !termFieldsWellFormed(envelope))
|
|
211
|
+
return false;
|
|
212
|
+
const termSignature = signed.termSignature;
|
|
213
|
+
if (typeof termSignature !== "string" || termSignature.length === 0)
|
|
214
|
+
return false;
|
|
215
|
+
return checkBytes(envelope.keyId, canonicalizeLicenseVerdictTerm(envelope), termSignature, trustedKeys) === "ok";
|
|
216
|
+
}
|
|
135
217
|
/** Rebuild from only the signed fields rather than returning the caller's
|
|
136
218
|
* object verbatim, so an extra unsigned property the server happened to
|
|
137
219
|
* attach cannot ride along on a result labelled verified. This also
|
|
138
220
|
* normalizes a `reason: null` producer to `undefined`, matching the type,
|
|
139
221
|
* and leaves `tamper` and `detail` out entirely when the envelope had
|
|
140
|
-
* none.
|
|
141
|
-
|
|
222
|
+
* none. `planId` and `term` are kept only when `withTerm` (their own
|
|
223
|
+
* signature verified, `termVerified`). */
|
|
224
|
+
function signedFieldsOnly(envelope, withTerm) {
|
|
142
225
|
return {
|
|
143
226
|
v: envelope.v,
|
|
144
227
|
alg: envelope.alg,
|
|
@@ -153,6 +236,17 @@ function signedFieldsOnly(envelope) {
|
|
|
153
236
|
issuedAt: envelope.issuedAt,
|
|
154
237
|
...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
|
|
155
238
|
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
239
|
+
...(withTerm && envelope.planId !== undefined ? { planId: envelope.planId } : {}),
|
|
240
|
+
...(withTerm && envelope.term !== undefined
|
|
241
|
+
? {
|
|
242
|
+
term: {
|
|
243
|
+
state: envelope.term.state,
|
|
244
|
+
endsAt: envelope.term.endsAt,
|
|
245
|
+
renewalAmountCents: envelope.term.renewalAmountCents,
|
|
246
|
+
cancelAtPeriodEnd: envelope.term.cancelAtPeriodEnd,
|
|
247
|
+
},
|
|
248
|
+
}
|
|
249
|
+
: {}),
|
|
156
250
|
};
|
|
157
251
|
}
|
|
158
252
|
/** Verifies a verdict the way a plugin can: the signature against a trusted
|
|
@@ -181,7 +275,7 @@ export function verifyLicenseVerdictSignature(signed, trustedKeys, opts = {}) {
|
|
|
181
275
|
return { ok: false, reason: "future" };
|
|
182
276
|
if (nowMs - issued > maxAgeMs)
|
|
183
277
|
return { ok: false, reason: "expired" };
|
|
184
|
-
return { ok: true, envelope: signedFieldsOnly(envelope) };
|
|
278
|
+
return { ok: true, envelope: signedFieldsOnly(envelope, termVerified(signed, envelope, trustedKeys)) };
|
|
185
279
|
}
|
|
186
280
|
export function verifyLicenseVerdict(signedVerdict, challenge, trustedKeys, now = new Date()) {
|
|
187
281
|
// A challenge answers at most one question. Consuming it here (before
|
|
@@ -203,7 +297,7 @@ export function verifyLicenseVerdict(signedVerdict, challenge, trustedKeys, now
|
|
|
203
297
|
if (authentic === "bad-signature")
|
|
204
298
|
return { verdict: "unverifiable", reason: "bad-signature" };
|
|
205
299
|
// Subject binding. Without this a single genuine "valid" verdict, once
|
|
206
|
-
// captured, would unlock every plugin on every domain
|
|
300
|
+
// captured, would unlock every plugin on every domain, and without the
|
|
207
301
|
// nonce comparison specifically, it would unlock every future request
|
|
208
302
|
// too, regardless of issuedAt. A verdict answering a different challenge
|
|
209
303
|
// is exactly as wrong as one for a different plugin.
|
|
@@ -219,10 +313,10 @@ export function verifyLicenseVerdict(signedVerdict, challenge, trustedKeys, now
|
|
|
219
313
|
if (!Number.isFinite(issued) || Math.abs(now.getTime() - issued) > MAX_VERDICT_AGE_MS) {
|
|
220
314
|
return { verdict: "unverifiable", reason: "stale" };
|
|
221
315
|
}
|
|
222
|
-
const verifiedEnvelope = signedFieldsOnly(envelope);
|
|
316
|
+
const verifiedEnvelope = signedFieldsOnly(envelope, termVerified(signedVerdict, envelope, trustedKeys));
|
|
223
317
|
// Authentication is done; now, and only now, does the envelope's own
|
|
224
318
|
// `status` decide the verdict. `"valid"` is the sole branch a caller can
|
|
225
|
-
// use to unlock something
|
|
319
|
+
// use to unlock something; `"invalid"` and `"revoked"` are just as
|
|
226
320
|
// authentic but must never reach an `unlock()` call.
|
|
227
321
|
if (verifiedEnvelope.status === "valid") {
|
|
228
322
|
return { verdict: "licensed", envelope: verifiedEnvelope };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** S314c2 (D11): the one rule for a plugin project's manifest entry, shared by the server's
|
|
2
|
+
* sandbox (resolveManifestPath) and the CLI (resolveManifestEntry): src/plugin.tsx, else
|
|
3
|
+
* src/plugin.ts. The scaffolds write src/plugin.tsx and name it in their vite.config.ts, so
|
|
4
|
+
* .tsx wins when both exist, and `warn` is told that the other file is not read. */
|
|
5
|
+
export declare function resolvePluginManifestEntry(pluginDir: string, warn?: (message: string) => void): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/** S314c2 (D11): the one rule for a plugin project's manifest entry, shared by the server's
|
|
4
|
+
* sandbox (resolveManifestPath) and the CLI (resolveManifestEntry): src/plugin.tsx, else
|
|
5
|
+
* src/plugin.ts. The scaffolds write src/plugin.tsx and name it in their vite.config.ts, so
|
|
6
|
+
* .tsx wins when both exist, and `warn` is told that the other file is not read. */
|
|
7
|
+
export function resolvePluginManifestEntry(pluginDir, warn = (message) => console.warn(message)) {
|
|
8
|
+
const tsx = join(pluginDir, "src", "plugin.tsx");
|
|
9
|
+
const ts = join(pluginDir, "src", "plugin.ts");
|
|
10
|
+
const hasTsx = existsSync(tsx);
|
|
11
|
+
const hasTs = existsSync(ts);
|
|
12
|
+
if (hasTsx && hasTs) {
|
|
13
|
+
warn(`Both src/plugin.tsx and src/plugin.ts exist in ${pluginDir}: src/plugin.tsx is the plugin's entry and src/plugin.ts is not read. Remove one of them.`);
|
|
14
|
+
}
|
|
15
|
+
if (hasTsx)
|
|
16
|
+
return tsx;
|
|
17
|
+
if (hasTs)
|
|
18
|
+
return ts;
|
|
19
|
+
throw new Error(`No plugin entry found in ${pluginDir}: expected src/plugin.tsx or src/plugin.ts`);
|
|
20
|
+
}
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { type SampleContentFile, type ShippedInstallFacts } from "@kardalum/api-schemas";
|
|
2
2
|
/** The largest sample-content.json read to decide whether the sample ships,
|
|
3
|
-
* so the door's parse stays inside its validation budget.
|
|
3
|
+
* so the door's parse stays inside its validation budget. 2 MiB since the S311
|
|
4
|
+
* fix wave (it was 8): the largest first-party sample is about 5 KB, and at 8
|
|
5
|
+
* MiB a file the node count then refused still cost a door seconds of parsing. */
|
|
4
6
|
export declare const SAMPLE_CONTENT_MAX_BYTES: number;
|
|
5
|
-
/** S293: the package's sample-content.json as an install reads it.
|
|
7
|
+
/** S293: the package's sample-content.json as an install reads it. A file the
|
|
8
|
+
* schema refuses carries every issue in `details` (S311); its `reason` names
|
|
9
|
+
* the first few, since it is logged at install and shown at the door. */
|
|
6
10
|
export type ShippedSampleContent = {
|
|
7
11
|
status: "absent";
|
|
8
12
|
} | {
|
|
9
13
|
status: "unreadable";
|
|
10
14
|
reason: string;
|
|
15
|
+
details?: string[];
|
|
11
16
|
} | {
|
|
12
17
|
status: "ships";
|
|
13
18
|
file: SampleContentFile;
|
|
14
19
|
};
|
|
15
20
|
/** Absent, unreadable (not a regular file, over SAMPLE_CONTENT_MAX_BYTES, not
|
|
16
21
|
* JSON, or refused by the schema) or the parsed file. Never throws. The
|
|
17
|
-
* server's seeder reads through it, so the cap applies at install too
|
|
22
|
+
* server's seeder reads through it, so the cap applies at install too, and
|
|
23
|
+
* both gates' sample checks read the file through it once per run (S311). No
|
|
24
|
+
* word of the file itself reaches a reason: "not valid JSON" says enough, and
|
|
25
|
+
* the parser's own message quotes the text. */
|
|
18
26
|
export declare function readShippedSampleContent(dir: string): ShippedSampleContent;
|
|
27
|
+
/** What a read ships for the install interface: anything unreadable ships nothing. */
|
|
28
|
+
export declare function installFactsOf(sample: ShippedSampleContent): ShippedInstallFacts;
|
|
19
29
|
/** Never throws: anything unreadable ships nothing. */
|
|
20
30
|
export declare function readShippedInstallFacts(dir: string): ShippedInstallFacts;
|
|
31
|
+
/** S311 (D5): whether a sample-content.json can be consumed at all: it is the
|
|
32
|
+
* seed tree keyed to the plugin's own documentTypes, and it also ships with a
|
|
33
|
+
* starter a plugin bundles. Reads plain data, so it answers the same for a live
|
|
34
|
+
* manifest and the manifest.json the door parses. The CLI's build and pack
|
|
35
|
+
* steps and both gates call this one function. */
|
|
36
|
+
export declare function hasSampleContentConsumer(manifest: {
|
|
37
|
+
contributions?: unknown;
|
|
38
|
+
}): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lstatSync, readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { parseSampleContentFile } from "@kardalum/api-schemas";
|
|
4
|
+
import { listCapped } from "./delivery/support.js";
|
|
4
5
|
// S292 (2026-10-13-s292-what-the-wizard-may-ask-design.md, D8): what a
|
|
5
6
|
// package directory ships that its install's built-in questions are derived
|
|
6
7
|
// from. One definition for `kardalum plugin validate`'s `install options`
|
|
@@ -17,11 +18,16 @@ import { parseSampleContentFile } from "@kardalum/api-schemas";
|
|
|
17
18
|
// too, so the seeder parses only what the cap admits and a present but
|
|
18
19
|
// unreadable file is told apart from an absent one.
|
|
19
20
|
/** The largest sample-content.json read to decide whether the sample ships,
|
|
20
|
-
* so the door's parse stays inside its validation budget.
|
|
21
|
-
|
|
21
|
+
* so the door's parse stays inside its validation budget. 2 MiB since the S311
|
|
22
|
+
* fix wave (it was 8): the largest first-party sample is about 5 KB, and at 8
|
|
23
|
+
* MiB a file the node count then refused still cost a door seconds of parsing. */
|
|
24
|
+
export const SAMPLE_CONTENT_MAX_BYTES = 2 * 1024 * 1024;
|
|
22
25
|
/** Absent, unreadable (not a regular file, over SAMPLE_CONTENT_MAX_BYTES, not
|
|
23
26
|
* JSON, or refused by the schema) or the parsed file. Never throws. The
|
|
24
|
-
* server's seeder reads through it, so the cap applies at install too
|
|
27
|
+
* server's seeder reads through it, so the cap applies at install too, and
|
|
28
|
+
* both gates' sample checks read the file through it once per run (S311). No
|
|
29
|
+
* word of the file itself reaches a reason: "not valid JSON" says enough, and
|
|
30
|
+
* the parser's own message quotes the text. */
|
|
25
31
|
export function readShippedSampleContent(dir) {
|
|
26
32
|
const path = join(dir, "sample-content.json");
|
|
27
33
|
let size;
|
|
@@ -36,8 +42,12 @@ export function readShippedSampleContent(dir) {
|
|
|
36
42
|
? { status: "absent" }
|
|
37
43
|
: { status: "unreadable", reason: "sample-content.json cannot be read" };
|
|
38
44
|
}
|
|
39
|
-
if (size > SAMPLE_CONTENT_MAX_BYTES)
|
|
40
|
-
return {
|
|
45
|
+
if (size > SAMPLE_CONTENT_MAX_BYTES) {
|
|
46
|
+
return {
|
|
47
|
+
status: "unreadable",
|
|
48
|
+
reason: `sample-content.json is ${size} bytes, over the limit of ${SAMPLE_CONTENT_MAX_BYTES} bytes (${SAMPLE_CONTENT_MAX_BYTES / 1024 / 1024} MiB)`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
41
51
|
let raw;
|
|
42
52
|
try {
|
|
43
53
|
raw = JSON.parse(readFileSync(path, "utf8"));
|
|
@@ -46,12 +56,30 @@ export function readShippedSampleContent(dir) {
|
|
|
46
56
|
return { status: "unreadable", reason: "sample-content.json is not valid JSON" };
|
|
47
57
|
}
|
|
48
58
|
const parsed = parseSampleContentFile(raw);
|
|
49
|
-
|
|
59
|
+
if (parsed.ok)
|
|
60
|
+
return { status: "ships", file: parsed.file };
|
|
61
|
+
return { status: "unreadable", reason: `sample-content.json: ${listCapped(parsed.errors)}`, details: parsed.errors };
|
|
50
62
|
}
|
|
51
|
-
/**
|
|
52
|
-
export function
|
|
53
|
-
const sample = readShippedSampleContent(dir);
|
|
63
|
+
/** What a read ships for the install interface: anything unreadable ships nothing. */
|
|
64
|
+
export function installFactsOf(sample) {
|
|
54
65
|
if (sample.status !== "ships")
|
|
55
66
|
return { sampleContent: false };
|
|
56
67
|
return sample.file.description ? { sampleContent: true, sampleContentDescription: sample.file.description } : { sampleContent: true };
|
|
57
68
|
}
|
|
69
|
+
/** Never throws: anything unreadable ships nothing. */
|
|
70
|
+
export function readShippedInstallFacts(dir) {
|
|
71
|
+
return installFactsOf(readShippedSampleContent(dir));
|
|
72
|
+
}
|
|
73
|
+
/** S311 (D5): whether a sample-content.json can be consumed at all: it is the
|
|
74
|
+
* seed tree keyed to the plugin's own documentTypes, and it also ships with a
|
|
75
|
+
* starter a plugin bundles. Reads plain data, so it answers the same for a live
|
|
76
|
+
* manifest and the manifest.json the door parses. The CLI's build and pack
|
|
77
|
+
* steps and both gates call this one function. */
|
|
78
|
+
export function hasSampleContentConsumer(manifest) {
|
|
79
|
+
const contributions = manifest.contributions;
|
|
80
|
+
if (contributions === null || typeof contributions !== "object")
|
|
81
|
+
return false;
|
|
82
|
+
const declared = contributions;
|
|
83
|
+
const hasTypes = Array.isArray(declared.documentTypes) && declared.documentTypes.length > 0;
|
|
84
|
+
return hasTypes || (declared.bundledTemplate !== undefined && declared.bundledTemplate !== null);
|
|
85
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Names a package never carries, at any depth, a folder with everything under
|
|
2
|
+
* it: vendored and build folders, and env files (they can hold live secrets),
|
|
3
|
+
* `.env.example` excepted (placeholder values a reader copies). A bare file
|
|
4
|
+
* of one of these names is left out too. */
|
|
5
|
+
export declare const EXCLUDED_NAMES: readonly string[];
|
|
6
|
+
export declare function isExcludedSegment(segment: string): boolean;
|
|
7
|
+
export interface ShippedEntry {
|
|
8
|
+
/** Relative to the walked folder, with "/". */
|
|
9
|
+
path: string;
|
|
10
|
+
isDirectory: boolean;
|
|
11
|
+
/** A folder with nothing that ships inside it, which the build still
|
|
12
|
+
* creates; always false for a file. */
|
|
13
|
+
empty: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Every file and folder under `folder` that ships, parents before children,
|
|
16
|
+
* each folder's entries in name order. A link is never followed and never
|
|
17
|
+
* listed, a left-out name is skipped with everything under it, and a folder
|
|
18
|
+
* that is absent, a file or a link ships nothing. Iterative, so a deep tree
|
|
19
|
+
* costs no stack. */
|
|
20
|
+
export declare function walkShipped(folder: string): ShippedEntry[];
|
|
21
|
+
/** Why a file is not one the build carries into the package, for any number
|
|
22
|
+
* of paths under one package root, each folder read once (S311 second code
|
|
23
|
+
* fix). A path is relative to `root`, with "/"; the answer is null for a
|
|
24
|
+
* regular file reached through real folders only, none of them a left-out
|
|
25
|
+
* name, or the reason, which reads after the path: "public/dist/theme.css is
|
|
26
|
+
* inside public/dist/, which ...".
|
|
27
|
+
*
|
|
28
|
+
* The first segment is the folder the build opens by its own name
|
|
29
|
+
* (templates, public or media), which a case-insensitive host resolves in any
|
|
30
|
+
* case, as the build's copy does, and writes into the package under that
|
|
31
|
+
* name. Every segment below it must be spelled as its folder lists it: the
|
|
32
|
+
* build copies the names it reads, so on Windows or macOS a declared
|
|
33
|
+
* `Styles/Site.css` the file system would find as `styles/site.css` is not in
|
|
34
|
+
* the package under the declared name, and the marketplace (and any Linux
|
|
35
|
+
* install) reads names exactly. */
|
|
36
|
+
export declare function createShippedLookup(root: string): (path: string) => string | null;
|
|
37
|
+
/** createShippedLookup's answer for one path. A caller with many paths under
|
|
38
|
+
* one root makes one lookup and asks it each. */
|
|
39
|
+
export declare function whyNotShipped(root: string, path: string): string | null;
|