@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.
Files changed (170) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +661 -0
  3. package/README.md +48 -2
  4. package/SECURITY.md +21 -0
  5. package/dist/anchorKeyTrust.d.ts +9 -0
  6. package/dist/anchorKeyTrust.d.ts.map +1 -0
  7. package/dist/anchorKeyTrust.js +24 -0
  8. package/dist/anchorKeyTrust.js.map +1 -0
  9. package/dist/anchorKeyTrustView.d.ts +14 -0
  10. package/dist/anchorKeyTrustView.d.ts.map +1 -0
  11. package/dist/anchorKeyTrustView.js +95 -0
  12. package/dist/anchorKeyTrustView.js.map +1 -0
  13. package/dist/browserFiles.d.ts +5 -0
  14. package/dist/browserFiles.d.ts.map +1 -0
  15. package/dist/browserFiles.js +100 -0
  16. package/dist/browserFiles.js.map +1 -0
  17. package/dist/core/i18n.json +1518 -0
  18. package/dist/core/package.json +119 -0
  19. package/dist/core/validationRules.json +8 -0
  20. package/dist/domHelpers.d.ts +25 -0
  21. package/dist/domHelpers.d.ts.map +1 -0
  22. package/dist/domHelpers.js +212 -0
  23. package/dist/domHelpers.js.map +1 -0
  24. package/dist/historicalSessionPanel.d.ts +24 -0
  25. package/dist/historicalSessionPanel.d.ts.map +1 -0
  26. package/dist/historicalSessionPanel.js +108 -0
  27. package/dist/historicalSessionPanel.js.map +1 -0
  28. package/dist/index.d.ts +40 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +56 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/liveLinkTrust.d.ts +208 -0
  33. package/dist/liveLinkTrust.d.ts.map +1 -0
  34. package/dist/liveLinkTrust.js +452 -0
  35. package/dist/liveLinkTrust.js.map +1 -0
  36. package/dist/livePOISession.d.ts +38 -0
  37. package/dist/livePOISession.d.ts.map +1 -0
  38. package/dist/livePOISession.js +193 -0
  39. package/dist/livePOISession.js.map +1 -0
  40. package/dist/measurementDetailsRenderer.d.ts +25 -0
  41. package/dist/measurementDetailsRenderer.d.ts.map +1 -0
  42. package/dist/measurementDetailsRenderer.js +343 -0
  43. package/dist/measurementDetailsRenderer.js.map +1 -0
  44. package/dist/poiConsistencyView.d.ts +3 -0
  45. package/dist/poiConsistencyView.d.ts.map +1 -0
  46. package/dist/poiConsistencyView.js +14 -0
  47. package/dist/poiConsistencyView.js.map +1 -0
  48. package/dist/poiObservedHistory.d.ts +49 -0
  49. package/dist/poiObservedHistory.d.ts.map +1 -0
  50. package/dist/poiObservedHistory.js +205 -0
  51. package/dist/poiObservedHistory.js.map +1 -0
  52. package/dist/poiTransport.d.ts +12 -0
  53. package/dist/poiTransport.d.ts.map +1 -0
  54. package/dist/poiTransport.js +74 -0
  55. package/dist/poiTransport.js.map +1 -0
  56. package/dist/poiTrustContext.d.ts +134 -0
  57. package/dist/poiTrustContext.d.ts.map +1 -0
  58. package/dist/poiTrustContext.js +243 -0
  59. package/dist/poiTrustContext.js.map +1 -0
  60. package/dist/poiTrustLineage.d.ts +10 -0
  61. package/dist/poiTrustLineage.d.ts.map +1 -0
  62. package/dist/poiTrustLineage.js +47 -0
  63. package/dist/poiTrustLineage.js.map +1 -0
  64. package/dist/poiURLs.d.ts +5 -0
  65. package/dist/poiURLs.d.ts.map +1 -0
  66. package/dist/poiURLs.js +24 -0
  67. package/dist/poiURLs.js.map +1 -0
  68. package/dist/poiWitnessManagement.d.ts +3 -0
  69. package/dist/poiWitnessManagement.d.ts.map +1 -0
  70. package/dist/poiWitnessManagement.js +127 -0
  71. package/dist/poiWitnessManagement.js.map +1 -0
  72. package/dist/poiWitnessTrust.d.ts +26 -0
  73. package/dist/poiWitnessTrust.d.ts.map +1 -0
  74. package/dist/poiWitnessTrust.js +90 -0
  75. package/dist/poiWitnessTrust.js.map +1 -0
  76. package/dist/pricePublicationData.d.ts +19 -0
  77. package/dist/pricePublicationData.d.ts.map +1 -0
  78. package/dist/pricePublicationData.js +83 -0
  79. package/dist/pricePublicationData.js.map +1 -0
  80. package/dist/roamingNetworks.d.ts +14 -0
  81. package/dist/roamingNetworks.d.ts.map +1 -0
  82. package/dist/roamingNetworks.js +33 -0
  83. package/dist/roamingNetworks.js.map +1 -0
  84. package/dist/securityFingerprint.d.ts +16 -0
  85. package/dist/securityFingerprint.d.ts.map +1 -0
  86. package/dist/securityFingerprint.js +36 -0
  87. package/dist/securityFingerprint.js.map +1 -0
  88. package/dist/securityFingerprintView.d.ts +3 -0
  89. package/dist/securityFingerprintView.d.ts.map +1 -0
  90. package/dist/securityFingerprintView.js +61 -0
  91. package/dist/securityFingerprintView.js.map +1 -0
  92. package/dist/sessionEvidenceStore.d.ts +23 -0
  93. package/dist/sessionEvidenceStore.d.ts.map +1 -0
  94. package/dist/sessionEvidenceStore.js +81 -0
  95. package/dist/sessionEvidenceStore.js.map +1 -0
  96. package/dist/sessionMeterKeyView.d.ts +9 -0
  97. package/dist/sessionMeterKeyView.d.ts.map +1 -0
  98. package/dist/sessionMeterKeyView.js +55 -0
  99. package/dist/sessionMeterKeyView.js.map +1 -0
  100. package/dist/sessionPOIData.d.ts +49 -0
  101. package/dist/sessionPOIData.d.ts.map +1 -0
  102. package/dist/sessionPOIData.js +161 -0
  103. package/dist/sessionPOIData.js.map +1 -0
  104. package/dist/sessionPOIPanel.d.ts +50 -0
  105. package/dist/sessionPOIPanel.d.ts.map +1 -0
  106. package/dist/sessionPOIPanel.js +288 -0
  107. package/dist/sessionPOIPanel.js.map +1 -0
  108. package/dist/sessionPriceData.d.ts +17 -0
  109. package/dist/sessionPriceData.d.ts.map +1 -0
  110. package/dist/sessionPriceData.js +51 -0
  111. package/dist/sessionPriceData.js.map +1 -0
  112. package/dist/sessionPricePanel.d.ts +31 -0
  113. package/dist/sessionPricePanel.d.ts.map +1 -0
  114. package/dist/sessionPricePanel.js +222 -0
  115. package/dist/sessionPricePanel.js.map +1 -0
  116. package/dist/sessionUIState.d.ts +12 -0
  117. package/dist/sessionUIState.d.ts.map +1 -0
  118. package/dist/sessionUIState.js +33 -0
  119. package/dist/sessionUIState.js.map +1 -0
  120. package/dist/stationProofData.d.ts +38 -0
  121. package/dist/stationProofData.d.ts.map +1 -0
  122. package/dist/stationProofData.js +83 -0
  123. package/dist/stationProofData.js.map +1 -0
  124. package/dist/stationProofPanel.d.ts +44 -0
  125. package/dist/stationProofPanel.d.ts.map +1 -0
  126. package/dist/stationProofPanel.js +304 -0
  127. package/dist/stationProofPanel.js.map +1 -0
  128. package/dist/stationProofView.d.ts +9 -0
  129. package/dist/stationProofView.d.ts.map +1 -0
  130. package/dist/stationProofView.js +186 -0
  131. package/dist/stationProofView.js.map +1 -0
  132. package/dist/trustAnchorData.d.ts +40 -0
  133. package/dist/trustAnchorData.d.ts.map +1 -0
  134. package/dist/trustAnchorData.js +91 -0
  135. package/dist/trustAnchorData.js.map +1 -0
  136. package/dist/trustAnchorDataView.d.ts +13 -0
  137. package/dist/trustAnchorDataView.d.ts.map +1 -0
  138. package/dist/trustAnchorDataView.js +69 -0
  139. package/dist/trustAnchorDataView.js.map +1 -0
  140. package/dist/trustAnchorImport.d.ts +5 -0
  141. package/dist/trustAnchorImport.d.ts.map +1 -0
  142. package/dist/trustAnchorImport.js +34 -0
  143. package/dist/trustAnchorImport.js.map +1 -0
  144. package/dist/trustAnchorPreview.d.ts +37 -0
  145. package/dist/trustAnchorPreview.d.ts.map +1 -0
  146. package/dist/trustAnchorPreview.js +180 -0
  147. package/dist/trustAnchorPreview.js.map +1 -0
  148. package/dist/trustManagement.d.ts +34 -0
  149. package/dist/trustManagement.d.ts.map +1 -0
  150. package/dist/trustManagement.js +405 -0
  151. package/dist/trustManagement.js.map +1 -0
  152. package/dist/trustStore.d.ts +75 -0
  153. package/dist/trustStore.d.ts.map +1 -0
  154. package/dist/trustStore.js +408 -0
  155. package/dist/trustStore.js.map +1 -0
  156. package/dist/trustTransitionView.d.ts +5 -0
  157. package/dist/trustTransitionView.d.ts.map +1 -0
  158. package/dist/trustTransitionView.js +110 -0
  159. package/dist/trustTransitionView.js.map +1 -0
  160. package/dist/trustedPublicKeys.d.ts +4 -0
  161. package/dist/trustedPublicKeys.d.ts.map +1 -0
  162. package/dist/trustedPublicKeys.js +25 -0
  163. package/dist/trustedPublicKeys.js.map +1 -0
  164. package/dist/wwcpPoi.d.ts +2 -0
  165. package/dist/wwcpPoi.d.ts.map +1 -0
  166. package/dist/wwcpPoi.js +2 -0
  167. package/dist/wwcpPoi.js.map +1 -0
  168. package/documentation/AUDIT.md +262 -0
  169. package/images/NGI0_tag.svg +149 -0
  170. package/package.json +75 -4
@@ -0,0 +1,3 @@
1
+ /** Recommendations grant no authority. Only the explicit acceptance button changes local trust. */
2
+ export declare function renderPOIWitnessManagement(root: HTMLElement, localize: (key: string) => string, isCurrent: () => boolean, refresh: () => void): Promise<void>;
3
+ //# sourceMappingURL=poiWitnessManagement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poiWitnessManagement.d.ts","sourceRoot":"","sources":["../src/poiWitnessManagement.ts"],"names":[],"mappings":"AAKA,mGAAmG;AACnG,wBAAsB,0BAA0B,CAAC,IAAI,EAAC,WAAW,EAAC,QAAQ,EAAC,CAAC,GAAG,EAAC,MAAM,KAAG,MAAM,EAAC,SAAS,EAAC,MAAI,OAAO,EAAC,OAAO,EAAC,MAAI,IAAI,GAAE,OAAO,CAAC,IAAI,CAAC,CAgDpJ"}
@@ -0,0 +1,127 @@
1
+ import { prettyJSON } from '@open-charging-cloud/wwcp-poi';
2
+ import { POIWitnessTrustStore, witnessPolicySnapshot } from './poiWitnessTrust.js';
3
+ import { renderSecurityFingerprint } from './securityFingerprintView.js';
4
+ /** Recommendations grant no authority. Only the explicit acceptance button changes local trust. */
5
+ export async function renderPOIWitnessManagement(root, localize, isCurrent, refresh) {
6
+ const store = new POIWitnessTrustStore(), snapshot = await store.snapshot();
7
+ if (!isCurrent())
8
+ return;
9
+ root.classList.add('poiWitnessManagement');
10
+ const text = (parent, value) => { const p = parent.appendChild(document.createElement('p')); p.textContent = value; return p; };
11
+ const witnessCard = (parent, witness, expanded) => {
12
+ const card = parent.appendChild(document.createElement('article'));
13
+ card.className = 'trustManagementCard';
14
+ card.dataset['witnessId'] = witness.id;
15
+ card.appendChild(document.createElement('h4')).textContent = witness.organization + ' · ' + witness.id;
16
+ text(card, localize('poiWitnessNetworks') + ': ' + witness.networks.join(', '));
17
+ text(card, localize('poiWitnessClock') + ': ±' + String(witness.clockErrorMs) + ' ms');
18
+ text(card, new Date(witness.notBefore).toISOString() + ' → ' + new Date(witness.notAfter).toISOString());
19
+ const details = card.appendChild(document.createElement('details'));
20
+ details.open = expanded;
21
+ details.appendChild(document.createElement('summary')).textContent = localize('poiWitnessKeys');
22
+ const keys = details.appendChild(document.createElement('div'));
23
+ keys.className = 'poiCPOKeyList';
24
+ for (const key of witness.keys)
25
+ keys.appendChild(renderSecurityFingerprint(key.id, localize));
26
+ for (const endpoint of witness.endpoints)
27
+ text(details, endpoint);
28
+ return card;
29
+ };
30
+ text(root, localize('poiWitnessQuorum') + ': ' + String(snapshot.policy.requiredOrganizations));
31
+ if (snapshot.policy.witnesses.length === 0)
32
+ text(root, localize('poiWitnessEmpty'));
33
+ for (const witness of snapshot.policy.witnesses) {
34
+ const card = witnessCard(root, witness, false), remove = card.appendChild(document.createElement('button'));
35
+ remove.type = 'button';
36
+ remove.className = 'trustManagementDelete';
37
+ remove.textContent = localize('poiWitnessRemove');
38
+ remove.dataset['action'] = 'remove-witness';
39
+ remove.onclick = () => {
40
+ remove.disabled = true;
41
+ void store.remove(snapshot, witness.id).then(() => { if (isCurrent())
42
+ refresh(); }).catch((error) => {
43
+ if (isCurrent()) {
44
+ remove.disabled = false;
45
+ text(card, localize('poiWitnessFailed') + ': ' + (error instanceof Error ? error.message : String(error)));
46
+ }
47
+ });
48
+ };
49
+ }
50
+ const form = root.appendChild(document.createElement('section'));
51
+ form.className = 'poiWitnessPolicyEditor';
52
+ form.appendChild(document.createElement('h4')).textContent = localize('poiWitnessReviewTitle');
53
+ text(form, localize('poiWitnessReviewScope'));
54
+ const label = form.appendChild(document.createElement('label'));
55
+ label.textContent = localize('poiWitnessInput');
56
+ const input = label.appendChild(document.createElement('textarea'));
57
+ input.rows = 8;
58
+ input.maxLength = 1024 * 1024;
59
+ input.spellcheck = false;
60
+ input.dataset['action'] = 'witness-policy-text';
61
+ const file = form.appendChild(document.createElement('input'));
62
+ file.type = 'file';
63
+ file.accept = '.json,application/json';
64
+ file.dataset['action'] = 'witness-policy-file';
65
+ const review = form.appendChild(document.createElement('button'));
66
+ review.type = 'button';
67
+ review.textContent = localize('poiWitnessReview');
68
+ review.dataset['action'] = 'review-witness-policy';
69
+ const result = form.appendChild(document.createElement('div'));
70
+ result.className = 'poiWitnessPolicyPreview';
71
+ let generation = 0;
72
+ const reset = () => { generation++; result.replaceChildren(); delete result.dataset['state']; };
73
+ input.oninput = reset;
74
+ file.onchange = () => {
75
+ reset();
76
+ const selected = file.files?.[0], token = generation;
77
+ if (selected === undefined)
78
+ return;
79
+ if (selected.size > 1024 * 1024) {
80
+ text(result, localize('poiWitnessTooLarge'));
81
+ return;
82
+ }
83
+ void selected.text().then(value => { if (isCurrent() && token === generation) {
84
+ input.value = value;
85
+ reset();
86
+ } }).catch(() => { if (isCurrent() && token === generation)
87
+ text(result, localize('poiWitnessFailed')); });
88
+ };
89
+ review.onclick = () => {
90
+ reset();
91
+ const original = input.value, token = generation;
92
+ try {
93
+ const candidate = witnessPolicySnapshot(original);
94
+ result.dataset['state'] = 'review';
95
+ text(result, localize('poiWitnessQuorum') + ': ' + String(candidate.policy.requiredOrganizations));
96
+ text(result, localize('poiWitnessReplaced') + ': ' + String(snapshot.policy.witnesses.filter(before => !candidate.policy.witnesses.some(after => after.id === before.id)).length));
97
+ for (const witness of candidate.policy.witnesses)
98
+ witnessCard(result, witness, true);
99
+ text(result, localize('poiWitnessIndependence'));
100
+ const accept = result.appendChild(document.createElement('button'));
101
+ accept.type = 'button';
102
+ accept.dataset['action'] = 'accept-witness-policy';
103
+ accept.textContent = localize('poiWitnessAccept');
104
+ accept.onclick = () => {
105
+ if (!isCurrent() || token !== generation || original !== input.value)
106
+ return;
107
+ accept.disabled = true;
108
+ void store.replace(snapshot.revision, original).then(() => { if (isCurrent())
109
+ refresh(); }).catch((error) => {
110
+ if (isCurrent()) {
111
+ accept.disabled = false;
112
+ result.dataset['state'] = 'invalid';
113
+ text(result, localize('poiWitnessFailed') + ': ' + (error instanceof Error ? error.message : String(error)));
114
+ }
115
+ });
116
+ };
117
+ }
118
+ catch (error) {
119
+ result.dataset['state'] = 'invalid';
120
+ text(result, localize('poiWitnessFailed') + ': ' + (error instanceof Error ? error.message : String(error)));
121
+ }
122
+ };
123
+ const current = form.appendChild(document.createElement('details'));
124
+ current.appendChild(document.createElement('summary')).textContent = localize('poiWitnessCurrentPolicy');
125
+ current.appendChild(document.createElement('pre')).textContent = prettyJSON(snapshot.policy.json);
126
+ }
127
+ //# sourceMappingURL=poiWitnessManagement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poiWitnessManagement.js","sourceRoot":"","sources":["../src/poiWitnessManagement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EAAC,oBAAoB,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAC,yBAAyB,EAAC,MAAM,8BAA8B,CAAC;AAEvE,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,IAAgB,EAAC,QAA6B,EAAC,SAAqB,EAAC,OAAgB;IAClI,MAAM,KAAK,GAAC,IAAI,oBAAoB,EAAE,EAAC,QAAQ,GAAC,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;IAAA,IAAG,CAAC,SAAS,EAAE;QAAC,OAAO;IAC9F,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;I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AK,CAAC;wBAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAC,SAAS,CAAC;wBAAA,IAAI,CAAC,MAAM,EAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAC,IAAI,GAAC,CAAC,KAAK,YAAY,KAAK,CAAA,CAAC,CAAA,KAAK,CAAC,OAAO,CAAA,CAAC,CAAA,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAChK,CAAC;gBAAA,CAAC,CAAC,CAAC;YACR,CAAC,CAAC;QACN,CAAC;QAAA,OAAM,KAAK,EAAC,CAAC;YAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAC,SAAS,CAAC;YAAA,IAAI,CAAC,MAAM,EAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAC,IAAI,GAAC,CAAC,KAAK,YAAY,KAAK,CAAA,CAAC,CAAA,KAAK,CAAC,OAAO,CAAA,CAAC,CAAA,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAAA,CAAC;IACzJ,CAAC,CAAC;IACF,MAAM,OAAO,GAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAAA,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,GAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IAAA,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,GAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC7Q,CAAC","sourcesContent":["import {prettyJSON} from '@open-charging-cloud/wwcp-poi';\nimport type {PublicationWitness} from '@open-charging-cloud/wwcp-poi';\nimport {POIWitnessTrustStore,witnessPolicySnapshot} from './poiWitnessTrust.js';\nimport {renderSecurityFingerprint} from './securityFingerprintView.js';\n\n/** Recommendations grant no authority. Only the explicit acceptance button changes local trust. */\nexport async function renderPOIWitnessManagement(root:HTMLElement,localize:(key:string)=>string,isCurrent:()=>boolean,refresh:()=>void):Promise<void> {\n const store=new POIWitnessTrustStore(),snapshot=await store.snapshot();if(!isCurrent())return;\n root.classList.add('poiWitnessManagement');\n const text=(parent:HTMLElement,value:string):HTMLElement=>{const p=parent.appendChild(document.createElement('p'));p.textContent=value;return p;};\n const witnessCard=(parent:HTMLElement,witness:PublicationWitness,expanded:boolean):HTMLElement=>{\n const card=parent.appendChild(document.createElement('article'));card.className='trustManagementCard';card.dataset['witnessId']=witness.id;\n card.appendChild(document.createElement('h4')).textContent=witness.organization+' · '+witness.id;\n text(card,localize('poiWitnessNetworks')+': '+witness.networks.join(', '));text(card,localize('poiWitnessClock')+': ±'+String(witness.clockErrorMs)+' ms');\n text(card,new Date(witness.notBefore).toISOString()+' → '+new Date(witness.notAfter).toISOString());\n const details=card.appendChild(document.createElement('details'));details.open=expanded;details.appendChild(document.createElement('summary')).textContent=localize('poiWitnessKeys');\n const keys=details.appendChild(document.createElement('div'));keys.className='poiCPOKeyList';for(const key of witness.keys)keys.appendChild(renderSecurityFingerprint(key.id,localize));\n for(const endpoint of witness.endpoints)text(details,endpoint);return card;\n };\n text(root,localize('poiWitnessQuorum')+': '+String(snapshot.policy.requiredOrganizations));\n if(snapshot.policy.witnesses.length===0)text(root,localize('poiWitnessEmpty'));\n for(const witness of snapshot.policy.witnesses){\n const card=witnessCard(root,witness,false),remove=card.appendChild(document.createElement('button'));remove.type='button';remove.className='trustManagementDelete';remove.textContent=localize('poiWitnessRemove');remove.dataset['action']='remove-witness';\n remove.onclick=():void=>{remove.disabled=true;void store.remove(snapshot,witness.id).then(()=>{if(isCurrent())refresh();}).catch((error:unknown)=>{\n if(isCurrent()){remove.disabled=false;text(card,localize('poiWitnessFailed')+': '+(error instanceof Error?error.message:String(error)));}\n });};\n }\n const form=root.appendChild(document.createElement('section'));form.className='poiWitnessPolicyEditor';\n form.appendChild(document.createElement('h4')).textContent=localize('poiWitnessReviewTitle');text(form,localize('poiWitnessReviewScope'));\n const label=form.appendChild(document.createElement('label'));label.textContent=localize('poiWitnessInput');\n const input=label.appendChild(document.createElement('textarea'));input.rows=8;input.maxLength=1024*1024;input.spellcheck=false;input.dataset['action']='witness-policy-text';\n const file=form.appendChild(document.createElement('input'));file.type='file';file.accept='.json,application/json';file.dataset['action']='witness-policy-file';\n const review=form.appendChild(document.createElement('button'));review.type='button';review.textContent=localize('poiWitnessReview');review.dataset['action']='review-witness-policy';\n const result=form.appendChild(document.createElement('div'));result.className='poiWitnessPolicyPreview';let generation=0;\n const reset=():void=>{generation++;result.replaceChildren();delete result.dataset['state'];};input.oninput=reset;\n file.onchange=():void=>{reset();const selected=file.files?.[0],token=generation;if(selected===undefined)return;\n if(selected.size>1024*1024){text(result,localize('poiWitnessTooLarge'));return;}\n void selected.text().then(value=>{if(isCurrent()&&token===generation){input.value=value;reset();}}).catch(()=>{if(isCurrent()&&token===generation)text(result,localize('poiWitnessFailed'));});};\n review.onclick=():void=>{reset();const original=input.value,token=generation;\n try{\n const candidate=witnessPolicySnapshot(original);result.dataset['state']='review';\n text(result,localize('poiWitnessQuorum')+': '+String(candidate.policy.requiredOrganizations));\n text(result,localize('poiWitnessReplaced')+': '+String(snapshot.policy.witnesses.filter(before=>!candidate.policy.witnesses.some(after=>after.id===before.id)).length));\n for(const witness of candidate.policy.witnesses)witnessCard(result,witness,true);\n text(result,localize('poiWitnessIndependence'));\n const accept=result.appendChild(document.createElement('button'));accept.type='button';accept.dataset['action']='accept-witness-policy';accept.textContent=localize('poiWitnessAccept');\n accept.onclick=():void=>{if(!isCurrent()||token!==generation||original!==input.value)return;accept.disabled=true;\n void store.replace(snapshot.revision,original).then(()=>{if(isCurrent())refresh();}).catch((error:unknown)=>{if(isCurrent()){\n accept.disabled=false;result.dataset['state']='invalid';text(result,localize('poiWitnessFailed')+': '+(error instanceof Error?error.message:String(error)));\n }});\n };\n }catch(error){result.dataset['state']='invalid';text(result,localize('poiWitnessFailed')+': '+(error instanceof Error?error.message:String(error)));}\n };\n const current=form.appendChild(document.createElement('details'));current.appendChild(document.createElement('summary')).textContent=localize('poiWitnessCurrentPolicy');current.appendChild(document.createElement('pre')).textContent=prettyJSON(snapshot.policy.json);\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { JSONValue, WitnessPublicationPolicy } from '@open-charging-cloud/wwcp-poi';
2
+ export declare const witnessTrustDatabase = "ChargyPOIWitnessTrust";
3
+ export interface WitnessPolicySnapshot {
4
+ readonly revision: string;
5
+ readonly text: string;
6
+ readonly policy: WitnessPublicationPolicy;
7
+ }
8
+ export interface WitnessPolicyRepository {
9
+ snapshot(): Promise<WitnessPolicySnapshot>;
10
+ }
11
+ export declare function witnessPolicySnapshot(text: string, revision?: string): WitnessPolicySnapshot;
12
+ /** Explicit local role/time decisions. Evidence imports and RNO recommendations never write here. */
13
+ export declare class POIWitnessTrustStore implements WitnessPolicyRepository {
14
+ private open;
15
+ private read;
16
+ snapshot(): Promise<WitnessPolicySnapshot>;
17
+ replace(expectedRevision: string, text: string): Promise<void>;
18
+ remove(snapshot: WitnessPolicySnapshot, id: string): Promise<void>;
19
+ }
20
+ /** Explicit test-only implementation; production never substitutes memory for failed storage. */
21
+ export declare class MemoryWitnessPolicy implements WitnessPolicyRepository {
22
+ text: string;
23
+ snapshot(): Promise<WitnessPolicySnapshot>;
24
+ set(value: JSONValue): void;
25
+ }
26
+ //# sourceMappingURL=poiWitnessTrust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poiWitnessTrust.d.ts","sourceRoot":"","sources":["../src/poiWitnessTrust.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,wBAAwB,EAAC,MAAM,+BAA+B,CAAC;AAItF,eAAO,MAAM,oBAAoB,0BAAwB,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IAAE,QAAQ,CAAC,QAAQ,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,IAAI,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,MAAM,EAAC,wBAAwB,CAAC;CAAC;AAChI,MAAM,WAAW,uBAAuB;IAAE,QAAQ,IAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAAC;AACrF,wBAAgB,qBAAqB,CAAC,IAAI,EAAC,MAAM,EAAC,QAAQ,CAAC,EAAC,MAAM,GAAE,qBAAqB,CAIxF;AAED,qGAAqG;AACrG,qBAAa,oBAAqB,YAAW,uBAAuB;YAClD,IAAI;IAWlB,OAAO,CAAC,IAAI;IAKC,QAAQ,IAAG,OAAO,CAAC,qBAAqB,CAAC;IAQzC,OAAO,CAAC,gBAAgB,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC;IAY1D,MAAM,CAAC,QAAQ,EAAC,qBAAqB,EAAC,EAAE,EAAC,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC;CAG9E;AACD,iGAAiG;AACjG,qBAAa,mBAAoB,YAAW,uBAAuB;IACxD,IAAI,SAAa;IACX,QAAQ,IAAG,OAAO,CAAC,qBAAqB,CAAC;IAC/C,GAAG,CAAC,KAAK,EAAC,SAAS,GAAE,IAAI;CACnC"}
@@ -0,0 +1,90 @@
1
+ import { parseJSON, prettyJSON, parseWitnessPublicationPolicy, canonicalJSONBytes, hash, toHex } from '@open-charging-cloud/wwcp-poi';
2
+ const bundledPolicy = { '@context': 'https://open.charging.cloud/contexts/wwcp/witnessPublicationPolicy/v1', requiredOrganizations: 2, witnesses: [] };
3
+ import { broadcastWitnessPolicyChange } from './poiObservedHistory.js';
4
+ export const witnessTrustDatabase = 'ChargyPOIWitnessTrust';
5
+ const bundledText = prettyJSON(bundledPolicy);
6
+ export function witnessPolicySnapshot(text, revision) {
7
+ if (new TextEncoder().encode(text).length > 1024 * 1024)
8
+ throw new Error('Witness policy exceeds 1 MiB');
9
+ const policy = parseWitnessPublicationPolicy(parseJSON(text));
10
+ return { revision: revision ?? 'bundled:' + toHex(hash('sha256', canonicalJSONBytes(policy.json))), text, policy };
11
+ }
12
+ let connection;
13
+ /** Explicit local role/time decisions. Evidence imports and RNO recommendations never write here. */
14
+ export class POIWitnessTrustStore {
15
+ async open() {
16
+ connection ??= new Promise((resolve, reject) => {
17
+ if (typeof indexedDB === 'undefined') {
18
+ reject(new Error('Persistent witness trust unavailable'));
19
+ return;
20
+ }
21
+ const request = indexedDB.open(witnessTrustDatabase, 1);
22
+ let blocked = false;
23
+ request.onupgradeneeded = () => { request.result.createObjectStore('configuration', { keyPath: 'id' }); };
24
+ request.onblocked = () => { blocked = true; reject(new Error('Witness trust storage blocked')); };
25
+ request.onerror = () => { reject(request.error ?? new Error('Witness trust storage unavailable')); };
26
+ request.onsuccess = () => { const db = request.result; if (blocked) {
27
+ db.close();
28
+ return;
29
+ } db.onversionchange = () => { db.close(); connection = undefined; }; db.onclose = () => { connection = undefined; }; resolve(db); };
30
+ }).catch((error) => { connection = undefined; throw error; });
31
+ return connection;
32
+ }
33
+ read(value) {
34
+ if (value === undefined)
35
+ return witnessPolicySnapshot(bundledText);
36
+ if (value === null || typeof value !== 'object' || !('id' in value) || value.id !== 'current' || !('text' in value) || typeof value.text !== 'string' || !('revision' in value) || typeof value.revision !== 'string' || !/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/u.test(value.revision))
37
+ throw new Error('Invalid stored witness trust');
38
+ return witnessPolicySnapshot(value.text, value.revision);
39
+ }
40
+ async snapshot() {
41
+ const db = await this.open();
42
+ return new Promise((resolve, reject) => {
43
+ const tx = db.transaction('configuration'), request = tx.objectStore('configuration').get('current');
44
+ let answer, failure;
45
+ request.onsuccess = () => { try {
46
+ answer = this.read(request.result);
47
+ }
48
+ catch (error) {
49
+ failure = error;
50
+ tx.abort();
51
+ } };
52
+ tx.oncomplete = () => { if (answer === undefined)
53
+ reject(new Error('Witness policy read failed'));
54
+ else
55
+ resolve(answer); };
56
+ tx.onabort = () => { reject(failure instanceof Error ? failure : tx.error ?? new Error('Witness policy read failed')); };
57
+ });
58
+ }
59
+ async replace(expectedRevision, text) {
60
+ const candidate = witnessPolicySnapshot(text), db = await this.open();
61
+ await new Promise((resolve, reject) => {
62
+ const tx = db.transaction('configuration', 'readwrite'), store = tx.objectStore('configuration'), request = store.get('current');
63
+ let failure;
64
+ request.onsuccess = () => {
65
+ try {
66
+ if (this.read(request.result).revision !== expectedRevision)
67
+ throw new Error('Witness policy changed since review');
68
+ store.put({ id: 'current', revision: crypto.randomUUID(), text: candidate.text });
69
+ }
70
+ catch (error) {
71
+ failure = error;
72
+ tx.abort();
73
+ }
74
+ };
75
+ tx.oncomplete = () => { resolve(); };
76
+ tx.onabort = () => { reject(failure instanceof Error ? failure : tx.error ?? new Error('Witness policy update failed')); };
77
+ });
78
+ broadcastWitnessPolicyChange();
79
+ }
80
+ async remove(snapshot, id) {
81
+ await this.replace(snapshot.revision, prettyJSON({ ...snapshot.policy.json, witnesses: snapshot.policy.witnesses.filter(item => item.id !== id).map(item => item.json) }));
82
+ }
83
+ }
84
+ /** Explicit test-only implementation; production never substitutes memory for failed storage. */
85
+ export class MemoryWitnessPolicy {
86
+ text = bundledText;
87
+ async snapshot() { return Promise.resolve(witnessPolicySnapshot(this.text)); }
88
+ set(value) { this.text = prettyJSON(parseWitnessPublicationPolicy(value).json); }
89
+ }
90
+ //# sourceMappingURL=poiWitnessTrust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poiWitnessTrust.js","sourceRoot":"","sources":["../src/poiWitnessTrust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,UAAU,EAAC,6BAA6B,EAAC,kBAAkB,EAAC,IAAI,EAAC,KAAK,EAAC,MAAM,+BAA+B,CAAC;AAE/H,MAAM,aAAa,GAAc,EAAE,UAAU,EAAE,uEAAuE,EAAE,qBAAqB,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AAClK,OAAO,EAAC,4BAA4B,EA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KAAK,IAAE,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;QAC5J,CAAC,CAAC,CAAC;QACH,4BAA4B,EAAE,CAAC;IACnC,CAAC;IACM,KAAK,CAAC,MAAM,CAAC,QAA8B,EAAC,EAAS;QACxD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAC,UAAU,CAAC,EAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAC,SAAS,EAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAA,EAAE,CAAA,IAAI,CAAC,EAAE,KAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAA,EAAE,CAAA,IAAI,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC,CAAC;IACpK,CAAC;CACJ;AACD,iGAAiG;AACjG,MAAM,OAAO,mBAAmB;IACrB,IAAI,GAAC,WAAW,CAAC;IACjB,KAAK,CAAC,QAAQ,KAAkC,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC;IAC1G,GAAG,CAAC,KAAe,IAAO,IAAI,CAAC,IAAI,GAAC,UAAU,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA,CAAC;CACrG","sourcesContent":["import {parseJSON,prettyJSON,parseWitnessPublicationPolicy,canonicalJSONBytes,hash,toHex} from '@open-charging-cloud/wwcp-poi';\nimport type {JSONValue,WitnessPublicationPolicy} from '@open-charging-cloud/wwcp-poi';\nconst bundledPolicy: JSONValue = { '@context': 'https://open.charging.cloud/contexts/wwcp/witnessPublicationPolicy/v1', requiredOrganizations: 2, witnesses: [] };\nimport {broadcastWitnessPolicyChange} from './poiObservedHistory.js';\n\nexport const witnessTrustDatabase='ChargyPOIWitnessTrust';\nconst bundledText=prettyJSON(bundledPolicy);\nexport interface WitnessPolicySnapshot {readonly revision:string;readonly text:string;readonly policy:WitnessPublicationPolicy;}\nexport interface WitnessPolicyRepository {snapshot():Promise<WitnessPolicySnapshot>;}\nexport function witnessPolicySnapshot(text:string,revision?:string):WitnessPolicySnapshot {\n if(new TextEncoder().encode(text).length>1024*1024)throw new Error('Witness policy exceeds 1 MiB');\n const policy=parseWitnessPublicationPolicy(parseJSON(text));\n return {revision:revision??'bundled:'+toHex(hash('sha256',canonicalJSONBytes(policy.json))),text,policy};\n}\nlet connection:Promise<IDBDatabase>|undefined;\n/** Explicit local role/time decisions. Evidence imports and RNO recommendations never write here. */\nexport class POIWitnessTrustStore implements WitnessPolicyRepository {\n private async open():Promise<IDBDatabase> {\n connection??=new Promise<IDBDatabase>((resolve,reject)=>{\n if(typeof indexedDB==='undefined'){reject(new Error('Persistent witness trust unavailable'));return;}\n const request=indexedDB.open(witnessTrustDatabase,1);let blocked=false;\n request.onupgradeneeded=():void=>{request.result.createObjectStore('configuration',{keyPath:'id'});};\n request.onblocked=():void=>{blocked=true;reject(new Error('Witness trust storage blocked'));};\n request.onerror=():void=>{reject(request.error??new Error('Witness trust storage unavailable'));};\n request.onsuccess=():void=>{const db=request.result;if(blocked){db.close();return;}db.onversionchange=():void=>{db.close();connection=undefined;};db.onclose=():void=>{connection=undefined;};resolve(db);};\n }).catch((error:unknown)=>{connection=undefined;throw error;});\n return connection;\n }\n private read(value:unknown):WitnessPolicySnapshot {\n if(value===undefined)return witnessPolicySnapshot(bundledText);\n if(value===null||typeof value!=='object'||!('id' in value)||value.id!=='current'||!('text' in value)||typeof value.text!=='string'||!('revision' in value)||typeof value.revision!=='string'||!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/u.test(value.revision))throw new Error('Invalid stored witness trust');\n return witnessPolicySnapshot(value.text,value.revision);\n }\n public async snapshot():Promise<WitnessPolicySnapshot> {\n const db=await this.open();return new Promise((resolve,reject)=>{\n const tx=db.transaction('configuration'),request=tx.objectStore('configuration').get('current');let answer:WitnessPolicySnapshot|undefined,failure:unknown;\n request.onsuccess=():void=>{try{answer=this.read(request.result);}catch(error){failure=error;tx.abort();}};\n tx.oncomplete=():void=>{if(answer===undefined)reject(new Error('Witness policy read failed'));else resolve(answer);};\n tx.onabort=():void=>{reject(failure instanceof Error?failure:tx.error??new Error('Witness policy read failed'));};\n });\n }\n public async replace(expectedRevision:string,text:string):Promise<void> {\n const candidate=witnessPolicySnapshot(text),db=await this.open();\n await new Promise<void>((resolve,reject)=>{\n const tx=db.transaction('configuration','readwrite'),store=tx.objectStore('configuration'),request=store.get('current');let failure:unknown;\n request.onsuccess=():void=>{try{\n if(this.read(request.result).revision!==expectedRevision)throw new Error('Witness policy changed since review');\n store.put({id:'current',revision:crypto.randomUUID(),text:candidate.text});\n }catch(error){failure=error;tx.abort();}};\n tx.oncomplete=():void=>{resolve();};tx.onabort=():void=>{reject(failure instanceof Error?failure:tx.error??new Error('Witness policy update failed'));};\n });\n broadcastWitnessPolicyChange();\n }\n public async remove(snapshot:WitnessPolicySnapshot,id:string):Promise<void> {\n await this.replace(snapshot.revision,prettyJSON({...snapshot.policy.json,witnesses:snapshot.policy.witnesses.filter(item=>item.id!==id).map(item=>item.json)}));\n }\n}\n/** Explicit test-only implementation; production never substitutes memory for failed storage. */\nexport class MemoryWitnessPolicy implements WitnessPolicyRepository {\n public text=bundledText;\n public async snapshot():Promise<WitnessPolicySnapshot>{return Promise.resolve(witnessPolicySnapshot(this.text));}\n public set(value:JSONValue):void{this.text=prettyJSON(parseWitnessPublicationPolicy(value).json);}\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { ITransportAllowances } from './liveLinkTrust.js';
2
+ import type { WitnessPolicySnapshot } from './poiWitnessTrust.js';
3
+ import type { SessionPriceDocument } from './sessionPriceData.js';
4
+ /** Experimental GET contract. Only explicitly approved endpoints; sends public offer identifiers, no customer/start document. */
5
+ export declare function loadPricePublicationReceipts<T>(document: SessionPriceDocument, policy: WitnessPolicySnapshot, subject: {
6
+ readonly roamingNetworkId: string;
7
+ readonly evseId: string;
8
+ readonly digest: string;
9
+ readonly priceStatementSHA256: string;
10
+ readonly tariffSHA256: string;
11
+ readonly checkpointIds: readonly string[];
12
+ }, verify: (candidate: SessionPriceDocument) => Promise<T>, options: {
13
+ readonly signal: AbortSignal;
14
+ readonly fetch?: typeof fetch;
15
+ readonly allowances?: ITransportAllowances;
16
+ readonly timeoutMs?: number;
17
+ readonly totalTimeoutMs?: number;
18
+ }): Promise<T>;
19
+ //# sourceMappingURL=pricePublicationData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricePublicationData.d.ts","sourceRoot":"","sources":["../src/pricePublicationData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAEhE,iIAAiI;AACjI,wBAAsB,4BAA4B,CAAC,CAAC,EAAE,QAAQ,EAAC,oBAAoB,EAAC,MAAM,EAAC,qBAAqB,EAAC,OAAO,EAAC;IAAC,QAAQ,CAAC,gBAAgB,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,MAAM,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,MAAM,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,oBAAoB,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,YAAY,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,aAAa,EAAC,SAAS,MAAM,EAAE,CAAA;CAAC,EAChT,MAAM,EAAC,CAAC,SAAS,EAAC,oBAAoB,KAAG,OAAO,CAAC,CAAC,CAAC,EAAC,OAAO,EAAC;IAAC,QAAQ,CAAC,MAAM,EAAC,WAAW,CAAC;IAAA,QAAQ,CAAC,KAAK,CAAC,EAAC,OAAO,KAAK,CAAC;IAAA,QAAQ,CAAC,UAAU,CAAC,EAAC,oBAAoB,CAAC;IAAA,QAAQ,CAAC,SAAS,CAAC,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,cAAc,CAAC,EAAC,MAAM,CAAA;CAAC,GAAE,OAAO,CAAC,CAAC,CAAC,CAkC1O"}
@@ -0,0 +1,83 @@
1
+ import { parseJSON, prettyJSON, isObject, PricePublicationReceipt } from '@open-charging-cloud/wwcp-poi';
2
+ import { pollTargetProblem } from './liveLinkTrust.js';
3
+ import { getDefaultPOIFetch, readResponseWithinLimit } from './poiTransport.js';
4
+ /** Experimental GET contract. Only explicitly approved endpoints; sends public offer identifiers, no customer/start document. */
5
+ export async function loadPricePublicationReceipts(document, policy, subject, verify, options) {
6
+ const raw = parseJSON(document.text);
7
+ if (!isObject(raw))
8
+ throw new Error('Original price evidence required');
9
+ const urls = [...new Set(policy.policy.witnesses.filter(item => item.networks.includes(subject.roamingNetworkId)).flatMap(item => item.endpoints))];
10
+ const checkpointIds = [...new Set(subject.checkpointIds)];
11
+ if (urls.length === 0 || urls.length * checkpointIds.length > 16 || checkpointIds.length === 0)
12
+ throw new Error('No bounded authorized witness receipt sources; configure publication witnesses first');
13
+ const controller = new AbortController(), abort = () => { controller.abort(options.signal.reason); };
14
+ options.signal.throwIfAborted();
15
+ options.signal.addEventListener('abort', abort, { once: true });
16
+ const deadline = setTimeout(() => { controller.abort(new Error('Publication receipt deadline exceeded')); }, options.totalTimeoutMs ?? 30000);
17
+ const receipts = new Map(), errors = [];
18
+ let transferred = 0;
19
+ try {
20
+ for (const receipt of Array.isArray(raw['publicationReceipts']) ? raw['publicationReceipts'] : [])
21
+ receipts.set(PricePublicationReceipt.parse(receipt).digest(), receipt);
22
+ for (const endpoint of urls)
23
+ for (const checkpointId of checkpointIds) {
24
+ controller.signal.throwIfAborted();
25
+ const url = new URL(endpoint);
26
+ url.searchParams.set('roamingNetworkId', subject.roamingNetworkId);
27
+ url.searchParams.set('EVSEId', subject.evseId);
28
+ url.searchParams.set('priceStatementDigest', subject.digest);
29
+ url.searchParams.set('checkpointId', checkpointId);
30
+ url.searchParams.set('priceStatementSHA256', subject.priceStatementSHA256);
31
+ url.searchParams.set('tariffSHA256', subject.tariffSHA256);
32
+ if (pollTargetProblem(url, false, options.allowances) !== null) {
33
+ errors.push('Witness endpoint not permitted');
34
+ continue;
35
+ }
36
+ const source = new AbortController(), cancel = () => { source.abort(controller.signal.reason); };
37
+ controller.signal.addEventListener('abort', cancel, { once: true });
38
+ const timeout = setTimeout(() => { source.abort(new Error('Witness source timed out')); }, options.timeoutMs ?? 15000);
39
+ try {
40
+ const response = await (options.fetch ?? getDefaultPOIFetch())(url.href, { signal: source.signal, redirect: 'error', credentials: 'omit', cache: 'no-store', referrerPolicy: 'no-referrer', headers: { Accept: 'application/json' } });
41
+ if (!response.ok)
42
+ throw new Error('Witness source returned ' + String(response.status));
43
+ const bytes = await readResponseWithinLimit(response, Math.min(1024 * 1024, 4 * 1024 * 1024 - transferred));
44
+ transferred += bytes.length;
45
+ if (transferred >= 4 * 1024 * 1024) {
46
+ controller.abort(new Error('Publication receipts exceed the total transfer budget'));
47
+ controller.signal.throwIfAborted();
48
+ }
49
+ source.signal.throwIfAborted();
50
+ const body = parseJSON(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
51
+ const entries = Array.isArray(body) ? body : isObject(body) && Array.isArray(body['publicationReceipts']) ? body['publicationReceipts'] : [body];
52
+ if (entries.length > 64)
53
+ throw new Error('Too many publication receipts');
54
+ for (const entry of entries)
55
+ receipts.set(PricePublicationReceipt.parse(entry).digest(), entry);
56
+ if (receipts.size > 64)
57
+ throw new Error('Too many publication receipts');
58
+ }
59
+ catch (error) {
60
+ controller.signal.throwIfAborted();
61
+ errors.push(error instanceof Error ? error.message : String(error));
62
+ }
63
+ finally {
64
+ clearTimeout(timeout);
65
+ controller.signal.removeEventListener('abort', cancel);
66
+ }
67
+ }
68
+ controller.signal.throwIfAborted();
69
+ if (receipts.size === 0)
70
+ throw new Error('No publication receipts received: ' + errors.join('; '));
71
+ const text = prettyJSON({ ...raw, publicationReceipts: [...receipts.values()] });
72
+ if (new TextEncoder().encode(text).length > 4 * 1024 * 1024)
73
+ throw new Error('Price evidence exceeds 4 MiB');
74
+ const checked = await verify({ ...document, text });
75
+ controller.signal.throwIfAborted();
76
+ return checked;
77
+ }
78
+ finally {
79
+ clearTimeout(deadline);
80
+ options.signal.removeEventListener('abort', abort);
81
+ }
82
+ }
83
+ //# sourceMappingURL=pricePublicationData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricePublicationData.js","sourceRoot":"","sources":["../src/pricePublicationData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,UAAU,EAAC,QAAQ,EAAC,uBAAuB,EAAC,MAAM,+BAA+B,CAAC;AAEpG,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAIhF,iIAAiI;AACjI,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAI,QAA6B,EAAC,MAA4B,EAAC,OAAmM,EAChT,MAAmD,EAAC,OAAuK;IAC3N,MAAM,GAAG,GAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAAA,IAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACzG,MAAM,IAAI,GAAC,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAA,EAAE,CAAA,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA,EAAE,CAAA,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9I,MAAM,aAAa,GAAC,CAAC,GAAG,IAAI,GAAG,C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,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,GAAC,CAAC,GAAC,IAAI,GAAC,IAAI;YAAC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAChL,MAAM,OAAO,GAAC,MAAM,MAAM,CAAC,EAAC,GAAG,QAAQ,EAAC,IAAI,EAAC,CAAC,CAAC;QAAA,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAAA,OAAO,OAAO,CAAC;IACrG,CAAC;YAAO,CAAC;QAAA,YAAY,CAAC,QAAQ,CAAC,CAAC;QAAA,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAC,KAAK,CAAC,CAAC;IAAA,CAAC;AACvF,CAAC","sourcesContent":["import {parseJSON,prettyJSON,isObject,PricePublicationReceipt} from '@open-charging-cloud/wwcp-poi';\nimport type {JSONValue} from '@open-charging-cloud/wwcp-poi';\nimport {pollTargetProblem} from './liveLinkTrust.js';\nimport type {ITransportAllowances} from './liveLinkTrust.js';\nimport { getDefaultPOIFetch, readResponseWithinLimit } from './poiTransport.js';\nimport type {WitnessPolicySnapshot} from './poiWitnessTrust.js';\nimport type {SessionPriceDocument} from './sessionPriceData.js';\n\n/** Experimental GET contract. Only explicitly approved endpoints; sends public offer identifiers, no customer/start document. */\nexport async function loadPricePublicationReceipts<T>(document:SessionPriceDocument,policy:WitnessPolicySnapshot,subject:{readonly roamingNetworkId:string;readonly evseId:string;readonly digest:string;readonly priceStatementSHA256:string;readonly tariffSHA256:string;readonly checkpointIds:readonly string[]},\n verify:(candidate:SessionPriceDocument)=>Promise<T>,options:{readonly signal:AbortSignal;readonly fetch?:typeof fetch;readonly allowances?:ITransportAllowances;readonly timeoutMs?:number;readonly totalTimeoutMs?:number}):Promise<T> {\n const raw=parseJSON(document.text);if(!isObject(raw))throw new Error('Original price evidence required');\n const urls=[...new Set(policy.policy.witnesses.filter(item=>item.networks.includes(subject.roamingNetworkId)).flatMap(item=>item.endpoints))];\n const checkpointIds=[...new Set(subject.checkpointIds)];\n if(urls.length===0||urls.length*checkpointIds.length>16||checkpointIds.length===0)throw new Error('No bounded authorized witness receipt sources; configure publication witnesses first');\n const controller=new AbortController(),abort=():void=>{controller.abort(options.signal.reason);};options.signal.throwIfAborted();options.signal.addEventListener('abort',abort,{once:true});\n const deadline=setTimeout(()=>{controller.abort(new Error('Publication receipt deadline exceeded'));},options.totalTimeoutMs??30000);\n const receipts=new Map<string,JSONValue>(),errors:string[]=[];let transferred=0;\n try{\n for(const receipt of Array.isArray(raw['publicationReceipts'])?raw['publicationReceipts']:[])receipts.set(PricePublicationReceipt.parse(receipt).digest(),receipt);\n for(const endpoint of urls)for(const checkpointId of checkpointIds){\n controller.signal.throwIfAborted();const url=new URL(endpoint);\n url.searchParams.set('roamingNetworkId',subject.roamingNetworkId);url.searchParams.set('EVSEId',subject.evseId);url.searchParams.set('priceStatementDigest',subject.digest);url.searchParams.set('checkpointId',checkpointId);\n url.searchParams.set('priceStatementSHA256',subject.priceStatementSHA256);url.searchParams.set('tariffSHA256',subject.tariffSHA256);\n if(pollTargetProblem(url,false,options.allowances)!==null){errors.push('Witness endpoint not permitted');continue;}\n const source=new AbortController(),cancel=():void=>{source.abort(controller.signal.reason);};controller.signal.addEventListener('abort',cancel,{once:true});\n const timeout=setTimeout(()=>{source.abort(new Error('Witness source timed out'));},options.timeoutMs??15000);\n try{\n const response=await(options.fetch??getDefaultPOIFetch())(url.href,{signal:source.signal,redirect:'error',credentials:'omit',cache:'no-store',referrerPolicy:'no-referrer',headers:{Accept:'application/json'}});\n if(!response.ok)throw new Error('Witness source returned '+String(response.status));\n const bytes=await readResponseWithinLimit(response,Math.min(1024*1024,4*1024*1024-transferred));transferred+=bytes.length;\n if(transferred>=4*1024*1024){controller.abort(new Error('Publication receipts exceed the total transfer budget'));controller.signal.throwIfAborted();}\n source.signal.throwIfAborted();const body=parseJSON(new TextDecoder('utf-8',{fatal:true}).decode(bytes));\n const entries=Array.isArray(body)?body:isObject(body)&&Array.isArray(body['publicationReceipts'])?body['publicationReceipts']:[body];\n if(entries.length>64)throw new Error('Too many publication receipts');\n for(const entry of entries)receipts.set(PricePublicationReceipt.parse(entry).digest(),entry);\n if(receipts.size>64)throw new Error('Too many publication receipts');\n }catch(error){controller.signal.throwIfAborted();errors.push(error instanceof Error?error.message:String(error));}\n finally{clearTimeout(timeout);controller.signal.removeEventListener('abort',cancel);}\n }\n controller.signal.throwIfAborted();if(receipts.size===0)throw new Error('No publication receipts received: '+errors.join('; '));\n const text=prettyJSON({...raw,publicationReceipts:[...receipts.values()]});if(new TextEncoder().encode(text).length>4*1024*1024)throw new Error('Price evidence exceeds 4 MiB');\n const checked=await verify({...document,text});controller.signal.throwIfAborted();return checked;\n }finally{clearTimeout(deadline);options.signal.removeEventListener('abort',abort);}\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { POIPublicKey } from '@open-charging-cloud/wwcp-poi';
2
+ import type { StoredTrustAnchor } from './trustStore.js';
3
+ import type { POITrustContext } from './poiTrustContext.js';
4
+ export interface StoredRoamingNetwork {
5
+ readonly id: string;
6
+ readonly identity: string;
7
+ readonly context?: POITrustContext;
8
+ readonly anchors: readonly StoredTrustAnchor[];
9
+ }
10
+ /** Authenticated RN/RNO/policy identities; unverified policies stay isolated, even if they claim the same ID. */
11
+ export declare function groupRoamingNetworks(records: readonly StoredTrustAnchor[], bundled?: readonly POIPublicKey[], deleted?: ReadonlySet<string>, at?: number): readonly StoredRoamingNetwork[];
12
+ /** These display names come from imported anchors and are not authenticated network names. */
13
+ export declare function roamingNetworkDisplayName(network: StoredRoamingNetwork, language: string): string;
14
+ //# sourceMappingURL=roamingNetworks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roamingNetworks.d.ts","sourceRoot":"","sources":["../src/roamingNetworks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAClD;AAED,iHAAiH;AACjH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,OAAO,GAAE,SAAS,YAAY,EAAO,EAC1E,OAAO,GAAE,WAAW,CAAC,MAAM,CAAa,EAAE,EAAE,GAAE,MAAmB,GAAG,SAAS,oBAAoB,EAAE,CAiBzI;AAED,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CASjG"}
@@ -0,0 +1,33 @@
1
+ import { TrustAnchor } from '@open-charging-cloud/wwcp-poi';
2
+ import { createPOITrustContext } from './poiTrustContext.js';
3
+ /** Authenticated RN/RNO/policy identities; unverified policies stay isolated, even if they claim the same ID. */
4
+ export function groupRoamingNetworks(records, bundled = [], deleted = new Set(), at = Date.now()) {
5
+ const groups = new Map();
6
+ for (const record of records) {
7
+ const anchor = TrustAnchor.parse(record.qrCode);
8
+ let context;
9
+ try {
10
+ if (record.downloadedData !== undefined)
11
+ context = createPOITrustContext(anchor, record.downloadedData, record, bundled, deleted, at);
12
+ }
13
+ catch { /* Keep invalid, expired or insufficiently trusted imports visible as isolated policies. */ }
14
+ const identity = context === undefined ? `unverified:${record.id}` : `authenticated:${context.networkIdentity}`;
15
+ const previous = groups.get(identity);
16
+ groups.set(identity, { id: anchor.id, identity,
17
+ anchors: [...(previous?.anchors ?? []), record].sort((a, b) => b.importedAt.localeCompare(a.importedAt)),
18
+ ...(context === undefined ? {} : { context }) });
19
+ }
20
+ return [...groups.values()].sort((a, b) => a.id.localeCompare(b.id) || a.identity.localeCompare(b.identity));
21
+ }
22
+ /** These display names come from imported anchors and are not authenticated network names. */
23
+ export function roamingNetworkDisplayName(network, language) {
24
+ const names = network.anchors.map(record => TrustAnchor.parse(record.qrCode).name);
25
+ for (const candidate of [language, "en"])
26
+ for (const name of names) {
27
+ const value = name[candidate];
28
+ if (value !== undefined && value.trim() !== "")
29
+ return value;
30
+ }
31
+ return names.flatMap(name => Object.values(name)).find(value => value.trim() !== "") ?? network.id;
32
+ }
33
+ //# sourceMappingURL=roamingNetworks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roamingNetworks.js","sourceRoot":"","sources":["../src/roamingNetworks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAU7D,iHAAiH;AACjH,MAAM,UAAU,oBAAoB,CAAC,OAAqC,EAAE,UAAmC,EAAE,EAC1E,UAA+B,IAAI,GAAG,EAAE,EAAE,KAAa,IAAI,CAAC,GAAG,EAAE;IACpG,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgC,CAAC;IACvD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,OAAoC,CAAC;QACzC,IAAI,CAAC;YACD,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS;gBACnC,OAAO,GAAG,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,CAAC,CAAC,2FAA2F,CAAC,CAAC;QACrG,MAAM,QAAQ,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC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AI,CAAC,SAAS,CAAC,CAAC;YAC9B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;gBAC1C,OAAO,KAAK,CAAC;QACrB,CAAC;IACL,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC;AACvG,CAAC","sourcesContent":["import { TrustAnchor } from '@open-charging-cloud/wwcp-poi';\nimport type { POIPublicKey } from '@open-charging-cloud/wwcp-poi';\nimport type { StoredTrustAnchor } from './trustStore.js';\nimport { createPOITrustContext } from './poiTrustContext.js';\nimport type { POITrustContext } from './poiTrustContext.js';\n\nexport interface StoredRoamingNetwork {\n readonly id: string;\n readonly identity: string;\n readonly context?: POITrustContext;\n readonly anchors: readonly StoredTrustAnchor[];\n}\n\n/** Authenticated RN/RNO/policy identities; unverified policies stay isolated, even if they claim the same ID. */\nexport function groupRoamingNetworks(records: readonly StoredTrustAnchor[], bundled: readonly POIPublicKey[] = [],\n deleted: ReadonlySet<string> = new Set(), at: number = Date.now()): readonly StoredRoamingNetwork[] {\n const groups = new Map<string, StoredRoamingNetwork>();\n for (const record of records) {\n const anchor = TrustAnchor.parse(record.qrCode);\n let context: POITrustContext | undefined;\n try {\n if (record.downloadedData !== undefined)\n context = createPOITrustContext(anchor, record.downloadedData, record, bundled, deleted, at);\n }\n catch { /* Keep invalid, expired or insufficiently trusted imports visible as isolated policies. */ }\n const identity = context === undefined ? `unverified:${record.id}` : `authenticated:${context.networkIdentity}`;\n const previous = groups.get(identity);\n groups.set(identity, { id: anchor.id, identity,\n anchors: [...(previous?.anchors ?? []), record].sort((a, b) => b.importedAt.localeCompare(a.importedAt)),\n ...(context === undefined ? {} : { context }) });\n }\n return [...groups.values()].sort((a, b) => a.id.localeCompare(b.id) || a.identity.localeCompare(b.identity));\n}\n\n/** These display names come from imported anchors and are not authenticated network names. */\nexport function roamingNetworkDisplayName(network: StoredRoamingNetwork, language: string): string {\n const names = network.anchors.map(record => TrustAnchor.parse(record.qrCode).name);\n for (const candidate of [language, \"en\"])\n for (const name of names) {\n const value = name[candidate];\n if (value !== undefined && value.trim() !== \"\")\n return value;\n }\n return names.flatMap(name => Object.values(name)).find(value => value.trim() !== \"\") ?? network.id;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Drunken Bishop, compatible with Styx SecurityVisualization.DrunkenBishop:
3
+ * https://github.com/Vanaheimr/Styx/blob/master/Styx/Illias/SecurityVisualization/DrunkenBishop.cs
4
+ * Styx implementation copyright (c) 2014-2026 GraphDefined GmbH, Apache-2.0.
5
+ *
6
+ * Presentation only: the visit matrix is not a unique cryptographic identifier.
7
+ * v1 fixes a 17 x 9 board, center start, least-significant two-bit moves first,
8
+ * clamped edges and counts after each move. Do not change it without versioning.
9
+ */
10
+ export declare const fingerprintRasterVersion = "drunken-bishop-v1";
11
+ export declare const fingerprintRasterWidth = 17;
12
+ export declare const fingerprintRasterHeight = 9;
13
+ /** Plain hex fingerprints, up to SHA-512; never hash their textual spelling. */
14
+ export declare function fingerprintBytes(hex: string): Uint8Array;
15
+ export declare function drunkenBishop(bytes: Uint8Array): readonly number[];
16
+ //# sourceMappingURL=securityFingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityFingerprint.d.ts","sourceRoot":"","sources":["../src/securityFingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAIxD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,CAgBlE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Drunken Bishop, compatible with Styx SecurityVisualization.DrunkenBishop:
3
+ * https://github.com/Vanaheimr/Styx/blob/master/Styx/Illias/SecurityVisualization/DrunkenBishop.cs
4
+ * Styx implementation copyright (c) 2014-2026 GraphDefined GmbH, Apache-2.0.
5
+ *
6
+ * Presentation only: the visit matrix is not a unique cryptographic identifier.
7
+ * v1 fixes a 17 x 9 board, center start, least-significant two-bit moves first,
8
+ * clamped edges and counts after each move. Do not change it without versioning.
9
+ */
10
+ export const fingerprintRasterVersion = "drunken-bishop-v1";
11
+ export const fingerprintRasterWidth = 17;
12
+ export const fingerprintRasterHeight = 9;
13
+ /** Plain hex fingerprints, up to SHA-512; never hash their textual spelling. */
14
+ export function fingerprintBytes(hex) {
15
+ if (!/^(?:[0-9a-fA-F]{2}){1,64}$/.test(hex))
16
+ throw new Error("A visual fingerprint requires 1 to 64 bytes in hexadecimal");
17
+ return Uint8Array.from(hex.match(/../g) ?? [], byte => Number.parseInt(byte, 16));
18
+ }
19
+ export function drunkenBishop(bytes) {
20
+ if (bytes.length === 0 || bytes.length > 64)
21
+ throw new Error("A visual fingerprint requires 1 to 64 bytes");
22
+ const visits = new Array(fingerprintRasterWidth * fingerprintRasterHeight).fill(0);
23
+ let x = Math.floor(fingerprintRasterWidth / 2);
24
+ let y = Math.floor(fingerprintRasterHeight / 2);
25
+ for (const byte of bytes) {
26
+ for (let shift = 0; shift < 8; shift += 2) {
27
+ const move = (byte >> shift) & 3;
28
+ x = Math.max(0, Math.min(fingerprintRasterWidth - 1, x + ((move & 1) === 0 ? -1 : 1)));
29
+ y = Math.max(0, Math.min(fingerprintRasterHeight - 1, y + ((move & 2) === 0 ? -1 : 1)));
30
+ const position = y * fingerprintRasterWidth + x;
31
+ visits[position] = (visits[position] ?? 0) + 1;
32
+ }
33
+ }
34
+ return Object.freeze(visits);
35
+ }
36
+ //# sourceMappingURL=securityFingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityFingerprint.js","sourceRoot":"","sources":["../src/securityFingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,GAAW;IACxC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC3C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,IAAI,KAAK,CAAS,sBAAsB,GAAG,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3F,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,GAAG,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,GAAG,CAAC,CAAC,CAAC;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,sBAAsB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACvF,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxF,MAAM,QAAQ,GAAG,CAAC,GAAG,sBAAsB,GAAG,CAAC,CAAC;YAChD,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnD,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC","sourcesContent":["/**\n * Drunken Bishop, compatible with Styx SecurityVisualization.DrunkenBishop:\n * https://github.com/Vanaheimr/Styx/blob/master/Styx/Illias/SecurityVisualization/DrunkenBishop.cs\n * Styx implementation copyright (c) 2014-2026 GraphDefined GmbH, Apache-2.0.\n *\n * Presentation only: the visit matrix is not a unique cryptographic identifier.\n * v1 fixes a 17 x 9 board, center start, least-significant two-bit moves first,\n * clamped edges and counts after each move. Do not change it without versioning.\n */\nexport const fingerprintRasterVersion = \"drunken-bishop-v1\";\nexport const fingerprintRasterWidth = 17;\nexport const fingerprintRasterHeight = 9;\n\n/** Plain hex fingerprints, up to SHA-512; never hash their textual spelling. */\nexport function fingerprintBytes(hex: string): Uint8Array {\n if (!/^(?:[0-9a-fA-F]{2}){1,64}$/.test(hex))\n throw new Error(\"A visual fingerprint requires 1 to 64 bytes in hexadecimal\");\n return Uint8Array.from(hex.match(/../g) ?? [], byte => Number.parseInt(byte, 16));\n}\n\nexport function drunkenBishop(bytes: Uint8Array): readonly number[] {\n if (bytes.length === 0 || bytes.length > 64)\n throw new Error(\"A visual fingerprint requires 1 to 64 bytes\");\n const visits = new Array<number>(fingerprintRasterWidth * fingerprintRasterHeight).fill(0);\n let x = Math.floor(fingerprintRasterWidth / 2);\n let y = Math.floor(fingerprintRasterHeight / 2);\n for (const byte of bytes) {\n for (let shift = 0; shift < 8; shift += 2) {\n const move = (byte >> shift) & 3;\n x = Math.max(0, Math.min(fingerprintRasterWidth - 1, x + ((move & 1) === 0 ? -1 : 1)));\n y = Math.max(0, Math.min(fingerprintRasterHeight - 1, y + ((move & 2) === 0 ? -1 : 1)));\n const position = y * fingerprintRasterWidth + x;\n visits[position] = (visits[position] ?? 0) + 1;\n }\n }\n return Object.freeze(visits);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /** Shared by previews, key confirmations and Trust Management. Never makes trust decisions. */
2
+ export declare function renderSecurityFingerprint(fingerprint: string, localize: (key: string) => string, doc?: Document): HTMLElement;
3
+ //# sourceMappingURL=securityFingerprintView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityFingerprintView.d.ts","sourceRoot":"","sources":["../src/securityFingerprintView.ts"],"names":[],"mappings":"AAQA,+FAA+F;AAC/F,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAK,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EACpC,GAAG,GAAU,QAAmB,GAAG,WAAW,CAuDvF"}