@nakafa/aksara-contracts 0.38.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 +10 -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/date.js +3 -5
- 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 +29 -2
- package/dist/renderer/selection.d.ts +0 -39
- package/dist/renderer/selection.js +0 -87
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
3
|
-
import {
|
|
3
|
+
import { RendererComponentsSchema, } from "#contracts/renderer/component";
|
|
4
4
|
import { RENDERER_DOMAINS, RendererDomainSchema, } from "#contracts/renderer/domain";
|
|
5
5
|
import { compareCodeUnits } from "#contracts/text/order";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const RENDERER_CONTRACT_VERSION = "1.0.0";
|
|
9
|
-
/** Stable wire format for a domain-scoped Nakafa renderer manifest. */
|
|
10
|
-
export const RENDERER_MANIFEST_FORMAT = "nakafa-mdx-renderer-v1";
|
|
11
|
-
/** Canonical semantic version carried by a renderer runtime boundary. */
|
|
12
|
-
export const RendererContractVersionSchema = Schema.String.pipe(Schema.check(Schema.isPattern(RENDERER_CONTRACT_VERSION_PATTERN)));
|
|
6
|
+
/** Stable format for the one current domain-scoped renderer manifest. */
|
|
7
|
+
export const RENDERER_MANIFEST_FORMAT = "nakafa-mdx-renderer";
|
|
13
8
|
/** One route-domain component contract with an exact real domain name. */
|
|
14
9
|
export const RendererDomainCapabilitySchema = Schema.Struct({
|
|
15
|
-
|
|
10
|
+
components: RendererComponentsSchema,
|
|
16
11
|
name: RendererDomainSchema,
|
|
17
|
-
|
|
18
|
-
}).pipe(Schema.check(Schema.makeFilter(hasCompleteRendererSelection, {
|
|
19
|
-
message: "Expected one supported authoring selection for every domain component.",
|
|
20
|
-
})));
|
|
12
|
+
});
|
|
21
13
|
/** Checks published route domains are unique and ordered by code unit. */
|
|
22
14
|
function hasCanonicalPublishedDomains(domains) {
|
|
23
15
|
const canonical = [...domains].sort(compareCodeUnits);
|
|
@@ -31,26 +23,16 @@ export const RendererPublishedDomainsSchema = Schema.Array(RendererDomainSchema)
|
|
|
31
23
|
export function sortRendererDomains(domains) {
|
|
32
24
|
return [...domains].sort((left, right) => compareCodeUnits(left.name, right.name));
|
|
33
25
|
}
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
const canonical = sortRendererDomains(domains);
|
|
37
|
-
return domains.every((domain, index) => domain.name === canonical[index]?.name &&
|
|
38
|
-
domain.name !== domains[index - 1]?.name);
|
|
39
|
-
}
|
|
40
|
-
/** Canonical persisted domains, including older known domain subsets. */
|
|
41
|
-
export const RendererManifestDomainsSchema = Schema.Array(RendererDomainCapabilitySchema).pipe(Schema.check(Schema.isMinLength(1)), Schema.check(Schema.makeFilter(hasCanonicalRendererDomains, {
|
|
42
|
-
message: "Expected unique renderer domains in canonical order.",
|
|
43
|
-
})));
|
|
44
|
-
/** Complete current domain set required from a newly created live manifest. */
|
|
45
|
-
export const LiveRendererManifestDomainsSchema = RendererManifestDomainsSchema.pipe(Schema.check(Schema.makeFilter((domains) => domains.length === RENDERER_DOMAINS.length &&
|
|
26
|
+
/** Complete current domain set shared by published and deployed manifests. */
|
|
27
|
+
export const RendererManifestDomainsSchema = Schema.Array(RendererDomainCapabilitySchema).check(Schema.makeFilter((domains) => domains.length === RENDERER_DOMAINS.length &&
|
|
46
28
|
domains.every(({ name }, index) => name === RENDERER_DOMAINS[index]), {
|
|
47
|
-
message: "Expected every
|
|
48
|
-
}))
|
|
29
|
+
message: "Expected every renderer domain exactly once in canonical order.",
|
|
30
|
+
}));
|
|
49
31
|
/** Keeps base component names out of every route-owned registry. */
|
|
50
32
|
function hasDistinctBaseComponents(manifest) {
|
|
51
|
-
const baseNames = new Set(manifest.base
|
|
33
|
+
const baseNames = new Set(manifest.base);
|
|
52
34
|
for (const domain of manifest.domains) {
|
|
53
|
-
for (const
|
|
35
|
+
for (const name of domain.components) {
|
|
54
36
|
if (baseNames.has(name)) {
|
|
55
37
|
return false;
|
|
56
38
|
}
|
|
@@ -58,22 +40,14 @@ function hasDistinctBaseComponents(manifest) {
|
|
|
58
40
|
}
|
|
59
41
|
return true;
|
|
60
42
|
}
|
|
61
|
-
/** Keeps published domains bound to capabilities in the same envelope. */
|
|
62
|
-
function hasPublishedDomainCapabilities(manifest) {
|
|
63
|
-
const capabilities = new Set(manifest.domains.map(({ name }) => name));
|
|
64
|
-
return manifest.publishedDomains.every((domain) => capabilities.has(domain));
|
|
65
|
-
}
|
|
66
43
|
/** Hash-authenticated renderer envelope persisted with one signed release. */
|
|
67
44
|
export const RendererManifestEnvelopeSchema = Schema.Struct({
|
|
68
|
-
base:
|
|
45
|
+
base: RendererComponentsSchema.check(Schema.isMinLength(1)),
|
|
69
46
|
domains: RendererManifestDomainsSchema,
|
|
70
47
|
format: Schema.Literal(RENDERER_MANIFEST_FORMAT),
|
|
71
48
|
hash: Sha256HashSchema,
|
|
72
49
|
publishedDomains: RendererPublishedDomainsSchema,
|
|
73
|
-
|
|
74
|
-
}).pipe(Schema.check(Schema.makeFilter(hasPublishedDomainCapabilities, {
|
|
75
|
-
message: "Expected every published renderer domain to have a capability.",
|
|
76
|
-
})), Schema.check(Schema.makeFilter(hasDistinctBaseComponents, {
|
|
50
|
+
}).pipe(Schema.check(Schema.makeFilter(hasDistinctBaseComponents, {
|
|
77
51
|
message: "Expected base and route-domain component names to be disjoint.",
|
|
78
52
|
})));
|
|
79
53
|
/** A persisted renderer envelope does not carry the requested domain. */
|
|
@@ -98,24 +72,12 @@ export class RendererManifestHashMismatchError extends Schema.TaggedError()("Ren
|
|
|
98
72
|
}
|
|
99
73
|
/** Serializes the exact domain-scoped renderer tuple covered by SHA-256. */
|
|
100
74
|
export function canonicalizeRendererManifestContract(input) {
|
|
101
|
-
/** Copies one registry capability into exact canonical wire fields. */
|
|
102
|
-
const capability = (value) => ({
|
|
103
|
-
authoringComponents: value.authoringComponents.map(({ name, version }) => ({
|
|
104
|
-
name,
|
|
105
|
-
version,
|
|
106
|
-
})),
|
|
107
|
-
supportedComponents: value.supportedComponents.map(({ name, version }) => ({
|
|
108
|
-
name,
|
|
109
|
-
version,
|
|
110
|
-
})),
|
|
111
|
-
});
|
|
112
75
|
return JSON.stringify([
|
|
113
76
|
RENDERER_MANIFEST_FORMAT,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
77
|
+
input.base,
|
|
78
|
+
sortRendererDomains(input.domains).map(({ name, components }) => ({
|
|
79
|
+
components,
|
|
117
80
|
name,
|
|
118
|
-
...capability(domain),
|
|
119
81
|
})),
|
|
120
82
|
input.publishedDomains,
|
|
121
83
|
]);
|
|
@@ -1,86 +1,24 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { RendererManifestHashComputeError, RendererManifestHashMismatchError } from "#contracts/renderer/contract";
|
|
3
|
-
/** Creates a
|
|
3
|
+
/** Creates a complete authenticated manifest from one current name set. */
|
|
4
4
|
export declare const createRendererManifest: (input: unknown) => Effect.Effect<{
|
|
5
|
-
readonly base:
|
|
6
|
-
readonly authoringComponents: readonly {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly version: number;
|
|
9
|
-
}[];
|
|
10
|
-
readonly supportedComponents: readonly {
|
|
11
|
-
readonly name: string;
|
|
12
|
-
readonly version: number;
|
|
13
|
-
}[];
|
|
14
|
-
};
|
|
5
|
+
readonly base: readonly string[];
|
|
15
6
|
readonly domains: readonly {
|
|
16
|
-
readonly
|
|
17
|
-
readonly name: string;
|
|
18
|
-
readonly version: number;
|
|
19
|
-
}[];
|
|
7
|
+
readonly components: readonly string[];
|
|
20
8
|
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
21
|
-
readonly supportedComponents: readonly {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly version: number;
|
|
24
|
-
}[];
|
|
25
9
|
}[];
|
|
26
|
-
readonly format: "nakafa-mdx-renderer
|
|
10
|
+
readonly format: "nakafa-mdx-renderer";
|
|
27
11
|
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
28
12
|
readonly publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/** Verifies one persisted envelope, including a known historical domain subset. */
|
|
13
|
+
}, import("../errors.js").ContractDecodeError | RendererManifestHashComputeError, never>;
|
|
14
|
+
/** Authenticates the complete current renderer contract without normalization. */
|
|
32
15
|
export declare const validateRendererManifestHash: (input: unknown) => Effect.Effect<{
|
|
33
|
-
readonly base:
|
|
34
|
-
readonly authoringComponents: readonly {
|
|
35
|
-
readonly name: string;
|
|
36
|
-
readonly version: number;
|
|
37
|
-
}[];
|
|
38
|
-
readonly supportedComponents: readonly {
|
|
39
|
-
readonly name: string;
|
|
40
|
-
readonly version: number;
|
|
41
|
-
}[];
|
|
42
|
-
};
|
|
16
|
+
readonly base: readonly string[];
|
|
43
17
|
readonly domains: readonly {
|
|
44
|
-
readonly
|
|
45
|
-
readonly name: string;
|
|
46
|
-
readonly version: number;
|
|
47
|
-
}[];
|
|
18
|
+
readonly components: readonly string[];
|
|
48
19
|
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
49
|
-
readonly supportedComponents: readonly {
|
|
50
|
-
readonly name: string;
|
|
51
|
-
readonly version: number;
|
|
52
|
-
}[];
|
|
53
20
|
}[];
|
|
54
|
-
readonly format: "nakafa-mdx-renderer
|
|
21
|
+
readonly format: "nakafa-mdx-renderer";
|
|
55
22
|
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
56
23
|
readonly publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
57
|
-
|
|
58
|
-
}, import("../errors.js").ContractDecodeError | import("#contracts/renderer/component").RendererAuthoringComponentDuplicateError | import("#contracts/renderer/component").RendererAuthoringComponentExtraError | import("#contracts/renderer/component").RendererAuthoringComponentMissingError | import("#contracts/renderer/component").RendererAuthoringComponentUnsupportedError | import("#contracts/renderer/component").RendererAuthoringSelectionNonCanonicalError | RendererManifestHashComputeError | RendererManifestHashMismatchError, never>;
|
|
59
|
-
/** Verifies one complete manifest supplied by a current live renderer. */
|
|
60
|
-
export declare const validateLiveRendererManifestHash: (input: unknown) => Effect.Effect<{
|
|
61
|
-
base: {
|
|
62
|
-
readonly authoringComponents: readonly {
|
|
63
|
-
readonly name: string;
|
|
64
|
-
readonly version: number;
|
|
65
|
-
}[];
|
|
66
|
-
readonly supportedComponents: readonly {
|
|
67
|
-
readonly name: string;
|
|
68
|
-
readonly version: number;
|
|
69
|
-
}[];
|
|
70
|
-
};
|
|
71
|
-
format: "nakafa-mdx-renderer-v1";
|
|
72
|
-
hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
73
|
-
publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
74
|
-
rendererContractVersion: "1.0.0";
|
|
75
|
-
domains: readonly {
|
|
76
|
-
readonly authoringComponents: readonly {
|
|
77
|
-
readonly name: string;
|
|
78
|
-
readonly version: number;
|
|
79
|
-
}[];
|
|
80
|
-
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
81
|
-
readonly supportedComponents: readonly {
|
|
82
|
-
readonly name: string;
|
|
83
|
-
readonly version: number;
|
|
84
|
-
}[];
|
|
85
|
-
}[];
|
|
86
|
-
}, import("../errors.js").ContractDecodeError | import("#contracts/renderer/component").RendererAuthoringComponentDuplicateError | import("#contracts/renderer/component").RendererAuthoringComponentExtraError | import("#contracts/renderer/component").RendererAuthoringComponentMissingError | import("#contracts/renderer/component").RendererAuthoringComponentUnsupportedError | import("#contracts/renderer/component").RendererAuthoringSelectionNonCanonicalError | RendererManifestHashComputeError | RendererManifestHashMismatchError, never>;
|
|
24
|
+
}, import("../errors.js").ContractDecodeError | RendererManifestHashComputeError | RendererManifestHashMismatchError, never>;
|
|
@@ -1,49 +1,48 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { decodeContract } from "#contracts/decode";
|
|
3
3
|
import { hashText } from "#contracts/hash/text";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { RendererDomainSchema, } from "#contracts/renderer/domain";
|
|
8
|
-
import { normalizeRendererSelection } from "#contracts/renderer/selection";
|
|
4
|
+
import { RendererComponentNameSchema, sortRendererComponents, } from "#contracts/renderer/component";
|
|
5
|
+
import { canonicalizeRendererManifestContract, RENDERER_MANIFEST_FORMAT, RendererManifestDomainsSchema, RendererManifestEnvelopeSchema, RendererManifestHashComputeError, RendererManifestHashMismatchError, sortRendererDomains, } from "#contracts/renderer/contract";
|
|
6
|
+
import { RendererDomainSchema } from "#contracts/renderer/domain";
|
|
9
7
|
import { compareCodeUnits } from "#contracts/text/order";
|
|
10
|
-
const CapabilityCreationFields = {
|
|
11
|
-
authoringComponents: Schema.Array(RendererComponentRequirementSchema),
|
|
12
|
-
supportedComponents: Schema.Array(RendererComponentRequirementSchema),
|
|
13
|
-
};
|
|
14
8
|
const RendererManifestCreationSchema = Schema.Struct({
|
|
15
|
-
base: Schema.
|
|
16
|
-
domains: Schema.Array(Schema.Struct({
|
|
9
|
+
base: Schema.Array(RendererComponentNameSchema),
|
|
10
|
+
domains: Schema.Array(Schema.Struct({
|
|
11
|
+
components: Schema.Array(RendererComponentNameSchema),
|
|
12
|
+
name: RendererDomainSchema,
|
|
13
|
+
})),
|
|
17
14
|
publishedDomains: Schema.Array(RendererDomainSchema),
|
|
18
15
|
});
|
|
19
|
-
|
|
20
|
-
...RendererManifestCreationSchema.fields,
|
|
21
|
-
format: Schema.Literal(RENDERER_MANIFEST_FORMAT),
|
|
22
|
-
hash: Sha256HashSchema,
|
|
23
|
-
rendererContractVersion: Schema.Literal(RENDERER_CONTRACT_VERSION),
|
|
24
|
-
});
|
|
25
|
-
/** Sorts and decodes the exact route domains exposed by the deployed app. */
|
|
26
|
-
const normalizePublishedDomains = Effect.fn("AksaraContracts.normalizePublishedDomains")((domains) => decodeContract(RendererPublishedDomainsSchema, "RendererPublishedDomains", [...domains].sort(compareCodeUnits)));
|
|
27
|
-
/** Hashes the canonical base and domain-scoped renderer contract. */
|
|
16
|
+
/** Hashes the canonical current names and their physical domain ownership. */
|
|
28
17
|
const hashRendererContract = Effect.fn("AksaraContracts.hashRendererContract")((input) => hashText(canonicalizeRendererManifestContract(input)).pipe(Effect.mapError(({ cause }) => new RendererManifestHashComputeError({ cause }))));
|
|
29
|
-
/** Creates a
|
|
30
|
-
export const createRendererManifest = Effect.fn("AksaraContracts.createRendererManifest")(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
/**
|
|
49
|
-
export const
|
|
18
|
+
/** Creates a complete authenticated manifest from one current name set. */
|
|
19
|
+
export const createRendererManifest = Effect.fn("AksaraContracts.createRendererManifest")(function* (input) {
|
|
20
|
+
const wire = yield* decodeContract(RendererManifestCreationSchema, "RendererManifestCreation", input);
|
|
21
|
+
const domains = yield* decodeContract(RendererManifestDomainsSchema, "RendererManifestDomains", sortRendererDomains(wire.domains.map(({ name, components }) => ({
|
|
22
|
+
components: sortRendererComponents(components),
|
|
23
|
+
name,
|
|
24
|
+
}))));
|
|
25
|
+
const contract = {
|
|
26
|
+
base: sortRendererComponents(wire.base),
|
|
27
|
+
domains,
|
|
28
|
+
publishedDomains: [...wire.publishedDomains].sort(compareCodeUnits),
|
|
29
|
+
};
|
|
30
|
+
const hash = yield* hashRendererContract(contract);
|
|
31
|
+
return yield* decodeContract(RendererManifestEnvelopeSchema, "RendererManifestEnvelope", {
|
|
32
|
+
...contract,
|
|
33
|
+
format: RENDERER_MANIFEST_FORMAT,
|
|
34
|
+
hash,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
/** Authenticates the complete current renderer contract without normalization. */
|
|
38
|
+
export const validateRendererManifestHash = Effect.fn("AksaraContracts.validateRendererManifestHash")(function* (input) {
|
|
39
|
+
const manifest = yield* decodeContract(RendererManifestEnvelopeSchema, "RendererManifestEnvelope", input);
|
|
40
|
+
const actualHash = yield* hashRendererContract(manifest);
|
|
41
|
+
if (actualHash !== manifest.hash) {
|
|
42
|
+
return yield* new RendererManifestHashMismatchError({
|
|
43
|
+
actualHash,
|
|
44
|
+
expectedHash: manifest.hash,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return manifest;
|
|
48
|
+
});
|
|
@@ -34,10 +34,7 @@ export declare const ProtectedContentRuntimeItemSchema: Schema.Struct<{
|
|
|
34
34
|
readonly plainText: Schema.String;
|
|
35
35
|
readonly rawMdx: Schema.String;
|
|
36
36
|
readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
|
37
|
-
readonly requiredComponents: Schema.$Array<Schema.
|
|
38
|
-
readonly name: Schema.String;
|
|
39
|
-
readonly version: Schema.Finite;
|
|
40
|
-
}>>;
|
|
37
|
+
readonly requiredComponents: Schema.$Array<Schema.String>;
|
|
41
38
|
readonly sourceHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
42
39
|
}>;
|
|
43
40
|
readonly signature: Schema.brand<Schema.String, "@NakafaAI/AksaraEd25519Signature">;
|
|
@@ -92,10 +89,7 @@ export declare const ProtectedContentRuntimeFoundSchema: Schema.Struct<{
|
|
|
92
89
|
readonly plainText: Schema.String;
|
|
93
90
|
readonly rawMdx: Schema.String;
|
|
94
91
|
readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
|
95
|
-
readonly requiredComponents: Schema.$Array<Schema.
|
|
96
|
-
readonly name: Schema.String;
|
|
97
|
-
readonly version: Schema.Finite;
|
|
98
|
-
}>>;
|
|
92
|
+
readonly requiredComponents: Schema.$Array<Schema.String>;
|
|
99
93
|
readonly sourceHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
100
94
|
}>;
|
|
101
95
|
readonly signature: Schema.brand<Schema.String, "@NakafaAI/AksaraEd25519Signature">;
|
|
@@ -105,31 +99,14 @@ export declare const ProtectedContentRuntimeFoundSchema: Schema.Struct<{
|
|
|
105
99
|
}>>;
|
|
106
100
|
readonly kind: Schema.Literal<"found">;
|
|
107
101
|
readonly rendererManifest: Schema.Struct<{
|
|
108
|
-
readonly base: Schema.
|
|
109
|
-
authoringComponents: Schema.$Array<Schema.Struct<{
|
|
110
|
-
readonly name: Schema.String;
|
|
111
|
-
readonly version: Schema.Finite;
|
|
112
|
-
}>>;
|
|
113
|
-
supportedComponents: Schema.$Array<Schema.Struct<{
|
|
114
|
-
readonly name: Schema.String;
|
|
115
|
-
readonly version: Schema.Finite;
|
|
116
|
-
}>>;
|
|
117
|
-
}>;
|
|
102
|
+
readonly base: Schema.$Array<Schema.String>;
|
|
118
103
|
readonly domains: Schema.$Array<Schema.Struct<{
|
|
119
|
-
readonly
|
|
120
|
-
readonly name: Schema.String;
|
|
121
|
-
readonly version: Schema.Finite;
|
|
122
|
-
}>>;
|
|
104
|
+
readonly components: Schema.$Array<Schema.String>;
|
|
123
105
|
readonly name: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
|
124
|
-
readonly supportedComponents: Schema.$Array<Schema.Struct<{
|
|
125
|
-
readonly name: Schema.String;
|
|
126
|
-
readonly version: Schema.Finite;
|
|
127
|
-
}>>;
|
|
128
106
|
}>>;
|
|
129
|
-
readonly format: Schema.Literal<"nakafa-mdx-renderer
|
|
107
|
+
readonly format: Schema.Literal<"nakafa-mdx-renderer">;
|
|
130
108
|
readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
131
109
|
readonly publishedDomains: Schema.$Array<Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>>;
|
|
132
|
-
readonly rendererContractVersion: Schema.Literal<"1.0.0">;
|
|
133
110
|
}>;
|
|
134
111
|
}>;
|
|
135
112
|
export type ProtectedContentRuntimeFound = typeof ProtectedContentRuntimeFoundSchema.Type;
|
|
@@ -179,10 +156,7 @@ export declare const ProtectedContentRuntimeResponseSchema: Schema.Union<readonl
|
|
|
179
156
|
readonly plainText: Schema.String;
|
|
180
157
|
readonly rawMdx: Schema.String;
|
|
181
158
|
readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
|
182
|
-
readonly requiredComponents: Schema.$Array<Schema.
|
|
183
|
-
readonly name: Schema.String;
|
|
184
|
-
readonly version: Schema.Finite;
|
|
185
|
-
}>>;
|
|
159
|
+
readonly requiredComponents: Schema.$Array<Schema.String>;
|
|
186
160
|
readonly sourceHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
187
161
|
}>;
|
|
188
162
|
readonly signature: Schema.brand<Schema.String, "@NakafaAI/AksaraEd25519Signature">;
|
|
@@ -192,31 +166,14 @@ export declare const ProtectedContentRuntimeResponseSchema: Schema.Union<readonl
|
|
|
192
166
|
}>>;
|
|
193
167
|
readonly kind: Schema.Literal<"found">;
|
|
194
168
|
readonly rendererManifest: Schema.Struct<{
|
|
195
|
-
readonly base: Schema.
|
|
196
|
-
authoringComponents: Schema.$Array<Schema.Struct<{
|
|
197
|
-
readonly name: Schema.String;
|
|
198
|
-
readonly version: Schema.Finite;
|
|
199
|
-
}>>;
|
|
200
|
-
supportedComponents: Schema.$Array<Schema.Struct<{
|
|
201
|
-
readonly name: Schema.String;
|
|
202
|
-
readonly version: Schema.Finite;
|
|
203
|
-
}>>;
|
|
204
|
-
}>;
|
|
169
|
+
readonly base: Schema.$Array<Schema.String>;
|
|
205
170
|
readonly domains: Schema.$Array<Schema.Struct<{
|
|
206
|
-
readonly
|
|
207
|
-
readonly name: Schema.String;
|
|
208
|
-
readonly version: Schema.Finite;
|
|
209
|
-
}>>;
|
|
171
|
+
readonly components: Schema.$Array<Schema.String>;
|
|
210
172
|
readonly name: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
|
211
|
-
readonly supportedComponents: Schema.$Array<Schema.Struct<{
|
|
212
|
-
readonly name: Schema.String;
|
|
213
|
-
readonly version: Schema.Finite;
|
|
214
|
-
}>>;
|
|
215
173
|
}>>;
|
|
216
|
-
readonly format: Schema.Literal<"nakafa-mdx-renderer
|
|
174
|
+
readonly format: Schema.Literal<"nakafa-mdx-renderer">;
|
|
217
175
|
readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
218
176
|
readonly publishedDomains: Schema.$Array<Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>>;
|
|
219
|
-
readonly rendererContractVersion: Schema.Literal<"1.0.0">;
|
|
220
177
|
}>;
|
|
221
178
|
}>, Schema.Struct<{
|
|
222
179
|
readonly kind: Schema.Literal<"missing">;
|
|
@@ -281,10 +238,7 @@ export declare const decodeProtectedContentRuntimeResponse: (input: unknown) =>
|
|
|
281
238
|
readonly plainText: string;
|
|
282
239
|
readonly rawMdx: string;
|
|
283
240
|
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
284
|
-
readonly requiredComponents: readonly
|
|
285
|
-
readonly name: string;
|
|
286
|
-
readonly version: number;
|
|
287
|
-
}[];
|
|
241
|
+
readonly requiredComponents: readonly string[];
|
|
288
242
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
289
243
|
};
|
|
290
244
|
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
@@ -294,31 +248,14 @@ export declare const decodeProtectedContentRuntimeResponse: (input: unknown) =>
|
|
|
294
248
|
}[];
|
|
295
249
|
readonly kind: "found";
|
|
296
250
|
readonly rendererManifest: {
|
|
297
|
-
readonly base:
|
|
298
|
-
readonly authoringComponents: readonly {
|
|
299
|
-
readonly name: string;
|
|
300
|
-
readonly version: number;
|
|
301
|
-
}[];
|
|
302
|
-
readonly supportedComponents: readonly {
|
|
303
|
-
readonly name: string;
|
|
304
|
-
readonly version: number;
|
|
305
|
-
}[];
|
|
306
|
-
};
|
|
251
|
+
readonly base: readonly string[];
|
|
307
252
|
readonly domains: readonly {
|
|
308
|
-
readonly
|
|
309
|
-
readonly name: string;
|
|
310
|
-
readonly version: number;
|
|
311
|
-
}[];
|
|
253
|
+
readonly components: readonly string[];
|
|
312
254
|
readonly name: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
313
|
-
readonly supportedComponents: readonly {
|
|
314
|
-
readonly name: string;
|
|
315
|
-
readonly version: number;
|
|
316
|
-
}[];
|
|
317
255
|
}[];
|
|
318
|
-
readonly format: "nakafa-mdx-renderer
|
|
256
|
+
readonly format: "nakafa-mdx-renderer";
|
|
319
257
|
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
320
258
|
readonly publishedDomains: readonly ("ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math")[];
|
|
321
|
-
readonly rendererContractVersion: "1.0.0";
|
|
322
259
|
};
|
|
323
260
|
} | {
|
|
324
261
|
readonly kind: "missing";
|
|
@@ -50,10 +50,7 @@ export declare const verifyProtectedContentRuntimeExchange: (input: {
|
|
|
50
50
|
readonly plainText: string;
|
|
51
51
|
readonly rawMdx: string;
|
|
52
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
|
-
}[];
|
|
53
|
+
readonly requiredComponents: readonly string[];
|
|
57
54
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
58
55
|
};
|
|
59
56
|
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
@@ -63,35 +60,18 @@ export declare const verifyProtectedContentRuntimeExchange: (input: {
|
|
|
63
60
|
}[];
|
|
64
61
|
readonly kind: "found";
|
|
65
62
|
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
|
-
};
|
|
63
|
+
readonly base: readonly string[];
|
|
76
64
|
readonly domains: readonly {
|
|
77
|
-
readonly
|
|
78
|
-
readonly name: string;
|
|
79
|
-
readonly version: number;
|
|
80
|
-
}[];
|
|
65
|
+
readonly components: readonly string[];
|
|
81
66
|
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
67
|
}[];
|
|
87
|
-
readonly format: "nakafa-mdx-renderer
|
|
68
|
+
readonly format: "nakafa-mdx-renderer";
|
|
88
69
|
readonly hash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
89
70
|
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
71
|
};
|
|
92
72
|
} | {
|
|
93
73
|
readonly kind: "missing";
|
|
94
74
|
} | {
|
|
95
75
|
readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
|
|
96
76
|
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").
|
|
77
|
+
}, 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("#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>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Array as ReadonlyArray } from "effect";
|
|
2
2
|
import { verifySignedContentArtifact } from "#contracts/artifact/verify";
|
|
3
3
|
import { verifyContentRendererCompatibility } from "#contracts/renderer/compatibility";
|
|
4
|
-
import {
|
|
4
|
+
import { validateRendererManifestHash } from "#contracts/renderer/manifest";
|
|
5
5
|
import { ContentRuntimeMismatchError } from "#contracts/runtime/error";
|
|
6
6
|
import { decodeProtectedContentRuntimeRequest, decodeProtectedContentRuntimeResponse, } from "#contracts/runtime/protected/spec";
|
|
7
7
|
import { verifySignedTryoutRuntimeBundle } from "#contracts/tryout/runtime/verify";
|
|
@@ -29,13 +29,11 @@ const verifyProtectedItem = Effect.fn("AksaraContracts.verifyProtectedRuntimeIte
|
|
|
29
29
|
}
|
|
30
30
|
const artifact = yield* verifySignedContentArtifact({
|
|
31
31
|
artifact: item.artifact,
|
|
32
|
-
rendererContractVersion: bundleRenderer.rendererContractVersion,
|
|
33
32
|
rendererManifest: bundleRenderer,
|
|
34
33
|
});
|
|
35
34
|
if (liveRenderer.hash !== bundle.payload.rendererManifestHash) {
|
|
36
35
|
yield* verifyContentRendererCompatibility({
|
|
37
36
|
payload: artifact.payload,
|
|
38
|
-
rendererContractVersion: bundleRenderer.rendererContractVersion,
|
|
39
37
|
rendererManifest: liveRenderer,
|
|
40
38
|
});
|
|
41
39
|
}
|
|
@@ -65,7 +63,7 @@ export const verifyProtectedContentRuntimeExchange = Effect.fn("AksaraContracts.
|
|
|
65
63
|
bundle: response.bundle,
|
|
66
64
|
rendererManifest: response.rendererManifest,
|
|
67
65
|
});
|
|
68
|
-
const liveRenderer = yield*
|
|
66
|
+
const liveRenderer = yield* validateRendererManifestHash(input.rendererManifest);
|
|
69
67
|
yield* verifyProtectedBundle(request, bundle);
|
|
70
68
|
yield* Effect.forEach(ReadonlyArray.zip(request.selectors, response.items), ([selector, item]) => verifyProtectedItem(selector, item, bundle, response.rendererManifest, liveRenderer), { concurrency: "unbounded", discard: true });
|
|
71
69
|
return response;
|