import { msg } from '@lingui/core/macro'; import { useLingui } from '@lingui/react'; import { Trans } from '@lingui/react/macro'; import { InfoIcon } from 'lucide-react'; import { DOCUMENT_AUTH_TYPES } from '@documenso/lib/constants/document-auth'; import { DocumentActionAuth, DocumentAuth } from '@documenso/lib/types/document-auth'; import { MultiSelect, type Option } from '@documenso/ui/primitives/multiselect'; import { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitives/tooltip'; export interface DocumentGlobalAuthActionSelectProps { value?: string[]; defaultValue?: string[]; onValueChange?: (value: string[]) => void; disabled?: boolean; placeholder?: string; } export const DocumentGlobalAuthActionSelect = ({ value, defaultValue, onValueChange, disabled, placeholder, }: DocumentGlobalAuthActionSelectProps) => { const { _ } = useLingui(); // Convert auth types to MultiSelect options const authOptions: Option[] = [ { value: '-1', label: _(msg`No restrictions`), }, ...Object.values(DocumentActionAuth) .filter((auth) => auth !== DocumentAuth.ACCOUNT) .map((authType) => ({ value: authType, label: DOCUMENT_AUTH_TYPES[authType].value, })), ]; // Convert string array to Option array for MultiSelect const selectedOptions = (value ?.map((val) => authOptions.find((option) => option.value === val)) .filter(Boolean) as Option[]) || []; // Convert default value to Option array const defaultOptions = (defaultValue ?.map((val) => authOptions.find((option) => option.value === val)) .filter(Boolean) as Option[]) || []; const handleChange = (options: Option[]) => { const values = options.map((option) => option.value); onValueChange?.(values); }; return ( ); }; DocumentGlobalAuthActionSelect.displayName = 'DocumentGlobalAuthActionSelect'; export const DocumentGlobalAuthActionTooltip = () => (

Global recipient action authentication

The authentication methods required for recipients to sign the signature field.

These can be overriden by setting the authentication requirements directly on each recipient in the next step. Multiple methods can be selected.

  • Require passkey - The recipient must have an account and passkey configured via their settings
  • Require 2FA - The recipient must have an account and 2FA enabled via their settings
  • Require password - The recipient must have an account and password configured via their settings, the password will be verified during signing
  • No restrictions - No authentication required
);