@open-charging-cloud/chargy-gui 0.0.0-stage → 0.1.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 +87 -0
- package/LICENSE +661 -0
- package/README.md +48 -2
- package/SECURITY.md +21 -0
- package/dist/anchorKeyTrust.d.ts +9 -0
- package/dist/anchorKeyTrust.d.ts.map +1 -0
- package/dist/anchorKeyTrust.js +24 -0
- package/dist/anchorKeyTrust.js.map +1 -0
- package/dist/anchorKeyTrustView.d.ts +14 -0
- package/dist/anchorKeyTrustView.d.ts.map +1 -0
- package/dist/anchorKeyTrustView.js +95 -0
- package/dist/anchorKeyTrustView.js.map +1 -0
- package/dist/browserFiles.d.ts +5 -0
- package/dist/browserFiles.d.ts.map +1 -0
- package/dist/browserFiles.js +100 -0
- package/dist/browserFiles.js.map +1 -0
- package/dist/core/i18n.json +1518 -0
- package/dist/core/package.json +119 -0
- package/dist/core/validationRules.json +8 -0
- package/dist/domHelpers.d.ts +25 -0
- package/dist/domHelpers.d.ts.map +1 -0
- package/dist/domHelpers.js +212 -0
- package/dist/domHelpers.js.map +1 -0
- package/dist/historicalSessionPanel.d.ts +24 -0
- package/dist/historicalSessionPanel.d.ts.map +1 -0
- package/dist/historicalSessionPanel.js +108 -0
- package/dist/historicalSessionPanel.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/liveLinkTrust.d.ts +208 -0
- package/dist/liveLinkTrust.d.ts.map +1 -0
- package/dist/liveLinkTrust.js +452 -0
- package/dist/liveLinkTrust.js.map +1 -0
- package/dist/livePOISession.d.ts +38 -0
- package/dist/livePOISession.d.ts.map +1 -0
- package/dist/livePOISession.js +193 -0
- package/dist/livePOISession.js.map +1 -0
- package/dist/measurementDetailsRenderer.d.ts +25 -0
- package/dist/measurementDetailsRenderer.d.ts.map +1 -0
- package/dist/measurementDetailsRenderer.js +343 -0
- package/dist/measurementDetailsRenderer.js.map +1 -0
- package/dist/poiConsistencyView.d.ts +3 -0
- package/dist/poiConsistencyView.d.ts.map +1 -0
- package/dist/poiConsistencyView.js +14 -0
- package/dist/poiConsistencyView.js.map +1 -0
- package/dist/poiObservedHistory.d.ts +49 -0
- package/dist/poiObservedHistory.d.ts.map +1 -0
- package/dist/poiObservedHistory.js +205 -0
- package/dist/poiObservedHistory.js.map +1 -0
- package/dist/poiTransport.d.ts +12 -0
- package/dist/poiTransport.d.ts.map +1 -0
- package/dist/poiTransport.js +74 -0
- package/dist/poiTransport.js.map +1 -0
- package/dist/poiTrustContext.d.ts +134 -0
- package/dist/poiTrustContext.d.ts.map +1 -0
- package/dist/poiTrustContext.js +243 -0
- package/dist/poiTrustContext.js.map +1 -0
- package/dist/poiTrustLineage.d.ts +10 -0
- package/dist/poiTrustLineage.d.ts.map +1 -0
- package/dist/poiTrustLineage.js +47 -0
- package/dist/poiTrustLineage.js.map +1 -0
- package/dist/poiURLs.d.ts +5 -0
- package/dist/poiURLs.d.ts.map +1 -0
- package/dist/poiURLs.js +24 -0
- package/dist/poiURLs.js.map +1 -0
- package/dist/poiWitnessManagement.d.ts +3 -0
- package/dist/poiWitnessManagement.d.ts.map +1 -0
- package/dist/poiWitnessManagement.js +127 -0
- package/dist/poiWitnessManagement.js.map +1 -0
- package/dist/poiWitnessTrust.d.ts +26 -0
- package/dist/poiWitnessTrust.d.ts.map +1 -0
- package/dist/poiWitnessTrust.js +90 -0
- package/dist/poiWitnessTrust.js.map +1 -0
- package/dist/pricePublicationData.d.ts +19 -0
- package/dist/pricePublicationData.d.ts.map +1 -0
- package/dist/pricePublicationData.js +83 -0
- package/dist/pricePublicationData.js.map +1 -0
- package/dist/roamingNetworks.d.ts +14 -0
- package/dist/roamingNetworks.d.ts.map +1 -0
- package/dist/roamingNetworks.js +33 -0
- package/dist/roamingNetworks.js.map +1 -0
- package/dist/securityFingerprint.d.ts +16 -0
- package/dist/securityFingerprint.d.ts.map +1 -0
- package/dist/securityFingerprint.js +36 -0
- package/dist/securityFingerprint.js.map +1 -0
- package/dist/securityFingerprintView.d.ts +3 -0
- package/dist/securityFingerprintView.d.ts.map +1 -0
- package/dist/securityFingerprintView.js +61 -0
- package/dist/securityFingerprintView.js.map +1 -0
- package/dist/sessionEvidenceStore.d.ts +23 -0
- package/dist/sessionEvidenceStore.d.ts.map +1 -0
- package/dist/sessionEvidenceStore.js +81 -0
- package/dist/sessionEvidenceStore.js.map +1 -0
- package/dist/sessionMeterKeyView.d.ts +9 -0
- package/dist/sessionMeterKeyView.d.ts.map +1 -0
- package/dist/sessionMeterKeyView.js +55 -0
- package/dist/sessionMeterKeyView.js.map +1 -0
- package/dist/sessionPOIData.d.ts +49 -0
- package/dist/sessionPOIData.d.ts.map +1 -0
- package/dist/sessionPOIData.js +161 -0
- package/dist/sessionPOIData.js.map +1 -0
- package/dist/sessionPOIPanel.d.ts +50 -0
- package/dist/sessionPOIPanel.d.ts.map +1 -0
- package/dist/sessionPOIPanel.js +288 -0
- package/dist/sessionPOIPanel.js.map +1 -0
- package/dist/sessionPriceData.d.ts +17 -0
- package/dist/sessionPriceData.d.ts.map +1 -0
- package/dist/sessionPriceData.js +51 -0
- package/dist/sessionPriceData.js.map +1 -0
- package/dist/sessionPricePanel.d.ts +31 -0
- package/dist/sessionPricePanel.d.ts.map +1 -0
- package/dist/sessionPricePanel.js +222 -0
- package/dist/sessionPricePanel.js.map +1 -0
- package/dist/sessionUIState.d.ts +12 -0
- package/dist/sessionUIState.d.ts.map +1 -0
- package/dist/sessionUIState.js +33 -0
- package/dist/sessionUIState.js.map +1 -0
- package/dist/stationProofData.d.ts +38 -0
- package/dist/stationProofData.d.ts.map +1 -0
- package/dist/stationProofData.js +83 -0
- package/dist/stationProofData.js.map +1 -0
- package/dist/stationProofPanel.d.ts +44 -0
- package/dist/stationProofPanel.d.ts.map +1 -0
- package/dist/stationProofPanel.js +304 -0
- package/dist/stationProofPanel.js.map +1 -0
- package/dist/stationProofView.d.ts +9 -0
- package/dist/stationProofView.d.ts.map +1 -0
- package/dist/stationProofView.js +186 -0
- package/dist/stationProofView.js.map +1 -0
- package/dist/trustAnchorData.d.ts +40 -0
- package/dist/trustAnchorData.d.ts.map +1 -0
- package/dist/trustAnchorData.js +91 -0
- package/dist/trustAnchorData.js.map +1 -0
- package/dist/trustAnchorDataView.d.ts +13 -0
- package/dist/trustAnchorDataView.d.ts.map +1 -0
- package/dist/trustAnchorDataView.js +69 -0
- package/dist/trustAnchorDataView.js.map +1 -0
- package/dist/trustAnchorImport.d.ts +5 -0
- package/dist/trustAnchorImport.d.ts.map +1 -0
- package/dist/trustAnchorImport.js +34 -0
- package/dist/trustAnchorImport.js.map +1 -0
- package/dist/trustAnchorPreview.d.ts +37 -0
- package/dist/trustAnchorPreview.d.ts.map +1 -0
- package/dist/trustAnchorPreview.js +180 -0
- package/dist/trustAnchorPreview.js.map +1 -0
- package/dist/trustManagement.d.ts +34 -0
- package/dist/trustManagement.d.ts.map +1 -0
- package/dist/trustManagement.js +405 -0
- package/dist/trustManagement.js.map +1 -0
- package/dist/trustStore.d.ts +75 -0
- package/dist/trustStore.d.ts.map +1 -0
- package/dist/trustStore.js +408 -0
- package/dist/trustStore.js.map +1 -0
- package/dist/trustTransitionView.d.ts +5 -0
- package/dist/trustTransitionView.d.ts.map +1 -0
- package/dist/trustTransitionView.js +110 -0
- package/dist/trustTransitionView.js.map +1 -0
- package/dist/trustedPublicKeys.d.ts +4 -0
- package/dist/trustedPublicKeys.d.ts.map +1 -0
- package/dist/trustedPublicKeys.js +25 -0
- package/dist/trustedPublicKeys.js.map +1 -0
- package/dist/wwcpPoi.d.ts +2 -0
- package/dist/wwcpPoi.d.ts.map +1 -0
- package/dist/wwcpPoi.js +2 -0
- package/dist/wwcpPoi.js.map +1 -0
- package/documentation/AUDIT.md +262 -0
- package/images/NGI0_tag.svg +149 -0
- package/package.json +75 -4
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ObservationScope, ObservedHistoryRepository } from './poiObservedHistory.js';
|
|
2
|
+
import { verifyChargingDocumentKeys, OperatorTrust, TrustAnchor, TrustContext, HistoricalTrustContext } from '@open-charging-cloud/wwcp-poi';
|
|
3
|
+
import type { ObservedVersions, VersionObservation, VersionComparison, SessionPriceRequest, SessionPriceVerification, EpochProfiles, VerifiedTrustTransition } from '@open-charging-cloud/wwcp-poi';
|
|
4
|
+
import type { JSONValue, POIPublicKey, VerifiedChargingStation, VerifiedMeterKeyBinding, MeasurementKeyFormat, HistoricalMeterVerification } from '@open-charging-cloud/wwcp-poi';
|
|
5
|
+
import type { StoredTrustAnchorData } from './trustAnchorData.js';
|
|
6
|
+
import type { StoredTrustAnchor, TrustStore } from './trustStore.js';
|
|
7
|
+
import type { WitnessPolicyRepository } from './poiWitnessTrust.js';
|
|
8
|
+
/** An immutable report at evaluatedAt, never a reusable authorization token or a stored green flag. */
|
|
9
|
+
export interface POITrustContext {
|
|
10
|
+
readonly epoch?: number;
|
|
11
|
+
readonly epochProfiles?: EpochProfiles;
|
|
12
|
+
readonly verifiedTransitions?: readonly VerifiedTrustTransition[];
|
|
13
|
+
readonly effectivePolicyId?: string;
|
|
14
|
+
readonly verification: TrustContext;
|
|
15
|
+
readonly anchorPolicyId: string;
|
|
16
|
+
/** Conservatively scoped to this exact bootstrap policy until verified succession is supported. */
|
|
17
|
+
readonly networkIdentity: string;
|
|
18
|
+
readonly roamingNetworkId: string;
|
|
19
|
+
readonly roamingNetworkOperatorId: string;
|
|
20
|
+
readonly keyStatementDigest: string;
|
|
21
|
+
readonly evaluatedAt: number;
|
|
22
|
+
readonly validUntil: number;
|
|
23
|
+
readonly requiredConsensus: number;
|
|
24
|
+
/** Original holder positions are retained, including empty groups. */
|
|
25
|
+
readonly authorizedHolders: readonly (readonly string[])[];
|
|
26
|
+
readonly evidence: {
|
|
27
|
+
readonly bootstrapAnchorQRCode?: string;
|
|
28
|
+
readonly anchorQRCode: string;
|
|
29
|
+
readonly keyStatement: StoredTrustAnchorData;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface POIHistoricalContext extends Omit<POITrustContext, 'verification'> {
|
|
33
|
+
readonly verification: HistoricalTrustContext;
|
|
34
|
+
}
|
|
35
|
+
/** Reparse original evidence; callers cannot substitute a pre-parsed statement or cached verification result. */
|
|
36
|
+
export declare function createPOITrustContext(anchor: TrustAnchor, document: StoredTrustAnchorData, record: StoredTrustAnchor | undefined, bundled: readonly POIPublicKey[], deleted: ReadonlySet<string>, at?: number): POITrustContext;
|
|
37
|
+
export declare class POIHistoryError extends Error {
|
|
38
|
+
readonly report: VersionComparison;
|
|
39
|
+
constructor(report: VersionComparison);
|
|
40
|
+
}
|
|
41
|
+
export interface POIObservationTicket {
|
|
42
|
+
readonly context: POITrustContext | POIHistoricalContext;
|
|
43
|
+
readonly scope: ObservationScope;
|
|
44
|
+
readonly generation: string;
|
|
45
|
+
readonly historical: boolean;
|
|
46
|
+
readonly observed: ObservedVersions;
|
|
47
|
+
}
|
|
48
|
+
/** Storage-backed gateway. Every call reads current local decisions in one transaction; no authorization cache. */
|
|
49
|
+
export declare class POITrustService {
|
|
50
|
+
private readonly store;
|
|
51
|
+
private readonly bundled;
|
|
52
|
+
private readonly now;
|
|
53
|
+
private readonly history;
|
|
54
|
+
private readonly witnessPolicies;
|
|
55
|
+
previewTrustTransition(policyId: string, text: string, acceptedAt?: number): Promise<{
|
|
56
|
+
readonly record: StoredTrustAnchor;
|
|
57
|
+
readonly deleted: ReadonlySet<string>;
|
|
58
|
+
readonly context: POITrustContext;
|
|
59
|
+
readonly transition: VerifiedTrustTransition;
|
|
60
|
+
readonly consistency: VersionComparison;
|
|
61
|
+
readonly acceptedAt: string;
|
|
62
|
+
}>;
|
|
63
|
+
validateTransitionAppend(record: StoredTrustAnchor, deleted: ReadonlySet<string>, text: string, acceptedAt: string): void;
|
|
64
|
+
verifyLiveDocumentKeys(policyId: string, proof: JSONValue, request: {
|
|
65
|
+
readonly evseId: string;
|
|
66
|
+
readonly operatorId: string;
|
|
67
|
+
readonly at: number;
|
|
68
|
+
}, signal?: AbortSignal): Promise<ReturnType<typeof verifyChargingDocumentKeys>>;
|
|
69
|
+
private stationPoint;
|
|
70
|
+
private authenticatedCheckpoints;
|
|
71
|
+
constructor(store: Pick<TrustStore, 'trustSnapshot'>, bundled: readonly POIPublicKey[], now?: () => number, history?: ObservedHistoryRepository, witnessPolicies?: WitnessPolicyRepository);
|
|
72
|
+
assertPublicationPolicy(revision: string): Promise<void>;
|
|
73
|
+
resolve(anchorPolicyId: string): Promise<POITrustContext>;
|
|
74
|
+
resolveHistorical(anchorPolicyId: string): Promise<POIHistoricalContext>;
|
|
75
|
+
beginObservations(anchorPolicyId: string, historical?: boolean, signal?: AbortSignal): Promise<POIObservationTicket>;
|
|
76
|
+
recordObservations(ticket: POIObservationTicket, points: readonly VersionObservation[], mode: 'current' | 'historical', options?: {
|
|
77
|
+
readonly signal?: AbortSignal | undefined;
|
|
78
|
+
readonly live?: {
|
|
79
|
+
readonly chain: string;
|
|
80
|
+
readonly evidence: string;
|
|
81
|
+
};
|
|
82
|
+
readonly validUntil?: number;
|
|
83
|
+
}): Promise<VersionComparison>;
|
|
84
|
+
private checkpoints;
|
|
85
|
+
verifyCurrentCheckpoints(anchorPolicyId: string, entries: readonly {
|
|
86
|
+
readonly checkpoint: JSONValue;
|
|
87
|
+
readonly operator: JSONValue;
|
|
88
|
+
}[]): Promise<VersionComparison>;
|
|
89
|
+
verifyCurrentPrices(anchorPolicyId: string, proof: JSONValue, statements: readonly JSONValue[], evseId: string): Promise<{
|
|
90
|
+
readonly consistency: VersionComparison;
|
|
91
|
+
}>;
|
|
92
|
+
verifyOperator(anchorPolicyId: string, operator: JSONValue): Promise<{
|
|
93
|
+
readonly context: POITrustContext;
|
|
94
|
+
readonly trust: OperatorTrust;
|
|
95
|
+
}>;
|
|
96
|
+
verifyMeterKey(anchorPolicyId: string, proof: JSONValue, request: {
|
|
97
|
+
readonly evseId: string;
|
|
98
|
+
readonly meterSerialNumber: string;
|
|
99
|
+
readonly keyFormat: MeasurementKeyFormat;
|
|
100
|
+
}, signal?: AbortSignal): Promise<{
|
|
101
|
+
readonly context: POITrustContext;
|
|
102
|
+
readonly binding: VerifiedMeterKeyBinding;
|
|
103
|
+
}>;
|
|
104
|
+
verifyHistoricalMeterEvidence(anchorPolicyId: string, evidence: JSONValue, request: {
|
|
105
|
+
readonly evseId: string;
|
|
106
|
+
readonly meterSerialNumber: string;
|
|
107
|
+
readonly measurementTimes: readonly number[];
|
|
108
|
+
readonly keyFormat: MeasurementKeyFormat;
|
|
109
|
+
}, signal?: AbortSignal): Promise<{
|
|
110
|
+
readonly context: POIHistoricalContext;
|
|
111
|
+
readonly evidence: HistoricalMeterVerification;
|
|
112
|
+
readonly consistency: VersionComparison;
|
|
113
|
+
}>;
|
|
114
|
+
verifySessionPriceEvidence(anchorPolicyId: string, evidence: JSONValue, request: SessionPriceRequest, relatedCheckpoints?: readonly {
|
|
115
|
+
readonly checkpoint: JSONValue;
|
|
116
|
+
readonly operator: JSONValue;
|
|
117
|
+
}[], signal?: AbortSignal): Promise<{
|
|
118
|
+
readonly context: POIHistoricalContext;
|
|
119
|
+
readonly price: SessionPriceVerification;
|
|
120
|
+
readonly consistency: VersionComparison;
|
|
121
|
+
readonly publicationPolicyRevision: string;
|
|
122
|
+
}>;
|
|
123
|
+
/** Integration seam only: no fetching, station selection, caching or ChargyCore handoff here. */
|
|
124
|
+
verifyStation(anchorPolicyId: string, value: JSONValue, subject: {
|
|
125
|
+
readonly evseId: string;
|
|
126
|
+
} | {
|
|
127
|
+
readonly chargingStationId: string;
|
|
128
|
+
}, signal?: AbortSignal): Promise<{
|
|
129
|
+
readonly context: POITrustContext;
|
|
130
|
+
readonly station: VerifiedChargingStation;
|
|
131
|
+
readonly consistency?: VersionComparison;
|
|
132
|
+
}>;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=poiTrustContext.d.ts.map
|
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,SAAS,CAAA;KAAC,EAAK,EAAC,MAAM,CAAC,EAAC,WAAW,GAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAC,oBAAoB,CAAC;QAAA,QAAQ,CAAC,KAAK,EAAC,wBAAwB,CAAC;QAAA,QAAQ,CAAC,WAAW,EAAC,iBAAiB,CAAC;QAAA,QAAQ,CAAC,yBAAyB,EAAC,MAAM,CAAA;KAAC,CAAC;IAY/R,iGAAiG;IACpF,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EACvC,OAAO,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;KAAE,EAAC,MAAM,CAAC,EAAC,WAAW,GAAG,OAAO,CAAC;QACxG,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;QAAA,QAAQ,CAAC,WAAW,CAAC,EAAC,iBAAiB,CAAC;KACxH,CAAC;CAQjC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { POIObservedHistoryStore } from './poiObservedHistory.js';
|
|
2
|
+
import { applyVerifiedTrustTransition, verifyChargingDocumentKeys, ChargingStationProof, Checkpoint, PriceStatement, parseHistoricalMeterEvidence, parseSessionPriceEvidence, verifyAuthorizedCheckpoint, verifyPriceStatements, stationVersionObservation, checkpointVersionObservation, priceVersionObservation, checkpointRootVersionObservation, OperatorTrust, TrustAnchor, TrustContext, HistoricalTrustContext, canonicalJSONBytes, hash, toHex, verifyChargingStation, verifyMeterKey, verifyHistoricalMeterEvidence, verifySessionPriceEvidence } from '@open-charging-cloud/wwcp-poi';
|
|
3
|
+
import { derivePOITrustLineage } from './poiTrustLineage.js';
|
|
4
|
+
import { trustedAnchorHolders } from './anchorKeyTrust.js';
|
|
5
|
+
import { parseTrustAnchorData } from './trustAnchorData.js';
|
|
6
|
+
import { trustAnchorStorageId } from './trustStore.js';
|
|
7
|
+
import { POIWitnessTrustStore } from './poiWitnessTrust.js';
|
|
8
|
+
const digest = (value) => toHex(hash('sha256', canonicalJSONBytes(value)));
|
|
9
|
+
/** Reparse original evidence; callers cannot substitute a pre-parsed statement or cached verification result. */
|
|
10
|
+
export function createPOITrustContext(anchor, document, record, bundled, deleted, at = Date.now()) {
|
|
11
|
+
if (!Number.isFinite(at))
|
|
12
|
+
throw new Error('Invalid POI trust evaluation time');
|
|
13
|
+
if (record !== undefined && (record.transitions?.length ?? 0) > 0)
|
|
14
|
+
return derivePOITrustLineage(anchor, document, record, bundled, deleted, at, false);
|
|
15
|
+
if (record !== undefined && (record.id !== trustAnchorStorageId(anchor) ||
|
|
16
|
+
trustAnchorStorageId(TrustAnchor.parse(record.qrCode)) !== record.id))
|
|
17
|
+
throw new Error('The stored trust decision belongs to another anchor policy');
|
|
18
|
+
const data = parseTrustAnchorData(anchor, document, bundled);
|
|
19
|
+
const verification = TrustContext.create(anchor, data.statement, {
|
|
20
|
+
trustedIdentityKeyIds: trustedAnchorHolders(anchor, record, bundled, deleted, at).flat(),
|
|
21
|
+
otherIdentityKeys: data.identityKeys, at
|
|
22
|
+
});
|
|
23
|
+
const anchorPolicyId = trustAnchorStorageId(anchor);
|
|
24
|
+
const roamingNetworkId = data.statement.roamingNetworkId;
|
|
25
|
+
const roamingNetworkOperatorId = data.statement.roamingNetworkOperatorId;
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
verification,
|
|
28
|
+
anchorPolicyId,
|
|
29
|
+
networkIdentity: digest({ roamingNetworkId, roamingNetworkOperatorId, anchorPolicyId }),
|
|
30
|
+
roamingNetworkId, roamingNetworkOperatorId,
|
|
31
|
+
keyStatementDigest: verification.keyStatementDigest,
|
|
32
|
+
evaluatedAt: verification.evaluatedAt, validUntil: verification.validUntil, requiredConsensus: verification.requiredConsensus,
|
|
33
|
+
authorizedHolders: verification.trustedHolders,
|
|
34
|
+
evidence: Object.freeze({ anchorQRCode: anchor.toQRCode(), keyStatement: Object.freeze({ ...document }) })
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export class POIHistoryError extends Error {
|
|
38
|
+
report;
|
|
39
|
+
constructor(report) {
|
|
40
|
+
super('Local version history rejected: ' + report.issues.map(issue => issue.code + ': ' + issue.detail).join('; '));
|
|
41
|
+
this.report = report;
|
|
42
|
+
this.name = 'POIHistoryError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Storage-backed gateway. Every call reads current local decisions in one transaction; no authorization cache. */
|
|
46
|
+
export class POITrustService {
|
|
47
|
+
store;
|
|
48
|
+
bundled;
|
|
49
|
+
now;
|
|
50
|
+
history;
|
|
51
|
+
witnessPolicies;
|
|
52
|
+
async previewTrustTransition(policyId, text, acceptedAt = this.now()) {
|
|
53
|
+
if (new TextEncoder().encode(text).length > 2 * 1024 * 1024)
|
|
54
|
+
throw new Error('Trust-transition input exceeds 2 MiB');
|
|
55
|
+
const { record, deleted } = await this.store.trustSnapshot(policyId);
|
|
56
|
+
if (record?.downloadedData === undefined)
|
|
57
|
+
throw new Error('A saved authorized bootstrap is required');
|
|
58
|
+
const accepted = new Date(acceptedAt).toISOString(), candidate = { ...record, transitions: [...record.transitions ?? [], { text, acceptedAt: accepted }] };
|
|
59
|
+
const context = derivePOITrustLineage(TrustAnchor.parse(record.qrCode), record.downloadedData, candidate, this.bundled, deleted, this.now(), false);
|
|
60
|
+
const transition = context.verifiedTransitions?.at(-1);
|
|
61
|
+
if (transition === undefined)
|
|
62
|
+
throw new Error('No verified trust transition');
|
|
63
|
+
const scope = { id: context.networkIdentity, policyId, roamingNetworkId: context.roamingNetworkId, operatorId: context.roamingNetworkOperatorId };
|
|
64
|
+
let state = (await this.history.begin(scope)).state, consistency;
|
|
65
|
+
for (const item of context.verifiedTransitions ?? []) {
|
|
66
|
+
consistency = applyVerifiedTrustTransition(state, item, this.now());
|
|
67
|
+
state = consistency.state;
|
|
68
|
+
if (!consistency.accepted)
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
if (consistency === undefined)
|
|
72
|
+
throw new Error('Missing transition comparison');
|
|
73
|
+
return { record, deleted, context, transition, consistency, acceptedAt: accepted };
|
|
74
|
+
}
|
|
75
|
+
validateTransitionAppend(record, deleted, text, acceptedAt) {
|
|
76
|
+
if (record.downloadedData === undefined)
|
|
77
|
+
throw new Error('Missing bootstrap');
|
|
78
|
+
derivePOITrustLineage(TrustAnchor.parse(record.qrCode), record.downloadedData, { ...record, transitions: [...record.transitions ?? [], { text, acceptedAt }] }, this.bundled, deleted, this.now(), false);
|
|
79
|
+
}
|
|
80
|
+
async verifyLiveDocumentKeys(policyId, proof, request, signal) {
|
|
81
|
+
const ticket = await this.beginObservations(policyId, true, signal), keys = verifyChargingDocumentKeys(ticket.context.verification, proof, request);
|
|
82
|
+
const cutoff = ticket.context.verifiedTransitions?.at(-1)?.source.signedAt ?? Infinity;
|
|
83
|
+
const consistency = await this.recordObservations(ticket, [this.stationPoint(ticket, ChargingStationProof.parse(proof), request.at < cutoff)], 'historical', { signal });
|
|
84
|
+
if (!consistency.accepted)
|
|
85
|
+
throw new POIHistoryError(consistency);
|
|
86
|
+
return keys;
|
|
87
|
+
}
|
|
88
|
+
stationPoint(ticket, proof, historical, checkpoints = []) {
|
|
89
|
+
const known = ticket.observed.points.find(point => point.kind === 'station' && point.digest === proof.commitId);
|
|
90
|
+
const cp = checkpoints.find(item => item.commitId === proof.commitId), epoch = cp === undefined ? known?.epoch : cp.epoch === 1 ? '' : String(cp.epoch);
|
|
91
|
+
if (historical && (ticket.context.epoch ?? 1) > 1 && epoch === undefined)
|
|
92
|
+
throw new Error('An unknown historical commit needs authenticated checkpoint evidence naming its epoch');
|
|
93
|
+
return stationVersionObservation(proof, epoch ?? ((ticket.context.epoch ?? 1) === 1 ? '' : String(ticket.context.epoch)));
|
|
94
|
+
}
|
|
95
|
+
authenticatedCheckpoints(context, entries) {
|
|
96
|
+
return entries.flatMap(entry => { try {
|
|
97
|
+
return [verifyAuthorizedCheckpoint(context.verification, Checkpoint.parse(entry.checkpoint), entry.operator).checkpoint];
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return [];
|
|
101
|
+
} });
|
|
102
|
+
}
|
|
103
|
+
constructor(store, bundled, now = Date.now, history = new POIObservedHistoryStore(), witnessPolicies = new POIWitnessTrustStore()) {
|
|
104
|
+
this.store = store;
|
|
105
|
+
this.bundled = bundled;
|
|
106
|
+
this.now = now;
|
|
107
|
+
this.history = history;
|
|
108
|
+
this.witnessPolicies = witnessPolicies;
|
|
109
|
+
}
|
|
110
|
+
async assertPublicationPolicy(revision) {
|
|
111
|
+
if ((await this.witnessPolicies.snapshot()).revision !== revision)
|
|
112
|
+
throw new Error('Witness authorization changed during verification');
|
|
113
|
+
}
|
|
114
|
+
async resolve(anchorPolicyId) {
|
|
115
|
+
const { record, deleted } = await this.store.trustSnapshot(anchorPolicyId);
|
|
116
|
+
if (record?.id !== anchorPolicyId || record.downloadedData === undefined)
|
|
117
|
+
throw new Error('No saved KeyStatement exists for this anchor policy');
|
|
118
|
+
return createPOITrustContext(TrustAnchor.parse(record.qrCode), record.downloadedData, record, this.bundled, deleted, this.now());
|
|
119
|
+
}
|
|
120
|
+
async resolveHistorical(anchorPolicyId) {
|
|
121
|
+
const { record, deleted } = await this.store.trustSnapshot(anchorPolicyId);
|
|
122
|
+
if (record?.id !== anchorPolicyId || record.downloadedData === undefined)
|
|
123
|
+
throw new Error('No saved reference statement for this historical policy');
|
|
124
|
+
if ((record.transitions?.length ?? 0) > 0)
|
|
125
|
+
return derivePOITrustLineage(TrustAnchor.parse(record.qrCode), record.downloadedData, record, this.bundled, deleted, this.now(), true);
|
|
126
|
+
const anchor = TrustAnchor.parse(record.qrCode);
|
|
127
|
+
if (trustAnchorStorageId(anchor) !== anchorPolicyId)
|
|
128
|
+
throw new Error('Historical policy identity mismatch');
|
|
129
|
+
const data = parseTrustAnchorData(anchor, record.downloadedData, this.bundled);
|
|
130
|
+
const now = this.now();
|
|
131
|
+
const verification = HistoricalTrustContext.create(anchor, data.statement, {
|
|
132
|
+
trustedIdentityKeyIds: trustedAnchorHolders(anchor, record, this.bundled, deleted, now).flat(), otherIdentityKeys: data.identityKeys, now
|
|
133
|
+
});
|
|
134
|
+
return Object.freeze({ verification, anchorPolicyId,
|
|
135
|
+
networkIdentity: digest({ roamingNetworkId: verification.roamingNetworkId, roamingNetworkOperatorId: verification.roamingNetworkOperatorId, anchorPolicyId }),
|
|
136
|
+
roamingNetworkId: verification.roamingNetworkId, roamingNetworkOperatorId: verification.roamingNetworkOperatorId,
|
|
137
|
+
keyStatementDigest: verification.keyStatementDigest, evaluatedAt: verification.evaluatedAt, validUntil: verification.validUntil,
|
|
138
|
+
requiredConsensus: verification.requiredConsensus, authorizedHolders: verification.trustedHolders,
|
|
139
|
+
evidence: Object.freeze({ anchorQRCode: anchor.toQRCode(), keyStatement: Object.freeze({ ...record.downloadedData }) }) });
|
|
140
|
+
}
|
|
141
|
+
async beginObservations(anchorPolicyId, historical = true, signal) {
|
|
142
|
+
signal?.throwIfAborted();
|
|
143
|
+
const context = historical ? await this.resolveHistorical(anchorPolicyId) : await this.resolve(anchorPolicyId);
|
|
144
|
+
const scope = { id: context.networkIdentity, policyId: anchorPolicyId, roamingNetworkId: context.roamingNetworkId, operatorId: context.roamingNetworkOperatorId };
|
|
145
|
+
let stored = await this.history.begin(scope);
|
|
146
|
+
for (const transition of context.verifiedTransitions ?? []) {
|
|
147
|
+
const result = await this.history.transition(scope, stored.generation, transition, this.now());
|
|
148
|
+
if (!result.accepted)
|
|
149
|
+
throw new POIHistoryError(result);
|
|
150
|
+
}
|
|
151
|
+
stored = await this.history.begin(scope);
|
|
152
|
+
if ((stored.state.transitions?.length ?? 0) > (context.verifiedTransitions?.length ?? 0))
|
|
153
|
+
throw new Error('Accepted policy succession exists in the journal; restore its original certificates before checking current data');
|
|
154
|
+
signal?.throwIfAborted();
|
|
155
|
+
return { context, scope, generation: stored.generation, historical, observed: stored.state };
|
|
156
|
+
}
|
|
157
|
+
async recordObservations(ticket, points, mode, options = {}) {
|
|
158
|
+
const fresh = async () => {
|
|
159
|
+
const current = ticket.historical ? await this.resolveHistorical(ticket.context.anchorPolicyId) : await this.resolve(ticket.context.anchorPolicyId);
|
|
160
|
+
if (current.keyStatementDigest !== ticket.context.keyStatementDigest || current.effectivePolicyId !== ticket.context.effectivePolicyId || current.epoch !== ticket.context.epoch || current.requiredConsensus !== ticket.context.requiredConsensus || JSON.stringify(current.authorizedHolders) !== JSON.stringify(ticket.context.authorizedHolders) ||
|
|
161
|
+
current.evaluatedAt > Math.min(ticket.context.validUntil, options.validUntil ?? Infinity))
|
|
162
|
+
throw new Error('Authorization changed or expired while recording observed versions');
|
|
163
|
+
options.signal?.throwIfAborted();
|
|
164
|
+
};
|
|
165
|
+
await fresh();
|
|
166
|
+
const report = await this.history.observe(ticket.scope, ticket.generation, points, mode, this.now(), options.live, options.signal);
|
|
167
|
+
await fresh();
|
|
168
|
+
return report;
|
|
169
|
+
}
|
|
170
|
+
checkpoints(context, entries) {
|
|
171
|
+
return entries.flatMap(entry => { const checkpoint = verifyAuthorizedCheckpoint(context.verification, Checkpoint.parse(entry.checkpoint), entry.operator).checkpoint; return [checkpointVersionObservation(checkpoint), checkpointRootVersionObservation(checkpoint)]; });
|
|
172
|
+
}
|
|
173
|
+
async verifyCurrentCheckpoints(anchorPolicyId, entries) {
|
|
174
|
+
if (entries.length === 0)
|
|
175
|
+
throw new Error('No current checkpoint evidence supplied');
|
|
176
|
+
const ticket = await this.beginObservations(anchorPolicyId, false);
|
|
177
|
+
const points = this.checkpoints(ticket.context, entries), report = await this.recordObservations(ticket, points, 'current');
|
|
178
|
+
if (!report.accepted)
|
|
179
|
+
throw new POIHistoryError(report);
|
|
180
|
+
return report;
|
|
181
|
+
}
|
|
182
|
+
async verifyCurrentPrices(anchorPolicyId, proof, statements, evseId) {
|
|
183
|
+
if (statements.length === 0)
|
|
184
|
+
throw new Error('No signed current price statements supplied');
|
|
185
|
+
const ticket = await this.beginObservations(anchorPolicyId, false), station = verifyChargingStation(ticket.context.verification, proof, { evseId });
|
|
186
|
+
verifyPriceStatements(station, [...statements], { at: ticket.context.evaluatedAt });
|
|
187
|
+
const points = [this.stationPoint(ticket, ChargingStationProof.parse(proof), false), ...statements.map(item => priceVersionObservation(PriceStatement.parse(item)))];
|
|
188
|
+
const consistency = await this.recordObservations(ticket, points, 'current');
|
|
189
|
+
if (!consistency.accepted)
|
|
190
|
+
throw new POIHistoryError(consistency);
|
|
191
|
+
return { consistency };
|
|
192
|
+
}
|
|
193
|
+
async verifyOperator(anchorPolicyId, operator) {
|
|
194
|
+
const context = await this.resolve(anchorPolicyId);
|
|
195
|
+
return { context, trust: OperatorTrust.fromOperatorJSON(context.verification, operator) };
|
|
196
|
+
}
|
|
197
|
+
async verifyMeterKey(anchorPolicyId, proof, request, signal) {
|
|
198
|
+
const ticket = await this.beginObservations(anchorPolicyId, false, signal), context = ticket.context;
|
|
199
|
+
const binding = verifyMeterKey(context.verification, proof, request);
|
|
200
|
+
const consistency = await this.recordObservations(ticket, [this.stationPoint(ticket, ChargingStationProof.parse(proof), false)], 'current', { signal, validUntil: binding.evidence.validUntil });
|
|
201
|
+
if (!consistency.accepted)
|
|
202
|
+
throw new POIHistoryError(consistency);
|
|
203
|
+
return { context, binding };
|
|
204
|
+
}
|
|
205
|
+
async verifyHistoricalMeterEvidence(anchorPolicyId, evidence, request, signal) {
|
|
206
|
+
const ticket = await this.beginObservations(anchorPolicyId, true, signal), context = ticket.context;
|
|
207
|
+
const verified = verifyHistoricalMeterEvidence(context.verification, evidence, request), parsed = parseHistoricalMeterEvidence(evidence);
|
|
208
|
+
const used = new Set(verified.bindings.map(binding => binding.evidence.commitId));
|
|
209
|
+
const versions = parsed.versions.filter(version => used.has(ChargingStationProof.parse(version.proof).commitId));
|
|
210
|
+
const included = new Set(verified.versions.map(version => version.checkpointId));
|
|
211
|
+
const points = [...versions.map(version => this.stationPoint(ticket, ChargingStationProof.parse(version.proof), true, this.authenticatedCheckpoints(context, version.checkpoints))),
|
|
212
|
+
...this.checkpoints(context, versions.flatMap(version => version.checkpoints).filter(entry => included.has(Checkpoint.parse(entry.checkpoint).id)))];
|
|
213
|
+
const consistency = await this.recordObservations(ticket, points, 'historical', { signal });
|
|
214
|
+
return { context, evidence: verified, consistency };
|
|
215
|
+
}
|
|
216
|
+
async verifySessionPriceEvidence(anchorPolicyId, evidence, request, relatedCheckpoints = [], signal) {
|
|
217
|
+
const ticket = await this.beginObservations(anchorPolicyId, true, signal), context = ticket.context;
|
|
218
|
+
const witnesses = await this.witnessPolicies.snapshot();
|
|
219
|
+
signal?.throwIfAborted();
|
|
220
|
+
const price = verifySessionPriceEvidence(context.verification, evidence, request, { relatedCheckpoints, publicationPolicy: witnesses.policy }), parsed = parseSessionPriceEvidence(evidence);
|
|
221
|
+
const points = [this.stationPoint(ticket, ChargingStationProof.parse(parsed.proof), true, this.authenticatedCheckpoints(context, parsed.checkpoints))];
|
|
222
|
+
if (price.signatures === 'valid' && price.applicability !== 'invalid')
|
|
223
|
+
points.push(...parsed.priceStatements.map(item => priceVersionObservation(PriceStatement.parse(item))));
|
|
224
|
+
if (price.publication === 'valid' || price.publication === 'incomplete')
|
|
225
|
+
points.push(...this.checkpoints(context, parsed.checkpoints));
|
|
226
|
+
const consistency = await this.recordObservations(ticket, points, 'historical', { signal });
|
|
227
|
+
await this.assertPublicationPolicy(witnesses.revision);
|
|
228
|
+
signal?.throwIfAborted();
|
|
229
|
+
return { context, price, consistency, publicationPolicyRevision: witnesses.revision };
|
|
230
|
+
}
|
|
231
|
+
/** Integration seam only: no fetching, station selection, caching or ChargyCore handoff here. */
|
|
232
|
+
async verifyStation(anchorPolicyId, value, subject, signal) {
|
|
233
|
+
const ticket = await this.beginObservations(anchorPolicyId, false, signal), context = ticket.context;
|
|
234
|
+
if (('evseId' in subject ? subject.evseId : subject.chargingStationId).trim() === '')
|
|
235
|
+
throw new Error('A station proof requires an unambiguous subject');
|
|
236
|
+
const station = verifyChargingStation(context.verification, value, subject);
|
|
237
|
+
const consistency = await this.recordObservations(ticket, [this.stationPoint(ticket, ChargingStationProof.parse(value), false)], 'current', { signal, validUntil: station.verification.validUntil });
|
|
238
|
+
if (!consistency.accepted)
|
|
239
|
+
throw new POIHistoryError(consistency);
|
|
240
|
+
return { context, station, consistency };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=poiTrustContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poiTrustContext.js","sourceRoot":"","sources":["../src/poiTrustContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAC,4BAA4B,EAAC,0BAA0B,EAAC,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,gCAAgC,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC7jB,OAAO,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AA4B1D,MAAM,MAAM,GAAG,CAAC,KAAgB,EAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,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,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;YAChF,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC5E,MAAM,WAAW,GAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC,KAAK,CAAC,CAAC,EAAC,SAAS,EAAC,EAAC,MAAM,EAAC,UAAU,EAAC,OAAO,CAAC,YAAY,CAAC,UAAU,EAAC,CAAC,CAAC;QAC1L,IAAG,CAAC,WAAW,CAAC,QAAQ;YAAC,MAAM,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;QAAA,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,WAAW,EAAC,CAAC;IACzG,CAAC;CACJ","sourcesContent":["import {POIObservedHistoryStore} from './poiObservedHistory.js';\nimport type {ObservationScope,ObservedHistoryRepository} from './poiObservedHistory.js';\nimport {applyVerifiedTrustTransition,verifyChargingDocumentKeys,ChargingStationProof, Checkpoint, PriceStatement, parseHistoricalMeterEvidence, parseSessionPriceEvidence, verifyAuthorizedCheckpoint, verifyPriceStatements, stationVersionObservation, checkpointVersionObservation, priceVersionObservation, checkpointRootVersionObservation, OperatorTrust, TrustAnchor, TrustContext, HistoricalTrustContext, canonicalJSONBytes, hash, toHex, verifyChargingStation, verifyMeterKey, verifyHistoricalMeterEvidence, verifySessionPriceEvidence } from '@open-charging-cloud/wwcp-poi';\nimport {derivePOITrustLineage} from './poiTrustLineage.js';\nimport type {ObservedVersions,VersionObservation,VersionComparison,SessionPriceRequest,SessionPriceVerification, EpochProfiles,VerifiedTrustTransition} from '@open-charging-cloud/wwcp-poi';\nimport type { JSONValue, POIPublicKey, VerifiedChargingStation, VerifiedMeterKeyBinding, MeasurementKeyFormat, HistoricalMeterVerification } from '@open-charging-cloud/wwcp-poi';\nimport { trustedAnchorHolders } from './anchorKeyTrust.js';\nimport { parseTrustAnchorData } from './trustAnchorData.js';\nimport type { StoredTrustAnchorData } from './trustAnchorData.js';\nimport { trustAnchorStorageId } from './trustStore.js';\nimport type { StoredTrustAnchor, TrustStore } from './trustStore.js';\nimport {POIWitnessTrustStore} from './poiWitnessTrust.js';\nimport type {WitnessPolicyRepository} from './poiWitnessTrust.js';\n\n/** An immutable report at evaluatedAt, never a reusable authorization token or a stored green flag. */\nexport interface POITrustContext {\n readonly epoch?:number;readonly epochProfiles?:EpochProfiles;readonly verifiedTransitions?:readonly VerifiedTrustTransition[];readonly effectivePolicyId?:string;\n readonly verification: TrustContext;\n readonly anchorPolicyId: string;\n /** Conservatively scoped to this exact bootstrap policy until verified succession is supported. */\n readonly networkIdentity: string;\n readonly roamingNetworkId: string;\n readonly roamingNetworkOperatorId: string;\n readonly keyStatementDigest: string;\n readonly evaluatedAt: number;\n readonly validUntil: number;\n readonly requiredConsensus: number;\n /** Original holder positions are retained, including empty groups. */\n readonly authorizedHolders: readonly (readonly string[])[];\n readonly evidence: {\n readonly bootstrapAnchorQRCode?:string;\n readonly anchorQRCode: string;\n readonly keyStatement: StoredTrustAnchorData;\n };\n}\nexport interface POIHistoricalContext extends Omit<POITrustContext,'verification'> {\n readonly verification: HistoricalTrustContext;\n}\n\nconst digest = (value: JSONValue): string => toHex(hash('sha256', canonicalJSONBytes(value)));\n\n/** Reparse original evidence; callers cannot substitute a pre-parsed statement or cached verification result. */\nexport function createPOITrustContext(anchor: TrustAnchor, document: StoredTrustAnchorData,\n record: StoredTrustAnchor | undefined, bundled: readonly POIPublicKey[],\n deleted: ReadonlySet<string>, at: number = Date.now()): POITrustContext {\n if (!Number.isFinite(at))\n throw new Error('Invalid POI trust evaluation time');\n if(record!==undefined&&(record.transitions?.length??0)>0)return derivePOITrustLineage(anchor,document,record,bundled,deleted,at,false) as POITrustContext;\n if (record !== undefined && (record.id !== trustAnchorStorageId(anchor) ||\n trustAnchorStorageId(TrustAnchor.parse(record.qrCode)) !== record.id))\n throw new Error('The stored trust decision belongs to another anchor policy');\n const data = parseTrustAnchorData(anchor, document, bundled);\n const verification = TrustContext.create(anchor, data.statement, {\n trustedIdentityKeyIds: trustedAnchorHolders(anchor, record, bundled, deleted, at).flat(),\n otherIdentityKeys: data.identityKeys, at\n });\n const anchorPolicyId = trustAnchorStorageId(anchor);\n const roamingNetworkId = data.statement.roamingNetworkId;\n const roamingNetworkOperatorId = data.statement.roamingNetworkOperatorId;\n return Object.freeze({\n verification,\n anchorPolicyId,\n networkIdentity: digest({ roamingNetworkId, roamingNetworkOperatorId, anchorPolicyId }),\n roamingNetworkId, roamingNetworkOperatorId,\n keyStatementDigest: verification.keyStatementDigest,\n evaluatedAt: verification.evaluatedAt, validUntil: verification.validUntil, requiredConsensus: verification.requiredConsensus,\n authorizedHolders: verification.trustedHolders,\n evidence: Object.freeze({ anchorQRCode: anchor.toQRCode(), keyStatement: Object.freeze({ ...document }) })\n });\n}\n\nexport class POIHistoryError extends Error {\n public constructor(public readonly report:VersionComparison){super('Local version history rejected: '+report.issues.map(issue=>issue.code+': '+issue.detail).join('; '));this.name='POIHistoryError';}\n}\nexport interface POIObservationTicket {readonly context:POITrustContext|POIHistoricalContext;readonly scope:ObservationScope;readonly generation:string;readonly historical:boolean;readonly observed:ObservedVersions;}\n/** Storage-backed gateway. Every call reads current local decisions in one transaction; no authorization cache. */\nexport class POITrustService {\n public async previewTrustTransition(policyId:string,text:string,acceptedAt:number=this.now()):Promise<{\n readonly record:StoredTrustAnchor;readonly deleted:ReadonlySet<string>;readonly context:POITrustContext;readonly transition:VerifiedTrustTransition;readonly consistency:VersionComparison;readonly acceptedAt:string;\n }>{\n if(new TextEncoder().encode(text).length>2*1024*1024)throw new Error('Trust-transition input exceeds 2 MiB');\n const {record,deleted}=await this.store.trustSnapshot(policyId);if(record?.downloadedData===undefined)throw new Error('A saved authorized bootstrap is required');\n const accepted=new Date(acceptedAt).toISOString(),candidate={...record,transitions:[...record.transitions??[],{text,acceptedAt:accepted}]};\n const context=derivePOITrustLineage(TrustAnchor.parse(record.qrCode),record.downloadedData,candidate,this.bundled,deleted,this.now(),false) as POITrustContext;\n const transition=context.verifiedTransitions?.at(-1);if(transition===undefined)throw new Error('No verified trust transition');\n const scope={id:context.networkIdentity,policyId,roamingNetworkId:context.roamingNetworkId,operatorId:context.roamingNetworkOperatorId};\n let state=(await this.history.begin(scope)).state,consistency:VersionComparison|undefined;\n for(const item of context.verifiedTransitions??[]){consistency=applyVerifiedTrustTransition(state,item,this.now());state=consistency.state;if(!consistency.accepted)break;}\n if(consistency===undefined)throw new Error('Missing transition comparison');return {record,deleted,context,transition,consistency,acceptedAt:accepted};\n }\n public validateTransitionAppend(record:StoredTrustAnchor,deleted:ReadonlySet<string>,text:string,acceptedAt:string):void {\n if(record.downloadedData===undefined)throw new Error('Missing bootstrap');\n derivePOITrustLineage(TrustAnchor.parse(record.qrCode),record.downloadedData,{...record,transitions:[...record.transitions??[],{text,acceptedAt}]},this.bundled,deleted,this.now(),false);\n }\n public async verifyLiveDocumentKeys(policyId:string,proof:JSONValue,request:{readonly evseId:string;readonly operatorId:string;readonly at:number},signal?:AbortSignal):Promise<ReturnType<typeof verifyChargingDocumentKeys>>{\n const ticket=await this.beginObservations(policyId,true,signal),keys=verifyChargingDocumentKeys(ticket.context.verification,proof,request);\n const cutoff=ticket.context.verifiedTransitions?.at(-1)?.source.signedAt??Infinity;\n const consistency=await this.recordObservations(ticket,[this.stationPoint(ticket,ChargingStationProof.parse(proof),request.at<cutoff)],'historical',{signal});\n if(!consistency.accepted)throw new POIHistoryError(consistency);return keys;\n }\n private stationPoint(ticket:POIObservationTicket,proof:ChargingStationProof,historical:boolean,checkpoints:readonly Checkpoint[]=[]):VersionObservation {\n const known=ticket.observed.points.find(point=>point.kind==='station'&&point.digest===proof.commitId);\n const cp=checkpoints.find(item=>item.commitId===proof.commitId),epoch=cp===undefined?known?.epoch:cp.epoch===1?'':String(cp.epoch);\n if(historical&&(ticket.context.epoch??1)>1&&epoch===undefined)throw new Error('An unknown historical commit needs authenticated checkpoint evidence naming its epoch');\n return stationVersionObservation(proof,epoch??((ticket.context.epoch??1)===1?'':String(ticket.context.epoch)));\n }\n private authenticatedCheckpoints(context:POIHistoricalContext|POITrustContext,entries:readonly {readonly checkpoint:JSONValue;readonly operator:JSONValue}[]):Checkpoint[]{\n return entries.flatMap(entry=>{try{return [verifyAuthorizedCheckpoint(context.verification,Checkpoint.parse(entry.checkpoint),entry.operator).checkpoint];}catch{return [];}});\n }\n public constructor(private readonly store: Pick<TrustStore, 'trustSnapshot'>,\n private readonly bundled: readonly POIPublicKey[],\n private readonly now: () => number = Date.now,\n private readonly history:ObservedHistoryRepository=new POIObservedHistoryStore(),\n private readonly witnessPolicies:WitnessPolicyRepository=new POIWitnessTrustStore()) {}\n\n public async assertPublicationPolicy(revision:string):Promise<void>{\n if((await this.witnessPolicies.snapshot()).revision!==revision)throw new Error('Witness authorization changed during verification');\n }\n\n public async resolve(anchorPolicyId: string): Promise<POITrustContext> {\n const { record, deleted } = await this.store.trustSnapshot(anchorPolicyId);\n if (record?.id !== anchorPolicyId || record.downloadedData === undefined)\n throw new Error('No saved KeyStatement exists for this anchor policy');\n return createPOITrustContext(TrustAnchor.parse(record.qrCode), record.downloadedData,\n record, this.bundled, deleted, this.now());\n }\n\n public async resolveHistorical(anchorPolicyId: string): Promise<POIHistoricalContext> {\n const { record,deleted } = await this.store.trustSnapshot(anchorPolicyId);\n if (record?.id !== anchorPolicyId || record.downloadedData === undefined) throw new Error('No saved reference statement for this historical policy');\n if((record.transitions?.length??0)>0)return derivePOITrustLineage(TrustAnchor.parse(record.qrCode),record.downloadedData,record,this.bundled,deleted,this.now(),true) as POIHistoricalContext;\n const anchor = TrustAnchor.parse(record.qrCode);\n if (trustAnchorStorageId(anchor) !== anchorPolicyId) throw new Error('Historical policy identity mismatch');\n const data = parseTrustAnchorData(anchor,record.downloadedData,this.bundled);\n const now = this.now();\n const verification = HistoricalTrustContext.create(anchor,data.statement,{\n trustedIdentityKeyIds:trustedAnchorHolders(anchor,record,this.bundled,deleted,now).flat(),otherIdentityKeys:data.identityKeys,now\n });\n return Object.freeze({ verification,anchorPolicyId,\n networkIdentity:digest({roamingNetworkId:verification.roamingNetworkId,roamingNetworkOperatorId:verification.roamingNetworkOperatorId,anchorPolicyId}),\n roamingNetworkId:verification.roamingNetworkId,roamingNetworkOperatorId:verification.roamingNetworkOperatorId,\n keyStatementDigest:verification.keyStatementDigest,evaluatedAt:verification.evaluatedAt,validUntil:verification.validUntil,\n requiredConsensus:verification.requiredConsensus,authorizedHolders:verification.trustedHolders,\n evidence:Object.freeze({anchorQRCode:anchor.toQRCode(),keyStatement:Object.freeze({...record.downloadedData})}) });\n }\n\n public async beginObservations(anchorPolicyId:string,historical:boolean=true,signal?:AbortSignal):Promise<POIObservationTicket> {\n signal?.throwIfAborted();\n const context=historical?await this.resolveHistorical(anchorPolicyId):await this.resolve(anchorPolicyId);\n const scope:ObservationScope={id:context.networkIdentity,policyId:anchorPolicyId,roamingNetworkId:context.roamingNetworkId,operatorId:context.roamingNetworkOperatorId};\n let stored=await this.history.begin(scope);\n for(const transition of context.verifiedTransitions??[]){const result=await this.history.transition(scope,stored.generation,transition,this.now());if(!result.accepted)throw new POIHistoryError(result);}\n stored=await this.history.begin(scope);\n if((stored.state.transitions?.length??0)>(context.verifiedTransitions?.length??0))throw new Error('Accepted policy succession exists in the journal; restore its original certificates before checking current data');\n signal?.throwIfAborted();return {context,scope,generation:stored.generation,historical,observed:stored.state};\n }\n public async recordObservations(ticket:POIObservationTicket,points:readonly VersionObservation[],mode:'current'|'historical',\n options:{readonly signal?:AbortSignal|undefined;readonly live?:{readonly chain:string;readonly evidence:string};readonly validUntil?:number}={}):Promise<VersionComparison> {\n const fresh=async():Promise<void>=>{\n const current=ticket.historical?await this.resolveHistorical(ticket.context.anchorPolicyId):await this.resolve(ticket.context.anchorPolicyId);\n if(current.keyStatementDigest!==ticket.context.keyStatementDigest||current.effectivePolicyId!==ticket.context.effectivePolicyId||current.epoch!==ticket.context.epoch||current.requiredConsensus!==ticket.context.requiredConsensus||JSON.stringify(current.authorizedHolders)!==JSON.stringify(ticket.context.authorizedHolders)||\n current.evaluatedAt>Math.min(ticket.context.validUntil,options.validUntil??Infinity))throw new Error('Authorization changed or expired while recording observed versions');\n options.signal?.throwIfAborted();\n };\n await fresh();const report=await this.history.observe(ticket.scope,ticket.generation,points,mode,this.now(),options.live,options.signal);await fresh();return report;\n }\n private checkpoints(context:POIHistoricalContext|POITrustContext,entries:readonly {readonly checkpoint:JSONValue;readonly operator:JSONValue}[]):VersionObservation[] {\n return entries.flatMap(entry=>{const checkpoint=verifyAuthorizedCheckpoint(context.verification,Checkpoint.parse(entry.checkpoint),entry.operator).checkpoint;return [checkpointVersionObservation(checkpoint),checkpointRootVersionObservation(checkpoint)];});\n }\n public async verifyCurrentCheckpoints(anchorPolicyId:string,entries:readonly {readonly checkpoint:JSONValue;readonly operator:JSONValue}[]):Promise<VersionComparison> {\n if(entries.length===0)throw new Error('No current checkpoint evidence supplied');const ticket=await this.beginObservations(anchorPolicyId,false);\n const points=this.checkpoints(ticket.context,entries),report=await this.recordObservations(ticket,points,'current');if(!report.accepted)throw new POIHistoryError(report);return report;\n }\n public async verifyCurrentPrices(anchorPolicyId:string,proof:JSONValue,statements:readonly JSONValue[],evseId:string):Promise<{readonly consistency:VersionComparison}> {\n if(statements.length===0)throw new Error('No signed current price statements supplied');\n const ticket=await this.beginObservations(anchorPolicyId,false),station=verifyChargingStation((ticket.context as POITrustContext).verification,proof,{evseId});\n verifyPriceStatements(station,[...statements],{at:ticket.context.evaluatedAt});\n const points=[this.stationPoint(ticket,ChargingStationProof.parse(proof),false),...statements.map(item=>priceVersionObservation(PriceStatement.parse(item)))];\n const consistency=await this.recordObservations(ticket,points,'current');if(!consistency.accepted)throw new POIHistoryError(consistency);return {consistency};\n }\n\n public async verifyOperator(anchorPolicyId: string, operator: JSONValue): Promise<{ readonly context: POITrustContext; readonly trust: OperatorTrust }> {\n const context = await this.resolve(anchorPolicyId);\n return { context, trust: OperatorTrust.fromOperatorJSON(context.verification, operator) };\n }\n\n public async verifyMeterKey(anchorPolicyId: string, proof: JSONValue, request: {\n readonly evseId: string; readonly meterSerialNumber: string; readonly keyFormat: MeasurementKeyFormat;\n },signal?:AbortSignal): Promise<{ readonly context: POITrustContext; readonly binding: VerifiedMeterKeyBinding }> {\n const ticket=await this.beginObservations(anchorPolicyId,false,signal),context=ticket.context as POITrustContext;\n const binding=verifyMeterKey(context.verification,proof,request);\n const consistency=await this.recordObservations(ticket,[this.stationPoint(ticket,ChargingStationProof.parse(proof),false)],'current',{signal,validUntil:binding.evidence.validUntil});\n if(!consistency.accepted)throw new POIHistoryError(consistency);return {context,binding};\n }\n\n public async verifyHistoricalMeterEvidence(anchorPolicyId: string, evidence: JSONValue, request: {\n readonly evseId: string; readonly meterSerialNumber: string; readonly measurementTimes: readonly number[];\n readonly keyFormat: MeasurementKeyFormat;\n },signal?:AbortSignal): Promise<{ readonly context: POIHistoricalContext; readonly evidence: HistoricalMeterVerification;readonly consistency:VersionComparison }> {\n const ticket=await this.beginObservations(anchorPolicyId,true,signal),context=ticket.context as POIHistoricalContext;\n const verified=verifyHistoricalMeterEvidence(context.verification,evidence,request),parsed=parseHistoricalMeterEvidence(evidence);\n const used=new Set(verified.bindings.map(binding=>binding.evidence.commitId));\n const versions=parsed.versions.filter(version=>used.has(ChargingStationProof.parse(version.proof).commitId));\n const included=new Set(verified.versions.map(version=>version.checkpointId));\n const points=[...versions.map(version=>this.stationPoint(ticket,ChargingStationProof.parse(version.proof),true,this.authenticatedCheckpoints(context,version.checkpoints))),\n ...this.checkpoints(context,versions.flatMap(version=>version.checkpoints).filter(entry=>included.has(Checkpoint.parse(entry.checkpoint).id)))];\n const consistency=await this.recordObservations(ticket,points,'historical',{signal});return {context,evidence:verified,consistency};\n }\n\n public async verifySessionPriceEvidence(anchorPolicyId:string,evidence:JSONValue,request:SessionPriceRequest,\n relatedCheckpoints:readonly {readonly checkpoint:JSONValue;readonly operator:JSONValue}[]=[],signal?:AbortSignal):Promise<{readonly context:POIHistoricalContext;readonly price:SessionPriceVerification;readonly consistency:VersionComparison;readonly publicationPolicyRevision:string}>{\n const ticket=await this.beginObservations(anchorPolicyId,true,signal),context=ticket.context as POIHistoricalContext;\n const witnesses=await this.witnessPolicies.snapshot();signal?.throwIfAborted();\n const price=verifySessionPriceEvidence(context.verification,evidence,request,{relatedCheckpoints,publicationPolicy:witnesses.policy}),parsed=parseSessionPriceEvidence(evidence);\n const points=[this.stationPoint(ticket,ChargingStationProof.parse(parsed.proof),true,this.authenticatedCheckpoints(context,parsed.checkpoints))];\n if(price.signatures==='valid'&&price.applicability!=='invalid')points.push(...parsed.priceStatements.map(item=>priceVersionObservation(PriceStatement.parse(item))));\n if(price.publication==='valid'||price.publication==='incomplete')points.push(...this.checkpoints(context,parsed.checkpoints));\n const consistency=await this.recordObservations(ticket,points,'historical',{signal});\n await this.assertPublicationPolicy(witnesses.revision);signal?.throwIfAborted();\n return {context,price,consistency,publicationPolicyRevision:witnesses.revision};\n }\n\n /** Integration seam only: no fetching, station selection, caching or ChargyCore handoff here. */\n public async verifyStation(anchorPolicyId: string, value: JSONValue,\n subject: { readonly evseId: string } | { readonly chargingStationId: string },signal?:AbortSignal): Promise<{\n readonly context: POITrustContext; readonly station: VerifiedChargingStation;readonly consistency?:VersionComparison;\n }> {\n const ticket=await this.beginObservations(anchorPolicyId,false,signal),context=ticket.context as POITrustContext;\n if (('evseId' in subject ? subject.evseId : subject.chargingStationId).trim() === '')\n throw new Error('A station proof requires an unambiguous subject');\n const station = verifyChargingStation(context.verification, value, subject);\n const consistency=await this.recordObservations(ticket,[this.stationPoint(ticket,ChargingStationProof.parse(value),false)],'current',{signal,validUntil:station.verification.validUntil});\n if(!consistency.accepted)throw new POIHistoryError(consistency);return {context,station,consistency};\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TrustAnchor, POIPublicKey } from '@open-charging-cloud/wwcp-poi';
|
|
2
|
+
import type { JSONObject, JSONValue } from '@open-charging-cloud/wwcp-poi';
|
|
3
|
+
import type { StoredTrustAnchor } from './trustStore.js';
|
|
4
|
+
import type { StoredTrustAnchorData } from './trustAnchorData.js';
|
|
5
|
+
import type { POITrustContext, POIHistoricalContext } from './poiTrustContext.js';
|
|
6
|
+
/** Reconstruct the complete chain from today's local roots and original, explicitly accepted certificates. */
|
|
7
|
+
export declare function derivePOITrustLineage(anchor: TrustAnchor, document: StoredTrustAnchorData, record: StoredTrustAnchor, bundled: readonly POIPublicKey[], deleted: ReadonlySet<string>, at: number, historical: boolean): POITrustContext | POIHistoricalContext;
|
|
8
|
+
export declare function lineageOperator(context: POITrustContext | POIHistoricalContext): JSONObject;
|
|
9
|
+
export declare function transitionDigest(value: JSONValue): string;
|
|
10
|
+
//# sourceMappingURL=poiTrustLineage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poiTrustLineage.d.ts","sourceRoot":"","sources":["../src/poiTrustLineage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAA0F,YAAY,EAAsE,MAAM,+BAA+B,CAAC;AACrO,OAAO,KAAK,EAAC,UAAU,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAIhE,OAAO,KAAK,EAAC,eAAe,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE/E,8GAA8G;AAC9G,wBAAgB,qBAAqB,CAAC,MAAM,EAAC,WAAW,EAAC,QAAQ,EAAC,qBAAqB,EAAC,MAAM,EAAC,iBAAiB,EAAC,OAAO,EAAC,SAAS,YAAY,EAAE,EAAC,OAAO,EAAC,WAAW,CAAC,MAAM,CAAC,EAAC,EAAE,EAAC,MAAM,EAAC,UAAU,EAAC,OAAO,GAAE,eAAe,GAAC,oBAAoB,CAyB9O;AACD,wBAAgB,eAAe,CAAC,OAAO,EAAC,eAAe,GAAC,oBAAoB,GAAE,UAAU,CAGvF;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAC,SAAS,GAAE,MAAM,CAA+C"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TrustAnchor, TrustContext, HistoricalTrustContext, TrustTransition, VerifiedTrustTransition, KeyStatement, POIPublicKey, initialTrustEpoch, canonicalJSONBytes, hash, toHex, parseJSON, prettyJSON } from '@open-charging-cloud/wwcp-poi';
|
|
2
|
+
import { parseTrustAnchorData, keyStatementURL } from './trustAnchorData.js';
|
|
3
|
+
import { trustedAnchorHolders } from './anchorKeyTrust.js';
|
|
4
|
+
import { trustAnchorStorageId } from './trustStore.js';
|
|
5
|
+
/** Reconstruct the complete chain from today's local roots and original, explicitly accepted certificates. */
|
|
6
|
+
export function derivePOITrustLineage(anchor, document, record, bundled, deleted, at, historical) {
|
|
7
|
+
if (record.id !== trustAnchorStorageId(anchor) || trustAnchorStorageId(TrustAnchor.parse(record.qrCode)) !== record.id || !Number.isFinite(at) || record.transitions?.length === 0 || record.transitions === undefined)
|
|
8
|
+
throw new Error('Invalid trust-lineage reference');
|
|
9
|
+
const original = parseTrustAnchorData(anchor, document, bundled), first = TrustTransition.parse(parseJSON(record.transitions[0]?.text ?? 'null'));
|
|
10
|
+
const raw = parseJSON(document.text);
|
|
11
|
+
let activeAnchor = anchor, operator = (raw['operator'] ?? (raw['keyStatement'] === undefined ? { '@id': original.statement.roamingNetworkOperatorId, minConsensus: original.statement.minConsensus, keyStatement: original.statement.json, identityKeys: original.statement.identityKeys.map(key => key.json), signingKeyCertificates: [] } : raw)), statement = original.statement, epoch = initialTrustEpoch(), previous;
|
|
12
|
+
const root = TrustContext.create(anchor, statement, { trustedIdentityKeyIds: trustedAnchorHolders(anchor, record, bundled, deleted, first.signedAt).flat(), otherIdentityKeys: original.identityKeys, at: first.signedAt });
|
|
13
|
+
let authorized = root.authorizedAnchor.keys, from = statement.signedAt;
|
|
14
|
+
let epochs = [epoch];
|
|
15
|
+
const transitions = [], authorities = [];
|
|
16
|
+
for (const [index, saved] of record.transitions.entries()) {
|
|
17
|
+
const transition = TrustTransition.parse(parseJSON(saved.text));
|
|
18
|
+
if (transition.signedAt <= from || transition.signedAt > at)
|
|
19
|
+
throw new Error('Trust transitions must have increasing non-future effective times');
|
|
20
|
+
const old = TrustContext.withEpoch(TrustContext.create(activeAnchor, statement, { trustedIdentityKeyIds: authorized, otherIdentityKeys: POIPublicKey.parseAll(operator['identityKeys'], 'Operator identity keys'), at: transition.signedAt }), epoch, epochs);
|
|
21
|
+
const verified = VerifiedTrustTransition.verify(old, operator, transition, { acceptedAt: Date.parse(saved.acceptedAt), epoch, sequence: index, previous });
|
|
22
|
+
authorities.push({ context: old, from, until: transition.signedAt });
|
|
23
|
+
transitions.push(verified);
|
|
24
|
+
activeAnchor = transition.anchor;
|
|
25
|
+
operator = transition.operator;
|
|
26
|
+
statement = KeyStatement.parse(operator['keyStatement']);
|
|
27
|
+
epoch = verified.epoch;
|
|
28
|
+
authorized = verified.context.authorizedAnchor.keys;
|
|
29
|
+
epochs = [...verified.context.epochs];
|
|
30
|
+
previous = transition.digest();
|
|
31
|
+
from = transition.signedAt;
|
|
32
|
+
}
|
|
33
|
+
const current = TrustContext.withEpoch(TrustContext.create(activeAnchor, statement, { trustedIdentityKeyIds: authorized, otherIdentityKeys: POIPublicKey.parseAll(operator['identityKeys'], 'Operator identity keys'), at: historical ? from : at }), epoch, epochs);
|
|
34
|
+
authorities.push({ context: current, from, until: Infinity });
|
|
35
|
+
const verification = historical ? HistoricalTrustContext.fromVerifiedAuthorities(current, authorities, at) : current;
|
|
36
|
+
const policyId = trustAnchorStorageId(anchor), networkIdentity = toHex(hash('sha256', canonicalJSONBytes({ roamingNetworkId: current.roamingNetworkId, roamingNetworkOperatorId: current.roamingNetworkOperatorId, anchorPolicyId: policyId })));
|
|
37
|
+
return Object.freeze({ verification, anchorPolicyId: policyId, networkIdentity, roamingNetworkId: current.roamingNetworkId, roamingNetworkOperatorId: current.roamingNetworkOperatorId,
|
|
38
|
+
keyStatementDigest: verification.keyStatementDigest, evaluatedAt: at, validUntil: verification.validUntil, requiredConsensus: current.requiredConsensus, authorizedHolders: current.trustedHolders,
|
|
39
|
+
epoch: epoch.number, epochProfiles: epoch.profiles, verifiedTransitions: Object.freeze(transitions), effectivePolicyId: trustAnchorStorageId(activeAnchor),
|
|
40
|
+
evidence: Object.freeze({ anchorQRCode: activeAnchor.toQRCode(), bootstrapAnchorQRCode: anchor.toQRCode(), keyStatement: { origin: 'embedded', text: prettyJSON(operator), sourceURL: keyStatementURL(activeAnchor.urls[0] ?? ''), downloadedAt: record.transitions.at(-1)?.acceptedAt ?? document.downloadedAt } }) });
|
|
41
|
+
}
|
|
42
|
+
export function lineageOperator(context) {
|
|
43
|
+
const value = parseJSON(context.evidence.keyStatement.text);
|
|
44
|
+
return (value['operator'] ?? value);
|
|
45
|
+
}
|
|
46
|
+
export function transitionDigest(value) { return TrustTransition.parse(value).digest(); }
|
|
47
|
+
//# sourceMappingURL=poiTrustLineage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poiTrustLineage.js","sourceRoot":"","sources":["../src/poiTrustLineage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,YAAY,EAAC,sBAAsB,EAAC,eAAe,EAAC,uBAAuB,EAAC,YAAY,EAAC,YAAY,EAAC,iBAAiB,EAAC,kBAAkB,EAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,UAAU,EAAC,MAAM,+BAA+B,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,YAAY,CAAC,QAAQ,EAAE,EAAC,qBAAqB,EAAC,MAAM,CAAC,QAAQ,EAAE,EAAC,YAAY,EAAC,EAAC,MAAM,EAAC,UAAmB,EAAC,IAAI,EAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,SAAS,EAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,IAAE,EAAE,CAAC,EAAC,YAAY,EAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,IAAE,QAAQ,CAAC,YAAY,EAAC,EAAC,CAAC,EAAC,CAAyC,CAAC;AAC3V,CAAC;AACD,MAAM,UAAU,eAAe,CAAC,OAA4C;IACxE,MAAM,KAAK,GAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAe,CAAC;IACxE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAE,KAAK,CAAe,CAAC;AACpD,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,KAAe,IAAS,OAAO,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC","sourcesContent":["import {TrustAnchor,TrustContext,HistoricalTrustContext,TrustTransition,VerifiedTrustTransition,KeyStatement,POIPublicKey,initialTrustEpoch,canonicalJSONBytes,hash,toHex,parseJSON,prettyJSON} from '@open-charging-cloud/wwcp-poi';\nimport type {JSONObject,JSONValue} from '@open-charging-cloud/wwcp-poi';\nimport type {StoredTrustAnchor} from './trustStore.js';\nimport type {StoredTrustAnchorData} from './trustAnchorData.js';\nimport {parseTrustAnchorData,keyStatementURL} from './trustAnchorData.js';\nimport {trustedAnchorHolders} from './anchorKeyTrust.js';\nimport {trustAnchorStorageId} from './trustStore.js';\nimport type {POITrustContext,POIHistoricalContext} from './poiTrustContext.js';\n\n/** Reconstruct the complete chain from today's local roots and original, explicitly accepted certificates. */\nexport function derivePOITrustLineage(anchor:TrustAnchor,document:StoredTrustAnchorData,record:StoredTrustAnchor,bundled:readonly POIPublicKey[],deleted:ReadonlySet<string>,at:number,historical:boolean):POITrustContext|POIHistoricalContext {\n if(record.id!==trustAnchorStorageId(anchor)||trustAnchorStorageId(TrustAnchor.parse(record.qrCode))!==record.id||!Number.isFinite(at)||record.transitions?.length===0||record.transitions===undefined)throw new Error('Invalid trust-lineage reference');\n const original=parseTrustAnchorData(anchor,document,bundled),first=TrustTransition.parse(parseJSON(record.transitions[0]?.text??'null'));\n const raw=parseJSON(document.text) as JSONObject;\n let activeAnchor=anchor,operator=(raw['operator']??(raw['keyStatement']===undefined?{'@id':original.statement.roamingNetworkOperatorId,minConsensus:original.statement.minConsensus,keyStatement:original.statement.json,identityKeys:original.statement.identityKeys.map(key=>key.json),signingKeyCertificates:[]}:raw)) as JSONObject,\n statement=original.statement,epoch=initialTrustEpoch(),previous:string|undefined;\n const root=TrustContext.create(anchor,statement,{trustedIdentityKeyIds:trustedAnchorHolders(anchor,record,bundled,deleted,first.signedAt).flat(),otherIdentityKeys:original.identityKeys,at:first.signedAt});\n let authorized=root.authorizedAnchor.keys,from=statement.signedAt;let epochs=[epoch];\n const transitions:VerifiedTrustTransition[]=[],authorities:{context:TrustContext;from:number;until:number}[]=[];\n for(const [index,saved]of record.transitions.entries()){\n const transition=TrustTransition.parse(parseJSON(saved.text));if(transition.signedAt<=from||transition.signedAt>at)throw new Error('Trust transitions must have increasing non-future effective times');\n const old=TrustContext.withEpoch(TrustContext.create(activeAnchor,statement,{trustedIdentityKeyIds:authorized,otherIdentityKeys:POIPublicKey.parseAll(operator['identityKeys'],'Operator identity keys'),at:transition.signedAt}),epoch,epochs);\n const verified=VerifiedTrustTransition.verify(old,operator,transition,{acceptedAt:Date.parse(saved.acceptedAt),epoch,sequence:index,previous});\n authorities.push({context:old,from,until:transition.signedAt});transitions.push(verified);\n activeAnchor=transition.anchor;operator=transition.operator;statement=KeyStatement.parse(operator['keyStatement']);epoch=verified.epoch;\n authorized=verified.context.authorizedAnchor.keys;epochs=[...verified.context.epochs];previous=transition.digest();from=transition.signedAt;\n }\n const current=TrustContext.withEpoch(TrustContext.create(activeAnchor,statement,{trustedIdentityKeyIds:authorized,otherIdentityKeys:POIPublicKey.parseAll(operator['identityKeys'],'Operator identity keys'),at:historical?from:at}),epoch,epochs);\n authorities.push({context:current,from,until:Infinity});\n const verification=historical?HistoricalTrustContext.fromVerifiedAuthorities(current,authorities,at):current;\n const policyId=trustAnchorStorageId(anchor),networkIdentity=toHex(hash('sha256',canonicalJSONBytes({roamingNetworkId:current.roamingNetworkId,roamingNetworkOperatorId:current.roamingNetworkOperatorId,anchorPolicyId:policyId})));\n return Object.freeze({verification,anchorPolicyId:policyId,networkIdentity,roamingNetworkId:current.roamingNetworkId,roamingNetworkOperatorId:current.roamingNetworkOperatorId,\n keyStatementDigest:verification.keyStatementDigest,evaluatedAt:at,validUntil:verification.validUntil,requiredConsensus:current.requiredConsensus,authorizedHolders:current.trustedHolders,\n epoch:epoch.number,epochProfiles:epoch.profiles,verifiedTransitions:Object.freeze(transitions),effectivePolicyId:trustAnchorStorageId(activeAnchor),\n evidence:Object.freeze({anchorQRCode:activeAnchor.toQRCode(),bootstrapAnchorQRCode:anchor.toQRCode(),keyStatement:{origin:'embedded' as const,text:prettyJSON(operator),sourceURL:keyStatementURL(activeAnchor.urls[0]??''),downloadedAt:record.transitions.at(-1)?.acceptedAt??document.downloadedAt}})}) as POITrustContext|POIHistoricalContext;\n}\nexport function lineageOperator(context:POITrustContext|POIHistoricalContext):JSONObject {\n const value=parseJSON(context.evidence.keyStatement.text) as JSONObject;\n return (value['operator']??value) as JSONObject;\n}\nexport function transitionDigest(value:JSONValue):string{return TrustTransition.parse(value).digest();}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Application input/transport rules; POI identity matching remains the library's responsibility. */
|
|
2
|
+
export declare function stationEVSEId(value: string): string;
|
|
3
|
+
export declare function stationProofURL(base: string, evseId: string): string;
|
|
4
|
+
export declare function stationPriceStatementsURL(base: string, evseId: string): string;
|
|
5
|
+
//# sourceMappingURL=poiURLs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poiURLs.d.ts","sourceRoot":"","sources":["../src/poiURLs.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUnD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9E"}
|
package/dist/poiURLs.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Application input/transport rules; POI identity matching remains the library's responsibility. */
|
|
2
|
+
export function stationEVSEId(value) {
|
|
3
|
+
const id = value.trim();
|
|
4
|
+
let controls = false;
|
|
5
|
+
for (const character of id) {
|
|
6
|
+
const code = character.charCodeAt(0);
|
|
7
|
+
if (code < 32 || code === 127)
|
|
8
|
+
controls = true;
|
|
9
|
+
}
|
|
10
|
+
if (id.length === 0 || id.length > 256 || controls || /[\s/\\?#]/u.test(id) || id === "." || id === "..")
|
|
11
|
+
throw new Error("Enter one EVSE ID (at most 256 characters, without whitespace)");
|
|
12
|
+
return id;
|
|
13
|
+
}
|
|
14
|
+
export function stationProofURL(base, evseId) {
|
|
15
|
+
const url = new URL(base);
|
|
16
|
+
url.search = "";
|
|
17
|
+
url.hash = "";
|
|
18
|
+
url.pathname = url.pathname.replace(/\/+$/, "") + "/EVSEs/" + encodeURIComponent(stationEVSEId(evseId)) + "/proof";
|
|
19
|
+
return url.href;
|
|
20
|
+
}
|
|
21
|
+
export function stationPriceStatementsURL(base, evseId) {
|
|
22
|
+
return stationProofURL(base, evseId).replace(/\/proof$/, "/priceStatements");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=po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MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AACjF,CAAC","sourcesContent":["/** Application input/transport rules; POI identity matching remains the library's responsibility. */\nexport function stationEVSEId(value: string): string {\n const id = value.trim();\n let controls = false;\n for (const character of id) {\n const code = character.charCodeAt(0);\n if (code < 32 || code === 127) controls = true;\n }\n if (id.length === 0 || id.length > 256 || controls || /[\\s/\\\\?#]/u.test(id) || id === \".\" || id === \"..\")\n throw new Error(\"Enter one EVSE ID (at most 256 characters, without whitespace)\");\n return id;\n}\n\nexport function stationProofURL(base: string, evseId: string): string {\n const url = new URL(base);\n url.search = \"\";\n url.hash = \"\";\n url.pathname = url.pathname.replace(/\\/+$/, \"\") + \"/EVSEs/\" + encodeURIComponent(stationEVSEId(evseId)) + \"/proof\";\n return url.href;\n}\n\nexport function stationPriceStatementsURL(base: string, evseId: string): string {\n return stationProofURL(base, evseId).replace(/\\/proof$/, \"/priceStatements\");\n}\n"]}
|