useOtpCredential ​
Hook that creates an otp credential
browser
low
test coverage
 Last changed: last month
Installation ​
Library
CLI
Manual
typescript
import { useOtpCredential } from '@siberiacancode/reactuse';Usage ​
typescript
useOtpCredential((credential) => console.log(credential));
// or
useOtpCredential({ onSuccess: (credential) => console.log(credential), onError: (error) => console.log(error) });Demo ​
Api ​
Parameters
| Name | Type | Default | Note | 
|---|---|---|---|
| callback | UseOtpCredentialCallback | - | The callback function to be invoked | 
Returns
UseOtpCredentialReturn
Parameters
| Name | Type | Default | Note | 
|---|---|---|---|
| params.onSuccess | UseOtpCredentialCallback | - | The callback function to be invoked on success | 
| params.onError | UseOtpCredentialCallback | - | The callback function to be invoked on error | 
Returns
UseOtpCredentialReturn
Type declaration ​
typescript
interface OTPOptions {
    readonly transport: string[];
  }
interface CredentialRequestOptions {
    readonly otp: OTPOptions;
  }
interface Credential {
    readonly code: string;
  }
export type UseOtpCredentialCallback = (otp: Credential | null) => void;
export interface UseOtpCredentialParams {
  /* The callback function to be invoked on error */
  onError: (error: any) => void;
  /* The callback function to be invoked on success */
  onSuccess: (credential: Credential | null) => void;
}
export interface UseOtpCredentialReturn {
  /* The abort function */
  abort: AbortController['abort'];
  /*  The aborted state of the query */
  aborted: boolean;
  /* The supported state of the otp credential */
  supported: boolean;
  /* The get otp credential function */
  get: () => Promise<Credential | null>;
}
export interface UseOtpCredential {
  (callback?: UseOtpCredentialCallback): UseOtpCredentialReturn;
  (params?: UseOtpCredentialParams): UseOtpCredentialReturn;
}Source ​
Source • DemoContributors ​
D