connect-session-firebase
Advanced tools
Comparing version 3.4.2 to 3.5.0
@@ -0,1 +1,6 @@ | ||
3.5.0 / 2016-10-15 | ||
================== | ||
* Update Firebase dependency to v3.5.0 | ||
* Removed the functionality to pass a Firebase config object to FirebaseStore - a pre-initialised Firebase reference is now required | ||
3.4.0 / 2016-09-16 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -10,8 +10,2 @@ /** | ||
/** | ||
* Module dependencies | ||
* @private | ||
*/ | ||
const firebase = require('firebase'); | ||
/** | ||
* Six hours in milliseconds | ||
@@ -23,3 +17,4 @@ * @private | ||
/** | ||
* Return Firebase session store extending Connect/Express session store | ||
* Return Firebase session store extending Connect/Express session store. | ||
* | ||
* @module | ||
@@ -30,2 +25,3 @@ * @param {Object} session Connect/Express Session Store | ||
const connectSessionFirebase = function connectSessionFirebase (session) { | ||
/** | ||
@@ -38,11 +34,11 @@ * Connect Store | ||
/** | ||
* Create a new FirebaseStore | ||
* @class | ||
* Create a new FirebaseStore. | ||
* | ||
* @constructor | ||
* @param {Object} args The configuration options for FirebaseStore | ||
* @param {Function} fn OnComplete callback function for Connect Store | ||
*/ | ||
const FirebaseStore = function FirebaseStore (args) { | ||
const options = args || {}; | ||
const db = options.database || false; | ||
const sessions = options.sessions || false; | ||
const options = Object.assign({}, args); | ||
const db = options.database || {}; | ||
const sessions = typeof options.sessions === 'string' ? options.sessions : 'sessions'; | ||
@@ -56,6 +52,7 @@ Store.call(options); | ||
/** | ||
* Replace disallowed characters in a Firebase reference key | ||
* Replace disallowed characters in a Firebase reference key. | ||
* | ||
* @inner | ||
* @param {string} str A child reference key | ||
* @return {string} A valid child reference key | ||
* @param {String} str A child reference key | ||
* @return {String} A valid child reference key | ||
*/ | ||
@@ -71,15 +68,8 @@ this.cleanRef = function cleanRef (str) { | ||
this.db = db.database(); | ||
} else if (typeof db === 'object') { | ||
// Initialize a Firebase instance with the configuration object. | ||
if (!db.databaseURL) { | ||
throw new Error('`database` object must have a `databaseURL` value'); | ||
} | ||
this.db = firebase.initializeApp(db).database(); | ||
} else { | ||
throw new Error('Invalid `database` value provided.'); | ||
throw new Error('Invalid Firebase reference'); | ||
} | ||
// Set a child reference to the sessions path. | ||
this.sessions = typeof sessions === 'string' ? this.cleanRef(sessions) : 'sessions'; | ||
this.sessions = this.cleanRef(sessions); | ||
@@ -101,2 +91,3 @@ this.reapInterval = options.reapInterval || reapInterval; | ||
* Fetch a keyed session reference. | ||
* | ||
* @param {String} sid The session key | ||
@@ -130,2 +121,3 @@ * @param {Function} fn OnComplete callback function | ||
* Save a keyed session reference. | ||
* | ||
* @param {String} sid The session key | ||
@@ -153,2 +145,3 @@ * @param {Object} sess The session data | ||
* Remove a keyed session reference. | ||
* | ||
* @param {String} sid The session key | ||
@@ -167,2 +160,3 @@ * @param {Function} fn OnComplete callback function | ||
* Remove all session references. | ||
* | ||
* @param {Function} fn OnComplete callback function | ||
@@ -177,2 +171,3 @@ * @return {Promise} A thenable Firebase reference | ||
* Remove all expired session references. | ||
* | ||
* @param {Function} fn OnComplete callback function | ||
@@ -188,3 +183,3 @@ * @return {Promise} A thenable Firebase reference | ||
if (!snapshot.exists()) { | ||
return; | ||
return fn(); | ||
} | ||
@@ -209,2 +204,3 @@ | ||
* Update a keyed session reference. | ||
* | ||
* @param {String} sid The session key | ||
@@ -225,6 +221,9 @@ * @param {Object} sess The session data | ||
let currentSess = JSON.parse(snapshot.val().sess); | ||
currentSess.cookie = sess.cookie; | ||
const touched = Object.assign( | ||
{}, | ||
JSON.parse(snapshot.val().sess), | ||
{ cookie: sess.cookie } | ||
); | ||
return this.set(sid, currentSess, fn); | ||
return this.set(sid, touched, fn); | ||
}) | ||
@@ -231,0 +230,0 @@ .catch(fn); |
{ | ||
"name": "connect-session-firebase", | ||
"description": "Firebase session store for Connect/Express", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"author": "Ben Weier <ben.weier@gmail.com>", | ||
@@ -9,20 +9,22 @@ "main": "./index.js", | ||
"docs": "./node_modules/.bin/jsdoc -c ./conf.json", | ||
"lint": "./node_modules/.bin/eslint .", | ||
"lint": "./node_modules/.bin/eslint --ignore-path ./.eslintignore ./**.js", | ||
"istanbul": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec", | ||
"codecov": "./node_modules/.bin/codecov", | ||
"codeclimate": "./node_modules/.bin/codeclimate-test-reporter < ./coverage/lcov.info", | ||
"test": "./node_modules/.bin/mocha ./test/test.js" | ||
}, | ||
"peerDependencies": { | ||
"firebase": "~3.4.0" | ||
"firebase": "~3.5.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "~3.5.0", | ||
"codecov": "^1.0.1", | ||
"codeclimate-test-reporter": "~0.4.0", | ||
"codecov": "~1.0.1", | ||
"dotenv": "~2.0.0", | ||
"eslint": "~3.5.0", | ||
"eslint": "~3.8.0", | ||
"express-session": "~1.14.1", | ||
"firebase": "~3.4.0", | ||
"firebase": "~3.5.0", | ||
"istanbul": "~0.4.5", | ||
"jsdoc": "^3.4.1", | ||
"mocha": "~3.0.2", | ||
"jsdoc": "~3.4.1", | ||
"mocha": "~3.1.0", | ||
"mocha-eslint": "~3.0.1", | ||
@@ -29,0 +31,0 @@ "mocha-lcov-reporter": "~1.2.0" |
@@ -5,2 +5,3 @@ # Connect Session Firebase | ||
[![Codecov](https://img.shields.io/codecov/c/github/benweier/connect-session-firebase.svg?maxAge=2592000&style=flat-square)](https://codecov.io/gh/benweier/connect-session-firebase) | ||
[![Code Climate](https://img.shields.io/codeclimate/github/benweier/connect-session-firebase.svg?maxAge=2592000&style=flat-square)](https://codeclimate.com/github/benweier/connect-session-firebase) | ||
@@ -7,0 +8,0 @@ `connect-session-firebase` is a Connect/Express compatible session store backed by the [Firebase SDK](https://firebase.google.com/docs/server/setup). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14365
114
12