Skip to content

Commit

Permalink
Merge branch 'PB-34201_11-Prepare-windows-app-code_Pierre-Colart' int…
Browse files Browse the repository at this point in the history
…o 'release'

Pb 34201 11 prepare windows app code pierre colart

See merge request passbolt/desktop/passbolt-windows!152
  • Loading branch information
scadra committed Jul 25, 2024
2 parents 880fb79 + d636379 commit 3d35f07
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 65 deletions.
5 changes: 4 additions & 1 deletion passbolt/Models/Messaging/AllowedTopics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public class AllowedTopics
public const string BACKGROUND_SET_THEME = "passbolt.background.set-theme";
public const string BACKGROUND_SET_SECURITY_TOKEN = "passbolt.background.set-security-token";
public const string BACKGROUND_SET_LOCALE = "passbolt.background.set-locale";
public const string BACKGROUND_AUTHENTICATION_ERROR = "passbolt.background.authentication-error";
public const string RENDERED_READY = "passbolt.rendered.is-ready";
public const string RENDERED_STARTED = "passbolt.rendered.started";
public const string BACKGROUND_GET_COOKIE = "passbolt.background.get-cookie";
public const string BACKGROUND_ROTATE_KEY = "passbolt.background.rotate-private-key";
public const string RENDERED_RELOAD = "passbolt.tab.reload";

private static List<string> topics = new List<string>() { BACKGROUND_READY, ERROR, BACKGROUND_DOWNLOAD_FILE, BACKGROUND_STORE_PASSPHRASE, BACKGROUND_SET_THEME, BACKGROUND_SET_SECURITY_TOKEN, BACKGROUND_SET_LOCALE, RENDERED_READY, BACKGROUND_AFTER_LOGOUT, BACKGROUND_GET_COOKIE, BACKGROUND_ROTATE_KEY };
private static List<string> topics = new List<string>() { BACKGROUND_READY, ERROR, BACKGROUND_DOWNLOAD_FILE, BACKGROUND_STORE_PASSPHRASE, BACKGROUND_SET_THEME, BACKGROUND_SET_SECURITY_TOKEN, BACKGROUND_SET_LOCALE, RENDERED_READY, BACKGROUND_AFTER_LOGOUT, BACKGROUND_GET_COOKIE, BACKGROUND_ROTATE_KEY, BACKGROUND_AUTHENTICATION_ERROR, RENDERED_RELOAD, RENDERED_STARTED };
private static List<string> requestIds = new List<string>();
private static Dictionary<string, string> pendingRequests = new Dictionary<string, string>();

Expand Down
3 changes: 2 additions & 1 deletion passbolt/Models/Messaging/Topics/GroupTopics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class GroupTopics
public const string CREATE = "passbolt.groups.create";
public const string UPDATE = "passbolt.groups.update";
public const string DELETE = "passbolt.groups.delete";
public const string DELETE_DRY_RUN = "passbolt.groups.delete-dry-run";
public const string DELETE_DRY_RUN = "passbolt.groups.delete-dry-run";
public const string FIND_MY_GROUPS = "passbolt.groups.find-my-groups";
}
}
3 changes: 2 additions & 1 deletion passbolt/Models/Messaging/Topics/ResourceTopics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ResourceTopics
public const string DELETE_ALL = "passbolt.resources.delete-all";
public const string GET_ALL = "passbolt.resource-type.get-all";
public const string GET_GRID_SETTING = "passbolt.resources.get-grid-setting";
public const string SET_GRID_SETTING = "passbolt.resources.set-grid-setting";
public const string SET_GRID_SETTING = "passbolt.resources.set-grid-setting";
public const string FIND_DETAILS = "passbolt.resources.find-details";
}
}
11 changes: 11 additions & 0 deletions passbolt/Models/Messaging/Webviews/BackgroundTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ public async override void ProceedMessage(IPC ipc)
await localFolderService.CreateBackgroundIndex(this.currentIndexBackground, "background-auth", metaData.domain);
background.Source = new Uri(UriBuilderHelper.BuildHostUri(backgroundUrl, "/index-auth.html"));
break;
case AllowedTopics.BACKGROUND_AUTHENTICATION_ERROR:
//This case can happen when a certificate and/or the API cannot be reached. In this case we cancel the account saving and redirect background to import
if(currentIndexRendered == "index-import.html" && currentIndexBackground == "index-auth.html")
{
await this.credentialLockerService.Remove("account-metadata");
await this.credentialLockerService.Remove("account-secret");
await localFolderService.RemoveFile("Background", "index-auth.html");
await localFolderService.CreateBackgroundIndex(this.currentIndexBackground, "background-import");
background.Source = new Uri(UriBuilderHelper.BuildHostUri(BackgroundNavigationService.Instance.trustedUrl, "/Background/index-import.html"));
}
break;
case AllowedTopics.BACKGROUND_DOWNLOAD_FILE:
var downloadService = new DownloadService();
await downloadService.Download(ipc);
Expand Down
39 changes: 27 additions & 12 deletions passbolt/Models/Messaging/Webviews/RenderedTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace passbolt.Models.Messaging
{
public class RenderedTopic : WebviewTopic
{
private List<string> topics = new List<string>();
private List<string> topics = new List<string>();
private bool isRefreshed = false;

public RenderedTopic(WebView2 background, WebView2 rendered, LocalFolderService localFolderService, RenderedWebviewService renderedWebviewService) : base(background, rendered, localFolderService, renderedWebviewService) {
topics.AddRange(ListHelper.GetClassContantsToList(typeof(AccountRecoveryTopics)));
Expand All @@ -41,7 +42,7 @@ public RenderedTopic(WebView2 background, WebView2 rendered, LocalFolderService
topics.AddRange(ListHelper.GetClassContantsToList(typeof(LocaleTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(KeyringTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(MfaTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PownedPasswordTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PownedPasswordTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PasswordExpiryTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PasswordGeneratorTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PasswordPoliciesTopics)));
Expand All @@ -51,11 +52,13 @@ public RenderedTopic(WebView2 background, WebView2 rendered, LocalFolderService
topics.AddRange(ListHelper.GetClassContantsToList(typeof(SecretTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(SettingTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(ShareTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(TagTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(TagTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(ThemeTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(UserTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(UserTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(UserTopics)));
topics.Add(AllowedTopics.RENDERED_READY);
topics.Add(AllowedTopics.RENDERED_RELOAD);
topics.Add(AllowedTopics.RENDERED_STARTED);
}


Expand All @@ -69,7 +72,7 @@ public override async void ProceedMessage(IPC ipc)
{
new UnauthorizedTopicException("Rendered webview");
return;
}
}
else if (CanOpenToBrowser(ipc))
{
var url = (string)ipc.message;
Expand All @@ -78,14 +81,26 @@ public override async void ProceedMessage(IPC ipc)
else if (topics.Contains(ipc.topic))
{
AllowedTopics.AddRequestId(ipc.requestId);
}

if (ipc.topic == RbacTopics.FIND_ME)
{
//We intercept the requestId and save it to map the response
AllowedTopics.AddPendingRequest(ipc.requestId, RbacTopics.FIND_ME);
}

if(ipc.topic == AllowedTopics.RENDERED_STARTED)
{
if(this.isRefreshed)
{
rendered.CoreWebView2.PostWebMessageAsJson(SerializationHelper.SerializeToJson(new IPC(AllowedTopics.BACKGROUND_READY)));
this.isRefreshed = false;
}
}
if (ipc.topic == RbacTopics.FIND_ME)
{
//We intercept the requestId and save it to map the response
AllowedTopics.AddPendingRequest(ipc.requestId, RbacTopics.FIND_ME);
}
if(ipc.topic == AllowedTopics.RENDERED_RELOAD)
{
rendered.CoreWebView2.Reload();
this.isRefreshed = true;
return;
}

background.CoreWebView2.PostWebMessageAsJson(SerializationHelper.SerializeToJson(ipc));
}
Expand Down
1 change: 1 addition & 0 deletions passbolt/Webviews/Background/index-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import './src/polyfill/browserPolyfill';
import "./src/polyfill/commandPolyfill"
import './src/polyfill/desktopPolyfill';
import './src/polyfill/storagePolyfill';
import './src/polyfill/runtimePolyfill';
Expand Down
1 change: 1 addition & 0 deletions passbolt/Webviews/Background/index-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import './src/polyfill/browserPolyfill';
import "./src/polyfill/commandPolyfill"
import './src/polyfill/desktopPolyfill';
import './src/polyfill/storagePolyfill';
import './src/polyfill/runtimePolyfill';
Expand Down
1 change: 1 addition & 0 deletions passbolt/Webviews/Background/index-workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import './src/polyfill/browserPolyfill';
import "./src/polyfill/commandPolyfill"
import './src/polyfill/desktopPolyfill';
import './src/polyfill/storagePolyfill';
import './src/polyfill/runtimePolyfill';
Expand Down
56 changes: 28 additions & 28 deletions passbolt/Webviews/Background/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions passbolt/Webviews/Background/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@babel/preset-react": "^7.22.15",
"buffer": "^6.0.3",
"openpgp": "^5.11.1",
"passbolt-browser-extension": "4.8.2",
"passbolt-styleguide": "4.8.0",
"passbolt-browser-extension": "4.9.1",
"passbolt-styleguide": "4.9.3",
"setimmediate": "^1.0.5",
"stream-browserify": "^3.0.0",
"validator": "^13.7.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import {Config} from "passbolt-browser-extension/src/all/background_page/model/config";
import {REQUIRE_MFA, USER_LOGGED_IN} from "../enumerations/appEventEnumeration";
import {BACKGROUND_AUTHENTICATION_ERROR, REQUIRE_MFA, USER_LOGGED_IN} from "../enumerations/appEventEnumeration";
import LoginUserService from "../services/loginUserService";
import OrganizationSettingsModel from "passbolt-browser-extension/src/all/background_page/model/organizationSettings/organizationSettingsModel";

Expand Down Expand Up @@ -47,6 +47,7 @@ class DesktopAuthenticateController {
} catch (error) {
console.error(error);
this.worker.port.emit(this.requestId, 'ERROR', error);
this.worker.port.emit(BACKGROUND_AUTHENTICATION_ERROR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {v4 as uuidv4} from "uuid";
import VerifyAccountKitController from "./verifyAccountKitController";
import AuthImportStorageService from "../services/authImportStorageService";
import AuthImportEntity from "../entity/AuthImportEntity/authImportEntity";
import {pgpKeys} from "passbolt-browser-extension/test/fixtures/pgpKeys/keys";
import {pgpKeys} from "passbolt-styleguide/test/fixture/pgpKeys/keys";
import {defaultData} from "../services/verifyAccountKitService.test.data";

describe('VerifyAccountKitController', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
export const USER_LOGGED_IN = "passbolt.auth.after-login";
export const USER_LOGGED_OUT = "passbolt.auth.logout";
export const BACKGROUND_READY = "passbolt.background.is-ready";
export const BACKGROUND_AUTHENTICATION_ERROR = "passbolt.background.authentication-error";
export const BACKGROUND_IMPORT = "passbolt.background.import";
export const ERROR = "passbolt.error";
export const LOCALSTORAGE_UPDATE = "passbolt.background.localstorage-update";
Expand Down
2 changes: 1 addition & 1 deletion passbolt/Webviews/Background/src/polyfill/alarmPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class AlarmsPolyfill {
/**
* Class representing an alarm event.
*/
class OnAlarmEvent {
export class OnAlarmEvent {
/**
* Create a new OnAlarmEvent object.
*/
Expand Down
26 changes: 26 additions & 0 deletions passbolt/Webviews/Background/src/polyfill/commandPolyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.passbolt.com Passbolt(tm)
* @since 1.3.0
*/

import { OnAlarmEvent } from "./alarmPolyfill"

/**
* Polyfill to mock the commands API from browser extension
*/
export default class CommandsPolyfill {
constructor() {
this.onCommand = new OnAlarmEvent()
}
}

window.chrome.commands = new CommandsPolyfill()
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import {defaultAccountDto} from "passbolt-browser-extension/src/all/background_page/model/entity/account/accountEntity.test.data";
import VerifyAccountKitService from "./verifyAccountKitService";
import {defaultData} from "./verifyAccountKitService.test.data";
import {pgpKeys} from "passbolt-browser-extension/test/fixtures/pgpKeys/keys";
import {pgpKeys} from "passbolt-styleguide/test/fixture/pgpKeys/keys";

describe('VerifyAccountKitService', () => {
let verifyAccountKitService;
Expand Down
1 change: 1 addition & 0 deletions passbolt/Webviews/Background/test/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./polyfill/chromePolyfill"
import "../src/polyfill/alarmPolyfill"
import "../src/polyfill/commandPolyfill"
import "../src/polyfill/desktopPolyfill"
import "../src/polyfill/runtimePolyfill"
import "../src/polyfill/storagePolyfill"
Expand Down
Loading

0 comments on commit 3d35f07

Please sign in to comment.