@nakafa/aksara-contracts 0.50.0 → 0.51.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/dist/artifact/integrity.d.ts +15 -2
- package/dist/artifact/integrity.js +3 -15
- package/dist/artifact/limits.js +3 -4
- package/dist/artifact/source.js +4 -8
- package/dist/artifact/spec.d.ts +30 -10
- package/dist/assessment/hash.d.ts +3 -1
- package/dist/assessment/paper.d.ts +3 -1
- package/dist/errors.d.ts +3 -1
- package/dist/graph/family.d.ts +6 -2
- package/dist/graph/identity.d.ts +3 -1
- package/dist/hash/digest.d.ts +10 -0
- package/dist/hash/digest.js +40 -0
- package/dist/hash/stream.d.ts +12 -0
- package/dist/hash/stream.js +27 -0
- package/dist/hash/text.d.ts +3 -1
- package/dist/hash/text.js +2 -15
- package/dist/preview/auth.d.ts +4 -2
- package/dist/preview/auth.js +26 -12
- package/dist/program/snapshot/digest.d.ts +3 -1
- package/dist/program/snapshot/digest.js +14 -22
- package/dist/program/snapshot/hash.d.ts +6 -2
- package/dist/program/snapshot/hash.js +10 -21
- package/dist/projection/digest.d.ts +11 -9
- package/dist/projection/digest.js +23 -32
- package/dist/projection/hash.d.ts +222 -2
- package/dist/projection/hash.js +6 -8
- package/dist/projection/verify.d.ts +16 -6
- package/dist/question/item.d.ts +3 -1
- package/dist/question/item.js +3 -1
- package/dist/quran/notes.d.ts +3 -1
- package/dist/quran/provenance.d.ts +6 -2
- package/dist/quran/provenance.js +8 -15
- package/dist/quran/snapshot/digest.d.ts +9 -5
- package/dist/quran/snapshot/digest.js +33 -41
- package/dist/quran/snapshot/hash.d.ts +3 -1
- package/dist/quran/snapshot/hash.js +9 -15
- package/dist/quran/snapshot/row/hash.d.ts +3 -1
- package/dist/quran/snapshot/row/hash.js +2 -8
- package/dist/release/digest.d.ts +10 -8
- package/dist/release/digest.js +22 -31
- package/dist/release/hash.d.ts +3 -1
- package/dist/release/hash.js +3 -8
- package/dist/release/items.d.ts +25 -9
- package/dist/release/items.js +12 -3
- package/dist/release/policy.d.ts +3 -1
- package/dist/release/result/digest.d.ts +23 -13
- package/dist/release/result/digest.js +20 -29
- package/dist/release/rollback/digest.d.ts +16 -10
- package/dist/release/rollback/digest.js +25 -32
- package/dist/release/route/digest.d.ts +10 -8
- package/dist/release/route/digest.js +22 -31
- package/dist/release/route/verify.d.ts +16 -6
- package/dist/release/route/verify.js +8 -2
- package/dist/release/snapshot/evidence/requirement.d.ts +3 -1
- package/dist/release/snapshot/evidence/tryout.d.ts +1 -1
- package/dist/release/snapshot/evidence/tryout.js +1 -1
- package/dist/release/snapshot/evidence.d.ts +1 -1
- package/dist/release/snapshot/verify.d.ts +19 -7
- package/dist/release/snapshot/verify.js +20 -18
- package/dist/release/verify.d.ts +9 -3
- package/dist/renderer/compatibility.d.ts +6 -2
- package/dist/renderer/compatibility.js +3 -1
- package/dist/renderer/contract.d.ts +9 -3
- package/dist/renderer/contract.js +3 -1
- package/dist/runtime/error.d.ts +3 -1
- package/dist/runtime/protected/verify.d.ts +1 -1
- package/dist/runtime/verify.d.ts +2 -2
- package/dist/runtime/verify.js +2 -1
- package/dist/signature/key.d.ts +21 -0
- package/dist/signature/key.js +104 -0
- package/dist/signature/spec.d.ts +18 -6
- package/dist/signature/spec.js +16 -4
- package/dist/transport/request.d.ts +728 -728
- package/dist/transport/response.d.ts +26 -26
- package/dist/tryout/canonical.d.ts +11 -1
- package/dist/tryout/canonical.js +6 -10
- package/dist/tryout/closure/accounting.d.ts +3 -1
- package/dist/tryout/digest.d.ts +12 -6
- package/dist/tryout/digest.js +21 -14
- package/dist/tryout/hash/catalog.d.ts +228 -3
- package/dist/tryout/hash/catalog.js +5 -7
- package/dist/tryout/hash/content.d.ts +113 -2
- package/dist/tryout/hash/content.js +10 -8
- package/dist/tryout/hash/placement.d.ts +236 -5
- package/dist/tryout/hash/placement.js +7 -8
- package/dist/tryout/runtime/hash.d.ts +3 -1
- package/dist/tryout/runtime/hash.js +3 -1
- package/dist/tryout/runtime/source.d.ts +3 -1
- package/dist/tryout/runtime/verify.d.ts +13 -5
- package/dist/tryout/runtime/verify.js +1 -1
- package/dist/tryout/scoring.d.ts +3 -1
- package/dist/tryout/snapshot/hash.d.ts +45 -4
- package/dist/tryout/snapshot/hash.js +9 -7
- package/package.json +18 -2
package/dist/release/verify.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { type ContentReleaseBundle, type RollbackContentReleaseBundle } from "#contracts/release/lifecycle";
|
|
3
3
|
declare const ReleaseVerificationDecodeError_base: Schema.Class<ReleaseVerificationDecodeError, Schema.TaggedStruct<"ReleaseVerificationDecodeError", {
|
|
4
4
|
readonly message: Schema.Literal<"Release verification input does not satisfy its exact wire contract.">;
|
|
5
|
-
}>, import("effect/Cause").YieldableError
|
|
5
|
+
}>, import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly brand: unique symbol;
|
|
7
|
+
}>;
|
|
6
8
|
/** Unknown release input did not exactly satisfy its signed wire contract. */
|
|
7
9
|
export declare class ReleaseVerificationDecodeError extends ReleaseVerificationDecodeError_base {
|
|
8
10
|
}
|
|
@@ -10,13 +12,17 @@ declare const ReleaseManifestHashMismatchError_base: Schema.Class<ReleaseManifes
|
|
|
10
12
|
readonly actualHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
11
13
|
readonly expectedHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
12
14
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
13
|
-
}>, import("effect/Cause").YieldableError
|
|
15
|
+
}>, import("effect/Cause").YieldableError & {
|
|
16
|
+
readonly brand: unique symbol;
|
|
17
|
+
}>;
|
|
14
18
|
/** The envelope hash does not identify its complete canonical manifest. */
|
|
15
19
|
export declare class ReleaseManifestHashMismatchError extends ReleaseManifestHashMismatchError_base {
|
|
16
20
|
}
|
|
17
21
|
declare const ReleaseBundleVerificationDecodeError_base: Schema.Class<ReleaseBundleVerificationDecodeError, Schema.TaggedStruct<"ReleaseBundleVerificationDecodeError", {
|
|
18
22
|
readonly message: Schema.Literal<"Release bundle verification input does not satisfy its exact wire contract.">;
|
|
19
|
-
}>, import("effect/Cause").YieldableError
|
|
23
|
+
}>, import("effect/Cause").YieldableError & {
|
|
24
|
+
readonly brand: unique symbol;
|
|
25
|
+
}>;
|
|
20
26
|
/** Stored release recovery input does not satisfy its exact bundle contract. */
|
|
21
27
|
export declare class ReleaseBundleVerificationDecodeError extends ReleaseBundleVerificationDecodeError_base {
|
|
22
28
|
}
|
|
@@ -4,14 +4,18 @@ import type { CompiledContentPayload } from "#contracts/content";
|
|
|
4
4
|
import { type RendererManifestEnvelope } from "#contracts/renderer/contract";
|
|
5
5
|
declare const RendererManifestDomainUnpublishedError_base: Schema.Class<RendererManifestDomainUnpublishedError, Schema.TaggedStruct<"RendererManifestDomainUnpublishedError", {
|
|
6
6
|
readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
|
|
7
|
-
}>, import("effect/Cause").YieldableError
|
|
7
|
+
}>, import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly brand: unique symbol;
|
|
9
|
+
}>;
|
|
8
10
|
/** A live renderer no longer publishes one domain frozen by a signed release. */
|
|
9
11
|
export declare class RendererManifestDomainUnpublishedError extends RendererManifestDomainUnpublishedError_base {
|
|
10
12
|
}
|
|
11
13
|
declare const RendererManifestComponentUnsupportedError_base: Schema.Class<RendererManifestComponentUnsupportedError, Schema.TaggedStruct<"RendererManifestComponentUnsupportedError", {
|
|
12
14
|
readonly componentName: Schema.String;
|
|
13
15
|
readonly rendererScope: Schema.Union<readonly [Schema.Literal<"base">, Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>]>;
|
|
14
|
-
}>, import("effect/Cause").YieldableError
|
|
16
|
+
}>, import("effect/Cause").YieldableError & {
|
|
17
|
+
readonly brand: unique symbol;
|
|
18
|
+
}>;
|
|
15
19
|
/** A live renderer no longer supports one required frozen renderer name. */
|
|
16
20
|
export declare class RendererManifestComponentUnsupportedError extends RendererManifestComponentUnsupportedError_base {
|
|
17
21
|
}
|
|
@@ -9,7 +9,9 @@ const RendererCapabilityScopeSchema = Schema.Union([
|
|
|
9
9
|
RendererDomainSchema,
|
|
10
10
|
]);
|
|
11
11
|
/** A live renderer no longer publishes one domain frozen by a signed release. */
|
|
12
|
-
export class RendererManifestDomainUnpublishedError extends Schema.TaggedError()("RendererManifestDomainUnpublishedError", {
|
|
12
|
+
export class RendererManifestDomainUnpublishedError extends Schema.TaggedError()("RendererManifestDomainUnpublishedError", {
|
|
13
|
+
rendererDomain: RendererDomainSchema,
|
|
14
|
+
}) {
|
|
13
15
|
}
|
|
14
16
|
/** A live renderer no longer supports one required frozen renderer name. */
|
|
15
17
|
export class RendererManifestComponentUnsupportedError extends Schema.TaggedError()("RendererManifestComponentUnsupportedError", {
|
|
@@ -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", {
|
|
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) {
|
package/dist/runtime/error.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -74,4 +74,4 @@ export declare const verifyProtectedContentRuntimeExchange: (input: {
|
|
|
74
74
|
} | {
|
|
75
75
|
readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
|
|
76
76
|
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>;
|
|
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/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>;
|
package/dist/runtime/verify.d.ts
CHANGED
|
@@ -198,7 +198,7 @@ export declare const verifyContentRuntimeEvidenceExchange: (input: {
|
|
|
198
198
|
} | {
|
|
199
199
|
readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
|
|
200
200
|
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>;
|
|
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 | 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
202
|
/**
|
|
203
203
|
* Verifies independently signed runtime values selected for one exact request.
|
|
204
204
|
*
|
|
@@ -398,4 +398,4 @@ export declare const verifyContentRuntimeExchange: (input: {
|
|
|
398
398
|
} | {
|
|
399
399
|
readonly code: "CONTENT_RUNTIME_INTERNAL" | "CONTENT_RUNTIME_INVALID" | "CONTENT_RUNTIME_RESPONSE_TOO_LARGE" | "CONTENT_RUNTIME_UNAUTHORIZED";
|
|
400
400
|
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>;
|
|
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 | 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>;
|
package/dist/runtime/verify.js
CHANGED
|
@@ -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
|
-
|
|
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
|
+
});
|
package/dist/signature/spec.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/signature/spec.js
CHANGED
|
@@ -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", {
|
|
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", {
|
|
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", {
|
|
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", {
|
|
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") {
|