@ovok/native/auth
Sign-in, registration, password reset, profile and session components and hooks.
- Stable unknown
- Release candidate since 1.16.1-rc.3
- Development since 1.16.1-dev.2111+9796905
Sign-in, registration, password reset, profile and session components and hooks.
Import from @ovok/native/auth.
Components
DeleteAccountButton()
function DeleteAccountButton(__namedParameters): Element;Button that asks for confirmation, then deletes the account and signs out.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | DeleteAccountButtonProps |
Returns
Element
LogoutButton()
function LogoutButton(__namedParameters): Element;Button or row that signs the user out.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | LogoutButtonProps |
Returns
Element
ProfileForm()
function ProfileForm(props): Element;Profile form wrapped in its provider.
Parameters
| Parameter | Type |
|---|---|
props | ProfileFormProps |
Returns
Element
Register()
function Register(props): Element;Scrollable registration screen layout; compose it with the Register.* parts.
Parameters
| Parameter | Type |
|---|---|
props | KeyboardAwareScrollViewProps |
Returns
Element
ResetPassword()
function ResetPassword(props): Element;Scrollable reset password screen layout; compose it with the ResetPassword.* parts.
Parameters
| Parameter | Type |
|---|---|
props | KeyboardAwareScrollViewProps |
Returns
Element
SessionList()
function SessionList(__namedParameters): Element;Lists the active sessions and lets the user sign out the other devices.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | SessionListProps |
Returns
Element
SignIn()
function SignIn(props): Element;Scrollable sign-in screen layout; compose it with the SignIn.* parts.
Parameters
| Parameter | Type |
|---|---|
props | KeyboardAwareScrollViewProps |
Returns
Element
Hooks
useAcceptInviteLink()
function useAcceptInviteLink(__namedParameters): object;Accepts an invite link, or creates a carer account from a record-share invite.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | AcceptInviteLinkOptions |
Returns
| Name | Type | Description |
|---|---|---|
accept | Omit<AuthActionState<RecordShareAccepted>, "run"> & object | Accepts the invite link for the signed-in profile. |
createCarerAccount | Omit<AuthActionState<{ login: LoginResult; share: RecordShareAccepted; }>, "run"> & object | Accepts a record-share invite and signs in the new carer account. |
useAuthAction()
function useAuthAction<TArgs, TResult>(action): Omit<AuthActionState<TResult>, "run"> & object;Wraps an async auth action with status, loading and error state; concurrent runs share one call.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
action | (...args) => Promise<TResult> |
Returns
Omit<AuthActionState<TResult>, "run"> & object
useDeleteAccount()
function useDeleteAccount(__namedParameters?): Omit<AuthActionState<void>, "run"> & object;Deletes the signed-in account and signs out.
Parameters
| Parameter | Type |
|---|---|
__namedParameters? | DeleteAccountOptions |
Returns
Omit<AuthActionState<void>, "run"> & object
useRateLimitCooldown()
function useRateLimitCooldown(until?): number;Returns the milliseconds left until until (epoch milliseconds), updating every second.
Parameters
| Parameter | Type |
|---|---|
until? | number |
Returns
number
useSession()
function useSession(__namedParameters?): UseSessionResult;Tracks the current Ovok session, saved accounts and profile.
Parameters
| Parameter | Type |
|---|---|
__namedParameters? | UseSessionOptions |
Returns
useSignIn()
function useSignIn(options): object;Signs in with email and password and verifies the MFA challenge when one is required.
Parameters
| Parameter | Type |
|---|---|
options | SignInOptions |
Returns
| Name | Type | Default value | Description |
|---|---|---|---|
error? | Error | - | Error of the last run, if it failed. |
loading | boolean | - | Whether the action is running. |
mfaError | Error | undefined | verifyMfa.error | Error of the last MFA verification. |
mfaLoading | boolean | verifyMfa.loading | Whether MFA verification is running. |
mfaStatus | AuthActionStatus | verifyMfa.status | Stage of the MFA verification. |
reset() | () => void | - | Returns the action to idle and clears the error. |
run() | (...args) => Promise<LoginResult> | - | Runs the action with args; a call made while one is pending returns the pending promise. |
status | AuthActionStatus | - | Current stage. |
verifyMfa() | (...args) => Promise<LoginResult> | verifyMfa.run | Verifies an MFA challenge with the code the user entered. |
useSignOut()
function useSignOut(): Omit<AuthActionState<void>, "run"> & object;Signs out the current session.
Returns
Omit<AuthActionState<void>, "run"> & object
useSocialSignIn()
function useSocialSignIn(options): Omit<AuthActionState<Session>, "run"> & object;Signs in with Google or Apple and exchanges the credentials for an Ovok session.
Parameters
| Parameter | Type |
|---|---|
options | SocialSignInOptions |
Returns
Omit<AuthActionState<Session>, "run"> & object
Functions
getRateLimitDetails()
function getRateLimitDetails(error): RateLimitDetails | undefined;Supports @ovok/core's typed error while remaining compatible with HTTP 429 adapters.
Parameters
| Parameter | Type |
|---|---|
error | unknown |
Returns
RateLimitDetails | undefined
isNetworkError()
function isNetworkError(error, message?): boolean;Whether the error, or its message, indicates a network failure.
Parameters
| Parameter | Type |
|---|---|
error | unknown |
message? | unknown |
Returns
boolean
parseInviteLink()
function parseInviteLink(link): AcceptInviteBody;Reads invite and code from an …/accept-invite?invite=…&code=… link.
Parameters
| Parameter | Type |
|---|---|
link | string |
Returns
AcceptInviteBody
parseSignInError()
function parseSignInError(error, options?): ParsedSignInError;Converts auth transport/server failures to safe, translatable error keys.
Parameters
| Parameter | Type |
|---|---|
error | unknown |
options? | { errorScope?: "register" | "reset-password"; isMfaVerification?: boolean; isSignIn?: boolean; } |
options.errorScope? | "register" | "reset-password" |
options.isMfaVerification? | boolean |
options.isSignIn? | boolean |
Returns
setRateLimitFormError()
function setRateLimitFormError<T>(error, helpers): RateLimitDetails | undefined;Writes the rate limit error and cooldown deadline to the Formik form; returns the details, or undefined when the error is not a rate limit.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
error | unknown |
helpers | FormikHelpers<T> |
Returns
RateLimitDetails | undefined
Interfaces
AcceptInviteLinkOptions
Options of useAcceptInviteLink.
Properties
AuthActionState
State of an auth action.
Type Parameters
Properties
| Property | Type | Description |
|---|---|---|
error? | Error | Error of the last run, if it failed. |
loading | boolean | Whether the action is running. |
reset | () => void | Returns the action to idle and clears the error. |
run | () => Promise<TResult> | Runs the action. |
status | AuthActionStatus | Current stage. |
DeleteAccountOptions
Options of useDeleteAccount.
Properties
| Property | Type | Description |
|---|---|---|
days? | number | Days before the deletion becomes final. |
wipe? | boolean | Whether to also wipe the account data. |
ParsedSignInError
Sign-in error and the per-field errors parsed from it.
Properties
| Property | Type | Description |
|---|---|---|
error | SignInError | Normalized error. |
fieldErrors | ValidationError[] | Validation errors keyed by field. |
RateLimitDetails
Rate limit information extracted from an error.
Properties
| Property | Type | Description |
|---|---|---|
messageKey | string | Translation key of the message to show. |
retryAfterMs | number | Milliseconds until the user may retry. |
SignInCredentials
Email and password to sign in with.
Properties
UseSessionOptions
Options of useSession.
Properties
| Property | Type | Description |
|---|---|---|
refreshOnForeground? | boolean | Whether to refresh when the app returns to the foreground. |
sessions? | boolean | Whether to load the list of active sessions. |
UseSessionResult
Session state and actions returned by useSession.
Extends
SessionSnapshot
Properties
Type Aliases
AppleLoginProps
type AppleLoginProps = Omit<TouchableOpacityProps, "onPress" | "onPressIn" | "onPressOut" | "onLongPress" | "children"> & object;Props of SignIn.SocialLogins.AppleLogin.
Type Declaration
| Name | Type | Description |
|---|---|---|
appleRedirectUri? | string | Web only: a Return URL registered for the Services ID. Defaults to this site's origin. |
appleServicesId? | string | Web only: the Services ID Apple signs the user in for. Without it the button renders nothing on the web. |
children | React.ReactNode | Button content, usually AppleLogin.Icon and AppleLogin.Text. |
internalId | string | The external-auth-internal-id of the Apple entry on the ClientApplication; the web needs its own entry. |
onError()? | (error) => void | Called when sign-in fails; a cancelled sign-in is not an error. |
onSuccess()? | (loginResponse) => void | Called with the session once the user has signed in. |
testID? | string | Test identifier of the button. |
AuthActionStatus
type AuthActionStatus = "idle" | "loading" | "success" | "error";Stage of an auth action.
FooterProps
type FooterProps = object;Props of the sign-in footer.
Properties
testID?
testID?: string;Test identifier of the footer.
GoogleLoginProps
type GoogleLoginProps = Omit<TouchableOpacityProps, "onPress" | "onPressIn" | "onPressOut" | "onLongPress" | "children"> & object;Props of SignIn.SocialLogins.GoogleLogin.
Type Declaration
| Name | Type | Description |
|---|---|---|
children | React.ReactNode | Button content, usually GoogleLogin.Icon and GoogleLogin.Text. |
googleIosClientId | string | Google OAuth client ID for iOS; the web ignores it. |
googleRedirectUri? | string | Web only: the redirect URI Google returns to, which must be an Authorized redirect URI of the web client. Defaults to /oauth/google.html on this site, where the app serves GOOGLE_RETURN_PAGE_HTML. |
googleWebClientId | string | Google OAuth web client ID. On the web it is the client ID the sign-in page asks Google for. |
internalId | string | The external-auth-internal-id of the Google entry on the ClientApplication. |
onError()? | (error) => void | Called when sign-in fails; a cancelled sign-in is not an error. |
onSuccess()? | (loginResponse) => void | Called with the session once the user has signed in. |
testID? | string | Test identifier of the button. |
LoginFormProps
type LoginFormProps = object & (
| {
onError?: (error) => void;
onSubmit?: undefined;
onSuccess?: (response) => void;
}
| {
onError?: undefined;
onSubmit?: (values, formikHelpers) => Promise<void>;
onSuccess?: undefined;
}) & (
| {
loginType: "Patient" | "RelatedPerson";
tenantCode: string;
}
| {
loginType: "Practitioner";
tenantCode?: string;
});Props of the sign-in form.
Type Declaration
| Name | Type | Description |
|---|---|---|
children? | React.ReactNode | Content rendered inside the form. |
customValidations? | { [key in keyof LoginFormValues]?: Yup.StringSchema | ((existingRule: Yup.StringSchema) => Yup.StringSchema) } | Per-field validation rules or functions that extend the default rule. |
style? | StyleProp<ViewStyle> | Style of the form container. |
testID? | string | Test identifier of the form. |
LoginWithSeparatorProps
type LoginWithSeparatorProps = object;Props of the sign-in separator.
Properties
lineColor?
lineColor?: string;Color of the separator lines.
testID?
testID?: string;Test identifier of the separator.
textColor?
textColor?: string;Color of the separator text.
ProfileFormField
type ProfileFormField = ProfileFormFieldBase & (
| {
options: object[];
type: "select";
}
| {
display?: DateFieldProps["display"];
formatValue?: DateFieldProps["formatValue"];
initialDate?: DateFieldProps["initialDate"];
locale?: DateFieldProps["locale"];
maximumDate?: DateFieldProps["maximumDate"];
minimumDate?: DateFieldProps["minimumDate"];
mode?: DateFieldProps["mode"];
type: "date";
}
| {
inputProps?: TextInputFieldProps;
keyboardType?: TextInputProps["keyboardType"];
type: "text";
}
| {
options: object[];
type: "choice";
}
| {
countryName?: (code, language) => string;
defaultCountry: CountryCode;
type: "phone";
});Field definition of the profile form, discriminated by type.
ProfileFormProps
type ProfileFormProps = object;Props of the profile form.
Properties
fields
fields: ProfileFormField[];Fields to render and edit.
onError?
onError?: (error) => void;Called when saving fails.
Parameters
| Parameter | Type |
|---|---|
error | unknown |
Returns
void
onSubmit?
onSubmit?: (values, formikHelpers) => Promise<void> | void;Replaces the default save; use it to handle the submitted values yourself.
Parameters
| Parameter | Type |
|---|---|
values | ProfileFormValues |
formikHelpers | FormikHelpers<ProfileFormValues> |
Returns
Promise<void> | void
onSuccess?
onSuccess?: (response, values) => Promise<void> | void;Called with the updated patient and the submitted values after a successful save.
Parameters
| Parameter | Type |
|---|---|
response | Patient |
values | ProfileFormValues |
Returns
Promise<void> | void
style?
style?: StyleProp<ViewStyle>;Style of the form container.
testID?
testID?: string;Test identifier of the form.
ProfileFormValues
type ProfileFormValues = object;Profile form values keyed by field name.
Indexable
[key: string]: stringProperties
submit
submit: string;Holds the submit error message.
RegisterFormValues
type RegisterFormValues = PatientRegistration & object;Registration values plus form-only fields.
Type Declaration
| Name | Type | Description |
|---|---|---|
fullName? | string | Full name, split into name and surname by the app. |
submit | string | Holds the submit error message. |
ResetPasswordButtonProps
type ResetPasswordButtonProps = AuthSubmitButtonProps;Props of the reset password submit button.
ResetPasswordContextType
type ResetPasswordContextType = ReturnType<typeof useFormik> & object;Formik state of the reset password form.
Type Declaration
| Name | Type | Description |
|---|---|---|
typeLocked? | boolean | Whether the profile type is fixed and its input hidden. |
ResetPasswordFormValues
type ResetPasswordFormValues = object;Values of the reset password form.
Properties
email: string;Account email.
submit
submit: string;Holds the submit error message.
type
type: "Patient" | "Practitioner" | "RelatedPerson";Profile type of the account.
ResetPasswordHeaderProps
type ResetPasswordHeaderProps = AuthHeaderProps;Props of the reset password header.
ResetPasswordProps
type ResetPasswordProps = KeyboardAwareScrollViewProps;Props of ResetPassword.
SessionListProps
type SessionListProps = ViewProps & object;Props of SessionList: view props plus an error callback.
Type Declaration
| Name | Type | Description |
|---|---|---|
onError()? | (error) => void | Called when loading or revoking sessions fails. |
SigninButtonProps
type SigninButtonProps = AuthSubmitButtonProps;Props of the sign-in submit button.
SignInError
type SignInError = Error & object;Error enriched with the HTTP status and request details of a failed sign-in.
Type Declaration
| Name | Type | Description |
|---|---|---|
code? | string | Machine-readable error code. |
requestId? | string | Request ID to quote when contacting support. |
retryAfterMs? | number | Milliseconds to wait before retrying, when rate limited. |
status? | number | HTTP status code of the failed request. |
SigninFormForgotPasswordProps
type SigninFormForgotPasswordProps<TVariant> = TouchableOpacityProps & object;Props of the forgot password link.
Type Parameters
Type Declaration
| Name | Type | Description |
|---|---|---|
textProps? | Omit<TextProps<TVariant>, "children"> | Props of the link text. |
SignInHeaderProps
type SignInHeaderProps = AuthHeaderProps;Props of the sign-in header.
SignInOptions
type SignInOptions =
| {
tenantCode: string;
type: "Patient" | "RelatedPerson";
}
| {
tenantCode?: string;
type: "Practitioner";
};Profile type and tenant to sign in to.
Union Members
Type Literal
{
tenantCode: string;
type: "Patient" | "RelatedPerson";
}| Name | Type | Description |
|---|---|---|
tenantCode | string | Tenant to sign in to. |
type | "Patient" | "RelatedPerson" | Sign in as a patient or related person. |
Type Literal
{
tenantCode?: string;
type: "Practitioner";
}| Name | Type | Description |
|---|---|---|
tenantCode? | string | Tenant to sign in to, when applicable. |
type | "Practitioner" | Sign in as a practitioner. |
SignInProps
type SignInProps = KeyboardAwareScrollViewProps;Props of SignIn.
SocialLoginsProps
type SocialLoginsProps = object;Props of SocialLogins.
Properties
style?
style?: StyleProp<ViewStyle>;Style of the container.
testID?
testID?: string;Test identifier of the container.
SocialSignInOptions
type SocialSignInOptions =
| {
googleIosClientId: string;
googleWebClientId: string;
internalId: string;
provider: "google";
}
| {
internalId: string;
provider: "apple";
};Social provider and its configuration.
Union Members
Type Literal
{
googleIosClientId: string;
googleWebClientId: string;
internalId: string;
provider: "google";
}| Name | Type | Description |
|---|---|---|
googleIosClientId | string | Google OAuth client ID for iOS. |
googleWebClientId | string | Google OAuth web client ID. |
internalId | string | Identifier of the app the sign-in belongs to. |
provider | "google" | Sign in with Google. |
Type Literal
{
internalId: string;
provider: "apple";
}| Name | Type | Description |
|---|---|---|
internalId | string | Identifier of the app the sign-in belongs to. |
provider | "apple" | Sign in with Apple. |
SpacingProps
type SpacingProps = ViewProps & object;Props of Spacing: view props plus the flex share.
Type Declaration
| Name | Type | Description |
|---|---|---|
percentage | number | Flex value of the spacer. |
Variables
DEFAULT_RATE_LIMIT_RETRY_MS
const DEFAULT_RATE_LIMIT_RETRY_MS: 60000 = 60_000;Retry delay used when the error carries none.
GOOGLE_RETURN_PAGE_HTML
const GOOGLE_RETURN_PAGE_HTML: string;The page Google returns to when GoogleLogin signs in on the web.
Serve it as a static file at the redirect URI, by default /oauth/google.html. It keeps Google's answer
for this tab and sends the tab back to the sign-in screen, so the token never stays in the address.
RATE_LIMIT_MESSAGE_KEY
const RATE_LIMIT_MESSAGE_KEY: "auth.rate-limit" = "auth.rate-limit";Translation key of the rate limit message.
Last updated on