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
1 changed files with 8 additions and 14 deletions

View File

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