@voltro/cms 0.86.0 → 0.87.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 +5321 -0
- package/README.md +138 -0
- package/THIRD-PARTY-NOTICES.md +860 -221
- package/dist/RichDocumentView.js +81 -36
- package/dist/aiCandidates.js +3 -3
- package/dist/applicationBuildSnapshotService.js +101 -0
- package/dist/assetRenditions.js +102 -0
- package/dist/assetRevision.js +46 -0
- package/dist/assetUseRights.js +72 -0
- package/dist/availability.js +19 -16
- package/dist/blueprint.js +75 -75
- package/dist/build.d.ts +3063 -0
- package/dist/build.js +37 -0
- package/dist/buildApplicationAdmission.js +16 -0
- package/dist/buildApplicationCatalog.js +136 -0
- package/dist/buildApplicationCatalogTable.js +24 -0
- package/dist/buildApplicationRest.js +99 -0
- package/dist/buildApplicationUpload.js +111 -0
- package/dist/buildSnapshot.js +401 -0
- package/dist/buildSnapshotApplicationPin.js +32 -0
- package/dist/buildSnapshotRest.js +210 -0
- package/dist/buildSnapshotService.js +265 -0
- package/dist/buildSnapshotTables.js +25 -0
- package/dist/bulk.js +71 -70
- package/dist/changes.js +279 -62
- package/dist/consent.js +5 -5
- package/dist/contentLocations.js +53 -0
- package/dist/contentProjection.js +83 -0
- package/dist/contentRouteIdentity.js +13 -0
- package/dist/contentRouteMaterializer.js +97 -0
- package/dist/contentRouteTypes.js +39 -0
- package/dist/contentSeo.js +189 -0
- package/dist/contentTreePath.js +60 -0
- package/dist/contentType.js +117 -100
- package/dist/contentValues.js +18 -0
- package/dist/copies.js +3 -3
- package/dist/domainHost.js +7 -0
- package/dist/domains.js +81 -87
- package/dist/draftTexts.js +37 -37
- package/dist/duplicates.js +23 -23
- package/dist/environmentAliases.js +138 -0
- package/dist/environments.js +107 -69
- package/dist/errors.js +54 -14
- package/dist/experiments.js +7 -7
- package/dist/frontendBindings.js +99 -0
- package/dist/frontendMedia.js +18 -0
- package/dist/index.d.ts +760 -47
- package/dist/index.js +89 -73
- package/dist/initializePublicRoutes.js +28 -0
- package/dist/liveContentRouteView.js +76 -0
- package/dist/nativeOutputDeploymentService.js +205 -0
- package/dist/outputActivation.js +234 -0
- package/dist/outputActivationOrigin.js +51 -0
- package/dist/outputActivationStore.js +411 -0
- package/dist/outputActivationTables.js +11 -0
- package/dist/outputActivationTarget.js +81 -0
- package/dist/outputActivationTargetTable.js +25 -0
- package/dist/outputDeployment.js +174 -0
- package/dist/outputDeploymentRest.js +168 -0
- package/dist/outputDeploymentService.js +241 -0
- package/dist/outputRouteGraph.js +177 -0
- package/dist/outputSafetyArtifact.js +147 -0
- package/dist/outputTargetRest.js +62 -0
- package/dist/pathSegmentEncoding.js +4 -0
- package/dist/privateCmsTransport.js +76 -0
- package/dist/privateNativeRouteReservation.js +10 -0
- package/dist/promotion.js +68 -59
- package/dist/publicBuild.js +90 -0
- package/dist/publicBuildRest.js +98 -0
- package/dist/publicBuildService.js +63 -0
- package/dist/publicOutputHttp.js +129 -0
- package/dist/publicOutputService.js +287 -0
- package/dist/publicPresentation.js +17 -0
- package/dist/publicRouteDispositionAdmission.js +38 -0
- package/dist/publicRouteHistoryStore.js +12 -0
- package/dist/publicRouteHistoryView.js +34 -0
- package/dist/publicRouteIntegrity.js +5 -0
- package/dist/publicRouteMutation.js +6 -0
- package/dist/publicRouteNamespace.js +134 -0
- package/dist/publicRoutePublication.js +36 -0
- package/dist/publicRouteRegistry.js +17 -0
- package/dist/publicRouteRegistryBinding.js +194 -0
- package/dist/publicRouteRegistryDefinition.js +76 -0
- package/dist/publicRouteSitePublication.js +40 -0
- package/dist/publicRouteTables.js +13 -0
- package/dist/publicRouteUrl.js +18 -0
- package/dist/publicationSeo.js +52 -0
- package/dist/publicationState.js +296 -0
- package/dist/quality.js +8 -8
- package/dist/reconfigurePublicRoutes.js +41 -0
- package/dist/redirects.js +104 -73
- package/dist/referenceGraph.js +15 -14
- package/dist/references.js +2 -2
- package/dist/release.js +177 -141
- package/dist/renderReadAuthority.js +43 -0
- package/dist/renderReadGrant.js +137 -0
- package/dist/review.js +28 -28
- package/dist/richDocument.js +54 -24
- package/dist/routeDispositionGraph.js +44 -0
- package/dist/routeDispositionRest.js +51 -0
- package/dist/routeDispositionService.js +73 -0
- package/dist/routeDispositionStore.js +289 -0
- package/dist/routeDispositionTables.js +5 -0
- package/dist/routeDispositions.js +91 -0
- package/dist/routeHistoryStorage.js +320 -0
- package/dist/routeHistoryStore.js +12 -0
- package/dist/schedule.js +36 -36
- package/dist/seo.js +1 -1
- package/dist/series.js +11 -11
- package/dist/share.js +13 -13
- package/dist/siteBindings.js +159 -0
- package/dist/siteBuildCandidate.js +104 -0
- package/dist/siteDelivery.js +115 -0
- package/dist/siteState.js +47 -0
- package/dist/snapshotAddressGraph.js +55 -0
- package/dist/snapshotAddressRead.js +73 -0
- package/dist/snapshotAppConsumer.js +71 -0
- package/dist/snapshotAppExecution.js +102 -0
- package/dist/snapshotApplication.js +75 -0
- package/dist/snapshotApprovedRouteDispositions.js +44 -0
- package/dist/snapshotAssetAssembly.js +70 -0
- package/dist/snapshotAssetAssemblyRest.js +50 -0
- package/dist/snapshotBindingRead.js +61 -0
- package/dist/snapshotCodeSeo.js +29 -0
- package/dist/snapshotComponent.js +34 -0
- package/dist/snapshotComponentSource.js +24 -0
- package/dist/snapshotConsumer.js +87 -0
- package/dist/snapshotContentIdentity.js +10 -0
- package/dist/snapshotDefinitions.js +264 -0
- package/dist/snapshotDocumentAssembly.js +193 -0
- package/dist/snapshotDocumentAssemblyRest.js +84 -0
- package/dist/snapshotDocumentProjection.js +202 -0
- package/dist/snapshotDocumentTransfer.js +35 -0
- package/dist/snapshotDocumentTransferRest.js +80 -0
- package/dist/snapshotDomains.js +56 -0
- package/dist/snapshotEnvironment.js +31 -0
- package/dist/snapshotFieldPlan.js +85 -0
- package/dist/snapshotFrontend.js +103 -0
- package/dist/snapshotLink.js +8 -0
- package/dist/snapshotMedia.js +111 -0
- package/dist/snapshotMediaCapture.js +246 -0
- package/dist/snapshotMediaFields.js +225 -0
- package/dist/snapshotMediaRead.js +185 -0
- package/dist/snapshotMediaReader.js +13 -0
- package/dist/snapshotObservation.js +16 -0
- package/dist/snapshotObservedRouteHistory.js +34 -0
- package/dist/snapshotOutputTransfer.js +78 -0
- package/dist/snapshotPageLoader.js +7 -0
- package/dist/snapshotPageSeo.js +59 -0
- package/dist/snapshotPathLocale.js +15 -0
- package/dist/snapshotPresentation.js +86 -0
- package/dist/snapshotPresentationPolicy.js +12 -0
- package/dist/snapshotProjection.js +119 -0
- package/dist/snapshotPublicAccess.js +161 -0
- package/dist/snapshotPublicRouteHistory.js +40 -0
- package/dist/snapshotReadAdmission.js +38 -0
- package/dist/snapshotRedirectOutput.js +151 -0
- package/dist/snapshotRedirectTargets.js +24 -0
- package/dist/snapshotRedirects.js +132 -0
- package/dist/snapshotReference.js +8 -0
- package/dist/snapshotReferenceAddress.js +10 -0
- package/dist/snapshotReferenceGraph.js +79 -0
- package/dist/snapshotReferenceRead.js +65 -0
- package/dist/snapshotRelease.js +99 -0
- package/dist/snapshotRender.js +361 -0
- package/dist/snapshotRenderDependencies.js +178 -0
- package/dist/snapshotRenditions.js +88 -0
- package/dist/snapshotRichDocument.js +62 -0
- package/dist/snapshotRoleTransfer.js +106 -0
- package/dist/snapshotRoleTransferRest.js +99 -0
- package/dist/snapshotRouteAdmission.js +71 -0
- package/dist/snapshotRouteDispatch.js +111 -0
- package/dist/snapshotRouteDispositionPlan.js +73 -0
- package/dist/snapshotRouteRead.js +43 -0
- package/dist/snapshotRoutes.js +79 -0
- package/dist/snapshotRouting.js +113 -0
- package/dist/snapshotSeo.js +179 -0
- package/dist/snapshotSeoControls.js +101 -0
- package/dist/snapshotSeoDocumentInventory.js +115 -0
- package/dist/snapshotSeoDocuments.js +129 -0
- package/dist/snapshotSeoMerge.js +85 -0
- package/dist/snapshotSeoMetadata.js +137 -0
- package/dist/snapshotSeoOutput.js +173 -0
- package/dist/snapshotSeoPathSets.js +105 -0
- package/dist/snapshotSeoRead.js +88 -0
- package/dist/snapshotSite.js +128 -0
- package/dist/snapshotSitemapFiles.js +36 -0
- package/dist/snapshotTreeDependencies.js +58 -0
- package/dist/snapshotTreeLoader.js +10 -0
- package/dist/snapshotTreeRead.js +158 -0
- package/dist/staticPathSet.js +177 -0
- package/dist/staticPathSetRest.js +129 -0
- package/dist/staticPathSetService.js +249 -0
- package/dist/staticPathSetStore.js +338 -0
- package/dist/tree.js +9 -9
- package/dist/validation.js +53 -53
- package/dist/web.d.ts +709 -7
- package/dist/web.js +50 -33
- package/dist/workflow.js +8 -8
- package/dist/write.js +250 -225
- package/package.json +20 -6
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { compileSiteDelivery as e, defineSiteDelivery as t } from "./siteDelivery.js";
|
|
2
|
+
import { buildTree as n } from "./tree.js";
|
|
3
|
+
import { pageCapturedPublications as r, readCapturedPublication as i, verifyPublicationState as a } from "./publicationState.js";
|
|
4
|
+
import { readVerifiedSnapshotResource as o } from "./buildSnapshot.js";
|
|
5
|
+
import { verifySnapshotRouteOwnership as s } from "./snapshotRouting.js";
|
|
6
|
+
import { admitVerifiedSnapshotPublicDocument as c } from "./snapshotPublicAccess.js";
|
|
7
|
+
import { projectContentValues as l } from "./contentProjection.js";
|
|
8
|
+
import { copySnapshotTrees as u } from "./snapshotProjection.js";
|
|
9
|
+
import { readSnapshotAppExecution as d } from "./snapshotAppExecution.js";
|
|
10
|
+
import { SnapshotRouteReadUnavailable as f, readSnapshotRouteAdmission as p } from "./snapshotRouteAdmission.js";
|
|
11
|
+
import { readAdmittedCapturedAddress as m } from "./snapshotAddressRead.js";
|
|
12
|
+
import { snapshotPathLocale as h } from "./snapshotPathLocale.js";
|
|
13
|
+
import { createHash as g } from "node:crypto";
|
|
14
|
+
import { canonicalJson as _ } from "@voltro/runtime";
|
|
15
|
+
//#region src/snapshotTreeRead.ts
|
|
16
|
+
var v = (e) => {
|
|
17
|
+
throw new f({ reason: e });
|
|
18
|
+
}, y = (e) => g("sha256").update(_(e)).digest("hex"), b = (e) => typeof e != "object" || !e || Array.isArray(e) ? v("definition") : e, x = async (e, n, r, i, a) => {
|
|
19
|
+
let o = { ...i }, c = await p(e, n, r, o, a);
|
|
20
|
+
if (typeof o.name != "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(o.name)) return v("definition");
|
|
21
|
+
let l = t(c.configuration.site), u = h(l, o.path);
|
|
22
|
+
await d(e, c.place, c.snapshot, void 0, [], {
|
|
23
|
+
id: u.id,
|
|
24
|
+
contentLocale: u.contentLocale
|
|
25
|
+
});
|
|
26
|
+
let f = c.route;
|
|
27
|
+
if (f !== void 0 && f.definitionDigest !== c.configuration.definitionDigest) return v("binding");
|
|
28
|
+
let m = f !== void 0 && s(c.configuration, f).owner === "cms" ? {
|
|
29
|
+
contentType: String(f.contentType),
|
|
30
|
+
documentId: String(f.documentId)
|
|
31
|
+
} : null, g = await S(e, c.place, c.snapshot, u.id, m, c.now);
|
|
32
|
+
return Object.hasOwn(g, o.name) ? g[o.name] : v("definition");
|
|
33
|
+
}, S = async (t, s, d, f, p, h) => {
|
|
34
|
+
let g = (await o(t, s, d, "projection", "registry")).value;
|
|
35
|
+
if (g.trees === void 0) return {};
|
|
36
|
+
if (!Array.isArray(g.types) || !g.types.every((e) => typeof e == "string")) return v("binding");
|
|
37
|
+
let x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
|
|
38
|
+
for (let e of Object.values(b(g.trees))) {
|
|
39
|
+
let n = b(e).contentType;
|
|
40
|
+
if (typeof n != "string" || !g.types.includes(n)) return v("definition");
|
|
41
|
+
if (S.has(n)) continue;
|
|
42
|
+
let r = (await o(t, s, d, "schema", `type:${n}`)).value, i = b(r.definition);
|
|
43
|
+
if (r.version !== 1 || i.name !== n || _(r.app) !== _(g.app)) return v("binding");
|
|
44
|
+
S.set(n, r), x.set(n, i);
|
|
45
|
+
}
|
|
46
|
+
let C = u(g.trees, [...x.values()]), w = (await o(t, s, d, "routes", "configuration")).value, T = e(w.site), E = T.definition.locales.find((e) => e.id === f && e.enabled), D = (await o(t, s, d, "site", "configuration")).value;
|
|
47
|
+
if (E === void 0 || T.definition.id !== s.site || !T.definition.environments.includes(s.environment) || w.tenantId !== s.tenantId || w.environment !== s.environment || _(w.app) !== _(g.app) || D.definitionDigest !== y(T.definition)) return v("binding");
|
|
48
|
+
let O = await a(t, s, d.manifest.publication, h), k = Object.create(null), A = 0, j = 0, M = 0, N = 0;
|
|
49
|
+
for (let [e, a] of Object.entries(C)) {
|
|
50
|
+
let o = x.get(a.contentType).tree, u = [
|
|
51
|
+
"id",
|
|
52
|
+
"documentId",
|
|
53
|
+
"revisionId",
|
|
54
|
+
"status",
|
|
55
|
+
"locale",
|
|
56
|
+
o.parent,
|
|
57
|
+
o.segment,
|
|
58
|
+
...o.order === void 0 ? [] : [o.order],
|
|
59
|
+
...a.includeField === void 0 ? [] : [a.includeField]
|
|
60
|
+
], g = /* @__PURE__ */ new Map();
|
|
61
|
+
for (let e of [E.contentLocale, ...T.fallback[E.contentLocale]]) {
|
|
62
|
+
let n;
|
|
63
|
+
do {
|
|
64
|
+
let i = await r(t, s, d.manifest.publication.id, a.contentType, e, {
|
|
65
|
+
limit: 200,
|
|
66
|
+
now: h,
|
|
67
|
+
...n === void 0 ? {} : { after: n }
|
|
68
|
+
});
|
|
69
|
+
for (let t of i.items) {
|
|
70
|
+
if (++A > 5e4) return v("bounds");
|
|
71
|
+
if (typeof t.documentId != "string" || t.status !== "published" || t.locale !== e) return v("publication");
|
|
72
|
+
if (!g.has(t.documentId)) {
|
|
73
|
+
let n = Object.fromEntries(u.filter((e) => Object.hasOwn(t, e)).map((e) => [e, t[e]]));
|
|
74
|
+
if (Object.values(n).some((e) => e !== null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e)))) return v("publication");
|
|
75
|
+
if (N += Buffer.byteLength(_(n)), N > 16777216) return v("bounds");
|
|
76
|
+
g.set(t.documentId, {
|
|
77
|
+
row: n,
|
|
78
|
+
locale: e,
|
|
79
|
+
fallback: e !== E.contentLocale
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
n = i.next ?? void 0;
|
|
84
|
+
} while (n !== void 0);
|
|
85
|
+
}
|
|
86
|
+
for (let e of g.values()) {
|
|
87
|
+
let t = /* @__PURE__ */ new Set(), n = e;
|
|
88
|
+
for (; n !== void 0;) {
|
|
89
|
+
let e = String(n.row.documentId);
|
|
90
|
+
if (t.has(e)) break;
|
|
91
|
+
if (t.size >= 128) return v("bounds");
|
|
92
|
+
t.add(e);
|
|
93
|
+
let r = n.row[o.parent];
|
|
94
|
+
n = typeof r == "string" ? g.get(r) : void 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let y = n([...g.values()], o), b = new Map(y.nodes.map((e) => [e.documentId, e])), S = /* @__PURE__ */ new Map(), C = async (e) => {
|
|
98
|
+
if (S.has(e.documentId)) return S.get(e.documentId);
|
|
99
|
+
if (++M > 4096) return v("bounds");
|
|
100
|
+
let n = await c(t, s, d, O, a.contentType, f, e.documentId, h);
|
|
101
|
+
if (n === null) return S.set(e.documentId, null), null;
|
|
102
|
+
let r = await m(t, s, d, {
|
|
103
|
+
contentType: a.contentType,
|
|
104
|
+
documentId: e.documentId,
|
|
105
|
+
localeId: f,
|
|
106
|
+
mappingId: a.mappingId
|
|
107
|
+
}, n, h);
|
|
108
|
+
if (r === null) return S.set(e.documentId, null), null;
|
|
109
|
+
if (r.document.variantId !== e.row.id || r.document.revisionId !== e.row.revisionId || r.document.locale !== e.locale) return v("binding");
|
|
110
|
+
let o = await i(t, s, d.manifest.publication.id, a.contentType, r.document.locale, r.document.variantId, h);
|
|
111
|
+
if (o === null || o.documentId !== e.documentId || o.revisionId !== r.document.revisionId) return v("publication");
|
|
112
|
+
let u = l({
|
|
113
|
+
version: 1,
|
|
114
|
+
fields: Object.fromEntries(a.fields.map((e) => [e, !0]))
|
|
115
|
+
}, o);
|
|
116
|
+
if (Object.values(u).some((e) => e !== null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e)))) return v("publication");
|
|
117
|
+
let p = {
|
|
118
|
+
documentId: e.documentId,
|
|
119
|
+
parent: e.parent,
|
|
120
|
+
depth: e.depth,
|
|
121
|
+
path: r.output.path,
|
|
122
|
+
sourceLocale: e.locale,
|
|
123
|
+
fallback: e.fallback,
|
|
124
|
+
values: u
|
|
125
|
+
};
|
|
126
|
+
return S.set(e.documentId, p), p;
|
|
127
|
+
}, w = [], D = /* @__PURE__ */ new Set();
|
|
128
|
+
for (let e of y.nodes) {
|
|
129
|
+
if (a.includeField !== void 0 && (e.row[a.includeField] !== !0 || e.parent !== null && !D.has(e.parent))) continue;
|
|
130
|
+
let t = await C(e);
|
|
131
|
+
if (t !== null) {
|
|
132
|
+
if (++j > 4096) return v("bounds");
|
|
133
|
+
w.push(t), D.add(e.documentId);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
let P = p?.contentType === a.contentType ? b.get(p.documentId) : void 0, F = P === void 0 ? null : await C(P), I = [];
|
|
137
|
+
if (F !== null) for (let e = P.parent; e !== null;) {
|
|
138
|
+
let t = b.get(e);
|
|
139
|
+
if (t === void 0) return v("binding");
|
|
140
|
+
let n = await C(t);
|
|
141
|
+
if (n === null) return v("binding");
|
|
142
|
+
if (++j > 4096) return v("bounds");
|
|
143
|
+
I.unshift(n), e = t.parent;
|
|
144
|
+
}
|
|
145
|
+
k[e] = {
|
|
146
|
+
version: 1,
|
|
147
|
+
contentType: a.contentType,
|
|
148
|
+
localeId: f,
|
|
149
|
+
requestedLocale: E.contentLocale,
|
|
150
|
+
currentDocumentId: F?.documentId ?? null,
|
|
151
|
+
nodes: w,
|
|
152
|
+
ancestors: I
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return Buffer.byteLength(_(k)) > 4194304 ? v("bounds") : k;
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
export { S as readAdmittedSnapshotTrees, x as readSnapshotTree };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { normalizeHost as e } from "./domainHost.js";
|
|
2
|
+
import { canonicalCmsPublicPath as t } from "./publicBuild.js";
|
|
3
|
+
import { Schema as n } from "effect";
|
|
4
|
+
import { createHash as r, createHmac as i, timingSafeEqual as a } from "node:crypto";
|
|
5
|
+
import { canonicalJson as o } from "@voltro/runtime";
|
|
6
|
+
//#region src/staticPathSet.ts
|
|
7
|
+
var s = class extends n.TaggedError()("StaticPathSetUnavailable", { reason: n.Literals([
|
|
8
|
+
"input",
|
|
9
|
+
"bounds",
|
|
10
|
+
"integrity",
|
|
11
|
+
"key",
|
|
12
|
+
"cursor",
|
|
13
|
+
"state",
|
|
14
|
+
"changed"
|
|
15
|
+
]) }) {}, c = class extends n.TaggedError()("StaticPathSetConflict", {
|
|
16
|
+
url: n.String,
|
|
17
|
+
owners: n.Array(n.String),
|
|
18
|
+
repair: n.String
|
|
19
|
+
}) {}, l = (e) => r("sha256").update(o(e)).digest("hex"), u = (e) => {
|
|
20
|
+
throw new s({ reason: e });
|
|
21
|
+
}, d = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), f = (e) => typeof e == "string" && /^[A-Za-z0-9_-]{1,64}$/.test(e), p = (e) => typeof e != "object" || !e || Array.isArray(e) ? u("input") : e, m = (e, t) => {
|
|
22
|
+
if (Object.keys(e).sort().join(",") !== [...t].sort().join(",")) return u("input");
|
|
23
|
+
}, h = (e) => typeof e == "string" && e.length > 0 && e.length <= 1024 && !/[\\\x00-\x1f\x7f:]/.test(e) && e.split("/").every((e) => e !== "" && e !== "." && e !== ".." && e.toLowerCase() !== ".git"), g = (n, r) => {
|
|
24
|
+
if (e(n) !== n) return u("input");
|
|
25
|
+
try {
|
|
26
|
+
return `https://${n}${t(r)}`;
|
|
27
|
+
} catch {
|
|
28
|
+
return u("input");
|
|
29
|
+
}
|
|
30
|
+
}, _ = (e) => {
|
|
31
|
+
let t = p(e);
|
|
32
|
+
if (m(t, [
|
|
33
|
+
"host",
|
|
34
|
+
"path",
|
|
35
|
+
"localeId",
|
|
36
|
+
"routeId",
|
|
37
|
+
"owner",
|
|
38
|
+
"file",
|
|
39
|
+
"sourceDigest",
|
|
40
|
+
"parameters"
|
|
41
|
+
]), typeof t.host != "string" || typeof t.path != "string" || !f(t.localeId) || typeof t.routeId != "string" || !/^(route_|native_)[a-f0-9]{64}$/.test(t.routeId) || typeof t.owner != "string" || !["cms", "code"].includes(t.owner) || !(t.file === null && t.sourceDigest === null || h(t.file) && d(t.sourceDigest)) || t.owner === "code" && t.file === null) return u("input");
|
|
42
|
+
g(t.host, t.path);
|
|
43
|
+
let n = p(t.parameters);
|
|
44
|
+
return Object.keys(n).length > 64 || Object.entries(n).some(([e, t]) => !/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e) || typeof t != "string" || t.length > 4096) ? u("input") : {
|
|
45
|
+
host: t.host,
|
|
46
|
+
path: t.path,
|
|
47
|
+
localeId: t.localeId,
|
|
48
|
+
routeId: t.routeId,
|
|
49
|
+
owner: t.owner,
|
|
50
|
+
file: t.file,
|
|
51
|
+
sourceDigest: t.sourceDigest,
|
|
52
|
+
parameters: Object.fromEntries(Object.keys(n).sort().map((e) => [e, n[e]]))
|
|
53
|
+
};
|
|
54
|
+
}, v = (e) => {
|
|
55
|
+
if (!Array.isArray(e) || e.length === 0 || e.length > 2 || e.some((e) => typeof e != "string" || !["cms", "code"].includes(e))) return u("input");
|
|
56
|
+
let t = [...e].sort();
|
|
57
|
+
return new Set(t).size === t.length ? t : u("input");
|
|
58
|
+
}, y = (t) => {
|
|
59
|
+
let n = p(t), r = [
|
|
60
|
+
"tenantId",
|
|
61
|
+
"site",
|
|
62
|
+
"environment",
|
|
63
|
+
"snapshotId",
|
|
64
|
+
"consumerId",
|
|
65
|
+
"buildId"
|
|
66
|
+
], i = [
|
|
67
|
+
"snapshotDigest",
|
|
68
|
+
"inputsId",
|
|
69
|
+
"executionId",
|
|
70
|
+
"routesDigest",
|
|
71
|
+
"domainsDigest",
|
|
72
|
+
"localesDigest",
|
|
73
|
+
"policyDigest",
|
|
74
|
+
"projectionDigest"
|
|
75
|
+
];
|
|
76
|
+
if (m(n, [
|
|
77
|
+
...r,
|
|
78
|
+
...i,
|
|
79
|
+
"releaseId",
|
|
80
|
+
"host",
|
|
81
|
+
"localeIds",
|
|
82
|
+
"owners"
|
|
83
|
+
]), !r.every((e) => f(n[e])) || !i.every((e) => d(n[e])) || !(n.releaseId === null || f(n.releaseId)) || typeof n.host != "string" || e(n.host) !== n.host || !Array.isArray(n.localeIds) || n.localeIds.length === 0 || n.localeIds.length > 64 || n.localeIds.some((e, t, n) => !f(e) || t > 0 && n[t - 1] >= e)) return u("input");
|
|
84
|
+
let a = v(n.owners);
|
|
85
|
+
return o(a) === o(n.owners) ? {
|
|
86
|
+
...n,
|
|
87
|
+
localeIds: [...n.localeIds],
|
|
88
|
+
owners: a
|
|
89
|
+
} : u("input");
|
|
90
|
+
}, b = (e) => !f(e.id) || !(e.material instanceof Uint8Array) || e.material.byteLength < 32 ? u("key") : {
|
|
91
|
+
id: e.id,
|
|
92
|
+
material: new Uint8Array(e.material)
|
|
93
|
+
}, x = (e, t) => i("sha256", t.material).update(o({
|
|
94
|
+
purpose: "voltro.cms.static-path-set/v1",
|
|
95
|
+
id: e,
|
|
96
|
+
keyId: t.id
|
|
97
|
+
})).digest("hex"), S = (e) => {
|
|
98
|
+
let t = p(e);
|
|
99
|
+
if (m(t, [
|
|
100
|
+
"version",
|
|
101
|
+
"context",
|
|
102
|
+
"sort",
|
|
103
|
+
"pageSize",
|
|
104
|
+
"count",
|
|
105
|
+
"sources",
|
|
106
|
+
"pages"
|
|
107
|
+
]), t.version !== 1 || t.sort !== "host-nfc-path/v1" || t.pageSize !== 200 || typeof t.count != "number" || !Number.isSafeInteger(t.count) || t.count < 0 || t.count > 1e5 || !Array.isArray(t.pages) || t.pages.length !== Math.ceil(t.count / 200)) return u("bounds");
|
|
108
|
+
let n = p(t.sources);
|
|
109
|
+
if (m(n, ["count", "digest"]), typeof n.count != "number" || !Number.isSafeInteger(n.count) || n.count < 1 || n.count > 1e5 || !d(n.digest)) return u("integrity");
|
|
110
|
+
let r = 0, i = "", a = t.pages.map((e, n) => {
|
|
111
|
+
let a = p(e);
|
|
112
|
+
return m(a, [
|
|
113
|
+
"count",
|
|
114
|
+
"digest",
|
|
115
|
+
"first",
|
|
116
|
+
"last"
|
|
117
|
+
]), typeof a.count != "number" || a.count !== Math.min(200, Number(t.count) - n * 200) || !d(a.digest) || typeof a.first != "string" || typeof a.last != "string" || a.first > a.last || a.first <= i || a.last.length > 8192 ? u("integrity") : (r += a.count, i = a.last, {
|
|
118
|
+
count: a.count,
|
|
119
|
+
digest: a.digest,
|
|
120
|
+
first: a.first,
|
|
121
|
+
last: a.last
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
return r === t.count ? {
|
|
125
|
+
version: 1,
|
|
126
|
+
context: y(t.context),
|
|
127
|
+
sort: "host-nfc-path/v1",
|
|
128
|
+
pageSize: 200,
|
|
129
|
+
count: r,
|
|
130
|
+
sources: {
|
|
131
|
+
count: n.count,
|
|
132
|
+
digest: n.digest
|
|
133
|
+
},
|
|
134
|
+
pages: a
|
|
135
|
+
} : u("integrity");
|
|
136
|
+
}, C = (e, t) => {
|
|
137
|
+
let n = b(t), r = S(e), i = l(r);
|
|
138
|
+
return {
|
|
139
|
+
id: i,
|
|
140
|
+
manifest: r,
|
|
141
|
+
keyId: n.id,
|
|
142
|
+
signature: x(i, n)
|
|
143
|
+
};
|
|
144
|
+
}, w = (e, t) => {
|
|
145
|
+
let n = p(e);
|
|
146
|
+
m(n, [
|
|
147
|
+
"id",
|
|
148
|
+
"manifest",
|
|
149
|
+
"keyId",
|
|
150
|
+
"signature"
|
|
151
|
+
]);
|
|
152
|
+
let r = t.map(b);
|
|
153
|
+
if (r.length === 0 || new Set(r.map((e) => e.id)).size !== r.length) return u("key");
|
|
154
|
+
let i = r.find((e) => e.id === n.keyId);
|
|
155
|
+
if (i === void 0 || !d(n.id) || !d(n.signature)) return u("integrity");
|
|
156
|
+
let o = S(n.manifest);
|
|
157
|
+
return l(o) !== n.id || !a(Buffer.from(x(n.id, i), "hex"), Buffer.from(n.signature, "hex")) ? u("integrity") : {
|
|
158
|
+
id: n.id,
|
|
159
|
+
manifest: o,
|
|
160
|
+
keyId: i.id,
|
|
161
|
+
signature: n.signature
|
|
162
|
+
};
|
|
163
|
+
}, T = (e, t, n) => {
|
|
164
|
+
if (e.manifest.count === 0 && e.manifest.pages.length === 0 && t === 0 && Array.isArray(n) && n.length === 0) return [];
|
|
165
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= e.manifest.pages.length || !Array.isArray(n)) return u("bounds");
|
|
166
|
+
let r = e.manifest.pages[t];
|
|
167
|
+
if (n.length !== r.count || l(n) !== r.digest) return u("integrity");
|
|
168
|
+
let i = n.map(_), a = "";
|
|
169
|
+
for (let t of i) {
|
|
170
|
+
let n = g(t.host, t.path);
|
|
171
|
+
if (t.host !== e.manifest.context.host || !e.manifest.context.localeIds.includes(t.localeId) || !e.manifest.context.owners.includes(t.owner) || n <= a) return u("integrity");
|
|
172
|
+
a = n;
|
|
173
|
+
}
|
|
174
|
+
return g(i[0].host, i[0].path) !== r.first || a !== r.last ? u("integrity") : i;
|
|
175
|
+
};
|
|
176
|
+
//#endregion
|
|
177
|
+
export { c as StaticPathSetConflict, s as StaticPathSetUnavailable, y as copyStaticPathContext, _ as copyStaticPathEntry, S as copyStaticPathManifest, v as copyStaticPathOwners, C as signStaticPathSet, l as staticPathHash, g as staticPathUrl, T as verifyStaticPathPage, w as verifyStaticPathSet };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { cmsCredential as e, privateCmsHttpRoutes as t, privateCmsOperation as n } from "./privateCmsTransport.js";
|
|
2
|
+
import { StaticPathSetConflict as r, StaticPathSetUnavailable as i } from "./staticPathSet.js";
|
|
3
|
+
import { Schema as a } from "effect";
|
|
4
|
+
//#region src/staticPathSetRest.ts
|
|
5
|
+
var o = a.Struct({
|
|
6
|
+
id: a.String,
|
|
7
|
+
digest: a.String
|
|
8
|
+
}), s = a.Struct({
|
|
9
|
+
snapshot: o,
|
|
10
|
+
consumerId: a.String,
|
|
11
|
+
buildId: a.String,
|
|
12
|
+
host: a.String,
|
|
13
|
+
localeIds: a.optional(a.Array(a.String)),
|
|
14
|
+
owners: a.optional(a.Array(a.Literals(["cms", "code"])))
|
|
15
|
+
}), c = a.Struct({
|
|
16
|
+
tenantId: a.String,
|
|
17
|
+
site: a.String,
|
|
18
|
+
environment: a.String,
|
|
19
|
+
snapshotId: a.String,
|
|
20
|
+
snapshotDigest: a.String,
|
|
21
|
+
releaseId: a.NullOr(a.String),
|
|
22
|
+
consumerId: a.String,
|
|
23
|
+
buildId: a.String,
|
|
24
|
+
inputsId: a.String,
|
|
25
|
+
executionId: a.String,
|
|
26
|
+
routesDigest: a.String,
|
|
27
|
+
domainsDigest: a.String,
|
|
28
|
+
localesDigest: a.String,
|
|
29
|
+
policyDigest: a.String,
|
|
30
|
+
projectionDigest: a.String,
|
|
31
|
+
host: a.String,
|
|
32
|
+
localeIds: a.Array(a.String),
|
|
33
|
+
owners: a.Array(a.Literals(["cms", "code"]))
|
|
34
|
+
}), l = a.Struct({
|
|
35
|
+
id: a.String,
|
|
36
|
+
keyId: a.String,
|
|
37
|
+
signature: a.String,
|
|
38
|
+
manifest: a.Struct({
|
|
39
|
+
version: a.Literal(1),
|
|
40
|
+
context: c,
|
|
41
|
+
sort: a.Literal("host-nfc-path/v1"),
|
|
42
|
+
pageSize: a.Literal(200),
|
|
43
|
+
count: a.Number,
|
|
44
|
+
sources: a.Struct({
|
|
45
|
+
count: a.Number,
|
|
46
|
+
digest: a.String
|
|
47
|
+
}),
|
|
48
|
+
pages: a.Array(a.Struct({
|
|
49
|
+
count: a.Number,
|
|
50
|
+
digest: a.String,
|
|
51
|
+
first: a.String,
|
|
52
|
+
last: a.String
|
|
53
|
+
}))
|
|
54
|
+
})
|
|
55
|
+
}), u = a.Struct({
|
|
56
|
+
id: a.String,
|
|
57
|
+
revision: a.Number,
|
|
58
|
+
phase: a.Literals([
|
|
59
|
+
"cms",
|
|
60
|
+
"code",
|
|
61
|
+
"seal",
|
|
62
|
+
"ready"
|
|
63
|
+
]),
|
|
64
|
+
enumerated: a.Number,
|
|
65
|
+
set: a.NullOr(l)
|
|
66
|
+
}), d = a.Struct({
|
|
67
|
+
host: a.String,
|
|
68
|
+
path: a.String,
|
|
69
|
+
localeId: a.String,
|
|
70
|
+
routeId: a.String,
|
|
71
|
+
owner: a.Literals(["cms", "code"]),
|
|
72
|
+
file: a.NullOr(a.String),
|
|
73
|
+
sourceDigest: a.NullOr(a.String),
|
|
74
|
+
parameters: a.Record(a.String, a.String)
|
|
75
|
+
}), f = {
|
|
76
|
+
namespace: "cms.staticPathSet",
|
|
77
|
+
path: "/v1/cms/static-path-sets",
|
|
78
|
+
operationPrefix: "cmsStaticPathSet",
|
|
79
|
+
tags: ["CMS static path sets"],
|
|
80
|
+
credentialError: "CmsBuildSnapshotUnavailable",
|
|
81
|
+
error: a.Union([i, r]),
|
|
82
|
+
errorStatus: {
|
|
83
|
+
StaticPathSetUnavailable: 409,
|
|
84
|
+
StaticPathSetConflict: 409
|
|
85
|
+
}
|
|
86
|
+
}, p = (t, n) => ({
|
|
87
|
+
snapshot: t.snapshot,
|
|
88
|
+
token: e(n, "CmsBuildSnapshotUnavailable"),
|
|
89
|
+
consumerId: t.consumerId,
|
|
90
|
+
buildId: t.buildId,
|
|
91
|
+
host: t.host,
|
|
92
|
+
...t.localeIds === void 0 ? {} : { localeIds: t.localeIds },
|
|
93
|
+
...t.owners === void 0 ? {} : { owners: t.owners }
|
|
94
|
+
}), m = (e) => {
|
|
95
|
+
let r = [
|
|
96
|
+
n(f, "begin", "Begin or resume a captured static path set", "Render-read bearer. Scope, snapshot, build, admitted host and exact locale selection identify the durable job. An id alone grants nothing.", s, u, (t, n) => e.begin(p(t, n))),
|
|
97
|
+
n(f, "advance", "Advance one bounded durable path enumeration step", "Render-read bearer for the same build. Captured CMS resources and retained native code are merged with captured ownership rules. Renew bounded grants through snapshot open when needed. URL conflicts include both admitted owners and a repair action.", a.Struct({
|
|
98
|
+
...s.fields,
|
|
99
|
+
id: a.String,
|
|
100
|
+
revision: a.Number
|
|
101
|
+
}), u, (t, n) => e.advance({
|
|
102
|
+
...p(t, n),
|
|
103
|
+
id: t.id,
|
|
104
|
+
revision: t.revision
|
|
105
|
+
})),
|
|
106
|
+
n(f, "page", "Read one authenticated immutable static path page", "Render-read bearer. The digest pins the complete signed set and its exact filter, count and ordered page digests. Index is interpreted only within this root. Repeating the same page is idempotent; there is no live fallback.", a.Struct({
|
|
107
|
+
...s.fields,
|
|
108
|
+
id: a.String,
|
|
109
|
+
digest: a.String,
|
|
110
|
+
index: a.Number
|
|
111
|
+
}), a.Struct({
|
|
112
|
+
set: l,
|
|
113
|
+
index: a.Number,
|
|
114
|
+
entries: a.Array(d),
|
|
115
|
+
next: a.NullOr(a.Number)
|
|
116
|
+
}), (t, n) => e.page({
|
|
117
|
+
...p(t, n),
|
|
118
|
+
id: t.id,
|
|
119
|
+
digest: t.digest,
|
|
120
|
+
index: t.index
|
|
121
|
+
}))
|
|
122
|
+
];
|
|
123
|
+
return {
|
|
124
|
+
routes: r,
|
|
125
|
+
httpRoutes: t(r)
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
export { m as cmsStaticPathSetRest };
|