Tend your corner of the atmosphere. spores.garden turns your AT Protocol records into a personal site with unique themes. Your data never leaves your PDS. Grow something that's truly yours. spores.garden
at main 31 lines 870 B view raw
1export const SEED_SPORE_DIDS = [ 2 'did:plc:y3lae7hmqiwyq7w2v3bcb2c2', // v's test DID 3]; 4 5export function seededRandom(seed: string): () => number { 6 let hash = 0; 7 for (let i = 0; i < seed.length; i++) { 8 hash = ((hash << 5) - hash) + seed.charCodeAt(i); 9 hash = hash & hash; // Convert to 32bit integer 10 } 11 let state = Math.abs(hash); 12 13 return function () { 14 state = (state * 1103515245 + 12345) & 0x7fffffff; 15 return state / 0x7fffffff; 16 }; 17} 18 19export function shouldReceiveInitialSpore(did: string): boolean { 20 if (!did) return false; 21 if (SEED_SPORE_DIDS.includes(did)) return true; 22 const rng = seededRandom(did); 23 return rng() < 0.1; 24} 25 26/** 27 * Validate if a spore is authentic (should exist for the given origin DID) 28 */ 29export function isValidSpore(originGardenDid: string): boolean { 30 return shouldReceiveInitialSpore(originGardenDid); 31}