@fabricorg/sdui-release 0.3.0 → 0.6.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/dist/index.d.ts CHANGED
@@ -1,265 +1,9 @@
1
+ import { S as SduiAuthorizationGrants, a as SduiComponentPack, b as SduiDocument, c as SduiFragment, d as SduiRelease, e as SduiTokenSet, f as SduiValidationInput, g as SduiValidationResult, R as ResolvedSduiComponentPack } from './contracts-4fL-Yh38.js';
2
+ export { E as EffectiveFragmentGrant, h as ExperienceIntentRoute, i as ExperienceViewRoute, j as RELEASE_CHANNEL_POINTER_FORMAT_VERSION, k as ReleaseChannelPointer, l as ReleaseCryptoPort, m as ReleaseGenerationStore, n as ReleaseTrustStore, o as ReleaseVerificationKey, p as SDUI_COMPONENT_PACK_FORMAT_VERSION, q as SDUI_DOCUMENT_FORMAT_VERSION, r as SDUI_RELEASE_FORMAT_VERSION, s as SDUI_RELEASE_V3_FORMAT_VERSION, t as SDUI_TOKEN_SET_FORMAT_VERSION, u as SduiActionRef, v as SduiCapabilityRef, w as SduiComponentDefinition, x as SduiComponentPackReference, y as SduiFinding, z as SduiFindingCode, A as SduiFragmentValue, B as SduiReleaseV3, C as SduiToken, D as SduiTokenSetReference, F as SduiTokenType, V as VerifySignedExperienceArtifactInput, G as activateReleaseChannelPointer, H as assertReleaseChannelPointer, I as assertSduiReleaseV3, J as canonicalizeJcs, K as verifySignedExperienceArtifact, L as verifySignedExperienceRelease } from './contracts-4fL-Yh38.js';
3
+ import { UsageContract } from '@fabricorg/gen-capability';
1
4
  import { PortableJsonSchema } from '@fabricorg/platform';
2
5
  export { JsonValue } from '@fabricorg/platform';
3
- import { UsageContractDocument } from '@fabricorg/gen-capability';
4
- import { AssemblyLockfile } from '@fabricorg/assembly';
5
-
6
- /**
7
- * Version of the SDUI document contract. A vertical negotiates on this, not on
8
- * this package's version, and it moves only when the serialized shape changes.
9
- */
10
- declare const SDUI_DOCUMENT_FORMAT_VERSION: 1;
11
- /**
12
- * Version of the SDUI token-set contract.
13
- */
14
- declare const SDUI_TOKEN_SET_FORMAT_VERSION: 1;
15
- /**
16
- * Version of the SDUI component-pack contract.
17
- */
18
- declare const SDUI_COMPONENT_PACK_FORMAT_VERSION: 1;
19
- /**
20
- * Version of the promoted SDUI release contract.
21
- */
22
- declare const SDUI_RELEASE_FORMAT_VERSION: 2;
23
- /**
24
- * A capability read reference embedded in fragment props. The `capability://`
25
- * scheme ties a data binding to a published view; the host resolves it through
26
- * `ProjectionHost`, never through a direct query.
27
- */
28
- interface SduiCapabilityRef {
29
- $ref: `capability://${string}`;
30
- }
31
- /**
32
- * A value that may appear in fragment props: a JSON literal, an array, an
33
- * object, or a `capability://` read reference. Direct mutation endpoints,
34
- * API URLs, or code strings are not valid fragment values.
35
- */
36
- type SduiFragmentValue = string | number | boolean | null | SduiFragmentValue[] | SduiCapabilityRef | {
37
- [key: string]: SduiFragmentValue;
38
- };
39
- /**
40
- * An action declared on a fragment. The `intent` must be a `capability://`
41
- * reference to a published action intent; the host dispatches it through
42
- * `PlatformHost`, preserving governance. A bare endpoint URL, function name,
43
- * or inline script is a mutation bypass and is rejected.
44
- */
45
- interface SduiActionRef {
46
- intent: `capability://${string}`;
47
- params?: Record<string, SduiFragmentValue>;
48
- }
49
- /**
50
- * A node in an SDUI document tree. A fragment either renders a component from
51
- * a declared pack, binds data from a capability view, or both. Actions on a
52
- * fragment are always capability action-intent references — never direct
53
- * mutations.
54
- */
55
- interface SduiFragment {
56
- /** Unique identifier within the document. */
57
- id: string;
58
- /** Namespaced component (`pack.Component`) or a core component name. */
59
- component?: string;
60
- /** Props for the component; values may be literals or capability refs. */
61
- props?: Record<string, SduiFragmentValue>;
62
- /** Named slot this fragment fills in its parent component. */
63
- slot?: string;
64
- /** A capability view reference for data-driven fragments. */
65
- dataRef?: `capability://${string}`;
66
- /** Action handlers; every entry must be a capability action-intent reference. */
67
- actions?: Record<string, SduiActionRef>;
68
- /** Child fragments. */
69
- children?: SduiFragment[];
70
- }
71
- type SduiTokenType = "color" | "spacing" | "fontSize" | "fontWeight" | "radius" | "border" | "shadow";
72
- interface SduiToken {
73
- type: SduiTokenType;
74
- value: string;
75
- description?: string;
76
- }
77
- /**
78
- * A versioned set of design tokens. Tokens are semantic, not literal CSS — a
79
- * renderer maps them to its own platform. Two channels consuming the same
80
- * token set apply the same visual intent through different renderings.
81
- */
82
- interface SduiTokenSet {
83
- formatVersion: typeof SDUI_TOKEN_SET_FORMAT_VERSION;
84
- name: string;
85
- version: string;
86
- tokens: Record<string, SduiToken>;
87
- }
88
- interface SduiComponentDefinition {
89
- /** Roles this component implements (for adoption-binding validation). */
90
- implements?: string[];
91
- /** JSON Schema for component props. */
92
- propsSchema?: PortableJsonSchema;
93
- /** Named slots this component accepts. */
94
- slots?: string[];
95
- }
96
- /**
97
- * A versioned pack of SDUI components. Compatible with the adoption-bindings
98
- * `ComponentPackManifest` but adds prop schemas and slot declarations so a
99
- * document can be validated without a renderer.
100
- */
101
- interface SduiComponentPack {
102
- formatVersion: typeof SDUI_COMPONENT_PACK_FORMAT_VERSION;
103
- pack: string;
104
- namespace: string;
105
- version: string;
106
- /** SHA-256 digest of the published component-pack artifact. */
107
- artifactDigest: string;
108
- /**
109
- * Where this pack is loaded from when it is delivered as a federated
110
- * remote. The artifact digest identifies the pack that was reviewed; this
111
- * is what a shell actually executes, so validation requires the two to be
112
- * locked together or the review covers something other than what runs.
113
- */
114
- remote?: SduiComponentPackRemote;
115
- components: Record<string, SduiComponentDefinition>;
116
- }
117
- /** Delivery binding for a federated component pack. */
118
- interface SduiComponentPackRemote {
119
- /** Remote entry URL the shell loads. */
120
- entry: string;
121
- /** Subresource-integrity value for that entry, e.g. `sha384-…`. */
122
- integrity: string;
123
- /** Exposed module path keyed by the component name it provides. */
124
- exposes: Record<string, string>;
125
- }
126
- interface SduiComponentPackReference {
127
- pack: string;
128
- namespace: string;
129
- /** Semver range, e.g. `^1.0.0`. */
130
- range: string;
131
- }
132
- interface SduiTokenSetReference {
133
- name: string;
134
- version: string;
135
- }
136
- /**
137
- * A versioned SDUI document: a tree of fragments, a token-set reference, and
138
- * the component packs it depends on. This is the build-time input; the release
139
- * is the validated, resolved output.
140
- */
141
- interface SduiDocument {
142
- formatVersion: typeof SDUI_DOCUMENT_FORMAT_VERSION;
143
- name: string;
144
- version: string;
145
- /** The tree rendered when no variant is selected. */
146
- root: SduiFragment;
147
- /**
148
- * Alternative trees a compositor may select at request time, for experiment
149
- * arms and personalization. Every variant is enumerated here and validated
150
- * against the same grants as `root`, and all of them are covered by the
151
- * release digest.
152
- *
153
- * Enumeration is what makes selection safe. A selector that can produce a
154
- * tree outside this set cannot be validated at promotion, so "selection may
155
- * never widen grants" would be unenforceable rather than merely unenforced.
156
- */
157
- variants?: SduiVariant[];
158
- tokenSet: SduiTokenSetReference;
159
- componentPacks: SduiComponentPackReference[];
160
- }
161
- /** One selectable alternative to a document's default tree. */
162
- interface SduiVariant {
163
- /** Stable key the compositor matches on. Unique within the document. */
164
- id: string;
165
- /** The audience or experiment arm this arm serves. */
166
- description?: string;
167
- root: SduiFragment;
168
- }
169
- interface ResolvedSduiComponentPack {
170
- pack: string;
171
- namespace: string;
172
- version: string;
173
- range: string;
174
- artifactDigest: string;
175
- /**
176
- * The locked delivery binding, carried onto the release so the digest
177
- * identifies which remote a channel is expected to load. Omitting it would
178
- * let two releases differing only in their remote share a digest.
179
- */
180
- remote?: SduiComponentPackRemote;
181
- }
182
- /**
183
- * A promoted, validated, immutable SDUI release. It bundles a document, a
184
- * resolved token set, and locked component packs. Two channels (web, mobile,
185
- * CLI) can consume the same release and render it through their own renderers
186
- * while reads and actions remain capability references.
187
- */
188
- interface SduiRelease {
189
- formatVersion: typeof SDUI_RELEASE_FORMAT_VERSION;
190
- /** SHA-256 of the canonical document, token set, resolved packs, grants, and assembly identity. */
191
- releaseDigest: string;
192
- /** Approved application assembly this release was validated against. */
193
- assemblyDigest: string;
194
- document: SduiDocument;
195
- tokenSet: SduiTokenSet;
196
- componentPacks: ResolvedSduiComponentPack[];
197
- grants: SduiAuthorizationGrants;
198
- }
199
- type SduiFindingCode = "unknown_component" | "incompatible_pack" | "unauthorized_data_ref" | "denied_view_ref" | "mutation_bypass" | "denied_intent_ref" | "intent_action_not_found" | "invalid_fragment" | "invalid_action_ref" | "unknown_token" | "duplicate_fragment_id" | "invalid_token_set" | "invalid_component_pack" | "invalid_document" | "missing_token_set" | "missing_component_pack" | "component_pack_not_in_assembly" | "capability_contract_not_in_assembly" | "duplicate_variant_id" | "fragment_grant_exceeds_release" | "remote_not_locked";
200
- interface SduiFinding {
201
- code: SduiFindingCode;
202
- path: string;
203
- message: string;
204
- }
205
- interface SduiValidationResult {
206
- valid: boolean;
207
- findings: SduiFinding[];
208
- release: SduiRelease | undefined;
209
- }
210
- /**
211
- * Explicit capability references authorized for an SDUI release.
212
- *
213
- * The presence of a view or action in a supplied usage contract proves that
214
- * the capability publishes it, not that this document may use it. The
215
- * experience host must therefore provide both grant lists explicitly.
216
- */
217
- interface SduiAuthorizationGrants {
218
- /** Full `capability://namespace/view` references allowed in data bindings. */
219
- views: readonly string[];
220
- /** Full `capability://namespace/intent` references allowed in actions. */
221
- intents: readonly string[];
222
- /**
223
- * Per-fragment narrowing, keyed by fragment id.
224
- *
225
- * The release-wide lists above are the ceiling. A listed fragment may use
226
- * only the references named for it, and the narrowing is inherited by that
227
- * fragment's children, so a page assembled from several teams' fragments
228
- * gets least privilege rather than the union of everything any of them
229
- * needs. A fragment entry can only ever narrow: naming a reference outside
230
- * the release-wide list is an authoring error and is reported rather than
231
- * silently granted.
232
- *
233
- * Keys are fragment ids, which are unique within a tree but may repeat
234
- * across variants, so two variants using the same fragment id share one
235
- * entry. Give them distinct ids when they need distinct narrowing. This
236
- * cannot widen either fragment, since narrowing stays an intersection.
237
- */
238
- fragments?: Record<string, SduiFragmentGrants>;
239
- }
240
- /** References one fragment subtree may use, drawn from the release-wide lists. */
241
- interface SduiFragmentGrants {
242
- views?: readonly string[];
243
- intents?: readonly string[];
244
- }
245
- interface SduiValidationInput {
246
- document: SduiDocument;
247
- tokenSet: SduiTokenSet;
248
- /** Available component packs for version resolution. */
249
- componentPacks: SduiComponentPack[];
250
- /** Capability contracts available for data-ref and action validation. */
251
- contracts: UsageContractDocument[];
252
- /**
253
- * Explicit authorization grants for every capability view and action
254
- * reference used by the document. Contract membership alone never grants
255
- * access.
256
- */
257
- grants: SduiAuthorizationGrants;
258
- /** Approved resolved application composition. */
259
- assembly: AssemblyLockfile;
260
- /** Core component vocabulary every renderer implements. */
261
- coreComponents?: readonly string[];
262
- }
6
+ import '@fabricorg/assembly';
263
7
 
264
8
  declare function assertSduiTokenSet(value: unknown, path?: string): asserts value is SduiTokenSet;
265
9
  declare function assertSduiComponentPack(value: unknown, path?: string): asserts value is SduiComponentPack;
@@ -298,6 +42,11 @@ declare function computeReleaseDigest(document: SduiDocument, tokenSet: SduiToke
298
42
  /** Reject promoted release content that no longer matches its immutable digest. */
299
43
  declare function assertSduiReleaseIntegrity(release: SduiRelease): void;
300
44
 
45
+ declare function parseCapabilityRef(ref: string): {
46
+ namespace: string;
47
+ name: string;
48
+ } | undefined;
49
+
301
50
  /**
302
51
  * A channel is a rendering target (web, mobile, CLI). A channel consumes a
303
52
  * validated release and resolves capability references through its own host
@@ -327,8 +76,118 @@ interface SduiChannelConsumptionResult {
327
76
  * components are resolved from the release's locked packs, not the channel.
328
77
  */
329
78
  declare function createSduiChannel(id: string, coreComponents: readonly string[]): SduiChannel;
79
+ /**
80
+ * The subject a channel implementation supplies to be certified.
81
+ *
82
+ * `validRelease` must be a genuinely promoted release, and it must use
83
+ * `unimplementedCoreComponent`, which the channel must not implement. The suite
84
+ * certifies that a channel *reports* what it cannot render, so the fixture has
85
+ * to be one that requires reporting: consuming `validRelease` is therefore
86
+ * expected to come back incompatible. The suite derives its own tampered and
87
+ * unpromoted variants from it, so an implementer never has to hand-construct an
88
+ * invalid release correctly.
89
+ */
90
+ interface SduiChannelConformanceSubject {
91
+ channel: SduiChannel;
92
+ validRelease: SduiRelease;
93
+ /** A core component the channel does not implement, used to prove it reports rather than renders. */
94
+ unimplementedCoreComponent: string;
95
+ }
96
+ interface SduiChannelCheck {
97
+ id: "fabric.sdui-channel.verified-release.v1" | "fabric.sdui-channel.tampered-release-denial.v1" | "fabric.sdui-channel.unpromoted-document-denial.v1" | "fabric.sdui-channel.reports-missing-vocabulary.v1" | "fabric.sdui-channel.consumption-is-pure.v1";
98
+ run(subject: SduiChannelConformanceSubject): Promise<string[]>;
99
+ }
100
+ interface SduiChannelConformanceResult {
101
+ passed: boolean;
102
+ checks: Array<{
103
+ id: SduiChannelCheck["id"];
104
+ status: "passed" | "failed";
105
+ evidence: string[];
106
+ error?: string;
107
+ }>;
108
+ }
109
+ /**
110
+ * The suite any channel must pass before it is allowed to render.
111
+ *
112
+ * The governed path holds only if a channel refuses anything that is not a
113
+ * promoted, digest-verified release. A renderer that accepts a composed
114
+ * document directly never runs `validateSduiRelease`, so grants, variants and
115
+ * locked remotes apply to nothing. That is the single failure this suite
116
+ * exists to make impossible to ship.
117
+ */
118
+ declare function sduiChannelChecks(): readonly SduiChannelCheck[];
119
+ /** Run every channel check, returning each result rather than throwing on the first. */
120
+ declare function runSduiChannelChecks(subject: SduiChannelConformanceSubject): Promise<SduiChannelConformanceResult>;
121
+
122
+ /**
123
+ * What an actor holds, as the surrounding system already models it.
124
+ *
125
+ * These come from wherever entitlements are administered — a plan, a licence,
126
+ * a role assignment, an identity provider's scopes. Fabric does not administer
127
+ * them; it decides what they add up to.
128
+ */
129
+ interface ActorEntitlements {
130
+ permissions?: readonly string[];
131
+ entitlements?: readonly string[];
132
+ featureFlags?: readonly string[];
133
+ }
134
+ /** A capability the actor cannot use, and the first requirement they are missing. */
135
+ interface WithheldCapability {
136
+ namespace: string;
137
+ missing: {
138
+ kind: "permission" | "entitlement" | "featureFlag";
139
+ name: string;
140
+ };
141
+ }
142
+ interface DerivedGrants {
143
+ grants: SduiAuthorizationGrants;
144
+ /** Capabilities deliberately left out, so an absent navigation entry is explainable. */
145
+ withheld: WithheldCapability[];
146
+ }
147
+ interface DeriveGrantsOptions {
148
+ /**
149
+ * Restrict the result to references this document actually binds.
150
+ *
151
+ * Supply it whenever the grants will be promoted. Grants are not only a
152
+ * navigation hint: `validateSduiRelease` carries them onto the release
153
+ * unexamined, and promotion compiles a signed route for every one, so a
154
+ * surplus grant becomes a signed route to a capability the screen never
155
+ * uses. Scoping to the document is what keeps the release's exposed surface
156
+ * equal to what it actually renders.
157
+ */
158
+ document?: SduiDocument;
159
+ /**
160
+ * What to do with a capability that declares no requirements at all.
161
+ *
162
+ * Defaults to `"withhold"`. Requirements are optional metadata, so silence
163
+ * is the common case, and reading silence as "available to everyone" makes
164
+ * the default open. Pass `"grant"` only for a contract set you have decided
165
+ * is unrestricted.
166
+ */
167
+ undeclaredRequirements?: "withhold" | "grant";
168
+ }
169
+ /**
170
+ * Derive release grants from what an actor holds.
171
+ *
172
+ * A shell has to decide what to show. If it answers that from its own
173
+ * configuration while grants are hand-maintained somewhere else and enforcement
174
+ * happens in a third place, the three drift, and the one the user sees drifts
175
+ * from the one that enforces. Deriving grants here makes navigation a
176
+ * projection of the same declarations rather than a parallel guess at them.
177
+ *
178
+ * This is navigation-shaped, not enforcement. It decides what a viewer is
179
+ * offered; `PlatformHost` still re-checks authority when an action executes and
180
+ * `ProjectionHost` still authorizes every query, so stale navigation is a
181
+ * cosmetic problem rather than a security one. Nothing here is a gate.
182
+ *
183
+ * A capability contributes nothing unless every requirement it declares is
184
+ * held. Partial access is not modelled on purpose: a capability that publishes
185
+ * a view behind a permission the actor lacks has said the whole capability is
186
+ * gated, and inferring finer structure from silence would be inventing policy.
187
+ */
188
+ declare function deriveAuthorizationGrants(contracts: readonly UsageContract[], held: ActorEntitlements, options?: DeriveGrantsOptions): DerivedGrants;
330
189
 
331
190
  declare const SDUI_DOCUMENT_JSON_SCHEMA: PortableJsonSchema;
332
191
  declare const SDUI_RELEASE_JSON_SCHEMA: PortableJsonSchema;
333
192
 
334
- export { type ResolvedSduiComponentPack, SDUI_COMPONENT_PACK_FORMAT_VERSION, SDUI_DOCUMENT_FORMAT_VERSION, SDUI_DOCUMENT_JSON_SCHEMA, SDUI_RELEASE_FORMAT_VERSION, SDUI_RELEASE_JSON_SCHEMA, SDUI_TOKEN_SET_FORMAT_VERSION, type SduiActionRef, type SduiAuthorizationGrants, type SduiCapabilityRef, type SduiChannel, type SduiChannelConsumptionResult, type SduiComponentDefinition, type SduiComponentPack, type SduiComponentPackReference, type SduiDocument, type SduiFinding, type SduiFindingCode, type SduiFragment, type SduiFragmentValue, type SduiRelease, type SduiToken, type SduiTokenSet, type SduiTokenSetReference, type SduiTokenType, type SduiValidationInput, type SduiValidationResult, assertSduiAuthorizationGrants, assertSduiComponentPack, assertSduiDocument, assertSduiFragment, assertSduiRelease, assertSduiReleaseIntegrity, assertSduiReleaseValid, assertSduiTokenSet, computeReleaseDigest, createSduiChannel, validateSduiRelease };
193
+ export { type ActorEntitlements, type DerivedGrants, ResolvedSduiComponentPack, SDUI_DOCUMENT_JSON_SCHEMA, SDUI_RELEASE_JSON_SCHEMA, SduiAuthorizationGrants, type SduiChannel, type SduiChannelCheck, type SduiChannelConformanceResult, type SduiChannelConformanceSubject, type SduiChannelConsumptionResult, SduiComponentPack, SduiDocument, SduiFragment, SduiRelease, SduiTokenSet, SduiValidationInput, SduiValidationResult, type WithheldCapability, assertSduiAuthorizationGrants, assertSduiComponentPack, assertSduiDocument, assertSduiFragment, assertSduiRelease, assertSduiReleaseIntegrity, assertSduiReleaseValid, assertSduiTokenSet, computeReleaseDigest, createSduiChannel, deriveAuthorizationGrants, parseCapabilityRef, runSduiChannelChecks, sduiChannelChecks, validateSduiRelease };