Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider a verify JS file that can run headless #199

Closed
deinspanjer opened this issue Oct 6, 2016 · 3 comments
Closed

Consider a verify JS file that can run headless #199

deinspanjer opened this issue Oct 6, 2016 · 3 comments

Comments

@deinspanjer
Copy link

I needed to verify a JWT token from Google inside PostgreSQL. After some research, I determined that the quickest way I might be able to do it was using the plv8 language and running a standalone JS verifier.

I used your jsrsassign and managed to get it running although I had to hack out the YUI and other parts that were doing window.crypto related calls.

I don't expect this to be easily reusable by anyone else, but I thought I'd share it in case you are interested in providing a compact version of the JS as a module that could serve that need.

https://gist.github.com/deinspanjer/5f25e50653c83989dbaff283a1d46d6b

@MaikStohn
Copy link

Hi,

i used it "headless" in postman with a simple trick to just provide the window and navigator object:

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

My "postman" way:


  1. create a GET to
https://raw.githubusercontent.com/kjur/jsrsasign/master/jsrsasign-latest-all-min.js

and in Tests put this line:

postman.setGlobalVariable("jsrsasign-js", responseBody);

  1. in your script where you need jsrsasign:
//load the external jsrsasign lib (must be fetched and stored in global before)
var navigator = {}; //fake a navigator object for the lib
var window = {}; //fake a window object for the lib
eval(postman.getGlobalVariable("jsrsasign-js")); //import javascript jsrsasign
...

Hope it's useful.

@Ruffio
Copy link

Ruffio commented Jul 2, 2017

@MaikStohn and @deinspanjer is this still an issue/feature request? As I understand there have been performed some YUI cleanup/removal of dependencies...

@deinspanjer
Copy link
Author

I have been able to install jsrasign in plv8 using the project plv8-npm. The YUI cleanup did help although I'm not quite sure why it is still being included when it is only being used for one small function that could easily be polyfilled. Regardless, I'm in good shape now and am fine closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants