Sifa professional network API (Fastify, AT Protocol, Jetstream) sifa.id/

feat(pds): add northsky, selfhosted.social and selfhosted fallback (#94)

Add Northsky and selfhosted.social as known PDS providers.
Change mapPdsHostToProvider to return { name: 'selfhosted', host }
for any resolved PDS host that doesn't match a known provider,
instead of returning null.

authored by

Guido X Jansen and committed by
GitHub
0162999f 947fe6dc

+26 -6
+6 -2
src/lib/pds-provider.ts
··· 15 15 { pattern: /^blacksky\.app$/i, name: 'blacksky' }, 16 16 { pattern: /\.eurosky\.social$/i, name: 'eurosky' }, 17 17 { pattern: /^eurosky\.social$/i, name: 'eurosky' }, 18 + { pattern: /\.northsky\.social$/i, name: 'northsky' }, 19 + { pattern: /^northsky\.social$/i, name: 'northsky' }, 20 + { pattern: /\.selfhosted\.social$/i, name: 'selfhosted-social' }, 21 + { pattern: /^selfhosted\.social$/i, name: 'selfhosted-social' }, 18 22 ]; 19 23 20 - export function mapPdsHostToProvider(host: string): PdsProviderInfo | null { 24 + export function mapPdsHostToProvider(host: string): PdsProviderInfo { 21 25 for (const entry of KNOWN_PDS_HOSTS) { 22 26 if (entry.pattern.test(host)) { 23 27 return { name: entry.name, host }; 24 28 } 25 29 } 26 - return null; 30 + return { name: 'selfhosted', host }; 27 31 } 28 32 29 33 export function extractPdsHostFromEndpoint(endpoint: string): string | null {
+20 -4
tests/lib/pds-provider.test.ts
··· 46 46 expect(result).toEqual({ name: 'eurosky', host: 'pds.eurosky.social' }); 47 47 }); 48 48 49 - it('returns null for unknown PDS host', () => { 50 - expect(mapPdsHostToProvider('my-pds.example.com')).toBeNull(); 49 + it('maps northsky.social to northsky', () => { 50 + const result = mapPdsHostToProvider('pds.northsky.social'); 51 + expect(result).toEqual({ name: 'northsky', host: 'pds.northsky.social' }); 51 52 }); 52 53 53 - it('returns null for self-hosted PDS', () => { 54 - expect(mapPdsHostToProvider('pds.alice.dev')).toBeNull(); 54 + it('maps selfhosted.social to selfhosted-social', () => { 55 + const result = mapPdsHostToProvider('pds.selfhosted.social'); 56 + expect(result).toEqual({ name: 'selfhosted-social', host: 'pds.selfhosted.social' }); 57 + }); 58 + 59 + it('returns selfhosted for unknown PDS host', () => { 60 + expect(mapPdsHostToProvider('my-pds.example.com')).toEqual({ 61 + name: 'selfhosted', 62 + host: 'my-pds.example.com', 63 + }); 64 + }); 65 + 66 + it('returns selfhosted for individual self-hosted PDS', () => { 67 + expect(mapPdsHostToProvider('pds.alice.dev')).toEqual({ 68 + name: 'selfhosted', 69 + host: 'pds.alice.dev', 70 + }); 55 71 }); 56 72 }); 57 73