Padloc Logo Docs & Resources

Class: Account

account.Account

The Account object represents an individual Padloc user and holds general account information as well as cryptographic keys necessary for accessing [[Vaults]] and signing/verifying Organization details.

The privateKey and signingKey properties are considered secret and therefore need to be encrypted at rest. For this, the Account object serves as a PBES2Container which is unlocked by the users master password.

Hierarchy

Implements

Constructors

constructor

new Account()

Inherited from

PBES2Container.constructor

Properties

_key

Protected Optional _key: Uint8Array

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

Inherited from

PBES2Container._key

Defined in

core/src/container.ts:33


_propertySerializationOptions

_propertySerializationOptions: SerializationOptions[]

Implementation of

Storable._propertySerializationOptions

Inherited from

PBES2Container._propertySerializationOptions

Defined in

core/src/encoding.ts:163


created

created: Date

When the account was created

Defined in

core/src/account.ts:55


email

email: string = ""

The users email address

Defined in

core/src/account.ts:48


encryptedData

Optional encryptedData: Uint8Array

Encrypted data

Inherited from

PBES2Container.encryptedData

Defined in

core/src/container.ts:28


encryptionParams

encryptionParams: AESEncryptionParams

Parameters used for encryption of content data

Inherited from

PBES2Container.encryptionParams

Defined in

core/src/container.ts:24


favorites

favorites: Set<string>

Defined in

core/src/account.ts:103


id

id: string = ""

Unique account ID

Implementation of

Storable.id

Defined in

core/src/account.ts:45


keyParams

keyParams: PBKDF2Params

Parameters used for key derivation

Inherited from

PBES2Container.keyParams

Defined in

core/src/container.ts:110


mainVault

mainVault: Object

ID of the accounts main or "private" Vault.

Type declaration

Name Type
id string
name? string
revision? string

Defined in

core/src/account.ts:87


name

name: string = ""

The users display name

Defined in

core/src/account.ts:51


orgs

orgs: OrgInfo[] = []

All organizations this account is a member of

Defined in

core/src/account.ts:94


privateKey

Optional privateKey: Uint8Array

The accounts private key

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

Defined in

core/src/account.ts:73


publicKey

publicKey: Uint8Array

The accounts public key

Defined in

core/src/account.ts:63


revision

revision: string = ""

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

Defined in

core/src/account.ts:100


signingKey

Optional signingKey: Uint8Array

HMAC key used for signing and verifying organization details

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

secret

Defined in

core/src/account.ts:84


updated

updated: Date

when the account was last updated

Defined in

core/src/account.ts:59

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

PBES2Container.kind

Defined in

core/src/encoding.ts:159


locked

get locked(): boolean

Whether or not this Account object is current "locked" or, in other words, whether the privateKey and signingKey properties have been decrypted.

Returns

boolean

Defined in

core/src/account.ts:109


masterKey

get masterKey(): undefined | Uint8Array

Returns

undefined | Uint8Array

Defined in

core/src/account.ts:113

set masterKey(key): void

Parameters

Name Type
key undefined | Uint8Array

Returns

void

Defined in

core/src/account.ts:117

Methods

_commitSecrets

Private _commitSecrets(): Promise<void>

Returns

Promise<void>

Defined in

core/src/account.ts:253


_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

PBES2Container._fromRaw

Defined in

core/src/encoding.ts:286


_loadSecrets

Private _loadSecrets(): Promise<void>

Returns

Promise<void>

Defined in

core/src/account.ts:245


_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

PBES2Container._toRaw

Defined in

core/src/encoding.ts:257


clone

clone(): Account

Creates a deep clone of the object

Returns

Account

Implementation of

Storable.clone

Overrides

PBES2Container.clone

Defined in

core/src/account.ts:168


copySecrets

copySecrets(account): void

Parameters

Name Type
account Account

Returns

void

Defined in

core/src/account.ts:226


fromBytes

fromBytes(bytes): Account

Deserializes the object from a byte array

Parameters

Name Type
bytes Uint8Array

Returns

Account

Implementation of

Storable.fromBytes

Inherited from

PBES2Container.fromBytes

Defined in

core/src/encoding.ts:237


fromJSON

fromJSON(json): Account

Deserializes the object from a JSON string

Parameters

Name Type
json string

Returns

Account

Implementation of

Storable.fromJSON

Inherited from

PBES2Container.fromJSON

Defined in

core/src/encoding.ts:223


fromRaw

fromRaw(raw): Account

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

Account

Implementation of

Storable.fromRaw

Inherited from

PBES2Container.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

PBES2Container.getData

Defined in

core/src/container.ts:61


initialize

initialize(password): Promise<void>

Generates the accounts privateKey, publicKey and signingKey and encrypts privateKey and [[singingKey]] using the master password.

Parameters

Name Type
password string

Returns

Promise<void>

Defined in

core/src/account.ts:125


lock

lock(): void

"Locks" the account by deleting all sensitive data from the object

Returns

void

Overrides

PBES2Container.lock

Defined in

core/src/account.ts:161


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

PBES2Container.setData

Defined in

core/src/container.ts:38


setPassword

setPassword(password): Promise<void>

Updates the master password by reencrypting the privateKey and signingKey properties

Parameters

Name Type
password string

Returns

Promise<void>

Defined in

core/src/account.ts:134


signOrg

signOrg(__namedParameters): Promise<Uint8Array>

Creates a signature that can be used later to verify an organizations id and public key

Parameters

Name Type
__namedParameters Object
__namedParameters.id string
__namedParameters.publicKey Uint8Array

Returns

Promise<Uint8Array>

Defined in

core/src/account.ts:181


toBytes

toBytes(): Uint8Array

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

Returns

Uint8Array

Implementation of

Storable.toBytes

Inherited from

PBES2Container.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

PBES2Container.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

PBES2Container.toRaw

Defined in

core/src/encoding.ts:179


toString

toString(): string

Returns

string

Defined in

core/src/account.ts:174


toggleFavorite

toggleFavorite(id, favorite): Promise<void>

Parameters

Name Type
id string
favorite boolean

Returns

Promise<void>

Defined in

core/src/account.ts:221


unlock

unlock(password): Promise<void>

"Unlocks" the account by decrypting and extracting privateKey and signingKey from encryptedData

Parameters

Name Type
password string

Returns

Promise<void>

Overrides

PBES2Container.unlock

Defined in

core/src/account.ts:144


unlockWithMasterKey

unlockWithMasterKey(key): Promise<void>

Unlocks the account by providing the encryption key directly rather than deriving it fro the master password

Parameters

Name Type
key Uint8Array

Returns

Promise<void>

Defined in

core/src/account.ts:153


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

Overrides

PBES2Container.validate

Defined in

core/src/account.ts:233


verifyOrg

verifyOrg(org): Promise<void>

Verifies an organizations id an public key, using the signature stored in the Member object associated with the account.

Parameters

Name Type
org Org

Returns

Promise<void>

Defined in

core/src/account.ts:192