mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
[PS-1302] added duckduckgo's email forwarding service 🦆 (#3306)
* added duckduckgo's email forwarding * removed unnecessary excxeption * renamed "Private Duck Address" to "DuckDuckGo" Co-authored-by: Dattito <github@relay.datti.to>
This commit is contained in:
@@ -349,6 +349,18 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
<ng-container *ngIf="usernameOptions.forwardedService === 'duckduckgo'">
|
||||||
|
<div class="box-content-row" appBoxRow>
|
||||||
|
<label for="duckduckgo-apikey">{{ "apiKey" | i18n }}</label>
|
||||||
|
<input
|
||||||
|
id="duckduckgo-apikey"
|
||||||
|
type="password"
|
||||||
|
name="DuckDudkGoApiKey"
|
||||||
|
[(ngModel)]="usernameOptions.forwardedDuckDuckGoToken"
|
||||||
|
(blur)="saveUsernameOptions()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
<ng-container *ngIf="usernameOptions.forwardedService === 'anonaddy'">
|
<ng-container *ngIf="usernameOptions.forwardedService === 'anonaddy'">
|
||||||
<div class="box-content-row" appBoxRow>
|
<div class="box-content-row" appBoxRow>
|
||||||
<label for="anonaddy-accessToken">{{ "apiAccessToken" | i18n }}</label>
|
<label for="anonaddy-accessToken">{{ "apiAccessToken" | i18n }}</label>
|
||||||
|
|||||||
@@ -382,6 +382,18 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
<ng-container *ngIf="usernameOptions.forwardedService === 'duckduckgo'">
|
||||||
|
<div class="box-content-row" appBoxRow>
|
||||||
|
<label for="duckduckgo-apikey">{{ "apiKey" | i18n }}</label>
|
||||||
|
<input
|
||||||
|
id="duckduckgo-apikey"
|
||||||
|
type="password"
|
||||||
|
name="DuckDudkGoApiKey"
|
||||||
|
[(ngModel)]="usernameOptions.forwardedDuckDuckGoToken"
|
||||||
|
(blur)="saveUsernameOptions()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
<ng-container *ngIf="usernameOptions.forwardedService === 'anonaddy'">
|
<ng-container *ngIf="usernameOptions.forwardedService === 'anonaddy'">
|
||||||
<div class="box-content-row" appBoxRow>
|
<div class="box-content-row" appBoxRow>
|
||||||
<label for="anonaddy-accessToken">{{ "apiAccessToken" | i18n }}</label>
|
<label for="anonaddy-accessToken">{{ "apiAccessToken" | i18n }}</label>
|
||||||
|
|||||||
@@ -296,6 +296,19 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row" *ngIf="usernameOptions.forwardedService === 'duckduckgo'">
|
||||||
|
<div class="form-group col-4">
|
||||||
|
<label for="duckduckgo-apikey">{{ "apiKey" | i18n }}</label>
|
||||||
|
<input
|
||||||
|
id="duckduckgo-apikey"
|
||||||
|
class="form-control"
|
||||||
|
type="password"
|
||||||
|
name="DuckDudkGoApiKey"
|
||||||
|
[(ngModel)]="usernameOptions.forwardedDuckDuckGoToken"
|
||||||
|
(blur)="saveUsernameOptions()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row" *ngIf="usernameOptions.forwardedService === 'anonaddy'">
|
<div class="row" *ngIf="usernameOptions.forwardedService === 'anonaddy'">
|
||||||
<div class="form-group col-4">
|
<div class="form-group col-4">
|
||||||
<label for="anonaddy-apikey">{{ "apiAccessToken" | i18n }}</label>
|
<label for="anonaddy-apikey">{{ "apiAccessToken" | i18n }}</label>
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ const devServer =
|
|||||||
https://*.braintree-api.com
|
https://*.braintree-api.com
|
||||||
https://*.blob.core.windows.net
|
https://*.blob.core.windows.net
|
||||||
https://app.simplelogin.io/api/alias/random/new
|
https://app.simplelogin.io/api/alias/random/new
|
||||||
|
https://quack.duckduckgo.com/api/email/addresses
|
||||||
https://app.anonaddy.com/api/v1/aliases;
|
https://app.anonaddy.com/api/v1/aliases;
|
||||||
object-src
|
object-src
|
||||||
'self'
|
'self'
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ export class GeneratorComponent implements OnInit {
|
|||||||
{ name: "SimpleLogin", value: "simplelogin" },
|
{ name: "SimpleLogin", value: "simplelogin" },
|
||||||
{ name: "AnonAddy", value: "anonaddy" },
|
{ name: "AnonAddy", value: "anonaddy" },
|
||||||
{ name: "Firefox Relay", value: "firefoxrelay" },
|
{ name: "Firefox Relay", value: "firefoxrelay" },
|
||||||
|
{ name: "DuckDuckGo", value: "duckduckgo" },
|
||||||
// { name: "FastMail", value: "fastmail" },
|
// { name: "FastMail", value: "fastmail" },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.generateFirefoxRelayAlias(o.forwardedFirefoxApiToken, o.website);
|
return this.generateFirefoxRelayAlias(o.forwardedFirefoxApiToken, o.website);
|
||||||
|
} else if (o.forwardedService === "duckduckgo") {
|
||||||
|
if (o.forwardedDuckDuckGoToken == null || o.forwardedDuckDuckGoToken === "") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.generateDuckDuckGoAlias(o.forwardedDuckDuckGoToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -274,4 +279,31 @@ export class UsernameGenerationService implements BaseUsernameGenerationService
|
|||||||
}
|
}
|
||||||
throw "Unknown Firefox Relay error occurred.";
|
throw "Unknown Firefox Relay error occurred.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async generateDuckDuckGoAlias(apiToken: string): Promise<string> {
|
||||||
|
if (apiToken == null || apiToken === "") {
|
||||||
|
throw "Invalid DuckDuckGo API token.";
|
||||||
|
}
|
||||||
|
const requestInit: RequestInit = {
|
||||||
|
redirect: "manual",
|
||||||
|
cache: "no-store",
|
||||||
|
method: "POST",
|
||||||
|
headers: new Headers({
|
||||||
|
Authorization: "Bearer " + apiToken,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
const url = "https://quack.duckduckgo.com/api/email/addresses";
|
||||||
|
const request = new Request(url, requestInit);
|
||||||
|
const response = await this.apiService.nativeFetch(request);
|
||||||
|
if (response.status === 200 || response.status === 201) {
|
||||||
|
const json = await response.json();
|
||||||
|
if (json.address) {
|
||||||
|
return `${json.address}@duck.com`;
|
||||||
|
}
|
||||||
|
} else if (response.status === 401) {
|
||||||
|
throw "Invalid DuckDuckGo API token.";
|
||||||
|
}
|
||||||
|
throw "Unknown DuckDuckGo error occurred.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user