1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: upgrade deno_core to 0.256.0 (#22145)

This commit is contained in:
Divy Srivastava 2024-01-27 12:27:41 +05:30 committed by GitHub
parent 462ce14a78
commit d9191db0ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 56 additions and 79 deletions

12
Cargo.lock generated
View file

@ -1196,9 +1196,9 @@ dependencies = [
[[package]]
name = "deno_core"
version = "0.255.0"
version = "0.256.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66349d0fd8e9cad751435b59cf9e09e9fad9433301e9529ca4edf130ea3a06a0"
checksum = "cd5997286bcc46199bbae727f43ee65cf4bd073ac2d240a36a6ceae3bfab14ac"
dependencies = [
"anyhow",
"bit-set",
@ -1653,9 +1653,9 @@ dependencies = [
[[package]]
name = "deno_ops"
version = "0.131.0"
version = "0.132.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee3363343cd15758aa02792e93b53b1def9cf1e8b23dd82bdce0f223e6046e76"
checksum = "02163d08afdd6fcf21e37c399c7425987c7170203a853052a800e80c91c2e87b"
dependencies = [
"proc-macro-rules",
"proc-macro2",
@ -5357,9 +5357,9 @@ dependencies = [
[[package]]
name = "serde_v8"
version = "0.164.0"
version = "0.165.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f96a94476f3d22fe9f70c2d992d020173ccd61ad6fa1b62ed8090abe835c4e9f"
checksum = "88862d513bcbc04a7f93b0f454dffd0b01a5c0d8e1964c7532ec55f52b9a6351"
dependencies = [
"bytes",
"derive_more",

View file

@ -42,7 +42,7 @@ repository = "https://github.com/denoland/deno"
[workspace.dependencies]
deno_ast = { version = "0.32.0", features = ["transpiling"] }
deno_core = { version = "0.255.0" }
deno_core = { version = "0.256.0" }
deno_bench_util = { version = "0.129.0", path = "./bench_util" }
deno_lockfile = "0.18.0"

View file

@ -653,16 +653,16 @@ impl ModuleLoader for CliModuleLoader {
maybe_referrer: Option<&ModuleSpecifier>,
is_dynamic: bool,
requested_module_type: RequestedModuleType,
) -> Pin<Box<deno_core::ModuleSourceFuture>> {
) -> deno_core::ModuleLoadResponse {
// NOTE: this block is async only because of `deno_core` interface
// requirements; module was already loaded when constructing module graph
// during call to `prepare_load` so we can load it synchronously.
Box::pin(deno_core::futures::future::ready(self.load_sync(
deno_core::ModuleLoadResponse::Sync(self.load_sync(
specifier,
maybe_referrer,
is_dynamic,
requested_module_type,
)))
))
}
fn prepare_load(

View file

@ -53,7 +53,6 @@ use deno_runtime::permissions::PermissionsContainer;
use deno_runtime::WorkerLogLevel;
use deno_semver::npm::NpmPackageReqReference;
use import_map::parse_from_json;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
@ -150,16 +149,16 @@ impl ModuleLoader for EmbeddedModuleLoader {
maybe_referrer: Option<&ModuleSpecifier>,
is_dynamic: bool,
_requested_module_type: RequestedModuleType,
) -> Pin<Box<deno_core::ModuleSourceFuture>> {
) -> deno_core::ModuleLoadResponse {
let is_data_uri = get_source_from_data_url(original_specifier).ok();
if let Some((source, _)) = is_data_uri {
return Box::pin(deno_core::futures::future::ready(Ok(
return deno_core::ModuleLoadResponse::Sync(Ok(
deno_core::ModuleSource::new(
deno_core::ModuleType::JavaScript,
ModuleSourceCode::String(source.into()),
original_specifier,
),
)));
));
}
let permissions = if is_dynamic {
@ -175,7 +174,7 @@ impl ModuleLoader for EmbeddedModuleLoader {
)
{
return match result {
Ok(code_source) => Box::pin(deno_core::futures::future::ready(Ok(
Ok(code_source) => deno_core::ModuleLoadResponse::Sync(Ok(
deno_core::ModuleSource::new_with_redirect(
match code_source.media_type {
MediaType::Json => ModuleType::Json,
@ -185,45 +184,48 @@ impl ModuleLoader for EmbeddedModuleLoader {
original_specifier,
&code_source.found_url,
),
))),
Err(err) => Box::pin(deno_core::futures::future::ready(Err(err))),
)),
Err(err) => deno_core::ModuleLoadResponse::Sync(Err(err)),
};
}
let Some(module) =
self.shared.eszip.get_module(original_specifier.as_str())
else {
return Box::pin(deno_core::futures::future::ready(Err(type_error(
format!("Module not found: {}", original_specifier),
return deno_core::ModuleLoadResponse::Sync(Err(type_error(format!(
"Module not found: {}",
original_specifier
))));
};
let original_specifier = original_specifier.clone();
let found_specifier =
ModuleSpecifier::parse(&module.specifier).expect("invalid url in eszip");
async move {
let code = module.source().await.ok_or_else(|| {
type_error(format!("Module not found: {}", original_specifier))
})?;
let code = arc_u8_to_arc_str(code)
.map_err(|_| type_error("Module source is not utf-8"))?;
Ok(deno_core::ModuleSource::new_with_redirect(
match module.kind {
eszip::ModuleKind::JavaScript => ModuleType::JavaScript,
eszip::ModuleKind::Json => ModuleType::Json,
eszip::ModuleKind::Jsonc => {
return Err(type_error("jsonc modules not supported"))
}
eszip::ModuleKind::OpaqueData => {
unreachable!();
}
},
ModuleSourceCode::String(code.into()),
&original_specifier,
&found_specifier,
))
}
.boxed_local()
deno_core::ModuleLoadResponse::Async(
async move {
let code = module.source().await.ok_or_else(|| {
type_error(format!("Module not found: {}", original_specifier))
})?;
let code = arc_u8_to_arc_str(code)
.map_err(|_| type_error("Module source is not utf-8"))?;
Ok(deno_core::ModuleSource::new_with_redirect(
match module.kind {
eszip::ModuleKind::JavaScript => ModuleType::JavaScript,
eszip::ModuleKind::Json => ModuleType::Json,
eszip::ModuleKind::Jsonc => {
return Err(type_error("jsonc modules not supported"))
}
eszip::ModuleKind::OpaqueData => {
unreachable!();
}
},
ModuleSourceCode::String(code.into()),
&original_specifier,
&found_specifier,
))
}
.boxed_local(),
)
}
}

View file

@ -1,6 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use deno_core::error::bad_resource_id;
use deno_core::error::AnyError;
use deno_core::op2;
use deno_core::v8;
@ -14,7 +13,7 @@ use x509_parser::prelude::*;
use digest::Digest;
struct Certificate {
pub(crate) struct Certificate {
_buf: Vec<u8>,
pem: Option<pem::Pem>,
cert: X509Certificate<'static>,
@ -73,20 +72,15 @@ pub fn op_node_x509_parse<'s>(
}
#[op2(fast)]
pub fn op_node_x509_ca(rid: v8::Local<v8::Object>) -> Result<bool, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
pub fn op_node_x509_ca(#[cppgc] cert: &Certificate) -> Result<bool, AnyError> {
Ok(cert.is_ca())
}
#[op2(fast)]
pub fn op_node_x509_check_email(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
#[string] email: &str,
) -> Result<bool, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
let subject = cert.subject();
if subject
.iter_email()
@ -120,50 +114,40 @@ pub fn op_node_x509_check_email(
#[op2]
#[string]
pub fn op_node_x509_fingerprint(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<Option<String>, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(cert.fingerprint::<sha1::Sha1>())
}
#[op2]
#[string]
pub fn op_node_x509_fingerprint256(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<Option<String>, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(cert.fingerprint::<sha2::Sha256>())
}
#[op2]
#[string]
pub fn op_node_x509_fingerprint512(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<Option<String>, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(cert.fingerprint::<sha2::Sha512>())
}
#[op2]
#[string]
pub fn op_node_x509_get_issuer(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<String, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(x509name_to_string(cert.issuer(), oid_registry())?)
}
#[op2]
#[string]
pub fn op_node_x509_get_subject(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<String, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(x509name_to_string(cert.subject(), oid_registry())?)
}
@ -230,30 +214,24 @@ fn x509name_to_string(
#[op2]
#[string]
pub fn op_node_x509_get_valid_from(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<String, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(cert.validity().not_before.to_string())
}
#[op2]
#[string]
pub fn op_node_x509_get_valid_to(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<String, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
Ok(cert.validity().not_after.to_string())
}
#[op2]
#[string]
pub fn op_node_x509_get_serial_number(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<String, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
let mut s = cert.serial.to_str_radix(16);
s.make_ascii_uppercase();
Ok(s)
@ -261,11 +239,8 @@ pub fn op_node_x509_get_serial_number(
#[op2(fast)]
pub fn op_node_x509_key_usage(
rid: v8::Local<v8::Object>,
#[cppgc] cert: &Certificate,
) -> Result<u16, AnyError> {
let cert = deno_core::cppgc::unwrap_cppgc_object::<Certificate>(rid)
.ok_or_else(bad_resource_id)?;
let key_usage = cert
.extensions()
.iter()