Padloc Logo Docs & Resources

Class: Vault

vault.Vault

Container for securely storing a collection of VaultItems. Vaults can be owned by a single user ("private" vaults) or shared between multiple users ("shared" vaults). Shared vaults are provisioned and managed through Orgs.

Hierarchy

Implements

Constructors

constructor

new Vault()

Inherited from

SharedContainer.constructor

Properties

_key

Protected Optional _key: Uint8Array

The key used for encryption. Sub classes must set this property in the unlock method.

Inherited from

SharedContainer._key

Defined in

core/src/container.ts:33


_propertySerializationOptions

_propertySerializationOptions: SerializationOptions[]

Implementation of

Storable._propertySerializationOptions

Inherited from

SharedContainer._propertySerializationOptions

Defined in

core/src/encoding.ts:163


accessors

accessors: Accessor[] = []

The ids and encrypted keys of all accessors

Inherited from

SharedContainer.accessors

Defined in

core/src/container.ts:159


created

created: Date

Time of creation

Defined in

core/src/vault.ts:32


encryptedData

Optional encryptedData: Uint8Array

Encrypted data

Inherited from

SharedContainer.encryptedData

Defined in

core/src/container.ts:28


encryptionParams

encryptionParams: AESEncryptionParams

Parameters used for encryption of content data

Inherited from

SharedContainer.encryptionParams

Defined in

core/src/container.ts:24


error

Optional error: Err

Defined in

core/src/vault.ts:56


id

id: string = ""

unique identifier

Implementation of

Storable.id

Defined in

core/src/vault.ts:19


items

items: VaultItemCollection

A collection VaultItems representing the senstive data store in this vault

secret

IMPORTANT: This property is considered secret and should never stored or transmitted in plain text

Defined in

core/src/vault.ts:53


keyParams

keyParams: RSAEncryptionParams

Parameters used to wrap the shared encryption key

Inherited from

SharedContainer.keyParams

Defined in

core/src/container.ts:155


name

name: string = ""

Vault name

Defined in

core/src/vault.ts:25


org

Optional org: OrgInfo = undefined

The Org this vault belongs to (if a shared vault)

Defined in

core/src/vault.ts:22


owner

owner: string = ""

The vault owner (the Account that created this vault)

Defined in

core/src/vault.ts:28


revision

revision: string = ""

Revision id used for ensuring continuity when synchronizing the vault object between client and server

Defined in

core/src/vault.ts:42


updated

updated: Date

Time of last update

Defined in

core/src/vault.ts:36

Accessors

kind

get kind(): string

A string representing the objects "type", useful for segmenting storage, among other things. Defaults to the lowercase class name, but can be overwritten by subclasses

Returns

string

Implementation of

Storable.kind

Inherited from

SharedContainer.kind

Defined in

core/src/encoding.ts:159


label

get label(): string

Convenience getter for getting a display label truncated to a certain maximum length

Returns

string

Defined in

core/src/vault.ts:61

Methods

_fromRaw

Protected _fromRaw(raw): void

Restore values from a raw object. The default implementation simply copies over all iterable properties from the base object. Overwrite this method for properties that require special treatment

Parameters

Name Type
raw any

Returns

void

Implementation of

Storable._fromRaw

Inherited from

SharedContainer._fromRaw

Defined in

core/src/encoding.ts:286


_toRaw

Protected _toRaw(version): any

Transform this object into a raw javascript object used for serialization. The default implementation simply copies all iterable properties not included in the [[exlude]] array and calls toRaw on any properties that are themselfes instances of Serializable. This method should be overwritten by subclasses if certain properties require special treatment.

Parameters

Name Type
version undefined | string

Returns

any

Implementation of

Storable._toRaw

Inherited from

SharedContainer._toRaw

Defined in

core/src/encoding.ts:257


clone

clone(): Vault

Creates a deep clone of the object

Returns

Vault

Implementation of

Storable.clone

Overrides

SharedContainer.clone

Defined in

core/src/vault.ts:110


commit

commit(): Promise<void>

Commit changes to items by reencrypting the data.

Returns

Promise<void>

Defined in

core/src/vault.ts:88


fromBytes

fromBytes(bytes): Vault

Deserializes the object from a byte array

Parameters

Name Type
bytes Uint8Array

Returns

Vault

Implementation of

Storable.fromBytes

Inherited from

SharedContainer.fromBytes

Defined in

core/src/encoding.ts:237


fromJSON

fromJSON(json): Vault

Deserializes the object from a JSON string

Parameters

Name Type
json string

Returns

Vault

Implementation of

Storable.fromJSON

Inherited from

SharedContainer.fromJSON

Defined in

core/src/encoding.ts:223


fromRaw

fromRaw(raw): Vault

Restores propertiers from a raw object of the same form generated by toRaw. The base implementation blindly copies over values from the raw object via Object.assign so subclasses should explictly process any propertyies that need special treatment.

Also takes are of validation and "upgrading" in case the raw object has an old version. Use the protected _fromRaw method to implement subclass-specific behavior.

Parameters

Name Type
raw any

Returns

Vault

Implementation of

Storable.fromRaw

Inherited from

SharedContainer.fromRaw

Defined in

core/src/encoding.ts:196


getData

getData(): Promise<Uint8Array>

Decrypts and extracts the plain text data from the container. This will usually require unlocking the container first.

Returns

Promise<Uint8Array>

Inherited from

SharedContainer.getData

Defined in

core/src/container.ts:61


lock

lock(): Promise<void>

Locks the container, removing the possibility to extract the plain text data via getData until the container is unlocked again. Subclasses extending this class must take care to delete any keys or other sensitive data that may have been stored temporarily after unlocking the container.

Returns

Promise<void>

Overrides

SharedContainer.lock

Defined in

core/src/vault.ts:80


merge

merge(vault): void

Merges in changes from another vault. This requires both vaults to be unlocked.

Parameters

Name Type
vault Vault

Returns

void

Defined in

core/src/vault.ts:95


setData

setData(data): Promise<void>

Encrypts the provided data and stores it in the container

Parameters

Name Type
data Uint8Array

Returns

Promise<void>

Inherited from

SharedContainer.setData

Defined in

core/src/container.ts:38


toBytes

toBytes(): Uint8Array

Returns a serialization of the object in form of a byte array

Returns

Uint8Array

Implementation of

Storable.toBytes

Inherited from

SharedContainer.toBytes

Defined in

core/src/encoding.ts:230


toJSON

toJSON(): string

Returns a JSON serialization of the object

Returns

string

Implementation of

Storable.toJSON

Inherited from

SharedContainer.toJSON

Defined in

core/src/encoding.ts:216


toRaw

toRaw(version?): any

Creates a raw javascript object representation of the class, which can be used for storage or data transmission. Also handles "downgrading" to previous versions. Use _toRaw for subclass-specific behavior.

Parameters

Name Type
version? string

Returns

any

Implementation of

Storable.toRaw

Inherited from

SharedContainer.toRaw

Defined in

core/src/encoding.ts:179


toString

toString(): string

Returns

string

Defined in

core/src/vault.ts:106


unlock

unlock(account): Promise<void>

Unlocks the vault with the given account, decrypting the data stored in the vault and populating the items property. For this to be successful, the account object needs to be unlocked and the account must have access to this vault.

Parameters

Name Type
account UnlockedAccount

Returns

Promise<void>

Overrides

SharedContainer.unlock

Defined in

core/src/vault.ts:70


updateAccessors

updateAccessors(subjects): Promise<void>

Updates the containers accessors, generating a new shared key and encrypting it with the public keys of the provided subjects. Non-empty containers need to be unlocked first.

Parameters

Name Type
subjects { id: string ; publicKey: Uint8Array }[]

Returns

Promise<void>

Inherited from

SharedContainer.updateAccessors

Defined in

core/src/container.ts:189


validate

validate(): boolean

This is called during deserialization and should verify that all properties have been populated with values of the correct type. Subclasses should implement this method based on their class structure.

Returns

boolean

Implementation of

Storable.validate

Inherited from

SharedContainer.validate

Defined in

core/src/encoding.ts:170