tuain-form-manager 1.1.15 → 1.1.18

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/lib/form.js CHANGED
@@ -116,7 +116,10 @@ class Form {
116
116
  }
117
117
 
118
118
  getImmutableElement(name) {
119
- const { value, signature } = this._responseData.immutableData[name];
119
+ if (!this._responseData?.immutableData) {
120
+ return null;
121
+ }
122
+ const { value, signature } = this._responseData?.immutableData?.[name] ?? {};
120
123
  const content = JSON.stringify({ name, value });
121
124
  const signatureKey = this._requestContext.signatureKey ?? this._requestContext.deviceKey ?? '1234567890';
122
125
  const checkSignature = crypto.createHmac('sha256', signatureKey).update(content).digest('hex');
@@ -166,11 +169,13 @@ class Form {
166
169
  }
167
170
  if (!this.state) {
168
171
  this.state = newState;
172
+ this.responseData.currentMode = newState;
169
173
  } else {
170
174
  const transitionToChange = this._formDefinition.transitions
171
175
  .find(trns => trns.source === this.state && trns.destination === newState);
172
176
  if (transitionToChange) {
173
177
  this.state = newState;
178
+ this.responseData.currentMode = newState;
174
179
  }
175
180
  }
176
181
  return (this.state === newState);
@@ -37,11 +37,15 @@ function exportExchange(form) {
37
37
  const exchangeFormInfo = {};
38
38
  const { requestVersion } = form;
39
39
  if (requestVersion === 'TUAINEXCHANGE_1.0') {
40
+ if (formExportData.formSubject) {
41
+ exchangeFormInfo.formSubject = formExportData.formSubject;
42
+ }
40
43
  exchangeFormInfo.actions = formExportData.actions;
41
44
  exchangeFormInfo.cookiesToSet = formExportData.cookiesToSet;
42
45
  exchangeFormInfo.immutableData = formExportData.immutableData;
43
46
  exchangeFormInfo.returnedFile = formExportData.returnedFile;
44
47
  exchangeFormInfo.extraInfo = formExportData.extraInfo;
48
+ exchangeFormInfo.currentMode = formExportData.currentMode;
45
49
  exchangeFormInfo.fields = [];
46
50
  const fieldNames = Object.keys(formExportData.fields);
47
51
  for (let index = 0; index < fieldNames.length; index++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.1.15",
3
+ "version": "1.1.18",
4
4
  "description": "Component library to perform operations on Tuain Development Framework forms to interchange information on web or mobile applications based on the data interchange of abstract forms making trnasformation on the data upon actions required on both sides (front and back)",
5
5
  "main": "index.js",
6
6
  "scripts": {