Events 3.1.0, Accounts 1.2.0, contracts 1.9.0: the move needs Accounts' email

A church moved sign-in to Accounts without email set up there: codes and
password links couldn't be sent, sign-in failed with a 500, nobody could
get in.

- contracts 1.9.0: messaging.status/test/set (SMTP, WAWP; secrets sealed);
  people.ensure answers emailSent.
- Accounts 1.2.0: SendError instead of a 500; WhatsApp codes fall back to
  email; forgot password says email isn't set up; setup only offers
  methods that work; messaging.* (test, save only what worked); test
  WhatsApp in admin; WAWP from .env.
- Events 3.1.0: Settings -> Sign-in shows what Accounts can send and
  copies this site's SMTP/WAWP into it (secrets stay on the server), test
  then save; Move disabled and refused (EMAIL_NOT_READY) without email.
Tests: Accounts 54, contracts 218, Events 774, test:accounts 16 (also on
Postgres).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 21:41:31 +02:00
co-authored by Claude Opus 5.5
parent 4b28fc485b
commit cc18b7b514
44 changed files with 2568 additions and 51 deletions
+23
View File
@@ -5,6 +5,29 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project follows [Semantic Versioning](https://semver.org/).
## [3.1.0] - 2026-11-19
Found after a church moved sign-in without email set up in Accounts: Accounts couldn't send codes or
password links, sign-in failed with a 500, and nobody could get in. Requires Accounts 1.2.0
(`— requires accounts 1.2.0`) and contracts 1.9.0.
### Added
- **Settings → Sign-in → Email and WhatsApp for the church's sign-in** (`src/accounts/messaging.ts`,
`components/admin/AccountsMessaging.tsx`): what Accounts can send, and this site's SMTP and WAWP
settings to copy into it. The password and access token never reach the page: left blank, this
site's own are used, sealed with the link's secret on the way. **Send a test** has Accounts send a
test email / WhatsApp with those settings (nothing saved); **Save in Accounts** tests again and
saves each part only if its test worked. Shown whenever Accounts is connected, so a church that
already moved can mend it. `GET /api/v2/settings/sign-in/messaging`, `POST …/messaging/test`,
`POST …/messaging`.
### Changed
- **The move needs Accounts' email.** Check reports what Accounts can send (and how many people get
WhatsApp codes, which go by email while Accounts' WhatsApp isn't set up); Move is disabled, and
refused by the server (`EMAIL_NOT_READY`), until Accounts' email works.
## [3.0.0] - 2026-11-19
Sign-in through the church's Accounts (ROADMAP-v3 phase 4, docs/EVENTS-3.0-PLAN.md). Requires
+8 -3
View File
@@ -22,12 +22,17 @@ Events password until an admin moves sign-in (step 4). The plan behind it is
Site settings → **Sign-in**:
1. **Check the move.** Nothing changes. It lists how many people move, who already has a church
1. **Set up the church account's email** (Email and WhatsApp for the church's sign-in, on the same
page, from 3.1.0). Accounts sends sign-in codes and password links itself, so without email there
nobody could sign in after the move; Move stays disabled until it works. The page copies this
site's email settings (leave the password blank to use this site's), **Send a test email**, check
it arrived, then **Save in Accounts**. WhatsApp the same way, if you use it.
2. **Check the move.** Nothing changes. It lists how many people move, who already has a church
account (they're linked to it and keep that account's password), anyone who can't move and why,
and the guests and deleted people who stay in Cross Events only.
2. Tick which Cross Events admins should also be **Accounts admins** (they can manage everyone's
3. Tick which Cross Events admins should also be **Accounts admins** (they can manage everyone's
sign-in). By default every admin is ticked.
3. **Move sign-in to Accounts** at a quiet time (not the evening before a big event's registration
4. **Move sign-in to Accounts** at a quiet time (not the evening before a big event's registration
closes). It takes about a minute. People already signed in stay signed in.
What people notice afterwards:
+8
View File
@@ -12,6 +12,14 @@ Write for church admins, not developers: no environment variables, endpoints or
developer log is CHANGELOG.md. A tagged version without a section here shows "No details given".
-->
## 3.1.0 — requires accounts 1.2.0
- **Fix:** moving sign-in to your church's Accounts now needs Accounts' email to work first, so
people can always get their sign-in codes and password links. Settings → Sign-in shows whether it
does, and sets it up for you: it copies this site's email settings (your password stays where it
is), sends a test, and only saves them in Accounts once the test arrived. The same for WhatsApp.
- If your church already moved without it, the same page sets it up now.
## 3.0.0 — requires accounts 1.1.0
- **One sign-in for all your church's sites and apps.** People can now sign in to Cross Events with
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/events-backend",
"version": "3.0.0",
"version": "3.1.0",
"description": "Event Management System Backend",
"main": "src/index.js",
"scripts": {
@@ -0,0 +1,85 @@
/**
* Email and WhatsApp for the church's Accounts (3.1.0). Accounts sends its own sign-in codes and
* password links, with its own settings, which a move doesn't bring along: a church that moved
* sign-in without them couldn't sign in at all. Settings → Sign-in therefore shows what Accounts can
* send, offers this site's own SMTP and WAWP settings to copy (the password and token stay on the
* server: blank means "use this site's"), tests them through Accounts, and saves them there only
* once the test worked (`crosscode.identity-request/1` messaging.*, contracts 1.9.0). The move
* itself needs Accounts' email to work (move.ts).
*/
import type { MessagingStatusReply, MessagingTestReply } from '@crosscode/contracts';
import { accounts } from './client';
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
const { getSetting } = require('../utils/settingsCache') as { getSetting(k: string, f?: string): Promise<string> };
const whatsapp = require('../utils/whatsapp') as { getConfig(): Promise<{ token: string; instanceId: string }> };
/* eslint-enable @typescript-eslint/no-require-imports */
type Smtp = { host: string; port: number; secure: boolean; user: string; pass: string; from: string };
/** This site's SMTP settings, as utils/email.js reads them (the database, then the .env). */
async function eventsSmtp(): Promise<Smtp | null> {
const env = process.env;
const host = await getSetting('smtp_host', env.SMTP_HOST || env.EMAIL_HOST || '');
if (!host) return null;
const port = parseInt(await getSetting('smtp_port', env.SMTP_PORT || env.EMAIL_PORT || '587'), 10) || 587;
return {
host,
port,
secure: String(await getSetting('smtp_secure', env.SMTP_SECURE || env.EMAIL_SECURE || 'false')).toLowerCase() === 'true',
user: await getSetting('smtp_user', env.SMTP_USER || env.EMAIL_USER || ''),
pass: await getSetting('smtp_pass', env.SMTP_PASS || env.EMAIL_PASS || ''),
from: await getSetting('smtp_from', env.MAIL_FROM || env.EMAIL_FROM || ''),
};
}
/** What this site has, to offer for copying: never the password or token themselves. */
export async function eventsMessaging() {
const smtp = await eventsSmtp();
const wa = await whatsapp.getConfig().catch(() => ({ token: '', instanceId: '' }));
return {
email: smtp ? { host: smtp.host, port: smtp.port, secure: smtp.secure, user: smtp.user, from: smtp.from || smtp.user, hasPass: !!smtp.pass } : null,
whatsapp: wa.instanceId ? { instanceId: wa.instanceId, hasToken: !!wa.token } : null,
};
}
/** What Accounts can send now. */
export async function accountsMessaging(): Promise<Omit<MessagingStatusReply, 'schema'>> {
const r = await (await accounts()).request<MessagingStatusReply>({ type: 'messaging.status', actor: null });
return { email: r.email, whatsapp: r.whatsapp };
}
export type MessagingInput = {
email?: { host: string; port: number; secure: boolean; user: string; from: string; pass?: string | null; to: string };
whatsapp?: { instanceId: string; accessToken?: string | null; to: string };
};
/**
* Tests (and with `save`, saves) settings in Accounts. A blank password or token means this site's
* own; Accounts gets it sealed with the link's secret. Returns Accounts' answer per part.
*/
export async function sendToAccounts(input: MessagingInput, opts: { save: boolean; actor: string | null }): Promise<Omit<MessagingTestReply, 'schema'>> {
const auth = await accounts();
let email;
if (input.email) {
const own = await eventsSmtp();
const pass = input.email.pass ? input.email.pass : (own?.pass ?? '');
email = {
settings: { host: input.email.host.trim(), port: input.email.port, secure: input.email.secure, user: input.email.user.trim(), from: input.email.from.trim(), pass: pass ? auth.seal(pass) : null },
to: input.email.to.trim(),
};
}
let wa;
if (input.whatsapp) {
const own = await whatsapp.getConfig().catch(() => ({ token: '', instanceId: '' }));
const token = input.whatsapp.accessToken ? input.whatsapp.accessToken : own.token;
wa = { settings: { instanceId: input.whatsapp.instanceId.trim(), accessToken: token ? auth.seal(token) : null }, to: input.whatsapp.to.trim() };
}
const r = await auth.request<MessagingTestReply>({
type: opts.save ? 'messaging.set' : 'messaging.test',
actor: opts.actor,
...(email ? { email } : {}),
...(wa ? { whatsapp: wa } : {}),
}, { timeoutMs: 60000 });
return { email: r.email, whatsapp: r.whatsapp, status: r.status };
}
+15
View File
@@ -17,6 +17,7 @@ import crypto from 'node:crypto';
import { IMPORT_BATCH_MAX, phoneSchema, type ImportPerson, type ImportResult } from '@crosscode/contracts';
import { siteUrl } from '../feed/context';
import { accounts, accountsLink, AccountsUnavailable } from './client';
import { accountsMessaging } from './messaging';
import { authMode, CLEARED_KEY, getSetting, MODE_KEY, MOVED_AT_KEY, REPORT_KEY, setSetting, UNDO_DAYS } from './mode';
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
@@ -159,6 +160,8 @@ export type CheckResult = {
admins: { id: string; name: string; email: string }[];
noticeConflict: { accountsVersions: number[]; eventsVersions: number[] } | null;
withTwoFactor: number;
/** 3.1.0: what Accounts can send. The move needs email (codes and password links); WhatsApp codes go by email when WhatsApp can't. */
messaging: { email: boolean; whatsapp: boolean; whatsappTwoFactor: number };
};
async function connected() {
@@ -199,9 +202,15 @@ export async function check(): Promise<CheckResult> {
admins: people.filter((p) => p.role === 'admin').map((p) => ({ id: p.id, name: p.name, email: p.email })),
noticeConflict: !begin.noticesTaken && eventsNotices.length ? { accountsVersions: begin.accountsNoticeVersions, eventsVersions: eventsNotices.map((n) => n.version - 1) } : null,
withTwoFactor: people.filter((p) => p.twoFactorEnabled).length,
messaging: await messagingNow(people),
};
}
async function messagingNow(people: Row[]) {
const status = await accountsMessaging();
return { email: status.email.ready, whatsapp: status.whatsapp.ready, whatsappTwoFactor: people.filter((p) => p.twoFactorEnabled && p.twoFactorMethod === 'whatsapp').length };
}
export type MoveReport = {
movedAt: string;
by: string;
@@ -262,6 +271,12 @@ export async function moveNewPeople(actor: string | null = null): Promise<{ move
/** The move. Throws MoveError when it doesn't finish; nothing changes for anyone then. */
export async function move(opts: { actor: { id: string; role: string; name?: string }; adminIds: string[]; keepAccountsNotices?: boolean; ip?: string | null }): Promise<MoveReport> {
const auth = await connected();
// 3.1.0: without email in Accounts nobody can get a code or a password link there, so nobody
// could sign in after the move. Set it up first (Settings → Sign-in → Email and WhatsApp).
const messaging = await accountsMessaging();
if (!messaging.email.ready) {
throw new MoveError("The church's Accounts can't send email yet, so people couldn't get their sign-in codes or password links there. Set up its email first (copy this site's, test it, save it), then move.", 'EMAIL_NOT_READY');
}
const running = await getSetting(RUNNING_KEY);
if (running && Date.now() - new Date(running).getTime() < 30 * 60e3) throw new MoveError('A move is already running.', 'RUNNING');
await setSetting(RUNNING_KEY, new Date().toISOString());
@@ -5,6 +5,7 @@ import { single } from '../paging';
import { authMode } from '../../accounts/mode';
import { check, move, MoveError, status, undo } from '../../accounts/move';
import { accounts, accountsLink, AccountsUnavailable } from '../../accounts/client';
import { accountsMessaging, eventsMessaging, sendToAccounts } from '../../accounts/messaging';
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
const prisma = require('../../config/db');
@@ -94,6 +95,7 @@ export const signInCheck = defineRoute({
admins: z.array(person.extend({ id: z.string() })),
noticeConflict: z.object({ accountsVersions: z.array(z.number()), eventsVersions: z.array(z.number()) }).nullable(),
withTwoFactor: z.number().int(),
messaging: z.object({ email: z.boolean(), whatsapp: z.boolean(), whatsappTwoFactor: z.number().int() }).describe('3.1.0: what Accounts can send; the move needs email'),
})),
async handler() {
return { data: await check().catch(asApiError) };
@@ -132,6 +134,103 @@ export const signInUndo = defineRoute({
},
});
// ─── Email and WhatsApp for Accounts (3.1.0) ────────────────────────────────
const messagingOverview = z.object({
events: z.object({
email: z.object({ host: z.string(), port: z.number().int(), secure: z.boolean(), user: z.string(), from: z.string(), hasPass: z.boolean() }).nullable(),
whatsapp: z.object({ instanceId: z.string(), hasToken: z.boolean() }).nullable(),
}).describe("This site's own settings, to copy (never the password or token)"),
accounts: z.object({
email: z.object({ ready: z.boolean(), host: z.string().nullable(), from: z.string().nullable() }),
whatsapp: z.object({ ready: z.boolean(), instanceId: z.string().nullable() }),
}).nullable().describe("What the church's Accounts can send (null: it can't be reached)"),
accountsError: z.string().nullable(),
});
export const signInMessaging = defineRoute({
method: 'get',
path: '/settings/sign-in/messaging',
tag: 'Accounts',
summary: "Email and WhatsApp: this site's, and what Accounts can send",
access: 'admin',
response: single(messagingOverview),
async handler() {
const events = await eventsMessaging();
try {
return { data: { events, accounts: await accountsMessaging(), accountsError: null } };
} catch (e) {
return { data: { events, accounts: null, accountsError: (e as Error).message } };
}
},
});
/** 082 123 4567 → +27821234567 (as Accounts keeps phone numbers). */
const toE164 = (raw: string) => {
const d = raw.replace(/\D/g, '');
if (raw.trim().startsWith('+')) return `+${d}`;
return d.startsWith('0') && d.length === 10 ? `+27${d.slice(1)}` : `+${d}`;
};
const messagingBody = z.object({
email: z.object({
host: z.string().trim().min(1).max(253),
port: z.number().int().min(1).max(65535),
secure: z.boolean(),
user: z.string().max(254),
from: z.string().trim().min(3).max(320),
pass: z.string().max(500).nullable().optional().describe("Blank: this site's own password"),
to: z.email().describe('Where the test email goes'),
}).optional(),
whatsapp: z.object({
instanceId: z.string().trim().min(1).max(200),
accessToken: z.string().max(500).nullable().optional().describe("Blank: this site's own token"),
to: z.string().trim().min(8).max(30).describe('The phone the test message goes to'),
}).optional(),
});
const messagingResult = z.object({ ok: z.boolean(), error: z.string().nullable(), saved: z.boolean() }).nullable();
const messagingAnswer = single(z.object({ email: messagingResult, whatsapp: messagingResult, status: z.object({ email: z.object({ ready: z.boolean(), host: z.string().nullable(), from: z.string().nullable() }), whatsapp: z.object({ ready: z.boolean(), instanceId: z.string().nullable() }) }) }));
async function messagingFor(body: z.infer<typeof messagingBody>, user: { id: string; role: string }, req: unknown, save: boolean) {
if (!body.email && !body.whatsapp) throw new ApiError('VALIDATION_FAILED', 'Give email or WhatsApp settings.');
const actor = (await prisma.user.findUnique({ where: { id: user.id }, select: { accountId: true } }))?.accountId ?? null;
const input = { ...(body.email ? { email: body.email } : {}), ...(body.whatsapp ? { whatsapp: { ...body.whatsapp, to: toE164(body.whatsapp.to) } } : {}) };
const out = await sendToAccounts(input, { save, actor }).catch(asApiError);
if (save) {
await logAdminAction({ actorId: user.id, actorRole: user.role, action: 'account_changed_in_accounts', targetType: 'setting', targetId: 'accounts_messaging', metadata: { email: out.email && { ok: out.email.ok, saved: out.email.saved, host: body.email?.host }, whatsapp: out.whatsapp && { ok: out.whatsapp.ok, saved: out.whatsapp.saved } }, ip: getClientIp(req) });
}
return { data: out };
}
export const signInMessagingTest = defineRoute({
method: 'post',
path: '/settings/sign-in/messaging/test',
tag: 'Accounts',
summary: 'Test email / WhatsApp settings through Accounts (nothing saved)',
description: "Accounts sends a test email to `email.to` and a WhatsApp message to `whatsapp.to` with the settings given. A blank password or token uses this site's own.",
access: 'admin',
body: messagingBody,
response: messagingAnswer,
async handler({ body, user, req }) {
return messagingFor(body, user!, req, false);
},
});
export const signInMessagingSave = defineRoute({
method: 'post',
path: '/settings/sign-in/messaging',
tag: 'Accounts',
summary: 'Save email / WhatsApp settings in Accounts (after a test)',
description: 'Accounts tests each part as /test does, and saves it only if its test worked.',
access: 'admin',
body: messagingBody,
response: messagingAnswer,
async handler({ body, user, req }) {
return messagingFor(body, user!, req, true);
},
});
// ─── An admin, for someone's account (sign-in through Accounts) ─────────────
const idParams = z.object({ id: z.uuid() });
@@ -58,6 +58,7 @@ const { signInGuard } = require('../../src/accounts/guard.ts');
const { protect } = require('../../src/middleware/authMiddleware.js');
const move = require('../../src/accounts/move.ts');
const mode = require('../../src/accounts/mode.ts');
const messaging = require('../../src/accounts/messaging.ts');
const { setAuthClientLoader } = require('../../src/accounts/client.ts');
const EVENTS_ID = '6d1f0b2c-8a3e-4c5d-9e7f-1a2b3c4d5e6f';
@@ -104,6 +105,10 @@ before(async () => {
await h.db.productLink.create({ data: { installId: EVENTS_ID, product: 'events', url: eventsUrl, publicKey: ed25519PublicToPem(generateEd25519().publicKey), secret: h.ctx.secrets.encrypt(secret), connectedAt: new Date() } });
await edb.productLink.create({ data: { installId: ACCOUNTS_ID, product: 'accounts', url: h.publicUrl, publicKey: 'x', secret: encrypt(secret), connectedAt: new Date(), updatedAt: new Date() } });
await edb.appSetting.create({ data: { key: 'hub_install_id', value: EVENTS_ID } });
// This site's own email settings (3.1.0: copied to Accounts before the move).
for (const [key, value] of Object.entries({ smtp_host: 'smtp.hope.test', smtp_port: '587', smtp_secure: 'false', smtp_user: 'events@hope.test', smtp_pass: 'events-mail-pass', smtp_from: 'events@hope.test' })) {
await edb.appSetting.create({ data: { key, value } });
}
// Events' people before the move.
await eventsUser({ id: ids.thandi, name: 'Thandi Mokoena', email: 'thandi@hope.test', password: await bcrypt.hash('Old-events-pass1', 4), newsEmail: true });
@@ -143,6 +148,34 @@ async function signInThroughEvents(browser: Browser, email: string, password: st
const me = (token: string) => fetch(`${eventsUrl}/api/v2/me`, { headers: { authorization: `Bearer ${token}` } });
describe('Accounts\' email before the move (3.1.0)', () => {
test('without email in Accounts, the check says so and the move is refused', async () => {
(h.messenger as unknown as { emailOn: boolean }).emailOn = false;
const r = await move.check();
assert.equal(r.messaging.email, false);
await assert.rejects(move.move({ actor: { id: ids.sam, role: 'admin' }, adminIds: [] }), (e: { code?: string }) => e.code === 'EMAIL_NOT_READY');
mode.forgetMode();
assert.equal(await mode.authMode(), 'local');
});
test('this site\'s SMTP is copied (its own password, never sent to the page), tested, then saved in Accounts', async () => {
const own = await messaging.eventsMessaging();
assert.deepEqual(own.email, { host: 'smtp.hope.test', port: 587, secure: false, user: 'events@hope.test', from: 'events@hope.test', hasPass: true });
const email = { host: own.email.host, port: own.email.port, secure: own.email.secure, user: own.email.user, from: own.email.from, pass: null, to: 'sam@hope.test' };
const tested = await messaging.sendToAccounts({ email }, { save: false, actor: null });
assert.deepEqual(tested.email, { ok: true, error: null, saved: false });
const tried = (h.messenger as unknown as { tried: { settings: { pass: string } }[] }).tried.at(-1)!;
assert.equal(tried.settings.pass, 'events-mail-pass', 'this site\'s own password, sealed on the way');
assert.equal(await h.ctx.settings.get('smtp_host'), null, 'a test saves nothing');
const saved = await messaging.sendToAccounts({ email }, { save: true, actor: null });
assert.equal(saved.email.saved, true);
assert.equal(await h.ctx.settings.get('smtp_pass'), 'events-mail-pass');
// (The in-memory messenger stands for a working SMTP from here.)
(h.messenger as unknown as { emailOn: boolean }).emailOn = true;
assert.equal((await messaging.accountsMessaging()).email.ready, true);
});
});
describe('moving Events\' sign-in to Accounts', () => {
test('the check counts people and writes nothing', async () => {
const r = await move.check();
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/events-frontend",
"version": "3.0.0",
"version": "3.1.0",
"private": true,
"scripts": {
"dev": "next dev",
@@ -0,0 +1,145 @@
"use client";
import React, { useEffect, useState } from "react";
import { Mail, MessageCircle } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { apiV2, type V2Result } from "@/lib/apiV2";
import { errorMessage } from "@/lib/utils";
type Overview = V2Result<"/settings/sign-in/messaging", "get">["data"];
type Answer = V2Result<"/settings/sign-in/messaging", "post">["data"];
type Result = { ok: boolean; error: string | null; saved: boolean } | null;
/**
* Email and WhatsApp for the church's Accounts (3.1.0): Accounts sends its own sign-in codes and
* password links, with its own settings, so they're set up before sign-in moves there. This site's
* own settings are offered to copy (its password and WAWP token stay on the server: leave the field
* blank to use them), tested through Accounts, and saved there only once the test worked.
*/
export function AccountsMessaging({ onReady }: { onReady: (ready: { email: boolean; whatsapp: boolean }) => void }) {
const { token, user } = useAuth();
const [data, setData] = useState<Overview | null>(null);
const [err, setErr] = useState<string | null>(null);
const [email, setEmail] = useState({ host: "", port: "587", secure: false, user: "", from: "", pass: "", to: "" });
const [wa, setWa] = useState({ instanceId: "", accessToken: "", to: "" });
const [emailResult, setEmailResult] = useState<Result>(null);
const [waResult, setWaResult] = useState<Result>(null);
const [testedEmail, setTestedEmail] = useState<string | null>(null);
const [testedWa, setTestedWa] = useState<string | null>(null);
const [busy, setBusy] = useState<string | null>(null);
const load = () => {
if (!token) return;
apiV2("get", "/settings/sign-in/messaging", { authToken: token })
.then(({ data: d }) => {
setData(d);
if (d.accounts) onReady({ email: d.accounts.email.ready, whatsapp: d.accounts.whatsapp.ready });
const e = d.events.email;
if (e) setEmail((x) => (x.host ? x : { ...x, host: e.host, port: String(e.port), secure: e.secure, user: e.user, from: e.from }));
if (d.events.whatsapp) setWa((x) => (x.instanceId ? x : { ...x, instanceId: d.events.whatsapp!.instanceId }));
})
.catch((e) => setErr(errorMessage(e) || "Could not load the email settings."));
};
// eslint-disable-next-line react-hooks/exhaustive-deps -- once per sign-in
useEffect(load, [token]);
useEffect(() => {
setEmail((x) => (x.to ? x : { ...x, to: user?.email || "" }));
setWa((x) => (x.to ? x : { ...x, to: user?.phoneNumber || "" }));
}, [user]);
if (!token) return null;
if (!data) return err ? <p className="text-sm text-red-700">{err}</p> : <p className="text-sm text-gray-500">Loading email settings…</p>;
const emailKey = JSON.stringify({ ...email, to: undefined });
const waKey = JSON.stringify({ ...wa, to: undefined });
const emailBody = () => ({ email: { host: email.host, port: parseInt(email.port, 10) || 587, secure: email.secure, user: email.user, from: email.from, pass: email.pass || null, to: email.to } });
const waBody = () => ({ whatsapp: { instanceId: wa.instanceId, accessToken: wa.accessToken || null, to: wa.to } });
const run = async (key: string, save: boolean, body: object, after: (a: Answer) => void) => {
setBusy(key);
setErr(null);
try {
const { data: a } = save
? await apiV2("post", "/settings/sign-in/messaging", { authToken: token, body: body as never })
: await apiV2("post", "/settings/sign-in/messaging/test", { authToken: token, body: body as never });
after(a);
setData((d) => (d ? { ...d, accounts: { email: a.status.email, whatsapp: a.status.whatsapp }, accountsError: null } : d));
onReady({ email: a.status.email.ready, whatsapp: a.status.whatsapp.ready });
} catch (e) {
setErr(errorMessage(e) || "That didn't work.");
}
setBusy(null);
};
const acc = data.accounts;
const input = "w-full rounded-lg border px-3 py-2 text-sm";
const line = (r: Result, what: string) => r && (
<p className={`text-sm ${r.ok ? "text-green-800" : "text-red-800"}`} role="status">
{r.ok ? (r.saved ? `Saved in Accounts: ${what} works there now.` : `The test ${what} went. Check it arrived, then save.`) : `The test didn't work: ${r.error}`}
</p>
);
return (
<section className="border rounded-xl p-4 space-y-4">
<div>
<h3 className="font-medium">Email and WhatsApp for the church&apos;s sign-in</h3>
<p className="text-sm text-gray-600">Accounts sends sign-in codes and password links itself, with its own settings. Without email there, nobody can sign in after the move.</p>
</div>
{data.accountsError ? (
<p className="text-sm text-red-700">Accounts can&apos;t be reached: {data.accountsError}</p>
) : acc && (
<ul className="text-sm space-y-1">
<li className="flex items-center gap-2"><Mail className="h-4 w-4" aria-hidden /> Email: {acc.email.ready ? <span className="text-green-800">works{acc.email.from ? ` (from ${acc.email.from})` : ""}</span> : <span className="font-medium text-red-800">not set up</span>}</li>
<li className="flex items-center gap-2"><MessageCircle className="h-4 w-4" aria-hidden /> WhatsApp: {acc.whatsapp.ready ? <span className="text-green-800">works</span> : <span className="text-amber-800">not set up (WhatsApp codes then go by email)</span>}</li>
</ul>
)}
{err && <p className="text-sm text-red-800">{err}</p>}
<details open={!!acc && !acc.email.ready} className="rounded-lg border p-3">
<summary className="cursor-pointer text-sm font-medium">{acc?.email.ready ? "Change Accounts' email" : "Set up Accounts' email"}{data.events.email ? " (copied from this site)" : ""}</summary>
<div className="mt-3 grid gap-3 md:grid-cols-2">
<label className="text-sm">SMTP server<input className={input} value={email.host} onChange={(e) => setEmail({ ...email, host: e.target.value })} /></label>
<label className="text-sm">Port<input className={input} inputMode="numeric" value={email.port} onChange={(e) => setEmail({ ...email, port: e.target.value })} /></label>
<label className="text-sm">User name<input className={input} value={email.user} onChange={(e) => setEmail({ ...email, user: e.target.value })} autoComplete="off" /></label>
<label className="text-sm">Password<input className={input} type="password" value={email.pass} onChange={(e) => setEmail({ ...email, pass: e.target.value })} autoComplete="new-password" placeholder={data.events.email?.hasPass ? "Leave blank to use this site's password" : ""} /></label>
<label className="text-sm">Send from<input className={input} value={email.from} onChange={(e) => setEmail({ ...email, from: e.target.value })} /></label>
<label className="flex items-center gap-2 text-sm md:mt-6"><input type="checkbox" checked={email.secure} onChange={(e) => setEmail({ ...email, secure: e.target.checked })} /> TLS from the start (port 465)</label>
<label className="text-sm md:col-span-2">Send the test email to<input className={input} type="email" value={email.to} onChange={(e) => setEmail({ ...email, to: e.target.value })} /></label>
</div>
<div className="mt-3 flex flex-wrap gap-2">
<button type="button" className="px-3 py-2 rounded-lg border text-sm" disabled={!!busy || !email.host || !email.to}
onClick={() => run("email-test", false, emailBody(), (a) => { setEmailResult(a.email); if (a.email?.ok) setTestedEmail(emailKey); })}>
{busy === "email-test" ? "Sending…" : "Send a test email"}
</button>
<button type="button" className="px-3 py-2 rounded-lg bg-brand-600 text-white text-sm disabled:opacity-50" disabled={!!busy || testedEmail !== emailKey}
title={testedEmail !== emailKey ? "Send a test with these settings first" : undefined}
onClick={() => run("email-save", true, emailBody(), (a) => setEmailResult(a.email))}>
{busy === "email-save" ? "Saving…" : "Save in Accounts"}
</button>
</div>
<div className="mt-2">{line(emailResult, "email")}</div>
</details>
<details className="rounded-lg border p-3">
<summary className="cursor-pointer text-sm font-medium">{acc?.whatsapp.ready ? "Change Accounts' WhatsApp (WAWP)" : "Set up Accounts' WhatsApp (WAWP), optional"}{data.events.whatsapp ? " (copied from this site)" : ""}</summary>
<div className="mt-3 grid gap-3 md:grid-cols-2">
<label className="text-sm">WAWP instance id<input className={input} value={wa.instanceId} onChange={(e) => setWa({ ...wa, instanceId: e.target.value })} /></label>
<label className="text-sm">WAWP access token<input className={input} type="password" value={wa.accessToken} onChange={(e) => setWa({ ...wa, accessToken: e.target.value })} autoComplete="new-password" placeholder={data.events.whatsapp?.hasToken ? "Leave blank to use this site's token" : ""} /></label>
<label className="text-sm md:col-span-2">Send the test message to<input className={input} type="tel" value={wa.to} onChange={(e) => setWa({ ...wa, to: e.target.value })} placeholder="082 123 4567" /></label>
</div>
<div className="mt-3 flex flex-wrap gap-2">
<button type="button" className="px-3 py-2 rounded-lg border text-sm" disabled={!!busy || !wa.instanceId || !wa.to}
onClick={() => run("wa-test", false, waBody(), (a) => { setWaResult(a.whatsapp); if (a.whatsapp?.ok) setTestedWa(waKey); })}>
{busy === "wa-test" ? "Sending…" : "Send a test WhatsApp"}
</button>
<button type="button" className="px-3 py-2 rounded-lg bg-brand-600 text-white text-sm disabled:opacity-50" disabled={!!busy || testedWa !== waKey}
title={testedWa !== waKey ? "Send a test with these settings first" : undefined}
onClick={() => run("wa-save", true, waBody(), (a) => setWaResult(a.whatsapp))}>
{busy === "wa-save" ? "Saving…" : "Save in Accounts"}
</button>
</div>
<div className="mt-2">{line(waResult, "WhatsApp")}</div>
</details>
</section>
);
}
@@ -5,6 +5,7 @@ import { LogIn } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { apiV2, type V2Result } from "@/lib/apiV2";
import { errorMessage } from "@/lib/utils";
import { AccountsMessaging } from "@/components/admin/AccountsMessaging";
type Status = V2Result<"/settings/sign-in", "get">["data"];
type Check = V2Result<"/settings/sign-in/check", "post">["data"];
@@ -26,6 +27,8 @@ export function SignInTab({ active }: { active: boolean }) {
const [keepAccountsNotices, setKeepAccountsNotices] = useState(false);
const [busy, setBusy] = useState<string | null>(null);
const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null);
// 3.1.0: what Accounts can send (the move needs its email).
const [sending, setSending] = useState<{ email: boolean; whatsapp: boolean } | null>(null);
useEffect(() => {
if (!active || !token) return;
@@ -98,6 +101,8 @@ export function SignInTab({ active }: { active: boolean }) {
{msg && <p className={`text-sm rounded-lg px-3 py-2 ${msg.ok ? "bg-green-50 text-green-800" : "bg-red-50 text-red-800"}`} role="status">{msg.text}</p>}
{status.accountsConnected && <AccountsMessaging onReady={setSending} />}
{status.mode === "accounts" ? (
<section className="border rounded-xl p-4 space-y-3">
<p className="text-sm"><span className="font-medium">Through Accounts</span>{status.accountsUrl ? <> at <a className="underline" href={status.accountsUrl} target="_blank" rel="noreferrer">{status.accountsUrl.replace(/^https?:\/\//, "")}</a></> : null}{status.movedAt ? `, since ${when(status.movedAt)}` : ""}.</p>
@@ -158,7 +163,13 @@ export function SignInTab({ active }: { active: boolean }) {
<label className="flex items-center gap-2 text-sm py-0.5 text-gray-400"><input type="radio" name="notice" disabled checked={!keepAccountsNotices} readOnly /> Use Cross Events&apos; notice (remove Accounts&apos; notice in Accounts first)</label>
</fieldset>
)}
<button type="button" onClick={runMove} disabled={!!busy || (!!checked.noticeConflict && !keepAccountsNotices)} className="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium disabled:opacity-50">
{!(sending?.email ?? checked.messaging.email) && (
<p className="text-sm font-medium text-red-800">Set up Accounts&apos; email above first (copy this site&apos;s, test it, save it): without it nobody could get a sign-in code or password link after the move.</p>
)}
{!!checked.messaging.whatsappTwoFactor && !(sending?.whatsapp ?? checked.messaging.whatsapp) && (
<p className="text-sm text-amber-800">{checked.messaging.whatsappTwoFactor} people get their codes by WhatsApp, which Accounts can&apos;t send yet: their codes will go by email until you set it up.</p>
)}
<button type="button" onClick={runMove} disabled={!!busy || (!!checked.noticeConflict && !keepAccountsNotices) || !(sending?.email ?? checked.messaging.email)} className="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium disabled:opacity-50">
{busy === "move" ? "Moving… (don't close this page)" : "Move sign-in to Accounts"}
</button>
<p className="text-xs text-gray-500">Pick a quiet time. It takes about a minute; people already signed in stay signed in. You can undo it for 14 days.</p>
@@ -72554,6 +72554,29 @@
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"messaging": {
"type": "object",
"properties": {
"email": {
"type": "boolean"
},
"whatsapp": {
"type": "boolean"
},
"whatsappTwoFactor": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [
"email",
"whatsapp",
"whatsappTwoFactor"
],
"additionalProperties": false,
"description": "3.1.0: what Accounts can send; the move needs email"
}
},
"required": [
@@ -72565,7 +72588,8 @@
"skipped",
"admins",
"noticeConflict",
"withTwoFactor"
"withTwoFactor",
"messaging"
],
"additionalProperties": false
}
@@ -72870,6 +72894,787 @@
}
}
},
"/settings/sign-in/messaging": {
"get": {
"tags": [
"Accounts"
],
"summary": "Email and WhatsApp: this site's, and what Accounts can send",
"description": "**Who:** Admins only.",
"operationId": "getSettingsSign-inMessaging",
"security": [
{
"bearerAuth": []
}
],
"parameters": [],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"events": {
"type": "object",
"properties": {
"email": {
"anyOf": [
{
"type": "object",
"properties": {
"host": {
"type": "string"
},
"port": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"secure": {
"type": "boolean"
},
"user": {
"type": "string"
},
"from": {
"type": "string"
},
"hasPass": {
"type": "boolean"
}
},
"required": [
"host",
"port",
"secure",
"user",
"from",
"hasPass"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"whatsapp": {
"anyOf": [
{
"type": "object",
"properties": {
"instanceId": {
"type": "string"
},
"hasToken": {
"type": "boolean"
}
},
"required": [
"instanceId",
"hasToken"
],
"additionalProperties": false
},
{
"type": "null"
}
]
}
},
"required": [
"email",
"whatsapp"
],
"additionalProperties": false,
"description": "This site's own settings, to copy (never the password or token)"
},
"accounts": {
"anyOf": [
{
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"ready": {
"type": "boolean"
},
"host": {
"type": [
"string",
"null"
]
},
"from": {
"type": [
"string",
"null"
]
}
},
"required": [
"ready",
"host",
"from"
],
"additionalProperties": false
},
"whatsapp": {
"type": "object",
"properties": {
"ready": {
"type": "boolean"
},
"instanceId": {
"type": [
"string",
"null"
]
}
},
"required": [
"ready",
"instanceId"
],
"additionalProperties": false
}
},
"required": [
"email",
"whatsapp"
],
"additionalProperties": false
},
{
"type": "null"
}
],
"description": "What the church's Accounts can send (null: it can't be reached)"
},
"accountsError": {
"type": [
"string",
"null"
]
}
},
"required": [
"events",
"accounts",
"accountsError"
],
"additionalProperties": false
}
},
"required": [
"data"
],
"additionalProperties": false
}
}
}
},
"401": {
"description": "Not signed in (UNAUTHENTICATED)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not allowed for this role (FORBIDDEN)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"tags": [
"Accounts"
],
"summary": "Save email / WhatsApp settings in Accounts (after a test)",
"description": "Accounts tests each part as /test does, and saves it only if its test worked.\n\n**Who:** Admins only.",
"operationId": "postSettingsSign-inMessaging",
"security": [
{
"bearerAuth": []
}
],
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"host": {
"type": "string",
"minLength": 1,
"maxLength": 253
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535
},
"secure": {
"type": "boolean"
},
"user": {
"type": "string",
"maxLength": 254
},
"from": {
"type": "string",
"minLength": 3,
"maxLength": 320
},
"pass": {
"description": "Blank: this site's own password",
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"to": {
"type": "string",
"format": "email",
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
"description": "Where the test email goes"
}
},
"required": [
"host",
"port",
"secure",
"user",
"from",
"to"
]
},
"whatsapp": {
"type": "object",
"properties": {
"instanceId": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"accessToken": {
"description": "Blank: this site's own token",
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"to": {
"type": "string",
"minLength": 8,
"maxLength": 30,
"description": "The phone the test message goes to"
}
},
"required": [
"instanceId",
"to"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"email": {
"anyOf": [
{
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"error": {
"type": [
"string",
"null"
]
},
"saved": {
"type": "boolean"
}
},
"required": [
"ok",
"error",
"saved"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"whatsapp": {
"anyOf": [
{
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"error": {
"type": [
"string",
"null"
]
},
"saved": {
"type": "boolean"
}
},
"required": [
"ok",
"error",
"saved"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"status": {
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"ready": {
"type": "boolean"
},
"host": {
"type": [
"string",
"null"
]
},
"from": {
"type": [
"string",
"null"
]
}
},
"required": [
"ready",
"host",
"from"
],
"additionalProperties": false
},
"whatsapp": {
"type": "object",
"properties": {
"ready": {
"type": "boolean"
},
"instanceId": {
"type": [
"string",
"null"
]
}
},
"required": [
"ready",
"instanceId"
],
"additionalProperties": false
}
},
"required": [
"email",
"whatsapp"
],
"additionalProperties": false
}
},
"required": [
"email",
"whatsapp",
"status"
],
"additionalProperties": false
}
},
"required": [
"data"
],
"additionalProperties": false
}
}
}
},
"400": {
"description": "Validation failed (VALIDATION_FAILED)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Not signed in (UNAUTHENTICATED)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not allowed for this role (FORBIDDEN)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/settings/sign-in/messaging/test": {
"post": {
"tags": [
"Accounts"
],
"summary": "Test email / WhatsApp settings through Accounts (nothing saved)",
"description": "Accounts sends a test email to `email.to` and a WhatsApp message to `whatsapp.to` with the settings given. A blank password or token uses this site's own.\n\n**Who:** Admins only.",
"operationId": "postSettingsSign-inMessagingTest",
"security": [
{
"bearerAuth": []
}
],
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"host": {
"type": "string",
"minLength": 1,
"maxLength": 253
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535
},
"secure": {
"type": "boolean"
},
"user": {
"type": "string",
"maxLength": 254
},
"from": {
"type": "string",
"minLength": 3,
"maxLength": 320
},
"pass": {
"description": "Blank: this site's own password",
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"to": {
"type": "string",
"format": "email",
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
"description": "Where the test email goes"
}
},
"required": [
"host",
"port",
"secure",
"user",
"from",
"to"
]
},
"whatsapp": {
"type": "object",
"properties": {
"instanceId": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"accessToken": {
"description": "Blank: this site's own token",
"anyOf": [
{
"type": "string",
"maxLength": 500
},
{
"type": "null"
}
]
},
"to": {
"type": "string",
"minLength": 8,
"maxLength": 30,
"description": "The phone the test message goes to"
}
},
"required": [
"instanceId",
"to"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"email": {
"anyOf": [
{
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"error": {
"type": [
"string",
"null"
]
},
"saved": {
"type": "boolean"
}
},
"required": [
"ok",
"error",
"saved"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"whatsapp": {
"anyOf": [
{
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"error": {
"type": [
"string",
"null"
]
},
"saved": {
"type": "boolean"
}
},
"required": [
"ok",
"error",
"saved"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"status": {
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"ready": {
"type": "boolean"
},
"host": {
"type": [
"string",
"null"
]
},
"from": {
"type": [
"string",
"null"
]
}
},
"required": [
"ready",
"host",
"from"
],
"additionalProperties": false
},
"whatsapp": {
"type": "object",
"properties": {
"ready": {
"type": "boolean"
},
"instanceId": {
"type": [
"string",
"null"
]
}
},
"required": [
"ready",
"instanceId"
],
"additionalProperties": false
}
},
"required": [
"email",
"whatsapp"
],
"additionalProperties": false
}
},
"required": [
"email",
"whatsapp",
"status"
],
"additionalProperties": false
}
},
"required": [
"data"
],
"additionalProperties": false
}
}
}
},
"400": {
"description": "Validation failed (VALIDATION_FAILED)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Not signed in (UNAUTHENTICATED)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not allowed for this role (FORBIDDEN)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/users/{id}/account/reset-two-factor": {
"post": {
"tags": [
+317
View File
@@ -7606,6 +7606,54 @@ export interface paths {
patch?: never;
trace?: never;
};
"/settings/sign-in/messaging": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/**
* Email and WhatsApp: this site's, and what Accounts can send
* @description **Who:** Admins only.
*/
get: operations["getSettingsSign-inMessaging"];
put?: never;
/**
* Save email / WhatsApp settings in Accounts (after a test)
* @description Accounts tests each part as /test does, and saves it only if its test worked.
*
* **Who:** Admins only.
*/
post: operations["postSettingsSign-inMessaging"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/settings/sign-in/messaging/test": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* Test email / WhatsApp settings through Accounts (nothing saved)
* @description Accounts sends a test email to `email.to` and a WhatsApp message to `whatsapp.to` with the settings given. A blank password or token uses this site's own.
*
* **Who:** Admins only.
*/
post: operations["postSettingsSign-inMessagingTest"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/users/{id}/account/reset-two-factor": {
parameters: {
query?: never;
@@ -39892,6 +39940,12 @@ export interface operations {
eventsVersions: number[];
} | null;
withTwoFactor: number;
/** @description 3.1.0: what Accounts can send; the move needs email */
messaging: {
email: boolean;
whatsapp: boolean;
whatsappTwoFactor: number;
};
};
};
};
@@ -40044,6 +40098,269 @@ export interface operations {
};
};
};
"getSettingsSign-inMessaging": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
data: {
/** @description This site's own settings, to copy (never the password or token) */
events: {
email: {
host: string;
port: number;
secure: boolean;
user: string;
from: string;
hasPass: boolean;
} | null;
whatsapp: {
instanceId: string;
hasToken: boolean;
} | null;
};
/** @description What the church's Accounts can send (null: it can't be reached) */
accounts: {
email: {
ready: boolean;
host: string | null;
from: string | null;
};
whatsapp: {
ready: boolean;
instanceId: string | null;
};
} | null;
accountsError: string | null;
};
};
};
};
/** @description Not signed in (UNAUTHENTICATED) */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not allowed for this role (FORBIDDEN) */
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
};
};
"postSettingsSign-inMessaging": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
email?: {
host: string;
port: number;
secure: boolean;
user: string;
from: string;
/** @description Blank: this site's own password */
pass?: string | null;
/**
* Format: email
* @description Where the test email goes
*/
to: string;
};
whatsapp?: {
instanceId: string;
/** @description Blank: this site's own token */
accessToken?: string | null;
/** @description The phone the test message goes to */
to: string;
};
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
data: {
email: {
ok: boolean;
error: string | null;
saved: boolean;
} | null;
whatsapp: {
ok: boolean;
error: string | null;
saved: boolean;
} | null;
status: {
email: {
ready: boolean;
host: string | null;
from: string | null;
};
whatsapp: {
ready: boolean;
instanceId: string | null;
};
};
};
};
};
};
/** @description Validation failed (VALIDATION_FAILED) */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not signed in (UNAUTHENTICATED) */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not allowed for this role (FORBIDDEN) */
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
};
};
"postSettingsSign-inMessagingTest": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
email?: {
host: string;
port: number;
secure: boolean;
user: string;
from: string;
/** @description Blank: this site's own password */
pass?: string | null;
/**
* Format: email
* @description Where the test email goes
*/
to: string;
};
whatsapp?: {
instanceId: string;
/** @description Blank: this site's own token */
accessToken?: string | null;
/** @description The phone the test message goes to */
to: string;
};
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
data: {
email: {
ok: boolean;
error: string | null;
saved: boolean;
} | null;
whatsapp: {
ok: boolean;
error: string | null;
saved: boolean;
} | null;
status: {
email: {
ready: boolean;
host: string | null;
from: string | null;
};
whatsapp: {
ready: boolean;
instanceId: string | null;
};
};
};
};
};
};
/** @description Validation failed (VALIDATION_FAILED) */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not signed in (UNAUTHENTICATED) */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not allowed for this role (FORBIDDEN) */
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
};
};
"postUsersIdAccountReset-two-factor": {
parameters: {
query?: never;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/events",
"version": "3.0.0",
"version": "3.1.0",
"main": "index.js",
"scripts": {
"dev:backend": "cd backend && npm run dev",