@nakafa/aksara-contracts 0.27.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/LICENSE +185 -0
- package/README.md +73 -0
- package/dist/artifact/integrity.d.ts +29 -0
- package/dist/artifact/integrity.js +54 -0
- package/dist/artifact/limits.d.ts +26 -0
- package/dist/artifact/limits.js +46 -0
- package/dist/artifact/source.d.ts +21 -0
- package/dist/artifact/source.js +24 -0
- package/dist/artifact/spec.d.ts +148 -0
- package/dist/artifact/spec.js +92 -0
- package/dist/artifact/verify.d.ts +26 -0
- package/dist/artifact/verify.js +18 -0
- package/dist/cache/content.d.ts +52 -0
- package/dist/cache/content.js +80 -0
- package/dist/content.d.ts +168 -0
- package/dist/content.js +107 -0
- package/dist/country.d.ts +4 -0
- package/dist/country.js +8 -0
- package/dist/date.d.ts +24 -0
- package/dist/date.js +44 -0
- package/dist/decode.d.ts +4 -0
- package/dist/decode.js +8 -0
- package/dist/delivery.d.ts +4 -0
- package/dist/delivery.js +7 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +8 -0
- package/dist/graph/family.d.ts +45 -0
- package/dist/graph/family.js +85 -0
- package/dist/graph/identity.d.ts +19 -0
- package/dist/graph/identity.js +39 -0
- package/dist/graph/spec.d.ts +20 -0
- package/dist/graph/spec.js +26 -0
- package/dist/hash/text.d.ts +10 -0
- package/dist/hash/text.js +20 -0
- package/dist/ids.d.ts +27 -0
- package/dist/ids.js +63 -0
- package/dist/limits.d.ts +10 -0
- package/dist/limits.js +10 -0
- package/dist/locale.d.ts +37 -0
- package/dist/locale.js +53 -0
- package/dist/material/domain.d.ts +4 -0
- package/dist/material/domain.js +8 -0
- package/dist/preview/artifact.d.ts +198 -0
- package/dist/preview/artifact.js +20 -0
- package/dist/preview/auth.d.ts +71 -0
- package/dist/preview/auth.js +49 -0
- package/dist/preview/document.d.ts +692 -0
- package/dist/preview/document.js +90 -0
- package/dist/preview/spec.d.ts +2517 -0
- package/dist/preview/spec.js +142 -0
- package/dist/preview/target.d.ts +172 -0
- package/dist/preview/target.js +70 -0
- package/dist/program/curriculum.d.ts +69 -0
- package/dist/program/curriculum.js +181 -0
- package/dist/program/snapshot/digest.d.ts +26 -0
- package/dist/program/snapshot/digest.js +220 -0
- package/dist/program/snapshot/hash.d.ts +31 -0
- package/dist/program/snapshot/hash.js +40 -0
- package/dist/program/snapshot/row-hash.d.ts +155 -0
- package/dist/program/snapshot/row-hash.js +34 -0
- package/dist/program/snapshot/row.d.ts +139 -0
- package/dist/program/snapshot/row.js +28 -0
- package/dist/program/snapshot/spec.d.ts +36 -0
- package/dist/program/snapshot/spec.js +39 -0
- package/dist/program/spec.d.ts +85 -0
- package/dist/program/spec.js +197 -0
- package/dist/projection/article.d.ts +145 -0
- package/dist/projection/article.js +150 -0
- package/dist/projection/digest.d.ts +261 -0
- package/dist/projection/digest.js +59 -0
- package/dist/projection/hash.d.ts +3 -0
- package/dist/projection/hash.js +10 -0
- package/dist/projection/material.d.ts +109 -0
- package/dist/projection/material.js +160 -0
- package/dist/projection/page.d.ts +112 -0
- package/dist/projection/page.js +106 -0
- package/dist/projection/question.d.ts +520 -0
- package/dist/projection/question.js +109 -0
- package/dist/projection/spec.d.ts +503 -0
- package/dist/projection/spec.js +56 -0
- package/dist/projection/verify.d.ts +281 -0
- package/dist/projection/verify.js +86 -0
- package/dist/question/identity.d.ts +175 -0
- package/dist/question/identity.js +205 -0
- package/dist/question/item.d.ts +453 -0
- package/dist/question/item.js +146 -0
- package/dist/question/response.d.ts +175 -0
- package/dist/question/response.js +150 -0
- package/dist/quran/attribution.d.ts +48 -0
- package/dist/quran/attribution.js +44 -0
- package/dist/quran/identity.d.ts +105 -0
- package/dist/quran/identity.js +100 -0
- package/dist/quran/notes.d.ts +56 -0
- package/dist/quran/notes.js +142 -0
- package/dist/quran/provenance.d.ts +257 -0
- package/dist/quran/provenance.js +144 -0
- package/dist/quran/snapshot/digest.d.ts +33 -0
- package/dist/quran/snapshot/digest.js +232 -0
- package/dist/quran/snapshot/hash.d.ts +51 -0
- package/dist/quran/snapshot/hash.js +50 -0
- package/dist/quran/snapshot/row/hash.d.ts +748 -0
- package/dist/quran/snapshot/row/hash.js +115 -0
- package/dist/quran/snapshot/row.d.ts +354 -0
- package/dist/quran/snapshot/row.js +91 -0
- package/dist/quran/snapshot/spec.d.ts +50 -0
- package/dist/quran/snapshot/spec.js +66 -0
- package/dist/quran/source.d.ts +206 -0
- package/dist/quran/source.js +153 -0
- package/dist/quran/spec.d.ts +47 -0
- package/dist/quran/spec.js +41 -0
- package/dist/quran/text.d.ts +7 -0
- package/dist/quran/text.js +11 -0
- package/dist/release/canonical.d.ts +23 -0
- package/dist/release/canonical.js +29 -0
- package/dist/release/current/evidence.d.ts +424 -0
- package/dist/release/current/evidence.js +41 -0
- package/dist/release/current/runtime.d.ts +4 -0
- package/dist/release/current/runtime.js +15 -0
- package/dist/release/current/state.d.ts +567 -0
- package/dist/release/current/state.js +91 -0
- package/dist/release/digest.d.ts +54 -0
- package/dist/release/digest.js +71 -0
- package/dist/release/hash.d.ts +72 -0
- package/dist/release/hash.js +14 -0
- package/dist/release/head.d.ts +206 -0
- package/dist/release/head.js +131 -0
- package/dist/release/items.d.ts +98 -0
- package/dist/release/items.js +114 -0
- package/dist/release/lifecycle.d.ts +297 -0
- package/dist/release/lifecycle.js +97 -0
- package/dist/release/origin.d.ts +30 -0
- package/dist/release/origin.js +24 -0
- package/dist/release/policy.d.ts +45 -0
- package/dist/release/policy.js +124 -0
- package/dist/release/result/digest.d.ts +127 -0
- package/dist/release/result/digest.js +140 -0
- package/dist/release/result/spec.d.ts +4 -0
- package/dist/release/result/spec.js +5 -0
- package/dist/release/rollback/digest.d.ts +126 -0
- package/dist/release/rollback/digest.js +92 -0
- package/dist/release/rollback/spec.d.ts +1729 -0
- package/dist/release/rollback/spec.js +156 -0
- package/dist/release/route/digest.d.ts +45 -0
- package/dist/release/route/digest.js +59 -0
- package/dist/release/route/page.d.ts +56 -0
- package/dist/release/route/page.js +46 -0
- package/dist/release/route/spec.d.ts +49 -0
- package/dist/release/route/spec.js +40 -0
- package/dist/release/route/verify.d.ts +66 -0
- package/dist/release/route/verify.js +67 -0
- package/dist/release/signing.d.ts +6 -0
- package/dist/release/signing.js +38 -0
- package/dist/release/snapshot/data.d.ts +475 -0
- package/dist/release/snapshot/data.js +74 -0
- package/dist/release/snapshot/evidence-requirement.d.ts +22 -0
- package/dist/release/snapshot/evidence-requirement.js +21 -0
- package/dist/release/snapshot/evidence.d.ts +58 -0
- package/dist/release/snapshot/evidence.js +14 -0
- package/dist/release/snapshot/program-evidence.d.ts +17 -0
- package/dist/release/snapshot/program-evidence.js +39 -0
- package/dist/release/snapshot/quran-evidence.d.ts +27 -0
- package/dist/release/snapshot/quran-evidence.js +43 -0
- package/dist/release/snapshot/scope.d.ts +60 -0
- package/dist/release/snapshot/scope.js +102 -0
- package/dist/release/snapshot/spec.d.ts +193 -0
- package/dist/release/snapshot/spec.js +139 -0
- package/dist/release/snapshot/tryout-evidence.d.ts +22 -0
- package/dist/release/snapshot/tryout-evidence.js +86 -0
- package/dist/release/snapshot/verify.d.ts +710 -0
- package/dist/release/snapshot/verify.js +147 -0
- package/dist/release/spec.d.ts +491 -0
- package/dist/release/spec.js +200 -0
- package/dist/release/verify.d.ts +98 -0
- package/dist/release/verify.js +70 -0
- package/dist/renderer/compatibility.d.ts +35 -0
- package/dist/renderer/compatibility.js +48 -0
- package/dist/renderer/component.d.ts +99 -0
- package/dist/renderer/component.js +102 -0
- package/dist/renderer/contract.d.ts +144 -0
- package/dist/renderer/contract.js +122 -0
- package/dist/renderer/domain.d.ts +6 -0
- package/dist/renderer/domain.js +18 -0
- package/dist/renderer/manifest.d.ts +86 -0
- package/dist/renderer/manifest.js +49 -0
- package/dist/renderer/selection.d.ts +39 -0
- package/dist/renderer/selection.js +87 -0
- package/dist/runtime/error.d.ts +8 -0
- package/dist/runtime/error.js +20 -0
- package/dist/runtime/protected/limits.d.ts +10 -0
- package/dist/runtime/protected/limits.js +15 -0
- package/dist/runtime/protected/spec.d.ts +328 -0
- package/dist/runtime/protected/spec.js +79 -0
- package/dist/runtime/protected/verify.d.ts +97 -0
- package/dist/runtime/protected/verify.js +72 -0
- package/dist/runtime/result.d.ts +12 -0
- package/dist/runtime/result.js +17 -0
- package/dist/runtime/spec.d.ts +705 -0
- package/dist/runtime/spec.js +61 -0
- package/dist/runtime/verify.d.ts +479 -0
- package/dist/runtime/verify.js +123 -0
- package/dist/signature/spec.d.ts +53 -0
- package/dist/signature/spec.js +29 -0
- package/dist/signature/trusted.d.ts +19 -0
- package/dist/signature/trusted.js +32 -0
- package/dist/signature/verify.d.ts +10 -0
- package/dist/signature/verify.js +82 -0
- package/dist/text/order.d.ts +2 -0
- package/dist/text/order.js +10 -0
- package/dist/text/syntax.d.ts +6 -0
- package/dist/text/syntax.js +15 -0
- package/dist/transport/batch.d.ts +971 -0
- package/dist/transport/batch.js +101 -0
- package/dist/transport/failure.d.ts +168 -0
- package/dist/transport/failure.js +194 -0
- package/dist/transport/group.d.ts +2946 -0
- package/dist/transport/group.js +47 -0
- package/dist/transport/limits.d.ts +30 -0
- package/dist/transport/limits.js +30 -0
- package/dist/transport/request.d.ts +9333 -0
- package/dist/transport/request.js +121 -0
- package/dist/transport/response.d.ts +6247 -0
- package/dist/transport/response.js +181 -0
- package/dist/transport/runtime.d.ts +77 -0
- package/dist/transport/runtime.js +33 -0
- package/dist/transport/snapshot.d.ts +978 -0
- package/dist/transport/snapshot.js +70 -0
- package/dist/tryout/canonical.d.ts +2 -0
- package/dist/tryout/canonical.js +11 -0
- package/dist/tryout/catalog-hash.d.ts +134 -0
- package/dist/tryout/catalog-hash.js +203 -0
- package/dist/tryout/catalog.d.ts +376 -0
- package/dist/tryout/catalog.js +147 -0
- package/dist/tryout/content-hash.d.ts +89 -0
- package/dist/tryout/content-hash.js +72 -0
- package/dist/tryout/identity.d.ts +12 -0
- package/dist/tryout/identity.js +46 -0
- package/dist/tryout/key.d.ts +4 -0
- package/dist/tryout/key.js +8 -0
- package/dist/tryout/language.d.ts +24 -0
- package/dist/tryout/language.js +32 -0
- package/dist/tryout/locale-closure.d.ts +20 -0
- package/dist/tryout/locale-closure.js +164 -0
- package/dist/tryout/placement-closure.d.ts +5 -0
- package/dist/tryout/placement-closure.js +30 -0
- package/dist/tryout/placement-hash.d.ts +11 -0
- package/dist/tryout/placement-hash.js +55 -0
- package/dist/tryout/placement.d.ts +280 -0
- package/dist/tryout/placement.js +82 -0
- package/dist/tryout/row-hash.d.ts +28 -0
- package/dist/tryout/row-hash.js +50 -0
- package/dist/tryout/runtime/canonical.d.ts +8 -0
- package/dist/tryout/runtime/canonical.js +33 -0
- package/dist/tryout/runtime/hash.d.ts +32 -0
- package/dist/tryout/runtime/hash.js +11 -0
- package/dist/tryout/runtime/source.d.ts +42 -0
- package/dist/tryout/runtime/source.js +47 -0
- package/dist/tryout/runtime/spec.d.ts +58 -0
- package/dist/tryout/runtime/spec.js +21 -0
- package/dist/tryout/runtime/verify.d.ts +61 -0
- package/dist/tryout/runtime/verify.js +69 -0
- package/dist/tryout/snapshot/canonical.d.ts +7 -0
- package/dist/tryout/snapshot/canonical.js +17 -0
- package/dist/tryout/snapshot/hash.d.ts +8 -0
- package/dist/tryout/snapshot/hash.js +19 -0
- package/dist/tryout/snapshot/spec.d.ts +46 -0
- package/dist/tryout/snapshot/spec.js +30 -0
- package/dist/tryout/spec.d.ts +13 -0
- package/dist/tryout/spec.js +15 -0
- package/package.json +506 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { ContentRuntimeMismatchError } from "#contracts/runtime/error";
|
|
3
|
+
/** Verifies one retained-snapshot batch and every ordered signed artifact. */
|
|
4
|
+
export declare const verifyProtectedContentRuntimeExchange: (input: {
|
|
5
|
+
readonly rendererManifest: unknown;
|
|
6
|
+
readonly request: unknown;
|
|
7
|
+
readonly response: unknown;
|
|
8
|
+
}) => Effect.Effect<{
|
|
9
|
+
readonly bundle: {
|
|
10
|
+
readonly bundleHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
11
|
+
readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
|
|
12
|
+
readonly payload: {
|
|
13
|
+
readonly format: "signed-tryout-runtime-bundle";
|
|
14
|
+
readonly rendererManifestHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
15
|
+
readonly snapshot: {
|
|
16
|
+
readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
|
|
17
|
+
readonly catalogDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
18
|
+
readonly counts: {
|
|
19
|
+
readonly country: number;
|
|
20
|
+
readonly exam: number;
|
|
21
|
+
readonly section: number;
|
|
22
|
+
readonly set: number;
|
|
23
|
+
readonly track: number;
|
|
24
|
+
};
|
|
25
|
+
readonly placementCount: number;
|
|
26
|
+
readonly placementDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
27
|
+
readonly routeCount: number;
|
|
28
|
+
readonly format: "localized-tryout-snapshot";
|
|
29
|
+
readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
30
|
+
};
|
|
31
|
+
readonly sourceGitSha: string & import("effect/Brand").Brand<"@NakafaAI/AksaraGitCommitSha">;
|
|
32
|
+
readonly sourceManifestHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
33
|
+
readonly sourceReleaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">;
|
|
34
|
+
};
|
|
35
|
+
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
36
|
+
};
|
|
37
|
+
readonly items: readonly {
|
|
38
|
+
readonly artifact: {
|
|
39
|
+
readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
40
|
+
readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
|
|
41
|
+
readonly payload: {
|
|
42
|
+
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
43
|
+
readonly byteLength: number;
|
|
44
|
+
readonly compiledCode: string;
|
|
45
|
+
readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
46
|
+
readonly compilerVersion: "0.1.0";
|
|
47
|
+
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
48
|
+
readonly format: "mdx-function-body";
|
|
49
|
+
readonly mdxCompilerVersion: "3.1.1";
|
|
50
|
+
readonly plainText: string;
|
|
51
|
+
readonly rawMdx: string;
|
|
52
|
+
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
53
|
+
readonly requiredComponents: readonly {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly version: number;
|
|
56
|
+
}[];
|
|
57
|
+
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
58
|
+
};
|
|
59
|
+
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
60
|
+
};
|
|
61
|
+
readonly delivery: "authenticated" | "entitled";
|
|
62
|
+
readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
63
|
+
}[];
|
|
64
|
+
readonly kind: "found";
|
|
65
|
+
readonly rendererManifest: {
|
|
66
|
+
readonly base: {
|
|
67
|
+
readonly authoringComponents: readonly {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly version: number;
|
|
70
|
+
}[];
|
|
71
|
+
readonly supportedComponents: readonly {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly version: number;
|
|
74
|
+
}[];
|
|
75
|
+
};
|
|
76
|
+
readonly domains: readonly {
|
|
77
|
+
readonly authoringComponents: readonly {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly version: number;
|
|
80
|
+
}[];
|
|
81
|
+
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
82
|
+
readonly supportedComponents: readonly {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly version: number;
|
|
85
|
+
}[];
|
|
86
|
+
}[];
|
|
87
|
+
readonly format: "nakafa-mdx-renderer-v1";
|
|
88
|
+
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
89
|
+
readonly publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
90
|
+
readonly rendererContractVersion: "1.0.0";
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
93
|
+
readonly kind: "missing";
|
|
94
|
+
} | {
|
|
95
|
+
readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
|
|
96
|
+
readonly kind: "failure";
|
|
97
|
+
}, import("../../artifact/spec.js").ArtifactCompiledByteLengthMismatchError | import("../../artifact/spec.js").ArtifactHashComputationError | import("../../artifact/spec.js").ArtifactHashMismatchError | import("../../artifact/spec.js").ArtifactPayloadFieldByteLimitError | import("../../artifact/spec.js").ArtifactRendererComponentMissingError | import("../../artifact/spec.js").ArtifactRendererDomainUnpublishedError | import("../../artifact/spec.js").ArtifactRendererVersionUnsupportedError | import("../../artifact/spec.js").ArtifactSourceHashComputationError | import("../../artifact/spec.js").ArtifactSourceHashMismatchError | import("../../artifact/spec.js").ArtifactVerificationByteLimitError | import("../../artifact/spec.js").ArtifactVerificationDecodeError | ContentRuntimeMismatchError | import("../../errors.js").ContractDecodeError | import("../../signature/spec.js").PublicKeyParseError | import("../../signature/spec.js").PublicKeyTypeError | import("../../renderer/component.js").RendererAuthoringComponentDuplicateError | import("../../renderer/component.js").RendererAuthoringComponentExtraError | import("../../renderer/component.js").RendererAuthoringComponentMissingError | import("../../renderer/component.js").RendererAuthoringComponentUnsupportedError | import("../../renderer/component.js").RendererAuthoringSelectionNonCanonicalError | import("../../artifact/spec.js").RendererContractVersionMismatchError | import("#contracts/renderer/contract").RendererDomainCapabilityMissingError | import("#contracts/renderer/contract").RendererManifestHashComputeError | import("#contracts/renderer/contract").RendererManifestHashMismatchError | import("../../signature/spec.js").SignatureCheckError | import("../../signature/spec.js").SignatureInvalidError | import("../../signature/spec.js").SigningKeyNotFoundError | import("../../signature/spec.js").SigningKeyResolutionError | import("../../tryout/runtime/hash.js").TryoutRuntimeBundleHashComputationError | import("#contracts/tryout/runtime/verify").TryoutRuntimeBundleHashMismatchError | import("#contracts/tryout/runtime/verify").TryoutRuntimeBundleRendererMismatchError | import("#contracts/tryout/runtime/verify").TryoutRuntimeBundleSnapshotMismatchError | import("#contracts/tryout/runtime/verify").TryoutRuntimeBundleVerificationDecodeError, import("../../signature/spec.js").ContentVerificationKeyResolver>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Effect, Array as ReadonlyArray } from "effect";
|
|
2
|
+
import { verifySignedContentArtifact } from "#contracts/artifact/verify";
|
|
3
|
+
import { verifyContentRendererCompatibility } from "#contracts/renderer/compatibility";
|
|
4
|
+
import { validateLiveRendererManifestHash } from "#contracts/renderer/manifest";
|
|
5
|
+
import { ContentRuntimeMismatchError } from "#contracts/runtime/error";
|
|
6
|
+
import { decodeProtectedContentRuntimeRequest, decodeProtectedContentRuntimeResponse, } from "#contracts/runtime/protected/spec";
|
|
7
|
+
import { verifySignedTryoutRuntimeBundle } from "#contracts/tryout/runtime/verify";
|
|
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
|
+
rendererContractVersion: bundleRenderer.rendererContractVersion,
|
|
33
|
+
rendererManifest: bundleRenderer,
|
|
34
|
+
});
|
|
35
|
+
if (liveRenderer.hash !== bundle.payload.rendererManifestHash) {
|
|
36
|
+
yield* verifyContentRendererCompatibility({
|
|
37
|
+
payload: artifact.payload,
|
|
38
|
+
rendererContractVersion: bundleRenderer.rendererContractVersion,
|
|
39
|
+
rendererManifest: liveRenderer,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
/** Binds one protected batch to its exact permanent runtime bundle. */
|
|
44
|
+
const verifyProtectedBundle = Effect.fn("AksaraContracts.verifyProtectedRuntimeBundle")(function* (request, bundle) {
|
|
45
|
+
if (bundle.bundleHash !== request.bundleHash) {
|
|
46
|
+
return yield* new ContentRuntimeMismatchError({ reason: "bundleHash" });
|
|
47
|
+
}
|
|
48
|
+
if (bundle.payload.snapshot.snapshotId !== request.snapshotId) {
|
|
49
|
+
return yield* new ContentRuntimeMismatchError({ reason: "snapshotId" });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
/** Verifies one retained-snapshot batch and every ordered signed artifact. */
|
|
53
|
+
export const verifyProtectedContentRuntimeExchange = Effect.fn("AksaraContracts.verifyProtectedContentRuntimeExchange")(function* (input) {
|
|
54
|
+
const request = yield* decodeProtectedContentRuntimeRequest(input.request);
|
|
55
|
+
const response = yield* decodeProtectedContentRuntimeResponse(input.response);
|
|
56
|
+
if (response.kind !== "found") {
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
if (response.items.length !== request.selectors.length) {
|
|
60
|
+
return yield* new ContentRuntimeMismatchError({
|
|
61
|
+
reason: "selectorCount",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const bundle = yield* verifySignedTryoutRuntimeBundle({
|
|
65
|
+
bundle: response.bundle,
|
|
66
|
+
rendererManifest: response.rendererManifest,
|
|
67
|
+
});
|
|
68
|
+
const liveRenderer = yield* validateLiveRendererManifestHash(input.rendererManifest);
|
|
69
|
+
yield* verifyProtectedBundle(request, bundle);
|
|
70
|
+
yield* Effect.forEach(ReadonlyArray.zip(request.selectors, response.items), ([selector, item]) => verifyProtectedItem(selector, item, bundle, response.rendererManifest, liveRenderer), { concurrency: "unbounded", discard: true });
|
|
71
|
+
return response;
|
|
72
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Exact absence response distinct from runtime or integrity failures. */
|
|
3
|
+
export declare const ContentRuntimeMissingSchema: Schema.Struct<{
|
|
4
|
+
readonly kind: Schema.Literal<"missing">;
|
|
5
|
+
}>;
|
|
6
|
+
/** Sanitized failure codes exposed by server-only runtime endpoints. */
|
|
7
|
+
export declare const ContentRuntimeFailureCodeSchema: Schema.Literals<readonly ["CONTENT_RUNTIME_INTERNAL", "CONTENT_RUNTIME_INVALID", "CONTENT_RUNTIME_RESPONSE_TOO_LARGE", "CONTENT_RUNTIME_UNAUTHORIZED"]>;
|
|
8
|
+
/** Sanitized runtime failure without implementation details or body bytes. */
|
|
9
|
+
export declare const ContentRuntimeFailureSchema: Schema.Struct<{
|
|
10
|
+
readonly code: Schema.Literals<readonly ["CONTENT_RUNTIME_INTERNAL", "CONTENT_RUNTIME_INVALID", "CONTENT_RUNTIME_RESPONSE_TOO_LARGE", "CONTENT_RUNTIME_UNAUTHORIZED"]>;
|
|
11
|
+
readonly kind: Schema.Literal<"failure">;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Exact absence response distinct from runtime or integrity failures. */
|
|
3
|
+
export const ContentRuntimeMissingSchema = Schema.Struct({
|
|
4
|
+
kind: Schema.Literal("missing"),
|
|
5
|
+
});
|
|
6
|
+
/** Sanitized failure codes exposed by server-only runtime endpoints. */
|
|
7
|
+
export const ContentRuntimeFailureCodeSchema = Schema.Literals([
|
|
8
|
+
"CONTENT_RUNTIME_INTERNAL",
|
|
9
|
+
"CONTENT_RUNTIME_INVALID",
|
|
10
|
+
"CONTENT_RUNTIME_RESPONSE_TOO_LARGE",
|
|
11
|
+
"CONTENT_RUNTIME_UNAUTHORIZED",
|
|
12
|
+
]);
|
|
13
|
+
/** Sanitized runtime failure without implementation details or body bytes. */
|
|
14
|
+
export const ContentRuntimeFailureSchema = Schema.Struct({
|
|
15
|
+
code: ContentRuntimeFailureCodeSchema,
|
|
16
|
+
kind: Schema.Literal("failure"),
|
|
17
|
+
});
|