Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/rpc-transport

Package Overview
Dependencies
Maintainers
13
Versions
602
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-transport - npm Package Compare versions

Comparing version 2.0.0-experimental.92a60c3 to 2.0.0-experimental.982fafd

dist/types/json-rpc-errors.d.ts

243

dist/index.browser.js
// ../build-scripts/env-shim.ts
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/http-request-errors.ts
var SolanaHttpError = class extends Error {
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
get name() {
return "SolanaHttpError";
}
};
// src/http-request-headers.ts
var DISALLOWED_HEADERS = {
accept: true,
"content-length": true,
"content-type": true
};
var FORBIDDEN_HEADERS = {
"accept-charset": true,
"accept-encoding": true,
"access-control-request-headers": true,
"access-control-request-method": true,
connection: true,
"content-length": true,
cookie: true,
date: true,
dnt: true,
expect: true,
host: true,
"keep-alive": true,
origin: true,
"permissions-policy": true,
// No currently available Typescript technique allows you to match on a prefix.
// 'proxy-':true,
// 'sec-':true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
via: true
};
function assertIsAllowedHttpRequestHeaders(headers) {
const badHeaders = Object.keys(headers).filter((headerName) => {
const lowercaseHeaderName = headerName.toLowerCase();
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
});
if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
}
}
function normalizeHeaders(headers) {
const out = {};
for (const headerName in headers) {
out[headerName.toLowerCase()] = headers[headerName];
}
return out;
}
// ../fetch-impl/dist/index.browser.js
var e = globalThis.fetch;
// src/http-request.ts
async function makeHttpRequest({ headers, payload, signal, url }) {
const body = JSON.stringify(payload);
const requestInfo = {
body,
headers: {
...headers && normalizeHeaders(headers),
// Keep these headers lowercase so they will override any user-supplied headers above.
accept: "application/json",
"content-length": body.length.toString(),
"content-type": "application/json; charset=utf-8"
},
method: "POST",
signal
};
const response = await e(url, requestInfo);
if (!response.ok) {
throw new SolanaHttpError({
message: response.statusText,
statusCode: response.status
});
}
return await response.json();
}
// src/json-rpc-transport/json-rpc-errors.ts
// src/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {

@@ -107,3 +17,3 @@ constructor(details) {

// src/json-rpc-transport/json-rpc-message-id.ts
// src/json-rpc-message-id.ts
var _nextMessageId = 0;

@@ -116,3 +26,3 @@ function getNextMessageId() {

// src/json-rpc-transport/json-rpc-message.ts
// src/json-rpc-message.ts
function createJsonRpcMessage(method, params) {

@@ -127,4 +37,4 @@ return {

// src/json-rpc-transport/index.ts
function createArmedJsonRpcTransport(transportConfig, pendingRequest) {
// src/json-rpc.ts
function createArmedJsonRpc(rpcConfig, pendingRequest) {
const overrides = {

@@ -134,7 +44,5 @@ async send(options) {

const payload = createJsonRpcMessage(methodName, params);
const response = await makeHttpRequest({
headers: transportConfig.headers,
const response = await rpcConfig.transport({
payload,
signal: options?.abortSignal,
url: transportConfig.url
signal: options?.abortSignal
});

@@ -148,13 +56,11 @@ if ("error" in response) {

};
return makeProxy(transportConfig, overrides, pendingRequest);
return makeProxy(rpcConfig, overrides, pendingRequest);
}
function createArmedBatchJsonRpcTransport(transportConfig, pendingRequests) {
function createArmedBatchJsonRpc(rpcConfig, pendingRequests) {
const overrides = {
async sendBatch(options) {
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params));
const responses = await makeHttpRequest({
headers: transportConfig.headers,
const responses = await rpcConfig.transport({
payload,
signal: options?.abortSignal,
url: transportConfig.url
signal: options?.abortSignal
});

@@ -172,6 +78,6 @@ const requestOrder = payload.map((p) => p.id);

};
return makeProxy(transportConfig, overrides, pendingRequests);
return makeProxy(rpcConfig, overrides, pendingRequests);
}
function makeProxy(transportConfig, overrides, pendingRequestOrRequests) {
return new Proxy(transportConfig.api, {
function makeProxy(rpcConfig, overrides, pendingRequestOrRequests) {
return new Proxy(rpcConfig.api, {
defineProperty() {

@@ -189,9 +95,9 @@ return false;

const methodName = p.toString();
const createTransportRequest = Reflect.get(target, methodName, receiver);
const newRequest = createTransportRequest ? createTransportRequest(...rawParams) : { methodName, params: rawParams };
const createRpcRequest = Reflect.get(target, methodName, receiver);
const newRequest = createRpcRequest ? createRpcRequest(...rawParams) : { methodName, params: rawParams };
if (pendingRequestOrRequests == null) {
return createArmedJsonRpcTransport(transportConfig, newRequest);
return createArmedJsonRpc(rpcConfig, newRequest);
} else {
const nextPendingRequests = Array.isArray(pendingRequestOrRequests) ? [...pendingRequestOrRequests, newRequest] : [pendingRequestOrRequests, newRequest];
return createArmedBatchJsonRpcTransport(transportConfig, nextPendingRequests);
return createArmedBatchJsonRpc(rpcConfig, nextPendingRequests);
}

@@ -202,11 +108,114 @@ };

}
function createJsonRpcTransport(transportConfig) {
if (__DEV__ && transportConfig.headers) {
assertIsAllowedHttpRequestHeaders(transportConfig.headers);
function createJsonRpc(rpcConfig) {
return makeProxy(rpcConfig);
}
// src/transports/http/http-transport-errors.ts
var SolanaHttpError = class extends Error {
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
return makeProxy(transportConfig);
get name() {
return "SolanaHttpError";
}
};
// src/transports/http/http-transport-headers.ts
var DISALLOWED_HEADERS = {
accept: true,
"content-length": true,
"content-type": true
};
var FORBIDDEN_HEADERS = {
"accept-charset": true,
"accept-encoding": true,
"access-control-request-headers": true,
"access-control-request-method": true,
connection: true,
"content-length": true,
cookie: true,
date: true,
dnt: true,
expect: true,
host: true,
"keep-alive": true,
origin: true,
"permissions-policy": true,
// No currently available Typescript technique allows you to match on a prefix.
// 'proxy-':true,
// 'sec-':true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
via: true
};
function assertIsAllowedHttpRequestHeaders(headers) {
const badHeaders = Object.keys(headers).filter((headerName) => {
const lowercaseHeaderName = headerName.toLowerCase();
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
});
if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
}
}
function normalizeHeaders(headers) {
const out = {};
for (const headerName in headers) {
out[headerName.toLowerCase()] = headers[headerName];
}
return out;
}
export { createJsonRpcTransport };
// ../fetch-impl/dist/index.browser.js
var e = globalThis.fetch;
// src/transports/http/http-transport.ts
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
if (__DEV__ && headers) {
assertIsAllowedHttpRequestHeaders(headers);
}
const agent = void 0;
if (__DEV__ && httpAgentNodeOnly != null) {
console.warn(
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
);
}
const customHeaders = headers && normalizeHeaders(headers);
return async function makeHttpRequest({
payload,
signal
}) {
const body = JSON.stringify(payload);
const requestInfo = {
agent,
body,
headers: {
...customHeaders,
// Keep these headers lowercase so they will override any user-supplied headers above.
accept: "application/json",
"content-length": body.length.toString(),
"content-type": "application/json; charset=utf-8"
},
method: "POST",
signal
};
const response = await e(url, requestInfo);
if (!response.ok) {
throw new SolanaHttpError({
message: response.statusText,
statusCode: response.status
});
}
return await response.json();
};
}
export { createHttpTransport, createJsonRpc };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map
// ../build-scripts/env-shim.ts
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/http-request-errors.ts
var SolanaHttpError = class extends Error {
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
get name() {
return "SolanaHttpError";
}
};
// src/http-request-headers.ts
var DISALLOWED_HEADERS = {
accept: true,
"content-length": true,
"content-type": true
};
var FORBIDDEN_HEADERS = {
"accept-charset": true,
"accept-encoding": true,
"access-control-request-headers": true,
"access-control-request-method": true,
connection: true,
"content-length": true,
cookie: true,
date: true,
dnt: true,
expect: true,
host: true,
"keep-alive": true,
origin: true,
"permissions-policy": true,
// No currently available Typescript technique allows you to match on a prefix.
// 'proxy-':true,
// 'sec-':true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
via: true
};
function assertIsAllowedHttpRequestHeaders(headers) {
const badHeaders = Object.keys(headers).filter((headerName) => {
const lowercaseHeaderName = headerName.toLowerCase();
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
});
if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
}
}
function normalizeHeaders(headers) {
const out = {};
for (const headerName in headers) {
out[headerName.toLowerCase()] = headers[headerName];
}
return out;
}
// ../fetch-impl/dist/index.browser.js
var e = globalThis.fetch;
// src/http-request.ts
async function makeHttpRequest({ headers, payload, signal, url }) {
const body = JSON.stringify(payload);
const requestInfo = {
body,
headers: {
...headers && normalizeHeaders(headers),
// Keep these headers lowercase so they will override any user-supplied headers above.
accept: "application/json",
"content-length": body.length.toString(),
"content-type": "application/json; charset=utf-8"
},
method: "POST",
signal
};
const response = await e(url, requestInfo);
if (!response.ok) {
throw new SolanaHttpError({
message: response.statusText,
statusCode: response.status
});
}
return await response.json();
}
// src/json-rpc-transport/json-rpc-errors.ts
// src/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {

@@ -107,3 +17,3 @@ constructor(details) {

// src/json-rpc-transport/json-rpc-message-id.ts
// src/json-rpc-message-id.ts
var _nextMessageId = 0;

@@ -116,3 +26,3 @@ function getNextMessageId() {

// src/json-rpc-transport/json-rpc-message.ts
// src/json-rpc-message.ts
function createJsonRpcMessage(method, params) {

@@ -127,4 +37,4 @@ return {

// src/json-rpc-transport/index.ts
function createArmedJsonRpcTransport(transportConfig, pendingRequest) {
// src/json-rpc.ts
function createArmedJsonRpc(rpcConfig, pendingRequest) {
const overrides = {

@@ -134,7 +44,5 @@ async send(options) {

const payload = createJsonRpcMessage(methodName, params);
const response = await makeHttpRequest({
headers: transportConfig.headers,
const response = await rpcConfig.transport({
payload,
signal: options?.abortSignal,
url: transportConfig.url
signal: options?.abortSignal
});

@@ -148,13 +56,11 @@ if ("error" in response) {

};
return makeProxy(transportConfig, overrides, pendingRequest);
return makeProxy(rpcConfig, overrides, pendingRequest);
}
function createArmedBatchJsonRpcTransport(transportConfig, pendingRequests) {
function createArmedBatchJsonRpc(rpcConfig, pendingRequests) {
const overrides = {
async sendBatch(options) {
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params));
const responses = await makeHttpRequest({
headers: transportConfig.headers,
const responses = await rpcConfig.transport({
payload,
signal: options?.abortSignal,
url: transportConfig.url
signal: options?.abortSignal
});

@@ -172,6 +78,6 @@ const requestOrder = payload.map((p) => p.id);

};
return makeProxy(transportConfig, overrides, pendingRequests);
return makeProxy(rpcConfig, overrides, pendingRequests);
}
function makeProxy(transportConfig, overrides, pendingRequestOrRequests) {
return new Proxy(transportConfig.api, {
function makeProxy(rpcConfig, overrides, pendingRequestOrRequests) {
return new Proxy(rpcConfig.api, {
defineProperty() {

@@ -189,9 +95,9 @@ return false;

const methodName = p.toString();
const createTransportRequest = Reflect.get(target, methodName, receiver);
const newRequest = createTransportRequest ? createTransportRequest(...rawParams) : { methodName, params: rawParams };
const createRpcRequest = Reflect.get(target, methodName, receiver);
const newRequest = createRpcRequest ? createRpcRequest(...rawParams) : { methodName, params: rawParams };
if (pendingRequestOrRequests == null) {
return createArmedJsonRpcTransport(transportConfig, newRequest);
return createArmedJsonRpc(rpcConfig, newRequest);
} else {
const nextPendingRequests = Array.isArray(pendingRequestOrRequests) ? [...pendingRequestOrRequests, newRequest] : [pendingRequestOrRequests, newRequest];
return createArmedBatchJsonRpcTransport(transportConfig, nextPendingRequests);
return createArmedBatchJsonRpc(rpcConfig, nextPendingRequests);
}

@@ -202,11 +108,114 @@ };

}
function createJsonRpcTransport(transportConfig) {
if (__DEV__ && transportConfig.headers) {
assertIsAllowedHttpRequestHeaders(transportConfig.headers);
function createJsonRpc(rpcConfig) {
return makeProxy(rpcConfig);
}
// src/transports/http/http-transport-errors.ts
var SolanaHttpError = class extends Error {
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
return makeProxy(transportConfig);
get name() {
return "SolanaHttpError";
}
};
// src/transports/http/http-transport-headers.ts
var DISALLOWED_HEADERS = {
accept: true,
"content-length": true,
"content-type": true
};
var FORBIDDEN_HEADERS = {
"accept-charset": true,
"accept-encoding": true,
"access-control-request-headers": true,
"access-control-request-method": true,
connection: true,
"content-length": true,
cookie: true,
date: true,
dnt: true,
expect: true,
host: true,
"keep-alive": true,
origin: true,
"permissions-policy": true,
// No currently available Typescript technique allows you to match on a prefix.
// 'proxy-':true,
// 'sec-':true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
via: true
};
function assertIsAllowedHttpRequestHeaders(headers) {
const badHeaders = Object.keys(headers).filter((headerName) => {
const lowercaseHeaderName = headerName.toLowerCase();
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
});
if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
}
}
function normalizeHeaders(headers) {
const out = {};
for (const headerName in headers) {
out[headerName.toLowerCase()] = headers[headerName];
}
return out;
}
export { createJsonRpcTransport };
// ../fetch-impl/dist/index.browser.js
var e = globalThis.fetch;
// src/transports/http/http-transport.ts
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
if (__DEV__ && headers) {
assertIsAllowedHttpRequestHeaders(headers);
}
const agent = void 0;
if (__DEV__ && httpAgentNodeOnly != null) {
console.warn(
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
);
}
const customHeaders = headers && normalizeHeaders(headers);
return async function makeHttpRequest({
payload,
signal
}) {
const body = JSON.stringify(payload);
const requestInfo = {
agent,
body,
headers: {
...customHeaders,
// Keep these headers lowercase so they will override any user-supplied headers above.
accept: "application/json",
"content-length": body.length.toString(),
"content-type": "application/json; charset=utf-8"
},
method: "POST",
signal
};
const response = await e(url, requestInfo);
if (!response.ok) {
throw new SolanaHttpError({
message: response.statusText,
statusCode: response.status
});
}
return await response.json();
};
}
export { createHttpTransport, createJsonRpc };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -6,91 +6,3 @@ import t from 'node-fetch';

// src/http-request-errors.ts
var SolanaHttpError = class extends Error {
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
get name() {
return "SolanaHttpError";
}
};
// src/http-request-headers.ts
var DISALLOWED_HEADERS = {
accept: true,
"content-length": true,
"content-type": true
};
var FORBIDDEN_HEADERS = {
"accept-charset": true,
"accept-encoding": true,
"access-control-request-headers": true,
"access-control-request-method": true,
connection: true,
"content-length": true,
cookie: true,
date: true,
dnt: true,
expect: true,
host: true,
"keep-alive": true,
origin: true,
"permissions-policy": true,
// No currently available Typescript technique allows you to match on a prefix.
// 'proxy-':true,
// 'sec-':true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
via: true
};
function assertIsAllowedHttpRequestHeaders(headers) {
const badHeaders = Object.keys(headers).filter((headerName) => {
const lowercaseHeaderName = headerName.toLowerCase();
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
});
if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
}
}
function normalizeHeaders(headers) {
const out = {};
for (const headerName in headers) {
out[headerName.toLowerCase()] = headers[headerName];
}
return out;
}
var f = t;
// src/http-request.ts
async function makeHttpRequest({ headers, payload, signal, url }) {
const body = JSON.stringify(payload);
const requestInfo = {
body,
headers: {
...headers && normalizeHeaders(headers),
// Keep these headers lowercase so they will override any user-supplied headers above.
accept: "application/json",
"content-length": body.length.toString(),
"content-type": "application/json; charset=utf-8"
},
method: "POST",
signal
};
const response = await f(url, requestInfo);
if (!response.ok) {
throw new SolanaHttpError({
message: response.statusText,
statusCode: response.status
});
}
return await response.json();
}
// src/json-rpc-transport/json-rpc-errors.ts
// src/json-rpc-errors.ts
var SolanaJsonRpcError = class extends Error {

@@ -108,3 +20,3 @@ constructor(details) {

// src/json-rpc-transport/json-rpc-message-id.ts
// src/json-rpc-message-id.ts
var _nextMessageId = 0;

@@ -117,3 +29,3 @@ function getNextMessageId() {

// src/json-rpc-transport/json-rpc-message.ts
// src/json-rpc-message.ts
function createJsonRpcMessage(method, params) {

@@ -128,4 +40,4 @@ return {

// src/json-rpc-transport/index.ts
function createArmedJsonRpcTransport(transportConfig, pendingRequest) {
// src/json-rpc.ts
function createArmedJsonRpc(rpcConfig, pendingRequest) {
const overrides = {

@@ -135,7 +47,5 @@ async send(options) {

const payload = createJsonRpcMessage(methodName, params);
const response = await makeHttpRequest({
headers: transportConfig.headers,
const response = await rpcConfig.transport({
payload,
signal: options?.abortSignal,
url: transportConfig.url
signal: options?.abortSignal
});

@@ -149,13 +59,11 @@ if ("error" in response) {

};
return makeProxy(transportConfig, overrides, pendingRequest);
return makeProxy(rpcConfig, overrides, pendingRequest);
}
function createArmedBatchJsonRpcTransport(transportConfig, pendingRequests) {
function createArmedBatchJsonRpc(rpcConfig, pendingRequests) {
const overrides = {
async sendBatch(options) {
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params));
const responses = await makeHttpRequest({
headers: transportConfig.headers,
const responses = await rpcConfig.transport({
payload,
signal: options?.abortSignal,
url: transportConfig.url
signal: options?.abortSignal
});

@@ -173,6 +81,6 @@ const requestOrder = payload.map((p) => p.id);

};
return makeProxy(transportConfig, overrides, pendingRequests);
return makeProxy(rpcConfig, overrides, pendingRequests);
}
function makeProxy(transportConfig, overrides, pendingRequestOrRequests) {
return new Proxy(transportConfig.api, {
function makeProxy(rpcConfig, overrides, pendingRequestOrRequests) {
return new Proxy(rpcConfig.api, {
defineProperty() {

@@ -190,9 +98,9 @@ return false;

const methodName = p.toString();
const createTransportRequest = Reflect.get(target, methodName, receiver);
const newRequest = createTransportRequest ? createTransportRequest(...rawParams) : { methodName, params: rawParams };
const createRpcRequest = Reflect.get(target, methodName, receiver);
const newRequest = createRpcRequest ? createRpcRequest(...rawParams) : { methodName, params: rawParams };
if (pendingRequestOrRequests == null) {
return createArmedJsonRpcTransport(transportConfig, newRequest);
return createArmedJsonRpc(rpcConfig, newRequest);
} else {
const nextPendingRequests = Array.isArray(pendingRequestOrRequests) ? [...pendingRequestOrRequests, newRequest] : [pendingRequestOrRequests, newRequest];
return createArmedBatchJsonRpcTransport(transportConfig, nextPendingRequests);
return createArmedBatchJsonRpc(rpcConfig, nextPendingRequests);
}

@@ -203,11 +111,112 @@ };

}
function createJsonRpcTransport(transportConfig) {
if (__DEV__ && transportConfig.headers) {
assertIsAllowedHttpRequestHeaders(transportConfig.headers);
function createJsonRpc(rpcConfig) {
return makeProxy(rpcConfig);
}
// src/transports/http/http-transport-errors.ts
var SolanaHttpError = class extends Error {
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
return makeProxy(transportConfig);
get name() {
return "SolanaHttpError";
}
};
// src/transports/http/http-transport-headers.ts
var DISALLOWED_HEADERS = {
accept: true,
"content-length": true,
"content-type": true
};
var FORBIDDEN_HEADERS = {
"accept-charset": true,
"accept-encoding": true,
"access-control-request-headers": true,
"access-control-request-method": true,
connection: true,
"content-length": true,
cookie: true,
date: true,
dnt: true,
expect: true,
host: true,
"keep-alive": true,
origin: true,
"permissions-policy": true,
// No currently available Typescript technique allows you to match on a prefix.
// 'proxy-':true,
// 'sec-':true,
referer: true,
te: true,
trailer: true,
"transfer-encoding": true,
upgrade: true,
via: true
};
function assertIsAllowedHttpRequestHeaders(headers) {
const badHeaders = Object.keys(headers).filter((headerName) => {
const lowercaseHeaderName = headerName.toLowerCase();
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
});
if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
}
}
function normalizeHeaders(headers) {
const out = {};
for (const headerName in headers) {
out[headerName.toLowerCase()] = headers[headerName];
}
return out;
}
var f = t;
export { createJsonRpcTransport };
// src/transports/http/http-transport.ts
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
if (__DEV__ && headers) {
assertIsAllowedHttpRequestHeaders(headers);
}
const agent = httpAgentNodeOnly ;
if (__DEV__ && httpAgentNodeOnly != null) {
console.warn(
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
);
}
const customHeaders = headers && normalizeHeaders(headers);
return async function makeHttpRequest({
payload,
signal
}) {
const body = JSON.stringify(payload);
const requestInfo = {
agent,
body,
headers: {
...customHeaders,
// Keep these headers lowercase so they will override any user-supplied headers above.
accept: "application/json",
"content-length": body.length.toString(),
"content-type": "application/json; charset=utf-8"
},
method: "POST",
signal
};
const response = await f(url, requestInfo);
if (!response.ok) {
throw new SolanaHttpError({
message: response.statusText,
statusCode: response.status
});
}
return await response.json();
};
}
export { createHttpTransport, createJsonRpc };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

@@ -1,2 +0,3 @@

export * from './json-rpc-transport';
export * from './json-rpc';
export * from './transports/http/http-transport';
//# sourceMappingURL=index.d.ts.map
{
"name": "@solana/rpc-transport",
"version": "2.0.0-experimental.92a60c3",
"version": "2.0.0-experimental.982fafd",
"description": "Network transports for accessing the Solana JSON RPC API",

@@ -5,0 +5,0 @@ "exports": {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc