Skip to content

Commit

Permalink
Ensure text encoding/decoding is performed.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Oct 2, 2024
1 parent 42d48bf commit 01e5f4f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/DidJwkDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class DidJwkDriver {
let jwkJson;
let jwk;
try {
jwkJson = base64url.decode(encodedJwk);
jwkJson = new TextDecoder().decode(base64url.decode(encodedJwk));
} catch(e) {
const error = new Error(
`Could not decode base64url-encoded JWK from "${encodedJwk}".`);
Expand Down Expand Up @@ -220,7 +220,9 @@ export class DidJwkDriver {
did, jwk, verificationMethodType = 'JsonWebKey'
} = {}) {
if(did === undefined) {
did = `did:jwk:${base64url.encode(JSON.stringify(jwk))}`;
const encoded = base64url.encode(
new TextEncoder().encode(JSON.stringify(jwk)));
did = `did:jwk:${encoded}`;
} else if(typeof did !== 'string') {
throw new TypeError('"did" must be a string.');
}
Expand Down

0 comments on commit 01e5f4f

Please sign in to comment.