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
| Parameter | Type | Required | Description |
|---|---|---|---|
userSchema | Record<string, AttributeSchema> | null | undefined | ✅ | The user type schema resolved by the provider, keyed by attribute. |
attribute | string | ✅ | The 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.
}
Related
resolveChangeCredentialPolicy(): Reads the sameuserSchemafor the credential's validation rulesupdateMeCredentials(): The write this check protects against a guaranteed failure