@evanp/activitypub-bot 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.github/dependabot.yml +11 -0
  2. package/.github/workflows/main-docker.yml +45 -0
  3. package/.github/workflows/tag-docker.yml +54 -0
  4. package/Dockerfile +23 -0
  5. package/LICENSE +661 -0
  6. package/README.md +82 -0
  7. package/bots/index.js +7 -0
  8. package/docs/activitypub.bot.drawio +110 -0
  9. package/index.js +23 -0
  10. package/lib/activitydistributor.js +263 -0
  11. package/lib/activityhandler.js +999 -0
  12. package/lib/activitypubclient.js +126 -0
  13. package/lib/activitystreams.js +41 -0
  14. package/lib/actorstorage.js +300 -0
  15. package/lib/app.js +173 -0
  16. package/lib/authorizer.js +133 -0
  17. package/lib/bot.js +44 -0
  18. package/lib/botcontext.js +520 -0
  19. package/lib/botdatastorage.js +87 -0
  20. package/lib/bots/donothing.js +11 -0
  21. package/lib/bots/ok.js +41 -0
  22. package/lib/digester.js +23 -0
  23. package/lib/httpsignature.js +195 -0
  24. package/lib/httpsignatureauthenticator.js +81 -0
  25. package/lib/keystorage.js +113 -0
  26. package/lib/microsyntax.js +140 -0
  27. package/lib/objectcache.js +48 -0
  28. package/lib/objectstorage.js +319 -0
  29. package/lib/remotekeystorage.js +116 -0
  30. package/lib/routes/collection.js +92 -0
  31. package/lib/routes/health.js +24 -0
  32. package/lib/routes/inbox.js +83 -0
  33. package/lib/routes/object.js +69 -0
  34. package/lib/routes/server.js +47 -0
  35. package/lib/routes/user.js +63 -0
  36. package/lib/routes/webfinger.js +36 -0
  37. package/lib/urlformatter.js +97 -0
  38. package/package.json +51 -0
  39. package/tests/activitydistributor.test.js +606 -0
  40. package/tests/activityhandler.test.js +2185 -0
  41. package/tests/activitypubclient.test.js +225 -0
  42. package/tests/actorstorage.test.js +261 -0
  43. package/tests/app.test.js +17 -0
  44. package/tests/authorizer.test.js +306 -0
  45. package/tests/bot.donothing.test.js +30 -0
  46. package/tests/bot.ok.test.js +101 -0
  47. package/tests/botcontext.test.js +674 -0
  48. package/tests/botdatastorage.test.js +87 -0
  49. package/tests/digester.test.js +56 -0
  50. package/tests/fixtures/bots.js +15 -0
  51. package/tests/httpsignature.test.js +200 -0
  52. package/tests/httpsignatureauthenticator.test.js +463 -0
  53. package/tests/keystorage.test.js +89 -0
  54. package/tests/microsyntax.test.js +122 -0
  55. package/tests/objectcache.test.js +133 -0
  56. package/tests/objectstorage.test.js +148 -0
  57. package/tests/remotekeystorage.test.js +76 -0
  58. package/tests/routes.actor.test.js +207 -0
  59. package/tests/routes.collection.test.js +434 -0
  60. package/tests/routes.health.test.js +41 -0
  61. package/tests/routes.inbox.test.js +135 -0
  62. package/tests/routes.object.test.js +519 -0
  63. package/tests/routes.server.test.js +69 -0
  64. package/tests/routes.webfinger.test.js +41 -0
  65. package/tests/urlformatter.test.js +164 -0
  66. package/tests/utils/digest.js +7 -0
  67. package/tests/utils/nock.js +276 -0
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,45 @@
1
+ name: Build and push Docker image
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ contents: read
11
+ packages: write
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+
17
+ env:
18
+ REGISTRY: ghcr.io
19
+ REPOSITORY: evanp/activitypub-bot
20
+
21
+ steps:
22
+ - name: Checkout repository
23
+ uses: actions/checkout@v2
24
+
25
+ - name: Set up Docker Buildx
26
+ uses: docker/setup-buildx-action@v1
27
+
28
+ - name: Log in to GitHub Container Registry
29
+ uses: docker/login-action@v1
30
+ with:
31
+ registry: ${{ env.REGISTRY }}
32
+ username: ${{ github.actor }}
33
+ password: ${{ secrets.GITHUB_TOKEN }}
34
+
35
+ - name: Build and push
36
+ uses: docker/build-push-action@v5
37
+ with:
38
+ context: .
39
+ push: true
40
+ platforms: linux/amd64,linux/arm64
41
+ tags: |
42
+ ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:latest
43
+ ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ github.sha }}
44
+ cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY }}:latest
45
+ cache-to: type=inline
@@ -0,0 +1,54 @@
1
+ name: Build and Push Docker Image
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v[0-9]+.[0-9]+.[0-9]+'
7
+
8
+ jobs:
9
+ build-and-push:
10
+ runs-on: ubuntu-latest
11
+
12
+ permissions:
13
+ contents: read
14
+ packages: write
15
+
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v3
19
+
20
+ - name: Set up Docker Buildx
21
+ uses: docker/setup-buildx-action@v2
22
+
23
+ - name: Extract version components from tag
24
+ id: get_version
25
+ run: |
26
+ FULL_VERSION=${GITHUB_REF#refs/tags/v}
27
+ MAJOR=$(echo $FULL_VERSION | cut -d. -f1)
28
+ MINOR=$(echo $FULL_VERSION | cut -d. -f2)
29
+ PATCH=$(echo $FULL_VERSION | cut -d. -f3)
30
+
31
+ echo "FULL_VERSION=$FULL_VERSION" >> $GITHUB_OUTPUT
32
+ echo "MAJOR_VERSION=$MAJOR" >> $GITHUB_OUTPUT
33
+ echo "MAJOR_MINOR_VERSION=$MAJOR.$MINOR" >> $GITHUB_OUTPUT
34
+
35
+ - name: Login to GitHub Container Registry
36
+ uses: docker/login-action@v2
37
+ with:
38
+ registry: ghcr.io
39
+ username: ${{ github.actor }}
40
+ password: ${{ secrets.GITHUB_TOKEN }}
41
+
42
+ - name: Build and push Docker image
43
+ uses: docker/build-push-action@v4
44
+ with:
45
+ context: .
46
+ push: true
47
+ platforms: linux/amd64,linux/arm64
48
+ tags: |
49
+ ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.FULL_VERSION }}
50
+ ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.MAJOR_MINOR_VERSION }}
51
+ ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.MAJOR_VERSION }}
52
+ ghcr.io/${{ github.repository }}:${{ github.sha }}
53
+ cache-from: type=gha
54
+ cache-to: type=gha,mode=max
package/Dockerfile ADDED
@@ -0,0 +1,23 @@
1
+ FROM node:20-alpine AS builder
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apk add --no-cache python3 make g++ py3-setuptools
6
+
7
+ COPY package.json package-lock.json ./
8
+ RUN npm ci
9
+
10
+ COPY index.js .
11
+ COPY lib lib
12
+ COPY bots bots
13
+ COPY README.md .
14
+
15
+ FROM node:20-alpine
16
+
17
+ WORKDIR /app
18
+
19
+ RUN apk add --no-cache libstdc++ sqlite sqlite-libs
20
+
21
+ COPY --from=builder /app/ ./
22
+
23
+ CMD ["npm", "start"]