UNPKG

@luxorai/sandbox

Version:

TypeScript SDK for Luxor Sandbox: cloud sandboxes (microVMs) for AI agents on Luxor Agent Cloud

41 lines • 1.83 kB
import { create } from "@bufbuild/protobuf"; import { durationFromMs, timestampDate } from "@bufbuild/protobuf/wkt"; import { IssueSandboxSSHCertRequestSchema, } from "./internal/proto/tenki/sandbox/v1/ssh_gateway_client_pb.js"; // Requests a user certificate for the caller-owned OpenSSH public key. // The service caps ttlMs to policy; omit it to use the default validity. export async function issueSandboxSSHCert(gatewayClient, sessionId, publicKey, ttlMs) { const sid = sessionId.trim(); if (!sid) throw new Error("session_id required"); const pub = publicKey.trim(); if (!pub) throw new Error("public_key required"); const req = create(IssueSandboxSSHCertRequestSchema, { sessionId: sid, publicKey: pub, }); if (ttlMs && ttlMs > 0) { req.requestedTtl = durationFromMs(ttlMs); } const resp = await gatewayClient.issueSandboxSSHCert(req); return { sshCert: resp.sshCert, caPub: resp.caPub, pinHostKey: resp.pinHostKey, certSerial: resp.certSerial, expiresAt: resp.expiresAt ? timestampDate(resp.expiresAt) : undefined, renewalAfterMs: resp.renewalAfter ? Number(resp.renewalAfter.seconds) * 1000 + Math.floor(resp.renewalAfter.nanos / 1_000_000) : undefined, permissions: resp.permissions ? { allowPty: resp.permissions.allowPty, allowAgentForwarding: resp.permissions.allowAgentForwarding, allowPortForwardingLocal: resp.permissions.allowPortForwardingLocal, allowPortForwardingRemote: resp.permissions.allowPortForwardingRemote, allowX11Forwarding: resp.permissions.allowX11Forwarding, } : undefined, }; } //# sourceMappingURL=ssh-cert.js.map