@strongvault/sdk
SDK for Node.js
Last updated 2 months ago by sskathy .
SEE LICENSE IN License.txt · Original npm · Tarball · package.json
$ cnpm install @strongvault/sdk 
SYNC missed versions from official npm registry.

StrongVault SDK

This SDK was created to utilize the StrongVault network to store and search documents.

Limitations: The current implementation is designed to work in a Node.js environment and will not work in the browser.

File Search

Current supported file formats that can be added to the search index are: png, jpg, pdf, txt, json, xlsx and docx.

Docs

Install

npm install @strongvault/sdk

Generating a mnemonic phrase

A mnemonic phrase needs to be generated and saved in order to access encrypted data. If the phrase is lost, the data cannot be recovered. This phrase can be generated by using the SDK or anything that follows the bip39 spec

  const { generateMnemonicPhrase } = require('@strongvault/sdk');
  console.log('mnemonic: ', generateMnemonicPhrase());

Initialize

Initialization will ensure the account is created for the mnemonic given. If one doesn't exist, it will be created.

const sv = require('@strongvault/sdk');

await sv.initialize({
    mnemonic: 'your mnemonic phrase',
    stellarHorizonUrl: 'https://horizon1.staging.electra.strongvault.app',
    stellarUrl: 'https://node1.staging.electra.strongvault.app',
    stellarNetworkPassphrase: 'Strongvault Staging Network Electra May 2019',
    
    // Search Options (optional)
    searchFilePath: 'directory where the search related files will be written to',
    searchIndexFilename: 'unique filename where the search index will be written to',
    searchKeyFilename: 'unique filename where the search key will be written to',
    customIndexFields: [ 'custom_index_field', 'custom_index_field' ],
    dynamicAddIndexFields: boolean, // Add json keys dynamically as indexed fields to the search index when parsing the json document
});

Default Search Option Values

  • searchFilePath: use current directory if blank
  • searchIndexFilename: use 'search_index_<account_id>' if blank
  • searchKeyFilename: use '.search_keys_<account_id>' if blank
  • customIndexFields: empty array
  • dynamicAddIndexFields: false

Sync

The SDK is stateful, works offline and will need to be synced after actions that affect files. The sync sends the proper changes to the network records the transactions on the blockchain. await sv.sync()

Import a File

 await sv.importFile(filename, filePath)

When a document is uploaded, it is automatically added to the search index.

List Current Files

sv.listDocs
//[{id: 'dsfoid8sfnfkdsj389d8dn', name: 'my_document', ...}, ...]

Retrieve a File

 await sv.retrieveDocument(document, destinationPath);

Delete files

 await sv.deleteDocuments(docs);

Search

There are 4 predefined fields that are used in the search index. When documents such as PDF, Word and Excel files are uploaded, the text is extracted from the file and added to the index under the field 'ssText'.

  • ssUuid: an unique identifier
  • ssFileUuid: the uuid created when a file is uploaded
  • ssFileName: the file name
  • ssText: text extracted from documents
Initialize
  sv.searchApi.init(keys, options);
General Search
  const params = {query: '<word to query>'};
  sv.runSearch(params);
Field Search
  const params = {query: '<word to query>', field: '<indexed field>'};
  sv.runFieldSearch(params);
Add Documents
  await sv.searchApi.addDocs(docs);
Get Document
  await sv.searchApi.getDoc(docId);
Delete Documents
  await sv.searchApi.removeDocs(docIds);
Update Documents
  await sv.searchApi.updateDocs(docs);

Current Tags

  • 2.0.12                                ...           latest (2 months ago)

46 Versions

  • 2.0.12                                ...           2 months ago
  • 2.0.11                                ...           3 months ago
  • 2.0.10                                ...           3 months ago
  • 2.0.9                                ...           3 months ago
  • 2.0.8                                ...           3 months ago
  • 2.0.7                                ...           4 months ago
  • 2.0.6                                ...           4 months ago
  • 2.0.5                                ...           4 months ago
  • 2.0.4                                ...           4 months ago
  • 2.0.3                                ...           4 months ago
  • 2.0.2                                ...           4 months ago
  • 2.0.1                                ...           4 months ago
  • 1.0.33                                ...           5 months ago
  • 1.0.32                                ...           5 months ago
  • 1.0.31                                ...           5 months ago
  • 1.0.30                                ...           5 months ago
  • 1.0.29                                ...           5 months ago
  • 1.0.28                                ...           5 months ago
  • 1.0.27                                ...           5 months ago
  • 1.0.26                                ...           5 months ago
  • 1.0.25                                ...           5 months ago
  • 1.0.24                                ...           5 months ago
  • 1.0.23                                ...           5 months ago
  • 1.0.22                                ...           5 months ago
  • 1.0.21                                ...           5 months ago
  • 1.0.20                                ...           5 months ago
  • 1.0.19                                ...           5 months ago
  • 1.0.18                                ...           5 months ago
  • 1.0.17                                ...           5 months ago
  • 1.0.16                                ...           5 months ago
  • 1.0.15                                ...           5 months ago
  • 1.0.14                                ...           5 months ago
  • 1.0.13                                ...           5 months ago
  • 1.0.12                                ...           5 months ago
  • 1.0.11                                ...           6 months ago
  • 1.0.10                                ...           6 months ago
  • 1.0.9                                ...           6 months ago
  • 1.0.8                                ...           6 months ago
  • 1.0.7                                ...           6 months ago
  • 1.0.6                                ...           6 months ago
  • 1.0.5                                ...           6 months ago
  • 1.0.4                                ...           6 months ago
  • 1.0.3                                ...           6 months ago
  • 1.0.2                                ...           6 months ago
  • 1.0.1                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (14)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |