@open-charging-cloud/chargy-core 0.7.0 → 0.8.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/README.md +1 -1
- package/dist/Alfen.d.ts.map +1 -1
- package/dist/EDL40.d.ts +178 -0
- package/dist/EDL40.d.ts.map +1 -0
- package/dist/OCMF.d.ts.map +1 -1
- package/dist/SAFE_XML.d.ts +1 -1
- package/dist/SAFE_XML.d.ts.map +1 -1
- package/dist/browser/index.js +1488 -541
- package/dist/browser/index.js.map +1 -1
- package/dist/chargy.d.ts +4 -3
- 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/IChargeTransparencyRecord.d.ts +2 -0
- package/dist/interfaces/IChargeTransparencyRecord.d.ts.map +1 -1
- package/dist/interfaces/chargyInterfaces.d.ts +2 -0
- package/dist/interfaces/chargyInterfaces.d.ts.map +1 -1
- package/dist/node/index.js +1486 -539
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -150,11 +150,11 @@ var require_bn = __commonJS({
|
|
|
150
150
|
}
|
|
151
151
|
} catch (e) {
|
|
152
152
|
}
|
|
153
|
-
BN.isBN = function isBN(
|
|
154
|
-
if (
|
|
153
|
+
BN.isBN = function isBN(num2) {
|
|
154
|
+
if (num2 instanceof BN) {
|
|
155
155
|
return true;
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return num2 !== null && typeof num2 === "object" && num2.constructor.wordSize === BN.wordSize && Array.isArray(num2.words);
|
|
158
158
|
};
|
|
159
159
|
BN.max = function max(left, right) {
|
|
160
160
|
if (left.cmp(right) > 0) return left;
|
|
@@ -675,12 +675,12 @@ var require_bn = __commonJS({
|
|
|
675
675
|
var hi = this._countBits(w);
|
|
676
676
|
return (this.length - 1) * 26 + hi;
|
|
677
677
|
};
|
|
678
|
-
function toBitArray(
|
|
679
|
-
var w = new Array(
|
|
678
|
+
function toBitArray(num2) {
|
|
679
|
+
var w = new Array(num2.bitLength());
|
|
680
680
|
for (var bit = 0; bit < w.length; bit++) {
|
|
681
681
|
var off = bit / 26 | 0;
|
|
682
682
|
var wbit = bit % 26;
|
|
683
|
-
w[bit] = (
|
|
683
|
+
w[bit] = (num2.words[off] & 1 << wbit) >>> wbit;
|
|
684
684
|
}
|
|
685
685
|
return w;
|
|
686
686
|
}
|
|
@@ -721,60 +721,60 @@ var require_bn = __commonJS({
|
|
|
721
721
|
}
|
|
722
722
|
return this;
|
|
723
723
|
};
|
|
724
|
-
BN.prototype.iuor = function iuor(
|
|
725
|
-
while (this.length <
|
|
724
|
+
BN.prototype.iuor = function iuor(num2) {
|
|
725
|
+
while (this.length < num2.length) {
|
|
726
726
|
this.words[this.length++] = 0;
|
|
727
727
|
}
|
|
728
|
-
for (var i = 0; i <
|
|
729
|
-
this.words[i] = this.words[i] |
|
|
728
|
+
for (var i = 0; i < num2.length; i++) {
|
|
729
|
+
this.words[i] = this.words[i] | num2.words[i];
|
|
730
730
|
}
|
|
731
731
|
return this.strip();
|
|
732
732
|
};
|
|
733
|
-
BN.prototype.ior = function ior(
|
|
734
|
-
assert((this.negative |
|
|
735
|
-
return this.iuor(
|
|
733
|
+
BN.prototype.ior = function ior(num2) {
|
|
734
|
+
assert((this.negative | num2.negative) === 0);
|
|
735
|
+
return this.iuor(num2);
|
|
736
736
|
};
|
|
737
|
-
BN.prototype.or = function or(
|
|
738
|
-
if (this.length >
|
|
739
|
-
return
|
|
737
|
+
BN.prototype.or = function or(num2) {
|
|
738
|
+
if (this.length > num2.length) return this.clone().ior(num2);
|
|
739
|
+
return num2.clone().ior(this);
|
|
740
740
|
};
|
|
741
|
-
BN.prototype.uor = function uor(
|
|
742
|
-
if (this.length >
|
|
743
|
-
return
|
|
741
|
+
BN.prototype.uor = function uor(num2) {
|
|
742
|
+
if (this.length > num2.length) return this.clone().iuor(num2);
|
|
743
|
+
return num2.clone().iuor(this);
|
|
744
744
|
};
|
|
745
|
-
BN.prototype.iuand = function iuand(
|
|
745
|
+
BN.prototype.iuand = function iuand(num2) {
|
|
746
746
|
var b;
|
|
747
|
-
if (this.length >
|
|
748
|
-
b =
|
|
747
|
+
if (this.length > num2.length) {
|
|
748
|
+
b = num2;
|
|
749
749
|
} else {
|
|
750
750
|
b = this;
|
|
751
751
|
}
|
|
752
752
|
for (var i = 0; i < b.length; i++) {
|
|
753
|
-
this.words[i] = this.words[i] &
|
|
753
|
+
this.words[i] = this.words[i] & num2.words[i];
|
|
754
754
|
}
|
|
755
755
|
this.length = b.length;
|
|
756
756
|
return this.strip();
|
|
757
757
|
};
|
|
758
|
-
BN.prototype.iand = function iand(
|
|
759
|
-
assert((this.negative |
|
|
760
|
-
return this.iuand(
|
|
758
|
+
BN.prototype.iand = function iand(num2) {
|
|
759
|
+
assert((this.negative | num2.negative) === 0);
|
|
760
|
+
return this.iuand(num2);
|
|
761
761
|
};
|
|
762
|
-
BN.prototype.and = function and(
|
|
763
|
-
if (this.length >
|
|
764
|
-
return
|
|
762
|
+
BN.prototype.and = function and(num2) {
|
|
763
|
+
if (this.length > num2.length) return this.clone().iand(num2);
|
|
764
|
+
return num2.clone().iand(this);
|
|
765
765
|
};
|
|
766
|
-
BN.prototype.uand = function uand(
|
|
767
|
-
if (this.length >
|
|
768
|
-
return
|
|
766
|
+
BN.prototype.uand = function uand(num2) {
|
|
767
|
+
if (this.length > num2.length) return this.clone().iuand(num2);
|
|
768
|
+
return num2.clone().iuand(this);
|
|
769
769
|
};
|
|
770
|
-
BN.prototype.iuxor = function iuxor(
|
|
770
|
+
BN.prototype.iuxor = function iuxor(num2) {
|
|
771
771
|
var a;
|
|
772
772
|
var b;
|
|
773
|
-
if (this.length >
|
|
773
|
+
if (this.length > num2.length) {
|
|
774
774
|
a = this;
|
|
775
|
-
b =
|
|
775
|
+
b = num2;
|
|
776
776
|
} else {
|
|
777
|
-
a =
|
|
777
|
+
a = num2;
|
|
778
778
|
b = this;
|
|
779
779
|
}
|
|
780
780
|
for (var i = 0; i < b.length; i++) {
|
|
@@ -788,17 +788,17 @@ var require_bn = __commonJS({
|
|
|
788
788
|
this.length = a.length;
|
|
789
789
|
return this.strip();
|
|
790
790
|
};
|
|
791
|
-
BN.prototype.ixor = function ixor(
|
|
792
|
-
assert((this.negative |
|
|
793
|
-
return this.iuxor(
|
|
791
|
+
BN.prototype.ixor = function ixor(num2) {
|
|
792
|
+
assert((this.negative | num2.negative) === 0);
|
|
793
|
+
return this.iuxor(num2);
|
|
794
794
|
};
|
|
795
|
-
BN.prototype.xor = function xor(
|
|
796
|
-
if (this.length >
|
|
797
|
-
return
|
|
795
|
+
BN.prototype.xor = function xor(num2) {
|
|
796
|
+
if (this.length > num2.length) return this.clone().ixor(num2);
|
|
797
|
+
return num2.clone().ixor(this);
|
|
798
798
|
};
|
|
799
|
-
BN.prototype.uxor = function uxor(
|
|
800
|
-
if (this.length >
|
|
801
|
-
return
|
|
799
|
+
BN.prototype.uxor = function uxor(num2) {
|
|
800
|
+
if (this.length > num2.length) return this.clone().iuxor(num2);
|
|
801
|
+
return num2.clone().iuxor(this);
|
|
802
802
|
};
|
|
803
803
|
BN.prototype.inotn = function inotn(width) {
|
|
804
804
|
assert(typeof width === "number" && width >= 0);
|
|
@@ -831,25 +831,25 @@ var require_bn = __commonJS({
|
|
|
831
831
|
}
|
|
832
832
|
return this.strip();
|
|
833
833
|
};
|
|
834
|
-
BN.prototype.iadd = function iadd(
|
|
834
|
+
BN.prototype.iadd = function iadd(num2) {
|
|
835
835
|
var r;
|
|
836
|
-
if (this.negative !== 0 &&
|
|
836
|
+
if (this.negative !== 0 && num2.negative === 0) {
|
|
837
837
|
this.negative = 0;
|
|
838
|
-
r = this.isub(
|
|
838
|
+
r = this.isub(num2);
|
|
839
839
|
this.negative ^= 1;
|
|
840
840
|
return this._normSign();
|
|
841
|
-
} else if (this.negative === 0 &&
|
|
842
|
-
|
|
843
|
-
r = this.isub(
|
|
844
|
-
|
|
841
|
+
} else if (this.negative === 0 && num2.negative !== 0) {
|
|
842
|
+
num2.negative = 0;
|
|
843
|
+
r = this.isub(num2);
|
|
844
|
+
num2.negative = 1;
|
|
845
845
|
return r._normSign();
|
|
846
846
|
}
|
|
847
847
|
var a, b;
|
|
848
|
-
if (this.length >
|
|
848
|
+
if (this.length > num2.length) {
|
|
849
849
|
a = this;
|
|
850
|
-
b =
|
|
850
|
+
b = num2;
|
|
851
851
|
} else {
|
|
852
|
-
a =
|
|
852
|
+
a = num2;
|
|
853
853
|
b = this;
|
|
854
854
|
}
|
|
855
855
|
var carry = 0;
|
|
@@ -874,35 +874,35 @@ var require_bn = __commonJS({
|
|
|
874
874
|
}
|
|
875
875
|
return this;
|
|
876
876
|
};
|
|
877
|
-
BN.prototype.add = function add(
|
|
877
|
+
BN.prototype.add = function add(num2) {
|
|
878
878
|
var res;
|
|
879
|
-
if (
|
|
880
|
-
|
|
881
|
-
res = this.sub(
|
|
882
|
-
|
|
879
|
+
if (num2.negative !== 0 && this.negative === 0) {
|
|
880
|
+
num2.negative = 0;
|
|
881
|
+
res = this.sub(num2);
|
|
882
|
+
num2.negative ^= 1;
|
|
883
883
|
return res;
|
|
884
|
-
} else if (
|
|
884
|
+
} else if (num2.negative === 0 && this.negative !== 0) {
|
|
885
885
|
this.negative = 0;
|
|
886
|
-
res =
|
|
886
|
+
res = num2.sub(this);
|
|
887
887
|
this.negative = 1;
|
|
888
888
|
return res;
|
|
889
889
|
}
|
|
890
|
-
if (this.length >
|
|
891
|
-
return
|
|
890
|
+
if (this.length > num2.length) return this.clone().iadd(num2);
|
|
891
|
+
return num2.clone().iadd(this);
|
|
892
892
|
};
|
|
893
|
-
BN.prototype.isub = function isub(
|
|
894
|
-
if (
|
|
895
|
-
|
|
896
|
-
var r = this.iadd(
|
|
897
|
-
|
|
893
|
+
BN.prototype.isub = function isub(num2) {
|
|
894
|
+
if (num2.negative !== 0) {
|
|
895
|
+
num2.negative = 0;
|
|
896
|
+
var r = this.iadd(num2);
|
|
897
|
+
num2.negative = 1;
|
|
898
898
|
return r._normSign();
|
|
899
899
|
} else if (this.negative !== 0) {
|
|
900
900
|
this.negative = 0;
|
|
901
|
-
this.iadd(
|
|
901
|
+
this.iadd(num2);
|
|
902
902
|
this.negative = 1;
|
|
903
903
|
return this._normSign();
|
|
904
904
|
}
|
|
905
|
-
var cmp = this.cmp(
|
|
905
|
+
var cmp = this.cmp(num2);
|
|
906
906
|
if (cmp === 0) {
|
|
907
907
|
this.negative = 0;
|
|
908
908
|
this.length = 1;
|
|
@@ -912,9 +912,9 @@ var require_bn = __commonJS({
|
|
|
912
912
|
var a, b;
|
|
913
913
|
if (cmp > 0) {
|
|
914
914
|
a = this;
|
|
915
|
-
b =
|
|
915
|
+
b = num2;
|
|
916
916
|
} else {
|
|
917
|
-
a =
|
|
917
|
+
a = num2;
|
|
918
918
|
b = this;
|
|
919
919
|
}
|
|
920
920
|
var carry = 0;
|
|
@@ -939,16 +939,16 @@ var require_bn = __commonJS({
|
|
|
939
939
|
}
|
|
940
940
|
return this.strip();
|
|
941
941
|
};
|
|
942
|
-
BN.prototype.sub = function sub(
|
|
943
|
-
return this.clone().isub(
|
|
942
|
+
BN.prototype.sub = function sub(num2) {
|
|
943
|
+
return this.clone().isub(num2);
|
|
944
944
|
};
|
|
945
|
-
function smallMulTo(self2,
|
|
946
|
-
out.negative =
|
|
947
|
-
var len = self2.length +
|
|
945
|
+
function smallMulTo(self2, num2, out) {
|
|
946
|
+
out.negative = num2.negative ^ self2.negative;
|
|
947
|
+
var len = self2.length + num2.length | 0;
|
|
948
948
|
out.length = len;
|
|
949
949
|
len = len - 1 | 0;
|
|
950
950
|
var a = self2.words[0] | 0;
|
|
951
|
-
var b =
|
|
951
|
+
var b = num2.words[0] | 0;
|
|
952
952
|
var r = a * b;
|
|
953
953
|
var lo = r & 67108863;
|
|
954
954
|
var carry = r / 67108864 | 0;
|
|
@@ -956,11 +956,11 @@ var require_bn = __commonJS({
|
|
|
956
956
|
for (var k = 1; k < len; k++) {
|
|
957
957
|
var ncarry = carry >>> 26;
|
|
958
958
|
var rword = carry & 67108863;
|
|
959
|
-
var maxJ = Math.min(k,
|
|
959
|
+
var maxJ = Math.min(k, num2.length - 1);
|
|
960
960
|
for (var j = Math.max(0, k - self2.length + 1); j <= maxJ; j++) {
|
|
961
961
|
var i = k - j | 0;
|
|
962
962
|
a = self2.words[i] | 0;
|
|
963
|
-
b =
|
|
963
|
+
b = num2.words[j] | 0;
|
|
964
964
|
r = a * b + rword;
|
|
965
965
|
ncarry += r / 67108864 | 0;
|
|
966
966
|
rword = r & 67108863;
|
|
@@ -975,9 +975,9 @@ var require_bn = __commonJS({
|
|
|
975
975
|
}
|
|
976
976
|
return out.strip();
|
|
977
977
|
}
|
|
978
|
-
var comb10MulTo = function comb10MulTo2(self2,
|
|
978
|
+
var comb10MulTo = function comb10MulTo2(self2, num2, out) {
|
|
979
979
|
var a = self2.words;
|
|
980
|
-
var b =
|
|
980
|
+
var b = num2.words;
|
|
981
981
|
var o = out.words;
|
|
982
982
|
var c = 0;
|
|
983
983
|
var lo;
|
|
@@ -1043,7 +1043,7 @@ var require_bn = __commonJS({
|
|
|
1043
1043
|
var b9 = b[9] | 0;
|
|
1044
1044
|
var bl9 = b9 & 8191;
|
|
1045
1045
|
var bh9 = b9 >>> 13;
|
|
1046
|
-
out.negative = self2.negative ^
|
|
1046
|
+
out.negative = self2.negative ^ num2.negative;
|
|
1047
1047
|
out.length = 19;
|
|
1048
1048
|
lo = Math.imul(al0, bl0);
|
|
1049
1049
|
mid = Math.imul(al0, bh0);
|
|
@@ -1530,20 +1530,20 @@ var require_bn = __commonJS({
|
|
|
1530
1530
|
if (!Math.imul) {
|
|
1531
1531
|
comb10MulTo = smallMulTo;
|
|
1532
1532
|
}
|
|
1533
|
-
function bigMulTo(self2,
|
|
1534
|
-
out.negative =
|
|
1535
|
-
out.length = self2.length +
|
|
1533
|
+
function bigMulTo(self2, num2, out) {
|
|
1534
|
+
out.negative = num2.negative ^ self2.negative;
|
|
1535
|
+
out.length = self2.length + num2.length;
|
|
1536
1536
|
var carry = 0;
|
|
1537
1537
|
var hncarry = 0;
|
|
1538
1538
|
for (var k = 0; k < out.length - 1; k++) {
|
|
1539
1539
|
var ncarry = hncarry;
|
|
1540
1540
|
hncarry = 0;
|
|
1541
1541
|
var rword = carry & 67108863;
|
|
1542
|
-
var maxJ = Math.min(k,
|
|
1542
|
+
var maxJ = Math.min(k, num2.length - 1);
|
|
1543
1543
|
for (var j = Math.max(0, k - self2.length + 1); j <= maxJ; j++) {
|
|
1544
1544
|
var i = k - j;
|
|
1545
1545
|
var a = self2.words[i] | 0;
|
|
1546
|
-
var b =
|
|
1546
|
+
var b = num2.words[j] | 0;
|
|
1547
1547
|
var r = a * b;
|
|
1548
1548
|
var lo = r & 67108863;
|
|
1549
1549
|
ncarry = ncarry + (r / 67108864 | 0) | 0;
|
|
@@ -1564,21 +1564,21 @@ var require_bn = __commonJS({
|
|
|
1564
1564
|
}
|
|
1565
1565
|
return out.strip();
|
|
1566
1566
|
}
|
|
1567
|
-
function jumboMulTo(self2,
|
|
1567
|
+
function jumboMulTo(self2, num2, out) {
|
|
1568
1568
|
var fftm = new FFTM();
|
|
1569
|
-
return fftm.mulp(self2,
|
|
1569
|
+
return fftm.mulp(self2, num2, out);
|
|
1570
1570
|
}
|
|
1571
|
-
BN.prototype.mulTo = function mulTo(
|
|
1571
|
+
BN.prototype.mulTo = function mulTo(num2, out) {
|
|
1572
1572
|
var res;
|
|
1573
|
-
var len = this.length +
|
|
1574
|
-
if (this.length === 10 &&
|
|
1575
|
-
res = comb10MulTo(this,
|
|
1573
|
+
var len = this.length + num2.length;
|
|
1574
|
+
if (this.length === 10 && num2.length === 10) {
|
|
1575
|
+
res = comb10MulTo(this, num2, out);
|
|
1576
1576
|
} else if (len < 63) {
|
|
1577
|
-
res = smallMulTo(this,
|
|
1577
|
+
res = smallMulTo(this, num2, out);
|
|
1578
1578
|
} else if (len < 1024) {
|
|
1579
|
-
res = bigMulTo(this,
|
|
1579
|
+
res = bigMulTo(this, num2, out);
|
|
1580
1580
|
} else {
|
|
1581
|
-
res = jumboMulTo(this,
|
|
1581
|
+
res = jumboMulTo(this, num2, out);
|
|
1582
1582
|
}
|
|
1583
1583
|
return res;
|
|
1584
1584
|
};
|
|
@@ -1723,25 +1723,25 @@ var require_bn = __commonJS({
|
|
|
1723
1723
|
out.length = x.length + y.length;
|
|
1724
1724
|
return out.strip();
|
|
1725
1725
|
};
|
|
1726
|
-
BN.prototype.mul = function mul(
|
|
1726
|
+
BN.prototype.mul = function mul(num2) {
|
|
1727
1727
|
var out = new BN(null);
|
|
1728
|
-
out.words = new Array(this.length +
|
|
1729
|
-
return this.mulTo(
|
|
1728
|
+
out.words = new Array(this.length + num2.length);
|
|
1729
|
+
return this.mulTo(num2, out);
|
|
1730
1730
|
};
|
|
1731
|
-
BN.prototype.mulf = function mulf(
|
|
1731
|
+
BN.prototype.mulf = function mulf(num2) {
|
|
1732
1732
|
var out = new BN(null);
|
|
1733
|
-
out.words = new Array(this.length +
|
|
1734
|
-
return jumboMulTo(this,
|
|
1733
|
+
out.words = new Array(this.length + num2.length);
|
|
1734
|
+
return jumboMulTo(this, num2, out);
|
|
1735
1735
|
};
|
|
1736
|
-
BN.prototype.imul = function imul(
|
|
1737
|
-
return this.clone().mulTo(
|
|
1736
|
+
BN.prototype.imul = function imul(num2) {
|
|
1737
|
+
return this.clone().mulTo(num2, this);
|
|
1738
1738
|
};
|
|
1739
|
-
BN.prototype.imuln = function imuln(
|
|
1740
|
-
assert(typeof
|
|
1741
|
-
assert(
|
|
1739
|
+
BN.prototype.imuln = function imuln(num2) {
|
|
1740
|
+
assert(typeof num2 === "number");
|
|
1741
|
+
assert(num2 < 67108864);
|
|
1742
1742
|
var carry = 0;
|
|
1743
1743
|
for (var i = 0; i < this.length; i++) {
|
|
1744
|
-
var w = (this.words[i] | 0) *
|
|
1744
|
+
var w = (this.words[i] | 0) * num2;
|
|
1745
1745
|
var lo = (w & 67108863) + (carry & 67108863);
|
|
1746
1746
|
carry >>= 26;
|
|
1747
1747
|
carry += w / 67108864 | 0;
|
|
@@ -1752,11 +1752,11 @@ var require_bn = __commonJS({
|
|
|
1752
1752
|
this.words[i] = carry;
|
|
1753
1753
|
this.length++;
|
|
1754
1754
|
}
|
|
1755
|
-
this.length =
|
|
1755
|
+
this.length = num2 === 0 ? 1 : this.length;
|
|
1756
1756
|
return this;
|
|
1757
1757
|
};
|
|
1758
|
-
BN.prototype.muln = function muln(
|
|
1759
|
-
return this.clone().imuln(
|
|
1758
|
+
BN.prototype.muln = function muln(num2) {
|
|
1759
|
+
return this.clone().imuln(num2);
|
|
1760
1760
|
};
|
|
1761
1761
|
BN.prototype.sqr = function sqr() {
|
|
1762
1762
|
return this.mul(this);
|
|
@@ -1764,8 +1764,8 @@ var require_bn = __commonJS({
|
|
|
1764
1764
|
BN.prototype.isqr = function isqr() {
|
|
1765
1765
|
return this.imul(this.clone());
|
|
1766
1766
|
};
|
|
1767
|
-
BN.prototype.pow = function pow(
|
|
1768
|
-
var w = toBitArray(
|
|
1767
|
+
BN.prototype.pow = function pow(num2) {
|
|
1768
|
+
var w = toBitArray(num2);
|
|
1769
1769
|
if (w.length === 0) return new BN(1);
|
|
1770
1770
|
var res = this;
|
|
1771
1771
|
for (var i = 0; i < w.length; i++, res = res.sqr()) {
|
|
@@ -1907,25 +1907,25 @@ var require_bn = __commonJS({
|
|
|
1907
1907
|
BN.prototype.maskn = function maskn(bits) {
|
|
1908
1908
|
return this.clone().imaskn(bits);
|
|
1909
1909
|
};
|
|
1910
|
-
BN.prototype.iaddn = function iaddn(
|
|
1911
|
-
assert(typeof
|
|
1912
|
-
assert(
|
|
1913
|
-
if (
|
|
1910
|
+
BN.prototype.iaddn = function iaddn(num2) {
|
|
1911
|
+
assert(typeof num2 === "number");
|
|
1912
|
+
assert(num2 < 67108864);
|
|
1913
|
+
if (num2 < 0) return this.isubn(-num2);
|
|
1914
1914
|
if (this.negative !== 0) {
|
|
1915
|
-
if (this.length === 1 && (this.words[0] | 0) <
|
|
1916
|
-
this.words[0] =
|
|
1915
|
+
if (this.length === 1 && (this.words[0] | 0) < num2) {
|
|
1916
|
+
this.words[0] = num2 - (this.words[0] | 0);
|
|
1917
1917
|
this.negative = 0;
|
|
1918
1918
|
return this;
|
|
1919
1919
|
}
|
|
1920
1920
|
this.negative = 0;
|
|
1921
|
-
this.isubn(
|
|
1921
|
+
this.isubn(num2);
|
|
1922
1922
|
this.negative = 1;
|
|
1923
1923
|
return this;
|
|
1924
1924
|
}
|
|
1925
|
-
return this._iaddn(
|
|
1925
|
+
return this._iaddn(num2);
|
|
1926
1926
|
};
|
|
1927
|
-
BN.prototype._iaddn = function _iaddn(
|
|
1928
|
-
this.words[0] +=
|
|
1927
|
+
BN.prototype._iaddn = function _iaddn(num2) {
|
|
1928
|
+
this.words[0] += num2;
|
|
1929
1929
|
for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
|
|
1930
1930
|
this.words[i] -= 67108864;
|
|
1931
1931
|
if (i === this.length - 1) {
|
|
@@ -1937,17 +1937,17 @@ var require_bn = __commonJS({
|
|
|
1937
1937
|
this.length = Math.max(this.length, i + 1);
|
|
1938
1938
|
return this;
|
|
1939
1939
|
};
|
|
1940
|
-
BN.prototype.isubn = function isubn(
|
|
1941
|
-
assert(typeof
|
|
1942
|
-
assert(
|
|
1943
|
-
if (
|
|
1940
|
+
BN.prototype.isubn = function isubn(num2) {
|
|
1941
|
+
assert(typeof num2 === "number");
|
|
1942
|
+
assert(num2 < 67108864);
|
|
1943
|
+
if (num2 < 0) return this.iaddn(-num2);
|
|
1944
1944
|
if (this.negative !== 0) {
|
|
1945
1945
|
this.negative = 0;
|
|
1946
|
-
this.iaddn(
|
|
1946
|
+
this.iaddn(num2);
|
|
1947
1947
|
this.negative = 1;
|
|
1948
1948
|
return this;
|
|
1949
1949
|
}
|
|
1950
|
-
this.words[0] -=
|
|
1950
|
+
this.words[0] -= num2;
|
|
1951
1951
|
if (this.length === 1 && this.words[0] < 0) {
|
|
1952
1952
|
this.words[0] = -this.words[0];
|
|
1953
1953
|
this.negative = 1;
|
|
@@ -1959,11 +1959,11 @@ var require_bn = __commonJS({
|
|
|
1959
1959
|
}
|
|
1960
1960
|
return this.strip();
|
|
1961
1961
|
};
|
|
1962
|
-
BN.prototype.addn = function addn(
|
|
1963
|
-
return this.clone().iaddn(
|
|
1962
|
+
BN.prototype.addn = function addn(num2) {
|
|
1963
|
+
return this.clone().iaddn(num2);
|
|
1964
1964
|
};
|
|
1965
|
-
BN.prototype.subn = function subn(
|
|
1966
|
-
return this.clone().isubn(
|
|
1965
|
+
BN.prototype.subn = function subn(num2) {
|
|
1966
|
+
return this.clone().isubn(num2);
|
|
1967
1967
|
};
|
|
1968
1968
|
BN.prototype.iabs = function iabs() {
|
|
1969
1969
|
this.negative = 0;
|
|
@@ -1972,15 +1972,15 @@ var require_bn = __commonJS({
|
|
|
1972
1972
|
BN.prototype.abs = function abs() {
|
|
1973
1973
|
return this.clone().iabs();
|
|
1974
1974
|
};
|
|
1975
|
-
BN.prototype._ishlnsubmul = function _ishlnsubmul(
|
|
1976
|
-
var len =
|
|
1975
|
+
BN.prototype._ishlnsubmul = function _ishlnsubmul(num2, mul, shift) {
|
|
1976
|
+
var len = num2.length + shift;
|
|
1977
1977
|
var i;
|
|
1978
1978
|
this._expand(len);
|
|
1979
1979
|
var w;
|
|
1980
1980
|
var carry = 0;
|
|
1981
|
-
for (i = 0; i <
|
|
1981
|
+
for (i = 0; i < num2.length; i++) {
|
|
1982
1982
|
w = (this.words[i + shift] | 0) + carry;
|
|
1983
|
-
var right = (
|
|
1983
|
+
var right = (num2.words[i] | 0) * mul;
|
|
1984
1984
|
w -= right & 67108863;
|
|
1985
1985
|
carry = (w >> 26) - (right / 67108864 | 0);
|
|
1986
1986
|
this.words[i + shift] = w & 67108863;
|
|
@@ -2001,10 +2001,10 @@ var require_bn = __commonJS({
|
|
|
2001
2001
|
this.negative = 1;
|
|
2002
2002
|
return this.strip();
|
|
2003
2003
|
};
|
|
2004
|
-
BN.prototype._wordDiv = function _wordDiv(
|
|
2005
|
-
var shift = this.length -
|
|
2004
|
+
BN.prototype._wordDiv = function _wordDiv(num2, mode) {
|
|
2005
|
+
var shift = this.length - num2.length;
|
|
2006
2006
|
var a = this.clone();
|
|
2007
|
-
var b =
|
|
2007
|
+
var b = num2;
|
|
2008
2008
|
var bhi = b.words[b.length - 1] | 0;
|
|
2009
2009
|
var bhiBits = this._countBits(bhi);
|
|
2010
2010
|
shift = 26 - bhiBits;
|
|
@@ -2058,8 +2058,8 @@ var require_bn = __commonJS({
|
|
|
2058
2058
|
mod: a
|
|
2059
2059
|
};
|
|
2060
2060
|
};
|
|
2061
|
-
BN.prototype.divmod = function divmod(
|
|
2062
|
-
assert(!
|
|
2061
|
+
BN.prototype.divmod = function divmod(num2, mode, positive) {
|
|
2062
|
+
assert(!num2.isZero());
|
|
2063
2063
|
if (this.isZero()) {
|
|
2064
2064
|
return {
|
|
2065
2065
|
div: new BN(0),
|
|
@@ -2067,15 +2067,15 @@ var require_bn = __commonJS({
|
|
|
2067
2067
|
};
|
|
2068
2068
|
}
|
|
2069
2069
|
var div, mod, res;
|
|
2070
|
-
if (this.negative !== 0 &&
|
|
2071
|
-
res = this.neg().divmod(
|
|
2070
|
+
if (this.negative !== 0 && num2.negative === 0) {
|
|
2071
|
+
res = this.neg().divmod(num2, mode);
|
|
2072
2072
|
if (mode !== "mod") {
|
|
2073
2073
|
div = res.div.neg();
|
|
2074
2074
|
}
|
|
2075
2075
|
if (mode !== "div") {
|
|
2076
2076
|
mod = res.mod.neg();
|
|
2077
2077
|
if (positive && mod.negative !== 0) {
|
|
2078
|
-
mod.iadd(
|
|
2078
|
+
mod.iadd(num2);
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
2081
|
return {
|
|
@@ -2083,8 +2083,8 @@ var require_bn = __commonJS({
|
|
|
2083
2083
|
mod
|
|
2084
2084
|
};
|
|
2085
2085
|
}
|
|
2086
|
-
if (this.negative === 0 &&
|
|
2087
|
-
res = this.divmod(
|
|
2086
|
+
if (this.negative === 0 && num2.negative !== 0) {
|
|
2087
|
+
res = this.divmod(num2.neg(), mode);
|
|
2088
2088
|
if (mode !== "mod") {
|
|
2089
2089
|
div = res.div.neg();
|
|
2090
2090
|
}
|
|
@@ -2093,12 +2093,12 @@ var require_bn = __commonJS({
|
|
|
2093
2093
|
mod: res.mod
|
|
2094
2094
|
};
|
|
2095
2095
|
}
|
|
2096
|
-
if ((this.negative &
|
|
2097
|
-
res = this.neg().divmod(
|
|
2096
|
+
if ((this.negative & num2.negative) !== 0) {
|
|
2097
|
+
res = this.neg().divmod(num2.neg(), mode);
|
|
2098
2098
|
if (mode !== "div") {
|
|
2099
2099
|
mod = res.mod.neg();
|
|
2100
2100
|
if (positive && mod.negative !== 0) {
|
|
2101
|
-
mod.isub(
|
|
2101
|
+
mod.isub(num2);
|
|
2102
2102
|
}
|
|
2103
2103
|
}
|
|
2104
2104
|
return {
|
|
@@ -2106,72 +2106,72 @@ var require_bn = __commonJS({
|
|
|
2106
2106
|
mod
|
|
2107
2107
|
};
|
|
2108
2108
|
}
|
|
2109
|
-
if (
|
|
2109
|
+
if (num2.length > this.length || this.cmp(num2) < 0) {
|
|
2110
2110
|
return {
|
|
2111
2111
|
div: new BN(0),
|
|
2112
2112
|
mod: this
|
|
2113
2113
|
};
|
|
2114
2114
|
}
|
|
2115
|
-
if (
|
|
2115
|
+
if (num2.length === 1) {
|
|
2116
2116
|
if (mode === "div") {
|
|
2117
2117
|
return {
|
|
2118
|
-
div: this.divn(
|
|
2118
|
+
div: this.divn(num2.words[0]),
|
|
2119
2119
|
mod: null
|
|
2120
2120
|
};
|
|
2121
2121
|
}
|
|
2122
2122
|
if (mode === "mod") {
|
|
2123
2123
|
return {
|
|
2124
2124
|
div: null,
|
|
2125
|
-
mod: new BN(this.modn(
|
|
2125
|
+
mod: new BN(this.modn(num2.words[0]))
|
|
2126
2126
|
};
|
|
2127
2127
|
}
|
|
2128
2128
|
return {
|
|
2129
|
-
div: this.divn(
|
|
2130
|
-
mod: new BN(this.modn(
|
|
2129
|
+
div: this.divn(num2.words[0]),
|
|
2130
|
+
mod: new BN(this.modn(num2.words[0]))
|
|
2131
2131
|
};
|
|
2132
2132
|
}
|
|
2133
|
-
return this._wordDiv(
|
|
2133
|
+
return this._wordDiv(num2, mode);
|
|
2134
2134
|
};
|
|
2135
|
-
BN.prototype.div = function div(
|
|
2136
|
-
return this.divmod(
|
|
2135
|
+
BN.prototype.div = function div(num2) {
|
|
2136
|
+
return this.divmod(num2, "div", false).div;
|
|
2137
2137
|
};
|
|
2138
|
-
BN.prototype.mod = function mod(
|
|
2139
|
-
return this.divmod(
|
|
2138
|
+
BN.prototype.mod = function mod(num2) {
|
|
2139
|
+
return this.divmod(num2, "mod", false).mod;
|
|
2140
2140
|
};
|
|
2141
|
-
BN.prototype.umod = function umod(
|
|
2142
|
-
return this.divmod(
|
|
2141
|
+
BN.prototype.umod = function umod(num2) {
|
|
2142
|
+
return this.divmod(num2, "mod", true).mod;
|
|
2143
2143
|
};
|
|
2144
|
-
BN.prototype.divRound = function divRound(
|
|
2145
|
-
var dm = this.divmod(
|
|
2144
|
+
BN.prototype.divRound = function divRound(num2) {
|
|
2145
|
+
var dm = this.divmod(num2);
|
|
2146
2146
|
if (dm.mod.isZero()) return dm.div;
|
|
2147
|
-
var mod = dm.div.negative !== 0 ? dm.mod.isub(
|
|
2148
|
-
var half =
|
|
2149
|
-
var r2 =
|
|
2147
|
+
var mod = dm.div.negative !== 0 ? dm.mod.isub(num2) : dm.mod;
|
|
2148
|
+
var half = num2.ushrn(1);
|
|
2149
|
+
var r2 = num2.andln(1);
|
|
2150
2150
|
var cmp = mod.cmp(half);
|
|
2151
2151
|
if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
|
|
2152
2152
|
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
|
|
2153
2153
|
};
|
|
2154
|
-
BN.prototype.modn = function modn(
|
|
2155
|
-
assert(
|
|
2156
|
-
var p = (1 << 26) %
|
|
2154
|
+
BN.prototype.modn = function modn(num2) {
|
|
2155
|
+
assert(num2 <= 67108863);
|
|
2156
|
+
var p = (1 << 26) % num2;
|
|
2157
2157
|
var acc = 0;
|
|
2158
2158
|
for (var i = this.length - 1; i >= 0; i--) {
|
|
2159
|
-
acc = (p * acc + (this.words[i] | 0)) %
|
|
2159
|
+
acc = (p * acc + (this.words[i] | 0)) % num2;
|
|
2160
2160
|
}
|
|
2161
2161
|
return acc;
|
|
2162
2162
|
};
|
|
2163
|
-
BN.prototype.idivn = function idivn(
|
|
2164
|
-
assert(
|
|
2163
|
+
BN.prototype.idivn = function idivn(num2) {
|
|
2164
|
+
assert(num2 <= 67108863);
|
|
2165
2165
|
var carry = 0;
|
|
2166
2166
|
for (var i = this.length - 1; i >= 0; i--) {
|
|
2167
2167
|
var w = (this.words[i] | 0) + carry * 67108864;
|
|
2168
|
-
this.words[i] = w /
|
|
2169
|
-
carry = w %
|
|
2168
|
+
this.words[i] = w / num2 | 0;
|
|
2169
|
+
carry = w % num2;
|
|
2170
2170
|
}
|
|
2171
2171
|
return this.strip();
|
|
2172
2172
|
};
|
|
2173
|
-
BN.prototype.divn = function divn(
|
|
2174
|
-
return this.clone().idivn(
|
|
2173
|
+
BN.prototype.divn = function divn(num2) {
|
|
2174
|
+
return this.clone().idivn(num2);
|
|
2175
2175
|
};
|
|
2176
2176
|
BN.prototype.egcd = function egcd(p) {
|
|
2177
2177
|
assert(p.negative === 0);
|
|
@@ -2289,11 +2289,11 @@ var require_bn = __commonJS({
|
|
|
2289
2289
|
}
|
|
2290
2290
|
return res;
|
|
2291
2291
|
};
|
|
2292
|
-
BN.prototype.gcd = function gcd(
|
|
2293
|
-
if (this.isZero()) return
|
|
2294
|
-
if (
|
|
2292
|
+
BN.prototype.gcd = function gcd(num2) {
|
|
2293
|
+
if (this.isZero()) return num2.abs();
|
|
2294
|
+
if (num2.isZero()) return this.abs();
|
|
2295
2295
|
var a = this.clone();
|
|
2296
|
-
var b =
|
|
2296
|
+
var b = num2.clone();
|
|
2297
2297
|
a.negative = 0;
|
|
2298
2298
|
b.negative = 0;
|
|
2299
2299
|
for (var shift = 0; a.isEven() && b.isEven(); shift++) {
|
|
@@ -2319,8 +2319,8 @@ var require_bn = __commonJS({
|
|
|
2319
2319
|
} while (true);
|
|
2320
2320
|
return b.iushln(shift);
|
|
2321
2321
|
};
|
|
2322
|
-
BN.prototype.invm = function invm(
|
|
2323
|
-
return this.egcd(
|
|
2322
|
+
BN.prototype.invm = function invm(num2) {
|
|
2323
|
+
return this.egcd(num2).a.umod(num2);
|
|
2324
2324
|
};
|
|
2325
2325
|
BN.prototype.isEven = function isEven() {
|
|
2326
2326
|
return (this.words[0] & 1) === 0;
|
|
@@ -2328,8 +2328,8 @@ var require_bn = __commonJS({
|
|
|
2328
2328
|
BN.prototype.isOdd = function isOdd() {
|
|
2329
2329
|
return (this.words[0] & 1) === 1;
|
|
2330
2330
|
};
|
|
2331
|
-
BN.prototype.andln = function andln(
|
|
2332
|
-
return this.words[0] &
|
|
2331
|
+
BN.prototype.andln = function andln(num2) {
|
|
2332
|
+
return this.words[0] & num2;
|
|
2333
2333
|
};
|
|
2334
2334
|
BN.prototype.bincn = function bincn(bit) {
|
|
2335
2335
|
assert(typeof bit === "number");
|
|
@@ -2358,8 +2358,8 @@ var require_bn = __commonJS({
|
|
|
2358
2358
|
BN.prototype.isZero = function isZero() {
|
|
2359
2359
|
return this.length === 1 && this.words[0] === 0;
|
|
2360
2360
|
};
|
|
2361
|
-
BN.prototype.cmpn = function cmpn(
|
|
2362
|
-
var negative =
|
|
2361
|
+
BN.prototype.cmpn = function cmpn(num2) {
|
|
2362
|
+
var negative = num2 < 0;
|
|
2363
2363
|
if (this.negative !== 0 && !negative) return -1;
|
|
2364
2364
|
if (this.negative === 0 && negative) return 1;
|
|
2365
2365
|
this.strip();
|
|
@@ -2368,29 +2368,29 @@ var require_bn = __commonJS({
|
|
|
2368
2368
|
res = 1;
|
|
2369
2369
|
} else {
|
|
2370
2370
|
if (negative) {
|
|
2371
|
-
|
|
2371
|
+
num2 = -num2;
|
|
2372
2372
|
}
|
|
2373
|
-
assert(
|
|
2373
|
+
assert(num2 <= 67108863, "Number is too big");
|
|
2374
2374
|
var w = this.words[0] | 0;
|
|
2375
|
-
res = w ===
|
|
2375
|
+
res = w === num2 ? 0 : w < num2 ? -1 : 1;
|
|
2376
2376
|
}
|
|
2377
2377
|
if (this.negative !== 0) return -res | 0;
|
|
2378
2378
|
return res;
|
|
2379
2379
|
};
|
|
2380
|
-
BN.prototype.cmp = function cmp(
|
|
2381
|
-
if (this.negative !== 0 &&
|
|
2382
|
-
if (this.negative === 0 &&
|
|
2383
|
-
var res = this.ucmp(
|
|
2380
|
+
BN.prototype.cmp = function cmp(num2) {
|
|
2381
|
+
if (this.negative !== 0 && num2.negative === 0) return -1;
|
|
2382
|
+
if (this.negative === 0 && num2.negative !== 0) return 1;
|
|
2383
|
+
var res = this.ucmp(num2);
|
|
2384
2384
|
if (this.negative !== 0) return -res | 0;
|
|
2385
2385
|
return res;
|
|
2386
2386
|
};
|
|
2387
|
-
BN.prototype.ucmp = function ucmp(
|
|
2388
|
-
if (this.length >
|
|
2389
|
-
if (this.length <
|
|
2387
|
+
BN.prototype.ucmp = function ucmp(num2) {
|
|
2388
|
+
if (this.length > num2.length) return 1;
|
|
2389
|
+
if (this.length < num2.length) return -1;
|
|
2390
2390
|
var res = 0;
|
|
2391
2391
|
for (var i = this.length - 1; i >= 0; i--) {
|
|
2392
2392
|
var a = this.words[i] | 0;
|
|
2393
|
-
var b =
|
|
2393
|
+
var b = num2.words[i] | 0;
|
|
2394
2394
|
if (a === b) continue;
|
|
2395
2395
|
if (a < b) {
|
|
2396
2396
|
res = -1;
|
|
@@ -2401,38 +2401,38 @@ var require_bn = __commonJS({
|
|
|
2401
2401
|
}
|
|
2402
2402
|
return res;
|
|
2403
2403
|
};
|
|
2404
|
-
BN.prototype.gtn = function gtn(
|
|
2405
|
-
return this.cmpn(
|
|
2404
|
+
BN.prototype.gtn = function gtn(num2) {
|
|
2405
|
+
return this.cmpn(num2) === 1;
|
|
2406
2406
|
};
|
|
2407
|
-
BN.prototype.gt = function gt(
|
|
2408
|
-
return this.cmp(
|
|
2407
|
+
BN.prototype.gt = function gt(num2) {
|
|
2408
|
+
return this.cmp(num2) === 1;
|
|
2409
2409
|
};
|
|
2410
|
-
BN.prototype.gten = function gten(
|
|
2411
|
-
return this.cmpn(
|
|
2410
|
+
BN.prototype.gten = function gten(num2) {
|
|
2411
|
+
return this.cmpn(num2) >= 0;
|
|
2412
2412
|
};
|
|
2413
|
-
BN.prototype.gte = function gte(
|
|
2414
|
-
return this.cmp(
|
|
2413
|
+
BN.prototype.gte = function gte(num2) {
|
|
2414
|
+
return this.cmp(num2) >= 0;
|
|
2415
2415
|
};
|
|
2416
|
-
BN.prototype.ltn = function ltn(
|
|
2417
|
-
return this.cmpn(
|
|
2416
|
+
BN.prototype.ltn = function ltn(num2) {
|
|
2417
|
+
return this.cmpn(num2) === -1;
|
|
2418
2418
|
};
|
|
2419
|
-
BN.prototype.lt = function lt(
|
|
2420
|
-
return this.cmp(
|
|
2419
|
+
BN.prototype.lt = function lt(num2) {
|
|
2420
|
+
return this.cmp(num2) === -1;
|
|
2421
2421
|
};
|
|
2422
|
-
BN.prototype.lten = function lten(
|
|
2423
|
-
return this.cmpn(
|
|
2422
|
+
BN.prototype.lten = function lten(num2) {
|
|
2423
|
+
return this.cmpn(num2) <= 0;
|
|
2424
2424
|
};
|
|
2425
|
-
BN.prototype.lte = function lte(
|
|
2426
|
-
return this.cmp(
|
|
2425
|
+
BN.prototype.lte = function lte(num2) {
|
|
2426
|
+
return this.cmp(num2) <= 0;
|
|
2427
2427
|
};
|
|
2428
|
-
BN.prototype.eqn = function eqn(
|
|
2429
|
-
return this.cmpn(
|
|
2428
|
+
BN.prototype.eqn = function eqn(num2) {
|
|
2429
|
+
return this.cmpn(num2) === 0;
|
|
2430
2430
|
};
|
|
2431
|
-
BN.prototype.eq = function eq(
|
|
2432
|
-
return this.cmp(
|
|
2431
|
+
BN.prototype.eq = function eq(num2) {
|
|
2432
|
+
return this.cmp(num2) === 0;
|
|
2433
2433
|
};
|
|
2434
|
-
BN.red = function red(
|
|
2435
|
-
return new Red(
|
|
2434
|
+
BN.red = function red(num2) {
|
|
2435
|
+
return new Red(num2);
|
|
2436
2436
|
};
|
|
2437
2437
|
BN.prototype.toRed = function toRed(ctx) {
|
|
2438
2438
|
assert(!this.red, "Already a number in reduction context");
|
|
@@ -2451,35 +2451,35 @@ var require_bn = __commonJS({
|
|
|
2451
2451
|
assert(!this.red, "Already a number in reduction context");
|
|
2452
2452
|
return this._forceRed(ctx);
|
|
2453
2453
|
};
|
|
2454
|
-
BN.prototype.redAdd = function redAdd(
|
|
2454
|
+
BN.prototype.redAdd = function redAdd(num2) {
|
|
2455
2455
|
assert(this.red, "redAdd works only with red numbers");
|
|
2456
|
-
return this.red.add(this,
|
|
2456
|
+
return this.red.add(this, num2);
|
|
2457
2457
|
};
|
|
2458
|
-
BN.prototype.redIAdd = function redIAdd(
|
|
2458
|
+
BN.prototype.redIAdd = function redIAdd(num2) {
|
|
2459
2459
|
assert(this.red, "redIAdd works only with red numbers");
|
|
2460
|
-
return this.red.iadd(this,
|
|
2460
|
+
return this.red.iadd(this, num2);
|
|
2461
2461
|
};
|
|
2462
|
-
BN.prototype.redSub = function redSub(
|
|
2462
|
+
BN.prototype.redSub = function redSub(num2) {
|
|
2463
2463
|
assert(this.red, "redSub works only with red numbers");
|
|
2464
|
-
return this.red.sub(this,
|
|
2464
|
+
return this.red.sub(this, num2);
|
|
2465
2465
|
};
|
|
2466
|
-
BN.prototype.redISub = function redISub(
|
|
2466
|
+
BN.prototype.redISub = function redISub(num2) {
|
|
2467
2467
|
assert(this.red, "redISub works only with red numbers");
|
|
2468
|
-
return this.red.isub(this,
|
|
2468
|
+
return this.red.isub(this, num2);
|
|
2469
2469
|
};
|
|
2470
|
-
BN.prototype.redShl = function redShl(
|
|
2470
|
+
BN.prototype.redShl = function redShl(num2) {
|
|
2471
2471
|
assert(this.red, "redShl works only with red numbers");
|
|
2472
|
-
return this.red.shl(this,
|
|
2472
|
+
return this.red.shl(this, num2);
|
|
2473
2473
|
};
|
|
2474
|
-
BN.prototype.redMul = function redMul(
|
|
2474
|
+
BN.prototype.redMul = function redMul(num2) {
|
|
2475
2475
|
assert(this.red, "redMul works only with red numbers");
|
|
2476
|
-
this.red._verify2(this,
|
|
2477
|
-
return this.red.mul(this,
|
|
2476
|
+
this.red._verify2(this, num2);
|
|
2477
|
+
return this.red.mul(this, num2);
|
|
2478
2478
|
};
|
|
2479
|
-
BN.prototype.redIMul = function redIMul(
|
|
2479
|
+
BN.prototype.redIMul = function redIMul(num2) {
|
|
2480
2480
|
assert(this.red, "redMul works only with red numbers");
|
|
2481
|
-
this.red._verify2(this,
|
|
2482
|
-
return this.red.imul(this,
|
|
2481
|
+
this.red._verify2(this, num2);
|
|
2482
|
+
return this.red.imul(this, num2);
|
|
2483
2483
|
};
|
|
2484
2484
|
BN.prototype.redSqr = function redSqr() {
|
|
2485
2485
|
assert(this.red, "redSqr works only with red numbers");
|
|
@@ -2506,10 +2506,10 @@ var require_bn = __commonJS({
|
|
|
2506
2506
|
this.red._verify1(this);
|
|
2507
2507
|
return this.red.neg(this);
|
|
2508
2508
|
};
|
|
2509
|
-
BN.prototype.redPow = function redPow(
|
|
2510
|
-
assert(this.red && !
|
|
2509
|
+
BN.prototype.redPow = function redPow(num2) {
|
|
2510
|
+
assert(this.red && !num2.red, "redPow(normalNum)");
|
|
2511
2511
|
this.red._verify1(this);
|
|
2512
|
-
return this.red.pow(this,
|
|
2512
|
+
return this.red.pow(this, num2);
|
|
2513
2513
|
};
|
|
2514
2514
|
var primes = {
|
|
2515
2515
|
k256: null,
|
|
@@ -2529,8 +2529,8 @@ var require_bn = __commonJS({
|
|
|
2529
2529
|
tmp.words = new Array(Math.ceil(this.n / 13));
|
|
2530
2530
|
return tmp;
|
|
2531
2531
|
};
|
|
2532
|
-
MPrime.prototype.ireduce = function ireduce(
|
|
2533
|
-
var r =
|
|
2532
|
+
MPrime.prototype.ireduce = function ireduce(num2) {
|
|
2533
|
+
var r = num2;
|
|
2534
2534
|
var rlen;
|
|
2535
2535
|
do {
|
|
2536
2536
|
this.split(r, this.tmp);
|
|
@@ -2556,8 +2556,8 @@ var require_bn = __commonJS({
|
|
|
2556
2556
|
MPrime.prototype.split = function split(input, out) {
|
|
2557
2557
|
input.iushrn(this.n, 0, out);
|
|
2558
2558
|
};
|
|
2559
|
-
MPrime.prototype.imulK = function imulK(
|
|
2560
|
-
return
|
|
2559
|
+
MPrime.prototype.imulK = function imulK(num2) {
|
|
2560
|
+
return num2.imul(this.k);
|
|
2561
2561
|
};
|
|
2562
2562
|
function K256() {
|
|
2563
2563
|
MPrime.call(
|
|
@@ -2594,24 +2594,24 @@ var require_bn = __commonJS({
|
|
|
2594
2594
|
input.length -= 9;
|
|
2595
2595
|
}
|
|
2596
2596
|
};
|
|
2597
|
-
K256.prototype.imulK = function imulK(
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2597
|
+
K256.prototype.imulK = function imulK(num2) {
|
|
2598
|
+
num2.words[num2.length] = 0;
|
|
2599
|
+
num2.words[num2.length + 1] = 0;
|
|
2600
|
+
num2.length += 2;
|
|
2601
2601
|
var lo = 0;
|
|
2602
|
-
for (var i = 0; i <
|
|
2603
|
-
var w =
|
|
2602
|
+
for (var i = 0; i < num2.length; i++) {
|
|
2603
|
+
var w = num2.words[i] | 0;
|
|
2604
2604
|
lo += w * 977;
|
|
2605
|
-
|
|
2605
|
+
num2.words[i] = lo & 67108863;
|
|
2606
2606
|
lo = w * 64 + (lo / 67108864 | 0);
|
|
2607
2607
|
}
|
|
2608
|
-
if (
|
|
2609
|
-
|
|
2610
|
-
if (
|
|
2611
|
-
|
|
2608
|
+
if (num2.words[num2.length - 1] === 0) {
|
|
2609
|
+
num2.length--;
|
|
2610
|
+
if (num2.words[num2.length - 1] === 0) {
|
|
2611
|
+
num2.length--;
|
|
2612
2612
|
}
|
|
2613
2613
|
}
|
|
2614
|
-
return
|
|
2614
|
+
return num2;
|
|
2615
2615
|
};
|
|
2616
2616
|
function P224() {
|
|
2617
2617
|
MPrime.call(
|
|
@@ -2637,19 +2637,19 @@ var require_bn = __commonJS({
|
|
|
2637
2637
|
);
|
|
2638
2638
|
}
|
|
2639
2639
|
inherits(P25519, MPrime);
|
|
2640
|
-
P25519.prototype.imulK = function imulK(
|
|
2640
|
+
P25519.prototype.imulK = function imulK(num2) {
|
|
2641
2641
|
var carry = 0;
|
|
2642
|
-
for (var i = 0; i <
|
|
2643
|
-
var hi = (
|
|
2642
|
+
for (var i = 0; i < num2.length; i++) {
|
|
2643
|
+
var hi = (num2.words[i] | 0) * 19 + carry;
|
|
2644
2644
|
var lo = hi & 67108863;
|
|
2645
2645
|
hi >>>= 26;
|
|
2646
|
-
|
|
2646
|
+
num2.words[i] = lo;
|
|
2647
2647
|
carry = hi;
|
|
2648
2648
|
}
|
|
2649
2649
|
if (carry !== 0) {
|
|
2650
|
-
|
|
2650
|
+
num2.words[num2.length++] = carry;
|
|
2651
2651
|
}
|
|
2652
|
-
return
|
|
2652
|
+
return num2;
|
|
2653
2653
|
};
|
|
2654
2654
|
BN._prime = function prime(name) {
|
|
2655
2655
|
if (primes[name]) return primes[name];
|
|
@@ -2732,9 +2732,9 @@ var require_bn = __commonJS({
|
|
|
2732
2732
|
}
|
|
2733
2733
|
return res;
|
|
2734
2734
|
};
|
|
2735
|
-
Red.prototype.shl = function shl(a,
|
|
2735
|
+
Red.prototype.shl = function shl(a, num2) {
|
|
2736
2736
|
this._verify1(a);
|
|
2737
|
-
return this.imod(a.ushln(
|
|
2737
|
+
return this.imod(a.ushln(num2));
|
|
2738
2738
|
};
|
|
2739
2739
|
Red.prototype.imul = function imul(a, b) {
|
|
2740
2740
|
this._verify2(a, b);
|
|
@@ -2800,9 +2800,9 @@ var require_bn = __commonJS({
|
|
|
2800
2800
|
return this.imod(inv);
|
|
2801
2801
|
}
|
|
2802
2802
|
};
|
|
2803
|
-
Red.prototype.pow = function pow(a,
|
|
2804
|
-
if (
|
|
2805
|
-
if (
|
|
2803
|
+
Red.prototype.pow = function pow(a, num2) {
|
|
2804
|
+
if (num2.isZero()) return new BN(1).toRed(this);
|
|
2805
|
+
if (num2.cmpn(1) === 0) return a.clone();
|
|
2806
2806
|
var windowSize = 4;
|
|
2807
2807
|
var wnd = new Array(1 << windowSize);
|
|
2808
2808
|
wnd[0] = new BN(1).toRed(this);
|
|
@@ -2813,12 +2813,12 @@ var require_bn = __commonJS({
|
|
|
2813
2813
|
var res = wnd[0];
|
|
2814
2814
|
var current = 0;
|
|
2815
2815
|
var currentLen = 0;
|
|
2816
|
-
var start =
|
|
2816
|
+
var start = num2.bitLength() % 26;
|
|
2817
2817
|
if (start === 0) {
|
|
2818
2818
|
start = 26;
|
|
2819
2819
|
}
|
|
2820
|
-
for (i =
|
|
2821
|
-
var word =
|
|
2820
|
+
for (i = num2.length - 1; i >= 0; i--) {
|
|
2821
|
+
var word = num2.words[i];
|
|
2822
2822
|
for (var j = start - 1; j >= 0; j--) {
|
|
2823
2823
|
var bit = word >> j & 1;
|
|
2824
2824
|
if (res !== wnd[0]) {
|
|
@@ -2840,17 +2840,17 @@ var require_bn = __commonJS({
|
|
|
2840
2840
|
}
|
|
2841
2841
|
return res;
|
|
2842
2842
|
};
|
|
2843
|
-
Red.prototype.convertTo = function convertTo(
|
|
2844
|
-
var r =
|
|
2845
|
-
return r ===
|
|
2843
|
+
Red.prototype.convertTo = function convertTo(num2) {
|
|
2844
|
+
var r = num2.umod(this.m);
|
|
2845
|
+
return r === num2 ? r.clone() : r;
|
|
2846
2846
|
};
|
|
2847
|
-
Red.prototype.convertFrom = function convertFrom(
|
|
2848
|
-
var res =
|
|
2847
|
+
Red.prototype.convertFrom = function convertFrom(num2) {
|
|
2848
|
+
var res = num2.clone();
|
|
2849
2849
|
res.red = null;
|
|
2850
2850
|
return res;
|
|
2851
2851
|
};
|
|
2852
|
-
BN.mont = function mont(
|
|
2853
|
-
return new Mont(
|
|
2852
|
+
BN.mont = function mont(num2) {
|
|
2853
|
+
return new Mont(num2);
|
|
2854
2854
|
};
|
|
2855
2855
|
function Mont(m) {
|
|
2856
2856
|
Red.call(this, m);
|
|
@@ -2866,11 +2866,11 @@ var require_bn = __commonJS({
|
|
|
2866
2866
|
this.minv = this.r.sub(this.minv);
|
|
2867
2867
|
}
|
|
2868
2868
|
inherits(Mont, Red);
|
|
2869
|
-
Mont.prototype.convertTo = function convertTo(
|
|
2870
|
-
return this.imod(
|
|
2869
|
+
Mont.prototype.convertTo = function convertTo(num2) {
|
|
2870
|
+
return this.imod(num2.ushln(this.shift));
|
|
2871
2871
|
};
|
|
2872
|
-
Mont.prototype.convertFrom = function convertFrom(
|
|
2873
|
-
var r = this.imod(
|
|
2872
|
+
Mont.prototype.convertFrom = function convertFrom(num2) {
|
|
2873
|
+
var r = this.imod(num2.mul(this.rinv));
|
|
2874
2874
|
r.red = null;
|
|
2875
2875
|
return r;
|
|
2876
2876
|
};
|
|
@@ -2997,14 +2997,14 @@ var require_utils2 = __commonJS({
|
|
|
2997
2997
|
utils.zero2 = minUtils.zero2;
|
|
2998
2998
|
utils.toHex = minUtils.toHex;
|
|
2999
2999
|
utils.encode = minUtils.encode;
|
|
3000
|
-
function getNAF(
|
|
3001
|
-
var naf = new Array(Math.max(
|
|
3000
|
+
function getNAF(num2, w, bits) {
|
|
3001
|
+
var naf = new Array(Math.max(num2.bitLength(), bits) + 1);
|
|
3002
3002
|
var i;
|
|
3003
3003
|
for (i = 0; i < naf.length; i += 1) {
|
|
3004
3004
|
naf[i] = 0;
|
|
3005
3005
|
}
|
|
3006
3006
|
var ws = 1 << w + 1;
|
|
3007
|
-
var k =
|
|
3007
|
+
var k = num2.clone();
|
|
3008
3008
|
for (i = 0; i < naf.length; i++) {
|
|
3009
3009
|
var z;
|
|
3010
3010
|
var mod = k.andln(ws - 1);
|
|
@@ -3574,8 +3574,8 @@ var require_short = __commonJS({
|
|
|
3574
3574
|
basis
|
|
3575
3575
|
};
|
|
3576
3576
|
};
|
|
3577
|
-
ShortCurve.prototype._getEndoRoots = function _getEndoRoots(
|
|
3578
|
-
var red =
|
|
3577
|
+
ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num2) {
|
|
3578
|
+
var red = num2 === this.p ? this.red : BN.mont(num2);
|
|
3579
3579
|
var tinv = new BN(2).toRed(red).redInvm();
|
|
3580
3580
|
var ntinv = tinv.redNeg();
|
|
3581
3581
|
var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
|
|
@@ -4361,17 +4361,17 @@ var require_edwards = __commonJS({
|
|
|
4361
4361
|
}
|
|
4362
4362
|
inherits(EdwardsCurve, Base);
|
|
4363
4363
|
module.exports = EdwardsCurve;
|
|
4364
|
-
EdwardsCurve.prototype._mulA = function _mulA(
|
|
4364
|
+
EdwardsCurve.prototype._mulA = function _mulA(num2) {
|
|
4365
4365
|
if (this.mOneA)
|
|
4366
|
-
return
|
|
4366
|
+
return num2.redNeg();
|
|
4367
4367
|
else
|
|
4368
|
-
return this.a.redMul(
|
|
4368
|
+
return this.a.redMul(num2);
|
|
4369
4369
|
};
|
|
4370
|
-
EdwardsCurve.prototype._mulC = function _mulC(
|
|
4370
|
+
EdwardsCurve.prototype._mulC = function _mulC(num2) {
|
|
4371
4371
|
if (this.oneC)
|
|
4372
|
-
return
|
|
4372
|
+
return num2;
|
|
4373
4373
|
else
|
|
4374
|
-
return this.c.redMul(
|
|
4374
|
+
return this.c.redMul(num2);
|
|
4375
4375
|
};
|
|
4376
4376
|
EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
|
|
4377
4377
|
return this.point(x, y, z, t);
|
|
@@ -4870,22 +4870,22 @@ var require_utils3 = __commonJS({
|
|
|
4870
4870
|
return lo >>> 0;
|
|
4871
4871
|
}
|
|
4872
4872
|
exports.sum64_5_lo = sum64_5_lo;
|
|
4873
|
-
function rotr64_hi(ah, al,
|
|
4874
|
-
var r = al << 32 -
|
|
4873
|
+
function rotr64_hi(ah, al, num2) {
|
|
4874
|
+
var r = al << 32 - num2 | ah >>> num2;
|
|
4875
4875
|
return r >>> 0;
|
|
4876
4876
|
}
|
|
4877
4877
|
exports.rotr64_hi = rotr64_hi;
|
|
4878
|
-
function rotr64_lo(ah, al,
|
|
4879
|
-
var r = ah << 32 -
|
|
4878
|
+
function rotr64_lo(ah, al, num2) {
|
|
4879
|
+
var r = ah << 32 - num2 | al >>> num2;
|
|
4880
4880
|
return r >>> 0;
|
|
4881
4881
|
}
|
|
4882
4882
|
exports.rotr64_lo = rotr64_lo;
|
|
4883
|
-
function shr64_hi(ah, al,
|
|
4884
|
-
return ah >>>
|
|
4883
|
+
function shr64_hi(ah, al, num2) {
|
|
4884
|
+
return ah >>> num2;
|
|
4885
4885
|
}
|
|
4886
4886
|
exports.shr64_hi = shr64_hi;
|
|
4887
|
-
function shr64_lo(ah, al,
|
|
4888
|
-
var r = ah << 32 -
|
|
4887
|
+
function shr64_lo(ah, al, num2) {
|
|
4888
|
+
var r = ah << 32 - num2 | al >>> num2;
|
|
4889
4889
|
return r >>> 0;
|
|
4890
4890
|
}
|
|
4891
4891
|
exports.shr64_lo = shr64_lo;
|
|
@@ -7966,8 +7966,8 @@ var require_eddsa = __commonJS({
|
|
|
7966
7966
|
var y = utils.intFromLE(normed);
|
|
7967
7967
|
return this.curve.pointFromY(y, xIsOdd);
|
|
7968
7968
|
};
|
|
7969
|
-
EDDSA.prototype.encodeInt = function encodeInt(
|
|
7970
|
-
return
|
|
7969
|
+
EDDSA.prototype.encodeInt = function encodeInt(num2) {
|
|
7970
|
+
return num2.toArray("le", this.encodingLength);
|
|
7971
7971
|
};
|
|
7972
7972
|
EDDSA.prototype.decodeInt = function decodeInt(bytes) {
|
|
7973
7973
|
return utils.intFromLE(bytes);
|
|
@@ -7996,6 +7996,7 @@ var require_elliptic = __commonJS({
|
|
|
7996
7996
|
var chargyInterfaces_exports = {};
|
|
7997
7997
|
__export(chargyInterfaces_exports, {
|
|
7998
7998
|
CreateError: () => CreateError,
|
|
7999
|
+
CreateWarning: () => CreateWarning,
|
|
7999
8000
|
CryptoAlgorithms: () => CryptoAlgorithms,
|
|
8000
8001
|
CryptoHashAlgorithms: () => CryptoHashAlgorithms,
|
|
8001
8002
|
DayOfWeek: () => DayOfWeek,
|
|
@@ -8071,6 +8072,12 @@ var ErrorLevel = /* @__PURE__ */ ((ErrorLevel2) => {
|
|
|
8071
8072
|
ErrorLevel2["high"] = "high";
|
|
8072
8073
|
return ErrorLevel2;
|
|
8073
8074
|
})(ErrorLevel || {});
|
|
8075
|
+
function CreateWarning(message, level = "low" /* low */) {
|
|
8076
|
+
return {
|
|
8077
|
+
level,
|
|
8078
|
+
message
|
|
8079
|
+
};
|
|
8080
|
+
}
|
|
8074
8081
|
function CreateError(message, level = "high" /* high */) {
|
|
8075
8082
|
return {
|
|
8076
8083
|
level,
|
|
@@ -9388,6 +9395,8 @@ var Alfen = class {
|
|
|
9388
9395
|
);
|
|
9389
9396
|
}
|
|
9390
9397
|
_CTR["status"] = "Unvalidated" /* Unvalidated */;
|
|
9398
|
+
if (ContainerInfos.warnings !== void 0)
|
|
9399
|
+
_CTR.warnings = [..._CTR.warnings ?? [], ...ContainerInfos.warnings];
|
|
9391
9400
|
return _CTR;
|
|
9392
9401
|
} catch (exception) {
|
|
9393
9402
|
return {
|
|
@@ -10614,6 +10623,1051 @@ var BSMCrypt01 = class extends ACrypt {
|
|
|
10614
10623
|
// //#endregion
|
|
10615
10624
|
};
|
|
10616
10625
|
|
|
10626
|
+
// src/interfaces/IPublicKeyInfo.ts
|
|
10627
|
+
var IPublicKeyInfo_exports = {};
|
|
10628
|
+
__export(IPublicKeyInfo_exports, {
|
|
10629
|
+
IsAPublicKey: () => IsAPublicKey,
|
|
10630
|
+
IsAPublicKeyLookup: () => IsAPublicKeyLookup,
|
|
10631
|
+
IsAPublicKeySignature: () => IsAPublicKeySignature,
|
|
10632
|
+
IsAPublicKeyXY: () => IsAPublicKeyXY,
|
|
10633
|
+
PublicKeyFormats: () => PublicKeyFormats,
|
|
10634
|
+
isPublicKeySubject: () => isPublicKeySubject
|
|
10635
|
+
});
|
|
10636
|
+
var PublicKeyFormats = /* @__PURE__ */ ((PublicKeyFormats2) => {
|
|
10637
|
+
PublicKeyFormats2["DER"] = "DER";
|
|
10638
|
+
PublicKeyFormats2["XY"] = "XY";
|
|
10639
|
+
return PublicKeyFormats2;
|
|
10640
|
+
})(PublicKeyFormats || {});
|
|
10641
|
+
function IsAPublicKeyLookup(data) {
|
|
10642
|
+
if (!isMandatoryJSONObject(data))
|
|
10643
|
+
return false;
|
|
10644
|
+
return Array.isArray(data["publicKeys"]);
|
|
10645
|
+
}
|
|
10646
|
+
function IsAPublicKey(data) {
|
|
10647
|
+
if (!isMandatoryJSONObject(data))
|
|
10648
|
+
return false;
|
|
10649
|
+
if (data["@context"] !== void 0 && !isStringOrStringArray(data["@context"])) {
|
|
10650
|
+
return false;
|
|
10651
|
+
}
|
|
10652
|
+
if (!isPublicKeySubject(data["subject"]))
|
|
10653
|
+
return false;
|
|
10654
|
+
if (data["value"] !== void 0 && !isString(data["value"])) {
|
|
10655
|
+
return false;
|
|
10656
|
+
}
|
|
10657
|
+
if (data["value"] === void 0 && (data["x"] === void 0 || data["y"] === void 0)) {
|
|
10658
|
+
return false;
|
|
10659
|
+
}
|
|
10660
|
+
if (data["value"] !== void 0 && !isStringOrOIDInfo(data["algorithm"])) {
|
|
10661
|
+
return false;
|
|
10662
|
+
}
|
|
10663
|
+
if (data["certainty"] !== void 0 && (typeof data["certainty"] !== "number" || !Number.isFinite(data["certainty"]))) {
|
|
10664
|
+
return false;
|
|
10665
|
+
}
|
|
10666
|
+
if (data["type"] !== void 0 && !isStringOrOIDInfo(data["type"])) {
|
|
10667
|
+
return false;
|
|
10668
|
+
}
|
|
10669
|
+
if (data["encoding"] !== void 0 && typeof data["encoding"] !== "string") {
|
|
10670
|
+
return false;
|
|
10671
|
+
}
|
|
10672
|
+
if (data["signatures"] !== void 0 && (!Array.isArray(data["signatures"]) || !data["signatures"].every(IsAPublicKeySignature))) {
|
|
10673
|
+
return false;
|
|
10674
|
+
}
|
|
10675
|
+
return true;
|
|
10676
|
+
}
|
|
10677
|
+
function isPublicKeySubject(data) {
|
|
10678
|
+
if (data === void 0)
|
|
10679
|
+
return true;
|
|
10680
|
+
if (isStringOrStringArray(data))
|
|
10681
|
+
return true;
|
|
10682
|
+
if (!isMandatoryJSONObject(data))
|
|
10683
|
+
return false;
|
|
10684
|
+
return Object.values(data).every(
|
|
10685
|
+
(value) => typeof value === "string" || isStringOrStringArray(value)
|
|
10686
|
+
);
|
|
10687
|
+
}
|
|
10688
|
+
function IsAPublicKeySignature(data) {
|
|
10689
|
+
if (!isMandatoryJSONObject(data))
|
|
10690
|
+
return false;
|
|
10691
|
+
if (!isOptionalString(data["@id"]))
|
|
10692
|
+
return false;
|
|
10693
|
+
if (data["@context"] !== void 0 && !isStringOrStringArray(data["@context"]))
|
|
10694
|
+
return false;
|
|
10695
|
+
if (!isOptionalStringOrOIDInfo(data["algorithm"]))
|
|
10696
|
+
return false;
|
|
10697
|
+
if (!isOptionalString(data["format"]))
|
|
10698
|
+
return false;
|
|
10699
|
+
if (!isOptionalString(data["encoding"]))
|
|
10700
|
+
return false;
|
|
10701
|
+
if (data["value"] !== void 0 && !isString(data["value"]))
|
|
10702
|
+
return false;
|
|
10703
|
+
if (data["publicKey"] !== void 0 && !isEncodedValue(data["publicKey"]))
|
|
10704
|
+
return false;
|
|
10705
|
+
if (data["signature"] !== void 0 && !isEncodedValue(data["signature"]))
|
|
10706
|
+
return false;
|
|
10707
|
+
if (!isOptionalString(data["timestamp"]))
|
|
10708
|
+
return false;
|
|
10709
|
+
if (!isOptionalString(data["issuer"]))
|
|
10710
|
+
return false;
|
|
10711
|
+
if (!isOptionalString(data["signer"]))
|
|
10712
|
+
return false;
|
|
10713
|
+
if (!isOptionalString(data["notBefore"]))
|
|
10714
|
+
return false;
|
|
10715
|
+
if (!isOptionalString(data["notAfter"]))
|
|
10716
|
+
return false;
|
|
10717
|
+
if (!isOptionalStringArray(data["keyUsage"]))
|
|
10718
|
+
return false;
|
|
10719
|
+
if (data["operations"] !== void 0 && !isMandatoryJSONObject(data["operations"]))
|
|
10720
|
+
return false;
|
|
10721
|
+
if (data["comment"] !== void 0 && !isMandatoryJSONObject(data["comment"]))
|
|
10722
|
+
return false;
|
|
10723
|
+
return data["value"] !== void 0 || data["signature"] !== void 0 || data["algorithm"] !== void 0 || data["timestamp"] !== void 0 || data["issuer"] !== void 0 || data["signer"] !== void 0 || data["keyUsage"] !== void 0;
|
|
10724
|
+
}
|
|
10725
|
+
function IsAPublicKeyXY(data) {
|
|
10726
|
+
if (!IsAPublicKey(data))
|
|
10727
|
+
return false;
|
|
10728
|
+
if (!isString(data["x"])) {
|
|
10729
|
+
return false;
|
|
10730
|
+
}
|
|
10731
|
+
if (!isString(data["y"])) {
|
|
10732
|
+
return false;
|
|
10733
|
+
}
|
|
10734
|
+
return true;
|
|
10735
|
+
}
|
|
10736
|
+
var EDL40_SESSION_CONTEXT = "https://open.charging.cloud/contexts/SessionSignatureFormats/EDL40+json";
|
|
10737
|
+
var EDL40_SIGNATURE_CONTEXT = "https://open.charging.cloud/contexts/EnergyMeterSignatureFormats/EDL40+json";
|
|
10738
|
+
var EDL40_OBIS = "1-0:1.8.0*255";
|
|
10739
|
+
var EDL40ValidationError = class extends Error {
|
|
10740
|
+
constructor(code, message) {
|
|
10741
|
+
super(message);
|
|
10742
|
+
this.code = code;
|
|
10743
|
+
this.name = "EDL40ValidationError";
|
|
10744
|
+
}
|
|
10745
|
+
code;
|
|
10746
|
+
};
|
|
10747
|
+
var START_ESCAPE = [27, 27, 27, 27, 1, 1, 1, 1];
|
|
10748
|
+
var ESCAPE = [27, 27, 27, 27];
|
|
10749
|
+
var REQUIRED_UNIT = 30;
|
|
10750
|
+
var SIGNATURE_LENGTH = 320;
|
|
10751
|
+
var OBIS_CONTRACT_ID = "8182815401ff";
|
|
10752
|
+
var OBIS_SIGNED_VALUE = "0100011100ff";
|
|
10753
|
+
var OBIS_SIGNED_VALUE_2 = "0100010800ff";
|
|
10754
|
+
var OBIS_EDL_PAGINATION = "8180817101ff";
|
|
10755
|
+
var OBIS_EDL_SECONDS_INDEX = "810060080001";
|
|
10756
|
+
var OBIS_SIGNATURE_VERSION = "00af737672ff";
|
|
10757
|
+
var OBIS_START_EC = "010001080080";
|
|
10758
|
+
var OBIS_ACTUAL_EC = "0100010800ff";
|
|
10759
|
+
var OBIS_ISA_PAGINATION = "8180c7f040ff";
|
|
10760
|
+
var OBIS_ESTH = "8180816101ff";
|
|
10761
|
+
function canParseEDL40(data) {
|
|
10762
|
+
try {
|
|
10763
|
+
parseEDL40(data);
|
|
10764
|
+
return true;
|
|
10765
|
+
} catch {
|
|
10766
|
+
return false;
|
|
10767
|
+
}
|
|
10768
|
+
}
|
|
10769
|
+
function parseEDL40(data) {
|
|
10770
|
+
const res = parseGetListRes(data);
|
|
10771
|
+
try {
|
|
10772
|
+
return buildIsaSignature(res);
|
|
10773
|
+
} catch {
|
|
10774
|
+
return buildEDL40Signature(res);
|
|
10775
|
+
}
|
|
10776
|
+
}
|
|
10777
|
+
async function verifyEDL40Document(document2, publicKey, chargy) {
|
|
10778
|
+
const normalizedPublicKey = cleanHex(publicKey);
|
|
10779
|
+
if (document2.variant === "ISA_EDL_40_P") {
|
|
10780
|
+
const signature2 = document2.dataSignature;
|
|
10781
|
+
const hashValue = await hashSignedData(document2.signedData, 32);
|
|
10782
|
+
if (normalizedPublicKey.length !== 128 || signature2.length !== 64)
|
|
10783
|
+
return {
|
|
10784
|
+
status: "InvalidPublicKey" /* InvalidPublicKey */,
|
|
10785
|
+
curve: "secp256r1",
|
|
10786
|
+
hashValue,
|
|
10787
|
+
signature: signature2
|
|
10788
|
+
};
|
|
10789
|
+
return {
|
|
10790
|
+
status: verifyRawSignature(chargy, "secp256r1", normalizedPublicKey, signature2, hashValue),
|
|
10791
|
+
curve: "secp256r1",
|
|
10792
|
+
hashValue,
|
|
10793
|
+
signature: signature2
|
|
10794
|
+
};
|
|
10795
|
+
}
|
|
10796
|
+
const cutoff = document2.version === 4 || document2.listSignature.length === 50 ? 2 : 0;
|
|
10797
|
+
const signature = document2.listSignature.subarray(0, document2.listSignature.length - cutoff);
|
|
10798
|
+
if (normalizedPublicKey.length === 96 && signature.length === 48) {
|
|
10799
|
+
const hashValue = await hashSignedData(document2.signedData, 24);
|
|
10800
|
+
return {
|
|
10801
|
+
status: verifyRawSignature(chargy, "secp192r1", normalizedPublicKey, signature, hashValue),
|
|
10802
|
+
curve: "secp192r1",
|
|
10803
|
+
hashValue,
|
|
10804
|
+
signature
|
|
10805
|
+
};
|
|
10806
|
+
}
|
|
10807
|
+
if (normalizedPublicKey.length === 128 && signature.length === 64) {
|
|
10808
|
+
const hashValue = await hashSignedData(document2.signedData, 32);
|
|
10809
|
+
return {
|
|
10810
|
+
status: verifyRawSignature(chargy, "secp256r1", normalizedPublicKey, signature, hashValue),
|
|
10811
|
+
curve: "secp256r1",
|
|
10812
|
+
hashValue,
|
|
10813
|
+
signature
|
|
10814
|
+
};
|
|
10815
|
+
}
|
|
10816
|
+
return {
|
|
10817
|
+
status: normalizedPublicKey.length === 96 || normalizedPublicKey.length === 128 ? "InvalidSignature" /* InvalidSignature */ : "InvalidPublicKey" /* InvalidPublicKey */,
|
|
10818
|
+
curve: normalizedPublicKey.length === 128 ? "secp256r1" : "secp192r1",
|
|
10819
|
+
hashValue: await hashSignedData(document2.signedData, normalizedPublicKey.length === 128 ? 32 : 24),
|
|
10820
|
+
signature
|
|
10821
|
+
};
|
|
10822
|
+
}
|
|
10823
|
+
function parseGetListRes(data) {
|
|
10824
|
+
for (const encoding of guessEncoding(data)) {
|
|
10825
|
+
try {
|
|
10826
|
+
const bytes = decodeWithEncoding(encoding, data);
|
|
10827
|
+
const res = findGetListRes(decodeSmlMessages(stripTransport(bytes)));
|
|
10828
|
+
if (res != null)
|
|
10829
|
+
return res;
|
|
10830
|
+
} catch {
|
|
10831
|
+
}
|
|
10832
|
+
}
|
|
10833
|
+
throw new EDL40ValidationError("SML_NO_GETLISTRES", "No verifiable SML data found");
|
|
10834
|
+
}
|
|
10835
|
+
function guessEncoding(data) {
|
|
10836
|
+
const matches = [];
|
|
10837
|
+
if (data == null || data.trim().length === 0)
|
|
10838
|
+
return matches;
|
|
10839
|
+
try {
|
|
10840
|
+
decodeBase32(data);
|
|
10841
|
+
matches.push("base32");
|
|
10842
|
+
} catch {
|
|
10843
|
+
}
|
|
10844
|
+
try {
|
|
10845
|
+
decodeBase64(data);
|
|
10846
|
+
matches.push("base64");
|
|
10847
|
+
} catch {
|
|
10848
|
+
}
|
|
10849
|
+
try {
|
|
10850
|
+
hexToBytes(data);
|
|
10851
|
+
matches.push("hex");
|
|
10852
|
+
} catch {
|
|
10853
|
+
}
|
|
10854
|
+
return matches;
|
|
10855
|
+
}
|
|
10856
|
+
function decodeWithEncoding(encoding, data) {
|
|
10857
|
+
switch (encoding) {
|
|
10858
|
+
case "base32":
|
|
10859
|
+
return decodeBase32(data);
|
|
10860
|
+
case "base64":
|
|
10861
|
+
return decodeBase64(data);
|
|
10862
|
+
default:
|
|
10863
|
+
return hexToBytes(data);
|
|
10864
|
+
}
|
|
10865
|
+
}
|
|
10866
|
+
function decodeBase64(data) {
|
|
10867
|
+
const clean = data.replace(/\s+/g, "");
|
|
10868
|
+
if (clean.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(clean))
|
|
10869
|
+
throw new Error("Invalid base64 data");
|
|
10870
|
+
return base64ToBytes(clean);
|
|
10871
|
+
}
|
|
10872
|
+
function decodeBase32(data) {
|
|
10873
|
+
const clean = data.replace(/\s+/g, "").replace(/=+$/, "").toUpperCase();
|
|
10874
|
+
if (clean.length === 0)
|
|
10875
|
+
return new Uint8Array(0);
|
|
10876
|
+
if (!/^[A-Z2-7]+$/.test(clean))
|
|
10877
|
+
throw new Error("Invalid base32 data");
|
|
10878
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
10879
|
+
let bits = 0;
|
|
10880
|
+
let value = 0;
|
|
10881
|
+
const out = [];
|
|
10882
|
+
for (const ch of clean) {
|
|
10883
|
+
const idx = alphabet.indexOf(ch);
|
|
10884
|
+
value = value << 5 | idx;
|
|
10885
|
+
bits += 5;
|
|
10886
|
+
if (bits >= 8) {
|
|
10887
|
+
bits -= 8;
|
|
10888
|
+
out.push(value >>> bits & 255);
|
|
10889
|
+
}
|
|
10890
|
+
}
|
|
10891
|
+
return Uint8Array.from(out);
|
|
10892
|
+
}
|
|
10893
|
+
function stripTransport(raw) {
|
|
10894
|
+
const start = indexOfSeq(raw, START_ESCAPE);
|
|
10895
|
+
if (start < 0)
|
|
10896
|
+
return raw;
|
|
10897
|
+
let i = start + START_ESCAPE.length;
|
|
10898
|
+
const out = [];
|
|
10899
|
+
while (i < raw.length) {
|
|
10900
|
+
if (matchSeq(raw, i, ESCAPE)) {
|
|
10901
|
+
if (raw[i + 4] === 26)
|
|
10902
|
+
break;
|
|
10903
|
+
if (matchSeq(raw, i + 4, ESCAPE)) {
|
|
10904
|
+
out.push(27, 27, 27, 27);
|
|
10905
|
+
i += 8;
|
|
10906
|
+
continue;
|
|
10907
|
+
}
|
|
10908
|
+
}
|
|
10909
|
+
const byte = raw[i];
|
|
10910
|
+
if (byte === void 0)
|
|
10911
|
+
break;
|
|
10912
|
+
out.push(byte);
|
|
10913
|
+
i++;
|
|
10914
|
+
}
|
|
10915
|
+
return Uint8Array.from(out);
|
|
10916
|
+
}
|
|
10917
|
+
function readTLV(buf, pos) {
|
|
10918
|
+
if (pos >= buf.length)
|
|
10919
|
+
throw new EDL40ValidationError("SML_INCOMPLETE", "Unexpected end of SML data at " + pos.toString());
|
|
10920
|
+
const tl = byteAt(buf, pos);
|
|
10921
|
+
if (tl === 0)
|
|
10922
|
+
return { value: { kind: "empty" }, next: pos + 1 };
|
|
10923
|
+
if (tl === 1)
|
|
10924
|
+
return { value: null, next: pos + 1 };
|
|
10925
|
+
const type = tl >> 4 & 7;
|
|
10926
|
+
let len = tl & 15;
|
|
10927
|
+
let headerBytes = 1;
|
|
10928
|
+
if (tl & 128) {
|
|
10929
|
+
let p = pos + 1;
|
|
10930
|
+
while (p < buf.length && byteAt(buf, p) & 128) {
|
|
10931
|
+
len = len << 4 | byteAt(buf, p) & 15;
|
|
10932
|
+
p++;
|
|
10933
|
+
headerBytes++;
|
|
10934
|
+
}
|
|
10935
|
+
if (p >= buf.length)
|
|
10936
|
+
throw new EDL40ValidationError("SML_INCOMPLETE", "Truncated multi-byte length");
|
|
10937
|
+
len = len << 4 | byteAt(buf, p) & 15;
|
|
10938
|
+
headerBytes++;
|
|
10939
|
+
}
|
|
10940
|
+
if (type === 7) {
|
|
10941
|
+
let p = pos + headerBytes;
|
|
10942
|
+
const items = [];
|
|
10943
|
+
for (let k = 0; k < len; k++) {
|
|
10944
|
+
const r = readTLV(buf, p);
|
|
10945
|
+
items.push(r.value);
|
|
10946
|
+
p = r.next;
|
|
10947
|
+
}
|
|
10948
|
+
return { value: { kind: "list", items }, next: p };
|
|
10949
|
+
}
|
|
10950
|
+
const dataLen = len - headerBytes;
|
|
10951
|
+
if (dataLen < 0 || pos + headerBytes + dataLen > buf.length)
|
|
10952
|
+
throw new EDL40ValidationError("SML_TLV_INVALID", "Invalid TLV length at " + pos.toString());
|
|
10953
|
+
const data = buf.slice(pos + headerBytes, pos + headerBytes + dataLen);
|
|
10954
|
+
const next = pos + headerBytes + dataLen;
|
|
10955
|
+
switch (type) {
|
|
10956
|
+
case 0:
|
|
10957
|
+
return { value: { kind: "octet", bytes: data }, next };
|
|
10958
|
+
case 4:
|
|
10959
|
+
return { value: { kind: "bool", value: data.length > 0 && data[0] !== 0 }, next };
|
|
10960
|
+
case 5:
|
|
10961
|
+
return { value: { kind: "int", value: toSignedBigInt(data) }, next };
|
|
10962
|
+
case 6:
|
|
10963
|
+
return { value: { kind: "uint", value: toUnsignedBigInt(data) }, next };
|
|
10964
|
+
default:
|
|
10965
|
+
throw new EDL40ValidationError("SML_TLV_INVALID", "Unknown SML type 0x" + type.toString(16));
|
|
10966
|
+
}
|
|
10967
|
+
}
|
|
10968
|
+
function decodeSmlMessages(payload) {
|
|
10969
|
+
const messages = [];
|
|
10970
|
+
let pos = 0;
|
|
10971
|
+
while (pos < payload.length) {
|
|
10972
|
+
if (payload[pos] === 0) {
|
|
10973
|
+
pos++;
|
|
10974
|
+
continue;
|
|
10975
|
+
}
|
|
10976
|
+
const r = readTLV(payload, pos);
|
|
10977
|
+
if (r.next <= pos)
|
|
10978
|
+
break;
|
|
10979
|
+
if (r.value?.kind === "list")
|
|
10980
|
+
messages.push(r.value);
|
|
10981
|
+
pos = r.next;
|
|
10982
|
+
}
|
|
10983
|
+
return messages;
|
|
10984
|
+
}
|
|
10985
|
+
function findGetListRes(messages) {
|
|
10986
|
+
for (const msg of messages) {
|
|
10987
|
+
if (msg.kind !== "list" || msg.items.length < 4)
|
|
10988
|
+
continue;
|
|
10989
|
+
const messageBody = msg.items[3];
|
|
10990
|
+
if (messageBody?.kind !== "list" || messageBody.items.length < 2)
|
|
10991
|
+
continue;
|
|
10992
|
+
const tagNode = messageBody.items[0];
|
|
10993
|
+
const bodyNode = messageBody.items[1];
|
|
10994
|
+
if (tagNode == null || tagNode.kind !== "uint" && tagNode.kind !== "int")
|
|
10995
|
+
continue;
|
|
10996
|
+
if (Number(tagNode.value) !== 1793 || bodyNode == null)
|
|
10997
|
+
continue;
|
|
10998
|
+
const res = parseGetListResNode(bodyNode);
|
|
10999
|
+
if (res != null)
|
|
11000
|
+
return res;
|
|
11001
|
+
}
|
|
11002
|
+
return null;
|
|
11003
|
+
}
|
|
11004
|
+
function parseGetListResNode(body) {
|
|
11005
|
+
if (body.kind !== "list" || body.items.length < 6)
|
|
11006
|
+
return null;
|
|
11007
|
+
const serverId = octet(body.items[1]);
|
|
11008
|
+
const listName = octet(body.items[2]);
|
|
11009
|
+
const valListNode = body.items[4];
|
|
11010
|
+
const listSignature = octet(body.items[5]);
|
|
11011
|
+
if (serverId == null || listSignature == null || valListNode?.kind !== "list")
|
|
11012
|
+
return null;
|
|
11013
|
+
const valList = [];
|
|
11014
|
+
for (const entry of valListNode.items) {
|
|
11015
|
+
const parsed = parseListEntry(entry);
|
|
11016
|
+
if (parsed != null)
|
|
11017
|
+
valList.push(parsed);
|
|
11018
|
+
}
|
|
11019
|
+
return { serverId, listName, valList, listSignature };
|
|
11020
|
+
}
|
|
11021
|
+
function parseListEntry(v) {
|
|
11022
|
+
if (v?.kind !== "list")
|
|
11023
|
+
return null;
|
|
11024
|
+
return {
|
|
11025
|
+
objName: octet(v.items[0]),
|
|
11026
|
+
status: v.items[1] ?? null,
|
|
11027
|
+
valTime: parseSmlTime(v.items[2]),
|
|
11028
|
+
unit: num(v.items[3]),
|
|
11029
|
+
scaler: num(v.items[4]),
|
|
11030
|
+
value: v.items[5] ?? null,
|
|
11031
|
+
valueSignature: octet(v.items[6])
|
|
11032
|
+
};
|
|
11033
|
+
}
|
|
11034
|
+
function findEntryByObis(res, obisHex) {
|
|
11035
|
+
const target = obisHex.toLowerCase();
|
|
11036
|
+
for (const entry of res.valList)
|
|
11037
|
+
if (entry.objName != null && bytesToHex2(entry.objName) === target)
|
|
11038
|
+
return entry;
|
|
11039
|
+
return null;
|
|
11040
|
+
}
|
|
11041
|
+
function parseSmlTime(v) {
|
|
11042
|
+
if (v?.kind !== "list" || v.items.length < 2)
|
|
11043
|
+
return null;
|
|
11044
|
+
const tag = asNumber2(v.items[0]);
|
|
11045
|
+
const body = v.items[1];
|
|
11046
|
+
if (tag === 1)
|
|
11047
|
+
return { kind: "secIndex", timestamp: asNumber2(body), localOffsetMin: 0, seasonOffsetMin: 0 };
|
|
11048
|
+
if (tag === 2)
|
|
11049
|
+
return { kind: "timestamp", timestamp: asNumber2(body), localOffsetMin: 0, seasonOffsetMin: 0 };
|
|
11050
|
+
if (tag === 3 && body?.kind === "list" && body.items.length >= 3)
|
|
11051
|
+
return {
|
|
11052
|
+
kind: "timestampLocal",
|
|
11053
|
+
timestamp: asNumber2(body.items[0]),
|
|
11054
|
+
localOffsetMin: asNumber2(body.items[1]),
|
|
11055
|
+
seasonOffsetMin: asNumber2(body.items[2])
|
|
11056
|
+
};
|
|
11057
|
+
return null;
|
|
11058
|
+
}
|
|
11059
|
+
function resolveSmlTime(t) {
|
|
11060
|
+
const offsetSec = (t.localOffsetMin + t.seasonOffsetMin) * 60;
|
|
11061
|
+
return {
|
|
11062
|
+
localEpoch: t.timestamp + offsetSec,
|
|
11063
|
+
date: new Date(t.timestamp * 1e3)
|
|
11064
|
+
};
|
|
11065
|
+
}
|
|
11066
|
+
function buildEDL40Signature(res) {
|
|
11067
|
+
const listSignature = res.listSignature;
|
|
11068
|
+
const isEmoc = listSignature.length === 66;
|
|
11069
|
+
let signedValueEntry = findEntryByObis(res, OBIS_SIGNED_VALUE);
|
|
11070
|
+
signedValueEntry ??= findEntryByObis(res, OBIS_SIGNED_VALUE_2);
|
|
11071
|
+
if (signedValueEntry == null)
|
|
11072
|
+
throw new EDL40ValidationError("MISSING_FIELD", "EDL40: missing signed value entry");
|
|
11073
|
+
const contractEntry = findEntryByObis(res, OBIS_CONTRACT_ID);
|
|
11074
|
+
const paginationEntry = findEntryByObis(res, OBIS_EDL_PAGINATION);
|
|
11075
|
+
const secondsIndexEntry = findEntryByObis(res, OBIS_EDL_SECONDS_INDEX);
|
|
11076
|
+
const versionEntry = findEntryByObis(res, OBIS_SIGNATURE_VERSION);
|
|
11077
|
+
const unit = signedValueEntry.unit ?? 0;
|
|
11078
|
+
if (unit !== REQUIRED_UNIT)
|
|
11079
|
+
throw new EDL40ValidationError("INVALID_UNIT", "EDL40: unit must be 30 (Wh)");
|
|
11080
|
+
const scaler = signedValueEntry.scaler ?? 0;
|
|
11081
|
+
const meterValue = valueAsLong(signedValueEntry);
|
|
11082
|
+
const obisId = signedValueEntry.objName ?? new Uint8Array(6);
|
|
11083
|
+
let status = 0;
|
|
11084
|
+
if (signedValueEntry.status != null && (signedValueEntry.status.kind === "uint" || signedValueEntry.status.kind === "int"))
|
|
11085
|
+
status = Number(BigInt.asUintN(32, signedValueEntry.status.value)) & 255;
|
|
11086
|
+
if (isEmoc && signedValueEntry.status != null && (signedValueEntry.status.kind === "uint" || signedValueEntry.status.kind === "int"))
|
|
11087
|
+
status = transformEDL40Status(Number(BigInt.asUintN(32, signedValueEntry.status.value)));
|
|
11088
|
+
let pagination = 0;
|
|
11089
|
+
const p = deepFirstInt(paginationEntry?.value);
|
|
11090
|
+
if (p != null)
|
|
11091
|
+
pagination = Number(p);
|
|
11092
|
+
let secondsIndex = 0;
|
|
11093
|
+
const s = deepFirstInt(secondsIndexEntry?.value);
|
|
11094
|
+
if (s != null)
|
|
11095
|
+
secondsIndex = Number(s);
|
|
11096
|
+
let version = 0;
|
|
11097
|
+
const ver = deepFirstInt(versionEntry?.value);
|
|
11098
|
+
if (ver != null)
|
|
11099
|
+
version = Number(ver);
|
|
11100
|
+
const contractRaw = contractEntry?.value?.kind === "octet" ? contractEntry.value.bytes : new Uint8Array(0);
|
|
11101
|
+
const contractId = new Uint8Array(128);
|
|
11102
|
+
contractId.set(contractRaw.subarray(0, 128), 0);
|
|
11103
|
+
const out = new Uint8Array(SIGNATURE_LENGTH);
|
|
11104
|
+
out.set(res.serverId.subarray(0, 10), 0);
|
|
11105
|
+
out.set(timeBytes(signedValueEntry), 10);
|
|
11106
|
+
out[14] = status;
|
|
11107
|
+
out.set(reverseBytes(intToBytesBE(secondsIndex >>> 0)), 15);
|
|
11108
|
+
out.set(reverseBytes(intToBytesBE(pagination >>> 0)), 19);
|
|
11109
|
+
out.set(obisId.subarray(0, 6), 23);
|
|
11110
|
+
out[29] = unit & 255;
|
|
11111
|
+
out[30] = scaler & 255;
|
|
11112
|
+
out.set(reverseBytes(longToBytesBE(meterValue)), 31);
|
|
11113
|
+
out.set(listSignature.subarray(listSignature.length - 2), 39);
|
|
11114
|
+
out.set(contractId, 41);
|
|
11115
|
+
if (contractEntry != null)
|
|
11116
|
+
out.set(timeBytes(contractEntry), 169);
|
|
11117
|
+
return {
|
|
11118
|
+
variant: "EDL_40_P",
|
|
11119
|
+
signedData: out,
|
|
11120
|
+
listSignature,
|
|
11121
|
+
version,
|
|
11122
|
+
isEmoc,
|
|
11123
|
+
unit,
|
|
11124
|
+
scaler,
|
|
11125
|
+
serverId: res.serverId,
|
|
11126
|
+
contractId,
|
|
11127
|
+
pagination,
|
|
11128
|
+
meterValue,
|
|
11129
|
+
obisId,
|
|
11130
|
+
status,
|
|
11131
|
+
meterDate: signedValueEntry.valTime != null ? resolveSmlTime(signedValueEntry.valTime).date : /* @__PURE__ */ new Date(0)
|
|
11132
|
+
};
|
|
11133
|
+
}
|
|
11134
|
+
function buildIsaSignature(res) {
|
|
11135
|
+
const contractEntry = requireEntry(res, OBIS_CONTRACT_ID, "contract-id");
|
|
11136
|
+
const startEntry = requireEntry(res, OBIS_START_EC, "start-ec");
|
|
11137
|
+
const actualEntry = requireEntry(res, OBIS_ACTUAL_EC, "actual-ec");
|
|
11138
|
+
const paginationEntry = requireEntry(res, OBIS_ISA_PAGINATION, "pagination");
|
|
11139
|
+
const esthEntry = requireEntry(res, OBIS_ESTH, "esth");
|
|
11140
|
+
const actualUnit = actualEntry.unit ?? 0;
|
|
11141
|
+
const startUnit = startEntry.unit ?? 0;
|
|
11142
|
+
if (actualUnit !== REQUIRED_UNIT || startUnit !== REQUIRED_UNIT)
|
|
11143
|
+
throw new EDL40ValidationError("INVALID_UNIT", "ISA: unit must be 30 (Wh)");
|
|
11144
|
+
if (paginationEntry.value == null || paginationEntry.value.kind !== "uint" && paginationEntry.value.kind !== "int")
|
|
11145
|
+
throw new EDL40ValidationError("MISSING_FIELD", "ISA: pagination is not an unsigned integer");
|
|
11146
|
+
const contractRaw = contractEntry.value?.kind === "octet" ? contractEntry.value.bytes : new Uint8Array(0);
|
|
11147
|
+
const contractId = new Uint8Array(128);
|
|
11148
|
+
contractId.set(contractRaw.subarray(0, 128), 0);
|
|
11149
|
+
const esth = esthEntry.value?.kind === "octet" ? esthEntry.value.bytes : new Uint8Array(20);
|
|
11150
|
+
const actualStatus = status8(actualEntry);
|
|
11151
|
+
const startStatus = status8(startEntry);
|
|
11152
|
+
const actualValue = valueAsLong(actualEntry);
|
|
11153
|
+
const startValue = valueAsLong(startEntry);
|
|
11154
|
+
const actualSig = actualEntry.valueSignature ?? new Uint8Array(66);
|
|
11155
|
+
const listName = res.listName ?? new Uint8Array(6);
|
|
11156
|
+
const listSignature = res.listSignature;
|
|
11157
|
+
const dataSignature = listSignature.subarray(0, listSignature.length - 2);
|
|
11158
|
+
const pagination = Number(paginationEntry.value.value);
|
|
11159
|
+
const out = new Uint8Array(SIGNATURE_LENGTH);
|
|
11160
|
+
out.set(res.serverId.subarray(0, 10), 0);
|
|
11161
|
+
out.set(timeBytes(actualEntry), 10);
|
|
11162
|
+
out[14] = actualStatus[7] ?? 0;
|
|
11163
|
+
out.set((actualEntry.objName ?? new Uint8Array(6)).subarray(0, 6), 15);
|
|
11164
|
+
out[21] = actualUnit & 255;
|
|
11165
|
+
out[22] = (actualEntry.scaler ?? 0) & 255;
|
|
11166
|
+
out.set(reverseBytes(longToBytesBE(actualValue)), 23);
|
|
11167
|
+
out.set(listSignature.subarray(listSignature.length - 2), 31);
|
|
11168
|
+
out.set(actualSig.subarray(0, 66), 33);
|
|
11169
|
+
out.set(contractId, 99);
|
|
11170
|
+
out.set(timeBytes(startEntry), 227);
|
|
11171
|
+
out.set(esth.subarray(0, 20), 231);
|
|
11172
|
+
out[251] = startStatus[7] ?? 0;
|
|
11173
|
+
out.set((startEntry.objName ?? new Uint8Array(6)).subarray(0, 6), 252);
|
|
11174
|
+
out[258] = startUnit & 255;
|
|
11175
|
+
out[259] = (startEntry.scaler ?? 0) & 255;
|
|
11176
|
+
out.set(reverseBytes(longToBytesBE(startValue)), 260);
|
|
11177
|
+
out.set(listName.subarray(0, 6), 268);
|
|
11178
|
+
out.set(reverseBytes(intToBytesBE(pagination >>> 0)), 274);
|
|
11179
|
+
return {
|
|
11180
|
+
variant: "ISA_EDL_40_P",
|
|
11181
|
+
signedData: out,
|
|
11182
|
+
dataSignature,
|
|
11183
|
+
listSignature,
|
|
11184
|
+
serverId: res.serverId,
|
|
11185
|
+
listName: res.listName,
|
|
11186
|
+
contractId,
|
|
11187
|
+
pagination,
|
|
11188
|
+
unit: actualUnit,
|
|
11189
|
+
actualEcValue: actualValue,
|
|
11190
|
+
actualEcScaler: actualEntry.scaler ?? 0,
|
|
11191
|
+
actualEcObis: actualEntry.objName ?? new Uint8Array(6),
|
|
11192
|
+
actualEcStatus: actualStatus,
|
|
11193
|
+
actualEcDate: actualEntry.valTime != null ? resolveSmlTime(actualEntry.valTime).date : /* @__PURE__ */ new Date(0),
|
|
11194
|
+
startEcValue: startValue,
|
|
11195
|
+
startEcScaler: startEntry.scaler ?? 0,
|
|
11196
|
+
startEcObis: startEntry.objName ?? new Uint8Array(6),
|
|
11197
|
+
startEcStatus: startStatus,
|
|
11198
|
+
startEcDate: startEntry.valTime != null ? resolveSmlTime(startEntry.valTime).date : /* @__PURE__ */ new Date(0)
|
|
11199
|
+
};
|
|
11200
|
+
}
|
|
11201
|
+
function isaListNameContext(listName) {
|
|
11202
|
+
const hex = listName != null ? bytesToHex2(listName) : "";
|
|
11203
|
+
if (hex === "8180816201ff")
|
|
11204
|
+
return "UPDATE";
|
|
11205
|
+
if (hex === "8180816202ff")
|
|
11206
|
+
return "STOP";
|
|
11207
|
+
return "START";
|
|
11208
|
+
}
|
|
11209
|
+
function transformEDL40Status(value) {
|
|
11210
|
+
let b = 0;
|
|
11211
|
+
const set = (targetBit, sourceBit) => {
|
|
11212
|
+
if (value & 1 << sourceBit)
|
|
11213
|
+
b |= 1 << targetBit;
|
|
11214
|
+
};
|
|
11215
|
+
set(0, 17);
|
|
11216
|
+
set(3, 31);
|
|
11217
|
+
set(4, 16);
|
|
11218
|
+
set(5, 11);
|
|
11219
|
+
set(6, 9);
|
|
11220
|
+
set(7, 8);
|
|
11221
|
+
return b & 255;
|
|
11222
|
+
}
|
|
11223
|
+
var EDL40Crypt01 = class extends ACrypt {
|
|
11224
|
+
constructor(chargy) {
|
|
11225
|
+
super(
|
|
11226
|
+
"EDL40/ISA-EDL40",
|
|
11227
|
+
chargy
|
|
11228
|
+
);
|
|
11229
|
+
}
|
|
11230
|
+
async VerifyChargingSession(chargingSession) {
|
|
11231
|
+
let sessionResult = "ValidSignature" /* ValidSignature */;
|
|
11232
|
+
let valueCount = 0;
|
|
11233
|
+
for (const measurement of chargingSession.measurements ?? []) {
|
|
11234
|
+
measurement.chargingSession = chargingSession;
|
|
11235
|
+
for (const measurementValue of measurement.values) {
|
|
11236
|
+
valueCount++;
|
|
11237
|
+
measurementValue.measurement = measurement;
|
|
11238
|
+
const result = await this.VerifyMeasurement(measurementValue);
|
|
11239
|
+
if (result.status !== "ValidSignature" /* ValidSignature */)
|
|
11240
|
+
sessionResult = "InvalidSignature" /* InvalidSignature */;
|
|
11241
|
+
}
|
|
11242
|
+
if (measurement.values.length > 0 && measurement.values.every((value) => value.result?.status === "ValidSignature" /* ValidSignature */)) {
|
|
11243
|
+
measurement.verificationResult = {
|
|
11244
|
+
status: "ValidSignature" /* ValidSignature */
|
|
11245
|
+
};
|
|
11246
|
+
} else {
|
|
11247
|
+
measurement.verificationResult = {
|
|
11248
|
+
status: "InvalidSignature" /* InvalidSignature */
|
|
11249
|
+
};
|
|
11250
|
+
}
|
|
11251
|
+
}
|
|
11252
|
+
if (valueCount === 0)
|
|
11253
|
+
sessionResult = "InvalidSessionFormat" /* InvalidSessionFormat */;
|
|
11254
|
+
return {
|
|
11255
|
+
status: sessionResult,
|
|
11256
|
+
certainty: 0.9
|
|
11257
|
+
};
|
|
11258
|
+
}
|
|
11259
|
+
async VerifyMeasurement(measurementValue) {
|
|
11260
|
+
measurementValue.method = this;
|
|
11261
|
+
const document2 = measurementValue.edl40Document;
|
|
11262
|
+
const result = {
|
|
11263
|
+
status: document2.validationStatus,
|
|
11264
|
+
hashValue: document2.hashValue,
|
|
11265
|
+
signedData: document2.signedData,
|
|
11266
|
+
publicKey: document2.publicKey,
|
|
11267
|
+
publicKeyFormat: document2.publicKeyFormat,
|
|
11268
|
+
signature: document2.signature,
|
|
11269
|
+
serverId: document2.serverId,
|
|
11270
|
+
variant: document2.variant,
|
|
11271
|
+
curve: document2.curve,
|
|
11272
|
+
pagination: document2.pagination.toString(),
|
|
11273
|
+
obis: measurementValue.measurement?.obis,
|
|
11274
|
+
unitEncoded: String(measurementValue.measurement?.unitEncoded ?? ""),
|
|
11275
|
+
scaler: String(measurementValue.measurement?.scale ?? ""),
|
|
11276
|
+
value: measurementValue.value.toString()
|
|
11277
|
+
};
|
|
11278
|
+
measurementValue.result = result;
|
|
11279
|
+
return Promise.resolve(result);
|
|
11280
|
+
}
|
|
11281
|
+
async ViewMeasurement(measurementValue, errorDiv, introDiv, infoDiv, PlainTextDiv, HashedPlainTextDiv, PublicKeyDiv, SignatureExpectedDiv, SignatureCheckDiv) {
|
|
11282
|
+
const result = measurementValue.result;
|
|
11283
|
+
introDiv.innerHTML = this.chargy.GetLocalizedMessage("The following data of the charging session is relevant for metrological and legal metrological purposes and therefore part of the digital signature").replace("{methodName}", "EDL40/ISA-EDL40").replace("{cryptoAlgorithm}", result?.curve ?? "");
|
|
11284
|
+
PlainTextDiv.innerHTML = result?.signedData?.match(/.{1,8}/g)?.join(" ") ?? "";
|
|
11285
|
+
HashedPlainTextDiv.innerHTML = result?.hashValue?.match(/.{1,8}/g)?.join(" ") ?? "";
|
|
11286
|
+
PublicKeyDiv.innerHTML = result?.publicKey?.match(/.{1,8}/g)?.join(" ") ?? "";
|
|
11287
|
+
SignatureExpectedDiv.innerHTML = result?.signature != null ? "r: " + (result.signature.r.match(/.{1,8}/g)?.join(" ") ?? "") + "<br />s: " + (result.signature.s.match(/.{1,8}/g)?.join(" ") ?? "") : "";
|
|
11288
|
+
SignatureCheckDiv.innerHTML = result?.status === "ValidSignature" /* ValidSignature */ ? '<i class="fas fa-check-circle"></i><div id="description">' + this.chargy.GetLocalizedMessage("Valid signature") + "</div>" : '<i class="fas fa-times-circle"></i><div id="description">' + this.chargy.GetLocalizedMessage("Invalid signature") + "</div>";
|
|
11289
|
+
return Promise.resolve(void 0);
|
|
11290
|
+
}
|
|
11291
|
+
};
|
|
11292
|
+
var EDL40 = class {
|
|
11293
|
+
constructor(chargy) {
|
|
11294
|
+
this.chargy = chargy;
|
|
11295
|
+
}
|
|
11296
|
+
chargy;
|
|
11297
|
+
async TryToParseEDL40Documents(signedDataValues, publicKey, containerInfos) {
|
|
11298
|
+
try {
|
|
11299
|
+
if (signedDataValues.length === 0)
|
|
11300
|
+
return {
|
|
11301
|
+
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
11302
|
+
message: this.chargy.GetMultilanguageText("The given EDL40 data could not be parsed!"),
|
|
11303
|
+
certainty: 0
|
|
11304
|
+
};
|
|
11305
|
+
const parsed = signedDataValues.map((signedData) => ({
|
|
11306
|
+
raw: signedData,
|
|
11307
|
+
signature: parseEDL40(signedData)
|
|
11308
|
+
}));
|
|
11309
|
+
const variants = new Set(parsed.map((value) => value.signature.variant));
|
|
11310
|
+
if (variants.size > 1)
|
|
11311
|
+
return {
|
|
11312
|
+
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
11313
|
+
message: this.chargy.GetMultilanguageText("Invalid mixture of different signed data formats within the given XML container!"),
|
|
11314
|
+
certainty: 0
|
|
11315
|
+
};
|
|
11316
|
+
const documents = [];
|
|
11317
|
+
for (const value of parsed) {
|
|
11318
|
+
const verification = await verifyEDL40Document(value.signature, publicKey, this.chargy);
|
|
11319
|
+
const signatureHex = bytesToHex2(verification.signature);
|
|
11320
|
+
const document2 = {
|
|
11321
|
+
"@context": "EDL40",
|
|
11322
|
+
raw: value.raw,
|
|
11323
|
+
variant: value.signature.variant,
|
|
11324
|
+
curve: verification.curve,
|
|
11325
|
+
encoding: "guessed",
|
|
11326
|
+
serverId: bytesToHex2(value.signature.serverId),
|
|
11327
|
+
contractId: bytesToHex2(trimPaddingAtEnd(value.signature.contractId)),
|
|
11328
|
+
publicKey: cleanHex(publicKey),
|
|
11329
|
+
publicKeyFormat: "XY" /* XY */,
|
|
11330
|
+
signedData: bytesToHex2(value.signature.signedData),
|
|
11331
|
+
hashAlgorithm: "SHA256",
|
|
11332
|
+
hashValue: verification.hashValue,
|
|
11333
|
+
signatureHex,
|
|
11334
|
+
signature: rawSignatureToRS(verification.signature),
|
|
11335
|
+
pagination: value.signature.pagination,
|
|
11336
|
+
validationStatus: verification.status
|
|
11337
|
+
};
|
|
11338
|
+
if (value.signature.variant === "ISA_EDL_40_P")
|
|
11339
|
+
document2.listNameContext = isaListNameContext(value.signature.listName);
|
|
11340
|
+
documents.push(document2);
|
|
11341
|
+
}
|
|
11342
|
+
return this.toChargeTransparencyRecord(parsed.map((value) => value.signature), documents, publicKey, containerInfos);
|
|
11343
|
+
} catch (exception) {
|
|
11344
|
+
return {
|
|
11345
|
+
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
11346
|
+
message: this.chargy.GetMultilanguageText(exception instanceof Error ? exception.message : String(exception)),
|
|
11347
|
+
certainty: 0
|
|
11348
|
+
};
|
|
11349
|
+
}
|
|
11350
|
+
}
|
|
11351
|
+
toChargeTransparencyRecord(signatures, documents, publicKey, containerInfos) {
|
|
11352
|
+
const first = getFirstArrayElement(signatures, "Missing EDL40 signature data");
|
|
11353
|
+
const values = this.toMeasurementValues(signatures, documents);
|
|
11354
|
+
const firstValue2 = getFirstArrayElement(values, "Missing EDL40 measurement value");
|
|
11355
|
+
const lastValue = values[values.length - 1] ?? firstValue2;
|
|
11356
|
+
const serverId = bytesToHex2(first.serverId);
|
|
11357
|
+
const meterId = serverId;
|
|
11358
|
+
const sessionId = serverId + "-" + String(first.pagination) + "-" + String(signatures[signatures.length - 1]?.pagination ?? first.pagination);
|
|
11359
|
+
const curve = documents[0]?.curve ?? "secp192r1";
|
|
11360
|
+
const variant = first.variant;
|
|
11361
|
+
const evseId = containerInfos?.chargingStations?.[0]?.EVSEs?.[0]?.["@id"] ?? "DE*GEF*EVSE*EDL40*1";
|
|
11362
|
+
const chargingStation = containerInfos?.chargingStations?.[0] ?? {
|
|
11363
|
+
"@id": "DE*GEF*STATION*EDL40*1",
|
|
11364
|
+
"description": { "en": "EDL40 charging station" }
|
|
11365
|
+
};
|
|
11366
|
+
chargingStation.EVSEs ??= [
|
|
11367
|
+
{
|
|
11368
|
+
"@id": evseId
|
|
11369
|
+
}
|
|
11370
|
+
];
|
|
11371
|
+
let primaryEVSE = chargingStation.EVSEs[0];
|
|
11372
|
+
if (primaryEVSE == null) {
|
|
11373
|
+
primaryEVSE = {
|
|
11374
|
+
"@id": evseId
|
|
11375
|
+
};
|
|
11376
|
+
chargingStation.EVSEs = [primaryEVSE];
|
|
11377
|
+
}
|
|
11378
|
+
primaryEVSE.energyMeters = [
|
|
11379
|
+
{
|
|
11380
|
+
"@id": meterId,
|
|
11381
|
+
"manufacturer": { "name": variant === "ISA_EDL_40_P" ? "ISA" : "EDL40" },
|
|
11382
|
+
"signatureFormat": EDL40_SIGNATURE_CONTEXT,
|
|
11383
|
+
"publicKeys": [
|
|
11384
|
+
{
|
|
11385
|
+
"value": cleanHex(publicKey),
|
|
11386
|
+
"algorithm": curve,
|
|
11387
|
+
"format": "XY" /* XY */,
|
|
11388
|
+
"encoding": "hex" /* hex */
|
|
11389
|
+
}
|
|
11390
|
+
]
|
|
11391
|
+
}
|
|
11392
|
+
];
|
|
11393
|
+
const measurement = {
|
|
11394
|
+
"energyMeterId": meterId,
|
|
11395
|
+
"@context": EDL40_SIGNATURE_CONTEXT,
|
|
11396
|
+
"name": OBIS2MeasurementName(EDL40_OBIS),
|
|
11397
|
+
"obis": EDL40_OBIS,
|
|
11398
|
+
"unit": "kWh",
|
|
11399
|
+
"unitEncoded": 30,
|
|
11400
|
+
"scale": -3,
|
|
11401
|
+
"serverId": serverId,
|
|
11402
|
+
"publicKey": cleanHex(publicKey),
|
|
11403
|
+
"variant": variant,
|
|
11404
|
+
"curve": curve,
|
|
11405
|
+
"signatureInfos": {
|
|
11406
|
+
"hash": "SHA256" /* SHA256 */,
|
|
11407
|
+
"hashTruncation": curve === "secp192r1" ? 24 : 32,
|
|
11408
|
+
"algorithm": "ECC" /* ECC */,
|
|
11409
|
+
"curve": curve,
|
|
11410
|
+
"format": "RS" /* RS */,
|
|
11411
|
+
"encoding": "hex" /* hex */
|
|
11412
|
+
},
|
|
11413
|
+
"values": values
|
|
11414
|
+
};
|
|
11415
|
+
const firstDocument = documents[0];
|
|
11416
|
+
const authorizationStart = firstDocument?.contractId != null && firstDocument.contractId.length > 0 ? {
|
|
11417
|
+
"@id": firstDocument.contractId
|
|
11418
|
+
} : void 0;
|
|
11419
|
+
const chargingSession = {
|
|
11420
|
+
"@id": sessionId,
|
|
11421
|
+
"@context": EDL40_SESSION_CONTEXT,
|
|
11422
|
+
"begin": firstValue2.timestamp,
|
|
11423
|
+
"end": lastValue.timestamp,
|
|
11424
|
+
"internalSessionId": sessionId,
|
|
11425
|
+
"EVSEId": evseId,
|
|
11426
|
+
"meterId": meterId,
|
|
11427
|
+
"authorizationStart": authorizationStart,
|
|
11428
|
+
"measurements": [
|
|
11429
|
+
measurement
|
|
11430
|
+
]
|
|
11431
|
+
};
|
|
11432
|
+
return {
|
|
11433
|
+
"@id": sessionId,
|
|
11434
|
+
"@context": "https://open.charging.cloud/contexts/CTR+json",
|
|
11435
|
+
"begin": chargingSession.begin,
|
|
11436
|
+
"end": chargingSession.end,
|
|
11437
|
+
"description": {
|
|
11438
|
+
"de": "EDL40/ISA-EDL40 Ladevorgang",
|
|
11439
|
+
"en": "EDL40/ISA-EDL40 charging session"
|
|
11440
|
+
},
|
|
11441
|
+
"chargingStations": [
|
|
11442
|
+
chargingStation
|
|
11443
|
+
],
|
|
11444
|
+
"chargingSessions": [
|
|
11445
|
+
chargingSession
|
|
11446
|
+
],
|
|
11447
|
+
"publicKeys": [
|
|
11448
|
+
{
|
|
11449
|
+
"@context": "https://open.charging.cloud/contexts/publicKey+json",
|
|
11450
|
+
"subject": meterId,
|
|
11451
|
+
"algorithm": curve,
|
|
11452
|
+
"encoding": "hex" /* hex */,
|
|
11453
|
+
"format": "XY" /* XY */,
|
|
11454
|
+
"value": cleanHex(publicKey),
|
|
11455
|
+
"certainty": 1
|
|
11456
|
+
}
|
|
11457
|
+
],
|
|
11458
|
+
"warnings": containerInfos?.warnings,
|
|
11459
|
+
"edl40": {
|
|
11460
|
+
variant,
|
|
11461
|
+
serverId,
|
|
11462
|
+
paginationStart: first.pagination,
|
|
11463
|
+
paginationEnd: signatures[signatures.length - 1]?.pagination ?? first.pagination
|
|
11464
|
+
},
|
|
11465
|
+
"certainty": 1,
|
|
11466
|
+
"status": "Unvalidated" /* Unvalidated */
|
|
11467
|
+
};
|
|
11468
|
+
}
|
|
11469
|
+
toMeasurementValues(signatures, documents) {
|
|
11470
|
+
const values = [];
|
|
11471
|
+
for (let index = 0; index < signatures.length; index++) {
|
|
11472
|
+
const signature = getArrayElement(signatures, index, "Missing EDL40 signature data");
|
|
11473
|
+
const document2 = getArrayElement(documents, index, "Missing EDL40 document");
|
|
11474
|
+
if (signature.variant === "ISA_EDL_40_P") {
|
|
11475
|
+
values.push(this.toValue(
|
|
11476
|
+
signature.startEcDate,
|
|
11477
|
+
signature.startEcValue,
|
|
11478
|
+
signature.startEcScaler,
|
|
11479
|
+
bytesToHex2(signature.startEcStatus),
|
|
11480
|
+
signature.pagination,
|
|
11481
|
+
document2
|
|
11482
|
+
));
|
|
11483
|
+
values.push(this.toValue(
|
|
11484
|
+
signature.actualEcDate,
|
|
11485
|
+
signature.actualEcValue,
|
|
11486
|
+
signature.actualEcScaler,
|
|
11487
|
+
bytesToHex2(signature.actualEcStatus),
|
|
11488
|
+
signature.pagination,
|
|
11489
|
+
document2
|
|
11490
|
+
));
|
|
11491
|
+
} else {
|
|
11492
|
+
values.push(this.toValue(
|
|
11493
|
+
signature.meterDate,
|
|
11494
|
+
signature.meterValue,
|
|
11495
|
+
signature.scaler,
|
|
11496
|
+
signature.status.toString(16).padStart(2, "0"),
|
|
11497
|
+
signature.pagination,
|
|
11498
|
+
document2
|
|
11499
|
+
));
|
|
11500
|
+
}
|
|
11501
|
+
}
|
|
11502
|
+
return values.sort((left, right) => left.timestamp.localeCompare(right.timestamp));
|
|
11503
|
+
}
|
|
11504
|
+
toValue(timestamp, valueWh, scaler, statusMeter, pagination, document2) {
|
|
11505
|
+
return {
|
|
11506
|
+
"timestamp": timestamp.toISOString(),
|
|
11507
|
+
"value": scaledWhToKWh(valueWh, scaler),
|
|
11508
|
+
"statusMeter": statusMeter,
|
|
11509
|
+
"paginationId": pagination,
|
|
11510
|
+
"signatures": [
|
|
11511
|
+
document2.signature
|
|
11512
|
+
],
|
|
11513
|
+
"edl40Document": document2,
|
|
11514
|
+
"result": {
|
|
11515
|
+
"status": document2.validationStatus
|
|
11516
|
+
}
|
|
11517
|
+
};
|
|
11518
|
+
}
|
|
11519
|
+
};
|
|
11520
|
+
async function hashSignedData(signedData, crop) {
|
|
11521
|
+
return bytesToHex2((await sha256____(signedData)).subarray(0, crop));
|
|
11522
|
+
}
|
|
11523
|
+
function verifyRawSignature(chargy, curve, publicKey, signature, hashValue) {
|
|
11524
|
+
try {
|
|
11525
|
+
const ec = curve === "secp192r1" ? new chargy.elliptic.ec("p192") : new chargy.elliptic.ec("p256");
|
|
11526
|
+
const verified = ec.keyFromPublic("04" + publicKey, "hex").verify(hashValue.toUpperCase(), rawSignatureToRS(signature));
|
|
11527
|
+
return verified ? "ValidSignature" /* ValidSignature */ : "InvalidSignature" /* InvalidSignature */;
|
|
11528
|
+
} catch {
|
|
11529
|
+
return "InvalidSignature" /* InvalidSignature */;
|
|
11530
|
+
}
|
|
11531
|
+
}
|
|
11532
|
+
function rawSignatureToRS(signature) {
|
|
11533
|
+
const signatureHex = bytesToHex2(signature);
|
|
11534
|
+
const half = signatureHex.length / 2;
|
|
11535
|
+
return {
|
|
11536
|
+
algorithm: "ECC" /* ECC */,
|
|
11537
|
+
format: "RS" /* RS */,
|
|
11538
|
+
value: signatureHex,
|
|
11539
|
+
r: signatureHex.substring(0, half),
|
|
11540
|
+
s: signatureHex.substring(half)
|
|
11541
|
+
};
|
|
11542
|
+
}
|
|
11543
|
+
function scaledWhToKWh(valueWh, scaler) {
|
|
11544
|
+
return new Decimal(valueWh.toString()).mul(new Decimal(10).pow(scaler)).div(1e3);
|
|
11545
|
+
}
|
|
11546
|
+
function timeBytes(entry) {
|
|
11547
|
+
if (entry.valTime == null)
|
|
11548
|
+
throw new EDL40ValidationError("MISSING_FIELD", "EDL40/ISA: missing valTime");
|
|
11549
|
+
return reverseBytes(intToBytesBE(resolveSmlTime(entry.valTime).localEpoch >>> 0));
|
|
11550
|
+
}
|
|
11551
|
+
function valueAsLong(entry) {
|
|
11552
|
+
if (entry.value?.kind === "int" || entry.value?.kind === "uint")
|
|
11553
|
+
return entry.value.value;
|
|
11554
|
+
if (entry.value?.kind === "octet")
|
|
11555
|
+
return toSignedBigInt(entry.value.bytes);
|
|
11556
|
+
return 0n;
|
|
11557
|
+
}
|
|
11558
|
+
function requireEntry(res, obis, label) {
|
|
11559
|
+
const entry = findEntryByObis(res, obis);
|
|
11560
|
+
if (entry == null)
|
|
11561
|
+
throw new EDL40ValidationError("MISSING_FIELD", "ISA: missing " + label + " entry (OBIS " + obis + ")");
|
|
11562
|
+
return entry;
|
|
11563
|
+
}
|
|
11564
|
+
function status8(entry) {
|
|
11565
|
+
const value = entry.status;
|
|
11566
|
+
if (value != null && (value.kind === "uint" || value.kind === "int"))
|
|
11567
|
+
return longToBytesBE(BigInt.asUintN(64, value.value));
|
|
11568
|
+
return new Uint8Array(8);
|
|
11569
|
+
}
|
|
11570
|
+
function deepFirstInt(value) {
|
|
11571
|
+
if (value == null)
|
|
11572
|
+
return null;
|
|
11573
|
+
if (value.kind === "uint" || value.kind === "int")
|
|
11574
|
+
return value.value;
|
|
11575
|
+
if (value.kind === "list")
|
|
11576
|
+
for (let i = value.items.length - 1; i >= 0; i--) {
|
|
11577
|
+
const result = deepFirstInt(value.items[i]);
|
|
11578
|
+
if (result != null)
|
|
11579
|
+
return result;
|
|
11580
|
+
}
|
|
11581
|
+
return null;
|
|
11582
|
+
}
|
|
11583
|
+
function octet(value) {
|
|
11584
|
+
return value?.kind === "octet" ? value.bytes : null;
|
|
11585
|
+
}
|
|
11586
|
+
function num(value) {
|
|
11587
|
+
if (value?.kind === "uint" || value?.kind === "int")
|
|
11588
|
+
return Number(value.value);
|
|
11589
|
+
return null;
|
|
11590
|
+
}
|
|
11591
|
+
function asNumber2(value) {
|
|
11592
|
+
if (value?.kind === "uint" || value?.kind === "int")
|
|
11593
|
+
return Number(value.value);
|
|
11594
|
+
return 0;
|
|
11595
|
+
}
|
|
11596
|
+
function intToBytesBE(value) {
|
|
11597
|
+
return Uint8Array.from([
|
|
11598
|
+
value >>> 24 & 255,
|
|
11599
|
+
value >>> 16 & 255,
|
|
11600
|
+
value >>> 8 & 255,
|
|
11601
|
+
value & 255
|
|
11602
|
+
]);
|
|
11603
|
+
}
|
|
11604
|
+
function longToBytesBE(value) {
|
|
11605
|
+
const out = new Uint8Array(8);
|
|
11606
|
+
let v = BigInt.asUintN(64, value);
|
|
11607
|
+
for (let i = 7; i >= 0; i--) {
|
|
11608
|
+
out[i] = Number(v & 0xffn);
|
|
11609
|
+
v >>= 8n;
|
|
11610
|
+
}
|
|
11611
|
+
return out;
|
|
11612
|
+
}
|
|
11613
|
+
function reverseBytes(bytes) {
|
|
11614
|
+
const out = new Uint8Array(bytes.length);
|
|
11615
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
11616
|
+
const byte = bytes[i];
|
|
11617
|
+
if (byte !== void 0)
|
|
11618
|
+
out[bytes.length - 1 - i] = byte;
|
|
11619
|
+
}
|
|
11620
|
+
return out;
|
|
11621
|
+
}
|
|
11622
|
+
function toUnsignedBigInt(bytes) {
|
|
11623
|
+
let value = 0n;
|
|
11624
|
+
for (const byte of bytes)
|
|
11625
|
+
value = value << 8n | BigInt(byte);
|
|
11626
|
+
return value;
|
|
11627
|
+
}
|
|
11628
|
+
function toSignedBigInt(bytes) {
|
|
11629
|
+
if (bytes.length === 0)
|
|
11630
|
+
return 0n;
|
|
11631
|
+
let value = toUnsignedBigInt(bytes);
|
|
11632
|
+
const bits = BigInt(bytes.length * 8);
|
|
11633
|
+
const signBit = 1n << bits - 1n;
|
|
11634
|
+
if (value & signBit)
|
|
11635
|
+
value -= 1n << bits;
|
|
11636
|
+
return value;
|
|
11637
|
+
}
|
|
11638
|
+
function trimPaddingAtEnd(bytes) {
|
|
11639
|
+
let end = bytes.length;
|
|
11640
|
+
while (end > 0 && bytes[end - 1] === 0)
|
|
11641
|
+
end--;
|
|
11642
|
+
return bytes.subarray(0, end);
|
|
11643
|
+
}
|
|
11644
|
+
function indexOfSeq(haystack, needle) {
|
|
11645
|
+
outer: for (let i = 0; i + needle.length <= haystack.length; i++) {
|
|
11646
|
+
for (let j = 0; j < needle.length; j++)
|
|
11647
|
+
if (haystack[i + j] !== needle[j])
|
|
11648
|
+
continue outer;
|
|
11649
|
+
return i;
|
|
11650
|
+
}
|
|
11651
|
+
return -1;
|
|
11652
|
+
}
|
|
11653
|
+
function matchSeq(buf, pos, seq) {
|
|
11654
|
+
if (pos + seq.length > buf.length)
|
|
11655
|
+
return false;
|
|
11656
|
+
for (let i = 0; i < seq.length; i++)
|
|
11657
|
+
if (buf[pos + i] !== seq[i])
|
|
11658
|
+
return false;
|
|
11659
|
+
return true;
|
|
11660
|
+
}
|
|
11661
|
+
function bytesToHex2(bytes) {
|
|
11662
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
11663
|
+
}
|
|
11664
|
+
function byteAt(bytes, index) {
|
|
11665
|
+
const byte = bytes[index];
|
|
11666
|
+
if (byte === void 0)
|
|
11667
|
+
throw new EDL40ValidationError("SML_INCOMPLETE", "Unexpected end of SML data at " + index.toString());
|
|
11668
|
+
return byte;
|
|
11669
|
+
}
|
|
11670
|
+
|
|
10617
11671
|
// src/interfaces/CryptoUtils.ts
|
|
10618
11672
|
var import_elliptic = __toESM(require_elliptic());
|
|
10619
11673
|
var JSONSignatureVerificationStatus = /* @__PURE__ */ ((JSONSignatureVerificationStatus2) => {
|
|
@@ -11375,117 +12429,6 @@ var GDFCrypt01 = class extends ACrypt {
|
|
|
11375
12429
|
return void 0;
|
|
11376
12430
|
}
|
|
11377
12431
|
};
|
|
11378
|
-
|
|
11379
|
-
// src/interfaces/IPublicKeyInfo.ts
|
|
11380
|
-
var IPublicKeyInfo_exports = {};
|
|
11381
|
-
__export(IPublicKeyInfo_exports, {
|
|
11382
|
-
IsAPublicKey: () => IsAPublicKey,
|
|
11383
|
-
IsAPublicKeyLookup: () => IsAPublicKeyLookup,
|
|
11384
|
-
IsAPublicKeySignature: () => IsAPublicKeySignature,
|
|
11385
|
-
IsAPublicKeyXY: () => IsAPublicKeyXY,
|
|
11386
|
-
PublicKeyFormats: () => PublicKeyFormats,
|
|
11387
|
-
isPublicKeySubject: () => isPublicKeySubject
|
|
11388
|
-
});
|
|
11389
|
-
var PublicKeyFormats = /* @__PURE__ */ ((PublicKeyFormats2) => {
|
|
11390
|
-
PublicKeyFormats2["DER"] = "DER";
|
|
11391
|
-
PublicKeyFormats2["XY"] = "XY";
|
|
11392
|
-
return PublicKeyFormats2;
|
|
11393
|
-
})(PublicKeyFormats || {});
|
|
11394
|
-
function IsAPublicKeyLookup(data) {
|
|
11395
|
-
if (!isMandatoryJSONObject(data))
|
|
11396
|
-
return false;
|
|
11397
|
-
return Array.isArray(data["publicKeys"]);
|
|
11398
|
-
}
|
|
11399
|
-
function IsAPublicKey(data) {
|
|
11400
|
-
if (!isMandatoryJSONObject(data))
|
|
11401
|
-
return false;
|
|
11402
|
-
if (data["@context"] !== void 0 && !isStringOrStringArray(data["@context"])) {
|
|
11403
|
-
return false;
|
|
11404
|
-
}
|
|
11405
|
-
if (!isPublicKeySubject(data["subject"]))
|
|
11406
|
-
return false;
|
|
11407
|
-
if (data["value"] !== void 0 && !isString(data["value"])) {
|
|
11408
|
-
return false;
|
|
11409
|
-
}
|
|
11410
|
-
if (data["value"] === void 0 && (data["x"] === void 0 || data["y"] === void 0)) {
|
|
11411
|
-
return false;
|
|
11412
|
-
}
|
|
11413
|
-
if (data["value"] !== void 0 && !isStringOrOIDInfo(data["algorithm"])) {
|
|
11414
|
-
return false;
|
|
11415
|
-
}
|
|
11416
|
-
if (data["certainty"] !== void 0 && (typeof data["certainty"] !== "number" || !Number.isFinite(data["certainty"]))) {
|
|
11417
|
-
return false;
|
|
11418
|
-
}
|
|
11419
|
-
if (data["type"] !== void 0 && !isStringOrOIDInfo(data["type"])) {
|
|
11420
|
-
return false;
|
|
11421
|
-
}
|
|
11422
|
-
if (data["encoding"] !== void 0 && typeof data["encoding"] !== "string") {
|
|
11423
|
-
return false;
|
|
11424
|
-
}
|
|
11425
|
-
if (data["signatures"] !== void 0 && (!Array.isArray(data["signatures"]) || !data["signatures"].every(IsAPublicKeySignature))) {
|
|
11426
|
-
return false;
|
|
11427
|
-
}
|
|
11428
|
-
return true;
|
|
11429
|
-
}
|
|
11430
|
-
function isPublicKeySubject(data) {
|
|
11431
|
-
if (data === void 0)
|
|
11432
|
-
return true;
|
|
11433
|
-
if (isStringOrStringArray(data))
|
|
11434
|
-
return true;
|
|
11435
|
-
if (!isMandatoryJSONObject(data))
|
|
11436
|
-
return false;
|
|
11437
|
-
return Object.values(data).every(
|
|
11438
|
-
(value) => typeof value === "string" || isStringOrStringArray(value)
|
|
11439
|
-
);
|
|
11440
|
-
}
|
|
11441
|
-
function IsAPublicKeySignature(data) {
|
|
11442
|
-
if (!isMandatoryJSONObject(data))
|
|
11443
|
-
return false;
|
|
11444
|
-
if (!isOptionalString(data["@id"]))
|
|
11445
|
-
return false;
|
|
11446
|
-
if (data["@context"] !== void 0 && !isStringOrStringArray(data["@context"]))
|
|
11447
|
-
return false;
|
|
11448
|
-
if (!isOptionalStringOrOIDInfo(data["algorithm"]))
|
|
11449
|
-
return false;
|
|
11450
|
-
if (!isOptionalString(data["format"]))
|
|
11451
|
-
return false;
|
|
11452
|
-
if (!isOptionalString(data["encoding"]))
|
|
11453
|
-
return false;
|
|
11454
|
-
if (data["value"] !== void 0 && !isString(data["value"]))
|
|
11455
|
-
return false;
|
|
11456
|
-
if (data["publicKey"] !== void 0 && !isEncodedValue(data["publicKey"]))
|
|
11457
|
-
return false;
|
|
11458
|
-
if (data["signature"] !== void 0 && !isEncodedValue(data["signature"]))
|
|
11459
|
-
return false;
|
|
11460
|
-
if (!isOptionalString(data["timestamp"]))
|
|
11461
|
-
return false;
|
|
11462
|
-
if (!isOptionalString(data["issuer"]))
|
|
11463
|
-
return false;
|
|
11464
|
-
if (!isOptionalString(data["signer"]))
|
|
11465
|
-
return false;
|
|
11466
|
-
if (!isOptionalString(data["notBefore"]))
|
|
11467
|
-
return false;
|
|
11468
|
-
if (!isOptionalString(data["notAfter"]))
|
|
11469
|
-
return false;
|
|
11470
|
-
if (!isOptionalStringArray(data["keyUsage"]))
|
|
11471
|
-
return false;
|
|
11472
|
-
if (data["operations"] !== void 0 && !isMandatoryJSONObject(data["operations"]))
|
|
11473
|
-
return false;
|
|
11474
|
-
if (data["comment"] !== void 0 && !isMandatoryJSONObject(data["comment"]))
|
|
11475
|
-
return false;
|
|
11476
|
-
return data["value"] !== void 0 || data["signature"] !== void 0 || data["algorithm"] !== void 0 || data["timestamp"] !== void 0 || data["issuer"] !== void 0 || data["signer"] !== void 0 || data["keyUsage"] !== void 0;
|
|
11477
|
-
}
|
|
11478
|
-
function IsAPublicKeyXY(data) {
|
|
11479
|
-
if (!IsAPublicKey(data))
|
|
11480
|
-
return false;
|
|
11481
|
-
if (!isString(data["x"])) {
|
|
11482
|
-
return false;
|
|
11483
|
-
}
|
|
11484
|
-
if (!isString(data["y"])) {
|
|
11485
|
-
return false;
|
|
11486
|
-
}
|
|
11487
|
-
return true;
|
|
11488
|
-
}
|
|
11489
12432
|
var MENNEKES_EDL40_XMLNS = "http://www.mennekes.de/Mennekes.EdlVerification.xsd";
|
|
11490
12433
|
var MENNEKES_EDL40_OBIS = "1-0:1.17.0*255";
|
|
11491
12434
|
var Mennekes = class {
|
|
@@ -12223,6 +13166,9 @@ var OCMF = class {
|
|
|
12223
13166
|
//#region (private) tryToParseOCMFv1_0(OCMFDataList, ContainerInfos?)
|
|
12224
13167
|
tryToParseOCMFv1_0(OCMFJSONDocuments, ContainerInfos) {
|
|
12225
13168
|
try {
|
|
13169
|
+
const containerChargingStation = ContainerInfos?.chargingStations?.[0];
|
|
13170
|
+
const containerEVSE = containerChargingStation?.EVSEs?.[0] ?? ContainerInfos?.EVSEs?.[0];
|
|
13171
|
+
const containerConnector = containerEVSE?.connectors?.[0] ?? ContainerInfos?.connectors?.[0];
|
|
12226
13172
|
const firstOCMDJSONDocument = getFirstArrayElement(OCMFJSONDocuments, "Missing first OCMF JSON document");
|
|
12227
13173
|
const formatVersion = firstOCMDJSONDocument.payload.FV;
|
|
12228
13174
|
const gatewayInformation = firstOCMDJSONDocument.payload.GI ?? firstOCMDJSONDocument.payload.VI;
|
|
@@ -12359,7 +13305,6 @@ var OCMF = class {
|
|
|
12359
13305
|
"@context": "https://open.charging.cloud/contexts/SessionSignatureFormats/OCMFv1.0+json",
|
|
12360
13306
|
"begin": "?",
|
|
12361
13307
|
"end": "?",
|
|
12362
|
-
//"EVSEId": evseId,
|
|
12363
13308
|
"authorizationStart": {
|
|
12364
13309
|
"@id": identificationData ?? "?",
|
|
12365
13310
|
"type": identificationType ?? "?",
|
|
@@ -12374,6 +13319,18 @@ var OCMF = class {
|
|
|
12374
13319
|
};
|
|
12375
13320
|
if (ContainerInfos?.chargingStations !== void 0)
|
|
12376
13321
|
CTR.chargingStations = ContainerInfos.chargingStations;
|
|
13322
|
+
if (containerChargingStation !== void 0 && CTR.chargingSessions?.[0] !== void 0) {
|
|
13323
|
+
CTR.chargingSessions[0].chargingStationId = containerChargingStation["@id"];
|
|
13324
|
+
CTR.chargingSessions[0].chargingStation = containerChargingStation;
|
|
13325
|
+
}
|
|
13326
|
+
if (containerEVSE !== void 0 && CTR.chargingSessions?.[0] !== void 0) {
|
|
13327
|
+
CTR.chargingSessions[0].EVSEId = containerEVSE["@id"];
|
|
13328
|
+
CTR.chargingSessions[0].EVSE = containerEVSE;
|
|
13329
|
+
}
|
|
13330
|
+
if (containerConnector !== void 0 && CTR.chargingSessions?.[0] !== void 0) {
|
|
13331
|
+
CTR.chargingSessions[0].ConnectorId = containerConnector["@id"];
|
|
13332
|
+
CTR.chargingSessions[0].Connector = containerConnector;
|
|
13333
|
+
}
|
|
12377
13334
|
const measurementsByKey = /* @__PURE__ */ new Map();
|
|
12378
13335
|
for (const ocmfJSONDocument of OCMFJSONDocuments) {
|
|
12379
13336
|
let inheritedReading = {};
|
|
@@ -12508,6 +13465,8 @@ var OCMF = class {
|
|
|
12508
13465
|
}
|
|
12509
13466
|
if (ContainerInfos?.chargingStations !== void 0)
|
|
12510
13467
|
CTR.chargingStations = ContainerInfos.chargingStations;
|
|
13468
|
+
if (ContainerInfos?.warnings !== void 0)
|
|
13469
|
+
CTR.warnings = [...CTR.warnings ?? [], ...ContainerInfos.warnings];
|
|
12511
13470
|
CTR.status = OCMFJSONDocuments.every((ocmfJSONDocument) => ocmfJSONDocument.validationStatus === "ValidSignature" /* ValidSignature */) ? "ValidSignature" /* ValidSignature */ : "InvalidSignature" /* InvalidSignature */;
|
|
12512
13471
|
if (CTR.chargingSessions != null && CTR.chargingSessions.length > 0 && CTR.chargingSessions[0]) {
|
|
12513
13472
|
CTR.begin = CTR.chargingSessions[0].begin;
|
|
@@ -14031,31 +14990,26 @@ var SAFEXML = class _SAFEXML {
|
|
|
14031
14990
|
}
|
|
14032
14991
|
static ParseContainerInfos(XMLDocument, chargy) {
|
|
14033
14992
|
const containerInfos = {};
|
|
14993
|
+
const addWarning = (message) => {
|
|
14994
|
+
containerInfos.warnings ??= [];
|
|
14995
|
+
containerInfos.warnings.push(
|
|
14996
|
+
CreateWarning(chargy.GetMultilanguageText(message))
|
|
14997
|
+
);
|
|
14998
|
+
};
|
|
14034
14999
|
const chargingStationElements = getElementsByLocalName(XMLDocument, "chargingStation");
|
|
14035
15000
|
if (chargingStationElements.length == 0)
|
|
14036
15001
|
return containerInfos;
|
|
14037
|
-
if (chargingStationElements.length > 1)
|
|
14038
|
-
|
|
14039
|
-
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
14040
|
-
message: chargy.GetMultilanguageText("Only one chargingStation element is allowed within the given SAFE XML container!"),
|
|
14041
|
-
certainty: 0
|
|
14042
|
-
};
|
|
14043
|
-
}
|
|
15002
|
+
if (chargingStationElements.length > 1)
|
|
15003
|
+
addWarning("Only one chargingStation element is allowed within the given SAFE XML container!");
|
|
14044
15004
|
if (chargingStationElements[0] === void 0) {
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
message: chargy.GetMultilanguageText("The chargingStation element within the given SAFE XML container is invalid!"),
|
|
14048
|
-
certainty: 0
|
|
14049
|
-
};
|
|
15005
|
+
addWarning("The chargingStation element within the given SAFE XML container is invalid!");
|
|
15006
|
+
return containerInfos;
|
|
14050
15007
|
}
|
|
14051
15008
|
const chargingStationElement = chargingStationElements[0];
|
|
14052
15009
|
const chargingStationId = chargingStationElement.getAttribute("id")?.trim();
|
|
14053
15010
|
if (chargingStationId === void 0 || chargingStationId.length == 0) {
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
message: chargy.GetMultilanguageText("The chargingStation identifier within the given SAFE XML container is invalid!"),
|
|
14057
|
-
certainty: 0
|
|
14058
|
-
};
|
|
15011
|
+
addWarning("The chargingStation identifier within the given SAFE XML container is invalid!");
|
|
15012
|
+
return containerInfos;
|
|
14059
15013
|
}
|
|
14060
15014
|
const chargingStation = {
|
|
14061
15015
|
"@id": chargingStationId
|
|
@@ -14085,19 +15039,11 @@ var SAFEXML = class _SAFEXML {
|
|
|
14085
15039
|
chargingStation.geoLocation = geoLocation;
|
|
14086
15040
|
}
|
|
14087
15041
|
const evseElements = getElementsByLocalName(chargingStationElement, "EVSE");
|
|
14088
|
-
if (evseElements.length > 1)
|
|
14089
|
-
|
|
14090
|
-
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
14091
|
-
message: chargy.GetMultilanguageText("Only one EVSE element is allowed within the given SAFE XML chargingStation element!"),
|
|
14092
|
-
certainty: 0
|
|
14093
|
-
};
|
|
14094
|
-
}
|
|
15042
|
+
if (evseElements.length > 1)
|
|
15043
|
+
addWarning("Only one EVSE element is allowed within the given SAFE XML chargingStation element!");
|
|
14095
15044
|
if (evseElements[0] === void 0) {
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
message: chargy.GetMultilanguageText("The EVSE element within the given SAFE XML chargingStation element is invalid!"),
|
|
14099
|
-
certainty: 0
|
|
14100
|
-
};
|
|
15045
|
+
addWarning("The EVSE element within the given SAFE XML chargingStation element is invalid!");
|
|
15046
|
+
return containerInfos;
|
|
14101
15047
|
}
|
|
14102
15048
|
const evseElement = evseElements[0];
|
|
14103
15049
|
const evseId = evseElement.getAttribute("id")?.trim();
|
|
@@ -14110,19 +15056,11 @@ var SAFEXML = class _SAFEXML {
|
|
|
14110
15056
|
if (evseDescription !== void 0)
|
|
14111
15057
|
evse.description = evseDescription;
|
|
14112
15058
|
const connectorElements = getElementsByLocalName(evseElement, "connector");
|
|
14113
|
-
if (connectorElements.length > 1)
|
|
14114
|
-
|
|
14115
|
-
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
14116
|
-
message: chargy.GetMultilanguageText("Only one connector element is allowed within the given SAFE XML EVSE element!"),
|
|
14117
|
-
certainty: 0
|
|
14118
|
-
};
|
|
14119
|
-
}
|
|
15059
|
+
if (connectorElements.length > 1)
|
|
15060
|
+
addWarning("Only one connector element is allowed within the given SAFE XML EVSE element!");
|
|
14120
15061
|
if (connectorElements[0] === void 0) {
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
message: chargy.GetMultilanguageText("The connector element within the given SAFE XML EVSE element is invalid!"),
|
|
14124
|
-
certainty: 0
|
|
14125
|
-
};
|
|
15062
|
+
addWarning("The connector element within the given SAFE XML EVSE element is invalid!");
|
|
15063
|
+
return containerInfos;
|
|
14126
15064
|
}
|
|
14127
15065
|
const connectorElement = connectorElements[0];
|
|
14128
15066
|
const connector = {};
|
|
@@ -14145,8 +15083,6 @@ var SAFEXML = class _SAFEXML {
|
|
|
14145
15083
|
XMLDocument,
|
|
14146
15084
|
this.chargy
|
|
14147
15085
|
);
|
|
14148
|
-
if (isISessionCryptoResult1(safeXMLContext))
|
|
14149
|
-
return safeXMLContext;
|
|
14150
15086
|
const signedDataValues = new Array();
|
|
14151
15087
|
let commonSignedDataFormat = "";
|
|
14152
15088
|
let commonSignedDataEncoding = "";
|
|
@@ -14240,6 +15176,14 @@ var SAFEXML = class _SAFEXML {
|
|
|
14240
15176
|
commonPublicKeyEncoding,
|
|
14241
15177
|
safeXMLContext
|
|
14242
15178
|
);
|
|
15179
|
+
case "edl_40_p":
|
|
15180
|
+
case "isa_edl_40_p":
|
|
15181
|
+
case "sml_edl40_p":
|
|
15182
|
+
return await new EDL40(this.chargy).TryToParseEDL40Documents(
|
|
15183
|
+
signedDataValues,
|
|
15184
|
+
commonPublicKey,
|
|
15185
|
+
safeXMLContext
|
|
15186
|
+
);
|
|
14243
15187
|
default:
|
|
14244
15188
|
return {
|
|
14245
15189
|
status: "InvalidSessionFormat" /* InvalidSessionFormat */,
|
|
@@ -16465,45 +17409,6 @@ var Chargy = class {
|
|
|
16465
17409
|
return fileName.substring(0, lastDot);
|
|
16466
17410
|
return fileName;
|
|
16467
17411
|
}
|
|
16468
|
-
tryExtractChargeTransparencyTextFromURL(qrText) {
|
|
16469
|
-
if (!qrText.startsWith("http://") && !qrText.startsWith("https://"))
|
|
16470
|
-
return qrText;
|
|
16471
|
-
try {
|
|
16472
|
-
const url = new URL(qrText);
|
|
16473
|
-
const candidates = [
|
|
16474
|
-
url.hash.startsWith("#") ? url.hash.substring(1) : url.hash,
|
|
16475
|
-
url.searchParams.get("data"),
|
|
16476
|
-
url.searchParams.get("content"),
|
|
16477
|
-
url.searchParams.get("ctr"),
|
|
16478
|
-
url.searchParams.get("record"),
|
|
16479
|
-
url.searchParams.get("payload"),
|
|
16480
|
-
url.searchParams.get("q")
|
|
16481
|
-
];
|
|
16482
|
-
for (const candidate of candidates) {
|
|
16483
|
-
const decodedCandidate = candidate != null ? decodeURIComponent(candidate).trim() : "";
|
|
16484
|
-
if (decodedCandidate.startsWith("<?xml") || decodedCandidate.startsWith("<values") || decodedCandidate.startsWith("{") || decodedCandidate.startsWith("[") || decodedCandidate.startsWith("OCMF") || decodedCandidate.startsWith("AP;")) {
|
|
16485
|
-
return decodedCandidate;
|
|
16486
|
-
}
|
|
16487
|
-
}
|
|
16488
|
-
} catch {
|
|
16489
|
-
console.log("Invalid URL in QR code: " + qrText);
|
|
16490
|
-
}
|
|
16491
|
-
return qrText;
|
|
16492
|
-
}
|
|
16493
|
-
tryExtractSignedDataTextFromXML(qrText) {
|
|
16494
|
-
const trimmedQRCodeText = qrText.trim();
|
|
16495
|
-
if (!trimmedQRCodeText.startsWith("<?xml") && !trimmedQRCodeText.startsWith("<"))
|
|
16496
|
-
return qrText;
|
|
16497
|
-
try {
|
|
16498
|
-
const xmlDocument = new DOMParser().parseFromString(trimmedQRCodeText, "text/xml");
|
|
16499
|
-
const signedDataValues = getElementsByLocalName(xmlDocument, "signedData").filter((signedData) => (signedData.getAttribute("format") ?? "").trim().toLowerCase() === "alfen").map((signedData) => signedData.textContent.trim()).filter((signedData) => signedData.startsWith("AP;"));
|
|
16500
|
-
if (signedDataValues.length > 0)
|
|
16501
|
-
return signedDataValues.join("\n");
|
|
16502
|
-
} catch {
|
|
16503
|
-
console.log("Error parsing XML content from QR code: " + qrText);
|
|
16504
|
-
}
|
|
16505
|
-
return qrText;
|
|
16506
|
-
}
|
|
16507
17412
|
//#region Public key methods...
|
|
16508
17413
|
PublicKeyIdFromFileName(fileName) {
|
|
16509
17414
|
return (fileName.includes(".") ? fileName.substring(0, fileName.indexOf(".")) : fileName).replace(/[-_]?public[-_]?key/i, "");
|
|
@@ -16589,25 +17494,70 @@ var Chargy = class {
|
|
|
16589
17494
|
}
|
|
16590
17495
|
//#endregion
|
|
16591
17496
|
//#region QR code image files...
|
|
16592
|
-
|
|
16593
|
-
|
|
16594
|
-
|
|
16595
|
-
|
|
17497
|
+
normalizeMIMEType(mimeType) {
|
|
17498
|
+
return mimeType?.split(";")[0]?.trim().toLowerCase();
|
|
17499
|
+
}
|
|
17500
|
+
getQRCodeImageMIMETypeFromFileName(fileName) {
|
|
17501
|
+
fileName = fileName.toLowerCase();
|
|
17502
|
+
if (fileName.endsWith(".png"))
|
|
17503
|
+
return "image/png";
|
|
17504
|
+
if (fileName.endsWith(".jpeg"))
|
|
17505
|
+
return "image/jpeg";
|
|
17506
|
+
if (fileName.endsWith(".jpg"))
|
|
17507
|
+
return "image/jpg";
|
|
17508
|
+
if (fileName.endsWith(".gif"))
|
|
17509
|
+
return "image/gif";
|
|
17510
|
+
if (fileName.endsWith(".webp"))
|
|
17511
|
+
return "image/webp";
|
|
17512
|
+
if (fileName.endsWith(".bmp"))
|
|
17513
|
+
return "image/bmp";
|
|
17514
|
+
if (fileName.endsWith(".svg"))
|
|
17515
|
+
return "image/svg+xml";
|
|
17516
|
+
return void 0;
|
|
17517
|
+
}
|
|
17518
|
+
getQRCodeImageMIMEType(fileInfo, mimeType) {
|
|
17519
|
+
const detectedMIMEType = this.normalizeMIMEType(mimeType);
|
|
17520
|
+
const declaredMIMEType = this.normalizeMIMEType(fileInfo.type);
|
|
17521
|
+
const fileNameMIMEType = this.getQRCodeImageMIMETypeFromFileName(fileInfo.name);
|
|
17522
|
+
if (this.isSupportedQRCodeImageFileType(detectedMIMEType))
|
|
17523
|
+
return detectedMIMEType;
|
|
17524
|
+
if (this.isSupportedQRCodeImageFileType(declaredMIMEType))
|
|
17525
|
+
return declaredMIMEType;
|
|
17526
|
+
if (fileNameMIMEType !== void 0)
|
|
17527
|
+
return fileNameMIMEType;
|
|
17528
|
+
return detectedMIMEType ?? declaredMIMEType;
|
|
17529
|
+
}
|
|
17530
|
+
isSupportedQRCodeImageFileType(MIMEType) {
|
|
17531
|
+
switch (MIMEType) {
|
|
17532
|
+
case void 0:
|
|
17533
|
+
return false;
|
|
17534
|
+
case "image/png":
|
|
17535
|
+
case "image/jpeg":
|
|
17536
|
+
case "image/jpg":
|
|
17537
|
+
case "image/gif":
|
|
17538
|
+
case "image/webp":
|
|
17539
|
+
case "image/bmp":
|
|
17540
|
+
case "image/svg":
|
|
17541
|
+
case "image/svg+xml":
|
|
17542
|
+
return true;
|
|
17543
|
+
}
|
|
17544
|
+
return false;
|
|
16596
17545
|
}
|
|
16597
17546
|
async expandQRCodeImageFiles(FileInfos) {
|
|
16598
17547
|
const expandedFileInfos = new Array();
|
|
16599
17548
|
for (const fileInfo of FileInfos) {
|
|
16600
|
-
|
|
16601
|
-
|
|
17549
|
+
const mimeType = this.getQRCodeImageMIMEType(fileInfo);
|
|
17550
|
+
if (fileInfo.data != null && this.isSupportedQRCodeImageFileType(mimeType)) {
|
|
17551
|
+
const qrText = await readQRCodeTextFromImage(
|
|
17552
|
+
fileInfo.data,
|
|
17553
|
+
mimeType
|
|
17554
|
+
);
|
|
16602
17555
|
if (qrText != null) {
|
|
16603
|
-
const extractedText = this.tryExtractSignedDataTextFromXML(
|
|
16604
|
-
this.tryExtractChargeTransparencyTextFromURL(qrText)
|
|
16605
|
-
);
|
|
16606
17556
|
expandedFileInfos.push({
|
|
16607
|
-
name: this.textFileNameForQRCodeContent(fileInfo.name,
|
|
17557
|
+
name: this.textFileNameForQRCodeContent(fileInfo.name, qrText),
|
|
16608
17558
|
path: fileInfo.path,
|
|
16609
17559
|
type: "text/plain",
|
|
16610
|
-
data: new TextEncoder().encode(
|
|
17560
|
+
data: new TextEncoder().encode(qrText),
|
|
16611
17561
|
info: "Text extracted from QR code image"
|
|
16612
17562
|
});
|
|
16613
17563
|
continue;
|
|
@@ -16806,55 +17756,42 @@ var Chargy = class {
|
|
|
16806
17756
|
if (FileInfo.data != null && FileInfo.data.byteLength > 0) {
|
|
16807
17757
|
try {
|
|
16808
17758
|
const filetype = await fileTypeFromBuffer(FileInfo.data);
|
|
16809
|
-
|
|
16810
|
-
|
|
16811
|
-
|
|
16812
|
-
|
|
16813
|
-
|
|
16814
|
-
|
|
16815
|
-
|
|
16816
|
-
|
|
16817
|
-
else if (FileInfo.name.endsWith(".chargy"))
|
|
16818
|
-
expandedFileInfos.push({
|
|
16819
|
-
name: FileInfo.name,
|
|
16820
|
-
data: FileInfo.data,
|
|
16821
|
-
info: ".chargy file"
|
|
16822
|
-
});
|
|
16823
|
-
else
|
|
16824
|
-
expandedFileInfos.push({
|
|
16825
|
-
name: FileInfo.name,
|
|
16826
|
-
data: FileInfo.data,
|
|
16827
|
-
exception: "Unknown file type!"
|
|
16828
|
-
});
|
|
17759
|
+
const mimeType = this.getQRCodeImageMIMEType(FileInfo, filetype?.mime);
|
|
17760
|
+
if (this.isSupportedQRCodeImageFileType(mimeType)) {
|
|
17761
|
+
expandedFileInfos.push({
|
|
17762
|
+
name: FileInfo.name,
|
|
17763
|
+
data: FileInfo.data,
|
|
17764
|
+
type: FileInfo.type ?? mimeType,
|
|
17765
|
+
info: "QR code image file"
|
|
17766
|
+
});
|
|
16829
17767
|
continue;
|
|
16830
|
-
} else if (
|
|
17768
|
+
} else if (FileInfo.name.endsWith(".chargy")) {
|
|
16831
17769
|
expandedFileInfos.push({
|
|
16832
17770
|
name: FileInfo.name,
|
|
16833
17771
|
data: FileInfo.data,
|
|
16834
|
-
info: "
|
|
17772
|
+
info: ".chargy file"
|
|
16835
17773
|
});
|
|
16836
17774
|
continue;
|
|
16837
|
-
} else if (
|
|
17775
|
+
} else if (mimeType === "text/xml" || mimeType === "application/xml") {
|
|
16838
17776
|
expandedFileInfos.push({
|
|
16839
17777
|
name: FileInfo.name,
|
|
16840
17778
|
data: FileInfo.data,
|
|
16841
|
-
info: "
|
|
17779
|
+
info: "XML file"
|
|
16842
17780
|
});
|
|
16843
17781
|
continue;
|
|
16844
|
-
} else if (
|
|
17782
|
+
} else if (mimeType === "text/json" || mimeType === "application/json") {
|
|
16845
17783
|
expandedFileInfos.push({
|
|
16846
17784
|
name: FileInfo.name,
|
|
16847
17785
|
data: FileInfo.data,
|
|
16848
|
-
|
|
16849
|
-
info: "QR code image file"
|
|
17786
|
+
info: "JSON file"
|
|
16850
17787
|
});
|
|
16851
17788
|
continue;
|
|
16852
|
-
} else if (
|
|
17789
|
+
} else if (mimeType === "application/zip" || mimeType === "application/x-bzip2" || mimeType === "application/gzip" || mimeType === "application/x-tar") {
|
|
16853
17790
|
try {
|
|
16854
17791
|
const compressedFiles = await this.extractArchive(
|
|
16855
17792
|
FileInfo.name,
|
|
16856
17793
|
FileInfo.data,
|
|
16857
|
-
|
|
17794
|
+
mimeType
|
|
16858
17795
|
);
|
|
16859
17796
|
if (compressedFiles.length == 0)
|
|
16860
17797
|
continue;
|
|
@@ -16926,6 +17863,12 @@ var Chargy = class {
|
|
|
16926
17863
|
}
|
|
16927
17864
|
continue;
|
|
16928
17865
|
}
|
|
17866
|
+
expandedFileInfos.push({
|
|
17867
|
+
name: FileInfo.name,
|
|
17868
|
+
data: FileInfo.data,
|
|
17869
|
+
exception: "Unknown file type!"
|
|
17870
|
+
});
|
|
17871
|
+
continue;
|
|
16929
17872
|
} catch (exception) {
|
|
16930
17873
|
expandedFileInfos.push({
|
|
16931
17874
|
name: FileInfo.name,
|
|
@@ -17641,6 +18584,10 @@ var Chargy = class {
|
|
|
17641
18584
|
chargingSession.method = new PCDFCrypt01(this);
|
|
17642
18585
|
verificationResult2 = await chargingSession.method.VerifyChargingSession(chargingSession);
|
|
17643
18586
|
break;
|
|
18587
|
+
case "https://open.charging.cloud/contexts/SessionSignatureFormats/EDL40+json":
|
|
18588
|
+
chargingSession.method = new EDL40Crypt01(this);
|
|
18589
|
+
verificationResult2 = await chargingSession.method.VerifyChargingSession(chargingSession);
|
|
18590
|
+
break;
|
|
17644
18591
|
case "https://open.charging.cloud/contexts/SessionSignatureFormats/bsm-ws36a-v0+json":
|
|
17645
18592
|
chargingSession.method = new BSMCrypt01(this);
|
|
17646
18593
|
verificationResult2 = await chargingSession.method.VerifyChargingSession(chargingSession);
|
|
@@ -17721,6 +18668,6 @@ var Chargy = class {
|
|
|
17721
18668
|
}
|
|
17722
18669
|
};
|
|
17723
18670
|
|
|
17724
|
-
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, CryptoAlgorithms, CryptoHashAlgorithms, DayOfWeek, DisplayPrefixes, EMHCrypt01, ErrorLevel, GDFCrypt01, IECCurves, IEncoding, InformationRelevance, InformationRelevanceToString, IsAChargeTransparencyLiveLink, IsAChargeTransparencyRecord, IsAPublicKey, IsAPublicKeyLookup, IsAPublicKeySignature, IsAPublicKeyXY, IsASessionCryptoResult, IsNullOrEmpty, JSONSignatureVerificationStatus, MENNEKES_EDL40_OBIS, MENNEKES_EDL40_XMLNS, Mennekes, MennekesCrypt01, OBIS2Hex, OBIS2MeasurementName, OBIS_RegExpr, OCMF, OCMFTransactionTypes, OCMFv1_x, OCPI, OIDInfo, PCDF, PCDFCrypt01, PCDFParseError, PCDFValidationError, PCDF_FIELD_ORDER, PCDF_PREFIX, ParseJSON_LD, PublicKeyFormats, IPublicKeyInfo_exports as PublicKeyInfo, SAFEXML, SessionVerificationResult, SetHex, SetInt8, SetText, SetText_withLength, SetTimestamp, SetTimestamp32, SetUInt32, SetUInt32_withCode, SetUInt64, SetUInt64D, SignMessage, SignatureFormats, TimeStatusTypes, UTC2human, VerificationResult, VerifyJSONMessageSignatures, WarningLevel, WhenNullOrEmpty, XMLContainer, asJSONArray, asJSONObject, asNumber, asString, base64ToBytes, buf2hex, buildMennekesSignatureData, bytesToBase64, bytesToHex, canonicalJSONBytes, canonicalJSONStringify, cleanHex, closeFullscreen, createHexString, dateToMennekesLocalEpochSeconds, extractMennekesChargingProcesses, firstKey, firstValue, getArrayElement, getArrayLikeElement, getDirectChildByLocalName, getDirectChildrenByLocalName, getElementsByLocalName, getFirstArrayElement, getInt16Bytes, getInt32Bytes, getInt64Bytes, getInt8Bytes, getLastArrayElement, 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, jsonPrettyPrinter, measurementName2human, normalizePCDFPublicKeyHex, normalizeXMLText, openFullscreen, pad, parseAndVerifyJSONSignatures, parseDescription, parseHexString, parseMennekesXMLDocument, parseNumber, parseOBIS, parsePCDFDocument, parsePCDFPublicKey, parsePCDFSignature, parseUTC, readQRCodeTextFromImage, readQRCodeTextFromImageData, secp224k1, setUILocale, sha256, sha256____, sha384, sha384____, sha512, sha512____, signJSONMessage, signMessage, stripPCDFControlCharacters, time2human, toArrayBuffer, toSessionVerificationResults, toUint8Array, unquotePCDFText, validatePCDFFields, verifyJSONMessageSignatureResults, verifyJSONMessageSignatures, verifyJSONSignature, verifyJSONSignatureResult, verifyPCDFDocument };
|
|
18671
|
+
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, IsNullOrEmpty, JSONSignatureVerificationStatus, MENNEKES_EDL40_OBIS, MENNEKES_EDL40_XMLNS, Mennekes, MennekesCrypt01, OBIS2Hex, OBIS2MeasurementName, OBIS_RegExpr, OCMF, OCMFTransactionTypes, OCMFv1_x, OCPI, OIDInfo, PCDF, PCDFCrypt01, PCDFParseError, PCDFValidationError, PCDF_FIELD_ORDER, PCDF_PREFIX, ParseJSON_LD, PublicKeyFormats, IPublicKeyInfo_exports as PublicKeyInfo, SAFEXML, SessionVerificationResult, SetHex, SetInt8, SetText, SetText_withLength, SetTimestamp, SetTimestamp32, SetUInt32, SetUInt32_withCode, SetUInt64, SetUInt64D, SignMessage, SignatureFormats, TimeStatusTypes, UTC2human, VerificationResult, VerifyJSONMessageSignatures, WarningLevel, WhenNullOrEmpty, XMLContainer, asJSONArray, asJSONObject, asNumber, asString, base64ToBytes, buf2hex, buildEDL40Signature, buildIsaSignature, buildMennekesSignatureData, bytesToBase64, bytesToHex, canParseEDL40, canonicalJSONBytes, canonicalJSONStringify, cleanHex, closeFullscreen, createHexString, dateToMennekesLocalEpochSeconds, decodeSmlMessages, extractMennekesChargingProcesses, findEntryByObis, findGetListRes, firstKey, firstValue, getArrayElement, getArrayLikeElement, getDirectChildByLocalName, getDirectChildrenByLocalName, getElementsByLocalName, getFirstArrayElement, getInt16Bytes, getInt32Bytes, getInt64Bytes, getInt8Bytes, getLastArrayElement, 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, normalizePCDFPublicKeyHex, normalizeXMLText, openFullscreen, pad, parseAndVerifyJSONSignatures, parseDescription, parseEDL40, parseHexString, parseMennekesXMLDocument, parseNumber, parseOBIS, parsePCDFDocument, parsePCDFPublicKey, parsePCDFSignature, parseSmlTime, parseUTC, readQRCodeTextFromImage, readQRCodeTextFromImageData, readTLV, secp224k1, setUILocale, sha256, sha256____, sha384, sha384____, sha512, sha512____, signJSONMessage, signMessage, stripPCDFControlCharacters, stripTransport, time2human, toArrayBuffer, toSessionVerificationResults, toUint8Array, transformEDL40Status, unquotePCDFText, validatePCDFFields, verifyEDL40Document, verifyJSONMessageSignatureResults, verifyJSONMessageSignatures, verifyJSONSignature, verifyJSONSignatureResult, verifyPCDFDocument };
|
|
17725
18672
|
//# sourceMappingURL=index.js.map
|
|
17726
18673
|
//# sourceMappingURL=index.js.map
|