UNPKG

@nfen/webcrypto-ts

Version:
24 lines 3.47 kB
/** * Wrapper for node/browser webcrypto * @module */ import { Alg as SHA } from "./sha/shared.js"; /** * Crypto loader which loads native webcrypto depending on environment */ export declare const _crypto: Promise<Crypto>; export declare function encrypt<T extends CryptoKey, U extends AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams>(algorithm: U, key: T, data: BufferSource): Promise<ArrayBuffer>; export declare function decrypt<T extends CryptoKey, U extends AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams>(algorithm: U, key: T, data: BufferSource): Promise<ArrayBuffer>; export declare function sign<T extends CryptoKey, U extends AlgorithmIdentifier | RsaPssParams | EcdsaParams>(algorithm: U, key: T, data: BufferSource): Promise<ArrayBuffer>; export declare function verify<T extends CryptoKey, U extends AlgorithmIdentifier | RsaPssParams | EcdsaParams>(algorithm: U, key: T, signature: BufferSource, data: BufferSource): Promise<boolean>; export declare function deriveKey<T extends CryptoKey, U extends AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params>(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, key: CryptoKey, derivedKeyType: U, extractable: boolean, keyUsages: KeyUsage[]): Promise<T>; export declare function deriveBits<T extends CryptoKey, U extends AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params>(algorithm: U, baseKey: T, length: number): Promise<ArrayBuffer>; export declare function wrapKey<T extends CryptoKey, U extends AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams>(format: KeyFormat, key: CryptoKey, wrappingKey: T, wrapAlgorithm: U): Promise<ArrayBuffer>; export declare function unwrapKey<T extends CryptoKey, U extends AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, V extends AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm>(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: T, unwrapAlgorithm: U, unwrappedKeyAlgorithm: V, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>; export declare function exportKey<T extends CryptoKey>(format: Extract<KeyFormat, "jwk">, key: T): Promise<JsonWebKey>; export declare function exportKey<T extends CryptoKey>(format: Exclude<KeyFormat, "jwk">, key: T): Promise<ArrayBuffer>; export declare function importKey<T extends CryptoKey, U extends AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm>(format: Extract<KeyFormat, "jwk">, key: JsonWebKey, algorithm: U, extractable: boolean, keyUsages: KeyUsage[]): Promise<T>; export declare function importKey<T extends CryptoKey, U extends AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm>(format: Exclude<KeyFormat, "jwk">, key: BufferSource, algorithm: U, extractable: boolean, keyUsages: KeyUsage[]): Promise<T>; export declare function generateKey<T extends CryptoKeyPair | CryptoKey, U extends RsaHashedKeyGenParams | EcKeyGenParams | AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params | AlgorithmIdentifier>(algorithm: U, extractable: boolean, keyUsages: KeyUsage[]): Promise<T>; export declare function digest<T extends ArrayBuffer>(algorithm: SHA.Variants, data: BufferSource): Promise<T>; //# sourceMappingURL=webcrypto.d.ts.map