This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 1.4 kB View raw
1// List of allowed DIDs and usernames 2export const ALLOWED_ACCOUNTS = [ 3 'did:plc:gq4fo3u6tqzzdkjlwzpb23tj', // Dame's DID 4 'dame.is' // Dame's handle 5]; 6 7// Helper function to check if an account is allowed 8export const isAccountAllowed = (session) => { 9 console.log('Checking if account is allowed:', session); 10 11 if (!session) { 12 console.log('No session provided, denying access'); 13 return false; 14 } 15 16 // Extract DID from various possible session formats 17 const did = session.did || session.sub || null; 18 19 // Extract handle from various possible session formats 20 const handle = session.handle || null; 21 22 console.log(`Checking permissions for DID: ${did}, handle: ${handle}`); 23 24 // Check if either did or handle is in the allowlist 25 if (did && ALLOWED_ACCOUNTS.includes(did)) { 26 console.log('DID is in allowlist, granting access'); 27 return true; 28 } 29 30 if (handle && ALLOWED_ACCOUNTS.includes(handle)) { 31 console.log('Handle is in allowlist, granting access'); 32 return true; 33 } 34 35 // Also check if the handle (without domain) is in the allowlist 36 if (handle && handle.includes('.')) { 37 const handleWithoutDomain = handle.split('.')[0]; 38 if (ALLOWED_ACCOUNTS.includes(handleWithoutDomain)) { 39 console.log('Handle (without domain) is in allowlist, granting access'); 40 return true; 41 } 42 } 43 44 console.log('Account not in allowlist, denying access'); 45 return false; 46};