@sockethub/schemas 3.0.0-alpha.12 → 3.0.0-alpha.13
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/activity-stream-helper.d.ts +5 -0
- package/dist/activity-stream-helper.js +36 -0
- package/dist/activity-stream-helper.js.map +10 -0
- package/dist/context.d.ts +56 -0
- package/dist/context.js +20 -41
- package/dist/context.js.map +3 -3
- package/dist/helpers/error-parser.d.ts +13 -0
- package/dist/helpers/objects.d.ts +122 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +180 -218
- package/dist/index.js.map +12 -12
- package/dist/maps/context-map.json +2 -2
- package/dist/object-types.d.ts +2 -0
- package/dist/object-types.js +296 -0
- package/dist/object-types.js.map +12 -0
- package/dist/schemas/activity-stream.d.ts +161 -0
- package/dist/schemas/platform/feeds/v1/messages.schema.json +8 -17
- package/dist/schemas/platform/irc/v1/credentials.schema.json +71 -1
- package/dist/schemas/platform/irc/v1/messages.schema.json +84 -0
- package/dist/schemas/platform/metadata/v1/messages.schema.json +1 -16
- package/dist/schemas/platform/xmpp/v1/credentials.schema.json +2 -2
- package/dist/schemas/platform/xmpp/v1/messages.schema.json +108 -0
- package/dist/schemas/platform.d.ts +62 -0
- package/dist/schemas/sockethub-config.d.ts +261 -0
- package/{src/types.ts → dist/types.d.ts} +17 -45
- package/dist/validator.d.ts +26 -0
- package/package.json +13 -8
- package/src/context.ts +0 -125
- package/src/helpers/error-parser.ts +0 -160
- package/src/helpers/objects.ts +0 -283
- package/src/index.test.data.credentials.ts +0 -103
- package/src/index.test.data.objects.ts +0 -241
- package/src/index.test.data.platform.ts +0 -48
- package/src/index.test.data.streams.ts +0 -590
- package/src/index.test.ts +0 -127
- package/src/index.ts +0 -56
- package/src/schemas/activity-object.ts +0 -19
- package/src/schemas/activity-stream.ts +0 -75
- package/src/schemas/json/activity-object.json +0 -405
- package/src/schemas/json/activity-stream.json +0 -502
- package/src/schemas/json/platform.json +0 -48
- package/src/schemas/json/sockethub-config.json +0 -236
- package/src/schemas/platform.ts +0 -71
- package/src/schemas/sockethub-config.ts +0 -220
- package/src/types/ajv-formats-draft2019.d.ts +0 -5
- package/src/validator.ts +0 -207
package/dist/index.js
CHANGED
|
@@ -4574,6 +4574,7 @@ var require_limitLength = __commonJS((exports) => {
|
|
|
4574
4574
|
var require_pattern = __commonJS((exports) => {
|
|
4575
4575
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4576
4576
|
var code_1 = require_code2();
|
|
4577
|
+
var util_1 = require_util();
|
|
4577
4578
|
var codegen_1 = require_codegen();
|
|
4578
4579
|
var error = {
|
|
4579
4580
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4586,10 +4587,18 @@ var require_pattern = __commonJS((exports) => {
|
|
|
4586
4587
|
$data: true,
|
|
4587
4588
|
error,
|
|
4588
4589
|
code(cxt) {
|
|
4589
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4590
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4590
4591
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4591
|
-
|
|
4592
|
-
|
|
4592
|
+
if ($data) {
|
|
4593
|
+
const { regExp } = it.opts.code;
|
|
4594
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4595
|
+
const valid = gen.let("valid");
|
|
4596
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4597
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4598
|
+
} else {
|
|
4599
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4600
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4601
|
+
}
|
|
4593
4602
|
}
|
|
4594
4603
|
};
|
|
4595
4604
|
exports.default = def;
|
|
@@ -15760,12 +15769,24 @@ var INTERNAL_PLATFORM_CONTEXT_URL = "https://sockethub.org/ns/context/platform/s
|
|
|
15760
15769
|
var platformContextToPlatformId = new Map;
|
|
15761
15770
|
var platformContextToSchemaId = new Map;
|
|
15762
15771
|
var platformContextToCredentialsSchemaId = new Map;
|
|
15763
|
-
function buildCanonicalContext(
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15772
|
+
function buildCanonicalContext(platform) {
|
|
15773
|
+
const platformUrl = platform.startsWith("https://") ? platform : `${PLATFORM_CONTEXT_PREFIX}${platform}/v1.jsonld`;
|
|
15774
|
+
return [AS2_BASE_CONTEXT_URL, SOCKETHUB_BASE_CONTEXT_URL, platformUrl];
|
|
15775
|
+
}
|
|
15776
|
+
function platformIdFromContext(context) {
|
|
15777
|
+
if (!Array.isArray(context)) {
|
|
15778
|
+
return;
|
|
15779
|
+
}
|
|
15780
|
+
for (const entry of context) {
|
|
15781
|
+
if (typeof entry === "string" && entry.startsWith(PLATFORM_CONTEXT_PREFIX)) {
|
|
15782
|
+
const rest = entry.slice(PLATFORM_CONTEXT_PREFIX.length);
|
|
15783
|
+
const slashIdx = rest.indexOf("/");
|
|
15784
|
+
if (slashIdx > 0) {
|
|
15785
|
+
return rest.slice(0, slashIdx);
|
|
15786
|
+
}
|
|
15787
|
+
}
|
|
15788
|
+
}
|
|
15789
|
+
return;
|
|
15769
15790
|
}
|
|
15770
15791
|
function normalizeContextArray(value) {
|
|
15771
15792
|
if (!Array.isArray(value)) {
|
|
@@ -15800,18 +15821,7 @@ function getCredentialsSchemaIdByContextUrl(platformContextUrl) {
|
|
|
15800
15821
|
}
|
|
15801
15822
|
|
|
15802
15823
|
// src/helpers/objects.ts
|
|
15803
|
-
var validObjectRefs = [];
|
|
15804
|
-
var validObjectDefs = {};
|
|
15805
15824
|
var ObjectTypesSchema = {
|
|
15806
|
-
credentials: {
|
|
15807
|
-
required: ["type"],
|
|
15808
|
-
additionalProperties: true,
|
|
15809
|
-
properties: {
|
|
15810
|
-
type: {
|
|
15811
|
-
enum: ["credentials"]
|
|
15812
|
-
}
|
|
15813
|
-
}
|
|
15814
|
-
},
|
|
15815
15825
|
feed: {
|
|
15816
15826
|
required: ["id", "type"],
|
|
15817
15827
|
additionalProperties: true,
|
|
@@ -15837,36 +15847,6 @@ var ObjectTypesSchema = {
|
|
|
15837
15847
|
}
|
|
15838
15848
|
}
|
|
15839
15849
|
},
|
|
15840
|
-
message: {
|
|
15841
|
-
required: ["type", "content"],
|
|
15842
|
-
additionalProperties: true,
|
|
15843
|
-
properties: {
|
|
15844
|
-
type: {
|
|
15845
|
-
enum: ["message"]
|
|
15846
|
-
},
|
|
15847
|
-
id: {
|
|
15848
|
-
type: "string"
|
|
15849
|
-
},
|
|
15850
|
-
name: {
|
|
15851
|
-
type: "string"
|
|
15852
|
-
},
|
|
15853
|
-
content: {
|
|
15854
|
-
type: "string"
|
|
15855
|
-
}
|
|
15856
|
-
}
|
|
15857
|
-
},
|
|
15858
|
-
me: {
|
|
15859
|
-
required: ["type", "content"],
|
|
15860
|
-
additionalProperties: true,
|
|
15861
|
-
properties: {
|
|
15862
|
-
type: {
|
|
15863
|
-
enum: ["me"]
|
|
15864
|
-
},
|
|
15865
|
-
content: {
|
|
15866
|
-
type: "string"
|
|
15867
|
-
}
|
|
15868
|
-
}
|
|
15869
|
-
},
|
|
15870
15850
|
person: {
|
|
15871
15851
|
required: ["id", "type"],
|
|
15872
15852
|
additionalProperties: true,
|
|
@@ -15943,71 +15923,6 @@ var ObjectTypesSchema = {
|
|
|
15943
15923
|
}
|
|
15944
15924
|
}
|
|
15945
15925
|
},
|
|
15946
|
-
attendance: {
|
|
15947
|
-
required: ["type"],
|
|
15948
|
-
additionalProperties: false,
|
|
15949
|
-
properties: {
|
|
15950
|
-
type: {
|
|
15951
|
-
enum: ["attendance"]
|
|
15952
|
-
},
|
|
15953
|
-
members: {
|
|
15954
|
-
type: "array",
|
|
15955
|
-
items: {
|
|
15956
|
-
type: "string"
|
|
15957
|
-
}
|
|
15958
|
-
}
|
|
15959
|
-
}
|
|
15960
|
-
},
|
|
15961
|
-
presence: {
|
|
15962
|
-
required: ["type"],
|
|
15963
|
-
additionalProperties: false,
|
|
15964
|
-
properties: {
|
|
15965
|
-
type: {
|
|
15966
|
-
enum: ["presence"]
|
|
15967
|
-
},
|
|
15968
|
-
presence: {
|
|
15969
|
-
enum: ["away", "chat", "dnd", "xa", "offline", "online"]
|
|
15970
|
-
},
|
|
15971
|
-
role: {
|
|
15972
|
-
enum: ["owner", "member", "participant", "admin"]
|
|
15973
|
-
},
|
|
15974
|
-
content: {
|
|
15975
|
-
type: "string"
|
|
15976
|
-
}
|
|
15977
|
-
}
|
|
15978
|
-
},
|
|
15979
|
-
relationship: {
|
|
15980
|
-
required: ["type", "relationship"],
|
|
15981
|
-
additionalProperties: false,
|
|
15982
|
-
properties: {
|
|
15983
|
-
type: {
|
|
15984
|
-
enum: ["relationship"]
|
|
15985
|
-
},
|
|
15986
|
-
relationship: {
|
|
15987
|
-
enum: ["role"]
|
|
15988
|
-
},
|
|
15989
|
-
subject: {
|
|
15990
|
-
type: "object",
|
|
15991
|
-
oneOf: [{ $ref: "#/definitions/type/presence" }]
|
|
15992
|
-
},
|
|
15993
|
-
object: {
|
|
15994
|
-
type: "object",
|
|
15995
|
-
oneOf: validObjectRefs
|
|
15996
|
-
}
|
|
15997
|
-
}
|
|
15998
|
-
},
|
|
15999
|
-
topic: {
|
|
16000
|
-
required: ["type"],
|
|
16001
|
-
additionalProperties: false,
|
|
16002
|
-
properties: {
|
|
16003
|
-
type: {
|
|
16004
|
-
enum: ["topic"]
|
|
16005
|
-
},
|
|
16006
|
-
content: {
|
|
16007
|
-
type: "string"
|
|
16008
|
-
}
|
|
16009
|
-
}
|
|
16010
|
-
},
|
|
16011
15926
|
address: {
|
|
16012
15927
|
required: ["type"],
|
|
16013
15928
|
additionalProperties: false,
|
|
@@ -16016,18 +15931,6 @@ var ObjectTypesSchema = {
|
|
|
16016
15931
|
enum: ["address"]
|
|
16017
15932
|
}
|
|
16018
15933
|
}
|
|
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
|
-
}
|
|
16031
15934
|
}
|
|
16032
15935
|
};
|
|
16033
15936
|
var InternalObjectTypesList = ["platform", "heartbeat"];
|
|
@@ -16055,36 +15958,8 @@ var validActorRefs = ActorTypesList.map((type) => ({
|
|
|
16055
15958
|
var validTargetRefs = TargetTypesList.map((type) => ({
|
|
16056
15959
|
$ref: `#/definitions/type/${type}`
|
|
16057
15960
|
}));
|
|
16058
|
-
for (const type of ObjectTypesList) {
|
|
16059
|
-
if (type === "credentials") {
|
|
16060
|
-
continue;
|
|
16061
|
-
}
|
|
16062
|
-
validObjectRefs.push({ $ref: `#/definitions/type/${type}` });
|
|
16063
|
-
validObjectDefs[type] = ObjectTypesSchema[type];
|
|
16064
|
-
}
|
|
16065
|
-
|
|
16066
|
-
// src/schemas/activity-object.ts
|
|
16067
|
-
var ActivityObjectSchema = {
|
|
16068
|
-
$id: "https://sockethub.org/schemas/v/activity-object.json",
|
|
16069
|
-
description: "Schema for Sockethub Activity Objects",
|
|
16070
|
-
type: "object",
|
|
16071
|
-
required: ["object"],
|
|
16072
|
-
properties: {
|
|
16073
|
-
object: {
|
|
16074
|
-
type: "object",
|
|
16075
|
-
oneOf: validObjectRefs
|
|
16076
|
-
}
|
|
16077
|
-
},
|
|
16078
|
-
definitions: {
|
|
16079
|
-
type: validObjectDefs
|
|
16080
|
-
}
|
|
16081
|
-
};
|
|
16082
15961
|
|
|
16083
15962
|
// src/schemas/activity-stream.ts
|
|
16084
|
-
var validObjectRefs2 = [];
|
|
16085
|
-
for (const type of ObjectTypesList) {
|
|
16086
|
-
validObjectRefs2.push({ $ref: `#/definitions/type/${type}` });
|
|
16087
|
-
}
|
|
16088
15963
|
var contextSchema = {
|
|
16089
15964
|
type: "array",
|
|
16090
15965
|
minItems: 3,
|
|
@@ -16113,6 +15988,7 @@ var ActivityStreamSchema = {
|
|
|
16113
15988
|
description: "Schema for Sockethub Activity Streams",
|
|
16114
15989
|
type: "object",
|
|
16115
15990
|
required: ["@context", "type", "actor"],
|
|
15991
|
+
additionalProperties: false,
|
|
16116
15992
|
properties: {
|
|
16117
15993
|
"@context": contextSchema,
|
|
16118
15994
|
id: {
|
|
@@ -16128,8 +16004,7 @@ var ActivityStreamSchema = {
|
|
|
16128
16004
|
oneOf: validTargetRefs
|
|
16129
16005
|
},
|
|
16130
16006
|
object: {
|
|
16131
|
-
type: "object"
|
|
16132
|
-
oneOf: validObjectRefs2
|
|
16007
|
+
type: "object"
|
|
16133
16008
|
},
|
|
16134
16009
|
published: {
|
|
16135
16010
|
type: "string",
|
|
@@ -16180,6 +16055,10 @@ var PlatformSchema = {
|
|
|
16180
16055
|
title: "messages",
|
|
16181
16056
|
type: "object"
|
|
16182
16057
|
},
|
|
16058
|
+
responses: {
|
|
16059
|
+
title: "responses",
|
|
16060
|
+
type: "object"
|
|
16061
|
+
},
|
|
16183
16062
|
name: {
|
|
16184
16063
|
title: "name",
|
|
16185
16064
|
type: "string"
|
|
@@ -16192,11 +16071,6 @@ var PlatformSchema = {
|
|
|
16192
16071
|
};
|
|
16193
16072
|
|
|
16194
16073
|
// src/schemas/sockethub-config.ts
|
|
16195
|
-
var connectConfigPlatforms = {
|
|
16196
|
-
connectTimeoutMs: {
|
|
16197
|
-
type: "number"
|
|
16198
|
-
}
|
|
16199
|
-
};
|
|
16200
16074
|
var SockethubConfigSchema = {
|
|
16201
16075
|
$id: "https://sockethub.org/schemas/v/sockethub-config.json",
|
|
16202
16076
|
description: "Sockethub Config Schema",
|
|
@@ -16211,6 +16085,10 @@ var SockethubConfigSchema = {
|
|
|
16211
16085
|
type: "boolean",
|
|
16212
16086
|
default: true
|
|
16213
16087
|
},
|
|
16088
|
+
info: {
|
|
16089
|
+
type: "boolean",
|
|
16090
|
+
default: false
|
|
16091
|
+
},
|
|
16214
16092
|
logging: {
|
|
16215
16093
|
type: "object",
|
|
16216
16094
|
additionalProperties: false,
|
|
@@ -16231,71 +16109,76 @@ var SockethubConfigSchema = {
|
|
|
16231
16109
|
}
|
|
16232
16110
|
}
|
|
16233
16111
|
},
|
|
16112
|
+
platforms: {
|
|
16113
|
+
type: "array",
|
|
16114
|
+
items: {
|
|
16115
|
+
type: "string"
|
|
16116
|
+
},
|
|
16117
|
+
default: [
|
|
16118
|
+
"@sockethub/platform-dummy",
|
|
16119
|
+
"@sockethub/platform-feeds",
|
|
16120
|
+
"@sockethub/platform-irc",
|
|
16121
|
+
"@sockethub/platform-metadata",
|
|
16122
|
+
"@sockethub/platform-xmpp"
|
|
16123
|
+
]
|
|
16124
|
+
},
|
|
16234
16125
|
packageConfig: {
|
|
16235
16126
|
type: "object",
|
|
16236
16127
|
properties: {
|
|
16237
|
-
"@sockethub/
|
|
16128
|
+
"@sockethub/platform-dummy": {
|
|
16238
16129
|
type: "object",
|
|
16239
16130
|
additionalProperties: false,
|
|
16240
16131
|
properties: {
|
|
16241
|
-
|
|
16242
|
-
type: "array",
|
|
16243
|
-
items: {
|
|
16244
|
-
type: "string"
|
|
16245
|
-
},
|
|
16246
|
-
default: ["credentials"]
|
|
16247
|
-
},
|
|
16248
|
-
failOnUnknownObjectProperties: {
|
|
16249
|
-
type: "boolean",
|
|
16250
|
-
default: true
|
|
16251
|
-
}
|
|
16132
|
+
greeting: { type: "string", default: "Hello" }
|
|
16252
16133
|
}
|
|
16253
16134
|
},
|
|
16254
|
-
"@sockethub/platform-
|
|
16135
|
+
"@sockethub/platform-feeds": {
|
|
16255
16136
|
type: "object",
|
|
16256
16137
|
additionalProperties: false,
|
|
16257
16138
|
properties: {
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
}
|
|
16139
|
+
connectTimeoutMs: { type: "number" },
|
|
16140
|
+
allowPrivateAddresses: { type: "boolean" },
|
|
16141
|
+
concurrency: { type: "integer", minimum: 1 }
|
|
16262
16142
|
}
|
|
16263
16143
|
},
|
|
16264
|
-
"@sockethub/platform-
|
|
16144
|
+
"@sockethub/platform-irc": {
|
|
16265
16145
|
type: "object",
|
|
16266
16146
|
additionalProperties: false,
|
|
16267
16147
|
properties: {
|
|
16268
|
-
|
|
16148
|
+
connectTimeoutMs: { type: "number" }
|
|
16269
16149
|
}
|
|
16270
16150
|
},
|
|
16271
|
-
"@sockethub/platform-
|
|
16151
|
+
"@sockethub/platform-xmpp": {
|
|
16272
16152
|
type: "object",
|
|
16273
16153
|
additionalProperties: false,
|
|
16274
16154
|
properties: {
|
|
16275
|
-
|
|
16155
|
+
connectTimeoutMs: { type: "number" }
|
|
16276
16156
|
}
|
|
16277
16157
|
},
|
|
16278
|
-
"@sockethub/platform-
|
|
16158
|
+
"@sockethub/platform-metadata": {
|
|
16279
16159
|
type: "object",
|
|
16280
16160
|
additionalProperties: false,
|
|
16281
16161
|
properties: {
|
|
16282
|
-
|
|
16162
|
+
allowPrivateAddresses: { type: "boolean" },
|
|
16163
|
+
concurrency: { type: "integer", minimum: 1 }
|
|
16283
16164
|
}
|
|
16284
16165
|
}
|
|
16285
16166
|
}
|
|
16286
16167
|
},
|
|
16287
|
-
|
|
16288
|
-
type: "
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16168
|
+
credentialCheck: {
|
|
16169
|
+
type: "object",
|
|
16170
|
+
additionalProperties: false,
|
|
16171
|
+
properties: {
|
|
16172
|
+
reconnectIpSource: {
|
|
16173
|
+
type: "string",
|
|
16174
|
+
enum: ["socket", "proxy"],
|
|
16175
|
+
default: "socket"
|
|
16176
|
+
},
|
|
16177
|
+
proxyHeader: {
|
|
16178
|
+
type: "string",
|
|
16179
|
+
default: "x-forwarded-for"
|
|
16180
|
+
}
|
|
16181
|
+
}
|
|
16299
16182
|
},
|
|
16300
16183
|
public: {
|
|
16301
16184
|
type: "object",
|
|
@@ -16334,6 +16217,22 @@ var SockethubConfigSchema = {
|
|
|
16334
16217
|
blockDurationMs: {
|
|
16335
16218
|
type: "number",
|
|
16336
16219
|
default: 5000
|
|
16220
|
+
},
|
|
16221
|
+
maxConnectionsPerIp: {
|
|
16222
|
+
type: "number",
|
|
16223
|
+
minimum: 0,
|
|
16224
|
+
default: 0
|
|
16225
|
+
}
|
|
16226
|
+
}
|
|
16227
|
+
},
|
|
16228
|
+
limits: {
|
|
16229
|
+
type: "object",
|
|
16230
|
+
additionalProperties: false,
|
|
16231
|
+
properties: {
|
|
16232
|
+
maxPlatformInstances: {
|
|
16233
|
+
type: "number",
|
|
16234
|
+
minimum: 0,
|
|
16235
|
+
default: 0
|
|
16337
16236
|
}
|
|
16338
16237
|
}
|
|
16339
16238
|
},
|
|
@@ -16391,6 +16290,16 @@ var SockethubConfigSchema = {
|
|
|
16391
16290
|
path: {
|
|
16392
16291
|
type: "string",
|
|
16393
16292
|
default: "/sockethub"
|
|
16293
|
+
},
|
|
16294
|
+
cors: {
|
|
16295
|
+
type: "object",
|
|
16296
|
+
additionalProperties: false,
|
|
16297
|
+
properties: {
|
|
16298
|
+
origin: {
|
|
16299
|
+
type: "string",
|
|
16300
|
+
default: "*"
|
|
16301
|
+
}
|
|
16302
|
+
}
|
|
16394
16303
|
}
|
|
16395
16304
|
}
|
|
16396
16305
|
},
|
|
@@ -16525,7 +16434,6 @@ var schemas = {};
|
|
|
16525
16434
|
var validationErrorOptions = {};
|
|
16526
16435
|
var systemContextsRegistered = false;
|
|
16527
16436
|
schemas[`${schemaURL}/activity-stream`] = ActivityStreamSchema;
|
|
16528
|
-
schemas[`${schemaURL}/activity-object`] = ActivityObjectSchema;
|
|
16529
16437
|
for (const uri in schemas) {
|
|
16530
16438
|
ajv.addSchema(schemas[uri], uri);
|
|
16531
16439
|
}
|
|
@@ -16549,17 +16457,12 @@ function registerSystemPlatformContexts() {
|
|
|
16549
16457
|
systemContextsRegistered = true;
|
|
16550
16458
|
}
|
|
16551
16459
|
registerSystemPlatformContexts();
|
|
16552
|
-
function handleValidation(schemaRef, msg
|
|
16460
|
+
function handleValidation(schemaRef, msg) {
|
|
16553
16461
|
const validator = ajv.getSchema(schemaRef);
|
|
16554
16462
|
if (!validator) {
|
|
16555
16463
|
return `schema ${schemaRef} not found`;
|
|
16556
16464
|
}
|
|
16557
|
-
|
|
16558
|
-
if (isObject) {
|
|
16559
|
-
result = validator({ object: msg });
|
|
16560
|
-
} else {
|
|
16561
|
-
result = validator(msg);
|
|
16562
|
-
}
|
|
16465
|
+
const result = validator(msg);
|
|
16563
16466
|
if (!result) {
|
|
16564
16467
|
let errorMessage = getErrorMessage(msg, validator.errors, validationErrorOptions);
|
|
16565
16468
|
if (Array.isArray(msg["@context"])) {
|
|
@@ -16578,8 +16481,17 @@ function handleValidation(schemaRef, msg, isObject = false) {
|
|
|
16578
16481
|
function setValidationErrorOptions(options) {
|
|
16579
16482
|
validationErrorOptions = { ...validationErrorOptions, ...options };
|
|
16580
16483
|
}
|
|
16581
|
-
|
|
16582
|
-
|
|
16484
|
+
var sockethubConfigValidator;
|
|
16485
|
+
function validateSockethubConfig(config) {
|
|
16486
|
+
if (!sockethubConfigValidator) {
|
|
16487
|
+
sockethubConfigValidator = ajv.compile(SockethubConfigSchema);
|
|
16488
|
+
}
|
|
16489
|
+
if (sockethubConfigValidator(config)) {
|
|
16490
|
+
return "";
|
|
16491
|
+
}
|
|
16492
|
+
return ajv.errorsText(sockethubConfigValidator.errors, {
|
|
16493
|
+
dataVar: "config"
|
|
16494
|
+
});
|
|
16583
16495
|
}
|
|
16584
16496
|
function validateActivityStream(msg) {
|
|
16585
16497
|
const streamValidationError = handleValidation(`${schemaURL}/activity-stream`, msg);
|
|
@@ -16596,6 +16508,21 @@ function validateActivityStream(msg) {
|
|
|
16596
16508
|
}
|
|
16597
16509
|
return handleValidation(schemaId, msg);
|
|
16598
16510
|
}
|
|
16511
|
+
function validateActivityStreamResponse(msg) {
|
|
16512
|
+
const platformContextUrl = resolvePlatformContextUrl(msg);
|
|
16513
|
+
if (!platformContextUrl) {
|
|
16514
|
+
return "";
|
|
16515
|
+
}
|
|
16516
|
+
const platformId = getPlatformIdByContextUrl(platformContextUrl);
|
|
16517
|
+
if (!platformId) {
|
|
16518
|
+
return "";
|
|
16519
|
+
}
|
|
16520
|
+
const responsesSchemaId = `${schemaURL}/context/${platformId}/responses`;
|
|
16521
|
+
if (!ajv.getSchema(responsesSchemaId)) {
|
|
16522
|
+
return "";
|
|
16523
|
+
}
|
|
16524
|
+
return handleValidation(responsesSchemaId, msg);
|
|
16525
|
+
}
|
|
16599
16526
|
function validateCredentials(msg) {
|
|
16600
16527
|
if (!Array.isArray(msg["@context"])) {
|
|
16601
16528
|
return "credential activity streams must have an @context set";
|
|
@@ -16621,7 +16548,12 @@ function validatePlatformSchema(schema) {
|
|
|
16621
16548
|
const validate = ajv.compile(PlatformSchema);
|
|
16622
16549
|
const err = validate(schema);
|
|
16623
16550
|
if (!err) {
|
|
16624
|
-
|
|
16551
|
+
const validationError = validate.errors[0];
|
|
16552
|
+
let message = `${validationError.instancePath} ${validationError.message}`;
|
|
16553
|
+
if (validationError.keyword === "additionalProperties") {
|
|
16554
|
+
message += `: ${validationError.params.additionalProperty}`;
|
|
16555
|
+
}
|
|
16556
|
+
return `platform schema failed to validate: ${message}`;
|
|
16625
16557
|
}
|
|
16626
16558
|
return "";
|
|
16627
16559
|
}
|
|
@@ -16639,24 +16571,54 @@ function addPlatformContext(platformId, platformContextUrl) {
|
|
|
16639
16571
|
}
|
|
16640
16572
|
function resolvePlatformId(msg) {
|
|
16641
16573
|
const platformContextUrl = resolvePlatformContextUrl(msg);
|
|
16642
|
-
if (platformContextUrl) {
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16574
|
+
if (!platformContextUrl) {
|
|
16575
|
+
return null;
|
|
16576
|
+
}
|
|
16577
|
+
return getPlatformIdByContextUrl(platformContextUrl) ?? null;
|
|
16578
|
+
}
|
|
16579
|
+
|
|
16580
|
+
// src/activity-stream-helper.ts
|
|
16581
|
+
var stringRefKeys = {
|
|
16582
|
+
actor: "id",
|
|
16583
|
+
target: "id",
|
|
16584
|
+
object: "content"
|
|
16585
|
+
};
|
|
16586
|
+
function normalizeStringRef(value, primaryKey) {
|
|
16587
|
+
if (typeof value === "string") {
|
|
16588
|
+
return { [primaryKey]: value };
|
|
16646
16589
|
}
|
|
16647
|
-
if (
|
|
16648
|
-
return
|
|
16590
|
+
if (Array.isArray(value)) {
|
|
16591
|
+
return value.map((entry) => {
|
|
16592
|
+
if (typeof entry === "string") {
|
|
16593
|
+
return { id: entry };
|
|
16594
|
+
}
|
|
16595
|
+
return entry;
|
|
16596
|
+
});
|
|
16597
|
+
}
|
|
16598
|
+
return value;
|
|
16599
|
+
}
|
|
16600
|
+
function normalizeActivityStream(meta) {
|
|
16601
|
+
const stream = {
|
|
16602
|
+
...meta
|
|
16603
|
+
};
|
|
16604
|
+
for (const key of Object.keys(stringRefKeys)) {
|
|
16605
|
+
if (key in stream) {
|
|
16606
|
+
stream[key] = normalizeStringRef(stream[key], stringRefKeys[key]);
|
|
16607
|
+
}
|
|
16649
16608
|
}
|
|
16650
|
-
return
|
|
16609
|
+
return stream;
|
|
16651
16610
|
}
|
|
16652
16611
|
export {
|
|
16612
|
+
validateSockethubConfig,
|
|
16653
16613
|
validatePlatformSchema,
|
|
16654
16614
|
validateCredentials,
|
|
16615
|
+
validateActivityStreamResponse,
|
|
16655
16616
|
validateActivityStream,
|
|
16656
|
-
validateActivityObject,
|
|
16657
16617
|
setValidationErrorOptions,
|
|
16658
16618
|
resolvePlatformId,
|
|
16659
16619
|
registerSystemPlatformContexts,
|
|
16620
|
+
platformIdFromContext,
|
|
16621
|
+
normalizeActivityStream,
|
|
16660
16622
|
getPlatformSchema,
|
|
16661
16623
|
buildCanonicalContext,
|
|
16662
16624
|
addPlatformSchema,
|
|
@@ -16665,6 +16627,7 @@ export {
|
|
|
16665
16627
|
SOCKETHUB_BASE_CONTEXT_URL,
|
|
16666
16628
|
PlatformSchema,
|
|
16667
16629
|
PLATFORM_CONTEXT_PREFIX,
|
|
16630
|
+
ObjectTypesSchema,
|
|
16668
16631
|
ObjectTypesList,
|
|
16669
16632
|
InternalObjectTypesList,
|
|
16670
16633
|
INTERNAL_PLATFORM_ID,
|
|
@@ -16672,8 +16635,7 @@ export {
|
|
|
16672
16635
|
ERROR_PLATFORM_ID,
|
|
16673
16636
|
ERROR_PLATFORM_CONTEXT_URL,
|
|
16674
16637
|
ActivityStreamSchema,
|
|
16675
|
-
ActivityObjectSchema,
|
|
16676
16638
|
AS2_BASE_CONTEXT_URL
|
|
16677
16639
|
};
|
|
16678
16640
|
|
|
16679
|
-
//# debugId=
|
|
16641
|
+
//# debugId=E0C024B0EB3D053564756E2164756E21
|