@blockchaincommons/sskr - v1.0.0-beta.3
    Preparing search index...

    Class Secret

    A validated secret: 16–32 bytes, even length. Holds its own copy and hands out copies; nothing outside can change it.

    Index
    • get bytes(): Uint8Array<ArrayBuffer>

      A fresh copy of the bytes (16–32); mutating it does not change the secret.

      Returns Uint8Array<ArrayBuffer>

    • get byteLength(): number

      The length in bytes.

      Returns number

    • Type guard for a Secret, including one from another copy of this package.

      Parameters

      • value: unknown

      Returns value is Secret

    • A validated copy of bytes. The copy is taken first, so the checks and the secret see the same bytes (a Buffer is accepted; its slice would alias).

      Parameters

      • bytes: Uint8Array

      Returns Secret

      InvalidParameter unless bytes is a Uint8Array (text goes through Secret.fromText); then SecretTooShort, SecretTooLong, SecretLengthNotEven, in that order.

    • The UTF-8 bytes of text, validated as from (the reference's Secret::new(&str)). A lone surrogate, which &str cannot hold, is encoded as U+FFFD.

      Parameters

      • text: string

      Returns Secret

      InvalidParameter unless text is a string; then the from codes.

    • Same bytes; false for anything that is not a Secret (one from another copy of this package compares by its bytes).

      Parameters

      • other: unknown

      Returns boolean