The credentials module provides W3C Verifiable Credentials backed by BSV MasterCertificate cryptography. It includes schema definition, credential issuance/verification/revocation, and wallet-side acquisition.
Source: src/modules/credentials.ts
CredentialSchema
Defines the fields, validation, and computed values for a credential type.
Copy new CredentialSchema ( config : CredentialSchemaConfig ) schema.validate()
Copy validate ( values : Record < string , string > ): string | null Validate field values. Returns null if valid, or an error message string.
Checks:
Required fields are present and non-empty
Custom validate function (if provided)
schema.computeFields()
Merge computed fields into values. Returns a new object with original values plus computed additions.
schema.getInfo()
schema.getConfig()
Returns the full configuration object. Used when creating a CredentialIssuer.
CredentialIssuer
Issues, verifies, and revokes Verifiable Credentials.
CredentialIssuer.create()
Throws: CredentialError if revocation is enabled but no wallet is provided.
Issue a Verifiable Credential.
What happens:
Validates fields against the schema
If revocation enabled: creates a hash-lock UTXO (OP_SHA256 <hash> OP_EQUAL, 1 satoshi), saves secret to store
Issues a MasterCertificate
Wraps in W3C Verifiable Credential format
Throws: CredentialError if schema not found or validation fails.
issuer.verify()
Verify a Verifiable Credential.
Returns:
Checks:
VerifiableCredential type is present
Proof and signature are present
BSV certificate data is present
Revocation status (checks if secret still exists in store)
issuer.revoke()
Revoke a credential by spending its hash-lock UTXO.
What happens:
Loads the revocation record (secret + outpoint) from the store
Creates an unlocking script with the secret
Spends the hash-lock UTXO
Deletes the record from the store
Throws: CredentialError if revocation is not enabled, or the certificate is not found/already revoked.
issuer.isRevoked()
Check if a credential has been revoked. Returns true if the revocation record no longer exists in the store.
issuer.getInfo()
Revocation Stores
MemoryRevocationStore
In-memory storage for browser and tests.
FileRevocationStore
File-based storage for Node.js servers.
Add the secrets file to .gitignore.
RevocationStore Interface
Both stores implement:
Standalone Utilities
toVerifiableCredential()
Wrap a BSV CertificateData into a W3C Verifiable Credential envelope.
toVerifiablePresentation()
Wrap an array of VCs into a W3C Verifiable Presentation.
acquireCredential()
Acquire a Verifiable Credential from a remote issuer server.
listCredentials()
List wallet certificates wrapped as Verifiable Credentials.
createPresentation()
Wrap Verifiable Credentials into a Verifiable Presentation. Synchronous .