Change ND genre ids to b64 encoded strings of genre, so as to differentiate between genre name and id (#54)

This commit is contained in:
Simon J
2021-09-21 10:53:02 +10:00
committed by GitHub
parent be4fcdff24
commit d508eaebcf
8 changed files with 68 additions and 53 deletions

View File

@@ -5,6 +5,7 @@ import crypto from "crypto";
import { Encryption } from "./encryption";
import logger from "./logger";
import { Clock, SystemClock } from "./clock";
import { b64Encode, b64Decode } from "./b64";
type AccessToken = {
value: string;
@@ -60,14 +61,12 @@ export class EncryptedAccessTokens implements AccessTokens {
}
mint = (authToken: string): string =>
Buffer.from(JSON.stringify(this.encryption.encrypt(authToken))).toString(
"base64"
);
b64Encode(JSON.stringify(this.encryption.encrypt(authToken)));
authTokenFor(value: string): string | undefined {
try {
return this.encryption.decrypt(
JSON.parse(Buffer.from(value, "base64").toString("ascii"))
JSON.parse(b64Decode(value))
);
} catch {
logger.warn("Failed to decrypt access token...");