feat(enclave): add ping function for echoing input messages

This commit is contained in:
2026-01-07 18:57:11 -05:00
parent dca8ac95b9
commit 21f7ee4bc1
6 changed files with 96 additions and 1 deletions

View File

@@ -40,6 +40,12 @@
<button onclick="runAllTests()" style="margin-left: 1rem;">Run All Tests</button>
</div>
<div class="card">
<h2>ping(message)</h2>
<input type="text" id="ping-msg" value="hello from browser" placeholder="Message to echo">
<button onclick="testPing()">Run</button>
</div>
<div class="card">
<h2>generate(credential)</h2>
<input type="text" id="credential" value="dGVzdC1jcmVkZW50aWFs" placeholder="Base64 credential">

View File

@@ -40,6 +40,26 @@ async function init() {
}
}
window.testPing = async function() {
if (!enclave) return log(LogLevel.ERR, 'ping', 'Plugin not loaded');
const message = document.getElementById('ping-msg').value || 'hello';
log(LogLevel.INFO, 'ping', `message="${message}"`);
try {
const result = await enclave.ping(message);
if (result.success) {
log(LogLevel.OK, 'ping', `echo="${result.echo}"`, result);
} else {
log(LogLevel.ERR, 'ping', result.message, result);
}
return result;
} catch (err) {
log(LogLevel.ERR, 'ping', err?.message || String(err));
throw err;
}
};
window.testGenerate = async function() {
if (!enclave) return log(LogLevel.ERR, 'generate', 'Plugin not loaded');
@@ -137,6 +157,7 @@ window.runAllTests = async function() {
log(LogLevel.INFO, null, '=== Running all tests ===');
try {
await testPing();
await testGenerate();
await testLoad();
await testExec();