@live-change/message-authentication-service 0.2.6 → 0.2.13

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.
@@ -0,0 +1,219 @@
1
+ const app = require("@live-change/framework").app()
2
+ const definition = require('./definition.js')
3
+ const config = definition.config
4
+
5
+ const contactProperties = {
6
+ contactType: {
7
+ type: String,
8
+ validation: ['nonEmpty']
9
+ },
10
+ contact: {
11
+ type: String,
12
+ validation: ['nonEmpty']
13
+ }
14
+ }
15
+
16
+ const targetProperties = {
17
+ action: {
18
+ type: String,
19
+ validation: ['nonEmpty'],
20
+ },
21
+ actionProperties: {
22
+ type: Object
23
+ },
24
+ targetPage: {
25
+ type: Object,
26
+ validation: ['nonEmpty'],
27
+ properties: {
28
+ name: {
29
+ type: String,
30
+ validation: ['nonEmpty']
31
+ },
32
+ params: {
33
+ type: Object
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ const messageProperties = {
40
+ messageData: {
41
+ type: Object
42
+ }
43
+ }
44
+
45
+ const Authentication = definition.model({
46
+ name: 'Authentication',
47
+ properties: {
48
+ ...contactProperties,
49
+ ...targetProperties,
50
+ ...messageProperties,
51
+ state: {
52
+ type: "String",
53
+ validation: ['nonEmpty'],
54
+ options: ['created', 'used']
55
+ }
56
+ }
57
+ })
58
+
59
+ definition.event({
60
+ name: 'authenticationCreated',
61
+ execute({ authentication, contactType, contact, action, actionProperties, targetPage, messageData }) {
62
+ return Authentication.create({
63
+ id: authentication,
64
+ contactType, contact,
65
+ action, actionProperties, targetPage,
66
+ messageData,
67
+ state: 'created'
68
+ })
69
+ }
70
+ })
71
+
72
+ definition.event({
73
+ name: 'authenticationUsed',
74
+ execute({ authentication, targetPage }) {
75
+ return Authentication.update(authentication, { state: 'used', targetPage })
76
+ }
77
+ })
78
+
79
+ definition.view({
80
+ name: "authentication",
81
+ properties: {
82
+ authentication: {
83
+ type: Authentication
84
+ }
85
+ },
86
+ daoPath({ authentication }, { client, context }) {
87
+ return Authentication.path(authentication)
88
+ }
89
+ })
90
+
91
+ definition.trigger({
92
+ name: 'authenticateWithMessage',
93
+ waitForEvents: true,
94
+ properties: {
95
+ ...contactProperties,
96
+ ...targetProperties,
97
+ ...messageProperties
98
+ },
99
+ async execute({ contactType, contact, action, actionProperties, targetPage, messageData },
100
+ { client, service }, emit) {
101
+ const authentication = app.generateUid()
102
+ const secrets = await service.trigger({
103
+ type: 'authenticationSecret',
104
+ authentication
105
+ })
106
+ if(secrets.length == 0) throw new Error('no secrets generated!')
107
+ const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
108
+ await service.trigger({
109
+ type: 'send' + contactTypeUpperCase + 'Message',
110
+ render: {
111
+ action,
112
+ contactType,
113
+ contact,
114
+ secrets,
115
+ ...messageData
116
+ }
117
+ })
118
+ emit({
119
+ type: "authenticationCreated",
120
+ authentication,
121
+ contactType,
122
+ contact,
123
+ action,
124
+ actionProperties,
125
+ targetPage,
126
+ messageData
127
+ })
128
+ return {
129
+ type: 'sent',
130
+ authentication,
131
+ secrets: secrets.map(({ secret, ...notSecret }) => notSecret)
132
+ }
133
+ }
134
+ })
135
+
136
+ definition.action({
137
+ name: 'finishMessageAuthentication',
138
+ waitForEvents: true,
139
+ properties: {
140
+ secretType: {
141
+ type: String,
142
+ validation: ['nonEmpty']
143
+ },
144
+ secret: {
145
+ type: String,
146
+ validation: ['nonEmpty']
147
+ },
148
+ authentication: {
149
+ type: Authentication
150
+ }
151
+ },
152
+ async execute({ secretType, secret, authentication = undefined }, { client, service }, emit) {
153
+ const secretTypeUpperCase = secretType[0].toUpperCase() + secretType.slice(1)
154
+ const checkResults = await service.trigger({
155
+ type: 'check' + secretTypeUpperCase + 'Secret',
156
+ secret,
157
+ authentication
158
+ })
159
+ authentication = checkResults[0]
160
+ const authenticationData = await Authentication.get(authentication)
161
+ if(authenticationData.state == 'used') throw 'authenticationUsed'
162
+ const actionName = authenticationData.action
163
+ const actionResults = await service.trigger({
164
+ type: actionName+'Authenticated',
165
+ ...authenticationData.actionProperties,
166
+ contactType: authenticationData.contactType,
167
+ contact: authenticationData.contact,
168
+ session: client.session
169
+ })
170
+ const result = actionResults[0]
171
+ const targetPage = (typeof result == 'object')
172
+ ? { ...authenticationData.targetPage, params: { ...authenticationData.targetPage.params, ...result } }
173
+ : authenticationData.targetPage
174
+ emit({
175
+ type: 'authenticationUsed',
176
+ authentication,
177
+ targetPage
178
+ })
179
+ return { result, targetPage }
180
+ }
181
+ })
182
+
183
+ definition.action({
184
+ name: 'resendMessageAuthentication',
185
+ waitForEvents: true,
186
+ properties: {
187
+ authentication: {
188
+ type: Authentication,
189
+ validation: ['nonEmpty']
190
+ }
191
+ },
192
+ async execute({ authentication }, { client, service }, emit) {
193
+ const authenticationData = await Authentication.get(authentication)
194
+ if(!authenticationData) throw 'notFound'
195
+ const { contactType, contact, action } = authenticationData
196
+ const secrets = await service.trigger({
197
+ type: 'refreshAuthenticationSecret',
198
+ authentication
199
+ })
200
+ if(secrets.length == 0) throw new Error('no secrets generated!')
201
+ const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
202
+ await service.trigger({
203
+ type: 'send' + contactTypeUpperCase + 'Message',
204
+ render: {
205
+ action,
206
+ contactType,
207
+ contact,
208
+ secrets,
209
+ ...authentication.messageData
210
+ }
211
+ })
212
+ return {
213
+ authentication,
214
+ secrets: secrets.map(({ secret, ...notSecret }) => notSecret)
215
+ }
216
+ }
217
+ })
218
+
219
+ module.exports = { Authentication, contactProperties, targetProperties, messageProperties }
package/definition.js ADDED
@@ -0,0 +1,7 @@
1
+ const app = require("@live-change/framework").app()
2
+
3
+ const definition = app.createServiceDefinition({
4
+ name: "messageAuthentication"
5
+ })
6
+
7
+ module.exports = definition
package/index.js CHANGED
@@ -1,356 +1,9 @@
1
- const autoValidation = require('@live-change/framework/lib/processors/autoValidation')
2
- const nodemailer = require('nodemailer')
3
1
  const app = require("@live-change/framework").app()
4
2
 
5
- const definition = app.createServiceDefinition({
6
- name: "messageAuthentication"
7
- })
3
+ const definition = require('./definition.js')
8
4
  const config = definition.config
9
5
 
10
- const contactProperties = {
11
- contactType: {
12
- type: String,
13
- validation: ['nonEmpty']
14
- },
15
- contact: {
16
- type: String,
17
- validation: ['nonEmpty']
18
- }
19
- }
20
-
21
- const targetProperties = {
22
- action: {
23
- type: String,
24
- validation: ['nonEmpty'],
25
- },
26
- actionProperties: {
27
- type: Object
28
- },
29
- targetPage: {
30
- type: Object,
31
- validation: ['nonEmpty'],
32
- properties: {
33
- name: {
34
- type: String,
35
- validation: ['nonEmpty']
36
- },
37
- params: {
38
- type: Object
39
- }
40
- }
41
- }
42
- }
43
-
44
- const messageProperties = {
45
- messageData: {
46
- type: Object
47
- }
48
- }
49
-
50
- const Authentication = definition.model({
51
- name: 'Authentication',
52
- properties: {
53
- ...contactProperties,
54
- ...targetProperties,
55
- ...messageProperties,
56
- state: {
57
- type: "String",
58
- validation: ['nonEmpty'],
59
- options: ['created', 'used']
60
- }
61
- }
62
- })
63
-
64
- definition.view({
65
- name: "authentication",
66
- properties: {
67
- authentication: {
68
- type: Authentication
69
- }
70
- },
71
- daoPath({ authentication }, { client, context }) {
72
- return Authentication.path(authentication)
73
- }
74
- })
75
-
76
-
77
- definition.event({
78
- name: 'authenticationCreated',
79
- execute({ authentication, contactType, contact, action, actionProperties, targetPage, messageData }) {
80
- return Authentication.create({
81
- id: authentication,
82
- contactType, contact,
83
- action, actionProperties, targetPage,
84
- messageData,
85
- state: 'created'
86
- })
87
- }
88
- })
89
-
90
- definition.event({
91
- name: 'authenticationUsed',
92
- execute({ authentication }) {
93
- return Authentication.update(authentication, { state: 'used' })
94
- }
95
- })
96
-
97
- definition.trigger({
98
- name: 'authenticateWithMessage',
99
- waitForEvents: true,
100
- properties: {
101
- ...contactProperties,
102
- ...targetProperties,
103
- ...messageProperties
104
- },
105
- async execute({ contactType, contact, action, actionProperties, targetPage, messageData },
106
- { client, service }, emit) {
107
- const authentication = app.generateUid()
108
- const secrets = await service.trigger({
109
- type: 'authenticationSecret',
110
- authentication
111
- })
112
- if(secrets.length == 0) throw new Error('no secrets generated!')
113
- const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
114
- await service.trigger({
115
- type: 'send' + contactTypeUpperCase + 'Message',
116
- render: {
117
- action,
118
- contactType,
119
- contact,
120
- secrets,
121
- ...messageData
122
- }
123
- })
124
- emit({
125
- type: "authenticationCreated",
126
- authentication,
127
- contactType,
128
- contact,
129
- action,
130
- actionProperties,
131
- targetPage,
132
- messageData
133
- })
134
- return {
135
- type: 'sent',
136
- authentication,
137
- secrets: secrets.map(({ secret, ...notSecret }) => notSecret)
138
- }
139
- }
140
- })
141
-
142
- definition.action({
143
- name: 'finishMessageAuthentication',
144
- waitForEvents: true,
145
- properties: {
146
- secretType: {
147
- type: String,
148
- validation: ['nonEmpty']
149
- },
150
- secret: {
151
- type: String,
152
- validation: ['nonEmpty']
153
- },
154
- authentication: {
155
- type: Authentication
156
- }
157
- },
158
- async execute({ secretType, secret, authentication = undefined }, { client, service }, emit) {
159
- const secretTypeUpperCase = secretType[0].toUpperCase() + secretType.slice(1)
160
- const checkResults = await service.trigger({
161
- type: 'check' + secretTypeUpperCase + 'Secret',
162
- secret,
163
- authentication
164
- })
165
- authentication = checkResults[0]
166
- const authenticationData = await Authentication.get(authentication)
167
- if(authenticationData.state == 'used') throw 'authenticationUsed'
168
- const actionName = authenticationData.action
169
- const actionResults = await service.trigger({
170
- type: actionName+'Authenticated',
171
- ...authenticationData.actionProperties,
172
- contactType: authenticationData.contactType,
173
- contact: authenticationData.contact,
174
- session: client.session
175
- })
176
- emit({
177
- type: 'authenticationUsed',
178
- authentication
179
- })
180
- return {
181
- result: actionResults[0],
182
- targetPage: authenticationData.targetPage
183
- }
184
- }
185
- })
186
-
187
- definition.action({
188
- name: 'resendMessageAuthentication',
189
- waitForEvents: true,
190
- properties: {
191
- authentication: {
192
- type: Authentication,
193
- validation: ['nonEmpty']
194
- }
195
- },
196
- async execute({ authentication }, { client, service }, emit) {
197
- const authenticationData = await Authentication.get(authentication)
198
- if(!authenticationData) throw 'notFound'
199
- const { contactType, contact, action } = authenticationData
200
- const secrets = await service.trigger({
201
- type: 'refreshAuthenticationSecret',
202
- authentication
203
- })
204
- if(secrets.length == 0) throw new Error('no secrets generated!')
205
- const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
206
- await service.trigger({
207
- type: 'send' + contactTypeUpperCase + 'Message',
208
- render: {
209
- action,
210
- contactType,
211
- contact,
212
- secrets,
213
- ...authentication.messageData
214
- }
215
- })
216
- return {
217
- authentication,
218
- secrets: secrets.map(({ secret, ...notSecret }) => notSecret)
219
- }
220
- }
221
- })
222
-
223
- definition.trigger({
224
- name: 'signUpWithMessageAuthenticated',
225
- waitForEvents: true,
226
- properties: {
227
- ...contactProperties
228
- },
229
- async execute({ contactType, contact, session }, { service }, emit) {
230
- const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
231
- const user = app.generateUid()
232
- await service.trigger({
233
- type: 'connect' + contactTypeUpperCase,
234
- [contactType]: contact,
235
- user
236
- })
237
- await service.trigger({
238
- type: 'signUpAndSignIn',
239
- user, session
240
- })
241
- return user
242
- }
243
- })
244
-
245
- definition.trigger({
246
- name: 'signInWithMessageAuthenticated',
247
- waitForEvents: true,
248
- properties: {
249
- ...contactProperties
250
- },
251
- async execute({ contactType, contact, session }, { client, service }, emit) {
252
- const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
253
- const user = await service.trigger({
254
- type: 'signIn' + contactTypeUpperCase,
255
- [contactType]: contact,
256
- session
257
- })
258
- return user
259
- }
260
- })
261
-
262
- for(const contactType of config.contactTypes) {
263
- const contactTypeUpperCaseName = contactType[0].toUpperCase() + contactType.slice(1)
264
-
265
- const contactConfig = (typeof contactType == "string") ? { name: contactType } : contactType
266
-
267
- const contactTypeName = contactConfig.name
268
- const contactTypeUName = contactTypeName[0].toUpperCase() + contactTypeName.slice(1)
269
-
270
- const contactTypeProperties = {
271
- [contactType]: {
272
- type: String,
273
- validation: ['nonEmpty', contactTypeName]
274
- }
275
- }
276
-
277
- if(contactConfig.signUp || config.signUp) {
278
- definition.action({
279
- name: 'signUp' + contactTypeUpperCaseName,
280
- waitForEvents: true,
281
- properties: {
282
- ...contactTypeProperties
283
- },
284
- async execute({ [contactTypeName]: contact }, { client, service }, emit) {
285
- await service.trigger({
286
- type: 'checkNew' + contactTypeUName,
287
- [contactType]: contact,
288
- })
289
- return service.triggerService(definition.name, {
290
- type: 'authenticateWithMessage',
291
- contactType,
292
- contact,
293
- action: 'signUpWithMessage',
294
- targetPage: config.signUpTargetPage || { name: 'user:signUpFinished' }
295
- })
296
- }
297
- })
298
- }
299
-
300
- if(contactConfig.signUp || config.signUp || contactConfig.signIn || config.signIn) {
301
- definition.action({
302
- name: 'signIn' + contactTypeUpperCaseName,
303
- waitForEvents: true,
304
- properties: {
305
- ...contactTypeProperties
306
- },
307
- async execute({ [contactTypeName]: contact }, { client, service }, emit) {
308
- const contactData = await service.trigger({
309
- type: 'get' + contactTypeUName,
310
- [contactType]: contact,
311
- })
312
- const messageData = {
313
- user: contactData.user
314
- }
315
- return service.triggerService(definition.name, {
316
- type: 'authenticateWithMessage',
317
- contactType,
318
- contact,
319
- messageData,
320
- action: 'signInWithMessage',
321
- targetPage: config.signInTargetPage || { name: 'user:signInFinished' }
322
- })
323
- }
324
- })
325
- }
326
-
327
- if(contactConfig.connect || config.connect ) {
328
- definition.action({
329
- name: 'connect',
330
- properties: {
331
- ...contactTypeProperties
332
- },
333
- async execute({ [contactTypeName]: contact }, { client, service }, emit) {
334
-
335
- }
336
- })
337
- }
338
-
339
-
340
-
341
- if(contactConfig.signUp || config.signUp) {
342
- definition.action({
343
- name: 'signInOrSignUp' + contactTypeUpperCaseName,
344
- waitForEvents: true,
345
- properties: {
346
- ...contactTypeProperties
347
- },
348
- async execute({ [contactType]: contact }, { client, service }, emit) {
349
-
350
- }
351
- })
352
- }
353
-
354
- }
6
+ require('./authentication.js')
7
+ require('./sign.js')
355
8
 
356
9
  module.exports = definition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/message-authentication-service",
3
- "version": "0.2.6",
3
+ "version": "0.2.13",
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": "2491e82b350403cf187887e8f06d140e0c362860"
27
+ "gitHead": "add122f25ae8a848c2d24e1a75c3c9ae69d86faa"
28
28
  }
package/sign.js ADDED
@@ -0,0 +1,220 @@
1
+ const app = require("@live-change/framework").app()
2
+ const definition = require('./definition.js')
3
+ const config = definition.config
4
+
5
+ const { contactProperties } = require('./authentication.js')
6
+
7
+ definition.trigger({
8
+ name: 'signUpWithMessageAuthenticated',
9
+ waitForEvents: true,
10
+ properties: {
11
+ ...contactProperties
12
+ },
13
+ async execute({ contactType, contact, session }, { service }, emit) {
14
+ const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
15
+ const user = app.generateUid()
16
+ await service.trigger({
17
+ type: 'connect' + contactTypeUpperCase,
18
+ [contactType]: contact,
19
+ user
20
+ })
21
+ await service.trigger({
22
+ type: 'signUpAndSignIn',
23
+ user, session
24
+ })
25
+ return user
26
+ }
27
+ })
28
+
29
+ definition.trigger({
30
+ name: 'signInWithMessageAuthenticated',
31
+ waitForEvents: true,
32
+ properties: {
33
+ ...contactProperties
34
+ },
35
+ async execute({ contactType, contact, session }, { client, service }, emit) {
36
+ const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
37
+ const user = await service.trigger({
38
+ type: 'signIn' + contactTypeUpperCase,
39
+ [contactType]: contact,
40
+ session
41
+ })
42
+ return user
43
+ }
44
+ })
45
+
46
+ definition.trigger({
47
+ name: 'connectWithMessageAuthenticated',
48
+ waitForEvents: true,
49
+ properties: {
50
+ ...contactProperties
51
+ },
52
+ async execute({ contactType, contact, user }, { client, service }, emit) {
53
+ const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
54
+ await service.trigger({
55
+ type: 'connect' + contactTypeUpperCase,
56
+ [contactType]: contact,
57
+ user
58
+ })
59
+ return user
60
+ }
61
+ })
62
+
63
+ for(const contactType of config.contactTypes) {
64
+
65
+ const contactConfig = (typeof contactType == "string") ? { name: contactType } : contactType
66
+ const contactTypeName = contactConfig.name
67
+ const contactTypeUName = contactTypeName[0].toUpperCase() + contactTypeName.slice(1)
68
+
69
+ const contactTypeProperties = {
70
+ [contactTypeName]: {
71
+ type: String,
72
+ validation: ['nonEmpty', contactTypeName]
73
+ }
74
+ }
75
+
76
+ if(contactConfig.signUp || config.signUp) {
77
+ definition.action({
78
+ name: 'signUp' + contactTypeUName,
79
+ waitForEvents: true,
80
+ properties: {
81
+ ...contactTypeProperties
82
+ },
83
+ async execute({ [contactTypeName]: contact }, { client, service }, emit) {
84
+ await service.trigger({
85
+ type: 'checkNew' + contactTypeUName,
86
+ [contactTypeName]: contact,
87
+ })
88
+ return service.triggerService(definition.name, {
89
+ type: 'authenticateWithMessage',
90
+ contactType,
91
+ contact,
92
+ action: 'signUpWithMessage',
93
+ targetPage: config.signUpTargetPage || { name: 'user:signUpFinished' }
94
+ })
95
+ }
96
+ })
97
+ }
98
+
99
+ if(contactConfig.signUp || config.signUp || contactConfig.signIn || config.signIn) {
100
+ definition.action({
101
+ name: 'signIn' + contactTypeUName,
102
+ waitForEvents: true,
103
+ properties: {
104
+ ...contactTypeProperties
105
+ },
106
+ async execute({ [contactTypeName]: contact }, { client, service }, emit) {
107
+ const contactData = await service.trigger({
108
+ type: 'get' + contactTypeUName,
109
+ [contactTypeName]: contact,
110
+ })
111
+ const messageData = {
112
+ user: contactData.user
113
+ }
114
+ return service.triggerService(definition.name, {
115
+ type: 'authenticateWithMessage',
116
+ contactType,
117
+ contact,
118
+ messageData,
119
+ action: 'signInWithMessage',
120
+ targetPage: config.signInTargetPage || { name: 'user:signInFinished' }
121
+ })
122
+ }
123
+ })
124
+ }
125
+
126
+ if(contactConfig.connect || config.connect ) {
127
+ definition.action({
128
+ name: 'connect' + contactTypeUName,
129
+ properties: {
130
+ ...contactTypeProperties
131
+ },
132
+ access: (params, { client }) => {
133
+ return !!client.user
134
+ },
135
+ async execute({ [contactTypeName]: contact }, { client, service }, emit) {
136
+ await service.trigger({
137
+ type: 'checkNew' + contactTypeUName,
138
+ [contactTypeName]: contact,
139
+ })
140
+ return service.triggerService(definition.name, {
141
+ type: 'authenticateWithMessage',
142
+ contactType,
143
+ contact,
144
+ action: 'connectWithMessage',
145
+ actionProperties: {
146
+ user: client.user
147
+ },
148
+ messageData: {
149
+ user: client.user
150
+ },
151
+ targetPage: config.signUpTargetPage || { name: 'user:connectFinished' }
152
+ })
153
+ }
154
+ })
155
+
156
+ definition.action({
157
+ name: 'disconnect' + contactTypeUName,
158
+ properties: {
159
+ ...contactTypeProperties
160
+ },
161
+ access: (params, { client }) => {
162
+ return !!client.user
163
+ },
164
+ async execute({ [contactTypeName]: contact }, { client, service }, emit) {
165
+ const contacts = (await service.trigger({
166
+ type: 'getConnectedContacts',
167
+ user: client.user
168
+ })).flat()
169
+ console.log("CONTACTS", contacts, contactTypeName, contact)
170
+ const contactData = contacts.find(c => c.type == contactTypeName && c.contact == contact)
171
+ if(!contactData) throw 'notFound'
172
+ if(contacts.length == 1) throw 'lastOne'
173
+ console.log("DISCONNECT", contact)
174
+ return await service.trigger({
175
+ type: 'disconnect' + contactTypeUName,
176
+ [contactTypeName]: contact,
177
+ user: client.user
178
+ })
179
+ }
180
+ })
181
+ }
182
+
183
+ if(contactConfig.signUp || config.signUp) {
184
+ definition.action({
185
+ name: 'signInOrSignUp' + contactTypeUName,
186
+ waitForEvents: true,
187
+ properties: {
188
+ ...contactTypeProperties
189
+ },
190
+ async execute({ [contactTypeName]: contact }, { client, service }, emit) {
191
+ const contactData = await service.trigger({
192
+ type: 'get' + contactTypeUName + 'OrNull',
193
+ [contactTypeName]: contact,
194
+ })
195
+ if(contactData) {
196
+ const messageData = {
197
+ user: contactData.user
198
+ }
199
+ return service.triggerService(definition.name, {
200
+ type: 'authenticateWithMessage',
201
+ contactType,
202
+ contact,
203
+ messageData,
204
+ action: 'signInWithMessage',
205
+ targetPage: config.signInTargetPage || { name: 'user:signInFinished' }
206
+ })
207
+ } else {
208
+ return service.triggerService(definition.name, {
209
+ type: 'authenticateWithMessage',
210
+ contactType,
211
+ contact,
212
+ action: 'signUpWithMessage',
213
+ targetPage: config.signUpTargetPage || { name: 'user:signUpFinished' }
214
+ })
215
+ }
216
+ }
217
+ })
218
+ }
219
+
220
+ }