next-auth-client
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -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.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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9zZXNzaW9uLmpzPzlmYzAiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnXG5cbmltcG9ydCBmZXRjaCBmcm9tICdpc29tb3JwaGljLWZldGNoJ1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyB7XG4gIC8qKlxuICAgKiBUaGlzIGlzIGFuIGFzeW5jLCBpc29tZXRyaWMgbWV0aG9kIHdoaWNoIHJldHVybnMgYSBzZXNzaW9uIG9iamVjdCAtIFxuICAgKiBlaXRoZXIgYnkgbG9va2luZyB1cCB0aGUgY3VycmVudCBleHByZXNzIHNlc3Npb24gb2JqZWN0IHdoZW4gcnVuIG9uIHRoZVxuICAgKiBzZXJ2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Q0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0=\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 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 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9zZXNzaW9uLmpzPzlmYzAiXSwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnXG5cbmltcG9ydCBmZXRjaCBmcm9tICdpc29tb3JwaGljLWZldGNoJ1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyB7XG4gIC8qKlxuICAgKiBUaGlzIGlzIGFuIGFzeW5jLCBpc29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BO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n"); | ||
@@ -101,0 +101,0 @@ /***/ }), |
{ | ||
"name": "next-auth-client", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A client for next-auth", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.js", |
@@ -120,3 +120,3 @@ 'use strict' | ||
.then(response => response.json()) | ||
.then(data => data.csrfToken) | ||
.then(data => data) | ||
.catch(() => Error('Unable to get linked accounts')) | ||
@@ -123,0 +123,0 @@ } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
31364