@solana/rpc-transport-http
Advanced tools
Comparing version 2.0.0-experimental.61f4b59 to 2.0.0-experimental.97527f4
@@ -41,5 +41,5 @@ // ../build-scripts/env-shim.ts | ||
"permissions-policy": true, | ||
// No currently available Typescript technique allows you to match on a prefix. | ||
// 'proxy-':true, | ||
// 'sec-':true, | ||
// Prefix matching is implemented in code, below. | ||
// 'proxy-': true, | ||
// 'sec-': true, | ||
referer: true, | ||
@@ -72,6 +72,21 @@ te: true, | ||
// src/http-transport.ts | ||
function createHttpTransport({ headers, url }) { | ||
var didWarnDispatcherWasSuppliedInNonNodeEnvironment = false; | ||
function warnDispatcherWasSuppliedInNonNodeEnvironment() { | ||
if (didWarnDispatcherWasSuppliedInNonNodeEnvironment) { | ||
return; | ||
} | ||
didWarnDispatcherWasSuppliedInNonNodeEnvironment = true; | ||
console.warn( | ||
"You have supplied a `Dispatcher` to `createHttpTransport()`. It has been ignored because Undici dispatchers only work in Node environments. To eliminate this warning, omit the `dispatcher_NODE_ONLY` property from your config when running in a non-Node environment." | ||
); | ||
} | ||
function createHttpTransport(config) { | ||
if (__DEV__ && true && "dispatcher_NODE_ONLY" in config) { | ||
warnDispatcherWasSuppliedInNonNodeEnvironment(); | ||
} | ||
const { headers, url } = config; | ||
if (__DEV__ && headers) { | ||
assertIsAllowedHttpRequestHeaders(headers); | ||
} | ||
let dispatcherConfig; | ||
const customHeaders = headers && normalizeHeaders(headers); | ||
@@ -84,2 +99,3 @@ return async function makeHttpRequest({ | ||
const requestInfo = { | ||
...dispatcherConfig, | ||
body, | ||
@@ -86,0 +102,0 @@ headers: { |
@@ -41,5 +41,5 @@ // ../build-scripts/env-shim.ts | ||
"permissions-policy": true, | ||
// No currently available Typescript technique allows you to match on a prefix. | ||
// 'proxy-':true, | ||
// 'sec-':true, | ||
// Prefix matching is implemented in code, below. | ||
// 'proxy-': true, | ||
// 'sec-': true, | ||
referer: true, | ||
@@ -72,6 +72,21 @@ te: true, | ||
// src/http-transport.ts | ||
function createHttpTransport({ headers, url }) { | ||
var didWarnDispatcherWasSuppliedInNonNodeEnvironment = false; | ||
function warnDispatcherWasSuppliedInNonNodeEnvironment() { | ||
if (didWarnDispatcherWasSuppliedInNonNodeEnvironment) { | ||
return; | ||
} | ||
didWarnDispatcherWasSuppliedInNonNodeEnvironment = true; | ||
console.warn( | ||
"You have supplied a `Dispatcher` to `createHttpTransport()`. It has been ignored because Undici dispatchers only work in Node environments. To eliminate this warning, omit the `dispatcher_NODE_ONLY` property from your config when running in a non-Node environment." | ||
); | ||
} | ||
function createHttpTransport(config) { | ||
if (__DEV__ && true && "dispatcher_NODE_ONLY" in config) { | ||
warnDispatcherWasSuppliedInNonNodeEnvironment(); | ||
} | ||
const { headers, url } = config; | ||
if (__DEV__ && headers) { | ||
assertIsAllowedHttpRequestHeaders(headers); | ||
} | ||
let dispatcherConfig; | ||
const customHeaders = headers && normalizeHeaders(headers); | ||
@@ -84,2 +99,3 @@ return async function makeHttpRequest({ | ||
const requestInfo = { | ||
...dispatcherConfig, | ||
body, | ||
@@ -86,0 +102,0 @@ headers: { |
@@ -0,7 +1,6 @@ | ||
import { fetch } from 'undici'; | ||
// ../build-scripts/env-shim.ts | ||
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")(); | ||
// ../fetch-impl/dist/index.node.js | ||
var e = globalThis.fetch; | ||
// src/http-transport-errors.ts | ||
@@ -41,5 +40,5 @@ var SolanaHttpError = class extends Error { | ||
"permissions-policy": true, | ||
// No currently available Typescript technique allows you to match on a prefix. | ||
// 'proxy-':true, | ||
// 'sec-':true, | ||
// Prefix matching is implemented in code, below. | ||
// 'proxy-': true, | ||
// 'sec-': true, | ||
referer: true, | ||
@@ -72,6 +71,14 @@ te: true, | ||
// src/http-transport.ts | ||
function createHttpTransport({ headers, url }) { | ||
function createHttpTransport(config) { | ||
if (__DEV__ && false) { | ||
warnDispatcherWasSuppliedInNonNodeEnvironment(); | ||
} | ||
const { headers, url } = config; | ||
if (__DEV__ && headers) { | ||
assertIsAllowedHttpRequestHeaders(headers); | ||
} | ||
let dispatcherConfig; | ||
if ("dispatcher_NODE_ONLY" in config) { | ||
dispatcherConfig = { dispatcher: config.dispatcher_NODE_ONLY }; | ||
} | ||
const customHeaders = headers && normalizeHeaders(headers); | ||
@@ -84,2 +91,3 @@ return async function makeHttpRequest({ | ||
const requestInfo = { | ||
...dispatcherConfig, | ||
body, | ||
@@ -96,3 +104,3 @@ headers: { | ||
}; | ||
const response = await e(url, requestInfo); | ||
const response = await fetch(url, requestInfo); | ||
if (!response.ok) { | ||
@@ -99,0 +107,0 @@ throw new SolanaHttpError({ |
@@ -7,3 +7,3 @@ export type AllowedHttpRequestHeaders = Readonly<{ | ||
type DisallowedHeaders = 'Accept' | 'Content-Length' | 'Content-Type' | 'Solana-Client'; | ||
type ForbiddenHeaders = 'Accept-Charset' | 'Accept-Encoding' | 'Access-Control-Request-Headers' | 'Access-Control-Request-Method' | 'Connection' | 'Content-Length' | 'Cookie' | 'Date' | 'DNT' | 'Expect' | 'Host' | 'Keep-Alive' | 'Origin' | 'Permissions-Policy' | 'Referer' | 'TE' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Via'; | ||
type ForbiddenHeaders = 'Accept-Charset' | 'Accept-Encoding' | 'Access-Control-Request-Headers' | 'Access-Control-Request-Method' | 'Connection' | 'Content-Length' | 'Cookie' | 'Date' | 'DNT' | 'Expect' | 'Host' | 'Keep-Alive' | 'Origin' | 'Permissions-Policy' | `Proxy-${string}` | `Sec-${string}` | 'Referer' | 'TE' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Via'; | ||
export declare function assertIsAllowedHttpRequestHeaders(headers: Record<string, string>): asserts headers is AllowedHttpRequestHeaders; | ||
@@ -10,0 +10,0 @@ /** |
import { RpcTransport } from '@solana/rpc-spec'; | ||
import type Dispatcher from 'undici/types/dispatcher'; | ||
import { AllowedHttpRequestHeaders } from './http-transport-headers.js'; | ||
type Config = Readonly<{ | ||
dispatcher_NODE_ONLY?: Dispatcher; | ||
headers?: AllowedHttpRequestHeaders; | ||
url: string; | ||
}>; | ||
export declare function createHttpTransport({ headers, url }: Config): RpcTransport; | ||
export declare function createHttpTransport(config: Config): RpcTransport; | ||
export {}; | ||
//# sourceMappingURL=http-transport.d.ts.map |
{ | ||
"name": "@solana/rpc-transport-http", | ||
"version": "2.0.0-experimental.61f4b59", | ||
"version": "2.0.0-experimental.97527f4", | ||
"description": "An RPC transport that uses HTTP requests", | ||
@@ -49,3 +49,4 @@ "exports": { | ||
"dependencies": { | ||
"@solana/rpc-spec": "2.0.0-experimental.61f4b59" | ||
"undici": "^6.6.2", | ||
"@solana/rpc-spec": "2.0.0-experimental.97527f4" | ||
}, | ||
@@ -52,0 +53,0 @@ "bundlewatch": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77416
713
2
1
+ Addedundici@^6.6.2
+ Added@solana/rpc-spec@2.0.0-experimental.97527f4(transitive)
+ Added@solana/rpc-spec-types@2.0.0-experimental.97527f4(transitive)
+ Addedundici@6.21.0(transitive)
- Removed@solana/rpc-spec@2.0.0-experimental.61f4b59(transitive)
- Removed@solana/rpc-spec-types@2.0.0-experimental.61f4b59(transitive)