@vllnt/convex-tokens 0.1.0-canary.4f0e428

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/dist/client/index.d.ts +116 -0
  4. package/dist/client/index.d.ts.map +1 -0
  5. package/dist/client/index.js +92 -0
  6. package/dist/client/index.js.map +1 -0
  7. package/dist/client/types.d.ts +59 -0
  8. package/dist/client/types.d.ts.map +1 -0
  9. package/dist/client/types.js +3 -0
  10. package/dist/client/types.js.map +1 -0
  11. package/dist/component/_generated/api.d.ts +40 -0
  12. package/dist/component/_generated/api.d.ts.map +1 -0
  13. package/dist/component/_generated/api.js +31 -0
  14. package/dist/component/_generated/api.js.map +1 -0
  15. package/dist/component/_generated/component.d.ts +71 -0
  16. package/dist/component/_generated/component.d.ts.map +1 -0
  17. package/dist/component/_generated/component.js +11 -0
  18. package/dist/component/_generated/component.js.map +1 -0
  19. package/dist/component/_generated/dataModel.d.ts +46 -0
  20. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  21. package/dist/component/_generated/dataModel.js +11 -0
  22. package/dist/component/_generated/dataModel.js.map +1 -0
  23. package/dist/component/_generated/server.d.ts +121 -0
  24. package/dist/component/_generated/server.d.ts.map +1 -0
  25. package/dist/component/_generated/server.js +78 -0
  26. package/dist/component/_generated/server.js.map +1 -0
  27. package/dist/component/convex.config.d.ts +3 -0
  28. package/dist/component/convex.config.d.ts.map +1 -0
  29. package/dist/component/convex.config.js +7 -0
  30. package/dist/component/convex.config.js.map +1 -0
  31. package/dist/component/crons.d.ts +10 -0
  32. package/dist/component/crons.d.ts.map +1 -0
  33. package/dist/component/crons.js +13 -0
  34. package/dist/component/crons.js.map +1 -0
  35. package/dist/component/mutations.d.ts +49 -0
  36. package/dist/component/mutations.d.ts.map +1 -0
  37. package/dist/component/mutations.js +141 -0
  38. package/dist/component/mutations.js.map +1 -0
  39. package/dist/component/queries.d.ts +51 -0
  40. package/dist/component/queries.d.ts.map +1 -0
  41. package/dist/component/queries.js +84 -0
  42. package/dist/component/queries.js.map +1 -0
  43. package/dist/component/schema.d.ts +30 -0
  44. package/dist/component/schema.d.ts.map +1 -0
  45. package/dist/component/schema.js +23 -0
  46. package/dist/component/schema.js.map +1 -0
  47. package/dist/component/validators.d.ts +45 -0
  48. package/dist/component/validators.d.ts.map +1 -0
  49. package/dist/component/validators.js +24 -0
  50. package/dist/component/validators.js.map +1 -0
  51. package/dist/react/index.d.ts +35 -0
  52. package/dist/react/index.d.ts.map +1 -0
  53. package/dist/react/index.js +30 -0
  54. package/dist/react/index.js.map +1 -0
  55. package/dist/shared.d.ts +60 -0
  56. package/dist/shared.d.ts.map +1 -0
  57. package/dist/shared.js +69 -0
  58. package/dist/shared.js.map +1 -0
  59. package/package.json +112 -0
  60. package/src/client/index.ts +220 -0
  61. package/src/client/types.ts +60 -0
  62. package/src/component/_generated/api.ts +56 -0
  63. package/src/component/_generated/component.ts +93 -0
  64. package/src/component/_generated/dataModel.ts +60 -0
  65. package/src/component/_generated/server.ts +156 -0
  66. package/src/component/convex.config.ts +9 -0
  67. package/src/component/crons.ts +19 -0
  68. package/src/component/mutations.ts +158 -0
  69. package/src/component/queries.ts +90 -0
  70. package/src/component/schema.ts +23 -0
  71. package/src/component/validators.ts +28 -0
  72. package/src/react/index.test.tsx +86 -0
  73. package/src/react/index.tsx +41 -0
  74. package/src/shared.ts +98 -0
  75. package/src/test.ts +12 -0
  76. package/src/unit.test.ts +48 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bntvllnt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ <!-- Badges -->
2
+ [![Convex Component](https://img.shields.io/badge/convex-component-EE342F.svg)](https://www.convex.dev/components)
3
+ [![npm](https://img.shields.io/npm/v/@vllnt/convex-tokens.svg)](https://www.npmjs.com/package/@vllnt/convex-tokens)
4
+ [![CI](https://github.com/vllnt/convex-tokens/actions/workflows/ci.yml/badge.svg)](https://github.com/vllnt/convex-tokens/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/npm/l/@vllnt/convex-tokens.svg)](./LICENSE)
6
+
7
+ # @vllnt/convex-tokens
8
+
9
+ Hashed-secret token primitive with mint-once, TTL, revoke and scope, as a Convex component — mint a secret against an opaque `resourceRef`, return the raw value once, and store only its SHA-256 hash.
10
+
11
+ ```ts
12
+ const tokens = new Tokens(components.tokens);
13
+ const { token, id } = await tokens.mint(ctx, { resourceRef }); // show `token` once
14
+ const result = await tokens.validate(ctx, rawToken); // { valid: true, resourceRef? } | { valid: false }
15
+ ```
16
+
17
+ ## Features
18
+
19
+ - **Mint-once** — the raw token is returned a single time and never persisted; only its digest rests in the component.
20
+ - **Hash-at-rest** — a leaked DB row can't be replayed; digest is `SHA-256` by default, `SHA-512` configurable, fixed per mount.
21
+ - **Server-sourced time** — `expiresAt` and validate-time `now` come from the server clock; expiry can't be spoofed.
22
+ - **TTL with clamp** — every token expires; a requested `ttlMs` is clamped server-side into `[MIN_TTL_MS, maxTtlMs]`.
23
+ - **Revoke** — invalidate a token before it expires, via a transition contract.
24
+ - **Scopes** — global by default, or namespace per tenant / purpose / locale.
25
+ - **Self-pruning cron + safe management surface** — sweeps expired/stale-revoked tokens; `list`/`getMetadata` never return the hash.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pnpm add @vllnt/convex-tokens
31
+ ```
32
+
33
+ Peer dependency: `convex@^1.41.0`.
34
+
35
+ ## Usage
36
+
37
+ ```ts
38
+ // convex/convex.config.ts
39
+ import { defineApp } from "convex/server";
40
+ import tokens from "@vllnt/convex-tokens/convex.config";
41
+
42
+ const app = defineApp();
43
+ app.use(tokens);
44
+ export default app;
45
+ ```
46
+
47
+ ```ts
48
+ // convex/api-keys.ts — host owns auth; pass an opaque resourceRef in.
49
+ import { components } from "./_generated/api";
50
+ import { mutation, query } from "./_generated/server";
51
+ import { v } from "convex/values";
52
+ import { Tokens } from "@vllnt/convex-tokens";
53
+
54
+ const tokens = new Tokens(components.tokens);
55
+
56
+ export const issue = mutation({
57
+ args: { userId: v.string() },
58
+ // returns { token, id }; show `token` to the user once — it is never recoverable.
59
+ handler: (ctx, { userId }) => tokens.mint(ctx, { resourceRef: userId }),
60
+ });
61
+
62
+ export const check = query({
63
+ args: { token: v.string() },
64
+ handler: (ctx, { token }) => tokens.validate(ctx, token),
65
+ });
66
+ ```
67
+
68
+ ## API Reference
69
+
70
+ | Method | Kind | Result |
71
+ |--------|------|--------|
72
+ | `mint(ctx, { scope?, resourceRef?, ttlMs? })` | mutation | `{ token, id }` (raw shown once; TTL clamped server-side) |
73
+ | `validate(ctx, rawToken, scope?)` | query | `{ valid: true, resourceRef? } \| { valid: false }` |
74
+ | `revoke(ctx, rawToken, scope?)` | mutation | `boolean` (`true` = transitioned to revoked this call) |
75
+ | `list(ctx, { scope?, resourceRef?, limit? })` | query | `TokenMetadata[]` (never the hash; `limit` clamped to 1000) |
76
+ | `getMetadata(ctx, id)` | query | `TokenMetadata \| null` (never the hash) |
77
+ | `prune(ctx, before?)` | mutation | `number` (deleted in a bounded batch) |
78
+
79
+ Full reference: [docs/API.md](docs/API.md) — including client options (`defaultScope`, `defaultTtlMs`, `maxTtlMs`, `hashAlgo`, …) and the hash-guard error code.
80
+
81
+ ## React
82
+
83
+ Optional, tree-shakeable front-tooling at `@vllnt/convex-tokens/react`; `react` and `convex` are optional peer deps. **No-leak:** hooks expose only token metadata — never a raw token or hash. Pass the host's own re-exported `list` query ref.
84
+
85
+ ```tsx
86
+ import { useTokens } from "@vllnt/convex-tokens/react";
87
+ import { api } from "./convex/_generated/api";
88
+
89
+ const tokens = useTokens(api.apiKeys.list, { resourceRef }); // TokenMetadata[] | undefined
90
+ ```
91
+
92
+ | Hook | Wraps | Returns |
93
+ |------|-------|---------|
94
+ | `useTokens(listRef, { scope?, resourceRef })` | host's `list` query | `TokenMetadata[] \| undefined` (metadata only) |
95
+
96
+ ## Security
97
+
98
+ - Auth-agnostic — the host resolves identity and passes an opaque `resourceRef`; the component never authenticates.
99
+ - Hash-at-rest — the raw token is hashed client-side (Web Crypto, SHA-256 by default); only the digest is stored, so a compromised DB yields no usable token.
100
+ - Time is server-sourced (expiry can't be forged), `validate` returns a discriminated union, and the management surface (`list`, `getMetadata`) never returns the hash.
101
+
102
+ See [docs/API.md](docs/API.md).
103
+
104
+ ## Testing
105
+
106
+ ```bash
107
+ pnpm test # single run
108
+ pnpm test:coverage # enforced 100% on covered files
109
+ ```
110
+
111
+ Tests run against the real component runtime via `convex-test` (`@edge-runtime/vm`), not mocks.
112
+
113
+ ## Contributing
114
+
115
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
116
+
117
+ ## Author
118
+
119
+ Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
120
+
121
+ Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
122
+
123
+ If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
124
+
125
+ ## License
126
+
127
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,116 @@
1
+ import type { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
2
+ import type { MintResult, TokenMetadata, TokensOptions, ValidateResult } from "./types.js";
3
+ /**
4
+ * The token component's function references, as exposed on the host via
5
+ * `components.tokens`. The component computes `expiresAt` itself from `ttlMs` —
6
+ * the client never sends a timestamp — and reads the current time server-side in
7
+ * `validate`, so neither expiry nor validity can be spoofed by a client clock.
8
+ */
9
+ export interface TokensComponent {
10
+ mutations: {
11
+ mint: FunctionReference<"mutation", "internal", {
12
+ tokenHash: string;
13
+ scope: string;
14
+ resourceRef?: string;
15
+ ttlMs: number;
16
+ defaultTtlMs: number;
17
+ maxTtlMs: number;
18
+ }, string>;
19
+ revoke: FunctionReference<"mutation", "internal", {
20
+ tokenHash: string;
21
+ scope: string;
22
+ }, boolean>;
23
+ prune: FunctionReference<"mutation", "internal", {
24
+ before: number;
25
+ }, number>;
26
+ };
27
+ queries: {
28
+ validate: FunctionReference<"query", "internal", {
29
+ tokenHash: string;
30
+ scope: string;
31
+ }, ValidateResult>;
32
+ list: FunctionReference<"query", "internal", {
33
+ scope: string;
34
+ resourceRef?: string;
35
+ limit?: number;
36
+ }, TokenMetadata[]>;
37
+ getMetadata: FunctionReference<"query", "internal", {
38
+ id: string;
39
+ }, TokenMetadata | null>;
40
+ };
41
+ }
42
+ interface RunQueryCtx {
43
+ runQuery<Q extends FunctionReference<"query", "internal">>(reference: Q, args: FunctionArgs<Q>): Promise<FunctionReturnType<Q>>;
44
+ }
45
+ interface RunMutationCtx {
46
+ runMutation<M extends FunctionReference<"mutation", "internal">>(reference: M, args: FunctionArgs<M>): Promise<FunctionReturnType<M>>;
47
+ }
48
+ /** Options for {@link Tokens.mint}. */
49
+ export interface MintOptions {
50
+ /** Namespace for the token. Defaults to the client's `defaultScope`. */
51
+ scope?: string;
52
+ /** Opaque host-owned reference to carry on the token. */
53
+ resourceRef?: string;
54
+ /**
55
+ * Requested lifetime in ms. The component clamps it into
56
+ * `[MIN_TTL_MS, maxTtlMs]` server-side; a non-finite value falls back to
57
+ * `defaultTtlMs`. The client never computes the expiry timestamp.
58
+ */
59
+ ttlMs?: number;
60
+ }
61
+ /** Options for {@link Tokens.list}. */
62
+ export interface ListOptions {
63
+ /** Namespace to list within. Defaults to the client's `defaultScope`. */
64
+ scope?: string;
65
+ /** Restrict to a single opaque host reference. */
66
+ resourceRef?: string;
67
+ /** Max rows to return. Default 100 (component-side). */
68
+ limit?: number;
69
+ }
70
+ /**
71
+ * Consumer-facing client for the hashed-secret token registry. The host owns
72
+ * meaning and auth; it passes an opaque `resourceRef` and an optional `scope`.
73
+ * The raw token is generated and hashed here — the component only ever sees the
74
+ * hash, never the secret. Time is sourced server-side: the client never supplies
75
+ * `now` or an `expiresAt`.
76
+ */
77
+ export declare class Tokens {
78
+ private readonly component;
79
+ private readonly defaultScope;
80
+ private readonly defaultTtlMs;
81
+ private readonly maxTtlMs;
82
+ private readonly tokenBytes;
83
+ private readonly hashAlgo;
84
+ constructor(component: TokensComponent, options?: TokensOptions);
85
+ private scopeOf;
86
+ /**
87
+ * Mint a new token. Returns the raw secret ONCE (it is never recoverable
88
+ * afterwards) alongside the component-side id. The requested `ttlMs` is sent
89
+ * to the component, which clamps it and computes `expiresAt` from its own
90
+ * clock.
91
+ */
92
+ mint(ctx: RunMutationCtx, opts?: MintOptions): Promise<MintResult>;
93
+ /**
94
+ * Validate `rawToken`. Hashes the secret and checks scope, revocation, and
95
+ * expiry. Expiry is evaluated against the component's server clock — there is
96
+ * no client-supplied time to override it.
97
+ */
98
+ validate(ctx: RunQueryCtx, rawToken: string, scope?: string): Promise<ValidateResult>;
99
+ /** Revoke `rawToken`. Returns `true` if a matching token was revoked. */
100
+ revoke(ctx: RunMutationCtx, rawToken: string, scope?: string): Promise<boolean>;
101
+ /**
102
+ * List token METADATA (never the hash) for a management surface, filtered by
103
+ * scope and optional `resourceRef`. Safe to expose to a future admin UI.
104
+ */
105
+ list(ctx: RunQueryCtx, opts?: ListOptions): Promise<TokenMetadata[]>;
106
+ /**
107
+ * Fetch the safe METADATA of one token by its component id (the `id` from
108
+ * {@link Tokens.mint}). Returns `null` if it no longer exists. Never returns
109
+ * the hash.
110
+ */
111
+ getMetadata(ctx: RunQueryCtx, id: string): Promise<TokenMetadata | null>;
112
+ /** Delete every token that expired before `before` (default now). Returns the count. */
113
+ prune(ctx: RunMutationCtx, before?: number): Promise<number>;
114
+ }
115
+ export type { MintResult, TokenMetadata, TokensOptions, ValidateResult };
116
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAYpB;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE;QACT,IAAI,EAAE,iBAAiB,CACrB,UAAU,EACV,UAAU,EACV;YACE,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC;YACd,YAAY,EAAE,MAAM,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC;SAClB,EACD,MAAM,CACP,CAAC;QACF,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EACpC,OAAO,CACR,CAAC;QACF,KAAK,E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AE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAK7D;AAED,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { DEFAULT_HASH_ALGO, DEFAULT_MAX_TTL_MS, DEFAULT_SCOPE, DEFAULT_TOKEN_BYTES, DEFAULT_TTL_MS, generateToken, hashToken, } from "../shared.js";
2
+ /**
3
+ * Consumer-facing client for the hashed-secret token registry. The host owns
4
+ * meaning and auth; it passes an opaque `resourceRef` and an optional `scope`.
5
+ * The raw token is generated and hashed here — the component only ever sees the
6
+ * hash, never the secret. Time is sourced server-side: the client never supplies
7
+ * `now` or an `expiresAt`.
8
+ */
9
+ export class Tokens {
10
+ component;
11
+ defaultScope;
12
+ defaultTtlMs;
13
+ maxTtlMs;
14
+ tokenBytes;
15
+ hashAlgo;
16
+ constructor(component, options = {}) {
17
+ this.component = component;
18
+ this.defaultScope = options.defaultScope ?? DEFAULT_SCOPE;
19
+ this.defaultTtlMs = options.defaultTtlMs ?? DEFAULT_TTL_MS;
20
+ this.maxTtlMs = options.maxTtlMs ?? DEFAULT_MAX_TTL_MS;
21
+ this.tokenBytes = options.tokenBytes ?? DEFAULT_TOKEN_BYTES;
22
+ this.hashAlgo = options.hashAlgo ?? DEFAULT_HASH_ALGO;
23
+ }
24
+ scopeOf(scope) {
25
+ return scope ?? this.defaultScope;
26
+ }
27
+ /**
28
+ * Mint a new token. Returns the raw secret ONCE (it is never recoverable
29
+ * afterwards) alongside the component-side id. The requested `ttlMs` is sent
30
+ * to the component, which clamps it and computes `expiresAt` from its own
31
+ * clock.
32
+ */
33
+ async mint(ctx, opts = {}) {
34
+ const raw = generateToken(this.tokenBytes);
35
+ const tokenHash = await hashToken(raw, this.hashAlgo);
36
+ const id = await ctx.runMutation(this.component.mutations.mint, {
37
+ tokenHash,
38
+ scope: this.scopeOf(opts.scope),
39
+ resourceRef: opts.resourceRef,
40
+ ttlMs: opts.ttlMs ?? this.defaultTtlMs,
41
+ defaultTtlMs: this.defaultTtlMs,
42
+ maxTtlMs: this.maxTtlMs,
43
+ });
44
+ return { token: raw, id };
45
+ }
46
+ /**
47
+ * Validate `rawToken`. Hashes the secret and checks scope, revocation, and
48
+ * expiry. Expiry is evaluated against the component's server clock — there is
49
+ * no client-supplied time to override it.
50
+ */
51
+ async validate(ctx, rawToken, scope) {
52
+ const tokenHash = await hashToken(rawToken, this.hashAlgo);
53
+ return ctx.runQuery(this.component.queries.validate, {
54
+ tokenHash,
55
+ scope: this.scopeOf(scope),
56
+ });
57
+ }
58
+ /** Revoke `rawToken`. Returns `true` if a matching token was revoked. */
59
+ async revoke(ctx, rawToken, scope) {
60
+ const tokenHash = await hashToken(rawToken, this.hashAlgo);
61
+ return ctx.runMutation(this.component.mutations.revoke, {
62
+ tokenHash,
63
+ scope: this.scopeOf(scope),
64
+ });
65
+ }
66
+ /**
67
+ * List token METADATA (never the hash) for a management surface, filtered by
68
+ * scope and optional `resourceRef`. Safe to expose to a future admin UI.
69
+ */
70
+ list(ctx, opts = {}) {
71
+ return ctx.runQuery(this.component.queries.list, {
72
+ scope: this.scopeOf(opts.scope),
73
+ resourceRef: opts.resourceRef,
74
+ limit: opts.limit,
75
+ });
76
+ }
77
+ /**
78
+ * Fetch the safe METADATA of one token by its component id (the `id` from
79
+ * {@link Tokens.mint}). Returns `null` if it no longer exists. Never returns
80
+ * the hash.
81
+ */
82
+ getMetadata(ctx, id) {
83
+ return ctx.runQuery(this.component.queries.getMetadata, { id });
84
+ }
85
+ /** Delete every token that expired before `before` (default now). Returns the count. */
86
+ prune(ctx, before) {
87
+ return ctx.runMutation(this.component.mutations.prune, {
88
+ before: before ?? Date.now(),
89
+ });
90
+ }
91
+ }
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,i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,GAAgB,EAAE,EAAU;QACtC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,wFAAwF;IACxF,KAAK,CAAC,GAAmB,EAAE,MAAe;QACxC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE;YACrD,MAAM,EAAE,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,59 @@
1
+ /** Public TypeScript surface for the tokens client. */
2
+ import type { HashAlgo } from "../shared.js";
3
+ /** Result of minting a token. `token` is the raw secret — shown ONCE, never stored. */
4
+ export interface MintResult {
5
+ /** The raw token. Hand it to the caller now; the component keeps only its hash. */
6
+ token: string;
7
+ /** The component-side id of the minted token record (use it with `getMetadata`). */
8
+ id: string;
9
+ }
10
+ /**
11
+ * Result of validating a raw token.
12
+ *
13
+ * Discriminated union on `valid`:
14
+ * - `{ valid: true, resourceRef? }` — the token is live; `resourceRef` is the
15
+ * opaque host-owned reference the token was minted with, if any.
16
+ * - `{ valid: false }` — the token is unknown, wrong-scope, revoked, or expired.
17
+ * The failed branch structurally cannot carry `resourceRef`.
18
+ */
19
+ export type ValidateResult = {
20
+ valid: true;
21
+ resourceRef?: string;
22
+ } | {
23
+ valid: false;
24
+ };
25
+ /**
26
+ * Safe, leak-free metadata for one token — what a management UI may display.
27
+ * NEVER includes `tokenHash`.
28
+ */
29
+ export interface TokenMetadata {
30
+ /** The component-side id of the token record. */
31
+ id: string;
32
+ /** The token's namespace. */
33
+ scope: string;
34
+ /** The opaque host-owned reference, if the token carries one. */
35
+ resourceRef?: string;
36
+ /** Whether the token has been revoked. */
37
+ revoked: boolean;
38
+ /** Expiry timestamp (ms since epoch). */
39
+ expiresAt: number;
40
+ /** Creation timestamp (ms since epoch). */
41
+ createdAt: number;
42
+ }
43
+ /** Construction options for the {@link Tokens} client. */
44
+ export interface TokensOptions {
45
+ /** Namespace applied when a call omits `scope`. Default `"global"`. */
46
+ defaultScope?: string;
47
+ /** Lifetime applied when `mint` omits `ttlMs`, in ms. Default 24h. */
48
+ defaultTtlMs?: number;
49
+ /** Ceiling a requested TTL is clamped to, in ms. Default 30d. */
50
+ maxTtlMs?: number;
51
+ /** Entropy of a generated raw token, in bytes. Default 24. */
52
+ tokenBytes?: number;
53
+ /**
54
+ * Digest algorithm for hashing tokens. Fixed per mount — changing it
55
+ * invalidates every existing hash. Default `"SHA-256"`.
56
+ */
57
+ hashAlgo?: HashAlgo;
58
+ }
59
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,uFAAuF;AACvF,MAAM,WAAW,UAAU;IACzB,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAErB;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ /** Public TypeScript surface for the tokens client. */
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,uDAAuD"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Generated `api` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type * as crons from "../crons.js";
10
+ import type * as mutations from "../mutations.js";
11
+ import type * as queries from "../queries.js";
12
+ import type * as validators from "../validators.js";
13
+ import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
14
+ declare const fullApi: ApiFromModules<{
15
+ crons: typeof crons;
16
+ mutations: typeof mutations;
17
+ queries: typeof queries;
18
+ validators: typeof validators;
19
+ }>;
20
+ /**
21
+ * A utility for referencing Convex functions in your app's public API.
22
+ *
23
+ * Usage:
24
+ * ```js
25
+ * const myFunctionReference = api.myModule.myFunction;
26
+ * ```
27
+ */
28
+ export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
29
+ /**
30
+ * A utility for referencing Convex functions in your app's internal API.
31
+ *
32
+ * Usage:
33
+ * ```js
34
+ * const myFunctionReference = internal.myModule.myFunction;
35
+ * ```
36
+ */
37
+ export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
38
+ export declare const components: {};
39
+ export {};
40
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,UAAU,CAAC;CAC/B,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `api` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ import { anyApi, componentsGeneric } from "convex/server";
11
+ const fullApi = anyApi;
12
+ /**
13
+ * A utility for referencing Convex functions in your app's public API.
14
+ *
15
+ * Usage:
16
+ * ```js
17
+ * const myFunctionReference = api.myModule.myFunction;
18
+ * ```
19
+ */
20
+ export const api = anyApi;
21
+ /**
22
+ * A utility for referencing Convex functions in your app's internal API.
23
+ *
24
+ * Usage:
25
+ * ```js
26
+ * const myFunctionReference = internal.myModule.myFunction;
27
+ * ```
28
+ */
29
+ export const internal = anyApi;
30
+ export const components = componentsGeneric();
31
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAYH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAKR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Generated `ComponentApi` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { FunctionReference } from "convex/server";
10
+ /**
11
+ * A utility for referencing a Convex component's exposed API.
12
+ *
13
+ * Useful when expecting a parameter like `components.myComponent`.
14
+ * Usage:
15
+ * ```ts
16
+ * async function myFunction(ctx: QueryCtx, component: ComponentApi) {
17
+ * return ctx.runQuery(component.someFile.someQuery, { ...args });
18
+ * }
19
+ * ```
20
+ */
21
+ export type ComponentApi<Name extends string | undefined = string | undefined> = {
22
+ mutations: {
23
+ mint: FunctionReference<"mutation", "internal", {
24
+ defaultTtlMs: number;
25
+ maxTtlMs: number;
26
+ resourceRef?: string;
27
+ scope: string;
28
+ tokenHash: string;
29
+ ttlMs: number;
30
+ }, string, Name>;
31
+ prune: FunctionReference<"mutation", "internal", {
32
+ before: number;
33
+ }, number, Name>;
34
+ revoke: FunctionReference<"mutation", "internal", {
35
+ scope: string;
36
+ tokenHash: string;
37
+ }, boolean, Name>;
38
+ };
39
+ queries: {
40
+ getMetadata: FunctionReference<"query", "internal", {
41
+ id: string;
42
+ }, {
43
+ createdAt: number;
44
+ expiresAt: number;
45
+ id: string;
46
+ resourceRef?: string;
47
+ revoked: boolean;
48
+ scope: string;
49
+ } | null, Name>;
50
+ list: FunctionReference<"query", "internal", {
51
+ limit?: number;
52
+ resourceRef?: string;
53
+ scope: string;
54
+ }, Array<{
55
+ createdAt: number;
56
+ expiresAt: number;
57
+ id: string;
58
+ resourceRef?: string;
59
+ revoked: boolean;
60
+ scope: string;
61
+ }>, Name>;
62
+ validate: FunctionReference<"query", "internal", {
63
+ scope: string;
64
+ tokenHash: string;
65
+ }, {
66
+ resourceRef?: string;
67
+ valid: boolean;
68
+ }, Name>;
69
+ };
70
+ };
71
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/component.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3E;IACE,SAAS,EAAE;QACT,IAAI,EAAE,iBAAiB,CACrB,UAAU,EACV,UAAU,EACV;YACE,YAAY,EAAE,MAAM,CAAC;YACrB,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC;YACd,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE,MAAM,CAAC;SACf,EACD,MAAM,EACN,IAAI,CACL,CAAC;QACF,KAAK,EAAE,iBAAiB,CACtB,UAAU,EACV,UAAU,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@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `ComponentApi` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/component/_generated/component.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generated data model types.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { DataModelFromSchemaDefinition, DocumentByName, TableNamesInDataModel, SystemTableNames } from "convex/server";
10
+ import type { GenericId } from "convex/values";
11
+ import schema from "../schema.js";
12
+ /**
13
+ * The names of all of your Convex tables.
14
+ */
15
+ export type TableNames = TableNamesInDataModel<DataModel>;
16
+ /**
17
+ * The type of a document stored in Convex.
18
+ *
19
+ * @typeParam TableName - A string literal type of the table name (like "users").
20
+ */
21
+ export type Doc<TableName extends TableNames> = DocumentByName<DataModel, TableName>;
22
+ /**
23
+ * An identifier for a document in Convex.
24
+ *
25
+ * Convex documents are uniquely identified by their `Id`, which is accessible
26
+ * on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
27
+ *
28
+ * Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
29
+ *
30
+ * IDs are just strings at runtime, but this type can be used to distinguish them from other
31
+ * strings when type checking.
32
+ *
33
+ * @typeParam TableName - A string literal type of the table name (like "users").
34
+ */
35
+ export type Id<TableName extends TableNames | SystemTableNames> = GenericId<TableName>;
36
+ /**
37
+ * A type describing your Convex data model.
38
+ *
39
+ * This type includes information about what tables you have, the type of
40
+ * documents stored in those tables, and the indexes defined on them.
41
+ *
42
+ * This type is used to parameterize methods like `queryGeneric` and
43
+ * `mutationGeneric` to make them type-safe.
44
+ */
45
+ export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
46
+ //# sourceMappingURL=dataModel.d.ts.map