@owox/backend 0.38.0 → 0.39.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/dist/src/common/helpers/read-bounded-body.helper.d.ts +1 -0
- package/dist/src/common/helpers/read-bounded-body.helper.js +28 -0
- package/dist/src/common/scheduler/system-tasks/system-trigger-type.d.ts +3 -1
- package/dist/src/common/scheduler/system-tasks/system-trigger-type.js +2 -0
- package/dist/src/config/data-source-options.config.d.ts +4 -3
- package/dist/src/config/data-source-options.config.js +10 -3
- package/dist/src/config/plugin-collections-body-parser.config.js +3 -0
- package/dist/src/data-marts/credentials/credential.types.d.ts +26 -2
- package/dist/src/data-marts/credentials/credential.types.js +18 -6
- package/dist/src/data-marts/credentials/dto/credential-api.dto.d.ts +5 -1
- package/dist/src/data-marts/credentials/dto/credential-api.dto.js +21 -0
- package/dist/src/data-marts/credentials/dto/credential.dto.d.ts +2 -1
- package/dist/src/data-marts/credentials/entities/credential.entity.d.ts +2 -1
- package/dist/src/data-marts/credentials/entities/credential.entity.js +5 -0
- package/dist/src/data-marts/credentials/facades/credential-consumer-binding.facade.impl.js +6 -1
- package/dist/src/data-marts/credentials/mappers/credential.mapper.js +2 -0
- package/dist/src/data-marts/credentials/services/builtin-credential-definitions.js +8 -0
- package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.d.ts +4 -0
- package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.js +36 -17
- package/dist/src/data-marts/credentials/services/credential-fetch.service.d.ts +8 -0
- package/dist/src/data-marts/credentials/services/credential-fetch.service.js +115 -46
- package/dist/src/data-marts/credentials/services/credential-validation-probe.service.d.ts +3 -1
- package/dist/src/data-marts/credentials/services/credential-validation-probe.service.js +10 -2
- package/dist/src/data-marts/credentials/services/credential.service.d.ts +4 -0
- package/dist/src/data-marts/credentials/services/credential.service.js +36 -0
- package/dist/src/data-marts/credentials/services/google-service-account-key.d.ts +6 -0
- package/dist/src/data-marts/credentials/services/google-service-account-key.js +46 -0
- package/dist/src/data-marts/credentials/services/google-service-account-token.service.d.ts +25 -0
- package/dist/src/data-marts/credentials/services/google-service-account-token.service.js +177 -0
- package/dist/src/data-marts/credentials/use-cases/create-credential.service.d.ts +1 -0
- package/dist/src/data-marts/credentials/use-cases/create-credential.service.js +10 -2
- package/dist/src/data-marts/credentials/use-cases/update-credential.service.d.ts +1 -0
- package/dist/src/data-marts/credentials/use-cases/update-credential.service.js +28 -4
- package/dist/src/data-marts/credentials/use-cases/validate-credential.service.js +2 -5
- package/dist/src/data-marts/data-marts.module.js +4 -0
- package/dist/src/data-marts/data-storage-types/snowflake/adapters/snowflake-api.adapter.js +1 -0
- package/dist/src/data-marts/dto/presentation/run-data-mart-request-api.dto.js +4 -2
- package/dist/src/data-marts/services/connector/backfill-segment.d.ts +22 -0
- package/dist/src/data-marts/services/connector/backfill-segment.js +91 -0
- package/dist/src/data-marts/services/connector/connector-execution.service.d.ts +1 -0
- package/dist/src/data-marts/services/connector/connector-execution.service.js +3 -0
- package/dist/src/data-marts/services/connector/connector-executor.service.d.ts +4 -1
- package/dist/src/data-marts/services/connector/connector-executor.service.js +107 -23
- package/dist/src/data-marts/services/connector/connector-run.service.d.ts +3 -0
- package/dist/src/data-marts/services/connector/connector-run.service.js +98 -4
- package/dist/src/data-marts/services/data-mart-run.service.d.ts +1 -0
- package/dist/src/data-marts/services/data-mart-run.service.js +9 -0
- package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.d.ts +14 -0
- package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.js +45 -0
- package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.d.ts +4 -0
- package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.js +46 -1
- package/dist/src/data-marts/utils/manual-backfill-range.d.ts +52 -0
- package/dist/src/data-marts/utils/manual-backfill-range.js +110 -8
- package/dist/src/ee/mcp/instructions/mcp-system-instructions.d.ts +1 -1
- package/dist/src/ee/mcp/instructions/mcp-system-instructions.js +1 -0
- package/dist/src/idp/decorators/auth-context.decorator.js +1 -0
- package/dist/src/idp/guards/idp.guard.d.ts +3 -0
- package/dist/src/idp/guards/idp.guard.js +38 -8
- package/dist/src/idp/oauth/controllers/oauth-authorization.controller.js +8 -6
- package/dist/src/idp/oauth/mcp-client-integration.d.ts +1 -0
- package/dist/src/idp/oauth/mcp-client-integration.js +15 -0
- package/dist/src/idp/ports/plugin-runtime-authorizer.port.d.ts +6 -0
- package/dist/src/idp/types/auth.types.d.ts +1 -0
- package/dist/src/migrations/1790900000000-add-plugin-version-backend.d.ts +6 -0
- package/dist/src/migrations/1790900000000-add-plugin-version-backend.js +21 -0
- package/dist/src/migrations/1790900000001-create-plugin-action-execution.d.ts +6 -0
- package/dist/src/migrations/1790900000001-create-plugin-action-execution.js +77 -0
- package/dist/src/migrations/1791000000000-add-credential-public-metadata.d.ts +6 -0
- package/dist/src/migrations/1791000000000-add-credential-public-metadata.js +23 -0
- package/dist/src/plugin-host/collections/dto/domain/plugin-collection.types.d.ts +1 -0
- package/dist/src/plugin-host/collections/errors/plugin-collection.errors.d.ts +6 -0
- package/dist/src/plugin-host/collections/errors/plugin-collection.errors.js +19 -1
- package/dist/src/plugin-host/collections/services/plugin-collection-declaration.service.js +3 -3
- package/dist/src/plugin-host/collections/use-cases/put-plugin-collection-document.service.js +7 -0
- package/dist/src/plugin-host/constants/plugin-action-limits.d.ts +34 -0
- package/dist/src/plugin-host/constants/plugin-action-limits.js +51 -0
- package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.d.ts +20 -0
- package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.js +123 -0
- package/dist/src/plugin-host/controllers/plugin-credential-runtime.controller.js +11 -19
- package/dist/src/plugin-host/controllers/plugin-history.controller.d.ts +10 -0
- package/dist/src/plugin-host/controllers/plugin-history.controller.js +57 -0
- package/dist/src/plugin-host/controllers/plugin-release-check.controller.d.ts +10 -0
- package/dist/src/plugin-host/controllers/plugin-release-check.controller.js +58 -0
- package/dist/src/plugin-host/dto/domain/check-plugin-release.command.d.ts +22 -0
- package/dist/src/plugin-host/dto/domain/check-plugin-release.command.js +17 -0
- package/dist/src/plugin-host/dto/domain/list-plugin-history.command.d.ts +10 -0
- package/dist/src/plugin-host/dto/domain/list-plugin-history.command.js +18 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.d.ts +23 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.js +44 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.d.ts +36 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.js +3 -0
- package/dist/src/plugin-host/dto/domain/plugin-history.dto.d.ts +29 -0
- package/dist/src/plugin-host/dto/domain/plugin-history.dto.js +3 -0
- package/dist/src/plugin-host/dto/domain/plugin-view.dto.d.ts +1 -0
- package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.d.ts +44 -0
- package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.js +208 -0
- package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.d.ts +2 -0
- package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.js +7 -0
- package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.d.ts +29 -0
- package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.js +148 -0
- package/dist/src/plugin-host/dto/presentation/publication-api.dto.d.ts +17 -0
- package/dist/src/plugin-host/dto/presentation/publication-api.dto.js +95 -1
- package/dist/src/plugin-host/entities/plugin-action-execution.entity.d.ts +24 -0
- package/dist/src/plugin-host/entities/plugin-action-execution.entity.js +136 -0
- package/dist/src/plugin-host/entities/plugin-version.entity.d.ts +2 -1
- package/dist/src/plugin-host/entities/plugin-version.entity.js +5 -0
- package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.d.ts +9 -0
- package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.js +22 -0
- package/dist/src/plugin-host/enums/release-rejection-code.enum.d.ts +3 -0
- package/dist/src/plugin-host/enums/release-rejection-code.enum.js +6 -0
- package/dist/src/plugin-host/errors/plugin-action.errors.d.ts +45 -0
- package/dist/src/plugin-host/errors/plugin-action.errors.js +70 -0
- package/dist/src/plugin-host/errors/plugin-host.errors.d.ts +6 -0
- package/dist/src/plugin-host/errors/plugin-host.errors.js +10 -1
- package/dist/src/plugin-host/filters/plugin-host-exception.filter.js +2 -2
- package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.d.ts +3 -0
- package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.js +22 -0
- package/dist/src/plugin-host/mappers/plugin-presentation.mapper.d.ts +16 -1
- package/dist/src/plugin-host/mappers/plugin-presentation.mapper.js +80 -1
- package/dist/src/plugin-host/plugin-host.module.js +32 -0
- package/dist/src/plugin-host/services/action-input-validator.service.d.ts +23 -0
- package/dist/src/plugin-host/services/action-input-validator.service.js +277 -0
- package/dist/src/plugin-host/services/external-credential-definition-sync.service.d.ts +3 -0
- package/dist/src/plugin-host/services/external-credential-definition-sync.service.js +47 -15
- package/dist/src/plugin-host/services/plugin-action-dispatcher.service.d.ts +13 -0
- package/dist/src/plugin-host/services/plugin-action-dispatcher.service.js +140 -0
- package/dist/src/plugin-host/services/plugin-action-execution.service.d.ts +69 -0
- package/dist/src/plugin-host/services/plugin-action-execution.service.js +239 -0
- package/dist/src/plugin-host/services/plugin-action-starter.service.d.ts +22 -0
- package/dist/src/plugin-host/services/plugin-action-starter.service.js +81 -0
- package/dist/src/plugin-host/services/plugin-audit.service.d.ts +13 -0
- package/dist/src/plugin-host/services/plugin-audit.service.js +78 -0
- package/dist/src/plugin-host/services/plugin-publication.service.d.ts +2 -0
- package/dist/src/plugin-host/services/plugin-publication.service.js +18 -10
- package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.d.ts +5 -2
- package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.js +31 -3
- package/dist/src/plugin-host/services/plugin-version.service.d.ts +2 -1
- package/dist/src/plugin-host/services/release-candidate-rules.service.d.ts +51 -0
- package/dist/src/plugin-host/services/release-candidate-rules.service.js +198 -0
- package/dist/src/plugin-host/services/remote-url-validator.service.d.ts +7 -0
- package/dist/src/plugin-host/services/remote-url-validator.service.js +4 -0
- package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.d.ts +14 -0
- package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.js +50 -0
- package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.d.ts +8 -0
- package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.js +39 -0
- package/dist/src/plugin-host/use-cases/check-plugin-release.service.d.ts +22 -0
- package/dist/src/plugin-host/use-cases/check-plugin-release.service.js +152 -0
- package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.d.ts +14 -0
- package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.js +85 -0
- package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.d.ts +9 -0
- package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.js +67 -0
- package/dist/src/plugin-host/use-cases/get-plugin-installation-entry.service.js +2 -7
- package/dist/src/plugin-host/use-cases/install-plugin.service.js +4 -0
- package/dist/src/plugin-host/use-cases/list-plugin-history.service.d.ts +25 -0
- package/dist/src/plugin-host/use-cases/list-plugin-history.service.js +147 -0
- package/dist/src/plugin-host/use-cases/plugin-publisher-access.d.ts +5 -0
- package/dist/src/plugin-host/use-cases/plugin-publisher-access.js +28 -0
- package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.d.ts +12 -0
- package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.js +64 -0
- package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.d.ts +3 -5
- package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.js +15 -59
- package/dist/src/plugin-host/use-cases/uninstall-plugin.service.js +3 -1
- package/dist/src/plugin-host/use-cases/update-plugin.service.d.ts +0 -1
- package/dist/src/plugin-host/use-cases/update-plugin.service.js +3 -25
- package/dist/src/plugin-host/utils/action-input-schema.util.d.ts +14 -0
- package/dist/src/plugin-host/utils/action-input-schema.util.js +133 -0
- package/dist/src/plugin-host/utils/credential-handles.util.d.ts +3 -0
- package/dist/src/plugin-host/utils/credential-handles.util.js +13 -0
- package/dist/src/plugin-host/utils/execution-token.util.d.ts +5 -0
- package/dist/src/plugin-host/utils/execution-token.util.js +13 -0
- package/dist/src/plugin-host/utils/json-shape.util.d.ts +1 -0
- package/dist/src/plugin-host/utils/json-shape.util.js +21 -0
- package/dist/src/plugin-host/utils/plugin-action-outcome.util.d.ts +10 -0
- package/dist/src/plugin-host/utils/plugin-action-outcome.util.js +67 -0
- package/dist/src/plugin-host/utils/plugin-manifest.util.d.ts +121 -0
- package/dist/src/plugin-host/utils/plugin-manifest.util.js +111 -1
- package/dist/src/plugin-host/utils/request-abort-signal.util.d.ts +5 -0
- package/dist/src/plugin-host/utils/request-abort-signal.util.js +19 -0
- package/package.json +10 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readBoundedBody(response: Response, maxBytes: number): Promise<Buffer | null>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readBoundedBody = readBoundedBody;
|
|
4
|
+
async function readBoundedBody(response, maxBytes) {
|
|
5
|
+
const declaredLength = Number(response.headers.get('content-length'));
|
|
6
|
+
if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {
|
|
7
|
+
await response.body?.cancel();
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (!response.body)
|
|
11
|
+
return Buffer.alloc(0);
|
|
12
|
+
const reader = response.body.getReader();
|
|
13
|
+
const chunks = [];
|
|
14
|
+
let total = 0;
|
|
15
|
+
while (true) {
|
|
16
|
+
const { done, value } = await reader.read();
|
|
17
|
+
if (done)
|
|
18
|
+
break;
|
|
19
|
+
total += value.byteLength;
|
|
20
|
+
if (total > maxBytes) {
|
|
21
|
+
await reader.cancel();
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
chunks.push(value);
|
|
25
|
+
}
|
|
26
|
+
return Buffer.concat(chunks.map(chunk => Buffer.from(chunk)), total);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=read-bounded-body.helper.js.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export declare enum SystemTriggerType {
|
|
2
2
|
RETRY_INTERRUPTED_CONNECTOR_RUNS = "RETRY_INTERRUPTED_CONNECTOR_RUNS",
|
|
3
|
+
REPAIR_BACKFILL_CHAINS = "REPAIR_BACKFILL_CHAINS",
|
|
3
4
|
RUNS_NOTIFICATION = "RUNS_NOTIFICATION",
|
|
4
5
|
SEND_NOTIFICATIONS = "SEND_NOTIFICATIONS",
|
|
5
6
|
SEARCH_INDEX_DRIFT = "SEARCH_INDEX_DRIFT",
|
|
6
7
|
PLUGIN_UPDATE_CHECK = "PLUGIN_UPDATE_CHECK",
|
|
7
|
-
CREDENTIAL_DEFINITION_UPDATE_CHECK = "CREDENTIAL_DEFINITION_UPDATE_CHECK"
|
|
8
|
+
CREDENTIAL_DEFINITION_UPDATE_CHECK = "CREDENTIAL_DEFINITION_UPDATE_CHECK",
|
|
9
|
+
PLUGIN_ACTION_EXECUTION_SWEEP = "PLUGIN_ACTION_EXECUTION_SWEEP"
|
|
8
10
|
}
|
|
@@ -4,10 +4,12 @@ exports.SystemTriggerType = void 0;
|
|
|
4
4
|
var SystemTriggerType;
|
|
5
5
|
(function (SystemTriggerType) {
|
|
6
6
|
SystemTriggerType["RETRY_INTERRUPTED_CONNECTOR_RUNS"] = "RETRY_INTERRUPTED_CONNECTOR_RUNS";
|
|
7
|
+
SystemTriggerType["REPAIR_BACKFILL_CHAINS"] = "REPAIR_BACKFILL_CHAINS";
|
|
7
8
|
SystemTriggerType["RUNS_NOTIFICATION"] = "RUNS_NOTIFICATION";
|
|
8
9
|
SystemTriggerType["SEND_NOTIFICATIONS"] = "SEND_NOTIFICATIONS";
|
|
9
10
|
SystemTriggerType["SEARCH_INDEX_DRIFT"] = "SEARCH_INDEX_DRIFT";
|
|
10
11
|
SystemTriggerType["PLUGIN_UPDATE_CHECK"] = "PLUGIN_UPDATE_CHECK";
|
|
11
12
|
SystemTriggerType["CREDENTIAL_DEFINITION_UPDATE_CHECK"] = "CREDENTIAL_DEFINITION_UPDATE_CHECK";
|
|
13
|
+
SystemTriggerType["PLUGIN_ACTION_EXECUTION_SWEEP"] = "PLUGIN_ACTION_EXECUTION_SWEEP";
|
|
12
14
|
})(SystemTriggerType || (exports.SystemTriggerType = SystemTriggerType = {}));
|
|
13
15
|
//# sourceMappingURL=system-trigger-type.js.map
|
|
@@ -11,9 +11,10 @@ export declare class CustomDataSourceLogger implements Logger {
|
|
|
11
11
|
private readonly logQueryParameters;
|
|
12
12
|
constructor(logger: LoggerService, loggingOptions: LoggerOptions, logQueryParameters?: boolean);
|
|
13
13
|
private checkLoggingOptions;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
private loggableParameters;
|
|
15
|
+
logQuery(query: string, queryParameters?: unknown[]): void;
|
|
16
|
+
logQueryError(error: string | Error, query: string, queryParameters?: unknown[]): void;
|
|
17
|
+
logQuerySlow(time: number, query: string, queryParameters?: unknown[]): void;
|
|
17
18
|
logSchemaBuild(message: string): void;
|
|
18
19
|
logMigration(message: string): void;
|
|
19
20
|
log(level: LogLevel, message: unknown): void;
|
|
@@ -11,6 +11,7 @@ var DbType;
|
|
|
11
11
|
DbType["sqlite"] = "sqlite";
|
|
12
12
|
DbType["mysql"] = "mysql";
|
|
13
13
|
})(DbType || (exports.DbType = DbType = {}));
|
|
14
|
+
const REDACTED_PARAMETER_TABLES = ['plugin_action_execution'];
|
|
14
15
|
class CustomDataSourceLogger {
|
|
15
16
|
logger;
|
|
16
17
|
loggingOptions;
|
|
@@ -31,22 +32,28 @@ class CustomDataSourceLogger {
|
|
|
31
32
|
return true;
|
|
32
33
|
return false;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
loggableParameters(query, parameters) {
|
|
36
|
+
return REDACTED_PARAMETER_TABLES.some(table => query.includes(table)) ? undefined : parameters;
|
|
37
|
+
}
|
|
38
|
+
logQuery(query, queryParameters) {
|
|
35
39
|
if (this.checkLoggingOptions('query')) {
|
|
40
|
+
const parameters = this.loggableParameters(query, queryParameters);
|
|
36
41
|
const message = this.logQueryParameters && parameters?.length
|
|
37
42
|
? `${query} -- Parameters: ${JSON.stringify(parameters)}`
|
|
38
43
|
: query;
|
|
39
44
|
this.logger.log(message);
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
|
-
logQueryError(error, query,
|
|
47
|
+
logQueryError(error, query, queryParameters) {
|
|
43
48
|
if (this.checkLoggingOptions('error')) {
|
|
49
|
+
const parameters = this.loggableParameters(query, queryParameters);
|
|
44
50
|
const errorMessage = `[QUERY ERROR] ${query}${this.logQueryParameters && parameters?.length ? ` -- Parameters: ${JSON.stringify(parameters)}` : ''}`;
|
|
45
51
|
this.logger.error(errorMessage, String(error));
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
|
-
logQuerySlow(time, query,
|
|
54
|
+
logQuerySlow(time, query, queryParameters) {
|
|
49
55
|
if (this.checkLoggingOptions('warn')) {
|
|
56
|
+
const parameters = this.loggableParameters(query, queryParameters);
|
|
50
57
|
const message = `[SLOW QUERY] (${time}ms): ${query}${this.logQueryParameters && parameters?.length ? ` -- Parameters: ${JSON.stringify(parameters)}` : ''}`;
|
|
51
58
|
this.logger.warn(message);
|
|
52
59
|
}
|
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PLUGIN_COLLECTIONS_JSON_BODY_LIMIT = void 0;
|
|
4
4
|
exports.registerPluginCollectionsBodyParser = registerPluginCollectionsBodyParser;
|
|
5
5
|
const express_1 = require("express");
|
|
6
|
+
const plugin_action_limits_1 = require("../plugin-host/constants/plugin-action-limits");
|
|
6
7
|
exports.PLUGIN_COLLECTIONS_JSON_BODY_LIMIT = '2mb';
|
|
7
8
|
const PLUGIN_COLLECTIONS_ROUTE = '/api/plugins/runtime/collections';
|
|
9
|
+
const PLUGIN_ACTIONS_ROUTE = '/api/plugins/runtime/actions';
|
|
8
10
|
const configuredApps = new WeakSet();
|
|
9
11
|
function registerPluginCollectionsBodyParser(app) {
|
|
10
12
|
if (configuredApps.has(app))
|
|
11
13
|
return;
|
|
12
14
|
app.use(PLUGIN_COLLECTIONS_ROUTE, (0, express_1.json)({ limit: exports.PLUGIN_COLLECTIONS_JSON_BODY_LIMIT }));
|
|
15
|
+
app.use(PLUGIN_ACTIONS_ROUTE, (0, express_1.json)({ limit: plugin_action_limits_1.PLUGIN_ACTION_LIMITS.routeBodyLimit }));
|
|
13
16
|
configuredApps.add(app);
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=plugin-collections-body-parser.config.js.map
|
|
@@ -16,7 +16,7 @@ export declare const CredentialDefinitionContractSchema: z.ZodObject<{
|
|
|
16
16
|
displayName: z.ZodString;
|
|
17
17
|
description: z.ZodDefault<z.ZodString>;
|
|
18
18
|
documentationUrl: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
19
|
-
auth: z.ZodObject<{
|
|
19
|
+
auth: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
20
20
|
type: z.ZodLiteral<"header">;
|
|
21
21
|
label: z.ZodString;
|
|
22
22
|
headerName: z.ZodString;
|
|
@@ -31,7 +31,16 @@ export declare const CredentialDefinitionContractSchema: z.ZodObject<{
|
|
|
31
31
|
label: string;
|
|
32
32
|
headerName: string;
|
|
33
33
|
prefix?: string | undefined;
|
|
34
|
-
}
|
|
34
|
+
}>, z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"google-service-account">;
|
|
36
|
+
label: z.ZodString;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
type: "google-service-account";
|
|
39
|
+
label: string;
|
|
40
|
+
}, {
|
|
41
|
+
type: "google-service-account";
|
|
42
|
+
label: string;
|
|
43
|
+
}>]>;
|
|
35
44
|
origins: z.ZodArray<z.ZodString, "many">;
|
|
36
45
|
validation: z.ZodOptional<z.ZodObject<{
|
|
37
46
|
method: z.ZodDefault<z.ZodEnum<["GET", "POST"]>>;
|
|
@@ -153,6 +162,9 @@ export declare const CredentialDefinitionContractSchema: z.ZodObject<{
|
|
|
153
162
|
label: string;
|
|
154
163
|
headerName: string;
|
|
155
164
|
prefix?: string | undefined;
|
|
165
|
+
} | {
|
|
166
|
+
type: "google-service-account";
|
|
167
|
+
label: string;
|
|
156
168
|
};
|
|
157
169
|
displayName: string;
|
|
158
170
|
origins: string[];
|
|
@@ -190,6 +202,9 @@ export declare const CredentialDefinitionContractSchema: z.ZodObject<{
|
|
|
190
202
|
label: string;
|
|
191
203
|
headerName: string;
|
|
192
204
|
prefix?: string | undefined;
|
|
205
|
+
} | {
|
|
206
|
+
type: "google-service-account";
|
|
207
|
+
label: string;
|
|
193
208
|
};
|
|
194
209
|
displayName: string;
|
|
195
210
|
origins: string[];
|
|
@@ -227,12 +242,15 @@ export declare const CredentialRequirementSchema: z.ZodUnion<[z.ZodString, z.Zod
|
|
|
227
242
|
id: z.ZodString;
|
|
228
243
|
optional: z.ZodDefault<z.ZodBoolean>;
|
|
229
244
|
models: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
245
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
230
246
|
}, "strip", z.ZodTypeAny, {
|
|
231
247
|
id: string;
|
|
232
248
|
optional: boolean;
|
|
249
|
+
scopes?: string[] | undefined;
|
|
233
250
|
models?: string[] | undefined;
|
|
234
251
|
}, {
|
|
235
252
|
id: string;
|
|
253
|
+
scopes?: string[] | undefined;
|
|
236
254
|
models?: string[] | undefined;
|
|
237
255
|
optional?: boolean | undefined;
|
|
238
256
|
}>]>;
|
|
@@ -249,11 +267,17 @@ export interface NormalizedCredentialRequirement {
|
|
|
249
267
|
readonly definitionId: string | null;
|
|
250
268
|
readonly optional: boolean;
|
|
251
269
|
readonly models: readonly string[];
|
|
270
|
+
readonly scopes: readonly string[];
|
|
252
271
|
}
|
|
253
272
|
export declare function normalizeCredentialRequirement(requirement: StoredCredentialRequirement): NormalizedCredentialRequirement;
|
|
254
273
|
export interface CredentialSecret {
|
|
255
274
|
readonly value: string;
|
|
256
275
|
}
|
|
276
|
+
export interface CredentialPublicMetadata {
|
|
277
|
+
readonly clientEmail: string;
|
|
278
|
+
readonly projectId: string;
|
|
279
|
+
readonly privateKeyId: string;
|
|
280
|
+
}
|
|
257
281
|
export type CredentialAiModelMappings = Record<string, string>;
|
|
258
282
|
export type CredentialAiModelMappingModes = Record<string, 'recommended' | 'override'>;
|
|
259
283
|
export type CredentialAiModelMappingSources = Record<string, 'catalog' | 'manual'>;
|
|
@@ -29,17 +29,25 @@ exports.CredentialDocumentationUrlSchema = zod_1.z
|
|
|
29
29
|
}
|
|
30
30
|
}, 'documentationUrl must be an absolute HTTPS URL without embedded credentials')
|
|
31
31
|
.transform(value => new URL(value).href);
|
|
32
|
+
const CredentialHeaderAuthSchema = zod_1.z.object({
|
|
33
|
+
type: zod_1.z.literal('header'),
|
|
34
|
+
label: zod_1.z.string().trim().min(1).max(255),
|
|
35
|
+
headerName: zod_1.z.string().trim().min(1).max(255),
|
|
36
|
+
prefix: zod_1.z.string().max(64).optional(),
|
|
37
|
+
});
|
|
38
|
+
const CredentialGoogleServiceAccountAuthSchema = zod_1.z.object({
|
|
39
|
+
type: zod_1.z.literal('google-service-account'),
|
|
40
|
+
label: zod_1.z.string().trim().min(1).max(255),
|
|
41
|
+
});
|
|
32
42
|
exports.CredentialDefinitionContractSchema = zod_1.z.object({
|
|
33
43
|
id: zod_1.z.string().trim().min(1).max(255),
|
|
34
44
|
displayName: zod_1.z.string().trim().min(1).max(255),
|
|
35
45
|
description: zod_1.z.string().trim().max(2000).default(''),
|
|
36
46
|
documentationUrl: exports.CredentialDocumentationUrlSchema.optional(),
|
|
37
|
-
auth: zod_1.z.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
prefix: zod_1.z.string().max(64).optional(),
|
|
42
|
-
}),
|
|
47
|
+
auth: zod_1.z.discriminatedUnion('type', [
|
|
48
|
+
CredentialHeaderAuthSchema,
|
|
49
|
+
CredentialGoogleServiceAccountAuthSchema,
|
|
50
|
+
]),
|
|
43
51
|
origins: zod_1.z.array(zod_1.z.string().url().startsWith('https://')).min(1).max(20),
|
|
44
52
|
validation: zod_1.z
|
|
45
53
|
.object({
|
|
@@ -82,6 +90,7 @@ exports.CredentialRequirementSchema = zod_1.z.union([
|
|
|
82
90
|
id: zod_1.z.string().trim().min(1).max(255),
|
|
83
91
|
optional: zod_1.z.boolean().default(false),
|
|
84
92
|
models: zod_1.z.array(zod_1.z.string().trim().min(1).max(255)).max(20).optional(),
|
|
93
|
+
scopes: zod_1.z.array(zod_1.z.string().min(1).max(200).regex(/^\S+$/)).min(1).max(20).optional(),
|
|
85
94
|
}),
|
|
86
95
|
]);
|
|
87
96
|
function normalizeCredentialRequirement(requirement) {
|
|
@@ -92,6 +101,7 @@ function normalizeCredentialRequirement(requirement) {
|
|
|
92
101
|
definitionId: null,
|
|
93
102
|
optional: false,
|
|
94
103
|
models: ['fast'],
|
|
104
|
+
scopes: [],
|
|
95
105
|
};
|
|
96
106
|
}
|
|
97
107
|
return {
|
|
@@ -99,6 +109,7 @@ function normalizeCredentialRequirement(requirement) {
|
|
|
99
109
|
definitionId: requirement,
|
|
100
110
|
optional: false,
|
|
101
111
|
models: [],
|
|
112
|
+
scopes: [],
|
|
102
113
|
};
|
|
103
114
|
}
|
|
104
115
|
return {
|
|
@@ -112,6 +123,7 @@ function normalizeCredentialRequirement(requirement) {
|
|
|
112
123
|
models: [
|
|
113
124
|
...(requirement.id === 'ai' ? (requirement.models ?? ['fast']) : (requirement.models ?? [])),
|
|
114
125
|
].sort(),
|
|
126
|
+
scopes: 'definitionId' in requirement ? [] : [...new Set(requirement.scopes ?? [])].sort(),
|
|
115
127
|
};
|
|
116
128
|
}
|
|
117
129
|
function isCredentialAiModelInCatalog(ai, capability, modelId) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CredentialAiModelMappings, CredentialAiModelMappingModes, CredentialDefinitionContract, CredentialDefinitionSource, CredentialValidationState } from '../credential.types';
|
|
1
|
+
import type { CredentialAiModelMappings, CredentialAiModelMappingModes, CredentialDefinitionContract, CredentialDefinitionSource, CredentialPublicMetadata, CredentialValidationState } from '../credential.types';
|
|
2
2
|
import type { UserProjectionDto } from '../../../idp/dto/domain/user-projection.dto';
|
|
3
3
|
import type { ContextSummary } from '../../utils/extract-context-summaries';
|
|
4
4
|
export declare class CredentialSecretApiDto {
|
|
@@ -33,6 +33,9 @@ export declare class CredentialDefinitionApiDto {
|
|
|
33
33
|
description: string;
|
|
34
34
|
documentationUrl: string | null;
|
|
35
35
|
secretLabel: string;
|
|
36
|
+
auth: {
|
|
37
|
+
type: CredentialDefinitionContract['auth']['type'];
|
|
38
|
+
};
|
|
36
39
|
origins: string[];
|
|
37
40
|
supportsAi: boolean;
|
|
38
41
|
ai: CredentialDefinitionContract['ai'] | null;
|
|
@@ -60,6 +63,7 @@ export declare class CredentialResponseApiDto {
|
|
|
60
63
|
lastUsedAt: Date | null;
|
|
61
64
|
aiModelMappings: CredentialAiModelMappings | null;
|
|
62
65
|
aiModelMappingModes: CredentialAiModelMappingModes | null;
|
|
66
|
+
publicMetadata: CredentialPublicMetadata | null;
|
|
63
67
|
ownerUsers: UserProjectionDto[];
|
|
64
68
|
contexts: ContextSummary[];
|
|
65
69
|
usedBy: CredentialConsumerReferenceApiDto[];
|
|
@@ -196,6 +196,7 @@ class CredentialDefinitionApiDto {
|
|
|
196
196
|
description;
|
|
197
197
|
documentationUrl;
|
|
198
198
|
secretLabel;
|
|
199
|
+
auth;
|
|
199
200
|
origins;
|
|
200
201
|
supportsAi;
|
|
201
202
|
ai;
|
|
@@ -226,6 +227,13 @@ __decorate([
|
|
|
226
227
|
(0, swagger_1.ApiProperty)(),
|
|
227
228
|
__metadata("design:type", String)
|
|
228
229
|
], CredentialDefinitionApiDto.prototype, "secretLabel", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, swagger_1.ApiProperty)({
|
|
232
|
+
type: 'object',
|
|
233
|
+
properties: { type: { type: 'string', enum: ['header', 'google-service-account'] } },
|
|
234
|
+
}),
|
|
235
|
+
__metadata("design:type", Object)
|
|
236
|
+
], CredentialDefinitionApiDto.prototype, "auth", void 0);
|
|
229
237
|
__decorate([
|
|
230
238
|
(0, swagger_1.ApiProperty)({ type: [String] }),
|
|
231
239
|
__metadata("design:type", Array)
|
|
@@ -258,6 +266,7 @@ class CredentialResponseApiDto {
|
|
|
258
266
|
lastUsedAt;
|
|
259
267
|
aiModelMappings;
|
|
260
268
|
aiModelMappingModes;
|
|
269
|
+
publicMetadata;
|
|
261
270
|
ownerUsers;
|
|
262
271
|
contexts;
|
|
263
272
|
usedBy;
|
|
@@ -333,6 +342,18 @@ __decorate([
|
|
|
333
342
|
}),
|
|
334
343
|
__metadata("design:type", Object)
|
|
335
344
|
], CredentialResponseApiDto.prototype, "aiModelMappingModes", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
347
|
+
type: 'object',
|
|
348
|
+
nullable: true,
|
|
349
|
+
properties: {
|
|
350
|
+
clientEmail: { type: 'string' },
|
|
351
|
+
projectId: { type: 'string' },
|
|
352
|
+
privateKeyId: { type: 'string' },
|
|
353
|
+
},
|
|
354
|
+
}),
|
|
355
|
+
__metadata("design:type", Object)
|
|
356
|
+
], CredentialResponseApiDto.prototype, "publicMetadata", void 0);
|
|
336
357
|
__decorate([
|
|
337
358
|
(0, swagger_1.ApiProperty)({ type: [Object] }),
|
|
338
359
|
__metadata("design:type", Array)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UserProjectionDto } from '../../../idp/dto/domain/user-projection.dto';
|
|
2
2
|
import type { ContextSummary } from '../../utils/extract-context-summaries';
|
|
3
|
-
import type { CredentialAiModelMappingModes, CredentialAiModelMappings, CredentialValidationState } from '../credential.types';
|
|
3
|
+
import type { CredentialAiModelMappingModes, CredentialAiModelMappings, CredentialPublicMetadata, CredentialValidationState } from '../credential.types';
|
|
4
4
|
import type { CredentialConsumerReferenceApiDto, CredentialDefinitionApiDto } from './credential-api.dto';
|
|
5
5
|
export interface CredentialDto {
|
|
6
6
|
readonly id: string;
|
|
@@ -17,6 +17,7 @@ export interface CredentialDto {
|
|
|
17
17
|
readonly lastUsedAt: Date | null;
|
|
18
18
|
readonly aiModelMappings: CredentialAiModelMappings | null;
|
|
19
19
|
readonly aiModelMappingModes: CredentialAiModelMappingModes | null;
|
|
20
|
+
readonly publicMetadata: CredentialPublicMetadata | null;
|
|
20
21
|
readonly ownerUsers: UserProjectionDto[];
|
|
21
22
|
readonly contexts: ContextSummary[];
|
|
22
23
|
readonly usedBy: CredentialConsumerReferenceApiDto[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CredentialAiModelMappings, CredentialAiModelMappingModes, CredentialAiModelMappingSources, CredentialDefinitionSource, CredentialSecret, CredentialValidationState } from '../credential.types';
|
|
1
|
+
import type { CredentialAiModelMappings, CredentialAiModelMappingModes, CredentialAiModelMappingSources, CredentialDefinitionSource, CredentialPublicMetadata, CredentialSecret, CredentialValidationState } from '../credential.types';
|
|
2
2
|
import { CredentialContext } from './credential-context.entity';
|
|
3
3
|
import { CredentialOwner } from './credential-owner.entity';
|
|
4
4
|
export declare class Credential {
|
|
@@ -9,6 +9,7 @@ export declare class Credential {
|
|
|
9
9
|
definitionId: string;
|
|
10
10
|
acceptedCompatibilityLine: string | null;
|
|
11
11
|
secret: CredentialSecret;
|
|
12
|
+
publicMetadata: CredentialPublicMetadata | null;
|
|
12
13
|
aiModelMappings: CredentialAiModelMappings | null;
|
|
13
14
|
aiModelMappingModes: CredentialAiModelMappingModes | null;
|
|
14
15
|
aiModelMappingSources: CredentialAiModelMappingSources | null;
|
|
@@ -21,6 +21,7 @@ let Credential = class Credential {
|
|
|
21
21
|
definitionId;
|
|
22
22
|
acceptedCompatibilityLine;
|
|
23
23
|
secret;
|
|
24
|
+
publicMetadata;
|
|
24
25
|
aiModelMappings;
|
|
25
26
|
aiModelMappingModes;
|
|
26
27
|
aiModelMappingSources;
|
|
@@ -72,6 +73,10 @@ __decorate([
|
|
|
72
73
|
(0, typeorm_1.Column)({ type: 'json' }),
|
|
73
74
|
__metadata("design:type", Object)
|
|
74
75
|
], Credential.prototype, "secret", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
78
|
+
__metadata("design:type", Object)
|
|
79
|
+
], Credential.prototype, "publicMetadata", void 0);
|
|
75
80
|
__decorate([
|
|
76
81
|
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
77
82
|
__metadata("design:type", Object)
|
|
@@ -258,11 +258,15 @@ function assertUniqueRequirementKeys(requirements) {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
function sameRequirement(left, right) {
|
|
261
|
+
const leftScopes = left.scopes ?? [];
|
|
262
|
+
const rightScopes = right.scopes ?? [];
|
|
261
263
|
return (left.key === right.key &&
|
|
262
264
|
left.definitionId === right.definitionId &&
|
|
263
265
|
left.optional === right.optional &&
|
|
264
266
|
left.models.length === right.models.length &&
|
|
265
|
-
left.models.every((model, index) => model === right.models[index])
|
|
267
|
+
left.models.every((model, index) => model === right.models[index]) &&
|
|
268
|
+
leftScopes.length === rightScopes.length &&
|
|
269
|
+
leftScopes.every((scope, index) => scope === rightScopes[index]));
|
|
266
270
|
}
|
|
267
271
|
function requirementRevision(requirement) {
|
|
268
272
|
return (0, node_crypto_1.createHash)('sha256')
|
|
@@ -271,6 +275,7 @@ function requirementRevision(requirement) {
|
|
|
271
275
|
definitionId: requirement.definitionId,
|
|
272
276
|
optional: requirement.optional,
|
|
273
277
|
models: requirement.models,
|
|
278
|
+
...(requirement.scopes?.length ? { scopes: requirement.scopes } : {}),
|
|
274
279
|
}))
|
|
275
280
|
.digest('hex');
|
|
276
281
|
}
|
|
@@ -24,6 +24,7 @@ function mapCredentialDefinitionToApiDto(definition) {
|
|
|
24
24
|
description: definition.contract.description,
|
|
25
25
|
documentationUrl: definition.contract.documentationUrl ?? null,
|
|
26
26
|
secretLabel: definition.contract.auth.label,
|
|
27
|
+
auth: { type: definition.contract.auth.type },
|
|
27
28
|
origins: [...definition.contract.origins],
|
|
28
29
|
supportsAi: definition.contract.ai !== undefined,
|
|
29
30
|
ai: definition.contract.ai ?? null,
|
|
@@ -53,6 +54,7 @@ let CredentialMapper = class CredentialMapper {
|
|
|
53
54
|
lastUsedAt,
|
|
54
55
|
aiModelMappings: (0, credential_types_1.resolveCredentialAiModelMappings)(credential.aiModelMappings, credential.aiModelMappingModes, definition.contract.ai?.recommended),
|
|
55
56
|
aiModelMappingModes: credential.aiModelMappingModes,
|
|
57
|
+
publicMetadata: credential.publicMetadata ?? null,
|
|
56
58
|
ownerUsers: (0, resolve_owner_users_1.resolveOwnerUsers)(credential.ownerIds, users),
|
|
57
59
|
contexts: (0, extract_context_summaries_1.extractContextSummaries)(credential.contexts),
|
|
58
60
|
usedBy: bindings.map(binding => ({
|
|
@@ -128,6 +128,14 @@ exports.BUILTIN_CREDENTIAL_DEFINITIONS = [
|
|
|
128
128
|
},
|
|
129
129
|
},
|
|
130
130
|
},
|
|
131
|
+
{
|
|
132
|
+
id: 'google-service-account',
|
|
133
|
+
displayName: 'Google Service Account',
|
|
134
|
+
description: 'Google Cloud service account JSON key',
|
|
135
|
+
documentationUrl: 'https://docs.cloud.google.com/iam/docs/keys-create-delete',
|
|
136
|
+
auth: { type: 'google-service-account', label: 'Service account key (JSON)' },
|
|
137
|
+
origins: ['https://*.googleapis.com'],
|
|
138
|
+
},
|
|
131
139
|
];
|
|
132
140
|
exports.BUILTIN_CREDENTIAL_DEFINITION_IDS = new Set(exports.BUILTIN_CREDENTIAL_DEFINITIONS.map(definition => definition.id));
|
|
133
141
|
//# sourceMappingURL=builtin-credential-definitions.js.map
|
|
@@ -19,7 +19,11 @@ export declare class CredentialExternalDefinitionRegistryService {
|
|
|
19
19
|
private readonly dataSource;
|
|
20
20
|
constructor(definitions: Repository<CredentialExternalDefinition>, versions: Repository<CredentialDefinitionVersion>, dataSource: DataSource);
|
|
21
21
|
register(input: RegisterExternalCredentialDefinitionInput): Promise<ResolvedCredentialDefinition>;
|
|
22
|
+
preview(input: RegisterExternalCredentialDefinitionInput): Promise<{
|
|
23
|
+
readonly contract: CredentialDefinitionContract;
|
|
24
|
+
}>;
|
|
22
25
|
private persist;
|
|
26
|
+
private validateAgainstRecorded;
|
|
23
27
|
private createOrFindDefinition;
|
|
24
28
|
getCurrentByGithubRepoId(githubRepoId: string): Promise<ResolvedCredentialDefinition | null>;
|
|
25
29
|
listDue(now: Date, limit: number): Promise<CredentialExternalDefinition[]>;
|
package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.js
CHANGED
|
@@ -39,6 +39,12 @@ let CredentialExternalDefinitionRegistryService = class CredentialExternalDefini
|
|
|
39
39
|
const definition = await this.createOrFindDefinition(input);
|
|
40
40
|
return this.persist(definition.id, input);
|
|
41
41
|
}
|
|
42
|
+
async preview(input) {
|
|
43
|
+
await this.validateNetworkBoundary(input.contract);
|
|
44
|
+
const definition = await this.definitions.findOneBy({ githubRepoId: input.githubRepoId });
|
|
45
|
+
const { recorded } = await this.validateAgainstRecorded(definition, input);
|
|
46
|
+
return { contract: (recorded ?? input).contract };
|
|
47
|
+
}
|
|
42
48
|
async persist(definitionId, input) {
|
|
43
49
|
const query = this.definitions
|
|
44
50
|
.createQueryBuilder('definition')
|
|
@@ -51,27 +57,12 @@ let CredentialExternalDefinitionRegistryService = class CredentialExternalDefini
|
|
|
51
57
|
throw new common_1.BadRequestException('Credential definition sync state was lost');
|
|
52
58
|
definition.repoOwner = input.repoOwner;
|
|
53
59
|
definition.repoName = input.repoName;
|
|
54
|
-
const compatibilityLine =
|
|
55
|
-
const recorded = await this.versions.findOneBy({
|
|
56
|
-
externalDefinitionId: definition.id,
|
|
57
|
-
semver: input.semver,
|
|
58
|
-
});
|
|
60
|
+
const { compatibilityLine, recorded, current } = await this.validateAgainstRecorded(definition, input);
|
|
59
61
|
if (recorded) {
|
|
60
|
-
if (recorded.commitSha !== input.commitSha ||
|
|
61
|
-
recorded.githubReleaseId !== input.githubReleaseId) {
|
|
62
|
-
throw new common_1.BadRequestException(`Credential definition version ${input.semver} was already recorded from another release`);
|
|
63
|
-
}
|
|
64
62
|
this.markSynced(definition, input.semver, new Date());
|
|
65
63
|
await this.definitions.save(definition);
|
|
66
64
|
return this.resolved(definition.id, recorded);
|
|
67
65
|
}
|
|
68
|
-
const current = definition.currentVersionId
|
|
69
|
-
? await this.versions.findOneBy({ id: definition.currentVersionId })
|
|
70
|
-
: null;
|
|
71
|
-
if (current?.compatibilityLine === compatibilityLine &&
|
|
72
|
-
!isCompatibleWithinLine(current.contract, input.contract)) {
|
|
73
|
-
throw new common_1.BadRequestException(`Credential definition ${input.semver} changes an incompatible contract within compatibility line ${compatibilityLine}; publish a new compatibility line for this change`);
|
|
74
|
-
}
|
|
75
66
|
const version = await this.versions.save(this.versions.create({
|
|
76
67
|
externalDefinitionId: definition.id,
|
|
77
68
|
semver: input.semver,
|
|
@@ -89,6 +80,30 @@ let CredentialExternalDefinitionRegistryService = class CredentialExternalDefini
|
|
|
89
80
|
await this.definitions.save(definition);
|
|
90
81
|
return this.resolved(definition.id, version);
|
|
91
82
|
}
|
|
83
|
+
async validateAgainstRecorded(definition, input) {
|
|
84
|
+
const compatibilityLine = compatibilityLineForSemver(input.semver);
|
|
85
|
+
const recorded = definition
|
|
86
|
+
? await this.versions.findOneBy({
|
|
87
|
+
externalDefinitionId: definition.id,
|
|
88
|
+
semver: input.semver,
|
|
89
|
+
})
|
|
90
|
+
: null;
|
|
91
|
+
if (recorded) {
|
|
92
|
+
if (recorded.commitSha !== input.commitSha ||
|
|
93
|
+
recorded.githubReleaseId !== input.githubReleaseId) {
|
|
94
|
+
throw new common_1.BadRequestException(`Credential definition version ${input.semver} was already recorded from another release`);
|
|
95
|
+
}
|
|
96
|
+
return { compatibilityLine, recorded, current: null };
|
|
97
|
+
}
|
|
98
|
+
const current = definition?.currentVersionId
|
|
99
|
+
? await this.versions.findOneBy({ id: definition.currentVersionId })
|
|
100
|
+
: null;
|
|
101
|
+
if (current?.compatibilityLine === compatibilityLine &&
|
|
102
|
+
!isCompatibleWithinLine(current.contract, input.contract)) {
|
|
103
|
+
throw new common_1.BadRequestException(`Credential definition ${input.semver} changes an incompatible contract within compatibility line ${compatibilityLine}; publish a new compatibility line for this change`);
|
|
104
|
+
}
|
|
105
|
+
return { compatibilityLine, recorded: null, current };
|
|
106
|
+
}
|
|
92
107
|
async createOrFindDefinition(input) {
|
|
93
108
|
const existing = await this.definitions.findOneBy({ githubRepoId: input.githubRepoId });
|
|
94
109
|
if (existing)
|
|
@@ -149,6 +164,9 @@ let CredentialExternalDefinitionRegistryService = class CredentialExternalDefini
|
|
|
149
164
|
return hash % SLOTS_PER_DAY;
|
|
150
165
|
}
|
|
151
166
|
async validateNetworkBoundary(contract) {
|
|
167
|
+
if (contract.auth.type !== 'header') {
|
|
168
|
+
throw new common_1.BadRequestException('An external Credential definition must use header auth');
|
|
169
|
+
}
|
|
152
170
|
try {
|
|
153
171
|
for (const origin of contract.origins) {
|
|
154
172
|
const url = await (0, safe_url_helper_1.assertPublicHttpUrl)(origin, { allowedProtocols: ['https:'] });
|
|
@@ -203,7 +221,8 @@ function compatibilityLineForSemver(semver) {
|
|
|
203
221
|
function isCompatibleWithinLine(previous, next) {
|
|
204
222
|
return (previous.id === next.id &&
|
|
205
223
|
sameSet(previous.origins, next.origins) &&
|
|
206
|
-
previous.auth.type ===
|
|
224
|
+
previous.auth.type === 'header' &&
|
|
225
|
+
next.auth.type === 'header' &&
|
|
207
226
|
previous.auth.headerName.toLowerCase() === next.auth.headerName.toLowerCase() &&
|
|
208
227
|
(previous.auth.prefix ?? '') === (next.auth.prefix ?? '') &&
|
|
209
228
|
(!previous.ai || Boolean(next.ai)) &&
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { CredentialFetchRequestApiDto, CredentialFetchResponseApiDto } from '../dto/credential-fetch-api.dto';
|
|
2
2
|
import type { ResolvedCredentialBinding } from '../facades/credential-consumer-binding.facade';
|
|
3
|
+
import { CredentialService } from './credential.service';
|
|
4
|
+
import { GoogleServiceAccountTokenService } from './google-service-account-token.service';
|
|
3
5
|
export interface CredentialFetchLimits {
|
|
4
6
|
readonly timeoutMs?: number;
|
|
5
7
|
readonly maxResponseBodyBytes?: number;
|
|
6
8
|
readonly signal?: AbortSignal;
|
|
7
9
|
}
|
|
8
10
|
export declare class CredentialFetchService {
|
|
11
|
+
private readonly googleTokens;
|
|
12
|
+
private readonly credentials;
|
|
13
|
+
private readonly logger;
|
|
14
|
+
constructor(googleTokens: GoogleServiceAccountTokenService, credentials: CredentialService);
|
|
9
15
|
run(binding: ResolvedCredentialBinding, input: CredentialFetchRequestApiDto, limits?: CredentialFetchLimits): Promise<CredentialFetchResponseApiDto>;
|
|
10
16
|
runRaw(binding: ResolvedCredentialBinding, input: CredentialFetchRequestApiDto, limits?: CredentialFetchLimits): Promise<Response>;
|
|
17
|
+
private send;
|
|
18
|
+
private authorization;
|
|
11
19
|
private assertAllowedUrl;
|
|
12
20
|
private buildRequestHeaders;
|
|
13
21
|
}
|