AUTHconstno test imports itconst AUTH: { readonly NONE: 0; readonly SYS: 1; }The authentication flavors the server reads.
ONC RPC version 2 (RFC 5531) over TCP, as far as a server of NFS needs it: the record marking that frames messages on a stream (a record is one or more fragments, the last marked), a call read from a record with its credential (AUTH_NONE or AUTH_SYS with the uid and gid), and the replies a server gives: accepted with a result, accepted with the failure it names (PROG_UNAVAIL, PROG_MISMATCH, PROC_UNAVAIL, GARBAGE_ARGS, SYSTEM_ERR) and denied (RPC_MISMATCH, an authentication error). Pure: bytes in, bytes out.
import { frame, RecordReader } from "./rpc.ts";
const reader = new RecordReader(1024);
const records = reader.push(frame(new Uint8Array([1, 2, 3, 4])));
records.kind === "ok" && records.value.length; // 1AUTHconstno test imports itconst AUTH: { readonly NONE: 0; readonly SYS: 1; }The authentication flavors the server reads.
Credtypeno test imports ittype Cred = { readonly flavor: number; readonly uid?: number; readonly gid?: number; readonly machine?: string };Who a call says it is: nothing, or a uid and a gid of the caller's computer.
RpcCalltypeno test imports ittype RpcCall = {
readonly xid: number;
readonly prog: number;
readonly vers: number;
readonly proc: number;
readonly cred: Cred;
/** The bytes of the arguments of the procedure. */
readonly args: Uint8Array;
};A call, read from a record.
Parsedtypeno test imports ittype Parsed = { readonly kind: "call"; readonly call: RpcCall } | { readonly kind: "reply"; readonly reply: Uint8Array } | { readonly kind: "drop" };What a record was: a call, or what to answer (or nothing) where it was not one the server can serve.
ACCEPTconstno test imports itconst ACCEPT: { readonly SUCCESS: 0; readonly PROG_UNAVAIL: 1; readonly PROG_MISMATCH: 2; readonly PROC_UNAVAIL: 3; readonly GARBAGE_ARGS: 4; readonly SYSTEM_ERR: 5; }The accept statuses of a reply.
AUTH_STATconstno test imports itconst AUTH_STAT: { readonly BADCRED: 1; readonly REJECTEDCRED: 2; readonly BADVERF: 3; readonly REJECTEDVERF: 4; readonly TOOWEAK: 5; }The reasons of an authentication error.
acceptedfunctionfunction accepted(xid: number, result?: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>An accepted reply with a result: result is the XDR of what the procedure returns.
failedfunctionno test imports itfunction failed(xid: number, stat: 1 | 3 | 4 | 5): Uint8Array<ArrayBufferLike>An accepted reply that says why there is no result.
progMismatchfunctionfunction progMismatch(xid: number, low: number, high: number): Uint8Array<ArrayBufferLike>The reply to a call for a version the server does not have: the versions it has.
rpcMismatchfunctionno test imports itfunction rpcMismatch(xid: number): Uint8Array<ArrayBufferLike>The denial of a call of another version of RPC than 2.
authErrorfunctionno test imports itfunction authError(xid: number, stat: 1 | 2 | 3 | 4 | 5): Uint8Array<ArrayBufferLike>The denial of a call whose authentication is refused.
parseCallfunctionfunction parseCall(record: Uint8Array<ArrayBufferLike>): ParsedReads a record as a call, or says what to do with it.
framefunctionfunction frame(record: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>A record of one fragment, for sending.
RecordReaderclassclass RecordReaderJoins what arrives on a stream into records: fragments are joined, a record longer than the limit is refused.
| Member | Type | What it is |
|---|---|---|
push | (chunk: Uint8Array<ArrayBufferLike>) => Result<readonly Uint8Array<ArrayBufferLike>[], string> | Takes bytes; gives the records they complete, or the reason the stream is not one a server can read. |