@snokam/auth 2.2.19 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/middleware.js +1 -1
- package/lib/middleware.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.20](https://github.com/snokam/components/compare/@snokam/auth@2.2.19...@snokam/auth@2.2.20) (2025-09-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* default allow healthy checks ([d91764d](https://github.com/snokam/components/commit/d91764df8b29641f60da6ed286c26b62d841009b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [2.2.19](https://github.com/snokam/components/compare/@snokam/auth@2.2.18...@snokam/auth@2.2.19) (2025-09-25)
|
|
7
18
|
|
|
8
19
|
|
package/lib/middleware.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.snokam=e():t.snokam=e()}(this,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{buildAuthMiddleware:()=>i,config:()=>c,default:()=>l});const n=require("path-to-regexp"),o=require("next-auth/middleware");var r=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n};const a=["/((?!api/healthy|api/ready|_next/static|_next/image|favicon.ico|.*\\..*).*)"];function i(t={}){var e,{matcher:i=[],callbacks:s={},protectAllRoutes:c}=t,l=r(t,["matcher","callbacks","protectAllRoutes"]);const u="preview"===process.env.NEXT_PUBLIC_VERCEL_ENV,{name:d}=function(t){const{hostname:e,protocol:n}=new URL(t),o="https:"===n,r=o?"__Secure-":"",{tag:a,domain:i}=(()=>{if("localhost"===e||/^[\d.]+$/.test(e))return{tag:"local"};if(e.endsWith(".test.snokam.no"))return{tag:"test",domain:".test.snokam.no"};if(e.endsWith(".snokam.no"))return{tag:"prod",domain:".snokam.no"};const t=e.split(".");if(t.length>=2){const e=t.slice(-2).join(".");return{tag:e.replace(/\./g,"-"),domain:`.${e}`}}return{tag:"host"}})();return{name:`${r}next-auth.${a}.session-token`,domain:i,secure:o}}(`${process.env.NEXTAUTH_URL}`);return{middleware:(0,o.withAuth)((t=>{}),Object.assign({pages:{signIn:"/auth/login"},cookies:{sessionToken:{name:d}},callbacks:{authorized:null!==(e=s.authorized)&&void 0!==e?e:({req:t,token:e})=>{return!(!(o=t.nextUrl.pathname).startsWith("/api/healthy")&&!o.startsWith("/api/ready")&&(u||c&&0===(null==i?void 0:i.length)||i.some((t=>{if(!t)return!1;if(t.startsWith("/")&&t.endsWith(")")){const e=t.substring(1);let n=e;return e.startsWith("((?!")&&!e.startsWith("^")&&(n="^"+e),new RegExp(n).test(o)}if(t.endsWith(":path*")){const e=t.replace(/\/:path\*$/,"");return o.startsWith(e)}try{return!1!==(0,n.match)(t,{end:!0})(o)}catch(t){return console.warn(`Invalid path pattern in auth middleware: ${t}`),!1}})))&&!e);var o}}},l)),config:u?{matcher:a}:(null==i?void 0:i.length)>0?{matcher:i}:void 0}}const{middleware:s,config:c}=i(),l=s;return e})()));
|
|
2
2
|
//# sourceMappingURL=middleware.js.map
|
package/lib/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,0ECL9D,MAAM,EAA+BC,QAAQ,kBCAvC,EAA+BA,QAAQ,wBCA7C,IAAIC,EAAkC,SAAUC,EAAGC,GAC/C,IAAIC,EAAI,CAAC,EACT,IAAK,IAAIC,KAAKH,EAAOd,OAAOM,UAAUC,eAAeC,KAAKM,EAAGG,IAAMF,EAAEG,QAAQD,GAAK,IAC9ED,EAAEC,GAAKH,EAAEG,IACb,GAAS,MAALH,GAAqD,mBAAjCd,OAAOmB,sBACtB,KAAIC,EAAI,EAAb,IAAgBH,EAAIjB,OAAOmB,sBAAsBL,G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S,CACRC,aAAc,CACV3B,SAELP,UAAW,CACVmC,WAA4C,QAA/BrC,EAAKE,EAAUmC,kBAA+B,IAAPrC,EAAgBA,EAAK,EAAIsC,MAAKC,YAC9E,OA3CeC,EA2CUF,EAAIG,QAAQD,WA1CzCnC,GAAcF,GAA2F,KAAtEF,aAAyC,EAASA,EAAQN,SAG1FM,EAAQyC,MAAMC,IACjB,IAAKA,EACD,OAAO,EAGX,GAAIA,EAAQC,WAAW,MAAQD,EAAQxB,SAAS,KAAM,CAElD,MAAM0B,EAAeF,EAAQG,UAAU,GAGvC,IAAIC,EAAeF,EAKnB,OAJIA,EAAaD,WAAW,UAAYC,EAAaD,WAAW,OAC5DG,EAAe,IAAMF,GAEX,IAAIG,OAAOD,GACZ7B,KAAKsB,EACtB,CAEA,GAAIG,EAAQxB,SAAS,UAAW,CAC5B,MAAMG,EAAOqB,EAAQlB,QAAQ,aAAc,IAC3C,OAAOe,EAASI,WAAWtB,EAC/B,CACA,IACI,OAAmD,KAA5C,IAAA2B,OAAMN,EAAS,CAAEO,KAAK,GAAtB,CAA8BV,EACzC,CACA,MAAOW,GAEH,OADAC,QAAQC,KAAK,4CAA4CF,MAClD,CACX,SAWuDZ,EA3CrC,IAACC,CA4ClB,IACApC,IAMYkD,OALNjD,EACT,CAAEJ,QAASJ,IACVI,aAAyC,EAASA,EAAQN,QAAU,EACjE,CAAEM,gBACFsD,EAEd,CAEA,MAAM,WAAE1B,EAAU,OAAEyB,GAAWxD,IAE/B,I","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"path-to-regexp\"","webpack://snokam/external commonjs \"next-auth/middleware\"","webpack://snokam/./src/middleware.tsx","webpack://snokam/./src/utils/cookies.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"path-to-regexp\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/middleware\");","var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport { match } from \"path-to-regexp\";\nimport { withAuth } from \"next-auth/middleware\";\nimport { getSessionCookieSettings } from \"./utils/cookies\";\n// Default catch-all matcher used in Vercel preview environments\nconst previewMatcher = [\n \"/((?!api/healthy|api/ready|_next/static|_next/image|favicon.ico|.*\\\\..*).*)\",\n];\nexport function buildAuthMiddleware(_a = {}) {\n var _b;\n var { matcher = [], callbacks = {}, protectAllRoutes } = _a, rest = __rest(_a, [\"matcher\", \"callbacks\", \"protectAllRoutes\"]);\n const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === \"preview\";\n const { name } = getSessionCookieSettings(`${process.env.NEXTAUTH_URL}`);\n const shouldProtectPath = (pathname) => {\n if (isPreview || (protectAllRoutes && (matcher === null || matcher === void 0 ? void 0 : matcher.length) === 0)) {\n return true;\n }\n return matcher.some((pattern) => {\n if (!pattern) {\n return false;\n }\n // Handle regex patterns (starting with / and containing complex regex)\n if (pattern.startsWith(\"/\") && pattern.endsWith(\")\")) {\n // Remove the leading / from pattern and pathname\n const cleanPattern = pattern.substring(1);\n // Fix the regex by anchoring it to the start of the string\n // The original regex was missing the ^ anchor\n let fixedPattern = cleanPattern;\n if (cleanPattern.startsWith(\"((?!\") && !cleanPattern.startsWith(\"^\")) {\n fixedPattern = \"^\" + cleanPattern;\n }\n const regex = new RegExp(fixedPattern);\n return regex.test(pathname);\n }\n // Handle simple path patterns with :path*\n if (pattern.endsWith(\":path*\")) {\n const base = pattern.replace(/\\/:path\\*$/, \"\");\n return pathname.startsWith(base);\n }\n try {\n return match(pattern, { end: true })(pathname) !== false;\n }\n catch (error) {\n console.warn(`Invalid path pattern in auth middleware: ${error}`);\n return false;\n }\n });\n };\n const middleware = withAuth((_req) => { }, Object.assign({ pages: {\n signIn: \"/auth/login\",\n }, cookies: {\n sessionToken: {\n name,\n },\n }, callbacks: {\n authorized: (_b = callbacks.authorized) !== null && _b !== void 0 ? _b : (({ req, token }) => {\n return shouldProtectPath(req.nextUrl.pathname) ? !!token : true;\n }),\n } }, rest));\n const config = isPreview\n ? { matcher: previewMatcher }\n : (matcher === null || matcher === void 0 ? void 0 : matcher.length) > 0\n ? { matcher }\n : undefined;\n return { middleware, config };\n}\n// Default: protect all HTML pages in preview, do nothing in production\nconst { middleware, config } = buildAuthMiddleware();\nexport { config };\nexport default middleware;\n","export function getSessionCookieSettings(nextAuthUrl) {\n const { hostname, protocol } = new URL(nextAuthUrl);\n const secure = protocol === \"https:\";\n const prefix = secure ? \"__Secure-\" : \"\";\n const getTagAndDomain = () => {\n if (hostname === \"localhost\" || /^[\\d.]+$/.test(hostname)) {\n return { tag: \"local\" };\n }\n if (hostname.endsWith(\".test.snokam.no\")) {\n return { tag: \"test\", domain: \".test.snokam.no\" };\n }\n if (hostname.endsWith(\".snokam.no\")) {\n return { tag: \"prod\", domain: \".snokam.no\" };\n }\n const parts = hostname.split(\".\");\n if (parts.length >= 2) {\n const base = parts.slice(-2).join(\".\");\n return { tag: base.replace(/\\./g, \"-\"), domain: `.${base}` };\n }\n return { tag: \"host\" };\n };\n const { tag, domain } = getTagAndDomain();\n const name = `${prefix}next-auth.${tag}.session-token`;\n return { name, domain, secure };\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","__rest","s","e","t","p","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","previewMatcher","buildAuthMiddleware","_a","_b","matcher","callbacks","protectAllRoutes","rest","isPreview","process","env","NEXT_PUBLIC_VERCEL_ENV","name","nextAuthUrl","hostname","protocol","URL","secure","prefix","tag","domain","test","endsWith","parts","split","base","slice","join","replace","getTagAndDomain","getSessionCookieSettings","NEXTAUTH_URL","middleware","withAuth","_req","assign","pages","signIn","cookies","sessionToken","authorized","req","token","pathname","nextUrl","some","pattern","startsWith","cleanPattern","substring","fixedPattern","RegExp","match","end","error","console","warn","config","undefined"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"middleware.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM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G,OAAOD,GACZ7B,KAAKsB,EACtB,CAEA,GAAII,EAAQzB,SAAS,UAAW,CAC5B,MAAMG,EAAOsB,EAAQnB,QAAQ,aAAc,IAC3C,OAAOe,EAASE,WAAWpB,EAC/B,CACA,IACI,OAAmD,KAA5C,IAAA2B,OAAML,EAAS,CAAEM,KAAK,GAAtB,CAA8BV,EACzC,CACA,MAAOW,GAEH,OADAC,QAAQC,KAAK,4CAA4CF,MAClD,CACX,QAWuDZ,GAhDrC,IAACC,CAiDlB,IACApC,IAMYkD,OALNjD,EACT,CAAEJ,QAASJ,IACVI,aAAyC,EAASA,EAAQN,QAAU,EACjE,CAAEM,gBACFsD,EAEd,CAEA,MAAM,WAAE1B,EAAU,OAAEyB,GAAWxD,IAE/B,I","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"path-to-regexp\"","webpack://snokam/external commonjs \"next-auth/middleware\"","webpack://snokam/./src/middleware.tsx","webpack://snokam/./src/utils/cookies.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"path-to-regexp\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/middleware\");","var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport { match } from \"path-to-regexp\";\nimport { withAuth } from \"next-auth/middleware\";\nimport { getSessionCookieSettings } from \"./utils/cookies\";\n// Default catch-all matcher used in Vercel preview environments\nconst previewMatcher = [\n \"/((?!api/healthy|api/ready|_next/static|_next/image|favicon.ico|.*\\\\..*).*)\",\n];\nexport function buildAuthMiddleware(_a = {}) {\n var _b;\n var { matcher = [], callbacks = {}, protectAllRoutes } = _a, rest = __rest(_a, [\"matcher\", \"callbacks\", \"protectAllRoutes\"]);\n const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === \"preview\";\n const { name } = getSessionCookieSettings(`${process.env.NEXTAUTH_URL}`);\n const shouldProtectPath = (pathname) => {\n // Container health check paths\n if (pathname.startsWith(\"/api/healthy\")) {\n return false;\n }\n // Container readiness check paths\n if (pathname.startsWith(\"/api/ready\")) {\n return false;\n }\n if (isPreview || (protectAllRoutes && (matcher === null || matcher === void 0 ? void 0 : matcher.length) === 0)) {\n return true;\n }\n return matcher.some((pattern) => {\n if (!pattern) {\n return false;\n }\n // Fix to handle Nextjs regex patterns\n if (pattern.startsWith(\"/\") && pattern.endsWith(\")\")) {\n const cleanPattern = pattern.substring(1);\n let fixedPattern = cleanPattern;\n if (cleanPattern.startsWith(\"((?!\") && !cleanPattern.startsWith(\"^\")) {\n fixedPattern = \"^\" + cleanPattern;\n }\n const regex = new RegExp(fixedPattern);\n return regex.test(pathname);\n }\n // Handle simple path patterns with :path*\n if (pattern.endsWith(\":path*\")) {\n const base = pattern.replace(/\\/:path\\*$/, \"\");\n return pathname.startsWith(base);\n }\n try {\n return match(pattern, { end: true })(pathname) !== false;\n }\n catch (error) {\n console.warn(`Invalid path pattern in auth middleware: ${error}`);\n return false;\n }\n });\n };\n const middleware = withAuth((_req) => { }, Object.assign({ pages: {\n signIn: \"/auth/login\",\n }, cookies: {\n sessionToken: {\n name,\n },\n }, callbacks: {\n authorized: (_b = callbacks.authorized) !== null && _b !== void 0 ? _b : (({ req, token }) => {\n return shouldProtectPath(req.nextUrl.pathname) ? !!token : true;\n }),\n } }, rest));\n const config = isPreview\n ? { matcher: previewMatcher }\n : (matcher === null || matcher === void 0 ? void 0 : matcher.length) > 0\n ? { matcher }\n : undefined;\n return { middleware, config };\n}\n// Default: protect all HTML pages in preview, do nothing in production\nconst { middleware, config } = buildAuthMiddleware();\nexport { config };\nexport default middleware;\n","export function getSessionCookieSettings(nextAuthUrl) {\n const { hostname, protocol } = new URL(nextAuthUrl);\n const secure = protocol === \"https:\";\n const prefix = secure ? \"__Secure-\" : \"\";\n const getTagAndDomain = () => {\n if (hostname === \"localhost\" || /^[\\d.]+$/.test(hostname)) {\n return { tag: \"local\" };\n }\n if (hostname.endsWith(\".test.snokam.no\")) {\n return { tag: \"test\", domain: \".test.snokam.no\" };\n }\n if (hostname.endsWith(\".snokam.no\")) {\n return { tag: \"prod\", domain: \".snokam.no\" };\n }\n const parts = hostname.split(\".\");\n if (parts.length >= 2) {\n const base = parts.slice(-2).join(\".\");\n return { tag: base.replace(/\\./g, \"-\"), domain: `.${base}` };\n }\n return { tag: \"host\" };\n };\n const { tag, domain } = getTagAndDomain();\n const name = `${prefix}next-auth.${tag}.session-token`;\n return { name, domain, secure };\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","__rest","s","e","t","p","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","previewMatcher","buildAuthMiddleware","_a","_b","matcher","callbacks","protectAllRoutes","rest","isPreview","process","env","NEXT_PUBLIC_VERCEL_ENV","name","nextAuthUrl","hostname","protocol","URL","secure","prefix","tag","domain","test","endsWith","parts","split","base","slice","join","replace","getTagAndDomain","getSessionCookieSettings","NEXTAUTH_URL","middleware","withAuth","_req","assign","pages","signIn","cookies","sessionToken","authorized","req","token","pathname","nextUrl","startsWith","some","pattern","cleanPattern","substring","fixedPattern","RegExp","match","end","error","console","warn","config","undefined"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snokam/auth",
|
|
3
3
|
"description": "Snøkam auth components",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.20",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
]
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "e1eec46385dab7beb3dc16acc70d4df792d9320b"
|
|
71
71
|
}
|