How to use the asn1js.Set 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 / CertificateSet.js View on Github external
toSchema()
	{
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Set({
			value: Array.from(this.certificates, element =>
			{
				switch(true)
				{
					case (element instanceof Certificate):
						return element.toSchema();
					case (element instanceof AttributeCertificateV1):
						return new asn1js.Constructed({
							idBlock: {
								tagClass: 3,
								tagNumber: 1 // [1]
							},
							value: element.toSchema().valueBlock.value
						});
					case (element instanceof AttributeCertificateV2):
						return new asn1js.Constructed({
github PeculiarVentures / PKI.js / src / EnvelopedData.js View on Github external
const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Integer({ name: (names.version || "") }),
				new asn1js.Constructed({
					name: (names.originatorInfo || ""),
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					value: OriginatorInfo.schema().valueBlock.value
				}),
				new asn1js.Set({
					value: [
						new asn1js.Repeated({
							name: (names.recipientInfos || ""),
							value: RecipientInfo.schema()
						})
					]
				}),
				EncryptedContentInfo.schema(names.encryptedContentInfo || {}),
				new asn1js.Constructed({
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 1 // [1]
					},
					value: [
						new asn1js.Repeated({
github PeculiarVentures / PKI.js / src / GeneralName.js View on Github external
function extensionAttributes(optional = false)
{
	return (new asn1js.Set({
		optional,
		value: [
			new asn1js.Primitive({
				optional: true,
				idBlock: {
					tagClass: 3, // CONTEXT-SPECIFIC
					tagNumber: 0 // [0]
				},
				isHexOnly: true
			}),
			new asn1js.Constructed({
				optional: true,
				idBlock: {
					tagClass: 3, // CONTEXT-SPECIFIC
					tagNumber: 1 // [1]
				},
github PeculiarVentures / PKI.js / src / CertificateSet.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (
			new asn1js.Set({
				name: (names.blockName || ""),
				value: [
					new asn1js.Repeated({
						name: (names.certificates || "certificates"),
						value: new asn1js.Choice({
							value: [
								Certificate.schema(),
								new asn1js.Constructed({
									idBlock: {
										tagClass: 3, // CONTEXT-SPECIFIC
										tagNumber: 0 // [0]
									},
									value: [
										new asn1js.Any()
									]
								}), // JUST A STUB
github PeculiarVentures / PKI.js / src / RelativeDistinguishedNames.js View on Github external
toSchema()
	{
		//region Decode stored TBS value
		if(this.valueBeforeDecode.byteLength === 0) // No stored encoded array, create "from scratch"
		{
			return (new asn1js.Sequence({
				value: [new asn1js.Set({
					value: Array.from(this.typesAndValues, element => element.toSchema())
				})]
			}));
		}

		const asn1 = asn1js.fromBER(this.valueBeforeDecode);
		//endregion

		//region Construct and return new ASN.1 schema for this object
		return asn1.result;
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / SafeBag.js View on Github external
* @property {string} [bagAttributes]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.ObjectIdentifier({ name: (names.bagId || "bagId") }),
				new asn1js.Constructed({
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					value: [new asn1js.Any({ name: (names.bagValue || "bagValue") })] // EXPLICIT ANY value
				}),
				new asn1js.Set({
					optional: true,
					value: [
						new asn1js.Repeated({
							name: (names.bagAttributes || "bagAttributes"),
							value: Attribute.schema()
						})
					]
				})
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / Attribute.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [type]
		 * @property {string} [setName]
		 * @property {string} [values]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.ObjectIdentifier({ name: (names.type || "") }),
				new asn1js.Set({
					name: (names.setName || ""),
					value: [
						new asn1js.Repeated({
							name: (names.values || ""),
							value: new asn1js.Any()
						})
					]
				})
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / RevocationInfoChoices.js View on Github external
outputArray.push(...Array.from(this.crls, element => element.toSchema()));
		
		outputArray.push(...Array.from(this.otherRevocationInfos, element =>
		{
			const schema = element.toSchema();
			
			schema.idBlock.tagClass = 3;
			schema.idBlock.tagNumber = 1;
			
			return schema;
		}));
		//endregion
		
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Set({
			value: outputArray
		}));
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / RelativeDistinguishedNames.js View on Github external
{
		/**
		 * @type {Object}
		 * @property {string} [blockName] Name for entire block
		 * @property {string} [repeatedSequence] Name for "repeatedSequence" block
		 * @property {string} [repeatedSet] Name for "repeatedSet" block
		 * @property {string} [typeAndValue] Name for "typeAndValue" block
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Repeated({
					name: (names.repeatedSequence || ""),
					value: new asn1js.Set({
						value: [
							new asn1js.Repeated({
								name: (names.repeatedSet || ""),
								value: AttributeTypeAndValue.schema(names.typeAndValue || {})
							})
						]
					})
				})
			]
		}));
	}
	//**********************************************************************************

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

76 / 100
Full package analysis