@nakafa/aksara-contracts 0.50.0 → 1.0.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.
Files changed (111) hide show
  1. package/LICENSE +207 -152
  2. package/README.md +3 -0
  3. package/dist/artifact/integrity.d.ts +33 -8
  4. package/dist/artifact/integrity.js +19 -17
  5. package/dist/artifact/limits.d.ts +13 -7
  6. package/dist/artifact/limits.js +7 -15
  7. package/dist/artifact/source.d.ts +10 -4
  8. package/dist/artifact/source.js +4 -8
  9. package/dist/artifact/spec.d.ts +54 -22
  10. package/dist/artifact/spec.js +7 -8
  11. package/dist/artifact/verify.d.ts +11 -5
  12. package/dist/assessment/hash.d.ts +3 -1
  13. package/dist/assessment/paper.d.ts +3 -1
  14. package/dist/content.d.ts +37 -11
  15. package/dist/content.js +7 -21
  16. package/dist/errors.d.ts +3 -1
  17. package/dist/graph/family.d.ts +6 -2
  18. package/dist/graph/identity.d.ts +3 -1
  19. package/dist/hash/digest.d.ts +10 -0
  20. package/dist/hash/digest.js +40 -0
  21. package/dist/hash/stream.d.ts +12 -0
  22. package/dist/hash/stream.js +27 -0
  23. package/dist/hash/text.d.ts +3 -1
  24. package/dist/hash/text.js +2 -15
  25. package/dist/limits.d.ts +2 -2
  26. package/dist/limits.js +2 -2
  27. package/dist/preview/auth.d.ts +4 -2
  28. package/dist/preview/auth.js +26 -12
  29. package/dist/program/snapshot/digest.d.ts +3 -1
  30. package/dist/program/snapshot/digest.js +14 -22
  31. package/dist/program/snapshot/hash.d.ts +6 -2
  32. package/dist/program/snapshot/hash.js +10 -21
  33. package/dist/projection/digest.d.ts +11 -9
  34. package/dist/projection/digest.js +23 -32
  35. package/dist/projection/hash.d.ts +222 -2
  36. package/dist/projection/hash.js +6 -8
  37. package/dist/projection/verify.d.ts +16 -6
  38. package/dist/question/item.d.ts +3 -1
  39. package/dist/question/item.js +3 -1
  40. package/dist/quran/notes.d.ts +3 -1
  41. package/dist/quran/provenance.d.ts +6 -2
  42. package/dist/quran/provenance.js +8 -15
  43. package/dist/quran/snapshot/digest.d.ts +9 -5
  44. package/dist/quran/snapshot/digest.js +33 -41
  45. package/dist/quran/snapshot/hash.d.ts +3 -1
  46. package/dist/quran/snapshot/hash.js +9 -15
  47. package/dist/quran/snapshot/row/hash.d.ts +3 -1
  48. package/dist/quran/snapshot/row/hash.js +2 -8
  49. package/dist/release/digest.d.ts +10 -8
  50. package/dist/release/digest.js +22 -31
  51. package/dist/release/hash.d.ts +3 -1
  52. package/dist/release/hash.js +3 -8
  53. package/dist/release/items.d.ts +25 -9
  54. package/dist/release/items.js +12 -3
  55. package/dist/release/policy.d.ts +3 -1
  56. package/dist/release/result/digest.d.ts +23 -13
  57. package/dist/release/result/digest.js +20 -29
  58. package/dist/release/rollback/digest.d.ts +16 -10
  59. package/dist/release/rollback/digest.js +25 -32
  60. package/dist/release/rollback/spec.d.ts +102 -24
  61. package/dist/release/route/digest.d.ts +10 -8
  62. package/dist/release/route/digest.js +22 -31
  63. package/dist/release/route/verify.d.ts +16 -6
  64. package/dist/release/route/verify.js +8 -2
  65. package/dist/release/snapshot/evidence/requirement.d.ts +3 -1
  66. package/dist/release/snapshot/evidence/tryout.d.ts +1 -1
  67. package/dist/release/snapshot/evidence/tryout.js +1 -1
  68. package/dist/release/snapshot/evidence.d.ts +1 -1
  69. package/dist/release/snapshot/verify.d.ts +19 -7
  70. package/dist/release/snapshot/verify.js +20 -18
  71. package/dist/release/verify.d.ts +9 -3
  72. package/dist/renderer/compatibility.d.ts +6 -2
  73. package/dist/renderer/compatibility.js +3 -1
  74. package/dist/renderer/contract.d.ts +9 -3
  75. package/dist/renderer/contract.js +3 -1
  76. package/dist/runtime/error.d.ts +3 -1
  77. package/dist/runtime/protected/spec.d.ts +61 -16
  78. package/dist/runtime/protected/verify.d.ts +11 -5
  79. package/dist/runtime/spec.d.ts +44 -12
  80. package/dist/runtime/verify.d.ts +22 -10
  81. package/dist/runtime/verify.js +2 -1
  82. package/dist/signature/key.d.ts +21 -0
  83. package/dist/signature/key.js +104 -0
  84. package/dist/signature/spec.d.ts +18 -6
  85. package/dist/signature/spec.js +16 -4
  86. package/dist/transport/batch.d.ts +34 -8
  87. package/dist/transport/group.d.ts +51 -12
  88. package/dist/transport/request.d.ts +826 -764
  89. package/dist/transport/response.d.ts +148 -58
  90. package/dist/tree.d.ts +52 -0
  91. package/dist/tree.js +162 -0
  92. package/dist/tryout/canonical.d.ts +11 -1
  93. package/dist/tryout/canonical.js +6 -10
  94. package/dist/tryout/closure/accounting.d.ts +3 -1
  95. package/dist/tryout/digest.d.ts +12 -6
  96. package/dist/tryout/digest.js +21 -14
  97. package/dist/tryout/hash/catalog.d.ts +228 -3
  98. package/dist/tryout/hash/catalog.js +5 -7
  99. package/dist/tryout/hash/content.d.ts +113 -2
  100. package/dist/tryout/hash/content.js +10 -8
  101. package/dist/tryout/hash/placement.d.ts +236 -5
  102. package/dist/tryout/hash/placement.js +7 -8
  103. package/dist/tryout/runtime/hash.d.ts +3 -1
  104. package/dist/tryout/runtime/hash.js +3 -1
  105. package/dist/tryout/runtime/source.d.ts +3 -1
  106. package/dist/tryout/runtime/verify.d.ts +13 -5
  107. package/dist/tryout/runtime/verify.js +1 -1
  108. package/dist/tryout/scoring.d.ts +3 -1
  109. package/dist/tryout/snapshot/hash.d.ts +45 -4
  110. package/dist/tryout/snapshot/hash.js +9 -7
  111. package/package.json +22 -2
@@ -32,7 +32,9 @@ export declare const RendererManifestEnvelopeSchema: Schema.Struct<{
32
32
  export type RendererManifestEnvelope = typeof RendererManifestEnvelopeSchema.Type;
33
33
  declare const RendererDomainCapabilityMissingError_base: Schema.Class<RendererDomainCapabilityMissingError, Schema.TaggedStruct<"RendererDomainCapabilityMissingError", {
34
34
  readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
35
- }>, import("effect/Cause").YieldableError>;
35
+ }>, import("effect/Cause").YieldableError & {
36
+ readonly brand: unique symbol;
37
+ }>;
36
38
  /** A persisted renderer envelope does not carry the requested domain. */
37
39
  export declare class RendererDomainCapabilityMissingError extends RendererDomainCapabilityMissingError_base {
38
40
  }
@@ -52,14 +54,18 @@ export declare const selectRendererDomainCapability: (manifest: {
52
54
  }, RendererDomainCapabilityMissingError, never>;
53
55
  declare const RendererManifestHashComputeError_base: Schema.Class<RendererManifestHashComputeError, Schema.TaggedStruct<"RendererManifestHashComputeError", {
54
56
  readonly cause: Schema.Unknown;
55
- }>, import("effect/Cause").YieldableError>;
57
+ }>, import("effect/Cause").YieldableError & {
58
+ readonly brand: unique symbol;
59
+ }>;
56
60
  /** SHA-256 could not be calculated for the renderer contract bytes. */
57
61
  export declare class RendererManifestHashComputeError extends RendererManifestHashComputeError_base {
58
62
  }
59
63
  declare const RendererManifestHashMismatchError_base: Schema.Class<RendererManifestHashMismatchError, Schema.TaggedStruct<"RendererManifestHashMismatchError", {
60
64
  readonly actualHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
61
65
  readonly expectedHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
62
- }>, import("effect/Cause").YieldableError>;
66
+ }>, import("effect/Cause").YieldableError & {
67
+ readonly brand: unique symbol;
68
+ }>;
63
69
  /** The renderer envelope hash does not authenticate its canonical tuple. */
64
70
  export declare class RendererManifestHashMismatchError extends RendererManifestHashMismatchError_base {
65
71
  }
@@ -52,7 +52,9 @@ export const RendererManifestEnvelopeSchema = Schema.Struct({
52
52
  message: "Expected base and route-domain component names to be disjoint.",
53
53
  })));
54
54
  /** A persisted renderer envelope does not carry the requested domain. */
55
- export class RendererDomainCapabilityMissingError extends Schema.TaggedError()("RendererDomainCapabilityMissingError", { rendererDomain: RendererDomainSchema }) {
55
+ export class RendererDomainCapabilityMissingError extends Schema.TaggedError()("RendererDomainCapabilityMissingError", {
56
+ rendererDomain: RendererDomainSchema,
57
+ }) {
56
58
  }
57
59
  /** Selects the one physical route registry authorized for a document. */
58
60
  export const selectRendererDomainCapability = Effect.fn("AksaraContracts.selectRendererDomainCapability")(function* (manifest, rendererDomain) {
@@ -1,7 +1,9 @@
1
1
  import { Schema } from "effect";
2
2
  declare const ContentRuntimeMismatchError_base: Schema.Class<ContentRuntimeMismatchError, Schema.TaggedStruct<"ContentRuntimeMismatchError", {
3
3
  readonly reason: Schema.Literals<readonly ["activeManifestHash", "activeReleaseId", "artifactHash", "bundleHash", "contentKey", "delivery", "locale", "projectionHash", "publicPath", "rendererManifest", "selectorCount", "snapshotId", "sourcePath"]>;
4
- }>, import("effect/Cause").YieldableError>;
4
+ }>, import("effect/Cause").YieldableError & {
5
+ readonly brand: unique symbol;
6
+ }>;
5
7
  /** A decoded runtime response does not belong to its initiating request. */
6
8
  export declare class ContentRuntimeMismatchError extends ContentRuntimeMismatchError_base {
7
9
  }
@@ -24,12 +24,25 @@ export declare const ProtectedContentRuntimeItemSchema: Schema.Struct<{
24
24
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
25
25
  readonly payload: Schema.Struct<{
26
26
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
27
- readonly byteLength: Schema.Finite;
28
- readonly compiledCode: Schema.String;
29
27
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
30
- readonly compilerVersion: Schema.Literal<"0.1.0">;
28
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
31
29
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
32
- readonly format: Schema.Literal<"mdx-function-body">;
30
+ readonly contentTree: Schema.Codec<{
31
+ readonly $node: "element";
32
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
33
+ readonly name: import("../../tree.js").ContentTreeElementName;
34
+ readonly props: {
35
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
36
+ };
37
+ }, {
38
+ readonly $node: "element";
39
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
40
+ readonly name: import("../../tree.js").ContentTreeElementName;
41
+ readonly props: {
42
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
43
+ };
44
+ }, never, never>;
45
+ readonly format: Schema.Literal<"content-tree">;
33
46
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
34
47
  readonly plainText: Schema.String;
35
48
  readonly rawMdx: Schema.String;
@@ -79,12 +92,25 @@ export declare const ProtectedContentRuntimeFoundSchema: Schema.Struct<{
79
92
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
80
93
  readonly payload: Schema.Struct<{
81
94
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
82
- readonly byteLength: Schema.Finite;
83
- readonly compiledCode: Schema.String;
84
95
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
85
- readonly compilerVersion: Schema.Literal<"0.1.0">;
96
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
86
97
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
87
- readonly format: Schema.Literal<"mdx-function-body">;
98
+ readonly contentTree: Schema.Codec<{
99
+ readonly $node: "element";
100
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
101
+ readonly name: import("../../tree.js").ContentTreeElementName;
102
+ readonly props: {
103
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
104
+ };
105
+ }, {
106
+ readonly $node: "element";
107
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
108
+ readonly name: import("../../tree.js").ContentTreeElementName;
109
+ readonly props: {
110
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
111
+ };
112
+ }, never, never>;
113
+ readonly format: Schema.Literal<"content-tree">;
88
114
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
89
115
  readonly plainText: Schema.String;
90
116
  readonly rawMdx: Schema.String;
@@ -146,12 +172,25 @@ export declare const ProtectedContentRuntimeResponseSchema: Schema.Union<readonl
146
172
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
147
173
  readonly payload: Schema.Struct<{
148
174
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
149
- readonly byteLength: Schema.Finite;
150
- readonly compiledCode: Schema.String;
151
175
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
152
- readonly compilerVersion: Schema.Literal<"0.1.0">;
176
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
153
177
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
154
- readonly format: Schema.Literal<"mdx-function-body">;
178
+ readonly contentTree: Schema.Codec<{
179
+ readonly $node: "element";
180
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
181
+ readonly name: import("../../tree.js").ContentTreeElementName;
182
+ readonly props: {
183
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
184
+ };
185
+ }, {
186
+ readonly $node: "element";
187
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
188
+ readonly name: import("../../tree.js").ContentTreeElementName;
189
+ readonly props: {
190
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
191
+ };
192
+ }, never, never>;
193
+ readonly format: Schema.Literal<"content-tree">;
155
194
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
156
195
  readonly plainText: Schema.String;
157
196
  readonly rawMdx: Schema.String;
@@ -228,12 +267,18 @@ export declare const decodeProtectedContentRuntimeResponse: (input: unknown) =>
228
267
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
229
268
  readonly payload: {
230
269
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
231
- readonly byteLength: number;
232
- readonly compiledCode: string;
233
270
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
234
- readonly compilerVersion: "0.1.0";
271
+ readonly compilerVersion: "0.2.0";
235
272
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
236
- readonly format: "mdx-function-body";
273
+ readonly contentTree: {
274
+ readonly $node: "element";
275
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
276
+ readonly name: import("../../tree.js").ContentTreeElementName;
277
+ readonly props: {
278
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
279
+ };
280
+ };
281
+ readonly format: "content-tree";
237
282
  readonly mdxCompilerVersion: "3.1.1";
238
283
  readonly plainText: string;
239
284
  readonly rawMdx: string;
@@ -40,12 +40,18 @@ export declare const verifyProtectedContentRuntimeExchange: (input: {
40
40
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
41
41
  readonly payload: {
42
42
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
43
- readonly byteLength: number;
44
- readonly compiledCode: string;
45
43
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
46
- readonly compilerVersion: "0.1.0";
44
+ readonly compilerVersion: "0.2.0";
47
45
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
48
- readonly format: "mdx-function-body";
46
+ readonly contentTree: {
47
+ readonly $node: "element";
48
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
49
+ readonly name: import("../../tree.js").ContentTreeElementName;
50
+ readonly props: {
51
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
52
+ };
53
+ };
54
+ readonly format: "content-tree";
49
55
  readonly mdxCompilerVersion: "3.1.1";
50
56
  readonly plainText: string;
51
57
  readonly rawMdx: string;
@@ -74,4 +80,4 @@ export declare const verifyProtectedContentRuntimeExchange: (input: {
74
80
  } | {
75
81
  readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
76
82
  readonly kind: "failure";
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>;
83
+ }, 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").ArtifactTreeComponentUnlistedError | 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/canonical.js").TryoutCanonicalHashError | 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>;
@@ -17,12 +17,25 @@ export declare const PublicContentRuntimeFoundSchema: Schema.Struct<{
17
17
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
18
18
  readonly payload: Schema.Struct<{
19
19
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
20
- readonly byteLength: Schema.Finite;
21
- readonly compiledCode: Schema.String;
22
20
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
23
- readonly compilerVersion: Schema.Literal<"0.1.0">;
21
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
24
22
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
25
- readonly format: Schema.Literal<"mdx-function-body">;
23
+ readonly contentTree: Schema.Codec<{
24
+ readonly $node: "element";
25
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
26
+ readonly name: import("../tree.js").ContentTreeElementName;
27
+ readonly props: {
28
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
29
+ };
30
+ }, {
31
+ readonly $node: "element";
32
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
33
+ readonly name: import("../tree.js").ContentTreeElementName;
34
+ readonly props: {
35
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
36
+ };
37
+ }, never, never>;
38
+ readonly format: Schema.Literal<"content-tree">;
26
39
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
27
40
  readonly plainText: Schema.String;
28
41
  readonly rawMdx: Schema.String;
@@ -204,12 +217,25 @@ export declare const PublicContentRuntimeResponseSchema: Schema.Union<readonly [
204
217
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
205
218
  readonly payload: Schema.Struct<{
206
219
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
207
- readonly byteLength: Schema.Finite;
208
- readonly compiledCode: Schema.String;
209
220
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
210
- readonly compilerVersion: Schema.Literal<"0.1.0">;
221
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
211
222
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
212
- readonly format: Schema.Literal<"mdx-function-body">;
223
+ readonly contentTree: Schema.Codec<{
224
+ readonly $node: "element";
225
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
226
+ readonly name: import("../tree.js").ContentTreeElementName;
227
+ readonly props: {
228
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
229
+ };
230
+ }, {
231
+ readonly $node: "element";
232
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
233
+ readonly name: import("../tree.js").ContentTreeElementName;
234
+ readonly props: {
235
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
236
+ };
237
+ }, never, never>;
238
+ readonly format: Schema.Literal<"content-tree">;
213
239
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
214
240
  readonly plainText: Schema.String;
215
241
  readonly rawMdx: Schema.String;
@@ -402,12 +428,18 @@ export declare const decodePublicContentRuntimeResponse: (input: unknown) => Eff
402
428
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
403
429
  readonly payload: {
404
430
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
405
- readonly byteLength: number;
406
- readonly compiledCode: string;
407
431
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
408
- readonly compilerVersion: "0.1.0";
432
+ readonly compilerVersion: "0.2.0";
409
433
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
410
- readonly format: "mdx-function-body";
434
+ readonly contentTree: {
435
+ readonly $node: "element";
436
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
437
+ readonly name: import("../tree.js").ContentTreeElementName;
438
+ readonly props: {
439
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
440
+ };
441
+ };
442
+ readonly format: "content-tree";
411
443
  readonly mdxCompilerVersion: "3.1.1";
412
444
  readonly plainText: string;
413
445
  readonly rawMdx: string;
@@ -15,12 +15,18 @@ export declare const verifyContentRuntimeEvidenceExchange: (input: {
15
15
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
16
16
  readonly payload: {
17
17
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
18
- readonly byteLength: number;
19
- readonly compiledCode: string;
20
18
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
21
- readonly compilerVersion: "0.1.0";
19
+ readonly compilerVersion: "0.2.0";
22
20
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
23
- readonly format: "mdx-function-body";
21
+ readonly contentTree: {
22
+ readonly $node: "element";
23
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
24
+ readonly name: import("../tree.js").ContentTreeElementName;
25
+ readonly props: {
26
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
27
+ };
28
+ };
29
+ readonly format: "content-tree";
24
30
  readonly mdxCompilerVersion: "3.1.1";
25
31
  readonly plainText: string;
26
32
  readonly rawMdx: string;
@@ -198,7 +204,7 @@ export declare const verifyContentRuntimeEvidenceExchange: (input: {
198
204
  } | {
199
205
  readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
200
206
  readonly kind: "failure";
201
- }, 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/release/verify").ReleaseBundleVerificationDecodeError | import("../release/hash.js").ReleaseHashComputationError | import("#contracts/release/verify").ReleaseManifestHashMismatchError | import("#contracts/release/verify").ReleaseVerificationDecodeError | 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>;
207
+ }, 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").ArtifactTreeComponentUnlistedError | import("../artifact/spec.js").ArtifactVerificationByteLimitError | import("../artifact/spec.js").ArtifactVerificationDecodeError | import("#contracts/projection/hash").ContentProjectionHashError | ContentRuntimeMismatchError | import("../errors.js").ContractDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("#contracts/release/verify").ReleaseBundleVerificationDecodeError | import("../release/hash.js").ReleaseHashComputationError | import("#contracts/release/verify").ReleaseManifestHashMismatchError | import("#contracts/release/verify").ReleaseVerificationDecodeError | 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>;
202
208
  /**
203
209
  * Verifies independently signed runtime values selected for one exact request.
204
210
  *
@@ -215,12 +221,18 @@ export declare const verifyContentRuntimeExchange: (input: {
215
221
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
216
222
  readonly payload: {
217
223
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
218
- readonly byteLength: number;
219
- readonly compiledCode: string;
220
224
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
221
- readonly compilerVersion: "0.1.0";
225
+ readonly compilerVersion: "0.2.0";
222
226
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
223
- readonly format: "mdx-function-body";
227
+ readonly contentTree: {
228
+ readonly $node: "element";
229
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
230
+ readonly name: import("../tree.js").ContentTreeElementName;
231
+ readonly props: {
232
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
233
+ };
234
+ };
235
+ readonly format: "content-tree";
224
236
  readonly mdxCompilerVersion: "3.1.1";
225
237
  readonly plainText: string;
226
238
  readonly rawMdx: string;
@@ -398,4 +410,4 @@ export declare const verifyContentRuntimeExchange: (input: {
398
410
  } | {
399
411
  readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
400
412
  readonly kind: "failure";
401
- }, 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/release/verify").ReleaseBundleVerificationDecodeError | import("../release/hash.js").ReleaseHashComputationError | import("#contracts/release/verify").ReleaseManifestHashMismatchError | import("#contracts/release/verify").ReleaseVerificationDecodeError | 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>;
413
+ }, 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").ArtifactTreeComponentUnlistedError | import("../artifact/spec.js").ArtifactVerificationByteLimitError | import("../artifact/spec.js").ArtifactVerificationDecodeError | import("#contracts/projection/hash").ContentProjectionHashError | ContentRuntimeMismatchError | import("../errors.js").ContractDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("#contracts/release/verify").ReleaseBundleVerificationDecodeError | import("../release/hash.js").ReleaseHashComputationError | import("#contracts/release/verify").ReleaseManifestHashMismatchError | import("#contracts/release/verify").ReleaseVerificationDecodeError | 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>;
@@ -43,7 +43,8 @@ const verifyPublicIdentity = Effect.fn("AksaraContracts.verifyPublicIdentity")(f
43
43
  if (!hasProjectionSourcePath(response.projection, response.sourcePath)) {
44
44
  return yield* new ContentRuntimeMismatchError({ reason: "sourcePath" });
45
45
  }
46
- if (response.projectionHash !== hashContentProjection(response.projection)) {
46
+ const projectionHash = yield* hashContentProjection(response.projection);
47
+ if (response.projectionHash !== projectionHash) {
47
48
  return yield* new ContentRuntimeMismatchError({
48
49
  reason: "projectionHash",
49
50
  });
@@ -0,0 +1,21 @@
1
+ import { Effect, Schema } from "effect";
2
+ declare const Ed25519KeyError_base: Schema.Class<Ed25519KeyError, Schema.TaggedStruct<"Ed25519KeyError", {
3
+ readonly stage: Schema.Literals<readonly ["derive", "import", "sign"]>;
4
+ }>, import("effect/Cause").YieldableError & {
5
+ readonly brand: unique symbol;
6
+ }>;
7
+ /** An Ed25519 key could not be generated, imported from PEM, derived as a public key, or used to sign. */
8
+ export declare class Ed25519KeyError extends Ed25519KeyError_base {
9
+ }
10
+ /** Reads the 32 raw public-key bytes from the `x` member of an exported Ed25519 JSON Web Key. */
11
+ export declare const ed25519PublicKeyBytes: (x: string | undefined) => Effect.Effect<Uint8Array<ArrayBufferLike>, Ed25519KeyError, never>;
12
+ /** Derives the SPKI PEM public key of one Ed25519 PKCS#8 private key PEM. */
13
+ export declare const ed25519PublicKeyPem: (privateKeyPem: string) => Effect.Effect<string, Ed25519KeyError, never>;
14
+ /** Generates one Ed25519 key pair as PKCS#8 and SPKI PEM text, from a random seed. */
15
+ export declare const generateEd25519KeyPem: () => Effect.Effect<{
16
+ privateKeyPem: string;
17
+ publicKeyPem: string;
18
+ }, Ed25519KeyError, never>;
19
+ /** Signs the UTF-8 bytes of one canonical message with an unencrypted Ed25519 PKCS#8 PEM private key, returning the unpadded base64url signature. */
20
+ export declare const signEd25519Message: (privateKeyPem: string, message: string) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">, Ed25519KeyError, never>;
21
+ export {};
@@ -0,0 +1,104 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { Base64, Base64Url } from "effect/encoding";
3
+ import { webCryptoService } from "#contracts/hash/digest";
4
+ import { Ed25519SignatureSchema } from "#contracts/ids";
5
+ /** The DER prefix of one PKCS#8 Ed25519 private key, before its 32-byte seed. */
6
+ const ED25519_PKCS8_HEADER = Uint8Array.of(0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20);
7
+ const ED25519_SEED_BYTES = 32;
8
+ const PRIVATE_KEY_HEADER = "-----BEGIN PRIVATE KEY-----\n";
9
+ const PRIVATE_KEY_FOOTER = "-----END PRIVATE KEY-----";
10
+ const PUBLIC_KEY_HEADER = "-----BEGIN PUBLIC KEY-----\n";
11
+ const PUBLIC_KEY_FOOTER = "-----END PUBLIC KEY-----";
12
+ /** The DER header that wraps one 32-byte Ed25519 public key as SubjectPublicKeyInfo. */
13
+ const ED25519_SPKI_HEADER = Uint8Array.of(0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00);
14
+ const ED25519_PUBLIC_KEY_BYTES = 32;
15
+ /** PEM bodies wrap base64 text at this many characters per line. */
16
+ const PEM_LINE_LENGTH = 64;
17
+ /** An Ed25519 key could not be generated, imported from PEM, derived as a public key, or used to sign. */
18
+ export class Ed25519KeyError extends Schema.TaggedError()("Ed25519KeyError", {
19
+ stage: Schema.Literals(["derive", "import", "sign"]),
20
+ }) {
21
+ }
22
+ /** Decodes the DER bytes of one unencrypted PKCS#8 private key PEM. */
23
+ function decodePrivateKeyPem(privateKeyPem) {
24
+ const pem = privateKeyPem.replaceAll("\r\n", "\n");
25
+ const end = pem.trimEnd();
26
+ if (!(pem.startsWith(PRIVATE_KEY_HEADER) && end.endsWith(PRIVATE_KEY_FOOTER))) {
27
+ return Effect.fail(new Ed25519KeyError({ stage: "import" }));
28
+ }
29
+ const body = end
30
+ .slice(PRIVATE_KEY_HEADER.length, end.length - PRIVATE_KEY_FOOTER.length)
31
+ .replaceAll("\n", "");
32
+ return Effect.fromResult(Base64.decode(body)).pipe(Effect.mapError(() => new Ed25519KeyError({ stage: "import" })));
33
+ }
34
+ /** Imports one Ed25519 PKCS#8 key through Web Crypto, extractable only when asked. */
35
+ function importPkcs8(der, extractable) {
36
+ return Effect.tryPromise({
37
+ catch: () => new Ed25519KeyError({ stage: "import" }),
38
+ try: () => globalThis.crypto.subtle.importKey("pkcs8", new Uint8Array(der), { name: "Ed25519" }, extractable, ["sign"]),
39
+ });
40
+ }
41
+ /** Encodes DER bytes as PEM text with 64-character lines, the layout that Node writes. */
42
+ function encodePem(der, header, footer) {
43
+ const base64 = Base64.encode(der);
44
+ let body = "";
45
+ for (let offset = 0; offset < base64.length; offset += PEM_LINE_LENGTH) {
46
+ body += `${base64.slice(offset, offset + PEM_LINE_LENGTH)}\n`;
47
+ }
48
+ return `${header}${body}${footer}\n`;
49
+ }
50
+ /** Imports one unencrypted Ed25519 PKCS#8 PEM private key as a non-extractable signing key. */
51
+ const importPrivateKey = Effect.fn("AksaraContracts.importEd25519PrivateKey")(function* (privateKeyPem) {
52
+ const der = yield* decodePrivateKeyPem(privateKeyPem);
53
+ return yield* importPkcs8(der, false);
54
+ });
55
+ /** Reads the 32 raw public-key bytes from the `x` member of an exported Ed25519 JSON Web Key. */
56
+ export const ed25519PublicKeyBytes = Effect.fn("AksaraContracts.ed25519PublicKeyBytes")(function* (x) {
57
+ const bytes = yield* Effect.fromResult(Base64Url.decode(x ?? "")).pipe(Effect.mapError(() => new Ed25519KeyError({ stage: "derive" })));
58
+ if (bytes.byteLength !== ED25519_PUBLIC_KEY_BYTES) {
59
+ return yield* new Ed25519KeyError({ stage: "derive" });
60
+ }
61
+ return bytes;
62
+ });
63
+ /** Derives the SPKI PEM public key of one Ed25519 PKCS#8 private key PEM. */
64
+ export const ed25519PublicKeyPem = Effect.fn("AksaraContracts.ed25519PublicKeyPem")(function* (privateKeyPem) {
65
+ const der = yield* decodePrivateKeyPem(privateKeyPem);
66
+ const key = yield* importPkcs8(der, true);
67
+ const jwk = yield* Effect.tryPromise({
68
+ catch: () => new Ed25519KeyError({ stage: "derive" }),
69
+ try: () => globalThis.crypto.subtle.exportKey("jwk", key),
70
+ });
71
+ const publicKey = yield* ed25519PublicKeyBytes(jwk.x);
72
+ const spki = new Uint8Array(ED25519_SPKI_HEADER.byteLength + ED25519_PUBLIC_KEY_BYTES);
73
+ spki.set(ED25519_SPKI_HEADER);
74
+ spki.set(publicKey, ED25519_SPKI_HEADER.byteLength);
75
+ return encodePem(spki, PUBLIC_KEY_HEADER, PUBLIC_KEY_FOOTER);
76
+ });
77
+ /** Generates one Ed25519 key pair as PKCS#8 and SPKI PEM text, from a random seed. */
78
+ export const generateEd25519KeyPem = Effect.fn("AksaraContracts.generateEd25519KeyPem")(function* () {
79
+ const seed = yield* webCryptoService
80
+ .randomBytes(ED25519_SEED_BYTES)
81
+ .pipe(Effect.orDie);
82
+ const der = new Uint8Array(ED25519_PKCS8_HEADER.byteLength + seed.byteLength);
83
+ der.set(ED25519_PKCS8_HEADER);
84
+ der.set(seed, ED25519_PKCS8_HEADER.byteLength);
85
+ const privateKeyPem = encodePem(der, PRIVATE_KEY_HEADER, PRIVATE_KEY_FOOTER);
86
+ return {
87
+ privateKeyPem,
88
+ publicKeyPem: yield* ed25519PublicKeyPem(privateKeyPem),
89
+ };
90
+ });
91
+ /** Signs one exact message with an imported Ed25519 key, returning the raw 64-byte signature. */
92
+ const signBytes = Effect.fn("AksaraContracts.signEd25519")(function* (privateKey, message) {
93
+ const signature = yield* Effect.tryPromise({
94
+ catch: () => new Ed25519KeyError({ stage: "sign" }),
95
+ try: () => globalThis.crypto.subtle.sign("Ed25519", privateKey, new Uint8Array(message)),
96
+ });
97
+ return new Uint8Array(signature);
98
+ });
99
+ /** Signs the UTF-8 bytes of one canonical message with an unencrypted Ed25519 PKCS#8 PEM private key, returning the unpadded base64url signature. */
100
+ export const signEd25519Message = Effect.fn("AksaraContracts.signEd25519Message")(function* (privateKeyPem, message) {
101
+ const privateKey = yield* importPrivateKey(privateKeyPem);
102
+ const signature = yield* signBytes(privateKey, new TextEncoder().encode(message));
103
+ return Ed25519SignatureSchema.make(Base64Url.encode(signature));
104
+ });
@@ -5,41 +5,53 @@ export declare const ContentSignatureSubjectSchema: Schema.Literals<readonly ["a
5
5
  export type ContentSignatureSubject = typeof ContentSignatureSubjectSchema.Type;
6
6
  declare const SigningKeyNotFoundError_base: Schema.Class<SigningKeyNotFoundError, Schema.TaggedStruct<"SigningKeyNotFoundError", {
7
7
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
8
- }>, import("effect/Cause").YieldableError>;
8
+ }>, import("effect/Cause").YieldableError & {
9
+ readonly brand: unique symbol;
10
+ }>;
9
11
  /** No trusted public key exists for the requested key identifier. */
10
12
  export declare class SigningKeyNotFoundError extends SigningKeyNotFoundError_base {
11
13
  }
12
14
  declare const SigningKeyResolutionError_base: Schema.Class<SigningKeyResolutionError, Schema.TaggedStruct<"SigningKeyResolutionError", {
13
15
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
14
- }>, import("effect/Cause").YieldableError>;
16
+ }>, import("effect/Cause").YieldableError & {
17
+ readonly brand: unique symbol;
18
+ }>;
15
19
  /** The trusted key source could not resolve the requested public key. */
16
20
  export declare class SigningKeyResolutionError extends SigningKeyResolutionError_base {
17
21
  }
18
22
  declare const PublicKeyParseError_base: Schema.Class<PublicKeyParseError, Schema.TaggedStruct<"PublicKeyParseError", {
19
23
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
20
24
  readonly subject: Schema.Literals<readonly ["artifact", "release", "tryout-runtime-bundle"]>;
21
- }>, import("effect/Cause").YieldableError>;
25
+ }>, import("effect/Cause").YieldableError & {
26
+ readonly brand: unique symbol;
27
+ }>;
22
28
  /** A resolved public key could not be parsed without exposing its contents. */
23
29
  export declare class PublicKeyParseError extends PublicKeyParseError_base {
24
30
  }
25
31
  declare const PublicKeyTypeError_base: Schema.Class<PublicKeyTypeError, Schema.TaggedStruct<"PublicKeyTypeError", {
26
32
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
27
33
  readonly subject: Schema.Literals<readonly ["artifact", "release", "tryout-runtime-bundle"]>;
28
- }>, import("effect/Cause").YieldableError>;
34
+ }>, import("effect/Cause").YieldableError & {
35
+ readonly brand: unique symbol;
36
+ }>;
29
37
  /** A resolved public key is not an Ed25519 verification key. */
30
38
  export declare class PublicKeyTypeError extends PublicKeyTypeError_base {
31
39
  }
32
40
  declare const SignatureCheckError_base: Schema.Class<SignatureCheckError, Schema.TaggedStruct<"SignatureCheckError", {
33
41
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
34
42
  readonly subject: Schema.Literals<readonly ["artifact", "release", "tryout-runtime-bundle"]>;
35
- }>, import("effect/Cause").YieldableError>;
43
+ }>, import("effect/Cause").YieldableError & {
44
+ readonly brand: unique symbol;
45
+ }>;
36
46
  /** Web Crypto could not complete an Ed25519 verification operation. */
37
47
  export declare class SignatureCheckError extends SignatureCheckError_base {
38
48
  }
39
49
  declare const SignatureInvalidError_base: Schema.Class<SignatureInvalidError, Schema.TaggedStruct<"SignatureInvalidError", {
40
50
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
41
51
  readonly subject: Schema.Literals<readonly ["artifact", "release", "tryout-runtime-bundle"]>;
42
- }>, import("effect/Cause").YieldableError>;
52
+ }>, import("effect/Cause").YieldableError & {
53
+ readonly brand: unique symbol;
54
+ }>;
43
55
  /** The signature does not authenticate the supplied canonical bytes. */
44
56
  export declare class SignatureInvalidError extends SignatureInvalidError_base {
45
57
  }
@@ -13,16 +13,28 @@ export class SigningKeyNotFoundError extends Schema.TaggedError()("SigningKeyNot
13
13
  export class SigningKeyResolutionError extends Schema.TaggedError()("SigningKeyResolutionError", { keyId: SigningKeyIdSchema }) {
14
14
  }
15
15
  /** A resolved public key could not be parsed without exposing its contents. */
16
- export class PublicKeyParseError extends Schema.TaggedError()("PublicKeyParseError", { keyId: SigningKeyIdSchema, subject: ContentSignatureSubjectSchema }) {
16
+ export class PublicKeyParseError extends Schema.TaggedError()("PublicKeyParseError", {
17
+ keyId: SigningKeyIdSchema,
18
+ subject: ContentSignatureSubjectSchema,
19
+ }) {
17
20
  }
18
21
  /** A resolved public key is not an Ed25519 verification key. */
19
- export class PublicKeyTypeError extends Schema.TaggedError()("PublicKeyTypeError", { keyId: SigningKeyIdSchema, subject: ContentSignatureSubjectSchema }) {
22
+ export class PublicKeyTypeError extends Schema.TaggedError()("PublicKeyTypeError", {
23
+ keyId: SigningKeyIdSchema,
24
+ subject: ContentSignatureSubjectSchema,
25
+ }) {
20
26
  }
21
27
  /** Web Crypto could not complete an Ed25519 verification operation. */
22
- export class SignatureCheckError extends Schema.TaggedError()("SignatureCheckError", { keyId: SigningKeyIdSchema, subject: ContentSignatureSubjectSchema }) {
28
+ export class SignatureCheckError extends Schema.TaggedError()("SignatureCheckError", {
29
+ keyId: SigningKeyIdSchema,
30
+ subject: ContentSignatureSubjectSchema,
31
+ }) {
23
32
  }
24
33
  /** The signature does not authenticate the supplied canonical bytes. */
25
- export class SignatureInvalidError extends Schema.TaggedError()("SignatureInvalidError", { keyId: SigningKeyIdSchema, subject: ContentSignatureSubjectSchema }) {
34
+ export class SignatureInvalidError extends Schema.TaggedError()("SignatureInvalidError", {
35
+ keyId: SigningKeyIdSchema,
36
+ subject: ContentSignatureSubjectSchema,
37
+ }) {
26
38
  }
27
39
  /** Server-side trust seam for resolving reviewed Ed25519 public keys. */
28
40
  export class ContentVerificationKeyResolver extends Context.Service()("@nakafa/aksara-contracts/signature/spec/ContentVerificationKeyResolver") {