@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.
Files changed (98) hide show
  1. package/README.md +1 -35
  2. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +1 -1
  3. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +19 -57
  4. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/05-authorize-access.js +1 -0
  6. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/06-obtain-credential.js +1 -2
  8. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/errors.js +1 -18
  10. package/lib/commonjs/credential/issuance/errors.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/index.js +6 -0
  12. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  13. package/lib/commonjs/credential/status/02-status-attestation.js +2 -4
  14. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
  15. package/lib/commonjs/index.js +1 -3
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/utils/misc.js +19 -58
  18. package/lib/commonjs/utils/misc.js.map +1 -1
  19. package/lib/commonjs/wallet-instance-attestation/issuing.js +1 -2
  20. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  21. package/lib/module/credential/issuance/03-start-user-authorization.js +1 -1
  22. package/lib/module/credential/issuance/04-complete-user-authorization.js +19 -58
  23. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  24. package/lib/module/credential/issuance/05-authorize-access.js +1 -0
  25. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  26. package/lib/module/credential/issuance/06-obtain-credential.js +1 -2
  27. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  28. package/lib/module/credential/issuance/errors.js +0 -16
  29. package/lib/module/credential/issuance/errors.js.map +1 -1
  30. package/lib/module/credential/issuance/index.js +2 -2
  31. package/lib/module/credential/issuance/index.js.map +1 -1
  32. package/lib/module/credential/status/02-status-attestation.js +2 -4
  33. package/lib/module/credential/status/02-status-attestation.js.map +1 -1
  34. package/lib/module/index.js +1 -2
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/module/utils/misc.js +14 -51
  37. package/lib/module/utils/misc.js.map +1 -1
  38. package/lib/module/wallet-instance-attestation/issuing.js +1 -2
  39. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  40. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +1 -1
  41. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +16 -15
  42. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  43. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +1 -0
  44. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  45. package/lib/typescript/credential/issuance/errors.d.ts +0 -9
  46. package/lib/typescript/credential/issuance/errors.d.ts.map +1 -1
  47. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  48. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  49. package/lib/typescript/credential/status/02-status-attestation.d.ts +1 -2
  50. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
  51. package/lib/typescript/index.d.ts +1 -2
  52. package/lib/typescript/index.d.ts.map +1 -1
  53. package/lib/typescript/utils/misc.d.ts +5 -25
  54. package/lib/typescript/utils/misc.d.ts.map +1 -1
  55. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +2 -2
  56. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  57. package/package.json +2 -6
  58. package/src/credential/issuance/03-start-user-authorization.ts +1 -1
  59. package/src/credential/issuance/04-complete-user-authorization.ts +42 -103
  60. package/src/credential/issuance/05-authorize-access.ts +1 -0
  61. package/src/credential/issuance/06-obtain-credential.ts +1 -2
  62. package/src/credential/issuance/errors.ts +0 -15
  63. package/src/credential/issuance/index.ts +4 -0
  64. package/src/credential/status/02-status-attestation.ts +2 -4
  65. package/src/index.ts +0 -2
  66. package/src/utils/misc.ts +16 -63
  67. package/src/wallet-instance-attestation/issuing.ts +1 -2
  68. package/lib/commonjs/cie/README.md +0 -6
  69. package/lib/commonjs/cie/component.js +0 -182
  70. package/lib/commonjs/cie/component.js.map +0 -1
  71. package/lib/commonjs/cie/error.js +0 -44
  72. package/lib/commonjs/cie/error.js.map +0 -1
  73. package/lib/commonjs/cie/index.js +0 -32
  74. package/lib/commonjs/cie/index.js.map +0 -1
  75. package/lib/commonjs/cie/manager.js +0 -142
  76. package/lib/commonjs/cie/manager.js.map +0 -1
  77. package/lib/module/cie/README.md +0 -6
  78. package/lib/module/cie/component.js +0 -172
  79. package/lib/module/cie/component.js.map +0 -1
  80. package/lib/module/cie/error.js +0 -36
  81. package/lib/module/cie/error.js.map +0 -1
  82. package/lib/module/cie/index.js +0 -4
  83. package/lib/module/cie/index.js.map +0 -1
  84. package/lib/module/cie/manager.js +0 -133
  85. package/lib/module/cie/manager.js.map +0 -1
  86. package/lib/typescript/cie/component.d.ts +0 -46
  87. package/lib/typescript/cie/component.d.ts.map +0 -1
  88. package/lib/typescript/cie/error.d.ts +0 -31
  89. package/lib/typescript/cie/error.d.ts.map +0 -1
  90. package/lib/typescript/cie/index.d.ts +0 -4
  91. package/lib/typescript/cie/index.d.ts.map +0 -1
  92. package/lib/typescript/cie/manager.d.ts +0 -5
  93. package/lib/typescript/cie/manager.d.ts.map +0 -1
  94. package/src/cie/README.md +0 -6
  95. package/src/cie/component.tsx +0 -218
  96. package/src/cie/error.ts +0 -58
  97. package/src/cie/index.ts +0 -4
  98. package/src/cie/manager.ts +0 -183
@@ -72,8 +72,7 @@ export async function getAttestationRequest(
72
72
  * @param params.appFetch (optional) Http client
73
73
  * @param walletProviderBaseUrl Base url for the Wallet Provider
74
74
  * @returns The retrieved Wallet Instance Attestation token
75
- * @throws {WalletInstanceRevokedError} The Wallet Instance was revoked
76
- * @throws {WalletInstanceNotFoundError} The Wallet Instance does not exist
75
+ * @throws {WalletProviderResponseError} with a specific code for more context
77
76
  */
78
77
  export const getAttestation = async ({
79
78
  wiaCryptoContext,
@@ -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.
@@ -1,182 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WebViewComponent = exports.CieEvent = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _reactNativeWebview = require("react-native-webview");
10
- var _manager = require("./manager");
11
- var _error = require("./error");
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
- const AUTH_LINK_PATTERN = "lettura carta";
15
-
16
- /* To obtain the authentication URL on CIE L3 it is necessary to take the
17
- * link contained in the "Entra con lettura carta CIE" button.
18
- * This link can then be used on CieManager.
19
- * This javascript code takes the link in question and sends it to the react native function via postMessage
20
- */
21
- const injectedJavaScript = `
22
- (function() {
23
- function sendDocumentContent() {
24
- const idpAuthUrl = [...document.querySelectorAll("a")]
25
- .filter(a => a.textContent.toLowerCase().includes("${AUTH_LINK_PATTERN}"))
26
- .map(a=>a.href)[0];
27
-
28
- if(idpAuthUrl) {
29
- window.ReactNativeWebView.postMessage(idpAuthUrl);
30
- }
31
- }
32
- if (document.readyState === 'complete') {
33
- sendDocumentContent();
34
- } else {
35
- window.addEventListener('load', sendDocumentContent);
36
- }
37
- })();
38
- true;
39
- `;
40
- let CieEvent = /*#__PURE__*/function (CieEvent) {
41
- CieEvent["reading"] = "reading";
42
- CieEvent["completed"] = "completed";
43
- CieEvent["waiting_card"] = "waiting_card";
44
- return CieEvent;
45
- }({});
46
- exports.CieEvent = CieEvent;
47
- /*
48
- * To make sure the server recognizes the client as valid iPhone device (iOS only) we use a custom header
49
- * on Android it is not required.
50
- */
51
- const iOSUserAgent = "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";
52
- const defaultUserAgent = _reactNative.Platform.select({
53
- ios: iOSUserAgent,
54
- default: undefined
55
- });
56
- const webView = /*#__PURE__*/(0, _react.createRef)();
57
-
58
- /**
59
- * WebViewComponent
60
- *
61
- * Component that manages authentication via CIE L3 (NFC+PIN) based on WebView (react-native-webview).
62
- * In particular, once rendered, it makes a series of calls to the authUrl in the WebView,
63
- * extrapolates the authentication URL necessary for CieManager to sign via certificate
64
- * and calls the CIE SDK which is responsible for starting card reading via NFC.
65
- * At the end of the reading, a redirect is made in the WebView towards the page that asks
66
- * the user for consent to send the data to the Service Provider. This moment can be captured
67
- * via the onUserInteraction parameter. When the user allows or denies their consent,
68
- * a redirect is made to the URL set by the Service Provider.
69
- * This url can be configured using the redirectUrl parameter which allows you to close the WebView.
70
- * The event can then be captured via the onSuccess parameter.
71
- *
72
- * @param {CIEParams} params - Parameters required by the component.
73
- * @param {string} params.authUrl -The authentication URL of the Service Provider to which to authenticate.
74
- * @param {boolean} params.useUat - If set to true it uses the CIE testing environment.
75
- * @param {string} params.pin - CIE pin for use with NFC reading.
76
- * @param {Function} params.onError - Callback function in case of error. The function is passed the Error parameter.
77
- * @param {Function} params.onSuccess - Callback at the end of authentication to which the redirect URL including parameters is passed.
78
- * @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.
79
- * @param {Function} params.onEvent - Callback function that is called whenever there is a new CieEvent from the CIE reader.
80
- * @returns {JSX.Element} - The configured component with WebView.
81
- */
82
- const WebViewComponent = params => {
83
- const [webViewUrl, setWebViewUrl] = _react.default.useState(params.authUrl);
84
- const [isCardReadingFinished, setCardReadingFinished] = _react.default.useState(false);
85
-
86
- /*
87
- * Once the reading of the card with NFC is finished, it is necessary
88
- * to change the URL of the WebView by redirecting to the URL returned by
89
- * CieManager to allow the user to continue with the consent authorization
90
- * */
91
- const continueWithUrl = callbackUrl => {
92
- setCardReadingFinished(true);
93
- setWebViewUrl(callbackUrl);
94
- };
95
-
96
- // This function is called from the injected javascript code (postMessage). Which receives the authentication URL
97
- const handleMessage = async event => {
98
- const cieAuthorizationUri = event.nativeEvent.data;
99
- const startCie = _reactNative.Platform.select({
100
- ios: _manager.startCieiOS,
101
- default: _manager.startCieAndroid
102
- });
103
- await startCie(params.useUat, params.pin, params.onError, params.onEvent, cieAuthorizationUri, continueWithUrl);
104
- };
105
-
106
- //This function is called when authentication with CIE ends and the SP URL containing code and state is returned
107
- const handleShouldStartLoading = (onSuccess, redirectUrl) => event => {
108
- if (isCardReadingFinished && event.url.includes(redirectUrl)) {
109
- onSuccess(event.url);
110
- return false;
111
- } else {
112
- return true;
113
- }
114
- };
115
- const handleOnLoadEnd = (onError, onCieEvent) => e => {
116
- const eventTitle = e.nativeEvent.title.toLowerCase();
117
- if (eventTitle === "pagina web non disponibile" ||
118
- // On Android, if we attempt to access the idp URL twice,
119
- // we are presented with an error page titled "ERROR".
120
- eventTitle === "errore") {
121
- handleOnError(onError)(new Error(eventTitle));
122
- }
123
-
124
- /* At the end of loading the page, if the card has already been read
125
- * then the WebView has loaded the page to ask the user for consent,
126
- * so send the completed event
127
- * */
128
- if (isCardReadingFinished) {
129
- onCieEvent(CieEvent.completed);
130
- }
131
- };
132
- const handleOnError = onError => e => {
133
- const error = e;
134
- const webViewError = e;
135
- const webViewHttpError = e;
136
- if (webViewHttpError.nativeEvent.statusCode) {
137
- const {
138
- description,
139
- statusCode
140
- } = webViewHttpError.nativeEvent;
141
- onError(new _error.CieError({
142
- message: `WebView http error: ${description} with status code: ${statusCode}`,
143
- type: _error.CieErrorType.WEB_VIEW_ERROR
144
- }));
145
- } else if (webViewError.nativeEvent) {
146
- const {
147
- code,
148
- description
149
- } = webViewError.nativeEvent;
150
- onError(new _error.CieError({
151
- message: `WebView error: ${description} with code: ${code}`,
152
- type: _error.CieErrorType.WEB_VIEW_ERROR
153
- }));
154
- } else if (error.message !== undefined) {
155
- onError(new _error.CieError({
156
- message: `${error.message}`,
157
- type: _error.CieErrorType.WEB_VIEW_ERROR
158
- }));
159
- } else {
160
- onError(new _error.CieError({
161
- message: "An error occurred in the WebView",
162
- type: _error.CieErrorType.WEB_VIEW_ERROR
163
- }));
164
- }
165
- };
166
- return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
167
- ref: webView,
168
- userAgent: defaultUserAgent,
169
- javaScriptEnabled: true,
170
- source: {
171
- uri: webViewUrl
172
- },
173
- onLoadEnd: handleOnLoadEnd(params.onError, params.onEvent),
174
- onError: handleOnError(params.onError),
175
- onHttpError: handleOnError(params.onError),
176
- injectedJavaScript: injectedJavaScript,
177
- onShouldStartLoadWithRequest: handleShouldStartLoading(params.onSuccess, params.redirectUrl),
178
- onMessage: handleMessage
179
- });
180
- };
181
- exports.WebViewComponent = WebViewComponent;
182
- //# sourceMappingURL=component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_manager","_error","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AUTH_LINK_PATTERN","injectedJavaScript","CieEvent","exports","iOSUserAgent","defaultUserAgent","Platform","select","ios","undefined","webView","createRef","WebViewComponent","params","webViewUrl","setWebViewUrl","React","useState","authUrl","isCardReadingFinished","setCardReadingFinished","continueWithUrl","callbackUrl","handleMessage","event","cieAuthorizationUri","nativeEvent","data","startCie","startCieiOS","startCieAndroid","useUat","pin","onError","onEvent","handleShouldStartLoading","onSuccess","redirectUrl","url","includes","handleOnLoadEnd","onCieEvent","e","eventTitle","title","toLowerCase","handleOnError","Error","completed","error","webViewError","webViewHttpError","statusCode","description","CieError","message","type","CieErrorType","WEB_VIEW_ERROR","code","createElement","WebView","ref","userAgent","javaScriptEnabled","source","uri","onLoadEnd","onHttpError","onShouldStartLoadWithRequest","onMessage"],"sourceRoot":"../../../src","sources":["cie/component.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AASA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAiD,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AA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ACXC,OAAO,EAAG,kBAAiBF,WAAY,eAAcM,IAAK,EAAC;QAC3DH,IAAI,EAAEC,mBAAY,CAACC;MACrB,CAAC,CACH,CAAC;IACH,CAAC,MAAM,IAAIT,KAAK,CAACM,OAAO,KAAK9C,SAAS,EAAE;MACtCwB,OAAO,CACL,IAAIqB,eAAQ,CAAC;QACXC,OAAO,EAAG,GAAEN,KAAK,CAACM,OAAQ,EAAC;QAC3BC,IAAI,EAAEC,mBAAY,CAACC;MACrB,CAAC,CACH,CAAC;IACH,CAAC,MAAM;MACLzB,OAAO,CACL,IAAIqB,eAAQ,CAAC;QACXC,OAAO,EAAE,kCAAkC;QAC3CC,IAAI,EAAEC,mBAAY,CAACC;MACrB,CAAC,CACH,CAAC;IACH;EACF,CAAC;EAEH,oBACEvF,MAAA,CAAAc,OAAA,CAAA2E,aAAA,CAACrF,mBAAA,CAAAsF,OAAO;IACNC,GAAG,EAAEpD,OAAQ;IACbqD,SAAS,EAAE1D,gBAAiB;IAC5B2D,iBAAiB,EAAE,IAAK;IACxBC,MAAM,EAAE;MAAEC,GAAG,EAAEpD;IAAW,CAAE;IAC5BqD,SAAS,EAAE3B,eAAe,CAAC3B,MAAM,CAACoB,OAAO,EAAEpB,MAAM,CAACqB,OAAO,CAAE;IAC3DD,OAAO,EAAEa,aAAa,CAACjC,MAAM,CAACoB,OAAO,CAAE;IACvCmC,WAAW,EAAEtB,aAAa,CAACjC,MAAM,CAACoB,OAAO,CAAE;IAC3ChC,kBAAkB,EAAEA,kBAAmB;IACvCoE,4BAA4B,EAAElC,wBAAwB,CACpDtB,MAAM,CAACuB,SAAS,EAChBvB,MAAM,CAACwB,WACT,CAAE;IACFiC,SAAS,EAAE/C;EAAc,CAC1B,CAAC;AAEN,CAAC;AAACpB,OAAA,CAAAS,gBAAA,GAAAA,gBAAA"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CieErrorType = exports.CieError = void 0;
7
- let CieErrorType = /*#__PURE__*/function (CieErrorType) {
8
- CieErrorType[CieErrorType["GENERIC"] = 0] = "GENERIC";
9
- CieErrorType[CieErrorType["TAG_NOT_VALID"] = 1] = "TAG_NOT_VALID";
10
- CieErrorType[CieErrorType["WEB_VIEW_ERROR"] = 2] = "WEB_VIEW_ERROR";
11
- CieErrorType[CieErrorType["NFC_ERROR"] = 3] = "NFC_ERROR";
12
- CieErrorType[CieErrorType["AUTHENTICATION_ERROR"] = 4] = "AUTHENTICATION_ERROR";
13
- CieErrorType[CieErrorType["PIN_ERROR"] = 5] = "PIN_ERROR";
14
- CieErrorType[CieErrorType["PIN_LOCKED"] = 6] = "PIN_LOCKED";
15
- CieErrorType[CieErrorType["CERTIFICATE_ERROR"] = 7] = "CERTIFICATE_ERROR";
16
- return CieErrorType;
17
- }({});
18
- exports.CieErrorType = CieErrorType;
19
- class CieError extends Error {
20
- constructor(options) {
21
- super(options.message);
22
- if (options.type) {
23
- this.type = options.type;
24
- } else {
25
- this.type = CieErrorType.GENERIC;
26
- }
27
- if (this.type === CieErrorType.PIN_ERROR) {
28
- this.attemptsLeft = options.attemptsLeft;
29
- } else if (this.type === CieErrorType.PIN_LOCKED) {
30
- this.attemptsLeft = 0;
31
- }
32
- this.name = this.constructor.name;
33
- }
34
- toString() {
35
- return JSON.stringify({
36
- name: this.name,
37
- type: CieErrorType[this.type],
38
- message: this.message,
39
- attemptsLeft: this.attemptsLeft
40
- });
41
- }
42
- }
43
- exports.CieError = CieError;
44
- //# sourceMappingURL=error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CieErrorType","exports","CieError","Error","constructor","options","message","type","GENERIC","PIN_ERROR","attemptsLeft","PIN_LOCKED","name","toString","JSON","stringify"],"sourceRoot":"../../../src","sources":["cie/error.ts"],"mappings":";;;;;;IAAYA,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;AAAAC,OAAA,CAAAD,YAAA,GAAAA,YAAA;AA4BjB,MAAME,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,GAAGP,YAAY,CAACQ,OAAO;IAClC;IAEA,IAAI,IAAI,CAACD,IAAI,KAAKP,YAAY,CAACS,SAAS,EAAE;MACxC,IAAI,CAACC,YAAY,GAAGL,OAAO,CAACK,YAAY;IAC1C,CAAC,MAAM,IAAI,IAAI,CAACH,IAAI,KAAKP,YAAY,CAACW,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,EAAEP,YAAY,CAAC,IAAI,CAACO,IAAI,CAAC;MAC7BD,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBI,YAAY,EAAE,IAAI,CAACA;IACrB,CAAC,CAAC;EACJ;AACF;AAACT,OAAA,CAAAC,QAAA,GAAAA,QAAA"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "CieError", {
7
- enumerable: true,
8
- get: function () {
9
- return _error.CieError;
10
- }
11
- });
12
- Object.defineProperty(exports, "CieErrorType", {
13
- enumerable: true,
14
- get: function () {
15
- return _error.CieErrorType;
16
- }
17
- });
18
- Object.defineProperty(exports, "CieEvent", {
19
- enumerable: true,
20
- get: function () {
21
- return _component.CieEvent;
22
- }
23
- });
24
- Object.defineProperty(exports, "WebViewComponent", {
25
- enumerable: true,
26
- get: function () {
27
- return _component.WebViewComponent;
28
- }
29
- });
30
- var _component = require("./component");
31
- var _error = require("./error");
32
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_component","require","_error"],"sourceRoot":"../../../src","sources":["cie/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA"}
@@ -1,142 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.startCieiOS = exports.startCieAndroid = void 0;
7
- var _reactNativeCie = _interopRequireDefault(require("@pagopa/react-native-cie"));
8
- var _reactNative = require("react-native");
9
- var _component = require("./component");
10
- var _error = require("./error");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- const BASE_UAT_URL = "https://collaudo.idserver.servizicie.interno.gov.it/idp/";
13
- const startCieAndroid = (useCieUat, ciePin, onError, onEvent, cieAuthorizationUri, continueWithUrl) => {
14
- try {
15
- _reactNativeCie.default.removeAllListeners();
16
- _reactNativeCie.default.start().then(async () => {
17
- _reactNativeCie.default.onEvent(handleCieEvent(onError, onEvent));
18
- _reactNativeCie.default.onError(e => {
19
- console.error(e);
20
- return onError(new _error.CieError({
21
- message: e.message
22
- }));
23
- });
24
- _reactNativeCie.default.onSuccess(handleCieSuccess(continueWithUrl));
25
- await _reactNativeCie.default.setPin(ciePin);
26
- _reactNativeCie.default.setAuthenticationUrl(cieAuthorizationUri);
27
- _reactNativeCie.default.enableLog(useCieUat);
28
- _reactNativeCie.default.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
29
- await _reactNativeCie.default.startListeningNFC();
30
- onEvent(_component.CieEvent.waiting_card);
31
- }).catch(onError);
32
- } catch (e) {
33
- onError(new _error.CieError({
34
- message: `Unable to start CIE NFC manager on Android: ${e}`,
35
- type: _error.CieErrorType.NFC_ERROR
36
- }));
37
- }
38
- };
39
- exports.startCieAndroid = startCieAndroid;
40
- const startCieiOS = async (useCieUat, ciePin, onError, onEvent, cieAuthorizationUri, continueWithUrl) => {
41
- try {
42
- _reactNativeCie.default.removeAllListeners();
43
- _reactNativeCie.default.onEvent(handleCieEvent(onError, onEvent));
44
- _reactNativeCie.default.onError(e => onError(new _error.CieError({
45
- message: e.message
46
- })));
47
- _reactNativeCie.default.onSuccess(handleCieSuccess(continueWithUrl));
48
- _reactNativeCie.default.enableLog(useCieUat);
49
- _reactNativeCie.default.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
50
- await _reactNativeCie.default.setPin(ciePin);
51
- _reactNativeCie.default.setAuthenticationUrl(cieAuthorizationUri);
52
- _reactNativeCie.default.start().then(async () => {
53
- await _reactNativeCie.default.startListeningNFC();
54
- onEvent(_component.CieEvent.waiting_card);
55
- }).catch(onError);
56
- } catch (e) {
57
- onError(new _error.CieError({
58
- message: `Unable to start CIE NFC manager on iOS: ${e}`,
59
- type: _error.CieErrorType.NFC_ERROR
60
- }));
61
- }
62
- };
63
- exports.startCieiOS = startCieiOS;
64
- const handleCieEvent = (onError, onEvent) => event => {
65
- switch (event.event) {
66
- // Reading starts
67
- case "ON_TAG_DISCOVERED":
68
- onEvent(_component.CieEvent.reading);
69
- break;
70
- // "Function not supported" seems to be TAG_ERROR_NFC_NOT_SUPPORTED
71
- // for the iOS SDK
72
- case "Function not supported":
73
- case "TAG_ERROR_NFC_NOT_SUPPORTED":
74
- case "ON_TAG_DISCOVERED_NOT_CIE":
75
- onError(new _error.CieError({
76
- message: `Invalid CIE card: ${event.event}`,
77
- type: _error.CieErrorType.TAG_NOT_VALID
78
- }));
79
- break;
80
- case "AUTHENTICATION_ERROR":
81
- case "ON_NO_INTERNET_CONNECTION":
82
- onError(new _error.CieError({
83
- message: `Authentication error or no internet connection`,
84
- type: _error.CieErrorType.AUTHENTICATION_ERROR
85
- }));
86
- break;
87
- case "EXTENDED_APDU_NOT_SUPPORTED":
88
- onError(new _error.CieError({
89
- message: `APDU not supported`,
90
- type: _error.CieErrorType.NFC_ERROR
91
- }));
92
- break;
93
- case "Transmission Error":
94
- case "ON_TAG_LOST":
95
- onError(new _error.CieError({
96
- message: `Trasmission error`,
97
- type: _error.CieErrorType.NFC_ERROR
98
- }));
99
- break;
100
-
101
- // The card is temporarily locked. Unlock is available by CieID app
102
- case "PIN Locked":
103
- case "ON_CARD_PIN_LOCKED":
104
- onError(new _error.CieError({
105
- message: `PIN locked`,
106
- type: _error.CieErrorType.PIN_LOCKED
107
- }));
108
- break;
109
- case "ON_PIN_ERROR":
110
- onError(new _error.CieError({
111
- message: `PIN locked`,
112
- type: _error.CieErrorType.PIN_ERROR,
113
- attemptsLeft: event.attemptsLeft
114
- }));
115
- break;
116
-
117
- // CIE is Expired or Revoked
118
- case "CERTIFICATE_EXPIRED":
119
- onError(new _error.CieError({
120
- message: `Certificate expired`,
121
- type: _error.CieErrorType.CERTIFICATE_ERROR
122
- }));
123
- break;
124
- case "CERTIFICATE_REVOKED":
125
- onError(new _error.CieError({
126
- message: `Certificate revoked`,
127
- type: _error.CieErrorType.CERTIFICATE_ERROR
128
- }));
129
- break;
130
- default:
131
- break;
132
- }
133
- };
134
- const handleCieSuccess = continueWithUrl => url => {
135
- continueWithUrl(decodeURIComponent(url));
136
- };
137
- const getCieUatEndpoint = () => _reactNative.Platform.select({
138
- ios: `${BASE_UAT_URL}Authn/SSL/Login2`,
139
- android: BASE_UAT_URL,
140
- default: null
141
- });
142
- //# sourceMappingURL=manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNativeCie","_interopRequireDefault","require","_reactNative","_component","_error","obj","__esModule","default","BASE_UAT_URL","startCieAndroid","useCieUat","ciePin","onError","onEvent","cieAuthorizationUri","continueWithUrl","cieManager","removeAllListeners","start","then","handleCieEvent","e","console","error","CieError","message","onSuccess","handleCieSuccess","setPin","setAuthenticationUrl","enableLog","setCustomIdpUrl","getCieUatEndpoint","startListeningNFC","CieEvent","waiting_card","catch","type","CieErrorType","NFC_ERROR","exports","startCieiOS","event","reading","TAG_NOT_VALID","AUTHENTICATION_ERROR","PIN_LOCKED","PIN_ERROR","attemptsLeft","CERTIFICATE_ERROR","url","decodeURIComponent","Platform","select","ios","android"],"sourceRoot":"../../../src","sources":["cie/manager.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAiD,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjD,MAAMG,YAAY,GAAG,0DAA0D;AAIxE,MAAMC,eAAe,GAAGA,CAC7BC,SAAkB,EAClBC,MAAc,EACdC,OAAgB,EAChBC,OAAmB,EACnBC,mBAA2B,EAC3BC,eAAgC,KAC7B;EACH,IAAI;IACFC,uBAAU,CAACC,kBAAkB,CAAC,CAAC;IAC/BD,uBAAU,CACPE,KAAK,CAAC,CAAC,CACPC,IAAI,CAAC,YAAY;MAChBH,uBAAU,CAACH,OAAO,CAACO,cAAc,CAACR,OAAO,EAAEC,OAAO,CAAC,CAAC;MACpDG,uBAAU,CAACJ,OAAO,CAAES,CAAQ,IAAK;QAC/BC,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC;QAChB,OAAOT,OAAO,CAAC,IAAIY,eAAQ,CAAC;UAAEC,OAAO,EAAEJ,CAAC,CAACI;QAAQ,CAAC,CAAC,CAAC;MACtD,CAAC,CAAC;MACFT,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C"}
@@ -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.
@@ -1,172 +0,0 @@
1
- import React, { createRef } from "react";
2
- import { Platform } from "react-native";
3
- import { WebView } from "react-native-webview";
4
- import { startCieAndroid, startCieiOS } from "./manager";
5
- import { CieError, CieErrorType } from "./error";
6
- const AUTH_LINK_PATTERN = "lettura carta";
7
-
8
- /* To obtain the authentication URL on CIE L3 it is necessary to take the
9
- * link contained in the "Entra con lettura carta CIE" button.
10
- * This link can then be used on CieManager.
11
- * This javascript code takes the link in question and sends it to the react native function via postMessage
12
- */
13
- const injectedJavaScript = `
14
- (function() {
15
- function sendDocumentContent() {
16
- const idpAuthUrl = [...document.querySelectorAll("a")]
17
- .filter(a => a.textContent.toLowerCase().includes("${AUTH_LINK_PATTERN}"))
18
- .map(a=>a.href)[0];
19
-
20
- if(idpAuthUrl) {
21
- window.ReactNativeWebView.postMessage(idpAuthUrl);
22
- }
23
- }
24
- if (document.readyState === 'complete') {
25
- sendDocumentContent();
26
- } else {
27
- window.addEventListener('load', sendDocumentContent);
28
- }
29
- })();
30
- true;
31
- `;
32
- export let CieEvent = /*#__PURE__*/function (CieEvent) {
33
- CieEvent["reading"] = "reading";
34
- CieEvent["completed"] = "completed";
35
- CieEvent["waiting_card"] = "waiting_card";
36
- return CieEvent;
37
- }({});
38
- /*
39
- * To make sure the server recognizes the client as valid iPhone device (iOS only) we use a custom header
40
- * on Android it is not required.
41
- */
42
- const iOSUserAgent = "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";
43
- const defaultUserAgent = Platform.select({
44
- ios: iOSUserAgent,
45
- default: undefined
46
- });
47
- const webView = /*#__PURE__*/createRef();
48
-
49
- /**
50
- * WebViewComponent
51
- *
52
- * Component that manages authentication via CIE L3 (NFC+PIN) based on WebView (react-native-webview).
53
- * In particular, once rendered, it makes a series of calls to the authUrl in the WebView,
54
- * extrapolates the authentication URL necessary for CieManager to sign via certificate
55
- * and calls the CIE SDK which is responsible for starting card reading via NFC.
56
- * At the end of the reading, a redirect is made in the WebView towards the page that asks
57
- * the user for consent to send the data to the Service Provider. This moment can be captured
58
- * via the onUserInteraction parameter. When the user allows or denies their consent,
59
- * a redirect is made to the URL set by the Service Provider.
60
- * This url can be configured using the redirectUrl parameter which allows you to close the WebView.
61
- * The event can then be captured via the onSuccess parameter.
62
- *
63
- * @param {CIEParams} params - Parameters required by the component.
64
- * @param {string} params.authUrl -The authentication URL of the Service Provider to which to authenticate.
65
- * @param {boolean} params.useUat - If set to true it uses the CIE testing environment.
66
- * @param {string} params.pin - CIE pin for use with NFC reading.
67
- * @param {Function} params.onError - Callback function in case of error. The function is passed the Error parameter.
68
- * @param {Function} params.onSuccess - Callback at the end of authentication to which the redirect URL including parameters is passed.
69
- * @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.
70
- * @param {Function} params.onEvent - Callback function that is called whenever there is a new CieEvent from the CIE reader.
71
- * @returns {JSX.Element} - The configured component with WebView.
72
- */
73
- export const WebViewComponent = params => {
74
- const [webViewUrl, setWebViewUrl] = React.useState(params.authUrl);
75
- const [isCardReadingFinished, setCardReadingFinished] = React.useState(false);
76
-
77
- /*
78
- * Once the reading of the card with NFC is finished, it is necessary
79
- * to change the URL of the WebView by redirecting to the URL returned by
80
- * CieManager to allow the user to continue with the consent authorization
81
- * */
82
- const continueWithUrl = callbackUrl => {
83
- setCardReadingFinished(true);
84
- setWebViewUrl(callbackUrl);
85
- };
86
-
87
- // This function is called from the injected javascript code (postMessage). Which receives the authentication URL
88
- const handleMessage = async event => {
89
- const cieAuthorizationUri = event.nativeEvent.data;
90
- const startCie = Platform.select({
91
- ios: startCieiOS,
92
- default: startCieAndroid
93
- });
94
- await startCie(params.useUat, params.pin, params.onError, params.onEvent, cieAuthorizationUri, continueWithUrl);
95
- };
96
-
97
- //This function is called when authentication with CIE ends and the SP URL containing code and state is returned
98
- const handleShouldStartLoading = (onSuccess, redirectUrl) => event => {
99
- if (isCardReadingFinished && event.url.includes(redirectUrl)) {
100
- onSuccess(event.url);
101
- return false;
102
- } else {
103
- return true;
104
- }
105
- };
106
- const handleOnLoadEnd = (onError, onCieEvent) => e => {
107
- const eventTitle = e.nativeEvent.title.toLowerCase();
108
- if (eventTitle === "pagina web non disponibile" ||
109
- // On Android, if we attempt to access the idp URL twice,
110
- // we are presented with an error page titled "ERROR".
111
- eventTitle === "errore") {
112
- handleOnError(onError)(new Error(eventTitle));
113
- }
114
-
115
- /* At the end of loading the page, if the card has already been read
116
- * then the WebView has loaded the page to ask the user for consent,
117
- * so send the completed event
118
- * */
119
- if (isCardReadingFinished) {
120
- onCieEvent(CieEvent.completed);
121
- }
122
- };
123
- const handleOnError = onError => e => {
124
- const error = e;
125
- const webViewError = e;
126
- const webViewHttpError = e;
127
- if (webViewHttpError.nativeEvent.statusCode) {
128
- const {
129
- description,
130
- statusCode
131
- } = webViewHttpError.nativeEvent;
132
- onError(new CieError({
133
- message: `WebView http error: ${description} with status code: ${statusCode}`,
134
- type: CieErrorType.WEB_VIEW_ERROR
135
- }));
136
- } else if (webViewError.nativeEvent) {
137
- const {
138
- code,
139
- description
140
- } = webViewError.nativeEvent;
141
- onError(new CieError({
142
- message: `WebView error: ${description} with code: ${code}`,
143
- type: CieErrorType.WEB_VIEW_ERROR
144
- }));
145
- } else if (error.message !== undefined) {
146
- onError(new CieError({
147
- message: `${error.message}`,
148
- type: CieErrorType.WEB_VIEW_ERROR
149
- }));
150
- } else {
151
- onError(new CieError({
152
- message: "An error occurred in the WebView",
153
- type: CieErrorType.WEB_VIEW_ERROR
154
- }));
155
- }
156
- };
157
- return /*#__PURE__*/React.createElement(WebView, {
158
- ref: webView,
159
- userAgent: defaultUserAgent,
160
- javaScriptEnabled: true,
161
- source: {
162
- uri: webViewUrl
163
- },
164
- onLoadEnd: handleOnLoadEnd(params.onError, params.onEvent),
165
- onError: handleOnError(params.onError),
166
- onHttpError: handleOnError(params.onError),
167
- injectedJavaScript: injectedJavaScript,
168
- onShouldStartLoadWithRequest: handleShouldStartLoading(params.onSuccess, params.redirectUrl),
169
- onMessage: handleMessage
170
- });
171
- };
172
- //# sourceMappingURL=component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","createRef","Platform","WebView","startCieAndroid","startCieiOS","CieError","CieErrorType","AUTH_LINK_PATTERN","injectedJavaScript","CieEvent","iOSUserAgent","defaultUserAgent","select","ios","default","undefined","webView","WebViewComponent","params","webViewUrl","setWebViewUrl","useState","authUrl","isCardReadingFinished","setCardReadingFinished","continueWithUrl","callbackUrl","handleMessage","event","cieAuthorizationUri","nativeEvent","data","startCie","useUat","pin","onError","onEvent","handleShouldStartLoading","onSuccess","redirectUrl","url","includes","handleOnLoadEnd","onCieEvent","e","eventTitle","title","toLowerCase","handleOnError","Error","completed","error","webViewError","webViewHttpError","statusCode","description","message","type","WEB_VIEW_ERROR","code","createElement","ref","userAgent","javaScriptEnabled","source","uri","onLoadEnd","onHttpError","onShouldStartLoadWithRequest","onMessage"],"sourceRoot":"../../../src","sources":["cie/component.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,OAAO,QAAQ,sBAAsB;AAS9C,SAASC,eAAe,EAAEC,WAAW,QAA8B,WAAW;AAC9E,SAASC,QAAQ,EAAEC,YAAY,QAAQ,SAAS;AAEhD,MAAMC,iBAAiB,GAAG,eAAe;;AAEzC;AACA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