docs: apply the changes from ^1

This commit is contained in:
Filip Skokan 2021-11-10 15:10:56 +01:00
parent 3925ebc561
commit ce2c55ba1e
31 changed files with 39 additions and 501 deletions

View file

@ -6,28 +6,13 @@ The CompactEncrypt class is a utility for creating Compact JWE strings.
```js
const encoder = new TextEncoder()
const jwe = await new CompactEncrypt(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
const jwe = await new jose.CompactEncrypt(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
.setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM' })
.encrypt(publicKey)
console.log(jwe)
```
**`example`** ESM import
```js
import { CompactEncrypt } from 'jose'
```
**`example`** CJS import
```js
const { CompactEncrypt } = require('jose')
```
**`example`** Deno import
```js
import { CompactEncrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -7,7 +7,7 @@ objects.
```js
const encoder = new TextEncoder()
const jwe = await new FlattenedEncrypt(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
const jwe = await new jose.FlattenedEncrypt(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
.setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM' })
.setAdditionalAuthenticatedData(encoder.encode('The Fellowship of the Ring'))
.encrypt(publicKey)
@ -15,21 +15,6 @@ const jwe = await new FlattenedEncrypt(encoder.encode('Its a dangerous busine
console.log(jwe)
```
**`example`** ESM import
```js
import { FlattenedEncrypt } from 'jose'
```
**`example`** CJS import
```js
const { FlattenedEncrypt } = require('jose')
```
**`example`** Deno import
```js
import { FlattenedEncrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -6,7 +6,7 @@ The GeneralEncrypt class is a utility for creating General JWE objects.
```js
const encoder = new TextEncoder()
const encrypt = new GeneralEncrypt(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
const encrypt = new jose.GeneralEncrypt(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
.setProtectedHeader({ enc: 'A256GCM' })
encrypt
@ -20,21 +20,6 @@ encrypt
const jwe = await encrypt.encrypt()
```
**`example`** ESM import
```js
import { GeneralEncrypt } from 'jose'
```
**`example`** CJS import
```js
const { GeneralEncrypt } = require('jose')
```
**`example`** Deno import
```js
import { GeneralEncrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -6,28 +6,13 @@ The CompactSign class is a utility for creating Compact JWS strings.
```js
const encoder = new TextEncoder()
const jws = await new CompactSign(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
const jws = await new jose.CompactSign(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
.setProtectedHeader({ alg: 'ES256' })
.sign(privateKey)
console.log(jws)
```
**`example`** ESM import
```js
import { CompactSign } from 'jose'
```
**`example`** CJS import
```js
const { CompactSign } = require('jose')
```
**`example`** Deno import
```js
import { CompactSign } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -6,27 +6,12 @@ The FlattenedSign class is a utility for creating Flattened JWS objects.
```js
const encoder = new TextEncoder()
const jws = await new FlattenedSign(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
const jws = await new jose.FlattenedSign(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
.setProtectedHeader({ alg: 'ES256' })
.sign(privateKey)
console.log(jws)
```
**`example`** ESM import
```js
import { FlattenedSign } from 'jose'
```
**`example`** CJS import
```js
const { FlattenedSign } = require('jose')
```
**`example`** Deno import
```js
import { FlattenedSign } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -6,7 +6,7 @@ The GeneralSign class is a utility for creating General JWS objects.
```js
const encoder = new TextEncoder()
const sign = new GeneralSign(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
const sign = new jose.GeneralSign(encoder.encode('Its a dangerous business, Frodo, going out your door.'))
sign
.addSignature(ecPrivateKey)
@ -19,21 +19,6 @@ sign
const jws = await sign.sign()
```
**`example`** ESM import
```js
import { GeneralSign } from 'jose'
```
**`example`** CJS import
```js
const { GeneralSign } = require('jose')
```
**`example`** Deno import
```js
import { GeneralSign } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -4,7 +4,7 @@ The EncryptJWT class is a utility for creating Compact JWE formatted JWT strings
**`example`** Usage
```js
const jwt = await new EncryptJWT({ 'urn:example:claim': true })
const jwt = await new jose.EncryptJWT({ 'urn:example:claim': true })
.setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
.setIssuedAt()
.setIssuer('urn:example:issuer')
@ -15,21 +15,6 @@ const jwt = await new EncryptJWT({ 'urn:example:claim': true })
console.log(jwt)
```
**`example`** ESM import
```js
import { EncryptJWT } from 'jose'
```
**`example`** CJS import
```js
const { EncryptJWT } = require('jose')
```
**`example`** Deno import
```js
import { EncryptJWT } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -4,7 +4,7 @@ The SignJWT class is a utility for creating Compact JWS formatted JWT strings.
**`example`** Usage
```js
const jwt = await new SignJWT({ 'urn:example:claim': true })
const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
.setProtectedHeader({ alg: 'ES256' })
.setIssuedAt()
.setIssuer('urn:example:issuer')
@ -15,21 +15,6 @@ const jwt = await new SignJWT({ 'urn:example:claim': true })
console.log(jwt)
```
**`example`** ESM import
```js
import { SignJWT } from 'jose'
```
**`example`** CJS import
```js
const { SignJWT } = require('jose')
```
**`example`** Deno import
```js
import { SignJWT } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -4,7 +4,7 @@ The UnsecuredJWT class is a utility for dealing with `{ "alg": "none" }` Unsecur
**`example`** Encoding
```js *
const unsecuredJwt = new UnsecuredJWT({ 'urn:example:claim': true })
const unsecuredJwt = new jose.UnsecuredJWT({ 'urn:example:claim': true })
.setIssuedAt()
.setIssuer('urn:example:issuer')
.setAudience('urn:example:audience')
@ -16,7 +16,7 @@ console.log(unsecuredJwt)
**`example`** Decoding
```js *
const payload = new UnsecuredJWT.decode(jwt, {
const payload = new jose.UnsecuredJWT.decode(jwt, {
issuer: 'urn:example:issuer',
audience: 'urn:example:audience'
})
@ -24,21 +24,6 @@ const payload = new UnsecuredJWT.decode(jwt, {
console.log(payload)
```
**`example`** ESM import
```js
import { UnsecuredJWT } from 'jose'
```
**`example`** CJS import
```js
const { UnsecuredJWT } = require('jose')
```
**`example`** Deno import
```js
import { UnsecuredJWT } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
## Table of contents
### Constructors

View file

@ -9,27 +9,12 @@ Decrypts a Compact JWE.
const decoder = new TextDecoder()
const jwe = 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0.nyQ19eq9ogh9wA7fFtnI2oouzy5_8b5DeLkoRMfi2yijgfTs2zEnayCEofz_qhnL-nwszabd9qUeHv0-IwvhhJJS7GUJOU3ikiIe42qcIAFme1A_Fo9CTxw4XTOy-I5qanl8So91u6hwfyN1VxAqVLsSE7_23EC-gfGEg_5znew9PyXXsOIE-K_HH7IQowRrlZ1X_bM_Liu53RzDpLDvRz59mp3S8L56YqpM8FexFGTGpEaoTcEIst375qncYt3-79IVR7gZN1RWsWgjPatfvVbnh74PglQcATSf3UUhaW0OAKn6q7r3PDx6DIKQ35bgHQg5QopuN00eIfLQL2trGw.W3grIVj5HVuAb76X.6PcuDe5D6ttWFYyv0oqqdDXfI2R8wBg1F2Q80UUA_Gv8eEimNWfxIWdLxrjzgQGSvIhxmFKuLM0.a93_Ug3uZHuczj70Zavx8Q'
const { plaintext, protectedHeader } = await compactDecrypt(jwe, privateKey)
const { plaintext, protectedHeader } = await jose.compactDecrypt(jwe, privateKey)
console.log(protectedHeader)
console.log(decoder.decode(plaintext))
```
**`example`** ESM import
```js
import { compactDecrypt } from 'jose'
```
**`example`** CJS import
```js
const { compactDecrypt } = require('jose')
```
**`example`** Deno import
```js
import { compactDecrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -20,28 +20,13 @@ const {
plaintext,
protectedHeader,
additionalAuthenticatedData
} = await flattenedDecrypt(jwe, privateKey)
} = await jose.flattenedDecrypt(jwe, privateKey)
console.log(protectedHeader)
console.log(decoder.decode(plaintext))
console.log(decoder.decode(additionalAuthenticatedData))
```
**`example`** ESM import
```js
import { flattenedDecrypt } from 'jose'
```
**`example`** CJS import
```js
const { flattenedDecrypt } = require('jose')
```
**`example`** Deno import
```js
import { flattenedDecrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -4,21 +4,6 @@
Decrypts a General JWE.
**`example`** ESM import
```js
import { generalDecrypt } from 'jose'
```
**`example`** CJS import
```js
const { generalDecrypt } = require('jose')
```
**`example`** Deno import
```js
import { generalDecrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
**`example`** Usage
```js
const decoder = new TextDecoder()
@ -39,7 +24,7 @@ const {
plaintext,
protectedHeader,
additionalAuthenticatedData
} = await generalDecrypt(jwe, privateKey)
} = await jose.generalDecrypt(jwe, privateKey)
console.log(protectedHeader)
console.log(decoder.decode(plaintext))

View file

@ -10,11 +10,9 @@ JWS algorithms to accept.
**`example`** Usage
```js
import { jwtVerify } from 'jose'
const jwt = 'eyJqd2siOnsiY3J2IjoiUC0yNTYiLCJ4IjoiVU05ZzVuS25aWFlvdldBbE03NmNMejl2VG96UmpfX0NIVV9kT2wtZ09vRSIsInkiOiJkczhhZVF3MWwyY0RDQTdiQ2tPTnZ3REtwWEFidFhqdnFDbGVZSDhXc19VIiwia3R5IjoiRUMifSwiYWxnIjoiRVMyNTYifQ.eyJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSIsImlhdCI6MTYwNDU4MDc5NH0.60boak3_dErnW47ZPty1C0nrjeVq86EN_eK0GOq6K8w2OA0thKoBxFK4j-NuU9yZ_A9UKGxPT_G87DladBaV9g'
const { payload, protectedHeader } = await jwtVerify(jwt, EmbeddedJWK, {
const { payload, protectedHeader } = await jose.jwtVerify(jwt, jose.EmbeddedJWK, {
issuer: 'urn:example:issuer',
audience: 'urn:example:audience'
})
@ -23,21 +21,6 @@ console.log(protectedHeader)
console.log(payload)
```
**`example`** ESM import
```js
import { EmbeddedJWK } from 'jose'
```
**`example`** CJS import
```js
const { EmbeddedJWK } = require('jose')
```
**`example`** Deno import
```js
import { EmbeddedJWK } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type |

View file

@ -7,7 +7,7 @@ Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint as per
**`example`** Usage
```js
const thumbprint = await calculateJwkThumbprint({
const thumbprint = await jose.calculateJwkThumbprint({
kty: 'RSA',
e: 'AQAB',
n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'
@ -16,21 +16,6 @@ const thumbprint = await calculateJwkThumbprint({
console.log(thumbprint)
```
**`example`** ESM import
```js
import { calculateJwkThumbprint } from 'jose'
```
**`example`** CJS import
```js
const { calculateJwkThumbprint } = require('jose')
```
**`example`** Deno import
```js
import { calculateJwkThumbprint } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Default value | Description |

View file

@ -9,11 +9,9 @@ the selection process.
**`example`** Usage
```js
import { jwtVerify } from 'jose'
const JWKS = jose.createRemoteJWKSet(new URL('https://www.googleapis.com/oauth2/v3/certs'))
const JWKS = createRemoteJWKSet(new URL('https://www.googleapis.com/oauth2/v3/certs'))
const { payload, protectedHeader } = await jwtVerify(jwt, JWKS, {
const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
issuer: 'urn:example:issuer',
audience: 'urn:example:audience'
})
@ -21,21 +19,6 @@ console.log(protectedHeader)
console.log(payload)
```
**`example`** ESM import
```js
import { createRemoteJWKSet } from 'jose'
```
**`example`** CJS import
```js
const { createRemoteJWKSet } = require('jose')
```
**`example`** Deno import
```js
import { createRemoteJWKSet } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -9,27 +9,12 @@ Verifies the signature and format of and afterwards decodes the Compact JWS.
const decoder = new TextDecoder()
const jws = 'eyJhbGciOiJFUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4.kkAs_gPPxWMI3rHuVlxHaTPfDWDoqdI8jSvuSmqV-8IHIWXg9mcAeC9ggV-45ZHRbiRJ3obUIFo1rHphPA5URg'
const { payload, protectedHeader } = await compactVerify(jws, publicKey)
const { payload, protectedHeader } = await jose.compactVerify(jws, publicKey)
console.log(protectedHeader)
console.log(decoder.decode(payload))
```
**`example`** ESM import
```js
import { compactVerify } from 'jose'
```
**`example`** CJS import
```js
const { compactVerify } = require('jose')
```
**`example`** Deno import
```js
import { compactVerify } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -13,27 +13,12 @@ const jws = {
protected: 'eyJhbGciOiJFUzI1NiJ9'
}
const { payload, protectedHeader } = await flattenedVerify(jws, publicKey)
const { payload, protectedHeader } = await jose.flattenedVerify(jws, publicKey)
console.log(protectedHeader)
console.log(decoder.decode(payload))
```
**`example`** ESM import
```js
import { flattenedVerify } from 'jose'
```
**`example`** CJS import
```js
const { flattenedVerify } = require('jose')
```
**`example`** Deno import
```js
import { flattenedVerify } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -17,27 +17,12 @@ const jws = {
]
}
const { payload, protectedHeader } = await generalVerify(jws, publicKey)
const { payload, protectedHeader } = await jose.generalVerify(jws, publicKey)
console.log(protectedHeader)
console.log(decoder.decode(payload))
```
**`example`** ESM import
```js
import { generalVerify } from 'jose'
```
**`example`** CJS import
```js
const { generalVerify } = require('jose')
```
**`example`** Deno import
```js
import { generalVerify } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -8,7 +8,7 @@ Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, v
```js
const jwt = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..KVcNLqK-3-8ZkYIC.xSwF4VxO0kUMUD2W-cifsNUxnr-swyBq-nADBptyt6y9n79-iNc5b0AALJpRwc0wwDkJw8hNOMjApNUTMsK9b-asToZ3DXFMvwfJ6n1aWefvd7RsoZ2LInWFfVAuttJDzoGB.uuexQoWHwrLMEYRElT8pBQ'
const { payload, protectedHeader } = await jwtDecrypt(jwt, secretKey, {
const { payload, protectedHeader } = await jose.jwtDecrypt(jwt, secretKey, {
issuer: 'urn:example:issuer',
audience: 'urn:example:audience'
})
@ -17,21 +17,6 @@ console.log(protectedHeader)
console.log(payload)
```
**`example`** ESM import
```js
import { jwtDecrypt } from 'jose'
```
**`example`** CJS import
```js
const { jwtDecrypt } = require('jose')
```
**`example`** Deno import
```js
import { jwtDecrypt } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -8,7 +8,7 @@ Verifies the JWT format (to be a JWS Compact format), verifies the JWS signature
```js
const jwt = 'eyJhbGciOiJFUzI1NiJ9.eyJ1cm46ZXhhbXBsZTpjbGFpbSI6dHJ1ZSwiaWF0IjoxNjA0MzE1MDc0LCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSJ9.hx1nOfAT5LlXuzu8O-bhjXBGpklWDt2EsHw7-MDn49NrnwvVsstNhEnkW2ddauB7eSikFtUNeumLpFI9CWDBsg'
const { payload, protectedHeader } = await jwtVerify(jwt, publicKey, {
const { payload, protectedHeader } = await jose.jwtVerify(jwt, publicKey, {
issuer: 'urn:example:issuer',
audience: 'urn:example:audience'
})
@ -17,21 +17,6 @@ console.log(protectedHeader)
console.log(payload)
```
**`example`** ESM import
```js
import { jwtVerify } from 'jose'
```
**`example`** CJS import
```js
const { jwtVerify } = require('jose')
```
**`example`** Deno import
```js
import { jwtVerify } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -6,28 +6,13 @@ Exports a runtime-specific key representation (KeyLike) to a JWK.
**`example`** Usage
```js
const privateJwk = await exportJWK(privateKey)
const publicJwk = await exportJWK(publicKey)
const privateJwk = await jose.exportJWK(privateKey)
const publicJwk = await jose.exportJWK(publicKey)
console.log(privateJwk)
console.log(publicJwk)
```
**`example`** ESM import
```js
import { exportJWK } from 'jose'
```
**`example`** CJS import
```js
const { exportJWK } = require('jose')
```
**`example`** Deno import
```js
import { exportJWK } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -6,26 +6,11 @@ Exports a runtime-specific private key representation (KeyObject or CryptoKey) t
**`example`** Usage
```js
const pkcs8Pem = await exportPKCS8(privateKey)
const pkcs8Pem = await jose.exportPKCS8(privateKey)
console.log(pkcs8Pem)
```
**`example`** ESM import
```js
import { exportPKCS8 } from 'jose'
```
**`example`** CJS import
```js
const { exportPKCS8 } = require('jose')
```
**`example`** Deno import
```js
import { exportPKCS8 } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -6,26 +6,11 @@ Exports a runtime-specific public key representation (KeyObject or CryptoKey) to
**`example`** Usage
```js
const spkiPem = await exportSPKI(publicKey)
const spkiPem = await jose.exportSPKI(publicKey)
console.log(spkiPem)
```
**`example`** ESM import
```js
import { exportSPKI } from 'jose'
```
**`example`** CJS import
```js
const { exportSPKI } = require('jose')
```
**`example`** Deno import
```js
import { exportSPKI } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -11,26 +11,11 @@ Note: Under Web Cryptography API runtime the `privateKey` is generated with
**`example`** Usage
```js
const { publicKey, privateKey } = await generateKeyPair('PS256')
const { publicKey, privateKey } = await jose.generateKeyPair('PS256')
console.log(publicKey)
console.log(privateKey)
```
**`example`** ESM import
```js
import { generateKeyPair } from 'jose'
```
**`example`** CJS import
```js
const { generateKeyPair } = require('jose')
```
**`example`** Deno import
```js
import { generateKeyPair } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -9,25 +9,10 @@ Note: Under Web Cryptography API runtime the secret key is generated with
**`example`** Usage
```js
const secret = await generateSecret('HS256')
const secret = await jose.generateSecret('HS256')
console.log(secret)
```
**`example`** ESM import
```js
import { generateSecret } from 'jose'
```
**`example`** CJS import
```js
const { generateSecret } = require('jose')
```
**`example`** Deno import
```js
import { generateSecret } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -11,35 +11,20 @@ requirements and mapping.
**`example`** Usage
```js
const ecPublicKey = await importJWK({
const ecPublicKey = await jose.importJWK({
crv: 'P-256',
kty: 'EC',
x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo'
}, 'ES256')
const rsaPublicKey = await importJWK({
const rsaPublicKey = await jose.importJWK({
kty: 'RSA',
e: 'AQAB',
n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'
}, 'PS256')
```
**`example`** ESM import
```js
import { importJWK } from 'jose'
```
**`example`** CJS import
```js
const { importJWK } = require('jose')
```
**`example`** Deno import
```js
import { importJWK } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -14,22 +14,7 @@ MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
-----END PRIVATE KEY-----`
const ecPrivateKey = await importPKCS8(pkcs8, algorithm)
```
**`example`** ESM import
```js
import { importPKCS8 } from 'jose'
```
**`example`** CJS import
```js
const { importPKCS8 } = require('jose')
```
**`example`** Deno import
```js
import { importPKCS8 } from 'https://deno.land/x/jose@v4.2.1/index.ts'
const ecPrivateKey = await jose.importPKCS8(pkcs8, algorithm)
```
#### Parameters

View file

@ -13,22 +13,7 @@ const spki = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
-----END PUBLIC KEY-----`
const ecPublicKey = await importSPKI(spki, algorithm)
```
**`example`** ESM import
```js
import { importSPKI } from 'jose'
```
**`example`** CJS import
```js
const { importSPKI } = require('jose')
```
**`example`** Deno import
```js
import { importSPKI } from 'https://deno.land/x/jose@v4.2.1/index.ts'
const ecPublicKey = await jose.importSPKI(spki, algorithm)
```
#### Parameters

View file

@ -19,22 +19,7 @@ UH+kBKDnphJO3odpPZ5gvgKs2nwRWcrDnUjYLDAKBggqhkjOPQQDAgNIADBFAiEA
1yyMTRe66MhEXID9+uVub7woMkNYd0LhSHwKSPMUUTkCIFQGsfm1ecXOpeGOufAh
v+A1QWZMuTWqYt+uh/YSRNDn
-----END CERTIFICATE-----`
const ecPublicKey = await importX509(x509, algorithm)
```
**`example`** ESM import
```js
import { importX509 } from 'jose'
```
**`example`** CJS import
```js
const { importX509 } = require('jose')
```
**`example`** Deno import
```js
import { importX509 } from 'https://deno.land/x/jose@v4.2.1/index.ts'
const ecPublicKey = await jose.importX509(x509, algorithm)
```
#### Parameters

View file

@ -6,25 +6,10 @@ Decodes the Protected Header of a JWE/JWS/JWT token utilizing any JOSE serializa
**`example`** Usage
```js
const protectedHeader = decodeProtectedHeader(token)
const protectedHeader = jose.decodeProtectedHeader(token)
console.log(protectedHeader)
```
**`example`** ESM import
```js
import { decodeProtectedHeader } from 'jose'
```
**`example`** CJS import
```js
const { decodeProtectedHeader } = require('jose')
```
**`example`** Deno import
```js
import { decodeProtectedHeader } from 'https://deno.land/x/jose@v4.2.1/index.ts'
```
#### Parameters
| Name | Type | Description |

View file

@ -38,20 +38,16 @@ to obtain a CryptoKey from your existing key material.
**`example`** Import a PEM-encoded SPKI Public Key
```js
import { importSPKI } from 'jose'
const algorithm = 'ES256'
const spki = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
-----END PUBLIC KEY-----`
const ecPublicKey = await importSPKI(spki, algorithm)
const ecPublicKey = await jose.importSPKI(spki, algorithm)
```
**`example`** Import a X.509 Certificate
```js
import { importX509 } from 'jose'
const algorithm = 'ES256'
const x509 = `-----BEGIN CERTIFICATE-----
MIIBXjCCAQSgAwIBAgIGAXvykuMKMAoGCCqGSM49BAMCMDYxNDAyBgNVBAMMK3Np
@ -63,34 +59,30 @@ UH+kBKDnphJO3odpPZ5gvgKs2nwRWcrDnUjYLDAKBggqhkjOPQQDAgNIADBFAiEA
1yyMTRe66MhEXID9+uVub7woMkNYd0LhSHwKSPMUUTkCIFQGsfm1ecXOpeGOufAh
v+A1QWZMuTWqYt+uh/YSRNDn
-----END CERTIFICATE-----`
const ecPublicKey = await importX509(x509, algorithm)
const ecPublicKey = await jose.importX509(x509, algorithm)
```
**`example`** Import a PEM-encoded PKCS8 Private Key
```js
import { importPKCS8 } from 'jose'
const algorithm = 'ES256'
const pkcs8 = `-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
-----END PRIVATE KEY-----`
const ecPrivateKey = await importPKCS8(pkcs8, algorithm)
const ecPrivateKey = await jose.importPKCS8(pkcs8, algorithm)
```
**`example`** Import a JSON Web Key (JWK)
```js
import { importJWK } from 'jose'
const ecPublicKey = await importJWK({
const ecPublicKey = await jose.importJWK({
crv: 'P-256',
kty: 'EC',
x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo'
}, 'ES256')
const rsaPublicKey = await importJWK({
const rsaPublicKey = await jose.importJWK({
kty: 'RSA',
e: 'AQAB',
n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'