1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
19 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
20 | return new (P || (P = Promise))(function (resolve, reject) {
|
21 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
22 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
23 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
24 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
25 | });
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 |
|
29 | const appRoot = require("app-root-path");
|
30 | const cluster = require("cluster");
|
31 | const fg = require("fast-glob");
|
32 | const fs = require("fs-extra");
|
33 | const stringify = require("json-stringify-safe");
|
34 | const _ = require("lodash");
|
35 | const os = require("os");
|
36 | const p = require("path");
|
37 | const semver = require("semver");
|
38 | const globals_1 = require("./globals");
|
39 | const WebSocketLifecycle_1 = require("./internal/transport/websocket/WebSocketLifecycle");
|
40 | const config_1 = require("./internal/util/config");
|
41 | const shutdown_1 = require("./internal/util/shutdown");
|
42 | const string_1 = require("./internal/util/string");
|
43 | const GraphClientFactory_1 = require("./spi/graph/GraphClientFactory");
|
44 | const httpClient_1 = require("./spi/http/httpClient");
|
45 | const wsClient_1 = require("./spi/http/wsClient");
|
46 | const statsdClient_1 = require("./spi/statsd/statsdClient");
|
47 | const logger_1 = require("./util/logger");
|
48 | const packageJson_1 = require("./util/packageJson");
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | function defaultConfiguration() {
|
57 | const pj = packageJson_1.loadHostPackageJson() || {};
|
58 | pj.name = pj.name || "atm-client-" + string_1.guid();
|
59 | pj.version = pj.version || "0.0.0";
|
60 | pj.keywords = pj.keywords || [];
|
61 | const cfg = loadDefaultConfiguration();
|
62 | cfg.name = pj.name;
|
63 | cfg.version = pj.version;
|
64 | cfg.keywords = pj.keywords;
|
65 | cfg.application = pj.name.replace(/^@.*?\//, "");
|
66 | return cfg;
|
67 | }
|
68 | exports.defaultConfiguration = defaultConfiguration;
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | function configurationValue(path = "", defaultValue) {
|
77 | if (globals_1.automationClientInstance()) {
|
78 | const conf = globals_1.automationClientInstance().configuration;
|
79 | let value;
|
80 | if (!path || path.length === 0) {
|
81 | value = conf;
|
82 | }
|
83 | else {
|
84 | value = _.get(conf, path);
|
85 | }
|
86 |
|
87 | if (value !== null && value !== undefined) {
|
88 | return value;
|
89 | }
|
90 | }
|
91 | if (defaultValue !== undefined) {
|
92 | return defaultValue;
|
93 | }
|
94 | throw new Error(`Required @Value '${path}' not available`);
|
95 | }
|
96 | exports.configurationValue = configurationValue;
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | function loadDefaultConfiguration() {
|
102 | const cfg = exports.LocalDefaultConfiguration;
|
103 |
|
104 | _.set(cfg, "http.client.factory", httpClient_1.defaultHttpClientFactory());
|
105 | _.set(cfg, "ws.client.factory", wsClient_1.defaultWebSocketFactory());
|
106 | _.set(cfg, "graphql.client.factory", GraphClientFactory_1.defaultGraphClientFactory());
|
107 | _.set(cfg, "statsd.client.factory", statsdClient_1.defaultStatsDClientFactory());
|
108 | let envSpecificCfg = {};
|
109 | const nodeEnv = process.env.ATOMIST_ENV || process.env.NODE_ENV;
|
110 | if (nodeEnv === "production") {
|
111 | envSpecificCfg = exports.ProductionDefaultConfiguration;
|
112 | cfgLog("production default");
|
113 | }
|
114 | else if (nodeEnv === "staging" || nodeEnv === "testing") {
|
115 | envSpecificCfg = exports.TestingDefaultConfiguration;
|
116 | cfgLog("testing default");
|
117 | }
|
118 | else if (nodeEnv) {
|
119 | cfg.environment = nodeEnv;
|
120 | }
|
121 |
|
122 | if (process.env.ATOMIST_ENDPOINTS === "staging") {
|
123 | cfg.endpoints = {
|
124 | graphql: "https://automation-staging.atomist.services/graphql/team",
|
125 | api: "https://automation-staging.atomist.services/registration",
|
126 | auth: "https://api-staging.atomist.services/v2/auth",
|
127 | };
|
128 | }
|
129 | return mergeConfigs(cfg, envSpecificCfg);
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 | function userConfigDir() {
|
135 | return p.join(os.homedir(), ".atomist");
|
136 | }
|
137 |
|
138 |
|
139 |
|
140 | function userConfigPath() {
|
141 | const clientConfigFile = "client.config.json";
|
142 | return p.join(userConfigDir(), clientConfigFile);
|
143 | }
|
144 | exports.userConfigPath = userConfigPath;
|
145 |
|
146 |
|
147 |
|
148 |
|
149 | function userConfigPaths() {
|
150 | const configPaths = [userConfigPath()];
|
151 | const profiles = process.env.ATOMIST_CONFIG_PROFILE || process.env.ATOMIST_CONFIG_PROFILES;
|
152 | if (!!profiles) {
|
153 | for (const profile of profiles.split(",")) {
|
154 | configPaths.push(p.join(userConfigDir(), `client.config-${profile}.json`));
|
155 | }
|
156 | }
|
157 | return configPaths;
|
158 | }
|
159 | exports.userConfigPaths = userConfigPaths;
|
160 |
|
161 |
|
162 |
|
163 | function writeUserConfig(cfg) {
|
164 | const cfgDir = userConfigDir();
|
165 | return fs.ensureDir(cfgDir)
|
166 | .then(() => fs.chmod(cfgDir, 0o700))
|
167 | .then(() => fs.writeJson(userConfigPath(), cfg, {
|
168 | spaces: 2,
|
169 | encoding: "utf8",
|
170 | mode: 0o600,
|
171 | }));
|
172 | }
|
173 | exports.writeUserConfig = writeUserConfig;
|
174 |
|
175 |
|
176 |
|
177 | function getUserConfig() {
|
178 | const configPaths = userConfigPaths();
|
179 | const userConfigs = [];
|
180 | for (const configPath of configPaths) {
|
181 | if (fs.existsSync(configPath)) {
|
182 | try {
|
183 | const cfg = fs.readJsonSync(configPath);
|
184 |
|
185 | if (cfg.name) {
|
186 | delete cfg.name;
|
187 | }
|
188 | if (cfg.version) {
|
189 | delete cfg.version;
|
190 | }
|
191 | userConfigs.push(cfg);
|
192 | }
|
193 | catch (e) {
|
194 | e.message = `Failed to read user config: ${e.message}`;
|
195 | throw e;
|
196 | }
|
197 | }
|
198 | }
|
199 | if (userConfigs.length > 0) {
|
200 | return mergeConfigs({}, ...userConfigs);
|
201 | }
|
202 | else {
|
203 | return undefined;
|
204 | }
|
205 | }
|
206 | exports.getUserConfig = getUserConfig;
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | function cfgLog(source) {
|
213 | if (cluster.isMaster) {
|
214 | logger_1.logger.debug(`Loading configuration '${source}'`);
|
215 | }
|
216 | }
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 | function mergeConfigs(obj, ...sources) {
|
226 | return _.mergeWith(obj, ...sources, (objValue, srcValue) => {
|
227 | if (_.isArray(srcValue)) {
|
228 | return srcValue;
|
229 | }
|
230 | });
|
231 | }
|
232 | exports.mergeConfigs = mergeConfigs;
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | function deepMergeConfigs(obj, ...sources) {
|
242 | return _.mergeWith(obj, ...sources, (objValue, srcValue) => {
|
243 | if (_.isArray(objValue) && srcValue) {
|
244 | return objValue.concat(srcValue);
|
245 | }
|
246 | });
|
247 | }
|
248 | exports.deepMergeConfigs = deepMergeConfigs;
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 | function resolveModuleConfig(userConfig, name, version) {
|
273 | const cfg = {};
|
274 | if (userConfig) {
|
275 | cfgLog(userConfigPath());
|
276 | const uc = _.cloneDeep(userConfig);
|
277 | let mc = {};
|
278 | if (userConfig.modules) {
|
279 | delete uc.modules;
|
280 | if (name) {
|
281 | let modCfg;
|
282 | const moduleConfigs = userConfig.modules.filter(m => m.name === name);
|
283 | if (version) {
|
284 | modCfg = moduleConfigs.find(m => !m.version || semver.satisfies(version, m.version));
|
285 | }
|
286 | else if (moduleConfigs.length > 0) {
|
287 | modCfg = moduleConfigs[0];
|
288 | }
|
289 | if (modCfg) {
|
290 | cfgLog("module");
|
291 | if (modCfg.name) {
|
292 | delete modCfg.name;
|
293 | }
|
294 | if (modCfg.version) {
|
295 | delete modCfg.version;
|
296 | }
|
297 | mc = modCfg;
|
298 | }
|
299 | }
|
300 | }
|
301 | mergeConfigs(cfg, uc, mc);
|
302 | }
|
303 | return cfg;
|
304 | }
|
305 | exports.resolveModuleConfig = resolveModuleConfig;
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 | function loadUserConfiguration(name, version) {
|
316 | const userConfig = getUserConfig();
|
317 | return resolveModuleConfig(userConfig, name, version);
|
318 | }
|
319 | exports.loadUserConfiguration = loadUserConfiguration;
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 | function loadAutomationConfig(configPath) {
|
332 | return __awaiter(this, void 0, void 0, function* () {
|
333 | let cfgPath = configPath;
|
334 | if (!cfgPath) {
|
335 | const cfgFile = "atomist.config.js";
|
336 | const files = yield fg(`${appRoot.path}/**/${cfgFile}`, { ignore: [`${appRoot.path}/**/{.git,node_modules}/**`] });
|
337 | if (files.length === 1) {
|
338 | cfgPath = files[0];
|
339 | }
|
340 | else if (files.length > 1) {
|
341 | throw new Error(`More than one automation configuration found in package: ${files.join(", ")}`);
|
342 | }
|
343 | }
|
344 | if (cfgPath) {
|
345 | try {
|
346 | let cfg = require(cfgPath).configuration;
|
347 | if (cfg instanceof Promise) {
|
348 | cfg = yield cfg;
|
349 | }
|
350 | cfgLog(cfgPath);
|
351 | return cfg;
|
352 | }
|
353 | catch (e) {
|
354 | e.message = `Failed to load ${cfgPath}.configuration: ${e.message}`;
|
355 | throw e;
|
356 | }
|
357 | }
|
358 | return undefined;
|
359 | });
|
360 | }
|
361 | exports.loadAutomationConfig = loadAutomationConfig;
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 | function loadIndexConfig() {
|
369 | return __awaiter(this, void 0, void 0, function* () {
|
370 | const cfgFile = "index.js";
|
371 | const files = yield fg(`${appRoot.path}/**/${cfgFile}`, { ignore: [`${appRoot.path}/**/{.git,node_modules}/**`] });
|
372 | if (files.length > 0) {
|
373 | const cfgs = [];
|
374 | for (const f of files) {
|
375 | try {
|
376 | let cfg = require(f).configuration || {};
|
377 | if (cfg instanceof Promise) {
|
378 | cfg = yield cfg;
|
379 | }
|
380 | cfgLog(f);
|
381 | cfgs.push(cfg);
|
382 | }
|
383 | catch (e) {
|
384 | e.message = `Failed to load ${f}.configuration: ${e.message}`;
|
385 | throw e;
|
386 | }
|
387 | }
|
388 | return deepMergeConfigs({}, ...cfgs);
|
389 | }
|
390 | return {};
|
391 | });
|
392 | }
|
393 | exports.loadIndexConfig = loadIndexConfig;
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 | function loadAtomistConfigPath() {
|
405 | let cfg = {};
|
406 | if (process.env.ATOMIST_CONFIG_PATH) {
|
407 | try {
|
408 | cfg = fs.readJsonSync(process.env.ATOMIST_CONFIG_PATH);
|
409 | cfgLog("ATOMIST_CONFIG_PATH");
|
410 | }
|
411 | catch (e) {
|
412 | e.message = `Failed to read ATOMIST_CONFIG_PATH: ${e.message}`;
|
413 | throw e;
|
414 | }
|
415 | }
|
416 | return cfg;
|
417 | }
|
418 | exports.loadAtomistConfigPath = loadAtomistConfigPath;
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 | function loadAtomistConfig() {
|
431 | let cfg = {};
|
432 | if (process.env.ATOMIST_CONFIG) {
|
433 | try {
|
434 | cfg = JSON.parse(process.env.ATOMIST_CONFIG);
|
435 | cfgLog("ATOMIST_CONFIG");
|
436 | }
|
437 | catch (e) {
|
438 | e.message = `Failed to parse contents of ATOMIST_CONFIG environment variable: ${e.message}`;
|
439 | throw e;
|
440 | }
|
441 | }
|
442 | return cfg;
|
443 | }
|
444 | exports.loadAtomistConfig = loadAtomistConfig;
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | function resolveWorkspaceIds(cfg) {
|
456 | if (process.env.ATOMIST_WORKSPACES) {
|
457 | cfg.workspaceIds = process.env.ATOMIST_WORKSPACES.split(",");
|
458 | }
|
459 | else if (config_1.config("workspaceIds")) {
|
460 | cfg.workspaceIds = config_1.config("workspaceIds");
|
461 | }
|
462 | return cfg.workspaceIds;
|
463 | }
|
464 | exports.resolveWorkspaceIds = resolveWorkspaceIds;
|
465 |
|
466 |
|
467 |
|
468 |
|
469 | function resolvePort(cfg) {
|
470 | if (process.env.PORT) {
|
471 | cfg.http.port = parseInt(process.env.PORT, 10);
|
472 | }
|
473 | return cfg.http.port;
|
474 | }
|
475 | exports.resolvePort = resolvePort;
|
476 | const EnvironmentVariablePrefix = "ATOMIST_";
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 | function resolveEnvironmentVariables(cfg) {
|
484 | for (const key in process.env) {
|
485 | if (key.startsWith(EnvironmentVariablePrefix) && process.env.hasOwnProperty(key)) {
|
486 | const cleanKey = key.slice(EnvironmentVariablePrefix.length).split("_").join(".");
|
487 | if (cleanKey[0] !== cleanKey[0].toUpperCase()) {
|
488 | _.update(cfg, cleanKey, () => process.env[key]);
|
489 | }
|
490 | }
|
491 | }
|
492 | }
|
493 | exports.resolveEnvironmentVariables = resolveEnvironmentVariables;
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 | function resolvePlaceholders(cfg, replacer = resolvePlaceholder, visited = [cfg.sdm, cfg.local, cfg.events, cfg.commands, cfg.listeners]) {
|
500 | return __awaiter(this, void 0, void 0, function* () {
|
501 | yield resolvePlaceholdersRecursively(cfg, visited, replacer);
|
502 | });
|
503 | }
|
504 | exports.resolvePlaceholders = resolvePlaceholders;
|
505 | function resolvePlaceholdersRecursively(obj, visited, replacer) {
|
506 | return __awaiter(this, void 0, void 0, function* () {
|
507 | if (!visited.includes(obj)) {
|
508 | visited.push(obj);
|
509 | for (const property in obj) {
|
510 | if (_.has(obj, property)) {
|
511 | if (typeof obj[property] === "object") {
|
512 | yield resolvePlaceholdersRecursively(obj[property], visited, replacer);
|
513 | }
|
514 | else if (typeof obj[property] === "string") {
|
515 | obj[property] = yield replacer(obj[property]);
|
516 | }
|
517 | }
|
518 | }
|
519 | }
|
520 | });
|
521 | }
|
522 | const PlaceholderExpression = /\$\{([.a-zA-Z_-]+)([.:0-9a-zA-Z-_ \" ]+)*\}/g;
|
523 | function resolvePlaceholder(value) {
|
524 | return __awaiter(this, void 0, void 0, function* () {
|
525 | if (!PlaceholderExpression.test(value)) {
|
526 | return value;
|
527 | }
|
528 | PlaceholderExpression.lastIndex = 0;
|
529 | let currentValue = value;
|
530 | let result;
|
531 |
|
532 | while (result = PlaceholderExpression.exec(currentValue)) {
|
533 | const fm = result[0];
|
534 | const envValue = process.env[result[1]];
|
535 | const defaultValue = result[2] ? result[2].trim().slice(1) : undefined;
|
536 | if (envValue) {
|
537 | currentValue = currentValue.split(fm).join(envValue);
|
538 | }
|
539 | else if (defaultValue) {
|
540 | currentValue = currentValue.split(fm).join(defaultValue);
|
541 | }
|
542 | else {
|
543 | throw new Error(`Environment variable '${result[1]}' is not defined`);
|
544 | }
|
545 | }
|
546 | return currentValue;
|
547 | });
|
548 | }
|
549 |
|
550 |
|
551 |
|
552 | function invokePostProcessors(cfg) {
|
553 | return cfg.postProcessors.reduce((pp, fp) => pp.then(fp), Promise.resolve(cfg));
|
554 | }
|
555 | exports.invokePostProcessors = invokePostProcessors;
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 | function validateConfiguration(cfg) {
|
563 | if (!cfg) {
|
564 | throw new Error(`no configuration defined`);
|
565 | }
|
566 | const errors = [];
|
567 | if (!cfg.name) {
|
568 | errors.push("you must set a 'name' property in your configuration");
|
569 | }
|
570 | if (!cfg.version) {
|
571 | errors.push("you must set a 'version' property in your configuration");
|
572 | }
|
573 | if (!cfg.apiKey) {
|
574 | logger_1.logger.info("To obtain an 'apiKey' visit https://app.atomist.com/apikeys and run 'atomist config' " +
|
575 | "to configure the apiKey in your local configuration");
|
576 | errors.push("you must set an 'apiKey' property in your configuration");
|
577 | }
|
578 | cfg.workspaceIds = cfg.workspaceIds || [];
|
579 | cfg.groups = cfg.groups || [];
|
580 | if (cfg.workspaceIds.length < 1 && cfg.groups.length < 1) {
|
581 | errors.push("you must either provide an array of 'groups' in your configuration or, more likely, provide " +
|
582 | "an array of 'workspaceIds' in your configuration or set the ATOMIST_WORKSPACES environment variable " +
|
583 | "to a comma-separated list of workspace IDs");
|
584 | }
|
585 | if (cfg.workspaceIds.length > 0 && cfg.groups.length > 0) {
|
586 | errors.push("you cannot specify both 'workspaceIds' and 'groups' in your configuration, you must set one " +
|
587 | "to an empty array");
|
588 | }
|
589 | if (errors.length > 0) {
|
590 | const msg = `Configuration (${stringify(cfg, string_1.obfuscateJson)}) is not correct: ${errors.join("; ")}`;
|
591 | throw new Error(msg);
|
592 | }
|
593 | }
|
594 | exports.validateConfiguration = validateConfiguration;
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 | function loadConfiguration(base) {
|
642 | return __awaiter(this, void 0, void 0, function* () {
|
643 |
|
644 | global.__logger = logger_1.logger;
|
645 | const cfgPath = typeof base === "string" ? base : undefined;
|
646 | const cfgBase = typeof base !== "string" ? base : undefined;
|
647 | let cfg;
|
648 | try {
|
649 | const defCfg = defaultConfiguration();
|
650 | const autoCfg = (yield cfgBase) || (yield loadAutomationConfig(cfgPath)) || (yield loadIndexConfig());
|
651 | const userCfg = loadUserConfiguration(defCfg.name, defCfg.version);
|
652 | const atmPathCfg = loadAtomistConfigPath();
|
653 | const atmCfg = loadAtomistConfig();
|
654 | cfg = mergeConfigs({}, defCfg, autoCfg, userCfg, atmPathCfg, atmCfg);
|
655 | resolveWorkspaceIds(cfg);
|
656 | resolvePort(cfg);
|
657 | }
|
658 | catch (e) {
|
659 | e.message = `Failed to load configuration: ${e.message}`;
|
660 | logger_1.logger.error(e.message);
|
661 | if (e.stack) {
|
662 | logger_1.logger.error(`Stack trace:\n${e.stack}`);
|
663 | }
|
664 | throw e;
|
665 | }
|
666 | const completeCfg = yield invokePostProcessors(cfg);
|
667 | completeCfg.postProcessors = [];
|
668 | resolveEnvironmentVariables(completeCfg);
|
669 | yield resolvePlaceholders(completeCfg);
|
670 | validateConfiguration(completeCfg);
|
671 | return completeCfg;
|
672 | });
|
673 | }
|
674 | exports.loadConfiguration = loadConfiguration;
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 | exports.DEFAULT_REDACTION_PATTERNS = [
|
683 | {
|
684 | regexp: /\b[A-F0-9]{64}\b/g,
|
685 | replacement: "[ATOMIST_API_KEY]",
|
686 | },
|
687 | {
|
688 | regexp: /[1-9][0-9]+-[0-9a-zA-Z]{40}/g,
|
689 | replacement: "[TWITTER_ACCESS_TOKEN]",
|
690 | },
|
691 | {
|
692 | regexp: /EAACEdEose0cBA[0-9A-Za-z]+/g,
|
693 | replacement: "[FACEBOOK_ACCESS_TOKEN]",
|
694 | },
|
695 | {
|
696 | regexp: /AIza[0-9A-Za-z\-_]{35}/g,
|
697 | replacement: "[GOOGLE_API_KEY]",
|
698 | },
|
699 | {
|
700 | regexp: /[0-9]+-[0-9A-Za-z_]{32}\.apps\.googleusercontent\.com/g,
|
701 | replacement: "[GOOGLE_OAUTH_ID]",
|
702 | },
|
703 | {
|
704 | regexp: /sk_live_[0-9a-z]{32}/g,
|
705 | replacement: "[PICATIC_API_KEY|",
|
706 | },
|
707 | {
|
708 | regexp: /sk_live_[0-9a-zA-Z]{24}/g,
|
709 | replacement: "[STRIPE_REGULAR_API_KEY]",
|
710 | },
|
711 | {
|
712 | regexp: /rk_live_[0-9a-zA-Z]{24}/g,
|
713 | replacement: "[STRIPE_RESTRICTED_API_KEY]",
|
714 | },
|
715 | {
|
716 | regexp: /sq0atp-[0-9A-Za-z\-_]{22}/g,
|
717 | replacement: "[SQUARE_OAUTH_TOKEN]",
|
718 | },
|
719 | {
|
720 | regexp: /sq0csp-[0-9A-Za-z\-_]{43}/g,
|
721 | replacement: "[SQUARE_OAUTH_SECRET]",
|
722 | },
|
723 | {
|
724 | regexp: /access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}/g,
|
725 | replacement: "[BRAINTREE_ACCESS_TOKEN]",
|
726 | },
|
727 | {
|
728 | regexp: /amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g,
|
729 | replacement: "[AMAZON_AUTH_TOKEN]",
|
730 | },
|
731 | {
|
732 | regexp: /SK[0-9a-fA-F]{32}/g,
|
733 | replacement: "[TWILLIO_API_KEY]",
|
734 | },
|
735 | {
|
736 | regexp: /key-[0-9a-zA-Z]{32}/g,
|
737 | replacement: "[MAILGUN_KEY]",
|
738 | },
|
739 | {
|
740 | regexp: /[0-9a-f]{32}-us[0-9]{1,2}/g,
|
741 | replacement: "[MAILCHIMP_API_KEY]",
|
742 | },
|
743 | {
|
744 | regexp: /\bAK[0-9A-Z]{18}\b/g,
|
745 | replacement: "[AMAZON_ACCESS_KEY]",
|
746 | },
|
747 | {
|
748 | regexp: /\b(https?:\/\/)(?:v1\.)?[a-f0-9]{40}((?::x-oauth-basic)?@)/g,
|
749 | replacement: "$1[GITHUB_TOKEN]$2",
|
750 | },
|
751 | {
|
752 |
|
753 |
|
754 | regexp: /\b((?:ht|f|sm)tps?:\/\/[^:/?#\[\]@""<>{}|\\^``\s]+:)[^:/?#\[\]@""<>{}|\\^``\s]+@/g,
|
755 | replacement: "$1[URL_PASSWORD]@",
|
756 | },
|
757 | ];
|
758 |
|
759 |
|
760 |
|
761 |
|
762 | exports.LocalDefaultConfiguration = {
|
763 | workspaceIds: [],
|
764 | groups: [],
|
765 | environment: "local",
|
766 | policy: "ephemeral",
|
767 | endpoints: {
|
768 | api: "https://automation.atomist.com/registration",
|
769 | graphql: "https://automation.atomist.com/graphql/team",
|
770 | auth: "https://api.atomist.com/v2/auth",
|
771 | },
|
772 | http: {
|
773 | enabled: true,
|
774 | host: "0.0.0.0",
|
775 | auth: {
|
776 | basic: {
|
777 | enabled: false,
|
778 | },
|
779 | bearer: {
|
780 | enabled: false,
|
781 | },
|
782 | },
|
783 | customizers: [],
|
784 | },
|
785 | ws: {
|
786 | enabled: true,
|
787 | termination: {
|
788 | graceful: false,
|
789 | gracePeriod: shutdown_1.defaultGracePeriod,
|
790 | },
|
791 | compress: false,
|
792 | timeout: 30000,
|
793 | lifecycle: new WebSocketLifecycle_1.QueuingWebSocketLifecycle(),
|
794 | },
|
795 | applicationEvents: {
|
796 | enabled: false,
|
797 | },
|
798 | cluster: {
|
799 | enabled: false,
|
800 | },
|
801 | logging: {
|
802 | level: "info",
|
803 | callsite: false,
|
804 | color: true,
|
805 | file: {
|
806 | enabled: true,
|
807 | level: "debug",
|
808 | },
|
809 | banner: {
|
810 | enabled: true,
|
811 | contributors: [],
|
812 | },
|
813 | },
|
814 | statsd: {
|
815 | enabled: false,
|
816 | },
|
817 | redact: {
|
818 | log: true,
|
819 | messages: true,
|
820 | patterns: exports.DEFAULT_REDACTION_PATTERNS,
|
821 | },
|
822 | commands: undefined,
|
823 | events: undefined,
|
824 | ingesters: [],
|
825 | listeners: [],
|
826 | postProcessors: [],
|
827 | };
|
828 |
|
829 |
|
830 |
|
831 | exports.ProductionDefaultConfiguration = {
|
832 | environment: "production",
|
833 | policy: "durable",
|
834 | http: {
|
835 | port: 2866,
|
836 | auth: {
|
837 | basic: {
|
838 | enabled: true,
|
839 | },
|
840 | bearer: {
|
841 | enabled: true,
|
842 | },
|
843 | },
|
844 | },
|
845 | ws: {
|
846 | termination: {
|
847 | graceful: true,
|
848 | },
|
849 | compress: true,
|
850 | },
|
851 | applicationEvents: {
|
852 | enabled: true,
|
853 | },
|
854 | cluster: {
|
855 | enabled: true,
|
856 | },
|
857 | logging: {
|
858 | level: "info",
|
859 | file: {
|
860 | enabled: false,
|
861 | },
|
862 | },
|
863 | statsd: {
|
864 | enabled: true,
|
865 | },
|
866 | };
|
867 |
|
868 |
|
869 |
|
870 | exports.TestingDefaultConfiguration = {
|
871 | environment: "testing",
|
872 | policy: "durable",
|
873 | http: {
|
874 | auth: {
|
875 | basic: {
|
876 | enabled: true,
|
877 | },
|
878 | bearer: {
|
879 | enabled: true,
|
880 | },
|
881 | },
|
882 | },
|
883 | ws: {
|
884 | termination: {
|
885 | graceful: true,
|
886 | },
|
887 | compress: true,
|
888 | },
|
889 | applicationEvents: {
|
890 | enabled: true,
|
891 | },
|
892 | cluster: {
|
893 | enabled: true,
|
894 | },
|
895 | logging: {
|
896 | level: "info",
|
897 | file: {
|
898 | enabled: false,
|
899 | },
|
900 | },
|
901 | statsd: {
|
902 | enabled: true,
|
903 | },
|
904 | };
|
905 |
|
\ | No newline at end of file |