Skip to content

otplib API Documentation / @otplib/core / hasCrypto

Function: hasCrypto()

hasCrypto<T>(options): options is T & { crypto: CryptoPlugin }

Defined in: packages/core/src/utility-types.ts:157

Type predicate to check if an object has a crypto plugin

Type Parameters

T

T extends object

Parameters

options

T

Returns

options is T & { crypto: CryptoPlugin }

Example

ts
if (hasCrypto(options)) {
  await options.crypto.hmac('sha1', key, data);
}

Released under the MIT License.