parseSecurePlaintextToken validUntil
This commit is contained in:
@@ -153,6 +153,12 @@ export async function generateSecurePlaintextToken<T extends object>(validUntil:
|
||||
}
|
||||
|
||||
export async function parseSecurePlaintextToken<T extends object>(secureToken: SecurePlaintextToken, presharedTokenSecret?: string): Promise<T> {
|
||||
const now = new Date();
|
||||
const validUntil = new Date(secureToken.validUntil);
|
||||
if (now > validUntil) {
|
||||
throw new Error("token expired");
|
||||
}
|
||||
|
||||
if (!presharedTokenSecret) {
|
||||
if (!staticPresharedTokenSecret) {
|
||||
throw new Error("PRESHARED_TOKEN_SECRET is not set");
|
||||
|
||||
Reference in New Issue
Block a user