1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-06 03:33:30 +00:00

[PM-2014] chore: document requests and responses

This commit is contained in:
Andreas Coroiu
2023-09-27 11:03:04 +02:00
parent 32ba34eafe
commit 38db065749
5 changed files with 36 additions and 5 deletions

View File

@@ -1,7 +1,18 @@
import { WebauthnLoginResponseRequest } from "./webauthn-login-response.request";
import { WebauthnLoginAttestationResponseRequest } from "./webauthn-login-attestation-response.request";
/**
* Request sent to the server to save a newly created webauthn login credential.
*/
export class SaveCredentialRequest {
deviceResponse: WebauthnLoginResponseRequest;
/** The response recieved from the authenticator. This contains the public key */
deviceResponse: WebauthnLoginAttestationResponseRequest;
/** Nickname chosen by the user to identify this credential */
name: string;
/**
* Token required by the server to complete the creation.
* It contains encrypted information that the server needs to verify the credential.
*/
token: string;
}

View File

@@ -1,8 +1,12 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { WebauthnLoginResponseRequest } from "./webauthn-login-response.request";
import { WebauthnLoginAuthenticatorResponseRequest } from "./webauthn-login-authenticator-response.request";
export class WebauthnLoginAttestationResponseRequest extends WebauthnLoginResponseRequest {
/**
* The response recieved from an authentiator after a successful attestation.
* This request is used to save newly created webauthn login credentials to the server.
*/
export class WebauthnLoginAttestationResponseRequest extends WebauthnLoginAuthenticatorResponseRequest {
response: {
attestationObject: string;
clientDataJson: string;

View File

@@ -1,6 +1,10 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
export abstract class WebauthnLoginResponseRequest {
/**
* An abstract class that represents responses recieved from the webauthn authenticator.
* It contains data that is commonly returned during different types of authenticator interactions.
*/
export abstract class WebauthnLoginAuthenticatorResponseRequest {
id: string;
rawId: string;
type: string;

View File

@@ -1,8 +1,17 @@
import { ChallengeResponse } from "@bitwarden/common/auth/models/response/two-factor-web-authn.response";
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
/**
* Options provided by the server to be used during attestation (i.e. creation of a new webauthn credential)
*/
export class WebauthnLoginCredentialCreateOptionsResponse extends BaseResponse {
/** Options to be provided to the webauthn authenticator */
options: ChallengeResponse;
/**
* Contains an encrypted version of the {@link options}.
* Used by the server to validate the attestation response of newly created credentials.
*/
token: string;
constructor(response: unknown) {

View File

@@ -1,5 +1,8 @@
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
/**
* A webauthn login credential recieved from the server.
*/
export class WebauthnLoginCredentialResponse extends BaseResponse {
id: string;
name: string;