@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
@@ -1,183 +0,0 @@
1
- import cieManager, { type Event as CEvent } from "@pagopa/react-native-cie";
2
- import { Platform } from "react-native";
3
- import { CieEvent, type OnCieEvent, type OnError } from "./component";
4
- import { CieError, CieErrorType } from "./error";
5
-
6
- const BASE_UAT_URL = "https://collaudo.idserver.servizicie.interno.gov.it/idp/";
7
-
8
- export type ContinueWithUrl = (callbackUrl: string) => void;
9
-
10
- export const startCieAndroid = (
11
- useCieUat: boolean,
12
- ciePin: string,
13
- onError: OnError,
14
- onEvent: OnCieEvent,
15
- cieAuthorizationUri: string,
16
- continueWithUrl: ContinueWithUrl
17
- ) => {
18
- try {
19
- cieManager.removeAllListeners();
20
- cieManager
21
- .start()
22
- .then(async () => {
23
- cieManager.onEvent(handleCieEvent(onError, onEvent));
24
- cieManager.onError((e: Error) => {
25
- console.error(e);
26
- return onError(new CieError({ message: e.message }));
27
- });
28
- cieManager.onSuccess(handleCieSuccess(continueWithUrl));
29
- await cieManager.setPin(ciePin);
30
- cieManager.setAuthenticationUrl(cieAuthorizationUri);
31
- cieManager.enableLog(useCieUat);
32
- cieManager.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
33
- await cieManager.startListeningNFC();
34
- onEvent(CieEvent.waiting_card);
35
- })
36
- .catch(onError);
37
- } catch (e) {
38
- onError(
39
- new CieError({
40
- message: `Unable to start CIE NFC manager on Android: ${e}`,
41
- type: CieErrorType.NFC_ERROR,
42
- })
43
- );
44
- }
45
- };
46
-
47
- export const startCieiOS = async (
48
- useCieUat: boolean,
49
- ciePin: string,
50
- onError: OnError,
51
- onEvent: OnCieEvent,
52
- cieAuthorizationUri: string,
53
- continueWithUrl: ContinueWithUrl
54
- ) => {
55
- try {
56
- cieManager.removeAllListeners();
57
- cieManager.onEvent(handleCieEvent(onError, onEvent));
58
- cieManager.onError((e: Error) =>
59
- onError(new CieError({ message: e.message }))
60
- );
61
- cieManager.onSuccess(handleCieSuccess(continueWithUrl));
62
- cieManager.enableLog(useCieUat);
63
- cieManager.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
64
- await cieManager.setPin(ciePin);
65
- cieManager.setAuthenticationUrl(cieAuthorizationUri);
66
- cieManager
67
- .start()
68
- .then(async () => {
69
- await cieManager.startListeningNFC();
70
- onEvent(CieEvent.waiting_card);
71
- })
72
- .catch(onError);
73
- } catch (e) {
74
- onError(
75
- new CieError({
76
- message: `Unable to start CIE NFC manager on iOS: ${e}`,
77
- type: CieErrorType.NFC_ERROR,
78
- })
79
- );
80
- }
81
- };
82
-
83
- const handleCieEvent =
84
- (onError: OnError, onEvent: OnCieEvent) => (event: CEvent) => {
85
- switch (event.event) {
86
- // Reading starts
87
- case "ON_TAG_DISCOVERED":
88
- onEvent(CieEvent.reading);
89
- break;
90
- // "Function not supported" seems to be TAG_ERROR_NFC_NOT_SUPPORTED
91
- // for the iOS SDK
92
- case "Function not supported" as unknown:
93
- case "TAG_ERROR_NFC_NOT_SUPPORTED":
94
- case "ON_TAG_DISCOVERED_NOT_CIE":
95
- onError(
96
- new CieError({
97
- message: `Invalid CIE card: ${event.event}`,
98
- type: CieErrorType.TAG_NOT_VALID,
99
- })
100
- );
101
- break;
102
- case "AUTHENTICATION_ERROR":
103
- case "ON_NO_INTERNET_CONNECTION":
104
- onError(
105
- new CieError({
106
- message: `Authentication error or no internet connection`,
107
- type: CieErrorType.AUTHENTICATION_ERROR,
108
- })
109
- );
110
- break;
111
- case "EXTENDED_APDU_NOT_SUPPORTED":
112
- onError(
113
- new CieError({
114
- message: `APDU not supported`,
115
- type: CieErrorType.NFC_ERROR,
116
- })
117
- );
118
- break;
119
- case "Transmission Error":
120
- case "ON_TAG_LOST":
121
- onError(
122
- new CieError({
123
- message: `Trasmission error`,
124
- type: CieErrorType.NFC_ERROR,
125
- })
126
- );
127
- break;
128
-
129
- // The card is temporarily locked. Unlock is available by CieID app
130
- case "PIN Locked":
131
- case "ON_CARD_PIN_LOCKED":
132
- onError(
133
- new CieError({
134
- message: `PIN locked`,
135
- type: CieErrorType.PIN_LOCKED,
136
- })
137
- );
138
- break;
139
- case "ON_PIN_ERROR":
140
- onError(
141
- new CieError({
142
- message: `PIN locked`,
143
- type: CieErrorType.PIN_ERROR,
144
- attemptsLeft: event.attemptsLeft,
145
- })
146
- );
147
- break;
148
-
149
- // CIE is Expired or Revoked
150
- case "CERTIFICATE_EXPIRED":
151
- onError(
152
- new CieError({
153
- message: `Certificate expired`,
154
- type: CieErrorType.CERTIFICATE_ERROR,
155
- })
156
- );
157
- break;
158
- case "CERTIFICATE_REVOKED":
159
- onError(
160
- new CieError({
161
- message: `Certificate revoked`,
162
- type: CieErrorType.CERTIFICATE_ERROR,
163
- })
164
- );
165
-
166
- break;
167
-
168
- default:
169
- break;
170
- }
171
- };
172
-
173
- const handleCieSuccess =
174
- (continueWithUrl: ContinueWithUrl) => (url: string) => {
175
- continueWithUrl(decodeURIComponent(url));
176
- };
177
-
178
- const getCieUatEndpoint = () =>
179
- Platform.select({
180
- ios: `${BASE_UAT_URL}Authn/SSL/Login2`,
181
- android: BASE_UAT_URL,
182
- default: null,
183
- });