Created
August 10, 2023 14:38
-
-
Save pbruna/c267c3cad430c058b6477d297c76ce06 to your computer and use it in GitHub Desktop.
JWT for OnlyOffice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Page Title</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script type="text/Javascript"> | |
var editorConfig = { | |
"c": "add", | |
"images": [ | |
{ | |
"fileType": "png", | |
"url": "https://example.com/url-to-example-image.png" | |
} | |
] | |
} | |
function base64RemovePadding(str) { | |
return str.replace(/={1,2}$/, ''); | |
} | |
function base64Encoder(text = "") { | |
return base64RemovePadding(window.btoa(text)); | |
} | |
function generateJWT(config = {}, key = "") | |
{ | |
var header = { | |
"alg": "HS256", | |
"typ": "JWT" | |
} | |
var payload = base64Encoder(JSON.stringify(header)) + "." + base64Encoder(JSON.stringify(config)) + "." + base64Encoder(key) | |
console.log(payload); | |
return(payload); | |
} | |
//generateJWT(editorConfig, "secret")) | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment