Skip to content

otplib API Documentation / @otplib/core / hasPlugins

Function: hasPlugins()

hasPlugins<T>(options): options is T & { base32: Base32Plugin; crypto: CryptoPlugin }

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

Type predicate to check if an object has the required plugins

Type Parameters

T

T extends object

Parameters

options

T

Returns

options is T & { base32: Base32Plugin; crypto: CryptoPlugin }

Example

ts
const options = getOptions();
if (hasPlugins(options)) {
  // TypeScript knows plugins are defined
  options.crypto.hmac(...);
}

Released under the MIT License.