Create a Template / Schema
Schemas define the data structure of the credential being requested or issued. They are referenced as Templates in the SELF mobile app for language simplification purposes.
note
Ensure that Keymaster is installed, initialized, and started as described in the Keymaster installation documentation before creating a schema.
import { Keymaster } from "@yourself_id/siwys-api-js";
const schema = {
$schema: "http://json-schema.org/draft-07/schema#",
title: "Drivers License",
type: "object",
properties: {
licenseNumber: 1234567890,
firstName: "Paul",
lastName: "Revere",
isValid: true,
},
required: ["licenseNumber", "firstName", "lastName"],
};
const schemaDid = await Keymaster.createSchema(schema);
const retrievedSchema = await Keymaster.resolveDID(schemaDid);
Your application can then use the schema DID to create challenges or issue credentials that reference the schema. The SELF mobile app will display the title of the schema when the user is prompted to respond to a challenge or accept a credential offer that references the schema. It is best practice to store your schemas following generation for convenient access.