@friggframework/core 2.0.0--canary.704.79d9a63.0 → 2.0.0--canary.686.e94de4d.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/CLAUDE.md +28 -40
- package/README.md +105 -0
- package/application/commands/entity-commands.js +60 -18
- package/application/commands/integration-commands.js +20 -73
- package/application/commands/scheduler-commands.js +11 -7
- package/application/commands/user-commands.js +17 -5
- package/application/index.js +6 -2
- package/core/Worker.js +31 -7
- package/core/create-handler.js +9 -0
- package/credential/repositories/credential-repository-documentdb.js +34 -0
- package/credential/repositories/credential-repository-interface.js +15 -0
- package/credential/repositories/credential-repository-mongo.js +23 -0
- package/credential/repositories/credential-repository-postgres.js +28 -0
- package/credential/use-cases/credential-operations-for-user.js +202 -0
- package/credential/use-cases/reauthorize-credential-for-user.js +73 -0
- package/database/config.js +48 -24
- package/database/documentdb-encryption-service.js +9 -22
- package/database/documentdb-utils.js +2 -0
- package/database/encryption/README.md +76 -14
- package/database/encryption/documentdb-encryption-service.md +78 -1
- package/database/encryption/encryption-config.js +219 -0
- package/database/encryption/encryption-schema-registry.js +93 -12
- package/database/encryption/integration-mapping-encryption.js +1 -1
- package/database/organization-where.js +18 -0
- package/database/prisma.js +15 -38
- package/database/unique-violation.js +25 -0
- package/database/use-cases/check-encryption-health-use-case.js +43 -52
- package/errors/index.js +0 -4
- package/extensions/bootstrap-runner.js +43 -0
- package/extensions/extension-loader.js +187 -0
- package/extensions/index.js +41 -0
- package/extensions/initialize-app.js +123 -0
- package/extensions/route-mounter.js +103 -0
- package/extensions/schema-composer.js +188 -0
- package/generated/prisma-mongodb/edge.js +43 -4
- package/generated/prisma-mongodb/index-browser.js +40 -1
- package/generated/prisma-mongodb/index.d.ts +4761 -133
- package/generated/prisma-mongodb/index.js +43 -4
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/schema.prisma +92 -0
- package/generated/prisma-mongodb/wasm.js +43 -4
- package/generated/prisma-postgresql/edge.js +43 -4
- package/generated/prisma-postgresql/index-browser.js +40 -1
- package/generated/prisma-postgresql/index.d.ts +4961 -28
- package/generated/prisma-postgresql/index.js +43 -4
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/schema.prisma +87 -0
- package/generated/prisma-postgresql/wasm.js +43 -4
- package/handlers/WEBHOOKS.md +0 -29
- package/handlers/app-definition-loader.js +121 -19
- package/handlers/app-handler-helpers.js +25 -3
- package/handlers/backend-utils.js +31 -25
- package/handlers/middleware/admin-auth.js +14 -1
- package/handlers/routers/auth.js +46 -10
- package/handlers/routers/health.js +13 -4
- package/handlers/routers/integration-defined-routers.js +144 -92
- package/handlers/routers/integration-webhook-routers.js +102 -64
- package/handlers/workers/integration-defined-workers.js +5 -2
- package/index.js +65 -3
- package/infrastructure/scheduler/index.js +19 -6
- package/infrastructure/scheduler/netlify-scheduler-adapter.js +216 -0
- package/infrastructure/scheduler/scheduled-job-repository.js +118 -0
- package/infrastructure/scheduler/scheduler-service-factory.js +55 -7
- package/integrations/index.js +1 -0
- package/integrations/integration-base.js +0 -29
- package/integrations/integration-router.js +131 -96
- package/integrations/repositories/integration-mapping-repository-documentdb.js +0 -50
- package/integrations/repositories/integration-mapping-repository-interface.js +0 -15
- package/integrations/repositories/integration-mapping-repository-mongo.js +0 -29
- package/integrations/repositories/integration-mapping-repository-postgres.js +0 -30
- package/integrations/repositories/integration-mapping-repository.js +0 -29
- package/integrations/repositories/integration-not-found.js +14 -0
- package/integrations/repositories/integration-repository-documentdb.js +35 -35
- package/integrations/repositories/integration-repository-interface.js +17 -31
- package/integrations/repositories/integration-repository-mongo.js +60 -129
- package/integrations/repositories/integration-repository-postgres.js +62 -134
- package/integrations/repositories/process-repository-mongo.js +1 -1
- package/integrations/schedule-config.js +80 -0
- package/integrations/tests/doubles/test-integration-repository.js +12 -1
- package/integrations/use-cases/create-integration.js +72 -75
- package/integrations/use-cases/dispatch-ongoing-syncs.js +100 -0
- package/integrations/use-cases/get-integrations-for-user.js +80 -40
- package/integrations/use-cases/index.js +7 -1
- package/integrations/use-cases/integration-operations-for-user.js +256 -0
- package/integrations/use-cases/resolve-integration-ownership.js +177 -0
- package/integrations/utils/map-integration-dto.js +43 -14
- package/management-api/create-management-api-router.js +49 -0
- package/management-api/error-response.js +116 -0
- package/management-api/management-api-config.js +151 -0
- package/management-api/meta-router.js +76 -0
- package/management-api/openapi/build-openapi.js +144 -0
- package/management-api/openapi/components.js +408 -0
- package/management-api/openapi/v1-operations.js +83 -0
- package/management-api/openapi/v2-operations.js +264 -0
- package/management-api/route-registry.js +411 -0
- package/management-api/test-support/http-client.js +39 -0
- package/management-api/use-cases/get-management-api-meta.js +57 -0
- package/management-api/v1-deprecation.js +120 -0
- package/management-api/v2/create-v2-router.js +85 -0
- package/management-api/v2/dependencies.js +281 -0
- package/management-api/v2/dto.js +143 -0
- package/management-api/v2/handlers/authorization.js +94 -0
- package/management-api/v2/handlers/credentials.js +33 -0
- package/management-api/v2/handlers/entities.js +77 -0
- package/management-api/v2/handlers/integrations.js +128 -0
- package/management-api/v2/handlers/proxy.js +34 -0
- package/management-api/v2/request.js +85 -0
- package/management-api/v2/test-support/fake-dependencies.js +103 -0
- package/modules/domain/authorization-session.js +144 -0
- package/modules/entity-scope.js +15 -0
- package/modules/entity-type-registry.js +311 -0
- package/modules/index.js +14 -0
- package/modules/module-factory.js +12 -0
- package/modules/module.js +53 -2
- package/modules/proxy/proxy-errors.js +20 -0
- package/modules/proxy/proxy-path.js +179 -0
- package/modules/proxy/proxy-policy.js +248 -0
- package/modules/repositories/authorization-session-repository-documentdb.js +112 -0
- package/modules/repositories/authorization-session-repository-factory.js +31 -0
- package/modules/repositories/authorization-session-repository-interface.js +47 -0
- package/modules/repositories/authorization-session-repository-prisma.js +87 -0
- package/modules/repositories/entity-not-found.js +18 -0
- package/modules/repositories/module-repository-documentdb.js +51 -6
- package/modules/repositories/module-repository-interface.js +19 -2
- package/modules/repositories/module-repository-mongo.js +67 -74
- package/modules/repositories/module-repository-postgres.js +66 -74
- package/modules/repositories/module-repository.js +2 -1
- package/modules/requester/proxy-request.js +244 -0
- package/modules/requester/requester.js +27 -2
- package/modules/scope-config.js +192 -0
- package/modules/scope-policy.js +112 -0
- package/modules/scope-resolution.js +288 -0
- package/modules/scope-visibility.js +247 -0
- package/modules/tests/doubles/in-memory-authorization-session-repository.js +45 -0
- package/modules/tests/doubles/ownership-matching.js +18 -0
- package/modules/use-cases/authorize-entity-for-user.js +61 -0
- package/modules/use-cases/create-entity-from-credential.js +113 -0
- package/modules/use-cases/entity-operations-for-user.js +162 -0
- package/modules/use-cases/entity-types.js +139 -0
- package/modules/use-cases/execute-entity-proxy-request.js +286 -0
- package/modules/use-cases/get-authorization-requirements.js +100 -0
- package/modules/use-cases/get-entities-for-user.js +26 -13
- package/modules/use-cases/get-entity-module-for-user.js +113 -0
- package/modules/use-cases/get-entity-options-by-id.js +10 -4
- package/modules/use-cases/get-entity-options-by-type.js +1 -1
- package/modules/use-cases/get-module-instance-from-type.js +1 -1
- package/modules/use-cases/get-module.js +10 -4
- package/modules/use-cases/manage-access.js +21 -0
- package/modules/use-cases/multi-step-authorization.js +329 -0
- package/modules/use-cases/process-authorization-callback.js +53 -19
- package/modules/use-cases/refresh-entity-options.js +10 -4
- package/modules/use-cases/test-module-auth.js +10 -4
- package/modules/utils/map-module-dto.js +3 -5
- package/package.json +6 -5
- package/prisma-mongodb/schema.prisma +92 -0
- package/prisma-postgresql/migrations/20261003000000_add_authorization_session/migration.sql +28 -0
- package/prisma-postgresql/migrations/20261015000000_add_organization_membership/migration.sql +26 -0
- package/prisma-postgresql/migrations/20261016000000_add_entity_integration_organization/migration.sql +25 -0
- package/prisma-postgresql/migrations/20261017000000_add_scheduled_job/migration.sql +28 -0
- package/prisma-postgresql/schema.prisma +87 -0
- package/providers/index.js +23 -0
- package/providers/resolve-provider.js +93 -0
- package/providers/runtime-detection.js +124 -0
- package/queues/index.js +25 -0
- package/queues/providers/index.js +11 -0
- package/queues/providers/netlify-background-provider.js +150 -0
- package/queues/providers/qstash-queue-provider.js +219 -0
- package/queues/providers/sqs-queue-provider.js +70 -0
- package/queues/queue-client-interface.js +55 -0
- package/queues/queue-message-auth.js +193 -0
- package/queues/queue-provider-factory.js +101 -0
- package/queues/queue-provider.js +65 -0
- package/queues/sqs-queue-client.js +81 -0
- package/types/index.d.ts +2 -0
- package/types/modules/index.d.ts +197 -0
- package/types/user/index.d.ts +134 -0
- package/user/adopter-jwt-config.js +177 -0
- package/user/adopter-jwt-errors.js +59 -0
- package/user/adopter-token-verifier.js +122 -0
- package/user/app-user-helpers.js +97 -0
- package/user/create-user-authentication.js +64 -0
- package/user/membership.js +51 -0
- package/user/repositories/organization-membership-record.js +19 -0
- package/user/repositories/organization-membership-repository-documentdb.js +106 -0
- package/user/repositories/organization-membership-repository-factory.js +42 -0
- package/user/repositories/organization-membership-repository-interface.js +57 -0
- package/user/repositories/organization-membership-repository-mongo.js +13 -0
- package/user/repositories/organization-membership-repository-postgres.js +29 -0
- package/user/repositories/organization-membership-repository-prisma.js +81 -0
- package/user/repositories/user-repository-documentdb.js +27 -2
- package/user/repositories/user-repository-interface.js +18 -0
- package/user/repositories/user-repository-mongo.js +24 -0
- package/user/repositories/user-repository-postgres.js +18 -0
- package/user/tests/doubles/adopter-jwt-fixtures.js +220 -0
- package/user/tests/doubles/test-user-repository.js +1 -1
- package/user/use-cases/authenticate-user.js +7 -1
- package/user/use-cases/ensure-organization-membership.js +92 -0
- package/user/use-cases/find-individual-users-by-organization.js +54 -0
- package/user/use-cases/get-user-from-adopter-jwt.js +95 -124
- package/user/use-cases/get-user-from-bearer-token.js +2 -7
- package/user/use-cases/get-user-from-x-frigg-headers.js +83 -80
- package/user/user.js +64 -1
- package/errors/mapping-already-exists-error.js +0 -14
- package/integrations/use-cases/add-entities-to-integration.js +0 -92
- package/integrations/use-cases/remove-entities-from-integration.js +0 -70
- package/integrations/utils/assert-entity-ids-input.js +0 -42
- package/modules/utils/to-credential-id.js +0 -14
package/modules/module.js
CHANGED
|
@@ -21,8 +21,17 @@ class Module extends Delegate {
|
|
|
21
21
|
* @param {string} params.userId The user id
|
|
22
22
|
* @param {Object} params.entity The entity record from the database
|
|
23
23
|
* @param {string} [params.state] Optional OAuth state value forwarded to the API client (round-trips through the OAuth provider).
|
|
24
|
+
* @param {Object} [params.resolvedEnv] definition.env as Module.create() resolved it (may be undefined).
|
|
25
|
+
* @param {boolean} [params.envResolved=false] true when resolvedEnv carries the resolved env, even an undefined one; otherwise the static definition.env is used.
|
|
24
26
|
*/
|
|
25
|
-
constructor({
|
|
27
|
+
constructor({
|
|
28
|
+
definition,
|
|
29
|
+
userId = null,
|
|
30
|
+
entity: entityObj = null,
|
|
31
|
+
state = null,
|
|
32
|
+
resolvedEnv,
|
|
33
|
+
envResolved = false,
|
|
34
|
+
}) {
|
|
26
35
|
super({ definition, userId, entity: entityObj });
|
|
27
36
|
|
|
28
37
|
this.validateDefinition(definition);
|
|
@@ -54,8 +63,23 @@ class Module extends Delegate {
|
|
|
54
63
|
|
|
55
64
|
Object.assign(this, this.definition.requiredAuthMethods);
|
|
56
65
|
|
|
66
|
+
// A pre-resolved env (Module.create()) supports definition.env as an
|
|
67
|
+
// async function, e.g. OAuth app credentials loaded from the database
|
|
68
|
+
// by the db-credentials extension; otherwise the static object.
|
|
69
|
+
// "Resolved" is an explicit flag, not a non-null value: a function env
|
|
70
|
+
// may legitimately resolve to undefined (no static env, no DB row),
|
|
71
|
+
// and falling back to definition.env would then read the function.
|
|
72
|
+
const envValues = envResolved ? resolvedEnv : this.definition.env;
|
|
73
|
+
if (typeof envValues === 'function') {
|
|
74
|
+
// Spreading a function yields no keys, so the API client would
|
|
75
|
+
// silently get no client_id / client_secret.
|
|
76
|
+
throw new TypeError(
|
|
77
|
+
`Module ${this.name}: definition.env is a function; build the module with await Module.create(...)`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
57
81
|
const apiParams = {
|
|
58
|
-
...
|
|
82
|
+
...envValues,
|
|
59
83
|
delegate: this,
|
|
60
84
|
logger: this.logger,
|
|
61
85
|
...(state ? { state } : {}),
|
|
@@ -67,6 +91,33 @@ class Module extends Delegate {
|
|
|
67
91
|
this.api = new this.apiClass(apiParams);
|
|
68
92
|
}
|
|
69
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Resolves definition.env, supporting both a static object and a
|
|
96
|
+
* (possibly async) function.
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} definition - Module definition
|
|
99
|
+
* @returns {Promise<Object|undefined>} Resolved env values
|
|
100
|
+
*/
|
|
101
|
+
static async resolveEnv(definition) {
|
|
102
|
+
if (typeof definition.env === 'function') {
|
|
103
|
+
return await definition.env();
|
|
104
|
+
}
|
|
105
|
+
return definition.env;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Async factory that resolves definition.env first, so a module whose
|
|
110
|
+
* env is a function gets its values. Prefer it over `new Module(...)`
|
|
111
|
+
* wherever the call site can await.
|
|
112
|
+
*
|
|
113
|
+
* @param {Object} params - same as the constructor, minus resolvedEnv
|
|
114
|
+
* @returns {Promise<Module>}
|
|
115
|
+
*/
|
|
116
|
+
static async create({ definition, userId = null, entity = null, state = null }) {
|
|
117
|
+
const resolvedEnv = await Module.resolveEnv(definition);
|
|
118
|
+
return new Module({ definition, userId, entity, state, resolvedEnv, envResolved: true });
|
|
119
|
+
}
|
|
120
|
+
|
|
70
121
|
getName() {
|
|
71
122
|
return this.name;
|
|
72
123
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A proxied call was refused or failed in a way the Management API maps to a
|
|
3
|
+
* documented status (ADR-052 §10). `code` is the public error code; nothing
|
|
4
|
+
* here carries the upstream URL, headers or credential material.
|
|
5
|
+
*/
|
|
6
|
+
class ProxyRequestError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} code - e.g. INVALID_PROXY_REQUEST, PROXY_NOT_ALLOWED, TIMEOUT
|
|
9
|
+
* @param {string} message - safe to show the caller
|
|
10
|
+
* @param {Object} [details] - safe structured details
|
|
11
|
+
*/
|
|
12
|
+
constructor(code, message, details) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'ProxyRequestError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.details = details;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = { ProxyRequestError };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const { ProxyRequestError } = require('./proxy-errors');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Path rules for the entity proxy (ADR-052 §4). The caller supplies a path
|
|
5
|
+
* relative to the module's base URL and nothing else: the host, scheme and
|
|
6
|
+
* port always come from the module.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const invalid = (reason) =>
|
|
10
|
+
new ProxyRequestError('INVALID_PROXY_REQUEST', `Invalid proxy path: ${reason}`, {
|
|
11
|
+
field: 'path',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Control characters (C0, DEL, C1), any whitespace, and invisible format
|
|
15
|
+
// characters such as zero-width spaces and byte-order marks.
|
|
16
|
+
const FORBIDDEN_CHARS = /[\x00-\x20\x7f-\x9f]|\s|\p{Cf}/u;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validates and normalises a caller-supplied path.
|
|
20
|
+
*
|
|
21
|
+
* - must start with a single `/`; `//` (anywhere), `\`, `?`, `#`, control
|
|
22
|
+
* and whitespace characters are rejected;
|
|
23
|
+
* - encoded separators (`%2f`, `%5c`) are rejected, then the path is
|
|
24
|
+
* percent-decoded exactly once; a `%` left after decoding (double
|
|
25
|
+
* encoding) is rejected, as is any decoded control or whitespace
|
|
26
|
+
* character other than a space (`%20`);
|
|
27
|
+
* - `.` and `..` segments are rejected rather than resolved.
|
|
28
|
+
*
|
|
29
|
+
* @param {unknown} path
|
|
30
|
+
* @returns {string} the decoded path, e.g. `/crm/v3/objects/contacts`
|
|
31
|
+
* @throws {ProxyRequestError} INVALID_PROXY_REQUEST
|
|
32
|
+
*/
|
|
33
|
+
function normalizeProxyPath(path) {
|
|
34
|
+
if (typeof path !== 'string' || path.length === 0) {
|
|
35
|
+
throw invalid('path must be a non-empty string');
|
|
36
|
+
}
|
|
37
|
+
if (path.length > 2048) throw invalid('path is too long');
|
|
38
|
+
if (!path.startsWith('/')) throw invalid('path must start with /');
|
|
39
|
+
if (path.startsWith('//') || path.includes('//')) {
|
|
40
|
+
throw invalid('empty path segments (//) are not allowed');
|
|
41
|
+
}
|
|
42
|
+
if (path.includes('\\')) throw invalid('backslashes are not allowed');
|
|
43
|
+
if (path.includes('?') || path.includes('#')) {
|
|
44
|
+
throw invalid('send the query string in `query`, not in the path');
|
|
45
|
+
}
|
|
46
|
+
if (FORBIDDEN_CHARS.test(path)) {
|
|
47
|
+
throw invalid('control and whitespace characters are not allowed');
|
|
48
|
+
}
|
|
49
|
+
if (/%(2f|5c)/i.test(path)) {
|
|
50
|
+
throw invalid('encoded path separators are not allowed');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let decoded;
|
|
54
|
+
try {
|
|
55
|
+
decoded = decodeURIComponent(path);
|
|
56
|
+
} catch {
|
|
57
|
+
throw invalid('malformed percent-encoding');
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
decoded.includes('%') ||
|
|
61
|
+
decoded.includes('\\') ||
|
|
62
|
+
decoded.includes('?') ||
|
|
63
|
+
decoded.includes('#') ||
|
|
64
|
+
decoded.includes('//') ||
|
|
65
|
+
// An encoded space (%20) is a legitimate path character; every other
|
|
66
|
+
// control or whitespace character stays forbidden.
|
|
67
|
+
FORBIDDEN_CHARS.test(decoded.replaceAll(' ', ''))
|
|
68
|
+
) {
|
|
69
|
+
throw invalid('encoded characters decode to something not allowed');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const segments = decoded.split('/').slice(1);
|
|
73
|
+
if (segments.some((segment) => segment === '.' || segment === '..')) {
|
|
74
|
+
throw invalid('dot segments (. and ..) are not allowed');
|
|
75
|
+
}
|
|
76
|
+
return decoded;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Joins a module base URL and a normalised path, then proves the result
|
|
81
|
+
* cannot leave the module's API: https only, same origin as the base URL,
|
|
82
|
+
* and under the base URL's path.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} baseUrl - from the module, never from the request
|
|
85
|
+
* @param {string} normalizedPath - from normalizeProxyPath()
|
|
86
|
+
* @returns {{ url: string, basePath: string, origin: string }} `url` is not
|
|
87
|
+
* percent-encoded; the Requester encodes it once.
|
|
88
|
+
* @throws {ProxyRequestError} PROXY_NOT_CONFIGURED or INVALID_PROXY_REQUEST
|
|
89
|
+
*/
|
|
90
|
+
function joinProxyUrl(baseUrl, normalizedPath) {
|
|
91
|
+
let base;
|
|
92
|
+
try {
|
|
93
|
+
base = new URL(baseUrl);
|
|
94
|
+
} catch {
|
|
95
|
+
throw new ProxyRequestError(
|
|
96
|
+
'PROXY_NOT_CONFIGURED',
|
|
97
|
+
'The module has no valid base URL to proxy to'
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (base.protocol !== 'https:') {
|
|
101
|
+
throw new ProxyRequestError(
|
|
102
|
+
'PROXY_NOT_CONFIGURED',
|
|
103
|
+
'The module base URL must use https to be proxied'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (base.username || base.password || base.search || base.hash) {
|
|
107
|
+
throw new ProxyRequestError(
|
|
108
|
+
'PROXY_NOT_CONFIGURED',
|
|
109
|
+
'The module base URL must not carry credentials, a query or a fragment'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const basePath = base.pathname.replace(/\/+$/, '');
|
|
114
|
+
const url = `${base.origin}${basePath}${normalizedPath}`;
|
|
115
|
+
|
|
116
|
+
let joined;
|
|
117
|
+
try {
|
|
118
|
+
joined = new URL(url);
|
|
119
|
+
} catch {
|
|
120
|
+
throw invalid('the joined URL is not valid');
|
|
121
|
+
}
|
|
122
|
+
const joinedPath = decodeURIComponent(joined.pathname);
|
|
123
|
+
if (
|
|
124
|
+
joined.protocol !== 'https:' ||
|
|
125
|
+
joined.origin !== base.origin ||
|
|
126
|
+
joined.username ||
|
|
127
|
+
joined.password ||
|
|
128
|
+
!(joinedPath === basePath || joinedPath.startsWith(`${basePath}/`))
|
|
129
|
+
) {
|
|
130
|
+
throw invalid('the path leaves the module API');
|
|
131
|
+
}
|
|
132
|
+
return { url, basePath, origin: base.origin };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Finds the allow-list rule that permits `method` on `path`.
|
|
137
|
+
*
|
|
138
|
+
* Patterns use `:param` for exactly one segment and a trailing `/**` for a
|
|
139
|
+
* subtree (the prefix itself included). `method: '*'` matches any method.
|
|
140
|
+
*
|
|
141
|
+
* @param {Array<{method: string, path: string}>} rules
|
|
142
|
+
* @param {string} method - upper case
|
|
143
|
+
* @param {string} path - normalised path
|
|
144
|
+
* @returns {{method: string, path: string}|null}
|
|
145
|
+
*/
|
|
146
|
+
function matchAllowRule(rules, method, path) {
|
|
147
|
+
const requestSegments = path.split('/').slice(1);
|
|
148
|
+
for (const rule of rules || []) {
|
|
149
|
+
if (!rule || typeof rule.path !== 'string' || typeof rule.method !== 'string') {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const ruleMethod = rule.method.toUpperCase();
|
|
153
|
+
if (ruleMethod !== '*' && ruleMethod !== method) continue;
|
|
154
|
+
if (patternMatches(rule.path, requestSegments)) return rule;
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function patternMatches(pattern, requestSegments) {
|
|
160
|
+
if (!pattern.startsWith('/')) return false;
|
|
161
|
+
let patternSegments = pattern.split('/').slice(1);
|
|
162
|
+
let subtree = false;
|
|
163
|
+
if (patternSegments[patternSegments.length - 1] === '**') {
|
|
164
|
+
subtree = true;
|
|
165
|
+
patternSegments = patternSegments.slice(0, -1);
|
|
166
|
+
}
|
|
167
|
+
if (subtree) {
|
|
168
|
+
if (requestSegments.length < patternSegments.length) return false;
|
|
169
|
+
} else if (requestSegments.length !== patternSegments.length) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return patternSegments.every((segment, index) => {
|
|
173
|
+
const actual = requestSegments[index];
|
|
174
|
+
if (segment.startsWith(':')) return actual !== undefined && actual !== '';
|
|
175
|
+
return segment === actual;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
module.exports = { normalizeProxyPath, joinProxyUrl, matchAllowRule };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
const { ProxyRequestError } = require('./proxy-errors');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the entity proxy accepts and returns (ADR-052 §5-§7). Pure functions:
|
|
5
|
+
* no I/O, so every rule is unit-tested on its own.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const PROXY_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
|
|
9
|
+
const METHODS_WITH_BODY = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);
|
|
10
|
+
|
|
11
|
+
/** Request headers a caller may always send (lower case). */
|
|
12
|
+
const ALLOWED_REQUEST_HEADERS = [
|
|
13
|
+
'accept',
|
|
14
|
+
'content-type',
|
|
15
|
+
'accept-language',
|
|
16
|
+
'if-match',
|
|
17
|
+
'if-none-match',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** Request headers that are refused outright, even if a module lists them. */
|
|
21
|
+
const REJECTED_REQUEST_HEADERS = [
|
|
22
|
+
'authorization',
|
|
23
|
+
'proxy-authorization',
|
|
24
|
+
'cookie',
|
|
25
|
+
'host',
|
|
26
|
+
'forwarded',
|
|
27
|
+
'x-real-ip',
|
|
28
|
+
'x-api-key',
|
|
29
|
+
];
|
|
30
|
+
const REJECTED_REQUEST_HEADER_PREFIXES = ['x-forwarded-'];
|
|
31
|
+
|
|
32
|
+
/** Response headers never passed back (credentials and hop-by-hop). */
|
|
33
|
+
const REMOVED_RESPONSE_HEADERS = [
|
|
34
|
+
'authorization',
|
|
35
|
+
'proxy-authorization',
|
|
36
|
+
'proxy-authenticate',
|
|
37
|
+
'set-cookie',
|
|
38
|
+
'set-cookie2',
|
|
39
|
+
'www-authenticate',
|
|
40
|
+
'x-api-key',
|
|
41
|
+
'connection',
|
|
42
|
+
'keep-alive',
|
|
43
|
+
'te',
|
|
44
|
+
'trailer',
|
|
45
|
+
'transfer-encoding',
|
|
46
|
+
'upgrade',
|
|
47
|
+
// The body is re-encoded as JSON, so these no longer describe it.
|
|
48
|
+
'content-length',
|
|
49
|
+
'content-encoding',
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const invalid = (message, details) =>
|
|
53
|
+
new ProxyRequestError('INVALID_PROXY_REQUEST', message, details);
|
|
54
|
+
|
|
55
|
+
const isPlainObject = (value) =>
|
|
56
|
+
value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Validates the request body of POST /api/v2/entities/:id/proxy and returns
|
|
60
|
+
* it with the method upper-cased and the body serialised.
|
|
61
|
+
*
|
|
62
|
+
* @param {unknown} request
|
|
63
|
+
* @param {{ maxRequestBytes: number }} limits
|
|
64
|
+
* @returns {{ method: string, path: string, query?: Object, headers: Object, body?: string, requestBytes: number, bodyIsJson: boolean }}
|
|
65
|
+
*/
|
|
66
|
+
function validateProxyRequest(request, { maxRequestBytes }) {
|
|
67
|
+
if (!isPlainObject(request)) throw invalid('The proxy request must be a JSON object');
|
|
68
|
+
const method = typeof request.method === 'string' ? request.method.toUpperCase() : '';
|
|
69
|
+
if (!PROXY_METHODS.includes(method)) {
|
|
70
|
+
throw invalid(`method must be one of ${PROXY_METHODS.join(', ')}`, { field: 'method' });
|
|
71
|
+
}
|
|
72
|
+
if (typeof request.path !== 'string') {
|
|
73
|
+
throw invalid('path is required', { field: 'path' });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let query;
|
|
77
|
+
if (request.query !== undefined && request.query !== null) {
|
|
78
|
+
if (!isPlainObject(request.query)) throw invalid('query must be an object', { field: 'query' });
|
|
79
|
+
query = {};
|
|
80
|
+
for (const [key, value] of Object.entries(request.query)) {
|
|
81
|
+
const scalar = ['string', 'number', 'boolean'].includes(typeof value);
|
|
82
|
+
const list = Array.isArray(value) && value.every((v) => typeof v === 'string');
|
|
83
|
+
if (!scalar && !list) {
|
|
84
|
+
throw invalid(`query.${key} must be a string, number, boolean or array of strings`, {
|
|
85
|
+
field: `query.${key}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// The requester sends one value per key; arrays go comma-separated.
|
|
89
|
+
query[key] = list ? value.join(',') : value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const headers = {};
|
|
94
|
+
if (request.headers !== undefined && request.headers !== null) {
|
|
95
|
+
if (!isPlainObject(request.headers)) throw invalid('headers must be an object', { field: 'headers' });
|
|
96
|
+
for (const [name, value] of Object.entries(request.headers)) {
|
|
97
|
+
if (typeof value !== 'string') {
|
|
98
|
+
throw invalid(`header ${name} must be a string`, { field: `headers.${name}` });
|
|
99
|
+
}
|
|
100
|
+
headers[name.toLowerCase()] = value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let body;
|
|
105
|
+
let bodyIsJson = false;
|
|
106
|
+
if (request.body !== undefined && request.body !== null) {
|
|
107
|
+
if (!METHODS_WITH_BODY.has(method)) {
|
|
108
|
+
throw invalid(`${method} requests cannot have a body`, { field: 'body' });
|
|
109
|
+
}
|
|
110
|
+
if (typeof request.body === 'string') {
|
|
111
|
+
body = request.body;
|
|
112
|
+
} else {
|
|
113
|
+
body = JSON.stringify(request.body);
|
|
114
|
+
bodyIsJson = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const requestBytes = body === undefined ? 0 : Buffer.byteLength(body);
|
|
118
|
+
if (requestBytes > maxRequestBytes) {
|
|
119
|
+
throw new ProxyRequestError(
|
|
120
|
+
'PAYLOAD_TOO_LARGE',
|
|
121
|
+
`The proxied request body is larger than ${maxRequestBytes} bytes`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return { method, path: request.path, query, headers, body, bodyIsJson, requestBytes };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const isWildcardRule = (rule) => rule?.method === '*' || rule?.path === '/**';
|
|
128
|
+
|
|
129
|
+
const isValidRule = (rule) =>
|
|
130
|
+
isPlainObject(rule) &&
|
|
131
|
+
typeof rule.method === 'string' &&
|
|
132
|
+
typeof rule.path === 'string' &&
|
|
133
|
+
rule.path.startsWith('/');
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The allow-list in force for a module: the app definition's list for it when
|
|
137
|
+
* one is given (`managementApi.proxy.modules[name].allow`), otherwise the
|
|
138
|
+
* module's own `proxy.allow`. A module cannot grant itself a wildcard; only
|
|
139
|
+
* the app definition can. No list means nothing may be proxied.
|
|
140
|
+
*
|
|
141
|
+
* @returns {{ rules: Array<{method: string, path: string}>, source: 'app'|'module'|'none', ignored: number }}
|
|
142
|
+
*/
|
|
143
|
+
function resolveAllowRules(definition, moduleOverrides = {}) {
|
|
144
|
+
const override = moduleOverrides?.[definition.moduleName]?.allow;
|
|
145
|
+
if (Array.isArray(override)) {
|
|
146
|
+
return { rules: override.filter(isValidRule), source: 'app', ignored: 0 };
|
|
147
|
+
}
|
|
148
|
+
const declared = Array.isArray(definition.proxy?.allow) ? definition.proxy.allow : [];
|
|
149
|
+
const rules = declared.filter((rule) => isValidRule(rule) && !isWildcardRule(rule));
|
|
150
|
+
return {
|
|
151
|
+
rules,
|
|
152
|
+
source: rules.length ? 'module' : 'none',
|
|
153
|
+
ignored: declared.length - rules.length,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Keeps only the request headers the caller may set. A header from the
|
|
159
|
+
* rejected list (credentials, Host, forwarding headers, or one the module's
|
|
160
|
+
* own auth sets) fails the request instead of being dropped quietly.
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} headers - lower-cased names
|
|
163
|
+
* @param {Object} options
|
|
164
|
+
* @param {string[]} [options.moduleHeaders] - from the module's `proxy.headers`
|
|
165
|
+
* @param {string[]} [options.authHeaderNames] - headers the module's auth sets
|
|
166
|
+
*/
|
|
167
|
+
function filterRequestHeaders(headers, { moduleHeaders = [], authHeaderNames = [] } = {}) {
|
|
168
|
+
const rejected = new Set([
|
|
169
|
+
...REJECTED_REQUEST_HEADERS,
|
|
170
|
+
...authHeaderNames.filter(Boolean).map((name) => String(name).toLowerCase()),
|
|
171
|
+
]);
|
|
172
|
+
const allowed = new Set([
|
|
173
|
+
...ALLOWED_REQUEST_HEADERS,
|
|
174
|
+
...moduleHeaders.map((name) => String(name).toLowerCase()),
|
|
175
|
+
]);
|
|
176
|
+
const kept = {};
|
|
177
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
178
|
+
if (
|
|
179
|
+
rejected.has(name) ||
|
|
180
|
+
REJECTED_REQUEST_HEADER_PREFIXES.some((prefix) => name.startsWith(prefix))
|
|
181
|
+
) {
|
|
182
|
+
throw invalid(`The ${name} header cannot be sent through the proxy`, {
|
|
183
|
+
field: `headers.${name}`,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (allowed.has(name)) kept[name] = value;
|
|
187
|
+
}
|
|
188
|
+
return kept;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Removes credential and hop-by-hop headers from an upstream response, and
|
|
193
|
+
* the Location of a redirect the proxy refused to follow.
|
|
194
|
+
*/
|
|
195
|
+
function filterResponseHeaders(headers, { redirectBlocked = false, authHeaderNames = [] } = {}) {
|
|
196
|
+
const removed = new Set([
|
|
197
|
+
...REMOVED_RESPONSE_HEADERS,
|
|
198
|
+
...authHeaderNames.filter(Boolean).map((name) => String(name).toLowerCase()),
|
|
199
|
+
]);
|
|
200
|
+
if (redirectBlocked) removed.add('location');
|
|
201
|
+
const kept = {};
|
|
202
|
+
for (const [name, value] of Object.entries(headers || {})) {
|
|
203
|
+
if (!removed.has(name.toLowerCase())) kept[name.toLowerCase()] = value;
|
|
204
|
+
}
|
|
205
|
+
return kept;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const JSON_TYPE = /^application\/([a-z0-9.+-]*\+)?json\b/i;
|
|
209
|
+
const TEXT_TYPE = /^(text\/|application\/(xml|x-www-form-urlencoded|javascript|graphql)\b|[a-z]+\/[a-z0-9.+-]*\+xml\b)/i;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Turns the upstream body into the `data` of the proxy response: parsed JSON,
|
|
213
|
+
* text, or (only if the module allows binary) base64.
|
|
214
|
+
*
|
|
215
|
+
* @returns {{ data: unknown, encoding?: 'base64' }}
|
|
216
|
+
*/
|
|
217
|
+
function decodeResponseBody(body, contentType, { binary = false } = {}) {
|
|
218
|
+
if (!body || body.length === 0) return { data: null };
|
|
219
|
+
if (JSON_TYPE.test(contentType)) {
|
|
220
|
+
const text = body.toString('utf8');
|
|
221
|
+
try {
|
|
222
|
+
return { data: JSON.parse(text) };
|
|
223
|
+
} catch {
|
|
224
|
+
return { data: text };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (!contentType || TEXT_TYPE.test(contentType)) {
|
|
228
|
+
return { data: body.toString('utf8') };
|
|
229
|
+
}
|
|
230
|
+
if (binary) return { data: body.toString('base64'), encoding: 'base64' };
|
|
231
|
+
throw new ProxyRequestError(
|
|
232
|
+
'UNSUPPORTED_MEDIA_TYPE',
|
|
233
|
+
'The upstream response is binary and this module does not allow binary proxying',
|
|
234
|
+
{ contentType: contentType.split(';')[0] }
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
module.exports = {
|
|
239
|
+
PROXY_METHODS,
|
|
240
|
+
ALLOWED_REQUEST_HEADERS,
|
|
241
|
+
REJECTED_REQUEST_HEADERS,
|
|
242
|
+
REMOVED_RESPONSE_HEADERS,
|
|
243
|
+
validateProxyRequest,
|
|
244
|
+
resolveAllowRules,
|
|
245
|
+
filterRequestHeaders,
|
|
246
|
+
filterResponseHeaders,
|
|
247
|
+
decodeResponseBody,
|
|
248
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const { prisma } = require('../../database/prisma');
|
|
2
|
+
const {
|
|
3
|
+
findOne,
|
|
4
|
+
insertOne,
|
|
5
|
+
updateOne,
|
|
6
|
+
deleteMany,
|
|
7
|
+
} = require('../../database/documentdb-utils');
|
|
8
|
+
const {
|
|
9
|
+
DocumentDBEncryptionService,
|
|
10
|
+
} = require('../../database/documentdb-encryption-service');
|
|
11
|
+
const { AuthorizationSession } = require('../domain/authorization-session');
|
|
12
|
+
const {
|
|
13
|
+
AuthorizationSessionRepositoryInterface,
|
|
14
|
+
} = require('./authorization-session-repository-interface');
|
|
15
|
+
|
|
16
|
+
const COLLECTION = 'AuthorizationSession';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* AuthorizationSession persistence for DocumentDB through raw commands.
|
|
20
|
+
* `stepData` is encrypted with DocumentDBEncryptionService, as the Prisma
|
|
21
|
+
* extension does not run for raw commands.
|
|
22
|
+
*/
|
|
23
|
+
class AuthorizationSessionRepositoryDocumentDB extends AuthorizationSessionRepositoryInterface {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.prisma = prisma;
|
|
27
|
+
this.encryptionService = new DocumentDBEncryptionService();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async create(session) {
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const document = await this.encryptionService.encryptFields(COLLECTION, {
|
|
33
|
+
sessionId: session.sessionId,
|
|
34
|
+
userId: session.userId,
|
|
35
|
+
entityType: session.entityType,
|
|
36
|
+
credentialId: session.credentialId,
|
|
37
|
+
currentStep: session.currentStep,
|
|
38
|
+
maxSteps: session.maxSteps,
|
|
39
|
+
stepData: session.stepData,
|
|
40
|
+
expiresAt: session.expiresAt,
|
|
41
|
+
completed: session.completed,
|
|
42
|
+
createdAt: now,
|
|
43
|
+
updatedAt: now,
|
|
44
|
+
});
|
|
45
|
+
await insertOne(this.prisma, COLLECTION, document);
|
|
46
|
+
return this._toDomain(
|
|
47
|
+
await this.encryptionService.decryptFields(COLLECTION, document)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async findBySessionId(sessionId) {
|
|
52
|
+
if (typeof sessionId !== 'string' || !sessionId) return null;
|
|
53
|
+
const document = await findOne(this.prisma, COLLECTION, {
|
|
54
|
+
sessionId,
|
|
55
|
+
expiresAt: { $gt: new Date() },
|
|
56
|
+
});
|
|
57
|
+
if (!document) return null;
|
|
58
|
+
return this._toDomain(
|
|
59
|
+
await this.encryptionService.decryptFields(COLLECTION, document)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async update(session) {
|
|
64
|
+
const encrypted = await this.encryptionService.encryptFields(COLLECTION, {
|
|
65
|
+
stepData: session.stepData,
|
|
66
|
+
});
|
|
67
|
+
await updateOne(
|
|
68
|
+
this.prisma,
|
|
69
|
+
COLLECTION,
|
|
70
|
+
{ sessionId: session.sessionId },
|
|
71
|
+
{
|
|
72
|
+
$set: {
|
|
73
|
+
currentStep: session.currentStep,
|
|
74
|
+
stepData: encrypted.stepData,
|
|
75
|
+
completed: session.completed,
|
|
76
|
+
updatedAt: new Date(),
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
return session;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async deleteBySessionId(sessionId) {
|
|
84
|
+
const result = await deleteMany(this.prisma, COLLECTION, { sessionId });
|
|
85
|
+
return result?.n ?? 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async deleteExpired(now = new Date()) {
|
|
89
|
+
const result = await deleteMany(this.prisma, COLLECTION, {
|
|
90
|
+
expiresAt: { $lte: now },
|
|
91
|
+
});
|
|
92
|
+
return result?.n ?? 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
_toDomain(document) {
|
|
96
|
+
return new AuthorizationSession({
|
|
97
|
+
sessionId: document.sessionId,
|
|
98
|
+
userId: document.userId,
|
|
99
|
+
entityType: document.entityType,
|
|
100
|
+
credentialId: document.credentialId ?? null,
|
|
101
|
+
currentStep: document.currentStep,
|
|
102
|
+
maxSteps: document.maxSteps,
|
|
103
|
+
stepData: document.stepData || {},
|
|
104
|
+
expiresAt: new Date(document.expiresAt),
|
|
105
|
+
completed: Boolean(document.completed),
|
|
106
|
+
createdAt: document.createdAt,
|
|
107
|
+
updatedAt: document.updatedAt,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = { AuthorizationSessionRepositoryDocumentDB };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const config = require('../../database/config');
|
|
2
|
+
const {
|
|
3
|
+
AuthorizationSessionRepositoryPrisma,
|
|
4
|
+
} = require('./authorization-session-repository-prisma');
|
|
5
|
+
const {
|
|
6
|
+
AuthorizationSessionRepositoryDocumentDB,
|
|
7
|
+
} = require('./authorization-session-repository-documentdb');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* AuthorizationSession repository for the configured database. PostgreSQL
|
|
11
|
+
* and MongoDB share the Prisma adapter; DocumentDB uses raw commands.
|
|
12
|
+
*/
|
|
13
|
+
function createAuthorizationSessionRepository() {
|
|
14
|
+
switch (config.DB_TYPE) {
|
|
15
|
+
case 'mongodb':
|
|
16
|
+
case 'postgresql':
|
|
17
|
+
return new AuthorizationSessionRepositoryPrisma();
|
|
18
|
+
case 'documentdb':
|
|
19
|
+
return new AuthorizationSessionRepositoryDocumentDB();
|
|
20
|
+
default:
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Unsupported database type: ${config.DB_TYPE}. Supported values: 'mongodb', 'documentdb', 'postgresql'`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
createAuthorizationSessionRepository,
|
|
29
|
+
AuthorizationSessionRepositoryPrisma,
|
|
30
|
+
AuthorizationSessionRepositoryDocumentDB,
|
|
31
|
+
};
|