Skip to content

feat(redis): add setKeyIfNotExists for one-time claims - #726

Open
Anshumancanrock wants to merge 1 commit into
cameri:mainfrom
Anshumancanrock:feat/nip98-redis-nx
Open

feat(redis): add setKeyIfNotExists for one-time claims#726
Anshumancanrock wants to merge 1 commit into
cameri:mainfrom
Anshumancanrock:feat/nip98-redis-nx

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Description

This PR adds ICacheAdapter.setKeyIfNotExists() / Redis SET … NX (optional EX) so callers can claim a key once; used next for one-time NIP-98 auth event ids.

  • returns true when the key is created, false when it already exists (null from Redis)
  • mirrors existing setKey expiry options
  • no admin middleware / NIP-98 replay wiring in this PR

Related Issue

Prerequisite for NIP-98 admin API auth (follows #722 verifier; pairs with absolute URL helper). Next: admin middleware.

Motivation and Context

Replay protection needs an atomic “set if absent” primitive. Exposing it on the cache adapter keeps the later middleware thin and reusable.

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a36d12b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Anshumancanrock
Anshumancanrock requested a review from cameri August 12, 2026 07:57
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 69.74% (-0.008%) from 69.748% — Anshumancanrock:feat/nip98-redis-nx into cameri:main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants