@nakafa/aksara-contracts 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/projection/digest.d.ts +35 -35
- package/dist/projection/verify.d.ts +87 -87
- package/dist/quran/snapshot/row/hash.d.ts +50 -50
- package/dist/release/result/digest.d.ts +4 -4
- package/dist/release/snapshot/verify.d.ts +21 -21
- package/dist/runtime/verify.d.ts +54 -54
- package/dist/transport/request.d.ts +90 -90
- package/dist/transport/response.d.ts +138 -138
- package/dist/tryout/catalog-hash.d.ts +18 -18
- package/package.json +1 -28
- package/dist/adoption/protected.d.ts +0 -125
- package/dist/adoption/protected.js +0 -70
- package/dist/adoption/public.d.ts +0 -619
- package/dist/adoption/public.js +0 -121
- package/dist/adoption/runtime.d.ts +0 -1297
- package/dist/adoption/runtime.js +0 -40
- package/dist/adoption/schema.d.ts +0 -3794
- package/dist/adoption/schema.js +0 -125
- package/dist/adoption/transport.d.ts +0 -23257
- package/dist/adoption/transport.js +0 -74
- package/dist/adoption/verify.d.ts +0 -457
- package/dist/adoption/verify.js +0 -167
package/dist/adoption/verify.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { verifySignedContentArtifactIntegrity as verifyRetainedArtifact } from "@nakafa/aksara-retained/artifact/integrity";
|
|
2
|
-
import { verifySignedContentRelease as verifyRetainedRelease } from "@nakafa/aksara-retained/release/verify";
|
|
3
|
-
import { validateRendererManifestHash as validateRetainedRenderer } from "@nakafa/aksara-retained/renderer/manifest";
|
|
4
|
-
import { ContentVerificationKeyResolver as RetainedKeyResolver } from "@nakafa/aksara-retained/signature/spec";
|
|
5
|
-
import { verifySignedTryoutRuntimeBundle as verifyRetainedRuntime } from "@nakafa/aksara-retained/tryout/runtime/verify";
|
|
6
|
-
import { Effect, Schema } from "effect";
|
|
7
|
-
import { ContentReleaseBundleSchema, RendererManifestEnvelopeSchema, RetainedRendererComponentUnsupportedError, RollbackContentReleaseBundleSchema, SignedContentArtifactSchema, SignedContentReleaseSchema, } from "#contracts/adoption/schema";
|
|
8
|
-
import { verifySignedContentArtifactIntegrity as verifyCurrentArtifact } from "#contracts/artifact/integrity";
|
|
9
|
-
import { ArtifactCompiledByteLengthMismatchError as CurrentArtifactCompiledByteLengthMismatchError, ArtifactHashComputationError as CurrentArtifactHashComputationError, ArtifactHashMismatchError as CurrentArtifactHashMismatchError, ArtifactPayloadFieldByteLimitError as CurrentArtifactPayloadFieldByteLimitError, ArtifactRendererComponentMissingError as CurrentArtifactRendererComponentMissingError, ArtifactRendererDomainUnpublishedError as CurrentArtifactRendererDomainUnpublishedError, ArtifactSourceHashComputationError as CurrentArtifactSourceHashComputationError, ArtifactSourceHashMismatchError as CurrentArtifactSourceHashMismatchError, ArtifactVerificationByteLimitError as CurrentArtifactVerificationByteLimitError, ArtifactVerificationDecodeError as CurrentArtifactVerificationDecodeError, } from "#contracts/artifact/spec";
|
|
10
|
-
import { SignedContentArtifactSchema as CurrentArtifactSchema } from "#contracts/content";
|
|
11
|
-
import { decodeContract } from "#contracts/decode";
|
|
12
|
-
import { ContractDecodeError } from "#contracts/errors";
|
|
13
|
-
import { ReleaseHashComputationError } from "#contracts/release/hash";
|
|
14
|
-
import { ReleaseBundleVerificationDecodeError as CurrentReleaseBundleVerificationDecodeError, ReleaseManifestHashMismatchError as CurrentReleaseManifestHashMismatchError, ReleaseVerificationDecodeError as CurrentReleaseVerificationDecodeError, verifySignedContentRelease as verifyCurrentSignedContentRelease, } from "#contracts/release/verify";
|
|
15
|
-
import { RendererManifestHashComputeError as CurrentRendererManifestHashComputeError, RendererManifestHashMismatchError as CurrentRendererManifestHashMismatchError, } from "#contracts/renderer/contract";
|
|
16
|
-
import { validateRendererManifestHash as validateCurrentRenderer } from "#contracts/renderer/manifest";
|
|
17
|
-
import { ContentVerificationKeyResolver as CurrentContentVerificationKeyResolver, PublicKeyParseError as CurrentPublicKeyParseError, PublicKeyTypeError as CurrentPublicKeyTypeError, SignatureCheckError as CurrentSignatureCheckError, SignatureInvalidError as CurrentSignatureInvalidError, SigningKeyNotFoundError as CurrentSigningKeyNotFoundError, SigningKeyResolutionError as CurrentSigningKeyResolutionError, } from "#contracts/signature/spec";
|
|
18
|
-
import { TryoutRuntimeBundleHashComputationError } from "#contracts/tryout/runtime/hash";
|
|
19
|
-
import { TryoutRuntimeBundleHashMismatchError as CurrentTryoutRuntimeBundleHashMismatchError, TryoutRuntimeBundleRendererMismatchError as CurrentTryoutRuntimeBundleRendererMismatchError, TryoutRuntimeBundleSnapshotMismatchError as CurrentTryoutRuntimeBundleSnapshotMismatchError, TryoutRuntimeBundleVerificationDecodeError as CurrentTryoutRuntimeBundleVerificationDecodeError, verifySignedTryoutRuntimeBundle as verifyCurrentSignedTryoutRuntimeBundle, } from "#contracts/tryout/runtime/verify";
|
|
20
|
-
const RetainedFailureSchema = Schema.Union([
|
|
21
|
-
CurrentArtifactHashComputationError,
|
|
22
|
-
CurrentArtifactHashMismatchError,
|
|
23
|
-
CurrentArtifactVerificationDecodeError,
|
|
24
|
-
CurrentArtifactVerificationByteLimitError,
|
|
25
|
-
CurrentArtifactCompiledByteLengthMismatchError,
|
|
26
|
-
CurrentArtifactPayloadFieldByteLimitError,
|
|
27
|
-
CurrentArtifactSourceHashComputationError,
|
|
28
|
-
CurrentArtifactSourceHashMismatchError,
|
|
29
|
-
CurrentSigningKeyNotFoundError,
|
|
30
|
-
CurrentSigningKeyResolutionError,
|
|
31
|
-
CurrentPublicKeyParseError,
|
|
32
|
-
CurrentPublicKeyTypeError,
|
|
33
|
-
CurrentSignatureCheckError,
|
|
34
|
-
CurrentSignatureInvalidError,
|
|
35
|
-
CurrentReleaseVerificationDecodeError,
|
|
36
|
-
CurrentReleaseManifestHashMismatchError,
|
|
37
|
-
CurrentRendererManifestHashComputeError,
|
|
38
|
-
CurrentRendererManifestHashMismatchError,
|
|
39
|
-
CurrentTryoutRuntimeBundleVerificationDecodeError,
|
|
40
|
-
CurrentTryoutRuntimeBundleHashMismatchError,
|
|
41
|
-
CurrentTryoutRuntimeBundleSnapshotMismatchError,
|
|
42
|
-
CurrentTryoutRuntimeBundleRendererMismatchError,
|
|
43
|
-
ContractDecodeError,
|
|
44
|
-
ReleaseHashComputationError,
|
|
45
|
-
TryoutRuntimeBundleHashComputationError,
|
|
46
|
-
]);
|
|
47
|
-
/** Reconstitutes current tagged errors at the temporary published-package seam. */
|
|
48
|
-
const failRetained = Effect.fn("AksaraContracts.adoption.failRetained")((error) => Schema.decodeUnknownEffect(RetainedFailureSchema)(error).pipe(Effect.orDie, Effect.flatMap(Effect.fail)));
|
|
49
|
-
/** Authenticates original bytes before inspecting any execution capability. */
|
|
50
|
-
export const verifySignedContentArtifactIntegrity = Effect.fn("AksaraContracts.adoption.verifyArtifactIntegrity")(function* (input) {
|
|
51
|
-
const artifact = yield* Schema.decodeUnknownEffect(SignedContentArtifactSchema)(input, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new CurrentArtifactVerificationDecodeError({
|
|
52
|
-
message: "Artifact verification input does not satisfy its exact wire contract.",
|
|
53
|
-
})));
|
|
54
|
-
if (Schema.is(CurrentArtifactSchema)(artifact)) {
|
|
55
|
-
return yield* verifyCurrentArtifact(artifact);
|
|
56
|
-
}
|
|
57
|
-
const resolver = yield* CurrentContentVerificationKeyResolver;
|
|
58
|
-
return yield* verifyRetainedArtifact(artifact).pipe(Effect.provideService(RetainedKeyResolver, resolver), Effect.catch(failRetained));
|
|
59
|
-
});
|
|
60
|
-
/** Selects unsigned execution names only after the caller authenticates bytes. */
|
|
61
|
-
export const selectVerifiedArtifactRenderer = Effect.fn("AksaraContracts.adoption.selectVerifiedArtifactRenderer")(function* (artifact) {
|
|
62
|
-
if (Schema.is(CurrentArtifactSchema)(artifact)) {
|
|
63
|
-
return artifact.payload;
|
|
64
|
-
}
|
|
65
|
-
for (const component of artifact.payload.requiredComponents) {
|
|
66
|
-
if (component.version !== 1) {
|
|
67
|
-
return yield* new RetainedRendererComponentUnsupportedError({
|
|
68
|
-
componentName: component.name,
|
|
69
|
-
contentKey: artifact.payload.contentKey,
|
|
70
|
-
version: component.version,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
contentKey: artifact.payload.contentKey,
|
|
76
|
-
rendererDomain: artifact.payload.rendererDomain,
|
|
77
|
-
requiredComponents: artifact.payload.requiredComponents.map(({ name }) => name),
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
/** Verifies each renderer with its exact published canonicalizer. */
|
|
81
|
-
export const validateRendererManifestHash = Effect.fn("AksaraContracts.adoption.validateRenderer")(function* (input) {
|
|
82
|
-
const renderer = yield* decodeContract(RendererManifestEnvelopeSchema, "RendererManifestEnvelope", input);
|
|
83
|
-
if (renderer.format === "nakafa-mdx-renderer") {
|
|
84
|
-
return yield* validateCurrentRenderer(renderer);
|
|
85
|
-
}
|
|
86
|
-
return yield* validateRetainedRenderer(renderer).pipe(Effect.catch(failRetained));
|
|
87
|
-
});
|
|
88
|
-
/** Verifies an independently signed artifact against an authenticated renderer. */
|
|
89
|
-
export const verifySignedContentArtifact = Effect.fn("AksaraContracts.adoption.verifyArtifact")(function* (input) {
|
|
90
|
-
const request = yield* Schema.decodeUnknownEffect(Schema.Struct({
|
|
91
|
-
artifact: SignedContentArtifactSchema,
|
|
92
|
-
rendererManifest: RendererManifestEnvelopeSchema,
|
|
93
|
-
}))(input, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new CurrentArtifactVerificationDecodeError({
|
|
94
|
-
message: "Artifact verification input does not satisfy its exact wire contract.",
|
|
95
|
-
})));
|
|
96
|
-
const artifact = yield* verifySignedContentArtifactIntegrity(request.artifact);
|
|
97
|
-
const selection = yield* selectVerifiedArtifactRenderer(artifact);
|
|
98
|
-
const renderer = yield* validateRendererManifestHash(request.rendererManifest);
|
|
99
|
-
if (!renderer.publishedDomains.includes(selection.rendererDomain)) {
|
|
100
|
-
return yield* new CurrentArtifactRendererDomainUnpublishedError({
|
|
101
|
-
contentKey: selection.contentKey,
|
|
102
|
-
rendererDomain: selection.rendererDomain,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
const available = renderer.format === "nakafa-mdx-renderer"
|
|
106
|
-
? [
|
|
107
|
-
...renderer.base,
|
|
108
|
-
...renderer.domains
|
|
109
|
-
.filter(({ name }) => name === selection.rendererDomain)
|
|
110
|
-
.flatMap(({ components }) => components),
|
|
111
|
-
]
|
|
112
|
-
: [
|
|
113
|
-
...renderer.base.supportedComponents,
|
|
114
|
-
...renderer.domains
|
|
115
|
-
.filter(({ name }) => name === selection.rendererDomain)
|
|
116
|
-
.flatMap(({ supportedComponents }) => supportedComponents),
|
|
117
|
-
]
|
|
118
|
-
.filter(({ version }) => version === 1)
|
|
119
|
-
.map(({ name }) => name);
|
|
120
|
-
for (const name of selection.requiredComponents) {
|
|
121
|
-
if (!available.includes(name)) {
|
|
122
|
-
return yield* new CurrentArtifactRendererComponentMissingError({
|
|
123
|
-
componentName: name,
|
|
124
|
-
contentKey: selection.contentKey,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return artifact;
|
|
129
|
-
});
|
|
130
|
-
/** Authenticates old and current release envelopes without rewriting manifests. */
|
|
131
|
-
export const verifySignedContentRelease = Effect.fn("AksaraContracts.adoption.verifyRelease")(function* (input) {
|
|
132
|
-
const release = yield* Schema.decodeUnknownEffect(SignedContentReleaseSchema)(input, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new CurrentReleaseVerificationDecodeError({
|
|
133
|
-
message: "Release verification input does not satisfy its exact wire contract.",
|
|
134
|
-
})));
|
|
135
|
-
if (!("rendererContractVersion" in release.manifest)) {
|
|
136
|
-
return yield* verifyCurrentSignedContentRelease(release);
|
|
137
|
-
}
|
|
138
|
-
const resolver = yield* CurrentContentVerificationKeyResolver;
|
|
139
|
-
return yield* verifyRetainedRelease(release).pipe(Effect.provideService(RetainedKeyResolver, resolver), Effect.catch(failRetained));
|
|
140
|
-
});
|
|
141
|
-
/** Authenticates release and renderer independently, retaining exact hash binding. */
|
|
142
|
-
export const verifyContentReleaseBundle = Effect.fn("AksaraContracts.adoption.verifyBundle")(function* (input) {
|
|
143
|
-
const bundle = yield* Schema.decodeUnknownEffect(ContentReleaseBundleSchema)(input, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new CurrentReleaseBundleVerificationDecodeError({
|
|
144
|
-
message: "Release bundle verification input does not satisfy its exact wire contract.",
|
|
145
|
-
})));
|
|
146
|
-
yield* verifySignedContentRelease(bundle.release);
|
|
147
|
-
yield* validateRendererManifestHash(bundle.rendererManifest);
|
|
148
|
-
return bundle;
|
|
149
|
-
});
|
|
150
|
-
/** Authenticates a renderer-bound inverse from either encoding before recovery. */
|
|
151
|
-
export const verifyRollbackContentReleaseBundle = Effect.fn("AksaraContracts.adoption.verifyRollbackBundle")(function* (input) {
|
|
152
|
-
const bundle = yield* Schema.decodeUnknownEffect(RollbackContentReleaseBundleSchema)(input, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new CurrentReleaseBundleVerificationDecodeError({
|
|
153
|
-
message: "Release bundle verification input does not satisfy its exact wire contract.",
|
|
154
|
-
})));
|
|
155
|
-
yield* verifySignedContentRelease(bundle.release);
|
|
156
|
-
yield* validateRendererManifestHash(bundle.rendererManifest);
|
|
157
|
-
return bundle;
|
|
158
|
-
});
|
|
159
|
-
/** Keeps permanent runtime bundles bound to their exact frozen renderer hash. */
|
|
160
|
-
export const verifySignedTryoutRuntimeBundle = Effect.fn("AksaraContracts.adoption.verifyRuntimeBundle")(function* (input) {
|
|
161
|
-
const renderer = yield* validateRendererManifestHash(input.rendererManifest);
|
|
162
|
-
if (renderer.format === "nakafa-mdx-renderer") {
|
|
163
|
-
return yield* verifyCurrentSignedTryoutRuntimeBundle(input);
|
|
164
|
-
}
|
|
165
|
-
const resolver = yield* CurrentContentVerificationKeyResolver;
|
|
166
|
-
return yield* verifyRetainedRuntime(input).pipe(Effect.provideService(RetainedKeyResolver, resolver), Effect.catch(failRetained));
|
|
167
|
-
});
|