saveCredential

suspend fun saveCredential(credentialId: String, publicKey: ByteArray, nickname: String? = null, contractId: String? = null): StoredCredential

Saves a credential to storage.

Saves a credential directly to storage with PENDING deployment status and isPrimary = false. Unlike createPendingCredential, this does not set deployment metadata (transports, deviceType, backedUp) and does not check for duplicates — if a credential with the same ID already exists, it is silently overwritten.

Validates that credentialId is non-empty and publicKey is exactly 65 bytes. A null contractId is stored as an empty string.

Return

The saved credential

Parameters

credentialId

The Base64URL-encoded credential ID (must not be empty)

publicKey

The uncompressed secp256r1 public key (65 bytes)

nickname

Optional user-friendly name for the credential

contractId

Optional smart account contract address (C-address). Null is stored as empty string.

Throws

if credentialId is empty or publicKey is wrong size

if saving fails

Example:

val credential = manager.saveCredential(
credentialId = "abc123",
publicKey = publicKeyData,
nickname = "MacBook Pro",
contractId = "CBCD1234..."
)