Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toSchema()
{
//region Construct and return new ASN.1 schema for this object
return (new asn1js.Set({
value: Array.from(this.certificates, element =>
{
switch(true)
{
case (element instanceof Certificate):
return element.toSchema();
case (element instanceof AttributeCertificateV1):
return new asn1js.Constructed({
idBlock: {
tagClass: 3,
tagNumber: 1 // [1]
},
value: element.toSchema().valueBlock.value
});
case (element instanceof AttributeCertificateV2):
return new asn1js.Constructed({
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Integer({ name: (names.version || "") }),
new asn1js.Constructed({
name: (names.originatorInfo || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: OriginatorInfo.schema().valueBlock.value
}),
new asn1js.Set({
value: [
new asn1js.Repeated({
name: (names.recipientInfos || ""),
value: RecipientInfo.schema()
})
]
}),
EncryptedContentInfo.schema(names.encryptedContentInfo || {}),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
value: [
new asn1js.Repeated({
function extensionAttributes(optional = false)
{
return (new asn1js.Set({
optional,
value: [
new asn1js.Primitive({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
isHexOnly: true
}),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
*/
const names = getParametersValue(parameters, "names", {});
return (
new asn1js.Set({
name: (names.blockName || ""),
value: [
new asn1js.Repeated({
name: (names.certificates || "certificates"),
value: new asn1js.Choice({
value: [
Certificate.schema(),
new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [
new asn1js.Any()
]
}), // JUST A STUB
toSchema()
{
//region Decode stored TBS value
if(this.valueBeforeDecode.byteLength === 0) // No stored encoded array, create "from scratch"
{
return (new asn1js.Sequence({
value: [new asn1js.Set({
value: Array.from(this.typesAndValues, element => element.toSchema())
})]
}));
}
const asn1 = asn1js.fromBER(this.valueBeforeDecode);
//endregion
//region Construct and return new ASN.1 schema for this object
return asn1.result;
//endregion
}
//**********************************************************************************
* @property {string} [bagAttributes]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier({ name: (names.bagId || "bagId") }),
new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [new asn1js.Any({ name: (names.bagValue || "bagValue") })] // EXPLICIT ANY value
}),
new asn1js.Set({
optional: true,
value: [
new asn1js.Repeated({
name: (names.bagAttributes || "bagAttributes"),
value: Attribute.schema()
})
]
})
]
}));
}
//**********************************************************************************
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [type]
* @property {string} [setName]
* @property {string} [values]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier({ name: (names.type || "") }),
new asn1js.Set({
name: (names.setName || ""),
value: [
new asn1js.Repeated({
name: (names.values || ""),
value: new asn1js.Any()
})
]
})
]
}));
}
//**********************************************************************************
outputArray.push(...Array.from(this.crls, element => element.toSchema()));
outputArray.push(...Array.from(this.otherRevocationInfos, element =>
{
const schema = element.toSchema();
schema.idBlock.tagClass = 3;
schema.idBlock.tagNumber = 1;
return schema;
}));
//endregion
//region Construct and return new ASN.1 schema for this object
return (new asn1js.Set({
value: outputArray
}));
//endregion
}
//**********************************************************************************
{
/**
* @type {Object}
* @property {string} [blockName] Name for entire block
* @property {string} [repeatedSequence] Name for "repeatedSequence" block
* @property {string} [repeatedSet] Name for "repeatedSet" block
* @property {string} [typeAndValue] Name for "typeAndValue" block
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Repeated({
name: (names.repeatedSequence || ""),
value: new asn1js.Set({
value: [
new asn1js.Repeated({
name: (names.repeatedSet || ""),
value: AttributeTypeAndValue.schema(names.typeAndValue || {})
})
]
})
})
]
}));
}
//**********************************************************************************