How to use the asn1js.compareSchema function in asn1js

To help you get started, we’ve selected a few asn1js 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 / PKI.js / src / EnvelopedData.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"version",
			"originatorInfo",
			"recipientInfos",
			"encryptedContentInfo",
			"unprotectedAttrs"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			EnvelopedData.schema({
				names: {
					version: "version",
					originatorInfo: "originatorInfo",
					recipientInfos: "recipientInfos",
					encryptedContentInfo: {
						names: {
							blockName: "encryptedContentInfo"
						}
					},
					unprotectedAttrs: "unprotectedAttrs"
				}
			})
		);
github PeculiarVentures / PKI.js / src / CRLBag.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"crlId",
			"crlValue"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			CRLBag.schema({
				names: {
					id: "crlId",
					value: "crlValue"
				}
			})
		);
		
		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for CRLBag");
		//endregion
		
		//region Get internal properties from parsed schema
		this.crlId = asn1.result.crlId.valueBlock.toString();
		this.crlValue = asn1.result.crlValue;
github PeculiarVentures / PKI.js / src / PrivateKeyUsagePeriod.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"notBefore",
			"notAfter"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			PrivateKeyUsagePeriod.schema({
				names: {
					notBefore: "notBefore",
					notAfter: "notAfter"
				}
			})
		);

		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for PrivateKeyUsagePeriod");
		//endregion

		//region Get internal properties from parsed schema
		if("notBefore" in asn1.result)
		{
github PeculiarVentures / PKI.js / src / AuthorityKeyIdentifier.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"keyIdentifier",
			"authorityCertIssuer",
			"authorityCertSerialNumber"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			AuthorityKeyIdentifier.schema({
				names: {
					keyIdentifier: "keyIdentifier",
					authorityCertIssuer: "authorityCertIssuer",
					authorityCertSerialNumber: "authorityCertSerialNumber"
				}
			})
		);

		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for AuthorityKeyIdentifier");
		//endregion

		//region Get internal properties from parsed schema
		if("keyIdentifier" in asn1.result)
github PeculiarVentures / PKI.js / src / RecipientEncryptedKey.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"rid",
			"encryptedKey"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			RecipientEncryptedKey.schema({
				names: {
					rid: {
						names: {
							blockName: "rid"
						}
					},
					encryptedKey: "encryptedKey"
				}
			})
		);

		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for RecipientEncryptedKey");
		//endregion
github PeculiarVentures / PKI.js / src / SignedAndUnsignedAttributes.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"attributes"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			SignedAndUnsignedAttributes.schema({
				names: {
					tagNumber: this.type,
					attributes: "attributes"
				}
			})
		);

		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for SignedAndUnsignedAttributes");
		//endregion

		//region Get internal properties from parsed schema
		this.type = asn1.result.idBlock.tagNumber;
		this.encodedValue = asn1.result.valueBeforeDecode;
github PeculiarVentures / PKI.js / src / ResponseData.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"ResponseData",
			"ResponseData.version",
			"ResponseData.responderID",
			"ResponseData.producedAt",
			"ResponseData.responses",
			"ResponseData.responseExtensions"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			ResponseData.schema()
		);

		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for ResponseData");
		//endregion

		//region Get internal properties from parsed schema
		this.tbs = asn1.result.ResponseData.valueBeforeDecode;

		if("ResponseData.version" in asn1.result)
			this.version = asn1.result["ResponseData.version"].valueBlock.valueDec;

		if(asn1.result["ResponseData.responderID"].idBlock.tagNumber === 1)
			this.responderID = new RelativeDistinguishedNames({ schema: asn1.result["ResponseData.responderID"].valueBlock.value[0] });
github PeculiarVentures / CAdES.js / src / ContentHints.js View on Github external
fromSchema(schema)
	{
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			ContentHints.schema({
				names: {
					contentDescription: "contentDescription",
					contentType: "contentType"
				}
			})
		);
		
		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for ContentHints");
		//endregion
		
		//region Get internal properties from parsed schema
		if("contentDescription" in asn1.result)
			this.contentDescription = asn1.result.contentDescription.valueBlock.value;
github PeculiarVentures / CAdES.js / src / CompleteCertificateRefs.js View on Github external
fromSchema(schema)
	{
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			CompleteCertificateRefs.schema({
				names: {
					completeCertificateRefs: "completeCertificateRefs"
				}
			})
		);
		
		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for CompleteCertificateRefs");
		//endregion
		
		//region Get internal properties from parsed schema
		this.completeCertificateRefs = Array.from(asn1.result.completeCertificateRefs, element => new OtherCertID({ schema: element }));
		//endregion
	}
github PeculiarVentures / PKI.js / src / Signature.js View on Github external
fromSchema(schema)
	{
		//region Clear input data first
		clearProps(schema, [
			"signatureAlgorithm",
			"signature",
			"certs"
		]);
		//endregion
		
		//region Check the schema is valid
		const asn1 = asn1js.compareSchema(schema,
			schema,
			Signature.schema({
				names: {
					signatureAlgorithm: {
						names: {
							blockName: "signatureAlgorithm"
						}
					},
					signature: "signature",
					certs: "certs"
				}
			})
		);

		if(asn1.verified === false)
			throw new Error("Object's schema was not verified against input data for Signature");

asn1js

asn1js is a pure JavaScript library implementing this standard. ASN.1 is the basis of all X.509 related data structures and numerous other protocols used on the web

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis