2.0.12 • Published 5 years ago

@strongvault/sdk v2.0.12

Weekly downloads
-
License
SEE LICENSE IN Li...
Repository
-
Last release
5 years ago

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 'searchindex<account_id>' if blank
  • searchKeyFilename: use '.searchkeys<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);
2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago