@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
@@ -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
- /** A cheap SECONDARY bound only — the nonce (see `createLicenseChallenge`'s
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 — the nonce already closes the gap this
16
- * was guarding — but it did fail a paying customer's install outright the
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 — the
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 — see `LicenseChallenge`'s doc
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
- /** Explicit field order, exactly like canonicalizeEnvelope — never
57
- * JSON.stringify of the object itself, whose key order is not guaranteed
58
- * across producers. `tamper` and then `detail` are appended last and only
59
- * when present, so an envelope without them produces exactly the bytes it
60
- * did before the fields existed (pinned by a test): old signatures keep
61
- * verifying. */
62
- export function canonicalizeLicenseVerdict(envelope) {
63
- return Buffer.from(JSON.stringify({
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 — null and "absent" mean the
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 `verifyLicenseVerdict` and
112
- * `verifyLicenseVerdictSignature` so there is one definition of "authentic". */
113
- function checkSignature(envelope, signature, trustedKeys) {
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) === envelope.keyId;
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, canonicalizeLicenseVerdict(envelope), createPublicKey({ key: Buffer.from(match.publicKey, "base64"), format: "der", type: "spki" }), Buffer.from(signature, "base64"));
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
- function signedFieldsOnly(envelope) {
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 — and without the
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 — `"invalid"` and `"revoked"` are just as
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,24 @@
1
+ import { type VendorTokenPayload } from "@kardalum/api-schemas";
2
+ import type { TrustedKey } from "./types.js";
3
+ export declare const VENDOR_TOKEN_SIGNING_PREFIX: string;
4
+ /** Spec 3e: clock leeway either side. */
5
+ export declare const VENDOR_TOKEN_LEEWAY_SECONDS = 60;
6
+ export type VendorTokenFailure = "missing" | "malformed" | "bad_signature" | "expired";
7
+ export type VendorTokenVerifyResult = {
8
+ ok: true;
9
+ payload: VendorTokenPayload;
10
+ } | {
11
+ ok: false;
12
+ reason: VendorTokenFailure;
13
+ };
14
+ /** The marketplace's signer. Throws RangeError for a payload the schema refuses or past the caps. */
15
+ export declare function signVendorToken(payload: VendorTokenPayload, privateKeyBase64: string): string;
16
+ /**
17
+ * The author's server's check of the signature and the clock (spec 3e). It
18
+ * does not check the plugin, the audience or `live`: createVendorLicenceCheck
19
+ * (@kardalum/plugin-sdk/vendor) does, because only it knows what it expects.
20
+ */
21
+ export declare function verifyVendorToken(token: unknown, trustedKeys: TrustedKey[], opts?: {
22
+ now?: Date;
23
+ leewaySeconds?: number;
24
+ }): VendorTokenVerifyResult;
@@ -0,0 +1,118 @@
1
+ import { createPrivateKey, createPublicKey, sign, verify } from "node:crypto";
2
+ import { VENDOR_TOKEN_MAX_LENGTH, VENDOR_TOKEN_PAYLOAD_MAX_BYTES, VENDOR_TOKEN_TYPE, VendorTokenPayloadSchema, } from "@kardalum/api-schemas";
3
+ import { deriveKeyId } from "./envelope.js";
4
+ // S320 (spec 3a, D4, D5): the vendor token. `<payload>.<signature>`, both
5
+ // base64url without padding. The signature is Ed25519, by the licence verdict
6
+ // key, over the purpose string and the payload segment as it travels (plan
7
+ // P1), so a token's bytes can never be a verdict's canonical JSON (which
8
+ // starts with "{") and the reverse. Parsed without a regex: split on the last
9
+ // ".", linear checks, length caps, then the schema.
10
+ export const VENDOR_TOKEN_SIGNING_PREFIX = `${VENDOR_TOKEN_TYPE}.`;
11
+ /** Spec 3e: clock leeway either side. */
12
+ export const VENDOR_TOKEN_LEEWAY_SECONDS = 60;
13
+ const SIGNATURE_BYTES = 64;
14
+ const termStatesMatch = true;
15
+ void termStatesMatch;
16
+ function signedBytes(payloadSegment) {
17
+ return Buffer.from(VENDOR_TOKEN_SIGNING_PREFIX + payloadSegment, "ascii");
18
+ }
19
+ /** The payload's JSON in the schema's field order, so one payload has one spelling. */
20
+ function payloadText(p) {
21
+ return JSON.stringify({
22
+ typ: p.typ, kid: p.kid, pluginId: p.pluginId, aud: p.aud, domain: p.domain, live: p.live,
23
+ plan: { id: p.plan.id, key: p.plan.key, name: p.plan.name },
24
+ term: { state: p.term.state, endsAt: p.term.endsAt },
25
+ iat: p.iat, exp: p.exp, jti: p.jti,
26
+ });
27
+ }
28
+ /** The marketplace's signer. Throws RangeError for a payload the schema refuses or past the caps. */
29
+ export function signVendorToken(payload, privateKeyBase64) {
30
+ const parsed = VendorTokenPayloadSchema.safeParse(payload);
31
+ if (!parsed.success)
32
+ throw new RangeError("signVendorToken: the payload is malformed");
33
+ const text = Buffer.from(payloadText(parsed.data), "utf8");
34
+ if (text.length > VENDOR_TOKEN_PAYLOAD_MAX_BYTES)
35
+ throw new RangeError("signVendorToken: the payload is over 4 KiB");
36
+ const segment = text.toString("base64url");
37
+ const key = createPrivateKey({ key: Buffer.from(privateKeyBase64, "base64"), format: "der", type: "pkcs8" });
38
+ const token = `${segment}.${sign(null, signedBytes(segment), key).toString("base64url")}`;
39
+ if (token.length > VENDOR_TOKEN_MAX_LENGTH)
40
+ throw new RangeError("signVendorToken: the token is too long");
41
+ return token;
42
+ }
43
+ /** Plan P2: a segment counts only in its one canonical base64url spelling. */
44
+ function decodeSegment(segment) {
45
+ if (segment.length === 0)
46
+ return null;
47
+ const bytes = Buffer.from(segment, "base64url");
48
+ return bytes.toString("base64url") === segment ? bytes : null;
49
+ }
50
+ function keyFor(kid, trustedKeys) {
51
+ return trustedKeys.find((k) => {
52
+ try {
53
+ return deriveKeyId(k.publicKey) === kid;
54
+ }
55
+ catch {
56
+ return false;
57
+ }
58
+ });
59
+ }
60
+ /**
61
+ * The author's server's check of the signature and the clock (spec 3e). It
62
+ * does not check the plugin, the audience or `live`: createVendorLicenceCheck
63
+ * (@kardalum/plugin-sdk/vendor) does, because only it knows what it expects.
64
+ */
65
+ export function verifyVendorToken(token, trustedKeys, opts = {}) {
66
+ if (token === undefined || token === null || token === "")
67
+ return { ok: false, reason: "missing" };
68
+ if (typeof token !== "string" || token.length > VENDOR_TOKEN_MAX_LENGTH)
69
+ return { ok: false, reason: "malformed" };
70
+ const dot = token.lastIndexOf(".");
71
+ if (dot <= 0 || dot === token.length - 1)
72
+ return { ok: false, reason: "malformed" };
73
+ const payloadSegment = token.slice(0, dot);
74
+ if (payloadSegment.includes("."))
75
+ return { ok: false, reason: "malformed" };
76
+ // Cheap bound before decoding: 4 KiB of bytes is at most 5462 base64url characters.
77
+ if (payloadSegment.length > Math.ceil((VENDOR_TOKEN_PAYLOAD_MAX_BYTES * 4) / 3))
78
+ return { ok: false, reason: "malformed" };
79
+ const payloadBytes = decodeSegment(payloadSegment);
80
+ const signature = decodeSegment(token.slice(dot + 1));
81
+ if (!payloadBytes || !signature || signature.length !== SIGNATURE_BYTES || payloadBytes.length > VENDOR_TOKEN_PAYLOAD_MAX_BYTES) {
82
+ return { ok: false, reason: "malformed" };
83
+ }
84
+ let json;
85
+ try {
86
+ json = JSON.parse(payloadBytes.toString("utf8"));
87
+ }
88
+ catch {
89
+ return { ok: false, reason: "malformed" };
90
+ }
91
+ const parsed = VendorTokenPayloadSchema.safeParse(json);
92
+ if (!parsed.success)
93
+ return { ok: false, reason: "malformed" };
94
+ const match = keyFor(parsed.data.kid, trustedKeys);
95
+ if (!match)
96
+ return { ok: false, reason: "bad_signature" };
97
+ let authentic = false;
98
+ try {
99
+ authentic = verify(null, signedBytes(payloadSegment), createPublicKey({ key: Buffer.from(match.publicKey, "base64"), format: "der", type: "spki" }), signature);
100
+ }
101
+ catch {
102
+ authentic = false;
103
+ }
104
+ if (!authentic)
105
+ return { ok: false, reason: "bad_signature" };
106
+ const nowSeconds = Math.floor((opts.now ?? new Date()).getTime() / 1000);
107
+ const leeway = opts.leewaySeconds ?? VENDOR_TOKEN_LEEWAY_SECONDS;
108
+ // An invalid clock would make every comparison below false and pass any token: a caller bug, refused loudly.
109
+ if (!Number.isFinite(nowSeconds))
110
+ throw new RangeError("verifyVendorToken: opts.now is not a valid date");
111
+ if (!Number.isFinite(leeway) || leeway < 0)
112
+ throw new RangeError("verifyVendorToken: opts.leewaySeconds must be a finite number of seconds, zero or more");
113
+ if (parsed.data.iat > nowSeconds + leeway)
114
+ return { ok: false, reason: "malformed" };
115
+ if (nowSeconds > parsed.data.exp + leeway)
116
+ return { ok: false, reason: "expired" };
117
+ return { ok: true, payload: parsed.data };
118
+ }
@@ -32,4 +32,4 @@ function Example() {
32
32
 
33
33
  Kardalum's source is not public. Questions and bug reports:
34
34
  [kardalum-devkit](https://github.com/kardalum/kardalum-devkit). Docs at
35
- https://docs.kardalum.com. Apache-2.0.
35
+ https://dev.kardalum.com/docs/. Apache-2.0.
@@ -6,7 +6,7 @@ import { cn } from '../lib/cn.js';
6
6
  // @kardalum/design-tokens Tailwind theme: all of these classes resolve
7
7
  // to var(--...) references, never baked values (host-provided
8
8
  // components constraint).
9
- const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:pointer-events-none disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50', {
9
+ const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:pointer-events-none disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50', {
10
10
  variants: {
11
11
  variant: {
12
12
  // Action = primary-600 (S177): cerulean in light, the light blue
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
3
  import { cn } from '../lib/cn.js';
4
4
  function Checkbox({ className, ...props }) {
5
- return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-neutral-500 bg-background-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 data-[state=checked]:text-text-inverse data-[state=indeterminate]:border-primary-600 data-[state=indeterminate]:text-primary-600', className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group flex items-center justify-center text-current", children: [_jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "h-3 w-3 group-data-[state=indeterminate]:hidden", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8.5L6.5 11.5L12.5 4.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "hidden h-3 w-3 group-data-[state=indeterminate]:block", "aria-hidden": "true", children: _jsx("path", { d: "M4 8h8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })] }) }));
5
+ return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-neutral-500 bg-background-elevated focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 data-[state=checked]:text-text-inverse data-[state=indeterminate]:border-primary-600 data-[state=indeterminate]:text-primary-600', className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group flex items-center justify-center text-current", children: [_jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "h-3 w-3 group-data-[state=indeterminate]:hidden", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8.5L6.5 11.5L12.5 4.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "hidden h-3 w-3 group-data-[state=indeterminate]:block", "aria-hidden": "true", children: _jsx("path", { d: "M4 8h8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })] }) }));
6
6
  }
7
7
  export { Checkbox };
@@ -7,6 +7,9 @@ import { cn } from '../lib/cn.js';
7
7
  // caller, same convention as AlertDialog. Radix supplies the focus trap,
8
8
  // Escape handling, and aria wiring; `onCloseAutoFocus` on DialogContent is
9
9
  // how a caller returns focus to its trigger (see the admin UI conventions).
10
+ // Radix hides the page behind with aria-hidden but never marks the dialog
11
+ // itself modal, so DialogContent sets aria-modal="true" as a default the
12
+ // caller can override (S314c4).
10
13
  const Dialog = DialogPrimitive.Root;
11
14
  const DialogTrigger = DialogPrimitive.Trigger;
12
15
  const DialogPortal = DialogPrimitive.Portal;
@@ -28,7 +31,7 @@ function DialogOverlay({ className, ...props }) {
28
31
  // gets a reachable footer. 460px, the height a 920px screen gives at 200%
29
32
  // browser zoom, is the case this is measured against (WCAG 1.4.4).
30
33
  function DialogContent({ className, ...props }) {
31
- return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsx(DialogPrimitive.Content, { className: cn('fixed start-1/2 top-1/2 z-50 max-h-[calc(100dvh_-_var(--spacing-8))] w-full max-w-lg -translate-y-1/2 overflow-y-auto ltr:-translate-x-1/2 rtl:translate-x-1/2 rounded-xl border border-border-default bg-background-elevated p-6 shadow-xl', className), ...props })] }));
34
+ return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsx(DialogPrimitive.Content, { "aria-modal": "true", className: cn('fixed start-1/2 top-1/2 z-50 max-h-[calc(100dvh_-_var(--spacing-8))] w-full max-w-lg -translate-y-1/2 overflow-y-auto ltr:-translate-x-1/2 rtl:translate-x-1/2 rounded-xl border border-border-default bg-background-elevated p-6 shadow-xl', className), ...props })] }));
32
35
  }
33
36
  function DialogHeader({ className, ...props }) {
34
37
  return (_jsx("div", { className: cn('flex items-center gap-2 text-start', className), ...props }));
@@ -43,6 +46,6 @@ function DialogDescription({ className, ...props }) {
43
46
  return (_jsx(DialogPrimitive.Description, { className: cn('text-sm text-text-secondary', className), ...props }));
44
47
  }
45
48
  function DialogCloseButton({ className, ...props }) {
46
- return (_jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
49
+ return (_jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
47
50
  }
48
51
  export { Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogClose, DialogCloseButton, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
@@ -34,13 +34,13 @@ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
34
34
  // Radio item with a check indicator at the inline start — the shape a
35
35
  // "pick one" preference (theme mode, language) takes inside a menu.
36
36
  function DropdownMenuRadioItem({ className, children, ...props }) {
37
- return (_jsxs(DropdownMenuPrimitive.RadioItem, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm py-2 pe-2 ps-8 text-sm text-text-primary outline-none transition-colors data-[highlighted]:bg-background-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute start-2 flex size-4 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "size-4 text-primary-600", children: _jsx("path", { d: "M20 6 9 17l-5-5" }) }) }) }), children] }));
37
+ return (_jsxs(DropdownMenuPrimitive.RadioItem, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm py-2 pe-2 ps-8 text-sm text-text-primary outline-hidden transition-colors data-[highlighted]:bg-background-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute start-2 flex size-4 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "size-4 text-primary-600", children: _jsx("path", { d: "M20 6 9 17l-5-5" }) }) }) }), children] }));
38
38
  }
39
39
  function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
40
40
  return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { sideOffset: sideOffset, className: cn('z-50 min-w-[10rem] overflow-hidden rounded-lg border border-border-default bg-background-elevated p-1 text-text-primary shadow-lg', className), ...props }) }));
41
41
  }
42
42
  function DropdownMenuItem({ className, inset, variant = 'default', ...props }) {
43
- return (_jsx(DropdownMenuPrimitive.Item, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50', variant === 'destructive'
43
+ return (_jsx(DropdownMenuPrimitive.Item, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50', variant === 'destructive'
44
44
  ? 'text-danger-600 data-[highlighted]:bg-danger-100 data-[highlighted]:text-danger-700'
45
45
  : 'text-text-primary data-[highlighted]:bg-background-hover', inset && 'ps-8', className), ...props }));
46
46
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from '../lib/cn.js';
3
3
  function Input({ className, type, ...props }) {
4
- return (_jsx("input", { type: type, "data-slot": "input", className: cn('flex h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary placeholder:text-text-disabled file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-text-primary transition-colors duration-fast focus-visible:border-primary-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary-50 disabled:cursor-not-allowed disabled:opacity-50', className), ...props }));
4
+ return (_jsx("input", { type: type, "data-slot": "input", className: cn('flex h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary placeholder:text-text-disabled file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-text-primary transition-colors duration-fast focus-visible:border-primary-600 focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-primary-50 disabled:cursor-not-allowed disabled:opacity-50', className), ...props }));
5
5
  }
6
6
  export { Input };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
3
+ declare function PopoverPanel({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Content>): React.JSX.Element;
4
+ export { PopoverPanel };
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
3
+ import { cn } from '../lib/cn.js';
4
+ // S314n2: a small panel pinned under the app bar at the inline end, the content of a
5
+ // non-modal Dialog (`<Dialog modal={false}>`): the bell's notifications. Radix supplies
6
+ // Escape, the outside click that closes it and the return of focus to its trigger; being
7
+ // non-modal, the page behind stays live and gets no overlay. Never wider than the viewport
8
+ // less a gutter, so at a phone's width it spans the screen. No owned strings: the caller
9
+ // gives it a DialogTitle.
10
+ function PopoverPanel({ className, ...props }) {
11
+ return (_jsx(DialogPrimitive.Portal, { children: _jsx(DialogPrimitive.Content, { className: cn('fixed end-4 top-14 z-50 flex max-h-[calc(100dvh_-_var(--spacing-16))] w-[calc(100vw_-_var(--spacing-8))] max-w-md flex-col overflow-hidden rounded-lg border border-border-default bg-background-elevated shadow-xl', className), ...props }) }));
12
+ }
13
+ export { PopoverPanel };
@@ -4,8 +4,9 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
4
4
  import { cn } from '../lib/cn.js';
5
5
  // A right-side drawer variant of Dialog — same Radix primitive underneath
6
6
  // (focus trap, Escape handling, aria wiring: SheetContent is still a
7
- // DialogPrimitive.Content, so it still carries role="dialog"/aria-modal
8
- // the way DialogContent does), just a different Content shell: a
7
+ // DialogPrimitive.Content, so it carries role="dialog", and like
8
+ // DialogContent it sets aria-modal="true" itself as an overridable default,
9
+ // because Radix does not), just a different Content shell: a
9
10
  // fixed-width panel pinned to the inline end of the viewport instead of a
10
11
  // centered card. Ported by hand in the shadcn/ui model (same convention as
11
12
  // dialog.tsx/alert-dialog.tsx: retargeted to @kardalum/design-tokens
@@ -35,7 +36,7 @@ function SheetContent({ className, children, ...props }) {
35
36
  const frame = requestAnimationFrame(() => setEntered(true));
36
37
  return () => cancelAnimationFrame(frame);
37
38
  }, []);
38
- return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsx(DialogPrimitive.Content, { className: cn('fixed inset-y-0 end-0 z-50 flex h-full w-full max-w-md flex-col border-s border-border-default bg-background-elevated shadow-xl', 'motion-safe:transition-transform motion-safe:duration-normal motion-safe:ease-standard motion-reduce:transition-none', entered ? 'translate-x-0' : 'ltr:translate-x-full rtl:-translate-x-full', className), ...props, children: children })] }));
39
+ return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsx(DialogPrimitive.Content, { "aria-modal": "true", className: cn('fixed inset-y-0 end-0 z-50 flex h-full w-full max-w-md flex-col border-s border-border-default bg-background-elevated shadow-xl', 'motion-safe:transition-transform motion-safe:duration-normal motion-safe:ease-standard motion-reduce:transition-none', entered ? 'translate-x-0' : 'ltr:translate-x-full rtl:-translate-x-full', className), ...props, children: children })] }));
39
40
  }
40
41
  function SheetHeader({ className, ...props }) {
41
42
  return (_jsx("div", { className: cn('flex shrink-0 items-center gap-2 border-b border-border-default px-4 py-3 text-start', className), ...props }));
@@ -50,6 +51,6 @@ function SheetDescription({ className, ...props }) {
50
51
  return (_jsx(DialogPrimitive.Description, { className: cn('text-sm text-text-secondary', className), ...props }));
51
52
  }
52
53
  function SheetCloseButton({ className, ...props }) {
53
- return (_jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
54
+ return (_jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
54
55
  }
55
56
  export { Sheet, SheetTrigger, SheetPortal, SheetClose, SheetCloseButton, SheetOverlay, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as SwitchPrimitive from '@radix-ui/react-switch';
3
3
  import { cn } from '../lib/cn.js';
4
4
  function Switch({ className, ...props }) {
5
- return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn('peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-600 data-[state=unchecked]:bg-border-strong', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block h-5 w-5 rounded-full bg-background-elevated shadow-sm ring-0 transition-transform data-[state=unchecked]:translate-x-0 ltr:data-[state=checked]:translate-x-5 rtl:data-[state=checked]:-translate-x-5" }) }));
5
+ return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn('peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-600 data-[state=unchecked]:bg-border-strong', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block h-5 w-5 rounded-full bg-background-elevated shadow-sm ring-0 transition-transform data-[state=unchecked]:translate-x-0 ltr:data-[state=checked]:translate-x-5 rtl:data-[state=checked]:-translate-x-5" }) }));
6
6
  }
7
7
  export { Switch };
@@ -65,7 +65,7 @@ export function TabStrip({ tabs, activeId, onChange, label, errorLabel, idPrefix
65
65
  const active = tab.id === activeId;
66
66
  return (_jsxs("button", { type: "button", role: "tab", id: tabStripTabId(idPrefix, tab.id), "aria-selected": active, "aria-controls": tabStripPanelId(idPrefix, tab.id), "aria-label": tab.hasError && errorLabel
67
67
  ? `${tab.label}${tab.detail ? `, ${tab.detail}` : ''}: ${errorLabel}`
68
- : undefined, tabIndex: active ? 0 : -1, onClick: () => onChange(tab.id), className: cn('-mb-px inline-flex items-center gap-1 whitespace-nowrap rounded-t-md border-b-2 px-3 py-2 text-sm transition-colors duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base', active
68
+ : undefined, tabIndex: active ? 0 : -1, onClick: () => onChange(tab.id), className: cn('-mb-px inline-flex items-center gap-1 whitespace-nowrap rounded-t-md border-b-2 px-3 py-2 text-sm transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base', active
69
69
  ? 'border-primary-300 font-medium text-text-primary'
70
70
  : 'border-transparent text-text-secondary hover:text-text-primary'), children: [tab.label, tab.detail && _jsx("span", { className: "text-xs text-text-tertiary", children: tab.detail }), tab.hasError && (_jsx("span", { "aria-hidden": "true", className: "size-1 shrink-0 rounded-full bg-danger-500" }))] }, tab.id));
71
71
  }) }));
@@ -37,6 +37,6 @@ function ToastDescription({ className, ...props }) {
37
37
  return (_jsx(ToastPrimitives.Description, { className: cn('text-sm text-background-elevated opacity-80', className), ...props }));
38
38
  }
39
39
  function ToastClose({ className, ...props }) {
40
- return (_jsx(ToastPrimitives.Close, { className: cn('absolute end-2 top-2 rounded-md p-1 text-background-elevated opacity-70 transition-colors duration-fast hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
40
+ return (_jsx(ToastPrimitives.Close, { className: cn('absolute end-2 top-2 rounded-md p-1 text-background-elevated opacity-70 transition-colors duration-fast hover:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
41
41
  }
42
42
  export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose };
@@ -8,6 +8,7 @@ export { Badge, badgeVariants, type BadgeProps } from './components/badge.js';
8
8
  export { Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogClose, DialogCloseButton, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, } from './components/dialog.js';
9
9
  export { DropdownMenu, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuGroup, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, } from './components/dropdown-menu.js';
10
10
  export { EmptyState, type EmptyStateProps } from './components/empty-state.js';
11
+ export { PopoverPanel } from './components/popover-panel.js';
11
12
  export { Sheet, SheetTrigger, SheetPortal, SheetClose, SheetCloseButton, SheetOverlay, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, } from './components/sheet.js';
12
13
  export { Skeleton } from './components/skeleton.js';
13
14
  export { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, type ToastProps, } from './components/toast.js';
@@ -8,6 +8,7 @@ export { Badge, badgeVariants } from './components/badge.js';
8
8
  export { Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogClose, DialogCloseButton, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, } from './components/dialog.js';
9
9
  export { DropdownMenu, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuGroup, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, } from './components/dropdown-menu.js';
10
10
  export { EmptyState } from './components/empty-state.js';
11
+ export { PopoverPanel } from './components/popover-panel.js';
11
12
  export { Sheet, SheetTrigger, SheetPortal, SheetClose, SheetCloseButton, SheetOverlay, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, } from './components/sheet.js';
12
13
  export { Skeleton } from './components/skeleton.js';
13
14
  export { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, } from './components/toast.js';