Skip to main content

@std/crypto@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Provides the KeyStack class which implements the KeyRing interface for managing rotatable keys.

Classes

c
KeyStack(keys: Iterable<Key>)

A cryptographic key chain which allows signing of data to prevent tampering, but also allows for easy key rotation without needing to re-sign the data.

  • indexOf(
    data: Data,
    digest: string
    ): Promise<number>

    Given data and a digest, return the current index of the key in the keys passed the constructor that was used to generate the digest. If no key can be found, the method returns -1.

  • length(): number

    Number of keys

  • sign(data: Data): Promise<string>

    Take data and return a SHA256 HMAC digest that uses the current 0 index of the keys passed to the constructor. This digest is in the form of a URL safe base64 encoded string.

  • verify(
    data: Data,
    digest: string
    ): Promise<boolean>

    Given data and a digest, verify that one of the keys provided the constructor was used to generate the digest. Returns true if one of the keys was used, otherwise false.

Type Aliases

T
Data = string | number[] | ArrayBuffer | Uint8Array

Types of data that can be signed cryptographically.

T
Key = string | number[] | ArrayBuffer | Uint8Array

Types of keys that can be used to sign data.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/crypto

Import symbol

import * as mod from "@std/crypto/unstable_keystack";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/crypto/unstable_keystack";