@snokam/auth 2.2.0-alpha.20 → 2.2.0-alpha.22
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 +22 -0
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- 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,28 @@
|
|
|
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.0-alpha.22](https://github.com/snokam/components/compare/@snokam/auth@2.2.0-alpha.21...@snokam/auth@2.2.0-alpha.22) (2025-06-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* change to NEXT_PUBLIC_APP_ENV ([6082efa](https://github.com/snokam/components/commit/6082efadd5e7683e631c6a9a7e309671da2a8df3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [2.2.0-alpha.21](https://github.com/snokam/components/compare/@snokam/auth@2.2.0-alpha.20...@snokam/auth@2.2.0-alpha.21) (2025-06-02)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* error page ([fa7a824](https://github.com/snokam/components/commit/fa7a8240f495d4f4eb6a2418f4ec46697818b95a))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [2.2.0-alpha.20](https://github.com/snokam/components/compare/@snokam/auth@2.2.0-alpha.19...@snokam/auth@2.2.0-alpha.20) (2025-06-02)
|
|
7
29
|
|
|
8
30
|
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.snokam=r():e.snokam=r()}(this,(()=>(()=>{"use strict";var e={n:r=>{var
|
|
2
|
-
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.snokam=r():e.snokam=r()}(this,(()=>(()=>{"use strict";var e={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{Authenticated:()=>U,Unauthenticated:()=>I,default:()=>R,middleware:()=>_(),signIn:()=>i.signIn,useAuth:()=>a});const n=require("react/jsx-runtime"),t=require("react"),o=require("next/router"),i=require("next-auth/react");var s=function(e,r,n,t){return new(n||(n=Promise))((function(o,i){function s(e){try{l(t.next(e))}catch(e){i(e)}}function a(e){try{l(t.throw(e))}catch(e){i(e)}}function l(e){var r;e.done?o(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(s,a)}l((t=t.apply(e,r||[])).next())}))};function a(){const{data:e,status:r,update:n}=(0,i.useSession)(),o=e=>s(this,void 0,void 0,(function*(){const r=e[0],n=yield fetch("/api/auth/token",{method:"POST",body:JSON.stringify({scope:r}),credentials:"include",headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error("Token fetch failed");const t=yield n.json(),{accessToken:o}=t;return`Bearer ${o}`}));return(0,t.useMemo)((()=>({update:n,signIn:i.signIn,session:e,getToken:e=>o(e).catch((e=>{console.error(e),window.location.href="/auth/login?error=true"})),inProgress:"loading"===r,isAuthenticated:"authenticated"===r,signOut:e=>s(this,[e],void 0,(function*({redirectTo:e}){return(0,i.signOut)().finally((()=>{window.location.href=e}))}))})),[n,o,r,e,i.signIn,i.signOut])}const l=require("@snokam/core"),u=(0,t.memo)((e=>{const{children:r,provider:o}=e,{inProgress:s,isAuthenticated:u}=a();return(0,t.useEffect)((()=>{s||u||(0,i.signIn)(o)}),[s,u]),u?r:(0,n.jsx)(l.PageLoader,{})})),c=(0,t.memo)((e=>{const{session:r,children:t,enforceLogin:s}=e,a=(0,o.useRouter)(),l=null==a?void 0:a.query;return(null==l?void 0:l.enforceLogin)||s?(0,n.jsx)(i.SessionProvider,{session:r,children:(0,n.jsx)(u,Object.assign({provider:"azure-ad"},e,{children:t}))}):(0,n.jsx)(i.SessionProvider,{session:r,children:(0,n.jsx)(d,{children:t})})})),d=({children:e})=>{var r;const{signOut:i}=a(),s=(0,o.useRouter)();return(0,t.useEffect)((()=>{var e;"true"===(null===(e=null==s?void 0:s.query)||void 0===e?void 0:e.logout)&&i({redirectTo:"/auth/login?callbackUrl=/"})}),[null===(r=null==s?void 0:s.query)||void 0===r?void 0:r.logout]),(0,n.jsx)(n.Fragment,{children:e})},g=require("@emotion/styled");var h=e.n(g);const m=require("@snokam/core/layout");var f=e.n(m);const p=h()(f().Container)`
|
|
2
|
+
flex: 1;
|
|
3
|
+
justify-content: center;
|
|
3
4
|
`,x=h().div`
|
|
4
5
|
display: flex;
|
|
5
6
|
flex-direction: column;
|
|
@@ -37,5 +38,5 @@
|
|
|
37
38
|
font-size: 1rem;
|
|
38
39
|
margin-top: 1rem;
|
|
39
40
|
gap: 1rem;
|
|
40
|
-
`},k=require("@mui/material/Button");var
|
|
41
|
+
`},k=require("@mui/material/Button");var S=e.n(k);const P=require("@mui/material/Alert");var q=e.n(P);let O=!1;const T=t.forwardRef((function(e,r){return O||(console.warn(["MUI: The Alert component was moved from the lab to the core.","","You should use `import { Alert } from '@mui/material'`","or `import Alert from '@mui/material/Alert'`"].join("\n")),O=!0),(0,n.jsx)(q(),{ref:r,...e})})),A=require("@mui/material"),E=({message:e})=>{const{session:r,signOut:t}=a(),o="preview"===process.env.NEXT_PUBLIC_VERCEL_ENV;return(0,n.jsx)(w.Container,{transitions:{bottom:{type:m.TransitionType.Wave}},children:(0,n.jsx)(l.Layout.Content,{children:(0,n.jsx)(w.Section,{children:(0,n.jsxs)(w.Wrapper,{children:[(0,n.jsx)(w.Heading,{children:"Oops! Noe gikk galt."}),(0,n.jsx)(w.Illustration,{src:"https://ressurser.snokam.no/figures/snowman.svg",alt:"Feil illustrasjon"}),(0,n.jsx)(w.Description,{children:null!=e?e:(0,n.jsxs)(n.Fragment,{children:["En uventet feil har oppstått.",(0,n.jsx)("br",{}),"Prøv igjen, eller logg inn på nytt."]})}),r&&(0,n.jsxs)(w.User,{children:[(0,n.jsx)(A.Avatar,{src:r.user.image}),"Logget inn som: ",r.user.name,(0,n.jsx)("br",{}),"(",r.user.email,")"]}),o&&(0,n.jsxs)(T,{severity:"warning",children:["Du er i test! Husk at det kun er mulig å logge inn ",(0,n.jsx)("br",{}),"med en av våre testbrukere som du finner i 1Password."]}),(0,n.jsx)(S(),{sx:{mt:3},color:"secondary",variant:"contained",onClick:()=>{t({redirectTo:"/auth/login?callbackUrl=/&prompt=login"})},children:"Logg inn på nytt"})]})})})})},L=E,I=({children:e})=>{const{status:r}=(0,i.useSession)();return"unauthenticated"===r?e:null},U=({children:e})=>{const{status:r}=(0,i.useSession)();return"authenticated"===r?e:null},C=require("next-auth/middleware");var _=e.n(C);const R={Login:()=>{const{isAuthenticated:e}=a(),[r,s]=(0,t.useState)(null),[u,c]=(0,t.useState)({}),[d,g]=(0,t.useState)(!1),h=(0,o.useRouter)();return(0,t.useEffect)((()=>{const e=new URLSearchParams(window.location.search);s(e.get("callbackUrl")),g(!!e.get("error"));const r={};e.forEach(((e,n)=>{"error"!==n&&"callbackUrl"!==n&&(r[n]=e)})),c(r)}),[]),(0,t.useEffect)((()=>{r&&(e?h.replace("/"):(0,i.signIn)("azure-ad",{callbackUrl:r},u))}),[e,r,u]),d?(0,n.jsx)(L,{}):(0,n.jsx)(l.PageLoader,{})},Error:E,Provider:c,Authenticate:u};return r})()));
|
|
41
42
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.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,EAAyBJ,IACxB,IAAIK,EAASL,GAAUA,EAAOM,WAC7B,IAAON,EAAiB,QACxB,IAAM,EAEP,OADAI,EAAoBG,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdD,EAAwB,CAACL,EAASU,KACjC,IAAI,IAAIC,KAAOD,EACXL,EAAoBO,EAAEF,EAAYC,KAASN,EAAoBO,EAAEZ,EAASW,IAC5EE,OAAOC,eAAed,EAASW,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDN,EAAwB,CAACY,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFb,EAAyBL,IACH,oBAAXsB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAed,EAASsB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAed,EAAS,aAAc,CAAEwB,OAAO,GAAO,G,kICL9D,MAAM,EAA+BC,QAAQ,qBCAvC,EAA+BA,QAAQ,SCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,mBCA7C,IAAIC,EAAwC,SAAUC,EAASC,EAAYC,EAAGC,GAE1E,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUV,GAAS,IAAMW,EAAKL,E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SAAQ,EACRP,aAAY,G","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/compat get default export","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"react/jsx-runtime\"","webpack://snokam/external commonjs \"react\"","webpack://snokam/external commonjs \"next/router\"","webpack://snokam/external commonjs \"next-auth/react\"","webpack://snokam/./src/hooks.ts","webpack://snokam/external commonjs \"@snokam/core\"","webpack://snokam/./src/components/Authenticate.tsx","webpack://snokam/./src/components/Provider/index.tsx","webpack://snokam/external commonjs \"@emotion/styled\"","webpack://snokam/external commonjs \"@snokam/core/layout\"","webpack://snokam/./src/components/Error/styled.tsx","webpack://snokam/external commonjs \"@mui/material/Button\"","webpack://snokam/external commonjs \"@mui/material/Alert\"","webpack://snokam/../../../node_modules/.pnpm/@mui+lab@6.0.0-beta.31_@emotion+react@11.14.0_@types+react@19.0.12_react@19.1.0__@emotion+sty_fz6gji5ey23b355xhyqlbn33ti/node_modules/@mui/lab/Alert/Alert.js","webpack://snokam/external commonjs \"@mui/material\"","webpack://snokam/./src/components/Error/index.tsx","webpack://snokam/./src/components/Unauthenticated.tsx","webpack://snokam/./src/components/Authenticated.tsx","webpack://snokam/external commonjs \"next-auth/middleware\"","webpack://snokam/./src/index.tsx","webpack://snokam/./src/components/Login.tsx"],"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","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\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(\"react/jsx-runtime\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next/router\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/react\");","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { useSession, signIn, signOut } from \"next-auth/react\";\nimport { useRouter } from \"next/router\";\nimport { useMemo } from \"react\";\nexport function useAuth() {\n const { data: session, status, update } = useSession();\n const router = useRouter();\n const getToken = (scopes) => __awaiter(this, void 0, void 0, function* () {\n const scope = scopes[0];\n const res = yield fetch(\"/api/auth/token\", {\n method: \"POST\",\n body: JSON.stringify({ scope }),\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n if (!res.ok) {\n throw new Error(\"Token fetch failed\");\n }\n const token = yield res.json();\n const { accessToken } = token;\n return `Bearer ${accessToken}`;\n });\n const value = useMemo(() => ({\n update,\n signIn,\n session,\n getToken: (scopes) => getToken(scopes).catch((error) => {\n console.error(error);\n window.location.href = \"/auth/login?error=true\";\n }),\n inProgress: status === \"loading\",\n isAuthenticated: status === \"authenticated\",\n signOut: (_a) => __awaiter(this, [_a], void 0, function* ({ redirectTo }) {\n return signOut().finally(() => {\n window.location.href = redirectTo;\n });\n }),\n }), [update, getToken, status, session, signIn, signOut]);\n return value;\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@snokam/core\");","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { memo, useEffect } from \"react\";\nimport { signIn } from \"next-auth/react\";\nimport { useAuth } from \"../hooks\";\nimport { PageLoader } from \"@snokam/core\";\nexport const Authenticate = memo((props) => {\n const { children, provider } = props;\n const { inProgress, isAuthenticated } = useAuth();\n useEffect(() => {\n if (!inProgress && !isAuthenticated) {\n signIn(provider);\n }\n }, [inProgress, isAuthenticated]);\n if (!isAuthenticated) {\n return _jsx(PageLoader, {});\n }\n return children;\n});\n","import { jsx as _jsx, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { memo, useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { Authenticate } from \"../Authenticate\";\nimport { SessionProvider } from \"next-auth/react\";\nimport { useAuth } from \"../../hooks\";\nexport const Provider = memo((props) => {\n const { session, children, enforceLogin } = props;\n const router = useRouter();\n const query = router === null || router === void 0 ? void 0 : router.query;\n if ((query === null || query === void 0 ? void 0 : query.enforceLogin) || enforceLogin) {\n return (_jsx(SessionProvider, { session: session, children: _jsx(Authenticate, Object.assign({ provider: \"azure-ad\" }, props, { children: children })) }));\n }\n return (_jsx(SessionProvider, { session: session, children: _jsx(Wrapper, { children: children }) }));\n});\nexport const Wrapper = ({ children }) => {\n var _a;\n const { signOut } = useAuth();\n const router = useRouter();\n useEffect(() => {\n var _a;\n if (((_a = router === null || router === void 0 ? void 0 : router.query) === null || _a === void 0 ? void 0 : _a.logout) === \"true\") {\n signOut({\n redirectTo: \"/auth/login?callbackUrl=/\",\n });\n }\n }, [(_a = router === null || router === void 0 ? void 0 : router.query) === null || _a === void 0 ? void 0 : _a.logout]);\n return _jsx(_Fragment, { children: children });\n};\nexport default Provider;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@emotion/styled\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@snokam/core/layout\");","import styled from \"@emotion/styled\";\nimport Layout from \"@snokam/core/layout\";\nconst Container = styled(Layout.Container) `\n height: calc(100% - 100px);\n`;\nconst Wrapper = styled.div `\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n align-items: center;\n width: 100%;\n max-width: 600px;\n padding: 2rem;\n background-color: var(--color-dark-green);\n border-radius: 1rem;\n box-shadow: 0 4px 10px rgba(0, 0, 0, 0.9);\n`;\nconst Heading = styled.h1 `\n font-size: 2rem;\n font-weight: 600;\n margin: 0;\n`;\nconst Illustration = styled.img `\n width: 200px;\n max-width: 100%;\n height: auto;\n`;\nconst Link = styled.a `\n text-decoration: underline;\n color: inherit;\n`;\nconst Section = styled(Layout.Section) `\n display: flex;\n justify-content: center;\n align-items: center;\n color: var(--color-light-blue);\n`;\nconst Description = styled.div `\n display: flex;\n font-size: 1.15rem;\n text-align: center;\n`;\nconst User = styled.div `\n display: flex;\n align-items: center;\n font-size: 1rem;\n margin-top: 1rem;\n gap: 1rem;\n`;\nexport default {\n Container,\n Wrapper,\n Heading,\n Illustration,\n Description,\n Section,\n Link,\n User,\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material/Button\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material/Alert\");","'use client';\n\nimport * as React from 'react';\nimport Alert from '@mui/material/Alert';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nlet warnedOnce = false;\nconst warn = () => {\n if (!warnedOnce) {\n console.warn(['MUI: The Alert component was moved from the lab to the core.', '', \"You should use `import { Alert } from '@mui/material'`\", \"or `import Alert from '@mui/material/Alert'`\"].join('\\n'));\n warnedOnce = true;\n }\n};\n\n/**\n * @ignore - do not document.\n */\nexport default /*#__PURE__*/React.forwardRef(function DeprecatedAlert(props, ref) {\n warn();\n return /*#__PURE__*/_jsx(Alert, {\n ref: ref,\n ...props\n });\n});","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material\");","import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport Styled from \"./styled\";\nimport { Layout } from \"@snokam/core\";\nimport { Padding, TransitionType } from \"@snokam/core/layout\";\nimport { useAuth } from \"../../hooks\";\nimport Button from \"@mui/material/Button\";\nimport { Alert } from \"@mui/lab\";\nimport { Avatar } from \"@mui/material\";\nexport const Error = ({ message }) => {\n const { session, signOut } = useAuth();\n const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === \"preview\";\n return (_jsx(Styled.Container, { transitions: {\n bottom: {\n type: TransitionType.Wave,\n },\n }, children: _jsx(Layout.Content, { children: _jsx(Styled.Section, { padding: {\n top: Padding.Large,\n bottom: Padding.Large,\n }, children: _jsxs(Styled.Wrapper, { children: [_jsx(Styled.Heading, { children: \"Oops! Noe gikk galt.\" }), _jsx(Styled.Illustration, { src: \"https://ressurser.snokam.no/figures/snowman.svg\", alt: \"Feil illustrasjon\" }), _jsx(Styled.Description, { children: message !== null && message !== void 0 ? message : (_jsxs(_Fragment, { children: [\"En uventet feil har oppst\\u00E5tt.\", _jsx(\"br\", {}), \"Pr\\u00F8v igjen, eller logg inn p\\u00E5 nytt.\"] })) }), session && (_jsxs(Styled.User, { children: [_jsx(Avatar, { src: session.user.image }), \"Logget inn som: \", session.user.name, _jsx(\"br\", {}), \"(\", session.user.email, \")\"] })), isPreview && (_jsxs(Alert, { severity: \"warning\", children: [\"Du er i test! Husk at det kun er mulig \\u00E5 logge inn \", _jsx(\"br\", {}), \"med en av v\\u00E5re testbrukere som du finner i 1Password.\"] })), _jsx(Button, { sx: { mt: 3 }, color: \"secondary\", variant: \"contained\", onClick: () => {\n signOut({\n redirectTo: \"/auth/login?callbackUrl=/&prompt=login\",\n });\n }, children: \"Logg inn p\\u00E5 nytt\" })] }) }) }) }));\n};\nexport default Error;\n","import { useSession } from \"next-auth/react\";\nexport const Unauthenticated = ({ children }) => {\n const { status } = useSession();\n return status === \"unauthenticated\" ? children : null;\n};\n","import { useSession } from \"next-auth/react\";\nexport const Authenticated = ({ children }) => {\n const { status } = useSession();\n return status === \"authenticated\" ? children : null;\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/middleware\");","import { Provider } from \"./components/Provider\";\nimport { Authenticate } from \"./components/Authenticate\";\nimport { Login } from \"./components/Login\";\nimport { Error } from \"./components/Error\";\nexport { Unauthenticated } from \"./components/Unauthenticated\";\nexport { Authenticated } from \"./components/Authenticated\";\nexport { useAuth } from \"./hooks\";\nexport { default as middleware } from \"next-auth/middleware\";\nexport { signIn } from \"next-auth/react\";\nexport default {\n Login,\n Error,\n Provider,\n Authenticate,\n};\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useState } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { useAuth } from \"../hooks\";\nimport { signIn } from \"next-auth/react\";\nimport { PageLoader } from \"@snokam/core\";\nimport Error from \"./Error\";\nexport const Login = () => {\n const { isAuthenticated } = useAuth();\n const [callbackUrl, setCallbackUrl] = useState(null);\n const [authParams, setAuthParams] = useState({});\n const [isError, setIsError] = useState(false);\n const router = useRouter();\n useEffect(() => {\n const params = new URLSearchParams(window.location.search);\n setCallbackUrl(params.get(\"callbackUrl\"));\n setIsError(!!params.get(\"error\"));\n const authParamsObj = {};\n params.forEach((value, key) => {\n if (key !== \"error\" && key !== \"callbackUrl\") {\n authParamsObj[key] = value;\n }\n });\n setAuthParams(authParamsObj);\n }, []);\n useEffect(() => {\n if (!callbackUrl)\n return;\n if (isAuthenticated) {\n router.replace(\"/\");\n }\n else {\n signIn(\"azure-ad\", { callbackUrl }, authParams);\n }\n }, [isAuthenticated, callbackUrl, authParams]);\n if (isError) {\n return _jsx(Error, {});\n }\n return _jsx(PageLoader, {});\n};\nexport default Login;\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","step","next","e","rejected","result","done","then","apply","useAuth","data","session","status","update","useSession","getToken","useRouter","scopes","scope","res","fetch","method","body","JSON","stringify","credentials","headers","ok","Error","token","json","accessToken","useMemo","signIn","catch","error","console","window","location","href","inProgress","isAuthenticated","signOut","_a","redirectTo","finally","Authenticate","memo","props","children","provider","useEffect","PageLoader","Provider","enforceLogin","router","query","SessionProvider","assign","Wrapper","logout","Container","Heading","Illustration","Link","Section","Description","User","warnedOnce","ref","warn","join","message","isPreview","process","env","NEXT_PUBLIC_VERCEL_ENV","transitions","bottom","type","TransitionType","Wave","Layout","Content","padding","top","Padding","Large","src","alt","Avatar","user","image","name","email","Alert","severity","sx","mt","color","variant","onClick","Unauthenticated","Authenticated","Login","callbackUrl","setCallbackUrl","useState","authParams","setAuthParams","isError","setIsError","params","URLSearchParams","search","authParamsObj","forEach","replace"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.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,EAAyBJ,IACxB,IAAIK,EAASL,GAAUA,EAAOM,WAC7B,IAAON,EAAiB,QACxB,IAAM,EAEP,OADAI,EAAoB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C,UAAS,OACxCC,EAAYC,IAAiB,IAAAF,UAAS,CAAC,IACvCG,EAASC,IAAc,IAAAJ,WAAS,GACjCjD,GAAS,IAAAC,aAuBf,OAtBA,IAAAL,YAAU,KACN,MAAM0D,EAAS,IAAIC,gBAAgBzE,OAAOC,SAASyE,QACnDR,EAAeM,EAAO9H,IAAI,gBAC1B6H,IAAaC,EAAO9H,IAAI,UACxB,MAAMiI,EAAgB,CAAC,EACvBH,EAAOI,SAAQ,CAAC1H,EAAOb,KACP,UAARA,GAA2B,gBAARA,IACnBsI,EAActI,GAAOa,EACzB,IAEJmH,EAAcM,EAAc,GAC7B,KACH,IAAA7D,YAAU,KACDmD,IAED7D,EACAc,EAAO2D,QAAQ,MAGf,IAAAjF,QAAO,WAAY,CAAEqE,eAAeG,GACxC,GACD,CAAChE,EAAiB6D,EAAaG,IAC9BE,GACO,SAAK,EAAO,CAAC,IAEjB,SAAK,EAAAvD,WAAY,CAAC,EAAE,ED3B3BxB,MAAK,EACLyB,SAAQ,EACRP,aAAY,G","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/compat get default export","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"react/jsx-runtime\"","webpack://snokam/external commonjs \"react\"","webpack://snokam/external commonjs \"next/router\"","webpack://snokam/external commonjs \"next-auth/react\"","webpack://snokam/./src/hooks.ts","webpack://snokam/external commonjs \"@snokam/core\"","webpack://snokam/./src/components/Authenticate.tsx","webpack://snokam/./src/components/Provider/index.tsx","webpack://snokam/external commonjs \"@emotion/styled\"","webpack://snokam/external commonjs \"@snokam/core/layout\"","webpack://snokam/./src/components/Error/styled.tsx","webpack://snokam/external commonjs \"@mui/material/Button\"","webpack://snokam/external commonjs \"@mui/material/Alert\"","webpack://snokam/../../../node_modules/.pnpm/@mui+lab@6.0.0-beta.31_@emotion+react@11.14.0_@types+react@19.0.12_react@19.1.0__@emotion+sty_fz6gji5ey23b355xhyqlbn33ti/node_modules/@mui/lab/Alert/Alert.js","webpack://snokam/external commonjs \"@mui/material\"","webpack://snokam/./src/components/Error/index.tsx","webpack://snokam/./src/components/Unauthenticated.tsx","webpack://snokam/./src/components/Authenticated.tsx","webpack://snokam/external commonjs \"next-auth/middleware\"","webpack://snokam/./src/index.tsx","webpack://snokam/./src/components/Login.tsx"],"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","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\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(\"react/jsx-runtime\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next/router\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/react\");","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { useSession, signIn, signOut } from \"next-auth/react\";\nimport { useMemo } from \"react\";\nexport function useAuth() {\n const { data: session, status, update } = useSession();\n const getToken = (scopes) => __awaiter(this, void 0, void 0, function* () {\n const scope = scopes[0];\n const res = yield fetch(\"/api/auth/token\", {\n method: \"POST\",\n body: JSON.stringify({ scope }),\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n if (!res.ok) {\n throw new Error(\"Token fetch failed\");\n }\n const token = yield res.json();\n const { accessToken } = token;\n return `Bearer ${accessToken}`;\n });\n const value = useMemo(() => ({\n update,\n signIn,\n session,\n getToken: (scopes) => getToken(scopes).catch((error) => {\n console.error(error);\n window.location.href = \"/auth/login?error=true\";\n }),\n inProgress: status === \"loading\",\n isAuthenticated: status === \"authenticated\",\n signOut: (_a) => __awaiter(this, [_a], void 0, function* ({ redirectTo }) {\n return signOut().finally(() => {\n window.location.href = redirectTo;\n });\n }),\n }), [update, getToken, status, session, signIn, signOut]);\n return value;\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@snokam/core\");","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { memo, useEffect } from \"react\";\nimport { signIn } from \"next-auth/react\";\nimport { useAuth } from \"../hooks\";\nimport { PageLoader } from \"@snokam/core\";\nexport const Authenticate = memo((props) => {\n const { children, provider } = props;\n const { inProgress, isAuthenticated } = useAuth();\n useEffect(() => {\n if (!inProgress && !isAuthenticated) {\n signIn(provider);\n }\n }, [inProgress, isAuthenticated]);\n if (!isAuthenticated) {\n return _jsx(PageLoader, {});\n }\n return children;\n});\n","import { jsx as _jsx, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { memo, useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { Authenticate } from \"../Authenticate\";\nimport { SessionProvider } from \"next-auth/react\";\nimport { useAuth } from \"../../hooks\";\nexport const Provider = memo((props) => {\n const { session, children, enforceLogin } = props;\n const router = useRouter();\n const query = router === null || router === void 0 ? void 0 : router.query;\n if ((query === null || query === void 0 ? void 0 : query.enforceLogin) || enforceLogin) {\n return (_jsx(SessionProvider, { session: session, children: _jsx(Authenticate, Object.assign({ provider: \"azure-ad\" }, props, { children: children })) }));\n }\n return (_jsx(SessionProvider, { session: session, children: _jsx(Wrapper, { children: children }) }));\n});\nexport const Wrapper = ({ children }) => {\n var _a;\n const { signOut } = useAuth();\n const router = useRouter();\n useEffect(() => {\n var _a;\n if (((_a = router === null || router === void 0 ? void 0 : router.query) === null || _a === void 0 ? void 0 : _a.logout) === \"true\") {\n signOut({\n redirectTo: \"/auth/login?callbackUrl=/\",\n });\n }\n }, [(_a = router === null || router === void 0 ? void 0 : router.query) === null || _a === void 0 ? void 0 : _a.logout]);\n return _jsx(_Fragment, { children: children });\n};\nexport default Provider;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@emotion/styled\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@snokam/core/layout\");","import styled from \"@emotion/styled\";\nimport Layout from \"@snokam/core/layout\";\nconst Container = styled(Layout.Container) `\n flex: 1;\n justify-content: center;\n`;\nconst Wrapper = styled.div `\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n align-items: center;\n width: 100%;\n max-width: 600px;\n padding: 2rem;\n background-color: var(--color-dark-green);\n border-radius: 1rem;\n box-shadow: 0 4px 10px rgba(0, 0, 0, 0.9);\n`;\nconst Heading = styled.h1 `\n font-size: 2rem;\n font-weight: 600;\n margin: 0;\n`;\nconst Illustration = styled.img `\n width: 200px;\n max-width: 100%;\n height: auto;\n`;\nconst Link = styled.a `\n text-decoration: underline;\n color: inherit;\n`;\nconst Section = styled(Layout.Section) `\n display: flex;\n justify-content: center;\n align-items: center;\n color: var(--color-light-blue);\n`;\nconst Description = styled.div `\n display: flex;\n font-size: 1.15rem;\n text-align: center;\n`;\nconst User = styled.div `\n display: flex;\n align-items: center;\n font-size: 1rem;\n margin-top: 1rem;\n gap: 1rem;\n`;\nexport default {\n Container,\n Wrapper,\n Heading,\n Illustration,\n Description,\n Section,\n Link,\n User,\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material/Button\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material/Alert\");","'use client';\n\nimport * as React from 'react';\nimport Alert from '@mui/material/Alert';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nlet warnedOnce = false;\nconst warn = () => {\n if (!warnedOnce) {\n console.warn(['MUI: The Alert component was moved from the lab to the core.', '', \"You should use `import { Alert } from '@mui/material'`\", \"or `import Alert from '@mui/material/Alert'`\"].join('\\n'));\n warnedOnce = true;\n }\n};\n\n/**\n * @ignore - do not document.\n */\nexport default /*#__PURE__*/React.forwardRef(function DeprecatedAlert(props, ref) {\n warn();\n return /*#__PURE__*/_jsx(Alert, {\n ref: ref,\n ...props\n });\n});","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material\");","import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport Styled from \"./styled\";\nimport { Layout } from \"@snokam/core\";\nimport { TransitionType } from \"@snokam/core/layout\";\nimport { useAuth } from \"../../hooks\";\nimport Button from \"@mui/material/Button\";\nimport { Alert } from \"@mui/lab\";\nimport { Avatar } from \"@mui/material\";\nexport const Error = ({ message }) => {\n const { session, signOut } = useAuth();\n const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === \"preview\";\n return (_jsx(Styled.Container, { transitions: {\n bottom: {\n type: TransitionType.Wave,\n },\n }, children: _jsx(Layout.Content, { children: _jsx(Styled.Section, { children: _jsxs(Styled.Wrapper, { children: [_jsx(Styled.Heading, { children: \"Oops! Noe gikk galt.\" }), _jsx(Styled.Illustration, { src: \"https://ressurser.snokam.no/figures/snowman.svg\", alt: \"Feil illustrasjon\" }), _jsx(Styled.Description, { children: message !== null && message !== void 0 ? message : (_jsxs(_Fragment, { children: [\"En uventet feil har oppst\\u00E5tt.\", _jsx(\"br\", {}), \"Pr\\u00F8v igjen, eller logg inn p\\u00E5 nytt.\"] })) }), session && (_jsxs(Styled.User, { children: [_jsx(Avatar, { src: session.user.image }), \"Logget inn som: \", session.user.name, _jsx(\"br\", {}), \"(\", session.user.email, \")\"] })), isPreview && (_jsxs(Alert, { severity: \"warning\", children: [\"Du er i test! Husk at det kun er mulig \\u00E5 logge inn \", _jsx(\"br\", {}), \"med en av v\\u00E5re testbrukere som du finner i 1Password.\"] })), _jsx(Button, { sx: { mt: 3 }, color: \"secondary\", variant: \"contained\", onClick: () => {\n signOut({\n redirectTo: \"/auth/login?callbackUrl=/&prompt=login\",\n });\n }, children: \"Logg inn p\\u00E5 nytt\" })] }) }) }) }));\n};\nexport default Error;\n","import { useSession } from \"next-auth/react\";\nexport const Unauthenticated = ({ children }) => {\n const { status } = useSession();\n return status === \"unauthenticated\" ? children : null;\n};\n","import { useSession } from \"next-auth/react\";\nexport const Authenticated = ({ children }) => {\n const { status } = useSession();\n return status === \"authenticated\" ? children : null;\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/middleware\");","import { Provider } from \"./components/Provider\";\nimport { Authenticate } from \"./components/Authenticate\";\nimport { Login } from \"./components/Login\";\nimport { Error } from \"./components/Error\";\nexport { Unauthenticated } from \"./components/Unauthenticated\";\nexport { Authenticated } from \"./components/Authenticated\";\nexport { useAuth } from \"./hooks\";\nexport { default as middleware } from \"next-auth/middleware\";\nexport { signIn } from \"next-auth/react\";\nexport default {\n Login,\n Error,\n Provider,\n Authenticate,\n};\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect, useState } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { useAuth } from \"../hooks\";\nimport { signIn } from \"next-auth/react\";\nimport { PageLoader } from \"@snokam/core\";\nimport Error from \"./Error\";\nexport const Login = () => {\n const { isAuthenticated } = useAuth();\n const [callbackUrl, setCallbackUrl] = useState(null);\n const [authParams, setAuthParams] = useState({});\n const [isError, setIsError] = useState(false);\n const router = useRouter();\n useEffect(() => {\n const params = new URLSearchParams(window.location.search);\n setCallbackUrl(params.get(\"callbackUrl\"));\n setIsError(!!params.get(\"error\"));\n const authParamsObj = {};\n params.forEach((value, key) => {\n if (key !== \"error\" && key !== \"callbackUrl\") {\n authParamsObj[key] = value;\n }\n });\n setAuthParams(authParamsObj);\n }, []);\n useEffect(() => {\n if (!callbackUrl)\n return;\n if (isAuthenticated) {\n router.replace(\"/\");\n }\n else {\n signIn(\"azure-ad\", { callbackUrl }, authParams);\n }\n }, [isAuthenticated, callbackUrl, authParams]);\n if (isError) {\n return _jsx(Error, {});\n }\n return _jsx(PageLoader, {});\n};\nexport default Login;\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","step","next","e","rejected","result","done","then","apply","useAuth","data","session","status","update","useSession","getToken","scopes","scope","res","fetch","method","body","JSON","stringify","credentials","headers","ok","Error","token","json","accessToken","useMemo","signIn","catch","error","console","window","location","href","inProgress","isAuthenticated","signOut","_a","redirectTo","finally","Authenticate","memo","props","children","provider","useEffect","PageLoader","Provider","enforceLogin","router","useRouter","query","SessionProvider","assign","Wrapper","logout","Container","Heading","Illustration","Link","Section","Description","User","warnedOnce","ref","warn","join","message","isPreview","process","env","NEXT_PUBLIC_VERCEL_ENV","transitions","bottom","type","TransitionType","Wave","Layout","Content","src","alt","Avatar","user","image","name","email","Alert","severity","sx","mt","color","variant","onClick","Unauthenticated","Authenticated","Login","callbackUrl","setCallbackUrl","useState","authParams","setAuthParams","isError","setIsError","params","URLSearchParams","search","authParamsObj","forEach","replace"],"sourceRoot":""}
|
package/lib/middleware.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{buildAuthMiddleware:()=>i,config:()=>c,default:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{buildAuthMiddleware:()=>i,config:()=>c,default:()=>p});const r=require("path-to-regexp"),o=require("next-auth/middleware");var n=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};const a=["/((?!api|_next/static|_next/image|favicon.ico|.*\\..*).*)"];function i(e={}){var t,{matcher:i=[],callbacks:l={},protectAllRoutes:c}=e,p=n(e,["matcher","callbacks","protectAllRoutes"]);const s="development"===process.env.NEXT_PUBLIC_APP_ENV,u="preview"===process.env.NEXT_PUBLIC_VERCEL_ENV&&!s;return{middleware:(0,o.withAuth)((e=>{}),Object.assign({pages:{signIn:"/auth/login"},callbacks:{authorized:null!==(t=l.authorized)&&void 0!==t?t:({req:e,token:t})=>{return o=e.nextUrl.pathname,!(u||c&&0===(null==i?void 0:i.length)||i.some((e=>{if(!e)return!1;if(e.endsWith(":path*")){const t=e.replace(/\/:path\*$/,"");return o.startsWith(t)}return!1!==(0,r.match)(e,{end:!0})(o)})))||!!t;var o}}},p)),config:u?{matcher:a}:(null==i?void 0:i.length)>0?{matcher:i}:void 0}}const{middleware:l,config:c}=i(),p=l;return t})()));
|
|
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,eAAe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,GAAevC,OAAOwC,OAAO,CAAEC,MAAO,CAC1DC,OAAQ,eACTd,UAAW,CACVe,WAA4C,QAA/BjB,EAAKE,EAAUe,kBAA+B,IAAPjB,EAAgBA,EAAK,EAAIkB,MAAKC,YAC9E,OAnBeC,EAmBUF,EAAIG,QAAQD,WAlBzCX,GAAcN,GAA2F,KAAtEF,aAAyC,EAASA,EAAQN,SAG1FM,EAAQqB,MAAMC,IACjB,IAAKA,EACD,OAAO,EAEX,GAAIA,EAAQC,SAAS,UAAW,CAC5B,MAAMC,EAAOF,EAAQG,QAAQ,aAAc,IAC3C,OAAON,EAASO,WAAWF,EAC/B,CACA,OAAmD,KAA5C,IAAAG,OAAML,EAAS,CAAEM,KAAK,GAAtB,CAA8BT,EAAmB,QAODD,EAnBrC,IAACC,CAoBlB,IACAhB,IAOY0B,OALNrB,EACT,CAAER,QAASJ,IACVI,aAAyC,EAASA,EAAQN,QAAU,EACjE,CAAEM,gBACF8B,EAEd,CAEA,MAAM,WAAEpB,EAAU,OAAEmB,GAAWhC,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"],"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\";\n// Catch-all matcher used in Vercel preview environments\nconst previewMatcher = [\n \"/((?!api|_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 isDev = process.env.NEXT_PUBLIC_APP_ENV === \"development\";\n const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === \"preview\" && !isDev;\n // Decide at runtime whether the current path should be protected\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 if (pattern.endsWith(\":path*\")) {\n const base = pattern.replace(/\\/:path\\*$/, \"\");\n return pathname.startsWith(base);\n }\n return match(pattern, { end: true })(pathname) !== false;\n });\n };\n const middleware = withAuth((_req) => { }, Object.assign({ pages: {\n signIn: \"/auth/login\",\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 // Only apply matcher config if needed (to avoid enabling middleware unnecessarily)\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"],"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","isDev","process","env","NEXT_PUBLIC_APP_ENV","isPreview","NEXT_PUBLIC_VERCEL_ENV","middleware","withAuth","_req","assign","pages","signIn","authorized","req","token","pathname","nextUrl","some","pattern","endsWith","base","replace","startsWith","match","end","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.0-alpha.
|
|
4
|
+
"version": "2.2.0-alpha.22",
|
|
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": "89710a48f7e1ae027a7e7069161f68d745ea005f"
|
|
71
71
|
}
|