/** * Connection for the activate-now Zapier app. * * No live Verae or zappier server is required. The test always succeeds so a * developer can push and run Add Numbers before billing or timestamping is wired. * * Optional later: set ZAPPIER_API_BASE + api_key to send Add Numbers through * packages/zappier POST /v1/add. * * @module authentication */ /** * @param {object} z * @param {object} bundle * @returns {Promise<{ok: boolean, mode: string, label: string}>} */ const testAuth = async (z, bundle) => { const base = (bundle.authData.api_base || process.env.ZAPPIER_API_BASE || '').replace(/\/$/, ''); const key = bundle.authData.api_key || ''; if (base && key) { const response = await z.request({ url: `${base}/v1/status`, headers: { 'x-api-key': key }, }); return { ok: true, mode: 'hosted', label: response.data?.status === 'ok' ? 'zappier' : 'hosted', }; } return { ok: true, mode: 'local', label: 'Verae Time (Add Numbers)' }; }; module.exports = { type: 'custom', fields: [ { key: 'api_key', type: 'string', required: false, label: 'API Key (optional)', helpText: 'Leave blank for Add Numbers (runs inside Zapier). Later, paste a key from your zappier portal. See https://github.com/zapier/zapier-platform#authentication', }, { key: 'api_base', type: 'string', required: false, label: 'API base URL (optional)', helpText: 'Example: https://your-host.example.com — only needed when routing Add Numbers to hosted /v1/add.', }, ], test: testAuth, connectionLabel: '{{label}}', };