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.2 to 1.0.3

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 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 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 // @TODO We aren't checking for success, just completion\n this._removeLocalStore('session')\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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9zZXNzaW9uLmpzPzlmYzAiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnXG5cbmltcG9ydCBmZXRjaCBmcm9tICdpc29tb3JwaGljLWZldGNoJ1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyB7XG4gIC8qKlxuICAgKiBUaGlzIGlzIGFuIGFzeW5jLCBpc29tZXRyaWMgbWV0aG9kIHdoaWNoIHJldHVybnMgYSBzZXNzaW9uIG9iamVjdCAtIFxuICAgKiBlaXRoZXIgYnkgbG9va2luZyB1cCB0aGUgY3VycmVudCBleHByZXNzIHNlc3Npb24gb2JqZWN0IHdoZW4gcnVuIG9uIHRoZVxuICAgKiBzZXJ2ZXIsIG9yIGJ5IHVzaW5nIGZldGNoIChhbmQgb3B0aW9uYWxseSBjYWNoaW5nIHRoZSByZXN1bHQgaW4gb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E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlUm9vdCI6IiJ9\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 linkedAccounts() {\n return __WEBPACK_IMPORTED_MODULE_0_isomorphic_fetch___default()('/auth/accounts', {\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.csrfToken)\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 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 // @TODO We aren't checking for success, just completion\n this._removeLocalStore('session')\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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9zZXNzaW9uLmpzPzlmYzAiXSwic291cmNlc0NvbnRlbnQiOlsiJ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DQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1\n");

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

{
"name": "next-auth-client",
"version": "1.0.2",
"version": "1.0.3",
"description": "A client for next-auth",

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

@@ -105,2 +105,21 @@ 'use strict'

/**
* A simple static method to get list of currently linked oAuth Accounts
**/
static async linkedAccounts() {
return fetch('/auth/accounts', {
credentials: 'same-origin'
})
.then(response => {
if (response.ok) {
return response
} else {
return Promise.reject(Error('Unexpected response when trying to get linked accounts'))
}
})
.then(response => response.json())
.then(data => data.csrfToken)
.catch(() => Error('Unable to get linked accounts'))
}
static async signin(email) {

@@ -107,0 +126,0 @@ // Sign in to the server

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