Merge branch 'feat/filesystem_and_search' of github.com:toeverything/AFFiNE into feat/filesystem_and_search

This commit is contained in:
alt0
2022-12-20 19:11:55 +08:00
8 changed files with 113 additions and 43 deletions
@@ -36,10 +36,23 @@ function getToken(): { accessToken: string; refreshToken: string } | null {
}
}
function b64DecodeUnicode(str: string) {
// Going backwards: from byte stream, to percent-encoding, to original string.
return decodeURIComponent(
window
.atob(str)
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
})
.join('')
);
}
function parseAccessToken(token: string): AccessTokenMessage | null {
try {
const message: AccessTokenMessage = JSON.parse(
window.atob(token.split('.')[1])
b64DecodeUnicode(token.split('.')[1])
);
return message;
} catch (error) {