Interface ApiTokenAuthDefinitionInput<Credential, UserInputsSchema>
interface ApiTokenAuthDefinitionInput {
getCredentialDataFromUserInputs: ((opts) => Credential["data"] | Promise<Credential["data"]>);
getCredentialOption: GetCredentialOptionFn<Credential>;
refreshTokens?: ((opts) => Credential["data"] | Promise<Credential["data"]>);
singleCredentialOnly?: boolean;
testConnection: ((opts) => Promise<boolean>);
userInputsSchema: UserInputsSchema;
}
getCredentialDataFromUserInputs: ((opts) => Credential["data"] | Promise<Credential["data"]>);
getCredentialOption: GetCredentialOptionFn<Credential>;
refreshTokens?: ((opts) => Credential["data"] | Promise<Credential["data"]>);
singleCredentialOnly?: boolean;
testConnection: ((opts) => Promise<boolean>);
userInputsSchema: UserInputsSchema;
}
Type Parameters
Credential extends AnyAppCredential
UserInputsSchema extends AuthUserInputDefinition[]
Properties
getCredentialDataFromUserInputs
getCredentialDataFromUserInputs : ((opts) => Credential["data"] | Promise<Credential["data"]>)
Type declaration
- (opts): Credential["data"] | Promise<Credential["data"]>
Parameters
opts: {
httpRequest: {
ipAddress: null | string;
userAgent: string;
};
userInputs: InferAuthUserInputsType<UserInputsSchema>;
}http
Request : {
ipAddress: null | string;
userAgent: string;
}ip
Address : null | stringuser
Agent : string
user
Inputs : InferAuthUserInputsType<UserInputsSchema>
Returns Credential["data"] | Promise<Credential["data"]>
getCredentialOption
getCredentialOption : GetCredentialOptionFn<Credential>
Receives a Credential and should return the avatar and label for this credential. It's called every time a credential is rendered in UI.
Optional
refreshTokens
refreshTokens ?: ((opts) => Credential["data"] | Promise<Credential["data"]>)
Type declaration
- (opts): Credential["data"] | Promise<Credential["data"]>
Receives the credential, should refresh it if needed and return new credential data.
Parameters
Returns Credential["data"] | Promise<Credential["data"]>
Optional
singleCredentialOnly
singleCredentialOnly ?: boolean
If true, it's assumed there will be always one credential only at most, therefore UI for selecting credential won't not rendered.
Default
false
testConnection
testConnection : ((opts) => Promise<boolean>)
Type declaration
- (opts): Promise<boolean>
Receives Credential data, as specified by
Credential
type and should returntrue
/false
depending on whether the credential works.Parameters
opts: {
httpRequest: {
ipAddress: null | string;
userAgent: string;
};
userInputs: InferAuthUserInputsType<UserInputsSchema>;
}http
Request : {
ipAddress: null | string;
userAgent: string;
}ip
Address : null | stringuser
Agent : string
user
Inputs : InferAuthUserInputsType<UserInputsSchema>
Returns Promise<boolean>
userInputsSchema
userInputsSchema : UserInputsSchema
List of inputs to render when adding a new credential in UI.
Receives the field values defined by userInputsSchema and should return the credential data