tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SecurityDetails.ts (1796B)


      1 /**
      2 * @license
      3 * Copyright 2020 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 import type {Protocol} from 'devtools-protocol';
      8 
      9 /**
     10 * The SecurityDetails class represents the security details of a
     11 * response that was received over a secure connection.
     12 *
     13 * @public
     14 */
     15 export class SecurityDetails {
     16  #subjectName: string;
     17  #issuer: string;
     18  #validFrom: number;
     19  #validTo: number;
     20  #protocol: string;
     21  #sanList: string[];
     22 
     23  /**
     24   * @internal
     25   */
     26  constructor(securityPayload: Protocol.Network.SecurityDetails) {
     27    this.#subjectName = securityPayload.subjectName;
     28    this.#issuer = securityPayload.issuer;
     29    this.#validFrom = securityPayload.validFrom;
     30    this.#validTo = securityPayload.validTo;
     31    this.#protocol = securityPayload.protocol;
     32    this.#sanList = securityPayload.sanList;
     33  }
     34 
     35  /**
     36   * The name of the issuer of the certificate.
     37   */
     38  issuer(): string {
     39    return this.#issuer;
     40  }
     41 
     42  /**
     43   * {@link https://en.wikipedia.org/wiki/Unix_time | Unix timestamp}
     44   * marking the start of the certificate's validity.
     45   */
     46  validFrom(): number {
     47    return this.#validFrom;
     48  }
     49 
     50  /**
     51   * {@link https://en.wikipedia.org/wiki/Unix_time | Unix timestamp}
     52   * marking the end of the certificate's validity.
     53   */
     54  validTo(): number {
     55    return this.#validTo;
     56  }
     57 
     58  /**
     59   * The security protocol being used, e.g. "TLS 1.2".
     60   */
     61  protocol(): string {
     62    return this.#protocol;
     63  }
     64 
     65  /**
     66   * The name of the subject to which the certificate was issued.
     67   */
     68  subjectName(): string {
     69    return this.#subjectName;
     70  }
     71 
     72  /**
     73   * The list of {@link https://en.wikipedia.org/wiki/Subject_Alternative_Name | subject alternative names (SANs)} of the certificate.
     74   */
     75  subjectAlternativeNames(): string[] {
     76    return this.#sanList;
     77  }
     78 }