New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-auth

Package Overview
Dependencies
Maintainers
1
Versions
715
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-auth - npm Package Compare versions

Comparing version 2.0.0-beta.44 to 2.0.0-beta.45

2

client.js

@@ -1,1 +0,1 @@

module.exports = require('./dist/client').default
module.exports = require('./dist/client').default

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("reflect-metadata");var _typeorm=require("typeorm"),_crypto=require("crypto"),_errors=require("../../lib/errors"),_models=_interopRequireDefault(require("./models"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Adapter=function(a){function b(){return c.apply(this,arguments)}function c(){return c=_asyncToGenerator(function*(b){function c(){return d.apply(this,arguments)}function d(){return d=_asyncToGenerator(function*(){n=(0,_typeorm.getConnection)(a.name),n.isConnected||(n=yield n.connect())}),d.apply(this,arguments)}function f(){if(b.debug){for(var a=arguments.length,c=Array(a),d=0;d<a;d++)c[d]=arguments[d];console.log("[DEBUG]",...c)}}function h(){return j.apply(this,arguments)}function j(){return j=_asyncToGenerator(function*(a){f("Create user",a);try{var b=new g(a.name,a.email,a.image);return yield(0,_typeorm.getManager)().save(b)}catch(a){return console.error("CREATE_USER_ERROR",a),Promise.reject(new _errors.CreateUserError(a))}}),j.apply(this,arguments)}function l(){return m.apply(this,arguments)}function m(){return m=_asyncToGenerator(function*(a){f("Get user",a);try{return n.getRepository(g).findOne({id:a})}catch(a){return console.error("GET_USER_BY_ID_ERROR",a),Promise.reject(new Error("GET_USER_BY_ID_ERROR",a))}}),m.apply(this,arguments)}function o(){return p.apply(this,arguments)}function p(){return p=_asyncToGenerator(function*(a){f("Get user by email address",a);try{return n.getRepository(g).findOne({email:a})}catch(a){return console.error("GET_USER_BY_EMAIL_ERROR",a),Promise.reject(new Error("GET_USER_BY_EMAIL_ERROR",a))}}),p.apply(this,arguments)}function q(){return r.apply(this,arguments)}function r(){return r=_asyncToGenerator(function*(a,b){f("Get user by provider account ID",a,b);try{var c=yield n.getRepository(e).findOne({providerId:a,providerAccountId:b});return c?n.getRepository(g).findOne({id:c.userId}):null}catch(a){return console.error("GET_USER_BY_PROVIDER_ACCOUNT_ID_ERROR",a),Promise.reject(new Error("GET_USER_BY_PROVIDER_ACCOUNT_ID_ERROR",a))}}),r.apply(this,arguments)}function s(){return t.apply(this,arguments)}function t(){return t=_asyncToGenerator(function*(a){return f("Get user by credentials",a),!1}),t.apply(this,arguments)}function u(){return v.apply(this,arguments)}function v(){return v=_asyncToGenerator(function*(a){return f("Update user",a),!1}),v.apply(this,arguments)}function w(){return x.apply(this,arguments)}function x(){return x=_asyncToGenerator(function*(a){return f("Delete user",a),!1}),x.apply(this,arguments)}function y(){return z.apply(this,arguments)}function z(){return z=_asyncToGenerator(function*(a,b,c,d,g,h,i){f("Link provider account",a,b,c,d,g,h,i);try{var j=new e(a,b,c,d,g,h,i);return(0,_typeorm.getManager)().save(j)}catch(a){return console.error("LINK_ACCOUNT_ERROR",a),Promise.reject(new Error("LINK_ACCOUNT_ERROR",a))}}),z.apply(this,arguments)}function A(){return B.apply(this,arguments)}function B(){return B=_asyncToGenerator(function*(a,b,c){return f("Unlink provider account",a,b,c),!1}),B.apply(this,arguments)}function C(){return D.apply(this,arguments)}function D(){return D=_asyncToGenerator(function*(a){f("Create session",a);try{var{sessionMaxAge:c}=b,d=null;if(c){var e=new Date;e.setTime(e.getTime()+c),d=e.toISOString()}var g=new i(a.id,null,d);return(0,_typeorm.getManager)().save(g)}catch(a){return console.error("CREATE_SESSION_ERROR",a),Promise.reject(new Error("CREATE_SESSION_ERROR",a))}}),D.apply(this,arguments)}function E(){return F.apply(this,arguments)}function F(){return F=_asyncToGenerator(function*(a){f("Get session",a);try{var b=yield n.getRepository(i).findOne({sessionToken:a});return b&&b.sessionExpires&&new Date>new Date(b.sessionExpires)?null:b}catch(a){return console.error("GET_SESSION_ERROR",a),Promise.reject(new Error("GET_SESSION_ERROR",a))}}),F.apply(this,arguments)}function G(){return H.apply(this,arguments)}function H(){return H=_asyncToGenerator(function*(a,c){f("Update session",a);try{var{sessionMaxAge:d,sessionUpdateAge:e}=b;if(d&&(e||0===e)&&a.sessionExpires){var g=new Date(a.sessionExpires);if(g.setTime(g.getTime()-d),g.setTime(g.getTime()+e),new Date>g){var h=new Date;h.setTime(h.getTime()+d),a.sessionExpires=h.toISOString()}else if(!c)return null}else if(!c)return null;return(0,_typeorm.getManager)().save(a)}catch(a){return console.error("UPDATE_SESSION_ERROR",a),Promise.reject(new Error("UPDATE_SESSION_ERROR",a))}}),H.apply(this,arguments)}function I(){return J.apply(this,arguments)}function J(){return J=_asyncToGenerator(function*(a){f("Delete session",a);try{return yield n.getRepository(i).delete({sessionToken:a})}catch(a){return console.error("DELETE_SESSION_ERROR",a),Promise.reject(new Error("DELETE_SESSION_ERROR",a))}}),J.apply(this,arguments)}function K(){return L.apply(this,arguments)}function L(){return L=_asyncToGenerator(function*(a,c,d,e,g){f("Create verification request",a);try{var{site:h,verificationMaxAge:i}=b,{verificationCallback:j}=g,l=(0,_crypto.createHash)("sha256").update("".concat(d).concat(e)).digest("hex"),m=null;if(i){var p=new Date;p.setTime(p.getTime()+i),m=p.toISOString()}var n=new k(a,l,m),o=yield(0,_typeorm.getManager)().save(n);return yield j({recipient:a,url:c,token:d,site:h,provider:g}),o}catch(a){return console.error("CREATE_EMAIL_VERIFICATION_ERROR",a),Promise.reject(new Error("CREATE_EMAIL_VERIFICATION_ERROR",a))}}),L.apply(this,arguments)}function M(){return N.apply(this,arguments)}function N(){return N=_asyncToGenerator(function*(a,b,c){f("Get verification request",a,b);try{var d=(0,_crypto.createHash)("sha256").update("".concat(b).concat(c)).digest("hex"),e=yield n.getRepository(k).findOne({email:a,token:d});return e&&e.expires&&new Date>new Date(e.expires)?(yield n.getRepository(k).delete({token:d}),null):e}catch(a){return console.error("GET_EMAIL_VERIFICATION_ERROR",a),Promise.reject(new Error("GET_EMAIL_VERIFICATION_ERROR",a))}}),N.apply(this,arguments)}function O(){return P.apply(this,arguments)}function P(){return P=_asyncToGenerator(function*(a,b,c){f("Delete verification request",a,b);try{var d=(0,_crypto.createHash)("sha256").update("".concat(b).concat(c)).digest("hex");yield n.getRepository(k).delete({token:d})}catch(a){return console.error("DELETE_EMAIL_VERIFICATION_ERROR",a),Promise.reject(new Error("DELETE_EMAIL_VERIFICATION_ERROR",a))}}),P.apply(this,arguments)}if(!n)try{n=yield(0,_typeorm.createConnection)(a)}catch(a){"AlreadyHasActiveConnectionError"===a.name?yield c():console.error("ADAPTER_CONNECTION_ERROR",a)}else yield c();return Promise.resolve({createUser:h,getUser:l,getUserByEmail:o,getUserByProviderAccountId:q,getUserByCredentials:s,updateUser:u,deleteUser:w,linkAccount:y,unlinkAccount:A,createSession:C,getSession:E,updateSession:G,deleteSession:I,createEmailVerification:K,getEmailVerification:M,deleteEmailVerification:O})}),c.apply(this,arguments)}var d=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},e=d.Account?d.Account.model:_models.default.Account.model,f=d.Account?d.Account.schema:_models.default.Account.schema,g=d.User?d.User.model:_models.default.User.model,h=d.User?d.User.schema:_models.default.User.schema,i=d.Session?d.Session.model:_models.default.Session.model,j=d.Session?d.Session.schema:_models.default.Session.schema,k=d.EmailVerification?d.EmailVerification.model:_models.default.EmailVerification.model,l=d.EmailVerification?d.EmailVerification.schema:_models.default.EmailVerification.schema,m={name:"default",autoLoadEntities:!0,entities:[new _typeorm.EntitySchema(f),new _typeorm.EntitySchema(h),new _typeorm.EntitySchema(j),new _typeorm.EntitySchema(l)],logging:!1};a=_objectSpread(_objectSpread({},m),a);var n=null;return{getAdapter:b}},_default={Adapter,Models:_models.default};exports.default=_default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("reflect-metadata");var _typeorm=require("typeorm"),_crypto=require("crypto"),_errors=require("../../lib/errors"),_models=_interopRequireDefault(require("./models"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Adapter=function(a){function b(){return c.apply(this,arguments)}function c(){return c=_asyncToGenerator(function*(b){function c(){return d.apply(this,arguments)}function d(){return d=_asyncToGenerator(function*(){o=(0,_typeorm.getConnection)(a.name),o.isConnected||(o=yield o.connect())}),d.apply(this,arguments)}function f(){if(b.debug){for(var a=arguments.length,c=Array(a),d=0;d<a;d++)c[d]=arguments[d];console.log("[NextAuth.js][DEBUG]",...c)}}function h(){return j.apply(this,arguments)}function j(){return j=_asyncToGenerator(function*(a){f("createUser",a);try{var b=new g(a.name,a.email,a.image);return yield(0,_typeorm.getManager)().save(b)}catch(a){return console.error("CREATE_USER_ERROR",a),Promise.reject(new _errors.CreateUserError(a))}}),j.apply(this,arguments)}function l(){return n.apply(this,arguments)}function n(){return n=_asyncToGenerator(function*(a){f("getUser",a);try{return o.getRepository(g).findOne({id:m(a)})}catch(a){return console.error("GET_USER_BY_ID_ERROR",a),Promise.reject(new Error("GET_USER_BY_ID_ERROR",a))}}),n.apply(this,arguments)}function p(){return q.apply(this,arguments)}function q(){return q=_asyncToGenerator(function*(a){f("getUserByEmail",a);try{return o.getRepository(g).findOne({email:a})}catch(a){return console.error("GET_USER_BY_EMAIL_ERROR",a),Promise.reject(new Error("GET_USER_BY_EMAIL_ERROR",a))}}),q.apply(this,arguments)}function r(){return s.apply(this,arguments)}function s(){return s=_asyncToGenerator(function*(a,b){f("getUserByProviderAccountId",a,b);try{var c=yield o.getRepository(e).findOne({providerId:a,providerAccountId:b});return c?o.getRepository(g).findOne({id:m(c.userId)}):null}catch(a){return console.error("GET_USER_BY_PROVIDER_ACCOUNT_ID_ERROR",a),Promise.reject(new Error("GET_USER_BY_PROVIDER_ACCOUNT_ID_ERROR",a))}}),s.apply(this,arguments)}function t(){return u.apply(this,arguments)}function u(){return u=_asyncToGenerator(function*(a){return f("getUserByCredentials",a),!1}),u.apply(this,arguments)}function v(){return w.apply(this,arguments)}function w(){return w=_asyncToGenerator(function*(a){return f("updateUser",a),!1}),w.apply(this,arguments)}function x(){return y.apply(this,arguments)}function y(){return y=_asyncToGenerator(function*(a){return f("deleteUser",a),!1}),y.apply(this,arguments)}function z(){return A.apply(this,arguments)}function A(){return A=_asyncToGenerator(function*(a,b,c,d,g,h,i){f("linkAccount",a,b,c,d,g,h,i);try{var j=new e(a,b,c,d,g,h,i);return(0,_typeorm.getManager)().save(j)}catch(a){return console.error("LINK_ACCOUNT_ERROR",a),Promise.reject(new Error("LINK_ACCOUNT_ERROR",a))}}),A.apply(this,arguments)}function B(){return C.apply(this,arguments)}function C(){return C=_asyncToGenerator(function*(a,b,c){return f("unlinkAccount",a,b,c),!1}),C.apply(this,arguments)}function D(){return E.apply(this,arguments)}function E(){return E=_asyncToGenerator(function*(a){f("createSession",a);try{var{sessionMaxAge:c}=b,d=null;if(c){var e=new Date;e.setTime(e.getTime()+c),d=e.toISOString()}var g=new i(a.id,null,d);return(0,_typeorm.getManager)().save(g)}catch(a){return console.error("CREATE_SESSION_ERROR",a),Promise.reject(new Error("CREATE_SESSION_ERROR",a))}}),E.apply(this,arguments)}function F(){return G.apply(this,arguments)}function G(){return G=_asyncToGenerator(function*(a){f("getSession",a);try{var b=yield o.getRepository(i).findOne({sessionToken:a});return b&&b.sessionExpires&&new Date>new Date(b.sessionExpires)?null:b}catch(a){return console.error("GET_SESSION_ERROR",a),Promise.reject(new Error("GET_SESSION_ERROR",a))}}),G.apply(this,arguments)}function H(){return I.apply(this,arguments)}function I(){return I=_asyncToGenerator(function*(a,c){f("updateSession",a);try{var{sessionMaxAge:d,sessionUpdateAge:e}=b;if(d&&(e||0===e)&&a.sessionExpires){var g=new Date(a.sessionExpires);if(g.setTime(g.getTime()-d),g.setTime(g.getTime()+e),new Date>g){var h=new Date;h.setTime(h.getTime()+d),a.sessionExpires=h}else if(!c)return null}else if(!c)return null;return(0,_typeorm.getManager)().save(a)}catch(a){return console.error("UPDATE_SESSION_ERROR",a),Promise.reject(new Error("UPDATE_SESSION_ERROR",a))}}),I.apply(this,arguments)}function J(){return K.apply(this,arguments)}function K(){return K=_asyncToGenerator(function*(a){f("deleteSession",a);try{return yield o.getRepository(i).delete({sessionToken:a})}catch(a){return console.error("DELETE_SESSION_ERROR",a),Promise.reject(new Error("DELETE_SESSION_ERROR",a))}}),K.apply(this,arguments)}function L(){return M.apply(this,arguments)}function M(){return M=_asyncToGenerator(function*(a,c,d,e,g){f("createEmailVerification",a);try{var{site:h,verificationMaxAge:i}=b,{verificationCallback:j}=g,l=(0,_crypto.createHash)("sha256").update("".concat(d).concat(e)).digest("hex"),m=null;if(i){var p=new Date;p.setTime(p.getTime()+i),m=p.toISOString()}var n=new k(a,l,m),o=yield(0,_typeorm.getManager)().save(n);return yield j({recipient:a,url:c,token:d,site:h,provider:g}),o}catch(a){return console.error("CREATE_EMAIL_VERIFICATION_ERROR",a),Promise.reject(new Error("CREATE_EMAIL_VERIFICATION_ERROR",a))}}),M.apply(this,arguments)}function N(){return O.apply(this,arguments)}function O(){return O=_asyncToGenerator(function*(a,b,c){f("getEmailVerification",a,b);try{var d=(0,_crypto.createHash)("sha256").update("".concat(b).concat(c)).digest("hex"),e=yield o.getRepository(k).findOne({email:a,token:d});return e&&e.expires&&new Date>new Date(e.expires)?(yield o.getRepository(k).delete({token:d}),null):e}catch(a){return console.error("GET_EMAIL_VERIFICATION_ERROR",a),Promise.reject(new Error("GET_EMAIL_VERIFICATION_ERROR",a))}}),O.apply(this,arguments)}function P(){return Q.apply(this,arguments)}function Q(){return Q=_asyncToGenerator(function*(a,b,c){f("deleteEmailVerification",a,b);try{var d=(0,_crypto.createHash)("sha256").update("".concat(b).concat(c)).digest("hex");yield o.getRepository(k).delete({token:d})}catch(a){return console.error("DELETE_EMAIL_VERIFICATION_ERROR",a),Promise.reject(new Error("DELETE_EMAIL_VERIFICATION_ERROR",a))}}),Q.apply(this,arguments)}if(!o)try{o=yield(0,_typeorm.createConnection)(a)}catch(a){"AlreadyHasActiveConnectionError"===a.name?yield c():console.error("ADAPTER_CONNECTION_ERROR",a)}else yield c();return Promise.resolve({createUser:h,getUser:l,getUserByEmail:p,getUserByProviderAccountId:r,getUserByCredentials:t,updateUser:v,deleteUser:x,linkAccount:z,unlinkAccount:B,createSession:D,getSession:F,updateSession:H,deleteSession:J,createEmailVerification:L,getEmailVerification:N,deleteEmailVerification:P})}),c.apply(this,arguments)}var d=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},e=d.Account?d.Account.model:_models.default.Account.model,f=d.Account?d.Account.schema:_models.default.Account.schema,g=d.User?d.User.model:_models.default.User.model,h=d.User?d.User.schema:_models.default.User.schema,i=d.Session?d.Session.model:_models.default.Session.model,j=d.Session?d.Session.schema:_models.default.Session.schema,k=d.EmailVerification?d.EmailVerification.model:_models.default.EmailVerification.model,l=d.EmailVerification?d.EmailVerification.schema:_models.default.EmailVerification.schema,m=a=>a,n={name:"default",autoLoadEntities:!0,entities:[new _typeorm.EntitySchema(f),new _typeorm.EntitySchema(h),new _typeorm.EntitySchema(j),new _typeorm.EntitySchema(l)],logging:!1};a=_objectSpread(_objectSpread({},n),a);var o=null;return{getAdapter:b}},_default={Adapter,Models:_models.default};exports.default=_default;

@@ -1,1 +0,1 @@

"use strict";var _crypto=require("crypto");Object.defineProperty(exports,"__esModule",{value:!0}),exports.AccountSchema=exports.Account=void 0;class Account{constructor(a,b,c,d,e,f,g){this.providerCompoundId=(0,_crypto.createHash)("sha256").update("".concat(b,":").concat(d)).digest("hex"),this.userId=a,this.providerId=b,this.providerType=c,this.providerAccountId=d,this.refreshToken=e,this.accessToken=f,this.accessTokenExpires=g}}exports.Account=Account;var AccountSchema={name:"Account",target:Account,columns:{id:{primary:!0,type:"int",generated:!0},providerCompoundId:{type:"varchar",unique:!0},userId:{type:"varchar"},providerId:{type:"varchar"},providerType:{type:"varchar"},providerAccountId:{type:"varchar"},refreshToken:{type:"varchar",nullable:!0},accessToken:{type:"varchar"},accessTokenExpires:{type:"varchar",nullable:!0}}};exports.AccountSchema=AccountSchema;
"use strict";var _crypto=require("crypto");Object.defineProperty(exports,"__esModule",{value:!0}),exports.AccountSchema=exports.Account=void 0;class Account{constructor(a,b,c,d,e,f,g){this.providerCompoundId=(0,_crypto.createHash)("sha256").update("".concat(b,":").concat(d)).digest("hex"),this.userId=a,this.providerId=b,this.providerType=c,this.providerAccountId=d,this.refreshToken=e,this.accessToken=f,this.accessTokenExpires=g}}exports.Account=Account;var AccountSchema={name:"Account",target:Account,columns:{id:{primary:!0,type:"int",generated:!0},providerCompoundId:{type:"varchar",unique:!0},userId:{type:"int"},providerId:{type:"varchar"},providerType:{type:"varchar"},providerAccountId:{type:"varchar"},refreshToken:{type:"text",nullable:!0},accessToken:{type:"text"},accessTokenExpires:{type:"timestamp",nullable:!0}}};exports.AccountSchema=AccountSchema;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailVerificationSchema=exports.EmailVerification=void 0;class EmailVerification{constructor(a,b,c){this.email=a,this.token=b,this.expires=c}}exports.EmailVerification=EmailVerification;var EmailVerificationSchema={name:"EmailVerification",target:EmailVerification,columns:{id:{primary:!0,type:"int",generated:!0},email:{type:"varchar"},token:{type:"varchar",unique:!0},expires:{type:"date"}}};exports.EmailVerificationSchema=EmailVerificationSchema;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailVerificationSchema=exports.EmailVerification=void 0;class EmailVerification{constructor(a,b,c){this.email=a,this.token=b,this.expires=c}}exports.EmailVerification=EmailVerification;var EmailVerificationSchema={name:"EmailVerification",target:EmailVerification,columns:{id:{primary:!0,type:"int",generated:!0},email:{type:"varchar"},token:{type:"varchar",unique:!0},expires:{type:"timestamp"}}};exports.EmailVerificationSchema=EmailVerificationSchema;

@@ -1,1 +0,1 @@

"use strict";var _crypto=require("crypto");Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionSchema=exports.Session=void 0;class Session{constructor(a,b,c,d){this.userId=a,this.sessionToken=b||(0,_crypto.randomBytes)(32).toString("hex"),this.sessionExpires=c,this.accessToken=d||(0,_crypto.randomBytes)(32).toString("hex")}}exports.Session=Session;var SessionSchema={name:"Session",target:Session,columns:{id:{primary:!0,type:"int",generated:!0},userId:{type:"int"},sessionToken:{type:"varchar",unique:!0},sessionExpires:{type:"date"},accessToken:{type:"varchar",unique:!0}}};exports.SessionSchema=SessionSchema;
"use strict";var _crypto=require("crypto");Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionSchema=exports.Session=void 0;class Session{constructor(a,b,c,d){this.userId=a,this.sessionToken=b||(0,_crypto.randomBytes)(32).toString("hex"),this.sessionExpires=c,this.accessToken=d||(0,_crypto.randomBytes)(32).toString("hex")}}exports.Session=Session;var SessionSchema={name:"Session",target:Session,columns:{id:{primary:!0,type:"int",generated:!0},userId:{type:"int"},sessionToken:{type:"varchar",unique:!0},sessionExpires:{type:"timestamp"},accessToken:{type:"varchar",unique:!0}}};exports.SessionSchema=SessionSchema;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _callback=_interopRequireDefault(require("../lib/oauth/callback")),_callbackHandler=_interopRequireDefault(require("../lib/callback-handler")),_cookie=_interopRequireDefault(require("../lib/cookie"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var _default=function(){var a=_asyncToGenerator(function*(a,b,c,d){var{provider:e,providers:f,adapter:g,site:h,secret:i,baseUrl:j,cookies:k,callbackUrl:l,newAccountLandingPageUrl:m}=c,n=f[e],{type:o}=n,{getEmailVerification:p,deleteEmailVerification:q}=yield g.getAdapter(c),r=a.cookies[k.sessionToken.name];if("oauth"===o)(0,_callback.default)(a,n,function(){var a=_asyncToGenerator(function*(a,e){if(a)return console.error("OAUTH_CALLBACK_ERROR",a),b.status(302).setHeader("Location","".concat(j,"/error?error=OAuthCallback")),b.end(),d();var{profile:f,account:g}=yield e;try{var{session:i,isNewAccount:n}=yield(0,_callbackHandler.default)(r,f,g,c);if(_cookie.default.set(b,k.sessionToken.name,i.sessionToken,_objectSpread({expires:i.sessionExpires||null},k.sessionToken.options)),n&&m)return b.status(302).setHeader("Location",m),b.end(),d()}catch(a){return"AccountNotLinkedError"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=oAuthAccountNotLinked")):"CreateUserError"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=OAuthCreateAccount")):"InvalidProfile"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=EmailRequired")):(console.error("OAUTH_CALLBACK_ERROR",a),b.status(302).setHeader("Location","".concat(j,"/error?error=Callback"))),b.end(),d()}return l?(b.status(302).setHeader("Location",l),b.end()):(b.status(302).setHeader("Location",h),b.end()),d()});return function(){return a.apply(this,arguments)}}());else if("email"===o)try{var s=a.query.token,t=a.query.email?a.query.email.toLowerCase():null,u=yield p(t,s,i,n);if(!u)return b.status(302).setHeader("Location","".concat(j,"/error?error=Verification")),b.end(),d();yield q(t,s,i,n);var v={id:n.id,type:"email"},{session:w,isNewAccount:x}=yield(0,_callbackHandler.default)(r,{email:t},v,c);return(_cookie.default.set(b,k.sessionToken.name,w.sessionToken,_objectSpread({expires:w.sessionExpires||null},k.sessionToken.options)),x&&m)?(b.status(302).setHeader("Location",m),b.end(),d()):(l?(b.status(302).setHeader("Location",l),b.end()):(b.status(302).setHeader("Location",h),b.end()),d())}catch(a){return"CreateUserError"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=EmailCreateAccount")):(b.status(302).setHeader("Location","".concat(j,"/error?error=Callback")),console.error("EMAIL_CALLBACK_ERROR",a)),b.end(),d()}else return b.status(500).end("Error: Callback for provider type ".concat(o," not supported")),d()});return function(){return a.apply(this,arguments)}}();exports.default=_default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _callback=_interopRequireDefault(require("../lib/oauth/callback")),_callbackHandler=_interopRequireDefault(require("../lib/callback-handler")),_cookie=_interopRequireDefault(require("../lib/cookie"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var _default=function(){var a=_asyncToGenerator(function*(a,b,c,d){var{provider:e,providers:f,adapter:g,site:h,secret:i,baseUrl:j,cookies:k,callbackUrl:l,newAccountLandingPageUrl:m}=c,n=f[e],{type:o}=n,{getEmailVerification:p,deleteEmailVerification:q}=yield g.getAdapter(c),r=a.cookies[k.sessionToken.name];if("oauth"===o)(0,_callback.default)(a,n,function(){var a=_asyncToGenerator(function*(a,e){if(a)return console.error("OAUTH_CALLBACK_ERROR",a),b.status(302).setHeader("Location","".concat(j,"/error?error=OAuthCallback")),b.end(),d();var{profile:f,account:g}=yield e;try{var{session:i,isNewAccount:n}=yield(0,_callbackHandler.default)(r,f,g,c);if(_cookie.default.set(b,k.sessionToken.name,i.sessionToken,_objectSpread({expires:i.sessionExpires||null},k.sessionToken.options)),n&&m)return b.status(302).setHeader("Location",m),b.end(),d()}catch(a){return"AccountNotLinkedError"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=oAuthAccountNotLinked")):"CreateUserError"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=OAuthCreateAccount")):"InvalidProfile"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=EmailRequired")):(console.error("OAUTH_CALLBACK_HANDLER_ERROR",a),b.status(302).setHeader("Location","".concat(j,"/error?error=Callback"))),b.end(),d()}return l?(b.status(302).setHeader("Location",l),b.end()):(b.status(302).setHeader("Location",h),b.end()),d()});return function(){return a.apply(this,arguments)}}());else if("email"===o)try{var s=a.query.token,t=a.query.email?a.query.email.toLowerCase():null,u=yield p(t,s,i,n);if(!u)return b.status(302).setHeader("Location","".concat(j,"/error?error=Verification")),b.end(),d();yield q(t,s,i,n);var v={id:n.id,type:"email"},{session:w,isNewAccount:x}=yield(0,_callbackHandler.default)(r,{email:t},v,c);return(_cookie.default.set(b,k.sessionToken.name,w.sessionToken,_objectSpread({expires:w.sessionExpires||null},k.sessionToken.options)),x&&m)?(b.status(302).setHeader("Location",m),b.end(),d()):(l?(b.status(302).setHeader("Location",l),b.end()):(b.status(302).setHeader("Location",h),b.end()),d())}catch(a){return"CreateUserError"===a.name?b.status(302).setHeader("Location","".concat(j,"/error?error=EmailCreateAccount")):(b.status(302).setHeader("Location","".concat(j,"/error?error=Callback")),console.error("EMAIL_CALLBACK_ERROR",a)),b.end(),d()}else return b.status(500).end("Error: Callback for provider type ".concat(o," not supported")),d()});return function(){return a.apply(this,arguments)}}();exports.default=_default;
{
"name": "next-auth",
"version": "2.0.0-beta.44",
"version": "2.0.0-beta.45",
"description": "An authentication library for Next.js",

@@ -20,3 +20,5 @@ "repository": "https://github.com/iaincollins/next-auth.git",

"lint": "standard",
"lint:fix": "standard --fix"
"lint:fix": "standard --fix",
"test:db:start": "docker-compose -f tests/docker/docker-compose.yml up",
"test:db:stop": "docker-compose -f tests/docker/docker-compose.yml down"
},

@@ -23,0 +25,0 @@ "files": [

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