@live-change/message-authentication-service 0.2.8 → 0.2.9
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 +37 -13
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -231,7 +231,7 @@ definition.trigger({
|
|
|
231
231
|
const user = app.generateUid()
|
|
232
232
|
await service.trigger({
|
|
233
233
|
type: 'connect' + contactTypeUpperCase,
|
|
234
|
-
[
|
|
234
|
+
[contactTypeName]: contact,
|
|
235
235
|
user
|
|
236
236
|
})
|
|
237
237
|
await service.trigger({
|
|
@@ -277,15 +277,13 @@ definition.trigger({
|
|
|
277
277
|
})
|
|
278
278
|
|
|
279
279
|
for(const contactType of config.contactTypes) {
|
|
280
|
-
const contactTypeUpperCaseName = contactType[0].toUpperCase() + contactType.slice(1)
|
|
281
280
|
|
|
282
281
|
const contactConfig = (typeof contactType == "string") ? { name: contactType } : contactType
|
|
283
|
-
|
|
284
282
|
const contactTypeName = contactConfig.name
|
|
285
283
|
const contactTypeUName = contactTypeName[0].toUpperCase() + contactTypeName.slice(1)
|
|
286
284
|
|
|
287
285
|
const contactTypeProperties = {
|
|
288
|
-
[
|
|
286
|
+
[contactTypeName]: {
|
|
289
287
|
type: String,
|
|
290
288
|
validation: ['nonEmpty', contactTypeName]
|
|
291
289
|
}
|
|
@@ -293,7 +291,7 @@ for(const contactType of config.contactTypes) {
|
|
|
293
291
|
|
|
294
292
|
if(contactConfig.signUp || config.signUp) {
|
|
295
293
|
definition.action({
|
|
296
|
-
name: 'signUp' +
|
|
294
|
+
name: 'signUp' + contactTypeUName,
|
|
297
295
|
waitForEvents: true,
|
|
298
296
|
properties: {
|
|
299
297
|
...contactTypeProperties
|
|
@@ -301,7 +299,7 @@ for(const contactType of config.contactTypes) {
|
|
|
301
299
|
async execute({ [contactTypeName]: contact }, { client, service }, emit) {
|
|
302
300
|
await service.trigger({
|
|
303
301
|
type: 'checkNew' + contactTypeUName,
|
|
304
|
-
[
|
|
302
|
+
[contactTypeName]: contact,
|
|
305
303
|
})
|
|
306
304
|
return service.triggerService(definition.name, {
|
|
307
305
|
type: 'authenticateWithMessage',
|
|
@@ -316,7 +314,7 @@ for(const contactType of config.contactTypes) {
|
|
|
316
314
|
|
|
317
315
|
if(contactConfig.signUp || config.signUp || contactConfig.signIn || config.signIn) {
|
|
318
316
|
definition.action({
|
|
319
|
-
name: 'signIn' +
|
|
317
|
+
name: 'signIn' + contactTypeUName,
|
|
320
318
|
waitForEvents: true,
|
|
321
319
|
properties: {
|
|
322
320
|
...contactTypeProperties
|
|
@@ -324,7 +322,7 @@ for(const contactType of config.contactTypes) {
|
|
|
324
322
|
async execute({ [contactTypeName]: contact }, { client, service }, emit) {
|
|
325
323
|
const contactData = await service.trigger({
|
|
326
324
|
type: 'get' + contactTypeUName,
|
|
327
|
-
[
|
|
325
|
+
[contactTypeName]: contact,
|
|
328
326
|
})
|
|
329
327
|
const messageData = {
|
|
330
328
|
user: contactData.user
|
|
@@ -343,7 +341,7 @@ for(const contactType of config.contactTypes) {
|
|
|
343
341
|
|
|
344
342
|
if(contactConfig.connect || config.connect ) {
|
|
345
343
|
definition.action({
|
|
346
|
-
name: 'connect' +
|
|
344
|
+
name: 'connect' + contactTypeUName,
|
|
347
345
|
properties: {
|
|
348
346
|
...contactTypeProperties
|
|
349
347
|
},
|
|
@@ -353,7 +351,7 @@ for(const contactType of config.contactTypes) {
|
|
|
353
351
|
async execute({ [contactTypeName]: contact }, { client, service }, emit) {
|
|
354
352
|
await service.trigger({
|
|
355
353
|
type: 'checkNew' + contactTypeUName,
|
|
356
|
-
[
|
|
354
|
+
[contactTypeName]: contact,
|
|
357
355
|
})
|
|
358
356
|
return service.triggerService(definition.name, {
|
|
359
357
|
type: 'authenticateWithMessage',
|
|
@@ -370,19 +368,45 @@ for(const contactType of config.contactTypes) {
|
|
|
370
368
|
})
|
|
371
369
|
}
|
|
372
370
|
})
|
|
371
|
+
|
|
372
|
+
definition.action({
|
|
373
|
+
name: 'disconnect' + contactTypeUName,
|
|
374
|
+
properties: {
|
|
375
|
+
...contactTypeProperties
|
|
376
|
+
},
|
|
377
|
+
access: (params, { client }) => {
|
|
378
|
+
return !!client.user
|
|
379
|
+
},
|
|
380
|
+
async execute({ [contactTypeName]: contact }, { client, service }, emit) {
|
|
381
|
+
const contacts = (await service.trigger({
|
|
382
|
+
type: 'getConnectedContacts',
|
|
383
|
+
user: client.user
|
|
384
|
+
})).flat()
|
|
385
|
+
console.log("CONTACTS", contacts, contactTypeName, contact)
|
|
386
|
+
const contactData = contacts.find(c => c.type == contactTypeName && c.contact == contact)
|
|
387
|
+
if(!contactData) throw 'notFound'
|
|
388
|
+
if(contacts.length == 1) throw 'lastOne'
|
|
389
|
+
console.log("DISCONNECT", contact)
|
|
390
|
+
return await service.trigger({
|
|
391
|
+
type: 'disconnect' + contactTypeUName,
|
|
392
|
+
[contactTypeName]: contact,
|
|
393
|
+
user: client.user
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
})
|
|
373
397
|
}
|
|
374
398
|
|
|
375
399
|
if(contactConfig.signUp || config.signUp) {
|
|
376
400
|
definition.action({
|
|
377
|
-
name: 'signInOrSignUp' +
|
|
401
|
+
name: 'signInOrSignUp' + contactTypeUName,
|
|
378
402
|
waitForEvents: true,
|
|
379
403
|
properties: {
|
|
380
404
|
...contactTypeProperties
|
|
381
405
|
},
|
|
382
|
-
async execute({ [
|
|
406
|
+
async execute({ [contactTypeName]: contact }, { client, service }, emit) {
|
|
383
407
|
const contactData = await service.trigger({
|
|
384
408
|
type: 'get' + contactTypeUName + 'OrNull',
|
|
385
|
-
[
|
|
409
|
+
[contactTypeName]: contact,
|
|
386
410
|
})
|
|
387
411
|
if(contactData) {
|
|
388
412
|
const messageData = {
|
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.9",
|
|
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": "5362172c498a5d131b945c4a2f4644565a5c9a3c"
|
|
28
28
|
}
|