Skip to content

Commit

Permalink
mansar.io
Browse files Browse the repository at this point in the history
  • Loading branch information
MuneebAnsari committed Apr 15, 2024
1 parent d3be225 commit dff52ed
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions verifyemail/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,15 @@
const updatedPayload = {
...decodedPayload,
status: "abc",
state: getState(),
aud: "https://mansari-custom2.cantoll.auth0app.com",
// state: getState(),
// aud: "https://mansari-custom2.cantoll.auth0app.com",
};

const updatedPayloadString = JSON.stringify(updatedPayload);

const sharedSecret = await importKey(
"acec655005ad1288027db5d9cf1d232795b11894d8750aaa11e5b11102fa38f9"
);
const signature = await crypto.subtle.sign(
{ name: "HMAC", hash: "SHA-256" },
sharedSecret,
new TextEncoder().encode(updatedPayloadString)
);

const headerBase64url = base64urlEncode(
JSON.stringify({
Expand All @@ -161,10 +156,19 @@
);

const payloadBase64url = base64urlEncode(updatedPayloadString);
const unsignedToken = headerBase64url + "." + payloadBase64url;

const signature = await crypto.subtle.sign(
// { name: "HMAC", hash: "SHA-256" },
"HMAC",
sharedSecret,
new TextEncoder().encode(unsignedToken)
);

const signatureBase64url = base64urlEncode(
String.fromCharCode.apply(null, new Uint8Array(signature))
);
const jwt = `${headerBase64url}.${payloadBase64url}.${signatureBase64url}`;
const jwt = `${unsignedToken}.${signatureBase64url}`;
console.log("Result", jwt);
return receivedToken;
}
Expand Down

0 comments on commit dff52ed

Please sign in to comment.