Skip to content

Commit 3ea742d

Browse files
romainv42rviau42
authored andcommitted
Fix Lint and Tests
1 parent 9bd796b commit 3ea742d

113 files changed

Lines changed: 499 additions & 416 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ module.exports = {
4545
],
4646
"keyword-spacing": [
4747
"error",
48-
{ "after": false }
48+
{ "overrides": {
49+
"if": { "after": false },
50+
"for": { "after": false },
51+
"while": { "after": false },
52+
"catch": { "after": false },
53+
}}
4954
]
5055
}
5156
};

src/AccessDescription.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class AccessDescription
4040
*/
4141
static defaultValues(memberName)
4242
{
43-
switch(memberName)
43+
switch (memberName)
4444
{
4545
case "accessMethod":
4646
return "";

src/Accuracy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class Accuracy
4949
*/
5050
static defaultValues(memberName)
5151
{
52-
switch(memberName)
52+
switch (memberName)
5353
{
5454
case "seconds":
5555
case "millis":
@@ -67,7 +67,7 @@ export default class Accuracy
6767
*/
6868
static compareWithDefault(memberName, memberValue)
6969
{
70-
switch(memberName)
70+
switch (memberName)
7171
{
7272
case "seconds":
7373
case "millis":

src/AlgorithmIdentifier.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class AlgorithmIdentifier
4242
*/
4343
static defaultValues(memberName)
4444
{
45-
switch(memberName)
45+
switch (memberName)
4646
{
4747
case "algorithmId":
4848
return "";
@@ -60,7 +60,7 @@ export default class AlgorithmIdentifier
6060
*/
6161
static compareWithDefault(memberName, memberValue)
6262
{
63-
switch(memberName)
63+
switch (memberName)
6464
{
6565
case "algorithmId":
6666
return (memberValue === "");

src/AltName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class AltName
3535
*/
3636
static defaultValues(memberName)
3737
{
38-
switch(memberName)
38+
switch (memberName)
3939
{
4040
case "altNames":
4141
return [];

src/Attribute.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { getParametersValue, clearProps } from "pvutils";
44
/**
55
* Class from RFC2986
66
*/
7-
export default class Attribute {
7+
export default class Attribute
8+
{
89
//**********************************************************************************
910
/**
1011
* Constructor for Attribute class
@@ -38,7 +39,7 @@ export default class Attribute {
3839
*/
3940
static defaultValues(memberName)
4041
{
41-
switch(memberName)
42+
switch (memberName)
4243
{
4344
case "type":
4445
return "";
@@ -56,7 +57,7 @@ export default class Attribute {
5657
*/
5758
static compareWithDefault(memberName, memberValue)
5859
{
59-
switch(memberName)
60+
switch (memberName)
6061
{
6162
case "type":
6263
return (memberValue === "");

src/AttributeCertificateV1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class AttCertValidityPeriod
4343
*/
4444
static defaultValues(memberName)
4545
{
46-
switch(memberName)
46+
switch (memberName)
4747
{
4848
case "notBeforeTime":
4949
case "notAfterTime":
@@ -195,7 +195,7 @@ export class IssuerSerial
195195
*/
196196
static defaultValues(memberName)
197197
{
198-
switch(memberName)
198+
switch (memberName)
199199
{
200200
case "issuer":
201201
return new GeneralNames();
@@ -420,7 +420,7 @@ export class AttributeCertificateInfoV1
420420
*/
421421
static defaultValues(memberName)
422422
{
423-
switch(memberName)
423+
switch (memberName)
424424
{
425425
case "version":
426426
return 0;
@@ -745,7 +745,7 @@ export default class AttributeCertificateV1
745745
*/
746746
static defaultValues(memberName)
747747
{
748-
switch(memberName)
748+
switch (memberName)
749749
{
750750
case "acinfo":
751751
return new AttributeCertificateInfoV1();

src/AttributeCertificateV2.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class ObjectDigestInfo
5757
*/
5858
static defaultValues(memberName)
5959
{
60-
switch(memberName)
60+
switch (memberName)
6161
{
6262
case "digestedObjectType":
6363
return new asn1js.Enumerated();
@@ -254,7 +254,7 @@ export class V2Form
254254
*/
255255
static defaultValues(memberName)
256256
{
257-
switch(memberName)
257+
switch (memberName)
258258
{
259259
case "issuerName":
260260
return new GeneralNames();
@@ -488,7 +488,7 @@ export class Holder
488488
*/
489489
static defaultValues(memberName)
490490
{
491-
switch(memberName)
491+
switch (memberName)
492492
{
493493
case "baseCertificateID":
494494
return new IssuerSerial();
@@ -769,7 +769,7 @@ export class AttributeCertificateInfoV2
769769
*/
770770
static defaultValues(memberName)
771771
{
772-
switch(memberName)
772+
switch (memberName)
773773
{
774774
case "version":
775775
return 1;
@@ -929,7 +929,7 @@ export class AttributeCertificateInfoV2
929929
this.version = asn1.result.version.valueBlock.valueDec;
930930
this.holder = new Holder({ schema: asn1.result.holder });
931931

932-
switch(asn1.result.issuer.idBlock.tagClass)
932+
switch (asn1.result.issuer.idBlock.tagClass)
933933
{
934934
case 3: // V2Form
935935
this.issuer = new V2Form({
@@ -1061,7 +1061,7 @@ export default class AttributeCertificateV2
10611061
*/
10621062
static defaultValues(memberName)
10631063
{
1064-
switch(memberName)
1064+
switch (memberName)
10651065
{
10661066
case "acinfo":
10671067
return new AttributeCertificateInfoV2();

src/AttributeTypeAndValue.js

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import AttributeTypeDictionary from "./AttributeTypeDictionary";
66
/**
77
* Class from RFC5280
88
*/
9-
export default class AttributeTypeAndValue {
9+
export default class AttributeTypeAndValue
10+
{
1011
//**********************************************************************************
1112
/**
1213
* Constructor for AttributeTypeAndValue class
1314
* @param {Object} [parameters={}]
1415
* @param {Object} [parameters.schema] asn1js parsed value to initialize the class from
1516
*/
16-
constructor(parameters = {}) {
17+
constructor(parameters = {})
18+
{
1719
//region Internal properties of the object
1820
/**
1921
* @type {string}
@@ -28,7 +30,7 @@ export default class AttributeTypeAndValue {
2830
//endregion
2931

3032
//region If input argument array contains "schema" for this object
31-
if ("schema" in parameters)
33+
if("schema" in parameters)
3234
this.fromSchema(parameters.schema);
3335
//endregion
3436
}
@@ -37,8 +39,10 @@ export default class AttributeTypeAndValue {
3739
* Return default values for all class members
3840
* @param {string} memberName String name for a class member
3941
*/
40-
static defaultValues(memberName) {
41-
switch (memberName) {
42+
static defaultValues(memberName)
43+
{
44+
switch (memberName)
45+
{
4246
case "type":
4347
return "";
4448
case "value":
@@ -65,7 +69,8 @@ export default class AttributeTypeAndValue {
6569
* @param {Object} parameters Input parameters for the schema
6670
* @returns {Object} asn1js schema object
6771
*/
68-
static schema(parameters = {}) {
72+
static schema(parameters = {})
73+
{
6974
/**
7075
* @type {Object}
7176
* @property {string} [blockName] Name for entire block
@@ -83,15 +88,17 @@ export default class AttributeTypeAndValue {
8388
}));
8489
}
8590
//**********************************************************************************
86-
static blockName() {
91+
static blockName()
92+
{
8793
return "AttributeTypeAndValue";
8894
}
8995
//**********************************************************************************
9096
/**
9197
* Convert parsed asn1js object into current class
9298
* @param {!Object} schema
9399
*/
94-
fromSchema(schema) {
100+
fromSchema(schema)
101+
{
95102
//region Clear input data first
96103
clearProps(schema, [
97104
"type",
@@ -110,7 +117,7 @@ export default class AttributeTypeAndValue {
110117
})
111118
);
112119

113-
if (asn1.verified === false)
120+
if(asn1.verified === false)
114121
throw new Error("Object's schema was not verified against input data for AttributeTypeAndValue");
115122
//endregion
116123

@@ -125,7 +132,8 @@ export default class AttributeTypeAndValue {
125132
* Convert current object to asn1js object and set correct values
126133
* @returns {Object} asn1js object
127134
*/
128-
toSchema() {
135+
toSchema()
136+
{
129137
//region Construct and return new ASN.1 schema for this object
130138
return (new asn1js.Sequence({
131139
value: [
@@ -140,12 +148,13 @@ export default class AttributeTypeAndValue {
140148
* Convertion for the class to JSON object
141149
* @returns {Object}
142150
*/
143-
toJSON() {
151+
toJSON()
152+
{
144153
const _object = {
145154
type: this.type
146155
};
147156

148-
if (Object.keys(this.value).length !== 0)
157+
if(Object.keys(this.value).length !== 0)
149158
_object.value = this.value.toJSON();
150159
else
151160
_object.value = this.value;
@@ -158,7 +167,8 @@ export default class AttributeTypeAndValue {
158167
* @param {(AttributeTypeAndValue|ArrayBuffer)} compareTo The value compare to current
159168
* @returns {boolean}
160169
*/
161-
isEqual(compareTo) {
170+
isEqual(compareTo)
171+
{
162172
const stringBlockNames = [
163173
asn1js.Utf8String.blockName(),
164174
asn1js.BmpString.blockName(),
@@ -174,63 +184,71 @@ export default class AttributeTypeAndValue {
174184
asn1js.CharacterString.blockName()
175185
];
176186

177-
if (compareTo.constructor.blockName() === AttributeTypeAndValue.blockName()) {
178-
if (this.type !== compareTo.type)
187+
if(compareTo.constructor.blockName() === AttributeTypeAndValue.blockName())
188+
{
189+
if(this.type !== compareTo.type)
179190
return false;
180191

181192
//region Check we do have both strings
182193
let isString = [false, false];
183194
const thisName = this.value.constructor.blockName();
184-
for (const name of stringBlockNames) {
185-
if (thisName === name) {
195+
for(const name of stringBlockNames)
196+
{
197+
if(thisName === name)
198+
{
186199
isString[0] = true;
187200
}
188-
if (compareTo.value.constructor.blockName() === name) {
201+
if(compareTo.value.constructor.blockName() === name)
202+
{
189203
isString[1] = true;
190204
}
191205
}
192-
if (isString[0] ^ isString[1])
206+
if(isString[0] ^ isString[1])
193207
return false;
194208

195209
isString = (isString[0] && isString[1]);
196210
//endregion
197211

198-
if (isString) {
212+
if(isString)
213+
{
199214
const value1 = stringPrep(this.value.valueBlock.value);
200215
const value2 = stringPrep(compareTo.value.valueBlock.value);
201216

202-
if (value1.localeCompare(value2) !== 0)
217+
if(value1.localeCompare(value2) !== 0)
203218
return false;
204219
}
205220
else // Comparing as two ArrayBuffers
206221
{
207-
if (isEqualBuffer(this.value.valueBeforeDecode, compareTo.value.valueBeforeDecode) === false)
222+
if(isEqualBuffer(this.value.valueBeforeDecode, compareTo.value.valueBeforeDecode) === false)
208223
return false;
209224
}
210225

211226
return true;
212227
}
213228

214-
if (compareTo instanceof ArrayBuffer)
229+
if(compareTo instanceof ArrayBuffer)
215230
return isEqualBuffer(this.value.valueBeforeDecode, compareTo);
216231

217232
return false;
218233
}
219234
//**********************************************************************************
220235
/**
221236
* Convert an AttributeTypeAndValue to a human-readable string
222-
* based on RFC4514, with escaping charaters
237+
* based on RFC4514, with escaping characters
223238
* @returns {string}
224239
*/
225-
toString() {
240+
toString()
241+
{
226242
let value = this.value.valueBlock.value;
227243

228244
value = value.replace(/(["+,;<>\\=])/g, "\\$1");
229245

230-
if (value.startsWith(" ") || value.startsWith("#")) {
246+
if(value.startsWith(" ") || value.startsWith("#"))
247+
{
231248
value = "\\" + value;
232249
}
233-
if (value.endsWith(" ")) {
250+
if(value.endsWith(" "))
251+
{
234252
value = value.substring(0, value.length - 1) + "\\" + value.substring(value.length - 1);
235253
}
236254

0 commit comments

Comments
 (0)