sockethub 4.0.0 → 5.0.0-alpha.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/README.md +3 -3
- package/bin/sockethub +23 -19
- package/coverage/tmp/coverage-15699-1646422276150-0.json +1 -0
- package/dist/bootstrap/init.js +14 -4
- package/dist/bootstrap/init.js.map +1 -1
- package/dist/bootstrap/platforms.js +81 -69
- package/dist/common.js +10 -12
- package/dist/common.js.map +1 -1
- package/dist/config.js +4 -22
- package/dist/config.js.map +1 -1
- package/dist/crypto.js +7 -8
- package/dist/crypto.js.map +1 -1
- package/dist/janitor.js +14 -9
- package/dist/janitor.js.map +1 -1
- package/dist/middleware/create-activity-object.js +19 -0
- package/dist/middleware/create-activity-object.js.map +1 -0
- package/dist/middleware/expand-activity-stream.js +33 -0
- package/dist/middleware/expand-activity-stream.js.map +1 -0
- package/dist/middleware/expand-activity-stream.test.data.js +360 -0
- package/dist/middleware/expand-activity-stream.test.data.js.map +1 -0
- package/dist/middleware/store-credentials.js +19 -0
- package/dist/middleware/store-credentials.js.map +1 -0
- package/dist/middleware/validate.js +77 -0
- package/dist/middleware/validate.js.map +1 -0
- package/dist/middleware/validate.test.data.js +321 -0
- package/dist/middleware/validate.test.data.js.map +1 -0
- package/dist/middleware.js +47 -49
- package/dist/middleware.js.map +1 -1
- package/dist/platform-instance.js +84 -66
- package/dist/platform-instance.js.map +1 -1
- package/dist/platform.js +50 -25
- package/dist/platform.js.map +1 -1
- package/dist/process-manager.js +7 -4
- package/dist/process-manager.js.map +1 -1
- package/dist/routes.js +9 -7
- package/dist/routes.js.map +1 -1
- package/dist/serve.js +3 -3
- package/dist/serve.js.map +1 -1
- package/dist/sockethub-client.js +2604 -0
- package/dist/sockethub-client.js.map +1 -0
- package/dist/sockethub-client.min.js +2 -0
- package/dist/sockethub-client.min.js.LICENSE.txt +24 -0
- package/dist/sockethub.js +75 -58
- package/dist/sockethub.js.map +1 -1
- package/dist/store.js +17 -0
- package/dist/store.js.map +1 -0
- package/package.json +48 -44
- package/src/bootstrap/init.ts +16 -2
- package/src/bootstrap/platforms.js +14 -18
- package/src/common.test.ts +44 -33
- package/src/common.ts +9 -17
- package/src/config.test.ts +16 -38
- package/src/config.ts +1 -23
- package/src/crypto.test.ts +15 -17
- package/src/crypto.ts +4 -5
- package/src/janitor.ts +19 -12
- package/src/middleware/create-activity-object.test.ts +10 -0
- package/src/middleware/create-activity-object.ts +13 -0
- package/src/middleware/expand-activity-stream.test.data.ts +365 -0
- package/src/middleware/expand-activity-stream.test.ts +78 -0
- package/src/middleware/expand-activity-stream.ts +27 -0
- package/src/middleware/store-credentials.test.ts +72 -0
- package/src/middleware/store-credentials.ts +16 -0
- package/src/{validate.d.ts → middleware/validate.d.ts} +0 -0
- package/src/middleware/validate.test.data.ts +320 -0
- package/src/middleware/validate.test.ts +47 -0
- package/src/middleware/validate.ts +49 -0
- package/src/middleware.test.ts +148 -0
- package/src/middleware.ts +46 -51
- package/src/platform-instance.test.ts +224 -196
- package/src/platform-instance.ts +74 -58
- package/src/platform.ts +44 -24
- package/src/process-manager.ts +7 -4
- package/src/routes.test.ts +32 -17
- package/src/routes.ts +8 -6
- package/src/serve.ts +1 -1
- package/src/sockethub-client.test.ts +235 -0
- package/src/sockethub-client.ts +164 -0
- package/src/sockethub.ts +96 -93
- package/src/store.test.ts +26 -0
- package/src/store.ts +17 -0
- package/tsconfig.json +8 -8
- package/views/examples/dummy.ejs +7 -7
- package/views/examples/feeds.ejs +10 -10
- package/views/examples/irc.ejs +65 -59
- package/views/examples/shared.js +31 -29
- package/views/examples/xmpp.ejs +49 -58
- package/webpack.minified.config.js +14 -0
- package/webpack.normal.config.js +14 -0
- package/coverage/clover.xml +0 -190
- package/coverage/coverage-final.json +0 -6
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/common.ts.html +0 -143
- package/coverage/lcov-report/config.ts.html +0 -359
- package/coverage/lcov-report/crypto.ts.html +0 -203
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -171
- package/coverage/lcov-report/platform-instance.ts.html +0 -740
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/routes.ts.html +0 -353
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/src/common.ts.html +0 -143
- package/coverage/lcov-report/src/config.ts.html +0 -359
- package/coverage/lcov-report/src/crypto.ts.html +0 -182
- package/coverage/lcov-report/src/index.html +0 -156
- package/coverage/lcov-report/src/platform-instance.ts.html +0 -740
- package/coverage/lcov-report/src/routes/base.ts.html +0 -359
- package/coverage/lcov-report/src/routes/examples.ts.html +0 -311
- package/coverage/lcov-report/src/routes/index.html +0 -111
- package/coverage/lcov-report/src/services/http.ts.html +0 -239
- package/coverage/lcov-report/src/services/index.html +0 -111
- package/coverage/lcov-report/src/services/redis.ts.html +0 -140
- package/coverage/lcov-report/src/shared-resources.ts.html +0 -104
- package/coverage/lcov.info +0 -336
- package/coverage/tmp/coverage-70996-1620314182345-0.json +0 -1
- package/dist/bootstrap/platforms.js.map +0 -1
- package/dist/js/client.js +0 -177
- package/dist/js/client.js.map +0 -1
- package/dist/resource-manager.js +0 -66
- package/dist/resource-manager.js.map +0 -1
- package/dist/routes/base.js +0 -92
- package/dist/routes/base.js.map +0 -1
- package/dist/routes/examples.js +0 -93
- package/dist/routes/examples.js.map +0 -1
- package/dist/services/http.js +0 -68
- package/dist/services/http.js.map +0 -1
- package/dist/services/redis.js +0 -1
- package/dist/services/redis.js.map +0 -1
- package/dist/shared-resources.js +0 -11
- package/dist/shared-resources.js.map +0 -1
- package/dist/validate.js +0 -157
- package/dist/validate.js.map +0 -1
- package/jest.config.js +0 -18
- package/src/js/client.js +0 -190
- package/src/validate.ts +0 -147
- package/test/middleware-suite.js +0 -101
- package/test/validate-suite.js +0 -338
package/test/validate-suite.js
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
if (typeof define !== 'function') {
|
|
2
|
-
let define = require('amdefine')(module);
|
|
3
|
-
}
|
|
4
|
-
define(['require', '../dist/validate', 'activity-streams'], function (require, library, AS) {
|
|
5
|
-
const validate = library.default;
|
|
6
|
-
let activity = new AS();
|
|
7
|
-
let errMsg = '';
|
|
8
|
-
let suites = [];
|
|
9
|
-
|
|
10
|
-
let testGroups = [
|
|
11
|
-
{
|
|
12
|
-
name: 'one',
|
|
13
|
-
result: true,
|
|
14
|
-
type: 'credentials',
|
|
15
|
-
input: {
|
|
16
|
-
'@id': 'blah',
|
|
17
|
-
'@type': 'send',
|
|
18
|
-
context: 'dummy',
|
|
19
|
-
actor: {
|
|
20
|
-
'@id': 'dood@irc.freenode.net',
|
|
21
|
-
'@type': 'person',
|
|
22
|
-
displayName: 'dood',
|
|
23
|
-
},
|
|
24
|
-
target: {
|
|
25
|
-
'@id': 'irc.freenode.net/sockethub',
|
|
26
|
-
'@type': 'person',
|
|
27
|
-
displayName: 'sockethub'
|
|
28
|
-
},
|
|
29
|
-
object: {
|
|
30
|
-
'@type': 'credentials'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
output: 'same'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: 'new format',
|
|
37
|
-
result: true,
|
|
38
|
-
type: 'credentials',
|
|
39
|
-
input: {
|
|
40
|
-
context: 'irc',
|
|
41
|
-
actor: {
|
|
42
|
-
'@id': 'sh-9K3Vk@irc.freenode.net',
|
|
43
|
-
'@type': 'person',
|
|
44
|
-
displayName: 'sh-9K3Vk',
|
|
45
|
-
image: {
|
|
46
|
-
height: 250,
|
|
47
|
-
mediaType: 'image/jpeg',
|
|
48
|
-
url: 'http://example.org/image.jpg',
|
|
49
|
-
width: 250
|
|
50
|
-
},
|
|
51
|
-
url: 'http://sockethub.org'
|
|
52
|
-
},
|
|
53
|
-
object: {
|
|
54
|
-
'@type': 'credentials',
|
|
55
|
-
nick: 'sh-9K3Vk',
|
|
56
|
-
port: 6667,
|
|
57
|
-
secure: false,
|
|
58
|
-
server: 'irc.freenode.net'
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
output: 'same'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'no type',
|
|
65
|
-
result: false,
|
|
66
|
-
type: 'credentials',
|
|
67
|
-
input: {
|
|
68
|
-
'actor': 'hyper_rau@localhost',
|
|
69
|
-
'context': 'xmpp',
|
|
70
|
-
'object': {
|
|
71
|
-
'username': 'hyper_rau',
|
|
72
|
-
'password': '123',
|
|
73
|
-
'server': 'localhost',
|
|
74
|
-
'port': 5222,
|
|
75
|
-
'resource': 'laptop'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'person',
|
|
81
|
-
type: 'activity-object',
|
|
82
|
-
result: true,
|
|
83
|
-
input: {
|
|
84
|
-
'@id': 'blah',
|
|
85
|
-
'@type': 'person',
|
|
86
|
-
displayName: 'dood'
|
|
87
|
-
},
|
|
88
|
-
output: 'same'
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: 'person with extras',
|
|
92
|
-
result: true,
|
|
93
|
-
type: 'activity-object',
|
|
94
|
-
input: {
|
|
95
|
-
'@id': 'blah',
|
|
96
|
-
'@type': 'person',
|
|
97
|
-
displayName: 'bob',
|
|
98
|
-
hello: 'there',
|
|
99
|
-
i: [ 'am', 'extras' ]
|
|
100
|
-
},
|
|
101
|
-
output: 'same'
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: 'alone credentials (as activity-object)',
|
|
105
|
-
result: false,
|
|
106
|
-
type: 'activity-object',
|
|
107
|
-
input: {
|
|
108
|
-
'@type': 'credentials',
|
|
109
|
-
nick: 'sh-9K3Vk',
|
|
110
|
-
port: 6667,
|
|
111
|
-
secure: false,
|
|
112
|
-
server: 'irc.freenode.net'
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: 'alone credentials (as credentials)',
|
|
117
|
-
result: false,
|
|
118
|
-
type: 'credentials',
|
|
119
|
-
input: {
|
|
120
|
-
'@type': 'credentials',
|
|
121
|
-
nick: 'sh-9K3Vk',
|
|
122
|
-
port: 6667,
|
|
123
|
-
secure: false,
|
|
124
|
-
server: 'irc.freenode.net'
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: 'new person',
|
|
129
|
-
result: true,
|
|
130
|
-
type: 'activity-object',
|
|
131
|
-
input: {
|
|
132
|
-
'@id': 'sh-9K3Vk@irc.freenode.net',
|
|
133
|
-
'@type': 'person',
|
|
134
|
-
displayName: 'sh-9K3Vk',
|
|
135
|
-
image: {
|
|
136
|
-
height: 250,
|
|
137
|
-
mediaType: 'image/jpeg',
|
|
138
|
-
url: 'http://example.org/image.jpg',
|
|
139
|
-
width: 250
|
|
140
|
-
},
|
|
141
|
-
url: 'http://sockethub.org'
|
|
142
|
-
},
|
|
143
|
-
output: 'same'
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: 'new person',
|
|
147
|
-
result: true,
|
|
148
|
-
type: 'activity-object',
|
|
149
|
-
input: {
|
|
150
|
-
'@id': 'irc://sh-9K3Vk@irc.freenode.net',
|
|
151
|
-
'@type': 'person',
|
|
152
|
-
displayName: 'sh-9K3Vk',
|
|
153
|
-
url: 'http://sockethub.org'
|
|
154
|
-
},
|
|
155
|
-
output: 'same'
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: 'bad parent object',
|
|
159
|
-
result: false,
|
|
160
|
-
type: 'activity-object',
|
|
161
|
-
input: {
|
|
162
|
-
string: 'this is a string',
|
|
163
|
-
array: ['this', 'is', { an: 'array'} ],
|
|
164
|
-
as: {
|
|
165
|
-
'@id': 'blah',
|
|
166
|
-
'@type': 'send',
|
|
167
|
-
context: 'hello',
|
|
168
|
-
actor: {
|
|
169
|
-
displayName: 'dood'
|
|
170
|
-
},
|
|
171
|
-
target: {
|
|
172
|
-
'@type': 'person',
|
|
173
|
-
displayName: 'bob'
|
|
174
|
-
},
|
|
175
|
-
object: {
|
|
176
|
-
'@type': 'credentials'
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
noId: {
|
|
180
|
-
displayName: 'dood'
|
|
181
|
-
},
|
|
182
|
-
noId2: {
|
|
183
|
-
'@type': 'person',
|
|
184
|
-
displayName: 'bob'
|
|
185
|
-
},
|
|
186
|
-
noDisplayName: {
|
|
187
|
-
'@id': 'larg',
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: 'expand actor and target of unknowns',
|
|
193
|
-
result: true,
|
|
194
|
-
type: 'message',
|
|
195
|
-
input: {
|
|
196
|
-
'actor': 'irc://uuu@localhost',
|
|
197
|
-
'@type': 'join',
|
|
198
|
-
'context': 'irc',
|
|
199
|
-
'target': 'irc://irc.dooder.net/a-room'
|
|
200
|
-
},
|
|
201
|
-
output: {
|
|
202
|
-
'actor': {
|
|
203
|
-
'@id': 'irc://uuu@localhost',
|
|
204
|
-
'displayName': 'uuu'
|
|
205
|
-
},
|
|
206
|
-
'@type': 'join',
|
|
207
|
-
'context': 'irc',
|
|
208
|
-
'target': {
|
|
209
|
-
'@id': 'irc://irc.dooder.net/a-room',
|
|
210
|
-
'displayName': '/a-room'
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
name: 'expand actor and target of unknowns',
|
|
216
|
-
result: true,
|
|
217
|
-
type: 'message',
|
|
218
|
-
input: {
|
|
219
|
-
'actor': 'hyper_rau@localhost',
|
|
220
|
-
'@type': 'join',
|
|
221
|
-
'context': 'xmpp',
|
|
222
|
-
'object': {},
|
|
223
|
-
target: 'dooder'
|
|
224
|
-
},
|
|
225
|
-
output: {
|
|
226
|
-
'actor': {
|
|
227
|
-
'@id': 'hyper_rau@localhost',
|
|
228
|
-
displayName: 'hyper_rau@localhost'
|
|
229
|
-
},
|
|
230
|
-
'@type': 'join',
|
|
231
|
-
'context': 'xmpp',
|
|
232
|
-
'object': {},
|
|
233
|
-
target: {
|
|
234
|
-
'@id': 'dooder',
|
|
235
|
-
displayName: 'dooder'
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: 'expand known person',
|
|
241
|
-
result: true,
|
|
242
|
-
type: 'message',
|
|
243
|
-
input: {
|
|
244
|
-
actor: 'sh-9K3Vk@irc.freenode.net',
|
|
245
|
-
target: 'blah',
|
|
246
|
-
'@type': 'send',
|
|
247
|
-
context: 'irc',
|
|
248
|
-
object: {}
|
|
249
|
-
},
|
|
250
|
-
output: {
|
|
251
|
-
actor: {
|
|
252
|
-
'@id': 'sh-9K3Vk@irc.freenode.net',
|
|
253
|
-
'@type': 'person',
|
|
254
|
-
displayName: 'sh-9K3Vk',
|
|
255
|
-
image: {
|
|
256
|
-
height: 250,
|
|
257
|
-
mediaType: 'image/jpeg',
|
|
258
|
-
url: 'http://example.org/image.jpg',
|
|
259
|
-
width: 250
|
|
260
|
-
},
|
|
261
|
-
url: 'http://sockethub.org'
|
|
262
|
-
},
|
|
263
|
-
target: {
|
|
264
|
-
'@id': 'blah',
|
|
265
|
-
'@type': 'person',
|
|
266
|
-
displayName: 'bob',
|
|
267
|
-
hello: 'there',
|
|
268
|
-
i: [ 'am', 'extras' ]
|
|
269
|
-
},
|
|
270
|
-
'@type': 'send',
|
|
271
|
-
context: 'irc',
|
|
272
|
-
object: {}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
];
|
|
276
|
-
|
|
277
|
-
function buildTest(name, result, type, input, output) {
|
|
278
|
-
let string = 'fail';
|
|
279
|
-
if (result) {
|
|
280
|
-
string = 'pass';
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
let test = {
|
|
284
|
-
desc: '# [' + string + '] ' + name,
|
|
285
|
-
run: function (env, test) {
|
|
286
|
-
env.validate(type)((state, msg) => {
|
|
287
|
-
//console.log('input: ', input);
|
|
288
|
-
//console.log('msg: ', msg);
|
|
289
|
-
//console.log('expected output: ', output);
|
|
290
|
-
//console.log('result: ', state);
|
|
291
|
-
|
|
292
|
-
if (output === 'same') {
|
|
293
|
-
test.assertAnd(
|
|
294
|
-
input, msg,
|
|
295
|
-
`input not the same as output. ${JSON.stringify(input)} ... ${JSON.stringify(msg)}`);
|
|
296
|
-
} else if (output) {
|
|
297
|
-
test.assertAnd(
|
|
298
|
-
msg, output,
|
|
299
|
-
`expected and returned output don't match: ` +
|
|
300
|
-
`${JSON.stringify(msg)} ... ${JSON.stringify(output)}`);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
test.assertAnd(
|
|
304
|
-
result, state,
|
|
305
|
-
`results don't match: ${JSON.stringify(result)} ... ${JSON.stringify(state)}`);
|
|
306
|
-
|
|
307
|
-
if ((result) && (type === 'activity-object')) {
|
|
308
|
-
// console.log('activity: ', activity);
|
|
309
|
-
activity.Object.create(msg);
|
|
310
|
-
}
|
|
311
|
-
test.done();
|
|
312
|
-
}, input);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
return test;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function buildSuite(type) {
|
|
319
|
-
return {
|
|
320
|
-
desc: 'validate middleware - ' + type,
|
|
321
|
-
timeout: 1000,
|
|
322
|
-
abortOnFail: true,
|
|
323
|
-
setup: function (env, test) {
|
|
324
|
-
test.assertTypeAnd(validate, 'function');
|
|
325
|
-
env.validate = validate;
|
|
326
|
-
test.assertType(env.validate, 'function');
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
let suite = buildSuite('input validation tests');
|
|
332
|
-
let tests = [];
|
|
333
|
-
testGroups.forEach(function (entry, i) {
|
|
334
|
-
tests.push(buildTest(entry.name, entry.result, entry.type, entry.input, entry.output));
|
|
335
|
-
});
|
|
336
|
-
suite.tests = tests;
|
|
337
|
-
return [ suite ];
|
|
338
|
-
});
|