passbolt-styleguide 5.14.0-alpha.6 → 5.14.0-alpha.7
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/build/css/help.min.css +1 -1
- package/build/css/public.min.css +1 -1
- package/build/css/themes/default/api_authentication.min.css +1 -1
- package/build/css/themes/default/api_cloud.min.css +1 -1
- package/build/css/themes/default/api_main.min.css +1 -1
- package/build/css/themes/default/api_reports.min.css +1 -1
- package/build/css/themes/default/api_webinstaller.min.css +1 -1
- package/build/css/themes/default/ext_app.min.css +1 -1
- package/build/css/themes/default/ext_authentication.min.css +1 -1
- package/build/css/themes/default/ext_external.min.css +1 -1
- package/build/css/themes/default/ext_in_form_cta.min.css +1 -1
- package/build/css/themes/default/ext_in_form_menu.min.css +1 -1
- package/build/css/themes/default/ext_quickaccess.min.css +1 -1
- package/build/css/themes/midgar/api_authentication.min.css +1 -1
- package/build/css/themes/midgar/api_main.min.css +1 -1
- package/build/css/themes/midgar/api_reports.min.css +1 -1
- package/build/css/themes/midgar/ext_app.min.css +1 -1
- package/build/css/themes/midgar/ext_authentication.min.css +1 -1
- package/build/css/themes/midgar/ext_in_form_cta.min.css +1 -1
- package/build/css/themes/midgar/ext_in_form_menu.min.css +1 -1
- package/build/css/themes/midgar/ext_quickaccess.min.css +1 -1
- package/build/css/themes/solarized_dark/api_authentication.min.css +1 -1
- package/build/css/themes/solarized_dark/api_main.min.css +1 -1
- package/build/css/themes/solarized_dark/api_reports.min.css +1 -1
- package/build/css/themes/solarized_dark/ext_app.min.css +1 -1
- package/build/css/themes/solarized_dark/ext_authentication.min.css +1 -1
- package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +1 -1
- package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +1 -1
- package/build/css/themes/solarized_dark/ext_quickaccess.min.css +1 -1
- package/build/css/themes/solarized_light/api_authentication.min.css +1 -1
- package/build/css/themes/solarized_light/api_main.min.css +1 -1
- package/build/css/themes/solarized_light/api_reports.min.css +1 -1
- package/build/css/themes/solarized_light/ext_app.min.css +1 -1
- package/build/css/themes/solarized_light/ext_authentication.min.css +1 -1
- package/build/css/themes/solarized_light/ext_in_form_cta.min.css +1 -1
- package/build/css/themes/solarized_light/ext_in_form_menu.min.css +1 -1
- package/build/css/themes/solarized_light/ext_quickaccess.min.css +1 -1
- package/package.json +1 -1
- package/src/react-extension/components/Resource/DisplayResourcesList/DisplayResourcesListContextualMenu.js +1 -1
- package/src/react-extension/components/Resource/DisplayResourcesWorkspace/DisplayResourcesWorkspaceMenu.js +1 -1
- package/src/react-quickaccess/ExtQuickAccess.js +2 -2
- package/src/shared/models/entity/session/userActiveSessionEntity.js +183 -0
- package/src/shared/models/entity/session/{onlineSessionEntity.test.data.js → userActiveSessionEntity.test.data.js} +10 -4
- package/src/shared/models/entity/session/userActiveSessionEntity.test.js +194 -0
- package/src/shared/services/serviceWorker/offline/offlineModeServiceWorkerService.js +6 -5
- package/src/shared/services/serviceWorker/offline/offlineModeServiceWorkerService.test.js +5 -5
- package/src/shared/models/entity/session/onlineSessionEntity.js +0 -73
- package/src/shared/models/entity/session/onlineSessionEntity.test.js +0 -91
package/build/css/help.min.css
CHANGED
package/build/css/public.min.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passbolt-styleguide",
|
|
3
|
-
"version": "5.14.0-alpha.
|
|
3
|
+
"version": "5.14.0-alpha.7",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"copyright": "Copyright 2023 Passbolt SA",
|
|
6
6
|
"description": "Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.",
|
|
@@ -344,7 +344,7 @@ class DisplayResourcesListContextualMenu extends React.Component {
|
|
|
344
344
|
const isAvailableOffline = Boolean(this.resource.offline);
|
|
345
345
|
try {
|
|
346
346
|
if (isAvailableOffline) {
|
|
347
|
-
await this.offlineModeServiceWorkerService.unmarkItem(this.resource.id);
|
|
347
|
+
await this.offlineModeServiceWorkerService.unmarkItem(this.resource.offline.id);
|
|
348
348
|
await this.props.actionFeedbackContext.displaySuccess(
|
|
349
349
|
this.translate("The resource is no longer available offline."),
|
|
350
350
|
);
|
|
@@ -144,7 +144,7 @@ class DisplayResourcesWorkspaceMenu extends React.Component {
|
|
|
144
144
|
const isAvailableOffline = Boolean(resource.offline);
|
|
145
145
|
try {
|
|
146
146
|
if (isAvailableOffline) {
|
|
147
|
-
await this.offlineModeServiceWorkerService.unmarkItem(resource.id);
|
|
147
|
+
await this.offlineModeServiceWorkerService.unmarkItem(resource.offline.id);
|
|
148
148
|
await this.props.actionFeedbackContext.displaySuccess(
|
|
149
149
|
this.translate("The resource is no longer available offline."),
|
|
150
150
|
);
|
|
@@ -42,7 +42,7 @@ import MetadataTrustedKeyEntity from "../shared/models/entity/metadata/metadataT
|
|
|
42
42
|
import MetadataKeysSettingsLocalStorageContextProvider from "../shared/context/MetadataKeysSettingsLocalStorageContext/MetadataKeysSettingsLocalStorageContext";
|
|
43
43
|
import ActionAbortedMissingMetadataKeysPage from "./components/ActionAbortedMissingMetadataKeysPage/ActionAbortedMissingMetadataKeysPage";
|
|
44
44
|
import RbacServiceWorkerService from "../shared/services/serviceWorker/rbac/rbacServiceWorkerService";
|
|
45
|
-
import
|
|
45
|
+
import UserActiveSessionEntity from "../shared/models/entity/session/userActiveSessionEntity";
|
|
46
46
|
import OfflineSettingsLocalStorageContextProvider from "../shared/context/offline/OfflineSettingsLocalStorageContext";
|
|
47
47
|
|
|
48
48
|
const SEARCH_VISIBLE_ROUTES = [
|
|
@@ -292,7 +292,7 @@ class ExtQuickAccess extends React.Component {
|
|
|
292
292
|
*/
|
|
293
293
|
async checkAuthStatus() {
|
|
294
294
|
const activeSession = await this.state.port.request("passbolt.auth.check-status");
|
|
295
|
-
const activeSessionEntity = new
|
|
295
|
+
const activeSessionEntity = new UserActiveSessionEntity(activeSession);
|
|
296
296
|
if (!activeSessionEntity.isMfaAuthenticated) {
|
|
297
297
|
await this.redirectToMfaAuthentication();
|
|
298
298
|
return;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.13.0
|
|
13
|
+
*/
|
|
14
|
+
import EntityV2 from "../abstract/entityV2";
|
|
15
|
+
import EntitySchema from "../abstract/entitySchema";
|
|
16
|
+
|
|
17
|
+
export const USER_ACTIVE_SESSION_ONLINE = "online";
|
|
18
|
+
export const USER_ACTIVE_SESSION_OFFLINE = "offline";
|
|
19
|
+
|
|
20
|
+
const SUPPORTED_USER_ACTIVE_SESSION_TYPES = [USER_ACTIVE_SESSION_ONLINE, USER_ACTIVE_SESSION_OFFLINE];
|
|
21
|
+
|
|
22
|
+
class UserActiveSessionEntity extends EntityV2 {
|
|
23
|
+
/**
|
|
24
|
+
* Get online session entity schema
|
|
25
|
+
* @returns {object} schema
|
|
26
|
+
*/
|
|
27
|
+
static getSchema() {
|
|
28
|
+
return {
|
|
29
|
+
type: "object",
|
|
30
|
+
required: ["is_authenticated", "type"],
|
|
31
|
+
properties: {
|
|
32
|
+
is_authenticated: {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
format: "uuid",
|
|
35
|
+
},
|
|
36
|
+
is_mfa_authenticated: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
format: "uuid",
|
|
39
|
+
},
|
|
40
|
+
is_server_reachable: {
|
|
41
|
+
type: "boolean",
|
|
42
|
+
format: "uuid",
|
|
43
|
+
},
|
|
44
|
+
type: {
|
|
45
|
+
type: "string",
|
|
46
|
+
enum: SUPPORTED_USER_ACTIVE_SESSION_TYPES,
|
|
47
|
+
},
|
|
48
|
+
last_logged_in: {
|
|
49
|
+
type: "string",
|
|
50
|
+
format: "date-time",
|
|
51
|
+
},
|
|
52
|
+
last_seen_online: {
|
|
53
|
+
type: "string",
|
|
54
|
+
format: "date-time",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* ==================================================
|
|
62
|
+
* Dynamic properties getters
|
|
63
|
+
* ==================================================
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get the is authenticated
|
|
68
|
+
* @returns {boolean}
|
|
69
|
+
*/
|
|
70
|
+
get isAuthenticated() {
|
|
71
|
+
return this._props.is_authenticated;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the is mfa authenticated
|
|
76
|
+
* @returns {boolean}
|
|
77
|
+
*/
|
|
78
|
+
get isMfaAuthenticated() {
|
|
79
|
+
return this._props.is_mfa_authenticated;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get the is server reachable
|
|
84
|
+
* @returns {boolean}
|
|
85
|
+
*/
|
|
86
|
+
get isServerReachable() {
|
|
87
|
+
return this._props.is_server_reachable;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the active session type
|
|
92
|
+
* @returns {string}
|
|
93
|
+
*/
|
|
94
|
+
get type() {
|
|
95
|
+
return this._props.type;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get the last online logged in date
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
get lastLoggedIn() {
|
|
103
|
+
return this._props.last_logged_in;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get the last seen online date
|
|
108
|
+
* @returns {string}
|
|
109
|
+
*/
|
|
110
|
+
get lastSeenOnline() {
|
|
111
|
+
return this._props.last_seen_online;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* ==================================================
|
|
116
|
+
* Dynamic properties setters
|
|
117
|
+
* ==================================================
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Set the is authenticated
|
|
122
|
+
* @param {boolean} isAuthenticated
|
|
123
|
+
*/
|
|
124
|
+
set isAuthenticated(isAuthenticated) {
|
|
125
|
+
EntitySchema.validateProp("is_authenticated", isAuthenticated, this.cachedSchema.properties.is_authenticated);
|
|
126
|
+
this._props.is_authenticated = isAuthenticated;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Set the is mfa authenticated
|
|
131
|
+
* @param {boolean} isMfaAuthenticated
|
|
132
|
+
*/
|
|
133
|
+
set isMfaAuthenticated(isMfaAuthenticated) {
|
|
134
|
+
EntitySchema.validateProp(
|
|
135
|
+
"is_mfa_authenticated",
|
|
136
|
+
isMfaAuthenticated,
|
|
137
|
+
this.cachedSchema.properties.is_mfa_authenticated,
|
|
138
|
+
);
|
|
139
|
+
this._props.is_mfa_authenticated = isMfaAuthenticated;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Set the is server reachable
|
|
144
|
+
* @param {boolean} isServerReachable
|
|
145
|
+
*/
|
|
146
|
+
set isServerReachable(isServerReachable) {
|
|
147
|
+
EntitySchema.validateProp(
|
|
148
|
+
"is_server_reachable",
|
|
149
|
+
isServerReachable,
|
|
150
|
+
this.cachedSchema.properties.is_server_reachable,
|
|
151
|
+
);
|
|
152
|
+
this._props.is_server_reachable = isServerReachable;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Set the active session type
|
|
157
|
+
* @param {string} type
|
|
158
|
+
*/
|
|
159
|
+
set type(type) {
|
|
160
|
+
EntitySchema.validateProp("type", type, this.cachedSchema.properties.type);
|
|
161
|
+
this._props.type = type;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Set the last logged in date
|
|
166
|
+
* @param {string} date
|
|
167
|
+
*/
|
|
168
|
+
set lastLoggedIn(date) {
|
|
169
|
+
EntitySchema.validateProp("last_logged_in", date, this.cachedSchema.properties.last_logged_in);
|
|
170
|
+
this._props.last_logged_in = date;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Set the last seen online date
|
|
175
|
+
* @param {string} date
|
|
176
|
+
*/
|
|
177
|
+
set lastSeenOnline(date) {
|
|
178
|
+
EntitySchema.validateProp("last_seen_online", date, this.cachedSchema.properties.last_seen_online);
|
|
179
|
+
this._props.last_seen_online = date;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export default UserActiveSessionEntity;
|
|
@@ -12,13 +12,16 @@
|
|
|
12
12
|
* @since 5.13.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { USER_ACTIVE_SESSION_ONLINE } from "./userActiveSessionEntity";
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
|
-
* Build minimal
|
|
18
|
+
* Build minimal user active session.
|
|
17
19
|
* @param {object} [data={}] Data to override
|
|
18
20
|
* @returns {object}
|
|
19
21
|
*/
|
|
20
|
-
export const
|
|
22
|
+
export const minimalUserActiveSessionDto = (data = {}) => ({
|
|
21
23
|
is_authenticated: true,
|
|
24
|
+
type: USER_ACTIVE_SESSION_ONLINE,
|
|
22
25
|
...data,
|
|
23
26
|
});
|
|
24
27
|
|
|
@@ -27,9 +30,12 @@ export const minimalOnlineSessionDto = (data = {}) => ({
|
|
|
27
30
|
* @param {object} [data={}] Data to override
|
|
28
31
|
* @returns {object}
|
|
29
32
|
*/
|
|
30
|
-
export const
|
|
33
|
+
export const defaultUserActiveSessionDto = (data = {}) => ({
|
|
31
34
|
is_authenticated: true,
|
|
32
35
|
is_mfa_authenticated: true,
|
|
33
|
-
|
|
36
|
+
is_server_reachable: true,
|
|
37
|
+
type: USER_ACTIVE_SESSION_ONLINE,
|
|
38
|
+
last_logged_in: "2025-08-04T18:58:11+00:00",
|
|
39
|
+
last_seen_online: "2025-08-04T18:59:11+00:00",
|
|
34
40
|
...data,
|
|
35
41
|
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passbolt ~ Open source password manager for teams
|
|
3
|
+
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
+
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
+
* Redistributions of files must retain the above copyright notice.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
+
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
+
* @since 5.13.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import EntitySchema from "../abstract/entitySchema";
|
|
16
|
+
import * as assertEntityProperty from "../../../../../test/assert/assertEntityProperty";
|
|
17
|
+
import UserActiveSessionEntity, {
|
|
18
|
+
USER_ACTIVE_SESSION_OFFLINE,
|
|
19
|
+
USER_ACTIVE_SESSION_ONLINE,
|
|
20
|
+
} from "./userActiveSessionEntity";
|
|
21
|
+
import { defaultUserActiveSessionDto, minimalUserActiveSessionDto } from "./userActiveSessionEntity.test.data";
|
|
22
|
+
|
|
23
|
+
describe("UserActiveSession", () => {
|
|
24
|
+
describe("::getSchema", () => {
|
|
25
|
+
it("schema must validate", () => {
|
|
26
|
+
EntitySchema.validateSchema(UserActiveSessionEntity.name, UserActiveSessionEntity.getSchema());
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("validates is_authenticated property", () => {
|
|
30
|
+
assertEntityProperty.boolean(UserActiveSessionEntity, "is_authenticated");
|
|
31
|
+
assertEntityProperty.required(UserActiveSessionEntity, "is_authenticated");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("validates is_mfa_authenticated property", () => {
|
|
35
|
+
assertEntityProperty.boolean(UserActiveSessionEntity, "is_mfa_authenticated");
|
|
36
|
+
assertEntityProperty.notRequired(UserActiveSessionEntity, "is_mfa_authenticated");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("validates is_server_reachable property", () => {
|
|
40
|
+
assertEntityProperty.boolean(UserActiveSessionEntity, "is_server_reachable");
|
|
41
|
+
assertEntityProperty.notRequired(UserActiveSessionEntity, "is_server_reachable");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("validates type property", () => {
|
|
45
|
+
assertEntityProperty.string(UserActiveSessionEntity, "type");
|
|
46
|
+
const expectedValues = ["online", "offline"];
|
|
47
|
+
const unexpectedValues = ["1", "false", "test"];
|
|
48
|
+
assertEntityProperty.enumeration(UserActiveSessionEntity, "type", expectedValues, unexpectedValues);
|
|
49
|
+
assertEntityProperty.required(UserActiveSessionEntity, "type");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("validates last_logged_in property", () => {
|
|
53
|
+
assertEntityProperty.string(UserActiveSessionEntity, "last_logged_in");
|
|
54
|
+
assertEntityProperty.dateTime(UserActiveSessionEntity, "last_logged_in");
|
|
55
|
+
assertEntityProperty.notRequired(UserActiveSessionEntity, "last_logged_in");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("validates last_seen_online property", () => {
|
|
59
|
+
assertEntityProperty.string(UserActiveSessionEntity, "last_seen_online");
|
|
60
|
+
assertEntityProperty.dateTime(UserActiveSessionEntity, "last_seen_online");
|
|
61
|
+
assertEntityProperty.notRequired(UserActiveSessionEntity, "last_seen_online");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe("::constructor", () => {
|
|
66
|
+
it("constructor works if minimal dto is provided.", () => {
|
|
67
|
+
expect.assertions(2);
|
|
68
|
+
const dto = minimalUserActiveSessionDto();
|
|
69
|
+
const entity = new UserActiveSessionEntity(dto);
|
|
70
|
+
|
|
71
|
+
expect(entity._props.is_authenticated).toStrictEqual(dto.is_authenticated);
|
|
72
|
+
expect(entity._props.type).toStrictEqual(dto.type);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("constructor works if valid DTO is provided", () => {
|
|
76
|
+
expect.assertions(6);
|
|
77
|
+
const dto = defaultUserActiveSessionDto();
|
|
78
|
+
const entity = new UserActiveSessionEntity(dto);
|
|
79
|
+
|
|
80
|
+
expect(entity._props.is_authenticated).toStrictEqual(dto.is_authenticated);
|
|
81
|
+
expect(entity._props.is_mfa_authenticated).toStrictEqual(dto.is_mfa_authenticated);
|
|
82
|
+
expect(entity._props.is_server_reachable).toStrictEqual(dto.is_server_reachable);
|
|
83
|
+
expect(entity._props.type).toStrictEqual(dto.type);
|
|
84
|
+
expect(entity._props.last_logged_in).toStrictEqual(dto.last_logged_in);
|
|
85
|
+
expect(entity._props.last_seen_online).toStrictEqual(dto.last_seen_online);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("::isAuthenticated", () => {
|
|
90
|
+
it("get is_authenticated property value", () => {
|
|
91
|
+
expect.assertions(2);
|
|
92
|
+
let entity = new UserActiveSessionEntity(minimalUserActiveSessionDto());
|
|
93
|
+
expect(entity.isAuthenticated).toBeTruthy();
|
|
94
|
+
entity = new UserActiveSessionEntity(minimalUserActiveSessionDto({ is_authenticated: false }));
|
|
95
|
+
expect(entity.isAuthenticated).toBeFalsy();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("set is_authenticated property value", () => {
|
|
99
|
+
expect.assertions(2);
|
|
100
|
+
let entity = new UserActiveSessionEntity(minimalUserActiveSessionDto());
|
|
101
|
+
expect(entity.isAuthenticated).toBeTruthy();
|
|
102
|
+
entity.isAuthenticated = false;
|
|
103
|
+
expect(entity.isAuthenticated).toBeFalsy();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe("::isMfaAuthenticated", () => {
|
|
108
|
+
it("get is_mfa_authenticated property value", () => {
|
|
109
|
+
expect.assertions(2);
|
|
110
|
+
let entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
111
|
+
expect(entity.isMfaAuthenticated).toBeTruthy();
|
|
112
|
+
entity = new UserActiveSessionEntity(defaultUserActiveSessionDto({ is_mfa_authenticated: false }));
|
|
113
|
+
expect(entity.isMfaAuthenticated).toBeFalsy();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("set is_mfa_authenticated property value", () => {
|
|
117
|
+
expect.assertions(2);
|
|
118
|
+
let entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
119
|
+
expect(entity.isMfaAuthenticated).toBeTruthy();
|
|
120
|
+
entity.isMfaAuthenticated = false;
|
|
121
|
+
expect(entity.isMfaAuthenticated).toBeFalsy();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe("::isServerReachable", () => {
|
|
126
|
+
it("get is_server_reachable property value", () => {
|
|
127
|
+
expect.assertions(2);
|
|
128
|
+
let entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
129
|
+
expect(entity.isServerReachable).toBeTruthy();
|
|
130
|
+
entity = new UserActiveSessionEntity(defaultUserActiveSessionDto({ is_server_reachable: false }));
|
|
131
|
+
expect(entity.isServerReachable).toBeFalsy();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("set is_server_reachable property value", () => {
|
|
135
|
+
expect.assertions(2);
|
|
136
|
+
let entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
137
|
+
expect(entity.isServerReachable).toBeTruthy();
|
|
138
|
+
entity.isServerReachable = false;
|
|
139
|
+
expect(entity.isServerReachable).toBeFalsy();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("::type", () => {
|
|
144
|
+
it("get type property value", () => {
|
|
145
|
+
expect.assertions(2);
|
|
146
|
+
let entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
147
|
+
expect(entity.type).toStrictEqual(USER_ACTIVE_SESSION_ONLINE);
|
|
148
|
+
entity = new UserActiveSessionEntity(defaultUserActiveSessionDto({ type: USER_ACTIVE_SESSION_OFFLINE }));
|
|
149
|
+
expect(entity.type).toStrictEqual(USER_ACTIVE_SESSION_OFFLINE);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("set type property value", () => {
|
|
153
|
+
expect.assertions(2);
|
|
154
|
+
let entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
155
|
+
expect(entity.type).toStrictEqual(USER_ACTIVE_SESSION_ONLINE);
|
|
156
|
+
entity.type = USER_ACTIVE_SESSION_OFFLINE;
|
|
157
|
+
expect(entity.type).toStrictEqual(USER_ACTIVE_SESSION_OFFLINE);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe("::lastLoggedIn", () => {
|
|
162
|
+
it("get last_logged_in property value", () => {
|
|
163
|
+
expect.assertions(1);
|
|
164
|
+
const last_logged_in = "2024-10-05T12:10:00+00:00";
|
|
165
|
+
const entity = new UserActiveSessionEntity(defaultUserActiveSessionDto({ last_logged_in }));
|
|
166
|
+
expect(entity.lastLoggedIn).toStrictEqual(last_logged_in);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("set last_logged_in property value", () => {
|
|
170
|
+
expect.assertions(1);
|
|
171
|
+
const last_logged_in = "2024-10-05T12:10:00+00:00";
|
|
172
|
+
const entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
173
|
+
entity.lastLoggedIn = last_logged_in;
|
|
174
|
+
expect(entity.lastLoggedIn).toStrictEqual(last_logged_in);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe("::lastSeenOnline", () => {
|
|
179
|
+
it("get last_seen_online property value", () => {
|
|
180
|
+
expect.assertions(1);
|
|
181
|
+
const last_seen_online = "2024-10-05T12:10:00+00:00";
|
|
182
|
+
const entity = new UserActiveSessionEntity(defaultUserActiveSessionDto({ last_seen_online }));
|
|
183
|
+
expect(entity.lastSeenOnline).toStrictEqual(last_seen_online);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("set last_seen_online property value", () => {
|
|
187
|
+
expect.assertions(1);
|
|
188
|
+
const last_seen_online = "2024-10-05T12:10:00+00:00";
|
|
189
|
+
const entity = new UserActiveSessionEntity(defaultUserActiveSessionDto());
|
|
190
|
+
entity.lastSeenOnline = last_seen_online;
|
|
191
|
+
expect(entity.lastSeenOnline).toStrictEqual(last_seen_online);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -41,14 +41,15 @@ class OfflineModeServiceWorkerService {
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Unmark an item available offline.
|
|
44
|
-
* @param {string}
|
|
44
|
+
* @param {string} offlineItemId The offline item id (offline_items row id), used to delete the item on the API
|
|
45
|
+
* and to resolve the resource whose offline OPFS entries should be dropped.
|
|
45
46
|
* @return {Promise<null>}
|
|
46
47
|
*/
|
|
47
|
-
async unmarkItem(
|
|
48
|
-
if (!isValidUuid(
|
|
49
|
-
throw new Error("The given
|
|
48
|
+
async unmarkItem(offlineItemId) {
|
|
49
|
+
if (!isValidUuid(offlineItemId)) {
|
|
50
|
+
throw new Error("The given offlineItemId should be a valid UUID");
|
|
50
51
|
}
|
|
51
|
-
return await this.port.request(OFFLINE_UNMARK_ITEM_OFFLINE_EVENT,
|
|
52
|
+
return await this.port.request(OFFLINE_UNMARK_ITEM_OFFLINE_EVENT, offlineItemId);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
export default OfflineModeServiceWorkerService;
|
|
@@ -56,16 +56,16 @@ describe("OfflineModeServiceWorkerService", () => {
|
|
|
56
56
|
it("should unmark offline item", async () => {
|
|
57
57
|
expect.assertions(1);
|
|
58
58
|
portMock.request.mockResolvedValue(null);
|
|
59
|
-
const
|
|
59
|
+
const offlineItemId = uuidv4();
|
|
60
60
|
|
|
61
|
-
await service.unmarkItem(
|
|
61
|
+
await service.unmarkItem(offlineItemId);
|
|
62
62
|
|
|
63
|
-
expect(portMock.request).toHaveBeenCalledWith(OFFLINE_UNMARK_ITEM_OFFLINE_EVENT,
|
|
63
|
+
expect(portMock.request).toHaveBeenCalledWith(OFFLINE_UNMARK_ITEM_OFFLINE_EVENT, offlineItemId);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
it("should throw an error if the id is not a valid uuid", async () => {
|
|
66
|
+
it("should throw an error if the offline item id is not a valid uuid", async () => {
|
|
67
67
|
expect.assertions(2);
|
|
68
|
-
expect(() => service.unmarkItem("not-a-uuid")).rejects.toThrow("The given
|
|
68
|
+
expect(() => service.unmarkItem("not-a-uuid")).rejects.toThrow("The given offlineItemId should be a valid UUID");
|
|
69
69
|
expect(portMock.request).not.toHaveBeenCalled();
|
|
70
70
|
});
|
|
71
71
|
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Passbolt ~ Open source password manager for teams
|
|
3
|
-
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
-
*
|
|
5
|
-
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
-
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
-
* Redistributions of files must retain the above copyright notice.
|
|
8
|
-
*
|
|
9
|
-
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
-
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
-
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
-
* @since 5.13.0
|
|
13
|
-
*/
|
|
14
|
-
import EntityV2 from "../abstract/entityV2";
|
|
15
|
-
|
|
16
|
-
class OnlineSessionEntity extends EntityV2 {
|
|
17
|
-
/**
|
|
18
|
-
* Get online session entity schema
|
|
19
|
-
* @returns {object} schema
|
|
20
|
-
*/
|
|
21
|
-
static getSchema() {
|
|
22
|
-
return {
|
|
23
|
-
type: "object",
|
|
24
|
-
required: ["is_authenticated"],
|
|
25
|
-
properties: {
|
|
26
|
-
is_authenticated: {
|
|
27
|
-
type: "boolean",
|
|
28
|
-
format: "uuid",
|
|
29
|
-
},
|
|
30
|
-
is_mfa_authenticated: {
|
|
31
|
-
type: "boolean",
|
|
32
|
-
format: "uuid",
|
|
33
|
-
},
|
|
34
|
-
last_online_logged_in: {
|
|
35
|
-
type: "string",
|
|
36
|
-
format: "date-time",
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/*
|
|
43
|
-
* ==================================================
|
|
44
|
-
* Dynamic properties getters
|
|
45
|
-
* ==================================================
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get the is authenticated
|
|
50
|
-
* @returns {boolean}
|
|
51
|
-
*/
|
|
52
|
-
get isAuthenticated() {
|
|
53
|
-
return this._props.is_authenticated;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get the is mfa authenticated
|
|
58
|
-
* @returns {boolean}
|
|
59
|
-
*/
|
|
60
|
-
get isMfaAuthenticated() {
|
|
61
|
-
return this._props.is_mfa_authenticated;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get the last online logged in date
|
|
66
|
-
* @returns {string}
|
|
67
|
-
*/
|
|
68
|
-
get lastOnlineLoggedIn() {
|
|
69
|
-
return this._props.last_online_logged_in;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default OnlineSessionEntity;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Passbolt ~ Open source password manager for teams
|
|
3
|
-
* Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
4
|
-
*
|
|
5
|
-
* Licensed under GNU Affero General Public License version 3 of the or any later version.
|
|
6
|
-
* For full copyright and license information, please see the LICENSE.txt
|
|
7
|
-
* Redistributions of files must retain the above copyright notice.
|
|
8
|
-
*
|
|
9
|
-
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
|
|
10
|
-
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
|
|
11
|
-
* @link https://www.passbolt.com Passbolt(tm)
|
|
12
|
-
* @since 5.13.0
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import EntitySchema from "../abstract/entitySchema";
|
|
16
|
-
import * as assertEntityProperty from "../../../../../test/assert/assertEntityProperty";
|
|
17
|
-
import OnlineSessionEntity from "./onlineSessionEntity";
|
|
18
|
-
import { defaultOnlineSessionDto, minimalOnlineSessionDto } from "./onlineSessionEntity.test.data";
|
|
19
|
-
|
|
20
|
-
describe("OnlineSession", () => {
|
|
21
|
-
describe("::getSchema", () => {
|
|
22
|
-
it("schema must validate", () => {
|
|
23
|
-
EntitySchema.validateSchema(OnlineSessionEntity.name, OnlineSessionEntity.getSchema());
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("validates is_authenticated property", () => {
|
|
27
|
-
assertEntityProperty.boolean(OnlineSessionEntity, "is_authenticated");
|
|
28
|
-
assertEntityProperty.required(OnlineSessionEntity, "is_authenticated");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("validates is_mfa_authenticated property", () => {
|
|
32
|
-
assertEntityProperty.boolean(OnlineSessionEntity, "is_mfa_authenticated");
|
|
33
|
-
assertEntityProperty.notRequired(OnlineSessionEntity, "is_mfa_authenticated");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("validates last_online_logged_in property", () => {
|
|
37
|
-
assertEntityProperty.string(OnlineSessionEntity, "last_online_logged_in");
|
|
38
|
-
assertEntityProperty.dateTime(OnlineSessionEntity, "last_online_logged_in");
|
|
39
|
-
assertEntityProperty.notRequired(OnlineSessionEntity, "last_online_logged_in");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe("::constructor", () => {
|
|
44
|
-
it("constructor works if minimal dto is provided.", () => {
|
|
45
|
-
expect.assertions(1);
|
|
46
|
-
const dto = minimalOnlineSessionDto();
|
|
47
|
-
const entity = new OnlineSessionEntity(dto);
|
|
48
|
-
|
|
49
|
-
expect(entity._props.is_authenticated).toStrictEqual(dto.is_authenticated);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("constructor works if valid DTO is provided", () => {
|
|
53
|
-
expect.assertions(3);
|
|
54
|
-
const dto = defaultOnlineSessionDto();
|
|
55
|
-
const entity = new OnlineSessionEntity(dto);
|
|
56
|
-
|
|
57
|
-
expect(entity._props.is_authenticated).toStrictEqual(dto.is_authenticated);
|
|
58
|
-
expect(entity._props.is_mfa_authenticated).toStrictEqual(dto.is_mfa_authenticated);
|
|
59
|
-
expect(entity._props.last_online_logged_in).toStrictEqual(dto.last_online_logged_in);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("::isAuthenticated", () => {
|
|
64
|
-
it("get is_authenticated property value", () => {
|
|
65
|
-
expect.assertions(2);
|
|
66
|
-
let entity = new OnlineSessionEntity(minimalOnlineSessionDto());
|
|
67
|
-
expect(entity.isAuthenticated).toBeTruthy();
|
|
68
|
-
entity = new OnlineSessionEntity(minimalOnlineSessionDto({ is_authenticated: false }));
|
|
69
|
-
expect(entity.isAuthenticated).toBeFalsy();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe("::isMfaAuthenticated", () => {
|
|
74
|
-
it("get is__mfaauthenticated property value", () => {
|
|
75
|
-
expect.assertions(2);
|
|
76
|
-
let entity = new OnlineSessionEntity(defaultOnlineSessionDto());
|
|
77
|
-
expect(entity.isMfaAuthenticated).toBeTruthy();
|
|
78
|
-
entity = new OnlineSessionEntity(defaultOnlineSessionDto({ is_mfa_authenticated: false }));
|
|
79
|
-
expect(entity.isMfaAuthenticated).toBeFalsy();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe("::lastOnlineLoggedIn", () => {
|
|
84
|
-
it("get last_online_logged_in property value", () => {
|
|
85
|
-
expect.assertions(1);
|
|
86
|
-
const last_online_logged_in = "2024-10-05T12:10:00+00:00";
|
|
87
|
-
const entity = new OnlineSessionEntity(defaultOnlineSessionDto({ last_online_logged_in }));
|
|
88
|
-
expect(entity.lastOnlineLoggedIn).toStrictEqual(last_online_logged_in);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|