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

    Class AppTokenStore

    Persists app refresh tokens as hashes in a JSON file on the data volume.

    Index
    • Binds the store to one path on one filesystem.

      Parameters

      • fileSystem: IFileSystem

        Injected filesystem access.

      • filePath: string

        Absolute path of the app-tokens JSON file.

      • ttlDays: number = DEFAULT_REFRESH_TTL_DAYS

        Refresh-token lifetime in days.

      Returns AppTokenStore

    • Issues the first refresh token of a new family.

      Parameters

      • grant: TokenGrant

        Device, factors and fingerprint captured at authorization.

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns IIssuedToken

      The new record together with its one-time plaintext token.

      StorageError when the current file cannot be read or the new one saved.

    • Looks up a record by the plaintext token the client presented.

      Parameters

      • token: string

        The plaintext refresh token.

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns IAppTokenRecord | undefined

      The matching record, or undefined when unknown, pruned, or unreadable.

    • Rotates a refresh token: the presented record is revoked and a replacement joins the same family. Presenting an already-revoked token means the client or an attacker replayed it, so the whole family is revoked instead, unless it falls within ROTATION_OVERLAP_MS of its rotation.

      An expired token reads as unknown, because the load that feeds this drops expired records before anything looks at them. A spent token is kept until its overlap has passed, even when that is after its own expiry.

      Parameters

      • token: string

        The plaintext refresh token presented by the client.

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns Procedure<IIssuedToken>

      Procedure with the replacement token, or a failure naming the reason.

      StorageError when the current file cannot be read or the new one saved.

    • Revokes the family a live record belongs to, so signing a device out kills its replacements too. It reads the file as a write does, so an unreadable file throws rather than reading as "no such session".

      Parameters

      • id: string

        Public record id, as shown in the sessions list.

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns boolean

      True when a live record with that id existed.

      StorageError when the current file cannot be read or the new one saved.

    • Revokes the family of the record a refresh token belongs to, whether or not that record was already rotated. It reads the file as a write does, so an unreadable file throws rather than reading as "no such token".

      Parameters

      • token: string

        The plaintext refresh token.

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns boolean

      True when an unexpired record held that token.

      StorageError when the current file cannot be read or the new one saved.

    • Revokes every live record sharing a family id.

      Parameters

      • familyId: string

        The family to kill.

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns number

      How many records were revoked by this call.

      StorageError when the current file cannot be read or the new one saved.

    • Lists the records that can still be refreshed.

      Parameters

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns IAppTokenRecord[]

      Live records, newest last; none when the file cannot be read.

    • Drops expired records from the file.

      Parameters

      • now: number = ...

        Current epoch milliseconds, injectable for tests.

      Returns void

      Nothing; the file is rewritten only when something was dropped.

      StorageError when the current file cannot be read or the new one saved.