assemblee-virtuelle / activitypods

Brings together two game-changing technologies, ActivityPub and Solid Pods, and empowers developers to create truly decentralized applications

Home Page:https://activitypods.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SemApps Chat

activitypods-small

ActivityPods

Check out our website or these slides (French version) for more information about this project !

Note: the next version of ActivityPods, currently in alpha stage, is available in the next branch.

Frontends using ActivityPods

Pod providers

Available bots

Utilities

Getting started

Launch the triplestore

docker-compose up -d fuseki

Bootstrap (installs frontend and backend)

yarn install

Launch the backend

cd backend
yarn run dev

Launch the frontend

cd frontend
yarn start

Quick guide

Create an actor with a Pod

POST /auth/signup HTTP/1.1
Host: localhost:3000
Content-Type: application/json

{
    "name": "Alice",
    "username": "alice",
    "email": "alice@test.com",
    "password": "test"
}

This will create an ActivityPub actor on http://localhost:3000/alice (viewable by everyone) and a Solid Pod on http://localhost:3000/alice/data.

You will receive in return a JWT token to authenticate the newly-created user on subsequent requests.

{
  "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "webId": "http://localhost:3000/alice",
  "newUser": true
}

If you need to login again with the same user, you can use the /auth/login endpoint with the username and password.

Post a resource in a container

Upon actor creation, several LDP containers have been automatically created on the http://localhost:3000/alice/data Pod: /profiles, /events, /places.

You can now post an event on the /events container, following the LDP specification.

POST /alice/data/events HTTP/1.1
Host: localhost:3000
Content-Type: application/ld+json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

{
    "@context": "https://www.w3.org/ns/activitystreams",
    "type": "Event",
    "name": "Birthday party !"
}

The URL of the newly-created event will be returned in the Location: header of the response.

Location: http://localhost:3000/alice/data/events/61a0f897e5b88b06f85b1190
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"

By default, this event is only visible by yourself (you can do a GET with the JWT token).

Post an activity in the outbox

The created actor has everything needed to exchange with other ActivityPub actors.

You can announce the new event using the ActivityPub outbox:

POST /alice/outbox HTTP/1.1
Host: localhost:3000
Content-Type: application/ld+json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

{
    "@context": "https://www.w3.org/ns/activitystreams",
    "type": "Announce",
    "actor": "http://localhost:3000/alice",
    "object": "http://localhost:3000/alice/data/events/61a0f897e5b88b06f85b1190",
    "to": "https://www.w3.org/ns/activitystreams#Public"
}

Since this activity is public, anyone will be able to view it on the outbox. But you could of course have sent it only to selected users, in which case it will have been sent to their inboxes.

GET /alice/outbox?page=1 HTTP/1.1
Host: localhost:3000
Accept: application/ld+json

{
    "@context": "http://localhost:3000/_system/context.json",
    "id": "http://localhost:3000/alice/outbox?page=1",
    "type": "OrderedCollectionPage",
    "partOf": "http://localhost:3000/alice/outbox",
    "orderedItems": [{
        "id": "http://localhost:3000/alice/data/activities/61b72a9cc7ff2f4bbb85606b",
        "type": "Announce",
        "actor": "http://localhost:3000/alice",
        "object": "http://localhost:3000/alice/data/events/61a0f897e5b88b06f85b1190",
        "published": "2021-12-13T11:12:28.943Z",
        "to": "as:Public"
    }],
    "totalItems": 1
}

Linking to SemApps packages

To modify packages on the SemApps repository, and see the changes before they are published on NPM, see the following instructions.

Linking backend packages

To link backend packages, you can use yarn link.

cd /SEMAPPS_REPO/src/middleware
yarn run link-all
cd /ACTIVITYPODS_REPO
yarn run link-semapps-packages

Linking frontend packages

Linking frontend packages with yarn link doesn't work because it causes version mismatch errors for React and MUI (see this PR for explainations). So you should use Yalc instead. Fortunately, we make it easy for you.

cd /SEMAPPS_REPO/src/frontend
yarn run yalc:publish
cd /ACTIVITYPODS_REPO/frontend
yarn run link-semapps-packages

Additionally, frontend packages need to be rebuilt on every change, or they will not be taken into account by ActivityPods. You can use yarn run build to build a package once, or yarn run watch to rebuild a package on every change. On every build, the new package will be published to Yalc.

Thanks to Git hooks, the frontend packages will also be published to Yalc whenever Git branches are changed.

Deployment to production

Follow the guide here.

Integration tests

yarn install
docker-compose up -d fuseki_test
cd tests
yarn run test

Cleaning up

Fuseki requires regular compacting, or it will eat up all your disk space. It must be done with Fuseki stopped. In dev environment, you can use the following command which will first stop all containers, compact all datasets (including those used by tests), and then start again all containers.

./compact.sh

Funding

This project is funded through the NGI0 Entrust Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101069594. Learn more on the NLnet project page.

NLNet foundation logo NGI Zero Entrust Logo

About

Brings together two game-changing technologies, ActivityPub and Solid Pods, and empowers developers to create truly decentralized applications

https://activitypods.org

License:Apache License 2.0


Languages

Language:JavaScript 87.7%Language:TypeScript 8.3%Language:CSS 2.8%Language:Dockerfile 0.5%Language:Shell 0.5%Language:HTML 0.3%