Operations
Below are the methods exposed by the CYS keymaster client SDKs.
DID Operations
Create an Identity
- Node.js
- Java
await Keymaster.createId({ name: "Paul Revere" });
String did = keymaster.createId("Alice");
System.out.println("DID: " + did);
Get a DID Document
- Node.js
- Java
await Keymaster.resolveDID({
did: "did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
});
System.out.println(keymaster.resolveDID(did).didDocument.id);
Delete a DID
- Node.js
- Java
await Keymaster.removeId({
did: "did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
});
keymaster.revokeDID(did); // deactivates DID on network
keymaster.removeId("Alice"); // removes local wallet entry
Set Current DID
- Node.js
- Java
await Keymaster.setCurrentId("identity-name-1");
keymaster.setCurrentId("Alice");
Templates / Schemas
Create a Template / Schema
- Node.js
- Java
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"],
};
await Keymaster.createSchema(schema);
Map<String, Object> emailSchema = new HashMap<>();
emailSchema.put("$schema", "http://json-schema.org/draft-07/schema#");
Map<String, Object> properties = new HashMap<>();
Map<String, Object> email = new HashMap<>();
email.put("format", "email");
email.put("type", "string");
properties.put("email", email);
emailSchema.put("properties", properties);
emailSchema.put("required", List.of("email"));
emailSchema.put("type", "object");
String schemaDid = keymaster.createSchema(emailSchema);
Challenges & Responses
Create a Challenge
- Node.js
- Java
await Keymaster.createChallenge({
callback: "https://www.your-domain.com/api/auth",
});
Map<String, Object> challenge = Map.of(
"credentials",
List.of(
Map.of(
"schema",
credentialDid,
"issuers",
List.of(alice)
)
)
);
String challengeDid = keymaster.createChallenge(challenge);
Create a Response
- Node.js
- Java
await Keymaster.createResponse(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
);
String responseDid = keymaster.createResponse(challengeDid);
Verify Response
- Node.js
- Java
await Keymaster.verifyResponse(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
);
Map<String, Object> verify = keymaster.verifyResponse(responseDid);
System.out.println(verify.get("match"));
Credentials
Issue Credential
- Node.js
- Java
await Keymaster.issueCredential(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
);
String credentialDid = keymaster.issueCredential(bound);
Bind Credential
- Node.js
- Java
await Keymaster.bindCredential(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZw",
);
Map<String, Object> bound = keymaster.bindCredential(schemaDid, aliceDid);
Get Credential
- Node.js
- Java
await Keymaster.getCredential(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
);
@SuppressWarnings("unchecked")
Map<String, Object> vc = (Map<String, Object>) keymaster.getCredential(credentialDid);
Update a Credential
- Node.js
- Java
await Keymaster.updateCredential(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
{},
);
keymaster.updateCredential(credentialDid, vc);
Accept Credentials
- Node.js
- Java
await Keymaster.acceptCredential(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
);
keymaster.acceptCredential(credentialDid);
Decrypt Message
- Node.js
- Java
await Keymaster.decryptMessage(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
);
String message = keymaster.decryptMessage(cipherDid);
System.out.println(message);
Publish Credentials
- Node.js
- Java
await Keymaster.publishCredential(
"did:test:z3v8AuagJiXARFGw3B8Mc6DrLBC2thMzjgeUZWQvHcyPVBxAYZv",
{ reveal: true },
);
PublishCredentialOptions publish = new PublishCredentialOptions();
publish.reveal = true;
keymaster.publishCredential(credentialDid, publish);
Custom Headers
Add Custom Header
- Node.js
- Java
await Keymaster.addCustomHeader("authorization", "base64-encoded-string");
// Not supported in Java Keymaster API.
// Java Keymaster runs as an in-process library, not a hosted SDK service.
// Set HTTP headers in your application's own transport/client layer.
Remove Custom Header
- Node.js
- Java
await Keymaster.removeCustomHeader("authorization");
// Not supported in Java Keymaster API.
// Java Keymaster runs as an in-process library, not a hosted SDK service.
// Clear HTTP headers in your application's own transport/client layer.