Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if("tspResponse" in parameters)
tspResponse = parameters.tspResponse;
else
{
if("tspResponse" in this)
tspResponse = this.tspResponse;
else
throw new Error("Parameter \"tspResponse\" is mandatory for making archive-time-stamp-v3 attribute");
}
this.tspResponse = tspResponse;
//endregion
//region Change type of "tspResponse"
const asn1 = asn1js.fromBER(tspResponse);
tspResponse = new TimeStampResp({ schema: asn1.result });
//endregion
//region Initialize internal variables from "tspResponse"
if("timeStampToken" in tspResponse)
this.fromSchema(tspResponse.timeStampToken.toSchema(), false);
else
throw new Error("No neccessary \"timeStampToken\" inside \"tspResponse\"");
//endregion
//region Append "ATSHashIndex" into local unsigned attributes
const cmsSignedData = new SignedData({ schema: this.content });
cmsSignedData.signerInfos[0].unsignedAttrs = new SignedAndUnsignedAttributes({
type: 1, // UnsignedAttributes
attributes: [
this.aTSHashIndex.makeAttribute()
sequence = sequence.then(() =>
{
const tspResponse = new TimeStampResp({
status: new PKIStatusInfo({
status: 0 // granted
}),
timeStampToken: new ContentInfo({
contentType: "1.2.840.113549.1.7.2",
content: cmsSignedSimpl.toSchema(false)
})
});
return tspResponse.toSchema().toBER(false);
});
if("tspResponse" in parameters)
tspResponse = parameters.tspResponse;
else
{
if("tspResponse" in this)
tspResponse = this.tspResponse;
else
throw new Error("Parameter \"tspResponse\" is mandatory for making \"CAdES-C-Timestamp\" attribute");
}
this.tspResponse = tspResponse;
//endregion
//region Change type of "tspResponse"
const asn1 = asn1js.fromBER(tspResponse);
tspResponse = new TimeStampResp({ schema: asn1.result });
//endregion
//region Initialize internal variables from "tspResponse"
if("timeStampToken" in tspResponse)
this.fromSchema(tspResponse.timeStampToken.toSchema());
else
throw new Error("No neccessary \"timeStampToken\" inside \"tspResponse\"");
//endregion
//region Create and return attribute
return new Attribute({
type: "1.2.840.113549.1.9.16.2.25",
values: [
this.toSchema()
]
});
fromSchema(schema, initValues = true)
{
super.fromSchema(schema);
if(initValues)
{
if(this.contentType !== "1.2.840.113549.1.7.2")
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect content type");
this.tspResponse = new TimeStampResp({ timeStampToken: schema });
const cmsSignedData = new SignedData({ schema: this.content });
if(cmsSignedData.signerInfos.length !== 1)
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect signerInfos length");
if(("unsignedAttrs" in cmsSignedData.signerInfos[0]) === false)
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: missing unsignedAttrs");
if(cmsSignedData.signerInfos[0].unsignedAttrs.attributes.length !== 1)
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect unsignedAttrs length");
const attribute = new Attribute(cmsSignedData.signerInfos[0].unsignedAttrs.attributes[0]);
if(attribute.type !== "0.4.0.1733.2.5")
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect type for aTSHashIndex value");
if("tspResponse" in parameters)
tspResponse = parameters.tspResponse;
else
{
if("tspResponse" in this)
tspResponse = this.tspResponse;
else
throw new Error("Parameter \"tspResponse\" is mandatory for making \"signature-time-stamp\" attribute");
}
this.tspResponse = tspResponse;
//endregion
//region Change type of "tspResponse"
const asn1 = asn1js.fromBER(tspResponse);
tspResponse = new TimeStampResp({ schema: asn1.result });
//endregion
//region Initialize internal variables from "tspResponse"
if("timeStampToken" in tspResponse)
this.fromSchema(tspResponse.timeStampToken.toSchema());
else
throw new Error("No neccessary \"timeStampToken\" inside \"tspResponse\"");
//endregion
//region Create and return attribute
return new Attribute({
type: "1.2.840.113549.1.9.16.2.14",
values: [
this.toSchema()
]
});