skohub-io / skohub-pubsub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improvement of README.md

sroertgen opened this issue · comments

Hello there and thanks for your great work!

I just wanted to mention that when trying your project out, I had to provide a key in .pem-format in the data-directory. Otherwise the project didn't run. Also the npm test-command is still failing even, when providing the key with the following output:

$ npm test

> skohub-pubsub@0.1.0 test /.../skohub/skohub-pubsub
> eslint src/ && jest

  console.log src/activitypub.js:62
    { host: '127.0.0.1:59725',
      'accept-encoding': 'gzip, deflate',
      'user-agent': 'node-superagent/3.8.3',
      connection: 'close' }

  console.log src/activitypub.js:63
    {}

GET /.well-known/webfinger?resource=acct%3A6c697465726172796d616368696e652f736b6f732f773369642e6f72672f636c6173732f686f6368736368756c666165636865722f423536%40127.0.0.1%3A59725 200 58.688 ms - 296
  console.log src/activitypub.js:62
    { host: 'localhost:3001',
      'accept-encoding': 'gzip',
      'user-agent':
       'http.rb/3.3.0 (Mastodon/3.0.1; +https://openbiblio.social/)',
      date: 'Fri, 15 Nov 2019 11:28:48 GMT',
      digest: 'SHA-256=G5dlKO1mapLz4t8oq6tGBrXTIdaoN4fxklbDsPDURs0=',
      'content-type': 'application/activity+json',
      signature:
       'keyId="https://openbiblio.social/users/literarymachine#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="l5afVIKkHqh8Uj2pO/X3KVq8c3uwIA2J2ATEX7Dq+pAagwy43SNn205jXWk2FAg6sV5Xzpbre2YcuEd0UpfUJUrFR+u9i+YpCaK6hgLZJ6x+QW4v63mp91sHpv698hnHzJ3DuXN8pqqeGR/HFNh3CG1mZxwOYNf/EBJbQ79eUfa80RvBvnP5kMAki+Rd/FkjOFzuem2Yb09Wz66tUU75ecjoan405R1Bi8e7j5UwWku4vHI1hGWbLxgI0TlgHGs/fQQ3txYXeKVqqD4zFH6Ij7zau0cNLdt+gtsn0hi78d9/Y1TMZI+fhhegDFUqgPgkmfCX5jXSAeCTgkimi/LEaQ=="',
      'x-forwarded-proto': 'https',
      'x-forwarded-host': 'test.skohub.io',
      'x-forwarded-server': 'test.skohub.io',
      'content-length': '287',
      connection: 'close' }

  console.log src/activitypub.js:63
    { '@context': 'https://www.w3.org/ns/activitystreams',
      id:
       'https://openbiblio.social/46279d5a-656a-4b29-bdfd-ee280e83f0e0',
      type: 'Follow',
      actor: 'https://openbiblio.social/users/literarymachine',
      object:
       'https://test.skohub.io/literarymachine/skos/w3id.org/class/hochschulfaecher/B56' }

 FAIL  tests/activitypub.test.js
  Webfinger
    ✓ returns correct link for valid webfinger user (101ms)
  ActivityPub
    ✕ accepts valid follow requests (98ms)
    ✕ distributes notifications to followers (4ms)
    ✕ persists notifications (2ms)
    ✕ unverified actions are rejected (14ms)
    ✓ unsupported actions are rejected (11ms)
    ✕ new followers are added to followers list (11ms)
    ✕ undone followers are removed from followers list (11ms)

  ● ActivityPub › accepts valid follow requests

    error:0909006C:PEM routines:get_name:no start line

      118 |   ].join('\n'))
      119 |   signer.end()
    > 120 |   const signature = signer.sign(PRIV_KEY).toString('base64')
          |                            ^
      121 |   const header = [
      122 |     `keyId="${from.id}#main-key"`,
      123 |     `headers="(request-target) host date"`,

      at sign (src/activitypub.js:120:28)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
      at node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12

  ● ActivityPub › distributes notifications to followers

    assert.equal(received, expected) or assert(received)

    Expected value to be equal to:
      true
    Received:
      false

    Message:
      Mocks not yet satisfied:
    POST https://openbiblio.social:443/users/literarymachine/inbox

      46 |     // confirm ACCEPT message confirming FOLLOW activity has been received
      47 |     await timeout(10)
    > 48 |     acceptScope.done()
         |                 ^
      49 |     done()
      50 |   })
      51 |

      at Scope.done (node_modules/nock/lib/scope.js:155:10)
      at done (tests/activitypub.test.js:48:17)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)

  ● ActivityPub › persists notifications

    connect ECONNRESET 127.0.0.1:59729



  ● ActivityPub › unverified actions are rejected

    connect ECONNRESET 127.0.0.1:59731



  ● ActivityPub › new followers are added to followers list

    error:0909006C:PEM routines:get_name:no start line

      118 |   ].join('\n'))
      119 |   signer.end()
    > 120 |   const signature = signer.sign(PRIV_KEY).toString('base64')
          |                            ^
      121 |   const header = [
      122 |     `keyId="${from.id}#main-key"`,
      123 |     `headers="(request-target) host date"`,

      at sign (src/activitypub.js:120:28)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
      at node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12

  ● ActivityPub › undone followers are removed from followers list

    assert.equal(received, expected) or assert(received)

    Expected value to be equal to:
      true
    Received:
      false

    Message:
      Mocks not yet satisfied:
    POST https://openbiblio.social:443/users/literarymachine/inbox

      138 |
      139 |     await timeout(10)
    > 140 |     acceptScope.done()
          |                 ^
      141 |
      142 |     const response = await request.agent(server).get('/followers')
      143 |       .set({

      at Scope.done (node_modules/nock/lib/scope.js:155:10)
      at done (tests/activitypub.test.js:140:17)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)

  ● ActivityPub › undone followers are removed from followers list

    error:0909006C:PEM routines:get_name:no start line

      118 |   ].join('\n'))
      119 |   signer.end()
    > 120 |   const signature = signer.sign(PRIV_KEY).toString('base64')
          |                            ^
      121 |   const header = [
      122 |     `keyId="${from.id}#main-key"`,
      123 |     `headers="(request-target) host date"`,

      at sign (src/activitypub.js:120:28)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
      at node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12

Test Suites: 1 failed, 1 total
Tests:       6 failed, 2 passed, 8 total
Snapshots:   0 total
Time:        2.095s
Ran all test suites.
(node:61676) UnhandledPromiseRejectionWarning: Error: Caught error after test environment was torn down

assert.equal(received, expected) or assert(received)

Expected value to be equal to:
  true
Received:
  false

Message:
  Mocks not yet satisfied:
POST https://openbiblio.social:443/users/literarymachine/inbox
    at Scope.done (/.../skohub/skohub-pubsub/node_modules/nock/lib/scope.js:155:10)
    at done (/...skohub/skohub-pubsub/tests/activitypub.test.js:166:17)
    at tryCatch (/.../skohub/skohub-pubsub/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/.../skohub/skohub-pubsub/node_modules/regenerator-runtime/runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (/.../skohub/skohub-pubsub/node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (/.../skohub/skohub-pubsub/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/.../skohub/skohub-pubsub/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
(node:61676) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
(node:61676) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
POST /inbox 201 71.112 ms - -
  console.log src/activitypub.js:62
    { host: 'localhost:3001',
      'accept-encoding': 'gzip',
      'user-agent':
       'http.rb/3.3.0 (Mastodon/3.0.1; +https://openbiblio.social/)',
      date: 'Fri, 15 Nov 2019 11:28:48 GMT',
      digest: 'SHA-256=G5dlKO1mapLz4t8oq6tGBrXTIdaoN4fxklbDsPDURs0=',
      'content-type': 'application/activity+json',
      signature:
       'keyId="https://openbiblio.social/users/literarymachine#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="foobar"',
      'x-forwarded-proto': 'https',
      'x-forwarded-host': 'test.skohub.io',
      'x-forwarded-server': 'test.skohub.io',
      'content-length': '287',
      connection: 'close' }

  console.log src/activitypub.js:63
    { '@context': 'https://www.w3.org/ns/activitystreams',
      id:
       'https://openbiblio.social/46279d5a-656a-4b29-bdfd-ee280e83f0e0',
      type: 'Follow',
      actor: 'https://openbiblio.social/users/literarymachine',
      object:
       'https://test.skohub.io/literarymachine/skos/w3id.org/class/hochschulfaecher/B56' }

  console.warn src/activitypub.js:219
    Could not verify action

POST /inbox 400 10.038 ms - -
  console.log src/activitypub.js:62
    { host: 'localhost:3001',
      'accept-encoding': 'gzip',
      'user-agent':
       'http.rb/3.3.0 (Mastodon/3.0.1; +https://openbiblio.social/)',
      date: 'Fri, 15 Nov 2019 11:28:48 GMT',
      digest: 'SHA-256=G5dlKO1mapLz4t8oq6tGBrXTIdaoN4fxklbDsPDURs0=',
      'content-type': 'application/activity+json',
      signature:
       'keyId="https://openbiblio.social/users/literarymachine#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="l5afVIKkHqh8Uj2pO/X3KVq8c3uwIA2J2ATEX7Dq+pAagwy43SNn205jXWk2FAg6sV5Xzpbre2YcuEd0UpfUJUrFR+u9i+YpCaK6hgLZJ6x+QW4v63mp91sHpv698hnHzJ3DuXN8pqqeGR/HFNh3CG1mZxwOYNf/EBJbQ79eUfa80RvBvnP5kMAki+Rd/FkjOFzuem2Yb09Wz66tUU75ecjoan405R1Bi8e7j5UwWku4vHI1hGWbLxgI0TlgHGs/fQQ3txYXeKVqqD4zFH6Ij7zau0cNLdt+gtsn0hi78d9/Y1TMZI+fhhegDFUqgPgkmfCX5jXSAeCTgkimi/LEaQ=="',
      'x-forwarded-proto': 'https',
      'x-forwarded-host': 'test.skohub.io',
      'x-forwarded-server': 'test.skohub.io',
      'content-length': '284',
      connection: 'close' }

  console.log src/activitypub.js:63
    { '@context': 'https://www.w3.org/ns/activitystreams',
      id:
       'https://openbiblio.social/46279d5a-656a-4b29-bdfd-ee280e83f0e0',
      type: 'Add',
      actor: 'https://openbiblio.social/users/literarymachine',
      object:
       'https://test.skohub.io/literarymachine/skos/w3id.org/class/hochschulfaecher/B56' }

  console.warn src/activitypub.js:231
    Unhandled action type Add

POST /inbox 400 8.470 ms - -
  console.log src/activitypub.js:62
    { host: 'localhost:3001',
      'accept-encoding': 'gzip',
      'user-agent':
       'http.rb/3.3.0 (Mastodon/3.0.1; +https://openbiblio.social/)',
      date: 'Fri, 15 Nov 2019 11:28:48 GMT',
      digest: 'SHA-256=G5dlKO1mapLz4t8oq6tGBrXTIdaoN4fxklbDsPDURs0=',
      'content-type': 'application/activity+json',
      signature:
       'keyId="https://openbiblio.social/users/literarymachine#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="l5afVIKkHqh8Uj2pO/X3KVq8c3uwIA2J2ATEX7Dq+pAagwy43SNn205jXWk2FAg6sV5Xzpbre2YcuEd0UpfUJUrFR+u9i+YpCaK6hgLZJ6x+QW4v63mp91sHpv698hnHzJ3DuXN8pqqeGR/HFNh3CG1mZxwOYNf/EBJbQ79eUfa80RvBvnP5kMAki+Rd/FkjOFzuem2Yb09Wz66tUU75ecjoan405R1Bi8e7j5UwWku4vHI1hGWbLxgI0TlgHGs/fQQ3txYXeKVqqD4zFH6Ij7zau0cNLdt+gtsn0hi78d9/Y1TMZI+fhhegDFUqgPgkmfCX5jXSAeCTgkimi/LEaQ=="',
      'x-forwarded-proto': 'https',
      'x-forwarded-host': 'test.skohub.io',
      'x-forwarded-server': 'test.skohub.io',
      'content-length': '287',
      connection: 'close' }

  console.log src/activitypub.js:63
    { '@context': 'https://www.w3.org/ns/activitystreams',
      id:
       'https://openbiblio.social/46279d5a-656a-4b29-bdfd-ee280e83f0e0',
      type: 'Follow',
      actor: 'https://openbiblio.social/users/literarymachine',
      object:
       'https://test.skohub.io/literarymachine/skos/w3id.org/class/hochschulfaecher/B56' }

POST /inbox 201 6.534 ms - -
  console.log src/activitypub.js:62
    { host: 'localhost:3001',
      'accept-encoding': 'gzip',
      'user-agent':
       'http.rb/3.3.0 (Mastodon/3.0.1; +https://openbiblio.social/)',
      date: 'Fri, 15 Nov 2019 11:28:48 GMT',
      digest: 'SHA-256=G5dlKO1mapLz4t8oq6tGBrXTIdaoN4fxklbDsPDURs0=',
      'content-type': 'application/activity+json',
      signature:
       'keyId="https://openbiblio.social/users/literarymachine#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="l5afVIKkHqh8Uj2pO/X3KVq8c3uwIA2J2ATEX7Dq+pAagwy43SNn205jXWk2FAg6sV5Xzpbre2YcuEd0UpfUJUrFR+u9i+YpCaK6hgLZJ6x+QW4v63mp91sHpv698hnHzJ3DuXN8pqqeGR/HFNh3CG1mZxwOYNf/EBJbQ79eUfa80RvBvnP5kMAki+Rd/FkjOFzuem2Yb09Wz66tUU75ecjoan405R1Bi8e7j5UwWku4vHI1hGWbLxgI0TlgHGs/fQQ3txYXeKVqqD4zFH6Ij7zau0cNLdt+gtsn0hi78d9/Y1TMZI+fhhegDFUqgPgkmfCX5jXSAeCTgkimi/LEaQ=="',
      'x-forwarded-proto': 'https',
      'x-forwarded-host': 'test.skohub.io',
      'x-forwarded-server': 'test.skohub.io',
      'content-length': '287',
      connection: 'close' }

  console.log src/activitypub.js:63
    { '@context': 'https://www.w3.org/ns/activitystreams',
      id:
       'https://openbiblio.social/46279d5a-656a-4b29-bdfd-ee280e83f0e0',
      type: 'Follow',
      actor: 'https://openbiblio.social/users/literarymachine',
      object:
       'https://test.skohub.io/literarymachine/skos/w3id.org/class/hochschulfaecher/B56' }

POST /inbox 201 6.384 ms - -
npm ERR! Test failed.  See above for more details.

SUGGESTION
For providing an easy entry, maybe you could improve the README by noting that one has to generate the keys and place them in the data directory. Maybe you could also provide an example on how to use the AcitivityPub Server. E.g. like how to subscribe, set up a user etc.

Thanks again! If I find some time, I might also make a suggest, but as you already now this project very well, I guess you will be faster!

All the best!

Hi @sroertgen, thanks for your report!

I just wanted to mention that when trying your project out, I had to provide a key in .pem-format in the data-directory. Also the npm test-command is still failing even, when providing the key with the following output.

In order to run the test, no .pem has to be provided, a key will be generated. If this does not work for you, I assume that your version of node is outdated. Which one are you using? Tests run fine for me on the latest stable (v13.7.0).

For providing an easy entry, maybe you could improve the README by noting that one has to generate the keys and place them in the data directory. Maybe you could also provide an example on how to use the AcitivityPub Server. E.g. like how to subscribe, set up a user etc.

Will do!

Hello @literarymachine,

you are right! I had an outdated node version running. I can confirm that with v13.7.0 everything is running fine!

Thank you for your fast response and providing some basic examples!

As it works for @sroertgen now and the README was improved with #34 and cf495a8 and a start script is provided this issue is closed.