@sockethub/schemas 3.0.0-alpha.10 → 3.0.0-alpha.12
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/dist/context.js +101 -0
- package/dist/context.js.map +10 -0
- package/dist/contexts/platform/dummy/v1.jsonld +8 -0
- package/dist/contexts/platform/error/v1.jsonld +8 -0
- package/dist/contexts/platform/feeds/v1.jsonld +8 -0
- package/dist/contexts/platform/irc/v1.jsonld +8 -0
- package/dist/contexts/platform/metadata/v1.jsonld +8 -0
- package/dist/contexts/platform/sockethub%3Ainternal/v1.jsonld +8 -0
- package/dist/contexts/platform/xmpp/v1.jsonld +8 -0
- package/dist/contexts/v1.jsonld +7 -0
- package/dist/index.js +533 -796
- package/dist/index.js.map +10 -15
- package/dist/maps/context-map.json +35 -0
- package/dist/schemas/platform/dummy/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/dummy/v1/messages.schema.json +22 -0
- package/dist/schemas/platform/error/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/error/v1/messages.schema.json +1 -0
- package/dist/schemas/platform/feeds/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/feeds/v1/messages.schema.json +36 -0
- package/dist/schemas/platform/irc/v1/credentials.schema.json +48 -0
- package/dist/schemas/platform/irc/v1/messages.schema.json +19 -0
- package/dist/schemas/platform/metadata/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/metadata/v1/messages.schema.json +29 -0
- package/dist/schemas/platform/sockethub%3Ainternal/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/sockethub%3Ainternal/v1/messages.schema.json +1 -0
- package/dist/schemas/platform/xmpp/v1/credentials.schema.json +43 -0
- package/dist/schemas/platform/xmpp/v1/messages.schema.json +21 -0
- package/package.json +15 -8
- package/src/context.ts +125 -0
- package/src/helpers/error-parser.ts +65 -18
- package/src/helpers/objects.ts +59 -3
- package/src/index.test.data.credentials.ts +37 -5
- package/src/index.test.data.platform.ts +3 -0
- package/src/index.test.data.streams.ts +117 -25
- package/src/index.test.ts +31 -3
- package/src/index.ts +30 -1
- package/src/schemas/activity-stream.ts +30 -9
- package/src/schemas/json/activity-object.json +50 -1
- package/src/schemas/json/activity-stream.json +77 -44
- package/src/schemas/json/platform.json +22 -2
- package/src/schemas/json/sockethub-config.json +120 -28
- package/src/schemas/platform.ts +25 -1
- package/src/schemas/sockethub-config.ts +94 -14
- package/src/types/ajv-formats-draft2019.d.ts +5 -0
- package/src/types.ts +29 -12
- package/src/validator.ts +138 -25
package/dist/index.js
CHANGED
|
@@ -4,15 +4,29 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
@@ -9384,10 +9398,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
9384
9398
|
}
|
|
9385
9399
|
return output;
|
|
9386
9400
|
}
|
|
9387
|
-
var ucs2encode = function
|
|
9401
|
+
var ucs2encode = function ucs2encode2(array) {
|
|
9388
9402
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
9389
9403
|
};
|
|
9390
|
-
var basicToDigit = function
|
|
9404
|
+
var basicToDigit = function basicToDigit2(codePoint) {
|
|
9391
9405
|
if (codePoint - 48 < 10) {
|
|
9392
9406
|
return codePoint - 22;
|
|
9393
9407
|
}
|
|
@@ -9399,10 +9413,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
9399
9413
|
}
|
|
9400
9414
|
return base;
|
|
9401
9415
|
};
|
|
9402
|
-
var digitToBasic = function
|
|
9416
|
+
var digitToBasic = function digitToBasic2(digit, flag) {
|
|
9403
9417
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
9404
9418
|
};
|
|
9405
|
-
var adapt = function
|
|
9419
|
+
var adapt = function adapt2(delta, numPoints, firstTime) {
|
|
9406
9420
|
var k = 0;
|
|
9407
9421
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
9408
9422
|
delta += floor(delta / numPoints);
|
|
@@ -9411,7 +9425,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
9411
9425
|
}
|
|
9412
9426
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
9413
9427
|
};
|
|
9414
|
-
var decode = function
|
|
9428
|
+
var decode = function decode2(input) {
|
|
9415
9429
|
var output = [];
|
|
9416
9430
|
var inputLength = input.length;
|
|
9417
9431
|
var i = 0;
|
|
@@ -9459,7 +9473,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
9459
9473
|
}
|
|
9460
9474
|
return String.fromCodePoint.apply(String, output);
|
|
9461
9475
|
};
|
|
9462
|
-
var encode = function
|
|
9476
|
+
var encode = function encode2(input) {
|
|
9463
9477
|
var output = [];
|
|
9464
9478
|
input = ucs2decode(input);
|
|
9465
9479
|
var inputLength = input.length;
|
|
@@ -9573,12 +9587,12 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
9573
9587
|
}
|
|
9574
9588
|
return output.join("");
|
|
9575
9589
|
};
|
|
9576
|
-
var toUnicode = function
|
|
9590
|
+
var toUnicode = function toUnicode2(input) {
|
|
9577
9591
|
return mapDomain(input, function(string) {
|
|
9578
9592
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
9579
9593
|
});
|
|
9580
9594
|
};
|
|
9581
|
-
var toASCII = function
|
|
9595
|
+
var toASCII = function toASCII2(input) {
|
|
9582
9596
|
return mapDomain(input, function(string) {
|
|
9583
9597
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
9584
9598
|
});
|
|
@@ -9975,13 +9989,13 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
9975
9989
|
var handler = {
|
|
9976
9990
|
scheme: "http",
|
|
9977
9991
|
domainHost: true,
|
|
9978
|
-
parse: function
|
|
9992
|
+
parse: function parse2(components, options) {
|
|
9979
9993
|
if (!components.host) {
|
|
9980
9994
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
9981
9995
|
}
|
|
9982
9996
|
return components;
|
|
9983
9997
|
},
|
|
9984
|
-
serialize: function
|
|
9998
|
+
serialize: function serialize2(components, options) {
|
|
9985
9999
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
9986
10000
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
9987
10001
|
components.port = undefined;
|
|
@@ -10004,7 +10018,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
10004
10018
|
var handler$2 = {
|
|
10005
10019
|
scheme: "ws",
|
|
10006
10020
|
domainHost: true,
|
|
10007
|
-
parse: function
|
|
10021
|
+
parse: function parse2(components, options) {
|
|
10008
10022
|
var wsComponents = components;
|
|
10009
10023
|
wsComponents.secure = isSecure(wsComponents);
|
|
10010
10024
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -10012,7 +10026,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
10012
10026
|
wsComponents.query = undefined;
|
|
10013
10027
|
return wsComponents;
|
|
10014
10028
|
},
|
|
10015
|
-
serialize: function
|
|
10029
|
+
serialize: function serialize2(wsComponents, options) {
|
|
10016
10030
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
10017
10031
|
wsComponents.port = undefined;
|
|
10018
10032
|
}
|
|
@@ -10180,7 +10194,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
10180
10194
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
10181
10195
|
var handler$6 = {
|
|
10182
10196
|
scheme: "urn:uuid",
|
|
10183
|
-
parse: function
|
|
10197
|
+
parse: function parse2(urnComponents, options) {
|
|
10184
10198
|
var uuidComponents = urnComponents;
|
|
10185
10199
|
uuidComponents.uuid = uuidComponents.nss;
|
|
10186
10200
|
uuidComponents.nss = undefined;
|
|
@@ -10189,7 +10203,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
10189
10203
|
}
|
|
10190
10204
|
return uuidComponents;
|
|
10191
10205
|
},
|
|
10192
|
-
serialize: function
|
|
10206
|
+
serialize: function serialize2(uuidComponents, options) {
|
|
10193
10207
|
var urnComponents = uuidComponents;
|
|
10194
10208
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
10195
10209
|
return urnComponents;
|
|
@@ -13527,13 +13541,13 @@ var require_extend = __commonJS((exports, module) => {
|
|
|
13527
13541
|
var toStr = Object.prototype.toString;
|
|
13528
13542
|
var defineProperty = Object.defineProperty;
|
|
13529
13543
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
13530
|
-
var isArray = function
|
|
13544
|
+
var isArray = function isArray2(arr) {
|
|
13531
13545
|
if (typeof Array.isArray === "function") {
|
|
13532
13546
|
return Array.isArray(arr);
|
|
13533
13547
|
}
|
|
13534
13548
|
return toStr.call(arr) === "[object Array]";
|
|
13535
13549
|
};
|
|
13536
|
-
var isPlainObject = function
|
|
13550
|
+
var isPlainObject = function isPlainObject2(obj) {
|
|
13537
13551
|
if (!obj || toStr.call(obj) !== "[object Object]") {
|
|
13538
13552
|
return false;
|
|
13539
13553
|
}
|
|
@@ -13546,7 +13560,7 @@ var require_extend = __commonJS((exports, module) => {
|
|
|
13546
13560
|
for (key in obj) {}
|
|
13547
13561
|
return typeof key === "undefined" || hasOwn.call(obj, key);
|
|
13548
13562
|
};
|
|
13549
|
-
var setProperty = function
|
|
13563
|
+
var setProperty = function setProperty2(target, options) {
|
|
13550
13564
|
if (defineProperty && options.name === "__proto__") {
|
|
13551
13565
|
defineProperty(target, options.name, {
|
|
13552
13566
|
enumerable: true,
|
|
@@ -13558,7 +13572,7 @@ var require_extend = __commonJS((exports, module) => {
|
|
|
13558
13572
|
target[options.name] = options.newValue;
|
|
13559
13573
|
}
|
|
13560
13574
|
};
|
|
13561
|
-
var getProperty = function
|
|
13575
|
+
var getProperty = function getProperty2(obj, name) {
|
|
13562
13576
|
if (name === "__proto__") {
|
|
13563
13577
|
if (!hasOwn.call(obj, name)) {
|
|
13564
13578
|
return;
|
|
@@ -15735,751 +15749,55 @@ var require_ajv_formats_draft2019 = __commonJS((exports, module) => {
|
|
|
15735
15749
|
};
|
|
15736
15750
|
});
|
|
15737
15751
|
|
|
15738
|
-
//
|
|
15739
|
-
var
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
15755
|
-
};
|
|
15756
|
-
function parse(str) {
|
|
15757
|
-
str = String(str);
|
|
15758
|
-
if (str.length > 100) {
|
|
15759
|
-
return;
|
|
15760
|
-
}
|
|
15761
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
15762
|
-
if (!match) {
|
|
15763
|
-
return;
|
|
15764
|
-
}
|
|
15765
|
-
var n = parseFloat(match[1]);
|
|
15766
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
15767
|
-
switch (type) {
|
|
15768
|
-
case "years":
|
|
15769
|
-
case "year":
|
|
15770
|
-
case "yrs":
|
|
15771
|
-
case "yr":
|
|
15772
|
-
case "y":
|
|
15773
|
-
return n * y;
|
|
15774
|
-
case "weeks":
|
|
15775
|
-
case "week":
|
|
15776
|
-
case "w":
|
|
15777
|
-
return n * w;
|
|
15778
|
-
case "days":
|
|
15779
|
-
case "day":
|
|
15780
|
-
case "d":
|
|
15781
|
-
return n * d;
|
|
15782
|
-
case "hours":
|
|
15783
|
-
case "hour":
|
|
15784
|
-
case "hrs":
|
|
15785
|
-
case "hr":
|
|
15786
|
-
case "h":
|
|
15787
|
-
return n * h;
|
|
15788
|
-
case "minutes":
|
|
15789
|
-
case "minute":
|
|
15790
|
-
case "mins":
|
|
15791
|
-
case "min":
|
|
15792
|
-
case "m":
|
|
15793
|
-
return n * m;
|
|
15794
|
-
case "seconds":
|
|
15795
|
-
case "second":
|
|
15796
|
-
case "secs":
|
|
15797
|
-
case "sec":
|
|
15798
|
-
case "s":
|
|
15799
|
-
return n * s;
|
|
15800
|
-
case "milliseconds":
|
|
15801
|
-
case "millisecond":
|
|
15802
|
-
case "msecs":
|
|
15803
|
-
case "msec":
|
|
15804
|
-
case "ms":
|
|
15805
|
-
return n;
|
|
15806
|
-
default:
|
|
15807
|
-
return;
|
|
15808
|
-
}
|
|
15809
|
-
}
|
|
15810
|
-
function fmtShort(ms) {
|
|
15811
|
-
var msAbs = Math.abs(ms);
|
|
15812
|
-
if (msAbs >= d) {
|
|
15813
|
-
return Math.round(ms / d) + "d";
|
|
15814
|
-
}
|
|
15815
|
-
if (msAbs >= h) {
|
|
15816
|
-
return Math.round(ms / h) + "h";
|
|
15817
|
-
}
|
|
15818
|
-
if (msAbs >= m) {
|
|
15819
|
-
return Math.round(ms / m) + "m";
|
|
15820
|
-
}
|
|
15821
|
-
if (msAbs >= s) {
|
|
15822
|
-
return Math.round(ms / s) + "s";
|
|
15823
|
-
}
|
|
15824
|
-
return ms + "ms";
|
|
15825
|
-
}
|
|
15826
|
-
function fmtLong(ms) {
|
|
15827
|
-
var msAbs = Math.abs(ms);
|
|
15828
|
-
if (msAbs >= d) {
|
|
15829
|
-
return plural(ms, msAbs, d, "day");
|
|
15830
|
-
}
|
|
15831
|
-
if (msAbs >= h) {
|
|
15832
|
-
return plural(ms, msAbs, h, "hour");
|
|
15833
|
-
}
|
|
15834
|
-
if (msAbs >= m) {
|
|
15835
|
-
return plural(ms, msAbs, m, "minute");
|
|
15836
|
-
}
|
|
15837
|
-
if (msAbs >= s) {
|
|
15838
|
-
return plural(ms, msAbs, s, "second");
|
|
15839
|
-
}
|
|
15840
|
-
return ms + " ms";
|
|
15841
|
-
}
|
|
15842
|
-
function plural(ms, msAbs, n, name) {
|
|
15843
|
-
var isPlural = msAbs >= n * 1.5;
|
|
15844
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
15845
|
-
}
|
|
15846
|
-
});
|
|
15847
|
-
|
|
15848
|
-
// ../../node_modules/debug/src/common.js
|
|
15849
|
-
var require_common = __commonJS((exports, module) => {
|
|
15850
|
-
function setup(env) {
|
|
15851
|
-
createDebug.debug = createDebug;
|
|
15852
|
-
createDebug.default = createDebug;
|
|
15853
|
-
createDebug.coerce = coerce;
|
|
15854
|
-
createDebug.disable = disable;
|
|
15855
|
-
createDebug.enable = enable;
|
|
15856
|
-
createDebug.enabled = enabled;
|
|
15857
|
-
createDebug.humanize = require_ms();
|
|
15858
|
-
createDebug.destroy = destroy;
|
|
15859
|
-
Object.keys(env).forEach((key) => {
|
|
15860
|
-
createDebug[key] = env[key];
|
|
15861
|
-
});
|
|
15862
|
-
createDebug.names = [];
|
|
15863
|
-
createDebug.skips = [];
|
|
15864
|
-
createDebug.formatters = {};
|
|
15865
|
-
function selectColor(namespace) {
|
|
15866
|
-
let hash = 0;
|
|
15867
|
-
for (let i = 0;i < namespace.length; i++) {
|
|
15868
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
15869
|
-
hash |= 0;
|
|
15870
|
-
}
|
|
15871
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
15872
|
-
}
|
|
15873
|
-
createDebug.selectColor = selectColor;
|
|
15874
|
-
function createDebug(namespace) {
|
|
15875
|
-
let prevTime;
|
|
15876
|
-
let enableOverride = null;
|
|
15877
|
-
let namespacesCache;
|
|
15878
|
-
let enabledCache;
|
|
15879
|
-
function debug(...args) {
|
|
15880
|
-
if (!debug.enabled) {
|
|
15881
|
-
return;
|
|
15882
|
-
}
|
|
15883
|
-
const self = debug;
|
|
15884
|
-
const curr = Number(new Date);
|
|
15885
|
-
const ms = curr - (prevTime || curr);
|
|
15886
|
-
self.diff = ms;
|
|
15887
|
-
self.prev = prevTime;
|
|
15888
|
-
self.curr = curr;
|
|
15889
|
-
prevTime = curr;
|
|
15890
|
-
args[0] = createDebug.coerce(args[0]);
|
|
15891
|
-
if (typeof args[0] !== "string") {
|
|
15892
|
-
args.unshift("%O");
|
|
15893
|
-
}
|
|
15894
|
-
let index = 0;
|
|
15895
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
15896
|
-
if (match === "%%") {
|
|
15897
|
-
return "%";
|
|
15898
|
-
}
|
|
15899
|
-
index++;
|
|
15900
|
-
const formatter = createDebug.formatters[format];
|
|
15901
|
-
if (typeof formatter === "function") {
|
|
15902
|
-
const val = args[index];
|
|
15903
|
-
match = formatter.call(self, val);
|
|
15904
|
-
args.splice(index, 1);
|
|
15905
|
-
index--;
|
|
15906
|
-
}
|
|
15907
|
-
return match;
|
|
15908
|
-
});
|
|
15909
|
-
createDebug.formatArgs.call(self, args);
|
|
15910
|
-
const logFn = self.log || createDebug.log;
|
|
15911
|
-
logFn.apply(self, args);
|
|
15912
|
-
}
|
|
15913
|
-
debug.namespace = namespace;
|
|
15914
|
-
debug.useColors = createDebug.useColors();
|
|
15915
|
-
debug.color = createDebug.selectColor(namespace);
|
|
15916
|
-
debug.extend = extend;
|
|
15917
|
-
debug.destroy = createDebug.destroy;
|
|
15918
|
-
Object.defineProperty(debug, "enabled", {
|
|
15919
|
-
enumerable: true,
|
|
15920
|
-
configurable: false,
|
|
15921
|
-
get: () => {
|
|
15922
|
-
if (enableOverride !== null) {
|
|
15923
|
-
return enableOverride;
|
|
15924
|
-
}
|
|
15925
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
15926
|
-
namespacesCache = createDebug.namespaces;
|
|
15927
|
-
enabledCache = createDebug.enabled(namespace);
|
|
15928
|
-
}
|
|
15929
|
-
return enabledCache;
|
|
15930
|
-
},
|
|
15931
|
-
set: (v) => {
|
|
15932
|
-
enableOverride = v;
|
|
15933
|
-
}
|
|
15934
|
-
});
|
|
15935
|
-
if (typeof createDebug.init === "function") {
|
|
15936
|
-
createDebug.init(debug);
|
|
15937
|
-
}
|
|
15938
|
-
return debug;
|
|
15939
|
-
}
|
|
15940
|
-
function extend(namespace, delimiter) {
|
|
15941
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
15942
|
-
newDebug.log = this.log;
|
|
15943
|
-
return newDebug;
|
|
15944
|
-
}
|
|
15945
|
-
function enable(namespaces) {
|
|
15946
|
-
createDebug.save(namespaces);
|
|
15947
|
-
createDebug.namespaces = namespaces;
|
|
15948
|
-
createDebug.names = [];
|
|
15949
|
-
createDebug.skips = [];
|
|
15950
|
-
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
15951
|
-
for (const ns of split) {
|
|
15952
|
-
if (ns[0] === "-") {
|
|
15953
|
-
createDebug.skips.push(ns.slice(1));
|
|
15954
|
-
} else {
|
|
15955
|
-
createDebug.names.push(ns);
|
|
15956
|
-
}
|
|
15957
|
-
}
|
|
15958
|
-
}
|
|
15959
|
-
function matchesTemplate(search, template) {
|
|
15960
|
-
let searchIndex = 0;
|
|
15961
|
-
let templateIndex = 0;
|
|
15962
|
-
let starIndex = -1;
|
|
15963
|
-
let matchIndex = 0;
|
|
15964
|
-
while (searchIndex < search.length) {
|
|
15965
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
15966
|
-
if (template[templateIndex] === "*") {
|
|
15967
|
-
starIndex = templateIndex;
|
|
15968
|
-
matchIndex = searchIndex;
|
|
15969
|
-
templateIndex++;
|
|
15970
|
-
} else {
|
|
15971
|
-
searchIndex++;
|
|
15972
|
-
templateIndex++;
|
|
15973
|
-
}
|
|
15974
|
-
} else if (starIndex !== -1) {
|
|
15975
|
-
templateIndex = starIndex + 1;
|
|
15976
|
-
matchIndex++;
|
|
15977
|
-
searchIndex = matchIndex;
|
|
15978
|
-
} else {
|
|
15979
|
-
return false;
|
|
15980
|
-
}
|
|
15981
|
-
}
|
|
15982
|
-
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
15983
|
-
templateIndex++;
|
|
15984
|
-
}
|
|
15985
|
-
return templateIndex === template.length;
|
|
15986
|
-
}
|
|
15987
|
-
function disable() {
|
|
15988
|
-
const namespaces = [
|
|
15989
|
-
...createDebug.names,
|
|
15990
|
-
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
15991
|
-
].join(",");
|
|
15992
|
-
createDebug.enable("");
|
|
15993
|
-
return namespaces;
|
|
15994
|
-
}
|
|
15995
|
-
function enabled(name) {
|
|
15996
|
-
for (const skip of createDebug.skips) {
|
|
15997
|
-
if (matchesTemplate(name, skip)) {
|
|
15998
|
-
return false;
|
|
15999
|
-
}
|
|
16000
|
-
}
|
|
16001
|
-
for (const ns of createDebug.names) {
|
|
16002
|
-
if (matchesTemplate(name, ns)) {
|
|
16003
|
-
return true;
|
|
16004
|
-
}
|
|
16005
|
-
}
|
|
16006
|
-
return false;
|
|
16007
|
-
}
|
|
16008
|
-
function coerce(val) {
|
|
16009
|
-
if (val instanceof Error) {
|
|
16010
|
-
return val.stack || val.message;
|
|
16011
|
-
}
|
|
16012
|
-
return val;
|
|
16013
|
-
}
|
|
16014
|
-
function destroy() {
|
|
16015
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
16016
|
-
}
|
|
16017
|
-
createDebug.enable(createDebug.load());
|
|
16018
|
-
return createDebug;
|
|
16019
|
-
}
|
|
16020
|
-
module.exports = setup;
|
|
16021
|
-
});
|
|
16022
|
-
|
|
16023
|
-
// ../../node_modules/debug/src/browser.js
|
|
16024
|
-
var require_browser = __commonJS((exports, module) => {
|
|
16025
|
-
exports.formatArgs = formatArgs;
|
|
16026
|
-
exports.save = save;
|
|
16027
|
-
exports.load = load;
|
|
16028
|
-
exports.useColors = useColors;
|
|
16029
|
-
exports.storage = localstorage();
|
|
16030
|
-
exports.destroy = (() => {
|
|
16031
|
-
let warned = false;
|
|
16032
|
-
return () => {
|
|
16033
|
-
if (!warned) {
|
|
16034
|
-
warned = true;
|
|
16035
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
16036
|
-
}
|
|
16037
|
-
};
|
|
16038
|
-
})();
|
|
16039
|
-
exports.colors = [
|
|
16040
|
-
"#0000CC",
|
|
16041
|
-
"#0000FF",
|
|
16042
|
-
"#0033CC",
|
|
16043
|
-
"#0033FF",
|
|
16044
|
-
"#0066CC",
|
|
16045
|
-
"#0066FF",
|
|
16046
|
-
"#0099CC",
|
|
16047
|
-
"#0099FF",
|
|
16048
|
-
"#00CC00",
|
|
16049
|
-
"#00CC33",
|
|
16050
|
-
"#00CC66",
|
|
16051
|
-
"#00CC99",
|
|
16052
|
-
"#00CCCC",
|
|
16053
|
-
"#00CCFF",
|
|
16054
|
-
"#3300CC",
|
|
16055
|
-
"#3300FF",
|
|
16056
|
-
"#3333CC",
|
|
16057
|
-
"#3333FF",
|
|
16058
|
-
"#3366CC",
|
|
16059
|
-
"#3366FF",
|
|
16060
|
-
"#3399CC",
|
|
16061
|
-
"#3399FF",
|
|
16062
|
-
"#33CC00",
|
|
16063
|
-
"#33CC33",
|
|
16064
|
-
"#33CC66",
|
|
16065
|
-
"#33CC99",
|
|
16066
|
-
"#33CCCC",
|
|
16067
|
-
"#33CCFF",
|
|
16068
|
-
"#6600CC",
|
|
16069
|
-
"#6600FF",
|
|
16070
|
-
"#6633CC",
|
|
16071
|
-
"#6633FF",
|
|
16072
|
-
"#66CC00",
|
|
16073
|
-
"#66CC33",
|
|
16074
|
-
"#9900CC",
|
|
16075
|
-
"#9900FF",
|
|
16076
|
-
"#9933CC",
|
|
16077
|
-
"#9933FF",
|
|
16078
|
-
"#99CC00",
|
|
16079
|
-
"#99CC33",
|
|
16080
|
-
"#CC0000",
|
|
16081
|
-
"#CC0033",
|
|
16082
|
-
"#CC0066",
|
|
16083
|
-
"#CC0099",
|
|
16084
|
-
"#CC00CC",
|
|
16085
|
-
"#CC00FF",
|
|
16086
|
-
"#CC3300",
|
|
16087
|
-
"#CC3333",
|
|
16088
|
-
"#CC3366",
|
|
16089
|
-
"#CC3399",
|
|
16090
|
-
"#CC33CC",
|
|
16091
|
-
"#CC33FF",
|
|
16092
|
-
"#CC6600",
|
|
16093
|
-
"#CC6633",
|
|
16094
|
-
"#CC9900",
|
|
16095
|
-
"#CC9933",
|
|
16096
|
-
"#CCCC00",
|
|
16097
|
-
"#CCCC33",
|
|
16098
|
-
"#FF0000",
|
|
16099
|
-
"#FF0033",
|
|
16100
|
-
"#FF0066",
|
|
16101
|
-
"#FF0099",
|
|
16102
|
-
"#FF00CC",
|
|
16103
|
-
"#FF00FF",
|
|
16104
|
-
"#FF3300",
|
|
16105
|
-
"#FF3333",
|
|
16106
|
-
"#FF3366",
|
|
16107
|
-
"#FF3399",
|
|
16108
|
-
"#FF33CC",
|
|
16109
|
-
"#FF33FF",
|
|
16110
|
-
"#FF6600",
|
|
16111
|
-
"#FF6633",
|
|
16112
|
-
"#FF9900",
|
|
16113
|
-
"#FF9933",
|
|
16114
|
-
"#FFCC00",
|
|
16115
|
-
"#FFCC33"
|
|
15752
|
+
// src/context.ts
|
|
15753
|
+
var AS2_BASE_CONTEXT_URL = "https://www.w3.org/ns/activitystreams";
|
|
15754
|
+
var SOCKETHUB_BASE_CONTEXT_URL = "https://sockethub.org/ns/context/v1.jsonld";
|
|
15755
|
+
var PLATFORM_CONTEXT_PREFIX = "https://sockethub.org/ns/context/platform/";
|
|
15756
|
+
var ERROR_PLATFORM_ID = "error";
|
|
15757
|
+
var ERROR_PLATFORM_CONTEXT_URL = "https://sockethub.org/ns/context/platform/error/v1.jsonld";
|
|
15758
|
+
var INTERNAL_PLATFORM_ID = "sockethub:internal";
|
|
15759
|
+
var INTERNAL_PLATFORM_CONTEXT_URL = "https://sockethub.org/ns/context/platform/sockethub:internal/v1.jsonld";
|
|
15760
|
+
var platformContextToPlatformId = new Map;
|
|
15761
|
+
var platformContextToSchemaId = new Map;
|
|
15762
|
+
var platformContextToCredentialsSchemaId = new Map;
|
|
15763
|
+
function buildCanonicalContext(platformContextUrl) {
|
|
15764
|
+
return [
|
|
15765
|
+
AS2_BASE_CONTEXT_URL,
|
|
15766
|
+
SOCKETHUB_BASE_CONTEXT_URL,
|
|
15767
|
+
platformContextUrl
|
|
16116
15768
|
];
|
|
16117
|
-
|
|
16118
|
-
|
|
16119
|
-
|
|
16120
|
-
|
|
16121
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
16122
|
-
return false;
|
|
16123
|
-
}
|
|
16124
|
-
let m;
|
|
16125
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
16126
|
-
}
|
|
16127
|
-
function formatArgs(args) {
|
|
16128
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
16129
|
-
if (!this.useColors) {
|
|
16130
|
-
return;
|
|
16131
|
-
}
|
|
16132
|
-
const c = "color: " + this.color;
|
|
16133
|
-
args.splice(1, 0, c, "color: inherit");
|
|
16134
|
-
let index = 0;
|
|
16135
|
-
let lastC = 0;
|
|
16136
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
16137
|
-
if (match === "%%") {
|
|
16138
|
-
return;
|
|
16139
|
-
}
|
|
16140
|
-
index++;
|
|
16141
|
-
if (match === "%c") {
|
|
16142
|
-
lastC = index;
|
|
16143
|
-
}
|
|
16144
|
-
});
|
|
16145
|
-
args.splice(lastC, 0, c);
|
|
16146
|
-
}
|
|
16147
|
-
exports.log = console.debug || console.log || (() => {});
|
|
16148
|
-
function save(namespaces) {
|
|
16149
|
-
try {
|
|
16150
|
-
if (namespaces) {
|
|
16151
|
-
exports.storage.setItem("debug", namespaces);
|
|
16152
|
-
} else {
|
|
16153
|
-
exports.storage.removeItem("debug");
|
|
16154
|
-
}
|
|
16155
|
-
} catch (error) {}
|
|
16156
|
-
}
|
|
16157
|
-
function load() {
|
|
16158
|
-
let r;
|
|
16159
|
-
try {
|
|
16160
|
-
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
16161
|
-
} catch (error) {}
|
|
16162
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
16163
|
-
r = process.env.DEBUG;
|
|
16164
|
-
}
|
|
16165
|
-
return r;
|
|
16166
|
-
}
|
|
16167
|
-
function localstorage() {
|
|
16168
|
-
try {
|
|
16169
|
-
return localStorage;
|
|
16170
|
-
} catch (error) {}
|
|
16171
|
-
}
|
|
16172
|
-
module.exports = require_common()(exports);
|
|
16173
|
-
var { formatters } = module.exports;
|
|
16174
|
-
formatters.j = function(v) {
|
|
16175
|
-
try {
|
|
16176
|
-
return JSON.stringify(v);
|
|
16177
|
-
} catch (error) {
|
|
16178
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
16179
|
-
}
|
|
16180
|
-
};
|
|
16181
|
-
});
|
|
16182
|
-
|
|
16183
|
-
// ../../node_modules/has-flag/index.js
|
|
16184
|
-
var require_has_flag = __commonJS((exports, module) => {
|
|
16185
|
-
module.exports = (flag, argv = process.argv) => {
|
|
16186
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
16187
|
-
const position = argv.indexOf(prefix + flag);
|
|
16188
|
-
const terminatorPosition = argv.indexOf("--");
|
|
16189
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
16190
|
-
};
|
|
16191
|
-
});
|
|
16192
|
-
|
|
16193
|
-
// ../../node_modules/supports-color/index.js
|
|
16194
|
-
var require_supports_color = __commonJS((exports, module) => {
|
|
16195
|
-
var os = __require("os");
|
|
16196
|
-
var tty = __require("tty");
|
|
16197
|
-
var hasFlag = require_has_flag();
|
|
16198
|
-
var { env } = process;
|
|
16199
|
-
var flagForceColor;
|
|
16200
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
16201
|
-
flagForceColor = 0;
|
|
16202
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
16203
|
-
flagForceColor = 1;
|
|
16204
|
-
}
|
|
16205
|
-
function envForceColor() {
|
|
16206
|
-
if ("FORCE_COLOR" in env) {
|
|
16207
|
-
if (env.FORCE_COLOR === "true") {
|
|
16208
|
-
return 1;
|
|
16209
|
-
}
|
|
16210
|
-
if (env.FORCE_COLOR === "false") {
|
|
16211
|
-
return 0;
|
|
16212
|
-
}
|
|
16213
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
16214
|
-
}
|
|
16215
|
-
}
|
|
16216
|
-
function translateLevel(level) {
|
|
16217
|
-
if (level === 0) {
|
|
16218
|
-
return false;
|
|
16219
|
-
}
|
|
16220
|
-
return {
|
|
16221
|
-
level,
|
|
16222
|
-
hasBasic: true,
|
|
16223
|
-
has256: level >= 2,
|
|
16224
|
-
has16m: level >= 3
|
|
16225
|
-
};
|
|
16226
|
-
}
|
|
16227
|
-
function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
16228
|
-
const noFlagForceColor = envForceColor();
|
|
16229
|
-
if (noFlagForceColor !== undefined) {
|
|
16230
|
-
flagForceColor = noFlagForceColor;
|
|
16231
|
-
}
|
|
16232
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
16233
|
-
if (forceColor === 0) {
|
|
16234
|
-
return 0;
|
|
16235
|
-
}
|
|
16236
|
-
if (sniffFlags) {
|
|
16237
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
16238
|
-
return 3;
|
|
16239
|
-
}
|
|
16240
|
-
if (hasFlag("color=256")) {
|
|
16241
|
-
return 2;
|
|
16242
|
-
}
|
|
16243
|
-
}
|
|
16244
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
16245
|
-
return 0;
|
|
16246
|
-
}
|
|
16247
|
-
const min = forceColor || 0;
|
|
16248
|
-
if (env.TERM === "dumb") {
|
|
16249
|
-
return min;
|
|
16250
|
-
}
|
|
16251
|
-
if (process.platform === "win32") {
|
|
16252
|
-
const osRelease = os.release().split(".");
|
|
16253
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
16254
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
16255
|
-
}
|
|
16256
|
-
return 1;
|
|
16257
|
-
}
|
|
16258
|
-
if ("CI" in env) {
|
|
16259
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
|
|
16260
|
-
return 1;
|
|
16261
|
-
}
|
|
16262
|
-
return min;
|
|
16263
|
-
}
|
|
16264
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
16265
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
16266
|
-
}
|
|
16267
|
-
if (env.COLORTERM === "truecolor") {
|
|
16268
|
-
return 3;
|
|
16269
|
-
}
|
|
16270
|
-
if ("TERM_PROGRAM" in env) {
|
|
16271
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
16272
|
-
switch (env.TERM_PROGRAM) {
|
|
16273
|
-
case "iTerm.app":
|
|
16274
|
-
return version >= 3 ? 3 : 2;
|
|
16275
|
-
case "Apple_Terminal":
|
|
16276
|
-
return 2;
|
|
16277
|
-
}
|
|
16278
|
-
}
|
|
16279
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
16280
|
-
return 2;
|
|
16281
|
-
}
|
|
16282
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
16283
|
-
return 1;
|
|
16284
|
-
}
|
|
16285
|
-
if ("COLORTERM" in env) {
|
|
16286
|
-
return 1;
|
|
16287
|
-
}
|
|
16288
|
-
return min;
|
|
16289
|
-
}
|
|
16290
|
-
function getSupportLevel(stream, options = {}) {
|
|
16291
|
-
const level = supportsColor(stream, {
|
|
16292
|
-
streamIsTTY: stream && stream.isTTY,
|
|
16293
|
-
...options
|
|
16294
|
-
});
|
|
16295
|
-
return translateLevel(level);
|
|
16296
|
-
}
|
|
16297
|
-
module.exports = {
|
|
16298
|
-
supportsColor: getSupportLevel,
|
|
16299
|
-
stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
|
|
16300
|
-
stderr: getSupportLevel({ isTTY: tty.isatty(2) })
|
|
16301
|
-
};
|
|
16302
|
-
});
|
|
16303
|
-
|
|
16304
|
-
// ../../node_modules/debug/src/node.js
|
|
16305
|
-
var require_node = __commonJS((exports, module) => {
|
|
16306
|
-
var tty = __require("tty");
|
|
16307
|
-
var util = __require("util");
|
|
16308
|
-
exports.init = init;
|
|
16309
|
-
exports.log = log;
|
|
16310
|
-
exports.formatArgs = formatArgs;
|
|
16311
|
-
exports.save = save;
|
|
16312
|
-
exports.load = load;
|
|
16313
|
-
exports.useColors = useColors;
|
|
16314
|
-
exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
16315
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
16316
|
-
try {
|
|
16317
|
-
const supportsColor = require_supports_color();
|
|
16318
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
16319
|
-
exports.colors = [
|
|
16320
|
-
20,
|
|
16321
|
-
21,
|
|
16322
|
-
26,
|
|
16323
|
-
27,
|
|
16324
|
-
32,
|
|
16325
|
-
33,
|
|
16326
|
-
38,
|
|
16327
|
-
39,
|
|
16328
|
-
40,
|
|
16329
|
-
41,
|
|
16330
|
-
42,
|
|
16331
|
-
43,
|
|
16332
|
-
44,
|
|
16333
|
-
45,
|
|
16334
|
-
56,
|
|
16335
|
-
57,
|
|
16336
|
-
62,
|
|
16337
|
-
63,
|
|
16338
|
-
68,
|
|
16339
|
-
69,
|
|
16340
|
-
74,
|
|
16341
|
-
75,
|
|
16342
|
-
76,
|
|
16343
|
-
77,
|
|
16344
|
-
78,
|
|
16345
|
-
79,
|
|
16346
|
-
80,
|
|
16347
|
-
81,
|
|
16348
|
-
92,
|
|
16349
|
-
93,
|
|
16350
|
-
98,
|
|
16351
|
-
99,
|
|
16352
|
-
112,
|
|
16353
|
-
113,
|
|
16354
|
-
128,
|
|
16355
|
-
129,
|
|
16356
|
-
134,
|
|
16357
|
-
135,
|
|
16358
|
-
148,
|
|
16359
|
-
149,
|
|
16360
|
-
160,
|
|
16361
|
-
161,
|
|
16362
|
-
162,
|
|
16363
|
-
163,
|
|
16364
|
-
164,
|
|
16365
|
-
165,
|
|
16366
|
-
166,
|
|
16367
|
-
167,
|
|
16368
|
-
168,
|
|
16369
|
-
169,
|
|
16370
|
-
170,
|
|
16371
|
-
171,
|
|
16372
|
-
172,
|
|
16373
|
-
173,
|
|
16374
|
-
178,
|
|
16375
|
-
179,
|
|
16376
|
-
184,
|
|
16377
|
-
185,
|
|
16378
|
-
196,
|
|
16379
|
-
197,
|
|
16380
|
-
198,
|
|
16381
|
-
199,
|
|
16382
|
-
200,
|
|
16383
|
-
201,
|
|
16384
|
-
202,
|
|
16385
|
-
203,
|
|
16386
|
-
204,
|
|
16387
|
-
205,
|
|
16388
|
-
206,
|
|
16389
|
-
207,
|
|
16390
|
-
208,
|
|
16391
|
-
209,
|
|
16392
|
-
214,
|
|
16393
|
-
215,
|
|
16394
|
-
220,
|
|
16395
|
-
221
|
|
16396
|
-
];
|
|
16397
|
-
}
|
|
16398
|
-
} catch (error) {}
|
|
16399
|
-
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
16400
|
-
return /^debug_/i.test(key);
|
|
16401
|
-
}).reduce((obj, key) => {
|
|
16402
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
16403
|
-
return k.toUpperCase();
|
|
16404
|
-
});
|
|
16405
|
-
let val = process.env[key];
|
|
16406
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
16407
|
-
val = true;
|
|
16408
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
16409
|
-
val = false;
|
|
16410
|
-
} else if (val === "null") {
|
|
16411
|
-
val = null;
|
|
16412
|
-
} else {
|
|
16413
|
-
val = Number(val);
|
|
16414
|
-
}
|
|
16415
|
-
obj[prop] = val;
|
|
16416
|
-
return obj;
|
|
16417
|
-
}, {});
|
|
16418
|
-
function useColors() {
|
|
16419
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
16420
|
-
}
|
|
16421
|
-
function formatArgs(args) {
|
|
16422
|
-
const { namespace: name, useColors: useColors2 } = this;
|
|
16423
|
-
if (useColors2) {
|
|
16424
|
-
const c = this.color;
|
|
16425
|
-
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
16426
|
-
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
16427
|
-
args[0] = prefix + args[0].split(`
|
|
16428
|
-
`).join(`
|
|
16429
|
-
` + prefix);
|
|
16430
|
-
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
16431
|
-
} else {
|
|
16432
|
-
args[0] = getDate() + name + " " + args[0];
|
|
16433
|
-
}
|
|
16434
|
-
}
|
|
16435
|
-
function getDate() {
|
|
16436
|
-
if (exports.inspectOpts.hideDate) {
|
|
16437
|
-
return "";
|
|
16438
|
-
}
|
|
16439
|
-
return new Date().toISOString() + " ";
|
|
16440
|
-
}
|
|
16441
|
-
function log(...args) {
|
|
16442
|
-
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + `
|
|
16443
|
-
`);
|
|
16444
|
-
}
|
|
16445
|
-
function save(namespaces) {
|
|
16446
|
-
if (namespaces) {
|
|
16447
|
-
process.env.DEBUG = namespaces;
|
|
16448
|
-
} else {
|
|
16449
|
-
delete process.env.DEBUG;
|
|
16450
|
-
}
|
|
16451
|
-
}
|
|
16452
|
-
function load() {
|
|
16453
|
-
return process.env.DEBUG;
|
|
16454
|
-
}
|
|
16455
|
-
function init(debug) {
|
|
16456
|
-
debug.inspectOpts = {};
|
|
16457
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
16458
|
-
for (let i = 0;i < keys.length; i++) {
|
|
16459
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
16460
|
-
}
|
|
15769
|
+
}
|
|
15770
|
+
function normalizeContextArray(value) {
|
|
15771
|
+
if (!Array.isArray(value)) {
|
|
15772
|
+
return [];
|
|
16461
15773
|
}
|
|
16462
|
-
|
|
16463
|
-
|
|
16464
|
-
|
|
16465
|
-
|
|
16466
|
-
|
|
16467
|
-
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
|
|
16471
|
-
|
|
16472
|
-
|
|
16473
|
-
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16477
|
-
if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
|
|
16478
|
-
module.exports = require_browser();
|
|
16479
|
-
} else {
|
|
16480
|
-
module.exports = require_node();
|
|
15774
|
+
return value.filter((entry) => typeof entry === "string");
|
|
15775
|
+
}
|
|
15776
|
+
function getContextArray(msg) {
|
|
15777
|
+
return normalizeContextArray(msg["@context"]);
|
|
15778
|
+
}
|
|
15779
|
+
function registerPlatformContext(platformId, platformContextUrl, schemaId, credentialsSchemaId) {
|
|
15780
|
+
platformContextToPlatformId.set(platformContextUrl, platformId);
|
|
15781
|
+
platformContextToSchemaId.set(platformContextUrl, schemaId);
|
|
15782
|
+
platformContextToCredentialsSchemaId.set(platformContextUrl, credentialsSchemaId);
|
|
15783
|
+
}
|
|
15784
|
+
function resolvePlatformContextUrl(msg) {
|
|
15785
|
+
const contexts = getContextArray(msg);
|
|
15786
|
+
const matches = contexts.filter((contextUrl) => platformContextToPlatformId.has(contextUrl));
|
|
15787
|
+
if (matches.length !== 1) {
|
|
15788
|
+
return null;
|
|
16481
15789
|
}
|
|
16482
|
-
|
|
15790
|
+
return matches[0];
|
|
15791
|
+
}
|
|
15792
|
+
function getPlatformIdByContextUrl(platformContextUrl) {
|
|
15793
|
+
return platformContextToPlatformId.get(platformContextUrl);
|
|
15794
|
+
}
|
|
15795
|
+
function getSchemaIdByContextUrl(platformContextUrl) {
|
|
15796
|
+
return platformContextToSchemaId.get(platformContextUrl);
|
|
15797
|
+
}
|
|
15798
|
+
function getCredentialsSchemaIdByContextUrl(platformContextUrl) {
|
|
15799
|
+
return platformContextToCredentialsSchemaId.get(platformContextUrl);
|
|
15800
|
+
}
|
|
16483
15801
|
|
|
16484
15802
|
// src/helpers/objects.ts
|
|
16485
15803
|
var validObjectRefs = [];
|
|
@@ -16594,6 +15912,21 @@ var ObjectTypesSchema = {
|
|
|
16594
15912
|
}
|
|
16595
15913
|
}
|
|
16596
15914
|
},
|
|
15915
|
+
platform: {
|
|
15916
|
+
required: ["id", "type"],
|
|
15917
|
+
additionalProperties: true,
|
|
15918
|
+
properties: {
|
|
15919
|
+
id: {
|
|
15920
|
+
type: "string"
|
|
15921
|
+
},
|
|
15922
|
+
type: {
|
|
15923
|
+
enum: ["platform"]
|
|
15924
|
+
},
|
|
15925
|
+
name: {
|
|
15926
|
+
type: "string"
|
|
15927
|
+
}
|
|
15928
|
+
}
|
|
15929
|
+
},
|
|
16597
15930
|
website: {
|
|
16598
15931
|
required: ["id", "type"],
|
|
16599
15932
|
additionalProperties: true,
|
|
@@ -16683,9 +16016,45 @@ var ObjectTypesSchema = {
|
|
|
16683
16016
|
enum: ["address"]
|
|
16684
16017
|
}
|
|
16685
16018
|
}
|
|
16019
|
+
},
|
|
16020
|
+
heartbeat: {
|
|
16021
|
+
required: ["type", "timestamp"],
|
|
16022
|
+
additionalProperties: false,
|
|
16023
|
+
properties: {
|
|
16024
|
+
type: {
|
|
16025
|
+
enum: ["heartbeat"]
|
|
16026
|
+
},
|
|
16027
|
+
timestamp: {
|
|
16028
|
+
type: "number"
|
|
16029
|
+
}
|
|
16030
|
+
}
|
|
16686
16031
|
}
|
|
16687
16032
|
};
|
|
16033
|
+
var InternalObjectTypesList = ["platform", "heartbeat"];
|
|
16688
16034
|
var ObjectTypesList = Object.keys(ObjectTypesSchema);
|
|
16035
|
+
var ActorTypesList = [
|
|
16036
|
+
"person",
|
|
16037
|
+
"room",
|
|
16038
|
+
"service",
|
|
16039
|
+
"feed",
|
|
16040
|
+
"website",
|
|
16041
|
+
"platform"
|
|
16042
|
+
];
|
|
16043
|
+
var TargetTypesList = [
|
|
16044
|
+
"person",
|
|
16045
|
+
"room",
|
|
16046
|
+
"service",
|
|
16047
|
+
"feed",
|
|
16048
|
+
"website",
|
|
16049
|
+
"platform",
|
|
16050
|
+
"address"
|
|
16051
|
+
];
|
|
16052
|
+
var validActorRefs = ActorTypesList.map((type) => ({
|
|
16053
|
+
$ref: `#/definitions/type/${type}`
|
|
16054
|
+
}));
|
|
16055
|
+
var validTargetRefs = TargetTypesList.map((type) => ({
|
|
16056
|
+
$ref: `#/definitions/type/${type}`
|
|
16057
|
+
}));
|
|
16689
16058
|
for (const type of ObjectTypesList) {
|
|
16690
16059
|
if (type === "credentials") {
|
|
16691
16060
|
continue;
|
|
@@ -16712,14 +16081,29 @@ var ActivityObjectSchema = {
|
|
|
16712
16081
|
};
|
|
16713
16082
|
|
|
16714
16083
|
// src/schemas/activity-stream.ts
|
|
16715
|
-
var validActorRefs = ActivityObjectSchema.properties.object.oneOf;
|
|
16716
|
-
var validTargetRefs = ActivityObjectSchema.properties.object.oneOf;
|
|
16717
16084
|
var validObjectRefs2 = [];
|
|
16718
16085
|
for (const type of ObjectTypesList) {
|
|
16719
16086
|
validObjectRefs2.push({ $ref: `#/definitions/type/${type}` });
|
|
16720
16087
|
}
|
|
16721
16088
|
var contextSchema = {
|
|
16722
|
-
type: "
|
|
16089
|
+
type: "array",
|
|
16090
|
+
minItems: 3,
|
|
16091
|
+
maxItems: 3,
|
|
16092
|
+
items: {
|
|
16093
|
+
type: "string"
|
|
16094
|
+
},
|
|
16095
|
+
allOf: [
|
|
16096
|
+
{
|
|
16097
|
+
contains: {
|
|
16098
|
+
const: AS2_BASE_CONTEXT_URL
|
|
16099
|
+
}
|
|
16100
|
+
},
|
|
16101
|
+
{
|
|
16102
|
+
contains: {
|
|
16103
|
+
const: SOCKETHUB_BASE_CONTEXT_URL
|
|
16104
|
+
}
|
|
16105
|
+
}
|
|
16106
|
+
]
|
|
16723
16107
|
};
|
|
16724
16108
|
var typeSchema = {
|
|
16725
16109
|
type: "string"
|
|
@@ -16728,13 +16112,13 @@ var ActivityStreamSchema = {
|
|
|
16728
16112
|
$id: "https://sockethub.org/schemas/v/activity-stream.json",
|
|
16729
16113
|
description: "Schema for Sockethub Activity Streams",
|
|
16730
16114
|
type: "object",
|
|
16731
|
-
required: ["context", "type", "actor"],
|
|
16115
|
+
required: ["@context", "type", "actor"],
|
|
16732
16116
|
properties: {
|
|
16117
|
+
"@context": contextSchema,
|
|
16733
16118
|
id: {
|
|
16734
16119
|
type: "string"
|
|
16735
16120
|
},
|
|
16736
16121
|
type: typeSchema,
|
|
16737
|
-
context: contextSchema,
|
|
16738
16122
|
actor: {
|
|
16739
16123
|
type: "object",
|
|
16740
16124
|
oneOf: validActorRefs
|
|
@@ -16761,9 +16145,33 @@ var ActivityStreamSchema = {
|
|
|
16761
16145
|
var PlatformSchema = {
|
|
16762
16146
|
$id: "https://sockethub.org/schemas/v/platform.json",
|
|
16763
16147
|
type: "object",
|
|
16764
|
-
required: [
|
|
16148
|
+
required: [
|
|
16149
|
+
"name",
|
|
16150
|
+
"version",
|
|
16151
|
+
"messages",
|
|
16152
|
+
"contextUrl",
|
|
16153
|
+
"contextVersion",
|
|
16154
|
+
"schemaVersion"
|
|
16155
|
+
],
|
|
16765
16156
|
additionalProperties: false,
|
|
16766
16157
|
properties: {
|
|
16158
|
+
contextUrl: {
|
|
16159
|
+
title: "contextUrl",
|
|
16160
|
+
type: "string",
|
|
16161
|
+
format: "uri"
|
|
16162
|
+
},
|
|
16163
|
+
contextVersion: {
|
|
16164
|
+
title: "contextVersion",
|
|
16165
|
+
type: "string"
|
|
16166
|
+
},
|
|
16167
|
+
schemaVersion: {
|
|
16168
|
+
title: "schemaVersion",
|
|
16169
|
+
type: "string"
|
|
16170
|
+
},
|
|
16171
|
+
messageConstraints: {
|
|
16172
|
+
title: "messageConstraints",
|
|
16173
|
+
type: "object"
|
|
16174
|
+
},
|
|
16767
16175
|
credentials: {
|
|
16768
16176
|
title: "credentials",
|
|
16769
16177
|
type: "object"
|
|
@@ -16783,11 +16191,230 @@ var PlatformSchema = {
|
|
|
16783
16191
|
}
|
|
16784
16192
|
};
|
|
16785
16193
|
|
|
16194
|
+
// src/schemas/sockethub-config.ts
|
|
16195
|
+
var connectConfigPlatforms = {
|
|
16196
|
+
connectTimeoutMs: {
|
|
16197
|
+
type: "number"
|
|
16198
|
+
}
|
|
16199
|
+
};
|
|
16200
|
+
var SockethubConfigSchema = {
|
|
16201
|
+
$id: "https://sockethub.org/schemas/v/sockethub-config.json",
|
|
16202
|
+
description: "Sockethub Config Schema",
|
|
16203
|
+
type: "object",
|
|
16204
|
+
required: ["platforms"],
|
|
16205
|
+
additionalProperties: false,
|
|
16206
|
+
properties: {
|
|
16207
|
+
$schema: {
|
|
16208
|
+
type: "string"
|
|
16209
|
+
},
|
|
16210
|
+
examples: {
|
|
16211
|
+
type: "boolean",
|
|
16212
|
+
default: true
|
|
16213
|
+
},
|
|
16214
|
+
logging: {
|
|
16215
|
+
type: "object",
|
|
16216
|
+
additionalProperties: false,
|
|
16217
|
+
properties: {
|
|
16218
|
+
level: {
|
|
16219
|
+
type: "string",
|
|
16220
|
+
enum: ["error", "warn", "info", "debug"],
|
|
16221
|
+
default: "info"
|
|
16222
|
+
},
|
|
16223
|
+
fileLevel: {
|
|
16224
|
+
type: "string",
|
|
16225
|
+
enum: ["error", "warn", "info", "debug"],
|
|
16226
|
+
default: "debug"
|
|
16227
|
+
},
|
|
16228
|
+
file: {
|
|
16229
|
+
type: "string",
|
|
16230
|
+
default: "sockethub.log"
|
|
16231
|
+
}
|
|
16232
|
+
}
|
|
16233
|
+
},
|
|
16234
|
+
packageConfig: {
|
|
16235
|
+
type: "object",
|
|
16236
|
+
properties: {
|
|
16237
|
+
"@sockethub/activity-streams": {
|
|
16238
|
+
type: "object",
|
|
16239
|
+
additionalProperties: false,
|
|
16240
|
+
properties: {
|
|
16241
|
+
specialObjs: {
|
|
16242
|
+
type: "array",
|
|
16243
|
+
items: {
|
|
16244
|
+
type: "string"
|
|
16245
|
+
},
|
|
16246
|
+
default: ["credentials"]
|
|
16247
|
+
},
|
|
16248
|
+
failOnUnknownObjectProperties: {
|
|
16249
|
+
type: "boolean",
|
|
16250
|
+
default: true
|
|
16251
|
+
}
|
|
16252
|
+
}
|
|
16253
|
+
},
|
|
16254
|
+
"@sockethub/platform-dummy": {
|
|
16255
|
+
type: "object",
|
|
16256
|
+
additionalProperties: false,
|
|
16257
|
+
properties: {
|
|
16258
|
+
greeting: {
|
|
16259
|
+
type: "string",
|
|
16260
|
+
default: "Hello"
|
|
16261
|
+
}
|
|
16262
|
+
}
|
|
16263
|
+
},
|
|
16264
|
+
"@sockethub/platform-feeds": {
|
|
16265
|
+
type: "object",
|
|
16266
|
+
additionalProperties: false,
|
|
16267
|
+
properties: {
|
|
16268
|
+
...connectConfigPlatforms
|
|
16269
|
+
}
|
|
16270
|
+
},
|
|
16271
|
+
"@sockethub/platform-irc": {
|
|
16272
|
+
type: "object",
|
|
16273
|
+
additionalProperties: false,
|
|
16274
|
+
properties: {
|
|
16275
|
+
...connectConfigPlatforms
|
|
16276
|
+
}
|
|
16277
|
+
},
|
|
16278
|
+
"@sockethub/platform-xmpp": {
|
|
16279
|
+
type: "object",
|
|
16280
|
+
additionalProperties: false,
|
|
16281
|
+
properties: {
|
|
16282
|
+
...connectConfigPlatforms
|
|
16283
|
+
}
|
|
16284
|
+
}
|
|
16285
|
+
}
|
|
16286
|
+
},
|
|
16287
|
+
platforms: {
|
|
16288
|
+
type: "array",
|
|
16289
|
+
items: {
|
|
16290
|
+
type: "string"
|
|
16291
|
+
},
|
|
16292
|
+
default: [
|
|
16293
|
+
"@sockethub/platform-dummy",
|
|
16294
|
+
"@sockethub/platform-feeds",
|
|
16295
|
+
"@sockethub/platform-irc",
|
|
16296
|
+
"@sockethub/platform-metadata",
|
|
16297
|
+
"@sockethub/platform-xmpp"
|
|
16298
|
+
]
|
|
16299
|
+
},
|
|
16300
|
+
public: {
|
|
16301
|
+
type: "object",
|
|
16302
|
+
additionalProperties: false,
|
|
16303
|
+
properties: {
|
|
16304
|
+
protocol: {
|
|
16305
|
+
type: "string",
|
|
16306
|
+
default: "http"
|
|
16307
|
+
},
|
|
16308
|
+
host: {
|
|
16309
|
+
type: "string",
|
|
16310
|
+
default: "localhost"
|
|
16311
|
+
},
|
|
16312
|
+
port: {
|
|
16313
|
+
type: "number",
|
|
16314
|
+
default: 10550
|
|
16315
|
+
},
|
|
16316
|
+
path: {
|
|
16317
|
+
type: "string",
|
|
16318
|
+
default: "/"
|
|
16319
|
+
}
|
|
16320
|
+
}
|
|
16321
|
+
},
|
|
16322
|
+
rateLimiter: {
|
|
16323
|
+
type: "object",
|
|
16324
|
+
additionalProperties: false,
|
|
16325
|
+
properties: {
|
|
16326
|
+
windowMs: {
|
|
16327
|
+
type: "number",
|
|
16328
|
+
default: 1000
|
|
16329
|
+
},
|
|
16330
|
+
maxRequests: {
|
|
16331
|
+
type: "number",
|
|
16332
|
+
default: 100
|
|
16333
|
+
},
|
|
16334
|
+
blockDurationMs: {
|
|
16335
|
+
type: "number",
|
|
16336
|
+
default: 5000
|
|
16337
|
+
}
|
|
16338
|
+
}
|
|
16339
|
+
},
|
|
16340
|
+
redis: {
|
|
16341
|
+
type: "object",
|
|
16342
|
+
additionalProperties: false,
|
|
16343
|
+
properties: {
|
|
16344
|
+
url: {
|
|
16345
|
+
type: "string",
|
|
16346
|
+
default: "redis://127.0.0.1:6379"
|
|
16347
|
+
},
|
|
16348
|
+
connectTimeout: {
|
|
16349
|
+
type: "number",
|
|
16350
|
+
default: 1e4,
|
|
16351
|
+
description: "Connection timeout in milliseconds"
|
|
16352
|
+
},
|
|
16353
|
+
disconnectTimeout: {
|
|
16354
|
+
type: "number",
|
|
16355
|
+
default: 5000,
|
|
16356
|
+
description: "Disconnect timeout in milliseconds"
|
|
16357
|
+
},
|
|
16358
|
+
maxRetriesPerRequest: {
|
|
16359
|
+
type: ["number", "null"],
|
|
16360
|
+
default: null,
|
|
16361
|
+
description: "Maximum number of retries per request (null for BullMQ default)"
|
|
16362
|
+
}
|
|
16363
|
+
}
|
|
16364
|
+
},
|
|
16365
|
+
sentry: {
|
|
16366
|
+
type: "object",
|
|
16367
|
+
additionalProperties: false,
|
|
16368
|
+
properties: {
|
|
16369
|
+
dsn: {
|
|
16370
|
+
type: "string",
|
|
16371
|
+
default: ""
|
|
16372
|
+
},
|
|
16373
|
+
traceSampleRate: {
|
|
16374
|
+
type: "number",
|
|
16375
|
+
default: 1
|
|
16376
|
+
}
|
|
16377
|
+
}
|
|
16378
|
+
},
|
|
16379
|
+
sockethub: {
|
|
16380
|
+
type: "object",
|
|
16381
|
+
additionalProperties: false,
|
|
16382
|
+
properties: {
|
|
16383
|
+
port: {
|
|
16384
|
+
type: "number",
|
|
16385
|
+
default: 10550
|
|
16386
|
+
},
|
|
16387
|
+
host: {
|
|
16388
|
+
type: "string",
|
|
16389
|
+
default: "localhost"
|
|
16390
|
+
},
|
|
16391
|
+
path: {
|
|
16392
|
+
type: "string",
|
|
16393
|
+
default: "/sockethub"
|
|
16394
|
+
}
|
|
16395
|
+
}
|
|
16396
|
+
},
|
|
16397
|
+
platformHeartbeat: {
|
|
16398
|
+
type: "object",
|
|
16399
|
+
additionalProperties: false,
|
|
16400
|
+
properties: {
|
|
16401
|
+
intervalMs: {
|
|
16402
|
+
type: "number",
|
|
16403
|
+
default: 5000
|
|
16404
|
+
},
|
|
16405
|
+
timeoutMs: {
|
|
16406
|
+
type: "number",
|
|
16407
|
+
default: 15000
|
|
16408
|
+
}
|
|
16409
|
+
}
|
|
16410
|
+
}
|
|
16411
|
+
}
|
|
16412
|
+
};
|
|
16413
|
+
|
|
16786
16414
|
// src/validator.ts
|
|
16787
16415
|
var import_ajv = __toESM(require_ajv(), 1);
|
|
16788
16416
|
var import_ajv_formats = __toESM(require_dist(), 1);
|
|
16789
16417
|
var import_ajv_formats_draft2019 = __toESM(require_ajv_formats_draft2019(), 1);
|
|
16790
|
-
var import_debug = __toESM(require_src(), 1);
|
|
16791
16418
|
|
|
16792
16419
|
// src/helpers/error-parser.ts
|
|
16793
16420
|
function parseMsg(error) {
|
|
@@ -16800,11 +16427,15 @@ function parseMsg(error) {
|
|
|
16800
16427
|
return err;
|
|
16801
16428
|
}
|
|
16802
16429
|
function getTypeList(msg) {
|
|
16803
|
-
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
|
|
16807
|
-
|
|
16430
|
+
const types = [];
|
|
16431
|
+
if (msg?.type) {
|
|
16432
|
+
types.push(msg.type);
|
|
16433
|
+
}
|
|
16434
|
+
const record = msg;
|
|
16435
|
+
for (const prop in record) {
|
|
16436
|
+
const value = record[prop];
|
|
16437
|
+
if (value && typeof value === "object" && "type" in value) {
|
|
16438
|
+
types.push(...getTypeList(value));
|
|
16808
16439
|
}
|
|
16809
16440
|
}
|
|
16810
16441
|
return types;
|
|
@@ -16823,23 +16454,32 @@ function getPartsCount(error, types) {
|
|
|
16823
16454
|
if (!errType) {
|
|
16824
16455
|
return -1;
|
|
16825
16456
|
}
|
|
16826
|
-
|
|
16457
|
+
const typeList = types[errType];
|
|
16458
|
+
if (!typeList) {
|
|
16827
16459
|
return -1;
|
|
16828
16460
|
}
|
|
16829
|
-
if (!
|
|
16461
|
+
if (!schemaType || !typeList.includes(schemaType)) {
|
|
16830
16462
|
return -1;
|
|
16831
16463
|
}
|
|
16832
16464
|
const parts = error.instancePath.split("/");
|
|
16833
16465
|
return parts.length;
|
|
16834
16466
|
}
|
|
16835
16467
|
function getTypes(msg) {
|
|
16468
|
+
if (!Array.isArray(msg["@context"])) {
|
|
16469
|
+
return {
|
|
16470
|
+
actor: [],
|
|
16471
|
+
target: [],
|
|
16472
|
+
object: getTypeList(msg)
|
|
16473
|
+
};
|
|
16474
|
+
}
|
|
16475
|
+
const stream = msg;
|
|
16836
16476
|
return {
|
|
16837
|
-
actor: getTypeList(
|
|
16838
|
-
target: getTypeList(
|
|
16839
|
-
object:
|
|
16477
|
+
actor: getTypeList(stream.actor),
|
|
16478
|
+
target: getTypeList(stream.target),
|
|
16479
|
+
object: stream.object ? getTypeList(stream.object) : []
|
|
16840
16480
|
};
|
|
16841
16481
|
}
|
|
16842
|
-
function getErrorMessage(msg, errors) {
|
|
16482
|
+
function getErrorMessage(msg, errors, options) {
|
|
16843
16483
|
const types = getTypes(msg);
|
|
16844
16484
|
let deepest_entry = 0;
|
|
16845
16485
|
let highest_depth = -1;
|
|
@@ -16850,12 +16490,23 @@ function getErrorMessage(msg, errors) {
|
|
|
16850
16490
|
deepest_entry = i;
|
|
16851
16491
|
}
|
|
16852
16492
|
}
|
|
16853
|
-
return highest_depth >= 0 ? parseMsg(errors[deepest_entry]) : composeFinalError(errors[errors.length - 1]);
|
|
16493
|
+
return highest_depth >= 0 ? parseMsg(errors[deepest_entry]) : composeFinalError(errors[errors.length - 1], options);
|
|
16854
16494
|
}
|
|
16855
|
-
function
|
|
16495
|
+
function filterTypeList(types, options) {
|
|
16496
|
+
if (!options?.excludeTypes || options.excludeTypes.length === 0) {
|
|
16497
|
+
return types;
|
|
16498
|
+
}
|
|
16499
|
+
const exclude = new Set(options.excludeTypes);
|
|
16500
|
+
return types.filter((type) => !exclude.has(type));
|
|
16501
|
+
}
|
|
16502
|
+
function composeFinalError(error, options) {
|
|
16856
16503
|
let msg;
|
|
16857
16504
|
if (error.keyword === "oneOf") {
|
|
16858
|
-
|
|
16505
|
+
const instanceRoot = error.instancePath.split("/")[1];
|
|
16506
|
+
const pathScopedTypes = instanceRoot === "actor" ? ActorTypesList : instanceRoot === "target" ? TargetTypesList : ObjectTypesList;
|
|
16507
|
+
const filteredTypes = filterTypeList(pathScopedTypes, options);
|
|
16508
|
+
const typesList = filteredTypes.length > 0 ? filteredTypes : pathScopedTypes;
|
|
16509
|
+
msg = `${error.instancePath}: ${error.message}: ` + `${typesList.join(", ")}`;
|
|
16859
16510
|
} else {
|
|
16860
16511
|
msg = `${error.instancePath ? error.instancePath : "activity stream"}: ${error.message}`;
|
|
16861
16512
|
}
|
|
@@ -16869,17 +16520,40 @@ function composeFinalError(error) {
|
|
|
16869
16520
|
var ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
|
|
16870
16521
|
import_ajv_formats.default(ajv);
|
|
16871
16522
|
import_ajv_formats_draft2019.default(ajv);
|
|
16872
|
-
var log = import_debug.default("sockethub:schemas:validator");
|
|
16873
16523
|
var schemaURL = "https://sockethub.org/schemas/v0";
|
|
16874
16524
|
var schemas = {};
|
|
16525
|
+
var validationErrorOptions = {};
|
|
16526
|
+
var systemContextsRegistered = false;
|
|
16875
16527
|
schemas[`${schemaURL}/activity-stream`] = ActivityStreamSchema;
|
|
16876
16528
|
schemas[`${schemaURL}/activity-object`] = ActivityObjectSchema;
|
|
16877
16529
|
for (const uri in schemas) {
|
|
16878
|
-
log(`registering schema ${uri}`);
|
|
16879
16530
|
ajv.addSchema(schemas[uri], uri);
|
|
16880
16531
|
}
|
|
16532
|
+
function registerSystemContext(platformId, contextUrl) {
|
|
16533
|
+
registerPlatformContext(platformId, contextUrl, `${schemaURL}/context/${platformId}/messages`, `${schemaURL}/context/${platformId}/credentials`);
|
|
16534
|
+
const messageSchemaRef = `${schemaURL}/context/${platformId}/messages`;
|
|
16535
|
+
if (!ajv.getSchema(messageSchemaRef)) {
|
|
16536
|
+
ajv.addSchema({}, messageSchemaRef);
|
|
16537
|
+
}
|
|
16538
|
+
const credentialsSchemaRef = `${schemaURL}/context/${platformId}/credentials`;
|
|
16539
|
+
if (!ajv.getSchema(credentialsSchemaRef)) {
|
|
16540
|
+
ajv.addSchema({}, credentialsSchemaRef);
|
|
16541
|
+
}
|
|
16542
|
+
}
|
|
16543
|
+
function registerSystemPlatformContexts() {
|
|
16544
|
+
if (systemContextsRegistered) {
|
|
16545
|
+
return;
|
|
16546
|
+
}
|
|
16547
|
+
registerSystemContext(ERROR_PLATFORM_ID, ERROR_PLATFORM_CONTEXT_URL);
|
|
16548
|
+
registerSystemContext(INTERNAL_PLATFORM_ID, INTERNAL_PLATFORM_CONTEXT_URL);
|
|
16549
|
+
systemContextsRegistered = true;
|
|
16550
|
+
}
|
|
16551
|
+
registerSystemPlatformContexts();
|
|
16881
16552
|
function handleValidation(schemaRef, msg, isObject = false) {
|
|
16882
16553
|
const validator = ajv.getSchema(schemaRef);
|
|
16554
|
+
if (!validator) {
|
|
16555
|
+
return `schema ${schemaRef} not found`;
|
|
16556
|
+
}
|
|
16883
16557
|
let result;
|
|
16884
16558
|
if (isObject) {
|
|
16885
16559
|
result = validator({ object: msg });
|
|
@@ -16887,29 +16561,61 @@ function handleValidation(schemaRef, msg, isObject = false) {
|
|
|
16887
16561
|
result = validator(msg);
|
|
16888
16562
|
}
|
|
16889
16563
|
if (!result) {
|
|
16890
|
-
let errorMessage = getErrorMessage(msg, validator.errors);
|
|
16891
|
-
if (msg
|
|
16892
|
-
|
|
16564
|
+
let errorMessage = getErrorMessage(msg, validator.errors, validationErrorOptions);
|
|
16565
|
+
if (Array.isArray(msg["@context"])) {
|
|
16566
|
+
const platformContextUrl = resolvePlatformContextUrl(msg);
|
|
16567
|
+
if (platformContextUrl) {
|
|
16568
|
+
const platformId = getPlatformIdByContextUrl(platformContextUrl);
|
|
16569
|
+
if (platformId) {
|
|
16570
|
+
errorMessage = `[${platformId}] ${errorMessage}`;
|
|
16571
|
+
}
|
|
16572
|
+
}
|
|
16893
16573
|
}
|
|
16894
16574
|
return errorMessage;
|
|
16895
16575
|
}
|
|
16896
16576
|
return "";
|
|
16897
16577
|
}
|
|
16578
|
+
function setValidationErrorOptions(options) {
|
|
16579
|
+
validationErrorOptions = { ...validationErrorOptions, ...options };
|
|
16580
|
+
}
|
|
16898
16581
|
function validateActivityObject(msg) {
|
|
16899
16582
|
return handleValidation(`${schemaURL}/activity-object`, msg, true);
|
|
16900
16583
|
}
|
|
16901
16584
|
function validateActivityStream(msg) {
|
|
16902
|
-
|
|
16585
|
+
const streamValidationError = handleValidation(`${schemaURL}/activity-stream`, msg);
|
|
16586
|
+
if (streamValidationError) {
|
|
16587
|
+
return streamValidationError;
|
|
16588
|
+
}
|
|
16589
|
+
const platformContextUrl = resolvePlatformContextUrl(msg);
|
|
16590
|
+
if (!platformContextUrl) {
|
|
16591
|
+
return "activity streams must have exactly one registered platform context URL in @context";
|
|
16592
|
+
}
|
|
16593
|
+
const schemaId = getSchemaIdByContextUrl(platformContextUrl);
|
|
16594
|
+
if (!schemaId) {
|
|
16595
|
+
return `platform context URL ${platformContextUrl} does not have a registered message schema`;
|
|
16596
|
+
}
|
|
16597
|
+
return handleValidation(schemaId, msg);
|
|
16903
16598
|
}
|
|
16904
16599
|
function validateCredentials(msg) {
|
|
16905
|
-
if (!msg
|
|
16906
|
-
return "credential activity streams must have
|
|
16600
|
+
if (!Array.isArray(msg["@context"])) {
|
|
16601
|
+
return "credential activity streams must have an @context set";
|
|
16907
16602
|
}
|
|
16908
16603
|
if (msg.type !== "credentials") {
|
|
16909
16604
|
return "credential activity streams must have credentials set as type";
|
|
16910
16605
|
}
|
|
16911
|
-
|
|
16912
|
-
|
|
16606
|
+
const streamValidationError = handleValidation(`${schemaURL}/activity-stream`, msg);
|
|
16607
|
+
if (streamValidationError) {
|
|
16608
|
+
return streamValidationError;
|
|
16609
|
+
}
|
|
16610
|
+
const platformContextUrl = resolvePlatformContextUrl(msg);
|
|
16611
|
+
if (!platformContextUrl) {
|
|
16612
|
+
return "credential activity streams must have exactly one registered platform context URL in @context";
|
|
16613
|
+
}
|
|
16614
|
+
const credentialsSchemaId = getCredentialsSchemaIdByContextUrl(platformContextUrl);
|
|
16615
|
+
if (!credentialsSchemaId) {
|
|
16616
|
+
return `platform context URL ${platformContextUrl} does not have a registered credentials schema`;
|
|
16617
|
+
}
|
|
16618
|
+
return handleValidation(credentialsSchemaId, msg);
|
|
16913
16619
|
}
|
|
16914
16620
|
function validatePlatformSchema(schema) {
|
|
16915
16621
|
const validate = ajv.compile(PlatformSchema);
|
|
@@ -16920,23 +16626,54 @@ function validatePlatformSchema(schema) {
|
|
|
16920
16626
|
return "";
|
|
16921
16627
|
}
|
|
16922
16628
|
function addPlatformSchema(schema, platform_type) {
|
|
16923
|
-
|
|
16924
|
-
ajv.
|
|
16629
|
+
const schemaRef = `${schemaURL}/context/${platform_type}`;
|
|
16630
|
+
if (!ajv.getSchema(schemaRef)) {
|
|
16631
|
+
ajv.addSchema(schema, schemaRef);
|
|
16632
|
+
}
|
|
16925
16633
|
}
|
|
16926
16634
|
function getPlatformSchema(platform_type) {
|
|
16927
16635
|
return ajv.getSchema(`${schemaURL}/context/${platform_type}`);
|
|
16928
16636
|
}
|
|
16637
|
+
function addPlatformContext(platformId, platformContextUrl) {
|
|
16638
|
+
registerPlatformContext(platformId, platformContextUrl, `${schemaURL}/context/${platformId}/messages`, `${schemaURL}/context/${platformId}/credentials`);
|
|
16639
|
+
}
|
|
16640
|
+
function resolvePlatformId(msg) {
|
|
16641
|
+
const platformContextUrl = resolvePlatformContextUrl(msg);
|
|
16642
|
+
if (platformContextUrl) {
|
|
16643
|
+
const id = getPlatformIdByContextUrl(platformContextUrl);
|
|
16644
|
+
if (id)
|
|
16645
|
+
return id;
|
|
16646
|
+
}
|
|
16647
|
+
if (typeof msg.platform === "string" && msg.platform) {
|
|
16648
|
+
return msg.platform;
|
|
16649
|
+
}
|
|
16650
|
+
return null;
|
|
16651
|
+
}
|
|
16929
16652
|
export {
|
|
16930
16653
|
validatePlatformSchema,
|
|
16931
16654
|
validateCredentials,
|
|
16932
16655
|
validateActivityStream,
|
|
16933
16656
|
validateActivityObject,
|
|
16657
|
+
setValidationErrorOptions,
|
|
16658
|
+
resolvePlatformId,
|
|
16659
|
+
registerSystemPlatformContexts,
|
|
16934
16660
|
getPlatformSchema,
|
|
16661
|
+
buildCanonicalContext,
|
|
16935
16662
|
addPlatformSchema,
|
|
16663
|
+
addPlatformContext,
|
|
16664
|
+
SockethubConfigSchema,
|
|
16665
|
+
SOCKETHUB_BASE_CONTEXT_URL,
|
|
16936
16666
|
PlatformSchema,
|
|
16667
|
+
PLATFORM_CONTEXT_PREFIX,
|
|
16937
16668
|
ObjectTypesList,
|
|
16669
|
+
InternalObjectTypesList,
|
|
16670
|
+
INTERNAL_PLATFORM_ID,
|
|
16671
|
+
INTERNAL_PLATFORM_CONTEXT_URL,
|
|
16672
|
+
ERROR_PLATFORM_ID,
|
|
16673
|
+
ERROR_PLATFORM_CONTEXT_URL,
|
|
16938
16674
|
ActivityStreamSchema,
|
|
16939
|
-
ActivityObjectSchema
|
|
16675
|
+
ActivityObjectSchema,
|
|
16676
|
+
AS2_BASE_CONTEXT_URL
|
|
16940
16677
|
};
|
|
16941
16678
|
|
|
16942
|
-
//# debugId=
|
|
16679
|
+
//# debugId=6297C1FC6C040BA364756E2164756E21
|