Socket
Socket
Sign inDemoInstall

@contentpass/next-auth

Package Overview
Dependencies
697
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.0 to 1.13.0

109

client.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('babel-runtime/core-js/json/stringify'), require('babel-runtime/regenerator'), require('babel-runtime/core-js/promise'), require('babel-runtime/core-js/object/keys'), require('babel-runtime/helpers/asyncToGenerator'), require('babel-runtime/helpers/classCallCheck'), require('babel-runtime/helpers/createClass'), require('isomorphic-fetch')) :
typeof define === 'function' && define.amd ? define(['exports', 'babel-runtime/core-js/json/stringify', 'babel-runtime/regenerator', 'babel-runtime/core-js/promise', 'babel-runtime/core-js/object/keys', 'babel-runtime/helpers/asyncToGenerator', 'babel-runtime/helpers/classCallCheck', 'babel-runtime/helpers/createClass', 'isomorphic-fetch'], factory) :
(factory((global['next-auth-client'] = {}),null,null,null,null,null,null,null,null));
}(this, (function (exports,_JSON$stringify,_regeneratorRuntime,_Promise,_Object$keys,_asyncToGenerator,_classCallCheck,_createClass,fetch) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('babel-runtime/core-js/json/stringify'), require('babel-runtime/core-js/object/assign'), require('babel-runtime/helpers/typeof'), require('babel-runtime/regenerator'), require('babel-runtime/core-js/promise'), require('babel-runtime/core-js/object/keys'), require('babel-runtime/helpers/asyncToGenerator'), require('babel-runtime/helpers/classCallCheck'), require('babel-runtime/helpers/createClass'), require('isomorphic-fetch')) :
typeof define === 'function' && define.amd ? define(['exports', 'babel-runtime/core-js/json/stringify', 'babel-runtime/core-js/object/assign', 'babel-runtime/helpers/typeof', 'babel-runtime/regenerator', 'babel-runtime/core-js/promise', 'babel-runtime/core-js/object/keys', 'babel-runtime/helpers/asyncToGenerator', 'babel-runtime/helpers/classCallCheck', 'babel-runtime/helpers/createClass', 'isomorphic-fetch'], factory) :
(factory((global['next-auth-client'] = {}),null,null,null,null,null,null,null,null,null,null));
}(this, (function (exports,_JSON$stringify,_Object$assign,_typeof,_regeneratorRuntime,_Promise,_Object$keys,_asyncToGenerator,_classCallCheck,_createClass,fetch) { 'use strict';
_JSON$stringify = _JSON$stringify && _JSON$stringify.hasOwnProperty('default') ? _JSON$stringify['default'] : _JSON$stringify;
_Object$assign = _Object$assign && _Object$assign.hasOwnProperty('default') ? _Object$assign['default'] : _Object$assign;
_typeof = _typeof && _typeof.hasOwnProperty('default') ? _typeof['default'] : _typeof;
_regeneratorRuntime = _regeneratorRuntime && _regeneratorRuntime.hasOwnProperty('default') ? _regeneratorRuntime['default'] : _regeneratorRuntime;

@@ -25,7 +27,7 @@ _Promise = _Promise && _Promise.hasOwnProperty('default') ? _Promise['default'] : _Promise;

/**
* This is an async, isometric method which returns a session object -
* This is an async, isometric method which returns a session object -
* either by looking up the current express session object when run on the
* server, or by using fetch (and optionally caching the result in local
* storage) when run on the client.
*
* storage) when run on the client.
*
* Note that actual session tokens are not stored in local storage, they are

@@ -43,3 +45,5 @@ * kept in an HTTP Only cookie as protection against session hi-jacking by

_ref2$force = _ref2.force,
force = _ref2$force === undefined ? false : _ref2$force;
force = _ref2$force === undefined ? false : _ref2$force,
_ref2$pathPrefix = _ref2.pathPrefix,
pathPrefix = _ref2$pathPrefix === undefined ? '/auth' : _ref2$pathPrefix;

@@ -96,3 +100,3 @@ var session;

case 8:
return _context.abrupt('return', fetch('/auth/session', {
return _context.abrupt('return', fetch(pathPrefix + '/session', {
credentials: 'same-origin'

@@ -146,2 +150,6 @@ }).then(function (response) {

var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref4$pathPrefix = _ref4.pathPrefix,
pathPrefix = _ref4$pathPrefix === undefined ? '/auth' : _ref4$pathPrefix;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {

@@ -151,3 +159,3 @@ while (1) {

case 0:
return _context2.abrupt('return', fetch('/auth/csrf', {
return _context2.abrupt('return', fetch(pathPrefix + '/csrf', {
credentials: 'same-origin'

@@ -190,6 +198,8 @@ }).then(function (response) {

value: function () {
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref5$req = _ref5.req,
req = _ref5$req === undefined ? null : _ref5$req;
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref6$req = _ref6.req,
req = _ref6$req === undefined ? null : _ref6$req,
_ref6$pathPrefix = _ref6.pathPrefix,
pathPrefix = _ref6$pathPrefix === undefined ? '/auth' : _ref6$pathPrefix;

@@ -208,3 +218,3 @@ return _regeneratorRuntime.wrap(function _callee3$(_context3) {

case 2:
return _context3.abrupt('return', fetch('/auth/linked', {
return _context3.abrupt('return', fetch(pathPrefix + '/linked', {
credentials: 'same-origin'

@@ -234,3 +244,3 @@ }).then(function (response) {

function linked() {
return _ref4.apply(this, arguments);
return _ref5.apply(this, arguments);
}

@@ -248,6 +258,8 @@

value: function () {
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref7$req = _ref7.req,
req = _ref7$req === undefined ? null : _ref7$req;
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref8$req = _ref8.req,
req = _ref8$req === undefined ? null : _ref8$req,
_ref8$pathPrefix = _ref8.pathPrefix,
pathPrefix = _ref8$pathPrefix === undefined ? '/auth' : _ref8$pathPrefix;

@@ -266,3 +278,3 @@ return _regeneratorRuntime.wrap(function _callee4$(_context4) {

case 2:
return _context4.abrupt('return', fetch('/auth/providers', {
return _context4.abrupt('return', fetch(pathPrefix + '/providers', {
credentials: 'same-origin'

@@ -295,3 +307,3 @@ }).then(function (response) {

function providers() {
return _ref6.apply(this, arguments);
return _ref7.apply(this, arguments);
}

@@ -304,3 +316,3 @@

* Sign in
*
*
* Will post a form to /auth/signin auth route if an object is passed.

@@ -318,6 +330,6 @@ * If the details are valid a session will be created and you should redirect

value: function () {
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params) {
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params) {
var _this2 = this;
var formData, route, encodedForm;
var formData, pathPrefix, route, encodedForm;
return _regeneratorRuntime.wrap(function _callee6$(_context6) {

@@ -328,14 +340,25 @@ while (1) {

// Params can be just string (an email address) or an object (form fields)
formData = typeof params === 'string' ? { email: params } : params;
formData = {};
pathPrefix = '/auth';
if ((typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
formData = _Object$assign({}, params);
if (params.pathPrefix) {
pathPrefix = params.pathPrefix;
delete formData.pathPrefix;
}
} else {
formData.email = params;
}
// Use either the email token generation route or the custom form auth route
route = typeof params === 'string' ? pathPrefix + '/email/signin' : pathPrefix + '/signin';
route = typeof params === 'string' ? '/auth/email/signin' : '/auth/signin';
// Add latest CSRF Token to request
_context6.next = 4;
return this.csrfToken();
_context6.next = 6;
return this.csrfToken({ pathPrefix: pathPrefix });
case 4:
case 6:
formData._csrf = _context6.sent;

@@ -357,3 +380,3 @@

}).then(function () {
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(response) {
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(response) {
return _regeneratorRuntime.wrap(function _callee5$(_context5) {

@@ -385,4 +408,4 @@ while (1) {

return function (_x5) {
return _ref9.apply(this, arguments);
return function (_x6) {
return _ref10.apply(this, arguments);
};

@@ -397,3 +420,3 @@ }()).then(function (data) {

case 7:
case 9:
case 'end':

@@ -406,4 +429,4 @@ return _context6.stop();

function signin(_x4) {
return _ref8.apply(this, arguments);
function signin(_x5) {
return _ref9.apply(this, arguments);
}

@@ -416,3 +439,7 @@

value: function () {
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref12$pathPrefix = _ref12.pathPrefix,
pathPrefix = _ref12$pathPrefix === undefined ? '/auth' : _ref12$pathPrefix;
var csrfToken, formData, encodedForm;

@@ -424,3 +451,3 @@ return _regeneratorRuntime.wrap(function _callee7$(_context7) {

_context7.next = 2;
return this.csrfToken();
return this.csrfToken({ pathPrefix: pathPrefix });

@@ -441,3 +468,3 @@ case 2:

return _context7.abrupt('return', fetch('/auth/signout', {
return _context7.abrupt('return', fetch(pathPrefix + '/signout', {
method: 'POST',

@@ -465,3 +492,3 @@ headers: {

function signout() {
return _ref10.apply(this, arguments);
return _ref11.apply(this, arguments);
}

@@ -468,0 +495,0 @@

@@ -17,4 +17,2 @@ 'use strict'

// URL base path for authentication routes (optional).
// Note: The prefix value of '/auth' is currently hard coded in
// next-auth-client so you should not change this unless you also modify it.
pathPrefix = '/auth',

@@ -21,0 +19,0 @@ // Express Server (optional).

{
"name": "@contentpass/next-auth",
"version": "1.12.0",
"version": "1.13.0",
"description": "An authentication library for Next.js",

@@ -5,0 +5,0 @@ "repository": "https://github.com/contentpass/next-auth.git",

@@ -7,7 +7,7 @@ 'use strict'

/**
* This is an async, isometric method which returns a session object -
* This is an async, isometric method which returns a session object -
* either by looking up the current express session object when run on the
* server, or by using fetch (and optionally caching the result in local
* storage) when run on the client.
*
* storage) when run on the client.
*
* Note that actual session tokens are not stored in local storage, they are

@@ -19,3 +19,4 @@ * kept in an HTTP Only cookie as protection against session hi-jacking by

req = null,
force = false
force = false,
pathPrefix = '/auth'
} = {}) {

@@ -61,3 +62,3 @@ let session = {}

// to true then revalidate it by fetching it again from the server.
return fetch('/auth/session', {
return fetch(`${pathPrefix}/session`, {
credentials: 'same-origin'

@@ -92,4 +93,6 @@ })

**/
static async csrfToken() {
return fetch('/auth/csrf', {
static async csrfToken({
pathPrefix = '/auth'
} = {}) {
return fetch(`${pathPrefix}/csrf`, {
credentials: 'same-origin'

@@ -113,9 +116,10 @@ })

static async linked({
req = null
req = null,
pathPrefix = '/auth'
} = {}) {
// If running server side, uses server side method
if (req) return req.linked()
// If running client side, use RESTful endpoint
return fetch('/auth/linked', {
return fetch(`${pathPrefix}/linked`, {
credentials: 'same-origin'

@@ -134,3 +138,3 @@ })

}
/**

@@ -140,9 +144,10 @@ * A static method to get list of currently configured oAuth providers

static async providers({
req = null
req = null,
pathPrefix = '/auth'
} = {}) {
// If running server side, uses server side method
if (req) return req.providers()
// If running client side, use RESTful endpoint
return fetch('/auth/providers', {
return fetch(`${pathPrefix}/providers`, {
credentials: 'same-origin'

@@ -170,3 +175,3 @@ })

* Sign in
*
*
* Will post a form to /auth/signin auth route if an object is passed.

@@ -182,10 +187,21 @@ * If the details are valid a session will be created and you should redirect

// Params can be just string (an email address) or an object (form fields)
const formData = (typeof params === 'string') ? { email: params } : params
let formData = {};
let pathPrefix = '/auth';
if (typeof params === 'object') {
formData = Object.assign({}, params);
if (params.pathPrefix) {
pathPrefix = params.pathPrefix;
delete formData.pathPrefix;
}
} else {
formData.email = params;
}
// Use either the email token generation route or the custom form auth route
const route = (typeof params === 'string') ? '/auth/email/signin' : '/auth/signin'
const route = (typeof params === 'string') ? `${pathPrefix}/email/signin` : `${pathPrefix}/signin`
// Add latest CSRF Token to request
formData._csrf = await this.csrfToken()
formData._csrf = await this.csrfToken({ pathPrefix })
// Encoded form parser for sending data in the body

@@ -221,5 +237,7 @@ const encodedForm = Object.keys(formData).map((key) => {

static async signout() {
static async signout({
pathPrefix = '/auth'
} = {}) {
// Signout from the server
const csrfToken = await this.csrfToken()
const csrfToken = await this.csrfToken({ pathPrefix })
const formData = { _csrf: csrfToken }

@@ -231,7 +249,7 @@

}).join('&')
// Remove cached session data
this._removeLocalStore('session')
return fetch('/auth/signout', {
return fetch(`${pathPrefix}/signout`, {
method: 'POST',

@@ -261,3 +279,3 @@ headers: {

}
static _saveLocalStore(name, data) {

@@ -271,3 +289,3 @@ try {

}
static _removeLocalStore(name) {

@@ -281,2 +299,2 @@ try {

}
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc