From 01159fa0d155c826557d046d816406c5f00b5e74 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 25 Apr 2023 16:52:57 +0100 Subject: [PATCH] Update yaml dependency (#728) * Update yaml dependency * changelog --- changelog.d/728.misc | 1 + config.sample.yml | 52 +++++++++++++++++++++--------------------- package.json | 2 +- src/Config/Defaults.ts | 11 ++++----- yarn.lock | 8 +++---- 5 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 changelog.d/728.misc diff --git a/changelog.d/728.misc b/changelog.d/728.misc new file mode 100644 index 00000000..2623cc30 --- /dev/null +++ b/changelog.d/728.misc @@ -0,0 +1 @@ +Update `yaml` dependency to `2.2.2` diff --git a/config.sample.yml b/config.sample.yml index 2cf86367..c2cab55b 100644 --- a/config.sample.yml +++ b/config.sample.yml @@ -2,7 +2,7 @@ bridge: # Basic homeserver configuration - # + domain: example.com url: http://localhost:8008 mediaUrl: https://example.com @@ -10,35 +10,35 @@ bridge: bindAddress: 127.0.0.1 github: # (Optional) Configure this to enable GitHub support - # + auth: # Authentication for the GitHub App. - # + id: 123 privateKeyFile: github-key.pem webhook: # Webhook settings for the GitHub app. - # + secret: secrettoken oauth: # (Optional) Settings for allowing users to sign in via OAuth. - # + client_id: foo client_secret: bar redirect_uri: https://example.com/bridge_oauth/ defaultOptions: # (Optional) Default options for GitHub connections. - # + showIssueRoomLink: false hotlinkIssues: prefix: "#" userIdPrefix: # (Optional) Prefix used when creating ghost users for GitHub accounts. - # + _github_ gitlab: # (Optional) Configure this to enable GitLab support - # + instances: gitlab.com: url: https://gitlab.com @@ -47,11 +47,11 @@ gitlab: publicUrl: https://example.com/hookshot/ userIdPrefix: # (Optional) Prefix used when creating ghost users for GitLab accounts. - # + _gitlab_ figma: # (Optional) Configure this to enable Figma support - # + publicUrl: https://example.com/hookshot/ instances: your-instance: @@ -60,22 +60,22 @@ figma: passcode: your-webhook-passcode jira: # (Optional) Configure this to enable Jira support. Only specify `url` if you are using a On Premise install (i.e. not atlassian.com) - # + webhook: # Webhook settings for JIRA - # + secret: secrettoken oauth: # (Optional) OAuth settings for connecting users to JIRA. See documentation for more information - # + client_id: foo client_secret: bar redirect_uri: https://example.com/bridge_oauth/ generic: # (Optional) Support for generic webhook events. #'allowJsTransformationFunctions' will allow users to write short transformation snippets in code, and thus is unsafe in untrusted environments - # - # + + enabled: false enableHttpGet: false urlPrefix: https://example.com/webhook/ @@ -84,27 +84,27 @@ generic: waitForComplete: false feeds: # (Optional) Configure this to enable RSS/Atom feed support - # + enabled: false pollIntervalSeconds: 600 pollTimeoutSeconds: 30 provisioning: # (Optional) Provisioning API for integration managers - # + secret: "!secretToken" passFile: # A passkey used to encrypt tokens stored inside the bridge. # Run openssl genpkey -out passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:4096 to generate - # + passkey.pem bot: # (Optional) Define profile information for the bot user - # + displayname: Hookshot Bot avatar: mxc://half-shot.uk/2876e89ccade4cb615e210c458e2a7a6883fe17d serviceBots: # (Optional) Define additional bot users for specific services - # + - localpart: feeds displayname: Feeds avatar: mxc://half-shot.uk/2876e89ccade4cb615e210c458e2a7a6883fe17d @@ -112,25 +112,25 @@ serviceBots: service: feeds metrics: # (Optional) Prometheus metrics support - # + enabled: true queue: # (Optional) Message queue / cache configuration options for large scale deployments. # For encryption to work, must be set to monolithic mode and have a host & port specified. - # + monolithic: true port: 6379 host: localhost logging: # (Optional) Logging settings. You can have a severity debug,info,warn,error - # + level: info colorize: true json: false timestampFormat: HH:mm:ss:SSS widgets: # (Optional) EXPERIMENTAL support for complimentary widgets - # + addToAdminRooms: false disallowedIpRanges: - 127.0.0.0/8 @@ -159,7 +159,7 @@ widgets: widgetTitle: Hookshot Configuration permissions: # (Optional) Permissions for using the bridge. See docs/setup.md#permissions for help - # + - actor: example.com services: - service: "*" @@ -170,7 +170,7 @@ listeners: # 'port' must be specified. Each listener must listen on a unique port. # 'bindAddress' will default to '127.0.0.1' if not specified, which may not be suited to Docker environments. # 'resources' may be any of webhooks, widgets, metrics, provisioning - # + - port: 9000 bindAddress: 0.0.0.0 resources: diff --git a/package.json b/package.json index 91052d0a..f4768c38 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "vm2": "^3.9.17", "winston": "^3.3.3", "xml2js": "^0.5.0", - "yaml": "^1.10.2" + "yaml": "^2.2.2" }, "devDependencies": { "@codemirror/lang-javascript": "^6.0.2", diff --git a/src/Config/Defaults.ts b/src/Config/Defaults.ts index 5e166f31..6ad266ac 100644 --- a/src/Config/Defaults.ts +++ b/src/Config/Defaults.ts @@ -1,7 +1,6 @@ import { BridgeConfig, BridgeConfigRoot } from "./Config"; -import YAML from "yaml"; import { getConfigKeyMetadata, keyIsHidden } from "./Decorators"; -import { Node, YAMLSeq } from "yaml/types"; +import { Node, YAMLSeq, default as YAML } from "yaml"; import { randomBytes } from "crypto"; import { DefaultDisallowedIpRanges } from "matrix-appservice-bridge"; @@ -164,15 +163,15 @@ function renderSection(doc: YAML.Document, obj: Record, parentN let newNode: Node; if (typeof value === "object" && !Array.isArray(value)) { - newNode = YAML.createNode({}); + newNode = doc.createNode({}); renderSection(doc, value as Record, newNode as YAMLSeq); } else if (typeof value === "function") { if (value.length !== 0) { throw Error("Only zero-argument functions are allowed as config values"); } - newNode = YAML.createNode(value()); + newNode = doc.createNode(value()); } else { - newNode = YAML.createNode(value); + newNode = doc.createNode(value); } const metadata = getConfigKeyMetadata(obj, key); @@ -190,7 +189,7 @@ function renderSection(doc: YAML.Document, obj: Record, parentN function renderDefaultConfig() { const doc = new YAML.Document(); - doc.contents = YAML.createNode({}); + doc.contents = doc.createNode({}); doc.commentBefore = ' This is an example configuration file'; // Needed because the entries syntax below would not work otherwise renderSection(doc, DefaultConfig as unknown as Record); diff --git a/yarn.lock b/yarn.lock index 66c67525..96a961db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6243,10 +6243,10 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml@^1.10.2: - version "1.10.2" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== +yaml@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.2.tgz#ec551ef37326e6d42872dad1970300f8eb83a073" + integrity sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA== yargs-parser@20.2.4: version "20.2.4"