@it-enterprise/digital-signature 1.4.7 → 1.5.0

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.
@@ -1,5 +1,5 @@
1
1
  import { EndUserConstants, EndUserError } from "../euscp/euscp";
2
- import { arrayToBase64, base64ToArray } from "./Utils";
2
+ import { arrayToBase64, base64ToArray, convertToBase64 } from "./Utils";
3
3
 
4
4
  export default class UmCAService {
5
5
  constructor(port) {
@@ -72,11 +72,14 @@ export default class UmCAService {
72
72
  toSign = [...toSign];
73
73
  }
74
74
 
75
+ // при подписани данных, строковые данные передаются в "сыром" виде а не в base64
75
76
  for (let i = 0; i < toSign.length; i++) {
76
- const d = toSign[i];
77
+ let d = toSign[i];
77
78
  if (d.val) {
79
+ if (typeof d.val === "string") d.val = convertToBase64(d.val);
78
80
  toSign[i] = { name: d.name, val: formatData(d.val, true) };
79
81
  } else {
82
+ if (typeof d === "string") d = convertToBase64(d);
80
83
  toSign[i] = formatData(d, true);
81
84
  }
82
85
  }
@@ -124,7 +127,7 @@ export default class UmCAService {
124
127
  }
125
128
 
126
129
  const formatData = (data, toBase64) => {
127
- return toBase64 && typeof data != "string" ? arrayToBase64(data)
128
- : !toBase64 && typeof data == "string" ? base64ToArray(data)
129
- : data;
130
+ if (toBase64 && typeof data !== "string") return arrayToBase64(data);
131
+ if (!toBase64 && typeof data === "string") return base64ToArray(data);
132
+ return data;
130
133
  };