Module jwk aims to provide an implementation of the JSON Web Key.
Ƭ ByteArrayLike: ArrayBuffer | string | bytes
Byte array convertible types
Ƭ bytes: number[]
Array of numbers. The number range is from 0 to 255.
▸ adopt(algorithm
: string, key
: ByteArrayLike, isPublic?
: boolean): Key
Adopt an existing asymmetric key with the given algorithm (algorithm
).
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(algorithm
: string, seed?
: ByteArrayLike): Key
Generates a new asymmetric key with the given algorithm (algorithm
) or import exising private key from seed
.
Name | Type | Description |
---|---|---|
algorithm |
string | Key algorithm, supported values: ed25519 |
seed? |
ByteArrayLike | Seed value when importing private key |
Returns: Key
The generated key
▸ parse(source
: string): Key
Parse a key from its JSON representation.
Name | Type | Description |
---|---|---|
source |
string | JSON source to parse |
Returns: Key
The parsed JWK representation
▸ parseKeySet(source
: string): Key[]
Parse JSON Web Key Set into key array.
Name | Type | Description |
---|---|---|
source |
string | JSON source to parse |
Returns: Key[]
The array of keys from parsed JWKS