Skip to content

@fkn/lib/cloud/fs

  • Error
new StorageLockedError(): StorageLockedError;

StorageLockedError

Error.constructor
code: string = 'FKN_E2E_LOCKED';

There is no object at this path. Test err.code === STORAGE_NOT_FOUND, never the message: absence is worded differently by the presign (“Not found”) and by the object fetch (“storage: read failed (404)”).

“There is nothing here” is safe to overwrite; “I could not tell you” is not, and a caller that confuses them either never writes a first backup or destroys a real one.

  • Error
new StorageNotFoundError(message?): StorageNotFoundError;

string = 'storage: no object at that path'

StorageNotFoundError

Error.constructor
code: string = STORAGE_NOT_FOUND;
type CloudAvailability = "connected" | "disconnected" | "unknown";

type EncryptionStatus = object;
enrolled: boolean;
keyEpoch: number | null;
unlocked: boolean;

type FileEntry = object;
contentType: string | null;
encryption: string | null;
path: string;
size: number;
updatedAt: string;

type StorageQuota = object;
limitBytes: number;
maxObjects: number;
objects: number;
remaining: number;
usedBytes: number;
available: () => Promise<boolean>;

Promise<boolean>


mkdir: (path, a, b?) => void;

PathLike

MakeOptions | Callback<void>

Callback<void>

void


promises: object;
access: (path) => Promise<void>;

PathLike

Promise<void>

lstat: (path) => Promise<Stats> = stat;

PathLike

Promise<Stats>

mkdir: (_path?, _options?) => Promise<void>;

PathLike

MakeOptions

Promise<void>

readdir: (path) => Promise<string[]>;

PathLike

Promise<string[]>

readFile: (path, options?) => Promise<string | Buffer<ArrayBufferLike>>;

PathLike

ReadOptions

Promise<string | Buffer<ArrayBufferLike>>

rename: (from, to) => Promise<void>;

PathLike

PathLike

Promise<void>

rm: (path, options?) => Promise<void>;

PathLike

boolean

Promise<void>

rmdir: (path, options?) => Promise<void> = rm;

PathLike

boolean

Promise<void>

stat: (path) => Promise<Stats>;

PathLike

Promise<Stats>

unlink: (path) => Promise<void>;

PathLike

Promise<void>

writeFile: (path, data, options?) => Promise<void>;

PathLike

WriteData

WriteOptions

Promise<void>


readdir: (path, a, b?) => void;

PathLike

unknown

Callback<string[]>

void


readFile: (path, a, b?) => void;

PathLike

ReadOptions | Callback<string | Buffer<ArrayBufferLike>>

Callback<string | Buffer<ArrayBufferLike>>

void


rename: (from, to, callback) => void;

PathLike

PathLike

Callback<void>

void


rm: (path, a, b?) => void;

PathLike

| Callback<void> | { recursive?: boolean; }

Callback<void>

void


stat: (path, callback) => void;

PathLike

Callback<Stats>

void


unlink: (path, callback) => void;

PathLike

Callback<void>

void


writeFile: (path, data, a, b?) => void;

PathLike

WriteData

WriteOptions | Callback<void>

Callback<void>

void

function availability(): Promise<CloudAvailability>;

Whether the cloud half is backed by an account, as three answers rather than two: ‘disconnected’ is an ANSWER (signed out, or the api refusing the stored token), ‘unknown’ means nobody could be asked, including a broker that never came up. Always settles within the probe deadline. A caller owing data to the cloud may drop that obligation only on ‘disconnected’; treating ‘unknown’ the same silently loses the write.

Promise<CloudAvailability>


function encryption(): Promise<EncryptionStatus>;

Promise<EncryptionStatus>


function isNotFound(error): boolean;

Whether an error from this module means the path is empty, as opposed to unreadable.

unknown

boolean


function list(): Promise<FileEntry[]>;

Every object of this app in the account, with the server’s stamps.

Promise<FileEntry[]>


function quota(): Promise<StorageQuota>;

Promise<StorageQuota>


function readFileSealed(path): Promise<SealedRead>;

Not part of the node-style surface above, since node has no concept of a seal time; readFile is untouched.

string

Promise<SealedRead>


function unlock(): Promise<boolean>;

Promise<boolean>

Re-exports isAccountChanged


Re-exports SealedRead


Re-exports Stats


Re-exports STORAGE_ACCOUNT_CHANGED


Re-exports STORAGE_ACCOUNT_PIN_UNSUPPORTED


Re-exports STORAGE_NOT_FOUND


Re-exports StorageAccountChangedError


Re-exports StorageAccountPinUnsupportedError