mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
31154ff958
I've been meaning to fix this for ages, but I finally ran into it here: https://github.com/dsherret/ts-ast-viewer/actions/runs/9432038675/job/25981325408 We need to resolve the `@types` package as a fallback instead of eagerly resolving it.
25 lines
743 B
Rust
25 lines
743 B
Rust
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use deno_npm::npm_rc::RegistryConfig;
|
|
use reqwest::header;
|
|
|
|
// TODO(bartlomieju): support more auth methods besides token and basic auth
|
|
pub fn maybe_auth_header_for_npm_registry(
|
|
registry_config: &RegistryConfig,
|
|
) -> Option<(header::HeaderName, header::HeaderValue)> {
|
|
if let Some(token) = registry_config.auth_token.as_ref() {
|
|
return Some((
|
|
header::AUTHORIZATION,
|
|
header::HeaderValue::from_str(&format!("Bearer {}", token)).unwrap(),
|
|
));
|
|
}
|
|
|
|
if let Some(auth) = registry_config.auth.as_ref() {
|
|
return Some((
|
|
header::AUTHORIZATION,
|
|
header::HeaderValue::from_str(&format!("Basic {}", auth)).unwrap(),
|
|
));
|
|
}
|
|
|
|
None
|
|
}
|