Explorer

html-ui.release-host-script

description
Serves the host.js of the signed release (the part host-release.host-script of the latest commit of host-release main) at /host.js, so that a new PC can get its first host.js without git or GitHub (docs/local-server.md). Only this first download trusts HTTPS; host.js checks the signature of every later release
type
Fn() -> @definy.service-io
expression
fn() =>
  @"LgFd1w9SpWSWaDXqXHiMSOjBWh_OBk2l0m7hTCq3bHg"(
    project: "host-release",
    branch: "main",
    then: fn(commit$0, commits$1) =>
      match $0 {
        #none(_) =>
          @html-ui.text-response(status: 404, text: "host-release main was not found"),
        #some(found$2) =>
          match @"GTiuHX4lQLsiDZCWSD4_d7b7zuIC6pZtRupwkr6Neek"(commits: [$2], name: "host-release.host-script", index: 0) {
            #none(_) =>
              @html-ui.text-response(status: 404, text: "host-release.host-script was not found"),
            #some(part$3) =>
              @definy.read-part-contents(
                parts: [$3.part],
                then: fn(parts$4) =>
                  match @core.list-get(list: $4, index: 0) {
                    #none(_) =>
                      @html-ui.text-response(status: 500, text: "host-release.host-script could not be read"),
                    #some(resolved$5) =>
                      match $5.content {
                        #none(_) =>
                          @html-ui.text-response(status: 500, text: "host-release.host-script could not be read"),
                        #some(content$6) =>
                          match $6.expression {
                            #none(_) =>
                              @html-ui.text-response(status: 500, text: "host-release.host-script has no expression"),
                            #some(expression$7) =>
                              match $7 {
                                #string(text$8) =>
                                  #done<@definy.service-io>(#respond({
                                    status: 200,
                                    headers: [
                                      {name: "content-type", value: "text/javascript; charset=utf-8"},
                                      {name: "cache-control", value: "no-store"},
                                      {name: "x-definy-release", value: $2.event_hash}
                                    ],
                                    body: #text<@definy.http-body>($8)
                                  })),
                                _ =>
                                  @html-ui.text-response(status: 500, text: "host-release.host-script is not a string")
                              }
                          }
                      }
                  }
              )
          }
      }
  )
visibility
public
html-ui.release-host-script (project html-ui, branch edit-check, snapshot FWBeS680eOlm6c2NOnWcarkR0iM2Jt6ap5-Rv0zDiXk)
id: OZlFDUyynqe2BO6-eq0bcY57rqY6z6QWn-52ihs8NO8
content hash: Agmm4-zXlm20ZkdhkdGG9SCBCv6A2gOVzw_Zh2w-Bfo