iya-sts
    Preparing search index...

    The mail channel's messages: the built-in template of every message this service sends, the rules a realm's own template must keep, and the renderer.

    Values are escaped by the renderer, a link is always a placeholder for this service's own address, and the HTML part may load and run nothing. A library that stores nothing.

    Index
    BUILT_IN: TemplateSpec[] = BUILT_IN

    The built-in template of every message, in English: its id, category, title, placeholders, links and three parts.

    CATEGORIES: {
        id: string;
        label: string;
        optional: boolean;
        reason: string;
        what: string;
    }[] = CATEGORIES

    The message categories (security, account, notification), with whether a person may decline each.

    COMMON: string[] = COMMON

    The placeholders every message offers: realm and service.

    LAYOUT_ID: "layout" = LAYOUT_ID

    The id of the layout every message is wrapped in: layout.

    • Finds the built-in template with an id.

      Parameters

      • id: string

        the message's id

      Returns TemplateSpec

      the template, or null

    • Finds the built-in translation of a message (or of the layout) for a language: the first file along the language's chain that has it.

      Parameters

      • id: string

        the message's id, or layout

      • language: string

        a language tag, in any case

      Returns any

      { parts, lang } with lang the catalog tag that answered, or null for English, a language no catalog answers, or an unknown id

    • Lists the catalog tags a message has a built-in translation in (an overlay counts when its base has the message).

      Parameters

      • id: string

        the message's id, or layout

      Returns string[]

      catalog tags, sorted

    • Finds a category by id.

      Parameters

      • id: string

        the category's id

      Returns any

      the category, or null

    • Lists the translation files to read for a language tag, overlay first, English left out; empty when no catalog answers the tag.

      Parameters

      • language: string

        a language tag, in any case

      Returns string[]

      catalog tags, most specific first

    • Wraps an HTML part in the one document every message is: a language tag and a head that loads nothing.

      Parameters

      • body: string

        the HTML part

      • lang: string

        the language tag; en when absent

      Returns string

      the document

    • Orders the languages to try for a message, best first: each tag of an Accept-Language value and its primary subtag by q, then the realm's default, then en.

      Parameters

      • preferred: string

        the entry's preferredLanguage

      • fallback: string

        the realm's default language

      Returns string[]

      the language tags

    • Reads common/mail_locales/*.json once, keyed by catalog tag. An unreadable file is logged (STS-I18N-0001) and left out.

      Returns { [tag: string]: any }

      every translation file, by catalog tag

    • Lists every {{name}} placeholder in a piece of text, once each.

      Parameters

      • text: string

        the text

      Returns string[]

      the placeholder names

    • Prepares a value for a subject or a text part: every control character, CR and LF above all, becomes a space.

      Parameters

      • value: unknown

        the value

      Returns string

      the text

    • Checks a realm's template against the rules, when it is saved: all three parts, sizes, placeholders the message offers, no address of its own, every link in the text part, and no HTML that loads or runs anything.

      Parameters

      • spec: TemplateSpec

        the built-in template it rewords

      • parts: any

        { subject, text, html }

      Returns string

      one sentence saying what is wrong, or '' when nothing is

    • Says why a person received a message of a category, in a language: the words the layout finishes "because it is ..." with.

      Parameters

      • id: string

        the category's id

      • language: string

        the language the layout went out in

      Returns string

      the reason

    • Renders a template: each placeholder filled with its value, escaped for HTML in the HTML part and stripped of control characters elsewhere. A placeholder with no value renders empty.

      Parameters

      • parts: any

        the template's { subject, text, html }

      • values: any

        every placeholder's raw value, links already absolute

      Returns any

      { subject, text, html }

    • Wraps a rendered message in the layout: its body as {{content}}, unescaped since it was escaped when rendered, and its subject as {{subject}}.

      Parameters

      • layoutParts: any

        the layout's { subject, text, html }

      • rendered: any

        render()'s answer for the message

      • values: any

        the other placeholders' values

      Returns any

      { subject, text, html }