How to use the pkijs.Attribute 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 / CompleteRevocationReferences.js View on Github external
makeAttribute(parameters = {})
	{
		//region Create and return attribute
		return new Attribute({
			type: "1.2.840.113549.1.9.16.2.22",
			values: [
				this.toSchema()
			]
		});
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / common.js View on Github external
result => {
			//region Create signed attribute with "message digest" value 
			const attribute = new Attribute({
				type: "1.2.840.113549.1.9.4",
				values: [
					new asn1js.OctetString({ valueHex: result })
				]
			});
			//endregion 
			
			resultAttributes.push(attribute);
		},
		error => Promise.reject(error)
github PeculiarVentures / CAdES.js / src / SignatureTimeStamp.js View on Github external
//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()
			]
		});
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / CompleteCertificateReferences.js View on Github external
makeAttribute(parameters = {})
	{
		//region Create and return attribute
		return new Attribute({
			type: "1.2.840.113549.1.9.16.2.21",
			values: [
				this.toSchema()
			]
		});
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / ArchiveTimeStampV3.js View on Github external
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");
			
			let parsedValue;
			
			try
			{
				parsedValue = new ATSHashIndex({ schema: attribute.values[0] });
			}
			catch(e)
			{
				throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect aTSHashIndex value");
			}
			
			this.aTSHashIndex = parsedValue;
github PeculiarVentures / CAdES.js / src / CertificateValues.js View on Github external
makeAttribute()
	{
		return new Attribute({
			type: "1.2.840.113549.1.9.16.2.23",
			values: [
				this.toSchema()
			]
		});
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / ATSHashIndex.js View on Github external
makeAttribute(parameters = {})
	{
		//region Create and return attribute
		return new Attribute({
			type: "0.4.0.1733.2.5",
			values: [
				this.toSchema()
			]
		});
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / common.js View on Github external
() => {
			//region Create "Content type" attribute 
			const contentTypeAttribute = new Attribute({
				type: "1.2.840.113549.1.9.3",
				values: [
					new asn1js.ObjectIdentifier({ value: contentOID })
				]
			});
			
			resultAttributes.push(contentTypeAttribute);
			//endregion 
			
			//region Create "Signing Time" attribute 
			const signingTimeAttribute = new Attribute({
				type: "1.2.840.113549.1.9.5",
				values: [
					new asn1js.UTCTime({ valueDate: getUTCDate(new Date()) })
				]
			});
			
			resultAttributes.push(signingTimeAttribute);
			//endregion 
		},
		error => Promise.reject(error)
github PeculiarVentures / CAdES.js / src / CAdESCTimestamp.js View on Github external
//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()
			]
		});
		//endregion
	}
	//**********************************************************************************

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 2 months ago

Package Health Score

84 / 100
Full package analysis