1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-13 01:58:44 +02:00

Forwardfix (#803)

* fix default forwardedService property name

* fixes to apis for forwarding services
This commit is contained in:
Kyle Spearrin 2022-05-13 10:40:41 -04:00 committed by GitHub
parent de2eb0359b
commit 65584c6496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,11 +112,7 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
if (o.forwardedSimpleLoginApiKey == null || o.forwardedSimpleLoginApiKey === "") { if (o.forwardedSimpleLoginApiKey == null || o.forwardedSimpleLoginApiKey === "") {
return null; return null;
} }
return this.generateSimpleLoginAlias( return this.generateSimpleLoginAlias(o.forwardedSimpleLoginApiKey, o.website);
o.forwardedSimpleLoginApiKey,
o.forwardedSimpleLoginHostname,
o.website
);
} else if (o.forwardedService === "anonaddy") { } else if (o.forwardedService === "anonaddy") {
if ( if (
o.forwardedAnonAddyApiToken == null || o.forwardedAnonAddyApiToken == null ||
@ -173,15 +169,12 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
: new Array(width - number.length + 1).join("0") + number; : new Array(width - number.length + 1).join("0") + number;
} }
private async generateSimpleLoginAlias( private async generateSimpleLoginAlias(apiKey: string, website: string): Promise<string> {
apiKey: string,
hostname: string,
websiteNote: string
): Promise<string> {
if (apiKey == null || apiKey === "") { if (apiKey == null || apiKey === "") {
throw "Invalid SimpleLogin API key."; throw "Invalid SimpleLogin API key.";
} }
const requestInit: RequestInit = { const requestInit: RequestInit = {
redirect: "manual",
cache: "no-store", cache: "no-store",
method: "POST", method: "POST",
headers: new Headers({ headers: new Headers({
@ -190,12 +183,11 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
}), }),
}; };
let url = "https://app.simplelogin.io/api/alias/random/new"; let url = "https://app.simplelogin.io/api/alias/random/new";
if (hostname != null) { if (website != null) {
url += "?hostname=" + hostname; url += "?hostname=" + website;
} }
requestInit.body = JSON.stringify({ requestInit.body = JSON.stringify({
note: note: (website != null ? "Website: " + website + ". " : "") + "Generated by Bitwarden.",
(websiteNote != null ? "Website: " + websiteNote + ". " : "") + "Generated by Bitwarden.",
}); });
const request = new Request(url, requestInit); const request = new Request(url, requestInit);
const response = await this.apiService.nativeFetch(request); const response = await this.apiService.nativeFetch(request);
@ -226,6 +218,7 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
throw "Invalid AnonAddy API token."; throw "Invalid AnonAddy API token.";
} }
const requestInit: RequestInit = { const requestInit: RequestInit = {
redirect: "manual",
cache: "no-store", cache: "no-store",
method: "POST", method: "POST",
headers: new Headers({ headers: new Headers({
@ -256,6 +249,7 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
throw "Invalid Firefox Relay API token."; throw "Invalid Firefox Relay API token.";
} }
const requestInit: RequestInit = { const requestInit: RequestInit = {
redirect: "manual",
cache: "no-store", cache: "no-store",
method: "POST", method: "POST",
headers: new Headers({ headers: new Headers({