release-notes.ts

4.8 KB · raw

1/** Curated release history and post-update notice selection. */23declare const __PEACH_VERSION__: string;45export type ReleaseImportance = "breaking" | "critical";6export interface ReleaseNote {7  heading: string;8  body: string;9}1011export const PEACH_VERSION: string = typeof __PEACH_VERSION__ !== "undefined"12  ? __PEACH_VERSION__13  : "0.0.0";1415export interface PeachRelease {16  version: string;17  releasedAt: string;18  notes: ReleaseNote[];19  importance?: ReleaseImportance;20}2122export const RELEASES: PeachRelease[] = [23  {24    version: "5.2.46",25    releasedAt: "2026-09-11",26    importance: "breaking",27    notes: [{28      heading: "Sync needs one deliberate repair",29      body: "This security update starts a new Sync generation. Update Peach on every other device, reset Sync here, then pair each device again. Your vault and recovery words are unchanged; old device trust is archived, not silently reused.",30    }],31  },32  { version: "5.2.17", releasedAt: "2026-09-07", importance: "breaking", notes: [{ heading: "Sync may need device repair", body: "If sync starts failing after this security update, revoke the affected devices and pair them again. A recent security change may require repairing device trust before sync can resume." }] },33  { version: "5.2.6", releasedAt: "2026-09-06", notes: [{ heading: "Release history", body: "Settings now has an accurate, versioned changelog. Important notices combine every critical or breaking change since your previous installed version." }] },34  { version: "5.2.5", releasedAt: "2026-09-06", notes: [{ heading: "Quieter update notices", body: "Routine updates no longer replay unchanged What's New information." }] },35  { version: "5.2.4", releasedAt: "2026-09-06", notes: [{ heading: "Chrome passkey sign-in", body: "Older Peach passkeys work again on GitHub and other strict sites." }] },36  { version: "5.2.3", releasedAt: "2026-09-06", notes: [{ heading: "Inline entry creation", body: "The + button keeps new-entry creation inside the unlocked page helper." }] },37  { version: "5.2.2", releasedAt: "2026-09-06", notes: [{ heading: "Inline editing", body: "Entry editing stays in the page helper, and password-limit guidance is readable." }] },38  {39    version: "5.1.3", releasedAt: "2026-09-05", importance: "breaking",40    notes: [41      { heading: "Passphrases & long passwords", body: "Peach supports passphrases and passwords up to 256 characters." },42      { heading: "Update Android before using Vault V4", body: "Vault V4 requires Peach Android v2.15.3 or newer. Update Android and export a backup there before moving to Vault V4." },43    ],44  },45];4647export function hasReleaseNotes(): boolean { return RELEASES.length > 0; }4849const UPGRADE_FROM_KEY = "peach_release_notes_from";50const LEGACY_SEEN_KEY = "peach_whats_new_seen";5152function versionParts(version: string): [number, number, number] | null {53  const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);54  return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;55}5657export function compareVersions(left: string, right: string): number {58  const a = versionParts(left); const b = versionParts(right);59  if (!a || !b) return 0;60  for (let index = 0; index < 3; index += 1) if (a[index] !== b[index]) return a[index]! - b[index]!;61  return 0;62}6364export function importantReleasesSince(version: string): PeachRelease[] {65  const currentVersion = PEACH_VERSION === "0.0.0" ? RELEASES[0]!.version : PEACH_VERSION;66  return selectImportantReleases(RELEASES, version, currentVersion);67}6869export function selectImportantReleases(70  releases: PeachRelease[],71  fromVersion: string,72  throughVersion: string,73): PeachRelease[] {74  return releases.filter((release) =>75    release.importance !== undefined &&76    compareVersions(release.version, fromVersion) > 0 &&77    compareVersions(release.version, throughVersion) <= 078  );79}8081export async function recordInstalledVersion(details: chrome.runtime.InstalledDetails): Promise<void> {82  if (details.reason !== "update" || !details.previousVersion) return;83  const stored = await chrome.storage.local.get(UPGRADE_FROM_KEY);84  if (stored[UPGRADE_FROM_KEY] === undefined) await chrome.storage.local.set({ [UPGRADE_FROM_KEY]: details.previousVersion });85}8687export async function pendingImportantReleases(): Promise<PeachRelease[]> {88  try {89    const stored = await chrome.storage.local.get([UPGRADE_FROM_KEY, LEGACY_SEEN_KEY]);90    const from = stored[UPGRADE_FROM_KEY];91    return typeof from === "string" && versionParts(from) ? importantReleasesSince(from) : [];92  } catch { return []; }93}9495export async function shouldShowWhatsNew(): Promise<boolean> {96  return (await pendingImportantReleases()).length > 0;97}9899export async function markWhatsNewSeen(): Promise<void> {100  try {101    await chrome.storage.local.remove([UPGRADE_FROM_KEY, LEGACY_SEEN_KEY]);102  } catch {103    // Best effort: a storage failure may make an important notice reappear.104  }105}