@smg-automotive/auth 7.0.0 → 7.1.0-always-mount-auth-under-proxy-segment.2
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/README.md +91 -171
- package/dist/Auth-C40nODjM.d.ts +11 -0
- package/dist/cjs/api/baseUrl.js +2 -2
- package/dist/cjs/api/baseUrl.js.map +1 -1
- package/dist/cjs/api/entitlements/client.js +1 -1
- package/dist/cjs/api/entitlements/client.js.map +1 -1
- package/dist/cjs/api/entitlements/getEntitlements.js +20 -24
- package/dist/cjs/api/entitlements/getEntitlements.js.map +1 -1
- package/dist/cjs/api/seller/client.d.ts +2 -2
- package/dist/cjs/api/seller/client.js +1 -1
- package/dist/cjs/api/seller/client.js.map +1 -1
- package/dist/cjs/api/seller/getSeller.js +21 -22
- package/dist/cjs/api/seller/getSeller.js.map +1 -1
- package/dist/cjs/api/user/client.js +1 -1
- package/dist/cjs/api/user/client.js.map +1 -1
- package/dist/cjs/api/user/getManagedSellers.js +26 -30
- package/dist/cjs/api/user/getManagedSellers.js.map +1 -1
- package/dist/cjs/client/contexts/Auth.d.ts +12 -0
- package/dist/cjs/client/contexts/Auth.js +26 -0
- package/dist/cjs/client/contexts/Auth.js.map +1 -0
- package/dist/cjs/client/contexts/index.d.ts +1 -0
- package/dist/cjs/client/helpers/getAccessToken.d.ts +4 -0
- package/dist/cjs/client/helpers/getAccessToken.js +27 -0
- package/dist/cjs/client/helpers/getAccessToken.js.map +1 -0
- package/dist/cjs/client/helpers/index.d.ts +2 -0
- package/dist/cjs/client/helpers/switchSelectedTenant.d.ts +5 -0
- package/dist/cjs/client/helpers/switchSelectedTenant.js +17 -0
- package/dist/cjs/client/helpers/switchSelectedTenant.js.map +1 -0
- package/dist/cjs/client/hooks/index.d.ts +2 -0
- package/dist/cjs/client/hooks/useAuthConfig.d.ts +1 -0
- package/dist/cjs/client/hooks/useAuthConfig.js +15 -0
- package/dist/cjs/client/hooks/useAuthConfig.js.map +1 -0
- package/dist/cjs/client/hooks/useUser.d.ts +7 -0
- package/dist/cjs/client/hooks/useUser.js +28 -0
- package/dist/cjs/client/hooks/useUser.js.map +1 -0
- package/dist/cjs/config/auth0.d.ts +1 -3
- package/dist/cjs/config/auth0.js +38 -29
- package/dist/cjs/config/auth0.js.map +1 -1
- package/dist/cjs/fixtures/authConfig.js +39 -23
- package/dist/cjs/fixtures/authConfig.js.map +1 -1
- package/dist/cjs/fixtures/entitlements.js +151 -136
- package/dist/cjs/fixtures/entitlements.js.map +1 -1
- package/dist/cjs/fixtures/user.js +64 -55
- package/dist/cjs/fixtures/user.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/authLinks.d.ts +3 -1
- package/dist/cjs/lib/authLinks.js +14 -11
- package/dist/cjs/lib/authLinks.js.map +1 -1
- package/dist/cjs/lib/enrichUser/auth0.d.ts +1 -1
- package/dist/cjs/lib/enrichUser/auth0.js +28 -29
- package/dist/cjs/lib/enrichUser/auth0.js.map +1 -1
- package/dist/cjs/lib/enrichUser/session.js +31 -48
- package/dist/cjs/lib/enrichUser/session.js.map +1 -1
- package/dist/cjs/lib/utils.js +3 -3
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/cjs/node_modules/whatwg-fetch/fetch.js +650 -0
- package/dist/cjs/node_modules/whatwg-fetch/fetch.js.map +1 -0
- package/dist/cjs/server/getAuth0Instance.d.ts +8 -0
- package/dist/cjs/server/getAuth0Instance.js +59 -0
- package/dist/cjs/server/getAuth0Instance.js.map +1 -0
- package/dist/cjs/server/helpers/getAccessToken.d.ts +2 -0
- package/dist/cjs/server/helpers/getAccessToken.js +12 -0
- package/dist/cjs/server/helpers/getAccessToken.js.map +1 -0
- package/dist/cjs/server/helpers/getAuthProps.d.ts +12 -0
- package/dist/cjs/server/helpers/getAuthProps.js +13 -0
- package/dist/cjs/server/helpers/getAuthProps.js.map +1 -0
- package/dist/cjs/server/helpers/getUser.d.ts +13 -0
- package/dist/cjs/server/helpers/getUser.js +33 -0
- package/dist/cjs/server/helpers/getUser.js.map +1 -0
- package/dist/cjs/server/helpers/index.d.ts +4 -0
- package/dist/cjs/server/helpers/isLoggedIn.d.ts +2 -0
- package/dist/cjs/server/helpers/isLoggedIn.js +11 -0
- package/dist/cjs/server/helpers/isLoggedIn.js.map +1 -0
- package/dist/cjs/server/hooks/beforeSessionSavedFactory.d.ts +3 -0
- package/dist/cjs/server/hooks/beforeSessionSavedFactory.js +22 -0
- package/dist/cjs/server/hooks/beforeSessionSavedFactory.js.map +1 -0
- package/dist/cjs/server/hooks/onCallbackFactory.d.ts +9 -0
- package/dist/cjs/server/hooks/onCallbackFactory.js +99 -0
- package/dist/cjs/server/hooks/onCallbackFactory.js.map +1 -0
- package/dist/cjs/server/middleware/addCachingHeaders.d.ts +2 -0
- package/dist/cjs/server/middleware/addCachingHeaders.js +10 -0
- package/dist/cjs/server/middleware/addCachingHeaders.js.map +1 -0
- package/dist/cjs/server/middleware/combineHeaders.d.ts +5 -0
- package/dist/cjs/server/middleware/combineHeaders.js +11 -0
- package/dist/cjs/server/middleware/combineHeaders.js.map +1 -0
- package/dist/cjs/server/middleware/index.d.ts +12 -0
- package/dist/cjs/server/middleware/index.js +102 -0
- package/dist/cjs/server/middleware/index.js.map +1 -0
- package/dist/cjs/server/middleware/login.d.ts +11 -0
- package/dist/cjs/server/middleware/login.js +37 -0
- package/dist/cjs/server/middleware/login.js.map +1 -0
- package/dist/cjs/server/middleware/logout.d.ts +14 -0
- package/dist/cjs/server/middleware/logout.js +118 -0
- package/dist/cjs/server/middleware/logout.js.map +1 -0
- package/dist/cjs/server/middleware/proactivelyRefreshAccessToken.d.ts +12 -0
- package/dist/cjs/server/middleware/proactivelyRefreshAccessToken.js +13 -0
- package/dist/cjs/server/middleware/proactivelyRefreshAccessToken.js.map +1 -0
- package/dist/cjs/server/middleware/profile.d.ts +10 -0
- package/dist/cjs/server/middleware/profile.js +28 -0
- package/dist/cjs/server/middleware/profile.js.map +1 -0
- package/dist/cjs/server/middleware/protectRoute.d.ts +13 -0
- package/dist/cjs/server/middleware/protectRoute.js +52 -0
- package/dist/cjs/server/middleware/protectRoute.js.map +1 -0
- package/dist/cjs/server/middleware/token.d.ts +10 -0
- package/dist/cjs/server/middleware/token.js +44 -0
- package/dist/cjs/server/middleware/token.js.map +1 -0
- package/dist/cjs/server/redisSessionStore.d.ts +15 -0
- package/dist/cjs/server.d.ts +2 -4
- package/dist/cjs/server.js +9 -10
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/test/mocks.d.ts +1 -0
- package/dist/cjs/test/mocks.js +10 -0
- package/dist/cjs/test/mocks.js.map +1 -0
- package/dist/cjs/test/setup.d.ts +2 -0
- package/dist/cjs/test/setup.js +28 -0
- package/dist/cjs/test/setup.js.map +1 -0
- package/dist/cjs/types/auth0/config.d.ts +3 -3
- package/dist/cjs/types/auth0/jwtPayload.d.ts +2 -0
- package/dist/cjs/types/auth0/user.d.ts +0 -1
- package/dist/cjs/types/cookieOptions.d.ts +1 -1
- package/dist/esm/api/baseUrl.js +2 -2
- package/dist/esm/api/baseUrl.js.map +1 -1
- package/dist/esm/api/entitlements/client.js +2 -2
- package/dist/esm/api/entitlements/client.js.map +1 -1
- package/dist/esm/api/entitlements/getEntitlements.js +20 -24
- package/dist/esm/api/entitlements/getEntitlements.js.map +1 -1
- package/dist/esm/api/seller/client.d.ts +2 -2
- package/dist/esm/api/seller/client.js +2 -2
- package/dist/esm/api/seller/client.js.map +1 -1
- package/dist/esm/api/seller/getSeller.js +21 -22
- package/dist/esm/api/seller/getSeller.js.map +1 -1
- package/dist/esm/api/user/client.js +2 -2
- package/dist/esm/api/user/client.js.map +1 -1
- package/dist/esm/api/user/getManagedSellers.js +26 -30
- package/dist/esm/api/user/getManagedSellers.js.map +1 -1
- package/dist/esm/client/contexts/Auth.d.ts +12 -0
- package/dist/esm/client/contexts/Auth.js +23 -0
- package/dist/esm/client/contexts/Auth.js.map +1 -0
- package/dist/esm/client/contexts/__tests__/Auth.Test.d.ts +1 -0
- package/dist/esm/client/contexts/index.d.ts +1 -0
- package/dist/esm/client/helpers/getAccessToken.d.ts +4 -0
- package/dist/esm/client/helpers/getAccessToken.js +25 -0
- package/dist/esm/client/helpers/getAccessToken.js.map +1 -0
- package/dist/esm/client/helpers/index.d.ts +2 -0
- package/dist/esm/client/helpers/switchSelectedTenant.d.ts +5 -0
- package/dist/esm/client/helpers/switchSelectedTenant.js +15 -0
- package/dist/esm/client/helpers/switchSelectedTenant.js.map +1 -0
- package/dist/esm/client/hooks/__tests__/UseUser.Test.d.ts +1 -0
- package/dist/esm/client/hooks/index.d.ts +2 -0
- package/dist/esm/client/hooks/useAuthConfig.d.ts +1 -0
- package/dist/esm/client/hooks/useAuthConfig.js +13 -0
- package/dist/esm/client/hooks/useAuthConfig.js.map +1 -0
- package/dist/esm/client/hooks/useUser.d.ts +7 -0
- package/dist/esm/client/hooks/useUser.js +26 -0
- package/dist/esm/client/hooks/useUser.js.map +1 -0
- package/dist/esm/config/auth0.d.ts +1 -3
- package/dist/esm/config/auth0.js +38 -29
- package/dist/esm/config/auth0.js.map +1 -1
- package/dist/esm/fixtures/authConfig.js +39 -23
- package/dist/esm/fixtures/authConfig.js.map +1 -1
- package/dist/esm/fixtures/entitlements.js +151 -136
- package/dist/esm/fixtures/entitlements.js.map +1 -1
- package/dist/esm/fixtures/user.js +64 -55
- package/dist/esm/fixtures/user.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/authLinks.d.ts +3 -1
- package/dist/esm/lib/authLinks.js +14 -11
- package/dist/esm/lib/authLinks.js.map +1 -1
- package/dist/esm/lib/enrichUser/auth0.d.ts +1 -1
- package/dist/esm/lib/enrichUser/auth0.js +28 -29
- package/dist/esm/lib/enrichUser/auth0.js.map +1 -1
- package/dist/esm/lib/enrichUser/session.js +31 -48
- package/dist/esm/lib/enrichUser/session.js.map +1 -1
- package/dist/esm/lib/utils.js +3 -3
- package/dist/esm/lib/utils.js.map +1 -1
- package/dist/esm/node_modules/whatwg-fetch/fetch.js +645 -0
- package/dist/esm/node_modules/whatwg-fetch/fetch.js.map +1 -0
- package/dist/esm/server/getAuth0Instance.d.ts +8 -0
- package/dist/esm/server/getAuth0Instance.js +57 -0
- package/dist/esm/server/getAuth0Instance.js.map +1 -0
- package/dist/esm/server/helpers/getAccessToken.d.ts +2 -0
- package/dist/esm/server/helpers/getAccessToken.js +10 -0
- package/dist/esm/server/helpers/getAccessToken.js.map +1 -0
- package/dist/esm/server/helpers/getAuthProps.d.ts +12 -0
- package/dist/esm/server/helpers/getAuthProps.js +11 -0
- package/dist/esm/server/helpers/getAuthProps.js.map +1 -0
- package/dist/esm/server/helpers/getUser.d.ts +13 -0
- package/dist/esm/server/helpers/getUser.js +30 -0
- package/dist/esm/server/helpers/getUser.js.map +1 -0
- package/dist/esm/server/helpers/index.d.ts +4 -0
- package/dist/esm/server/helpers/isLoggedIn.d.ts +2 -0
- package/dist/esm/server/helpers/isLoggedIn.js +9 -0
- package/dist/esm/server/helpers/isLoggedIn.js.map +1 -0
- package/dist/esm/server/hooks/beforeSessionSavedFactory.d.ts +3 -0
- package/dist/esm/server/hooks/beforeSessionSavedFactory.js +20 -0
- package/dist/esm/server/hooks/beforeSessionSavedFactory.js.map +1 -0
- package/dist/esm/server/hooks/onCallbackFactory.d.ts +9 -0
- package/dist/esm/server/hooks/onCallbackFactory.js +97 -0
- package/dist/esm/server/hooks/onCallbackFactory.js.map +1 -0
- package/dist/esm/server/middleware/addCachingHeaders.d.ts +2 -0
- package/dist/esm/server/middleware/addCachingHeaders.js +8 -0
- package/dist/esm/server/middleware/addCachingHeaders.js.map +1 -0
- package/dist/esm/server/middleware/combineHeaders.d.ts +5 -0
- package/dist/esm/server/middleware/combineHeaders.js +9 -0
- package/dist/esm/server/middleware/combineHeaders.js.map +1 -0
- package/dist/esm/server/middleware/index.d.ts +12 -0
- package/dist/esm/server/middleware/index.js +100 -0
- package/dist/esm/server/middleware/index.js.map +1 -0
- package/dist/esm/server/middleware/login.d.ts +11 -0
- package/dist/esm/server/middleware/login.js +34 -0
- package/dist/esm/server/middleware/login.js.map +1 -0
- package/dist/esm/server/middleware/logout.d.ts +14 -0
- package/dist/esm/server/middleware/logout.js +115 -0
- package/dist/esm/server/middleware/logout.js.map +1 -0
- package/dist/esm/server/middleware/proactivelyRefreshAccessToken.d.ts +12 -0
- package/dist/esm/server/middleware/proactivelyRefreshAccessToken.js +11 -0
- package/dist/esm/server/middleware/proactivelyRefreshAccessToken.js.map +1 -0
- package/dist/esm/server/middleware/profile.d.ts +10 -0
- package/dist/esm/server/middleware/profile.js +26 -0
- package/dist/esm/server/middleware/profile.js.map +1 -0
- package/dist/esm/server/middleware/protectRoute.d.ts +13 -0
- package/dist/esm/server/middleware/protectRoute.js +50 -0
- package/dist/esm/server/middleware/protectRoute.js.map +1 -0
- package/dist/esm/server/middleware/token.d.ts +10 -0
- package/dist/esm/server/middleware/token.js +42 -0
- package/dist/esm/server/middleware/token.js.map +1 -0
- package/dist/esm/server/redisSessionStore.d.ts +15 -0
- package/dist/esm/server.d.ts +2 -4
- package/dist/esm/server.js +5 -5
- package/dist/esm/test/mocks.d.ts +1 -0
- package/dist/esm/test/mocks.js +8 -0
- package/dist/esm/test/mocks.js.map +1 -0
- package/dist/esm/test/setup.d.ts +2 -0
- package/dist/esm/test/setup.js +26 -0
- package/dist/esm/test/setup.js.map +1 -0
- package/dist/esm/types/auth0/config.d.ts +3 -3
- package/dist/esm/types/auth0/jwtPayload.d.ts +2 -0
- package/dist/esm/types/auth0/user.d.ts +0 -1
- package/dist/esm/types/cookieOptions.d.ts +1 -1
- package/dist/fixtures.d.ts +1 -1
- package/dist/index.d.ts +27 -5
- package/dist/server.d.ts +26 -64
- package/dist/{sessionUser-DV1lFwq8.d.ts → sessionUser-wavMinWI.d.ts} +27 -37
- package/package.json +26 -22
- package/dist/cjs/apiRoutes/getImpersonatedSellerId.d.ts +0 -5
- package/dist/cjs/apiRoutes/getImpersonatedSellerId.js +0 -18
- package/dist/cjs/apiRoutes/getImpersonatedSellerId.js.map +0 -1
- package/dist/cjs/apiRoutes/getSelectedSeller.d.ts +0 -5
- package/dist/cjs/apiRoutes/getSelectedSeller.js +0 -13
- package/dist/cjs/apiRoutes/getSelectedSeller.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/constants.d.ts +0 -1
- package/dist/cjs/apiRoutes/handlers/constants.js +0 -6
- package/dist/cjs/apiRoutes/handlers/constants.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/creators/afterCallback.d.ts +0 -11
- package/dist/cjs/apiRoutes/handlers/creators/afterCallback.js +0 -48
- package/dist/cjs/apiRoutes/handlers/creators/afterCallback.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/creators/error.d.ts +0 -8
- package/dist/cjs/apiRoutes/handlers/creators/error.js +0 -78
- package/dist/cjs/apiRoutes/handlers/creators/error.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/creators/login.d.ts +0 -2
- package/dist/cjs/apiRoutes/handlers/creators/login.js +0 -27
- package/dist/cjs/apiRoutes/handlers/creators/login.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/creators/logout.d.ts +0 -2
- package/dist/cjs/apiRoutes/handlers/creators/logout.js +0 -111
- package/dist/cjs/apiRoutes/handlers/creators/logout.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/creators/token.d.ts +0 -12
- package/dist/cjs/apiRoutes/handlers/creators/token.js +0 -70
- package/dist/cjs/apiRoutes/handlers/creators/token.js.map +0 -1
- package/dist/cjs/apiRoutes/handlers/creators/types.d.ts +0 -10
- package/dist/cjs/apiRoutes/handlers/index.d.ts +0 -6
- package/dist/cjs/apiRoutes/handlers/index.js +0 -32
- package/dist/cjs/apiRoutes/handlers/index.js.map +0 -1
- package/dist/cjs/apiRoutes/index.d.ts +0 -1
- package/dist/cjs/apiRoutes/mapLegacyVehicleTypeGroup.d.ts +0 -2
- package/dist/cjs/apiRoutes/mapLegacyVehicleTypeGroup.js +0 -15
- package/dist/cjs/apiRoutes/mapLegacyVehicleTypeGroup.js.map +0 -1
- package/dist/cjs/contexts/Auth.d.ts +0 -25
- package/dist/cjs/contexts/Auth.js +0 -262
- package/dist/cjs/contexts/Auth.js.map +0 -1
- package/dist/cjs/contexts/index.d.ts +0 -1
- package/dist/cjs/edge.d.ts +0 -1
- package/dist/cjs/edge.js +0 -8
- package/dist/cjs/edge.js.map +0 -1
- package/dist/cjs/fixtures/jwt.d.ts +0 -1
- package/dist/cjs/getServerAuthProps/app.d.ts +0 -14
- package/dist/cjs/getServerAuthProps/app.js +0 -64
- package/dist/cjs/getServerAuthProps/app.js.map +0 -1
- package/dist/cjs/getServerAuthProps/getAuthProps.d.ts +0 -13
- package/dist/cjs/getServerAuthProps/getAuthProps.js +0 -54
- package/dist/cjs/getServerAuthProps/getAuthProps.js.map +0 -1
- package/dist/cjs/getServerAuthProps/index.d.ts +0 -3
- package/dist/cjs/getServerAuthProps/pages.d.ts +0 -22
- package/dist/cjs/getServerAuthProps/pages.js +0 -63
- package/dist/cjs/getServerAuthProps/pages.js.map +0 -1
- package/dist/cjs/getServerAuthProps/types.d.ts +0 -2
- package/dist/cjs/hooks/useInterval.d.ts +0 -6
- package/dist/cjs/hooks/useInterval.js +0 -25
- package/dist/cjs/hooks/useInterval.js.map +0 -1
- package/dist/cjs/lib/buildInstanceKey.d.ts +0 -6
- package/dist/cjs/lib/buildInstanceKey.js +0 -9
- package/dist/cjs/lib/buildInstanceKey.js.map +0 -1
- package/dist/cjs/lib/edge/getAuth0Instance.d.ts +0 -3
- package/dist/cjs/lib/edge/getAuth0Instance.js +0 -31
- package/dist/cjs/lib/edge/getAuth0Instance.js.map +0 -1
- package/dist/cjs/lib/request/getAccessToken.d.ts +0 -30
- package/dist/cjs/lib/request/getAccessToken.js +0 -130
- package/dist/cjs/lib/request/getAccessToken.js.map +0 -1
- package/dist/cjs/lib/request/getAuth0Instance.d.ts +0 -3
- package/dist/cjs/lib/request/getAuth0Instance.js +0 -31
- package/dist/cjs/lib/request/getAuth0Instance.js.map +0 -1
- package/dist/cjs/lib/request/getUserAndAccessToken.d.ts +0 -21
- package/dist/cjs/lib/request/getUserAndAccessToken.js +0 -67
- package/dist/cjs/lib/request/getUserAndAccessToken.js.map +0 -1
- package/dist/cjs/lib/request/inFlightAccessTokenCache.d.ts +0 -8
- package/dist/cjs/lib/request/inFlightAccessTokenCache.js +0 -6
- package/dist/cjs/lib/request/inFlightAccessTokenCache.js.map +0 -1
- package/dist/cjs/lib/request/isLoggedIn.d.ts +0 -14
- package/dist/cjs/lib/request/isLoggedIn.js +0 -26
- package/dist/cjs/lib/request/isLoggedIn.js.map +0 -1
- package/dist/cjs/lib/request/sessionCallbackHandler.d.ts +0 -17
- package/dist/cjs/lib/request/sessionCallbackHandler.js +0 -74
- package/dist/cjs/lib/request/sessionCallbackHandler.js.map +0 -1
- package/dist/cjs/middleware.d.ts +0 -12
- package/dist/cjs/middleware.js +0 -75
- package/dist/cjs/middleware.js.map +0 -1
- package/dist/cjs/node_modules/tslib/tslib.es6.js +0 -100
- package/dist/cjs/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/cjs/types/brand.js +0 -8
- package/dist/cjs/types/brand.js.map +0 -1
- package/dist/edge.d.ts +0 -16
- package/dist/esm/apiRoutes/getImpersonatedSellerId.d.ts +0 -5
- package/dist/esm/apiRoutes/getImpersonatedSellerId.js +0 -16
- package/dist/esm/apiRoutes/getImpersonatedSellerId.js.map +0 -1
- package/dist/esm/apiRoutes/getSelectedSeller.d.ts +0 -5
- package/dist/esm/apiRoutes/getSelectedSeller.js +0 -11
- package/dist/esm/apiRoutes/getSelectedSeller.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/constants.d.ts +0 -1
- package/dist/esm/apiRoutes/handlers/constants.js +0 -4
- package/dist/esm/apiRoutes/handlers/constants.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/creators/afterCallback.d.ts +0 -11
- package/dist/esm/apiRoutes/handlers/creators/afterCallback.js +0 -46
- package/dist/esm/apiRoutes/handlers/creators/afterCallback.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/creators/error.d.ts +0 -8
- package/dist/esm/apiRoutes/handlers/creators/error.js +0 -76
- package/dist/esm/apiRoutes/handlers/creators/error.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/creators/login.d.ts +0 -2
- package/dist/esm/apiRoutes/handlers/creators/login.js +0 -25
- package/dist/esm/apiRoutes/handlers/creators/login.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/creators/logout.d.ts +0 -2
- package/dist/esm/apiRoutes/handlers/creators/logout.js +0 -109
- package/dist/esm/apiRoutes/handlers/creators/logout.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/creators/token.d.ts +0 -12
- package/dist/esm/apiRoutes/handlers/creators/token.js +0 -68
- package/dist/esm/apiRoutes/handlers/creators/token.js.map +0 -1
- package/dist/esm/apiRoutes/handlers/creators/types.d.ts +0 -10
- package/dist/esm/apiRoutes/handlers/index.d.ts +0 -6
- package/dist/esm/apiRoutes/handlers/index.js +0 -30
- package/dist/esm/apiRoutes/handlers/index.js.map +0 -1
- package/dist/esm/apiRoutes/index.d.ts +0 -1
- package/dist/esm/apiRoutes/mapLegacyVehicleTypeGroup.d.ts +0 -2
- package/dist/esm/apiRoutes/mapLegacyVehicleTypeGroup.js +0 -13
- package/dist/esm/apiRoutes/mapLegacyVehicleTypeGroup.js.map +0 -1
- package/dist/esm/contexts/Auth.d.ts +0 -25
- package/dist/esm/contexts/Auth.js +0 -259
- package/dist/esm/contexts/Auth.js.map +0 -1
- package/dist/esm/contexts/index.d.ts +0 -1
- package/dist/esm/edge.d.ts +0 -1
- package/dist/esm/edge.js +0 -2
- package/dist/esm/edge.js.map +0 -1
- package/dist/esm/fixtures/jwt.d.ts +0 -1
- package/dist/esm/getServerAuthProps/app.d.ts +0 -14
- package/dist/esm/getServerAuthProps/app.js +0 -62
- package/dist/esm/getServerAuthProps/app.js.map +0 -1
- package/dist/esm/getServerAuthProps/getAuthProps.d.ts +0 -13
- package/dist/esm/getServerAuthProps/getAuthProps.js +0 -52
- package/dist/esm/getServerAuthProps/getAuthProps.js.map +0 -1
- package/dist/esm/getServerAuthProps/index.d.ts +0 -3
- package/dist/esm/getServerAuthProps/pages.d.ts +0 -22
- package/dist/esm/getServerAuthProps/pages.js +0 -61
- package/dist/esm/getServerAuthProps/pages.js.map +0 -1
- package/dist/esm/getServerAuthProps/types.d.ts +0 -2
- package/dist/esm/hooks/useInterval.d.ts +0 -6
- package/dist/esm/hooks/useInterval.js +0 -23
- package/dist/esm/hooks/useInterval.js.map +0 -1
- package/dist/esm/lib/buildInstanceKey.d.ts +0 -6
- package/dist/esm/lib/buildInstanceKey.js +0 -7
- package/dist/esm/lib/buildInstanceKey.js.map +0 -1
- package/dist/esm/lib/edge/getAuth0Instance.d.ts +0 -3
- package/dist/esm/lib/edge/getAuth0Instance.js +0 -29
- package/dist/esm/lib/edge/getAuth0Instance.js.map +0 -1
- package/dist/esm/lib/request/getAccessToken.d.ts +0 -30
- package/dist/esm/lib/request/getAccessToken.js +0 -128
- package/dist/esm/lib/request/getAccessToken.js.map +0 -1
- package/dist/esm/lib/request/getAuth0Instance.d.ts +0 -3
- package/dist/esm/lib/request/getAuth0Instance.js +0 -29
- package/dist/esm/lib/request/getAuth0Instance.js.map +0 -1
- package/dist/esm/lib/request/getUserAndAccessToken.d.ts +0 -21
- package/dist/esm/lib/request/getUserAndAccessToken.js +0 -64
- package/dist/esm/lib/request/getUserAndAccessToken.js.map +0 -1
- package/dist/esm/lib/request/inFlightAccessTokenCache.d.ts +0 -8
- package/dist/esm/lib/request/inFlightAccessTokenCache.js +0 -4
- package/dist/esm/lib/request/inFlightAccessTokenCache.js.map +0 -1
- package/dist/esm/lib/request/isLoggedIn.d.ts +0 -14
- package/dist/esm/lib/request/isLoggedIn.js +0 -24
- package/dist/esm/lib/request/isLoggedIn.js.map +0 -1
- package/dist/esm/lib/request/sessionCallbackHandler.d.ts +0 -17
- package/dist/esm/lib/request/sessionCallbackHandler.js +0 -72
- package/dist/esm/lib/request/sessionCallbackHandler.js.map +0 -1
- package/dist/esm/middleware.d.ts +0 -12
- package/dist/esm/middleware.js +0 -73
- package/dist/esm/middleware.js.map +0 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js +0 -95
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/esm/types/brand.js +0 -8
- package/dist/esm/types/brand.js.map +0 -1
- package/dist/types-QCN7bglM.d.ts +0 -28
- /package/dist/cjs/{contexts/__tests__/AuthTest.d.ts → client/contexts/__tests__/Auth.Test.d.ts} +0 -0
- /package/dist/{esm/contexts/__tests__/AuthTest.d.ts → cjs/client/hooks/__tests__/UseUser.Test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -14,7 +14,6 @@ npm install @smg-automotive/auth
|
|
|
14
14
|
You need following environment variables to be set:
|
|
15
15
|
|
|
16
16
|
- To communicate with automotive APIs:
|
|
17
|
-
|
|
18
17
|
- `API_ROOT`
|
|
19
18
|
- `API_VERSION`
|
|
20
19
|
|
|
@@ -27,14 +26,12 @@ You need following environment variables to be set:
|
|
|
27
26
|
- `PROXY_REQUEST_PATH_SEGMENT` - The path segment on which your application is mounted.
|
|
28
27
|
|
|
29
28
|
- Localization
|
|
30
|
-
|
|
31
29
|
- `DEFAULT_LOCALE` - The default locale of the application.
|
|
32
30
|
- `SUPPORTED_LOCALES` - All supported locales of the application, comma separated.
|
|
33
31
|
|
|
34
32
|
- Auth0 configuration
|
|
35
|
-
|
|
36
33
|
- `AUTH0_CLIENT_ID`
|
|
37
|
-
- `
|
|
34
|
+
- `AUTH0_DOMAIN`
|
|
38
35
|
- `AUTH0_SESSION_NAME`
|
|
39
36
|
- `AUTH0_AUDIENCE`
|
|
40
37
|
- `AUTH0_SECRET`
|
|
@@ -43,15 +40,25 @@ You need following environment variables to be set:
|
|
|
43
40
|
|
|
44
41
|
Check out the [Auth0 docs](https://auth0.com/docs/quickstart/webapp/nextjs/interactive) for more information.
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
- Redis Session Store
|
|
44
|
+
- `AUTH0_CUSTOM_REDIS_URL`: When present the package will create a redis session store instead of using cookies to store the session
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
Example: `redis://default:devpassword123@localhost:6379`
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
The consuming project needs to enable node js middleware in next
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// middleware.ts
|
|
52
|
+
...
|
|
53
|
+
export const config = { runtime: "nodejs" };
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- Debug flag to force a token refresh on every interval
|
|
57
|
+
- `AUTH0_DEBUG_FORCE_TOKEN_REFRESH` - [optional] set to `true` to force a token refresh on every interval
|
|
58
|
+
|
|
59
|
+
### Auth Context
|
|
60
|
+
|
|
61
|
+
This package exposes the `AuthProvider`. It exposes the auth configuration and pre-caches the user data.
|
|
55
62
|
|
|
56
63
|
You want to include the `AuthProvider` on the top level of your application and supply the props obtained server-side from auth0. The usage varies slightly depending on the router you are using. Check out the examples below.
|
|
57
64
|
|
|
@@ -62,11 +69,11 @@ We rely on `PageProps` combined with `getInitialProps` to pass the auth props to
|
|
|
62
69
|
```tsx
|
|
63
70
|
// src/pages/_app.tsx
|
|
64
71
|
import App, { type AppContext, type AppProps } from 'next/app';
|
|
65
|
-
import { type
|
|
72
|
+
import { type AuthProviderProps, AuthProvider } from '@smg-automotive/auth';
|
|
66
73
|
|
|
67
74
|
type PageProps = {
|
|
68
75
|
// your other page props
|
|
69
|
-
authProps:
|
|
76
|
+
authProps: AuthProviderProps;
|
|
70
77
|
};
|
|
71
78
|
|
|
72
79
|
const MyApp = ({
|
|
@@ -87,27 +94,28 @@ MyApp.getInitialProps = async (appContext: AppContext) => {
|
|
|
87
94
|
|
|
88
95
|
const brand = yourBrandDerivingLogic();
|
|
89
96
|
const language = yourLanguageDerivingLogic();
|
|
90
|
-
const isProxied = yourProxyDetectionLogic();
|
|
91
97
|
const protocol = yourProtocolDetectionLogic();
|
|
92
98
|
const host = yourHostDetectionLogic();
|
|
93
99
|
|
|
94
|
-
const {
|
|
100
|
+
const { getAuthProps } = await import(
|
|
95
101
|
'@smg-automotive/auth/server'
|
|
96
102
|
);
|
|
97
|
-
|
|
98
|
-
request,
|
|
99
|
-
response,
|
|
100
|
-
appProps,
|
|
103
|
+
const authProps = await getAuthProps({
|
|
101
104
|
brand,
|
|
102
|
-
language,
|
|
103
|
-
isProxied,
|
|
104
105
|
protocol,
|
|
105
106
|
host,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
context: {
|
|
108
|
+
request,
|
|
109
|
+
response,
|
|
110
|
+
},
|
|
110
111
|
});
|
|
112
|
+
|
|
113
|
+
Object.assign(appProps.pageProps, {
|
|
114
|
+
...pageProps,
|
|
115
|
+
authProps,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return appProps;
|
|
111
119
|
};
|
|
112
120
|
|
|
113
121
|
export default MyApp;
|
|
@@ -123,30 +131,25 @@ You can pass an `errorHandler` of your choice to the `AuthProvider` to handle er
|
|
|
123
131
|
|
|
124
132
|
#### App Router
|
|
125
133
|
|
|
126
|
-
We provide `
|
|
134
|
+
We provide `getAuthProps` function to get the auth props in the app router. You'll use it in the layout component where you include the `AuthProvider`.
|
|
127
135
|
|
|
128
136
|
```tsx
|
|
129
137
|
// src/app/layout.tsx
|
|
130
138
|
import { FC, PropsWithChildren } from 'react';
|
|
131
139
|
|
|
132
140
|
import { AuthProvider } from '@smg-automotive/auth';
|
|
133
|
-
import {
|
|
141
|
+
import { getAuthProps } from '@smg-automotive/auth/server';
|
|
134
142
|
|
|
135
143
|
const Layout: FC<PropsWithChildren> = ({ children }) => {
|
|
136
144
|
const brand = yourBrandDerivingLogic();
|
|
137
145
|
const language = yourLanguageDetectionLogic();
|
|
138
|
-
const isProxied = yourProxyDetectionLogic();
|
|
139
146
|
const protocol = yourProtocolDetectionLogic();
|
|
140
147
|
const host = yourHostDetectionLogic();
|
|
141
148
|
|
|
142
|
-
const authProps = await
|
|
149
|
+
const authProps = await getAuthProps({
|
|
143
150
|
brand,
|
|
144
|
-
language,
|
|
145
|
-
isProxied,
|
|
146
151
|
protocol,
|
|
147
152
|
host,
|
|
148
|
-
// You can pass the error handler of your choice
|
|
149
|
-
// onError: Sentry.captureException,
|
|
150
153
|
});
|
|
151
154
|
|
|
152
155
|
return (
|
|
@@ -168,6 +171,37 @@ const onError = async (error) => {
|
|
|
168
171
|
};
|
|
169
172
|
```
|
|
170
173
|
|
|
174
|
+
#### Hooks and helpers
|
|
175
|
+
|
|
176
|
+
The package provides following hooks and helpers for session and user handling:
|
|
177
|
+
|
|
178
|
+
##### Client-side (exposed from `@smg-automotive/auth`)
|
|
179
|
+
- `useUser` - a hook to access the user data
|
|
180
|
+
- `useAuthConfig` - a hook to access the auth config
|
|
181
|
+
- `getAccessToken` - a helper to get the access token. It can be used in the client-side data fetching logic
|
|
182
|
+
- `switchSelectedTenant` - a helper to switch the selected tenant. It will trigger a re-login and client-side navigation
|
|
183
|
+
|
|
184
|
+
##### Server-side (exposed from `@smg-automotive/auth/server`)
|
|
185
|
+
- `isLoggedIn` - a helper to check if the user is logged in
|
|
186
|
+
- `getUser` - a helper to get the user data
|
|
187
|
+
- `getAccessToken` - a helper to get the access token for server-side data fetching
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
##### Login and logout links
|
|
191
|
+
|
|
192
|
+
This package also provides utility functions to generate login and logout links.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { getLoginLink, getLogoutLink } from '@smg-automotive/auth';
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
They expect the `auth0Config` to be passed as an argument, you can obtain it from the `config` object in the auth context.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
const auth0Config = useAuthConfig();
|
|
202
|
+
const loginLink = getLoginLink({ auth0Config });
|
|
203
|
+
```
|
|
204
|
+
|
|
171
205
|
### Protecting routes with middleware
|
|
172
206
|
|
|
173
207
|
We provide a middleware to protect routes from unauthenticated access. It will redirect to the login page if the user is not authenticated.
|
|
@@ -186,106 +220,22 @@ export default function middleware(
|
|
|
186
220
|
request: NextRequest,
|
|
187
221
|
event: NextFetchEvent,
|
|
188
222
|
) {
|
|
189
|
-
|
|
190
|
-
const language = determineLanguage(request);
|
|
191
|
-
const isProxied = yourProxyDetectionLogic();
|
|
223
|
+
const language = yourLanguageDetectionLogic();
|
|
192
224
|
const protocol = yourProtocolDetectionLogic();
|
|
193
225
|
const host = yourHostDetectionLogic();
|
|
226
|
+
const brand = yourBrandDetectionLogic();
|
|
194
227
|
|
|
195
228
|
return authMiddleware({
|
|
196
229
|
request,
|
|
197
|
-
event,
|
|
198
230
|
isProtectedRoute,
|
|
199
231
|
language,
|
|
200
|
-
isProxied,
|
|
201
232
|
protocol,
|
|
202
233
|
host,
|
|
203
|
-
// You can pass the error handler of your choice
|
|
204
|
-
// onError: Sentry.captureException,
|
|
205
234
|
});
|
|
206
235
|
}
|
|
207
236
|
```
|
|
208
237
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
For auth0 integration to work you need to provide api routes to handle the auth flow.
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
// pages/api/auth/[auth0].ts
|
|
215
|
-
import { NextApiRequest, NextApiResponse } from 'next';
|
|
216
|
-
import { apiRoutesHandler } from '@smg-automotive/auth/server';
|
|
217
|
-
|
|
218
|
-
export default async function handler(
|
|
219
|
-
req: NextApiRequest,
|
|
220
|
-
res: NextApiResponse,
|
|
221
|
-
) {
|
|
222
|
-
const brand = yourBrandDerivingLogic();
|
|
223
|
-
const isProxied = yourProxyDetectionLogic();
|
|
224
|
-
const protocol = yourProtocolDetectionLogic();
|
|
225
|
-
const host = yourHostDetectionLogic();
|
|
226
|
-
|
|
227
|
-
return apiRoutesHandler({
|
|
228
|
-
req,
|
|
229
|
-
res,
|
|
230
|
-
brand,
|
|
231
|
-
isProxied,
|
|
232
|
-
protocol,
|
|
233
|
-
host,
|
|
234
|
-
// You can pass the error handler of your choice (eg. Sentry)
|
|
235
|
-
// onError
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### Utility functions
|
|
241
|
-
|
|
242
|
-
#### Login and logout links
|
|
243
|
-
|
|
244
|
-
This package also provides utility functions to generate login and logout links.
|
|
245
|
-
|
|
246
|
-
```ts
|
|
247
|
-
import { getLoginLink, getLogoutLink } from '@smg-automotive/auth';
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
They expect the `auth0Config` to be passed as an argument, you can obtain it from the `config` object in the auth context.
|
|
251
|
-
|
|
252
|
-
```ts
|
|
253
|
-
const { config: auth0Config } = useAuth();
|
|
254
|
-
const loginLink = getLoginLink({ auth0Config });
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
#### Session helpers
|
|
258
|
-
|
|
259
|
-
For simplifying session handling on the server side we provide two helpers one to get the user and one to get the user and access tokens
|
|
260
|
-
The functions share the same interface, the `getUser` function is non invasive and will return null if no user is present
|
|
261
|
-
In comparison `getUserAndAccessToken` with trow errors and attempt to refresh the access token in case it's expired
|
|
262
|
-
|
|
263
|
-
```ts
|
|
264
|
-
import { getUserAndAccessToken } from '@smg-automotive/auth';
|
|
265
|
-
import { getUser } from '@smg-automotive/auth';
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
The function expects the following arguments:
|
|
269
|
-
|
|
270
|
-
- `protocol` - The protocol of the request.
|
|
271
|
-
- `host` - The host of the request.
|
|
272
|
-
- `isProxied` - Whether the request is proxied.
|
|
273
|
-
- `context` - Request & Response objects (optionally, for pages router)
|
|
274
|
-
|
|
275
|
-
The function will return the user and access token and will throw an error if the user is not authenticated.
|
|
276
|
-
|
|
277
|
-
To guard against the errors you can use the `isLoggedIn` helper. It guarantees the presence of the user object in the session.
|
|
278
|
-
|
|
279
|
-
```ts
|
|
280
|
-
import { isLoggedIn } from '@smg-automotive/auth/server';
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
The function expects the following arguments:
|
|
284
|
-
|
|
285
|
-
- `protocol` - The protocol of the request.
|
|
286
|
-
- `host` - The host of the request.
|
|
287
|
-
- `isProxied` - Whether the request is proxied.
|
|
288
|
-
- `context` - Request & Response objects (optionally, for pages router)
|
|
238
|
+
Auth0 integration routes are handled by the middleware. You need to make sure that the middleware is invoked for all the route patters except the static assets, image optimisation and metadata files.
|
|
289
239
|
|
|
290
240
|
### Fixtures
|
|
291
241
|
|
|
@@ -313,66 +263,36 @@ import {
|
|
|
313
263
|
|
|
314
264
|
### Test environment setup
|
|
315
265
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
// jest.config.ts
|
|
322
|
-
export default {
|
|
323
|
-
// rest of your config
|
|
324
|
-
moduleNameMapper: {
|
|
325
|
-
'^jose': require.resolve('jose'),
|
|
326
|
-
'^@panva/hkdf': require.resolve('@panva/hkdf'),
|
|
327
|
-
},
|
|
328
|
-
};
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
#### Mock the `oauth4webapi` package
|
|
266
|
+
#### Environment extension
|
|
267
|
+
Ensure that `TextEncoder`, `TextDecoder` and `fetch` are available in the test environment.
|
|
268
|
+
To make this easier we expose a `@smg-automotive/auth/test/environment-setup` module that you can add to jest setup:
|
|
332
269
|
|
|
333
270
|
```js
|
|
334
|
-
//
|
|
335
|
-
|
|
336
|
-
|
|
271
|
+
// jest.config.js
|
|
272
|
+
const jestConfig = {
|
|
273
|
+
setupFilesAfterEnv: ['@smg-automotive/auth/test/environment-setup'],
|
|
337
274
|
};
|
|
338
275
|
```
|
|
339
276
|
|
|
340
|
-
####
|
|
341
|
-
|
|
342
|
-
```ts
|
|
343
|
-
// .jest/setup/textEncoder.ts
|
|
344
|
-
const {
|
|
345
|
-
TextEncoder: ImportedTextEncoder,
|
|
346
|
-
TextDecoder: ImportedTextDecoder,
|
|
347
|
-
} = require('util');
|
|
348
|
-
|
|
349
|
-
Object.assign(global, {
|
|
350
|
-
TextEncoder: ImportedTextEncoder,
|
|
351
|
-
TextDecoder: ImportedTextDecoder,
|
|
352
|
-
});
|
|
353
|
-
```
|
|
277
|
+
#### ESM modules transpilation
|
|
354
278
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
export default {
|
|
358
|
-
// rest of your config
|
|
359
|
-
setupFilesAfterEnv: ['<rootDir>/.jest/setup/textEncoder.ts'],
|
|
360
|
-
};
|
|
361
|
-
```
|
|
279
|
+
`auth0/nextjs-auth0` and some other transient dependencies are now pure ESM modules. Unfortunately, `jset` still struggles with ESM support, and when using `next/jest` the setup is quite challenging.
|
|
280
|
+
To that end we expose a `@smg-automotive/auth/test/setup` that can whitelist the required ESM modules for transpilation.
|
|
362
281
|
|
|
363
|
-
|
|
282
|
+
```js
|
|
283
|
+
// jest.config.js
|
|
284
|
+
const nextJest = require('next/jest.js');
|
|
285
|
+
const {
|
|
286
|
+
transpileESMModulesForJest,
|
|
287
|
+
} = require('@smg-automotive/auth/test/setup');
|
|
364
288
|
|
|
365
|
-
|
|
366
|
-
// .jest/setup/fetch.ts
|
|
367
|
-
import 'whatwg-fetch';
|
|
368
|
-
```
|
|
289
|
+
const createJestConfig = nextJest({ dir: './' });
|
|
369
290
|
|
|
370
|
-
|
|
371
|
-
// jest
|
|
372
|
-
export default {
|
|
373
|
-
// rest of your config
|
|
374
|
-
setupFilesAfterEnv: ['<rootDir>/.jest/setup/fetch.ts'],
|
|
291
|
+
const customJestConfig = {
|
|
292
|
+
// your custom jest config
|
|
375
293
|
};
|
|
294
|
+
|
|
295
|
+
module.exports = transpileESMModulesForJest(createJestConfig(customJestConfig));
|
|
376
296
|
```
|
|
377
297
|
|
|
378
298
|
#### Ensure you have configuration of the test environment
|
|
@@ -383,7 +303,7 @@ All required [configuration variables](#configuration) need to be set and loaded
|
|
|
383
303
|
|
|
384
304
|
You can link your local npm package to integrate it with any local project:
|
|
385
305
|
|
|
386
|
-
```
|
|
306
|
+
```bash
|
|
387
307
|
cd smg-automotive-auth-pkg
|
|
388
308
|
npm run build
|
|
389
309
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { A as Auth0Config, E as EnrichedSessionUser } from './sessionUser-wavMinWI.js';
|
|
3
|
+
|
|
4
|
+
type AuthProviderProps = {
|
|
5
|
+
auth0Config: Auth0Config;
|
|
6
|
+
user: EnrichedSessionUser | null;
|
|
7
|
+
};
|
|
8
|
+
declare const AuthProvider: FC<PropsWithChildren<AuthProviderProps>>;
|
|
9
|
+
|
|
10
|
+
export { AuthProvider as A };
|
|
11
|
+
export type { AuthProviderProps as a };
|
package/dist/cjs/api/baseUrl.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const apiConfig = {
|
|
4
4
|
apiRoot: process.env.API_ROOT,
|
|
5
5
|
apiVersion: process.env.API_VERSION,
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
const baseUrl = `https://${apiConfig.apiRoot}/${apiConfig.apiVersion}`;
|
|
8
8
|
|
|
9
9
|
exports.baseUrl = baseUrl;
|
|
10
10
|
//# sourceMappingURL=baseUrl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseUrl.js","sources":["../../../../src/api/baseUrl.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"baseUrl.js","sources":["../../../../src/api/baseUrl.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG;AAChB,IAAA,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;AAC7B,IAAA,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;CAC3B;AAEH,MAAM,OAAO,GAAG,CAAA,QAAA,EAAW,SAAS,CAAC,OAAO,CAAA,CAAA,EAAI,SAAS,CAAC,UAAU;;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var apiClientPkg = require('@smg-automotive/api-client-pkg');
|
|
4
4
|
var baseUrl = require('../baseUrl.js');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const entitlementsClient = apiClientPkg.ApiClient({
|
|
7
7
|
baseUrl: baseUrl.baseUrl,
|
|
8
8
|
headers: {
|
|
9
9
|
'Content-Type': 'application/json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../../src/api/entitlements/client.ts"],"sourcesContent":[null],"names":["ApiClient","baseUrl"],"mappings":";;;;;AAkBO,
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../../src/api/entitlements/client.ts"],"sourcesContent":[null],"names":["ApiClient","baseUrl"],"mappings":";;;;;AAkBO,MAAM,kBAAkB,GAE3BA,sBAAS,CAAkC;aAC7CC,eAAO;AACP,IAAA,OAAO,EAAE;AACP,QAAA,cAAc,EAAE,kBAAkB;AACnC,KAAA;AACF,CAAA;;;;"}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
|
|
4
3
|
var client = require('./client.js');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
case 1:
|
|
19
|
-
response = _c.sent();
|
|
20
|
-
if (response.ok) {
|
|
21
|
-
return [2 /*return*/, response.body];
|
|
22
|
-
}
|
|
23
|
-
if (response.status === 404) {
|
|
24
|
-
return [2 /*return*/, null];
|
|
25
|
-
}
|
|
26
|
-
throw new Error(response.statusText);
|
|
27
|
-
}
|
|
5
|
+
const getEntitlements = async ({ sellerId, accessToken, }) => {
|
|
6
|
+
const response = await client.entitlementsClient
|
|
7
|
+
.path('/sellers/{sellerId}/entitlements', { sellerId })
|
|
8
|
+
.get({
|
|
9
|
+
options: {
|
|
10
|
+
accessToken,
|
|
11
|
+
cache: 'force-cache',
|
|
12
|
+
next: {
|
|
13
|
+
revalidate: 3600,
|
|
14
|
+
tags: [`entitlements/${sellerId}`],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
28
17
|
});
|
|
29
|
-
|
|
18
|
+
if (response.ok) {
|
|
19
|
+
return response.body;
|
|
20
|
+
}
|
|
21
|
+
if (response.status === 404) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(response.statusText);
|
|
25
|
+
};
|
|
30
26
|
|
|
31
27
|
exports.getEntitlements = getEntitlements;
|
|
32
28
|
//# sourceMappingURL=getEntitlements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntitlements.js","sources":["../../../../../src/api/entitlements/getEntitlements.ts"],"sourcesContent":[null],"names":["entitlementsClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getEntitlements.js","sources":["../../../../../src/api/entitlements/getEntitlements.ts"],"sourcesContent":[null],"names":["entitlementsClient"],"mappings":";;;;AAEO,MAAM,eAAe,GAAG,OAAO,EACpC,QAAQ,EACR,WAAW,GAIZ,KAAI;IACH,MAAM,QAAQ,GAAG,MAAMA;AACpB,SAAA,IAAI,CAAC,kCAAkC,EAAE,EAAE,QAAQ,EAAE;AACrD,SAAA,GAAG,CAAC;AACH,QAAA,OAAO,EAAE;YACP,WAAW;AACX,YAAA,KAAK,EAAE,aAAa;AACpB,YAAA,IAAI,EAAE;AACJ,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,IAAI,EAAE,CAAC,CAAA,aAAA,EAAgB,QAAQ,EAAE,CAAC;AACnC,aAAA;AACF,SAAA;AACF,KAAA,CAAC;AAEJ,IAAA,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,OAAO,QAAQ,CAAC,IAAI;IACtB;AAEA,IAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;AAC3B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;AACtC;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ApiClient, ClientConfiguration, ResponseType } from '@smg-automotive/api-client-pkg';
|
|
1
|
+
import { ApiClient, ClientConfiguration, RequestType, ResponseType } from '@smg-automotive/api-client-pkg';
|
|
2
2
|
import { Seller } from './types';
|
|
3
3
|
interface SellerClientConfiguration extends ClientConfiguration {
|
|
4
4
|
'sellers/{sellerId}': {
|
|
5
|
-
get: () => ResponseType<never, Seller>;
|
|
5
|
+
get: (data?: RequestType<never, never>) => ResponseType<never, Seller>;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
export declare const sellerClient: ReturnType<typeof ApiClient<SellerClientConfiguration>>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var apiClientPkg = require('@smg-automotive/api-client-pkg');
|
|
4
4
|
var baseUrl = require('../baseUrl.js');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const sellerClient = apiClientPkg.ApiClient({
|
|
7
7
|
baseUrl: baseUrl.baseUrl,
|
|
8
8
|
headers: {
|
|
9
9
|
'Content-Type': 'application/json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../../src/api/seller/client.ts"],"sourcesContent":[null],"names":["ApiClient","baseUrl"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../../src/api/seller/client.ts"],"sourcesContent":[null],"names":["ApiClient","baseUrl"],"mappings":";;;;;AAgBO,MAAM,YAAY,GAErBA,sBAAS,CAA4B;aACvCC,eAAO;AACP,IAAA,OAAO,EAAE;AACP,QAAA,cAAc,EAAE,kBAAkB;AACnC,KAAA;AACF,CAAA;;;;"}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
|
|
4
3
|
var client = require('./client.js');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return [2 /*return*/, response.body];
|
|
20
|
-
}
|
|
21
|
-
if (response.status === 404) {
|
|
22
|
-
return [2 /*return*/, null];
|
|
23
|
-
}
|
|
24
|
-
throw new Error(response.statusText);
|
|
25
|
-
}
|
|
5
|
+
const getSeller = async ({ sellerId }) => {
|
|
6
|
+
const response = await client.sellerClient
|
|
7
|
+
.path('sellers/{sellerId}', {
|
|
8
|
+
sellerId,
|
|
9
|
+
})
|
|
10
|
+
.get({
|
|
11
|
+
options: {
|
|
12
|
+
cache: 'force-cache',
|
|
13
|
+
next: {
|
|
14
|
+
revalidate: 3600,
|
|
15
|
+
tags: [`seller/${sellerId}`],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
26
18
|
});
|
|
27
|
-
|
|
19
|
+
if (response.ok) {
|
|
20
|
+
return response.body;
|
|
21
|
+
}
|
|
22
|
+
if (response.status === 404) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
throw new Error(response.statusText);
|
|
26
|
+
};
|
|
28
27
|
|
|
29
28
|
exports.getSeller = getSeller;
|
|
30
29
|
//# sourceMappingURL=getSeller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeller.js","sources":["../../../../../src/api/seller/getSeller.ts"],"sourcesContent":[null],"names":["sellerClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSeller.js","sources":["../../../../../src/api/seller/getSeller.ts"],"sourcesContent":[null],"names":["sellerClient"],"mappings":";;;;AAEO,MAAM,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAwB,KAAI;IACpE,MAAM,QAAQ,GAAG,MAAMA;SACpB,IAAI,CAAC,oBAAoB,EAAE;QAC1B,QAAQ;KACT;AACA,SAAA,GAAG,CAAC;AACH,QAAA,OAAO,EAAE;AACP,YAAA,KAAK,EAAE,aAAa;AACpB,YAAA,IAAI,EAAE;AACJ,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,IAAI,EAAE,CAAC,CAAA,OAAA,EAAU,QAAQ,EAAE,CAAC;AAC7B,aAAA;AACF,SAAA;AACF,KAAA,CAAC;AAEJ,IAAA,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,OAAO,QAAQ,CAAC,IAAI;IACtB;AAEA,IAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;AAC3B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;AACtC;;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var apiClientPkg = require('@smg-automotive/api-client-pkg');
|
|
4
4
|
var baseUrl = require('../baseUrl.js');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const userClient = apiClientPkg.ApiClient({
|
|
7
7
|
baseUrl: baseUrl.baseUrl,
|
|
8
8
|
headers: {
|
|
9
9
|
'Content-Type': 'application/json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../../src/api/user/client.ts"],"sourcesContent":[null],"names":["ApiClient","baseUrl"],"mappings":";;;;;AAwBO,
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../../src/api/user/client.ts"],"sourcesContent":[null],"names":["ApiClient","baseUrl"],"mappings":";;;;;AAwBO,MAAM,UAAU,GACrBA,sBAAS,CAA0B;aACjCC,eAAO;AACP,IAAA,OAAO,EAAE;AACP,QAAA,cAAc,EAAE,kBAAkB;AACnC,KAAA;AACF,CAAA;;;;"}
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
|
|
4
3
|
var client = require('./client.js');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case 1:
|
|
25
|
-
response = _c.sent();
|
|
26
|
-
if (response.ok) {
|
|
27
|
-
return [2 /*return*/, response.body];
|
|
28
|
-
}
|
|
29
|
-
if (response.status === 404) {
|
|
30
|
-
return [2 /*return*/, null];
|
|
31
|
-
}
|
|
32
|
-
throw new Error(response.statusText);
|
|
33
|
-
}
|
|
5
|
+
const getManagedSellers = async ({ userId, accessToken, }) => {
|
|
6
|
+
const response = await client.userClient
|
|
7
|
+
.path('users/{userId}/sellers', {
|
|
8
|
+
userId,
|
|
9
|
+
})
|
|
10
|
+
.get({
|
|
11
|
+
options: {
|
|
12
|
+
accessToken,
|
|
13
|
+
cache: 'force-cache',
|
|
14
|
+
next: {
|
|
15
|
+
revalidate: 3600,
|
|
16
|
+
tags: [`managed-sellers/${userId}`],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
searchParams: {
|
|
20
|
+
page: 0,
|
|
21
|
+
size: 300,
|
|
22
|
+
},
|
|
34
23
|
});
|
|
35
|
-
|
|
24
|
+
if (response.ok) {
|
|
25
|
+
return response.body;
|
|
26
|
+
}
|
|
27
|
+
if (response.status === 404) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(response.statusText);
|
|
31
|
+
};
|
|
36
32
|
|
|
37
33
|
exports.getManagedSellers = getManagedSellers;
|
|
38
34
|
//# sourceMappingURL=getManagedSellers.js.map
|