@snokam/auth 2.0.6 → 2.0.8
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 +19 -0
- package/lib/config.d.ts +0 -16
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/server.d.ts +8 -1
- package/lib/server.js +1 -1
- package/lib/server.js.map +1 -1
- package/lib/types.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.0.8](https://github.com/snokam/components/compare/@snokam/auth@2.0.7...@snokam/auth@2.0.8) (2024-10-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* send everything as props, not env ([bd3ac04](https://github.com/snokam/components/commit/bd3ac04ddd95747cbee60f315a00206cb3e79f44))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.0.7](https://github.com/snokam/components/compare/@snokam/auth@2.0.6...@snokam/auth@2.0.7) (2024-10-04)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @snokam/auth
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [2.0.6](https://github.com/snokam/components/compare/@snokam/auth@2.0.5-alpha.0...@snokam/auth@2.0.6) (2024-10-02)
|
|
7
26
|
|
|
8
27
|
|
package/lib/config.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
export declare const config: {
|
|
2
|
-
auth: {
|
|
3
|
-
clientId: string;
|
|
4
|
-
authority: string;
|
|
5
|
-
postLogoutRedirectUri: string;
|
|
6
|
-
redirectUri: string;
|
|
7
|
-
navigateToLoginRequestUrl: boolean;
|
|
8
|
-
};
|
|
9
|
-
system: {
|
|
10
|
-
allowRedirectInIframe: boolean;
|
|
11
|
-
};
|
|
12
|
-
cache: {
|
|
13
|
-
storeAuthStateInCookie: boolean;
|
|
14
|
-
cacheLocation: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
1
|
export declare const loginRequest: {
|
|
18
2
|
scopes: string[];
|
|
19
3
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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,{Authenticated:()=>r.AuthenticatedTemplate,Unauthenticated:()=>r.UnauthenticatedTemplate,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={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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,{Authenticated:()=>r.AuthenticatedTemplate,Unauthenticated:()=>r.UnauthenticatedTemplate,default:()=>y,useAuth:()=>d});const n=require("react/jsx-runtime"),r=require("@azure/msal-react"),o=require("@azure/msal-browser"),i=require("next/router"),s=require("react"),c="redirect",a=()=>{window.sessionStorage.setItem(c,window.location.pathname)},l=require("@snokam/core"),u=require("@mui/material"),d=()=>{const{instance:e,inProgress:t}=(0,r.useMsal)(),n=e.getAllAccounts()[0];return{getToken:t=>e.acquireTokenSilent({scopes:t||[],account:n}).then((({accessToken:e})=>`Bearer ${e}`)),isAuthenticated:(0,r.useIsAuthenticated)(),inProgress:"startup"===t||"login"===t,instance:e,account:n}},g={scopes:["openid"]},p=require("@emotion/styled");var m=e.n(p);const h={Container:m().div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
align-items: center;
|
|
6
6
|
flex: 1;
|
|
7
|
-
`,Link:
|
|
7
|
+
`,Link:m().a`
|
|
8
8
|
text-decoration: "underline";
|
|
9
|
-
`},
|
|
9
|
+
`},f=()=>{const{instance:e}=(0,r.useMsal)(),{account:t}=d(),[o,i]=(0,s.useState)();return o?(0,n.jsxs)(h.Container,{children:[(0,n.jsxs)("p",{children:["En feil oppstod: ",o.errorCode]}),(0,n.jsxs)("span",{children:["Prøv å gå direkte til ",(0,n.jsx)(h.Link,{target:"_blank",href:"https://skjer.snokam.no/?enforceLogin=true",rel:"noopener noreferrer",children:"skjer.snokam.no"}),"."]})]}):(0,n.jsxs)(h.Container,{children:["Du må logge inn på nytt for å vise siden",(0,n.jsx)(u.Button,{sx:{marginTop:"1rem"},onClick:()=>{a(),e.loginPopup(Object.assign(Object.assign(Object.assign({},g),t&&{account:t}),{redirectUri:"/blank.html"})).then((()=>i(void 0))).catch((e=>i(e)))},children:"Fortsett"})]})},j=e=>{const{children:t}=e,{query:s}=(0,i.useRouter)(),c=s.username,u=(null==s?void 0:s.enforceLogin)&&(null==s?void 0:s.username)?o.InteractionType.Silent:o.InteractionType.Redirect,d=Object.assign(Object.assign(Object.assign({},g),c&&{loginHint:c}),{onRedirectNavigate:e=>{a()}});return(0,n.jsx)(r.MsalAuthenticationTemplate,{interactionType:u,authenticationRequest:d,errorComponent:f,loadingComponent:()=>(0,n.jsx)(l.PageLoader,{color:"inherit"}),children:t})},b=e=>{const{children:t,enforceLogin:c}=e,{query:a}=(0,i.useRouter)(),l=(0,s.useRef)(null);if(!l.current){const t={auth:{clientId:e.config.clientId,authority:`https://login.microsoftonline.com/${e.config.tenantId}/`,postLogoutRedirectUri:"/",redirectUri:"/callback",navigateToLoginRequestUrl:!1},system:{allowRedirectInIframe:!0},cache:{storeAuthStateInCookie:!0,cacheLocation:"localStorage"}};l.current=new o.PublicClientApplication(t)}const u=l.current;return a.enforceLogin||c?(0,n.jsx)(r.MsalProvider,{instance:u,children:(0,n.jsx)(j,Object.assign({},e,{children:t}))}):(0,n.jsx)(r.MsalProvider,{instance:u,children:t})};b.Callback=()=>{const e=(0,i.useRouter)();return(0,s.useEffect)((()=>{const t=window.sessionStorage.getItem(c);t?(window.sessionStorage.removeItem(c),console.log(`Redirecting to ${t} ...`),e.replace(t)):e.replace("/")}),[e]),(0,n.jsx)(l.PageLoader,{color:"inherit"})};const y={Provider:b,Authenticate:j};return t})()));
|
|
10
10
|
//# 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,I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M,eAAgBlC,EAAYmC,iBAH7H,KACL,SAAK,EAAAC,WAAY,CAAEC,MAAO,YAEmIjC,SAAUA,GAAY,EChB5LkC,EAAe,IAAI,EAAAC,wBAAwB9E,GACjD6E,EAAaE,aACN,MAAMC,EAAYtB,IACrB,MAAM,SAAEf,EAAQ,aAAEoB,GAAiBL,GAC7B,MAAEC,IAAU,IAAAC,aAClB,IAAKzD,QAAQC,IAAIC,+BACb,MAAM,IAAI4E,MAAM,2EAEpB,IAAK9E,QAAQC,IAAIG,+BACb,MAAM,IAAI0E,MAAM,2EAEpB,OAAItB,EAAMI,cAAgBA,GACd,SAAK,EAAAmB,aAAc,CAAExD,SAAUmD,EAAclC,UAAU,SAAKc,EAActE,OAAOkE,OAAO,CAAC,EAAGK,EAAO,CAAEf,SAAUA,QAEpH,SAAK,EAAAuC,aAAc,CAAExD,SAAUmD,EAAclC,SAAUA,GAAW,EAE7EqC,EAASG,SClBe,KACpB,MAAMC,GAAS,IAAAxB,aAYf,OAXA,IAAAyB,YAAU,KACN,MAAMC,EVHHlE,OAAOC,eAAekE,QAAQrE,GUI7BoE,GVDRlE,OAAOC,eAAemE,WAAWtE,GUGzBuE,QAAQC,IAAI,kBAAkBJ,SAC9BF,EAAOO,QAAQL,IAGfF,EAAOO,QAAQ,IACnB,GACD,CAACP,KACG,SAAK,EAAAT,WAAY,CAAEC,MAAO,WAAY,EDMjD,MEpBA,GAAiBI,SAAQ,eAAc,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 \"@azure/msal-react\"","webpack://snokam/external commonjs \"@azure/msal-browser\"","webpack://snokam/external commonjs \"next/router\"","webpack://snokam/./src/config.ts","webpack://snokam/./src/storage.ts","webpack://snokam/external commonjs \"@snokam/core\"","webpack://snokam/external commonjs \"@mui/material\"","webpack://snokam/external commonjs \"react\"","webpack://snokam/./src/hooks.ts","webpack://snokam/external commonjs \"@emotion/styled\"","webpack://snokam/./src/components/Provider/styled.tsx","webpack://snokam/./src/components/Provider/Provider.PopupLogin.tsx","webpack://snokam/./src/components/Provider/Provider.Authenticate.tsx","webpack://snokam/./src/components/Provider/index.tsx","webpack://snokam/./src/components/Provider/Provider.Callback.tsx","webpack://snokam/./src/index.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(\"@azure/msal-react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@azure/msal-browser\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next/router\");","export const config = {\n auth: {\n clientId: `${process.env.NEXT_PUBLIC_AZURE_AD_CLIENT_ID}`,\n authority: `https://login.microsoftonline.com/${process.env.NEXT_PUBLIC_AZURE_AD_TENANT_ID}/`,\n postLogoutRedirectUri: \"/\",\n redirectUri: `/callback`,\n navigateToLoginRequestUrl: false,\n },\n system: {\n allowRedirectInIframe: true,\n },\n cache: {\n storeAuthStateInCookie: true,\n cacheLocation: \"localStorage\",\n },\n};\nexport const loginRequest = {\n scopes: [\"openid\"],\n};\n","const SessionStorageKey = \"redirect\";\nexport const storeCurrentPath = () => {\n window.sessionStorage.setItem(SessionStorageKey, window.location.pathname);\n};\nexport const getStoredPath = () => {\n return window.sessionStorage.getItem(SessionStorageKey);\n};\nexport const clearStoredPath = () => {\n window.sessionStorage.removeItem(SessionStorageKey);\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@snokam/core\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","import { useIsAuthenticated, useMsal } from \"@azure/msal-react\";\nexport const useAuth = () => {\n const { instance, inProgress } = useMsal();\n const account = instance.getAllAccounts()[0];\n const isAuthenticated = useIsAuthenticated();\n const getToken = (scopes) => instance\n .acquireTokenSilent({\n scopes: scopes || [],\n account: account,\n })\n .then(({ accessToken }) => `Bearer ${accessToken}`);\n return {\n getToken,\n isAuthenticated,\n inProgress: inProgress === \"startup\" || inProgress === \"login\",\n instance,\n account,\n };\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@emotion/styled\");","import styled from \"@emotion/styled\";\nconst Container = styled.div `\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n flex: 1;\n`;\nconst Link = styled.a `\n text-decoration: \"underline\";\n`;\nexport default { Container, Link };\n","import { jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nimport { useMsal } from \"@azure/msal-react\";\nimport { Button } from \"@mui/material\";\nimport { storeCurrentPath } from \"../../storage\";\nimport { useState } from \"react\";\nimport { useAuth } from \"../../hooks\";\nimport { loginRequest } from \"../../config\";\nimport Styled from \"./styled\";\nexport const PopupLogin = () => {\n const { instance } = useMsal();\n const { account } = useAuth();\n const [popupError, setPopupError] = useState();\n if (popupError) {\n return (_jsxs(Styled.Container, { children: [_jsxs(\"p\", { children: [\"En feil oppstod: \", popupError.errorCode] }), _jsxs(\"span\", { children: [`Prøv å gå direkte til `, _jsx(Styled.Link, { target: \"_blank\", href: \"https://skjer.snokam.no/?enforceLogin=true\", rel: \"noopener noreferrer\", children: \"skjer.snokam.no\" }), \".\"] })] }));\n }\n return (_jsxs(Styled.Container, { children: [\"Du m\\u00E5 logge inn p\\u00E5 nytt for \\u00E5 vise siden\", _jsx(Button, { sx: { marginTop: \"1rem\" }, onClick: () => {\n storeCurrentPath();\n instance\n .loginPopup(Object.assign(Object.assign(Object.assign({}, loginRequest), (account && {\n account,\n })), { redirectUri: \"/blank.html\" }))\n .then(() => setPopupError(undefined))\n .catch((error) => setPopupError(error));\n }, children: \"Fortsett\" })] }));\n};\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { MsalAuthenticationTemplate } from \"@azure/msal-react\";\nimport { InteractionType } from \"@azure/msal-browser\";\nimport { storeCurrentPath } from \"../../storage\";\nimport { useRouter } from \"next/router\";\nimport { PageLoader } from \"@snokam/core\";\nimport { loginRequest } from \"../../config\";\nimport { PopupLogin } from \"./Provider.PopupLogin\";\nexport const Authenticate = (props) => {\n const { children } = props;\n const { query } = useRouter();\n const username = query.username;\n const interactionType = (query === null || query === void 0 ? void 0 : query.enforceLogin) && (query === null || query === void 0 ? void 0 : query.username)\n ? InteractionType.Silent\n : InteractionType.Redirect;\n const authRequest = Object.assign(Object.assign(Object.assign({}, loginRequest), (username && {\n loginHint: username,\n })), { onRedirectNavigate: (_) => {\n storeCurrentPath();\n } });\n const Loading = () => {\n return _jsx(PageLoader, { color: \"inherit\" });\n };\n return (_jsx(MsalAuthenticationTemplate, { interactionType: interactionType, authenticationRequest: authRequest, errorComponent: PopupLogin, loadingComponent: Loading, children: children }));\n};\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { MsalProvider } from \"@azure/msal-react\";\nimport { PublicClientApplication } from \"@azure/msal-browser\";\nimport { useRouter } from \"next/router\";\nimport { config } from \"../../config\";\nimport { Authenticate } from \"./Provider.Authenticate\";\nimport Callback from \"./Provider.Callback\";\nconst msalInstance = new PublicClientApplication(config);\nmsalInstance.initialize();\nexport const Provider = (props) => {\n const { children, enforceLogin } = props;\n const { query } = useRouter();\n if (!process.env.NEXT_PUBLIC_AZURE_AD_CLIENT_ID) {\n throw new Error(\"NEXT_PUBLIC_AZURE_AD_CLIENT_ID must be set in the environment variables\");\n }\n if (!process.env.NEXT_PUBLIC_AZURE_AD_TENANT_ID) {\n throw new Error(\"NEXT_PUBLIC_AZURE_AD_TENANT_ID must be set in the environment variables\");\n }\n if (query.enforceLogin || enforceLogin) {\n return (_jsx(MsalProvider, { instance: msalInstance, children: _jsx(Authenticate, Object.assign({}, props, { children: children })) }));\n }\n return _jsx(MsalProvider, { instance: msalInstance, children: children });\n};\nProvider.Callback = Callback;\nexport default Provider;\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { clearStoredPath, getStoredPath } from \"../../storage\";\nimport { PageLoader } from \"@snokam/core\";\nexport const Callback = () => {\n const router = useRouter();\n useEffect(() => {\n const redirectUrl = getStoredPath();\n if (redirectUrl) {\n clearStoredPath();\n console.log(`Redirecting to ${redirectUrl} ...`);\n router.replace(redirectUrl);\n }\n else {\n router.replace(\"/\");\n }\n }, [router]);\n return _jsx(PageLoader, { color: \"inherit\" });\n};\nexport default Callback;\n","import { Provider } from \"./components/Provider\";\nimport { Authenticate } from \"./components/Provider/Provider.Authenticate\";\nexport { useAuth } from \"./hooks\";\nexport { AuthenticatedTemplate as Authenticated, UnauthenticatedTemplate as Unauthenticated, } from \"@azure/msal-react\";\nexport default { Provider, Authenticate };\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","config","auth","clientId","process","env","NEXT_PUBLIC_AZURE_AD_CLIENT_ID","authority","NEXT_PUBLIC_AZURE_AD_TENANT_ID","postLogoutRedirectUri","redirectUri","navigateToLoginRequestUrl","system","allowRedirectInIframe","cache","storeAuthStateInCookie","cacheLocation","loginRequest","scopes","SessionStorageKey","storeCurrentPath","window","sessionStorage","setItem","location","pathname","useAuth","instance","inProgress","useMsal","account","getAllAccounts","getToken","acquireTokenSilent","then","accessToken","isAuthenticated","useIsAuthenticated","Container","Link","PopupLogin","popupError","setPopupError","useState","children","errorCode","target","href","rel","Button","sx","marginTop","onClick","loginPopup","assign","undefined","catch","error","Authenticate","props","query","useRouter","username","interactionType","enforceLogin","InteractionType","Silent","Redirect","authRequest","loginHint","onRedirectNavigate","_","MsalAuthenticationTemplate","authenticationRequest","errorComponent","loadingComponent","PageLoader","color","msalInstance","PublicClientApplication","initialize","Provider","Error","MsalProvider","Callback","router","useEffect","redirectUrl","getItem","removeItem","console","log","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,EAAoBG,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,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SAAUzB,EAAMuB,OAAOE,SACvBC,UAAW,qCAAqC1B,EAAMuB,OAAOI,YAC7DC,sBAAuB,IACvBjC,YAAa,YACbkC,2BAA2B,GAE/BC,OAAQ,CACJC,uBAAuB,GAE3BC,MAAO,CACHC,wBAAwB,EACxBC,cAAe,iBAGvBd,EAAgBE,QAAU,IAAI,EAAAa,wBAAwBZ,EAC1D,CACA,MAAMa,EAAehB,EAAgBE,QACrC,OAAIrB,EAAMI,cAAgBA,GACd,SAAK,EAAAgC,aAAc,CAAExE,SAAUuE,EAAcpD,UAAU,SAAKe,EAAcvD,OAAOkD,OAAO,CAAC,EAAGM,EAAO,CAAEhB,SAAUA,QAEpH,SAAK,EAAAqD,aAAc,CAAExE,SAAUuE,EAAcpD,SAAUA,GAAW,EAE7EmC,EAASmB,SChCe,KACpB,MAAMC,GAAS,IAAArC,aAYf,OAXA,IAAAsC,YAAU,KACN,MAAMC,EVHHlF,OAAOC,eAAekF,QAAQrF,GUI7BoF,GVDRlF,OAAOC,eAAemF,WAAWtF,GUGzBuF,QAAQC,IAAI,kBAAkBJ,SAC9BF,EAAOO,QAAQL,IAGfF,EAAOO,QAAQ,IACnB,GACD,CAACP,KACG,SAAK,EAAAtB,WAAY,CAAEC,MAAO,WAAY,EDoBjD,MElCA,GAAiBC,SAAQ,eAAc,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 \"@azure/msal-react\"","webpack://snokam/external commonjs \"@azure/msal-browser\"","webpack://snokam/external commonjs \"next/router\"","webpack://snokam/external commonjs \"react\"","webpack://snokam/./src/storage.ts","webpack://snokam/external commonjs \"@snokam/core\"","webpack://snokam/external commonjs \"@mui/material\"","webpack://snokam/./src/hooks.ts","webpack://snokam/./src/config.ts","webpack://snokam/external commonjs \"@emotion/styled\"","webpack://snokam/./src/components/Provider/styled.tsx","webpack://snokam/./src/components/Provider/Provider.PopupLogin.tsx","webpack://snokam/./src/components/Provider/Provider.Authenticate.tsx","webpack://snokam/./src/components/Provider/index.tsx","webpack://snokam/./src/components/Provider/Provider.Callback.tsx","webpack://snokam/./src/index.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(\"@azure/msal-react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@azure/msal-browser\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next/router\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const SessionStorageKey = \"redirect\";\nexport const storeCurrentPath = () => {\n window.sessionStorage.setItem(SessionStorageKey, window.location.pathname);\n};\nexport const getStoredPath = () => {\n return window.sessionStorage.getItem(SessionStorageKey);\n};\nexport const clearStoredPath = () => {\n window.sessionStorage.removeItem(SessionStorageKey);\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@snokam/core\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material\");","import { useIsAuthenticated, useMsal } from \"@azure/msal-react\";\nexport const useAuth = () => {\n const { instance, inProgress } = useMsal();\n const account = instance.getAllAccounts()[0];\n const isAuthenticated = useIsAuthenticated();\n const getToken = (scopes) => instance\n .acquireTokenSilent({\n scopes: scopes || [],\n account: account,\n })\n .then(({ accessToken }) => `Bearer ${accessToken}`);\n return {\n getToken,\n isAuthenticated,\n inProgress: inProgress === \"startup\" || inProgress === \"login\",\n instance,\n account,\n };\n};\n","export const loginRequest = {\n scopes: [\"openid\"],\n};\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@emotion/styled\");","import styled from \"@emotion/styled\";\nconst Container = styled.div `\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n flex: 1;\n`;\nconst Link = styled.a `\n text-decoration: \"underline\";\n`;\nexport default { Container, Link };\n","import { jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nimport { useMsal } from \"@azure/msal-react\";\nimport { Button } from \"@mui/material\";\nimport { storeCurrentPath } from \"../../storage\";\nimport { useState } from \"react\";\nimport { useAuth } from \"../../hooks\";\nimport { loginRequest } from \"../../config\";\nimport Styled from \"./styled\";\nexport const PopupLogin = () => {\n const { instance } = useMsal();\n const { account } = useAuth();\n const [popupError, setPopupError] = useState();\n if (popupError) {\n return (_jsxs(Styled.Container, { children: [_jsxs(\"p\", { children: [\"En feil oppstod: \", popupError.errorCode] }), _jsxs(\"span\", { children: [`Prøv å gå direkte til `, _jsx(Styled.Link, { target: \"_blank\", href: \"https://skjer.snokam.no/?enforceLogin=true\", rel: \"noopener noreferrer\", children: \"skjer.snokam.no\" }), \".\"] })] }));\n }\n return (_jsxs(Styled.Container, { children: [\"Du m\\u00E5 logge inn p\\u00E5 nytt for \\u00E5 vise siden\", _jsx(Button, { sx: { marginTop: \"1rem\" }, onClick: () => {\n storeCurrentPath();\n instance\n .loginPopup(Object.assign(Object.assign(Object.assign({}, loginRequest), (account && {\n account,\n })), { redirectUri: \"/blank.html\" }))\n .then(() => setPopupError(undefined))\n .catch((error) => setPopupError(error));\n }, children: \"Fortsett\" })] }));\n};\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { MsalAuthenticationTemplate } from \"@azure/msal-react\";\nimport { InteractionType } from \"@azure/msal-browser\";\nimport { storeCurrentPath } from \"../../storage\";\nimport { useRouter } from \"next/router\";\nimport { PageLoader } from \"@snokam/core\";\nimport { PopupLogin } from \"./Provider.PopupLogin\";\nimport { loginRequest } from \"../../config\";\nexport const Authenticate = (props) => {\n const { children } = props;\n const { query } = useRouter();\n const username = query.username;\n const interactionType = (query === null || query === void 0 ? void 0 : query.enforceLogin) && (query === null || query === void 0 ? void 0 : query.username)\n ? InteractionType.Silent\n : InteractionType.Redirect;\n const authRequest = Object.assign(Object.assign(Object.assign({}, loginRequest), (username && {\n loginHint: username,\n })), { onRedirectNavigate: (_) => {\n storeCurrentPath();\n } });\n const Loading = () => {\n return _jsx(PageLoader, { color: \"inherit\" });\n };\n return (_jsx(MsalAuthenticationTemplate, { interactionType: interactionType, authenticationRequest: authRequest, errorComponent: PopupLogin, loadingComponent: Loading, children: children }));\n};\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { MsalProvider } from \"@azure/msal-react\";\nimport { PublicClientApplication } from \"@azure/msal-browser\";\nimport { useRouter } from \"next/router\";\nimport { useRef } from \"react\";\nimport { Authenticate } from \"./Provider.Authenticate\";\nimport Callback from \"./Provider.Callback\";\nexport const Provider = (props) => {\n const { children, enforceLogin } = props;\n const { query } = useRouter();\n // Store msalInstance in a ref to ensure it initializes only once\n const msalInstanceRef = useRef(null);\n if (!msalInstanceRef.current) {\n const config = {\n auth: {\n clientId: props.config.clientId,\n authority: `https://login.microsoftonline.com/${props.config.tenantId}/`,\n postLogoutRedirectUri: \"/\",\n redirectUri: `/callback`,\n navigateToLoginRequestUrl: false,\n },\n system: {\n allowRedirectInIframe: true,\n },\n cache: {\n storeAuthStateInCookie: true,\n cacheLocation: \"localStorage\",\n },\n };\n msalInstanceRef.current = new PublicClientApplication(config);\n }\n const msalInstance = msalInstanceRef.current;\n if (query.enforceLogin || enforceLogin) {\n return (_jsx(MsalProvider, { instance: msalInstance, children: _jsx(Authenticate, Object.assign({}, props, { children: children })) }));\n }\n return _jsx(MsalProvider, { instance: msalInstance, children: children });\n};\nProvider.Callback = Callback;\nexport default Provider;\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { clearStoredPath, getStoredPath } from \"../../storage\";\nimport { PageLoader } from \"@snokam/core\";\nexport const Callback = () => {\n const router = useRouter();\n useEffect(() => {\n const redirectUrl = getStoredPath();\n if (redirectUrl) {\n clearStoredPath();\n console.log(`Redirecting to ${redirectUrl} ...`);\n router.replace(redirectUrl);\n }\n else {\n router.replace(\"/\");\n }\n }, [router]);\n return _jsx(PageLoader, { color: \"inherit\" });\n};\nexport default Callback;\n","import { Provider } from \"./components/Provider\";\nimport { Authenticate } from \"./components/Provider/Provider.Authenticate\";\nexport { useAuth } from \"./hooks\";\nexport { AuthenticatedTemplate as Authenticated, UnauthenticatedTemplate as Unauthenticated, } from \"@azure/msal-react\";\nexport default { Provider, Authenticate };\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","SessionStorageKey","storeCurrentPath","window","sessionStorage","setItem","location","pathname","useAuth","instance","inProgress","useMsal","account","getAllAccounts","getToken","scopes","acquireTokenSilent","then","accessToken","isAuthenticated","useIsAuthenticated","loginRequest","Container","Link","PopupLogin","popupError","setPopupError","useState","children","errorCode","target","href","rel","Button","sx","marginTop","onClick","loginPopup","assign","redirectUri","undefined","catch","error","Authenticate","props","query","useRouter","username","interactionType","enforceLogin","InteractionType","Silent","Redirect","authRequest","loginHint","onRedirectNavigate","_","MsalAuthenticationTemplate","authenticationRequest","errorComponent","loadingComponent","PageLoader","color","Provider","msalInstanceRef","useRef","current","config","auth","clientId","authority","tenantId","postLogoutRedirectUri","navigateToLoginRequestUrl","system","allowRedirectInIframe","cache","storeAuthStateInCookie","cacheLocation","PublicClientApplication","msalInstance","MsalProvider","Callback","router","useEffect","redirectUrl","getItem","removeItem","console","log","replace"],"sourceRoot":""}
|
package/lib/server.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
interface Config {
|
|
2
|
+
scopes: string[];
|
|
3
|
+
tenantId: string;
|
|
4
|
+
clientId: string;
|
|
5
|
+
secret: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getServerToken: (props: Config) => Promise<string>;
|
|
8
|
+
export {};
|
package/lib/server.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,
|
|
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,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},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,{getServerToken:()=>n});const o=require("@azure/msal-node");const n=e=>{return t=void 0,n=void 0,i=function*(){const{scopes:t}=e,n={auth:{clientId:`${e.clientId}`,authority:`https://login.microsoftonline.com/${e.tenantId}/oauth2/v2.0`,clientSecret:`${e.secret}`}},r=new o.ConfidentialClientApplication(n),i=yield r.acquireTokenByClientCredential({scopes:t.map((e=>e.replace("user_impersonation",".default")))});return`Bearer ${null==i?void 0:i.accessToken}`},new((r=void 0)||(r=Promise))((function(e,o){function c(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r((function(e){e(o)}))).then(c,a)}l((i=i.apply(t,n||[])).next())}));var t,n,r,i};return t})()));
|
|
2
2
|
//# sourceMappingURL=server.js.map
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.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,CAAE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EC,OAUR,KAR7CA,EAAIC,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAU5B,GAAS,IAAM6B,EAAKtB,EAAUuB,KAAK9B,GAAS,CAAE,MAAO+B,GAAKJ,EAAOI,EAAI,CAAE,CAC1F,SAASC,EAAShC,GAAS,IAAM6B,EAAKtB,EAAiB,MAAEP,GAAS,CAAE,MAAO+B,GAAKJ,EAAOI,EAAI,CAAE,CAC7F,SAASF,EAAKI,GAJlB,IAAejC,EAIaiC,EAAOC,KAAOR,EAAQO,EAAOjC,QAJ1CA,EAIyDiC,EAAOjC,MAJhDA,aAAiBwB,EAAIxB,EAAQ,IAAIwB,GAAE,SAAUE,GAAWA,EAAQ1B,EAAQ,KAIjBmC,KAAKP,EAAWI,EAAW,CAC7GH,GAAMtB,EAAYA,EAAU6B,MAAM/B,EAASC,GAAc,KAAKwB,OAClE,IAPwC,IAAUzB,EAASC,EAAYkB,EAAGjB,CAwB5E,E","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 \"@azure/msal-node\"","webpack://snokam/./src/server.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(\"@azure/msal-node\");","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 { ConfidentialClientApplication } from \"@azure/msal-node\";\nexport const getServerToken = (props) => __awaiter(void 0, void 0, void 0, function* () {\n const { scopes } = props;\n const config = {\n auth: {\n clientId: `${props.clientId}`,\n authority: `https://login.microsoftonline.com/${props.tenantId}/oauth2/v2.0`,\n clientSecret: `${props.secret}`,\n },\n };\n const cca = new ConfidentialClientApplication(config);\n const response = yield cca.acquireTokenByClientCredential({\n scopes: scopes.map((scope) => scope.replace(\"user_impersonation\", \".default\")),\n });\n return `Bearer ${response === null || response === void 0 ? void 0 : response.accessToken}`;\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","getServerToken","props","__awaiter","thisArg","_arguments","generator","scopes","config","auth","clientId","authority","tenantId","clientSecret","secret","cca","ConfidentialClientApplication","response","acquireTokenByClientCredential","map","scope","replace","accessToken","P","Promise","resolve","reject","fulfilled","step","next","e","rejected","result","done","then","apply"],"sourceRoot":""}
|
package/lib/types.d.ts
CHANGED
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.0.
|
|
4
|
+
"version": "2.0.8",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
]
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2fbaef82d6e5a98c0af5f55f0642a972af6d788d"
|
|
61
61
|
}
|