SpruceKit
SpruceID
  • 🌲SpruceKit Introduction
    • Decentralized Identity Overview
    • Glossary
  • ⚡Quickstart
  • SpruceKit Mobile
    • SpruceKit Showcase App
      • Installation
      • Getting Started
      • Issue a Showcase Credential
      • Present a Showcase Credential
    • SpruceKit Mobile SDK
      • Introduction
      • Core Components
        • StorageManager
        • KeyManager
        • CredentialPack
        • Card
        • IsoMdlPresentation
        • mDocReader/IsomDLReader
        • Document Scanner
      • SpruceKit iOS SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
      • SpruceKit Android SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present an mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
  • Verifiable Digital Credentials
    • ⚙️DIDKit
      • Installation
      • Core Concepts
      • DID Methods
      • Runtime Configuration
      • Specifications and Dependencies
      • Quickstart
      • DIDKit Packages
        • Command Line Interface
        • HTTP Server
        • Rust Crate
        • C Interface
        • Java and Android
        • Python
        • Javascript
      • DIDKit Examples
        • Core Functions (CLI)
        • Core Functions (HTTP)
        • did-web in minutes
        • Batch Generation & Verification
    • 🪪ISO mDL
      • Quickstart
      • Core Concepts
      • User Guide
  • Schema Definition Language
    • 🔗TreeLDR
      • TreeLDR Quickstart
        • First Schema
        • Compilation into JSON Schema
        • Compilation into JSON-LD Context
        • Writing a Layout
        • Simple Rust Integration
      • Types
        • Literal Types
      • Layouts
        • Primitive Layouts
        • Literal Layouts
        • Enumeration
        • Array Layout
        • References
      • Compiling
        • Schema Definition Formats
          • JSON Schema
          • JSON-LD Context
          • Resource Description Framework (RDF)
        • Programming Languages
          • Compiling to Rust
      • RDF Vocabulary
      • 💡TreeLDR Basics
        • Types and Layouts
        • Properties
        • Syntax
  • Witness for Credential Claims
    • 🔭Rebase
      • Core Library
      • Rust Client/Witness SDK
      • WASM Client SDK
      • Simple "Basic Post" Schema
      • DNS Witness Flow Schema
  • References
    • Contributing
    • Code of Conduct
Powered by GitBook
On this page

Was this helpful?

  1. Witness for Credential Claims
  2. Rebase

WASM Client SDK

PreviousRust Client/Witness SDKNextSimple "Basic Post" Schema

Last updated 11 months ago

Was this helpful?

The source for this project can be found .

This Rust-to-WASM compiled library is a thin wrapper around the client portion of the Rebase Witness SDK. It makes several design choices that make usage in WASM easier. An example of this client in use is here.

This client includes Typescript types generated via the underlying Rust code, so all arguments are well specified and de/serialization code at the borders between JS and WASM have largely been avoided (the only place it's still needed is creating the client initially, shown below). This should at least make it easier to reason about.

Installation

Install throughnpm:

Copy

$ npm i @spruceid/rebase-client

Usage

Basic usage is as follows:

Copy

// 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)
🔭
here