Padloc Logo Docs & Resources

Class: Attachment

attachment.Attachment

Hierarchy

Constructors

constructor

• new Attachment(__namedParameters?)

Parameters

Name Type
__namedParameters Partial<AttachmentInfo>

Overrides

SimpleContainer.constructor

Defined in

core/src/attachment.ts:105

Properties

_key

• Protected Optional _key: Uint8Array

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

Inherited from

SimpleContainer._key

Defined in

core/src/container.ts:33


_propertySerializationOptions

• _propertySerializationOptions: SerializationOptions[]

Inherited from

SimpleContainer._propertySerializationOptions

Defined in

core/src/encoding.ts:163


downloadProgress

• Optional downloadProgress: RequestProgress

Defined in

core/src/attachment.ts:103


encryptedData

• Optional encryptedData: Uint8Array

Encrypted data

Inherited from

SimpleContainer.encryptedData

Defined in

core/src/container.ts:28


encryptionParams

• encryptionParams: AESEncryptionParams

Parameters used for encryption of content data

Inherited from

SimpleContainer.encryptionParams

Defined in

core/src/container.ts:24


id

• id: string = ""

Defined in

core/src/attachment.ts:97


name

• name: string = ""

Defined in

core/src/attachment.ts:99


size

• size: number = 0

Defined in

core/src/attachment.ts:100


type

• type: string = ""

Defined in

core/src/attachment.ts:101


uploadProgress

• Optional uploadProgress: RequestProgress

Defined in

core/src/attachment.ts:102


vault

• vault: string = ""

Defined in

core/src/attachment.ts:98

Accessors

info

• get info(): AttachmentInfo

Returns

AttachmentInfo

Defined in

core/src/attachment.ts:113


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

Inherited from

SimpleContainer.kind

Defined in

core/src/encoding.ts:159


loaded

• get loaded(): boolean

Returns

boolean

Defined in

core/src/attachment.ts:124

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

Inherited from

SimpleContainer._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

Inherited from

SimpleContainer._toRaw

Defined in

core/src/encoding.ts:257


clone

▸ clone(): Attachment

Creates a deep clone of the object

Returns

Attachment

Inherited from

SimpleContainer.clone

Defined in

core/src/container.ts:85


fromBytes

▸ fromBytes(bytes): Attachment

Deserializes the object from a byte array

Parameters

Name Type
bytes Uint8Array

Returns

Attachment

Inherited from

SimpleContainer.fromBytes

Defined in

core/src/encoding.ts:237


fromFile

▸ fromFile(file): Promise<Attachment>

Parameters

Name Type
file File

Returns

Promise<Attachment>

Defined in

core/src/attachment.ts:128


fromJSON

▸ fromJSON(json): Attachment

Deserializes the object from a JSON string

Parameters

Name Type
json string

Returns

Attachment

Inherited from

SimpleContainer.fromJSON

Defined in

core/src/encoding.ts:223


fromRaw

▸ fromRaw(raw): Attachment

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

Attachment

Inherited from

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

SimpleContainer.getData

Defined in

core/src/container.ts:61


lock

▸ lock(): 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

void

Inherited from

SimpleContainer.lock

Defined in

core/src/container.ts:81


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

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

Inherited from

SimpleContainer.toBytes

Defined in

core/src/encoding.ts:230


toDataURL

▸ toDataURL(): Promise<string>

Returns

Promise<string>

Defined in

core/src/attachment.ts:149


toFile

▸ toFile(): Promise<File>

Returns

Promise<File>

Defined in

core/src/attachment.ts:144


toJSON

▸ toJSON(): string

Returns a JSON serialization of the object

Returns

string

Inherited from

SimpleContainer.toJSON

Defined in

core/src/encoding.ts:216


toObjectURL

▸ toObjectURL(): Promise<string>

Returns

Promise<string>

Defined in

core/src/attachment.ts:154


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

Inherited from

SimpleContainer.toRaw

Defined in

core/src/encoding.ts:179


toText

▸ toText(): Promise<string>

Returns

Promise<string>

Defined in

core/src/attachment.ts:159


unlock

▸ unlock(key): Promise<void>

Unlocks the container, making it possible to extract the plain text data via getData. The type of secret provided will differ based on the encryption scheme used by implemenations.

Parameters

Name Type
key Uint8Array

Returns

Promise<void>

Inherited from

SimpleContainer.unlock

Defined in

core/src/container.ts:97


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

Overrides

SimpleContainer.validate

Defined in

core/src/attachment.ts:164