@pagopa/selfcare-common-frontend 1.34.13 → 1.34.15

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/CHANGELOG.md CHANGED
@@ -4,8 +4,10 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- #### [v1.34.13](https://github.com/pagopa/selfcare-common-frontend/compare/v1.35.0...v1.34.13)
7
+ #### [v1.34.15](https://github.com/pagopa/selfcare-common-frontend/compare/v1.35.0...v1.34.15)
8
8
 
9
+ - [SELC-4521] feat: Added two new exportable utilities methods for storage managment: parseJwt and isExpiredToken [`#202`](https://github.com/pagopa/selfcare-common-frontend/pull/202)
10
+ - [SELC-3936] feat: Created a method that return productTitle receiving productId [`#196`](https://github.com/pagopa/selfcare-common-frontend/pull/196)
9
11
  - [SELC-3324] Updated React version from 17.0.2 to 18.0.2 + updated other project dependencies for ensure compatibility [`#195`](https://github.com/pagopa/selfcare-common-frontend/pull/195)
10
12
  - [SELC-1712] feat: change footer link label of privacy policy [`#194`](https://github.com/pagopa/selfcare-common-frontend/pull/194)
11
13
  - SELC-3242 Updated translations [`#193`](https://github.com/pagopa/selfcare-common-frontend/pull/193)
@@ -18,6 +20,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
18
20
  - SELC-2590 [`#186`](https://github.com/pagopa/selfcare-common-frontend/pull/186)
19
21
  - SELC-2590 - update common [`#185`](https://github.com/pagopa/selfcare-common-frontend/pull/185)
20
22
  - Used a environment variable to manage correct links in the footer based to product and actual environment [`#184`](https://github.com/pagopa/selfcare-common-frontend/pull/184)
23
+ - [SELC-4521] feat: Added two new exportable utilities methods for storage managment: parseJwt and isExpiredToken (#202) [`#4521`](https://pagopa.atlassian.net/browse/4521)
24
+ - Merge pull request #196 from pagopa/SELC-3936 [`#3936`](https://pagopa.atlassian.net/browse/3936) [`#3936`](https://pagopa.atlassian.net/browse/3936)
25
+ - [SELC-3936] feat: Added UnitTest [`#3936`](https://pagopa.atlassian.net/browse/3936)
26
+ - [SELC-3936] feat: Created a method that return productTitle receiving productId [`#3936`](https://pagopa.atlassian.net/browse/3936)
21
27
  - Merge pull request #195 from pagopa/SELC-3324 [`#3324`](https://pagopa.atlassian.net/browse/3324) [`#3324`](https://pagopa.atlassian.net/browse/3324)
22
28
  - [SELC-3324] Updated React testing library and Jest dependencies for ensure React v18 compatibility [`#3324`](https://pagopa.atlassian.net/browse/3324)
23
29
  - [SELC-3324 Updated mui-italia dependencies to v1.1.0 [`#3324`](https://pagopa.atlassian.net/browse/3324)
@@ -41,13 +47,32 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
41
47
  - SELC-2590 - update common (#185) [`#2590`](https://pagopa.atlassian.net/browse/2590)
42
48
  - SELC-2590 - update common [`#2590`](https://pagopa.atlassian.net/browse/2590)
43
49
  - Used a environment variable to manage correct links in the footer based to product and actual environment [`960e2fb`](https://github.com/pagopa/selfcare-common-frontend/commit/960e2fbaa8aa8f79061639b26dc1a27f28b8aae3)
50
+ - Update README.md [`a360cdb`](https://github.com/pagopa/selfcare-common-frontend/commit/a360cdbf86d7f5b7aa9df4aec586f76362e13e3a)
44
51
  - Fixed broken unitTest [`d9bb4de`](https://github.com/pagopa/selfcare-common-frontend/commit/d9bb4deafebc474c7dfe475ca68bce898c762cfd)
45
- - empty space [`8b39bc7`](https://github.com/pagopa/selfcare-common-frontend/commit/8b39bc7af38c4e8b916c257d39c9b54bd6120e9f)
46
52
 
47
- #### [v1.35.0](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.12...v1.35.0)
53
+ #### [v1.35.0](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.14...v1.35.0)
48
54
 
49
55
  > 20 July 2023
50
56
 
57
+ #### [v1.34.14](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.13...v1.34.14)
58
+
59
+ > 23 January 2024
60
+
61
+ - [SELC-3936] feat: Created a method that return productTitle receiving productId [`#196`](https://github.com/pagopa/selfcare-common-frontend/pull/196)
62
+ - Merge pull request #196 from pagopa/SELC-3936 [`#3936`](https://pagopa.atlassian.net/browse/3936) [`#3936`](https://pagopa.atlassian.net/browse/3936)
63
+ - [SELC-3936] feat: Added UnitTest [`#3936`](https://pagopa.atlassian.net/browse/3936)
64
+ - [SELC-3936] feat: Created a method that return productTitle receiving productId [`#3936`](https://pagopa.atlassian.net/browse/3936)
65
+
66
+ #### [v1.34.13](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.12...v1.34.13)
67
+
68
+ > 20 December 2023
69
+
70
+ - [SELC-3324] Updated React version from 17.0.2 to 18.0.2 + updated other project dependencies for ensure compatibility [`#195`](https://github.com/pagopa/selfcare-common-frontend/pull/195)
71
+ - Merge pull request #195 from pagopa/SELC-3324 [`#3324`](https://pagopa.atlassian.net/browse/3324) [`#3324`](https://pagopa.atlassian.net/browse/3324)
72
+ - [SELC-3324] Updated React testing library and Jest dependencies for ensure React v18 compatibility [`#3324`](https://pagopa.atlassian.net/browse/3324)
73
+ - [SELC-3324 Updated mui-italia dependencies to v1.1.0 [`#3324`](https://pagopa.atlassian.net/browse/3324)
74
+ - [SELC-3324] Updated React version from 17.0.2 to 18.0.2 + consequent update of other project dependencies [`#3324`](https://pagopa.atlassian.net/browse/3324)
75
+
51
76
  #### [v1.34.12](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.11...v1.34.12)
52
77
 
53
78
  > 13 December 2023
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SelfCare's common components & features
1
+ # SelfCare's common components & features
2
2
  This library contains [utilities](#utilities), [components](#components), [decorators](#decorators), [custom hooks](#custom-hooks) and [features](#features) built for the selfcare project.
3
3
 
4
4
  # Localization
@@ -243,6 +243,12 @@ An object containing a complete set of operation on the storage regarding the ke
243
243
  ### storageUserOps
244
244
  An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser in selfcare projects.
245
245
 
246
+ ## parseJwt
247
+ Decode and then convert the jwt into a JWTUser object
248
+
249
+ ## isExpiredToken
250
+ Determines whether the token has expired
251
+
246
252
  # Decorators
247
253
  ## withLogin
248
254
  This feature is based on react-redux library and require to register the reducer build in userSlice into the application's redux store.
@@ -420,4 +426,4 @@ The tool used is [OneTrust](#https://www.onetrust.it/), and in order to be able
420
426
 
421
427
  | Key | Type | Description | DefaultValue |
422
428
  |-----|------|-------------|--------------|
423
- | COOKIE_GROUP_ANALYTICS | string | The cookie group configured for the analytics tool. MixPanel's cookies are configured as default by OneTrust with C0004 group, or as Targeting Cookies | C0004 |
429
+ | COOKIE_GROUP_ANALYTICS | string | The cookie group configured for the analytics tool. MixPanel's cookies are configured as default by OneTrust with C0004 group, or as Targeting Cookies | C0004 |
package/build.info CHANGED
@@ -1,2 +1,2 @@
1
- 20231220.2 - selfcare-common-frontend.deploy(133835)
2
- tags/v1.29.0~1^2 b76cf732259281d5d993d0e8fc8f2af264e831b2
1
+ 20240318.2 - selfcare-common-frontend.deploy(148161)
2
+ tags/v1.29.0~1^2 fbb59b3ac21d7e68aa2d9d8c48927ad275be4ef5
@@ -0,0 +1,8 @@
1
+ export type JwtUser = {
2
+ uid: string;
3
+ fiscal_number: string;
4
+ name: string;
5
+ family_name: string;
6
+ email: string;
7
+ exp: string;
8
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=JwtUser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JwtUser.js","sourceRoot":"","sources":["../../src/lib/model/JwtUser.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagopa/selfcare-common-frontend",
3
3
  "description": "Shared React components for the pagopa selfcare project",
4
- "version": "1.34.13",
4
+ "version": "1.34.15",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/pagopa/selfcare-common-frontend",
7
7
  "author": "https://www.pagopa.gov.it",
@@ -0,0 +1 @@
1
+ export declare const productId2ProductTitle: (productId: string) => string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.productId2ProductTitle = void 0;
4
+ const productId2ProductTitle = (productId) => {
5
+ const productMap = {
6
+ 'prod-io': 'App IO',
7
+ 'prod-pn': 'SEND - Servizio Notifiche Digitali',
8
+ 'prod-interop': 'Interoperabilità',
9
+ 'prod-pagopa': 'Piattaforma pagoPA',
10
+ 'prod-idpay': 'IDPay',
11
+ 'prod-cgn': 'Carta Giovani',
12
+ 'prod-io-sign': 'Firma con IO',
13
+ 'prod-fd': 'Fideiussioni Digitali',
14
+ };
15
+ return productMap[productId];
16
+ };
17
+ exports.productId2ProductTitle = productId2ProductTitle;
18
+ //# sourceMappingURL=productId2ProductTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productId2ProductTitle.js","sourceRoot":"","sources":["../../src/lib/utils/productId2ProductTitle.tsx"],"names":[],"mappings":";;;AAAO,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC1D,MAAM,UAAU,GAAG;QACjB,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,oCAAoC;QAC/C,cAAc,EAAE,kBAAkB;QAClC,aAAa,EAAE,oBAAoB;QACnC,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,eAAe;QAC3B,cAAc,EAAE,cAAc;QAC9B,SAAS,EAAE,uBAAuB;KACnC,CAAC;IACF,OAAO,UAAU,CAAC,SAAoC,CAAC,CAAC;AAC1D,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC"}
@@ -1,5 +1,10 @@
1
1
  import { User } from '../model/User';
2
+ import { JwtUser } from '../model/JwtUser';
2
3
  /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser token in selfcare projects */
3
4
  export declare const storageTokenOps: import("./storage-utils").StorageOps<string>;
4
5
  /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser in selfcare projects */
5
6
  export declare const storageUserOps: import("./storage-utils").StorageOps<User>;
7
+ /** Decode and then convert the jwt into a JWTUser object */
8
+ export declare const parseJwt: (token: string) => JwtUser | null;
9
+ /** Determines whether the token has expired */
10
+ export declare const isExpiredToken: (token: string) => boolean;
package/utils/storage.js CHANGED
@@ -1,9 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storageUserOps = exports.storageTokenOps = void 0;
3
+ exports.isExpiredToken = exports.parseJwt = exports.storageUserOps = exports.storageTokenOps = void 0;
4
4
  const storage_utils_1 = require("./storage-utils");
5
5
  /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser token in selfcare projects */
6
6
  exports.storageTokenOps = (0, storage_utils_1.storageOpsBuilder)('token', 'string', true);
7
7
  /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser in selfcare projects */
8
8
  exports.storageUserOps = (0, storage_utils_1.storageOpsBuilder)('user', 'object', true);
9
+ function decodeUTF8(binary) {
10
+ const bytes = new Uint8Array(binary.length);
11
+ // eslint-disable-next-line functional/no-let
12
+ for (let b = 0; b < bytes.length; ++b) {
13
+ // eslint-disable-next-line functional/immutable-data
14
+ bytes[b] = binary.charCodeAt(b);
15
+ }
16
+ const decoder = new TextDecoder('utf-8');
17
+ return decoder.decode(bytes);
18
+ }
19
+ /** Decode and then convert the jwt into a JWTUser object */
20
+ const parseJwt = (token) => {
21
+ try {
22
+ return JSON.parse(decodeUTF8(atob(token.split('.')[1])));
23
+ }
24
+ catch (e) {
25
+ return null;
26
+ }
27
+ };
28
+ exports.parseJwt = parseJwt;
29
+ /** Determines whether the token has expired */
30
+ const isExpiredToken = (token) => {
31
+ const jwtUser = (0, exports.parseJwt)(token);
32
+ const tokenExpDate = new Date(Number(jwtUser.exp) * 1000);
33
+ return new Date() >= tokenExpDate;
34
+ };
35
+ exports.isExpiredToken = isExpiredToken;
9
36
  //# sourceMappingURL=storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/lib/utils/storage.ts"],"names":[],"mappings":";;;AACA,mDAAoD;AAEpD,+JAA+J;AAClJ,QAAA,eAAe,GAAG,IAAA,iCAAiB,EAAS,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAClF,yJAAyJ;AAC5I,QAAA,cAAc,GAAG,IAAA,iCAAiB,EAAO,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/lib/utils/storage.ts"],"names":[],"mappings":";;;AAEA,mDAAoD;AAEpD,+JAA+J;AAClJ,QAAA,eAAe,GAAG,IAAA,iCAAiB,EAAS,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAClF,yJAAyJ;AAC5I,QAAA,cAAc,GAAG,IAAA,iCAAiB,EAAO,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAE9E,SAAS,UAAU,CAAC,MAAc;IAChC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,6CAA6C;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACrC,qDAAqD;QACrD,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KACjC;IACD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,4DAA4D;AACrD,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAY,CAAC;KACrE;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC,CAAC;AANW,QAAA,QAAQ,YAMnB;AAEF,+CAA+C;AACxC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IAC9C,MAAM,OAAO,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAY,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAE1D,OAAO,IAAI,IAAI,EAAE,IAAI,YAAY,CAAC;AACpC,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB"}