@live-change/message-authentication-service 0.8.31 → 0.8.33

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/authentication.js CHANGED
@@ -105,14 +105,12 @@ definition.trigger({
105
105
  async execute({ contactType, contact, action, actionProperties, targetPage, messageData },
106
106
  { client, service }, emit) {
107
107
  const authentication = app.generateUid()
108
- const secrets = await service.trigger({
109
- type: 'authenticationSecret',
108
+ const secrets = await service.trigger({ type: 'authenticationSecret' }, {
110
109
  authentication
111
110
  })
112
- if(secrets.length == 0) throw new Error('no secrets generated!')
111
+ if(secrets.length === 0) throw new Error('no secrets generated!')
113
112
  const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
114
- await service.trigger({
115
- type: 'send' + contactTypeUpperCase + 'Message',
113
+ await service.trigger({ type: 'send' + contactTypeUpperCase + 'Message' }, {
116
114
  render: {
117
115
  action,
118
116
  contactType,
@@ -157,18 +155,16 @@ definition.action({
157
155
  },
158
156
  async execute({ secretType, secret, authentication = undefined }, { client, service }, emit) {
159
157
  const secretTypeUpperCase = secretType[0].toUpperCase() + secretType.slice(1)
160
- const checkResults = await service.trigger({
161
- type: 'check' + secretTypeUpperCase + 'Secret',
158
+ const checkResults = await service.trigger({ type: 'check' + secretTypeUpperCase + 'Secret' }, {
162
159
  secret,
163
160
  authentication,
164
161
  client
165
162
  })
166
163
  authentication = checkResults[0]
167
164
  const authenticationData = await Authentication.get(authentication)
168
- if(authenticationData.state == 'used') throw 'authenticationUsed'
165
+ if(authenticationData.state === 'used') throw 'authenticationUsed'
169
166
  const actionName = authenticationData.action
170
- const actionResults = await service.trigger({
171
- type: actionName+'Authenticated',
167
+ const actionResults = await service.trigger({ type: actionName+'Authenticated' }, {
172
168
  ...authenticationData.actionProperties,
173
169
  contactType: authenticationData.contactType,
174
170
  contact: authenticationData.contact,
@@ -200,14 +196,12 @@ definition.action({
200
196
  const authenticationData = await Authentication.get(authentication)
201
197
  if(!authenticationData) throw 'notFound'
202
198
  const { contactType, contact, action } = authenticationData
203
- const secrets = await service.trigger({
204
- type: 'refreshAuthenticationSecret',
199
+ const secrets = await service.trigger({ type: 'refreshAuthenticationSecret' }, {
205
200
  authentication
206
201
  })
207
- if(secrets.length == 0) throw new Error('no secrets generated!')
202
+ if(secrets.length === 0) throw new Error('no secrets generated!')
208
203
  const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
209
- await service.trigger({
210
- type: 'send' + contactTypeUpperCase + 'Message',
204
+ await service.trigger({ type: 'send' + contactTypeUpperCase + 'Message' }, {
211
205
  render: {
212
206
  action,
213
207
  contactType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/message-authentication-service",
3
- "version": "0.8.31",
3
+ "version": "0.8.33",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,9 +21,9 @@
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "^0.8.31",
24
+ "@live-change/framework": "^0.8.33",
25
25
  "nodemailer": "^6.7.2"
26
26
  },
27
- "gitHead": "9ab10c6f2854dd5472cc6becb128951db16218e3",
27
+ "gitHead": "98ff6f9c09e5fc1f408010df6cc8038eff571276",
28
28
  "type": "module"
29
29
  }
package/sign.js CHANGED
@@ -14,13 +14,11 @@ definition.trigger({
14
14
  async execute({ contactType, contact, session }, { service }, _emit) {
15
15
  const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
16
16
  const user = app.generateUid()
17
- await service.trigger({
18
- type: 'connect' + contactTypeUpperCase,
17
+ await service.trigger({ type: 'connect' + contactTypeUpperCase }, {
19
18
  [contactType]: contact,
20
19
  user
21
20
  })
22
- await service.trigger({
23
- type: 'signUpAndSignIn',
21
+ await service.trigger({ type: 'signUpAndSignIn' }, {
24
22
  user, session
25
23
  })
26
24
  return user
@@ -35,8 +33,7 @@ definition.trigger({
35
33
  },
36
34
  async execute({ contactType, contact, session }, { service }, _emit) {
37
35
  const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
38
- const user = await service.trigger({
39
- type: 'signIn' + contactTypeUpperCase,
36
+ const user = await service.trigger({ type: 'signIn' + contactTypeUpperCase }, {
40
37
  [contactType]: contact,
41
38
  session
42
39
  })
@@ -52,8 +49,7 @@ definition.trigger({
52
49
  },
53
50
  async execute({ contactType, contact, user }, { client, service }, _emit) {
54
51
  const contactTypeUpperCase = contactType[0].toUpperCase() + contactType.slice(1)
55
- await service.trigger({
56
- type: 'connect' + contactTypeUpperCase,
52
+ await service.trigger({ type: 'connect' + contactTypeUpperCase }, {
57
53
  [contactType]: contact,
58
54
  user
59
55
  })
@@ -82,12 +78,10 @@ for(const contactType of config.contactTypes) {
82
78
  ...contactTypeProperties
83
79
  },
84
80
  async execute({ [contactTypeName]: contact }, { service }, _emit) {
85
- await service.trigger({
86
- type: 'checkNew' + contactTypeUName,
81
+ await service.trigger({ type: 'checkNew' + contactTypeUName }, {
87
82
  [contactTypeName]: contact,
88
83
  })
89
- return service.triggerService(definition.name, {
90
- type: 'authenticateWithMessage',
84
+ return service.triggerService({ service: definition.name, type: 'authenticateWithMessage' }, {
91
85
  contactType,
92
86
  contact,
93
87
  action: 'signUpWithMessage',
@@ -105,15 +99,13 @@ for(const contactType of config.contactTypes) {
105
99
  ...contactTypeProperties
106
100
  },
107
101
  async execute({ [contactTypeName]: contact }, { _client, service }, _emit) {
108
- const contactData = await service.trigger({
109
- type: 'get' + contactTypeUName,
102
+ const contactData = await service.trigger({ type: 'get' + contactTypeUName }, {
110
103
  [contactTypeName]: contact,
111
104
  })
112
105
  const messageData = {
113
106
  user: contactData.user
114
107
  }
115
- return service.triggerService(definition.name, {
116
- type: 'authenticateWithMessage',
108
+ return service.triggerService({ service: definition.name, type: 'authenticateWithMessage' }, {
117
109
  contactType,
118
110
  contact,
119
111
  messageData,
@@ -134,12 +126,10 @@ for(const contactType of config.contactTypes) {
134
126
  return !!client.user
135
127
  },
136
128
  async execute({ [contactTypeName]: contact }, { client, service }, _emit) {
137
- await service.trigger({
138
- type: 'checkNew' + contactTypeUName,
129
+ await service.trigger({ type: 'checkNew' + contactTypeUName }, {
139
130
  [contactTypeName]: contact,
140
131
  })
141
- return service.triggerService(definition.name, {
142
- type: 'authenticateWithMessage',
132
+ return service.triggerService({ service: definition.name, type: 'authenticateWithMessage' }, {
143
133
  contactType,
144
134
  contact,
145
135
  action: 'connectWithMessage',
@@ -163,8 +153,7 @@ for(const contactType of config.contactTypes) {
163
153
  return !!client.user
164
154
  },
165
155
  async execute({ [contactTypeName]: contact }, { client, service }, _emit) {
166
- const contacts = (await service.trigger({
167
- type: 'getConnectedContacts',
156
+ const contacts = (await service.trigger({ type: 'getConnectedContacts' }, {
168
157
  user: client.user
169
158
  })).flat()
170
159
  console.log("CONTACTS", contacts, contactTypeName, contact)
@@ -174,8 +163,7 @@ for(const contactType of config.contactTypes) {
174
163
  if(!contactData) throw 'notFound'
175
164
  if(contacts.length === 1) throw 'lastOne'
176
165
  console.log("DISCONNECT", contact)
177
- return await service.trigger({
178
- type: 'disconnect' + contactTypeUName,
166
+ return await service.trigger({ type: 'disconnect' + contactTypeUName }, {
179
167
  [contactTypeName]: contact,
180
168
  user: client.user
181
169
  })
@@ -191,16 +179,14 @@ for(const contactType of config.contactTypes) {
191
179
  ...contactTypeProperties
192
180
  },
193
181
  async execute({ [contactTypeName]: contact }, { client, service }, _emit) {
194
- const contactData = await service.trigger({
195
- type: 'get' + contactTypeUName + 'OrNull',
182
+ const contactData = await service.trigger({ type: 'get' + contactTypeUName + 'OrNull' }, {
196
183
  [contactTypeName]: contact,
197
184
  })
198
185
  if(contactData) {
199
186
  const messageData = {
200
187
  user: contactData.user
201
188
  }
202
- return service.triggerService(definition.name, {
203
- type: 'authenticateWithMessage',
189
+ return service.triggerService({ service: definition.name, type: 'authenticateWithMessage' }, {
204
190
  contactType,
205
191
  contact,
206
192
  messageData,
@@ -208,8 +194,7 @@ for(const contactType of config.contactTypes) {
208
194
  targetPage: config.signInTargetPage || { name: 'user:signInFinished' }
209
195
  })
210
196
  } else {
211
- return service.triggerService(definition.name, {
212
- type: 'authenticateWithMessage',
197
+ return service.triggerService({ service: definition.name, type: 'authenticateWithMessage' }, {
213
198
  contactType,
214
199
  contact,
215
200
  action: 'signUpWithMessage',