fix docs (again)

This commit is contained in:
Tiago
2025-04-22 15:28:56 +01:00
parent 283ff08744
commit 1246493cc7
4 changed files with 51 additions and 50 deletions
+7
View File
@@ -82,6 +82,13 @@ export default defineConfig({
}
`,
],
[
"script",
{
src: "https://unpkg.com/@cap.js/widget",
async: true,
}
]
],
themeConfig: {
search: {
@@ -13,13 +13,13 @@ const progressValue = ref(0);
async function runBenchmark() {
if (isRunning.value) return;
const Cap = window.Cap;
isRunning.value = true;
progressValue.value = 0;
resultMessage.value = "Running benchmark... 0%";
try {
const { default: Cap } = await import("https://unpkg.com/@cap.js/widget");
window.CAP_CUSTOM_FETCH = async (url, options) => {
if (url === "/api/challenge") {
const browserCrypto = window.crypto;
+41 -48
View File
@@ -2,57 +2,50 @@
import { onMounted } from "vue";
onMounted(() => {
import("https://unpkg.com/@cap.js/widget")
.then(({ default: Cap }) => {
window.CAP_CUSTOM_FETCH = async (url, options) => {
if (url === "/api/challenge") {
const browserCrypto = window.crypto;
return new Response(
JSON.stringify({
challenge: Array.from({ length: 18 }, () => [
Array.from(
browserCrypto.getRandomValues(
new Uint8Array(Math.ceil(32 / 2))
)
)
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
.slice(0, 32),
window.CAP_CUSTOM_FETCH = async (url, options) => {
if (url === "/api/challenge") {
const browserCrypto = window.crypto;
return new Response(
JSON.stringify({
challenge: Array.from({ length: 18 }, () => [
Array.from(
browserCrypto.getRandomValues(new Uint8Array(Math.ceil(32 / 2)))
)
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
.slice(0, 32),
Array.from(
browserCrypto.getRandomValues(
new Uint8Array(Math.ceil(4 / 2))
)
)
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
.slice(0, 4),
]),
token: "",
expires: new Date().getTime() + 6000 * 100,
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
}
);
Array.from(
browserCrypto.getRandomValues(new Uint8Array(Math.ceil(4 / 2)))
)
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
.slice(0, 4),
]),
token: "",
expires: new Date().getTime() + 6000 * 100,
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
}
if (url === "/api/redeem") {
return new Response(
JSON.stringify({
success: true,
token: "",
expires: new Date().getTime() + 1000 * 60,
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
}
);
);
}
if (url === "/api/redeem") {
return new Response(
JSON.stringify({
success: true,
token: "",
expires: new Date().getTime() + 1000 * 60,
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
}
return await window.fetch(url, options);
};
})
);
}
return await window.fetch(url, options);
};
});
</script>
+1
View File
@@ -9,6 +9,7 @@
"vue": "^3.5.13"
},
"dependencies": {
"@cap.js/widget": "^0.0.22",
"vitepress": "^1.6.3"
}
}