Skip to content

Commit f6d7faf

Browse files
Merge pull request #262 from supabase/bump-d-version
feat: Upgrade to Deno 1.40.3
2 parents 5cfa578 + 87f8b69 commit f6d7faf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2167
-1045
lines changed

Cargo.lock

Lines changed: 737 additions & 197 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,41 @@ resolver = "2"
1818

1919
[workspace.dependencies]
2020
url = { version = "2.3.1" }
21-
eszip = "0.56.0"
21+
eszip = "0.60.0"
2222
log = "0.4.20"
2323
anyhow = { version = "1.0.57" }
2424
libc = { version = "0.2.144" }
25-
deno_ast = { version = "0.31.6", features = ["transpiling"] }
26-
deno_broadcast_channel = { version = "0.124.0" }
27-
deno_core = { version = "0.243.0" }
28-
deno_console = { version = "0.130.0" }
29-
deno_crypto = { version = "0.144.0" }
30-
deno_fetch = { version = "0.154.0" }
31-
deno_fs = { version = "0.40.0", features = ["sync_fs"] }
32-
deno_config = "=0.3.1"
33-
deno_io = "0.40.0"
34-
deno_graph = "=0.62.2"
35-
deno_http = { version = "0.127.0" }
25+
deno_ast = { version = "0.32.0", features = ["transpiling"] }
26+
deno_broadcast_channel = { version = "0.130.0" }
27+
deno_core = { version = "0.256.0" }
28+
deno_console = { version = "0.136.0" }
29+
deno_crypto = { version = "0.150.0" }
30+
deno_fetch = { version = "0.160.0" }
31+
deno_fs = { version = "0.46.0", features = ["sync_fs"] }
32+
deno_config = "=0.9.1"
33+
deno_io = "0.46.0"
34+
deno_webgpu = "0.103.0"
35+
deno_canvas = "0.5.0"
36+
deno_graph = "=0.64.1"
37+
deno_http = { version = "0.133.0" }
3638
deno_media_type = { version = "0.1.1", features = ["module_specifier"] }
37-
deno_net = { version = "0.122.0" }
38-
deno_npm = "0.15.3"
39-
deno_url = { version = "0.130.0" }
40-
deno_semver = "0.5.1"
41-
deno_tls = { version = "0.117.0"}
42-
deno_webidl = { version = "0.130.0" }
43-
deno_web = { version = "0.161.0" }
44-
deno_websocket = { version = "0.135.0" }
45-
deno_webstorage = { version = "0.125.0" }
39+
deno_net = { version = "0.128.0" }
40+
deno_npm = "0.16.0"
41+
deno_url = { version = "0.136.0" }
42+
deno_semver = "0.5.4"
43+
deno_tls = { version = "0.123.0"}
44+
deno_webidl = { version = "0.136.0" }
45+
deno_web = { version = "0.167.0" }
46+
deno_websocket = { version = "0.141.0" }
47+
deno_webstorage = { version = "0.131.0" }
4648
enum-as-inner = "0.6.0"
4749
serde = { version = "1.0.149", features = ["derive"] }
4850
hyper = "0.14.26"
4951
tokio = { version = "1.28.1", features = ["full"] }
5052
bytes = { version = "1.4.0" }
5153
once_cell = "1.17.1"
5254
thiserror = "1.0.40"
53-
deno_lockfile = "0.17.2"
55+
deno_lockfile = "0.18.0"
5456
async-trait = "0.1.73"
5557
indexmap = { version = "2.0.0", features = ["serde"] }
5658
flate2 = "=1.0.26"

crates/base/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ urlencoding.workspace = true
6060
scopeguard.workspace = true
6161
pin-project = { version = "1.1.3" }
6262
ctor = { workspace = true }
63+
deno_canvas.workspace = true
64+
deno_webgpu.workspace = true
6365

6466
[dev-dependencies]
6567
flaky_test = { version = "0.1.0", path = "../flaky_test" }
@@ -98,4 +100,6 @@ tokio.workspace = true
98100
url.workspace = true
99101
event_worker ={ version = "0.1.0", path = "../event_worker" }
100102
deno_broadcast_channel.workspace = true
101-
deno_core.workspace = true
103+
deno_core.workspace = true
104+
deno_canvas.workspace = true
105+
deno_webgpu.workspace = true

crates/base/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ mod supabase_startup_snapshot {
156156
fn check_sys(&self, _kind: &str, _api_name: &str) -> Result<(), AnyError> {
157157
unreachable!("snapshotting!")
158158
}
159+
160+
fn check_write_with_api_name(
161+
&self,
162+
_path: &Path,
163+
_api_name: Option<&str>,
164+
) -> Result<(), AnyError> {
165+
unreachable!("snapshotting!")
166+
}
159167
}
160168

161169
pub fn create_runtime_snapshot(snapshot_path: PathBuf) {
@@ -170,6 +178,8 @@ mod supabase_startup_snapshot {
170178
Arc::new(deno_web::BlobStore::default()),
171179
None,
172180
),
181+
deno_webgpu::deno_webgpu::init_ops_and_esm(),
182+
deno_canvas::deno_canvas::init_ops_and_esm(),
173183
deno_fetch::deno_fetch::init_ops_and_esm::<Permissions>(deno_fetch::Options {
174184
user_agent: user_agent.clone(),
175185
root_cert_store_provider: None,

crates/base/src/deno_runtime.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ctor::ctor;
88
use deno_core::error::AnyError;
99
use deno_core::url::Url;
1010
use deno_core::{
11-
located_script_name, serde_v8, JsRuntime, ModuleCode, ModuleId, PollEventLoopOptions,
11+
located_script_name, serde_v8, JsRuntime, ModuleCodeString, ModuleId, PollEventLoopOptions,
1212
RuntimeOptions,
1313
};
1414
use deno_http::DefaultHttpPropertyExtractor;
@@ -247,6 +247,8 @@ impl DenoRuntime {
247247
Arc::new(deno_web::BlobStore::default()),
248248
None,
249249
),
250+
deno_webgpu::deno_webgpu::init_ops(),
251+
deno_canvas::deno_canvas::init_ops(),
250252
deno_fetch::deno_fetch::init_ops::<Permissions>(deno_fetch::Options {
251253
user_agent: user_agent.clone(),
252254
root_cert_store_provider: Some(root_cert_store_provider.clone()),
@@ -319,7 +321,7 @@ impl DenoRuntime {
319321
);
320322

321323
js_runtime
322-
.execute_script(located_script_name!(), ModuleCode::from(script))
324+
.execute_script(located_script_name!(), ModuleCodeString::from(script))
323325
.expect("Failed to execute bootstrap script");
324326

325327
{
@@ -539,7 +541,7 @@ fn set_v8_flags() {
539541
mod test {
540542
use crate::deno_runtime::DenoRuntime;
541543
use crate::rt_worker::worker::UnixStreamEntry;
542-
use deno_core::{FastString, ModuleCode, PollEventLoopOptions};
544+
use deno_core::{FastString, ModuleCodeString, PollEventLoopOptions};
543545
use sb_graph::emitter::EmitterFactory;
544546
use sb_graph::{generate_binary_eszip, EszipPayloadKind};
545547
use sb_workers::context::{
@@ -634,7 +636,7 @@ mod test {
634636
.js_runtime
635637
.execute_script(
636638
"<anon>",
637-
ModuleCode::from(
639+
ModuleCodeString::from(
638640
r#"
639641
globalThis.isTenEven;
640642
"#
@@ -695,7 +697,7 @@ mod test {
695697
.js_runtime
696698
.execute_script(
697699
"<anon>",
698-
ModuleCode::from(
700+
ModuleCodeString::from(
699701
r#"
700702
globalThis.isTenEven;
701703
"#
@@ -798,7 +800,7 @@ mod test {
798800
.js_runtime
799801
.execute_script(
800802
"<anon>",
801-
ModuleCode::from(
803+
ModuleCodeString::from(
802804
r#"
803805
Deno.readTextFileSync("./test_cases/readFile/hello_world.json");
804806
"#
@@ -853,7 +855,7 @@ mod test {
853855
.js_runtime
854856
.execute_script(
855857
"<anon>",
856-
ModuleCode::from(
858+
ModuleCodeString::from(
857859
r#"
858860
// Should not be able to set
859861
const data = {
@@ -947,7 +949,7 @@ mod test {
947949

948950
let user_rt_execute_scripts = user_rt.js_runtime.execute_script(
949951
"<anon>",
950-
ModuleCode::from(
952+
ModuleCodeString::from(
951953
r#"
952954
let cmd = new Deno.Command("", {});
953955
cmd.outputSync();
@@ -980,7 +982,7 @@ mod test {
980982
.js_runtime
981983
.execute_script(
982984
"<anon>",
983-
ModuleCode::from(
985+
ModuleCodeString::from(
984986
r#"
985987
// Should not be able to set
986988
Deno.env.set("Supa_Test", "Supa_Value");
@@ -998,7 +1000,7 @@ mod test {
9981000
.js_runtime
9991001
.execute_script(
10001002
"<anon>",
1001-
ModuleCode::from(
1003+
ModuleCodeString::from(
10021004
r#"
10031005
// Should not be able to set
10041006
Deno.env.get("Supa_Test");
@@ -1017,7 +1019,7 @@ mod test {
10171019
.js_runtime
10181020
.execute_script(
10191021
"<anon>",
1020-
ModuleCode::from(
1022+
ModuleCodeString::from(
10211023
r#"
10221024
// Should not be able to set
10231025
Deno.env.get("Supa_Test");

crates/cli/.env.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DENO_VERSION="1.39.2"
1+
DENO_VERSION="1.40.3"

crates/node/analyze.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,16 @@ static RESERVED_WORDS: Lazy<HashSet<&str>> = Lazy::new(|| {
379379
fn add_export(source: &mut Vec<String>, name: &str, initializer: &str, temp_var_count: &mut usize) {
380380
fn is_valid_var_decl(name: &str) -> bool {
381381
// it's ok to be super strict here
382+
if name.is_empty() {
383+
return false;
384+
}
385+
386+
if let Some(first) = name.chars().next() {
387+
if !first.is_ascii_alphabetic() && first != '_' && first != '$' {
388+
return false;
389+
}
390+
}
391+
382392
name.chars()
383393
.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '$')
384394
}
@@ -465,7 +475,7 @@ mod tests {
465475
let mut temp_var_count = 0;
466476
let mut source = vec![];
467477

468-
let exports = vec!["static", "server", "app", "dashed-export"];
478+
let exports = vec!["static", "server", "app", "dashed-export", "3d"];
469479
for export in exports {
470480
add_export(&mut source, export, "init", &mut temp_var_count);
471481
}
@@ -478,6 +488,8 @@ mod tests {
478488
"export const app = init;".to_string(),
479489
"const __deno_export_2__ = init;".to_string(),
480490
"export { __deno_export_2__ as \"dashed-export\" };".to_string(),
491+
"const __deno_export_3__ = init;".to_string(),
492+
"export { __deno_export_3__ as \"3d\" };".to_string(),
481493
]
482494
)
483495
}

crates/node/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ pub trait NodePermissions {
5757
fn check_read_with_api_name(&self, path: &Path, api_name: Option<&str>)
5858
-> Result<(), AnyError>;
5959
fn check_sys(&self, kind: &str, api_name: &str) -> Result<(), AnyError>;
60+
fn check_write_with_api_name(
61+
&self,
62+
path: &Path,
63+
api_name: Option<&str>,
64+
) -> Result<(), AnyError>;
6065
}
6166

6267
pub(crate) struct AllowAllNodePermissions;
@@ -72,6 +77,13 @@ impl NodePermissions for AllowAllNodePermissions {
7277
) -> Result<(), AnyError> {
7378
Ok(())
7479
}
80+
fn check_write_with_api_name(
81+
&self,
82+
_path: &Path,
83+
_api_name: Option<&str>,
84+
) -> Result<(), AnyError> {
85+
Ok(())
86+
}
7587
fn check_sys(&self, _kind: &str, _api_name: &str) -> Result<(), AnyError> {
7688
Ok(())
7789
}
@@ -226,6 +238,8 @@ deno_core::extension!(deno_node,
226238
ops::crypto::x509::op_node_x509_get_serial_number,
227239
ops::crypto::x509::op_node_x509_key_usage,
228240
ops::fs::op_node_fs_exists_sync<P>,
241+
ops::fs::op_node_cp_sync<P>,
242+
ops::fs::op_node_cp<P>,
229243
ops::winerror::op_node_sys_to_uv_error,
230244
ops::v8::op_v8_cached_data_version_tag,
231245
ops::v8::op_v8_get_heap_statistics,
@@ -317,6 +331,7 @@ deno_core::extension!(deno_node,
317331
"_fs/_fs_common.ts",
318332
"_fs/_fs_constants.ts",
319333
"_fs/_fs_copy.ts",
334+
"_fs/_fs_cp.js",
320335
"_fs/_fs_dir.ts",
321336
"_fs/_fs_dirent.ts",
322337
"_fs/_fs_exists.ts",
@@ -359,7 +374,7 @@ deno_core::extension!(deno_node,
359374
"_stream.mjs",
360375
"_tls_common.ts",
361376
"_tls_wrap.ts",
362-
"_util/_util_callbackify.ts",
377+
"_util/_util_callbackify.js",
363378
"_util/asserts.ts",
364379
"_util/async.ts",
365380
"_util/os.ts",

crates/node/ops/crypto/cipher.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ enum Cipher {
2525
Aes256Ecb(Box<ecb::Encryptor<aes::Aes256>>),
2626
Aes128Gcm(Box<Aes128Gcm>),
2727
Aes256Gcm(Box<Aes256Gcm>),
28-
// TODO(kt3k): add more algorithms Aes192Cbc, Aes256Cbc, etc.
28+
Aes256Cbc(Box<cbc::Encryptor<aes::Aes256>>),
29+
// TODO(kt3k): add more algorithms Aes192Cbc, etc.
2930
}
3031

3132
enum Decipher {
@@ -35,7 +36,8 @@ enum Decipher {
3536
Aes256Ecb(Box<ecb::Decryptor<aes::Aes256>>),
3637
Aes128Gcm(Box<Aes128Gcm>),
3738
Aes256Gcm(Box<Aes256Gcm>),
38-
// TODO(kt3k): add more algorithms Aes192Cbc, Aes256Cbc, Aes128GCM, etc.
39+
Aes256Cbc(Box<cbc::Decryptor<aes::Aes256>>),
40+
// TODO(kt3k): add more algorithms Aes192Cbc, Aes128GCM, etc.
3941
}
4042

4143
pub struct CipherContext {
@@ -124,6 +126,9 @@ impl Cipher {
124126

125127
Aes256Gcm(Box::new(cipher))
126128
}
129+
"aes256" | "aes-256-cbc" => {
130+
Aes256Cbc(Box::new(cbc::Encryptor::new(key.into(), iv.into())))
131+
}
127132
_ => return Err(type_error(format!("Unknown cipher {algorithm_name}"))),
128133
})
129134
}
@@ -177,6 +182,12 @@ impl Cipher {
177182
output[..input.len()].copy_from_slice(input);
178183
cipher.encrypt(output);
179184
}
185+
Aes256Cbc(encryptor) => {
186+
assert!(input.len() % 16 == 0);
187+
for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) {
188+
encryptor.encrypt_block_b2b_mut(input.into(), output.into());
189+
}
190+
}
180191
}
181192
}
182193

@@ -211,6 +222,12 @@ impl Cipher {
211222
}
212223
Aes128Gcm(cipher) => Ok(Some(cipher.finish().to_vec())),
213224
Aes256Gcm(cipher) => Ok(Some(cipher.finish().to_vec())),
225+
Aes256Cbc(encryptor) => {
226+
let _ = (*encryptor)
227+
.encrypt_padded_b2b_mut::<Pkcs7>(input, output)
228+
.map_err(|_| type_error("Cannot pad the input data"))?;
229+
Ok(None)
230+
}
214231
}
215232
}
216233
}
@@ -235,6 +252,9 @@ impl Decipher {
235252

236253
Aes256Gcm(Box::new(decipher))
237254
}
255+
"aes256" | "aes-256-cbc" => {
256+
Aes256Cbc(Box::new(cbc::Decryptor::new(key.into(), iv.into())))
257+
}
238258
_ => return Err(type_error(format!("Unknown cipher {algorithm_name}"))),
239259
})
240260
}
@@ -288,6 +308,12 @@ impl Decipher {
288308
output[..input.len()].copy_from_slice(input);
289309
decipher.decrypt(output);
290310
}
311+
Aes256Cbc(decryptor) => {
312+
assert!(input.len() % 16 == 0);
313+
for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) {
314+
decryptor.decrypt_block_b2b_mut(input.into(), output.into());
315+
}
316+
}
291317
}
292318
}
293319

@@ -339,6 +365,13 @@ impl Decipher {
339365
Err(type_error("Failed to authenticate data"))
340366
}
341367
}
368+
Aes256Cbc(decryptor) => {
369+
assert!(input.len() == 16);
370+
let _ = (*decryptor)
371+
.decrypt_padded_b2b_mut::<Pkcs7>(input, output)
372+
.map_err(|_| type_error("Cannot unpad the input data"))?;
373+
Ok(())
374+
}
342375
}
343376
}
344377
}

0 commit comments

Comments
 (0)