Skip to content
quarry Artifact [6ab1720827]
Login

Artifact [6ab1720827]

Artifact 6ab172082775c0ed3be616b7f61607e3307b0cf4e38b1c8c54f5aac8283676e3:


// Package legal serves the notices a public forge owes its readers: the
// third-party licence inventory, and the privacy statement describing
// what this instance actually stores.
package legal

import (
	_ "embed"
	"encoding/json"
	"fmt"
)

//go:embed licenses.json
var inventory []byte

// Quarry is this software's own licence, embedded from the repository
// root so the page cannot disagree with the file that governs.
//
//go:embed LICENSE
var Quarry string

// Notice is one dependency's licence.
type Notice struct {
	Module  string `json:"module"`
	Version string `json:"version"`
	License string `json:"license"`
	Text    string `json:"text"`
}

// Notices returns the embedded inventory. Generated by cmd/licensegen
// and checked for freshness by a test, because a licence page that has
// silently stopped listing a dependency is worse than none: it asserts
// completeness it no longer has.
func Notices() ([]Notice, error) {
	var out []Notice
	if err := json.Unmarshal(inventory, &out); err != nil {
		return nil, fmt.Errorf("legal: inventory: %w", err)
	}
	return out, nil
}

//go:embed plex-OFL.txt
var plexOFL string

// Bundled lists what quarry serves to browsers that is not a Go module,
// and so never appears in the generated inventory: today, the IBM Plex
// fonts every page is set in.
func Bundled() []Notice {
	return []Notice{{
		Module:  "IBM Plex Sans and IBM Plex Mono (fonts, Latin-1 subset)",
		Version: "Sans 1.1.0, Mono 2.5.0",
		License: "OFL-1.1",
		Text:    plexOFL,
	}}
}