next-auth
Advanced tools
Comparing version 2.0.0-beta.47 to 2.0.0-beta.48
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _crypto=require("crypto"),_cookie=_interopRequireDefault(require("./lib/cookie")),_callbackUrlHandler=_interopRequireDefault(require("./lib/callback-url-handler")),_providers=_interopRequireDefault(require("./lib/providers")),_providers2=_interopRequireDefault(require("./routes/providers")),_signin=_interopRequireDefault(require("./routes/signin")),_signout=_interopRequireDefault(require("./routes/signout")),_callback=_interopRequireDefault(require("./routes/callback")),_session=_interopRequireDefault(require("./routes/session")),_pages=_interopRequireDefault(require("./pages")),_adapters=_interopRequireDefault(require("../adapters"));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_SITE="",DEFAULT_BASE_PATH="/api/auth",_default=function(){var a=_asyncToGenerator(function*(a,b,c){return new Promise(function(){var d=_asyncToGenerator(function*(d){var e,f=d,{url:g,query:h,body:i}=a,{slug:j,action:l=j[0],provider:m=j[1],error:k}=h,{csrfToken:n}=i,o=c.site||DEFAULT_SITE,p=c.basePath||DEFAULT_BASE_PATH,q="".concat(o).concat(p);if(c.adapter)e=c.adapter;else if(c.database)e=_adapters.default.Default(c.database);else return console.error("Error:\n","NextAuth requires a 'database' or 'adapter' option to be specified.\n","See documentation for details https://next-auth.js.org"),_pages.default.render(a,b,"error",{site:o,error:"Configuration",baseUrl:q},f),f();var r,s=c.secureCookies||q.startsWith("https://"),t=s?"__Secure-":"",u=_objectSpread({sessionToken:{name:"".concat(t,"next-auth.session-token"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:s}},callbackUrl:{name:"".concat(t,"next-auth.callback-url"),options:{sameSite:"lax",path:"/",secure:s}},baseUrl:{name:"".concat(t,"next-auth.base-url"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:s}},csrfToken:{name:"".concat(s?"__Host-":"","next-auth.csrf-token"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:s}}},c.cookies),v=c.secret||(0,_crypto.createHash)("sha256").update(JSON.stringify(c)).digest("hex"),w=!1;if(a.cookies[u.csrfToken.name]){var[z,A]=a.cookies[u.csrfToken.name].split("|");A===(0,_crypto.createHash)("sha256").update("".concat(z).concat(v)).digest("hex")&&(r=z,"POST"===a.method&&r===n&&(w=!0))}if(!r){r=(0,_crypto.randomBytes)(32).toString("hex");var B="".concat(r,"|").concat((0,_crypto.createHash)("sha256").update("".concat(r).concat(v)).digest("hex"));_cookie.default.set(b,u.csrfToken.name,B,u.csrfToken.options)}var x=!0;if(a.cookies[u.baseUrl.name]){var[C,D]=a.cookies[u.baseUrl.name].split("|");C===q&&D===(0,_crypto.createHash)("sha256").update("".concat(C).concat(v)).digest("hex")&&(x=!1)}if(x){var E="".concat(q,"|").concat((0,_crypto.createHash)("sha256").update("".concat(q).concat(v)).digest("hex"));_cookie.default.set(b,u.baseUrl.name,E,u.baseUrl.options)}var y=_objectSpread(_objectSpread({sessionMaxAge:2592000000,sessionUpdateAge:86400000,verificationMaxAge:86400000,debug:!1},c),{},{adapter:e,site:o,basePath:p,baseUrl:q,action:l,provider:m,cookies:u,secret:v,csrfToken:r,csrfTokenVerified:w,providers:(0,_providers.default)(c.providers,q),callbackUrl:o});if(y.callbackUrl=yield(0,_callbackUrlHandler.default)(a,b,y),"GET"===a.method)switch(l){case"providers":(0,_providers2.default)(a,b,y,f);break;case"session":(0,_session.default)(a,b,y,f);break;case"csrf":return b.json({csrfToken:r}),f();case"signin":m&&y.providers[m]?(0,_signin.default)(a,b,y,f):_pages.default.render(a,b,"signin",{site:o,providers:Object.values(y.providers),callbackUrl:y.callbackUrl,csrfToken:r},f);break;case"signout":_pages.default.render(a,b,"signout",{site:o,baseUrl:q,csrfToken:r,callbackUrl:y.callbackUrl},f);break;case"callback":if(m&&y.providers[m])(0,_callback.default)(a,b,y,f);else return b.status(400).end("Error: HTTP GET is not supported for ".concat(g)),f();break;case"check-email":_pages.default.render(a,b,"check-email",{site:o},f);break;case"error":_pages.default.render(a,b,"error",{site:o,error:k,baseUrl:q},f);break;default:return b.status(404).end(),f();}else if("POST"===a.method)switch(l){case"signin":if(m&&y.providers[m]){(0,_signin.default)(a,b,y,f);break}break;case"signout":(0,_signout.default)(a,b,y,f);break;default:return b.status(400).end("Error: HTTP POST is not supported for ".concat(g)),f();}else return b.status(400).end("Error: HTTP ".concat(a.method," is not supported for ").concat(g)),f()});return function(){return d.apply(this,arguments)}}())});return function(){return a.apply(this,arguments)}}();exports.default=_default; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _crypto=require("crypto"),_cookie=_interopRequireDefault(require("./lib/cookie")),_callbackUrlHandler=_interopRequireDefault(require("./lib/callback-url-handler")),_providers=_interopRequireDefault(require("./lib/providers")),_providers2=_interopRequireDefault(require("./routes/providers")),_signin=_interopRequireDefault(require("./routes/signin")),_signout=_interopRequireDefault(require("./routes/signout")),_callback=_interopRequireDefault(require("./routes/callback")),_session=_interopRequireDefault(require("./routes/session")),_pages=_interopRequireDefault(require("./pages")),_adapters=_interopRequireDefault(require("../adapters"));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_SITE="",DEFAULT_BASE_PATH="/api/auth",_default=function(){var a=_asyncToGenerator(function*(a,b,c){return new Promise(function(){var d=_asyncToGenerator(function*(d){var e,f=d,{url:g,query:h,body:i}=a,{slug:j,action:l=j[0],provider:m=j[1],error:k}=h,{csrfToken:n}=i,o=c.site||DEFAULT_SITE,p=c.basePath||DEFAULT_BASE_PATH,q="".concat(o).concat(p);if(c.adapter)e=c.adapter;else if(c.database)e=_adapters.default.Default(c.database);else return console.error("Error:\n","NextAuth requires a 'database' or 'adapter' option to be specified.\n","See documentation for details https://next-auth.js.org"),_pages.default.render(a,b,"error",{site:o,error:"Configuration",baseUrl:q},f),f();var r,s=c.secureCookies||q.startsWith("https://"),t=s?"__Secure-":"",u=_objectSpread({sessionToken:{name:"".concat(t,"next-auth.session-token"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:s}},callbackUrl:{name:"".concat(t,"next-auth.callback-url"),options:{sameSite:"lax",path:"/",secure:s}},baseUrl:{name:"".concat(t,"next-auth.base-url"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:s}},csrfToken:{name:"".concat(s?"__Host-":"","next-auth.csrf-token"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:s}}},c.cookies),v=c.secret||(0,_crypto.createHash)("sha256").update(JSON.stringify(c)).digest("hex"),w=!1;if(a.cookies[u.csrfToken.name]){var[A,B]=a.cookies[u.csrfToken.name].split("|");B===(0,_crypto.createHash)("sha256").update("".concat(A).concat(v)).digest("hex")&&(r=A,"POST"===a.method&&r===n&&(w=!0))}if(!r){r=(0,_crypto.randomBytes)(32).toString("hex");var C="".concat(r,"|").concat((0,_crypto.createHash)("sha256").update("".concat(r).concat(v)).digest("hex"));_cookie.default.set(b,u.csrfToken.name,C,u.csrfToken.options)}var x=!0;if(a.cookies[u.baseUrl.name]){var[D,E]=a.cookies[u.baseUrl.name].split("|");D===q&&E===(0,_crypto.createHash)("sha256").update("".concat(D).concat(v)).digest("hex")&&(x=!1)}if(x){var F="".concat(q,"|").concat((0,_crypto.createHash)("sha256").update("".concat(q).concat(v)).digest("hex"));_cookie.default.set(b,u.baseUrl.name,F,u.baseUrl.options)}var y=_objectSpread(_objectSpread({sessionMaxAge:2592000000,sessionUpdateAge:86400000,verificationMaxAge:86400000,debug:!1,pages:{}},c),{},{adapter:e,site:o,basePath:p,baseUrl:q,action:l,provider:m,cookies:u,secret:v,csrfToken:r,csrfTokenVerified:w,providers:(0,_providers.default)(c.providers,q),callbackUrl:o});y.callbackUrl=yield(0,_callbackUrlHandler.default)(a,b,y);var z=a=>(b.status(302).setHeader("Location",a),b.end(),f());if("GET"===a.method)switch(l){case"providers":(0,_providers2.default)(a,b,y,f);break;case"session":(0,_session.default)(a,b,y,f);break;case"csrf":return b.json({csrfToken:r}),f();case"signin":if(m&&y.providers[m])(0,_signin.default)(a,b,y,f);else{if(y.pages.signin)return z(y.pages.signin);_pages.default.render(a,b,"signin",{site:o,providers:Object.values(y.providers),callbackUrl:y.callbackUrl,csrfToken:r},f)}break;case"signout":if(y.pages.signout)return z(y.pages.signout);_pages.default.render(a,b,"signout",{site:o,baseUrl:q,csrfToken:r,callbackUrl:y.callbackUrl},f);break;case"callback":if(m&&y.providers[m])(0,_callback.default)(a,b,y,f);else return b.status(400).end("Error: HTTP GET is not supported for ".concat(g)),f();break;case"check-email":if(y.pages.checkEmail)return z(y.pages.checkEmail);_pages.default.render(a,b,"check-email",{site:o},f);break;case"error":if(y.pages.error)return z("".concat(y.pages.error).concat(y.pages.error.includes("?")?"&":"?","error=").concat(k));_pages.default.render(a,b,"error",{site:o,error:k,baseUrl:q},f);break;default:return b.status(404).end(),f();}else if("POST"===a.method)switch(l){case"signin":if(m&&y.providers[m]){(0,_signin.default)(a,b,y,f);break}break;case"signout":(0,_signout.default)(a,b,y,f);break;default:return b.status(400).end("Error: HTTP POST is not supported for ".concat(g)),f();}else return b.status(400).end("Error: HTTP ".concat(a.method," is not supported for ").concat(g)),f()});return function(){return d.apply(this,arguments)}}())});return function(){return a.apply(this,arguments)}}();exports.default=_default; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _index=require("./index"),_crypto=_interopRequireDefault(require("crypto"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var _default=(a,b)=>{var{type:c,callbackUrl:d}=a;if("oauth"===c){var i=(0,_index.oAuthClient)(a);if(a.version&&a.version.startsWith("2.")){var j=i.getAuthorizeUrl({redirect_uri:a.callbackUrl,scope:a.scope,state:_crypto.default.randomBytes(64).toString("hex")});if(a.authorizationUrl.includes("?")){var e=new URL(a.authorizationUrl),f="".concat(e.origin).concat(e.pathname,"?");j=j.replace(f,a.authorizationUrl+"&")}b(null,j)}else i.getOAuthRequestToken((c,d)=>{c&&console.error("GET_AUTHORISATION_URL_ERROR",c);var e="".concat(a.authorizationUrl,"?oauth_token=").concat(d);b(c,e)},d)}else if("oauth2"===c){var g=(0,_index.oAuth2Client)(a),h=g.code.getUri();b(null,h)}};exports.default=_default; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAuthorizationUrl=void 0;var _index=require("./index"),getAuthorizationUrl=(a,b)=>{var{type:c,callbackUrl:d}=a;if("oauth"===c){var i=(0,_index.oAuthClient)(a);if(a.version&&a.version.startsWith("2.")){var j=i.getAuthorizeUrl({redirect_uri:a.callbackUrl,scope:a.scope,state:""});if(a.authorizationUrl.includes("?")){var e=new URL(a.authorizationUrl),f="".concat(e.origin).concat(e.pathname,"?");j=j.replace(f,a.authorizationUrl+"&")}b(null,j)}else i.getOAuthRequestToken((c,d)=>{c&&console.error("GET_AUTHORISATION_URL_ERROR",c);var e="".concat(a.authorizationUrl,"?oauth_token=").concat(d);b(c,e)},d)}else if("oauth2"===c){var g=(0,_index.oAuth2Client)(a),h=g.code.getUri();b(null,h)}};exports.getAuthorizationUrl=getAuthorizationUrl; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;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){try{if(!c||!c.email)throw new Error("Missing or invalid profile");if(!d||!d.id||!d.type)throw new Error("Missing or invalid provider account");var e=yield a.getAdapter(),{createUser:f,updateUser:g,getUser:h,getUserByProviderAccountId:i,getUserByEmail:j,getUserByCredentials:k,removeUser:l,linkAccount:m,unlinkAccount:n,createSession:o,getSession:p,deleteSession:q}=e,r=b?yield p(b):null,s=!!r,t=s?yield h(r.userId):null,u=!1;if("email"===d.type){var v=yield j(c.email);if(!v)t=yield f(c),u=!0;else if(s){if(t.id===v.id)return{session:r,user:t,isNewAccount:u};yield q(b),t=v}else t=v;return r=yield o(t),{session:r,user:t,isNewAccount:u}}if("oauth"===d.type){var w=yield i(d.provider,d.id);if(!w){if(s)return yield m(t.id,d.provider,d.type,d.id,d.refreshToken,d.accessToken,d.accessTokenExpires),{session:r,user:t,isNewAccount:u};var x=yield j(c.email);if(x)throw new Error("Another user account associated with the same email address already exists");else return t=yield f(c),yield m(t.id,d.provider,d.type,d.id,d.refreshToken,d.accessToken,d.accessTokenExpires),r=yield o(t),u=!0,{session:r,user:t,isNewAccount:u}}else if(s){if(w.id===t.id)return{session:r,user:t,isNewAccount:u};throw new Error("This account is already associated with another user")}else return r=yield o(w),{session:r,user:w,isNewAccount:u}}else return Promise.reject(new Error("Provider not supported"))}catch(a){return Promise.reject(a)}});return function(){return a.apply(this,arguments)}}();exports.default=_default; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;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=(a,b,c,d)=>new Promise(function(){var e=_asyncToGenerator(function*(e,f){try{if(!c||!c.email)return f(new Error("Missing or invalid profile"));if(!d||!d.id||!d.type)return f(new Error("Missing or invalid provider account"));var g=yield a.getAdapter(),{createUser:h,updateUser:i,getUserById:j,getUserByProviderAccountId:k,getUserByEmail:l,getUserByCredentials:m,removeUser:n,linkAccount:o,unlinkAccount:p,createSession:q,getSessionById:r,deleteSessionById:s}=g,t=b?yield r(b):null,u=!!t,v=u?yield j(t.userId):null,w=!1;if("email"===d.type){var y=yield l(c.email);if(!y)v=yield h(c),w=!0;else if(u){if(v.id==y.id)return e({session:t,user:v,isNewAccount:w});yield s(b),v=y}else v=y;return t=yield q(v),e({session:t,user:v,isNewAccount:w})}if("oauth"===d.type){var z=yield k(d.provider,d.id);if(z)return u?z.id===v.id?e({session:t,user:v,isNewAccount:w}):f(new Error("This account is already associated with another user")):(t=yield q(z),e({session:t,user:z,isNewAccount:w}));if(u)return yield o(v.id,d.provider,d.type,d.id,d.refreshToken,d.accessToken,d.accessTokenExpires),e({session:t,user:v,isNewAccount:w});var x=yield l(c.email);return x?f(new Error("Another user account associated with the same email address already exists")):(v=yield h(c),yield o(v.id,d.provider,d.type,d.id,d.refreshToken,d.accessToken,d.accessTokenExpires),t=yield q(v),w=!0,e({session:t,user:v,isNewAccount:w}))}f(new Error("Provider not supported"))}catch(a){f(a)}});return function(){return e.apply(this,arguments)}}());exports.default=_default; |
{ | ||
"name": "next-auth", | ||
"version": "2.0.0-beta.47", | ||
"version": "2.0.0-beta.48", | ||
"description": "An authentication library for Next.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/iaincollins/next-auth.git", |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
67
33
86147