DefectRAG phase 5: incremental real-model application migration
Browse files- backend/gallery.py +8 -0
- deployment/space/app.py +5 -1
- deployment/space/publish.py +25 -6
- deployment/space/supabase_repository.py +36 -0
- frontend/dist/assets/TeamWorkspace-DVtFB4ub.js +41 -0
- frontend/dist/assets/authSecurity-C13nsxqA.js +1 -0
- frontend/dist/assets/index-C51GOc1V.js +0 -0
- frontend/dist/config.js +1 -5
- frontend/dist/index.html +1 -1
backend/gallery.py
CHANGED
|
@@ -186,6 +186,14 @@ def mount_gallery(app,repo,artifacts,gallery=None,owner=lambda:'local-operator',
|
|
| 186 |
if not path.is_file():raise HTTPException(409,'Saved image is unavailable. Nothing was published.')
|
| 187 |
content=path.read_bytes()
|
| 188 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
url=record.get(kind+'_url','')
|
| 190 |
if not cloud_origin or urlparse(url).netloc!=urlparse(cloud_origin).netloc or not url.startswith('https://'):
|
| 191 |
raise HTTPException(403,'Saved image origin is not authorized.')
|
|
|
|
| 186 |
if not path.is_file():raise HTTPException(409,'Saved image is unavailable. Nothing was published.')
|
| 187 |
content=path.read_bytes()
|
| 188 |
else:
|
| 189 |
+
if getattr(current,'config',{}).get('auth_workflow_enabled'):
|
| 190 |
+
# The MFA-enabled repository deliberately returns scoped API
|
| 191 |
+
# URLs, not signed Storage links. Read under the user's JWT
|
| 192 |
+
# so owner/RLS/MFA checks still apply to public publication.
|
| 193 |
+
content=current.private_artifact(identifier,kind)
|
| 194 |
+
if len(content)>5*1024*1024:raise HTTPException(413,'Saved image exceeds gallery limit.')
|
| 195 |
+
previews.append(thumbnail(content))
|
| 196 |
+
continue
|
| 197 |
url=record.get(kind+'_url','')
|
| 198 |
if not cloud_origin or urlparse(url).netloc!=urlparse(cloud_origin).netloc or not url.startswith('https://'):
|
| 199 |
raise HTTPException(403,'Saved image origin is not authorized.')
|
deployment/space/app.py
CHANGED
|
@@ -22,7 +22,7 @@ import torch
|
|
| 22 |
import torch.nn.functional as F
|
| 23 |
from gradio import Server
|
| 24 |
from fastapi import HTTPException
|
| 25 |
-
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse
|
| 26 |
from fastapi.staticfiles import StaticFiles
|
| 27 |
from backend.config import CATEGORIES, Settings
|
| 28 |
from backend.calibration import calibrated_card
|
|
@@ -82,6 +82,7 @@ CLOUD_CONFIG=None
|
|
| 82 |
if os.getenv('DEFECTRAG_STAFF_BACKEND')=='1':
|
| 83 |
from deployment.space.supabase_repository import read_public_config
|
| 84 |
CLOUD_CONFIG=read_public_config(UI/'config.js')
|
|
|
|
| 85 |
PERSONAL_ENABLED=os.getenv('DEFECTRAG_PERSONAL_WORKSPACE')=='1' and CLOUD_CONFIG is not None
|
| 86 |
REPO = SessionRepository(RUNTIME/'sessions',cloud_config=CLOUD_CONFIG,artifacts=ARTIFACTS,personal_enabled=PERSONAL_ENABLED)
|
| 87 |
from backend.main import create_app
|
|
@@ -235,6 +236,7 @@ def health():
|
|
| 235 |
'staff_persistence_enabled':CLOUD_CONFIG is not None,
|
| 236 |
'community_gallery_enabled':GALLERY is not None,
|
| 237 |
'personal_workspace_enabled':PERSONAL_ENABLED,
|
|
|
|
| 238 |
'history':'anonymous browser history is temporary; signed-in approved staff use Supabase' if CLOUD_CONFIG else 'anonymous browser history is temporary; staff backend disabled'}}
|
| 239 |
|
| 240 |
|
|
@@ -243,6 +245,8 @@ def artifact(identifier: str,kind: str):
|
|
| 243 |
if record is None:
|
| 244 |
raise HTTPException(404,'Inspection not found')
|
| 245 |
if record.get('storage','').startswith('supabase'):
|
|
|
|
|
|
|
| 246 |
return RedirectResponse(record[kind+'_url'],status_code=307)
|
| 247 |
return FileResponse(ARTIFACTS/f"{identifier}{'_heatmap' if kind=='heatmap' else ''}.jpg")
|
| 248 |
|
|
|
|
| 22 |
import torch.nn.functional as F
|
| 23 |
from gradio import Server
|
| 24 |
from fastapi import HTTPException
|
| 25 |
+
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse, Response
|
| 26 |
from fastapi.staticfiles import StaticFiles
|
| 27 |
from backend.config import CATEGORIES, Settings
|
| 28 |
from backend.calibration import calibrated_card
|
|
|
|
| 82 |
if os.getenv('DEFECTRAG_STAFF_BACKEND')=='1':
|
| 83 |
from deployment.space.supabase_repository import read_public_config
|
| 84 |
CLOUD_CONFIG=read_public_config(UI/'config.js')
|
| 85 |
+
CLOUD_CONFIG['auth_workflow_enabled']=os.getenv('DEFECTRAG_AUTH_WORKFLOW')=='1'
|
| 86 |
PERSONAL_ENABLED=os.getenv('DEFECTRAG_PERSONAL_WORKSPACE')=='1' and CLOUD_CONFIG is not None
|
| 87 |
REPO = SessionRepository(RUNTIME/'sessions',cloud_config=CLOUD_CONFIG,artifacts=ARTIFACTS,personal_enabled=PERSONAL_ENABLED)
|
| 88 |
from backend.main import create_app
|
|
|
|
| 236 |
'staff_persistence_enabled':CLOUD_CONFIG is not None,
|
| 237 |
'community_gallery_enabled':GALLERY is not None,
|
| 238 |
'personal_workspace_enabled':PERSONAL_ENABLED,
|
| 239 |
+
'auth_workflow_enabled':bool(CLOUD_CONFIG and CLOUD_CONFIG.get('auth_workflow_enabled')),
|
| 240 |
'history':'anonymous browser history is temporary; signed-in approved staff use Supabase' if CLOUD_CONFIG else 'anonymous browser history is temporary; staff backend disabled'}}
|
| 241 |
|
| 242 |
|
|
|
|
| 245 |
if record is None:
|
| 246 |
raise HTTPException(404,'Inspection not found')
|
| 247 |
if record.get('storage','').startswith('supabase'):
|
| 248 |
+
if CLOUD_CONFIG and CLOUD_CONFIG.get('auth_workflow_enabled'):
|
| 249 |
+
return Response(REPO.current().private_artifact(identifier,kind),media_type='image/jpeg',headers={'Cache-Control':'private, no-store'})
|
| 250 |
return RedirectResponse(record[kind+'_url'],status_code=307)
|
| 251 |
return FileResponse(ARTIFACTS/f"{identifier}{'_heatmap' if kind=='heatmap' else ''}.jpg")
|
| 252 |
|
deployment/space/publish.py
CHANGED
|
@@ -3,18 +3,33 @@ import argparse
|
|
| 3 |
import hashlib
|
| 4 |
import json
|
| 5 |
import os
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
-
from huggingface_hub import HfApi, CommitOperationAdd
|
| 8 |
|
| 9 |
ROOT = Path(__file__).resolve().parents[2]
|
| 10 |
REPO = 'Wizzas/DefectRAG'
|
| 11 |
OUT = ROOT/'development-support/space'
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def main():
|
| 15 |
parser = argparse.ArgumentParser()
|
| 16 |
-
parser.add_argument('--phase', type=int, choices=(2,3,4,5)
|
|
|
|
| 17 |
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
if args.phase>=4:
|
| 19 |
confirmation=OUT/'migration-confirmed.json'
|
| 20 |
assert confirmation.exists() and json.loads(confirmation.read_text()).get('user_confirmed_manual_execution'), 'Wait for the user to confirm manual SQL execution before enabling staff persistence.'
|
|
@@ -30,9 +45,11 @@ def main():
|
|
| 30 |
for directory in ('backend','deployment/space'):
|
| 31 |
for path in (ROOT/directory).glob('*.py'):
|
| 32 |
files[path.relative_to(ROOT).as_posix()] = path
|
| 33 |
-
for
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
for path in (ROOT/'models/highres').glob('*.npz'):
|
| 37 |
files[path.relative_to(ROOT).as_posix()] = path
|
| 38 |
if args.phase>=3:
|
|
@@ -81,10 +98,12 @@ DINOv2: Meta, Apache-2.0. See docs/THIRD_PARTY_NOTICES.md.
|
|
| 81 |
previous = json.loads(state_file.read_text()) if state_file.exists() else {}
|
| 82 |
hashes = {name:hashlib.sha256(path.read_bytes()).hexdigest() for name,path in files.items()}
|
| 83 |
hashes.update({name:hashlib.sha256(value).hexdigest() for name,value in raw.items()})
|
| 84 |
-
operations = [CommitOperationAdd(path_in_repo=name,path_or_fileobj=
|
|
|
|
| 85 |
for name,path in files.items() if previous.get(name)!=hashes[name]]
|
| 86 |
operations += [CommitOperationAdd(path_in_repo=name,path_or_fileobj=value)
|
| 87 |
for name,value in raw.items() if previous.get(name)!=hashes[name]]
|
|
|
|
| 88 |
commit = api.create_commit(repo_id=REPO,repo_type='space',operations=operations,
|
| 89 |
parent_commit=before.sha,commit_message=f'DefectRAG phase {args.phase}: incremental real-model application migration')
|
| 90 |
state_file.write_text(json.dumps(hashes,indent=2))
|
|
|
|
| 3 |
import hashlib
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
+
import subprocess
|
| 7 |
from pathlib import Path
|
|
|
|
| 8 |
|
| 9 |
ROOT = Path(__file__).resolve().parents[2]
|
| 10 |
REPO = 'Wizzas/DefectRAG'
|
| 11 |
OUT = ROOT/'development-support/space'
|
| 12 |
|
| 13 |
|
| 14 |
+
def checked_frontend():
|
| 15 |
+
checked=subprocess.run(['node',str(ROOT/'deployment/space/frontend_release.mjs'),'check',str(OUT/'ui-dist')],
|
| 16 |
+
cwd=ROOT,capture_output=True,text=True,check=False,timeout=60)
|
| 17 |
+
if checked.returncode:
|
| 18 |
+
raise SystemExit('Frontend release blocked: '+checked.stderr.strip())
|
| 19 |
+
return json.loads(checked.stdout)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
def main():
|
| 23 |
parser = argparse.ArgumentParser()
|
| 24 |
+
parser.add_argument('--phase', type=int, choices=(2,3,4,5))
|
| 25 |
+
parser.add_argument('--check-frontend',action='store_true',help='Offline readiness check only; never contacts Hugging Face')
|
| 26 |
args = parser.parse_args()
|
| 27 |
+
frontend=checked_frontend()
|
| 28 |
+
if args.check_frontend:
|
| 29 |
+
print(json.dumps({'verified':True,'files':len(frontend['files']),'source_fingerprint':frontend['source_fingerprint']}))
|
| 30 |
+
return
|
| 31 |
+
if args.phase is None:parser.error('--phase is required for an authorized deployment')
|
| 32 |
+
from huggingface_hub import HfApi, CommitOperationAdd
|
| 33 |
if args.phase>=4:
|
| 34 |
confirmation=OUT/'migration-confirmed.json'
|
| 35 |
assert confirmation.exists() and json.loads(confirmation.read_text()).get('user_confirmed_manual_execution'), 'Wait for the user to confirm manual SQL execution before enabling staff persistence.'
|
|
|
|
| 45 |
for directory in ('backend','deployment/space'):
|
| 46 |
for path in (ROOT/directory).glob('*.py'):
|
| 47 |
files[path.relative_to(ROOT).as_posix()] = path
|
| 48 |
+
for name in frontend['files']:
|
| 49 |
+
files['frontend/dist/'+name] = OUT/'ui-dist'/name
|
| 50 |
+
frontend_bytes={name:files['frontend/dist/'+name].read_bytes() for name in frontend['files']}
|
| 51 |
+
if any(hashlib.sha256(content).hexdigest()!=frontend['files'][name] for name,content in frontend_bytes.items()):
|
| 52 |
+
raise SystemExit('Frontend changed while assembling release')
|
| 53 |
for path in (ROOT/'models/highres').glob('*.npz'):
|
| 54 |
files[path.relative_to(ROOT).as_posix()] = path
|
| 55 |
if args.phase>=3:
|
|
|
|
| 98 |
previous = json.loads(state_file.read_text()) if state_file.exists() else {}
|
| 99 |
hashes = {name:hashlib.sha256(path.read_bytes()).hexdigest() for name,path in files.items()}
|
| 100 |
hashes.update({name:hashlib.sha256(value).hexdigest() for name,value in raw.items()})
|
| 101 |
+
operations = [CommitOperationAdd(path_in_repo=name,path_or_fileobj=frontend_bytes[name.removeprefix('frontend/dist/')] if name.startswith('frontend/dist/')
|
| 102 |
+
else path.read_bytes() if path.suffix in ('.py','.js','.json','.md','.html','.css','.svg') else path)
|
| 103 |
for name,path in files.items() if previous.get(name)!=hashes[name]]
|
| 104 |
operations += [CommitOperationAdd(path_in_repo=name,path_or_fileobj=value)
|
| 105 |
for name,value in raw.items() if previous.get(name)!=hashes[name]]
|
| 106 |
+
if checked_frontend()!=frontend:raise SystemExit('Frontend inputs changed before publication; rebuild and verify')
|
| 107 |
commit = api.create_commit(repo_id=REPO,repo_type='space',operations=operations,
|
| 108 |
parent_commit=before.sha,commit_message=f'DefectRAG phase {args.phase}: incremental real-model application migration')
|
| 109 |
state_file.write_text(json.dumps(hashes,indent=2))
|
deployment/space/supabase_repository.py
CHANGED
|
@@ -34,6 +34,20 @@ class StaffRepository:
|
|
| 34 |
def __init__(self,config,token,artifacts):
|
| 35 |
self.config,self.token,self.artifacts=config,token,Path(artifacts)
|
| 36 |
self.headers={'apikey':config['key'],'Authorization':'Bearer '+token}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Do not trust decoded JWT claims. Supabase validates the token, and the
|
| 38 |
# staff allowlist is read through its existing authenticated policies.
|
| 39 |
with _cache_lock:
|
|
@@ -82,11 +96,33 @@ class StaffRepository:
|
|
| 82 |
record['workspace']=self.workspace
|
| 83 |
record['owner_id']=row['owner_id']
|
| 84 |
for kind in ('image','heatmap'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
result=self.request('POST','/storage/v1/object/sign/'+self.bucket+'/'+quote(row[kind+'_path'],safe='/'),json={'expiresIn':600})
|
| 86 |
signed=result.get('signedURL',result.get('signedUrl'))
|
| 87 |
record[kind+'_url']=signed if signed.startswith('https://') else self.config['url']+'/storage/v1'+signed
|
| 88 |
return record
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
def raw(self,identifier,archived=False):
|
| 91 |
rows=self.request('GET','/rest/v1/'+self.table,params={'id':'eq.'+identifier,'select':'*','limit':'1',
|
| 92 |
'archived_at':'not.is.null' if archived else 'is.null'})
|
|
|
|
| 34 |
def __init__(self,config,token,artifacts):
|
| 35 |
self.config,self.token,self.artifacts=config,token,Path(artifacts)
|
| 36 |
self.headers={'apikey':config['key'],'Authorization':'Bearer '+token}
|
| 37 |
+
if config.get('auth_workflow_enabled'):
|
| 38 |
+
# Supabase verifies the JWT. No decoded/browser AAL or role is trusted.
|
| 39 |
+
# Deliberately fresh for each protected operation: revocation must
|
| 40 |
+
# not reuse the legacy 45-second membership cache before GPU work.
|
| 41 |
+
posture=self.request('POST','/rest/v1/rpc/defectrag_auth_status',json={})
|
| 42 |
+
if (not isinstance(posture,dict) or posture.get('approved') is not True
|
| 43 |
+
or posture.get('revoked') is not False or posture.get('authorized') is not True
|
| 44 |
+
or type(posture.get('mfa_required')) is not bool
|
| 45 |
+
or (posture['mfa_required'] and posture.get('aal2') is not True)
|
| 46 |
+
or posture.get('role') not in ('staff','developer') or not posture.get('user_id')):
|
| 47 |
+
raise ValueError('Approved staff and required authenticator verification are needed. Open Staff workspace.')
|
| 48 |
+
self.user={'id':posture['user_id']}
|
| 49 |
+
self.staff={'user_id':posture['user_id'],'role':posture['role'],'display_name':posture.get('display_name') or 'Staff member'}
|
| 50 |
+
return
|
| 51 |
# Do not trust decoded JWT claims. Supabase validates the token, and the
|
| 52 |
# staff allowlist is read through its existing authenticated policies.
|
| 53 |
with _cache_lock:
|
|
|
|
| 96 |
record['workspace']=self.workspace
|
| 97 |
record['owner_id']=row['owner_id']
|
| 98 |
for kind in ('image','heatmap'):
|
| 99 |
+
if self.config.get('auth_workflow_enabled'):
|
| 100 |
+
# SessionRepository replaces these with scoped artifact URLs;
|
| 101 |
+
# the backend fetches private bytes under the current user JWT.
|
| 102 |
+
record[kind+'_url']=f"/api/inspections/{record['id']}/{kind}"
|
| 103 |
+
continue
|
| 104 |
result=self.request('POST','/storage/v1/object/sign/'+self.bucket+'/'+quote(row[kind+'_path'],safe='/'),json={'expiresIn':600})
|
| 105 |
signed=result.get('signedURL',result.get('signedUrl'))
|
| 106 |
record[kind+'_url']=signed if signed.startswith('https://') else self.config['url']+'/storage/v1'+signed
|
| 107 |
return record
|
| 108 |
|
| 109 |
+
def private_artifact(self,identifier,kind):
|
| 110 |
+
if kind not in ('image','heatmap'):raise ValueError('Invalid private artifact')
|
| 111 |
+
row=self.raw(identifier)
|
| 112 |
+
if row is None:raise ValueError('Private inspection is unavailable')
|
| 113 |
+
try:
|
| 114 |
+
with httpx.Client(timeout=25,trust_env=False) as client:
|
| 115 |
+
with client.stream('GET',self.config['url']+'/storage/v1/object/authenticated/'+self.bucket+'/'+quote(row[kind+'_path'],safe='/'),headers=self.headers) as response:
|
| 116 |
+
if not response.is_success:raise ValueError('Private artifact access denied')
|
| 117 |
+
content=bytearray()
|
| 118 |
+
for chunk in response.iter_bytes(chunk_size=65536):
|
| 119 |
+
if len(content)+len(chunk)>10*1024*1024:raise ValueError('Private artifact exceeds the size limit')
|
| 120 |
+
content.extend(chunk)
|
| 121 |
+
if not content:raise ValueError('Private artifact is empty')
|
| 122 |
+
return bytes(content)
|
| 123 |
+
except httpx.HTTPError:
|
| 124 |
+
raise RuntimeError('Private artifact could not be loaded. Retry later.') from None
|
| 125 |
+
|
| 126 |
def raw(self,identifier,archived=False):
|
| 127 |
rows=self.request('GET','/rest/v1/'+self.table,params={'id':'eq.'+identifier,'select':'*','limit':'1',
|
| 128 |
'archived_at':'not.is.null' if archived else 'is.null'})
|
frontend/dist/assets/TeamWorkspace-DVtFB4ub.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import{c as I,r,R as e,a as ve,b as A,s as ge,w as re,L as be,S as we,A as Se,d as Ne,e as ke,p as fe,f as Ce}from"./index-C51GOc1V.js";import{authStatus as _e,registerAccount as Re,submitAccessRequest as Ae,enrollTotp as qe,decideAccess as xe,verifyTotp as Le,authWorkflowEnabled as Me,privateTeamImages as he}from"./authSecurity-C13nsxqA.js";/**
|
| 2 |
+
* @license lucide-react v0.468.0 - ISC
|
| 3 |
+
*
|
| 4 |
+
* This source code is licensed under the ISC license.
|
| 5 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 6 |
+
*/const De=I("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
| 7 |
+
* @license lucide-react v0.468.0 - ISC
|
| 8 |
+
*
|
| 9 |
+
* This source code is licensed under the ISC license.
|
| 10 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 11 |
+
*/const de=I("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
|
| 12 |
+
* @license lucide-react v0.468.0 - ISC
|
| 13 |
+
*
|
| 14 |
+
* This source code is licensed under the ISC license.
|
| 15 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 16 |
+
*/const Pe=I("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
| 17 |
+
* @license lucide-react v0.468.0 - ISC
|
| 18 |
+
*
|
| 19 |
+
* This source code is licensed under the ISC license.
|
| 20 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 21 |
+
*/const Ue=I("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
| 22 |
+
* @license lucide-react v0.468.0 - ISC
|
| 23 |
+
*
|
| 24 |
+
* This source code is licensed under the ISC license.
|
| 25 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 26 |
+
*/const Ie=I("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
| 27 |
+
* @license lucide-react v0.468.0 - ISC
|
| 28 |
+
*
|
| 29 |
+
* This source code is licensed under the ISC license.
|
| 30 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 31 |
+
*/const ze=I("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
| 32 |
+
* @license lucide-react v0.468.0 - ISC
|
| 33 |
+
*
|
| 34 |
+
* This source code is licensed under the ISC license.
|
| 35 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 36 |
+
*/const Oe=I("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
|
| 37 |
+
* @license lucide-react v0.468.0 - ISC
|
| 38 |
+
*
|
| 39 |
+
* This source code is licensed under the ISC license.
|
| 40 |
+
* See the LICENSE file in the root directory of this source tree.
|
| 41 |
+
*/const Te=I("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Fe({client:m,user:i,onChange:G}){var X;const[s,z]=r.useState(null),[x,K]=r.useState([]),[ne,d]=r.useState([]),[E,u]=r.useState(null),[O,N]=r.useState(""),[T,L]=r.useState(""),[F,j]=r.useState(""),[le,se]=r.useState(""),[Y,y]=r.useState(""),[Z,k]=r.useState(""),[p,C]=r.useState(!1),[oe,c]=r.useState([]),[w,M]=r.useState([]),D=((X=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:X.registrationEnabled)===!0;async function S(){if(!i){z(null),c([]),M([]);return}const a=await _e(m);z(a);const{data:o,error:ee}=await m.auth.mfa.listFactors();if(ee)throw ee;const Q=(o.totp||[]).filter(v=>v.status==="verified");if(K(Q),d((o.all||[]).filter(v=>v.factor_type==="totp"&&v.status==="unverified")),L(v=>{var _;return Q.some(ce=>ce.id===v)?v:((_=Q[0])==null?void 0:_.id)||""}),a.role==="developer"&&a.approved&&a.aal2){const[v,_]=await Promise.all([m.rpc("defectrag_access_directory"),m.rpc("defectrag_notification_status")]);if(v.error)throw v.error;if(_.error)throw _.error;c(v.data||[]),M(_.data||[])}else c([]),M([])}async function f(a){C(!0),k("");try{await a()}catch(o){k(o.message||"Security request failed.")}finally{C(!1)}}r.useEffect(()=>{let a=!0;return u(null),N(""),c([]),M([]),m&&i?S().catch(o=>{a&&k(o.message)}):z(null),()=>{a=!1}},[m,i==null?void 0:i.id]);async function J(){await Le(m,(E==null?void 0:E.id)||T,O),N(""),u(null),await S(),G(),k("Authenticator verified. Account approval still controls staff access.")}return e.createElement("div",{className:"section-gap"},e.createElement("h3",null,"Account access & security"),Z&&e.createElement("p",{className:"note",role:"status"},Z),i?e.createElement(e.Fragment,null,e.createElement("p",null,"Access: ",e.createElement("strong",null,s!=null&&s.revoked?"revoked":s!=null&&s.approved?"approved":(s==null?void 0:s.request_status)||"not requested")," · Authenticator: ",e.createElement("strong",null,s!=null&&s.aal2?"verified session":"session not verified")),e.createElement("button",{className:"secondary",disabled:p,onClick:()=>f(S)},"Refresh account status"),s&&!s.approved&&!s.revoked&&!s.request_status&&e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),f(async()=>{await Ae(m,F),await S(),k("Access request saved. Staff data remains unavailable until developer approval."),G()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:F,maxLength:80,onChange:a=>j(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:p||!s.registration_enabled||!s.email_verified},"Request staff access")),e.createElement("p",{className:"caption"},"Enrollment does not grant membership. Keep the authenticator available before mandatory MFA is enabled. Lost-factor recovery requires the workspace administrator; password reset does not remove MFA."),!E&&!x.length&&!ne.length&&e.createElement("button",{className:"secondary",disabled:p,onClick:()=>f(async()=>u(await qe(m)))},"Set up authenticator"),!E&&ne.map(a=>e.createElement("p",{key:a.id,className:"caption"},"An unfinished enrollment exists. ",e.createElement("button",{className:"text-button",disabled:p,onClick:()=>f(async()=>{const{error:o}=await m.auth.mfa.unenroll({factorId:a.id});if(o)throw o;await S()})},"Cancel unfinished setup"))),E&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("p",null,"Scan this QR code in an authenticator. Keep it private and verify a code to finish enrollment."),e.createElement("img",{src:E.totp.qr_code,width:"200",height:"200",alt:"Private authenticator enrollment QR code"}),e.createElement("button",{className:"text-button",disabled:p,onClick:()=>f(async()=>{const{error:a}=await m.auth.mfa.unenroll({factorId:E.id});if(a)throw a;u(null),N("")})},"Cancel unfinished enrollment"))),(E||x.length>0)&&e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),f(J)}},!E&&e.createElement("label",{className:"field"},"Authenticator",e.createElement("select",{value:T,onChange:a=>L(a.target.value)},x.map(a=>e.createElement("option",{key:a.id,value:a.id},a.friendly_name||"Authenticator")))),e.createElement("label",{className:"field"},"Six-digit code",e.createElement("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:O,onChange:a=>N(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:p},"Verify authenticator")),(s==null?void 0:s.role)==="developer"&&s.approved&&s.aal2&&e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Staff access management"),e.createElement("p",null,"Only pending requests can be approved or rejected. Revocation retains inspection history and blocks new protected operations."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Account"),e.createElement("th",null,"Status"),e.createElement("th",null,"Role"),e.createElement("th",null,"Action"))),e.createElement("tbody",null,oe.map(a=>e.createElement("tr",{key:a.user_id},e.createElement("td",null,a.display_name,e.createElement("br",null),e.createElement("small",null,a.email)),e.createElement("td",null,a.status),e.createElement("td",null,a.role||"applicant"),e.createElement("td",null,a.user_id!==i.id&&(a.status==="pending"?["approve","reject"]:a.status==="approved"?["revoke"]:[]).map(o=>e.createElement("button",{key:o,className:"text-button",disabled:p,onClick:()=>{window.confirm(`${o[0].toUpperCase()+o.slice(1)} access for ${a.display_name}?`)&&f(async()=>{await xe(m,a,o),await S(),G(),k("Access decision saved. Notification delivery is tracked separately.")})}},o)))))))),e.createElement("h3",{className:"section-gap"},"Notification delivery"),e.createElement("p",{className:"caption"},"Queued messages wait while the notification service is offline. Sent means the mail provider accepted the message, not proof of inbox delivery."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Event"),e.createElement("th",null,"Delivery"),e.createElement("th",null,"Attempts"),e.createElement("th",null))),e.createElement("tbody",null,w.map(a=>e.createElement("tr",{key:a.id},e.createElement("td",null,a.kind),e.createElement("td",null,a.status),e.createElement("td",null,a.attempts),e.createElement("td",null,a.status==="dead"&&e.createElement("button",{className:"text-button",disabled:p,onClick:()=>f(async()=>{const{error:o}=await m.rpc("defectrag_retry_notification",{p_id:a.id});if(o)throw o;await S()})},"Retry delivery"))))))))):D?e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),f(async()=>{await Re(m,{email:le,password:Y,displayName:F,redirectTo:location.origin+location.pathname}),y(""),k("If registration is available, check the email for confirmation. Sign in afterward and submit the staff access request. Registration does not grant staff access.")})}},e.createElement("p",null,"Register an account to request staff access. Public Demo Mode does not require registration."),e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:F,onChange:a=>j(a.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:le,onChange:a=>se(a.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:Y,onChange:a=>y(a.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:p||!m},"Register account")):e.createElement("p",{className:"caption"},"Self-registration is not enabled. Existing approved accounts can sign in below. Public Demo Mode remains accessible."))}function We({onOpenInspection:m}){var ue;const i=r.useRef(0),G=r.useRef(null),s=r.useRef(0),z=r.useRef(null),x=r.useRef(0),[K,ne]=r.useState({state:"refreshing"}),[d,E]=r.useState(null),[u,O]=r.useState(null),[N,T]=r.useState([]),[L,F]=r.useState({}),[j,le]=r.useState(""),[se,Y]=r.useState(""),[y,Z]=r.useState(!1),[k,p]=r.useState(""),[C,oe]=r.useState(!1),[c,w]=r.useState(null),[M,D]=r.useState([]),[S,f]=r.useState([]),[J,X]=r.useState(""),[a,o]=r.useState(!1),[ee,Q]=r.useState(""),[v,_]=r.useState(!1),[ce,Ee]=r.useState(null),$=Me();r.useEffect(()=>()=>{M.filter(t=>t.startsWith("blob:")).forEach(t=>URL.revokeObjectURL(t))},[M]),r.useEffect(()=>{z.current=c},[c]);const ie=ve();async function R(t){Z(!0),p("");try{await t()}catch(n){p(n.message||"Team request failed.")}finally{Z(!1)}}async function te(){var pe;const t=++s.current,n=i.current,l=(pe=z.current)==null?void 0:pe.id,{client:b,staff:q}=await Ce();let h=b.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);h=C?h.not("archived_at","is",null):h.is("archived_at",null);const[{data:B,error:P},{data:W,error:ae},g]=await Promise.all([h,b.from("staff_members").select("*"),l?b.from("staff_notes").select("*").eq("inspection_id",l).order("created_at"):{data:[]}]);if(P)throw P;if(ae)throw ae;if(g.error)throw g.error;if(t===s.current&&(O(q),p(""),T(B||[]),F(Object.fromEntries((W||[]).map(U=>[U.user_id,U.display_name]))),l&&n===i.current)){const U=(B||[]).find(H=>H.id===l);if(!U)i.current++,w(null),D([]),f([]);else if(w(U),f(g.data||[]),Date.now()-x.current>480*1e3)if($){const H=await he(b,U);t===s.current&&n===i.current?(D(H),x.current=Date.now()):H.forEach(V=>URL.revokeObjectURL(V))}else{const H=await Promise.all([U.image_path,U.heatmap_path].map(V=>b.storage.from("team-inspections").createSignedUrl(V,900)));if(t===s.current&&n===i.current){if(H.some(V=>V.error))throw new Error("Shared image links could not refresh.");D(H.map(V=>V.data.signedUrl)),x.current=Date.now()}}}}r.useEffect(()=>{if(!ie)return;let t=!1,n;return A().then(async l=>{!t&&$&&Ee(l),n=l.auth.onAuthStateChange((q,h)=>{var B;if(!t){const P=((B=h==null?void 0:h.user)==null?void 0:B.id)||null;G.current!==P&&(i.current++,s.current++,w(null),T([]),D([]),f([]),O(null),G.current=P),E((h==null?void 0:h.user)||null),q==="PASSWORD_RECOVERY"&&o(!0)}}).data.subscription;const{data:b}=await l.auth.getUser();t||E(b.user)}).catch(l=>{t||p(l.message)}),()=>{t=!0,i.current++,n==null||n.unsubscribe()}},[ie]),r.useEffect(()=>{if(!d)return;const t=ge(te,{onState:n=>{ne(n),n.error&&(p(n.error),$&&(i.current++,T([]),F({}),w(null),D([]),f([]),O(null)))}});return()=>{t.stop(),s.current++}},[d==null?void 0:d.id,C]);async function me(t){const n=++i.current;await R(async()=>{const l=await A(),b=l.storage.from("team-inspections"),[{data:q,error:h},{data:B,error:P}]=await Promise.all([l.from("shared_inspections").select("*").eq("id",t.id).single(),l.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(h)throw h;if(P)throw P;const W=$?await he(l,q):null,ae=W?W.map(g=>({data:{signedUrl:g}})):await Promise.all([q.image_path,q.heatmap_path].map(g=>b.createSignedUrl(g,900)));if(ae.some(g=>g.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(n!==i.current){W==null||W.forEach(g=>URL.revokeObjectURL(g));return}z.current=q,x.current=Date.now(),w(q),D(ae.map(g=>g.data.signedUrl)),f(B||[])})}async function ye(){await R(async()=>{const t=await A(),n=N.filter(l=>l.owner_id===d.id).map(l=>l.id);if(n.length){const{error:l}=await t.rpc("archive_team_inspections",{p_ids:n});if(l)throw l}i.current++,w(null),_(!1),await te(),re()})}return ie?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(Te,{size:21})," Staff workspace"),e.createElement("p",null,"Signed-in staff share saved inspections and review notes. Live AI runs on the connected inspection backend.")),e.createElement("span",{className:"subtle-tag"},e.createElement(de,{size:13})," SUPABASE")),k&&e.createElement("div",{className:"error",role:"alert"},k),$&&ce&&e.createElement(Fe,{key:(d==null?void 0:d.id)||"anonymous",client:ce,user:d,onChange:()=>{re(),d&&R(te)}}),d?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(we,{size:18}),e.createElement("strong",null,(u==null?void 0:u.display_name)||d.email),e.createElement("span",{className:"subtle-tag"},(u==null?void 0:u.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:y,onClick:()=>R(te)},e.createElement(ze,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>R(async()=>{await(await A()).auth.signOut(),T([]),w(null),O(null)})},e.createElement(Ie,{size:16})," Sign out")),a&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),R(async()=>{const n=await A(),{error:l}=await n.auth.updateUser({password:ee});if(l)throw l;Q(""),o(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:ee,onChange:t=>Q(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:y},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},"Team Workspace · latest ",N.length," shared records · ",K.state==="synced"?"synchronized at "+new Date(K.at).toLocaleTimeString():K.state==="offline"?"offline; data may be stale":K.state==="stale"?"synchronization failed; data may be stale":"refreshing…"," · polls every 15 seconds"),(u==null?void 0:u.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{oe(!C),w(null)}},e.createElement(De,{size:16}),C?"Active history":"Developer recovery"),!C&&e.createElement("button",{className:"secondary danger",disabled:y||!N.some(t=>t.owner_id===d.id),onClick:()=>_(!0)},e.createElement(Se,{size:16})," Archive my visible history")),v&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:y,onClick:ye},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>_(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,N.map(t=>{var n;return e.createElement("tr",{key:t.id},e.createElement("td",null,e.createElement("strong",null,t.id.slice(0,8))),e.createElement("td",null,t.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((n=t.payload.verdict)==null?void 0:n.toLowerCase())},t.payload.verdict)),e.createElement("td",null,L[t.owner_id]||"Staff member"),e.createElement("td",null,new Date(t.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>me(t)},"Review"),C&&(u==null?void 0:u.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:y,onClick:()=>R(async()=>{const l=await A(),{error:b}=await l.rpc("restore_team_inspections",{p_ids:[t.id]});if(b)throw b;await te(),re()})},"Restore")))}))),!N.length&&e.createElement("div",{className:"empty"},e.createElement(de,{size:30}),e.createElement("p",null,C?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),R(async()=>{const n=await A(),{error:l}=await n.auth.signInWithPassword({email:j,password:se});if(l)throw l;Y("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:j,onChange:t=>le(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:se,onChange:t=>Y(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:y},y?e.createElement(be,{className:"spin",size:17}):e.createElement(Ue,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!j||y,onClick:()=>R(async()=>{const t=await A(),{error:n}=await t.auth.resetPasswordForEmail(j,{redirectTo:location.origin+location.pathname});if(n)throw n;p("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},$?"Registration alone does not grant staff access. Approved staff complete any required authenticator verification.":"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),d&&c&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",c.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",L[c.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},m&&!c.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>m(c)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{i.current++,w(null)}},"Close"))),e.createElement("div",{className:"shared-images"},M.map((t,n)=>e.createElement("img",{key:t,src:t,alt:n?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,c.payload.verdict," · score ",Number(c.payload.score).toFixed(5)," · threshold ",Number(c.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(ue=c.conversation)!=null&&ue.length?c.conversation.map((t,n)=>e.createElement("p",{className:"cloud-message",key:n},e.createElement("strong",null,t.role==="user"?"Inspector":"Evidence Assistant",": "),t.question||t.answer)):e.createElement("p",{className:"caption"},"No conversation was included when this inspection was shared."),!c.archived_at&&e.createElement(Ne,{key:c.id+String(S.length),current:S.map(t=>fe(t,L)).filter(Boolean).at(-1),disabled:y,onSave:async t=>{const n=await A(),{error:l}=await n.from("staff_notes").insert({inspection_id:c.id,author_id:d.id,body:ke(t.status,t.decision,t.note)});if(l)throw l;await me(c),re()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),S.filter(t=>!fe(t,L)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,L[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!c.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),R(async()=>{const n=await A(),{error:l}=await n.from("staff_notes").insert({inspection_id:c.id,author_id:d.id,body:J.trim()});if(l)throw l;X(""),await me(c),re()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:J,onChange:t=>X(t.target.value)}),e.createElement("button",{className:"primary",disabled:y||!J.trim()},e.createElement(Oe,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(de,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"One shared view of inspection."),e.createElement("p",null,"The staff workspace is ready to connect to your own Supabase project. No cloud project or account has been created for you."),e.createElement("div",{className:"setup-grid"},[["01","Create a free project","Use your Supabase account and select an eligible Free plan."],["02","Set up staff access","Run the supplied schema, add your developer account and invite colleagues."],["03","Connect this dashboard","Add the project URL and publishable key to config.js, then reload."]].map(([t,n,l])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,n),e.createElement("p",null,l)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(Pe,{size:16})),e.createElement("p",{className:"caption"},"Setup files: deployment/SUPABASE_SETUP.md and deployment/supabase.sql. Never place a service-role key in the browser. Local inspection works without cloud setup."))}export{We as default};
|
frontend/dist/assets/authSecurity-C13nsxqA.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
function f(){var r,t;return((t=(r=globalThis.window)==null?void 0:r.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:t.authWorkflowEnabled)===!0}async function c(r){const{data:t,error:e}=await r.rpc("defectrag_auth_status");if(e)throw e;if(!t||typeof t.approved!="boolean"||typeof t.authorized!="boolean"||typeof t.aal2!="boolean")throw new Error("Account security status is unavailable.");return t}async function u(r){const t=await c(r);if(!t.approved||t.revoked)throw new Error("Staff access is pending, rejected or revoked. Demo Mode remains available after signing out.");if(!t.authorized||t.mfa_required&&!t.aal2)throw new Error("Complete authenticator verification in Staff workspace.");return t}async function h(r,{email:t,password:e,displayName:a,redirectTo:o}){if(e.length<12||!a.trim()||a.trim().length>80)throw new Error("Use a display name and a password of at least 12 characters.");const{data:n,error:i}=await r.auth.signUp({email:t,password:e,options:{emailRedirectTo:o}});if(i)throw i;return n.session&&await s(r,a),{confirmationRequired:!n.session}}async function s(r,t){const{data:e,error:a}=await r.rpc("defectrag_request_access",{p_display_name:t.trim()});if(a)throw a;return e}async function d(r){const{data:t,error:e}=await r.auth.mfa.enroll({factorType:"totp",friendlyName:"DefectRAG authenticator"});if(e)throw e;return t}async function w(r,t,e){if(!/^\d{6}$/.test(e))throw new Error("Enter the six-digit authenticator code.");const{data:a,error:o}=await r.auth.mfa.challenge({factorId:t});if(o)throw o;const n=await r.auth.mfa.verify({factorId:t,challengeId:a.id,code:e});if(n.error)throw n.error;return n.data}async function l(r,t,e){if(!["approve","reject","revoke"].includes(e))throw new Error("Invalid account action.");const{data:a,error:o}=await r.rpc("defectrag_decide_access",{p_user_id:t.user_id,p_action:e,p_version:t.version});if(o)throw o;return a}async function p(r,t){const e=[];try{for(const a of[t.image_path,t.heatmap_path]){const{data:o,error:n}=await r.storage.from("team-inspections").download(a);if(n)throw n;e.push(URL.createObjectURL(o))}return e}catch(a){throw e.forEach(o=>URL.revokeObjectURL(o)),a}}export{c as authStatus,f as authWorkflowEnabled,l as decideAccess,d as enrollTotp,p as privateTeamImages,h as registerAccount,u as requireStaff,s as submitAccessRequest,w as verifyTotp};
|
frontend/dist/assets/index-C51GOc1V.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/dist/config.js
CHANGED
|
@@ -1,5 +1 @@
|
|
| 1 |
-
|
| 2 |
-
window.DEFECTRAG_PUBLIC_CONFIG = {
|
| 3 |
-
supabaseUrl: 'https://zrzqpbcomlorfzszolrs.supabase.co',
|
| 4 |
-
supabasePublishableKey: 'sb_publishable_ff0gl6l7ZWb_zKcklF6e3g_VT7Qi7FF'
|
| 5 |
-
};
|
|
|
|
| 1 |
+
window.DEFECTRAG_PUBLIC_CONFIG = {"supabaseUrl":"https://zrzqpbcomlorfzszolrs.supabase.co","supabasePublishableKey":"sb_publishable_ff0gl6l7ZWb_zKcklF6e3g_VT7Qi7FF","authWorkflowEnabled":true,"registrationEnabled":false};
|
|
|
|
|
|
|
|
|
|
|
|
frontend/dist/index.html
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
|
| 3 |
</head><body><div id="root"></div></body></html>
|
|
|
|
| 1 |
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-C51GOc1V.js"></script>
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
|
| 3 |
</head><body><div id="root"></div></body></html>
|