@live-change/message-authentication-service 0.2.6 → 0.2.8
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/index.js +63 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -259,6 +259,23 @@ definition.trigger({
|
|
|
259
259
|
}
|
|
260
260
|
})
|
|
261
261
|
|
|
262
|
+
definition.trigger({
|
|
263
|
+
name: 'connectWithMessageAuthenticated',
|
|
264
|
+
waitForEvents: true,
|
|
265
|
+
properties: {
|
|
266
|
+
...contactProperties
|
|
267
|
+
},
|
|
268
|
+
async execute({ contactType, contact, user }, { client, service }, emit) {
|
|
269
|
+
const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
|
|
270
|
+
await service.trigger({
|
|
271
|
+
type: 'connect' + contactTypeUpperCase,
|
|
272
|
+
[contactType]: contact,
|
|
273
|
+
user
|
|
274
|
+
})
|
|
275
|
+
return user
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
|
|
262
279
|
for(const contactType of config.contactTypes) {
|
|
263
280
|
const contactTypeUpperCaseName = contactType[0].toUpperCase() + contactType.slice(1)
|
|
264
281
|
|
|
@@ -326,18 +343,35 @@ for(const contactType of config.contactTypes) {
|
|
|
326
343
|
|
|
327
344
|
if(contactConfig.connect || config.connect ) {
|
|
328
345
|
definition.action({
|
|
329
|
-
name: 'connect',
|
|
346
|
+
name: 'connect' + contactTypeUpperCaseName,
|
|
330
347
|
properties: {
|
|
331
348
|
...contactTypeProperties
|
|
332
349
|
},
|
|
350
|
+
access: (params, { client }) => {
|
|
351
|
+
return !!client.user
|
|
352
|
+
},
|
|
333
353
|
async execute({ [contactTypeName]: contact }, { client, service }, emit) {
|
|
334
|
-
|
|
354
|
+
await service.trigger({
|
|
355
|
+
type: 'checkNew' + contactTypeUName,
|
|
356
|
+
[contactType]: contact,
|
|
357
|
+
})
|
|
358
|
+
return service.triggerService(definition.name, {
|
|
359
|
+
type: 'authenticateWithMessage',
|
|
360
|
+
contactType,
|
|
361
|
+
contact,
|
|
362
|
+
action: 'connectWithMessage',
|
|
363
|
+
actionProperties: {
|
|
364
|
+
user: client.user
|
|
365
|
+
},
|
|
366
|
+
messageData: {
|
|
367
|
+
user: client.user
|
|
368
|
+
},
|
|
369
|
+
targetPage: config.signUpTargetPage || { name: 'user:connectFinished' }
|
|
370
|
+
})
|
|
335
371
|
}
|
|
336
372
|
})
|
|
337
373
|
}
|
|
338
374
|
|
|
339
|
-
|
|
340
|
-
|
|
341
375
|
if(contactConfig.signUp || config.signUp) {
|
|
342
376
|
definition.action({
|
|
343
377
|
name: 'signInOrSignUp' + contactTypeUpperCaseName,
|
|
@@ -346,7 +380,31 @@ for(const contactType of config.contactTypes) {
|
|
|
346
380
|
...contactTypeProperties
|
|
347
381
|
},
|
|
348
382
|
async execute({ [contactType]: contact }, { client, service }, emit) {
|
|
349
|
-
|
|
383
|
+
const contactData = await service.trigger({
|
|
384
|
+
type: 'get' + contactTypeUName + 'OrNull',
|
|
385
|
+
[contactType]: contact,
|
|
386
|
+
})
|
|
387
|
+
if(contactData) {
|
|
388
|
+
const messageData = {
|
|
389
|
+
user: contactData.user
|
|
390
|
+
}
|
|
391
|
+
return service.triggerService(definition.name, {
|
|
392
|
+
type: 'authenticateWithMessage',
|
|
393
|
+
contactType,
|
|
394
|
+
contact,
|
|
395
|
+
messageData,
|
|
396
|
+
action: 'signInWithMessage',
|
|
397
|
+
targetPage: config.signInTargetPage || { name: 'user:signInFinished' }
|
|
398
|
+
})
|
|
399
|
+
} else {
|
|
400
|
+
return service.triggerService(definition.name, {
|
|
401
|
+
type: 'authenticateWithMessage',
|
|
402
|
+
contactType,
|
|
403
|
+
contact,
|
|
404
|
+
action: 'signUpWithMessage',
|
|
405
|
+
targetPage: config.signUpTargetPage || { name: 'user:signUpFinished' }
|
|
406
|
+
})
|
|
407
|
+
}
|
|
350
408
|
}
|
|
351
409
|
})
|
|
352
410
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/message-authentication-service",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@live-change/framework": "^0.5.7",
|
|
25
25
|
"nodemailer": "^6.7.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "1e8102d02b6745fea401e967c211c6a9cb03e19b"
|
|
28
28
|
}
|