@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.
- package/LICENSE +207 -152
- package/README.md +3 -0
- package/dist/artifact/integrity.d.ts +33 -8
- package/dist/artifact/integrity.js +19 -17
- package/dist/artifact/limits.d.ts +13 -7
- package/dist/artifact/limits.js +7 -15
- package/dist/artifact/source.d.ts +10 -4
- package/dist/artifact/source.js +4 -8
- package/dist/artifact/spec.d.ts +54 -22
- package/dist/artifact/spec.js +7 -8
- package/dist/artifact/verify.d.ts +11 -5
- package/dist/assessment/hash.d.ts +3 -1
- package/dist/assessment/paper.d.ts +3 -1
- package/dist/content.d.ts +37 -11
- package/dist/content.js +7 -21
- 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/limits.d.ts +2 -2
- package/dist/limits.js +2 -2
- 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/rollback/spec.d.ts +102 -24
- 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/spec.d.ts +61 -16
- package/dist/runtime/protected/verify.d.ts +11 -5
- package/dist/runtime/spec.d.ts +44 -12
- package/dist/runtime/verify.d.ts +22 -10
- package/dist/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/batch.d.ts +34 -8
- package/dist/transport/group.d.ts +51 -12
- package/dist/transport/request.d.ts +826 -764
- package/dist/transport/response.d.ts +148 -58
- package/dist/tree.d.ts +52 -0
- package/dist/tree.js +162 -0
- 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 +22 -2
package/dist/release/items.d.ts
CHANGED
|
@@ -2,14 +2,18 @@ import { Effect, Schema, Stream } from "effect";
|
|
|
2
2
|
import { type ContentReleaseManifest } from "#contracts/release/spec";
|
|
3
3
|
declare const ReleaseItemDecodeError_base: Schema.Class<ReleaseItemDecodeError, Schema.TaggedStruct<"ReleaseItemDecodeError", {
|
|
4
4
|
readonly itemOffset: Schema.Finite;
|
|
5
|
-
}>, import("effect/Cause").YieldableError
|
|
5
|
+
}>, import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly brand: unique symbol;
|
|
7
|
+
}>;
|
|
6
8
|
/** One release item failed strict wire decoding. */
|
|
7
9
|
export declare class ReleaseItemDecodeError extends ReleaseItemDecodeError_base {
|
|
8
10
|
}
|
|
9
11
|
declare const ReleaseItemCountMismatchError_base: Schema.Class<ReleaseItemCountMismatchError, Schema.TaggedStruct<"ReleaseItemCountMismatchError", {
|
|
10
12
|
readonly actualCount: Schema.Finite;
|
|
11
13
|
readonly expectedCount: Schema.Finite;
|
|
12
|
-
}>, import("effect/Cause").YieldableError
|
|
14
|
+
}>, import("effect/Cause").YieldableError & {
|
|
15
|
+
readonly brand: unique symbol;
|
|
16
|
+
}>;
|
|
13
17
|
/** The separate item stream does not have the signed manifest length. */
|
|
14
18
|
export declare class ReleaseItemCountMismatchError extends ReleaseItemCountMismatchError_base {
|
|
15
19
|
}
|
|
@@ -18,33 +22,43 @@ declare const ReleaseItemOperationCountMismatchError_base: Schema.Class<ReleaseI
|
|
|
18
22
|
readonly actualUpserts: Schema.Finite;
|
|
19
23
|
readonly expectedDeletes: Schema.Finite;
|
|
20
24
|
readonly expectedUpserts: Schema.Finite;
|
|
21
|
-
}>, import("effect/Cause").YieldableError
|
|
25
|
+
}>, import("effect/Cause").YieldableError & {
|
|
26
|
+
readonly brand: unique symbol;
|
|
27
|
+
}>;
|
|
22
28
|
/** Upsert and delete totals do not match the counts signed by the manifest. */
|
|
23
29
|
export declare class ReleaseItemOperationCountMismatchError extends ReleaseItemOperationCountMismatchError_base {
|
|
24
30
|
}
|
|
25
31
|
declare const ReleaseItemReleaseMismatchError_base: Schema.Class<ReleaseItemReleaseMismatchError, Schema.TaggedStruct<"ReleaseItemReleaseMismatchError", {
|
|
26
32
|
readonly itemOffset: Schema.Finite;
|
|
27
33
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
28
|
-
}>, import("effect/Cause").YieldableError
|
|
34
|
+
}>, import("effect/Cause").YieldableError & {
|
|
35
|
+
readonly brand: unique symbol;
|
|
36
|
+
}>;
|
|
29
37
|
/** An item belongs to another release envelope. */
|
|
30
38
|
export declare class ReleaseItemReleaseMismatchError extends ReleaseItemReleaseMismatchError_base {
|
|
31
39
|
}
|
|
32
40
|
declare const ReleaseItemIndexMismatchError_base: Schema.Class<ReleaseItemIndexMismatchError, Schema.TaggedStruct<"ReleaseItemIndexMismatchError", {
|
|
33
41
|
readonly actualIndex: Schema.Finite;
|
|
34
42
|
readonly expectedIndex: Schema.Finite;
|
|
35
|
-
}>, import("effect/Cause").YieldableError
|
|
43
|
+
}>, import("effect/Cause").YieldableError & {
|
|
44
|
+
readonly brand: unique symbol;
|
|
45
|
+
}>;
|
|
36
46
|
/** An item is missing, duplicated, or out of its signed sequence. */
|
|
37
47
|
export declare class ReleaseItemIndexMismatchError extends ReleaseItemIndexMismatchError_base {
|
|
38
48
|
}
|
|
39
49
|
declare const ReleaseItemOrderError_base: Schema.Class<ReleaseItemOrderError, Schema.TaggedStruct<"ReleaseItemOrderError", {
|
|
40
50
|
readonly itemOffset: Schema.Finite;
|
|
41
|
-
}>, import("effect/Cause").YieldableError
|
|
51
|
+
}>, import("effect/Cause").YieldableError & {
|
|
52
|
+
readonly brand: unique symbol;
|
|
53
|
+
}>;
|
|
42
54
|
/** Item heads are duplicated or not in canonical content-head order. */
|
|
43
55
|
export declare class ReleaseItemOrderError extends ReleaseItemOrderError_base {
|
|
44
56
|
}
|
|
45
57
|
declare const ReleaseItemScopeError_base: Schema.Class<ReleaseItemScopeError, Schema.TaggedStruct<"ReleaseItemScopeError", {
|
|
46
58
|
readonly itemOffset: Schema.Finite;
|
|
47
|
-
}>, import("effect/Cause").YieldableError
|
|
59
|
+
}>, import("effect/Cause").YieldableError & {
|
|
60
|
+
readonly brand: unique symbol;
|
|
61
|
+
}>;
|
|
48
62
|
/** One signed item falls outside the release's exact publication scope. */
|
|
49
63
|
export declare class ReleaseItemScopeError extends ReleaseItemScopeError_base {
|
|
50
64
|
}
|
|
@@ -52,7 +66,9 @@ declare const ReleaseItemsDigestMismatchError_base: Schema.Class<ReleaseItemsDig
|
|
|
52
66
|
readonly actualDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
53
67
|
readonly expectedDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
54
68
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
55
|
-
}>, import("effect/Cause").YieldableError
|
|
69
|
+
}>, import("effect/Cause").YieldableError & {
|
|
70
|
+
readonly brand: unique symbol;
|
|
71
|
+
}>;
|
|
56
72
|
/** The separate ordered items do not match the signed digest. */
|
|
57
73
|
export declare class ReleaseItemsDigestMismatchError extends ReleaseItemsDigestMismatchError_base {
|
|
58
74
|
}
|
|
@@ -60,7 +76,7 @@ declare const VerifiedContentReleaseItemsSchema: Schema.Struct<{
|
|
|
60
76
|
readonly deleteCount: Schema.Finite;
|
|
61
77
|
readonly upsertCount: Schema.Finite;
|
|
62
78
|
}>;
|
|
63
|
-
/** Counts derived
|
|
79
|
+
/** Counts derived from one authenticated item stream. The digest holds every canonical byte until its one final call, so its memory grows with the stream. */
|
|
64
80
|
export type VerifiedContentReleaseItems = typeof VerifiedContentReleaseItemsSchema.Type;
|
|
65
81
|
/**
|
|
66
82
|
* Strictly decodes a replayable item stream without retaining its bodies.
|
package/dist/release/items.js
CHANGED
|
@@ -9,7 +9,10 @@ import { ContentReleaseItemSchema, } from "#contracts/release/spec";
|
|
|
9
9
|
export class ReleaseItemDecodeError extends Schema.TaggedError()("ReleaseItemDecodeError", { itemOffset: ReleaseCountSchema }) {
|
|
10
10
|
}
|
|
11
11
|
/** The separate item stream does not have the signed manifest length. */
|
|
12
|
-
export class ReleaseItemCountMismatchError extends Schema.TaggedError()("ReleaseItemCountMismatchError", {
|
|
12
|
+
export class ReleaseItemCountMismatchError extends Schema.TaggedError()("ReleaseItemCountMismatchError", {
|
|
13
|
+
actualCount: ReleaseCountSchema,
|
|
14
|
+
expectedCount: ReleaseCountSchema,
|
|
15
|
+
}) {
|
|
13
16
|
}
|
|
14
17
|
/** Upsert and delete totals do not match the counts signed by the manifest. */
|
|
15
18
|
export class ReleaseItemOperationCountMismatchError extends Schema.TaggedError()("ReleaseItemOperationCountMismatchError", {
|
|
@@ -20,10 +23,16 @@ export class ReleaseItemOperationCountMismatchError extends Schema.TaggedError()
|
|
|
20
23
|
}) {
|
|
21
24
|
}
|
|
22
25
|
/** An item belongs to another release envelope. */
|
|
23
|
-
export class ReleaseItemReleaseMismatchError extends Schema.TaggedError()("ReleaseItemReleaseMismatchError", {
|
|
26
|
+
export class ReleaseItemReleaseMismatchError extends Schema.TaggedError()("ReleaseItemReleaseMismatchError", {
|
|
27
|
+
itemOffset: ReleaseCountSchema,
|
|
28
|
+
releaseId: ReleaseIdSchema,
|
|
29
|
+
}) {
|
|
24
30
|
}
|
|
25
31
|
/** An item is missing, duplicated, or out of its signed sequence. */
|
|
26
|
-
export class ReleaseItemIndexMismatchError extends Schema.TaggedError()("ReleaseItemIndexMismatchError", {
|
|
32
|
+
export class ReleaseItemIndexMismatchError extends Schema.TaggedError()("ReleaseItemIndexMismatchError", {
|
|
33
|
+
actualIndex: ReleaseCountSchema,
|
|
34
|
+
expectedIndex: ReleaseCountSchema,
|
|
35
|
+
}) {
|
|
27
36
|
}
|
|
28
37
|
/** Item heads are duplicated or not in canonical content-head order. */
|
|
29
38
|
export class ReleaseItemOrderError extends Schema.TaggedError()("ReleaseItemOrderError", { itemOffset: ReleaseCountSchema }) {
|
package/dist/release/policy.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ declare const ReleasePolicyClosureError_base: Schema.Class<ReleasePolicyClosureE
|
|
|
15
15
|
readonly expected: Schema.String;
|
|
16
16
|
readonly family: Schema.Union<readonly [Schema.Literals<readonly ["program", "quran", "tryout"]>, Schema.Literals<readonly ["article", "material", "page", "question"]>]>;
|
|
17
17
|
readonly field: Schema.Literals<readonly ["activeAppLocales", "manifest", "scope"]>;
|
|
18
|
-
}>, import("effect/Cause").YieldableError
|
|
18
|
+
}>, import("effect/Cause").YieldableError & {
|
|
19
|
+
readonly brand: unique symbol;
|
|
20
|
+
}>;
|
|
19
21
|
/** One structured scope does not close over the current release policy. */
|
|
20
22
|
export declare class ReleasePolicyClosureError extends ReleasePolicyClosureError_base {
|
|
21
23
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Effect, Schema, Stream } from "effect";
|
|
2
|
-
import { type PublicPath, type ReleaseId, Sha256HashSchema } from "#contracts/ids";
|
|
2
|
+
import { type PublicPath, type ReleaseId, type Sha256HashSchema } from "#contracts/ids";
|
|
3
3
|
import { type ArtifactLocale } from "#contracts/locale";
|
|
4
4
|
import { type ContentHead } from "#contracts/release/head";
|
|
5
5
|
declare const ResultCatalogHashError_base: Schema.Class<ResultCatalogHashError, Schema.TaggedStruct<"ResultCatalogHashError", {
|
|
6
6
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
7
|
-
}>, import("effect/Cause").YieldableError
|
|
7
|
+
}>, import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly brand: unique symbol;
|
|
9
|
+
}>;
|
|
8
10
|
/** SHA-256 computation failed before result-catalog integrity was established. */
|
|
9
11
|
export declare class ResultCatalogHashError extends ResultCatalogHashError_base {
|
|
10
12
|
}
|
|
@@ -12,7 +14,9 @@ declare const ResultCatalogOrderError_base: Schema.Class<ResultCatalogOrderError
|
|
|
12
14
|
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
13
15
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
14
16
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
15
|
-
}>, import("effect/Cause").YieldableError
|
|
17
|
+
}>, import("effect/Cause").YieldableError & {
|
|
18
|
+
readonly brand: unique symbol;
|
|
19
|
+
}>;
|
|
16
20
|
/** A result catalog is duplicated or outside canonical content-head order. */
|
|
17
21
|
export declare class ResultCatalogOrderError extends ResultCatalogOrderError_base {
|
|
18
22
|
}
|
|
@@ -21,7 +25,9 @@ declare const ResultCatalogRouteError_base: Schema.Class<ResultCatalogRouteError
|
|
|
21
25
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
22
26
|
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
23
27
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
24
|
-
}>, import("effect/Cause").YieldableError
|
|
28
|
+
}>, import("effect/Cause").YieldableError & {
|
|
29
|
+
readonly brand: unique symbol;
|
|
30
|
+
}>;
|
|
25
31
|
/** Two complete result heads claim the same locale-specific public route. */
|
|
26
32
|
export declare class ResultCatalogRouteError extends ResultCatalogRouteError_base {
|
|
27
33
|
}
|
|
@@ -29,7 +35,9 @@ declare const ResultCatalogCountMismatchError_base: Schema.Class<ResultCatalogCo
|
|
|
29
35
|
readonly actualCount: Schema.Finite;
|
|
30
36
|
readonly expectedCount: Schema.Finite;
|
|
31
37
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
32
|
-
}>, import("effect/Cause").YieldableError
|
|
38
|
+
}>, import("effect/Cause").YieldableError & {
|
|
39
|
+
readonly brand: unique symbol;
|
|
40
|
+
}>;
|
|
33
41
|
/** A replayed result catalog has a different signed head count. */
|
|
34
42
|
export declare class ResultCatalogCountMismatchError extends ResultCatalogCountMismatchError_base {
|
|
35
43
|
}
|
|
@@ -37,31 +45,33 @@ declare const ResultCatalogDigestMismatchError_base: Schema.Class<ResultCatalogD
|
|
|
37
45
|
readonly actualDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
38
46
|
readonly expectedDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
39
47
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
40
|
-
}>, import("effect/Cause").YieldableError
|
|
48
|
+
}>, import("effect/Cause").YieldableError & {
|
|
49
|
+
readonly brand: unique symbol;
|
|
50
|
+
}>;
|
|
41
51
|
/** A replayed result catalog does not match its signed digest. */
|
|
42
52
|
export declare class ResultCatalogDigestMismatchError extends ResultCatalogDigestMismatchError_base {
|
|
43
53
|
}
|
|
44
|
-
/** Keeps mutable
|
|
54
|
+
/** Keeps mutable digest and ordering state private to one catalog replay. */
|
|
45
55
|
declare class ResultCatalogDigestState {
|
|
46
56
|
#private;
|
|
47
57
|
count: number;
|
|
48
58
|
previous: ContentHead | undefined;
|
|
49
|
-
/**
|
|
59
|
+
/** Starts one domain-separated result-catalog digest. */
|
|
50
60
|
constructor();
|
|
51
61
|
/** Claims one public route and reports whether it was globally unique. */
|
|
52
62
|
claimRoute(artifactLocale: ArtifactLocale, publicPath: PublicPath): boolean;
|
|
53
63
|
/** Adds one canonical compact head and advances ordering evidence. */
|
|
54
64
|
update(head: ContentHead): void;
|
|
55
|
-
/**
|
|
56
|
-
digest(): string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
65
|
+
/** Digests the complete stream once and returns its branded immutable identity. */
|
|
66
|
+
digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, import("effect/PlatformError").PlatformError, never>;
|
|
57
67
|
}
|
|
58
68
|
/** Creates a fresh domain-separated digest state for one result catalog. */
|
|
59
|
-
export declare
|
|
69
|
+
export declare const createResultCatalogDigest: Effect.Effect<ResultCatalogDigestState, never, never>;
|
|
60
70
|
/** Adds one canonically ordered compact head to a result digest. */
|
|
61
|
-
export declare function updateResultCatalogDigest(releaseId: ReleaseId, state: ResultCatalogDigestState, head: ContentHead): Effect.Effect<ResultCatalogDigestState,
|
|
71
|
+
export declare function updateResultCatalogDigest(releaseId: ReleaseId, state: ResultCatalogDigestState, head: ContentHead): Effect.Effect<ResultCatalogDigestState, ResultCatalogOrderError | ResultCatalogRouteError>;
|
|
62
72
|
/** Finalizes one incremental result-catalog digest. */
|
|
63
73
|
export declare function finalizeResultCatalogDigest(releaseId: ReleaseId, state: ResultCatalogDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, ResultCatalogHashError, never>;
|
|
64
|
-
/** Digests one complete compact-head stream
|
|
74
|
+
/** Digests one complete compact-head stream. Its canonical bytes are held until one Web Crypto digest runs. */
|
|
65
75
|
export declare const digestResultCatalog: <E, R>(releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">, heads: Stream.Stream<{
|
|
66
76
|
readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
67
77
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { Effect, MutableHashSet, Schema, Stream } from "effect";
|
|
3
2
|
import { ContentHeadIdentitySchema, compareContentHeads, routeIdentity, } from "#contracts/content";
|
|
4
|
-
import {
|
|
3
|
+
import { DigestStream } from "#contracts/hash/stream";
|
|
4
|
+
import { PublicPathSchema, ReleaseIdSchema, } from "#contracts/ids";
|
|
5
5
|
import { AppLocaleSchema } from "#contracts/locale";
|
|
6
6
|
import { canonicalizeContentHead, } from "#contracts/release/head";
|
|
7
7
|
import { ReleaseCountMismatchFields, ReleaseDigestMismatchFields, } from "#contracts/release/mismatch";
|
|
@@ -28,16 +28,16 @@ export class ResultCatalogCountMismatchError extends Schema.TaggedError()("Resul
|
|
|
28
28
|
/** A replayed result catalog does not match its signed digest. */
|
|
29
29
|
export class ResultCatalogDigestMismatchError extends Schema.TaggedError()("ResultCatalogDigestMismatchError", { ...ReleaseDigestMismatchFields }) {
|
|
30
30
|
}
|
|
31
|
-
/** Keeps mutable
|
|
31
|
+
/** Keeps mutable digest and ordering state private to one catalog replay. */
|
|
32
32
|
class ResultCatalogDigestState {
|
|
33
|
-
#
|
|
33
|
+
#stream = new DigestStream();
|
|
34
34
|
#routes = MutableHashSet.empty();
|
|
35
35
|
count = 0;
|
|
36
36
|
previous;
|
|
37
|
-
/**
|
|
37
|
+
/** Starts one domain-separated result-catalog digest. */
|
|
38
38
|
constructor() {
|
|
39
|
-
this.#
|
|
40
|
-
this.#
|
|
39
|
+
this.#stream.add(RESULT_CATALOG_DIGEST_DOMAIN);
|
|
40
|
+
this.#stream.add("\n");
|
|
41
41
|
}
|
|
42
42
|
/** Claims one public route and reports whether it was globally unique. */
|
|
43
43
|
claimRoute(artifactLocale, publicPath) {
|
|
@@ -53,23 +53,18 @@ class ResultCatalogDigestState {
|
|
|
53
53
|
}
|
|
54
54
|
/** Adds one canonical compact head and advances ordering evidence. */
|
|
55
55
|
update(head) {
|
|
56
|
-
this.#
|
|
57
|
-
this.#
|
|
56
|
+
this.#stream.add(canonicalizeContentHead(head));
|
|
57
|
+
this.#stream.add("\n");
|
|
58
58
|
this.count += 1;
|
|
59
59
|
this.previous = head;
|
|
60
60
|
}
|
|
61
|
-
/**
|
|
61
|
+
/** Digests the complete stream once and returns its branded immutable identity. */
|
|
62
62
|
digest() {
|
|
63
|
-
return
|
|
63
|
+
return this.#stream.digest();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
/** Creates a fresh domain-separated digest state for one result catalog. */
|
|
67
|
-
export
|
|
68
|
-
return Effect.try({
|
|
69
|
-
catch: () => new ResultCatalogHashError({ releaseId }),
|
|
70
|
-
try: () => new ResultCatalogDigestState(),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
67
|
+
export const createResultCatalogDigest = Effect.sync(() => new ResultCatalogDigestState());
|
|
73
68
|
/** Adds one canonically ordered compact head to a result digest. */
|
|
74
69
|
export function updateResultCatalogDigest(releaseId, state, head) {
|
|
75
70
|
if (state.previous && compareContentHeads(state.previous, head) >= 0) {
|
|
@@ -88,24 +83,20 @@ export function updateResultCatalogDigest(releaseId, state, head) {
|
|
|
88
83
|
releaseId,
|
|
89
84
|
}));
|
|
90
85
|
}
|
|
91
|
-
return Effect.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
state.update(head);
|
|
95
|
-
return state;
|
|
96
|
-
},
|
|
86
|
+
return Effect.sync(() => {
|
|
87
|
+
state.update(head);
|
|
88
|
+
return state;
|
|
97
89
|
});
|
|
98
90
|
}
|
|
99
91
|
/** Finalizes one incremental result-catalog digest. */
|
|
100
92
|
export function finalizeResultCatalogDigest(releaseId, state) {
|
|
101
|
-
return
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
93
|
+
return state
|
|
94
|
+
.digest()
|
|
95
|
+
.pipe(Effect.mapError(() => new ResultCatalogHashError({ releaseId })));
|
|
105
96
|
}
|
|
106
|
-
/** Digests one complete compact-head stream
|
|
97
|
+
/** Digests one complete compact-head stream. Its canonical bytes are held until one Web Crypto digest runs. */
|
|
107
98
|
export const digestResultCatalog = Effect.fn("AksaraContracts.digestResultCatalog")(function* (releaseId, heads) {
|
|
108
|
-
const initial = yield* createResultCatalogDigest
|
|
99
|
+
const initial = yield* createResultCatalogDigest;
|
|
109
100
|
const state = yield* heads.pipe(Stream.runFoldEffect(() => initial, (current, head) => updateResultCatalogDigest(releaseId, current, head)));
|
|
110
101
|
const digest = yield* finalizeResultCatalogDigest(releaseId, state);
|
|
111
102
|
return { count: state.count, digest };
|
|
@@ -4,7 +4,9 @@ import { type RollbackSnapshotEntry } from "#contracts/release/rollback/spec";
|
|
|
4
4
|
import type { ContentReleaseManifest } from "#contracts/release/spec";
|
|
5
5
|
declare const RollbackSnapshotHashError_base: Schema.Class<RollbackSnapshotHashError, Schema.TaggedStruct<"RollbackSnapshotHashError", {
|
|
6
6
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
7
|
-
}>, import("effect/Cause").YieldableError
|
|
7
|
+
}>, import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly brand: unique symbol;
|
|
9
|
+
}>;
|
|
8
10
|
/** SHA-256 computation failed before rollback-state integrity was established. */
|
|
9
11
|
export declare class RollbackSnapshotHashError extends RollbackSnapshotHashError_base {
|
|
10
12
|
}
|
|
@@ -12,7 +14,9 @@ declare const RollbackSnapshotCountMismatchError_base: Schema.Class<RollbackSnap
|
|
|
12
14
|
readonly actualCount: Schema.Finite;
|
|
13
15
|
readonly expectedCount: Schema.Finite;
|
|
14
16
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
15
|
-
}>, import("effect/Cause").YieldableError
|
|
17
|
+
}>, import("effect/Cause").YieldableError & {
|
|
18
|
+
readonly brand: unique symbol;
|
|
19
|
+
}>;
|
|
16
20
|
/** A replayed rollback snapshot has a different signed entry count. */
|
|
17
21
|
export declare class RollbackSnapshotCountMismatchError extends RollbackSnapshotCountMismatchError_base {
|
|
18
22
|
}
|
|
@@ -20,28 +24,30 @@ declare const RollbackSnapshotDigestMismatchError_base: Schema.Class<RollbackSna
|
|
|
20
24
|
readonly actualDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
21
25
|
readonly expectedDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
22
26
|
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
23
|
-
}>, import("effect/Cause").YieldableError
|
|
27
|
+
}>, import("effect/Cause").YieldableError & {
|
|
28
|
+
readonly brand: unique symbol;
|
|
29
|
+
}>;
|
|
24
30
|
/** A replayed rollback snapshot does not match its signed digest. */
|
|
25
31
|
export declare class RollbackSnapshotDigestMismatchError extends RollbackSnapshotDigestMismatchError_base {
|
|
26
32
|
}
|
|
27
|
-
/** Keeps
|
|
33
|
+
/** Keeps the digest stream private behind the incremental digest seam. */
|
|
28
34
|
declare class RollbackSnapshotDigestState {
|
|
29
35
|
#private;
|
|
30
36
|
count: number;
|
|
31
|
-
/**
|
|
37
|
+
/** Starts one domain-separated rollback snapshot digest. */
|
|
32
38
|
constructor();
|
|
33
39
|
/** Adds one canonical prior state to the snapshot digest. */
|
|
34
40
|
update(entry: RollbackSnapshotEntry): void;
|
|
35
|
-
/**
|
|
36
|
-
digest(): string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
41
|
+
/** Digests the complete stream once and returns its branded immutable identity. */
|
|
42
|
+
digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, import("effect/PlatformError").PlatformError, never>;
|
|
37
43
|
}
|
|
38
44
|
/** Creates a fresh domain-separated digest state for one rollback snapshot. */
|
|
39
|
-
export declare
|
|
45
|
+
export declare const createRollbackSnapshotDigest: Effect.Effect<RollbackSnapshotDigestState, never, never>;
|
|
40
46
|
/** Adds one canonical prior state to an incremental rollback digest. */
|
|
41
|
-
export declare function updateRollbackSnapshotDigest(
|
|
47
|
+
export declare function updateRollbackSnapshotDigest(state: RollbackSnapshotDigestState, entry: RollbackSnapshotEntry): Effect.Effect<RollbackSnapshotDigestState, never, never>;
|
|
42
48
|
/** Finalizes one rollback snapshot digest with a typed hash failure. */
|
|
43
49
|
export declare function finalizeRollbackSnapshotDigest(releaseId: ReleaseId, state: RollbackSnapshotDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, RollbackSnapshotHashError, never>;
|
|
44
|
-
/** Digests one rollback snapshot stream
|
|
50
|
+
/** Digests one rollback snapshot stream. Its canonical bytes are held until one Web Crypto digest runs. */
|
|
45
51
|
export declare const digestRollbackSnapshot: <E, R>(releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">, entries: Stream.Stream<{
|
|
46
52
|
readonly index: number;
|
|
47
53
|
readonly releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { Effect, Schema, Stream } from "effect";
|
|
3
|
-
import {
|
|
2
|
+
import { DigestStream } from "#contracts/hash/stream";
|
|
3
|
+
import { ReleaseIdSchema } from "#contracts/ids";
|
|
4
4
|
import { ReleaseCountMismatchFields, ReleaseDigestMismatchFields, } from "#contracts/release/mismatch";
|
|
5
5
|
import { canonicalizeRollbackSnapshotEntry, } from "#contracts/release/rollback/spec";
|
|
6
6
|
const ROLLBACK_SNAPSHOT_DIGEST_DOMAIN = "nakafa.aksara.rollback-snapshot";
|
|
@@ -11,56 +11,49 @@ export class RollbackSnapshotHashError extends Schema.TaggedError()("RollbackSna
|
|
|
11
11
|
export class RollbackSnapshotCountMismatchError extends Schema.TaggedError()("RollbackSnapshotCountMismatchError", { ...ReleaseCountMismatchFields }) {
|
|
12
12
|
}
|
|
13
13
|
/** A replayed rollback snapshot does not match its signed digest. */
|
|
14
|
-
export class RollbackSnapshotDigestMismatchError extends Schema.TaggedError()("RollbackSnapshotDigestMismatchError", {
|
|
14
|
+
export class RollbackSnapshotDigestMismatchError extends Schema.TaggedError()("RollbackSnapshotDigestMismatchError", {
|
|
15
|
+
...ReleaseDigestMismatchFields,
|
|
16
|
+
}) {
|
|
15
17
|
}
|
|
16
|
-
/** Keeps
|
|
18
|
+
/** Keeps the digest stream private behind the incremental digest seam. */
|
|
17
19
|
class RollbackSnapshotDigestState {
|
|
18
|
-
#
|
|
20
|
+
#stream = new DigestStream();
|
|
19
21
|
count = 0;
|
|
20
|
-
/**
|
|
22
|
+
/** Starts one domain-separated rollback snapshot digest. */
|
|
21
23
|
constructor() {
|
|
22
|
-
this.#
|
|
23
|
-
this.#
|
|
24
|
+
this.#stream.add(ROLLBACK_SNAPSHOT_DIGEST_DOMAIN);
|
|
25
|
+
this.#stream.add("\n");
|
|
24
26
|
}
|
|
25
27
|
/** Adds one canonical prior state to the snapshot digest. */
|
|
26
28
|
update(entry) {
|
|
27
|
-
this.#
|
|
28
|
-
this.#
|
|
29
|
+
this.#stream.add(canonicalizeRollbackSnapshotEntry(entry));
|
|
30
|
+
this.#stream.add("\n");
|
|
29
31
|
this.count += 1;
|
|
30
32
|
}
|
|
31
|
-
/**
|
|
33
|
+
/** Digests the complete stream once and returns its branded immutable identity. */
|
|
32
34
|
digest() {
|
|
33
|
-
return
|
|
35
|
+
return this.#stream.digest();
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
/** Creates a fresh domain-separated digest state for one rollback snapshot. */
|
|
37
|
-
export
|
|
38
|
-
return Effect.try({
|
|
39
|
-
catch: () => new RollbackSnapshotHashError({ releaseId }),
|
|
40
|
-
try: () => new RollbackSnapshotDigestState(),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
39
|
+
export const createRollbackSnapshotDigest = Effect.sync(() => new RollbackSnapshotDigestState());
|
|
43
40
|
/** Adds one canonical prior state to an incremental rollback digest. */
|
|
44
|
-
export function updateRollbackSnapshotDigest(
|
|
45
|
-
return Effect.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
state.update(entry);
|
|
49
|
-
return state;
|
|
50
|
-
},
|
|
41
|
+
export function updateRollbackSnapshotDigest(state, entry) {
|
|
42
|
+
return Effect.sync(() => {
|
|
43
|
+
state.update(entry);
|
|
44
|
+
return state;
|
|
51
45
|
});
|
|
52
46
|
}
|
|
53
47
|
/** Finalizes one rollback snapshot digest with a typed hash failure. */
|
|
54
48
|
export function finalizeRollbackSnapshotDigest(releaseId, state) {
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
49
|
+
return state
|
|
50
|
+
.digest()
|
|
51
|
+
.pipe(Effect.mapError(() => new RollbackSnapshotHashError({ releaseId })));
|
|
59
52
|
}
|
|
60
|
-
/** Digests one rollback snapshot stream
|
|
53
|
+
/** Digests one rollback snapshot stream. Its canonical bytes are held until one Web Crypto digest runs. */
|
|
61
54
|
export const digestRollbackSnapshot = Effect.fn("AksaraContracts.digestRollbackSnapshot")(function* (releaseId, entries) {
|
|
62
|
-
const initial = yield* createRollbackSnapshotDigest
|
|
63
|
-
const state = yield* entries.pipe(Stream.runFoldEffect(() => initial, (current, entry) => updateRollbackSnapshotDigest(
|
|
55
|
+
const initial = yield* createRollbackSnapshotDigest;
|
|
56
|
+
const state = yield* entries.pipe(Stream.runFoldEffect(() => initial, (current, entry) => updateRollbackSnapshotDigest(current, entry)));
|
|
64
57
|
const digest = yield* finalizeRollbackSnapshotDigest(releaseId, state);
|
|
65
58
|
return { count: state.count, digest };
|
|
66
59
|
});
|