@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
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Effect, Array as ReadonlyArray } from "effect";
|
|
2
|
-
import { decodeProtectedContentRuntimeResponse, } from "#contracts/adoption/runtime";
|
|
3
|
-
import { selectVerifiedArtifactRenderer, verifySignedContentArtifact, verifySignedTryoutRuntimeBundle, } from "#contracts/adoption/verify";
|
|
4
|
-
import { verifyContentRendererCompatibility } from "#contracts/renderer/compatibility";
|
|
5
|
-
import { validateRendererManifestHash } from "#contracts/renderer/manifest";
|
|
6
|
-
import { ContentRuntimeMismatchError } from "#contracts/runtime/error";
|
|
7
|
-
import { decodeProtectedContentRuntimeRequest, } from "#contracts/runtime/protected/spec";
|
|
8
|
-
/** Checks one protected body path matches its exact content and artifact locale. */
|
|
9
|
-
function hasProtectedSourcePath(contentKey, artifactLocale, sourcePath) {
|
|
10
|
-
const separator = contentKey.lastIndexOf("/");
|
|
11
|
-
const sourceRoot = contentKey.slice(0, separator);
|
|
12
|
-
const bodyKind = contentKey.slice(separator + 1);
|
|
13
|
-
return (sourcePath ===
|
|
14
|
-
`packages/corpus/${sourceRoot}/${bodyKind}.${artifactLocale}.mdx`);
|
|
15
|
-
}
|
|
16
|
-
/** Verifies one returned item belongs to its ordered snapshot selector. */
|
|
17
|
-
const verifyProtectedItem = Effect.fn("AksaraContracts.verifyProtectedRuntimeItem")(function* (selector, item, bundle, bundleRenderer, liveRenderer) {
|
|
18
|
-
if (item.delivery !== selector.delivery) {
|
|
19
|
-
return yield* new ContentRuntimeMismatchError({ reason: "delivery" });
|
|
20
|
-
}
|
|
21
|
-
if (item.artifact.artifactHash !== selector.artifactHash) {
|
|
22
|
-
return yield* new ContentRuntimeMismatchError({ reason: "artifactHash" });
|
|
23
|
-
}
|
|
24
|
-
if (item.artifact.payload.contentKey !== selector.contentKey) {
|
|
25
|
-
return yield* new ContentRuntimeMismatchError({ reason: "contentKey" });
|
|
26
|
-
}
|
|
27
|
-
if (!hasProtectedSourcePath(selector.contentKey, item.artifact.payload.artifactLocale, item.sourcePath)) {
|
|
28
|
-
return yield* new ContentRuntimeMismatchError({ reason: "sourcePath" });
|
|
29
|
-
}
|
|
30
|
-
const artifact = yield* verifySignedContentArtifact({
|
|
31
|
-
artifact: item.artifact,
|
|
32
|
-
rendererManifest: bundleRenderer,
|
|
33
|
-
});
|
|
34
|
-
if (liveRenderer.hash !== bundle.payload.rendererManifestHash) {
|
|
35
|
-
yield* verifyContentRendererCompatibility({
|
|
36
|
-
payload: yield* selectVerifiedArtifactRenderer(artifact),
|
|
37
|
-
rendererManifest: liveRenderer,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
/** Binds one protected batch to its exact permanent runtime bundle. */
|
|
42
|
-
const verifyProtectedBundle = Effect.fn("AksaraContracts.verifyProtectedRuntimeBundle")(function* (request, bundle) {
|
|
43
|
-
if (bundle.bundleHash !== request.bundleHash) {
|
|
44
|
-
return yield* new ContentRuntimeMismatchError({ reason: "bundleHash" });
|
|
45
|
-
}
|
|
46
|
-
if (bundle.payload.snapshot.snapshotId !== request.snapshotId) {
|
|
47
|
-
return yield* new ContentRuntimeMismatchError({ reason: "snapshotId" });
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
/** Verifies one retained-snapshot batch and every ordered signed artifact. */
|
|
51
|
-
export const verifyProtectedContentRuntimeExchange = Effect.fn("AksaraContracts.verifyProtectedContentRuntimeExchange")(function* (input) {
|
|
52
|
-
const request = yield* decodeProtectedContentRuntimeRequest(input.request);
|
|
53
|
-
const response = yield* decodeProtectedContentRuntimeResponse(input.response);
|
|
54
|
-
if (response.kind !== "found") {
|
|
55
|
-
return response;
|
|
56
|
-
}
|
|
57
|
-
if (response.items.length !== request.selectors.length) {
|
|
58
|
-
return yield* new ContentRuntimeMismatchError({
|
|
59
|
-
reason: "selectorCount",
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const bundle = yield* verifySignedTryoutRuntimeBundle({
|
|
63
|
-
bundle: response.bundle,
|
|
64
|
-
rendererManifest: response.rendererManifest,
|
|
65
|
-
});
|
|
66
|
-
const liveRenderer = yield* validateRendererManifestHash(input.rendererManifest);
|
|
67
|
-
yield* verifyProtectedBundle(request, bundle);
|
|
68
|
-
yield* Effect.forEach(ReadonlyArray.zip(request.selectors, response.items), ([selector, item]) => verifyProtectedItem(selector, item, bundle, response.rendererManifest, liveRenderer), { concurrency: "unbounded", discard: true });
|
|
69
|
-
return response;
|
|
70
|
-
});
|