Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.1.12 Bugfix release #10

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [18.x, 19.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Run linter
run: npm run lint

- name: Build
run: npm run

- name: Run test with coverage
run: npm run coverage

Expand Down
36 changes: 21 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"name": "@estos/asn1ts",
"version": "3.1.12",
"license": "BSD-3-Clause",
"author": {
"email": "[email protected]",
"name": "Jan Fellner"
"name": "estos GmbH",
"email": "[email protected]",
"url": "https://www.estos.de"
},
"contributors": [
{
"email": "[email protected]",
"name": "Jan Fellner"
},
{
"email": "[email protected]",
"name": "Yury Strozhevsky"
Expand All @@ -14,30 +22,31 @@
}
],
"engines": {
"node": ">=12.0.0"
"node": ">=18.0.0"
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"@types/node": "^20.8.6",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"asn1-test-suite": "^1.0.2",
"eslint": "^8.31.0",
"eslint-plugin-deprecation": "^1.3.3",
"eslint-plugin-deprecation": "^2.0.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"rollup": "^3.9.1",
"rollup-plugin-dts": "^5.1.1",
"rollup": "^4.1.4",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-typescript2": "^0.36.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.2.2"
},
"repository": {
"type": "git",
"url": "git://github.com/ESTOS/ASN1.ts.git"
},
"dependencies": {
"jest": "^29.7.0",
"pvtsutils": "^1.3.2",
"pvutils": "^1.1.3",
"tslib": "^2.4.1"
Expand Down Expand Up @@ -65,7 +74,6 @@
"main": "build/index.js",
"module": "build/index.es.js",
"types": "build/index.d.ts",
"name": "@estos/asn1ts",
"files": [
"build",
"LICENSE",
Expand All @@ -78,7 +86,5 @@
"lint": "eslint . --ext .ts",
"lint:fix": "eslint --fix . --ext .ts",
"coverage": "nyc npm test"
},
"version": "3.1.11",
"license": "BSD-3-Clause"
}
}
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "path";
import fs from "fs";
import typescript from "rollup-plugin-typescript2";
import dts from "rollup-plugin-dts";
import pkg from "./package.json" assert { type: 'json' };
import pkg from "./package.json" assert { type: "json" };

const __dirname = path.resolve();
const LICENSE = fs.readFileSync("LICENSE", { encoding: "utf-8" });
Expand Down
17 changes: 1 addition & 16 deletions src/internals/LocalBitStringValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,4 @@ export class LocalBitStringValueBlock extends HexBlock(LocalConstructedValueBloc
isConstructed: this.isConstructed,
} as LocalBitStringValueBlockJson;
}
}

export interface LocalBitStringValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
}
15 changes: 0 additions & 15 deletions src/internals/LocalBooleanValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,3 @@ export class LocalBooleanValueBlock extends HexBlock(ValueBlock) implements ILoc
};
}
}

export interface LocalBooleanValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalIdentificationBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,3 @@ export class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) implement
return this.tagClass === other.tagClass && this.tagNumber === other.tagNumber;
}
}

export interface LocalIdentificationBlock {
/**
* @deprecated since version 3.0.0
*/
/** @ts-ignore */
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
/** @ts-ignore */
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalIntegerValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,3 @@ export class LocalIntegerValueBlock extends HexBlock(ValueBlock) {
}

}

export interface LocalIntegerValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalOctetStringValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,3 @@ export class LocalOctetStringValueBlock extends HexBlock(LocalConstructedValueBl
}

}

export interface LocalOctetStringValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalPrimitiveValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,3 @@ export class LocalPrimitiveValueBlock extends HexBlock(ValueBlock) {
}

}

export interface LocalPrimitiveValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalRealValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,3 @@ export class LocalRealValueBlock extends HexBlock(ValueBlock) {
}

}

export interface LocalRealValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalSidValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,3 @@ export class LocalSidValueBlock extends HexBlock(ValueBlock) implements ILocalSi
}

}

export interface LocalSidValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
15 changes: 0 additions & 15 deletions src/internals/LocalStringValueBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,3 @@ export abstract class LocalStringValueBlock extends HexBlock(ValueBlock) impleme
}

}

export interface LocalStringValueBlock {
/**
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueBeforeDecode: ArrayBuffer;
/**
* Binary data in ArrayBuffer representation
*
* @deprecated since version 3.0.0
*/
// @ts-ignore
valueHex: ArrayBuffer;
}
30 changes: 23 additions & 7 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export enum ESchemaError {
MISSING_CONSTRUCTED_FLAG_IN_SCHEMA = 7,
/** Mismatching constructed flag between asn1 and schema */
MISMATCHING_CONSTRUCTED_FLAG = 8,
/** The schema attribute has no constructed flag */
/** Missing is hex only flag in schems */
MISSING_ISHEXONLY_FLAG_IN_SCHEMA = 9,
/** Mismatching constructed flag between asn1 and schema */
/** Mismatching is hex only flag between asn1 and schema */
MISMATCHING_ISHEXONLY_FLAG = 10,
/** The schema attribute has hexview flag */
MISSING_HEXVIEW_IN_SCHEMA = 11,
Expand All @@ -110,7 +110,10 @@ export enum ESchemaError {
/** Failed to match asn1 data with choice from the schema */
NO_MATCHING_DATA_FOR_CHOICE = 17,
/** The ASN1 structure is larger than the schema */
ASN1_IS_LARGER_THAN_SCHEMA = 18
ASN1_IS_LARGER_THAN_SCHEMA = 18,
/** Data and schema are not pointing to the same context specific entry */
MISMATCHING_CONTEXT_SPECIFIC_ID = 19

/** If you add new Values !!! Add them to the getTextForError as well !!! */
}

Expand All @@ -136,9 +139,9 @@ function getTextForError(error: ESchemaError): string {
case ESchemaError.MISMATCHING_CONSTRUCTED_FLAG:
return "Mismatching constructed flag between asn1 and schema";
case ESchemaError.MISSING_ISHEXONLY_FLAG_IN_SCHEMA:
return "The schema attribute has no constructed flag";
return "Missing is hex only flag in schems";
case ESchemaError.MISMATCHING_ISHEXONLY_FLAG:
return "Mismatching constructed flag between asn1 and schema";
return "Mismatching is hex only flag between asn1 and schema";
case ESchemaError.MISSING_HEXVIEW_IN_SCHEMA:
return "The schema attribute has hexview flag";
case ESchemaError.MISMATCHING_HEX_VIEW_LENGTH:
Expand All @@ -153,6 +156,8 @@ function getTextForError(error: ESchemaError): string {
return "Failed to match asn1 data with choice from the schema";
case ESchemaError.ASN1_IS_LARGER_THAN_SCHEMA:
return "The ASN1 structure is larger than the schema";
case ESchemaError.MISMATCHING_CONTEXT_SPECIFIC_ID:
return "Mismatching context specific id between schema and data";
default:
return `Unknown error: ${error}`;
}
Expand Down Expand Up @@ -233,10 +238,12 @@ function compareSchemaInternal(root: AsnType, inputSchema: AsnSchemaType, option
const schema = inputSchema.value[j];
if ((bContextSpecific && inputData.idBlock.tagNumber === schema.idBlock.optionalID) || !bContextSpecific) {
const savedTagClass = inputData.idBlock.tagClass;
const savedTagNumebr = inputData.idBlock.tagNumber;
const savedTagNumber = inputData.idBlock.tagNumber;
const savedOptionalID = inputData.idBlock.optionalID;
if (bContextSpecific) {
inputData.idBlock.tagClass = schema.idBlock.tagClass;
inputData.idBlock.tagNumber = schema.idBlock.tagNumber;
inputData.idBlock.optionalID = schema.idBlock.optionalID;
}
const newContext = context.recurse(schema);
const errors = compareSchemaInternal(root, schema, options, newContext, inputData);
Expand All @@ -247,7 +254,8 @@ function compareSchemaInternal(root: AsnType, inputSchema: AsnSchemaType, option
return errors;
} else if (bContextSpecific) {
inputData.idBlock.tagClass = savedTagClass;
inputData.idBlock.tagNumber = savedTagNumebr;
inputData.idBlock.tagNumber = savedTagNumber;
inputData.idBlock.optionalID = savedOptionalID;
}
}
}
Expand Down Expand Up @@ -414,6 +422,11 @@ function compareSchemaInternal(root: AsnType, inputSchema: AsnSchemaType, option
errors.push(new SchemaError(ESchemaError.MISMATCHING_TAG_NUMBER, context));
return errors;
}
} else if(inputSchema.idBlock.optionalID !== inputData.idBlock.optionalID) {
// If the tag and the class are matching we need to ensure that the schema is matching the optionalID flags from the data
// IF that ist the case the data should have been encoded context specific to point to that field
errors.push(new SchemaError(ESchemaError.MISMATCHING_CONTEXT_SPECIFIC_ID, context));
return errors;
}

//#endregion
Expand Down Expand Up @@ -496,6 +509,9 @@ function compareSchemaInternal(root: AsnType, inputSchema: AsnSchemaType, option
errors.push(new SchemaError(ESchemaError.MISMATCHING_OBJECT_LENGTH, context));
return errors;
}

// To match the input data with the schema we first need to match the mandatory attributes and then the optionals...

/** Helper variable to improve searching for context specific optional attributes */
/** The variable stores the last value where we found the last optional param */
let nextOptional = 0;
Expand Down
Loading