Skip to main content
Module

x/mandarinets/security-core/keyStack.ts>KeyStack

Mandarine.TS is a typescript, decorator-driven framework that allows you to create server-side applications. Mandarine.TS provides a range of built-in solutions such as Dependency Injection, Components, ORM and more. Under its umbrella, Mandarine.TS has 4 modules: Core, Data, Security and MVC, these modules will offer you the requirements to build a Mandarine-powered application.
Latest
class KeyStack
import { KeyStack } from "https://deno.land/x/mandarinets@v2.3.2/security-core/keyStack.ts";

Constructors

new
KeyStack(keys: Key[])

A class which accepts an array of keys that are used to sign and verify data and allows easy key rotation without invalidation of previously signed data.

Methods

indexOf(data: Data, digest: string): 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.

sign(data: Data): 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): 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.