blob: 60f159695b2ec35a6e0b82425b0d6decb5f84b6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
export interface AsnFromBerResult {
offset: number;
result: any;
}
export interface AsnCompareSchemaResult {
verified: boolean;
result?: any;
}
export class AsnError extends Error {
static assertSchema(asn1: AsnCompareSchemaResult, target: string): asserts asn1 is { verified: true, result: any; } {
if (!asn1.verified) {
throw new Error(`Object's schema was not verified against input data for ${target}`);
}
}
public static assert(asn: AsnFromBerResult, target: string): void {
if (asn.offset === -1) {
throw new AsnError(`Error during parsing of ASN.1 data. Data is not correct for '${target}'.`);
}
}
constructor(message: string) {
super(message);
this.name = "AsnError";
}
}
|