@daytonaio/sdk 0.200.0 → 0.201.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/Daytona.js +2 -2
- 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/ObjectStorage.d.ts +2 -1
- package/cjs/ObjectStorage.js +1 -5
- package/cjs/ObjectStorage.js.map +1 -1
- package/cjs/Sandbox.d.ts +53 -0
- package/cjs/Sandbox.js +72 -0
- 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 +119 -141
- package/cjs/errors/DaytonaError.js +225 -163
- package/cjs/errors/DaytonaError.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +40 -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/Daytona.js +2 -2
- 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/ObjectStorage.d.ts +2 -1
- package/esm/ObjectStorage.js +1 -5
- package/esm/ObjectStorage.js.map +1 -1
- package/esm/Sandbox.d.ts +53 -0
- package/esm/Sandbox.js +72 -0
- 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 +119 -141
- package/esm/errors/DaytonaError.js +194 -157
- package/esm/errors/DaytonaError.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +11 -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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { createHmac } from 'crypto';
|
|
6
|
+
import { DaytonaError } from '../errors/DaytonaError.js';
|
|
7
|
+
const SIGNATURE_V1_PREFIX = 'v1_';
|
|
8
|
+
const DEFAULT_TTL_SECONDS = 3600;
|
|
9
|
+
export function computeFileUrlSignature(signingKey, method, path, expires) {
|
|
10
|
+
const canonical = `v1:files:${method}:${path}:${expires}`;
|
|
11
|
+
const digest = createHmac('sha256', signingKey).update(canonical).digest('base64url');
|
|
12
|
+
return `${SIGNATURE_V1_PREFIX}${digest}`;
|
|
13
|
+
}
|
|
14
|
+
export function resolveExpires(ttlSeconds) {
|
|
15
|
+
if (ttlSeconds === undefined) {
|
|
16
|
+
return Math.floor(Date.now() / 1000) + DEFAULT_TTL_SECONDS;
|
|
17
|
+
}
|
|
18
|
+
if (!Number.isFinite(ttlSeconds)) {
|
|
19
|
+
throw new DaytonaError('ttlSeconds must be a finite number');
|
|
20
|
+
}
|
|
21
|
+
if (ttlSeconds <= 0) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
return Math.floor(Date.now() / 1000) + Math.floor(ttlSeconds);
|
|
25
|
+
}
|
|
26
|
+
export function buildSignedFileUrl(toolboxProxyUrl, sandboxId, operationPath, method, filePath, signingKey, ttlSeconds) {
|
|
27
|
+
if (!signingKey) {
|
|
28
|
+
throw new DaytonaError('Sandbox signing key is not available. Call refreshData() or fetch the sandbox by ID to load it.');
|
|
29
|
+
}
|
|
30
|
+
if (!toolboxProxyUrl) {
|
|
31
|
+
throw new DaytonaError('Sandbox toolbox proxy URL is not available. Call refreshData() or fetch the sandbox by ID to load it.');
|
|
32
|
+
}
|
|
33
|
+
const expires = resolveExpires(ttlSeconds);
|
|
34
|
+
const signature = computeFileUrlSignature(signingKey, method, filePath, expires);
|
|
35
|
+
const query = new URLSearchParams({
|
|
36
|
+
path: filePath,
|
|
37
|
+
expires: String(expires),
|
|
38
|
+
signature,
|
|
39
|
+
});
|
|
40
|
+
return `${toolboxProxyUrl.replace(/\/+$/, '')}/${sandboxId}${operationPath}?${query.toString()}`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=fileUrlSigning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUrlSigning.js","sourceRoot":"","sources":["../../../../../sdk-typescript/src/utils/fileUrlSigning.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD,MAAM,mBAAmB,GAAG,KAAK,CAAA;AACjC,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC,MAAM,UAAU,uBAAuB,CAAC,UAAkB,EAAE,MAAc,EAAE,IAAY,EAAE,OAAe;IACvG,MAAM,SAAS,GAAG,YAAY,MAAM,IAAI,IAAI,IAAI,OAAO,EAAE,CAAA;IACzD,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;IACrF,OAAO,GAAG,mBAAmB,GAAG,MAAM,EAAE,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,UAA8B;IAC3D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAA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
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.201.0",
|
|
4
4
|
"description": "Daytona TypeScript SDK for sandbox management and code execution",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -69,18 +69,20 @@
|
|
|
69
69
|
"sdk"
|
|
70
70
|
],
|
|
71
71
|
"dependencies": {
|
|
72
|
+
"tslib": "2.8.1",
|
|
73
|
+
"ws": "^8.18.0",
|
|
72
74
|
"@aws-sdk/client-s3": "^3.787.0",
|
|
73
75
|
"@aws-sdk/lib-storage": "^3.798.0",
|
|
74
76
|
"@iarna/toml": "^2.2.5",
|
|
75
|
-
"@opentelemetry/api": "^1.9.
|
|
76
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
77
|
-
"@opentelemetry/instrumentation-http": "^0.
|
|
78
|
-
"@opentelemetry/otlp-exporter-base": "0.
|
|
79
|
-
"@opentelemetry/resources": "2.
|
|
80
|
-
"@opentelemetry/sdk-node": "^0.
|
|
81
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
82
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
83
|
-
"axios": "^1.
|
|
77
|
+
"@opentelemetry/api": "^1.9.1",
|
|
78
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
|
|
79
|
+
"@opentelemetry/instrumentation-http": "^0.220.0",
|
|
80
|
+
"@opentelemetry/otlp-exporter-base": "0.220.0",
|
|
81
|
+
"@opentelemetry/resources": "2.9.0",
|
|
82
|
+
"@opentelemetry/sdk-node": "^0.220.0",
|
|
83
|
+
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
84
|
+
"@opentelemetry/semantic-conventions": "^1.43.0",
|
|
85
|
+
"axios": "^1.18.0",
|
|
84
86
|
"busboy": "^1.0.0",
|
|
85
87
|
"dotenv": "^17.0.1",
|
|
86
88
|
"expand-tilde": "^2.0.2",
|
|
@@ -91,8 +93,8 @@
|
|
|
91
93
|
"shell-quote": "^1.8.2",
|
|
92
94
|
"socket.io-client": "^4.8.1",
|
|
93
95
|
"tar": "^7.5.11",
|
|
94
|
-
"@daytona/api-client": "0.
|
|
95
|
-
"@daytona/toolbox-api-client": "0.
|
|
96
|
-
"@daytona/analytics-api-client": "0.
|
|
96
|
+
"@daytona/api-client": "0.201.0",
|
|
97
|
+
"@daytona/toolbox-api-client": "0.201.0",
|
|
98
|
+
"@daytona/analytics-api-client": "0.201.0"
|
|
97
99
|
}
|
|
98
100
|
}
|