@fabricorg/platform 1.9.0 → 1.10.1
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/CHANGELOG.md +56 -0
- package/README.md +48 -2
- package/dist/actions/index.cjs +45 -26
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +225 -226
- package/dist/actions/index.d.ts +225 -226
- package/dist/actions/index.js +41 -2
- package/dist/actions/index.js.map +1 -1
- package/dist/adapters/index.cjs +696 -66
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +367 -365
- package/dist/adapters/index.d.ts +367 -365
- package/dist/adapters/index.js +682 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/agent-hitl/index.cjs +21 -10
- package/dist/agent-hitl/index.cjs.map +1 -1
- package/dist/agent-hitl/index.d.cts +30 -30
- package/dist/agent-hitl/index.d.ts +30 -30
- package/dist/agent-hitl/index.js +21 -2
- package/dist/agent-hitl/index.js.map +1 -1
- package/dist/certification/index.cjs +109 -24
- package/dist/certification/index.cjs.map +1 -1
- package/dist/certification/index.d.cts +33 -39
- package/dist/certification/index.d.ts +33 -39
- package/dist/certification/index.js +107 -8
- package/dist/certification/index.js.map +1 -1
- package/dist/discovery/index.cjs +12 -10
- package/dist/discovery/index.cjs.map +1 -1
- package/dist/discovery/index.d.cts +2 -10
- package/dist/discovery/index.d.ts +2 -10
- package/dist/discovery/index.js +12 -2
- package/dist/discovery/index.js.map +1 -1
- package/dist/engine-B4csEOEc.js +223 -0
- package/dist/engine-B4csEOEc.js.map +1 -0
- package/dist/engine-BqScuhrT.cjs +246 -0
- package/dist/engine-BqScuhrT.cjs.map +1 -0
- package/dist/events/index.cjs +39 -10
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +43 -43
- package/dist/events/index.d.ts +43 -43
- package/dist/events/index.js +39 -2
- package/dist/events/index.js.map +1 -1
- package/dist/evidence/index.cjs +12 -50
- package/dist/evidence/index.d.cts +2 -229
- package/dist/evidence/index.d.ts +2 -229
- package/dist/evidence/index.js +1 -5
- package/dist/evidence-BuCICb0c.js +516 -0
- package/dist/evidence-BuCICb0c.js.map +1 -0
- package/dist/evidence-Cq48eDvA.cjs +575 -0
- package/dist/evidence-Cq48eDvA.cjs.map +1 -0
- package/dist/governance/index.cjs +24 -18
- package/dist/governance/index.cjs.map +1 -1
- package/dist/governance/index.d.cts +80 -83
- package/dist/governance/index.d.ts +80 -83
- package/dist/governance/index.js +22 -2
- package/dist/governance/index.js.map +1 -1
- package/dist/ids/index.cjs +52 -22
- package/dist/ids/index.cjs.map +1 -1
- package/dist/ids/index.d.cts +17 -17
- package/dist/ids/index.d.ts +17 -17
- package/dist/ids/index.js +49 -2
- package/dist/ids/index.js.map +1 -1
- package/dist/index-9jasmw76.d.cts +124 -0
- package/dist/index-BXpeFdk2.d.cts +190 -0
- package/dist/index-BXpeFdk2.d.ts +190 -0
- package/dist/index-BnbsKZsT.d.cts +231 -0
- package/dist/index-CIl1rYRv.d.cts +11 -0
- package/dist/index-CIl1rYRv.d.ts +11 -0
- package/dist/index-CVHA1ypT.d.cts +262 -0
- package/dist/index-DZ4mnNb7.d.cts +78 -0
- package/dist/index-DZ4mnNb7.d.ts +78 -0
- package/dist/index-IqcDvl69.d.ts +124 -0
- package/dist/index-fmUiRBXu.d.cts +57 -0
- package/dist/index-fmUiRBXu.d.ts +57 -0
- package/dist/index-sPUPs8pr.d.ts +262 -0
- package/dist/index-z9-CYOIo.d.ts +231 -0
- package/dist/index.cjs +111 -385
- package/dist/index.d.cts +18 -17
- package/dist/index.d.ts +18 -17
- package/dist/index.js +19 -20
- package/dist/manifest/index.cjs +224 -35
- package/dist/manifest/index.cjs.map +1 -1
- package/dist/manifest/index.d.cts +130 -131
- package/dist/manifest/index.d.ts +130 -131
- package/dist/manifest/index.js +219 -7
- package/dist/manifest/index.js.map +1 -1
- package/dist/modules/index.cjs +281 -42
- package/dist/modules/index.cjs.map +1 -1
- package/dist/modules/index.d.cts +157 -159
- package/dist/modules/index.d.ts +157 -159
- package/dist/modules/index.js +274 -6
- package/dist/modules/index.js.map +1 -1
- package/dist/objects/index.cjs +355 -22
- package/dist/objects/index.cjs.map +1 -1
- package/dist/objects/index.d.cts +2 -77
- package/dist/objects/index.d.ts +2 -77
- package/dist/objects/index.js +352 -2
- package/dist/objects/index.js.map +1 -1
- package/dist/policies/index.cjs +14 -48
- package/dist/policies/index.d.cts +2 -247
- package/dist/policies/index.d.ts +2 -247
- package/dist/policies/index.js +1 -3
- package/dist/policies-DH_GCXQ-.js +627 -0
- package/dist/policies-DH_GCXQ-.js.map +1 -0
- package/dist/policies-Nxbp1CH8.cjs +698 -0
- package/dist/policies-Nxbp1CH8.cjs.map +1 -0
- package/dist/privacy/index.cjs +26 -43
- package/dist/privacy/index.cjs.map +1 -1
- package/dist/privacy/index.d.cts +2 -189
- package/dist/privacy/index.d.ts +2 -189
- package/dist/privacy/index.js +18 -3
- package/dist/privacy/index.js.map +1 -1
- package/dist/projections/index.cjs +241 -23
- package/dist/projections/index.cjs.map +1 -1
- package/dist/projections/index.d.cts +2 -125
- package/dist/projections/index.d.ts +2 -125
- package/dist/projections/index.js +238 -3
- package/dist/projections/index.js.map +1 -1
- package/dist/state-machines/index.cjs +76 -18
- package/dist/state-machines/index.cjs.map +1 -1
- package/dist/state-machines/index.d.cts +2 -55
- package/dist/state-machines/index.d.ts +2 -55
- package/dist/state-machines/index.js +74 -2
- package/dist/state-machines/index.js.map +1 -1
- package/dist/testing/index.cjs +27 -19
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +17 -19
- package/dist/testing/index.d.ts +17 -19
- package/dist/testing/index.js +25 -3
- package/dist/testing/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/chunk-2AE6TMAX.cjs +0 -44
- package/dist/chunk-2AE6TMAX.cjs.map +0 -1
- package/dist/chunk-6HY35TKB.cjs +0 -491
- package/dist/chunk-6HY35TKB.cjs.map +0 -1
- package/dist/chunk-6UGEIDLC.cjs +0 -26
- package/dist/chunk-6UGEIDLC.cjs.map +0 -1
- package/dist/chunk-7GAWSUOG.js +0 -64
- package/dist/chunk-7GAWSUOG.js.map +0 -1
- package/dist/chunk-AFXFAEWA.js +0 -673
- package/dist/chunk-AFXFAEWA.js.map +0 -1
- package/dist/chunk-AFXKSIVI.cjs +0 -540
- package/dist/chunk-AFXKSIVI.cjs.map +0 -1
- package/dist/chunk-B5DOGDPG.js +0 -42
- package/dist/chunk-B5DOGDPG.js.map +0 -1
- package/dist/chunk-BJGZE3GE.js +0 -20
- package/dist/chunk-BJGZE3GE.js.map +0 -1
- package/dist/chunk-CRZXTZ36.cjs +0 -258
- package/dist/chunk-CRZXTZ36.cjs.map +0 -1
- package/dist/chunk-D4SWRBUH.cjs +0 -22
- package/dist/chunk-D4SWRBUH.cjs.map +0 -1
- package/dist/chunk-DBTAUI6C.cjs +0 -395
- package/dist/chunk-DBTAUI6C.cjs.map +0 -1
- package/dist/chunk-EMSAFNPX.js +0 -98
- package/dist/chunk-EMSAFNPX.js.map +0 -1
- package/dist/chunk-F3E5SXPN.cjs +0 -28
- package/dist/chunk-F3E5SXPN.cjs.map +0 -1
- package/dist/chunk-HEYMMVDP.js +0 -480
- package/dist/chunk-HEYMMVDP.js.map +0 -1
- package/dist/chunk-IFW43ELT.cjs +0 -331
- package/dist/chunk-IFW43ELT.cjs.map +0 -1
- package/dist/chunk-LFE74IJX.js +0 -20
- package/dist/chunk-LFE74IJX.js.map +0 -1
- package/dist/chunk-LZSE6QGQ.cjs +0 -60
- package/dist/chunk-LZSE6QGQ.cjs.map +0 -1
- package/dist/chunk-MCWSUGB3.cjs +0 -102
- package/dist/chunk-MCWSUGB3.cjs.map +0 -1
- package/dist/chunk-MLBALEUR.js +0 -290
- package/dist/chunk-MLBALEUR.js.map +0 -1
- package/dist/chunk-NNXQZPB3.cjs +0 -31
- package/dist/chunk-NNXQZPB3.cjs.map +0 -1
- package/dist/chunk-OFCCZ27Z.js +0 -26
- package/dist/chunk-OFCCZ27Z.js.map +0 -1
- package/dist/chunk-PDN5DOLQ.js +0 -242
- package/dist/chunk-PDN5DOLQ.js.map +0 -1
- package/dist/chunk-PIDZQAEL.js +0 -50
- package/dist/chunk-PIDZQAEL.js.map +0 -1
- package/dist/chunk-Q4Q4JPR3.js +0 -524
- package/dist/chunk-Q4Q4JPR3.js.map +0 -1
- package/dist/chunk-RALMUSOX.js +0 -55
- package/dist/chunk-RALMUSOX.js.map +0 -1
- package/dist/chunk-SNTV45LH.cjs +0 -295
- package/dist/chunk-SNTV45LH.cjs.map +0 -1
- package/dist/chunk-TBS2S5AX.cjs +0 -40
- package/dist/chunk-TBS2S5AX.cjs.map +0 -1
- package/dist/chunk-TYNIFC7J.js +0 -253
- package/dist/chunk-TYNIFC7J.js.map +0 -1
- package/dist/chunk-UGWGHTNC.cjs +0 -56
- package/dist/chunk-UGWGHTNC.cjs.map +0 -1
- package/dist/chunk-WI7CWNYI.cjs +0 -68
- package/dist/chunk-WI7CWNYI.cjs.map +0 -1
- package/dist/chunk-WNZP53GI.js +0 -386
- package/dist/chunk-WNZP53GI.js.map +0 -1
- package/dist/chunk-WQ3BYI7T.cjs +0 -249
- package/dist/chunk-WQ3BYI7T.cjs.map +0 -1
- package/dist/chunk-Y2PJLRIY.js +0 -36
- package/dist/chunk-Y2PJLRIY.js.map +0 -1
- package/dist/chunk-YGIPN3TU.cjs +0 -684
- package/dist/chunk-YGIPN3TU.cjs.map +0 -1
- package/dist/chunk-ZAEVQSB5.js +0 -326
- package/dist/chunk-ZAEVQSB5.js.map +0 -1
- package/dist/chunk-ZMQTV5OJ.js +0 -27
- package/dist/chunk-ZMQTV5OJ.js.map +0 -1
- package/dist/evidence/index.cjs.map +0 -1
- package/dist/evidence/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/policies/index.cjs.map +0 -1
- package/dist/policies/index.js.map +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
//#region privacy/engine.d.ts
|
|
2
|
+
declare const ANONYMIZATION_POLICY_VERSION = "adr-026-platform-anonymization-v1";
|
|
3
|
+
type JsonObject = Record<string, unknown>;
|
|
4
|
+
interface AnonymizationFieldPolicy {
|
|
5
|
+
method: RedactionMethod;
|
|
6
|
+
match: "key" | "path";
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
interface AnonymizationPolicy {
|
|
10
|
+
fields: readonly AnonymizationFieldPolicy[];
|
|
11
|
+
preservedSemantics?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
interface AssetEventLike {
|
|
14
|
+
id: string;
|
|
15
|
+
tenantId: string;
|
|
16
|
+
spaceId: string;
|
|
17
|
+
eventType: string;
|
|
18
|
+
subjectType: string;
|
|
19
|
+
subjectId: string;
|
|
20
|
+
actionInvocationId: string;
|
|
21
|
+
payload: unknown;
|
|
22
|
+
sequence: number;
|
|
23
|
+
occurredAt: Date;
|
|
24
|
+
recordedAt: Date;
|
|
25
|
+
correlationId: string;
|
|
26
|
+
causationId?: string | null;
|
|
27
|
+
}
|
|
28
|
+
interface EvidencePacketLike {
|
|
29
|
+
id: string;
|
|
30
|
+
packet: unknown;
|
|
31
|
+
redactionMetadata: unknown;
|
|
32
|
+
checksum: string;
|
|
33
|
+
}
|
|
34
|
+
interface AnonymizationLifecycleEvidence {
|
|
35
|
+
eventType: "AnonymizationApplied";
|
|
36
|
+
policyVersion: string;
|
|
37
|
+
jobId: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
appliedAt: string;
|
|
40
|
+
tenantId: string;
|
|
41
|
+
spaceId: string | null;
|
|
42
|
+
counts: {
|
|
43
|
+
assetEvents: number;
|
|
44
|
+
readModels: number;
|
|
45
|
+
evidencePackets: number;
|
|
46
|
+
redactedFields: number;
|
|
47
|
+
};
|
|
48
|
+
records: Array<{
|
|
49
|
+
recordClass: PlatformDataClass;
|
|
50
|
+
recordId: string;
|
|
51
|
+
subjectType?: string;
|
|
52
|
+
subjectId?: string;
|
|
53
|
+
fieldManifest: Array<Pick<AnonymizationFieldMetadata, "fieldPath" | "method" | "beforeChecksum">>;
|
|
54
|
+
}>;
|
|
55
|
+
preservedSemantics: string[];
|
|
56
|
+
}
|
|
57
|
+
declare function stableChecksum(value: unknown): string;
|
|
58
|
+
declare class FieldRedactor {
|
|
59
|
+
redactField(value: unknown, method: RedactionMethod, context: AnonymizationContext, path: string): unknown;
|
|
60
|
+
mask(value: unknown): string | null;
|
|
61
|
+
hash(value: unknown): string;
|
|
62
|
+
tokenize(value: unknown, context: AnonymizationContext, path: string): string;
|
|
63
|
+
generalize(value: unknown): unknown;
|
|
64
|
+
}
|
|
65
|
+
declare class AnonymizationEngine {
|
|
66
|
+
#private;
|
|
67
|
+
constructor(policy: AnonymizationPolicy);
|
|
68
|
+
anonymizeJsonValue<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass): AnonymizationResult<TValue>;
|
|
69
|
+
anonymizeJsonValueAtPath<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass, basePath: string): AnonymizationResult<TValue>;
|
|
70
|
+
anonymizeAssetEventPayload(event: AssetEventLike, context: AnonymizationContext): AnonymizationResult<unknown>;
|
|
71
|
+
anonymizeEvidencePacket(packet: EvidencePacketLike, context: AnonymizationContext): AnonymizationResult<Pick<EvidencePacketLike, "packet" | "redactionMetadata" | "checksum">>;
|
|
72
|
+
buildAnonymizationLifecycleEvidence(input: {
|
|
73
|
+
context: AnonymizationContext;
|
|
74
|
+
assetEvents?: Array<{
|
|
75
|
+
event: AssetEventLike;
|
|
76
|
+
metadata: AnonymizationMetadata;
|
|
77
|
+
}>;
|
|
78
|
+
readModels?: Array<{
|
|
79
|
+
modelKind: string;
|
|
80
|
+
record: JsonObject & {
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
metadata: AnonymizationMetadata;
|
|
84
|
+
}>;
|
|
85
|
+
evidencePackets?: Array<{
|
|
86
|
+
packet: EvidencePacketLike;
|
|
87
|
+
metadata: AnonymizationMetadata;
|
|
88
|
+
}>;
|
|
89
|
+
}): AnonymizationLifecycleEvidence;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region privacy/index.d.ts
|
|
93
|
+
declare const PLATFORM_PRIVACY_POLICY_VERSION = "fabric-platform-privacy-v1";
|
|
94
|
+
type RedactionMethod = "nullify" | "mask" | "hash" | "tokenize" | "generalize" | "drop";
|
|
95
|
+
declare function anonymizeJsonValue<TValue>(value: TValue, context: AnonymizationContext, dataClass: PlatformDataClass, policy: AnonymizationPolicy): AnonymizationResult<TValue>;
|
|
96
|
+
declare function anonymizeAssetEventPayload(event: AssetEventLike, context: AnonymizationContext, policy: AnonymizationPolicy): AnonymizationResult<unknown>;
|
|
97
|
+
declare function anonymizeEvidencePacket(packet: EvidencePacketLike, context: AnonymizationContext, policy: AnonymizationPolicy): AnonymizationResult<Pick<EvidencePacketLike, "packet" | "redactionMetadata" | "checksum">>;
|
|
98
|
+
declare function buildAnonymizationLifecycleEvidence(input: {
|
|
99
|
+
context: AnonymizationContext;
|
|
100
|
+
assetEvents?: Array<{
|
|
101
|
+
event: AssetEventLike;
|
|
102
|
+
metadata: AnonymizationMetadata;
|
|
103
|
+
}>;
|
|
104
|
+
readModels?: Array<{
|
|
105
|
+
modelKind: string;
|
|
106
|
+
record: Record<string, unknown> & {
|
|
107
|
+
id: string;
|
|
108
|
+
};
|
|
109
|
+
metadata: AnonymizationMetadata;
|
|
110
|
+
}>;
|
|
111
|
+
evidencePackets?: Array<{
|
|
112
|
+
packet: EvidencePacketLike;
|
|
113
|
+
metadata: AnonymizationMetadata;
|
|
114
|
+
}>;
|
|
115
|
+
}, policy: AnonymizationPolicy): AnonymizationLifecycleEvidence;
|
|
116
|
+
type PlatformDataClass = "asset_event" | "read_model" | "raw_payload" | "evidence_packet" | "action_evidence" | "access_event";
|
|
117
|
+
interface RedactionRule {
|
|
118
|
+
fieldPath: string;
|
|
119
|
+
method: RedactionMethod;
|
|
120
|
+
reason: string;
|
|
121
|
+
dataClass?: PlatformDataClass;
|
|
122
|
+
}
|
|
123
|
+
interface DataClassificationRule {
|
|
124
|
+
fieldPath: string;
|
|
125
|
+
classification: string;
|
|
126
|
+
containsDirectIdentifier?: boolean;
|
|
127
|
+
containsSensitiveData?: boolean;
|
|
128
|
+
}
|
|
129
|
+
interface AnonymizationContext {
|
|
130
|
+
tenantId: string;
|
|
131
|
+
spaceId?: string | null;
|
|
132
|
+
jobId: string;
|
|
133
|
+
reason: string;
|
|
134
|
+
redactedAt?: Date;
|
|
135
|
+
policyVersion?: string;
|
|
136
|
+
}
|
|
137
|
+
interface AnonymizationFieldMetadata {
|
|
138
|
+
fieldPath: string;
|
|
139
|
+
method: RedactionMethod;
|
|
140
|
+
policyVersion: string;
|
|
141
|
+
jobId: string;
|
|
142
|
+
redactedAt: string;
|
|
143
|
+
reason: string;
|
|
144
|
+
dataClass: PlatformDataClass;
|
|
145
|
+
beforeChecksum: string;
|
|
146
|
+
}
|
|
147
|
+
interface AnonymizationMetadata {
|
|
148
|
+
redactionState: "anonymized";
|
|
149
|
+
policyVersion: string;
|
|
150
|
+
jobId: string;
|
|
151
|
+
redactedAt: string;
|
|
152
|
+
reason: string;
|
|
153
|
+
dataClass: PlatformDataClass;
|
|
154
|
+
redactedFields: AnonymizationFieldMetadata[];
|
|
155
|
+
preservedSemantics: string[];
|
|
156
|
+
}
|
|
157
|
+
interface AnonymizationResult<TValue> {
|
|
158
|
+
value: TValue;
|
|
159
|
+
metadata: AnonymizationMetadata;
|
|
160
|
+
}
|
|
161
|
+
interface AnalyticsDataContractSource {
|
|
162
|
+
name: string;
|
|
163
|
+
privacyClass: "raw" | "operational_pii" | "tenant_scoped_tokenized" | "anonymized" | "aggregated" | "differentially_minimized";
|
|
164
|
+
containsDirectIdentifiers?: boolean;
|
|
165
|
+
containsGloballyStablePersonTokens?: boolean;
|
|
166
|
+
anonymizationPolicyVersion?: string;
|
|
167
|
+
minimumGroupSize?: number;
|
|
168
|
+
}
|
|
169
|
+
interface AnalyticsDataContract {
|
|
170
|
+
contractId: string;
|
|
171
|
+
status: "draft" | "accepted" | "deprecated";
|
|
172
|
+
crossTenant: boolean;
|
|
173
|
+
acceptedBy?: string;
|
|
174
|
+
acceptedAt?: string;
|
|
175
|
+
adrReference?: string;
|
|
176
|
+
sources: AnalyticsDataContractSource[];
|
|
177
|
+
}
|
|
178
|
+
interface AnalyticsEligibilityDecision {
|
|
179
|
+
eligible: boolean;
|
|
180
|
+
policyVersion: string;
|
|
181
|
+
reasons: string[];
|
|
182
|
+
}
|
|
183
|
+
interface RetentionRule {
|
|
184
|
+
dataClass: PlatformDataClass;
|
|
185
|
+
retainForDays: number;
|
|
186
|
+
afterRetention: "delete" | "anonymize" | "archive";
|
|
187
|
+
legalHoldExempt?: boolean;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { AssetEventLike as C, stableChecksum as E, AnonymizationPolicy as S, FieldRedactor as T, buildAnonymizationLifecycleEvidence as _, AnonymizationFieldMetadata as a, AnonymizationFieldPolicy as b, DataClassificationRule as c, RedactionMethod as d, RedactionRule as f, anonymizeJsonValue as g, anonymizeEvidencePacket as h, AnonymizationContext as i, PLATFORM_PRIVACY_POLICY_VERSION as l, anonymizeAssetEventPayload as m, AnalyticsDataContractSource as n, AnonymizationMetadata as o, RetentionRule as p, AnalyticsEligibilityDecision as r, AnonymizationResult as s, AnalyticsDataContract as t, PlatformDataClass as u, ANONYMIZATION_POLICY_VERSION as v, EvidencePacketLike as w, AnonymizationLifecycleEvidence as x, AnonymizationEngine as y };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { S as AnonymizationPolicy, o as AnonymizationMetadata } from "./index-BXpeFdk2.cjs";
|
|
2
|
+
//#region evidence/canonical-json.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Serializes a value as JSON with every object's keys sorted, recursively, by UTF-16 code-unit
|
|
5
|
+
* order (locale-independent). Array order is preserved.
|
|
6
|
+
*
|
|
7
|
+
* This is the serialization behind the `fabric-canonical-json-sha256-v1` digests: Host's
|
|
8
|
+
* parameter digests (`PARAMETER_DIGEST_ALGORITHM` in `@fabricorg/platform-host`) and evidence
|
|
9
|
+
* packet checksums (`EVIDENCE_PACKET_CHECKSUM_ALGORITHM`). Its output is a durable contract, so it
|
|
10
|
+
* must not change for any input. That includes values that are not plain JSON: any non-array
|
|
11
|
+
* object is rebuilt from its own enumerable entries before serialization, so a `Date` (which has
|
|
12
|
+
* none) serializes as `{}`, not as an ISO string. Convert dates to strings before calling this
|
|
13
|
+
* when they must survive into the output.
|
|
14
|
+
*/
|
|
15
|
+
declare function canonicalJson(value: unknown): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region evidence/generator.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Identifies how `EvidencePacketEnvelope.checksum` is computed: the lowercase hex SHA-256 of
|
|
20
|
+
* `canonicalJson(payload)`. It is the same identifier as Host's `PARAMETER_DIGEST_ALGORITHM`
|
|
21
|
+
* because the algorithm is the same (SHA-256 over `canonicalJson`).
|
|
22
|
+
*/
|
|
23
|
+
declare const EVIDENCE_PACKET_CHECKSUM_ALGORITHM: "fabric-canonical-json-sha256-v1";
|
|
24
|
+
/** Version of the `EvidencePacketPayload` shape produced by `generateEvidencePacket`. */
|
|
25
|
+
declare const EVIDENCE_PACKET_SCHEMA_VERSION: 1;
|
|
26
|
+
/** Packet type used when the input does not name one. */
|
|
27
|
+
declare const DEFAULT_EVIDENCE_PACKET_TYPE = "compliance_evidence";
|
|
28
|
+
/** Anonymization reason recorded when the caller does not supply one. */
|
|
29
|
+
declare const DEFAULT_EVIDENCE_REDACTION_REASON = "evidence_packet_generation";
|
|
30
|
+
/**
|
|
31
|
+
* A `Date`, or an ISO 8601 / PostgreSQL ISO date-time string with an explicit zone (`Z`, `+HH`,
|
|
32
|
+
* `+HH:MM` or `+HHMM`). Zone-less, non-ISO and out-of-range strings are rejected.
|
|
33
|
+
*/
|
|
34
|
+
type EvidenceTimestamp = Date | string;
|
|
35
|
+
/** Tenant and space every record read through the port must belong to. */
|
|
36
|
+
interface EvidenceScope {
|
|
37
|
+
tenantId: string;
|
|
38
|
+
spaceId: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* An asset event as the read port returns it. `AssetEventEnvelope` (events) and `AssetEventLike`
|
|
42
|
+
* (privacy) both satisfy this shape. Fields beyond these are kept in the packet payload.
|
|
43
|
+
*/
|
|
44
|
+
interface EvidenceEventRecord {
|
|
45
|
+
id: string;
|
|
46
|
+
tenantId: string;
|
|
47
|
+
spaceId: string;
|
|
48
|
+
eventType: string;
|
|
49
|
+
subjectType: string;
|
|
50
|
+
subjectId: string;
|
|
51
|
+
actionInvocationId?: string | null;
|
|
52
|
+
sequence: number;
|
|
53
|
+
occurredAt: EvidenceTimestamp;
|
|
54
|
+
recordedAt: EvidenceTimestamp;
|
|
55
|
+
correlationId: string;
|
|
56
|
+
causationId?: string | null;
|
|
57
|
+
payload: unknown;
|
|
58
|
+
}
|
|
59
|
+
/** An action invocation, policy evaluation or adapter invocation record. Further fields are kept. */
|
|
60
|
+
interface EvidenceRecord {
|
|
61
|
+
id: string;
|
|
62
|
+
tenantId: string;
|
|
63
|
+
spaceId: string;
|
|
64
|
+
actionInvocationId?: string | null;
|
|
65
|
+
[field: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
/** A record that belongs to one action invocation (policy evaluations, adapter invocations). */
|
|
68
|
+
interface EvidenceInvocationRecord extends EvidenceRecord {
|
|
69
|
+
actionInvocationId: string;
|
|
70
|
+
}
|
|
71
|
+
interface EvidenceEventQuery extends EvidenceScope {
|
|
72
|
+
/** The subject the packet is about. Always `subjects[0]`. */
|
|
73
|
+
primarySubject: EvidencePacketSubject;
|
|
74
|
+
/** Primary subject first, then related subjects, de-duplicated and sorted. */
|
|
75
|
+
subjects: readonly EvidencePacketSubject[];
|
|
76
|
+
}
|
|
77
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Read-only access to the application's evidence store. The generator filters nothing the port
|
|
80
|
+
* returns; it rejects, rather than drops, a record that fails one of its checks:
|
|
81
|
+
*
|
|
82
|
+
* - every record must have the generation context's `tenantId` and `spaceId`;
|
|
83
|
+
* - action invocations must have one of the requested ids, and policy evaluations and adapter
|
|
84
|
+
* invocations one of the requested `actionInvocationId`s;
|
|
85
|
+
* - records must have the documented shape (non-empty `id`, event fields, parseable timestamps) and
|
|
86
|
+
* be representable as plain JSON, and any `_privacy` value must be engine-written
|
|
87
|
+
* `AnonymizationMetadata`.
|
|
88
|
+
*
|
|
89
|
+
* Which events belong to the packet is the port's decision: the generator does not check an event's
|
|
90
|
+
* subject against `subjects`, because a port may legitimately return events recorded against the
|
|
91
|
+
* primary subject's own action invocations under another subject.
|
|
92
|
+
*/
|
|
93
|
+
interface EvidencePacketReadPort {
|
|
94
|
+
/** Asset events for the given subjects within the tenant and space. Required. */
|
|
95
|
+
listEvents(query: EvidenceEventQuery): MaybePromise<readonly EvidenceEventRecord[]>;
|
|
96
|
+
/** The application's related-subject rules. When absent, only the primary subject is used. */
|
|
97
|
+
resolveRelatedSubjects?(subject: EvidencePacketSubject, scope: EvidenceScope): MaybePromise<readonly EvidencePacketSubject[]>;
|
|
98
|
+
/** Action invocations by id. When absent, the section is empty. */
|
|
99
|
+
listActionInvocations?(scope: EvidenceScope, ids: readonly string[]): MaybePromise<readonly EvidenceRecord[]>;
|
|
100
|
+
/** Policy evaluations for the given action invocations. When absent, the section is empty. */
|
|
101
|
+
listPolicyEvaluations?(scope: EvidenceScope, actionInvocationIds: readonly string[]): MaybePromise<readonly EvidenceInvocationRecord[]>;
|
|
102
|
+
/** Adapter invocations for the given action invocations. When absent, the section is empty. */
|
|
103
|
+
listAdapterInvocations?(scope: EvidenceScope, actionInvocationIds: readonly string[]): MaybePromise<readonly EvidenceInvocationRecord[]>;
|
|
104
|
+
}
|
|
105
|
+
/** A record after normalization: plain JSON, every `Date` replaced by its ISO string. */
|
|
106
|
+
type EvidenceJsonRecord = Record<string, unknown>;
|
|
107
|
+
interface EvidencePacketPayload {
|
|
108
|
+
schemaVersion: typeof EVIDENCE_PACKET_SCHEMA_VERSION;
|
|
109
|
+
packetType: string;
|
|
110
|
+
tenantId: string;
|
|
111
|
+
spaceId: string;
|
|
112
|
+
primarySubject: EvidencePacketSubject;
|
|
113
|
+
subjects: EvidencePacketSubject[];
|
|
114
|
+
includeRelated: boolean;
|
|
115
|
+
policyVersion?: string;
|
|
116
|
+
events: EvidenceJsonRecord[];
|
|
117
|
+
actionInvocations: EvidenceJsonRecord[];
|
|
118
|
+
policyEvaluations: EvidenceJsonRecord[];
|
|
119
|
+
adapterInvocations: EvidenceJsonRecord[];
|
|
120
|
+
/** Metadata from the anonymization pass over the rest of the payload (validated engine-written `_privacy` values pass through it unchanged). */
|
|
121
|
+
redaction: AnonymizationMetadata;
|
|
122
|
+
}
|
|
123
|
+
interface GenerateEvidencePacketInput {
|
|
124
|
+
subject: EvidencePacketSubject;
|
|
125
|
+
/** Set to `false` to skip `resolveRelatedSubjects`. Defaults to `true`. */
|
|
126
|
+
includeRelated?: boolean;
|
|
127
|
+
/** Defaults to `DEFAULT_EVIDENCE_PACKET_TYPE`. */
|
|
128
|
+
packetType?: string;
|
|
129
|
+
policyVersion?: string;
|
|
130
|
+
}
|
|
131
|
+
interface GenerateEvidencePacketOptions {
|
|
132
|
+
port: EvidencePacketReadPort;
|
|
133
|
+
/**
|
|
134
|
+
* Redaction applied to the whole payload with data class `"evidence_packet"`. Required so that
|
|
135
|
+
* redaction cannot be skipped by omission; pass `{ fields: [] }` to redact nothing.
|
|
136
|
+
*/
|
|
137
|
+
anonymizationPolicy: AnonymizationPolicy;
|
|
138
|
+
anonymization?: {
|
|
139
|
+
/** Defaults to the packet id. */
|
|
140
|
+
jobId?: string;
|
|
141
|
+
/** Defaults to `DEFAULT_EVIDENCE_REDACTION_REASON`. */
|
|
142
|
+
reason?: string;
|
|
143
|
+
/** Defaults to the engine's `ANONYMIZATION_POLICY_VERSION`. */
|
|
144
|
+
policyVersion?: string;
|
|
145
|
+
};
|
|
146
|
+
/** Defaults to `createFabricId(FABRIC_ID_PREFIXES.complianceEvidencePacket)`. */
|
|
147
|
+
idFactory?: () => string;
|
|
148
|
+
}
|
|
149
|
+
type EvidencePacketGenerationErrorCode = "EVIDENCE_SCOPE_MISMATCH" | "EVIDENCE_INVALID_RECORD" | "EVIDENCE_UNREQUESTED_RECORD" | "EVIDENCE_IDENTIFIER_REDACTED";
|
|
150
|
+
declare class EvidencePacketGenerationError extends Error {
|
|
151
|
+
readonly code: EvidencePacketGenerationErrorCode;
|
|
152
|
+
constructor(code: EvidencePacketGenerationErrorCode, message: string);
|
|
153
|
+
}
|
|
154
|
+
/** Lowercase hex SHA-256 of `canonicalJson(payload)`. */
|
|
155
|
+
declare function computeEvidencePacketChecksum(payload: unknown): string;
|
|
156
|
+
/**
|
|
157
|
+
* Builds a sealed evidence packet for one subject from the application's read port.
|
|
158
|
+
*
|
|
159
|
+
* Steps: resolve subjects (primary first, then related, de-duplicated and sorted); read events,
|
|
160
|
+
* then the action invocations, policy evaluations and adapter invocations those events reference;
|
|
161
|
+
* reject any record outside `context.tenantId`/`context.spaceId`; normalize to plain JSON and sort
|
|
162
|
+
* deterministically; redact the payload with `AnonymizationEngine` (data class
|
|
163
|
+
* `"evidence_packet"`); checksum the redacted payload; and build references from it.
|
|
164
|
+
*
|
|
165
|
+
* Nothing is persisted. Storing the returned envelope is the application's job.
|
|
166
|
+
*/
|
|
167
|
+
declare function generateEvidencePacket<TDb = unknown>(input: GenerateEvidencePacketInput, context: EvidenceGenerationContext<TDb>, options: GenerateEvidencePacketOptions): Promise<EvidencePacketEnvelope<EvidencePacketPayload>>;
|
|
168
|
+
/**
|
|
169
|
+
* Recomputes an envelope's checksum. Returns `false`, never throws, when the checksum is missing,
|
|
170
|
+
* the algorithm is missing or unknown, the payload cannot be serialized, or the values differ.
|
|
171
|
+
* It covers `payload` only, which includes the subjects and the redaction metadata; the other
|
|
172
|
+
* envelope fields are not covered.
|
|
173
|
+
*/
|
|
174
|
+
declare function verifyEvidencePacketChecksum(envelope: Pick<EvidencePacketEnvelope<unknown>, "payload" | "checksum" | "checksumAlgorithm">): boolean;
|
|
175
|
+
type EvidencePacketRendererInput = Omit<GenerateEvidencePacketInput, "packetType">;
|
|
176
|
+
interface EvidencePacketRendererOptions extends GenerateEvidencePacketOptions {
|
|
177
|
+
packetType?: string;
|
|
178
|
+
}
|
|
179
|
+
/** Wraps `generateEvidencePacket` as an `EvidenceRenderer` for one packet type. */
|
|
180
|
+
declare function createEvidencePacketRenderer<TDb = unknown>(options: EvidencePacketRendererOptions): EvidenceRenderer<EvidencePacketRendererInput, EvidencePacketPayload, TDb>;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region evidence/index.d.ts
|
|
183
|
+
type EvidencePacketStatus = "draft" | "sealed" | "superseded";
|
|
184
|
+
interface EvidencePacketSubject {
|
|
185
|
+
subjectType: string;
|
|
186
|
+
subjectId: string;
|
|
187
|
+
}
|
|
188
|
+
interface EvidencePacketReference {
|
|
189
|
+
referenceType: "action_invocation" | "asset_event" | "policy_evaluation" | "adapter_invocation" | "document" | "external_observation";
|
|
190
|
+
referenceId: string;
|
|
191
|
+
checksum?: string;
|
|
192
|
+
uri?: string;
|
|
193
|
+
metadata?: Record<string, unknown>;
|
|
194
|
+
}
|
|
195
|
+
interface EvidencePacketEnvelope<TPayload = Record<string, unknown>> {
|
|
196
|
+
id: string;
|
|
197
|
+
tenantId: string;
|
|
198
|
+
spaceId: string;
|
|
199
|
+
packetType: string;
|
|
200
|
+
status: EvidencePacketStatus;
|
|
201
|
+
subjects: EvidencePacketSubject[];
|
|
202
|
+
references: EvidencePacketReference[];
|
|
203
|
+
payload: TPayload;
|
|
204
|
+
generatedAt: Date | string;
|
|
205
|
+
generatedBy: string;
|
|
206
|
+
policyVersion?: string;
|
|
207
|
+
checksum?: string;
|
|
208
|
+
/**
|
|
209
|
+
* How `checksum` was computed. Packets built by `generateEvidencePacket` use
|
|
210
|
+
* `EVIDENCE_PACKET_CHECKSUM_ALGORITHM`. Optional and additive: envelopes built before this field
|
|
211
|
+
* existed omit it.
|
|
212
|
+
*/
|
|
213
|
+
checksumAlgorithm?: string;
|
|
214
|
+
correlationId: string;
|
|
215
|
+
causationId?: string;
|
|
216
|
+
}
|
|
217
|
+
interface EvidenceGenerationContext<TDb = unknown> {
|
|
218
|
+
tenantId: string;
|
|
219
|
+
spaceId: string;
|
|
220
|
+
actorId: string;
|
|
221
|
+
correlationId: string;
|
|
222
|
+
causationId?: string;
|
|
223
|
+
db: TDb;
|
|
224
|
+
now?: Date;
|
|
225
|
+
}
|
|
226
|
+
interface EvidenceRenderer<TInput = unknown, TPayload = Record<string, unknown>, TDb = unknown> {
|
|
227
|
+
packetType: string;
|
|
228
|
+
render: (input: TInput, context: EvidenceGenerationContext<TDb>) => Promise<EvidencePacketEnvelope<TPayload>> | EvidencePacketEnvelope<TPayload>;
|
|
229
|
+
}
|
|
230
|
+
//#endregion
|
|
231
|
+
export { canonicalJson as A, EvidenceTimestamp as C, createEvidencePacketRenderer as D, computeEvidencePacketChecksum as E, generateEvidencePacket as O, EvidenceScope as S, GenerateEvidencePacketOptions as T, EvidencePacketPayload as _, EvidencePacketSubject as a, EvidencePacketRendererOptions as b, DEFAULT_EVIDENCE_REDACTION_REASON as c, EvidenceEventQuery as d, EvidenceEventRecord as f, EvidencePacketGenerationErrorCode as g, EvidencePacketGenerationError as h, EvidencePacketStatus as i, verifyEvidencePacketChecksum as k, EVIDENCE_PACKET_CHECKSUM_ALGORITHM as l, EvidenceJsonRecord as m, EvidencePacketEnvelope as n, EvidenceRenderer as o, EvidenceInvocationRecord as p, EvidencePacketReference as r, DEFAULT_EVIDENCE_PACKET_TYPE as s, EvidenceGenerationContext as t, EVIDENCE_PACKET_SCHEMA_VERSION as u, EvidencePacketReadPort as v, GenerateEvidencePacketInput as w, EvidenceRecord as x, EvidencePacketRendererInput as y };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region discovery/index.d.ts
|
|
2
|
+
/** Portable discovery metadata. It never grants or denies runtime invocation authority. */
|
|
3
|
+
interface SurfaceDeclaration {
|
|
4
|
+
/** Omitted is public discovery; internal contracts are withheld from external catalogs. */
|
|
5
|
+
surface?: "public" | "internal";
|
|
6
|
+
/** Required, non-blank explanation when surface is internal; never include sensitive data. */
|
|
7
|
+
surfaceReason?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function assertSurfaceDeclaration(value: unknown, label?: string): asserts value is SurfaceDeclaration;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { assertSurfaceDeclaration as n, SurfaceDeclaration as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region discovery/index.d.ts
|
|
2
|
+
/** Portable discovery metadata. It never grants or denies runtime invocation authority. */
|
|
3
|
+
interface SurfaceDeclaration {
|
|
4
|
+
/** Omitted is public discovery; internal contracts are withheld from external catalogs. */
|
|
5
|
+
surface?: "public" | "internal";
|
|
6
|
+
/** Required, non-blank explanation when surface is internal; never include sensitive data. */
|
|
7
|
+
surfaceReason?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function assertSurfaceDeclaration(value: unknown, label?: string): asserts value is SurfaceDeclaration;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { assertSurfaceDeclaration as n, SurfaceDeclaration as t };
|