From 3463d93eda32b4c4b0fb93b77476c39462f2d451 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 17 Feb 2022 13:53:51 +0000 Subject: [PATCH] chore(release): 2.0.0 [skip ci] # [2.0.0](https://github.com/willgm/web-crypto-tools/compare/v1.2.1...v2.0.0) (2022-02-17) ### Features * support for TypeScript 4.5 ([998d68b](https://github.com/willgm/web-crypto-tools/commit/998d68b10b6c2eb02d428b3b011fcd72d0d7ea3a)) ### BREAKING CHANGES * Some type definitions on the public API needed to be changed due to TypeScript breaking changes --- CHANGELOG.md | 13 +++++++ docs/assets/search.js | 2 +- docs/index.html | 2 +- docs/modules.html | 82 ++++++++++++++++++++----------------------- package-lock.json | 4 +-- package.json | 2 +- 6 files changed, 57 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff39cc..437ba8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# [2.0.0](https://github.com/willgm/web-crypto-tools/compare/v1.2.1...v2.0.0) (2022-02-17) + + +### Features + +* support for TypeScript 4.5 ([998d68b](https://github.com/willgm/web-crypto-tools/commit/998d68b10b6c2eb02d428b3b011fcd72d0d7ea3a)) + + +### BREAKING CHANGES + +* Some type definitions on the public API needed to be changed due to TypeScript +breaking changes + ## [1.2.1](https://github.com/willgm/web-crypto-tools/compare/v1.2.0...v1.2.1) (2022-02-16) diff --git a/docs/assets/search.js b/docs/assets/search.js index 8455143..a860322 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = JSON.parse("{\"kinds\":{\"32\":\"Variable\",\"64\":\"Function\",\"4194304\":\"Type alias\"},\"rows\":[{\"id\":0,\"kind\":64,\"name\":\"getCryptoObject\",\"url\":\"modules.html#getCryptoObject\",\"classes\":\"tsd-kind-function\"},{\"id\":1,\"kind\":64,\"name\":\"generateBaseCryptoKey\",\"url\":\"modules.html#generateBaseCryptoKey\",\"classes\":\"tsd-kind-function\"},{\"id\":2,\"kind\":64,\"name\":\"deriveCryptKey\",\"url\":\"modules.html#deriveCryptKey\",\"classes\":\"tsd-kind-function\"},{\"id\":3,\"kind\":64,\"name\":\"isTypedArray\",\"url\":\"modules.html#isTypedArray\",\"classes\":\"tsd-kind-function\"},{\"id\":4,\"kind\":64,\"name\":\"encryptValue\",\"url\":\"modules.html#encryptValue\",\"classes\":\"tsd-kind-function\"},{\"id\":5,\"kind\":64,\"name\":\"decryptValue\",\"url\":\"modules.html#decryptValue\",\"classes\":\"tsd-kind-function\"},{\"id\":6,\"kind\":64,\"name\":\"generateNonce\",\"url\":\"modules.html#generateNonce\",\"classes\":\"tsd-kind-function\"},{\"id\":7,\"kind\":64,\"name\":\"generateSalt\",\"url\":\"modules.html#generateSalt\",\"classes\":\"tsd-kind-function\"},{\"id\":8,\"kind\":64,\"name\":\"generateRandomValues\",\"url\":\"modules.html#generateRandomValues\",\"classes\":\"tsd-kind-function\"},{\"id\":9,\"kind\":64,\"name\":\"encode\",\"url\":\"modules.html#encode\",\"classes\":\"tsd-kind-function\"},{\"id\":10,\"kind\":64,\"name\":\"decode\",\"url\":\"modules.html#decode\",\"classes\":\"tsd-kind-function\"},{\"id\":11,\"kind\":64,\"name\":\"generateHash\",\"url\":\"modules.html#generateHash\",\"classes\":\"tsd-kind-function\"},{\"id\":12,\"kind\":4194304,\"name\":\"ImportAlgorithm\",\"url\":\"modules.html#ImportAlgorithm\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":13,\"kind\":4194304,\"name\":\"OriginalKeyFormat\",\"url\":\"modules.html#OriginalKeyFormat\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":14,\"kind\":4194304,\"name\":\"DeriveAlgorithm\",\"url\":\"modules.html#DeriveAlgorithm\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":15,\"kind\":4194304,\"name\":\"DerivedAlgorithmFor\",\"url\":\"modules.html#DerivedAlgorithmFor\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":16,\"kind\":4194304,\"name\":\"CryptoAlgorithm\",\"url\":\"modules.html#CryptoAlgorithm\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":17,\"kind\":4194304,\"name\":\"TypedArray\",\"url\":\"modules.html#TypedArray\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":18,\"kind\":4194304,\"name\":\"CryptoKeyUsage\",\"url\":\"modules.html#CryptoKeyUsage\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":19,\"kind\":32,\"name\":\"PBKDF2_ITERATIONS_DEFAULT\",\"url\":\"modules.html#PBKDF2_ITERATIONS_DEFAULT\",\"classes\":\"tsd-kind-variable\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"parent\"],\"fieldVectors\":[[\"name/0\",[0,26.391]],[\"parent/0\",[]],[\"name/1\",[1,26.391]],[\"parent/1\",[]],[\"name/2\",[2,26.391]],[\"parent/2\",[]],[\"name/3\",[3,26.391]],[\"parent/3\",[]],[\"name/4\",[4,26.391]],[\"parent/4\",[]],[\"name/5\",[5,26.391]],[\"parent/5\",[]],[\"name/6\",[6,26.391]],[\"parent/6\",[]],[\"name/7\",[7,26.391]],[\"parent/7\",[]],[\"name/8\",[8,26.391]],[\"parent/8\",[]],[\"name/9\",[9,26.391]],[\"parent/9\",[]],[\"name/10\",[10,26.391]],[\"parent/10\",[]],[\"name/11\",[11,26.391]],[\"parent/11\",[]],[\"name/12\",[12,26.391]],[\"parent/12\",[]],[\"name/13\",[13,26.391]],[\"parent/13\",[]],[\"name/14\",[14,26.391]],[\"parent/14\",[]],[\"name/15\",[15,26.391]],[\"parent/15\",[]],[\"name/16\",[16,26.391]],[\"parent/16\",[]],[\"name/17\",[17,26.391]],[\"parent/17\",[]],[\"name/18\",[18,26.391]],[\"parent/18\",[]],[\"name/19\",[19,26.391]],[\"parent/19\",[]]],\"invertedIndex\":[[\"cryptoalgorithm\",{\"_index\":16,\"name\":{\"16\":{}},\"parent\":{}}],[\"cryptokeyusage\",{\"_index\":18,\"name\":{\"18\":{}},\"parent\":{}}],[\"decode\",{\"_index\":10,\"name\":{\"10\":{}},\"parent\":{}}],[\"decryptvalue\",{\"_index\":5,\"name\":{\"5\":{}},\"parent\":{}}],[\"derivealgorithm\",{\"_index\":14,\"name\":{\"14\":{}},\"parent\":{}}],[\"derivecryptkey\",{\"_index\":2,\"name\":{\"2\":{}},\"parent\":{}}],[\"derivedalgorithmfor\",{\"_index\":15,\"name\":{\"15\":{}},\"parent\":{}}],[\"encode\",{\"_index\":9,\"name\":{\"9\":{}},\"parent\":{}}],[\"encryptvalue\",{\"_index\":4,\"name\":{\"4\":{}},\"parent\":{}}],[\"generatebasecryptokey\",{\"_index\":1,\"name\":{\"1\":{}},\"parent\":{}}],[\"generatehash\",{\"_index\":11,\"name\":{\"11\":{}},\"parent\":{}}],[\"generatenonce\",{\"_index\":6,\"name\":{\"6\":{}},\"parent\":{}}],[\"generaterandomvalues\",{\"_index\":8,\"name\":{\"8\":{}},\"parent\":{}}],[\"generatesalt\",{\"_index\":7,\"name\":{\"7\":{}},\"parent\":{}}],[\"getcryptoobject\",{\"_index\":0,\"name\":{\"0\":{}},\"parent\":{}}],[\"importalgorithm\",{\"_index\":12,\"name\":{\"12\":{}},\"parent\":{}}],[\"istypedarray\",{\"_index\":3,\"name\":{\"3\":{}},\"parent\":{}}],[\"originalkeyformat\",{\"_index\":13,\"name\":{\"13\":{}},\"parent\":{}}],[\"pbkdf2_iterations_default\",{\"_index\":19,\"name\":{\"19\":{}},\"parent\":{}}],[\"typedarray\",{\"_index\":17,\"name\":{\"17\":{}},\"parent\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file +window.searchData = JSON.parse("{\"kinds\":{\"32\":\"Variable\",\"64\":\"Function\",\"4194304\":\"Type alias\"},\"rows\":[{\"id\":0,\"kind\":64,\"name\":\"getCryptoObject\",\"url\":\"modules.html#getCryptoObject\",\"classes\":\"tsd-kind-function\"},{\"id\":1,\"kind\":64,\"name\":\"generateBaseCryptoKey\",\"url\":\"modules.html#generateBaseCryptoKey\",\"classes\":\"tsd-kind-function\"},{\"id\":2,\"kind\":64,\"name\":\"deriveCryptKey\",\"url\":\"modules.html#deriveCryptKey\",\"classes\":\"tsd-kind-function\"},{\"id\":3,\"kind\":64,\"name\":\"isTypedArray\",\"url\":\"modules.html#isTypedArray\",\"classes\":\"tsd-kind-function\"},{\"id\":4,\"kind\":64,\"name\":\"encryptValue\",\"url\":\"modules.html#encryptValue\",\"classes\":\"tsd-kind-function\"},{\"id\":5,\"kind\":64,\"name\":\"decryptValue\",\"url\":\"modules.html#decryptValue\",\"classes\":\"tsd-kind-function\"},{\"id\":6,\"kind\":64,\"name\":\"generateNonce\",\"url\":\"modules.html#generateNonce\",\"classes\":\"tsd-kind-function\"},{\"id\":7,\"kind\":64,\"name\":\"generateSalt\",\"url\":\"modules.html#generateSalt\",\"classes\":\"tsd-kind-function\"},{\"id\":8,\"kind\":64,\"name\":\"generateRandomValues\",\"url\":\"modules.html#generateRandomValues\",\"classes\":\"tsd-kind-function\"},{\"id\":9,\"kind\":64,\"name\":\"encode\",\"url\":\"modules.html#encode\",\"classes\":\"tsd-kind-function\"},{\"id\":10,\"kind\":64,\"name\":\"decode\",\"url\":\"modules.html#decode\",\"classes\":\"tsd-kind-function\"},{\"id\":11,\"kind\":64,\"name\":\"generateHash\",\"url\":\"modules.html#generateHash\",\"classes\":\"tsd-kind-function\"},{\"id\":12,\"kind\":4194304,\"name\":\"ImportAlgorithm\",\"url\":\"modules.html#ImportAlgorithm\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":13,\"kind\":4194304,\"name\":\"DeriveAlgorithm\",\"url\":\"modules.html#DeriveAlgorithm\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":14,\"kind\":4194304,\"name\":\"DerivedAlgorithmFor\",\"url\":\"modules.html#DerivedAlgorithmFor\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":15,\"kind\":4194304,\"name\":\"CryptoAlgorithm\",\"url\":\"modules.html#CryptoAlgorithm\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":16,\"kind\":4194304,\"name\":\"CryptoKeyUsage\",\"url\":\"modules.html#CryptoKeyUsage\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":17,\"kind\":32,\"name\":\"PBKDF2_ITERATIONS_DEFAULT\",\"url\":\"modules.html#PBKDF2_ITERATIONS_DEFAULT\",\"classes\":\"tsd-kind-variable\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"parent\"],\"fieldVectors\":[[\"name/0\",[0,25.39]],[\"parent/0\",[]],[\"name/1\",[1,25.39]],[\"parent/1\",[]],[\"name/2\",[2,25.39]],[\"parent/2\",[]],[\"name/3\",[3,25.39]],[\"parent/3\",[]],[\"name/4\",[4,25.39]],[\"parent/4\",[]],[\"name/5\",[5,25.39]],[\"parent/5\",[]],[\"name/6\",[6,25.39]],[\"parent/6\",[]],[\"name/7\",[7,25.39]],[\"parent/7\",[]],[\"name/8\",[8,25.39]],[\"parent/8\",[]],[\"name/9\",[9,25.39]],[\"parent/9\",[]],[\"name/10\",[10,25.39]],[\"parent/10\",[]],[\"name/11\",[11,25.39]],[\"parent/11\",[]],[\"name/12\",[12,25.39]],[\"parent/12\",[]],[\"name/13\",[13,25.39]],[\"parent/13\",[]],[\"name/14\",[14,25.39]],[\"parent/14\",[]],[\"name/15\",[15,25.39]],[\"parent/15\",[]],[\"name/16\",[16,25.39]],[\"parent/16\",[]],[\"name/17\",[17,25.39]],[\"parent/17\",[]]],\"invertedIndex\":[[\"cryptoalgorithm\",{\"_index\":15,\"name\":{\"15\":{}},\"parent\":{}}],[\"cryptokeyusage\",{\"_index\":16,\"name\":{\"16\":{}},\"parent\":{}}],[\"decode\",{\"_index\":10,\"name\":{\"10\":{}},\"parent\":{}}],[\"decryptvalue\",{\"_index\":5,\"name\":{\"5\":{}},\"parent\":{}}],[\"derivealgorithm\",{\"_index\":13,\"name\":{\"13\":{}},\"parent\":{}}],[\"derivecryptkey\",{\"_index\":2,\"name\":{\"2\":{}},\"parent\":{}}],[\"derivedalgorithmfor\",{\"_index\":14,\"name\":{\"14\":{}},\"parent\":{}}],[\"encode\",{\"_index\":9,\"name\":{\"9\":{}},\"parent\":{}}],[\"encryptvalue\",{\"_index\":4,\"name\":{\"4\":{}},\"parent\":{}}],[\"generatebasecryptokey\",{\"_index\":1,\"name\":{\"1\":{}},\"parent\":{}}],[\"generatehash\",{\"_index\":11,\"name\":{\"11\":{}},\"parent\":{}}],[\"generatenonce\",{\"_index\":6,\"name\":{\"6\":{}},\"parent\":{}}],[\"generaterandomvalues\",{\"_index\":8,\"name\":{\"8\":{}},\"parent\":{}}],[\"generatesalt\",{\"_index\":7,\"name\":{\"7\":{}},\"parent\":{}}],[\"getcryptoobject\",{\"_index\":0,\"name\":{\"0\":{}},\"parent\":{}}],[\"importalgorithm\",{\"_index\":12,\"name\":{\"12\":{}},\"parent\":{}}],[\"istypedarray\",{\"_index\":3,\"name\":{\"3\":{}},\"parent\":{}}],[\"pbkdf2_iterations_default\",{\"_index\":17,\"name\":{\"17\":{}},\"parent\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 5a250fc..f49ea24 100644 --- a/docs/index.html +++ b/docs/index.html @@ -74,4 +74,4 @@

:book: Documentation

License

MIT

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index 6e55d46..be64f54 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,129 +1,125 @@ -@webcrypto/tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

@webcrypto/tools

Index

Type aliases

CryptoAlgorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams
+@webcrypto/tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

@webcrypto/tools

Index

Type aliases

CryptoAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

Params for Encrypt / Decrypt Algorithms at Web Crypto API

-
CryptoKeyUsage: "encrypt" | "decrypt" | "deriveKey" | "deriveBits" | "wrapKey" | "sign" | "verify" | "unwrapKey"
+
CryptoKeyUsage: "encrypt" | "decrypt" | "deriveKey" | "deriveBits" | "wrapKey" | "sign" | "verify" | "unwrapKey"

Possible uses of Crypto Keys

-
DeriveAlgorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params
+
DeriveAlgorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params

Derive Key Algorithms at at Web Crypto API

-
DerivedAlgorithmFor: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params
+
DerivedAlgorithmFor: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params

Derive Algorithms Params for Web Crypto API

-
ImportAlgorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams | AesKeyAlgorithm
+
ImportAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm

Import Key Algorithms at Web Crypto API

-
OriginalKeyFormat: "raw" | "pkcs8" | "spki" | "jwk"
-

Import Key Web Crypto Algorithms

-
TypedArray: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer
-

TypedArray used in Web Crypto API Algorithms

-

Variables

PBKDF2_ITERATIONS_DEFAULT: number = 50000
+

Variables

PBKDF2_ITERATIONS_DEFAULT: number = 50000

Default number of iterations used with PBKDF2 algorithm

-

Functions

  • decode(data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer): string

Functions

  • decode(data: string | BufferSource): string
  • Decode a ArrayBuffer value to a string. If the given value is already a string, then the value will be returned without any transformation.

    -

    Parameters

    • data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer
      +

      Parameters

      • data: string | BufferSource

        Value to be decoded.

      Returns string

      The transformed given value as a string.

      -
  • decryptValue(data: TypedArray, cryptoKey: CryptoKey, nonceOrAlgorithm: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams): Promise<ArrayBuffer>
  • decryptValue(data: BufferSource, cryptoKey: CryptoKey, nonceOrAlgorithm: BufferSource | CryptoAlgorithm): Promise<ArrayBuffer>
  • Decrypt a value with the given Crypto Key and Algorithm

    -

    Parameters

    • data: TypedArray
      +

      Parameters

      • data: BufferSource

        Value to be encrypted.

      • cryptoKey: CryptoKey

        The Crypto Key used in encryption.

        -
      • nonceOrAlgorithm: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams
        +
      • nonceOrAlgorithm: BufferSource | CryptoAlgorithm

        The nonce used for AES encryption or the custom algorithm.

      Returns Promise<ArrayBuffer>

      A promise with the decrypt value

      -
  • deriveCryptKey(cryptoBaseKey: CryptoKey, salt: TypedArray, iterations?: number, keyUsages?: KeyUsage[]): Promise<CryptoKey>
  • deriveCryptKey(cryptoBaseKey: CryptoKey, salt: TypedArray, algorithmFor?: string | HmacImportParams | AesDerivedKeyParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, keyUsages?: KeyUsage[]): Promise<CryptoKey>
  • deriveCryptKey(cryptoBaseKey: CryptoKey, deriveAlgorithm: DeriveAlgorithm, algorithmFor?: string | HmacImportParams | AesDerivedKeyParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, keyUsages?: KeyUsage[]): Promise<CryptoKey>
  • Derives a base Crypto Key to new one that can be used in encrypt / decrypt algorithms or any other possible uses in CryptoKeyUsage.

    Parameters

    • cryptoBaseKey: CryptoKey

      The base Crypto Key to be derive.

      -
    • salt: TypedArray
      +
    • salt: BufferSource

      The salt value to be used with the default PBKDF2 derive algorithm.

    • Optional iterations: number

      The number of iterations to be used with the default PBKDF2 derive algorithm. Default value: PBKDF2_ITERATIONS_DEFAULT.

      -
    • Optional keyUsages: KeyUsage[]
      +
    • Optional keyUsages: CryptoKeyUsage[]

      The new uses of the new derive Crypto Key. Default value: ['encrypt', 'decrypt'].

    Returns Promise<CryptoKey>

    A promise with the derived Crypto Key for other uses.

    -
  • +
  • Derives a base Crypto Key to new one that can be used in encrypt / decrypt algorithms or any other possible uses in CryptoKeyUsage.

    Parameters

    • cryptoBaseKey: CryptoKey

      The base Crypto Key to be derive.

      -
    • salt: TypedArray
      +
    • salt: BufferSource

      The salt value to be used with the default PBKDF2 derive algorithm.

      -
    • Optional algorithmFor: string | HmacImportParams | AesDerivedKeyParams | ConcatParams | HkdfCtrParams | Pbkdf2Params
      +
    • Optional algorithmFor: DerivedAlgorithmFor

      The algorithm where the derived Crypto Key will be used. Default value: { name: 'AES-GCM', length: 256 }.

      -
    • Optional keyUsages: KeyUsage[]
      +
    • Optional keyUsages: CryptoKeyUsage[]

      The new uses of the new derive Crypto Key. Default value: ['encrypt', 'decrypt'].

    Returns Promise<CryptoKey>

    A promise with the derived Crypto Key for other uses.

    -
  • +
  • Derives a base Crypto Key to new one that can be used in encrypt / decrypt algorithms or any other possible uses in CryptoKeyUsage.

    Parameters

    • cryptoBaseKey: CryptoKey

      The base Crypto Key to be derive.

    • deriveAlgorithm: DeriveAlgorithm

      The algorithm to be used when deriving the Crypto Key.

      -
    • Optional algorithmFor: string | HmacImportParams | AesDerivedKeyParams | ConcatParams | HkdfCtrParams | Pbkdf2Params
      +
    • Optional algorithmFor: DerivedAlgorithmFor

      The algorithm where the derived Crypto Key will be used. Default value: { name: 'AES-GCM', length: 256 }.

      -
    • Optional keyUsages: KeyUsage[]
      +
    • Optional keyUsages: CryptoKeyUsage[]

      The new uses of the new derive Crypto Key. Default value: ['encrypt', 'decrypt'].

    Returns Promise<CryptoKey>

    A promise with the derived Crypto Key for other uses.

    -
  • encode(data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer): TypedArray
  • encode(data: string | BufferSource): BufferSource
  • Encode a string value to a Typed Array as Uint8Array. If the given value is already a Typed Array, then the value will be returned without any transformation.

    -

    Parameters

    • data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer
      +

      Parameters

      • data: string | BufferSource

        Value to be encoded.

        -

      Returns TypedArray

      The transformed given value as a Typed Array.

      -
  • encryptValue(data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, cryptoKey: CryptoKey, algorithm?: CryptoAlgorithm): Promise<[ArrayBuffer, TypedArray | null]>

Returns BufferSource

The transformed given value as a Typed Array.

+
  • encryptValue(data: string | BufferSource, cryptoKey: CryptoKey, algorithm?: CryptoAlgorithm): Promise<[ArrayBuffer, BufferSource | null]>
  • Encrypt a value with the given Crypto Key and Algorithm

    -

    Parameters

    • data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer
      +

      Parameters

      • data: string | BufferSource

        Value to be encrypted.

      • cryptoKey: CryptoKey

        The Crypto Key to be used in encryption.

      • algorithm: CryptoAlgorithm = ...

        The algorithm to be used in encryption. Default to AES-GCM.

        -

      Returns Promise<[ArrayBuffer, TypedArray | null]>

      A promise with the encrypted value and the used nonce, if used with the encryption algorithm.

      -
  • generateBaseCryptoKey(rawKey: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | JsonWebKey, algorithm?: ImportAlgorithm, keyUsages?: KeyUsage[], format?: OriginalKeyFormat): Promise<CryptoKey>

Returns Promise<[ArrayBuffer, BufferSource | null]>

A promise with the encrypted value and the used nonce, if used with the encryption algorithm.

+
  • generateBaseCryptoKey(rawKey: string | BufferSource | JsonWebKey, algorithm?: ImportAlgorithm, keyUsages?: KeyUsage[], format?: KeyFormat): Promise<CryptoKey>
  • Creates a base Crypto Key from the original raw key, by default this base key should just be used to protect the original key to be discovery, and should not be used directly to any encrypt / decrypt algorithm. The generated base crypto key should be used just to derive new ones, that then will be used to encrypt / decrypt algorithms.

    -

    Parameters

    • rawKey: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | JsonWebKey
      +

      Parameters

      • rawKey: string | BufferSource | JsonWebKey

        The original key to start the encrypt process.

      • algorithm: ImportAlgorithm = 'PBKDF2'

        The algorithm used to import the key.

      • keyUsages: KeyUsage[] = ...

        The uses for the generated Crypto Key.

        -
      • format: OriginalKeyFormat = 'raw'
        +
      • format: KeyFormat = 'raw'

        Input format for the raw key.

      Returns Promise<CryptoKey>

      A promise with the base Crypto Key.

      -
  • generateHash(data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, algorithm?: string | Algorithm): Promise<ArrayBuffer>
  • generateHash(data: string | BufferSource, algorithm?: string | Algorithm): Promise<ArrayBuffer>
  • Generates a hash value for the given value.

    -

    Parameters

    • data: string | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer
      +

      Parameters

      • data: string | BufferSource

        Seed value to generate a hash.

      • algorithm: string | Algorithm = 'SHA-256'

        The algorithm to be used when generating the hash.

      Returns Promise<ArrayBuffer>

      A promise containing the hash value.

      -
  • generateNonce(byteSize?: number): Uint8Array
  • generateNonce(byteSize?: number): Uint8Array
  • Generates random value to be used as nonce with encryption algorithms.

    Parameters

    • byteSize: number = 16

      The byte size of the generated random value.

    Returns Uint8Array

    The random value.

    -
  • generateRandomValues(byteSize?: number): Uint8Array
  • generateRandomValues(byteSize?: number): Uint8Array
  • Generates random value as a typed array of Uint8Array.

    Parameters

    • byteSize: number = 8

      The byte size of the generated random value.

    Returns Uint8Array

    The random value.

    -
  • generateSalt(byteSize?: number): Uint8Array
  • generateSalt(byteSize?: number): Uint8Array
  • Generates random value to be used as salt with encryption algorithms.

    Parameters

    • byteSize: number = 8

      The byte size of the generated random value.

    Returns Uint8Array

    The random value.

    -
  • getCryptoObject(): Crypto
  • getCryptoObject(): Crypto
  • Returns the crypto object depending on browser support. IE11 has support for the Crypto API, but it is in a different global scope.

    Returns Crypto

    The Crypto object.

    -
  • isTypedArray(data: unknown): data is BufferSource
  • Type Guard to Typed Array.

    Parameters

    • data: unknown

      Any data to be checked.

      -

    Returns data is TypedArray

    Verify if the given data is a Typed Array.

    -

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +

Returns data is BufferSource

Verify if the given data is a Typed Array.

+

Generated using TypeDoc

\ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3830c25..1a8a5fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@webcrypto/tools", - "version": "1.2.1", + "version": "2.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@webcrypto/tools", - "version": "1.2.1", + "version": "2.0.0", "license": "MIT", "devDependencies": { "@commitlint/cli": "^11.0.0", diff --git a/package.json b/package.json index 4bfa2f9..7c5cd84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@webcrypto/tools", - "version": "1.2.1", + "version": "2.0.0", "private": false, "description": "A set of tools to facilitate and give good defaults for use of the native Web Crypto API.", "publishConfig": {