Skip to content

Instantly share code, notes, and snippets.

@melvincarvalho
Forked from cameri/nostr_pubring.json
Last active December 31, 2021 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melvincarvalho/672cf02e3560a17b11ce2af684dd852d to your computer and use it in GitHub Desktop.
Save melvincarvalho/672cf02e3560a17b11ce2af684dd852d to your computer and use it in GitHub Desktop.
[
"076161ca22da5a2ab8c74465cbf08f79f3e7e8bb31f4dc211bd94319ebade03d",
"5a462fa6044b4b8da318528a6987a45e3adf832bd1c64bd6910eacfecdf07541",
"1bbb8324577ac089607e45813bac499ebdab4621d029f8c02b2c82b4410fd3f4",
"e9e4276490374a0daf7759fd5f475deff6ffb9b0fc5fa98c902b5f4b2fe3bba2",
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072",
"ce5061bfcc16476b9bde3f1d5b3ec7730c4361cf8c827fbd9c14eb8c7003a1de",
"22e804d26ed16b68db5259e78449e96dab5d464c8f470bda3eb1a70467f2c793",
"ff24202025283c90d05337559b8ad7e3e0b811726d1cbb400a9b698cd7a01780",
"b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9",
"d9c8c00017a2a345c2f32132436a26e1c72cb7a57e7b6b316f62dee2f8bcf8dd",
"c2bb5d6529095edbfbdbe3f136175c146c6706526325b32da881c7c34c7b1ab8",
"e6f6a6f84f6892c4e632515f633690d2239e4b7b0ee1c8b159722733d678cc0c",
"07cfbf55b270096b1487ee752f9ffeddd8952e109ec615eb56f19c7016e2ea09",
"1f12c3a03fddd3cb4a538d6b060f691c7307f597b81987e6b82a3ea3f8f3d3ed",
"7e88f589d2677ea4a863c72af5d0e85fbe1d3db111667c50d33fa42196a1afc0",
"fd3fdb0d0d8d6f9a7667b53211de8ae3c5246b79bdaf64ebac849d5148b5615f",
"942d2eac93d2b30d9941a63c42d22e9d1f8cb6b538bb7030391bd886a17264ff",
"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d",
"503f6500e36205e770e0b23c681f951a18946e68a5a76b69ed9ff2add3042da5",
"168b5acb915b1ea5bcdefb460823fd9cd56399da75a8da78459fa1a1bdc7df32"
]
{
"wss://nostr.rocks": {
"read": true,
"write": true
},
"wss://relayer.fiatjaf.com": {
"read": true,
"write": true
},
"wss://nostr-pub.wellorder.net": {
"read": true,
"write": true
},
"wss://rsslay.fiatjaf.com": {
"read": true,
"write": false
}
}
/************************
* Use at your own risk *
************************/
(async () => {
const gistId = 'yourGistId';
const response = await fetch(`https://api.github.com/gists/${gistId}`, {
headers: {
'Accept': 'application/vnd.github.v3+json',
},
})
const {
files: {
'nostr_pubring.json': {
content: pubring
},
'nostr_relays.json': {
content: relays,
},
}
} = await response.json();
const existingPubring = JSON.parse((localStorage.getItem('following') || '').substr(9)) || [];
const existingRelays = JSON.parse(localStorage.getItem('relays').substr(9)) || {};
const pulledPubring = JSON.parse(pubring);
const pulledRelays = JSON.parse(relays);
const newPubring = Array.from(new Set([...pulledPubring, ...existingPubring]));
const newRelays = { ...pulledRelays, ...existingRelays };
localStorage.setItem('following', `__q_objt|${JSON.stringify(newPubring)}`)
localStorage.setItem('relays', `__q_objt|${JSON.stringify(newRelays)}`)
})();
/* run this on the browser to push your followers' pubkeys to a gist */
(async () => {
const username = 'yourUser';
const personalToken = 'yourTokenHere'; // create one with gist scope here: https://github.com/settings/tokens
const gistId = 'yourGistId'; // must already exist, this script does not create a new gist
const pubring = JSON.parse(localStorage.getItem("following").substr(9));
const relays = JSON.parse(localStorage.getItem("relays").substr(9));
const body = {
files: {
'nostr_pubring.json': {
content: JSON.stringify(pubring, undefined, 2),
},
'nostr_relays.json': {
content: JSON.stringify(relays, undefined, 2),
},
}
}
await fetch(`https://api.github.com/gists/${gistId}`, {
method: 'PATCH',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `token ${personalToken}`
},
body: JSON.stringify(body),
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment