packages/js-x509-utils/src/x509.js
function setRDNSequence(options) {
  const encodedArray = Object.keys(options).map((k) => {
    if (Object.keys(attributeTypeOIDMap).indexOf(k) < 0) throw new Error('InvalidOptionSpecification');

    const type = attributeTypeOIDMap[k];
    let value;
    if (['dnQualifier, countryName, serialNumber'].indexOf(k) >= 0) {
      if (k === 'countryName' && options[k].length !== 2) throw new Error('InvalidCountryNameCode');
      value = rfc5280.DirectoryString.encode({type: 'printableString', value: options[k]}, 'der');
    }
    else value = rfc5280.DirectoryString.encode({type: 'utf8String', value: options[k]}, 'der');

    return {type, value};
  });

  return [encodedArray];
}
function setRDNSequence(options) {
  const encodedArray = Object.keys(options).map((k) => {
    if (Object.keys(attributeTypeOIDMap).indexOf(k) < 0) throw new Error('InvalidOptionSpecification');

    const type = attributeTypeOIDMap[k];
    let value;
    if (['dnQualifier, countryName, serialNumber'].indexOf(k) >= 0) {
      if (k === 'countryName' && options[k].length !== 2) throw new Error('InvalidCountryNameCode');
      value = rfc5280.DirectoryString.encode({type: 'printableString', value: options[k]}, 'der');
    }
    else value = rfc5280.DirectoryString.encode({type: 'utf8String', value: options[k]}, 'der');

    return {type, value};
  });

  return [encodedArray];
}
function setRDNSequence ( options ) { const encodedArray = Object . keys ( options ) . map ( ( k ) => { if ( Object . keys ( attributeTypeOIDMap ) . indexOf ( k ) < 0 ) throw new Error ( 'InvalidOptionSpecification' ) ; const type = attributeTypeOIDMap [ k ] ; let value ; if ( [ 'dnQualifier, countryName, serialNumber' ] . indexOf ( k ) >= 0 ) { if ( k === 'countryName' && options [ k ] . length !== 2 ) throw new Error ( 'InvalidCountryNameCode' ) ; value = rfc5280 . DirectoryString . encode ( { type : 'printableString' , value : options [ k ] } , 'der' ) ; } else value = rfc5280 . DirectoryString . encode ( { type : 'utf8String' , value : options [ k ] } , 'der' ) ; return { type , value } ; } ) ; return [ encodedArray ] ; }
Set RDN sequence for issuer and subject fields
@param {Object} options - RDN Sequence
@return {{type: *, value: *}[][]}
@throws {Error} - throws if InvalidOptionSpecification or InvalidCountryNameCode.
Set RDN sequence for issuer and subject fields