apacuana-sdk-core 1.12.0 → 1.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apacuana-sdk-core",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Core SDK para interacciones con las APIs de Apacuana.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -100,11 +100,16 @@ const encryptedCsr = (csr, encryptKey = KEY_HEX) => {
100
100
  const createPayloadGetDigest = (signData) => {
101
101
  const formData = new FormData();
102
102
 
103
- // Iterate over the object's own properties
104
103
  Object.keys(signData).forEach((key) => {
105
- // Conditionally handle the 'document' field
106
-
107
- if (key === "document" && signData[key] instanceof File) {
104
+ const value = signData[key];
105
+ const isRNFile =
106
+ value &&
107
+ typeof value === "object" &&
108
+ value.uri &&
109
+ value.name &&
110
+ value.type;
111
+
112
+ if (key === "document" && (signData[key] instanceof File || isRNFile)) {
108
113
  // Append the file directly
109
114
  formData.append(key, signData[key]);
110
115
  } else if (key === "cert") {
@@ -129,7 +134,6 @@ const validateOnBoardingSignerData = (signerData) => {
129
134
  );
130
135
  }
131
136
 
132
- // Limpia 'reference' si es inválido o está vacío.
133
137
  if (
134
138
  !validatedSignerData.reference ||
135
139
  typeof validatedSignerData.reference !== "string" ||
@@ -138,7 +142,6 @@ const validateOnBoardingSignerData = (signerData) => {
138
142
  delete validatedSignerData.reference;
139
143
  }
140
144
 
141
- // Limpia 'file' si no es una instancia de File.
142
145
  if (
143
146
  typeof File === "undefined" ||
144
147
  !validatedSignerData.file ||
@@ -229,9 +232,17 @@ const validateOnBoardingSignerData = (signerData) => {
229
232
 
230
233
  const formData = new FormData();
231
234
  Object.keys(validatedSignerData).forEach((key) => {
235
+ const value = validatedSignerData[key];
236
+ const isRNFile =
237
+ value &&
238
+ typeof value === "object" &&
239
+ value.uri &&
240
+ value.name &&
241
+ value.type;
242
+
232
243
  if (key === "signature") {
233
244
  formData.append(key, JSON.stringify(validatedSignerData[key]));
234
- } else if (key === "file") {
245
+ } else if (key === "file" || isRNFile) {
235
246
  formData.append("document", validatedSignerData[key]);
236
247
  } else if (validatedSignerData[key] !== undefined) {
237
248
  formData.append(key, validatedSignerData[key]);
@@ -356,7 +367,11 @@ const validateOnBoardingSignDocumentData = (signData) => {
356
367
  );
357
368
  formData.append("publickey", cert);
358
369
  formData.append("signeddigest", signedDigest);
359
- if (signData.document && signData.document instanceof File) {
370
+ const value = signData.document;
371
+ const isRNFile =
372
+ value && typeof value === "object" && value.uri && value.name && value.type;
373
+
374
+ if (signData.document && (signData.document instanceof File || isRNFile)) {
360
375
  formData.append("document", signData.document);
361
376
  }
362
377