@codefox-inc/oauth-provider 0.2.0
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 +201 -0
- package/README.md +572 -0
- package/dist/client/_generated/_ignore.d.ts +1 -0
- package/dist/client/_generated/_ignore.d.ts.map +1 -0
- package/dist/client/_generated/_ignore.js +3 -0
- package/dist/client/_generated/_ignore.js.map +1 -0
- package/dist/client/auth-config.d.ts +85 -0
- package/dist/client/auth-config.d.ts.map +1 -0
- package/dist/client/auth-config.js +81 -0
- package/dist/client/auth-config.js.map +1 -0
- package/dist/client/auth-helper.d.ts +81 -0
- package/dist/client/auth-helper.d.ts.map +1 -0
- package/dist/client/auth-helper.js +97 -0
- package/dist/client/auth-helper.js.map +1 -0
- package/dist/client/index.d.ts +189 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +230 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/routes.d.ts +94 -0
- package/dist/client/routes.d.ts.map +1 -0
- package/dist/client/routes.js +113 -0
- package/dist/client/routes.js.map +1 -0
- package/dist/component/_generated/api.d.ts +44 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +123 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/clientManagement.d.ts +39 -0
- package/dist/component/clientManagement.d.ts.map +1 -0
- package/dist/component/clientManagement.js +169 -0
- package/dist/component/clientManagement.js.map +1 -0
- package/dist/component/constants.d.ts +31 -0
- package/dist/component/constants.d.ts.map +1 -0
- package/dist/component/constants.js +36 -0
- package/dist/component/constants.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +3 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/handlers.d.ts +143 -0
- package/dist/component/handlers.d.ts.map +1 -0
- package/dist/component/handlers.js +624 -0
- package/dist/component/handlers.js.map +1 -0
- package/dist/component/mutations.d.ts +111 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +459 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +127 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +145 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +116 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +77 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/token_security.d.ts +53 -0
- package/dist/component/token_security.d.ts.map +1 -0
- package/dist/component/token_security.js +91 -0
- package/dist/component/token_security.js.map +1 -0
- package/dist/lib/convex-types.d.ts +21 -0
- package/dist/lib/convex-types.d.ts.map +1 -0
- package/dist/lib/convex-types.js +2 -0
- package/dist/lib/convex-types.js.map +1 -0
- package/dist/lib/oauth.d.ts +123 -0
- package/dist/lib/oauth.d.ts.map +1 -0
- package/dist/lib/oauth.js +295 -0
- package/dist/lib/oauth.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +6 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +121 -0
- package/src/client/__tests__/auth-config.test.ts +244 -0
- package/src/client/__tests__/auth-helper.test.ts +273 -0
- package/src/client/__tests__/oauth-provider.test.ts +418 -0
- package/src/client/__tests__/routes.test.ts +428 -0
- package/src/client/_generated/_ignore.ts +1 -0
- package/src/client/auth-config.ts +157 -0
- package/src/client/auth-helper.ts +201 -0
- package/src/client/index.ts +326 -0
- package/src/client/routes.ts +251 -0
- package/src/component/__tests__/oauth.test.ts +3310 -0
- package/src/component/__tests__/rfc-compliance.test.ts +788 -0
- package/src/component/__tests__/token-security.test.ts +133 -0
- package/src/component/_generated/api.ts +60 -0
- package/src/component/_generated/component.ts +201 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/clientManagement.ts +189 -0
- package/src/component/constants.ts +40 -0
- package/src/component/convex.config.ts +3 -0
- package/src/component/handlers.ts +964 -0
- package/src/component/mutations.ts +531 -0
- package/src/component/queries.ts +165 -0
- package/src/component/schema.ts +92 -0
- package/src/component/token_security.ts +102 -0
- package/src/lib/__tests__/oauth-helpers.test.ts +143 -0
- package/src/lib/__tests__/oauth-jwt.test.ts +405 -0
- package/src/lib/convex-types.ts +37 -0
- package/src/lib/oauth.ts +412 -0
- package/src/react/index.ts +7 -0
- package/src/test.ts +21 -0
|
@@ -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,gBAAgB,EAAE;QAChB,YAAY,EAAE,iBAAiB,CAC7B,UAAU,EACV,UAAU,EACV;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,EACpB,GAAG,EACH,IAAI,CACL,CAAC;QACF,cAAc,EAAE,iBAAiB,CAC/B,UAAU,EACV,UAAU,EACV;YACE,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,UAAU,CAAC,EAAE,OAAO,CAAC;YACrB,OAAO,CAAC,EAAE,MA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OAAO,EAAE;QACP,gBAAgB,EAAE,iBAAiB,CACjC,OAAO,EACP,UAAU,EACV;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EACpC,GAAG,EACH,IAAI,CACL,CAAC;QACF,SAAS,EAAE,iBAAiB,CAC1B,OAAO,EACP,UAAU,EACV;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,EACpB,GAAG,EACH,IAAI,CACL,CAAC;QACF,eAAe,EAAE,iBAAiB,CAChC,OAAO,EACP,UAAU,EACV;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE,EACxB,GAAG,EACH,IAAI,CACL,CAAC;QACF,eAAe,EAAE,iBAAiB,CAChC,OAAO,EACP,UAAU,EACV;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,EAClB,GAAG,EACH,IAAI,CACL,CAAC;QACF,mBAAmB,EAAE,iBAAiB,CACpC,OAAO,EACP,UAAU,EACV;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,EAClB,GAAG,EACH,IAAI,CACL,CAAC;QACF,gBAAgB,EAAE,iBAAiB,CACjC,OAAO,EACP,UAAU,EACV;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EACpC,GAAG,EACH,IAAI,CACL,CAAC;QACF,WAAW,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACnE,sBAAsB,EAAE,iBAAiB,CACvC,OAAO,EACP,UAAU,EACV;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,EAClB,GAAG,EACH,IAAI,CACL,CAAC;KACH,CAAC;CACH,CAAC"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/dataModel.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,SAAS,SAAS,UAAU,IAAI,cAAc,CAC5D,SAAS,EACT,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,EAAE,CAAC,SAAS,SAAS,UAAU,GAAG,gBAAgB,IAC5D,SAAS,CAAC,SAAS,CAAC,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,6BAA6B,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.js","sourceRoot":"","sources":["../../../src/component/_generated/dataModel.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AASH,OAAO,MAAM,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
|
|
10
|
+
import type { DataModel } from "./dataModel.js";
|
|
11
|
+
/**
|
|
12
|
+
* Define a query in this Convex app's public API.
|
|
13
|
+
*
|
|
14
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
15
|
+
*
|
|
16
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
17
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
18
|
+
*/
|
|
19
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
20
|
+
/**
|
|
21
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
22
|
+
*
|
|
23
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
24
|
+
*
|
|
25
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
26
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
27
|
+
*/
|
|
28
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
29
|
+
/**
|
|
30
|
+
* Define a mutation in this Convex app's public API.
|
|
31
|
+
*
|
|
32
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
33
|
+
*
|
|
34
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
35
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
36
|
+
*/
|
|
37
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
38
|
+
/**
|
|
39
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
40
|
+
*
|
|
41
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
42
|
+
*
|
|
43
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
44
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
45
|
+
*/
|
|
46
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
47
|
+
/**
|
|
48
|
+
* Define an action in this Convex app's public API.
|
|
49
|
+
*
|
|
50
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
51
|
+
* code and code with side-effects, like calling third-party services.
|
|
52
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
53
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
54
|
+
*
|
|
55
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
56
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
57
|
+
*/
|
|
58
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
59
|
+
/**
|
|
60
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
61
|
+
*
|
|
62
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
63
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
64
|
+
*/
|
|
65
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
66
|
+
/**
|
|
67
|
+
* Define an HTTP action.
|
|
68
|
+
*
|
|
69
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
70
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
71
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
72
|
+
*
|
|
73
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
74
|
+
* and a Fetch API `Request` object as its second.
|
|
75
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
76
|
+
*/
|
|
77
|
+
export declare const httpAction: HttpActionBuilder;
|
|
78
|
+
/**
|
|
79
|
+
* A set of services for use within Convex query functions.
|
|
80
|
+
*
|
|
81
|
+
* The query context is passed as the first argument to any Convex query
|
|
82
|
+
* function run on the server.
|
|
83
|
+
*
|
|
84
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
85
|
+
*/
|
|
86
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
87
|
+
/**
|
|
88
|
+
* A set of services for use within Convex mutation functions.
|
|
89
|
+
*
|
|
90
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
91
|
+
* function run on the server.
|
|
92
|
+
*
|
|
93
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
94
|
+
*/
|
|
95
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
96
|
+
/**
|
|
97
|
+
* A set of services for use within Convex action functions.
|
|
98
|
+
*
|
|
99
|
+
* The action context is passed as the first argument to any Convex action
|
|
100
|
+
* function run on the server.
|
|
101
|
+
*/
|
|
102
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
103
|
+
/**
|
|
104
|
+
* An interface to read from the database within Convex query functions.
|
|
105
|
+
*
|
|
106
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
107
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
108
|
+
* building a query.
|
|
109
|
+
*/
|
|
110
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
111
|
+
/**
|
|
112
|
+
* An interface to read from and write to the database within Convex mutation
|
|
113
|
+
* functions.
|
|
114
|
+
*
|
|
115
|
+
* Convex guarantees that all writes within a single mutation are
|
|
116
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
117
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
118
|
+
* for the guarantees Convex provides your functions.
|
|
119
|
+
*/
|
|
120
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
121
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.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AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, } from "convex/server";
|
|
11
|
+
/**
|
|
12
|
+
* Define a query in this Convex app's public API.
|
|
13
|
+
*
|
|
14
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
15
|
+
*
|
|
16
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
17
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
18
|
+
*/
|
|
19
|
+
export const query = queryGeneric;
|
|
20
|
+
/**
|
|
21
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
22
|
+
*
|
|
23
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
24
|
+
*
|
|
25
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
26
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
27
|
+
*/
|
|
28
|
+
export const internalQuery = internalQueryGeneric;
|
|
29
|
+
/**
|
|
30
|
+
* Define a mutation in this Convex app's public API.
|
|
31
|
+
*
|
|
32
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
33
|
+
*
|
|
34
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
35
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
36
|
+
*/
|
|
37
|
+
export const mutation = mutationGeneric;
|
|
38
|
+
/**
|
|
39
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
40
|
+
*
|
|
41
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
42
|
+
*
|
|
43
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
44
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
45
|
+
*/
|
|
46
|
+
export const internalMutation = internalMutationGeneric;
|
|
47
|
+
/**
|
|
48
|
+
* Define an action in this Convex app's public API.
|
|
49
|
+
*
|
|
50
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
51
|
+
* code and code with side-effects, like calling third-party services.
|
|
52
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
53
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
54
|
+
*
|
|
55
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
56
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
57
|
+
*/
|
|
58
|
+
export const action = actionGeneric;
|
|
59
|
+
/**
|
|
60
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
61
|
+
*
|
|
62
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
63
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
64
|
+
*/
|
|
65
|
+
export const internalAction = internalActionGeneric;
|
|
66
|
+
/**
|
|
67
|
+
* Define an HTTP action.
|
|
68
|
+
*
|
|
69
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
70
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
71
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
72
|
+
*
|
|
73
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
74
|
+
* and a Fetch API `Request` object as its second.
|
|
75
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
76
|
+
*/
|
|
77
|
+
export const httpAction = httpActionGeneric;
|
|
78
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +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;AAGvB;;;;;;;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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register OAuth Client
|
|
3
|
+
*/
|
|
4
|
+
export declare const registerClient: import("convex/server").RegisteredMutation<"public", {
|
|
5
|
+
description?: string | undefined;
|
|
6
|
+
logoUrl?: string | undefined;
|
|
7
|
+
website?: string | undefined;
|
|
8
|
+
tosUrl?: string | undefined;
|
|
9
|
+
policyUrl?: string | undefined;
|
|
10
|
+
isInternal?: boolean | undefined;
|
|
11
|
+
name: string;
|
|
12
|
+
type: "public" | "confidential";
|
|
13
|
+
redirectUris: string[];
|
|
14
|
+
scopes: string[];
|
|
15
|
+
}, Promise<{
|
|
16
|
+
clientId: `${string}-${string}-${string}-${string}-${string}`;
|
|
17
|
+
clientSecret: string;
|
|
18
|
+
clientIdIssuedAt: number;
|
|
19
|
+
} | {
|
|
20
|
+
clientId: `${string}-${string}-${string}-${string}-${string}`;
|
|
21
|
+
clientIdIssuedAt: number;
|
|
22
|
+
clientSecret?: undefined;
|
|
23
|
+
}>>;
|
|
24
|
+
/**
|
|
25
|
+
* Verify Client Secret
|
|
26
|
+
*/
|
|
27
|
+
export declare const verifyClientSecret: import("convex/server").RegisteredMutation<"public", {
|
|
28
|
+
clientId: string;
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
}, Promise<boolean>>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete OAuth Client
|
|
33
|
+
*/
|
|
34
|
+
export declare const deleteClient: import("convex/server").RegisteredMutation<"public", {
|
|
35
|
+
clientId: string;
|
|
36
|
+
}, Promise<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
}>>;
|
|
39
|
+
//# sourceMappingURL=clientManagement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientManagement.d.ts","sourceRoot":"","sources":["../../src/component/clientManagement.ts"],"names":[],"mappings":"AAmCA;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;GA+EzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;oBAsB7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;GAuCvB,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { mutation } from "./_generated/server";
|
|
3
|
+
import * as bcrypt from "bcryptjs";
|
|
4
|
+
import { generateClientSecret } from "../lib/oauth.js";
|
|
5
|
+
import { OAUTH_CONSTANTS } from "./constants";
|
|
6
|
+
/**
|
|
7
|
+
* OAuth Client Management Mutations
|
|
8
|
+
*
|
|
9
|
+
* Handles client registration, verification, and deletion.
|
|
10
|
+
* Uses bcryptjs (pure JavaScript implementation) for secure client secret hashing.
|
|
11
|
+
*/
|
|
12
|
+
function isValidRedirectUri(uri) {
|
|
13
|
+
let parsed;
|
|
14
|
+
try {
|
|
15
|
+
parsed = new URL(uri);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (parsed.hash)
|
|
21
|
+
return false;
|
|
22
|
+
const host = parsed.hostname.toLowerCase();
|
|
23
|
+
const isLoopback = host === "localhost" ||
|
|
24
|
+
host === "127.0.0.1" ||
|
|
25
|
+
host === "::1";
|
|
26
|
+
if (parsed.protocol === "https:")
|
|
27
|
+
return true;
|
|
28
|
+
if (parsed.protocol === "http:" && isLoopback)
|
|
29
|
+
return true;
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Register OAuth Client
|
|
34
|
+
*/
|
|
35
|
+
export const registerClient = mutation({
|
|
36
|
+
args: {
|
|
37
|
+
name: v.string(),
|
|
38
|
+
redirectUris: v.array(v.string()),
|
|
39
|
+
scopes: v.array(v.string()),
|
|
40
|
+
type: v.union(v.literal("confidential"), v.literal("public")),
|
|
41
|
+
// metadata
|
|
42
|
+
description: v.optional(v.string()),
|
|
43
|
+
website: v.optional(v.string()),
|
|
44
|
+
logoUrl: v.optional(v.string()),
|
|
45
|
+
tosUrl: v.optional(v.string()),
|
|
46
|
+
policyUrl: v.optional(v.string()),
|
|
47
|
+
isInternal: v.optional(v.boolean()),
|
|
48
|
+
},
|
|
49
|
+
handler: async (ctx, args) => {
|
|
50
|
+
if (args.redirectUris.length === 0) {
|
|
51
|
+
throw new Error("redirect_uris required");
|
|
52
|
+
}
|
|
53
|
+
const invalidRedirect = args.redirectUris.find((uri) => !isValidRedirectUri(uri));
|
|
54
|
+
if (invalidRedirect) {
|
|
55
|
+
throw new Error(`Invalid redirect_uri: ${invalidRedirect}`);
|
|
56
|
+
}
|
|
57
|
+
const clientId = crypto.randomUUID();
|
|
58
|
+
// Generate secret only if confidential
|
|
59
|
+
if (args.type === "confidential") {
|
|
60
|
+
// Generate plain secret using CSPrng
|
|
61
|
+
const clientSecret = generateClientSecret(OAUTH_CONSTANTS.CLIENT_SECRET_LENGTH);
|
|
62
|
+
// Hash the secret
|
|
63
|
+
const clientSecretHash = await bcrypt.hash(clientSecret, 10);
|
|
64
|
+
// Store the HASH, return the PLAIN secret once
|
|
65
|
+
await ctx.db.insert("oauthClients", {
|
|
66
|
+
name: args.name,
|
|
67
|
+
clientId,
|
|
68
|
+
clientSecret: clientSecretHash, // Store Hash!
|
|
69
|
+
type: args.type,
|
|
70
|
+
redirectUris: args.redirectUris,
|
|
71
|
+
allowedScopes: args.scopes,
|
|
72
|
+
createdAt: Date.now(),
|
|
73
|
+
description: args.description,
|
|
74
|
+
website: args.website,
|
|
75
|
+
logoUrl: args.logoUrl,
|
|
76
|
+
tosUrl: args.tosUrl,
|
|
77
|
+
policyUrl: args.policyUrl,
|
|
78
|
+
isInternal: args.isInternal,
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
clientId,
|
|
82
|
+
clientSecret, // Return Plain!
|
|
83
|
+
clientIdIssuedAt: Math.floor(Date.now() / 1000),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Public client (no secret)
|
|
87
|
+
await ctx.db.insert("oauthClients", {
|
|
88
|
+
name: args.name,
|
|
89
|
+
clientId,
|
|
90
|
+
clientSecret: undefined,
|
|
91
|
+
type: args.type,
|
|
92
|
+
redirectUris: args.redirectUris,
|
|
93
|
+
allowedScopes: args.scopes,
|
|
94
|
+
createdAt: Date.now(),
|
|
95
|
+
description: args.description,
|
|
96
|
+
website: args.website,
|
|
97
|
+
logoUrl: args.logoUrl,
|
|
98
|
+
tosUrl: args.tosUrl,
|
|
99
|
+
policyUrl: args.policyUrl,
|
|
100
|
+
isInternal: args.isInternal,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
clientId,
|
|
104
|
+
clientIdIssuedAt: Math.floor(Date.now() / 1000),
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* Verify Client Secret
|
|
110
|
+
*/
|
|
111
|
+
export const verifyClientSecret = mutation({
|
|
112
|
+
args: {
|
|
113
|
+
clientId: v.string(),
|
|
114
|
+
clientSecret: v.string(),
|
|
115
|
+
},
|
|
116
|
+
handler: async (ctx, args) => {
|
|
117
|
+
const client = await ctx.db
|
|
118
|
+
.query("oauthClients")
|
|
119
|
+
.withIndex("by_client_id", (q) => q.eq("clientId", args.clientId))
|
|
120
|
+
.unique();
|
|
121
|
+
if (!client || !client.clientSecret) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
return await bcrypt.compare(args.clientSecret, client.clientSecret);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
console.error("Client Secret Verification Failed:", e);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Delete OAuth Client
|
|
135
|
+
*/
|
|
136
|
+
export const deleteClient = mutation({
|
|
137
|
+
args: {
|
|
138
|
+
clientId: v.string(),
|
|
139
|
+
},
|
|
140
|
+
handler: async (ctx, args) => {
|
|
141
|
+
const client = await ctx.db
|
|
142
|
+
.query("oauthClients")
|
|
143
|
+
.withIndex("by_client_id", (q) => q.eq("clientId", args.clientId))
|
|
144
|
+
.unique();
|
|
145
|
+
if (!client) {
|
|
146
|
+
throw new Error("Client not found");
|
|
147
|
+
}
|
|
148
|
+
// Delete all tokens for this client
|
|
149
|
+
const tokens = await ctx.db
|
|
150
|
+
.query("oauthTokens")
|
|
151
|
+
.filter(q => q.eq(q.field("clientId"), args.clientId))
|
|
152
|
+
.collect();
|
|
153
|
+
for (const token of tokens) {
|
|
154
|
+
await ctx.db.delete(token._id);
|
|
155
|
+
}
|
|
156
|
+
// Delete all codes for this client
|
|
157
|
+
const codes = await ctx.db
|
|
158
|
+
.query("oauthCodes")
|
|
159
|
+
.filter(q => q.eq(q.field("clientId"), args.clientId))
|
|
160
|
+
.collect();
|
|
161
|
+
for (const code of codes) {
|
|
162
|
+
await ctx.db.delete(code._id);
|
|
163
|
+
}
|
|
164
|
+
// Delete the client
|
|
165
|
+
await ctx.db.delete(client._id);
|
|
166
|
+
return { success: true };
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=clientManagement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientManagement.js","sourceRoot":"","sources":["../../src/component/clientManagement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AAEH,SAAS,kBAAkB,CAAC,GAAW;IACnC,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACD,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,MAAM,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAE9B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,UAAU,GACZ,IAAI,KAAK,WAAW;QACpB,IAAI,KAAK,WAAW;QACpB,IAAI,KAAK,KAAK,CAAC;IAEnB,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC9C,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,UAAU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AAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;aACrD,OAAO,EAAE,CAAC;QAEf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;QAED,oBAAoB;QACpB,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAEhC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.1 Provider Constants
|
|
3
|
+
*/
|
|
4
|
+
export declare const OAUTH_CONSTANTS: {
|
|
5
|
+
readonly CODE_EXPIRY_MS: number;
|
|
6
|
+
readonly ACCESS_TOKEN_EXPIRY_SECONDS: 3600;
|
|
7
|
+
readonly ACCESS_TOKEN_EXPIRY: "1h";
|
|
8
|
+
readonly ID_TOKEN_EXPIRY: "1h";
|
|
9
|
+
readonly REFRESH_TOKEN_EXPIRY_MS: number;
|
|
10
|
+
readonly AUTH_CODE_LENGTH: 32;
|
|
11
|
+
readonly CLIENT_SECRET_LENGTH: 64;
|
|
12
|
+
readonly SUPPORTED_SCOPES: readonly ["openid", "profile", "email", "offline_access"];
|
|
13
|
+
readonly SUPPORTED_GRANT_TYPES: readonly ["authorization_code", "refresh_token"];
|
|
14
|
+
readonly SUPPORTED_RESPONSE_TYPES: readonly ["code"];
|
|
15
|
+
readonly SUPPORTED_CODE_CHALLENGE_METHODS: readonly ["S256"];
|
|
16
|
+
readonly DEFAULT_KEY_ID: "default-key";
|
|
17
|
+
readonly CORS_MAX_AGE: "3600";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* OAuth Error Codes (RFC 6749)
|
|
21
|
+
*/
|
|
22
|
+
export declare const OAUTH_ERROR_CODES: {
|
|
23
|
+
readonly INVALID_REQUEST: "invalid_request";
|
|
24
|
+
readonly INVALID_CLIENT: "invalid_client";
|
|
25
|
+
readonly INVALID_GRANT: "invalid_grant";
|
|
26
|
+
readonly UNAUTHORIZED_CLIENT: "unauthorized_client";
|
|
27
|
+
readonly UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type";
|
|
28
|
+
readonly INVALID_SCOPE: "invalid_scope";
|
|
29
|
+
readonly SERVER_ERROR: "server_error";
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/component/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;CAuBlB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;CAQpB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.1 Provider Constants
|
|
3
|
+
*/
|
|
4
|
+
export const OAUTH_CONSTANTS = {
|
|
5
|
+
// Code & Token Expiry
|
|
6
|
+
CODE_EXPIRY_MS: 10 * 60 * 1000, // 10 minutes
|
|
7
|
+
ACCESS_TOKEN_EXPIRY_SECONDS: 3600, // 1 hour
|
|
8
|
+
ACCESS_TOKEN_EXPIRY: "1h",
|
|
9
|
+
ID_TOKEN_EXPIRY: "1h",
|
|
10
|
+
REFRESH_TOKEN_EXPIRY_MS: 30 * 24 * 60 * 60 * 1000, // 30 days
|
|
11
|
+
// Code Generation
|
|
12
|
+
AUTH_CODE_LENGTH: 32,
|
|
13
|
+
CLIENT_SECRET_LENGTH: 64,
|
|
14
|
+
// Supported Values
|
|
15
|
+
SUPPORTED_SCOPES: ["openid", "profile", "email", "offline_access"],
|
|
16
|
+
SUPPORTED_GRANT_TYPES: ["authorization_code", "refresh_token"],
|
|
17
|
+
SUPPORTED_RESPONSE_TYPES: ["code"],
|
|
18
|
+
SUPPORTED_CODE_CHALLENGE_METHODS: ["S256"],
|
|
19
|
+
// Keys
|
|
20
|
+
DEFAULT_KEY_ID: "default-key",
|
|
21
|
+
// CORS
|
|
22
|
+
CORS_MAX_AGE: "3600", // 1 hour
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* OAuth Error Codes (RFC 6749)
|
|
26
|
+
*/
|
|
27
|
+
export const OAUTH_ERROR_CODES = {
|
|
28
|
+
INVALID_REQUEST: "invalid_request",
|
|
29
|
+
INVALID_CLIENT: "invalid_client",
|
|
30
|
+
INVALID_GRANT: "invalid_grant",
|
|
31
|
+
UNAUTHORIZED_CLIENT: "unauthorized_client",
|
|
32
|
+
UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type",
|
|
33
|
+
INVALID_SCOPE: "invalid_scope",
|
|
34
|
+
SERVER_ERROR: "server_error",
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/component/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,sBAAsB;IACtB,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAe,aAAa;IAC1D,2BAA2B,EAAE,IAAI,EAAY,SAAS;IACtD,mBAAmB,EAAE,IAAI;IACzB,eAAe,EAAE,IAAI;IACrB,uBAAuB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,UAAU;IAE7D,kBAAkB;IAClB,gBAAgB,EAAE,EAAE;IACpB,oBAAoB,EAAE,EAAE;IAExB,mBAAmB;IACnB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC;IAClE,qBAAqB,EAAE,CAAC,oBAAoB,EAAE,eAAe,CAAC;IAC9D,wBAAwB,EAAE,CAAC,MAAM,CAAC;IAClC,gCAAgC,EAAE,CAAC,MAAM,CAAC;IAE1C,OAAO;IACP,cAAc,EAAE,aAAa;IAE7B,OAAO;IACP,YAAY,EAAE,MAAM,EAAE,SAAS;CACzB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,mBAAmB,EAAE,qBAAqB;IAC1C,sBAAsB,EAAE,wBAAwB;IAChD,aAAa,EAAE,eAAe;IAC9B,YAAY,EAAE,cAAc;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":";AAEA,wBAAgD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAe,eAAe,CAAC,eAAe,CAAC,CAAC"}
|