Static ReadonlyIsValidate that the tag is any valid ASN.1 type
Static ReadonlyIsValidate the tag is either a GeneralizedTime or UTCTime
Static ReadonlyIsValidate that the tag is any string type of PrintableString, IA5String, or UTF8String
Static ReadonlyIsValidate that the tag is a BitString
Static ReadonlyIsValidate that the tag is a Boolean
Static ReadonlyIsValidate the tag is either a GeneralizedTime or UTCTime depending on the value (i.e. before or after 2050) as per RFC 5280
Static ReadonlyIsValidate that the tag is an Integer
Static ReadonlyIsValidate that the tag is a Null
Static ReadonlyIsValidate that the tag is an OctetString
Static ReadonlyIsValidate that the tag is an Object Identifier (OID)
Static ReadonlyIsValidate that the tag is a Set
Static ReadonlyIsValidate that the tag is the least-requisite string type (i.e. PrintableString, IA5String, or UTF8String) for the value
Static ReadonlyIsValidate that the tag is any valid ASN.1 type, but do not attempt to interpret it
Convert a plain JavaScript object back to an ASN.1 object based on the schema.
Converts plain JavaScript objects back to ASN1 representation according to the schema:
Example schema: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: ValidateASN1.IsAnyString, age: ValidateASN1.IsInteger } } Input: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n } Output: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n } }
Convert an ASN.1 object to a JavaScript object (including primitives) based on the schema.
Converts ASN1 objects to plain JavaScript objects according to the schema:
Example schema: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: ValidateASN1.IsAnyString, age: ValidateASN1.IsInteger } } Input: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n } } Output: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n }
Staticagainst
Helper class to validate ASN.1 values against schemas
Some schemas are basic types, others are more complex Basic types are defined as:
More complex types are defined as:
Choice (named):
{ choice: { name1: schema1, name2: schema2, ... } }- Converts to{ name1: value }or{ name2: value }Choice (legacy array):
{ choice: [ schema1, schema2, ... ] }- Converts to union type (ambiguous for re-encoding)Sequence of:
{ sequenceOf: schema }Optional:
{ optional: schema }Context Tag:
{ type: 'context'; kind: 'implicit' | 'explicit'; contains: schema; value: number }OID:
{ type: 'oid'; oid: string }String:
{ type: 'string'; kind: 'printable' | 'ia5' | 'utf8' }Date:
{ type: 'date'; kind: 'utc' | 'general' }Fixed Integer:
bigint(where the value is the exact integer required)Sequence:
[ schema1, schema2, ... ](a tuple where each item is a schema)Lazy Schema:
() => schema(a function that returns a schema, useful for recursive schemas)