@dcupl/cli 1.4.0-beta.1 → 1.4.0-beta.10
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 +34 -0
- package/dist/cli.js +724 -168
- package/dist/cli.js.map +1 -1
- package/dist/functions/app/app-id.js +34 -2
- package/dist/functions/app/app-id.js.map +1 -1
- package/dist/functions/app/client/daemon-client.js.map +1 -1
- package/dist/functions/app/commands/cdn-host.d.ts +16 -0
- package/dist/functions/app/commands/cdn-host.js +47 -0
- package/dist/functions/app/commands/cdn-host.js.map +1 -0
- package/dist/functions/app/commands/create.js +50 -34
- package/dist/functions/app/commands/create.js.map +1 -1
- package/dist/functions/app/commands/destroy.js +10 -4
- package/dist/functions/app/commands/destroy.js.map +1 -1
- package/dist/functions/app/commands/detect-serve.js +17 -6
- package/dist/functions/app/commands/detect-serve.js.map +1 -1
- package/dist/functions/app/commands/fn/_fn-helpers.js +11 -3
- package/dist/functions/app/commands/fn/_fn-helpers.js.map +1 -1
- package/dist/functions/app/commands/fn/aggregate.js +4 -1
- package/dist/functions/app/commands/fn/aggregate.js.map +1 -1
- package/dist/functions/app/commands/fn/pivot.js.map +1 -1
- package/dist/functions/app/commands/list.js +6 -2
- package/dist/functions/app/commands/list.js.map +1 -1
- package/dist/functions/app/commands/loader-hash.js.map +1 -1
- package/dist/functions/app/commands/loaders/add.js +6 -0
- package/dist/functions/app/commands/loaders/add.js.map +1 -1
- package/dist/functions/app/commands/loaders/process-flags.js +4 -1
- package/dist/functions/app/commands/loaders/process-flags.js.map +1 -1
- package/dist/functions/app/commands/loaders/process.js +3 -1
- package/dist/functions/app/commands/loaders/process.js.map +1 -1
- package/dist/functions/app/commands/models/get.js.map +1 -1
- package/dist/functions/app/commands/models/keys.js.map +1 -1
- package/dist/functions/app/commands/models/remove.js.map +1 -1
- package/dist/functions/app/commands/models/set.js +3 -1
- package/dist/functions/app/commands/models/set.js.map +1 -1
- package/dist/functions/app/commands/query/execute.js +5 -2
- package/dist/functions/app/commands/query/execute.js.map +1 -1
- package/dist/functions/app/commands/query/one.js +3 -1
- package/dist/functions/app/commands/query/one.js.map +1 -1
- package/dist/functions/app/commands/render.js +10 -4
- package/dist/functions/app/commands/render.js.map +1 -1
- package/dist/functions/app/commands/resolve-app.js.map +1 -1
- package/dist/functions/app/commands/resolve-source.d.ts +1 -0
- package/dist/functions/app/commands/resolve-source.js +20 -5
- package/dist/functions/app/commands/resolve-source.js.map +1 -1
- package/dist/functions/app/commands/validate-report.d.ts +31 -0
- package/dist/functions/app/commands/validate-report.js +20 -1
- package/dist/functions/app/commands/validate-report.js.map +1 -1
- package/dist/functions/app/commands/validate.d.ts +1 -0
- package/dist/functions/app/commands/validate.js +31 -10
- package/dist/functions/app/commands/validate.js.map +1 -1
- package/dist/functions/app/daemon/app-server.module.js +6 -1
- package/dist/functions/app/daemon/app-server.module.js.map +1 -1
- package/dist/functions/app/daemon/controllers/data.controller.js +17 -6
- package/dist/functions/app/daemon/controllers/data.controller.js.map +1 -1
- package/dist/functions/app/daemon/controllers/lifecycle.controller.js.map +1 -1
- package/dist/functions/app/daemon/controllers/query.controller.js +4 -1
- package/dist/functions/app/daemon/controllers/query.controller.js.map +1 -1
- package/dist/functions/app/daemon/daemon-args.js +2 -2
- package/dist/functions/app/daemon/daemon-args.js.map +1 -1
- package/dist/functions/app/daemon/filters/envelope-exception.filter.js +6 -1
- package/dist/functions/app/daemon/filters/envelope-exception.filter.js.map +1 -1
- package/dist/functions/app/daemon/main.js +14 -7
- package/dist/functions/app/daemon/main.js.map +1 -1
- package/dist/functions/app/daemon/services/attribute-validation.d.ts +21 -0
- package/dist/functions/app/daemon/services/attribute-validation.js +164 -0
- package/dist/functions/app/daemon/services/attribute-validation.js.map +1 -0
- package/dist/functions/app/daemon/services/dcupl-host.service.d.ts +5 -0
- package/dist/functions/app/daemon/services/dcupl-host.service.js +83 -16
- package/dist/functions/app/daemon/services/dcupl-host.service.js.map +1 -1
- package/dist/functions/app/daemon/services/idle-watchdog.service.js.map +1 -1
- package/dist/functions/app/daemon/services/ingest.service.js +8 -4
- package/dist/functions/app/daemon/services/ingest.service.js.map +1 -1
- package/dist/functions/app/daemon/services/init-options.js.map +1 -1
- package/dist/functions/app/daemon/services/loaders.service.d.ts +3 -1
- package/dist/functions/app/daemon/services/loaders.service.js +22 -6
- package/dist/functions/app/daemon/services/loaders.service.js.map +1 -1
- package/dist/functions/app/e2e/port-lock.d.ts +8 -0
- package/dist/functions/app/e2e/port-lock.js +66 -2
- package/dist/functions/app/e2e/port-lock.js.map +1 -1
- package/dist/functions/app/registry/registry.js +11 -10
- package/dist/functions/app/registry/registry.js.map +1 -1
- package/dist/functions/app/registry/serve-registry.js +13 -9
- package/dist/functions/app/registry/serve-registry.js.map +1 -1
- package/dist/functions/app/types.d.ts +2 -0
- package/dist/functions/config/commands/set.js +2 -2
- package/dist/functions/config/commands/set.js.map +1 -1
- package/dist/functions/config/io.js +1 -3
- package/dist/functions/config/io.js.map +1 -1
- package/dist/functions/config/prompts.js +1 -3
- package/dist/functions/config/prompts.js.map +1 -1
- package/dist/functions/files/commands/copy.js +1 -1
- package/dist/functions/files/commands/copy.js.map +1 -1
- package/dist/functions/files/commands/delete.js +1 -1
- package/dist/functions/files/commands/delete.js.map +1 -1
- package/dist/functions/files/commands/list.js +6 -3
- package/dist/functions/files/commands/list.js.map +1 -1
- package/dist/functions/files/commands/move.js +1 -1
- package/dist/functions/files/commands/move.js.map +1 -1
- package/dist/functions/files/commands/pull.d.ts +16 -1
- package/dist/functions/files/commands/pull.js +135 -1
- package/dist/functions/files/commands/pull.js.map +1 -1
- package/dist/functions/files/commands/push.d.ts +1 -0
- package/dist/functions/files/commands/push.js +25 -3
- package/dist/functions/files/commands/push.js.map +1 -1
- package/dist/functions/files/commands/read.js +3 -2
- package/dist/functions/files/commands/read.js.map +1 -1
- package/dist/functions/files/commands/render.d.ts +29 -0
- package/dist/functions/files/commands/render.js +8 -4
- package/dist/functions/files/commands/render.js.map +1 -1
- package/dist/functions/files/commands/status.js +1 -0
- package/dist/functions/files/commands/status.js.map +1 -1
- package/dist/functions/files/commands/versions/copy.js +1 -1
- package/dist/functions/files/commands/versions/copy.js.map +1 -1
- package/dist/functions/files/commands/versions/delete.js +1 -1
- package/dist/functions/files/commands/versions/delete.js.map +1 -1
- package/dist/functions/files/commands/versions/list.js +4 -0
- package/dist/functions/files/commands/versions/list.js.map +1 -1
- package/dist/functions/files/commands/write.js +13 -3
- package/dist/functions/files/commands/write.js.map +1 -1
- package/dist/functions/files/files-push.js +1 -1
- package/dist/functions/files/files-push.js.map +1 -1
- package/dist/functions/files/helper/text-policy.d.ts +5 -0
- package/dist/functions/files/helper/text-policy.js +31 -0
- package/dist/functions/files/helper/text-policy.js.map +1 -0
- package/dist/functions/files/sync/large-upload.d.ts +20 -0
- package/dist/functions/files/sync/large-upload.js +140 -0
- package/dist/functions/files/sync/large-upload.js.map +1 -0
- package/dist/functions/files/sync/manifest.js +2 -1
- package/dist/functions/files/sync/manifest.js.map +1 -1
- package/dist/functions/files/sync/transfer.d.ts +5 -0
- package/dist/functions/files/sync/transfer.js +47 -10
- package/dist/functions/files/sync/transfer.js.map +1 -1
- package/dist/functions/files/test-helpers.d.ts +11 -0
- package/dist/functions/files/test-helpers.js +28 -0
- package/dist/functions/files/test-helpers.js.map +1 -1
- package/dist/functions/generate/files/generate-code.d.ts +1 -1
- package/dist/functions/generate/files/generate-files.d.ts +7 -1
- package/dist/functions/generate/files/generate-files.js +63 -15
- package/dist/functions/generate/files/generate-files.js.map +1 -1
- package/dist/functions/generate/files/workflow-presets.d.ts +6 -0
- package/dist/functions/generate/files/workflow-presets.js +158 -0
- package/dist/functions/generate/files/workflow-presets.js.map +1 -0
- package/dist/functions/generate/model-from-data/generate-model-from-data.js +8 -3
- package/dist/functions/generate/model-from-data/generate-model-from-data.js.map +1 -1
- package/dist/functions/generate/model-from-data/infer-key.js +1 -4
- package/dist/functions/generate/model-from-data/infer-key.js.map +1 -1
- package/dist/functions/generate/model-from-data/infer-to-model.js +1 -2
- package/dist/functions/generate/model-from-data/infer-to-model.js.map +1 -1
- package/dist/functions/generate/projects/generate-project.d.ts +5 -0
- package/dist/functions/generate/projects/generate-project.js +29 -8
- package/dist/functions/generate/projects/generate-project.js.map +1 -1
- package/dist/functions/helper/api-client.d.ts +3 -0
- package/dist/functions/helper/api-client.js +10 -3
- package/dist/functions/helper/api-client.js.map +1 -1
- package/dist/functions/helper/config.helper.d.ts +1 -0
- package/dist/functions/helper/config.helper.js.map +1 -1
- package/dist/functions/helper/output.d.ts +1 -1
- package/dist/functions/helper/output.js +10 -12
- package/dist/functions/helper/output.js.map +1 -1
- package/dist/functions/helper/parse-fail.js +4 -1
- package/dist/functions/helper/parse-fail.js.map +1 -1
- package/dist/functions/schemas/command.js.map +1 -1
- package/dist/functions/schemas/examples/AppLoaderConfiguration.example.json +1 -3
- package/dist/functions/schemas/examples/DataMapperStepConfig.example.json +6 -1
- package/dist/functions/schemas/examples/ModelDefinition.example.json +8 -1
- package/dist/functions/schemas/examples/ScriptStepConfig.example.json +3 -1
- package/dist/functions/schemas/examples/TemplateV3.example.json +5 -1
- package/dist/functions/schemas/extract.js +1 -1
- package/dist/functions/schemas/extract.js.map +1 -1
- package/dist/functions/schemas/format.js +4 -4
- package/dist/functions/schemas/format.js.map +1 -1
- package/dist/functions/schemas/registry.d.ts +14 -0
- package/dist/functions/schemas/registry.js +103 -30
- package/dist/functions/schemas/registry.js.map +1 -1
- package/dist/functions/schemas/resolve.js +1 -2
- package/dist/functions/schemas/resolve.js.map +1 -1
- package/dist/functions/schemas/validate.d.ts +22 -0
- package/dist/functions/schemas/validate.js +67 -0
- package/dist/functions/schemas/validate.js.map +1 -0
- package/dist/functions/serve/commands/list.js +2 -1
- package/dist/functions/serve/commands/list.js.map +1 -1
- package/dist/functions/serve/commands/stop.js +10 -5
- package/dist/functions/serve/commands/stop.js.map +1 -1
- package/dist/functions/serve/dev-server/dev-server-access.guard.d.ts +11 -0
- package/dist/functions/serve/dev-server/dev-server-access.guard.js +41 -0
- package/dist/functions/serve/dev-server/dev-server-access.guard.js.map +1 -0
- package/dist/functions/serve/dev-server/dev-server.controller.d.ts +3 -0
- package/dist/functions/serve/dev-server/dev-server.controller.js +20 -0
- package/dist/functions/serve/dev-server/dev-server.controller.js.map +1 -1
- package/dist/functions/serve/dev-server/dev-server.module.d.ts +3 -0
- package/dist/functions/serve/dev-server/dev-server.module.js +34 -23
- package/dist/functions/serve/dev-server/dev-server.module.js.map +1 -1
- package/dist/functions/serve/dev-server/dev-server.options.d.ts +8 -0
- package/dist/functions/serve/dev-server/dev-server.options.js +5 -0
- package/dist/functions/serve/dev-server/dev-server.options.js.map +1 -0
- package/dist/functions/serve/dev-server/dev-server.service.d.ts +11 -3
- package/dist/functions/serve/dev-server/dev-server.service.js +72 -65
- package/dist/functions/serve/dev-server/dev-server.service.js.map +1 -1
- package/dist/functions/serve/dev-server/path-scope.d.ts +5 -0
- package/dist/functions/serve/dev-server/path-scope.js +88 -0
- package/dist/functions/serve/dev-server/path-scope.js.map +1 -0
- package/dist/functions/serve/dev-server/request-security.d.ts +34 -0
- package/dist/functions/serve/dev-server/request-security.js +145 -0
- package/dist/functions/serve/dev-server/request-security.js.map +1 -0
- package/dist/functions/serve/main.d.ts +13 -0
- package/dist/functions/serve/main.js +85 -13
- package/dist/functions/serve/main.js.map +1 -1
- package/dist/functions/serve/serve-self-register.js +2 -1
- package/dist/functions/serve/serve-self-register.js.map +1 -1
- package/dist/functions/version/command.js +1 -6
- package/dist/functions/version/command.js.map +1 -1
- package/dist/functions/workflow/commands/deploy.d.ts +9 -1
- package/dist/functions/workflow/commands/deploy.js +39 -10
- package/dist/functions/workflow/commands/deploy.js.map +1 -1
- package/dist/functions/workflow/commands/get.js.map +1 -1
- package/dist/functions/workflow/commands/history.js.map +1 -1
- package/dist/functions/workflow/commands/run.d.ts +26 -0
- package/dist/functions/workflow/commands/run.js +101 -0
- package/dist/functions/workflow/commands/run.js.map +1 -0
- package/dist/functions/workflow/commands/runners-get.js.map +1 -1
- package/dist/functions/workflow/commands/runners.d.ts +2 -0
- package/dist/functions/workflow/commands/runners.js +10 -1
- package/dist/functions/workflow/commands/runners.js.map +1 -1
- package/dist/functions/workflow/commands/status.d.ts +1 -1
- package/dist/functions/workflow/commands/status.js +7 -1
- package/dist/functions/workflow/commands/status.js.map +1 -1
- package/dist/functions/workflow/commands/template.js.map +1 -1
- package/dist/functions/workflow/commands/test.d.ts +3 -0
- package/dist/functions/workflow/commands/test.js +22 -73
- package/dist/functions/workflow/commands/test.js.map +1 -1
- package/dist/functions/workflow/commands/trace.d.ts +4 -2
- package/dist/functions/workflow/commands/trace.js +22 -1
- package/dist/functions/workflow/commands/trace.js.map +1 -1
- package/dist/functions/workflow/commands/undeploy.js +3 -1
- package/dist/functions/workflow/commands/undeploy.js.map +1 -1
- package/dist/functions/workflow/commands/validate.d.ts +2 -0
- package/dist/functions/workflow/commands/validate.js +16 -2
- package/dist/functions/workflow/commands/validate.js.map +1 -1
- package/dist/functions/workflow/resolve-runner.d.ts +17 -0
- package/dist/functions/workflow/resolve-runner.js +41 -0
- package/dist/functions/workflow/resolve-runner.js.map +1 -0
- package/dist/functions/workflow/run-failure.d.ts +11 -0
- package/dist/functions/workflow/run-failure.js +74 -0
- package/dist/functions/workflow/run-failure.js.map +1 -0
- package/dist/functions/workflow/runner-health.d.ts +16 -0
- package/dist/functions/workflow/runner-health.js +36 -0
- package/dist/functions/workflow/runner-health.js.map +1 -0
- package/dist/functions/workflow/script-lint.d.ts +10 -0
- package/dist/functions/workflow/script-lint.js +513 -0
- package/dist/functions/workflow/script-lint.js.map +1 -0
- package/dist/functions/workflow/trace.js.map +1 -1
- package/dist/functions/workflow/types.d.ts +11 -2
- package/dist/functions/workflow/types.js +4 -0
- package/dist/functions/workflow/types.js.map +1 -1
- package/dist/functions/workflow/validate.js +4 -1
- package/dist/functions/workflow/validate.js.map +1 -1
- package/dist/functions/workflow/wait-for-swap.d.ts +24 -1
- package/dist/functions/workflow/wait-for-swap.js +58 -0
- package/dist/functions/workflow/wait-for-swap.js.map +1 -1
- package/dist/functions/workflow/workflow-api.js +3 -1
- package/dist/functions/workflow/workflow-api.js.map +1 -1
- package/files/dev-server/index.html +2 -1
- package/package.json +24 -18
- package/dist/functions/serve/guards/apiKey.guard.d.ts +0 -4
- package/dist/functions/serve/guards/apiKey.guard.js +0 -23
- package/dist/functions/serve/guards/apiKey.guard.js.map +0 -1
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var DevServerModule_1;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.DevServerModule = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const common_1 = require("@nestjs/common");
|
|
7
|
+
const core_1 = require("@nestjs/core");
|
|
6
8
|
const serve_static_1 = require("@nestjs/serve-static");
|
|
7
9
|
const dev_server_service_1 = require("./dev-server.service");
|
|
8
10
|
const path_1 = require("path");
|
|
9
11
|
const dev_server_controller_1 = require("./dev-server.controller");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
const dev_server_options_1 = require("./dev-server.options");
|
|
13
|
+
const dev_server_access_guard_1 = require("./dev-server-access.guard");
|
|
14
|
+
let DevServerModule = DevServerModule_1 = class DevServerModule {
|
|
15
|
+
static register(options) {
|
|
16
|
+
return {
|
|
17
|
+
module: DevServerModule_1,
|
|
18
|
+
imports: [
|
|
19
|
+
serve_static_1.ServeStaticModule.forRootAsync({
|
|
20
|
+
useFactory: () => [
|
|
21
|
+
{
|
|
22
|
+
rootPath: (0, path_1.join)(options.workspaceRoot, options.servePath),
|
|
23
|
+
exclude: ['/api{/*splat}'],
|
|
24
|
+
serveStaticOptions: {
|
|
25
|
+
fallthrough: false,
|
|
26
|
+
setHeaders: (res, _path, _stat) => {
|
|
27
|
+
res.set('Timing-Allow-Origin', '*');
|
|
28
|
+
},
|
|
26
29
|
},
|
|
27
30
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
],
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
providers: [
|
|
35
|
+
{ provide: dev_server_options_1.DEV_SERVER_OPTIONS, useValue: options },
|
|
36
|
+
dev_server_service_1.DevServerService,
|
|
37
|
+
{ provide: core_1.APP_GUARD, useClass: dev_server_access_guard_1.DevServerAccessGuard },
|
|
38
|
+
],
|
|
39
|
+
controllers: [dev_server_controller_1.DevServerController],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.DevServerModule = DevServerModule;
|
|
44
|
+
exports.DevServerModule = DevServerModule = DevServerModule_1 = tslib_1.__decorate([
|
|
45
|
+
(0, common_1.Module)({})
|
|
35
46
|
], DevServerModule);
|
|
36
47
|
//# sourceMappingURL=dev-server.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.module.js","sourceRoot":"","sources":["../../../../src/functions/serve/dev-server/dev-server.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev-server.module.js","sourceRoot":"","sources":["../../../../src/functions/serve/dev-server/dev-server.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,uCAAyC;AACzC,uDAAyD;AACzD,6DAAwD;AACxD,+BAA4B;AAC5B,mEAA8D;AAC9D,6DAA4E;AAC5E,uEAAiE;AAG1D,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,MAAM,CAAC,QAAQ,CAAC,OAAyB;QACvC,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,OAAO,EAAE;gBACP,gCAAiB,CAAC,YAAY,CAAC;oBAC7B,UAAU,EAAE,GAAG,EAAE,CAAC;wBAChB;4BACE,QAAQ,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC;4BAGxD,OAAO,EAAE,CAAC,eAAe,CAAC;4BAC1B,kBAAkB,EAAE;gCAClB,WAAW,EAAE,KAAK;gCAClB,UAAU,EAAE,CAAC,GAAQ,EAAE,KAAa,EAAE,KAAU,EAAQ,EAAE;oCACxD,GAAG,CAAC,GAAG,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;gCACtC,CAAC;6BACF;yBACF;qBACF;iBACF,CAAC;aACH;YAED,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,uCAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAClD,qCAAgB;gBAChB,EAAE,OAAO,EAAE,gBAAS,EAAE,QAAQ,EAAE,8CAAoB,EAAE;aACvD;YACD,WAAW,EAAE,CAAC,2CAAmB,CAAC;SACnC,CAAC;IACJ,CAAC;CACF,CAAA;AA/BY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CA+B3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server.options.js","sourceRoot":"","sources":["../../../../src/functions/serve/dev-server/dev-server.options.ts"],"names":[],"mappings":";;;AAEa,QAAA,kBAAkB,GAAG,oBAAoB,CAAC"}
|
|
@@ -4,8 +4,14 @@ import { DcuplApplicationTestingConfig, DcuplTestScenario, TestRunnerOptions } f
|
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import { ApiFiles } from '@dcupl/common-internal';
|
|
6
6
|
import { CreateFolderBody, DeleteFileBody, MoveFileBody, ReadFileBody, WriteFileBody } from './types/file.types';
|
|
7
|
+
import { DevServerOptions } from './dev-server.options';
|
|
7
8
|
export declare class DevServerService {
|
|
9
|
+
private readonly options;
|
|
8
10
|
runner: TestRunner;
|
|
11
|
+
private readonly fileApiBlocked;
|
|
12
|
+
constructor(options: DevServerOptions);
|
|
13
|
+
private get workspaceRoot();
|
|
14
|
+
private get baseFolder();
|
|
9
15
|
get config(): DcuplCliConfig;
|
|
10
16
|
watchFiles(): Observable<ApiFiles.InternalEvent> | undefined;
|
|
11
17
|
writeFile(data: WriteFileBody): string;
|
|
@@ -20,10 +26,12 @@ export declare class DevServerService {
|
|
|
20
26
|
runTests(data: TestRunnerOptions): Promise<unknown>;
|
|
21
27
|
getTestConfigs(): Promise<DcuplApplicationTestingConfig[] | undefined>;
|
|
22
28
|
getTestLoader(): Promise<DcuplTestScenario[] | undefined>;
|
|
23
|
-
getFile(data:
|
|
24
|
-
deleteFile(data:
|
|
29
|
+
getFile(data: ReadFileBody): string | null;
|
|
30
|
+
deleteFile(data: DeleteFileBody): boolean | null;
|
|
25
31
|
moveFile(data: MoveFileBody): boolean | null;
|
|
26
32
|
private getFiles;
|
|
27
|
-
private
|
|
33
|
+
private assertFileApiEnabled;
|
|
34
|
+
private resolveInBaseFolder;
|
|
28
35
|
updateConfig(config: Partial<DcuplCliConfig>): void;
|
|
36
|
+
setOpenBrowser(openBrowser: unknown): void;
|
|
29
37
|
}
|
|
@@ -7,30 +7,37 @@ const fs_1 = require("fs");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
9
|
const config_helper_1 = require("../../helper/config.helper");
|
|
10
|
-
const generate_helper_1 = require("../../generate/files/generate.helper");
|
|
11
10
|
const glob_1 = require("glob");
|
|
12
11
|
const testing_1 = require("../../testing/testing");
|
|
13
12
|
const kleur_1 = require("kleur");
|
|
14
13
|
const lodash_1 = require("lodash");
|
|
15
14
|
const fs_extra_1 = require("fs-extra");
|
|
16
|
-
const
|
|
15
|
+
const dev_server_options_1 = require("./dev-server.options");
|
|
16
|
+
const path_scope_1 = require("./path-scope");
|
|
17
17
|
let DevServerService = class DevServerService {
|
|
18
|
-
constructor() {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.options = options;
|
|
19
20
|
this.runner = new testing_1.TestRunner();
|
|
21
|
+
this.fileApiBlocked = (0, path_scope_1.fileApiBlockReason)(options.workspaceRoot, options.baseFolder);
|
|
22
|
+
}
|
|
23
|
+
get workspaceRoot() {
|
|
24
|
+
return this.options.workspaceRoot;
|
|
25
|
+
}
|
|
26
|
+
get baseFolder() {
|
|
27
|
+
return this.options.baseFolder;
|
|
20
28
|
}
|
|
21
29
|
get config() {
|
|
22
|
-
const configFile = (0, config_helper_1.getConfigFileValue)(
|
|
30
|
+
const configFile = (0, config_helper_1.getConfigFileValue)(this.workspaceRoot);
|
|
23
31
|
if (configFile) {
|
|
24
32
|
return configFile;
|
|
25
33
|
}
|
|
26
34
|
else {
|
|
27
|
-
throw new Error(`Please make sure you have a valid config file with an existing projectId at ${
|
|
35
|
+
throw new Error(`Please make sure you have a valid config file with an existing projectId at ${this.workspaceRoot}/dcupl.config.json`);
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
watchFiles() {
|
|
31
39
|
const subject = new rxjs_1.Subject();
|
|
32
|
-
const
|
|
33
|
-
const baseFolderPath = (0, path_1.join)(currentBasePath, baseFolderName);
|
|
40
|
+
const baseFolderPath = this.baseFolder;
|
|
34
41
|
if (!(0, fs_extra_1.existsSync)(baseFolderPath)) {
|
|
35
42
|
console.log(`${(0, kleur_1.blue)((0, kleur_1.bold)('INFO'))} ${(0, kleur_1.underline)('dcupl')} folder not found at ${baseFolderPath}`);
|
|
36
43
|
return;
|
|
@@ -46,14 +53,19 @@ let DevServerService = class DevServerService {
|
|
|
46
53
|
return subject.asObservable().pipe((0, rxjs_1.debounceTime)(300));
|
|
47
54
|
}
|
|
48
55
|
writeFile(data) {
|
|
49
|
-
const
|
|
50
|
-
|
|
56
|
+
const pathToFile = this.resolveInBaseFolder(data?.path);
|
|
57
|
+
if (typeof data.content !== 'string') {
|
|
58
|
+
throw new common_1.BadRequestException('content must be a string');
|
|
59
|
+
}
|
|
60
|
+
(0, fs_extra_1.outputFileSync)(pathToFile, data.content, { encoding: 'utf-8' });
|
|
61
|
+
return data.content;
|
|
51
62
|
}
|
|
52
63
|
createFolder(data) {
|
|
53
|
-
|
|
54
|
-
return
|
|
64
|
+
(0, fs_extra_1.ensureDirSync)(this.resolveInBaseFolder(data?.path));
|
|
65
|
+
return true;
|
|
55
66
|
}
|
|
56
67
|
async listFiles(search) {
|
|
68
|
+
this.assertFileApiEnabled();
|
|
57
69
|
let list = await this.getFilesAsFlatList();
|
|
58
70
|
if (search) {
|
|
59
71
|
list = list.filter((item) => item.includes(`${search}`));
|
|
@@ -62,29 +74,13 @@ let DevServerService = class DevServerService {
|
|
|
62
74
|
return { list, nested: nested };
|
|
63
75
|
}
|
|
64
76
|
async getFilesAsFlatList() {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const includedFiles = await Promise.all(includes.map((pattern) => this.getFiles(pattern, config.baseFolder)));
|
|
68
|
-
const list = includedFiles
|
|
69
|
-
.flat()
|
|
70
|
-
.filter((item) => (0, fs_1.statSync)(item).isFile())
|
|
71
|
-
.map((filePath) => {
|
|
72
|
-
return filePath.slice(config.baseFolder.length + 1);
|
|
73
|
-
});
|
|
74
|
-
return list;
|
|
77
|
+
const files = await this.getFiles();
|
|
78
|
+
return files.filter((item) => (0, fs_1.statSync)((0, path_1.join)(this.baseFolder, item)).isFile());
|
|
75
79
|
}
|
|
76
80
|
async getFilesAndFoldersAsNested() {
|
|
77
|
-
|
|
78
|
-
const config = this.config;
|
|
79
|
-
const includedFiles = await Promise.all(includes.map((pattern) => this.getFiles(pattern, config.baseFolder)));
|
|
80
|
-
const cleanFiles = includedFiles.flat().map((filePath) => {
|
|
81
|
-
return filePath.slice(config.baseFolder.length + 1);
|
|
82
|
-
});
|
|
83
|
-
const fileTree = this.createFileTree(cleanFiles);
|
|
84
|
-
return fileTree;
|
|
81
|
+
return this.createFileTree(await this.getFiles());
|
|
85
82
|
}
|
|
86
83
|
createFileTree(paths) {
|
|
87
|
-
const config = this.config;
|
|
88
84
|
const emptyMetadata = {
|
|
89
85
|
size: '0',
|
|
90
86
|
timeCreated: '',
|
|
@@ -107,7 +103,7 @@ let DevServerService = class DevServerService {
|
|
|
107
103
|
parts.forEach((part) => {
|
|
108
104
|
let child = current.children.find((child) => child.path === part);
|
|
109
105
|
const fullPath = current.fullPath ? `${current.fullPath}/${part}` : part;
|
|
110
|
-
const fullPathIncludingBaseFolder = (0, path_1.join)(
|
|
106
|
+
const fullPathIncludingBaseFolder = (0, path_1.join)(this.baseFolder, path);
|
|
111
107
|
const stat = (0, fs_1.statSync)(fullPathIncludingBaseFolder);
|
|
112
108
|
const type = stat.isDirectory() ? 'dir' : 'file';
|
|
113
109
|
if (!child) {
|
|
@@ -148,56 +144,67 @@ let DevServerService = class DevServerService {
|
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
146
|
getFile(data) {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
throw new Error('File not in scope');
|
|
147
|
+
const pathToFile = this.resolveInBaseFolder(data?.path);
|
|
148
|
+
if (!(0, fs_extra_1.pathExistsSync)(pathToFile)) {
|
|
149
|
+
return null;
|
|
155
150
|
}
|
|
156
|
-
return (0,
|
|
151
|
+
return (0, fs_extra_1.readFileSync)(pathToFile, { encoding: 'utf-8' });
|
|
157
152
|
}
|
|
158
153
|
deleteFile(data) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
throw new Error('File not in scope');
|
|
154
|
+
const pathToFile = this.resolveInBaseFolder(data?.path);
|
|
155
|
+
if (!(0, fs_extra_1.pathExistsSync)(pathToFile)) {
|
|
156
|
+
return null;
|
|
163
157
|
}
|
|
164
|
-
|
|
158
|
+
(0, fs_extra_1.removeSync)(pathToFile);
|
|
159
|
+
return true;
|
|
165
160
|
}
|
|
166
161
|
moveFile(data) {
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
throw new Error('File not in scope');
|
|
172
|
-
}
|
|
173
|
-
if (!this.isInScope(pathToToFile)) {
|
|
174
|
-
throw new Error('File not in scope');
|
|
162
|
+
const pathToFromFile = this.resolveInBaseFolder(data?.from);
|
|
163
|
+
const pathToToFile = this.resolveInBaseFolder(data?.to);
|
|
164
|
+
if (!(0, fs_extra_1.pathExistsSync)(pathToFromFile)) {
|
|
165
|
+
return null;
|
|
175
166
|
}
|
|
176
|
-
|
|
167
|
+
(0, fs_extra_1.moveSync)(pathToFromFile, pathToToFile);
|
|
168
|
+
return true;
|
|
177
169
|
}
|
|
178
|
-
getFiles(
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
async getFiles() {
|
|
171
|
+
const name = (0, path_1.basename)(this.baseFolder);
|
|
172
|
+
const matches = await (0, glob_1.glob)(`${(0, glob_1.escape)(name)}/**/*`, { cwd: (0, path_1.dirname)(this.baseFolder) });
|
|
173
|
+
return matches.map((match) => match.slice(name.length + 1));
|
|
174
|
+
}
|
|
175
|
+
assertFileApiEnabled() {
|
|
176
|
+
if (this.fileApiBlocked) {
|
|
177
|
+
throw new common_1.ForbiddenException(this.fileApiBlocked);
|
|
181
178
|
}
|
|
182
|
-
return (0, glob_1.glob)(pattern);
|
|
183
179
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
resolveInBaseFolder(requested) {
|
|
181
|
+
this.assertFileApiEnabled();
|
|
182
|
+
try {
|
|
183
|
+
return (0, path_scope_1.resolveInScope)(this.baseFolder, requested);
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
if (err instanceof path_scope_1.PathScopeError) {
|
|
187
|
+
throw new common_1.ForbiddenException(err.message);
|
|
188
|
+
}
|
|
189
|
+
throw err;
|
|
190
|
+
}
|
|
187
191
|
}
|
|
188
192
|
updateConfig(config) {
|
|
189
|
-
|
|
190
|
-
const currentConfig = (0, config_helper_1.getConfigFileValue)(currentBasePath);
|
|
191
|
-
console.log('currentConfig', currentConfig);
|
|
193
|
+
const currentConfig = (0, config_helper_1.getConfigFileValue)(this.workspaceRoot);
|
|
192
194
|
const newConfig = { ...currentConfig, ...config };
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
(
|
|
195
|
+
(0, config_helper_1.setConfigFileValue)(this.workspaceRoot, newConfig);
|
|
196
|
+
}
|
|
197
|
+
setOpenBrowser(openBrowser) {
|
|
198
|
+
if (typeof openBrowser !== 'boolean') {
|
|
199
|
+
throw new common_1.BadRequestException('openBrowser must be a boolean');
|
|
200
|
+
}
|
|
201
|
+
this.updateConfig({ openBrowser });
|
|
197
202
|
}
|
|
198
203
|
};
|
|
199
204
|
exports.DevServerService = DevServerService;
|
|
200
205
|
exports.DevServerService = DevServerService = tslib_1.__decorate([
|
|
201
|
-
(0, common_1.Injectable)()
|
|
206
|
+
(0, common_1.Injectable)(),
|
|
207
|
+
tslib_1.__param(0, (0, common_1.Inject)(dev_server_options_1.DEV_SERVER_OPTIONS)),
|
|
208
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
202
209
|
], DevServerService);
|
|
203
210
|
//# sourceMappingURL=dev-server.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.service.js","sourceRoot":"","sources":["../../../../src/functions/serve/dev-server/dev-server.service.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"dev-server.service.js","sourceRoot":"","sources":["../../../../src/functions/serve/dev-server/dev-server.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA6F;AAC7F,2BAAqC;AACrC,+BAA+C;AAC/C,+BAA6C;AAC7C,8DAAoG;AAEpG,+BAAoC;AACpC,mDAAmD;AAInD,iCAA8C;AAC9C,mCAAiC;AAEjC,uCAQkB;AAClB,6DAA4E;AAC5E,6CAAkF;AAG3E,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAK3B,YAAwC,OAA0C;QAAzB,YAAO,GAAP,OA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AAG,IAAA,kCAAkB,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7D,MAAM,SAAS,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAoB,CAAC;QACpE,IAAA,kCAAkB,EAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAGM,cAAc,CAAC,WAAoB;QACxC,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,4BAAmB,CAAC,+BAA+B,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AA5OY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAME,mBAAA,IAAA,eAAM,EAAC,uCAAkB,CAAC,CAAA;;GAL5B,gBAAgB,CA4O5B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare class PathScopeError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare function resolveInScope(baseDir: string, requested: unknown): string;
|
|
5
|
+
export declare function fileApiBlockReason(workspaceRoot: string, baseFolder: string): string | null;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PathScopeError = void 0;
|
|
4
|
+
exports.resolveInScope = resolveInScope;
|
|
5
|
+
exports.fileApiBlockReason = fileApiBlockReason;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
class PathScopeError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'PathScopeError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.PathScopeError = PathScopeError;
|
|
15
|
+
function resolveInScope(baseDir, requested) {
|
|
16
|
+
if (typeof requested !== 'string') {
|
|
17
|
+
throw new PathScopeError('path must be a string');
|
|
18
|
+
}
|
|
19
|
+
if (requested.includes('\0')) {
|
|
20
|
+
throw new PathScopeError('path must not contain NUL bytes');
|
|
21
|
+
}
|
|
22
|
+
if ((0, path_1.isAbsolute)(requested) || path_1.win32.isAbsolute(requested) || /^[a-zA-Z]:/.test(requested)) {
|
|
23
|
+
throw new PathScopeError(`absolute paths are not allowed: ${requested}`);
|
|
24
|
+
}
|
|
25
|
+
if (requested.split(/[\\/]/).includes('..')) {
|
|
26
|
+
throw new PathScopeError(`".." segments are not allowed: ${requested}`);
|
|
27
|
+
}
|
|
28
|
+
const base = (0, path_1.resolve)(baseDir);
|
|
29
|
+
const target = (0, path_1.resolve)(base, requested);
|
|
30
|
+
if (!isStrictlyInside(base, target)) {
|
|
31
|
+
throw new PathScopeError(`path must point inside the served folder: ${requested}`);
|
|
32
|
+
}
|
|
33
|
+
if (!isStrictlyInside(realpathOfNearestExisting(base), realpathOfNearestExisting(target))) {
|
|
34
|
+
throw new PathScopeError(`path leads outside the served folder through a symlink: ${requested}`);
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
}
|
|
38
|
+
function fileApiBlockReason(workspaceRoot, baseFolder) {
|
|
39
|
+
const root = realpathOrSelf((0, path_1.resolve)(workspaceRoot));
|
|
40
|
+
const base = realpathOrSelf((0, path_1.resolve)(baseFolder));
|
|
41
|
+
if (root !== base && !isStrictlyInside(base, root)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return (`The file API is disabled: baseFolder "${(0, path_1.relative)(workspaceRoot, baseFolder) || '.'}" contains the workspace ` +
|
|
45
|
+
'root with dcupl.config.json and dcupl.secrets.json. Point baseFolder in dcupl.config.json at a subfolder ' +
|
|
46
|
+
'such as "dcupl" and restart dcupl serve.');
|
|
47
|
+
}
|
|
48
|
+
function realpathOrSelf(path) {
|
|
49
|
+
try {
|
|
50
|
+
return fs_1.realpathSync.native(path);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return path;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function isStrictlyInside(parent, child) {
|
|
57
|
+
const rel = (0, path_1.relative)(parent, child);
|
|
58
|
+
return rel !== '' && rel !== '..' && !rel.startsWith(`..${path_1.sep}`) && !(0, path_1.isAbsolute)(rel);
|
|
59
|
+
}
|
|
60
|
+
function realpathOfNearestExisting(path) {
|
|
61
|
+
const missing = [];
|
|
62
|
+
let current = path;
|
|
63
|
+
while (!entryExists(current)) {
|
|
64
|
+
const parent = (0, path_1.dirname)(current);
|
|
65
|
+
if (parent === current)
|
|
66
|
+
break;
|
|
67
|
+
missing.unshift((0, path_1.basename)(current));
|
|
68
|
+
current = parent;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
return (0, path_1.join)(fs_1.realpathSync.native(current), ...missing);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
throw new PathScopeError(`path leads through a broken symlink: ${path}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function entryExists(path) {
|
|
78
|
+
try {
|
|
79
|
+
(0, fs_1.lstatSync)(path);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (err?.code === 'ENOENT' || err?.code === 'ENOTDIR')
|
|
84
|
+
return false;
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=path-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-scope.js","sourceRoot":"","sources":["../../../../src/functions/serve/dev-server/path-scope.ts"],"names":[],"mappings":";;;AAiBA,wCAuBC;AAMD,gDAWC;AAzDD,2BAA6C;AAC7C,+BAA0F;AAG1F,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAA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nC,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAA,WAAI,EAAC,iBAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QAEP,MAAM,IAAI,cAAc,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,CAAC;QACH,IAAA,cAAS,EAAC,IAAI,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,IAAI,GAAG,EAAE,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACpE,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const DEFAULT_SERVE_HOST = "127.0.0.1";
|
|
2
|
+
export declare const SERVE_TOKEN_HEADER = "x-dcupl-serve-token";
|
|
3
|
+
export declare const DCUPL_CONSOLE_ORIGINS: readonly string[];
|
|
4
|
+
export type DevServerSecurity = {
|
|
5
|
+
token: string;
|
|
6
|
+
allowedHosts: string[];
|
|
7
|
+
trustedOrigins: string[];
|
|
8
|
+
};
|
|
9
|
+
export type DevServerAccessLevel = 'read' | 'edit' | 'admin';
|
|
10
|
+
export type AccessRequest = {
|
|
11
|
+
origin?: string;
|
|
12
|
+
token?: unknown;
|
|
13
|
+
remoteAddress?: string;
|
|
14
|
+
proxied?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type AccessDecision = {
|
|
17
|
+
allowed: true;
|
|
18
|
+
} | {
|
|
19
|
+
allowed: false;
|
|
20
|
+
reason: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function resolveServeHost(flag: string | string[] | undefined): string;
|
|
23
|
+
export declare function parseAllowedOrigins(values: unknown): string[];
|
|
24
|
+
export declare function isLoopbackAddress(address: string): boolean;
|
|
25
|
+
export declare function isAllowedHost(hostHeader: string | undefined, allowedHosts: readonly string[]): boolean;
|
|
26
|
+
export declare function isTrustedOrigin(origin: string, trustedOrigins: readonly string[]): boolean;
|
|
27
|
+
export declare function isProxiedRequest(headers: Record<string, unknown>): boolean;
|
|
28
|
+
export declare function createServeToken(): string;
|
|
29
|
+
export declare function tokenMatches(expected: string, provided: unknown): boolean;
|
|
30
|
+
export declare function admitRequest(request: {
|
|
31
|
+
host?: string;
|
|
32
|
+
origin?: string;
|
|
33
|
+
}, security: DevServerSecurity): string | null;
|
|
34
|
+
export declare function authorizeRequest(level: DevServerAccessLevel, request: AccessRequest, security: DevServerSecurity): AccessDecision;
|