diff --git a/README.md b/README.md index 406ea5c..d5f65e4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- Comms CLI + Comms CLI

# Comms CLI diff --git a/icons/comms-cli_512px.png b/icons/comms-cli_512px.png deleted file mode 100644 index aa79fa4..0000000 Binary files a/icons/comms-cli_512px.png and /dev/null differ diff --git a/src/lib/auth-constants.ts b/src/lib/auth-constants.ts index d8dc09a..266c0e2 100644 --- a/src/lib/auth-constants.ts +++ b/src/lib/auth-constants.ts @@ -1,2 +1,11 @@ /** OS keyring `service` identifier for every comms-cli secret. */ export const SECURE_STORE_SERVICE = 'comms-cli' + +/** + * Icon sent as `logo_uri` when registering an OAuth client, and shown on the + * local auth result pages. Todoist keeps the URL each client registered with, + * so never rename or delete the file behind it. (3.6.1 to 3.6.3 registered + * `icons/comms-cli_512px.png`, since removed, so those clients show Todoist's + * fallback icon.) + */ +export const LOGO_URI = 'https://raw.githubusercontent.com/doist/comms-cli/main/icons/comms-cli.png' diff --git a/src/lib/auth-pages.test.ts b/src/lib/auth-pages.test.ts new file mode 100644 index 0000000..1efb28e --- /dev/null +++ b/src/lib/auth-pages.test.ts @@ -0,0 +1,25 @@ +import { existsSync } from 'node:fs' +import { fileURLToPath } from 'node:url' + +import { describe, expect, it } from 'vitest' + +import { LOGO_URI } from './auth-constants.js' +import { renderError, renderSuccess } from './auth-pages.js' + +describe('auth pages', () => { + it.each([ + ['success', renderSuccess()], + ['error', renderError('boom')], + ])('the %s page shows the published icon rather than an inline copy', (_, html) => { + expect(html).toContain(`]*viewBox="0 0 72 72"/) + }) +}) + +describe('LOGO_URI', () => { + it('points at a file in this repo, which registered OAuth clients keep using', () => { + const path = new URL(LOGO_URI).pathname.replace(/^\/doist\/comms-cli\/main\//, '') + expect(existsSync(fileURLToPath(new URL(`../../${path}`, import.meta.url)))).toBe(true) + }) +}) diff --git a/src/lib/auth-pages.ts b/src/lib/auth-pages.ts index c1b87aa..e24e46e 100644 --- a/src/lib/auth-pages.ts +++ b/src/lib/auth-pages.ts @@ -1,159 +1,7 @@ -const COMMS_CLI_ICON_SVG = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -` +import { LOGO_URI } from './auth-constants.js' + +// The same PNG the OAuth consent screen shows, so the icon lives in one file. +const COMMS_CLI_ICON = `` export function renderSuccess(): string { return ` @@ -229,6 +77,7 @@ export function renderSuccess(): string { position: relative; isolation: isolate; } + .logo-wrap img, .logo-wrap svg { width: 100%; height: 100%; @@ -390,7 +239,7 @@ export function renderSuccess(): string {
- ${COMMS_CLI_ICON_SVG} + ${COMMS_CLI_ICON}
@@ -513,6 +362,7 @@ export function renderError(errorMessage: string): string { position: relative; isolation: isolate; } + .logo img, .logo svg { width: 100%; height: 100%; @@ -562,7 +412,7 @@ export function renderError(errorMessage: string): string {