@daytonaio/sdk 0.200.1 → 0.202.0
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/cjs/CodeInterpreter.js +1 -1
- package/cjs/CodeInterpreter.js.map +1 -1
- package/cjs/Daytona.d.ts +17 -5
- package/cjs/Daytona.js +23 -16
- package/cjs/Daytona.js.map +1 -1
- package/cjs/FileSystem.d.ts +5 -1
- package/cjs/FileSystem.js +1 -1
- package/cjs/FileSystem.js.map +1 -1
- package/cjs/Image.js +14 -14
- package/cjs/Image.js.map +1 -1
- package/cjs/LspServer.js +1 -1
- package/cjs/LspServer.js.map +1 -1
- package/cjs/ObjectStorage.d.ts +2 -1
- package/cjs/ObjectStorage.js +1 -5
- package/cjs/ObjectStorage.js.map +1 -1
- package/cjs/Sandbox.d.ts +74 -10
- package/cjs/Sandbox.js +120 -31
- package/cjs/Sandbox.js.map +1 -1
- package/cjs/Snapshot.js +1 -0
- package/cjs/Snapshot.js.map +1 -1
- package/cjs/errors/DaytonaError.d.ts +152 -128
- package/cjs/errors/DaytonaError.js +276 -150
- package/cjs/errors/DaytonaError.js.map +1 -1
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +44 -6
- package/cjs/index.js.map +1 -1
- package/cjs/utils/FileTransfer.js +5 -2
- package/cjs/utils/FileTransfer.js.map +1 -1
- package/cjs/utils/fileUrlSigning.d.ts +4 -0
- package/cjs/utils/fileUrlSigning.js +47 -0
- package/cjs/utils/fileUrlSigning.js.map +1 -0
- package/esm/CodeInterpreter.js +2 -2
- package/esm/CodeInterpreter.js.map +1 -1
- package/esm/Daytona.d.ts +17 -5
- package/esm/Daytona.js +24 -17
- package/esm/Daytona.js.map +1 -1
- package/esm/FileSystem.d.ts +5 -1
- package/esm/FileSystem.js +1 -1
- package/esm/FileSystem.js.map +1 -1
- package/esm/Image.js +15 -15
- package/esm/Image.js.map +1 -1
- package/esm/LspServer.js +2 -2
- package/esm/LspServer.js.map +1 -1
- package/esm/ObjectStorage.d.ts +2 -1
- package/esm/ObjectStorage.js +1 -5
- package/esm/ObjectStorage.js.map +1 -1
- package/esm/Sandbox.d.ts +74 -10
- package/esm/Sandbox.js +121 -32
- package/esm/Sandbox.js.map +1 -1
- package/esm/Snapshot.js +1 -0
- package/esm/Snapshot.js.map +1 -1
- package/esm/errors/DaytonaError.d.ts +152 -128
- package/esm/errors/DaytonaError.js +242 -144
- package/esm/errors/DaytonaError.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +13 -1
- package/esm/index.js.map +1 -1
- package/esm/utils/FileTransfer.js +5 -2
- package/esm/utils/FileTransfer.js.map +1 -1
- package/esm/utils/Import.js +5 -3
- package/esm/utils/fileUrlSigning.d.ts +4 -0
- package/esm/utils/fileUrlSigning.js +42 -0
- package/esm/utils/fileUrlSigning.js.map +1 -0
- package/package.json +15 -13
package/cjs/LspServer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LspServer.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/LspServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAIH,
|
|
1
|
+
{"version":3,"file":"LspServer.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/LspServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAIH,wDAAmE;AACnE,2DAA4D;AAE5D;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;AAC3B,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAuBD;;;;;;;;;;GAUG;IACU,SAAS;;;;;;;;;;iBAAT,SAAS;;;iCAwBnB,IAAA,oCAAmB,GAAE;gCAkBrB,IAAA,oCAAmB,GAAE;mCAqBrB,IAAA,oCAAmB,GAAE;oCAqBrB,IAAA,oCAAmB,GAAE;2CA0BrB,IAAA,oCAAmB,GAAE;4CAiBrB,IAAA,oCAAmB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SAAS,CAAC,WAAW,CAAC;gBAChD,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,GAAG,EAAE,SAAS,GAAG,IAAI;gBACrB,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,SAAS,EAAE,QAAQ,CAAC,SAAS;iBAC9B;aACF,CAAC,CAAA;YACF,OAAO,QAAQ,CAAC,IAAI,CAAA;QACtB,CAAC;;;AAjMU,8BAAS"}
|
package/cjs/ObjectStorage.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @property {string} secretAccessKey - The secret access key for the object storage service.
|
|
8
8
|
* @property {string} [sessionToken] - The session token for the object storage service. Used for temporary credentials.
|
|
9
9
|
* @property {string} [bucketName] - The name of the bucket to use.
|
|
10
|
+
* @property {string} region - The region of the storage backend.
|
|
10
11
|
*/
|
|
11
12
|
export interface ObjectStorageConfig {
|
|
12
13
|
endpointUrl: string;
|
|
@@ -14,6 +15,7 @@ export interface ObjectStorageConfig {
|
|
|
14
15
|
secretAccessKey: string;
|
|
15
16
|
sessionToken?: string;
|
|
16
17
|
bucketName?: string;
|
|
18
|
+
region: string;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* ObjectStorage class for interacting with object storage services.
|
|
@@ -74,6 +76,5 @@ export declare class ObjectStorage {
|
|
|
74
76
|
* @param {string} archiveBasePath - The base path to use for the archive.
|
|
75
77
|
*/
|
|
76
78
|
private uploadAsTar;
|
|
77
|
-
private extractAwsRegion;
|
|
78
79
|
}
|
|
79
80
|
//# sourceMappingURL=ObjectStorage.d.ts.map
|
package/cjs/ObjectStorage.js
CHANGED
|
@@ -34,7 +34,7 @@ let ObjectStorage = (() => {
|
|
|
34
34
|
constructor(config) {
|
|
35
35
|
this.bucketName = config.bucketName || 'daytona-volume-builds';
|
|
36
36
|
this.s3Client = new client_s3_1.S3Client({
|
|
37
|
-
region:
|
|
37
|
+
region: config.region,
|
|
38
38
|
endpoint: config.endpointUrl,
|
|
39
39
|
credentials: {
|
|
40
40
|
accessKeyId: config.accessKeyId,
|
|
@@ -193,10 +193,6 @@ let ObjectStorage = (() => {
|
|
|
193
193
|
});
|
|
194
194
|
await uploader.done();
|
|
195
195
|
}
|
|
196
|
-
extractAwsRegion(endpoint) {
|
|
197
|
-
const match = endpoint.match(/s3[.-]([a-z0-9-]+)\.amazonaws\.com/);
|
|
198
|
-
return match?.[1];
|
|
199
|
-
}
|
|
200
196
|
};
|
|
201
197
|
})();
|
|
202
198
|
exports.ObjectStorage = ObjectStorage;
|
package/cjs/ObjectStorage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectStorage.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/ObjectStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kDAAmE;AACnE,sDAA6C;AAC7C,uDAAgC;AAChC,qDAA8B;AAC9B,wDAA4D;AAC5D,2CAA8C;AAC9C,2DAA4D;
|
|
1
|
+
{"version":3,"file":"ObjectStorage.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/ObjectStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kDAAmE;AACnE,sDAA6C;AAC7C,uDAAgC;AAChC,qDAA8B;AAC9B,wDAA4D;AAC5D,2CAA8C;AAC9C,2DAA4D;AAsB5D;;;;;GAKG;IACU,aAAa;;;iBAAb,aAAa;;;kCA0BvB,IAAA,oCAAmB,GAAE;YACtB,6KAAM,MAAM,6DAwBX;;;QAlDO,UAAU,GADP,2DAAa,CACE;QAClB,QAAQ,CAAU;QAE1B,YAAY,MAA2B;YACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,uBAAuB,CAAA;YAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAQ,CAAC;gBAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,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AA;YAED,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAA;YACrC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAEpB,MAAM,QAAQ,GAAG,IAAI,oBAAM,CAAC;gBAC1B,MAAM,EAAE,IAAI,CAAC,QAAQ;gBACrB,MAAM,EAAE;oBACN,MAAM,EAAE,IAAI,CAAC,UAAU;oBACvB,GAAG,EAAE,KAAK;oBACV,IAAI,EAAE,IAAI;iBACX;aACF,CAAC,CAAA;YAEF,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACvB,CAAC;;;AAtMU,sCAAa"}
|
package/cjs/Sandbox.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SandboxState, SandboxApi, SandboxBackupStateEnum, Configuration } from '@daytona/api-client';
|
|
2
2
|
import type { Sandbox as SandboxDto, SandboxListItem as SandboxListItemDto, PortPreviewUrl, SandboxVolume, BuildInfo, SshAccessDto, SshAccessValidationDto, SignedPortPreviewUrl, UpdateSandboxNetworkSettings, SandboxListSortField, SandboxListSortDirection } from '@daytona/api-client';
|
|
3
|
-
import type { Resources } from './Daytona';
|
|
3
|
+
import type { ForkSandboxParams, Resources } from './Daytona';
|
|
4
4
|
import { FileSystem } from './FileSystem';
|
|
5
5
|
import { Git } from './Git';
|
|
6
6
|
import { Process } from './Process';
|
|
@@ -110,6 +110,8 @@ export declare class Sandbox {
|
|
|
110
110
|
private readonly stateWaiters;
|
|
111
111
|
private readonly stateWaiterErrorMessageFns;
|
|
112
112
|
private subId;
|
|
113
|
+
private signingKey;
|
|
114
|
+
private signingKeyFetchedAt;
|
|
113
115
|
/**
|
|
114
116
|
* Creates a new Sandbox instance.
|
|
115
117
|
*
|
|
@@ -258,22 +260,25 @@ export declare class Sandbox {
|
|
|
258
260
|
* The forked Sandbox is a copy-on-write clone of the original. It starts
|
|
259
261
|
* with the same disk contents but operates independently from that point on.
|
|
260
262
|
*
|
|
261
|
-
* @param {
|
|
263
|
+
* @param {ForkSandboxParams} [params] - Fork parameters
|
|
262
264
|
* @param {string} [params.name] - Optional name for the forked Sandbox. If not provided, a unique name will be generated.
|
|
263
265
|
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
264
266
|
* Defaults to 60-second timeout.
|
|
265
267
|
* @returns {Promise<Sandbox>} The forked Sandbox.
|
|
266
|
-
* @throws {
|
|
268
|
+
* @throws {DaytonaInvalidArgumentError} - If timeout is a negative number
|
|
267
269
|
* @throws {DaytonaError} - If the fork operation fails or times out
|
|
268
270
|
*
|
|
269
271
|
* @example
|
|
270
272
|
* const sandbox = await daytona.get('my-sandbox');
|
|
271
|
-
* const forked = await sandbox.
|
|
273
|
+
* const forked = await sandbox.fork({ name: 'my-fork' });
|
|
272
274
|
* console.log(`Forked sandbox: ${forked.id}`);
|
|
273
275
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
fork(params?: ForkSandboxParams, timeout?: number): Promise<Sandbox>;
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated Use `fork` instead. This method will be removed in a future version.
|
|
279
|
+
* @see {@link Sandbox.fork}
|
|
280
|
+
*/
|
|
281
|
+
_experimental_fork(params?: ForkSandboxParams, timeout?: number): Promise<Sandbox>;
|
|
277
282
|
/**
|
|
278
283
|
* Creates a snapshot from the current state of the Sandbox.
|
|
279
284
|
*
|
|
@@ -285,14 +290,22 @@ export declare class Sandbox {
|
|
|
285
290
|
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
286
291
|
* Defaults to 60-second timeout.
|
|
287
292
|
* @returns {Promise<void>}
|
|
288
|
-
* @throws {
|
|
293
|
+
* @throws {DaytonaInvalidArgumentError} - If timeout is a negative number
|
|
289
294
|
* @throws {DaytonaError} - If the snapshot operation fails or times out
|
|
290
295
|
*
|
|
291
296
|
* @example
|
|
292
297
|
* const sandbox = await daytona.get('my-sandbox');
|
|
293
|
-
* await sandbox.
|
|
298
|
+
* await sandbox.createSnapshot('my-snapshot');
|
|
294
299
|
* console.log('Snapshot created successfully');
|
|
295
300
|
*/
|
|
301
|
+
createSnapshot(name: string, timeout?: number): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* @param {string} name - Name for the new snapshot
|
|
304
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
305
|
+
* Defaults to 60-second timeout.
|
|
306
|
+
* @deprecated Use `createSnapshot` instead. This method will be removed in a future version.
|
|
307
|
+
* @see {@link Sandbox.createSnapshot}
|
|
308
|
+
*/
|
|
296
309
|
_experimental_createSnapshot(name: string, timeout?: number): Promise<void>;
|
|
297
310
|
private waitForSnapshotComplete;
|
|
298
311
|
/**
|
|
@@ -305,7 +318,7 @@ export declare class Sandbox {
|
|
|
305
318
|
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
306
319
|
* Defaults to 60-second timeout.
|
|
307
320
|
* @returns {Promise<void>}
|
|
308
|
-
* @throws {
|
|
321
|
+
* @throws {DaytonaInvalidArgumentError} - If timeout is a negative number
|
|
309
322
|
* @throws {DaytonaError} - If the pause operation fails or times out
|
|
310
323
|
*
|
|
311
324
|
* @example
|
|
@@ -552,6 +565,48 @@ export declare class Sandbox {
|
|
|
552
565
|
* console.log(`Token: ${previewLink.token}`);
|
|
553
566
|
*/
|
|
554
567
|
getPreviewLink(port: number): Promise<PortPreviewUrl>;
|
|
568
|
+
/**
|
|
569
|
+
* Creates a pre-signed URL for downloading a file from the Sandbox.
|
|
570
|
+
*
|
|
571
|
+
* The URL works with any HTTP client without auth headers and stays valid across
|
|
572
|
+
* sandbox restarts (downloads succeed only while the sandbox is running). The signing
|
|
573
|
+
* key is cached locally for up to 15 seconds; if the key was rotated from another
|
|
574
|
+
* client, URLs may be rejected until the cache refreshes.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```typescript
|
|
578
|
+
* const url = await sandbox.downloadUrl('/home/user/report.pdf')
|
|
579
|
+
* // curl "$url" -o report.pdf
|
|
580
|
+
* ```
|
|
581
|
+
*
|
|
582
|
+
* @param path - Path to the file in the Sandbox.
|
|
583
|
+
* @param ttlSeconds - How long the URL stays valid, in seconds. Defaults to 3600. Zero or negative means the URL never expires.
|
|
584
|
+
* @returns Pre-signed download URL.
|
|
585
|
+
*/
|
|
586
|
+
downloadUrl(path: string, ttlSeconds?: number): Promise<string>;
|
|
587
|
+
/**
|
|
588
|
+
* Creates a pre-signed URL for uploading a file to the Sandbox.
|
|
589
|
+
*
|
|
590
|
+
* Send a POST request with the file as multipart/form-data. The URL works with any
|
|
591
|
+
* HTTP client without auth headers. The signing key is cached locally for up to
|
|
592
|
+
* 15 seconds; if the key was rotated from another client, URLs may be rejected
|
|
593
|
+
* until the cache refreshes.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```typescript
|
|
597
|
+
* const url = await sandbox.uploadUrl('/home/user/data.bin')
|
|
598
|
+
* // curl -X POST -F "file=@local.bin" "$url"
|
|
599
|
+
* ```
|
|
600
|
+
*
|
|
601
|
+
* @param path - Destination path for the uploaded file in the Sandbox.
|
|
602
|
+
* @param ttlSeconds - How long the URL stays valid, in seconds. Defaults to 3600. Zero or negative means the URL never expires.
|
|
603
|
+
* @returns Pre-signed upload URL.
|
|
604
|
+
*/
|
|
605
|
+
uploadUrl(path: string, ttlSeconds?: number): Promise<string>;
|
|
606
|
+
/**
|
|
607
|
+
* Rotates the sandbox signing key, invalidating all previously signed URLs.
|
|
608
|
+
*/
|
|
609
|
+
rotateSigningKey(): Promise<void>;
|
|
555
610
|
/**
|
|
556
611
|
* Retrieves a signed preview url for the sandbox at the specified port.
|
|
557
612
|
*
|
|
@@ -667,6 +722,7 @@ export declare class Sandbox {
|
|
|
667
722
|
private applyState;
|
|
668
723
|
private checkStateWaiter;
|
|
669
724
|
private removeStateWaiter;
|
|
725
|
+
private ensureSigningKey;
|
|
670
726
|
}
|
|
671
727
|
export interface ListSandboxesQuery {
|
|
672
728
|
/**
|
|
@@ -753,6 +809,14 @@ export interface ListSandboxesQuery {
|
|
|
753
809
|
* Include sandboxes with last activity before this timestamp
|
|
754
810
|
* */
|
|
755
811
|
lastActivityBefore?: Date;
|
|
812
|
+
/**
|
|
813
|
+
* Include sandboxes scheduled for auto destroy after this timestamp
|
|
814
|
+
* */
|
|
815
|
+
autoDestroyAtAfter?: Date;
|
|
816
|
+
/**
|
|
817
|
+
* Include sandboxes scheduled for auto destroy before this timestamp
|
|
818
|
+
* */
|
|
819
|
+
autoDestroyAtBefore?: Date;
|
|
756
820
|
}
|
|
757
821
|
/**
|
|
758
822
|
* A single point-in-time sample of historical Sandbox resource usage.
|
package/cjs/Sandbox.js
CHANGED
|
@@ -19,6 +19,7 @@ const Daytona_2 = require("./Daytona");
|
|
|
19
19
|
const ComputerUse_1 = require("./ComputerUse");
|
|
20
20
|
const CodeInterpreter_1 = require("./CodeInterpreter");
|
|
21
21
|
const otel_decorator_1 = require("./utils/otel.decorator");
|
|
22
|
+
const fileUrlSigning_1 = require("./utils/fileUrlSigning");
|
|
22
23
|
function withEvents(target, _context) {
|
|
23
24
|
return function (...args) {
|
|
24
25
|
;
|
|
@@ -89,8 +90,8 @@ let Sandbox = (() => {
|
|
|
89
90
|
let _start_decorators;
|
|
90
91
|
let _recover_decorators;
|
|
91
92
|
let _stop_decorators;
|
|
92
|
-
let
|
|
93
|
-
let
|
|
93
|
+
let _fork_decorators;
|
|
94
|
+
let _createSnapshot_decorators;
|
|
94
95
|
let _pause_decorators;
|
|
95
96
|
let _delete_decorators;
|
|
96
97
|
let _waitUntilStarted_decorators;
|
|
@@ -106,6 +107,9 @@ let Sandbox = (() => {
|
|
|
106
107
|
let _updateSecrets_decorators;
|
|
107
108
|
let _updateEnv_decorators;
|
|
108
109
|
let _getPreviewLink_decorators;
|
|
110
|
+
let _downloadUrl_decorators;
|
|
111
|
+
let _uploadUrl_decorators;
|
|
112
|
+
let _rotateSigningKey_decorators;
|
|
109
113
|
let _getSignedPreviewUrl_decorators;
|
|
110
114
|
let _expireSignedPreviewUrl_decorators;
|
|
111
115
|
let _archive_decorators;
|
|
@@ -127,8 +131,8 @@ let Sandbox = (() => {
|
|
|
127
131
|
_start_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
128
132
|
_recover_decorators = [withEvents];
|
|
129
133
|
_stop_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
_fork_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
135
|
+
_createSnapshot_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
132
136
|
_pause_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
133
137
|
_delete_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
134
138
|
_waitUntilStarted_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
@@ -144,6 +148,9 @@ let Sandbox = (() => {
|
|
|
144
148
|
_updateSecrets_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
145
149
|
_updateEnv_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
146
150
|
_getPreviewLink_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
151
|
+
_downloadUrl_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
152
|
+
_uploadUrl_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
153
|
+
_rotateSigningKey_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
147
154
|
_getSignedPreviewUrl_decorators = [withEvents];
|
|
148
155
|
_expireSignedPreviewUrl_decorators = [withEvents];
|
|
149
156
|
_archive_decorators = [(0, otel_decorator_1.WithInstrumentation)(), withEvents];
|
|
@@ -162,8 +169,8 @@ let Sandbox = (() => {
|
|
|
162
169
|
tslib_1.__esDecorate(this, null, _start_decorators, { kind: "method", name: "start", static: false, private: false, access: { has: obj => "start" in obj, get: obj => obj.start }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
163
170
|
tslib_1.__esDecorate(this, null, _recover_decorators, { kind: "method", name: "recover", static: false, private: false, access: { has: obj => "recover" in obj, get: obj => obj.recover }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
164
171
|
tslib_1.__esDecorate(this, null, _stop_decorators, { kind: "method", name: "stop", static: false, private: false, access: { has: obj => "stop" in obj, get: obj => obj.stop }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
165
|
-
tslib_1.__esDecorate(this, null,
|
|
166
|
-
tslib_1.__esDecorate(this, null,
|
|
172
|
+
tslib_1.__esDecorate(this, null, _fork_decorators, { kind: "method", name: "fork", static: false, private: false, access: { has: obj => "fork" in obj, get: obj => obj.fork }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
173
|
+
tslib_1.__esDecorate(this, null, _createSnapshot_decorators, { kind: "method", name: "createSnapshot", static: false, private: false, access: { has: obj => "createSnapshot" in obj, get: obj => obj.createSnapshot }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
167
174
|
tslib_1.__esDecorate(this, null, _pause_decorators, { kind: "method", name: "pause", static: false, private: false, access: { has: obj => "pause" in obj, get: obj => obj.pause }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
168
175
|
tslib_1.__esDecorate(this, null, _delete_decorators, { kind: "method", name: "delete", static: false, private: false, access: { has: obj => "delete" in obj, get: obj => obj.delete }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
169
176
|
tslib_1.__esDecorate(this, null, _waitUntilStarted_decorators, { kind: "method", name: "waitUntilStarted", static: false, private: false, access: { has: obj => "waitUntilStarted" in obj, get: obj => obj.waitUntilStarted }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -179,6 +186,9 @@ let Sandbox = (() => {
|
|
|
179
186
|
tslib_1.__esDecorate(this, null, _updateSecrets_decorators, { kind: "method", name: "updateSecrets", static: false, private: false, access: { has: obj => "updateSecrets" in obj, get: obj => obj.updateSecrets }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
180
187
|
tslib_1.__esDecorate(this, null, _updateEnv_decorators, { kind: "method", name: "updateEnv", static: false, private: false, access: { has: obj => "updateEnv" in obj, get: obj => obj.updateEnv }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
181
188
|
tslib_1.__esDecorate(this, null, _getPreviewLink_decorators, { kind: "method", name: "getPreviewLink", static: false, private: false, access: { has: obj => "getPreviewLink" in obj, get: obj => obj.getPreviewLink }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
189
|
+
tslib_1.__esDecorate(this, null, _downloadUrl_decorators, { kind: "method", name: "downloadUrl", static: false, private: false, access: { has: obj => "downloadUrl" in obj, get: obj => obj.downloadUrl }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
190
|
+
tslib_1.__esDecorate(this, null, _uploadUrl_decorators, { kind: "method", name: "uploadUrl", static: false, private: false, access: { has: obj => "uploadUrl" in obj, get: obj => obj.uploadUrl }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
191
|
+
tslib_1.__esDecorate(this, null, _rotateSigningKey_decorators, { kind: "method", name: "rotateSigningKey", static: false, private: false, access: { has: obj => "rotateSigningKey" in obj, get: obj => obj.rotateSigningKey }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
182
192
|
tslib_1.__esDecorate(this, null, _getSignedPreviewUrl_decorators, { kind: "method", name: "getSignedPreviewUrl", static: false, private: false, access: { has: obj => "getSignedPreviewUrl" in obj, get: obj => obj.getSignedPreviewUrl }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
183
193
|
tslib_1.__esDecorate(this, null, _expireSignedPreviewUrl_decorators, { kind: "method", name: "expireSignedPreviewUrl", static: false, private: false, access: { has: obj => "expireSignedPreviewUrl" in obj, get: obj => obj.expireSignedPreviewUrl }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
184
194
|
tslib_1.__esDecorate(this, null, _archive_decorators, { kind: "method", name: "archive", static: false, private: false, access: { has: obj => "archive" in obj, get: obj => obj.archive }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -238,6 +248,8 @@ let Sandbox = (() => {
|
|
|
238
248
|
stateWaiters = [];
|
|
239
249
|
stateWaiterErrorMessageFns = new WeakMap();
|
|
240
250
|
subId;
|
|
251
|
+
signingKey = null;
|
|
252
|
+
signingKeyFetchedAt = 0;
|
|
241
253
|
/**
|
|
242
254
|
* Creates a new Sandbox instance.
|
|
243
255
|
*
|
|
@@ -401,7 +413,7 @@ let Sandbox = (() => {
|
|
|
401
413
|
*/
|
|
402
414
|
async start(timeout = 60) {
|
|
403
415
|
if (timeout < 0) {
|
|
404
|
-
throw new DaytonaError_1.
|
|
416
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
405
417
|
}
|
|
406
418
|
const startTime = Date.now();
|
|
407
419
|
const response = await this.sandboxApi.startSandbox(this.id, undefined, { timeout: timeout * 1000 });
|
|
@@ -424,7 +436,7 @@ let Sandbox = (() => {
|
|
|
424
436
|
*/
|
|
425
437
|
async recover(timeout = 60) {
|
|
426
438
|
if (timeout < 0) {
|
|
427
|
-
throw new DaytonaError_1.
|
|
439
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
428
440
|
}
|
|
429
441
|
const startTime = Date.now();
|
|
430
442
|
const response = await this.sandboxApi.recoverSandbox(this.id, undefined, undefined, { timeout: timeout * 1000 });
|
|
@@ -449,7 +461,7 @@ let Sandbox = (() => {
|
|
|
449
461
|
*/
|
|
450
462
|
async stop(timeout = 60, force = false) {
|
|
451
463
|
if (timeout < 0) {
|
|
452
|
-
throw new DaytonaError_1.
|
|
464
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
453
465
|
}
|
|
454
466
|
const startTime = Date.now();
|
|
455
467
|
await this.sandboxApi.stopSandbox(this.id, undefined, force, { timeout: timeout * 1000 });
|
|
@@ -463,22 +475,22 @@ let Sandbox = (() => {
|
|
|
463
475
|
* The forked Sandbox is a copy-on-write clone of the original. It starts
|
|
464
476
|
* with the same disk contents but operates independently from that point on.
|
|
465
477
|
*
|
|
466
|
-
* @param {
|
|
478
|
+
* @param {ForkSandboxParams} [params] - Fork parameters
|
|
467
479
|
* @param {string} [params.name] - Optional name for the forked Sandbox. If not provided, a unique name will be generated.
|
|
468
480
|
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
469
481
|
* Defaults to 60-second timeout.
|
|
470
482
|
* @returns {Promise<Sandbox>} The forked Sandbox.
|
|
471
|
-
* @throws {
|
|
483
|
+
* @throws {DaytonaInvalidArgumentError} - If timeout is a negative number
|
|
472
484
|
* @throws {DaytonaError} - If the fork operation fails or times out
|
|
473
485
|
*
|
|
474
486
|
* @example
|
|
475
487
|
* const sandbox = await daytona.get('my-sandbox');
|
|
476
|
-
* const forked = await sandbox.
|
|
488
|
+
* const forked = await sandbox.fork({ name: 'my-fork' });
|
|
477
489
|
* console.log(`Forked sandbox: ${forked.id}`);
|
|
478
490
|
*/
|
|
479
|
-
async
|
|
491
|
+
async fork(params, timeout = 60) {
|
|
480
492
|
if (timeout < 0) {
|
|
481
|
-
throw new DaytonaError_1.
|
|
493
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
482
494
|
}
|
|
483
495
|
const startTime = Date.now();
|
|
484
496
|
const response = await this.sandboxApi.forkSandbox(this.id, { name: params?.name }, undefined, {
|
|
@@ -497,6 +509,13 @@ let Sandbox = (() => {
|
|
|
497
509
|
await forkedSandbox.waitUntilStarted(remainingTimeout);
|
|
498
510
|
return forkedSandbox;
|
|
499
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* @deprecated Use `fork` instead. This method will be removed in a future version.
|
|
514
|
+
* @see {@link Sandbox.fork}
|
|
515
|
+
*/
|
|
516
|
+
async _experimental_fork(params, timeout = 60) {
|
|
517
|
+
return this.fork(params, timeout);
|
|
518
|
+
}
|
|
500
519
|
/**
|
|
501
520
|
* Creates a snapshot from the current state of the Sandbox.
|
|
502
521
|
*
|
|
@@ -508,17 +527,17 @@ let Sandbox = (() => {
|
|
|
508
527
|
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
509
528
|
* Defaults to 60-second timeout.
|
|
510
529
|
* @returns {Promise<void>}
|
|
511
|
-
* @throws {
|
|
530
|
+
* @throws {DaytonaInvalidArgumentError} - If timeout is a negative number
|
|
512
531
|
* @throws {DaytonaError} - If the snapshot operation fails or times out
|
|
513
532
|
*
|
|
514
533
|
* @example
|
|
515
534
|
* const sandbox = await daytona.get('my-sandbox');
|
|
516
|
-
* await sandbox.
|
|
535
|
+
* await sandbox.createSnapshot('my-snapshot');
|
|
517
536
|
* console.log('Snapshot created successfully');
|
|
518
537
|
*/
|
|
519
|
-
async
|
|
538
|
+
async createSnapshot(name, timeout = 60) {
|
|
520
539
|
if (timeout < 0) {
|
|
521
|
-
throw new DaytonaError_1.
|
|
540
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
522
541
|
}
|
|
523
542
|
const startTime = Date.now();
|
|
524
543
|
const req = { name };
|
|
@@ -530,6 +549,16 @@ let Sandbox = (() => {
|
|
|
530
549
|
const remainingTimeout = timeout ? Math.max(0.001, timeout - timeElapsed / 1000) : timeout;
|
|
531
550
|
await this.waitForSnapshotComplete(remainingTimeout);
|
|
532
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* @param {string} name - Name for the new snapshot
|
|
554
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
555
|
+
* Defaults to 60-second timeout.
|
|
556
|
+
* @deprecated Use `createSnapshot` instead. This method will be removed in a future version.
|
|
557
|
+
* @see {@link Sandbox.createSnapshot}
|
|
558
|
+
*/
|
|
559
|
+
async _experimental_createSnapshot(name, timeout = 60) {
|
|
560
|
+
return this.createSnapshot(name, timeout);
|
|
561
|
+
}
|
|
533
562
|
async waitForSnapshotComplete(timeout) {
|
|
534
563
|
const errorStates = [api_client_1.SandboxState.ERROR, api_client_1.SandboxState.BUILD_FAILED];
|
|
535
564
|
const excludeStates = new Set([api_client_1.SandboxState.SNAPSHOTTING, ...errorStates]);
|
|
@@ -546,7 +575,7 @@ let Sandbox = (() => {
|
|
|
546
575
|
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
547
576
|
* Defaults to 60-second timeout.
|
|
548
577
|
* @returns {Promise<void>}
|
|
549
|
-
* @throws {
|
|
578
|
+
* @throws {DaytonaInvalidArgumentError} - If timeout is a negative number
|
|
550
579
|
* @throws {DaytonaError} - If the pause operation fails or times out
|
|
551
580
|
*
|
|
552
581
|
* @example
|
|
@@ -556,7 +585,7 @@ let Sandbox = (() => {
|
|
|
556
585
|
*/
|
|
557
586
|
async pause(timeout = 60) {
|
|
558
587
|
if (timeout < 0) {
|
|
559
|
-
throw new DaytonaError_1.
|
|
588
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
560
589
|
}
|
|
561
590
|
const startTime = Date.now();
|
|
562
591
|
await this.sandboxApi.pauseSandbox(this.id, undefined, {
|
|
@@ -587,7 +616,7 @@ let Sandbox = (() => {
|
|
|
587
616
|
*/
|
|
588
617
|
async delete(timeout = 60, wait = false) {
|
|
589
618
|
if (timeout < 0) {
|
|
590
|
-
throw new DaytonaError_1.
|
|
619
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
591
620
|
}
|
|
592
621
|
const startTime = Date.now();
|
|
593
622
|
const response = await this.sandboxApi.deleteSandbox(this.id, undefined, { timeout: timeout * 1000 });
|
|
@@ -620,7 +649,7 @@ let Sandbox = (() => {
|
|
|
620
649
|
*/
|
|
621
650
|
async waitUntilStarted(timeout = 60) {
|
|
622
651
|
if (timeout < 0) {
|
|
623
|
-
throw new DaytonaError_1.
|
|
652
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
624
653
|
}
|
|
625
654
|
if (this.state === api_client_1.SandboxState.STARTED) {
|
|
626
655
|
return;
|
|
@@ -640,7 +669,7 @@ let Sandbox = (() => {
|
|
|
640
669
|
*/
|
|
641
670
|
async waitUntilStopped(timeout = 60) {
|
|
642
671
|
if (timeout < 0) {
|
|
643
|
-
throw new DaytonaError_1.
|
|
672
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
644
673
|
}
|
|
645
674
|
// Treat destroyed as stopped to cover ephemeral sandboxes that are automatically deleted after stopping
|
|
646
675
|
if (this.state === api_client_1.SandboxState.STOPPED || this.state === api_client_1.SandboxState.DESTROYED) {
|
|
@@ -698,7 +727,7 @@ let Sandbox = (() => {
|
|
|
698
727
|
*/
|
|
699
728
|
async setAutostopInterval(interval) {
|
|
700
729
|
if (!Number.isInteger(interval) || interval < 0) {
|
|
701
|
-
throw new DaytonaError_1.
|
|
730
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('autoStopInterval must be a non-negative integer');
|
|
702
731
|
}
|
|
703
732
|
await this.sandboxApi.setAutostopInterval(this.id, interval);
|
|
704
733
|
this.autoStopInterval = interval;
|
|
@@ -728,7 +757,7 @@ let Sandbox = (() => {
|
|
|
728
757
|
*/
|
|
729
758
|
async setAutoPauseInterval(interval) {
|
|
730
759
|
if (!Number.isInteger(interval) || interval < 0) {
|
|
731
|
-
throw new DaytonaError_1.
|
|
760
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('autoPauseInterval must be a non-negative integer');
|
|
732
761
|
}
|
|
733
762
|
await this.sandboxApi.setAutoPauseInterval(this.id, interval);
|
|
734
763
|
this.autoPauseInterval = interval;
|
|
@@ -753,7 +782,7 @@ let Sandbox = (() => {
|
|
|
753
782
|
*/
|
|
754
783
|
async setTtl(ttlMinutes) {
|
|
755
784
|
if (!Number.isInteger(ttlMinutes) || ttlMinutes < 0) {
|
|
756
|
-
throw new DaytonaError_1.
|
|
785
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('ttlMinutes must be a non-negative integer');
|
|
757
786
|
}
|
|
758
787
|
await this.sandboxApi.setTtl(this.id, ttlMinutes);
|
|
759
788
|
}
|
|
@@ -775,7 +804,7 @@ let Sandbox = (() => {
|
|
|
775
804
|
*/
|
|
776
805
|
async setAutoArchiveInterval(interval) {
|
|
777
806
|
if (!Number.isInteger(interval) || interval < 0) {
|
|
778
|
-
throw new DaytonaError_1.
|
|
807
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('autoArchiveInterval must be a non-negative integer');
|
|
779
808
|
}
|
|
780
809
|
await this.sandboxApi.setAutoArchiveInterval(this.id, interval);
|
|
781
810
|
this.autoArchiveInterval = interval;
|
|
@@ -825,7 +854,7 @@ let Sandbox = (() => {
|
|
|
825
854
|
if (settings.networkBlockAll === undefined &&
|
|
826
855
|
settings.networkAllowList === undefined &&
|
|
827
856
|
settings.domainAllowList === undefined) {
|
|
828
|
-
throw new DaytonaError_1.
|
|
857
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('At least one of networkBlockAll, networkAllowList or domainAllowList must be set');
|
|
829
858
|
}
|
|
830
859
|
const response = await this.sandboxApi.updateNetworkSettings(this.id, settings);
|
|
831
860
|
this.processSandboxDto(response.data);
|
|
@@ -897,6 +926,56 @@ let Sandbox = (() => {
|
|
|
897
926
|
async getPreviewLink(port) {
|
|
898
927
|
return (await this.sandboxApi.getPortPreviewUrl(this.id, port)).data;
|
|
899
928
|
}
|
|
929
|
+
/**
|
|
930
|
+
* Creates a pre-signed URL for downloading a file from the Sandbox.
|
|
931
|
+
*
|
|
932
|
+
* The URL works with any HTTP client without auth headers and stays valid across
|
|
933
|
+
* sandbox restarts (downloads succeed only while the sandbox is running). The signing
|
|
934
|
+
* key is cached locally for up to 15 seconds; if the key was rotated from another
|
|
935
|
+
* client, URLs may be rejected until the cache refreshes.
|
|
936
|
+
*
|
|
937
|
+
* @example
|
|
938
|
+
* ```typescript
|
|
939
|
+
* const url = await sandbox.downloadUrl('/home/user/report.pdf')
|
|
940
|
+
* // curl "$url" -o report.pdf
|
|
941
|
+
* ```
|
|
942
|
+
*
|
|
943
|
+
* @param path - Path to the file in the Sandbox.
|
|
944
|
+
* @param ttlSeconds - How long the URL stays valid, in seconds. Defaults to 3600. Zero or negative means the URL never expires.
|
|
945
|
+
* @returns Pre-signed download URL.
|
|
946
|
+
*/
|
|
947
|
+
async downloadUrl(path, ttlSeconds) {
|
|
948
|
+
return (0, fileUrlSigning_1.buildSignedFileUrl)(this.toolboxProxyUrl, this.id, '/files/download', 'GET', path, await this.ensureSigningKey(), ttlSeconds);
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Creates a pre-signed URL for uploading a file to the Sandbox.
|
|
952
|
+
*
|
|
953
|
+
* Send a POST request with the file as multipart/form-data. The URL works with any
|
|
954
|
+
* HTTP client without auth headers. The signing key is cached locally for up to
|
|
955
|
+
* 15 seconds; if the key was rotated from another client, URLs may be rejected
|
|
956
|
+
* until the cache refreshes.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const url = await sandbox.uploadUrl('/home/user/data.bin')
|
|
961
|
+
* // curl -X POST -F "file=@local.bin" "$url"
|
|
962
|
+
* ```
|
|
963
|
+
*
|
|
964
|
+
* @param path - Destination path for the uploaded file in the Sandbox.
|
|
965
|
+
* @param ttlSeconds - How long the URL stays valid, in seconds. Defaults to 3600. Zero or negative means the URL never expires.
|
|
966
|
+
* @returns Pre-signed upload URL.
|
|
967
|
+
*/
|
|
968
|
+
async uploadUrl(path, ttlSeconds) {
|
|
969
|
+
return (0, fileUrlSigning_1.buildSignedFileUrl)(this.toolboxProxyUrl, this.id, '/files/upload-v2', 'POST', path, await this.ensureSigningKey(), ttlSeconds);
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Rotates the sandbox signing key, invalidating all previously signed URLs.
|
|
973
|
+
*/
|
|
974
|
+
async rotateSigningKey() {
|
|
975
|
+
const signingKey = (await this.sandboxApi.rotateSigningKey(this.id)).data;
|
|
976
|
+
this.signingKey = signingKey;
|
|
977
|
+
this.signingKeyFetchedAt = Date.now() / 1000;
|
|
978
|
+
}
|
|
900
979
|
/**
|
|
901
980
|
* Retrieves a signed preview url for the sandbox at the specified port.
|
|
902
981
|
*
|
|
@@ -948,10 +1027,10 @@ let Sandbox = (() => {
|
|
|
948
1027
|
*/
|
|
949
1028
|
async resize(resources, timeout = 60) {
|
|
950
1029
|
if (timeout < 0) {
|
|
951
|
-
throw new DaytonaError_1.
|
|
1030
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
952
1031
|
}
|
|
953
1032
|
if ('gpu' in resources || 'gpuType' in resources) {
|
|
954
|
-
throw new DaytonaError_1.
|
|
1033
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Resize does not support changes to gpu or gpuType — to change GPU, create a new Sandbox');
|
|
955
1034
|
}
|
|
956
1035
|
const startTime = Date.now();
|
|
957
1036
|
const resizeRequest = {
|
|
@@ -977,7 +1056,7 @@ let Sandbox = (() => {
|
|
|
977
1056
|
*/
|
|
978
1057
|
async waitForResizeComplete(timeout = 60) {
|
|
979
1058
|
if (timeout < 0) {
|
|
980
|
-
throw new DaytonaError_1.
|
|
1059
|
+
throw new DaytonaError_1.DaytonaInvalidArgumentError('Timeout must be a non-negative number');
|
|
981
1060
|
}
|
|
982
1061
|
if (this.state !== api_client_1.SandboxState.RESIZING) {
|
|
983
1062
|
return;
|
|
@@ -1295,6 +1374,16 @@ let Sandbox = (() => {
|
|
|
1295
1374
|
}
|
|
1296
1375
|
this.stateWaiterErrorMessageFns.delete(waiter);
|
|
1297
1376
|
}
|
|
1377
|
+
async ensureSigningKey() {
|
|
1378
|
+
const key = this.signingKey;
|
|
1379
|
+
if (key === null || Date.now() / 1000 - this.signingKeyFetchedAt > 15) {
|
|
1380
|
+
const fetched = (await this.sandboxApi.getSandboxSigningKey(this.id)).data;
|
|
1381
|
+
this.signingKey = fetched;
|
|
1382
|
+
this.signingKeyFetchedAt = Date.now() / 1000;
|
|
1383
|
+
return fetched;
|
|
1384
|
+
}
|
|
1385
|
+
return key;
|
|
1386
|
+
}
|
|
1298
1387
|
};
|
|
1299
1388
|
})();
|
|
1300
1389
|
exports.Sandbox = Sandbox;
|