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 Create array for output sequence
const outputArray = [];
outputArray.push(new asn1js.Integer({ value: this.version }));
outputArray.push(this.messageImprint.toSchema());
if("reqPolicy" in this)
outputArray.push(new asn1js.ObjectIdentifier({ value: this.reqPolicy }));
if("nonce" in this)
outputArray.push(this.nonce);
if(("certReq" in this) && (TimeStampReq.compareWithDefault("certReq", this.certReq) === false))
outputArray.push(new asn1js.Boolean({ value: this.certReq }));
//region Create array of extensions
if("extensions" in this)
{
outputArray.push(new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: Array.from(this.extensions, element => element.toSchema())
}));
}
//endregion
//endregion
//region Construct and return new ASN.1 schema for this object
value: [
new asn1js.Integer({ name: (names.version || "TimeStampReq.version") }),
MessageImprint.schema(names.messageImprint || {
names: {
blockName: "TimeStampReq.messageImprint"
}
}),
new asn1js.ObjectIdentifier({
name: (names.reqPolicy || "TimeStampReq.reqPolicy"),
optional: true
}),
new asn1js.Integer({
name: (names.nonce || "TimeStampReq.nonce"),
optional: true
}),
new asn1js.Boolean({
name: (names.certReq || "TimeStampReq.certReq"),
optional: true
}),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [new asn1js.Repeated({
name: (names.extensions || "TimeStampReq.extensions"),
value: Extension.schema()
})]
}) // IMPLICIT SEQUENCE value
]
}));
toSchema()
{
//region Create array for output sequence
const outputArray = [];
outputArray.push(new asn1js.Integer({ value: this.version }));
outputArray.push(new asn1js.ObjectIdentifier({ value: this.policy }));
outputArray.push(this.messageImprint.toSchema());
outputArray.push(this.serialNumber);
outputArray.push(new asn1js.GeneralizedTime({ valueDate: this.genTime }));
if("accuracy" in this)
outputArray.push(this.accuracy.toSchema());
if("ordering" in this)
outputArray.push(new asn1js.Boolean({ value: this.ordering }));
if("nonce" in this)
outputArray.push(this.nonce);
if("tsa" in this)
{
outputArray.push(new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [this.tsa.toSchema()]
}));
}
//region Create array of extensions
if("extensions" in this)
value: [
new asn1js.Integer({ name: (names.version || "TSTInfo.version") }),
new asn1js.ObjectIdentifier({ name: (names.policy || "TSTInfo.policy") }),
MessageImprint.schema(names.messageImprint || {
names: {
blockName: "TSTInfo.messageImprint"
}
}),
new asn1js.Integer({ name: (names.serialNumber || "TSTInfo.serialNumber") }),
new asn1js.GeneralizedTime({ name: (names.genTime || "TSTInfo.genTime") }),
Accuracy.schema(names.accuracy || {
names: {
blockName: "TSTInfo.accuracy"
}
}),
new asn1js.Boolean({
name: (names.ordering || "TSTInfo.ordering"),
optional: true
}),
new asn1js.Integer({
name: (names.nonce || "TSTInfo.nonce"),
optional: true
}),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [GeneralName.schema(names.tsa || {
names: {
blockName: "TSTInfo.tsa"
toSchema()
{
//region Create array for output sequence
const outputArray = [];
if(this.cA !== BasicConstraints.defaultValues("cA"))
outputArray.push(new asn1js.Boolean({ value: this.cA }));
if("pathLenConstraint" in this)
{
if(this.pathLenConstraint instanceof asn1js.Integer)
outputArray.push(this.pathLenConstraint);
else
outputArray.push(new asn1js.Integer({ value: this.pathLenConstraint }));
}
//endregion
//region Construct and return new ASN.1 schema for this object
return (new asn1js.Sequence({
value: outputArray
}));
//endregion
}
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [cA]
* @property {string} [pathLenConstraint]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Boolean({
optional: true,
name: (names.cA || "")
}),
new asn1js.Integer({
optional: true,
name: (names.pathLenConstraint || "")
})
]
}));
}
//**********************************************************************************
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [extnID]
* @property {string} [critical]
* @property {string} [extnValue]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier({ name: (names.extnID || "") }),
new asn1js.Boolean({
name: (names.critical || ""),
optional: true
}),
new asn1js.OctetString({ name: (names.extnValue || "") })
]
}));
}
//**********************************************************************************
toSchema()
{
//region Create array for output sequence
const outputArray = [];
outputArray.push(new asn1js.ObjectIdentifier({ value: this.extnID }));
if(this.critical !== Extension.defaultValues("critical"))
outputArray.push(new asn1js.Boolean({ value: this.critical }));
outputArray.push(this.extnValue);
//endregion
//region Construct and return new ASN.1 schema for this object
return (new asn1js.Sequence({
value: outputArray
}));
//endregion
}
//**********************************************************************************