| Current Path : /var/node/inatote/Inatote-Backend/helpers/ |
| 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;
}