Skip to content
← Public packages

@danj/hey-email

HEY.com email for Kody: search threads, read messages, download PDF attachments, and write drafts. Sending is barred until you allow it.

src/config.js

15 lines · 604 B · JavaScript
Raw
/** @type {'barred' | 'allowed'} */
export const SENDING = 'barred'

/**
 * Gate first, then confirm. No policy argument. Pure. No I/O.
 * Only the exact string 'allowed' opens the gate. true, 'True', 'enabled' stay barred.
 * confirm must be boolean true. 'true', 1, and omitted do not confirm.
 * @param {unknown} confirm
 * @returns {{ effect: 'barred' } | { effect: 'unconfirmed' } | { effect: 'confirmed' }}
 */
export function decideSend(confirm) {
  if (SENDING !== 'allowed') return { effect: 'barred' }
  if (confirm !== true) return { effect: 'unconfirmed' }
  return { effect: 'confirmed' }
}