{"version":3,"sources":["webpack:///../node_modules/@ux/auth/dist/es/InfoProvider-0d45f21b.js","webpack:///../node_modules/@ux/auth/dist/es/di-88d740db.js"],"names":["basicToCustomer","idp","info_shopperId","username","kind","CUSTOMER","shopperId","convertIdpToUser","del","info_accountName","firstname","lastname","e2s","DELEGATE","firstName","lastName","customer","e2sToDelegate","Error","di","jpex","constant","factory","location","root","hostname","concat","getHostname","window","getAppName","args","host","app","encodeURIComponent","path","level","getLevelupPath","getLoginPath","getLogoutPath","children","ref","current","commonDi","getCookieDomain$1","COOKIE_DOMAIN","e","getCookieDomain","APP_NAME","pathname","search","hash","getPathname","cookieKeys","cookies","cookieKey","Promise","res","rej","cookie","get","JSON","parse","fetchInfo","domain","forEach","key","erase","clearAuth","fetch","convert","async","fetchAuth","url","href","redirectToLogin","redirectToLogout","redirect","logout"],"mappings":"8EAAA,mIAqBA,MAAMA,EAAkBC,IACtB,MAAM,eACJC,EAAc,SACdC,GACEF,EACJ,MAAO,CACLG,KAAM,IAAKC,SACXC,UAAWJ,EACXC,aAsBEI,EAAmBN,IACvB,GAAI,YAAYA,GACd,OAAOD,EAAgBC,GAGzB,GAAI,YAAUA,GACZ,MAxBkBA,KACpB,MACEO,KAAK,iBACHC,EAAgB,UAChBC,EAAS,SACTC,GACD,IACDC,GACEX,EACJ,MAAO,CACLG,KAAM,IAAKS,SACXV,SAAUM,EACVK,UAAWJ,EACXK,SAAUJ,EACVK,SAAUhB,EAAgBY,KAUnBK,CAAchB,GAGvB,MAAM,IAAIiB,MAAM,sBAmClB,IAAIC,EAAMC,IACR,YAASA,GACTA,EAAKC,SAAS,2BAA4B,CAAC,WAAY,aACvDD,EAAKE,QAAQ,4BAA6B,GAAI,IAV5BC,IAAY,KAC9B,MAAMC,EAAO,YAAcD,EAASE,UAEpC,MADa,eAAeC,OAAOF,IAQiBG,CAAYC,OAAOL,WACvEH,EAAKC,SAAS,kCAAmCd,GACjDa,EAAKE,QAAQ,+BAAgC,CAAC,2BAA4B,6B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MsC,EAAMlC,EAAc,CACxBJ,KAAMiB,EAAYjB,KAEpBX,EAASkD,KAAOD,GAwB6HG,CAAiB/C,OAAOL,SAAUe,EAAea,IAC9L/B,EAAKE,QAAQ,uBAAwB,CAAC,0BAA2B,kCAAmC,CAAC6C,EAAWS,IA7CnG,EAACT,EAAWS,IAAa9C,IACtCqC,IACAS,EAAS9C,IA2CoH+C,CAAOV,EAAWS","file":"pex-static/40/80.177dc56919782c76267d.chunk.js","sourcesContent":["import '@ux/hooks';\nimport '@ux/promise';\nimport { resolve } from 'url';\nimport { useJpex } from 'react-jpex';\nimport { useRef } from 'react';\nimport 'react-query';\nimport { isBasicInfo, Kind, isE2sInfo, getRootDomain, useAuth } from './auth.js';\nimport 'jpex';\nimport 'react-with-suspense-lazy';\nimport '@team-griffin/rehook';\nimport '@ux/pure-enhance';\nimport '@ux/penders';\nimport '@ux/theme-utils';\nimport '@team-griffin/css-sides';\nimport '@ux/type-size';\nimport '@team-griffin/stylr';\nimport 'browser-cookies';\nimport { c as commonDi } from './di-88d740db.js';\n\n/* eslint-disable camelcase */\n\nconst basicToCustomer = idp => {\n const {\n info_shopperId,\n username\n } = idp;\n return {\n kind: Kind.CUSTOMER,\n shopperId: info_shopperId,\n username\n };\n};\n\nconst e2sToDelegate = idp => {\n const {\n del: {\n info_accountName,\n firstname,\n lastname\n },\n e2s\n } = idp;\n return {\n kind: Kind.DELEGATE,\n username: info_accountName,\n firstName: firstname,\n lastName: lastname,\n customer: basicToCustomer(e2s)\n };\n};\n\nconst convertIdpToUser = idp => {\n if (isBasicInfo(idp)) {\n return basicToCustomer(idp);\n }\n\n if (isE2sInfo(idp)) {\n return e2sToDelegate(idp);\n }\n\n throw new Error('Unknown auth type');\n};\n\nconst getLevelupPath = (getAppName, getHostname) => args => {\n const realm = 'idp';\n const host = getHostname();\n const app = encodeURIComponent(getAppName());\n const path = encodeURIComponent(args.path);\n const level = encodeURIComponent(args.level);\n return \"\".concat(host, \"/identity-verification?app=\").concat(app, \"&path=\").concat(path, \"&realm=\").concat(realm, \"&hbi=\").concat(level);\n};\n\nconst getLoginPath = (getAppName, getHostname) => args => {\n const realm = 'idp';\n const host = getHostname();\n const app = encodeURIComponent(getAppName());\n const path = encodeURIComponent(args.path);\n return \"\".concat(host, \"?app=\").concat(app, \"&path=\").concat(path, \"&realm=\").concat(realm);\n};\n\nconst getLogoutPath = (getAppName, getHostname) => args => {\n const realm = 'idp';\n const host = getHostname();\n const app = encodeURIComponent(getAppName());\n const path = encodeURIComponent(args.path);\n return resolve(host, \"/logout?app=\".concat(app, \"&path=\").concat(path, \"&realm=\").concat(realm));\n};\n\nconst getHostname = location => () => {\n const root = getRootDomain(location.hostname);\n const host = \"https://sso.\".concat(root);\n return host;\n};\n\n/* eslint-disable max-len */\nvar di = (jpex => {\n commonDi(jpex);\n jpex.constant(\"type:@ux/auth/CookieKeys\", ['info_idp', 'auth_idp']);\n jpex.factory(\"type:@ux/auth/GetHostname\", [], () => getHostname(window.location));\n jpex.constant(\"type:@ux/auth/ConvertInfoToUser\", convertIdpToUser);\n jpex.factory(\"type:@ux/auth/GetLevelupPath\", [\"type:@ux/auth/GetAppName\", \"type:@ux/auth/GetHostname\"], (getAppName, getHostname) => getLevelupPath(getAppName, getHostname));\n jpex.factory(\"type:@ux/auth/GetLoginPath\", [\"type:@ux/auth/GetAppName\", \"type:@ux/auth/GetHostname\"], (getAppName, getHostname) => getLoginPath(getAppName, getHostname));\n jpex.factory(\"type:@ux/auth/GetLogoutPath\", [\"type:@ux/auth/GetAppName\", \"type:@ux/auth/GetHostname\"], (getAppName, getHostname) => getLogoutPath(getAppName, getHostname));\n});\n\nconst IdpProvider = ({\n children\n}) => {\n const jpex = useJpex(); // we want to only do this once, but we want to do it _before_ the `useEffect` step\n\n const ref = useRef(false);\n\n if (!ref.current) {\n di(jpex);\n ref.current = true;\n } // fetch the auth tokens\n\n\n useAuth();\n return children;\n};\n\nexport default IdpProvider;\n","import cookies from 'browser-cookies';\n\nconst clearAuth = (cookies, getCookieDomain, cookieKeys) => () => {\n const domain = getCookieDomain();\n cookieKeys.forEach(key => {\n cookies.erase(key, {\n domain\n });\n });\n};\n\nconst fetchAuth = (fetch, convert) => async () => {\n const idp = await fetch();\n const user = convert(idp);\n return user;\n};\n\nconst fetchInfo = (cookies, cookieKey) => () => new Promise((res, rej) => {\n try {\n const cookie = cookies.get(cookieKey);\n\n if (!cookie) {\n return rej(new Error('no auth cookie'));\n }\n\n const idp = JSON.parse(cookie);\n\n if (!idp) {\n return rej(new Error('no auth cookie'));\n }\n\n return res(idp);\n } catch (e) {\n rej(e);\n }\n});\n\nconst getCookieDomain = () => () => {\n try {\n return COOKIE_DOMAIN;\n } catch (e) {\n return '';\n }\n};\n\nconst logout = (clearAuth, redirect) => args => {\n clearAuth();\n redirect(args);\n};\n\nconst redirectToLogin = (location, getLoginPath, getPathname) => ({\n path\n} = {}) => {\n const url = getLoginPath({\n path: getPathname(path)\n });\n location.href = url;\n};\n\nconst redirectToLogout = (location, getLogoutPath, getPathname) => ({\n path\n} = {}) => {\n const url = getLogoutPath({\n path: getPathname(path)\n });\n location.href = url;\n};\n\nconst getAppName = () => () => {\n try {\n return APP_NAME;\n } catch (e) {\n throw new Error('APP_NAME not set');\n }\n};\n\nconst getPathname = window => path => {\n return path != null ? path : \"\".concat(window.location.pathname).concat(window.location.search).concat(window.location.hash);\n};\n\n/* eslint-disable max-len */\nvar commonDi = (jpex => {\n const getCookieDomain$1 = getCookieDomain();\n jpex.constant(\"type:@ux/auth/GetAppName\", getAppName());\n jpex.factory(\"type:@ux/auth/GetPathname\", [], () => getPathname(window));\n jpex.factory(\"type:@ux/auth/FetchInfo\", [\"type:@ux/auth/CookieKeys\"], cookieKeys => fetchInfo(cookies, cookieKeys[0]));\n jpex.factory(\"type:@ux/auth/ClearAuth\", [\"type:@ux/auth/CookieKeys\"], cookieKeys => clearAuth(cookies, getCookieDomain$1, cookieKeys));\n jpex.factory(\"type:@ux/auth/FetchAuth\", [\"type:@ux/auth/FetchInfo\", \"type:@ux/auth/ConvertInfoToUser\"], (fetch, convert) => fetchAuth(fetch, convert));\n jpex.factory(\"type:@ux/auth/RedirectToLogin\", [\"type:@ux/auth/GetLoginPath\", \"type:@ux/auth/GetPathname\"], (getLoginPath, getPathname) => redirectToLogin(window.location, getLoginPath, getPathname));\n jpex.factory(\"type:@ux/auth/RedirectToLogout\", [\"type:@ux/auth/GetLogoutPath\", \"type:@ux/auth/GetPathname\"], (getLogoutPath, getPathname) => redirectToLogout(window.location, getLogoutPath, getPathname));\n jpex.factory(\"type:@ux/auth/Logout\", [\"type:@ux/auth/ClearAuth\", \"type:@ux/auth/RedirectToLogout\"], (clearAuth, redirect) => logout(clearAuth, redirect));\n});\n\nexport { commonDi as c };\n"],"sourceRoot":""}