Jon Kohne
Jon Kohne
Mar 1, 2019 · 1 min read

Hi, Klaasjan Tukker I’m trying to get the library import and eval to work for jsrsasign. The global variable assignment works after the initial call, but it looks like after I run the eval on the global variable in the test script, it isn’t properly parsing the object. I’m not seeing the same result as you in your tutorial. I end up with an object in memory that has a bunch of empty child objects, with no methods. Results in the entire script failing. I’ve pasted the eval result below…

I also tried removing the navigator and window faking statements, because Postman has them built-in, but that resulted in the module failing in a different way. Seems you were right in the tutorial that those need to be faked. I put them back in place. The script fails either way.

var navigator = {}; //fake a navigator object for the lib
var window = {}; //fake a window object for the lib

I’m not sure what’s wrong. I’ve tried about everything I can think of. Any ideas?

This is what is the result of eval(postman.getGlobalVariable(“jsrsasign-js”));

You’ll notice that the KJUR.jws.JWS.sign won’t work because it’s undefined. The KJUR.jws object is defined, but that’s where the child nodes stop. There are no deeper nodes, so I get an error of undefined : undefined when calling that method.

{“asn1”:{“ASN1Util”:{},”x509":{“OID”:{“atype2oidList”:{“CN”:”2.5.4.3",”L”:”2.5.4.7",”ST”:”2.5.4.8",”O”:”2.5.4.10",”OU”:”2.5.4.11",”C”:”2.5.4.6",”STREET”:”2.5.4.9",”DC”:”0.9.2342.19200300.100.1.25",”UID”:”0.9.2342.19200300.100.1.1",”SN”:”2.5.4.4",”T”:”2.5.4.12",”DN”:”2.5.4.49",”E”:”1.2.840.113549.1.9.1",”description”:”2.5.4.13",”businessCategory”:”2.5.4.15",”postalCode”:”2.5.4.17",”serialNumber”:”2.5.4.5",”uniqueIdentifier”:”2.5.4.45",”organizationIdentifier”:”2.5.4.97",”jurisdictionOfIncorporationL”:”1.3.6.1.4.1.311.60.2.1.1",”jurisdictionOfIncorporationSP”:”1.3.6.1.4.1.311.60.2.1.2",”jurisdictionOfIncorporationC”:”1.3.6.1.4.1.311.60.2.1.3"},”name2oidList”:{“sha1”:”1.3.14.3.2.26",”sha256":”2.16.840.1.101.3.4.2.1",”sha384":”2.16.840.1.101.3.4.2.2",”sha512":”2.16.840.1.101.3.4.2.3",”sha224":”2.16.840.1.101.3.4.2.4",”md5":”1.2.840.113549.2.5",”md2":”1.3.14.7.2.2.1",”ripemd160":”1.3.36.3.2.1",”MD2withRSA”:”1.2.840.113549.1.1.2",”MD4withRSA”:”1.2.840.113549.1.1.3",”MD5withRSA”:”1.2.840.113549.1.1.4",”SHA1withRSA”:”1.2.840.113549.1.1.5",”SHA224withRSA”:”1.2.840.113549.1.1.14",”SHA256withRSA”:”1.2.840.113549.1.1.11",”SHA384withRSA”:”1.2.840.113549.1.1.12",”SHA512withRSA”:”1.2.840.113549.1.1.13",”SHA1withECDSA”:”1.2.840.10045.4.1",”SHA224withECDSA”:”1.2.840.10045.4.3.1",”SHA256withECDSA”:”1.2.840.10045.4.3.2",”SHA384withECDSA”:”1.2.840.10045.4.3.3",”SHA512withECDSA”:”1.2.840.10045.4.3.4",”dsa”:”1.2.840.10040.4.1",”SHA1withDSA”:”1.2.840.10040.4.3",”SHA224withDSA”:”2.16.840.1.101.3.4.3.1",”SHA256withDSA”:”2.16.840.1.101.3.4.3.2",”rsaEncryption”:”1.2.840.113549.1.1.1",”commonName”:”2.5.4.3",”countryName”:”2.5.4.6",”localityName”:”2.5.4.7",”stateOrProvinceName”:”2.5.4.8",”streetAddress”:”2.5.4.9",”organizationName”:”2.5.4.10",”organizationalUnitName”:”2.5.4.11",”domainComponent”:”0.9.2342.19200300.100.1.25",”userId”:”0.9.2342.19200300.100.1.1",”surname”:”2.5.4.4",”title”:”2.5.4.12",”distinguishedName”:”2.5.4.49",”emailAddress”:”1.2.840.113549.1.9.1",”description”:”2.5.4.13",”businessCategory”:”2.5.4.15",”postalCode”:”2.5.4.17",”uniqueIdentifier”:”2.5.4.45",”organizationIdentifier”:”2.5.4.97",”jurisdictionOfIncorporationL”:”1.3.6.1.4.1.311.60.2.1.1",”jurisdictionOfIncorporationSP”:”1.3.6.1.4.1.311.60.2.1.2",”jurisdictionOfIncorporationC”:”1.3.6.1.4.1.311.60.2.1.3",”subjectKeyIdentifier”:”2.5.29.14",”keyUsage”:”2.5.29.15",”subjectAltName”:”2.5.29.17",”issuerAltName”:”2.5.29.18",”basicConstraints”:”2.5.29.19",”nameConstraints”:”2.5.29.30",”cRLDistributionPoints”:”2.5.29.31",”certificatePolicies”:”2.5.29.32",”authorityKeyIdentifier”:”2.5.29.35",”policyConstraints”:”2.5.29.36",”extKeyUsage”:”2.5.29.37",”authorityInfoAccess”:”1.3.6.1.5.5.7.1.1",”ocsp”:”1.3.6.1.5.5.7.48.1",”caIssuers”:”1.3.6.1.5.5.7.48.2",”anyExtendedKeyUsage”:”2.5.29.37.0",”serverAuth”:”1.3.6.1.5.5.7.3.1",”clientAuth”:”1.3.6.1.5.5.7.3.2",”codeSigning”:”1.3.6.1.5.5.7.3.3",”emailProtection”:”1.3.6.1.5.5.7.3.4",”timeStamping”:”1.3.6.1.5.5.7.3.8",”ocspSigning”:”1.3.6.1.5.5.7.3.9",”ecPublicKey”:”1.2.840.10045.2.1",”secp256r1":”1.2.840.10045.3.1.7",”secp256k1":”1.3.132.0.10",”secp384r1":”1.3.132.0.34",”pkcs5PBES2":”1.2.840.113549.1.5.13",”pkcs5PBKDF2":”1.2.840.113549.1.5.12",”des-EDE3-CBC”:”1.2.840.113549.3.7",”data”:”1.2.840.113549.1.7.1",”signed-data”:”1.2.840.113549.1.7.2",”enveloped-data”:”1.2.840.113549.1.7.3",”digested-data”:”1.2.840.113549.1.7.5",”encrypted-data”:”1.2.840.113549.1.7.6",”authenticated-data”:”1.2.840.113549.1.9.16.1.2",”tstinfo”:”1.2.840.113549.1.9.16.1.4",”extensionRequest”:”1.2.840.113549.1.9.14"},”objCache”:{}},”X509Util”:{}},”cms”:{“CMSUtil”:{}},”tsp”:{“TSPUtil”:{}},”cades”:{“CAdESUtil”:{}},”csr”:{“CSRUtil”:{}},”ocsp”:{“DEFAULT_HASH”:”sha1",”OCSPUtil”:{}}},”lang”:{},”crypto”:{“Util”:{“DIGESTINFOHEAD”:{“sha1”:”3021300906052b0e03021a05000414",”sha224":”302d300d06096086480165030402040500041c”,”sha256":”3031300d060960864801650304020105000420",”sha384":”3041300d060960864801650304020205000430",”sha512":”3051300d060960864801650304020305000440",”md2":”3020300c06082a864886f70d020205000410",”md5":”3020300c06082a864886f70d020505000410",”ripemd160":”3021300906052b2403020105000414"},”DEFAULTPROVIDER”:{“md5”:”cryptojs”,”sha1":”cryptojs”,”sha224":”cryptojs”,”sha256":”cryptojs”,”sha384":”cryptojs”,”sha512":”cryptojs”,”ripemd160":”cryptojs”,”hmacmd5":”cryptojs”,”hmacsha1":”cryptojs”,”hmacsha224":”cryptojs”,”hmacsha256":”cryptojs”,”hmacsha384":”cryptojs”,”hmacsha512":”cryptojs”,”hmacripemd160":”cryptojs”,”MD5withRSA”:”cryptojs/jsrsa”,”SHA1withRSA”:”cryptojs/jsrsa”,”SHA224withRSA”:”cryptojs/jsrsa”,”SHA256withRSA”:”cryptojs/jsrsa”,”SHA384withRSA”:”cryptojs/jsrsa”,”SHA512withRSA”:”cryptojs/jsrsa”,”RIPEMD160withRSA”:”cryptojs/jsrsa”,”MD5withECDSA”:”cryptojs/jsrsa”,”SHA1withECDSA”:”cryptojs/jsrsa”,”SHA224withECDSA”:”cryptojs/jsrsa”,”SHA256withECDSA”:”cryptojs/jsrsa”,”SHA384withECDSA”:”cryptojs/jsrsa”,”SHA512withECDSA”:”cryptojs/jsrsa”,”RIPEMD160withECDSA”:”cryptojs/jsrsa”,”SHA1withDSA”:”cryptojs/jsrsa”,”SHA224withDSA”:”cryptojs/jsrsa”,”SHA256withDSA”:”cryptojs/jsrsa”,”MD5withRSAandMGF1":”cryptojs/jsrsa”,”SHA1withRSAandMGF1":”cryptojs/jsrsa”,”SHA224withRSAandMGF1":”cryptojs/jsrsa”,”SHA256withRSAandMGF1":”cryptojs/jsrsa”,”SHA384withRSAandMGF1":”cryptojs/jsrsa”,”SHA512withRSAandMGF1":”cryptojs/jsrsa”,”RIPEMD160withRSAandMGF1":”cryptojs/jsrsa”},”CRYPTOJSMESSAGEDIGESTNAME”:{“md5”:{“$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}},”sha1":{“$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}},”sha224":{“$super”:{“$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}}},”sha256":{“$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}},”sha384":{“$super”:{“blockSize”:32,”$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}}},”sha512":{“blockSize”:32,”$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}},”ripemd160":{“$super”:{“cfg”:{“$super”:{}},”blockSize”:16,”$super”:{“_minBufferSize”:0,”$super”:{}}}}},”SECURERANDOMGEN”:{}},”OID”:{“oidhex2name”:{“2a864886f70d010101”:”rsaEncryption”,”2a8648ce3d0201":”ecPublicKey”,”2a8648ce380401":”dsa”,”2a8648ce3d030107":”secp256r1",”2b8104001f”:”secp192k1",”2b81040021":”secp224r1",”2b8104000a”:”secp256k1",”2b81040023":”secp521r1",”2b81040022":”secp384r1",”2a8648ce380403":”SHA1withDSA”,”608648016503040301":”SHA224withDSA”,”608648016503040302":”SHA256withDSA”}},”ECParameterDB”:{}},”jws”:{“IntDate”:{}}}

    Jon Kohne

    Written by

    Jon Kohne

    Web Applications Engineer