sandbox0 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apispec/src/apis/SandboxVolumesApi.d.ts +14 -1
- package/dist/apispec/src/apis/SandboxVolumesApi.d.ts.map +1 -1
- package/dist/apispec/src/apis/SandboxVolumesApi.js +39 -1
- package/dist/apispec/src/apis/SandboxesApi.d.ts +2 -2
- package/dist/apispec/src/apis/SandboxesApi.d.ts.map +1 -1
- package/dist/apispec/src/apis/SandboxesApi.js +2 -2
- package/dist/apispec/src/models/ContextResourceUsage.d.ts +2 -2
- package/dist/apispec/src/models/ContextResourceUsage.d.ts.map +1 -1
- package/dist/apispec/src/models/ContextResourceUsage.js +2 -2
- package/dist/apispec/src/models/ContextResponse.d.ts +2 -2
- package/dist/apispec/src/models/ContextResponse.d.ts.map +1 -1
- package/dist/apispec/src/models/ContextResponse.js +2 -2
- package/dist/apispec/src/models/ContextStatsResponse.d.ts +2 -2
- package/dist/apispec/src/models/ContextStatsResponse.d.ts.map +1 -1
- package/dist/apispec/src/models/ContextStatsResponse.js +2 -2
- package/dist/apispec/src/models/CreateREPLContextRequest.d.ts +2 -2
- package/dist/apispec/src/models/CreateREPLContextRequest.d.ts.map +1 -1
- package/dist/apispec/src/models/CreateREPLContextRequest.js +2 -2
- package/dist/apispec/src/models/ForkVolumeRequest.d.ts +58 -0
- package/dist/apispec/src/models/ForkVolumeRequest.d.ts.map +1 -0
- package/dist/apispec/src/models/ForkVolumeRequest.js +50 -0
- package/dist/apispec/src/models/RefreshResponse.d.ts +6 -0
- package/dist/apispec/src/models/RefreshResponse.d.ts.map +1 -1
- package/dist/apispec/src/models/RefreshResponse.js +4 -0
- package/dist/apispec/src/models/Sandbox.d.ts +7 -1
- package/dist/apispec/src/models/Sandbox.d.ts.map +1 -1
- package/dist/apispec/src/models/Sandbox.js +4 -0
- package/dist/apispec/src/models/SandboxRefreshRequest.d.ts +33 -0
- package/dist/apispec/src/models/SandboxRefreshRequest.d.ts.map +1 -0
- package/dist/apispec/src/models/SandboxRefreshRequest.js +41 -0
- package/dist/apispec/src/models/SandboxStatus.d.ts +6 -0
- package/dist/apispec/src/models/SandboxStatus.d.ts.map +1 -1
- package/dist/apispec/src/models/SandboxStatus.js +2 -0
- package/dist/apispec/src/models/SandboxSummary.d.ts +6 -0
- package/dist/apispec/src/models/SandboxSummary.d.ts.map +1 -1
- package/dist/apispec/src/models/SandboxSummary.js +4 -0
- package/dist/apispec/src/models/SandboxUpdateConfig.d.ts +63 -0
- package/dist/apispec/src/models/SandboxUpdateConfig.d.ts.map +1 -0
- package/dist/apispec/src/models/SandboxUpdateConfig.js +51 -0
- package/dist/apispec/src/models/SandboxUpdateRequest.d.ts +3 -3
- package/dist/apispec/src/models/SandboxUpdateRequest.d.ts.map +1 -1
- package/dist/apispec/src/models/SandboxUpdateRequest.js +3 -3
- package/dist/apispec/src/models/SandboxVolume.d.ts +6 -0
- package/dist/apispec/src/models/SandboxVolume.d.ts.map +1 -1
- package/dist/apispec/src/models/SandboxVolume.js +2 -0
- package/dist/apispec/src/models/index.d.ts +3 -0
- package/dist/apispec/src/models/index.d.ts.map +1 -1
- package/dist/apispec/src/models/index.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/resources/sandboxes.d.ts +4 -2
- package/dist/resources/sandboxes.d.ts.map +1 -1
- package/dist/resources/sandboxes.js +16 -1
- package/dist/resources/volumes.d.ts +5 -2
- package/dist/resources/volumes.d.ts.map +1 -1
- package/dist/resources/volumes.js +12 -2
- package/dist/sandbox.d.ts +6 -7
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +6 -10
- package/dist/webhook_signature.d.ts +2 -0
- package/dist/webhook_signature.d.ts.map +1 -0
- package/dist/webhook_signature.js +35 -0
- package/package.json +1 -1
package/dist/sandbox.js
CHANGED
|
@@ -236,7 +236,7 @@ export class Sandbox {
|
|
|
236
236
|
this.podName = params.podName ?? "";
|
|
237
237
|
this.status = params.status ?? "";
|
|
238
238
|
}
|
|
239
|
-
async run(
|
|
239
|
+
async run(alias, input, options) {
|
|
240
240
|
if (!input.trim()) {
|
|
241
241
|
throw new APIError({
|
|
242
242
|
statusCode: 0,
|
|
@@ -244,7 +244,7 @@ export class Sandbox {
|
|
|
244
244
|
message: "input cannot be empty",
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
|
-
const contextId = await this.ensureReplContext(
|
|
247
|
+
const contextId = await this.ensureReplContext(alias, options);
|
|
248
248
|
const execResp = await this.contextExec(contextId, normalizeReplInput(input));
|
|
249
249
|
return {
|
|
250
250
|
sandboxId: this.id,
|
|
@@ -292,23 +292,19 @@ export class Sandbox {
|
|
|
292
292
|
const socket = new WebSocketClient(wsUrl, { headers });
|
|
293
293
|
return new ContextStream(socket, this.id, contextId);
|
|
294
294
|
}
|
|
295
|
-
async ensureReplContext(
|
|
295
|
+
async ensureReplContext(alias, options) {
|
|
296
296
|
if (options?.contextId) {
|
|
297
297
|
return options.contextId;
|
|
298
298
|
}
|
|
299
|
-
const normalized =
|
|
299
|
+
const normalized = alias.trim() || "python";
|
|
300
300
|
const cached = this.replContextByLang.get(normalized);
|
|
301
301
|
if (cached) {
|
|
302
302
|
return cached;
|
|
303
303
|
}
|
|
304
|
+
// Create a default REPL context with no custom settings
|
|
304
305
|
const request = {
|
|
305
306
|
type: models.ProcessType.Repl,
|
|
306
|
-
repl: {
|
|
307
|
-
cwd: options?.cwd,
|
|
308
|
-
envVars: options?.envVars,
|
|
309
|
-
ptySize: buildPty(options?.ptyRows, options?.ptyCols),
|
|
310
|
-
idleTimeoutSec: options?.idleTimeoutSec,
|
|
311
|
-
ttlSec: options?.ttlSec,
|
|
307
|
+
repl: { alias: normalized },
|
|
312
308
|
};
|
|
313
309
|
const response = await this.createContext(request);
|
|
314
310
|
this.replContextByLang.set(normalized, response.id);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook_signature.d.ts","sourceRoot":"","sources":["../src/webhook_signature.ts"],"names":[],"mappings":"AAyBA,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,SAAS,EAAE,MAAM,GAChB,OAAO,CAiBT"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
function toPayloadBytes(payload) {
|
|
3
|
+
if (typeof payload === "string") {
|
|
4
|
+
return new TextEncoder().encode(payload);
|
|
5
|
+
}
|
|
6
|
+
return payload;
|
|
7
|
+
}
|
|
8
|
+
function decodeHexStrict(input) {
|
|
9
|
+
if (input.length === 0 || input.length % 2 !== 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const normalized = input.toLowerCase();
|
|
13
|
+
const decoded = Buffer.from(normalized, "hex");
|
|
14
|
+
// Strict check: Buffer.from(hex) is permissive for invalid input.
|
|
15
|
+
if (decoded.toString("hex") !== normalized) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return new Uint8Array(decoded);
|
|
19
|
+
}
|
|
20
|
+
// Verify X-Sandbox0-Signature with HMAC-SHA256 over raw payload bytes.
|
|
21
|
+
export function verifyWebhookSignature(secret, payload, signature) {
|
|
22
|
+
const normalizedSignature = signature.trim();
|
|
23
|
+
if (!normalizedSignature) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const provided = decodeHexStrict(normalizedSignature);
|
|
27
|
+
if (!provided) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const expected = createHmac("sha256", secret).update(toPayloadBytes(payload)).digest();
|
|
31
|
+
if (expected.length !== provided.length) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return timingSafeEqual(expected, Buffer.from(provided));
|
|
35
|
+
}
|