@vercel/sandbox 1.8.0 → 2.0.0-beta.1
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/api-client/api-client.d.ts +319 -4
- package/dist/api-client/api-client.js +68 -1
- package/dist/api-client/api-client.js.map +1 -1
- package/dist/api-client/validators.d.ts +1271 -0
- package/dist/api-client/validators.js +37 -1
- package/dist/api-client/validators.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +277 -126
- package/dist/sandbox.js +262 -217
- package/dist/sandbox.js.map +1 -1
- package/dist/session.d.ts +369 -0
- package/dist/session.js +486 -0
- package/dist/session.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/session.js
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Session = void 0;
|
|
4
|
+
const promises_1 = require("stream/promises");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const promises_2 = require("fs/promises");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const command_1 = require("./command");
|
|
9
|
+
const snapshot_1 = require("./snapshot");
|
|
10
|
+
const consume_readable_1 = require("./utils/consume-readable");
|
|
11
|
+
const convert_sandbox_1 = require("./utils/convert-sandbox");
|
|
12
|
+
/**
|
|
13
|
+
* A Session represents a running VM instance within a named {@link Sandbox}.
|
|
14
|
+
*
|
|
15
|
+
* Obtain a session via {@link Sandbox.currentSession}.
|
|
16
|
+
*/
|
|
17
|
+
class Session {
|
|
18
|
+
/**
|
|
19
|
+
* Unique ID of this session.
|
|
20
|
+
*/
|
|
21
|
+
get sessionId() {
|
|
22
|
+
return this.session.id;
|
|
23
|
+
}
|
|
24
|
+
get interactivePort() {
|
|
25
|
+
return this.session.interactivePort ?? undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The status of this session.
|
|
29
|
+
*/
|
|
30
|
+
get status() {
|
|
31
|
+
return this.session.status;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The creation date of this session.
|
|
35
|
+
*/
|
|
36
|
+
get createdAt() {
|
|
37
|
+
return new Date(this.session.createdAt);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The timeout of this session in milliseconds.
|
|
41
|
+
*/
|
|
42
|
+
get timeout() {
|
|
43
|
+
return this.session.timeout;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The network policy of this session.
|
|
47
|
+
*/
|
|
48
|
+
get networkPolicy() {
|
|
49
|
+
return this.session.networkPolicy;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* If the session was created from a snapshot, the ID of that snapshot.
|
|
53
|
+
*/
|
|
54
|
+
get sourceSnapshotId() {
|
|
55
|
+
return this.session.sourceSnapshotId;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Memory allocated to this session in MB.
|
|
59
|
+
*/
|
|
60
|
+
get memory() {
|
|
61
|
+
return this.session.memory;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Number of vCPUs allocated to this session.
|
|
65
|
+
*/
|
|
66
|
+
get vcpus() {
|
|
67
|
+
return this.session.vcpus;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The region where this session is hosted.
|
|
71
|
+
*/
|
|
72
|
+
get region() {
|
|
73
|
+
return this.session.region;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Runtime identifier (e.g. "node24", "python3.13").
|
|
77
|
+
*/
|
|
78
|
+
get runtime() {
|
|
79
|
+
return this.session.runtime;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The working directory of this session.
|
|
83
|
+
*/
|
|
84
|
+
get cwd() {
|
|
85
|
+
return this.session.cwd;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* When this session was requested.
|
|
89
|
+
*/
|
|
90
|
+
get requestedAt() {
|
|
91
|
+
return new Date(this.session.requestedAt);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* When this session started running.
|
|
95
|
+
*/
|
|
96
|
+
get startedAt() {
|
|
97
|
+
return this.session.startedAt != null ? new Date(this.session.startedAt) : undefined;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* When this session was requested to stop.
|
|
101
|
+
*/
|
|
102
|
+
get requestedStopAt() {
|
|
103
|
+
return this.session.requestedStopAt != null ? new Date(this.session.requestedStopAt) : undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* When this session was stopped.
|
|
107
|
+
*/
|
|
108
|
+
get stoppedAt() {
|
|
109
|
+
return this.session.stoppedAt != null ? new Date(this.session.stoppedAt) : undefined;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* When this session was aborted.
|
|
113
|
+
*/
|
|
114
|
+
get abortedAt() {
|
|
115
|
+
return this.session.abortedAt != null ? new Date(this.session.abortedAt) : undefined;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The wall-clock duration of this session in milliseconds.
|
|
119
|
+
*/
|
|
120
|
+
get duration() {
|
|
121
|
+
return this.session.duration;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* When a snapshot was requested for this session.
|
|
125
|
+
*/
|
|
126
|
+
get snapshottedAt() {
|
|
127
|
+
return this.session.snapshottedAt != null ? new Date(this.session.snapshottedAt) : undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* When this session was last updated.
|
|
131
|
+
*/
|
|
132
|
+
get updatedAt() {
|
|
133
|
+
return new Date(this.session.updatedAt);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The amount of active CPU used by the session. Only reported once the VM is
|
|
137
|
+
* stopped.
|
|
138
|
+
*/
|
|
139
|
+
get activeCpuUsageMs() {
|
|
140
|
+
return this.session.activeCpuDurationMs;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The amount of network data used by the session. Only reported once the VM
|
|
144
|
+
* is stopped.
|
|
145
|
+
*/
|
|
146
|
+
get networkTransfer() {
|
|
147
|
+
return this.session.networkTransfer;
|
|
148
|
+
}
|
|
149
|
+
constructor({ client, routes, session, }) {
|
|
150
|
+
this.client = client;
|
|
151
|
+
this.routes = routes;
|
|
152
|
+
this.session = (0, convert_sandbox_1.convertSandbox)(session);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get a previously run command by its ID.
|
|
156
|
+
*
|
|
157
|
+
* @param cmdId - ID of the command to retrieve
|
|
158
|
+
* @param opts - Optional parameters.
|
|
159
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
160
|
+
* @returns A {@link Command} instance representing the command
|
|
161
|
+
*/
|
|
162
|
+
async getCommand(cmdId, opts) {
|
|
163
|
+
const command = await this.client.getCommand({
|
|
164
|
+
sandboxId: this.session.id,
|
|
165
|
+
cmdId,
|
|
166
|
+
signal: opts?.signal,
|
|
167
|
+
});
|
|
168
|
+
return new command_1.Command({
|
|
169
|
+
client: this.client,
|
|
170
|
+
sandboxId: this.session.id,
|
|
171
|
+
cmd: command.json.command,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async runCommand(commandOrParams, args, opts) {
|
|
175
|
+
return typeof commandOrParams === "string"
|
|
176
|
+
? this._runCommand({ cmd: commandOrParams, args, signal: opts?.signal })
|
|
177
|
+
: this._runCommand(commandOrParams);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Internal helper to start a command in the session.
|
|
181
|
+
*
|
|
182
|
+
* @param params - Command execution parameters.
|
|
183
|
+
* @returns A {@link Command} or {@link CommandFinished}, depending on `detached`.
|
|
184
|
+
* @internal
|
|
185
|
+
*/
|
|
186
|
+
async _runCommand(params) {
|
|
187
|
+
const wait = params.detached ? false : true;
|
|
188
|
+
const getLogs = (command) => {
|
|
189
|
+
if (params.stdout || params.stderr) {
|
|
190
|
+
(async () => {
|
|
191
|
+
try {
|
|
192
|
+
for await (const log of command.logs({ signal: params.signal })) {
|
|
193
|
+
if (log.stream === "stdout") {
|
|
194
|
+
params.stdout?.write(log.data);
|
|
195
|
+
}
|
|
196
|
+
else if (log.stream === "stderr") {
|
|
197
|
+
params.stderr?.write(log.data);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
if (params.signal?.aborted) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
if (wait) {
|
|
211
|
+
const commandStream = await this.client.runCommand({
|
|
212
|
+
sandboxId: this.session.id,
|
|
213
|
+
command: params.cmd,
|
|
214
|
+
args: params.args ?? [],
|
|
215
|
+
cwd: params.cwd,
|
|
216
|
+
env: params.env ?? {},
|
|
217
|
+
sudo: params.sudo ?? false,
|
|
218
|
+
wait: true,
|
|
219
|
+
signal: params.signal,
|
|
220
|
+
});
|
|
221
|
+
const command = new command_1.Command({
|
|
222
|
+
client: this.client,
|
|
223
|
+
sandboxId: this.session.id,
|
|
224
|
+
cmd: commandStream.command,
|
|
225
|
+
});
|
|
226
|
+
getLogs(command);
|
|
227
|
+
const finished = await commandStream.finished;
|
|
228
|
+
return new command_1.CommandFinished({
|
|
229
|
+
client: this.client,
|
|
230
|
+
sandboxId: this.session.id,
|
|
231
|
+
cmd: finished,
|
|
232
|
+
exitCode: finished.exitCode ?? 0,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const commandResponse = await this.client.runCommand({
|
|
236
|
+
sandboxId: this.session.id,
|
|
237
|
+
command: params.cmd,
|
|
238
|
+
args: params.args ?? [],
|
|
239
|
+
cwd: params.cwd,
|
|
240
|
+
env: params.env ?? {},
|
|
241
|
+
sudo: params.sudo ?? false,
|
|
242
|
+
signal: params.signal,
|
|
243
|
+
});
|
|
244
|
+
const command = new command_1.Command({
|
|
245
|
+
client: this.client,
|
|
246
|
+
sandboxId: this.session.id,
|
|
247
|
+
cmd: commandResponse.json.command,
|
|
248
|
+
});
|
|
249
|
+
getLogs(command);
|
|
250
|
+
return command;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Create a directory in the filesystem of this session.
|
|
254
|
+
*
|
|
255
|
+
* @param path - Path of the directory to create
|
|
256
|
+
* @param opts - Optional parameters.
|
|
257
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
258
|
+
*/
|
|
259
|
+
async mkDir(path, opts) {
|
|
260
|
+
await this.client.mkDir({
|
|
261
|
+
sandboxId: this.session.id,
|
|
262
|
+
path: path,
|
|
263
|
+
signal: opts?.signal,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Read a file from the filesystem of this session as a stream.
|
|
268
|
+
*
|
|
269
|
+
* @param file - File to read, with path and optional cwd
|
|
270
|
+
* @param opts - Optional parameters.
|
|
271
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
272
|
+
* @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
|
|
273
|
+
*/
|
|
274
|
+
async readFile(file, opts) {
|
|
275
|
+
return this.client.readFile({
|
|
276
|
+
sandboxId: this.session.id,
|
|
277
|
+
path: file.path,
|
|
278
|
+
cwd: file.cwd,
|
|
279
|
+
signal: opts?.signal,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Read a file from the filesystem of this session as a Buffer.
|
|
284
|
+
*
|
|
285
|
+
* @param file - File to read, with path and optional cwd
|
|
286
|
+
* @param opts - Optional parameters.
|
|
287
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
288
|
+
* @returns A promise that resolves to the file contents as a Buffer, or null if file not found
|
|
289
|
+
*/
|
|
290
|
+
async readFileToBuffer(file, opts) {
|
|
291
|
+
const stream = await this.client.readFile({
|
|
292
|
+
sandboxId: this.session.id,
|
|
293
|
+
path: file.path,
|
|
294
|
+
cwd: file.cwd,
|
|
295
|
+
signal: opts?.signal,
|
|
296
|
+
});
|
|
297
|
+
if (stream === null) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
return (0, consume_readable_1.consumeReadable)(stream);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Download a file from the session to the local filesystem.
|
|
304
|
+
*
|
|
305
|
+
* @param src - Source file on the session, with path and optional cwd
|
|
306
|
+
* @param dst - Destination file on the local machine, with path and optional cwd
|
|
307
|
+
* @param opts - Optional parameters.
|
|
308
|
+
* @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
|
|
309
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
310
|
+
* @returns The absolute path to the written file, or null if the source file was not found
|
|
311
|
+
*/
|
|
312
|
+
async downloadFile(src, dst, opts) {
|
|
313
|
+
if (!src?.path) {
|
|
314
|
+
throw new Error("downloadFile: source path is required");
|
|
315
|
+
}
|
|
316
|
+
if (!dst?.path) {
|
|
317
|
+
throw new Error("downloadFile: destination path is required");
|
|
318
|
+
}
|
|
319
|
+
const stream = await this.client.readFile({
|
|
320
|
+
sandboxId: this.session.id,
|
|
321
|
+
path: src.path,
|
|
322
|
+
cwd: src.cwd,
|
|
323
|
+
signal: opts?.signal,
|
|
324
|
+
});
|
|
325
|
+
if (stream === null) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
const dstPath = (0, path_1.resolve)(dst.cwd ?? "", dst.path);
|
|
330
|
+
if (opts?.mkdirRecursive) {
|
|
331
|
+
await (0, promises_2.mkdir)((0, path_1.dirname)(dstPath), { recursive: true });
|
|
332
|
+
}
|
|
333
|
+
await (0, promises_1.pipeline)(stream, (0, fs_1.createWriteStream)(dstPath), {
|
|
334
|
+
signal: opts?.signal,
|
|
335
|
+
});
|
|
336
|
+
return dstPath;
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
stream.destroy();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Write files to the filesystem of this session.
|
|
344
|
+
* Defaults to writing to /vercel/sandbox unless an absolute path is specified.
|
|
345
|
+
* Writes files using the `vercel-sandbox` user.
|
|
346
|
+
*
|
|
347
|
+
* @param files - Array of files with path and stream/buffer contents
|
|
348
|
+
* @param opts - Optional parameters.
|
|
349
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
350
|
+
* @returns A promise that resolves when the files are written
|
|
351
|
+
*/
|
|
352
|
+
async writeFiles(files, opts) {
|
|
353
|
+
return this.client.writeFiles({
|
|
354
|
+
sandboxId: this.session.id,
|
|
355
|
+
cwd: this.session.cwd,
|
|
356
|
+
extractDir: "/",
|
|
357
|
+
files: files,
|
|
358
|
+
signal: opts?.signal,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Get the public domain of a port of this session.
|
|
363
|
+
*
|
|
364
|
+
* @param p - Port number to resolve
|
|
365
|
+
* @returns A full domain (e.g. `https://subdomain.vercel.run`)
|
|
366
|
+
* @throws If the port has no associated route
|
|
367
|
+
*/
|
|
368
|
+
domain(p) {
|
|
369
|
+
const route = this.routes.find(({ port }) => port == p);
|
|
370
|
+
if (route) {
|
|
371
|
+
return `https://${route.subdomain}.vercel.run`;
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
throw new Error(`No route for port ${p}`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Stop this session.
|
|
379
|
+
*
|
|
380
|
+
* @param opts - Optional parameters.
|
|
381
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
382
|
+
* @param opts.blocking - If true, poll until the session has fully stopped and return the final state.
|
|
383
|
+
* @returns The session metadata at the time the stop was acknowledged, or after fully stopped if `blocking` is true.
|
|
384
|
+
*/
|
|
385
|
+
async stop(opts) {
|
|
386
|
+
const response = await this.client.stopSandbox({
|
|
387
|
+
sandboxId: this.session.id,
|
|
388
|
+
signal: opts?.signal,
|
|
389
|
+
blocking: opts?.blocking,
|
|
390
|
+
});
|
|
391
|
+
this.session = (0, convert_sandbox_1.convertSandbox)(response.json.sandbox);
|
|
392
|
+
return this.session;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Update the network policy for this session.
|
|
396
|
+
*
|
|
397
|
+
* @param networkPolicy - The new network policy to apply.
|
|
398
|
+
* @param opts - Optional parameters.
|
|
399
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
400
|
+
* @returns A promise that resolves when the network policy is updated.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* // Restrict to specific domains
|
|
404
|
+
* await session.updateNetworkPolicy({
|
|
405
|
+
* allow: ["*.npmjs.org", "github.com"],
|
|
406
|
+
* });
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* // Inject credentials with per-domain transformers
|
|
410
|
+
* await session.updateNetworkPolicy({
|
|
411
|
+
* allow: {
|
|
412
|
+
* "ai-gateway.vercel.sh": [{
|
|
413
|
+
* transform: [{
|
|
414
|
+
* headers: { authorization: "Bearer ..." }
|
|
415
|
+
* }]
|
|
416
|
+
* }],
|
|
417
|
+
* "*": []
|
|
418
|
+
* }
|
|
419
|
+
* });
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* // Deny all network access
|
|
423
|
+
* await session.updateNetworkPolicy("deny-all");
|
|
424
|
+
*/
|
|
425
|
+
async updateNetworkPolicy(networkPolicy, opts) {
|
|
426
|
+
const response = await this.client.updateNetworkPolicy({
|
|
427
|
+
sandboxId: this.session.id,
|
|
428
|
+
networkPolicy: networkPolicy,
|
|
429
|
+
signal: opts?.signal,
|
|
430
|
+
});
|
|
431
|
+
// Update the internal session metadata with the new network policy
|
|
432
|
+
this.session = (0, convert_sandbox_1.convertSandbox)(response.json.sandbox);
|
|
433
|
+
return this.session.networkPolicy;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Extend the timeout of the session by the specified duration.
|
|
437
|
+
*
|
|
438
|
+
* This allows you to extend the lifetime of a session up until the maximum
|
|
439
|
+
* execution timeout for your plan.
|
|
440
|
+
*
|
|
441
|
+
* @param duration - The duration in milliseconds to extend the timeout by
|
|
442
|
+
* @param opts - Optional parameters.
|
|
443
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
444
|
+
* @returns A promise that resolves when the timeout is extended
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* const sandbox = await Sandbox.create({ timeout: ms('10m') });
|
|
448
|
+
* const session = sandbox.currentSession();
|
|
449
|
+
* // Extends timeout by 5 minutes, to a total of 15 minutes.
|
|
450
|
+
* await session.extendTimeout(ms('5m'));
|
|
451
|
+
*/
|
|
452
|
+
async extendTimeout(duration, opts) {
|
|
453
|
+
const response = await this.client.extendTimeout({
|
|
454
|
+
sandboxId: this.session.id,
|
|
455
|
+
duration,
|
|
456
|
+
signal: opts?.signal,
|
|
457
|
+
});
|
|
458
|
+
// Update the internal session metadata with the new timeout value
|
|
459
|
+
this.session = (0, convert_sandbox_1.convertSandbox)(response.json.sandbox);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Create a snapshot from this currently running session. New sandboxes can
|
|
463
|
+
* then be created from this snapshot using {@link Sandbox.create}.
|
|
464
|
+
*
|
|
465
|
+
* Note: this session will be stopped as part of the snapshot creation process.
|
|
466
|
+
*
|
|
467
|
+
* @param opts - Optional parameters.
|
|
468
|
+
* @param opts.expiration - Optional expiration time in milliseconds. Use 0 for no expiration at all.
|
|
469
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
470
|
+
* @returns A promise that resolves to the Snapshot instance
|
|
471
|
+
*/
|
|
472
|
+
async snapshot(opts) {
|
|
473
|
+
const response = await this.client.createSnapshot({
|
|
474
|
+
sandboxId: this.session.id,
|
|
475
|
+
expiration: opts?.expiration,
|
|
476
|
+
signal: opts?.signal,
|
|
477
|
+
});
|
|
478
|
+
this.session = (0, convert_sandbox_1.convertSandbox)(response.json.sandbox);
|
|
479
|
+
return new snapshot_1.Snapshot({
|
|
480
|
+
client: this.client,
|
|
481
|
+
snapshot: response.json.snapshot,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
exports.Session = Session;
|
|
486
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":";;;AAEA,8CAA2C;AAC3C,2BAAuC;AACvC,0CAAoC;AACpC,+BAAwC;AAExC,uCAAqD;AACrD,yCAAsC;AACtC,+DAA2D;AAM3D,6DAAgF;AA4ChF;;;;GAIG;AACH,MAAa,OAAO;IAclB;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,SAAS,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACvC,CAAC;IAED;;O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AA,gCAAc,EAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAErD,OAAO,IAAI,mBAAQ,CAAC;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAxlBD,0BAwlBC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.1";
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACxB,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACxB,QAAA,OAAO,GAAG,cAAc,CAAC"}
|