@fides-anima/fpp-protocol-core 1.0.2
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 +95 -0
- package/README.md +41 -0
- package/SKILL.md +348 -0
- package/constitution.json +102 -0
- package/constitution.yaml +106 -0
- package/dist/adoption-disclosure.d.ts +35 -0
- package/dist/adoption-disclosure.d.ts.map +1 -0
- package/dist/adoption-disclosure.js +67 -0
- package/dist/adoption-disclosure.js.map +1 -0
- package/dist/adoption.d.ts +56 -0
- package/dist/adoption.d.ts.map +1 -0
- package/dist/adoption.js +97 -0
- package/dist/adoption.js.map +1 -0
- package/dist/canonical-json.d.ts +23 -0
- package/dist/canonical-json.d.ts.map +1 -0
- package/dist/canonical-json.js +60 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/capsules.d.ts +63 -0
- package/dist/capsules.d.ts.map +1 -0
- package/dist/capsules.js +94 -0
- package/dist/capsules.js.map +1 -0
- package/dist/claims.d.ts +62 -0
- package/dist/claims.d.ts.map +1 -0
- package/dist/claims.js +99 -0
- package/dist/claims.js.map +1 -0
- package/dist/digest.d.ts +38 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +52 -0
- package/dist/digest.js.map +1 -0
- package/dist/disposition.d.ts +34 -0
- package/dist/disposition.d.ts.map +1 -0
- package/dist/disposition.js +51 -0
- package/dist/disposition.js.map +1 -0
- package/dist/emergency-override.d.ts +73 -0
- package/dist/emergency-override.d.ts.map +1 -0
- package/dist/emergency-override.js +102 -0
- package/dist/emergency-override.js.map +1 -0
- package/dist/evidence.d.ts +25 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +30 -0
- package/dist/evidence.js.map +1 -0
- package/dist/freshness.d.ts +41 -0
- package/dist/freshness.d.ts.map +1 -0
- package/dist/freshness.js +66 -0
- package/dist/freshness.js.map +1 -0
- package/dist/governance.d.ts +87 -0
- package/dist/governance.d.ts.map +1 -0
- package/dist/governance.js +94 -0
- package/dist/governance.js.map +1 -0
- package/dist/identity.d.ts +43 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +93 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/mandates.d.ts +80 -0
- package/dist/mandates.d.ts.map +1 -0
- package/dist/mandates.js +127 -0
- package/dist/mandates.js.map +1 -0
- package/dist/merkle.d.ts +31 -0
- package/dist/merkle.d.ts.map +1 -0
- package/dist/merkle.js +95 -0
- package/dist/merkle.js.map +1 -0
- package/dist/quorum.d.ts +133 -0
- package/dist/quorum.d.ts.map +1 -0
- package/dist/quorum.js +128 -0
- package/dist/quorum.js.map +1 -0
- package/dist/receipts.d.ts +77 -0
- package/dist/receipts.d.ts.map +1 -0
- package/dist/receipts.js +104 -0
- package/dist/receipts.js.map +1 -0
- package/dist/steward-authorization.d.ts +200 -0
- package/dist/steward-authorization.d.ts.map +1 -0
- package/dist/steward-authorization.js +483 -0
- package/dist/steward-authorization.js.map +1 -0
- package/dist/workspace-profile.d.ts +43 -0
- package/dist/workspace-profile.d.ts.map +1 -0
- package/dist/workspace-profile.js +91 -0
- package/dist/workspace-profile.js.map +1 -0
- package/package.json +56 -0
- package/src/adoption-disclosure.ts +120 -0
- package/src/adoption.ts +152 -0
- package/src/canonical-json.ts +70 -0
- package/src/capsules.ts +161 -0
- package/src/claims.ts +147 -0
- package/src/digest.ts +63 -0
- package/src/disposition.ts +74 -0
- package/src/emergency-override.ts +168 -0
- package/src/evidence.ts +48 -0
- package/src/freshness.ts +103 -0
- package/src/governance.ts +152 -0
- package/src/identity.ts +119 -0
- package/src/index.ts +270 -0
- package/src/mandates.ts +201 -0
- package/src/merkle.ts +138 -0
- package/src/quorum.ts +193 -0
- package/src/receipts.ts +150 -0
- package/src/steward-authorization.ts +657 -0
- package/src/workspace-profile.ts +134 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freshness and replay-key contracts for signed envelopes.
|
|
3
|
+
*
|
|
4
|
+
* Policy limits (max lifetime, clock skew) are verifier-controlled inputs.
|
|
5
|
+
* This module does not implement replay-cache persistence (Plan 4).
|
|
6
|
+
*/
|
|
7
|
+
import { type Static } from "@sinclair/typebox";
|
|
8
|
+
export declare const FreshnessEnvelopeSchema: import("@sinclair/typebox").TObject<{
|
|
9
|
+
audience: import("@sinclair/typebox").TString;
|
|
10
|
+
challenge: import("@sinclair/typebox").TString;
|
|
11
|
+
issuedAt: import("@sinclair/typebox").TString;
|
|
12
|
+
expiresAt: import("@sinclair/typebox").TString;
|
|
13
|
+
}>;
|
|
14
|
+
export type FreshnessEnvelope = Static<typeof FreshnessEnvelopeSchema>;
|
|
15
|
+
export type FreshnessPolicy = {
|
|
16
|
+
/** Maximum allowed (expiresAt - issuedAt) in milliseconds. */
|
|
17
|
+
maxLifetimeMs: number;
|
|
18
|
+
/** Allowed clock skew when comparing issuedAt/expiresAt to now. */
|
|
19
|
+
allowedClockSkewMs: number;
|
|
20
|
+
/** Verifier clock — not signer-controlled. */
|
|
21
|
+
nowMs: number;
|
|
22
|
+
};
|
|
23
|
+
export type FreshnessValidation = {
|
|
24
|
+
valid: boolean;
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
export type FreshnessParseResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
envelope: FreshnessEnvelope;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function parseFreshnessEnvelope(input: unknown): FreshnessParseResult;
|
|
35
|
+
export declare function validateFreshness(envelope: FreshnessEnvelope, policy: FreshnessPolicy): FreshnessValidation;
|
|
36
|
+
/**
|
|
37
|
+
* Deterministic replay key over audience + challenge + issuedAt.
|
|
38
|
+
* Persistence/dedup is deferred to Plan 4.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildReplayKey(envelope: FreshnessEnvelope): string;
|
|
41
|
+
//# sourceMappingURL=freshness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../src/freshness.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAMtD,eAAO,MAAM,uBAAuB;;;;;EAQnC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEvE,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,iBAAiB,CAAA;CAAE,GACzC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAY3E;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,eAAe,GACtB,mBAAmB,CAuBrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAalE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freshness and replay-key contracts for signed envelopes.
|
|
3
|
+
*
|
|
4
|
+
* Policy limits (max lifetime, clock skew) are verifier-controlled inputs.
|
|
5
|
+
* This module does not implement replay-cache persistence (Plan 4).
|
|
6
|
+
*/
|
|
7
|
+
import { Type } from "@sinclair/typebox";
|
|
8
|
+
import { Value } from "@sinclair/typebox/value";
|
|
9
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
10
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils";
|
|
11
|
+
import { canonicalizeV2 } from "./canonical-json.js";
|
|
12
|
+
export const FreshnessEnvelopeSchema = Type.Object({
|
|
13
|
+
audience: Type.String({ minLength: 1 }),
|
|
14
|
+
challenge: Type.String({ minLength: 1 }),
|
|
15
|
+
issuedAt: Type.String({ minLength: 1 }),
|
|
16
|
+
expiresAt: Type.String({ minLength: 1 }),
|
|
17
|
+
}, { additionalProperties: false });
|
|
18
|
+
export function parseFreshnessEnvelope(input) {
|
|
19
|
+
if (!Value.Check(FreshnessEnvelopeSchema, input)) {
|
|
20
|
+
const errors = [...Value.Errors(FreshnessEnvelopeSchema, input)];
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: errors[0] !== undefined
|
|
24
|
+
? `${errors[0].path}: ${errors[0].message}`
|
|
25
|
+
: "invalid freshness envelope",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return { ok: true, envelope: input };
|
|
29
|
+
}
|
|
30
|
+
export function validateFreshness(envelope, policy) {
|
|
31
|
+
const issued = Date.parse(envelope.issuedAt);
|
|
32
|
+
const expires = Date.parse(envelope.expiresAt);
|
|
33
|
+
if (Number.isNaN(issued) || Number.isNaN(expires)) {
|
|
34
|
+
return { valid: false, reason: "issuedAt/expiresAt must be ISO-8601" };
|
|
35
|
+
}
|
|
36
|
+
if (expires <= issued) {
|
|
37
|
+
return { valid: false, reason: "expiresAt must be after issuedAt" };
|
|
38
|
+
}
|
|
39
|
+
const lifetime = expires - issued;
|
|
40
|
+
if (lifetime > policy.maxLifetimeMs) {
|
|
41
|
+
return {
|
|
42
|
+
valid: false,
|
|
43
|
+
reason: "lifetime exceeds verifier policy maxLifetimeMs",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (issued > policy.nowMs + policy.allowedClockSkewMs) {
|
|
47
|
+
return { valid: false, reason: "issuedAt is in the future beyond skew" };
|
|
48
|
+
}
|
|
49
|
+
if (expires < policy.nowMs - policy.allowedClockSkewMs) {
|
|
50
|
+
return { valid: false, reason: "envelope expired" };
|
|
51
|
+
}
|
|
52
|
+
return { valid: true, reason: "fresh" };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Deterministic replay key over audience + challenge + issuedAt.
|
|
56
|
+
* Persistence/dedup is deferred to Plan 4.
|
|
57
|
+
*/
|
|
58
|
+
export function buildReplayKey(envelope) {
|
|
59
|
+
return bytesToHex(sha256(utf8ToBytes("fpp:v2:replay\0" +
|
|
60
|
+
canonicalizeV2({
|
|
61
|
+
audience: envelope.audience,
|
|
62
|
+
challenge: envelope.challenge,
|
|
63
|
+
issuedAt: envelope.issuedAt,
|
|
64
|
+
}))));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=freshness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.js","sourceRoot":"","sources":["../src/freshness.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAChD;IACE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACvC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,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ACtB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,kCAAkC,EAAE,CAAC;IACtE,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC,IAAI,QAAQ,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,gDAAgD;SACzD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACtD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uCAAuC,EAAE,CAAC;IAC3E,CAAC;IACD,IAAI,OAAO,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACvD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAA2B;IACxD,OAAO,UAAU,CACf,MAAM,CACJ,WAAW,CACT,iBAAiB;QACf,cAAc,CAAC;YACb,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B,CAAC,CACL,CACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway governance transition contracts: modes, epochs, and audited events.
|
|
3
|
+
*
|
|
4
|
+
* These schemas define the voluntary constitutional-layer state machine
|
|
5
|
+
* (enabled → draining → disabled) without implying gateway enforcement is shipped.
|
|
6
|
+
*/
|
|
7
|
+
import { type Static } from "@sinclair/typebox";
|
|
8
|
+
export declare const GOVERNANCE_MODES: readonly ["enabled", "draining", "disabled"];
|
|
9
|
+
export type GovernanceMode = (typeof GOVERNANCE_MODES)[number];
|
|
10
|
+
export declare const GOVERNANCE_EVENT_KINDS: readonly ["governance-enabled", "governance-disabled"];
|
|
11
|
+
export type GovernanceEventKind = (typeof GOVERNANCE_EVENT_KINDS)[number];
|
|
12
|
+
export declare const GovernanceEpochSchema: import("@sinclair/typebox").TInteger;
|
|
13
|
+
export declare const GovernanceModeSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">, ...import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">[]]>;
|
|
14
|
+
export declare const GovernanceStateV1Schema: import("@sinclair/typebox").TObject<{
|
|
15
|
+
schemaVersion: import("@sinclair/typebox").TLiteral<1>;
|
|
16
|
+
mode: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">, ...import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">[]]>;
|
|
17
|
+
epoch: import("@sinclair/typebox").TInteger;
|
|
18
|
+
}>;
|
|
19
|
+
export type GovernanceStateV1 = Static<typeof GovernanceStateV1Schema>;
|
|
20
|
+
export declare const GovernanceActorSchema: import("@sinclair/typebox").TObject<{
|
|
21
|
+
role: import("@sinclair/typebox").TString;
|
|
22
|
+
id: import("@sinclair/typebox").TString;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const GovernanceEventSignatureSchema: import("@sinclair/typebox").TObject<{
|
|
25
|
+
alg: import("@sinclair/typebox").TString;
|
|
26
|
+
keyId: import("@sinclair/typebox").TString;
|
|
27
|
+
sig: import("@sinclair/typebox").TString;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Tamper-evident governance enable/disable event.
|
|
31
|
+
* `epoch` is the published epoch after the transition; `previousMode` is the
|
|
32
|
+
* mode immediately before durable publication of this event.
|
|
33
|
+
*/
|
|
34
|
+
export declare const GovernanceEventV1Schema: import("@sinclair/typebox").TObject<{
|
|
35
|
+
schemaVersion: import("@sinclair/typebox").TLiteral<1>;
|
|
36
|
+
kind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"governance-enabled">, import("@sinclair/typebox").TLiteral<"governance-disabled">]>;
|
|
37
|
+
eventId: import("@sinclair/typebox").TString;
|
|
38
|
+
ts: import("@sinclair/typebox").TString;
|
|
39
|
+
epoch: import("@sinclair/typebox").TInteger;
|
|
40
|
+
previousMode: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">, ...import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">[]]>;
|
|
41
|
+
mode: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">, ...import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">[]]>;
|
|
42
|
+
actor: import("@sinclair/typebox").TObject<{
|
|
43
|
+
role: import("@sinclair/typebox").TString;
|
|
44
|
+
id: import("@sinclair/typebox").TString;
|
|
45
|
+
}>;
|
|
46
|
+
constitutionHash: import("@sinclair/typebox").TString;
|
|
47
|
+
policyEngineVersion: import("@sinclair/typebox").TString;
|
|
48
|
+
prevHash: import("@sinclair/typebox").TString;
|
|
49
|
+
entryHash: import("@sinclair/typebox").TString;
|
|
50
|
+
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
51
|
+
signature: import("@sinclair/typebox").TObject<{
|
|
52
|
+
alg: import("@sinclair/typebox").TString;
|
|
53
|
+
keyId: import("@sinclair/typebox").TString;
|
|
54
|
+
sig: import("@sinclair/typebox").TString;
|
|
55
|
+
}>;
|
|
56
|
+
}>;
|
|
57
|
+
export type GovernanceEventV1 = Static<typeof GovernanceEventV1Schema>;
|
|
58
|
+
export type GovernanceEpochParseResult = {
|
|
59
|
+
ok: true;
|
|
60
|
+
epoch: number;
|
|
61
|
+
} | {
|
|
62
|
+
ok: false;
|
|
63
|
+
error: string;
|
|
64
|
+
};
|
|
65
|
+
export type GovernanceStateParseResult = {
|
|
66
|
+
ok: true;
|
|
67
|
+
state: GovernanceStateV1;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
error: string;
|
|
71
|
+
};
|
|
72
|
+
export type GovernanceEventParseResult = {
|
|
73
|
+
ok: true;
|
|
74
|
+
event: GovernanceEventV1;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
error: string;
|
|
78
|
+
};
|
|
79
|
+
export declare function isGovernanceMode(value: unknown): value is GovernanceMode;
|
|
80
|
+
export declare function parseGovernanceEpoch(input: unknown): GovernanceEpochParseResult;
|
|
81
|
+
export declare function parseGovernanceState(input: unknown): GovernanceStateParseResult;
|
|
82
|
+
/**
|
|
83
|
+
* Parse a governance event and enforce kind ↔ terminal mode consistency:
|
|
84
|
+
* disabled events publish mode "disabled"; enabled events publish "enabled".
|
|
85
|
+
*/
|
|
86
|
+
export declare function parseGovernanceEvent(input: unknown): GovernanceEventParseResult;
|
|
87
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtD,eAAO,MAAM,gBAAgB,8CAA+C,CAAC;AAE7E,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,sBAAsB,wDAGzB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAK1E,eAAO,MAAM,qBAAqB,sCAA+B,CAAC;AAElE,eAAO,MAAM,oBAAoB,iMAKhC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;EAOnC,CAAC;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|
3
|
+
*
|
|
4
|
+
* These schemas define the voluntary constitutional-layer state machine
|
|
5
|
+
* (enabled → draining → disabled) without implying gateway enforcement is shipped.
|
|
6
|
+
*/
|
|
7
|
+
import { Type } from "@sinclair/typebox";
|
|
8
|
+
import { Value } from "@sinclair/typebox/value";
|
|
9
|
+
export const GOVERNANCE_MODES = ["enabled", "draining", "disabled"];
|
|
10
|
+
export const GOVERNANCE_EVENT_KINDS = [
|
|
11
|
+
"governance-enabled",
|
|
12
|
+
"governance-disabled",
|
|
13
|
+
];
|
|
14
|
+
/** SHA-256 hex digest (64 lowercase or uppercase hex chars). */
|
|
15
|
+
const HexDigest64 = Type.String({ pattern: "^[0-9a-fA-F]{64}$" });
|
|
16
|
+
export const GovernanceEpochSchema = Type.Integer({ minimum: 0 });
|
|
17
|
+
export const GovernanceModeSchema = Type.Union(GOVERNANCE_MODES.map((m) => Type.Literal(m)));
|
|
18
|
+
export const GovernanceStateV1Schema = Type.Object({
|
|
19
|
+
schemaVersion: Type.Literal(1),
|
|
20
|
+
mode: GovernanceModeSchema,
|
|
21
|
+
epoch: GovernanceEpochSchema,
|
|
22
|
+
}, { additionalProperties: false });
|
|
23
|
+
export const GovernanceActorSchema = Type.Object({
|
|
24
|
+
role: Type.String({ minLength: 1 }),
|
|
25
|
+
id: Type.String({ minLength: 1 }),
|
|
26
|
+
}, { additionalProperties: false });
|
|
27
|
+
export const GovernanceEventSignatureSchema = Type.Object({
|
|
28
|
+
alg: Type.String({ minLength: 1 }),
|
|
29
|
+
keyId: Type.String({ minLength: 1 }),
|
|
30
|
+
sig: Type.String({ minLength: 1 }),
|
|
31
|
+
}, { additionalProperties: false });
|
|
32
|
+
/**
|
|
33
|
+
* Tamper-evident governance enable/disable event.
|
|
34
|
+
* `epoch` is the published epoch after the transition; `previousMode` is the
|
|
35
|
+
* mode immediately before durable publication of this event.
|
|
36
|
+
*/
|
|
37
|
+
export const GovernanceEventV1Schema = Type.Object({
|
|
38
|
+
schemaVersion: Type.Literal(1),
|
|
39
|
+
kind: Type.Union([
|
|
40
|
+
Type.Literal("governance-enabled"),
|
|
41
|
+
Type.Literal("governance-disabled"),
|
|
42
|
+
]),
|
|
43
|
+
eventId: Type.String({ minLength: 1 }),
|
|
44
|
+
ts: Type.String({ minLength: 1 }),
|
|
45
|
+
epoch: GovernanceEpochSchema,
|
|
46
|
+
previousMode: GovernanceModeSchema,
|
|
47
|
+
mode: GovernanceModeSchema,
|
|
48
|
+
actor: GovernanceActorSchema,
|
|
49
|
+
constitutionHash: HexDigest64,
|
|
50
|
+
policyEngineVersion: Type.String({ minLength: 1 }),
|
|
51
|
+
prevHash: HexDigest64,
|
|
52
|
+
entryHash: HexDigest64,
|
|
53
|
+
reason: Type.Optional(Type.String({ minLength: 1 })),
|
|
54
|
+
signature: GovernanceEventSignatureSchema,
|
|
55
|
+
}, { additionalProperties: false });
|
|
56
|
+
export function isGovernanceMode(value) {
|
|
57
|
+
return (typeof value === "string" &&
|
|
58
|
+
GOVERNANCE_MODES.includes(value));
|
|
59
|
+
}
|
|
60
|
+
export function parseGovernanceEpoch(input) {
|
|
61
|
+
if (!Value.Check(GovernanceEpochSchema, input)) {
|
|
62
|
+
return { ok: false, error: "invalid GovernanceEpoch" };
|
|
63
|
+
}
|
|
64
|
+
return { ok: true, epoch: input };
|
|
65
|
+
}
|
|
66
|
+
export function parseGovernanceState(input) {
|
|
67
|
+
if (!Value.Check(GovernanceStateV1Schema, input)) {
|
|
68
|
+
return { ok: false, error: "invalid GovernanceStateV1" };
|
|
69
|
+
}
|
|
70
|
+
return { ok: true, state: input };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Parse a governance event and enforce kind ↔ terminal mode consistency:
|
|
74
|
+
* disabled events publish mode "disabled"; enabled events publish "enabled".
|
|
75
|
+
*/
|
|
76
|
+
export function parseGovernanceEvent(input) {
|
|
77
|
+
if (!Value.Check(GovernanceEventV1Schema, input)) {
|
|
78
|
+
return { ok: false, error: "invalid GovernanceEventV1" };
|
|
79
|
+
}
|
|
80
|
+
if (input.kind === "governance-disabled" && input.mode !== "disabled") {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
error: "governance-disabled event must publish mode disabled",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (input.kind === "governance-enabled" && input.mode !== "enabled") {
|
|
87
|
+
return {
|
|
88
|
+
ok: false,
|
|
89
|
+
error: "governance-enabled event must publish mode enabled",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return { ok: true, event: input };
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAI7E,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,oBAAoB;IACpB,qBAAqB;CACb,CAAC;AAIX,gEAAgE;AAChE,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAC5C,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAG1C,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAChD;IACE,aAAa,EAAE,I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,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC;IAC3D,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACtE,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,sDAAsD;SAC9D,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACpE,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,oDAAoD;SAC5D,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key-bound agent identity primitives.
|
|
3
|
+
*
|
|
4
|
+
* V2 agent IDs are full key fingerprints: `fpp:ed25519:<sha256(pubkey)>`.
|
|
5
|
+
* Legacy truncated aliases (`fpp-<16 hex>`) remain parseable for display and
|
|
6
|
+
* migration but are never independent proof of identity.
|
|
7
|
+
*/
|
|
8
|
+
export declare const KEY_ALGORITHM: "ed25519";
|
|
9
|
+
export type ParsedAgentId = {
|
|
10
|
+
kind: "v2";
|
|
11
|
+
algorithm: typeof KEY_ALGORITHM;
|
|
12
|
+
fingerprint: string;
|
|
13
|
+
raw: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "legacy-alias";
|
|
16
|
+
fingerprintPrefix: string;
|
|
17
|
+
raw: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "unknown";
|
|
20
|
+
raw: string;
|
|
21
|
+
};
|
|
22
|
+
/** SHA-256 fingerprint of the raw public key bytes (64 hex chars). */
|
|
23
|
+
export declare function fingerprintPublicKey(publicKeyHex: string): string;
|
|
24
|
+
/** V2 agent identifier bound to the full public-key fingerprint. */
|
|
25
|
+
export declare function deriveAgentIdV2(publicKeyHex: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Historical truncated alias: `fpp-` + first 16 hex chars of SHA-256(pubkey).
|
|
28
|
+
* Labeled for migration/display only — not independent identity proof.
|
|
29
|
+
*/
|
|
30
|
+
export declare function deriveLegacyAlias(publicKeyHex: string): string;
|
|
31
|
+
export declare function isLegacyAgentAlias(agentId: string): boolean;
|
|
32
|
+
export declare function parseAgentId(agentId: string): ParsedAgentId;
|
|
33
|
+
/**
|
|
34
|
+
* Recompute the expected identifier from the public key and compare.
|
|
35
|
+
* Legacy aliases match only when `allowLegacyAlias` is explicitly set.
|
|
36
|
+
*/
|
|
37
|
+
export declare function publicKeyMatchesAgentId(agentId: string, publicKeyHex: string, options?: {
|
|
38
|
+
allowLegacyAlias?: boolean;
|
|
39
|
+
}): boolean;
|
|
40
|
+
export declare function verifySignature(message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean;
|
|
41
|
+
export declare function signMessage(message: Uint8Array, privateKey: Uint8Array): Uint8Array;
|
|
42
|
+
export declare function publicKeyFromSeed(seed: Uint8Array): Uint8Array;
|
|
43
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,eAAO,MAAM,aAAa,EAAG,SAAkB,CAAC;AAEhD,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,OAAO,aAAa,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACjF;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAgBrC,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAmB3D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC3C,OAAO,CAOT;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE,UAAU,GACpB,OAAO,CAMT;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,UAAU,GACrB,UAAU,CAEZ;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAE9D"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key-bound agent identity primitives.
|
|
3
|
+
*
|
|
4
|
+
* V2 agent IDs are full key fingerprints: `fpp:ed25519:<sha256(pubkey)>`.
|
|
5
|
+
* Legacy truncated aliases (`fpp-<16 hex>`) remain parseable for display and
|
|
6
|
+
* migration but are never independent proof of identity.
|
|
7
|
+
*/
|
|
8
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
9
|
+
import { bytesToHex } from "@noble/hashes/utils";
|
|
10
|
+
import * as ed from "@noble/ed25519";
|
|
11
|
+
import { sha512 } from "@noble/hashes/sha512";
|
|
12
|
+
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
|
|
13
|
+
export const KEY_ALGORITHM = "ed25519";
|
|
14
|
+
function decodePublicKeyHex(publicKeyHex) {
|
|
15
|
+
if (!/^[0-9a-fA-F]+$/.test(publicKeyHex)) {
|
|
16
|
+
throw new Error("public key must be hex");
|
|
17
|
+
}
|
|
18
|
+
if (publicKeyHex.length !== 64) {
|
|
19
|
+
throw new Error("public key must be 32 bytes (64 hex chars)");
|
|
20
|
+
}
|
|
21
|
+
const bytes = new Uint8Array(32);
|
|
22
|
+
for (let i = 0; i < 32; i++) {
|
|
23
|
+
bytes[i] = Number.parseInt(publicKeyHex.slice(i * 2, i * 2 + 2), 16);
|
|
24
|
+
}
|
|
25
|
+
return bytes;
|
|
26
|
+
}
|
|
27
|
+
/** SHA-256 fingerprint of the raw public key bytes (64 hex chars). */
|
|
28
|
+
export function fingerprintPublicKey(publicKeyHex) {
|
|
29
|
+
const bytes = decodePublicKeyHex(publicKeyHex);
|
|
30
|
+
return bytesToHex(sha256(bytes));
|
|
31
|
+
}
|
|
32
|
+
/** V2 agent identifier bound to the full public-key fingerprint. */
|
|
33
|
+
export function deriveAgentIdV2(publicKeyHex) {
|
|
34
|
+
return `fpp:${KEY_ALGORITHM}:${fingerprintPublicKey(publicKeyHex)}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Historical truncated alias: `fpp-` + first 16 hex chars of SHA-256(pubkey).
|
|
38
|
+
* Labeled for migration/display only — not independent identity proof.
|
|
39
|
+
*/
|
|
40
|
+
export function deriveLegacyAlias(publicKeyHex) {
|
|
41
|
+
return "fpp-" + fingerprintPublicKey(publicKeyHex).slice(0, 16);
|
|
42
|
+
}
|
|
43
|
+
export function isLegacyAgentAlias(agentId) {
|
|
44
|
+
return /^fpp-[0-9a-f]{16}$/i.test(agentId);
|
|
45
|
+
}
|
|
46
|
+
export function parseAgentId(agentId) {
|
|
47
|
+
const v2 = /^fpp:(ed25519):([0-9a-f]{64})$/i.exec(agentId);
|
|
48
|
+
if (v2) {
|
|
49
|
+
return {
|
|
50
|
+
kind: "v2",
|
|
51
|
+
algorithm: KEY_ALGORITHM,
|
|
52
|
+
fingerprint: v2[2].toLowerCase(),
|
|
53
|
+
raw: agentId,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const legacy = /^fpp-([0-9a-f]{16})$/i.exec(agentId);
|
|
57
|
+
if (legacy) {
|
|
58
|
+
return {
|
|
59
|
+
kind: "legacy-alias",
|
|
60
|
+
fingerprintPrefix: legacy[1].toLowerCase(),
|
|
61
|
+
raw: agentId,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return { kind: "unknown", raw: agentId };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Recompute the expected identifier from the public key and compare.
|
|
68
|
+
* Legacy aliases match only when `allowLegacyAlias` is explicitly set.
|
|
69
|
+
*/
|
|
70
|
+
export function publicKeyMatchesAgentId(agentId, publicKeyHex, options = {}) {
|
|
71
|
+
const expectedV2 = deriveAgentIdV2(publicKeyHex);
|
|
72
|
+
if (agentId === expectedV2)
|
|
73
|
+
return true;
|
|
74
|
+
if (options.allowLegacyAlias === true) {
|
|
75
|
+
return agentId === deriveLegacyAlias(publicKeyHex);
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
export function verifySignature(message, signature, publicKey) {
|
|
80
|
+
try {
|
|
81
|
+
return ed.verify(signature, message, publicKey);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function signMessage(message, privateKey) {
|
|
88
|
+
return ed.sign(message, privateKey);
|
|
89
|
+
}
|
|
90
|
+
export function publicKeyFromSeed(seed) {
|
|
91
|
+
return ed.getPublicKey(seed);
|
|
92
|
+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e,EACf,YAAoB,EACpB,UAA0C,EAAE;IAE5C,MAAM,UAAU,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;IACjD,IAAI,OAAO,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,OAAO,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;QACtC,OAAO,OAAO,KAAK,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAAmB,EACnB,SAAqB,EACrB,SAAqB;IAErB,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,OAAmB,EACnB,UAAsB;IAEtB,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAgB;IAChD,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fides-anima/fpp-protocol-core — shared schemas and cryptographic contracts
|
|
3
|
+
* for the Freedom Preserving Protocol.
|
|
4
|
+
*
|
|
5
|
+
* Package version and protocol schema version are independent:
|
|
6
|
+
* this package release carries schema version 2.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PACKAGE_NAME: "@fides-anima/fpp-protocol-core";
|
|
9
|
+
export declare const PACKAGE_VERSION: "1.0.2";
|
|
10
|
+
/** Protocol schema version carried by this package release. */
|
|
11
|
+
export declare const SCHEMA_VERSION: 2;
|
|
12
|
+
export { canonicalize, canonicalizeV1, canonicalizeV2, } from "./canonical-json.js";
|
|
13
|
+
export { DIGEST_DOMAINS, digest, hashEntryV1, type DigestDomain, type DigestInput, } from "./digest.js";
|
|
14
|
+
export { computeMerkleRoot, computeMerkleRootV1, computeMerkleRootV2, createMerkleProof, createMerkleProofV1, createMerkleProofV2, hashPairV1, hashPairV2, verifyMerkleProof, verifyMerkleProofV1, verifyMerkleProofV2, type MerkleProof, type MerkleProofStep, } from "./merkle.js";
|
|
15
|
+
export { KEY_ALGORITHM, deriveAgentIdV2, deriveLegacyAlias, fingerprintPublicKey, isLegacyAgentAlias, parseAgentId, publicKeyFromSeed, publicKeyMatchesAgentId, signMessage, verifySignature, type ParsedAgentId, } from "./identity.js";
|
|
16
|
+
export { STEWARD_DIGEST_DOMAINS, KeyRefSchema, OperatorAuthorizationRevocationV1Schema, OperatorAuthorizationV1Schema, StewardBootstrapPolicyCapsV1Schema, StewardBootstrapV1Schema, StewardKeyAttestationV1Schema, attestationSigningFields, authorizationRevocationSigningFields, authorizationSigningFields, bootstrapSigningFields, buildStewardEvidenceDigest, buildStewardReplayDigest, containsOpenPgpSecretKeyArmor, isStewardIdV1, mintStewardIdV1, parseKeyRef, parseOperatorAuthorization, parseOperatorAuthorizationRevocation, parseStewardBootstrap, parseStewardIdV1, parseStewardKeyAttestation, validateOperatorAuthorizationBounds, type BoundsResult, type KeyRefParseResult, type OperatorAuthorizationParseResult, type OperatorAuthorizationRevocationParseResult, type OperatorAuthorizationRevocationV1, type OperatorAuthorizationV1, type ParsedKeyRef, type ParsedStewardIdV1, type StewardBootstrapParseResult, type StewardBootstrapPolicyCapsV1, type StewardBootstrapV1, type StewardIdParseResult, type StewardIdV1, type StewardKeyAttestationParseResult, type StewardKeyAttestationV1, } from "./steward-authorization.js";
|
|
17
|
+
export { CLAIM_CLASSES, ConstitutionalClaimV2Schema, LegacyConstitutionalClaimV1Schema, parseClaim, type ClaimClass, type ClaimParseResult, type ConstitutionalClaimV2, type LegacyConstitutionalClaimV1, } from "./claims.js";
|
|
18
|
+
export { FreshnessEnvelopeSchema, buildReplayKey, parseFreshnessEnvelope, validateFreshness, type FreshnessEnvelope, type FreshnessParseResult, type FreshnessPolicy, type FreshnessValidation, } from "./freshness.js";
|
|
19
|
+
export { ConformanceReceiptV1Schema, ReceiptInclusionEvidenceV1Schema, parseConformanceReceipt, parseReceiptInclusionEvidence, type ConformanceReceiptV1, type ReceiptInclusionEvidenceParseResult, type ReceiptInclusionEvidenceV1, type ReceiptParseResult, } from "./receipts.js";
|
|
20
|
+
export { GOVERNANCE_EVENT_KINDS, GOVERNANCE_MODES, GovernanceActorSchema, GovernanceEpochSchema, GovernanceEventSignatureSchema, GovernanceEventV1Schema, GovernanceModeSchema, GovernanceStateV1Schema, isGovernanceMode, parseGovernanceEpoch, parseGovernanceEvent, parseGovernanceState, type GovernanceEpochParseResult, type GovernanceEventKind, type GovernanceEventParseResult, type GovernanceEventV1, type GovernanceMode, type GovernanceStateParseResult, type GovernanceStateV1, } from "./governance.js";
|
|
21
|
+
export { MANDATE_ISSUER_CLASSES, StandingMandateV1Schema, mandateSigningFields, parseStandingMandate, validateMandateValidity, verifyMandateSignature, type MandateIssuerClass, type MandateLedgerEntry, type MandateParseResult, type MandateStoreFile, type MandateValidity, type MandateValidityPolicy, type StandingMandateV1, } from "./mandates.js";
|
|
22
|
+
export { SignedEmergencyOverrideV1Schema, emergencyOverrideSigningFields, parseSignedEmergencyOverride, validateEmergencyOverrideValidity, verifyEmergencyOverrideSignature, type EmergencyOverrideLedgerEntry, type EmergencyOverrideParseResult, type EmergencyOverrideStoreFile, type EmergencyOverrideValidity, type EmergencyOverrideValidityPolicy, type SignedEmergencyOverrideV1, } from "./emergency-override.js";
|
|
23
|
+
export { AUTHORIZATION_CLASSES, AUTHZ, DISPOSITION_DECISIONS, isAuthorizationClass, isDispositionDecision, parseDispositionDecision, type AuthorizationClass, type DispositionDecision, type DispositionParseResult, } from "./disposition.js";
|
|
24
|
+
export { CapsuleAdoptionDisclosureSummarySchema, TrustStateCapsuleV2Schema, parseTrustStateCapsule, validateCapsuleAdoptionConsistency, type CapsuleAdoptionConsistency, type CapsuleAdoptionDisclosureSummary, type CapsuleParseResult, type TrustStateCapsuleV2, } from "./capsules.js";
|
|
25
|
+
export { ADOPTION_OVERLAY_FLAGS, ADOPTION_STATES, AdoptionStateRecordV1Schema, AdoptionStateRecordV2Schema, ENFORCEMENT_GRADES, parseAdoptionStateRecord, type AdoptionOverlayFlag, type AdoptionParseResult, type AdoptionState, type AdoptionStateRecord, type AdoptionStateRecordV1, type AdoptionStateRecordV2, type EnforcementGrade, } from "./adoption.js";
|
|
26
|
+
export { ADOPTION_ASSURANCE_CLASSES, AdoptionDisclosureV1Schema, maxJustifiedConclusion, parseAdoptionDisclosure, type AdoptionAssurance, type AdoptionDisclosureParseResult, type AdoptionDisclosureV1, } from "./adoption-disclosure.js";
|
|
27
|
+
export { EvidenceEnvelopeV1Schema, parseEvidenceEnvelope, type EvidenceEnvelopeV1, type EvidenceParseResult, } from "./evidence.js";
|
|
28
|
+
export { QUORUM_CLASSES, QUORUM_VOTES, QuorumBallotV1Schema, QuorumEvidencePackageV1Schema, QuorumProposalV1Schema, computeQuorumEvidenceDigest, parseQuorumBallot, parseQuorumEvidencePackage, parseQuorumProposal, validateBallotAgainstProposal, type BallotMatchResult, type QuorumBallotParseResult, type QuorumBallotV1, type QuorumClass, type QuorumEvidencePackageV1, type QuorumEvidenceParseResult, type QuorumProposalParseResult, type QuorumProposalV1, type QuorumVote, } from "./quorum.js";
|
|
29
|
+
export { DEFAULT_WORKSPACE_PROFILE, resolveWorkspaceRoot, workspaceFile, absolutizeWorkspacePath, type ResolveWorkspaceOptions, type AbsolutizeWorkspaceOptions, type WorkspaceProfileId, } from "./workspace-profile.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,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EACpB,6BAA6B,EAC7B,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,6BAA6B,EAC7B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,GACxB,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fides-anima/fpp-protocol-core — shared schemas and cryptographic contracts
|
|
3
|
+
* for the Freedom Preserving Protocol.
|
|
4
|
+
*
|
|
5
|
+
* Package version and protocol schema version are independent:
|
|
6
|
+
* this package release carries schema version 2.
|
|
7
|
+
*/
|
|
8
|
+
export const PACKAGE_NAME = "@fides-anima/fpp-protocol-core";
|
|
9
|
+
export const PACKAGE_VERSION = "1.0.2";
|
|
10
|
+
/** Protocol schema version carried by this package release. */
|
|
11
|
+
export const SCHEMA_VERSION = 2;
|
|
12
|
+
export { canonicalize, canonicalizeV1, canonicalizeV2, } from "./canonical-json.js";
|
|
13
|
+
export { DIGEST_DOMAINS, digest, hashEntryV1, } from "./digest.js";
|
|
14
|
+
export { computeMerkleRoot, computeMerkleRootV1, computeMerkleRootV2, createMerkleProof, createMerkleProofV1, createMerkleProofV2, hashPairV1, hashPairV2, verifyMerkleProof, verifyMerkleProofV1, verifyMerkleProofV2, } from "./merkle.js";
|
|
15
|
+
export { KEY_ALGORITHM, deriveAgentIdV2, deriveLegacyAlias, fingerprintPublicKey, isLegacyAgentAlias, parseAgentId, publicKeyFromSeed, publicKeyMatchesAgentId, signMessage, verifySignature, } from "./identity.js";
|
|
16
|
+
export { STEWARD_DIGEST_DOMAINS, KeyRefSchema, OperatorAuthorizationRevocationV1Schema, OperatorAuthorizationV1Schema, StewardBootstrapPolicyCapsV1Schema, StewardBootstrapV1Schema, StewardKeyAttestationV1Schema, attestationSigningFields, authorizationRevocationSigningFields, authorizationSigningFields, bootstrapSigningFields, buildStewardEvidenceDigest, buildStewardReplayDigest, containsOpenPgpSecretKeyArmor, isStewardIdV1, mintStewardIdV1, parseKeyRef, parseOperatorAuthorization, parseOperatorAuthorizationRevocation, parseStewardBootstrap, parseStewardIdV1, parseStewardKeyAttestation, validateOperatorAuthorizationBounds, } from "./steward-authorization.js";
|
|
17
|
+
export { CLAIM_CLASSES, ConstitutionalClaimV2Schema, LegacyConstitutionalClaimV1Schema, parseClaim, } from "./claims.js";
|
|
18
|
+
export { FreshnessEnvelopeSchema, buildReplayKey, parseFreshnessEnvelope, validateFreshness, } from "./freshness.js";
|
|
19
|
+
export { ConformanceReceiptV1Schema, ReceiptInclusionEvidenceV1Schema, parseConformanceReceipt, parseReceiptInclusionEvidence, } from "./receipts.js";
|
|
20
|
+
export { GOVERNANCE_EVENT_KINDS, GOVERNANCE_MODES, GovernanceActorSchema, GovernanceEpochSchema, GovernanceEventSignatureSchema, GovernanceEventV1Schema, GovernanceModeSchema, GovernanceStateV1Schema, isGovernanceMode, parseGovernanceEpoch, parseGovernanceEvent, parseGovernanceState, } from "./governance.js";
|
|
21
|
+
export { MANDATE_ISSUER_CLASSES, StandingMandateV1Schema, mandateSigningFields, parseStandingMandate, validateMandateValidity, verifyMandateSignature, } from "./mandates.js";
|
|
22
|
+
export { SignedEmergencyOverrideV1Schema, emergencyOverrideSigningFields, parseSignedEmergencyOverride, validateEmergencyOverrideValidity, verifyEmergencyOverrideSignature, } from "./emergency-override.js";
|
|
23
|
+
export { AUTHORIZATION_CLASSES, AUTHZ, DISPOSITION_DECISIONS, isAuthorizationClass, isDispositionDecision, parseDispositionDecision, } from "./disposition.js";
|
|
24
|
+
export { CapsuleAdoptionDisclosureSummarySchema, TrustStateCapsuleV2Schema, parseTrustStateCapsule, validateCapsuleAdoptionConsistency, } from "./capsules.js";
|
|
25
|
+
export { ADOPTION_OVERLAY_FLAGS, ADOPTION_STATES, AdoptionStateRecordV1Schema, AdoptionStateRecordV2Schema, ENFORCEMENT_GRADES, parseAdoptionStateRecord, } from "./adoption.js";
|
|
26
|
+
export { ADOPTION_ASSURANCE_CLASSES, AdoptionDisclosureV1Schema, maxJustifiedConclusion, parseAdoptionDisclosure, } from "./adoption-disclosure.js";
|
|
27
|
+
export { EvidenceEnvelopeV1Schema, parseEvidenceEnvelope, } from "./evidence.js";
|
|
28
|
+
export { QUORUM_CLASSES, QUORUM_VOTES, QuorumBallotV1Schema, QuorumEvidencePackageV1Schema, QuorumProposalV1Schema, computeQuorumEvidenceDigest, parseQuorumBallot, parseQuorumEvidencePackage, parseQuorumProposal, validateBallotAgainstProposal, } from "./quorum.js";
|
|
29
|
+
export { DEFAULT_WORKSPACE_PROFILE, resolveWorkspaceRoot, workspaceFile, absolutizeWorkspacePath, } from "./workspace-profile.js";
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,gCAAyC,CAAC;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,OAAgB,CAAC;AAChD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAU,CAAC;AAEzC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,cAAc,EACd,MAAM,EACN,WAAW,GAGZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EAC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BAAuB,EACvB,sBAAsB,GAQvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC5B,iCAAiC,EACjC,gCAAgC,GAOjC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,GAIzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,sCAAsC,EACtC,yBAAyB,EACzB,sBAAsB,EACtB,kCAAkC,GAKnC,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,GAQzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GAGtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,6BAA6B,GAU9B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,uBAAuB,GAIxB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standing mandate schema — signed or allowlist-backed authorization
|
|
3
|
+
* consumed by the unattended disposition engine.
|
|
4
|
+
*/
|
|
5
|
+
import { type Static } from "@sinclair/typebox";
|
|
6
|
+
export declare const MANDATE_ISSUER_CLASSES: readonly ["operator", "peer-quorum", "steward-quorum", "standing-allowlist"];
|
|
7
|
+
export type MandateIssuerClass = (typeof MANDATE_ISSUER_CLASSES)[number];
|
|
8
|
+
export declare const StandingMandateV1Schema: import("@sinclair/typebox").TObject<{
|
|
9
|
+
schemaVersion: import("@sinclair/typebox").TLiteral<1>;
|
|
10
|
+
mandateId: import("@sinclair/typebox").TString;
|
|
11
|
+
issuerClass: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"standing-allowlist" | "operator" | "peer-quorum" | "steward-quorum">, ...import("@sinclair/typebox").TLiteral<"standing-allowlist" | "operator" | "peer-quorum" | "steward-quorum">[]]>;
|
|
12
|
+
issuerId: import("@sinclair/typebox").TString;
|
|
13
|
+
scope: import("@sinclair/typebox").TObject<{
|
|
14
|
+
classifications: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
15
|
+
capabilities: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
16
|
+
}>;
|
|
17
|
+
budgets: import("@sinclair/typebox").TObject<{
|
|
18
|
+
maxActions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
19
|
+
remainingActions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
20
|
+
}>;
|
|
21
|
+
validFrom: import("@sinclair/typebox").TString;
|
|
22
|
+
validTo: import("@sinclair/typebox").TString;
|
|
23
|
+
revocable: import("@sinclair/typebox").TBoolean;
|
|
24
|
+
revoked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
25
|
+
evidenceRef: import("@sinclair/typebox").TString;
|
|
26
|
+
quorumRef: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
27
|
+
publicKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
28
|
+
signature: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
29
|
+
}>;
|
|
30
|
+
export type StandingMandateV1 = Static<typeof StandingMandateV1Schema>;
|
|
31
|
+
/** Mutable runtime counters — never part of the signed grant payload. */
|
|
32
|
+
export type MandateLedgerEntry = {
|
|
33
|
+
remainingActions?: number;
|
|
34
|
+
revoked?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Shared on-disk mandate store shape (enforcement-core + trust-core).
|
|
38
|
+
* `ledgers` is additive; absent keys mean unlimited budget / not revoked.
|
|
39
|
+
*/
|
|
40
|
+
export type MandateStoreFile = {
|
|
41
|
+
schemaVersion: 1;
|
|
42
|
+
mandates: StandingMandateV1[];
|
|
43
|
+
ledgers?: Record<string, MandateLedgerEntry>;
|
|
44
|
+
};
|
|
45
|
+
export type MandateParseResult = {
|
|
46
|
+
ok: true;
|
|
47
|
+
mandate: StandingMandateV1;
|
|
48
|
+
} | {
|
|
49
|
+
ok: false;
|
|
50
|
+
error: string;
|
|
51
|
+
};
|
|
52
|
+
export type MandateValidityPolicy = {
|
|
53
|
+
/** Verifier clock — not signer-controlled. */
|
|
54
|
+
nowMs: number;
|
|
55
|
+
};
|
|
56
|
+
export type MandateValidity = {
|
|
57
|
+
valid: boolean;
|
|
58
|
+
reason: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function parseStandingMandate(input: unknown): MandateParseResult;
|
|
61
|
+
/**
|
|
62
|
+
* Temporal / revocation check for a schema-valid mandate.
|
|
63
|
+
* Budget debit and signature verification live in the plugin mandate store.
|
|
64
|
+
*/
|
|
65
|
+
export declare function validateMandateValidity(mandate: StandingMandateV1, policy: MandateValidityPolicy): MandateValidity;
|
|
66
|
+
/**
|
|
67
|
+
* Canonical unsigned payload for new mandate signatures.
|
|
68
|
+
* Excludes `signature`, `revoked`, and `budgets.remainingActions` so debit/revoke
|
|
69
|
+
* can mutate an unsigned ledger without invalidating the grant.
|
|
70
|
+
*/
|
|
71
|
+
export declare function mandateSigningFields(mandate: StandingMandateV1): Record<string, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Dual-verify mandate signatures:
|
|
74
|
+
* 1. New payload (`mandateSigningFields`) — preferred for newly issued grants.
|
|
75
|
+
* 2. Legacy payload (full object minus `signature`) — undebited historical files.
|
|
76
|
+
*
|
|
77
|
+
* Standing-allowlist mandates are unsigned by design.
|
|
78
|
+
*/
|
|
79
|
+
export declare function verifyMandateSignature(mandate: StandingMandateV1): boolean;
|
|
80
|
+
//# sourceMappingURL=mandates.d.ts.map
|