jose 4.3.0 → 4.3.5
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/dist/browser/jwks/remote.js +16 -12
- package/dist/browser/jws/compact/verify.js +1 -5
- package/dist/node/cjs/jwks/remote.js +16 -12
- package/dist/node/cjs/jws/compact/verify.js +1 -5
- package/dist/node/esm/jwks/remote.js +16 -12
- package/dist/node/esm/jws/compact/verify.js +1 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/jwe/compact/decrypt.d.ts +2 -2
- package/dist/types/jwe/compact/encrypt.d.ts +2 -2
- package/dist/types/jws/compact/sign.d.ts +2 -2
- package/dist/types/jws/compact/verify.d.ts +2 -2
- package/dist/types/jwt/decrypt.d.ts +2 -2
- package/dist/types/jwt/encrypt.d.ts +2 -2
- package/dist/types/jwt/sign.d.ts +2 -2
- package/dist/types/jwt/verify.d.ts +2 -2
- package/dist/types/types.d.ts +14 -4
- package/package.json +1 -1
|
@@ -37,17 +37,21 @@ class RemoteJWKSet {
|
|
|
37
37
|
}
|
|
38
38
|
return Date.now() < this._cooldownStarted + this._cooldownDuration;
|
|
39
39
|
}
|
|
40
|
-
async getKey(protectedHeader) {
|
|
40
|
+
async getKey(protectedHeader, token) {
|
|
41
|
+
const joseHeader = {
|
|
42
|
+
...protectedHeader,
|
|
43
|
+
...token.header,
|
|
44
|
+
};
|
|
41
45
|
if (!this._jwks) {
|
|
42
46
|
await this.reload();
|
|
43
47
|
}
|
|
44
48
|
const candidates = this._jwks.keys.filter((jwk) => {
|
|
45
|
-
let candidate = jwk.kty === getKtyFromAlg(
|
|
46
|
-
if (candidate && typeof
|
|
47
|
-
candidate =
|
|
49
|
+
let candidate = jwk.kty === getKtyFromAlg(joseHeader.alg);
|
|
50
|
+
if (candidate && typeof joseHeader.kid === 'string') {
|
|
51
|
+
candidate = joseHeader.kid === jwk.kid;
|
|
48
52
|
}
|
|
49
53
|
if (candidate && typeof jwk.alg === 'string') {
|
|
50
|
-
candidate =
|
|
54
|
+
candidate = joseHeader.alg === jwk.alg;
|
|
51
55
|
}
|
|
52
56
|
if (candidate && typeof jwk.use === 'string') {
|
|
53
57
|
candidate = jwk.use === 'sig';
|
|
@@ -55,11 +59,11 @@ class RemoteJWKSet {
|
|
|
55
59
|
if (candidate && Array.isArray(jwk.key_ops)) {
|
|
56
60
|
candidate = jwk.key_ops.includes('verify');
|
|
57
61
|
}
|
|
58
|
-
if (candidate &&
|
|
62
|
+
if (candidate && joseHeader.alg === 'EdDSA') {
|
|
59
63
|
candidate = jwk.crv === 'Ed25519' || jwk.crv === 'Ed448';
|
|
60
64
|
}
|
|
61
65
|
if (candidate) {
|
|
62
|
-
switch (
|
|
66
|
+
switch (joseHeader.alg) {
|
|
63
67
|
case 'ES256':
|
|
64
68
|
candidate = jwk.crv === 'P-256';
|
|
65
69
|
break;
|
|
@@ -81,7 +85,7 @@ class RemoteJWKSet {
|
|
|
81
85
|
if (length === 0) {
|
|
82
86
|
if (this.coolingDown() === false) {
|
|
83
87
|
await this.reload();
|
|
84
|
-
return this.getKey(protectedHeader);
|
|
88
|
+
return this.getKey(protectedHeader, token);
|
|
85
89
|
}
|
|
86
90
|
throw new JWKSNoMatchingKey();
|
|
87
91
|
}
|
|
@@ -89,14 +93,14 @@ class RemoteJWKSet {
|
|
|
89
93
|
throw new JWKSMultipleMatchingKeys();
|
|
90
94
|
}
|
|
91
95
|
const cached = this._cached.get(jwk) || this._cached.set(jwk, {}).get(jwk);
|
|
92
|
-
if (cached[
|
|
93
|
-
const keyObject = await importJWK({ ...jwk, ext: true },
|
|
96
|
+
if (cached[joseHeader.alg] === undefined) {
|
|
97
|
+
const keyObject = await importJWK({ ...jwk, ext: true }, joseHeader.alg);
|
|
94
98
|
if (keyObject instanceof Uint8Array || keyObject.type !== 'public') {
|
|
95
99
|
throw new JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
96
100
|
}
|
|
97
|
-
cached[
|
|
101
|
+
cached[joseHeader.alg] = keyObject;
|
|
98
102
|
}
|
|
99
|
-
return cached[
|
|
103
|
+
return cached[joseHeader.alg];
|
|
100
104
|
}
|
|
101
105
|
async reload() {
|
|
102
106
|
if (!this._pendingFetch) {
|
|
@@ -12,11 +12,7 @@ export async function compactVerify(jws, key, options) {
|
|
|
12
12
|
if (length !== 3) {
|
|
13
13
|
throw new JWSInvalid('Invalid Compact JWS');
|
|
14
14
|
}
|
|
15
|
-
const verified = await flattenedVerify({
|
|
16
|
-
payload: (payload || undefined),
|
|
17
|
-
protected: protectedHeader || undefined,
|
|
18
|
-
signature: (signature || undefined),
|
|
19
|
-
}, key, options);
|
|
15
|
+
const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);
|
|
20
16
|
const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };
|
|
21
17
|
if (typeof key === 'function') {
|
|
22
18
|
return { ...result, key: verified.key };
|
|
@@ -40,17 +40,21 @@ class RemoteJWKSet {
|
|
|
40
40
|
}
|
|
41
41
|
return Date.now() < this._cooldownStarted + this._cooldownDuration;
|
|
42
42
|
}
|
|
43
|
-
async getKey(protectedHeader) {
|
|
43
|
+
async getKey(protectedHeader, token) {
|
|
44
|
+
const joseHeader = {
|
|
45
|
+
...protectedHeader,
|
|
46
|
+
...token.header,
|
|
47
|
+
};
|
|
44
48
|
if (!this._jwks) {
|
|
45
49
|
await this.reload();
|
|
46
50
|
}
|
|
47
51
|
const candidates = this._jwks.keys.filter((jwk) => {
|
|
48
|
-
let candidate = jwk.kty === getKtyFromAlg(
|
|
49
|
-
if (candidate && typeof
|
|
50
|
-
candidate =
|
|
52
|
+
let candidate = jwk.kty === getKtyFromAlg(joseHeader.alg);
|
|
53
|
+
if (candidate && typeof joseHeader.kid === 'string') {
|
|
54
|
+
candidate = joseHeader.kid === jwk.kid;
|
|
51
55
|
}
|
|
52
56
|
if (candidate && typeof jwk.alg === 'string') {
|
|
53
|
-
candidate =
|
|
57
|
+
candidate = joseHeader.alg === jwk.alg;
|
|
54
58
|
}
|
|
55
59
|
if (candidate && typeof jwk.use === 'string') {
|
|
56
60
|
candidate = jwk.use === 'sig';
|
|
@@ -58,11 +62,11 @@ class RemoteJWKSet {
|
|
|
58
62
|
if (candidate && Array.isArray(jwk.key_ops)) {
|
|
59
63
|
candidate = jwk.key_ops.includes('verify');
|
|
60
64
|
}
|
|
61
|
-
if (candidate &&
|
|
65
|
+
if (candidate && joseHeader.alg === 'EdDSA') {
|
|
62
66
|
candidate = jwk.crv === 'Ed25519' || jwk.crv === 'Ed448';
|
|
63
67
|
}
|
|
64
68
|
if (candidate) {
|
|
65
|
-
switch (
|
|
69
|
+
switch (joseHeader.alg) {
|
|
66
70
|
case 'ES256':
|
|
67
71
|
candidate = jwk.crv === 'P-256';
|
|
68
72
|
break;
|
|
@@ -84,7 +88,7 @@ class RemoteJWKSet {
|
|
|
84
88
|
if (length === 0) {
|
|
85
89
|
if (this.coolingDown() === false) {
|
|
86
90
|
await this.reload();
|
|
87
|
-
return this.getKey(protectedHeader);
|
|
91
|
+
return this.getKey(protectedHeader, token);
|
|
88
92
|
}
|
|
89
93
|
throw new errors_js_1.JWKSNoMatchingKey();
|
|
90
94
|
}
|
|
@@ -92,14 +96,14 @@ class RemoteJWKSet {
|
|
|
92
96
|
throw new errors_js_1.JWKSMultipleMatchingKeys();
|
|
93
97
|
}
|
|
94
98
|
const cached = this._cached.get(jwk) || this._cached.set(jwk, {}).get(jwk);
|
|
95
|
-
if (cached[
|
|
96
|
-
const keyObject = await (0, import_js_1.importJWK)({ ...jwk, ext: true },
|
|
99
|
+
if (cached[joseHeader.alg] === undefined) {
|
|
100
|
+
const keyObject = await (0, import_js_1.importJWK)({ ...jwk, ext: true }, joseHeader.alg);
|
|
97
101
|
if (keyObject instanceof Uint8Array || keyObject.type !== 'public') {
|
|
98
102
|
throw new errors_js_1.JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
99
103
|
}
|
|
100
|
-
cached[
|
|
104
|
+
cached[joseHeader.alg] = keyObject;
|
|
101
105
|
}
|
|
102
|
-
return cached[
|
|
106
|
+
return cached[joseHeader.alg];
|
|
103
107
|
}
|
|
104
108
|
async reload() {
|
|
105
109
|
if (!this._pendingFetch) {
|
|
@@ -15,11 +15,7 @@ async function compactVerify(jws, key, options) {
|
|
|
15
15
|
if (length !== 3) {
|
|
16
16
|
throw new errors_js_1.JWSInvalid('Invalid Compact JWS');
|
|
17
17
|
}
|
|
18
|
-
const verified = await (0, verify_js_1.flattenedVerify)({
|
|
19
|
-
payload: (payload || undefined),
|
|
20
|
-
protected: protectedHeader || undefined,
|
|
21
|
-
signature: (signature || undefined),
|
|
22
|
-
}, key, options);
|
|
18
|
+
const verified = await (0, verify_js_1.flattenedVerify)({ payload, protected: protectedHeader, signature }, key, options);
|
|
23
19
|
const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };
|
|
24
20
|
if (typeof key === 'function') {
|
|
25
21
|
return { ...result, key: verified.key };
|
|
@@ -37,17 +37,21 @@ class RemoteJWKSet {
|
|
|
37
37
|
}
|
|
38
38
|
return Date.now() < this._cooldownStarted + this._cooldownDuration;
|
|
39
39
|
}
|
|
40
|
-
async getKey(protectedHeader) {
|
|
40
|
+
async getKey(protectedHeader, token) {
|
|
41
|
+
const joseHeader = {
|
|
42
|
+
...protectedHeader,
|
|
43
|
+
...token.header,
|
|
44
|
+
};
|
|
41
45
|
if (!this._jwks) {
|
|
42
46
|
await this.reload();
|
|
43
47
|
}
|
|
44
48
|
const candidates = this._jwks.keys.filter((jwk) => {
|
|
45
|
-
let candidate = jwk.kty === getKtyFromAlg(
|
|
46
|
-
if (candidate && typeof
|
|
47
|
-
candidate =
|
|
49
|
+
let candidate = jwk.kty === getKtyFromAlg(joseHeader.alg);
|
|
50
|
+
if (candidate && typeof joseHeader.kid === 'string') {
|
|
51
|
+
candidate = joseHeader.kid === jwk.kid;
|
|
48
52
|
}
|
|
49
53
|
if (candidate && typeof jwk.alg === 'string') {
|
|
50
|
-
candidate =
|
|
54
|
+
candidate = joseHeader.alg === jwk.alg;
|
|
51
55
|
}
|
|
52
56
|
if (candidate && typeof jwk.use === 'string') {
|
|
53
57
|
candidate = jwk.use === 'sig';
|
|
@@ -55,11 +59,11 @@ class RemoteJWKSet {
|
|
|
55
59
|
if (candidate && Array.isArray(jwk.key_ops)) {
|
|
56
60
|
candidate = jwk.key_ops.includes('verify');
|
|
57
61
|
}
|
|
58
|
-
if (candidate &&
|
|
62
|
+
if (candidate && joseHeader.alg === 'EdDSA') {
|
|
59
63
|
candidate = jwk.crv === 'Ed25519' || jwk.crv === 'Ed448';
|
|
60
64
|
}
|
|
61
65
|
if (candidate) {
|
|
62
|
-
switch (
|
|
66
|
+
switch (joseHeader.alg) {
|
|
63
67
|
case 'ES256':
|
|
64
68
|
candidate = jwk.crv === 'P-256';
|
|
65
69
|
break;
|
|
@@ -81,7 +85,7 @@ class RemoteJWKSet {
|
|
|
81
85
|
if (length === 0) {
|
|
82
86
|
if (this.coolingDown() === false) {
|
|
83
87
|
await this.reload();
|
|
84
|
-
return this.getKey(protectedHeader);
|
|
88
|
+
return this.getKey(protectedHeader, token);
|
|
85
89
|
}
|
|
86
90
|
throw new JWKSNoMatchingKey();
|
|
87
91
|
}
|
|
@@ -89,14 +93,14 @@ class RemoteJWKSet {
|
|
|
89
93
|
throw new JWKSMultipleMatchingKeys();
|
|
90
94
|
}
|
|
91
95
|
const cached = this._cached.get(jwk) || this._cached.set(jwk, {}).get(jwk);
|
|
92
|
-
if (cached[
|
|
93
|
-
const keyObject = await importJWK({ ...jwk, ext: true },
|
|
96
|
+
if (cached[joseHeader.alg] === undefined) {
|
|
97
|
+
const keyObject = await importJWK({ ...jwk, ext: true }, joseHeader.alg);
|
|
94
98
|
if (keyObject instanceof Uint8Array || keyObject.type !== 'public') {
|
|
95
99
|
throw new JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
96
100
|
}
|
|
97
|
-
cached[
|
|
101
|
+
cached[joseHeader.alg] = keyObject;
|
|
98
102
|
}
|
|
99
|
-
return cached[
|
|
103
|
+
return cached[joseHeader.alg];
|
|
100
104
|
}
|
|
101
105
|
async reload() {
|
|
102
106
|
if (!this._pendingFetch) {
|
|
@@ -12,11 +12,7 @@ export async function compactVerify(jws, key, options) {
|
|
|
12
12
|
if (length !== 3) {
|
|
13
13
|
throw new JWSInvalid('Invalid Compact JWS');
|
|
14
14
|
}
|
|
15
|
-
const verified = await flattenedVerify({
|
|
16
|
-
payload: (payload || undefined),
|
|
17
|
-
protected: protectedHeader || undefined,
|
|
18
|
-
signature: (signature || undefined),
|
|
19
|
-
}, key, options);
|
|
15
|
+
const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);
|
|
20
16
|
const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };
|
|
21
17
|
if (typeof key === 'function') {
|
|
22
18
|
return { ...result, key: verified.key };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -42,4 +42,4 @@ export type { GenerateKeyPairResult, GenerateKeyPairOptions } from './key/genera
|
|
|
42
42
|
export { generateSecret } from './key/generate_secret';
|
|
43
43
|
export type { GenerateSecretOptions } from './key/generate_secret';
|
|
44
44
|
export * as base64url from './util/base64url';
|
|
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';
|
|
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, CompactJWEHeaderParameters, CompactJWSHeaderParameters, JWTHeaderParameters, } from './types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { KeyLike, DecryptOptions,
|
|
2
|
-
export interface CompactDecryptGetKey extends GetKeyFunction<
|
|
1
|
+
import type { KeyLike, DecryptOptions, CompactJWEHeaderParameters, GetKeyFunction, FlattenedJWE, CompactDecryptResult, ResolvedKey } from '../../types';
|
|
2
|
+
export interface CompactDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParameters, FlattenedJWE> {
|
|
3
3
|
}
|
|
4
4
|
export declare function compactDecrypt(jwe: string | Uint8Array, key: KeyLike | Uint8Array, options?: DecryptOptions): Promise<CompactDecryptResult>;
|
|
5
5
|
export declare function compactDecrypt(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult & ResolvedKey>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { KeyLike, JWEKeyManagementHeaderParameters,
|
|
1
|
+
import type { KeyLike, JWEKeyManagementHeaderParameters, CompactJWEHeaderParameters, EncryptOptions } from '../../types';
|
|
2
2
|
export declare class CompactEncrypt {
|
|
3
3
|
private _flattened;
|
|
4
4
|
constructor(plaintext: Uint8Array);
|
|
5
5
|
setContentEncryptionKey(cek: Uint8Array): this;
|
|
6
6
|
setInitializationVector(iv: Uint8Array): this;
|
|
7
|
-
setProtectedHeader(protectedHeader:
|
|
7
|
+
setProtectedHeader(protectedHeader: CompactJWEHeaderParameters): this;
|
|
8
8
|
setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters): this;
|
|
9
9
|
encrypt(key: KeyLike | Uint8Array, options?: EncryptOptions): Promise<string>;
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompactJWSHeaderParameters, KeyLike, SignOptions } from '../../types';
|
|
2
2
|
export declare class CompactSign {
|
|
3
3
|
private _flattened;
|
|
4
4
|
constructor(payload: Uint8Array);
|
|
5
|
-
setProtectedHeader(protectedHeader:
|
|
5
|
+
setProtectedHeader(protectedHeader: CompactJWSHeaderParameters): this;
|
|
6
6
|
sign(key: KeyLike | Uint8Array, options?: SignOptions): Promise<string>;
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction,
|
|
2
|
-
export interface CompactVerifyGetKey extends GetKeyFunction<
|
|
1
|
+
import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction, CompactJWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
|
|
2
|
+
export interface CompactVerifyGetKey extends GetKeyFunction<CompactJWSHeaderParameters, FlattenedJWSInput> {
|
|
3
3
|
}
|
|
4
4
|
export declare function compactVerify(jws: string | Uint8Array, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<CompactVerifyResult>;
|
|
5
5
|
export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { KeyLike, DecryptOptions, JWTClaimVerificationOptions, GetKeyFunction,
|
|
1
|
+
import type { KeyLike, DecryptOptions, JWTClaimVerificationOptions, GetKeyFunction, CompactJWEHeaderParameters, FlattenedJWE, JWTDecryptResult, ResolvedKey } from '../types';
|
|
2
2
|
export interface JWTDecryptOptions extends DecryptOptions, JWTClaimVerificationOptions {
|
|
3
3
|
}
|
|
4
|
-
export interface JWTDecryptGetKey extends GetKeyFunction<
|
|
4
|
+
export interface JWTDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParameters, FlattenedJWE> {
|
|
5
5
|
}
|
|
6
6
|
export declare function jwtDecrypt(jwt: string | Uint8Array, key: KeyLike | Uint8Array, options?: JWTDecryptOptions): Promise<JWTDecryptResult>;
|
|
7
7
|
export declare function jwtDecrypt(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EncryptOptions,
|
|
1
|
+
import type { EncryptOptions, CompactJWEHeaderParameters, JWEKeyManagementHeaderParameters, KeyLike } from '../types';
|
|
2
2
|
import { ProduceJWT } from './produce';
|
|
3
3
|
export declare class EncryptJWT extends ProduceJWT {
|
|
4
4
|
private _cek;
|
|
@@ -8,7 +8,7 @@ export declare class EncryptJWT extends ProduceJWT {
|
|
|
8
8
|
private _replicateIssuerAsHeader;
|
|
9
9
|
private _replicateSubjectAsHeader;
|
|
10
10
|
private _replicateAudienceAsHeader;
|
|
11
|
-
setProtectedHeader(protectedHeader:
|
|
11
|
+
setProtectedHeader(protectedHeader: CompactJWEHeaderParameters): this;
|
|
12
12
|
setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters): this;
|
|
13
13
|
setContentEncryptionKey(cek: Uint8Array): this;
|
|
14
14
|
setInitializationVector(iv: Uint8Array): this;
|
package/dist/types/jwt/sign.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JWTHeaderParameters, KeyLike, SignOptions } from '../types';
|
|
2
2
|
import { ProduceJWT } from './produce';
|
|
3
3
|
export declare class SignJWT extends ProduceJWT {
|
|
4
4
|
private _protectedHeader;
|
|
5
|
-
setProtectedHeader(protectedHeader:
|
|
5
|
+
setProtectedHeader(protectedHeader: JWTHeaderParameters): this;
|
|
6
6
|
sign(key: KeyLike | Uint8Array, options?: SignOptions): Promise<string>;
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { KeyLike, VerifyOptions, JWTClaimVerificationOptions,
|
|
1
|
+
import type { KeyLike, VerifyOptions, JWTClaimVerificationOptions, JWTHeaderParameters, GetKeyFunction, FlattenedJWSInput, JWTVerifyResult, ResolvedKey } from '../types';
|
|
2
2
|
export interface JWTVerifyOptions extends VerifyOptions, JWTClaimVerificationOptions {
|
|
3
3
|
}
|
|
4
|
-
export interface JWTVerifyGetKey extends GetKeyFunction<
|
|
4
|
+
export interface JWTVerifyGetKey extends GetKeyFunction<JWTHeaderParameters, FlattenedJWSInput> {
|
|
5
5
|
}
|
|
6
6
|
export declare function jwtVerify(jwt: string | Uint8Array, key: KeyLike | Uint8Array, options?: JWTVerifyOptions): Promise<JWTVerifyResult>;
|
|
7
7
|
export declare function jwtVerify(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult & ResolvedKey>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -235,7 +235,7 @@ export interface FlattenedDecryptResult {
|
|
|
235
235
|
export interface GeneralDecryptResult extends FlattenedDecryptResult {}
|
|
236
236
|
export interface CompactDecryptResult {
|
|
237
237
|
plaintext: Uint8Array
|
|
238
|
-
protectedHeader:
|
|
238
|
+
protectedHeader: CompactJWEHeaderParameters
|
|
239
239
|
}
|
|
240
240
|
export interface FlattenedVerifyResult {
|
|
241
241
|
payload: Uint8Array
|
|
@@ -245,16 +245,26 @@ export interface FlattenedVerifyResult {
|
|
|
245
245
|
export interface GeneralVerifyResult extends FlattenedVerifyResult {}
|
|
246
246
|
export interface CompactVerifyResult {
|
|
247
247
|
payload: Uint8Array
|
|
248
|
-
protectedHeader:
|
|
248
|
+
protectedHeader: CompactJWSHeaderParameters
|
|
249
249
|
}
|
|
250
250
|
export interface JWTVerifyResult {
|
|
251
251
|
payload: JWTPayload
|
|
252
|
-
protectedHeader:
|
|
252
|
+
protectedHeader: JWTHeaderParameters
|
|
253
253
|
}
|
|
254
254
|
export interface JWTDecryptResult {
|
|
255
255
|
payload: JWTPayload
|
|
256
|
-
protectedHeader:
|
|
256
|
+
protectedHeader: CompactJWEHeaderParameters
|
|
257
257
|
}
|
|
258
258
|
export interface ResolvedKey {
|
|
259
259
|
key: KeyLike | Uint8Array
|
|
260
260
|
}
|
|
261
|
+
export interface CompactJWSHeaderParameters extends JWSHeaderParameters {
|
|
262
|
+
alg: string
|
|
263
|
+
}
|
|
264
|
+
export interface JWTHeaderParameters extends CompactJWSHeaderParameters {
|
|
265
|
+
b64?: never
|
|
266
|
+
}
|
|
267
|
+
export interface CompactJWEHeaderParameters extends JWEHeaderParameters {
|
|
268
|
+
alg: string
|
|
269
|
+
enc: string
|
|
270
|
+
}
|