diff --git a/bower.json b/bower.json index cb3992e..e4806c0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "firebase-token-generator", - "version": "1.1.2", + "version": "1.1.3", "homepage": "https://firebase.com", "authors": [ "Firebase " diff --git a/build/firebase-token-generator-debug.js b/build/firebase-token-generator-debug.js index 1c1a678..af39d0f 100644 --- a/build/firebase-token-generator-debug.js +++ b/build/firebase-token-generator-debug.js @@ -999,8 +999,8 @@ fb.tokengenerator.validation.validateCredentialOptions = function(fnName, argume } }; fb.tokengenerator.validation.validateOption = function(prefix, optName, opt, expectedType, suffix) { - if(typeof opt !== expectedType) { - throw new Error(prefix + " option " + optName + " must be " + suffix); + if(typeof opt !== expectedType || expectedType === "number" && isNaN(opt)) { + throw new Error(prefix + ' option "' + optName + '" must be ' + suffix + ", instead got " + opt); } }; goog.provide("goog.dom.NodeType"); @@ -2450,28 +2450,28 @@ FirebaseTokenGenerator.prototype.createOptionsClaims = function(func_name, opts) if(opts[o] instanceof Date) { claims[code] = Math.round(opts[o].getTime() / 1E3) }else { - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number"); claims[code] = opts[o] } break; case "admin": - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean"); claims["admin"] = opts[o]; break; case "debug": - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean"); claims["debug"] = opts[o]; break; case "simulate": - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean"); claims["simulate"] = opts[o]; break; case "iat": - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number"); claims["iat"] = opts[o]; break; default: - throw new Error(func_name + " unrecognized option: " + o); + throw new Error(func_name + ': unrecognized "' + o + '" option'); } } return claims diff --git a/build/firebase-token-generator-node.js b/build/firebase-token-generator-node.js index b12f158..ae0991e 100644 --- a/build/firebase-token-generator-node.js +++ b/build/firebase-token-generator-node.js @@ -40,7 +40,7 @@ b[d>>>5]|=128<<24-d%32;b[(d+64>>>9<<4)+15]=c;a.sigBytes=4*b.length;this._process this._hasher,a=b.finalize(a);b.reset();return b.finalize(this._oKey.clone().concat(a))}})})();fb.tokengenerator.validation={};fb.tokengenerator.validation.validateArgCount=function(a,b,c,d){var e;dc&&(e=0===c?"none":"no more than "+c);if(e)throw Error(a+" failed: Was called with "+d+(1===d?" argument.":" arguments.")+" Expects "+e+".");}; fb.tokengenerator.validation.errorPrefix_=function(a,b,c){var d="";switch(b){case 1:d=c?"first":"First";break;case 2:d=c?"second":"Second";break;case 3:d=c?"third":"Third";break;case 4:d=c?"fourth":"Fourth";break;default:fb.core.util.validation.assert(!1,"errorPrefix_ called with argumentNumber > 4. Need to update it?")}return a+" failed: "+(d+" argument ")}; fb.tokengenerator.validation.validateSecret=function(a,b,c){if(!goog.isString(c))throw Error(fb.tokengenerator.validation.errorPrefix_(a,b,!1)+"must be a valid firebase namespace secret.");};fb.tokengenerator.validation.validateCredentialData=function(){};fb.tokengenerator.validation.validateCredentialOptions=function(a,b,c,d){if(!d||goog.isDef(c))if(null===c||"object"!=typeof c)throw Error(fb.tokengenerator.validation.errorPrefix_(a,b,d)+"must be a dictionary of token options.");}; -fb.tokengenerator.validation.validateOption=function(a,b,c,d,e){if(typeof c!==d)throw Error(a+" option "+b+" must be "+e);};goog.dom={};goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.debug={};goog.debug.Error=function(a){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.string={};goog.string.Unicode={NBSP:"\u00a0"};goog.string.startsWith=function(a,b){return 0==a.lastIndexOf(b,0)};goog.string.endsWith=function(a,b){var c=a.length-b.length;return 0<=c&&a.indexOf(b,c)==c};goog.string.caseInsensitiveStartsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(0,b.length))};goog.string.caseInsensitiveEndsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(a.length-b.length,b.length))}; +fb.tokengenerator.validation.validateOption=function(a,b,c,d,e){if(typeof c!==d||"number"===d&&isNaN(c))throw Error(a+' option "'+b+'" must be '+e+", instead got "+c);};goog.dom={};goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.debug={};goog.debug.Error=function(a){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.string={};goog.string.Unicode={NBSP:"\u00a0"};goog.string.startsWith=function(a,b){return 0==a.lastIndexOf(b,0)};goog.string.endsWith=function(a,b){var c=a.length-b.length;return 0<=c&&a.indexOf(b,c)==c};goog.string.caseInsensitiveStartsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(0,b.length))};goog.string.caseInsensitiveEndsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(a.length-b.length,b.length))}; goog.string.caseInsensitiveEquals=function(a,b){return a.toLowerCase()==b.toLowerCase()};goog.string.subs=function(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1=a||"\u0080"<=a&&"\ufffd">=a};goog.string.stripNewlines=function(a){return a.replace(/(\r\n|\r|\n)+/g," ")}; goog.string.canonicalizeNewlines=function(a){return a.replace(/(\r\n|\r|\n)/g,"\n")};goog.string.normalizeWhitespace=function(a){return a.replace(/\xa0|\s/g," ")};goog.string.normalizeSpaces=function(a){return a.replace(/\xa0|[ \t]+/g," ")};goog.string.collapseBreakingSpaces=function(a){return a.replace(/[\t\r\n ]+/g," ").replace(/^[\t\r\n ]+|[\t\r\n ]+$/g,"")};goog.string.trim=function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")}; @@ -116,8 +116,8 @@ goog.crypt.base64.init_=function(){if(!goog.crypt.base64.byteToCharMap_){goog.cr goog.crypt.base64.charToByteMapWebSafe_[goog.crypt.base64.byteToCharMapWebSafe_[a]]=a}};var TOKEN_SEP=".",TOKEN_VERSION=0,FirebaseTokenGenerator=function(a){fb.tokengenerator.validation.validateArgCount("new FirebaseTokenGenerator",1,1,arguments.length);fb.tokengenerator.validation.validateSecret("new FirebaseTokenGenerator",1,a);this.mSecret=a};goog.exportSymbol("FirebaseTokenGenerator",FirebaseTokenGenerator); FirebaseTokenGenerator.prototype.createToken=function(a,b){fb.tokengenerator.validation.validateArgCount("FirebaseTokenGenerator.createToken",1,2,arguments.length);fb.tokengenerator.validation.validateCredentialData("FirebaseTokenGenerator.createToken",1,a,!1);fb.tokengenerator.validation.validateCredentialOptions("FirebaseTokenGenerator.createToken",2,b,!0);b=b||{};if(FirebaseTokenGenerator.isEmptyObject_(a)&&FirebaseTokenGenerator.isUselessOptionsObject_(b))throw Error("FirebaseTokenGenerator.createToken: data is empty and no options are set. This token will have no effect on Firebase."); var c=this.createOptionsClaims("FirebaseTokenGenerator.createToken",b);c.v=TOKEN_VERSION;c.d=a;c.iat||(c.iat=Math.floor((new Date).getTime()/1E3));return this.createToken_(c)};goog.exportProperty(FirebaseTokenGenerator.prototype,"createToken",FirebaseTokenGenerator.prototype.createToken); -FirebaseTokenGenerator.prototype.createOptionsClaims=function(a,b){var c={},d;for(d in b)switch(d){case "expires":case "notBefore":var e="notBefore"==d?"nbf":"exp";b[d]instanceof Date?c[e]=Math.round(b[d].getTime()/1E3):(fb.tokengenerator.validation.validateOption(a,d,b[d],"number","a number."),c[e]=b[d]);break;case "admin":fb.tokengenerator.validation.validateOption(a,d,b[d],"boolean","a boolean.");c.admin=b[d];break;case "debug":fb.tokengenerator.validation.validateOption(a,d,b[d],"boolean","a boolean."); -c.debug=b[d];break;case "simulate":fb.tokengenerator.validation.validateOption(a,d,b[d],"boolean","a boolean.");c.simulate=b[d];break;case "iat":fb.tokengenerator.validation.validateOption(a,d,b[d],"number","a number.");c.iat=b[d];break;default:throw Error(a+" unrecognized option: "+d);}return c}; +FirebaseTokenGenerator.prototype.createOptionsClaims=function(a,b){var c={},d;for(d in b)switch(d){case "expires":case "notBefore":var e="notBefore"==d?"nbf":"exp";b[d]instanceof Date?c[e]=Math.round(b[d].getTime()/1E3):(fb.tokengenerator.validation.validateOption(a,d,b[d],"number","a number"),c[e]=b[d]);break;case "admin":fb.tokengenerator.validation.validateOption(a,d,b[d],"boolean","a boolean");c.admin=b[d];break;case "debug":fb.tokengenerator.validation.validateOption(a,d,b[d],"boolean","a boolean"); +c.debug=b[d];break;case "simulate":fb.tokengenerator.validation.validateOption(a,d,b[d],"boolean","a boolean");c.simulate=b[d];break;case "iat":fb.tokengenerator.validation.validateOption(a,d,b[d],"number","a number");c.iat=b[d];break;default:throw Error(a+': unrecognized "'+d+'" option');}return c}; FirebaseTokenGenerator.prototype.createToken_=function(a){var b=this.noPadWebsafeBase64Encode_(fb.tokengenerator.json.stringify({typ:"JWT",alg:"HS256"})),a=this.noPadWebsafeBase64Encode_(fb.tokengenerator.json.stringify(a)),c=CryptoJS.HmacSHA256(b+TOKEN_SEP+a,this.mSecret).toString(),c=this.hexToBytes_(c),c=goog.crypt.base64.encodeByteArray(c,!0),c=this.removeBase64Pad_(c);return b+TOKEN_SEP+a+TOKEN_SEP+c}; FirebaseTokenGenerator.prototype.noPadWebsafeBase64Encode_=function(a){a=fb.tokengenerator.utf8.stringToByteArray(a);a=goog.crypt.base64.encodeByteArray(a,!0);return this.removeBase64Pad_(a)};FirebaseTokenGenerator.prototype.removeBase64Pad_=function(a){var b=a.indexOf(".");return 0<=b?a.substring(0,b):a};FirebaseTokenGenerator.prototype.hexToBytes_=function(a){for(var b=[],c=0;cK;){var var N=[],I=I.D=H.extend({L:function(){this.g=ia.create(ja.slice(0))},K:function(a,c){for(var b=this.g.b,d=b[0],e=b[1],f=b[2],g=b[3],j=b[4],k=b[5],w=b[6],S=b[7],l=0;64>l;l++){if(16>l)N[l]=a[c+l]|0;else{var p=N[l-15],s=N[l-2];N[l]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+N[l-7]+((s<<15|s>>>17)^(s<<13|s>>>19)^s>>>10)+N[l-16]}p=S+((j<<26|j>>>6)^(j<<21|j>>>11)^(j<<7|j>>>25))+(j&k^~j&w)+ka[l]+N[l];s=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f);S=w;w=k;k=j;j=g+p|0;g=f;f=e;e=d;d=p+s|0}b[0]=b[0]+ d|0;b[1]=b[1]+e|0;b[2]=b[2]+f|0;b[3]=b[3]+g|0;b[4]=b[4]+j|0;b[5]=b[5]+k|0;b[6]=b[6]+w|0;b[7]=b[7]+S|0},J:function(){var a=this.f,c=a.b,b=8*this.k,d=8*a.a;c[d>>>5]|=128<<24-d%32;c[(d+64>>>9<<4)+15]=b;a.a=4*c.length;this.m()}});A.D=H.H(I);A.C=H.I(I);var na=A.S.F; A.n.A=A.p.z.extend({h:function(a,c){a=this.j=a.create();"string"==typeof c&&(c=na.parse(c));var b=a.o,d=4*b;c.a>d&&(c=a.e(c));for(var e=this.O=c.c(),f=this.M=c.c(),g=e.b,j=f.b,k=0;kb?d="at least 1":b>c&&(d=0===c?"none":"no more than "+c);if(d)throw Error(a+" failed: Was called with "+b+(1===b?" argument.":" arguments.")+" Expects "+d+".");}function pa(a,c,b){var d="";switch(c){case 1:d=b?"first":"First";break;case 2:d=b?"second":"Second";break;case 3:d=b?"third":"Third";break;case 4:d=b?"fourth":"Fourth";break;default:t.Q.V.aa.assert(m,"errorPrefix_ called with argumentNumber > 4. Need to update it?")}return a+" failed: "+(d+" argument ")} -function O(a,c,b,d){if(typeof c!==b)throw Error("FirebaseTokenGenerator.createToken option "+a+" must be "+d);};Math.random();q("goog.asserts.ENABLE_ASSERTS",h);q("goog.NATIVE_ARRAY_PROTOTYPES",n.Z);q("goog.array.ASSUME_NATIVE_FUNCTIONS",m);var P={},Q,R,T,U;q("goog.userAgent.ASSUME_IE",m);q("goog.userAgent.ASSUME_GECKO",m);q("goog.userAgent.ASSUME_WEBKIT",m);q("goog.userAgent.ASSUME_MOBILE_WEBKIT",m);q("goog.userAgent.ASSUME_OPERA",m);q("goog.userAgent.ASSUME_ANY_VERSION",m);var V=P.s||P.r||P.t||P.w||P.u;function qa(){return o.navigator?o.navigator.userAgent:i} +function O(a,c,b,d){if(typeof c!==b||"number"===b&&isNaN(c))throw Error('FirebaseTokenGenerator.createToken option "'+a+'" must be '+d+", instead got "+c);};Math.random();q("goog.asserts.ENABLE_ASSERTS",h);q("goog.NATIVE_ARRAY_PROTOTYPES",n.Z);q("goog.array.ASSUME_NATIVE_FUNCTIONS",m);var P={},Q,R,T,U;q("goog.userAgent.ASSUME_IE",m);q("goog.userAgent.ASSUME_GECKO",m);q("goog.userAgent.ASSUME_WEBKIT",m);q("goog.userAgent.ASSUME_MOBILE_WEBKIT",m);q("goog.userAgent.ASSUME_OPERA",m);q("goog.userAgent.ASSUME_ANY_VERSION",m);var V=P.s||P.r||P.t||P.w||P.u;function qa(){return o.navigator?o.navigator.userAgent:i} if(!V){U=T=R=Q=m;var W;if(!V&&(W=qa())){var ra=o.navigator;Q=0==W.lastIndexOf("Opera",0);R=!Q&&(-1!=W.indexOf("MSIE")||-1!=W.indexOf("Trident"));T=!Q&&-1!=W.indexOf("WebKit");U=!Q&&!T&&!R&&"Gecko"==ra.product}}var sa=V?P.u:Q,ta=V?P.s:R,ua=V?P.r:U,va=V?P.w||P.t:T;q("goog.userAgent.ASSUME_MAC",m);q("goog.userAgent.ASSUME_WINDOWS",m);q("goog.userAgent.ASSUME_LINUX",m);q("goog.userAgent.ASSUME_X11",m);q("goog.userAgent.ASSUME_ANDROID",m);q("goog.userAgent.ASSUME_IPHONE",m); q("goog.userAgent.ASSUME_IPAD",m);var X;if(sa&&o.opera){var wa=o.opera.version;"function"==typeof wa&&wa()}else ua?X=/rv\:([^\);]+)(\)|;)/:ta?X=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:va&&(X=/WebKit\/(\S+)/),X&&X.exec(qa());var Y=i,Z=i; function xa(a){var c=r(a);if(!("array"==c||"object"==c&&"number"==typeof a.length))throw Error("encodeByteArray takes an array as a parameter");if(!Y){Y={};Z={};for(c=0;65>c;c++)Y[c]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c),Z[c]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(c)}for(var c=Z,b=[],d=0;d>2,e=(e&3)<<4|g>>4,g=(g&15)<<2|k>>6,k=k&63;j||(k= 64,f||(g=64));b.push(c[w],c[e],c[g],c[k])}return b.join("")};function $(a){oa("new FirebaseTokenGenerator",1,arguments.length);if("string"!=typeof a)throw Error(pa("new FirebaseTokenGenerator",1,m)+"must be a valid firebase namespace secret.");this.T=a}q("FirebaseTokenGenerator",$,void 0); $.prototype.R=function(a,c){oa("FirebaseTokenGenerator.createToken",2,arguments.length);if(void 0!==c&&(c===i||"object"!=typeof c))throw Error(pa("FirebaseTokenGenerator.createToken",2,h)+"must be a dictionary of token options.");var c=c||{},b;if(b=ya(a))if(!(b=ya(c))){var d;a:{b=["admin","debug","simulate"];for(d in b)if(Object.prototype.hasOwnProperty.call(c,b[d])){d=h;break a}d=m}b=!d}if(b)throw Error("FirebaseTokenGenerator.createToken: data is empty and no options are set. This token will have no effect on Firebase."); -b=c;d={};for(var e in b)switch(e){case "expires":case "notBefore":var f="notBefore"==e?"nbf":"exp";b[e]instanceof Date?d[f]=Math.round(b[e].getTime()/1E3):(O(e,b[e],"number","a number."),d[f]=b[e]);break;case "admin":O(e,b[e],"boolean","a boolean.");d.admin=b[e];break;case "debug":O(e,b[e],"boolean","a boolean.");d.debug=b[e];break;case "simulate":O(e,b[e],"boolean","a boolean.");d.simulate=b[e];break;case "iat":O(e,b[e],"number","a number.");d.iat=b[e];break;default:throw Error("FirebaseTokenGenerator.createToken unrecognized option: "+ -e);}d.v=0;d.d=a;d.iat||(d.iat=Math.floor((new Date).getTime()/1E3));e=za(y({typ:"JWT",alg:"HS256"}));d=za(y(d));b=A.C(e+"."+d,this.T).toString();for(var f=[],g=0;g=e&&(e-=55296,d++,t.Q.V.assert(de?c[b++]=e:(2048>e?c[b++]=e>>6|192:(65536>e?c[b++]=e>>12|224:(c[b++]=e>>18|240,c[b++]=e>>12&63|128),c[b++]=e>>6&63|128),c[b++]=e&63|128)}a=xa(c);return Aa(a)}function Aa(a){var c=a.indexOf(".");return 0<=c?a.substring(0,c):a} function ya(a){if("object"!==typeof a)return m;if(a===i)return h;for(var c in a)if(Object.prototype.hasOwnProperty.call(a,c))return m;return h};})(); diff --git a/js/src/FirebaseTokenGenerator.js b/js/src/FirebaseTokenGenerator.js index 6489c42..62f350d 100644 --- a/js/src/FirebaseTokenGenerator.js +++ b/js/src/FirebaseTokenGenerator.js @@ -81,28 +81,28 @@ FirebaseTokenGenerator.prototype.createOptionsClaims = function(func_name, opts) if (opts[o] instanceof Date) { claims[code] = Math.round(opts[o].getTime() / 1000); } else { - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number"); claims[code] = opts[o]; } break; case "admin" : - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean"); claims["admin"] = opts[o]; break; case "debug" : - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean"); claims["debug"] = opts[o]; break; case "simulate" : - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "boolean", "a boolean"); claims["simulate"] = opts[o]; break; case "iat": - fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number."); + fb.tokengenerator.validation.validateOption(func_name, o, opts[o], "number", "a number"); claims["iat"] = opts[o]; break; default: { - throw new Error(func_name + " unrecognized option: " + o); + throw new Error(func_name + ": unrecognized \"" + o + "\" option"); } } } diff --git a/js/src/validation.js b/js/src/validation.js index 096732a..d624a2f 100644 --- a/js/src/validation.js +++ b/js/src/validation.js @@ -73,7 +73,7 @@ fb.tokengenerator.validation.validateCredentialOptions = function(fnName, argume if (optional && !goog.isDef(opt)) { return; } - + if(opt === null || typeof opt != "object") { throw new Error(fb.tokengenerator.validation.errorPrefix_(fnName, argumentNumber, optional) + "must be a dictionary of token options."); } @@ -81,7 +81,7 @@ fb.tokengenerator.validation.validateCredentialOptions = function(fnName, argume fb.tokengenerator.validation.validateOption = function(prefix, optName, opt, expectedType, suffix) { - if (typeof opt !== expectedType) { - throw new Error(prefix + " option " + optName + " must be " + suffix); - } + if (typeof opt !== expectedType || (expectedType === "number" && isNaN(opt))) { + throw new Error(prefix + " option \"" + optName + "\" must be " + suffix + ", instead got " + opt); + } }; diff --git a/js/test/jasmine/tokengenerator.spec.js b/js/test/jasmine/tokengenerator.spec.js index d20543c..98b3424 100644 --- a/js/test/jasmine/tokengenerator.spec.js +++ b/js/test/jasmine/tokengenerator.spec.js @@ -15,26 +15,36 @@ describe("TokenGenerator Tests", function () { tokengenerator.createToken({blah: 5}, {'sdkhdgrkr' : false}) }).toThrow(); - //unknown option + //invalid option expect(function() { tokengenerator.createToken({blah: 5}, {'expires' : false}) }).toThrow(); - //unknown option + //invalid option expect(function() { tokengenerator.createToken({blah: 5}, {'notBefore' : "hello"}) }).toThrow(); - //unknown option + //invalid option expect(function() { tokengenerator.createToken({blah: 5}, {'admin' : 5}) }).toThrow(); - //unknown option + //invalid option expect(function() { tokengenerator.createToken({blah: 5}, {'debug' : function() {}}) }).toThrow(); + //null option + expect(function() { + tokengenerator.createToken({blah: 5}, {'expires' : null}) + }).toThrow(); + + //NaN option + expect(function() { + tokengenerator.createToken({blah: 5}, {'expires' : NaN}) + }).toThrow(); + //valid options shouldn't throw tokengenerator.createToken({blah: 5}, { 'expires' : 1234, diff --git a/package.json b/package.json index 67cee0f..3d81dcc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Firebase", "name": "firebase-token-generator", "description": "A utility to generate signed Firebase Authentication Tokens", - "version": "1.1.2", + "version": "1.1.3", "main": "./build/firebase-token-generator-node.js", "dependencies": {}, "devDependencies": {