@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.
Files changed (113) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +572 -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/auth-config.d.ts +85 -0
  8. package/dist/client/auth-config.d.ts.map +1 -0
  9. package/dist/client/auth-config.js +81 -0
  10. package/dist/client/auth-config.js.map +1 -0
  11. package/dist/client/auth-helper.d.ts +81 -0
  12. package/dist/client/auth-helper.d.ts.map +1 -0
  13. package/dist/client/auth-helper.js +97 -0
  14. package/dist/client/auth-helper.js.map +1 -0
  15. package/dist/client/index.d.ts +189 -0
  16. package/dist/client/index.d.ts.map +1 -0
  17. package/dist/client/index.js +230 -0
  18. package/dist/client/index.js.map +1 -0
  19. package/dist/client/routes.d.ts +94 -0
  20. package/dist/client/routes.d.ts.map +1 -0
  21. package/dist/client/routes.js +113 -0
  22. package/dist/client/routes.js.map +1 -0
  23. package/dist/component/_generated/api.d.ts +44 -0
  24. package/dist/component/_generated/api.d.ts.map +1 -0
  25. package/dist/component/_generated/api.js +31 -0
  26. package/dist/component/_generated/api.js.map +1 -0
  27. package/dist/component/_generated/component.d.ts +123 -0
  28. package/dist/component/_generated/component.d.ts.map +1 -0
  29. package/dist/component/_generated/component.js +11 -0
  30. package/dist/component/_generated/component.js.map +1 -0
  31. package/dist/component/_generated/dataModel.d.ts +46 -0
  32. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  33. package/dist/component/_generated/dataModel.js +11 -0
  34. package/dist/component/_generated/dataModel.js.map +1 -0
  35. package/dist/component/_generated/server.d.ts +121 -0
  36. package/dist/component/_generated/server.d.ts.map +1 -0
  37. package/dist/component/_generated/server.js +78 -0
  38. package/dist/component/_generated/server.js.map +1 -0
  39. package/dist/component/clientManagement.d.ts +39 -0
  40. package/dist/component/clientManagement.d.ts.map +1 -0
  41. package/dist/component/clientManagement.js +169 -0
  42. package/dist/component/clientManagement.js.map +1 -0
  43. package/dist/component/constants.d.ts +31 -0
  44. package/dist/component/constants.d.ts.map +1 -0
  45. package/dist/component/constants.js +36 -0
  46. package/dist/component/constants.js.map +1 -0
  47. package/dist/component/convex.config.d.ts +3 -0
  48. package/dist/component/convex.config.d.ts.map +1 -0
  49. package/dist/component/convex.config.js +3 -0
  50. package/dist/component/convex.config.js.map +1 -0
  51. package/dist/component/handlers.d.ts +143 -0
  52. package/dist/component/handlers.d.ts.map +1 -0
  53. package/dist/component/handlers.js +624 -0
  54. package/dist/component/handlers.js.map +1 -0
  55. package/dist/component/mutations.d.ts +111 -0
  56. package/dist/component/mutations.d.ts.map +1 -0
  57. package/dist/component/mutations.js +459 -0
  58. package/dist/component/mutations.js.map +1 -0
  59. package/dist/component/queries.d.ts +127 -0
  60. package/dist/component/queries.d.ts.map +1 -0
  61. package/dist/component/queries.js +145 -0
  62. package/dist/component/queries.js.map +1 -0
  63. package/dist/component/schema.d.ts +116 -0
  64. package/dist/component/schema.d.ts.map +1 -0
  65. package/dist/component/schema.js +77 -0
  66. package/dist/component/schema.js.map +1 -0
  67. package/dist/component/token_security.d.ts +53 -0
  68. package/dist/component/token_security.d.ts.map +1 -0
  69. package/dist/component/token_security.js +91 -0
  70. package/dist/component/token_security.js.map +1 -0
  71. package/dist/lib/convex-types.d.ts +21 -0
  72. package/dist/lib/convex-types.d.ts.map +1 -0
  73. package/dist/lib/convex-types.js +2 -0
  74. package/dist/lib/convex-types.js.map +1 -0
  75. package/dist/lib/oauth.d.ts +123 -0
  76. package/dist/lib/oauth.d.ts.map +1 -0
  77. package/dist/lib/oauth.js +295 -0
  78. package/dist/lib/oauth.js.map +1 -0
  79. package/dist/react/index.d.ts +2 -0
  80. package/dist/react/index.d.ts.map +1 -0
  81. package/dist/react/index.js +6 -0
  82. package/dist/react/index.js.map +1 -0
  83. package/package.json +121 -0
  84. package/src/client/__tests__/auth-config.test.ts +244 -0
  85. package/src/client/__tests__/auth-helper.test.ts +273 -0
  86. package/src/client/__tests__/oauth-provider.test.ts +418 -0
  87. package/src/client/__tests__/routes.test.ts +428 -0
  88. package/src/client/_generated/_ignore.ts +1 -0
  89. package/src/client/auth-config.ts +157 -0
  90. package/src/client/auth-helper.ts +201 -0
  91. package/src/client/index.ts +326 -0
  92. package/src/client/routes.ts +251 -0
  93. package/src/component/__tests__/oauth.test.ts +3310 -0
  94. package/src/component/__tests__/rfc-compliance.test.ts +788 -0
  95. package/src/component/__tests__/token-security.test.ts +133 -0
  96. package/src/component/_generated/api.ts +60 -0
  97. package/src/component/_generated/component.ts +201 -0
  98. package/src/component/_generated/dataModel.ts +60 -0
  99. package/src/component/_generated/server.ts +156 -0
  100. package/src/component/clientManagement.ts +189 -0
  101. package/src/component/constants.ts +40 -0
  102. package/src/component/convex.config.ts +3 -0
  103. package/src/component/handlers.ts +964 -0
  104. package/src/component/mutations.ts +531 -0
  105. package/src/component/queries.ts +165 -0
  106. package/src/component/schema.ts +92 -0
  107. package/src/component/token_security.ts +102 -0
  108. package/src/lib/__tests__/oauth-helpers.test.ts +143 -0
  109. package/src/lib/__tests__/oauth-jwt.test.ts +405 -0
  110. package/src/lib/convex-types.ts +37 -0
  111. package/src/lib/oauth.ts +412 -0
  112. package/src/react/index.ts +7 -0
  113. package/src/test.ts +21 -0
@@ -0,0 +1,230 @@
1
+ import { openIdConfigurationHandler, jwksHandler, tokenHandler, userInfoHandler, registerHandler, authorizeHandler, oauthProtectedResourceHandler, } from "../component/handlers.js";
2
+ export { OAuthError, verifyAccessToken, isOAuthToken, getOAuthClientId, DEFAULT_OAUTH_ISSUER_PATTERN, } from "../lib/oauth.js";
3
+ export { OAUTH_CONSTANTS, OAUTH_ERROR_CODES } from "../component/constants.js";
4
+ // Auth helper for getCurrentUser pattern
5
+ export { createAuthHelper } from "./auth-helper.js";
6
+ // Route registration helper
7
+ export { registerOAuthRoutes } from "./routes.js";
8
+ // Auth config generator
9
+ export { generateAuthConfig, createAuthConfig } from "./auth-config.js";
10
+ /**
11
+ * OAuth Provider SDK
12
+ *
13
+ * Usage:
14
+ * ```typescript
15
+ * import { OAuthProvider } from "@codefox-inc/oauth-provider";
16
+ * import { components } from "./_generated/api";
17
+ *
18
+ * const oauthProvider = new OAuthProvider(components.oauthProvider, {
19
+ * privateKey: process.env.OAUTH_PRIVATE_KEY!,
20
+ * publicKey: process.env.OAUTH_PUBLIC_KEY!,
21
+ * siteUrl: process.env.SITE_URL!,
22
+ * });
23
+ *
24
+ * // In http.ts
25
+ * http.route({
26
+ * path: "/oauth/.well-known/openid-configuration",
27
+ * method: "GET",
28
+ * handler: httpAction((ctx, req) => oauthProvider.handlers.openIdConfiguration(ctx, req)),
29
+ * });
30
+ * ```
31
+ */
32
+ export class OAuthProvider {
33
+ config;
34
+ api;
35
+ component;
36
+ constructor(component, config) {
37
+ this.config = config;
38
+ this.component = component;
39
+ this.api = this.createAPI(component);
40
+ }
41
+ getConfig() {
42
+ return this.config;
43
+ }
44
+ createAPI(component) {
45
+ return {
46
+ queries: {
47
+ getClient: (ctx, args) => ctx.runQuery(component.queries.getClient, args),
48
+ getRefreshToken: (ctx, args) => ctx.runQuery(component.queries.getRefreshToken, args),
49
+ getTokensByUser: (ctx, args) => ctx.runQuery(component.queries.getTokensByUser, args),
50
+ },
51
+ mutations: {
52
+ issueAuthorizationCode: (ctx, args) => ctx.runMutation(component.mutations.issueAuthorizationCode, args),
53
+ consumeAuthCode: (ctx, args) => ctx.runMutation(component.mutations.consumeAuthCode, args),
54
+ saveTokens: (ctx, args) => ctx.runMutation(component.mutations.saveTokens, args),
55
+ rotateRefreshToken: (ctx, args) => ctx.runMutation(component.mutations.rotateRefreshToken, args),
56
+ upsertAuthorization: (ctx, args) => ctx.runMutation(component.mutations.upsertAuthorization, args),
57
+ updateAuthorizationLastUsed: (ctx, args) => ctx.runMutation(component.mutations.updateAuthorizationLastUsed, args),
58
+ },
59
+ clientManagement: {
60
+ registerClient: (ctx, args) => ctx.runMutation(component.clientManagement.registerClient, args),
61
+ verifyClientSecret: (ctx, args) => ctx.runMutation(component.clientManagement.verifyClientSecret, args),
62
+ },
63
+ };
64
+ }
65
+ /**
66
+ * HTTP Handlers for mounting in http.ts
67
+ *
68
+ * Note: ctx expects Convex ActionCtx (HTTP Action context).
69
+ * RunActionCtx is used as the base type for compatibility.
70
+ */
71
+ get handlers() {
72
+ return {
73
+ /**
74
+ * OpenID Connect Discovery
75
+ * Mount at: /oauth/.well-known/openid-configuration
76
+ */
77
+ openIdConfiguration: (ctx, request) => openIdConfigurationHandler(ctx, request, this.config),
78
+ /**
79
+ * Authorization Endpoint
80
+ * Mount at: /oauth/authorize
81
+ */
82
+ authorize: (ctx, request) => authorizeHandler(ctx, request, this.config, this.api),
83
+ /**
84
+ * JWKS Endpoint
85
+ * Mount at: /oauth/.well-known/jwks.json
86
+ */
87
+ jwks: (ctx, request) => jwksHandler(ctx, request, this.config),
88
+ /**
89
+ * Token Endpoint
90
+ * Mount at: /oauth/token
91
+ */
92
+ token: (ctx, request) => tokenHandler(ctx, request, this.config, this.api),
93
+ /**
94
+ * UserInfo Endpoint
95
+ * Mount at: /oauth/userinfo
96
+ * Requires getUserProfile callback
97
+ */
98
+ userInfo: (ctx, request, getUserProfile) => userInfoHandler(ctx, request, this.config, getUserProfile),
99
+ /**
100
+ * Dynamic Client Registration
101
+ * Mount at: /oauth/register
102
+ */
103
+ register: (ctx, request) => registerHandler(ctx, request, this.config, this.api),
104
+ /**
105
+ * Protected Resource Metadata
106
+ * Mount at: /.well-known/oauth-protected-resource
107
+ */
108
+ protectedResource: (ctx, request) => oauthProtectedResourceHandler(ctx, request, this.config),
109
+ };
110
+ }
111
+ /**
112
+ * Issue Authorization Code
113
+ * Called from consent approval mutation
114
+ * Also creates/updates authorization record automatically
115
+ */
116
+ async issueAuthorizationCode(ctx, args) {
117
+ if (!args.codeChallenge) {
118
+ throw new Error("codeChallenge required");
119
+ }
120
+ const codeChallengeMethod = args.codeChallengeMethod ?? "S256";
121
+ if (codeChallengeMethod !== "S256") {
122
+ throw new Error("codeChallengeMethod must be S256");
123
+ }
124
+ // 1. Create/update authorization record (user consented)
125
+ await this.api.mutations.upsertAuthorization(ctx, {
126
+ userId: args.userId,
127
+ clientId: args.clientId,
128
+ scopes: args.scopes,
129
+ });
130
+ // 2. Issue the authorization code
131
+ return this.api.mutations.issueAuthorizationCode(ctx, {
132
+ ...args,
133
+ codeChallenge: args.codeChallenge,
134
+ codeChallengeMethod,
135
+ });
136
+ }
137
+ /**
138
+ * Get OAuth Client
139
+ */
140
+ async getClient(ctx, clientId) {
141
+ return this.api.queries.getClient(ctx, { clientId });
142
+ }
143
+ /**
144
+ * Register OAuth Client (for admin use)
145
+ */
146
+ async registerClient(ctx, args) {
147
+ return this.api.clientManagement.registerClient(ctx, args);
148
+ }
149
+ /**
150
+ * Get user's active tokens
151
+ */
152
+ async getTokensByUser(ctx, userId) {
153
+ return this.api.queries.getTokensByUser(ctx, { userId });
154
+ }
155
+ // -------------------------------------------------------------------------
156
+ // Authorization Management
157
+ // -------------------------------------------------------------------------
158
+ /**
159
+ * Get authorization for a specific user-client pair
160
+ * Returns null if user has not authorized this client
161
+ */
162
+ async getAuthorization(ctx, userId, clientId) {
163
+ return ctx.runQuery(this.component.queries.getAuthorization, { userId, clientId });
164
+ }
165
+ /**
166
+ * List all authorized apps for a user
167
+ * Returns client info along with authorization details
168
+ */
169
+ async listUserAuthorizations(ctx, userId) {
170
+ return ctx.runQuery(this.component.queries.listUserAuthorizations, { userId });
171
+ }
172
+ /**
173
+ * Create or update authorization when user grants consent
174
+ * Call this when user approves OAuth consent
175
+ */
176
+ async upsertAuthorization(ctx, args) {
177
+ return ctx.runMutation(this.component.mutations.upsertAuthorization, args);
178
+ }
179
+ /**
180
+ * Revoke authorization and delete all associated tokens
181
+ * Call this when user wants to disconnect an app
182
+ */
183
+ async revokeAuthorization(ctx, userId, clientId) {
184
+ return ctx.runMutation(this.component.mutations.revokeAuthorization, { userId, clientId });
185
+ }
186
+ /**
187
+ * Check if user has already authorized this client with sufficient scopes
188
+ * Useful for "skip consent" flow
189
+ */
190
+ async hasAuthorization(ctx, userId, clientId, requiredScopes) {
191
+ const auth = await this.getAuthorization(ctx, userId, clientId);
192
+ if (!auth)
193
+ return false;
194
+ // Check if all required scopes are authorized
195
+ return requiredScopes.every(scope => auth.scopes.includes(scope));
196
+ }
197
+ /**
198
+ * Check if authorization exists (for revocation check)
199
+ * Use this with createAuthHelper's checkAuthorization option
200
+ */
201
+ async checkAuthorizationValid(ctx, userId, clientId) {
202
+ if (clientId) {
203
+ // Check specific client authorization
204
+ return ctx.runQuery(this.component.queries.hasAuthorization, { userId, clientId });
205
+ }
206
+ else {
207
+ // Check if user has any authorization
208
+ return ctx.runQuery(this.component.queries.hasAnyAuthorization, { userId });
209
+ }
210
+ }
211
+ /**
212
+ * Create a checkAuthorization function for use with createAuthHelper
213
+ * This ensures revoked authorizations are rejected
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const oauthProvider = new OAuthProvider(components.oauthProvider, config);
218
+ * const authHelper = createAuthHelper({
219
+ * providers: ["anonymous"],
220
+ * checkAuthorization: oauthProvider.createAuthorizationChecker(),
221
+ * });
222
+ * ```
223
+ */
224
+ createAuthorizationChecker() {
225
+ return async (ctx, userId, clientId) => {
226
+ return this.checkAuthorizationValid(ctx, userId, clientId);
227
+ };
228
+ }
229
+ }
230
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,0BAA0B,EAC1B,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,6BAA6B,GAChC,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EACH,UAAU,EACV,iB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;YACX,sCAAsC;YACtC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvF,CAAC;aAAM,CAAC;YACJ,sCAAsC;YACtC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAChF,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,0BAA0B;QACtB,OAAO,KAAK,EAAE,GAAgB,EAAE,MAAc,EAAE,QAAiB,EAAoB,EAAE;YACnF,OAAO,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC/D,CAAC,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * OAuth Route Registration Helper
3
+ *
4
+ * Simplifies registering all OAuth endpoints in http.ts
5
+ */
6
+ import type { OAuthProvider } from "./index.js";
7
+ import type { UserProfile } from "../lib/oauth.js";
8
+ import type { RunActionCtx, RunQueryCtx } from "../lib/convex-types.js";
9
+ import type { Auth } from "convex/server";
10
+ /**
11
+ * HTTP Router interface (compatible with Convex httpRouter)
12
+ */
13
+ interface HttpRouter {
14
+ route: (config: {
15
+ path: string;
16
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
17
+ handler: any;
18
+ }) => void;
19
+ }
20
+ /**
21
+ * HTTP Action creator function
22
+ * Note: Actual Convex ActionCtx extends RunActionCtx with additional HTTP-specific properties
23
+ */
24
+ type HttpActionCreator = (handler: (ctx: RunActionCtx & {
25
+ auth: Auth;
26
+ }, request: Request) => Promise<Response>) => unknown;
27
+ /**
28
+ * Options for registering OAuth routes
29
+ */
30
+ export interface RegisterOAuthRoutesOptions {
31
+ /**
32
+ * URL prefix for OAuth endpoints
33
+ * @default "/oauth"
34
+ */
35
+ prefix?: string;
36
+ /**
37
+ * Callback to get user profile for UserInfo endpoint
38
+ * Receives ctx for DB access (e.g., ctx.runQuery)
39
+ * If not provided, UserInfo endpoint returns only { sub: userId }
40
+ */
41
+ getUserProfile?: (ctx: RunQueryCtx, userId: string) => Promise<UserProfile | null>;
42
+ /**
43
+ * Custom authorize handler for authentication check before consent
44
+ * If not provided, simply redirects to consent page
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * authorizeHandler: async (ctx, request, defaultRedirect) => {
49
+ * const identity = await ctx.auth.getUserIdentity();
50
+ * if (!identity) {
51
+ * const loginUrl = new URL(`${siteUrl}/login`);
52
+ * loginUrl.searchParams.set("returnTo", request.url);
53
+ * return Response.redirect(loginUrl.toString());
54
+ * }
55
+ * return defaultRedirect();
56
+ * }
57
+ * ```
58
+ */
59
+ authorizeHandler?: (ctx: RunActionCtx & {
60
+ auth: Auth;
61
+ }, request: Request, defaultAuthorize: () => Promise<Response>) => Promise<Response>;
62
+ /**
63
+ * SITE_URL for authorize redirect
64
+ */
65
+ siteUrl?: string;
66
+ /**
67
+ * Also register routes without /oauth prefix for RFC 8414 compatibility
68
+ * @default true
69
+ */
70
+ registerRootWellKnown?: boolean;
71
+ }
72
+ /**
73
+ * Register all OAuth routes on an HTTP router
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * import { httpRouter } from "convex/server";
78
+ * import { httpAction } from "./_generated/server";
79
+ * import { OAuthProvider, registerOAuthRoutes } from "@codefox-inc/oauth-provider";
80
+ *
81
+ * const http = httpRouter();
82
+ * const oauthProvider = new OAuthProvider(components.oauthProvider, config);
83
+ *
84
+ * registerOAuthRoutes(http, httpAction, oauthProvider, {
85
+ * siteUrl: process.env.SITE_URL,
86
+ * getUserProfile: async (userId) => ({ sub: userId, name: "User" }),
87
+ * });
88
+ *
89
+ * export default http;
90
+ * ```
91
+ */
92
+ export declare function registerOAuthRoutes(http: HttpRouter, httpAction: HttpActionCreator, oauthProvider: OAuthProvider, options?: RegisterOAuthRoutesOptions): void;
93
+ export {};
94
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/client/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AACH,UAAU,UAAU;IAChB,KAAK,EAAE,CAAC,MAAM,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;QAEhE,OAAO,EAAE,GAAG,CAAC;KAChB,KAAK,IAAI,CAAC;CACd;AAED;;;GAGG;AACH,KAAK,iBAAiB,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,YAAY,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC;AAE3H;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAEnF;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,CAAC,EAAE,CACf,GAAG,EAAE,YAAY,GAAG;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,EAClC,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,KACxC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAAE,aAAa,EAC5B,OAAO,GAAE,0BAA+B,GACzC,IAAI,CA+IN"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * OAuth Route Registration Helper
3
+ *
4
+ * Simplifies registering all OAuth endpoints in http.ts
5
+ */
6
+ import { normalizePrefix } from "../lib/oauth.js";
7
+ /**
8
+ * Register all OAuth routes on an HTTP router
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { httpRouter } from "convex/server";
13
+ * import { httpAction } from "./_generated/server";
14
+ * import { OAuthProvider, registerOAuthRoutes } from "@codefox-inc/oauth-provider";
15
+ *
16
+ * const http = httpRouter();
17
+ * const oauthProvider = new OAuthProvider(components.oauthProvider, config);
18
+ *
19
+ * registerOAuthRoutes(http, httpAction, oauthProvider, {
20
+ * siteUrl: process.env.SITE_URL,
21
+ * getUserProfile: async (userId) => ({ sub: userId, name: "User" }),
22
+ * });
23
+ *
24
+ * export default http;
25
+ * ```
26
+ */
27
+ export function registerOAuthRoutes(http, httpAction, oauthProvider, options = {}) {
28
+ const baseConfig = oauthProvider.getConfig?.();
29
+ const prefix = normalizePrefix(options.prefix ?? baseConfig?.prefix);
30
+ const { getUserProfile, authorizeHandler, siteUrl: _siteUrl = "http://localhost:5173", registerRootWellKnown = true, } = options;
31
+ const handlers = oauthProvider.handlers;
32
+ // Helper to register GET + OPTIONS for a path
33
+ const registerGetEndpoint = (path, handler) => {
34
+ http.route({
35
+ path,
36
+ method: "GET",
37
+ handler: httpAction((ctx, req) => handler(ctx, req)),
38
+ });
39
+ http.route({
40
+ path,
41
+ method: "OPTIONS",
42
+ handler: httpAction((ctx, req) => handler(ctx, req)),
43
+ });
44
+ };
45
+ // Helper to register POST + OPTIONS for a path
46
+ const registerPostEndpoint = (path, handler) => {
47
+ http.route({
48
+ path,
49
+ method: "POST",
50
+ handler: httpAction((ctx, req) => handler(ctx, req)),
51
+ });
52
+ http.route({
53
+ path,
54
+ method: "OPTIONS",
55
+ handler: httpAction((ctx, req) => handler(ctx, req)),
56
+ });
57
+ };
58
+ // 1. OpenID Configuration
59
+ registerGetEndpoint(`${prefix}/.well-known/openid-configuration`, (ctx, req) => handlers.openIdConfiguration(ctx, req));
60
+ // 2. OAuth Authorization Server Metadata (RFC 8414)
61
+ registerGetEndpoint(`${prefix}/.well-known/oauth-authorization-server`, (ctx, req) => handlers.openIdConfiguration(ctx, req));
62
+ // 3. JWKS
63
+ registerGetEndpoint(`${prefix}/.well-known/jwks.json`, (ctx, req) => handlers.jwks(ctx, req));
64
+ // 4. Protected Resource Metadata (RFC 9728)
65
+ registerGetEndpoint(`${prefix}/.well-known/oauth-protected-resource`, (ctx, req) => handlers.protectedResource(ctx, req));
66
+ // 5. Authorization Endpoint (redirect to frontend)
67
+ const authorizeEndpoint = async (ctx, request) => {
68
+ const defaultAuthorize = () => handlers.authorize(ctx, request);
69
+ if (authorizeHandler) {
70
+ return authorizeHandler(ctx, request, defaultAuthorize);
71
+ }
72
+ return defaultAuthorize();
73
+ };
74
+ registerGetEndpoint(`${prefix}/authorize`, (ctx, req) => authorizeEndpoint(ctx, req));
75
+ // 6. Token Endpoint
76
+ registerPostEndpoint(`${prefix}/token`, (ctx, req) => handlers.token(ctx, req));
77
+ // 7. UserInfo Endpoint
78
+ // Wrap getUserProfile to pass ctx for DB access
79
+ const userInfoHandler = getUserProfile
80
+ ? (ctx, req) => handlers.userInfo(ctx, req, (userId) => getUserProfile(ctx, userId))
81
+ : (ctx, req) => handlers.userInfo(ctx, req, async (userId) => ({ sub: userId }));
82
+ http.route({
83
+ path: `${prefix}/userinfo`,
84
+ method: "GET",
85
+ handler: httpAction(userInfoHandler),
86
+ });
87
+ http.route({
88
+ path: `${prefix}/userinfo`,
89
+ method: "POST",
90
+ handler: httpAction(userInfoHandler),
91
+ });
92
+ http.route({
93
+ path: `${prefix}/userinfo`,
94
+ method: "OPTIONS",
95
+ handler: httpAction(userInfoHandler),
96
+ });
97
+ // 8. Dynamic Client Registration
98
+ registerPostEndpoint(`${prefix}/register`, (ctx, req) => handlers.register(ctx, req));
99
+ // Root well-known paths (RFC 8414 compatibility)
100
+ if (registerRootWellKnown) {
101
+ // /.well-known/oauth-authorization-server
102
+ registerGetEndpoint("/.well-known/oauth-authorization-server", (ctx, req) => handlers.openIdConfiguration(ctx, req));
103
+ // /.well-known/oauth-authorization-server{prefix} (for issuer with custom prefix)
104
+ // RFC 8414: If issuer is https://example.com/oauth, well-known is /.well-known/oauth-authorization-server/oauth
105
+ // Only register if prefix is non-empty to avoid duplicate route registration
106
+ if (prefix && prefix !== "/") {
107
+ registerGetEndpoint(`/.well-known/oauth-authorization-server${prefix}`, (ctx, req) => handlers.openIdConfiguration(ctx, req));
108
+ }
109
+ // /.well-known/oauth-protected-resource
110
+ registerGetEndpoint("/.well-known/oauth-protected-resource", (ctx, req) => handlers.protectedResource(ctx, req));
111
+ }
112
+ }
113
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/client/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA2ElD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CAC/B,IAAgB,EAChB,UAA6B,EAC7B,aAA4B,EAC5B,UAAsC,EAAE;IAExC,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC;IAC/C,MAAM,MAAM,GAAG,eAAe,CAAC,OA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GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CACvD,CAAC;QAEF,kFAAkF;QAClF,gHAAgH;QAChH,6EAA6E;QAC7E,IAAI,MAAM,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YAC3B,mBAAmB,CACf,0CAA0C,MAAM,EAAE,EAClD,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CACvD,CAAC;QACN,CAAC;QAED,wCAAwC;QACxC,mBAAmB,CACf,uCAAuC,EACvC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CACrD,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Generated `api` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type * as clientManagement from "../clientManagement.js";
10
+ import type * as constants from "../constants.js";
11
+ import type * as handlers from "../handlers.js";
12
+ import type * as mutations from "../mutations.js";
13
+ import type * as queries from "../queries.js";
14
+ import type * as token_security from "../token_security.js";
15
+ import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
16
+ declare const fullApi: ApiFromModules<{
17
+ clientManagement: typeof clientManagement;
18
+ constants: typeof constants;
19
+ handlers: typeof handlers;
20
+ mutations: typeof mutations;
21
+ queries: typeof queries;
22
+ token_security: typeof token_security;
23
+ }>;
24
+ /**
25
+ * A utility for referencing Convex functions in your app's public API.
26
+ *
27
+ * Usage:
28
+ * ```js
29
+ * const myFunctionReference = api.myModule.myFunction;
30
+ * ```
31
+ */
32
+ export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
33
+ /**
34
+ * A utility for referencing Convex functions in your app's internal API.
35
+ *
36
+ * Usage:
37
+ * ```js
38
+ * const myFunctionReference = internal.myModule.myFunction;
39
+ * ```
40
+ */
41
+ export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
42
+ export declare const components: {};
43
+ export {};
44
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,cAAc,CAAC;CACvC,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `api` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ import { anyApi, componentsGeneric } from "convex/server";
11
+ const fullApi = anyApi;
12
+ /**
13
+ * A utility for referencing Convex functions in your app's public API.
14
+ *
15
+ * Usage:
16
+ * ```js
17
+ * const myFunctionReference = api.myModule.myFunction;
18
+ * ```
19
+ */
20
+ export const api = anyApi;
21
+ /**
22
+ * A utility for referencing Convex functions in your app's internal API.
23
+ *
24
+ * Usage:
25
+ * ```js
26
+ * const myFunctionReference = internal.myModule.myFunction;
27
+ * ```
28
+ */
29
+ export const internal = anyApi;
30
+ export const components = componentsGeneric();
31
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAcH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAOR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Generated `ComponentApi` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { FunctionReference } from "convex/server";
10
+ /**
11
+ * A utility for referencing a Convex component's exposed API.
12
+ *
13
+ * Useful when expecting a parameter like `components.myComponent`.
14
+ * Usage:
15
+ * ```ts
16
+ * async function myFunction(ctx: QueryCtx, component: ComponentApi) {
17
+ * return ctx.runQuery(component.someFile.someQuery, { ...args });
18
+ * }
19
+ * ```
20
+ */
21
+ export type ComponentApi<Name extends string | undefined = string | undefined> = {
22
+ clientManagement: {
23
+ deleteClient: FunctionReference<"mutation", "internal", {
24
+ clientId: string;
25
+ }, any, Name>;
26
+ registerClient: FunctionReference<"mutation", "internal", {
27
+ description?: string;
28
+ isInternal?: boolean;
29
+ logoUrl?: string;
30
+ name: string;
31
+ policyUrl?: string;
32
+ redirectUris: Array<string>;
33
+ scopes: Array<string>;
34
+ tosUrl?: string;
35
+ type: "confidential" | "public";
36
+ website?: string;
37
+ }, any, Name>;
38
+ verifyClientSecret: FunctionReference<"mutation", "internal", {
39
+ clientId: string;
40
+ clientSecret: string;
41
+ }, any, Name>;
42
+ };
43
+ mutations: {
44
+ consumeAuthCode: FunctionReference<"mutation", "internal", {
45
+ clientId: string;
46
+ code: string;
47
+ codeVerifier: string;
48
+ redirectUri?: string;
49
+ }, any, Name>;
50
+ deleteClient: FunctionReference<"mutation", "internal", {
51
+ clientId: string;
52
+ }, any, Name>;
53
+ issueAuthorizationCode: FunctionReference<"mutation", "internal", {
54
+ clientId: string;
55
+ codeChallenge: string;
56
+ codeChallengeMethod: string;
57
+ nonce?: string;
58
+ redirectUri: string;
59
+ scopes: Array<string>;
60
+ userId: string;
61
+ }, any, Name>;
62
+ revokeAuthorization: FunctionReference<"mutation", "internal", {
63
+ clientId: string;
64
+ userId: string;
65
+ }, any, Name>;
66
+ rotateRefreshToken: FunctionReference<"mutation", "internal", {
67
+ accessToken: string;
68
+ clientId: string;
69
+ expiresAt: number;
70
+ oldRefreshToken: string;
71
+ refreshToken?: string;
72
+ refreshTokenExpiresAt?: number;
73
+ scopes: Array<string>;
74
+ userId: string;
75
+ }, any, Name>;
76
+ saveTokens: FunctionReference<"mutation", "internal", {
77
+ accessToken: string;
78
+ authorizationCode?: string;
79
+ clientId: string;
80
+ expiresAt: number;
81
+ refreshToken?: string;
82
+ refreshTokenExpiresAt?: number;
83
+ scopes: Array<string>;
84
+ userId: string;
85
+ }, any, Name>;
86
+ updateAuthorizationLastUsed: FunctionReference<"mutation", "internal", {
87
+ clientId: string;
88
+ userId: string;
89
+ }, any, Name>;
90
+ upsertAuthorization: FunctionReference<"mutation", "internal", {
91
+ clientId: string;
92
+ scopes: Array<string>;
93
+ userId: string;
94
+ }, any, Name>;
95
+ };
96
+ queries: {
97
+ getAuthorization: FunctionReference<"query", "internal", {
98
+ clientId: string;
99
+ userId: string;
100
+ }, any, Name>;
101
+ getClient: FunctionReference<"query", "internal", {
102
+ clientId: string;
103
+ }, any, Name>;
104
+ getRefreshToken: FunctionReference<"query", "internal", {
105
+ refreshToken: string;
106
+ }, any, Name>;
107
+ getTokensByUser: FunctionReference<"query", "internal", {
108
+ userId: string;
109
+ }, any, Name>;
110
+ hasAnyAuthorization: FunctionReference<"query", "internal", {
111
+ userId: string;
112
+ }, any, Name>;
113
+ hasAuthorization: FunctionReference<"query", "internal", {
114
+ clientId: string;
115
+ userId: string;
116
+ }, any, Name>;
117
+ listClients: FunctionReference<"query", "internal", {}, any, Name>;
118
+ listUserAuthorizations: FunctionReference<"query", "internal", {
119
+ userId: string;
120
+ }, any, Name>;
121
+ };
122
+ };
123
+ //# sourceMappingURL=component.d.ts.map