@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / a853c6a
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 17:00 UTC

fix: add safe live-login network diagnostics and QA coverage

Davood Mehraban committed Oct 11, 2026 at 13:30 UTC a853c6a6ef324ddf9ba1503498cf26214c8d7b27
7 files changed +110 -3
.github/workflows/quality.yml
+3 -1
@@ -74,6 +74,8 @@ jobs:
74 run: node scripts/identity-wave5c-check.mjs
75 - name: Finora branding and login invariants
76 run: node scripts/branding-login-check.mjs
77 + - name: Login connectivity diagnostics
78 + run: node scripts/login-connectivity-check.mjs
79 - name: Office Slice C1 invariants
80 run: node scripts/office-slice-c1-check.mjs
81 - name: Office Slice C2 invariants
@@ -111,7 +113,7 @@ jobs:
113 - name: Real DOM smoke
114 run: |
115 python3 -m http.server 4173 >/tmp/finora-http.log 2>&1 &
114 - npx playwright test scripts/dom-smoke.spec.js scripts/platform-office.spec.js scripts/enterprise-license.spec.js scripts/enterprise-role.spec.js scripts/enterprise-invitation.spec.js scripts/enterprise-org-ux.spec.js scripts/identity-wave5a.spec.js scripts/identity-wave5b.spec.js scripts/identity-wave5c.spec.js scripts/branding-login.spec.js scripts/shell-scroll-ownership.spec.js scripts/office-slice-c1.spec.js scripts/office-slice-c2.spec.js scripts/office-slice-c3.spec.js scripts/office-slice-c4.spec.js scripts/office-slice-c5.spec.js scripts/office-slice-c6.spec.js scripts/office-slice-c7.spec.js scripts/office-slice-c8.spec.js scripts/office-slice-c8-runtime.spec.js scripts/request-workflow-d2.spec.js scripts/request-workflow-d3b.spec.js scripts/request-workflow-d3c.spec.js scripts/request-workflow-d4a.spec.js scripts/taxpayer-print.spec.js scripts/chart-completeness.spec.js scripts/accounting-p0-journal.spec.js scripts/ux-hardening-r2.spec.js scripts/pages-artifact.spec.js --reporter=line --workers=1
116 + npx playwright test scripts/dom-smoke.spec.js scripts/platform-office.spec.js scripts/enterprise-license.spec.js scripts/enterprise-role.spec.js scripts/enterprise-invitation.spec.js scripts/enterprise-org-ux.spec.js scripts/identity-wave5a.spec.js scripts/identity-wave5b.spec.js scripts/identity-wave5c.spec.js scripts/branding-login.spec.js scripts/login-connectivity.spec.js scripts/shell-scroll-ownership.spec.js scripts/office-slice-c1.spec.js scripts/office-slice-c2.spec.js scripts/office-slice-c3.spec.js scripts/office-slice-c4.spec.js scripts/office-slice-c5.spec.js scripts/office-slice-c6.spec.js scripts/office-slice-c7.spec.js scripts/office-slice-c8.spec.js scripts/office-slice-c8-runtime.spec.js scripts/request-workflow-d2.spec.js scripts/request-workflow-d3b.spec.js scripts/request-workflow-d3c.spec.js scripts/request-workflow-d4a.spec.js scripts/taxpayer-print.spec.js scripts/chart-completeness.spec.js scripts/accounting-p0-journal.spec.js scripts/ux-hardening-r2.spec.js scripts/pages-artifact.spec.js --reporter=line --workers=1
117
118 identity-wave5a-database:
119 runs-on: ubuntu-latest
PROJECT_STATE.md
+7
@@ -170,3 +170,10 @@ Owner requested implementation to continue autonomously and precise owner-only s
170
171
172 2026-10-11 verified deployment checkpoint: PR #66 head 67081d8c26253c0413bf014213589066b8ad6728 passed GitHub Quality run 38117668618 (including Stripe Edge 26-case authorization test, Golden accounting, Real DOM) and Security run 38117668637. Merged on main as 70addfe731524341f70115d85451b9dacfb1aaf9. Deployed only the fail-closed Supabase Edge Function finora-stripe-qa-read to verified ACTIVE_HEALTHY Finora project hcsixhqbyuhpshfwqpjx; deployment function ID 1ba946df-11ee-42d1-b86a-3e4b27331b10, version=1, ACTIVE, verify_jwt=true, inspected deployed index.ts + handler.mjs. No schema/RLS/auth/role, payment, user/financial-record or UI mutation. An independent unauthenticated HTTP 401 probe was ATTEMPTED but could not be completed due DNS/network fetch failures from remote PC/container; do not claim 401 live verified. IMPORTANT: no restricted Stripe sandbox key or user allowlist has been provisioned through these tools, so function intentionally returns no sandbox data; direct Finora backend-to-Stripe request and authenticated real user session remain NOT VERIFIED. The owner must privately set STRIPE_SANDBOX_RESTRICTED_KEY (rk_test_, Invoices:Read, all other permissions None) and FINORA_STRIPE_QA_ALLOWED_USER_ID (tester's Auth User UID) in Supabase Edge Function Secrets, without ever sharing values in chat/repo. Next: authenticated end-to-end invoke from approved test user, verify retrieved synthetic Stripe sandbox invoice amount=1250 USD minor units, detect 401/403 for unauthorized actor, confirm no production accounting effect.
173 +
174 +## 2026-10-11 urgent login outage triage
175 +Owner reports login blocked with generic 'check internet/VPN' network error on live Finora. Priority supersedes Stripe rollout. Read-only baseline: origin/main 459d8cfc368fbebf1a5a26f7e7abe1c5e01c4bba; Supabase project ACTIVE_HEALTHY and public key current/enabled; two Chromium live-site synthetic invalid-user password token requests returned expected HTTP 400 invalid_credentials (factoreasy.ir and GitHub Pages), no JS page errors. Windows PC GET site HTTP 200 and DNS resolves Supabase; unauthenticated health without public key 401 as expected. User-side regional/ISP reachability NOT VERIFIED. Do not alter passwords, accounts, schema, auth settings, token policy, or live financial data. First deliver honest diagnostic UI and explain that platform-side working does not verify user's ISP route; public proxy or new Cloudflare Worker/DNS/auth transport is separately security-and-cost approved work.
176 +
177 +
178 +2026-10-11 login diagnostic implementation: added explicit '????? ????? ?? ???? ????' action on login screen, credential-free parallel same-origin manifest + GoTrue /auth/v1/health (publishable key) probe with bounded 12s timeout, stable AUTH_OK/AUTH_UNREACHABLE/AUTH_TIMEOUT/AUTH_HTTP_NNN/SITE_UNREACHABLE statuses and automatic probe when password login rejects due network. Preserved existing sign-in policy, passwords, and Supabase endpoint. Bumped core.js cache key; added login-connectivity.js. Verified on local source AND Pages artifact: Playwright 3/3 diagnostics PASS each; syntax check 54 JS+50 MJS PASS; static diagnostic check PASS; branding/login PASS; golden accounting journey PASS; site build PASS. Live browser fake invalid account got real GoTrue HTTP 400 invalid_credentials from both site origins (client-to-Supabase working from remote Windows); user network route NOT VERIFIED and restored login NOT CLAIMED. Cloudflare DNS for factoreasy.ir is DNS-only; routing a new public proxy would add a security boundary, require approvals/cost checks and must NOT be silently enabled. Next: PR CI and gated Pages exact SHA publication; user to click new button on affected network and share status, then decide whether DNS/ISP or auth route change is justified.
179 +
index.html
+4 -1
@@ -236,6 +236,8 @@ body{background:#f6f9fc}
236 <button class="btn btn-primary" onclick="handleLogin()">ورود با رمز</button>
237 <button class="btn btn-secondary" onclick="startEmailOtp(false,false)">ورود با کد ایمیل</button>
238 </div>
239 + <button type="button" id="auth-connectivity-check" class="btn btn-secondary" style="width:100%;margin-top:10px" onclick="checkAuthConnectivity()">بررسی اتصال به سرور ورود</button>
240 + <p id="auth-connectivity-result" role="status" aria-live="polite" style="font-size:12px;line-height:1.9;margin-top:8px;overflow-wrap:anywhere"></p>
241 <button class="btn auth-signup" onclick="startEmailOtp(false,true)">ثبت‌نام با کد ایمیل</button>
242 <p class="auth-note">ورود با کد ایمیل برای حساب موجود است. ایجاد حساب جدید فقط از مسیر «ثبت‌نام با کد ایمیل» انجام می‌شود.</p>
243 </div>
@@ -871,7 +873,8 @@ body{background:#f6f9fc}
873 <div class="dock-tab" data-view="view-settings" onclick="switchView('view-settings')"><span>⚙️</span><span>تنظیمات</span></div>
874 </nav>
875
874 -<script src="js/core.js?v=20260928-security-v4"></script>
876 +<script src="js/core.js?v=20261011-login-triage-v1"></script>
877 +<script src="js/login-connectivity.js?v=20261011-login-triage-v1"></script>
878 <script src="js/admin.js"></script>
879 <script src="js/sync.js?v=20260928-data-v4"></script>
880 <script src="js/ui.js?v=20261002-shell-scroll-ownership-v2"></script>
js/core.js
+1 -1
@@ -128,7 +128,7 @@ async function handleLogin(){
128 const {data,error}=await sb.auth.signInWithPassword({email,password:pass});
129 if(error)throw error;
130 await enterApp(data.user);
131 - }catch(err){alert(authMsg(err));}
131 + }catch(err){alert(authMsg(err));if(typeof isAuthNetworkError==='function'&&isAuthNetworkError(err)&&typeof checkAuthConnectivity==='function')void checkAuthConnectivity();}
132 finally{authBusy=false;}
133 }
134 async function signInWithGoogle(){
js/login-connectivity.js new
+49
@@ -0,0 +1,49 @@
1 +// Read-only, credential-free connection diagnostics for the Finora login screen.
2 +// Never logs usernames, passwords, sessions, API responses, or access tokens.
3 +async function checkAuthConnectivity(){
4 + const out=document.getElementById('auth-connectivity-result');
5 + const button=document.getElementById('auth-connectivity-check');
6 + if(!out)return;
7 + if(button?.disabled)return;
8 + if(button)button.disabled=true;
9 + out.textContent='در حال بررسی اتصال به سایت و سرویس ورود...';
10 + out.dataset.status='checking';
11 + const controller=new AbortController();
12 + const timer=setTimeout(()=>controller.abort(),12000);
13 + try{
14 + if(navigator.onLine===false){
15 + out.textContent='اتصال اینترنت این دستگاه قطع است (OFFLINE). پس از وصل‌شدن اینترنت دوباره تلاش کنید.';
16 + out.dataset.status='offline';
17 + return;
18 + }
19 + const [site,auth]=await Promise.allSettled([
20 + fetch(new URL('manifest.json',document.baseURI).href,{cache:'no-store',signal:controller.signal}),
21 + fetch(SUPABASE_URL+'/auth/v1/health',{method:'GET',headers:{apikey:SUPABASE_KEY},cache:'no-store',signal:controller.signal})
22 + ]);
23 + const siteOk=site.status==='fulfilled'&&site.value.ok;
24 + if(!siteOk){
25 + out.textContent='فایل‌های نرم‌افزار از این شبکه به‌درستی دریافت نمی‌شوند (SITE_UNREACHABLE). با اینترنت دیگری امتحان کنید.';
26 + out.dataset.status='site-error';
27 + }else if(auth.status==='rejected'){
28 + const code=controller.signal.aborted?'AUTH_TIMEOUT':'AUTH_UNREACHABLE';
29 + out.textContent='سایت باز می‌شود، اما مرورگر به سرور ورود فینورا دسترسی ندارد ('+code+'). با اینترنت دیگری آزمایش کنید؛ اگر مشکل باقی بود، همین کد را برای پشتیبانی بفرستید.';
30 + out.dataset.status='auth-unreachable';
31 + }else if(auth.value.status===200){
32 + out.textContent='اتصال به سایت و سرور ورود برقرار است (AUTH_OK). اگر ورود انجام نمی‌شود، متن دقیق خطای ورود را بررسی کنید.';
33 + out.dataset.status='ok';
34 + }else{
35 + out.textContent='سرویس ورود پاسخ داده، اما پاسخ آن غیرمنتظره است (AUTH_HTTP_'+auth.value.status+'). این کد را برای پشتیبانی بفرستید.';
36 + out.dataset.status='auth-http';
37 + }
38 + }catch(err){
39 + out.textContent='آزمایش اتصال کامل نشد (DIAGNOSTIC_FAILED). با اینترنت دیگری دوباره امتحان کنید.';
40 + out.dataset.status='error';
41 + }finally{
42 + clearTimeout(timer);
43 + if(button)button.disabled=false;
44 + }
45 +}
46 +function isAuthNetworkError(error){
47 + if(error?.code==='invalid_credentials'||error?.status===400||error?.status===401)return false;
48 + return /fetch|network|load failed|timeout|abort/i.test(String(error?.message||''));
49 +}
scripts/login-connectivity-check.mjs new
+16
@@ -0,0 +1,16 @@
1 +import fs from 'node:fs';
2 +import assert from 'node:assert/strict';
3 +const html=fs.readFileSync('index.html','utf8');
4 +const core=fs.readFileSync('js/core.js','utf8');
5 +const diagnostic=fs.readFileSync('js/login-connectivity.js','utf8');
6 +assert(html.includes('id="auth-connectivity-check"'),'Missing diagnostic action');
7 +assert(html.includes('id="auth-connectivity-result"'),'Missing accessible result');
8 +assert(html.includes('js/login-connectivity.js?v=20261011-login-triage-v1'),'Missing versioned script');
9 +assert(html.includes('js/core.js?v=20261011-login-triage-v1'),'Core.js cache version not bumped');
10 +assert(core.includes('isAuthNetworkError(err)'),'Network error diagnostic not wired');
11 +assert(diagnostic.includes("'/auth/v1/health'"),'Must test the real GoTrue health path');
12 +assert(diagnostic.includes('apikey:SUPABASE_KEY'),'Health check requires public API key');
13 +assert(diagnostic.includes("new URL('manifest.json',document.baseURI)"),'Missing same-origin site baseline');
14 +assert(!diagnostic.includes('signInWithPassword')&&!diagnostic.includes('auth-password'),'Diagnostic must not touch credentials');
15 +assert(diagnostic.includes('new AbortController()'),'Probe timeout must be bounded');
16 +console.log('PASS: login connectivity diagnostics are read-only, cache-versioned and credential-free');
scripts/login-connectivity.spec.js new
+30
@@ -0,0 +1,30 @@
1 +const { test, expect } = require('@playwright/test');
2 +const base=process.env.FINORA_TEST_BASE||'http://127.0.0.1:4173/index.html';
3 +test('Login diagnostics distinguish a reachable auth service from password errors', async ({page})=>{
4 + await page.route('**/auth/v1/health', route=>route.fulfill({
5 + status:200, contentType:'application/json',
6 + headers:{'access-control-allow-origin':'*'},
7 + body:JSON.stringify({name:'GoTrue'})
8 + }));
9 + await page.goto(base,{waitUntil:'domcontentloaded'});
10 + await page.locator('#auth-connectivity-check').click();
11 + await expect(page.locator('#auth-connectivity-result')).toHaveAttribute('data-status','ok',{timeout:15000});
12 + await expect(page.locator('#auth-connectivity-result')).toContainText('AUTH_OK');
13 + await expect(page.locator('#auth-email')).toBeVisible();
14 + await expect(page.locator('#auth-password')).toBeVisible();
15 +});
16 +test('Login diagnostics label upstream unreachable without exposing credentials', async ({page})=>{
17 + await page.route('**/auth/v1/health', route=>route.abort('failed'));
18 + await page.goto(base,{waitUntil:'domcontentloaded'});
19 + await page.locator('#auth-connectivity-check').click();
20 + await expect(page.locator('#auth-connectivity-result')).toHaveAttribute('data-status','auth-unreachable',{timeout:15000});
21 + await expect(page.locator('#auth-connectivity-result')).toContainText('AUTH_UNREACHABLE');
22 + expect(await page.locator('#auth-connectivity-result').textContent()).not.toContain('password');
23 +});
24 +test('Login diagnostics label HTTP server failures, not bad passwords', async ({page})=>{
25 + await page.route('**/auth/v1/health', route=>route.fulfill({status:503,headers:{'access-control-allow-origin':'*'},body:'unavailable'}));
26 + await page.goto(base,{waitUntil:'domcontentloaded'});
27 + await page.locator('#auth-connectivity-check').click();
28 + await expect(page.locator('#auth-connectivity-result')).toHaveAttribute('data-status','auth-http',{timeout:15000});
29 + await expect(page.locator('#auth-connectivity-result')).toContainText('AUTH_HTTP_503');
30 +});