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 arrives from two places that word it completely differently: the api refusing to presign a path with no committed row says “Not found”, and a presign that succeeded followed by an object fetch that 404s says “storage: read failed (404)”. Neither is a fault, both mean the same thing, and matching either by hand means matching both. Ripple matched only the first, so a missing backup read as a transient failure, retried forever, and a library went un-backed-up for a day without a single error anywhere.

The distinction matters more than it sounds. “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 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 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 quota(): Promise<StorageQuota>;

Promise<StorageQuota>


function readFileSealed(path): Promise<SealedRead>;

A cloud read that also reports when the copy was sealed.

sealedAt is an ISO string, or null when the envelope carries no such field (one written before the seal time existed) or when the data plane is older than this call. The value is AUTHENTICATED, so the server can neither forge nor alter it, and it is the WRITER’s own claim about when it sealed, so on its own it does not prove this copy is the newest one: an older but perfectly authentic copy of the same path is still authentic. An app that needs that answer keeps a high-water mark per path and compares. Do not confuse it with the updatedAt on a listing, which is the server’s hint and is fine for display and nothing else.

The bytes and the stamp come from ONE read of ONE envelope, which is what makes the stamp describe the bytes returned beside it. readFile is unchanged and unaffected.

string

Promise<SealedRead>


function unlock(): Promise<boolean>;

Promise<boolean>

Re-exports SealedRead


Re-exports Stats


Re-exports STORAGE_NOT_FOUND