npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@trust0/identus-store

v0.0.1

Published

Identus SDK Pluto.Store build with RIDB

Downloads

20

Readme

Trust0 is contributing to the Hyperledger Identus community open source code by creating RIDB. RIDB is a rust based, light weight wasm package for nodejs and browsers to build databases for the web.

Hyperledger Identus

We extract the schemas, database structure and migrations paths of existing SDK in order to make sure everyone can transition from pluto-encrypted to this project with minimal changes.

How to install the package

npm i @trust0/identus-store --save

or with yarn:

yarn add @trust0/identus-store

Using in the typescript SDK

In order to use RIDBStore inside the Hyperledger Identus TS SDK you just need to initialise the Store before passing it to the Pluto constructor.

import SDK from '@hyperledger/identus-edge-agent-sdk';
import {RIDBStore} from '@trust0/identus-store'
const apollo = new SDK.Apollo();
const store = new RIDBStore({
    dbName: YOUR_DATABASE_NAME
})
const defaultSeed = apollo.createRandomSeed().seed // 
const castor = new SDK.Castor(apollo)
const agent = await SDK.Agent.initialize({
    apollo,
    castor,
    mediatorDID,
    pluto: new SDK.Pluto(store, apollo),
    seed: defaultSeed
});

Documentation

Here's the main compliant SDK.Pluto.Store interface implementation

import { BaseStorage, QueryType, SchemaType, StorageType } from '@trust0/ridb';
import SDK from '@hyperledger/identus-edge-agent-sdk';
export declare class RIDBStore implements SDK.Pluto.Store {
    private options;
    private _db;
    private extractCollections;
    constructor(options: {
        dbName: string;
        storageType?: typeof BaseStorage  | StorageType;
        password?: string;
    });
    private parseName;
    query(table: string, query?: QueryType<any>): Promise<any[]>;
    insert<T extends SDK.Domain.Pluto.Storable>(table: string, model: T): Promise<void>;
    update<T extends SDK.Domain.Pluto.Storable>(table: string, model: T): Promise<void>;
    delete(table: string, uuid: string): Promise<void>;
    get collections(): {
        [x: string]: import("@trust0/ridb").Collection<import("@trust0/ridb").Schema<SchemaType>>;
    };
    start(): Promise<void>;
    cleanup(): Promise<void>;
    clear(): Promise<void>;
}

How to use a different store?

There's currently 2 available storages, inMemory and indexDB

InMemory

Works in any environment (browser and node) and support all available plugins, Migration and Encryption.

Using InMemory:

import {RIDBStore} from '@trust0/identus-store'
const apollo = new SDK.Apollo();
const store = new RIDBStore({
    dbName: YOUR_DATABASE_NAME,
    storageType: StorageType.InMemory
})

IndexDB

Works only in Browser environments as our lightweight implementation is using the browser API's directly and also supports all available plugins, Migration and Encryption.

Using IndexDB:

import {RIDBStore} from '@trust0/identus-store'
const apollo = new SDK.Apollo();
const store = new RIDBStore({
    dbName: YOUR_DATABASE_NAME,
    storageType: StorageType.IndexDB
})

How do I plug my own storage?

In order to create your own storage, compatible with Identus and RIDB you must follow this interface and implement the code choosing the storage of your choice.

Using your own storage:

import {RIDBStore} from '@trust0/identus-store'
export class MyOwnStorage<T extends SchemaTypeRecord>  extends BaseStorage<T> {

    static create<SchemasCreate extends SchemaTypeRecord>(
        name: string,
        schemas: SchemasCreate,
        options: any
    ): Promise<
        BaseStorage<
            SchemasCreate
        >
    > {
        throw new Error("Method not implemented.");
    }

    constructor(name: string, schemas: T, options: any) {
        super(name, schemas, options);
    }

    findDocumentById(collectionName: keyof T, id: string): Promise<Doc<T[keyof T]> | null> {
        throw new Error("Method not implemented.");
    }
    find(collectionName: keyof T, query: QueryType<T[keyof T]>): Promise<Doc<T[keyof T]>[]> {
        throw new Error("Method not implemented.");
    }
    write(op: Operation<T[keyof T]>): Promise<Doc<T[keyof T]>> {
        throw new Error("Method not implemented.");
    }
    count(collectionName: keyof T, query: QueryType<T[keyof T]>): Promise<number> {
        throw new Error("Method not implemented.");
    }
    start(): Promise<void> {
        throw new Error("Method not implemented.");
    }
    close(): Promise<void> {
        throw new Error("Method not implemented.");
    }
}
const apollo = new SDK.Apollo();
const store = new RIDBStore({
    dbName: YOUR_DATABASE_NAME,
    storageType: MyOwnStorage
})