@open-charging-cloud/chargy-core 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +1 -1
- package/dist/DocumentSignatures.d.ts +70 -0
- package/dist/DocumentSignatures.d.ts.map +1 -0
- package/dist/OCMF.d.ts +1 -1
- package/dist/OCMF.d.ts.map +1 -1
- package/dist/browser/index.js +333 -29
- package/dist/browser/index.js.map +1 -1
- package/dist/chargy.d.ts +1 -0
- package/dist/chargy.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/interfaces/IChargeTransparencyLiveLink.d.ts +19 -1
- package/dist/interfaces/IChargeTransparencyLiveLink.d.ts.map +1 -1
- package/dist/node/index.js +333 -29
- package/dist/node/index.js.map +1 -1
- package/i18n.json +25 -0
- package/package.json +1 -1
package/dist/chargy.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ export declare class Chargy {
|
|
|
100
100
|
* that are understood here.
|
|
101
101
|
*/
|
|
102
102
|
TryToParseLiveLinkMeterValues(LiveLink: chargeTransparencyLiveLink.IChargeTransparencyLiveLink): Promise<chargeTransparencyRecord.IChargeTransparencyRecord | undefined>;
|
|
103
|
+
private verifyLiveLinkSignatures;
|
|
103
104
|
private collectLiveLinkMeterValueKeys;
|
|
104
105
|
private processChargeTransparencyRecord;
|
|
105
106
|
private hasInplausibleChargingSessionTotalEnergyMeasurement;
|
package/dist/chargy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chargy.d.ts","sourceRoot":"","sources":["../src/chargy.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,gBAAgB,MAAqB,+BAA+B,CAAA;AAChF,OAAO,KAAK,wBAAwB,MAAa,wCAAwC,CAAA;AACzF,OAAO,KAAK,0BAA0B,MAAW,0CAA0C,CAAA;AAC3F,OAAO,KAAK,SAAS,MAA4B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AC,aAAa;YAaP,sBAAsB;IAsG7B,8BAA8B,CAAC,IAAI,EAAE,KAAK,CAAC,wBAAwB,CAAC,yBAAyB,CAAC,GAAG,wBAAwB,CAAC,yBAAyB;CAgF7J"}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./interfaces/IChargeTransparencyRecord";
|
|
|
28
28
|
export * from "./interfaces/IPublicKeyInfo";
|
|
29
29
|
export { IsAURL, IsValidURL, URLContext, type IURL, type URLResolver } from "./interfaces/IURL";
|
|
30
30
|
export { ChargeTransparencyLiveLinkContext, IsAChargeTransparencyLiveLink, type IChargeTransparencyLiveLink, type ITransport, type ITransportURL, type TOTPConfig, type Transport, type TransportHTTPS, type TransportHTTPSSE, type TransportWebsocket } from "./interfaces/IChargeTransparencyLiveLink";
|
|
31
|
+
export { collectDocumentPublicKeys, verifyDocumentSignatures, type DocumentSignatureStatus, type DocumentSignaturesStatus, type IDocumentPublicKey, type IDocumentSignatureResult, type IDocumentSignaturesResult } from "./DocumentSignatures";
|
|
31
32
|
export * as ChargyInterfaces from "./interfaces/chargyInterfaces";
|
|
32
33
|
export * as ChargeTransparencyLiveLink from "./interfaces/IChargeTransparencyLiveLink";
|
|
33
34
|
export * as ChargeTransparencyRecord from "./interfaces/IChargeTransparencyRecord";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,c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c,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACH,MAAM,EACN,UAAU,EACV,UAAU,EACV,KAAK,IAAI,EACT,KAAK,WAAW,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,iCAAiC,EACjC,6BAA6B,EAC7B,KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAC1B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,yBAAyB,EACzB,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EACjC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,gBAAgB,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,0BAA0B,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,wBAAwB,MAAM,wCAAwC,CAAC;AACnF,OAAO,KAAK,aAAa,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import * as chargyInterfaces from './chargyInterfaces';
|
|
1
|
+
import type * as chargyInterfaces from './chargyInterfaces';
|
|
2
2
|
import * as chargyLib from './chargyLib';
|
|
3
|
+
import type { IDocumentSignaturesResult } from '../DocumentSignatures';
|
|
3
4
|
export declare const ChargeTransparencyLiveLinkContext = "https://open.charging.cloud/contexts/chargeTransparency/live/link/1.0";
|
|
5
|
+
export declare function isConnector(data: unknown): data is IConnector;
|
|
6
|
+
export declare function isTransport(data: unknown): data is Transport;
|
|
4
7
|
export declare function IsAChargeTransparencyLiveLink(data: unknown): data is IChargeTransparencyLiveLink;
|
|
5
8
|
export interface IChargeTransparencyLiveLink extends chargyLib.JSONObject {
|
|
6
9
|
"@context": typeof ChargeTransparencyLiveLinkContext;
|
|
@@ -18,6 +21,21 @@ export interface IChargeTransparencyLiveLink extends chargyLib.JSONObject {
|
|
|
18
21
|
liveTransports?: Transport[];
|
|
19
22
|
/** Digital signatures (currently empty or extendable) */
|
|
20
23
|
signatures?: chargyInterfaces.ISignature[];
|
|
24
|
+
/**
|
|
25
|
+
* How the signatures over this whole document came out, filled in when the
|
|
26
|
+
* document was read.
|
|
27
|
+
*
|
|
28
|
+
* The signatures cover every property except their own, so this - like
|
|
29
|
+
* every other property added after reading - must be set only *after* the
|
|
30
|
+
* document has been verified. Adding it first would change the very bytes
|
|
31
|
+
* that are verified.
|
|
32
|
+
*/
|
|
33
|
+
signatureVerification?: IDocumentSignaturesResult;
|
|
34
|
+
/**
|
|
35
|
+
* Non-fatal findings about this document, e.g. that it is unsigned or that
|
|
36
|
+
* a signature did not verify. None of these make the document unusable.
|
|
37
|
+
*/
|
|
38
|
+
warnings?: Array<chargyInterfaces.IWarning>;
|
|
21
39
|
}
|
|
22
40
|
/** Connector information */
|
|
23
41
|
export interface IConnector {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IChargeTransparencyLiveLink.d.ts","sourceRoot":"","sources":["../../src/interfaces/IChargeTransparencyLiveLink.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"IChargeTransparencyLiveLink.d.ts","sourceRoot":"","sources":["../../src/interfaces/IChargeTransparencyLiveLink.ts"],"names":[],"mappings":"AAiBA,OAAO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,EAAa,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAc,MAAM,CAAC;CACjC;AAID,sDAAsD;AACtD,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,UAAU;IACvB,GAAG,CAAC,EAAG,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,GAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,cAAmB,SAAQ,UAAU;IAClD,IAAI,EAAE,OAAO,CAAC;IAEd;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAmB,SAAQ,UAAU;IAClD,IAAI,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IAClD,IAAI,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAoB,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAc,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAgB,MAAM,CAAC;CACjC;AAED,iDAAiD;AACjD,MAAM,WAAW,UAAU;IACvB,mBAAmB,EAAI,MAAM,CAAC;IAC9B,QAAQ,EAAe,MAAM,CAAC;CACjC"}
|
package/dist/node/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ed448ph, ed448 } from '@noble/curves/ed448.js';
|
|
|
5
5
|
import { p521, p384, p256 } from '@noble/curves/nist.js';
|
|
6
6
|
import { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
7
7
|
import { ml_dsa87, ml_dsa65, ml_dsa44 } from '@noble/post-quantum/ml-dsa.js';
|
|
8
|
-
import { sha256 as sha256$1 } from '@noble/hashes/sha2.js';
|
|
8
|
+
import { sha256 as sha256$1, sha512 as sha512$1, sha384 as sha384$1 } from '@noble/hashes/sha2.js';
|
|
9
9
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
10
10
|
import { fileTypeFromBuffer } from 'file-type';
|
|
11
11
|
import isURL from 'is-url-superb';
|
|
@@ -1278,10 +1278,10 @@ var NobleCompatibleCurve = class {
|
|
|
1278
1278
|
keyFromPublic(publicKey, encoding) {
|
|
1279
1279
|
if (encoding.toLowerCase() !== "hex")
|
|
1280
1280
|
throw new TypeError("Only hexadecimal public keys are supported by the compatibility API.");
|
|
1281
|
-
const
|
|
1282
|
-
if (!this.suite.isValidPublicKey(
|
|
1281
|
+
const publicKeyBytes2 = normalizeSEC1PublicKey(publicKey, this.coordinateLength);
|
|
1282
|
+
if (!this.suite.isValidPublicKey(publicKeyBytes2))
|
|
1283
1283
|
throw new TypeError("Public key is not a valid point on the selected curve.");
|
|
1284
|
-
return new NobleCompatiblePublicKey(this.suite,
|
|
1284
|
+
return new NobleCompatiblePublicKey(this.suite, publicKeyBytes2, this.coordinateLength);
|
|
1285
1285
|
}
|
|
1286
1286
|
};
|
|
1287
1287
|
var suites = {
|
|
@@ -4115,7 +4115,7 @@ async function signJSONMessage(JSONMessage, KeyPairs, options) {
|
|
|
4115
4115
|
continue;
|
|
4116
4116
|
const publicKeyEncoding = isRawSignatureAlgorithm(algorithm) ? "raw" : "sec1";
|
|
4117
4117
|
const signatureEncoding = options?.signatureEncoding ?? suite.signatureEncoding;
|
|
4118
|
-
const
|
|
4118
|
+
const publicKeyBytes2 = KeyPair.publicKey ?? suite.getPublicKey(KeyPair.privateKey);
|
|
4119
4119
|
const signatureBytes = suite.sign(
|
|
4120
4120
|
plainText,
|
|
4121
4121
|
KeyPair.privateKey,
|
|
@@ -4125,8 +4125,8 @@ async function signJSONMessage(JSONMessage, KeyPairs, options) {
|
|
|
4125
4125
|
algorithm,
|
|
4126
4126
|
publicKeyEncoding,
|
|
4127
4127
|
signatureEncoding,
|
|
4128
|
-
publicKey: bytesToBase64(
|
|
4129
|
-
publicKeyHEX: bytesToHex(
|
|
4128
|
+
publicKey: bytesToBase64(publicKeyBytes2),
|
|
4129
|
+
publicKeyHEX: bytesToHex(publicKeyBytes2),
|
|
4130
4130
|
signature: bytesToBase64(signatureBytes),
|
|
4131
4131
|
signatureHEX: bytesToHex(signatureBytes)
|
|
4132
4132
|
};
|
|
@@ -4137,7 +4137,7 @@ async function signJSONMessage(JSONMessage, KeyPairs, options) {
|
|
|
4137
4137
|
const signatureIsValid = suite.verify(
|
|
4138
4138
|
plainText,
|
|
4139
4139
|
signatureBytes,
|
|
4140
|
-
|
|
4140
|
+
publicKeyBytes2,
|
|
4141
4141
|
signatureOptions(options, signatureEncoding)
|
|
4142
4142
|
);
|
|
4143
4143
|
if (!signatureIsValid)
|
|
@@ -4180,11 +4180,11 @@ async function verifyJSONSignatureResult(JSONMessage, signature, options) {
|
|
|
4180
4180
|
const resolvedOptions = resolveSignOptions(options);
|
|
4181
4181
|
const algorithm = signature.algorithm ?? resolvedOptions.algorithm;
|
|
4182
4182
|
const suite = getSignatureSuite(algorithm);
|
|
4183
|
-
const
|
|
4183
|
+
const publicKeyBytes2 = hexToBytes(signature.publicKeyHEX);
|
|
4184
4184
|
const signatureBytes = hexToBytes(signature.signatureHEX);
|
|
4185
4185
|
const signatureEncoding = signature.signatureEncoding ?? (isRawSignatureAlgorithm(algorithm) ? "raw" : "der");
|
|
4186
4186
|
try {
|
|
4187
|
-
const publicKeyIsValid = suite.isValidPublicKey(
|
|
4187
|
+
const publicKeyIsValid = suite.isValidPublicKey(publicKeyBytes2);
|
|
4188
4188
|
if (!publicKeyIsValid)
|
|
4189
4189
|
return verificationResult(
|
|
4190
4190
|
"InvalidPublicKey" /* InvalidPublicKey */,
|
|
@@ -4200,7 +4200,7 @@ async function verifyJSONSignatureResult(JSONMessage, signature, options) {
|
|
|
4200
4200
|
const signatureIsValid = suite.verify(
|
|
4201
4201
|
plainText,
|
|
4202
4202
|
signatureBytes,
|
|
4203
|
-
|
|
4203
|
+
publicKeyBytes2,
|
|
4204
4204
|
signatureVerificationOptions(signature, options, signatureEncoding)
|
|
4205
4205
|
);
|
|
4206
4206
|
return signatureIsValid ? verificationResult("True" /* True */) : verificationResult(
|
|
@@ -6529,10 +6529,10 @@ var OCMF = class {
|
|
|
6529
6529
|
try {
|
|
6530
6530
|
if (typeof PublicKey !== "string")
|
|
6531
6531
|
throw new TypeError("EdDSA and ML-DSA public keys must use a raw string encoding.");
|
|
6532
|
-
const
|
|
6532
|
+
const publicKeyBytes2 = decodeRawOCMFBytes(PublicKey, PublicKeyEncoding);
|
|
6533
6533
|
const signatureBytes = OCMFJSONDocument.signatureBytes;
|
|
6534
6534
|
const rawPayload = OCMFJSONDocument.rawPayload;
|
|
6535
|
-
if (!signatureSuite.isValidPublicKey(
|
|
6535
|
+
if (!signatureSuite.isValidPublicKey(publicKeyBytes2))
|
|
6536
6536
|
throw new TypeError("Public key is invalid for the selected signature algorithm.");
|
|
6537
6537
|
if (signatureBytes == null)
|
|
6538
6538
|
throw new TypeError("Missing raw signature bytes.");
|
|
@@ -6541,7 +6541,7 @@ var OCMF = class {
|
|
|
6541
6541
|
const signatureValid = signatureSuite.verify(
|
|
6542
6542
|
new TextEncoder().encode(rawPayload),
|
|
6543
6543
|
signatureBytes,
|
|
6544
|
-
|
|
6544
|
+
publicKeyBytes2
|
|
6545
6545
|
);
|
|
6546
6546
|
if (!signatureValid)
|
|
6547
6547
|
this.AddValidationError(OCMFJSONDocument, "Verification_SignatureMismatch");
|
|
@@ -6558,7 +6558,7 @@ var OCMF = class {
|
|
|
6558
6558
|
if (curve === null)
|
|
6559
6559
|
throw new Error(`Unsupported ECC curve '${OCMFJSONDocument.signature.SA ?? ""}'!`);
|
|
6560
6560
|
OCMFJSONDocument.publicKey ??= PublicKey;
|
|
6561
|
-
let
|
|
6561
|
+
let publicKeyBytes2 = null;
|
|
6562
6562
|
if (typeof OCMFJSONDocument.publicKey === "string") {
|
|
6563
6563
|
const ECPoint = this.chargy.asn1.define("ECPoint", function() {
|
|
6564
6564
|
this.seq().obj(
|
|
@@ -6572,36 +6572,36 @@ var OCMF = class {
|
|
|
6572
6572
|
if (PublicKeyEncoding != null && PublicKeyEncoding.length > 0) {
|
|
6573
6573
|
switch (PublicKeyEncoding.toLowerCase()) {
|
|
6574
6574
|
case "hex":
|
|
6575
|
-
|
|
6575
|
+
publicKeyBytes2 = Buffer.from(OCMFJSONDocument.publicKey, "hex");
|
|
6576
6576
|
break;
|
|
6577
6577
|
case "base32":
|
|
6578
|
-
|
|
6578
|
+
publicKeyBytes2 = Buffer.from(this.chargy.base32Decode(OCMFJSONDocument.publicKey, "RFC4648"));
|
|
6579
6579
|
break;
|
|
6580
6580
|
case "base64":
|
|
6581
|
-
|
|
6581
|
+
publicKeyBytes2 = Buffer.from(OCMFJSONDocument.publicKey, "base64");
|
|
6582
6582
|
break;
|
|
6583
6583
|
}
|
|
6584
6584
|
}
|
|
6585
|
-
if (
|
|
6585
|
+
if (publicKeyBytes2 == null) {
|
|
6586
6586
|
const hexRegex = /^[0-9A-Fa-f]+$/;
|
|
6587
6587
|
const base32Regex = /^(?:[A-Z2-7]{8})*(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}=)?$/;
|
|
6588
6588
|
const base64Regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
6589
6589
|
if (hexRegex.test(OCMFJSONDocument.publicKey)) {
|
|
6590
6590
|
PublicKeyEncoding = "hex";
|
|
6591
|
-
|
|
6591
|
+
publicKeyBytes2 = Buffer.from(OCMFJSONDocument.publicKey, "hex");
|
|
6592
6592
|
} else if (base32Regex.test(OCMFJSONDocument.publicKey)) {
|
|
6593
6593
|
PublicKeyEncoding = "base32";
|
|
6594
|
-
|
|
6594
|
+
publicKeyBytes2 = Buffer.from(this.chargy.base32Decode(OCMFJSONDocument.publicKey, "RFC4648"));
|
|
6595
6595
|
} else if (base64Regex.test(OCMFJSONDocument.publicKey)) {
|
|
6596
6596
|
PublicKeyEncoding = "base64";
|
|
6597
|
-
|
|
6597
|
+
publicKeyBytes2 = Buffer.from(OCMFJSONDocument.publicKey, "base64");
|
|
6598
6598
|
}
|
|
6599
6599
|
}
|
|
6600
|
-
if (
|
|
6600
|
+
if (publicKeyBytes2 == null) {
|
|
6601
6601
|
OCMFJSONDocument.validationStatus = "UnknownPublicKeyFormat" /* UnknownPublicKeyFormat */;
|
|
6602
6602
|
return OCMFJSONDocument.validationStatus;
|
|
6603
6603
|
}
|
|
6604
|
-
const decodedPublicKeyASN1 = ECPoint.decode(
|
|
6604
|
+
const decodedPublicKeyASN1 = ECPoint.decode(publicKeyBytes2, "der");
|
|
6605
6605
|
const publicKeyASN1 = decodedPublicKeyASN1;
|
|
6606
6606
|
const coordinates = publicKeyASN1.pubKey.data.subarray(1);
|
|
6607
6607
|
const halfLength = coordinates.length / 2;
|
|
@@ -10259,7 +10259,9 @@ function toSessionVerificationResults(CTR, noRecordsMessage = { "en": "No charge
|
|
|
10259
10259
|
var IChargeTransparencyLiveLink_exports = {};
|
|
10260
10260
|
__export(IChargeTransparencyLiveLink_exports, {
|
|
10261
10261
|
ChargeTransparencyLiveLinkContext: () => ChargeTransparencyLiveLinkContext,
|
|
10262
|
-
IsAChargeTransparencyLiveLink: () => IsAChargeTransparencyLiveLink
|
|
10262
|
+
IsAChargeTransparencyLiveLink: () => IsAChargeTransparencyLiveLink,
|
|
10263
|
+
isConnector: () => isConnector,
|
|
10264
|
+
isTransport: () => isTransport
|
|
10263
10265
|
});
|
|
10264
10266
|
var ChargeTransparencyLiveLinkContext = "https://open.charging.cloud/contexts/chargeTransparency/live/link/1.0";
|
|
10265
10267
|
function isConnector(data) {
|
|
@@ -10285,9 +10287,7 @@ function isTransport(data) {
|
|
|
10285
10287
|
return (data["url"] === void 0 || typeof data["url"] === "string") && (data["urls"] === void 0 || Array.isArray(data["urls"]) && data["urls"].every(isTransportURL)) && (data["totp"] === void 0 || isTOTPConfig(data["totp"]));
|
|
10286
10288
|
}
|
|
10287
10289
|
function IsAChargeTransparencyLiveLink(data) {
|
|
10288
|
-
|
|
10289
|
-
return false;
|
|
10290
|
-
return data["@context"] === ChargeTransparencyLiveLinkContext && (data["created"] === void 0 || data["created"] === null || typeof data["created"] === "string") && (data["description"] === void 0 || isI18NString(data["description"])) && (data["imageURLs"] === void 0 || Array.isArray(data["imageURLs"]) && data["imageURLs"].every((value) => typeof value === "string")) && (data["geoLocation"] === void 0 || isGeoLocation(data["geoLocation"])) && (data["connector"] === void 0 || isConnector(data["connector"])) && (data["liveTransports"] === void 0 || Array.isArray(data["liveTransports"]) && data["liveTransports"].every(isTransport)) && (data["signatures"] === void 0 || Array.isArray(data["signatures"]));
|
|
10290
|
+
return isMandatoryJSONObject(data) && data["@context"] === ChargeTransparencyLiveLinkContext;
|
|
10291
10291
|
}
|
|
10292
10292
|
function isTOTPConfig(data) {
|
|
10293
10293
|
return isObject(data) && typeof data["initialSharedSecret"] === "string" && typeof data["timeStep"] === "number";
|
|
@@ -10528,6 +10528,259 @@ var validationRules_default = {
|
|
|
10528
10528
|
}
|
|
10529
10529
|
}
|
|
10530
10530
|
};
|
|
10531
|
+
var defaultKeyIdGeneration = ["SubjectPublicKeyInfo", "DER", "SHA-256", "hex"];
|
|
10532
|
+
var defaultExcludedProperties = ["signatures"];
|
|
10533
|
+
var canonicalJSONEncodings = ["JSON", "JCS", "UTF-8"];
|
|
10534
|
+
var subjectPublicKeyInfoHeaders = {
|
|
10535
|
+
"EdDSA-Ed25519": "302A300506032B6570032100",
|
|
10536
|
+
"EdDSA-Ed448": "3043300506032B6571033A00",
|
|
10537
|
+
"ECDSA-secp256r1": "3059301306072A8648CE3D020106082A8648CE3D030107034200",
|
|
10538
|
+
"ECDSA-secp384r1": "3076301006072A8648CE3D020106052B81040022036200",
|
|
10539
|
+
"ECDSA-secp521r1": "30819B301006072A8648CE3D020106052B8104002303818600"
|
|
10540
|
+
};
|
|
10541
|
+
function readDERLength2(bytes, offset) {
|
|
10542
|
+
const first = bytes[offset];
|
|
10543
|
+
if (first === void 0)
|
|
10544
|
+
throw new Error("Truncated ASN.1 length!");
|
|
10545
|
+
if (first < 128)
|
|
10546
|
+
return { length: first, size: 1 };
|
|
10547
|
+
const count = first & 127;
|
|
10548
|
+
if (count === 0 || count > 4)
|
|
10549
|
+
throw new Error("Unsupported ASN.1 length!");
|
|
10550
|
+
let length = 0;
|
|
10551
|
+
for (let index = 1; index <= count; index++) {
|
|
10552
|
+
const byte = bytes[offset + index];
|
|
10553
|
+
if (byte === void 0)
|
|
10554
|
+
throw new Error("Truncated ASN.1 length!");
|
|
10555
|
+
length = length * 256 + byte;
|
|
10556
|
+
}
|
|
10557
|
+
return { length, size: count + 1 };
|
|
10558
|
+
}
|
|
10559
|
+
function subjectPublicKeyInfoKeyMaterial(spki) {
|
|
10560
|
+
if (spki[0] !== 48)
|
|
10561
|
+
throw new Error("A SubjectPublicKeyInfo must start with a SEQUENCE!");
|
|
10562
|
+
let index = 1 + readDERLength2(spki, 1).size;
|
|
10563
|
+
if (spki[index] !== 48)
|
|
10564
|
+
throw new Error("The SubjectPublicKeyInfo does not start with an AlgorithmIdentifier!");
|
|
10565
|
+
const algorithmLength = readDERLength2(spki, index + 1);
|
|
10566
|
+
index += 1 + algorithmLength.size + algorithmLength.length;
|
|
10567
|
+
if (spki[index] !== 3)
|
|
10568
|
+
throw new Error("The SubjectPublicKeyInfo does not contain a BIT STRING!");
|
|
10569
|
+
const keyLength = readDERLength2(spki, index + 1);
|
|
10570
|
+
const start = index + 1 + keyLength.size;
|
|
10571
|
+
if (spki[start] !== 0)
|
|
10572
|
+
throw new Error("The SubjectPublicKeyInfo BIT STRING has unused bits!");
|
|
10573
|
+
const keyMaterial = spki.subarray(start + 1, start + keyLength.length);
|
|
10574
|
+
if (keyMaterial.length === 0)
|
|
10575
|
+
throw new Error("The SubjectPublicKeyInfo contains no key material!");
|
|
10576
|
+
return keyMaterial;
|
|
10577
|
+
}
|
|
10578
|
+
function wrapInSubjectPublicKeyInfo(keyMaterial, algorithm) {
|
|
10579
|
+
const header = subjectPublicKeyInfoHeaders[algorithm];
|
|
10580
|
+
if (header === void 0)
|
|
10581
|
+
throw new Error("Cannot wrap a raw " + algorithm + " key into a SubjectPublicKeyInfo!");
|
|
10582
|
+
const headerBytes = hexToBytes(header);
|
|
10583
|
+
const spki = new Uint8Array(headerBytes.length + keyMaterial.length);
|
|
10584
|
+
spki.set(headerBytes, 0);
|
|
10585
|
+
spki.set(keyMaterial, headerBytes.length);
|
|
10586
|
+
return spki;
|
|
10587
|
+
}
|
|
10588
|
+
function decodeText(value, encoding) {
|
|
10589
|
+
switch (encoding) {
|
|
10590
|
+
case "hex":
|
|
10591
|
+
return hexToBytes(value);
|
|
10592
|
+
case "base64":
|
|
10593
|
+
return base64ToBytes(value);
|
|
10594
|
+
default:
|
|
10595
|
+
throw new Error("Unsupported text encoding: " + String(encoding));
|
|
10596
|
+
}
|
|
10597
|
+
}
|
|
10598
|
+
function encodeText(bytes, encoding) {
|
|
10599
|
+
switch (encoding) {
|
|
10600
|
+
case "hex":
|
|
10601
|
+
return bytesToHex(bytes).toUpperCase();
|
|
10602
|
+
case "base64":
|
|
10603
|
+
return bytesToBase64(bytes);
|
|
10604
|
+
default:
|
|
10605
|
+
return null;
|
|
10606
|
+
}
|
|
10607
|
+
}
|
|
10608
|
+
function publicKeyBytes(publicKey, structure) {
|
|
10609
|
+
const storedStructure = publicKey.encodings[0];
|
|
10610
|
+
const storedBytes = decodeText(publicKey.value, publicKey.encodings[publicKey.encodings.length - 1]);
|
|
10611
|
+
if (storedStructure === structure)
|
|
10612
|
+
return storedBytes;
|
|
10613
|
+
if (storedStructure === "SubjectPublicKeyInfo" && structure === "raw")
|
|
10614
|
+
return subjectPublicKeyInfoKeyMaterial(storedBytes);
|
|
10615
|
+
if (storedStructure === "raw" && structure === "SubjectPublicKeyInfo")
|
|
10616
|
+
return wrapInSubjectPublicKeyInfo(storedBytes, publicKey.algorithm);
|
|
10617
|
+
throw new Error("Cannot represent a " + String(storedStructure) + " key as " + structure + "!");
|
|
10618
|
+
}
|
|
10619
|
+
function computeKeyId(publicKey, keyIdGeneration) {
|
|
10620
|
+
let index = 0;
|
|
10621
|
+
const structure = keyIdGeneration[index++];
|
|
10622
|
+
if (structure === void 0)
|
|
10623
|
+
return null;
|
|
10624
|
+
if (structure === "SubjectPublicKeyInfo" && keyIdGeneration[index] === "DER")
|
|
10625
|
+
index++;
|
|
10626
|
+
let bytes;
|
|
10627
|
+
try {
|
|
10628
|
+
bytes = publicKeyBytes(publicKey, structure);
|
|
10629
|
+
} catch {
|
|
10630
|
+
return null;
|
|
10631
|
+
}
|
|
10632
|
+
for (; index < keyIdGeneration.length; index++) {
|
|
10633
|
+
const step = keyIdGeneration[index];
|
|
10634
|
+
if (step === void 0)
|
|
10635
|
+
return null;
|
|
10636
|
+
switch (step) {
|
|
10637
|
+
case "SHA-256":
|
|
10638
|
+
bytes = sha256$1(bytes);
|
|
10639
|
+
break;
|
|
10640
|
+
case "SHA-384":
|
|
10641
|
+
bytes = sha384$1(bytes);
|
|
10642
|
+
break;
|
|
10643
|
+
case "SHA-512":
|
|
10644
|
+
bytes = sha512$1(bytes);
|
|
10645
|
+
break;
|
|
10646
|
+
// A pipeline ends with the text encoding of the id.
|
|
10647
|
+
default:
|
|
10648
|
+
return encodeText(bytes, step);
|
|
10649
|
+
}
|
|
10650
|
+
}
|
|
10651
|
+
return null;
|
|
10652
|
+
}
|
|
10653
|
+
function nobleSignatureAlgorithm(algorithm) {
|
|
10654
|
+
switch (algorithm) {
|
|
10655
|
+
case "ECDSA-secp256r1-SHA256":
|
|
10656
|
+
return "ECDSA-P256";
|
|
10657
|
+
case "ECDSA-secp384r1-SHA384":
|
|
10658
|
+
return "ECDSA-P384";
|
|
10659
|
+
case "ECDSA-secp521r1-SHA512":
|
|
10660
|
+
return "ECDSA-P521";
|
|
10661
|
+
case "EdDSA-Ed25519":
|
|
10662
|
+
return "Ed25519";
|
|
10663
|
+
case "EdDSA-Ed448":
|
|
10664
|
+
return "Ed448";
|
|
10665
|
+
case "ML-DSA-44":
|
|
10666
|
+
return "ML-DSA-44";
|
|
10667
|
+
case "ML-DSA-65":
|
|
10668
|
+
return "ML-DSA-65";
|
|
10669
|
+
case "ML-DSA-87":
|
|
10670
|
+
return "ML-DSA-87";
|
|
10671
|
+
default:
|
|
10672
|
+
return null;
|
|
10673
|
+
}
|
|
10674
|
+
}
|
|
10675
|
+
function asStringArray(value) {
|
|
10676
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : void 0;
|
|
10677
|
+
}
|
|
10678
|
+
function collectDocumentPublicKeys(Document) {
|
|
10679
|
+
const publicKeys = new Array();
|
|
10680
|
+
const collectFrom = (candidates) => {
|
|
10681
|
+
if (!Array.isArray(candidates))
|
|
10682
|
+
return;
|
|
10683
|
+
for (const candidate of candidates) {
|
|
10684
|
+
const entry = asJSONObject(candidate);
|
|
10685
|
+
if (entry === void 0)
|
|
10686
|
+
continue;
|
|
10687
|
+
const algorithm = asString(entry["algorithm"]);
|
|
10688
|
+
const value = asString(entry["value"]);
|
|
10689
|
+
const encodings = asStringArray(entry["encodings"]);
|
|
10690
|
+
const keyUsage = asStringArray(entry["keyUsage"]) ?? [];
|
|
10691
|
+
if (algorithm === void 0 || algorithm === "" || value === void 0 || value === "" || encodings === void 0 || encodings.length === 0) {
|
|
10692
|
+
continue;
|
|
10693
|
+
}
|
|
10694
|
+
publicKeys.push({ algorithm, encodings, value, keyUsage });
|
|
10695
|
+
}
|
|
10696
|
+
};
|
|
10697
|
+
const chargingStation = asJSONObject(Document["chargingStation"]);
|
|
10698
|
+
const evse = asJSONObject(chargingStation?.["EVSE"]);
|
|
10699
|
+
collectFrom(asJSONObject(Document["chargingStationOperator"])?.["publicKeys"]);
|
|
10700
|
+
collectFrom(asJSONObject(evse?.["energyMeter"])?.["publicKeys"]);
|
|
10701
|
+
return publicKeys;
|
|
10702
|
+
}
|
|
10703
|
+
function verifyDocumentSignature(Document, Signature, Index, PublicKeys, KeyIdGeneration) {
|
|
10704
|
+
const entry = asJSONObject(Signature);
|
|
10705
|
+
if (entry === void 0)
|
|
10706
|
+
return { index: Index, status: "malformed", details: "The signature is not a JSON object." };
|
|
10707
|
+
const keyId = asString(entry["keyId"]);
|
|
10708
|
+
const algorithm = asString(entry["algorithm"]);
|
|
10709
|
+
const value = asString(entry["value"]);
|
|
10710
|
+
const encodings = asStringArray(entry["encodings"]);
|
|
10711
|
+
const signedData = asJSONObject(entry["signedData"]);
|
|
10712
|
+
const described = (status, details) => ({
|
|
10713
|
+
index: Index,
|
|
10714
|
+
...keyId !== void 0 ? { keyId } : {},
|
|
10715
|
+
...algorithm !== void 0 ? { algorithm } : {},
|
|
10716
|
+
status,
|
|
10717
|
+
...details !== void 0 ? { details } : {}
|
|
10718
|
+
});
|
|
10719
|
+
if (keyId === void 0 || keyId === "" || algorithm === void 0 || algorithm === "" || value === void 0 || value === "" || encodings === void 0 || encodings.length === 0) {
|
|
10720
|
+
return described("malformed", "A signature needs a keyId, an algorithm, encodings and a value.");
|
|
10721
|
+
}
|
|
10722
|
+
const signedEncodings = asStringArray(signedData?.["encodings"]) ?? canonicalJSONEncodings;
|
|
10723
|
+
if (signedEncodings.length !== canonicalJSONEncodings.length || !signedEncodings.every((step, position) => step === canonicalJSONEncodings[position])) {
|
|
10724
|
+
return described(
|
|
10725
|
+
"unsupportedAlgorithm",
|
|
10726
|
+
"Only [ " + canonicalJSONEncodings.join(", ") + " ] signed data is understood here."
|
|
10727
|
+
);
|
|
10728
|
+
}
|
|
10729
|
+
const excludedProperties = asStringArray(signedData?.["excludedProperties"]) ?? defaultExcludedProperties;
|
|
10730
|
+
if (!excludedProperties.includes("signatures"))
|
|
10731
|
+
excludedProperties.push("signatures");
|
|
10732
|
+
let signedBytes;
|
|
10733
|
+
try {
|
|
10734
|
+
signedBytes = canonicalJSONBytes(
|
|
10735
|
+
Object.fromEntries(
|
|
10736
|
+
Object.entries(Document).filter(([property]) => !excludedProperties.includes(property))
|
|
10737
|
+
)
|
|
10738
|
+
);
|
|
10739
|
+
} catch (exception) {
|
|
10740
|
+
return described(
|
|
10741
|
+
"malformed",
|
|
10742
|
+
"The signed properties could not be canonicalized: " + (exception instanceof Error ? exception.message : String(exception))
|
|
10743
|
+
);
|
|
10744
|
+
}
|
|
10745
|
+
const suiteAlgorithm = nobleSignatureAlgorithm(algorithm);
|
|
10746
|
+
if (suiteAlgorithm === null)
|
|
10747
|
+
return described("unsupportedAlgorithm", "Unsupported signature algorithm: " + algorithm);
|
|
10748
|
+
const wantedKeyId = keyId.toUpperCase();
|
|
10749
|
+
const publicKey = PublicKeys.find((candidate) => computeKeyId(candidate, KeyIdGeneration)?.toUpperCase() === wantedKeyId);
|
|
10750
|
+
if (publicKey === void 0)
|
|
10751
|
+
return described("unknownPublicKey", "No public key of this document has the key id " + keyId + ".");
|
|
10752
|
+
try {
|
|
10753
|
+
const suite = getSignatureSuite(suiteAlgorithm);
|
|
10754
|
+
const publicKeyBytes_ = publicKeyBytes(publicKey, "raw");
|
|
10755
|
+
const signatureBytes = decodeText(value, encodings[encodings.length - 1]);
|
|
10756
|
+
if (!suite.isValidPublicKey(publicKeyBytes_))
|
|
10757
|
+
return described("malformed", "The public key is not valid for " + algorithm + ".");
|
|
10758
|
+
return described(suite.verify(signedBytes, signatureBytes, publicKeyBytes_) ? "validSignature" : "invalidSignature");
|
|
10759
|
+
} catch (exception) {
|
|
10760
|
+
return described(
|
|
10761
|
+
"malformed",
|
|
10762
|
+
exception instanceof Error ? exception.message : String(exception)
|
|
10763
|
+
);
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10766
|
+
function verifyDocumentSignatures(Document) {
|
|
10767
|
+
const signatures = Document["signatures"];
|
|
10768
|
+
if (!Array.isArray(signatures) || signatures.length === 0)
|
|
10769
|
+
return { status: "unsigned", signatures: [], validCount: 0 };
|
|
10770
|
+
const keyIdGeneration = asStringArray(Document["keyIdGeneration"]) ?? defaultKeyIdGeneration;
|
|
10771
|
+
const publicKeys = collectDocumentPublicKeys(Document);
|
|
10772
|
+
const results = signatures.map(
|
|
10773
|
+
(signature, index) => verifyDocumentSignature(Document, signature, index, publicKeys, keyIdGeneration)
|
|
10774
|
+
);
|
|
10775
|
+
const validCount = results.filter((result) => result.status === "validSignature").length;
|
|
10776
|
+
return {
|
|
10777
|
+
status: validCount === 0 ? "noneValid" : validCount === results.length ? "allValid" : "someValid",
|
|
10778
|
+
signatures: results,
|
|
10779
|
+
validCount
|
|
10780
|
+
};
|
|
10781
|
+
}
|
|
10782
|
+
|
|
10783
|
+
// src/chargy.ts
|
|
10531
10784
|
function isPdfAttachment(value) {
|
|
10532
10785
|
if (!isMandatoryJSONObject(value))
|
|
10533
10786
|
return false;
|
|
@@ -11464,6 +11717,7 @@ var Chargy = class {
|
|
|
11464
11717
|
throw new Error("Parsed JSON content is not a JSON object!");
|
|
11465
11718
|
const JSONContext = JSONContent["@context"];
|
|
11466
11719
|
if (IsAChargeTransparencyLiveLink(JSONContent)) {
|
|
11720
|
+
this.verifyLiveLinkSignatures(JSONContent);
|
|
11467
11721
|
JSONContent.created ??= (/* @__PURE__ */ new Date()).toISOString();
|
|
11468
11722
|
processedFile.result = JSONContent;
|
|
11469
11723
|
} else if (JSONContent["format"] === "ptb")
|
|
@@ -11633,6 +11887,56 @@ var Chargy = class {
|
|
|
11633
11887
|
return IsAChargeTransparencyRecord(verifiedCTR) ? verifiedCTR : void 0;
|
|
11634
11888
|
}
|
|
11635
11889
|
//#endregion
|
|
11890
|
+
//#region (private) verifyLiveLinkSignatures(LiveLink)
|
|
11891
|
+
// A live link may be signed as a whole by the operator, which is what ties
|
|
11892
|
+
// the transport URLs and the listed public keys to whoever signed them.
|
|
11893
|
+
// Those signatures are verified whenever the document carries any.
|
|
11894
|
+
//
|
|
11895
|
+
// Nothing here rejects a document. An unsigned live link, an unknown key or
|
|
11896
|
+
// even a signature that does not match is reported as a warning and the
|
|
11897
|
+
// document stays usable: its transports still work, and its signed meter
|
|
11898
|
+
// values carry their own signatures, which are verified separately. What a
|
|
11899
|
+
// reader makes of the warning is the reader's decision.
|
|
11900
|
+
//
|
|
11901
|
+
// Must run before anything is added to the document - see the note at the
|
|
11902
|
+
// call site.
|
|
11903
|
+
verifyLiveLinkSignatures(LiveLink) {
|
|
11904
|
+
const result = verifyDocumentSignatures(LiveLink);
|
|
11905
|
+
const warnings = new Array();
|
|
11906
|
+
const warn = (messageKey, level) => {
|
|
11907
|
+
const message = this.GetMultilanguageText(messageKey);
|
|
11908
|
+
if (!warnings.some((warning) => warning.message === message))
|
|
11909
|
+
warnings.push({ level, message });
|
|
11910
|
+
};
|
|
11911
|
+
if (result.status === "unsigned")
|
|
11912
|
+
warn("DocumentSignature_Missing", "low" /* low */);
|
|
11913
|
+
for (const signature of result.signatures) {
|
|
11914
|
+
switch (signature.status) {
|
|
11915
|
+
case "validSignature":
|
|
11916
|
+
break;
|
|
11917
|
+
// A signature that demonstrably does not match its document is
|
|
11918
|
+
// the one case that says something is actually wrong.
|
|
11919
|
+
case "invalidSignature":
|
|
11920
|
+
warn("DocumentSignature_Mismatch", "high" /* high */);
|
|
11921
|
+
break;
|
|
11922
|
+
// The rest mean "cannot be judged here", which is a weaker
|
|
11923
|
+
// statement than "is wrong".
|
|
11924
|
+
case "unknownPublicKey":
|
|
11925
|
+
warn("DocumentSignature_UnknownPublicKey", "medium" /* medium */);
|
|
11926
|
+
break;
|
|
11927
|
+
case "unsupportedAlgorithm":
|
|
11928
|
+
warn("DocumentSignature_UnsupportedAlgorithm", "medium" /* medium */);
|
|
11929
|
+
break;
|
|
11930
|
+
case "malformed":
|
|
11931
|
+
warn("DocumentSignature_Malformed", "medium" /* medium */);
|
|
11932
|
+
break;
|
|
11933
|
+
}
|
|
11934
|
+
}
|
|
11935
|
+
LiveLink.signatureVerification = result;
|
|
11936
|
+
if (warnings.length > 0)
|
|
11937
|
+
LiveLink.warnings = [...LiveLink.warnings ?? [], ...warnings];
|
|
11938
|
+
}
|
|
11939
|
+
//#endregion
|
|
11636
11940
|
//#region (private) collectLiveLinkMeterValueKeys(LiveLink)
|
|
11637
11941
|
// Every public key of the document that is allowed to sign meter values.
|
|
11638
11942
|
// A charging session is regularly signed by more than one of them: the
|
|
@@ -11999,6 +12303,6 @@ var Chargy = class {
|
|
|
11999
12303
|
}
|
|
12000
12304
|
};
|
|
12001
12305
|
|
|
12002
|
-
export { ACrypt, Alfen, AlfenCrypt01, BSMCrypt01, CanonicalJSONError, ChargeIT, ChargePoint, ChargePointCrypt01, IChargeTransparencyLiveLink_exports as ChargeTransparencyLiveLink, ChargeTransparencyLiveLinkContext, IChargeTransparencyRecord_exports as ChargeTransparencyRecord, Chargy, chargyInterfaces_exports as ChargyInterfaces, Clone, CloneCTR, ConcatenateBuffers, CreateDiv, CreateDiv2, CreateError, CreateWarning, CryptoAlgorithms, CryptoHashAlgorithms, DayOfWeek, DisplayPrefixes, EDL40, EDL40Crypt01, EDL40ValidationError, EDL40_OBIS, EDL40_SESSION_CONTEXT, EDL40_SIGNATURE_CONTEXT, EMHCrypt01, ErrorLevel, GDFCrypt01, IECCurves, IEncoding, InformationRelevance, InformationRelevanceToString, IsAChargeTransparencyLiveLink, IsAChargeTransparencyRecord, IsAPublicKey, IsAPublicKeyLookup, IsAPublicKeySignature, IsAPublicKeyXY, IsASessionCryptoResult, IsAURL, IsNullOrEmpty, IsValidURL, JSONSignatureVerificationStatus, MENNEKES_EDL40_OBIS, MENNEKES_EDL40_XMLNS, Mennekes, MennekesCrypt01, OBIS2Hex, OBIS2MeasurementName, OBIS_RegExpr, OCMF, OCMFBonnTariffParseError, OCMFTransactionTypes, OCMF_SIGNATURE_ALGORITHMS, OCMFv1_x, OCPI, OIDInfo, PCDF, PCDFCrypt01, PCDFParseError, PCDFValidationError, PCDF_FIELD_ORDER, PCDF_PREFIX, PTB, ParseJSON_LD, PublicKeyFormats, IPublicKeyInfo_exports as PublicKeyInfo, SAFEXML, SessionVerificationResult, SetHex, SetInt8, SetText, SetText_withLength, SetTimestamp, SetTimestamp32, SetUInt32, SetUInt32_withCode, SetUInt64, SetUInt64D, SignMessage, SignatureFormats, IURL_exports as SimpleURL, TimeStatusTypes, URLContext, UTC2human, VerificationResult, VerifyJSONMessageSignatures, WarningLevel, WhenNullOrEmpty, XMLContainer, asJSONArray, asJSONObject, asNumber, asString, base64ToBytes, buf2hex, buildEDL40Signature, buildIsaSignature, buildMennekesSignatureData, bytesToBase64, bytesToHex, canParseEDL40, canonicalJSONBytes, canonicalJSONStringify, cleanHex, closeFullscreen, createCompatibleCurve, createHexString, createLegacyP192Curve, dateToMennekesLocalEpochSeconds, decodeSmlMessages, extractMennekesChargingProcesses, findEntryByObis, findGetListRes, firstKey, firstValue, generateSignatureKeyPair, getArrayElement, getArrayLikeElement, getDirectChildByLocalName, getDirectChildrenByLocalName, getElementsByLocalName, getFirstArrayElement, getInt16Bytes, getInt32Bytes, getInt64Bytes, getInt8Bytes, getLastArrayElement, getOCMFSignatureDisplay, getSignatureSuite, getTrimmedTextContent, hashFile, hex2bin, hex32, hexToArrayBuffer, hexToBytes, intFromBytes, isEncodedValue, isGeoLocation, isI18NString, isICryptoResult, isIFileInfo, isISessionCryptoResult1, isISessionCryptoResult2, isJSONLDObject, isMandatoryArrayOfStrings, isMandatoryBoolean, isMandatoryDecimal, isMandatoryJSONArray, isMandatoryJSONObject, isMandatoryNumber, isMandatoryString, isMandatoryURL, isOIDInfo, isObject, isOptionalArrayOfStrings, isOptionalDecimal, isOptionalJSONArray, isOptionalJSONArrayError, isOptionalJSONArrayOk, isOptionalJSONObject, isOptionalNumber, isOptionalString, isOptionalStringArray, isOptionalStringOrOIDInfo, isOptionalURL, isPCDFText, isPublicKeySubject, isString, isStringArray, isStringOrOIDInfo, isStringOrStringArray, isaListNameContext, jsonPrettyPrinter, measurementName2human, meterTimeZone, normalizePCDFPublicKeyHex, normalizeXMLText, ocmfBonnTariffToChargingTariff, openFullscreen, pad, parseAndVerifyJSONSignatures, parseDescription, parseEDL40, parseHexString, parseMennekesXMLDocument, parseNumber, parseOBIS, parseOCMFBonnTariffText, parsePCDFDocument, parsePCDFPublicKey, parsePCDFSignature, parseSmlTime, parseUTC, readQRCodeTextFromImage, readQRCodeTextFromImageData, readTLV, secp224k1, setUILocale, sha256, sha256____, sha384, sha384____, sha512, sha512____, signJSONMessage, signMessage, stripPCDFControlCharacters, stripTransport, time2human, timeZoneOffsetMinutes, toArrayBuffer, toSessionVerificationResults, toUint8Array, transformEDL40Status, tryParseOCMFBonnTariffText, unquotePCDFText, validatePCDFFields, verifyEDL40Document, verifyJSONMessageSignatureResults, verifyJSONMessageSignatures, verifyJSONSignature, verifyJSONSignatureResult, verifyPCDFDocument };
|
|
12306
|
+
export { ACrypt, Alfen, AlfenCrypt01, BSMCrypt01, CanonicalJSONError, ChargeIT, ChargePoint, ChargePointCrypt01, IChargeTransparencyLiveLink_exports as ChargeTransparencyLiveLink, ChargeTransparencyLiveLinkContext, IChargeTransparencyRecord_exports as ChargeTransparencyRecord, Chargy, chargyInterfaces_exports as ChargyInterfaces, Clone, CloneCTR, ConcatenateBuffers, CreateDiv, CreateDiv2, CreateError, CreateWarning, CryptoAlgorithms, CryptoHashAlgorithms, DayOfWeek, DisplayPrefixes, EDL40, EDL40Crypt01, EDL40ValidationError, EDL40_OBIS, EDL40_SESSION_CONTEXT, EDL40_SIGNATURE_CONTEXT, EMHCrypt01, ErrorLevel, GDFCrypt01, IECCurves, IEncoding, InformationRelevance, InformationRelevanceToString, IsAChargeTransparencyLiveLink, IsAChargeTransparencyRecord, IsAPublicKey, IsAPublicKeyLookup, IsAPublicKeySignature, IsAPublicKeyXY, IsASessionCryptoResult, IsAURL, IsNullOrEmpty, IsValidURL, JSONSignatureVerificationStatus, MENNEKES_EDL40_OBIS, MENNEKES_EDL40_XMLNS, Mennekes, MennekesCrypt01, OBIS2Hex, OBIS2MeasurementName, OBIS_RegExpr, OCMF, OCMFBonnTariffParseError, OCMFTransactionTypes, OCMF_SIGNATURE_ALGORITHMS, OCMFv1_x, OCPI, OIDInfo, PCDF, PCDFCrypt01, PCDFParseError, PCDFValidationError, PCDF_FIELD_ORDER, PCDF_PREFIX, PTB, ParseJSON_LD, PublicKeyFormats, IPublicKeyInfo_exports as PublicKeyInfo, SAFEXML, SessionVerificationResult, SetHex, SetInt8, SetText, SetText_withLength, SetTimestamp, SetTimestamp32, SetUInt32, SetUInt32_withCode, SetUInt64, SetUInt64D, SignMessage, SignatureFormats, IURL_exports as SimpleURL, TimeStatusTypes, URLContext, UTC2human, VerificationResult, VerifyJSONMessageSignatures, WarningLevel, WhenNullOrEmpty, XMLContainer, asJSONArray, asJSONObject, asNumber, asString, base64ToBytes, buf2hex, buildEDL40Signature, buildIsaSignature, buildMennekesSignatureData, bytesToBase64, bytesToHex, canParseEDL40, canonicalJSONBytes, canonicalJSONStringify, cleanHex, closeFullscreen, collectDocumentPublicKeys, createCompatibleCurve, createHexString, createLegacyP192Curve, dateToMennekesLocalEpochSeconds, decodeSmlMessages, extractMennekesChargingProcesses, findEntryByObis, findGetListRes, firstKey, firstValue, generateSignatureKeyPair, getArrayElement, getArrayLikeElement, getDirectChildByLocalName, getDirectChildrenByLocalName, getElementsByLocalName, getFirstArrayElement, getInt16Bytes, getInt32Bytes, getInt64Bytes, getInt8Bytes, getLastArrayElement, getOCMFSignatureDisplay, getSignatureSuite, getTrimmedTextContent, hashFile, hex2bin, hex32, hexToArrayBuffer, hexToBytes, intFromBytes, isEncodedValue, isGeoLocation, isI18NString, isICryptoResult, isIFileInfo, isISessionCryptoResult1, isISessionCryptoResult2, isJSONLDObject, isMandatoryArrayOfStrings, isMandatoryBoolean, isMandatoryDecimal, isMandatoryJSONArray, isMandatoryJSONObject, isMandatoryNumber, isMandatoryString, isMandatoryURL, isOIDInfo, isObject, isOptionalArrayOfStrings, isOptionalDecimal, isOptionalJSONArray, isOptionalJSONArrayError, isOptionalJSONArrayOk, isOptionalJSONObject, isOptionalNumber, isOptionalString, isOptionalStringArray, isOptionalStringOrOIDInfo, isOptionalURL, isPCDFText, isPublicKeySubject, isString, isStringArray, isStringOrOIDInfo, isStringOrStringArray, isaListNameContext, jsonPrettyPrinter, measurementName2human, meterTimeZone, normalizePCDFPublicKeyHex, normalizeXMLText, ocmfBonnTariffToChargingTariff, openFullscreen, pad, parseAndVerifyJSONSignatures, parseDescription, parseEDL40, parseHexString, parseMennekesXMLDocument, parseNumber, parseOBIS, parseOCMFBonnTariffText, parsePCDFDocument, parsePCDFPublicKey, parsePCDFSignature, parseSmlTime, parseUTC, readQRCodeTextFromImage, readQRCodeTextFromImageData, readTLV, secp224k1, setUILocale, sha256, sha256____, sha384, sha384____, sha512, sha512____, signJSONMessage, signMessage, stripPCDFControlCharacters, stripTransport, time2human, timeZoneOffsetMinutes, toArrayBuffer, toSessionVerificationResults, toUint8Array, transformEDL40Status, tryParseOCMFBonnTariffText, unquotePCDFText, validatePCDFFields, verifyDocumentSignatures, verifyEDL40Document, verifyJSONMessageSignatureResults, verifyJSONMessageSignatures, verifyJSONSignature, verifyJSONSignatureResult, verifyPCDFDocument };
|
|
12003
12307
|
//# sourceMappingURL=index.js.map
|
|
12004
12308
|
//# sourceMappingURL=index.js.map
|