سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 18:15 UTC
feat: secure server-only administrator account provisioning and regression contracts
davoodmehraban89 committed
Oct 11, 2026 at 20:35 UTC
565108784f7de25517cd380fdee44e75a1732118
1 file changed
+17
scripts/admin-provisioning-contract.mjs
new
+17
@@ -0,0 +1,17 @@
1
+import{readFileSync}from'node:fs';
2
+import assert from'node:assert/strict';
3
+const edge=readFileSync('supabase/functions/admin-user-management/index.ts','utf8');
4
+const ui=readFileSync('js/admin.js','utf8');
5
+const html=readFileSync('index.html','utf8');
6
+assert.match(edge,/auth\.getUser\(token\)/,'Caller bearer token must be verified on server');
7
+assert.match(edge,/profile\?\.role!=="admin"/,'Profile role must be verified via service-side query');
8
+assert.match(edge,/SUPABASE_SERVICE_ROLE_KEY/,'Service-side admin API must be used');
9
+assert.match(edge,/server\.auth\.admin\.createUser/,'Account created only in server Auth admin API');
10
+assert.match(edge,/email_confirm:true/,'Direct provision uses confirmed address');
11
+assert.doesNotMatch(edge,/\b(?:app_metadata|role)\s*:\s*["']admin["']/i,'Client must not elevate a new account');
12
+assert.match(edge,/strongPassword\(password\)/,'Server enforces strong initial credential');
13
+assert.match(edge,/allowedOrigins\.has\(origin\)/,'Browser origins are restricted');
14
+assert.match(ui,/currentUser\.role!=='admin'/,'UI refuses non-admin account creation');
15
+assert.match(html,/id="admin-create-user-button"/,'Central admin create button must exist');
16
+assert.doesNotMatch(ui,/SUPABASE_SERVICE_ROLE_KEY/,'Service role key never enters browser');
17
+console.log('Admin server-only provisioning contract PASS');