mirror of
https://github.com/bitwarden/browser
synced 2026-02-11 22:13:32 +00:00
* 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>
99 lines
3.2 KiB
TypeScript
99 lines
3.2 KiB
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { Jsonify } from "type-fest";
|
|
|
|
import { AllowedFeatureFlagTypes } from "../../../enums/feature-flag.enum";
|
|
import { Region } from "../../abstractions/environment.service";
|
|
import { ServerSettings } from "../domain/server-settings";
|
|
import {
|
|
ServerConfigResponse,
|
|
ThirdPartyServerConfigResponse,
|
|
EnvironmentServerConfigResponse,
|
|
PushSettingsConfigResponse,
|
|
} from "../response/server-config.response";
|
|
|
|
export class ServerConfigData {
|
|
version: string;
|
|
gitHash: string;
|
|
server?: ThirdPartyServerConfigData;
|
|
environment?: EnvironmentServerConfigData;
|
|
utcDate: string;
|
|
featureStates: { [key: string]: AllowedFeatureFlagTypes } = {};
|
|
push: PushSettingsConfigData;
|
|
settings: ServerSettings;
|
|
|
|
constructor(serverConfigResponse: Partial<ServerConfigResponse>) {
|
|
this.version = serverConfigResponse?.version;
|
|
this.gitHash = serverConfigResponse?.gitHash;
|
|
this.server = serverConfigResponse?.server
|
|
? new ThirdPartyServerConfigData(serverConfigResponse.server)
|
|
: null;
|
|
this.utcDate = new Date().toISOString();
|
|
this.environment = serverConfigResponse?.environment
|
|
? new EnvironmentServerConfigData(serverConfigResponse.environment)
|
|
: 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 {
|
|
return Object.assign(new ServerConfigData({}), obj, {
|
|
server: obj?.server ? ThirdPartyServerConfigData.fromJSON(obj.server) : null,
|
|
environment: obj?.environment ? EnvironmentServerConfigData.fromJSON(obj.environment) : null,
|
|
});
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
constructor(response: Partial<ThirdPartyServerConfigResponse>) {
|
|
this.name = response.name;
|
|
this.url = response.url;
|
|
}
|
|
|
|
static fromJSON(obj: Jsonify<ThirdPartyServerConfigData>): ThirdPartyServerConfigData {
|
|
return Object.assign(new ThirdPartyServerConfigData({}), obj);
|
|
}
|
|
}
|
|
|
|
export class EnvironmentServerConfigData {
|
|
cloudRegion: Region;
|
|
vault: string;
|
|
api: string;
|
|
identity: string;
|
|
notifications: string;
|
|
sso: string;
|
|
|
|
constructor(response: Partial<EnvironmentServerConfigResponse>) {
|
|
this.cloudRegion = response.cloudRegion;
|
|
this.vault = response.vault;
|
|
this.api = response.api;
|
|
this.identity = response.identity;
|
|
this.notifications = response.notifications;
|
|
this.sso = response.sso;
|
|
}
|
|
|
|
static fromJSON(obj: Jsonify<EnvironmentServerConfigData>): EnvironmentServerConfigData {
|
|
return Object.assign(new EnvironmentServerConfigData({}), obj);
|
|
}
|
|
}
|