@kkuffour/solid-moderation-plugin 0.1.0
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/CONFIG-GUIDE.md +49 -0
- package/DEVELOPMENT.md +129 -0
- package/ENV-VARIABLES.md +137 -0
- package/INSTALLATION.md +90 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +81 -0
- package/PRODUCTION.md +186 -0
- package/PUBLISHING.md +104 -0
- package/README.md +53 -0
- package/TESTING.md +64 -0
- package/components/components.jsonld +17 -0
- package/components/context.jsonld +211 -0
- package/config/context.jsonld +15 -0
- package/config/default.json +80 -0
- package/dist/ModerationConfig.d.ts +16 -0
- package/dist/ModerationConfig.d.ts.map +1 -0
- package/dist/ModerationConfig.js +18 -0
- package/dist/ModerationConfig.js.map +1 -0
- package/dist/ModerationConfig.jsonld +66 -0
- package/dist/ModerationMixin.d.ts +13 -0
- package/dist/ModerationMixin.d.ts.map +1 -0
- package/dist/ModerationMixin.js +136 -0
- package/dist/ModerationMixin.js.map +1 -0
- package/dist/ModerationMixin.jsonld +180 -0
- package/dist/ModerationOperationHandler.d.ts +16 -0
- package/dist/ModerationOperationHandler.d.ts.map +1 -0
- package/dist/ModerationOperationHandler.js +45 -0
- package/dist/ModerationOperationHandler.js.map +1 -0
- package/dist/ModerationOperationHandler.jsonld +140 -0
- package/dist/ModerationRecord.d.ts +20 -0
- package/dist/ModerationRecord.d.ts.map +1 -0
- package/dist/ModerationRecord.js +3 -0
- package/dist/ModerationRecord.js.map +1 -0
- package/dist/ModerationRecord.jsonld +59 -0
- package/dist/ModerationStore.d.ts +12 -0
- package/dist/ModerationStore.d.ts.map +1 -0
- package/dist/ModerationStore.js +37 -0
- package/dist/ModerationStore.js.map +1 -0
- package/dist/ModerationStore.jsonld +59 -0
- package/dist/components/components.jsonld +17 -0
- package/dist/components/context.jsonld +211 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/SightEngineProvider.d.ts +52 -0
- package/dist/providers/SightEngineProvider.d.ts.map +1 -0
- package/dist/providers/SightEngineProvider.js +302 -0
- package/dist/providers/SightEngineProvider.js.map +1 -0
- package/dist/providers/SightEngineProvider.jsonld +209 -0
- package/dist/util/GuardedStream.d.ts +33 -0
- package/dist/util/GuardedStream.d.ts.map +1 -0
- package/dist/util/GuardedStream.js +89 -0
- package/dist/util/GuardedStream.js.map +1 -0
- package/package.json +40 -0
- package/simple-test.json +7 -0
- package/src/ModerationConfig.ts +29 -0
- package/src/ModerationMixin.ts +153 -0
- package/src/ModerationOperationHandler.ts +64 -0
- package/src/ModerationRecord.ts +19 -0
- package/src/ModerationStore.ts +41 -0
- package/src/index.ts +6 -0
- package/src/providers/SightEngineProvider.ts +367 -0
- package/src/util/GuardedStream.ts +101 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationMixin.d.ts","sourceRoot":"","sources":["../src/ModerationMixin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,qBAAa,eAAe;IAC1B,SAAS,CAAC,QAAQ,CAAC,MAAM,2CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAkB;gBAEhC,gBAAgB,EAAE,gBAAgB;IAOxC,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;YAenD,oBAAoB;YAwCpB,mBAAmB;YAuCnB,oBAAoB;CAsCnC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModerationMixin = void 0;
|
|
4
|
+
const node_stream_1 = require("node:stream");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const community_server_1 = require("@solid/community-server");
|
|
7
|
+
const SightEngineProvider_1 = require("./providers/SightEngineProvider");
|
|
8
|
+
const ModerationStore_1 = require("./ModerationStore");
|
|
9
|
+
class ModerationMixin {
|
|
10
|
+
constructor(moderationConfig) {
|
|
11
|
+
this.logger = (0, community_server_1.getLoggerFor)(this);
|
|
12
|
+
this.moderationConfig = moderationConfig;
|
|
13
|
+
this.moderationStore = moderationConfig.auditLoggingEnabled ?
|
|
14
|
+
new ModerationStore_1.ModerationStore(moderationConfig.auditLoggingStorePath) :
|
|
15
|
+
undefined;
|
|
16
|
+
}
|
|
17
|
+
async moderateContent(operation) {
|
|
18
|
+
if (!this.moderationConfig.enabled || !operation.body?.data) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const contentType = operation.body.metadata.contentType;
|
|
22
|
+
if (contentType?.startsWith('image/') && this.moderationConfig.imagesEnabled) {
|
|
23
|
+
await this.moderateImageContent(operation);
|
|
24
|
+
}
|
|
25
|
+
else if (contentType?.startsWith('text/') && this.moderationConfig.textEnabled) {
|
|
26
|
+
await this.moderateTextContent(operation);
|
|
27
|
+
}
|
|
28
|
+
else if (contentType?.startsWith('video/') && this.moderationConfig.videoEnabled) {
|
|
29
|
+
await this.moderateVideoContent(operation);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async moderateImageContent(operation) {
|
|
33
|
+
const chunks = [];
|
|
34
|
+
for await (const chunk of operation.body.data) {
|
|
35
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
36
|
+
}
|
|
37
|
+
const buffer = Buffer.concat(chunks);
|
|
38
|
+
operation.body.data = (0, community_server_1.guardStream)(node_stream_1.Readable.from(buffer));
|
|
39
|
+
const tempFile = `/tmp/moderation_${Date.now()}.jpg`;
|
|
40
|
+
await node_fs_1.promises.writeFile(tempFile, buffer);
|
|
41
|
+
try {
|
|
42
|
+
const client = new SightEngineProvider_1.SightEngineProvider(this.moderationConfig.sightEngineApiUser, this.moderationConfig.sightEngineApiSecret);
|
|
43
|
+
const result = await client.analyzeImage(tempFile);
|
|
44
|
+
this.logger.info(`MODERATION: Image analysis result - nudity score: ${result.nudity?.raw}, threshold: ${this.moderationConfig.imageNudityThreshold}`);
|
|
45
|
+
if (result.nudity?.raw && result.nudity.raw > this.moderationConfig.imageNudityThreshold) {
|
|
46
|
+
if (this.moderationStore) {
|
|
47
|
+
await this.moderationStore.recordViolation({
|
|
48
|
+
contentType: 'image',
|
|
49
|
+
resourcePath: operation.target.path,
|
|
50
|
+
violations: [{ model: 'nudity', score: result.nudity.raw, threshold: this.moderationConfig.imageNudityThreshold }],
|
|
51
|
+
contentSize: buffer.length,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
throw new community_server_1.ForbiddenHttpError('Upload blocked: Content violates community guidelines');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof community_server_1.ForbiddenHttpError) {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
this.logger.warn(`MODERATION: Image check failed (fail-open): ${error}`);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
await node_fs_1.promises.unlink(tempFile).catch(() => { });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async moderateTextContent(operation) {
|
|
68
|
+
const chunks = [];
|
|
69
|
+
for await (const chunk of operation.body.data) {
|
|
70
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
71
|
+
}
|
|
72
|
+
const buffer = Buffer.concat(chunks);
|
|
73
|
+
const text = buffer.toString('utf8');
|
|
74
|
+
operation.body.data = (0, community_server_1.guardStream)(node_stream_1.Readable.from(buffer));
|
|
75
|
+
if (!text?.trim()) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const client = new SightEngineProvider_1.SightEngineProvider(this.moderationConfig.sightEngineApiUser, this.moderationConfig.sightEngineApiSecret);
|
|
80
|
+
const result = await client.analyzeText(text);
|
|
81
|
+
if (result.sexual > this.moderationConfig.textSexualThreshold || result.toxic > this.moderationConfig.textToxicThreshold) {
|
|
82
|
+
if (this.moderationStore) {
|
|
83
|
+
await this.moderationStore.recordViolation({
|
|
84
|
+
contentType: 'text',
|
|
85
|
+
resourcePath: operation.target.path,
|
|
86
|
+
violations: [{ model: 'text', score: Math.max(result.sexual, result.toxic), threshold: Math.min(this.moderationConfig.textSexualThreshold, this.moderationConfig.textToxicThreshold) }],
|
|
87
|
+
contentSize: buffer.length,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
throw new community_server_1.ForbiddenHttpError('Upload blocked: Content violates community guidelines');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof community_server_1.ForbiddenHttpError) {
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
this.logger.warn(`MODERATION: Text check failed (fail-open): ${error}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async moderateVideoContent(operation) {
|
|
101
|
+
const chunks = [];
|
|
102
|
+
for await (const chunk of operation.body.data) {
|
|
103
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
104
|
+
}
|
|
105
|
+
const buffer = Buffer.concat(chunks);
|
|
106
|
+
operation.body.data = (0, community_server_1.guardStream)(node_stream_1.Readable.from(buffer));
|
|
107
|
+
const tempFile = `/tmp/moderation_${Date.now()}.mp4`;
|
|
108
|
+
await node_fs_1.promises.writeFile(tempFile, buffer);
|
|
109
|
+
try {
|
|
110
|
+
const client = new SightEngineProvider_1.SightEngineProvider(this.moderationConfig.sightEngineApiUser, this.moderationConfig.sightEngineApiSecret);
|
|
111
|
+
const result = await client.analyzeVideo(tempFile);
|
|
112
|
+
if (result.nudity?.raw && result.nudity.raw > this.moderationConfig.videoNudityThreshold) {
|
|
113
|
+
if (this.moderationStore) {
|
|
114
|
+
await this.moderationStore.recordViolation({
|
|
115
|
+
contentType: 'video',
|
|
116
|
+
resourcePath: operation.target.path,
|
|
117
|
+
violations: [{ model: 'nudity', score: result.nudity.raw, threshold: this.moderationConfig.videoNudityThreshold }],
|
|
118
|
+
contentSize: buffer.length,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
throw new community_server_1.ForbiddenHttpError('Upload blocked: Content violates community guidelines');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (error instanceof community_server_1.ForbiddenHttpError) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
this.logger.warn(`MODERATION: Video check failed (fail-open): ${error}`);
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
await node_fs_1.promises.unlink(tempFile).catch(() => { });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.ModerationMixin = ModerationMixin;
|
|
136
|
+
//# sourceMappingURL=ModerationMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationMixin.js","sourceRoot":"","sources":["../src/ModerationMixin.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,qCAAyC;AAEzC,8DAAwF;AAExF,yEAAsE;AACtE,uDAAoD;AAEpD,MAAa,eAAe;IAK1B,YAAmB,gBAAkC;QAJlC,WAAM,GAAG,IAAA,+BAAY,EAAC,IAAI,CAAC,CAAC;QAK7C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;YAC3D,IAAI,iCAAe,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC,CAAC;YAC7D,SAAS,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB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CAAC,CAAC;QAC3E,CAAC;gBAAS,CAAC;YACT,MAAM,kBAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AAhJD,0CAgJC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.1.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.1.0/config/context.jsonld"
|
|
5
|
+
],
|
|
6
|
+
"@id": "npmd:@kkuffour/solid-moderation-plugin",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin",
|
|
10
|
+
"@type": "Class",
|
|
11
|
+
"requireElement": "ModerationMixin",
|
|
12
|
+
"parameters": [
|
|
13
|
+
{
|
|
14
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_enabled",
|
|
15
|
+
"range": "xsd:boolean"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingEnabled",
|
|
19
|
+
"range": "xsd:boolean"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingStorePath",
|
|
23
|
+
"range": "xsd:string"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiUser",
|
|
27
|
+
"range": "xsd:string"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiSecret",
|
|
31
|
+
"range": "xsd:string"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imagesEnabled",
|
|
35
|
+
"range": "xsd:boolean"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textEnabled",
|
|
39
|
+
"range": "xsd:boolean"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoEnabled",
|
|
43
|
+
"range": "xsd:boolean"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imageNudityThreshold",
|
|
47
|
+
"range": "xsd:number"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textSexualThreshold",
|
|
51
|
+
"range": "xsd:number"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textToxicThreshold",
|
|
55
|
+
"range": "xsd:number"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoNudityThreshold",
|
|
59
|
+
"range": "xsd:number"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"memberFields": [
|
|
63
|
+
{
|
|
64
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_logger",
|
|
65
|
+
"memberFieldName": "logger",
|
|
66
|
+
"range": {
|
|
67
|
+
"@type": "ParameterRangeWildcard"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_moderationConfig",
|
|
72
|
+
"memberFieldName": "moderationConfig"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_moderationStore",
|
|
76
|
+
"memberFieldName": "moderationStore"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_constructor",
|
|
80
|
+
"memberFieldName": "constructor"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_moderateContent",
|
|
84
|
+
"memberFieldName": "moderateContent"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_moderateImageContent",
|
|
88
|
+
"memberFieldName": "moderateImageContent"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_moderateTextContent",
|
|
92
|
+
"memberFieldName": "moderateTextContent"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin__member_moderateVideoContent",
|
|
96
|
+
"memberFieldName": "moderateVideoContent"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"constructorArguments": [
|
|
100
|
+
{
|
|
101
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig__constructorArgument",
|
|
102
|
+
"fields": [
|
|
103
|
+
{
|
|
104
|
+
"keyRaw": "enabled",
|
|
105
|
+
"value": {
|
|
106
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_enabled"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"keyRaw": "auditLoggingEnabled",
|
|
111
|
+
"value": {
|
|
112
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingEnabled"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"keyRaw": "auditLoggingStorePath",
|
|
117
|
+
"value": {
|
|
118
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingStorePath"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"keyRaw": "sightEngineApiUser",
|
|
123
|
+
"value": {
|
|
124
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiUser"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"keyRaw": "sightEngineApiSecret",
|
|
129
|
+
"value": {
|
|
130
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiSecret"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"keyRaw": "imagesEnabled",
|
|
135
|
+
"value": {
|
|
136
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imagesEnabled"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"keyRaw": "textEnabled",
|
|
141
|
+
"value": {
|
|
142
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textEnabled"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"keyRaw": "videoEnabled",
|
|
147
|
+
"value": {
|
|
148
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoEnabled"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"keyRaw": "imageNudityThreshold",
|
|
153
|
+
"value": {
|
|
154
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imageNudityThreshold"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"keyRaw": "textSexualThreshold",
|
|
159
|
+
"value": {
|
|
160
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textSexualThreshold"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"keyRaw": "textToxicThreshold",
|
|
165
|
+
"value": {
|
|
166
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textToxicThreshold"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"keyRaw": "videoNudityThreshold",
|
|
171
|
+
"value": {
|
|
172
|
+
"@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoNudityThreshold"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ResponseDescription, OperationHandlerInput, OperationHandler } from '@solid/community-server';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an OperationHandler to add content moderation for operations with body data.
|
|
4
|
+
* Checks PUT, POST, and PATCH operations before passing them to the wrapped handler.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export declare class ModerationOperationHandler {
|
|
9
|
+
protected readonly logger: import("@solid/community-server").Logger;
|
|
10
|
+
private readonly source;
|
|
11
|
+
private readonly moderationMixin;
|
|
12
|
+
constructor(source: OperationHandler, enabled: boolean, auditLoggingEnabled: boolean, auditLoggingStorePath: string, sightEngineApiUser: string, sightEngineApiSecret: string, imagesEnabled: boolean, textEnabled: boolean, videoEnabled: boolean, imageNudityThreshold: number, textSexualThreshold: number, textToxicThreshold: number, videoNudityThreshold: number);
|
|
13
|
+
canHandle(input: OperationHandlerInput): Promise<void>;
|
|
14
|
+
handle(input: OperationHandlerInput): Promise<ResponseDescription>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ModerationOperationHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationOperationHandler.d.ts","sourceRoot":"","sources":["../src/ModerationOperationHandler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG5G;;;;;GAKG;AACH,qBAAa,0BAA0B;IACrC,SAAS,CAAC,QAAQ,CAAC,MAAM,2CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;gBAGhD,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,OAAO,EAChB,mBAAmB,EAAE,OAAO,EAC5B,qBAAqB,EAAE,MAAM,EAC7B,kBAAkB,EAAE,MAAM,EAC1B,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,OAAO,EACtB,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,OAAO,EACrB,oBAAoB,EAAE,MAAM,EAC5B,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,MAAM,EAC1B,oBAAoB,EAAE,MAAM;IAmBjB,SAAS,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAWhF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModerationOperationHandler = void 0;
|
|
4
|
+
const community_server_1 = require("@solid/community-server");
|
|
5
|
+
const ModerationMixin_1 = require("./ModerationMixin");
|
|
6
|
+
/**
|
|
7
|
+
* Wraps an OperationHandler to add content moderation for operations with body data.
|
|
8
|
+
* Checks PUT, POST, and PATCH operations before passing them to the wrapped handler.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
class ModerationOperationHandler {
|
|
13
|
+
constructor(source, enabled, auditLoggingEnabled, auditLoggingStorePath, sightEngineApiUser, sightEngineApiSecret, imagesEnabled, textEnabled, videoEnabled, imageNudityThreshold, textSexualThreshold, textToxicThreshold, videoNudityThreshold) {
|
|
14
|
+
this.logger = (0, community_server_1.getLoggerFor)(this);
|
|
15
|
+
this.source = source;
|
|
16
|
+
this.moderationMixin = new ModerationMixin_1.ModerationMixin({
|
|
17
|
+
enabled,
|
|
18
|
+
auditLoggingEnabled,
|
|
19
|
+
auditLoggingStorePath,
|
|
20
|
+
sightEngineApiUser,
|
|
21
|
+
sightEngineApiSecret,
|
|
22
|
+
imagesEnabled,
|
|
23
|
+
textEnabled,
|
|
24
|
+
videoEnabled,
|
|
25
|
+
imageNudityThreshold,
|
|
26
|
+
textSexualThreshold,
|
|
27
|
+
textToxicThreshold,
|
|
28
|
+
videoNudityThreshold,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async canHandle(input) {
|
|
32
|
+
return this.source.canHandle(input);
|
|
33
|
+
}
|
|
34
|
+
async handle(input) {
|
|
35
|
+
const { operation } = input;
|
|
36
|
+
// Only moderate operations with body data
|
|
37
|
+
if (operation.body?.data && ['PUT', 'POST', 'PATCH'].includes(operation.method)) {
|
|
38
|
+
this.logger.info(`MODERATION: Checking ${operation.method} request to ${operation.target.path}`);
|
|
39
|
+
await this.moderationMixin.moderateContent(operation);
|
|
40
|
+
}
|
|
41
|
+
return this.source.handle(input);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ModerationOperationHandler = ModerationOperationHandler;
|
|
45
|
+
//# sourceMappingURL=ModerationOperationHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationOperationHandler.js","sourceRoot":"","sources":["../src/ModerationOperationHandler.ts"],"names":[],"m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C,CAAC;IACnC,CAAC;CACF;AApDD,gEAoDC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.1.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.1.0/config/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld"
|
|
6
|
+
],
|
|
7
|
+
"@id": "npmd:@kkuffour/solid-moderation-plugin",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler",
|
|
11
|
+
"@type": "Class",
|
|
12
|
+
"requireElement": "ModerationOperationHandler",
|
|
13
|
+
"comment": "Wraps an OperationHandler to add content moderation for operations with body data. Checks PUT, POST, and PATCH operations before passing them to the wrapped handler.",
|
|
14
|
+
"parameters": [
|
|
15
|
+
{
|
|
16
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_enabled",
|
|
17
|
+
"range": "xsd:boolean"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingEnabled",
|
|
21
|
+
"range": "xsd:boolean"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingStorePath",
|
|
25
|
+
"range": "xsd:string"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiUser",
|
|
29
|
+
"range": "xsd:string"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiSecret",
|
|
33
|
+
"range": "xsd:string"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imagesEnabled",
|
|
37
|
+
"range": "xsd:boolean"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textEnabled",
|
|
41
|
+
"range": "xsd:boolean"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoEnabled",
|
|
45
|
+
"range": "xsd:boolean"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imageNudityThreshold",
|
|
49
|
+
"range": "xsd:number"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textSexualThreshold",
|
|
53
|
+
"range": "xsd:number"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textToxicThreshold",
|
|
57
|
+
"range": "xsd:number"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoNudityThreshold",
|
|
61
|
+
"range": "xsd:number"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_source",
|
|
65
|
+
"range": "css:dist/http/ldp/OperationHandler.jsonld#OperationHandler"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"memberFields": [
|
|
69
|
+
{
|
|
70
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler__member_logger",
|
|
71
|
+
"memberFieldName": "logger",
|
|
72
|
+
"range": {
|
|
73
|
+
"@type": "ParameterRangeWildcard"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler__member_source",
|
|
78
|
+
"memberFieldName": "source"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler__member_moderationMixin",
|
|
82
|
+
"memberFieldName": "moderationMixin"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler__member_constructor",
|
|
86
|
+
"memberFieldName": "constructor"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler__member_canHandle",
|
|
90
|
+
"memberFieldName": "canHandle"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler__member_handle",
|
|
94
|
+
"memberFieldName": "handle"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"constructorArguments": [
|
|
98
|
+
{
|
|
99
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_source"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_enabled"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingEnabled"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingStorePath"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiUser"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiSecret"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imagesEnabled"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textEnabled"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoEnabled"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imageNudityThreshold"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textSexualThreshold"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textToxicThreshold"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoNudityThreshold"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record of a content moderation violation for admin review.
|
|
3
|
+
*/
|
|
4
|
+
export interface ModerationRecord {
|
|
5
|
+
id: string;
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
contentType: 'image' | 'text' | 'video';
|
|
8
|
+
resourcePath: string;
|
|
9
|
+
userWebId?: string;
|
|
10
|
+
userAgent?: string;
|
|
11
|
+
clientIp?: string;
|
|
12
|
+
violations: {
|
|
13
|
+
model: string;
|
|
14
|
+
score: number;
|
|
15
|
+
threshold: number;
|
|
16
|
+
}[];
|
|
17
|
+
contentSize: number;
|
|
18
|
+
contentHash?: string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ModerationRecord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationRecord.d.ts","sourceRoot":"","sources":["../src/ModerationRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;IACJ,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationRecord.js","sourceRoot":"","sources":["../src/ModerationRecord.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.1.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.1.0/config/context.jsonld"
|
|
5
|
+
],
|
|
6
|
+
"@id": "npmd:@kkuffour/solid-moderation-plugin",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord",
|
|
10
|
+
"@type": "AbstractClass",
|
|
11
|
+
"requireElement": "ModerationRecord",
|
|
12
|
+
"comment": "Record of a content moderation violation for admin review.",
|
|
13
|
+
"parameters": [],
|
|
14
|
+
"memberFields": [
|
|
15
|
+
{
|
|
16
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_id",
|
|
17
|
+
"memberFieldName": "id"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_timestamp",
|
|
21
|
+
"memberFieldName": "timestamp"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_contentType",
|
|
25
|
+
"memberFieldName": "contentType"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_resourcePath",
|
|
29
|
+
"memberFieldName": "resourcePath"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_userWebId",
|
|
33
|
+
"memberFieldName": "userWebId"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_userAgent",
|
|
37
|
+
"memberFieldName": "userAgent"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_clientIp",
|
|
41
|
+
"memberFieldName": "clientIp"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_violations",
|
|
45
|
+
"memberFieldName": "violations"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_contentSize",
|
|
49
|
+
"memberFieldName": "contentSize"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord__member_contentHash",
|
|
53
|
+
"memberFieldName": "contentHash"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"constructorArguments": []
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModerationRecord } from './ModerationRecord';
|
|
2
|
+
/**
|
|
3
|
+
* Service for storing moderation violation records.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ModerationStore {
|
|
6
|
+
protected readonly logger: import("@solid/community-server").Logger;
|
|
7
|
+
private readonly storePath;
|
|
8
|
+
constructor(storePath?: string);
|
|
9
|
+
recordViolation(record: Omit<ModerationRecord, 'id' | 'timestamp'>): Promise<void>;
|
|
10
|
+
private generateId;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ModerationStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModerationStore.d.ts","sourceRoot":"","sources":["../src/ModerationStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;GAEG;AACH,qBAAa,eAAe;IAC1B,SAAS,CAAC,QAAQ,CAAC,MAAM,2CAAsB;IAE/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEhB,SAAS,SAA2B;IAI1C,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/F,OAAO,CAAC,UAAU;CAGnB"}
|