WASM Client SDK
Installation
$ npm i @spruceid/rebase-clientUsage
// These are the types that will be regularly used by the application
import { Client, defaultClientConfig, Types } from "@spruceid/rebase-client";
// This is the inner, untyped WASM client that the above types will wrap.
import { WasmClient } from "@spruceid/rebase-client/wasm";
// Create the client, this is done to simplify build steps and wrap the untyped client
// in it's auto-generated types.
const client = new Client(new WasmClient(JSON.stringify(defaultClientConfig())));
// Get input from the user, format it into the request type for the client.
const getUserStatement = (): Types.BasicProfileAttestationStatement => {
// ...
};
// Save user input
const s = getUserStatement();
// Get the statement from the witness
let statementRes = await client.statement(s);
// Have a way to sign bytes using the subject provided in getUserStatement
const getUserSignature = (statement: string): string => {
// ...
};
// Issue the credential, in this case, a JWT.
let witnessRes = await client.witness_jwt(Types.BasicProfileAttestationProof {
statement: s,
signature: getUserSignature(statementRes.statement)
});
// Do something with the issued credential!
console.log(witnessRes.jwt)Last updated
Was this helpful?