LifeMate — Personal, Family & Learning Companion
docs(sms): record LifeGuide Kavenegar template and secret-safe QA rollout gates
davoodmehraban89 committed
Oct 15, 2026 at 00:58 UTC
fc3c0e8a7831920307e0d26b738a1e11104d2659
1 file changed
+59
docs/operations/KAVENEGAR_SMS_SETUP.md
new
+59
@@ -0,0 +1,59 @@
1
+# LifeGuide — Kavenegar VerifyLookup SMS OTP configuration (QA only)
2
+
3
+Status: **ADAPTER SOURCE PREPARED, LIVE SMS DISABLED / UNVERIFIED**
4
+Prepared: 2026-10-15
5
+Source branch: `infra/lifeguide-supabase-qa`
6
+Provider confirmed by owner screenshots: Kavenegar `console.kavenegar.com`. Owner's masked API key is visible only in their own authenticated console; it was **not retrieved or stored**.
7
+
8
+## Exact pattern to create in Kavenegar console
9
+
10
+Path: اعتبارسنجی → ایجاد الگوی جدید
11
+
12
+| Kavenegar field | QA / LifeGuide value |
13
+| --- | --- |
14
+| نوع استفاده | موبایل اپلیکیشن |
15
+| نام الگو (template) | `lifeguideotp` |
16
+| نوع ارسال | پیامک |
17
+| ارسال مجدد با مسیر جایگزین | غیرفعال |
18
+| متن الگو | See below |
19
+
20
+```text
21
+کد تأیید LifeGuide: %token
22
+
23
+اعتبار کد: ۵ دقیقه
24
+این کد را در اختیار دیگران قرار ندهید.
25
+```
26
+
27
+- Keep the literal **`%token`** intact. Its value is generated server-side as a six-digit number (may have a leading zero).
28
+- Name of system **LifeGuide** is included. Provider must approve the SMS template before sending is enabled.
29
+- Do **not** paste the API key, reveal the key with the eye icon, copy the key into chat, screenshots, Flutter, PWA or public GitHub.
30
+- Account balance in owner screenshot is 50,000 rials; that is a **finite prepaid balance**, not free SMS. No actual SMS should be sent during preparations without owner approval for charged sends.
31
+
32
+Official API documentation:
33
+- https://github.com/kavenegar/kavenegar-node — `VerifyLookup({ receptor, token, template })`
34
+- https://www.postman.com/kavenegarrestapi/kavenegar-s-public-workspace/documentation/v5ppwag/kavenegar-rest-api — endpoint `GET /v1/<API-KEY>/verify/lookup.json` with `receptor`, `token`, `template`, optional `type=sms`.
35
+
36
+## Actual code preparation
37
+
38
+- Dedicated backend module: `backend/src/kavenegar_sms.js`, selected only with explicit `SMS_PROVIDER=kavenegar`.
39
+- `backend/src/auth_delivery.js` retains the original disabled/default and HTTPS webhook behavior; it is **not** switched on by default.
40
+- Example environment keys:
41
+ - `SMS_PROVIDER=kavenegar`
42
+ - `KAVENEGAR_TEMPLATE=lifeguideotp`
43
+ - `KAVENEGAR_API_KEY=<secret value in server/secret manager ONLY>`
44
+- Adapter restricts to Iranian mobile numbers normalized by existing LifeGuide `normalizePhone()` as `+989XXXXXXXXX`; Kavenegar receives `09XXXXXXXXX`.
45
+- Fixed official HTTPS API host, redirect disabled, 10s maximum timeout, sanitized provider errors, no provider response/error body in logs, no automatic retries (Kavenegar `VerifyLookup` has **no idempotency key**, so retry could produce duplicate and charge again).
46
+- A provider return status 200 is **acceptance only**, never proof of handset delivery. Failure response 200 with `return.status != 200` is treated as failed.
47
+- LifeGuide's current original auth flow supplies 6-digit OTP, 5-minute expiry, recipient request limits, maximum failed attempts, and independent session checks. This adapter is **delivery only** and must never issue sessions or bypass guardian authorization.
48
+
49
+## Gates remaining
50
+
51
+1. Owner completes/obtains approval for `lifeguideotp` pattern. Only ask for the pattern **name and approval status**, no secret.
52
+2. CI must confirm synthetic mocked transport tests, syntax/security and all Backend regression tests on the isolated branch. No live provider API or real phone send is exercised by mocked tests.
53
+3. Prepare an **approved secure backend runtime** (existing Node/Express currently has no online host) and separate Supabase QA application schema/auth authorization parity. The Supabase `LifeGuide-QA` database plus `lifeguide-qa-health` probe are **not** a functioning family API.
54
+4. Put Kavenegar key in a **private secret manager** for that runtime only, after owner approves credential placement. Never read key back to chat or logs.
55
+5. Obtain separate owner approval for **one real paid SMS** to an owner-controlled test phone. Check approval of pattern, actual reception, repeat/expired code behavior and sanitized provider response; record no phone/OTP in report.
56
+6. Only after that and successful API integration separately discuss switching public `app.lifeguide.ir`/Android/PWA or releasing production.
57
+7. Confirm provider reachability and permitted access from the final hosting environment; do not assume foreign server can reach Kavenegar API.
58
+
59
+This preparation changes neither Supabase QA secret configuration nor the live `app.lifeguide.ir` deployment. The original SQL application tables, Android/Safari tests and real SMS remain **UNVERIFIED**.