Your IP : 216.73.216.91


Current Path : /var/node/inatote/Inatote-Backend/helpers/
Upload File :
Current File : /var/node/inatote/Inatote-Backend/helpers/validate-page-hash.js

import { AuthorizationTokenError, ApiTokenError } from "./errors.js"
import jwt from 'jsonwebtoken'

export default function validatePageHash(pageHash) {
    var verify = undefined;

    if (!pageHash || pageHash == undefined)
        throw new AuthorizationTokenError("Unauthorize access.")

    try {
        verify = jwt.verify(pageHash, 'secret')

        if (!verify)
            throw new AuthorizationTokenError("Invalid authorization.")
    } catch (e) {
        throw new AuthorizationTokenError("Invalid authorization.")
    }
    
    return verify;
}