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
714
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.8 to 2.0.0-beta.9

2

dist/client/index.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=require("react"),_isomorphicUnfetch=_interopRequireDefault(require("isomorphic-unfetch"));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)})}}var URL_PREFIX_COOKIE="next-auth.url-prefix",DEFAULT_SITE="",DEFAULT_PATH_PREFIX="/api/auth",session=(a)=>{var{req:b,site:c,pathPrefix:d}=a;return new Promise(function(){var a=_asyncToGenerator(function*(a){var e=b?_parseCookie(b.headers.cookie):null,f=b?{headers:{cookie:b.headers.cookie}}:{},g=c||d||null===b?"".concat(c||DEFAULT_SITE).concat(d||DEFAULT_PATH_PREFIX):e[URL_PREFIX_COOKIE];try{var h=yield(0,_isomorphicUnfetch.default)("".concat(g,"/session"),f),i=yield h.json();a(0<Object.keys(i).length?i:null)}catch(b){console.error("CLIENT_SESSION_ERROR",b),a(null)}});return function(){return a.apply(this,arguments)}}())},useSession=(a,b)=>{var[c,d]=(0,_react.useState)(a),[e,f]=(0,_react.useState)(!0),g=function(){var a=_asyncToGenerator(function*(){try{var a=yield(0,_isomorphicUnfetch.default)("".concat(b||DEFAULT_PATH_PREFIX,"/session")),c=yield a.json();d(0<Object.keys(c).length?c:null),f(!1)}catch(a){console.error("CLIENT_SESSION_ERROR",a)}});return function(){return a.apply(this,arguments)}}();return(0,_react.useEffect)(()=>{g()},[]),[c,e]},_parseCookie=c=>{if(!c)return{};try{for(var d,e={},f=c.split(";"),a=0;a<f.length;a++)d=f[a].split("="),1<d[0].length&&d[1]&&(e[d[0].trim()]=decodeURIComponent(d[1]));return e}catch(a){return console.error("CLIENT_COOKIE_PARSE_ERROR"),{}}},_default={session,useSession};exports.default=_default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=require("react"),_isomorphicUnfetch=_interopRequireDefault(require("isomorphic-unfetch"));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)})}}var URL_PREFIX_COOKIE="next-auth.url-prefix",DEFAULT_SITE="",DEFAULT_PATH_PREFIX="/api/auth",session=(a)=>{var{req:b,site:c,pathPrefix:d,urlPrefixCookieName:e}=a;return new Promise(function(){var a=_asyncToGenerator(function*(a){var f=b?_parseCookie(b.headers.cookie):null,g=b?{headers:{cookie:b.headers.cookie}}:{},h=c||d?"".concat(c||DEFAULT_SITE).concat(d||DEFAULT_PATH_PREFIX):f[e]||f["__Secure-".concat(URL_PREFIX_COOKIE)]||f[URL_PREFIX_COOKIE];if(b&&!h)return a(null);try{var i=yield(0,_isomorphicUnfetch.default)("".concat(h,"/session"),g),j=yield i.json();a(0<Object.keys(j).length?j:null)}catch(b){console.error("CLIENT_SESSION_ERROR",b),a(null)}});return function(){return a.apply(this,arguments)}}())},useSession=(a,b)=>{var[c,d]=(0,_react.useState)(a),[e,f]=(0,_react.useState)(!0),g=function(){var a=_asyncToGenerator(function*(){try{var a=yield(0,_isomorphicUnfetch.default)("".concat(b||DEFAULT_PATH_PREFIX,"/session")),c=yield a.json();d(0<Object.keys(c).length?c:null),f(!1)}catch(a){console.error("CLIENT_SESSION_ERROR",a)}});return function(){return a.apply(this,arguments)}}();return(0,_react.useEffect)(()=>{g()},[]),[c,e]},_parseCookie=c=>{if(!c)return{};try{for(var d,e={},f=c.split(";"),a=0;a<f.length;a++)d=f[a].split("="),1<d[0].length&&d[1]&&(e[d[0].trim()]=decodeURIComponent(d[1]));return e}catch(a){return console.error("CLIENT_COOKIE_PARSE_ERROR"),{}}},_default={session,useSession};exports.default=_default;

@@ -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")),_providers=_interopRequireDefault(require("./lib/providers")),_providers2=_interopRequireDefault(require("./routes/providers")),_signin=_interopRequireDefault(require("./routes/signin")),_callback=_interopRequireDefault(require("./routes/callback")),_session=_interopRequireDefault(require("./routes/session")),_pages=_interopRequireDefault(require("./pages"));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_PATH_PREFIX="/api/auth",_default=(a,b,c)=>new Promise(function(){var d=_asyncToGenerator(function*(d){var e,f=d,{url:g,query:h}=a,{slug:i,action:j=i[0],provider:k=i[1]}=h,l=c.site||DEFAULT_SITE,m=c.pathPrefix||DEFAULT_PATH_PREFIX,n="".concat(l).concat(m),o=h.callbackUrl||l,p=c.secureCookies||n.startsWith("https://"),q=p?"__Secure-":"",r=_objectSpread({sessionId:{name:"".concat(q,"next-auth.session-id"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:p}},callbackUrl:{name:"".concat(q,"next-auth.callback-url"),options:{sameSite:"lax",path:"/",secure:p}},urlPrefix:{name:"".concat(q,"next-auth.url-prefix"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:p}},csrfToken:{name:"".concat(p?"__Host-":"","next-auth.csrf-token"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:p}}},c.cookies),s=c.secret||(0,_crypto.createHash)("sha256").update(JSON.stringify(c)).digest("hex");if(a.cookies[r.csrfToken.name]){var[u,v]=a.cookies[r.csrfToken.name].split("|");v==(0,_crypto.createHash)("sha256").update("".concat(u).concat(s)).digest("hex")?e=u:console.warn("CSRF_TOKEN_CHECK_WARNING")}if(!e){e=(0,_crypto.randomBytes)(32).toString("hex");var w="".concat(e,"|").concat((0,_crypto.createHash)("sha256").update("".concat(e).concat(s)).digest("hex"));_cookie.default.set(b,r.csrfToken.name,w,r.csrfToken.options)}var t=_objectSpread(_objectSpread({},c),{},{site:l,pathPrefix:m,urlPrefix:n,callbackUrl:o,action:j,provider:k,cookies:r,secret:s,csrfToken:e,providers:(0,_providers.default)(c.providers,n)});if("GET"===a.method)switch(j){case"providers":(0,_providers2.default)(a,b,t,f);break;case"session":(0,_session.default)(a,b,t,f);break;case"csrf":return b.json({csrfToken:e}),f();break;case"signin":k&&t.providers[k]?(0,_signin.default)(a,b,t,f):_pages.default.render(b,"signin",{providers:Object.values(t.providers),callbackUrl:t.callbackUrl,site:t.site},f);break;case"callback":if(k&&t.providers[k])(0,_callback.default)(a,b,t,f);else return b.status(400).end("Error: HTTP GET is not supported for ".concat(g)),f();break;case"unlink":break;case"signout":break;case"done":return b.end("If you can see this, it worked!"),f();default:return b.status(400).end("Error: HTTP GET is not supported for ".concat(g)),f();}else return"POST"===a.method?(b.status(400).end("Error: HTTP POST is not supported for ".concat(g)),f()):(b.status(400).end("Error: HTTP ".concat(a.method," is not supported for ").concat(g)),f())});return function(){return d.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")),_providers=_interopRequireDefault(require("./lib/providers")),_providers2=_interopRequireDefault(require("./routes/providers")),_signin=_interopRequireDefault(require("./routes/signin")),_callback=_interopRequireDefault(require("./routes/callback")),_session=_interopRequireDefault(require("./routes/session")),_pages=_interopRequireDefault(require("./pages"));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_PATH_PREFIX="/api/auth",_default=(a,b,c)=>new Promise(function(){var d=_asyncToGenerator(function*(d){var e=d,{url:f,query:g}=a,{slug:h,action:i=h[0],provider:j=h[1]}=g,k=c.site||DEFAULT_SITE,l=c.pathPrefix||DEFAULT_PATH_PREFIX,m="".concat(k).concat(l),n=g.callbackUrl||k,o=c.secureCookies||m.startsWith("https://"),p=o?"__Secure-":"",q=_objectSpread({sessionId:{name:"".concat(p,"next-auth.session-id"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:o}},callbackUrl:{name:"".concat(p,"next-auth.callback-url"),options:{sameSite:"lax",path:"/",secure:o}},urlPrefix:{name:"".concat(p,"next-auth.url-prefix"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:o}},csrfToken:{name:"".concat(o?"__Host-":"","next-auth.csrf-token"),options:{httpOnly:!0,sameSite:"lax",path:"/",secure:o}}},c.cookies);a.cookies[q.urlPrefix.name]||_cookie.default.set(b,q.urlPrefix.name,m,q.urlPrefix.options);var r,s=c.secret||(0,_crypto.createHash)("sha256").update(JSON.stringify(c)).digest("hex");if(a.cookies[q.csrfToken.name]){var[u,v]=a.cookies[q.csrfToken.name].split("|");v==(0,_crypto.createHash)("sha256").update("".concat(u).concat(s)).digest("hex")?r=u:console.warn("CSRF_TOKEN_CHECK_WARNING")}if(!r){r=(0,_crypto.randomBytes)(32).toString("hex");var w="".concat(r,"|").concat((0,_crypto.createHash)("sha256").update("".concat(r).concat(s)).digest("hex"));_cookie.default.set(b,q.csrfToken.name,w,q.csrfToken.options)}var t=_objectSpread(_objectSpread({},c),{},{site:k,pathPrefix:l,urlPrefix:m,callbackUrl:n,action:i,provider:j,cookies:q,secret:s,csrfToken:r,providers:(0,_providers.default)(c.providers,m)});if("GET"===a.method)switch(i){case"providers":(0,_providers2.default)(a,b,t,e);break;case"session":(0,_session.default)(a,b,t,e);break;case"csrf":return b.json({csrfToken:r}),e();break;case"signin":j&&t.providers[j]?(0,_signin.default)(a,b,t,e):_pages.default.render(b,"signin",{providers:Object.values(t.providers),callbackUrl:t.callbackUrl,site:t.site},e);break;case"callback":if(j&&t.providers[j])(0,_callback.default)(a,b,t,e);else return b.status(400).end("Error: HTTP GET is not supported for ".concat(f)),e();break;case"unlink":break;case"signout":break;case"done":return b.end("If you can see this, it worked!"),e();default:return b.status(400).end("Error: HTTP GET is not supported for ".concat(f)),e();}else return"POST"===a.method?(b.status(400).end("Error: HTTP POST is not supported for ".concat(f)),e()):(b.status(400).end("Error: HTTP ".concat(a.method," is not supported for ").concat(f)),e())});return function(){return d.apply(this,arguments)}}());exports.default=_default;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _callback2=require("../lib/oauth/callback"),_signinFlow=_interopRequireDefault(require("../lib/signin-flow")),_cookie=_interopRequireDefault(require("../lib/cookie"));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)})}}var _default=function(){var a=_asyncToGenerator(function*(a,b,c,d){var{provider:e,providers:f,adapter:g,site:h,urlPrefix:i,cookies:j}=c,k=f[e],{type:l}=k,m=a.cookies[j.sessionId.name],n=a.cookies[j.callbackUrl.name]||h,o=function(){var a=_asyncToGenerator(function*(a,e){a&&console.log("SIGNIN_CALLBACK_ERROR",a);var{profile:f,account:k}=e;try{var{session:l,isNewAccount:o}=yield(0,_signinFlow.default)(g,m,f,k);_cookie.default.set(b,j.sessionId.name,l.id,j.sessionId.options),_cookie.default.set(b,j.urlPrefix.name,i,j.urlPrefix.options),o&&c.newAccountLandingPageUrl&&(n=c.newAccountLandingPageUrl)}catch(a){console.error(a)}return!c.checkCallbackUrl||c.checkCallbackUrl(n)?(b.status(302).setHeader("Location",n),b.end()):(console.warn("Warning: URL '".concat(n,"' is not an allowed callback URL (redirecting client to ").concat(h,")")),b.status(302).setHeader("Location",h),b.end()),d()});return function(){return a.apply(this,arguments)}}();return"oauth"===l||"oauth2"===l?void(0,_callback2.oAuthCallback)(a,k,o):(b.status(500).end("Error: Callback for provider type ".concat(l," 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 _callback2=require("../lib/oauth/callback"),_signinFlow=_interopRequireDefault(require("../lib/signin-flow")),_cookie=_interopRequireDefault(require("../lib/cookie"));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)})}}var _default=function(){var a=_asyncToGenerator(function*(a,b,c,d){var{provider:e,providers:f,adapter:g,site:h,urlPrefix:i,cookies:j}=c,k=f[e],{type:l}=k,m=a.cookies[j.sessionId.name],n=a.cookies[j.callbackUrl.name]||h,o=function(){var a=_asyncToGenerator(function*(a,e){a&&console.log("SIGNIN_CALLBACK_ERROR",a);var{profile:f,account:i}=e;try{var{session:k,isNewAccount:l}=yield(0,_signinFlow.default)(g,m,f,i);_cookie.default.set(b,j.sessionId.name,k.id,j.sessionId.options),l&&c.newAccountLandingPageUrl&&(n=c.newAccountLandingPageUrl)}catch(a){console.error(a)}return!c.checkCallbackUrl||c.checkCallbackUrl(n)?(b.status(302).setHeader("Location",n),b.end()):(console.warn("Warning: URL '".concat(n,"' is not an allowed callback URL (redirecting client to ").concat(h,")")),b.status(302).setHeader("Location",h),b.end()),d()});return function(){return a.apply(this,arguments)}}();return"oauth"===l||"oauth2"===l?void(0,_callback2.oAuthCallback)(a,k,o):(b.status(500).end("Error: Callback for provider type ".concat(l," not supported")),d())});return function(){return a.apply(this,arguments)}}();exports.default=_default;
{
"name": "next-auth",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.9",
"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