Options
All
  • Public
  • Public/Protected
  • All
Menu

To generate code verifier and code challenge

Hierarchy

  • SecurityHelper

Index

Constructors

Properties

algorithm: string = 'AES-GCM'
ivLength: number = 12
keyLength: number = 256
logger: Logger = ...

Methods

  • arrayBufferToBase64(buffer: ArrayBuffer): string
  • Method to Convert ArrayBuffer to Base64 string

    example
    arrayBufferToBase64(buffer);
    

    Parameters

    • buffer: ArrayBuffer

      The buffer to convert

    Returns string

    A Base64 string

  • atobV2(base64Str: string): string
  • base64ToArrayBuffer(base64: string): ArrayBuffer
  • base64urlencode(buffer: any): string
  • dec2hex(dec: number): string
  • decrypt(cipherText: string, iv: string, key: CryptoKey): Promise<string>
  • Method to decrypt a cipher text using a CryptoKey

    throws

    Error if the key export fails

    example
    decrypt(cipherText, iv, key);
    

    Parameters

    • cipherText: string
    • iv: string
    • key: CryptoKey

      The CryptoKey to export

    Returns Promise<string>

    A promise that resolves to a new JWK

  • deriveKey(key: string): Promise<JsonWebKey>
  • Method to derive a CryptoKey from a string

    throws

    Error if the key derivation fails

    example
    deriveKey(key);
    

    Parameters

    • key: string

      The key to derive

    Returns Promise<JsonWebKey>

    A promise that resolves to a new JWK

  • encrypt(plainText: string, key: CryptoKey): Promise<{ cipherText: string; iv: string }>
  • Method to encrypt a plaintext string using the provided CryptoKey

    throws

    Error if the key export fails

    example
    encrypt(plainText, key);
    

    Parameters

    • plainText: string
    • key: CryptoKey

      The CryptoKey to export

    Returns Promise<{ cipherText: string; iv: string }>

    A promise that resolves to a new JWK

  • generateCodeChallengeFromVerifier(verifier: string): Promise<string>
  • To generate the code challenge

    Parameters

    • verifier: string

      code verifier

    Returns Promise<string>

    • base64 Encoded value - ftMwffFeP8uzj-D9BKFG
    @example
    generateCodeChallengeFromVerifier('dfd7fe9fff84d20091bd6c');
  • generateCodeVerifier(): string
  • generateKey(): Promise<CryptoKey>
  • Method to generate a new AES-GCM key

    throws

    Error if the key generation fails

    example
    generateKey();
    

    Returns Promise<CryptoKey>

    A promise that resolves to a new CryptoKey

  • importKey(keyData: JsonWebKey): Promise<CryptoKey>
  • Method to import a JWK (JSON Web Key) as a CryptoKey

    throws

    Error if the JWK is invalid or the key import fails

    example
    importKey(keyData);
    

    Parameters

    • keyData: JsonWebKey

      The JWK to import

    Returns Promise<CryptoKey>

    A promise that resolves to a new CryptoKey

  • parseJwt(token: string): any
  • Parse jwt token to extract user data

    example
    parseJwt('token_string');
    

    Parameters

    • token: string

      input jwt token string

    Returns any

    • parsed user details
  • sha256(plain: string): Promise<ArrayBuffer>

Generated using TypeDoc