@pagopa/selfcare-common-frontend 1.34.14 → 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 +14 -3
- package/README.md +8 -2
- package/build.info +2 -2
- package/model/JwtUser.d.ts +8 -0
- package/model/JwtUser.js +3 -0
- package/model/JwtUser.js.map +1 -0
- package/package.json +1 -1
- package/utils/storage.d.ts +5 -0
- package/utils/storage.js +28 -1
- package/utils/storage.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,9 @@ 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.
|
|
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)
|
|
9
10
|
- [SELC-3936] feat: Created a method that return productTitle receiving productId [`#196`](https://github.com/pagopa/selfcare-common-frontend/pull/196)
|
|
10
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)
|
|
11
12
|
- [SELC-1712] feat: change footer link label of privacy policy [`#194`](https://github.com/pagopa/selfcare-common-frontend/pull/194)
|
|
@@ -19,6 +20,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
19
20
|
- SELC-2590 [`#186`](https://github.com/pagopa/selfcare-common-frontend/pull/186)
|
|
20
21
|
- SELC-2590 - update common [`#185`](https://github.com/pagopa/selfcare-common-frontend/pull/185)
|
|
21
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)
|
|
22
24
|
- Merge pull request #196 from pagopa/SELC-3936 [`#3936`](https://pagopa.atlassian.net/browse/3936) [`#3936`](https://pagopa.atlassian.net/browse/3936)
|
|
23
25
|
- [SELC-3936] feat: Added UnitTest [`#3936`](https://pagopa.atlassian.net/browse/3936)
|
|
24
26
|
- [SELC-3936] feat: Created a method that return productTitle receiving productId [`#3936`](https://pagopa.atlassian.net/browse/3936)
|
|
@@ -45,13 +47,22 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
45
47
|
- SELC-2590 - update common (#185) [`#2590`](https://pagopa.atlassian.net/browse/2590)
|
|
46
48
|
- SELC-2590 - update common [`#2590`](https://pagopa.atlassian.net/browse/2590)
|
|
47
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)
|
|
48
51
|
- Fixed broken unitTest [`d9bb4de`](https://github.com/pagopa/selfcare-common-frontend/commit/d9bb4deafebc474c7dfe475ca68bce898c762cfd)
|
|
49
|
-
- empty space [`8b39bc7`](https://github.com/pagopa/selfcare-common-frontend/commit/8b39bc7af38c4e8b916c257d39c9b54bd6120e9f)
|
|
50
52
|
|
|
51
|
-
#### [v1.35.0](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.
|
|
53
|
+
#### [v1.35.0](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.14...v1.35.0)
|
|
52
54
|
|
|
53
55
|
> 20 July 2023
|
|
54
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
|
+
|
|
55
66
|
#### [v1.34.13](https://github.com/pagopa/selfcare-common-frontend/compare/v1.34.12...v1.34.13)
|
|
56
67
|
|
|
57
68
|
> 20 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
|
-
|
|
2
|
-
tags/v1.29.0~1^2
|
|
1
|
+
20240318.2 - selfcare-common-frontend.deploy(148161)
|
|
2
|
+
tags/v1.29.0~1^2 fbb59b3ac21d7e68aa2d9d8c48927ad275be4ef5
|
package/model/JwtUser.js
ADDED
|
@@ -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.
|
|
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",
|
package/utils/storage.d.ts
CHANGED
|
@@ -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
|
package/utils/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/lib/utils/storage.ts"],"names":[],"mappings":";;;
|
|
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"}
|