diff --git a/public/src/code-execution.js b/public/src/code-execution.js index 013e18c..dea2e9e 100644 --- a/public/src/code-execution.js +++ b/public/src/code-execution.js @@ -1,6 +1,6 @@ // Code execution sandbox functionality import { CODE_EXEC_URL } from "./config.js"; -import * as unsandbox from "./unsandbox.js"; +import * as un from "./un.js"; // Helper function to sleep/wait function sleep(ms) { @@ -29,8 +29,8 @@ export async function executeCode(code, language, resultsContainer, playButton) language = 'python'; } - // Check if unsandbox.com API is configured - if (unsandbox.isConfigured()) { + // Check if un.com API is configured + if (un.isConfigured()) { await executeWithUnsandbox(code, language, resultsContainer); } else { await executeWithFallback(code, language, resultsContainer); @@ -46,7 +46,7 @@ export async function executeCode(code, language, resultsContainer, playButton) } } -// Execute using unsandbox.com SDK (authenticated) +// Execute using un.com SDK (authenticated) async function executeWithUnsandbox(code, language, resultsContainer) { let pollCount = 0; let cancelButton = null; @@ -54,13 +54,13 @@ async function executeWithUnsandbox(code, language, resultsContainer) { try { // Start async execution to get job_id for cancel button - currentJobId = await unsandbox.executeAsync(language, code); + currentJobId = await un.executeAsync(language, code); // Create cancel button (shown after 3 seconds) cancelButton = createCancelButton(resultsContainer, async () => { if (currentJobId) { try { - await unsandbox.cancelJob(currentJobId); + await un.cancelJob(currentJobId); cancelButton.disabled = true; cancelButton.textContent = 'Cancelling...'; } catch (error) { @@ -70,7 +70,7 @@ async function executeWithUnsandbox(code, language, resultsContainer) { }); // Wait for job with progress callback - const result = await unsandbox.waitForJob(currentJobId, null, null, (count) => { + const result = await un.waitForJob(currentJobId, null, null, (count) => { pollCount = count; // Show cancel button after poll #5 (around 3 seconds) if (count >= 5 && cancelButton) { diff --git a/public/src/unsandbox.js b/public/src/un.js similarity index 96% rename from public/src/unsandbox.js rename to public/src/un.js index 76fd7c5..b891f1b 100644 --- a/public/src/unsandbox.js +++ b/public/src/un.js @@ -1,7 +1,9 @@ /** - * Unsandbox.com Browser SDK - * Browser-compatible wrapper for unsandbox.com API - * Based on official SDK patterns from lib/un.js + * un.js - Unsandbox.com Browser SDK + * Browser-compatible version of the official SDK (lib/un.js) + * Uses Web Crypto API for HMAC-SHA256 signing + * + * Update Node.js SDK: make update-unsandbox-sdk */ const API_BASE = "https://api.unsandbox.com";