@nakafa/aksara-contracts 0.40.0 → 0.42.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/README.md +1 -1
- package/dist/projection/digest.d.ts +35 -35
- package/dist/projection/verify.d.ts +87 -87
- package/dist/quran/snapshot/row/hash.d.ts +50 -50
- package/dist/release/result/digest.d.ts +4 -4
- package/dist/release/snapshot/verify.d.ts +21 -21
- package/dist/runtime/verify.d.ts +54 -54
- package/dist/transport/request.d.ts +90 -90
- package/dist/transport/response.d.ts +138 -138
- package/dist/tryout/catalog-hash.d.ts +18 -18
- package/package.json +2 -29
- package/dist/adoption/protected.d.ts +0 -125
- package/dist/adoption/protected.js +0 -70
- package/dist/adoption/public.d.ts +0 -619
- package/dist/adoption/public.js +0 -121
- package/dist/adoption/runtime.d.ts +0 -1297
- package/dist/adoption/runtime.js +0 -40
- package/dist/adoption/schema.d.ts +0 -3794
- package/dist/adoption/schema.js +0 -125
- package/dist/adoption/transport.d.ts +0 -23257
- package/dist/adoption/transport.js +0 -74
- package/dist/adoption/verify.d.ts +0 -457
- package/dist/adoption/verify.js +0 -167
package/dist/adoption/public.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { decodePublicContentRuntimeResponse, } from "#contracts/adoption/runtime";
|
|
3
|
-
import { selectVerifiedArtifactRenderer, verifyContentReleaseBundle, verifySignedContentArtifact, } from "#contracts/adoption/verify";
|
|
4
|
-
import { hashContentProjection } from "#contracts/projection/hash";
|
|
5
|
-
import { verifyContentRendererCompatibility } from "#contracts/renderer/compatibility";
|
|
6
|
-
import { validateRendererManifestHash } from "#contracts/renderer/manifest";
|
|
7
|
-
import { ContentRuntimeMismatchError } from "#contracts/runtime/error";
|
|
8
|
-
import { decodePublicContentRuntimeRequest, } from "#contracts/runtime/spec";
|
|
9
|
-
/** Checks one article path preserves its pair-grouped physical source identity. */
|
|
10
|
-
function hasArticleSourcePath(projection, sourcePath) {
|
|
11
|
-
const prefix = `packages/corpus/articles/${projection.category}/`;
|
|
12
|
-
const suffix = `/${projection.artifactLocale}.mdx`;
|
|
13
|
-
if (!(sourcePath.startsWith(prefix) && sourcePath.endsWith(suffix))) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
const sourceRoot = sourcePath.slice(prefix.length, -suffix.length);
|
|
17
|
-
const segments = sourceRoot.split("/");
|
|
18
|
-
return segments.length === 2 && segments.join("-") === projection.articleSlug;
|
|
19
|
-
}
|
|
20
|
-
/** Checks one page path matches its signed source-owned provenance. */
|
|
21
|
-
function hasPageSourcePath(projection, sourcePath) {
|
|
22
|
-
return sourcePath === projection.sourcePath;
|
|
23
|
-
}
|
|
24
|
-
/** Checks one public path exactly matches its projected content family. */
|
|
25
|
-
function hasProjectionSourcePath(projection, sourcePath) {
|
|
26
|
-
if (projection.kind === "article") {
|
|
27
|
-
return hasArticleSourcePath(projection, sourcePath);
|
|
28
|
-
}
|
|
29
|
-
if (projection.kind === "public-page") {
|
|
30
|
-
return hasPageSourcePath(projection, sourcePath);
|
|
31
|
-
}
|
|
32
|
-
return (sourcePath ===
|
|
33
|
-
`packages/corpus/${projection.contentKey}/${projection.artifactLocale}.mdx`);
|
|
34
|
-
}
|
|
35
|
-
/** Verifies one active public artifact belongs to its exact route request. */
|
|
36
|
-
const verifyPublicIdentity = Effect.fn("AksaraContracts.verifyPublicIdentity")(function* (request, response) {
|
|
37
|
-
if (response.projection.appLocale !== request.appLocale) {
|
|
38
|
-
return yield* new ContentRuntimeMismatchError({ reason: "locale" });
|
|
39
|
-
}
|
|
40
|
-
if (response.projection.publicPath !== request.publicPath) {
|
|
41
|
-
return yield* new ContentRuntimeMismatchError({ reason: "publicPath" });
|
|
42
|
-
}
|
|
43
|
-
if (!hasProjectionSourcePath(response.projection, response.sourcePath)) {
|
|
44
|
-
return yield* new ContentRuntimeMismatchError({ reason: "sourcePath" });
|
|
45
|
-
}
|
|
46
|
-
if (response.projectionHash !== hashContentProjection(response.projection)) {
|
|
47
|
-
return yield* new ContentRuntimeMismatchError({
|
|
48
|
-
reason: "projectionHash",
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
/** Binds public content to the exact authenticated active release. */
|
|
53
|
-
const verifyPublicRelease = Effect.fn("AksaraContracts.verifyPublicRelease")(function* (response, bundle) {
|
|
54
|
-
if (response.activeReleaseId !== bundle.release.manifest.releaseId) {
|
|
55
|
-
return yield* new ContentRuntimeMismatchError({
|
|
56
|
-
reason: "activeReleaseId",
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (response.activeManifestHash !== bundle.release.manifestHash) {
|
|
60
|
-
return yield* new ContentRuntimeMismatchError({
|
|
61
|
-
reason: "activeManifestHash",
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
/** Authenticates one public response and applies its explicit use policy. */
|
|
66
|
-
const verifyPublicRuntimeExchange = Effect.fn("AksaraContracts.verifyPublicRuntimeExchange")(function* (input) {
|
|
67
|
-
const request = yield* decodePublicContentRuntimeRequest(input.request);
|
|
68
|
-
const response = yield* decodePublicContentRuntimeResponse(input.response);
|
|
69
|
-
if (response.kind !== "found") {
|
|
70
|
-
return response;
|
|
71
|
-
}
|
|
72
|
-
yield* verifyPublicIdentity(request, response);
|
|
73
|
-
const bundle = yield* verifyContentReleaseBundle({
|
|
74
|
-
release: response.release,
|
|
75
|
-
rendererManifest: response.rendererManifest,
|
|
76
|
-
});
|
|
77
|
-
yield* verifyPublicRelease(response, bundle);
|
|
78
|
-
const artifact = yield* verifySignedContentArtifact({
|
|
79
|
-
artifact: response.artifact,
|
|
80
|
-
rendererManifest: bundle.rendererManifest,
|
|
81
|
-
});
|
|
82
|
-
if (input.policy.kind === "evidence") {
|
|
83
|
-
return response;
|
|
84
|
-
}
|
|
85
|
-
const liveRenderer = yield* validateRendererManifestHash(input.policy.rendererManifest);
|
|
86
|
-
if (liveRenderer.hash !== bundle.rendererManifest.hash) {
|
|
87
|
-
yield* verifyContentRendererCompatibility({
|
|
88
|
-
payload: yield* selectVerifiedArtifactRenderer(artifact),
|
|
89
|
-
rendererManifest: liveRenderer,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return response;
|
|
93
|
-
});
|
|
94
|
-
/**
|
|
95
|
-
* Authenticates independently signed runtime evidence for one exact request.
|
|
96
|
-
*
|
|
97
|
-
* This capability does not claim that a non-rendering consumer can execute the
|
|
98
|
-
* artifact with a live renderer.
|
|
99
|
-
*/
|
|
100
|
-
export const verifyContentRuntimeEvidenceExchange = Effect.fn("AksaraContracts.verifyContentRuntimeEvidenceExchange")(function* (input) {
|
|
101
|
-
return yield* verifyPublicRuntimeExchange({
|
|
102
|
-
...input,
|
|
103
|
-
policy: { kind: "evidence" },
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
/**
|
|
107
|
-
* Verifies independently signed runtime values selected for one exact request.
|
|
108
|
-
*
|
|
109
|
-
* Active catalog membership is trusted authenticated target state as recorded
|
|
110
|
-
* in ADR 0002, not an artifact property inferred from the release digest.
|
|
111
|
-
*/
|
|
112
|
-
export const verifyContentRuntimeExchange = Effect.fn("AksaraContracts.verifyContentRuntimeExchange")(function* (input) {
|
|
113
|
-
return yield* verifyPublicRuntimeExchange({
|
|
114
|
-
policy: {
|
|
115
|
-
kind: "execution",
|
|
116
|
-
rendererManifest: input.rendererManifest,
|
|
117
|
-
},
|
|
118
|
-
request: input.request,
|
|
119
|
-
response: input.response,
|
|
120
|
-
});
|
|
121
|
-
});
|