# SecureVault | opentoken
Documentation for opentoken

Class representing a SecureVault.

### Hierarchy

- SecureVault

## Index

### Constructors

- constructor

### Properties

- privPath
- pubPath
- safe
- storage

### Methods

- clearVault
- decryptData
- findStorage
- getAllStorage
- getStorage
- loadData
- pushData
- pushStorage
- saveData
- setStorage
- writeTransaction
- genKey

## Constructors

### constructor

- new SecureVault(publicKey?: undefined | string, privateKey?: undefined | string): SecureVault

- - Defined in src/vault.ts:76

  Create a SecureVault.

  #### Parameters

  - ##### Optional publicKey: undefined | string

    Path to public key.

  - ##### Optional privateKey: undefined | string

    Path to private key.

  #### Returns SecureVault

## Properties

### Optional privPath

privPath: undefined | string

- Defined in src/vault.ts:72

Path to private key

### Optional pubPath

pubPath: undefined | string

- Defined in src/vault.ts:74

Path to public key

### safe

safe: secureVaultList

- Defined in src/vault.ts:70

Safe object

### storage

storage: StorageItem []

- Defined in src/vault.ts:76

Array of unencrypted items

## Methods

### clearVault

- clearVault(): void

- - Defined in src/vault.ts:303

  Clears all encrypted items from safe.

  #### Returns void

### decryptData

- decryptData(): Promise< SecureVaultItem []>

- - Defined in src/vault.ts:175

  Decrypts safe data. Requires specified and loaded private key. Prints data to console.

  #### Returns Promise< SecureVaultItem []>

  Resolves promise after decrypted

### findStorage

- findStorage(tag: string): StorageItem []

- - Defined in src/vault.ts:292

  Gets list of UUIDs matching the tag.

  #### Parameters

  - ##### tag: string

    tag to search for

  #### Returns StorageItem []

  UUID from item.

### getAllStorage

- getAllStorage(): StorageItem []

- - Defined in src/vault.ts:270

  Gets all unencrypted data as array.

  #### Returns StorageItem []

  Data from item.

### getStorage

- getStorage(suuid: string): any

- - Defined in src/vault.ts:256

  Gets unencrypted data of item specified by suuid.

  #### Parameters

  - ##### suuid: string

    UUID for item

  #### Returns any

  Data from item.

### loadData

- loadData(path: string): Promise<void>

- - Defined in src/vault.ts:153

  Loads safe from file and check compatibility

  #### Parameters

  - ##### path: string

    Path to safefile.

  #### Returns Promise<void>

  Resolves promise after loaded

### pushData

- pushData(data: any): Promise<string>

- - Defined in src/vault.ts:100

  Encrypts and appends data to SecureVault. Also writes data to transaction log using @function writeTransaction

  #### Parameters

  - ##### data: any

    Path to public key.

  #### Returns Promise<string>

  Returns the uuid of the added object as promise

### pushStorage

- pushStorage(tag: string, data: any): void

- - Defined in src/vault.ts:222

  Appends unencrypted data to safe.

  #### Parameters

  - ##### tag: string

    Tag for item

  - ##### data: any

    Data to store.

  #### Returns void

### saveData

- saveData(path: string): Promise<void>

- - Defined in src/vault.ts:140

  Saves safe to file

  #### Parameters

  - ##### path: string

    Path to safefile.

  #### Returns Promise<void>

  Resolves promise after loaded

### setStorage

- setStorage(suuid: string, data: any): void

- - Defined in src/vault.ts:241

  Sets unencrypted data for item specified by suuid.

  #### Parameters

  - ##### suuid: string

    UUID for item

  - ##### data: any

    Data to store.

  #### Returns void

### writeTransaction

- writeTransaction(payload: string): void

- - Defined in src/vault.ts:131

  Writes data to the vault log file located at ./vault.log

  #### Parameters

  - ##### payload: string

    Text to append

  #### Returns void

### Static genKey

- genKey(publicKeyDir: string, privateKeyDir: string): void

- - Defined in src/vault.ts:200

  Generates RSA keypair.

  #### Parameters

  - ##### publicKeyDir: string

  - ##### privateKeyDir: string

  #### Returns void

Generated using TypeDoc