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
package/Package.swift
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "Qrdnicapacitor",
|
|
6
|
+
platforms: [.iOS(.v13)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "Qrdnicapacitor",
|
|
10
|
+
targets: ["qrdniPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
|
|
14
|
+
.package(url: "https://github.com/diegocidm4/iQRDNI.git", from: "1.0.3")
|
|
15
|
+
// ,
|
|
16
|
+
//.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", exact: "1.6.0")
|
|
17
|
+
],
|
|
18
|
+
targets: [
|
|
19
|
+
.target(
|
|
20
|
+
name: "qrdniPlugin",
|
|
21
|
+
dependencies: [
|
|
22
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
23
|
+
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
|
24
|
+
.product(name: "iQRDNI", package: "iQRDNI")
|
|
25
|
+
//,
|
|
26
|
+
//.product(name: "CryptoSwift", package: "CryptoSwift")
|
|
27
|
+
],
|
|
28
|
+
path: "ios/Sources/qrdniPlugin"),
|
|
29
|
+
.testTarget(
|
|
30
|
+
name: "qrdniPluginTests",
|
|
31
|
+
dependencies: ["qrdniPlugin"],
|
|
32
|
+
path: "ios/Tests/qrdniPluginTests")
|
|
33
|
+
]
|
|
34
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'Qrdnicapacitor'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '15.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.dependency "iQRDNI", '~> 1.0.1'
|
|
17
|
+
s.swift_version = '5.1'
|
|
18
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# qrdnicapacitor
|
|
2
|
+
|
|
3
|
+
lectura y validación de códigos QR generados por la app MiDNI
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install qrdnicapacitor
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`configure(...)`](#configure)
|
|
17
|
+
* [`validaMiDNIQR(...)`](#validamidniqr)
|
|
18
|
+
* [`abrirEscaner()`](#abrirescaner)
|
|
19
|
+
* [Interfaces](#interfaces)
|
|
20
|
+
|
|
21
|
+
</docgen-index>
|
|
22
|
+
|
|
23
|
+
<docgen-api>
|
|
24
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
25
|
+
|
|
26
|
+
### configure(...)
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
configure(options: { license: string; certs?: { [key: string]: string; } | undefined; }) => Promise<EstadoLicencia>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Param | Type |
|
|
33
|
+
| ------------- | --------------------------------------------------------------------- |
|
|
34
|
+
| **`options`** | <code>{ license: string; certs?: { [key: string]: string; }; }</code> |
|
|
35
|
+
|
|
36
|
+
**Returns:** <code>Promise<<a href="#estadolicencia">EstadoLicencia</a>></code>
|
|
37
|
+
|
|
38
|
+
--------------------
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### validaMiDNIQR(...)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
validaMiDNIQR(options: { data: string; }) => Promise<MiDNIData>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Param | Type |
|
|
48
|
+
| ------------- | ------------------------------ |
|
|
49
|
+
| **`options`** | <code>{ data: string; }</code> |
|
|
50
|
+
|
|
51
|
+
**Returns:** <code>Promise<<a href="#midnidata">MiDNIData</a>></code>
|
|
52
|
+
|
|
53
|
+
--------------------
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### abrirEscaner()
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
abrirEscaner() => Promise<any>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Returns:** <code>Promise<any></code>
|
|
63
|
+
|
|
64
|
+
--------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Interfaces
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
#### EstadoLicencia
|
|
71
|
+
|
|
72
|
+
| Prop | Type |
|
|
73
|
+
| ------------------------- | -------------------- |
|
|
74
|
+
| **`descripcion`** | <code>string</code> |
|
|
75
|
+
| **`APIKeyValida`** | <code>boolean</code> |
|
|
76
|
+
| **`lecturaQRHabilitada`** | <code>boolean</code> |
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
#### MiDNIData
|
|
80
|
+
|
|
81
|
+
| Prop | Type |
|
|
82
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
83
|
+
| **`dni`** | <code>string</code> |
|
|
84
|
+
| **`name`** | <code>string</code> |
|
|
85
|
+
| **`surnames`** | <code>string</code> |
|
|
86
|
+
| **`birthDate`** | <code>string</code> |
|
|
87
|
+
| **`expiryDate`** | <code>string</code> |
|
|
88
|
+
| **`gender`** | <code>string</code> |
|
|
89
|
+
| **`address`** | <code>string</code> |
|
|
90
|
+
| **`nationality`** | <code>string</code> |
|
|
91
|
+
| **`parents`** | <code>string</code> |
|
|
92
|
+
| **`supportNumber`** | <code>string</code> |
|
|
93
|
+
| **`birthPlace1`** | <code>string</code> |
|
|
94
|
+
| **`birthPlace2`** | <code>string</code> |
|
|
95
|
+
| **`birthPlace3`** | <code>string</code> |
|
|
96
|
+
| **`photoData`** | <code>string</code> |
|
|
97
|
+
| **`isAdult`** | <code>boolean</code> |
|
|
98
|
+
| **`rawSignature`** | <code>string</code> |
|
|
99
|
+
| **`signedData`** | <code>string</code> |
|
|
100
|
+
| **`certificateRef`** | <code>string</code> |
|
|
101
|
+
| **`type`** | <code>number</code> |
|
|
102
|
+
| **`verificationResult`** | <code>{ status: 'VALID' \| 'INVALID' \| 'NO_CERTIFICATES' \| 'INVALID_QR' \| 'EXPIRED_QR' \| 'UNKNOWN'; certificate?: string; }</code> |
|
|
103
|
+
| **`qrDataExpiry`** | <code>string</code> |
|
|
104
|
+
| **`fullBirthPlace`** | <code>string</code> |
|
|
105
|
+
|
|
106
|
+
</docgen-api>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace = "com.cqesolutions.qrdnicapacitor"
|
|
22
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError = false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation files('libs/qrdnidroid-release.aar')
|
|
53
|
+
implementation files('libs/jpeg2000.jar')
|
|
54
|
+
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
|
55
|
+
implementation ('me.dm7.barcodescanner:zxing:1.9.8') {
|
|
56
|
+
exclude group: 'com.android.support'
|
|
57
|
+
}
|
|
58
|
+
implementation project(':capacitor-android')
|
|
59
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
60
|
+
testImplementation "junit:junit:$junitVersion"
|
|
61
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
62
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
63
|
+
|
|
64
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
package="com.cqesolutions.qrdnicapacitor">
|
|
4
|
+
|
|
5
|
+
<application>
|
|
6
|
+
<activity
|
|
7
|
+
android:name="com.cqesolutions.qrdnicapacitor.QrCodeScanner"
|
|
8
|
+
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
9
|
+
android:exported="false" />
|
|
10
|
+
</application>
|
|
11
|
+
|
|
12
|
+
</manifest>
|
|
13
|
+
<!--
|
|
14
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
15
|
+
</manifest>
|
|
16
|
+
-->
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package com.cqesolutions.qrdnicapacitor;
|
|
2
|
+
|
|
3
|
+
import android.content.Intent;
|
|
4
|
+
import android.os.Bundle;
|
|
5
|
+
import android.util.Base64;
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
9
|
+
|
|
10
|
+
import com.google.zxing.Result;
|
|
11
|
+
|
|
12
|
+
import me.dm7.barcodescanner.zxing.ZXingScannerView;
|
|
13
|
+
|
|
14
|
+
public class QrCodeScanner extends AppCompatActivity implements ZXingScannerView.ResultHandler {
|
|
15
|
+
public static final String KEY_QR_CODE = "qr_code";
|
|
16
|
+
private ZXingScannerView mScannerView;
|
|
17
|
+
private Boolean returnString = true;
|
|
18
|
+
@Override
|
|
19
|
+
public void onCreate(Bundle state) {
|
|
20
|
+
super.onCreate(state);
|
|
21
|
+
// Programmatically initialize the scanner view
|
|
22
|
+
mScannerView = new ZXingScannerView(this);
|
|
23
|
+
// Set the scanner view as the content view
|
|
24
|
+
if(getIntent().hasExtra("returnString")) {
|
|
25
|
+
returnString = (Boolean) getIntent().getExtras().get("returnString");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setContentView(mScannerView);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public void onResume() {
|
|
33
|
+
super.onResume();
|
|
34
|
+
// Register ourselves as a handler for scan results.
|
|
35
|
+
mScannerView.setResultHandler(this);
|
|
36
|
+
// Start camera on resume
|
|
37
|
+
mScannerView.startCamera();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public void onPause() {
|
|
42
|
+
super.onPause();
|
|
43
|
+
// Stop camera on pause
|
|
44
|
+
mScannerView.stopCamera();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public void handleResult(Result rawResult) {
|
|
49
|
+
if(returnString)
|
|
50
|
+
{
|
|
51
|
+
Intent intent = new Intent();
|
|
52
|
+
intent.putExtra(KEY_QR_CODE, rawResult.getText());
|
|
53
|
+
setResult(RESULT_OK, intent);
|
|
54
|
+
finish();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
Log.i("QrCodeScanner", "QR detectado");
|
|
58
|
+
// 1. OBTENER BYTES CRUDOS (CRÍTICO PARA DNI 4.0)
|
|
59
|
+
// No uses getText() para datos binarios
|
|
60
|
+
byte[] rawBytes = rawResult.getRawBytes();
|
|
61
|
+
|
|
62
|
+
if (rawBytes != null && rawBytes.length > 0) {
|
|
63
|
+
|
|
64
|
+
// 2. CONVERTIR A BASE64
|
|
65
|
+
// Como tu fragmento 'DatosMiDnie' espera un String y hace un Base64.decode,
|
|
66
|
+
// aquí debemos hacer el Base64.encode.
|
|
67
|
+
String base64Result = Base64.encodeToString(rawBytes, Base64.NO_WRAP);
|
|
68
|
+
|
|
69
|
+
// Debug: Ver longitud
|
|
70
|
+
Log.d("QrCodeScanner", "Bytes leídos: " + rawBytes.length);
|
|
71
|
+
|
|
72
|
+
// 3. RETORNAR EL RESULTADO
|
|
73
|
+
Intent intent = new Intent();
|
|
74
|
+
intent.putExtra(KEY_QR_CODE, base64Result);
|
|
75
|
+
setResult(RESULT_OK, intent);
|
|
76
|
+
finish();
|
|
77
|
+
} else {
|
|
78
|
+
// Si falla la lectura de bytes, reanudamos la cámara
|
|
79
|
+
mScannerView.resumeCameraPreview(this);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|