daytona 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.
@@ -0,0 +1,56 @@
1
+ # Copyright Daytona Platforms Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ # frozen_string_literal: true
5
+
6
+ require 'base64'
7
+ require 'openssl'
8
+ require 'uri'
9
+
10
+ module Daytona
11
+ module Utils
12
+ module FileUrlSigning
13
+ SIGNATURE_V1_PREFIX = 'v1_'
14
+ private_constant :SIGNATURE_V1_PREFIX
15
+
16
+ DEFAULT_TTL_SECONDS = 3600
17
+ private_constant :DEFAULT_TTL_SECONDS
18
+
19
+ module_function
20
+
21
+ def compute_file_url_signature(signing_key, method, path, expires)
22
+ canonical = "v1:files:#{method}:#{path}:#{expires}"
23
+ digest = OpenSSL::HMAC.digest('sha256', signing_key, canonical)
24
+
25
+ "#{SIGNATURE_V1_PREFIX}#{Base64.urlsafe_encode64(digest, padding: false)}"
26
+ end
27
+
28
+ def resolve_expires(ttl_seconds)
29
+ return Time.now.to_i + DEFAULT_TTL_SECONDS if ttl_seconds.nil?
30
+
31
+ return 0 if ttl_seconds <= 0
32
+
33
+ Time.now.to_i + ttl_seconds
34
+ end
35
+
36
+ def build_signed_file_url(toolbox_proxy_url, sandbox_id, operation_path, method, file_path, signing_key,
37
+ ttl_seconds)
38
+ if signing_key.nil? || signing_key.empty?
39
+ raise Daytona::Sdk::Error,
40
+ 'Sandbox signing key is not available. Call refresh or fetch the sandbox by ID to load it.'
41
+ end
42
+
43
+ if toolbox_proxy_url.nil? || toolbox_proxy_url.empty?
44
+ raise Daytona::Sdk::Error,
45
+ 'Sandbox toolbox proxy URL is not available. Call refresh or fetch the sandbox by ID to load it.'
46
+ end
47
+
48
+ expires = resolve_expires(ttl_seconds)
49
+ signature = compute_file_url_signature(signing_key, method, file_path, expires)
50
+ query = URI.encode_www_form(path: file_path, expires: expires.to_s, signature:)
51
+
52
+ "#{toolbox_proxy_url.sub(%r{/+\z}, '')}/#{sandbox_id}#{operation_path}?#{query}"
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daytona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.200.0
4
+ version: 0.201.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daytona Platforms Inc.
@@ -85,56 +85,62 @@ dependencies:
85
85
  requirements:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
- version: 0.200.0
88
+ version: 0.201.0
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 0.200.0
95
+ version: 0.201.0
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: daytona_api_client
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 0.200.0
102
+ version: 0.201.0
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 0.200.0
109
+ version: 0.201.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: daytona_toolbox_api_client
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 0.200.0
116
+ version: 0.201.0
117
117
  type: :runtime
118
118
  prerelease: false
119
119
  version_requirements: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - '='
122
122
  - !ruby/object:Gem::Version
123
- version: 0.200.0
123
+ version: 0.201.0
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: dotenv
126
126
  requirement: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - "~>"
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '2.0'
131
+ - - "<"
132
+ - !ruby/object:Gem::Version
133
+ version: '4'
131
134
  type: :runtime
132
135
  prerelease: false
133
136
  version_requirements: !ruby/object:Gem::Requirement
134
137
  requirements:
135
- - - "~>"
138
+ - - ">="
136
139
  - !ruby/object:Gem::Version
137
140
  version: '2.0'
141
+ - - "<"
142
+ - !ruby/object:Gem::Version
143
+ version: '4'
138
144
  - !ruby/object:Gem::Dependency
139
145
  name: observer
140
146
  requirement: !ruby/object:Gem::Requirement
@@ -221,11 +227,15 @@ files:
221
227
  - lib/daytona/process.rb
222
228
  - lib/daytona/sandbox.rb
223
229
  - lib/daytona/sdk.rb
230
+ - lib/daytona/sdk/deprecated.rb
231
+ - lib/daytona/sdk/errors.rb
232
+ - lib/daytona/sdk/file_download_patch.rb
224
233
  - lib/daytona/sdk/version.rb
225
234
  - lib/daytona/secret.rb
226
235
  - lib/daytona/secret_service.rb
227
236
  - lib/daytona/snapshot_service.rb
228
237
  - lib/daytona/util.rb
238
+ - lib/daytona/utils/file_url_signing.rb
229
239
  - lib/daytona/volume.rb
230
240
  - lib/daytona/volume_service.rb
231
241
  - project.json