Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-auth-client

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-auth-client - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

dist/bundle.js

@@ -98,3 +98,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

"use strict";
eval("/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch__ = __webpack_require__(/*! isomorphic-fetch */ 2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch__);\n\n\n\n\n/* harmony default export */ __webpack_exports__[\"a\"] = (class {\n /**\n * This is an async, isometric method which returns a session object - \n * either by looking up the current express session object when run on the\n * server, or by using fetch (and optionally caching the result in local\n * storage) when run on the client. \n * \n * Note that actual session tokens are not stored in local storage, they are\n * kept in an HTTP Only cookie as protection against session hi-jacking by\n * malicious JavaScript.\n **/\n static async init({\n req = null,\n force = false\n } = {}) {\n let session = {}\n if (req) {\n if (req.session) {\n // If running on the server session data should be in the req object\n session.csrfToken = req.connection._httpMessage.locals._csrf\n session.expires = req.session.cookie._expires\n // If the user is logged in, add the user to the session object\n if (req.user) {\n session.user = req.user\n }\n }\n } else {\n // If running in the browser attempt to load session from sessionStore\n if (force === true) {\n // If force update is set, reset data store\n this._removeLocalStore('session')\n } else {\n session = this._getLocalStore('session')\n }\n }\n\n // If session data exists, has not expired AND force is not set then\n // return the stored session we already have.\n if (session && Object.keys(session).length > 0 && session.expires && session.expires > Date.now()) {\n return new Promise(resolve => {\n resolve(session)\n })\n } else {\n // If running on server, but session has expired return empty object\n // (no valid session)\n if (typeof window === 'undefined') {\n return new Promise(resolve => {\n resolve({})\n })\n }\n }\n\n // If we don't have session data, or it's expired, or force is set\n // to true then revalidate it by fetching it again from the server.\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/session', {\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('HTTP error when trying to get session'))\n }\n })\n .then(response => response.json())\n .then(data => {\n // Update session with session info\n session = data\n\n // Set a value we will use to check this client should silently\n // revalidate, using the value for revalidateAge returned by the server.\n session.expires = Date.now() + session.revalidateAge\n\n // Save changes to session\n this._saveLocalStore('session', session)\n\n return session\n })\n .catch(() => Error('Unable to get session'))\n }\n\n /**\n * A simple static method to get the CSRF Token is provided for convenience\n **/\n static async csrfToken() {\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/csrf', {\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('Unexpected response when trying to get CSRF token'))\n }\n })\n .then(response => response.json())\n .then(data => data.csrfToken)\n .catch(() => Error('Unable to get CSRF token'))\n }\n\n /**\n * A simple static method to get list of currently linked oAuth Accounts\n **/\n static async linked() {\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/linked', {\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('Unexpected response when trying to get linked accounts'))\n }\n })\n .then(response => response.json())\n .then(data => data)\n .catch(() => Error('Unable to get linked accounts'))\n }\n \n static async signin(email) {\n // Sign in to the server\n\n // Load current session info from cache\n let session = await this.init()\n\n // Make sure we have the latest CSRF Token in our session\n session.csrfToken = await this.csrfToken()\n\n const formData = {\n _csrf: session.csrfToken,\n email,\n }\n \n // Encoded form parser for sending data in the body\n const encodedForm = Object.keys(formData).map((key) => {\n return encodeURIComponent(key) + '=' + encodeURIComponent(formData[key])\n }).join('&')\n\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/email/signin', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: encodedForm,\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('HTTP error while attempting to sign in'))\n }\n })\n .then(() => true)\n .catch(() => Error('Unable to sign in'))\n }\n\n static async signout() {\n // Signout from the server\n const csrfToken = await this.csrfToken()\n const formData = { _csrf: csrfToken }\n\n // Encoded form parser for sending data in the body\n const encodedForm = Object.keys(formData).map((key) => {\n return encodeURIComponent(key) + '=' + encodeURIComponent(formData[key])\n }).join('&')\n \n // Remove cached session\n this._removeLocalStore('session')\n\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/signout', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: encodedForm,\n credentials: 'same-origin'\n })\n .then(() => {\n return true\n })\n .catch(() => Error('Unable to sign out'))\n }\n\n // The Web Storage API is widely supported, but not always available (e.g.\n // it can be restricted in private browsing mode, triggering an exception).\n // We handle that silently by just returning null here.\n static _getLocalStore(name) {\n try {\n return JSON.parse(localStorage.getItem(name))\n } catch (err) {\n return null\n }\n }\n \n static _saveLocalStore(name, data) {\n try {\n localStorage.setItem(name, JSON.stringify(data))\n return true\n } catch (err) {\n return false\n }\n }\n \n static _removeLocalStore(name) {\n try {\n localStorage.removeItem(name)\n return true\n } catch (err) {\n return false\n }\n }\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9zZXNzaW9uLmpzPzlmYzAiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnXG5cbmltcG9ydCBmZXRjaCBmcm9tICdpc29tb3JwaGljLWZldGNoJ1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyB7XG4gIC8qKlxuICAgKiBUaGlzIGlzIGFuIGFzeW5jLCBpc29tZXRyaWMgbWV0aG9kIHdoaWNoIHJldHVybnMgYSBzZXNz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FDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1\n");
eval("/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch__ = __webpack_require__(/*! isomorphic-fetch */ 2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch__);\n\n\n\n\n/* harmony default export */ __webpack_exports__[\"a\"] = (class {\n /**\n * This is an async, isometric method which returns a session object - \n * either by looking up the current express session object when run on the\n * server, or by using fetch (and optionally caching the result in local\n * storage) when run on the client. \n * \n * Note that actual session tokens are not stored in local storage, they are\n * kept in an HTTP Only cookie as protection against session hi-jacking by\n * malicious JavaScript.\n **/\n static async init({\n req = null,\n force = false\n } = {}) {\n let session = {}\n if (req) {\n if (req.session) {\n // If running on the server session data should be in the req object\n session.csrfToken = req.connection._httpMessage.locals._csrf\n session.expires = req.session.cookie._expires\n // If the user is logged in, add the user to the session object\n if (req.user) {\n session.user = req.user\n }\n }\n } else {\n // If running in the browser attempt to load session from sessionStore\n if (force === true) {\n // If force update is set, reset data store\n this._removeLocalStore('session')\n } else {\n session = this._getLocalStore('session')\n }\n }\n\n // If session data exists, has not expired AND force is not set then\n // return the stored session we already have.\n if (session && Object.keys(session).length > 0 && session.expires && session.expires > Date.now()) {\n return new Promise(resolve => {\n resolve(session)\n })\n } else {\n // If running on server, but session has expired return empty object\n // (no valid session)\n if (typeof window === 'undefined') {\n return new Promise(resolve => {\n resolve({})\n })\n }\n }\n\n // If we don't have session data, or it's expired, or force is set\n // to true then revalidate it by fetching it again from the server.\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/session', {\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('HTTP error when trying to get session'))\n }\n })\n .then(response => response.json())\n .then(data => {\n // Update session with session info\n session = data\n\n // Set a value we will use to check this client should silently\n // revalidate, using the value for revalidateAge returned by the server.\n session.expires = Date.now() + session.revalidateAge\n\n // Save changes to session\n this._saveLocalStore('session', session)\n\n return session\n })\n .catch(() => Error('Unable to get session'))\n }\n\n /**\n * A simple static method to get the CSRF Token is provided for convenience\n **/\n static async csrfToken() {\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/csrf', {\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('Unexpected response when trying to get CSRF token'))\n }\n })\n .then(response => response.json())\n .then(data => data.csrfToken)\n .catch(() => Error('Unable to get CSRF token'))\n }\n\n /**\n * A simple static method to get list of currently linked oAuth Accounts\n **/\n static async linked({\n req = null\n } = {}) {\n // If running server side, uses server side method\n if (req) return req.linked()\n \n // If running client side, use RESTful endpoint\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/linked', {\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('Unexpected response when trying to get linked accounts'))\n }\n })\n .then(response => response.json())\n .then(data => data)\n .catch(() => Error('Unable to get linked accounts'))\n }\n \n static async signin(email) {\n // Sign in to the server\n\n // Load current session info from cache\n let session = await this.init()\n\n // Make sure we have the latest CSRF Token in our session\n session.csrfToken = await this.csrfToken()\n\n const formData = {\n _csrf: session.csrfToken,\n email,\n }\n \n // Encoded form parser for sending data in the body\n const encodedForm = Object.keys(formData).map((key) => {\n return encodeURIComponent(key) + '=' + encodeURIComponent(formData[key])\n }).join('&')\n\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/email/signin', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: encodedForm,\n credentials: 'same-origin'\n })\n .then(response => {\n if (response.ok) {\n return response\n } else {\n return Promise.reject(Error('HTTP error while attempting to sign in'))\n }\n })\n .then(() => true)\n .catch(() => Error('Unable to sign in'))\n }\n\n static async signout() {\n // Signout from the server\n const csrfToken = await this.csrfToken()\n const formData = { _csrf: csrfToken }\n\n // Encoded form parser for sending data in the body\n const encodedForm = Object.keys(formData).map((key) => {\n return encodeURIComponent(key) + '=' + encodeURIComponent(formData[key])\n }).join('&')\n \n // Remove cached session data\n this._removeLocalStore('session')\n\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/signout', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: encodedForm,\n credentials: 'same-origin'\n })\n .then(() => {\n return true\n })\n .catch(() => Error('Unable to sign out'))\n }\n\n // The Web Storage API is widely supported, but not always available (e.g.\n // it can be restricted in private browsing mode, triggering an exception).\n // We handle that silently by just returning null here.\n static _getLocalStore(name) {\n try {\n return JSON.parse(localStorage.getItem(name))\n } catch (err) {\n return null\n }\n }\n \n static _saveLocalStore(name, data) {\n try {\n localStorage.setItem(name, JSON.stringify(data))\n return true\n } catch (err) {\n return false\n }\n }\n \n static _removeLocalStore(name) {\n try {\n localStorage.removeItem(name)\n return true\n } catch (err) {\n return false\n }\n }\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9zZXNzaW9uLmpzPzlmYzAiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnXG5cbmltcG9ydCBm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BQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n");

@@ -101,0 +101,0 @@ /***/ }),

{
"name": "next-auth-client",
"version": "1.0.6",
"version": "1.0.7",
"description": "A client for next-auth",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

@@ -108,3 +108,9 @@ 'use strict'

**/
static async linked() {
static async linked({
req = null
} = {}) {
// If running server side, uses server side method
if (req) return req.linked()
// If running client side, use RESTful endpoint
return fetch('/auth/linked', {

@@ -173,3 +179,3 @@ credentials: 'same-origin'

// Remove cached session
// Remove cached session data
this._removeLocalStore('session')

@@ -176,0 +182,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc