@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.
Files changed (65) hide show
  1. package/CONFIG-GUIDE.md +49 -0
  2. package/DEVELOPMENT.md +129 -0
  3. package/ENV-VARIABLES.md +137 -0
  4. package/INSTALLATION.md +90 -0
  5. package/LICENSE +21 -0
  6. package/MIGRATION.md +81 -0
  7. package/PRODUCTION.md +186 -0
  8. package/PUBLISHING.md +104 -0
  9. package/README.md +53 -0
  10. package/TESTING.md +64 -0
  11. package/components/components.jsonld +17 -0
  12. package/components/context.jsonld +211 -0
  13. package/config/context.jsonld +15 -0
  14. package/config/default.json +80 -0
  15. package/dist/ModerationConfig.d.ts +16 -0
  16. package/dist/ModerationConfig.d.ts.map +1 -0
  17. package/dist/ModerationConfig.js +18 -0
  18. package/dist/ModerationConfig.js.map +1 -0
  19. package/dist/ModerationConfig.jsonld +66 -0
  20. package/dist/ModerationMixin.d.ts +13 -0
  21. package/dist/ModerationMixin.d.ts.map +1 -0
  22. package/dist/ModerationMixin.js +136 -0
  23. package/dist/ModerationMixin.js.map +1 -0
  24. package/dist/ModerationMixin.jsonld +180 -0
  25. package/dist/ModerationOperationHandler.d.ts +16 -0
  26. package/dist/ModerationOperationHandler.d.ts.map +1 -0
  27. package/dist/ModerationOperationHandler.js +45 -0
  28. package/dist/ModerationOperationHandler.js.map +1 -0
  29. package/dist/ModerationOperationHandler.jsonld +140 -0
  30. package/dist/ModerationRecord.d.ts +20 -0
  31. package/dist/ModerationRecord.d.ts.map +1 -0
  32. package/dist/ModerationRecord.js +3 -0
  33. package/dist/ModerationRecord.js.map +1 -0
  34. package/dist/ModerationRecord.jsonld +59 -0
  35. package/dist/ModerationStore.d.ts +12 -0
  36. package/dist/ModerationStore.d.ts.map +1 -0
  37. package/dist/ModerationStore.js +37 -0
  38. package/dist/ModerationStore.js.map +1 -0
  39. package/dist/ModerationStore.jsonld +59 -0
  40. package/dist/components/components.jsonld +17 -0
  41. package/dist/components/context.jsonld +211 -0
  42. package/dist/index.d.ts +7 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +23 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/providers/SightEngineProvider.d.ts +52 -0
  47. package/dist/providers/SightEngineProvider.d.ts.map +1 -0
  48. package/dist/providers/SightEngineProvider.js +302 -0
  49. package/dist/providers/SightEngineProvider.js.map +1 -0
  50. package/dist/providers/SightEngineProvider.jsonld +209 -0
  51. package/dist/util/GuardedStream.d.ts +33 -0
  52. package/dist/util/GuardedStream.d.ts.map +1 -0
  53. package/dist/util/GuardedStream.js +89 -0
  54. package/dist/util/GuardedStream.js.map +1 -0
  55. package/package.json +40 -0
  56. package/simple-test.json +7 -0
  57. package/src/ModerationConfig.ts +29 -0
  58. package/src/ModerationMixin.ts +153 -0
  59. package/src/ModerationOperationHandler.ts +64 -0
  60. package/src/ModerationRecord.ts +19 -0
  61. package/src/ModerationStore.ts +41 -0
  62. package/src/index.ts +6 -0
  63. package/src/providers/SightEngineProvider.ts +367 -0
  64. package/src/util/GuardedStream.ts +101 -0
  65. package/tsconfig.json +20 -0
package/PUBLISHING.md ADDED
@@ -0,0 +1,104 @@
1
+ # Publishing Guide
2
+
3
+ ## Before Publishing
4
+
5
+ Replace `@kkuffour` with your actual npm username/organization in these files:
6
+ - `package.json` (name, lsd:module, lsd:contexts)
7
+ - `components/context.jsonld` (smp prefix)
8
+ - `components/components.jsonld` (@context, @id, requireName)
9
+ - `config-with-moderation.json` (@context)
10
+
11
+ ## Steps to Publish
12
+
13
+ ### 1. Login to npm
14
+ ```bash
15
+ npm login
16
+ ```
17
+
18
+ ### 2. Build the package
19
+ ```bash
20
+ cd /Users/opendata/solid-moderation
21
+ npm run build
22
+ ```
23
+
24
+ ### 3. Test locally first (optional)
25
+ ```bash
26
+ npm pack
27
+ # This creates a .tgz file you can test with
28
+ ```
29
+
30
+ ### 4. Publish to npm
31
+ ```bash
32
+ # For scoped package (recommended for testing)
33
+ npm publish --access public
34
+
35
+ # Or for private testing
36
+ npm publish --access restricted
37
+ ```
38
+
39
+ ### 5. Install in CSS
40
+ ```bash
41
+ cd /Users/opendata/CommunitySolidServer
42
+ npm install @kkuffour/solid-moderation-plugin@latest
43
+ ```
44
+
45
+ ### 6. Update config reference
46
+ The config file path stays the same:
47
+ ```bash
48
+ npm start -- -c /Users/opendata/solid-moderation/config-with-moderation.json -f data/ -p 3009 -l debug
49
+ ```
50
+
51
+ ## Version Updates
52
+
53
+ After making changes:
54
+ ```bash
55
+ # Update version
56
+ npm version patch # 0.1.0 -> 0.1.1
57
+ # or
58
+ npm version minor # 0.1.0 -> 0.2.0
59
+
60
+ # Rebuild and republish
61
+ npm run build
62
+ npm publish
63
+ ```
64
+
65
+ ## Moving to @solid Namespace
66
+
67
+ Once tested and ready for official release:
68
+
69
+ 1. Request access to @solid npm organization
70
+ 2. Update all references from `@kkuffour/solid-moderation-plugin` to `@solid/moderation-plugin`
71
+ 3. Update version to `1.0.0`
72
+ 4. Publish to @solid namespace
73
+
74
+ ## Troubleshooting
75
+
76
+ **If publish fails with 403:**
77
+ - Check you're logged in: `npm whoami`
78
+ - Verify package name is available: `npm view @kkuffour/solid-moderation-plugin`
79
+ - Ensure `--access public` for scoped packages
80
+
81
+ **If Components.js can't find module after install:**
82
+ - Verify `lsd:module`, `lsd:components`, and `lsd:contexts` paths in package.json
83
+ - Check that `components/` directory exists with `.jsonld` files
84
+ - Rebuild: `npm run build`
85
+
86
+ ## Current Configuration
87
+
88
+ **Package Name**: `@kkuffour/solid-moderation-plugin`
89
+ **Version**: `0.1.0`
90
+ **Entry Point**: `dist/index.js`
91
+ **Components**: `components/components.jsonld`
92
+ **Context**: `components/context.jsonld`
93
+
94
+ **Environment Variables Required**:
95
+ ```bash
96
+ export SIGHTENGINE_API_USER="1060049443"
97
+ export SIGHTENGINE_API_SECRET="QRQ8HUmh4hyvhZjksBJq5ZaNYPLPEKXu"
98
+ ```
99
+
100
+ **Thresholds** (configurable in config-with-moderation.json):
101
+ - Image Nudity: 0.1 (10%)
102
+ - Text Sexual: 0.1 (10%)
103
+ - Text Toxic: 0.1 (10%)
104
+ - Video Nudity: 0.1 (10%)
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # @solid/moderation-plugin
2
+
3
+ Content moderation plugin for Community Solid Server using SightEngine API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @solid/moderation-plugin
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ Set environment variables:
14
+
15
+ ```bash
16
+ export SIGHTENGINE_API_USER=your_api_user
17
+ export SIGHTENGINE_API_SECRET=your_api_secret
18
+ ```
19
+
20
+ Create a configuration file that imports the plugin:
21
+
22
+ ```json
23
+ {
24
+ "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
25
+ "import": [
26
+ "css:config/file.json",
27
+ "@solid/moderation-plugin:config/default.json"
28
+ ]
29
+ }
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```bash
35
+ npx @solid/community-server -c config-with-moderation.json
36
+ ```
37
+
38
+ ## Features
39
+
40
+ - Image moderation (nudity, violence, gore, weapons, etc.)
41
+ - Text moderation (profanity, hate speech, toxic content)
42
+ - Video moderation
43
+ - Configurable thresholds
44
+ - Audit logging
45
+ - Fail-open policy (allows content if API fails)
46
+
47
+ ## Configuration Options
48
+
49
+ See `config/default.json` for all available options and thresholds.
50
+
51
+ ## License
52
+
53
+ MIT
package/TESTING.md ADDED
@@ -0,0 +1,64 @@
1
+ # Local Testing Guide
2
+
3
+ ## Setup
4
+
5
+ 1. **Set environment variables:**
6
+ ```bash
7
+ export SIGHTENGINE_API_USER=your_api_user
8
+ export SIGHTENGINE_API_SECRET=your_api_secret
9
+ ```
10
+
11
+ 2. **Link the plugin locally (run in plugin directory):**
12
+ ```bash
13
+ cd /Users/opendata/solid-moderation
14
+ npm link
15
+ ```
16
+
17
+ 3. **In your CSS project directory, link the plugin:**
18
+ ```bash
19
+ cd /path/to/your/communitysolidserver
20
+ npm link @solid/moderation-plugin
21
+ ```
22
+
23
+ ## Run CSS with Moderation
24
+
25
+ ```bash
26
+ npx @solid/community-server -c /Users/opendata/solid-moderation/config-with-moderation.json
27
+ ```
28
+
29
+ ## Test the Moderation
30
+
31
+ ### Test Image Upload:
32
+ ```bash
33
+ # Upload a safe image (should succeed)
34
+ curl -X PUT http://localhost:3000/test.jpg \
35
+ -H "Content-Type: image/jpeg" \
36
+ --data-binary @safe-image.jpg
37
+
38
+ # Upload inappropriate content (should be blocked)
39
+ curl -X PUT http://localhost:3000/test2.jpg \
40
+ -H "Content-Type: image/jpeg" \
41
+ --data-binary @inappropriate-image.jpg
42
+ ```
43
+
44
+ ### Test Text Upload:
45
+ ```bash
46
+ # Upload safe text (should succeed)
47
+ curl -X PUT http://localhost:3000/test.txt \
48
+ -H "Content-Type: text/plain" \
49
+ -d "Hello, this is safe content"
50
+
51
+ # Upload inappropriate text (should be blocked)
52
+ curl -X PUT http://localhost:3000/test2.txt \
53
+ -H "Content-Type: text/plain" \
54
+ -d "inappropriate content here"
55
+ ```
56
+
57
+ ## Check Logs
58
+
59
+ Moderation logs will be stored in:
60
+ ```
61
+ ./data/moderation-logs/
62
+ ```
63
+
64
+ Each violation is logged as a JSON line in daily files.
@@ -0,0 +1,17 @@
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
+ "@type": "Module",
8
+ "requireName": "@kkuffour/solid-moderation-plugin",
9
+ "import": [
10
+ "npmd:@solid/moderation-plugin/^1.0.0/components/ModerationOperationHandler.jsonld",
11
+ "npmd:@solid/moderation-plugin/^1.0.0/components/ModerationConfig.jsonld",
12
+ "npmd:@solid/moderation-plugin/^1.0.0/components/ModerationStore.jsonld",
13
+ "npmd:@solid/moderation-plugin/^1.0.0/components/ModerationRecord.jsonld",
14
+ "npmd:@solid/moderation-plugin/^1.0.0/components/ModerationMixin.jsonld",
15
+ "npmd:@solid/moderation-plugin/^1.0.0/components/providers/SightEngineProvider.jsonld"
16
+ ]
17
+ }
@@ -0,0 +1,211 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
4
+ {
5
+ "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
+ "ksmp": "npmd:@kkuffour/solid-moderation-plugin/^0.0.0/",
7
+ "ModerationOperationHandler": {
8
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler",
9
+ "@prefix": true,
10
+ "@context": {
11
+ "enabled": {
12
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_enabled"
13
+ },
14
+ "auditLoggingEnabled": {
15
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingEnabled"
16
+ },
17
+ "auditLoggingStorePath": {
18
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingStorePath"
19
+ },
20
+ "sightEngineApiUser": {
21
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiUser"
22
+ },
23
+ "sightEngineApiSecret": {
24
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiSecret"
25
+ },
26
+ "imagesEnabled": {
27
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imagesEnabled"
28
+ },
29
+ "textEnabled": {
30
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textEnabled"
31
+ },
32
+ "videoEnabled": {
33
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoEnabled"
34
+ },
35
+ "imageNudityThreshold": {
36
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imageNudityThreshold"
37
+ },
38
+ "textSexualThreshold": {
39
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textSexualThreshold"
40
+ },
41
+ "textToxicThreshold": {
42
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textToxicThreshold"
43
+ },
44
+ "videoNudityThreshold": {
45
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoNudityThreshold"
46
+ },
47
+ "source": {
48
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_source"
49
+ },
50
+ "": {
51
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_enabled"
52
+ },
53
+ "ggingEnabled": {
54
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingEnabled"
55
+ },
56
+ "ggingStorePath": {
57
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_auditLoggingStorePath"
58
+ },
59
+ "gineApiUser": {
60
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiUser"
61
+ },
62
+ "gineApiSecret": {
63
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_sightEngineApiSecret"
64
+ },
65
+ "nabled": {
66
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_imagesEnabled"
67
+ },
68
+ "bled": {
69
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textEnabled"
70
+ },
71
+ "abled": {
72
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoEnabled"
73
+ },
74
+ "dityThreshold": {
75
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_videoNudityThreshold"
76
+ },
77
+ "ualThreshold": {
78
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textSexualThreshold"
79
+ },
80
+ "icThreshold": {
81
+ "@id": "ksmp:dist/ModerationOperationHandler.jsonld#ModerationOperationHandler_textToxicThreshold"
82
+ }
83
+ }
84
+ },
85
+ "ModerationConfig": {
86
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig",
87
+ "@prefix": true,
88
+ "@context": {}
89
+ },
90
+ "ModerationStore": {
91
+ "@id": "ksmp:dist/ModerationStore.jsonld#ModerationStore",
92
+ "@prefix": true,
93
+ "@context": {
94
+ "storePath": {
95
+ "@id": "ksmp:dist/ModerationStore.jsonld#ModerationStore_storePath"
96
+ }
97
+ }
98
+ },
99
+ "ModerationRecord": {
100
+ "@id": "ksmp:dist/ModerationRecord.jsonld#ModerationRecord",
101
+ "@prefix": true,
102
+ "@context": {}
103
+ },
104
+ "ModerationMixin": {
105
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin",
106
+ "@prefix": true,
107
+ "@context": {
108
+ "moderationConfig_enabled": {
109
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_enabled"
110
+ },
111
+ "moderationConfig_auditLoggingEnabled": {
112
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingEnabled"
113
+ },
114
+ "moderationConfig_auditLoggingStorePath": {
115
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingStorePath"
116
+ },
117
+ "moderationConfig_sightEngineApiUser": {
118
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiUser"
119
+ },
120
+ "moderationConfig_sightEngineApiSecret": {
121
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiSecret"
122
+ },
123
+ "moderationConfig_imagesEnabled": {
124
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imagesEnabled"
125
+ },
126
+ "moderationConfig_textEnabled": {
127
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textEnabled"
128
+ },
129
+ "moderationConfig_videoEnabled": {
130
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoEnabled"
131
+ },
132
+ "moderationConfig_imageNudityThreshold": {
133
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imageNudityThreshold"
134
+ },
135
+ "moderationConfig_textSexualThreshold": {
136
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textSexualThreshold"
137
+ },
138
+ "moderationConfig_textToxicThreshold": {
139
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textToxicThreshold"
140
+ },
141
+ "moderationConfig_videoNudityThreshold": {
142
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoNudityThreshold"
143
+ },
144
+ "enabled": {
145
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_enabled"
146
+ },
147
+ "auditLoggingEnabled": {
148
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingEnabled"
149
+ },
150
+ "auditLoggingStorePath": {
151
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_auditLoggingStorePath"
152
+ },
153
+ "sightEngineApiUser": {
154
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiUser"
155
+ },
156
+ "sightEngineApiSecret": {
157
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_sightEngineApiSecret"
158
+ },
159
+ "imagesEnabled": {
160
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imagesEnabled"
161
+ },
162
+ "textEnabled": {
163
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textEnabled"
164
+ },
165
+ "videoEnabled": {
166
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoEnabled"
167
+ },
168
+ "imageNudityThreshold": {
169
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_imageNudityThreshold"
170
+ },
171
+ "textSexualThreshold": {
172
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textSexualThreshold"
173
+ },
174
+ "textToxicThreshold": {
175
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_textToxicThreshold"
176
+ },
177
+ "videoNudityThreshold": {
178
+ "@id": "ksmp:dist/ModerationMixin.jsonld#ModerationMixin_moderationConfig_videoNudityThreshold"
179
+ }
180
+ }
181
+ },
182
+ "SightEngineProvider": {
183
+ "@id": "ksmp:dist/providers/SightEngineProvider.jsonld#SightEngineProvider",
184
+ "@prefix": true,
185
+ "@context": {
186
+ "apiUser": {
187
+ "@id": "ksmp:dist/providers/SightEngineProvider.jsonld#SightEngineProvider_apiUser"
188
+ },
189
+ "apiSecret": {
190
+ "@id": "ksmp:dist/providers/SightEngineProvider.jsonld#SightEngineProvider_apiSecret"
191
+ }
192
+ }
193
+ },
194
+ "SightEngineResult": {
195
+ "@id": "ksmp:dist/providers/SightEngineProvider.jsonld#SightEngineResult",
196
+ "@prefix": true,
197
+ "@context": {}
198
+ },
199
+ "SightEngineTextResult": {
200
+ "@id": "ksmp:dist/providers/SightEngineProvider.jsonld#SightEngineTextResult",
201
+ "@prefix": true,
202
+ "@context": {}
203
+ },
204
+ "SightEngineVideoResult": {
205
+ "@id": "ksmp:dist/providers/SightEngineProvider.jsonld#SightEngineVideoResult",
206
+ "@prefix": true,
207
+ "@context": {}
208
+ }
209
+ }
210
+ ]
211
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "@context": [
3
+ {
4
+ "modConfig": "http://example.org/moderation-config#",
5
+ "enabled": "modConfig:enabled",
6
+ "auditLoggingEnabled": "modConfig:auditLoggingEnabled",
7
+ "auditLoggingStorePath": "modConfig:auditLoggingStorePath",
8
+ "sightEngineApiUser": "modConfig:sightEngineApiUser",
9
+ "sightEngineApiSecret": "modConfig:sightEngineApiSecret",
10
+ "imagesEnabled": "modConfig:imagesEnabled",
11
+ "textEnabled": "modConfig:textEnabled",
12
+ "videoEnabled": "modConfig:videoEnabled"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@solid/moderation-plugin/^1.0.0/components/context.jsonld"
5
+ ],
6
+ "@graph": [
7
+ {
8
+ "@id": "urn:solid-server:default:OperationHandler",
9
+ "@type": "WaterfallHandler",
10
+ "handlers": [
11
+ { "@id": "urn:solid-moderation:wrapped:PostHandler" },
12
+ { "@id": "urn:solid-moderation:wrapped:PutHandler" },
13
+ { "@id": "urn:solid-moderation:wrapped:PatchHandler" },
14
+ { "@type": "GetOperationHandler", "store": { "@id": "urn:solid-server:default:ResourceStore" } },
15
+ { "@type": "HeadOperationHandler", "store": { "@id": "urn:solid-server:default:ResourceStore" } },
16
+ { "@type": "DeleteOperationHandler", "store": { "@id": "urn:solid-server:default:ResourceStore" } }
17
+ ]
18
+ },
19
+ {
20
+ "@id": "urn:solid-moderation:wrapped:PostHandler",
21
+ "@type": "ModerationOperationHandler",
22
+ "ModerationOperationHandler:_source": {
23
+ "@type": "PostOperationHandler",
24
+ "store": { "@id": "urn:solid-server:default:ResourceStore" }
25
+ },
26
+ "ModerationOperationHandler:_enabled": true,
27
+ "ModerationOperationHandler:_auditLoggingEnabled": true,
28
+ "ModerationOperationHandler:_auditLoggingStorePath": "./data/moderation-logs",
29
+ "ModerationOperationHandler:_sightEngineApiUser": "${SIGHTENGINE_API_USER}",
30
+ "ModerationOperationHandler:_sightEngineApiSecret": "${SIGHTENGINE_API_SECRET}",
31
+ "ModerationOperationHandler:_imagesEnabled": true,
32
+ "ModerationOperationHandler:_textEnabled": true,
33
+ "ModerationOperationHandler:_videoEnabled": true,
34
+ "ModerationOperationHandler:_imageNudityThreshold": 0.5,
35
+ "ModerationOperationHandler:_textSexualThreshold": 0.5,
36
+ "ModerationOperationHandler:_textToxicThreshold": 0.5,
37
+ "ModerationOperationHandler:_videoNudityThreshold": 0.5
38
+ },
39
+ {
40
+ "@id": "urn:solid-moderation:wrapped:PutHandler",
41
+ "@type": "ModerationOperationHandler",
42
+ "ModerationOperationHandler:_source": {
43
+ "@type": "PutOperationHandler",
44
+ "store": { "@id": "urn:solid-server:default:ResourceStore" }
45
+ },
46
+ "ModerationOperationHandler:_enabled": true,
47
+ "ModerationOperationHandler:_auditLoggingEnabled": true,
48
+ "ModerationOperationHandler:_auditLoggingStorePath": "./data/moderation-logs",
49
+ "ModerationOperationHandler:_sightEngineApiUser": "${SIGHTENGINE_API_USER}",
50
+ "ModerationOperationHandler:_sightEngineApiSecret": "${SIGHTENGINE_API_SECRET}",
51
+ "ModerationOperationHandler:_imagesEnabled": true,
52
+ "ModerationOperationHandler:_textEnabled": true,
53
+ "ModerationOperationHandler:_videoEnabled": true,
54
+ "ModerationOperationHandler:_imageNudityThreshold": 0.5,
55
+ "ModerationOperationHandler:_textSexualThreshold": 0.5,
56
+ "ModerationOperationHandler:_textToxicThreshold": 0.5,
57
+ "ModerationOperationHandler:_videoNudityThreshold": 0.5
58
+ },
59
+ {
60
+ "@id": "urn:solid-moderation:wrapped:PatchHandler",
61
+ "@type": "ModerationOperationHandler",
62
+ "ModerationOperationHandler:_source": {
63
+ "@type": "PatchOperationHandler",
64
+ "store": { "@id": "urn:solid-server:default:ResourceStore" }
65
+ },
66
+ "ModerationOperationHandler:_enabled": true,
67
+ "ModerationOperationHandler:_auditLoggingEnabled": true,
68
+ "ModerationOperationHandler:_auditLoggingStorePath": "./data/moderation-logs",
69
+ "ModerationOperationHandler:_sightEngineApiUser": "${SIGHTENGINE_API_USER}",
70
+ "ModerationOperationHandler:_sightEngineApiSecret": "${SIGHTENGINE_API_SECRET}",
71
+ "ModerationOperationHandler:_imagesEnabled": true,
72
+ "ModerationOperationHandler:_textEnabled": true,
73
+ "ModerationOperationHandler:_videoEnabled": true,
74
+ "ModerationOperationHandler:_imageNudityThreshold": 0.5,
75
+ "ModerationOperationHandler:_textSexualThreshold": 0.5,
76
+ "ModerationOperationHandler:_textToxicThreshold": 0.5,
77
+ "ModerationOperationHandler:_videoNudityThreshold": 0.5
78
+ }
79
+ ]
80
+ }
@@ -0,0 +1,16 @@
1
+ export interface ModerationConfig {
2
+ enabled: boolean;
3
+ auditLoggingEnabled: boolean;
4
+ auditLoggingStorePath: string;
5
+ sightEngineApiUser: string;
6
+ sightEngineApiSecret: string;
7
+ imagesEnabled: boolean;
8
+ textEnabled: boolean;
9
+ videoEnabled: boolean;
10
+ imageNudityThreshold: number;
11
+ textSexualThreshold: number;
12
+ textToxicThreshold: number;
13
+ videoNudityThreshold: number;
14
+ }
15
+ export declare const DEFAULT_MODERATION_CONFIG: ModerationConfig;
16
+ //# sourceMappingURL=ModerationConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModerationConfig.d.ts","sourceRoot":"","sources":["../src/ModerationConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,yBAAyB,EAAE,gBAavC,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_MODERATION_CONFIG = void 0;
4
+ exports.DEFAULT_MODERATION_CONFIG = {
5
+ enabled: true,
6
+ auditLoggingEnabled: true,
7
+ auditLoggingStorePath: './data/moderation-logs',
8
+ sightEngineApiUser: '',
9
+ sightEngineApiSecret: '',
10
+ imagesEnabled: true,
11
+ textEnabled: true,
12
+ videoEnabled: true,
13
+ imageNudityThreshold: 0.5,
14
+ textSexualThreshold: 0.5,
15
+ textToxicThreshold: 0.5,
16
+ videoNudityThreshold: 0.5,
17
+ };
18
+ //# sourceMappingURL=ModerationConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModerationConfig.js","sourceRoot":"","sources":["../src/ModerationConfig.ts"],"names":[],"mappings":";;;AAea,QAAA,yBAAyB,GAAqB;IACzD,OAAO,EAAE,IAAI;IACb,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,wBAAwB;IAC/C,kBAAkB,EAAE,EAAE;IACtB,oBAAoB,EAAE,EAAE;IACxB,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,oBAAoB,EAAE,GAAG;IACzB,mBAAmB,EAAE,GAAG;IACxB,kBAAkB,EAAE,GAAG;IACvB,oBAAoB,EAAE,GAAG;CAC1B,CAAC"}
@@ -0,0 +1,66 @@
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/ModerationConfig.jsonld#ModerationConfig",
10
+ "@type": "AbstractClass",
11
+ "requireElement": "ModerationConfig",
12
+ "parameters": [],
13
+ "memberFields": [
14
+ {
15
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_enabled",
16
+ "memberFieldName": "enabled"
17
+ },
18
+ {
19
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_auditLoggingEnabled",
20
+ "memberFieldName": "auditLoggingEnabled"
21
+ },
22
+ {
23
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_auditLoggingStorePath",
24
+ "memberFieldName": "auditLoggingStorePath"
25
+ },
26
+ {
27
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_sightEngineApiUser",
28
+ "memberFieldName": "sightEngineApiUser"
29
+ },
30
+ {
31
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_sightEngineApiSecret",
32
+ "memberFieldName": "sightEngineApiSecret"
33
+ },
34
+ {
35
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_imagesEnabled",
36
+ "memberFieldName": "imagesEnabled"
37
+ },
38
+ {
39
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_textEnabled",
40
+ "memberFieldName": "textEnabled"
41
+ },
42
+ {
43
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_videoEnabled",
44
+ "memberFieldName": "videoEnabled"
45
+ },
46
+ {
47
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_imageNudityThreshold",
48
+ "memberFieldName": "imageNudityThreshold"
49
+ },
50
+ {
51
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_textSexualThreshold",
52
+ "memberFieldName": "textSexualThreshold"
53
+ },
54
+ {
55
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_textToxicThreshold",
56
+ "memberFieldName": "textToxicThreshold"
57
+ },
58
+ {
59
+ "@id": "ksmp:dist/ModerationConfig.jsonld#ModerationConfig__member_videoNudityThreshold",
60
+ "memberFieldName": "videoNudityThreshold"
61
+ }
62
+ ],
63
+ "constructorArguments": []
64
+ }
65
+ ]
66
+ }
@@ -0,0 +1,13 @@
1
+ import type { Operation } from '@solid/community-server';
2
+ import type { ModerationConfig } from './ModerationConfig';
3
+ export declare class ModerationMixin {
4
+ protected readonly logger: import("@solid/community-server").Logger;
5
+ private readonly moderationConfig;
6
+ private readonly moderationStore?;
7
+ constructor(moderationConfig: ModerationConfig);
8
+ moderateContent(operation: Operation): Promise<void>;
9
+ private moderateImageContent;
10
+ private moderateTextContent;
11
+ private moderateVideoContent;
12
+ }
13
+ //# sourceMappingURL=ModerationMixin.d.ts.map