Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="icons/comms-cli_512px.png" alt="Comms CLI" width="150" height="150" />
<img src="icons/comms-cli.png" alt="Comms CLI" width="150" height="150" />
</p>

# Comms CLI
Expand Down
Binary file removed icons/comms-cli_512px.png
Binary file not shown.
9 changes: 9 additions & 0 deletions src/lib/auth-constants.ts
Original file line number Diff line number Diff line change
@@ -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'
25 changes: 25 additions & 0 deletions src/lib/auth-pages.test.ts
Original file line number Diff line number Diff line change
@@ -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(`<img src="${LOGO_URI}"`)
expect(html).toContain('referrerpolicy="no-referrer"')
expect(html).not.toMatch(/<svg[^>]*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)
})
})
166 changes: 8 additions & 158 deletions src/lib/auth-pages.ts

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/lib/auth-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ describe('createCommsAuthProvider', () => {
expect(JSON.parse(String((fetchImpl.mock.calls[0][1] as RequestInit).body))).toMatchObject({
client_name: 'Comms CLI',
client_uri: 'https://github.com/doist/comms-cli',
logo_uri:
'https://raw.githubusercontent.com/doist/comms-cli/main/icons/comms-cli_512px.png',
logo_uri: 'https://raw.githubusercontent.com/doist/comms-cli/main/icons/comms-cli.png',
redirect_uris: ['http://localhost:8766/callback'],
scope: FULL_ACCESS_SCOPES.join(' '),
grant_types: ['authorization_code', 'refresh_token'],
Expand Down
4 changes: 1 addition & 3 deletions src/lib/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
type ValidateInput,
} from '@doist/cli-core/auth'
import { createWrappedCommsClient } from './api.js'
import { SECURE_STORE_SERVICE } from './auth-constants.js'
import { LOGO_URI, SECURE_STORE_SERVICE } from './auth-constants.js'
import { makeCommsAccount, toCommsAccount } from './comms-account.js'
import {
type AuthMode,
Expand All @@ -32,8 +32,6 @@ import { createCommsUserRecordStore, getDefaultUserRecord } from './user-records
const DEFAULT_TODOIST_AUTH_BASE_URL = 'https://todoist.com'
const DEFAULT_COMMS_OAUTH_RESOURCE = 'https://comms.todoist.com'

const LOGO_URI = 'https://raw.githubusercontent.com/doist/comms-cli/main/icons/comms-cli_512px.png'

export const READ_ONLY_SCOPES = [
'user:read',
'workspaces:read',
Expand Down
Loading