@contember/react-client-tenant 2.2.0-alpha.3 → 2.2.0-alpha.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/CLAUDE.md +40 -0
- package/dist/development/index.cjs +123 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +123 -0
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/components/forms/AddProjectMemberForm.cjs +59 -0
- package/dist/development/src/components/forms/AddProjectMemberForm.cjs.map +1 -0
- package/dist/development/src/components/forms/AddProjectMemberForm.js +59 -0
- package/dist/development/src/components/forms/AddProjectMemberForm.js.map +1 -0
- package/dist/development/src/components/forms/ChangeMyProfileForm.cjs +58 -0
- package/dist/development/src/components/forms/ChangeMyProfileForm.cjs.map +1 -0
- package/dist/development/src/components/forms/ChangeMyProfileForm.js +58 -0
- package/dist/development/src/components/forms/ChangeMyProfileForm.js.map +1 -0
- package/dist/development/src/components/forms/ChangePasswordForm.cjs +57 -0
- package/dist/development/src/components/forms/ChangePasswordForm.cjs.map +1 -0
- package/dist/development/src/components/forms/ChangePasswordForm.js +57 -0
- package/dist/development/src/components/forms/ChangePasswordForm.js.map +1 -0
- package/dist/development/src/components/forms/ChangeProfileForm.cjs +54 -0
- package/dist/development/src/components/forms/ChangeProfileForm.cjs.map +1 -0
- package/dist/development/src/components/forms/ChangeProfileForm.js +54 -0
- package/dist/development/src/components/forms/ChangeProfileForm.js.map +1 -0
- package/dist/development/src/components/forms/CreateGlobalApiKeyForm.cjs +53 -0
- package/dist/development/src/components/forms/CreateGlobalApiKeyForm.cjs.map +1 -0
- package/dist/development/src/components/forms/CreateGlobalApiKeyForm.js +53 -0
- package/dist/development/src/components/forms/CreateGlobalApiKeyForm.js.map +1 -0
- package/dist/development/src/components/forms/EmailOtpConfirmForm.cjs +51 -0
- package/dist/development/src/components/forms/EmailOtpConfirmForm.cjs.map +1 -0
- package/dist/development/src/components/forms/EmailOtpConfirmForm.js +51 -0
- package/dist/development/src/components/forms/EmailOtpConfirmForm.js.map +1 -0
- package/dist/development/src/components/forms/InviteForm.cjs +23 -3
- package/dist/development/src/components/forms/InviteForm.cjs.map +1 -1
- package/dist/development/src/components/forms/InviteForm.js +23 -3
- package/dist/development/src/components/forms/InviteForm.js.map +1 -1
- package/dist/development/src/components/forms/LoginForm.cjs +7 -3
- package/dist/development/src/components/forms/LoginForm.cjs.map +1 -1
- package/dist/development/src/components/forms/LoginForm.js +7 -3
- package/dist/development/src/components/forms/LoginForm.js.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInForm.cjs +7 -4
- package/dist/development/src/components/forms/PasswordlessSignInForm.cjs.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInForm.js +7 -4
- package/dist/development/src/components/forms/PasswordlessSignInForm.js.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInInitForm.cjs +2 -1
- package/dist/development/src/components/forms/PasswordlessSignInInitForm.cjs.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInInitForm.js +2 -1
- package/dist/development/src/components/forms/PasswordlessSignInInitForm.js.map +1 -1
- package/dist/development/src/components/forms/SetProjectSecretForm.cjs +53 -0
- package/dist/development/src/components/forms/SetProjectSecretForm.cjs.map +1 -0
- package/dist/development/src/components/forms/SetProjectSecretForm.js +53 -0
- package/dist/development/src/components/forms/SetProjectSecretForm.js.map +1 -0
- package/dist/development/src/components/forms/SignUpForm.cjs +66 -0
- package/dist/development/src/components/forms/SignUpForm.cjs.map +1 -0
- package/dist/development/src/components/forms/SignUpForm.js +66 -0
- package/dist/development/src/components/forms/SignUpForm.js.map +1 -0
- package/dist/development/src/components/forms/TenantForm.cjs +8 -4
- package/dist/development/src/components/forms/TenantForm.cjs.map +1 -1
- package/dist/development/src/components/forms/TenantForm.js +8 -4
- package/dist/development/src/components/forms/TenantForm.js.map +1 -1
- package/dist/development/src/components/triggers/DisableEmailOtpTrigger.cjs +32 -0
- package/dist/development/src/components/triggers/DisableEmailOtpTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/DisableEmailOtpTrigger.js +32 -0
- package/dist/development/src/components/triggers/DisableEmailOtpTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/DisableMyPasswordlessTrigger.cjs +32 -0
- package/dist/development/src/components/triggers/DisableMyPasswordlessTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/DisableMyPasswordlessTrigger.js +32 -0
- package/dist/development/src/components/triggers/DisableMyPasswordlessTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/DisableOtpTrigger.cjs +1 -1
- package/dist/development/src/components/triggers/DisableOtpTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/DisableOtpTrigger.js +1 -1
- package/dist/development/src/components/triggers/DisableOtpTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/DisablePersonTrigger.cjs +17 -0
- package/dist/development/src/components/triggers/DisablePersonTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/DisablePersonTrigger.js +17 -0
- package/dist/development/src/components/triggers/DisablePersonTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/EnableMyPasswordlessTrigger.cjs +32 -0
- package/dist/development/src/components/triggers/EnableMyPasswordlessTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/EnableMyPasswordlessTrigger.js +32 -0
- package/dist/development/src/components/triggers/EnableMyPasswordlessTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/EnablePersonTrigger.cjs +17 -0
- package/dist/development/src/components/triggers/EnablePersonTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/EnablePersonTrigger.js +17 -0
- package/dist/development/src/components/triggers/EnablePersonTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/ForceSignOutPersonTrigger.cjs +17 -0
- package/dist/development/src/components/triggers/ForceSignOutPersonTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/ForceSignOutPersonTrigger.js +17 -0
- package/dist/development/src/components/triggers/ForceSignOutPersonTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/InitEmailOtpTrigger.cjs +16 -0
- package/dist/development/src/components/triggers/InitEmailOtpTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/InitEmailOtpTrigger.js +16 -0
- package/dist/development/src/components/triggers/InitEmailOtpTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/RegenerateBackupCodesTrigger.cjs +26 -0
- package/dist/development/src/components/triggers/RegenerateBackupCodesTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/RegenerateBackupCodesTrigger.js +26 -0
- package/dist/development/src/components/triggers/RegenerateBackupCodesTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.cjs +1 -1
- package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.js +1 -1
- package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/ResetPersonMfaTrigger.cjs +17 -0
- package/dist/development/src/components/triggers/ResetPersonMfaTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/ResetPersonMfaTrigger.js +17 -0
- package/dist/development/src/components/triggers/ResetPersonMfaTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/RevokeSessionTrigger.cjs +17 -0
- package/dist/development/src/components/triggers/RevokeSessionTrigger.cjs.map +1 -0
- package/dist/development/src/components/triggers/RevokeSessionTrigger.js +17 -0
- package/dist/development/src/components/triggers/RevokeSessionTrigger.js.map +1 -0
- package/dist/development/src/components/triggers/TenantActionTrigger.cjs +7 -3
- package/dist/development/src/components/triggers/TenantActionTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/TenantActionTrigger.js +7 -3
- package/dist/development/src/components/triggers/TenantActionTrigger.js.map +1 -1
- package/dist/development/src/hooks/mutations/auth/useSignUpMutation.cjs +30 -0
- package/dist/development/src/hooks/mutations/auth/useSignUpMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/auth/useSignUpMutation.js +13 -0
- package/dist/development/src/hooks/mutations/auth/useSignUpMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.cjs +30 -0
- package/dist/development/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.js +13 -0
- package/dist/development/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.js +12 -0
- package/dist/development/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.js +12 -0
- package/dist/development/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.cjs +30 -0
- package/dist/development/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.js +13 -0
- package/dist/development/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.cjs +30 -0
- package/dist/development/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.js +13 -0
- package/dist/development/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.js +12 -0
- package/dist/development/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/invite/useUnmanagedInviteMutation.cjs +30 -0
- package/dist/development/src/hooks/mutations/invite/useUnmanagedInviteMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/invite/useUnmanagedInviteMutation.js +13 -0
- package/dist/development/src/hooks/mutations/invite/useUnmanagedInviteMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.cjs +30 -0
- package/dist/development/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.js +13 -0
- package/dist/development/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/person/useChangePasswordMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/person/useChangePasswordMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/person/useChangePasswordMutation.js +12 -0
- package/dist/development/src/hooks/mutations/person/useChangePasswordMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/person/useDisablePersonMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/person/useDisablePersonMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/person/useDisablePersonMutation.js +12 -0
- package/dist/development/src/hooks/mutations/person/useDisablePersonMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/person/useEnablePersonMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/person/useEnablePersonMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/person/useEnablePersonMutation.js +12 -0
- package/dist/development/src/hooks/mutations/person/useEnablePersonMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/person/useForceSignOutPersonMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/person/useForceSignOutPersonMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/person/useForceSignOutPersonMutation.js +12 -0
- package/dist/development/src/hooks/mutations/person/useForceSignOutPersonMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/person/useResetPersonMfaMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/person/useResetPersonMfaMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/person/useResetPersonMfaMutation.js +12 -0
- package/dist/development/src/hooks/mutations/person/useResetPersonMfaMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/project/useSetProjectSecretMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/project/useSetProjectSecretMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/project/useSetProjectSecretMutation.js +12 -0
- package/dist/development/src/hooks/mutations/project/useSetProjectSecretMutation.js.map +1 -0
- package/dist/development/src/hooks/mutations/session/useRevokeSessionMutation.cjs +29 -0
- package/dist/development/src/hooks/mutations/session/useRevokeSessionMutation.cjs.map +1 -0
- package/dist/development/src/hooks/mutations/session/useRevokeSessionMutation.js +12 -0
- package/dist/development/src/hooks/mutations/session/useRevokeSessionMutation.js.map +1 -0
- package/dist/development/src/hooks/queries/useAuthLogQuery.cjs +39 -0
- package/dist/development/src/hooks/queries/useAuthLogQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useAuthLogQuery.js +22 -0
- package/dist/development/src/hooks/queries/useAuthLogQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useAuthPoliciesQuery.cjs +32 -0
- package/dist/development/src/hooks/queries/useAuthPoliciesQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useAuthPoliciesQuery.js +15 -0
- package/dist/development/src/hooks/queries/useAuthPoliciesQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useConfigurationQuery.cjs +33 -0
- package/dist/development/src/hooks/queries/useConfigurationQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useConfigurationQuery.js +16 -0
- package/dist/development/src/hooks/queries/useConfigurationQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useGlobalApiKeysQuery.cjs +32 -0
- package/dist/development/src/hooks/queries/useGlobalApiKeysQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useGlobalApiKeysQuery.js +15 -0
- package/dist/development/src/hooks/queries/useGlobalApiKeysQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useIdentityProvidersQuery.cjs +32 -0
- package/dist/development/src/hooks/queries/useIdentityProvidersQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useIdentityProvidersQuery.js +15 -0
- package/dist/development/src/hooks/queries/useIdentityProvidersQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useMailTemplatesQuery.cjs +32 -0
- package/dist/development/src/hooks/queries/useMailTemplatesQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useMailTemplatesQuery.js +15 -0
- package/dist/development/src/hooks/queries/useMailTemplatesQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useMeQuery.cjs +4 -2
- package/dist/development/src/hooks/queries/useMeQuery.cjs.map +1 -1
- package/dist/development/src/hooks/queries/useMeQuery.js +4 -2
- package/dist/development/src/hooks/queries/useMeQuery.js.map +1 -1
- package/dist/development/src/hooks/queries/useMyIdentityProvidersQuery.cjs +38 -0
- package/dist/development/src/hooks/queries/useMyIdentityProvidersQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useMyIdentityProvidersQuery.js +21 -0
- package/dist/development/src/hooks/queries/useMyIdentityProvidersQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useMySessionsQuery.cjs +34 -0
- package/dist/development/src/hooks/queries/useMySessionsQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useMySessionsQuery.js +17 -0
- package/dist/development/src/hooks/queries/useMySessionsQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/usePersonQuery.cjs +40 -0
- package/dist/development/src/hooks/queries/usePersonQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/usePersonQuery.js +23 -0
- package/dist/development/src/hooks/queries/usePersonQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/usePersonSessionsQuery.cjs +39 -0
- package/dist/development/src/hooks/queries/usePersonSessionsQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/usePersonSessionsQuery.js +22 -0
- package/dist/development/src/hooks/queries/usePersonSessionsQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/usePersonsQuery.cjs +45 -0
- package/dist/development/src/hooks/queries/usePersonsQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/usePersonsQuery.js +28 -0
- package/dist/development/src/hooks/queries/usePersonsQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useProjectApiKeysQuery.cjs +49 -0
- package/dist/development/src/hooks/queries/useProjectApiKeysQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useProjectApiKeysQuery.js +32 -0
- package/dist/development/src/hooks/queries/useProjectApiKeysQuery.js.map +1 -0
- package/dist/development/src/hooks/queries/useProjectMembersQuery.cjs +1 -1
- package/dist/development/src/hooks/queries/useProjectMembersQuery.cjs.map +1 -1
- package/dist/development/src/hooks/queries/useProjectMembersQuery.js +1 -1
- package/dist/development/src/hooks/queries/useProjectMembersQuery.js.map +1 -1
- package/dist/development/src/hooks/queries/useProjectSecretsQuery.cjs +45 -0
- package/dist/development/src/hooks/queries/useProjectSecretsQuery.cjs.map +1 -0
- package/dist/development/src/hooks/queries/useProjectSecretsQuery.js +28 -0
- package/dist/development/src/hooks/queries/useProjectSecretsQuery.js.map +1 -0
- package/dist/development/src/hooks/useFetchIdentity.cjs +17 -3
- package/dist/development/src/hooks/useFetchIdentity.cjs.map +1 -1
- package/dist/development/src/hooks/useFetchIdentity.js +17 -3
- package/dist/development/src/hooks/useFetchIdentity.js.map +1 -1
- package/dist/development/src/types/forbidden.cjs +16 -0
- package/dist/development/src/types/forbidden.cjs.map +1 -0
- package/dist/development/src/types/forbidden.js +16 -0
- package/dist/development/src/types/forbidden.js.map +1 -0
- package/dist/production/index.cjs +123 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +123 -0
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/components/forms/AddProjectMemberForm.cjs +51 -0
- package/dist/production/src/components/forms/AddProjectMemberForm.cjs.map +1 -0
- package/dist/production/src/components/forms/AddProjectMemberForm.js +51 -0
- package/dist/production/src/components/forms/AddProjectMemberForm.js.map +1 -0
- package/dist/production/src/components/forms/ChangeMyProfileForm.cjs +50 -0
- package/dist/production/src/components/forms/ChangeMyProfileForm.cjs.map +1 -0
- package/dist/production/src/components/forms/ChangeMyProfileForm.js +50 -0
- package/dist/production/src/components/forms/ChangeMyProfileForm.js.map +1 -0
- package/dist/production/src/components/forms/ChangePasswordForm.cjs +49 -0
- package/dist/production/src/components/forms/ChangePasswordForm.cjs.map +1 -0
- package/dist/production/src/components/forms/ChangePasswordForm.js +49 -0
- package/dist/production/src/components/forms/ChangePasswordForm.js.map +1 -0
- package/dist/production/src/components/forms/ChangeProfileForm.cjs +46 -0
- package/dist/production/src/components/forms/ChangeProfileForm.cjs.map +1 -0
- package/dist/production/src/components/forms/ChangeProfileForm.js +46 -0
- package/dist/production/src/components/forms/ChangeProfileForm.js.map +1 -0
- package/dist/production/src/components/forms/CreateGlobalApiKeyForm.cjs +45 -0
- package/dist/production/src/components/forms/CreateGlobalApiKeyForm.cjs.map +1 -0
- package/dist/production/src/components/forms/CreateGlobalApiKeyForm.js +45 -0
- package/dist/production/src/components/forms/CreateGlobalApiKeyForm.js.map +1 -0
- package/dist/production/src/components/forms/EmailOtpConfirmForm.cjs +43 -0
- package/dist/production/src/components/forms/EmailOtpConfirmForm.cjs.map +1 -0
- package/dist/production/src/components/forms/EmailOtpConfirmForm.js +43 -0
- package/dist/production/src/components/forms/EmailOtpConfirmForm.js.map +1 -0
- package/dist/production/src/components/forms/InviteForm.cjs +22 -2
- package/dist/production/src/components/forms/InviteForm.cjs.map +1 -1
- package/dist/production/src/components/forms/InviteForm.js +22 -2
- package/dist/production/src/components/forms/InviteForm.js.map +1 -1
- package/dist/production/src/components/forms/LoginForm.cjs +6 -2
- package/dist/production/src/components/forms/LoginForm.cjs.map +1 -1
- package/dist/production/src/components/forms/LoginForm.js +6 -2
- package/dist/production/src/components/forms/LoginForm.js.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInForm.cjs +6 -3
- package/dist/production/src/components/forms/PasswordlessSignInForm.cjs.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInForm.js +6 -3
- package/dist/production/src/components/forms/PasswordlessSignInForm.js.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInInitForm.cjs +2 -1
- package/dist/production/src/components/forms/PasswordlessSignInInitForm.cjs.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInInitForm.js +2 -1
- package/dist/production/src/components/forms/PasswordlessSignInInitForm.js.map +1 -1
- package/dist/production/src/components/forms/SetProjectSecretForm.cjs +45 -0
- package/dist/production/src/components/forms/SetProjectSecretForm.cjs.map +1 -0
- package/dist/production/src/components/forms/SetProjectSecretForm.js +45 -0
- package/dist/production/src/components/forms/SetProjectSecretForm.js.map +1 -0
- package/dist/production/src/components/forms/SignUpForm.cjs +58 -0
- package/dist/production/src/components/forms/SignUpForm.cjs.map +1 -0
- package/dist/production/src/components/forms/SignUpForm.js +58 -0
- package/dist/production/src/components/forms/SignUpForm.js.map +1 -0
- package/dist/production/src/components/forms/TenantForm.cjs +6 -2
- package/dist/production/src/components/forms/TenantForm.cjs.map +1 -1
- package/dist/production/src/components/forms/TenantForm.js +6 -2
- package/dist/production/src/components/forms/TenantForm.js.map +1 -1
- package/dist/production/src/components/triggers/DisableEmailOtpTrigger.cjs +24 -0
- package/dist/production/src/components/triggers/DisableEmailOtpTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/DisableEmailOtpTrigger.js +24 -0
- package/dist/production/src/components/triggers/DisableEmailOtpTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/DisableMyPasswordlessTrigger.cjs +24 -0
- package/dist/production/src/components/triggers/DisableMyPasswordlessTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/DisableMyPasswordlessTrigger.js +24 -0
- package/dist/production/src/components/triggers/DisableMyPasswordlessTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/DisableOtpTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/DisableOtpTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/DisablePersonTrigger.cjs +13 -0
- package/dist/production/src/components/triggers/DisablePersonTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/DisablePersonTrigger.js +13 -0
- package/dist/production/src/components/triggers/DisablePersonTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/EnableMyPasswordlessTrigger.cjs +24 -0
- package/dist/production/src/components/triggers/EnableMyPasswordlessTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/EnableMyPasswordlessTrigger.js +24 -0
- package/dist/production/src/components/triggers/EnableMyPasswordlessTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/EnablePersonTrigger.cjs +13 -0
- package/dist/production/src/components/triggers/EnablePersonTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/EnablePersonTrigger.js +13 -0
- package/dist/production/src/components/triggers/EnablePersonTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/ForceSignOutPersonTrigger.cjs +13 -0
- package/dist/production/src/components/triggers/ForceSignOutPersonTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/ForceSignOutPersonTrigger.js +13 -0
- package/dist/production/src/components/triggers/ForceSignOutPersonTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/InitEmailOtpTrigger.cjs +12 -0
- package/dist/production/src/components/triggers/InitEmailOtpTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/InitEmailOtpTrigger.js +12 -0
- package/dist/production/src/components/triggers/InitEmailOtpTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/RegenerateBackupCodesTrigger.cjs +18 -0
- package/dist/production/src/components/triggers/RegenerateBackupCodesTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/RegenerateBackupCodesTrigger.js +18 -0
- package/dist/production/src/components/triggers/RegenerateBackupCodesTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/RemoveProjectMemberTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/RemoveProjectMemberTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/ResetPersonMfaTrigger.cjs +13 -0
- package/dist/production/src/components/triggers/ResetPersonMfaTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/ResetPersonMfaTrigger.js +13 -0
- package/dist/production/src/components/triggers/ResetPersonMfaTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/RevokeSessionTrigger.cjs +13 -0
- package/dist/production/src/components/triggers/RevokeSessionTrigger.cjs.map +1 -0
- package/dist/production/src/components/triggers/RevokeSessionTrigger.js +13 -0
- package/dist/production/src/components/triggers/RevokeSessionTrigger.js.map +1 -0
- package/dist/production/src/components/triggers/TenantActionTrigger.cjs +6 -2
- package/dist/production/src/components/triggers/TenantActionTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/TenantActionTrigger.js +6 -2
- package/dist/production/src/components/triggers/TenantActionTrigger.js.map +1 -1
- package/dist/production/src/hooks/mutations/auth/useSignUpMutation.cjs +30 -0
- package/dist/production/src/hooks/mutations/auth/useSignUpMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/auth/useSignUpMutation.js +13 -0
- package/dist/production/src/hooks/mutations/auth/useSignUpMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.cjs +30 -0
- package/dist/production/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.js +13 -0
- package/dist/production/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.js +12 -0
- package/dist/production/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.js +12 -0
- package/dist/production/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.cjs +30 -0
- package/dist/production/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.js +13 -0
- package/dist/production/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.cjs +30 -0
- package/dist/production/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.js +13 -0
- package/dist/production/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.js +12 -0
- package/dist/production/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/invite/useUnmanagedInviteMutation.cjs +30 -0
- package/dist/production/src/hooks/mutations/invite/useUnmanagedInviteMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/invite/useUnmanagedInviteMutation.js +13 -0
- package/dist/production/src/hooks/mutations/invite/useUnmanagedInviteMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.cjs +30 -0
- package/dist/production/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.js +13 -0
- package/dist/production/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/person/useChangePasswordMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/person/useChangePasswordMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/person/useChangePasswordMutation.js +12 -0
- package/dist/production/src/hooks/mutations/person/useChangePasswordMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/person/useDisablePersonMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/person/useDisablePersonMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/person/useDisablePersonMutation.js +12 -0
- package/dist/production/src/hooks/mutations/person/useDisablePersonMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/person/useEnablePersonMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/person/useEnablePersonMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/person/useEnablePersonMutation.js +12 -0
- package/dist/production/src/hooks/mutations/person/useEnablePersonMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/person/useForceSignOutPersonMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/person/useForceSignOutPersonMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/person/useForceSignOutPersonMutation.js +12 -0
- package/dist/production/src/hooks/mutations/person/useForceSignOutPersonMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/person/useResetPersonMfaMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/person/useResetPersonMfaMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/person/useResetPersonMfaMutation.js +12 -0
- package/dist/production/src/hooks/mutations/person/useResetPersonMfaMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/project/useSetProjectSecretMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/project/useSetProjectSecretMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/project/useSetProjectSecretMutation.js +12 -0
- package/dist/production/src/hooks/mutations/project/useSetProjectSecretMutation.js.map +1 -0
- package/dist/production/src/hooks/mutations/session/useRevokeSessionMutation.cjs +29 -0
- package/dist/production/src/hooks/mutations/session/useRevokeSessionMutation.cjs.map +1 -0
- package/dist/production/src/hooks/mutations/session/useRevokeSessionMutation.js +12 -0
- package/dist/production/src/hooks/mutations/session/useRevokeSessionMutation.js.map +1 -0
- package/dist/production/src/hooks/queries/useAuthLogQuery.cjs +39 -0
- package/dist/production/src/hooks/queries/useAuthLogQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useAuthLogQuery.js +22 -0
- package/dist/production/src/hooks/queries/useAuthLogQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useAuthPoliciesQuery.cjs +32 -0
- package/dist/production/src/hooks/queries/useAuthPoliciesQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useAuthPoliciesQuery.js +15 -0
- package/dist/production/src/hooks/queries/useAuthPoliciesQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useConfigurationQuery.cjs +33 -0
- package/dist/production/src/hooks/queries/useConfigurationQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useConfigurationQuery.js +16 -0
- package/dist/production/src/hooks/queries/useConfigurationQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useGlobalApiKeysQuery.cjs +32 -0
- package/dist/production/src/hooks/queries/useGlobalApiKeysQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useGlobalApiKeysQuery.js +15 -0
- package/dist/production/src/hooks/queries/useGlobalApiKeysQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useIdentityProvidersQuery.cjs +32 -0
- package/dist/production/src/hooks/queries/useIdentityProvidersQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useIdentityProvidersQuery.js +15 -0
- package/dist/production/src/hooks/queries/useIdentityProvidersQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useMailTemplatesQuery.cjs +32 -0
- package/dist/production/src/hooks/queries/useMailTemplatesQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useMailTemplatesQuery.js +15 -0
- package/dist/production/src/hooks/queries/useMailTemplatesQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useMeQuery.cjs +4 -2
- package/dist/production/src/hooks/queries/useMeQuery.cjs.map +1 -1
- package/dist/production/src/hooks/queries/useMeQuery.js +4 -2
- package/dist/production/src/hooks/queries/useMeQuery.js.map +1 -1
- package/dist/production/src/hooks/queries/useMyIdentityProvidersQuery.cjs +38 -0
- package/dist/production/src/hooks/queries/useMyIdentityProvidersQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useMyIdentityProvidersQuery.js +21 -0
- package/dist/production/src/hooks/queries/useMyIdentityProvidersQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useMySessionsQuery.cjs +34 -0
- package/dist/production/src/hooks/queries/useMySessionsQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useMySessionsQuery.js +17 -0
- package/dist/production/src/hooks/queries/useMySessionsQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/usePersonQuery.cjs +40 -0
- package/dist/production/src/hooks/queries/usePersonQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/usePersonQuery.js +23 -0
- package/dist/production/src/hooks/queries/usePersonQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/usePersonSessionsQuery.cjs +39 -0
- package/dist/production/src/hooks/queries/usePersonSessionsQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/usePersonSessionsQuery.js +22 -0
- package/dist/production/src/hooks/queries/usePersonSessionsQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/usePersonsQuery.cjs +45 -0
- package/dist/production/src/hooks/queries/usePersonsQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/usePersonsQuery.js +28 -0
- package/dist/production/src/hooks/queries/usePersonsQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useProjectApiKeysQuery.cjs +49 -0
- package/dist/production/src/hooks/queries/useProjectApiKeysQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useProjectApiKeysQuery.js +32 -0
- package/dist/production/src/hooks/queries/useProjectApiKeysQuery.js.map +1 -0
- package/dist/production/src/hooks/queries/useProjectMembersQuery.cjs +1 -1
- package/dist/production/src/hooks/queries/useProjectMembersQuery.cjs.map +1 -1
- package/dist/production/src/hooks/queries/useProjectMembersQuery.js +1 -1
- package/dist/production/src/hooks/queries/useProjectMembersQuery.js.map +1 -1
- package/dist/production/src/hooks/queries/useProjectSecretsQuery.cjs +45 -0
- package/dist/production/src/hooks/queries/useProjectSecretsQuery.cjs.map +1 -0
- package/dist/production/src/hooks/queries/useProjectSecretsQuery.js +28 -0
- package/dist/production/src/hooks/queries/useProjectSecretsQuery.js.map +1 -0
- package/dist/production/src/hooks/useFetchIdentity.cjs +17 -3
- package/dist/production/src/hooks/useFetchIdentity.cjs.map +1 -1
- package/dist/production/src/hooks/useFetchIdentity.js +17 -3
- package/dist/production/src/hooks/useFetchIdentity.js.map +1 -1
- package/dist/production/src/types/forbidden.cjs +16 -0
- package/dist/production/src/types/forbidden.cjs.map +1 -0
- package/dist/production/src/types/forbidden.js +16 -0
- package/dist/production/src/types/forbidden.js.map +1 -0
- package/dist/types/components/IdentityState.d.ts.map +1 -1
- package/dist/types/components/forms/AddProjectMemberForm.d.ts +20 -0
- package/dist/types/components/forms/AddProjectMemberForm.d.ts.map +1 -0
- package/dist/types/components/forms/ChangeMyPasswordForm.d.ts.map +1 -1
- package/dist/types/components/forms/ChangeMyProfileForm.d.ts +20 -0
- package/dist/types/components/forms/ChangeMyProfileForm.d.ts.map +1 -0
- package/dist/types/components/forms/ChangePasswordForm.d.ts +19 -0
- package/dist/types/components/forms/ChangePasswordForm.d.ts.map +1 -0
- package/dist/types/components/forms/ChangeProfileForm.d.ts +21 -0
- package/dist/types/components/forms/ChangeProfileForm.d.ts.map +1 -0
- package/dist/types/components/forms/ConfirmEmailChangeForm.d.ts.map +1 -1
- package/dist/types/components/forms/CreateApiKeyForm.d.ts.map +1 -1
- package/dist/types/components/forms/CreateGlobalApiKeyForm.d.ts +22 -0
- package/dist/types/components/forms/CreateGlobalApiKeyForm.d.ts.map +1 -0
- package/dist/types/components/forms/CreateSessionTokenForm.d.ts.map +1 -1
- package/dist/types/components/forms/EmailOtpConfirmForm.d.ts +21 -0
- package/dist/types/components/forms/EmailOtpConfirmForm.d.ts.map +1 -0
- package/dist/types/components/forms/InviteForm.d.ts +12 -1
- package/dist/types/components/forms/InviteForm.d.ts.map +1 -1
- package/dist/types/components/forms/LoginForm.d.ts +2 -0
- package/dist/types/components/forms/LoginForm.d.ts.map +1 -1
- package/dist/types/components/forms/OtpConfirmForm.d.ts.map +1 -1
- package/dist/types/components/forms/OtpPrepareForm.d.ts.map +1 -1
- package/dist/types/components/forms/PasswordResetForm.d.ts.map +1 -1
- package/dist/types/components/forms/PasswordResetRequestForm.d.ts.map +1 -1
- package/dist/types/components/forms/PasswordlessSignInForm.d.ts +2 -0
- package/dist/types/components/forms/PasswordlessSignInForm.d.ts.map +1 -1
- package/dist/types/components/forms/PasswordlessSignInInitForm.d.ts.map +1 -1
- package/dist/types/components/forms/RequestEmailVerificationForm.d.ts.map +1 -1
- package/dist/types/components/forms/SetProjectSecretForm.d.ts +19 -0
- package/dist/types/components/forms/SetProjectSecretForm.d.ts.map +1 -0
- package/dist/types/components/forms/SignUpForm.d.ts +31 -0
- package/dist/types/components/forms/SignUpForm.d.ts.map +1 -0
- package/dist/types/components/forms/TenantForm.d.ts.map +1 -1
- package/dist/types/components/forms/UpdateProjectMemberForm.d.ts.map +1 -1
- package/dist/types/components/forms/VerifyEmailForm.d.ts.map +1 -1
- package/dist/types/components/forms/index.d.ts +8 -0
- package/dist/types/components/forms/index.d.ts.map +1 -1
- package/dist/types/components/idp/IDP.d.ts.map +1 -1
- package/dist/types/components/idp/IDPInitTrigger.d.ts.map +1 -1
- package/dist/types/components/idp/IDPState.d.ts.map +1 -1
- package/dist/types/components/triggers/DisableEmailOtpTrigger.d.ts +10 -0
- package/dist/types/components/triggers/DisableEmailOtpTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/DisableMyPasswordlessTrigger.d.ts +10 -0
- package/dist/types/components/triggers/DisableMyPasswordlessTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/DisableOtpTrigger.d.ts +3 -1
- package/dist/types/components/triggers/DisableOtpTrigger.d.ts.map +1 -1
- package/dist/types/components/triggers/DisablePersonTrigger.d.ts +11 -0
- package/dist/types/components/triggers/DisablePersonTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/EnableMyPasswordlessTrigger.d.ts +10 -0
- package/dist/types/components/triggers/EnableMyPasswordlessTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/EnablePersonTrigger.d.ts +11 -0
- package/dist/types/components/triggers/EnablePersonTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/ForceSignOutPersonTrigger.d.ts +11 -0
- package/dist/types/components/triggers/ForceSignOutPersonTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/InitEmailOtpTrigger.d.ts +10 -0
- package/dist/types/components/triggers/InitEmailOtpTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/LogoutTrigger.d.ts.map +1 -1
- package/dist/types/components/triggers/RegenerateBackupCodesTrigger.d.ts +14 -0
- package/dist/types/components/triggers/RegenerateBackupCodesTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/RemoveProjectMemberTrigger.d.ts +3 -1
- package/dist/types/components/triggers/RemoveProjectMemberTrigger.d.ts.map +1 -1
- package/dist/types/components/triggers/ResetPersonMfaTrigger.d.ts +11 -0
- package/dist/types/components/triggers/ResetPersonMfaTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/RevokeSessionTrigger.d.ts +11 -0
- package/dist/types/components/triggers/RevokeSessionTrigger.d.ts.map +1 -0
- package/dist/types/components/triggers/TenantActionTrigger.d.ts +7 -4
- package/dist/types/components/triggers/TenantActionTrigger.d.ts.map +1 -1
- package/dist/types/components/triggers/index.d.ts +11 -0
- package/dist/types/components/triggers/index.d.ts.map +1 -1
- package/dist/types/hooks/mutations/auth/index.d.ts +1 -0
- package/dist/types/hooks/mutations/auth/index.d.ts.map +1 -1
- package/dist/types/hooks/mutations/auth/useSignUpMutation.d.ts +95 -0
- package/dist/types/hooks/mutations/auth/useSignUpMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/emailOtp/index.d.ts +4 -0
- package/dist/types/hooks/mutations/emailOtp/index.d.ts.map +1 -0
- package/dist/types/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.d.ts +31 -0
- package/dist/types/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/emailOtp/useDisableEmailOtpMutation.d.ts +15 -0
- package/dist/types/hooks/mutations/emailOtp/useDisableEmailOtpMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/emailOtp/useInitEmailOtpMutation.d.ts +15 -0
- package/dist/types/hooks/mutations/emailOtp/useInitEmailOtpMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/identity/index.d.ts +3 -0
- package/dist/types/hooks/mutations/identity/index.d.ts.map +1 -0
- package/dist/types/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.d.ts +51 -0
- package/dist/types/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.d.ts +51 -0
- package/dist/types/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/idp/index.d.ts +1 -0
- package/dist/types/hooks/mutations/idp/index.d.ts.map +1 -1
- package/dist/types/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.d.ts +19 -0
- package/dist/types/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/index.d.ts +5 -0
- package/dist/types/hooks/mutations/index.d.ts.map +1 -1
- package/dist/types/hooks/mutations/invite/index.d.ts +1 -0
- package/dist/types/hooks/mutations/invite/index.d.ts.map +1 -1
- package/dist/types/hooks/mutations/invite/useUnmanagedInviteMutation.d.ts +104 -0
- package/dist/types/hooks/mutations/invite/useUnmanagedInviteMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/otp/index.d.ts +1 -0
- package/dist/types/hooks/mutations/otp/index.d.ts.map +1 -1
- package/dist/types/hooks/mutations/otp/useRegenerateBackupCodesMutation.d.ts +27 -0
- package/dist/types/hooks/mutations/otp/useRegenerateBackupCodesMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/person/index.d.ts +6 -0
- package/dist/types/hooks/mutations/person/index.d.ts.map +1 -0
- package/dist/types/hooks/mutations/person/useChangePasswordMutation.d.ts +25 -0
- package/dist/types/hooks/mutations/person/useChangePasswordMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/person/useDisablePersonMutation.d.ts +19 -0
- package/dist/types/hooks/mutations/person/useDisablePersonMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/person/useEnablePersonMutation.d.ts +19 -0
- package/dist/types/hooks/mutations/person/useEnablePersonMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/person/useForceSignOutPersonMutation.d.ts +21 -0
- package/dist/types/hooks/mutations/person/useForceSignOutPersonMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/person/useResetPersonMfaMutation.d.ts +19 -0
- package/dist/types/hooks/mutations/person/useResetPersonMfaMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/project/index.d.ts +2 -0
- package/dist/types/hooks/mutations/project/index.d.ts.map +1 -0
- package/dist/types/hooks/mutations/project/useSetProjectSecretMutation.d.ts +23 -0
- package/dist/types/hooks/mutations/project/useSetProjectSecretMutation.d.ts.map +1 -0
- package/dist/types/hooks/mutations/session/index.d.ts +2 -0
- package/dist/types/hooks/mutations/session/index.d.ts.map +1 -0
- package/dist/types/hooks/mutations/session/useRevokeSessionMutation.d.ts +19 -0
- package/dist/types/hooks/mutations/session/useRevokeSessionMutation.d.ts.map +1 -0
- package/dist/types/hooks/queries/index.d.ts +13 -0
- package/dist/types/hooks/queries/index.d.ts.map +1 -1
- package/dist/types/hooks/queries/useAuthLogQuery.d.ts +48 -0
- package/dist/types/hooks/queries/useAuthLogQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useAuthPoliciesQuery.d.ts +35 -0
- package/dist/types/hooks/queries/useAuthPoliciesQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useConfigurationQuery.d.ts +139 -0
- package/dist/types/hooks/queries/useConfigurationQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useGlobalApiKeysQuery.d.ts +30 -0
- package/dist/types/hooks/queries/useGlobalApiKeysQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useIdentityProvidersQuery.d.ts +43 -0
- package/dist/types/hooks/queries/useIdentityProvidersQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useMailTemplatesQuery.d.ts +30 -0
- package/dist/types/hooks/queries/useMailTemplatesQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useMeQuery.d.ts +42 -0
- package/dist/types/hooks/queries/useMeQuery.d.ts.map +1 -1
- package/dist/types/hooks/queries/useMyIdentityProvidersQuery.d.ts +22 -0
- package/dist/types/hooks/queries/useMyIdentityProvidersQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useMySessionsQuery.d.ts +28 -0
- package/dist/types/hooks/queries/useMySessionsQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/usePersonQuery.d.ts +99 -0
- package/dist/types/hooks/queries/usePersonQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/usePersonSessionsQuery.d.ts +31 -0
- package/dist/types/hooks/queries/usePersonSessionsQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/usePersonsQuery.d.ts +41 -0
- package/dist/types/hooks/queries/usePersonsQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useProjectApiKeysQuery.d.ts +55 -0
- package/dist/types/hooks/queries/useProjectApiKeysQuery.d.ts.map +1 -0
- package/dist/types/hooks/queries/useProjectMembersQuery.d.ts +4 -0
- package/dist/types/hooks/queries/useProjectMembersQuery.d.ts.map +1 -1
- package/dist/types/hooks/queries/useProjectMembershipsQuery.d.ts.map +1 -1
- package/dist/types/hooks/queries/useProjectRolesDefinitionQuery.d.ts +19 -19
- package/dist/types/hooks/queries/useProjectRolesDefinitionQuery.d.ts.map +1 -1
- package/dist/types/hooks/queries/useProjectSecretsQuery.d.ts +17 -0
- package/dist/types/hooks/queries/useProjectSecretsQuery.d.ts.map +1 -0
- package/dist/types/hooks/useFetchIdentity.d.ts.map +1 -1
- package/dist/types/hooks/useLogout.d.ts.map +1 -1
- package/dist/types/hooks/usePasswordlessOtpActivator.d.ts.map +1 -1
- package/dist/types/hooks/useTenantApi.d.ts +1 -1
- package/dist/types/hooks/useTenantApi.d.ts.map +1 -1
- package/dist/types/hooks/useTenantMutation.d.ts.map +1 -1
- package/dist/types/hooks/useTenantQueryLoader.d.ts.map +1 -1
- package/dist/types/internal/hooks/useHandleIDPResponse.d.ts.map +1 -1
- package/dist/types/internal/hooks/useInitIDPRedirect.d.ts.map +1 -1
- package/dist/types/internal/hooks/useLogoutInternal.d.ts.map +1 -1
- package/dist/types/internal/hooks/useRedirectToBacklink.d.ts +1 -1
- package/dist/types/internal/hooks/useRedirectToBacklink.d.ts.map +1 -1
- package/dist/types/internal/utils/hashing.d.ts.map +1 -1
- package/dist/types/internal/utils/randomInt.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/Identity.d.ts +42 -3
- package/dist/types/types/Identity.d.ts.map +1 -1
- package/dist/types/types/forbidden.d.ts +21 -0
- package/dist/types/types/forbidden.d.ts.map +1 -0
- package/dist/types/types/forms.d.ts +6 -1
- package/dist/types/types/forms.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/components/forms/AddProjectMemberForm.tsx +74 -0
- package/src/components/forms/ChangeMyProfileForm.tsx +73 -0
- package/src/components/forms/ChangePasswordForm.tsx +73 -0
- package/src/components/forms/ChangeProfileForm.tsx +70 -0
- package/src/components/forms/CreateGlobalApiKeyForm.tsx +67 -0
- package/src/components/forms/EmailOtpConfirmForm.tsx +64 -0
- package/src/components/forms/InviteForm.tsx +36 -2
- package/src/components/forms/LoginForm.tsx +8 -1
- package/src/components/forms/PasswordlessSignInForm.tsx +7 -1
- package/src/components/forms/PasswordlessSignInInitForm.tsx +1 -0
- package/src/components/forms/SetProjectSecretForm.tsx +67 -0
- package/src/components/forms/SignUpForm.tsx +91 -0
- package/src/components/forms/TenantForm.tsx +6 -2
- package/src/components/forms/index.ts +8 -0
- package/src/components/triggers/DisableEmailOtpTrigger.tsx +27 -0
- package/src/components/triggers/DisableMyPasswordlessTrigger.tsx +27 -0
- package/src/components/triggers/DisableOtpTrigger.tsx +3 -2
- package/src/components/triggers/DisablePersonTrigger.tsx +18 -0
- package/src/components/triggers/EnableMyPasswordlessTrigger.tsx +27 -0
- package/src/components/triggers/EnablePersonTrigger.tsx +18 -0
- package/src/components/triggers/ForceSignOutPersonTrigger.tsx +18 -0
- package/src/components/triggers/InitEmailOtpTrigger.tsx +17 -0
- package/src/components/triggers/RegenerateBackupCodesTrigger.tsx +22 -0
- package/src/components/triggers/RemoveProjectMemberTrigger.tsx +3 -2
- package/src/components/triggers/ResetPersonMfaTrigger.tsx +18 -0
- package/src/components/triggers/RevokeSessionTrigger.tsx +18 -0
- package/src/components/triggers/TenantActionTrigger.tsx +11 -3
- package/src/components/triggers/index.ts +11 -0
- package/src/hooks/mutations/auth/index.ts +1 -0
- package/src/hooks/mutations/auth/useSignUpMutation.ts +28 -0
- package/src/hooks/mutations/emailOtp/index.ts +3 -0
- package/src/hooks/mutations/emailOtp/useConfirmEmailOtpMutation.ts +19 -0
- package/src/hooks/mutations/emailOtp/useDisableEmailOtpMutation.ts +13 -0
- package/src/hooks/mutations/emailOtp/useInitEmailOtpMutation.ts +13 -0
- package/src/hooks/mutations/identity/index.ts +2 -0
- package/src/hooks/mutations/identity/useAddGlobalIdentityRolesMutation.ts +19 -0
- package/src/hooks/mutations/identity/useRemoveGlobalIdentityRolesMutation.ts +19 -0
- package/src/hooks/mutations/idp/index.ts +1 -0
- package/src/hooks/mutations/idp/useDisconnectMyIdentityProviderMutation.tsx +13 -0
- package/src/hooks/mutations/index.ts +5 -0
- package/src/hooks/mutations/invite/index.ts +1 -0
- package/src/hooks/mutations/invite/useUnmanagedInviteMutation.tsx +25 -0
- package/src/hooks/mutations/otp/index.ts +1 -0
- package/src/hooks/mutations/otp/useRegenerateBackupCodesMutation.ts +19 -0
- package/src/hooks/mutations/person/index.ts +5 -0
- package/src/hooks/mutations/person/useChangePasswordMutation.ts +14 -0
- package/src/hooks/mutations/person/useDisablePersonMutation.ts +13 -0
- package/src/hooks/mutations/person/useEnablePersonMutation.ts +13 -0
- package/src/hooks/mutations/person/useForceSignOutPersonMutation.ts +13 -0
- package/src/hooks/mutations/person/useResetPersonMfaMutation.ts +13 -0
- package/src/hooks/mutations/project/index.ts +1 -0
- package/src/hooks/mutations/project/useSetProjectSecretMutation.ts +13 -0
- package/src/hooks/mutations/session/index.ts +1 -0
- package/src/hooks/mutations/session/useRevokeSessionMutation.ts +13 -0
- package/src/hooks/queries/index.ts +13 -0
- package/src/hooks/queries/useAuthLogQuery.ts +28 -0
- package/src/hooks/queries/useAuthPoliciesQuery.ts +26 -0
- package/src/hooks/queries/useConfigurationQuery.ts +42 -0
- package/src/hooks/queries/useGlobalApiKeysQuery.ts +19 -0
- package/src/hooks/queries/useIdentityProvidersQuery.ts +31 -0
- package/src/hooks/queries/useMailTemplatesQuery.ts +25 -0
- package/src/hooks/queries/useMeQuery.ts +6 -2
- package/src/hooks/queries/useMyIdentityProvidersQuery.ts +25 -0
- package/src/hooks/queries/useMySessionsQuery.ts +19 -0
- package/src/hooks/queries/usePersonQuery.ts +35 -0
- package/src/hooks/queries/usePersonSessionsQuery.ts +27 -0
- package/src/hooks/queries/usePersonsQuery.ts +37 -0
- package/src/hooks/queries/useProjectApiKeysQuery.ts +43 -0
- package/src/hooks/queries/useProjectMembersQuery.ts +1 -1
- package/src/hooks/queries/useProjectSecretsQuery.ts +33 -0
- package/src/hooks/useFetchIdentity.ts +18 -3
- package/src/tsconfig.json +1 -0
- package/src/types/Identity.ts +44 -3
- package/src/types/forbidden.ts +31 -0
- package/src/types/forms.ts +6 -1
- package/src/types/index.ts +1 -0
- package/tests/TenantForm.test.tsx +54 -0
|
@@ -4,9 +4,11 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const TenantForm = require("./TenantForm.cjs");
|
|
5
5
|
const contexts = require("../../contexts.cjs");
|
|
6
6
|
const useInviteMutation = require("../../hooks/mutations/invite/useInviteMutation.cjs");
|
|
7
|
+
const useUnmanagedInviteMutation = require("../../hooks/mutations/invite/useUnmanagedInviteMutation.cjs");
|
|
7
8
|
const useInviteForm = contexts.useForm;
|
|
8
|
-
const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions }) => {
|
|
9
|
+
const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions, allowUnmanaged }) => {
|
|
9
10
|
const invite = useInviteMutation.useInviteMutation();
|
|
11
|
+
const unmanagedInvite = useUnmanagedInviteMutation.useUnmanagedInviteMutation();
|
|
10
12
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11
13
|
TenantForm.TenantForm,
|
|
12
14
|
{
|
|
@@ -14,7 +16,9 @@ const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, invi
|
|
|
14
16
|
initialValues: {
|
|
15
17
|
email: "",
|
|
16
18
|
name: "",
|
|
17
|
-
memberships: initialMemberships || []
|
|
19
|
+
memberships: initialMemberships || [],
|
|
20
|
+
unmanaged: false,
|
|
21
|
+
password: ""
|
|
18
22
|
},
|
|
19
23
|
validate: ({ values }) => {
|
|
20
24
|
const errors = [];
|
|
@@ -27,6 +31,22 @@ const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, invi
|
|
|
27
31
|
return errors;
|
|
28
32
|
},
|
|
29
33
|
execute: async ({ values }) => {
|
|
34
|
+
if (values.unmanaged && !allowUnmanaged) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
"InviteForm: values.unmanaged is set but the form was not given allowUnmanaged. Pass it to both InviteForm and InviteFormFields."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (values.unmanaged) {
|
|
40
|
+
return await unmanagedInvite({
|
|
41
|
+
email: values.email,
|
|
42
|
+
name: values.name,
|
|
43
|
+
projectSlug,
|
|
44
|
+
memberships: values.memberships,
|
|
45
|
+
// An empty password creates the account without one — the person then
|
|
46
|
+
// has to go through a password reset, which is a legitimate setup.
|
|
47
|
+
options: values.password ? { password: values.password } : void 0
|
|
48
|
+
});
|
|
49
|
+
}
|
|
30
50
|
return await invite({
|
|
31
51
|
email: values.email,
|
|
32
52
|
name: values.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InviteForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/InviteForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { InviteErrorCode, InviteOptions, MembershipInput } from '@contember/graphql-client-tenant'\nimport { InviteMutationResult, useInviteMutation } from '../../hooks/index.js'\n\nexport type InviteFormValues = {\n\temail: string\n\tname: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type InviteFormErrorCode =\n\t| InviteErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type InviteFormState = FormState\n\nexport type InviteFormError = FormError<InviteFormValues, InviteFormErrorCode>\n\nexport type InviteFormContextValue = FormContextValue<InviteFormValues, InviteFormErrorCode>\n\nexport interface InviteFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinviteOptions?: InviteOptions\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: InviteMutationResult }) => void\n}\n\nexport const useInviteForm = useForm as () => InviteFormContextValue\n\nexport const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions }: InviteFormProps) => {\n\tconst invite = useInviteMutation()\n\treturn (\n\t\t<TenantForm<InviteFormContextValue, InviteMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tname: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: InviteFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await invite({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\tname: values.name,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\toptions: inviteOptions,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<InviteErrorCode, keyof InviteFormValues | undefined> = {\n\tALREADY_MEMBER: 'email',\n\tINVALID_EMAIL_FORMAT: 'email',\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":["useForm","useInviteMutation","jsx","TenantForm"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InviteForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/InviteForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { InviteErrorCode, InviteOptions, MembershipInput } from '@contember/graphql-client-tenant'\nimport { InviteMutationResult, useInviteMutation, useUnmanagedInviteMutation } from '../../hooks/index.js'\n\nexport type InviteFormValues = {\n\temail: string\n\tname: string\n\tmemberships: readonly MembershipInput[]\n\t/** Switches to `unmanagedInvite`: create the member without sending mail. Requires `allowUnmanaged` on the form. */\n\tunmanaged: boolean\n\t/** Only read when `unmanaged` is set; empty means the account is created without a password. */\n\tpassword: string\n}\n\nexport type InviteFormErrorCode =\n\t| InviteErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type InviteFormState = FormState\n\nexport type InviteFormError = FormError<InviteFormValues, InviteFormErrorCode>\n\nexport type InviteFormContextValue = FormContextValue<InviteFormValues, InviteFormErrorCode>\n\nexport interface InviteFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinviteOptions?: InviteOptions\n\tinitialMemberships?: readonly MembershipInput[]\n\t/**\n\t * Lets the form submit through `unmanagedInvite` when `values.unmanaged` is\n\t * set — no invitation e-mail, optionally with a password. Off by default, so\n\t * a host app has to opt into offering it. Submitting with `values.unmanaged`\n\t * set but this off throws rather than falling back to a mailed invitation.\n\t */\n\tallowUnmanaged?: boolean\n\tonSuccess?: (args: { result: InviteMutationResult }) => void\n}\n\nexport const useInviteForm = useForm as () => InviteFormContextValue\n\nexport const InviteForm = (\n\t{ children, onSuccess, projectSlug, initialMemberships, inviteOptions, allowUnmanaged }: InviteFormProps,\n) => {\n\tconst invite = useInviteMutation()\n\tconst unmanagedInvite = useUnmanagedInviteMutation()\n\treturn (\n\t\t<TenantForm<InviteFormContextValue, InviteMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tname: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t\tunmanaged: false,\n\t\t\t\tpassword: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: InviteFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\tif (values.unmanaged && !allowUnmanaged) {\n\t\t\t\t\t// `InviteFormFields` takes its own `allowUnmanaged`, so the two can drift.\n\t\t\t\t\t// Failing beats quietly mailing someone who asked for no mail.\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'InviteForm: values.unmanaged is set but the form was not given allowUnmanaged. Pass it to both InviteForm and InviteFormFields.',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (values.unmanaged) {\n\t\t\t\t\treturn await unmanagedInvite({\n\t\t\t\t\t\temail: values.email,\n\t\t\t\t\t\tname: values.name,\n\t\t\t\t\t\tprojectSlug,\n\t\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t\t\t// An empty password creates the account without one — the person then\n\t\t\t\t\t\t// has to go through a password reset, which is a legitimate setup.\n\t\t\t\t\t\toptions: values.password ? { password: values.password } : undefined,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn await invite({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\tname: values.name,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\toptions: inviteOptions,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<InviteErrorCode, keyof InviteFormValues | undefined> = {\n\tALREADY_MEMBER: 'email',\n\tINVALID_EMAIL_FORMAT: 'email',\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":["useForm","useInviteMutation","useUnmanagedInviteMutation","jsx","TenantForm"],"mappings":";;;;;;;AA2CO,MAAM,gBAAgBA,SAAAA;AAEtB,MAAM,aAAa,CACzB,EAAE,UAAU,WAAW,aAAa,oBAAoB,eAAe,qBACnE;AACJ,QAAM,SAASC,kBAAAA,kBAAA;AACf,QAAM,kBAAkBC,2BAAAA,2BAAA;AACxB,SACCC,2BAAAA;AAAAA,IAACC,WAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,OAAO;AAAA,QACP,MAAM;AAAA,QACN,aAAa,sBAAsB,CAAA;AAAA,QACnC,WAAW;AAAA,QACX,UAAU;AAAA,MAAA;AAAA,MAEX,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAA4B,CAAA;AAClC,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACvD;AACA,YAAI,OAAO,YAAY,WAAW,GAAG;AACpC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAC7D;AACA,eAAO;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,YAAI,OAAO,aAAa,CAAC,gBAAgB;AAGxC,gBAAM,IAAI;AAAA,YACT;AAAA,UAAA;AAAA,QAEF;AACA,YAAI,OAAO,WAAW;AACrB,iBAAO,MAAM,gBAAgB;AAAA,YAC5B,OAAO,OAAO;AAAA,YACd,MAAM,OAAO;AAAA,YACb;AAAA,YACA,aAAa,OAAO;AAAA;AAAA;AAAA,YAGpB,SAAS,OAAO,WAAW,EAAE,UAAU,OAAO,aAAa;AAAA,UAAA,CAC3D;AAAA,QACF;AACA,eAAO,MAAM,OAAO;AAAA,UACnB,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb;AAAA,UACA,SAAS;AAAA,UACT,aAAa,OAAO;AAAA,QAAA,CACpB;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EAAA;AAGJ;AAEA,MAAM,eAA4E;AAAA,EACjF,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AACrB;;;"}
|
|
@@ -2,9 +2,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { TenantForm } from "./TenantForm.js";
|
|
3
3
|
import { useForm } from "../../contexts.js";
|
|
4
4
|
import { useInviteMutation } from "../../hooks/mutations/invite/useInviteMutation.js";
|
|
5
|
+
import { useUnmanagedInviteMutation } from "../../hooks/mutations/invite/useUnmanagedInviteMutation.js";
|
|
5
6
|
const useInviteForm = useForm;
|
|
6
|
-
const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions }) => {
|
|
7
|
+
const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions, allowUnmanaged }) => {
|
|
7
8
|
const invite = useInviteMutation();
|
|
9
|
+
const unmanagedInvite = useUnmanagedInviteMutation();
|
|
8
10
|
return /* @__PURE__ */ jsx(
|
|
9
11
|
TenantForm,
|
|
10
12
|
{
|
|
@@ -12,7 +14,9 @@ const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, invi
|
|
|
12
14
|
initialValues: {
|
|
13
15
|
email: "",
|
|
14
16
|
name: "",
|
|
15
|
-
memberships: initialMemberships || []
|
|
17
|
+
memberships: initialMemberships || [],
|
|
18
|
+
unmanaged: false,
|
|
19
|
+
password: ""
|
|
16
20
|
},
|
|
17
21
|
validate: ({ values }) => {
|
|
18
22
|
const errors = [];
|
|
@@ -25,6 +29,22 @@ const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, invi
|
|
|
25
29
|
return errors;
|
|
26
30
|
},
|
|
27
31
|
execute: async ({ values }) => {
|
|
32
|
+
if (values.unmanaged && !allowUnmanaged) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"InviteForm: values.unmanaged is set but the form was not given allowUnmanaged. Pass it to both InviteForm and InviteFormFields."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (values.unmanaged) {
|
|
38
|
+
return await unmanagedInvite({
|
|
39
|
+
email: values.email,
|
|
40
|
+
name: values.name,
|
|
41
|
+
projectSlug,
|
|
42
|
+
memberships: values.memberships,
|
|
43
|
+
// An empty password creates the account without one — the person then
|
|
44
|
+
// has to go through a password reset, which is a legitimate setup.
|
|
45
|
+
options: values.password ? { password: values.password } : void 0
|
|
46
|
+
});
|
|
47
|
+
}
|
|
28
48
|
return await invite({
|
|
29
49
|
email: values.email,
|
|
30
50
|
name: values.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InviteForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/InviteForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { InviteErrorCode, InviteOptions, MembershipInput } from '@contember/graphql-client-tenant'\nimport { InviteMutationResult, useInviteMutation } from '../../hooks/index.js'\n\nexport type InviteFormValues = {\n\temail: string\n\tname: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type InviteFormErrorCode =\n\t| InviteErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type InviteFormState = FormState\n\nexport type InviteFormError = FormError<InviteFormValues, InviteFormErrorCode>\n\nexport type InviteFormContextValue = FormContextValue<InviteFormValues, InviteFormErrorCode>\n\nexport interface InviteFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinviteOptions?: InviteOptions\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: InviteMutationResult }) => void\n}\n\nexport const useInviteForm = useForm as () => InviteFormContextValue\n\nexport const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions }: InviteFormProps) => {\n\tconst invite = useInviteMutation()\n\treturn (\n\t\t<TenantForm<InviteFormContextValue, InviteMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tname: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: InviteFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await invite({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\tname: values.name,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\toptions: inviteOptions,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<InviteErrorCode, keyof InviteFormValues | undefined> = {\n\tALREADY_MEMBER: 'email',\n\tINVALID_EMAIL_FORMAT: 'email',\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InviteForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/InviteForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { InviteErrorCode, InviteOptions, MembershipInput } from '@contember/graphql-client-tenant'\nimport { InviteMutationResult, useInviteMutation, useUnmanagedInviteMutation } from '../../hooks/index.js'\n\nexport type InviteFormValues = {\n\temail: string\n\tname: string\n\tmemberships: readonly MembershipInput[]\n\t/** Switches to `unmanagedInvite`: create the member without sending mail. Requires `allowUnmanaged` on the form. */\n\tunmanaged: boolean\n\t/** Only read when `unmanaged` is set; empty means the account is created without a password. */\n\tpassword: string\n}\n\nexport type InviteFormErrorCode =\n\t| InviteErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type InviteFormState = FormState\n\nexport type InviteFormError = FormError<InviteFormValues, InviteFormErrorCode>\n\nexport type InviteFormContextValue = FormContextValue<InviteFormValues, InviteFormErrorCode>\n\nexport interface InviteFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinviteOptions?: InviteOptions\n\tinitialMemberships?: readonly MembershipInput[]\n\t/**\n\t * Lets the form submit through `unmanagedInvite` when `values.unmanaged` is\n\t * set — no invitation e-mail, optionally with a password. Off by default, so\n\t * a host app has to opt into offering it. Submitting with `values.unmanaged`\n\t * set but this off throws rather than falling back to a mailed invitation.\n\t */\n\tallowUnmanaged?: boolean\n\tonSuccess?: (args: { result: InviteMutationResult }) => void\n}\n\nexport const useInviteForm = useForm as () => InviteFormContextValue\n\nexport const InviteForm = (\n\t{ children, onSuccess, projectSlug, initialMemberships, inviteOptions, allowUnmanaged }: InviteFormProps,\n) => {\n\tconst invite = useInviteMutation()\n\tconst unmanagedInvite = useUnmanagedInviteMutation()\n\treturn (\n\t\t<TenantForm<InviteFormContextValue, InviteMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tname: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t\tunmanaged: false,\n\t\t\t\tpassword: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: InviteFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\tif (values.unmanaged && !allowUnmanaged) {\n\t\t\t\t\t// `InviteFormFields` takes its own `allowUnmanaged`, so the two can drift.\n\t\t\t\t\t// Failing beats quietly mailing someone who asked for no mail.\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'InviteForm: values.unmanaged is set but the form was not given allowUnmanaged. Pass it to both InviteForm and InviteFormFields.',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (values.unmanaged) {\n\t\t\t\t\treturn await unmanagedInvite({\n\t\t\t\t\t\temail: values.email,\n\t\t\t\t\t\tname: values.name,\n\t\t\t\t\t\tprojectSlug,\n\t\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t\t\t// An empty password creates the account without one — the person then\n\t\t\t\t\t\t// has to go through a password reset, which is a legitimate setup.\n\t\t\t\t\t\toptions: values.password ? { password: values.password } : undefined,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn await invite({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\tname: values.name,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\toptions: inviteOptions,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<InviteErrorCode, keyof InviteFormValues | undefined> = {\n\tALREADY_MEMBER: 'email',\n\tINVALID_EMAIL_FORMAT: 'email',\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":[],"mappings":";;;;;AA2CO,MAAM,gBAAgB;AAEtB,MAAM,aAAa,CACzB,EAAE,UAAU,WAAW,aAAa,oBAAoB,eAAe,qBACnE;AACJ,QAAM,SAAS,kBAAA;AACf,QAAM,kBAAkB,2BAAA;AACxB,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,OAAO;AAAA,QACP,MAAM;AAAA,QACN,aAAa,sBAAsB,CAAA;AAAA,QACnC,WAAW;AAAA,QACX,UAAU;AAAA,MAAA;AAAA,MAEX,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAA4B,CAAA;AAClC,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACvD;AACA,YAAI,OAAO,YAAY,WAAW,GAAG;AACpC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAC7D;AACA,eAAO;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,YAAI,OAAO,aAAa,CAAC,gBAAgB;AAGxC,gBAAM,IAAI;AAAA,YACT;AAAA,UAAA;AAAA,QAEF;AACA,YAAI,OAAO,WAAW;AACrB,iBAAO,MAAM,gBAAgB;AAAA,YAC5B,OAAO,OAAO;AAAA,YACd,MAAM,OAAO;AAAA,YACb;AAAA,YACA,aAAa,OAAO;AAAA;AAAA;AAAA,YAGpB,SAAS,OAAO,WAAW,EAAE,UAAU,OAAO,aAAa;AAAA,UAAA,CAC3D;AAAA,QACF;AACA,eAAO,MAAM,OAAO;AAAA,UACnB,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb;AAAA,UACA,SAAS;AAAA,UACT,aAAa,OAAO;AAAA,QAAA,CACpB;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EAAA;AAGJ;AAEA,MAAM,eAA4E;AAAA,EACjF,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AACrB;"}
|
|
@@ -27,7 +27,8 @@ const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess
|
|
|
27
27
|
initialValues: {
|
|
28
28
|
email: "",
|
|
29
29
|
password: "",
|
|
30
|
-
otpToken: ""
|
|
30
|
+
otpToken: "",
|
|
31
|
+
backupCode: ""
|
|
31
32
|
},
|
|
32
33
|
validate: ({ values, state }) => {
|
|
33
34
|
const errors = [];
|
|
@@ -41,7 +42,7 @@ const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess
|
|
|
41
42
|
} else if (values.password.length < 6) {
|
|
42
43
|
errors.push({ code: "INVALID_VALUE", field: "password" });
|
|
43
44
|
}
|
|
44
|
-
if (!values.otpToken && state === "otp-required") {
|
|
45
|
+
if (!values.otpToken && !values.backupCode && state === "otp-required") {
|
|
45
46
|
errors.push({ code: "FIELD_REQUIRED", field: "otpToken" });
|
|
46
47
|
} else if (values.otpToken && !values.otpToken.match(/^\d{6}$/)) {
|
|
47
48
|
errors.push({ code: "INVALID_VALUE", field: "otpToken" });
|
|
@@ -53,6 +54,7 @@ const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess
|
|
|
53
54
|
email: values.email,
|
|
54
55
|
password: values.password,
|
|
55
56
|
otpToken: values.otpToken || void 0,
|
|
57
|
+
backupCode: values.backupCode || void 0,
|
|
56
58
|
expiration
|
|
57
59
|
});
|
|
58
60
|
if (!result.ok && result.error === "OTP_REQUIRED") {
|
|
@@ -74,6 +76,8 @@ const errorToField = {
|
|
|
74
76
|
"RATE_LIMIT_EXCEEDED": "password",
|
|
75
77
|
"OTP_REQUIRED": void 0,
|
|
76
78
|
"MFA_ENROLLMENT_REQUIRED": void 0,
|
|
79
|
+
// Form-level, not a field: it is the account that cannot use a local credential.
|
|
80
|
+
"IDP_REQUIRED": void 0,
|
|
77
81
|
"EMAIL_NOT_VERIFIED": "email"
|
|
78
82
|
};
|
|
79
83
|
exports.LoginForm = LoginForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/LoginForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { SignInErrorCode } from '@contember/graphql-client-tenant'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { SignInMutationResult, useSignInMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type LoginFormValues = {\n\temail: string\n\tpassword: string\n\totpToken: string\n}\n\nexport type LoginFormErrorCode =\n\t| SignInErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type LoginFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type LoginFormError = FormError<LoginFormValues, LoginFormErrorCode>\n\nexport type LoginFormContextValue = FormContextValue<LoginFormValues, LoginFormErrorCode, LoginFormState>\n\nexport interface LoginFormProps {\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useLoginForm = useForm as () => LoginFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess }: LoginFormProps) => {\n\tconst login = useSignInMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<LoginFormContextValue, SignInMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tpassword: '',\n\t\t\t\totpToken: '',\n\t\t\t}}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tconst errors: LoginFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'email' })\n\t\t\t\t}\n\n\t\t\t\tif (!values.password) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'password' })\n\t\t\t\t} else if (values.password.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'password' })\n\t\t\t\t}\n\t\t\t\tif (!values.otpToken && state === 'otp-required') {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'otpToken' })\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'otpToken' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\tconst result = await login({\n\t\t\t\t\temail: values.email!,\n\t\t\t\t\tpassword: values.password!,\n\t\t\t\t\totpToken: values.otpToken || undefined,\n\t\t\t\t\texpiration: expiration,\n\t\t\t\t})\n\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInErrorCode, keyof LoginFormValues | undefined> = {\n\t'INVALID_PASSWORD': 'password',\n\t'NO_PASSWORD_SET': 'password',\n\t'UNKNOWN_EMAIL': 'email',\n\t'PERSON_DISABLED': 'email',\n\t'INVALID_OTP_TOKEN': 'otpToken',\n\t'INVALID_CREDENTIALS': 'password',\n\t'RATE_LIMIT_EXCEEDED': 'password',\n\t'OTP_REQUIRED': undefined,\n\t'MFA_ENROLLMENT_REQUIRED': undefined,\n\t'EMAIL_NOT_VERIFIED': 'email',\n}\n"],"names":["useForm","useSignInMutation","useRedirectToBacklinkCallback","useSetSessionToken","jsx","TenantForm"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"LoginForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/LoginForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { SignInErrorCode } from '@contember/graphql-client-tenant'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { SignInMutationResult, useSignInMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type LoginFormValues = {\n\temail: string\n\tpassword: string\n\totpToken: string\n\t/** Alternative to `otpToken` for a user who lost their authenticator. */\n\tbackupCode: string\n}\n\nexport type LoginFormErrorCode =\n\t| SignInErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type LoginFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type LoginFormError = FormError<LoginFormValues, LoginFormErrorCode>\n\nexport type LoginFormContextValue = FormContextValue<LoginFormValues, LoginFormErrorCode, LoginFormState>\n\nexport interface LoginFormProps {\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useLoginForm = useForm as () => LoginFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess }: LoginFormProps) => {\n\tconst login = useSignInMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<LoginFormContextValue, SignInMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tpassword: '',\n\t\t\t\totpToken: '',\n\t\t\t\tbackupCode: '',\n\t\t\t}}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tconst errors: LoginFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'email' })\n\t\t\t\t}\n\n\t\t\t\tif (!values.password) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'password' })\n\t\t\t\t} else if (values.password.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'password' })\n\t\t\t\t}\n\t\t\t\t// In the otp-required step either an otpToken or a backup code will do.\n\t\t\t\tif (!values.otpToken && !values.backupCode && state === 'otp-required') {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'otpToken' })\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'otpToken' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\tconst result = await login({\n\t\t\t\t\temail: values.email!,\n\t\t\t\t\tpassword: values.password!,\n\t\t\t\t\totpToken: values.otpToken || undefined,\n\t\t\t\t\tbackupCode: values.backupCode || undefined,\n\t\t\t\t\texpiration: expiration,\n\t\t\t\t})\n\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInErrorCode, keyof LoginFormValues | undefined> = {\n\t'INVALID_PASSWORD': 'password',\n\t'NO_PASSWORD_SET': 'password',\n\t'UNKNOWN_EMAIL': 'email',\n\t'PERSON_DISABLED': 'email',\n\t'INVALID_OTP_TOKEN': 'otpToken',\n\t'INVALID_CREDENTIALS': 'password',\n\t'RATE_LIMIT_EXCEEDED': 'password',\n\t'OTP_REQUIRED': undefined,\n\t'MFA_ENROLLMENT_REQUIRED': undefined,\n\t// Form-level, not a field: it is the account that cannot use a local credential.\n\t'IDP_REQUIRED': undefined,\n\t'EMAIL_NOT_VERIFIED': 'email',\n}\n"],"names":["useForm","useSignInMutation","useRedirectToBacklinkCallback","useSetSessionToken","jsx","TenantForm"],"mappings":";;;;;;;;AAsCO,MAAM,eAAeA,SAAAA;AAE5B,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AAEA,MAAM,2BAA2B,KAAK,KAAK;AAEpC,MAAM,YAAY,CAAC,EAAE,UAAU,aAAa,0BAA0B,gBAAgC;AAC5G,QAAM,QAAQC,kBAAAA,kBAAkB,EAAE,SAAS;AAC3C,QAAM,qBAAqBC,sBAAAA,8BAAA;AAC3B,QAAM,kBAAkBC,YAAAA,mBAAA;AACxB,SACCC,2BAAAA;AAAAA,IAACC,WAAAA;AAAAA,IAAA;AAAA,MACA,WAAW,CAAA,SAAQ;AAClB,oBAAA;AACA,wBAAgB,KAAK,OAAO,KAAK;AACjC,2BAAA;AAAA,MACD;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,QACd,OAAO;AAAA,QACP,UAAU;AAAA,QACV,UAAU;AAAA,QACV,YAAY;AAAA,MAAA;AAAA,MAEb,UAAU,CAAC,EAAE,QAAQ,YAAY;AAChC,cAAM,SAA2B,CAAA;AACjC,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACvD,WAAW,CAAC,OAAO,MAAM,MAAM,SAAS,GAAG;AAC1C,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,SAAS;AAAA,QACtD;AAEA,YAAI,CAAC,OAAO,UAAU;AACrB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,YAAY;AAAA,QAC1D,WAAW,OAAO,SAAS,SAAS,GAAG;AACtC,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,YAAY;AAAA,QACzD;AAEA,YAAI,CAAC,OAAO,YAAY,CAAC,OAAO,cAAc,UAAU,gBAAgB;AACvE,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,YAAY;AAAA,QAC1D,WAAW,OAAO,YAAY,CAAC,OAAO,SAAS,MAAM,SAAS,GAAG;AAChE,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,YAAY;AAAA,QACzD;AACA,eAAO;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,cAAM,SAAS,MAAM,MAAM;AAAA,UAC1B,OAAO,OAAO;AAAA,UACd,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO,YAAY;AAAA,UAC7B,YAAY,OAAO,cAAc;AAAA,UACjC;AAAA,QAAA,CACA;AAED,YAAI,CAAC,OAAO,MAAM,OAAO,UAAU,gBAAgB;AAClD,iBAAO,EAAE,GAAG,QAAQ,OAAO,eAAA;AAAA,QAC5B;AAEA,eAAO;AAAA,MACR;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAAqF;AAAA,EAC1F,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,gBAAgB;AAAA,EAChB,2BAA2B;AAAA;AAAA,EAE3B,gBAAgB;AAAA,EAChB,sBAAsB;AACvB;;;"}
|
|
@@ -25,7 +25,8 @@ const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess
|
|
|
25
25
|
initialValues: {
|
|
26
26
|
email: "",
|
|
27
27
|
password: "",
|
|
28
|
-
otpToken: ""
|
|
28
|
+
otpToken: "",
|
|
29
|
+
backupCode: ""
|
|
29
30
|
},
|
|
30
31
|
validate: ({ values, state }) => {
|
|
31
32
|
const errors = [];
|
|
@@ -39,7 +40,7 @@ const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess
|
|
|
39
40
|
} else if (values.password.length < 6) {
|
|
40
41
|
errors.push({ code: "INVALID_VALUE", field: "password" });
|
|
41
42
|
}
|
|
42
|
-
if (!values.otpToken && state === "otp-required") {
|
|
43
|
+
if (!values.otpToken && !values.backupCode && state === "otp-required") {
|
|
43
44
|
errors.push({ code: "FIELD_REQUIRED", field: "otpToken" });
|
|
44
45
|
} else if (values.otpToken && !values.otpToken.match(/^\d{6}$/)) {
|
|
45
46
|
errors.push({ code: "INVALID_VALUE", field: "otpToken" });
|
|
@@ -51,6 +52,7 @@ const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess
|
|
|
51
52
|
email: values.email,
|
|
52
53
|
password: values.password,
|
|
53
54
|
otpToken: values.otpToken || void 0,
|
|
55
|
+
backupCode: values.backupCode || void 0,
|
|
54
56
|
expiration
|
|
55
57
|
});
|
|
56
58
|
if (!result.ok && result.error === "OTP_REQUIRED") {
|
|
@@ -72,6 +74,8 @@ const errorToField = {
|
|
|
72
74
|
"RATE_LIMIT_EXCEEDED": "password",
|
|
73
75
|
"OTP_REQUIRED": void 0,
|
|
74
76
|
"MFA_ENROLLMENT_REQUIRED": void 0,
|
|
77
|
+
// Form-level, not a field: it is the account that cannot use a local credential.
|
|
78
|
+
"IDP_REQUIRED": void 0,
|
|
75
79
|
"EMAIL_NOT_VERIFIED": "email"
|
|
76
80
|
};
|
|
77
81
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/LoginForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { SignInErrorCode } from '@contember/graphql-client-tenant'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { SignInMutationResult, useSignInMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type LoginFormValues = {\n\temail: string\n\tpassword: string\n\totpToken: string\n}\n\nexport type LoginFormErrorCode =\n\t| SignInErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type LoginFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type LoginFormError = FormError<LoginFormValues, LoginFormErrorCode>\n\nexport type LoginFormContextValue = FormContextValue<LoginFormValues, LoginFormErrorCode, LoginFormState>\n\nexport interface LoginFormProps {\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useLoginForm = useForm as () => LoginFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess }: LoginFormProps) => {\n\tconst login = useSignInMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<LoginFormContextValue, SignInMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tpassword: '',\n\t\t\t\totpToken: '',\n\t\t\t}}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tconst errors: LoginFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'email' })\n\t\t\t\t}\n\n\t\t\t\tif (!values.password) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'password' })\n\t\t\t\t} else if (values.password.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'password' })\n\t\t\t\t}\n\t\t\t\tif (!values.otpToken && state === 'otp-required') {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'otpToken' })\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'otpToken' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\tconst result = await login({\n\t\t\t\t\temail: values.email!,\n\t\t\t\t\tpassword: values.password!,\n\t\t\t\t\totpToken: values.otpToken || undefined,\n\t\t\t\t\texpiration: expiration,\n\t\t\t\t})\n\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInErrorCode, keyof LoginFormValues | undefined> = {\n\t'INVALID_PASSWORD': 'password',\n\t'NO_PASSWORD_SET': 'password',\n\t'UNKNOWN_EMAIL': 'email',\n\t'PERSON_DISABLED': 'email',\n\t'INVALID_OTP_TOKEN': 'otpToken',\n\t'INVALID_CREDENTIALS': 'password',\n\t'RATE_LIMIT_EXCEEDED': 'password',\n\t'OTP_REQUIRED': undefined,\n\t'MFA_ENROLLMENT_REQUIRED': undefined,\n\t'EMAIL_NOT_VERIFIED': 'email',\n}\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"LoginForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/LoginForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { SignInErrorCode } from '@contember/graphql-client-tenant'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { SignInMutationResult, useSignInMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type LoginFormValues = {\n\temail: string\n\tpassword: string\n\totpToken: string\n\t/** Alternative to `otpToken` for a user who lost their authenticator. */\n\tbackupCode: string\n}\n\nexport type LoginFormErrorCode =\n\t| SignInErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type LoginFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type LoginFormError = FormError<LoginFormValues, LoginFormErrorCode>\n\nexport type LoginFormContextValue = FormContextValue<LoginFormValues, LoginFormErrorCode, LoginFormState>\n\nexport interface LoginFormProps {\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useLoginForm = useForm as () => LoginFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess }: LoginFormProps) => {\n\tconst login = useSignInMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<LoginFormContextValue, SignInMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tpassword: '',\n\t\t\t\totpToken: '',\n\t\t\t\tbackupCode: '',\n\t\t\t}}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tconst errors: LoginFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'email' })\n\t\t\t\t}\n\n\t\t\t\tif (!values.password) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'password' })\n\t\t\t\t} else if (values.password.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'password' })\n\t\t\t\t}\n\t\t\t\t// In the otp-required step either an otpToken or a backup code will do.\n\t\t\t\tif (!values.otpToken && !values.backupCode && state === 'otp-required') {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'otpToken' })\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'otpToken' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\tconst result = await login({\n\t\t\t\t\temail: values.email!,\n\t\t\t\t\tpassword: values.password!,\n\t\t\t\t\totpToken: values.otpToken || undefined,\n\t\t\t\t\tbackupCode: values.backupCode || undefined,\n\t\t\t\t\texpiration: expiration,\n\t\t\t\t})\n\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInErrorCode, keyof LoginFormValues | undefined> = {\n\t'INVALID_PASSWORD': 'password',\n\t'NO_PASSWORD_SET': 'password',\n\t'UNKNOWN_EMAIL': 'email',\n\t'PERSON_DISABLED': 'email',\n\t'INVALID_OTP_TOKEN': 'otpToken',\n\t'INVALID_CREDENTIALS': 'password',\n\t'RATE_LIMIT_EXCEEDED': 'password',\n\t'OTP_REQUIRED': undefined,\n\t'MFA_ENROLLMENT_REQUIRED': undefined,\n\t// Form-level, not a field: it is the account that cannot use a local credential.\n\t'IDP_REQUIRED': undefined,\n\t'EMAIL_NOT_VERIFIED': 'email',\n}\n"],"names":[],"mappings":";;;;;;AAsCO,MAAM,eAAe;AAE5B,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AAEA,MAAM,2BAA2B,KAAK,KAAK;AAEpC,MAAM,YAAY,CAAC,EAAE,UAAU,aAAa,0BAA0B,gBAAgC;AAC5G,QAAM,QAAQ,kBAAkB,EAAE,SAAS;AAC3C,QAAM,qBAAqB,8BAAA;AAC3B,QAAM,kBAAkB,mBAAA;AACxB,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAW,CAAA,SAAQ;AAClB,oBAAA;AACA,wBAAgB,KAAK,OAAO,KAAK;AACjC,2BAAA;AAAA,MACD;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,QACd,OAAO;AAAA,QACP,UAAU;AAAA,QACV,UAAU;AAAA,QACV,YAAY;AAAA,MAAA;AAAA,MAEb,UAAU,CAAC,EAAE,QAAQ,YAAY;AAChC,cAAM,SAA2B,CAAA;AACjC,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACvD,WAAW,CAAC,OAAO,MAAM,MAAM,SAAS,GAAG;AAC1C,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,SAAS;AAAA,QACtD;AAEA,YAAI,CAAC,OAAO,UAAU;AACrB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,YAAY;AAAA,QAC1D,WAAW,OAAO,SAAS,SAAS,GAAG;AACtC,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,YAAY;AAAA,QACzD;AAEA,YAAI,CAAC,OAAO,YAAY,CAAC,OAAO,cAAc,UAAU,gBAAgB;AACvE,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,YAAY;AAAA,QAC1D,WAAW,OAAO,YAAY,CAAC,OAAO,SAAS,MAAM,SAAS,GAAG;AAChE,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,YAAY;AAAA,QACzD;AACA,eAAO;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,cAAM,SAAS,MAAM,MAAM;AAAA,UAC1B,OAAO,OAAO;AAAA,UACd,UAAU,OAAO;AAAA,UACjB,UAAU,OAAO,YAAY;AAAA,UAC7B,YAAY,OAAO,cAAc;AAAA,UACjC;AAAA,QAAA,CACA;AAED,YAAI,CAAC,OAAO,MAAM,OAAO,UAAU,gBAAgB;AAClD,iBAAO,EAAE,GAAG,QAAQ,OAAO,eAAA;AAAA,QAC5B;AAEA,eAAO;AAAA,MACR;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAAqF;AAAA,EAC1F,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,gBAAgB;AAAA,EAChB,2BAA2B;AAAA;AAAA,EAE3B,gBAAgB;AAAA,EAChB,sBAAsB;AACvB;"}
|
|
@@ -27,13 +27,14 @@ const PasswordlessSignInForm = ({ children, onSuccess, requestId, validationType
|
|
|
27
27
|
errorMapping: errorToField,
|
|
28
28
|
initialValues: React.useMemo(() => ({
|
|
29
29
|
token: token ?? "",
|
|
30
|
-
otpToken: ""
|
|
30
|
+
otpToken: "",
|
|
31
|
+
backupCode: ""
|
|
31
32
|
}), [token]),
|
|
32
33
|
validate: ({ values, state }) => {
|
|
33
34
|
if (!values.token) {
|
|
34
35
|
return [{ code: "FIELD_REQUIRED", field: "token" }];
|
|
35
36
|
}
|
|
36
|
-
if (!values.otpToken && state === "otp-required") {
|
|
37
|
+
if (!values.otpToken && !values.backupCode && state === "otp-required") {
|
|
37
38
|
return [{ code: "FIELD_REQUIRED", field: "otpToken" }];
|
|
38
39
|
} else if (values.otpToken && !values.otpToken.match(/^\d{6}$/)) {
|
|
39
40
|
return [{ code: "INVALID_VALUE", field: "otpToken" }];
|
|
@@ -46,6 +47,7 @@ const PasswordlessSignInForm = ({ children, onSuccess, requestId, validationType
|
|
|
46
47
|
expiration,
|
|
47
48
|
token: values.token,
|
|
48
49
|
mfaOtp: values.otpToken || void 0,
|
|
50
|
+
backupCode: values.backupCode || void 0,
|
|
49
51
|
validationType
|
|
50
52
|
});
|
|
51
53
|
if (!result.ok && result.error === "OTP_REQUIRED") {
|
|
@@ -65,7 +67,8 @@ const errorToField = {
|
|
|
65
67
|
TOKEN_INVALID: "token",
|
|
66
68
|
INVALID_OTP_TOKEN: "otpToken",
|
|
67
69
|
OTP_REQUIRED: void 0,
|
|
68
|
-
MFA_ENROLLMENT_REQUIRED: void 0
|
|
70
|
+
MFA_ENROLLMENT_REQUIRED: void 0,
|
|
71
|
+
IDP_REQUIRED: void 0
|
|
69
72
|
};
|
|
70
73
|
exports.PasswordlessSignInForm = PasswordlessSignInForm;
|
|
71
74
|
exports.usePasswordlessSignInForm = usePasswordlessSignInForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordlessSignInForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInForm.tsx"],"sourcesContent":["import * as TenantApi from '@contember/graphql-client-tenant'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { ReactElement, useCallback, useMemo } from 'react'\nimport { useForm } from '../../contexts.js'\nimport { SignInPasswordlessMutationResult, useSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { TenantForm } from './TenantForm.js'\n\nexport type PasswordlessSignInFormValues = {\n\ttoken: string\n\totpToken: string\n}\n\nexport type PasswordlessSignInFormErrorCode =\n\t| TenantApi.SignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type PasswordlessSignInFormError = FormError<PasswordlessSignInFormValues, PasswordlessSignInFormErrorCode>\n\nexport type PasswordlessSignInFormContextValue = FormContextValue<\n\tPasswordlessSignInFormValues,\n\tPasswordlessSignInFormErrorCode,\n\tPasswordlessSignInFormState\n>\n\nexport interface PasswordlessSignInFormProps {\n\trequestId: string\n\tvalidationType: TenantApi.PasswordlessValidationType\n\ttoken?: string\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const usePasswordlessSignInForm = useForm as () => PasswordlessSignInFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const PasswordlessSignInForm = (\n\t{ children, onSuccess, requestId, validationType, token, expiration = DEFAULT_LOGIN_EXPIRATION }: PasswordlessSignInFormProps,\n) => {\n\tconst signIn = useSignInPasswordlessMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<PasswordlessSignInFormContextValue, SignInPasswordlessMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\ttoken: token ?? '',\n\t\t\t\totpToken: '',\n\t\t\t}), [token])}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tif (!values.token) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'token' }]\n\t\t\t\t}\n\t\t\t\tif (!values.otpToken && state === 'otp-required') {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'otpToken' }]\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'otpToken' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\tconst result = await signIn({\n\t\t\t\t\trequestId,\n\t\t\t\t\texpiration,\n\t\t\t\t\ttoken: values.token,\n\t\t\t\t\tmfaOtp: values.otpToken || undefined,\n\t\t\t\t\tvalidationType,\n\t\t\t\t})\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}, [expiration, requestId, signIn, validationType])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInPasswordlessErrorCode, keyof PasswordlessSignInFormValues | undefined> = {\n\tPERSON_DISABLED: undefined,\n\tTOKEN_EXPIRED: 'token',\n\tTOKEN_NOT_FOUND: 'token',\n\tTOKEN_USED: 'token',\n\tTOKEN_INVALID: 'token',\n\tINVALID_OTP_TOKEN: 'otpToken',\n\tOTP_REQUIRED: undefined,\n\tMFA_ENROLLMENT_REQUIRED: undefined,\n}\n"],"names":["useForm","useSignInPasswordlessMutation","useRedirectToBacklinkCallback","useSetSessionToken","jsx","TenantForm","useMemo","useCallback"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PasswordlessSignInForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInForm.tsx"],"sourcesContent":["import * as TenantApi from '@contember/graphql-client-tenant'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { ReactElement, useCallback, useMemo } from 'react'\nimport { useForm } from '../../contexts.js'\nimport { SignInPasswordlessMutationResult, useSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { TenantForm } from './TenantForm.js'\n\nexport type PasswordlessSignInFormValues = {\n\ttoken: string\n\totpToken: string\n\t/** Alternative to `otpToken` for a user who lost their authenticator. */\n\tbackupCode: string\n}\n\nexport type PasswordlessSignInFormErrorCode =\n\t| TenantApi.SignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type PasswordlessSignInFormError = FormError<PasswordlessSignInFormValues, PasswordlessSignInFormErrorCode>\n\nexport type PasswordlessSignInFormContextValue = FormContextValue<\n\tPasswordlessSignInFormValues,\n\tPasswordlessSignInFormErrorCode,\n\tPasswordlessSignInFormState\n>\n\nexport interface PasswordlessSignInFormProps {\n\trequestId: string\n\tvalidationType: TenantApi.PasswordlessValidationType\n\ttoken?: string\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const usePasswordlessSignInForm = useForm as () => PasswordlessSignInFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const PasswordlessSignInForm = (\n\t{ children, onSuccess, requestId, validationType, token, expiration = DEFAULT_LOGIN_EXPIRATION }: PasswordlessSignInFormProps,\n) => {\n\tconst signIn = useSignInPasswordlessMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<PasswordlessSignInFormContextValue, SignInPasswordlessMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\ttoken: token ?? '',\n\t\t\t\totpToken: '',\n\t\t\t\tbackupCode: '',\n\t\t\t}), [token])}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tif (!values.token) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'token' }]\n\t\t\t\t}\n\t\t\t\t// In the otp-required step either an otpToken or a backup code will do.\n\t\t\t\tif (!values.otpToken && !values.backupCode && state === 'otp-required') {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'otpToken' }]\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'otpToken' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\tconst result = await signIn({\n\t\t\t\t\trequestId,\n\t\t\t\t\texpiration,\n\t\t\t\t\ttoken: values.token,\n\t\t\t\t\tmfaOtp: values.otpToken || undefined,\n\t\t\t\t\tbackupCode: values.backupCode || undefined,\n\t\t\t\t\tvalidationType,\n\t\t\t\t})\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}, [expiration, requestId, signIn, validationType])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInPasswordlessErrorCode, keyof PasswordlessSignInFormValues | undefined> = {\n\tPERSON_DISABLED: undefined,\n\tTOKEN_EXPIRED: 'token',\n\tTOKEN_NOT_FOUND: 'token',\n\tTOKEN_USED: 'token',\n\tTOKEN_INVALID: 'token',\n\tINVALID_OTP_TOKEN: 'otpToken',\n\tOTP_REQUIRED: undefined,\n\tMFA_ENROLLMENT_REQUIRED: undefined,\n\tIDP_REQUIRED: undefined,\n}\n"],"names":["useForm","useSignInPasswordlessMutation","useRedirectToBacklinkCallback","useSetSessionToken","jsx","TenantForm","useMemo","useCallback"],"mappings":";;;;;;;;;AA2CO,MAAM,4BAA4BA,SAAAA;AAEzC,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AACA,MAAM,2BAA2B,KAAK,KAAK;AAEpC,MAAM,yBAAyB,CACrC,EAAE,UAAU,WAAW,WAAW,gBAAgB,OAAO,aAAa,+BAClE;AACJ,QAAM,SAASC,8BAAAA,8BAA8B,EAAE,SAAS;AACxD,QAAM,qBAAqBC,sBAAAA,8BAAA;AAC3B,QAAM,kBAAkBC,YAAAA,mBAAA;AACxB,SACCC,2BAAAA;AAAAA,IAACC,WAAAA;AAAAA,IAAA;AAAA,MACA,WAAW,CAAA,SAAQ;AAClB,oBAAA;AACA,wBAAgB,KAAK,OAAO,KAAK;AACjC,2BAAA;AAAA,MACD;AAAA,MACA,cAAc;AAAA,MACd,eAAeC,MAAAA,QAAQ,OAAO;AAAA,QAC7B,OAAO,SAAS;AAAA,QAChB,UAAU;AAAA,QACV,YAAY;AAAA,MAAA,IACT,CAAC,KAAK,CAAC;AAAA,MACX,UAAU,CAAC,EAAE,QAAQ,YAAY;AAChC,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACnD;AAEA,YAAI,CAAC,OAAO,YAAY,CAAC,OAAO,cAAc,UAAU,gBAAgB;AACvE,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,YAAY;AAAA,QACtD,WAAW,OAAO,YAAY,CAAC,OAAO,SAAS,MAAM,SAAS,GAAG;AAChE,iBAAO,CAAC,EAAE,MAAM,iBAAiB,OAAO,YAAY;AAAA,QACrD;AACA,eAAO,CAAA;AAAA,MACR;AAAA,MACA,SAASC,MAAAA,YAAY,OAAO,EAAE,aAAa;AAC1C,cAAM,SAAS,MAAM,OAAO;AAAA,UAC3B;AAAA,UACA;AAAA,UACA,OAAO,OAAO;AAAA,UACd,QAAQ,OAAO,YAAY;AAAA,UAC3B,YAAY,OAAO,cAAc;AAAA,UACjC;AAAA,QAAA,CACA;AACD,YAAI,CAAC,OAAO,MAAM,OAAO,UAAU,gBAAgB;AAClD,iBAAO,EAAE,GAAG,QAAQ,OAAO,eAAA;AAAA,QAC5B;AAEA,eAAO;AAAA,MACR,GAAG,CAAC,YAAY,WAAW,QAAQ,cAAc,CAAC;AAAA,MAEjD;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAA8G;AAAA,EACnH,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,yBAAyB;AAAA,EACzB,cAAc;AACf;;;"}
|
|
@@ -25,13 +25,14 @@ const PasswordlessSignInForm = ({ children, onSuccess, requestId, validationType
|
|
|
25
25
|
errorMapping: errorToField,
|
|
26
26
|
initialValues: useMemo(() => ({
|
|
27
27
|
token: token ?? "",
|
|
28
|
-
otpToken: ""
|
|
28
|
+
otpToken: "",
|
|
29
|
+
backupCode: ""
|
|
29
30
|
}), [token]),
|
|
30
31
|
validate: ({ values, state }) => {
|
|
31
32
|
if (!values.token) {
|
|
32
33
|
return [{ code: "FIELD_REQUIRED", field: "token" }];
|
|
33
34
|
}
|
|
34
|
-
if (!values.otpToken && state === "otp-required") {
|
|
35
|
+
if (!values.otpToken && !values.backupCode && state === "otp-required") {
|
|
35
36
|
return [{ code: "FIELD_REQUIRED", field: "otpToken" }];
|
|
36
37
|
} else if (values.otpToken && !values.otpToken.match(/^\d{6}$/)) {
|
|
37
38
|
return [{ code: "INVALID_VALUE", field: "otpToken" }];
|
|
@@ -44,6 +45,7 @@ const PasswordlessSignInForm = ({ children, onSuccess, requestId, validationType
|
|
|
44
45
|
expiration,
|
|
45
46
|
token: values.token,
|
|
46
47
|
mfaOtp: values.otpToken || void 0,
|
|
48
|
+
backupCode: values.backupCode || void 0,
|
|
47
49
|
validationType
|
|
48
50
|
});
|
|
49
51
|
if (!result.ok && result.error === "OTP_REQUIRED") {
|
|
@@ -63,7 +65,8 @@ const errorToField = {
|
|
|
63
65
|
TOKEN_INVALID: "token",
|
|
64
66
|
INVALID_OTP_TOKEN: "otpToken",
|
|
65
67
|
OTP_REQUIRED: void 0,
|
|
66
|
-
MFA_ENROLLMENT_REQUIRED: void 0
|
|
68
|
+
MFA_ENROLLMENT_REQUIRED: void 0,
|
|
69
|
+
IDP_REQUIRED: void 0
|
|
67
70
|
};
|
|
68
71
|
export {
|
|
69
72
|
PasswordlessSignInForm,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordlessSignInForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInForm.tsx"],"sourcesContent":["import * as TenantApi from '@contember/graphql-client-tenant'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { ReactElement, useCallback, useMemo } from 'react'\nimport { useForm } from '../../contexts.js'\nimport { SignInPasswordlessMutationResult, useSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { TenantForm } from './TenantForm.js'\n\nexport type PasswordlessSignInFormValues = {\n\ttoken: string\n\totpToken: string\n}\n\nexport type PasswordlessSignInFormErrorCode =\n\t| TenantApi.SignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type PasswordlessSignInFormError = FormError<PasswordlessSignInFormValues, PasswordlessSignInFormErrorCode>\n\nexport type PasswordlessSignInFormContextValue = FormContextValue<\n\tPasswordlessSignInFormValues,\n\tPasswordlessSignInFormErrorCode,\n\tPasswordlessSignInFormState\n>\n\nexport interface PasswordlessSignInFormProps {\n\trequestId: string\n\tvalidationType: TenantApi.PasswordlessValidationType\n\ttoken?: string\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const usePasswordlessSignInForm = useForm as () => PasswordlessSignInFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const PasswordlessSignInForm = (\n\t{ children, onSuccess, requestId, validationType, token, expiration = DEFAULT_LOGIN_EXPIRATION }: PasswordlessSignInFormProps,\n) => {\n\tconst signIn = useSignInPasswordlessMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<PasswordlessSignInFormContextValue, SignInPasswordlessMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\ttoken: token ?? '',\n\t\t\t\totpToken: '',\n\t\t\t}), [token])}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tif (!values.token) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'token' }]\n\t\t\t\t}\n\t\t\t\tif (!values.otpToken && state === 'otp-required') {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'otpToken' }]\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'otpToken' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\tconst result = await signIn({\n\t\t\t\t\trequestId,\n\t\t\t\t\texpiration,\n\t\t\t\t\ttoken: values.token,\n\t\t\t\t\tmfaOtp: values.otpToken || undefined,\n\t\t\t\t\tvalidationType,\n\t\t\t\t})\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}, [expiration, requestId, signIn, validationType])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInPasswordlessErrorCode, keyof PasswordlessSignInFormValues | undefined> = {\n\tPERSON_DISABLED: undefined,\n\tTOKEN_EXPIRED: 'token',\n\tTOKEN_NOT_FOUND: 'token',\n\tTOKEN_USED: 'token',\n\tTOKEN_INVALID: 'token',\n\tINVALID_OTP_TOKEN: 'otpToken',\n\tOTP_REQUIRED: undefined,\n\tMFA_ENROLLMENT_REQUIRED: undefined,\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"PasswordlessSignInForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInForm.tsx"],"sourcesContent":["import * as TenantApi from '@contember/graphql-client-tenant'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { ReactElement, useCallback, useMemo } from 'react'\nimport { useForm } from '../../contexts.js'\nimport { SignInPasswordlessMutationResult, useSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { TenantForm } from './TenantForm.js'\n\nexport type PasswordlessSignInFormValues = {\n\ttoken: string\n\totpToken: string\n\t/** Alternative to `otpToken` for a user who lost their authenticator. */\n\tbackupCode: string\n}\n\nexport type PasswordlessSignInFormErrorCode =\n\t| TenantApi.SignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInFormState =\n\t| FormState\n\t| 'otp-required'\n\nexport type PasswordlessSignInFormError = FormError<PasswordlessSignInFormValues, PasswordlessSignInFormErrorCode>\n\nexport type PasswordlessSignInFormContextValue = FormContextValue<\n\tPasswordlessSignInFormValues,\n\tPasswordlessSignInFormErrorCode,\n\tPasswordlessSignInFormState\n>\n\nexport interface PasswordlessSignInFormProps {\n\trequestId: string\n\tvalidationType: TenantApi.PasswordlessValidationType\n\ttoken?: string\n\texpiration?: number\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const usePasswordlessSignInForm = useForm as () => PasswordlessSignInFormContextValue\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const PasswordlessSignInForm = (\n\t{ children, onSuccess, requestId, validationType, token, expiration = DEFAULT_LOGIN_EXPIRATION }: PasswordlessSignInFormProps,\n) => {\n\tconst signIn = useSignInPasswordlessMutation({ headers })\n\tconst redirectToBacklink = useRedirectToBacklinkCallback()\n\tconst setSessionToken = useSetSessionToken()\n\treturn (\n\t\t<TenantForm<PasswordlessSignInFormContextValue, SignInPasswordlessMutationResult>\n\t\t\tonSuccess={args => {\n\t\t\t\tonSuccess?.()\n\t\t\t\tsetSessionToken(args.result.token)\n\t\t\t\tredirectToBacklink()\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\ttoken: token ?? '',\n\t\t\t\totpToken: '',\n\t\t\t\tbackupCode: '',\n\t\t\t}), [token])}\n\t\t\tvalidate={({ values, state }) => {\n\t\t\t\tif (!values.token) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'token' }]\n\t\t\t\t}\n\t\t\t\t// In the otp-required step either an otpToken or a backup code will do.\n\t\t\t\tif (!values.otpToken && !values.backupCode && state === 'otp-required') {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'otpToken' }]\n\t\t\t\t} else if (values.otpToken && !values.otpToken.match(/^\\d{6}$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'otpToken' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\tconst result = await signIn({\n\t\t\t\t\trequestId,\n\t\t\t\t\texpiration,\n\t\t\t\t\ttoken: values.token,\n\t\t\t\t\tmfaOtp: values.otpToken || undefined,\n\t\t\t\t\tbackupCode: values.backupCode || undefined,\n\t\t\t\t\tvalidationType,\n\t\t\t\t})\n\t\t\t\tif (!result.ok && result.error === 'OTP_REQUIRED') {\n\t\t\t\t\treturn { ...result, state: 'otp-required' }\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}, [expiration, requestId, signIn, validationType])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.SignInPasswordlessErrorCode, keyof PasswordlessSignInFormValues | undefined> = {\n\tPERSON_DISABLED: undefined,\n\tTOKEN_EXPIRED: 'token',\n\tTOKEN_NOT_FOUND: 'token',\n\tTOKEN_USED: 'token',\n\tTOKEN_INVALID: 'token',\n\tINVALID_OTP_TOKEN: 'otpToken',\n\tOTP_REQUIRED: undefined,\n\tMFA_ENROLLMENT_REQUIRED: undefined,\n\tIDP_REQUIRED: undefined,\n}\n"],"names":[],"mappings":";;;;;;;AA2CO,MAAM,4BAA4B;AAEzC,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AACA,MAAM,2BAA2B,KAAK,KAAK;AAEpC,MAAM,yBAAyB,CACrC,EAAE,UAAU,WAAW,WAAW,gBAAgB,OAAO,aAAa,+BAClE;AACJ,QAAM,SAAS,8BAA8B,EAAE,SAAS;AACxD,QAAM,qBAAqB,8BAAA;AAC3B,QAAM,kBAAkB,mBAAA;AACxB,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAW,CAAA,SAAQ;AAClB,oBAAA;AACA,wBAAgB,KAAK,OAAO,KAAK;AACjC,2BAAA;AAAA,MACD;AAAA,MACA,cAAc;AAAA,MACd,eAAe,QAAQ,OAAO;AAAA,QAC7B,OAAO,SAAS;AAAA,QAChB,UAAU;AAAA,QACV,YAAY;AAAA,MAAA,IACT,CAAC,KAAK,CAAC;AAAA,MACX,UAAU,CAAC,EAAE,QAAQ,YAAY;AAChC,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACnD;AAEA,YAAI,CAAC,OAAO,YAAY,CAAC,OAAO,cAAc,UAAU,gBAAgB;AACvE,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,YAAY;AAAA,QACtD,WAAW,OAAO,YAAY,CAAC,OAAO,SAAS,MAAM,SAAS,GAAG;AAChE,iBAAO,CAAC,EAAE,MAAM,iBAAiB,OAAO,YAAY;AAAA,QACrD;AACA,eAAO,CAAA;AAAA,MACR;AAAA,MACA,SAAS,YAAY,OAAO,EAAE,aAAa;AAC1C,cAAM,SAAS,MAAM,OAAO;AAAA,UAC3B;AAAA,UACA;AAAA,UACA,OAAO,OAAO;AAAA,UACd,QAAQ,OAAO,YAAY;AAAA,UAC3B,YAAY,OAAO,cAAc;AAAA,UACjC;AAAA,QAAA,CACA;AACD,YAAI,CAAC,OAAO,MAAM,OAAO,UAAU,gBAAgB;AAClD,iBAAO,EAAE,GAAG,QAAQ,OAAO,eAAA;AAAA,QAC5B;AAEA,eAAO;AAAA,MACR,GAAG,CAAC,YAAY,WAAW,QAAQ,cAAc,CAAC;AAAA,MAEjD;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAA8G;AAAA,EACnH,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,yBAAyB;AAAA,EACzB,cAAc;AACf;"}
|
|
@@ -46,7 +46,8 @@ const errorToField = {
|
|
|
46
46
|
PERSON_NOT_FOUND: "email",
|
|
47
47
|
PASSWORDLESS_DISABLED: void 0,
|
|
48
48
|
RATE_LIMIT_EXCEEDED: void 0,
|
|
49
|
-
INVALID_CAPTCHA: void 0
|
|
49
|
+
INVALID_CAPTCHA: void 0,
|
|
50
|
+
IDP_REQUIRED: void 0
|
|
50
51
|
};
|
|
51
52
|
exports.PasswordlessSignInInitForm = PasswordlessSignInInitForm;
|
|
52
53
|
exports.usePasswordlessSignInInitForm = usePasswordlessSignInInitForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordlessSignInInitForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInInitForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { useForm } from '../../contexts.js'\nimport { InitSignInPasswordlessMutationResult, useInitSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../../consts.js'\nimport { useSaveBacklink } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type PasswordlessSignInInitFormValues = {\n\temail: string\n}\n\nexport type PasswordlessSignInInitFormErrorCode =\n\t| TenantApi.InitSignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInInitFormState = FormState\n\nexport type PasswordlessSignInInitFormError = FormError<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport type PasswordlessSignInInitFormContextValue = FormContextValue<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport interface PasswordlessSignInInitFormProps {\n\tchildren: ReactElement\n\tonSuccess?: (args: { result: InitSignInPasswordlessMutationResult }) => void\n}\n\nexport const usePasswordlessSignInInitForm = useForm as () => PasswordlessSignInInitFormContextValue\n\nexport const PasswordlessSignInInitForm = ({ children, onSuccess }: PasswordlessSignInInitFormProps) => {\n\tconst initSignIn = useInitSignInPasswordlessMutation()\n\tconst saveBacklink = useSaveBacklink({\n\t\tstorage: 'local',\n\t})\n\n\treturn (\n\t\t<TenantForm<PasswordlessSignInInitFormContextValue, InitSignInPasswordlessMutationResult>\n\t\t\tonSuccess={res => {\n\t\t\t\tlocalStorage.setItem(PASSWORDLESS_REQUEST_STORAGE_KEY, res.result.requestId)\n\t\t\t\tsaveBacklink()\n\t\t\t\tonSuccess?.(res)\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\temail: '',\n\t\t\t}), [])}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tif (!values.email) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'email' }]\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'email' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\treturn await initSignIn({\n\t\t\t\t\temail: values.email,\n\t\t\t\t})\n\t\t\t}, [initSignIn])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.InitSignInPasswordlessErrorCode, keyof PasswordlessSignInInitFormValues | undefined> = {\n\tPERSON_NOT_FOUND: 'email',\n\tPASSWORDLESS_DISABLED: undefined,\n\tRATE_LIMIT_EXCEEDED: undefined,\n\tINVALID_CAPTCHA: undefined,\n}\n"],"names":["useForm","useInitSignInPasswordlessMutation","useSaveBacklink","jsx","TenantForm","PASSWORDLESS_REQUEST_STORAGE_KEY","useMemo","useCallback"],"mappings":";;;;;;;;;AA8BO,MAAM,gCAAgCA,SAAAA;AAEtC,MAAM,6BAA6B,CAAC,EAAE,UAAU,gBAAiD;AACvG,QAAM,aAAaC,kCAAAA,kCAAA;AACnB,QAAM,eAAeC,sBAAAA,gBAAgB;AAAA,IACpC,SAAS;AAAA,EAAA,CACT;AAED,SACCC,2BAAAA;AAAAA,IAACC,WAAAA;AAAAA,IAAA;AAAA,MACA,WAAW,CAAA,QAAO;AACjB,qBAAa,QAAQC,OAAAA,kCAAkC,IAAI,OAAO,SAAS;AAC3E,qBAAA;AACA,oBAAY,GAAG;AAAA,MAChB;AAAA,MACA,cAAc;AAAA,MACd,eAAeC,MAAAA,QAAQ,OAAO;AAAA,QAC7B,OAAO;AAAA,MAAA,IACJ,CAAA,CAAE;AAAA,MACN,UAAU,CAAC,EAAE,aAAa;AACzB,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACnD,WAAW,CAAC,OAAO,MAAM,MAAM,SAAS,GAAG;AAC1C,iBAAO,CAAC,EAAE,MAAM,iBAAiB,OAAO,SAAS;AAAA,QAClD;AACA,eAAO,CAAA;AAAA,MACR;AAAA,MACA,SAASC,MAAAA,YAAY,OAAO,EAAE,aAAa;AAC1C,eAAO,MAAM,WAAW;AAAA,UACvB,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF,GAAG,CAAC,UAAU,CAAC;AAAA,MAEd;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAAsH;AAAA,EAC3H,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"PasswordlessSignInInitForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInInitForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { useForm } from '../../contexts.js'\nimport { InitSignInPasswordlessMutationResult, useInitSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../../consts.js'\nimport { useSaveBacklink } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type PasswordlessSignInInitFormValues = {\n\temail: string\n}\n\nexport type PasswordlessSignInInitFormErrorCode =\n\t| TenantApi.InitSignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInInitFormState = FormState\n\nexport type PasswordlessSignInInitFormError = FormError<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport type PasswordlessSignInInitFormContextValue = FormContextValue<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport interface PasswordlessSignInInitFormProps {\n\tchildren: ReactElement\n\tonSuccess?: (args: { result: InitSignInPasswordlessMutationResult }) => void\n}\n\nexport const usePasswordlessSignInInitForm = useForm as () => PasswordlessSignInInitFormContextValue\n\nexport const PasswordlessSignInInitForm = ({ children, onSuccess }: PasswordlessSignInInitFormProps) => {\n\tconst initSignIn = useInitSignInPasswordlessMutation()\n\tconst saveBacklink = useSaveBacklink({\n\t\tstorage: 'local',\n\t})\n\n\treturn (\n\t\t<TenantForm<PasswordlessSignInInitFormContextValue, InitSignInPasswordlessMutationResult>\n\t\t\tonSuccess={res => {\n\t\t\t\tlocalStorage.setItem(PASSWORDLESS_REQUEST_STORAGE_KEY, res.result.requestId)\n\t\t\t\tsaveBacklink()\n\t\t\t\tonSuccess?.(res)\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\temail: '',\n\t\t\t}), [])}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tif (!values.email) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'email' }]\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'email' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\treturn await initSignIn({\n\t\t\t\t\temail: values.email,\n\t\t\t\t})\n\t\t\t}, [initSignIn])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.InitSignInPasswordlessErrorCode, keyof PasswordlessSignInInitFormValues | undefined> = {\n\tPERSON_NOT_FOUND: 'email',\n\tPASSWORDLESS_DISABLED: undefined,\n\tRATE_LIMIT_EXCEEDED: undefined,\n\tINVALID_CAPTCHA: undefined,\n\tIDP_REQUIRED: undefined,\n}\n"],"names":["useForm","useInitSignInPasswordlessMutation","useSaveBacklink","jsx","TenantForm","PASSWORDLESS_REQUEST_STORAGE_KEY","useMemo","useCallback"],"mappings":";;;;;;;;;AA8BO,MAAM,gCAAgCA,SAAAA;AAEtC,MAAM,6BAA6B,CAAC,EAAE,UAAU,gBAAiD;AACvG,QAAM,aAAaC,kCAAAA,kCAAA;AACnB,QAAM,eAAeC,sBAAAA,gBAAgB;AAAA,IACpC,SAAS;AAAA,EAAA,CACT;AAED,SACCC,2BAAAA;AAAAA,IAACC,WAAAA;AAAAA,IAAA;AAAA,MACA,WAAW,CAAA,QAAO;AACjB,qBAAa,QAAQC,OAAAA,kCAAkC,IAAI,OAAO,SAAS;AAC3E,qBAAA;AACA,oBAAY,GAAG;AAAA,MAChB;AAAA,MACA,cAAc;AAAA,MACd,eAAeC,MAAAA,QAAQ,OAAO;AAAA,QAC7B,OAAO;AAAA,MAAA,IACJ,CAAA,CAAE;AAAA,MACN,UAAU,CAAC,EAAE,aAAa;AACzB,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACnD,WAAW,CAAC,OAAO,MAAM,MAAM,SAAS,GAAG;AAC1C,iBAAO,CAAC,EAAE,MAAM,iBAAiB,OAAO,SAAS;AAAA,QAClD;AACA,eAAO,CAAA;AAAA,MACR;AAAA,MACA,SAASC,MAAAA,YAAY,OAAO,EAAE,aAAa;AAC1C,eAAO,MAAM,WAAW;AAAA,UACvB,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF,GAAG,CAAC,UAAU,CAAC;AAAA,MAEd;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAAsH;AAAA,EAC3H,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,cAAc;AACf;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordlessSignInInitForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInInitForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { useForm } from '../../contexts.js'\nimport { InitSignInPasswordlessMutationResult, useInitSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../../consts.js'\nimport { useSaveBacklink } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type PasswordlessSignInInitFormValues = {\n\temail: string\n}\n\nexport type PasswordlessSignInInitFormErrorCode =\n\t| TenantApi.InitSignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInInitFormState = FormState\n\nexport type PasswordlessSignInInitFormError = FormError<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport type PasswordlessSignInInitFormContextValue = FormContextValue<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport interface PasswordlessSignInInitFormProps {\n\tchildren: ReactElement\n\tonSuccess?: (args: { result: InitSignInPasswordlessMutationResult }) => void\n}\n\nexport const usePasswordlessSignInInitForm = useForm as () => PasswordlessSignInInitFormContextValue\n\nexport const PasswordlessSignInInitForm = ({ children, onSuccess }: PasswordlessSignInInitFormProps) => {\n\tconst initSignIn = useInitSignInPasswordlessMutation()\n\tconst saveBacklink = useSaveBacklink({\n\t\tstorage: 'local',\n\t})\n\n\treturn (\n\t\t<TenantForm<PasswordlessSignInInitFormContextValue, InitSignInPasswordlessMutationResult>\n\t\t\tonSuccess={res => {\n\t\t\t\tlocalStorage.setItem(PASSWORDLESS_REQUEST_STORAGE_KEY, res.result.requestId)\n\t\t\t\tsaveBacklink()\n\t\t\t\tonSuccess?.(res)\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\temail: '',\n\t\t\t}), [])}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tif (!values.email) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'email' }]\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'email' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\treturn await initSignIn({\n\t\t\t\t\temail: values.email,\n\t\t\t\t})\n\t\t\t}, [initSignIn])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.InitSignInPasswordlessErrorCode, keyof PasswordlessSignInInitFormValues | undefined> = {\n\tPERSON_NOT_FOUND: 'email',\n\tPASSWORDLESS_DISABLED: undefined,\n\tRATE_LIMIT_EXCEEDED: undefined,\n\tINVALID_CAPTCHA: undefined,\n}\n"],"names":[],"mappings":";;;;;;;AA8BO,MAAM,gCAAgC;AAEtC,MAAM,6BAA6B,CAAC,EAAE,UAAU,gBAAiD;AACvG,QAAM,aAAa,kCAAA;AACnB,QAAM,eAAe,gBAAgB;AAAA,IACpC,SAAS;AAAA,EAAA,CACT;AAED,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAW,CAAA,QAAO;AACjB,qBAAa,QAAQ,kCAAkC,IAAI,OAAO,SAAS;AAC3E,qBAAA;AACA,oBAAY,GAAG;AAAA,MAChB;AAAA,MACA,cAAc;AAAA,MACd,eAAe,QAAQ,OAAO;AAAA,QAC7B,OAAO;AAAA,MAAA,IACJ,CAAA,CAAE;AAAA,MACN,UAAU,CAAC,EAAE,aAAa;AACzB,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACnD,WAAW,CAAC,OAAO,MAAM,MAAM,SAAS,GAAG;AAC1C,iBAAO,CAAC,EAAE,MAAM,iBAAiB,OAAO,SAAS;AAAA,QAClD;AACA,eAAO,CAAA;AAAA,MACR;AAAA,MACA,SAAS,YAAY,OAAO,EAAE,aAAa;AAC1C,eAAO,MAAM,WAAW;AAAA,UACvB,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF,GAAG,CAAC,UAAU,CAAC;AAAA,MAEd;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAAsH;AAAA,EAC3H,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"PasswordlessSignInInitForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/PasswordlessSignInInitForm.tsx"],"sourcesContent":["import { ReactElement, useCallback, useMemo } from 'react'\nimport * as TenantApi from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/forms.js'\nimport { useForm } from '../../contexts.js'\nimport { InitSignInPasswordlessMutationResult, useInitSignInPasswordlessMutation } from '../../hooks/index.js'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../../consts.js'\nimport { useSaveBacklink } from '../../internal/hooks/useRedirectToBacklink.js'\n\nexport type PasswordlessSignInInitFormValues = {\n\temail: string\n}\n\nexport type PasswordlessSignInInitFormErrorCode =\n\t| TenantApi.InitSignInPasswordlessErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'UNKNOWN_ERROR'\n\nexport type PasswordlessSignInInitFormState = FormState\n\nexport type PasswordlessSignInInitFormError = FormError<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport type PasswordlessSignInInitFormContextValue = FormContextValue<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>\n\nexport interface PasswordlessSignInInitFormProps {\n\tchildren: ReactElement\n\tonSuccess?: (args: { result: InitSignInPasswordlessMutationResult }) => void\n}\n\nexport const usePasswordlessSignInInitForm = useForm as () => PasswordlessSignInInitFormContextValue\n\nexport const PasswordlessSignInInitForm = ({ children, onSuccess }: PasswordlessSignInInitFormProps) => {\n\tconst initSignIn = useInitSignInPasswordlessMutation()\n\tconst saveBacklink = useSaveBacklink({\n\t\tstorage: 'local',\n\t})\n\n\treturn (\n\t\t<TenantForm<PasswordlessSignInInitFormContextValue, InitSignInPasswordlessMutationResult>\n\t\t\tonSuccess={res => {\n\t\t\t\tlocalStorage.setItem(PASSWORDLESS_REQUEST_STORAGE_KEY, res.result.requestId)\n\t\t\t\tsaveBacklink()\n\t\t\t\tonSuccess?.(res)\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={useMemo(() => ({\n\t\t\t\temail: '',\n\t\t\t}), [])}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tif (!values.email) {\n\t\t\t\t\treturn [{ code: 'FIELD_REQUIRED', field: 'email' }]\n\t\t\t\t} else if (!values.email.match(/^.+@.+$/)) {\n\t\t\t\t\treturn [{ code: 'INVALID_VALUE', field: 'email' }]\n\t\t\t\t}\n\t\t\t\treturn []\n\t\t\t}}\n\t\t\texecute={useCallback(async ({ values }) => {\n\t\t\t\treturn await initSignIn({\n\t\t\t\t\temail: values.email,\n\t\t\t\t})\n\t\t\t}, [initSignIn])}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\nconst errorToField: Record<TenantApi.InitSignInPasswordlessErrorCode, keyof PasswordlessSignInInitFormValues | undefined> = {\n\tPERSON_NOT_FOUND: 'email',\n\tPASSWORDLESS_DISABLED: undefined,\n\tRATE_LIMIT_EXCEEDED: undefined,\n\tINVALID_CAPTCHA: undefined,\n\tIDP_REQUIRED: undefined,\n}\n"],"names":[],"mappings":";;;;;;;AA8BO,MAAM,gCAAgC;AAEtC,MAAM,6BAA6B,CAAC,EAAE,UAAU,gBAAiD;AACvG,QAAM,aAAa,kCAAA;AACnB,QAAM,eAAe,gBAAgB;AAAA,IACpC,SAAS;AAAA,EAAA,CACT;AAED,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAW,CAAA,QAAO;AACjB,qBAAa,QAAQ,kCAAkC,IAAI,OAAO,SAAS;AAC3E,qBAAA;AACA,oBAAY,GAAG;AAAA,MAChB;AAAA,MACA,cAAc;AAAA,MACd,eAAe,QAAQ,OAAO;AAAA,QAC7B,OAAO;AAAA,MAAA,IACJ,CAAA,CAAE;AAAA,MACN,UAAU,CAAC,EAAE,aAAa;AACzB,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,CAAC,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACnD,WAAW,CAAC,OAAO,MAAM,MAAM,SAAS,GAAG;AAC1C,iBAAO,CAAC,EAAE,MAAM,iBAAiB,OAAO,SAAS;AAAA,QAClD;AACA,eAAO,CAAA;AAAA,MACR;AAAA,MACA,SAAS,YAAY,OAAO,EAAE,aAAa;AAC1C,eAAO,MAAM,WAAW;AAAA,UACvB,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF,GAAG,CAAC,UAAU,CAAC;AAAA,MAEd;AAAA,IAAA;AAAA,EAAA;AAGJ;AACA,MAAM,eAAsH;AAAA,EAC3H,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,cAAc;AACf;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const TenantForm = require("./TenantForm.cjs");
|
|
5
|
+
const contexts = require("../../contexts.cjs");
|
|
6
|
+
const useSetProjectSecretMutation = require("../../hooks/mutations/project/useSetProjectSecretMutation.cjs");
|
|
7
|
+
const useSetProjectSecretForm = contexts.useForm;
|
|
8
|
+
const SetProjectSecretForm = ({ children, onSuccess, projectSlug }) => {
|
|
9
|
+
const setProjectSecret = useSetProjectSecretMutation.useSetProjectSecretMutation();
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11
|
+
TenantForm.TenantForm,
|
|
12
|
+
{
|
|
13
|
+
onSuccess,
|
|
14
|
+
errorMapping: errorToField,
|
|
15
|
+
initialValues: {
|
|
16
|
+
key: "",
|
|
17
|
+
value: ""
|
|
18
|
+
},
|
|
19
|
+
validate: ({ values }) => {
|
|
20
|
+
const errors = [];
|
|
21
|
+
if (!values.key) {
|
|
22
|
+
errors.push({ code: "FIELD_REQUIRED", field: "key" });
|
|
23
|
+
}
|
|
24
|
+
if (!values.value) {
|
|
25
|
+
errors.push({ code: "FIELD_REQUIRED", field: "value" });
|
|
26
|
+
}
|
|
27
|
+
return errors;
|
|
28
|
+
},
|
|
29
|
+
execute: async ({ values }) => {
|
|
30
|
+
return await setProjectSecret({
|
|
31
|
+
projectSlug,
|
|
32
|
+
key: values.key,
|
|
33
|
+
value: values.value
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
const errorToField = {
|
|
41
|
+
PROJECT_NOT_FOUND: void 0
|
|
42
|
+
};
|
|
43
|
+
exports.SetProjectSecretForm = SetProjectSecretForm;
|
|
44
|
+
exports.useSetProjectSecretForm = useSetProjectSecretForm;
|
|
45
|
+
//# sourceMappingURL=SetProjectSecretForm.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetProjectSecretForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/SetProjectSecretForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { SetProjectSecretErrorCode } from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { useSetProjectSecretMutation } from '../../hooks/index.js'\n\nexport type SetProjectSecretFormValues = {\n\tkey: string\n\tvalue: string\n}\n\nexport type SetProjectSecretFormErrorCode =\n\t| SetProjectSecretErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'UNKNOWN_ERROR'\n\nexport type SetProjectSecretFormState = FormState\n\nexport type SetProjectSecretFormError = FormError<SetProjectSecretFormValues, SetProjectSecretFormErrorCode>\n\nexport type SetProjectSecretFormContextValue = FormContextValue<SetProjectSecretFormValues, SetProjectSecretFormErrorCode>\n\nexport interface SetProjectSecretFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tonSuccess?: () => void\n}\n\nexport const useSetProjectSecretForm = useForm as () => SetProjectSecretFormContextValue\n\nexport const SetProjectSecretForm = ({ children, onSuccess, projectSlug }: SetProjectSecretFormProps) => {\n\tconst setProjectSecret = useSetProjectSecretMutation()\n\treturn (\n\t\t<TenantForm<SetProjectSecretFormContextValue>\n\t\t\tonSuccess={onSuccess}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\tkey: '',\n\t\t\t\tvalue: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: SetProjectSecretFormError[] = []\n\t\t\t\tif (!values.key) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'key' })\n\t\t\t\t}\n\t\t\t\tif (!values.value) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'value' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await setProjectSecret({\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\tkey: values.key,\n\t\t\t\t\tvalue: values.value,\n\t\t\t\t})\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<SetProjectSecretErrorCode, keyof SetProjectSecretFormValues | undefined> = {\n\tPROJECT_NOT_FOUND: undefined,\n}\n"],"names":["useForm","useSetProjectSecretMutation","jsx","TenantForm"],"mappings":";;;;;;AA6BO,MAAM,0BAA0BA,SAAAA;AAEhC,MAAM,uBAAuB,CAAC,EAAE,UAAU,WAAW,kBAA6C;AACxG,QAAM,mBAAmBC,4BAAAA,4BAAA;AACzB,SACCC,2BAAAA;AAAAA,IAACC,WAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,QACd,KAAK;AAAA,QACL,OAAO;AAAA,MAAA;AAAA,MAER,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAsC,CAAA;AAC5C,YAAI,CAAC,OAAO,KAAK;AAChB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,OAAO;AAAA,QACrD;AACA,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACvD;AACA,eAAO;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,iBAAiB;AAAA,UAC7B;AAAA,UACA,KAAK,OAAO;AAAA,UACZ,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAGJ;AAEA,MAAM,eAAgG;AAAA,EACrG,mBAAmB;AACpB;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TenantForm } from "./TenantForm.js";
|
|
3
|
+
import { useForm } from "../../contexts.js";
|
|
4
|
+
import { useSetProjectSecretMutation } from "../../hooks/mutations/project/useSetProjectSecretMutation.js";
|
|
5
|
+
const useSetProjectSecretForm = useForm;
|
|
6
|
+
const SetProjectSecretForm = ({ children, onSuccess, projectSlug }) => {
|
|
7
|
+
const setProjectSecret = useSetProjectSecretMutation();
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
TenantForm,
|
|
10
|
+
{
|
|
11
|
+
onSuccess,
|
|
12
|
+
errorMapping: errorToField,
|
|
13
|
+
initialValues: {
|
|
14
|
+
key: "",
|
|
15
|
+
value: ""
|
|
16
|
+
},
|
|
17
|
+
validate: ({ values }) => {
|
|
18
|
+
const errors = [];
|
|
19
|
+
if (!values.key) {
|
|
20
|
+
errors.push({ code: "FIELD_REQUIRED", field: "key" });
|
|
21
|
+
}
|
|
22
|
+
if (!values.value) {
|
|
23
|
+
errors.push({ code: "FIELD_REQUIRED", field: "value" });
|
|
24
|
+
}
|
|
25
|
+
return errors;
|
|
26
|
+
},
|
|
27
|
+
execute: async ({ values }) => {
|
|
28
|
+
return await setProjectSecret({
|
|
29
|
+
projectSlug,
|
|
30
|
+
key: values.key,
|
|
31
|
+
value: values.value
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
children
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
const errorToField = {
|
|
39
|
+
PROJECT_NOT_FOUND: void 0
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
SetProjectSecretForm,
|
|
43
|
+
useSetProjectSecretForm
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=SetProjectSecretForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetProjectSecretForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/SetProjectSecretForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { SetProjectSecretErrorCode } from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm.js'\nimport { FormContextValue, FormError, FormState } from '../../types/index.js'\nimport { useForm } from '../../contexts.js'\nimport { useSetProjectSecretMutation } from '../../hooks/index.js'\n\nexport type SetProjectSecretFormValues = {\n\tkey: string\n\tvalue: string\n}\n\nexport type SetProjectSecretFormErrorCode =\n\t| SetProjectSecretErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'UNKNOWN_ERROR'\n\nexport type SetProjectSecretFormState = FormState\n\nexport type SetProjectSecretFormError = FormError<SetProjectSecretFormValues, SetProjectSecretFormErrorCode>\n\nexport type SetProjectSecretFormContextValue = FormContextValue<SetProjectSecretFormValues, SetProjectSecretFormErrorCode>\n\nexport interface SetProjectSecretFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tonSuccess?: () => void\n}\n\nexport const useSetProjectSecretForm = useForm as () => SetProjectSecretFormContextValue\n\nexport const SetProjectSecretForm = ({ children, onSuccess, projectSlug }: SetProjectSecretFormProps) => {\n\tconst setProjectSecret = useSetProjectSecretMutation()\n\treturn (\n\t\t<TenantForm<SetProjectSecretFormContextValue>\n\t\t\tonSuccess={onSuccess}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\tkey: '',\n\t\t\t\tvalue: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: SetProjectSecretFormError[] = []\n\t\t\t\tif (!values.key) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'key' })\n\t\t\t\t}\n\t\t\t\tif (!values.value) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'value' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await setProjectSecret({\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\tkey: values.key,\n\t\t\t\t\tvalue: values.value,\n\t\t\t\t})\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<SetProjectSecretErrorCode, keyof SetProjectSecretFormValues | undefined> = {\n\tPROJECT_NOT_FOUND: undefined,\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,0BAA0B;AAEhC,MAAM,uBAAuB,CAAC,EAAE,UAAU,WAAW,kBAA6C;AACxG,QAAM,mBAAmB,4BAAA;AACzB,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,QACd,KAAK;AAAA,QACL,OAAO;AAAA,MAAA;AAAA,MAER,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAsC,CAAA;AAC5C,YAAI,CAAC,OAAO,KAAK;AAChB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,OAAO;AAAA,QACrD;AACA,YAAI,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QACvD;AACA,eAAO;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,iBAAiB;AAAA,UAC7B;AAAA,UACA,KAAK,OAAO;AAAA,UACZ,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAGJ;AAEA,MAAM,eAAgG;AAAA,EACrG,mBAAmB;AACpB;"}
|