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

@es-git/http-transport

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@es-git/http-transport - npm Package Compare versions

Comparing version 0.4.4 to 0.5.0

es/parsePackResponse.d.ts

2

es/composePushRequest.js
import pktLine from './pkt-line';
export default function* composePushRequest(packfile, commands) {
const [command, ...remainingCommands] = commands;
yield pktLine(encodeCommand(command) + '\0 report-status side-band-64k agent=es-git');
yield pktLine(encodeCommand(command) + '\0report-status side-band-64k agent=es-git');
for (const command of remainingCommands) {

@@ -6,0 +6,0 @@ yield pktLine(encodeCommand(command));

import { Ref, Hash } from './types';
import { Fetch as LsRemoteFetch } from './lsRemote';
import { Fetch as FetchPackFetch } from './post';
import { RawObject } from '@es-git/packfile';
import { RawObject, Progress } from '@es-git/packfile';
export declare type Fetch = LsRemoteFetch & FetchPackFetch;

@@ -28,2 +28,2 @@ export { RawObject };

}
export default function fetch({url, fetch, localRefs, refspec, hasObject, depth, shallows, unshallow}: FetchRequest, progress?: (message: string) => void): Promise<FetchResult>;
export default function fetch({url, fetch, localRefs, refspec, hasObject, depth, shallows, unshallow}: FetchRequest, progress?: Progress): Promise<FetchResult>;

@@ -29,3 +29,3 @@ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }

import post from './post';
import parseWantResponse from './parseWantResponse';
import parsePackResponse from './parsePackResponse';
import { unpack } from '@es-git/packfile';

@@ -70,3 +70,3 @@ import remotesToLocals from './remotesToLocals';

try {
for (var _a = __asyncValues(parseWantResponse(response)), _b; _b = yield __await(_a.next()), !_b.done;) {
for (var _a = __asyncValues(parsePackResponse(response)), _b; _b = yield __await(_a.next()), !_b.done;) {
const parsed = yield __await(_b.value);

@@ -90,2 +90,6 @@ switch (parsed.type) {

break;
case 'error':
if (progress)
progress(parsed.message);
break;
}

@@ -92,0 +96,0 @@ }

export { default as fetch, Fetch, RawObject, FetchRequest, FetchResult, RefChange } from './fetch';
export { default as lsRemote, Result } from './lsRemote';
export { default as lsRemote, Result, Ref } from './lsRemote';
export { default as push, Command, Auth } from './push';
export { Progress } from '@es-git/packfile';
import { Ref } from './types';
export { Ref };
export interface Result {

@@ -3,0 +4,0 @@ readonly capabilities: Map<string, string | boolean>;

@@ -5,3 +5,3 @@ import parseRefsResponse from './parseRefsResponse';

if (res.status !== 200)
throw new Error(`ls-remote failed with ${res.status} ${res.statusText}`);
throw new Error(`ls-remote failed with ${res.status} ${res.statusText}\n${await res.text()}`);
const refs = await res.text();

@@ -8,0 +8,0 @@ const capabilities = new Map();

@@ -0,4 +1,5 @@

import { Progress } from '@es-git/packfile';
import { Command } from './composePushRequest';
import { Fetch, Auth } from './post';
export { Command, Auth };
export default function push(url: string, fetch: Fetch, commands: Command[], objects: Map<string, Uint8Array>, auth?: Auth): AsyncIterableIterator<string>;
export default function push(url: string, fetch: Fetch, commands: Command[], objects: Map<string, Uint8Array>, auth?: Auth, progress?: Progress): Promise<void>;

@@ -6,38 +6,44 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {

};
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
};
import { decode } from '@es-git/core';
import { pack } from '@es-git/packfile';
import composePushRequest from './composePushRequest';
import post from './post';
export default function push(url, fetch, commands, objects, auth) {
return __asyncGenerator(this, arguments, function* push_1() {
const packfile = pack(objects.entries());
const body = composePushRequest(packfile, commands);
try {
for (var _a = __asyncValues(post(url, 'git-receive-pack', body, fetch, auth)), _b; _b = yield __await(_a.next()), !_b.done;) {
const result = yield __await(_b.value);
yield decode(result);
import parsePackResponse from './parsePackResponse';
export default async function push(url, fetch, commands, objects, auth, progress) {
//Delta compression isn't implemented yet
if (progress)
progress('Delta compression using up to 0 therads.\n');
const packfile = pack(objects.entries());
const size = (packfile.length / 1024) | 0;
if (progress)
progress(`Compressing objects: 100% ${size}/${size}, done.\n`);
const body = composePushRequest(packfile, commands);
if (progress)
progress(`Writing objects: 100% ${size}/${size}, ${size}KiB, done.\n`);
const response = post(url, 'git-receive-pack', body, fetch, auth);
try {
for (var _a = __asyncValues(parsePackResponse(response)), _b; _b = await _a.next(), !_b.done;) {
const parsed = await _b.value;
switch (parsed.type) {
case 'progress':
if (progress)
progress(parsed.message);
break;
case 'error':
if (progress)
progress(parsed.message);
break;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_b && !_b.done && (_c = _a.return)) yield __await(_c.call(_a));
}
finally { if (e_1) throw e_1.error; }
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_b && !_b.done && (_c = _a.return)) await _c.call(_a);
}
var e_1, _c;
});
finally { if (e_1) throw e_1.error; }
}
if (progress)
progress(`Total ${size} (delta 0), reused 0 (delta 0)\n`);
var e_1, _c;
}
//# sourceMappingURL=push.js.map

@@ -39,3 +39,3 @@ 'use strict';

_context.next = 3;
return (0, _pktLine2.default)(encodeCommand(command) + '\0 report-status side-band-64k agent=es-git');
return (0, _pktLine2.default)(encodeCommand(command) + '\0report-status side-band-64k agent=es-git');

@@ -42,0 +42,0 @@ case 3:

@@ -59,5 +59,5 @@ "use strict";

var _parseWantResponse = require("./parseWantResponse");
var _parsePackResponse = require("./parsePackResponse");
var _parseWantResponse2 = _interopRequireDefault(_parseWantResponse);
var _parsePackResponse2 = _interopRequireDefault(_parsePackResponse);

@@ -250,3 +250,3 @@ var _packfile = require("@es-git/packfile");

_context3.prev = 2;
_a = __asyncValues((0, _parseWantResponse2.default)(response));
_a = __asyncValues((0, _parsePackResponse2.default)(response));

@@ -261,3 +261,3 @@ case 4:

if (_b.done) {
_context3.next = 29;
_context3.next = 31;
break;

@@ -272,3 +272,3 @@ }

_context3.t0 = parsed.type;
_context3.next = _context3.t0 === 'shallow' ? 14 : _context3.t0 === 'unshallow' ? 16 : _context3.t0 === 'ack' ? 18 : _context3.t0 === 'nak' ? 18 : _context3.t0 === 'pack' ? 19 : _context3.t0 === 'progress' ? 25 : 27;
_context3.next = _context3.t0 === 'shallow' ? 14 : _context3.t0 === 'unshallow' ? 16 : _context3.t0 === 'ack' ? 18 : _context3.t0 === 'nak' ? 18 : _context3.t0 === 'pack' ? 19 : _context3.t0 === 'progress' ? 25 : _context3.t0 === 'error' ? 27 : 29;
break;

@@ -278,10 +278,10 @@

shallow.push(parsed.hash);
return _context3.abrupt("break", 27);
return _context3.abrupt("break", 29);
case 16:
unshallow.push(parsed.hash);
return _context3.abrupt("break", 27);
return _context3.abrupt("break", 29);
case 18:
return _context3.abrupt("break", 27);
return _context3.abrupt("break", 29);

@@ -298,38 +298,42 @@ case 19:

case 24:
return _context3.abrupt("break", 27);
return _context3.abrupt("break", 29);
case 25:
if (progress) progress(parsed.message);
return _context3.abrupt("break", 27);
return _context3.abrupt("break", 29);
case 27:
if (progress) progress(parsed.message);
return _context3.abrupt("break", 29);
case 29:
_context3.next = 4;
break;
case 29:
_context3.next = 34;
case 31:
_context3.next = 36;
break;
case 31:
_context3.prev = 31;
case 33:
_context3.prev = 33;
_context3.t4 = _context3["catch"](2);
e_1 = { error: _context3.t4 };
case 34:
_context3.prev = 34;
_context3.prev = 35;
case 36:
_context3.prev = 36;
_context3.prev = 37;
if (!(_b && !_b.done && (_c = _a.return))) {
_context3.next = 39;
_context3.next = 41;
break;
}
_context3.next = 39;
_context3.next = 41;
return __await(_c.call(_a));
case 39:
_context3.prev = 39;
case 41:
_context3.prev = 41;
if (!e_1) {
_context3.next = 42;
_context3.next = 44;
break;

@@ -340,13 +344,13 @@ }

case 42:
return _context3.finish(39);
case 44:
return _context3.finish(41);
case 43:
return _context3.finish(34);
case 45:
return _context3.finish(36);
case 44:
case 46:
resolveShallow(shallow);
resolveUnshallow(unshallow);
case 46:
case 48:
case "end":

@@ -356,3 +360,3 @@ return _context3.stop();

}
}, createResult_1, this, [[2, 31, 34, 44], [35,, 39, 43]]);
}, createResult_1, this, [[2, 33, 36, 46], [37,, 41, 45]]);
}));

@@ -359,0 +363,0 @@ }

@@ -50,13 +50,23 @@ 'use strict';

if (!(res.status !== 200)) {
_context.next = 5;
_context.next = 13;
break;
}
throw new Error('ls-remote failed with ' + String(res.status) + ' ' + String(res.statusText));
_context.t0 = Error;
_context.t1 = 'ls-remote failed with ' + String(res.status) + ' ' + String(res.statusText) + '\n';
_context.t2 = String;
_context.next = 9;
return res.text();
case 5:
_context.next = 7;
case 9:
_context.t3 = _context.sent;
_context.t4 = (0, _context.t2)(_context.t3);
_context.t5 = _context.t1 + _context.t4;
throw new _context.t0(_context.t5);
case 13:
_context.next = 15;
return res.text();
case 7:
case 15:
refs = _context.sent;

@@ -70,3 +80,3 @@ capabilities = new _map2.default();

case 11:
case 19:
case 'end':

@@ -73,0 +83,0 @@ return _context.stop();

@@ -11,6 +11,10 @@ "use strict";

var _promise = require("babel-runtime/core-js/promise");
var _newArrowCheck2 = require("babel-runtime/helpers/newArrowCheck");
var _promise2 = _interopRequireDefault(_promise);
var _newArrowCheck3 = _interopRequireDefault(_newArrowCheck2);
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");

@@ -24,6 +28,2 @@

exports.default = push;
var _core = require("@es-git/core");
var _packfile = require("@es-git/packfile");

@@ -39,2 +39,6 @@

var _parsePackResponse = require("./parsePackResponse");
var _parsePackResponse2 = _interopRequireDefault(_parsePackResponse);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -47,103 +51,85 @@

};
var __await = undefined && undefined.__await || function (v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
};
var __asyncGenerator = undefined && undefined.__asyncGenerator || function (thisArg, _arguments, generator) {
if (!_symbol2.default.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []),
i,
q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[_symbol2.default.asyncIterator] = function () {
return this;
}, i;
function verb(n) {
if (g[n]) i[n] = function (v) {
return new _promise2.default(function (a, b) {
q.push([n, v, a, b]) > 1 || resume(n, v);
});
};
}
function resume(n, v) {
try {
step(g[n](v));
} catch (e) {
settle(q[0][3], e);
}
}
function step(r) {
r.value instanceof __await ? _promise2.default.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
}
function fulfill(value) {
resume("next", value);
}
function reject(value) {
resume("throw", value);
}
function settle(f, v) {
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
}
};
function push(url, fetch, commands, objects, auth) {
return __asyncGenerator(this, arguments, /*#__PURE__*/_regenerator2.default.mark(function push_1() {
var packfile, body, _a, _b, result, e_1, _c;
return _regenerator2.default.wrap(function push_1$(_context) {
exports.default = function () {
(0, _newArrowCheck3.default)(undefined, undefined);
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(url, fetch, commands, objects, auth, progress) {
var packfile, size, body, response, _a, _b, parsed, e_1, _c;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
//Delta compression isn't implemented yet
if (progress) progress('Delta compression using up to 0 therads.\n');
packfile = (0, _packfile.pack)(objects.entries());
size = packfile.length / 1024 | 0;
if (progress) progress("Compressing objects: 100% " + size + "/" + size + ", done.\n");
body = (0, _composePushRequest2.default)(packfile, commands);
_context.prev = 2;
_a = __asyncValues((0, _post2.default)(url, 'git-receive-pack', body, fetch, auth));
case 4:
_context.next = 6;
return __await(_a.next());
if (progress) progress("Writing objects: 100% " + size + "/" + size + ", " + size + "KiB, done.\n");
response = (0, _post2.default)(url, 'git-receive-pack', body, fetch, auth);
_context.prev = 7;
_a = __asyncValues((0, _parsePackResponse2.default)(response));
case 6:
case 9:
_context.next = 11;
return _a.next();
case 11:
_b = _context.sent;
if (_b.done) {
_context.next = 15;
_context.next = 25;
break;
}
_context.next = 10;
return __await(_b.value);
_context.next = 15;
return _b.value;
case 10:
result = _context.sent;
_context.next = 13;
return (0, _core.decode)(result);
case 15:
parsed = _context.sent;
_context.t0 = parsed.type;
_context.next = _context.t0 === 'progress' ? 19 : _context.t0 === 'error' ? 21 : 23;
break;
case 13:
_context.next = 4;
case 19:
if (progress) progress(parsed.message);
return _context.abrupt("break", 23);
case 21:
if (progress) progress(parsed.message);
return _context.abrupt("break", 23);
case 23:
_context.next = 9;
break;
case 15:
_context.next = 20;
case 25:
_context.next = 30;
break;
case 17:
_context.prev = 17;
_context.t0 = _context["catch"](2);
e_1 = { error: _context.t0 };
case 27:
_context.prev = 27;
_context.t1 = _context["catch"](7);
e_1 = { error: _context.t1 };
case 20:
_context.prev = 20;
_context.prev = 21;
case 30:
_context.prev = 30;
_context.prev = 31;
if (!(_b && !_b.done && (_c = _a.return))) {
_context.next = 25;
_context.next = 35;
break;
}
_context.next = 25;
return __await(_c.call(_a));
_context.next = 35;
return _c.call(_a);
case 25:
_context.prev = 25;
case 35:
_context.prev = 35;
if (!e_1) {
_context.next = 28;
_context.next = 38;
break;

@@ -154,9 +140,12 @@ }

case 28:
return _context.finish(25);
case 38:
return _context.finish(35);
case 29:
return _context.finish(20);
case 39:
return _context.finish(30);
case 30:
case 40:
if (progress) progress("Total " + size + " (delta 0), reused 0 (delta 0)\n");
case 41:
case "end":

@@ -166,6 +155,12 @@ return _context.stop();

}
}, push_1, this, [[2, 17, 20, 30], [21,, 25, 29]]);
}, _callee, this, [[7, 27, 30, 40], [31,, 35, 39]]);
}));
}
function push(_x, _x2, _x3, _x4, _x5, _x6) {
return _ref.apply(this, arguments);
}
return push;
}.bind(undefined)();
//# sourceMappingURL=push.js.map
//# sourceMappingURL=push.js.map
{
"name": "@es-git/http-transport",
"version": "0.4.4",
"version": "0.5.0",
"description": "",

@@ -42,4 +42,4 @@ "main": "js/index.js",

"dependencies": {
"@es-git/core": "^0.4.2",
"@es-git/packfile": "^0.4.2"
"@es-git/core": "^0.5.0",
"@es-git/packfile": "^0.5.0"
},

@@ -46,0 +46,0 @@ "devDependencies": {

@@ -29,3 +29,3 @@ import pktLine from './pkt-line';

const [command, ...remainingCommands] = commands;
yield pktLine(encodeCommand(command) + '\0 report-status side-band-64k agent=es-git');
yield pktLine(encodeCommand(command) + '\0report-status side-band-64k agent=es-git');

@@ -32,0 +32,0 @@ for(const command of remainingCommands){

@@ -8,4 +8,4 @@ import { Ref, HasObject, Hash } from './types';

import post, { Fetch as FetchPackFetch } from './post';
import parseWantResponse, { Token } from './parseWantResponse';
import { unpack, RawObject } from '@es-git/packfile';
import parsePackResponse, { Token } from './parsePackResponse';
import { unpack, RawObject, Progress } from '@es-git/packfile';
import remotesToLocals from './remotesToLocals';

@@ -41,3 +41,3 @@ import defer from './utils/defer';

export default async function fetch({url, fetch, localRefs, refspec, hasObject, depth, shallows, unshallow} : FetchRequest, progress? : (message : string) => void) : Promise<FetchResult> {
export default async function fetch({url, fetch, localRefs, refspec, hasObject, depth, shallows, unshallow} : FetchRequest, progress? : Progress) : Promise<FetchResult> {
const {capabilities, remoteRefs} = await lsRemote(url, fetch, 'git-upload-pack');

@@ -79,6 +79,6 @@

async function* createResult(response : AsyncIterableIterator<Uint8Array>, resolveShallow : (v : string[]) => void, resolveUnshallow : (v : string[]) => void, progress?: (message: string) => void){
async function* createResult(response : AsyncIterableIterator<Uint8Array>, resolveShallow : (v : string[]) => void, resolveUnshallow : (v : string[]) => void, progress?: Progress){
const shallow : string[] = [];
const unshallow : string[] = [];
for await(const parsed of parseWantResponse(response)){
for await(const parsed of parsePackResponse(response)){
switch(parsed.type){

@@ -100,2 +100,5 @@ case 'shallow':

break;
case 'error':
if(progress) progress(parsed.message);
break;
}

@@ -102,0 +105,0 @@ }

export { default as fetch, Fetch, RawObject, FetchRequest, FetchResult, RefChange } from './fetch';
export { default as lsRemote, Result } from './lsRemote';
export { default as lsRemote, Result, Ref } from './lsRemote';
export { default as push, Command, Auth } from './push';
export { default as push, Command, Auth } from './push';
export { Progress } from '@es-git/packfile';
import parseRefsResponse from './parseRefsResponse';
import { Ref } from './types';
export { Ref };
export interface Result {

@@ -19,3 +21,3 @@ readonly capabilities : Map<string, string | boolean>,

const res = await fetch(`${url}/info/refs?service=${service}`);
if(res.status !== 200) throw new Error(`ls-remote failed with ${res.status} ${res.statusText}`);
if(res.status !== 200) throw new Error(`ls-remote failed with ${res.status} ${res.statusText}\n${await res.text()}`);
const refs = await res.text();

@@ -22,0 +24,0 @@ const capabilities = new Map<string, string | boolean>();

import { decode } from '@es-git/core';
import { pack, RawObject } from '@es-git/packfile';
import { pack, RawObject, Progress } from '@es-git/packfile';
import composePushRequest, { Command } from './composePushRequest';
import post, { Fetch, Auth } from './post';
import parsePackResponse from './parsePackResponse';
export { Command, Auth };
export default async function* push(url : string, fetch : Fetch, commands : Command[], objects : Map<string, Uint8Array>, auth? : Auth){
export default async function push(url : string, fetch : Fetch, commands : Command[], objects : Map<string, Uint8Array>, auth? : Auth, progress? : Progress){
//Delta compression isn't implemented yet
if(progress) progress('Delta compression using up to 0 therads.\n');
const packfile = pack(objects.entries());
const size = (packfile.length/1024)|0;
if(progress) progress(`Compressing objects: 100% ${size}/${size}, done.\n`);
const body = composePushRequest(packfile, commands);
for await(const result of post(url, 'git-receive-pack', body, fetch, auth)){
yield decode(result);
if(progress) progress(`Writing objects: 100% ${size}/${size}, ${size}KiB, done.\n`);
const response = post(url, 'git-receive-pack', body, fetch, auth);
for await(const parsed of parsePackResponse(response)){
switch(parsed.type){
case 'progress':
if(progress) progress(parsed.message);
break;
case 'error':
if(progress) progress(parsed.message);
break;
}
}
if(progress) progress(`Total ${size} (delta 0), reused 0 (delta 0)\n`);
}

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

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