How to use the pkijs.TimeStampResp function in pkijs

To help you get started, we’ve selected a few pkijs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / CAdES.js / src / ArchiveTimeStampV3.js View on Github external
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()
github PeculiarVentures / CAdES.js / examples / CAdESComplexExample / es6.js View on Github external
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);
	});
github PeculiarVentures / CAdES.js / src / CAdESCTimestamp.js View on Github external
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()
			]
		});
github PeculiarVentures / CAdES.js / src / ArchiveTimeStampV3.js View on Github external
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");
github PeculiarVentures / CAdES.js / src / SignatureTimeStamp.js View on Github external
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()
			]
		});

pkijs

Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it p

BSD-3-Clause
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis