@nakafa/aksara-contracts 0.51.0 → 1.0.1
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 +207 -152
- package/README.md +13 -10
- package/dist/artifact/integrity.d.ts +22 -10
- package/dist/artifact/integrity.js +16 -2
- package/dist/artifact/limits.d.ts +13 -7
- package/dist/artifact/limits.js +5 -12
- package/dist/artifact/source.d.ts +10 -4
- package/dist/artifact/spec.d.ts +27 -15
- package/dist/artifact/spec.js +7 -8
- package/dist/artifact/verify.d.ts +11 -5
- package/dist/content.d.ts +37 -11
- package/dist/content.js +7 -21
- package/dist/limits.d.ts +2 -2
- package/dist/limits.js +2 -2
- package/dist/release/rollback/spec.d.ts +102 -24
- package/dist/runtime/protected/spec.d.ts +61 -16
- package/dist/runtime/protected/verify.d.ts +11 -5
- package/dist/runtime/spec.d.ts +44 -12
- package/dist/runtime/verify.d.ts +22 -10
- package/dist/signature/trusted.d.ts +4 -1
- package/dist/signature/trusted.js +4 -1
- package/dist/transport/batch.d.ts +34 -8
- package/dist/transport/group.d.ts +51 -12
- package/dist/transport/request.d.ts +94 -32
- package/dist/transport/response.d.ts +122 -32
- package/dist/tree.d.ts +52 -0
- package/dist/tree.js +162 -0
- package/package.json +5 -1
package/dist/artifact/limits.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { ArtifactPayloadFieldByteLimitError, ArtifactVerificationByteLimitError, } from "#contracts/artifact/spec";
|
|
3
3
|
import { canonicalizeCompiledContentPayload, canonicalizeSignedContentArtifact, } from "#contracts/content";
|
|
4
|
-
import { MAX_CANONICAL_PAYLOAD_BYTES,
|
|
4
|
+
import { MAX_CANONICAL_PAYLOAD_BYTES, MAX_CONTENT_TREE_BYTES, MAX_PLAIN_TEXT_BYTES, MAX_RAW_MDX_BYTES, MAX_SIGNED_ARTIFACT_BYTES, } from "#contracts/limits";
|
|
5
|
+
import { canonicalizeContentTree } from "#contracts/tree";
|
|
5
6
|
/** Rejects a complete signed artifact envelope above its wire ceiling. */
|
|
6
7
|
function enforceSignedWireLimit(artifact) {
|
|
7
8
|
const actualBytes = new TextEncoder().encode(canonicalizeSignedContentArtifact(artifact)).byteLength;
|
|
@@ -26,20 +27,12 @@ function enforcePayloadFieldLimit(payload, field, value, maxBytes) {
|
|
|
26
27
|
maxBytes,
|
|
27
28
|
}));
|
|
28
29
|
}
|
|
29
|
-
/** Verifies complete wire
|
|
30
|
+
/** Verifies the complete wire and every bounded payload field. */
|
|
30
31
|
export const validateArtifactByteIntegrity = Effect.fn("AksaraContracts.validateArtifactByteIntegrity")(function* (artifact) {
|
|
31
32
|
yield* enforceSignedWireLimit(artifact);
|
|
32
33
|
const { payload } = artifact;
|
|
33
|
-
const compiledBytes = new TextEncoder().encode(payload.compiledCode).byteLength;
|
|
34
|
-
if (payload.byteLength !== compiledBytes) {
|
|
35
|
-
return yield* new ArtifactCompiledByteLengthMismatchError({
|
|
36
|
-
actualBytes: compiledBytes,
|
|
37
|
-
contentKey: payload.contentKey,
|
|
38
|
-
declaredBytes: payload.byteLength,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
34
|
yield* enforcePayloadFieldLimit(payload, "rawMdx", payload.rawMdx, MAX_RAW_MDX_BYTES);
|
|
42
|
-
yield* enforcePayloadFieldLimit(payload, "
|
|
35
|
+
yield* enforcePayloadFieldLimit(payload, "contentTree", canonicalizeContentTree(payload.contentTree), MAX_CONTENT_TREE_BYTES);
|
|
43
36
|
yield* enforcePayloadFieldLimit(payload, "plainText", payload.plainText, MAX_PLAIN_TEXT_BYTES);
|
|
44
37
|
yield* enforcePayloadFieldLimit(payload, "canonicalPayload", canonicalizeCompiledContentPayload(payload), MAX_CANONICAL_PAYLOAD_BYTES);
|
|
45
38
|
});
|
|
@@ -3,12 +3,18 @@ import { ArtifactSourceHashComputationError, ArtifactSourceHashMismatchError } f
|
|
|
3
3
|
/** Verifies that sourceHash identifies the complete authenticated raw MDX. */
|
|
4
4
|
export declare const verifyCompiledContentSourceHash: (payload: {
|
|
5
5
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
6
|
-
readonly byteLength: number;
|
|
7
|
-
readonly compiledCode: string;
|
|
8
6
|
readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
9
|
-
readonly compilerVersion: "0.
|
|
7
|
+
readonly compilerVersion: "0.2.0";
|
|
10
8
|
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
11
|
-
readonly
|
|
9
|
+
readonly contentTree: {
|
|
10
|
+
readonly $node: "element";
|
|
11
|
+
readonly children: readonly import("../tree.js").ContentTreeChild[];
|
|
12
|
+
readonly name: import("../tree.js").ContentTreeElementName;
|
|
13
|
+
readonly props: {
|
|
14
|
+
readonly [key: string]: import("../tree.js").ContentTreeValue;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly format: "content-tree";
|
|
12
18
|
readonly mdxCompilerVersion: "3.1.1";
|
|
13
19
|
readonly plainText: string;
|
|
14
20
|
readonly rawMdx: string;
|
package/dist/artifact/spec.d.ts
CHANGED
|
@@ -6,12 +6,25 @@ export declare const ArtifactVerificationRequestSchema: Schema.Struct<{
|
|
|
6
6
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
7
7
|
readonly payload: Schema.Struct<{
|
|
8
8
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
9
|
-
readonly byteLength: Schema.Finite;
|
|
10
|
-
readonly compiledCode: Schema.String;
|
|
11
9
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
12
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
10
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
13
11
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
14
|
-
readonly
|
|
12
|
+
readonly contentTree: Schema.Codec<{
|
|
13
|
+
readonly $node: "element";
|
|
14
|
+
readonly children: readonly import("../tree.js").ContentTreeChild[];
|
|
15
|
+
readonly name: import("../tree.js").ContentTreeElementName;
|
|
16
|
+
readonly props: {
|
|
17
|
+
readonly [key: string]: import("../tree.js").ContentTreeValue;
|
|
18
|
+
};
|
|
19
|
+
}, {
|
|
20
|
+
readonly $node: "element";
|
|
21
|
+
readonly children: readonly import("../tree.js").ContentTreeChild[];
|
|
22
|
+
readonly name: import("../tree.js").ContentTreeElementName;
|
|
23
|
+
readonly props: {
|
|
24
|
+
readonly [key: string]: import("../tree.js").ContentTreeValue;
|
|
25
|
+
};
|
|
26
|
+
}, never, never>;
|
|
27
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
15
28
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
16
29
|
readonly plainText: Schema.String;
|
|
17
30
|
readonly rawMdx: Schema.String;
|
|
@@ -50,20 +63,10 @@ declare const ArtifactVerificationByteLimitError_base: Schema.Class<ArtifactVeri
|
|
|
50
63
|
/** A signed artifact exceeded the canonical UTF-8 wire ceiling. */
|
|
51
64
|
export declare class ArtifactVerificationByteLimitError extends ArtifactVerificationByteLimitError_base {
|
|
52
65
|
}
|
|
53
|
-
declare const ArtifactCompiledByteLengthMismatchError_base: Schema.Class<ArtifactCompiledByteLengthMismatchError, Schema.TaggedStruct<"ArtifactCompiledByteLengthMismatchError", {
|
|
54
|
-
readonly actualBytes: Schema.Finite;
|
|
55
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
56
|
-
readonly declaredBytes: Schema.Finite;
|
|
57
|
-
}>, import("effect/Cause").YieldableError & {
|
|
58
|
-
readonly brand: unique symbol;
|
|
59
|
-
}>;
|
|
60
|
-
/** Declared compiled bytes differ from the authenticated function body. */
|
|
61
|
-
export declare class ArtifactCompiledByteLengthMismatchError extends ArtifactCompiledByteLengthMismatchError_base {
|
|
62
|
-
}
|
|
63
66
|
declare const ArtifactPayloadFieldByteLimitError_base: Schema.Class<ArtifactPayloadFieldByteLimitError, Schema.TaggedStruct<"ArtifactPayloadFieldByteLimitError", {
|
|
64
67
|
readonly actualBytes: Schema.Finite;
|
|
65
68
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
66
|
-
readonly field: Schema.Literals<readonly ["rawMdx", "
|
|
69
|
+
readonly field: Schema.Literals<readonly ["rawMdx", "contentTree", "plainText", "canonicalPayload"]>;
|
|
67
70
|
readonly maxBytes: Schema.Finite;
|
|
68
71
|
}>, import("effect/Cause").YieldableError & {
|
|
69
72
|
readonly brand: unique symbol;
|
|
@@ -116,6 +119,15 @@ declare const ArtifactRendererComponentMissingError_base: Schema.Class<ArtifactR
|
|
|
116
119
|
/** A custom component required by the artifact is absent from the renderer. */
|
|
117
120
|
export declare class ArtifactRendererComponentMissingError extends ArtifactRendererComponentMissingError_base {
|
|
118
121
|
}
|
|
122
|
+
declare const ArtifactTreeComponentUnlistedError_base: Schema.Class<ArtifactTreeComponentUnlistedError, Schema.TaggedStruct<"ArtifactTreeComponentUnlistedError", {
|
|
123
|
+
readonly componentName: Schema.String;
|
|
124
|
+
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
125
|
+
}>, import("effect/Cause").YieldableError & {
|
|
126
|
+
readonly brand: unique symbol;
|
|
127
|
+
}>;
|
|
128
|
+
/** The content tree uses a component that the artifact does not declare as required. */
|
|
129
|
+
export declare class ArtifactTreeComponentUnlistedError extends ArtifactTreeComponentUnlistedError_base {
|
|
130
|
+
}
|
|
119
131
|
declare const ArtifactRendererDomainUnpublishedError_base: Schema.Class<ArtifactRendererDomainUnpublishedError, Schema.TaggedStruct<"ArtifactRendererDomainUnpublishedError", {
|
|
120
132
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
121
133
|
readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
package/dist/artifact/spec.js
CHANGED
|
@@ -20,20 +20,13 @@ export class ArtifactVerificationByteLimitError extends Schema.TaggedError()("Ar
|
|
|
20
20
|
maxBytes: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThan(0))),
|
|
21
21
|
}) {
|
|
22
22
|
}
|
|
23
|
-
/** Declared compiled bytes differ from the authenticated function body. */
|
|
24
|
-
export class ArtifactCompiledByteLengthMismatchError extends Schema.TaggedError()("ArtifactCompiledByteLengthMismatchError", {
|
|
25
|
-
actualBytes: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
26
|
-
contentKey: ContentKeySchema,
|
|
27
|
-
declaredBytes: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
28
|
-
}) {
|
|
29
|
-
}
|
|
30
23
|
/** One authenticated payload field exceeded its shared runtime ceiling. */
|
|
31
24
|
export class ArtifactPayloadFieldByteLimitError extends Schema.TaggedError()("ArtifactPayloadFieldByteLimitError", {
|
|
32
25
|
actualBytes: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
33
26
|
contentKey: ContentKeySchema,
|
|
34
27
|
field: Schema.Literals([
|
|
35
28
|
"rawMdx",
|
|
36
|
-
"
|
|
29
|
+
"contentTree",
|
|
37
30
|
"plainText",
|
|
38
31
|
"canonicalPayload",
|
|
39
32
|
]),
|
|
@@ -64,6 +57,12 @@ export class ArtifactRendererComponentMissingError extends Schema.TaggedError()(
|
|
|
64
57
|
contentKey: ContentKeySchema,
|
|
65
58
|
}) {
|
|
66
59
|
}
|
|
60
|
+
/** The content tree uses a component that the artifact does not declare as required. */
|
|
61
|
+
export class ArtifactTreeComponentUnlistedError extends Schema.TaggedError()("ArtifactTreeComponentUnlistedError", {
|
|
62
|
+
componentName: Schema.String.check(Schema.isNonEmpty()),
|
|
63
|
+
contentKey: ContentKeySchema,
|
|
64
|
+
}) {
|
|
65
|
+
}
|
|
67
66
|
/** The deployed Nakafa app cannot route this artifact's renderer domain. */
|
|
68
67
|
export class ArtifactRendererDomainUnpublishedError extends Schema.TaggedError()("ArtifactRendererDomainUnpublishedError", {
|
|
69
68
|
contentKey: ContentKeySchema,
|
|
@@ -6,12 +6,18 @@ export declare const verifySignedContentArtifact: (input: unknown) => Effect.Eff
|
|
|
6
6
|
readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
|
|
7
7
|
readonly payload: {
|
|
8
8
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
9
|
-
readonly byteLength: number;
|
|
10
|
-
readonly compiledCode: string;
|
|
11
9
|
readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
12
|
-
readonly compilerVersion: "0.
|
|
10
|
+
readonly compilerVersion: "0.2.0";
|
|
13
11
|
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
14
|
-
readonly
|
|
12
|
+
readonly contentTree: {
|
|
13
|
+
readonly $node: "element";
|
|
14
|
+
readonly children: readonly import("../tree.js").ContentTreeChild[];
|
|
15
|
+
readonly name: import("../tree.js").ContentTreeElementName;
|
|
16
|
+
readonly props: {
|
|
17
|
+
readonly [key: string]: import("../tree.js").ContentTreeValue;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly format: "content-tree";
|
|
15
21
|
readonly mdxCompilerVersion: "3.1.1";
|
|
16
22
|
readonly plainText: string;
|
|
17
23
|
readonly rawMdx: string;
|
|
@@ -20,4 +26,4 @@ export declare const verifySignedContentArtifact: (input: unknown) => Effect.Eff
|
|
|
20
26
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
21
27
|
};
|
|
22
28
|
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
23
|
-
}, import("#contracts/artifact/spec").
|
|
29
|
+
}, import("#contracts/artifact/spec").ArtifactHashComputationError | import("#contracts/artifact/spec").ArtifactHashMismatchError | import("#contracts/artifact/spec").ArtifactPayloadFieldByteLimitError | import("#contracts/artifact/spec").ArtifactRendererComponentMissingError | import("#contracts/artifact/spec").ArtifactRendererDomainUnpublishedError | import("#contracts/artifact/spec").ArtifactSourceHashComputationError | import("#contracts/artifact/spec").ArtifactSourceHashMismatchError | import("#contracts/artifact/spec").ArtifactTreeComponentUnlistedError | import("#contracts/artifact/spec").ArtifactVerificationByteLimitError | ArtifactVerificationDecodeError | import("../errors.js").ContractDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("../renderer/contract.js").RendererDomainCapabilityMissingError | import("../renderer/contract.js").RendererManifestHashComputeError | import("../renderer/contract.js").RendererManifestHashMismatchError | import("../signature/spec.js").SignatureCheckError | import("../signature/spec.js").SignatureInvalidError | import("../signature/spec.js").SigningKeyNotFoundError | import("../signature/spec.js").SigningKeyResolutionError, import("../signature/spec.js").ContentVerificationKeyResolver>;
|
package/dist/content.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function routeIdentity(input: {
|
|
|
26
26
|
/** Compares content heads using deterministic Unicode code-unit order. */
|
|
27
27
|
export declare function compareContentHeads(left: ContentHeadIdentity, right: ContentHeadIdentity): -1 | 0 | 1;
|
|
28
28
|
/** Compiler protocol implemented by this Aksara compiler release. */
|
|
29
|
-
export declare const AKSARA_COMPILER_VERSION = "0.
|
|
29
|
+
export declare const AKSARA_COMPILER_VERSION = "0.2.0";
|
|
30
30
|
/** Official MDX compiler version used to produce function-body artifacts. */
|
|
31
31
|
export declare const MDX_COMPILER_VERSION = "3.1.1";
|
|
32
32
|
/** Authored source identity accepted before deterministic compilation. */
|
|
@@ -57,15 +57,28 @@ export declare const CompileDocumentRequestSchema: Schema.Struct<{
|
|
|
57
57
|
}>;
|
|
58
58
|
}>;
|
|
59
59
|
export type CompileDocumentRequest = typeof CompileDocumentRequestSchema.Type;
|
|
60
|
-
/**
|
|
60
|
+
/** Compiled trusted payload: its evaluated content tree is what Nakafa renders. */
|
|
61
61
|
export declare const CompiledContentPayloadSchema: Schema.Struct<{
|
|
62
62
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
63
|
-
readonly byteLength: Schema.Finite;
|
|
64
|
-
readonly compiledCode: Schema.String;
|
|
65
63
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
66
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
64
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
67
65
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
68
|
-
readonly
|
|
66
|
+
readonly contentTree: Schema.Codec<{
|
|
67
|
+
readonly $node: "element";
|
|
68
|
+
readonly children: readonly import("#contracts/tree").ContentTreeChild[];
|
|
69
|
+
readonly name: import("#contracts/tree").ContentTreeElementName;
|
|
70
|
+
readonly props: {
|
|
71
|
+
readonly [key: string]: import("#contracts/tree").ContentTreeValue;
|
|
72
|
+
};
|
|
73
|
+
}, {
|
|
74
|
+
readonly $node: "element";
|
|
75
|
+
readonly children: readonly import("#contracts/tree").ContentTreeChild[];
|
|
76
|
+
readonly name: import("#contracts/tree").ContentTreeElementName;
|
|
77
|
+
readonly props: {
|
|
78
|
+
readonly [key: string]: import("#contracts/tree").ContentTreeValue;
|
|
79
|
+
};
|
|
80
|
+
}, never, never>;
|
|
81
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
69
82
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
70
83
|
readonly plainText: Schema.String;
|
|
71
84
|
readonly rawMdx: Schema.String;
|
|
@@ -80,12 +93,25 @@ export declare const SignedContentArtifactSchema: Schema.Struct<{
|
|
|
80
93
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
81
94
|
readonly payload: Schema.Struct<{
|
|
82
95
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
83
|
-
readonly byteLength: Schema.Finite;
|
|
84
|
-
readonly compiledCode: Schema.String;
|
|
85
96
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
86
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
97
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
87
98
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
88
|
-
readonly
|
|
99
|
+
readonly contentTree: Schema.Codec<{
|
|
100
|
+
readonly $node: "element";
|
|
101
|
+
readonly children: readonly import("#contracts/tree").ContentTreeChild[];
|
|
102
|
+
readonly name: import("#contracts/tree").ContentTreeElementName;
|
|
103
|
+
readonly props: {
|
|
104
|
+
readonly [key: string]: import("#contracts/tree").ContentTreeValue;
|
|
105
|
+
};
|
|
106
|
+
}, {
|
|
107
|
+
readonly $node: "element";
|
|
108
|
+
readonly children: readonly import("#contracts/tree").ContentTreeChild[];
|
|
109
|
+
readonly name: import("#contracts/tree").ContentTreeElementName;
|
|
110
|
+
readonly props: {
|
|
111
|
+
readonly [key: string]: import("#contracts/tree").ContentTreeValue;
|
|
112
|
+
};
|
|
113
|
+
}, never, never>;
|
|
114
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
89
115
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
90
116
|
readonly plainText: Schema.String;
|
|
91
117
|
readonly rawMdx: Schema.String;
|
|
@@ -96,7 +122,7 @@ export declare const SignedContentArtifactSchema: Schema.Struct<{
|
|
|
96
122
|
readonly signature: Schema.brand<Schema.String, "@NakafaAI/AksaraEd25519Signature">;
|
|
97
123
|
}>;
|
|
98
124
|
export type SignedContentArtifact = typeof SignedContentArtifactSchema.Type;
|
|
99
|
-
/** Serializes a compiled payload with stable field and
|
|
125
|
+
/** Serializes a compiled payload with stable field, prop, and element order. */
|
|
100
126
|
export declare function canonicalizeCompiledContentPayload(payload: CompiledContentPayload): string;
|
|
101
127
|
/** Returns the domain-separated canonical bytes covered by Ed25519. */
|
|
102
128
|
export declare function canonicalizeContentArtifactSigningInput(artifactHash: typeof Sha256HashSchema.Type, payload: CompiledContentPayload): string;
|
package/dist/content.js
CHANGED
|
@@ -7,6 +7,7 @@ import { RendererManifestEnvelopeSchema } from "#contracts/renderer/contract";
|
|
|
7
7
|
import { RendererDomainSchema } from "#contracts/renderer/domain";
|
|
8
8
|
import { encodeJsonText } from "#contracts/text/json";
|
|
9
9
|
import { compareCodeUnits } from "#contracts/text/order";
|
|
10
|
+
import { ContentTreeSchema, canonicalizeContentTree } from "#contracts/tree";
|
|
10
11
|
/** Published content families backed by real Aksara source registries. */
|
|
11
12
|
export const ContentFamilySchema = Schema.Literals([
|
|
12
13
|
"article",
|
|
@@ -36,7 +37,7 @@ export function compareContentHeads(left, right) {
|
|
|
36
37
|
compareCodeUnits(left.artifactLocale, right.artifactLocale));
|
|
37
38
|
}
|
|
38
39
|
/** Compiler protocol implemented by this Aksara compiler release. */
|
|
39
|
-
export const AKSARA_COMPILER_VERSION = "0.
|
|
40
|
+
export const AKSARA_COMPILER_VERSION = "0.2.0";
|
|
40
41
|
/** Official MDX compiler version used to produce function-body artifacts. */
|
|
41
42
|
export const MDX_COMPILER_VERSION = "3.1.1";
|
|
42
43
|
/** Authored source identity accepted before deterministic compilation. */
|
|
@@ -52,15 +53,14 @@ export const CompileDocumentRequestSchema = Schema.Struct({
|
|
|
52
53
|
...CompileDocumentSourceSchema.fields,
|
|
53
54
|
rendererManifest: RendererManifestEnvelopeSchema,
|
|
54
55
|
});
|
|
55
|
-
/**
|
|
56
|
+
/** Compiled trusted payload: its evaluated content tree is what Nakafa renders. */
|
|
56
57
|
export const CompiledContentPayloadSchema = Schema.Struct({
|
|
57
58
|
artifactLocale: ArtifactLocaleSchema,
|
|
58
|
-
byteLength: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
59
|
-
compiledCode: Schema.String,
|
|
60
59
|
compilerConfigHash: Sha256HashSchema,
|
|
61
60
|
compilerVersion: Schema.Literal(AKSARA_COMPILER_VERSION),
|
|
62
61
|
contentKey: ContentKeySchema,
|
|
63
|
-
|
|
62
|
+
contentTree: ContentTreeSchema,
|
|
63
|
+
format: Schema.Literal("content-tree"),
|
|
64
64
|
mdxCompilerVersion: Schema.Literal(MDX_COMPILER_VERSION),
|
|
65
65
|
plainText: Schema.String,
|
|
66
66
|
rawMdx: Schema.String,
|
|
@@ -76,23 +76,9 @@ export const SignedContentArtifactSchema = Schema.Struct({
|
|
|
76
76
|
signature: Ed25519SignatureSchema,
|
|
77
77
|
});
|
|
78
78
|
const CONTENT_ARTIFACT_SIGNATURE_DOMAIN = "nakafa.aksara.content-artifact";
|
|
79
|
-
/** Serializes a compiled payload with stable field and
|
|
79
|
+
/** Serializes a compiled payload with stable field, prop, and element order. */
|
|
80
80
|
export function canonicalizeCompiledContentPayload(payload) {
|
|
81
|
-
return encodeJsonText({
|
|
82
|
-
artifactLocale: payload.artifactLocale,
|
|
83
|
-
byteLength: payload.byteLength,
|
|
84
|
-
compiledCode: payload.compiledCode,
|
|
85
|
-
compilerConfigHash: payload.compilerConfigHash,
|
|
86
|
-
compilerVersion: payload.compilerVersion,
|
|
87
|
-
contentKey: payload.contentKey,
|
|
88
|
-
format: payload.format,
|
|
89
|
-
mdxCompilerVersion: payload.mdxCompilerVersion,
|
|
90
|
-
plainText: payload.plainText,
|
|
91
|
-
rawMdx: payload.rawMdx,
|
|
92
|
-
rendererDomain: payload.rendererDomain,
|
|
93
|
-
requiredComponents: payload.requiredComponents,
|
|
94
|
-
sourceHash: payload.sourceHash,
|
|
95
|
-
});
|
|
81
|
+
return `{"artifactLocale":${encodeJsonText(payload.artifactLocale)},"compilerConfigHash":${encodeJsonText(payload.compilerConfigHash)},"compilerVersion":${encodeJsonText(payload.compilerVersion)},"contentKey":${encodeJsonText(payload.contentKey)},"contentTree":${canonicalizeContentTree(payload.contentTree)},"format":${encodeJsonText(payload.format)},"mdxCompilerVersion":${encodeJsonText(payload.mdxCompilerVersion)},"plainText":${encodeJsonText(payload.plainText)},"rawMdx":${encodeJsonText(payload.rawMdx)},"rendererDomain":${encodeJsonText(payload.rendererDomain)},"requiredComponents":${encodeJsonText(payload.requiredComponents)},"sourceHash":${encodeJsonText(payload.sourceHash)}}`;
|
|
96
82
|
}
|
|
97
83
|
/** Returns the domain-separated canonical bytes covered by Ed25519. */
|
|
98
84
|
export function canonicalizeContentArtifactSigningInput(artifactHash, payload) {
|
package/dist/limits.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Maximum UTF-8 bytes accepted for one authored MDX source. */
|
|
2
2
|
export declare const MAX_RAW_MDX_BYTES: number;
|
|
3
|
-
/** Maximum UTF-8 bytes accepted for one
|
|
4
|
-
export declare const
|
|
3
|
+
/** Maximum UTF-8 bytes accepted for one canonical content tree. */
|
|
4
|
+
export declare const MAX_CONTENT_TREE_BYTES: number;
|
|
5
5
|
/** Maximum UTF-8 bytes accepted for one extracted plain-text projection. */
|
|
6
6
|
export declare const MAX_PLAIN_TEXT_BYTES: number;
|
|
7
7
|
/** Maximum UTF-8 bytes for all canonical compiled payload fields. */
|
package/dist/limits.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Maximum UTF-8 bytes accepted for one authored MDX source. */
|
|
2
2
|
export const MAX_RAW_MDX_BYTES = 128 * 1024;
|
|
3
|
-
/** Maximum UTF-8 bytes accepted for one
|
|
4
|
-
export const
|
|
3
|
+
/** Maximum UTF-8 bytes accepted for one canonical content tree. */
|
|
4
|
+
export const MAX_CONTENT_TREE_BYTES = 384 * 1024;
|
|
5
5
|
/** Maximum UTF-8 bytes accepted for one extracted plain-text projection. */
|
|
6
6
|
export const MAX_PLAIN_TEXT_BYTES = 128 * 1024;
|
|
7
7
|
/** Maximum UTF-8 bytes for all canonical compiled payload fields. */
|
|
@@ -232,12 +232,25 @@ export declare const RollbackUpsertStateSchema: Schema.Struct<{
|
|
|
232
232
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
233
233
|
readonly payload: Schema.Struct<{
|
|
234
234
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
235
|
-
readonly byteLength: Schema.Finite;
|
|
236
|
-
readonly compiledCode: Schema.String;
|
|
237
235
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
238
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
236
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
239
237
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
240
|
-
readonly
|
|
238
|
+
readonly contentTree: Schema.Codec<{
|
|
239
|
+
readonly $node: "element";
|
|
240
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
241
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
242
|
+
readonly props: {
|
|
243
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
244
|
+
};
|
|
245
|
+
}, {
|
|
246
|
+
readonly $node: "element";
|
|
247
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
248
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
249
|
+
readonly props: {
|
|
250
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
251
|
+
};
|
|
252
|
+
}, never, never>;
|
|
253
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
241
254
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
242
255
|
readonly plainText: Schema.String;
|
|
243
256
|
readonly rawMdx: Schema.String;
|
|
@@ -480,12 +493,25 @@ export declare const RollbackStateSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
480
493
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
481
494
|
readonly payload: Schema.Struct<{
|
|
482
495
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
483
|
-
readonly byteLength: Schema.Finite;
|
|
484
|
-
readonly compiledCode: Schema.String;
|
|
485
496
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
486
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
497
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
487
498
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
488
|
-
readonly
|
|
499
|
+
readonly contentTree: Schema.Codec<{
|
|
500
|
+
readonly $node: "element";
|
|
501
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
502
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
503
|
+
readonly props: {
|
|
504
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
505
|
+
};
|
|
506
|
+
}, {
|
|
507
|
+
readonly $node: "element";
|
|
508
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
509
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
510
|
+
readonly props: {
|
|
511
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
512
|
+
};
|
|
513
|
+
}, never, never>;
|
|
514
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
489
515
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
490
516
|
readonly plainText: Schema.String;
|
|
491
517
|
readonly rawMdx: Schema.String;
|
|
@@ -726,12 +752,25 @@ export declare const RollbackRecordSchema: Schema.Struct<{
|
|
|
726
752
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
727
753
|
readonly payload: Schema.Struct<{
|
|
728
754
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
729
|
-
readonly byteLength: Schema.Finite;
|
|
730
|
-
readonly compiledCode: Schema.String;
|
|
731
755
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
732
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
756
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
733
757
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
734
|
-
readonly
|
|
758
|
+
readonly contentTree: Schema.Codec<{
|
|
759
|
+
readonly $node: "element";
|
|
760
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
761
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
762
|
+
readonly props: {
|
|
763
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
764
|
+
};
|
|
765
|
+
}, {
|
|
766
|
+
readonly $node: "element";
|
|
767
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
768
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
769
|
+
readonly props: {
|
|
770
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
771
|
+
};
|
|
772
|
+
}, never, never>;
|
|
773
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
735
774
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
736
775
|
readonly plainText: Schema.String;
|
|
737
776
|
readonly rawMdx: Schema.String;
|
|
@@ -970,12 +1009,25 @@ export declare const RollbackRecordSchema: Schema.Struct<{
|
|
|
970
1009
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
971
1010
|
readonly payload: Schema.Struct<{
|
|
972
1011
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
973
|
-
readonly byteLength: Schema.Finite;
|
|
974
|
-
readonly compiledCode: Schema.String;
|
|
975
1012
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
976
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
1013
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
977
1014
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
978
|
-
readonly
|
|
1015
|
+
readonly contentTree: Schema.Codec<{
|
|
1016
|
+
readonly $node: "element";
|
|
1017
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
1018
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
1019
|
+
readonly props: {
|
|
1020
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
1021
|
+
};
|
|
1022
|
+
}, {
|
|
1023
|
+
readonly $node: "element";
|
|
1024
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
1025
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
1026
|
+
readonly props: {
|
|
1027
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
1028
|
+
};
|
|
1029
|
+
}, never, never>;
|
|
1030
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
979
1031
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
980
1032
|
readonly plainText: Schema.String;
|
|
981
1033
|
readonly rawMdx: Schema.String;
|
|
@@ -1228,12 +1280,25 @@ export declare const RollbackPageSchema: Schema.Struct<{
|
|
|
1228
1280
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
1229
1281
|
readonly payload: Schema.Struct<{
|
|
1230
1282
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
1231
|
-
readonly byteLength: Schema.Finite;
|
|
1232
|
-
readonly compiledCode: Schema.String;
|
|
1233
1283
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
1234
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
1284
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
1235
1285
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
1236
|
-
readonly
|
|
1286
|
+
readonly contentTree: Schema.Codec<{
|
|
1287
|
+
readonly $node: "element";
|
|
1288
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
1289
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
1290
|
+
readonly props: {
|
|
1291
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
1292
|
+
};
|
|
1293
|
+
}, {
|
|
1294
|
+
readonly $node: "element";
|
|
1295
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
1296
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
1297
|
+
readonly props: {
|
|
1298
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
1299
|
+
};
|
|
1300
|
+
}, never, never>;
|
|
1301
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
1237
1302
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
1238
1303
|
readonly plainText: Schema.String;
|
|
1239
1304
|
readonly rawMdx: Schema.String;
|
|
@@ -1472,12 +1537,25 @@ export declare const RollbackPageSchema: Schema.Struct<{
|
|
|
1472
1537
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
1473
1538
|
readonly payload: Schema.Struct<{
|
|
1474
1539
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
1475
|
-
readonly byteLength: Schema.Finite;
|
|
1476
|
-
readonly compiledCode: Schema.String;
|
|
1477
1540
|
readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
1478
|
-
readonly compilerVersion: Schema.Literal<"0.
|
|
1541
|
+
readonly compilerVersion: Schema.Literal<"0.2.0">;
|
|
1479
1542
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
1480
|
-
readonly
|
|
1543
|
+
readonly contentTree: Schema.Codec<{
|
|
1544
|
+
readonly $node: "element";
|
|
1545
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
1546
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
1547
|
+
readonly props: {
|
|
1548
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
1549
|
+
};
|
|
1550
|
+
}, {
|
|
1551
|
+
readonly $node: "element";
|
|
1552
|
+
readonly children: readonly import("../../tree.js").ContentTreeChild[];
|
|
1553
|
+
readonly name: import("../../tree.js").ContentTreeElementName;
|
|
1554
|
+
readonly props: {
|
|
1555
|
+
readonly [key: string]: import("../../tree.js").ContentTreeValue;
|
|
1556
|
+
};
|
|
1557
|
+
}, never, never>;
|
|
1558
|
+
readonly format: Schema.Literal<"content-tree">;
|
|
1481
1559
|
readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
|
|
1482
1560
|
readonly plainText: Schema.String;
|
|
1483
1561
|
readonly rawMdx: Schema.String;
|