demos for spacedust

extract domain/psl and lex group

+28 -2
+13 -1
atproto-notifications/package-lock.json
··· 10 10 "dependencies": { 11 11 "@atcute/identity-resolver": "^1.1.3", 12 12 "@uidotdev/usehooks": "^2.4.1", 13 + "psl": "^1.15.0", 13 14 "react": "^19.1.0", 14 15 "react-dom": "^19.1.0" 15 16 }, ··· 2918 2919 "node": ">= 0.8.0" 2919 2920 } 2920 2921 }, 2922 + "node_modules/psl": { 2923 + "version": "1.15.0", 2924 + "resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz", 2925 + "integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==", 2926 + "license": "MIT", 2927 + "dependencies": { 2928 + "punycode": "^2.3.1" 2929 + }, 2930 + "funding": { 2931 + "url": "https://github.com/sponsors/lupomontero" 2932 + } 2933 + }, 2921 2934 "node_modules/punycode": { 2922 2935 "version": "2.3.1", 2923 2936 "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", 2924 2937 "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", 2925 - "dev": true, 2926 2938 "license": "MIT", 2927 2939 "engines": { 2928 2940 "node": ">=6"
+1
atproto-notifications/package.json
··· 12 12 "dependencies": { 13 13 "@atcute/identity-resolver": "^1.1.3", 14 14 "@uidotdev/usehooks": "^2.4.1", 15 + "psl": "^1.15.0", 15 16 "react": "^19.1.0", 16 17 "react-dom": "^19.1.0" 17 18 },
+14 -1
atproto-notifications/src/service-worker.ts
··· 1 + import psl from 'psl'; 1 2 import { resolveDid } from './atproto/resolve'; 2 3 3 4 self.addEventListener('push', handlePush); ··· 58 59 // const tag = 'simple-push-demo-notification-tag'; 59 60 // TODO: resubscribe to notifs to try to stay alive 60 61 62 + let group; 63 + let domain; 64 + try { 65 + const [nsid, ...rp] = source.split(':'); 66 + const parts = nsid.split('.'); 67 + group = parts.slice(0, parts.length - 1).join('.') ?? 'unknown'; 68 + const unreversed = parts.toReversed().join('.'); 69 + domain = psl.parse(unreversed)?.domain ?? 'unknown'; 70 + } catch (e) { 71 + console.error('getting top app domain failed', e); 72 + } 73 + 61 74 let db; 62 75 try { 63 76 db = await getDB(); ··· 79 92 80 93 const notification = self.registration.showNotification(title, { 81 94 icon, 82 - body: `from ${handle}`, 95 + body: `from ${handle} on ${domain} in ${group}`, 83 96 // actions: [ 84 97 // {'action': 'bsky', title: 'Bluesky'}, 85 98 // {'action': 'spacedust', title: 'All notifications'},