Skip to content

Commit 92be27f

Browse files
committed
add deriving kid from thumbprint to ts impl as well, ignore protobuf audit issue for now
1 parent 8850145 commit 92be27f

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.cargo/audit.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ ignore = [
44
"RUSTSEC-2023-0052", # temporary ignore until fix is provided
55
"RUSTSEC-2023-0065", # temporary ignore until fix is provided
66
"RUSTSEC-2023-0071", # temporary ignore until fix is provided
7+
"RUSTSEC-2024-0437", # temporary ignore until fix is provided
78
]

bindings/wasm/identity_wasm/lib/jwk_storage.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,16 @@ async function encodeJwk(privateKey: Ed25519PrivateKey, alg: JwsAlgorithm): Prom
9999
let x = encodeB64(publicKey);
100100
let d = encodeB64(privateKey);
101101

102-
return new Jwk({
102+
const jwk = new Jwk({
103103
"kty": JwkType.Okp,
104104
"crv": "Ed25519",
105105
d,
106106
x,
107107
alg,
108108
});
109+
jwk.setKid(jwk.thumbprintSha256B64());
110+
111+
return jwk;
109112
}
110113

111114
function decodeJwk(jwk: Jwk): [Ed25519PrivateKey, Ed25519PublicKey] {

bindings/wasm/identity_wasm/src/jose/jwk.rs

+16
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ impl WasmJwk {
8888
self.0.kid().map(ToOwned::to_owned)
8989
}
9090

91+
/// Sets a value for the key ID property (kid).
92+
#[wasm_bindgen(js_name = setKid)]
93+
pub fn set_kid(&mut self, kid: String) {
94+
self.0.set_kid(kid);
95+
}
96+
9197
/// Returns the value of the X.509 URL property (x5u).
9298
#[wasm_bindgen]
9399
pub fn x5u(&self) -> Option<String> {
@@ -168,6 +174,16 @@ impl WasmJwk {
168174
}
169175
}
170176

177+
/// Creates a Thumbprint of the JSON Web Key according to [RFC7638](https://tools.ietf.org/html/rfc7638).
178+
///
179+
/// `SHA2-256` is used as the hash function *H*.
180+
///
181+
/// The thumbprint is returned as a base64url-encoded string.
182+
#[wasm_bindgen(js_name = thumbprintSha256B64)]
183+
pub fn thumbprint_sha256_b64(&self) -> String {
184+
self.0.thumbprint_sha256_b64()
185+
}
186+
171187
/// Returns a clone of the {@link Jwk} with _all_ private key components unset.
172188
/// Nothing is returned when `kty = oct` as this key type is not considered public by this library.
173189
#[wasm_bindgen(js_name = toPublic)]

0 commit comments

Comments
 (0)