@luxorai/sandbox
Version:
TypeScript SDK for Luxor Sandbox: cloud sandboxes (microVMs) for AI agents on Luxor Agent Cloud
44 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.issueSandboxSSHCert = issueSandboxSSHCert;
const protobuf_1 = require("@bufbuild/protobuf");
const wkt_1 = require("@bufbuild/protobuf/wkt");
const ssh_gateway_client_pb_js_1 = require("./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.
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 = (0, protobuf_1.create)(ssh_gateway_client_pb_js_1.IssueSandboxSSHCertRequestSchema, {
sessionId: sid,
publicKey: pub,
});
if (ttlMs && ttlMs > 0) {
req.requestedTtl = (0, wkt_1.durationFromMs)(ttlMs);
}
const resp = await gatewayClient.issueSandboxSSHCert(req);
return {
sshCert: resp.sshCert,
caPub: resp.caPub,
pinHostKey: resp.pinHostKey,
certSerial: resp.certSerial,
expiresAt: resp.expiresAt ? (0, wkt_1.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