jose 4.1.4 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/browser/index.js +1 -0
- package/dist/browser/jwe/flattened/encrypt.js +15 -4
- package/dist/browser/jwe/general/decrypt.js +3 -0
- package/dist/browser/jwe/general/encrypt.js +171 -0
- package/dist/browser/jws/general/sign.js +25 -29
- package/dist/browser/key/import.js +2 -1
- package/dist/browser/lib/cek.js +5 -6
- package/dist/browser/lib/decrypt_key_management.js +1 -1
- package/dist/browser/lib/encrypt_key_management.js +1 -1
- package/dist/browser/lib/iv.js +4 -11
- package/dist/browser/runtime/aeskw.js +2 -1
- package/dist/browser/runtime/asn1.js +2 -1
- package/dist/browser/runtime/decrypt.js +2 -1
- package/dist/browser/runtime/ecdhes.js +5 -4
- package/dist/browser/runtime/encrypt.js +2 -1
- package/dist/browser/runtime/get_sign_verify_key.js +3 -2
- package/dist/browser/runtime/key_to_jwk.js +2 -1
- package/dist/browser/runtime/pbes2kw.js +2 -1
- package/dist/browser/runtime/rsaes.js +3 -2
- package/dist/node/cjs/index.js +9 -7
- package/dist/node/cjs/jwe/flattened/encrypt.js +16 -5
- package/dist/node/cjs/jwe/general/decrypt.js +3 -0
- package/dist/node/cjs/jwe/general/encrypt.js +175 -0
- package/dist/node/cjs/jws/general/sign.js +25 -29
- package/dist/node/cjs/key/import.js +2 -1
- package/dist/node/cjs/lib/cek.js +5 -6
- package/dist/node/cjs/lib/decrypt_key_management.js +1 -1
- package/dist/node/cjs/lib/encrypt_key_management.js +1 -1
- package/dist/node/cjs/lib/iv.js +4 -11
- package/dist/node/cjs/runtime/aeskw.js +4 -3
- package/dist/node/cjs/runtime/asn1.js +2 -1
- package/dist/node/cjs/runtime/decrypt.js +13 -10
- package/dist/node/cjs/runtime/ecdhes.js +5 -4
- package/dist/node/cjs/runtime/encrypt.js +7 -5
- package/dist/node/cjs/runtime/get_named_curve.js +2 -1
- package/dist/node/cjs/runtime/get_sign_verify_key.js +3 -2
- package/dist/node/cjs/runtime/key_to_jwk.js +2 -1
- package/dist/node/cjs/runtime/pbes2kw.js +2 -1
- package/dist/node/cjs/runtime/rsaes.js +4 -3
- package/dist/node/esm/index.js +1 -0
- package/dist/node/esm/jwe/flattened/encrypt.js +15 -4
- package/dist/node/esm/jwe/general/decrypt.js +3 -0
- package/dist/node/esm/jwe/general/encrypt.js +171 -0
- package/dist/node/esm/jws/general/sign.js +25 -29
- package/dist/node/esm/key/import.js +2 -1
- package/dist/node/esm/lib/cek.js +5 -6
- package/dist/node/esm/lib/decrypt_key_management.js +1 -1
- package/dist/node/esm/lib/encrypt_key_management.js +1 -1
- package/dist/node/esm/lib/iv.js +4 -11
- package/dist/node/esm/runtime/aeskw.js +4 -3
- package/dist/node/esm/runtime/asn1.js +2 -1
- package/dist/node/esm/runtime/decrypt.js +13 -10
- package/dist/node/esm/runtime/ecdhes.js +5 -4
- package/dist/node/esm/runtime/encrypt.js +7 -5
- package/dist/node/esm/runtime/get_named_curve.js +2 -1
- package/dist/node/esm/runtime/get_sign_verify_key.js +3 -2
- package/dist/node/esm/runtime/key_to_jwk.js +2 -1
- package/dist/node/esm/runtime/pbes2kw.js +2 -1
- package/dist/node/esm/runtime/rsaes.js +4 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/jwe/flattened/encrypt.d.ts +1 -0
- package/dist/types/jwe/general/encrypt.d.ts +20 -0
- package/dist/types/jws/general/sign.d.ts +3 -0
- package/dist/types/types.d.ts +7 -14
- package/package.json +1 -1
|
@@ -8,8 +8,9 @@ import { isCryptoKey } from './webcrypto.js';
|
|
|
8
8
|
import { checkEncCryptoKey } from '../lib/crypto_key.js';
|
|
9
9
|
import isKeyObject from './is_key_object.js';
|
|
10
10
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
11
|
+
import { types } from './is_key_like.js';
|
|
11
12
|
const generateKeyPair = promisify(generateKeyPairCb);
|
|
12
|
-
export const deriveKey =
|
|
13
|
+
export const deriveKey = (publicKee, privateKee, algorithm, keyLength, apu = new Uint8Array(0), apv = new Uint8Array(0)) => {
|
|
13
14
|
let publicKey;
|
|
14
15
|
if (isCryptoKey(publicKee)) {
|
|
15
16
|
checkEncCryptoKey(publicKee, 'ECDH-ES');
|
|
@@ -19,7 +20,7 @@ export const deriveKey = async (publicKee, privateKee, algorithm, keyLength, apu
|
|
|
19
20
|
publicKey = publicKee;
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
|
-
throw new TypeError(invalidKeyInput(publicKee,
|
|
23
|
+
throw new TypeError(invalidKeyInput(publicKee, ...types));
|
|
23
24
|
}
|
|
24
25
|
let privateKey;
|
|
25
26
|
if (isCryptoKey(privateKee)) {
|
|
@@ -30,7 +31,7 @@ export const deriveKey = async (publicKee, privateKee, algorithm, keyLength, apu
|
|
|
30
31
|
privateKey = privateKee;
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
throw new TypeError(invalidKeyInput(privateKee,
|
|
34
|
+
throw new TypeError(invalidKeyInput(privateKee, ...types));
|
|
34
35
|
}
|
|
35
36
|
const value = concat(lengthAndInput(encoder.encode(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));
|
|
36
37
|
const sharedSecret = diffieHellman({ privateKey, publicKey });
|
|
@@ -45,7 +46,7 @@ export const generateEpk = async (kee) => {
|
|
|
45
46
|
key = kee;
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
|
-
throw new TypeError(invalidKeyInput(kee,
|
|
49
|
+
throw new TypeError(invalidKeyInput(kee, ...types));
|
|
49
50
|
}
|
|
50
51
|
switch (key.asymmetricKeyType) {
|
|
51
52
|
case 'x25519':
|
|
@@ -9,7 +9,8 @@ import isKeyObject from './is_key_object.js';
|
|
|
9
9
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
10
10
|
import { JOSENotSupported } from '../util/errors.js';
|
|
11
11
|
import supported from './ciphers.js';
|
|
12
|
-
|
|
12
|
+
import { types } from './is_key_like.js';
|
|
13
|
+
function cbcEncrypt(enc, plaintext, cek, iv, aad) {
|
|
13
14
|
const keySize = parseInt(enc.substr(1, 3), 10);
|
|
14
15
|
if (isKeyObject(cek)) {
|
|
15
16
|
cek = cek.export();
|
|
@@ -26,7 +27,7 @@ async function cbcEncrypt(enc, plaintext, cek, iv, aad) {
|
|
|
26
27
|
const tag = cbcTag(aad, iv, ciphertext, macSize, macKey, keySize);
|
|
27
28
|
return { ciphertext, tag };
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
function gcmEncrypt(enc, plaintext, cek, iv, aad) {
|
|
30
31
|
const keySize = parseInt(enc.substr(1, 3), 10);
|
|
31
32
|
const algorithm = `aes-${keySize}-gcm`;
|
|
32
33
|
if (!supported(algorithm)) {
|
|
@@ -36,11 +37,12 @@ async function gcmEncrypt(enc, plaintext, cek, iv, aad) {
|
|
|
36
37
|
if (aad.byteLength) {
|
|
37
38
|
cipher.setAAD(aad, { plaintextLength: plaintext.length });
|
|
38
39
|
}
|
|
39
|
-
const ciphertext =
|
|
40
|
+
const ciphertext = cipher.update(plaintext);
|
|
41
|
+
cipher.final();
|
|
40
42
|
const tag = cipher.getAuthTag();
|
|
41
43
|
return { ciphertext, tag };
|
|
42
44
|
}
|
|
43
|
-
const encrypt =
|
|
45
|
+
const encrypt = (enc, plaintext, cek, iv, aad) => {
|
|
44
46
|
let key;
|
|
45
47
|
if (isCryptoKey(cek)) {
|
|
46
48
|
checkEncCryptoKey(cek, enc, 'encrypt');
|
|
@@ -50,7 +52,7 @@ const encrypt = async (enc, plaintext, cek, iv, aad) => {
|
|
|
50
52
|
key = cek;
|
|
51
53
|
}
|
|
52
54
|
else {
|
|
53
|
-
throw new TypeError(invalidKeyInput(cek,
|
|
55
|
+
throw new TypeError(invalidKeyInput(cek, ...types, 'Uint8Array'));
|
|
54
56
|
}
|
|
55
57
|
checkCekLength(enc, key);
|
|
56
58
|
checkIvLength(enc, iv);
|
|
@@ -4,6 +4,7 @@ import { JOSENotSupported } from '../util/errors.js';
|
|
|
4
4
|
import { isCryptoKey } from './webcrypto.js';
|
|
5
5
|
import isKeyObject from './is_key_object.js';
|
|
6
6
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
7
|
+
import { types } from './is_key_like.js';
|
|
7
8
|
const p256 = Buffer.from([42, 134, 72, 206, 61, 3, 1, 7]);
|
|
8
9
|
const p384 = Buffer.from([43, 129, 4, 0, 34]);
|
|
9
10
|
const p521 = Buffer.from([43, 129, 4, 0, 35]);
|
|
@@ -33,7 +34,7 @@ const getNamedCurve = (kee, raw) => {
|
|
|
33
34
|
key = kee;
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
throw new TypeError(invalidKeyInput(kee,
|
|
37
|
+
throw new TypeError(invalidKeyInput(kee, ...types));
|
|
37
38
|
}
|
|
38
39
|
if (key.type === 'secret') {
|
|
39
40
|
throw new TypeError('only "private" or "public" type keys can be used for this operation');
|
|
@@ -3,10 +3,11 @@ import { isCryptoKey } from './webcrypto.js';
|
|
|
3
3
|
import { checkSigCryptoKey } from '../lib/crypto_key.js';
|
|
4
4
|
import getSecretKey from './secret_key.js';
|
|
5
5
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
6
|
+
import { types } from './is_key_like.js';
|
|
6
7
|
export default function getSignVerifyKey(alg, key, usage) {
|
|
7
8
|
if (key instanceof Uint8Array) {
|
|
8
9
|
if (!alg.startsWith('HS')) {
|
|
9
|
-
throw new TypeError(invalidKeyInput(key,
|
|
10
|
+
throw new TypeError(invalidKeyInput(key, ...types));
|
|
10
11
|
}
|
|
11
12
|
return getSecretKey(key);
|
|
12
13
|
}
|
|
@@ -17,5 +18,5 @@ export default function getSignVerifyKey(alg, key, usage) {
|
|
|
17
18
|
checkSigCryptoKey(key, alg, usage);
|
|
18
19
|
return KeyObject.from(key);
|
|
19
20
|
}
|
|
20
|
-
throw new TypeError(invalidKeyInput(key,
|
|
21
|
+
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
|
|
21
22
|
}
|
|
@@ -6,6 +6,7 @@ import getNamedCurve from './get_named_curve.js';
|
|
|
6
6
|
import { isCryptoKey } from './webcrypto.js';
|
|
7
7
|
import isKeyObject from './is_key_object.js';
|
|
8
8
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
9
|
+
import { types } from './is_key_like.js';
|
|
9
10
|
const [major, minor] = process.version
|
|
10
11
|
.substr(1)
|
|
11
12
|
.split('.')
|
|
@@ -29,7 +30,7 @@ const keyToJWK = (key) => {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
|
-
throw new TypeError(invalidKeyInput(key,
|
|
33
|
+
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
|
|
33
34
|
}
|
|
34
35
|
if (jwkExportSupported) {
|
|
35
36
|
return keyObject.export({ format: 'jwk' });
|
|
@@ -9,6 +9,7 @@ import { isCryptoKey } from './webcrypto.js';
|
|
|
9
9
|
import { checkEncCryptoKey } from '../lib/crypto_key.js';
|
|
10
10
|
import isKeyObject from './is_key_object.js';
|
|
11
11
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
12
|
+
import { types } from './is_key_like.js';
|
|
12
13
|
const pbkdf2 = promisify(pbkdf2cb);
|
|
13
14
|
function getPassword(key, alg) {
|
|
14
15
|
if (isKeyObject(key)) {
|
|
@@ -21,7 +22,7 @@ function getPassword(key, alg) {
|
|
|
21
22
|
checkEncCryptoKey(key, alg, 'deriveBits', 'deriveKey');
|
|
22
23
|
return KeyObject.from(key).export();
|
|
23
24
|
}
|
|
24
|
-
throw new TypeError(invalidKeyInput(key,
|
|
25
|
+
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
|
|
25
26
|
}
|
|
26
27
|
export const encrypt = async (alg, key, cek, p2c = Math.floor(Math.random() * 2049) + 2048, p2s = random(new Uint8Array(16))) => {
|
|
27
28
|
checkP2s(p2s);
|
|
@@ -4,6 +4,7 @@ import { isCryptoKey } from './webcrypto.js';
|
|
|
4
4
|
import { checkEncCryptoKey } from '../lib/crypto_key.js';
|
|
5
5
|
import isKeyObject from './is_key_object.js';
|
|
6
6
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
7
|
+
import { types } from './is_key_like.js';
|
|
7
8
|
const checkKey = (key, alg) => {
|
|
8
9
|
if (key.asymmetricKeyType !== 'rsa') {
|
|
9
10
|
throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa');
|
|
@@ -45,16 +46,16 @@ function ensureKeyObject(key, alg, ...usages) {
|
|
|
45
46
|
checkEncCryptoKey(key, alg, ...usages);
|
|
46
47
|
return KeyObject.from(key);
|
|
47
48
|
}
|
|
48
|
-
throw new TypeError(invalidKeyInput(key,
|
|
49
|
+
throw new TypeError(invalidKeyInput(key, ...types));
|
|
49
50
|
}
|
|
50
|
-
export const encrypt =
|
|
51
|
+
export const encrypt = (alg, key, cek) => {
|
|
51
52
|
const padding = resolvePadding(alg);
|
|
52
53
|
const oaepHash = resolveOaepHash(alg);
|
|
53
54
|
const keyObject = ensureKeyObject(key, alg, 'wrapKey', 'encrypt');
|
|
54
55
|
checkKey(keyObject, alg);
|
|
55
56
|
return publicEncrypt({ key: keyObject, oaepHash, padding }, cek);
|
|
56
57
|
};
|
|
57
|
-
export const decrypt =
|
|
58
|
+
export const decrypt = (alg, key, encryptedKey) => {
|
|
58
59
|
const padding = resolvePadding(alg);
|
|
59
60
|
const oaepHash = resolveOaepHash(alg);
|
|
60
61
|
const keyObject = ensureKeyObject(key, alg, 'unwrapKey', 'decrypt');
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { flattenedDecrypt } from './jwe/flattened/decrypt';
|
|
|
4
4
|
export type { FlattenedDecryptGetKey } from './jwe/flattened/decrypt';
|
|
5
5
|
export { generalDecrypt } from './jwe/general/decrypt';
|
|
6
6
|
export type { GeneralDecryptGetKey } from './jwe/general/decrypt';
|
|
7
|
+
export { GeneralEncrypt } from './jwe/general/encrypt';
|
|
8
|
+
export type { Recipient } from './jwe/general/encrypt';
|
|
7
9
|
export { compactVerify } from './jws/compact/verify';
|
|
8
10
|
export type { CompactVerifyGetKey } from './jws/compact/verify';
|
|
9
11
|
export { flattenedVerify } from './jws/flattened/verify';
|
|
@@ -40,4 +42,4 @@ export type { GenerateKeyPairResult, GenerateKeyPairOptions } from './key/genera
|
|
|
40
42
|
export { generateSecret } from './key/generate_secret';
|
|
41
43
|
export type { GenerateSecretOptions } from './key/generate_secret';
|
|
42
44
|
export * as base64url from './util/base64url';
|
|
43
|
-
export type { KeyLike, JWK, FlattenedJWSInput, GeneralJWSInput, FlattenedJWS, GeneralJWS, JoseHeaderParameters, JWSHeaderParameters, JWEKeyManagementHeaderParameters, FlattenedJWE, GeneralJWE, JWEHeaderParameters, CritOption, DecryptOptions, EncryptOptions, JWTClaimVerificationOptions, VerifyOptions, SignOptions, JWTPayload, DeflateFunction, InflateFunction, FlattenedDecryptResult, GeneralDecryptResult, CompactDecryptResult, FlattenedVerifyResult, GeneralVerifyResult, CompactVerifyResult, JWTVerifyResult, JWTDecryptResult, ResolvedKey, } from './types';
|
|
45
|
+
export type { KeyLike, JWK, FlattenedJWSInput, GeneralJWSInput, FlattenedJWS, GeneralJWS, JoseHeaderParameters, JWSHeaderParameters, JWEKeyManagementHeaderParameters, FlattenedJWE, GeneralJWE, JWEHeaderParameters, CritOption, DeflateOption, DecryptOptions, EncryptOptions, JWTClaimVerificationOptions, VerifyOptions, SignOptions, JWTPayload, DeflateFunction, InflateFunction, FlattenedDecryptResult, GeneralDecryptResult, CompactDecryptResult, FlattenedVerifyResult, GeneralVerifyResult, CompactVerifyResult, JWTVerifyResult, JWTDecryptResult, ResolvedKey, } from './types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KeyLike, GeneralJWE, JWEHeaderParameters, CritOption, DeflateOption } from '../../types';
|
|
2
|
+
export interface Recipient {
|
|
3
|
+
setUnprotectedHeader(unprotectedHeader: JWEHeaderParameters): Recipient;
|
|
4
|
+
addRecipient(...args: Parameters<GeneralEncrypt['addRecipient']>): Recipient;
|
|
5
|
+
encrypt(...args: Parameters<GeneralEncrypt['encrypt']>): Promise<GeneralJWE>;
|
|
6
|
+
done(): GeneralEncrypt;
|
|
7
|
+
}
|
|
8
|
+
export declare class GeneralEncrypt {
|
|
9
|
+
private _plaintext;
|
|
10
|
+
private _recipients;
|
|
11
|
+
private _protectedHeader;
|
|
12
|
+
private _unprotectedHeader;
|
|
13
|
+
private _aad;
|
|
14
|
+
constructor(plaintext: Uint8Array);
|
|
15
|
+
addRecipient(key: KeyLike | Uint8Array, options?: CritOption): Recipient;
|
|
16
|
+
setProtectedHeader(protectedHeader: JWEHeaderParameters): this;
|
|
17
|
+
setSharedUnprotectedHeader(sharedUnprotectedHeader: JWEHeaderParameters): this;
|
|
18
|
+
setAdditionalAuthenticatedData(aad: Uint8Array): this;
|
|
19
|
+
encrypt(options?: DeflateOption): Promise<GeneralJWE>;
|
|
20
|
+
}
|
|
@@ -2,6 +2,9 @@ import type { KeyLike, GeneralJWS, JWSHeaderParameters, SignOptions } from '../.
|
|
|
2
2
|
export interface Signature {
|
|
3
3
|
setProtectedHeader(protectedHeader: JWSHeaderParameters): Signature;
|
|
4
4
|
setUnprotectedHeader(unprotectedHeader: JWSHeaderParameters): Signature;
|
|
5
|
+
addSignature(...args: Parameters<GeneralSign['addSignature']>): Signature;
|
|
6
|
+
sign(...args: Parameters<GeneralSign['sign']>): Promise<GeneralJWS>;
|
|
7
|
+
done(): GeneralSign;
|
|
5
8
|
}
|
|
6
9
|
export declare class GeneralSign {
|
|
7
10
|
private _payload;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -35,20 +35,16 @@
|
|
|
35
35
|
*
|
|
36
36
|
* @example Import a PEM-encoded SPKI Public Key
|
|
37
37
|
* ```js
|
|
38
|
-
* import { importSPKI } from 'jose'
|
|
39
|
-
*
|
|
40
38
|
* const algorithm = 'ES256'
|
|
41
39
|
* const spki = `-----BEGIN PUBLIC KEY-----
|
|
42
40
|
* MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
|
|
43
41
|
* YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
|
|
44
42
|
* -----END PUBLIC KEY-----`
|
|
45
|
-
* const ecPublicKey = await importSPKI(spki, algorithm)
|
|
43
|
+
* const ecPublicKey = await jose.importSPKI(spki, algorithm)
|
|
46
44
|
* ```
|
|
47
45
|
*
|
|
48
46
|
* @example Import a X.509 Certificate
|
|
49
47
|
* ```js
|
|
50
|
-
* import { importX509 } from 'jose'
|
|
51
|
-
*
|
|
52
48
|
* const algorithm = 'ES256'
|
|
53
49
|
* const x509 = `-----BEGIN CERTIFICATE-----
|
|
54
50
|
* MIIBXjCCAQSgAwIBAgIGAXvykuMKMAoGCCqGSM49BAMCMDYxNDAyBgNVBAMMK3Np
|
|
@@ -60,34 +56,30 @@
|
|
|
60
56
|
* 1yyMTRe66MhEXID9+uVub7woMkNYd0LhSHwKSPMUUTkCIFQGsfm1ecXOpeGOufAh
|
|
61
57
|
* v+A1QWZMuTWqYt+uh/YSRNDn
|
|
62
58
|
* -----END CERTIFICATE-----`
|
|
63
|
-
* const ecPublicKey = await importX509(x509, algorithm)
|
|
59
|
+
* const ecPublicKey = await jose.importX509(x509, algorithm)
|
|
64
60
|
* ```
|
|
65
61
|
*
|
|
66
62
|
* @example Import a PEM-encoded PKCS8 Private Key
|
|
67
63
|
* ```js
|
|
68
|
-
* import { importPKCS8 } from 'jose'
|
|
69
|
-
*
|
|
70
64
|
* const algorithm = 'ES256'
|
|
71
65
|
* const pkcs8 = `-----BEGIN PRIVATE KEY-----
|
|
72
66
|
* MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
|
|
73
67
|
* nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
|
|
74
68
|
* l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
|
|
75
69
|
* -----END PRIVATE KEY-----`
|
|
76
|
-
* const ecPrivateKey = await importPKCS8(pkcs8, algorithm)
|
|
70
|
+
* const ecPrivateKey = await jose.importPKCS8(pkcs8, algorithm)
|
|
77
71
|
* ```
|
|
78
72
|
*
|
|
79
73
|
* @example Import a JSON Web Key (JWK)
|
|
80
74
|
* ```js
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* const ecPublicKey = await importJWK({
|
|
75
|
+
* const ecPublicKey = await jose.importJWK({
|
|
84
76
|
* crv: 'P-256',
|
|
85
77
|
* kty: 'EC',
|
|
86
78
|
* x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
|
|
87
79
|
* y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo'
|
|
88
80
|
* }, 'ES256')
|
|
89
81
|
*
|
|
90
|
-
* const rsaPublicKey = await importJWK({
|
|
82
|
+
* const rsaPublicKey = await jose.importJWK({
|
|
91
83
|
* kty: 'RSA',
|
|
92
84
|
* e: 'AQAB',
|
|
93
85
|
* n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'
|
|
@@ -200,9 +192,10 @@ export interface DecryptOptions extends CritOption {
|
|
|
200
192
|
contentEncryptionAlgorithms?: string[]
|
|
201
193
|
inflateRaw?: InflateFunction
|
|
202
194
|
}
|
|
203
|
-
export interface
|
|
195
|
+
export interface DeflateOption {
|
|
204
196
|
deflateRaw?: DeflateFunction
|
|
205
197
|
}
|
|
198
|
+
export interface EncryptOptions extends CritOption, DeflateOption {}
|
|
206
199
|
export interface JWTClaimVerificationOptions {
|
|
207
200
|
audience?: string | string[]
|
|
208
201
|
clockTolerance?: string | number
|