1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

[SM-288] Rename requests and responses to follow naming convention (#3806)

This commit is contained in:
Oscar Hinton
2022-10-18 19:01:42 +02:00
committed by GitHub
parent c2df5c608e
commit cf2d3f5382
375 changed files with 868 additions and 1054 deletions

View File

@@ -0,0 +1,60 @@
import { Utils } from "../../misc/utils";
import { BaseResponse } from "./base.response";
export class TwoFactorWebAuthnResponse extends BaseResponse {
enabled: boolean;
keys: KeyResponse[];
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty("Enabled");
const keys = this.getResponseProperty("Keys");
this.keys = keys == null ? null : keys.map((k: any) => new KeyResponse(k));
}
}
export class KeyResponse extends BaseResponse {
name: string;
id: number;
migrated: boolean;
constructor(response: any) {
super(response);
this.name = this.getResponseProperty("Name");
this.id = this.getResponseProperty("Id");
this.migrated = this.getResponseProperty("Migrated");
}
}
export class ChallengeResponse extends BaseResponse implements PublicKeyCredentialCreationOptions {
attestation?: AttestationConveyancePreference;
authenticatorSelection?: AuthenticatorSelectionCriteria;
challenge: BufferSource;
excludeCredentials?: PublicKeyCredentialDescriptor[];
extensions?: AuthenticationExtensionsClientInputs;
pubKeyCredParams: PublicKeyCredentialParameters[];
rp: PublicKeyCredentialRpEntity;
timeout?: number;
user: PublicKeyCredentialUserEntity;
constructor(response: any) {
super(response);
this.attestation = this.getResponseProperty("attestation");
this.authenticatorSelection = this.getResponseProperty("authenticatorSelection");
this.challenge = Utils.fromUrlB64ToArray(this.getResponseProperty("challenge"));
this.excludeCredentials = this.getResponseProperty("excludeCredentials").map((c: any) => {
c.id = Utils.fromUrlB64ToArray(c.id).buffer;
return c;
});
this.extensions = this.getResponseProperty("extensions");
this.pubKeyCredParams = this.getResponseProperty("pubKeyCredParams");
this.rp = this.getResponseProperty("rp");
this.timeout = this.getResponseProperty("timeout");
const user = this.getResponseProperty("user");
user.id = Utils.fromUrlB64ToArray(user.id);
this.user = user;
}
}