Created
November 11, 2023 23:45
-
-
Save mackuba/a6c2a922be8895c2b82c93e54272b86d to your computer and use it in GitHub Desktop.
Revisions
-
mackuba created this gist
Nov 11, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # "proper" way, more future- and federation-proof handle = form.get('handle') password = form.get('password') if dns_record = lookup_dns("_atproto.#{handle}") did = did_from_dns(dns_record) elsif res = open_url("https://#{handle}/.well-known/atproto-did") did = did_from_well_known(res) else raise "handle could not be resolved" end if did.type == 'plc' did_doc = open_url("https://plc.directory/#{did}") elsif did.type == 'web' did_doc = open_url("https://#{host}/.well-known/did.json") else raise "unknown did type" end pds_host = did_doc['service'][0]['serviceEndpoint'] client = Client.new(pds_host) client.log_in(handle, password) client.post("hello world") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # shortcut via appview handle = form.get('handle') password = form.get('password') appview = Client.new('api.bsky.app') did = appview.resolveHandle(handle) if did.type == 'plc' did_doc = open_url("https://plc.directory/#{did}") elsif did.type == 'web' did_doc = open_url("https://#{host}/.well-known/did.json") else raise "unknown did type" end pds_host = did_doc['service'][0]['serviceEndpoint'] client = Client.new(pds_host) client.log_in(handle, password) client.post("hello world") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ # transitional way using bsky.social login, until full federation handle = form.get('handle') password = form.get('password') social = Client.new('bsky.social') res = social.log_in(handle, password) pds_host = res['didDoc']['service'][0]['serviceEndpoint'] client = Client.new(pds_host, access: res['accessJwt']) client.post("hello world")