@civic/identity-store-client
v0.1.2
Published
Civic Profile Library
Downloads
215
Maintainers
Keywords
Readme
Identity Store library
A library for accessing and managing a user's identity data.
Overview
This library provides two main functionalities:
- Reading identity data (
Store<T>
as an implementation ofIdentityStore<T>
). - Writing or updating identity data (
Store<T>
as an implementation ofUserIdentityStore<T>
).
Installation
npm install @civic/identity-store-client
Usage
Reading Identity Data
To read identity data, use the Store<T>
class implementing IdentityStore<T>
. Here's an example:
import { Store } from "@civic/identity-store-client";
// Initialize the store for reading data
const options = { endpoint: "http://example.com" };
const identityStore = new Store(options);
// Example of getting identity data
const data = await identityStore.get("did:sol:yourDID");
Writing Identity Data
To write or update identity data, use the Store<T>
class implementing UserIdentityStore<T>
. Here's an example:
import { Store } from "@civic/identity-store-client";
// Initialize the store for writing data
const options = { endpoint: "http://example.com" };
const auth = { token: "yourAuthToken" };
const did = "did:sol:yourDID";
const writeStore = new Store(options, auth, did);
// Example of creating new identity data
const newData = await writeStore.create();
Options
You can specify a different Identity Store endpoint by passing an options object:
const options = {
endpoint: "http://example.com",
};
Examples
The following examples demonstrate various queries to the Identity Store:
// Initialize the store
const store = new Store({ endpoint: "http://example.com" });
// Query using different identifiers
await store.get("did:sol:yourDID");
await store.get("yourSOLaddress");
await store.get("yourSNSaddress");
await store.get("0xyourEthereumAddress");
await store.get("yourENSaddress");
Obtaining the Civic Score for a DID
const store = new Store({ endpoint: "http://example.com" });
const civicScore = await store.getScore("yourDID");