@vllnt/convex-api-keys 0.1.0-canary.f67cc26

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 +190 -0
  2. package/README.md +227 -0
  3. package/dist/client/_generated/_ignore.d.ts +1 -0
  4. package/dist/client/_generated/_ignore.d.ts.map +1 -0
  5. package/dist/client/_generated/_ignore.js +3 -0
  6. package/dist/client/_generated/_ignore.js.map +1 -0
  7. package/dist/client/index.d.ts +67 -0
  8. package/dist/client/index.d.ts.map +1 -0
  9. package/dist/client/index.js +93 -0
  10. package/dist/client/index.js.map +1 -0
  11. package/dist/client/types.d.ts +68 -0
  12. package/dist/client/types.d.ts.map +1 -0
  13. package/dist/client/types.js +2 -0
  14. package/dist/client/types.js.map +1 -0
  15. package/dist/component/_generated/api.d.ts +41 -0
  16. package/dist/component/_generated/api.d.ts.map +1 -0
  17. package/dist/component/_generated/api.js +31 -0
  18. package/dist/component/_generated/api.js.map +1 -0
  19. package/dist/component/_generated/component.d.ts +146 -0
  20. package/dist/component/_generated/component.d.ts.map +1 -0
  21. package/dist/component/_generated/component.js +11 -0
  22. package/dist/component/_generated/component.js.map +1 -0
  23. package/dist/component/_generated/dataModel.d.ts +46 -0
  24. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  25. package/dist/component/_generated/dataModel.js +11 -0
  26. package/dist/component/_generated/dataModel.js.map +1 -0
  27. package/dist/component/_generated/server.d.ts +121 -0
  28. package/dist/component/_generated/server.d.ts.map +1 -0
  29. package/dist/component/_generated/server.js +78 -0
  30. package/dist/component/_generated/server.js.map +1 -0
  31. package/dist/component/convex.config.d.ts +3 -0
  32. package/dist/component/convex.config.d.ts.map +1 -0
  33. package/dist/component/convex.config.js +12 -0
  34. package/dist/component/convex.config.js.map +1 -0
  35. package/dist/component/mutations.d.ts +94 -0
  36. package/dist/component/mutations.d.ts.map +1 -0
  37. package/dist/component/mutations.js +456 -0
  38. package/dist/component/mutations.js.map +1 -0
  39. package/dist/component/queries.d.ts +49 -0
  40. package/dist/component/queries.d.ts.map +1 -0
  41. package/dist/component/queries.js +147 -0
  42. package/dist/component/queries.js.map +1 -0
  43. package/dist/component/schema.d.ts +70 -0
  44. package/dist/component/schema.d.ts.map +1 -0
  45. package/dist/component/schema.js +43 -0
  46. package/dist/component/schema.js.map +1 -0
  47. package/dist/component/validators.d.ts +3 -0
  48. package/dist/component/validators.d.ts.map +1 -0
  49. package/dist/component/validators.js +4 -0
  50. package/dist/component/validators.js.map +1 -0
  51. package/dist/log.d.ts +11 -0
  52. package/dist/log.d.ts.map +1 -0
  53. package/dist/log.js +15 -0
  54. package/dist/log.js.map +1 -0
  55. package/dist/shared.d.ts +26 -0
  56. package/dist/shared.d.ts.map +1 -0
  57. package/dist/shared.js +60 -0
  58. package/dist/shared.js.map +1 -0
  59. package/package.json +96 -0
  60. package/src/client/_generated/_ignore.ts +1 -0
  61. package/src/client/index.ts +185 -0
  62. package/src/client/types.ts +77 -0
  63. package/src/component/_generated/api.ts +57 -0
  64. package/src/component/_generated/component.ts +200 -0
  65. package/src/component/_generated/dataModel.ts +60 -0
  66. package/src/component/_generated/server.ts +156 -0
  67. package/src/component/convex.config.ts +14 -0
  68. package/src/component/mutations.ts +511 -0
  69. package/src/component/queries.ts +162 -0
  70. package/src/component/schema.ts +45 -0
  71. package/src/component/validators.ts +4 -0
  72. package/src/log.test.ts +52 -0
  73. package/src/log.ts +24 -0
  74. package/src/shared.test.ts +126 -0
  75. package/src/shared.ts +121 -0
  76. package/src/test.ts +15 -0
@@ -0,0 +1,162 @@
1
+ import { v } from "convex/values";
2
+ import { query } from "./_generated/server.js";
3
+ import { components } from "./_generated/api.js";
4
+ import { ShardedCounter } from "@convex-dev/sharded-counter";
5
+ import { KEY_STATUS, KEY_TYPE } from "../shared.js";
6
+ import { jsonValue } from "./validators.js";
7
+
8
+ const counter = new ShardedCounter(components.shardedCounter);
9
+
10
+ export const list = query({
11
+ args: {
12
+ ownerId: v.string(),
13
+ env: v.optional(v.string()),
14
+ status: v.optional(KEY_STATUS),
15
+ },
16
+ returns: v.array(
17
+ v.object({
18
+ keyId: v.id("apiKeys"),
19
+ name: v.string(),
20
+ lookupPrefix: v.string(),
21
+ type: KEY_TYPE,
22
+ env: v.string(),
23
+ scopes: v.array(v.string()),
24
+ tags: v.array(v.string()),
25
+ status: KEY_STATUS,
26
+ metadata: v.optional(jsonValue),
27
+ remaining: v.optional(v.number()),
28
+ expiresAt: v.optional(v.number()),
29
+ createdAt: v.number(),
30
+ lastUsedAt: v.optional(v.number()),
31
+ }),
32
+ ),
33
+ handler: async (ctx, { ownerId, env, status }) => {
34
+ let keysQuery;
35
+ if (env) {
36
+ keysQuery = ctx.db
37
+ .query("apiKeys")
38
+ .withIndex("by_owner_env", (q) => {
39
+ const q2 = q.eq("ownerId", ownerId).eq("env", env);
40
+ return status ? q2.eq("status", status) : q2;
41
+ });
42
+ } else if (status) {
43
+ keysQuery = ctx.db
44
+ .query("apiKeys")
45
+ .withIndex("by_owner_status", (q) =>
46
+ q.eq("ownerId", ownerId).eq("status", status),
47
+ );
48
+ } else {
49
+ keysQuery = ctx.db
50
+ .query("apiKeys")
51
+ .withIndex("by_owner_status", (q) => q.eq("ownerId", ownerId));
52
+ }
53
+
54
+ const keys = await keysQuery.collect();
55
+
56
+ return keys.map((k) => ({
57
+ keyId: k._id,
58
+ name: k.name,
59
+ lookupPrefix: k.lookupPrefix,
60
+ type: k.type,
61
+ env: k.env,
62
+ scopes: k.scopes,
63
+ tags: k.tags,
64
+ status: k.status,
65
+ metadata: k.metadata,
66
+ remaining: k.remaining,
67
+ expiresAt: k.expiresAt,
68
+ createdAt: k._creationTime,
69
+ lastUsedAt: k.lastUsedAt,
70
+ }));
71
+ },
72
+ });
73
+
74
+ export const listByTag = query({
75
+ args: {
76
+ ownerId: v.string(),
77
+ tag: v.string(),
78
+ },
79
+ returns: v.array(
80
+ v.object({
81
+ keyId: v.id("apiKeys"),
82
+ name: v.string(),
83
+ lookupPrefix: v.string(),
84
+ type: KEY_TYPE,
85
+ env: v.string(),
86
+ scopes: v.array(v.string()),
87
+ tags: v.array(v.string()),
88
+ status: KEY_STATUS,
89
+ metadata: v.optional(jsonValue),
90
+ remaining: v.optional(v.number()),
91
+ expiresAt: v.optional(v.number()),
92
+ createdAt: v.number(),
93
+ lastUsedAt: v.optional(v.number()),
94
+ }),
95
+ ),
96
+ handler: async (ctx, { ownerId, tag }) => {
97
+ const keys = await ctx.db
98
+ .query("apiKeys")
99
+ .withIndex("by_owner_status", (q) => q.eq("ownerId", ownerId))
100
+ .collect();
101
+
102
+ return keys
103
+ .filter((k) => k.tags.includes(tag))
104
+ .map((k) => ({
105
+ keyId: k._id,
106
+ name: k.name,
107
+ lookupPrefix: k.lookupPrefix,
108
+ type: k.type,
109
+ env: k.env,
110
+ scopes: k.scopes,
111
+ tags: k.tags,
112
+ status: k.status,
113
+ metadata: k.metadata,
114
+ remaining: k.remaining,
115
+ expiresAt: k.expiresAt,
116
+ createdAt: k._creationTime,
117
+ lastUsedAt: k.lastUsedAt,
118
+ }));
119
+ },
120
+ });
121
+
122
+ export const getUsage = query({
123
+ args: {
124
+ keyId: v.id("apiKeys"),
125
+ period: v.optional(
126
+ v.object({
127
+ start: v.number(),
128
+ end: v.number(),
129
+ }),
130
+ ),
131
+ },
132
+ returns: v.object({
133
+ total: v.number(),
134
+ remaining: v.optional(v.number()),
135
+ lastUsedAt: v.optional(v.number()),
136
+ }),
137
+ handler: async (ctx, { keyId, period }) => {
138
+ const key = await ctx.db.get(keyId);
139
+ if (!key) {
140
+ throw new Error("key not found");
141
+ }
142
+
143
+ let total: number;
144
+ if (period) {
145
+ const events = await ctx.db
146
+ .query("apiKeyEvents")
147
+ .withIndex("by_key", (q) =>
148
+ q.eq("keyId", keyId).gte("timestamp", period.start).lte("timestamp", period.end),
149
+ )
150
+ .collect();
151
+ total = events.filter((e) => e.eventType === "key.validated").length;
152
+ } else {
153
+ total = await counter.count(ctx, keyId);
154
+ }
155
+
156
+ return {
157
+ total,
158
+ remaining: key.remaining,
159
+ lastUsedAt: key.lastUsedAt,
160
+ };
161
+ },
162
+ });
@@ -0,0 +1,45 @@
1
+ import { defineSchema, defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ import { KEY_TYPE, KEY_STATUS } from "../shared.js";
4
+ import { jsonValue } from "./validators.js";
5
+
6
+ export default defineSchema({
7
+ apiKeys: defineTable({
8
+ hash: v.string(),
9
+ lookupPrefix: v.string(),
10
+ keyPrefix: v.string(),
11
+ type: KEY_TYPE,
12
+ env: v.string(),
13
+ ownerId: v.string(),
14
+ name: v.string(),
15
+ scopes: v.array(v.string()),
16
+ tags: v.array(v.string()),
17
+ status: KEY_STATUS,
18
+ metadata: v.optional(jsonValue),
19
+ remaining: v.optional(v.number()),
20
+ expiresAt: v.optional(v.number()),
21
+ gracePeriodEnd: v.optional(v.number()),
22
+ rotatedFromId: v.optional(v.id("apiKeys")),
23
+ lastUsedAt: v.optional(v.number()),
24
+ revokedAt: v.optional(v.number()),
25
+ })
26
+ .index("by_lookup_prefix", ["lookupPrefix"])
27
+ .index("by_owner_status", ["ownerId", "status"])
28
+ .index("by_owner_env", ["ownerId", "env", "status"]),
29
+
30
+ apiKeyEvents: defineTable({
31
+ keyId: v.id("apiKeys"),
32
+ ownerId: v.string(),
33
+ eventType: v.string(),
34
+ reason: v.optional(v.string()),
35
+ metadata: v.optional(jsonValue),
36
+ timestamp: v.number(),
37
+ })
38
+ .index("by_key", ["keyId", "timestamp"])
39
+ .index("by_owner", ["ownerId", "timestamp"]),
40
+
41
+ config: defineTable({
42
+ cleanupIntervalMs: v.optional(v.number()),
43
+ defaultExpiryMs: v.optional(v.number()),
44
+ }),
45
+ });
@@ -0,0 +1,4 @@
1
+ import { v } from "convex/values";
2
+
3
+ /** Arbitrary JSON metadata attached to keys, events, or config. */
4
+ export const jsonValue = v.any();
@@ -0,0 +1,52 @@
1
+ import { expect, test, describe, vi } from "vitest";
2
+ import { createLogger } from "./log.js";
3
+
4
+ describe("createLogger", () => {
5
+ test("info logs with scope prefix", () => {
6
+ const spy = vi.spyOn(console, "log").mockImplementation(() => {});
7
+ const log = createLogger("test");
8
+ log.info("hello", { key: "value" });
9
+ expect(spy).toHaveBeenCalledWith("[test]", "hello", { key: "value" });
10
+ spy.mockRestore();
11
+ });
12
+
13
+ test("info logs without data", () => {
14
+ const spy = vi.spyOn(console, "log").mockImplementation(() => {});
15
+ const log = createLogger("test");
16
+ log.info("hello");
17
+ expect(spy).toHaveBeenCalledWith("[test]", "hello", "");
18
+ spy.mockRestore();
19
+ });
20
+
21
+ test("warn logs with scope prefix", () => {
22
+ const spy = vi.spyOn(console, "warn").mockImplementation(() => {});
23
+ const log = createLogger("test");
24
+ log.warn("warning", { detail: 1 });
25
+ expect(spy).toHaveBeenCalledWith("[test]", "warning", { detail: 1 });
26
+ spy.mockRestore();
27
+ });
28
+
29
+ test("warn logs without data", () => {
30
+ const spy = vi.spyOn(console, "warn").mockImplementation(() => {});
31
+ const log = createLogger("test");
32
+ log.warn("warning");
33
+ expect(spy).toHaveBeenCalledWith("[test]", "warning", "");
34
+ spy.mockRestore();
35
+ });
36
+
37
+ test("error logs with scope prefix", () => {
38
+ const spy = vi.spyOn(console, "error").mockImplementation(() => {});
39
+ const log = createLogger("test");
40
+ log.error("oops", { code: 500 });
41
+ expect(spy).toHaveBeenCalledWith("[test]", "oops", { code: 500 });
42
+ spy.mockRestore();
43
+ });
44
+
45
+ test("error logs without data", () => {
46
+ const spy = vi.spyOn(console, "error").mockImplementation(() => {});
47
+ const log = createLogger("test");
48
+ log.error("oops");
49
+ expect(spy).toHaveBeenCalledWith("[test]", "oops", "");
50
+ spy.mockRestore();
51
+ });
52
+ });
package/src/log.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Minimal structured logger. Convex-safe (no process.env, no Node APIs).
3
+ * Replace with your own logger by wrapping this module.
4
+ */
5
+ export interface Logger {
6
+ info(message: string, data?: Record<string, unknown>): void;
7
+ warn(message: string, data?: Record<string, unknown>): void;
8
+ error(message: string, data?: Record<string, unknown>): void;
9
+ }
10
+
11
+ export function createLogger(scope: string): Logger {
12
+ const prefix = `[${scope}]`;
13
+ return {
14
+ info(message, data) {
15
+ console.log(prefix, message, data ?? "");
16
+ },
17
+ warn(message, data) {
18
+ console.warn(prefix, message, data ?? "");
19
+ },
20
+ error(message, data) {
21
+ console.error(prefix, message, data ?? "");
22
+ },
23
+ };
24
+ }
@@ -0,0 +1,126 @@
1
+ import { expect, test, describe } from "vitest";
2
+ import {
3
+ parseKeyString,
4
+ timingSafeEqual,
5
+ sha256Hex,
6
+ validateTag,
7
+ validateTags,
8
+ KEY_PREFIX_SEPARATOR,
9
+ } from "./shared.js";
10
+
11
+ describe("parseKeyString", () => {
12
+ test("parses a valid secret key", () => {
13
+ const result = parseKeyString("pre_secret_live_12345678_" + "a".repeat(64));
14
+ expect(result.valid).toBe(true);
15
+ if (result.valid) {
16
+ expect(result.prefix).toBe("pre");
17
+ expect(result.type).toBe("secret");
18
+ expect(result.env).toBe("live");
19
+ expect(result.lookupPrefix).toBe("12345678");
20
+ expect(result.secret).toBe("a".repeat(64));
21
+ }
22
+ });
23
+
24
+ test("parses a valid pub key", () => {
25
+ const result = parseKeyString("pre_pub_test_12345678_" + "b".repeat(64));
26
+ expect(result.valid).toBe(true);
27
+ if (result.valid) {
28
+ expect(result.type).toBe("pub");
29
+ }
30
+ });
31
+
32
+ test("rejects wrong segment count", () => {
33
+ expect(parseKeyString("too_few_parts").valid).toBe(false);
34
+ expect(parseKeyString("a_b_c_d_e_f").valid).toBe(false);
35
+ });
36
+
37
+ test("rejects empty segment", () => {
38
+ const result = parseKeyString("pre__live_12345678_" + "a".repeat(64));
39
+ expect(result.valid).toBe(false);
40
+ });
41
+
42
+ test("rejects bad type", () => {
43
+ const result = parseKeyString("pre_badtype_live_12345678_" + "a".repeat(64));
44
+ expect(result.valid).toBe(false);
45
+ });
46
+
47
+ test("rejects wrong lookupPrefix length", () => {
48
+ const result = parseKeyString("pre_secret_live_short_" + "a".repeat(64));
49
+ expect(result.valid).toBe(false);
50
+ });
51
+
52
+ test("rejects wrong secret length", () => {
53
+ const result = parseKeyString("pre_secret_live_12345678_tooshort");
54
+ expect(result.valid).toBe(false);
55
+ });
56
+ });
57
+
58
+ describe("timingSafeEqual", () => {
59
+ test("returns true for equal strings", () => {
60
+ expect(timingSafeEqual("abc", "abc")).toBe(true);
61
+ });
62
+
63
+ test("returns false for different strings same length", () => {
64
+ expect(timingSafeEqual("abc", "abd")).toBe(false);
65
+ });
66
+
67
+ test("returns false for different length strings", () => {
68
+ expect(timingSafeEqual("abc", "abcd")).toBe(false);
69
+ });
70
+
71
+ test("returns true for empty strings", () => {
72
+ expect(timingSafeEqual("", "")).toBe(true);
73
+ });
74
+ });
75
+
76
+ describe("sha256Hex", () => {
77
+ test("produces consistent 64-char hex output", async () => {
78
+ const hash = await sha256Hex("hello");
79
+ expect(hash).toHaveLength(64);
80
+ expect(/^[0-9a-f]+$/.test(hash)).toBe(true);
81
+
82
+ // Same input = same output
83
+ const hash2 = await sha256Hex("hello");
84
+ expect(hash2).toBe(hash);
85
+ });
86
+
87
+ test("different inputs produce different hashes", async () => {
88
+ const h1 = await sha256Hex("hello");
89
+ const h2 = await sha256Hex("world");
90
+ expect(h1).not.toBe(h2);
91
+ });
92
+ });
93
+
94
+ describe("validateTag", () => {
95
+ test("accepts valid tags", () => {
96
+ expect(() => validateTag("valid")).not.toThrow();
97
+ expect(() => validateTag("valid-tag")).not.toThrow();
98
+ expect(() => validateTag("v2")).not.toThrow();
99
+ expect(() => validateTag("A")).not.toThrow();
100
+ });
101
+
102
+ test("rejects tags starting with hyphen", () => {
103
+ expect(() => validateTag("-invalid")).toThrow("Invalid tag");
104
+ });
105
+
106
+ test("rejects tags with special chars", () => {
107
+ expect(() => validateTag("no spaces")).toThrow("Invalid tag");
108
+ expect(() => validateTag("no.dots")).toThrow("Invalid tag");
109
+ });
110
+ });
111
+
112
+ describe("validateTags", () => {
113
+ test("validates all tags in array", () => {
114
+ expect(() => validateTags(["valid", "also-valid"])).not.toThrow();
115
+ });
116
+
117
+ test("throws on first invalid tag", () => {
118
+ expect(() => validateTags(["valid", "-bad"])).toThrow("Invalid tag");
119
+ });
120
+ });
121
+
122
+ describe("KEY_PREFIX_SEPARATOR", () => {
123
+ test("is underscore", () => {
124
+ expect(KEY_PREFIX_SEPARATOR).toBe("_");
125
+ });
126
+ });
package/src/shared.ts ADDED
@@ -0,0 +1,121 @@
1
+ import { v } from "convex/values";
2
+
3
+ export const KEY_TYPE = v.union(v.literal("secret"), v.literal("publishable"));
4
+ export type KeyType = "secret" | "publishable";
5
+
6
+ export const KEY_STATUS = v.union(
7
+ v.literal("active"),
8
+ v.literal("disabled"),
9
+ v.literal("revoked"),
10
+ v.literal("rotating"),
11
+ v.literal("expired"),
12
+ v.literal("exhausted"),
13
+ );
14
+ export type KeyStatus =
15
+ | "active"
16
+ | "disabled"
17
+ | "revoked"
18
+ | "rotating"
19
+ | "expired"
20
+ | "exhausted";
21
+
22
+ export const TERMINAL_STATUSES: ReadonlySet<KeyStatus> = new Set([
23
+ "revoked",
24
+ "expired",
25
+ "exhausted",
26
+ ]);
27
+
28
+ export const TAG_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9-]*$/;
29
+
30
+ export const EVENT_TYPE = v.union(
31
+ v.literal("key.created"),
32
+ v.literal("key.validated"),
33
+ v.literal("key.validate_failed"),
34
+ v.literal("key.revoked"),
35
+ v.literal("key.rotated"),
36
+ v.literal("key.expired"),
37
+ v.literal("key.exhausted"),
38
+ v.literal("key.disabled"),
39
+ v.literal("key.enabled"),
40
+ v.literal("key.updated"),
41
+ v.literal("key.rate_limited"),
42
+ );
43
+ export type EventType =
44
+ | "key.created"
45
+ | "key.validated"
46
+ | "key.validate_failed"
47
+ | "key.revoked"
48
+ | "key.rotated"
49
+ | "key.expired"
50
+ | "key.exhausted"
51
+ | "key.disabled"
52
+ | "key.enabled"
53
+ | "key.updated"
54
+ | "key.rate_limited";
55
+
56
+ export function validateTag(tag: string): void {
57
+ if (!TAG_PATTERN.test(tag)) {
58
+ throw new Error(
59
+ `Invalid tag "${tag}": must be alphanumeric with hyphens, starting with alphanumeric`,
60
+ );
61
+ }
62
+ }
63
+
64
+ export function validateTags(tags: string[]): void {
65
+ for (const tag of tags) {
66
+ validateTag(tag);
67
+ }
68
+ }
69
+
70
+ export const KEY_PREFIX_SEPARATOR = "_";
71
+
72
+ export function parseKeyString(key: string): {
73
+ valid: false;
74
+ reason: "malformed";
75
+ } | {
76
+ valid: true;
77
+ prefix: string;
78
+ type: string;
79
+ env: string;
80
+ lookupPrefix: string;
81
+ secret: string;
82
+ } {
83
+ const parts = key.split(KEY_PREFIX_SEPARATOR);
84
+ if (parts.length !== 5) {
85
+ return { valid: false, reason: "malformed" };
86
+ }
87
+ const [prefix, type, env, lookupPrefix, secret] = parts;
88
+ if (!prefix || !type || !env || !lookupPrefix || !secret) {
89
+ return { valid: false, reason: "malformed" };
90
+ }
91
+ if (type !== "secret" && type !== "pub") {
92
+ return { valid: false, reason: "malformed" };
93
+ }
94
+ if (lookupPrefix.length !== 8) {
95
+ return { valid: false, reason: "malformed" };
96
+ }
97
+ if (secret.length !== 64) {
98
+ return { valid: false, reason: "malformed" };
99
+ }
100
+ return { valid: true, prefix, type, env, lookupPrefix, secret };
101
+ }
102
+
103
+ export function timingSafeEqual(a: string, b: string): boolean {
104
+ if (a.length !== b.length) {
105
+ return false;
106
+ }
107
+ let result = 0;
108
+ for (let i = 0; i < a.length; i++) {
109
+ result |= a.charCodeAt(i) ^ b.charCodeAt(i);
110
+ }
111
+ return result === 0;
112
+ }
113
+
114
+ /** Compute SHA-256 hash of input, returned as lowercase hex string. */
115
+ export async function sha256Hex(input: string): Promise<string> {
116
+ const encoder = new TextEncoder();
117
+ const data = encoder.encode(input);
118
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
119
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
120
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
121
+ }
package/src/test.ts ADDED
@@ -0,0 +1,15 @@
1
+ /// <reference types="vite/client" />
2
+ import type { TestConvex } from "convex-test";
3
+ import type { GenericSchema, SchemaDefinition } from "convex/server";
4
+ import schema from "./component/schema.js";
5
+
6
+ const modules = import.meta.glob("./component/**/*.ts");
7
+
8
+ export function register(
9
+ t: TestConvex<SchemaDefinition<GenericSchema, boolean>>,
10
+ name: string = "apiKeys",
11
+ ): void {
12
+ t.registerComponent(name, schema, modules);
13
+ }
14
+
15
+ export default { register, schema, modules };