Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added OVERRIDE to allow window and navigator to be used in scripts

  • Loading branch information...
commit 8456ddb393a6fbbcb1c45468d7a0281ccc8b47c9 1 parent c28da68
@benadida benadida authored
View
1  bundle-prelim.js
@@ -0,0 +1 @@
+OVERRIDE = {window:window, navigator:navigator};
View
2  bundle.js
@@ -31,5 +31,7 @@
var utils = require("./utils");
var jwcert = require("./jwcert");
+var jwt = require("./jwt");
+var jwk = require("./jwk");
var vep = require("./vep");
View
6 bundle.sh
@@ -6,6 +6,7 @@ echo '****Bundling VEP for Browser****'
echo ''
INPUT="./bundle.js"
+TMP="./tempbundle.js"
OUTPUT="./vepbundle.js"
# package
@@ -19,5 +20,8 @@ if [ -f "$OUTPUT" ]; then
rm "$OUTPUT"
fi
-browserify "$INPUT" -o "$OUTPUT"
+browserify "$INPUT" -o "$TMP"
+cat bundle-prelim.js > "$OUTPUT"
+cat "$TMP" >> "$OUTPUT"
+rm "$TMP"
View
7 libs/preliminaries.js
@@ -1,5 +1,5 @@
// faking some objects so all goes well
-if (typeof(navigator) == "undefined") {
+if (typeof(OVERRIDE) == "undefined") {
var navigator = {
appName: "Netscape"
};
@@ -15,7 +15,10 @@ if (typeof(navigator) == "undefined") {
var alert = function(msg) {
console.log(msg);
- }
+ };
+} else {
+ var navigator = OVERRIDE.navigator;
+ var window = OVERRIDE.window;
}
View
16 test.html
@@ -2,10 +2,20 @@
<title>test VEP from Browser</title>
<script type="text/javascript" src="vepbundle.js"></script>
<script type="text/javascript">
- var jwt = require("./jwt");
- var keypair = jwt.getByAlg("RS").KeyPair.generate(64);
- alert(keypair.publicKey.serialize());
+ // a small subset of vows tests
+ function runtests() {
+ var jwk = require("./jwk");
+ var jwt = require("./jwt");
+ var jwcert = require("./jwcert");
+ var user_kp = jwk.KeyPair.generate("RS",64);
+ var root_kp = jwk.KeyPair.generate("RS",64);
+ var cert = new jwcert.JWCert("foo.com", new Date(), user_kp.publicKey, {email : "foo@foo.com"}).sign(root_kp.secretKey);
+
+ var tok = new jwt.JWT(null, new Date(), "rp.com").sign(user_kp.secretKey);
+ alert("cert:\n" + cert + "\nassertion:\n" + tok);
+ }
</script>
</head>
<body>
+<button onclick="runtests();">run tests</button>
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.