@woodsportal/hubspot-kit 1.0.41-dev.4 → 1.0.41-dev.6
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 +7 -0
- package/README.md +191 -157
- package/dist/{chunk-S2YJDWZU.js → chunk-NWBK3XBZ.js} +1 -1
- package/dist/chunk-NWBK3XBZ.js.map +1 -0
- package/dist/chunk-WHYTQEZX.js +554 -0
- package/dist/chunk-WHYTQEZX.js.map +1 -0
- package/dist/cli.js +1494 -650
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/scaffold-page-lifecycle-EHMPWPPE.js +194 -0
- package/dist/scaffold-page-lifecycle-EHMPWPPE.js.map +1 -0
- package/dist/vite/index.js +1 -1
- package/examples/greenfield/module-hybrid-cdn/public/fields.json +73 -28
- package/examples/greenfield/module-hybrid-cdn/public/module.html +21 -5
- package/examples/greenfield/module-hybrid-cdn/src/assets/css/main.dev.css +15 -0
- package/examples/greenfield/module-hybrid-cdn/src/components/layout/starter-nav.tsx +12 -15
- package/examples/greenfield/module-hybrid-cdn/src/config/starter-nav.ts +9 -0
- package/examples/greenfield/module-hybrid-cdn/src/features/starter/components/starter-home.tsx +25 -29
- package/examples/greenfield/module-hybrid-cdn/src/features/starter/hooks/starter-preview-values.ts +60 -0
- package/examples/greenfield/module-hybrid-cdn/src/features/starter/hooks/use-starter-preview.dev.ts +18 -0
- package/examples/greenfield/module-hybrid-cdn/src/features/starter/hooks/use-starter-preview.ts +20 -37
- package/examples/greenfield/module-hybrid-cdn-auth-full/.env.dev.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/.env.local.example +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/.env.prod.example +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/.env.stg.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/.wphs/README.md +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/README.md +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/hubspot.config.yml.example +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/index.html +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/package.json +34 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/portal.cdn.json.example +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/public/fields.json +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/public/meta.json +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/public/module.html +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/app.tsx +172 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/assets/css/main.dev.css +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/assets/css/main.prod.css +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/assets/css/tailwind.css.config.css +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/cdn/app-entry.ts +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/cdn/vendor-entry.ts +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/Layouts/AppLayoutWrapper.tsx +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/Layouts/AuthLayout.tsx +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/Layouts/DefaultLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/Layouts/MainLayout.tsx +42 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/Layouts/UnauthorizedLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/Layouts/index.ts +13 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/layout/section-card.tsx +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/layout/starter-nav.tsx +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/layout/starter-shell.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/Button.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/Form.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/Input.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/Toaster.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/auth/SsoLoginButton.tsx +34 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/link.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/components/ui/loader/loader.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/config/auth-tier.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/config/nav-scaffold.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/config/portal-nav.ts +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/config/router.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/config/routes.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/data/hubSpotContext.ts +57 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/data/sync-sdk-hub-context.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/defaultData.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/env.ts +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/app-bootstrap-guards.ts +14 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/auth-navigation.ts +81 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/auth-route-paths.ts +29 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/auth-session-events.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/auth-session.ts +51 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/clear-client-auth-session.ts +62 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/components/starter-login.tsx +83 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/login-email-storage.ts +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/login-session-bridge.ts +74 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/mfa-otp-utils.ts +24 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/mfa-pending-storage.ts +108 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/mfa-portal.ts +45 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/post-login-path.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/resolve-auth-login-error-message.ts +52 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/resolve-post-login-path.ts +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/sso-callback.ts +120 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/use-mfa-login-otp-flow.ts +78 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/use-portal-session.ts +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/use-signed-in-email.ts +55 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/auth/use-sso-callback-handler.ts +92 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/components/starter-guide-page.tsx +210 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/components/starter-home-page.tsx +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/components/starter-home.tsx +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/components/starter-page-frame.tsx +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/components/starter-protected-page.tsx +54 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/components/starter-single-page.tsx +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/content/auth-guide-content.ts +85 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/content/woodscli-guide-content.ts +86 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/hooks/starter-preview-values.ts +60 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/hooks/use-starter-preview.dev.ts +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/hooks/use-starter-preview.ts +30 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/features/starter/index.ts +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/hubspot/bootstrap.ts +16 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/hubspot/default-data.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/hubspot/is-cms-editor.ts +78 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/hubspot/module-entry.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/hubspot/types.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/integrations/configure-woodsportal-sdk.ts +98 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/integrations/tanstack-query/root-provider.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/integrations/tanstack-router/router.tsx +39 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/integrations/woodsportal-sdk.ts +37 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/main.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/portal/api-endpoint.ts +11 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/portal/ensure-portal-cdn-stylesheet.ts +115 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/portal/mount-dev-preview.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/portal/mount-portal.tsx +57 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routeTree.gen.ts +182 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/__root.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/_app/portal.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/_auth/login/sso.tsx +27 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/_auth/login.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/_auth/two-fa.tsx +91 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/guide.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/index.tsx +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/routes/unauthorized.tsx +50 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/ValidationSchema.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/cookie.ts +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/normalize-router-path.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/private-route.tsx +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/public-route.tsx +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/resolve-api-base-url.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/src/utils/safe-router-navigation.ts +82 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/tsconfig.json +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/vite.config.cdn-app.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/vite.config.cdn-esm.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/vite.config.cdn-vendor.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/vite.config.dev.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/vite.config.hubspot.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/vite.config.monolith.mjs +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/woodscli.json +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-full/wphs.adapter.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/.env.dev.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/.env.local.example +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/.env.prod.example +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/.env.stg.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/.wphs/README.md +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/README.md +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/hubspot.config.yml.example +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/index.html +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/package.json +34 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/portal.cdn.json.example +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/public/fields.json +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/public/meta.json +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/public/module.html +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/app.tsx +180 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/assets/css/main.dev.css +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/assets/css/main.prod.css +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/assets/css/tailwind.css.config.css +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/cdn/app-entry.ts +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/cdn/vendor-entry.ts +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/Layouts/AppLayoutWrapper.tsx +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/Layouts/AuthLayout.tsx +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/Layouts/DefaultLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/Layouts/MainLayout.tsx +42 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/Layouts/UnauthorizedLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/Layouts/index.ts +13 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/layout/section-card.tsx +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/layout/starter-nav.tsx +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/layout/starter-shell.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/Button.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/Form.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/Input.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/Toaster.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/auth/SsoLoginButton.tsx +34 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/link.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/components/ui/loader/loader.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/config/auth-tier.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/config/nav-scaffold.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/config/portal-nav.ts +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/config/router.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/config/routes.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/data/hubSpotContext.ts +57 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/data/sync-sdk-hub-context.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/defaultData.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/env.ts +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/app-bootstrap-guards.ts +14 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/auth-navigation.ts +81 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/auth-route-paths.ts +29 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/auth-session-events.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/auth-session.ts +26 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/clear-client-auth-session.ts +62 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/components/starter-login.tsx +83 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/login-email-storage.ts +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/login-session-bridge.ts +72 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/post-login-path.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/resolve-auth-login-error-message.ts +52 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/resolve-post-login-path.ts +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/sso-callback.ts +120 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/use-portal-session.ts +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/use-signed-in-email.ts +55 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/auth/use-sso-callback-handler.ts +92 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/components/starter-guide-page.tsx +210 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/components/starter-home-page.tsx +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/components/starter-home.tsx +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/components/starter-page-frame.tsx +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/components/starter-protected-page.tsx +54 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/components/starter-single-page.tsx +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/content/auth-guide-content.ts +85 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/content/woodscli-guide-content.ts +86 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/hooks/starter-preview-values.ts +60 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/hooks/use-starter-preview.dev.ts +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/hooks/use-starter-preview.ts +30 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/features/starter/index.ts +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/hubspot/bootstrap.ts +16 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/hubspot/default-data.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/hubspot/is-cms-editor.ts +78 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/hubspot/module-entry.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/hubspot/types.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/integrations/configure-woodsportal-sdk.ts +94 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/integrations/tanstack-query/root-provider.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/integrations/tanstack-router/router.tsx +39 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/integrations/woodsportal-sdk.ts +37 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/main.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/portal/api-endpoint.ts +11 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/portal/ensure-portal-cdn-stylesheet.ts +115 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/portal/mount-dev-preview.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/portal/mount-portal.tsx +57 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routeTree.gen.ts +155 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/__root.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/_app/portal.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/_auth/login/sso.tsx +27 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/_auth/login.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/guide.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/index.tsx +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/routes/unauthorized.tsx +50 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/ValidationSchema.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/cookie.ts +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/normalize-router-path.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/private-route.tsx +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/public-route.tsx +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/resolve-api-base-url.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/src/utils/safe-router-navigation.ts +82 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/tsconfig.json +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/vite.config.cdn-app.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/vite.config.cdn-esm.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/vite.config.cdn-vendor.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/vite.config.dev.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/vite.config.hubspot.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/vite.config.monolith.mjs +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/woodscli.json +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-sso/wphs.adapter.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/.env.dev.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/.env.local.example +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/.env.prod.example +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/.env.stg.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/.wphs/README.md +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/README.md +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/hubspot.config.yml.example +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/index.html +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/package.json +34 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/portal.cdn.json.example +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/public/fields.json +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/public/meta.json +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/public/module.html +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/app.tsx +173 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/assets/css/main.dev.css +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/assets/css/main.prod.css +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/assets/css/tailwind.css.config.css +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/cdn/app-entry.ts +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/cdn/vendor-entry.ts +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/Layouts/AppLayoutWrapper.tsx +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/Layouts/AuthLayout.tsx +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/Layouts/DefaultLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/Layouts/MainLayout.tsx +42 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/Layouts/UnauthorizedLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/Layouts/index.ts +13 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/layout/section-card.tsx +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/layout/starter-nav.tsx +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/layout/starter-shell.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/ui/Button.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/ui/Form.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/ui/Input.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/ui/Toaster.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/ui/link.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/components/ui/loader/loader.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/config/auth-tier.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/config/nav-scaffold.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/config/portal-nav.ts +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/config/router.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/config/routes.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/data/hubSpotContext.ts +57 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/data/sync-sdk-hub-context.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/defaultData.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/env.ts +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/app-bootstrap-guards.ts +14 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/auth-navigation.ts +81 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/auth-route-paths.ts +29 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/auth-session-events.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/auth-session.ts +26 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/clear-client-auth-session.ts +62 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/components/starter-login.tsx +76 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/login-email-storage.ts +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/login-session-bridge.ts +72 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/post-login-path.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/resolve-auth-login-error-message.ts +52 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/resolve-post-login-path.ts +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/use-portal-session.ts +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/auth/use-signed-in-email.ts +55 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/components/starter-guide-page.tsx +218 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/components/starter-home-page.tsx +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/components/starter-home.tsx +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/components/starter-page-frame.tsx +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/components/starter-protected-page.tsx +54 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/components/starter-single-page.tsx +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/content/auth-guide-content.ts +91 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/content/woodscli-guide-content.ts +86 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/hooks/starter-preview-values.ts +60 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/hooks/use-starter-preview.dev.ts +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/hooks/use-starter-preview.ts +30 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/features/starter/index.ts +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/hubspot/bootstrap.ts +16 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/hubspot/default-data.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/hubspot/is-cms-editor.ts +78 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/hubspot/module-entry.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/hubspot/types.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/integrations/configure-woodsportal-sdk.ts +94 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/integrations/tanstack-query/root-provider.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/integrations/tanstack-router/router.tsx +39 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/integrations/woodsportal-sdk.ts +37 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/main.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/portal/api-endpoint.ts +11 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/portal/ensure-portal-cdn-stylesheet.ts +115 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/portal/mount-dev-preview.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/portal/mount-portal.tsx +52 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routeTree.gen.ts +134 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routes/__root.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routes/_app/portal.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routes/_auth/login.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routes/guide.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routes/index.tsx +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/routes/unauthorized.tsx +50 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/ValidationSchema.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/cookie.ts +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/normalize-router-path.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/private-route.tsx +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/public-route.tsx +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/resolve-api-base-url.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/src/utils/safe-router-navigation.ts +82 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/tsconfig.json +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/vite.config.cdn-app.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/vite.config.cdn-esm.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/vite.config.cdn-vendor.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/vite.config.dev.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/vite.config.hubspot.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/vite.config.monolith.mjs +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/woodscli.json +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter/wphs.adapter.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/.env.dev.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/.env.local.example +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/.env.prod.example +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/.env.stg.example +3 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/.wphs/README.md +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/README.md +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/hubspot.config.yml.example +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/index.html +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/package.json +34 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/portal.cdn.json.example +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/public/fields.json +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/public/meta.json +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/public/module.html +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/app.tsx +173 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/assets/css/main.dev.css +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/assets/css/main.prod.css +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/assets/css/tailwind.css.config.css +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/cdn/app-entry.ts +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/cdn/vendor-entry.ts +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/Layouts/AppLayoutWrapper.tsx +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/Layouts/AuthLayout.tsx +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/Layouts/DefaultLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/Layouts/MainLayout.tsx +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/Layouts/UnauthorizedLayout.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/Layouts/index.ts +13 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/layout/portal-sidebar-nav.tsx +33 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/layout/portal-sidebar.tsx +139 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/layout/section-card.tsx +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/layout/starter-nav.tsx +28 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/layout/starter-shell.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/ui/Button.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/ui/Form.tsx +22 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/ui/Input.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/ui/Toaster.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/ui/link.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/components/ui/loader/loader.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/config/auth-tier.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/config/nav-scaffold.ts +4 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/config/portal-nav.ts +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/config/router.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/config/routes.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/data/hubSpotContext.ts +57 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/data/sync-sdk-hub-context.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/defaultData.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/env.ts +59 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/app-bootstrap-guards.ts +14 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/auth-navigation.ts +81 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/auth-route-paths.ts +29 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/auth-session-events.ts +2 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/auth-session.ts +26 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/clear-client-auth-session.ts +62 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/components/starter-login.tsx +76 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/login-email-storage.ts +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/login-session-bridge.ts +72 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/post-login-path.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/resolve-auth-login-error-message.ts +52 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/resolve-post-login-path.ts +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/use-portal-session.ts +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/auth/use-signed-in-email.ts +55 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/components/starter-guide-page.tsx +210 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/components/starter-home-page.tsx +21 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/components/starter-home.tsx +48 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/components/starter-page-frame.tsx +25 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/components/starter-protected-page.tsx +54 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/components/starter-single-page.tsx +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/content/auth-guide-content.ts +85 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/content/woodscli-guide-content.ts +86 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/hooks/starter-preview-values.ts +60 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/hooks/use-starter-preview.dev.ts +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/hooks/use-starter-preview.ts +30 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/features/starter/index.ts +6 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/hubspot/bootstrap.ts +16 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/hubspot/default-data.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/hubspot/is-cms-editor.ts +78 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/hubspot/module-entry.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/hubspot/types.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/integrations/configure-woodsportal-sdk.ts +94 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/integrations/tanstack-query/root-provider.tsx +18 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/integrations/tanstack-router/router.tsx +39 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/integrations/woodsportal-sdk.ts +37 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/main.tsx +5 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/portal/api-endpoint.ts +11 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/portal/ensure-portal-cdn-stylesheet.ts +115 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/portal/mount-dev-preview.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/portal/mount-portal.tsx +52 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routeTree.gen.ts +134 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routes/__root.tsx +12 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routes/_app/portal.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routes/_auth/login.tsx +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routes/guide.tsx +9 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routes/index.tsx +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/routes/unauthorized.tsx +50 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/ValidationSchema.ts +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/cookie.ts +23 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/normalize-router-path.ts +10 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/private-route.tsx +100 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/public-route.tsx +64 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/resolve-api-base-url.ts +44 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/src/utils/safe-router-navigation.ts +82 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/tsconfig.json +20 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/vite.config.cdn-app.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/vite.config.cdn-esm.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/vite.config.cdn-vendor.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/vite.config.dev.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/vite.config.hubspot.mjs +1 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/vite.config.monolith.mjs +8 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/woodscli.json +38 -0
- package/examples/greenfield/module-hybrid-cdn-auth-starter-sidebar/wphs.adapter.ts +7 -0
- package/examples/greenfield/module-monolith/public/fields.json +66 -16
- package/examples/greenfield/module-monolith/src/assets/css/main.dev.css +7 -0
- package/examples/greenfield/module-monolith/src/components/layout/starter-nav.tsx +12 -15
- package/examples/greenfield/module-monolith/src/config/starter-nav.ts +9 -0
- package/examples/greenfield/module-monolith/src/features/starter/components/starter-home.tsx +25 -29
- package/examples/greenfield/module-monolith/src/features/starter/hooks/starter-preview-values.ts +60 -0
- package/examples/greenfield/module-monolith/src/features/starter/hooks/use-starter-preview.dev.ts +18 -0
- package/examples/greenfield/module-monolith/src/features/starter/hooks/use-starter-preview.ts +20 -37
- package/examples/manifest.json +5 -1
- package/examples/smoke/run-matrix.mjs +37 -0
- package/package.json +7 -5
- package/scripts/cli-smoke-helpers.mjs +150 -0
- package/scripts/regenerate-route-tree.mjs +71 -0
- package/scripts/sync-auth-scaffold-from-client.mjs +41 -0
- package/scripts/wp-cli-smoke.test.mjs +263 -0
- package/src/dev/bootstrap-greenfield.tsx +6 -0
- package/templates/module-hybrid-cdn/public/fields.json +47 -7
- package/templates/module-hybrid-cdn/public/module.html +7 -6
- package/templates/module-hybrid-cdn/src/assets/css/main.dev.css +7 -0
- package/templates/module-hybrid-cdn/src/components/layout/starter-nav.tsx +12 -15
- package/templates/module-hybrid-cdn/src/config/starter-nav.ts +9 -0
- package/templates/module-hybrid-cdn/src/features/starter/components/starter-home.tsx +25 -27
- package/templates/module-hybrid-cdn/src/features/starter/hooks/starter-preview-values.ts +5 -5
- package/templates/module-monolith/public/fields.json +49 -6
- package/templates/module-monolith/src/assets/css/main.dev.css +7 -0
- package/templates/module-monolith/src/components/layout/starter-nav.tsx +12 -15
- package/templates/module-monolith/src/config/starter-nav.ts +9 -0
- package/templates/module-monolith/src/features/starter/components/starter-home.tsx +25 -27
- package/templates/module-monolith/src/features/starter/hooks/starter-preview-values.ts +5 -5
- package/templates/scaffold/auth/_full/src/app.tsx +172 -0
- package/templates/scaffold/auth/_full/src/config/auth-tier.ts +4 -0
- package/templates/scaffold/auth/_full/src/features/auth/auth-session.ts +51 -0
- package/templates/scaffold/auth/_full/src/features/auth/login-session-bridge.ts +74 -0
- package/templates/scaffold/auth/_full/src/features/auth/mfa-otp-utils.ts +24 -0
- package/templates/scaffold/auth/_full/src/features/auth/mfa-pending-storage.ts +108 -0
- package/templates/scaffold/auth/_full/src/features/auth/mfa-portal.ts +45 -0
- package/templates/scaffold/auth/_full/src/features/auth/use-mfa-login-otp-flow.ts +78 -0
- package/templates/scaffold/auth/_full/src/routeTree.gen.ts +182 -0
- package/templates/scaffold/auth/_full/src/routes/_auth/two-fa.tsx +91 -0
- package/templates/scaffold/auth/_nav-sidebar/src/components/Layouts/MainLayout.tsx +7 -0
- package/templates/scaffold/auth/_nav-sidebar/src/components/layout/portal-sidebar-nav.tsx +33 -0
- package/templates/scaffold/auth/_nav-sidebar/src/components/layout/portal-sidebar.tsx +139 -0
- package/templates/scaffold/auth/_nav-top/src/components/Layouts/MainLayout.tsx +42 -0
- package/templates/scaffold/auth/_shared/src/app.tsx +178 -0
- package/templates/scaffold/auth/_shared/src/components/Layouts/AppLayoutWrapper.tsx +38 -0
- package/templates/scaffold/auth/_shared/src/components/Layouts/AuthLayout.tsx +7 -0
- package/templates/scaffold/auth/_shared/src/components/Layouts/DefaultLayout.tsx +5 -0
- package/templates/scaffold/auth/_shared/src/components/Layouts/UnauthorizedLayout.tsx +5 -0
- package/templates/scaffold/auth/_shared/src/components/Layouts/index.ts +13 -0
- package/templates/scaffold/auth/_shared/src/components/ui/Button.tsx +22 -0
- package/templates/scaffold/auth/_shared/src/components/ui/Form.tsx +22 -0
- package/templates/scaffold/auth/_shared/src/components/ui/Input.tsx +12 -0
- package/templates/scaffold/auth/_shared/src/components/ui/Toaster.tsx +5 -0
- package/templates/scaffold/auth/_shared/src/components/ui/link.tsx +10 -0
- package/templates/scaffold/auth/_shared/src/components/ui/loader/loader.tsx +18 -0
- package/templates/scaffold/auth/_shared/src/config/auth-tier.ts +4 -0
- package/templates/scaffold/auth/_shared/src/config/nav-scaffold.ts +4 -0
- package/templates/scaffold/auth/_shared/src/config/portal-nav.ts +9 -0
- package/templates/scaffold/auth/_shared/src/config/router.ts +1 -0
- package/templates/scaffold/auth/_shared/src/config/routes.ts +10 -0
- package/templates/scaffold/auth/_shared/src/data/hubSpotContext.ts +57 -0
- package/templates/scaffold/auth/_shared/src/data/sync-sdk-hub-context.ts +44 -0
- package/templates/scaffold/auth/_shared/src/env.ts +59 -0
- package/templates/scaffold/auth/_shared/src/features/auth/app-bootstrap-guards.ts +14 -0
- package/templates/scaffold/auth/_shared/src/features/auth/auth-navigation.ts +81 -0
- package/templates/scaffold/auth/_shared/src/features/auth/auth-route-paths.ts +29 -0
- package/templates/scaffold/auth/_shared/src/features/auth/auth-session-events.ts +2 -0
- package/templates/scaffold/auth/_shared/src/features/auth/auth-session.ts +26 -0
- package/templates/scaffold/auth/_shared/src/features/auth/clear-client-auth-session.ts +62 -0
- package/templates/scaffold/auth/_shared/src/features/auth/components/starter-login.tsx +76 -0
- package/templates/scaffold/auth/_shared/src/features/auth/login-email-storage.ts +64 -0
- package/templates/scaffold/auth/_shared/src/features/auth/login-session-bridge.ts +72 -0
- package/templates/scaffold/auth/_shared/src/features/auth/post-login-path.ts +17 -0
- package/templates/scaffold/auth/_shared/src/features/auth/resolve-auth-login-error-message.ts +52 -0
- package/templates/scaffold/auth/_shared/src/features/auth/resolve-post-login-path.ts +21 -0
- package/templates/scaffold/auth/_shared/src/features/auth/use-portal-session.ts +25 -0
- package/templates/scaffold/auth/_shared/src/features/auth/use-signed-in-email.ts +55 -0
- package/templates/scaffold/auth/_shared/src/features/starter/components/starter-guide-page.tsx +218 -0
- package/templates/scaffold/auth/_shared/src/features/starter/components/starter-page-frame.tsx +25 -0
- package/templates/scaffold/auth/_shared/src/features/starter/components/starter-protected-page.tsx +54 -0
- package/templates/scaffold/auth/_shared/src/features/starter/content/auth-guide-content.ts +91 -0
- package/templates/scaffold/auth/_shared/src/hubspot/is-cms-editor.ts +78 -0
- package/templates/scaffold/auth/_shared/src/integrations/configure-woodsportal-sdk.ts +100 -0
- package/templates/scaffold/auth/_shared/src/integrations/tanstack-query/root-provider.tsx +18 -0
- package/templates/scaffold/auth/_shared/src/integrations/tanstack-router/router.tsx +39 -0
- package/templates/scaffold/auth/_shared/src/integrations/woodsportal-sdk.ts +37 -0
- package/templates/scaffold/auth/_shared/src/portal/mount-portal.tsx +59 -0
- package/templates/scaffold/auth/_shared/src/routeTree.gen.ts +134 -0
- package/templates/scaffold/auth/_shared/src/routes/__root.tsx +12 -0
- package/templates/scaffold/auth/_shared/src/routes/_app/portal.tsx +10 -0
- package/templates/scaffold/auth/_shared/src/routes/_auth/login.tsx +10 -0
- package/templates/scaffold/auth/_shared/src/routes/guide.tsx +9 -0
- package/templates/scaffold/auth/_shared/src/routes/index.tsx +8 -0
- package/templates/scaffold/auth/_shared/src/routes/unauthorized.tsx +50 -0
- package/templates/scaffold/auth/_shared/src/utils/ValidationSchema.ts +1 -0
- package/templates/scaffold/auth/_shared/src/utils/cookie.ts +23 -0
- package/templates/scaffold/auth/_shared/src/utils/normalize-router-path.ts +10 -0
- package/templates/scaffold/auth/_shared/src/utils/private-route.tsx +100 -0
- package/templates/scaffold/auth/_shared/src/utils/public-route.tsx +64 -0
- package/templates/scaffold/auth/_shared/src/utils/resolve-api-base-url.ts +44 -0
- package/templates/scaffold/auth/_shared/src/utils/safe-router-navigation.ts +82 -0
- package/templates/scaffold/auth/_sso/src/app.tsx +180 -0
- package/templates/scaffold/auth/_sso/src/components/ui/auth/SsoLoginButton.tsx +34 -0
- package/templates/scaffold/auth/_sso/src/config/auth-tier.ts +4 -0
- package/templates/scaffold/auth/_sso/src/features/auth/components/starter-login.tsx +83 -0
- package/templates/scaffold/auth/_sso/src/features/auth/sso-callback.ts +120 -0
- package/templates/scaffold/auth/_sso/src/features/auth/use-sso-callback-handler.ts +92 -0
- package/templates/scaffold/auth/_sso/src/routeTree.gen.ts +155 -0
- package/templates/scaffold/auth/_sso/src/routes/_auth/login/sso.tsx +27 -0
- package/templates/scaffold/auth/nav-manifest.json +8 -0
- package/templates/scaffold/auth/sync-manifest.json +16 -0
- package/templates/scaffold/auth/tier-manifest.json +18 -0
- package/templates/scaffold/page/page-component-auth.tsx.tpl +10 -0
- package/templates/scaffold/page/page-component-plain.tsx.tpl +11 -0
- package/templates/scaffold/page/route-protected-auth.tsx.tpl +10 -0
- package/templates/scaffold/page/route-public-auth.tsx.tpl +9 -0
- package/templates/scaffold/page/route-public-plain.tsx.tpl +6 -0
- package/dist/chunk-S2YJDWZU.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createEnv } from '@t3-oss/env-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
const defaultHubspotObjectIds =
|
|
5
|
+
'{"contacts":"0-1","companies":"0-2","deals":"0-3","tickets":"0-5"}'
|
|
6
|
+
|
|
7
|
+
export function parseHubspotDefaultObjectIds(raw: unknown): Record<string, string> {
|
|
8
|
+
if (typeof raw === 'object' && raw !== null && !Array.isArray(raw)) {
|
|
9
|
+
return raw as Record<string, string>
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(String(raw ?? defaultHubspotObjectIds))
|
|
13
|
+
} catch {
|
|
14
|
+
return JSON.parse(defaultHubspotObjectIds)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const env = createEnv({
|
|
19
|
+
server: {
|
|
20
|
+
SERVER_URL: z.string().url().optional(),
|
|
21
|
+
},
|
|
22
|
+
clientPrefix: 'VITE_',
|
|
23
|
+
client: {
|
|
24
|
+
VITE_NODE_ENV: z.enum(['local', 'dev', 'prod', 'stg', 'development', 'production', 'staging']).default('local'),
|
|
25
|
+
VITE_PUBLIC_REST_API_ENDPOINT: z
|
|
26
|
+
.string()
|
|
27
|
+
.url()
|
|
28
|
+
.default('https://api.dev.woodsportal.com'),
|
|
29
|
+
VITE_DEV_PORTAL_ID: z.union([z.string(), z.number()]).optional(),
|
|
30
|
+
VITE_LOCAL_HUB_ID: z.union([z.string(), z.number()]).optional(),
|
|
31
|
+
VITE_DEV_HUB_ID: z.union([z.string(), z.number()]).optional(),
|
|
32
|
+
VITE_LOGIN_DETAILS: z.string().default('wp.c.auth.login'),
|
|
33
|
+
VITE_SUBSCRIPTION_TYPE: z.string().default('wp.c.auth.sub'),
|
|
34
|
+
VITE_PAGINATION_DATA: z.string().default('wp.c.ui.pag'),
|
|
35
|
+
VITE_PORTAL: z.string().default('wp.c.auth.portal'),
|
|
36
|
+
VITE_AUTH_TOKEN_KEY: z.string().default('woodsportal_access_token'),
|
|
37
|
+
VITE_REFRESH_TOKEN: z.string().default('wp.c.auth.refresh'),
|
|
38
|
+
VITE_AUTH_USER_KEY: z.string().default('wp.c.auth.login'),
|
|
39
|
+
VITE_ROUTE_MENU_CONFIG_KEY: z.string().default('wp.c.ui.menu'),
|
|
40
|
+
VITE_ASSOCIATION_VIEW_URL_KEY: z.string().default('wp.c.ui.assoc'),
|
|
41
|
+
VITE_COOKIE_EXPIRE: z.string().default('7'),
|
|
42
|
+
VITE_TABLE_PAGE_LIMIT: z.string().default('25'),
|
|
43
|
+
VITE_HUBSPOT_DEFAULT_OBJECT_IDS: z.any().default(defaultHubspotObjectIds),
|
|
44
|
+
},
|
|
45
|
+
runtimeEnv: import.meta.env,
|
|
46
|
+
emptyStringAsUndefined: true,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export const TABLE_PAGE_LIMIT = Math.max(
|
|
50
|
+
1,
|
|
51
|
+
Number.parseInt(env.VITE_TABLE_PAGE_LIMIT, 10) || 25,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
export const HUBSPOT_DEFAULT_OBJECT_IDS = parseHubspotDefaultObjectIds(
|
|
55
|
+
env.VITE_HUBSPOT_DEFAULT_OBJECT_IDS,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
export const isLocal =
|
|
59
|
+
env.VITE_NODE_ENV === 'local' || env.VITE_NODE_ENV === 'development'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type BootstrapRefreshDecisionInput = {
|
|
2
|
+
isMfaPendingSession: boolean
|
|
3
|
+
hasRefresh: boolean
|
|
4
|
+
isPublicAuthRoute: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function shouldBootstrapRefreshSession(
|
|
8
|
+
input: BootstrapRefreshDecisionInput,
|
|
9
|
+
): boolean {
|
|
10
|
+
if (input.isMfaPendingSession || input.isPublicAuthRoute) {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
return input.hasRefresh
|
|
14
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Routes } from '@/config/routes'
|
|
2
|
+
import { normalizeRouterPath } from '@/utils/normalize-router-path'
|
|
3
|
+
import {
|
|
4
|
+
hardReplaceToHashPath,
|
|
5
|
+
historyReplaceFirstNavigate,
|
|
6
|
+
readHashPathname,
|
|
7
|
+
readRouterPathname,
|
|
8
|
+
type SafeAuthRouter,
|
|
9
|
+
} from '@/utils/safe-router-navigation'
|
|
10
|
+
import { resolvePostLoginPath, type PostLoginRouter } from '@/features/auth/resolve-post-login-path'
|
|
11
|
+
|
|
12
|
+
export type AuthNavigationRouter = PostLoginRouter
|
|
13
|
+
|
|
14
|
+
let navigationState = {
|
|
15
|
+
inFlight: false,
|
|
16
|
+
lastTarget: '',
|
|
17
|
+
lastAt: 0,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function normalizeTarget(path: string): string {
|
|
21
|
+
return normalizeRouterPath(path)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isRouterAtPath(router: SafeAuthRouter, path: string): boolean {
|
|
25
|
+
const target = normalizeTarget(path)
|
|
26
|
+
const pathname = normalizeTarget(readRouterPathname(router))
|
|
27
|
+
const hashPath = normalizeTarget(readHashPathname())
|
|
28
|
+
return pathname === target && hashPath === target
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function shouldSkipNavigation(target: string): boolean {
|
|
32
|
+
const now = Date.now()
|
|
33
|
+
return (
|
|
34
|
+
navigationState.inFlight ||
|
|
35
|
+
(navigationState.lastTarget === target && now - navigationState.lastAt < 2000)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function runCoordinatedNavigation(router: SafeAuthRouter, rawTarget: string): Promise<void> {
|
|
40
|
+
const target = normalizeTarget(rawTarget)
|
|
41
|
+
if (!target || isRouterAtPath(router, target) || shouldSkipNavigation(target)) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
navigationState = { inFlight: true, lastTarget: target, lastAt: Date.now() }
|
|
45
|
+
try {
|
|
46
|
+
await historyReplaceFirstNavigate(router, target)
|
|
47
|
+
await new Promise<void>((resolve) => window.setTimeout(resolve, 100))
|
|
48
|
+
if (!isRouterAtPath(router, target)) {
|
|
49
|
+
hardReplaceToHashPath(target)
|
|
50
|
+
}
|
|
51
|
+
} finally {
|
|
52
|
+
navigationState = { inFlight: false, lastTarget: target, lastAt: Date.now() }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function navigateAfterFullAuth(router: AuthNavigationRouter, target?: string): void {
|
|
57
|
+
const resolved = target ?? resolvePostLoginPath(router)
|
|
58
|
+
if (isRouterAtPath(router, resolved)) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
void runCoordinatedNavigation(router, resolved)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function navigateToMfaGate(router: SafeAuthRouter): void {
|
|
65
|
+
if (isRouterAtPath(router, Routes.twoFa)) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
void runCoordinatedNavigation(router, Routes.twoFa)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function navigateToLogin(router: SafeAuthRouter, path: string = Routes.login): Promise<void> {
|
|
72
|
+
const target = normalizeTarget(path)
|
|
73
|
+
if (isRouterAtPath(router, target)) {
|
|
74
|
+
return Promise.resolve()
|
|
75
|
+
}
|
|
76
|
+
return runCoordinatedNavigation(router, target)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function resetAuthNavigationState(): void {
|
|
80
|
+
navigationState = { inFlight: false, lastTarget: '', lastAt: 0 }
|
|
81
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Routes } from '@/config/routes'
|
|
2
|
+
import { normalizeRouterPath } from '@/utils/normalize-router-path'
|
|
3
|
+
|
|
4
|
+
const PUBLIC_AUTH_PATHS = new Set<string>([
|
|
5
|
+
Routes.login,
|
|
6
|
+
Routes.twoFa,
|
|
7
|
+
Routes.unauthorized,
|
|
8
|
+
Routes.ssoLogin,
|
|
9
|
+
])
|
|
10
|
+
|
|
11
|
+
export function readHashPathname(): string {
|
|
12
|
+
if (typeof window === 'undefined') {
|
|
13
|
+
return Routes.app
|
|
14
|
+
}
|
|
15
|
+
const segment = window.location.hash.replace(/^#/, '').split('?')[0] || Routes.app
|
|
16
|
+
return normalizeRouterPath(segment.startsWith('/') ? segment : `/${segment}`)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isPublicAuthRoute(pathname: string): boolean {
|
|
20
|
+
const normalized = normalizeRouterPath(pathname)
|
|
21
|
+
if (PUBLIC_AUTH_PATHS.has(normalized)) {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
return normalized.startsWith('/login')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isProtectedHashPath(): boolean {
|
|
28
|
+
return !isPublicAuthRoute(readHashPathname())
|
|
29
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { api } from '@/integrations/woodsportal-sdk'
|
|
2
|
+
import { AUTH_SESSION_CHANGED } from '@/features/auth/auth-session-events'
|
|
3
|
+
|
|
4
|
+
/** Starter tier: no MFA gate — always false until _full layer overrides. */
|
|
5
|
+
export function isMfaPendingSession(): boolean {
|
|
6
|
+
return false
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Full portal session (starter tier: SDK fully authenticated). */
|
|
10
|
+
export function isFullyAuthenticatedSession(): boolean {
|
|
11
|
+
return api.auth.session.isFullyAuthenticated()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function clearMfaPendingLoginSession(): void {
|
|
15
|
+
api.auth.session.clearAccessToken()
|
|
16
|
+
if (typeof window !== 'undefined') {
|
|
17
|
+
window.dispatchEvent(new CustomEvent(AUTH_SESSION_CHANGED))
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type MfaBootRecoveryResult = 'pending' | 'orphan_cleared' | 'stale_token_cleared' | 'none'
|
|
22
|
+
|
|
23
|
+
/** Starter tier: no MFA recovery on boot. _full layer replaces this module. */
|
|
24
|
+
export async function recoverMfaGateOnBoot(): Promise<MfaBootRecoveryResult> {
|
|
25
|
+
return 'none'
|
|
26
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearClientIframeRefreshLocalKeys,
|
|
3
|
+
clearClientSessionStorageKeys,
|
|
4
|
+
resetSessionStores,
|
|
5
|
+
signalSessionChanged,
|
|
6
|
+
WP_STORAGE_KEYS,
|
|
7
|
+
} from 'woodsportal-client-sdk'
|
|
8
|
+
import { api } from '@/integrations/woodsportal-sdk'
|
|
9
|
+
import { clearClientAuthCookies } from '@/utils/cookie'
|
|
10
|
+
import {
|
|
11
|
+
captureLoginEmailBeforeSessionClear,
|
|
12
|
+
clearLoginPreAuthSession,
|
|
13
|
+
extractLoginEmailFromPayload,
|
|
14
|
+
getStoredLoginEmail,
|
|
15
|
+
} from '@/features/auth/login-email-storage'
|
|
16
|
+
import { clearMfaPendingLoginSession } from '@/features/auth/auth-session'
|
|
17
|
+
import { AUTH_SESSION_CHANGED } from '@/features/auth/auth-session-events'
|
|
18
|
+
|
|
19
|
+
let queryCacheClearHandler: (() => void) | undefined
|
|
20
|
+
|
|
21
|
+
export function registerClientSessionQueryClear(handler: () => void): void {
|
|
22
|
+
queryCacheClearHandler = handler
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function clearClientAuthSession(options?: { signalCrossTab?: boolean }): void {
|
|
26
|
+
captureLoginEmailBeforeSessionClear(() => {
|
|
27
|
+
const details = api.auth.session.getLoggedInDetails?.() as Record<string, unknown> | undefined
|
|
28
|
+
return (
|
|
29
|
+
extractLoginEmailFromPayload(details) ??
|
|
30
|
+
extractLoginEmailFromPayload({ email: getStoredLoginEmail() }) ??
|
|
31
|
+
undefined
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
clearClientAuthCookies()
|
|
36
|
+
clearMfaPendingLoginSession()
|
|
37
|
+
clearLoginPreAuthSession()
|
|
38
|
+
clearClientSessionStorageKeys()
|
|
39
|
+
clearClientIframeRefreshLocalKeys()
|
|
40
|
+
try {
|
|
41
|
+
window.localStorage?.removeItem(WP_STORAGE_KEYS.c.auth.refreshLock)
|
|
42
|
+
} catch {
|
|
43
|
+
// ignore
|
|
44
|
+
}
|
|
45
|
+
api.auth.session.clearAccessToken()
|
|
46
|
+
resetSessionStores()
|
|
47
|
+
api.auth.session.resetSessionAuthState()
|
|
48
|
+
api.auth.session.clearSessionRefreshExhaustedState?.()
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
queryCacheClearHandler?.()
|
|
52
|
+
} catch {
|
|
53
|
+
// ignore
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof window !== 'undefined') {
|
|
57
|
+
if (options?.signalCrossTab !== false) {
|
|
58
|
+
signalSessionChanged('rev')
|
|
59
|
+
}
|
|
60
|
+
window.dispatchEvent(new CustomEvent(AUTH_SESSION_CHANGED))
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { useRouter } from '@tanstack/react-router'
|
|
3
|
+
import { toast } from 'sonner'
|
|
4
|
+
import { Button } from '@/components/ui/Button'
|
|
5
|
+
import { Form, FormField } from '@/components/ui/Form'
|
|
6
|
+
import { Input } from '@/components/ui/Input'
|
|
7
|
+
import { api } from '@/integrations/woodsportal-sdk'
|
|
8
|
+
import { handleAuthLoginResponse, MFA_REQUIRED_SCAFFOLD_MESSAGE } from '@/features/auth/login-session-bridge'
|
|
9
|
+
import { resolveAuthLoginErrorMessage } from '@/features/auth/resolve-auth-login-error-message'
|
|
10
|
+
import {
|
|
11
|
+
getStoredLoginEmail,
|
|
12
|
+
setStoredLoginEmail,
|
|
13
|
+
} from '@/features/auth/login-email-storage'
|
|
14
|
+
|
|
15
|
+
export function StarterLogin() {
|
|
16
|
+
const router = useRouter()
|
|
17
|
+
const [email, setEmail] = useState(getStoredLoginEmail() ?? '')
|
|
18
|
+
const [password, setPassword] = useState('')
|
|
19
|
+
const [isSubmitting, setIsSubmitting] = useState(false)
|
|
20
|
+
|
|
21
|
+
const onSubmit = async (event: React.FormEvent) => {
|
|
22
|
+
event.preventDefault()
|
|
23
|
+
setIsSubmitting(true)
|
|
24
|
+
try {
|
|
25
|
+
setStoredLoginEmail(email)
|
|
26
|
+
const { login } = api.auth.login({})
|
|
27
|
+
const response = await login({ username: email.trim(), password })
|
|
28
|
+
const result = await handleAuthLoginResponse(response, router)
|
|
29
|
+
if (!result.success) {
|
|
30
|
+
if (result.reason === 'mfa_required') {
|
|
31
|
+
toast.error(MFA_REQUIRED_SCAFFOLD_MESSAGE)
|
|
32
|
+
} else {
|
|
33
|
+
toast.error('Login failed — no access token returned.')
|
|
34
|
+
}
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
if (!result.mfaRequired) {
|
|
38
|
+
toast.success('Signed in')
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
toast.error(resolveAuthLoginErrorMessage(error))
|
|
42
|
+
} finally {
|
|
43
|
+
setIsSubmitting(false)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="w-full max-w-md rounded-lg border border-gray-200 bg-white p-6 shadow-sm">
|
|
49
|
+
<h1 className="mb-2 text-xl font-semibold text-gray-900">Sign in</h1>
|
|
50
|
+
<p className="mb-6 text-sm text-gray-600">Use your portal email and password.</p>
|
|
51
|
+
<Form onSubmit={onSubmit}>
|
|
52
|
+
<FormField label="Email">
|
|
53
|
+
<Input
|
|
54
|
+
type="email"
|
|
55
|
+
autoComplete="email"
|
|
56
|
+
required
|
|
57
|
+
value={email}
|
|
58
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
59
|
+
/>
|
|
60
|
+
</FormField>
|
|
61
|
+
<FormField label="Password">
|
|
62
|
+
<Input
|
|
63
|
+
type="password"
|
|
64
|
+
autoComplete="current-password"
|
|
65
|
+
required
|
|
66
|
+
value={password}
|
|
67
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
68
|
+
/>
|
|
69
|
+
</FormField>
|
|
70
|
+
<Button type="submit" className="w-full" disabled={isSubmitting}>
|
|
71
|
+
{isSubmitting ? 'Signing in…' : 'Sign in'}
|
|
72
|
+
</Button>
|
|
73
|
+
</Form>
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { WP_STORAGE_KEYS } from 'woodsportal-client-sdk'
|
|
2
|
+
|
|
3
|
+
const LOGIN_EMAIL_KEY = WP_STORAGE_KEYS.c.login.email
|
|
4
|
+
|
|
5
|
+
function isValidEmail(value: string): boolean {
|
|
6
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim())
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function extractLoginEmailFromPayload(
|
|
10
|
+
payload: Record<string, unknown> | null | undefined,
|
|
11
|
+
): string | null {
|
|
12
|
+
if (!payload || typeof payload !== 'object') {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
const loggedInDetails = payload.loggedInDetails
|
|
16
|
+
if (loggedInDetails && typeof loggedInDetails === 'object') {
|
|
17
|
+
const email = (loggedInDetails as Record<string, unknown>).email
|
|
18
|
+
if (typeof email === 'string' && isValidEmail(email)) {
|
|
19
|
+
return email.trim().toLowerCase()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (const key of ['email', 'username'] as const) {
|
|
23
|
+
const value = payload[key]
|
|
24
|
+
if (typeof value === 'string' && isValidEmail(value)) {
|
|
25
|
+
return value.trim().toLowerCase()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function captureLoginEmailBeforeSessionClear(
|
|
32
|
+
resolveLoggedInEmail?: () => string | null | undefined,
|
|
33
|
+
): void {
|
|
34
|
+
if (getStoredLoginEmail()) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const email = resolveLoggedInEmail?.()
|
|
38
|
+
if (email) {
|
|
39
|
+
setStoredLoginEmail(email)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getStoredLoginEmail(): string | null {
|
|
44
|
+
if (typeof window === 'undefined') {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
const stored = sessionStorage.getItem(LOGIN_EMAIL_KEY)?.trim().toLowerCase() ?? ''
|
|
48
|
+
return stored && isValidEmail(stored) ? stored : null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function setStoredLoginEmail(email: string): void {
|
|
52
|
+
if (typeof window === 'undefined') {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
const normalized = email.trim().toLowerCase()
|
|
56
|
+
if (!isValidEmail(normalized)) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
sessionStorage.setItem(LOGIN_EMAIL_KEY, normalized)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function clearLoginPreAuthSession(): void {
|
|
63
|
+
// starter scaffold: no pre-login passkey state
|
|
64
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { api } from '@/integrations/woodsportal-sdk'
|
|
2
|
+
import {
|
|
3
|
+
navigateAfterFullAuth,
|
|
4
|
+
type AuthNavigationRouter,
|
|
5
|
+
} from '@/features/auth/auth-navigation'
|
|
6
|
+
import { resolvePostLoginPath } from '@/features/auth/resolve-post-login-path'
|
|
7
|
+
import { AUTH_SESSION_CHANGED } from '@/features/auth/auth-session-events'
|
|
8
|
+
import { signalSessionChanged } from 'woodsportal-client-sdk'
|
|
9
|
+
import {
|
|
10
|
+
extractLoginEmailFromPayload,
|
|
11
|
+
setStoredLoginEmail,
|
|
12
|
+
} from '@/features/auth/login-email-storage'
|
|
13
|
+
|
|
14
|
+
function notifyAuthSessionChanged(): void {
|
|
15
|
+
if (typeof window === 'undefined') return
|
|
16
|
+
signalSessionChanged('login')
|
|
17
|
+
window.dispatchEvent(new CustomEvent(AUTH_SESSION_CHANGED))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type AuthRouter = AuthNavigationRouter
|
|
21
|
+
|
|
22
|
+
function unwrapLoginPayload(
|
|
23
|
+
response: { data?: Record<string, unknown>; statusMsg?: string } | Record<string, unknown>,
|
|
24
|
+
): Record<string, unknown> {
|
|
25
|
+
return (response?.data ?? response ?? {}) as Record<string, unknown>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type HandleAuthLoginResponseOptions = {
|
|
29
|
+
clearPreHashQuery?: () => void
|
|
30
|
+
onSubscriptionType?: (subscriptionType: string) => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type HandleAuthLoginResponseResult =
|
|
34
|
+
| { success: false; reason: 'no_token' | 'mfa_required' }
|
|
35
|
+
| { success: true; mfaRequired: true }
|
|
36
|
+
| { success: true; mfaRequired: false }
|
|
37
|
+
|
|
38
|
+
/** Shown when the hub requires MFA but the project used `--auth starter` or `sso`. */
|
|
39
|
+
export const MFA_REQUIRED_SCAFFOLD_MESSAGE =
|
|
40
|
+
'This hub requires MFA. Re-init with wp init --auth full (see docs/AUTH-SCAFFOLD.md).'
|
|
41
|
+
|
|
42
|
+
export async function handleAuthLoginResponse(
|
|
43
|
+
response: { data?: Record<string, unknown>; statusMsg?: string } | Record<string, unknown>,
|
|
44
|
+
router: AuthRouter,
|
|
45
|
+
options: HandleAuthLoginResponseOptions = {},
|
|
46
|
+
): Promise<HandleAuthLoginResponseResult> {
|
|
47
|
+
const data = unwrapLoginPayload(response)
|
|
48
|
+
const tokenData = (data.tokenData ?? {}) as { token?: string }
|
|
49
|
+
const sessionToken = api.auth.session.getAccessToken()
|
|
50
|
+
const token = tokenData.token ?? sessionToken ?? undefined
|
|
51
|
+
|
|
52
|
+
if (!token) {
|
|
53
|
+
return { success: false, reason: 'no_token' }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const loginEmail = extractLoginEmailFromPayload(data)
|
|
57
|
+
if (loginEmail) {
|
|
58
|
+
setStoredLoginEmail(loginEmail)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (data.twoFactorRequired === true) {
|
|
62
|
+
return { success: false, reason: 'mfa_required' }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const loggedInDetails = (data.loggedInDetails ?? {}) as { subscriptionType?: string }
|
|
66
|
+
options.onSubscriptionType?.(loggedInDetails.subscriptionType ?? 'BASIC')
|
|
67
|
+
|
|
68
|
+
options.clearPreHashQuery?.()
|
|
69
|
+
notifyAuthSessionChanged()
|
|
70
|
+
navigateAfterFullAuth(router, resolvePostLoginPath(router))
|
|
71
|
+
return { success: true, mfaRequired: false }
|
|
72
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Routes } from '@/config/routes'
|
|
2
|
+
import { normalizeRouterPath } from '@/utils/normalize-router-path'
|
|
3
|
+
|
|
4
|
+
const AUTH_RETURN_PATHS = new Set<string>([
|
|
5
|
+
Routes.login,
|
|
6
|
+
Routes.twoFa,
|
|
7
|
+
Routes.unauthorized,
|
|
8
|
+
Routes.ssoLogin,
|
|
9
|
+
])
|
|
10
|
+
|
|
11
|
+
export function isBlockedPostLoginPath(path: string): boolean {
|
|
12
|
+
const normalized = normalizeRouterPath(path)
|
|
13
|
+
if (AUTH_RETURN_PATHS.has(normalized)) {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
return normalized.startsWith('/login')
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const GENERIC_AUTH_FAILED_MESSAGES = new Set([
|
|
2
|
+
'Authentication Failed',
|
|
3
|
+
'Invalid credentials provided.',
|
|
4
|
+
])
|
|
5
|
+
|
|
6
|
+
type LoginErrorPayload = {
|
|
7
|
+
errorCode?: unknown
|
|
8
|
+
errorMessage?: unknown
|
|
9
|
+
validationErrors?: unknown
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function extractFirstValidationMessage(validationErrors: unknown): string | null {
|
|
13
|
+
if (validationErrors == null || typeof validationErrors !== 'object') {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
const first = Object.values(validationErrors as Record<string, unknown>)[0]
|
|
17
|
+
if (typeof first === 'string') {
|
|
18
|
+
return first
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(first) && typeof first[0] === 'string') {
|
|
21
|
+
return first[0]
|
|
22
|
+
}
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resolveAuthLoginErrorMessage(error: unknown): string {
|
|
27
|
+
const fallback = 'Wrong email or password'
|
|
28
|
+
if (error == null || typeof error !== 'object') {
|
|
29
|
+
return fallback
|
|
30
|
+
}
|
|
31
|
+
const data = (error as { response?: { data?: LoginErrorPayload } }).response?.data
|
|
32
|
+
if (!data) {
|
|
33
|
+
return fallback
|
|
34
|
+
}
|
|
35
|
+
const validationMessage = extractFirstValidationMessage(data.validationErrors)
|
|
36
|
+
if (validationMessage) {
|
|
37
|
+
return validationMessage
|
|
38
|
+
}
|
|
39
|
+
const errorCode = typeof data.errorCode === 'string' ? data.errorCode : undefined
|
|
40
|
+
const errorMessage =
|
|
41
|
+
typeof data.errorMessage === 'string' ? data.errorMessage.trim() : ''
|
|
42
|
+
if (!errorMessage) {
|
|
43
|
+
return fallback
|
|
44
|
+
}
|
|
45
|
+
if (
|
|
46
|
+
errorCode === 'AUTHENTICATION_FAILED' &&
|
|
47
|
+
GENERIC_AUTH_FAILED_MESSAGES.has(errorMessage)
|
|
48
|
+
) {
|
|
49
|
+
return fallback
|
|
50
|
+
}
|
|
51
|
+
return errorMessage
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Routes } from '@/config/routes'
|
|
2
|
+
import { isBlockedPostLoginPath } from '@/features/auth/post-login-path'
|
|
3
|
+
import { normalizeRouterPath } from '@/utils/normalize-router-path'
|
|
4
|
+
import type { SafeAuthRouter } from '@/utils/safe-router-navigation'
|
|
5
|
+
|
|
6
|
+
export type PostLoginRouter = SafeAuthRouter & {
|
|
7
|
+
state: {
|
|
8
|
+
location?: {
|
|
9
|
+
search?: { r?: string; [key: string]: string | undefined }
|
|
10
|
+
pathname?: string
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function resolvePostLoginPath(router: PostLoginRouter): string {
|
|
16
|
+
const redirect = router.state.location?.search?.r
|
|
17
|
+
if (redirect && !isBlockedPostLoginPath(String(redirect))) {
|
|
18
|
+
return normalizeRouterPath(String(redirect))
|
|
19
|
+
}
|
|
20
|
+
return Routes.portal
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
+
import { AUTH_SESSION_CHANGED } from '@/features/auth/auth-session-events'
|
|
3
|
+
import { isFullyAuthenticatedSession, isMfaPendingSession } from '@/features/auth/auth-session'
|
|
4
|
+
|
|
5
|
+
function useAuthSessionRevision(): number {
|
|
6
|
+
const [revision, setRevision] = useState(0)
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const bump = () => setRevision((value) => value + 1)
|
|
9
|
+
window.addEventListener(AUTH_SESSION_CHANGED, bump)
|
|
10
|
+
return () => window.removeEventListener(AUTH_SESSION_CHANGED, bump)
|
|
11
|
+
}, [])
|
|
12
|
+
return revision
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useAuthSessionRevision }
|
|
16
|
+
|
|
17
|
+
export function usePortalSession(): boolean {
|
|
18
|
+
const revision = useAuthSessionRevision()
|
|
19
|
+
return useMemo(() => isFullyAuthenticatedSession(), [revision])
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useIsMfaPendingSession(): boolean {
|
|
23
|
+
const revision = useAuthSessionRevision()
|
|
24
|
+
return useMemo(() => isMfaPendingSession(), [revision])
|
|
25
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { api } from '@/integrations/woodsportal-sdk'
|
|
4
|
+
import { getStoredLoginEmail } from '@/features/auth/login-email-storage'
|
|
5
|
+
import { usePortalSession } from '@/features/auth/use-portal-session'
|
|
6
|
+
|
|
7
|
+
function readEmailFromProfile(data: unknown): string | null {
|
|
8
|
+
if (data == null || typeof data !== 'object') {
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
const root = data as Record<string, unknown>
|
|
12
|
+
const profile = (root.data ?? root) as Record<string, unknown>
|
|
13
|
+
const email = profile.email
|
|
14
|
+
return typeof email === 'string' && email.trim() !== '' ? email.trim() : null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function useSignedInEmail(): { email: string | null; isLoading: boolean } {
|
|
18
|
+
const isAuthenticated = usePortalSession()
|
|
19
|
+
const [email, setEmail] = useState<string | null>(() => getStoredLoginEmail())
|
|
20
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!isAuthenticated) {
|
|
24
|
+
setEmail(null)
|
|
25
|
+
setIsLoading(false)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const stored = getStoredLoginEmail()
|
|
30
|
+
if (stored) {
|
|
31
|
+
setEmail(stored)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setIsLoading(true)
|
|
36
|
+
const { me } = api.auth.me({
|
|
37
|
+
onSuccess: (data) => {
|
|
38
|
+
setEmail(readEmailFromProfile(data) ?? getStoredLoginEmail())
|
|
39
|
+
setIsLoading(false)
|
|
40
|
+
},
|
|
41
|
+
onError: () => {
|
|
42
|
+
setEmail(getStoredLoginEmail())
|
|
43
|
+
setIsLoading(false)
|
|
44
|
+
},
|
|
45
|
+
onLoadingChange: (loading) => {
|
|
46
|
+
if (!loading) {
|
|
47
|
+
setIsLoading(false)
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
void me()
|
|
52
|
+
}, [isAuthenticated])
|
|
53
|
+
|
|
54
|
+
return { email, isLoading }
|
|
55
|
+
}
|