@rebasepro/server-core 0.0.1-canary.09e5ec5
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 +6 -0
- package/README.md +40 -0
- package/build-errors.txt +52 -0
- package/coverage/clover.xml +3739 -0
- package/coverage/coverage-final.json +31 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +266 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/api/ast-schema-editor.ts.html +952 -0
- package/coverage/lcov-report/src/api/errors.ts.html +472 -0
- package/coverage/lcov-report/src/api/graphql/graphql-schema-generator.ts.html +1069 -0
- package/coverage/lcov-report/src/api/graphql/index.html +116 -0
- package/coverage/lcov-report/src/api/index.html +176 -0
- package/coverage/lcov-report/src/api/openapi-generator.ts.html +565 -0
- package/coverage/lcov-report/src/api/rest/api-generator.ts.html +994 -0
- package/coverage/lcov-report/src/api/rest/index.html +131 -0
- package/coverage/lcov-report/src/api/rest/query-parser.ts.html +550 -0
- package/coverage/lcov-report/src/api/schema-editor-routes.ts.html +202 -0
- package/coverage/lcov-report/src/api/server.ts.html +823 -0
- package/coverage/lcov-report/src/auth/admin-routes.ts.html +973 -0
- package/coverage/lcov-report/src/auth/index.html +176 -0
- package/coverage/lcov-report/src/auth/jwt.ts.html +574 -0
- package/coverage/lcov-report/src/auth/middleware.ts.html +745 -0
- package/coverage/lcov-report/src/auth/password.ts.html +310 -0
- package/coverage/lcov-report/src/auth/services.ts.html +2074 -0
- package/coverage/lcov-report/src/collections/index.html +116 -0
- package/coverage/lcov-report/src/collections/loader.ts.html +232 -0
- package/coverage/lcov-report/src/db/auth-schema.ts.html +523 -0
- package/coverage/lcov-report/src/db/data-transformer.ts.html +1753 -0
- package/coverage/lcov-report/src/db/entityService.ts.html +700 -0
- package/coverage/lcov-report/src/db/index.html +146 -0
- package/coverage/lcov-report/src/db/services/EntityFetchService.ts.html +4048 -0
- package/coverage/lcov-report/src/db/services/EntityPersistService.ts.html +883 -0
- package/coverage/lcov-report/src/db/services/RelationService.ts.html +3121 -0
- package/coverage/lcov-report/src/db/services/entity-helpers.ts.html +442 -0
- package/coverage/lcov-report/src/db/services/index.html +176 -0
- package/coverage/lcov-report/src/db/services/index.ts.html +124 -0
- package/coverage/lcov-report/src/generate-drizzle-schema-logic.ts.html +1960 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/services/driver-registry.ts.html +631 -0
- package/coverage/lcov-report/src/services/index.html +131 -0
- package/coverage/lcov-report/src/services/postgresDataDriver.ts.html +3025 -0
- package/coverage/lcov-report/src/storage/LocalStorageController.ts.html +1189 -0
- package/coverage/lcov-report/src/storage/S3StorageController.ts.html +970 -0
- package/coverage/lcov-report/src/storage/index.html +161 -0
- package/coverage/lcov-report/src/storage/storage-registry.ts.html +646 -0
- package/coverage/lcov-report/src/storage/types.ts.html +451 -0
- package/coverage/lcov-report/src/utils/drizzle-conditions.ts.html +3082 -0
- package/coverage/lcov-report/src/utils/index.html +116 -0
- package/coverage/lcov.info +7179 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +58 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +22 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/index-DXVBFp5V.js +37 -0
- package/dist/index-DXVBFp5V.js.map +1 -0
- package/dist/index.es.js +49934 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +49968 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/server-core/src/api/ast-schema-editor.d.ts +21 -0
- package/dist/server-core/src/api/collections_for_test/callbacks_test_collection.d.ts +2 -0
- package/dist/server-core/src/api/errors.d.ts +35 -0
- package/dist/server-core/src/api/graphql/graphql-schema-generator.d.ts +35 -0
- package/dist/server-core/src/api/graphql/index.d.ts +1 -0
- package/dist/server-core/src/api/index.d.ts +9 -0
- package/dist/server-core/src/api/openapi-generator.d.ts +16 -0
- package/dist/server-core/src/api/rest/api-generator.d.ts +64 -0
- package/dist/server-core/src/api/rest/index.d.ts +1 -0
- package/dist/server-core/src/api/rest/query-parser.d.ts +9 -0
- package/dist/server-core/src/api/schema-editor-routes.d.ts +3 -0
- package/dist/server-core/src/api/server.d.ts +40 -0
- package/dist/server-core/src/api/types.d.ts +90 -0
- package/dist/server-core/src/auth/admin-routes.d.ts +16 -0
- package/dist/server-core/src/auth/apple-oauth.d.ts +30 -0
- package/dist/server-core/src/auth/bitbucket-oauth.d.ts +11 -0
- package/dist/server-core/src/auth/discord-oauth.d.ts +14 -0
- package/dist/server-core/src/auth/facebook-oauth.d.ts +14 -0
- package/dist/server-core/src/auth/github-oauth.d.ts +15 -0
- package/dist/server-core/src/auth/gitlab-oauth.d.ts +13 -0
- package/dist/server-core/src/auth/google-oauth.d.ts +14 -0
- package/dist/server-core/src/auth/index.d.ts +23 -0
- package/dist/server-core/src/auth/interfaces.d.ts +309 -0
- package/dist/server-core/src/auth/jwt.d.ts +43 -0
- package/dist/server-core/src/auth/linkedin-oauth.d.ts +18 -0
- package/dist/server-core/src/auth/microsoft-oauth.d.ts +16 -0
- package/dist/server-core/src/auth/middleware.d.ts +81 -0
- package/dist/server-core/src/auth/password.d.ts +22 -0
- package/dist/server-core/src/auth/rate-limiter.d.ts +31 -0
- package/dist/server-core/src/auth/routes.d.ts +27 -0
- package/dist/server-core/src/auth/slack-oauth.d.ts +12 -0
- package/dist/server-core/src/auth/spotify-oauth.d.ts +12 -0
- package/dist/server-core/src/auth/twitter-oauth.d.ts +18 -0
- package/dist/server-core/src/bootstrappers/index.d.ts +0 -0
- package/dist/server-core/src/collections/BackendCollectionRegistry.d.ts +13 -0
- package/dist/server-core/src/collections/loader.d.ts +5 -0
- package/dist/server-core/src/cron/cron-loader.d.ts +17 -0
- package/dist/server-core/src/cron/cron-routes.d.ts +14 -0
- package/dist/server-core/src/cron/cron-scheduler.d.ts +61 -0
- package/dist/server-core/src/cron/cron-store.d.ts +32 -0
- package/dist/server-core/src/cron/index.d.ts +6 -0
- package/dist/server-core/src/db/interfaces.d.ts +18 -0
- package/dist/server-core/src/email/index.d.ts +6 -0
- package/dist/server-core/src/email/smtp-email-service.d.ts +25 -0
- package/dist/server-core/src/email/templates.d.ts +42 -0
- package/dist/server-core/src/email/types.d.ts +107 -0
- package/dist/server-core/src/functions/function-loader.d.ts +17 -0
- package/dist/server-core/src/functions/function-routes.d.ts +10 -0
- package/dist/server-core/src/functions/index.d.ts +3 -0
- package/dist/server-core/src/history/history-routes.d.ts +23 -0
- package/dist/server-core/src/history/index.d.ts +1 -0
- package/dist/server-core/src/index.d.ts +29 -0
- package/dist/server-core/src/init.d.ts +159 -0
- package/dist/server-core/src/serve-spa.d.ts +30 -0
- package/dist/server-core/src/services/driver-registry.d.ts +78 -0
- package/dist/server-core/src/singleton.d.ts +35 -0
- package/dist/server-core/src/storage/LocalStorageController.d.ts +46 -0
- package/dist/server-core/src/storage/S3StorageController.d.ts +36 -0
- package/dist/server-core/src/storage/index.d.ts +25 -0
- package/dist/server-core/src/storage/routes.d.ts +38 -0
- package/dist/server-core/src/storage/storage-registry.d.ts +78 -0
- package/dist/server-core/src/storage/types.d.ts +103 -0
- package/dist/server-core/src/types/index.d.ts +11 -0
- package/dist/server-core/src/utils/dev-port.d.ts +35 -0
- package/dist/server-core/src/utils/logger.d.ts +31 -0
- package/dist/server-core/src/utils/logging.d.ts +9 -0
- package/dist/server-core/src/utils/request-logger.d.ts +19 -0
- package/dist/server-core/src/utils/sql.d.ts +27 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +45 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +160 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +856 -0
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +10 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +23 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +279 -0
- package/dist/types/src/types/properties.d.ts +1176 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +252 -0
- package/dist/types/src/types/translations.d.ts +870 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/history_diff.log +385 -0
- package/jest.config.cjs +16 -0
- package/package.json +86 -0
- package/scratch.ts +9 -0
- package/src/api/ast-schema-editor.ts +289 -0
- package/src/api/collections_for_test/callbacks_test_collection.ts +60 -0
- package/src/api/errors.ts +179 -0
- package/src/api/graphql/graphql-schema-generator.ts +336 -0
- package/src/api/graphql/index.ts +2 -0
- package/src/api/index.ts +11 -0
- package/src/api/openapi-generator.ts +715 -0
- package/src/api/rest/api-generator.ts +472 -0
- package/src/api/rest/index.ts +2 -0
- package/src/api/rest/query-parser.ts +155 -0
- package/src/api/schema-editor-routes.ts +41 -0
- package/src/api/server.ts +248 -0
- package/src/api/types.ts +90 -0
- package/src/auth/admin-routes.ts +529 -0
- package/src/auth/apple-oauth.ts +130 -0
- package/src/auth/bitbucket-oauth.ts +82 -0
- package/src/auth/discord-oauth.ts +83 -0
- package/src/auth/facebook-oauth.ts +72 -0
- package/src/auth/github-oauth.ts +110 -0
- package/src/auth/gitlab-oauth.ts +70 -0
- package/src/auth/google-oauth.ts +48 -0
- package/src/auth/index.ts +34 -0
- package/src/auth/interfaces.ts +363 -0
- package/src/auth/jwt.ts +181 -0
- package/src/auth/linkedin-oauth.ts +81 -0
- package/src/auth/microsoft-oauth.ts +88 -0
- package/src/auth/middleware.ts +384 -0
- package/src/auth/password.ts +77 -0
- package/src/auth/rate-limiter.ts +129 -0
- package/src/auth/routes.ts +788 -0
- package/src/auth/slack-oauth.ts +71 -0
- package/src/auth/spotify-oauth.ts +67 -0
- package/src/auth/twitter-oauth.ts +120 -0
- package/src/bootstrappers/index.ts +1 -0
- package/src/collections/BackendCollectionRegistry.ts +20 -0
- package/src/collections/loader.ts +49 -0
- package/src/cron/cron-loader.ts +89 -0
- package/src/cron/cron-routes.test.ts +265 -0
- package/src/cron/cron-routes.ts +85 -0
- package/src/cron/cron-scheduler.test.ts +421 -0
- package/src/cron/cron-scheduler.ts +413 -0
- package/src/cron/cron-store.ts +163 -0
- package/src/cron/index.ts +6 -0
- package/src/db/interfaces.ts +60 -0
- package/src/email/index.ts +18 -0
- package/src/email/smtp-email-service.ts +91 -0
- package/src/email/templates.ts +388 -0
- package/src/email/types.ts +105 -0
- package/src/functions/function-loader.ts +119 -0
- package/src/functions/function-routes.ts +31 -0
- package/src/functions/index.ts +3 -0
- package/src/history/history-routes.ts +129 -0
- package/src/history/index.ts +2 -0
- package/src/index.ts +66 -0
- package/src/init.ts +727 -0
- package/src/serve-spa.ts +81 -0
- package/src/services/driver-registry.ts +182 -0
- package/src/singleton.test.ts +28 -0
- package/src/singleton.ts +70 -0
- package/src/storage/LocalStorageController.ts +365 -0
- package/src/storage/S3StorageController.ts +298 -0
- package/src/storage/index.ts +43 -0
- package/src/storage/routes.ts +264 -0
- package/src/storage/storage-registry.ts +187 -0
- package/src/storage/types.ts +134 -0
- package/src/types/index.ts +27 -0
- package/src/utils/dev-port.ts +176 -0
- package/src/utils/logger.ts +143 -0
- package/src/utils/logging.ts +38 -0
- package/src/utils/request-logger.ts +66 -0
- package/src/utils/sql.ts +38 -0
- package/test/admin-routes.test.ts +640 -0
- package/test/api-generator.test.ts +501 -0
- package/test/ast-schema-editor.test.ts +63 -0
- package/test/auth-middleware-hono.test.ts +556 -0
- package/test/auth-routes.test.ts +1047 -0
- package/test/driver-registry.test.ts +282 -0
- package/test/error-propagation.test.ts +226 -0
- package/test/errors-hono.test.ts +133 -0
- package/test/errors.test.ts +155 -0
- package/test/jwt-security.test.ts +182 -0
- package/test/jwt.test.ts +324 -0
- package/test/middleware.test.ts +300 -0
- package/test/password.test.ts +165 -0
- package/test/query-parser.test.ts +263 -0
- package/test/rate-limiter.test.ts +102 -0
- package/test/safe-compare.test.ts +66 -0
- package/test/singleton.test.ts +59 -0
- package/test/storage-local.test.ts +271 -0
- package/test/storage-registry.test.ts +282 -0
- package/test/storage-routes.test.ts +222 -0
- package/test/storage-s3.test.ts +304 -0
- package/test-ast.ts +28 -0
- package/test.ts +6 -0
- package/test_output.txt +1133 -0
- package/tsconfig.json +49 -0
- package/tsconfig.prod.json +20 -0
- package/vite.config.ts +80 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication Abstraction Interfaces
|
|
4
|
+
*
|
|
5
|
+
* These interfaces define the contracts for authentication-related operations.
|
|
6
|
+
* Implementations can use different databases (PostgreSQL, MongoDB, etc.) to
|
|
7
|
+
* store user, role, and token data.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* User data structure
|
|
11
|
+
*/
|
|
12
|
+
export interface UserData {
|
|
13
|
+
id: string;
|
|
14
|
+
email: string;
|
|
15
|
+
passwordHash?: string | null;
|
|
16
|
+
displayName?: string | null;
|
|
17
|
+
photoUrl?: string | null;
|
|
18
|
+
emailVerified: boolean;
|
|
19
|
+
emailVerificationToken?: string | null;
|
|
20
|
+
emailVerificationSentAt?: Date | null;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Data for creating a new user
|
|
26
|
+
*/
|
|
27
|
+
export interface CreateUserData {
|
|
28
|
+
email: string;
|
|
29
|
+
passwordHash?: string;
|
|
30
|
+
displayName?: string;
|
|
31
|
+
photoUrl?: string;
|
|
32
|
+
emailVerified?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* User Identity Data (OAuth accounts linked to user)
|
|
36
|
+
*/
|
|
37
|
+
export interface UserIdentityData {
|
|
38
|
+
id: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
provider: string;
|
|
41
|
+
providerId: string;
|
|
42
|
+
profileData?: Record<string, unknown> | null;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Standardized profile data returned by an OAuth provider verification payload
|
|
48
|
+
*/
|
|
49
|
+
export interface OAuthProviderProfile {
|
|
50
|
+
providerId: string;
|
|
51
|
+
email: string;
|
|
52
|
+
displayName?: string | null;
|
|
53
|
+
photoUrl?: string | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Pluggable OAuth Provider integration strategy
|
|
57
|
+
*/
|
|
58
|
+
export interface OAuthProvider<T = unknown> {
|
|
59
|
+
/** The identifier of the provider (e.g. "github", "google") */
|
|
60
|
+
id: string;
|
|
61
|
+
/** Zod schema validating the expected request payload (e.g. { code: string }) */
|
|
62
|
+
schema: z.ZodSchema<T>;
|
|
63
|
+
/** Verify external tokens/codes and return a standardized user profile */
|
|
64
|
+
verify: (payload: T) => Promise<OAuthProviderProfile | null>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Role data structure
|
|
68
|
+
*/
|
|
69
|
+
export interface RoleData {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
isAdmin: boolean;
|
|
73
|
+
defaultPermissions: {
|
|
74
|
+
read?: boolean;
|
|
75
|
+
create?: boolean;
|
|
76
|
+
edit?: boolean;
|
|
77
|
+
delete?: boolean;
|
|
78
|
+
} | null;
|
|
79
|
+
collectionPermissions: Record<string, {
|
|
80
|
+
read?: boolean;
|
|
81
|
+
create?: boolean;
|
|
82
|
+
edit?: boolean;
|
|
83
|
+
delete?: boolean;
|
|
84
|
+
}> | null;
|
|
85
|
+
config: Record<string, unknown> | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Data for creating a new role
|
|
89
|
+
*/
|
|
90
|
+
export interface CreateRoleData {
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
isAdmin?: boolean;
|
|
94
|
+
defaultPermissions?: RoleData["defaultPermissions"];
|
|
95
|
+
collectionPermissions?: RoleData["collectionPermissions"];
|
|
96
|
+
config?: RoleData["config"];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Refresh token info
|
|
100
|
+
*/
|
|
101
|
+
export interface RefreshTokenInfo {
|
|
102
|
+
id: string;
|
|
103
|
+
userId: string;
|
|
104
|
+
tokenHash: string;
|
|
105
|
+
expiresAt: Date;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
userAgent?: string | null;
|
|
108
|
+
ipAddress?: string | null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Password reset token info
|
|
112
|
+
*/
|
|
113
|
+
export interface PasswordResetTokenInfo {
|
|
114
|
+
userId: string;
|
|
115
|
+
expiresAt: Date;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Options for paginated user listing
|
|
119
|
+
*/
|
|
120
|
+
export interface ListUsersOptions {
|
|
121
|
+
/** Max results per page (default 25) */
|
|
122
|
+
limit?: number;
|
|
123
|
+
/** Number of results to skip (default 0) */
|
|
124
|
+
offset?: number;
|
|
125
|
+
/** Search term — matches against email and displayName (case-insensitive) */
|
|
126
|
+
search?: string;
|
|
127
|
+
/** Field to sort by (default "createdAt") */
|
|
128
|
+
orderBy?: string;
|
|
129
|
+
/** Sort direction (default "desc") */
|
|
130
|
+
orderDir?: "asc" | "desc";
|
|
131
|
+
/** Filter by role ID */
|
|
132
|
+
roleId?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Result of a paginated user listing
|
|
136
|
+
*/
|
|
137
|
+
export interface PaginatedUsersResult {
|
|
138
|
+
users: UserData[];
|
|
139
|
+
/** Total number of users matching the filters (ignoring limit/offset) */
|
|
140
|
+
total: number;
|
|
141
|
+
limit: number;
|
|
142
|
+
offset: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Abstract user repository interface.
|
|
146
|
+
* Handles all user-related database operations.
|
|
147
|
+
*/
|
|
148
|
+
export interface UserRepository {
|
|
149
|
+
/**
|
|
150
|
+
* Create a new user
|
|
151
|
+
*/
|
|
152
|
+
createUser(data: CreateUserData): Promise<UserData>;
|
|
153
|
+
/**
|
|
154
|
+
* Get a user by ID
|
|
155
|
+
*/
|
|
156
|
+
getUserById(id: string): Promise<UserData | null>;
|
|
157
|
+
/**
|
|
158
|
+
* Get a user by email
|
|
159
|
+
*/
|
|
160
|
+
getUserByEmail(email: string): Promise<UserData | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Get a user by an OAuth identity
|
|
163
|
+
*/
|
|
164
|
+
getUserByIdentity(provider: string, providerId: string): Promise<UserData | null>;
|
|
165
|
+
/**
|
|
166
|
+
* Get all identities linked to a user
|
|
167
|
+
*/
|
|
168
|
+
getUserIdentities(userId: string): Promise<UserIdentityData[]>;
|
|
169
|
+
/**
|
|
170
|
+
* Link a new OAuth identity to a user
|
|
171
|
+
*/
|
|
172
|
+
linkUserIdentity(userId: string, provider: string, providerId: string, profileData?: Record<string, unknown>): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Update a user
|
|
175
|
+
*/
|
|
176
|
+
updateUser(id: string, data: Partial<Omit<CreateUserData, "id">>): Promise<UserData | null>;
|
|
177
|
+
/**
|
|
178
|
+
* Delete a user
|
|
179
|
+
*/
|
|
180
|
+
deleteUser(id: string): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* List all users (unbounded — use listUsersPaginated for large datasets)
|
|
183
|
+
*/
|
|
184
|
+
listUsers(): Promise<UserData[]>;
|
|
185
|
+
/**
|
|
186
|
+
* List users with server-side pagination, search, and sorting.
|
|
187
|
+
*/
|
|
188
|
+
listUsersPaginated(options?: ListUsersOptions): Promise<PaginatedUsersResult>;
|
|
189
|
+
/**
|
|
190
|
+
* Update user's password hash
|
|
191
|
+
*/
|
|
192
|
+
updatePassword(id: string, passwordHash: string): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Set email verification status
|
|
195
|
+
*/
|
|
196
|
+
setEmailVerified(id: string, verified: boolean): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Set email verification token
|
|
199
|
+
*/
|
|
200
|
+
setVerificationToken(id: string, token: string | null): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Find user by email verification token
|
|
203
|
+
*/
|
|
204
|
+
getUserByVerificationToken(token: string): Promise<UserData | null>;
|
|
205
|
+
/**
|
|
206
|
+
* Get roles for a user
|
|
207
|
+
*/
|
|
208
|
+
getUserRoles(userId: string): Promise<RoleData[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Get role IDs for a user
|
|
211
|
+
*/
|
|
212
|
+
getUserRoleIds(userId: string): Promise<string[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Set roles for a user (replaces existing roles)
|
|
215
|
+
*/
|
|
216
|
+
setUserRoles(userId: string, roleIds: string[]): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Assign a specific role to a new user
|
|
219
|
+
*/
|
|
220
|
+
assignDefaultRole(userId: string, roleId: string): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Get user with their roles
|
|
223
|
+
*/
|
|
224
|
+
getUserWithRoles(userId: string): Promise<{
|
|
225
|
+
user: UserData;
|
|
226
|
+
roles: RoleData[];
|
|
227
|
+
} | null>;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Abstract role repository interface.
|
|
231
|
+
* Handles all role-related database operations.
|
|
232
|
+
*/
|
|
233
|
+
export interface RoleRepository {
|
|
234
|
+
/**
|
|
235
|
+
* Get a role by ID
|
|
236
|
+
*/
|
|
237
|
+
getRoleById(id: string): Promise<RoleData | null>;
|
|
238
|
+
/**
|
|
239
|
+
* List all roles
|
|
240
|
+
*/
|
|
241
|
+
listRoles(): Promise<RoleData[]>;
|
|
242
|
+
/**
|
|
243
|
+
* Create a new role
|
|
244
|
+
*/
|
|
245
|
+
createRole(data: CreateRoleData): Promise<RoleData>;
|
|
246
|
+
/**
|
|
247
|
+
* Update a role
|
|
248
|
+
*/
|
|
249
|
+
updateRole(id: string, data: Partial<Omit<RoleData, "id">>): Promise<RoleData | null>;
|
|
250
|
+
/**
|
|
251
|
+
* Delete a role
|
|
252
|
+
*/
|
|
253
|
+
deleteRole(id: string): Promise<void>;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Abstract token repository interface.
|
|
257
|
+
* Handles refresh tokens and password reset tokens.
|
|
258
|
+
*/
|
|
259
|
+
export interface TokenRepository {
|
|
260
|
+
/**
|
|
261
|
+
* Create a new refresh token
|
|
262
|
+
*/
|
|
263
|
+
createRefreshToken(userId: string, tokenHash: string, expiresAt: Date, userAgent?: string, ipAddress?: string): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Find a refresh token by hash
|
|
266
|
+
*/
|
|
267
|
+
findRefreshTokenByHash(tokenHash: string): Promise<RefreshTokenInfo | null>;
|
|
268
|
+
/**
|
|
269
|
+
* Delete a refresh token by hash
|
|
270
|
+
*/
|
|
271
|
+
deleteRefreshToken(tokenHash: string): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Delete all refresh tokens for a user
|
|
274
|
+
*/
|
|
275
|
+
deleteAllRefreshTokensForUser(userId: string): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* List all refresh tokens for a user
|
|
278
|
+
*/
|
|
279
|
+
listRefreshTokensForUser(userId: string): Promise<RefreshTokenInfo[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Delete a specific refresh token by its primary key ID
|
|
282
|
+
*/
|
|
283
|
+
deleteRefreshTokenById(id: string, userId: string): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Create a password reset token
|
|
286
|
+
*/
|
|
287
|
+
createPasswordResetToken(userId: string, tokenHash: string, expiresAt: Date): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Find a valid (not expired, not used) password reset token by hash
|
|
290
|
+
*/
|
|
291
|
+
findValidPasswordResetToken(tokenHash: string): Promise<PasswordResetTokenInfo | null>;
|
|
292
|
+
/**
|
|
293
|
+
* Mark a password reset token as used
|
|
294
|
+
*/
|
|
295
|
+
markPasswordResetTokenUsed(tokenHash: string): Promise<void>;
|
|
296
|
+
/**
|
|
297
|
+
* Delete all password reset tokens for a user
|
|
298
|
+
*/
|
|
299
|
+
deleteAllPasswordResetTokensForUser(userId: string): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Clean up expired tokens
|
|
302
|
+
*/
|
|
303
|
+
deleteExpiredTokens(): Promise<void>;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Combined auth repository interface for convenience
|
|
307
|
+
*/
|
|
308
|
+
export interface AuthRepository extends UserRepository, RoleRepository, TokenRepository {
|
|
309
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface JwtConfig {
|
|
2
|
+
secret: string;
|
|
3
|
+
accessExpiresIn?: string;
|
|
4
|
+
refreshExpiresIn?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AccessTokenPayload {
|
|
7
|
+
userId: string;
|
|
8
|
+
roles: string[];
|
|
9
|
+
uid?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configure JWT settings - call this during initialization.
|
|
13
|
+
* Validates the secret strength to prevent deployment with default/weak secrets.
|
|
14
|
+
*/
|
|
15
|
+
export declare function configureJwt(config: JwtConfig): void;
|
|
16
|
+
/**
|
|
17
|
+
* Generate an access token (short-lived, 1 hour by default)
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateAccessToken(userId: string, roles: string[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get the expiration time of an access token in milliseconds from now
|
|
22
|
+
*/
|
|
23
|
+
export declare function getAccessTokenExpiryMs(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Get the expiration timestamp for an access token
|
|
26
|
+
*/
|
|
27
|
+
export declare function getAccessTokenExpiry(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Verify and decode an access token
|
|
30
|
+
*/
|
|
31
|
+
export declare function verifyAccessToken(token: string): AccessTokenPayload | null;
|
|
32
|
+
/**
|
|
33
|
+
* Generate a random refresh token (long-lived, 30 days by default)
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateRefreshToken(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Hash a refresh token for database storage (don't store raw tokens)
|
|
38
|
+
*/
|
|
39
|
+
export declare function hashRefreshToken(token: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate refresh token expiration date
|
|
42
|
+
*/
|
|
43
|
+
export declare function getRefreshTokenExpiry(): Date;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
export interface LinkedinUserInfo {
|
|
3
|
+
linkedinId: string;
|
|
4
|
+
email: string;
|
|
5
|
+
displayName: string | null;
|
|
6
|
+
photoUrl: string | null;
|
|
7
|
+
emailVerified: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a LinkedIn OAuth Provider integration
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLinkedinProvider(config: {
|
|
13
|
+
clientId: string;
|
|
14
|
+
clientSecret: string;
|
|
15
|
+
}): OAuthProvider<{
|
|
16
|
+
code: string;
|
|
17
|
+
redirectUri: string;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Microsoft / Entra ID (Azure AD) OAuth Provider integration.
|
|
4
|
+
*
|
|
5
|
+
* Supports both personal Microsoft accounts and work/school (Azure AD) accounts
|
|
6
|
+
* via the "common" tenant endpoint. Uses the authorization code flow.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMicrosoftProvider(config: {
|
|
9
|
+
clientId: string;
|
|
10
|
+
clientSecret: string;
|
|
11
|
+
/** Tenant ID. Defaults to "common" which allows both personal and organizational accounts. */
|
|
12
|
+
tenantId?: string;
|
|
13
|
+
}): OAuthProvider<{
|
|
14
|
+
code: string;
|
|
15
|
+
redirectUri: string;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { MiddlewareHandler, Context } from "hono";
|
|
2
|
+
import { DataDriver } from "@rebasepro/types";
|
|
3
|
+
import { AccessTokenPayload } from "./jwt";
|
|
4
|
+
import { HonoEnv } from "../api/types";
|
|
5
|
+
/**
|
|
6
|
+
* Result from a custom auth validator.
|
|
7
|
+
* - `false`/`null`/`undefined` = not authenticated
|
|
8
|
+
* - `true` = authenticated as default user
|
|
9
|
+
* - object with `userId` or `uid` = authenticated with user info
|
|
10
|
+
*/
|
|
11
|
+
export type AuthResult = boolean | null | undefined | {
|
|
12
|
+
userId?: string;
|
|
13
|
+
uid?: string;
|
|
14
|
+
roles?: string[];
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Options for creating an auth middleware via createAuthMiddleware()
|
|
19
|
+
*/
|
|
20
|
+
export interface AuthMiddlewareOptions {
|
|
21
|
+
/** DataDriver to scope via withAuth() for RLS */
|
|
22
|
+
driver: DataDriver;
|
|
23
|
+
/**
|
|
24
|
+
* If true, return 401 when no valid token is present.
|
|
25
|
+
*
|
|
26
|
+
* **Defaults to `true` (secure by default).** Set to `false` only for
|
|
27
|
+
* intentionally public endpoints where access control is fully delegated
|
|
28
|
+
* to Postgres Row-Level Security policies.
|
|
29
|
+
*/
|
|
30
|
+
requireAuth?: boolean;
|
|
31
|
+
/** Optional custom validator (for non-JWT auth, e.g. Firebase Auth) */
|
|
32
|
+
validator?: (c: Context<HonoEnv>) => Promise<AuthResult>;
|
|
33
|
+
/**
|
|
34
|
+
* A static secret key for server-to-server / script authentication.
|
|
35
|
+
*
|
|
36
|
+
* When a request sends `Authorization: Bearer <key>` and the key matches
|
|
37
|
+
* this value, the request is granted admin-level access (uid: `service`,
|
|
38
|
+
* roles: `["admin"]`) **without** JWT verification. The driver is scoped
|
|
39
|
+
* via `withAuth()` with the service identity.
|
|
40
|
+
*
|
|
41
|
+
* This is the Rebase equivalent of a Firebase Service Account key.
|
|
42
|
+
* Set via `REBASE_SERVICE_KEY` in `.env` and pass through the backend config.
|
|
43
|
+
*
|
|
44
|
+
* **Security:** The comparison uses constant-time equality to prevent
|
|
45
|
+
* timing attacks. The key must be at least 32 characters.
|
|
46
|
+
*/
|
|
47
|
+
serviceKey?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hono middleware that requires a valid JWT token
|
|
51
|
+
* Returns 401 if token is missing or invalid
|
|
52
|
+
*/
|
|
53
|
+
export declare const requireAuth: MiddlewareHandler<HonoEnv>;
|
|
54
|
+
/**
|
|
55
|
+
* Factory that creates a requireAuth middleware with optional service key support.
|
|
56
|
+
*
|
|
57
|
+
* When `serviceKey` is provided, the middleware will check if the Bearer token
|
|
58
|
+
* matches the service key using constant-time comparison. If it matches, the
|
|
59
|
+
* request is authenticated as a service user with admin privileges.
|
|
60
|
+
*
|
|
61
|
+
* This allows admin routes (which use standalone requireAuth + requireAdmin)
|
|
62
|
+
* to be accessed via service keys for scripts and server-to-server calls.
|
|
63
|
+
*/
|
|
64
|
+
export declare function createRequireAuth(options?: {
|
|
65
|
+
serviceKey?: string;
|
|
66
|
+
}): MiddlewareHandler<HonoEnv>;
|
|
67
|
+
/**
|
|
68
|
+
* Middleware that requires the user to have an admin or schema-admin role.
|
|
69
|
+
* Must be used AFTER requireAuth or on a route where user is guaranteed.
|
|
70
|
+
*/
|
|
71
|
+
export declare const requireAdmin: MiddlewareHandler<HonoEnv>;
|
|
72
|
+
/**
|
|
73
|
+
* Middleware that optionally extracts user from JWT
|
|
74
|
+
* Does not return 401 if token is missing - allows anonymous access
|
|
75
|
+
*/
|
|
76
|
+
export declare const optionalAuth: MiddlewareHandler<HonoEnv>;
|
|
77
|
+
/**
|
|
78
|
+
* Extract user from token - for WebSocket authentication
|
|
79
|
+
*/
|
|
80
|
+
export declare function extractUserFromToken(token: string): AccessTokenPayload | null;
|
|
81
|
+
export declare function createAuthMiddleware(options: AuthMiddlewareOptions): MiddlewareHandler<HonoEnv>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface PasswordValidationResult {
|
|
2
|
+
valid: boolean;
|
|
3
|
+
errors: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Password requirements:
|
|
7
|
+
* - Minimum 8 characters
|
|
8
|
+
* - At least 1 uppercase letter
|
|
9
|
+
* - At least 1 lowercase letter
|
|
10
|
+
* - At least 1 number
|
|
11
|
+
*/
|
|
12
|
+
export declare function validatePasswordStrength(password: string): PasswordValidationResult;
|
|
13
|
+
/**
|
|
14
|
+
* Hash a password using Node's built-in scrypt
|
|
15
|
+
* Returns format: salt:hash (both hex encoded)
|
|
16
|
+
*/
|
|
17
|
+
export declare function hashPassword(password: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Verify a password against a scrypt hash
|
|
20
|
+
* Expects format: salt:hash (both hex encoded)
|
|
21
|
+
*/
|
|
22
|
+
export declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MiddlewareHandler } from "hono";
|
|
2
|
+
import { HonoEnv } from "../api/types";
|
|
3
|
+
interface RateLimiterOptions {
|
|
4
|
+
/** Time window in milliseconds (default: 15 minutes) */
|
|
5
|
+
windowMs?: number;
|
|
6
|
+
/** Maximum requests per window (default: 100) */
|
|
7
|
+
limit?: number;
|
|
8
|
+
/** Key generator function. Defaults to IP-based keying. */
|
|
9
|
+
keyGenerator?: (c: Parameters<MiddlewareHandler<HonoEnv>>[0]) => string;
|
|
10
|
+
/** Custom message for rate limit responses */
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a rate-limiting middleware.
|
|
15
|
+
*
|
|
16
|
+
* Uses a sliding window algorithm: only timestamps within the last
|
|
17
|
+
* `windowMs` milliseconds are counted. Old entries are garbage-collected
|
|
18
|
+
* every `windowMs` to prevent unbounded memory growth.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRateLimiter(options?: RateLimiterOptions): MiddlewareHandler<HonoEnv>;
|
|
21
|
+
/**
|
|
22
|
+
* Pre-configured rate limiter for general auth endpoints (login, register).
|
|
23
|
+
* 200 requests per 15 minutes per IP.
|
|
24
|
+
*/
|
|
25
|
+
export declare const defaultAuthLimiter: MiddlewareHandler<HonoEnv>;
|
|
26
|
+
/**
|
|
27
|
+
* Pre-configured strict rate limiter for sensitive endpoints (password reset, verification).
|
|
28
|
+
* 50 requests per 15 minutes per IP.
|
|
29
|
+
*/
|
|
30
|
+
export declare const strictAuthLimiter: MiddlewareHandler<HonoEnv>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { AuthRepository, OAuthProvider } from "./interfaces";
|
|
3
|
+
import { EmailService, EmailConfig } from "../email";
|
|
4
|
+
import { HonoEnv } from "../api/types";
|
|
5
|
+
/**
|
|
6
|
+
* Shared configuration for auth and admin route factories.
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthModuleConfig {
|
|
9
|
+
authRepo: AuthRepository;
|
|
10
|
+
emailService?: EmailService;
|
|
11
|
+
emailConfig?: EmailConfig;
|
|
12
|
+
/** Allow new user registration (default: false). */
|
|
13
|
+
allowRegistration?: boolean;
|
|
14
|
+
/** Default role ID to assign to new users (default: none). Must NOT be "admin". */
|
|
15
|
+
defaultRole?: string;
|
|
16
|
+
/** Optional array of OAuth providers */
|
|
17
|
+
oauthProviders?: OAuthProvider[];
|
|
18
|
+
/** When true, blocks all self-registration regardless of `allowRegistration`. */
|
|
19
|
+
disableSelfRegistration?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback that checks if bootstrap has already been completed.
|
|
22
|
+
* Used by GET /auth/config to report `needsSetup` status.
|
|
23
|
+
* When not provided, falls back to checking if any users exist.
|
|
24
|
+
*/
|
|
25
|
+
isBootstrapCompleted?: () => Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createAuthRoutes(config: AuthModuleConfig): Hono<HonoEnv>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Slack OAuth Provider integration (OAuth 2.0 / "Sign in with Slack").
|
|
4
|
+
* Uses the OpenID Connect flow with the "openid,email,profile" scopes.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createSlackProvider(config: {
|
|
7
|
+
clientId: string;
|
|
8
|
+
clientSecret: string;
|
|
9
|
+
}): OAuthProvider<{
|
|
10
|
+
code: string;
|
|
11
|
+
redirectUri: string;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Spotify OAuth Provider integration.
|
|
4
|
+
* Uses the authorization code flow with the "user-read-email" scope.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createSpotifyProvider(config: {
|
|
7
|
+
clientId: string;
|
|
8
|
+
clientSecret: string;
|
|
9
|
+
}): OAuthProvider<{
|
|
10
|
+
code: string;
|
|
11
|
+
redirectUri: string;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Twitter/X OAuth 2.0 Provider integration.
|
|
4
|
+
*
|
|
5
|
+
* Uses OAuth 2.0 with PKCE (authorization code flow). The frontend must include
|
|
6
|
+
* the PKCE `code_verifier` when sending the authorization code.
|
|
7
|
+
*
|
|
8
|
+
* Twitter API v2 requires the "tweet.read" and "users.read" scopes at minimum,
|
|
9
|
+
* plus "offline.access" if refresh tokens are needed on Twitter's side.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createTwitterProvider(config: {
|
|
12
|
+
clientId: string;
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
}): OAuthProvider<{
|
|
15
|
+
code: string;
|
|
16
|
+
redirectUri: string;
|
|
17
|
+
codeVerifier: string;
|
|
18
|
+
}>;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CollectionRegistry } from "@rebasepro/common";
|
|
2
|
+
import { CollectionRegistryInterface } from "../db/interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Backend-agnostic collection registry.
|
|
5
|
+
* Satisfies CollectionRegistryInterface through inheritance from CollectionRegistry.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BackendCollectionRegistry extends CollectionRegistry implements CollectionRegistryInterface {
|
|
8
|
+
/**
|
|
9
|
+
* Get the available relation keys for a given collection path.
|
|
10
|
+
* Maps from the collection's relation property names to the relation names.
|
|
11
|
+
*/
|
|
12
|
+
getRelationKeysForCollection(collectionPath: string): string[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CronJobDefinition } from "@rebasepro/types";
|
|
2
|
+
export interface LoadedCronJob {
|
|
3
|
+
/** Job ID derived from filename (e.g. "cleanup-sessions"). */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The full definition. */
|
|
6
|
+
definition: CronJobDefinition;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Auto-discover cron job files from a directory.
|
|
10
|
+
*
|
|
11
|
+
* Each file should default-export a `CronJobDefinition`.
|
|
12
|
+
* The filename (without extension) becomes the job ID:
|
|
13
|
+
* `crons/cleanup-sessions.ts` → id = "cleanup-sessions"
|
|
14
|
+
*
|
|
15
|
+
* Follows the same discovery pattern as `loadFunctionsFromDirectory`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadCronJobsFromDirectory(directory: string): Promise<LoadedCronJob[]>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { HonoEnv } from "../api/types";
|
|
3
|
+
import type { CronScheduler } from "./cron-scheduler";
|
|
4
|
+
/**
|
|
5
|
+
* Create admin REST routes for managing cron jobs.
|
|
6
|
+
*
|
|
7
|
+
* Routes:
|
|
8
|
+
* GET / → list all cron jobs
|
|
9
|
+
* GET /:id → get a single job's status
|
|
10
|
+
* POST /:id/trigger → manually trigger a job
|
|
11
|
+
* GET /:id/logs → get execution logs for a job
|
|
12
|
+
* PUT /:id → update job (enable/disable)
|
|
13
|
+
*/
|
|
14
|
+
export declare function createCronRoutes(scheduler: CronScheduler): Hono<HonoEnv>;
|