Credentials
Document Rails credentials are statically defined descriptors of credential kinds, fields, OID4VCI metadata, and other information useful for credential issuance.
By providing statically known data to Document Rails, you can print credentials, generate JSON-LD contexts and OID4VCI credential issuer metadata.
Usage
Credentials of all types are managed using a unified API, with specific credential types providing extended functionality through additional fields.
import { createCredential, CredentialVarType, StringifiedCredentialKind } from "@vaultie/document-rails";
const response = await createCredential(
client,
accessToken,
organizationId,
{
// Credential kind value, identifying semantics that should apply during the recipe processing.
credential_kind: StringifiedCredentialKind.W3C,
// Unique credential type value.
//
// Only one credential with a particular credential type
// may exist within an organization at the same time.
credential_type: "CinemaTicketCredential",
// Credential fields.
variables: {
// Simple fields can be specified in a form of just credential variable types.
givenName: CredentialVarType.String,
// Optionally, you may customize how fields should behave in different components
// by providing an object.
familyName: {
// Credential variable type (required).
type: CredentialVarType.String,
// OID4VCI credential issuer metadata generator information (optional).
//
// This information is used to provide localized information about
// credential fields.
//
// See OID4VCI specification for more information.
oid4vci_configuration: {
// Whether a given field is mandatory.
//
// This field does not influence the issuance process.
mandatory: false,
// Localized information on how to display a given field in a digital wallet.
display: [
{
name: "Last name",
locale: "en",
},
{
name: "Nom",
locale: "fr",
},
],
},
}
},
// Some configuration options are credential-specific.
// These options are available for W3C credentials.
// W3C contexts to utilize during the issuance process.
//
// Overriding context URLs is available through organization JSON-LD contexts.
// See "W3C" documentation for more information.
contexts: ["https://example.com/context/v2"],
// Type of the "credentialSubject" field within the issued W3C credential.
//
// Document Rails also utilizes this field during the JSON-LD context generation.
credential_subject_type: "CinemaTicket",
}
);
import { listCredentials } from "@vaultie/document-rails";
const response = await listCredentials(
client,
accessToken,
organizationId
);
import { deleteCredential } from "@vaultie/document-rails";
await deleteCredential(
client,
accessToken,
organizationId,
credentialId
);
Credential variable types
Credential variable types are static, but Document Rails can coerce a value of a given type into a value with a different type for output credential and template fields.
| Name | Numeric value | Description | Compatible with |
|---|---|---|---|
| String | 1 | A string value with any arbitrary value | String, Dynamic value |
| Date | 2 | A stringified date value | Date, String, Dynamic value |
| Image | 3 | A data-URL encoded stringified value with a PNG image within it | Image |
| Dynamic value | 4 | An arbitrary JSON object | Dynamic value |