passbolt-styleguide 5.18.2 → 5.19.0-alpha.2
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/RELEASE_NOTES.md +7 -2
- package/build/css/themes/default/api_authentication.min.css +4 -4
- package/build/css/themes/default/api_main.min.css +4 -4
- package/build/css/themes/default/ext_app.min.css +4 -4
- package/build/css/themes/default/ext_authentication.min.css +4 -4
- package/build/css/themes/default/ext_external.min.css +2 -2
- package/build/css/themes/default/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/default/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/default/ext_quickaccess.min.css +4 -4
- package/build/css/themes/layette/api_authentication.min.css +4 -4
- package/build/css/themes/layette/api_main.min.css +4 -4
- package/build/css/themes/layette/ext_app.min.css +4 -4
- package/build/css/themes/layette/ext_authentication.min.css +4 -4
- package/build/css/themes/layette/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/layette/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/layette/ext_quickaccess.min.css +4 -4
- package/build/css/themes/midgar/api_authentication.min.css +4 -4
- package/build/css/themes/midgar/api_main.min.css +4 -4
- package/build/css/themes/midgar/ext_app.min.css +4 -4
- package/build/css/themes/midgar/ext_authentication.min.css +4 -4
- package/build/css/themes/midgar/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/midgar/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/midgar/ext_quickaccess.min.css +4 -4
- package/build/css/themes/sakura/api_authentication.min.css +4 -4
- package/build/css/themes/sakura/api_main.min.css +4 -4
- package/build/css/themes/sakura/ext_app.min.css +4 -4
- package/build/css/themes/sakura/ext_authentication.min.css +4 -4
- package/build/css/themes/sakura/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/sakura/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/sakura/ext_quickaccess.min.css +4 -4
- package/build/css/themes/solarized_dark/api_authentication.min.css +4 -4
- package/build/css/themes/solarized_dark/api_main.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_app.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_authentication.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_quickaccess.min.css +4 -4
- package/build/css/themes/solarized_light/api_authentication.min.css +4 -4
- package/build/css/themes/solarized_light/api_main.min.css +4 -4
- package/build/css/themes/solarized_light/ext_app.min.css +4 -4
- package/build/css/themes/solarized_light/ext_authentication.min.css +4 -4
- package/build/css/themes/solarized_light/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/solarized_light/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/solarized_light/ext_quickaccess.min.css +4 -4
- package/build/css/themes/themes.json +1 -0
- package/build/js/dist/api-account-recovery.js +1 -1
- package/build/js/dist/api-app.js +1 -1
- package/build/js/dist/api-feedback.js +1 -1
- package/build/js/dist/api-mfa-verify-delegated.js +1 -1
- package/build/js/dist/api-mfa-verify.js +1 -1
- package/build/js/dist/api-recover.js +1 -1
- package/build/js/dist/api-setup.js +1 -1
- package/build/js/dist/api-triage.js +1 -1
- package/build/locales/cs-CZ/common.json +167 -13
- package/build/locales/de-DE/common.json +165 -13
- package/build/locales/es-ES/common.json +165 -13
- package/build/locales/fr-FR/common.json +165 -13
- package/build/locales/it-IT/common.json +165 -13
- package/build/locales/ja-JP/common.json +164 -13
- package/build/locales/ko-KR/common.json +164 -13
- package/build/locales/lt-LT/common.json +167 -13
- package/build/locales/nl-NL/common.json +165 -13
- package/build/locales/pl-PL/common.json +167 -13
- package/build/locales/pt-BR/common.json +165 -13
- package/build/locales/ro-RO/common.json +166 -13
- package/build/locales/ru-RU/common.json +167 -13
- package/build/locales/sl-SI/common.json +167 -13
- package/build/locales/sv-SE/common.json +165 -13
- package/build/locales/uk-UA/common.json +167 -13
- package/package.json +2 -2
- package/src/img/svg/logo.svg +2 -2
- package/src/locales/cs-CZ/common.json +167 -13
- package/src/locales/de-DE/common.json +165 -13
- package/src/locales/es-ES/common.json +165 -13
- package/src/locales/fr-FR/common.json +165 -13
- package/src/locales/it-IT/common.json +165 -13
- package/src/locales/ja-JP/common.json +164 -13
- package/src/locales/ko-KR/common.json +164 -13
- package/src/locales/lt-LT/common.json +167 -13
- package/src/locales/nl-NL/common.json +165 -13
- package/src/locales/pl-PL/common.json +167 -13
- package/src/locales/pt-BR/common.json +165 -13
- package/src/locales/ro-RO/common.json +166 -13
- package/src/locales/ru-RU/common.json +167 -13
- package/src/locales/sl-SI/common.json +167 -13
- package/src/locales/sv-SE/common.json +165 -13
- package/src/locales/uk-UA/common.json +167 -13
- package/src/react-extension/ExtAuthenticationLogin.js +1 -0
- package/src/react-extension/components/Administration/DisplayHealthcheckAdministration/DisplayHealthcheckAdministration.js +14 -23
- package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.js +2 -1
- package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.test.data.js +5 -0
- package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.test.js +13 -1
- package/src/react-extension/contexts/ResourceWorkspaceContext.js +3 -1
- package/src/react-extension/contexts/ResourceWorkspaceContext.test.js +8 -0
- package/src/react-web-integration/lib/Dom/DomUtils.js +1 -1
- package/src/react-web-integration/lib/Dom/DomUtils.test.js +19 -0
- package/src/react-web-integration/lib/InForm/InFormCallToActionField.js +5 -1
- package/src/react-web-integration/lib/InForm/InFormCallToActionField.test.js +39 -0
- package/src/react-web-integration/lib/InForm/InFormManager.js +36 -13
- package/src/react-web-integration/lib/InForm/InformManager.test.js +255 -6
- package/src/react-web-integration/lib/InForm/InformManager.test.page.js +7 -7
- package/src/react-web-integration/lib/InForm/ScrapingDictionary.js +1 -1
- package/src/react-web-integration/services/Scraping/FieldScraperService.js +7 -4
- package/src/react-web-integration/services/Scraping/LabelIndex.js +86 -0
- package/src/react-web-integration/services/Scraping/LabelIndex.test.js +111 -0
- package/src/react-web-integration/services/Scraping/LabelScraperService.js +18 -14
- package/src/react-web-integration/services/Scraping/LabelScraperService.test.js +5 -5
- package/src/react-web-integration/services/Scraping/PageScraperHelpers.js +21 -5
- package/src/react-web-integration/services/Scraping/PageScraperHelpers.test.js +116 -0
- package/src/react-web-integration/services/Scraping/PageScraperService.js +6 -3
- package/src/react-web-integration/services/classification/FieldClassificationService.js +46 -40
- package/src/react-web-integration/services/classification/FieldClassificationService.test.data.js +3 -2
- package/src/react-web-integration/services/classification/FieldClassificationService.test.js +72 -0
- package/src/react-web-integration/services/classification/FieldFeatureService.js +12 -14
- package/src/react-web-integration/services/classification/FieldFeatureService.test.js +25 -11
- package/src/react-web-integration/services/classification/FieldsRationalizationService.js +1 -1
- package/src/react-web-integration/services/classification/KeywordMatchingService.js +18 -4
- package/src/react-web-integration/services/classification/KeywordMatchingService.test.js +35 -0
- package/src/react-web-integration/services/classification/KeywordsDictionary.js +21 -1
- package/src/react-web-integration/services/classification/PasswordRoleResolutionService.js +2 -2
- package/src/react-web-integration/services/classification/SegmentedOtpResolutionService.js +2 -2
- package/src/shared/utils/filterUtils.js +3 -2
- package/src/shared/utils/filterUtils.test.js +15 -0
- package/build/css/help.min.css +0 -9
- package/build/css/public.min.css +0 -8
- package/build/css/themes/default/api_cloud.min.css +0 -8
- package/build/css/themes/default/api_reports.min.css +0 -9
- package/build/css/themes/default/api_webinstaller.min.css +0 -9
- package/build/css/themes/layette/api_reports.min.css +0 -9
- package/build/css/themes/midgar/api_reports.min.css +0 -9
- package/build/css/themes/sakura/api_reports.min.css +0 -9
- package/build/css/themes/solarized_dark/api_reports.min.css +0 -9
- package/build/css/themes/solarized_light/api_reports.min.css +0 -9
|
@@ -69,6 +69,7 @@ class ExtAuthenticationLogin extends Component {
|
|
|
69
69
|
siteSettings: null, // The site settings
|
|
70
70
|
extensionVersion: null, // The extension version
|
|
71
71
|
locale: null, // The locale
|
|
72
|
+
account: null, // The account
|
|
72
73
|
|
|
73
74
|
// Locale
|
|
74
75
|
onUpdateLocaleRequested: this.onUpdateLocaleRequested.bind(this),
|
|
@@ -208,29 +208,20 @@ class DisplayHealthcheckAdministration extends Component {
|
|
|
208
208
|
return (
|
|
209
209
|
<div key={checkKey} className={`accordion healthcheck-check ${isHelpOpened ? "" : "closed"}`}>
|
|
210
210
|
<div className="healthcheck-check-row accordion-header">
|
|
211
|
-
{
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
</button>
|
|
226
|
-
</>
|
|
227
|
-
) : (
|
|
228
|
-
<>
|
|
229
|
-
<span className={`healthcheck-badge ${modifier}`}>
|
|
230
|
-
<StatusIcon />
|
|
231
|
-
</span>
|
|
232
|
-
<span className="healthcheck-check-message">{check.message}</span>
|
|
233
|
-
</>
|
|
211
|
+
<span className={`healthcheck-badge ${modifier}`}>
|
|
212
|
+
<StatusIcon />
|
|
213
|
+
</span>
|
|
214
|
+
<span className="healthcheck-check-message">{check.message}</span>
|
|
215
|
+
{hasHelp && (
|
|
216
|
+
<button
|
|
217
|
+
type="button"
|
|
218
|
+
className="link no-border healthcheck-help-toggle"
|
|
219
|
+
aria-expanded={isHelpOpened}
|
|
220
|
+
aria-controls={helpId}
|
|
221
|
+
onClick={() => this.handleHelpToggleClick(checkKey)}
|
|
222
|
+
>
|
|
223
|
+
{isHelpOpened ? <CaretDownSVG /> : <CaretRightSVG />}
|
|
224
|
+
</button>
|
|
234
225
|
)}
|
|
235
226
|
</div>
|
|
236
227
|
{isHelpOpened && (
|
|
@@ -84,7 +84,8 @@ class DisplayUserTheme extends React.Component {
|
|
|
84
84
|
this.props.loadingContext.add();
|
|
85
85
|
const themes = await this.props.context.port.request("passbolt.themes.find-all");
|
|
86
86
|
const selectedTheme = this.props.context.userSettings.getTheme();
|
|
87
|
-
this
|
|
87
|
+
// Hide the themes this client cannot preview, case when the API is newer than the extension.
|
|
88
|
+
this.setState({ themes: themes.filter((theme) => this.getThemeName(theme)), selectedTheme });
|
|
88
89
|
this.props.loadingContext.remove();
|
|
89
90
|
}
|
|
90
91
|
|
package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.test.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @since 4.3.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { defaultProps, themes } from "./DisplayUserTheme.test.data";
|
|
15
|
+
import { defaultProps, themes, unsupportedTheme } from "./DisplayUserTheme.test.data";
|
|
16
16
|
import DisplayUserThemePage from "./DisplayUserTheme.test.page";
|
|
17
17
|
import NotifyError from "../../Common/Error/NotifyError/NotifyError";
|
|
18
18
|
import { screen } from "@testing-library/react";
|
|
@@ -108,3 +108,15 @@ describe("Display user theme", () => {
|
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
|
+
|
|
112
|
+
describe("Display user theme with a theme this client cannot preview", () => {
|
|
113
|
+
it("As LU, I should not see a theme this client has no preview for", async () => {
|
|
114
|
+
expect.assertions(2);
|
|
115
|
+
const props = defaultProps();
|
|
116
|
+
props.context.port.addRequestListener("passbolt.themes.find-all", () => [...themes, unsupportedTheme]);
|
|
117
|
+
const page = new DisplayUserThemePage(props);
|
|
118
|
+
await screen.findAllByRole("button");
|
|
119
|
+
expect(page.themesCount).toStrictEqual(6);
|
|
120
|
+
expect(page.theme(6).name).toStrictEqual("Layette");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -1035,7 +1035,7 @@ export class ResourceWorkspaceContextProvider extends React.Component {
|
|
|
1035
1035
|
const canUseTags = this.props.context.siteSettings.canIUse("tags");
|
|
1036
1036
|
const foldersMatchCache = {};
|
|
1037
1037
|
|
|
1038
|
-
// Test match of some escaped test words against the name / username / uri / description /tags resource properties
|
|
1038
|
+
// Test match of some escaped test words against the name / username / uri / description /tags / id (exact) resource properties
|
|
1039
1039
|
const escapeWord = (word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1040
1040
|
const wordToRegex = (word) => new RegExp(escapeWord(word), "i");
|
|
1041
1041
|
const matchWord = (word, value) => wordToRegex(word).test(value);
|
|
@@ -1058,11 +1058,13 @@ export class ResourceWorkspaceContextProvider extends React.Component {
|
|
|
1058
1058
|
resource.metadata?.custom_fields?.some((customField) => matchWord(word, customField.metadata_key));
|
|
1059
1059
|
const matchStringProperty = (word, resource) =>
|
|
1060
1060
|
["name", "username", "description"].some((key) => matchWord(word, resource.metadata?.[key]));
|
|
1061
|
+
const matchIdProperty = (word, resource) => resource.id === word.toLowerCase();
|
|
1061
1062
|
const matchResource = (word, resource) =>
|
|
1062
1063
|
matchStringProperty(word, resource) ||
|
|
1063
1064
|
matchUrisProperty(word, resource) ||
|
|
1064
1065
|
(canUseTags && matchTagProperty(word, resource)) ||
|
|
1065
1066
|
matchCustomFieldsProperty(word, resource) ||
|
|
1067
|
+
matchIdProperty(word, resource) ||
|
|
1066
1068
|
(resource?.folder_parent_id && matchFolderCache(word, resource.folder_parent_id));
|
|
1067
1069
|
const matchText = (resource) => words.every((word) => matchResource(word, resource));
|
|
1068
1070
|
|
|
@@ -166,6 +166,14 @@ describe("Resource Workspace Context", () => {
|
|
|
166
166
|
expect(page.filteredResources[0].metadata.name).toBe("Resource in folder");
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
+
it("AS LU I should have resources matching a text when the filter is TEXT in resource id", async () => {
|
|
170
|
+
const expectedResourcesCount = 1;
|
|
171
|
+
await page.goToText(context.resources[0].id);
|
|
172
|
+
await waitForTrue(() => page.filteredResources.length !== totalResourcesCount);
|
|
173
|
+
expect(page.filteredResources).toHaveLength(expectedResourcesCount);
|
|
174
|
+
expect(page.filteredResources[0].metadata.name).toBe("Resource owned");
|
|
175
|
+
});
|
|
176
|
+
|
|
169
177
|
it("AS LU I should have resources belonged to a group when the filter is GROUP", async () => {
|
|
170
178
|
expect.hasAssertions();
|
|
171
179
|
const mockGroupResources = context.resources.slice(0, 3);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
class DomUtils {
|
|
19
19
|
static getAccessibleAndSameDomainIframes() {
|
|
20
|
-
return Array.prototype.filter.call(document.querySelectorAll("iframe"), (iframe) => {
|
|
20
|
+
return Array.prototype.filter.call(document.querySelectorAll("iframe,frame"), (iframe) => {
|
|
21
21
|
const contentDocument = DomUtils.getAccessedIframeContentDocument(iframe);
|
|
22
22
|
return (
|
|
23
23
|
contentDocument &&
|
|
@@ -90,6 +90,25 @@ describe("DomUtils", () => {
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
describe("DomUtils::getAccessibleAndSameDomainIframes", () => {
|
|
94
|
+
afterEach(() => {
|
|
95
|
+
document.documentElement.replaceChild(document.createElement("body"), document.body);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("Should return the same-origin frame elements alongside the same-origin iframe elements", () => {
|
|
99
|
+
expect.assertions(1);
|
|
100
|
+
|
|
101
|
+
jest.spyOn(DOMUtils, "isRequestInitiatedFromSameOrigin").mockReturnValue(true);
|
|
102
|
+
const frameset = document.createElement("frameset");
|
|
103
|
+
const frame = document.createElement("frame");
|
|
104
|
+
const iframe = document.createElement("iframe");
|
|
105
|
+
frameset.append(frame, iframe);
|
|
106
|
+
document.documentElement.replaceChild(frameset, document.body);
|
|
107
|
+
|
|
108
|
+
expect(DOMUtils.getAccessibleAndSameDomainIframes()).toEqual([frame, iframe]);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
93
112
|
describe("DomUtils::getContainingDialog", () => {
|
|
94
113
|
it("Should return the closest ancestor dialog of an element contained inside a dialog", () => {
|
|
95
114
|
expect.assertions(1);
|
|
@@ -34,8 +34,9 @@ class InFormCallToActionField {
|
|
|
34
34
|
* @param field The DOM element
|
|
35
35
|
* @param fieldType The type of field
|
|
36
36
|
* @param shadowRoot The shadow root
|
|
37
|
+
* @param {function} [onBeforeIframeInsertion] Called right before the call-to-action iframe is inserted
|
|
37
38
|
*/
|
|
38
|
-
constructor(field, fieldType, shadowRoot) {
|
|
39
|
+
constructor(field, fieldType, shadowRoot, onBeforeIframeInsertion = () => {}) {
|
|
39
40
|
/** The field to which the in-form is attached */
|
|
40
41
|
this.field = field;
|
|
41
42
|
/** Type of the field ("username" or "password") */
|
|
@@ -58,6 +59,8 @@ class InFormCallToActionField {
|
|
|
58
59
|
this.callToActionClickCallback = null;
|
|
59
60
|
/** The shadow root **/
|
|
60
61
|
this.shadowRoot = shadowRoot;
|
|
62
|
+
/** Callback called right before the call-to-action iframe is inserted */
|
|
63
|
+
this.onBeforeIframeInsertion = onBeforeIframeInsertion;
|
|
61
64
|
/** Rectangle coordinates of the field */
|
|
62
65
|
this.viewableRect = null;
|
|
63
66
|
/** Pending removal scheduled while the pointer travels from the field to the call-to-action */
|
|
@@ -145,6 +148,7 @@ class InFormCallToActionField {
|
|
|
145
148
|
if (existingIframe) {
|
|
146
149
|
this.removeIframe();
|
|
147
150
|
}
|
|
151
|
+
this.onBeforeIframeInsertion();
|
|
148
152
|
const iframe = await this.createCallToActionIframe();
|
|
149
153
|
this.handleCallToActionClicked(iframe);
|
|
150
154
|
}
|
|
@@ -189,6 +189,45 @@ describe("InFormCallToActionField", () => {
|
|
|
189
189
|
expect(callToActionField.isCallToActionIframeAlive(iframe)).toStrictEqual(false);
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
+
it("should call the before insertion callback before creating the iframe", async () => {
|
|
193
|
+
expect.assertions(2);
|
|
194
|
+
|
|
195
|
+
const onBeforeIframeInsertion = jest.fn();
|
|
196
|
+
const field = document.createElement("input");
|
|
197
|
+
document.body.appendChild(field);
|
|
198
|
+
const shadowRoot = document.createElement("div").attachShadow({ mode: "open" });
|
|
199
|
+
const callToActionField = new InFormCallToActionField(field, "username", shadowRoot, onBeforeIframeInsertion);
|
|
200
|
+
callToActionField.createCallToActionIframe = jest.fn(async () => {
|
|
201
|
+
expect(onBeforeIframeInsertion).toHaveBeenCalledTimes(1);
|
|
202
|
+
return { addEventListener: jest.fn() };
|
|
203
|
+
});
|
|
204
|
+
callToActionField.handleCallToActionClicked = jest.fn();
|
|
205
|
+
|
|
206
|
+
await callToActionField.insertInformCallToActionIframe();
|
|
207
|
+
|
|
208
|
+
expect(callToActionField.createCallToActionIframe).toHaveBeenCalledTimes(1);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("should not call the before insertion callback when a live iframe is already inserted", async () => {
|
|
212
|
+
expect.assertions(1);
|
|
213
|
+
|
|
214
|
+
const onBeforeIframeInsertion = jest.fn();
|
|
215
|
+
const field = document.createElement("input");
|
|
216
|
+
document.body.appendChild(field);
|
|
217
|
+
const shadowRoot = document.createElement("div").attachShadow({ mode: "open" });
|
|
218
|
+
const callToActionField = new InFormCallToActionField(field, "username", shadowRoot, onBeforeIframeInsertion);
|
|
219
|
+
const iframe = document.createElement("iframe");
|
|
220
|
+
iframe.id = callToActionField.iframeId;
|
|
221
|
+
shadowRoot.appendChild(iframe);
|
|
222
|
+
const browsingContext = {};
|
|
223
|
+
Object.defineProperty(iframe, "contentWindow", { value: browsingContext });
|
|
224
|
+
callToActionField.callToActionWindow = browsingContext;
|
|
225
|
+
|
|
226
|
+
await callToActionField.insertInformCallToActionIframe();
|
|
227
|
+
|
|
228
|
+
expect(onBeforeIframeInsertion).not.toHaveBeenCalled();
|
|
229
|
+
});
|
|
230
|
+
|
|
192
231
|
it("should create the iframe and handle its click event", async () => {
|
|
193
232
|
expect.assertions(2);
|
|
194
233
|
|
|
@@ -31,6 +31,7 @@ import ShadowDomQueryService from "../../services/ShadowDom/ShadowDomQueryServic
|
|
|
31
31
|
import ElementVisibilityService from "../../services/DomExtraction/ElementVisibilityService";
|
|
32
32
|
import PageClassificationService from "../../services/PageClassificationService";
|
|
33
33
|
import { FieldRole } from "../../services/classification/Taxonomy";
|
|
34
|
+
import FieldFeatureService from "../../services/classification/FieldFeatureService";
|
|
34
35
|
|
|
35
36
|
const Z_INDEX_MAX = 2147483647;
|
|
36
37
|
const HOST_MOUNT_MAX_RETRIES = 3;
|
|
@@ -109,6 +110,7 @@ class InFormManager {
|
|
|
109
110
|
|
|
110
111
|
// Insert the host in the provided container
|
|
111
112
|
container.appendChild(this.host);
|
|
113
|
+
this.hostMutationObserver?.observe(this.host, { attributes: true });
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/**
|
|
@@ -171,7 +173,9 @@ class InFormManager {
|
|
|
171
173
|
this.htmlMutationObserver = new MutationObserver(() => this.destroyIfElementNotVisible(document.documentElement));
|
|
172
174
|
this.bodyMutationObserver = new MutationObserver(() => this.destroyIfElementNotVisible(document.body));
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
if (this.host) {
|
|
177
|
+
this.hostMutationObserver.observe(this.host, { attributes: true });
|
|
178
|
+
}
|
|
175
179
|
this.htmlMutationObserver.observe(document.documentElement, { attributes: true });
|
|
176
180
|
this.bodyMutationObserver.observe(document.body, { attributes: true });
|
|
177
181
|
}
|
|
@@ -284,7 +288,7 @@ class InFormManager {
|
|
|
284
288
|
/**
|
|
285
289
|
* Returns the element the shadow root host should be mounted into for the given input fields.
|
|
286
290
|
* @param {...HTMLElement[]} fieldsArrays One or more arrays of input fields.
|
|
287
|
-
* @return {HTMLElement} The dialog containing one of the fields (if any), or document.body.
|
|
291
|
+
* @return {HTMLElement} The dialog containing one of the fields (if any), the document element on a frameset page, or document.body.
|
|
288
292
|
*/
|
|
289
293
|
getContainerElement(...fieldsArrays) {
|
|
290
294
|
const fields = fieldsArrays.flat();
|
|
@@ -298,6 +302,11 @@ class InFormManager {
|
|
|
298
302
|
}
|
|
299
303
|
}
|
|
300
304
|
|
|
305
|
+
// A frameset body renders only its frames: mount the host next to it, under <html>
|
|
306
|
+
if (document.body?.nodeName === "FRAMESET") {
|
|
307
|
+
return document.documentElement;
|
|
308
|
+
}
|
|
309
|
+
|
|
301
310
|
return document.body;
|
|
302
311
|
}
|
|
303
312
|
|
|
@@ -310,12 +319,22 @@ class InFormManager {
|
|
|
310
319
|
|
|
311
320
|
if (!this.host) {
|
|
312
321
|
this.createAndInsertShadowRootWithHost(container);
|
|
313
|
-
} else if (this.host.parentNode !== container
|
|
314
|
-
// Re-append the host when it is not the last child so it stays above overlays at equal z-index.
|
|
322
|
+
} else if (this.host.parentNode !== container) {
|
|
315
323
|
container.appendChild(this.host);
|
|
316
324
|
}
|
|
317
325
|
}
|
|
318
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Re-append the host as the last child of its container so it stays above overlays at equal z-index.
|
|
329
|
+
*/
|
|
330
|
+
reappendHost() {
|
|
331
|
+
const container = this.host?.parentNode;
|
|
332
|
+
if (!container || container.lastChild === this.host || this.shadowRoot.querySelector("iframe")) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
container.appendChild(this.host);
|
|
336
|
+
}
|
|
337
|
+
|
|
319
338
|
/**
|
|
320
339
|
* Find authentication callToActionFields in the document and set them as object properties
|
|
321
340
|
*/
|
|
@@ -327,15 +346,15 @@ class InFormManager {
|
|
|
327
346
|
* Else we clean and reset callToActionFields.
|
|
328
347
|
*/
|
|
329
348
|
const { fields: classifiedFields } = PageClassificationService.classifyPage();
|
|
330
|
-
const fields = classifiedFields.filter(({ element }) =>
|
|
349
|
+
const fields = classifiedFields.filter(({ element }) => FieldFeatureService.isFillable(element));
|
|
331
350
|
const newUsernameFields = fields.filter((field) => IDENTIFIER_ROLES.includes(field.role));
|
|
332
351
|
const newPasswordFields = fields.filter((field) => PASSWORD_ROLES.includes(field.role));
|
|
333
352
|
const newOTPFields = fields.filter((field) => field.role === FieldRole.TOTP);
|
|
334
353
|
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
354
|
+
const fieldElements = [...newUsernameFields, ...newPasswordFields, ...newOTPFields].map((field) => field.element);
|
|
355
|
+
if (fieldElements.length > 0) {
|
|
356
|
+
this.ensureHostMounted(this.getContainerElement(fieldElements));
|
|
357
|
+
}
|
|
339
358
|
|
|
340
359
|
/**
|
|
341
360
|
* A function factory to map a classified field to an existing call-to-action or create a new one.
|
|
@@ -346,7 +365,9 @@ class InFormManager {
|
|
|
346
365
|
*/
|
|
347
366
|
const mapField = (fieldType) => (field) => {
|
|
348
367
|
const existingField = this.callToActionFields.find(({ field: ctaField }) => ctaField === field.element);
|
|
349
|
-
const callToActionField =
|
|
368
|
+
const callToActionField =
|
|
369
|
+
existingField ??
|
|
370
|
+
new InFormCallToActionField(field.element, fieldType, this.shadowRoot, () => this.reappendHost());
|
|
350
371
|
callToActionField.setClassification(field.role, field.formId);
|
|
351
372
|
return callToActionField;
|
|
352
373
|
};
|
|
@@ -466,9 +487,11 @@ class InFormManager {
|
|
|
466
487
|
const belongsToDocument = parent?.ownerDocument === document;
|
|
467
488
|
const isConnected = parent?.isConnected ?? false;
|
|
468
489
|
const isInBody = parent === document.body;
|
|
490
|
+
// On a frameset page the host is mounted under <html>, next to the frameset.
|
|
491
|
+
const isInFramesetRoot = document.body?.nodeName === "FRAMESET" && parent === document.documentElement;
|
|
469
492
|
const isInDialog = parent?.nodeName === "DIALOG";
|
|
470
493
|
|
|
471
|
-
return belongsToDocument && isConnected && (isInBody || isInDialog);
|
|
494
|
+
return belongsToDocument && isConnected && (isInBody || isInFramesetRoot || isInDialog);
|
|
472
495
|
}
|
|
473
496
|
|
|
474
497
|
/**
|
|
@@ -476,7 +499,7 @@ class InFormManager {
|
|
|
476
499
|
* @returns {boolean}
|
|
477
500
|
*/
|
|
478
501
|
_ensureHostIntegrity() {
|
|
479
|
-
if (this.isHostInValidLocation()) {
|
|
502
|
+
if (!this.host || this.isHostInValidLocation()) {
|
|
480
503
|
return true;
|
|
481
504
|
}
|
|
482
505
|
this.retryMountHost();
|
|
@@ -962,7 +985,7 @@ class InFormManager {
|
|
|
962
985
|
window.removeEventListener("resize", this.clean);
|
|
963
986
|
document.removeEventListener("cut", this.handleClipboardChange);
|
|
964
987
|
document.removeEventListener("copy", this.handleClipboardChange);
|
|
965
|
-
this.host
|
|
988
|
+
this.host?.remove();
|
|
966
989
|
}
|
|
967
990
|
|
|
968
991
|
/**
|