diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json
index 5244fed76ef..f5b3e798aff 100644
--- a/apps/browser/src/_locales/en/messages.json
+++ b/apps/browser/src/_locales/en/messages.json
@@ -1965,13 +1965,9 @@
"apiKey": {
"message": "API Key"
},
- "accountId": {
- "message": "Account ID",
- "description": "ID is short for 'Identifier'"
- },
"ssoKeyConnectorError": {
"message": "Key Connector error: make sure Key Connector is available and working correctly."
- },
+ },
"premiumSubcriptionRequired": {
"message": "Premium subscription required"
},
diff --git a/apps/browser/src/popup/generator/generator.component.html b/apps/browser/src/popup/generator/generator.component.html
index 5a9a067a4e1..c3ae6c6ab53 100644
--- a/apps/browser/src/popup/generator/generator.component.html
+++ b/apps/browser/src/popup/generator/generator.component.html
@@ -401,21 +401,11 @@
-
-
-
-
diff --git a/apps/desktop/src/app/vault/generator.component.html b/apps/desktop/src/app/vault/generator.component.html
index 79e66ae5366..6fdd33f0fab 100644
--- a/apps/desktop/src/app/vault/generator.component.html
+++ b/apps/desktop/src/app/vault/generator.component.html
@@ -434,21 +434,11 @@
-
-
-
-
diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json
index 04fd939c77c..e399281c061 100644
--- a/apps/desktop/src/locales/en/messages.json
+++ b/apps/desktop/src/locales/en/messages.json
@@ -1982,10 +1982,6 @@
"premiumSubcriptionRequired": {
"message": "Premium subscription required"
},
- "accountId": {
- "message": "Account ID",
- "description": "ID is short for 'Identifier'"
- },
"organizationIsDisabled": {
"message": "Organization is disabled."
},
diff --git a/apps/web/src/app/tools/generator.component.html b/apps/web/src/app/tools/generator.component.html
index 67d23e61463..542c0c3c5e3 100644
--- a/apps/web/src/app/tools/generator.component.html
+++ b/apps/web/src/app/tools/generator.component.html
@@ -354,16 +354,6 @@
(blur)="saveUsernameOptions()"
/>
-
-
-
-
diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json
index fa2a98f4e54..0e711752773 100644
--- a/apps/web/src/locales/en/messages.json
+++ b/apps/web/src/locales/en/messages.json
@@ -5312,9 +5312,5 @@
},
"numberOfUsers": {
"message": "Number of users"
- },
- "accountId": {
- "message": "Account ID",
- "description": "ID is short for 'Identifier'"
}
}
diff --git a/libs/angular/src/components/generator.component.ts b/libs/angular/src/components/generator.component.ts
index 15905632e45..90e5864dcbf 100644
--- a/libs/angular/src/components/generator.component.ts
+++ b/libs/angular/src/components/generator.component.ts
@@ -74,7 +74,7 @@ export class GeneratorComponent implements OnInit {
{ name: "SimpleLogin", value: "simplelogin" },
{ name: "AnonAddy", value: "anonaddy" },
{ name: "Firefox Relay", value: "firefoxrelay" },
- { name: "FastMail", value: "fastmail" },
+ { name: "Fastmail", value: "fastmail" },
{ name: "DuckDuckGo", value: "duckduckgo" },
];
}
diff --git a/libs/common/src/emailForwarders/fastmailForwarder.ts b/libs/common/src/emailForwarders/fastmailForwarder.ts
index 9e7dcbb7467..545a0c700a0 100644
--- a/libs/common/src/emailForwarders/fastmailForwarder.ts
+++ b/libs/common/src/emailForwarders/fastmailForwarder.ts
@@ -8,9 +8,12 @@ export class FastmailForwarder implements Forwarder {
if (options.apiKey == null || options.apiKey === "") {
throw "Invalid Fastmail API token.";
}
- if (options?.fastmail.accountId == null || options.fastmail.accountId === "") {
- throw "Invalid Fastmail account ID.";
+
+ const accountId = await this.getAccountId(apiService, options);
+ if (accountId == null || accountId === "") {
+ throw "Unable to obtain Fastmail masked email account ID.";
}
+
const requestInit: RequestInit = {
redirect: "manual",
cache: "no-store",
@@ -27,13 +30,11 @@ export class FastmailForwarder implements Forwarder {
[
"MaskedEmail/set",
{
- accountId: "u" + options.fastmail.accountId,
+ accountId: accountId,
create: {
"new-masked-email": {
state: "enabled",
- description:
- (options.website != null ? options.website + " - " : "") +
- "Generated by Bitwarden",
+ description: "",
url: options.website,
emailPrefix: options.fastmail.prefix,
},
@@ -59,9 +60,29 @@ export class FastmailForwarder implements Forwarder {
}
}
}
- if (response.status === 401) {
+ if (response.status === 401 || response.status === 403) {
throw "Invalid Fastmail API token.";
}
throw "Unknown Fastmail error occurred.";
}
+
+ private async getAccountId(apiService: ApiService, options: ForwarderOptions): Promise {
+ const requestInit: RequestInit = {
+ cache: "no-store",
+ method: "GET",
+ headers: new Headers({
+ Authorization: "Bearer " + options.apiKey,
+ }),
+ };
+ const url = "https://api.fastmail.com/.well-known/jmap";
+ const request = new Request(url, requestInit);
+ const response = await apiService.nativeFetch(request);
+ if (response.status === 200) {
+ const json = await response.json();
+ if (json.primaryAccounts != null) {
+ return json.primaryAccounts["https://www.fastmail.com/dev/maskedemail"];
+ }
+ }
+ return null;
+ }
}
diff --git a/libs/common/src/emailForwarders/forwarderOptions.ts b/libs/common/src/emailForwarders/forwarderOptions.ts
index 7482f82e496..ef5311f0d7d 100644
--- a/libs/common/src/emailForwarders/forwarderOptions.ts
+++ b/libs/common/src/emailForwarders/forwarderOptions.ts
@@ -6,7 +6,6 @@ export class ForwarderOptions {
}
export class FastmailForwarderOptions {
- accountId: string;
prefix: string;
}
diff --git a/libs/common/src/services/usernameGeneration.service.ts b/libs/common/src/services/usernameGeneration.service.ts
index 3ad2c513403..7a5abd4f7de 100644
--- a/libs/common/src/services/usernameGeneration.service.ts
+++ b/libs/common/src/services/usernameGeneration.service.ts
@@ -131,7 +131,6 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
} else if (o.forwardedService === "fastmail") {
forwarder = new FastmailForwarder();
forwarderOptions.apiKey = o.forwardedFastmailApiToken;
- forwarderOptions.fastmail.accountId = o.forwardedFastmailAccountId;
} else if (o.forwardedService === "duckduckgo") {
forwarder = new DuckDuckGoForwarder();
forwarderOptions.apiKey = o.forwardedDuckDuckGoToken;