Skip to content

basic ​

Function, in @jr2/orchestrator/src/http-effect.ts. It is an export of @jr2/orchestrator, on the Authoring surface page, in Effects.

ts
function basic<
  const U extends string | Secret | Text,
  const P extends string | Secret | Text,
>(
  user: U,
  password: P,
): MarkedIf<U | P, { readonly basic: { user: Text; password: Text } }>

Make the auth of an http Effect that sends Authorization: Basic <value>, where the value is the base64 of user:password. The Effector puts in the value of each secret.

Each of user and password is a string, a secret(...) or a text. In a packaged Machine, one of them can hold secret(open). It refuses another value: expected a string, a secret("name") or a text`…`, got <value>.

Parameters

  • user: The user name: a string, a secret(...) or a text.
  • password: The password: a string, a secret(...) or a text.

Returns: The auth of an http Effect.

Example

ts
import { basic, http, jr2Setup, secret } from "@jr2/orchestrator";

export const machine = jr2Setup({
  actors: {
    issue: http({
      method: "GET",
      url: "https://jira.example.com/rest/api/2/issue/APP-1",
      auth: basic("jr2-bot@example.com", secret("jira-token")),
    }),
  },
}).createMachine({
  id: "issue",
  initial: "reading",
  states: {
    reading: { invoke: { src: "issue", onDone: "done" } },
    done: { type: "final" },
  },
});

See also

The docs of Kit version 0.5.1. Each page is also at its .md URL.