jose 4.12.2 → 4.13.1
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 +1 -1
- package/dist/browser/jwk/embedded.js +1 -1
- package/dist/browser/jwks/local.js +7 -4
- package/dist/browser/jwks/remote.js +18 -27
- package/dist/node/cjs/jwk/embedded.js +1 -1
- package/dist/node/cjs/jwks/local.js +7 -4
- package/dist/node/cjs/jwks/remote.js +18 -27
- package/dist/node/esm/jwk/embedded.js +1 -1
- package/dist/node/esm/jwks/local.js +7 -4
- package/dist/node/esm/jwks/remote.js +18 -27
- package/dist/types/jwe/compact/decrypt.d.ts +1 -1
- package/dist/types/jwe/flattened/decrypt.d.ts +1 -1
- package/dist/types/jwe/general/decrypt.d.ts +1 -1
- package/dist/types/jwk/embedded.d.ts +1 -1
- package/dist/types/jwks/local.d.ts +3 -3
- package/dist/types/jwks/remote.d.ts +1 -1
- package/dist/types/jws/compact/verify.d.ts +1 -1
- package/dist/types/jws/flattened/verify.d.ts +1 -1
- package/dist/types/jws/general/verify.d.ts +1 -1
- package/dist/types/jwt/decrypt.d.ts +1 -1
- package/dist/types/jwt/verify.d.ts +1 -1
- package/dist/types/key/generate_key_pair.d.ts +4 -4
- package/dist/types/key/generate_secret.d.ts +1 -1
- package/dist/types/key/import.d.ts +4 -4
- package/dist/types/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ import { JWSInvalid } from '../util/errors.js';
|
|
|
4
4
|
export async function EmbeddedJWK(protectedHeader, token) {
|
|
5
5
|
const joseHeader = {
|
|
6
6
|
...protectedHeader,
|
|
7
|
-
...token.header,
|
|
7
|
+
...token === null || token === void 0 ? void 0 : token.header,
|
|
8
8
|
};
|
|
9
9
|
if (!isObject(joseHeader.jwk)) {
|
|
10
10
|
throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
|
|
@@ -100,14 +100,17 @@ export class LocalJWKSet {
|
|
|
100
100
|
async function importWithAlgCache(cache, jwk, alg) {
|
|
101
101
|
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
|
|
102
102
|
if (cached[alg] === undefined) {
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const key = await importJWK({ ...jwk, ext: true }, alg);
|
|
104
|
+
if (key instanceof Uint8Array || key.type !== 'public') {
|
|
105
105
|
throw new JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
106
106
|
}
|
|
107
|
-
cached[alg] =
|
|
107
|
+
cached[alg] = key;
|
|
108
108
|
}
|
|
109
109
|
return cached[alg];
|
|
110
110
|
}
|
|
111
111
|
export function createLocalJWKSet(jwks) {
|
|
112
|
-
|
|
112
|
+
const set = new LocalJWKSet(jwks);
|
|
113
|
+
return async function (protectedHeader, token) {
|
|
114
|
+
return set.getKey(protectedHeader, token);
|
|
115
|
+
};
|
|
113
116
|
}
|
|
@@ -46,36 +46,27 @@ class RemoteJWKSet extends LocalJWKSet {
|
|
|
46
46
|
}
|
|
47
47
|
async reload() {
|
|
48
48
|
if (this._pendingFetch && isCloudflareWorkers()) {
|
|
49
|
-
|
|
50
|
-
const isDone = () => {
|
|
51
|
-
if (this._pendingFetch === undefined) {
|
|
52
|
-
resolve();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
setTimeout(isDone, 5);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
isDone();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (!this._pendingFetch) {
|
|
62
|
-
this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)
|
|
63
|
-
.then((json) => {
|
|
64
|
-
if (!isJWKSLike(json)) {
|
|
65
|
-
throw new JWKSInvalid('JSON Web Key Set malformed');
|
|
66
|
-
}
|
|
67
|
-
this._jwks = { keys: json.keys };
|
|
68
|
-
this._jwksTimestamp = Date.now();
|
|
69
|
-
this._pendingFetch = undefined;
|
|
70
|
-
})
|
|
71
|
-
.catch((err) => {
|
|
72
|
-
this._pendingFetch = undefined;
|
|
73
|
-
throw err;
|
|
74
|
-
});
|
|
49
|
+
this._pendingFetch = undefined;
|
|
75
50
|
}
|
|
51
|
+
this._pendingFetch || (this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)
|
|
52
|
+
.then((json) => {
|
|
53
|
+
if (!isJWKSLike(json)) {
|
|
54
|
+
throw new JWKSInvalid('JSON Web Key Set malformed');
|
|
55
|
+
}
|
|
56
|
+
this._jwks = { keys: json.keys };
|
|
57
|
+
this._jwksTimestamp = Date.now();
|
|
58
|
+
this._pendingFetch = undefined;
|
|
59
|
+
})
|
|
60
|
+
.catch((err) => {
|
|
61
|
+
this._pendingFetch = undefined;
|
|
62
|
+
throw err;
|
|
63
|
+
}));
|
|
76
64
|
await this._pendingFetch;
|
|
77
65
|
}
|
|
78
66
|
}
|
|
79
67
|
export function createRemoteJWKSet(url, options) {
|
|
80
|
-
|
|
68
|
+
const set = new RemoteJWKSet(url, options);
|
|
69
|
+
return async function (protectedHeader, token) {
|
|
70
|
+
return set.getKey(protectedHeader, token);
|
|
71
|
+
};
|
|
81
72
|
}
|
|
@@ -7,7 +7,7 @@ const errors_js_1 = require("../util/errors.js");
|
|
|
7
7
|
async function EmbeddedJWK(protectedHeader, token) {
|
|
8
8
|
const joseHeader = {
|
|
9
9
|
...protectedHeader,
|
|
10
|
-
...token.header,
|
|
10
|
+
...token === null || token === void 0 ? void 0 : token.header,
|
|
11
11
|
};
|
|
12
12
|
if (!(0, is_object_js_1.default)(joseHeader.jwk)) {
|
|
13
13
|
throw new errors_js_1.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
|
|
@@ -105,15 +105,18 @@ exports.LocalJWKSet = LocalJWKSet;
|
|
|
105
105
|
async function importWithAlgCache(cache, jwk, alg) {
|
|
106
106
|
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
|
|
107
107
|
if (cached[alg] === undefined) {
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
108
|
+
const key = await (0, import_js_1.importJWK)({ ...jwk, ext: true }, alg);
|
|
109
|
+
if (key instanceof Uint8Array || key.type !== 'public') {
|
|
110
110
|
throw new errors_js_1.JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
111
111
|
}
|
|
112
|
-
cached[alg] =
|
|
112
|
+
cached[alg] = key;
|
|
113
113
|
}
|
|
114
114
|
return cached[alg];
|
|
115
115
|
}
|
|
116
116
|
function createLocalJWKSet(jwks) {
|
|
117
|
-
|
|
117
|
+
const set = new LocalJWKSet(jwks);
|
|
118
|
+
return async function (protectedHeader, token) {
|
|
119
|
+
return set.getKey(protectedHeader, token);
|
|
120
|
+
};
|
|
118
121
|
}
|
|
119
122
|
exports.createLocalJWKSet = createLocalJWKSet;
|
|
@@ -49,37 +49,28 @@ class RemoteJWKSet extends local_js_1.LocalJWKSet {
|
|
|
49
49
|
}
|
|
50
50
|
async reload() {
|
|
51
51
|
if (this._pendingFetch && (0, env_js_1.isCloudflareWorkers)()) {
|
|
52
|
-
|
|
53
|
-
const isDone = () => {
|
|
54
|
-
if (this._pendingFetch === undefined) {
|
|
55
|
-
resolve();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
setTimeout(isDone, 5);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
isDone();
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
if (!this._pendingFetch) {
|
|
65
|
-
this._pendingFetch = (0, fetch_jwks_js_1.default)(this._url, this._timeoutDuration, this._options)
|
|
66
|
-
.then((json) => {
|
|
67
|
-
if (!(0, local_js_1.isJWKSLike)(json)) {
|
|
68
|
-
throw new errors_js_1.JWKSInvalid('JSON Web Key Set malformed');
|
|
69
|
-
}
|
|
70
|
-
this._jwks = { keys: json.keys };
|
|
71
|
-
this._jwksTimestamp = Date.now();
|
|
72
|
-
this._pendingFetch = undefined;
|
|
73
|
-
})
|
|
74
|
-
.catch((err) => {
|
|
75
|
-
this._pendingFetch = undefined;
|
|
76
|
-
throw err;
|
|
77
|
-
});
|
|
52
|
+
this._pendingFetch = undefined;
|
|
78
53
|
}
|
|
54
|
+
this._pendingFetch || (this._pendingFetch = (0, fetch_jwks_js_1.default)(this._url, this._timeoutDuration, this._options)
|
|
55
|
+
.then((json) => {
|
|
56
|
+
if (!(0, local_js_1.isJWKSLike)(json)) {
|
|
57
|
+
throw new errors_js_1.JWKSInvalid('JSON Web Key Set malformed');
|
|
58
|
+
}
|
|
59
|
+
this._jwks = { keys: json.keys };
|
|
60
|
+
this._jwksTimestamp = Date.now();
|
|
61
|
+
this._pendingFetch = undefined;
|
|
62
|
+
})
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
this._pendingFetch = undefined;
|
|
65
|
+
throw err;
|
|
66
|
+
}));
|
|
79
67
|
await this._pendingFetch;
|
|
80
68
|
}
|
|
81
69
|
}
|
|
82
70
|
function createRemoteJWKSet(url, options) {
|
|
83
|
-
|
|
71
|
+
const set = new RemoteJWKSet(url, options);
|
|
72
|
+
return async function (protectedHeader, token) {
|
|
73
|
+
return set.getKey(protectedHeader, token);
|
|
74
|
+
};
|
|
84
75
|
}
|
|
85
76
|
exports.createRemoteJWKSet = createRemoteJWKSet;
|
|
@@ -4,7 +4,7 @@ import { JWSInvalid } from '../util/errors.js';
|
|
|
4
4
|
export async function EmbeddedJWK(protectedHeader, token) {
|
|
5
5
|
const joseHeader = {
|
|
6
6
|
...protectedHeader,
|
|
7
|
-
...token.header,
|
|
7
|
+
...token === null || token === void 0 ? void 0 : token.header,
|
|
8
8
|
};
|
|
9
9
|
if (!isObject(joseHeader.jwk)) {
|
|
10
10
|
throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
|
|
@@ -100,14 +100,17 @@ export class LocalJWKSet {
|
|
|
100
100
|
async function importWithAlgCache(cache, jwk, alg) {
|
|
101
101
|
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
|
|
102
102
|
if (cached[alg] === undefined) {
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const key = await importJWK({ ...jwk, ext: true }, alg);
|
|
104
|
+
if (key instanceof Uint8Array || key.type !== 'public') {
|
|
105
105
|
throw new JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
106
106
|
}
|
|
107
|
-
cached[alg] =
|
|
107
|
+
cached[alg] = key;
|
|
108
108
|
}
|
|
109
109
|
return cached[alg];
|
|
110
110
|
}
|
|
111
111
|
export function createLocalJWKSet(jwks) {
|
|
112
|
-
|
|
112
|
+
const set = new LocalJWKSet(jwks);
|
|
113
|
+
return async function (protectedHeader, token) {
|
|
114
|
+
return set.getKey(protectedHeader, token);
|
|
115
|
+
};
|
|
113
116
|
}
|
|
@@ -46,36 +46,27 @@ class RemoteJWKSet extends LocalJWKSet {
|
|
|
46
46
|
}
|
|
47
47
|
async reload() {
|
|
48
48
|
if (this._pendingFetch && isCloudflareWorkers()) {
|
|
49
|
-
|
|
50
|
-
const isDone = () => {
|
|
51
|
-
if (this._pendingFetch === undefined) {
|
|
52
|
-
resolve();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
setTimeout(isDone, 5);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
isDone();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (!this._pendingFetch) {
|
|
62
|
-
this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)
|
|
63
|
-
.then((json) => {
|
|
64
|
-
if (!isJWKSLike(json)) {
|
|
65
|
-
throw new JWKSInvalid('JSON Web Key Set malformed');
|
|
66
|
-
}
|
|
67
|
-
this._jwks = { keys: json.keys };
|
|
68
|
-
this._jwksTimestamp = Date.now();
|
|
69
|
-
this._pendingFetch = undefined;
|
|
70
|
-
})
|
|
71
|
-
.catch((err) => {
|
|
72
|
-
this._pendingFetch = undefined;
|
|
73
|
-
throw err;
|
|
74
|
-
});
|
|
49
|
+
this._pendingFetch = undefined;
|
|
75
50
|
}
|
|
51
|
+
this._pendingFetch || (this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)
|
|
52
|
+
.then((json) => {
|
|
53
|
+
if (!isJWKSLike(json)) {
|
|
54
|
+
throw new JWKSInvalid('JSON Web Key Set malformed');
|
|
55
|
+
}
|
|
56
|
+
this._jwks = { keys: json.keys };
|
|
57
|
+
this._jwksTimestamp = Date.now();
|
|
58
|
+
this._pendingFetch = undefined;
|
|
59
|
+
})
|
|
60
|
+
.catch((err) => {
|
|
61
|
+
this._pendingFetch = undefined;
|
|
62
|
+
throw err;
|
|
63
|
+
}));
|
|
76
64
|
await this._pendingFetch;
|
|
77
65
|
}
|
|
78
66
|
}
|
|
79
67
|
export function createRemoteJWKSet(url, options) {
|
|
80
|
-
|
|
68
|
+
const set = new RemoteJWKSet(url, options);
|
|
69
|
+
return async function (protectedHeader, token) {
|
|
70
|
+
return set.getKey(protectedHeader, token);
|
|
71
|
+
};
|
|
81
72
|
}
|
|
@@ -30,4 +30,4 @@ export declare function compactDecrypt(jwe: string | Uint8Array, key: KeyLike |
|
|
|
30
30
|
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with.
|
|
31
31
|
* @param options JWE Decryption options.
|
|
32
32
|
*/
|
|
33
|
-
export declare function compactDecrypt(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult & ResolvedKey
|
|
33
|
+
export declare function compactDecrypt<T extends KeyLike = KeyLike>(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult & ResolvedKey<T>>;
|
|
@@ -40,4 +40,4 @@ export declare function flattenedDecrypt(jwe: FlattenedJWE, key: KeyLike | Uint8
|
|
|
40
40
|
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with.
|
|
41
41
|
* @param options JWE Decryption options.
|
|
42
42
|
*/
|
|
43
|
-
export declare function flattenedDecrypt(jwe: FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: DecryptOptions): Promise<FlattenedDecryptResult & ResolvedKey
|
|
43
|
+
export declare function flattenedDecrypt<T extends KeyLike = KeyLike>(jwe: FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: DecryptOptions): Promise<FlattenedDecryptResult & ResolvedKey<T>>;
|
|
@@ -44,4 +44,4 @@ export declare function generalDecrypt(jwe: GeneralJWE, key: KeyLike | Uint8Arra
|
|
|
44
44
|
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with.
|
|
45
45
|
* @param options JWE Decryption options.
|
|
46
46
|
*/
|
|
47
|
-
export declare function generalDecrypt(jwe: GeneralJWE, getKey: GeneralDecryptGetKey, options?: DecryptOptions): Promise<GeneralDecryptResult & ResolvedKey
|
|
47
|
+
export declare function generalDecrypt<T extends KeyLike = KeyLike>(jwe: GeneralJWE, getKey: GeneralDecryptGetKey, options?: DecryptOptions): Promise<GeneralDecryptResult & ResolvedKey<T>>;
|
|
@@ -20,4 +20,4 @@ import type { KeyLike, FlattenedJWSInput, JWSHeaderParameters } from '../types';
|
|
|
20
20
|
* console.log(payload)
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export declare function EmbeddedJWK(protectedHeader
|
|
23
|
+
export declare function EmbeddedJWK<T extends KeyLike = KeyLike>(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<T>;
|
|
@@ -2,11 +2,11 @@ import type { KeyLike, JWSHeaderParameters, JSONWebKeySet, FlattenedJWSInput } f
|
|
|
2
2
|
/** @private */
|
|
3
3
|
export declare function isJWKSLike(jwks: unknown): jwks is JSONWebKeySet;
|
|
4
4
|
/** @private */
|
|
5
|
-
export declare class LocalJWKSet {
|
|
5
|
+
export declare class LocalJWKSet<T extends KeyLike = KeyLike> {
|
|
6
6
|
protected _jwks?: JSONWebKeySet;
|
|
7
7
|
private _cached;
|
|
8
8
|
constructor(jwks: unknown);
|
|
9
|
-
getKey(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<
|
|
9
|
+
getKey(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<T>;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Returns a function that resolves to a key object from a locally stored, or otherwise available,
|
|
@@ -82,4 +82,4 @@ export declare class LocalJWKSet {
|
|
|
82
82
|
*
|
|
83
83
|
* @param jwks JSON Web Key Set formatted object.
|
|
84
84
|
*/
|
|
85
|
-
export declare function createLocalJWKSet(jwks: JSONWebKeySet): (protectedHeader?: JWSHeaderParameters
|
|
85
|
+
export declare function createLocalJWKSet<T extends KeyLike = KeyLike>(jwks: JSONWebKeySet): (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<T>;
|
|
@@ -89,4 +89,4 @@ export interface RemoteJWKSetOptions {
|
|
|
89
89
|
* @param url URL to fetch the JSON Web Key Set from.
|
|
90
90
|
* @param options Options for the remote JSON Web Key Set.
|
|
91
91
|
*/
|
|
92
|
-
export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): (protectedHeader?: JWSHeaderParameters
|
|
92
|
+
export declare function createRemoteJWKSet<T extends KeyLike = KeyLike>(url: URL, options?: RemoteJWKSetOptions): (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<T>;
|
|
@@ -34,4 +34,4 @@ export declare function compactVerify(jws: string | Uint8Array, key: KeyLike | U
|
|
|
34
34
|
* @param getKey Function resolving a key to verify the JWS with.
|
|
35
35
|
* @param options JWS Verify options.
|
|
36
36
|
*/
|
|
37
|
-
export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey
|
|
37
|
+
export declare function compactVerify<T extends KeyLike = KeyLike>(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey<T>>;
|
|
@@ -39,4 +39,4 @@ export declare function flattenedVerify(jws: FlattenedJWSInput, key: KeyLike | U
|
|
|
39
39
|
* @param getKey Function resolving a key to verify the JWS with.
|
|
40
40
|
* @param options JWS Verify options.
|
|
41
41
|
*/
|
|
42
|
-
export declare function flattenedVerify(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey
|
|
42
|
+
export declare function flattenedVerify<T extends KeyLike = KeyLike>(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey<T>>;
|
|
@@ -42,4 +42,4 @@ export declare function generalVerify(jws: GeneralJWSInput, key: KeyLike | Uint8
|
|
|
42
42
|
* @param getKey Function resolving a key to verify the JWS with.
|
|
43
43
|
* @param options JWS Verify options.
|
|
44
44
|
*/
|
|
45
|
-
export declare function generalVerify(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey
|
|
45
|
+
export declare function generalVerify<T extends KeyLike = KeyLike>(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey<T>>;
|
|
@@ -38,4 +38,4 @@ export declare function jwtDecrypt(jwt: string | Uint8Array, key: KeyLike | Uint
|
|
|
38
38
|
* @param getKey Function resolving Private Key or Secret to decrypt and verify the JWT with.
|
|
39
39
|
* @param options JWT Decryption and JWT Claims Set validation options.
|
|
40
40
|
*/
|
|
41
|
-
export declare function jwtDecrypt(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey
|
|
41
|
+
export declare function jwtDecrypt<T extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey<T>>;
|
|
@@ -105,4 +105,4 @@ export declare function jwtVerify(jwt: string | Uint8Array, key: KeyLike | Uint8
|
|
|
105
105
|
* @param getKey Function resolving a key to verify the JWT with.
|
|
106
106
|
* @param options JWT Decryption and JWT Claims Set validation options.
|
|
107
107
|
*/
|
|
108
|
-
export declare function jwtVerify(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult & ResolvedKey
|
|
108
|
+
export declare function jwtVerify<T extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult & ResolvedKey<T>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { KeyLike } from '../types';
|
|
2
|
-
export interface GenerateKeyPairResult {
|
|
2
|
+
export interface GenerateKeyPairResult<T extends KeyLike = KeyLike> {
|
|
3
3
|
/** The generated Private Key. */
|
|
4
|
-
privateKey:
|
|
4
|
+
privateKey: T;
|
|
5
5
|
/** Public Key corresponding to the generated Private Key. */
|
|
6
|
-
publicKey:
|
|
6
|
+
publicKey: T;
|
|
7
7
|
}
|
|
8
8
|
export interface GenerateKeyPairOptions {
|
|
9
9
|
/**
|
|
@@ -41,4 +41,4 @@ export interface GenerateKeyPairOptions {
|
|
|
41
41
|
* @param alg JWA Algorithm Identifier to be used with the generated key pair.
|
|
42
42
|
* @param options Additional options passed down to the key pair generation.
|
|
43
43
|
*/
|
|
44
|
-
export declare function generateKeyPair(alg: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult
|
|
44
|
+
export declare function generateKeyPair<T extends KeyLike = KeyLike>(alg: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult<T>>;
|
|
@@ -23,4 +23,4 @@ export interface GenerateSecretOptions {
|
|
|
23
23
|
* @param alg JWA Algorithm Identifier to be used with the generated secret.
|
|
24
24
|
* @param options Additional options passed down to the secret generation.
|
|
25
25
|
*/
|
|
26
|
-
export declare function generateSecret(alg: string, options?: GenerateSecretOptions): Promise<
|
|
26
|
+
export declare function generateSecret<T extends KeyLike = KeyLike>(alg: string, options?: GenerateSecretOptions): Promise<T | Uint8Array>;
|
|
@@ -27,7 +27,7 @@ export interface PEMImportOptions {
|
|
|
27
27
|
* @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
|
|
28
28
|
* with the imported key, its presence is only enforced in Web Crypto API runtimes.
|
|
29
29
|
*/
|
|
30
|
-
export declare function importSPKI(spki: string, alg: string, options?: PEMImportOptions): Promise<
|
|
30
|
+
export declare function importSPKI<T extends KeyLike = KeyLike>(spki: string, alg: string, options?: PEMImportOptions): Promise<T>;
|
|
31
31
|
/**
|
|
32
32
|
* Imports the SPKI from an X.509 string certificate as a runtime-specific public key representation
|
|
33
33
|
* (KeyObject or CryptoKey). See [Algorithm Key
|
|
@@ -55,7 +55,7 @@ export declare function importSPKI(spki: string, alg: string, options?: PEMImpor
|
|
|
55
55
|
* @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
|
|
56
56
|
* with the imported key, its presence is only enforced in Web Crypto API runtimes.
|
|
57
57
|
*/
|
|
58
|
-
export declare function importX509(x509: string, alg: string, options?: PEMImportOptions): Promise<
|
|
58
|
+
export declare function importX509<T extends KeyLike = KeyLike>(x509: string, alg: string, options?: PEMImportOptions): Promise<T>;
|
|
59
59
|
/**
|
|
60
60
|
* Imports a PEM-encoded PKCS#8 string as a runtime-specific private key representation (KeyObject
|
|
61
61
|
* or CryptoKey). See [Algorithm Key Requirements](https://github.com/panva/jose/issues/210) to
|
|
@@ -77,7 +77,7 @@ export declare function importX509(x509: string, alg: string, options?: PEMImpor
|
|
|
77
77
|
* @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
|
|
78
78
|
* with the imported key, its presence is only enforced in Web Crypto API runtimes.
|
|
79
79
|
*/
|
|
80
|
-
export declare function importPKCS8(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<
|
|
80
|
+
export declare function importPKCS8<T extends KeyLike = KeyLike>(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<T>;
|
|
81
81
|
/**
|
|
82
82
|
* Imports a JWK to a runtime-specific key representation (KeyLike). Either JWK "alg" (Algorithm)
|
|
83
83
|
* Parameter must be present or the optional "alg" argument. When running on a runtime using [Web
|
|
@@ -116,4 +116,4 @@ export declare function importPKCS8(pkcs8: string, alg: string, options?: PEMImp
|
|
|
116
116
|
* @param octAsKeyObject Forces a symmetric key to be imported to a KeyObject or CryptoKey. Default
|
|
117
117
|
* is true unless JWK "ext" (Extractable) is true.
|
|
118
118
|
*/
|
|
119
|
-
export declare function importJWK(jwk: JWK, alg?: string, octAsKeyObject?: boolean): Promise<
|
|
119
|
+
export declare function importJWK<T extends KeyLike = KeyLike>(jwk: JWK, alg?: string, octAsKeyObject?: boolean): Promise<T | Uint8Array>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -601,9 +601,9 @@ export interface JWTDecryptResult {
|
|
|
601
601
|
protectedHeader: CompactJWEHeaderParameters
|
|
602
602
|
}
|
|
603
603
|
|
|
604
|
-
export interface ResolvedKey {
|
|
604
|
+
export interface ResolvedKey<T extends KeyLike = KeyLike> {
|
|
605
605
|
/** Key resolved from the key resolver function. */
|
|
606
|
-
key:
|
|
606
|
+
key: T | Uint8Array
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
/** Recognized Compact JWS Header Parameters, any other Header Members may also be present. */
|
package/package.json
CHANGED