idkit-core
Version:
The identity SDK. Privacy-preserving identity and proof of personhood with World ID.
31 lines (29 loc) • 759 B
JavaScript
import {
hashToField
} from "../chunk-HZ2SQA5V.js";
// src/lib/backend.ts
import { isBrowser } from "browser-or-node";
async function verifyCloudProof(proof, app_id, action, signal, endpoint) {
if (isBrowser) {
throw new Error("verifyCloudProof can only be used in the backend.");
}
const response = await fetch(endpoint ?? `https://developer.worldcoin.org/api/v2/verify/${app_id}`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
...proof,
action,
signal_hash: hashToField(signal ?? "").digest
})
});
if (response.ok) {
return { success: true };
} else {
return { success: false, ...await response.json() };
}
}
export {
verifyCloudProof
};