npm package: @hovi/core-sdk
Description: TypeScript SDK for Hovi Core
Latest version: 0.2.0

# ![Hovi SDK Logo](https://is1-ssl.mzstatic.com/image/thumb/Purple211/v4/62/ef/ab/62efab72-f110-39b6-ecd8-f1110652714c/AppIcon-0-0-1x_U007epad-0-1-85-220.png/1200x600wa.png)

# Hovi Core SDK

[![NPM Version](https://img.shields.io/npm/v/@hovi/core-sdk?color=green&label=NPM)](https://www.npmjs.com/package/@hovi/core-sdk) [![Build Status](https://img.shields.io/npm/dm/@hovi/core-sdk.svg)](https://www.npmjs.com/package/@hovi/core-sdk)

**Build cross-ecosystem verifiable credential flows, effortlessly**

Hovi Core SDK is a TypeScript library that streamlines decentralized identity workflows across multiple ecosystems (**OpenID, Indicio, Cheqd, Privado**). Whether you're issuing credentials, managing DIDComm connections, or verifying proofs, the SDK provides methods for different credential formats like **JSON-LD, Anoncreds, SD-JWT, and mDoc**.

---

## Table of Contents

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)

  - [ Tenant Management](#tenant-management)
  - [ Connections](#connections)
  - [Credentials Issuance](#credentials-issuance)
  - [ Credential Verification](#credential-verification)

- [API Reference](#api-reference)

---

## Installation

```bash
# Using npm
npm install @hovi/core-sdk

# Using Yarn
yarn add @hovi/core-sdk
```

---

## How to Get an API Key

To use the Core SDK, you’ll need an API key.  
You can generate one from the [Hovi Dashboard](https://studio.hovi.id/ecosystem/api-keys)

---

## Quick Start

```ts
import {
  OpenIdEcosystem,
  IndicioEcosystem,
  CheqdEcosystem,
  PrivadoEcosystem,
} from "@hovi/core-sdk";

const openid = new OpenIdEcosystem({ apiKey: "your-openid-api-key" });

const indicio = new IndicioEcosystem({ apiKey: "your-indicio-api-key" });

const cheqd = new CheqdEcosystem({ apiKey: "your-cheqd-api-key" });

const privado = new PrivadoEcosystem({ apiKey: "your-privado-api-key" });
```

## Usage

The SDK provides simple methods for managing tenants, establishing connections, issuing credentials, and verifying proofs.

### Tenant Management

Creates a new tenant in the Hovi ecosystem, which is required for managing credentials, verifications, and related operations

```ts
// Create a new tenant
const tenant = await openid.createTenant({
  tenantName: "your-tenant-name",
  tenantLabel: "tenant-label",
  tenantSecret: "secret1243",
  imageUrl: "https://example.com/logo.png",
});

// Get all tenants
const tenants = await openid.getAllTenants();
```

### Connections

Manage secure interactions between tenants and external wallets through connection endpoints.

```ts
// Create a connection invitation
const invitation = await cheqd.createConnectionInvitation({
  tenantId: "your-tenant-id",
  label: "connection-name",
});

// List connections
const connections = await cheqd.getConnections({
  tenantId: "your-tenant-id",
});
```

### Credential Issuance

Create reusable credential templates and issue verifiable credentials from them.

```ts
// Create a SD-JWT credential template
const credTemplate = await openid.createCredentialTemplateSdJwt({
  tenantId: "your-tenant-id",
  name: "Employee ID Card",
  version: "1.0.0",
  description: "Template for issuing employee ID credentials",
  schemaType: "EmployeeSchema",
  attributes: [
    {
      name: "firstName",
      label: "First Name",
      type: "string",
      description: "The employee's given name",
      required: true,
    },
    {
      name: "lastName",
      label: "Last Name",
      type: "string",
      description: "The employee's family name",
      required: true,
    },
  ],
});

// Offer a SD-JWT credential
const offer = await openid.offerCredentialSdJwt({
  tenantId: "your-tenant-id",
  credentialTemplateId: "your-credential-template-id",
  credentialValues: {
    firstName: "Alice",
    lastName: "Johnson",
  },
});
```

### Credential Verification

Use verification templates to request and verify credentials.

```ts

// Create a verification template
const vTemplate = await openid.createVerificationTemplateSdJwt({
  tenantId: "your-tenant-id",
  name: "Employee Verification",
  version: "1.0.0", // 0.0.0 format required
  description: "Template for verifying employee identity",
  requestedAttributes: [
    {
      name: "firstName",
      label: "First Name",
      type: "string",
      description: "The employee's given name",
      required: true,
    },
    {
      name: "lastName",
      label: "Last Name",
      type: "string",
      description: "The employee's family name",
      required: true,
    },
  ],
});


// send verification proof requests
const proofRequest = await openid.sendProofRequest({
  tenantId: "your-tenant-id",
  verificationTemplateId: "your-verification-template-id";
})

```

---

## SDK Documentation

Detailed docs are available at [Documentation](https://docs.hovi.id/).