Compare commits
No commits in common. "76caaa146861105ab42fd1942afbd911adf14820" and "f35c5266b6f7b6e3307c4674e95b5b9b456c0ebd" have entirely different histories.
76caaa1468
...
f35c5266b6
4 changed files with 30 additions and 6 deletions
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -27,6 +27,7 @@
|
||||||
"get-stream": "^6.0.1",
|
"get-stream": "^6.0.1",
|
||||||
"h3": "^1.12.0",
|
"h3": "^1.12.0",
|
||||||
"heatsync": "^2.5.3",
|
"heatsync": "^2.5.3",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"node-fetch": "^2.6.7",
|
"node-fetch": "^2.6.7",
|
||||||
"prettier-bytes": "^1.0.4",
|
"prettier-bytes": "^1.0.4",
|
||||||
|
@ -1016,6 +1017,11 @@
|
||||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/argparse": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||||
|
},
|
||||||
"node_modules/as-table": {
|
"node_modules/as-table": {
|
||||||
"version": "1.0.55",
|
"version": "1.0.55",
|
||||||
"resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz",
|
"resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz",
|
||||||
|
@ -1925,6 +1931,17 @@
|
||||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/js-yaml": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": "^2.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"js-yaml": "bin/js-yaml.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/just-kebab-case": {
|
"node_modules/just-kebab-case": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/just-kebab-case/-/just-kebab-case-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/just-kebab-case/-/just-kebab-case-4.2.0.tgz",
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
"get-stream": "^6.0.1",
|
"get-stream": "^6.0.1",
|
||||||
"h3": "^1.12.0",
|
"h3": "^1.12.0",
|
||||||
"heatsync": "^2.5.3",
|
"heatsync": "^2.5.3",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"node-fetch": "^2.6.7",
|
"node-fetch": "^2.6.7",
|
||||||
"prettier-bytes": "^1.0.4",
|
"prettier-bytes": "^1.0.4",
|
||||||
|
|
|
@ -87,9 +87,6 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) {
|
||||||
if (res.status !== 200) return `There is no Matrix server at that URL (${url}/_matrix/client/versions returned ${res.status})`
|
if (res.status !== 200) return `There is no Matrix server at that URL (${url}/_matrix/client/versions returned ${res.status})`
|
||||||
try {
|
try {
|
||||||
var json = await res.json()
|
var json = await res.json()
|
||||||
if (!Array.isArray(json?.versions) || !json.versions.includes("v1.11")) {
|
|
||||||
return `OOYE needs Matrix version v1.11, but ${url} doesn't support this`
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return `There is no Matrix server at that URL (${url}/_matrix/client/versions is not JSON)`
|
return `There is no Matrix server at that URL (${url}/_matrix/client/versions is not JSON)`
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ const fs = require("fs")
|
||||||
const crypto = require("crypto")
|
const crypto = require("crypto")
|
||||||
const assert = require("assert").strict
|
const assert = require("assert").strict
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
|
const yaml = require("js-yaml")
|
||||||
|
|
||||||
const registrationFilePath = path.join(process.cwd(), "registration.yaml")
|
const registrationFilePath = path.join(process.cwd(), "registration.yaml")
|
||||||
|
|
||||||
|
@ -59,10 +60,18 @@ function getTemplateRegistration() {
|
||||||
function readRegistration() {
|
function readRegistration() {
|
||||||
/** @type {import("../types").AppServiceRegistrationConfig} */ // @ts-ignore
|
/** @type {import("../types").AppServiceRegistrationConfig} */ // @ts-ignore
|
||||||
let result = null
|
let result = null
|
||||||
try {
|
if (fs.existsSync(registrationFilePath)) {
|
||||||
const content = fs.readFileSync(registrationFilePath, "utf8")
|
const content = fs.readFileSync(registrationFilePath, "utf8")
|
||||||
result = JSON.parse(content)
|
if (content.startsWith("{")) { // Use JSON parser
|
||||||
} catch (e) {}
|
result = JSON.parse(content)
|
||||||
|
checkRegistration(result)
|
||||||
|
} else { // Use YAML parser
|
||||||
|
result = yaml.load(content)
|
||||||
|
checkRegistration(result)
|
||||||
|
// Convert to JSON
|
||||||
|
writeRegistration(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue