CodeProvider
Reference doc for the `CodeProvider`.
Configures a provider that supports pin code authentication. This is usually paired with the
CodeUI
.
You can customize the adapter using.
Behind the scenes, the CodeProvider
expects callbacks that implements request handlers
that generate the UI for the following.
This allows you to create your own UI.
Methods
CodeProvider
CodeProviderConfig
-
length?
number
-
request
(req:
Request
<
>
, state:CodeProviderState
, form?:FormData
<
>
, error?:CodeProviderError
) =>Promise
<
Response
<
>
>
-
sendCode
(claims:
Record
<
string
,string
>
, code:string
) =>Promise
<
void
|
CodeProviderError
>
CodeProviderConfig.length?
Type number
Default 6
The length of the pin code.
CodeProviderConfig.request
Type (req:
Request
<
>
, state: CodeProviderState
, form?: FormData
<
>
, error?: CodeProviderError
) => Promise
<
Response
<
>
>
The request handler to generate the UI for the code flow.
Takes the standard Request
and optionally FormData
ojects.
Also passes in the current state
of the flow and any error
that occurred.
Expects the Response
object
in return.
CodeProviderConfig.sendCode
Type (claims:
Record
<
string
, string
>
, code: string
) => Promise
<
void
|
CodeProviderError
>
Callback to send the pin code to the user.
CodeProviderError
Type {
type
:
“
invalid_code
”
}
|
{
key
:
string
,
type
:
“
invalid_claim
”
,
value
:
string
}
The errors that can happen on the code flow.
Error | Description |
---|---|
invalid_code | The code is invalid. |
invalid_claim | The claim, email or phone number, is invalid. |
CodeProviderState
Type {
type
:
“
start
”
}
|
{
claims
:
Record
<
string
, string
>
,
code
:
string
,
resend
:
boolean
,
type
:
“
code
”
}
The state of the code flow.
State | Description |
---|---|
start | The user is asked to enter their email address or phone number to start the flow. |
code | The user needs to enter the pin code to verify their claim. |