@catalist-nestjs/offchain-key-storage-client
v1.0.0
Published
Library provide interface for storing Node operator's key in IPFS and preparing merkle tree and proofs. Part of [Catalist NestJS Modules](https://github.com/blockarchivelabs/catalist-nestjs-modules/#readme).
Downloads
10
Maintainers
Readme
Library for storing keys in IPFS and creating merkle tree
Library provide interface for storing Node operator's key in IPFS and preparing merkle tree and proofs. Part of Catalist NestJS Modules.
Install
yarn add @catalist-nestjs/offchain-key-storage-client
Ipfs
Usage
This module depends on IpfsModule
from @catalist-nestjs/ipfs-http-client
, so you need to provide it as a global module or import it into IpfsNopKeysModule
.
IpfsModule
// global IpfsModule usage
@Module({
imports: [
ConfigModule,
// FetchModule.forRoot(),
IpfsModule.forRootAsync({
imports: [CustomFetchModule],
async useFactory(config: ConfigService) {
return {
url: config.get('URL'),
username: config.get('USERNAME'),
password: config.get('PASSWORD'),
};
},
inject: [ConfigService],
}),
IpfsNopKeysModule.forRoot(),
],
})
export class MyModule {}
// IpfsModule as deps of IpfsNopKeysModule
@Module({
imports: [
ConfigModule,
// FetchModule.forRoot(),
IpfsNopKeysModule.forRoot({
imports: [
IpfsModule.forRootAsync({
imports: [CustomFetchModule],
async useFactory(config: ConfigService) {
return {
url: config.get('URL'),
username: config.get('USERNAME'),
password: config.get('PASSWORD'),
};
},
inject: [ConfigService],
}),
],
}),
],
})
export class MyModule {}
NopMerkleTree
// Import
import { Module } from '@nestjs/common';
import { NopMerkleTreeModule } from '@catalist-nestjs/offchain-key-storage-client';
import { MyService } from './my.service';
@Module({
imports: [NopMerkleTreeModule],
providers: [MyService],
exports: [MyService],
})
export class MyModule {}
// Usage
import {
NopMerkleTreeService,
KeySignBuffer,
} from '@catalist-nestjs/offchain-key-storage-client';
export class MyService {
constructor(private nopMerkleTreeService: NopMerkleTreeService) {}
myMethod(data: KeySignBuffer[]) {
return this.nopMerkleTreeService.createTree(data);
}
}
Example of usage this library https://github.com/blockarchivelabs/catalist-offchain-key-lib-test.git