@nakafa/aksara-contracts 0.39.0 → 0.40.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 +6 -5
- package/dist/adoption/protected.d.ts +125 -0
- package/dist/adoption/protected.js +70 -0
- package/dist/adoption/public.d.ts +619 -0
- package/dist/adoption/public.js +121 -0
- package/dist/adoption/runtime.d.ts +1297 -0
- package/dist/adoption/runtime.js +40 -0
- package/dist/adoption/schema.d.ts +3794 -0
- package/dist/adoption/schema.js +125 -0
- package/dist/adoption/transport.d.ts +23257 -0
- package/dist/adoption/transport.js +74 -0
- package/dist/adoption/verify.d.ts +457 -0
- package/dist/adoption/verify.js +167 -0
- package/dist/artifact/integrity.d.ts +1 -4
- package/dist/artifact/limits.d.ts +1 -4
- package/dist/artifact/source.d.ts +1 -4
- package/dist/artifact/spec.d.ts +5 -45
- package/dist/artifact/spec.js +2 -20
- package/dist/artifact/verify.d.ts +2 -5
- package/dist/artifact/verify.js +0 -1
- package/dist/content.d.ts +8 -48
- package/dist/content.js +4 -9
- package/dist/preview/artifact.d.ts +1 -1
- package/dist/preview/artifact.js +1 -1
- package/dist/preview/auth.d.ts +3 -20
- 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/current/evidence.d.ts +9 -63
- package/dist/release/current/state.d.ts +15 -105
- package/dist/release/hash.d.ts +0 -1
- package/dist/release/lifecycle.d.ts +6 -42
- package/dist/release/lifecycle.js +1 -3
- package/dist/release/result/digest.d.ts +4 -4
- package/dist/release/rollback/spec.d.ts +6 -24
- package/dist/release/signing.js +0 -1
- package/dist/release/snapshot/verify.d.ts +21 -21
- package/dist/release/spec.d.ts +0 -6
- package/dist/release/spec.js +0 -3
- package/dist/release/verify.d.ts +1 -2
- package/dist/renderer/compatibility.d.ts +10 -46
- package/dist/renderer/compatibility.js +20 -45
- package/dist/renderer/component.d.ts +7 -97
- package/dist/renderer/component.js +15 -93
- package/dist/renderer/contract.d.ts +14 -86
- package/dist/renderer/contract.js +16 -54
- package/dist/renderer/manifest.d.ts +10 -72
- package/dist/renderer/manifest.js +40 -41
- package/dist/runtime/protected/spec.d.ts +13 -76
- package/dist/runtime/protected/verify.d.ts +5 -25
- package/dist/runtime/protected/verify.js +2 -4
- package/dist/runtime/spec.d.ts +12 -75
- package/dist/runtime/verify.d.ts +64 -106
- package/dist/runtime/verify.js +2 -4
- package/dist/transport/batch.d.ts +2 -8
- package/dist/transport/group.d.ts +3 -12
- package/dist/transport/request.d.ts +116 -256
- package/dist/transport/response.d.ts +187 -467
- package/dist/tryout/catalog-hash.d.ts +18 -18
- package/dist/tryout/runtime/verify.d.ts +1 -1
- package/package.json +28 -1
- package/dist/renderer/selection.d.ts +0 -39
- package/dist/renderer/selection.js +0 -87
package/README.md
CHANGED
|
@@ -68,11 +68,12 @@ live renderer when the deployed manifest hash differs. Non-rendering evidence
|
|
|
68
68
|
verification authenticates the same frozen release and artifact without
|
|
69
69
|
claiming that its consumer can execute the artifact. This directional
|
|
70
70
|
execution check lets an additive live renderer serve an older release only when
|
|
71
|
-
it still publishes the selected domain and
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
it still publishes the selected domain and contains every required component
|
|
72
|
+
name. Every current manifest contains the complete canonical domain set. The same
|
|
73
|
+
contract validates stored and deployed manifests. A renderer-changing release
|
|
74
|
+
remains bound to the exact deployed manifest. A scoped content-only release may
|
|
75
|
+
retain the active frozen manifest only when activation proves the live renderer still publishes every frozen
|
|
76
|
+
domain and contains every frozen component name. The renderer is not a
|
|
76
77
|
third signed value. Current production trusts authenticated
|
|
77
78
|
Convex state for route/head membership, delivery class, and the active pointer;
|
|
78
79
|
a release result digest is not a per-row inclusion proof. This boundary is
|
|
@@ -0,0 +1,125 @@
|
|
|
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 kind: "found";
|
|
38
|
+
readonly items: readonly {
|
|
39
|
+
readonly delivery: "authenticated" | "entitled";
|
|
40
|
+
readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
41
|
+
readonly artifact: {
|
|
42
|
+
readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
43
|
+
readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
|
|
44
|
+
readonly payload: {
|
|
45
|
+
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
46
|
+
readonly byteLength: number;
|
|
47
|
+
readonly compiledCode: string;
|
|
48
|
+
readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
49
|
+
readonly compilerVersion: "0.1.0";
|
|
50
|
+
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
51
|
+
readonly format: "mdx-function-body";
|
|
52
|
+
readonly mdxCompilerVersion: "3.1.1";
|
|
53
|
+
readonly plainText: string;
|
|
54
|
+
readonly rawMdx: string;
|
|
55
|
+
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
56
|
+
readonly requiredComponents: readonly string[];
|
|
57
|
+
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
58
|
+
};
|
|
59
|
+
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
60
|
+
} | {
|
|
61
|
+
readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
62
|
+
readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
|
|
63
|
+
readonly payload: {
|
|
64
|
+
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
65
|
+
readonly byteLength: number;
|
|
66
|
+
readonly compiledCode: string;
|
|
67
|
+
readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
68
|
+
readonly compilerVersion: "0.1.0";
|
|
69
|
+
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
70
|
+
readonly format: "mdx-function-body";
|
|
71
|
+
readonly mdxCompilerVersion: "3.1.1";
|
|
72
|
+
readonly plainText: string;
|
|
73
|
+
readonly rawMdx: string;
|
|
74
|
+
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
75
|
+
readonly requiredComponents: readonly {
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly version: number;
|
|
78
|
+
}[];
|
|
79
|
+
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
80
|
+
};
|
|
81
|
+
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
82
|
+
};
|
|
83
|
+
}[];
|
|
84
|
+
readonly rendererManifest: {
|
|
85
|
+
readonly base: readonly string[];
|
|
86
|
+
readonly domains: readonly {
|
|
87
|
+
readonly components: readonly string[];
|
|
88
|
+
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
89
|
+
}[];
|
|
90
|
+
readonly format: "nakafa-mdx-renderer";
|
|
91
|
+
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
92
|
+
readonly publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
93
|
+
} | {
|
|
94
|
+
readonly base: {
|
|
95
|
+
readonly authoringComponents: readonly {
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly version: number;
|
|
98
|
+
}[];
|
|
99
|
+
readonly supportedComponents: readonly {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly version: number;
|
|
102
|
+
}[];
|
|
103
|
+
};
|
|
104
|
+
readonly domains: readonly {
|
|
105
|
+
readonly authoringComponents: readonly {
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly version: number;
|
|
108
|
+
}[];
|
|
109
|
+
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
110
|
+
readonly supportedComponents: readonly {
|
|
111
|
+
readonly name: string;
|
|
112
|
+
readonly version: number;
|
|
113
|
+
}[];
|
|
114
|
+
}[];
|
|
115
|
+
readonly format: "nakafa-mdx-renderer-v1";
|
|
116
|
+
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
117
|
+
readonly publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
118
|
+
readonly rendererContractVersion: "1.0.0";
|
|
119
|
+
};
|
|
120
|
+
} | {
|
|
121
|
+
readonly kind: "missing";
|
|
122
|
+
} | {
|
|
123
|
+
readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
|
|
124
|
+
readonly kind: "failure";
|
|
125
|
+
}, 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").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("../release/hash.js").ReleaseHashComputationError | import("../release/verify.js").ReleaseManifestHashMismatchError | import("../release/verify.js").ReleaseVerificationDecodeError | import("../renderer/contract.js").RendererDomainCapabilityMissingError | import("../renderer/contract.js").RendererManifestHashComputeError | import("../renderer/contract.js").RendererManifestHashMismatchError | import("#contracts/adoption/schema").RetainedRendererComponentUnsupportedError | 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("../tryout/runtime/verify.js").TryoutRuntimeBundleHashMismatchError | import("../tryout/runtime/verify.js").TryoutRuntimeBundleRendererMismatchError | import("../tryout/runtime/verify.js").TryoutRuntimeBundleSnapshotMismatchError | import("../tryout/runtime/verify.js").TryoutRuntimeBundleVerificationDecodeError, import("../signature/spec.js").ContentVerificationKeyResolver>;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
});
|