Skip to content
API reference

git-wire

Import
import * as api from "@fungi.computer/agar/git-wire";
Kind Export Description
type alias ReceivePack The decoded receive-pack command section; pack bytes remain unopened.
function readPacketLines() Split pkt-lines from the start of bytes; stops at the first flush when asked.
function pktLine() Encode one UTF-8 text packet with its byte-counted four-byte Git header.
function acceptedRefs() Refs the provider accepted, read from report-status (with or without side-band).
function parseReceivePack() Fail closed on any command the maintained Git wire contract does not support.
function refusalReport() Whole-push refusal in report-status, including the negotiated side-band framing.
function sideBandData() Data channel of an upload-pack side-band reply; fatal server messages refuse.
function advertisedRefs() Ref names and object IDs from the maintained smart-HTTP advertisement framing.
function advertisedCapabilities() Capabilities from the ref advertisement’s first NUL-delimited capability list.

ReceivePacktype alias

Section titled “ReceivePack”
Signature
type ReceivePack =
| Readonly<{
kind: "ok";
updates: readonly GitRefUpdate[];
capabilities: readonly string[];
}>
| Readonly<{
kind: "probe";
}>
| Readonly<{
kind: "invalid";
reason: "unparsable" | "push-cert" | "too-many";
}>;

The decoded receive-pack command section; pack bytes remain unopened.

readPacketLines()function

Section titled “readPacketLines()”
Signature
function readPacketLines(
bytes,
stopAtFlush,
strict?,
): Uint8Array<ArrayBufferLike>[];

Split pkt-lines from the start of bytes; stops at the first flush when asked.

Parameter Type Default value
bytes Uint8Array undefined
stopAtFlush boolean undefined
strict boolean false

Uint8Array<ArrayBufferLike>[]


Signature
function pktLine(text): string;

Encode one UTF-8 text packet with its byte-counted four-byte Git header.

Parameter Type
text string

string


acceptedRefs()function

Section titled “acceptedRefs()”
Signature
function acceptedRefs(response, sideBand): ReadonlySet<string>;

Refs the provider accepted, read from report-status (with or without side-band).

Parameter Type
response Uint8Array
sideBand boolean

ReadonlySet<string>


parseReceivePack()function

Section titled “parseReceivePack()”
Signature
function parseReceivePack(body): ReceivePack;

Fail closed on any command the maintained Git wire contract does not support.

Parameter Type
body Uint8Array

ReceivePack


refusalReport()function

Section titled “refusalReport()”
Signature
function refusalReport(verdict, updates, capabilities): Uint8Array;

Whole-push refusal in report-status, including the negotiated side-band framing.

Parameter Type
verdict | { allowed: true; } | { allowed: false; refused: object[]; } & object
updates readonly object[]
capabilities readonly string[]

Uint8Array


sideBandData()function

Section titled “sideBandData()”
Signature
function sideBandData(body): Uint8Array;

Data channel of an upload-pack side-band reply; fatal server messages refuse.

Parameter Type
body Uint8Array

Uint8Array


advertisedRefs()function

Section titled “advertisedRefs()”
Signature
function advertisedRefs(body): ReadonlyMap<string, string>;

Ref names and object IDs from the maintained smart-HTTP advertisement framing.

Parameter Type
body Uint8Array

ReadonlyMap<string, string>


advertisedCapabilities()function

Section titled “advertisedCapabilities()”
Signature
function advertisedCapabilities(body): ReadonlySet<string>;

Capabilities from the ref advertisement’s first NUL-delimited capability list.

Parameter Type
body Uint8Array

ReadonlySet<string>