forked from cory/tildefriends
Expose bip39 to script, and fix some things around base64 so that I can round trip it properly.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4729 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -45,12 +45,12 @@ function readSession(session) {
|
||||
let jwt_parts = session?.split('.');
|
||||
if (jwt_parts?.length === 3) {
|
||||
let [header, payload, signature] = jwt_parts;
|
||||
header = JSON.parse(base64Decode(unb64url(header)));
|
||||
header = JSON.parse(utf8Decode(base64Decode(unb64url(header))));
|
||||
if (header.typ === 'JWT' && header.alg === 'HS256') {
|
||||
signature = unb64url(signature);
|
||||
let id = ssb.getIdentities(':auth');
|
||||
if (id?.length && ssb.hmacsha256verify(id[0], payload, signature)) {
|
||||
let result = JSON.parse(base64Decode(unb64url(payload)));
|
||||
let result = JSON.parse(utf8Decode(base64Decode(unb64url(payload))));
|
||||
let now = new Date().valueOf()
|
||||
if (now < result.exp) {
|
||||
print(`JWT valid for another ${(result.exp - now) / 1000} seconds.`);
|
||||
|
Reference in New Issue
Block a user