@kardalum/plugin-sdk 0.17.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.
Files changed (174) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +4 -3
  3. package/dist/assets/asset-picker.d.ts +11 -0
  4. package/dist/assets/asset-picker.js +109 -0
  5. package/dist/assets/asset-tree.d.ts +30 -0
  6. package/dist/assets/asset-tree.js +150 -0
  7. package/dist/built-in-editor-ids.d.ts +1 -0
  8. package/dist/built-in-editor-ids.js +20 -0
  9. package/dist/built-in-settings-schemas.d.ts +2 -0
  10. package/dist/built-in-settings-schemas.js +27 -0
  11. package/dist/built-in-value-schemas.js +3 -0
  12. package/dist/built-ins.js +10 -1
  13. package/dist/capabilities.js +5 -0
  14. package/dist/datatype-validation.js +18 -4
  15. package/dist/datatypes-entry.d.ts +1 -0
  16. package/dist/datatypes-entry.js +1 -0
  17. package/dist/entitlement-entry.d.ts +3 -2
  18. package/dist/entitlement-entry.js +13 -1
  19. package/dist/entitlement-gate.d.ts +18 -0
  20. package/dist/entitlement-gate.js +95 -21
  21. package/dist/entitlement-plan.d.ts +21 -0
  22. package/dist/entitlement-plan.js +26 -0
  23. package/dist/entitlement-types.d.ts +21 -4
  24. package/dist/entitlement.d.ts +29 -1
  25. package/dist/entitlement.js +39 -0
  26. package/dist/grid-arrow-step.d.ts +7 -0
  27. package/dist/grid-arrow-step.js +20 -0
  28. package/dist/index.d.ts +6 -1
  29. package/dist/index.js +7 -12
  30. package/dist/manifest-entry.d.ts +4 -0
  31. package/dist/manifest-entry.js +4 -0
  32. package/dist/manifest-schema.d.ts +5 -1
  33. package/dist/manifest-schema.js +7 -1
  34. package/dist/manifest.d.ts +21 -1
  35. package/dist/media/media-picker.js +32 -32
  36. package/dist/notify.d.ts +17 -0
  37. package/dist/notify.js +17 -0
  38. package/dist/richtext/block-panel.js +17 -18
  39. package/dist/richtext/extensions.js +10 -1
  40. package/dist/richtext/insert-menu.js +1 -1
  41. package/dist/richtext/kardalum-block.js +17 -17
  42. package/dist/richtext/style-listbox.js +1 -1
  43. package/dist/richtext-html-entry.d.ts +35 -0
  44. package/dist/richtext-html-entry.js +73 -0
  45. package/dist/structured-storage-types.d.ts +11 -0
  46. package/dist/tailwind.js +10 -3
  47. package/dist/tokens/tailwind-theme.css +176 -0
  48. package/dist/tokens/tokens.css +1 -0
  49. package/dist/tokens/tokens.json +2 -1
  50. package/dist/vendor-check.d.ts +39 -0
  51. package/dist/vendor-check.js +79 -0
  52. package/dist/vendor-entry.d.ts +3 -0
  53. package/dist/vendor-entry.js +9 -0
  54. package/dist/vendor-service.d.ts +20 -0
  55. package/dist/vendor-service.js +20 -0
  56. package/dist/views/asset-view.d.ts +6 -0
  57. package/dist/views/asset-view.js +55 -0
  58. package/dist/views/content-list-settings-view.js +1 -1
  59. package/dist/views/content-list-view.js +1 -1
  60. package/dist/views/html-code-editor.js +0 -1
  61. package/dist/views/image-view.js +1 -1
  62. package/dist/views/rich-text-view.js +30 -30
  63. package/node_modules/@kardalum/api-schemas/README.md +1 -1
  64. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +16 -14
  65. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
  66. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
  67. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
  68. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
  69. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
  70. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
  71. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
  72. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +16 -1
  73. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
  74. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
  75. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
  76. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
  77. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
  78. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
  79. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
  80. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
  81. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
  82. package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
  83. package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
  84. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +41 -15
  85. package/node_modules/@kardalum/api-schemas/dist/index.js +30 -10
  86. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
  87. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
  88. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +115 -1
  89. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +102 -1
  90. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
  91. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
  92. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
  93. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
  94. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
  95. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
  96. package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
  97. package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
  98. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
  99. package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
  100. package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
  101. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
  102. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
  103. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
  104. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
  105. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +227 -0
  106. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +157 -31
  107. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
  108. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
  109. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
  110. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
  111. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
  112. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
  113. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
  114. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
  115. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
  116. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
  117. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
  118. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  119. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
  120. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -11
  121. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
  122. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
  123. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
  124. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +5 -0
  125. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
  126. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
  127. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
  128. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
  129. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
  130. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
  131. package/node_modules/@kardalum/design-tokens/README.md +1 -1
  132. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
  133. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
  134. package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
  135. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
  136. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
  137. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  138. package/node_modules/@kardalum/design-tokens/dist/tokens.js +1 -0
  139. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  140. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
  141. package/node_modules/@kardalum/design-tokens/package.json +6 -3
  142. package/node_modules/@kardalum/plugin-package/README.md +1 -1
  143. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  144. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
  145. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  146. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
  147. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
  148. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
  149. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
  150. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +8 -4
  151. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
  152. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
  153. package/node_modules/@kardalum/plugin-package/dist/extract.js +1 -1
  154. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
  155. package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
  156. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
  157. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
  158. package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
  159. package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
  160. package/node_modules/@kardalum/ui/README.md +1 -1
  161. package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
  162. package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
  163. package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
  164. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
  165. package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
  166. package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
  167. package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
  168. package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
  169. package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
  170. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
  171. package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
  172. package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
  173. package/node_modules/@kardalum/ui/dist/index.js +1 -0
  174. package/package.json +17 -4
@@ -30,8 +30,8 @@
30
30
  * them, and they read as a closing caveat rather than as a feature.
31
31
  *
32
32
  * This package cannot name the SDK's `PluginContributions` (the SDK depends
33
- * on it), so the SDK asserts at the type level that these 16 keys are
34
- * exactly `keyof PluginContributions`: a seventeenth contribution added to the
33
+ * on it), so the SDK asserts at the type level that these 17 keys are
34
+ * exactly `keyof PluginContributions`: an eighteenth contribution added to the
35
35
  * contract and not classified here is a compile error in the SDK's build.
36
36
  */
37
37
  export const CONTRIBUTION_EMISSION_ORDER = [
@@ -49,6 +49,7 @@ export const CONTRIBUTION_EMISSION_ORDER = [
49
49
  "serializers",
50
50
  "apiRoutes",
51
51
  "exposedServices",
52
+ "notifications",
52
53
  "bundledPlugins",
53
54
  "bundledTemplate",
54
55
  ];
@@ -64,11 +65,12 @@ export const ASSERTION_KEYS = ["externalNetwork", "filesystemAccess"];
64
65
  *
65
66
  * Classification follows S267 section 6 and its stated principle: a
66
67
  * capability is mediated when the platform decides the outcome, and promised
67
- * when the plugin does. Every contribution below is mediated,
68
+ * when the plugin does. Every contribution below is mediated but `notifications`,
68
69
  * because every one of them is consumed by the host: it mounts the view,
69
70
  * dispatches the hook, runs the task, registers the template. The only
70
- * contribution that is not wholly mediated is `apiRoutes`, and only for
71
- * the tiers that let traffic reach a handler without a signed-in session.
71
+ * contribution besides `notifications` that is not wholly mediated is
72
+ * `apiRoutes`, and only for the tiers that let traffic reach a handler
73
+ * without a signed-in session.
72
74
  *
73
75
  * `exposedServices`, `bundledPlugins` and `bundledTemplate` are not named
74
76
  * in section 6's automatic list, which enumerates a policy rather than the
@@ -101,13 +103,16 @@ const CONTRIBUTION_RULES = {
101
103
  mediaProcessors: { derives: "one", id: "media.processor", mediation: "mediated", actionGated: false },
102
104
  serializers: { derives: "one", id: "api.serializer", mediation: "mediated", actionGated: false },
103
105
  exposedServices: { derives: "one", id: "service.exposed", mediation: "mediated", actionGated: false },
106
+ // S314n3 (D1): the one contribution that is promised. The host delivers each send, but
107
+ // what the plugin sends, to whom and how often is the plugin's code, so a reviewer reads it.
108
+ notifications: { derives: "one", id: "admin.notifications", mediation: "promised", actionGated: false },
104
109
  bundledPlugins: { derives: "one", id: "bundle.plugin", mediation: "mediated", actionGated: false },
105
110
  bundledTemplate: { derives: "one", id: "bundle.template", mediation: "mediated", actionGated: false },
106
111
  apiRoutes: { derives: "perApiRouteTier", actionGated: true },
107
112
  };
108
113
  /** Whether this contribution kind sits behind a named permission action.
109
114
  * Lives on CONTRIBUTION_RULES rather than in a separate list, because that
110
- * record is compiler-total over the 16 contribution keys: a seventeenth key
115
+ * record is compiler-total over the 17 contribution keys: an eighteenth key
111
116
  * cannot be added without classifying it here. */
112
117
  export function isActionGated(key) {
113
118
  return CONTRIBUTION_RULES[key].actionGated;
@@ -169,6 +174,37 @@ const ASSERTION_ENTRIES = ASSERTION_KEYS.map((key) => [key, ASSERTION_RULES[key]
169
174
  * has to answer that question without the manifest.
170
175
  */
171
176
  const STRUCTURED_STORAGE_ID = "storage.structured";
177
+ /** S320 (plan P7): derived from the top-level `vendorService`, not from a
178
+ * contribution: the host makes the call, so it is mediated. */
179
+ const VENDOR_SERVICE_ID = "network.vendorService";
180
+ const VendorUrlCtor = globalThis.URL;
181
+ const VENDOR_LOCAL_HOSTS = ["localhost", "127.0.0.1", "[::1]"];
182
+ const VENDOR_ORIGIN_MAX = 255;
183
+ /** The declared vendor service's host, or null when the origin is malformed. */
184
+ function vendorServiceHost(declaration) {
185
+ if (declaration === null || typeof declaration !== "object")
186
+ return null;
187
+ const value = declaration.origin;
188
+ if (typeof value !== "string" || value.length === 0 || value.length > VENDOR_ORIGIN_MAX)
189
+ return null;
190
+ let url;
191
+ try {
192
+ url = new VendorUrlCtor(value);
193
+ }
194
+ catch {
195
+ return null;
196
+ }
197
+ if (url.username !== "" || url.password !== "")
198
+ return null;
199
+ if (url.protocol === "http:") {
200
+ if (!VENDOR_LOCAL_HOSTS.includes(url.hostname))
201
+ return null;
202
+ }
203
+ else if (url.protocol !== "https:") {
204
+ return null;
205
+ }
206
+ return url.origin === value ? url.host : null;
207
+ }
172
208
  /** Every capability id this contract can produce, for the readers that
173
209
  * need to be pinned against it (the marketplace's static mirror) and for
174
210
  * the reference page S289 generates. */
@@ -179,6 +215,7 @@ export const CAPABILITY_IDS = [
179
215
  return rule.derives === "one" ? [rule.id] : API_ROUTE_TIERS.map((entry) => entry.id);
180
216
  }),
181
217
  ...ASSERTION_ENTRIES.map(([, id]) => id),
218
+ VENDOR_SERVICE_ID,
182
219
  ];
183
220
  // ---------------------------------------------------------------------------
184
221
  // Reading a declaration's readable detail
@@ -327,6 +364,14 @@ export function deriveCapabilities(manifest) {
327
364
  });
328
365
  }
329
366
  }
367
+ // S320 (plan P7): the vendor service. Mediated: the host makes the call, to
368
+ // this origin only, and sends a token, never the key. Its detail is the host
369
+ // the install screen names. Declaring one implies outbound network use, so
370
+ // `network.external` is emitted below even without the assertion.
371
+ const vendorHost = vendorServiceHost(source.vendorService);
372
+ if (vendorHost !== null) {
373
+ capabilities.push({ id: VENDOR_SERVICE_ID, payload: { count: 1, details: [vendorHost] }, mediation: "mediated" });
374
+ }
330
375
  const assertions = source.assertions !== null && typeof source.assertions === "object"
331
376
  ? source.assertions
332
377
  : {};
@@ -342,5 +387,8 @@ export function deriveCapabilities(manifest) {
342
387
  continue;
343
388
  capabilities.push({ id, payload: { count: 1, details: [reason] }, mediation: "promised" });
344
389
  }
390
+ if (vendorHost !== null && !capabilities.some((c) => c.id === ASSERTION_RULES.externalNetwork)) {
391
+ capabilities.push({ id: ASSERTION_RULES.externalNetwork, payload: { count: 1, details: [] }, mediation: "promised" });
392
+ }
345
393
  return capabilities;
346
394
  }
@@ -4,7 +4,7 @@ import { gzipSync } from "node:zlib";
4
4
  import { declaresClientBundle } from "../client-bundle.js";
5
5
  import { BUNDLE_MAX_GZIP_BYTES, BUNDLE_WARN_SHARE, formatBinarySize } from "./limits.js";
6
6
  import { failed, passed, warning } from "./support.js";
7
- const kb = (bytes) => `${Math.ceil(bytes / 1024)} KB`;
7
+ const kb = (bytes) => `${Math.ceil(bytes / 1024)} KiB`;
8
8
  /** Every regular file under `dir`, at any depth, never following a link. */
9
9
  function filesUnder(dir) {
10
10
  const files = [];
@@ -3,3 +3,6 @@ export { iconNamesCheck } from "./icons.js";
3
3
  export declare const requiredViewsCheck: DeliveryCheck;
4
4
  export declare const apiRoutesCheck: DeliveryCheck;
5
5
  export declare const databaseCheck: DeliveryCheck;
6
+ /** S320 (spec 3c): a listed plugin's vendor service is https. A manifest may
7
+ * name http://localhost while in development; nothing published may. */
8
+ export declare const vendorServiceCheck: DeliveryCheck;
@@ -1,4 +1,4 @@
1
- import { API_ROUTE_ACCESS_TIERS, API_ROUTE_METHODS, TIER1_DIALECTS, checkApiRouteTiers, listIssues } from "@kardalum/api-schemas";
1
+ import { API_ROUTE_ACCESS_TIERS, API_ROUTE_METHODS, TIER1_DIALECTS, checkApiRouteTiers, listIssues, parseVendorServiceOrigin } from "@kardalum/api-schemas";
2
2
  import { contributionsOf, failed, list, passed, record } from "./support.js";
3
3
  export { iconNamesCheck } from "./icons.js";
4
4
  function hasContent(value) {
@@ -58,3 +58,20 @@ export const databaseCheck = {
58
58
  return passed(`declared: ${supported.map(String).join(", ")}`);
59
59
  },
60
60
  };
61
+ /** S320 (spec 3c): a listed plugin's vendor service is https. A manifest may
62
+ * name http://localhost while in development; nothing published may. */
63
+ export const vendorServiceCheck = {
64
+ name: "vendor service origin is https",
65
+ rule: "`vendorService.origin`, when declared, is an https origin only (scheme, host and port, no path): an http origin, localhost included, is for development and is refused at publish.",
66
+ gates: ["cli", "door"],
67
+ needsManifest: true,
68
+ run: ({ manifest }) => {
69
+ if (manifest.vendorService === undefined)
70
+ return passed("none declared");
71
+ const origin = record(manifest.vendorService)?.origin;
72
+ const parsed = parseVendorServiceOrigin(origin, { allowLocalHttp: false });
73
+ if (!parsed.ok)
74
+ return failed(`vendorService.origin ${parsed.reason}`);
75
+ return passed(`declared: ${parsed.origin}`);
76
+ },
77
+ };
@@ -10,5 +10,5 @@ export declare const BUNDLE_WARN_SHARE = 0.9;
10
10
  /** A byte count as the delivery page and every rule string write it (S311 docs
11
11
  * wave): binary units, 1 KiB being 1024 bytes, the largest that divides the
12
12
  * count exactly, so a limit is never rounded into a different number. A check's
13
- * own message prints the same size as KB or MB. */
13
+ * own message prints the same size, with the same units. */
14
14
  export declare function formatBinarySize(bytes: number): string;
@@ -11,7 +11,7 @@ export const BUNDLE_WARN_SHARE = 0.9;
11
11
  /** A byte count as the delivery page and every rule string write it (S311 docs
12
12
  * wave): binary units, 1 KiB being 1024 bytes, the largest that divides the
13
13
  * count exactly, so a limit is never rounded into a different number. A check's
14
- * own message prints the same size as KB or MB. */
14
+ * own message prints the same size, with the same units. */
15
15
  export function formatBinarySize(bytes) {
16
16
  if (bytes % (1024 * 1024) === 0)
17
17
  return `${bytes / 1024 / 1024} MiB`;
@@ -1,9 +1,9 @@
1
- import { FILE_NAME_MAX, MAX_DOC_PAGE_BYTES, MAX_DOC_PAGES, MAX_TEMPLATE_PAYLOAD_ENTRIES, PLUGIN_AUTHOR_MAX, PLUGIN_CMS_VERSION_MAX, PLUGIN_DESCRIPTION_MAX, PLUGIN_ID_MAX, PLUGIN_LICENSE_MAX, PLUGIN_LOCALE_KEY_MAX_LENGTH, PLUGIN_LOCALE_MAX_BYTES, PLUGIN_LOCALE_MAX_KEYS, PLUGIN_LOCALE_VALUE_MAX_LENGTH, PLUGIN_NAME_MAX, PLUGIN_VERSION_MAX, SAMPLE_CONTENT_MAX_MEDIA, SAMPLE_CONTENT_MAX_NODES, } from "@kardalum/api-schemas";
1
+ import { FILE_NAME_MAX, MAX_DOC_PAGE_BYTES, MAX_ASSET_CONTENT_BYTES, MAX_DOC_PAGES, MAX_TEMPLATE_CONTENT_BYTES, MAX_TEMPLATE_PAYLOAD_ENTRIES, PLUGIN_AUTHOR_MAX, PLUGIN_CMS_VERSION_MAX, PLUGIN_DESCRIPTION_MAX, PLUGIN_ID_MAX, PLUGIN_LICENSE_MAX, PLUGIN_LOCALE_KEY_MAX_LENGTH, PLUGIN_LOCALE_MAX_BYTES, PLUGIN_LOCALE_MAX_KEYS, PLUGIN_LOCALE_VALUE_MAX_LENGTH, PLUGIN_NAME_MAX, PLUGIN_VERSION_MAX, SAMPLE_CONTENT_MAX_MEDIA, SAMPLE_CONTENT_MAX_NODES, } from "@kardalum/api-schemas";
2
2
  import { ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "../extract.js";
3
3
  import { COVER_HEIGHT, COVER_WIDTH } from "../package-contract.js";
4
4
  import { archiveNamesCheck } from "./archive-names.js";
5
5
  import { bundleSizeCheck } from "./bundle.js";
6
- import { apiRoutesCheck, databaseCheck, iconNamesCheck, requiredViewsCheck } from "./contributions.js";
6
+ import { apiRoutesCheck, databaseCheck, iconNamesCheck, requiredViewsCheck, vendorServiceCheck } from "./contributions.js";
7
7
  import { labelLanguagesCheck } from "./label-languages.js";
8
8
  import { BUNDLE_MAX_GZIP_BYTES, MANIFEST_MAX_BYTES, formatBinarySize } from "./limits.js";
9
9
  import { localeParityCheck, localesCheck } from "./locales.js";
@@ -11,7 +11,7 @@ import { coverCheck, docsContractCheck, docsLinksCheck, readmeCheck } from "./pa
11
11
  import { installOptionsCheck, sampleContentCheck } from "./sample-content.js";
12
12
  import { SAMPLE_CONTENT_MAX_BYTES, readShippedSampleContent } from "../sample-content.js";
13
13
  import { describeError } from "./support.js";
14
- import { assetsCheck, entryBudgetCheck, templateDeclarationsCheck, templateFilesCheck, templateWiringCheck } from "./templates.js";
14
+ import { assetsCheck, entryBudgetCheck, payloadSizesCheck, templateDeclarationsCheck, templateFilesCheck, templateWiringCheck } from "./templates.js";
15
15
  /** Runs the checks of one gate in order. A check that cannot run because the
16
16
  * manifest did not parse says so; a check that throws is a failed result, never
17
17
  * an exception that escapes the gate (a directory where a file belongs is the
@@ -42,6 +42,7 @@ export const DELIVERY_CHECKS = [
42
42
  requiredViewsCheck,
43
43
  apiRoutesCheck,
44
44
  databaseCheck,
45
+ vendorServiceCheck,
45
46
  iconNamesCheck,
46
47
  readmeCheck,
47
48
  coverCheck,
@@ -56,6 +57,7 @@ export const DELIVERY_CHECKS = [
56
57
  templateFilesCheck,
57
58
  templateWiringCheck,
58
59
  assetsCheck,
60
+ payloadSizesCheck,
59
61
  entryBudgetCheck,
60
62
  archiveNamesCheck,
61
63
  bundleSizeCheck,
@@ -78,7 +80,7 @@ export const GATE_ONLY_CHECKS = [
78
80
  { name: "required-files", gate: "door", rule: "`manifest.json`, `server/plugin.js` and `server/package.json` (declaring the ESM marker) are present, plus `remoteEntry.js` when a view-bearing contribution is declared.", skippedAtDoor: false },
79
81
  { name: "manifest-consistency", gate: "door", rule: "The manifest's id and version match the submission record, and the extracted `manifest.json` is byte for byte the one read at upload.", skippedAtDoor: false },
80
82
  { name: "reserved-names", gate: "door", rule: "Nothing at the package root is named `kardalum-license.json`, in any case: the marketplace writes that file into every licensed download.", skippedAtDoor: false },
81
- { name: "bundle-members", gate: "door", rule: "Bundles only: every member id is a published, free listing.", skippedAtDoor: false },
83
+ { name: "bundle-members", gate: "door", rule: "Bundles only: every member id is a published listing, and a paid member belongs to the bundle's author.", skippedAtDoor: false },
82
84
  { name: "internal-validation-error", gate: "door", rule: "Not a rule a package breaks: the marketplace could not read the stored package, or could not finish checking it in time. Submit again under a new version number and every check runs afresh.", skippedAtDoor: false },
83
85
  ];
84
86
  export function runDeliveryChecks(context, gate) {
@@ -116,6 +118,8 @@ export function renderDeliveryLimits() {
116
118
  ["Cover image", `${COVER_WIDTH} by ${COVER_HEIGHT} pixels`, "`marketplace/cover.png`, exactly"],
117
119
  ["Docs pages", `${MAX_DOC_PAGES} pages`, "listed in the manifest's `docs`"],
118
120
  ["One docs page", formatBinarySize(MAX_DOC_PAGE_BYTES), "each page other than `README.md`"],
121
+ ["One template file", formatBinarySize(MAX_TEMPLATE_CONTENT_BYTES), "each declared file under `templates/`: a site's default limit, which the site may raise"],
122
+ ["One asset", formatBinarySize(MAX_ASSET_CONTENT_BYTES), "each declared asset under `public/`: a site's default limit, which the site may raise"],
119
123
  ["One locale file", formatBinarySize(PLUGIN_LOCALE_MAX_BYTES), "each `locales/<language>.json`"],
120
124
  ["Keys in a locale file", `${PLUGIN_LOCALE_MAX_KEYS} keys`, "each `locales/<language>.json`"],
121
125
  ["A locale key", `${PLUGIN_LOCALE_KEY_MAX_LENGTH} characters`, "letters, digits, `_` and `-`, in segments joined by dots"],
@@ -4,3 +4,4 @@ export declare const templateFilesCheck: DeliveryCheck;
4
4
  export declare const templateWiringCheck: DeliveryCheck;
5
5
  export declare const assetsCheck: DeliveryCheck;
6
6
  export declare const entryBudgetCheck: DeliveryCheck;
7
+ export declare const payloadSizesCheck: DeliveryCheck;
@@ -1,7 +1,9 @@
1
+ import { lstatSync } from "node:fs";
1
2
  import { join } from "node:path";
2
- import { MAX_TEMPLATE_PAYLOAD_ENTRIES, PluginAssetPathSchema, PluginTemplateFileSchema, PluginTemplatePayloadSchema, RESERVED_ASSET_ROOTS, TEMPLATE_KINDS, checkTemplateAndAssetDeclarations, effectiveDocsPages, listIssues, } from "@kardalum/api-schemas";
3
+ import { MAX_ASSET_CONTENT_BYTES, MAX_TEMPLATE_CONTENT_BYTES, MAX_TEMPLATE_PAYLOAD_ENTRIES, PluginAssetPathSchema, PluginTemplateFileSchema, PluginTemplatePayloadSchema, RESERVED_ASSET_ROOTS, TEMPLATE_KINDS, checkTemplateAndAssetDeclarations, effectiveDocsPages, isAssetTextPath, listIssues, } from "@kardalum/api-schemas";
3
4
  import { docsFilesToShip } from "../docs-contract.js";
4
5
  import { createShippedLookup, walkShipped } from "../shipped-files.js";
6
+ import { formatBinarySize } from "./limits.js";
5
7
  import { contributionsOf, failed, list, orList, passed, plural, record } from "./support.js";
6
8
  // S196 and S268: any plugin may declare templates and assets, whatever its
7
9
  // listing label. Each check here asks its own question of the declaration and
@@ -156,3 +158,58 @@ export const entryBudgetCheck = {
156
158
  return passed(message);
157
159
  },
158
160
  };
161
+ /** A regular file's size, or null for anything else (a missing file is the files checks' to report). */
162
+ function fileSize(path) {
163
+ try {
164
+ const stat = lstatSync(path, { throwIfNoEntry: false });
165
+ return stat?.isFile() ? stat.size : null;
166
+ }
167
+ catch {
168
+ return null;
169
+ }
170
+ }
171
+ // S314c3 (D10): a site holds a template to KARDALUM_MAX_TEMPLATE_BYTES and an asset to
172
+ // KARDALUM_MAX_ASSET_BYTES, and an install refuses a package with a larger file whole (D9). A build
173
+ // cannot know the site, so it holds the package to the defaults, and a package that passes installs
174
+ // on any site left at them.
175
+ export const payloadSizesCheck = {
176
+ name: "template and asset sizes",
177
+ rule: `Every declared template file is at most ${formatBinarySize(MAX_TEMPLATE_CONTENT_BYTES)}, and every declared asset and every text file under \`public/\` at most ${formatBinarySize(MAX_ASSET_CONTENT_BYTES)}: ` +
178
+ "the defaults of a site's own limits (`KARDALUM_MAX_TEMPLATE_BYTES`, `KARDALUM_MAX_ASSET_BYTES`), so the package installs on any site left at them.",
179
+ gates: ["cli", "door"],
180
+ needsManifest: true,
181
+ run: ({ dir, manifest }) => {
182
+ const c = contributionsOf(manifest);
183
+ const templates = list(c.templates).flatMap((raw) => {
184
+ const file = record(raw)?.file;
185
+ // An unusable path is reported by `template declarations valid`; never join it.
186
+ return typeof file === "string" && PluginTemplateFileSchema.safeParse(file).success ? [file] : [];
187
+ });
188
+ const assets = list(c.assets).filter((a) => typeof a === "string" && PluginAssetPathSchema.safeParse(a).success);
189
+ // The install also holds an undeclared text file under public/ to the asset limit (it lands as
190
+ // a plain file the asset editor opens), so the build does too, from the same extension list.
191
+ const declared = new Set(assets);
192
+ const undeclaredText = walkShipped(join(dir, "public")).filter((e) => !e.isDirectory && !declared.has(e.path) && isAssetTextPath(e.path)).map((e) => e.path);
193
+ if (templates.length === 0 && assets.length === 0 && undeclaredText.length === 0)
194
+ return passed("no templates or assets declared");
195
+ const problems = [];
196
+ for (const file of templates) {
197
+ const size = fileSize(join(dir, "templates", ...file.split("/")));
198
+ if (size !== null && size > MAX_TEMPLATE_CONTENT_BYTES)
199
+ problems.push(`${file}: ${size} bytes, over the ${formatBinarySize(MAX_TEMPLATE_CONTENT_BYTES)} a template may hold`);
200
+ }
201
+ for (const path of assets) {
202
+ const size = fileSize(join(dir, "public", ...path.split("/")));
203
+ if (size !== null && size > MAX_ASSET_CONTENT_BYTES)
204
+ problems.push(`${path}: ${size} bytes, over the ${formatBinarySize(MAX_ASSET_CONTENT_BYTES)} an asset may hold`);
205
+ }
206
+ for (const path of undeclaredText) {
207
+ const size = fileSize(join(dir, "public", ...path.split("/")));
208
+ if (size !== null && size > MAX_ASSET_CONTENT_BYTES)
209
+ problems.push(`${path}: ${size} bytes, over the ${formatBinarySize(MAX_ASSET_CONTENT_BYTES)} an asset may hold`);
210
+ }
211
+ if (problems.length > 0)
212
+ return failed(`${plural(problems.length, "file")} over the size a site holds by default`, problems);
213
+ return passed(`${plural(templates.length, "template")}, ${plural(assets.length, "asset")}: within the default limits`);
214
+ },
215
+ };
@@ -233,7 +233,7 @@ export function createEntryGate() {
233
233
  return { ok: false, reason: pathRefusal };
234
234
  totalBytes += entry.uncompressedSize;
235
235
  if (totalBytes > MAX_TOTAL_BYTES)
236
- return { ok: false, reason: `archive expands beyond the ${MAX_TOTAL_BYTES / 1024 / 1024} MB limit` };
236
+ return { ok: false, reason: `archive expands beyond the ${MAX_TOTAL_BYTES / 1024 / 1024} MiB limit` };
237
237
  return { ok: true, name, isDirectory };
238
238
  };
239
239
  }
@@ -1,8 +1,10 @@
1
1
  export type { PackageSignatureSidecar, SignatureEnvelope, TrustedKey, VerifyFailureReason, VerifyResult, } from "./types.js";
2
2
  export { VERIFY_FAILURE_REASONS } from "./types.js";
3
3
  export { canonicalizeEnvelope, deriveKeyId, generateSigningKeyPair, signEnvelope, verifyEnvelope, } from "./envelope.js";
4
- export type { LicenseChallenge, LicenseVerdictEnvelope, LicenseVerdictResult, LicenseVerdictSignatureResult, SignedLicenseVerdict, TamperKind, } from "./license-verdict.js";
5
- export { canonicalizeLicenseVerdict, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_VERDICT_DETAIL_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
4
+ export type { LicenseChallenge, LicenseTermState, LicenseVerdictEnvelope, LicenseVerdictResult, LicenseVerdictSignatureResult, LicenseVerdictTerm, SignedLicenseVerdict, TamperKind, } from "./license-verdict.js";
5
+ export { canonicalizeLicenseVerdict, canonicalizeLicenseVerdictTerm, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_TERM_STATES, LICENSE_VERDICT_DETAIL_MAX, LICENSE_VERDICT_PLAN_ID_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, signLicenseVerdictWithTerm, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
6
+ export { VENDOR_TOKEN_LEEWAY_SECONDS, VENDOR_TOKEN_SIGNING_PREFIX, signVendorToken, verifyVendorToken } from "./vendor-token.js";
7
+ export type { VendorTokenFailure, VendorTokenVerifyResult } from "./vendor-token.js";
6
8
  export { hashBuffer, hashArchive, hashDirectories } from "./hash.js";
7
9
  export type { AdmittedEntry, PlannedEntry } from "./extract.js";
8
10
  export { createEntryGate, createPathKeyGate, decodeEntryName, ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES, normalizeEntryName, plannedEntryRefusal, } from "./extract.js";
@@ -1,6 +1,8 @@
1
1
  export { VERIFY_FAILURE_REASONS } from "./types.js";
2
2
  export { canonicalizeEnvelope, deriveKeyId, generateSigningKeyPair, signEnvelope, verifyEnvelope, } from "./envelope.js";
3
- export { canonicalizeLicenseVerdict, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_VERDICT_DETAIL_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
3
+ export { canonicalizeLicenseVerdict, canonicalizeLicenseVerdictTerm, createLicenseChallenge, ENTITLEMENT_MAX_AGE_MS, hashLicenseKey, LICENSE_TERM_STATES, LICENSE_VERDICT_DETAIL_MAX, LICENSE_VERDICT_PLAN_ID_MAX, MAX_VERDICT_AGE_MS, signLicenseVerdict, signLicenseVerdictWithTerm, verifyLicenseVerdict, verifyLicenseVerdictSignature, } from "./license-verdict.js";
4
+ // S320: the vendor token (spec 3a).
5
+ export { VENDOR_TOKEN_LEEWAY_SECONDS, VENDOR_TOKEN_SIGNING_PREFIX, signVendorToken, verifyVendorToken } from "./vendor-token.js";
4
6
  export { hashBuffer, hashArchive, hashDirectories } from "./hash.js";
5
7
  export { createEntryGate, createPathKeyGate, decodeEntryName, ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, entryViolation, extractArtifact, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES, normalizeEntryName, plannedEntryRefusal, } from "./extract.js";
6
8
  export { EXCLUDED_NAMES, createShippedLookup, isExcludedSegment, walkShipped, whyNotShipped } from "./shipped-files.js";
@@ -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 — see
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) — derived, never assigned. */
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` — no source
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" — it is the only check here a
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 — there is no way to hand
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 — a retry is a new
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 — it plays no other role on the caller's side. */
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`) — a real verdict, safe to show the
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) — the
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 — the nonce (see `createLicenseChallenge`'s
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 — the nonce already closes the gap this
129
- * was guarding — but it did fail a paying customer's install outright the
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 — the
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 — see `LicenseChallenge`'s doc
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 — never
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. `tamper` and then `detail` are appended last and only
161
- * when present, so an envelope without them produces exactly the bytes it
162
- * did before the fields existed (pinned by a test): old signatures keep
163
- * verifying. */
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;