⚡ Zero-dependency plcbundle library exclusively for Bun
at main 1.0 kB view raw
1/** 2 * Example: Advanced detect function with multiple criteria 3 * 4 * Usage: 5 * bun src/cli.ts detect --detect ./examples/detect-advanced.ts 6 */ 7 8export function detect({ op }: { op: any }) { 9 const labels = []; 10 11 // Check for custom PDS 12 const pds = op.operation?.services?.atproto_pds?.endpoint; 13 if (pds && !pds.includes('bsky.social') && !pds.includes('bsky.network')) { 14 labels.push('custom-pds'); 15 } 16 17 // Check for multiple handles 18 if (op.operation?.alsoKnownAs?.length > 1) { 19 labels.push('multi-handle'); 20 } 21 22 // Check for rotation keys (security update) 23 if (op.operation?.rotationKeys) { 24 labels.push('rotation-keys'); 25 } 26 27 // Check for verification methods 28 const verificationMethods = op.operation?.verificationMethods; 29 if (verificationMethods && Object.keys(verificationMethods).length > 1) { 30 labels.push('multi-verification'); 31 } 32 33 // Detect by DID pattern 34 if (op.did.match(/^did:plc:[a-z]{24}$/)) { 35 labels.push('standard-did'); 36 } 37 38 return labels; 39}