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> {
|
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 (!presharedTokenSecret) {
|
||||||
if (!staticPresharedTokenSecret) {
|
if (!staticPresharedTokenSecret) {
|
||||||
throw new Error("PRESHARED_TOKEN_SECRET is not set");
|
throw new Error("PRESHARED_TOKEN_SECRET is not set");
|
||||||
|
|||||||
Reference in New Issue
Block a user