Israeli Bank Importer - v1.44.5
    Preparing search index...

    Interface IFileSystem

    Filesystem operations a secret-bearing store needs, and nothing more.

    interface IFileSystem {
        openForRead(filePath: string): Procedure<IOpenFile>;
        readAll(file: IOpenFile, maxBytes: number): Procedure<string>;
        restrictToOwner(file: IOpenFile): Procedure<IHardenOutcome>;
        close(file: IOpenFile): ICloseOutcome;
        createExclusive(
            filePath: string,
            contents: string,
        ): Procedure<IWriteOutcome>;
        rename(fromPath: string, toPath: string): Procedure<IMoveOutcome>;
        publishExclusive(
            stagePath: string,
            finalPath: string,
        ): Procedure<IMoveOutcome>;
        listNames(directoryPath: string): Procedure<readonly string[]>;
        remove(filePath: string): Procedure<IRemoveOutcome>;
    }
    Index
    • Opens a path for reading without following a final symlink.

      Must not block when the path is a FIFO or a device: a synchronous blocking open would stall the whole process. Must resolve the descriptor and its `fstat` facts as a single step.

      Parameters

      • filePath: string

        Absolute path to open.

      Returns Procedure<IOpenFile>

      The open file, or a failure carrying the errno in status.

    • Reads an open descriptor as UTF-8, refusing to allocate past a cap.

      The cap belongs here, with the read that does the allocating, rather than with an earlier size observation: a file can grow between being measured and being read.

      Implementations must decode strictly and report `EILSEQ` rather than substituting for malformed bytes. Replacing them can turn a corrupted file into valid JSON holding a quietly altered credential, which the layer above would accept as healthy.

      Parameters

      • file: IOpenFile

        Descriptor previously returned by openForRead.

      • maxBytes: number

        Largest payload to accept before failing with EFBIG.

      Returns Procedure<string>

      The file contents, or a failure carrying the errno in status.

    • Restricts an open file to owner-only access.

      Implementations must refuse when the inode carries more than one name, unless it is already owner-only and owned by this process. Permissions belong to the inode, not the name, so re-permissioning a hard-linked file would silently change a file the caller does not own. A private file needs no change, and IFileSystem.publishExclusive leaves one with two names until it removes the stage — for good if that removal fails.

      Parameters

      • file: IOpenFile

        Descriptor previously returned by openForRead.

      Returns Procedure<IHardenOutcome>

      The mode now in effect, or a failure explaining why it stands.

    • Creates a new file with owner-only permissions, failing if it exists.

      Exclusive creation is what makes this safe for secrets: a plain write follows a symlink planted at the path and sends the payload somewhere else, and it also ignores the requested mode when the path already exists. `EEXIST` means the caller does not own the path and must not delete what is there.

      Parameters

      • filePath: string

        Absolute path to create.

      • contents: string

        Payload to write, treated as opaque.

      Returns Procedure<IWriteOutcome>

      The bytes staged, or a failure carrying the errno in status.

    • Moves a path onto another, replacing the destination atomically.

      Parameters

      • fromPath: string

        Existing path to move.

      • toPath: string

        Destination, replaced if it exists.

      Returns Procedure<IMoveOutcome>

      The destination path, or a failure carrying the errno.

    • Gives a staged file a final name only if that name is free, then removes the stage.

      Unlike IFileSystem.rename, which replaces the destination, this never touches a taken name, so of two writers racing for one name exactly one wins and the other gets `EEXIST`. The final name is a second name for the finished file, so it appears with the whole contents or not at all, and a symlink already at the final name counts as taken rather than being followed. It needs a filesystem with hard links.

      On failure the stage is left for the caller to remove. On success the stage is removed; if that removal fails, the file is still published and the stage is a leftover for the caller's sweep. Until then the file has two names, which IFileSystem.restrictToOwner accepts because both are owner-only and this process's own.

      Parameters

      Returns Procedure<IMoveOutcome>

      The final path, or a failure carrying the errno; EEXIST means the name was taken.

    • Lists the full paths of everything directly inside a directory.

      Full paths rather than bare names, so no caller has to join them and no caller can get the separator wrong on a foreign platform.

      Parameters

      • directoryPath: string

        Directory to list.

      Returns Procedure<readonly string[]>

      The paths, or a failure carrying the errno in status.