mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
Add Web Push Support (#11346)
* WIP: PoC with lots of terrible code with web push * fix service worker building * Work on WebPush Tailored to Browser * Clean Up Web And MV2 * Fix Merge Conflicts * Prettier * Use Unsupported for MV2 * Add Doc Comments * Remove Permission Button * Fix Type Test * Write Time In More Readable Format * Add SignalR Logger * `sheduleReconnect` -> `scheduleReconnect` Co-authored-by: Matt Gibson <mgibson@bitwarden.com> * Capture Support Context In Connector * Remove Unneeded CSP Change * Fix Build * Simplify `getOrCreateSubscription` * Add More Docs to Matrix * Update libs/common/src/platform/notifications/internal/worker-webpush-connection.service.ts Co-authored-by: Matt Gibson <mgibson@bitwarden.com> * Move API Service Into Notifications Folder * Allow Connection When Account Is Locked * Add Comments to NotificationsService * Only Change Support Status If Public Key Changes * Move Service Choice Out To Method * Use Named Constant For Disabled Notification Url * Add Test & Cleanup * Flatten * Move Tests into `beforeEach` & `afterEach` * Add Tests * Test `distinctUntilChanged`'s Operators More * Make Helper And Cleanup Chain * Add Back Cast * Add extra safety to incoming config check * Put data through response object * Apply TS Strict Rules * Finish PushTechnology comment * Use `instanceof` check * Do Safer Worker Based Registration for MV3 * Remove TODO * Switch to SignalR on any WebPush Error * Fix Manifest Permissions * Add Back `webNavigation` * Sorry, Remove `webNavigation` * Fixed merge conflicts. --------- Co-authored-by: Matt Gibson <mgibson@bitwarden.com> Co-authored-by: Todd Martin <tmartin@bitwarden.com> Co-authored-by: Todd Martin <106564991+trmartin4@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { PushTechnology } from "../../../enums/push-technology.enum";
|
||||
import { Region } from "../../abstractions/environment.service";
|
||||
|
||||
import {
|
||||
@@ -29,6 +30,9 @@ describe("ServerConfigData", () => {
|
||||
},
|
||||
utcDate: "2020-01-01T00:00:00.000Z",
|
||||
featureStates: { feature: "state" },
|
||||
push: {
|
||||
pushTechnology: PushTechnology.SignalR,
|
||||
},
|
||||
};
|
||||
const serverConfigData = ServerConfigData.fromJSON(json);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
ServerConfigResponse,
|
||||
ThirdPartyServerConfigResponse,
|
||||
EnvironmentServerConfigResponse,
|
||||
PushSettingsConfigResponse,
|
||||
} from "../response/server-config.response";
|
||||
|
||||
export class ServerConfigData {
|
||||
@@ -18,6 +19,7 @@ export class ServerConfigData {
|
||||
environment?: EnvironmentServerConfigData;
|
||||
utcDate: string;
|
||||
featureStates: { [key: string]: AllowedFeatureFlagTypes } = {};
|
||||
push: PushSettingsConfigData;
|
||||
settings: ServerSettings;
|
||||
|
||||
constructor(serverConfigResponse: Partial<ServerConfigResponse>) {
|
||||
@@ -32,6 +34,9 @@ export class ServerConfigData {
|
||||
: null;
|
||||
this.featureStates = serverConfigResponse?.featureStates;
|
||||
this.settings = new ServerSettings(serverConfigResponse.settings);
|
||||
this.push = serverConfigResponse?.push
|
||||
? new PushSettingsConfigData(serverConfigResponse.push)
|
||||
: null;
|
||||
}
|
||||
|
||||
static fromJSON(obj: Jsonify<ServerConfigData>): ServerConfigData {
|
||||
@@ -42,6 +47,20 @@ export class ServerConfigData {
|
||||
}
|
||||
}
|
||||
|
||||
export class PushSettingsConfigData {
|
||||
pushTechnology: number;
|
||||
vapidPublicKey?: string;
|
||||
|
||||
constructor(response: Partial<PushSettingsConfigResponse>) {
|
||||
this.pushTechnology = response.pushTechnology;
|
||||
this.vapidPublicKey = response.vapidPublicKey;
|
||||
}
|
||||
|
||||
static fromJSON(obj: Jsonify<PushSettingsConfigData>): PushSettingsConfigData {
|
||||
return Object.assign(new PushSettingsConfigData({}), obj);
|
||||
}
|
||||
}
|
||||
|
||||
export class ThirdPartyServerConfigData {
|
||||
name: string;
|
||||
url: string;
|
||||
|
||||
@@ -11,6 +11,7 @@ export class ServerConfigResponse extends BaseResponse {
|
||||
server: ThirdPartyServerConfigResponse;
|
||||
environment: EnvironmentServerConfigResponse;
|
||||
featureStates: { [key: string]: AllowedFeatureFlagTypes } = {};
|
||||
push: PushSettingsConfigResponse;
|
||||
settings: ServerSettings;
|
||||
|
||||
constructor(response: any) {
|
||||
@@ -25,10 +26,27 @@ export class ServerConfigResponse extends BaseResponse {
|
||||
this.server = new ThirdPartyServerConfigResponse(this.getResponseProperty("Server"));
|
||||
this.environment = new EnvironmentServerConfigResponse(this.getResponseProperty("Environment"));
|
||||
this.featureStates = this.getResponseProperty("FeatureStates");
|
||||
this.push = new PushSettingsConfigResponse(this.getResponseProperty("Push"));
|
||||
this.settings = new ServerSettings(this.getResponseProperty("Settings"));
|
||||
}
|
||||
}
|
||||
|
||||
export class PushSettingsConfigResponse extends BaseResponse {
|
||||
pushTechnology: number;
|
||||
vapidPublicKey: string;
|
||||
|
||||
constructor(data: any = null) {
|
||||
super(data);
|
||||
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pushTechnology = this.getResponseProperty("PushTechnology");
|
||||
this.vapidPublicKey = this.getResponseProperty("VapidPublicKey");
|
||||
}
|
||||
}
|
||||
|
||||
export class EnvironmentServerConfigResponse extends BaseResponse {
|
||||
cloudRegion: Region;
|
||||
vault: string;
|
||||
|
||||
Reference in New Issue
Block a user