@vllnt/convex-api-keys 0.2.0-canary.d26dea5 → 0.2.1-canary.1629092
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.
- package/LICENSE +21 -190
- package/README.md +47 -134
- package/dist/client/index.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +2 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/_generated/server.d.ts +12 -0
- package/dist/component/_generated/server.d.ts.map +1 -1
- package/dist/component/_generated/server.js +2 -0
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/convex.config.d.ts +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/mutations.d.ts +11 -11
- package/dist/component/mutations.js +16 -16
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.d.ts +2 -2
- package/dist/component/queries.js +1 -1
- package/dist/component/queries.js.map +1 -1
- package/dist/component/schema.d.ts +13 -13
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/shared.d.ts +2 -2
- package/package.json +30 -18
- package/src/component/_generated/api.ts +2 -0
- package/src/component/_generated/component.ts +3 -6
- package/src/component/_generated/server.ts +13 -0
- package/src/component/mutations.ts +16 -16
- package/src/component/queries.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,190 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding any notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
Copyright 2026 vllnt
|
|
179
|
-
|
|
180
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
-
you may not use this file except in compliance with the License.
|
|
182
|
-
You may obtain a copy of the License at
|
|
183
|
-
|
|
184
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
-
|
|
186
|
-
Unless required by applicable law or agreed to in writing, software
|
|
187
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
-
See the License for the specific language governing permissions and
|
|
190
|
-
limitations under the License.
|
|
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
CHANGED
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
[](https://www.convex.dev/components)
|
|
3
|
+
[](https://www.npmjs.com/package/@vllnt/convex-api-keys)
|
|
3
4
|
[](https://github.com/vllnt/convex-api-keys/actions/workflows/ci.yml)
|
|
4
|
-
[](./LICENSE)
|
|
5
|
+
[](./LICENSE)
|
|
5
6
|
|
|
6
7
|
# @vllnt/convex-api-keys
|
|
7
8
|
|
|
8
|
-
Secure API key management as a [Convex component](https://docs.convex.dev/components)
|
|
9
|
+
Secure API key management as a [Convex component](https://docs.convex.dev/components) — create, validate, revoke, rotate, and track usage with built-in auth boundaries and structured audit logging.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- **Finite-use keys** — `remaining` counter with atomic decrement (verification tokens, one-time-use)
|
|
16
|
-
- **Disable / Enable** — reversible pause without revoking
|
|
17
|
-
- **Rotation** — configurable grace period (60s–30d) where both old and new keys are valid
|
|
18
|
-
- **Bulk revoke** — revoke all keys matching a tag (active, rotating, and disabled)
|
|
19
|
-
- **Tags & environments** — filter keys by tags and environment strings
|
|
20
|
-
- **Multi-tenant** — every query scoped by `ownerId`, no cross-tenant leakage
|
|
21
|
-
- **Usage tracking** — per-key usage counter via `@convex-dev/sharded-counter`
|
|
22
|
-
- **Input validation** — keyPrefix/env charset, metadata size (4KB), scopes (50), tags (20)
|
|
23
|
-
- **Structured logging** — audit trail via structured logs (Convex dashboard)
|
|
24
|
-
|
|
25
|
-
## Architecture
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
Your App → @vllnt/convex-api-keys
|
|
29
|
-
└── @convex-dev/sharded-counter (high-throughput usage counters)
|
|
11
|
+
```ts
|
|
12
|
+
const apiKeys = new ApiKeys(components.apiKeys, { prefix: "myapp" });
|
|
13
|
+
const { key, keyId } = await apiKeys.create(ctx, { name: "SDK Key", ownerId: orgId });
|
|
14
|
+
const result = await apiKeys.validate(ctx, { key: bearerToken });
|
|
15
|
+
// result.valid → { keyId, ownerId, scopes, ... } | result.reason
|
|
30
16
|
```
|
|
31
17
|
|
|
32
|
-
|
|
18
|
+
## Features
|
|
33
19
|
|
|
34
|
-
|
|
20
|
+
- **Secure by default** — SHA-256 hashed storage, constant-time comparison, prefix-indexed O(1) lookup, server-side secret generation.
|
|
21
|
+
- **Auth boundary** — `ownerId` required on all admin mutations; prevents cross-tenant access.
|
|
22
|
+
- **Key types** — `secret` and `publishable` keys with type-encoded prefixes.
|
|
23
|
+
- **Finite-use keys** — `remaining` counter with atomic decrement for one-time-use tokens.
|
|
24
|
+
- **Disable / enable** — reversible pause without revoking.
|
|
25
|
+
- **Rotation** — configurable grace period (60s–30d) where both old and new keys are valid.
|
|
26
|
+
- **Bulk revoke by tag, tags & environments, multi-tenant scoping, usage tracking, input validation, structured audit logging.**
|
|
35
27
|
|
|
36
28
|
## Installation
|
|
37
29
|
|
|
@@ -41,8 +33,6 @@ Peer dependency: `convex@^1.36.1`
|
|
|
41
33
|
npm install convex@^1.36.1 @vllnt/convex-api-keys
|
|
42
34
|
```
|
|
43
35
|
|
|
44
|
-
If your app already depends on Convex, make sure it satisfies `^1.36.1`.
|
|
45
|
-
|
|
46
36
|
Register in your `convex/convex.config.ts`:
|
|
47
37
|
|
|
48
38
|
```ts
|
|
@@ -51,27 +41,23 @@ import apiKeys from "@vllnt/convex-api-keys/convex.config";
|
|
|
51
41
|
|
|
52
42
|
const app = defineApp();
|
|
53
43
|
app.use(apiKeys);
|
|
54
|
-
|
|
55
44
|
export default app;
|
|
56
45
|
```
|
|
57
46
|
|
|
58
|
-
|
|
47
|
+
> **Rate limiting** is your responsibility — add `@convex-dev/rate-limiter` at your HTTP action/mutation layer where you have real caller context (IP, auth, plan tier). The component has none.
|
|
59
48
|
|
|
60
|
-
|
|
49
|
+
## Usage
|
|
61
50
|
|
|
62
51
|
```ts
|
|
63
52
|
import { ApiKeys } from "@vllnt/convex-api-keys";
|
|
64
53
|
import { components } from "./_generated/api";
|
|
65
54
|
|
|
66
55
|
const apiKeys = new ApiKeys(components.apiKeys, {
|
|
67
|
-
prefix: "myapp",
|
|
68
|
-
defaultType: "secret",
|
|
56
|
+
prefix: "myapp", // key prefix (default: "vk")
|
|
57
|
+
defaultType: "secret",
|
|
69
58
|
});
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Create a key
|
|
73
59
|
|
|
74
|
-
|
|
60
|
+
// Create — secret material is generated server-side, returned once.
|
|
75
61
|
const { key, keyId } = await apiKeys.create(ctx, {
|
|
76
62
|
name: "Production SDK Key",
|
|
77
63
|
ownerId: orgId,
|
|
@@ -79,102 +65,19 @@ const { key, keyId } = await apiKeys.create(ctx, {
|
|
|
79
65
|
scopes: ["read:users", "write:orders"],
|
|
80
66
|
tags: ["sdk", "v2"],
|
|
81
67
|
env: "live",
|
|
82
|
-
metadata: { plan: "enterprise" },
|
|
83
|
-
expiresAt: Date.now() + 90 * 24 * 60 * 60 * 1000,
|
|
84
|
-
remaining: 100000,
|
|
85
68
|
});
|
|
86
69
|
// key = "myapp_secret_live_a1b2c3d4_<64-char-hex>"
|
|
87
|
-
// Secret material is generated server-side — never passed from client
|
|
88
|
-
```
|
|
89
70
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```ts
|
|
71
|
+
// Validate — track usage and narrow on `valid`.
|
|
93
72
|
const result = await apiKeys.validate(ctx, { key: bearerToken });
|
|
94
|
-
|
|
95
73
|
if (!result.valid) {
|
|
96
|
-
// result.reason: "malformed" | "not_found" | "revoked" | "expired"
|
|
97
|
-
// | "exhausted" | "disabled"
|
|
74
|
+
// result.reason: "malformed" | "not_found" | "revoked" | "expired" | "exhausted" | "disabled"
|
|
98
75
|
return new Response("Unauthorized", { status: 401 });
|
|
99
76
|
}
|
|
100
|
-
|
|
101
|
-
const { keyId, ownerId, scopes, tags, env, type, metadata, remaining } = result;
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### List keys
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
const keys = await apiKeys.list(ctx, { ownerId: orgId });
|
|
108
|
-
const firstTwenty = await apiKeys.list(ctx, { ownerId: orgId, limit: 20 });
|
|
109
|
-
const prodKeys = await apiKeys.list(ctx, { ownerId: orgId, env: "live" });
|
|
110
|
-
const taggedKeys = await apiKeys.listByTag(ctx, { ownerId: orgId, tag: "sdk", limit: 20 });
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Update metadata (without rotation)
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
await apiKeys.update(ctx, {
|
|
117
|
-
keyId,
|
|
118
|
-
ownerId: orgId, // required — auth boundary
|
|
119
|
-
name: "Renamed Key",
|
|
120
|
-
scopes: ["read:users"],
|
|
121
|
-
tags: ["sdk", "v3"],
|
|
122
|
-
metadata: { plan: "pro" },
|
|
123
|
-
});
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Disable / Enable
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
await apiKeys.disable(ctx, { keyId, ownerId: orgId });
|
|
130
|
-
await apiKeys.enable(ctx, { keyId, ownerId: orgId });
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Revoke
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
await apiKeys.revoke(ctx, { keyId, ownerId: orgId });
|
|
137
|
-
|
|
138
|
-
// Bulk revoke by tag (catches active, rotating, and disabled keys)
|
|
139
|
-
await apiKeys.revokeByTag(ctx, { ownerId: orgId, tag: "compromised" });
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Rotate
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
const { newKey, newKeyId, oldKeyExpiresAt } = await apiKeys.rotate(ctx, {
|
|
146
|
-
keyId,
|
|
147
|
-
ownerId: orgId, // required — auth boundary
|
|
148
|
-
gracePeriodMs: 3600000, // 1 hour — both keys valid (min 60s, max 30d)
|
|
149
|
-
});
|
|
77
|
+
const { ownerId, scopes, tags, env, type, metadata, remaining } = result;
|
|
150
78
|
```
|
|
151
79
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
```ts
|
|
155
|
-
const usage = await apiKeys.getUsage(ctx, { keyId, ownerId: orgId });
|
|
156
|
-
// { total: 42000, remaining: 58000 }
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Key Format
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
{prefix}_{type}_{env}_{random8}_{secret64}
|
|
163
|
-
|
|
164
|
-
Examples:
|
|
165
|
-
myapp_secret_live_a1b2c3d4_<hex> ← production secret
|
|
166
|
-
myapp_pub_test_e5f6g7h8_<hex> ← test publishable
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Key Lifecycle
|
|
170
|
-
|
|
171
|
-
```
|
|
172
|
-
create() → ACTIVE ──→ DISABLED (reversible via enable())
|
|
173
|
-
──→ REVOKED (terminal)
|
|
174
|
-
──→ ROTATING (grace period → EXPIRED)
|
|
175
|
-
──→ EXPIRED (terminal, time-based)
|
|
176
|
-
──→ EXHAUSTED (terminal, remaining=0)
|
|
177
|
-
```
|
|
80
|
+
See [docs/API.md](docs/API.md) for the full method reference, key format, and lifecycle.
|
|
178
81
|
|
|
179
82
|
## API Reference
|
|
180
83
|
|
|
@@ -185,23 +88,25 @@ create() → ACTIVE ──→ DISABLED (reversible via enable())
|
|
|
185
88
|
| `revoke(ctx, { keyId, ownerId })` | mutation | Permanently revoke a key |
|
|
186
89
|
| `revokeByTag(ctx, { ownerId, tag })` | mutation | Bulk revoke by tag |
|
|
187
90
|
| `rotate(ctx, { keyId, ownerId, gracePeriodMs? })` | mutation | Rotate with grace period |
|
|
188
|
-
| `list(ctx, { ownerId, env?, status?, limit? })` | query | List keys (paginated, default 100) |
|
|
189
|
-
| `listByTag(ctx, { ownerId, tag, limit? })` | query | Filter by tag |
|
|
190
91
|
| `update(ctx, { keyId, ownerId, name?, ... })` | mutation | Update metadata in-place |
|
|
191
92
|
| `disable(ctx, { keyId, ownerId })` | mutation | Temporarily disable |
|
|
192
|
-
| `enable(ctx, { keyId, ownerId })` | mutation | Re-enable disabled key |
|
|
193
|
-
| `getUsage(ctx, { keyId, ownerId })` | query | Usage counter (O(1)) |
|
|
93
|
+
| `enable(ctx, { keyId, ownerId })` | mutation | Re-enable a disabled key |
|
|
194
94
|
| `configure(ctx, { ... })` | mutation | Runtime config (admin-only) |
|
|
95
|
+
| `list(ctx, { ownerId, env?, status?, limit? })` | query | List keys (paginated, default 100) |
|
|
96
|
+
| `listByTag(ctx, { ownerId, tag, limit? })` | query | Filter by tag |
|
|
97
|
+
| `getUsage(ctx, { keyId, ownerId })` | query | Usage counter (O(1)) |
|
|
195
98
|
|
|
196
|
-
|
|
99
|
+
Full reference: [docs/API.md](docs/API.md).
|
|
197
100
|
|
|
198
|
-
|
|
101
|
+
## Security
|
|
199
102
|
|
|
200
|
-
|
|
103
|
+
- Protects against **accidental cross-tenant bugs in honest host apps** — the `ownerId` check does NOT defend against a compromised host passing a forged `ownerId`.
|
|
104
|
+
- Derive `ownerId` from your own auth layer (e.g. `ctx.auth.getUserIdentity()`) before passing it in.
|
|
105
|
+
- Raw keys are never stored — only the SHA-256 hash; the raw value is returned once at creation.
|
|
201
106
|
|
|
202
|
-
|
|
107
|
+
See [docs/API.md](docs/API.md).
|
|
203
108
|
|
|
204
|
-
|
|
109
|
+
## Testing
|
|
205
110
|
|
|
206
111
|
```ts
|
|
207
112
|
import { convexTest } from "convex-test";
|
|
@@ -217,6 +122,14 @@ shardedCounterTest.register(t, "apiKeys/shardedCounter");
|
|
|
217
122
|
|
|
218
123
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, testing, and PR guidelines.
|
|
219
124
|
|
|
125
|
+
## Author
|
|
126
|
+
|
|
127
|
+
Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
128
|
+
|
|
129
|
+
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
|
|
130
|
+
|
|
131
|
+
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
132
|
+
|
|
220
133
|
## License
|
|
221
134
|
|
|
222
|
-
|
|
135
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,OAAO,EACP,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,OAAO,EACP,SAAS,GACV,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,CAAC;AACvF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,qBAAa,OAAO;IACX,SAAS,EAAE,YAAY,CAAC;IAC/B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CA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AAO,CAAC,CAAC;KACpC,GACA,OAAO,CAAC,IAAI,CAAC,CASf;IAEK,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1F;IAEK,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzF;IAEK,QAAQ,CACZ,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACvC,OAAO,CAAC,UAAU,CAAC,CAKrB;IAEK,SAAS,CACb,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7D,OAAO,CAAC,IAAI,CAAC,CAEf;CACF"}
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type * as mutations from "../mutations.js";
|
|
10
10
|
import type * as queries from "../queries.js";
|
|
11
|
+
import type * as validators from "../validators.js";
|
|
11
12
|
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
12
13
|
declare const fullApi: ApiFromModules<{
|
|
13
14
|
mutations: typeof mutations;
|
|
14
15
|
queries: typeof queries;
|
|
16
|
+
validators: typeof validators;
|
|
15
17
|
}>;
|
|
16
18
|
/**
|
|
17
19
|
* A utility for referencing Convex functions in your app's public API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,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,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;IAC1D,cAAc,EAAE,OAAO,qDAAqD,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;CAC9G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAWH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAIR,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,EAE1C,CAAC"}
|
|
@@ -101,6 +101,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
101
101
|
}, Name>;
|
|
102
102
|
list: FunctionReference<"query", "internal", {
|
|
103
103
|
env?: string;
|
|
104
|
+
limit?: number;
|
|
104
105
|
ownerId: string;
|
|
105
106
|
status?: "active" | "disabled" | "revoked" | "rotating" | "expired" | "exhausted";
|
|
106
107
|
}, Array<{
|
|
@@ -119,6 +120,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
119
120
|
type: "secret" | "publishable";
|
|
120
121
|
}>, Name>;
|
|
121
122
|
listByTag: FunctionReference<"query", "internal", {
|
|
123
|
+
limit?: number;
|
|
122
124
|
ownerId: string;
|
|
123
125
|
tag: string;
|
|
124
126
|
}, Array<{
|
|
@@ -1 +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,SAAS,EAAE,iBAAiB,CAC1B,UAAU,EACV,UAAU,EACV;YAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAAC,eAAe,CAAC,EAAE,MAAM,CAAA;SAAE,EACxD,IAAI,EACJ,IAAI,CACL,CAAC;QACF,MAAM,EAAE,iB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
|
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,SAAS,EAAE,iBAAiB,CAC1B,UAAU,EACV,UAAU,EACV;YAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAAC,eAAe,CAAC,EAAE,MAAM,CAAA;SAAE,EACxD,IAAI,EACJ,IAAI,CACL,CAAC;QACF,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YACE,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,GAAG,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;SACjC,EACD;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAC9B,IAAI,CACL,CAAC;QACF,OAAO,EAAE,iBAAiB,CACxB,UAAU,EACV,UAAU,EACV;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,EAClC,IAAI,EACJ,IAAI,CACL,CAAC;QACF,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YAAE,KAAK,EAAE,MA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AAU,GACV,SAAS,GACT,WAAW,CAAC;YAChB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACpB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;SAChC,CAAC,EACF,IAAI,CACL,CAAC;QACF,SAAS,EAAE,iBAAiB,CAC1B,OAAO,EACP,UAAU,EACV;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,EAChD,KAAK,CAAC;YACJ,SAAS,EAAE,MAAM,CAAC;YAClB,GAAG,EAAE,MAAM,CAAC;YACZ,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,KAAK,EAAE,MAAM,CAAC;YACd,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,YAAY,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,GAAG,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;YACb,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACtB,MAAM,EACF,QAAQ,GACR,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,WAAW,CAAC;YAChB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACpB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;SAChC,CAAC,EACF,IAAI,CACL,CAAC;KACH,CAAC;CACH,CAAC"}
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
|
|
10
10
|
import type { DataModel } from "./dataModel.js";
|
|
11
|
+
/**
|
|
12
|
+
* Typesafe environment variables.
|
|
13
|
+
*
|
|
14
|
+
* This includes platform-provided env vars and any variables declared in
|
|
15
|
+
* `convex.config.ts`.
|
|
16
|
+
*/
|
|
17
|
+
type Env = {
|
|
18
|
+
readonly CONVEX_CLOUD_URL: string;
|
|
19
|
+
readonly CONVEX_SITE_URL: string;
|
|
20
|
+
};
|
|
11
21
|
/**
|
|
12
22
|
* Define a query in this Convex app's public API.
|
|
13
23
|
*
|
|
@@ -75,6 +85,7 @@ export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
|
75
85
|
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
76
86
|
*/
|
|
77
87
|
export declare const httpAction: HttpActionBuilder;
|
|
88
|
+
export declare const env: Env;
|
|
78
89
|
/**
|
|
79
90
|
* A set of services for use within Convex query functions.
|
|
80
91
|
*
|
|
@@ -118,4 +129,5 @@ export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
|
118
129
|
* for the guarantees Convex provides your functions.
|
|
119
130
|
*/
|
|
120
131
|
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
132
|
+
export {};
|
|
121
133
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAgB,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CACxC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,SAAS,E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AAO,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAiB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,SAAS,EAAE,UAAU,CACzC,CAAC;AAExB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAqC,CAAC;AAC/D,eAAO,MAAM,GAAG,EAAE,GACJ,CAAC;AAEf;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -75,4 +75,6 @@ export const internalAction = internalActionGeneric;
|
|
|
75
75
|
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
76
76
|
*/
|
|
77
77
|
export const httpAction = httpActionGeneric;
|
|
78
|
+
export const env = globalThis
|
|
79
|
+
.process.env;
|
|
78
80
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAcvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAsC,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,oBAAoB,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyC,eAAe,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uBAAuB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuC,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,iBAAiB,CAAC;AAC/D,MAAM,CAAC,MAAM,GAAG,GAAS,UAAmD;KACzE,OAAO,CAAC,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,sDAA6B,CAAC;eAI9B,SAAS"}
|