diff options
author | pdp8 <pdp8@pdp8.info> | 2023-05-19 22:50:54 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-05-19 22:50:54 +0200 |
commit | d2c4d3b49e6b790d14f6dcb94c2ae0641559d2cf (patch) | |
tree | 09148e8d81e4686a9c969bb74b3f4f6fc9325f79 /post.rb | |
parent | d523ce8d4fe4e852944331eb0c300d309641c057 (diff) |
follow and followers
Diffstat (limited to 'post.rb')
-rwxr-xr-x | post.rb | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/post.rb b/post.rb deleted file mode 100755 index c5e7cd7..0000000 --- a/post.rb +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env ruby -require 'json' -require 'time' -require 'openssl' -require 'base64' -require 'net/http' -require 'uri' - -# document = { "a" => 2 } # .to_json -document = { - "@context": "https://www.w3.org/ns/activitystreams", - "type": "Like", - "actor": "https://example.net/~mallory", - "to": ["https://hatchat.example/sarah/", - "https://example.com/peeps/john/"], - "object": { - "@context": { "@language": "en" }, - "id": "https://example.org/~alice/note/23", - "type": "Note", - "attributedTo": "https://example.org/~alice", - "content": "I'm a goat" - } -} -date = Time.now.utc.httpdate -keypair = OpenSSL::PKey::RSA.new(File.read('private.pem')) -signed_string = "(request-target): post /inbox\nhost: social.pdp8.info\ndate: #{date}" -signed_string = keypair.sign(OpenSSL::Digest::SHA256.new, signed_string) -signature = Base64.urlsafe_encode64(signed_string).encode("UTF-8") -signed_header = 'keyId="https://social.pdp8.info/pdp8",headers="(request-target) host date",signature="' + signature + '"' - -uri = URI.parse("https://social.pdp8.info/inbox") -http = Net::HTTP.new(uri.host, uri.port) -http.use_ssl = true -http.verify_mode = OpenSSL::SSL::VERIFY_NONE -header = { - 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - 'Host' => 'social.pdp8.info', - 'Date' => date, - 'Signature' => signed_header, -} -request = Net::HTTP::Post.new(uri.request_uri, header) -request.body = document.to_json - -response = http.request(request) -puts(response.body, response.code) |