@salesforce/ui-bundle-template-feature-vue-authentication 0.0.0-stage → 13.1.0
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/LICENSE.txt +82 -0
- package/README.md +106 -2
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +5423 -0
- package/dist/README.md +83 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/eslint.config.js +7 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils.cls +68 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils_Test.cls +141 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils_Test.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleChangePassword.cls +77 -0
- package/dist/force-app/main/default/classes/UIBundleChangePassword.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleForgotPassword.cls +71 -0
- package/dist/force-app/main/default/classes/UIBundleForgotPassword.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleLogin.cls +105 -0
- package/dist/force-app/main/default/classes/UIBundleLogin.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleRegistration.cls +162 -0
- package/dist/force-app/main/default/classes/UIBundleRegistration.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig.cls +145 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig_Test.cls +181 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig_Test.cls-meta.xml +5 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.forceignore +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.prettierignore +9 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.prettierrc +11 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/README.md +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/codegen.yml +95 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/components.json +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/e2e/app.spec.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/eslint.config.js +124 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/feature-vue-authentication.uibundle-meta.xml +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/index.html +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/package.json +74 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/playwright.config.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/scripts/get-graphql-schema.mjs +71 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/App.vue +5 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/api/graphqlClient.ts +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/appLayout.vue +80 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/alerts/status-alert.vue +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/layouts/card-layout.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/Alert.vue +21 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/AlertAction.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/AlertDescription.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/AlertTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/index.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/Avatar.vue +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/AvatarFallback.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/AvatarImage.vue +16 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/button/Button.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/button/index.ts +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/Card.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardAction.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardContent.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardDescription.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardFooter.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardHeader.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/checkbox/Checkbox.vue +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/checkbox/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/Collapsible.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/CollapsibleContent.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/Dialog.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogClose.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogContent.vue +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogDescription.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogFooter.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogHeader.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogOverlay.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogPortal.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogTitle.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/index.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +51 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuContent.vue +47 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuItem.vue +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuPortal.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +52 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +37 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +38 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/index.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/Field.vue +27 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldContent.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldDescription.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldError.vue +48 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldGroup.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldLabel.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldLegend.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldSeparator.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldSet.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/index.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/index.ts +115 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/input/Input.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/input/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/label/Label.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/label/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/Pagination.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationContent.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationEllipsis.vue +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationItem.vue +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationLink.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationNext.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationPrevious.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/Popover.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverAnchor.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverContent.vue +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverDescription.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverHeader.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverTitle.vue +14 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/Select.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectContent.vue +65 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectGroup.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectItem.vue +41 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectLabel.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectScrollDownButton.vue +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectScrollUpButton.vue +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectSeparator.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectTrigger.vue +45 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectValue.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/index.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/separator/Separator.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/separator/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/skeleton/Skeleton.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/skeleton/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/sonner/Sonner.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/sonner/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/spinner/Spinner.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/spinner/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/composables/useAsyncData.ts +69 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/api/userProfileApi.ts +107 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/authHelpers.ts +78 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/authenticationConfig.ts +66 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/components/SocialLogin.vue +150 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/composables/useCountdownTimer.ts +246 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/composables/useRetryWithBackoff.ts +112 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/composables/useSessionTimeout.ts +244 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/context/authContext.ts +115 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/footers/FooterLink.vue +47 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/forms/AuthForm.vue +141 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/forms/SubmitButton.vue +57 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/EmailField.vue +46 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/PasswordField.vue +48 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/TextField.vue +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/form.ts +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/formContexts.ts +61 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/layout/CenteredPageLayout.vue +76 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/layouts/AuthAppLayout.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/layouts/PrivateRouteLayout.vue +50 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/menu/AuthMenu.vue +143 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/ChangePassword.vue +122 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/ForgotPassword.vue +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/Login.vue +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/Profile.vue +180 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/Register.vue +135 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/ResetPassword.vue +114 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/SessionExpiredAlert.vue +50 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/SessionTimeoutValidator.vue +136 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/SessionWarningModal.vue +151 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/sessionTimeService.ts +142 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/sessionTimeoutConfig.ts +82 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/utils/helpers.ts +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/utils/queryToSearchParams.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/main.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/pages/Home.vue +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/pages/NotFound.vue +18 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/router-utils.ts +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/router.ts +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/styles/global.css +134 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/test/setup.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/tsconfig.json +45 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/tsconfig.tsbuildinfo +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/ui-bundle.json +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/vite-env.d.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/vite.config.ts +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/vitest-env.d.ts +2 -0
- package/dist/jest.config.js +6 -0
- package/dist/package-lock.json +12554 -0
- package/dist/package.json +46 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/gitignore-templates.json +4 -0
- package/dist/scripts/graphql-search.sh +191 -0
- package/dist/scripts/network-senders.mjs +84 -0
- package/dist/scripts/org-setup-config-schema.mjs +132 -0
- package/dist/scripts/org-setup-dev.mjs +114 -0
- package/dist/scripts/org-setup-url.mjs +108 -0
- package/dist/scripts/org-setup-utils.mjs +569 -0
- package/dist/scripts/org-setup-xml.mjs +283 -0
- package/dist/scripts/org-setup.config.json +5 -0
- package/dist/scripts/org-setup.mjs +2545 -0
- package/dist/scripts/sf-project-setup.mjs +103 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/scripts/validate-org-setup-config.mjs +38 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +44 -4
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Composable for a countdown timer with accessibility features.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { computed, onBeforeUnmount, ref, type ComputedRef, type Ref } from "vue";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Accessibility configuration for the countdown timer.
|
|
14
|
+
*/
|
|
15
|
+
export interface CountdownTimerA11yConfig {
|
|
16
|
+
/** Announce time remaining at these specific second marks */
|
|
17
|
+
ANNOUNCE_AT_SECONDS: readonly number[];
|
|
18
|
+
/** Announce every N seconds (after the initial period) */
|
|
19
|
+
ANNOUNCE_INTERVAL_SECONDS: number;
|
|
20
|
+
/** Minimum elapsed time before starting interval announcements */
|
|
21
|
+
MIN_ELAPSED_FOR_INTERVAL: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reactive result from `useCountdownTimer`.
|
|
26
|
+
*/
|
|
27
|
+
export interface CountdownTimerResult {
|
|
28
|
+
/** Current time remaining in seconds */
|
|
29
|
+
displayTime: Ref<number>;
|
|
30
|
+
/** Formatted time string (MM:SS) */
|
|
31
|
+
formattedTime: ComputedRef<string>;
|
|
32
|
+
/** ISO 8601 duration string (e.g., PT2M15S) */
|
|
33
|
+
isoTime: ComputedRef<string>;
|
|
34
|
+
/** Accessibility announcement text for screen readers */
|
|
35
|
+
accessibilityAnnouncement: Ref<string>;
|
|
36
|
+
/** Start the countdown timer */
|
|
37
|
+
start: () => void;
|
|
38
|
+
/** Stop the countdown timer */
|
|
39
|
+
stop: () => void;
|
|
40
|
+
/** Reset the countdown timer to the initial time */
|
|
41
|
+
reset: () => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for the countdown timer composable.
|
|
46
|
+
*/
|
|
47
|
+
export interface CountdownTimerConfig {
|
|
48
|
+
/** Initial time in seconds */
|
|
49
|
+
initialTime: number;
|
|
50
|
+
/** Callback when the countdown reaches 0 */
|
|
51
|
+
onExpire: () => void;
|
|
52
|
+
/** Optional accessibility configuration */
|
|
53
|
+
a11yConfig?: CountdownTimerA11yConfig;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Default accessibility configuration.
|
|
58
|
+
*/
|
|
59
|
+
const DEFAULT_A11Y_CONFIG: CountdownTimerA11yConfig = {
|
|
60
|
+
ANNOUNCE_AT_SECONDS: [5, 1],
|
|
61
|
+
ANNOUNCE_INTERVAL_SECONDS: 10,
|
|
62
|
+
MIN_ELAPSED_FOR_INTERVAL: 10,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Format time remaining as an MM:SS string.
|
|
67
|
+
* Uses Intl.NumberFormat for zero-padding and internationalization.
|
|
68
|
+
*
|
|
69
|
+
* @param seconds - Total seconds remaining
|
|
70
|
+
* @returns Formatted time string (e.g., "05:23")
|
|
71
|
+
*/
|
|
72
|
+
function formatTimeRemaining(seconds: number): string {
|
|
73
|
+
const minutes = Math.floor(seconds / 60);
|
|
74
|
+
const secs = seconds % 60;
|
|
75
|
+
|
|
76
|
+
// Use Intl.NumberFormat for zero-padding with internationalization
|
|
77
|
+
const formatter = new Intl.NumberFormat(navigator.language, {
|
|
78
|
+
minimumIntegerDigits: 2,
|
|
79
|
+
useGrouping: false,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return `${formatter.format(minutes)}:${formatter.format(secs)}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Format time remaining as an ISO 8601 duration for ARIA.
|
|
87
|
+
* Used in the datetime attribute of the <time> element.
|
|
88
|
+
*
|
|
89
|
+
* @param seconds - Total seconds remaining
|
|
90
|
+
* @returns ISO 8601 duration string (e.g., "PT2M15S")
|
|
91
|
+
*/
|
|
92
|
+
function formatISODuration(seconds: number): string {
|
|
93
|
+
const minutes = Math.floor(seconds / 60);
|
|
94
|
+
const secs = seconds % 60;
|
|
95
|
+
return `PT${minutes}M${secs}S`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Format time remaining for a screen reader announcement.
|
|
100
|
+
* Uses Intl.DurationFormat if available, falling back to manual formatting.
|
|
101
|
+
*
|
|
102
|
+
* @param seconds - Total seconds remaining
|
|
103
|
+
* @returns Formatted announcement text (e.g., "2 minutes 15 seconds")
|
|
104
|
+
*/
|
|
105
|
+
function formatAccessibilityAnnouncement(seconds: number): string {
|
|
106
|
+
const minutes = Math.floor(seconds / 60);
|
|
107
|
+
const secs = seconds % 60;
|
|
108
|
+
|
|
109
|
+
// Try using Intl.DurationFormat (newer API, may not be available in all browsers)
|
|
110
|
+
if (typeof Intl !== "undefined" && "DurationFormat" in Intl) {
|
|
111
|
+
try {
|
|
112
|
+
// @ts-expect-error - DurationFormat is not yet in TypeScript lib
|
|
113
|
+
const formatter = new Intl.DurationFormat(navigator.language, { style: "long" });
|
|
114
|
+
return formatter.format({ minutes, seconds: secs });
|
|
115
|
+
} catch {
|
|
116
|
+
// Fallback to manual formatting
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Manual fallback
|
|
121
|
+
const parts: string[] = [];
|
|
122
|
+
if (minutes > 0) {
|
|
123
|
+
parts.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`);
|
|
124
|
+
}
|
|
125
|
+
if (secs > 0 || minutes === 0) {
|
|
126
|
+
parts.push(`${secs} ${secs === 1 ? "second" : "seconds"}`);
|
|
127
|
+
}
|
|
128
|
+
return parts.join(" ");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Determine if an accessibility announcement should be made at this time.
|
|
133
|
+
*
|
|
134
|
+
* @param currentTime - Current countdown time in seconds
|
|
135
|
+
* @param initialTime - Initial countdown time in seconds
|
|
136
|
+
* @param config - Accessibility configuration
|
|
137
|
+
* @returns True if an announcement should be made
|
|
138
|
+
*/
|
|
139
|
+
function shouldAnnounce(
|
|
140
|
+
currentTime: number,
|
|
141
|
+
initialTime: number,
|
|
142
|
+
config: CountdownTimerA11yConfig,
|
|
143
|
+
): boolean {
|
|
144
|
+
// Announce at specific second marks (5s, 1s)
|
|
145
|
+
if (config.ANNOUNCE_AT_SECONDS.includes(currentTime)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Calculate elapsed time
|
|
150
|
+
const elapsed = initialTime - currentTime;
|
|
151
|
+
|
|
152
|
+
// Announce every N seconds after the minimum elapsed time
|
|
153
|
+
if (elapsed >= config.MIN_ELAPSED_FOR_INTERVAL) {
|
|
154
|
+
return currentTime % config.ANNOUNCE_INTERVAL_SECONDS === 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Composable for a countdown timer with accessibility.
|
|
162
|
+
* Decrements from the initial time to 0, providing formatted output for
|
|
163
|
+
* display and ARIA. The Vue analogue of the React `useCountdownTimer` hook.
|
|
164
|
+
*
|
|
165
|
+
* @param config - Timer configuration
|
|
166
|
+
* @returns Reactive timer state and control functions
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* const timer = useCountdownTimer({
|
|
170
|
+
* initialTime: 300, // 5 minutes
|
|
171
|
+
* onExpire: () => handleLogout()
|
|
172
|
+
* });
|
|
173
|
+
*
|
|
174
|
+
* timer.start(); // Begin countdown
|
|
175
|
+
*/
|
|
176
|
+
export function useCountdownTimer({
|
|
177
|
+
initialTime,
|
|
178
|
+
onExpire,
|
|
179
|
+
a11yConfig = DEFAULT_A11Y_CONFIG,
|
|
180
|
+
}: CountdownTimerConfig): CountdownTimerResult {
|
|
181
|
+
const displayTime = ref<number>(initialTime);
|
|
182
|
+
const accessibilityAnnouncement = ref<string>("");
|
|
183
|
+
|
|
184
|
+
let intervalId: ReturnType<typeof setInterval> | undefined;
|
|
185
|
+
let endTime = 0;
|
|
186
|
+
let previousTime = initialTime;
|
|
187
|
+
|
|
188
|
+
const clear = (): void => {
|
|
189
|
+
if (intervalId !== undefined) {
|
|
190
|
+
clearInterval(intervalId);
|
|
191
|
+
intervalId = undefined;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const start = (): void => {
|
|
196
|
+
// Guard against concurrent intervals if start() is called twice.
|
|
197
|
+
clear();
|
|
198
|
+
|
|
199
|
+
// Set the target end time when the timer starts.
|
|
200
|
+
endTime = Date.now() + initialTime * 1000;
|
|
201
|
+
previousTime = initialTime;
|
|
202
|
+
|
|
203
|
+
intervalId = setInterval(() => {
|
|
204
|
+
const now = Date.now();
|
|
205
|
+
const remainingMs = endTime - now;
|
|
206
|
+
const newTime = Math.max(0, Math.ceil(remainingMs / 1000));
|
|
207
|
+
|
|
208
|
+
displayTime.value = newTime;
|
|
209
|
+
|
|
210
|
+
// Only announce when the second value changes.
|
|
211
|
+
if (newTime !== previousTime && shouldAnnounce(newTime, initialTime, a11yConfig)) {
|
|
212
|
+
accessibilityAnnouncement.value = formatAccessibilityAnnouncement(newTime);
|
|
213
|
+
}
|
|
214
|
+
previousTime = newTime;
|
|
215
|
+
|
|
216
|
+
// Check if the countdown expired.
|
|
217
|
+
if (newTime <= 0) {
|
|
218
|
+
clear();
|
|
219
|
+
onExpire();
|
|
220
|
+
}
|
|
221
|
+
}, 100); // Check more frequently for smoother updates
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const stop = (): void => {
|
|
225
|
+
clear();
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const reset = (): void => {
|
|
229
|
+
clear();
|
|
230
|
+
displayTime.value = initialTime;
|
|
231
|
+
accessibilityAnnouncement.value = "";
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// Ensure the interval never outlives the component.
|
|
235
|
+
onBeforeUnmount(clear);
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
displayTime,
|
|
239
|
+
formattedTime: computed(() => formatTimeRemaining(displayTime.value)),
|
|
240
|
+
isoTime: computed(() => formatISODuration(displayTime.value)),
|
|
241
|
+
accessibilityAnnouncement,
|
|
242
|
+
start,
|
|
243
|
+
stop,
|
|
244
|
+
reset,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Composable for retry logic with exponential backoff.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { computed, ref, type ComputedRef, type Ref } from "vue";
|
|
11
|
+
|
|
12
|
+
export interface UseRetryWithBackoffOptions {
|
|
13
|
+
/** Initial delay in milliseconds */
|
|
14
|
+
initialDelay: number;
|
|
15
|
+
/** Maximum number of retry attempts */
|
|
16
|
+
maxAttempts: number;
|
|
17
|
+
/** Maximum delay in milliseconds */
|
|
18
|
+
maxDelay: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface UseRetryWithBackoffResult {
|
|
22
|
+
/** Current number of retry attempts */
|
|
23
|
+
retryAttempts: Ref<number>;
|
|
24
|
+
/** Current retry delay in milliseconds */
|
|
25
|
+
currentRetryDelay: Ref<number>;
|
|
26
|
+
/** Whether max retry attempts have been reached */
|
|
27
|
+
maxRetriesReached: ComputedRef<boolean>;
|
|
28
|
+
/** Schedule a retry with exponential backoff; returns the timeout ID for cancellation */
|
|
29
|
+
scheduleRetry: (callback: () => void) => ReturnType<typeof setTimeout> | undefined;
|
|
30
|
+
/** Reset retry state after a successful operation */
|
|
31
|
+
resetRetry: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Composable for managing retry logic with exponential backoff.
|
|
36
|
+
* The Vue analogue of the React `useRetryWithBackoff` hook.
|
|
37
|
+
*
|
|
38
|
+
* @param options - Configuration for retry behavior
|
|
39
|
+
* @returns Reactive retry state and control functions
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const retry = useRetryWithBackoff({
|
|
43
|
+
* initialDelay: 2000,
|
|
44
|
+
* maxAttempts: 10,
|
|
45
|
+
* maxDelay: 1800000
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* async function fetchData() {
|
|
49
|
+
* try {
|
|
50
|
+
* const data = await apiCall();
|
|
51
|
+
* retry.resetRetry();
|
|
52
|
+
* return data;
|
|
53
|
+
* } catch (error) {
|
|
54
|
+
* if (retry.maxRetriesReached.value) {
|
|
55
|
+
* console.error('Max retries reached');
|
|
56
|
+
* return;
|
|
57
|
+
* }
|
|
58
|
+
* retry.scheduleRetry(() => fetchData());
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
*/
|
|
62
|
+
export function useRetryWithBackoff(
|
|
63
|
+
options: UseRetryWithBackoffOptions,
|
|
64
|
+
): UseRetryWithBackoffResult {
|
|
65
|
+
const { initialDelay, maxAttempts, maxDelay } = options;
|
|
66
|
+
|
|
67
|
+
const retryAttempts = ref<number>(0);
|
|
68
|
+
const currentRetryDelay = ref<number>(initialDelay);
|
|
69
|
+
|
|
70
|
+
const maxRetriesReached = computed(() => retryAttempts.value >= maxAttempts);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Reset retry state after a successful operation.
|
|
74
|
+
*/
|
|
75
|
+
const resetRetry = (): void => {
|
|
76
|
+
retryAttempts.value = 0;
|
|
77
|
+
currentRetryDelay.value = initialDelay;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Schedule a retry with exponential backoff.
|
|
82
|
+
* Returns the timeout ID which can be used to cancel the retry if needed.
|
|
83
|
+
*/
|
|
84
|
+
const scheduleRetry = (callback: () => void): ReturnType<typeof setTimeout> | undefined => {
|
|
85
|
+
if (retryAttempts.value >= maxAttempts) {
|
|
86
|
+
console.error("[useRetryWithBackoff] Max retry attempts reached");
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.warn(
|
|
91
|
+
`[useRetryWithBackoff] Retry attempt ${retryAttempts.value + 1}/${maxAttempts} in ${currentRetryDelay.value}ms`,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const timeoutId = setTimeout(() => {
|
|
95
|
+
callback();
|
|
96
|
+
}, currentRetryDelay.value);
|
|
97
|
+
|
|
98
|
+
retryAttempts.value += 1;
|
|
99
|
+
// Double the delay for the next retry, capped at maxDelay.
|
|
100
|
+
currentRetryDelay.value = Math.min(currentRetryDelay.value * 2, maxDelay);
|
|
101
|
+
|
|
102
|
+
return timeoutId;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
retryAttempts,
|
|
107
|
+
currentRetryDelay,
|
|
108
|
+
maxRetriesReached,
|
|
109
|
+
scheduleRetry,
|
|
110
|
+
resetRetry,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Composable for session timeout monitoring.
|
|
8
|
+
* Polls SessionTimeServlet at calculated intervals and handles retry with
|
|
9
|
+
* exponential backoff. The Vue analogue of the React `useSessionTimeout` hook.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { onBeforeUnmount, ref, type Ref } from "vue";
|
|
13
|
+
import { extendSessionTime, pollSessionTimeServlet } from "../sessionTimeout/sessionTimeService";
|
|
14
|
+
import {
|
|
15
|
+
INITIAL_RETRY_DELAY,
|
|
16
|
+
MAX_RETRY_ATTEMPTS,
|
|
17
|
+
MAX_RETRY_DELAY,
|
|
18
|
+
SESSION_WARNING_TIME,
|
|
19
|
+
} from "../sessionTimeout/sessionTimeoutConfig";
|
|
20
|
+
import { useRetryWithBackoff } from "./useRetryWithBackoff";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for session timeout monitoring.
|
|
24
|
+
*/
|
|
25
|
+
export interface SessionTimeoutConfig {
|
|
26
|
+
/** Community base path (e.g., "/sfsites/c/") */
|
|
27
|
+
basePath: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the current user is a guest user. Evaluated at `start()` time
|
|
30
|
+
* (via getter) so auth state that resolves asynchronously is honored.
|
|
31
|
+
*/
|
|
32
|
+
isGuest: () => boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reactive result from `useSessionTimeout`.
|
|
37
|
+
*/
|
|
38
|
+
export interface SessionTimeoutResult {
|
|
39
|
+
/** Seconds remaining in the current session (null if no response yet) */
|
|
40
|
+
timeLeftInSession: Ref<number | null>;
|
|
41
|
+
/** Whether the warning modal should be displayed */
|
|
42
|
+
showWarningModal: Ref<boolean>;
|
|
43
|
+
/** Extend the session */
|
|
44
|
+
extendSession: () => Promise<void>;
|
|
45
|
+
/** Reset local monitoring state (does not perform navigation) */
|
|
46
|
+
logout: () => void;
|
|
47
|
+
/** Check session status via the API */
|
|
48
|
+
checkSession: () => Promise<void>;
|
|
49
|
+
/** Number of failed retry attempts */
|
|
50
|
+
retryAttempts: Ref<number>;
|
|
51
|
+
/** Whether currently polling the session API */
|
|
52
|
+
isPolling: Ref<boolean>;
|
|
53
|
+
/** Begin polling (no-op for guests) */
|
|
54
|
+
start: () => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Composable for session timeout monitoring.
|
|
59
|
+
*
|
|
60
|
+
* @param config - Session monitoring configuration
|
|
61
|
+
* @returns Reactive session state and control functions
|
|
62
|
+
*/
|
|
63
|
+
export function useSessionTimeout(config: SessionTimeoutConfig): SessionTimeoutResult {
|
|
64
|
+
const { basePath } = config;
|
|
65
|
+
|
|
66
|
+
// Session state
|
|
67
|
+
const timeLeftInSession = ref<number | null>(null);
|
|
68
|
+
const showWarningModal = ref<boolean>(false);
|
|
69
|
+
const isPolling = ref<boolean>(false);
|
|
70
|
+
|
|
71
|
+
// Retry logic with exponential backoff
|
|
72
|
+
const retry = useRetryWithBackoff({
|
|
73
|
+
initialDelay: INITIAL_RETRY_DELAY,
|
|
74
|
+
maxAttempts: MAX_RETRY_ATTEMPTS,
|
|
75
|
+
maxDelay: MAX_RETRY_DELAY,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Timer handles (plain closures — no reactivity needed).
|
|
79
|
+
let pollTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
80
|
+
let retryTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
81
|
+
let isPollingInternal = false;
|
|
82
|
+
|
|
83
|
+
const clearPollTimeout = (): void => {
|
|
84
|
+
if (pollTimeout) {
|
|
85
|
+
clearTimeout(pollTimeout);
|
|
86
|
+
pollTimeout = null;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const clearRetryTimeout = (): void => {
|
|
91
|
+
if (retryTimeout) {
|
|
92
|
+
clearTimeout(retryTimeout);
|
|
93
|
+
retryTimeout = null;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Schedule the next session check, clearing any pending poll/retry first.
|
|
99
|
+
*/
|
|
100
|
+
const scheduleCheck = (delay: number): void => {
|
|
101
|
+
clearPollTimeout();
|
|
102
|
+
clearRetryTimeout();
|
|
103
|
+
pollTimeout = setTimeout(() => {
|
|
104
|
+
void checkSession();
|
|
105
|
+
}, delay);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Handle retry with exponential backoff, preventing concurrent retries.
|
|
110
|
+
*/
|
|
111
|
+
const handleRetryWithBackoff = (retryAction: () => void): void => {
|
|
112
|
+
if (retry.maxRetriesReached.value) {
|
|
113
|
+
console.error("[useSessionTimeout] Max retry attempts reached. Stopping polling.");
|
|
114
|
+
isPolling.value = false;
|
|
115
|
+
isPollingInternal = false;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (isPollingInternal) {
|
|
120
|
+
console.warn("[useSessionTimeout] Poll already in progress, skipping retry scheduling");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
clearRetryTimeout();
|
|
125
|
+
|
|
126
|
+
const delay = retry.currentRetryDelay.value;
|
|
127
|
+
console.warn(
|
|
128
|
+
`[useSessionTimeout] Scheduling retry attempt ${retry.retryAttempts.value + 1}/${MAX_RETRY_ATTEMPTS} in ${delay}ms`,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const timeoutId = retry.scheduleRetry(() => {
|
|
132
|
+
retryTimeout = null;
|
|
133
|
+
retryAction();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
if (timeoutId) {
|
|
137
|
+
retryTimeout = timeoutId;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Process the session timeout response and schedule the next check.
|
|
143
|
+
*/
|
|
144
|
+
const processTimeoutResponse = (secondsRemaining: number): void => {
|
|
145
|
+
timeLeftInSession.value = secondsRemaining;
|
|
146
|
+
|
|
147
|
+
// Session expired — the component reacts to timeLeftInSession <= 0.
|
|
148
|
+
if (secondsRemaining <= 0) {
|
|
149
|
+
showWarningModal.value = false;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const shouldShowWarning = secondsRemaining <= SESSION_WARNING_TIME;
|
|
154
|
+
|
|
155
|
+
if (shouldShowWarning) {
|
|
156
|
+
// Show warning modal and schedule a check for when the session expires.
|
|
157
|
+
showWarningModal.value = true;
|
|
158
|
+
scheduleCheck(secondsRemaining * 1000);
|
|
159
|
+
} else {
|
|
160
|
+
// Schedule a check for when the warning should appear.
|
|
161
|
+
const timeUntilWarning = (secondsRemaining - SESSION_WARNING_TIME) * 1000;
|
|
162
|
+
showWarningModal.value = false;
|
|
163
|
+
scheduleCheck(timeUntilWarning);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Check session status via the API.
|
|
169
|
+
*/
|
|
170
|
+
const checkSession = async (): Promise<void> => {
|
|
171
|
+
// Prevent concurrent polling.
|
|
172
|
+
if (isPollingInternal) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
isPollingInternal = true;
|
|
177
|
+
isPolling.value = true;
|
|
178
|
+
|
|
179
|
+
const response = await pollSessionTimeServlet(basePath);
|
|
180
|
+
isPollingInternal = false;
|
|
181
|
+
isPolling.value = false;
|
|
182
|
+
|
|
183
|
+
if (response) {
|
|
184
|
+
retry.resetRetry();
|
|
185
|
+
processTimeoutResponse(response.sr);
|
|
186
|
+
} else {
|
|
187
|
+
handleRetryWithBackoff(() => void checkSession());
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Extend the session (called when the user clicks "Continue Working").
|
|
193
|
+
*/
|
|
194
|
+
const extendSession = async (): Promise<void> => {
|
|
195
|
+
const response = await extendSessionTime(basePath);
|
|
196
|
+
|
|
197
|
+
if (response) {
|
|
198
|
+
retry.resetRetry();
|
|
199
|
+
processTimeoutResponse(response.sr);
|
|
200
|
+
} else {
|
|
201
|
+
handleRetryWithBackoff(() => void extendSession());
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Reset local monitoring state. Navigation is handled by the component.
|
|
207
|
+
*/
|
|
208
|
+
const logout = (): void => {
|
|
209
|
+
clearPollTimeout();
|
|
210
|
+
clearRetryTimeout();
|
|
211
|
+
showWarningModal.value = false;
|
|
212
|
+
timeLeftInSession.value = null;
|
|
213
|
+
isPolling.value = false;
|
|
214
|
+
isPollingInternal = false;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Begin polling. No-op for guest users.
|
|
219
|
+
*/
|
|
220
|
+
const start = (): void => {
|
|
221
|
+
if (config.isGuest()) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
void checkSession();
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// Cleanup on unmount.
|
|
228
|
+
onBeforeUnmount(() => {
|
|
229
|
+
clearPollTimeout();
|
|
230
|
+
clearRetryTimeout();
|
|
231
|
+
isPollingInternal = false;
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
timeLeftInSession,
|
|
236
|
+
showWarningModal,
|
|
237
|
+
extendSession,
|
|
238
|
+
logout,
|
|
239
|
+
checkSession,
|
|
240
|
+
retryAttempts: retry.retryAttempts,
|
|
241
|
+
isPolling,
|
|
242
|
+
start,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
import { inject, provide, readonly, ref, type InjectionKey, type Ref } from "vue";
|
|
7
|
+
import { getCurrentUser } from "@salesforce/ui-bundle/api";
|
|
8
|
+
import { API_ROUTES } from "../authenticationConfig";
|
|
9
|
+
|
|
10
|
+
/** Authenticated user identity. */
|
|
11
|
+
export interface User {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Reactive authentication state and actions shared via provide/inject. */
|
|
17
|
+
export interface AuthContext {
|
|
18
|
+
/** Current authenticated user, or null when unauthenticated. */
|
|
19
|
+
user: Ref<User | null>;
|
|
20
|
+
/** True once a user has been resolved. */
|
|
21
|
+
isAuthenticated: Ref<boolean>;
|
|
22
|
+
/** True while the initial/refresh auth check is in flight. */
|
|
23
|
+
loading: Ref<boolean>;
|
|
24
|
+
/** Error message from the most recent failed auth check, else null. */
|
|
25
|
+
error: Ref<string | null>;
|
|
26
|
+
/** Re-run the authentication check against the platform. */
|
|
27
|
+
checkAuth: () => Promise<void>;
|
|
28
|
+
/** Redirect to the server-side logout endpoint. */
|
|
29
|
+
logout: (startURL?: string) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Injection key for the auth context — kept internal to the feature. */
|
|
33
|
+
const AUTH_KEY: InjectionKey<AuthContext> = Symbol("auth");
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates the auth context and provides it to descendants.
|
|
37
|
+
* Call once in a top-level component's `<script setup>` (the auth layout).
|
|
38
|
+
*
|
|
39
|
+
* Mirrors the React `AuthProvider`: resolves the current user immediately and
|
|
40
|
+
* exposes reactive `user` / `isAuthenticated` / `loading` / `error` plus
|
|
41
|
+
* `checkAuth` / `logout`.
|
|
42
|
+
*/
|
|
43
|
+
export function provideAuth(): AuthContext {
|
|
44
|
+
const user = ref<User | null>(null);
|
|
45
|
+
const loading = ref<boolean>(true);
|
|
46
|
+
const error = ref<string | null>(null);
|
|
47
|
+
const isAuthenticated = ref<boolean>(false);
|
|
48
|
+
|
|
49
|
+
const checkAuth = async (): Promise<void> => {
|
|
50
|
+
loading.value = true;
|
|
51
|
+
error.value = null;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const userData = await getCurrentUser();
|
|
55
|
+
user.value = userData;
|
|
56
|
+
isAuthenticated.value = userData !== null;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error("Authentication failed", err);
|
|
59
|
+
error.value = "Authentication failed";
|
|
60
|
+
user.value = null;
|
|
61
|
+
isAuthenticated.value = false;
|
|
62
|
+
} finally {
|
|
63
|
+
loading.value = false;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const logout = (startURL?: string): void => {
|
|
68
|
+
// Navigate to logout URL (server-side endpoint).
|
|
69
|
+
// Use replace to prevent the back button from returning to an authenticated session.
|
|
70
|
+
const finalLogoutUrl = startURL
|
|
71
|
+
? `${API_ROUTES.LOGOUT}?startURL=${encodeURIComponent(startURL)}`
|
|
72
|
+
: API_ROUTES.LOGOUT;
|
|
73
|
+
window.location.replace(finalLogoutUrl);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const context: AuthContext = {
|
|
77
|
+
user,
|
|
78
|
+
isAuthenticated: readonly(isAuthenticated) as Ref<boolean>,
|
|
79
|
+
loading: readonly(loading) as Ref<boolean>,
|
|
80
|
+
error: readonly(error) as Ref<string | null>,
|
|
81
|
+
checkAuth,
|
|
82
|
+
logout,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
provide(AUTH_KEY, context);
|
|
86
|
+
|
|
87
|
+
// Resolve the current user immediately, mirroring the React effect.
|
|
88
|
+
void checkAuth();
|
|
89
|
+
|
|
90
|
+
return context;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Injects the authentication context.
|
|
95
|
+
* @throws {Error} If used outside a component tree that called `provideAuth`.
|
|
96
|
+
*/
|
|
97
|
+
export function useAuth(): AuthContext {
|
|
98
|
+
const context = inject(AUTH_KEY);
|
|
99
|
+
if (!context) {
|
|
100
|
+
throw new Error("useAuth must be used within a component that called provideAuth");
|
|
101
|
+
}
|
|
102
|
+
return context;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Returns the current authenticated user ref.
|
|
107
|
+
* @throws {Error} If not within an auth provider or the user is not authenticated.
|
|
108
|
+
*/
|
|
109
|
+
export function useUser(): Ref<User> {
|
|
110
|
+
const context = useAuth();
|
|
111
|
+
if (!context.user.value) {
|
|
112
|
+
throw new Error("Authenticated context not established");
|
|
113
|
+
}
|
|
114
|
+
return context.user as Ref<User>;
|
|
115
|
+
}
|