@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.
- package/CHANGELOG.md +67 -0
- package/README.md +4 -3
- package/dist/assets/asset-picker.d.ts +11 -0
- package/dist/assets/asset-picker.js +109 -0
- package/dist/assets/asset-tree.d.ts +30 -0
- package/dist/assets/asset-tree.js +150 -0
- package/dist/built-in-editor-ids.d.ts +1 -0
- package/dist/built-in-editor-ids.js +20 -0
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +27 -0
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +10 -1
- package/dist/capabilities.js +5 -0
- package/dist/datatype-validation.js +18 -4
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/entitlement-entry.d.ts +3 -2
- package/dist/entitlement-entry.js +13 -1
- package/dist/entitlement-gate.d.ts +18 -0
- package/dist/entitlement-gate.js +95 -21
- package/dist/entitlement-plan.d.ts +21 -0
- package/dist/entitlement-plan.js +26 -0
- package/dist/entitlement-types.d.ts +21 -4
- package/dist/entitlement.d.ts +29 -1
- package/dist/entitlement.js +39 -0
- package/dist/grid-arrow-step.d.ts +7 -0
- package/dist/grid-arrow-step.js +20 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -12
- package/dist/manifest-entry.d.ts +4 -0
- package/dist/manifest-entry.js +4 -0
- package/dist/manifest-schema.d.ts +5 -1
- package/dist/manifest-schema.js +7 -1
- package/dist/manifest.d.ts +21 -1
- package/dist/media/media-picker.js +32 -32
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- package/dist/richtext/block-panel.js +17 -18
- package/dist/richtext/extensions.js +10 -1
- package/dist/richtext/insert-menu.js +1 -1
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +1 -1
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/structured-storage-types.d.ts +11 -0
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/vendor-check.d.ts +39 -0
- package/dist/vendor-check.js +79 -0
- package/dist/vendor-entry.d.ts +3 -0
- package/dist/vendor-entry.js +9 -0
- package/dist/vendor-service.d.ts +20 -0
- package/dist/vendor-service.js +20 -0
- package/dist/views/asset-view.d.ts +6 -0
- package/dist/views/asset-view.js +55 -0
- package/dist/views/content-list-settings-view.js +1 -1
- package/dist/views/content-list-view.js +1 -1
- package/dist/views/html-code-editor.js +0 -1
- package/dist/views/image-view.js +1 -1
- package/dist/views/rich-text-view.js +30 -30
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +16 -14
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +16 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
- package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +41 -15
- package/node_modules/@kardalum/api-schemas/dist/index.js +30 -10
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +115 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +102 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +227 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +157 -31
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -11
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
- package/node_modules/@kardalum/design-tokens/README.md +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- package/node_modules/@kardalum/plugin-package/README.md +1 -1
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +8 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
- package/node_modules/@kardalum/plugin-package/dist/extract.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
- package/node_modules/@kardalum/ui/README.md +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
- package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
- package/node_modules/@kardalum/ui/dist/index.js +1 -0
- package/package.json +17 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type JSX, type ReactNode } from "react";
|
|
2
2
|
import type { TrustedKey } from "@kardalum/plugin-package";
|
|
3
|
+
import type { EntitlementPlan } from "./entitlement-plan.js";
|
|
3
4
|
import type { EntitlementErrorCode, LicenseVerdictEnvelope } from "./entitlement-types.js";
|
|
4
5
|
export declare const BROWSER_ENTITLEMENT_MAX_AGE_MS: number;
|
|
5
6
|
export declare const BROWSER_MAX_VERDICT_AGE_MS: number;
|
|
@@ -7,6 +8,10 @@ export type EntitlementStatus = "loading" | "entitled" | "locked";
|
|
|
7
8
|
export interface UseEntitlementResult {
|
|
8
9
|
status: EntitlementStatus;
|
|
9
10
|
reason?: EntitlementErrorCode;
|
|
11
|
+
/** S317: the plan and term, when entitled; plan unknown when this browser cannot verify the term (plan P9). */
|
|
12
|
+
plan?: EntitlementPlan;
|
|
13
|
+
/** S318: true when the verified term is lapsed: the host refuses writes, so disable Save actions. */
|
|
14
|
+
readOnly: boolean;
|
|
10
15
|
}
|
|
11
16
|
/** The exact bytes the marketplace signs, built the way
|
|
12
17
|
* @kardalum/plugin-package's `canonicalizeLicenseVerdict` builds them
|
|
@@ -15,12 +20,25 @@ export interface UseEntitlementResult {
|
|
|
15
20
|
* module that imports node:crypto; entitlement-gate.test.tsx pins this to
|
|
16
21
|
* its output for the same envelopes, so the two cannot drift silently. */
|
|
17
22
|
export declare function canonicalLicenseVerdictBytes(envelope: LicenseVerdictEnvelope): Uint8Array<ArrayBuffer>;
|
|
23
|
+
/** S317: the bytes `termSignature` covers, built the way
|
|
24
|
+
* @kardalum/plugin-package's `canonicalizeLicenseVerdictTerm` builds them
|
|
25
|
+
* (the version 1 fields, then `planId` and `term`, null when absent). A
|
|
26
|
+
* copy for the same reason as above; entitlement-gate.test.tsx pins it. */
|
|
27
|
+
export declare function canonicalLicenseVerdictTermBytes(envelope: LicenseVerdictEnvelope): Uint8Array<ArrayBuffer>;
|
|
18
28
|
/** true or false when this browser could check the signature itself; null
|
|
19
29
|
* when it cannot import an Ed25519 key, and the host's answer stands in. */
|
|
20
30
|
export declare function verifyEntitlementInBrowser(entitlement: {
|
|
21
31
|
envelope: LicenseVerdictEnvelope;
|
|
22
32
|
signature: string;
|
|
23
33
|
}, trustedKeys: TrustedKey[]): Promise<boolean | null>;
|
|
34
|
+
/** S317: true when the envelope carries a well-formed plan or term and its
|
|
35
|
+
* `termSignature` verifies; false when it carries none or the signature is
|
|
36
|
+
* wrong; null when this browser cannot check it (plan P9: the plan then
|
|
37
|
+
* reads as unknown). */
|
|
38
|
+
export declare function verifyTermInBrowser(entitlement: {
|
|
39
|
+
envelope: LicenseVerdictEnvelope;
|
|
40
|
+
termSignature?: string;
|
|
41
|
+
}, trustedKeys: TrustedKey[]): Promise<boolean | null>;
|
|
24
42
|
/** `entitled` for `exempt` (a non-production install) on a page served from
|
|
25
43
|
* a local host, and `locked` with `missing` for `exempt` anywhere else and
|
|
26
44
|
* for `none` (no verdict held); a `verdict` is verified as above. A host answer the view cannot read at all (no session, an unknown
|
package/dist/entitlement-gate.js
CHANGED
|
@@ -16,7 +16,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
16
16
|
// is absent. There is no floor in the browser: the view gate is the visible
|
|
17
17
|
// half, the server route's `requireEntitlement` is the one that guards the
|
|
18
18
|
// work.
|
|
19
|
+
//
|
|
20
|
+
// Since S317 the result carries `plan` beside the status: the signed plan
|
|
21
|
+
// and term when this browser verified their `termSignature`, otherwise plan
|
|
22
|
+
// unknown, term active.
|
|
19
23
|
import { useEffect, useState } from "react";
|
|
24
|
+
import { highestListingPlan, planFromEnvelope, UNKNOWN_TERM } from "./entitlement-plan.js";
|
|
20
25
|
import { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
21
26
|
import { isLocalHost } from "./local-host.js";
|
|
22
27
|
import { usePluginApi } from "./plugin-context.js";
|
|
@@ -48,6 +53,32 @@ export function canonicalLicenseVerdictBytes(envelope) {
|
|
|
48
53
|
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
49
54
|
}));
|
|
50
55
|
}
|
|
56
|
+
/** S317: the bytes `termSignature` covers, built the way
|
|
57
|
+
* @kardalum/plugin-package's `canonicalizeLicenseVerdictTerm` builds them
|
|
58
|
+
* (the version 1 fields, then `planId` and `term`, null when absent). A
|
|
59
|
+
* copy for the same reason as above; entitlement-gate.test.tsx pins it. */
|
|
60
|
+
export function canonicalLicenseVerdictTermBytes(envelope) {
|
|
61
|
+
const term = envelope.term;
|
|
62
|
+
return new TextEncoder().encode(JSON.stringify({
|
|
63
|
+
v: envelope.v,
|
|
64
|
+
alg: envelope.alg,
|
|
65
|
+
typ: envelope.typ,
|
|
66
|
+
keyId: envelope.keyId,
|
|
67
|
+
keyHash: envelope.keyHash,
|
|
68
|
+
pluginId: envelope.pluginId,
|
|
69
|
+
domain: envelope.domain,
|
|
70
|
+
nonce: envelope.nonce,
|
|
71
|
+
status: envelope.status,
|
|
72
|
+
reason: envelope.reason ?? null,
|
|
73
|
+
issuedAt: envelope.issuedAt,
|
|
74
|
+
...(envelope.tamper !== undefined ? { tamper: envelope.tamper } : {}),
|
|
75
|
+
...(envelope.detail !== undefined ? { detail: envelope.detail } : {}),
|
|
76
|
+
planId: envelope.planId ?? null,
|
|
77
|
+
term: term === undefined
|
|
78
|
+
? null
|
|
79
|
+
: { state: term.state, endsAt: term.endsAt, renewalAmountCents: term.renewalAmountCents, cancelAtPeriodEnd: term.cancelAtPeriodEnd },
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
51
82
|
function base64ToBytes(value) {
|
|
52
83
|
const binary = atob(value);
|
|
53
84
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -76,9 +107,9 @@ function looksLikeVerdict(value) {
|
|
|
76
107
|
typeof e.issuedAt === "string");
|
|
77
108
|
}
|
|
78
109
|
const ED25519_SPKI_LENGTH = 44;
|
|
79
|
-
/** true or false when this browser could check
|
|
80
|
-
* when it cannot import an Ed25519 key
|
|
81
|
-
|
|
110
|
+
/** true or false when this browser could check `signature` over `bytes`
|
|
111
|
+
* itself; null when it cannot import an Ed25519 key. */
|
|
112
|
+
async function verifyBytesInBrowser(keyId, signatureB64, bytes, trustedKeys) {
|
|
82
113
|
const subtle = globalThis.crypto?.subtle;
|
|
83
114
|
if (!subtle)
|
|
84
115
|
return null;
|
|
@@ -96,7 +127,7 @@ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
|
96
127
|
// Re-derive the key id from the raw key, as the server does: the
|
|
97
128
|
// listed keyId is a label, the key is the fact.
|
|
98
129
|
const derivedId = toHex(await subtle.digest("SHA-256", der.slice(12))).slice(0, 16);
|
|
99
|
-
if (derivedId !==
|
|
130
|
+
if (derivedId !== keyId)
|
|
100
131
|
continue;
|
|
101
132
|
let key;
|
|
102
133
|
try {
|
|
@@ -107,12 +138,12 @@ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
|
107
138
|
}
|
|
108
139
|
let signature;
|
|
109
140
|
try {
|
|
110
|
-
signature = base64ToBytes(
|
|
141
|
+
signature = base64ToBytes(signatureB64);
|
|
111
142
|
}
|
|
112
143
|
catch {
|
|
113
144
|
return false;
|
|
114
145
|
}
|
|
115
|
-
return await subtle.verify({ name: "Ed25519" }, key, signature,
|
|
146
|
+
return await subtle.verify({ name: "Ed25519" }, key, signature, bytes);
|
|
116
147
|
}
|
|
117
148
|
return false;
|
|
118
149
|
}
|
|
@@ -120,22 +151,56 @@ export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
|
120
151
|
return null;
|
|
121
152
|
}
|
|
122
153
|
}
|
|
154
|
+
/** true or false when this browser could check the signature itself; null
|
|
155
|
+
* when it cannot import an Ed25519 key, and the host's answer stands in. */
|
|
156
|
+
export async function verifyEntitlementInBrowser(entitlement, trustedKeys) {
|
|
157
|
+
return verifyBytesInBrowser(entitlement.envelope.keyId, entitlement.signature, canonicalLicenseVerdictBytes(entitlement.envelope), trustedKeys);
|
|
158
|
+
}
|
|
159
|
+
const TERM_STATES = ["active", "renewing", "past_due", "lapsed"];
|
|
160
|
+
function termShapeOk(envelope) {
|
|
161
|
+
const planId = envelope.planId;
|
|
162
|
+
const term = envelope.term;
|
|
163
|
+
if (planId === undefined && term === undefined)
|
|
164
|
+
return false;
|
|
165
|
+
if (planId !== undefined && (typeof planId !== "string" || planId.length === 0 || planId.length > 64))
|
|
166
|
+
return false;
|
|
167
|
+
if (term === undefined)
|
|
168
|
+
return true;
|
|
169
|
+
if (typeof term !== "object" || term === null)
|
|
170
|
+
return false;
|
|
171
|
+
const t = term;
|
|
172
|
+
return (typeof t.state === "string" && TERM_STATES.includes(t.state) &&
|
|
173
|
+
(t.endsAt === null || (typeof t.endsAt === "string" && Number.isFinite(Date.parse(t.endsAt)))) &&
|
|
174
|
+
(t.renewalAmountCents === null || (typeof t.renewalAmountCents === "number" && Number.isInteger(t.renewalAmountCents) && t.renewalAmountCents >= 0)) &&
|
|
175
|
+
typeof t.cancelAtPeriodEnd === "boolean");
|
|
176
|
+
}
|
|
177
|
+
/** S317: true when the envelope carries a well-formed plan or term and its
|
|
178
|
+
* `termSignature` verifies; false when it carries none or the signature is
|
|
179
|
+
* wrong; null when this browser cannot check it (plan P9: the plan then
|
|
180
|
+
* reads as unknown). */
|
|
181
|
+
export async function verifyTermInBrowser(entitlement, trustedKeys) {
|
|
182
|
+
if (!termShapeOk(entitlement.envelope))
|
|
183
|
+
return false;
|
|
184
|
+
if (typeof entitlement.termSignature !== "string" || entitlement.termSignature.length === 0)
|
|
185
|
+
return false;
|
|
186
|
+
return verifyBytesInBrowser(entitlement.envelope.keyId, entitlement.termSignature, canonicalLicenseVerdictTermBytes(entitlement.envelope), trustedKeys);
|
|
187
|
+
}
|
|
123
188
|
/** The checks after the signature, in the server's order. */
|
|
124
189
|
function decide(entitlement, pluginId, now) {
|
|
125
190
|
const { envelope } = entitlement;
|
|
126
191
|
if (envelope.pluginId !== pluginId)
|
|
127
|
-
return { status: "locked", reason: "wrong-plugin" };
|
|
192
|
+
return { status: "locked", reason: "wrong-plugin", readOnly: false };
|
|
128
193
|
if (envelope.status !== "valid")
|
|
129
|
-
return { status: "locked", reason: "not-valid" };
|
|
194
|
+
return { status: "locked", reason: "not-valid", readOnly: false };
|
|
130
195
|
const issuedMs = Date.parse(envelope.issuedAt);
|
|
131
196
|
const nowMs = now.getTime();
|
|
132
197
|
if (!Number.isFinite(issuedMs))
|
|
133
|
-
return { status: "locked", reason: "invalid-signature" };
|
|
198
|
+
return { status: "locked", reason: "invalid-signature", readOnly: false };
|
|
134
199
|
if (nowMs - issuedMs > BROWSER_ENTITLEMENT_MAX_AGE_MS)
|
|
135
|
-
return { status: "locked", reason: "expired" };
|
|
200
|
+
return { status: "locked", reason: "expired", readOnly: false };
|
|
136
201
|
if (issuedMs > nowMs + BROWSER_MAX_VERDICT_AGE_MS)
|
|
137
|
-
return { status: "locked", reason: "expired" };
|
|
138
|
-
return { status: "entitled" };
|
|
202
|
+
return { status: "locked", reason: "expired", readOnly: false };
|
|
203
|
+
return { status: "entitled", readOnly: false };
|
|
139
204
|
}
|
|
140
205
|
/** S284b, C9: the host hands `exempt` whenever its site domain is unset or
|
|
141
206
|
* local, which is one environment variable. The view takes it only when the
|
|
@@ -151,30 +216,39 @@ function pageIsLocal() {
|
|
|
151
216
|
* that cannot tell does not open. A free plugin never uses the gate. */
|
|
152
217
|
export function useEntitlement(pluginId) {
|
|
153
218
|
const fetchApi = usePluginApi();
|
|
154
|
-
const [result, setResult] = useState({ status: "loading" });
|
|
219
|
+
const [result, setResult] = useState({ status: "loading", readOnly: false });
|
|
155
220
|
useEffect(() => {
|
|
156
221
|
let cancelled = false;
|
|
157
|
-
setResult({ status: "loading" });
|
|
222
|
+
setResult({ status: "loading", readOnly: false });
|
|
158
223
|
(async () => {
|
|
159
224
|
const response = await fetchApi(`/api/plugin-management/entitlement/${encodeURIComponent(pluginId)}`);
|
|
160
225
|
if (!response.ok)
|
|
161
|
-
return { status: "locked", reason: "missing" };
|
|
226
|
+
return { status: "locked", reason: "missing", readOnly: false };
|
|
162
227
|
const body = (await response.json());
|
|
163
228
|
const entitlement = body?.entitlement;
|
|
229
|
+
// S318: the host's answer counts even where this browser cannot verify the term.
|
|
230
|
+
const hostReadOnly = body?.readOnly !== undefined && body?.readOnly !== null;
|
|
164
231
|
if (entitlement?.kind === "exempt") {
|
|
165
|
-
return pageIsLocal()
|
|
232
|
+
return pageIsLocal()
|
|
233
|
+
? { status: "entitled", plan: { planId: highestListingPlan(entitlement.listingPlans), term: { ...UNKNOWN_TERM } }, readOnly: hostReadOnly }
|
|
234
|
+
: { status: "locked", reason: "missing", readOnly: hostReadOnly };
|
|
166
235
|
}
|
|
167
236
|
if (entitlement?.kind !== "verdict")
|
|
168
|
-
return { status: "locked", reason: "missing" };
|
|
237
|
+
return { status: "locked", reason: "missing", readOnly: hostReadOnly };
|
|
169
238
|
if (!looksLikeVerdict(entitlement))
|
|
170
|
-
return { status: "locked", reason: "invalid-signature" };
|
|
239
|
+
return { status: "locked", reason: "invalid-signature", readOnly: hostReadOnly };
|
|
171
240
|
const own = await verifyEntitlementInBrowser(entitlement, LICENSE_VERDICT_PUBLIC_KEYS);
|
|
172
241
|
const authentic = own ?? body.valid === true;
|
|
173
242
|
if (!authentic)
|
|
174
|
-
return { status: "locked", reason: "invalid-signature" };
|
|
175
|
-
|
|
243
|
+
return { status: "locked", reason: "invalid-signature", readOnly: hostReadOnly };
|
|
244
|
+
const decided = decide(entitlement, pluginId, new Date());
|
|
245
|
+
if (decided.status !== "entitled")
|
|
246
|
+
return { ...decided, readOnly: hostReadOnly };
|
|
247
|
+
const termOk = await verifyTermInBrowser(entitlement, LICENSE_VERDICT_PUBLIC_KEYS);
|
|
248
|
+
const plan = planFromEnvelope(entitlement.envelope, termOk === true);
|
|
249
|
+
return { ...decided, plan, readOnly: hostReadOnly || plan.term.state === "lapsed" };
|
|
176
250
|
})()
|
|
177
|
-
.catch(() => ({ status: "locked", reason: "missing" }))
|
|
251
|
+
.catch(() => ({ status: "locked", reason: "missing", readOnly: false }))
|
|
178
252
|
.then((next) => {
|
|
179
253
|
if (!cancelled)
|
|
180
254
|
setResult(next);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LicenseVerdictEnvelope, LicenseVerdictTerm } from "@kardalum/plugin-package";
|
|
2
|
+
import type { ListingPlanSummary } from "./entitlement-types.js";
|
|
3
|
+
/** What a plugin knows about its licence's plan. `planId` is the plan's key
|
|
4
|
+
* on the listing, or null when unknown (a verdict from before S317, a host
|
|
5
|
+
* that could not verify the term, or a local install whose listing plans
|
|
6
|
+
* are not known). */
|
|
7
|
+
export interface EntitlementPlan {
|
|
8
|
+
planId: string | null;
|
|
9
|
+
term: LicenseVerdictTerm;
|
|
10
|
+
}
|
|
11
|
+
/** The term of a verdict that carries none: active, nothing known (S315
|
|
12
|
+
* section 9: an old verdict reads as plan unknown, term active). */
|
|
13
|
+
export declare const UNKNOWN_TERM: Readonly<LicenseVerdictTerm>;
|
|
14
|
+
/** S315 section 9: on a local install a plugin sees its listing's highest
|
|
15
|
+
* plan, the one with the highest yearly equivalent (the later position on
|
|
16
|
+
* a tie). Null with no plans. */
|
|
17
|
+
export declare function highestListingPlan(plans: readonly ListingPlanSummary[] | undefined): string | null;
|
|
18
|
+
/** The plan and term of an envelope whose base signature verified.
|
|
19
|
+
* `termVerified` says whether its `termSignature` did too; without it the
|
|
20
|
+
* fields are not trusted and the plan reads as unknown. */
|
|
21
|
+
export declare function planFromEnvelope(envelope: LicenseVerdictEnvelope, termVerified: boolean): EntitlementPlan;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The term of a verdict that carries none: active, nothing known (S315
|
|
2
|
+
* section 9: an old verdict reads as plan unknown, term active). */
|
|
3
|
+
export const UNKNOWN_TERM = Object.freeze({ state: "active", endsAt: null, renewalAmountCents: null, cancelAtPeriodEnd: false });
|
|
4
|
+
function yearlyEquivalentCents(plan) {
|
|
5
|
+
return plan.shape === "monthly" ? plan.priceCents * 12 : plan.priceCents;
|
|
6
|
+
}
|
|
7
|
+
/** S315 section 9: on a local install a plugin sees its listing's highest
|
|
8
|
+
* plan, the one with the highest yearly equivalent (the later position on
|
|
9
|
+
* a tie). Null with no plans. */
|
|
10
|
+
export function highestListingPlan(plans) {
|
|
11
|
+
let best = null;
|
|
12
|
+
for (const plan of plans ?? []) {
|
|
13
|
+
if (!best || yearlyEquivalentCents(plan) > yearlyEquivalentCents(best) || (yearlyEquivalentCents(plan) === yearlyEquivalentCents(best) && plan.position > best.position)) {
|
|
14
|
+
best = plan;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return best?.key ?? null;
|
|
18
|
+
}
|
|
19
|
+
/** The plan and term of an envelope whose base signature verified.
|
|
20
|
+
* `termVerified` says whether its `termSignature` did too; without it the
|
|
21
|
+
* fields are not trusted and the plan reads as unknown. */
|
|
22
|
+
export function planFromEnvelope(envelope, termVerified) {
|
|
23
|
+
if (!termVerified)
|
|
24
|
+
return { planId: null, term: { ...UNKNOWN_TERM } };
|
|
25
|
+
return { planId: envelope.planId ?? null, term: envelope.term ? { ...envelope.term } : { ...UNKNOWN_TERM } };
|
|
26
|
+
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import type { LicenseVerdictEnvelope } from "@kardalum/plugin-package";
|
|
1
|
+
import type { LicenseVerdictEnvelope, LicenseVerdictTerm } from "@kardalum/plugin-package";
|
|
2
2
|
import type { ScopedStructuredStorage } from "./structured-storage-types.js";
|
|
3
|
-
|
|
3
|
+
import type { PluginVendorService } from "./vendor-service.js";
|
|
4
|
+
export type { LicenseVerdictEnvelope, LicenseVerdictTerm };
|
|
5
|
+
/** A live plan of the plugin's marketplace listing, as the listing API
|
|
6
|
+
* names it (S316). `shape` is "free", "one_time", "monthly" or "yearly". */
|
|
7
|
+
export interface ListingPlanSummary {
|
|
8
|
+
key: string;
|
|
9
|
+
shape: string;
|
|
10
|
+
priceCents: number;
|
|
11
|
+
position: number;
|
|
12
|
+
}
|
|
4
13
|
/** The host's latest authentic licence verdict for a plugin, exactly as the
|
|
5
14
|
* marketplace signed it, whatever its status: a revoked or invalid one makes
|
|
6
|
-
* `requireEntitlement` answer `not-valid`.
|
|
15
|
+
* `requireEntitlement` answer `not-valid`. `termSignature` (S317) covers the
|
|
16
|
+
* envelope's `planId` and `term`; a host built before S317 hands none, and
|
|
17
|
+
* the plan then reads as unknown. */
|
|
7
18
|
export type EntitlementVerdict = {
|
|
8
19
|
kind: "verdict";
|
|
9
20
|
envelope: LicenseVerdictEnvelope;
|
|
10
21
|
signature: string;
|
|
22
|
+
termSignature?: string;
|
|
11
23
|
};
|
|
12
24
|
/** What the host hands a plugin (S284b fix wave: a tagged value, so "no
|
|
13
25
|
* check needed here" and "no verdict" can never be read as each other).
|
|
@@ -20,10 +32,14 @@ export type EntitlementVerdict = {
|
|
|
20
32
|
* - `none`: the host holds no verdict for this plugin (a free plugin, or a
|
|
21
33
|
* paid one whose verdict was never stored). `requireEntitlement` refuses
|
|
22
34
|
* with `missing`. A free plugin never calls it.
|
|
23
|
-
* - `verdict`: check it with `requireEntitlement`.
|
|
35
|
+
* - `verdict`: check it with `requireEntitlement`.
|
|
36
|
+
*
|
|
37
|
+
* `listingPlans` (S317) are the listing's live plans when the host knows
|
|
38
|
+
* them, so `entitlementPlan` can give a local evaluation the highest plan. */
|
|
24
39
|
export type Entitlement = {
|
|
25
40
|
kind: "exempt";
|
|
26
41
|
reason: "non-production";
|
|
42
|
+
listingPlans?: ListingPlanSummary[];
|
|
27
43
|
} | EntitlementVerdict | {
|
|
28
44
|
kind: "none";
|
|
29
45
|
};
|
|
@@ -36,4 +52,5 @@ export type EntitlementErrorCode = "missing" | "invalid-signature" | "wrong-plug
|
|
|
36
52
|
export type PluginTaskContext = {
|
|
37
53
|
entitlement: Entitlement;
|
|
38
54
|
structuredStorage?: ScopedStructuredStorage;
|
|
55
|
+
vendorService?: PluginVendorService;
|
|
39
56
|
};
|
package/dist/entitlement.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type LicenseVerdictEnvelope, type TrustedKey } from "@kardalum/plugin-package";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntitlementPlan } from "./entitlement-plan.js";
|
|
3
|
+
import type { Entitlement, EntitlementErrorCode, ListingPlanSummary } from "./entitlement-types.js";
|
|
3
4
|
import type { ScopedStructuredStorage } from "./structured-storage-types.js";
|
|
4
5
|
export declare class EntitlementError extends Error {
|
|
5
6
|
readonly code: EntitlementErrorCode;
|
|
@@ -55,3 +56,30 @@ export interface RequireEntitlementOptions {
|
|
|
55
56
|
* a future-dated verdict.
|
|
56
57
|
*/
|
|
57
58
|
export declare function requireEntitlement(entitlement: Entitlement | null | undefined, opts: RequireEntitlementOptions): Promise<LicenseVerdictEnvelope | null>;
|
|
59
|
+
/** S318: what `entitlementPlan` needs beside the entitlement. */
|
|
60
|
+
export interface EntitlementPlanOptions {
|
|
61
|
+
/** The plugin's own id: a verdict issued for another plugin reads as null. */
|
|
62
|
+
pluginId: string;
|
|
63
|
+
listingPlans?: readonly ListingPlanSummary[];
|
|
64
|
+
trustedKeys?: TrustedKey[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* S317 (spec 3d): the plan and the term beside `requireEntitlement`, never
|
|
68
|
+
* instead of it. It does not decide entitlement: call it after
|
|
69
|
+
* `requireEntitlement` resolved, to choose what the plan unlocks.
|
|
70
|
+
*
|
|
71
|
+
* - `verdict`: the signed `planId` and `term` when the verdict's signature
|
|
72
|
+
* and its `termSignature` verify; a verdict without them (one from before
|
|
73
|
+
* S317, or a host that hands no term signature) reads as plan unknown,
|
|
74
|
+
* term active. A verdict that does not verify is null.
|
|
75
|
+
* - `exempt` (a non-production install): the highest plan of
|
|
76
|
+
* `listingPlans`, or of the plans the host handed, term active; plan
|
|
77
|
+
* unknown when neither is known.
|
|
78
|
+
* - `none`, null or undefined: null.
|
|
79
|
+
* - A verdict of another plugin id, or whose status is not `valid`: null,
|
|
80
|
+
* as `requireEntitlement` would refuse it.
|
|
81
|
+
*
|
|
82
|
+
* A lapsed or past-due term still comes with a `valid` verdict (S317 D4):
|
|
83
|
+
* reads go on working, and the term is the signal for what to refuse.
|
|
84
|
+
*/
|
|
85
|
+
export declare function entitlementPlan(entitlement: Entitlement | null | undefined, opts: EntitlementPlanOptions): EntitlementPlan | null;
|
package/dist/entitlement.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// value, so an operator who flips the host's database still has to patch
|
|
13
13
|
// signed, watermarked plugin code to get that work for free.
|
|
14
14
|
import { ENTITLEMENT_MAX_AGE_MS, MAX_VERDICT_AGE_MS, verifyLicenseVerdictSignature, } from "@kardalum/plugin-package";
|
|
15
|
+
import { highestListingPlan, planFromEnvelope, UNKNOWN_TERM } from "./entitlement-plan.js";
|
|
15
16
|
import { LICENSE_VERDICT_PUBLIC_KEYS } from "./license-verdict-keys.js";
|
|
16
17
|
import { isLocalHost } from "./local-host.js";
|
|
17
18
|
const ERROR_CODES = ["missing", "invalid-signature", "wrong-plugin", "not-valid", "expired"];
|
|
@@ -168,3 +169,41 @@ export async function requireEntitlement(entitlement, opts) {
|
|
|
168
169
|
}
|
|
169
170
|
return envelope;
|
|
170
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* S317 (spec 3d): the plan and the term beside `requireEntitlement`, never
|
|
174
|
+
* instead of it. It does not decide entitlement: call it after
|
|
175
|
+
* `requireEntitlement` resolved, to choose what the plan unlocks.
|
|
176
|
+
*
|
|
177
|
+
* - `verdict`: the signed `planId` and `term` when the verdict's signature
|
|
178
|
+
* and its `termSignature` verify; a verdict without them (one from before
|
|
179
|
+
* S317, or a host that hands no term signature) reads as plan unknown,
|
|
180
|
+
* term active. A verdict that does not verify is null.
|
|
181
|
+
* - `exempt` (a non-production install): the highest plan of
|
|
182
|
+
* `listingPlans`, or of the plans the host handed, term active; plan
|
|
183
|
+
* unknown when neither is known.
|
|
184
|
+
* - `none`, null or undefined: null.
|
|
185
|
+
* - A verdict of another plugin id, or whose status is not `valid`: null,
|
|
186
|
+
* as `requireEntitlement` would refuse it.
|
|
187
|
+
*
|
|
188
|
+
* A lapsed or past-due term still comes with a `valid` verdict (S317 D4):
|
|
189
|
+
* reads go on working, and the term is the signal for what to refuse.
|
|
190
|
+
*/
|
|
191
|
+
export function entitlementPlan(entitlement, opts) {
|
|
192
|
+
if (entitlement === null || entitlement === undefined || typeof entitlement !== "object")
|
|
193
|
+
return null;
|
|
194
|
+
if (entitlement.kind === "exempt") {
|
|
195
|
+
return { planId: highestListingPlan(opts.listingPlans ?? entitlement.listingPlans), term: { ...UNKNOWN_TERM } };
|
|
196
|
+
}
|
|
197
|
+
if (entitlement.kind !== "verdict")
|
|
198
|
+
return null;
|
|
199
|
+
const checked = verifyLicenseVerdictSignature(entitlement, opts.trustedKeys ?? LICENSE_VERDICT_PUBLIC_KEYS, { now: END_OF_TIME, maxAgeMs: Number.POSITIVE_INFINITY });
|
|
200
|
+
if (!checked.ok)
|
|
201
|
+
return null;
|
|
202
|
+
// verifyLicenseVerdictSignature keeps planId and term only under a
|
|
203
|
+
// verified termSignature, so their presence is the verification.
|
|
204
|
+
const envelope = checked.envelope;
|
|
205
|
+
// S318 (S317 rider): the same plugin id and status checks requireEntitlement makes.
|
|
206
|
+
if (envelope.pluginId !== opts.pluginId || envelope.status !== "valid")
|
|
207
|
+
return null;
|
|
208
|
+
return planFromEnvelope(envelope, envelope.planId !== undefined || envelope.term !== undefined);
|
|
209
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S314c4 (D4): how far an arrow key moves focus in a picker's option grid,
|
|
3
|
+
* read in the page's direction. Right goes forward in a left-to-right page and
|
|
4
|
+
* back in a right-to-left one, as the row reads; Down and Up keep moving one
|
|
5
|
+
* option forward and back in both.
|
|
6
|
+
*/
|
|
7
|
+
export declare function gridArrowStep(key: string, rtl: boolean): -1 | 0 | 1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S314c4 (D4): how far an arrow key moves focus in a picker's option grid,
|
|
3
|
+
* read in the page's direction. Right goes forward in a left-to-right page and
|
|
4
|
+
* back in a right-to-left one, as the row reads; Down and Up keep moving one
|
|
5
|
+
* option forward and back in both.
|
|
6
|
+
*/
|
|
7
|
+
export function gridArrowStep(key, rtl) {
|
|
8
|
+
switch (key) {
|
|
9
|
+
case "ArrowDown":
|
|
10
|
+
return 1;
|
|
11
|
+
case "ArrowUp":
|
|
12
|
+
return -1;
|
|
13
|
+
case "ArrowRight":
|
|
14
|
+
return rtl ? -1 : 1;
|
|
15
|
+
case "ArrowLeft":
|
|
16
|
+
return rtl ? 1 : -1;
|
|
17
|
+
default:
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ export { PluginValueProvider, PluginSettingsProvider, PluginApiProvider, Content
|
|
|
11
11
|
export { PluginScreenProvider, PluginTranslateProvider, usePluginScreen, usePluginTranslate, type PluginScreenContext, type PluginTranslate, } from "./plugin-screen-context.js";
|
|
12
12
|
export { SimpleStorageValueProvider } from "./simple-storage-value-provider.js";
|
|
13
13
|
export { EntitlementGate, useEntitlement, type EntitlementStatus, type UseEntitlementResult, } from "./entitlement-gate.js";
|
|
14
|
-
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, PluginTaskContext } from "./entitlement-types.js";
|
|
14
|
+
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, PluginTaskContext, ListingPlanSummary, LicenseVerdictTerm } from "./entitlement-types.js";
|
|
15
|
+
export { highestListingPlan, planFromEnvelope, UNKNOWN_TERM, type EntitlementPlan } from "./entitlement-plan.js";
|
|
15
16
|
export { buildRichtextExtensions, TextStyleClass, KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, type BuildRichtextExtensionsOptions, type RichtextTextStyle, type TextStyleClassAttributes, type KardalumBlockAttributes, type KardalumBlockLocation, type SelectedKardalumBlock, } from "./richtext/extensions.js";
|
|
16
17
|
export { MediaPicker, type MediaPickerItem, type MediaPickerProps } from "./media/media-picker.js";
|
|
18
|
+
export { gridArrowStep } from "./grid-arrow-step.js";
|
|
17
19
|
export { MediaFileProvider, useMediaFile, useMediaFileReplace, type CurrentMediaFile, type MediaFileProviderProps, type MediaFileReplace, } from "./views/file-upload-view.js";
|
|
18
20
|
export { MediaRenditionProvider, useMediaRendition, isRenditionIneligible, RENDITION_INELIGIBLE_TYPES, type MediaRenditionCut, type MediaRenditionHost, type MediaRenditionProviderProps, } from "./views/crop-view.js";
|
|
19
21
|
export { StyleListbox, type StyleListboxProps } from "./richtext/style-listbox.js";
|
|
@@ -26,3 +28,6 @@ export { Button, type ButtonProps } from "@kardalum/ui";
|
|
|
26
28
|
export { Switch, type SwitchProps } from "@kardalum/ui";
|
|
27
29
|
export { Badge, type BadgeProps } from "@kardalum/ui";
|
|
28
30
|
export { cn } from "@kardalum/ui";
|
|
31
|
+
export type { NotificationRefusalReason, PluginNotify, PluginNotifyInput, PluginNotifyResult } from "./notify.js";
|
|
32
|
+
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
|
33
|
+
export type { PluginVendorService, VendorServiceErrorCode, VendorServiceRequestInit } from "./vendor-service.js";
|
package/dist/index.js
CHANGED
|
@@ -24,10 +24,15 @@ export { SimpleStorageValueProvider } from "./simple-storage-value-provider.js";
|
|
|
24
24
|
// the separate `@kardalum/plugin-sdk/entitlement` subpath (it needs
|
|
25
25
|
// node:crypto); these two verify in the browser and import nothing Node.
|
|
26
26
|
export { EntitlementGate, useEntitlement, } from "./entitlement-gate.js";
|
|
27
|
+
export { highestListingPlan, planFromEnvelope, UNKNOWN_TERM } from "./entitlement-plan.js";
|
|
27
28
|
export { buildRichtextExtensions, TextStyleClass, KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, } from "./richtext/extensions.js";
|
|
28
29
|
// Exported so a later on-page task can reuse the same modal from admin-ui
|
|
29
30
|
// (S197 Task 2) rather than forking it.
|
|
30
31
|
export { MediaPicker } from "./media/media-picker.js";
|
|
32
|
+
// S314c7 (D2): the arrow rule the pickers use (Left and Right follow the page
|
|
33
|
+
// direction, Up and Down keep theirs), for any grid or strip a host or plugin
|
|
34
|
+
// draws.
|
|
35
|
+
export { gridArrowStep } from "./grid-arrow-step.js";
|
|
31
36
|
// S234a: the file upload editor's field stores no value of its own (see
|
|
32
37
|
// file-upload-view.tsx's doc comment), so the host has no `data` key to
|
|
33
38
|
// hand it a current file through. Exported here so the media item screen
|
|
@@ -80,15 +85,5 @@ export { Button } from "@kardalum/ui";
|
|
|
80
85
|
export { Switch } from "@kardalum/ui";
|
|
81
86
|
export { Badge } from "@kardalum/ui";
|
|
82
87
|
export { cn } from "@kardalum/ui";
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
// package incidentally registered the six built-in datatypes, whether the
|
|
86
|
-
// consumer wanted that or not. That made this entry point permanently
|
|
87
|
-
// heavy (TipTap always, CodeMirror/lezer since S197 Task 8's HTML
|
|
88
|
-
// datatype), which every first-party plugin's Module Federation `shared`
|
|
89
|
-
// config (pointing at this exact bare specifier) then packaged a dead-
|
|
90
|
-
// weight fallback copy of into its own artifact, see
|
|
91
|
-
// `register-built-ins.ts`'s own doc comment for the full story. Built-in
|
|
92
|
-
// registration is now that separate, explicitly-imported subpath
|
|
93
|
-
// (`@kardalum/plugin-sdk/register-built-ins`): apps/admin-ui's
|
|
94
|
-
// bootstrap (main.tsx) and vitest setup are its only two real consumers.
|
|
88
|
+
// S320: context.vendorService and its typed error.
|
|
89
|
+
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
package/dist/manifest-entry.d.ts
CHANGED
|
@@ -6,3 +6,7 @@ export { ASSERTION_KINDS, AssertionsSchema, BUILT_IN_RAIL_SECTIONS, CMSPluginSch
|
|
|
6
6
|
export type { PluginColumnType, PluginColumnSchema, PluginIndexSchema, PluginTableSchema, StructuredQueryBuilder, StructuredStorageTransaction, ScopedStructuredStorage, PublishedContent, PluginApiRouteContext, } from "./structured-storage-types.js";
|
|
7
7
|
export type { Entitlement, EntitlementErrorCode, EntitlementVerdict, PluginTaskContext } from "./entitlement-types.js";
|
|
8
8
|
export { definePlugin, PluginDefinitionError } from "./define-plugin.js";
|
|
9
|
+
export { NOTIFICATION_REFUSAL_REASONS, NotificationRefusedError, isNotificationRefusedError } from "./notify.js";
|
|
10
|
+
export type { NotificationRefusalReason, PluginNotify, PluginNotifyInput, PluginNotifyResult } from "./notify.js";
|
|
11
|
+
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
|
12
|
+
export type { PluginVendorService, VendorServiceErrorCode, VendorServiceRequestInit } from "./vendor-service.js";
|
package/dist/manifest-entry.js
CHANGED
|
@@ -11,3 +11,7 @@ export { VIEW_BEARING_CONTRIBUTIONS, declaresClientBundle, slotLabel } from "./m
|
|
|
11
11
|
export { CAPABILITY_IDS, CAPABILITY_LABELS, capabilityLabel, PROMISED_CAPABILITY_SENTENCE, deriveCapabilities, isActionGated, } from "./capabilities.js";
|
|
12
12
|
export { ASSERTION_KINDS, AssertionsSchema, BUILT_IN_RAIL_SECTIONS, CMSPluginSchema, CONTRIBUTION_KEYS, DATABASE_DIALECTS, DataTypePluginSchema, PLUGIN_TYPES, TIER1_DIALECTS, formatIssues, validatePluginManifest, } from "./manifest-schema.js";
|
|
13
13
|
export { definePlugin, PluginDefinitionError } from "./define-plugin.js";
|
|
14
|
+
// S314n3: context.notify and its typed refusal.
|
|
15
|
+
export { NOTIFICATION_REFUSAL_REASONS, NotificationRefusedError, isNotificationRefusedError } from "./notify.js";
|
|
16
|
+
// S320: context.vendorService and its typed error.
|
|
17
|
+
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
|
@@ -119,9 +119,9 @@ export declare const CMSPluginSchema: z.ZodObject<{
|
|
|
119
119
|
railEntries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
120
120
|
id: z.ZodString;
|
|
121
121
|
section: z.ZodEnum<{
|
|
122
|
+
settings: "settings";
|
|
122
123
|
media: "media";
|
|
123
124
|
content: "content";
|
|
124
|
-
settings: "settings";
|
|
125
125
|
users: "users";
|
|
126
126
|
}>;
|
|
127
127
|
label: z.ZodPreprocess<z.ZodObject<{
|
|
@@ -304,6 +304,7 @@ export declare const CMSPluginSchema: z.ZodObject<{
|
|
|
304
304
|
description: z.ZodOptional<z.ZodString>;
|
|
305
305
|
repository: z.ZodOptional<z.ZodString>;
|
|
306
306
|
}, z.core.$strict>>;
|
|
307
|
+
notifications: z.ZodOptional<z.ZodLiteral<true>>;
|
|
307
308
|
}, z.core.$strict>;
|
|
308
309
|
price: z.ZodOptional<z.ZodNumber>;
|
|
309
310
|
signature: z.ZodOptional<z.ZodString>;
|
|
@@ -439,6 +440,9 @@ export declare const CMSPluginSchema: z.ZodObject<{
|
|
|
439
440
|
}, z.core.$strict>], "kind">>;
|
|
440
441
|
}, z.core.$strict>>;
|
|
441
442
|
}, z.core.$strict>>;
|
|
443
|
+
vendorService: z.ZodOptional<z.ZodObject<{
|
|
444
|
+
origin: z.ZodString;
|
|
445
|
+
}, z.core.$strict>>;
|
|
442
446
|
id: z.ZodString;
|
|
443
447
|
version: z.ZodString;
|
|
444
448
|
name: z.ZodString;
|
package/dist/manifest-schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { API_ROUTE_ACCESS_TIERS, API_ROUTE_METHODS, DATABASE_DIALECTS, PLUGIN_TYPES, STORAGE_TYPES, TEMPLATE_KINDS, TIER1_DIALECTS, API_ROUTE_RESPONSE_STATUSES_MAX, isApiRouteResponseStatus, ActionStringSchema, DocsLanguageSchema, PLUGIN_ID_MESSAGE, PLUGIN_ID_REGEX, PluginManifestIdSchema, SLOT_ID_MAX, pluginManifestFields, SLOT_ID_REGEX, PluginDocsPageSchema, PluginInstallDeclarationSchema, apiRoutePathParams, checkApiRouteActions, checkApiRouteDeclarations, checkTemplateAndAssetDeclarations, PluginAssetPathSchema, PluginTemplateEntrySchema, checkDocsDeclaration, checkInstallDeclaration, CreateDocumentTypeRequestSchema, PluginActionDeclarationSchema, PluginRoleOfferSchema, PluginLabelSchema, SlotLabelSchema, checkActionDeclarations as checkActionDeclarationsRule, isPluginActionFor } from "@kardalum/api-schemas";
|
|
2
|
+
import { API_ROUTE_ACCESS_TIERS, API_ROUTE_METHODS, DATABASE_DIALECTS, PLUGIN_TYPES, STORAGE_TYPES, TEMPLATE_KINDS, TIER1_DIALECTS, API_ROUTE_RESPONSE_STATUSES_MAX, isApiRouteResponseStatus, ActionStringSchema, DocsLanguageSchema, PLUGIN_ID_MESSAGE, PLUGIN_ID_REGEX, PluginManifestIdSchema, SLOT_ID_MAX, pluginManifestFields, SLOT_ID_REGEX, PluginDocsPageSchema, PluginInstallDeclarationSchema, PluginVendorServiceSchema, apiRoutePathParams, checkApiRouteActions, checkApiRouteDeclarations, checkTemplateAndAssetDeclarations, PluginAssetPathSchema, PluginTemplateEntrySchema, checkDocsDeclaration, checkInstallDeclaration, CreateDocumentTypeRequestSchema, PluginActionDeclarationSchema, PluginRoleOfferSchema, PluginLabelSchema, SlotLabelSchema, checkActionDeclarations as checkActionDeclarationsRule, isPluginActionFor } from "@kardalum/api-schemas";
|
|
3
3
|
import { isActionGated } from "./capabilities.js";
|
|
4
4
|
// Runtime mirror of manifest.ts: the same contract, enforced for
|
|
5
5
|
// manifests that arrive as VALUES (Module Federation remotes, sideloaded
|
|
@@ -515,6 +515,8 @@ const contributionsShape = {
|
|
|
515
515
|
// so catching it at publish beats discovering it at install.
|
|
516
516
|
bundledPlugins: z.array(manifestIdSchema).optional(),
|
|
517
517
|
bundledTemplate: bundledTemplateSchema.optional(),
|
|
518
|
+
// S314n3 (D1): `true` or absent; the capability is derived from it.
|
|
519
|
+
notifications: z.literal(true).optional(),
|
|
518
520
|
};
|
|
519
521
|
const contributionsSchema = z
|
|
520
522
|
.object(contributionsShape)
|
|
@@ -573,6 +575,10 @@ const baseFields = {
|
|
|
573
575
|
// defaults among the choices) runs below through checkInstallDeclaration,
|
|
574
576
|
// the function `kardalum plugin validate` and the marketplace door run.
|
|
575
577
|
install: PluginInstallDeclarationSchema.optional(),
|
|
578
|
+
// S320 (D6): the author's server, an origin and nothing else (strict). An
|
|
579
|
+
// http://localhost origin parses (a plugin in development); both publish
|
|
580
|
+
// gates refuse it (vendorServiceCheck in @kardalum/plugin-package).
|
|
581
|
+
vendorService: PluginVendorServiceSchema.optional(),
|
|
576
582
|
};
|
|
577
583
|
const pluginTypeSchema = z.enum(PLUGIN_TYPES);
|
|
578
584
|
// One manifest, no union (S268). `type` is a marketplace listing label
|