Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/javascript-api/crypto/jsonwebkey.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/javascript-api/crypto/jsonwebkey/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
JsonWebKey
The JsonWebKey object represents object/dictionary generated by exporting a
CryptoKey or used as an input parameter for key import.
The properties of the JsonWebKey could vary depending on the algorithm and key type. See specification JsonWebKey for details.
Properties
| Property | Type | Description |
|---|---|---|
| kty | string | The key type. |
| k | string | The key value. |
| alg | string | The algorithm. |
| ext | bool | The key is extractable. |
| key_ops | string array | The key operations. |
| crv | string | The curve name. |
| x | string | The x coordinate. |
| y | string | The y coordinate. |
| d | string | The private key. |
Example
export default async function () {
const jwk = {
alg: 'HS256',
ext: true,
k: 'H6gLp3lw7w27NrPUn00WpcKU-IJojJdNzhL_8F6se2k',
key_ops: ['sign', 'verify'],
kty: 'oct',
};
const importedKey = await crypto.subtle.importKey(
'jwk',
jwk,
{ name: 'HMAC', hash: { name: 'SHA-256' } },
true,
['sign', 'verify']
);
const exportedAgain = await crypto.subtle.exportKey('jwk', importedKey);
console.log('exported again: ' + JSON.stringify(exportedAgain));
// should print
// INFO[0000] exported again: {"k":"H6gLp3lw7w27NrPUn00WpcKU-IJojJdNzhL_8F6se2k","kty":"oct","ext":true,"key_ops":["sign","verify"],"alg":"HS256"} source=console
}Was this page helpful?
Related resources from Grafana Labs

