@rocket.chat/houston 0.27.0-next.3 → 2.1.9
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/LICENSE +1 -1
- package/README.md +109 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +642 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/loadtest.md +264 -0
- package/data/docs/troubleshooting.md +203 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +170 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +57 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3694 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +814 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2599 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +345 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +694 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1549 -0
- package/dist/core/lifecycle/create-k8s.js +960 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +636 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +862 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +818 -0
- package/dist/core/lifecycle/request.js +510 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +1051 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +976 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1336 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +877 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +371 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +299 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +191 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +236 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +70 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VOICE_PARAM_ALIASES = exports.VOICE_DEFAULT_PORTS = exports.VOICE_GUIDE_URL = exports.VOICE_TEST_USERS = void 0;
|
|
4
|
+
exports.refuseVoiceBefore800 = refuseVoiceBefore800;
|
|
5
|
+
exports.scenario = scenario;
|
|
6
|
+
exports.build = build;
|
|
7
|
+
/**
|
|
8
|
+
* Dynamic `voice` preset: Rocket.Chat Voice, calls between users, and with `sip_integration=on` the SIP stack
|
|
9
|
+
* Rocket.Chat's documentation pairs it with (Drachtio and Rocket.Chat's own FreeSWITCH image).
|
|
10
|
+
*
|
|
11
|
+
* A call's audio goes browser to browser over WebRTC; Rocket.Chat only signals. So calls between
|
|
12
|
+
* users need no service, only a licence carrying the Voice add-on (the `teams-voip` module):
|
|
13
|
+
* Rocket.Chat 8 has no setting that switches Voice on, a workspace licensed for it has it. Without
|
|
14
|
+
* one the workspace still boots and says so, because a licence can be applied later.
|
|
15
|
+
*
|
|
16
|
+
* With sip_integration=on Rocket.Chat reaches Drachtio, a SIP signalling gateway, on :9022, and Drachtio
|
|
17
|
+
* reaches FreeSWITCH on :5060. Both run as Rocket.Chat's own compose files define them
|
|
18
|
+
* (`compose.drachtio.yml`, `compose.freeswitch.yml` in RocketChat/rocketchat-compose): the same
|
|
19
|
+
* images, command and variables. FreeSWITCH's stock dialplan answers 123 with an echo test and
|
|
20
|
+
* sends a four-digit number back through Drachtio to the Rocket.Chat user with that extension.
|
|
21
|
+
*
|
|
22
|
+
* AUDIO IS A DIRECT UDP CONNECTION between FreeSWITCH and the browser, on a port of the RTP range
|
|
23
|
+
* (Rocket.Chat's docs), so the range is published and FreeSWITCH advertises VOIP_DOMAIN, the
|
|
24
|
+
* address browsers reach this machine at. The default is its own container name, which only a
|
|
25
|
+
* browser on this (Linux) machine reaches. Drachtio sends its in-dialog requests back to where
|
|
26
|
+
* FreeSWITCH's replies came from, so advertising the machine's address does not cut Drachtio off
|
|
27
|
+
* (measured: ACK and BYE delivered with FreeSWITCH advertising the host's address).
|
|
28
|
+
*
|
|
29
|
+
* Parameters (via `--set`), named as Rocket.Chat's settings and compose files name them; the GUI
|
|
30
|
+
* labels each with the same words (SIP integration, VoIP domain, RTP ports, ICE servers, PBX,
|
|
31
|
+
* FreeSWITCH dialplans), so a lab built in one front-end is repeated in the other word for word:
|
|
32
|
+
* sip_integration on|off (default off).
|
|
33
|
+
* voip_domain VOIP_DOMAIN, the hostname or IPv4 browsers reach this machine at.
|
|
34
|
+
* rtp_ports the published RTP range, start-end (default 20000-20046).
|
|
35
|
+
* ice_servers Rocket.Chat's ICE servers setting: [user:password@]stun:|turn:|turns:host:port,...
|
|
36
|
+
* pbx on|off (default off): the PBX lab, `voice-pbx.ts` (sip_integration=on).
|
|
37
|
+
* freeswitch_dialplans stock|edit (default stock): FreeSWITCH's dialplans as files to edit (pbx=on).
|
|
38
|
+
* 2.1.3 spelled the first and last `sip` and `fs_dialplan`; `VOICE_PARAM_ALIASES` keeps them working.
|
|
39
|
+
*/
|
|
40
|
+
const errors_1 = require("../errors");
|
|
41
|
+
const format_1 = require("../format");
|
|
42
|
+
const redact_1 = require("../redact");
|
|
43
|
+
const version_spec_1 = require("../version-spec");
|
|
44
|
+
const guides_1 = require("./guides");
|
|
45
|
+
const common_1 = require("./common");
|
|
46
|
+
const registry_1 = require("./registry");
|
|
47
|
+
const scenario_1 = require("./scenario");
|
|
48
|
+
const types_1 = require("./types");
|
|
49
|
+
const voice_pbx_1 = require("./voice-pbx");
|
|
50
|
+
/** Created by the `voice_users` post-ready action, each with its username as its password. */
|
|
51
|
+
exports.VOICE_TEST_USERS = Object.freeze({
|
|
52
|
+
'voice-alice': '1001',
|
|
53
|
+
'voice-bob': '1002',
|
|
54
|
+
});
|
|
55
|
+
// The images Rocket.Chat's compose files name. ponytail: `latest`, as those files have it (owner
|
|
56
|
+
// decision), so a workspace gets what a customer deploying them today gets; pin when a ticket
|
|
57
|
+
// needs an older FreeSWITCH build.
|
|
58
|
+
const DRACHTIO_IMAGE = 'docker.io/drachtio/drachtio-server:latest';
|
|
59
|
+
const FREESWITCH_IMAGE = 'docker.io/rocketchat/freeswitch:latest';
|
|
60
|
+
/** The shipped guide, where it is read online: the eight test calls, the PBX, the call flow. */
|
|
61
|
+
exports.VOICE_GUIDE_URL = 'https://github.com/RocketChat/Rocket.Chat.Houston/blob/main/data/docs/voice.md';
|
|
62
|
+
const DRACHTIO_PORT = 9022;
|
|
63
|
+
const DRACHTIO_SECRET = 'houston';
|
|
64
|
+
const SIP_PORT = 5060;
|
|
65
|
+
const DEFAULT_RTP = [20000, 20046];
|
|
66
|
+
/**
|
|
67
|
+
* Every host port voice publishes at its defaults, lab PBX included. They cannot move -- phones
|
|
68
|
+
* and the PBX dial them by number -- so another workspace's side port must never be given one
|
|
69
|
+
* (`core/lifecycle/ports.ts` skips them when it looks for a free port).
|
|
70
|
+
*/
|
|
71
|
+
exports.VOICE_DEFAULT_PORTS = Object.freeze([
|
|
72
|
+
SIP_PORT,
|
|
73
|
+
...Array.from({ length: DEFAULT_RTP[1] - DEFAULT_RTP[0] + 1 }, (_, i) => DEFAULT_RTP[0] + i),
|
|
74
|
+
voice_pbx_1.EXTERNAL_SIP_PORT,
|
|
75
|
+
...voice_pbx_1.PBX_PORTS,
|
|
76
|
+
]);
|
|
77
|
+
// Labels of 1-63 letters, digits and inner hyphens; an IPv4 address is such a name too.
|
|
78
|
+
const HOST = /^(?=.{1,253}$)[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/u;
|
|
79
|
+
// No `$`: compose reads it as interpolation, so `pa$w` reached Rocket.Chat as `pa`.
|
|
80
|
+
const ICE_SERVER = /^([^@\s,$]+@)?(stun|turns?):[^\s,@$]+$/u;
|
|
81
|
+
// Docker runs a proxy and rules per published port. The official range is 47 ports.
|
|
82
|
+
const MAX_RTP_PORTS = 200;
|
|
83
|
+
/** The 2.1.3 names of two options, still taken everywhere a `--set` key is read. */
|
|
84
|
+
exports.VOICE_PARAM_ALIASES = Object.freeze({
|
|
85
|
+
sip: 'sip_integration',
|
|
86
|
+
fs_dialplan: 'freeswitch_dialplans',
|
|
87
|
+
});
|
|
88
|
+
const PARAMS_HELP = Object.freeze({
|
|
89
|
+
sip_integration: 'off|on (default off); SIP integration: Drachtio and FreeSWITCH as rocketchat-compose runs them, SIP integration enabled in Rocket.Chat, Voice call extensions 1001 and 1002 for the test users. Docker only',
|
|
90
|
+
voip_domain: "VOIP_DOMAIN: the hostname or IPv4 address browsers and phones send RTP audio to, for other computers the server's LAN or public IP; any address but loopback opens the call ports on every address of the machine running houston (default freeswitch, a browser on that machine only; sip_integration=on)",
|
|
91
|
+
rtp_ports: 'the published UDP RTP range, start-end, at most 200 ports (VOIP_RTP_START_PORT-VOIP_RTP_END_PORT; default 20000-20046; sip_integration=on)',
|
|
92
|
+
ice_servers: "Rocket.Chat's ICE servers setting (WebRTC settings), comma-separated [user:password@]stun:|turn:|turns:host:port; unset keeps Rocket.Chat's own (Google STUN)",
|
|
93
|
+
pbx: "off|on (default off); a lab PBX (Asterisk) on FreeSWITCH's external profile: desk phones, ring groups, an outside caller (sip_integration=on)",
|
|
94
|
+
freeswitch_dialplans: "stock|edit (default stock); edit gives FreeSWITCH's public and drachtio dialplans as editable copies in the workspace folder (pbx=on)",
|
|
95
|
+
});
|
|
96
|
+
function rtpRange(params) {
|
|
97
|
+
const raw = (0, common_1.strParam)(params, 'rtp_ports', '');
|
|
98
|
+
if (raw === '')
|
|
99
|
+
return DEFAULT_RTP;
|
|
100
|
+
const match = /^(\d{4,5})-(\d{4,5})$/u.exec(raw.trim());
|
|
101
|
+
const [start, end] = match === null ? [0, 0] : [Number(match[1]), Number(match[2])];
|
|
102
|
+
if (start < 1024 || end > 65535 || start >= end || end - start + 1 > MAX_RTP_PORTS) {
|
|
103
|
+
throw new Error(`--set rtp_ports=${(0, format_1.shownValue)(raw)} expects start-end, start below end, both from 1024 to 65535, at most ${String(MAX_RTP_PORTS)} ports`);
|
|
104
|
+
}
|
|
105
|
+
return [start, end];
|
|
106
|
+
}
|
|
107
|
+
function resolveIntent(params) {
|
|
108
|
+
// choiceParam's first choice is the default.
|
|
109
|
+
const sip = (0, common_1.choiceParam)(params, 'sip_integration', ['off', 'on']) === 'on';
|
|
110
|
+
for (const key of ['voip_domain', 'rtp_ports']) {
|
|
111
|
+
if (!sip && (0, common_1.strParam)(params, key, '') !== '') {
|
|
112
|
+
throw new Error(`--set ${key} has an effect only with sip_integration=on`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const voipDomain = (0, common_1.strParam)(params, 'voip_domain', 'freeswitch');
|
|
116
|
+
if (!HOST.test(voipDomain)) {
|
|
117
|
+
throw new Error(`--set voip_domain=${(0, format_1.shownValue)(voipDomain)} expects a hostname or IPv4 address`);
|
|
118
|
+
}
|
|
119
|
+
const iceServers = (0, common_1.strParam)(params, 'ice_servers', '');
|
|
120
|
+
for (const entry of iceServers === '' ? [] : iceServers.split(',')) {
|
|
121
|
+
if (!ICE_SERVER.test(entry.trim())) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
// Masked: a refusal reaches houston.log and the GUI's Activity.
|
|
124
|
+
`--set ice_servers entry ${(0, format_1.shownValue)((0, redact_1.redactIceServers)(entry.trim()))} is not [user:password@]stun:, turn: or turns:host:port`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const pbx = (0, common_1.choiceParam)(params, 'pbx', ['off', 'on']) === 'on';
|
|
128
|
+
if (pbx && !sip)
|
|
129
|
+
throw new Error('--set pbx=on needs sip_integration=on');
|
|
130
|
+
const fsDialplan = (0, common_1.choiceParam)(params, 'freeswitch_dialplans', ['stock', 'edit']) === 'edit' ? 'edit' : 'stock';
|
|
131
|
+
if (fsDialplan === 'edit' && !pbx) {
|
|
132
|
+
throw new Error('--set freeswitch_dialplans=edit needs pbx=on');
|
|
133
|
+
}
|
|
134
|
+
return { sip, voipDomain, rtp: rtpRange(params), iceServers, pbx, fsDialplan };
|
|
135
|
+
}
|
|
136
|
+
/** Drachtio and FreeSWITCH as Rocket.Chat's compose files define them; see the module comment. */
|
|
137
|
+
function sipServices(intent) {
|
|
138
|
+
const [start, end] = intent.rtp;
|
|
139
|
+
const range = `${String(start)}-${String(end)}`;
|
|
140
|
+
const external = String(voice_pbx_1.EXTERNAL_SIP_PORT);
|
|
141
|
+
return {
|
|
142
|
+
// compose.drachtio.yml. Never published: Rocket.Chat and FreeSWITCH reach it by name.
|
|
143
|
+
drachtio: {
|
|
144
|
+
image: DRACHTIO_IMAGE,
|
|
145
|
+
restart: 'unless-stopped',
|
|
146
|
+
expose: [DRACHTIO_PORT, `${String(SIP_PORT)}/udp`],
|
|
147
|
+
environment: {
|
|
148
|
+
DRACHTIO_ADMIN_TCP_PORT: String(DRACHTIO_PORT),
|
|
149
|
+
DRACHTIO_SECRET,
|
|
150
|
+
DRACHTIO_LOGLEVEL: 'info',
|
|
151
|
+
DRACHTIO_SOFIA_LOGLEVEL: '3',
|
|
152
|
+
},
|
|
153
|
+
command: 'drachtio --contact "sip:*;transport=udp"',
|
|
154
|
+
},
|
|
155
|
+
// compose.freeswitch.yml, the `$$` escapes as that file writes them. houston adds only the
|
|
156
|
+
// start order: FreeSWITCH resolves the drachtio name once, when it starts.
|
|
157
|
+
freeswitch: {
|
|
158
|
+
image: FREESWITCH_IMAGE,
|
|
159
|
+
restart: 'unless-stopped',
|
|
160
|
+
depends_on: ['drachtio'],
|
|
161
|
+
environment: {
|
|
162
|
+
EXTERNAL_ADDRESS_FQDN: intent.voipDomain,
|
|
163
|
+
FREESWITCH_PASSWORD: '',
|
|
164
|
+
RTP_START_PORT: String(start),
|
|
165
|
+
RTP_END_PORT: String(end),
|
|
166
|
+
ACCEPT_EXTERNAL_CALLS: String(intent.pbx),
|
|
167
|
+
USE_LEGACY_ARCH: 'false',
|
|
168
|
+
DRACHTIO_DOMAIN: 'drachtio',
|
|
169
|
+
DEBUG_MODE: 'false',
|
|
170
|
+
INTERNAL_NUMBER_EXPRESSION: '^(\\d{4})$$',
|
|
171
|
+
INTERNAL_DIALPLAN_INTERNAL_NUMBER_BRIDGE_STRING: 'sofia/internal/$${dialed_extension}@$${domain_name}',
|
|
172
|
+
// compose.freeswitch.external.yml, laid over the base file as Rocket.Chat's docs do.
|
|
173
|
+
...(intent.pbx ? (0, voice_pbx_1.externalEnv)() : {}),
|
|
174
|
+
},
|
|
175
|
+
expose: [`${String(SIP_PORT)}/udp`, ...(intent.pbx ? [`${external}/udp`] : [])],
|
|
176
|
+
// Host = container: FreeSWITCH names its own ports in what it tells the browser. The RTP
|
|
177
|
+
// range on every address once voip_domain names one (`opensCallPorts`); 5080 stays on the
|
|
178
|
+
// bind, since the PBX reaches it by name.
|
|
179
|
+
ports: [
|
|
180
|
+
`${(0, voice_pbx_1.opensCallPorts)(intent.voipDomain) ? '0.0.0.0:' : ''}${range}:${range}/udp`,
|
|
181
|
+
...(intent.pbx ? [`${external}:${external}/udp`] : []),
|
|
182
|
+
],
|
|
183
|
+
...(intent.fsDialplan === 'edit' ? { volumes: [...voice_pbx_1.FS_DIALPLAN_MOUNTS] } : {}),
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** The scenario card's guide: who to sign in as, what to try, what to know, for this lab. */
|
|
188
|
+
function voiceGuide(intent) {
|
|
189
|
+
const stack = intent.sip ? ' with the SIP integration (Drachtio and FreeSWITCH)' : '';
|
|
190
|
+
const lab = intent.pbx ? ' and a lab PBX' : '';
|
|
191
|
+
return (0, guides_1.guide)('voice', {
|
|
192
|
+
summary: `Rocket.Chat Voice, calls between users${stack}${lab}; needs a license with the Voice add-on.`,
|
|
193
|
+
signIn: Object.entries(exports.VOICE_TEST_USERS).map(([user, extension]) => [
|
|
194
|
+
user,
|
|
195
|
+
user,
|
|
196
|
+
intent.sip ? `extension ${extension}` : '',
|
|
197
|
+
]),
|
|
198
|
+
steps: [
|
|
199
|
+
'Open Rocket.Chat over HTTPS, or at localhost in a browser on the machine running houston.',
|
|
200
|
+
'Sign in as both users in separate browser profiles, open a direct message between them, and press the call button.',
|
|
201
|
+
intent.sip ? 'Dial 123 from the keypad: FreeSWITCH answers with an echo test.' : '',
|
|
202
|
+
intent.pbx
|
|
203
|
+
? 'Ring voice-bob from the PBX: docker exec houston-<name>-pbx-1 asterisk -rx "channel originate Local/1002@from-outside application Echo".'
|
|
204
|
+
: intent.sip
|
|
205
|
+
? "Ring voice-bob from FreeSWITCH: docker exec houston-<name>-freeswitch-1 fs_cli -x 'originate {media_webrtc=true}sofia/internal/1002@drachtio &echo'."
|
|
206
|
+
: '',
|
|
207
|
+
],
|
|
208
|
+
know: [
|
|
209
|
+
'Without a license with the Voice add-on (teams-voip) there is no call button: add one when creating (--license, or the Enterprise license field), or later in Rocket.Chat under Administration → Subscription; then houston ready --name <name> (in the GUI: take it down, then bring it up) gives the extensions.',
|
|
210
|
+
'On a plain-HTTP address other than localhost the browser withholds the microphone, and Rocket.Chat 8.8.1 shows "Application Error".',
|
|
211
|
+
intent.sip
|
|
212
|
+
? intent.voipDomain === 'freeswitch'
|
|
213
|
+
? "SIP audio reaches a browser on the machine running houston only; for other computers set voip_domain to the server's LAN or public IP."
|
|
214
|
+
: (0, voice_pbx_1.opensCallPorts)(intent.voipDomain)
|
|
215
|
+
? `FreeSWITCH advertises ${intent.voipDomain}; houston opens the RTP ports on every address of the machine running houston, so browsers elsewhere reach it over UDP.`
|
|
216
|
+
: `FreeSWITCH advertises ${intent.voipDomain}; only a browser on the machine running houston reaches it.`
|
|
217
|
+
: '',
|
|
218
|
+
intent.pbx
|
|
219
|
+
? 'PBX numbers: 22101 rings 10 s then answers, 22102 never, 22103 busy, 22104 at once; ring groups 23000 and 23001; 5550000 echo, 5550001 rings forever, 5550002 busy; softphone accounts 22001 to 22004 (password = number).'
|
|
220
|
+
: '',
|
|
221
|
+
intent.pbx
|
|
222
|
+
? 'The lab files are in the workspace folder under voice/; the Voice guide, linked above, has the eight test calls, the call flow and the editable dialplans.'
|
|
223
|
+
: '',
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function adapter(intent) {
|
|
228
|
+
const users = Object.keys(exports.VOICE_TEST_USERS).join(', ');
|
|
229
|
+
const preset = {
|
|
230
|
+
...(0, types_1.emptyPreset)('voice'),
|
|
231
|
+
description:
|
|
232
|
+
// One sentence: the GUI's create dialog shows only the first.
|
|
233
|
+
'Rocket.Chat Voice, which needs a license with the Voice add-on: calls between users in ' +
|
|
234
|
+
'the browser, with test users; SIP integration (--set sip_integration=on) adds Drachtio and FreeSWITCH.',
|
|
235
|
+
source: 'built-in (scenario)',
|
|
236
|
+
scenario: 'voice',
|
|
237
|
+
scenarioParams: { ...intent },
|
|
238
|
+
paramsHelp: { ...PARAMS_HELP },
|
|
239
|
+
requiresLicense: true,
|
|
240
|
+
// The test users' emails are verified, so Rocket.Chat asks them for an emailed code a repro
|
|
241
|
+
// has no mail server to send; composed with `email`, Mailpit catches it and email's value wins.
|
|
242
|
+
env: {
|
|
243
|
+
[common_1.EMAIL_2FA]: 'false',
|
|
244
|
+
...(intent.iceServers === ''
|
|
245
|
+
? {}
|
|
246
|
+
: { OVERWRITE_SETTING_VoIP_TeamCollab_Ice_Servers: intent.iceServers }),
|
|
247
|
+
},
|
|
248
|
+
softEnv: [common_1.EMAIL_2FA],
|
|
249
|
+
postReady: [{ action: 'voice_users', extensions: intent.sip }],
|
|
250
|
+
guides: [voiceGuide(intent)],
|
|
251
|
+
notes: [
|
|
252
|
+
`Voice test users: ${users}, each with its username as its password. Sign in as both in separate browser profiles, open a direct message between them, and press the call button.`,
|
|
253
|
+
'Voice needs a license with the Voice add-on (teams-voip); without one Rocket.Chat shows no call button. Add one when creating (--license, or the Enterprise license field), or later in Rocket.Chat under Administration → Subscription.',
|
|
254
|
+
'Open Rocket.Chat over HTTPS, or at localhost in a browser on the machine running houston. On a plain-HTTP address elsewhere the browser withholds the microphone, and Rocket.Chat 8.8.1 shows "Application Error" for the whole page.',
|
|
255
|
+
// A place line: the CLI prints it, the GUI's card makes it a link row.
|
|
256
|
+
`Voice guide (the test calls, the PBX, the call flow): ${exports.VOICE_GUIDE_URL}`,
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
if (!intent.sip)
|
|
260
|
+
return preset;
|
|
261
|
+
return {
|
|
262
|
+
...preset,
|
|
263
|
+
env: {
|
|
264
|
+
...preset.env,
|
|
265
|
+
OVERWRITE_SETTING_VoIP_TeamCollab_SIP_Integration_Enabled: 'true',
|
|
266
|
+
OVERWRITE_SETTING_VoIP_TeamCollab_Drachtio_Host: 'drachtio',
|
|
267
|
+
OVERWRITE_SETTING_VoIP_TeamCollab_Drachtio_Port: String(DRACHTIO_PORT),
|
|
268
|
+
OVERWRITE_SETTING_VoIP_TeamCollab_Drachtio_Password: DRACHTIO_SECRET,
|
|
269
|
+
OVERWRITE_SETTING_VoIP_TeamCollab_SIP_Server_Host: 'freeswitch',
|
|
270
|
+
OVERWRITE_SETTING_VoIP_TeamCollab_SIP_Server_Port: String(SIP_PORT),
|
|
271
|
+
},
|
|
272
|
+
services: {
|
|
273
|
+
...sipServices(intent),
|
|
274
|
+
...(intent.pbx ? { pbx: (0, voice_pbx_1.pbxService)((0, voice_pbx_1.opensCallPorts)(intent.voipDomain)) } : {}),
|
|
275
|
+
},
|
|
276
|
+
// Rocket.Chat needs only the SIP stack; the PBX starts after FreeSWITCH (its depends_on).
|
|
277
|
+
dependsOn: ['drachtio', 'freeswitch'],
|
|
278
|
+
ports: [
|
|
279
|
+
...Array.from({ length: intent.rtp[1] - intent.rtp[0] + 1 }, (_, i) => intent.rtp[0] + i),
|
|
280
|
+
...(intent.pbx ? [voice_pbx_1.EXTERNAL_SIP_PORT, ...voice_pbx_1.PBX_PORTS] : []),
|
|
281
|
+
],
|
|
282
|
+
files: [
|
|
283
|
+
...(intent.pbx ? (0, voice_pbx_1.pbxFiles)(intent.voipDomain) : []),
|
|
284
|
+
...(intent.fsDialplan === 'edit' ? (0, voice_pbx_1.fsDialplanFiles)() : []),
|
|
285
|
+
],
|
|
286
|
+
keepFiles: [
|
|
287
|
+
...(intent.pbx ? voice_pbx_1.PBX_KEPT : []),
|
|
288
|
+
...(intent.fsDialplan === 'edit' ? voice_pbx_1.FS_DIALPLANS : []),
|
|
289
|
+
],
|
|
290
|
+
notes: [
|
|
291
|
+
...preset.notes,
|
|
292
|
+
'SIP: once Voice is licensed, voice-alice gets extension 1001 and voice-bob 1002 (after a license applied later, houston ready --name <name> sets them; in the GUI, take it down and bring it up). Dial 123 for FreeSWITCH’s echo test (you hear yourself): Rocket.Chat → Drachtio → FreeSWITCH. Dialling 1002 rings voice-bob directly, as Rocket.Chat calls its own users itself.',
|
|
293
|
+
"To ring voice-bob from the SIP side, as a PBX would: docker exec houston-<name>-freeswitch-1 fs_cli -x 'originate {media_webrtc=true}sofia/internal/1002@drachtio &echo'",
|
|
294
|
+
intent.voipDomain === 'freeswitch'
|
|
295
|
+
? "SIP audio reaches a browser on the machine running houston only (FreeSWITCH advertises its container name). For browsers on other computers, as Rocket.Chat's docs set it up: --set voip_domain=<the server's LAN or public IP>; houston then opens the call ports on every address of the server."
|
|
296
|
+
: (0, voice_pbx_1.opensCallPorts)(intent.voipDomain)
|
|
297
|
+
? `FreeSWITCH advertises ${intent.voipDomain}, and houston opens UDP ${String(intent.rtp[0])}-${String(intent.rtp[1])} on every address of the machine running houston (only the call ports; Rocket.Chat's own port stays on the bind). Calls between users are not affected: their audio goes browser to browser.`
|
|
298
|
+
: `FreeSWITCH advertises ${intent.voipDomain}: only a browser on the machine running houston reaches UDP ${String(intent.rtp[0])}-${String(intent.rtp[1])}. Calls between users are not affected: their audio goes browser to browser.`,
|
|
299
|
+
...(intent.pbx ? (0, voice_pbx_1.pbxNotes)(intent.voipDomain) : []),
|
|
300
|
+
],
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Rocket.Chat 7 has the older Team Voice Calls, with other settings and no Drachtio; a voice
|
|
305
|
+
* workspace on it would not be what was asked for, so it is refused before anything is created.
|
|
306
|
+
* A version that is not a number (a build tag) is let through, unknowable here.
|
|
307
|
+
*/
|
|
308
|
+
function refuseVoiceBefore800(pre, rcVersion) {
|
|
309
|
+
if (!pre.postReady.some((action) => action.action === 'voice_users'))
|
|
310
|
+
return;
|
|
311
|
+
let release;
|
|
312
|
+
try {
|
|
313
|
+
release = (0, version_spec_1.parseVersion)(rcVersion).release;
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if ((release[0] ?? 0) >= 8)
|
|
319
|
+
return;
|
|
320
|
+
throw new errors_1.ValidationError(`the voice preset needs Rocket.Chat 8.0.0 or later; ${rcVersion} has the older Team Voice ` +
|
|
321
|
+
'Calls. Choose a newer version.');
|
|
322
|
+
}
|
|
323
|
+
const SCENARIO = new scenario_1.Scenario({
|
|
324
|
+
name: 'voice',
|
|
325
|
+
paramsHelp: PARAMS_HELP,
|
|
326
|
+
paramAliases: exports.VOICE_PARAM_ALIASES,
|
|
327
|
+
resolveIntent,
|
|
328
|
+
adapters: {
|
|
329
|
+
docker: adapter,
|
|
330
|
+
// Settings and REST-created users work the same there; the SIP services have no manifests.
|
|
331
|
+
kubernetes: (intent) => {
|
|
332
|
+
if (intent.sip)
|
|
333
|
+
throw new Error('voice sip_integration=on runs on Docker only');
|
|
334
|
+
return adapter(intent);
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
function scenario() {
|
|
339
|
+
return SCENARIO;
|
|
340
|
+
}
|
|
341
|
+
function build(params) {
|
|
342
|
+
return SCENARIO.resolve(params, 'docker');
|
|
343
|
+
}
|
|
344
|
+
(0, registry_1.register)('voice', build);
|
|
345
|
+
(0, registry_1.registerScenario)('voice', SCENARIO);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.build = build;
|
|
37
|
+
/**
|
|
38
|
+
* Dynamic `webhooks` preset: a web inbox for HTTP requests (webhook-tester), wired to
|
|
39
|
+
* Rocket.Chat the way Mailpit is wired for mail.
|
|
40
|
+
*
|
|
41
|
+
* The receiver records any request whose path starts with a session's uuid, and answers
|
|
42
|
+
* what that session was made to answer. The `webhooks_setup` post-ready action makes ONE
|
|
43
|
+
* session through the receiver's API, answering 200 with a small JSON body -- the one the
|
|
44
|
+
* receiver makes by itself on an unknown uuid answers an EMPTY body, which Rocket.Chat
|
|
45
|
+
* reads as a failed call and retries four times -- and records the uuid the receiver chose.
|
|
46
|
+
* Every link ends in `/s/<uuid>` (the root page would open a new, empty session) and
|
|
47
|
+
* Rocket.Chat posts to the same place on both runtimes. Sub-paths say who posted:
|
|
48
|
+
* `/outgoing` (the sample integration), `/omnichannel` (the Omnichannel webhook),
|
|
49
|
+
* `/captured/<name>` (a customer's integration repointed by capture=all). The receiver
|
|
50
|
+
* keeps sessions and requests on disk, in a volume, so a stop, start, restart or rebuild
|
|
51
|
+
* keeps them; while the receiver's API cannot be reached, post-ready wires nothing and
|
|
52
|
+
* says so, because the auto-created session would bring the retries back.
|
|
53
|
+
*
|
|
54
|
+
* Nothing here is set by env: the sample integrations and the Omnichannel webhook settings
|
|
55
|
+
* are made by the post-ready action, so they stay editable in the admin UI (an
|
|
56
|
+
* OVERWRITE_SETTING_ greys a setting out, and repointing a webhook at a failing session is
|
|
57
|
+
* the point of the exercise).
|
|
58
|
+
*
|
|
59
|
+
* The inbox UI is a browser-router SPA with absolute /api, /js and /s paths and no base-path
|
|
60
|
+
* option, so it is not served under the HTTPS name (its /api would collide with Rocket.Chat's):
|
|
61
|
+
* it answers on its own port on the machine running houston, and the notes say so.
|
|
62
|
+
*
|
|
63
|
+
* Parameters (via `--set`):
|
|
64
|
+
* capture off|all (default off); all repoints every existing outgoing integration at the
|
|
65
|
+
* inbox, so a restored customer backup posts to nothing real.
|
|
66
|
+
*/
|
|
67
|
+
const config = __importStar(require("../config"));
|
|
68
|
+
const guides_1 = require("./guides");
|
|
69
|
+
const common_1 = require("./common");
|
|
70
|
+
const registry_1 = require("./registry");
|
|
71
|
+
const types_1 = require("./types");
|
|
72
|
+
const IMAGE = 'ghcr.io/tarampampam/webhook-tester:2.3.0';
|
|
73
|
+
/** The receiver's one port: UI, API and the capture endpoints together. */
|
|
74
|
+
const CONTAINER_PORT = 8080;
|
|
75
|
+
/**
|
|
76
|
+
* Sessions and requests on disk (the image's FS_STORAGE_DIR is /data), not in memory, and
|
|
77
|
+
* a session kept for the 31 days the receiver allows at most: a request renews it, an idle
|
|
78
|
+
* month ends it, and the next `ready` makes a new one.
|
|
79
|
+
*/
|
|
80
|
+
const ENV = { AUTO_CREATE_SESSIONS: 'true', STORAGE_DRIVER: 'fs', SESSION_TTL: '744h' };
|
|
81
|
+
const DATA = '/data';
|
|
82
|
+
/** The image runs as this uid; a provisioned claim is root's until the pod says otherwise. */
|
|
83
|
+
const UID = 10001;
|
|
84
|
+
const DOCS = 'docs.rocket.chat/docs/integrations#script-compatibility';
|
|
85
|
+
function build(params, ports) {
|
|
86
|
+
const capture = (0, common_1.choiceParam)(params, 'capture', ['off', 'all']);
|
|
87
|
+
const webPort = (0, common_1.presetPort)('webhooks', 0, ports);
|
|
88
|
+
const receiver = `${config.WEBHOOKS_RECEIVER}/<session>`;
|
|
89
|
+
const inboxOrigin = `http://localhost:${String(webPort)}`;
|
|
90
|
+
return {
|
|
91
|
+
...(0, types_1.emptyPreset)('webhooks'),
|
|
92
|
+
description:
|
|
93
|
+
// The GUI's create list shows only the first sentence: it has to say what this is.
|
|
94
|
+
'A web inbox (webhook-tester) that catches every outgoing integration call and ' +
|
|
95
|
+
'Omnichannel webhook Rocket.Chat sends and shows each one; nothing is ' +
|
|
96
|
+
`forwarded. Sample '${config.WEBHOOKS_OUTGOING}' and '${config.WEBHOOKS_INCOMING}' ` +
|
|
97
|
+
'integrations are created, --set capture=all repoints every existing outgoing ' +
|
|
98
|
+
`integration there, and the inbox UI is on port ${String(webPort)} on the machine ` +
|
|
99
|
+
'running houston (no HTTPS path; houston info and the GUI link it).',
|
|
100
|
+
services: {
|
|
101
|
+
webhooks: {
|
|
102
|
+
// Multi-arch (amd64/arm64), built from scratch: no shell, its own HEALTHCHECK.
|
|
103
|
+
image: IMAGE,
|
|
104
|
+
restart: 'unless-stopped',
|
|
105
|
+
environment: { ...ENV },
|
|
106
|
+
volumes: [`webhooks_data:${DATA}`],
|
|
107
|
+
ports: [`${String(webPort)}:${String(CONTAINER_PORT)}`],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
volumes: { webhooks_data: { driver: 'local' } },
|
|
111
|
+
dependsOn: ['webhooks'],
|
|
112
|
+
requiresLicense: false,
|
|
113
|
+
source: 'built-in (dynamic)',
|
|
114
|
+
paramsHelp: {
|
|
115
|
+
capture: 'off|all (default off); all repoints EVERY existing outgoing integration at the ' +
|
|
116
|
+
'inbox and lists the originals, so a restored customer backup posts to nothing real',
|
|
117
|
+
},
|
|
118
|
+
// The origins: post-ready makes the session and composes the addresses from them.
|
|
119
|
+
postReady: [
|
|
120
|
+
{
|
|
121
|
+
action: 'webhooks_setup',
|
|
122
|
+
receiver: config.WEBHOOKS_RECEIVER,
|
|
123
|
+
ui_url: inboxOrigin,
|
|
124
|
+
capture,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
ports: [webPort],
|
|
128
|
+
kubernetesManifests: [
|
|
129
|
+
(0, common_1.k8sManifests)({
|
|
130
|
+
name: 'webhooks',
|
|
131
|
+
image: IMAGE,
|
|
132
|
+
ports: [[webPort, CONTAINER_PORT]],
|
|
133
|
+
env: { ...ENV },
|
|
134
|
+
readiness: {
|
|
135
|
+
httpGet: { path: '/ready', port: CONTAINER_PORT },
|
|
136
|
+
initialDelaySeconds: 2,
|
|
137
|
+
periodSeconds: 3,
|
|
138
|
+
failureThreshold: 40,
|
|
139
|
+
},
|
|
140
|
+
// The lifecycle forwards the labelled Service to this host port, as Mailpit's.
|
|
141
|
+
ui: { webhooks: [webPort, CONTAINER_PORT] },
|
|
142
|
+
data: { path: DATA, size: '256Mi', fsGroup: UID },
|
|
143
|
+
}),
|
|
144
|
+
],
|
|
145
|
+
guides: [
|
|
146
|
+
(0, guides_1.guide)('webhooks', {
|
|
147
|
+
summary: 'A web inbox that shows every outgoing integration call and Omnichannel webhook Rocket.Chat sends, with sample integrations already pointing at it.',
|
|
148
|
+
steps: [
|
|
149
|
+
'Post a message in a public channel: it is in the inbox within a second (POST /outgoing, the message as JSON).',
|
|
150
|
+
"Run the curl that houston info prints under Webhooks: the text appears in #general as rocket.cat (the 'houston-incoming' integration).",
|
|
151
|
+
'With the livechat preset, start a chat on the demo page: every Omnichannel event (start, taken, each message, close) posts to /omnichannel with the X-RocketChat-Livechat-Token header.',
|
|
152
|
+
"Admin → Workspace → Integrations → 'houston-outgoing' → History lists each call and the inbox's answer, from any machine.",
|
|
153
|
+
],
|
|
154
|
+
know: [
|
|
155
|
+
`The inbox UI is on the machine running houston only, no HTTPS path: from elsewhere, ssh -L ${String(webPort)}:127.0.0.1:${String(webPort)} <host>, or --bind.`,
|
|
156
|
+
`Rocket.Chat posts to ${receiver}/<source> inside the workspace network (the session id is the receiver's; the Webhook inbox link carries it): /outgoing, /omnichannel (the Omnichannel webhook, token '${config.WEBHOOKS_TOKEN}'), /captured/<name>.`,
|
|
157
|
+
`The inbox answers 200 with {"captured": true}. A failing or slow endpoint: 'New URL' in the inbox UI with a 500 or a delay (untick 'Destroy current session', or houston's inbox goes with it), then paste its URL into the integration or into Omnichannel → Webhooks with the host replaced by webhooks:${String(CONTAINER_PORT)} (the inbox UI says localhost; Rocket.Chat reaches it inside the workspace network).`,
|
|
158
|
+
capture === 'all'
|
|
159
|
+
? 'capture=all: every existing outgoing integration was repointed at the inbox; houston info lists the original URLs.'
|
|
160
|
+
: 'A restored customer backup still posts to its real endpoints: --set capture=all repoints every outgoing integration at the inbox.',
|
|
161
|
+
`From Rocket.Chat 9.0.0 integration scripts run as written (strict mode): one saved earlier keeps working until it is edited and saved again (${DOCS}).`,
|
|
162
|
+
'The inbox keeps the last 128 requests, on disk: a stop, start, restart, upgrade or rebuild keeps them; down --volumes removes them. An inbox idle for 31 days loses its session, and houston ready makes a new one.',
|
|
163
|
+
],
|
|
164
|
+
}),
|
|
165
|
+
],
|
|
166
|
+
notes: [
|
|
167
|
+
// No URL here on purpose: the receiver chooses the session, so the live inbox link is
|
|
168
|
+
// in the links row and the Webhooks card (`notes.inboxUrl`). A placeholder URL here
|
|
169
|
+
// would show `/s/<session>` and the GUI would turn it into a broken link.
|
|
170
|
+
`Webhook inbox: a page that lists every request Rocket.Chat sends, on port ${String(webPort)} on the machine running houston (no HTTPS path). The 'Webhook inbox' link in houston info and the GUI opens it; from elsewhere, ssh -L ${String(webPort)}:127.0.0.1:${String(webPort)} <host>, or --bind.`,
|
|
171
|
+
`Rocket.Chat posts to ${receiver}/<source> inside the workspace network: /outgoing ('${config.WEBHOOKS_OUTGOING}': Message Sent, all public channels), /omnichannel (the Omnichannel webhook, token '${config.WEBHOOKS_TOKEN}'; fires once Omnichannel is on, e.g. --preset livechat), /captured/<name> (capture=all).`,
|
|
172
|
+
`'${config.WEBHOOKS_INCOMING}' takes POSTs into #general as rocket.cat: houston info prints its URL and a curl once the workspace is ready.`,
|
|
173
|
+
capture === 'all'
|
|
174
|
+
? 'capture=all: every existing outgoing integration is repointed at the inbox; the originals are listed under Webhooks in houston info.'
|
|
175
|
+
: 'A restored dump still posts to its real endpoints: --set capture=all repoints every outgoing integration at the inbox.',
|
|
176
|
+
`The inbox answers 200 with {"captured": true}, which Rocket.Chat reads as success and posts nothing back. A failing or slow endpoint: 'New URL' in the inbox UI with a 500 or a delay (untick 'Destroy current session', or houston's inbox goes with it), then paste its URL into the integration (Admin → Workspace → Integrations) or Omnichannel → Webhooks with the host replaced by webhooks:${String(CONTAINER_PORT)} (the inbox UI says localhost; Rocket.Chat reaches it inside the workspace network).`,
|
|
177
|
+
'Last 128 requests, on disk: a stop, start, restart, upgrade or rebuild keeps them; down --volumes removes them. An inbox idle for 31 days loses its session, and houston ready makes a new one.',
|
|
178
|
+
`From Rocket.Chat 9.0.0 integration scripts run as written (strict mode): one saved earlier keeps working until it is edited and saved again (${DOCS}). Paste the customer's script into ${config.WEBHOOKS_OUTGOING} to test it.`,
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
(0, registry_1.register)('webhooks', build);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Credential redaction shared by services, with no houston dependencies.
|
|
4
|
+
*
|
|
5
|
+
* It is a LEAF on purpose: `events.ts` deliberately imports nothing from the package and is
|
|
6
|
+
* imported by thirteen modules, so redaction lives in its own dependency-free module.
|
|
7
|
+
* Importing orchestration here would create a startup import cycle. Its one import is
|
|
8
|
+
* `float-text`, a rank-0 leaf with no imports of its own, for its whitespace set.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.URL_USERINFO = exports.REDACTED = exports.SECRET_KEY_HINTS = void 0;
|
|
12
|
+
exports.redactIceServers = redactIceServers;
|
|
13
|
+
exports.redactEnv = redactEnv;
|
|
14
|
+
exports.redactArgv = redactArgv;
|
|
15
|
+
const float_text_1 = require("./float-text");
|
|
16
|
+
/**
|
|
17
|
+
* Key-name fragments that mean the VALUE is a credential.
|
|
18
|
+
*
|
|
19
|
+
* Substring matching rather than exact names, because the keys these have to catch are
|
|
20
|
+
* whatever a preset author or a customer's dump happened to call them.
|
|
21
|
+
*/
|
|
22
|
+
exports.SECRET_KEY_HINTS = Object.freeze([
|
|
23
|
+
'password',
|
|
24
|
+
'pass',
|
|
25
|
+
'secret',
|
|
26
|
+
'token',
|
|
27
|
+
'_key',
|
|
28
|
+
'apikey',
|
|
29
|
+
'credential',
|
|
30
|
+
// Not in earlier releases, which printed a licence wherever they printed env.
|
|
31
|
+
'rocketchat_license',
|
|
32
|
+
]);
|
|
33
|
+
exports.REDACTED = '********';
|
|
34
|
+
/**
|
|
35
|
+
* The whitespace of `STRIP_CHARS`, as the inside of a character class.
|
|
36
|
+
*
|
|
37
|
+
* NOT JavaScript's `\s`, which the pattern below used to be written with: JavaScript's
|
|
38
|
+
* holds the BOM and not the information separators `\x1c`-`\x1f` or NEL, and this set is
|
|
39
|
+
* the reverse. Inside `[^...]` that decides where a password ENDS, so a `MONGO_URL`
|
|
40
|
+
* password holding a BOM, which earlier releases masked, was printed in the clear by `env`
|
|
41
|
+
* and the env panel, and one holding `\x1c` or NEL the other way round.
|
|
42
|
+
* Built from `STRIP_CHARS` rather than typed, because a control character in a regex
|
|
43
|
+
* literal is `no-control-regex` however it is spelled.
|
|
44
|
+
*/
|
|
45
|
+
const SPACE_CLASS = [...float_text_1.STRIP_CHARS]
|
|
46
|
+
.map((char) => `\\u{${(char.codePointAt(0) ?? 0).toString(16)}}`)
|
|
47
|
+
.join('');
|
|
48
|
+
/**
|
|
49
|
+
* A credential embedded in a URL: `scheme://user:password@host`.
|
|
50
|
+
*
|
|
51
|
+
* This must inspect VALUES rather than names, because a name such as `MONGO_URL` reveals
|
|
52
|
+
* nothing about the secret inside it. Global, because every occurrence is replaced and a
|
|
53
|
+
* value can hold more than one URL.
|
|
54
|
+
*/
|
|
55
|
+
exports.URL_USERINFO = new RegExp(`([a-zA-Z][a-zA-Z0-9+.-]*://[^/${SPACE_CLASS}:@]+):([^/${SPACE_CLASS}@]+)@`, 'gu');
|
|
56
|
+
/**
|
|
57
|
+
* A credential in Rocket.Chat's Ice Servers form: `user:password@turn:host:port`, comma-separated.
|
|
58
|
+
*
|
|
59
|
+
* It has no `://`, so `URL_USERINFO` passed it through, and the voice preset puts a TURN
|
|
60
|
+
* server's password exactly there. Anchored on what follows the `@`, so a bare `rc:s3cret@mongo`,
|
|
61
|
+
* which earlier releases left readable, still is.
|
|
62
|
+
*/
|
|
63
|
+
const ICE_USERINFO = /(^|,\s*)([^,:@\s]+):([^,@\s]+)@(?=(?:stun|turns?):)/gu;
|
|
64
|
+
/** Mask the passwords in an Ice Servers list, or one entry of it. */
|
|
65
|
+
function redactIceServers(value) {
|
|
66
|
+
return value.replace(ICE_USERINFO, `$1$2:${exports.REDACTED}@`);
|
|
67
|
+
}
|
|
68
|
+
/** Mask credentials named by their key or embedded in URL or Ice Servers userinfo. */
|
|
69
|
+
function redactEnv(key, value) {
|
|
70
|
+
const low = key.toLowerCase();
|
|
71
|
+
if (value && exports.SECRET_KEY_HINTS.some((h) => low.includes(h)))
|
|
72
|
+
return exports.REDACTED;
|
|
73
|
+
return redactIceServers((value || '').replace(exports.URL_USERINFO, `$1:${exports.REDACTED}@`));
|
|
74
|
+
}
|
|
75
|
+
/** Flags whose whole value is a credential. */
|
|
76
|
+
const SECRET_FLAGS = ['--reg-token'];
|
|
77
|
+
/** Flags whose value is `KEY=VALUE`, masked by `redactEnv`'s rule for that key. */
|
|
78
|
+
const PAIR_FLAGS = ['--env', '-e', '--setting', '--set'];
|
|
79
|
+
function redactFlagValue(flag, value) {
|
|
80
|
+
if (SECRET_FLAGS.includes(flag))
|
|
81
|
+
return value ? exports.REDACTED : value;
|
|
82
|
+
if (!PAIR_FLAGS.includes(flag))
|
|
83
|
+
return value.replace(exports.URL_USERINFO, `$1:${exports.REDACTED}@`);
|
|
84
|
+
const eq = value.indexOf('=');
|
|
85
|
+
if (eq < 0)
|
|
86
|
+
return value.replace(exports.URL_USERINFO, `$1:${exports.REDACTED}@`);
|
|
87
|
+
return `${value.slice(0, eq + 1)}${redactEnv(value.slice(0, eq), value.slice(eq + 1))}`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A command line with its credentials masked, for the event log: `ps` is not the only
|
|
91
|
+
* reader of an argv, and the log outlives the process. Every spelling the parser accepts:
|
|
92
|
+
* `--flag value`, `--flag=value` and `-eKEY=VALUE`.
|
|
93
|
+
*/
|
|
94
|
+
function redactArgv(argv) {
|
|
95
|
+
return argv.map((token, i) => {
|
|
96
|
+
const previous = argv[i - 1] ?? '';
|
|
97
|
+
if (SECRET_FLAGS.includes(previous) || PAIR_FLAGS.includes(previous))
|
|
98
|
+
return redactFlagValue(previous, token);
|
|
99
|
+
const eq = token.indexOf('=');
|
|
100
|
+
if (token.startsWith('--') && eq > 0)
|
|
101
|
+
return `${token.slice(0, eq + 1)}${redactFlagValue(token.slice(0, eq), token.slice(eq + 1))}`;
|
|
102
|
+
if (token.startsWith('-e') && token.length > 2)
|
|
103
|
+
return `-e${redactFlagValue('-e', token.slice(2))}`;
|
|
104
|
+
return token.replace(exports.URL_USERINFO, `$1:${exports.REDACTED}@`);
|
|
105
|
+
});
|
|
106
|
+
}
|