@omnirun/sdk 0.3.0 → 0.3.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/client.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { ConnectionConfig } from "./config.js";
2
2
  import type { StreamEvent } from "./models.js";
3
- /** Low-level HTTP transport for OmniRun API requests. */
4
3
  export declare class HTTPClient {
5
4
  private config;
6
5
  constructor(config: ConnectionConfig);
@@ -17,10 +16,6 @@ export declare class HTTPClient {
17
16
  }>;
18
17
  upload(path: string, filePath: string, content: Uint8Array, filename: string): Promise<any>;
19
18
  streamSSE(path: string, params?: Record<string, string>): AsyncGenerator<StreamEvent>;
20
- streamSSEPost(path: string, body?: unknown, signal?: AbortSignal): AsyncGenerator<StreamEvent>;
21
- streamSSEWithSignal(path: string, params?: Record<string, string>, signal?: AbortSignal): AsyncGenerator<StreamEvent>;
22
19
  private buildUrl;
23
20
  private handle;
24
- private parseSSE;
25
- private errorMessage;
26
21
  }
package/dist/client.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { SandboxError, StreamError } from "./errors.js";
2
- /** Low-level HTTP transport for OmniRun API requests. */
3
2
  export class HTTPClient {
4
3
  config;
5
4
  constructor(config) {
@@ -108,58 +107,8 @@ export class HTTPClient {
108
107
  Accept: "text/event-stream",
109
108
  },
110
109
  });
111
- yield* this.parseSSE(resp);
112
- }
113
- async *streamSSEPost(path, body, signal) {
114
- const resp = await fetch(this.buildUrl(path), {
115
- method: "POST",
116
- headers: {
117
- ...this.headers,
118
- Accept: "text/event-stream",
119
- },
120
- body: body != null ? JSON.stringify(body) : undefined,
121
- signal,
122
- });
123
- yield* this.parseSSE(resp);
124
- }
125
- async *streamSSEWithSignal(path, params, signal) {
126
- const url = this.buildUrl(path, params);
127
- const resp = await fetch(url, {
128
- method: "GET",
129
- headers: {
130
- ...this.headers,
131
- Accept: "text/event-stream",
132
- },
133
- signal,
134
- });
135
- yield* this.parseSSE(resp);
136
- }
137
- buildUrl(path, params) {
138
- const url = new URL(path, this.config.apiUrl);
139
- if (params) {
140
- for (const [key, val] of Object.entries(params)) {
141
- url.searchParams.set(key, val);
142
- }
143
- }
144
- return url.toString();
145
- }
146
- async handle(resp) {
147
- if (!resp.ok) {
148
- const msg = await this.errorMessage(resp);
149
- throw new SandboxError(`API error ${resp.status}: ${msg}`);
150
- }
151
- if (resp.status === 204) {
152
- return undefined;
153
- }
154
- const contentType = resp.headers.get("content-type") || "";
155
- if (contentType.includes("application/json")) {
156
- return resp.json();
157
- }
158
- return (await resp.text());
159
- }
160
- async *parseSSE(resp) {
161
110
  if (!resp.ok) {
162
- throw new StreamError(`Stream error ${resp.status}: ${await this.errorMessage(resp)}`);
111
+ throw new StreamError(`Stream error ${resp.status}: ${await resp.text()}`);
163
112
  }
164
113
  const reader = resp.body?.getReader();
165
114
  if (!reader)
@@ -190,25 +139,27 @@ export class HTTPClient {
190
139
  reader.releaseLock();
191
140
  }
192
141
  }
193
- async errorMessage(resp) {
194
- const raw = await resp.text();
195
- if (!raw)
196
- return "request failed";
197
- try {
198
- const parsed = JSON.parse(raw);
199
- if (typeof parsed === "string")
200
- return parsed;
201
- if (parsed && typeof parsed === "object") {
202
- const obj = parsed;
203
- if (typeof obj.message === "string")
204
- return obj.message;
205
- if (typeof obj.error === "string")
206
- return obj.error;
142
+ buildUrl(path, params) {
143
+ const url = new URL(path, this.config.apiUrl);
144
+ if (params) {
145
+ for (const [key, val] of Object.entries(params)) {
146
+ url.searchParams.set(key, val);
207
147
  }
208
- return raw;
209
148
  }
210
- catch {
211
- return raw;
149
+ return url.toString();
150
+ }
151
+ async handle(resp) {
152
+ if (!resp.ok) {
153
+ let msg;
154
+ try {
155
+ const body = await resp.json();
156
+ msg = body.message || body.error || JSON.stringify(body);
157
+ }
158
+ catch {
159
+ msg = await resp.text();
160
+ }
161
+ throw new SandboxError(`API error ${resp.status}: ${msg}`);
212
162
  }
163
+ return resp.json();
213
164
  }
214
165
  }
@@ -1,6 +1,5 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import type { CommandResult, ProcessInfo, StreamEvent } from "./models.js";
3
- /** Handle for a background command process. */
4
3
  export declare class CommandHandle {
5
4
  readonly pid: number;
6
5
  private sandboxId;
@@ -1,6 +1,5 @@
1
1
  import { TimeoutError } from "./errors.js";
2
2
  import { makeCommandResult } from "./utils.js";
3
- /** Handle for a background command process. */
4
3
  export class CommandHandle {
5
4
  pid;
6
5
  sandboxId;
@@ -1,7 +1,6 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import { CommandHandle } from "./command-handle.js";
3
3
  import type { CommandResult, ProcessInfo, RunCommandOptions } from "./models.js";
4
- /** Command execution namespace for a single sandbox. */
5
4
  export declare class Commands {
6
5
  private sandboxId;
7
6
  private client;
package/dist/commands.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { CommandHandle } from "./command-handle.js";
2
2
  import { CommandExitException } from "./errors.js";
3
3
  import { makeCommandResult } from "./utils.js";
4
- /** Command execution namespace for a single sandbox. */
5
4
  export class Commands {
6
5
  sandboxId;
7
6
  client;
package/dist/config.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- /** Connection options for OmniRun API calls. */
2
1
  export interface ConnectionConfig {
3
2
  apiUrl: string;
4
3
  apiKey: string;
5
4
  requestTimeout: number;
6
5
  }
7
- /** Resolves runtime config from explicit options, env vars, and defaults. */
8
6
  export declare function resolveConfig(opts?: {
9
7
  apiUrl?: string;
10
8
  apiKey?: string;
package/dist/config.js CHANGED
@@ -1,11 +1,10 @@
1
- /** Resolves runtime config from explicit options, env vars, and defaults. */
2
1
  export function resolveConfig(opts) {
3
2
  return {
4
3
  apiUrl: opts?.apiUrl ||
5
4
  (typeof process !== "undefined"
6
5
  ? process.env.OMNIRUN_API_URL
7
6
  : undefined) ||
8
- "https://api.omnirun.io",
7
+ "http://localhost:9090",
9
8
  apiKey: opts?.apiKey ||
10
9
  (typeof process !== "undefined"
11
10
  ? process.env.OMNIRUN_API_KEY
@@ -5,7 +5,6 @@ export interface ExecuteOptions {
5
5
  onStderr?: (data: string) => void;
6
6
  onResult?: (result: ResultItem) => void;
7
7
  }
8
- /** Persistent interpreter context namespace for a single sandbox. */
9
8
  export declare class Contexts {
10
9
  private sandboxId;
11
10
  private client;
package/dist/contexts.js CHANGED
@@ -1,4 +1,3 @@
1
- /** Persistent interpreter context namespace for a single sandbox. */
2
1
  export class Contexts {
3
2
  sandboxId;
4
3
  client;
@@ -60,7 +59,7 @@ export class Contexts {
60
59
  const stderrParts = [];
61
60
  const results = [];
62
61
  let executionCount = 0;
63
- for await (const event of this.client.streamSSEPost(`${this.baseUrl}/${contextId}/stream-execute`, { code })) {
62
+ for await (const event of this.client.streamSSE(`${this.baseUrl}/${contextId}/stream-execute`, { code })) {
64
63
  const e = event;
65
64
  if (e.type === "stdout") {
66
65
  stdoutParts.push(e.data ?? "");
@@ -0,0 +1,13 @@
1
+ import type { HTTPClient } from "./client.js";
2
+ import type { CreateExposureOptions, ExposureInfo, RefreshExposureOptions } from "./models.js";
3
+ export declare class Exposures {
4
+ private sandboxId;
5
+ private client;
6
+ constructor(sandboxId: string, client: HTTPClient);
7
+ private get baseUrl();
8
+ create(port: number, opts?: CreateExposureOptions): Promise<ExposureInfo>;
9
+ list(): Promise<ExposureInfo[]>;
10
+ get(exposureId: string): Promise<ExposureInfo>;
11
+ refresh(exposureId: string, opts?: RefreshExposureOptions): Promise<ExposureInfo>;
12
+ close(exposureId: string): Promise<void>;
13
+ }
@@ -0,0 +1,61 @@
1
+ function parseExposureInfo(data) {
2
+ return {
3
+ id: data.id ?? "",
4
+ sandboxId: data.sandboxId ?? data.sandboxID ?? "",
5
+ accountId: data.accountId,
6
+ port: data.port ?? 0,
7
+ hostname: data.hostname ?? "",
8
+ url: data.url ?? "",
9
+ accessUrl: data.accessUrl,
10
+ visibility: data.visibility ?? "public",
11
+ status: data.status ?? "pending",
12
+ createdAt: data.createdAt ?? "",
13
+ expiresAt: data.expiresAt ?? "",
14
+ revokedAt: data.revokedAt,
15
+ sandboxStoppedAt: data.sandboxStoppedAt,
16
+ lastAccessedAt: data.lastAccessedAt,
17
+ openPath: data.openPath ?? "/",
18
+ preserveHost: data.preserveHost ?? true,
19
+ createdBy: data.createdBy,
20
+ };
21
+ }
22
+ export class Exposures {
23
+ sandboxId;
24
+ client;
25
+ constructor(sandboxId, client) {
26
+ this.sandboxId = sandboxId;
27
+ this.client = client;
28
+ }
29
+ get baseUrl() {
30
+ return `/sandboxes/${this.sandboxId}/exposures`;
31
+ }
32
+ async create(port, opts) {
33
+ const data = await this.client.post(this.baseUrl, {
34
+ port,
35
+ visibility: opts?.visibility,
36
+ requestedTtlSeconds: opts?.ttlSeconds,
37
+ slug: opts?.slug,
38
+ openPath: opts?.openPath,
39
+ preserveHost: opts?.preserveHost,
40
+ });
41
+ return parseExposureInfo(data);
42
+ }
43
+ async list() {
44
+ const data = await this.client.get(this.baseUrl);
45
+ const items = Array.isArray(data) ? data : [];
46
+ return items.map(parseExposureInfo);
47
+ }
48
+ async get(exposureId) {
49
+ const data = await this.client.get(`${this.baseUrl}/${exposureId}`);
50
+ return parseExposureInfo(data);
51
+ }
52
+ async refresh(exposureId, opts) {
53
+ const data = await this.client.post(`${this.baseUrl}/${exposureId}/refresh`, {
54
+ requestedTtlSeconds: opts?.ttlSeconds,
55
+ });
56
+ return parseExposureInfo(data);
57
+ }
58
+ async close(exposureId) {
59
+ await this.client.delete(`${this.baseUrl}/${exposureId}`);
60
+ }
61
+ }
@@ -11,7 +11,6 @@ export interface FileListOptions {
11
11
  depth?: number;
12
12
  user?: string;
13
13
  }
14
- /** File operations namespace for a single sandbox. */
15
14
  export declare class Filesystem {
16
15
  private sandboxId;
17
16
  private client;
@@ -1,5 +1,4 @@
1
1
  import { WatchHandle } from "./watch-handle.js";
2
- /** File operations namespace for a single sandbox. */
3
2
  export class Filesystem {
4
3
  sandboxId;
5
4
  client;
package/dist/index.d.ts CHANGED
@@ -5,15 +5,14 @@ export { CommandHandle } from "./command-handle.js";
5
5
  export { Filesystem } from "./filesystem.js";
6
6
  export { Pty, PtySession } from "./pty.js";
7
7
  export { Contexts } from "./contexts.js";
8
+ export { Exposures } from "./exposures.js";
8
9
  export { Production } from "./production.js";
9
10
  export { Webhooks } from "./webhooks.js";
10
11
  export { WatchHandle } from "./watch-handle.js";
11
12
  export { HTTPClient } from "./client.js";
12
- export { generateE2EEKeyPair, importE2EEPublicKey, deriveE2EESharedKey, encryptE2EEJSON, decryptE2EEJSON, } from "./e2ee.js";
13
13
  export { resolveConfig } from "./config.js";
14
14
  export type { ConnectionConfig } from "./config.js";
15
15
  export { SandboxError, SandboxNotFoundError, CommandExitException, StreamError, TimeoutError, } from "./errors.js";
16
- export type { CommandResult, EntryInfo, SandboxInfo, FullSandboxInfo, ProcessInfo, PtyInfo, WriteEntry, FilesystemEvent, StreamEvent, RunCommandOptions, CreateSandboxOptions, ListSandboxOptions, ContextInfo, ResultItem, LogOutput, ExecutionResult, SandboxMetrics, MetricsSnapshot, NetworkPolicy, WebhookInfo, CodeResult, } from "./models.js";
17
- export type { E2EEAlgorithm, E2EEKeyPairMaterial, E2EECreateOptions, E2EESessionInfo, EncryptedEnvelope, } from "./e2ee.js";
16
+ export type { CommandResult, EntryInfo, SandboxInfo, FullSandboxInfo, ExposureInfo, ExposureStatus, ExposureVisibility, ProcessInfo, PtyInfo, WriteEntry, FilesystemEvent, StreamEvent, RunCommandOptions, CreateSandboxOptions, CreateExposureOptions, ListSandboxOptions, RefreshExposureOptions, ContextInfo, ResultItem, LogOutput, ExecutionResult, SandboxMetrics, MetricsSnapshot, NetworkPolicy, WebhookInfo, CodeResult, } from "./models.js";
18
17
  export type { FileReadOptions, FileWriteOptions, FileListOptions } from "./filesystem.js";
19
18
  export type { ExecuteOptions } from "./contexts.js";
package/dist/index.js CHANGED
@@ -5,10 +5,10 @@ export { CommandHandle } from "./command-handle.js";
5
5
  export { Filesystem } from "./filesystem.js";
6
6
  export { Pty, PtySession } from "./pty.js";
7
7
  export { Contexts } from "./contexts.js";
8
+ export { Exposures } from "./exposures.js";
8
9
  export { Production } from "./production.js";
9
10
  export { Webhooks } from "./webhooks.js";
10
11
  export { WatchHandle } from "./watch-handle.js";
11
12
  export { HTTPClient } from "./client.js";
12
- export { generateE2EEKeyPair, importE2EEPublicKey, deriveE2EESharedKey, encryptE2EEJSON, decryptE2EEJSON, } from "./e2ee.js";
13
13
  export { resolveConfig } from "./config.js";
14
14
  export { SandboxError, SandboxNotFoundError, CommandExitException, StreamError, TimeoutError, } from "./errors.js";
package/dist/models.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { E2EECreateOptions } from "./e2ee.js";
2
1
  export interface CommandResult {
3
2
  stdout: string;
4
3
  stderr: string;
@@ -17,6 +16,7 @@ export interface SandboxInfo {
17
16
  templateId: string;
18
17
  status: string;
19
18
  startedAt: string;
19
+ /** ISO timestamp when the sandbox expires. Absent for permanent sandboxes (timeout=0). */
20
20
  endAt?: string;
21
21
  name?: string;
22
22
  state?: string;
@@ -59,6 +59,37 @@ export interface FullSandboxInfo extends SandboxInfo {
59
59
  cpuCount: number;
60
60
  memoryMB: number;
61
61
  }
62
+ export type ExposureVisibility = "public" | "private";
63
+ export type ExposureStatus = "pending" | "ready" | "revoked" | "expired" | "sandbox_stopped" | "error";
64
+ export interface ExposureInfo {
65
+ id: string;
66
+ sandboxId: string;
67
+ accountId?: string;
68
+ port: number;
69
+ hostname: string;
70
+ url: string;
71
+ accessUrl?: string;
72
+ visibility: ExposureVisibility;
73
+ status: ExposureStatus;
74
+ createdAt: string;
75
+ expiresAt: string;
76
+ revokedAt?: string;
77
+ sandboxStoppedAt?: string;
78
+ lastAccessedAt?: string;
79
+ openPath?: string;
80
+ preserveHost: boolean;
81
+ createdBy?: string;
82
+ }
83
+ export interface CreateExposureOptions {
84
+ visibility?: ExposureVisibility;
85
+ ttlSeconds?: number;
86
+ slug?: string;
87
+ openPath?: string;
88
+ preserveHost?: boolean;
89
+ }
90
+ export interface RefreshExposureOptions {
91
+ ttlSeconds?: number;
92
+ }
62
93
  export interface RunCommandOptions {
63
94
  cwd?: string;
64
95
  timeout?: number;
@@ -81,8 +112,8 @@ export interface CreateSandboxOptions {
81
112
  network?: NetworkPolicy;
82
113
  secure?: boolean;
83
114
  maskRequestHost?: string;
84
- /** Client-side E2EE bootstrap options (key generation + public key announcement). */
85
- e2ee?: boolean | E2EECreateOptions;
115
+ e2ee?: boolean;
116
+ clientPublicKey?: string;
86
117
  }
87
118
  export interface ListSandboxOptions {
88
119
  apiKey?: string;
@@ -1,6 +1,5 @@
1
1
  import type { HTTPClient } from "./client.js";
2
- import type { MetricsSnapshot, NetworkPolicy, SandboxMetrics } from "./models.js";
3
- /** Production controls for pause/resume/metrics/network policy. */
2
+ import type { NetworkPolicy, SandboxMetrics } from "./models.js";
4
3
  export declare class Production {
5
4
  private sandboxId;
6
5
  private client;
@@ -16,8 +15,6 @@ export declare class Production {
16
15
  }>;
17
16
  /** Get usage metrics for the sandbox. */
18
17
  metrics(): Promise<SandboxMetrics>;
19
- /** Get raw metrics snapshots if the backend returns time-series data. */
20
- metricsSnapshots(): Promise<MetricsSnapshot[]>;
21
18
  /** Set network policy for the sandbox. */
22
19
  setNetworkPolicy(policy: NetworkPolicy): Promise<void>;
23
20
  }
@@ -1,4 +1,3 @@
1
- /** Production controls for pause/resume/metrics/network policy. */
2
1
  export class Production {
3
2
  sandboxId;
4
3
  client;
@@ -20,19 +19,6 @@ export class Production {
20
19
  /** Get usage metrics for the sandbox. */
21
20
  async metrics() {
22
21
  const data = await this.client.get(`${this.baseUrl}/metrics`);
23
- // Newer API shape: array of snapshots.
24
- if (Array.isArray(data)) {
25
- const last = data[data.length - 1] ?? {};
26
- return {
27
- cpuTimeMs: 0,
28
- memoryUsedMb: Math.round((last.mem_used ?? 0) / (1024 * 1024)),
29
- diskUsedMb: Math.round((last.disk_used ?? 0) / (1024 * 1024)),
30
- networkRxKb: 0,
31
- networkTxKb: 0,
32
- commandCount: 0,
33
- uptime: last.timestamp ?? "",
34
- };
35
- }
36
22
  return {
37
23
  cpuTimeMs: data.cpu_time_ms ?? 0,
38
24
  memoryUsedMb: data.memory_used_mb ?? 0,
@@ -40,24 +26,9 @@ export class Production {
40
26
  networkRxKb: data.network_rx_kb ?? 0,
41
27
  networkTxKb: data.network_tx_kb ?? 0,
42
28
  commandCount: data.command_count ?? 0,
43
- uptime: String(data.uptime ?? ""),
29
+ uptime: data.uptime ?? 0,
44
30
  };
45
31
  }
46
- /** Get raw metrics snapshots if the backend returns time-series data. */
47
- async metricsSnapshots() {
48
- const data = await this.client.get(`${this.baseUrl}/metrics`);
49
- if (!Array.isArray(data))
50
- return [];
51
- return data.map((m) => ({
52
- timestamp: m.timestamp ?? "",
53
- cpuUsedPct: m.cpu_used_pct ?? 0,
54
- cpuCount: m.cpu_count ?? 0,
55
- memUsed: m.mem_used ?? 0,
56
- memTotal: m.mem_total ?? 0,
57
- diskUsed: m.disk_used ?? 0,
58
- diskTotal: m.disk_total ?? 0,
59
- }));
60
- }
61
32
  /** Set network policy for the sandbox. */
62
33
  async setNetworkPolicy(policy) {
63
34
  await this.client.post(`${this.baseUrl}/network-policy`, {
package/dist/pty.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import type { PtyInfo } from "./models.js";
3
- /** PTY namespace for terminal sessions in a sandbox. */
4
3
  export declare class Pty {
5
4
  private sandboxId;
6
5
  private client;
@@ -12,7 +11,6 @@ export declare class Pty {
12
11
  }): Promise<PtySession>;
13
12
  list(): Promise<PtyInfo[]>;
14
13
  }
15
- /** Handle for a single PTY session. */
16
14
  export declare class PtySession {
17
15
  readonly pid: number;
18
16
  private sandboxId;
package/dist/pty.js CHANGED
@@ -1,4 +1,3 @@
1
- /** PTY namespace for terminal sessions in a sandbox. */
2
1
  export class Pty {
3
2
  sandboxId;
4
3
  client;
@@ -20,7 +19,6 @@ export class Pty {
20
19
  return this.client.get(this.baseUrl);
21
20
  }
22
21
  }
23
- /** Handle for a single PTY session. */
24
22
  export class PtySession {
25
23
  pid;
26
24
  sandboxId;
package/dist/sandbox.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import { Commands } from "./commands.js";
2
2
  import { Contexts } from "./contexts.js";
3
- import { type E2EESessionInfo } from "./e2ee.js";
3
+ import { Exposures } from "./exposures.js";
4
4
  import { Filesystem } from "./filesystem.js";
5
- import type { CodeResult, CreateSandboxOptions, FullSandboxInfo, ListSandboxOptions, MetricsSnapshot, NetworkPolicy, SandboxInfo } from "./models.js";
5
+ import type { CodeResult, CreateSandboxOptions, CreateExposureOptions, ExposureInfo, FullSandboxInfo, ListSandboxOptions, MetricsSnapshot, NetworkPolicy, SandboxInfo } from "./models.js";
6
6
  import { Production } from "./production.js";
7
7
  import { Pty } from "./pty.js";
8
8
  import { Webhooks } from "./webhooks.js";
9
- /** Cursor paginator for listing sandboxes via `x-next-token`. */
10
9
  export declare class SandboxPaginator {
11
10
  private client;
12
11
  private limit;
@@ -21,16 +20,15 @@ export declare class SandboxPaginator {
21
20
  get hasNext(): boolean;
22
21
  nextItems(): Promise<SandboxInfo[]>;
23
22
  }
24
- /** Top-level sandbox abstraction covering lifecycle and nested API namespaces. */
25
23
  export declare class Sandbox {
26
24
  readonly sandboxId: string;
27
25
  readonly commands: Commands;
28
26
  readonly files: Filesystem;
29
27
  readonly pty: Pty;
30
28
  readonly contexts: Contexts;
29
+ readonly exposures: Exposures;
31
30
  readonly production: Production;
32
31
  readonly webhooks: Webhooks;
33
- e2ee: E2EESessionInfo | null;
34
32
  trafficAccessToken: string;
35
33
  private client;
36
34
  private keepAliveInterval;
@@ -51,6 +49,8 @@ export declare class Sandbox {
51
49
  runCode(code: string, language?: string): Promise<CodeResult>;
52
50
  /** Get public URL for a port exposed inside the sandbox. */
53
51
  getHost(port: number): string;
52
+ /** Create a managed preview URL for a sandbox port. */
53
+ expose(port: number, opts?: CreateExposureOptions): Promise<ExposureInfo>;
54
54
  /** Get a pre-signed download URL for a file. */
55
55
  downloadUrl(path: string): Promise<string>;
56
56
  /** Get a pre-signed upload URL for a file. */
package/dist/sandbox.js CHANGED
@@ -2,25 +2,16 @@ import { HTTPClient } from "./client.js";
2
2
  import { Commands } from "./commands.js";
3
3
  import { resolveConfig } from "./config.js";
4
4
  import { Contexts } from "./contexts.js";
5
- import { generateE2EEKeyPair, } from "./e2ee.js";
5
+ import { Exposures } from "./exposures.js";
6
6
  import { Filesystem } from "./filesystem.js";
7
7
  import { Production } from "./production.js";
8
8
  import { Pty } from "./pty.js";
9
9
  import { makeCommandResult } from "./utils.js";
10
10
  import { Webhooks } from "./webhooks.js";
11
- function encodeMetadataFilter(metadata) {
12
- if (!metadata)
13
- return undefined;
14
- const entries = Object.entries(metadata);
15
- if (entries.length === 0)
16
- return undefined;
17
- const [key, value] = entries[0];
18
- return `${key}:${value}`;
19
- }
20
11
  function parseSandboxInfo(s) {
21
12
  return {
22
13
  sandboxId: s.sandboxID,
23
- templateId: s.templateID ?? s.templateId ?? "",
14
+ templateId: s.templateID ?? "",
24
15
  status: s.state ?? "running",
25
16
  startedAt: s.startedAt ?? "",
26
17
  endAt: s.endAt,
@@ -30,27 +21,6 @@ function parseSandboxInfo(s) {
30
21
  memoryMB: s.memoryMB,
31
22
  };
32
23
  }
33
- function parseFullSandboxInfo(s) {
34
- const base = parseSandboxInfo(s);
35
- return {
36
- ...base,
37
- templateId: base.templateId || s.templateID || s.templateId || "",
38
- state: s.state ?? base.state ?? "unknown",
39
- cpuCount: s.cpuCount ?? base.cpuCount ?? 0,
40
- memoryMB: s.memoryMB ?? base.memoryMB ?? 0,
41
- };
42
- }
43
- function normalizeE2EEOptions(e2ee) {
44
- if (!e2ee)
45
- return null;
46
- if (e2ee === true)
47
- return { enabled: true };
48
- if (typeof e2ee === "object" && (e2ee.enabled ?? true)) {
49
- return { enabled: true, keyPair: e2ee.keyPair, clientPublicKey: e2ee.clientPublicKey };
50
- }
51
- return null;
52
- }
53
- /** Cursor paginator for listing sandboxes via `x-next-token`. */
54
24
  export class SandboxPaginator {
55
25
  client;
56
26
  limit;
@@ -78,9 +48,11 @@ export class SandboxPaginator {
78
48
  params.next_token = this.nextToken;
79
49
  if (this.state)
80
50
  params.state = this.state;
81
- const metadataFilter = encodeMetadataFilter(this.metadata);
82
- if (metadataFilter)
83
- params.metadata = metadataFilter;
51
+ if (this.metadata) {
52
+ for (const [k, v] of Object.entries(this.metadata)) {
53
+ params[`metadata.${k}`] = v;
54
+ }
55
+ }
84
56
  const { data, headers } = await this.client.getWithHeaders("/sandboxes", params);
85
57
  const sandboxes = Array.isArray(data) ? data : [];
86
58
  const token = headers.get("x-next-token") || "";
@@ -89,16 +61,15 @@ export class SandboxPaginator {
89
61
  return sandboxes.map(parseSandboxInfo);
90
62
  }
91
63
  }
92
- /** Top-level sandbox abstraction covering lifecycle and nested API namespaces. */
93
64
  export class Sandbox {
94
65
  sandboxId;
95
66
  commands;
96
67
  files;
97
68
  pty;
98
69
  contexts;
70
+ exposures;
99
71
  production;
100
72
  webhooks;
101
- e2ee = null;
102
73
  trafficAccessToken = "";
103
74
  client;
104
75
  keepAliveInterval = null;
@@ -109,6 +80,7 @@ export class Sandbox {
109
80
  this.files = new Filesystem(sandboxId, client);
110
81
  this.pty = new Pty(sandboxId, client);
111
82
  this.contexts = new Contexts(sandboxId, client);
83
+ this.exposures = new Exposures(sandboxId, client);
112
84
  this.production = new Production(sandboxId, client);
113
85
  this.webhooks = new Webhooks(client);
114
86
  }
@@ -123,15 +95,6 @@ export class Sandbox {
123
95
  template,
124
96
  timeout: opts?.timeout ?? 300,
125
97
  };
126
- const e2eeOpts = normalizeE2EEOptions(opts?.e2ee);
127
- let e2eeKeyPair;
128
- let clientPublicKey;
129
- if (e2eeOpts?.enabled) {
130
- e2eeKeyPair = e2eeOpts.keyPair ?? (await generateE2EEKeyPair());
131
- clientPublicKey = e2eeOpts.clientPublicKey ?? e2eeKeyPair.publicKeyBase64;
132
- body.e2ee = true;
133
- body.clientPublicKey = clientPublicKey;
134
- }
135
98
  if (opts?.internet)
136
99
  body.internet = true;
137
100
  if (opts?.envVars)
@@ -146,17 +109,13 @@ export class Sandbox {
146
109
  body.secure = true;
147
110
  if (opts?.maskRequestHost)
148
111
  body.maskRequestHost = opts.maskRequestHost;
112
+ if (opts?.e2ee)
113
+ body.e2ee = true;
114
+ if (opts?.clientPublicKey)
115
+ body.clientPublicKey = opts.clientPublicKey;
149
116
  const data = await client.post("/sandboxes", body);
150
117
  const sandbox = new Sandbox(data.sandboxID, client);
151
118
  sandbox.trafficAccessToken = data.trafficToken ?? "";
152
- if (e2eeOpts?.enabled && clientPublicKey) {
153
- sandbox.e2ee = {
154
- enabled: true,
155
- clientPublicKey,
156
- clientKeyPair: e2eeKeyPair,
157
- serverPublicKey: data.serverPublicKey ?? data.e2ee?.serverPublicKey,
158
- };
159
- }
160
119
  if (opts?.keepAlive != null) {
161
120
  const interval = opts.keepAlive;
162
121
  const timeout = opts.timeout ?? 300;
@@ -187,9 +146,11 @@ export class Sandbox {
187
146
  params.next_token = opts.nextToken;
188
147
  if (opts?.state)
189
148
  params.state = opts.state;
190
- const metadataFilter = encodeMetadataFilter(opts?.metadata);
191
- if (metadataFilter)
192
- params.metadata = metadataFilter;
149
+ if (opts?.metadata) {
150
+ for (const [k, v] of Object.entries(opts.metadata)) {
151
+ params[`metadata.${k}`] = v;
152
+ }
153
+ }
193
154
  const data = await client.get("/sandboxes", Object.keys(params).length > 0 ? params : undefined);
194
155
  const sandboxes = Array.isArray(data) ? data : [];
195
156
  return sandboxes.map(parseSandboxInfo);
@@ -217,8 +178,14 @@ export class Sandbox {
217
178
  }
218
179
  }
219
180
  async getInfo() {
220
- const data = await this.client.get(`/sandboxes/${this.sandboxId}`);
221
- return parseFullSandboxInfo(data);
181
+ const raw = await this.client.get(`/sandboxes/${this.sandboxId}`);
182
+ const base = parseSandboxInfo(raw);
183
+ return {
184
+ ...base,
185
+ state: raw.state ?? "",
186
+ cpuCount: raw.cpuCount ?? 0,
187
+ memoryMB: raw.memoryMB ?? 0,
188
+ };
222
189
  }
223
190
  /** Execute code via the /code endpoint. */
224
191
  async runCode(code, language = "python") {
@@ -229,6 +196,10 @@ export class Sandbox {
229
196
  getHost(port) {
230
197
  return `https://${this.sandboxId}-${port}.claudebox.io`;
231
198
  }
199
+ /** Create a managed preview URL for a sandbox port. */
200
+ async expose(port, opts) {
201
+ return this.exposures.create(port, opts);
202
+ }
232
203
  /** Get a pre-signed download URL for a file. */
233
204
  async downloadUrl(path) {
234
205
  const data = await this.client.post(`/sandboxes/${this.sandboxId}/files/download-url`, { path });
@@ -1,6 +1,5 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import type { FilesystemEvent } from "./models.js";
3
- /** Pull-based file watch stream handle backed by server-sent events. */
4
3
  export declare class WatchHandle {
5
4
  private sandboxId;
6
5
  private path;
@@ -1,4 +1,3 @@
1
- /** Pull-based file watch stream handle backed by server-sent events. */
2
1
  export class WatchHandle {
3
2
  sandboxId;
4
3
  path;
@@ -20,7 +19,7 @@ export class WatchHandle {
20
19
  if (this.recursive)
21
20
  params.recursive = "true";
22
21
  try {
23
- for await (const event of this.client.streamSSEWithSignal(`/sandboxes/${this.sandboxId}/files/watch`, params, this.abortController.signal)) {
22
+ for await (const event of this.client.streamSSE(`/sandboxes/${this.sandboxId}/files/watch`, params)) {
24
23
  if (!this.running)
25
24
  break;
26
25
  const fsEvent = event;
@@ -1,6 +1,5 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import type { WebhookInfo } from "./models.js";
3
- /** Webhook management namespace for sandbox lifecycle events. */
4
3
  export declare class Webhooks {
5
4
  private client;
6
5
  constructor(client: HTTPClient);
package/dist/webhooks.js CHANGED
@@ -1,4 +1,3 @@
1
- /** Webhook management namespace for sandbox lifecycle events. */
2
1
  export class Webhooks {
3
2
  client;
4
3
  constructor(client) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnirun/sdk",
3
- "version": "0.3.0",
4
- "description": "TypeScript SDK for OmniRun sandboxes",
3
+ "version": "0.3.2",
4
+ "description": "TypeScript SDK for omnirun sandboxes (e2b-compatible)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -12,52 +12,19 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
- "dist",
16
- "README.md",
17
- "LICENSE",
18
- "CHANGELOG.md"
15
+ "dist"
19
16
  ],
20
17
  "scripts": {
21
- "build": "tsc -p tsconfig.json",
22
- "typecheck": "tsc --noEmit -p tsconfig.json",
18
+ "build": "tsc",
23
19
  "test": "vitest run",
24
- "test:unit": "vitest run tests/unit tests/contract",
25
- "test:integration": "RUN_OMNIRUN_INTEGRATION=1 vitest run tests/integration",
26
- "test:watch": "vitest",
27
- "pack:smoke": "npm pack --dry-run",
28
- "examples:hosted": "npm run build && node examples/hosted/run-all.mjs",
29
- "examples:hosted:preflight": "npm run build && node examples/hosted/run-all.mjs preflight",
30
- "changeset": "changeset",
31
- "version-packages": "changeset version",
32
- "release": "changeset publish"
20
+ "test:watch": "vitest"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^25.2.3",
24
+ "typescript": "^5.7.0",
25
+ "vitest": "^3.0.0"
33
26
  },
34
- "keywords": [
35
- "omnirun",
36
- "sandbox",
37
- "firecracker",
38
- "typescript",
39
- "sdk"
40
- ],
41
- "license": "MIT",
42
27
  "engines": {
43
28
  "node": ">=18"
44
- },
45
- "publishConfig": {
46
- "access": "public",
47
- "provenance": true
48
- },
49
- "repository": {
50
- "type": "git",
51
- "url": "https://github.com/a14a-org/omnirun-sdk.git"
52
- },
53
- "bugs": {
54
- "url": "https://github.com/a14a-org/omnirun-sdk/issues"
55
- },
56
- "homepage": "https://github.com/a14a-org/omnirun-sdk#readme",
57
- "devDependencies": {
58
- "@changesets/cli": "^2.29.7",
59
- "@types/node": "^24.0.0",
60
- "typescript": "^5.9.3",
61
- "vitest": "^3.2.4"
62
29
  }
63
30
  }
package/CHANGELOG.md DELETED
@@ -1,10 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- ## 0.3.0 - 2026-03-04
6
-
7
- - First standalone release of `@omnirun/sdk`.
8
- - Full sandbox SDK surface extracted from OmniRun monorepo.
9
- - API contract fixes for metadata filters and context stream execution.
10
- - Added Changesets and CI/publish workflows.
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 OmniRun
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,108 +0,0 @@
1
- # @omnirun/sdk
2
-
3
- TypeScript SDK for OmniRun sandboxes.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install @omnirun/sdk
9
- pnpm add @omnirun/sdk
10
- bun add @omnirun/sdk
11
- ```
12
-
13
- ## Configuration
14
-
15
- The SDK resolves configuration in this order:
16
-
17
- 1. Explicit options passed to SDK methods.
18
- 2. Environment variables: `OMNIRUN_API_URL`, `OMNIRUN_API_KEY`.
19
- 3. Default API URL: `https://api.omnirun.io`.
20
-
21
- ## Quickstart
22
-
23
- ```ts
24
- import { Sandbox } from "@omnirun/sdk";
25
-
26
- const sbx = await Sandbox.create("python-3.11", {
27
- apiKey: process.env.OMNIRUN_API_KEY,
28
- apiUrl: process.env.OMNIRUN_API_URL,
29
- timeout: 300,
30
- });
31
-
32
- const result = await sbx.commands.run("python3 -c \"print('hello')\"");
33
- console.log(result.stdout);
34
-
35
- await sbx.kill();
36
- ```
37
-
38
- ## Files
39
-
40
- ```ts
41
- await sbx.files.write("/tmp/input.txt", "hello");
42
- const content = await sbx.files.read("/tmp/input.txt");
43
- const bytes = await sbx.files.read("/tmp/input.txt", "bytes");
44
- ```
45
-
46
- ## Streaming
47
-
48
- ```ts
49
- const command = await sbx.commands.run("for i in 1 2 3; do echo $i; sleep 1; done", {
50
- background: true,
51
- });
52
-
53
- for await (const event of command) {
54
- if (event.type === "stdout") {
55
- process.stdout.write(event.data ?? "");
56
- }
57
- }
58
- ```
59
-
60
- ## Integration tests
61
-
62
- Integration tests are opt-in:
63
-
64
- ```bash
65
- OMNIRUN_API_URL=https://api.omnirun.io \
66
- OMNIRUN_API_KEY=<key> \
67
- RUN_OMNIRUN_INTEGRATION=1 \
68
- npm run test:integration
69
- ```
70
-
71
- ## Hosted API smoke examples
72
-
73
- ```bash
74
- OMNIRUN_API_URL=https://<your-api-host> \
75
- OMNIRUN_API_KEY=<key> \
76
- npm run examples:hosted
77
- ```
78
-
79
- Hosted example suites live in `examples/hosted/`.
80
-
81
- ## E2EE scaffold (client key bootstrap)
82
-
83
- The SDK can generate a client keypair and send `clientPublicKey` during sandbox creation:
84
-
85
- ```ts
86
- import { Sandbox } from "@omnirun/sdk";
87
-
88
- const sbx = await Sandbox.create("python-3.11", {
89
- apiUrl: process.env.OMNIRUN_API_URL,
90
- apiKey: process.env.OMNIRUN_API_KEY,
91
- e2ee: true,
92
- });
93
-
94
- console.log(sbx.e2ee?.clientPublicKey);
95
- console.log(sbx.e2ee?.serverPublicKey); // available when backend returns it
96
- ```
97
-
98
- Protocol scaffold details: `docs/E2EE-PROTOCOL-SCAFFOLD.md`.
99
-
100
- ## API Surface
101
-
102
- - `Sandbox`
103
- - `Commands` / `CommandHandle`
104
- - `Filesystem`
105
- - `Pty` / `PtySession`
106
- - `Contexts`
107
- - `Production`
108
- - `Webhooks`
package/dist/e2ee.d.ts DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * E2EE protocol helpers (SDK-side scaffold).
3
- *
4
- * Current purpose:
5
- * - generate client key material
6
- * - send client public key during sandbox create
7
- * - provide envelope encryption helpers for future encrypted endpoints
8
- */
9
- export type E2EEAlgorithm = "ECDH-P256";
10
- export interface E2EEKeyPairMaterial {
11
- algorithm: E2EEAlgorithm;
12
- publicKey: CryptoKey;
13
- privateKey: CryptoKey;
14
- /** Base64-encoded SPKI public key sent to OmniRun create endpoint. */
15
- publicKeyBase64: string;
16
- }
17
- export interface E2EECreateOptions {
18
- /** Enable E2EE bootstrap on sandbox create. */
19
- enabled?: boolean;
20
- /** Optional pre-generated keypair. If omitted, SDK generates one. */
21
- keyPair?: E2EEKeyPairMaterial;
22
- /** Optional explicit public key string if key material is managed externally. */
23
- clientPublicKey?: string;
24
- }
25
- export interface E2EESessionInfo {
26
- enabled: boolean;
27
- clientPublicKey: string;
28
- clientKeyPair?: E2EEKeyPairMaterial;
29
- /** Optional server public key returned by API for handshake completion. */
30
- serverPublicKey?: string;
31
- }
32
- export interface EncryptedEnvelope {
33
- alg: "AES-256-GCM";
34
- nonce: string;
35
- ciphertext: string;
36
- aad?: string;
37
- }
38
- export declare function generateE2EEKeyPair(): Promise<E2EEKeyPairMaterial>;
39
- export declare function importE2EEPublicKey(publicKeyBase64: string): Promise<CryptoKey>;
40
- export declare function deriveE2EESharedKey(privateKey: CryptoKey, peerPublicKeyBase64: string): Promise<CryptoKey>;
41
- export declare function encryptE2EEJSON(key: CryptoKey, payload: unknown, aad?: string): Promise<EncryptedEnvelope>;
42
- export declare function decryptE2EEJSON<T = unknown>(key: CryptoKey, envelope: EncryptedEnvelope): Promise<T>;
package/dist/e2ee.js DELETED
@@ -1,107 +0,0 @@
1
- /**
2
- * E2EE protocol helpers (SDK-side scaffold).
3
- *
4
- * Current purpose:
5
- * - generate client key material
6
- * - send client public key during sandbox create
7
- * - provide envelope encryption helpers for future encrypted endpoints
8
- */
9
- const ECDH_ALG = { name: "ECDH", namedCurve: "P-256" };
10
- const HKDF_ALG = {
11
- name: "HKDF",
12
- hash: "SHA-256",
13
- salt: new Uint8Array(),
14
- info: new TextEncoder().encode("omnirun-e2ee-v1"),
15
- };
16
- function getCrypto() {
17
- const c = globalThis.crypto;
18
- if (!c?.subtle) {
19
- throw new Error("WebCrypto is required for E2EE helpers (Node 18+ or modern browser)");
20
- }
21
- return c;
22
- }
23
- function bytesToBase64(bytes) {
24
- if (typeof Buffer !== "undefined") {
25
- return Buffer.from(bytes).toString("base64");
26
- }
27
- let binary = "";
28
- for (const b of bytes)
29
- binary += String.fromCharCode(b);
30
- return btoa(binary);
31
- }
32
- function base64ToBytes(b64) {
33
- if (typeof Buffer !== "undefined") {
34
- return new Uint8Array(Buffer.from(b64, "base64"));
35
- }
36
- const binary = atob(b64);
37
- const bytes = new Uint8Array(binary.length);
38
- for (let i = 0; i < binary.length; i++)
39
- bytes[i] = binary.charCodeAt(i);
40
- return bytes;
41
- }
42
- function toArrayBuffer(bytes) {
43
- return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
44
- }
45
- export async function generateE2EEKeyPair() {
46
- const crypto = getCrypto();
47
- const keys = await crypto.subtle.generateKey(ECDH_ALG, true, ["deriveBits"]);
48
- const publicKey = keys.publicKey;
49
- const privateKey = keys.privateKey;
50
- const spki = new Uint8Array(await crypto.subtle.exportKey("spki", publicKey));
51
- return {
52
- algorithm: "ECDH-P256",
53
- publicKey,
54
- privateKey,
55
- publicKeyBase64: bytesToBase64(spki),
56
- };
57
- }
58
- export async function importE2EEPublicKey(publicKeyBase64) {
59
- const crypto = getCrypto();
60
- const spki = base64ToBytes(publicKeyBase64);
61
- return crypto.subtle.importKey("spki", toArrayBuffer(spki), ECDH_ALG, true, []);
62
- }
63
- export async function deriveE2EESharedKey(privateKey, peerPublicKeyBase64) {
64
- const crypto = getCrypto();
65
- const peerKey = await importE2EEPublicKey(peerPublicKeyBase64);
66
- const bits = await crypto.subtle.deriveBits({ name: "ECDH", public: peerKey }, privateKey, 256);
67
- const ikm = await crypto.subtle.importKey("raw", bits, "HKDF", false, ["deriveKey"]);
68
- return crypto.subtle.deriveKey(HKDF_ALG, ikm, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
69
- }
70
- export async function encryptE2EEJSON(key, payload, aad) {
71
- const crypto = getCrypto();
72
- const iv = crypto.getRandomValues(new Uint8Array(12));
73
- const plaintext = new TextEncoder().encode(JSON.stringify(payload));
74
- const additionalData = aad ? new TextEncoder().encode(aad) : undefined;
75
- const ivBuffer = toArrayBuffer(iv);
76
- const plaintextBuffer = toArrayBuffer(plaintext);
77
- const additionalDataBuffer = additionalData ? toArrayBuffer(additionalData) : undefined;
78
- const ciphertext = await crypto.subtle.encrypt({
79
- name: "AES-GCM",
80
- iv: ivBuffer,
81
- additionalData: additionalDataBuffer,
82
- }, key, plaintextBuffer);
83
- return {
84
- alg: "AES-256-GCM",
85
- nonce: bytesToBase64(iv),
86
- ciphertext: bytesToBase64(new Uint8Array(ciphertext)),
87
- aad,
88
- };
89
- }
90
- export async function decryptE2EEJSON(key, envelope) {
91
- const crypto = getCrypto();
92
- const iv = base64ToBytes(envelope.nonce);
93
- const ciphertext = base64ToBytes(envelope.ciphertext);
94
- const additionalData = envelope.aad
95
- ? new TextEncoder().encode(envelope.aad)
96
- : undefined;
97
- const ivBuffer = toArrayBuffer(iv);
98
- const ciphertextBuffer = toArrayBuffer(ciphertext);
99
- const additionalDataBuffer = additionalData ? toArrayBuffer(additionalData) : undefined;
100
- const plaintext = await crypto.subtle.decrypt({
101
- name: "AES-GCM",
102
- iv: ivBuffer,
103
- additionalData: additionalDataBuffer,
104
- }, key, ciphertextBuffer);
105
- const decoded = new TextDecoder().decode(new Uint8Array(plaintext));
106
- return JSON.parse(decoded);
107
- }