@solana/rpc-transport
Advanced tools
Comparing version 2.0.0-experimental.dccb97c to 2.0.0-experimental.f0db543
@@ -1,40 +0,5 @@ | ||
import 'node-fetch'; | ||
// ../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"; | ||
} | ||
}; | ||
// ../fetch-impl-browser/dist/index.browser.js | ||
var { fetch } = globalThis; | ||
var src_default = fetch; | ||
async function makeHttpRequest({ payload, url }) { | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
headers: { | ||
"Content-type": "application/json" | ||
}, | ||
method: "POST" | ||
}; | ||
let response; | ||
{ | ||
response = await src_default(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 { | ||
@@ -52,3 +17,3 @@ constructor(details) { | ||
// src/json-rpc-transport/json-rpc-message-id.ts | ||
// src/json-rpc-message-id.ts | ||
var _nextMessageId = 0; | ||
@@ -61,3 +26,3 @@ function getNextMessageId() { | ||
// src/json-rpc-transport/json-rpc-message.ts | ||
// src/json-rpc-message.ts | ||
function createJsonRpcMessage(method, params) { | ||
@@ -72,11 +37,11 @@ return { | ||
// src/json-rpc-transport/index.ts | ||
function createArmedJsonRpcTransport(transportConfig, pendingRequest) { | ||
// src/json-rpc.ts | ||
function createArmedJsonRpc(rpcConfig, pendingRequest) { | ||
const overrides = { | ||
async send() { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
const response = await makeHttpRequest({ | ||
const response = await rpcConfig.transport({ | ||
payload, | ||
url: transportConfig.url | ||
signal: options?.abortSignal | ||
}); | ||
@@ -90,11 +55,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() { | ||
async sendBatch(options) { | ||
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params)); | ||
const responses = await makeHttpRequest({ | ||
const responses = await rpcConfig.transport({ | ||
payload, | ||
url: transportConfig.url | ||
signal: options?.abortSignal | ||
}); | ||
@@ -112,6 +77,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() { | ||
@@ -129,9 +94,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); | ||
} | ||
@@ -142,8 +107,107 @@ }; | ||
} | ||
function createJsonRpcTransport(transportConfig) { | ||
return makeProxy(transportConfig); | ||
function createJsonRpc(rpcConfig) { | ||
return makeProxy(rpcConfig); | ||
} | ||
export { createJsonRpcTransport }; | ||
// 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; | ||
} | ||
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; | ||
} | ||
// ../fetch-impl/dist/index.browser.js | ||
var e = globalThis.fetch; | ||
// src/transports/http/http-transport.ts | ||
function createHttpTransport({ headers, url }) { | ||
if (__DEV__ && headers) { | ||
assertIsAllowedHttpRequestHeaders(headers); | ||
} | ||
const customHeaders = headers && normalizeHeaders(headers); | ||
return async function makeHttpRequest({ | ||
payload, | ||
signal | ||
}) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
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 |
@@ -1,40 +0,5 @@ | ||
import 'node-fetch'; | ||
// ../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"; | ||
} | ||
}; | ||
// ../fetch-impl-browser/dist/index.browser.js | ||
var { fetch } = globalThis; | ||
var src_default = fetch; | ||
async function makeHttpRequest({ payload, url }) { | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
headers: { | ||
"Content-type": "application/json" | ||
}, | ||
method: "POST" | ||
}; | ||
let response; | ||
{ | ||
response = await src_default(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 { | ||
@@ -52,3 +17,3 @@ constructor(details) { | ||
// src/json-rpc-transport/json-rpc-message-id.ts | ||
// src/json-rpc-message-id.ts | ||
var _nextMessageId = 0; | ||
@@ -61,3 +26,3 @@ function getNextMessageId() { | ||
// src/json-rpc-transport/json-rpc-message.ts | ||
// src/json-rpc-message.ts | ||
function createJsonRpcMessage(method, params) { | ||
@@ -72,11 +37,11 @@ return { | ||
// src/json-rpc-transport/index.ts | ||
function createArmedJsonRpcTransport(transportConfig, pendingRequest) { | ||
// src/json-rpc.ts | ||
function createArmedJsonRpc(rpcConfig, pendingRequest) { | ||
const overrides = { | ||
async send() { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
const response = await makeHttpRequest({ | ||
const response = await rpcConfig.transport({ | ||
payload, | ||
url: transportConfig.url | ||
signal: options?.abortSignal | ||
}); | ||
@@ -90,11 +55,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() { | ||
async sendBatch(options) { | ||
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params)); | ||
const responses = await makeHttpRequest({ | ||
const responses = await rpcConfig.transport({ | ||
payload, | ||
url: transportConfig.url | ||
signal: options?.abortSignal | ||
}); | ||
@@ -112,6 +77,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() { | ||
@@ -129,9 +94,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); | ||
} | ||
@@ -142,8 +107,107 @@ }; | ||
} | ||
function createJsonRpcTransport(transportConfig) { | ||
return makeProxy(transportConfig); | ||
function createJsonRpc(rpcConfig) { | ||
return makeProxy(rpcConfig); | ||
} | ||
export { createJsonRpcTransport }; | ||
// 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; | ||
} | ||
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; | ||
} | ||
// ../fetch-impl/dist/index.browser.js | ||
var e = globalThis.fetch; | ||
// src/transports/http/http-transport.ts | ||
function createHttpTransport({ headers, url }) { | ||
if (__DEV__ && headers) { | ||
assertIsAllowedHttpRequestHeaders(headers); | ||
} | ||
const customHeaders = headers && normalizeHeaders(headers); | ||
return async function makeHttpRequest({ | ||
payload, | ||
signal | ||
}) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
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 |
@@ -1,36 +0,7 @@ | ||
import fetchImplNode from 'node-fetch'; | ||
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"; | ||
} | ||
}; | ||
async function makeHttpRequest({ payload, url }) { | ||
const requestInfo = { | ||
body: JSON.stringify(payload), | ||
headers: { | ||
"Content-type": "application/json" | ||
}, | ||
method: "POST" | ||
}; | ||
let response; | ||
{ | ||
response = await fetchImplNode(url, requestInfo); | ||
} | ||
if (!response.ok) { | ||
throw new SolanaHttpError({ | ||
message: response.statusText, | ||
statusCode: response.status | ||
}); | ||
} | ||
return await response.json(); | ||
} | ||
// ../build-scripts/env-shim.ts | ||
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")(); | ||
// src/json-rpc-transport/json-rpc-errors.ts | ||
// src/json-rpc-errors.ts | ||
var SolanaJsonRpcError = class extends Error { | ||
@@ -48,3 +19,3 @@ constructor(details) { | ||
// src/json-rpc-transport/json-rpc-message-id.ts | ||
// src/json-rpc-message-id.ts | ||
var _nextMessageId = 0; | ||
@@ -57,3 +28,3 @@ function getNextMessageId() { | ||
// src/json-rpc-transport/json-rpc-message.ts | ||
// src/json-rpc-message.ts | ||
function createJsonRpcMessage(method, params) { | ||
@@ -68,11 +39,11 @@ return { | ||
// src/json-rpc-transport/index.ts | ||
function createArmedJsonRpcTransport(transportConfig, pendingRequest) { | ||
// src/json-rpc.ts | ||
function createArmedJsonRpc(rpcConfig, pendingRequest) { | ||
const overrides = { | ||
async send() { | ||
async send(options) { | ||
const { methodName, params, responseProcessor } = pendingRequest; | ||
const payload = createJsonRpcMessage(methodName, params); | ||
const response = await makeHttpRequest({ | ||
const response = await rpcConfig.transport({ | ||
payload, | ||
url: transportConfig.url | ||
signal: options?.abortSignal | ||
}); | ||
@@ -86,11 +57,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() { | ||
async sendBatch(options) { | ||
const payload = pendingRequests.map(({ methodName, params }) => createJsonRpcMessage(methodName, params)); | ||
const responses = await makeHttpRequest({ | ||
const responses = await rpcConfig.transport({ | ||
payload, | ||
url: transportConfig.url | ||
signal: options?.abortSignal | ||
}); | ||
@@ -108,6 +79,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() { | ||
@@ -125,9 +96,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); | ||
} | ||
@@ -138,8 +109,105 @@ }; | ||
} | ||
function createJsonRpcTransport(transportConfig) { | ||
return makeProxy(transportConfig); | ||
function createJsonRpc(rpcConfig) { | ||
return makeProxy(rpcConfig); | ||
} | ||
export { createJsonRpcTransport }; | ||
// 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; | ||
} | ||
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; | ||
// src/transports/http/http-transport.ts | ||
function createHttpTransport({ headers, url }) { | ||
if (__DEV__ && headers) { | ||
assertIsAllowedHttpRequestHeaders(headers); | ||
} | ||
const customHeaders = headers && normalizeHeaders(headers); | ||
return async function makeHttpRequest({ | ||
payload, | ||
signal | ||
}) { | ||
const body = JSON.stringify(payload); | ||
const requestInfo = { | ||
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.dccb97c", | ||
"version": "2.0.0-experimental.f0db543", | ||
"description": "Network transports for accessing the Solana JSON RPC API", | ||
@@ -53,3 +53,2 @@ "exports": { | ||
"@types/jest": "^29.5.0", | ||
"@types/node-fetch": "2", | ||
"@typescript-eslint/eslint-plugin": "^5.57.1", | ||
@@ -64,3 +63,3 @@ "@typescript-eslint/parser": "^5.57.1", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"jest-fetch-mock": "^3.0.3", | ||
"jest-fetch-mock-fork": "^3.0.4", | ||
"jest-runner-eslint": "^2.0.0", | ||
@@ -72,6 +71,6 @@ "jest-runner-prettier": "^1.0.0", | ||
"tsup": "6.7.0", | ||
"turbo": "^1.6.3", | ||
"typescript": "^5.0.3", | ||
"version-from-git": "^1.1.1", | ||
"build-scripts": "0.0.0", | ||
"fetch-impl": "0.0.0", | ||
"test-config": "0.0.0", | ||
@@ -89,5 +88,3 @@ "tsconfig": "0.0.0" | ||
"dependencies": { | ||
"node-fetch": "^2.6.7", | ||
"@solana/keys": "2.0.0-experimental.dccb97c", | ||
"fetch-impl-browser": "0.0.0" | ||
"node-fetch": "^3.3.1" | ||
}, | ||
@@ -94,0 +91,0 @@ "scripts": { |
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
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
152290
1
26
33
1344
0
157
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removedfetch-impl-browser@0.0.0
- Removed@solana/keys@2.0.0-experimental.dccb97c(transitive)
- Removedbase-x@4.0.0(transitive)
- Removedbs58@5.0.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatednode-fetch@^3.3.1