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

@libsql/hrana-client

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libsql/hrana-client - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

6

lib-cjs/http/client.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpClient = exports.checkEndpoints = void 0;
const isomorphic_fetch_1 = require("@libsql/isomorphic-fetch");
const cross_fetch_1 = require("cross-fetch");
const client_js_1 = require("../client.js");

@@ -49,3 +49,3 @@ const errors_js_1 = require("../errors.js");

this.#jwt = jwt;
this.#fetch = customFetch ?? isomorphic_fetch_1.fetch;
this.#fetch = customFetch ?? cross_fetch_1.fetch;
this.#closed = undefined;

@@ -121,3 +121,3 @@ this.#streams = new Set();

const url = new URL(endpoint.versionPath, clientUrl);
const request = new isomorphic_fetch_1.Request(url.toString(), { method: "GET" });
const request = new cross_fetch_1.Request(url.toString(), { method: "GET" });
const response = await fetch(request);

@@ -124,0 +124,0 @@ await response.arrayBuffer();

@@ -58,3 +58,6 @@ "use strict";

}
this.#reader = response.body.getReader();
// node-fetch do not fully support WebStream API, especially getReader() function
// see https://github.com/node-fetch/node-fetch/issues/387
// so, we are using async iterator which behaves similarly here instead
this.#reader = response.body[Symbol.asyncIterator]();
const respBody = await this.#nextItem(json_decode_js_1.CursorRespBody, protobuf_decode_js_1.CursorRespBody);

@@ -82,3 +85,3 @@ if (respBody === undefined) {

if (this.#reader !== undefined) {
this.#reader.cancel();
this.#reader.return();
}

@@ -118,3 +121,3 @@ }

}
const { value, done } = await this.#reader.read();
const { value, done } = await this.#reader.next();
if (done && this.#queue.length === 0) {

@@ -121,0 +124,0 @@ this.#done = true;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpStream = void 0;
const isomorphic_fetch_1 = require("@libsql/isomorphic-fetch");
const cross_fetch_1 = require("cross-fetch");
const errors_js_1 = require("../errors.js");

@@ -303,3 +303,3 @@ const index_js_1 = require("../encoding/index.js");

}
const headers = new isomorphic_fetch_1.Headers();
const headers = new cross_fetch_1.Headers();
headers.set("content-type", contentType);

@@ -309,3 +309,3 @@ if (this.#jwt !== undefined) {

}
return new isomorphic_fetch_1.Request(url.toString(), { method: "POST", headers, body: bodyData });
return new cross_fetch_1.Request(url.toString(), { method: "POST", headers, body: bodyData });
}

@@ -312,0 +312,0 @@ }

@@ -25,6 +25,6 @@ "use strict";

Object.defineProperty(exports, "WebSocket", { enumerable: true, get: function () { return isomorphic_ws_2.WebSocket; } });
var isomorphic_fetch_1 = require("@libsql/isomorphic-fetch");
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return isomorphic_fetch_1.fetch; } });
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return isomorphic_fetch_1.Request; } });
Object.defineProperty(exports, "Headers", { enumerable: true, get: function () { return isomorphic_fetch_1.Headers; } });
var cross_fetch_1 = require("cross-fetch");
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return cross_fetch_1.fetch; } });
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return cross_fetch_1.Request; } });
Object.defineProperty(exports, "Headers", { enumerable: true, get: function () { return cross_fetch_1.Headers; } });
var client_js_4 = require("./client.js");

@@ -72,4 +72,4 @@ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_4.Client; } });

* If the `customFetch` argument is passed and not `undefined`, it is used in place of the `fetch` function
* from `@libsql/isomorphic-fetch`. This function is always called with a `Request` object from
* `@libsql/isomorphic-fetch`.
* from `cross-fetch`. This function is always called with a `Request` object from
* `cross-fetch`.
*/

@@ -76,0 +76,0 @@ function openHttp(url, jwt, customFetch, protocolVersion = 2) {

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

/// <reference types="node" />
import type { ProtocolVersion, ProtocolEncoding } from "../client.js";

@@ -3,0 +2,0 @@ import { Client } from "../client.js";

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

import { fetch, Request } from "@libsql/isomorphic-fetch";
import { fetch, Request } from "cross-fetch";
import { Client } from "../client.js";

@@ -3,0 +3,0 @@ import { ClientError, ClosedError, ProtocolVersionError } from "../errors.js";

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

import type { Response } from "@libsql/isomorphic-fetch";
import type { ProtocolEncoding } from "../client.js";

@@ -3,0 +2,0 @@ import { Cursor } from "../cursor.js";

@@ -32,3 +32,6 @@ import { ByteQueue } from "../byte_queue.js";

}
this.#reader = response.body.getReader();
// node-fetch do not fully support WebStream API, especially getReader() function
// see https://github.com/node-fetch/node-fetch/issues/387
// so, we are using async iterator which behaves similarly here instead
this.#reader = response.body[Symbol.asyncIterator]();
const respBody = await this.#nextItem(json_CursorRespBody, protobuf_CursorRespBody);

@@ -56,3 +59,3 @@ if (respBody === undefined) {

if (this.#reader !== undefined) {
this.#reader.cancel();
this.#reader.return();
}

@@ -92,3 +95,3 @@ }

}
const { value, done } = await this.#reader.read();
const { value, done } = await this.#reader.next();
if (done && this.#queue.length === 0) {

@@ -95,0 +98,0 @@ this.#done = true;

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

/// <reference types="node" />
import type { fetch } from "@libsql/isomorphic-fetch";
import type { fetch } from "cross-fetch";
import type { SqlOwner, ProtoSql } from "../sql.js";

@@ -4,0 +3,0 @@ import { Sql } from "../sql.js";

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

import { Request, Headers } from "@libsql/isomorphic-fetch";
import { Request, Headers } from "cross-fetch";
import { ClientError, HttpServerError, ProtocolVersionError, ProtoError, ClosedError, InternalError, } from "../errors.js";

@@ -3,0 +3,0 @@ import { readJsonObject, writeJsonObject, readProtobufMessage, writeProtobufMessage, } from "../encoding/index.js";

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

/// <reference types="node" />
import { HttpClient } from "./http/client.js";

@@ -6,4 +5,4 @@ import { WsClient } from "./ws/client.js";

export { WebSocket } from "@libsql/isomorphic-ws";
export type { RequestInit, Response } from "@libsql/isomorphic-fetch";
export { fetch, Request, Headers } from "@libsql/isomorphic-fetch";
export type { Response } from "cross-fetch";
export { fetch, Request, Headers } from "cross-fetch";
export type { ProtocolVersion, ProtocolEncoding } from "./client.js";

@@ -32,5 +31,5 @@ export { Client } from "./client.js";

* If the `customFetch` argument is passed and not `undefined`, it is used in place of the `fetch` function
* from `@libsql/isomorphic-fetch`. This function is always called with a `Request` object from
* `@libsql/isomorphic-fetch`.
* from `cross-fetch`. This function is always called with a `Request` object from
* `cross-fetch`.
*/
export declare function openHttp(url: string | URL, jwt?: string, customFetch?: unknown | undefined, protocolVersion?: ProtocolVersion): HttpClient;

@@ -7,3 +7,3 @@ import { WebSocket } from "@libsql/isomorphic-ws";

export { WebSocket } from "@libsql/isomorphic-ws";
export { fetch, Request, Headers } from "@libsql/isomorphic-fetch";
export { fetch, Request, Headers } from "cross-fetch";
export { Client } from "./client.js";

@@ -38,4 +38,4 @@ export * from "./errors.js";

* If the `customFetch` argument is passed and not `undefined`, it is used in place of the `fetch` function
* from `@libsql/isomorphic-fetch`. This function is always called with a `Request` object from
* `@libsql/isomorphic-fetch`.
* from `cross-fetch`. This function is always called with a `Request` object from
* `cross-fetch`.
*/

@@ -42,0 +42,0 @@ export function openHttp(url, jwt, customFetch, protocolVersion = 2) {

{
"name": "@libsql/hrana-client",
"version": "0.7.0",
"version": "0.8.0",
"keywords": [

@@ -48,4 +48,4 @@ "hrana",

"dependencies": {
"@libsql/isomorphic-fetch": "^0.3.1",
"@libsql/isomorphic-ws": "^0.1.5",
"cross-fetch": "^4.0.0",
"js-base64": "^3.7.5",

@@ -52,0 +52,0 @@ "node-fetch": "^3.3.2"

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