Home Reference Source Test
import CryptoNode from 'token-io/src/security/CryptoNode.js'
public class | source

CryptoNode

Class providing static crypto primitives for Node environments using libsodium.

Static Method Summary

Static Public Methods
public static

async generateKeys(keyLevel: string, expirationMs: number): Object

Generates a key pair to use with the Token system.

public static

async sign(message: string, keys: Object): string

Signs a string and returns the signature.

public static

async verify(message: string, signature: string, publicKey: Uint8Array)

Verifies a signature on a string.

Static Public Methods

public static async generateKeys(keyLevel: string, expirationMs: number): Object source

Generates a key pair to use with the Token system.

Params:

NameTypeAttributeDescription
keyLevel string

'LOW', 'STANDARD', or 'PRIVILEGED'

expirationMs number

(optional) expiration duration of the key in milliseconds

Return:

Object

generated key pair

public static async sign(message: string, keys: Object): string source

Signs a string and returns the signature.

Params:

NameTypeAttributeDescription
message string

message to sign

keys Object

keys to sign with

Return:

string

signature

public static async verify(message: string, signature: string, publicKey: Uint8Array) source

Verifies a signature on a string. Throws if verification fails.

Params:

NameTypeAttributeDescription
message string

string to verify

signature string

signature to verify

publicKey Uint8Array

public key to use for verification