@jetthai/cuora 1.0.46 → 1.0.47

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.47](https://github.com/jetthai/cuora-module/compare/v1.0.46...v1.0.47) (2021-11-24)
6
+
5
7
  ### [1.0.46](https://github.com/jetthai/cuora-module/compare/v1.0.45...v1.0.46) (2021-11-23)
6
8
 
7
9
  ### [1.0.45](https://github.com/jetthai/cuora-module/compare/v1.0.44...v1.0.45) (2021-11-23)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@ export default function (request) {
17
17
  requestId: null,
18
18
  ttl: null,
19
19
  target: {},
20
+ acknowledgeTtl: null,
20
21
  newPassword: null,
21
22
  },
22
23
  states: {
@@ -50,11 +51,16 @@ export default function (request) {
50
51
  },
51
52
  otp: {
52
53
  after: {
53
- 1000: {
54
- target: 'otp',
55
- actions: 'decreaseTtl',
56
- cond: (context) => context.ttl > 0,
57
- },
54
+ 1000: [
55
+ {
56
+ target: 'otp',
57
+ actions: 'decreaseTtl',
58
+ cond: (context) => context.ttl > 0,
59
+ },
60
+ {
61
+ target: 'idle',
62
+ },
63
+ ],
58
64
  },
59
65
  on: {
60
66
  ACKNOWLEDGE: {
@@ -85,6 +91,7 @@ export default function (request) {
85
91
  src: 'acknowledge',
86
92
  onDone: {
87
93
  target: 'acknowledged',
94
+ actions: 'setAcknowledgeResult',
88
95
  },
89
96
  onError: [
90
97
  {
@@ -98,6 +105,18 @@ export default function (request) {
98
105
  },
99
106
  },
100
107
  acknowledged: {
108
+ after: {
109
+ 1000: [
110
+ {
111
+ target: 'acknowledged',
112
+ actions: 'decreaseAcknowledgeTtl',
113
+ cond: (context) => context.acknowledgeTtl > 0,
114
+ },
115
+ {
116
+ target: 'idle',
117
+ },
118
+ ],
119
+ },
101
120
  on: {
102
121
  CHANGE: {
103
122
  target: 'changing',
@@ -168,6 +187,17 @@ export default function (request) {
168
187
  ttl: Math.max(context.ttl - 1, 0),
169
188
  }
170
189
  }),
190
+ setAcknowledgeResult: assign((context, event) => {
191
+ const { requestId, ttl, target } = event.data
192
+ return {
193
+ acknowledgeTtl: ttl,
194
+ }
195
+ }),
196
+ decreaseAcknowledgeTtl: assign((context, event) => {
197
+ return {
198
+ acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
199
+ }
200
+ }),
171
201
  setNewPassword: assign((context, event) => {
172
202
  return {
173
203
  newPassword: event.data,