Skip to content

Black Friday

Annual Pro is $90 for the first year, normally $120. Or start monthly at $6 for two months, then $12.

Ends Dec 4, 11:59 PM PT.

Create an account
← Public packages

@danj/audible-auth

Locked Audible gateway using one owner-provisioned Kody login.

FollowFork

Files

secret-list.ts

13 lines · 829 B · TypeScript
import { kody } from 'kody:runtime'

type LoginMetadata = { description: string; updatedAt: string; disconnected: boolean }
export async function loginMetadata(): Promise<LoginMetadata | null> {
	let listed: unknown
	try { listed = await kody.secretList({ scope: 'user' }) }
	catch { throw new Error('Audible login metadata unavailable. Check secretList capability and Kody access.') }
	const rows = listed && typeof listed === 'object' && 'secrets' in listed ? listed.secrets : listed
	if (!Array.isArray(rows)) return null
	const row = rows.find(row => row?.name === 'audible-login' && row.scope === 'user')
	if (!row) return null
	return { description: typeof row.description === 'string' ? row.description : '', updatedAt: typeof row.updated_at === 'string' ? row.updated_at : '', disconnected: row.disconnected === true }
}