@pagopa/io-react-native-iso18013 0.1.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/IoReactNativeIso18013.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +30 -0
- package/android/build.gradle +83 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/ioreactnativeiso18013/Base64Utils.kt +56 -0
- package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeCborModule.kt +209 -0
- package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Module.kt +439 -0
- package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Package.kt +17 -0
- package/ios/Base64Utils.swift +47 -0
- package/ios/IoReactNativeCbor.mm +32 -0
- package/ios/IoReactNativeCbor.swift +188 -0
- package/ios/IoReactNativeIso18013-Bridging-Header.h +2 -0
- package/ios/IoReactNativeIso18013.mm +43 -0
- package/ios/IoReactNativeIso18013.swift +491 -0
- package/lib/module/cbor/cbor/README.md +95 -0
- package/lib/module/cbor/cbor/decoder.js +51 -0
- package/lib/module/cbor/cbor/decoder.js.map +1 -0
- package/lib/module/cbor/cbor/failure.js +2 -0
- package/lib/module/cbor/cbor/failure.js.map +1 -0
- package/lib/module/cbor/cbor/index.js +5 -0
- package/lib/module/cbor/cbor/index.js.map +1 -0
- package/lib/module/cbor/cbor/schema.js +117 -0
- package/lib/module/cbor/cbor/schema.js.map +1 -0
- package/lib/module/cbor/cbor/schema.utils.js +16 -0
- package/lib/module/cbor/cbor/schema.utils.js.map +1 -0
- package/lib/module/cbor/cose/README.md +53 -0
- package/lib/module/cbor/cose/failure.js +2 -0
- package/lib/module/cbor/cose/failure.js.map +1 -0
- package/lib/module/cbor/cose/index.js +4 -0
- package/lib/module/cbor/cose/index.js.map +1 -0
- package/lib/module/cbor/cose/sign.js +23 -0
- package/lib/module/cbor/cose/sign.js.map +1 -0
- package/lib/module/cbor/index.js +13 -0
- package/lib/module/cbor/index.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/iso18013/index.js +14 -0
- package/lib/module/iso18013/index.js.map +1 -0
- package/lib/module/iso18013/iso18013-5/README.md +234 -0
- package/lib/module/iso18013/iso18013-5/index.js +5 -0
- package/lib/module/iso18013/iso18013-5/index.js.map +1 -0
- package/lib/module/iso18013/iso18013-5/proximity.js +112 -0
- package/lib/module/iso18013/iso18013-5/proximity.js.map +1 -0
- package/lib/module/iso18013/iso18013-5/schema.js +79 -0
- package/lib/module/iso18013/iso18013-5/schema.js.map +1 -0
- package/lib/module/iso18013/iso18013-7/README.md +59 -0
- package/lib/module/iso18013/iso18013-7/index.js +4 -0
- package/lib/module/iso18013/iso18013-7/index.js.map +1 -0
- package/lib/module/iso18013/iso18013-7/remote.js +31 -0
- package/lib/module/iso18013/iso18013-7/remote.js.map +1 -0
- package/lib/module/iso18013/types.js +2 -0
- package/lib/module/iso18013/types.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/cbor/cbor/decoder.d.ts +35 -0
- package/lib/typescript/src/cbor/cbor/decoder.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cbor/failure.d.ts +15 -0
- package/lib/typescript/src/cbor/cbor/failure.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cbor/index.d.ts +4 -0
- package/lib/typescript/src/cbor/cbor/index.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cbor/schema.d.ts +2420 -0
- package/lib/typescript/src/cbor/cbor/schema.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cbor/schema.utils.d.ts +8 -0
- package/lib/typescript/src/cbor/cbor/schema.utils.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cose/failure.d.ts +15 -0
- package/lib/typescript/src/cbor/cose/failure.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cose/index.d.ts +3 -0
- package/lib/typescript/src/cbor/cose/index.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cose/sign.d.ts +19 -0
- package/lib/typescript/src/cbor/cose/sign.d.ts.map +1 -0
- package/lib/typescript/src/cbor/index.d.ts +2 -0
- package/lib/typescript/src/cbor/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/index.d.ts +3 -0
- package/lib/typescript/src/iso18013/index.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-5/index.d.ts +4 -0
- package/lib/typescript/src/iso18013/iso18013-5/index.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts +88 -0
- package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-5/schema.d.ts +85 -0
- package/lib/typescript/src/iso18013/iso18013-5/schema.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-7/index.d.ts +3 -0
- package/lib/typescript/src/iso18013/iso18013-7/index.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts +29 -0
- package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/types.d.ts +16 -0
- package/lib/typescript/src/iso18013/types.d.ts.map +1 -0
- package/package.json +163 -0
- package/src/cbor/cbor/README.md +95 -0
- package/src/cbor/cbor/decoder.ts +56 -0
- package/src/cbor/cbor/failure.ts +18 -0
- package/src/cbor/cbor/index.ts +9 -0
- package/src/cbor/cbor/schema.ts +150 -0
- package/src/cbor/cbor/schema.utils.ts +13 -0
- package/src/cbor/cose/README.md +53 -0
- package/src/cbor/cose/failure.ts +20 -0
- package/src/cbor/cose/index.ts +2 -0
- package/src/cbor/cose/sign.ts +25 -0
- package/src/cbor/index.ts +18 -0
- package/src/index.tsx +5 -0
- package/src/iso18013/index.ts +25 -0
- package/src/iso18013/iso18013-5/README.md +234 -0
- package/src/iso18013/iso18013-5/index.ts +23 -0
- package/src/iso18013/iso18013-5/proximity.ts +134 -0
- package/src/iso18013/iso18013-5/schema.ts +87 -0
- package/src/iso18013/iso18013-7/README.md +59 -0
- package/src/iso18013/iso18013-7/index.ts +7 -0
- package/src/iso18013/iso18013-7/remote.ts +54 -0
- package/src/iso18013/types.ts +16 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { coerceToJSON } from "./schema.utils.js";
|
|
5
|
+
export let DocumentTypeEnum = /*#__PURE__*/function (DocumentTypeEnum) {
|
|
6
|
+
DocumentTypeEnum["MDL"] = "org.iso.18013.5.1.mDL";
|
|
7
|
+
DocumentTypeEnum["EU_PID"] = "eu.europa.ec.eudi.pid.1";
|
|
8
|
+
return DocumentTypeEnum;
|
|
9
|
+
}({});
|
|
10
|
+
export const DocumentType = z.nativeEnum(DocumentTypeEnum);
|
|
11
|
+
/**
|
|
12
|
+
* Value contained in a document
|
|
13
|
+
*/
|
|
14
|
+
export const DocumentValue = z.object({
|
|
15
|
+
digestID: z.coerce.number().optional(),
|
|
16
|
+
random: z.string().optional(),
|
|
17
|
+
elementIdentifier: z.string(),
|
|
18
|
+
elementValue: z.any()
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Issuer Auth Unprotected Header Entry
|
|
22
|
+
*/
|
|
23
|
+
export const IssuerAuthUnprotectedHeader = z.object({
|
|
24
|
+
algorithm: z.coerce.string().optional(),
|
|
25
|
+
keyId: z.string().optional(),
|
|
26
|
+
x5chain: z.array(z.string()).optional()
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Issuer Auth Payload Validity Info
|
|
30
|
+
*/
|
|
31
|
+
export const IssuerAuthPayloadValidityInfo = z.object({
|
|
32
|
+
signed: z.coerce.date(),
|
|
33
|
+
validUntil: z.coerce.date(),
|
|
34
|
+
validFrom: z.coerce.date(),
|
|
35
|
+
expectedUpdate: z.coerce.date().optional()
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* EC KEY
|
|
39
|
+
*/
|
|
40
|
+
const ECKey = z.object({
|
|
41
|
+
kty: z.enum(['EC']),
|
|
42
|
+
crv: z.enum(['P-256', 'P-384', 'P-521']),
|
|
43
|
+
x: z.string(),
|
|
44
|
+
y: z.string()
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* RSA KEY
|
|
49
|
+
*/
|
|
50
|
+
const RSAKEY = z.object({
|
|
51
|
+
kty: z.enum(['RSA']),
|
|
52
|
+
alg: z.string(),
|
|
53
|
+
e: z.string(),
|
|
54
|
+
n: z.string()
|
|
55
|
+
});
|
|
56
|
+
const PublicKey = z.union([RSAKEY, ECKey]);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Issuer Auth Payload Device Key Info
|
|
60
|
+
*/
|
|
61
|
+
export const IssuerAuthPayloadDeviceKeyInfo = z.object({
|
|
62
|
+
deviceKey: PublicKey
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Issuer Auth Payload Object
|
|
66
|
+
*/
|
|
67
|
+
export const IssuerAuthPayload = z.object({
|
|
68
|
+
docType: z.string().optional(),
|
|
69
|
+
version: z.string().optional(),
|
|
70
|
+
validityInfo: IssuerAuthPayloadValidityInfo,
|
|
71
|
+
digestAlgorithm: z.string().optional(),
|
|
72
|
+
deviceKeyInfo: IssuerAuthPayloadDeviceKeyInfo,
|
|
73
|
+
valueDigests: z.record(z.any())
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Issuer Auth Object
|
|
77
|
+
*/
|
|
78
|
+
export const IssuerAuth = z.object({
|
|
79
|
+
rawValue: z.string().optional(),
|
|
80
|
+
protectedHeader: z.string().optional(),
|
|
81
|
+
unprotectedHeader: IssuerAuthUnprotectedHeader,
|
|
82
|
+
payload: IssuerAuthPayload,
|
|
83
|
+
signature: z.string().optional()
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Issuer signed object
|
|
87
|
+
*/
|
|
88
|
+
export const IssuerSigned = z.object({
|
|
89
|
+
nameSpaces: z.record(z.string(), coerceToJSON.pipe(z.array(DocumentValue))),
|
|
90
|
+
issuerAuth: IssuerAuth
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* mDOC object
|
|
94
|
+
*/
|
|
95
|
+
export const MDOC = z.object({
|
|
96
|
+
docType: DocumentType,
|
|
97
|
+
issuerSigned: IssuerSigned
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* CBOR decoded data containing the status, version and the list of documents
|
|
101
|
+
*/
|
|
102
|
+
export const Documents = z.object({
|
|
103
|
+
status: z.number().optional(),
|
|
104
|
+
version: z.string().optional(),
|
|
105
|
+
documents: coerceToJSON.pipe(z.array(MDOC))
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Documents object from string
|
|
110
|
+
*/
|
|
111
|
+
export const DocumentsFromString = coerceToJSON.pipe(Documents);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* IssuerSigned object from string
|
|
115
|
+
*/
|
|
116
|
+
export const IssuerSignedFromString = coerceToJSON.pipe(IssuerSigned);
|
|
117
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["z","coerceToJSON","DocumentTypeEnum","DocumentType","nativeEnum","DocumentValue","object","digestID","coerce","number","optional","random","string","elementIdentifier","elementValue","any","IssuerAuthUnprotectedHeader","algorithm","keyId","x5chain","array","IssuerAuthPayloadValidityInfo","signed","date","validUntil","validFrom","expectedUpdate","ECKey","kty","enum","crv","x","y","RSAKEY","alg","e","n","PublicKey","union","IssuerAuthPayloadDeviceKeyInfo","deviceKey","IssuerAuthPayload","docType","version","validityInfo","digestAlgorithm","deviceKeyInfo","valueDigests","record","IssuerAuth","rawValue","protectedHeader","unprotectedHeader","payload","signature","IssuerSigned","nameSpaces","pipe","issuerAuth","MDOC","issuerSigned","Documents","status","documents","DocumentsFromString","IssuerSignedFromString"],"sourceRoot":"../../../../src","sources":["cbor/cbor/schema.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,YAAY,QAAQ,mBAAgB;AAE7C,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAK5B,OAAO,MAAMC,YAAY,GAAGH,CAAC,CAACI,UAAU,CAACF,gBAAgB,CAAC;AAG1D;AACA;AACA;AACA,OAAO,MAAMG,aAAa,GAAGL,CAAC,CAACM,MAAM,CAAC;EACpCC,QAAQ,EAAEP,CAAC,CAACQ,MAAM,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACtCC,MAAM,EAAEX,CAAC,CAACY,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;EAC7BG,iBAAiB,EAAEb,CAAC,CAACY,MAAM,CAAC,CAAC;EAC7BE,YAAY,EAAEd,CAAC,CAACe,GAAG,CAAC;AACtB,CAAC,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGhB,CAAC,CAACM,MAAM,CAAC;EAClDW,SAAS,EAAEjB,CAAC,CAACQ,MAAM,CAACI,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;EACvCQ,KAAK,EAAElB,CAAC,CAACY,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;EAC5BS,OAAO,EAAEnB,CAAC,CAACoB,KAAK,CAACpB,CAAC,CAACY,MAAM,CAAC,CAAC,CAAC,CAACF,QAAQ,CAAC;AACxC,CAAC,CAAC;AAMF;AACA;AACA;AACA,OAAO,MAAMW,6BAA6B,GAAGrB,CAAC,CAACM,MAAM,CAAC;EACpDgB,MAAM,EAAEtB,CAAC,CAACQ,MAAM,CAACe,IAAI,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D,MAAM,EAAE9D,CAAC,CAACS,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BiC,OAAO,EAAE3C,CAAC,CAACY,MAAM,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC;EAC9BqD,SAAS,EAAE9D,YAAY,CAACwD,IAAI,CAACzD,CAAC,CAACoB,KAAK,CAACuC,IAAI,CAAC;AAC5C,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMK,mBAAmB,GAAG/D,YAAY,CAACwD,IAAI,CAACI,SAAS,CAAC;;AAE/D;AACA;AACA;AACA,OAAO,MAAMI,sBAAsB,GAAGhE,YAAY,CAACwD,IAAI,CAACF,YAAY,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* If the value is a string, parse it as JSON.
|
|
7
|
+
* Otherwise, return the value as is.
|
|
8
|
+
* Useful for unescaping stringified JSON content
|
|
9
|
+
*/
|
|
10
|
+
export const coerceToJSON = z.any().transform(any => {
|
|
11
|
+
if (typeof any === 'object') {
|
|
12
|
+
return any;
|
|
13
|
+
}
|
|
14
|
+
return JSON.parse(any);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=schema.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["z","coerceToJSON","any","transform","JSON","parse"],"sourceRoot":"../../../../src","sources":["cbor/cbor/schema.utils.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGD,CAAC,CAACE,GAAG,CAAC,CAAC,CAACC,SAAS,CAAED,GAAG,IAAK;EACrD,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAOA,GAAG;EACZ;EACA,OAAOE,IAAI,CAACC,KAAK,CAACH,GAAG,CAAC;AACxB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
## COSE
|
|
2
|
+
|
|
3
|
+
This module provides methods to sign and verify data with COSE.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { COSE } from '@pagopa/io-react-native-cbor';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### Methods
|
|
10
|
+
|
|
11
|
+
#### `sign`
|
|
12
|
+
|
|
13
|
+
Signs base64 encoded data using COSE (CBOR Object Signing and Encryption).
|
|
14
|
+
Returns a `Promise` which resolves to a `string` containing the COSE-Sign1 object in base64 encoding or rejects with an instance of `CoseFailure` in case of failures.
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
try {
|
|
18
|
+
const coseSign1 = await COSE.sign('base64EncodedData', 'keyTag');
|
|
19
|
+
} catch (e) {
|
|
20
|
+
const { message, userInfo } = e as CoseFailure;
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### `verify`
|
|
25
|
+
|
|
26
|
+
Verifies a COSE-Sign1 object using the provided public key.
|
|
27
|
+
Returns a `Promise` which resolves to a `boolean` indicating if the signature is valid or rejects with an instance of `CoseFailure` in case of failures.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// public key in JWK format
|
|
31
|
+
const publicKey = {
|
|
32
|
+
kty: 'EC',
|
|
33
|
+
crv: 'P-256',
|
|
34
|
+
x: '...',
|
|
35
|
+
y: '...',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const isValid = await COSE.verify('coseSign1Base64Data', publicKey);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
const { message, userInfo } = e as CoseFailure;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Error Codes
|
|
46
|
+
|
|
47
|
+
| Type | Platform | Description |
|
|
48
|
+
| -------------------- | ----------- | -------------------------------------------------- |
|
|
49
|
+
| PUBLIC_KEY_NOT_FOUND | Android/iOS | The public key is missing for the specified keyTag |
|
|
50
|
+
| INVALID_ENCODING | Android/iOS | Provided payload has incorrect encoding |
|
|
51
|
+
| UNABLE_TO_SIGN | Android/iOS | It was not possible to sign the given string |
|
|
52
|
+
| THREADING_ERROR | iOS | Unexpected failure |
|
|
53
|
+
| UNKNOWN_EXCEPTION | Android/iOS | Unexpected failure |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["cbor/cose/failure.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sign","verify"],"sourceRoot":"../../../../src","sources":["cbor/cose/index.ts"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,MAAM,QAAQ,WAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { IoReactNativeCbor } from "../index.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sign base64 encoded data with COSE and return the COSE-Sign1 object in base64 encoding
|
|
7
|
+
*
|
|
8
|
+
* @param payload - The base64 or base64url encoded payload to sign
|
|
9
|
+
* @param keyTag - The alias of the key to use for signing.
|
|
10
|
+
* @throws {CoseFailure} If the key does not exist
|
|
11
|
+
* @returns The COSE-Sign1 object in base64 encoding
|
|
12
|
+
*/
|
|
13
|
+
export const sign = async (payload, keyTag) => await IoReactNativeCbor.sign(payload, keyTag);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Verifies a COSE-Sign1 object with the provided public key
|
|
17
|
+
*
|
|
18
|
+
* @param data - The COSE-Sign1 object in base64 or base64url encoding
|
|
19
|
+
* @param publicKey - The public key in JWK format
|
|
20
|
+
* @returns true if the signature is valid, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export const verify = async (data, publicKey) => await IoReactNativeCbor.verify(data, publicKey);
|
|
23
|
+
//# sourceMappingURL=sign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IoReactNativeCbor","sign","payload","keyTag","verify","data","publicKey"],"sourceRoot":"../../../../src","sources":["cbor/cose/sign.ts"],"mappings":";;AACA,SAASA,iBAAiB,QAAQ,aAAI;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG,MAAAA,CAAOC,OAAe,EAAEC,MAAc,KACxD,MAAMH,iBAAiB,CAACC,IAAI,CAACC,OAAO,EAAEC,MAAM,CAAC;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG,MAAAA,CACpBC,IAAY,EACZC,SAAoB,KACC,MAAMN,iBAAiB,CAACI,MAAM,CAACC,IAAI,EAAEC,SAAS,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
const LINKING_ERROR = `The package '@pagopa/io-react-native-cbor' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
|
+
ios: "- You have run 'pod install'\n",
|
|
6
|
+
default: ''
|
|
7
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
8
|
+
export const IoReactNativeCbor = NativeModules.IoReactNativeCbor ? NativeModules.IoReactNativeCbor : new Proxy({}, {
|
|
9
|
+
get() {
|
|
10
|
+
throw new Error(LINKING_ERROR);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","IoReactNativeCbor","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["cbor/index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,uFAAuF,GACvFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,iBAAiB,GAAGN,aAAa,CAACM,iBAAiB,GAC5DN,aAAa,CAACM,iBAAiB,GAC/B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as CBOR from "./cbor/cbor/index.js";
|
|
4
|
+
import * as COSE from "./cbor/cose/index.js";
|
|
5
|
+
import * as ISO18013_5 from "./iso18013/iso18013-5/index.js";
|
|
6
|
+
import * as ISO18013_7 from "./iso18013/iso18013-7/index.js";
|
|
7
|
+
export { CBOR, COSE, ISO18013_5, ISO18013_7 };
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CBOR","COSE","ISO18013_5","ISO18013_7"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAO,KAAKA,IAAI,MAAM,sBAAa;AACnC,OAAO,KAAKC,IAAI,MAAM,sBAAa;AACnC,OAAO,KAAKC,UAAU,MAAM,gCAAuB;AACnD,OAAO,KAAKC,UAAU,MAAM,gCAAuB;AACnD,SAASH,IAAI,EAAEC,IAAI,EAAEC,UAAU,EAAEC,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
export { parseEventError, parseVerifierRequest } from "./iso18013-5/schema.js";
|
|
5
|
+
const LINKING_ERROR = `The package '@pagopa/io-react-native-proximity' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
6
|
+
ios: "- You have run 'pod install'\n",
|
|
7
|
+
default: ''
|
|
8
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
9
|
+
export const IoReactNativeProximity = NativeModules.IoReactNativeIso18013 ? NativeModules.IoReactNativeIso18013 : new Proxy({}, {
|
|
10
|
+
get() {
|
|
11
|
+
throw new Error(LINKING_ERROR);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","parseEventError","parseVerifierRequest","LINKING_ERROR","select","ios","default","IoReactNativeProximity","IoReactNativeIso18013","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["iso18013/index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAIEC,eAAe,EACfC,oBAAoB,QACf,wBAAqB;AAE5B,MAAMC,aAAa,GACjB,4FAA4F,GAC5FH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,sBAAsB,GAAGR,aAAa,CAACS,qBAAqB,GACrET,aAAa,CAACS,qBAAqB,GACnC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# ISO18013-5
|
|
2
|
+
|
|
3
|
+
This library provides a React Native module based on [iso18013-android](https://github.com/pagopa/iso18013-android) and [iso18013-ios](https://github.com/pagopa/iso18013-ios) which allows mDL proximity presentation according to the
|
|
4
|
+
ISO 18013-5 standard and remote presentation according to the ISO 18013-7 standard.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
### `events`
|
|
11
|
+
|
|
12
|
+
This library emits the following events:
|
|
13
|
+
| Event | Payload | Description |
|
|
14
|
+
|---------------------------|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
|
|
15
|
+
| onDeviceConnecting (iOS only) | `undefined` | Event dispatched when the verifier app is connecting |
|
|
16
|
+
| onDeviceConnected | `undefined` | Event dispatched when the verifier app is connected. |
|
|
17
|
+
| onDocumentRequestReceived | `{ data: string } \| undefined` | Event dispatched when the consumer app receives a new request, contained in the data payload. It can be parsed via the `parseVerifierRequest` provided [here](src/schema.ts). |
|
|
18
|
+
| onDeviceDisconnected | `undefined` | Event dispatched when the verifier app disconnects. |
|
|
19
|
+
| onError | `{ error: string } \| undefined` | Event dispatched when an error occurs which is contained in the error payload. It can be parsed via the `parseError` provided [here](src/schema.ts). |
|
|
20
|
+
|
|
21
|
+
Listeners can be added using the `addListener` method and removed using the `removeListener` method.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
25
|
+
|
|
26
|
+
ISO18013_5.addListener('event', () => console.log('event occurred'));
|
|
27
|
+
|
|
28
|
+
ISO18013_5.removeListener('event');
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### `onDeviceConnecting`
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
35
|
+
|
|
36
|
+
ISO18013_5.addListener('onDeviceConnecting', () => {
|
|
37
|
+
console.log('Device is connecting');
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### `onDeviceConnected`
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
45
|
+
|
|
46
|
+
ISO18013_5.addListener('onDeviceConnected', () => {
|
|
47
|
+
console.log('Device is connected');
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### `onDocumentRequestReceived`
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
55
|
+
|
|
56
|
+
ISO18013_5.addListener(
|
|
57
|
+
'onDocumentRequestReceived',
|
|
58
|
+
(payload: ISO18013_5.EventsPayload['onDocumentRequestReceived']) => {
|
|
59
|
+
console.log('onDocumentRequestReceived', payload);
|
|
60
|
+
if (!payload || !payload.data) {
|
|
61
|
+
console.warn('Request does not contain a message.');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Parse and verify the received request with the exposed function
|
|
66
|
+
const parsedJson = JSON.parse(payload.data);
|
|
67
|
+
console.log('Parsed JSON:', parsedJson);
|
|
68
|
+
const parsedResponse = parseVerifierRequest(parsedJson);
|
|
69
|
+
console.log('Parsed response:', JSON.stringify(parsedResponse));
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### `onDeviceDisconnected`
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
78
|
+
|
|
79
|
+
ISO18013_5.addListener('onDeviceDisconnected', () => {
|
|
80
|
+
console.log('Device is disconnected');
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### `onError`
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
88
|
+
|
|
89
|
+
ISO18013_5.addListener(
|
|
90
|
+
'onError',
|
|
91
|
+
async (data: ISO18013_5.EventsPayload['onError']) => {
|
|
92
|
+
try {
|
|
93
|
+
if (!data || !data.error) {
|
|
94
|
+
throw new Error('No error data received');
|
|
95
|
+
}
|
|
96
|
+
const parsedError = parseError(data.error);
|
|
97
|
+
console.error(`onError: ${parsedError}`);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
console.error('Error parsing onError data:', e);
|
|
100
|
+
} finally {
|
|
101
|
+
// Close the flow on error
|
|
102
|
+
await closeFlow();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `start`
|
|
109
|
+
|
|
110
|
+
Starts the proximity flow and starts the bluetooth service. This method also accepts optional parameters to configure the initialization on Android, along with the possibility
|
|
111
|
+
to specify a certificates of array to verify the reader app.
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
115
|
+
|
|
116
|
+
await ISO18013_5.start();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `getQrCodeString`
|
|
120
|
+
|
|
121
|
+
Returns the QR code string which contains a base64url encoded CBOR object which encodes the bluetooth engagement data.
|
|
122
|
+
It can be used to display the QR code in the UI which will be scanned by the verifier app.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
126
|
+
|
|
127
|
+
const qrCodeString = await ISO18013_5.getQrCodeString();
|
|
128
|
+
console.log(qrCodeString);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `generateResponse`
|
|
132
|
+
|
|
133
|
+
Generates a response that will be sent to the verifier app containing the requested documents.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
137
|
+
|
|
138
|
+
const response = await ISO18013_5.generateResponse({
|
|
139
|
+
documents: [
|
|
140
|
+
{
|
|
141
|
+
type: 'mDL',
|
|
142
|
+
data: 'base64url-encoded-data',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
console.log(response);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `sendResponse`
|
|
150
|
+
|
|
151
|
+
Sends the response generate by `generateResponse` to the verifier app.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
155
|
+
|
|
156
|
+
await ISO18013_5.sendResponse(response);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `sendErrorResponse`
|
|
160
|
+
|
|
161
|
+
Sends an error response to the verifier app. The supported error codes are defined in the Table 20 of the ISO 18013-5 standard and are coded in the `ErrorCode` enum.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { ISO18013_5, ErrorCode } from '@pagopa/io-react-native-iso18013';
|
|
165
|
+
|
|
166
|
+
await ISO18013_5.sendErrorResponse({
|
|
167
|
+
errorCode: ErrorCode.SESSION_ENCRYPTION,
|
|
168
|
+
errorMessage: 'An error occurred while encrypting the session',
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### `close`
|
|
173
|
+
|
|
174
|
+
Closes the QR engagement by releasing the resources allocated during the `start` method.
|
|
175
|
+
Before starting a new flow, it is necessary to call this method to ensure that the previous flow is properly closed.
|
|
176
|
+
The listeners can be removed using the `removeListener` method.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
|
|
180
|
+
|
|
181
|
+
await ISO18013_5.close();
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Proximity Flow Schema
|
|
185
|
+
|
|
186
|
+
This section describes a high level overview of the interactions between an app implementing the `io-react-native-proximity` library and a verifier app.
|
|
187
|
+
|
|
188
|
+
```mermaid
|
|
189
|
+
sequenceDiagram
|
|
190
|
+
participant app as Consumer App
|
|
191
|
+
participant proximity as io-react-native-iso18013
|
|
192
|
+
participant verifier as Verifier App
|
|
193
|
+
|
|
194
|
+
Note over proximity, verifier: If an error occurs during the flow, the onError callback is triggered
|
|
195
|
+
app->>+proximity: Calls start()
|
|
196
|
+
app->>+proximity: Calls getQrCode()
|
|
197
|
+
proximity-->>+app: QR code string
|
|
198
|
+
app->>+app: Renders the QR code string
|
|
199
|
+
verifier->>+app: Scans the QR code
|
|
200
|
+
proximity->>+app: Triggers the onDeviceConnecting callback
|
|
201
|
+
verifier->>+app: Connects to the verifier app
|
|
202
|
+
proximity->>+app: Triggers the onDeviceConnected callback
|
|
203
|
+
verifier->>+app: Requests the credential(s)
|
|
204
|
+
proximity->>+app: Triggers the onDocumentRequestReceived() callback
|
|
205
|
+
app->>+proximity: Parses the request by calling parseVerifierRequest()
|
|
206
|
+
proximity-->>+app: Returns a VerifierRequest
|
|
207
|
+
app->>+app: Shows the requested data and asks for user consent
|
|
208
|
+
alt The user accepts
|
|
209
|
+
app->>+proximity: Calls generateResponse()
|
|
210
|
+
proximity-->>+app: Returns the response
|
|
211
|
+
app->>+proximity: Calls sendResponse()
|
|
212
|
+
proximity->>+verifier: Sends the response
|
|
213
|
+
verifier->>+verifier: Shows the received credential(s) and the verification result
|
|
214
|
+
else The user rejects
|
|
215
|
+
app->>+proximity: Calls sendErrorResponse()
|
|
216
|
+
proximity->>+verifier: Sends the error response code
|
|
217
|
+
verifier->>+verifier: Shows the received error response code
|
|
218
|
+
end
|
|
219
|
+
verifier->>+app: Closes the connection
|
|
220
|
+
proximity->>+app: Calls the onDeviceDisconnected callback
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Error Codes
|
|
224
|
+
|
|
225
|
+
| Type | Platform | Description |
|
|
226
|
+
| ------------------------------- | ----------- | ---------------------------------------------------------------------------- |
|
|
227
|
+
| DRH_NOT_DEFINED | Android | The device retrieval helper hasn't been initialized, call the `start` method |
|
|
228
|
+
| QR_ENGAGEMENT_NOT_DEFINED_ERROR | Android | The QR engagement hasn't been initialized, call the `start` method |
|
|
229
|
+
| START_ERROR | Android/iOS | An error occurred while initializing the required resources |
|
|
230
|
+
| GET_QR_CODE_ERROR | Android/iOS | An error occurred while generating the engagement QR code |
|
|
231
|
+
| GENERATE_RESPONSE_ERROR | Android/iOS | An error occurred while generating the response for the verifier app |
|
|
232
|
+
| SEND_RESPONSE_ERROR | Android/iOS | An error occurred while sending the response to the verifier app |
|
|
233
|
+
| SEND_ERROR_RESPONSE_ERROR | Android/iOS | An error occurred while sending the error response to the verifier app |
|
|
234
|
+
| CLOSE_ERROR | Android | An error occured while closing the required resources |
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { parseEventError, parseVerifierRequest } from "./schema.js";
|
|
4
|
+
export { ErrorCode, addListener, close, generateResponse, getQrCodeString, removeListener, sendErrorResponse, sendResponse, start } from "./proximity.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseEventError","parseVerifierRequest","ErrorCode","addListener","close","generateResponse","getQrCodeString","removeListener","sendErrorResponse","sendResponse","start"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/index.ts"],"mappings":";;AAAA,SAIEA,eAAe,EACfC,oBAAoB,QACf,aAAU;AAEjB,SACEC,SAAS,EAGTC,WAAW,EACXC,KAAK,EACLC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,EACdC,iBAAiB,EACjBC,YAAY,EACZC,KAAK,QACA,gBAAa","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeEventEmitter, Platform } from 'react-native';
|
|
4
|
+
import { IoReactNativeProximity } from "../index.js";
|
|
5
|
+
const eventEmitter = new NativeEventEmitter(IoReactNativeProximity);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Events emitted by the native module:
|
|
9
|
+
* - `onDeviceConnecting`: (iOS only) Emitted when the device is connecting to the verifier app.
|
|
10
|
+
* - `onDeviceConnected`: Emitted when the device is connected to the verifier app.
|
|
11
|
+
* - `onDocumentRequestReceived`: Emitted when a document request is received from the verifier app. Carries a payload containing the request data.
|
|
12
|
+
* - `onDeviceDisconnected`: Emitted when the device is disconnected from the verifier app.
|
|
13
|
+
* - `onError`: Emitted when an error occurs. Carries a payload containing the error data.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Events emitted by the native module.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Error codes that can be used with the `sendErrorResponse` method.
|
|
22
|
+
* These are defined based on the SessionData status code defined in the table 20 of the ISO 18013-5 standard
|
|
23
|
+
* and mirror codes defined in the native module.
|
|
24
|
+
*/
|
|
25
|
+
export let ErrorCode = /*#__PURE__*/function (ErrorCode) {
|
|
26
|
+
ErrorCode[ErrorCode["SESSION_ENCRYPTION"] = 10] = "SESSION_ENCRYPTION";
|
|
27
|
+
ErrorCode[ErrorCode["CBOR_DECODING"] = 11] = "CBOR_DECODING";
|
|
28
|
+
ErrorCode[ErrorCode["SESSION_TERMINATED"] = 20] = "SESSION_TERMINATED";
|
|
29
|
+
return ErrorCode;
|
|
30
|
+
}({});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Starts the proximity flow by allocating the necessary resources and initializing the Bluetooth stack.
|
|
34
|
+
* @param config.peripheralMode (Android only) - Whether the device is in peripheral mode. Defaults to true
|
|
35
|
+
* @param config.centralClientMode (Android only) - Whether the device is in central client mode. Defaults to false
|
|
36
|
+
* @param config.clearBleCache (Android only) - Whether the BLE cache should be cleared. Defaults to true
|
|
37
|
+
* @param config.certificates - Array of base64 representing DER encoded X.509 certificate which are used to authenticate the verifier app
|
|
38
|
+
*/
|
|
39
|
+
export function start(config = {}) {
|
|
40
|
+
const {
|
|
41
|
+
peripheralMode,
|
|
42
|
+
centralClientMode,
|
|
43
|
+
clearBleCache,
|
|
44
|
+
certificates
|
|
45
|
+
} = config;
|
|
46
|
+
if (Platform.OS === 'ios') {
|
|
47
|
+
return IoReactNativeProximity.start(certificates ? certificates : []);
|
|
48
|
+
} else {
|
|
49
|
+
return IoReactNativeProximity.start(peripheralMode ? peripheralMode : true, centralClientMode ? centralClientMode : false, clearBleCache ? clearBleCache : true, certificates ? certificates : []);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets the QR code string this method is responsible for initializing the connection and retrieving the QR code string
|
|
55
|
+
*/
|
|
56
|
+
export function getQrCodeString() {
|
|
57
|
+
return IoReactNativeProximity.getQrCodeString();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Closes the QR engagement
|
|
62
|
+
*/
|
|
63
|
+
export function close() {
|
|
64
|
+
return IoReactNativeProximity.close();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sends an error response to the verifier app.
|
|
69
|
+
* The error code must be one of the `ErrorCode` enum values.
|
|
70
|
+
* @param code - The error code to be sent to the verifier app.
|
|
71
|
+
*/
|
|
72
|
+
export function sendErrorResponse(code) {
|
|
73
|
+
return IoReactNativeProximity.sendErrorResponse(code);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Generates a response that will be sent to the verifier app containing the requested data
|
|
78
|
+
* @param documents - An array of `Document` which contains the requested data received from the `onDocumentRequestReceived` event
|
|
79
|
+
* @param acceptedFields - The accepted fields which will be presented to the verifier app. See the type definition for more details.
|
|
80
|
+
* @returns A base64 encoded response to be sent to the verifier app via `sendResponse`
|
|
81
|
+
*/
|
|
82
|
+
export function generateResponse(documents, acceptedFields) {
|
|
83
|
+
return IoReactNativeProximity.generateResponse(documents, acceptedFields);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Sends the response generated through the `generateResponse` method to the verifier app.
|
|
88
|
+
* Currently there's not evidence of the verifier app responding to this request, thus we don't handle the response.
|
|
89
|
+
* @param response - The base64 encoded response to be sent to the verifier app.
|
|
90
|
+
*/
|
|
91
|
+
export function sendResponse(response) {
|
|
92
|
+
return IoReactNativeProximity.sendResponse(response);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Adds a listener for a `QrEngagementEvents` event which will be emitted by the native module.
|
|
97
|
+
* The callback will be called with the event payload when the event is emitted.
|
|
98
|
+
* @param event - The event to listen for. The available events are defined in the `QrEngagementEvents` type.
|
|
99
|
+
* @param callback - The callback to be called when the event is emitted. The callback will receive the event payload as an argument.
|
|
100
|
+
*/
|
|
101
|
+
export function addListener(event, callback) {
|
|
102
|
+
eventEmitter.addListener(event, callback);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Removes a listener for a `QrEngagementEvents` event.
|
|
107
|
+
* @param event - The event to remove the listener for. The available events are defined in the `QrEngagementEvents` type.
|
|
108
|
+
*/
|
|
109
|
+
export function removeListener(event) {
|
|
110
|
+
eventEmitter.removeAllListeners(event);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=proximity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","IoReactNativeProximity","eventEmitter","ErrorCode","start","config","peripheralMode","centralClientMode","clearBleCache","certificates","OS","getQrCodeString","close","sendErrorResponse","code","generateResponse","documents","acceptedFields","sendResponse","response","addListener","event","callback","removeListener","removeAllListeners"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/proximity.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,SAASC,sBAAsB,QAAQ,aAAI;AAI3C,MAAMC,YAAY,GAAG,IAAIH,kBAAkB,CAACE,sBAAsB,CAAC;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,WAAYE,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;;AAM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