Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-129] Refactor email forwarding providers to remove filtering for self-hosted #4963

Merged
merged 6 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions apps/web/src/app/tools/generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,8 @@ export class GeneratorComponent extends BaseGeneratorComponent {
window
);
if (platformUtilsService.isSelfHost()) {
// Cannot use Firefox Relay on self hosted web vaults due to CORS issues with Firefox Relay API
this.forwardOptions.splice(
this.forwardOptions.findIndex((o) => o.value === "firefoxrelay"),
1
);
// Also cannot use Duck Duck Go on self hosted web vaults due to CORS issues
this.forwardOptions.splice(
this.forwardOptions.findIndex((o) => o.value === "duckduckgo"),
1
);
// Allow only valid email forwarders for self host
this.forwardOptions = this.forwardOptions.filter((forwarder) => forwarder.validForSelfHosted);
}
}

Expand Down
15 changes: 8 additions & 7 deletions libs/angular/src/components/generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwo
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { UsernameGenerationService } from "@bitwarden/common/abstractions/usernameGeneration.service";
import { EmailForwarderOptions } from "@bitwarden/common/models/domain/email-forwarder-options";
import { PasswordGeneratorPolicyOptions } from "@bitwarden/common/models/domain/password-generator-policy-options";

@Directive()
Expand All @@ -22,7 +23,7 @@ export class GeneratorComponent implements OnInit {
usernameTypeOptions: any[];
subaddressOptions: any[];
catchallOptions: any[];
forwardOptions: any[];
forwardOptions: EmailForwarderOptions[];
usernameOptions: any = {};
passwordOptions: any = {};
username = "-";
Expand Down Expand Up @@ -236,19 +237,19 @@ export class GeneratorComponent implements OnInit {

private async initForwardOptions() {
this.forwardOptions = [
{ name: "AnonAddy", value: "anonaddy" },
{ name: "DuckDuckGo", value: "duckduckgo" },
{ name: "Fastmail", value: "fastmail" },
{ name: "Firefox Relay", value: "firefoxrelay" },
{ name: "SimpleLogin", value: "simplelogin" },
{ name: "AnonAddy", value: "anonaddy", validForSelfHosted: true },
{ name: "DuckDuckGo", value: "duckduckgo", validForSelfHosted: false },
{ name: "Fastmail", value: "fastmail", validForSelfHosted: true },
{ name: "Firefox Relay", value: "firefoxrelay", validForSelfHosted: false },
{ name: "SimpleLogin", value: "simplelogin", validForSelfHosted: true },
];

this.usernameOptions = await this.usernameGenerationService.getOptions();
if (
this.usernameOptions.forwardedService == null ||
this.usernameOptions.forwardedService === ""
) {
this.forwardOptions.push({ name: "", value: null });
this.forwardOptions.push({ name: "", value: null, validForSelfHosted: false });
}

this.forwardOptions = this.forwardOptions.sort((a, b) => a.name.localeCompare(b.name));
Expand Down
5 changes: 5 additions & 0 deletions libs/common/src/models/domain/email-forwarder-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class EmailForwarderOptions {
name: string;
value: string;
validForSelfHosted: boolean;
}