@saurbit/oauth2-jwt 0.1.5 → 0.1.7
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/esm/methods.d.ts +13 -2
- package/esm/methods.d.ts.map +1 -1
- package/esm/methods.js +17 -4
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/package.json +2 -2
- package/script/methods.d.ts +13 -2
- package/script/methods.d.ts.map +1 -1
- package/script/methods.js +18 -4
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -1
package/esm/methods.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JwkVerify, JwtDecode, JwtVerify } from "@saurbit/oauth2";
|
|
1
|
+
import type { JwkThumbprintCalculator, JwkVerify, JwtDecode, JwtVerify } from "@saurbit/oauth2";
|
|
2
2
|
/**
|
|
3
3
|
* Verifies a JWT using the provided secret or key and returns the decoded payload.
|
|
4
4
|
* Wraps [jose](https://github.com/panva/jose)'s `jwtVerify`.
|
|
@@ -32,8 +32,19 @@ export declare const decodeJwt: JwtDecode;
|
|
|
32
32
|
* Pass this as the `JwkVerify` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
33
33
|
*
|
|
34
34
|
* @param token - The compact serialized JWT (DPoP proof) to verify.
|
|
35
|
-
* @returns The verified JWT payload.
|
|
35
|
+
* @returns The verified JWT payload and the protected header.
|
|
36
36
|
* @throws If the token is invalid, the `jwk` header is missing, or signature verification fails.
|
|
37
37
|
*/
|
|
38
38
|
export declare const verifyJwk: JwkVerify;
|
|
39
|
+
/**
|
|
40
|
+
* Calculates the JWK thumbprint for a given JSON Web Key (JWK) using SHA-256.
|
|
41
|
+
* The thumbprint is a base64url-encoded string that uniquely identifies the JWK.
|
|
42
|
+
*
|
|
43
|
+
* @param jwk - The JSON Web Key (JWK) for which to calculate the thumbprint.
|
|
44
|
+
* @returns The JWK thumbprint as a base64url-encoded string.
|
|
45
|
+
* @throws If the JWK is invalid or cannot be processed.
|
|
46
|
+
*
|
|
47
|
+
* Pass this as the `JwkThumbprintCalculator` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const calculateJwkThumbprint: JwkThumbprintCalculator;
|
|
39
50
|
//# sourceMappingURL=methods.d.ts.map
|
package/esm/methods.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQhG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,EAAE,SAGvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,EAAE,SAEvB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,SAYvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,uBAEpC,CAAC"}
|
package/esm/methods.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeJwt as joseDecodeJwt, importJWK, jwtVerify } from "jose";
|
|
1
|
+
import { calculateJwkThumbprint as joseCalculateJwkThumbprint, decodeJwt as joseDecodeJwt, importJWK, jwtVerify, } from "jose";
|
|
2
2
|
/**
|
|
3
3
|
* Verifies a JWT using the provided secret or key and returns the decoded payload.
|
|
4
4
|
* Wraps [jose](https://github.com/panva/jose)'s `jwtVerify`.
|
|
@@ -37,16 +37,29 @@ export const decodeJwt = (jwt) => {
|
|
|
37
37
|
* Pass this as the `JwkVerify` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
38
38
|
*
|
|
39
39
|
* @param token - The compact serialized JWT (DPoP proof) to verify.
|
|
40
|
-
* @returns The verified JWT payload.
|
|
40
|
+
* @returns The verified JWT payload and the protected header.
|
|
41
41
|
* @throws If the token is invalid, the `jwk` header is missing, or signature verification fails.
|
|
42
42
|
*/
|
|
43
43
|
export const verifyJwk = async (token) => {
|
|
44
|
-
const { payload } = await jwtVerify(token, (header) => {
|
|
44
|
+
const { payload, protectedHeader } = await jwtVerify(token, (header) => {
|
|
45
45
|
if (!header.jwk)
|
|
46
46
|
throw new Error("Missing JWK");
|
|
47
47
|
return importJWK(header.jwk, header.alg);
|
|
48
48
|
}, {
|
|
49
49
|
algorithms: ["ES256"],
|
|
50
50
|
});
|
|
51
|
-
return payload;
|
|
51
|
+
return { payload, protectedHeader };
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Calculates the JWK thumbprint for a given JSON Web Key (JWK) using SHA-256.
|
|
55
|
+
* The thumbprint is a base64url-encoded string that uniquely identifies the JWK.
|
|
56
|
+
*
|
|
57
|
+
* @param jwk - The JSON Web Key (JWK) for which to calculate the thumbprint.
|
|
58
|
+
* @returns The JWK thumbprint as a base64url-encoded string.
|
|
59
|
+
* @throws If the JWK is invalid or cannot be processed.
|
|
60
|
+
*
|
|
61
|
+
* Pass this as the `JwkThumbprintCalculator` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
62
|
+
*/
|
|
63
|
+
export const calculateJwkThumbprint = (jwk) => {
|
|
64
|
+
return joseCalculateJwkThumbprint(jwk, "sha256");
|
|
52
65
|
};
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { JoseJwksAuthority } from "./jose_jwks_authority.js";
|
|
2
2
|
export { createInMemoryKeyStore, InMemoryKeyStore } from "./jwks_key_store.js";
|
|
3
3
|
export { JwksRotator, type JwksRotatorOptions } from "./jwks_rotator.js";
|
|
4
|
-
export { decodeJwt, verifyJwk, verifyJwt } from "./methods.js";
|
|
4
|
+
export { calculateJwkThumbprint, decodeJwt, verifyJwk, verifyJwt } from "./methods.js";
|
|
5
5
|
export type { JwksKeyStore, JwksRotationTimestampStore, JwtAuthority, JwtSigner, JwtVerifier, KeyGenerator, RawKey, RSA, } from "./types.js";
|
|
6
6
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvF,YAAY,EACV,YAAY,EACZ,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,GAAG,GACJ,MAAM,YAAY,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { JoseJwksAuthority } from "./jose_jwks_authority.js";
|
|
2
2
|
export { createInMemoryKeyStore, InMemoryKeyStore } from "./jwks_key_store.js";
|
|
3
3
|
export { JwksRotator } from "./jwks_rotator.js";
|
|
4
|
-
export { decodeJwt, verifyJwk, verifyJwt } from "./methods.js";
|
|
4
|
+
export { calculateJwkThumbprint, decodeJwt, verifyJwk, verifyJwt } from "./methods.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saurbit/oauth2-jwt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "JWT utilities for @saurbit/oauth2 (jose-based)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oauth2",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"jose": "^6.2.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@saurbit/oauth2": "^0.1.
|
|
30
|
+
"@saurbit/oauth2": "^0.1.8"
|
|
31
31
|
},
|
|
32
32
|
"_generatedBy": "dnt@dev"
|
|
33
33
|
}
|
package/script/methods.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JwkVerify, JwtDecode, JwtVerify } from "@saurbit/oauth2";
|
|
1
|
+
import type { JwkThumbprintCalculator, JwkVerify, JwtDecode, JwtVerify } from "@saurbit/oauth2";
|
|
2
2
|
/**
|
|
3
3
|
* Verifies a JWT using the provided secret or key and returns the decoded payload.
|
|
4
4
|
* Wraps [jose](https://github.com/panva/jose)'s `jwtVerify`.
|
|
@@ -32,8 +32,19 @@ export declare const decodeJwt: JwtDecode;
|
|
|
32
32
|
* Pass this as the `JwkVerify` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
33
33
|
*
|
|
34
34
|
* @param token - The compact serialized JWT (DPoP proof) to verify.
|
|
35
|
-
* @returns The verified JWT payload.
|
|
35
|
+
* @returns The verified JWT payload and the protected header.
|
|
36
36
|
* @throws If the token is invalid, the `jwk` header is missing, or signature verification fails.
|
|
37
37
|
*/
|
|
38
38
|
export declare const verifyJwk: JwkVerify;
|
|
39
|
+
/**
|
|
40
|
+
* Calculates the JWK thumbprint for a given JSON Web Key (JWK) using SHA-256.
|
|
41
|
+
* The thumbprint is a base64url-encoded string that uniquely identifies the JWK.
|
|
42
|
+
*
|
|
43
|
+
* @param jwk - The JSON Web Key (JWK) for which to calculate the thumbprint.
|
|
44
|
+
* @returns The JWK thumbprint as a base64url-encoded string.
|
|
45
|
+
* @throws If the JWK is invalid or cannot be processed.
|
|
46
|
+
*
|
|
47
|
+
* Pass this as the `JwkThumbprintCalculator` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const calculateJwkThumbprint: JwkThumbprintCalculator;
|
|
39
50
|
//# sourceMappingURL=methods.d.ts.map
|
package/script/methods.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQhG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,EAAE,SAGvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,EAAE,SAEvB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,SAYvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,uBAEpC,CAAC"}
|
package/script/methods.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyJwk = exports.decodeJwt = exports.verifyJwt = void 0;
|
|
3
|
+
exports.calculateJwkThumbprint = exports.verifyJwk = exports.decodeJwt = exports.verifyJwt = void 0;
|
|
4
4
|
const jose_1 = require("jose");
|
|
5
5
|
/**
|
|
6
6
|
* Verifies a JWT using the provided secret or key and returns the decoded payload.
|
|
@@ -42,17 +42,31 @@ exports.decodeJwt = decodeJwt;
|
|
|
42
42
|
* Pass this as the `JwkVerify` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
43
43
|
*
|
|
44
44
|
* @param token - The compact serialized JWT (DPoP proof) to verify.
|
|
45
|
-
* @returns The verified JWT payload.
|
|
45
|
+
* @returns The verified JWT payload and the protected header.
|
|
46
46
|
* @throws If the token is invalid, the `jwk` header is missing, or signature verification fails.
|
|
47
47
|
*/
|
|
48
48
|
const verifyJwk = async (token) => {
|
|
49
|
-
const { payload } = await (0, jose_1.jwtVerify)(token, (header) => {
|
|
49
|
+
const { payload, protectedHeader } = await (0, jose_1.jwtVerify)(token, (header) => {
|
|
50
50
|
if (!header.jwk)
|
|
51
51
|
throw new Error("Missing JWK");
|
|
52
52
|
return (0, jose_1.importJWK)(header.jwk, header.alg);
|
|
53
53
|
}, {
|
|
54
54
|
algorithms: ["ES256"],
|
|
55
55
|
});
|
|
56
|
-
return payload;
|
|
56
|
+
return { payload, protectedHeader };
|
|
57
57
|
};
|
|
58
58
|
exports.verifyJwk = verifyJwk;
|
|
59
|
+
/**
|
|
60
|
+
* Calculates the JWK thumbprint for a given JSON Web Key (JWK) using SHA-256.
|
|
61
|
+
* The thumbprint is a base64url-encoded string that uniquely identifies the JWK.
|
|
62
|
+
*
|
|
63
|
+
* @param jwk - The JSON Web Key (JWK) for which to calculate the thumbprint.
|
|
64
|
+
* @returns The JWK thumbprint as a base64url-encoded string.
|
|
65
|
+
* @throws If the JWK is invalid or cannot be processed.
|
|
66
|
+
*
|
|
67
|
+
* Pass this as the `JwkThumbprintCalculator` argument to `DPoPTokenType` from `@saurbit/oauth2`.
|
|
68
|
+
*/
|
|
69
|
+
const calculateJwkThumbprint = (jwk) => {
|
|
70
|
+
return (0, jose_1.calculateJwkThumbprint)(jwk, "sha256");
|
|
71
|
+
};
|
|
72
|
+
exports.calculateJwkThumbprint = calculateJwkThumbprint;
|
package/script/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { JoseJwksAuthority } from "./jose_jwks_authority.js";
|
|
2
2
|
export { createInMemoryKeyStore, InMemoryKeyStore } from "./jwks_key_store.js";
|
|
3
3
|
export { JwksRotator, type JwksRotatorOptions } from "./jwks_rotator.js";
|
|
4
|
-
export { decodeJwt, verifyJwk, verifyJwt } from "./methods.js";
|
|
4
|
+
export { calculateJwkThumbprint, decodeJwt, verifyJwk, verifyJwt } from "./methods.js";
|
|
5
5
|
export type { JwksKeyStore, JwksRotationTimestampStore, JwtAuthority, JwtSigner, JwtVerifier, KeyGenerator, RawKey, RSA, } from "./types.js";
|
|
6
6
|
//# sourceMappingURL=mod.d.ts.map
|
package/script/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvF,YAAY,EACV,YAAY,EACZ,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,GAAG,GACJ,MAAM,YAAY,CAAC"}
|
package/script/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyJwt = exports.verifyJwk = exports.decodeJwt = exports.JwksRotator = exports.InMemoryKeyStore = exports.createInMemoryKeyStore = exports.JoseJwksAuthority = void 0;
|
|
3
|
+
exports.verifyJwt = exports.verifyJwk = exports.decodeJwt = exports.calculateJwkThumbprint = exports.JwksRotator = exports.InMemoryKeyStore = exports.createInMemoryKeyStore = exports.JoseJwksAuthority = void 0;
|
|
4
4
|
var jose_jwks_authority_js_1 = require("./jose_jwks_authority.js");
|
|
5
5
|
Object.defineProperty(exports, "JoseJwksAuthority", { enumerable: true, get: function () { return jose_jwks_authority_js_1.JoseJwksAuthority; } });
|
|
6
6
|
var jwks_key_store_js_1 = require("./jwks_key_store.js");
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "InMemoryKeyStore", { enumerable: true, get: func
|
|
|
9
9
|
var jwks_rotator_js_1 = require("./jwks_rotator.js");
|
|
10
10
|
Object.defineProperty(exports, "JwksRotator", { enumerable: true, get: function () { return jwks_rotator_js_1.JwksRotator; } });
|
|
11
11
|
var methods_js_1 = require("./methods.js");
|
|
12
|
+
Object.defineProperty(exports, "calculateJwkThumbprint", { enumerable: true, get: function () { return methods_js_1.calculateJwkThumbprint; } });
|
|
12
13
|
Object.defineProperty(exports, "decodeJwt", { enumerable: true, get: function () { return methods_js_1.decodeJwt; } });
|
|
13
14
|
Object.defineProperty(exports, "verifyJwk", { enumerable: true, get: function () { return methods_js_1.verifyJwk; } });
|
|
14
15
|
Object.defineProperty(exports, "verifyJwt", { enumerable: true, get: function () { return methods_js_1.verifyJwt; } });
|