@pagopa/io-react-native-wallet 0.25.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -35
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +19 -57
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +1 -0
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +1 -2
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/errors.js +1 -18
- package/lib/commonjs/credential/issuance/errors.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +6 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +2 -4
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
- package/lib/commonjs/index.js +1 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/misc.js +19 -58
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/issuing.js +1 -2
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +19 -58
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +1 -0
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +1 -2
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/errors.js +0 -16
- package/lib/module/credential/issuance/errors.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/status/02-status-attestation.js +2 -4
- package/lib/module/credential/status/02-status-attestation.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/misc.js +14 -51
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +1 -2
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +16 -15
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +1 -0
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/errors.d.ts +0 -9
- package/lib/typescript/credential/issuance/errors.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts +1 -2
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts +5 -25
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +2 -2
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/package.json +2 -6
- package/src/credential/issuance/03-start-user-authorization.ts +1 -1
- package/src/credential/issuance/04-complete-user-authorization.ts +42 -103
- package/src/credential/issuance/05-authorize-access.ts +1 -0
- package/src/credential/issuance/06-obtain-credential.ts +1 -2
- package/src/credential/issuance/errors.ts +0 -15
- package/src/credential/issuance/index.ts +4 -0
- package/src/credential/status/02-status-attestation.ts +2 -4
- package/src/index.ts +0 -2
- package/src/utils/misc.ts +16 -63
- package/src/wallet-instance-attestation/issuing.ts +1 -2
- package/lib/commonjs/cie/README.md +0 -6
- package/lib/commonjs/cie/component.js +0 -182
- package/lib/commonjs/cie/component.js.map +0 -1
- package/lib/commonjs/cie/error.js +0 -44
- package/lib/commonjs/cie/error.js.map +0 -1
- package/lib/commonjs/cie/index.js +0 -32
- package/lib/commonjs/cie/index.js.map +0 -1
- package/lib/commonjs/cie/manager.js +0 -142
- package/lib/commonjs/cie/manager.js.map +0 -1
- package/lib/module/cie/README.md +0 -6
- package/lib/module/cie/component.js +0 -172
- package/lib/module/cie/component.js.map +0 -1
- package/lib/module/cie/error.js +0 -36
- package/lib/module/cie/error.js.map +0 -1
- package/lib/module/cie/index.js +0 -4
- package/lib/module/cie/index.js.map +0 -1
- package/lib/module/cie/manager.js +0 -133
- package/lib/module/cie/manager.js.map +0 -1
- package/lib/typescript/cie/component.d.ts +0 -46
- package/lib/typescript/cie/component.d.ts.map +0 -1
- package/lib/typescript/cie/error.d.ts +0 -31
- package/lib/typescript/cie/error.d.ts.map +0 -1
- package/lib/typescript/cie/index.d.ts +0 -4
- package/lib/typescript/cie/index.d.ts.map +0 -1
- package/lib/typescript/cie/manager.d.ts +0 -5
- package/lib/typescript/cie/manager.d.ts.map +0 -1
- package/src/cie/README.md +0 -6
- package/src/cie/component.tsx +0 -218
- package/src/cie/error.ts +0 -58
- package/src/cie/index.ts +0 -4
- package/src/cie/manager.ts +0 -183
package/lib/module/cie/error.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
export let CieErrorType = /*#__PURE__*/function (CieErrorType) {
|
2
|
-
CieErrorType[CieErrorType["GENERIC"] = 0] = "GENERIC";
|
3
|
-
CieErrorType[CieErrorType["TAG_NOT_VALID"] = 1] = "TAG_NOT_VALID";
|
4
|
-
CieErrorType[CieErrorType["WEB_VIEW_ERROR"] = 2] = "WEB_VIEW_ERROR";
|
5
|
-
CieErrorType[CieErrorType["NFC_ERROR"] = 3] = "NFC_ERROR";
|
6
|
-
CieErrorType[CieErrorType["AUTHENTICATION_ERROR"] = 4] = "AUTHENTICATION_ERROR";
|
7
|
-
CieErrorType[CieErrorType["PIN_ERROR"] = 5] = "PIN_ERROR";
|
8
|
-
CieErrorType[CieErrorType["PIN_LOCKED"] = 6] = "PIN_LOCKED";
|
9
|
-
CieErrorType[CieErrorType["CERTIFICATE_ERROR"] = 7] = "CERTIFICATE_ERROR";
|
10
|
-
return CieErrorType;
|
11
|
-
}({});
|
12
|
-
export class CieError extends Error {
|
13
|
-
constructor(options) {
|
14
|
-
super(options.message);
|
15
|
-
if (options.type) {
|
16
|
-
this.type = options.type;
|
17
|
-
} else {
|
18
|
-
this.type = CieErrorType.GENERIC;
|
19
|
-
}
|
20
|
-
if (this.type === CieErrorType.PIN_ERROR) {
|
21
|
-
this.attemptsLeft = options.attemptsLeft;
|
22
|
-
} else if (this.type === CieErrorType.PIN_LOCKED) {
|
23
|
-
this.attemptsLeft = 0;
|
24
|
-
}
|
25
|
-
this.name = this.constructor.name;
|
26
|
-
}
|
27
|
-
toString() {
|
28
|
-
return JSON.stringify({
|
29
|
-
name: this.name,
|
30
|
-
type: CieErrorType[this.type],
|
31
|
-
message: this.message,
|
32
|
-
attemptsLeft: this.attemptsLeft
|
33
|
-
});
|
34
|
-
}
|
35
|
-
}
|
36
|
-
//# sourceMappingURL=error.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["CieErrorType","CieError","Error","constructor","options","message","type","GENERIC","PIN_ERROR","attemptsLeft","PIN_LOCKED","name","toString","JSON","stringify"],"sourceRoot":"../../../src","sources":["cie/error.ts"],"mappings":"AAAA,WAAYA,YAAY,0BAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;AA4BxB,OAAO,MAAMC,QAAQ,SAASC,KAAK,CAAC;EAGlCC,WAAWA,CAACC,OAAqB,EAAE;IACjC,KAAK,CAACA,OAAO,CAACC,OAAO,CAAC;IAEtB,IAAID,OAAO,CAACE,IAAI,EAAE;MAChB,IAAI,CAACA,IAAI,GAAGF,OAAO,CAACE,IAAI;IAC1B,CAAC,MAAM;MACL,IAAI,CAACA,IAAI,GAAGN,YAAY,CAACO,OAAO;IAClC;IAEA,IAAI,IAAI,CAACD,IAAI,KAAKN,YAAY,CAACQ,SAAS,EAAE;MACxC,IAAI,CAACC,YAAY,GAAGL,OAAO,CAACK,YAAY;IAC1C,CAAC,MAAM,IAAI,IAAI,CAACH,IAAI,KAAKN,YAAY,CAACU,UAAU,EAAE;MAChD,IAAI,CAACD,YAAY,GAAG,CAAC;IACvB;IAEA,IAAI,CAACE,IAAI,GAAG,IAAI,CAACR,WAAW,CAACQ,IAAI;EACnC;EAEAC,QAAQA,CAAA,EAAW;IACjB,OAAOC,IAAI,CAACC,SAAS,CAAC;MACpBH,IAAI,EAAE,IAAI,CAACA,IAAI;MACfL,IAAI,EAAEN,YAAY,CAAC,IAAI,CAACM,IAAI,CAAC;MAC7BD,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBI,YAAY,EAAE,IAAI,CAACA;IACrB,CAAC,CAAC;EACJ;AACF"}
|
package/lib/module/cie/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["CieEvent","WebViewComponent","CieError","CieErrorType"],"sourceRoot":"../../../src","sources":["cie/index.ts"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,aAAa;AACxD,SAASC,QAAQ,EAAEC,YAAY,QAAQ,SAAS;AAEhD,SAASF,gBAAgB,EAAEC,QAAQ,EAAEC,YAAY,EAAEH,QAAQ"}
|
@@ -1,133 +0,0 @@
|
|
1
|
-
import cieManager from "@pagopa/react-native-cie";
|
2
|
-
import { Platform } from "react-native";
|
3
|
-
import { CieEvent } from "./component";
|
4
|
-
import { CieError, CieErrorType } from "./error";
|
5
|
-
const BASE_UAT_URL = "https://collaudo.idserver.servizicie.interno.gov.it/idp/";
|
6
|
-
export const startCieAndroid = (useCieUat, ciePin, onError, onEvent, cieAuthorizationUri, continueWithUrl) => {
|
7
|
-
try {
|
8
|
-
cieManager.removeAllListeners();
|
9
|
-
cieManager.start().then(async () => {
|
10
|
-
cieManager.onEvent(handleCieEvent(onError, onEvent));
|
11
|
-
cieManager.onError(e => {
|
12
|
-
console.error(e);
|
13
|
-
return onError(new CieError({
|
14
|
-
message: e.message
|
15
|
-
}));
|
16
|
-
});
|
17
|
-
cieManager.onSuccess(handleCieSuccess(continueWithUrl));
|
18
|
-
await cieManager.setPin(ciePin);
|
19
|
-
cieManager.setAuthenticationUrl(cieAuthorizationUri);
|
20
|
-
cieManager.enableLog(useCieUat);
|
21
|
-
cieManager.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
|
22
|
-
await cieManager.startListeningNFC();
|
23
|
-
onEvent(CieEvent.waiting_card);
|
24
|
-
}).catch(onError);
|
25
|
-
} catch (e) {
|
26
|
-
onError(new CieError({
|
27
|
-
message: `Unable to start CIE NFC manager on Android: ${e}`,
|
28
|
-
type: CieErrorType.NFC_ERROR
|
29
|
-
}));
|
30
|
-
}
|
31
|
-
};
|
32
|
-
export const startCieiOS = async (useCieUat, ciePin, onError, onEvent, cieAuthorizationUri, continueWithUrl) => {
|
33
|
-
try {
|
34
|
-
cieManager.removeAllListeners();
|
35
|
-
cieManager.onEvent(handleCieEvent(onError, onEvent));
|
36
|
-
cieManager.onError(e => onError(new CieError({
|
37
|
-
message: e.message
|
38
|
-
})));
|
39
|
-
cieManager.onSuccess(handleCieSuccess(continueWithUrl));
|
40
|
-
cieManager.enableLog(useCieUat);
|
41
|
-
cieManager.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
|
42
|
-
await cieManager.setPin(ciePin);
|
43
|
-
cieManager.setAuthenticationUrl(cieAuthorizationUri);
|
44
|
-
cieManager.start().then(async () => {
|
45
|
-
await cieManager.startListeningNFC();
|
46
|
-
onEvent(CieEvent.waiting_card);
|
47
|
-
}).catch(onError);
|
48
|
-
} catch (e) {
|
49
|
-
onError(new CieError({
|
50
|
-
message: `Unable to start CIE NFC manager on iOS: ${e}`,
|
51
|
-
type: CieErrorType.NFC_ERROR
|
52
|
-
}));
|
53
|
-
}
|
54
|
-
};
|
55
|
-
const handleCieEvent = (onError, onEvent) => event => {
|
56
|
-
switch (event.event) {
|
57
|
-
// Reading starts
|
58
|
-
case "ON_TAG_DISCOVERED":
|
59
|
-
onEvent(CieEvent.reading);
|
60
|
-
break;
|
61
|
-
// "Function not supported" seems to be TAG_ERROR_NFC_NOT_SUPPORTED
|
62
|
-
// for the iOS SDK
|
63
|
-
case "Function not supported":
|
64
|
-
case "TAG_ERROR_NFC_NOT_SUPPORTED":
|
65
|
-
case "ON_TAG_DISCOVERED_NOT_CIE":
|
66
|
-
onError(new CieError({
|
67
|
-
message: `Invalid CIE card: ${event.event}`,
|
68
|
-
type: CieErrorType.TAG_NOT_VALID
|
69
|
-
}));
|
70
|
-
break;
|
71
|
-
case "AUTHENTICATION_ERROR":
|
72
|
-
case "ON_NO_INTERNET_CONNECTION":
|
73
|
-
onError(new CieError({
|
74
|
-
message: `Authentication error or no internet connection`,
|
75
|
-
type: CieErrorType.AUTHENTICATION_ERROR
|
76
|
-
}));
|
77
|
-
break;
|
78
|
-
case "EXTENDED_APDU_NOT_SUPPORTED":
|
79
|
-
onError(new CieError({
|
80
|
-
message: `APDU not supported`,
|
81
|
-
type: CieErrorType.NFC_ERROR
|
82
|
-
}));
|
83
|
-
break;
|
84
|
-
case "Transmission Error":
|
85
|
-
case "ON_TAG_LOST":
|
86
|
-
onError(new CieError({
|
87
|
-
message: `Trasmission error`,
|
88
|
-
type: CieErrorType.NFC_ERROR
|
89
|
-
}));
|
90
|
-
break;
|
91
|
-
|
92
|
-
// The card is temporarily locked. Unlock is available by CieID app
|
93
|
-
case "PIN Locked":
|
94
|
-
case "ON_CARD_PIN_LOCKED":
|
95
|
-
onError(new CieError({
|
96
|
-
message: `PIN locked`,
|
97
|
-
type: CieErrorType.PIN_LOCKED
|
98
|
-
}));
|
99
|
-
break;
|
100
|
-
case "ON_PIN_ERROR":
|
101
|
-
onError(new CieError({
|
102
|
-
message: `PIN locked`,
|
103
|
-
type: CieErrorType.PIN_ERROR,
|
104
|
-
attemptsLeft: event.attemptsLeft
|
105
|
-
}));
|
106
|
-
break;
|
107
|
-
|
108
|
-
// CIE is Expired or Revoked
|
109
|
-
case "CERTIFICATE_EXPIRED":
|
110
|
-
onError(new CieError({
|
111
|
-
message: `Certificate expired`,
|
112
|
-
type: CieErrorType.CERTIFICATE_ERROR
|
113
|
-
}));
|
114
|
-
break;
|
115
|
-
case "CERTIFICATE_REVOKED":
|
116
|
-
onError(new CieError({
|
117
|
-
message: `Certificate revoked`,
|
118
|
-
type: CieErrorType.CERTIFICATE_ERROR
|
119
|
-
}));
|
120
|
-
break;
|
121
|
-
default:
|
122
|
-
break;
|
123
|
-
}
|
124
|
-
};
|
125
|
-
const handleCieSuccess = continueWithUrl => url => {
|
126
|
-
continueWithUrl(decodeURIComponent(url));
|
127
|
-
};
|
128
|
-
const getCieUatEndpoint = () => Platform.select({
|
129
|
-
ios: `${BASE_UAT_URL}Authn/SSL/Login2`,
|
130
|
-
android: BASE_UAT_URL,
|
131
|
-
default: null
|
132
|
-
});
|
133
|
-
//# sourceMappingURL=manager.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["cieManager","Platform","CieEvent","CieError","CieErrorType","BASE_UAT_URL","startCieAndroid","useCieUat","ciePin","onError","onEvent","cieAuthorizationUri","continueWithUrl","removeAllListeners","start","then","handleCieEvent","e","console","error","message","onSuccess","handleCieSuccess","setPin","setAuthenticationUrl","enableLog","setCustomIdpUrl","getCieUatEndpoint","startListeningNFC","waiting_card","catch","type","NFC_ERROR","startCieiOS","event","reading","TAG_NOT_VALID","AUTHENTICATION_ERROR","PIN_LOCKED","PIN_ERROR","attemptsLeft","CERTIFICATE_ERROR","url","decodeURIComponent","select","ios","android","default"],"sourceRoot":"../../../src","sources":["cie/manager.ts"],"mappings":"AAAA,OAAOA,UAAU,MAAgC,0BAA0B;AAC3E,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,QAAQ,QAAuC,aAAa;AACrE,SAASC,QAAQ,EAAEC,YAAY,QAAQ,SAAS;AAEhD,MAAMC,YAAY,GAAG,0DAA0D;AAI/E,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,SAAkB,EAClBC,MAAc,EACdC,OAAgB,EAChBC,OAAmB,EACnBC,mBAA2B,EAC3BC,eAAgC,KAC7B;EACH,IAAI;IACFZ,UAAU,CAACa,kBAAkB,CAAC,CAAC;IAC/Bb,UAAU,CACPc,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC,YAAY;MAChBf,UAAU,CAACU,OAAO,CAACM,cAAc,CAACP,OAAO,EAAEC,OAAO,CAAC,CAAC;MACpDV,UAAU,CAACS,OAAO,CAAEQ,CAAQ,IAAK;QAC/BC,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC;QAChB,OAAOR,OAAO,CAAC,IAAIN,QAAQ,CAAC;UAAEiB,OAAO,EAAEH,CAAC,CAACG;QAAQ,CAAC,CAAC,CAAC;MACtD,CAAC,CAAC;MACFpB,UAAU,CAACqB,SAAS,CAACC,gBAAgB,CAACV,eAAe,CAAC,CAAC;MACvD,MAAMZ,UAAU,CAACuB,MAAM,CAACf,MAAM,CAAC;MAC/BR,UAAU,CAACwB,oBAAoB,CAACb,mBAAmB,CAAC;MACpDX,UAAU,CAACyB,SAAS,CAAClB,SAAS,CAAC;MAC/BP,UAAU,CAAC0B,eAAe,CAACnB,SAAS,GAAGoB,iBAAiB,CAAC,CAAC,GAAG,IAAI,CAAC;MAClE,MAAM3B,UAAU,CAAC4B,iBAAiB,CAAC,CAAC;MACpClB,OAAO,CAACR,QAAQ,CAAC2B,YAAY,CAAC;IAChC,CAAC,CAAC,CACDC,KAAK,CAACrB,OAAO,CAAC;EACnB,CAAC,CAAC,OAAOQ,CAAC,EAAE;IACVR,OAAO,CACL,IAAIN,QAAQ,CAAC;MACXiB,OAAO,EAAG,+CAA8CH,CAAE,EAAC;MAC3Dc,IAAI,EAAE3B,YAAY,CAAC4B;IACrB,CAAC,CACH,CAAC;EACH;AACF,CAAC;AAED,OAAO,MAAMC,WAAW,GAAG,MAAAA,CACzB1B,SAAkB,EAClBC,MAAc,EACdC,OAAgB,EAChBC,OAAmB,EACnBC,mBAA2B,EAC3BC,eAAgC,KAC7B;EACH,IAAI;IACFZ,UAAU,CAACa,kBAAkB,CAAC,CAAC;IAC/Bb,UAAU,CAACU,OAAO,CAACM,cAAc,CAACP,OAAO,EAAEC,OAAO,CAAC,CAAC;IACpDV,UAAU,CAACS,OAAO,CAAEQ,CAAQ,IAC1BR,OAAO,CAAC,IAAIN,QAAQ,CAAC;MAAEiB,OAAO,EAAEH,CAAC,CAACG;IAAQ,CAAC,CAAC,CAC9C,CAAC;IACDpB,UAAU,CAACqB,SAAS,CAACC,gBAAgB,CAACV,eAAe,CAAC,CAAC;IACvDZ,UAAU,CAACyB,SAAS,CAAClB,SAAS,CAAC;IAC/BP,UAAU,CAAC0B,eAAe,CAACnB,SAAS,GAAGoB,iBAAiB,CAAC,CAAC,GAAG,IAAI,CAAC;IAClE,MAAM3B,UAAU,CAACuB,MAAM,CAACf,MAAM,CAAC;IAC/BR,UAAU,CAACwB,oBAAoB,CAACb,mBAAmB,CAAC;IACpDX,UAAU,CACPc,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC,YAAY;MAChB,MAAMf,UAAU,CAAC4B,iBAAiB,CAAC,CAAC;MACpClB,OAAO,CAACR,QAAQ,CAAC2B,YAAY,CAAC;IAChC,CAAC,CAAC,CACDC,KAAK,CAACrB,OAAO,CAAC;EACnB,CAAC,CAAC,OAAOQ,CAAC,EAAE;IACVR,OAAO,CACL,IAAIN,QAAQ,CAAC;MACXiB,OAAO,EAAG,2CAA0CH,CAAE,EAAC;MACvDc,IAAI,EAAE3B,YAAY,CAAC4B;IACrB,CAAC,CACH,CAAC;EACH;AACF,CAAC;AAED,MAAMhB,cAAc,GAClBA,CAACP,OAAgB,EAAEC,OAAmB,KAAMwB,KAAa,IAAK;EAC5D,QAAQA,KAAK,CAACA,KAAK;IACjB;IACA,KAAK,mBAAmB;MACtBxB,OAAO,CAACR,QAAQ,CAACiC,OAAO,CAAC;MACzB;IACF;IACA;IACA,KAAK,wBAAwB;IAC7B,KAAK,6BAA6B;IAClC,KAAK,2BAA2B;MAC9B1B,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,sBAAqBc,KAAK,CAACA,KAAM,EAAC;QAC5CH,IAAI,EAAE3B,YAAY,CAACgC;MACrB,CAAC,CACH,CAAC;MACD;IACF,KAAK,sBAAsB;IAC3B,KAAK,2BAA2B;MAC9B3B,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,gDAA+C;QACzDW,IAAI,EAAE3B,YAAY,CAACiC;MACrB,CAAC,CACH,CAAC;MACD;IACF,KAAK,6BAA6B;MAChC5B,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,oBAAmB;QAC7BW,IAAI,EAAE3B,YAAY,CAAC4B;MACrB,CAAC,CACH,CAAC;MACD;IACF,KAAK,oBAAoB;IACzB,KAAK,aAAa;MAChBvB,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,mBAAkB;QAC5BW,IAAI,EAAE3B,YAAY,CAAC4B;MACrB,CAAC,CACH,CAAC;MACD;;IAEF;IACA,KAAK,YAAY;IACjB,KAAK,oBAAoB;MACvBvB,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,YAAW;QACrBW,IAAI,EAAE3B,YAAY,CAACkC;MACrB,CAAC,CACH,CAAC;MACD;IACF,KAAK,cAAc;MACjB7B,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,YAAW;QACrBW,IAAI,EAAE3B,YAAY,CAACmC,SAAS;QAC5BC,YAAY,EAAEN,KAAK,CAACM;MACtB,CAAC,CACH,CAAC;MACD;;IAEF;IACA,KAAK,qBAAqB;MACxB/B,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,qBAAoB;QAC9BW,IAAI,EAAE3B,YAAY,CAACqC;MACrB,CAAC,CACH,CAAC;MACD;IACF,KAAK,qBAAqB;MACxBhC,OAAO,CACL,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,qBAAoB;QAC9BW,IAAI,EAAE3B,YAAY,CAACqC;MACrB,CAAC,CACH,CAAC;MAED;IAEF;MACE;EACJ;AACF,CAAC;AAEH,MAAMnB,gBAAgB,GACnBV,eAAgC,IAAM8B,GAAW,IAAK;EACrD9B,eAAe,CAAC+B,kBAAkB,CAACD,GAAG,CAAC,CAAC;AAC1C,CAAC;AAEH,MAAMf,iBAAiB,GAAGA,CAAA,KACxB1B,QAAQ,CAAC2C,MAAM,CAAC;EACdC,GAAG,EAAG,GAAExC,YAAa,kBAAiB;EACtCyC,OAAO,EAAEzC,YAAY;EACrB0C,OAAO,EAAE;AACX,CAAC,CAAC"}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { CieError } from "./error";
|
3
|
-
export type OnSuccess = (url: string) => void;
|
4
|
-
export type OnError = (e: CieError) => void;
|
5
|
-
export type OnCieEvent = (e: CieEvent) => void;
|
6
|
-
export declare enum CieEvent {
|
7
|
-
"reading" = "reading",
|
8
|
-
"completed" = "completed",
|
9
|
-
"waiting_card" = "waiting_card"
|
10
|
-
}
|
11
|
-
type CIEParams = {
|
12
|
-
authUrl: string;
|
13
|
-
onSuccess: OnSuccess;
|
14
|
-
onError: OnError;
|
15
|
-
pin: string;
|
16
|
-
useUat: boolean;
|
17
|
-
redirectUrl: string;
|
18
|
-
onEvent: OnCieEvent;
|
19
|
-
};
|
20
|
-
/**
|
21
|
-
* WebViewComponent
|
22
|
-
*
|
23
|
-
* Component that manages authentication via CIE L3 (NFC+PIN) based on WebView (react-native-webview).
|
24
|
-
* In particular, once rendered, it makes a series of calls to the authUrl in the WebView,
|
25
|
-
* extrapolates the authentication URL necessary for CieManager to sign via certificate
|
26
|
-
* and calls the CIE SDK which is responsible for starting card reading via NFC.
|
27
|
-
* At the end of the reading, a redirect is made in the WebView towards the page that asks
|
28
|
-
* the user for consent to send the data to the Service Provider. This moment can be captured
|
29
|
-
* via the onUserInteraction parameter. When the user allows or denies their consent,
|
30
|
-
* a redirect is made to the URL set by the Service Provider.
|
31
|
-
* This url can be configured using the redirectUrl parameter which allows you to close the WebView.
|
32
|
-
* The event can then be captured via the onSuccess parameter.
|
33
|
-
*
|
34
|
-
* @param {CIEParams} params - Parameters required by the component.
|
35
|
-
* @param {string} params.authUrl -The authentication URL of the Service Provider to which to authenticate.
|
36
|
-
* @param {boolean} params.useUat - If set to true it uses the CIE testing environment.
|
37
|
-
* @param {string} params.pin - CIE pin for use with NFC reading.
|
38
|
-
* @param {Function} params.onError - Callback function in case of error. The function is passed the Error parameter.
|
39
|
-
* @param {Function} params.onSuccess - Callback at the end of authentication to which the redirect URL including parameters is passed.
|
40
|
-
* @param {string} params.redirectUrl - Redirect URL set by the Service Provider. It is used to stop the flow and return to the calling function via onSuccess.
|
41
|
-
* @param {Function} params.onEvent - Callback function that is called whenever there is a new CieEvent from the CIE reader.
|
42
|
-
* @returns {JSX.Element} - The configured component with WebView.
|
43
|
-
*/
|
44
|
-
export declare const WebViewComponent: (params: CIEParams) => React.JSX.Element;
|
45
|
-
export {};
|
46
|
-
//# sourceMappingURL=component.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/cie/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAYzC,OAAO,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;AA4BjD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAC9C,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;AAC5C,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;AAC/C,oBAAY,QAAQ;IAClB,SAAS,YAAY;IACrB,WAAW,cAAc;IACzB,cAAc,iBAAiB;CAChC;AAED,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAeF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gBAAgB,WAAY,SAAS,sBAyHjD,CAAC"}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
export declare enum CieErrorType {
|
2
|
-
GENERIC = 0,
|
3
|
-
TAG_NOT_VALID = 1,
|
4
|
-
WEB_VIEW_ERROR = 2,
|
5
|
-
NFC_ERROR = 3,
|
6
|
-
AUTHENTICATION_ERROR = 4,
|
7
|
-
PIN_ERROR = 5,
|
8
|
-
PIN_LOCKED = 6,
|
9
|
-
CERTIFICATE_ERROR = 7
|
10
|
-
}
|
11
|
-
interface BaseCieError {
|
12
|
-
message: string;
|
13
|
-
type?: CieErrorType;
|
14
|
-
}
|
15
|
-
interface PinErrorOptions extends BaseCieError {
|
16
|
-
type: CieErrorType.PIN_ERROR;
|
17
|
-
attemptsLeft: number;
|
18
|
-
}
|
19
|
-
interface NonPinErrorOptions extends BaseCieError {
|
20
|
-
type?: Exclude<CieErrorType, CieErrorType.PIN_ERROR>;
|
21
|
-
attemptsLeft?: number;
|
22
|
-
}
|
23
|
-
type ErrorOptions = PinErrorOptions | NonPinErrorOptions;
|
24
|
-
export declare class CieError extends Error {
|
25
|
-
type: CieErrorType;
|
26
|
-
attemptsLeft?: number;
|
27
|
-
constructor(options: ErrorOptions);
|
28
|
-
toString(): string;
|
29
|
-
}
|
30
|
-
export {};
|
31
|
-
//# sourceMappingURL=error.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/cie/error.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,OAAO,IAAA;IACP,aAAa,IAAA;IACb,cAAc,IAAA;IACd,SAAS,IAAA;IACT,oBAAoB,IAAA;IACpB,SAAS,IAAA;IACT,UAAU,IAAA;IACV,iBAAiB,IAAA;CAClB;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,UAAU,eAAgB,SAAQ,YAAY;IAC5C,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,kBAAmB,SAAQ,YAAY;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,YAAY,GAAG,eAAe,GAAG,kBAAkB,CAAC;AAEzD,qBAAa,QAAS,SAAQ,KAAK;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;gBACjB,OAAO,EAAE,YAAY;IAkBjC,QAAQ,IAAI,MAAM;CAQnB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cie/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { type OnCieEvent, type OnError } from "./component";
|
2
|
-
export type ContinueWithUrl = (callbackUrl: string) => void;
|
3
|
-
export declare const startCieAndroid: (useCieUat: boolean, ciePin: string, onError: OnError, onEvent: OnCieEvent, cieAuthorizationUri: string, continueWithUrl: ContinueWithUrl) => void;
|
4
|
-
export declare const startCieiOS: (useCieUat: boolean, ciePin: string, onError: OnError, onEvent: OnCieEvent, cieAuthorizationUri: string, continueWithUrl: ContinueWithUrl) => Promise<void>;
|
5
|
-
//# sourceMappingURL=manager.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/cie/manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAKtE,MAAM,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;AAE5D,eAAO,MAAM,eAAe,cACf,OAAO,UACV,MAAM,WACL,OAAO,WACP,UAAU,uBACE,MAAM,mBACV,eAAe,SA6BjC,CAAC;AAEF,eAAO,MAAM,WAAW,cACX,OAAO,UACV,MAAM,WACL,OAAO,WACP,UAAU,uBACE,MAAM,mBACV,eAAe,kBA4BjC,CAAC"}
|
package/src/cie/README.md
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
# CIE
|
2
|
-
|
3
|
-
This library provides a components and a set of utilities to interact with the physical [CIE (Carta d'Identità Elettronica)](https://www.cartaidentita.interno.gov.it/) card. It can be used to [obtain an eID](../credential/issuance/README.md) via strong authentication.
|
4
|
-
Under the hood it uses [@pagopa/react-native-cie](https://github.com/pagopa/io-cie-sdk) to interact with the card and [react-native-webview](https://github.com/react-native-webview/react-native-webview) to complete the authorization flow.
|
5
|
-
|
6
|
-
An example of usage can be found in the [example](./example) folder of this repository.
|
package/src/cie/component.tsx
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
import React, { createRef } from "react";
|
2
|
-
import { Platform } from "react-native";
|
3
|
-
import { WebView } from "react-native-webview";
|
4
|
-
|
5
|
-
import type {
|
6
|
-
WebViewErrorEvent,
|
7
|
-
WebViewNavigationEvent,
|
8
|
-
WebViewMessageEvent,
|
9
|
-
WebViewNavigation,
|
10
|
-
WebViewHttpErrorEvent,
|
11
|
-
} from "react-native-webview/lib/WebViewTypes";
|
12
|
-
import { startCieAndroid, startCieiOS, type ContinueWithUrl } from "./manager";
|
13
|
-
import { CieError, CieErrorType } from "./error";
|
14
|
-
|
15
|
-
const AUTH_LINK_PATTERN = "lettura carta";
|
16
|
-
|
17
|
-
/* To obtain the authentication URL on CIE L3 it is necessary to take the
|
18
|
-
* link contained in the "Entra con lettura carta CIE" button.
|
19
|
-
* This link can then be used on CieManager.
|
20
|
-
* This javascript code takes the link in question and sends it to the react native function via postMessage
|
21
|
-
*/
|
22
|
-
const injectedJavaScript = `
|
23
|
-
(function() {
|
24
|
-
function sendDocumentContent() {
|
25
|
-
const idpAuthUrl = [...document.querySelectorAll("a")]
|
26
|
-
.filter(a => a.textContent.toLowerCase().includes("${AUTH_LINK_PATTERN}"))
|
27
|
-
.map(a=>a.href)[0];
|
28
|
-
|
29
|
-
if(idpAuthUrl) {
|
30
|
-
window.ReactNativeWebView.postMessage(idpAuthUrl);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
if (document.readyState === 'complete') {
|
34
|
-
sendDocumentContent();
|
35
|
-
} else {
|
36
|
-
window.addEventListener('load', sendDocumentContent);
|
37
|
-
}
|
38
|
-
})();
|
39
|
-
true;
|
40
|
-
`;
|
41
|
-
export type OnSuccess = (url: string) => void;
|
42
|
-
export type OnError = (e: CieError) => void;
|
43
|
-
export type OnCieEvent = (e: CieEvent) => void;
|
44
|
-
export enum CieEvent {
|
45
|
-
"reading" = "reading",
|
46
|
-
"completed" = "completed",
|
47
|
-
"waiting_card" = "waiting_card",
|
48
|
-
}
|
49
|
-
|
50
|
-
type CIEParams = {
|
51
|
-
authUrl: string;
|
52
|
-
onSuccess: OnSuccess;
|
53
|
-
onError: OnError;
|
54
|
-
pin: string;
|
55
|
-
useUat: boolean;
|
56
|
-
redirectUrl: string;
|
57
|
-
onEvent: OnCieEvent;
|
58
|
-
};
|
59
|
-
|
60
|
-
/*
|
61
|
-
* To make sure the server recognizes the client as valid iPhone device (iOS only) we use a custom header
|
62
|
-
* on Android it is not required.
|
63
|
-
*/
|
64
|
-
const iOSUserAgent =
|
65
|
-
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1";
|
66
|
-
const defaultUserAgent = Platform.select({
|
67
|
-
ios: iOSUserAgent,
|
68
|
-
default: undefined,
|
69
|
-
});
|
70
|
-
|
71
|
-
const webView = createRef<WebView>();
|
72
|
-
|
73
|
-
/**
|
74
|
-
* WebViewComponent
|
75
|
-
*
|
76
|
-
* Component that manages authentication via CIE L3 (NFC+PIN) based on WebView (react-native-webview).
|
77
|
-
* In particular, once rendered, it makes a series of calls to the authUrl in the WebView,
|
78
|
-
* extrapolates the authentication URL necessary for CieManager to sign via certificate
|
79
|
-
* and calls the CIE SDK which is responsible for starting card reading via NFC.
|
80
|
-
* At the end of the reading, a redirect is made in the WebView towards the page that asks
|
81
|
-
* the user for consent to send the data to the Service Provider. This moment can be captured
|
82
|
-
* via the onUserInteraction parameter. When the user allows or denies their consent,
|
83
|
-
* a redirect is made to the URL set by the Service Provider.
|
84
|
-
* This url can be configured using the redirectUrl parameter which allows you to close the WebView.
|
85
|
-
* The event can then be captured via the onSuccess parameter.
|
86
|
-
*
|
87
|
-
* @param {CIEParams} params - Parameters required by the component.
|
88
|
-
* @param {string} params.authUrl -The authentication URL of the Service Provider to which to authenticate.
|
89
|
-
* @param {boolean} params.useUat - If set to true it uses the CIE testing environment.
|
90
|
-
* @param {string} params.pin - CIE pin for use with NFC reading.
|
91
|
-
* @param {Function} params.onError - Callback function in case of error. The function is passed the Error parameter.
|
92
|
-
* @param {Function} params.onSuccess - Callback at the end of authentication to which the redirect URL including parameters is passed.
|
93
|
-
* @param {string} params.redirectUrl - Redirect URL set by the Service Provider. It is used to stop the flow and return to the calling function via onSuccess.
|
94
|
-
* @param {Function} params.onEvent - Callback function that is called whenever there is a new CieEvent from the CIE reader.
|
95
|
-
* @returns {JSX.Element} - The configured component with WebView.
|
96
|
-
*/
|
97
|
-
export const WebViewComponent = (params: CIEParams) => {
|
98
|
-
const [webViewUrl, setWebViewUrl] = React.useState(params.authUrl);
|
99
|
-
const [isCardReadingFinished, setCardReadingFinished] = React.useState(false);
|
100
|
-
|
101
|
-
/*
|
102
|
-
* Once the reading of the card with NFC is finished, it is necessary
|
103
|
-
* to change the URL of the WebView by redirecting to the URL returned by
|
104
|
-
* CieManager to allow the user to continue with the consent authorization
|
105
|
-
* */
|
106
|
-
const continueWithUrl: ContinueWithUrl = (callbackUrl: string) => {
|
107
|
-
setCardReadingFinished(true);
|
108
|
-
setWebViewUrl(callbackUrl);
|
109
|
-
};
|
110
|
-
|
111
|
-
// This function is called from the injected javascript code (postMessage). Which receives the authentication URL
|
112
|
-
const handleMessage = async (event: WebViewMessageEvent) => {
|
113
|
-
const cieAuthorizationUri = event.nativeEvent.data;
|
114
|
-
const startCie = Platform.select({
|
115
|
-
ios: startCieiOS,
|
116
|
-
default: startCieAndroid,
|
117
|
-
});
|
118
|
-
await startCie(
|
119
|
-
params.useUat,
|
120
|
-
params.pin,
|
121
|
-
params.onError,
|
122
|
-
params.onEvent,
|
123
|
-
cieAuthorizationUri,
|
124
|
-
continueWithUrl
|
125
|
-
);
|
126
|
-
};
|
127
|
-
|
128
|
-
//This function is called when authentication with CIE ends and the SP URL containing code and state is returned
|
129
|
-
const handleShouldStartLoading =
|
130
|
-
(onSuccess: OnSuccess, redirectUrl: string) =>
|
131
|
-
(event: WebViewNavigation): boolean => {
|
132
|
-
if (isCardReadingFinished && event.url.includes(redirectUrl)) {
|
133
|
-
onSuccess(event.url);
|
134
|
-
return false;
|
135
|
-
} else {
|
136
|
-
return true;
|
137
|
-
}
|
138
|
-
};
|
139
|
-
|
140
|
-
const handleOnLoadEnd =
|
141
|
-
(onError: OnError, onCieEvent: OnCieEvent) =>
|
142
|
-
(e: WebViewNavigationEvent | WebViewErrorEvent) => {
|
143
|
-
const eventTitle = e.nativeEvent.title.toLowerCase();
|
144
|
-
if (
|
145
|
-
eventTitle === "pagina web non disponibile" ||
|
146
|
-
// On Android, if we attempt to access the idp URL twice,
|
147
|
-
// we are presented with an error page titled "ERROR".
|
148
|
-
eventTitle === "errore"
|
149
|
-
) {
|
150
|
-
handleOnError(onError)(new Error(eventTitle));
|
151
|
-
}
|
152
|
-
|
153
|
-
/* At the end of loading the page, if the card has already been read
|
154
|
-
* then the WebView has loaded the page to ask the user for consent,
|
155
|
-
* so send the completed event
|
156
|
-
* */
|
157
|
-
if (isCardReadingFinished) {
|
158
|
-
onCieEvent(CieEvent.completed);
|
159
|
-
}
|
160
|
-
};
|
161
|
-
|
162
|
-
const handleOnError =
|
163
|
-
(onError: OnError) =>
|
164
|
-
(e: WebViewErrorEvent | WebViewHttpErrorEvent | Error): void => {
|
165
|
-
const error = e as Error;
|
166
|
-
const webViewError = e as WebViewErrorEvent;
|
167
|
-
const webViewHttpError = e as WebViewHttpErrorEvent;
|
168
|
-
if (webViewHttpError.nativeEvent.statusCode) {
|
169
|
-
const { description, statusCode } = webViewHttpError.nativeEvent;
|
170
|
-
onError(
|
171
|
-
new CieError({
|
172
|
-
message: `WebView http error: ${description} with status code: ${statusCode}`,
|
173
|
-
type: CieErrorType.WEB_VIEW_ERROR,
|
174
|
-
})
|
175
|
-
);
|
176
|
-
} else if (webViewError.nativeEvent) {
|
177
|
-
const { code, description } = webViewError.nativeEvent;
|
178
|
-
onError(
|
179
|
-
new CieError({
|
180
|
-
message: `WebView error: ${description} with code: ${code}`,
|
181
|
-
type: CieErrorType.WEB_VIEW_ERROR,
|
182
|
-
})
|
183
|
-
);
|
184
|
-
} else if (error.message !== undefined) {
|
185
|
-
onError(
|
186
|
-
new CieError({
|
187
|
-
message: `${error.message}`,
|
188
|
-
type: CieErrorType.WEB_VIEW_ERROR,
|
189
|
-
})
|
190
|
-
);
|
191
|
-
} else {
|
192
|
-
onError(
|
193
|
-
new CieError({
|
194
|
-
message: "An error occurred in the WebView",
|
195
|
-
type: CieErrorType.WEB_VIEW_ERROR,
|
196
|
-
})
|
197
|
-
);
|
198
|
-
}
|
199
|
-
};
|
200
|
-
|
201
|
-
return (
|
202
|
-
<WebView
|
203
|
-
ref={webView}
|
204
|
-
userAgent={defaultUserAgent}
|
205
|
-
javaScriptEnabled={true}
|
206
|
-
source={{ uri: webViewUrl }}
|
207
|
-
onLoadEnd={handleOnLoadEnd(params.onError, params.onEvent)}
|
208
|
-
onError={handleOnError(params.onError)}
|
209
|
-
onHttpError={handleOnError(params.onError)}
|
210
|
-
injectedJavaScript={injectedJavaScript}
|
211
|
-
onShouldStartLoadWithRequest={handleShouldStartLoading(
|
212
|
-
params.onSuccess,
|
213
|
-
params.redirectUrl
|
214
|
-
)}
|
215
|
-
onMessage={handleMessage}
|
216
|
-
/>
|
217
|
-
);
|
218
|
-
};
|
package/src/cie/error.ts
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
export enum CieErrorType {
|
2
|
-
GENERIC,
|
3
|
-
TAG_NOT_VALID,
|
4
|
-
WEB_VIEW_ERROR,
|
5
|
-
NFC_ERROR,
|
6
|
-
AUTHENTICATION_ERROR,
|
7
|
-
PIN_ERROR,
|
8
|
-
PIN_LOCKED,
|
9
|
-
CERTIFICATE_ERROR,
|
10
|
-
}
|
11
|
-
|
12
|
-
interface BaseCieError {
|
13
|
-
message: string;
|
14
|
-
type?: CieErrorType;
|
15
|
-
}
|
16
|
-
|
17
|
-
interface PinErrorOptions extends BaseCieError {
|
18
|
-
type: CieErrorType.PIN_ERROR;
|
19
|
-
attemptsLeft: number;
|
20
|
-
}
|
21
|
-
|
22
|
-
interface NonPinErrorOptions extends BaseCieError {
|
23
|
-
type?: Exclude<CieErrorType, CieErrorType.PIN_ERROR>;
|
24
|
-
attemptsLeft?: number;
|
25
|
-
}
|
26
|
-
|
27
|
-
type ErrorOptions = PinErrorOptions | NonPinErrorOptions;
|
28
|
-
|
29
|
-
export class CieError extends Error {
|
30
|
-
public type: CieErrorType;
|
31
|
-
public attemptsLeft?: number;
|
32
|
-
constructor(options: ErrorOptions) {
|
33
|
-
super(options.message);
|
34
|
-
|
35
|
-
if (options.type) {
|
36
|
-
this.type = options.type;
|
37
|
-
} else {
|
38
|
-
this.type = CieErrorType.GENERIC;
|
39
|
-
}
|
40
|
-
|
41
|
-
if (this.type === CieErrorType.PIN_ERROR) {
|
42
|
-
this.attemptsLeft = options.attemptsLeft;
|
43
|
-
} else if (this.type === CieErrorType.PIN_LOCKED) {
|
44
|
-
this.attemptsLeft = 0;
|
45
|
-
}
|
46
|
-
|
47
|
-
this.name = this.constructor.name;
|
48
|
-
}
|
49
|
-
|
50
|
-
toString(): string {
|
51
|
-
return JSON.stringify({
|
52
|
-
name: this.name,
|
53
|
-
type: CieErrorType[this.type],
|
54
|
-
message: this.message,
|
55
|
-
attemptsLeft: this.attemptsLeft,
|
56
|
-
});
|
57
|
-
}
|
58
|
-
}
|
package/src/cie/index.ts
DELETED