qrdnicapacitor 1.0.3
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.swift +34 -0
- package/Qrdnicapacitor.podspec +18 -0
- package/README.md +106 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +16 -0
- package/android/src/main/java/com/cqesolutions/qrdnicapacitor/QrCodeScanner.java +84 -0
- package/android/src/main/java/com/cqesolutions/qrdnicapacitor/jj2000/ImgStreamWriter.java +483 -0
- package/android/src/main/java/com/cqesolutions/qrdnicapacitor/jj2000/J2kStreamDecoder.java +116 -0
- package/android/src/main/java/com/cqesolutions/qrdnicapacitor/jj2000/MyFileFormatReader.java +204 -0
- package/android/src/main/java/com/cqesolutions/qrdnicapacitor/qrdni.java +130 -0
- package/android/src/main/java/com/cqesolutions/qrdnicapacitor/qrdniPlugin.java +109 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +255 -0
- package/dist/esm/definitions.d.ts +44 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +14 -0
- package/dist/esm/web.js +18 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +32 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +35 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/qrdniPlugin/ScannerViewController.swift +170 -0
- package/ios/Sources/qrdniPlugin/qrdni.swift +111 -0
- package/ios/Sources/qrdniPlugin/qrdniPlugin.swift +105 -0
- package/ios/Tests/qrdniPluginTests/qrdniTests.swift +15 -0
- package/package.json +80 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
package com.cqesolutions.qrdnicapacitor.jj2000;
|
|
2
|
+
|
|
3
|
+
import java.io.EOFException;
|
|
4
|
+
import java.io.IOException;
|
|
5
|
+
import java.util.Vector;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import jj2000.j2k.fileformat.FileFormatBoxes;
|
|
9
|
+
import jj2000.j2k.io.RandomAccessIO;
|
|
10
|
+
import jj2000.j2k.util.FacilityManager;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
public class MyFileFormatReader implements FileFormatBoxes {
|
|
14
|
+
private RandomAccessIO in;
|
|
15
|
+
private Vector codeStreamPos;
|
|
16
|
+
private Vector codeStreamLength;
|
|
17
|
+
public boolean JP2FFUsed;
|
|
18
|
+
|
|
19
|
+
public MyFileFormatReader(RandomAccessIO in) {
|
|
20
|
+
this.in = in;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public void readFileFormat() throws IOException, EOFException {
|
|
24
|
+
boolean foundCodeStreamBoxes = false;
|
|
25
|
+
long longLength = 0L;
|
|
26
|
+
boolean jp2HeaderBoxFound = false;
|
|
27
|
+
boolean lastBoxFound = false;
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
/* if(this.in.readInt() != 12)
|
|
31
|
+
throw new IOException("File is neither valid JP2 file nor valid JPEG 2000 codestream");
|
|
32
|
+
else if(this.in.readInt() != 1783636000)
|
|
33
|
+
throw new IOException("File is neither valid JP2 file nor valid JPEG 2000 codestream");
|
|
34
|
+
else if(this.in.readInt() != 218793738)
|
|
35
|
+
//if(this.in.readInt() != 12 || this.in.readInt() != 1783636000 || this.in.readInt() != 218793738)
|
|
36
|
+
{
|
|
37
|
+
this.in.seek(0);
|
|
38
|
+
short marker = this.in.readShort();
|
|
39
|
+
if(marker != -177) {
|
|
40
|
+
throw new Error("File is neither valid JP2 file nor valid JPEG 2000 codestream");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.JP2FFUsed = false;
|
|
44
|
+
this.in.seek(0);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.JP2FFUsed = true;
|
|
49
|
+
if(!this.readFileTypeBox()) {
|
|
50
|
+
throw new Error("Invalid JP2 file: File Type box missing");
|
|
51
|
+
}*/
|
|
52
|
+
|
|
53
|
+
this.in.seek(0); // <--- pruebas. para intentar posicionar el buffer.
|
|
54
|
+
|
|
55
|
+
while(!lastBoxFound) {
|
|
56
|
+
int pos = this.in.getPos();
|
|
57
|
+
int length = this.in.readInt();
|
|
58
|
+
if(pos + length == this.in.length()) {
|
|
59
|
+
lastBoxFound = true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
int box = this.in.readInt();
|
|
63
|
+
if(length == 0) {
|
|
64
|
+
lastBoxFound = true;
|
|
65
|
+
length = this.in.length() - this.in.getPos();
|
|
66
|
+
} else {
|
|
67
|
+
if(length == 1) {
|
|
68
|
+
longLength = this.in.readLong();
|
|
69
|
+
throw new IOException("File too long.");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
longLength = 0L;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
switch(box) {
|
|
76
|
+
case 1685074537:
|
|
77
|
+
this.readIntPropertyBox(length);
|
|
78
|
+
break;
|
|
79
|
+
case 1785737827:
|
|
80
|
+
if(!jp2HeaderBoxFound) {
|
|
81
|
+
throw new Error("Invalid JP2 file: JP2Header box not found before Contiguous codestream box ");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.readContiguousCodeStreamBox((long)pos, length, longLength);
|
|
85
|
+
break;
|
|
86
|
+
case 1785737832:
|
|
87
|
+
if(jp2HeaderBoxFound) {
|
|
88
|
+
throw new Error("Invalid JP2 file: Multiple JP2Header boxes found");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.readJP2HeaderBox((long)pos, length, longLength);
|
|
92
|
+
jp2HeaderBoxFound = true;
|
|
93
|
+
break;
|
|
94
|
+
case 1969843814:
|
|
95
|
+
this.readUUIDInfoBox(length);
|
|
96
|
+
break;
|
|
97
|
+
case 1970628964:
|
|
98
|
+
this.readUUIDBox(length);
|
|
99
|
+
break;
|
|
100
|
+
case 2020437024:
|
|
101
|
+
this.readXMLBox(length);
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
FacilityManager.getMsgLogger().printmsg(2, "Unknown box-type: 0x" + Integer.toHexString(box));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if(!lastBoxFound) {
|
|
108
|
+
this.in.seek(pos + length);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} catch (EOFException var11) {
|
|
112
|
+
throw new Error("EOF reached before finding Contiguous Codestream Box");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if(this.codeStreamPos.size() == 0) {
|
|
116
|
+
throw new Error("Invalid JP2 file: Contiguous codestream box missing");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public boolean readFileTypeBox() throws IOException, EOFException {
|
|
121
|
+
long longLength = 0L;
|
|
122
|
+
boolean foundComp = false;
|
|
123
|
+
int pos = this.in.getPos();
|
|
124
|
+
int length = this.in.readInt();
|
|
125
|
+
if(length == 0) {
|
|
126
|
+
throw new Error("Zero-length of Profile Box");
|
|
127
|
+
} else if(this.in.readInt() != 1718909296) {
|
|
128
|
+
return false;
|
|
129
|
+
} else if(length == 1) {
|
|
130
|
+
longLength = this.in.readLong();
|
|
131
|
+
throw new IOException("File too long.");
|
|
132
|
+
} else {
|
|
133
|
+
this.in.readInt();
|
|
134
|
+
this.in.readInt();
|
|
135
|
+
int nComp = (length - 16) / 4;
|
|
136
|
+
|
|
137
|
+
for(int i = nComp; i > 0; --i) {
|
|
138
|
+
if(this.in.readInt() == 1785737760) {
|
|
139
|
+
foundComp = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if(!foundComp) {
|
|
144
|
+
return false;
|
|
145
|
+
} else {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public boolean readJP2HeaderBox(long pos, int length, long longLength) throws IOException, EOFException {
|
|
152
|
+
if(length == 0) {
|
|
153
|
+
throw new Error("Zero-length of JP2Header Box");
|
|
154
|
+
} else {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public boolean readContiguousCodeStreamBox(long pos, int length, long longLength) throws IOException, EOFException {
|
|
160
|
+
int ccpos = this.in.getPos();
|
|
161
|
+
if(this.codeStreamPos == null) {
|
|
162
|
+
this.codeStreamPos = new Vector();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
this.codeStreamPos.addElement(new Integer(ccpos));
|
|
166
|
+
if(this.codeStreamLength == null) {
|
|
167
|
+
this.codeStreamLength = new Vector();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
this.codeStreamLength.addElement(new Integer(length));
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public void readIntPropertyBox(int length) {
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public void readXMLBox(int length) {
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public void readUUIDBox(int length) {
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public void readUUIDInfoBox(int length) {
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public long[] getCodeStreamPos() {
|
|
187
|
+
int size = this.codeStreamPos.size();
|
|
188
|
+
long[] pos = new long[size];
|
|
189
|
+
|
|
190
|
+
for(int i = 0; i < size; ++i) {
|
|
191
|
+
pos[i] = ((Integer)((Integer)this.codeStreamPos.elementAt(i))).longValue();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return pos;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public int getFirstCodeStreamPos() {
|
|
198
|
+
return ((Integer)((Integer)this.codeStreamPos.elementAt(0))).intValue();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public int getFirstCodeStreamLength() {
|
|
202
|
+
return ((Integer)((Integer)this.codeStreamLength.elementAt(0))).intValue();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
package com.cqesolutions.qrdnicapacitor;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
5
|
+
import android.util.Base64;
|
|
6
|
+
|
|
7
|
+
import com.cqesolutions.qrdnicapacitor.jj2000.J2kStreamDecoder;
|
|
8
|
+
import com.getcapacitor.JSObject;
|
|
9
|
+
import com.cqesolutions.qrdnidroid_project.QRDNIdroid;
|
|
10
|
+
import com.cqesolutions.qrdnidroid_project.bean.EstadoLicencia;
|
|
11
|
+
import com.cqesolutions.qrdnidroid_project.bean.MiDNIData;
|
|
12
|
+
|
|
13
|
+
import org.json.JSONObject;
|
|
14
|
+
|
|
15
|
+
import java.io.ByteArrayInputStream;
|
|
16
|
+
import java.io.ByteArrayOutputStream;
|
|
17
|
+
import java.util.Map;
|
|
18
|
+
|
|
19
|
+
public class qrdni {
|
|
20
|
+
|
|
21
|
+
public JSObject configure(Context context, String license, Map<String, String> certConfig) {
|
|
22
|
+
// Convertimos el Map de certificados a un String JSON para tu librería
|
|
23
|
+
String jsonConfig = null;
|
|
24
|
+
if (certConfig != null && !certConfig.isEmpty()) {
|
|
25
|
+
jsonConfig = new JSONObject(certConfig).toString();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
EstadoLicencia estado = QRDNIdroid.getInstance(context).initialize(license, jsonConfig);
|
|
29
|
+
|
|
30
|
+
JSObject ret = new JSObject();
|
|
31
|
+
ret.put("descripcion", estado.descripcion);
|
|
32
|
+
ret.put("APIKeyValida", estado.apiKeyValida);
|
|
33
|
+
ret.put("lecturaQRHabilitada", estado.lecturaQRHabilitada);
|
|
34
|
+
return ret;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public void validaMiDNIQR(Context context, String base64Data, QRDNIdroid.ResultCallback callback) {
|
|
38
|
+
try {
|
|
39
|
+
byte[] rawBytes = Base64.decode(base64Data, Base64.DEFAULT);
|
|
40
|
+
QRDNIdroid.getInstance(context).processQR(rawBytes, callback);
|
|
41
|
+
} catch (Exception e) {
|
|
42
|
+
callback.onError("Error decodificando Base64: " + e.getMessage());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Mapeo manual similar al que hiciste en Swift
|
|
47
|
+
public JSObject mapMiDNIDataToJS(MiDNIData data) {
|
|
48
|
+
JSObject json = new JSObject();
|
|
49
|
+
json.put("dni", data.dni);
|
|
50
|
+
json.put("name", data.name);
|
|
51
|
+
json.put("surnames", data.surnames);
|
|
52
|
+
json.put("birthDate", data.birthDate);
|
|
53
|
+
json.put("expiryDate", data.expiryDate);
|
|
54
|
+
json.put("gender", data.gender);
|
|
55
|
+
json.put("address", data.address);
|
|
56
|
+
json.put("nationality", data.nationality);
|
|
57
|
+
json.put("parents", data.parents);
|
|
58
|
+
json.put("supportNumber", data.supportNumber);
|
|
59
|
+
json.put("birthPlace1", data.birthPlace1);
|
|
60
|
+
json.put("birthPlace2", data.birthPlace2);
|
|
61
|
+
json.put("birthPlace3", data.birthPlace3);
|
|
62
|
+
|
|
63
|
+
// Manejo de foto
|
|
64
|
+
if (data.photoData != null) {
|
|
65
|
+
try {
|
|
66
|
+
// 1. Decodificar el J2K usando el .jar que acabas de añadir
|
|
67
|
+
J2kStreamDecoder j2k = new J2kStreamDecoder();
|
|
68
|
+
ByteArrayInputStream bis = new ByteArrayInputStream(data.photoData);
|
|
69
|
+
Bitmap bitmap = j2k.decode(bis);
|
|
70
|
+
|
|
71
|
+
if (bitmap != null) {
|
|
72
|
+
// 2. Convertir a JPEG estándar para que Ionic lo entienda
|
|
73
|
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
74
|
+
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
|
|
75
|
+
byte[] jpegBytes = out.toByteArray();
|
|
76
|
+
|
|
77
|
+
// 3. Enviar a la parte web como Base64
|
|
78
|
+
json.put("photoData", Base64.encodeToString(jpegBytes, Base64.NO_WRAP));
|
|
79
|
+
}
|
|
80
|
+
} catch (Exception e) {
|
|
81
|
+
e.printStackTrace();
|
|
82
|
+
json.put("photoData", ""); // Evitamos enviar datos corruptos
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
json.put("photoData", "");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
json.put("isAdult", data.isAdult);
|
|
89
|
+
|
|
90
|
+
// Criptografía y firmas
|
|
91
|
+
json.put("rawSignature", data.rawSignature != null ? Base64.encodeToString(data.rawSignature, Base64.NO_WRAP) : "");
|
|
92
|
+
json.put("signedData", data.signedData != null ? Base64.encodeToString(data.signedData, Base64.NO_WRAP) : "");
|
|
93
|
+
json.put("certificateRef", data.certificateRef);
|
|
94
|
+
json.put("type", data.type);
|
|
95
|
+
|
|
96
|
+
// Verificación (Status Mapping)
|
|
97
|
+
JSObject verificationJson = new JSObject();
|
|
98
|
+
if (data.verificationResult != null) {
|
|
99
|
+
String statusNative = data.verificationResult.status.name(); // .name() para obtener el String del Enum
|
|
100
|
+
|
|
101
|
+
switch (statusNative) {
|
|
102
|
+
case "VALID":
|
|
103
|
+
verificationJson.put("status", "VALID");
|
|
104
|
+
// Si tienes el certificado, añádelo aquí
|
|
105
|
+
// verificationJson.put("certificate", data.getCertificate());
|
|
106
|
+
break;
|
|
107
|
+
case "INVALID":
|
|
108
|
+
verificationJson.put("status", "INVALID");
|
|
109
|
+
break;
|
|
110
|
+
case "NO_CERTIFICATES":
|
|
111
|
+
verificationJson.put("status", "NO_CERTIFICATES");
|
|
112
|
+
break;
|
|
113
|
+
case "EXPIRED_QR":
|
|
114
|
+
verificationJson.put("status", "EXPIRED_QR");
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
verificationJson.put("status", "INVALID");
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
verificationJson.put("status", "UNKNOWN");
|
|
122
|
+
}
|
|
123
|
+
json.put("verificationResult", verificationJson);
|
|
124
|
+
|
|
125
|
+
json.put("qrDataExpiry", data.qrDataExpiry);
|
|
126
|
+
json.put("fullBirthPlace", data.getFullBirthPlace());
|
|
127
|
+
|
|
128
|
+
return json;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
package com.cqesolutions.qrdnicapacitor;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.util.Base64;
|
|
6
|
+
|
|
7
|
+
import androidx.activity.result.ActivityResult;
|
|
8
|
+
|
|
9
|
+
import com.getcapacitor.JSObject;
|
|
10
|
+
import com.getcapacitor.Plugin;
|
|
11
|
+
import com.getcapacitor.PluginCall;
|
|
12
|
+
import com.getcapacitor.PluginMethod;
|
|
13
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
14
|
+
import com.cqesolutions.qrdnidroid_project.QRDNIdroid;
|
|
15
|
+
import com.cqesolutions.qrdnidroid_project.bean.MiDNIData;
|
|
16
|
+
|
|
17
|
+
import java.nio.charset.StandardCharsets;
|
|
18
|
+
import java.util.HashMap;
|
|
19
|
+
import java.util.Iterator;
|
|
20
|
+
import java.util.Map;
|
|
21
|
+
|
|
22
|
+
@CapacitorPlugin(name = "qrdni", requestCodes = {12345})
|
|
23
|
+
public class qrdniPlugin extends Plugin {
|
|
24
|
+
public static final String KEY_QR_CODE = "qr_code";
|
|
25
|
+
private qrdni implementation = new qrdni();
|
|
26
|
+
|
|
27
|
+
@PluginMethod
|
|
28
|
+
public void configure(PluginCall call) {
|
|
29
|
+
String license = call.getString("license", "");
|
|
30
|
+
JSObject certsObj = call.getObject("certs");
|
|
31
|
+
|
|
32
|
+
// Convertimos JSObject a Map<String, String>
|
|
33
|
+
Map<String, String> certMap = new HashMap<>();
|
|
34
|
+
if (certsObj != null) {
|
|
35
|
+
Iterator<String> keys = certsObj.keys();
|
|
36
|
+
while (keys.hasNext()) {
|
|
37
|
+
String key = keys.next();
|
|
38
|
+
certMap.put(key, certsObj.getString(key));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
JSObject result = implementation.configure(getContext(), license, certMap);
|
|
43
|
+
call.resolve(result);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@PluginMethod
|
|
47
|
+
public void validaMiDNIQR(PluginCall call) {
|
|
48
|
+
String base64Data = call.getString("data");
|
|
49
|
+
|
|
50
|
+
if (base64Data == null) {
|
|
51
|
+
call.reject("No se proporcionó el QR");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Llamamos a la implementación pasando un callback para manejar el hilo principal
|
|
56
|
+
implementation.validaMiDNIQR(getContext(), base64Data, new QRDNIdroid.ResultCallback() {
|
|
57
|
+
@Override
|
|
58
|
+
public void onSuccess(MiDNIData data) {
|
|
59
|
+
JSObject result = implementation.mapMiDNIDataToJS(data);
|
|
60
|
+
call.resolve(result);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
public void onError(String errorMessage) {
|
|
65
|
+
call.reject(errorMessage);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@PluginMethod
|
|
71
|
+
public void abrirEscaner(PluginCall call) {
|
|
72
|
+
saveCall(call);
|
|
73
|
+
Intent intent = new Intent(getContext(), QrCodeScanner.class);
|
|
74
|
+
intent.putExtra("returnString", false);
|
|
75
|
+
// El número 12345 es un identificador cualquiera
|
|
76
|
+
startActivityForResult(call, intent, 12345);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Override
|
|
80
|
+
protected void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
|
|
81
|
+
super.handleOnActivityResult(requestCode, resultCode, data);
|
|
82
|
+
|
|
83
|
+
if (requestCode != 12345) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Recuperamos la llamada guardada
|
|
87
|
+
PluginCall call = getSavedCall();
|
|
88
|
+
|
|
89
|
+
if (call == null) return;
|
|
90
|
+
|
|
91
|
+
if (resultCode == Activity.RESULT_OK && data != null) {
|
|
92
|
+
String base64QR = data.getStringExtra(KEY_QR_CODE);
|
|
93
|
+
|
|
94
|
+
// LLAMADA A LA LIBRERÍA
|
|
95
|
+
implementation.validaMiDNIQR(getContext(), base64QR, new QRDNIdroid.ResultCallback() {
|
|
96
|
+
@Override
|
|
97
|
+
public void onSuccess(MiDNIData data) {
|
|
98
|
+
call.resolve(implementation.mapMiDNIDataToJS(data));
|
|
99
|
+
}
|
|
100
|
+
@Override
|
|
101
|
+
public void onError(String errorMessage) {
|
|
102
|
+
call.reject(errorMessage);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
call.reject("Escaneo cancelado");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "qrdniPlugin",
|
|
4
|
+
"slug": "qrdniplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "configure",
|
|
10
|
+
"signature": "(options: { license: string; certs?: { [key: string]: string; } | undefined; }) => Promise<EstadoLicencia>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "{ license: string; certs?: { [key: string]: string; } | undefined; }"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<EstadoLicencia>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"EstadoLicencia"
|
|
23
|
+
],
|
|
24
|
+
"slug": "configure"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "validaMiDNIQR",
|
|
28
|
+
"signature": "(options: { data: string; }) => Promise<MiDNIData>",
|
|
29
|
+
"parameters": [
|
|
30
|
+
{
|
|
31
|
+
"name": "options",
|
|
32
|
+
"docs": "",
|
|
33
|
+
"type": "{ data: string; }"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"returns": "Promise<MiDNIData>",
|
|
37
|
+
"tags": [],
|
|
38
|
+
"docs": "",
|
|
39
|
+
"complexTypes": [
|
|
40
|
+
"MiDNIData"
|
|
41
|
+
],
|
|
42
|
+
"slug": "validamidniqr"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "abrirEscaner",
|
|
46
|
+
"signature": "() => Promise<any>",
|
|
47
|
+
"parameters": [],
|
|
48
|
+
"returns": "Promise<any>",
|
|
49
|
+
"tags": [],
|
|
50
|
+
"docs": "",
|
|
51
|
+
"complexTypes": [],
|
|
52
|
+
"slug": "abrirescaner"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"properties": []
|
|
56
|
+
},
|
|
57
|
+
"interfaces": [
|
|
58
|
+
{
|
|
59
|
+
"name": "EstadoLicencia",
|
|
60
|
+
"slug": "estadolicencia",
|
|
61
|
+
"docs": "",
|
|
62
|
+
"tags": [],
|
|
63
|
+
"methods": [],
|
|
64
|
+
"properties": [
|
|
65
|
+
{
|
|
66
|
+
"name": "descripcion",
|
|
67
|
+
"tags": [],
|
|
68
|
+
"docs": "",
|
|
69
|
+
"complexTypes": [],
|
|
70
|
+
"type": "string"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "APIKeyValida",
|
|
74
|
+
"tags": [],
|
|
75
|
+
"docs": "",
|
|
76
|
+
"complexTypes": [],
|
|
77
|
+
"type": "boolean"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "lecturaQRHabilitada",
|
|
81
|
+
"tags": [],
|
|
82
|
+
"docs": "",
|
|
83
|
+
"complexTypes": [],
|
|
84
|
+
"type": "boolean"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "MiDNIData",
|
|
90
|
+
"slug": "midnidata",
|
|
91
|
+
"docs": "",
|
|
92
|
+
"tags": [],
|
|
93
|
+
"methods": [],
|
|
94
|
+
"properties": [
|
|
95
|
+
{
|
|
96
|
+
"name": "dni",
|
|
97
|
+
"tags": [],
|
|
98
|
+
"docs": "",
|
|
99
|
+
"complexTypes": [],
|
|
100
|
+
"type": "string"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "name",
|
|
104
|
+
"tags": [],
|
|
105
|
+
"docs": "",
|
|
106
|
+
"complexTypes": [],
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "surnames",
|
|
111
|
+
"tags": [],
|
|
112
|
+
"docs": "",
|
|
113
|
+
"complexTypes": [],
|
|
114
|
+
"type": "string"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "birthDate",
|
|
118
|
+
"tags": [],
|
|
119
|
+
"docs": "",
|
|
120
|
+
"complexTypes": [],
|
|
121
|
+
"type": "string"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "expiryDate",
|
|
125
|
+
"tags": [],
|
|
126
|
+
"docs": "",
|
|
127
|
+
"complexTypes": [],
|
|
128
|
+
"type": "string"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "gender",
|
|
132
|
+
"tags": [],
|
|
133
|
+
"docs": "",
|
|
134
|
+
"complexTypes": [],
|
|
135
|
+
"type": "string"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "address",
|
|
139
|
+
"tags": [],
|
|
140
|
+
"docs": "",
|
|
141
|
+
"complexTypes": [],
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "nationality",
|
|
146
|
+
"tags": [],
|
|
147
|
+
"docs": "",
|
|
148
|
+
"complexTypes": [],
|
|
149
|
+
"type": "string"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "parents",
|
|
153
|
+
"tags": [],
|
|
154
|
+
"docs": "",
|
|
155
|
+
"complexTypes": [],
|
|
156
|
+
"type": "string"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "supportNumber",
|
|
160
|
+
"tags": [],
|
|
161
|
+
"docs": "",
|
|
162
|
+
"complexTypes": [],
|
|
163
|
+
"type": "string"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "birthPlace1",
|
|
167
|
+
"tags": [],
|
|
168
|
+
"docs": "",
|
|
169
|
+
"complexTypes": [],
|
|
170
|
+
"type": "string"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "birthPlace2",
|
|
174
|
+
"tags": [],
|
|
175
|
+
"docs": "",
|
|
176
|
+
"complexTypes": [],
|
|
177
|
+
"type": "string"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "birthPlace3",
|
|
181
|
+
"tags": [],
|
|
182
|
+
"docs": "",
|
|
183
|
+
"complexTypes": [],
|
|
184
|
+
"type": "string"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"name": "photoData",
|
|
188
|
+
"tags": [],
|
|
189
|
+
"docs": "",
|
|
190
|
+
"complexTypes": [],
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "isAdult",
|
|
195
|
+
"tags": [],
|
|
196
|
+
"docs": "",
|
|
197
|
+
"complexTypes": [],
|
|
198
|
+
"type": "boolean | undefined"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"name": "rawSignature",
|
|
202
|
+
"tags": [],
|
|
203
|
+
"docs": "",
|
|
204
|
+
"complexTypes": [],
|
|
205
|
+
"type": "string"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": "signedData",
|
|
209
|
+
"tags": [],
|
|
210
|
+
"docs": "",
|
|
211
|
+
"complexTypes": [],
|
|
212
|
+
"type": "string"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "certificateRef",
|
|
216
|
+
"tags": [],
|
|
217
|
+
"docs": "",
|
|
218
|
+
"complexTypes": [],
|
|
219
|
+
"type": "string"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "type",
|
|
223
|
+
"tags": [],
|
|
224
|
+
"docs": "",
|
|
225
|
+
"complexTypes": [],
|
|
226
|
+
"type": "number | undefined"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "verificationResult",
|
|
230
|
+
"tags": [],
|
|
231
|
+
"docs": "",
|
|
232
|
+
"complexTypes": [],
|
|
233
|
+
"type": "{ status: 'VALID' | 'INVALID' | 'NO_CERTIFICATES' | 'INVALID_QR' | 'EXPIRED_QR' | 'UNKNOWN'; certificate?: string | undefined; }"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"name": "qrDataExpiry",
|
|
237
|
+
"tags": [],
|
|
238
|
+
"docs": "",
|
|
239
|
+
"complexTypes": [],
|
|
240
|
+
"type": "string"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "fullBirthPlace",
|
|
244
|
+
"tags": [],
|
|
245
|
+
"docs": "",
|
|
246
|
+
"complexTypes": [],
|
|
247
|
+
"type": "string"
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"enums": [],
|
|
253
|
+
"typeAliases": [],
|
|
254
|
+
"pluginConfigs": []
|
|
255
|
+
}
|