@rebasepro/server-core 0.0.1-canary.4d4fb3e
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 +48 -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 +36 -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 +12 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/index-BeMqpmfQ.js +239 -0
- package/dist/index-BeMqpmfQ.js.map +1 -0
- package/dist/index-bl4J3lNb.js +55823 -0
- package/dist/index-bl4J3lNb.js.map +1 -0
- package/dist/index.es.js +58 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +56062 -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 +2 -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 +7 -0
- package/dist/server-core/src/auth/google-oauth.d.ts +20 -0
- package/dist/server-core/src/auth/index.d.ts +12 -0
- package/dist/server-core/src/auth/interfaces.d.ts +270 -0
- package/dist/server-core/src/auth/jwt.d.ts +42 -0
- package/dist/server-core/src/auth/middleware.d.ts +56 -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 +17 -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/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 +33 -0
- package/dist/server-core/src/email/types.d.ts +110 -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 +24 -0
- package/dist/server-core/src/init.d.ts +49 -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/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 +18 -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 +91 -0
- package/dist/server-core/src/types/index.d.ts +11 -0
- package/dist/server-core/src/utils/logging.d.ts +9 -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 +117 -0
- package/dist/types/src/controllers/client.d.ts +58 -0
- package/dist/types/src/controllers/collection_registry.d.ts +44 -0
- package/dist/types/src/controllers/customization_controller.d.ts +54 -0
- package/dist/types/src/controllers/data.d.ts +141 -0
- package/dist/types/src/controllers/data_driver.d.ts +168 -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/index.d.ts +17 -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 +51 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +89 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +173 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +101 -0
- package/dist/types/src/types/backend.d.ts +533 -0
- package/dist/types/src/types/builders.d.ts +14 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +812 -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 +9 -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 +22 -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 +225 -0
- package/dist/types/src/types/properties.d.ts +1091 -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 +228 -0
- package/dist/types/src/types/translations.d.ts +826 -0
- package/dist/types/src/types/user_management_delegate.d.ts +120 -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 +8 -0
- package/src/api/ast-schema-editor.ts +289 -0
- package/src/api/collections_for_test/callbacks_test_collection.ts +57 -0
- package/src/api/errors.ts +155 -0
- package/src/api/graphql/graphql-schema-generator.ts +334 -0
- package/src/api/graphql/index.ts +2 -0
- package/src/api/index.ts +11 -0
- package/src/api/openapi-generator.ts +160 -0
- package/src/api/rest/api-generator.ts +466 -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 +39 -0
- package/src/api/server.ts +245 -0
- package/src/api/types.ts +90 -0
- package/src/auth/admin-routes.ts +488 -0
- package/src/auth/google-oauth.ts +60 -0
- package/src/auth/index.ts +21 -0
- package/src/auth/interfaces.ts +316 -0
- package/src/auth/jwt.ts +164 -0
- package/src/auth/middleware.ts +235 -0
- package/src/auth/password.ts +75 -0
- package/src/auth/rate-limiter.ts +129 -0
- package/src/auth/routes.ts +730 -0
- package/src/bootstrappers/index.ts +1 -0
- package/src/collections/BackendCollectionRegistry.ts +20 -0
- package/src/collections/loader.ts +49 -0
- package/src/db/interfaces.ts +60 -0
- package/src/email/index.ts +17 -0
- package/src/email/smtp-email-service.ts +88 -0
- package/src/email/templates.ts +301 -0
- package/src/email/types.ts +112 -0
- package/src/functions/function-loader.ts +91 -0
- package/src/functions/function-routes.ts +31 -0
- package/src/functions/index.ts +3 -0
- package/src/history/history-routes.ts +128 -0
- package/src/history/index.ts +2 -0
- package/src/index.ts +56 -0
- package/src/init.ts +309 -0
- package/src/serve-spa.ts +81 -0
- package/src/services/driver-registry.ts +182 -0
- package/src/storage/LocalStorageController.ts +368 -0
- package/src/storage/S3StorageController.ts +295 -0
- package/src/storage/index.ts +32 -0
- package/src/storage/routes.ts +247 -0
- package/src/storage/storage-registry.ts +187 -0
- package/src/storage/types.ts +122 -0
- package/src/types/index.ts +27 -0
- package/src/utils/logging.ts +35 -0
- package/src/utils/sql.ts +38 -0
- package/test/admin-routes.test.ts +591 -0
- package/test/api-generator.test.ts +458 -0
- package/test/ast-schema-editor.test.ts +61 -0
- package/test/auth-middleware-hono.test.ts +321 -0
- package/test/auth-routes.test.ts +868 -0
- package/test/driver-registry.test.ts +280 -0
- package/test/errors-hono.test.ts +133 -0
- package/test/errors.test.ts +150 -0
- package/test/jwt-security.test.ts +173 -0
- package/test/jwt.test.ts +311 -0
- package/test/middleware.test.ts +295 -0
- package/test/password.test.ts +165 -0
- package/test/query-parser.test.ts +258 -0
- package/test/rate-limiter.test.ts +102 -0
- package/test/storage-local.test.ts +278 -0
- package/test/storage-registry.test.ts +280 -0
- package/test/storage-routes.test.ts +218 -0
- package/test/storage-s3.test.ts +301 -0
- package/test-ast.ts +28 -0
- package/test_output.txt +1133 -0
- package/tsconfig.json +49 -0
- package/tsconfig.prod.json +20 -0
- package/vite.config.ts +78 -0
- package/vite.config.ts.timestamp-1775065397568-8a853255edf6e.mjs +46 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class AstSchemaEditor {
|
|
2
|
+
private project;
|
|
3
|
+
private collectionsDir;
|
|
4
|
+
constructor(collectionsDir: string);
|
|
5
|
+
/**
|
|
6
|
+
* Sanitize collectionId to prevent path traversal attacks.
|
|
7
|
+
* Only allows alphanumeric characters, underscores, and hyphens.
|
|
8
|
+
*/
|
|
9
|
+
private sanitizeCollectionId;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a file path and ensure it falls within the collectionsDir.
|
|
12
|
+
*/
|
|
13
|
+
private safePath;
|
|
14
|
+
private getCollectionFile;
|
|
15
|
+
private getCollectionObject;
|
|
16
|
+
private convertJsonToAstString;
|
|
17
|
+
saveProperty(collectionId: string, propertyKey: string, propertyConfig: Record<string, unknown>): Promise<void>;
|
|
18
|
+
deleteProperty(collectionId: string, propertyKey: string): Promise<void>;
|
|
19
|
+
saveCollection(collectionId: string, collectionData: Record<string, unknown>): Promise<void>;
|
|
20
|
+
deleteCollection(collectionId: string): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ErrorHandler } from "hono";
|
|
2
|
+
/**
|
|
3
|
+
* Standardized API error class.
|
|
4
|
+
* Throw this from any route handler — the errorHandler middleware
|
|
5
|
+
* will format it into `{ error: { message, code, details? } }`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApiError extends Error {
|
|
8
|
+
readonly statusCode: number;
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly details?: unknown;
|
|
11
|
+
constructor(statusCode: number, code: string, message: string, details?: unknown);
|
|
12
|
+
static badRequest(message: string, code?: string, details?: unknown): ApiError;
|
|
13
|
+
static unauthorized(message: string, code?: string): ApiError;
|
|
14
|
+
static forbidden(message: string, code?: string): ApiError;
|
|
15
|
+
static notFound(message: string, code?: string): ApiError;
|
|
16
|
+
static conflict(message: string, code?: string): ApiError;
|
|
17
|
+
static internal(message: string, code?: string): ApiError;
|
|
18
|
+
static serviceUnavailable(message: string, code?: string): ApiError;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Canonical error response shape:
|
|
22
|
+
* `{ error: { message: string, code: string, details?: unknown } }`
|
|
23
|
+
*/
|
|
24
|
+
export interface ErrorResponse {
|
|
25
|
+
error: {
|
|
26
|
+
message: string;
|
|
27
|
+
code: string;
|
|
28
|
+
details?: unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hono error-handling middleware (`app.onError`).
|
|
33
|
+
* Converts any error into the canonical `{ error: { message, code } }` shape.
|
|
34
|
+
*/
|
|
35
|
+
export declare const errorHandler: ErrorHandler;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GraphQLSchema } from "graphql";
|
|
2
|
+
import { DataDriver, EntityCollection } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* Lightweight GraphQL schema generator that leverages existing DataDriver
|
|
5
|
+
* No duplication - uses your existing data layer and services
|
|
6
|
+
*/
|
|
7
|
+
export declare class GraphQLSchemaGenerator {
|
|
8
|
+
private collections;
|
|
9
|
+
private driver;
|
|
10
|
+
private typeRegistry;
|
|
11
|
+
private inputTypeRegistry;
|
|
12
|
+
constructor(collections: EntityCollection[], driver: DataDriver);
|
|
13
|
+
/**
|
|
14
|
+
* Generate complete GraphQL schema using existing DataDriver
|
|
15
|
+
*/
|
|
16
|
+
generateSchema(): GraphQLSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Create GraphQL type for an entity collection
|
|
19
|
+
*/
|
|
20
|
+
private createEntityType;
|
|
21
|
+
private convertPropertyToField;
|
|
22
|
+
private createInputType;
|
|
23
|
+
private convertPropertyToInputType;
|
|
24
|
+
/**
|
|
25
|
+
* Create Query type using existing DataDriver methods
|
|
26
|
+
*/
|
|
27
|
+
private createQueryType;
|
|
28
|
+
/**
|
|
29
|
+
* Create Mutation type using existing DataDriver methods
|
|
30
|
+
*/
|
|
31
|
+
private createMutationType;
|
|
32
|
+
private getTypeName;
|
|
33
|
+
private getSingleQueryName;
|
|
34
|
+
private getListQueryName;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./graphql-schema-generator";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API generation infrastructure for Rebase
|
|
3
|
+
* Automatically generates GraphQL and REST APIs from EntityCollection definitions
|
|
4
|
+
*/
|
|
5
|
+
export * from "./graphql";
|
|
6
|
+
export * from "./rest";
|
|
7
|
+
export * from "./types";
|
|
8
|
+
export * from "./errors";
|
|
9
|
+
export * from "./server";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { DataDriver, EntityCollection } from "@rebasepro/types";
|
|
3
|
+
import { HonoEnv } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight REST API generator that leverages existing Rebase DataDriver.
|
|
6
|
+
* Supports `include` query parameter for eager-loading relations via Drizzle.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RestApiGenerator {
|
|
9
|
+
private collections;
|
|
10
|
+
private router;
|
|
11
|
+
private driver;
|
|
12
|
+
constructor(collections: EntityCollection[], driver: DataDriver);
|
|
13
|
+
/**
|
|
14
|
+
* Generate REST routes using existing DataDriver
|
|
15
|
+
*/
|
|
16
|
+
generateRoutes(): Hono<HonoEnv>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the EntityFetchService from a driver if it exposes one (for include support)
|
|
19
|
+
*/
|
|
20
|
+
private getFetchService;
|
|
21
|
+
/**
|
|
22
|
+
* Create REST routes for a collection using existing Rebase patterns
|
|
23
|
+
*/
|
|
24
|
+
private createCollectionRoutes;
|
|
25
|
+
/**
|
|
26
|
+
* Catch-all routes for subcollection paths.
|
|
27
|
+
*
|
|
28
|
+
* Matches URL patterns like:
|
|
29
|
+
* GET /authors/111094/posts → list child collection
|
|
30
|
+
* GET /authors/111094/posts/43 → get child entity
|
|
31
|
+
* POST /authors/111094/posts → create child entity
|
|
32
|
+
* PUT /authors/111094/posts/43 → update child entity
|
|
33
|
+
* DELETE /authors/111094/posts/43 → delete child entity
|
|
34
|
+
*
|
|
35
|
+
* The `:rest{.+}` regex param captures the full remainder of the URL
|
|
36
|
+
* path (Hono v4 `*` wildcard does not populate `c.req.param("*")`).
|
|
37
|
+
* We split it into segments and reconstruct the `collectionPath`
|
|
38
|
+
* (e.g. "authors/111094/posts") and optional `entityId` (e.g. "43").
|
|
39
|
+
*
|
|
40
|
+
* The DataDriver.saveEntity / fetchCollection / etc. already know how to
|
|
41
|
+
* resolve multi-segment relation paths, so we just forward to them.
|
|
42
|
+
*/
|
|
43
|
+
private createSubcollectionRoutes;
|
|
44
|
+
/**
|
|
45
|
+
* Format successful API response - flattened for traditional REST API
|
|
46
|
+
*/
|
|
47
|
+
private formatResponse;
|
|
48
|
+
/**
|
|
49
|
+
* Flatten Rebase entity structure to traditional REST format
|
|
50
|
+
*/
|
|
51
|
+
private flattenEntity;
|
|
52
|
+
/**
|
|
53
|
+
* Fetch raw collection data without Entity wrapper (fallback for non-Postgres)
|
|
54
|
+
*/
|
|
55
|
+
private fetchRawCollection;
|
|
56
|
+
/**
|
|
57
|
+
* Count raw entities for a collection
|
|
58
|
+
*/
|
|
59
|
+
private countRawEntities;
|
|
60
|
+
/**
|
|
61
|
+
* Fetch single entity raw data without Entity wrapper (fallback)
|
|
62
|
+
*/
|
|
63
|
+
private fetchRawEntity;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api-generator";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { QueryOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Map PostgREST-style operators to Rebase WhereFilterOp
|
|
4
|
+
*/
|
|
5
|
+
export declare function mapOperator(op: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Parse query parameters into QueryOptions
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseQueryOptions(query: Record<string, unknown>): QueryOptions;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { DataDriver } from "@rebasepro/types";
|
|
3
|
+
import { ApiConfig, HonoEnv } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Simplified API server that leverages existing Rebase infrastructure
|
|
6
|
+
* Can be used standalone or mounted on existing Hono app
|
|
7
|
+
*/
|
|
8
|
+
export declare class RebaseApiServer {
|
|
9
|
+
private app;
|
|
10
|
+
private router;
|
|
11
|
+
private config;
|
|
12
|
+
private driver;
|
|
13
|
+
private constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Factory method to create an asynchronously initialized ApiServer instance
|
|
16
|
+
*/
|
|
17
|
+
static create(config: ApiConfig & {
|
|
18
|
+
driver: DataDriver;
|
|
19
|
+
}): Promise<RebaseApiServer>;
|
|
20
|
+
/**
|
|
21
|
+
* Setup Hono middleware
|
|
22
|
+
*/
|
|
23
|
+
private setupMiddleware;
|
|
24
|
+
/**
|
|
25
|
+
* Setup API routes using existing services
|
|
26
|
+
*/
|
|
27
|
+
private setupRoutes;
|
|
28
|
+
/**
|
|
29
|
+
* Get the Hono router with all API routes
|
|
30
|
+
*/
|
|
31
|
+
getRouter(): Hono<HonoEnv>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the standalone Hono app
|
|
34
|
+
*/
|
|
35
|
+
getApp(): Hono<HonoEnv>;
|
|
36
|
+
/**
|
|
37
|
+
* Start the server (standalone mode) via @hono/node-server
|
|
38
|
+
*/
|
|
39
|
+
listen(port?: number, callback?: () => void): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { EntityCollection } from "@rebasepro/types";
|
|
2
|
+
import { AuthResult } from "../auth/middleware";
|
|
3
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
|
+
import { DataDriver } from "@rebasepro/types";
|
|
5
|
+
/**
|
|
6
|
+
* Hono Environment Variables
|
|
7
|
+
* Passed to generic Hono<HonoEnv> to type `c.get()`
|
|
8
|
+
*/
|
|
9
|
+
export type HonoEnv = {
|
|
10
|
+
Variables: {
|
|
11
|
+
user?: AuthResult | {
|
|
12
|
+
userId?: string;
|
|
13
|
+
roles?: string[];
|
|
14
|
+
};
|
|
15
|
+
driver?: DataDriver;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for API generation
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for API generation
|
|
23
|
+
*/
|
|
24
|
+
export interface ApiConfig {
|
|
25
|
+
collections?: EntityCollection[];
|
|
26
|
+
collectionsDir?: string;
|
|
27
|
+
basePath?: string;
|
|
28
|
+
enableGraphQL?: boolean;
|
|
29
|
+
enableREST?: boolean;
|
|
30
|
+
cors?: {
|
|
31
|
+
origin?: string | string[] | boolean;
|
|
32
|
+
credentials?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Whether auth is required for API endpoints (default: true) */
|
|
35
|
+
requireAuth?: boolean;
|
|
36
|
+
/** Optional custom validator for authentication */
|
|
37
|
+
authValidator?: (c: import("hono").Context<import("./types").HonoEnv>) => Promise<AuthResult>;
|
|
38
|
+
pagination?: {
|
|
39
|
+
defaultLimit: number;
|
|
40
|
+
maxLimit: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Context passed to resolvers and handlers
|
|
45
|
+
*/
|
|
46
|
+
export interface ApiContext {
|
|
47
|
+
user?: AuthResult;
|
|
48
|
+
collections: Map<string, EntityCollection>;
|
|
49
|
+
db: NodePgDatabase;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Standard API response format
|
|
53
|
+
*/
|
|
54
|
+
export interface ApiResponse<T = unknown> {
|
|
55
|
+
data?: T;
|
|
56
|
+
error?: {
|
|
57
|
+
message: string;
|
|
58
|
+
code?: string;
|
|
59
|
+
details?: unknown;
|
|
60
|
+
};
|
|
61
|
+
meta?: {
|
|
62
|
+
total?: number;
|
|
63
|
+
page?: number;
|
|
64
|
+
limit?: number;
|
|
65
|
+
hasMore?: boolean;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Query options for API endpoints
|
|
70
|
+
*/
|
|
71
|
+
export interface QueryOptions {
|
|
72
|
+
limit?: number;
|
|
73
|
+
offset?: number;
|
|
74
|
+
where?: Record<string, unknown>;
|
|
75
|
+
orderBy?: Array<{
|
|
76
|
+
field: string;
|
|
77
|
+
direction: 'asc' | 'desc';
|
|
78
|
+
}>;
|
|
79
|
+
include?: string[];
|
|
80
|
+
/** Columns to return in the response (field-level selection) */
|
|
81
|
+
fields?: string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Relation resolution configuration
|
|
85
|
+
*/
|
|
86
|
+
export interface RelationConfig {
|
|
87
|
+
relationName: string;
|
|
88
|
+
depth?: number;
|
|
89
|
+
include?: string[];
|
|
90
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface GoogleUserInfo {
|
|
2
|
+
googleId: string;
|
|
3
|
+
email: string;
|
|
4
|
+
displayName: string | null;
|
|
5
|
+
photoUrl: string | null;
|
|
6
|
+
emailVerified: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Configure Google OAuth - call this during initialization
|
|
10
|
+
*/
|
|
11
|
+
export declare function configureGoogleOAuth(clientId: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Verify a Google ID token and extract user information
|
|
14
|
+
* @param idToken The ID token from Google Sign-In on the frontend
|
|
15
|
+
*/
|
|
16
|
+
export declare function verifyGoogleIdToken(idToken: string): Promise<GoogleUserInfo | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Check if Google OAuth is configured
|
|
19
|
+
*/
|
|
20
|
+
export declare function isGoogleOAuthConfigured(): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { configureJwt, generateAccessToken, verifyAccessToken, generateRefreshToken, hashRefreshToken, getRefreshTokenExpiry, getAccessTokenExpiry } from "./jwt";
|
|
2
|
+
export type { JwtConfig, AccessTokenPayload } from "./jwt";
|
|
3
|
+
export { hashPassword, verifyPassword, validatePasswordStrength } from "./password";
|
|
4
|
+
export type { PasswordValidationResult } from "./password";
|
|
5
|
+
export { configureGoogleOAuth, verifyGoogleIdToken, isGoogleOAuthConfigured } from "./google-oauth";
|
|
6
|
+
export type { GoogleUserInfo } from "./google-oauth";
|
|
7
|
+
export { requireAuth, requireAdmin, optionalAuth, extractUserFromToken, createAuthMiddleware } from "./middleware";
|
|
8
|
+
export type { AuthMiddlewareOptions, AuthResult } from "./middleware";
|
|
9
|
+
export { createAuthRoutes } from "./routes";
|
|
10
|
+
export type { AuthModuleConfig } from "./routes";
|
|
11
|
+
export { createAdminRoutes } from "./admin-routes";
|
|
12
|
+
export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter } from "./rate-limiter";
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Abstraction Interfaces
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define the contracts for authentication-related operations.
|
|
5
|
+
* Implementations can use different databases (PostgreSQL, MongoDB, etc.) to
|
|
6
|
+
* store user, role, and token data.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* User data structure
|
|
10
|
+
*/
|
|
11
|
+
export interface UserData {
|
|
12
|
+
id: string;
|
|
13
|
+
email: string;
|
|
14
|
+
passwordHash?: string | null;
|
|
15
|
+
displayName?: string | null;
|
|
16
|
+
photoUrl?: string | null;
|
|
17
|
+
provider: string;
|
|
18
|
+
googleId?: string | null;
|
|
19
|
+
emailVerified: boolean;
|
|
20
|
+
emailVerificationToken?: string | null;
|
|
21
|
+
emailVerificationSentAt?: Date | null;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Data for creating a new user
|
|
27
|
+
*/
|
|
28
|
+
export interface CreateUserData {
|
|
29
|
+
email: string;
|
|
30
|
+
passwordHash?: string;
|
|
31
|
+
displayName?: string;
|
|
32
|
+
photoUrl?: string;
|
|
33
|
+
provider?: string;
|
|
34
|
+
googleId?: string;
|
|
35
|
+
emailVerified?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Role data structure
|
|
39
|
+
*/
|
|
40
|
+
export interface RoleData {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
isAdmin: boolean;
|
|
44
|
+
defaultPermissions: {
|
|
45
|
+
read?: boolean;
|
|
46
|
+
create?: boolean;
|
|
47
|
+
edit?: boolean;
|
|
48
|
+
delete?: boolean;
|
|
49
|
+
} | null;
|
|
50
|
+
collectionPermissions: Record<string, {
|
|
51
|
+
read?: boolean;
|
|
52
|
+
create?: boolean;
|
|
53
|
+
edit?: boolean;
|
|
54
|
+
delete?: boolean;
|
|
55
|
+
}> | null;
|
|
56
|
+
config: Record<string, unknown> | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Data for creating a new role
|
|
60
|
+
*/
|
|
61
|
+
export interface CreateRoleData {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
isAdmin?: boolean;
|
|
65
|
+
defaultPermissions?: RoleData["defaultPermissions"];
|
|
66
|
+
collectionPermissions?: RoleData["collectionPermissions"];
|
|
67
|
+
config?: RoleData["config"];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Refresh token info
|
|
71
|
+
*/
|
|
72
|
+
export interface RefreshTokenInfo {
|
|
73
|
+
id: string;
|
|
74
|
+
userId: string;
|
|
75
|
+
tokenHash: string;
|
|
76
|
+
expiresAt: Date;
|
|
77
|
+
createdAt: Date;
|
|
78
|
+
userAgent?: string | null;
|
|
79
|
+
ipAddress?: string | null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Password reset token info
|
|
83
|
+
*/
|
|
84
|
+
export interface PasswordResetTokenInfo {
|
|
85
|
+
userId: string;
|
|
86
|
+
expiresAt: Date;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Options for paginated user listing
|
|
90
|
+
*/
|
|
91
|
+
export interface ListUsersOptions {
|
|
92
|
+
/** Max results per page (default 25) */
|
|
93
|
+
limit?: number;
|
|
94
|
+
/** Number of results to skip (default 0) */
|
|
95
|
+
offset?: number;
|
|
96
|
+
/** Search term — matches against email and displayName (case-insensitive) */
|
|
97
|
+
search?: string;
|
|
98
|
+
/** Field to sort by (default "createdAt") */
|
|
99
|
+
orderBy?: string;
|
|
100
|
+
/** Sort direction (default "desc") */
|
|
101
|
+
orderDir?: "asc" | "desc";
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Result of a paginated user listing
|
|
105
|
+
*/
|
|
106
|
+
export interface PaginatedUsersResult {
|
|
107
|
+
users: UserData[];
|
|
108
|
+
/** Total number of users matching the filters (ignoring limit/offset) */
|
|
109
|
+
total: number;
|
|
110
|
+
limit: number;
|
|
111
|
+
offset: number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Abstract user repository interface.
|
|
115
|
+
* Handles all user-related database operations.
|
|
116
|
+
*/
|
|
117
|
+
export interface UserRepository {
|
|
118
|
+
/**
|
|
119
|
+
* Create a new user
|
|
120
|
+
*/
|
|
121
|
+
createUser(data: CreateUserData): Promise<UserData>;
|
|
122
|
+
/**
|
|
123
|
+
* Get a user by ID
|
|
124
|
+
*/
|
|
125
|
+
getUserById(id: string): Promise<UserData | null>;
|
|
126
|
+
/**
|
|
127
|
+
* Get a user by email
|
|
128
|
+
*/
|
|
129
|
+
getUserByEmail(email: string): Promise<UserData | null>;
|
|
130
|
+
/**
|
|
131
|
+
* Get a user by Google ID
|
|
132
|
+
*/
|
|
133
|
+
getUserByGoogleId(googleId: string): Promise<UserData | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Update a user
|
|
136
|
+
*/
|
|
137
|
+
updateUser(id: string, data: Partial<Omit<CreateUserData, "id">>): Promise<UserData | null>;
|
|
138
|
+
/**
|
|
139
|
+
* Delete a user
|
|
140
|
+
*/
|
|
141
|
+
deleteUser(id: string): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* List all users (unbounded — use listUsersPaginated for large datasets)
|
|
144
|
+
*/
|
|
145
|
+
listUsers(): Promise<UserData[]>;
|
|
146
|
+
/**
|
|
147
|
+
* List users with server-side pagination, search, and sorting.
|
|
148
|
+
*/
|
|
149
|
+
listUsersPaginated(options?: ListUsersOptions): Promise<PaginatedUsersResult>;
|
|
150
|
+
/**
|
|
151
|
+
* Update user's password hash
|
|
152
|
+
*/
|
|
153
|
+
updatePassword(id: string, passwordHash: string): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Set email verification status
|
|
156
|
+
*/
|
|
157
|
+
setEmailVerified(id: string, verified: boolean): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Set email verification token
|
|
160
|
+
*/
|
|
161
|
+
setVerificationToken(id: string, token: string | null): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Find user by email verification token
|
|
164
|
+
*/
|
|
165
|
+
getUserByVerificationToken(token: string): Promise<UserData | null>;
|
|
166
|
+
/**
|
|
167
|
+
* Get roles for a user
|
|
168
|
+
*/
|
|
169
|
+
getUserRoles(userId: string): Promise<RoleData[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Get role IDs for a user
|
|
172
|
+
*/
|
|
173
|
+
getUserRoleIds(userId: string): Promise<string[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Set roles for a user (replaces existing roles)
|
|
176
|
+
*/
|
|
177
|
+
setUserRoles(userId: string, roleIds: string[]): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Assign a specific role to a new user
|
|
180
|
+
*/
|
|
181
|
+
assignDefaultRole(userId: string, roleId: string): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Get user with their roles
|
|
184
|
+
*/
|
|
185
|
+
getUserWithRoles(userId: string): Promise<{
|
|
186
|
+
user: UserData;
|
|
187
|
+
roles: RoleData[];
|
|
188
|
+
} | null>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Abstract role repository interface.
|
|
192
|
+
* Handles all role-related database operations.
|
|
193
|
+
*/
|
|
194
|
+
export interface RoleRepository {
|
|
195
|
+
/**
|
|
196
|
+
* Get a role by ID
|
|
197
|
+
*/
|
|
198
|
+
getRoleById(id: string): Promise<RoleData | null>;
|
|
199
|
+
/**
|
|
200
|
+
* List all roles
|
|
201
|
+
*/
|
|
202
|
+
listRoles(): Promise<RoleData[]>;
|
|
203
|
+
/**
|
|
204
|
+
* Create a new role
|
|
205
|
+
*/
|
|
206
|
+
createRole(data: CreateRoleData): Promise<RoleData>;
|
|
207
|
+
/**
|
|
208
|
+
* Update a role
|
|
209
|
+
*/
|
|
210
|
+
updateRole(id: string, data: Partial<Omit<RoleData, "id">>): Promise<RoleData | null>;
|
|
211
|
+
/**
|
|
212
|
+
* Delete a role
|
|
213
|
+
*/
|
|
214
|
+
deleteRole(id: string): Promise<void>;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Abstract token repository interface.
|
|
218
|
+
* Handles refresh tokens and password reset tokens.
|
|
219
|
+
*/
|
|
220
|
+
export interface TokenRepository {
|
|
221
|
+
/**
|
|
222
|
+
* Create a new refresh token
|
|
223
|
+
*/
|
|
224
|
+
createRefreshToken(userId: string, tokenHash: string, expiresAt: Date, userAgent?: string, ipAddress?: string): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Find a refresh token by hash
|
|
227
|
+
*/
|
|
228
|
+
findRefreshTokenByHash(tokenHash: string): Promise<RefreshTokenInfo | null>;
|
|
229
|
+
/**
|
|
230
|
+
* Delete a refresh token by hash
|
|
231
|
+
*/
|
|
232
|
+
deleteRefreshToken(tokenHash: string): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Delete all refresh tokens for a user
|
|
235
|
+
*/
|
|
236
|
+
deleteAllRefreshTokensForUser(userId: string): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* List all refresh tokens for a user
|
|
239
|
+
*/
|
|
240
|
+
listRefreshTokensForUser(userId: string): Promise<RefreshTokenInfo[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Delete a specific refresh token by its primary key ID
|
|
243
|
+
*/
|
|
244
|
+
deleteRefreshTokenById(id: string, userId: string): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Create a password reset token
|
|
247
|
+
*/
|
|
248
|
+
createPasswordResetToken(userId: string, tokenHash: string, expiresAt: Date): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Find a valid (not expired, not used) password reset token by hash
|
|
251
|
+
*/
|
|
252
|
+
findValidPasswordResetToken(tokenHash: string): Promise<PasswordResetTokenInfo | null>;
|
|
253
|
+
/**
|
|
254
|
+
* Mark a password reset token as used
|
|
255
|
+
*/
|
|
256
|
+
markPasswordResetTokenUsed(tokenHash: string): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Delete all password reset tokens for a user
|
|
259
|
+
*/
|
|
260
|
+
deleteAllPasswordResetTokensForUser(userId: string): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Clean up expired tokens
|
|
263
|
+
*/
|
|
264
|
+
deleteExpiredTokens(): Promise<void>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Combined auth repository interface for convenience
|
|
268
|
+
*/
|
|
269
|
+
export interface AuthRepository extends UserRepository, RoleRepository, TokenRepository {
|
|
270
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configure JWT settings - call this during initialization.
|
|
12
|
+
* Validates the secret strength to prevent deployment with default/weak secrets.
|
|
13
|
+
*/
|
|
14
|
+
export declare function configureJwt(config: JwtConfig): void;
|
|
15
|
+
/**
|
|
16
|
+
* Generate an access token (short-lived, 1 hour by default)
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateAccessToken(userId: string, roles: string[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the expiration time of an access token in milliseconds from now
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAccessTokenExpiryMs(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Get the expiration timestamp for an access token
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAccessTokenExpiry(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Verify and decode an access token
|
|
29
|
+
*/
|
|
30
|
+
export declare function verifyAccessToken(token: string): AccessTokenPayload | null;
|
|
31
|
+
/**
|
|
32
|
+
* Generate a random refresh token (long-lived, 30 days by default)
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateRefreshToken(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Hash a refresh token for database storage (don't store raw tokens)
|
|
37
|
+
*/
|
|
38
|
+
export declare function hashRefreshToken(token: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate refresh token expiration date
|
|
41
|
+
*/
|
|
42
|
+
export declare function getRefreshTokenExpiry(): Date;
|