Practic Passkey - v1.0.0
    Preparing search index...

    Interface StorageEngine

    Records kept by collection and key, as every storage engine keeps them, whether a JSON file or a database. The operations are the ones a store makes atomic natively, so the server builds its guarantees on them: create refuses a key that exists (a passkey is registered once), update with a condition refuses a record that changed (a signature counter cannot be replayed), and delete returns what it removed (a code or challenge works once).

    interface StorageEngine {
        create: (
            collection: string,
            key: string,
            record: StorageRecord,
        ) => Promise<void>;
        delete: (
            collection: string,
            key: string,
        ) => Promise<StorageRecord | undefined>;
        get: (
            collection: string,
            key: string,
        ) => Promise<StorageRecord | undefined>;
        list: (
            collection: string,
            where?: StorageMatch,
            page?: StoragePage,
        ) => Promise<StorageEntry[]>;
        update: (
            collection: string,
            key: string,
            changes: StorageRecord,
            condition?: StorageMatch,
        ) => Promise<StorageRecord>;
    }
    Index
    create: (
        collection: string,
        key: string,
        record: StorageRecord,
    ) => Promise<void>

    Stores a new record; throws StorageError exists when the key is taken.

    delete: (collection: string, key: string) => Promise<StorageRecord | undefined>

    Removes a record and returns it, or undefined when there was none, so only one caller ever receives it.

    get: (collection: string, key: string) => Promise<StorageRecord | undefined>

    The record under a key, or undefined.

    list: (
        collection: string,
        where?: StorageMatch,
        page?: StoragePage,
    ) => Promise<StorageEntry[]>

    Every record of a collection, or those matching where, in key order; with page, at most limit of them, after the key after, so a long list is read a page at a time.

    update: (
        collection: string,
        key: string,
        changes: StorageRecord,
        condition?: StorageMatch,
    ) => Promise<StorageRecord>

    Merges fields into a record and returns the result. Throws StorageError missing when there is no record, and conflict when condition is given and the record no longer matches it.