Mercurial > prosody-modules
annotate mod_json_streams/strophe.jsonstreams.js @ 6082:1a6cd0bbb7ab
mod_compliance_2023: Add 2023 Version of the compliance module, basis is the 2021 Version.
diff --git a/mod_compliance_2023/README.md b/mod_compliance_2023/README.md
new file mode 100644
--- /dev/null
+++ b/mod_compliance_2023/README.md
@@ -0,0 +1,22 @@
+---
+summary: XMPP Compliance Suites 2023 self-test
+labels:
+- Stage-Beta
+rockspec:
+ dependencies:
+ - mod_cloud_notify
+
+...
+
+Compare the list of enabled modules with
+[XEP-0479: XMPP Compliance Suites 2023] and produce basic report to the
+Prosody log file.
+
+If installed with the Prosody plugin installer then all modules needed for a green checkmark should be included. (With prosody 0.12 only [mod_cloud_notify] is not included with prosody and we need the community module)
+
+# Compatibility
+
+ Prosody-Version Status
+ --------------- ----------------------
+ trunk Works as of 2024-12-21
+ 0.12 Works
diff --git a/mod_compliance_2023/mod_compliance_2023.lua b/mod_compliance_2023/mod_compliance_2023.lua
new file mode 100644
--- /dev/null
+++ b/mod_compliance_2023/mod_compliance_2023.lua
@@ -0,0 +1,79 @@
+-- Copyright (c) 2021 Kim Alvefur
+--
+-- This module is MIT licensed.
+
+local hostmanager = require "core.hostmanager";
+
+local array = require "util.array";
+local set = require "util.set";
+
+local modules_enabled = module:get_option_inherited_set("modules_enabled");
+
+for host in pairs(hostmanager.get_children(module.host)) do
+ local component = module:context(host):get_option_string("component_module");
+ if component then
+ modules_enabled:add(component);
+ modules_enabled:include(module:context(host):get_option_set("modules_enabled", {}));
+ end
+end
+
+local function check(suggested, alternate, ...)
+ if set.intersection(modules_enabled, set.new({suggested; alternate; ...})):empty() then return suggested; end
+ return false;
+end
+
+local compliance = {
+ array {"Server"; check("tls"); check("disco")};
+
+ array {"Advanced Server"; check("pep", "pep_simple")};
+
+ array {"Web"; check("bosh"); check("websocket")};
+
+ -- No Server requirements for Advanced Web
+
+ array {"IM"; check("vcard_legacy", "vcard"); check("carbons"); check("http_file_share", "http_upload")};
+
+ array {
+ "Advanced IM";
+ check("vcard_legacy", "vcard");
+ check("blocklist");
+ check("muc");
+ check("private");
+ check("smacks");
+ check("mam");
+ check("bookmarks");
+ };
+
+ array {"Mobile"; check("smacks"); check("csi_simple", "csi_battery_saver")};
+
+ array {"Advanced Mobile"; check("cloud_notify")};
+
+ array {"A/V Calling"; check("turn_external", "external_services", "turncredentials", "extdisco")};
+
+};
+
+function check_compliance()
+ local compliant = true;
+ for _, suite in ipairs(compliance) do
+ local section = suite:pop(1);
+ if module:get_option_boolean("compliance_" .. section:lower():gsub("%A", "_"), true) then
+ local missing = set.new(suite:filter(function(m) return type(m) == "string" end):map(function(m) return "mod_" .. m end));
+ if suite[1] then
+ if compliant then
+ compliant = false;
+ module:log("warn", "Missing some modules for XMPP Compliance 2023");
+ end
+ module:log("info", "%s Compliance: %s", section, missing);
+ end
+ end
+ end
+
+ if compliant then module:log("info", "XMPP Compliance 2023: Compliant ✔️"); end
+end
+
+if prosody.start_time then
+ check_compliance()
+else
+ module:hook_global("server-started", check_compliance);
+end
+
| author | Menel <menel@snikket.de> |
|---|---|
| date | Sun, 22 Dec 2024 16:06:28 +0100 |
| parents | 7dbde05b48a9 |
| children |
| rev | line source |
|---|---|
|
351
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 /* jsonstreams plugin |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 ** |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 ** This plugin upgrades Strophe to support XEP-0295: JSON Encodings for XMPP |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 ** |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 */ |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 Strophe.addConnectionPlugin('jsonstreams', { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 init: function (conn) { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 var parseXMLString = function(xmlStr) { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 var xmlDoc = null; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 if (window.ActiveXObject) { |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
352
diff
changeset
|
14 xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); |
|
351
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 xmlDoc.async=false; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 xmlDoc.loadXML(xmlStr); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 } else { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 var parser = new DOMParser(); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 xmlDoc = parser.parseFromString(xmlStr, "text/xml"); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 return xmlDoc; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 // replace Strophe.Request._newXHR with new jsonstreams version |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 // if JSON is detected |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 if (window.JSON) { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 var _newXHR = Strophe.Request.prototype._newXHR; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
28 Strophe.Request.prototype._newXHR = function () { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 var _xhr = _newXHR.apply(this, arguments); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 var xhr = { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
31 readyState: 0, |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 responseText: null, |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 responseXML: null, |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 status: null, |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
35 open: function(a, b, c) { return _xhr.open(a, b, c) }, |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 abort: function() { _xhr.abort(); }, |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 send: function(data) { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 data = JSON.stringify({"s":data}); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 return _xhr.send(data); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 }; |
|
352
0b4fe47e648d
mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
Waqas Hussain <waqas20@gmail.com>
parents:
351
diff
changeset
|
42 var req = this; |
|
0b4fe47e648d
mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
Waqas Hussain <waqas20@gmail.com>
parents:
351
diff
changeset
|
43 xhr.onreadystatechange = this.func.bind(null, this); |
|
351
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
44 _xhr.onreadystatechange = function() { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 xhr.readyState = _xhr.readyState; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 if (xhr.readyState != 4) { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 xhr.status = 0; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
48 xhr.responseText = ""; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
49 xhr.responseXML = null; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
50 } else { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
51 xhr.status = _xhr.status; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
52 xhr.responseText = _xhr.responseText; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
53 xhr.responseXML = _xhr.responseXML; |
|
352
0b4fe47e648d
mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
Waqas Hussain <waqas20@gmail.com>
parents:
351
diff
changeset
|
54 if (_xhr.responseText && !(_xhr.responseXML |
|
0b4fe47e648d
mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
Waqas Hussain <waqas20@gmail.com>
parents:
351
diff
changeset
|
55 && _xhr.responseXML.documentElement |
|
0b4fe47e648d
mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
Waqas Hussain <waqas20@gmail.com>
parents:
351
diff
changeset
|
56 && _xhr.responseXML.documentElement.tagName != "parsererror")) { |
|
351
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
57 var data = JSON.parse(_xhr.responseText); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
58 if (data && data.s) { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
59 xhr.responseText = data.s; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 xhr.responseXML = parseXMLString(data.s); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
61 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
62 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
63 } |
|
352
0b4fe47e648d
mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
Waqas Hussain <waqas20@gmail.com>
parents:
351
diff
changeset
|
64 if ("function" == typeof xhr.onreadystatechange) { xhr.onreadystatechange(req); } |
|
351
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
65 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
66 return xhr; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
67 }; |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
68 } else { |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
69 Strophe.error("jsonstreams plugin loaded, but JSON not found." + |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
70 " Falling back to native XHR implementation."); |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
71 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
72 } |
|
85d3c04c64f6
mod_json_streams/strophe.jsonstreams.js: A strophe.js plugin to make it work.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
73 }); |
