This package has been deprecated

Author message:

Moved to organization https://www.npmjs.com/org/spartan-hc

@whi/mere-memory-sdk

0.1.3 • Public • Published

Mere Memory SDK

A Javascript SDK for the Mere Memory Zome (Holochain).

Overview

Install

npm i @whi/mere-memory-sdk

Usage

Import

import { MereMemoryClient } from '@whi/mere-memory-sdk';

Simplest

const client = new MereMemoryClient( app_port, cell_agent_hash, "storage", dna_hash );

client.setSigningHandler( async zome_call_request => {
    zome_call_request.signature = someSigningFunction( zome_call_request );
    return zome_call_request;
});

const memory_addr = await client.save( bytes );
const memory = await client.remember( memory_addr );

expect( memory ).to.deep.equal( bytes );

Use Existing WebSocket

import nacl from 'tweetnacl';

const socket = new WebSocket(`ws://127.0.0.1:${app_port}`);
socket.binaryType = "arraybuffer";

// Assuming CapGrant was already created with these credentials
const CAP_SECRET = "super_secret_password";
const key_pair = nacl.sign.keyPair();

const client = new MereMemoryClient( socket, cell_agent_hash, "storage", dna_hash );

client.setCapabilityAgent(
    cap_agent,
    async zome_call_request => {
        const zome_call_hash = await hashZomeCall( zome_call_request );

        zome_call_request.signature= nacl.sign( zome_call_hash, key_pair.secretKey )
            .subarray( 0, nacl.sign.signatureLength );

        return zome_call_request;
    },
    CAP_SECRET,
);

const memory_addr = await client.save( bytes );
const memory = await client.remember( memory_addr );

expect( memory ).to.deep.equal( bytes );

API Reference

See docs/API.md

Contributing

See CONTRIBUTING.md

Readme

Keywords

none

Package Sidebar

Install

npm i @whi/mere-memory-sdk

Weekly Downloads

0

Version

0.1.3

License

ISC

Unpacked Size

787 kB

Total Files

10

Last publish

Collaborators

  • brisebom