@kkuffour/solid-moderation-plugin 0.2.2 → 0.3.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/.data/.internal/idp/keys/cookie-secret$.json +1 -0
- package/.data/.internal/idp/keys/jwks$.json +1 -0
- package/.data/.internal/setup/current-base-url$.json +1 -0
- package/PLUGIN_DEVELOPER_GUIDE.md +213 -0
- package/README.md +25 -28
- package/components/context.jsonld +6 -245
- package/config/default.json +14 -28
- package/dist/ModerationHandler.d.ts +21 -0
- package/dist/ModerationHandler.d.ts.map +1 -0
- package/dist/ModerationHandler.js +158 -0
- package/dist/ModerationHandler.js.map +1 -0
- package/dist/ModerationHandler.jsonld +126 -0
- package/dist/components/components.jsonld +13 -0
- package/dist/components/context.jsonld +11 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/providers/SightEngineProvider.jsonld +2 -2
- package/package.json +11 -11
- package/src/ModerationHandler.ts +189 -0
- package/src/index.ts +1 -6
- package/ARCHITECTURE.md +0 -52
- package/CONFIG-GUIDE.md +0 -49
- package/DEVELOPMENT.md +0 -129
- package/ENV-VARIABLES.md +0 -137
- package/INSTALLATION.md +0 -90
- package/MIGRATION.md +0 -81
- package/PRODUCTION.md +0 -186
- package/PUBLISHING.md +0 -104
- package/TESTING.md +0 -93
- package/components/components.jsonld +0 -18
- package/dist/ModerationConfig.d.ts +0 -16
- package/dist/ModerationConfig.d.ts.map +0 -1
- package/dist/ModerationConfig.js +0 -18
- package/dist/ModerationConfig.js.map +0 -1
- package/dist/ModerationConfig.jsonld +0 -66
- package/dist/ModerationMixin.d.ts +0 -13
- package/dist/ModerationMixin.d.ts.map +0 -1
- package/dist/ModerationMixin.js +0 -136
- package/dist/ModerationMixin.js.map +0 -1
- package/dist/ModerationMixin.jsonld +0 -180
- package/dist/ModerationOperationHandler.d.ts +0 -16
- package/dist/ModerationOperationHandler.d.ts.map +0 -1
- package/dist/ModerationOperationHandler.js +0 -45
- package/dist/ModerationOperationHandler.js.map +0 -1
- package/dist/ModerationOperationHandler.jsonld +0 -140
- package/dist/ModerationRecord.d.ts +0 -20
- package/dist/ModerationRecord.d.ts.map +0 -1
- package/dist/ModerationRecord.js +0 -3
- package/dist/ModerationRecord.js.map +0 -1
- package/dist/ModerationRecord.jsonld +0 -59
- package/dist/ModerationResourceStore.d.ts +0 -30
- package/dist/ModerationResourceStore.d.ts.map +0 -1
- package/dist/ModerationResourceStore.js +0 -167
- package/dist/ModerationResourceStore.js.map +0 -1
- package/dist/ModerationResourceStore.jsonld +0 -157
- package/dist/ModerationStore.d.ts +0 -12
- package/dist/ModerationStore.d.ts.map +0 -1
- package/dist/ModerationStore.js +0 -37
- package/dist/ModerationStore.js.map +0 -1
- package/dist/ModerationStore.jsonld +0 -59
- package/dist/util/GuardedStream.d.ts +0 -33
- package/dist/util/GuardedStream.d.ts.map +0 -1
- package/dist/util/GuardedStream.js +0 -89
- package/dist/util/GuardedStream.js.map +0 -1
- package/simple-test.json +0 -7
- package/src/ModerationConfig.ts +0 -29
- package/src/ModerationMixin.ts +0 -153
- package/src/ModerationOperationHandler.ts +0 -64
- package/src/ModerationRecord.ts +0 -19
- package/src/ModerationResourceStore.ts +0 -227
- package/src/ModerationStore.ts +0 -41
- package/src/util/GuardedStream.ts +0 -101
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.2.0/components/context.jsonld",
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.2.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
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModerationOperationHandler.js","sourceRoot":"","sources":["../src/ModerationOperationHandler.ts"],"names":[],"mappings":";;;AAAA,8DAAuD;AAGvD,uDAAoD;AAEpD;;;;;GAKG;AACH,MAAa,0BAA0B;IAKrC,YACE,MAAwB,EACxB,OAAgB,EAChB,mBAA4B,EAC5B,qBAA6B,EAC7B,kBAA0B,EAC1B,oBAA4B,EAC5B,aAAsB,EACtB,WAAoB,EACpB,YAAqB,EACrB,oBAA4B,EAC5B,mBAA2B,EAC3B,kBAA0B,EAC1B,oBAA4B;QAjBX,WAAM,GAAG,IAAA,+BAAY,EAAC,IAAI,CAAC,CAAC;QAmB7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,CAAC;YACzC,OAAO;YACP,mBAAmB;YACnB,qBAAqB;YACrB,kBAAkB;YAClB,oBAAoB;YACpB,aAAa;YACb,WAAW;YACX,YAAY;YACZ,oBAAoB;YACpB,mBAAmB;YACnB,kBAAkB;YAClB,oBAAoB;SACrB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,KAA4B;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAA4B;QAC9C,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;QAE5B,0CAA0C;QAC1C,IAAI,SAAS,CAAC,IAAI,EAAE,IAAI,IAAI,CAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAClF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,SAAS,CAAC,MAAM,eAAe,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACjG,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF;AApDD,gEAoDC"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.2.0/components/context.jsonld",
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.2.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
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/ModerationRecord.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModerationRecord.js","sourceRoot":"","sources":["../src/ModerationRecord.ts"],"names":[],"mappings":""}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.2.0/components/context.jsonld",
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@kkuffour/solid-moderation-plugin/^0.2.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
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ResourceStore, ChangeMap, Representation, ResourceIdentifier, RepresentationPreferences, Conditions, Patch } from '@solid/community-server';
|
|
2
|
-
import type { SightEngineProvider } from './providers/SightEngineProvider';
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* Wraps a ResourceStore to add content moderation on write operations.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ModerationResourceStore implements ResourceStore {
|
|
8
|
-
private readonly logger;
|
|
9
|
-
private readonly source;
|
|
10
|
-
private readonly client;
|
|
11
|
-
private readonly enabled;
|
|
12
|
-
private readonly imageNudityThreshold;
|
|
13
|
-
private readonly textSexualThreshold;
|
|
14
|
-
private readonly textToxicThreshold;
|
|
15
|
-
private readonly videoNudityThreshold;
|
|
16
|
-
constructor(source: ResourceStore, client: SightEngineProvider, enabled: boolean, imageNudityThreshold: number, textSexualThreshold: number, textToxicThreshold: number, videoNudityThreshold: number);
|
|
17
|
-
hasResource(identifier: ResourceIdentifier): Promise<boolean>;
|
|
18
|
-
getRepresentation(identifier: ResourceIdentifier, preferences: RepresentationPreferences, conditions?: Conditions): Promise<Representation>;
|
|
19
|
-
setRepresentation(identifier: ResourceIdentifier, representation: Representation, conditions?: Conditions): Promise<ChangeMap>;
|
|
20
|
-
addResource(container: ResourceIdentifier, representation: Representation, conditions?: Conditions): Promise<ChangeMap>;
|
|
21
|
-
deleteResource(identifier: ResourceIdentifier, conditions?: Conditions): Promise<ChangeMap>;
|
|
22
|
-
modifyResource(identifier: ResourceIdentifier, patch: Patch, conditions?: Conditions): Promise<ChangeMap>;
|
|
23
|
-
private moderateRepresentation;
|
|
24
|
-
private shouldModerateContentType;
|
|
25
|
-
private moderateImage;
|
|
26
|
-
private moderateVideo;
|
|
27
|
-
private moderateText;
|
|
28
|
-
private getFileExtension;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=ModerationResourceStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModerationResourceStore.d.ts","sourceRoot":"","sources":["../src/ModerationResourceStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAG1J,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,aAAa;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAC5C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;gBAG5C,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,MAAM,EAC5B,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,MAAM,EAC1B,oBAAoB,EAAE,MAAM;IAejB,WAAW,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7D,iBAAiB,CAC5B,UAAU,EAAE,kBAAkB,EAC9B,WAAW,EAAE,yBAAyB,EACtC,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,cAAc,CAAC;IAIb,iBAAiB,CAC5B,UAAU,EAAE,kBAAkB,EAC9B,cAAc,EAAE,cAAc,EAC9B,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,SAAS,CAAC;IAKR,WAAW,CACtB,SAAS,EAAE,kBAAkB,EAC7B,cAAc,EAAE,cAAc,EAC9B,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,SAAS,CAAC;IAKR,cAAc,CACzB,UAAU,EAAE,kBAAkB,EAC9B,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,SAAS,CAAC;IAIR,cAAc,CACzB,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,KAAK,EACZ,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,SAAS,CAAC;YAIP,sBAAsB;IAyDpC,OAAO,CAAC,yBAAyB;YAMnB,aAAa;YAsBb,aAAa;YAsBb,YAAY;IAsB1B,OAAO,CAAC,gBAAgB;CAWzB"}
|