const hasToken = await Document.hasPrivateToken(`issuer.example`);
if (!hasToken) {
await fetch(
"https://issuer.example/.well-known/private-state-token/issuance",
{
method: "POST",
privateToken: {
version: 1,
operation: "token-request",
},
},
);
}Using the Private State Token API / notebook
Using the Private State Token API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
await fetch(
"https://issuer.example/.well-known/private-state-token/redemption",
{
method: "POST",
privateToken: {
version: 1,
operation: "token-redemption",
refreshPolicy: "none",
},
},
);const hasRR = await Document.hasRedemptionRecord(`issuer.example`);
if (hasRR) {
await fetch("some-resource.example", {
method: "POST",
privateToken: {
version: 1,
operation: "send-redemption-record",
issuers: ["https://issuer.example"],
},
});
}<iframe
src="https://example.com"
allow="private-state-token-issuance 'self';
private-state-token-redemption 'self'">
</iframe>