~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
38 lines · 1.9 KB Raw History
// What the harness may take of the server it compares with the reference,
// beyond what the protocol says: the one place checks/ reads its adapter
// (lib/adapters/). Monolith is held to every check as it always was; another
// implementation may lack some of what the harness assumes, and each such
// lack is a setting spec/COMPAT.md names and lets it have. A check asks
// here, never which implementation it is, and every answer for Monolith is
// what the check did before it asked: no request, and no draw from the
// seeded source, changes for Monolith (compat/README.md, "Adding an
// implementation").

import { cand } from './processes.mjs'
import { smtpSink } from './smtp.mjs'

/// Whether Monolith's own rules hold the server: its own pages where they
/// ask more than the reference, or other than it (compat/README.md lists
/// them). Only Monolith's adapter says so.
export const own = () => cand.adapter.own

/// Whether the server can be given `setting` (spec/COMPAT.md, "Settings an
/// implementation cannot be given"): every one, for Monolith.
export const can = (setting) => !cand.adapter.unsupported[setting]

/// Whether the server signs in through the reference's page API, so that
/// every step of a sign-in is compared; else its adapter's `signIn` hook.
export const pageApi = () => cand.adapter.pageApi

/// The side's OAuth issuer: its public URL's origin, unless its adapter
/// names another.
export const issuer = (side) => new URL(side.issuer ?? side.publicUrl).origin

/// A password the server's rules take, made from `p` the same way each time
/// and with no draw (spec/COMPAT.md, "Password rules"): `p` itself, unless
/// its adapter has rules of its own.
export const passwordFor = (p) => (cand.adapter.passwordFor ? cand.adapter.passwordFor(p) : p)

/// The SMTP server (lib/smtp.mjs) the server sends its email through, if
/// its adapter gave it one (spec/EMAIL.md, "SMTP"); else null.
export const smtp = () => smtpSink()