Skip to main content
Back to Browser

supportsCredential()

supportsCredential checks whether the signed-in user's type allows them to set the given credential for themselves. Without this check, a form for a credential the type doesn't declare would submit into a guaranteed 400, since POST /users/me/update-credentials only accepts schema-declared credential keys.

Signature

supportsCredential(
userSchema: Record<string, AttributeSchema> | null | undefined,
attribute: string,
): boolean

Parameters

ParameterTypeRequiredDescription
userSchemaRecord<string, AttributeSchema> | null | undefinedThe user type schema resolved by the provider, keyed by attribute.
attributestringThe credential attribute to check, e.g. 'password' or 'pin'.

Returns

boolean: false only when the schema is known and either defines no attribute named attribute or defines one that isn't marked credential: true.

An absent userSchema (still loading, or never fetched) resolves to true, so the affordance is never hidden on missing information alone. This only says the credential is declared on the type, not whether this particular account has one stored today; that second question is the server's to answer.

Usage

import { supportsCredential } from '@thunderid/browser'

if (!supportsCredential(userSchema, 'pin')) {
// Hide or disable the PIN change form; this account's type has no such credential.
}

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.