@voltro/cms 0.85.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 +5987 -0
- package/README.md +138 -0
- package/THIRD-PARTY-NOTICES.md +864 -253
- package/dist/ContentForm.js +282 -0
- package/dist/RichDocumentEditor.js +550 -0
- package/dist/RichDocumentView.js +177 -0
- package/dist/RichTextSurface.js +135 -0
- package/dist/aiCandidates.js +199 -0
- package/dist/aiOperations.js +152 -0
- 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/audiences.js +31 -0
- package/dist/availability.js +124 -0
- package/dist/blueprint.js +166 -0
- 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 +282 -0
- package/dist/cacheIdentity.js +152 -0
- package/dist/changes.js +307 -0
- package/dist/cmsContext.js +229 -0
- package/dist/collections.js +224 -0
- package/dist/consent.js +29 -0
- 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 +208 -0
- package/dist/contentValues.js +18 -0
- package/dist/contentfulImport.js +162 -0
- package/dist/copies.js +89 -0
- package/dist/cutover.js +202 -0
- package/dist/deliveryChecks.js +138 -0
- package/dist/domainHost.js +7 -0
- package/dist/domains.js +139 -0
- package/dist/draftTexts.js +164 -0
- package/dist/duplicates.js +78 -0
- package/dist/edgePurge.js +69 -0
- package/dist/editHistory.js +113 -0
- package/dist/effectForm.js +11 -0
- package/dist/environmentAliases.js +138 -0
- package/dist/environments.js +147 -0
- package/dist/errors.js +107 -0
- package/dist/experiments.js +528 -0
- package/dist/exposure.js +28 -0
- package/dist/extensionManifest.js +81 -0
- package/dist/extensions.js +314 -0
- package/dist/fieldSchema.js +199 -0
- package/dist/formStrings.js +74 -0
- package/dist/frontendBindings.js +99 -0
- package/dist/frontendMedia.js +18 -0
- package/dist/glossary.js +73 -0
- package/dist/history.js +54 -0
- package/dist/htmlImport.js +297 -0
- package/dist/index.d.ts +771 -54
- package/dist/index.js +89 -6082
- package/dist/initializePublicRoutes.js +28 -0
- package/dist/liveContentRouteView.js +76 -0
- package/dist/media.js +29 -0
- package/dist/metrics.js +46 -0
- package/dist/migration.js +193 -0
- package/dist/migrationStages.js +13 -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/presenceAnchors.js +68 -0
- package/dist/preview.js +31 -0
- package/dist/privateCmsTransport.js +76 -0
- package/dist/privateNativeRouteReservation.js +10 -0
- package/dist/promotion.js +116 -0
- 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 +188 -0
- package/dist/reconfigurePublicRoutes.js +41 -0
- package/dist/recurrence.js +78 -0
- package/dist/redirects.js +130 -0
- package/dist/referenceGraph.js +224 -0
- package/dist/references.js +173 -0
- package/dist/release.js +241 -0
- package/dist/renderReadAuthority.js +43 -0
- package/dist/renderReadGrant.js +137 -0
- package/dist/rest.js +52 -0
- package/dist/review.js +160 -0
- package/dist/richDocument.js +521 -0
- package/dist/richInline.js +100 -0
- 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 +80 -0
- package/dist/search.js +148 -0
- package/dist/selectionIntent.js +164 -0
- package/dist/seo.js +31 -0
- package/dist/series.js +105 -0
- package/dist/share.js +112 -0
- 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/stewardship.js +146 -0
- package/dist/taxonomy.js +36 -0
- package/dist/team.js +103 -0
- package/dist/templates.js +106 -0
- package/dist/trackChanges.js +197 -0
- package/dist/translation.js +64 -0
- package/dist/tree.js +87 -0
- package/dist/usage.js +50 -0
- package/dist/validation.js +192 -0
- package/dist/visualEditing.js +60 -0
- package/dist/web.d.ts +709 -7
- package/dist/web.js +50 -2
- package/dist/workflow.js +322 -0
- package/dist/write.js +419 -0
- package/dist/xliff.js +325 -0
- package/package.json +20 -6
- package/dist/presenceAnchors-4iHAVQB3.js +0 -4367
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { normalizeHost as e } from "./domainHost.js";
|
|
2
|
+
import { Schema as t } from "effect";
|
|
3
|
+
import { createHash as n, createHmac as r, timingSafeEqual as i } from "node:crypto";
|
|
4
|
+
import { canonicalJson as a } from "@voltro/runtime";
|
|
5
|
+
//#region src/outputActivation.ts
|
|
6
|
+
var o = class extends t.TaggedError()("OutputActivationUnavailable", { reason: t.Literals([
|
|
7
|
+
"input",
|
|
8
|
+
"integrity",
|
|
9
|
+
"state",
|
|
10
|
+
"changed",
|
|
11
|
+
"generation",
|
|
12
|
+
"regions",
|
|
13
|
+
"denied",
|
|
14
|
+
"expired"
|
|
15
|
+
]) }) {}, s = (e) => n("sha256").update(a(e)).digest("hex"), c = (e) => {
|
|
16
|
+
throw new o({ reason: e });
|
|
17
|
+
}, l = c, u = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), d = (e) => typeof e == "string" && /^[A-Za-z0-9_-]{1,64}$/.test(e), f = (e, t) => {
|
|
18
|
+
if (!e || typeof e != "object" || Array.isArray(e) || ![Object.prototype, null].includes(Object.getPrototypeOf(e)) || Object.getOwnPropertySymbols(e).length > 0) return l("input");
|
|
19
|
+
let n = Object.getOwnPropertyDescriptors(e);
|
|
20
|
+
return Object.keys(n).sort().join(",") !== [...t].sort().join(",") || Object.values(n).some((e) => !e.enumerable || !("value" in e)) ? l("input") : e;
|
|
21
|
+
}, p = (e, t) => !Array.isArray(e) || e.length < 1 || e.length > t || Object.getOwnPropertySymbols(e).length > 0 || Object.keys(e).length !== e.length ? l("input") : Array.from({ length: e.length }, (t, n) => {
|
|
22
|
+
let r = Object.getOwnPropertyDescriptor(e, String(n));
|
|
23
|
+
return r === void 0 || !r.enumerable || !("value" in r) ? l("input") : r.value;
|
|
24
|
+
}), m = (e) => {
|
|
25
|
+
let t = f(e, [
|
|
26
|
+
"tenantId",
|
|
27
|
+
"site",
|
|
28
|
+
"environment"
|
|
29
|
+
]);
|
|
30
|
+
return Object.values(t).every(d) ? {
|
|
31
|
+
tenantId: String(t.tenantId),
|
|
32
|
+
site: String(t.site),
|
|
33
|
+
environment: String(t.environment)
|
|
34
|
+
} : l("input");
|
|
35
|
+
}, h = (e) => s({
|
|
36
|
+
contractVersion: e.contractVersion,
|
|
37
|
+
bindingsDigest: e.bindingsDigest,
|
|
38
|
+
schemaDigest: e.schemaDigest,
|
|
39
|
+
cacheKeyDigest: e.cacheKeyDigest
|
|
40
|
+
}), g = (e) => {
|
|
41
|
+
let t = f(e, [
|
|
42
|
+
"publicationGeneration",
|
|
43
|
+
"releaseId",
|
|
44
|
+
"deploymentId",
|
|
45
|
+
"renderPolicyDigest",
|
|
46
|
+
"contractDigest"
|
|
47
|
+
]);
|
|
48
|
+
return typeof t.publicationGeneration != "string" || !/^\d{20}$/.test(t.publicationGeneration) || !(t.releaseId === null || d(t.releaseId)) || !d(t.deploymentId) || !u(t.renderPolicyDigest) || !u(t.contractDigest) ? l("input") : { ...t };
|
|
49
|
+
}, _ = (e) => {
|
|
50
|
+
let t = f(e, [
|
|
51
|
+
"deploymentId",
|
|
52
|
+
"inputsId",
|
|
53
|
+
"executionId",
|
|
54
|
+
"contractVersion",
|
|
55
|
+
"bindingsDigest",
|
|
56
|
+
"schemaDigest",
|
|
57
|
+
"cacheKeyDigest"
|
|
58
|
+
]);
|
|
59
|
+
return !d(t.deploymentId) || ![
|
|
60
|
+
"inputsId",
|
|
61
|
+
"executionId",
|
|
62
|
+
"bindingsDigest",
|
|
63
|
+
"schemaDigest",
|
|
64
|
+
"cacheKeyDigest"
|
|
65
|
+
].every((e) => u(t[e])) || !Number.isSafeInteger(t.contractVersion) || Number(t.contractVersion) < 1 ? l("input") : { ...t };
|
|
66
|
+
}, v = (t) => {
|
|
67
|
+
let n = f(t, [
|
|
68
|
+
"version",
|
|
69
|
+
"scope",
|
|
70
|
+
"snapshot",
|
|
71
|
+
"app",
|
|
72
|
+
"renderPolicyDigest",
|
|
73
|
+
"paths",
|
|
74
|
+
"artifacts",
|
|
75
|
+
"cacheNamespace",
|
|
76
|
+
"regions"
|
|
77
|
+
]);
|
|
78
|
+
if (n.version !== 2 || !u(n.renderPolicyDigest) || !u(n.cacheNamespace)) return l("input");
|
|
79
|
+
let r = m(n.scope), i = f(n.snapshot, [
|
|
80
|
+
"id",
|
|
81
|
+
"digest",
|
|
82
|
+
"releaseId",
|
|
83
|
+
"publicationGeneration"
|
|
84
|
+
]);
|
|
85
|
+
if (!d(i.id) || !u(i.digest) || !d(i.releaseId) || typeof i.publicationGeneration != "string" || !/^\d{20}$/.test(i.publicationGeneration)) return l("input");
|
|
86
|
+
let a = _(n.app), o = "", s = p(n.paths, 256).map((t) => {
|
|
87
|
+
let n = f(t, [
|
|
88
|
+
"host",
|
|
89
|
+
"setId",
|
|
90
|
+
"count"
|
|
91
|
+
]);
|
|
92
|
+
return typeof n.host != "string" || n.host <= o || n.host.length > 253 || e(n.host) !== n.host || !u(n.setId) || !Number.isSafeInteger(n.count) || Number(n.count) < 0 || Number(n.count) > 1e5 ? l("input") : (o = n.host, {
|
|
93
|
+
host: n.host,
|
|
94
|
+
setId: n.setId,
|
|
95
|
+
count: Number(n.count)
|
|
96
|
+
});
|
|
97
|
+
}), c = p(n.artifacts, 256).map((e, t) => {
|
|
98
|
+
let n = f(e, [
|
|
99
|
+
"host",
|
|
100
|
+
"documents",
|
|
101
|
+
"assets",
|
|
102
|
+
"redirects",
|
|
103
|
+
"sitemap",
|
|
104
|
+
"robots",
|
|
105
|
+
"deny"
|
|
106
|
+
]);
|
|
107
|
+
return n.host !== s[t]?.host || ![
|
|
108
|
+
"documents",
|
|
109
|
+
"assets",
|
|
110
|
+
"redirects",
|
|
111
|
+
"sitemap",
|
|
112
|
+
"robots",
|
|
113
|
+
"deny"
|
|
114
|
+
].every((e) => u(n[e])) ? l("input") : { ...n };
|
|
115
|
+
});
|
|
116
|
+
if (c.length !== s.length) return l("input");
|
|
117
|
+
let h = f(n.regions, ["required", "quorum"]), g = p(h.required, 64);
|
|
118
|
+
return g.some((e, t, n) => !d(e) || t > 0 && String(n[t - 1]) >= String(e)) || !Number.isSafeInteger(h.quorum) || Number(h.quorum) < 1 || Number(h.quorum) > g.length ? l("input") : {
|
|
119
|
+
version: 2,
|
|
120
|
+
scope: r,
|
|
121
|
+
snapshot: { ...i },
|
|
122
|
+
app: a,
|
|
123
|
+
renderPolicyDigest: n.renderPolicyDigest,
|
|
124
|
+
paths: s,
|
|
125
|
+
artifacts: c,
|
|
126
|
+
cacheNamespace: n.cacheNamespace,
|
|
127
|
+
regions: {
|
|
128
|
+
required: g,
|
|
129
|
+
quorum: Number(h.quorum)
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}, y = (e) => {
|
|
133
|
+
let t = v(e);
|
|
134
|
+
return {
|
|
135
|
+
id: s(t),
|
|
136
|
+
manifest: t
|
|
137
|
+
};
|
|
138
|
+
}, b = (e) => {
|
|
139
|
+
let t = f(e, ["id", "manifest"]), n = y(t.manifest);
|
|
140
|
+
return t.id === n.id ? n : l("integrity");
|
|
141
|
+
}, x = (e, t, n) => !d(n.id) || !(n.material instanceof Uint8Array) || n.material.byteLength < 32 ? l("input") : r("sha256", n.material).update(a({
|
|
142
|
+
purpose: e,
|
|
143
|
+
body: t,
|
|
144
|
+
keyId: n.id
|
|
145
|
+
})).digest("hex"), S = (e, t, n, r, a) => {
|
|
146
|
+
if (a.length === 0 || new Set(a.map((e) => e.id)).size !== a.length) return l("input");
|
|
147
|
+
let o = a.find((e) => e.id === r);
|
|
148
|
+
if (o === void 0 || !u(n) || !i(Buffer.from(x(e, t, o), "hex"), Buffer.from(n, "hex"))) return l("integrity");
|
|
149
|
+
}, C = (e, t) => {
|
|
150
|
+
let n = {
|
|
151
|
+
version: 1,
|
|
152
|
+
targetId: e.targetId,
|
|
153
|
+
expectedGeneration: e.expectedGeneration,
|
|
154
|
+
mode: e.mode,
|
|
155
|
+
expiresAt: e.expiresAt,
|
|
156
|
+
scope: m(e.scope),
|
|
157
|
+
observation: g(e.observation)
|
|
158
|
+
};
|
|
159
|
+
return !u(n.targetId) || !Number.isSafeInteger(n.expectedGeneration) || n.expectedGeneration < 0 || n.expectedGeneration >= 2 ** 53 - 1 || !["forward", "rollback"].includes(n.mode) || !Number.isSafeInteger(n.expiresAt) || n.expiresAt <= 0 || n.expiresAt > 864e13 ? l("input") : {
|
|
160
|
+
...n,
|
|
161
|
+
id: s(n),
|
|
162
|
+
keyId: t.id,
|
|
163
|
+
signature: x("voltro.cms.output-activation-probe/v1", n, t)
|
|
164
|
+
};
|
|
165
|
+
}, w = (e, t, n) => {
|
|
166
|
+
let r = f(e, [
|
|
167
|
+
"version",
|
|
168
|
+
"id",
|
|
169
|
+
"targetId",
|
|
170
|
+
"scope",
|
|
171
|
+
"expectedGeneration",
|
|
172
|
+
"mode",
|
|
173
|
+
"observation",
|
|
174
|
+
"expiresAt",
|
|
175
|
+
"keyId",
|
|
176
|
+
"signature"
|
|
177
|
+
]);
|
|
178
|
+
if (r.version !== 1 || !u(r.id) || !u(r.targetId) || !d(r.keyId) || !Number.isSafeInteger(r.expectedGeneration) || Number(r.expectedGeneration) < 0 || Number(r.expectedGeneration) >= 2 ** 53 - 1 || !["forward", "rollback"].includes(String(r.mode)) || !Number.isSafeInteger(r.expiresAt) || !Number.isSafeInteger(n)) return l("input");
|
|
179
|
+
let i = {
|
|
180
|
+
version: 1,
|
|
181
|
+
targetId: r.targetId,
|
|
182
|
+
scope: m(r.scope),
|
|
183
|
+
expectedGeneration: Number(r.expectedGeneration),
|
|
184
|
+
mode: r.mode,
|
|
185
|
+
observation: g(r.observation),
|
|
186
|
+
expiresAt: Number(r.expiresAt)
|
|
187
|
+
};
|
|
188
|
+
return s(i) === r.id ? (S("voltro.cms.output-activation-probe/v1", i, r.signature, r.keyId, t), i.expiresAt <= n ? l("expired") : {
|
|
189
|
+
...i,
|
|
190
|
+
id: r.id,
|
|
191
|
+
keyId: r.keyId,
|
|
192
|
+
signature: String(r.signature)
|
|
193
|
+
}) : l("integrity");
|
|
194
|
+
}, T = (e, t, n, r) => {
|
|
195
|
+
if (!d(t) || !u(r)) return l("input");
|
|
196
|
+
let i = {
|
|
197
|
+
version: 1,
|
|
198
|
+
probeId: e.id,
|
|
199
|
+
targetId: e.targetId,
|
|
200
|
+
generation: e.expectedGeneration + 1,
|
|
201
|
+
region: t,
|
|
202
|
+
outputId: r
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
...i,
|
|
206
|
+
keyId: n.id,
|
|
207
|
+
signature: x("voltro.cms.output-region-receipt/v1", i, n)
|
|
208
|
+
};
|
|
209
|
+
}, E = (e, t, n, r) => {
|
|
210
|
+
if (!Array.isArray(n) || n.length > e.manifest.regions.required.length) return l("regions");
|
|
211
|
+
let i = /* @__PURE__ */ new Set(), a = n.map((n) => {
|
|
212
|
+
let a = f(n, [
|
|
213
|
+
"version",
|
|
214
|
+
"probeId",
|
|
215
|
+
"targetId",
|
|
216
|
+
"generation",
|
|
217
|
+
"region",
|
|
218
|
+
"outputId",
|
|
219
|
+
"keyId",
|
|
220
|
+
"signature"
|
|
221
|
+
]);
|
|
222
|
+
return a.version !== 1 || a.probeId !== t.id || a.targetId !== e.id || a.generation !== t.expectedGeneration + 1 || typeof a.region != "string" || !e.manifest.regions.required.includes(a.region) || i.has(a.region) || !u(a.outputId) ? l("regions") : (i.add(a.region), S("voltro.cms.output-region-receipt/v1", {
|
|
223
|
+
version: 1,
|
|
224
|
+
probeId: a.probeId,
|
|
225
|
+
targetId: a.targetId,
|
|
226
|
+
generation: a.generation,
|
|
227
|
+
region: a.region,
|
|
228
|
+
outputId: a.outputId
|
|
229
|
+
}, a.signature, a.keyId, r[a.region] ?? []), { ...a });
|
|
230
|
+
});
|
|
231
|
+
return i.size < e.manifest.regions.quorum ? l("regions") : a.sort((e, t) => e.region < t.region ? -1 : +(e.region > t.region));
|
|
232
|
+
};
|
|
233
|
+
//#endregion
|
|
234
|
+
export { o as OutputActivationUnavailable, _ as copyOutputActivationApp, v as copyOutputActivationManifest, g as copyOutputActivationObservation, m as copyOutputActivationScope, b as copyOutputActivationSet, y as createOutputActivationSet, C as makeOutputActivationProbe, T as makeOutputRegionReceipt, h as outputActivationContractDigest, c as outputActivationFail, s as outputActivationHash, w as verifyOutputActivationProbe, E as verifyOutputRegionReceipts };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { copyOutputActivationManifest as e, outputActivationFail as t, outputActivationHash as n } from "./outputActivation.js";
|
|
2
|
+
import { copySnapshotResource as r } from "./buildSnapshot.js";
|
|
3
|
+
//#region src/outputActivationOrigin.ts
|
|
4
|
+
var i = (e) => !e || typeof e != "object" || Array.isArray(e) ? t("input") : e, a = (a) => {
|
|
5
|
+
if (!/^[A-Za-z0-9_-]{1,64}$/.test(a.activationId) || !Number.isSafeInteger(a.generation) || a.generation < 1) return t("input");
|
|
6
|
+
let o = i(r({
|
|
7
|
+
key: "stored-output-origin",
|
|
8
|
+
value: { manifest: a.manifest }
|
|
9
|
+
}).value.manifest);
|
|
10
|
+
if (typeof a.setId != "string" || !/^[a-f0-9]{64}$/.test(a.setId) || n(o) !== a.setId) return t("integrity");
|
|
11
|
+
if (o.version === 1) {
|
|
12
|
+
let r = i(o.artifacts), s = o.paths;
|
|
13
|
+
if (Object.keys(r).sort().join(",") !== "assets,deny,documents,redirects,robots,sitemap" || !Array.isArray(s)) return t("input");
|
|
14
|
+
let c = e({
|
|
15
|
+
...o,
|
|
16
|
+
version: 2,
|
|
17
|
+
artifacts: s.map((e) => ({
|
|
18
|
+
...r,
|
|
19
|
+
host: i(e).host
|
|
20
|
+
}))
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
scope: c.scope,
|
|
24
|
+
sourceDigest: n({
|
|
25
|
+
version: 1,
|
|
26
|
+
scope: c.scope,
|
|
27
|
+
activationId: a.activationId,
|
|
28
|
+
generation: a.generation,
|
|
29
|
+
setId: a.setId,
|
|
30
|
+
documentArtifactId: r.documents
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
let s = e(o);
|
|
35
|
+
return {
|
|
36
|
+
scope: s.scope,
|
|
37
|
+
sourceDigest: n({
|
|
38
|
+
version: 2,
|
|
39
|
+
scope: s.scope,
|
|
40
|
+
activationId: a.activationId,
|
|
41
|
+
generation: a.generation,
|
|
42
|
+
setId: a.setId,
|
|
43
|
+
documentArtifacts: s.artifacts.map((e) => ({
|
|
44
|
+
host: e.host,
|
|
45
|
+
artifactId: e.documents
|
|
46
|
+
}))
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { a as copyStoredOutputActivationOrigin };
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { copyOutputActivationManifest as e, copyOutputActivationObservation as t, copyOutputActivationScope as n, copyOutputActivationSet as r, makeOutputActivationProbe as i, outputActivationContractDigest as a, outputActivationFail as o, outputActivationHash as s, verifyOutputActivationProbe as c, verifyOutputRegionReceipts as l } from "./outputActivation.js";
|
|
2
|
+
import { copyObservedRoutes as u } from "./routeHistoryStorage.js";
|
|
3
|
+
import { copySnapshotResource as d } from "./buildSnapshot.js";
|
|
4
|
+
import { staticPathUrl as f } from "./staticPathSet.js";
|
|
5
|
+
import { copyStoredOutputActivationOrigin as p } from "./outputActivationOrigin.js";
|
|
6
|
+
import { iterateRouteHistory as m, readRouteHistoryPage as h, replaceRouteHistory as g, routeHistoryTables as _ } from "./routeHistoryStore.js";
|
|
7
|
+
import { and as v, eq as y, generateId as b, gt as x, id as S, integer as C, json as w, table as T, text as E, timestamp as D } from "@voltro/database";
|
|
8
|
+
import { tenant as O } from "@voltro/plugin-multitenancy/mixin";
|
|
9
|
+
import { canonicalJson as k } from "@voltro/runtime";
|
|
10
|
+
//#region src/outputActivationStore.ts
|
|
11
|
+
var A = "_voltro_cms_output_heads", j = "_voltro_cms_output_activations", M = "_voltro_cms_output_denies", N = T(A, {
|
|
12
|
+
id: S({ prefix: "couth" }),
|
|
13
|
+
site: E().maxLength(64),
|
|
14
|
+
environment: E().maxLength(64),
|
|
15
|
+
generation: C(),
|
|
16
|
+
safetyGeneration: C(),
|
|
17
|
+
activeMarkerId: E().maxLength(64).nullable()
|
|
18
|
+
}).with(O()).unique("cms_output_head_scope", [
|
|
19
|
+
"tenantId",
|
|
20
|
+
"site",
|
|
21
|
+
"environment"
|
|
22
|
+
]), P = T(j, {
|
|
23
|
+
id: S({ prefix: "couta" }),
|
|
24
|
+
site: E().maxLength(64),
|
|
25
|
+
environment: E().maxLength(64),
|
|
26
|
+
generation: C(),
|
|
27
|
+
setId: E().maxLength(64),
|
|
28
|
+
manifest: w(),
|
|
29
|
+
probe: w(),
|
|
30
|
+
receipts: w(),
|
|
31
|
+
activatedAt: D()
|
|
32
|
+
}).with(O()).unique("cms_output_activation_generation", [
|
|
33
|
+
"tenantId",
|
|
34
|
+
"site",
|
|
35
|
+
"environment",
|
|
36
|
+
"generation"
|
|
37
|
+
]), F = T(M, {
|
|
38
|
+
id: S({ prefix: "coutd" }),
|
|
39
|
+
site: E().maxLength(64),
|
|
40
|
+
environment: E().maxLength(64),
|
|
41
|
+
keyDigest: E().maxLength(64),
|
|
42
|
+
target: w(),
|
|
43
|
+
reason: E().oneOf([
|
|
44
|
+
"security",
|
|
45
|
+
"rights",
|
|
46
|
+
"takedown"
|
|
47
|
+
])
|
|
48
|
+
}).with(O()).unique("cms_output_safety_deny", [
|
|
49
|
+
"tenantId",
|
|
50
|
+
"site",
|
|
51
|
+
"environment",
|
|
52
|
+
"keyDigest"
|
|
53
|
+
]), I = Object.freeze([
|
|
54
|
+
N,
|
|
55
|
+
P,
|
|
56
|
+
F,
|
|
57
|
+
..._
|
|
58
|
+
]), L = (e) => v(y("tenantId", e.tenantId), y("site", e.site), y("environment", e.environment)), R = (e, t) => {
|
|
59
|
+
let n = b({
|
|
60
|
+
kind: "typeid",
|
|
61
|
+
prefix: e
|
|
62
|
+
}, t);
|
|
63
|
+
return n === null ? o("state") : n;
|
|
64
|
+
}, z = (e) => typeof e.id != "string" || !Number.isSafeInteger(e.generation) || Number(e.generation) < 0 || !Number.isSafeInteger(e.safetyGeneration) || Number(e.safetyGeneration) < 0 || e.activeMarkerId !== null && typeof e.activeMarkerId != "string" || e.generation === 0 != (e.activeMarkerId === null) ? o("state") : {
|
|
65
|
+
id: e.id,
|
|
66
|
+
generation: Number(e.generation),
|
|
67
|
+
safetyGeneration: Number(e.safetyGeneration),
|
|
68
|
+
activeMarkerId: e.activeMarkerId
|
|
69
|
+
}, B = async (e, t, n, r = "update") => {
|
|
70
|
+
n && await e.insertIgnore(A, {
|
|
71
|
+
id: R("couth", A),
|
|
72
|
+
...t,
|
|
73
|
+
generation: 0,
|
|
74
|
+
safetyGeneration: 0,
|
|
75
|
+
activeMarkerId: null
|
|
76
|
+
}, { conflictColumns: [
|
|
77
|
+
"tenantId",
|
|
78
|
+
"site",
|
|
79
|
+
"environment"
|
|
80
|
+
] });
|
|
81
|
+
let [i] = await e.query({
|
|
82
|
+
table: A,
|
|
83
|
+
predicate: L(t),
|
|
84
|
+
lock: r,
|
|
85
|
+
order: [],
|
|
86
|
+
take: 1,
|
|
87
|
+
skip: void 0,
|
|
88
|
+
projection: void 0
|
|
89
|
+
});
|
|
90
|
+
return i === void 0 ? null : z(i);
|
|
91
|
+
}, V = async (e, t) => {
|
|
92
|
+
let r = n(t), i = await B(e, r, !0);
|
|
93
|
+
if (i === null) return o("state");
|
|
94
|
+
let [a] = await e.query({
|
|
95
|
+
table: j,
|
|
96
|
+
predicate: i.generation === 0 ? L(r) : v(L(r), x("generation", i.generation)),
|
|
97
|
+
lock: "update",
|
|
98
|
+
order: [],
|
|
99
|
+
take: 1,
|
|
100
|
+
skip: void 0,
|
|
101
|
+
projection: ["id"]
|
|
102
|
+
});
|
|
103
|
+
if (a !== void 0) return o("state");
|
|
104
|
+
if (i.activeMarkerId === null) return {
|
|
105
|
+
generation: 0,
|
|
106
|
+
activationId: null,
|
|
107
|
+
sourceDigest: null
|
|
108
|
+
};
|
|
109
|
+
let [s] = await e.query({
|
|
110
|
+
table: j,
|
|
111
|
+
predicate: v(L(r), y("id", i.activeMarkerId)),
|
|
112
|
+
lock: "update",
|
|
113
|
+
order: [],
|
|
114
|
+
take: 1,
|
|
115
|
+
skip: void 0,
|
|
116
|
+
projection: void 0
|
|
117
|
+
});
|
|
118
|
+
if (s === void 0 || s.generation !== i.generation) return o("state");
|
|
119
|
+
let c = p({
|
|
120
|
+
setId: s.setId,
|
|
121
|
+
manifest: s.manifest,
|
|
122
|
+
activationId: i.activeMarkerId,
|
|
123
|
+
generation: i.generation
|
|
124
|
+
});
|
|
125
|
+
return W(c.scope, r) ? {
|
|
126
|
+
generation: i.generation,
|
|
127
|
+
activationId: i.activeMarkerId,
|
|
128
|
+
sourceDigest: c.sourceDigest
|
|
129
|
+
} : o("state");
|
|
130
|
+
}, H = (e, t, n, r) => {
|
|
131
|
+
let i = p({
|
|
132
|
+
setId: r.id,
|
|
133
|
+
manifest: r.manifest,
|
|
134
|
+
activationId: t,
|
|
135
|
+
generation: n
|
|
136
|
+
});
|
|
137
|
+
return W(i.scope, e) ? i.sourceDigest : o("state");
|
|
138
|
+
}, U = async (e, t, n) => {
|
|
139
|
+
let r = await n(e, t);
|
|
140
|
+
if (typeof r != "object" || !r || Array.isArray(r) || ![Object.prototype, null].includes(Object.getPrototypeOf(r)) || Object.getOwnPropertySymbols(r).length > 0) return o("input");
|
|
141
|
+
let i = Object.getOwnPropertyDescriptors(r);
|
|
142
|
+
if (Object.keys(i).sort().join(",") !== "documentArtifacts,routes" || Object.values(i).some((e) => !e.enumerable || !("value" in e))) return o("integrity");
|
|
143
|
+
let a = d({
|
|
144
|
+
key: "activation-documents",
|
|
145
|
+
value: { artifacts: i.documentArtifacts.value }
|
|
146
|
+
}).value.artifacts;
|
|
147
|
+
if (k(a) !== k(e.manifest.artifacts.map((e) => ({
|
|
148
|
+
host: e.host,
|
|
149
|
+
artifactId: e.documents
|
|
150
|
+
})))) return o("integrity");
|
|
151
|
+
let s = u(i.routes.value), c = /* @__PURE__ */ new Map();
|
|
152
|
+
for (let t of s) {
|
|
153
|
+
let n = new URL(t.url).hostname;
|
|
154
|
+
if (!e.manifest.paths.some((e) => e.host === n)) return o("integrity");
|
|
155
|
+
c.set(n, (c.get(n) ?? 0) + 1);
|
|
156
|
+
}
|
|
157
|
+
return e.manifest.paths.some((e) => (c.get(e.host) ?? 0) !== e.count) ? o("integrity") : s;
|
|
158
|
+
}, W = (e, t) => k(e) === k(t), G = async (e, n, r, i) => {
|
|
159
|
+
let s = t(await i(e, n, r));
|
|
160
|
+
return r === "forward" && (s.publicationGeneration !== n.manifest.snapshot.publicationGeneration || s.releaseId !== n.manifest.snapshot.releaseId || s.deploymentId !== n.manifest.app.deploymentId || s.renderPolicyDigest !== n.manifest.renderPolicyDigest || s.contractDigest !== a(n.manifest.app)) ? o("changed") : s;
|
|
161
|
+
}, K = async (t, n) => {
|
|
162
|
+
let [r] = await t.query({
|
|
163
|
+
table: j,
|
|
164
|
+
predicate: v(L(n.manifest.scope), y("setId", n.id)),
|
|
165
|
+
order: [],
|
|
166
|
+
take: 1,
|
|
167
|
+
skip: void 0,
|
|
168
|
+
projection: void 0
|
|
169
|
+
});
|
|
170
|
+
if (r === void 0 || k(e(r.manifest)) !== k(n.manifest)) return o("state");
|
|
171
|
+
}, q = async (e, t, i) => {
|
|
172
|
+
let a = n(t), s = await B(e, a, !1);
|
|
173
|
+
if (s === null || s.generation === 0) return {
|
|
174
|
+
revision: 0,
|
|
175
|
+
historyCount: 0
|
|
176
|
+
};
|
|
177
|
+
let u = 0, d;
|
|
178
|
+
for (; u < s.generation;) {
|
|
179
|
+
let t = await e.query({
|
|
180
|
+
table: j,
|
|
181
|
+
predicate: v(L(a), x("generation", u)),
|
|
182
|
+
lock: "update",
|
|
183
|
+
order: [{
|
|
184
|
+
column: "generation",
|
|
185
|
+
direction: "asc"
|
|
186
|
+
}],
|
|
187
|
+
take: 100,
|
|
188
|
+
skip: void 0,
|
|
189
|
+
projection: void 0
|
|
190
|
+
});
|
|
191
|
+
if (t.length === 0) return o("state");
|
|
192
|
+
for (let n of t) {
|
|
193
|
+
if (n.generation !== u + 1 || u >= s.generation || typeof n.id != "string") return o("state");
|
|
194
|
+
let t = r({
|
|
195
|
+
id: n.setId,
|
|
196
|
+
manifest: n.manifest
|
|
197
|
+
}), f = n.activatedAt instanceof Date ? n.activatedAt.getTime() : new Date(String(n.activatedAt)).getTime(), p = c(n.probe, i.keys, f);
|
|
198
|
+
if (!W(t.manifest.scope, a) || !W(p.scope, a) || p.targetId !== t.id || p.expectedGeneration !== u) return o("integrity");
|
|
199
|
+
let m = l(t, p, n.receipts, i.regionKeys), _ = await G(e, t, "rollback", i.admit), v = await U(t, m[0], i.readRoutes);
|
|
200
|
+
if (k(await G(e, t, "rollback", i.admit)) !== k(_)) return o("changed");
|
|
201
|
+
if (d ??= await h(e, a), d.revision !== 0 && d.revision !== s.generation) return o("state");
|
|
202
|
+
u++;
|
|
203
|
+
let y = H(a, n.id, u, t);
|
|
204
|
+
if (d.revision === 0 && await g(e, a, {
|
|
205
|
+
expectedRevision: u - 1,
|
|
206
|
+
sourceDigest: y,
|
|
207
|
+
routes: v
|
|
208
|
+
}), u === s.generation && (n.id !== s.activeMarkerId || d.revision !== 0 && d.sourceDigest !== y)) return o("state");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
let f = await h(e, a);
|
|
212
|
+
for await (let t of m(e, a, f.revision));
|
|
213
|
+
return {
|
|
214
|
+
revision: f.revision,
|
|
215
|
+
historyCount: f.historyCount
|
|
216
|
+
};
|
|
217
|
+
}, J = async (e, t, n) => {
|
|
218
|
+
let a = r(t), s = await B(e, a.manifest.scope, !0);
|
|
219
|
+
if (s === null || s.generation !== n.expectedGeneration || s.generation >= 2147483647) return o("generation");
|
|
220
|
+
if (!Number.isSafeInteger(n.now) || n.now < 0 || !Number.isSafeInteger(n.ttlMs) || n.ttlMs < 1 || n.ttlMs > 3e4) return o("input");
|
|
221
|
+
n.mode === "rollback" && await K(e, a);
|
|
222
|
+
let c = await G(e, a, n.mode, n.admit);
|
|
223
|
+
return i({
|
|
224
|
+
targetId: a.id,
|
|
225
|
+
scope: a.manifest.scope,
|
|
226
|
+
expectedGeneration: s.generation,
|
|
227
|
+
mode: n.mode,
|
|
228
|
+
observation: c,
|
|
229
|
+
expiresAt: n.now + n.ttlMs
|
|
230
|
+
}, n.key);
|
|
231
|
+
}, Y = async (e, t, n) => {
|
|
232
|
+
let i = r(t), a = c(n.probe, n.keys, n.now);
|
|
233
|
+
if (a.targetId !== i.id || !W(a.scope, i.manifest.scope)) return o("integrity");
|
|
234
|
+
let s = await B(e, i.manifest.scope, !1);
|
|
235
|
+
if (s === null || s.generation !== a.expectedGeneration) return o("generation");
|
|
236
|
+
a.mode === "rollback" && await K(e, i);
|
|
237
|
+
let u = await G(e, i, a.mode, n.admit);
|
|
238
|
+
if (k(u) !== k(a.observation)) return o("changed");
|
|
239
|
+
let d = l(i, a, n.receipts, n.regionKeys), f = await U(i, d[0], n.readRoutes);
|
|
240
|
+
if (k(await G(e, i, a.mode, n.admit)) !== k(u)) return o("changed");
|
|
241
|
+
let m = await h(e, i.manifest.scope);
|
|
242
|
+
if (m.revision !== s.generation) return o("state");
|
|
243
|
+
if (s.activeMarkerId !== null) {
|
|
244
|
+
let [t] = await e.query({
|
|
245
|
+
table: j,
|
|
246
|
+
predicate: v(L(i.manifest.scope), y("id", s.activeMarkerId)),
|
|
247
|
+
lock: "update",
|
|
248
|
+
order: [],
|
|
249
|
+
take: 1,
|
|
250
|
+
skip: void 0,
|
|
251
|
+
projection: void 0
|
|
252
|
+
});
|
|
253
|
+
if (t === void 0 || t.generation !== s.generation) return o("state");
|
|
254
|
+
let n = p({
|
|
255
|
+
setId: t.setId,
|
|
256
|
+
manifest: t.manifest,
|
|
257
|
+
activationId: s.activeMarkerId,
|
|
258
|
+
generation: s.generation
|
|
259
|
+
});
|
|
260
|
+
if (!W(n.scope, i.manifest.scope) || m.sourceDigest !== n.sourceDigest) return o("state");
|
|
261
|
+
}
|
|
262
|
+
let _ = {
|
|
263
|
+
id: R("couta", j),
|
|
264
|
+
generation: s.generation + 1,
|
|
265
|
+
set: i,
|
|
266
|
+
probe: a,
|
|
267
|
+
receipts: d,
|
|
268
|
+
activatedAt: n.now
|
|
269
|
+
};
|
|
270
|
+
return await e.updateMany("_voltro_cms_output_heads", {
|
|
271
|
+
generation: _.generation,
|
|
272
|
+
activeMarkerId: _.id
|
|
273
|
+
}, { where: v(L(i.manifest.scope), y("id", s.id), y("generation", s.generation)) }) === 1 ? (await e.insert(j, {
|
|
274
|
+
id: _.id,
|
|
275
|
+
...i.manifest.scope,
|
|
276
|
+
generation: _.generation,
|
|
277
|
+
setId: i.id,
|
|
278
|
+
manifest: i.manifest,
|
|
279
|
+
probe: a,
|
|
280
|
+
receipts: d,
|
|
281
|
+
activatedAt: new Date(n.now)
|
|
282
|
+
}), await g(e, i.manifest.scope, {
|
|
283
|
+
expectedRevision: m.revision,
|
|
284
|
+
sourceDigest: H(i.manifest.scope, _.id, _.generation, i),
|
|
285
|
+
routes: f
|
|
286
|
+
}), _) : o("generation");
|
|
287
|
+
}, X = (e) => {
|
|
288
|
+
if (!e || typeof e != "object") return o("input");
|
|
289
|
+
if (e.kind === "asset" && Object.keys(e).sort().join(",") === "digest,kind" && /^[a-f0-9]{64}$/.test(e.digest)) return { ...e };
|
|
290
|
+
if (e.kind === "url" && Object.keys(e).sort().join(",") === "kind,url") try {
|
|
291
|
+
let t = new URL(e.url);
|
|
292
|
+
if (t.protocol === "https:" && f(t.hostname, t.pathname) === e.url) return { ...e };
|
|
293
|
+
} catch {
|
|
294
|
+
return o("input");
|
|
295
|
+
}
|
|
296
|
+
return o("input");
|
|
297
|
+
}, Z = async (e, t, r = {}) => {
|
|
298
|
+
let i = n(t), { expectedGeneration: a, after: c, take: l = 500 } = r;
|
|
299
|
+
if (!Number.isSafeInteger(l) || l < 1 || l > 1e3 || a !== void 0 && (!Number.isSafeInteger(a) || a < 0 || a > 2147483647) || c !== void 0 && (a === void 0 || typeof c != "string" || !/^[a-f0-9]{64}$/.test(c))) return o("input");
|
|
300
|
+
let u = (await B(e, i, !1))?.safetyGeneration ?? 0;
|
|
301
|
+
if (u > 2147483647) return o("state");
|
|
302
|
+
if (a !== void 0 && a !== u) return o("generation");
|
|
303
|
+
let d = await e.query({
|
|
304
|
+
table: M,
|
|
305
|
+
predicate: v(L(i), ...c === void 0 ? [] : [x("keyDigest", c)]),
|
|
306
|
+
lock: "update",
|
|
307
|
+
order: [{
|
|
308
|
+
column: "keyDigest",
|
|
309
|
+
direction: "asc"
|
|
310
|
+
}],
|
|
311
|
+
take: l + 1,
|
|
312
|
+
skip: void 0,
|
|
313
|
+
projection: [
|
|
314
|
+
"keyDigest",
|
|
315
|
+
"target",
|
|
316
|
+
"reason"
|
|
317
|
+
]
|
|
318
|
+
});
|
|
319
|
+
if (d.length > l + 1 || d.length > u || c === void 0 && d.length <= l && d.length !== u) return o("state");
|
|
320
|
+
let f = c ?? "", p = d.map((e) => {
|
|
321
|
+
let t = X(e.target), n = e.keyDigest, r = e.reason;
|
|
322
|
+
return typeof n != "string" || !/^[a-f0-9]{64}$/.test(n) || n <= f || s(t) !== n ? o("integrity") : r !== "security" && r !== "rights" && r !== "takedown" ? o("state") : (f = n, {
|
|
323
|
+
keyDigest: n,
|
|
324
|
+
target: t,
|
|
325
|
+
reason: r
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
generation: u,
|
|
330
|
+
entries: p.slice(0, l),
|
|
331
|
+
next: p.length > l ? p[l - 1].keyDigest : null
|
|
332
|
+
};
|
|
333
|
+
}, Q = async (e, t, r, i) => {
|
|
334
|
+
let a = n(t), c = X(r);
|
|
335
|
+
if (![
|
|
336
|
+
"security",
|
|
337
|
+
"rights",
|
|
338
|
+
"takedown"
|
|
339
|
+
].includes(i)) return o("input");
|
|
340
|
+
let l = await B(e, a, !0);
|
|
341
|
+
if (l === null || l.safetyGeneration >= 2147483647) return o("state");
|
|
342
|
+
let u = s(c), [d] = await e.query({
|
|
343
|
+
table: M,
|
|
344
|
+
predicate: v(L(a), y("keyDigest", u)),
|
|
345
|
+
order: [],
|
|
346
|
+
take: 1,
|
|
347
|
+
skip: void 0,
|
|
348
|
+
projection: void 0
|
|
349
|
+
});
|
|
350
|
+
if (d !== void 0) return k(d.target) === k(c) ? l.safetyGeneration : o("integrity");
|
|
351
|
+
await e.insert(M, {
|
|
352
|
+
id: R("coutd", M),
|
|
353
|
+
...a,
|
|
354
|
+
keyDigest: u,
|
|
355
|
+
target: c,
|
|
356
|
+
reason: i
|
|
357
|
+
});
|
|
358
|
+
let f = l.safetyGeneration + 1;
|
|
359
|
+
return await e.update(A, l.id, { safetyGeneration: f }), f;
|
|
360
|
+
}, $ = async (e, t, n, i) => {
|
|
361
|
+
if (n.activeMarkerId === null) return o("state");
|
|
362
|
+
let [a] = await e.query({
|
|
363
|
+
table: j,
|
|
364
|
+
predicate: v(L(t), y("id", n.activeMarkerId)),
|
|
365
|
+
order: [],
|
|
366
|
+
take: 1,
|
|
367
|
+
skip: void 0,
|
|
368
|
+
projection: void 0
|
|
369
|
+
});
|
|
370
|
+
if (a === void 0 || a.generation !== n.generation) return o("state");
|
|
371
|
+
let s = a.activatedAt instanceof Date ? a.activatedAt.getTime() : typeof a.activatedAt == "string" ? Date.parse(a.activatedAt) : NaN;
|
|
372
|
+
if (!Number.isSafeInteger(s)) return o("state");
|
|
373
|
+
let u = r({
|
|
374
|
+
id: a.setId,
|
|
375
|
+
manifest: a.manifest
|
|
376
|
+
});
|
|
377
|
+
if (!W(t, u.manifest.scope)) return o("integrity");
|
|
378
|
+
let d = c(a.probe, i.keys, s);
|
|
379
|
+
if (d.targetId !== u.id || d.expectedGeneration + 1 !== n.generation || !W(d.scope, t)) return o("integrity");
|
|
380
|
+
let f = l(u, d, a.receipts, i.regionKeys);
|
|
381
|
+
return {
|
|
382
|
+
id: n.activeMarkerId,
|
|
383
|
+
generation: n.generation,
|
|
384
|
+
set: u,
|
|
385
|
+
probe: d,
|
|
386
|
+
receipts: f,
|
|
387
|
+
activatedAt: s
|
|
388
|
+
};
|
|
389
|
+
}, ee = async (e, t, r) => {
|
|
390
|
+
let i = n(t), a = await B(e, i, !1, r.lock ?? "update");
|
|
391
|
+
return a === null || a.activeMarkerId === null ? null : $(e, i, a, r);
|
|
392
|
+
}, te = async (e, t, r, i) => {
|
|
393
|
+
let a = n(t), c = X(r), l = await B(e, a, !1, i.lock ?? "update");
|
|
394
|
+
if (l === null || l.activeMarkerId === null) return null;
|
|
395
|
+
let [u] = await e.query({
|
|
396
|
+
table: M,
|
|
397
|
+
predicate: v(L(a), y("keyDigest", s(c))),
|
|
398
|
+
order: [],
|
|
399
|
+
take: 1,
|
|
400
|
+
skip: void 0,
|
|
401
|
+
projection: void 0
|
|
402
|
+
});
|
|
403
|
+
if (u !== void 0) return o("denied");
|
|
404
|
+
let d = await $(e, a, l, i), f = d.receipts.find((e) => e.region === i.region);
|
|
405
|
+
return f === void 0 ? o("regions") : (await i.admit(e, d.set, c, f), {
|
|
406
|
+
marker: d,
|
|
407
|
+
safetyGeneration: l.safetyGeneration
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
//#endregion
|
|
411
|
+
export { j as OUTPUT_ACTIVATIONS, A as OUTPUT_ACTIVATION_HEADS, M as OUTPUT_SAFETY_DENIES, Y as activateOutputSet, Q as denyOutputTarget, q as initializeOutputRouteHistory, V as lockOutputRouteHistoryCapture, N as outputActivationHeadsTable, I as outputActivationTables, P as outputActivationsTable, F as outputSafetyDeniesTable, J as probeOutputActivation, te as readActiveOutput, ee as readOutputActivationMarker, Z as readOutputSafetyPage };
|