Type alias JWTAuthDefinitionInput<Cred>

JWTAuthDefinitionInput<Cred>: {
    getCredentialFromJWT: ((ctx) => Cred | Promise<Cred>);
    getCredentialOption: GetCredentialOptionFn<Cred>;
    refreshTokens?: ((ctx) => Promise<Cred["data"]>);
    singleCredentialOnly?: boolean;
}

Type Parameters

Type declaration

  • getCredentialFromJWT: ((ctx) => Cred | Promise<Cred>)
      • (ctx): Cred | Promise<Cred>
      • Called on every incoming Consumer request. Receives the authData from the consumer JWT token and should return the credential to be stored.

        Parameters

        • ctx: {
              authData: unknown;
              consumer: Consumer;
          }

        Returns Cred | Promise<Cred>

  • getCredentialOption: GetCredentialOptionFn<Cred>

    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?: ((ctx) => Promise<Cred["data"]>)
      • (ctx): Promise<Cred["data"]>
      • Called every time Rollout is about to use a credential and can be used to refresh the credential, if needed. Receives the stored credential and should return a valid credential, whether it's the received one, or a fresh one.

        Parameters

        • ctx: {
              consumer: Consumer;
              credential: Cred;
          }

        Returns Promise<Cred["data"]>

  • Optional 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