IF Commons GitHub

client

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-s3-store FR-007

The client of a bucket: it builds the URL of a request (path style, host/bucket/key, or virtual-hosted style, bucket.host/key, each key encoded as RFC 3986 says), signs it with Signature Version 4 of @intellectual-frontiers/crypto for the service s3 (the payload's SHA-256 is signed on a connection that is not encrypted, and not signed on one that is, where UNSIGNED-PAYLOAD is allowed), sends it through a transport, and gives the answer if its status is a success and the failure S3 describes if it is not. It holds no state but the keys, which it asks its source for each time (a source remembers them as long as they last), and it never writes a key, a signature or a header that carries one.

import { parseEndpoint } from "./client.ts";
const e = parseEndpoint("http://127.0.0.1:9000");
e.kind === "ok" && e.value.host; // "127.0.0.1"

Source: commons/anyfs-s3/src/client.ts

2 of 9 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Addressingtypeno test imports it
type Addressing = "path" | "virtual";

How a bucket is written in a URL.

awsEndpointconstno test imports it
const awsEndpoint: (region: string) => Endpoint

The endpoint of Amazon S3 in a region.

CallErrortypeno test imports it
type CallError = { readonly kind: "transport"; readonly message: string } | { readonly kind: "credentials"; readonly message: string } | { readonly kind: "failure"; readonly failure: Failure };

Why a call has no answer that succeeded.

Endpointtypeno test imports it
type Endpoint = { readonly scheme: "http" | "https"; readonly host: string; readonly port?: number };

Where a service listens.

failureOffunctionno test imports it
function failureOf(response: HttpResponse): Failure

The failure an answer that is not a success stands for.

makeClientfunction
function makeClient(options: ClientOptions): S3Client

The client of a bucket.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

parseEndpointfunction
function parseEndpoint(text: string): Result<Endpoint, string>

An endpoint from a URL with no path, query or credentials.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

PayloadSigningtypeno test imports it
type PayloadSigning = "auto" | "signed" | "unsigned";

Whether the SHA-256 of a body is signed.

S3Clienttypeno test imports it
type S3Client = {
  readonly bucket: BucketName;
  readonly endpoint: Endpoint;
  readonly addressing: Addressing;
  /** The URL a call would be sent to, with nothing signed. */
  readonly urlOf: (call: Call) => string;
  /** The answer to a call if its status is 2xx, and the reason it is not one otherwise. */
  readonly send: (call: Call) => Promise<Result<HttpResponse, CallError>>;
};

The client of one bucket.

Titles, headings, exports, tables, columns and requirements. Esc closes.