Function: touchSecretLastUsedAt()
touchSecretLastUsedAt<
S>(secretRepo,uid,logger?):Promise<void>
Defined in: auth/src/auth/shared.ts:1220
Best-effort persists the current time as Secret.lastUsedAt on the identified secret, for observability
into when each stored credential was last used to successfully authenticate. Re-fetches the secret by
uid and writes a minimal partial update ({uid, version, lastUsedAt}), mirroring the exact
findOne-then-partial-update() pattern the various updateCredentialCounter()/updateSecretTimeStep()
route methods already use elsewhere in this library.
A call site that already performs its own findOne-then-update() round trip for the same secret in the
same request (e.g. updateCredentialCounter(), updateSecretTimeStep(), consumeRecoveryCode()) should
merge lastUsedAt into that existing write instead of calling this - a second independent write here
would race the first on version and either lose or fail spuriously. This helper is for the call sites
that have no such write of their own (a plain password/app-password match).
Deliberately swallows every failure - a missing secret, a stale version conflict, a transient datastore
error - rather than letting it propagate. Persisting this timestamp is a nice-to-have audit signal, never
something that should be allowed to fail an otherwise-successful authentication; callers can invoke this
without awaiting it, or .catch() it, either way it never rejects.
Type Parameters
S
S extends Secret
Parameters
secretRepo
RepoUtils<S> | undefined
The repository to persist the update through. A no-op if undefined.
uid
string
The unique id of the secret that was just used to authenticate.
logger?
any
An optional @Logger-injected logger to trace a swallowed failure onto, at debug level -
only passed by a call site whose class already has one (not every route does).
Returns
Promise<void>