Skip to content

[ CONVEX COMPONENT · STABLE · Apache-2.0 ]

@vllnt/convex-api-keys

Convex component for secure API key management — create, validate, revoke, rotate, and track usage

STABLE 0.2.0 · 1 GitHub star

Package details

Install

The untagged install gets the latest stable version (0.2.0). The canary tag tracks main (0.3.0-canary.be675d5).

terminal
pnpm add @vllnt/convex-api-keys
pnpm add @vllnt/convex-api-keys@canary

Register the component

Add it to your app’s convex/convex.config.ts, then run npx convex dev to generate the references.

convex/convex.config.ts
import { defineApp } from "convex/server";
import apiKeys from "@vllnt/convex-api-keys/convex.config";
const app = defineApp();
app.use(apiKeys);
export default app;

Use it

Usage, options and examples are in the package README.

Read the README

Downloads

Last 7 days
1,916
Since first publish
49,624

Downloads per week since 23 March 2026, oldest on the left. Weeks count back from 23 November 2026, so the first one may be shorter than seven days.

1,916 downloads in the last 7 days. 49,624 downloads since 23 March 2026. Source: npm, counted through 23 November 2026.

Show downloads per week as a table
WeekDownloads
23 March 202628
24 March 2026 to 30 March 2026583
31 March 2026 to 6 April 2026179
7 April 2026 to 13 April 202691
14 April 2026 to 20 April 202651
21 April 2026 to 27 April 2026437
28 April 2026 to 4 May 2026504
5 May 2026 to 11 May 2026496
12 May 2026 to 18 May 2026760
19 May 2026 to 25 May 2026954
26 May 2026 to 1 June 2026164
2 June 2026 to 8 June 2026117
9 June 2026 to 15 June 2026578
16 June 2026 to 22 June 2026462
23 June 2026 to 29 June 2026902
30 June 2026 to 6 July 2026887
7 July 2026 to 13 July 2026966
14 July 2026 to 20 July 2026343
21 July 2026 to 27 July 2026377
28 July 2026 to 3 August 20261,702
4 August 2026 to 10 August 20262,337
11 August 2026 to 17 August 20262,146
18 August 2026 to 24 August 20261,962
25 August 2026 to 31 August 20263,136
1 September 2026 to 7 September 20262,317
8 September 2026 to 14 September 20263,912
15 September 2026 to 21 September 20262,750
22 September 2026 to 28 September 20261,947
29 September 2026 to 5 October 20262,201
6 October 2026 to 12 October 20262,976
13 October 2026 to 19 October 20262,120
20 October 2026 to 26 October 20262,043
27 October 2026 to 2 November 20264,205
3 November 2026 to 9 November 20262,025
10 November 2026 to 16 November 20261,050
17 November 2026 to 23 November 20261,916

Release history

Every release on a timeline, oldest on the left. A tall mark with its version is a stable release; a short mark is a canary build. The time axis is the one of the downloads chart, so a release stands above the week it shipped in.

2 stable releases and 20 canary builds since 23 March 2026. Latest stable: 0.2.0 on 25 April 2026.

Show every release as a table
VersionKindPublished
0.3.0-canary.be675d5canary23 November 2026
0.3.0-canary.2a5f447canary23 November 2026
0.3.0-canary.a17e376canary22 November 2026
0.3.0-canary.c1e6b53canary31 October 2026
0.2.1-canary.c478e3dcanary31 October 2026
0.2.1-canary.6b29f95canary30 October 2026
0.2.1-canary.48f454acanary24 October 2026
0.2.1-canary.9b260a8canary1 September 2026
0.2.1-canary.1629092canary31 August 2026
0.2.1-canary.5593afccanary31 August 2026
0.2.1-canary.1e357f9canary31 August 2026
0.2.0-canary.3df35d3canary13 June 2026
0.2.0-canary.8d1ace0canary12 June 2026
0.2.0-canary.d26dea5canary12 June 2026
0.2.0stable25 April 2026
0.2.0-canary.780c0c3canary25 April 2026
0.2.0-canary.3214568canary25 April 2026
0.1.1-canary.61796d1canary27 March 2026
0.1.1-canary.f11443ecanary25 March 2026
0.1.1-canary.2fc1258canary24 March 2026
0.1.0-canary.f67cc26canary24 March 2026
0.1.0stable23 March 2026

Changelog

The newest stable releases of @vllnt/convex-api-keys, with the notes from its changelog.

  1. 0.2.0

    Breaking Changes
    • Convex compatibility: this release targets convex@^1.36.1 and convex-test@^0.0.50.
    • create() / rotate(): Secret material (lookupPrefix, secretHex, hash) now generated server-side. Remove these from client args.
    • Admin mutations (revoke, disable, enable, update, rotate, getUsage): ownerId is now a required argument for auth boundary enforcement.
    • apiKeyEvents table removed: Audit trail replaced with structured logging (Convex dashboard). Export existing event data before upgrading.
    • @convex-dev/rate-limiter removed: Rate limiting is now the integrator's responsibility at their HTTP action/mutation layer. Remove rateLimiterTest.register() from test setup.
    • @convex-dev/aggregate and @convex-dev/crons removed: Remove aggregateTest.register() and cronsTest.register() from test setup.
    • getUsage(): period param removed (counter-only). lastUsedAt removed from return type.
    • validate(): retryAfter removed from failure response (no internal rate limiting).
    • list() / listByTag(): Now paginated with limit param (default 100).
    Migration Guide
    // BEFORE (v0.1)
    const { key } = await apiKeys.create(ctx, {
      name: "My Key",
      ownerId: "org_1",
      lookupPrefix,
      secretHex,
      hash, // ← REMOVE these
    });
    await apiKeys.revoke(ctx, { keyId });
    await apiKeys.rotate(ctx, { keyId, lookupPrefix, secretHex });
    const usage = await apiKeys.getUsage(ctx, { keyId, period: { start, end } });
    
    // AFTER (v0.2)
    const { key } = await apiKeys.create(ctx, {
      name: "My Key",
      ownerId: "org_1",
      // secret material generated server-side
    });
    await apiKeys.revoke(ctx, { keyId, ownerId: "org_1" }); // ← ADD ownerId
    await apiKeys.rotate(ctx, { keyId, ownerId: "org_1" }); // ← ADD ownerId
    const usage = await apiKeys.getUsage(ctx, { keyId, ownerId: "org_1" }); // ← ADD ownerId, REMOVE period
    

    Test setup:

    // BEFORE
    import rateLimiterTest from "@convex-dev/rate-limiter/test";
    import aggregateTest from "@convex-dev/aggregate/test";
    import cronsTest from "@convex-dev/crons/test";
    rateLimiterTest.register(t, "apiKeys/rateLimiter");
    aggregateTest.register(t, "apiKeys/usageAggregate");
    cronsTest.register(t, "apiKeys/crons");
    
    // AFTER — only shardedCounter remains
    import shardedCounterTest from "@convex-dev/sharded-counter/test";
    shardedCounterTest.register(t, "apiKeys/shardedCounter");
    
    New Features
    • Public client wrapper now forwards optional limit to list() and listByTag()
    • ValidationFailure no longer advertises the removed retryAfter field
    • Auth boundary: ownerId cross-check on all admin mutations
    • Server-side secret generation for create() and rotate()
    • Input validation: keyPrefix charset, env charset, gracePeriodMs bounds (60s–30d), metadata size (4KB), scopes (50), tags (20)
    • Configure bounds validation (reject negative/zero)
    • Structured audit logging on all mutation outcomes
    • lastUsedAt throttled to 60s (reduces OCC contention)
    • Remaining decrement decoupled from lastUsedAt write (single merged patch)
    • revokeByTag expanded to include rotating and disabled statuses
    • Paginated list/listByTag with configurable limit
  2. 0.1.0

    • Initial release
    • Key creation with SHA-256 hashing, prefix-indexed lookup
    • Key validation with status/expiry/remaining checks
    • Key revocation (single + bulk by tag)
    • Key rotation with configurable grace period
    • Key listing by owner, tag, environment
    • Key update (name, scopes, tags, metadata) without rotation
    • Key disable/enable (reversible pause)
    • Finite-use keys (remaining counter with atomic decrement)
    • Key types (secret / publishable) with type-encoded prefix
    • Environment-aware key format
    • Multi-tenant isolation (ownerId-scoped queries)
    • Audit event log (apiKeyEvents table)
    • Usage analytics via event counting
    • Child components: @convex-dev/rate-limiter, sharded-counter, aggregate, crons
All releases of @vllnt/convex-api-keys
Stable releases
RSSAtomJSON Feed
Canary builds
RSSAtomJSON Feed

Licence

Released under the Apache-2.0 licence. The full text is in the source repository.

[ PACKAGE ]

Stable
0.2.0
Canary
0.3.0-canary.be675d5
GitHub stars
1 GitHub star
Licence
Apache-2.0

Theme