@prismicio/service-token
v0.0.6
Published
Validate Prismic Context
Downloads
24
Readme
service-token
Validate Prismic Context.
Example
import { decodeContext } from "@prismicio/service-token";
const token = "user-or-wroom-or-m2m-token-string";
async function main() {
const res = await fetch(`https://auth.wroom.io/validate?token=${token}`);
const body = await res.json();
const decodedContext = decodeContext(body);
if (decodedContext.isValid) {
console.log(decodedContext.decoded);
} else {
console.error(decodedContext.error);
}
}
main();