Skip to content

Latest commit

 

History

History
112 lines (64 loc) · 2.43 KB

jwk.md

File metadata and controls

112 lines (64 loc) · 2.43 KB

Namespace: jwk

Module jwk aims to provide an implementation of the JSON Web Key.

Table of contents

Interfaces

Type aliases

Functions

Type aliases

ByteArrayLike

Ƭ ByteArrayLike: ArrayBuffer | string | bytes

Byte array convertible types


bytes

Ƭ bytes: number[]

Array of numbers. The number range is from 0 to 255.

Functions

adopt

adopt(algorithm: string, key: ByteArrayLike, isPublic?: boolean): Key

Adopt an existing asymmetric key with the given algorithm (algorithm).

Parameters

Name Type Description
algorithm string Key algorithm, supported values: ed25519
key ByteArrayLike private or public key
isPublic? boolean true if key is a public key, false if it is a private key

Returns: Key

The adopted key


generate

generate(algorithm: string, seed?: ByteArrayLike): Key

Generates a new asymmetric key with the given algorithm (algorithm) or import exising private key from seed.

Parameters

Name Type Description
algorithm string Key algorithm, supported values: ed25519
seed? ByteArrayLike Seed value when importing private key

Returns: Key

The generated key


parse

parse(source: string): Key

Parse a key from its JSON representation.

Parameters

Name Type Description
source string JSON source to parse

Returns: Key

The parsed JWK representation


parseKeySet

parseKeySet(source: string): Key[]

Parse JSON Web Key Set into key array.

Parameters

Name Type Description
source string JSON source to parse

Returns: Key[]

The array of keys from parsed JWKS