@rebasepro/server-core 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/api/ast-schema-editor.d.ts +21 -0
- package/dist/api/collections_for_test/callbacks_test_collection.d.ts +2 -0
- package/dist/api/errors.d.ts +53 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/logs-routes.d.ts +37 -0
- package/dist/api/openapi-generator.d.ts +16 -0
- package/dist/api/rest/api-generator.d.ts +68 -0
- package/{src/api/rest/index.ts → dist/api/rest/index.d.ts} +0 -1
- package/dist/api/rest/query-parser.d.ts +6 -0
- package/dist/api/schema-editor-routes.d.ts +3 -0
- package/dist/api/types.d.ts +56 -0
- package/dist/auth/adapter-middleware.d.ts +43 -0
- package/dist/auth/admin-roles-route.d.ts +18 -0
- package/dist/auth/admin-user-ops.d.ts +79 -0
- package/dist/auth/admin-users-route.d.ts +28 -0
- package/dist/auth/api-keys/api-key-middleware.d.ts +39 -0
- package/{src/auth/api-keys/api-key-permission-guard.ts → dist/auth/api-keys/api-key-permission-guard.d.ts} +2 -34
- package/dist/auth/api-keys/api-key-routes.d.ts +20 -0
- package/dist/auth/api-keys/api-key-store.d.ts +35 -0
- package/{src/auth/api-keys/api-key-types.ts → dist/auth/api-keys/api-key-types.d.ts} +0 -6
- package/{src/auth/api-keys/index.ts → dist/auth/api-keys/index.d.ts} +2 -22
- package/dist/auth/apple-oauth.d.ts +30 -0
- package/{src/auth/auth-hooks.ts → dist/auth/auth-hooks.d.ts} +15 -73
- package/dist/auth/bitbucket-oauth.d.ts +11 -0
- package/dist/auth/builtin-auth-adapter.d.ts +55 -0
- package/dist/auth/cookie-utils.d.ts +32 -0
- package/{src/auth/crypto-utils.ts → dist/auth/crypto-utils.d.ts} +1 -16
- package/dist/auth/custom-auth-adapter.d.ts +39 -0
- package/dist/auth/discord-oauth.d.ts +14 -0
- package/dist/auth/facebook-oauth.d.ts +14 -0
- package/dist/auth/github-oauth.d.ts +15 -0
- package/dist/auth/gitlab-oauth.d.ts +13 -0
- package/dist/auth/google-oauth.d.ts +47 -0
- package/{src/auth/index.ts → dist/auth/index.d.ts} +4 -22
- package/{src/auth/interfaces.ts → dist/auth/interfaces.d.ts} +20 -89
- package/dist/auth/jwt.d.ts +67 -0
- package/dist/auth/linkedin-oauth.d.ts +18 -0
- package/dist/auth/magic-link-routes.d.ts +32 -0
- package/dist/auth/mfa-crypto.d.ts +23 -0
- package/dist/auth/mfa-routes.d.ts +7 -0
- package/dist/auth/mfa.d.ts +49 -0
- package/dist/auth/microsoft-oauth.d.ts +16 -0
- package/dist/auth/middleware.d.ts +158 -0
- package/dist/auth/password.d.ts +22 -0
- package/dist/auth/rate-limiter.d.ts +50 -0
- package/dist/auth/reset-password-admin.d.ts +29 -0
- package/dist/auth/rls-scope.d.ts +31 -0
- package/dist/auth/routes.d.ts +66 -0
- package/dist/auth/session-routes.d.ts +29 -0
- package/dist/auth/slack-oauth.d.ts +12 -0
- package/dist/auth/spotify-oauth.d.ts +12 -0
- package/dist/auth/twitter-oauth.d.ts +18 -0
- package/dist/collections/BackendCollectionRegistry.d.ts +13 -0
- package/dist/collections/loader.d.ts +5 -0
- package/dist/cron/cron-loader.d.ts +18 -0
- package/dist/cron/cron-routes.d.ts +14 -0
- package/dist/cron/cron-scheduler.d.ts +106 -0
- package/dist/cron/cron-store.d.ts +32 -0
- package/dist/cron/define-cron.d.ts +28 -0
- package/{src/cron/index.ts → dist/cron/index.d.ts} +1 -0
- package/dist/db/interfaces.d.ts +18 -0
- package/dist/dynamic-import-Dvh-K5fl.js +22 -0
- package/dist/dynamic-import-Dvh-K5fl.js.map +1 -0
- package/dist/email/index.d.ts +6 -0
- package/dist/email/smtp-email-service.d.ts +30 -0
- package/dist/email/templates.d.ts +50 -0
- package/{src/email/types.ts → dist/email/types.d.ts} +40 -36
- package/dist/env.d.ts +102 -0
- package/dist/functions/define-function.d.ts +55 -0
- package/dist/functions/function-loader.d.ts +18 -0
- package/dist/functions/function-routes.d.ts +10 -0
- package/{src/functions/index.ts → dist/functions/index.d.ts} +2 -0
- package/dist/history/history-routes.d.ts +23 -0
- package/{src/history/index.ts → dist/history/index.d.ts} +0 -1
- package/dist/index.d.ts +35 -0
- package/dist/index.es.js +18184 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +48629 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/init/docs.d.ts +4 -0
- package/dist/init/health.d.ts +2 -0
- package/dist/init/middlewares.d.ts +10 -0
- package/dist/init/shutdown.d.ts +65 -0
- package/dist/init/storage.d.ts +5 -0
- package/dist/init.d.ts +344 -0
- package/dist/jwt-BwIn8xmk.js +4200 -0
- package/dist/jwt-BwIn8xmk.js.map +1 -0
- package/dist/logger-BYU66ENZ.js +94 -0
- package/dist/logger-BYU66ENZ.js.map +1 -0
- package/dist/ms-DnYXB-Wd.js +162 -0
- package/dist/ms-DnYXB-Wd.js.map +1 -0
- package/dist/openapi-generator-Z9oYWLf_.js +586 -0
- package/dist/openapi-generator-Z9oYWLf_.js.map +1 -0
- package/dist/schema-editor-routes-D3ef8zu1.js +219 -0
- package/dist/schema-editor-routes-D3ef8zu1.js.map +1 -0
- package/dist/serve-spa.d.ts +36 -0
- package/dist/services/driver-registry.d.ts +78 -0
- package/dist/services/routed-realtime-service.d.ts +43 -0
- package/dist/services/webhook-service.d.ts +29 -0
- package/dist/singleton.d.ts +51 -0
- package/dist/src-B4OLmNVa.js +437 -0
- package/dist/src-B4OLmNVa.js.map +1 -0
- package/dist/src-B5WkP1Rv.js +24778 -0
- package/dist/src-B5WkP1Rv.js.map +1 -0
- package/dist/storage/GCSStorageController.d.ts +43 -0
- package/dist/storage/LocalStorageController.d.ts +46 -0
- package/dist/storage/S3StorageController.d.ts +40 -0
- package/dist/storage/image-transform.d.ts +50 -0
- package/{src/storage/index.ts → dist/storage/index.d.ts} +6 -21
- package/dist/storage/routes.d.ts +70 -0
- package/dist/storage/storage-registry.d.ts +78 -0
- package/dist/storage/tus-handler.d.ts +53 -0
- package/{src/storage/types.ts → dist/storage/types.d.ts} +32 -38
- package/dist/types/index.d.ts +11 -0
- package/dist/utils/dev-port.d.ts +45 -0
- package/dist/utils/dynamic-import.d.ts +25 -0
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logging.d.ts +9 -0
- package/dist/utils/request-id.d.ts +4 -0
- package/dist/utils/request-logger.d.ts +19 -0
- package/{src/utils/sql.ts → dist/utils/sql.d.ts} +5 -16
- package/package.json +49 -22
- package/coverage/clover.xml +0 -3739
- package/coverage/coverage-final.json +0 -31
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -266
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/api/ast-schema-editor.ts.html +0 -952
- package/coverage/lcov-report/src/api/errors.ts.html +0 -472
- package/coverage/lcov-report/src/api/graphql/graphql-schema-generator.ts.html +0 -1069
- package/coverage/lcov-report/src/api/graphql/index.html +0 -116
- package/coverage/lcov-report/src/api/index.html +0 -176
- package/coverage/lcov-report/src/api/openapi-generator.ts.html +0 -565
- package/coverage/lcov-report/src/api/rest/api-generator.ts.html +0 -994
- package/coverage/lcov-report/src/api/rest/index.html +0 -131
- package/coverage/lcov-report/src/api/rest/query-parser.ts.html +0 -550
- package/coverage/lcov-report/src/api/schema-editor-routes.ts.html +0 -202
- package/coverage/lcov-report/src/api/server.ts.html +0 -823
- package/coverage/lcov-report/src/auth/admin-routes.ts.html +0 -973
- package/coverage/lcov-report/src/auth/index.html +0 -176
- package/coverage/lcov-report/src/auth/jwt.ts.html +0 -574
- package/coverage/lcov-report/src/auth/middleware.ts.html +0 -745
- package/coverage/lcov-report/src/auth/password.ts.html +0 -310
- package/coverage/lcov-report/src/auth/services.ts.html +0 -2074
- package/coverage/lcov-report/src/collections/index.html +0 -116
- package/coverage/lcov-report/src/collections/loader.ts.html +0 -232
- package/coverage/lcov-report/src/db/auth-schema.ts.html +0 -523
- package/coverage/lcov-report/src/db/data-transformer.ts.html +0 -1753
- package/coverage/lcov-report/src/db/entityService.ts.html +0 -700
- package/coverage/lcov-report/src/db/index.html +0 -146
- package/coverage/lcov-report/src/db/services/EntityFetchService.ts.html +0 -4048
- package/coverage/lcov-report/src/db/services/EntityPersistService.ts.html +0 -883
- package/coverage/lcov-report/src/db/services/RelationService.ts.html +0 -3121
- package/coverage/lcov-report/src/db/services/entity-helpers.ts.html +0 -442
- package/coverage/lcov-report/src/db/services/index.html +0 -176
- package/coverage/lcov-report/src/db/services/index.ts.html +0 -124
- package/coverage/lcov-report/src/generate-drizzle-schema-logic.ts.html +0 -1960
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/services/driver-registry.ts.html +0 -631
- package/coverage/lcov-report/src/services/index.html +0 -131
- package/coverage/lcov-report/src/services/postgresDataDriver.ts.html +0 -3025
- package/coverage/lcov-report/src/storage/LocalStorageController.ts.html +0 -1189
- package/coverage/lcov-report/src/storage/S3StorageController.ts.html +0 -970
- package/coverage/lcov-report/src/storage/index.html +0 -161
- package/coverage/lcov-report/src/storage/storage-registry.ts.html +0 -646
- package/coverage/lcov-report/src/storage/types.ts.html +0 -451
- package/coverage/lcov-report/src/utils/drizzle-conditions.ts.html +0 -3082
- package/coverage/lcov-report/src/utils/index.html +0 -116
- package/coverage/lcov.info +0 -7179
- package/jest.config.cjs +0 -19
- package/src/api/ast-schema-editor.ts +0 -289
- package/src/api/collections_for_test/callbacks_test_collection.ts +0 -61
- package/src/api/errors.ts +0 -278
- package/src/api/graphql/graphql-schema-generator.ts +0 -383
- package/src/api/graphql/index.ts +0 -2
- package/src/api/index.ts +0 -11
- package/src/api/logs-routes.ts +0 -132
- package/src/api/openapi-generator.ts +0 -727
- package/src/api/rest/api-generator-count.test.ts +0 -126
- package/src/api/rest/api-generator.ts +0 -747
- package/src/api/rest/query-parser.ts +0 -300
- package/src/api/schema-editor-routes.ts +0 -41
- package/src/api/server.ts +0 -271
- package/src/api/types.ts +0 -104
- package/src/auth/adapter-middleware.ts +0 -114
- package/src/auth/admin-roles-route.ts +0 -36
- package/src/auth/admin-user-ops.ts +0 -236
- package/src/auth/admin-users-route.ts +0 -302
- package/src/auth/api-keys/api-key-middleware.ts +0 -133
- package/src/auth/api-keys/api-key-routes.ts +0 -193
- package/src/auth/api-keys/api-key-store.ts +0 -340
- package/src/auth/apple-oauth.ts +0 -122
- package/src/auth/bitbucket-oauth.ts +0 -84
- package/src/auth/builtin-auth-adapter.ts +0 -380
- package/src/auth/custom-auth-adapter.ts +0 -86
- package/src/auth/discord-oauth.ts +0 -85
- package/src/auth/facebook-oauth.ts +0 -74
- package/src/auth/github-oauth.ts +0 -112
- package/src/auth/gitlab-oauth.ts +0 -72
- package/src/auth/google-oauth.ts +0 -223
- package/src/auth/jwt.ts +0 -208
- package/src/auth/linkedin-oauth.ts +0 -83
- package/src/auth/magic-link-routes.ts +0 -167
- package/src/auth/mfa-crypto.ts +0 -91
- package/src/auth/mfa-routes.ts +0 -323
- package/src/auth/mfa.ts +0 -161
- package/src/auth/microsoft-oauth.ts +0 -90
- package/src/auth/middleware.ts +0 -369
- package/src/auth/password.ts +0 -77
- package/src/auth/rate-limiter.ts +0 -225
- package/src/auth/reset-password-admin.ts +0 -160
- package/src/auth/rls-scope.ts +0 -58
- package/src/auth/routes.ts +0 -802
- package/src/auth/session-routes.ts +0 -353
- package/src/auth/slack-oauth.ts +0 -73
- package/src/auth/spotify-oauth.ts +0 -69
- package/src/auth/twitter-oauth.ts +0 -128
- package/src/collections/BackendCollectionRegistry.ts +0 -20
- package/src/collections/loader.ts +0 -50
- package/src/cron/cron-loader.ts +0 -84
- package/src/cron/cron-routes.test.ts +0 -265
- package/src/cron/cron-routes.ts +0 -85
- package/src/cron/cron-scheduler.test.ts +0 -559
- package/src/cron/cron-scheduler.ts +0 -581
- package/src/cron/cron-store.ts +0 -166
- package/src/db/interfaces.ts +0 -60
- package/src/email/index.ts +0 -19
- package/src/email/smtp-email-service.ts +0 -123
- package/src/email/templates.ts +0 -470
- package/src/env.ts +0 -227
- package/src/functions/function-loader.ts +0 -116
- package/src/functions/function-routes.ts +0 -31
- package/src/history/history-routes.ts +0 -129
- package/src/index.ts +0 -70
- package/src/init/docs.ts +0 -47
- package/src/init/health.ts +0 -37
- package/src/init/middlewares.ts +0 -61
- package/src/init/shutdown.ts +0 -56
- package/src/init/storage.ts +0 -57
- package/src/init.ts +0 -1041
- package/src/serve-spa.ts +0 -89
- package/src/services/driver-registry.ts +0 -183
- package/src/services/routed-realtime-service.ts +0 -113
- package/src/services/webhook-service.ts +0 -155
- package/src/singleton.ts +0 -70
- package/src/storage/LocalStorageController.ts +0 -389
- package/src/storage/S3StorageController.ts +0 -300
- package/src/storage/image-transform.ts +0 -218
- package/src/storage/routes.ts +0 -368
- package/src/storage/storage-registry.ts +0 -188
- package/src/storage/tus-handler.ts +0 -315
- package/src/types/index.ts +0 -27
- package/src/utils/dev-port.ts +0 -196
- package/src/utils/logger.ts +0 -143
- package/src/utils/logging.ts +0 -40
- package/src/utils/request-id.ts +0 -40
- package/src/utils/request-logger.ts +0 -72
- package/test/api-generator.test.ts +0 -588
- package/test/api-key-permission-guard.test.ts +0 -144
- package/test/ast-schema-editor.test.ts +0 -89
- package/test/auth-middleware-hono.test.ts +0 -556
- package/test/auth-routes.test.ts +0 -1098
- package/test/backend-hooks-data.test.ts +0 -477
- package/test/custom-auth-adapter.test.ts +0 -189
- package/test/driver-registry.test.ts +0 -282
- package/test/email-templates.test.ts +0 -174
- package/test/env.test.ts +0 -128
- package/test/error-propagation.test.ts +0 -226
- package/test/errors-hono.test.ts +0 -133
- package/test/errors.test.ts +0 -155
- package/test/function-loader.test.ts +0 -127
- package/test/graphql-schema-generator.test.ts +0 -554
- package/test/jwt-security.test.ts +0 -182
- package/test/jwt.test.ts +0 -326
- package/test/mfa.test.ts +0 -197
- package/test/middleware.test.ts +0 -305
- package/test/multi-datasource-routing.test.ts +0 -113
- package/test/password.test.ts +0 -165
- package/test/query-parser.test.ts +0 -233
- package/test/rate-limiter.test.ts +0 -102
- package/test/reset-password-admin.test.ts +0 -113
- package/test/routed-realtime-service.test.ts +0 -86
- package/test/safe-compare.test.ts +0 -66
- package/test/singleton.test.ts +0 -59
- package/test/smtp-email-service.test.ts +0 -169
- package/test/storage-local.test.ts +0 -271
- package/test/storage-registry.test.ts +0 -282
- package/test/storage-routes.test.ts +0 -222
- package/test/storage-s3.test.ts +0 -304
- package/test/transform-auth-response.test.ts +0 -305
- package/test/webhook-service.test.ts +0 -260
- package/tsconfig.json +0 -54
- package/tsconfig.prod.json +0 -23
- package/vite.config.ts +0 -86
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* A single permission entry scoping an API key to a collection and set of operations.
|
|
13
12
|
*
|
|
@@ -19,7 +18,6 @@ export interface ApiKeyPermission {
|
|
|
19
18
|
/** Allowed operations on the collection. */
|
|
20
19
|
operations: ("read" | "write" | "delete")[];
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
/**
|
|
24
22
|
* Full database row for an API key.
|
|
25
23
|
* The `key_hash` is never exposed via the API — only stored for lookup.
|
|
@@ -43,7 +41,6 @@ export interface ApiKey {
|
|
|
43
41
|
expires_at: string | null;
|
|
44
42
|
revoked_at: string | null;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
/**
|
|
48
45
|
* Masked version of an API key, safe for API responses.
|
|
49
46
|
* Omits `key_hash` and shows only the prefix.
|
|
@@ -63,7 +60,6 @@ export interface ApiKeyMasked {
|
|
|
63
60
|
expires_at: string | null;
|
|
64
61
|
revoked_at: string | null;
|
|
65
62
|
}
|
|
66
|
-
|
|
67
63
|
/**
|
|
68
64
|
* Request body for creating a new API key.
|
|
69
65
|
*/
|
|
@@ -77,7 +73,6 @@ export interface CreateApiKeyRequest {
|
|
|
77
73
|
/** ISO-8601 expiration timestamp. Omit for no expiration. */
|
|
78
74
|
expires_at?: string | null;
|
|
79
75
|
}
|
|
80
|
-
|
|
81
76
|
/**
|
|
82
77
|
* Request body for updating an existing API key.
|
|
83
78
|
* All fields are optional — only provided fields are updated.
|
|
@@ -90,7 +85,6 @@ export interface UpdateApiKeyRequest {
|
|
|
90
85
|
rate_limit?: number | null;
|
|
91
86
|
expires_at?: string | null;
|
|
92
87
|
}
|
|
93
|
-
|
|
94
88
|
/**
|
|
95
89
|
* Returned exactly once when a key is created.
|
|
96
90
|
* The `key` field contains the full plaintext key — it is never stored
|
|
@@ -6,32 +6,12 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
// Types
|
|
11
|
-
export type {
|
|
12
|
-
ApiKey,
|
|
13
|
-
ApiKeyMasked,
|
|
14
|
-
ApiKeyPermission,
|
|
15
|
-
ApiKeyWithSecret,
|
|
16
|
-
CreateApiKeyRequest,
|
|
17
|
-
UpdateApiKeyRequest
|
|
18
|
-
} from "./api-key-types";
|
|
19
|
-
|
|
20
|
-
// Store
|
|
9
|
+
export type { ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest } from "./api-key-types";
|
|
21
10
|
export { createApiKeyStore } from "./api-key-store";
|
|
22
11
|
export type { ApiKeyStore } from "./api-key-store";
|
|
23
|
-
|
|
24
|
-
// Middleware
|
|
25
12
|
export { isApiKeyToken, validateApiKey } from "./api-key-middleware";
|
|
26
13
|
export type { ApiKeyAuthOptions } from "./api-key-middleware";
|
|
27
|
-
|
|
28
|
-
// Permission guard
|
|
29
|
-
export {
|
|
30
|
-
httpMethodToOperation,
|
|
31
|
-
isOperationAllowed
|
|
32
|
-
} from "./api-key-permission-guard";
|
|
14
|
+
export { httpMethodToOperation, isOperationAllowed } from "./api-key-permission-guard";
|
|
33
15
|
export type { ApiKeyOperation } from "./api-key-permission-guard";
|
|
34
|
-
|
|
35
|
-
// Routes
|
|
36
16
|
export { createApiKeyRoutes } from "./api-key-routes";
|
|
37
17
|
export type { ApiKeyRouteOptions } from "./api-key-routes";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates an Apple Sign In OAuth Provider integration.
|
|
4
|
+
*
|
|
5
|
+
* Apple requires a client secret that is a signed JWT, regenerated on each
|
|
6
|
+
* token exchange (valid up to 6 months). This provider handles that automatically.
|
|
7
|
+
*
|
|
8
|
+
* Required Apple Developer configuration:
|
|
9
|
+
* - Services ID (clientId)
|
|
10
|
+
* - Key ID from the private key registered with Apple
|
|
11
|
+
* - Team ID from Apple Developer account
|
|
12
|
+
* - Private key (.p8 file contents) downloaded from Apple Developer portal
|
|
13
|
+
*/
|
|
14
|
+
export declare function createAppleProvider(config: {
|
|
15
|
+
clientId: string;
|
|
16
|
+
teamId: string;
|
|
17
|
+
keyId: string;
|
|
18
|
+
/** The raw PEM contents of the .p8 private key file */
|
|
19
|
+
privateKey: string;
|
|
20
|
+
}): OAuthProvider<{
|
|
21
|
+
code: string;
|
|
22
|
+
redirectUri: string;
|
|
23
|
+
user?: {
|
|
24
|
+
name?: {
|
|
25
|
+
firstName?: string;
|
|
26
|
+
lastName?: string;
|
|
27
|
+
};
|
|
28
|
+
email?: string;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
@@ -36,22 +36,14 @@
|
|
|
36
36
|
* };
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
import {
|
|
41
|
-
hashPassword as defaultHashPassword,
|
|
42
|
-
verifyPassword as defaultVerifyPassword,
|
|
43
|
-
validatePasswordStrength as defaultValidatePasswordStrength
|
|
44
|
-
} from "./password";
|
|
45
39
|
import type { PasswordValidationResult } from "./password";
|
|
46
40
|
import type { AuthRepository, UserData, CreateUserData } from "./interfaces";
|
|
47
41
|
import type { EmailService, EmailConfig } from "../email";
|
|
48
42
|
import type { AuthResponsePayload, TransformAuthResponseContext } from "@rebasepro/types";
|
|
49
|
-
|
|
50
43
|
/**
|
|
51
44
|
* Authentication method identifier for lifecycle hooks.
|
|
52
45
|
*/
|
|
53
46
|
export type AuthMethod = "login" | "register" | "oauth" | "refresh" | "password-reset" | "anonymous" | "magic-link" | "mfa";
|
|
54
|
-
|
|
55
47
|
/**
|
|
56
48
|
* Hook specific parts of the built-in Rebase auth implementation.
|
|
57
49
|
*
|
|
@@ -59,8 +51,6 @@ export type AuthMethod = "login" | "register" | "oauth" | "refresh" | "password-
|
|
|
59
51
|
* that is not provided.
|
|
60
52
|
*/
|
|
61
53
|
export interface AuthHooks {
|
|
62
|
-
// ─── Password Operations ──────────────────────────────────────────────
|
|
63
|
-
|
|
64
54
|
/**
|
|
65
55
|
* Hash a cleartext password for storage.
|
|
66
56
|
*
|
|
@@ -70,7 +60,6 @@ export interface AuthHooks {
|
|
|
70
60
|
* @returns The hashed password string (format is implementation-defined).
|
|
71
61
|
*/
|
|
72
62
|
hashPassword?(password: string): Promise<string>;
|
|
73
|
-
|
|
74
63
|
/**
|
|
75
64
|
* Verify a cleartext password against a stored hash.
|
|
76
65
|
*
|
|
@@ -81,7 +70,6 @@ export interface AuthHooks {
|
|
|
81
70
|
* @returns `true` if the password matches the hash.
|
|
82
71
|
*/
|
|
83
72
|
verifyPassword?(password: string, storedHash: string): Promise<boolean>;
|
|
84
|
-
|
|
85
73
|
/**
|
|
86
74
|
* Validate password strength before hashing.
|
|
87
75
|
*
|
|
@@ -91,9 +79,6 @@ export interface AuthHooks {
|
|
|
91
79
|
* @returns Validation result with `valid` flag and error messages.
|
|
92
80
|
*/
|
|
93
81
|
validatePasswordStrength?(password: string): PasswordValidationResult;
|
|
94
|
-
|
|
95
|
-
// ─── Credential Resolution ────────────────────────────────────────────
|
|
96
|
-
|
|
97
82
|
/**
|
|
98
83
|
* Override the complete credential verification during email/password login.
|
|
99
84
|
*
|
|
@@ -107,9 +92,6 @@ export interface AuthHooks {
|
|
|
107
92
|
* Default: `getUserByEmail(email)` + `verifyPassword(password, user.passwordHash)`.
|
|
108
93
|
*/
|
|
109
94
|
verifyCredentials?(email: string, password: string, repo: AuthRepository): Promise<UserData | null>;
|
|
110
|
-
|
|
111
|
-
// ─── Lifecycle Hooks ──────────────────────────────────────────────────
|
|
112
|
-
|
|
113
95
|
/**
|
|
114
96
|
* Called after any successful authentication event (login, register,
|
|
115
97
|
* OAuth, token refresh, password reset).
|
|
@@ -120,7 +102,6 @@ export interface AuthHooks {
|
|
|
120
102
|
* This is fire-and-forget — errors are logged but do not fail the request.
|
|
121
103
|
*/
|
|
122
104
|
onAuthenticated?(user: UserData, method: AuthMethod): Promise<void>;
|
|
123
|
-
|
|
124
105
|
/**
|
|
125
106
|
* Called before a new user is created (registration or admin creation).
|
|
126
107
|
*
|
|
@@ -130,7 +111,6 @@ export interface AuthHooks {
|
|
|
130
111
|
* Default: passthrough (returns data unchanged).
|
|
131
112
|
*/
|
|
132
113
|
beforeUserCreate?(data: CreateUserData): Promise<CreateUserData>;
|
|
133
|
-
|
|
134
114
|
/**
|
|
135
115
|
* Called after a new user is created.
|
|
136
116
|
*
|
|
@@ -140,9 +120,6 @@ export interface AuthHooks {
|
|
|
140
120
|
* This is fire-and-forget — errors are logged but do not fail the request.
|
|
141
121
|
*/
|
|
142
122
|
afterUserCreate?(user: UserData): Promise<void>;
|
|
143
|
-
|
|
144
|
-
// ─── Extended Lifecycle Hooks ─────────────────────────────────────────
|
|
145
|
-
|
|
146
123
|
/**
|
|
147
124
|
* Pre-login validation. Called before credential verification.
|
|
148
125
|
*
|
|
@@ -150,7 +127,6 @@ export interface AuthHooks {
|
|
|
150
127
|
* IP-based restrictions, etc.).
|
|
151
128
|
*/
|
|
152
129
|
beforeLogin?(email: string, method: AuthMethod): Promise<void>;
|
|
153
|
-
|
|
154
130
|
/**
|
|
155
131
|
* Post-logout cleanup.
|
|
156
132
|
*
|
|
@@ -160,7 +136,6 @@ export interface AuthHooks {
|
|
|
160
136
|
* This is fire-and-forget — errors are logged but do not fail the request.
|
|
161
137
|
*/
|
|
162
138
|
afterLogout?(userId: string): Promise<void>;
|
|
163
|
-
|
|
164
139
|
/**
|
|
165
140
|
* Called after successful MFA verification.
|
|
166
141
|
*
|
|
@@ -169,7 +144,6 @@ export interface AuthHooks {
|
|
|
169
144
|
* This is fire-and-forget — errors are logged but do not fail the request.
|
|
170
145
|
*/
|
|
171
146
|
onMfaVerified?(userId: string, factorId: string): Promise<void>;
|
|
172
|
-
|
|
173
147
|
/**
|
|
174
148
|
* Customize JWT access token claims before signing.
|
|
175
149
|
*
|
|
@@ -181,7 +155,6 @@ export interface AuthHooks {
|
|
|
181
155
|
* @returns Modified claims to include in the JWT.
|
|
182
156
|
*/
|
|
183
157
|
customizeAccessToken?(claims: Record<string, unknown>, user: UserData): Promise<Record<string, unknown>>;
|
|
184
|
-
|
|
185
158
|
/**
|
|
186
159
|
* Transform the auth response before sending it to the client.
|
|
187
160
|
*
|
|
@@ -190,18 +163,14 @@ export interface AuthHooks {
|
|
|
190
163
|
* response and returns a (potentially enriched) response.
|
|
191
164
|
*
|
|
192
165
|
* Use cases:
|
|
193
|
-
* - Inject tokens from external auth systems (
|
|
166
|
+
* - Inject tokens from external auth systems (custom provider tokens, etc.)
|
|
194
167
|
* - Add project-specific metadata to the response
|
|
195
168
|
* - Enrich the user object with data from external sources
|
|
196
169
|
*
|
|
197
170
|
* The hook runs in the request path — keep it fast.
|
|
198
171
|
* Heavy work should be offloaded to `onAuthenticated` (fire-and-forget).
|
|
199
172
|
*/
|
|
200
|
-
transformAuthResponse?(
|
|
201
|
-
response: AuthResponsePayload,
|
|
202
|
-
context: TransformAuthResponseContext
|
|
203
|
-
): Promise<AuthResponsePayload>;
|
|
204
|
-
|
|
173
|
+
transformAuthResponse?(response: AuthResponsePayload, context: TransformAuthResponseContext): Promise<AuthResponsePayload>;
|
|
205
174
|
/**
|
|
206
175
|
* Called after a successful password reset.
|
|
207
176
|
*
|
|
@@ -210,7 +179,6 @@ export interface AuthHooks {
|
|
|
210
179
|
* This is fire-and-forget — errors are logged but do not fail the request.
|
|
211
180
|
*/
|
|
212
181
|
onPasswordReset?(userId: string): Promise<void>;
|
|
213
|
-
|
|
214
182
|
/**
|
|
215
183
|
* Called before a user is deleted.
|
|
216
184
|
*
|
|
@@ -218,7 +186,6 @@ export interface AuthHooks {
|
|
|
218
186
|
* subscriptions, pending transactions, etc.).
|
|
219
187
|
*/
|
|
220
188
|
beforeUserDelete?(userId: string): Promise<void>;
|
|
221
|
-
|
|
222
189
|
/**
|
|
223
190
|
* Called after a user is deleted.
|
|
224
191
|
*
|
|
@@ -227,42 +194,33 @@ export interface AuthHooks {
|
|
|
227
194
|
* This is fire-and-forget — errors are logged but do not fail the request.
|
|
228
195
|
*/
|
|
229
196
|
afterUserDelete?(userId: string): Promise<void>;
|
|
230
|
-
|
|
231
197
|
/**
|
|
232
198
|
* Optional hook to customize or override the default user creation flow via the admin panel/REST API.
|
|
233
199
|
* When provided, this replaces the built-in password generation, hashing, and invitation email logic.
|
|
234
200
|
*/
|
|
235
|
-
onAdminCreateUser?(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
hashPassword: (password: string) => Promise<string>;
|
|
242
|
-
}
|
|
243
|
-
): Promise<{
|
|
201
|
+
onAdminCreateUser?(values: Record<string, unknown>, ctx: {
|
|
202
|
+
authRepo: AuthRepository;
|
|
203
|
+
emailService?: EmailService;
|
|
204
|
+
emailConfig?: EmailConfig;
|
|
205
|
+
hashPassword: (password: string) => Promise<string>;
|
|
206
|
+
}): Promise<{
|
|
244
207
|
values: Record<string, unknown>;
|
|
245
208
|
temporaryPassword?: string;
|
|
246
209
|
invitationSent?: boolean;
|
|
247
210
|
}>;
|
|
248
|
-
|
|
249
211
|
/**
|
|
250
212
|
* Optional hook to customize or override the default password reset flow via the admin panel.
|
|
251
213
|
* When provided, this replaces the built-in password reset token generation, hashing, and email logic.
|
|
252
214
|
*/
|
|
253
|
-
onAdminResetPassword?(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
emailConfig?: EmailConfig;
|
|
259
|
-
}
|
|
260
|
-
): Promise<{
|
|
215
|
+
onAdminResetPassword?(userId: string, ctx: {
|
|
216
|
+
authRepo: AuthRepository;
|
|
217
|
+
emailService?: EmailService;
|
|
218
|
+
emailConfig?: EmailConfig;
|
|
219
|
+
}): Promise<{
|
|
261
220
|
temporaryPassword?: string;
|
|
262
221
|
invitationSent?: boolean;
|
|
263
222
|
}>;
|
|
264
223
|
}
|
|
265
|
-
|
|
266
224
|
/**
|
|
267
225
|
* Resolved auth hooks — password operations are guaranteed to exist,
|
|
268
226
|
* all other hooks are passed through as-is (optional).
|
|
@@ -273,10 +231,7 @@ export interface AuthHooks {
|
|
|
273
231
|
* Consumers should use the resolved object exclusively —
|
|
274
232
|
* never access the raw `AuthHooks` directly.
|
|
275
233
|
*/
|
|
276
|
-
export type ResolvedAuthHooks =
|
|
277
|
-
Required<Pick<AuthHooks, "hashPassword" | "verifyPassword" | "validatePasswordStrength">>
|
|
278
|
-
& Omit<AuthHooks, "hashPassword" | "verifyPassword" | "validatePasswordStrength">;
|
|
279
|
-
|
|
234
|
+
export type ResolvedAuthHooks = Required<Pick<AuthHooks, "hashPassword" | "verifyPassword" | "validatePasswordStrength">> & Omit<AuthHooks, "hashPassword" | "verifyPassword" | "validatePasswordStrength">;
|
|
280
235
|
/**
|
|
281
236
|
* Merge user-provided hooks with the built-in defaults to produce
|
|
282
237
|
* a complete set of resolved hooks.
|
|
@@ -284,17 +239,4 @@ export type ResolvedAuthHooks =
|
|
|
284
239
|
* This is the single point where defaults are applied — all consumers
|
|
285
240
|
* call this once and use the resolved hooks throughout.
|
|
286
241
|
*/
|
|
287
|
-
export function resolveAuthHooks(hooks?: AuthHooks): ResolvedAuthHooks
|
|
288
|
-
return {
|
|
289
|
-
...hooks,
|
|
290
|
-
|
|
291
|
-
hashPassword: hooks?.hashPassword
|
|
292
|
-
?? defaultHashPassword,
|
|
293
|
-
|
|
294
|
-
verifyPassword: hooks?.verifyPassword
|
|
295
|
-
?? defaultVerifyPassword,
|
|
296
|
-
|
|
297
|
-
validatePasswordStrength: hooks?.validatePasswordStrength
|
|
298
|
-
?? defaultValidatePasswordStrength
|
|
299
|
-
};
|
|
300
|
-
}
|
|
242
|
+
export declare function resolveAuthHooks(hooks?: AuthHooks): ResolvedAuthHooks;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Bitbucket OAuth Provider integration (OAuth 2.0 consumer).
|
|
4
|
+
*/
|
|
5
|
+
export declare function createBitbucketProvider(config: {
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
}): OAuthProvider<{
|
|
9
|
+
code: string;
|
|
10
|
+
redirectUri: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RebaseBuiltinAuthAdapter
|
|
3
|
+
*
|
|
4
|
+
* Wraps Rebase's existing built-in JWT auth system (routes, middleware, user/role
|
|
5
|
+
* management) into the `AuthAdapter` interface. This is the default adapter used
|
|
6
|
+
* when the user passes a plain `RebaseAuthConfig` object.
|
|
7
|
+
*
|
|
8
|
+
* This is NOT a rewrite — it delegates to the existing `createAuthRoutes()`,
|
|
9
|
+
* `createResetPasswordRoute()`, and `verifyAccessToken()` functions. The goal is to
|
|
10
|
+
* present the same functionality through the pluggable `AuthAdapter` contract.
|
|
11
|
+
*/
|
|
12
|
+
import type { AuthAdapter } from "@rebasepro/types";
|
|
13
|
+
import type { AuthRepository, OAuthProvider } from "./interfaces";
|
|
14
|
+
import type { AuthHooks } from "./auth-hooks";
|
|
15
|
+
import type { EmailService, EmailConfig } from "../email";
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for the built-in Rebase auth adapter.
|
|
18
|
+
*
|
|
19
|
+
* This mirrors the existing `RebaseAuthConfig` — users pass this and
|
|
20
|
+
* server-core auto-wraps it in a `RebaseBuiltinAuthAdapter`.
|
|
21
|
+
*/
|
|
22
|
+
export interface BuiltinAuthAdapterConfig {
|
|
23
|
+
/** The bootstrapper-provided auth repository (users, roles, tokens). */
|
|
24
|
+
authRepository: AuthRepository;
|
|
25
|
+
/** Email service for password resets, verification, etc. */
|
|
26
|
+
emailService?: EmailService;
|
|
27
|
+
/** Email configuration. */
|
|
28
|
+
emailConfig?: EmailConfig;
|
|
29
|
+
/** Whether to allow new user registration. */
|
|
30
|
+
allowRegistration?: boolean;
|
|
31
|
+
/** Whether to expose the authenticated email→minimal-profile lookup route. */
|
|
32
|
+
allowUserLookup?: boolean;
|
|
33
|
+
/** Default role to assign to new users. */
|
|
34
|
+
defaultRole?: string;
|
|
35
|
+
/** OAuth providers to register. */
|
|
36
|
+
oauthProviders?: OAuthProvider<unknown>[];
|
|
37
|
+
/** Static service key for server-to-server auth. */
|
|
38
|
+
serviceKey?: string;
|
|
39
|
+
/** Auth hooks for customizing password, credentials, lifecycle, etc. */
|
|
40
|
+
authHooks?: AuthHooks;
|
|
41
|
+
/** The parsed auth config from the collection (if `auth` is an object, not just `true`). */
|
|
42
|
+
collectionAuthConfig?: import("@rebasepro/types").AuthCollectionConfig;
|
|
43
|
+
/** Enable magic link (passwordless email) login. Requires email service. */
|
|
44
|
+
enableMagicLink?: boolean;
|
|
45
|
+
/** Opt-in httpOnly cookie mode for refresh tokens. */
|
|
46
|
+
cookieAuth?: import("./routes").CookieAuthConfig;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create the built-in Rebase auth adapter.
|
|
50
|
+
*
|
|
51
|
+
* This wraps the existing auth infrastructure (JWT, OAuth, user/role management)
|
|
52
|
+
* into the `AuthAdapter` interface. It's used internally by `initializeRebaseBackend()`
|
|
53
|
+
* when the user passes a plain `RebaseAuthConfig` object.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createBuiltinAuthAdapter(config: BuiltinAuthAdapterConfig): AuthAdapter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import type { AuthResponsePayload } from "@rebasepro/types";
|
|
3
|
+
import type { HonoEnv } from "../api/types";
|
|
4
|
+
import type { CookieAuthConfig } from "./routes";
|
|
5
|
+
/**
|
|
6
|
+
* Cookie auth helpers for httpOnly refresh tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCookieSettings(config: CookieAuthConfig | undefined): {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
12
|
+
domain: string | undefined;
|
|
13
|
+
secure: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Set the refresh token as an httpOnly cookie on the response.
|
|
17
|
+
*/
|
|
18
|
+
export declare function setRefreshCookie(c: Context<HonoEnv>, refreshToken: string, config: CookieAuthConfig | undefined): void;
|
|
19
|
+
/**
|
|
20
|
+
* Clear the refresh token cookie.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearRefreshCookie(c: Context<HonoEnv>, config: CookieAuthConfig | undefined): void;
|
|
23
|
+
/**
|
|
24
|
+
* Read the refresh token from the request — cookie first, then body fallback.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readRefreshToken(c: Context<HonoEnv>, body: {
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
}, config: CookieAuthConfig | undefined): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Redact the refresh token from the response body when cookie mode is active.
|
|
31
|
+
*/
|
|
32
|
+
export declare function redactRefreshToken(response: AuthResponsePayload, c: Context<HonoEnv>, refreshToken: string, config: CookieAuthConfig | undefined): AuthResponsePayload;
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import { timingSafeEqual } from "crypto";
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* Constant-time string comparison to prevent timing attacks.
|
|
11
8
|
*
|
|
@@ -16,16 +13,4 @@ import { timingSafeEqual } from "crypto";
|
|
|
16
13
|
* @param b - Second string to compare.
|
|
17
14
|
* @returns `true` if the strings are identical, `false` otherwise.
|
|
18
15
|
*/
|
|
19
|
-
export function safeCompare(a: string, b: string): boolean
|
|
20
|
-
const maxLen = Math.max(a.length, b.length);
|
|
21
|
-
const bufA = Buffer.alloc(maxLen);
|
|
22
|
-
const bufB = Buffer.alloc(maxLen);
|
|
23
|
-
bufA.write(a);
|
|
24
|
-
bufB.write(b);
|
|
25
|
-
try {
|
|
26
|
-
const isEqual = timingSafeEqual(bufA, bufB);
|
|
27
|
-
return isEqual && a.length === b.length;
|
|
28
|
-
} catch {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
16
|
+
export declare function safeCompare(a: string, b: string): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Auth Adapter Factory
|
|
3
|
+
*
|
|
4
|
+
* Provides a minimal-config way for users with existing auth systems
|
|
5
|
+
* to plug into Rebase. Only `verifyRequest` is required — everything
|
|
6
|
+
* else is optional.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createCustomAuthAdapter } from "@rebasepro/server-core";
|
|
11
|
+
*
|
|
12
|
+
* const auth = createCustomAuthAdapter({
|
|
13
|
+
* verifyRequest: async (request) => {
|
|
14
|
+
* const token = request.headers.get("Authorization")?.replace("Bearer ", "");
|
|
15
|
+
* if (!token) return null;
|
|
16
|
+
* const decoded = jwt.verify(token, MY_SECRET);
|
|
17
|
+
* return {
|
|
18
|
+
* uid: decoded.sub,
|
|
19
|
+
* email: decoded.email,
|
|
20
|
+
* displayName: decoded.name,
|
|
21
|
+
* roles: decoded.roles || [],
|
|
22
|
+
* isAdmin: decoded.roles?.includes("admin") ?? false,
|
|
23
|
+
* };
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
import type { AuthAdapter, CustomAuthAdapterOptions } from "@rebasepro/types";
|
|
29
|
+
/**
|
|
30
|
+
* Create a custom auth adapter from minimal options.
|
|
31
|
+
*
|
|
32
|
+
* This is the recommended entry point for users who already have their own
|
|
33
|
+
* auth system and just need to tell Rebase how to extract the user from
|
|
34
|
+
* incoming requests.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Configuration options. Only `verifyRequest` is required.
|
|
37
|
+
* @returns A fully-formed `AuthAdapter` ready for `initializeRebaseBackend()`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createCustomAuthAdapter(options: CustomAuthAdapterOptions): AuthAdapter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Discord OAuth2 Provider integration.
|
|
4
|
+
*
|
|
5
|
+
* Uses the authorization code flow. Requires the "identify" and "email"
|
|
6
|
+
* scopes to retrieve the user's email and profile information.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createDiscordProvider(config: {
|
|
9
|
+
clientId: string;
|
|
10
|
+
clientSecret: string;
|
|
11
|
+
}): OAuthProvider<{
|
|
12
|
+
code: string;
|
|
13
|
+
redirectUri: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Facebook / Meta OAuth Provider integration.
|
|
4
|
+
*
|
|
5
|
+
* Uses the authorization code flow to exchange a code for an access token,
|
|
6
|
+
* then fetches user profile from the Facebook Graph API.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createFacebookProvider(config: {
|
|
9
|
+
clientId: string;
|
|
10
|
+
clientSecret: string;
|
|
11
|
+
}): OAuthProvider<{
|
|
12
|
+
code: string;
|
|
13
|
+
redirectUri: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a GitHub OAuth Provider integration.
|
|
4
|
+
*
|
|
5
|
+
* Flow: Frontend receives an authorization `code` via the GitHub OAuth redirect.
|
|
6
|
+
* This provider exchanges the code for an access token, then fetches the user's
|
|
7
|
+
* profile and primary email from the GitHub API.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createGitHubProvider(config: {
|
|
10
|
+
clientId: string;
|
|
11
|
+
clientSecret: string;
|
|
12
|
+
}): OAuthProvider<{
|
|
13
|
+
code: string;
|
|
14
|
+
redirectUri: string;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a GitLab OAuth Provider integration.
|
|
4
|
+
* Works with both GitLab.com and self-hosted instances.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createGitLabProvider(config: {
|
|
7
|
+
clientId: string;
|
|
8
|
+
clientSecret: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
}): OAuthProvider<{
|
|
11
|
+
code: string;
|
|
12
|
+
redirectUri: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { OAuthProvider } from "./interfaces";
|
|
2
|
+
export interface GoogleUserInfo {
|
|
3
|
+
googleId: string;
|
|
4
|
+
email: string;
|
|
5
|
+
displayName: string | null;
|
|
6
|
+
photoUrl: string | null;
|
|
7
|
+
emailVerified: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface GoogleProviderConfig {
|
|
10
|
+
clientId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The OAuth 2.0 client secret from Google Cloud Console.
|
|
13
|
+
*
|
|
14
|
+
* Required for the **authorization code flow** (Path 3), where the
|
|
15
|
+
* frontend sends an authorization `code` and the backend exchanges it
|
|
16
|
+
* server-side for tokens. This is the most secure flow because tokens
|
|
17
|
+
* never touch the browser.
|
|
18
|
+
*
|
|
19
|
+
* When omitted, only ID-token and access-token verification are available
|
|
20
|
+
* (Paths 1 & 2), which rely on the frontend obtaining tokens directly.
|
|
21
|
+
*/
|
|
22
|
+
clientSecret?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a Google OAuth Provider integration.
|
|
26
|
+
*
|
|
27
|
+
* Supports three verification paths:
|
|
28
|
+
*
|
|
29
|
+
* **Path 1 – ID Token** (One Tap / Sign In With Google button):
|
|
30
|
+
* Frontend sends `idToken`. Backend verifies cryptographically using
|
|
31
|
+
* Google's public keys. No secret required.
|
|
32
|
+
*
|
|
33
|
+
* **Path 2 – Access Token** (popup via `initTokenClient`):
|
|
34
|
+
* Frontend sends `accessToken`. Backend validates by calling Google's
|
|
35
|
+
* userinfo endpoint. No secret required.
|
|
36
|
+
*
|
|
37
|
+
* **Path 3 – Authorization Code** (most secure, requires `clientSecret`):
|
|
38
|
+
* Frontend sends `code` + `redirectUri`. Backend exchanges the code
|
|
39
|
+
* server-side for an ID token using `clientId` + `clientSecret`, then
|
|
40
|
+
* verifies the ID token. Tokens never touch the browser.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createGoogleProvider(config: GoogleProviderConfig | string): OAuthProvider<{
|
|
43
|
+
idToken?: string;
|
|
44
|
+
accessToken?: string;
|
|
45
|
+
code?: string;
|
|
46
|
+
redirectUri?: string;
|
|
47
|
+
}>;
|