Huge News!Announcing our $40M Series B led by Abstract Ventures.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.49 to 2.0.0-beta.50

2

dist/adapters/typeorm/index.js

@@ -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*(){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({[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({[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]:{};if("string"==typeof a)try{var p=new URL(a);a={},a.type=p.protocol.replace(/:$/,""),a.hostname=p.hostname,a.port=+p.port,a.username=p.username,a.password=p.password,a.database=p.pathname.replace(/^\//,""),p.query&&p.query.split("&").forEach(b=>{var[c,d]=b.split("=");"true"===d&&(d=!0),"false"===d&&(d=!1),a[c]=d})}catch(a){throw new Error("Unable to parse database connection string")}var 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="id";"mongodb"===a.type&&(m="_id",f.columns.id.objectId=!0,f.columns.userId.type="objectId",h.columns.id.objectId=!0,j.columns.id.objectId=!0,j.columns.userId.type="objectId",l.columns.id.objectId=!0),"sqlite"===a.type&&(f.columns.accessTokenExpires.type="datetime",j.columns.sessionExpires.type="datetime",l.columns.expires.type="datetime");var 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;
"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({[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({[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]:{};if("string"==typeof a)try{var p=new URL(a);a={},a.type=p.protocol.replace(/:$/,""),a.hostname=p.hostname,a.port=+p.port,a.username=p.username,a.password=p.password,a.database=p.pathname.replace(/^\//,""),p.search&&p.search.replace(/^\?/,"").split("&").forEach(b=>{var[c,d]=b.split("=");"true"===d&&(d=!0),"false"===d&&(d=!1),a[c]=d})}catch(b){a={url:a}}var 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="id";"mongodb"===a.type&&(m="_id",f.columns.id.objectId=!0,f.columns.userId.type="objectId",h.columns.id.objectId=!0,j.columns.id.objectId=!0,j.columns.userId.type="objectId",l.columns.id.objectId=!0),"sqlite"===a.type&&(f.columns.accessTokenExpires.type="datetime",j.columns.sessionExpires.type="datetime",l.columns.expires.type="datetime");var 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;
{
"name": "next-auth",
"version": "2.0.0-beta.49",
"version": "2.0.0-beta.50",
"description": "An authentication library for Next.js",

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

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