fix sharedInbox

This commit is contained in:
Michael Puckett 2022-10-14 21:47:00 -04:00
parent ffc0359085
commit 4f2a52ca79
169 changed files with 2158 additions and 1195 deletions

3
.eslintrc.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright © 2022 Michael Puckett
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

556
package-lock.json generated
View File

@ -4005,6 +4005,10 @@
"resolved": "packages/activitypub-core-delivery",
"link": true
},
"node_modules/activitypub-core-example-2": {
"resolved": "packages/activitypub-core-example-2",
"link": true
},
"node_modules/activitypub-core-example-mongodb-express-jsx": {
"resolved": "packages/activitypub-core-example-mongodb-express-jsx",
"link": true
@ -11063,6 +11067,21 @@
"node": ">= 0.8.0"
}
},
"node_modules/prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/pretty-format": {
"version": "29.1.2",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.1.2.tgz",
@ -13775,12 +13794,12 @@
}
},
"packages/activitypub-core": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-delivery": "^0.0.43",
"activitypub-core-types": "^0.0.42",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"cookie": "^0.5.0",
"firebase-admin": "^11.1.0",
"http": "^0.0.1-security",
@ -13797,16 +13816,17 @@
"@types/jsonld": "^1.5.6",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}
},
"packages/activitypub-core-delivery": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"isomorphic-fetch": "^3.0.0"
},
"devDependencies": {
@ -13814,15 +13834,11 @@
"@types/jsonld": "^1.5.6",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}
},
"packages/activitypub-core-delivery/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core-delivery/node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -13832,15 +13848,120 @@
"node": ">=12"
}
},
"packages/activitypub-core-example-mongodb-express-jsx": {
"version": "0.0.51",
"packages/activitypub-core-example-2": {
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-delivery": "^0.0.51",
"activitypub-core-express-middleware": "^0.0.51",
"activitypub-core-jsx-components": "^0.0.51",
"activitypub-core-types": "^0.0.51",
"activitypub-core-utilities": "^0.0.51",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-express-middleware": "^0.0.54",
"activitypub-core-jsx-components": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase-admin": "^11.1.0",
"react": "^16.14.0",
"react-server": "^0.8.1"
},
"devDependencies": {
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"ts-node": "^10.9.1"
}
},
"packages/activitypub-core-example-2/node_modules/cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha512-+IJOX0OqlHCszo2mBUq+SrEbCj6w7Kpffqx60zYbPTFaO4+yYgRjHwcZNpWvaTylDHaV7PPmBHzSecZiMhtPgw==",
"engines": {
"node": ">= 0.6"
}
},
"packages/activitypub-core-example-2/node_modules/eventemitter3": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz",
"integrity": "sha512-jLN68Dx5kyFHaePoXWPsCGW5qdyZQtLYHkxkg02/Mz6g0kYpDx4FyP6XfArhQdlOC4b8Mv+EMxPo/8La7Tzghg=="
},
"packages/activitypub-core-example-2/node_modules/q": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz",
"integrity": "sha512-/CdEdaw49VZVmyIDGUQKDDT53c7qBkO6g5CefWz91Ae+l4+cRtcDYwMTXh6me4O8TMldeGHG3N2Bl84V78Ywbg==",
"engines": {
"node": ">=0.6.0",
"teleport": ">=0.2.0"
}
},
"packages/activitypub-core-example-2/node_modules/react": {
"version": "16.14.0",
"resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz",
"integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==",
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2"
},
"engines": {
"node": ">=0.10.0"
}
},
"packages/activitypub-core-example-2/node_modules/react-dom": {
"version": "16.14.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz",
"integrity": "sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==",
"peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"scheduler": "^0.19.1"
},
"peerDependencies": {
"react": "^16.14.0"
}
},
"packages/activitypub-core-example-2/node_modules/react-server": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/react-server/-/react-server-0.8.1.tgz",
"integrity": "sha512-1l0IAUF1sd5pK2Y6aResnH/47N9CPza3dQdA0e/pdYRYn8I9sZpsc9PBc+//xOcq+CHh/TU6JX9pBHQ25BC1tA==",
"dependencies": {
"body-parser": "^1.15.2",
"cls-q": "1.1.0",
"cookie": "^0.3.1",
"cookie-parser": "1.4.3",
"eventemitter3": "^2.0.2",
"express-state": "^1.4.0",
"flab": "^0.6.3",
"lodash": "^4.16.4",
"mobile-detect": "^1.3.5",
"q": "1.4.1",
"querystring": "0.2.0",
"request-local-storage": "^1.2.0",
"routr": "^2.1.0",
"winston": "^2.3.0"
},
"peerDependencies": {
"react": "~0.14.9 || ^15.3.0 || ^16.0.0",
"react-dom": "~0.14.9 || ^15.3.0 || ^16.0.0",
"superagent": "1.8.4"
}
},
"packages/activitypub-core-example-2/node_modules/scheduler": {
"version": "0.19.1",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz",
"integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==",
"peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
}
},
"packages/activitypub-core-example-mongodb-express-jsx": {
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-express-middleware": "^0.0.54",
"activitypub-core-jsx-components": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase-admin": "^11.1.0",
"react": "^16.14.0",
"react-server": "^0.8.1"
@ -13975,72 +14096,44 @@
}
},
"packages/activitypub-core-express-middleware": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core": "^0.0.51",
"activitypub-core-delivery": "^0.0.41",
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core": "^0.0.54",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"express": "^4.18.2",
"firebase-admin": "^11.1.0",
"http": "^0.0.1-security"
},
"devDependencies": {
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
}
},
"packages/activitypub-core-express-middleware/node_modules/activitypub-core-delivery": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/activitypub-core-delivery/-/activitypub-core-delivery-0.0.41.tgz",
"integrity": "sha512-4e6WAKNX204/Jk302g3gv1shFQUzYsxmrP4v5PthfDkxnPpn/I+yPb32YRe2oZcV/j3wD7C/580Uq7OfXiyIqQ==",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"isomorphic-fetch": "^3.0.0"
}
},
"packages/activitypub-core-express-middleware/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core-express-middleware/node_modules/activitypub-core-utilities": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-utilities/-/activitypub-core-utilities-0.0.40.tgz",
"integrity": "sha512-aGwj93MH2F5fl6QCiFD6vdwLEb5nfl5uN2RMXncX2hNweCX1fqh9es0p2it2W1OPzkeEFDziEwpEV5C8hwJ1oA==",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
}
},
"packages/activitypub-core-jsx-components": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase": "^9.12.0",
"react": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.21",
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
}
},
"packages/activitypub-core-jsx-components/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core-mongodb": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-delivery": "^0.0.41",
"activitypub-core-types": "^0.0.41",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase-admin": "^11.1.0",
"mongodb": "^4.10.0"
},
@ -14048,48 +14141,11 @@
"@types/jest": "^29.1.2",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}
},
"packages/activitypub-core-mongodb/node_modules/activitypub-core-delivery": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/activitypub-core-delivery/-/activitypub-core-delivery-0.0.41.tgz",
"integrity": "sha512-4e6WAKNX204/Jk302g3gv1shFQUzYsxmrP4v5PthfDkxnPpn/I+yPb32YRe2oZcV/j3wD7C/580Uq7OfXiyIqQ==",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"isomorphic-fetch": "^3.0.0"
}
},
"packages/activitypub-core-mongodb/node_modules/activitypub-core-delivery/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core-mongodb/node_modules/activitypub-core-types": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.41.tgz",
"integrity": "sha512-kIaJ6Jxwc1BeeO7j/Xm//070L07dckLPd/Qs3SkaJ02ytBunI1XbkSqFReSXRNd9UUYUS47XPAfd5BbHAPUU0w==",
"dependencies": {
"activitypub-core-utilities": "^0.0.40"
}
},
"packages/activitypub-core-mongodb/node_modules/activitypub-core-utilities": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-utilities/-/activitypub-core-utilities-0.0.40.tgz",
"integrity": "sha512-aGwj93MH2F5fl6QCiFD6vdwLEb5nfl5uN2RMXncX2hNweCX1fqh9es0p2it2W1OPzkeEFDziEwpEV5C8hwJ1oA==",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
}
},
"packages/activitypub-core-mongodb/node_modules/activitypub-core-utilities/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core-mongodb/node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -14100,17 +14156,18 @@
}
},
"packages/activitypub-core-types": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"devDependencies": {
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
}
},
"packages/activitypub-core-utilities": {
"version": "0.0.51",
"version": "0.0.54",
"license": "MIT",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-types": "^0.0.54",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
},
@ -14119,15 +14176,11 @@
"@types/jsonld": "^1.5.6",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}
},
"packages/activitypub-core-utilities/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core-utilities/node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -14137,36 +14190,6 @@
"node": ">=12"
}
},
"packages/activitypub-core/node_modules/activitypub-core-delivery": {
"version": "0.0.43",
"resolved": "https://registry.npmjs.org/activitypub-core-delivery/-/activitypub-core-delivery-0.0.43.tgz",
"integrity": "sha512-1SpZONwEvH5IR+hG6Rv7zDgfCLkdqhJ2drLYyUzfC8cPqLoxP8jOwFSd9wuqkzu6CDkxs46Viq0ZqQinjKUXLA==",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"isomorphic-fetch": "^3.0.0"
}
},
"packages/activitypub-core/node_modules/activitypub-core-delivery/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core/node_modules/activitypub-core-utilities": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-utilities/-/activitypub-core-utilities-0.0.40.tgz",
"integrity": "sha512-aGwj93MH2F5fl6QCiFD6vdwLEb5nfl5uN2RMXncX2hNweCX1fqh9es0p2it2W1OPzkeEFDziEwpEV5C8hwJ1oA==",
"dependencies": {
"activitypub-core-types": "^0.0.40",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
}
},
"packages/activitypub-core/node_modules/activitypub-core-utilities/node_modules/activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"packages/activitypub-core/node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -17389,9 +17412,9 @@
"@types/isomorphic-fetch": "^0.0.36",
"@types/jest": "^29.1.2",
"@types/jsonld": "^1.5.6",
"activitypub-core-delivery": "^0.0.43",
"activitypub-core-types": "^0.0.42",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"cookie": "^0.5.0",
"dotenv": "^16.0.3",
"firebase-admin": "^11.1.0",
@ -17401,45 +17424,12 @@
"jsonld": "^8.1.0",
"mongodb": "^4.10.0",
"next": "^12.3.1",
"prettier": "*",
"superjson": "^1.10.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
},
"dependencies": {
"activitypub-core-delivery": {
"version": "0.0.43",
"resolved": "https://registry.npmjs.org/activitypub-core-delivery/-/activitypub-core-delivery-0.0.43.tgz",
"integrity": "sha512-1SpZONwEvH5IR+hG6Rv7zDgfCLkdqhJ2drLYyUzfC8cPqLoxP8jOwFSd9wuqkzu6CDkxs46Viq0ZqQinjKUXLA==",
"requires": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"isomorphic-fetch": "^3.0.0"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
}
}
},
"activitypub-core-utilities": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-utilities/-/activitypub-core-utilities-0.0.40.tgz",
"integrity": "sha512-aGwj93MH2F5fl6QCiFD6vdwLEb5nfl5uN2RMXncX2hNweCX1fqh9es0p2it2W1OPzkeEFDziEwpEV5C8hwJ1oA==",
"requires": {
"activitypub-core-types": "^0.0.40",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
}
}
},
"dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -17453,20 +17443,16 @@
"requires": {
"@types/jest": "^29.1.2",
"@types/jsonld": "^1.5.6",
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"dotenv": "^16.0.3",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -17475,16 +17461,102 @@
}
}
},
"activitypub-core-example-2": {
"version": "file:packages/activitypub-core-example-2",
"requires": {
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-express-middleware": "^0.0.54",
"activitypub-core-jsx-components": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase-admin": "^11.1.0",
"react": "^16.14.0",
"react-server": "^0.8.1",
"ts-node": "^10.9.1"
},
"dependencies": {
"cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha512-+IJOX0OqlHCszo2mBUq+SrEbCj6w7Kpffqx60zYbPTFaO4+yYgRjHwcZNpWvaTylDHaV7PPmBHzSecZiMhtPgw=="
},
"eventemitter3": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz",
"integrity": "sha512-jLN68Dx5kyFHaePoXWPsCGW5qdyZQtLYHkxkg02/Mz6g0kYpDx4FyP6XfArhQdlOC4b8Mv+EMxPo/8La7Tzghg=="
},
"q": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz",
"integrity": "sha512-/CdEdaw49VZVmyIDGUQKDDT53c7qBkO6g5CefWz91Ae+l4+cRtcDYwMTXh6me4O8TMldeGHG3N2Bl84V78Ywbg=="
},
"react": {
"version": "16.14.0",
"resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz",
"integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2"
}
},
"react-dom": {
"version": "16.14.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz",
"integrity": "sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==",
"peer": true,
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"scheduler": "^0.19.1"
}
},
"react-server": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/react-server/-/react-server-0.8.1.tgz",
"integrity": "sha512-1l0IAUF1sd5pK2Y6aResnH/47N9CPza3dQdA0e/pdYRYn8I9sZpsc9PBc+//xOcq+CHh/TU6JX9pBHQ25BC1tA==",
"requires": {
"body-parser": "^1.15.2",
"cls-q": "1.1.0",
"cookie": "^0.3.1",
"cookie-parser": "1.4.3",
"eventemitter3": "^2.0.2",
"express-state": "^1.4.0",
"flab": "^0.6.3",
"lodash": "^4.16.4",
"mobile-detect": "^1.3.5",
"q": "1.4.1",
"querystring": "0.2.0",
"request-local-storage": "^1.2.0",
"routr": "^2.1.0",
"winston": "^2.3.0"
}
},
"scheduler": {
"version": "0.19.1",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz",
"integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==",
"peer": true,
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
}
}
}
},
"activitypub-core-example-mongodb-express-jsx": {
"version": "file:packages/activitypub-core-example-mongodb-express-jsx",
"requires": {
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"activitypub-core-delivery": "^0.0.51",
"activitypub-core-express-middleware": "^0.0.51",
"activitypub-core-jsx-components": "^0.0.51",
"activitypub-core-types": "^0.0.51",
"activitypub-core-utilities": "^0.0.51",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-express-middleware": "^0.0.54",
"activitypub-core-jsx-components": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase-admin": "^11.1.0",
"react": "^16.14.0",
"react-server": "^0.8.1",
@ -17564,118 +17636,45 @@
"activitypub-core-express-middleware": {
"version": "file:packages/activitypub-core-express-middleware",
"requires": {
"activitypub-core": "^0.0.51",
"activitypub-core-delivery": "^0.0.41",
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core": "^0.0.54",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"express": "^4.18.2",
"firebase-admin": "^11.1.0",
"http": "^0.0.1-security",
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
},
"dependencies": {
"activitypub-core-delivery": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/activitypub-core-delivery/-/activitypub-core-delivery-0.0.41.tgz",
"integrity": "sha512-4e6WAKNX204/Jk302g3gv1shFQUzYsxmrP4v5PthfDkxnPpn/I+yPb32YRe2oZcV/j3wD7C/580Uq7OfXiyIqQ==",
"requires": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"isomorphic-fetch": "^3.0.0"
}
},
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"activitypub-core-utilities": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-utilities/-/activitypub-core-utilities-0.0.40.tgz",
"integrity": "sha512-aGwj93MH2F5fl6QCiFD6vdwLEb5nfl5uN2RMXncX2hNweCX1fqh9es0p2it2W1OPzkeEFDziEwpEV5C8hwJ1oA==",
"requires": {
"activitypub-core-types": "^0.0.40",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
}
}
}
},
"activitypub-core-jsx-components": {
"version": "file:packages/activitypub-core-jsx-components",
"requires": {
"@types/react": "^18.0.21",
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase": "^9.12.0",
"prettier": "^2.7.1",
"react": "^18.2.0",
"ts-node": "^10.9.1"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
}
}
},
"activitypub-core-mongodb": {
"version": "file:packages/activitypub-core-mongodb",
"requires": {
"@types/jest": "^29.1.2",
"activitypub-core-delivery": "^0.0.41",
"activitypub-core-types": "^0.0.41",
"activitypub-core-utilities": "^0.0.40",
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"dotenv": "^16.0.3",
"firebase-admin": "^11.1.0",
"jest": "^29.1.2",
"mongodb": "^4.10.0",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
},
"dependencies": {
"activitypub-core-delivery": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/activitypub-core-delivery/-/activitypub-core-delivery-0.0.41.tgz",
"integrity": "sha512-4e6WAKNX204/Jk302g3gv1shFQUzYsxmrP4v5PthfDkxnPpn/I+yPb32YRe2oZcV/j3wD7C/580Uq7OfXiyIqQ==",
"requires": {
"activitypub-core-types": "^0.0.40",
"activitypub-core-utilities": "^0.0.40",
"isomorphic-fetch": "^3.0.0"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
}
}
},
"activitypub-core-types": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.41.tgz",
"integrity": "sha512-kIaJ6Jxwc1BeeO7j/Xm//070L07dckLPd/Qs3SkaJ02ytBunI1XbkSqFReSXRNd9UUYUS47XPAfd5BbHAPUU0w==",
"requires": {
"activitypub-core-utilities": "^0.0.40"
}
},
"activitypub-core-utilities": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-utilities/-/activitypub-core-utilities-0.0.40.tgz",
"integrity": "sha512-aGwj93MH2F5fl6QCiFD6vdwLEb5nfl5uN2RMXncX2hNweCX1fqh9es0p2it2W1OPzkeEFDziEwpEV5C8hwJ1oA==",
"requires": {
"activitypub-core-types": "^0.0.40",
"jsonld": "^8.1.0",
"superjson": "^1.10.1"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
}
}
},
"dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -17687,6 +17686,7 @@
"activitypub-core-types": {
"version": "file:packages/activitypub-core-types",
"requires": {
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
}
},
@ -17695,20 +17695,16 @@
"requires": {
"@types/jest": "^29.1.2",
"@types/jsonld": "^1.5.6",
"activitypub-core-types": "^0.0.40",
"activitypub-core-types": "^0.0.54",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"jsonld": "^8.1.0",
"prettier": "^2.7.1",
"superjson": "^1.10.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
},
"dependencies": {
"activitypub-core-types": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/activitypub-core-types/-/activitypub-core-types-0.0.40.tgz",
"integrity": "sha512-DwbhWt87m951/c6wxThpREQBWiu2bs0QXOvs5VqHM03iLLgjAG+CxMdg2mbEAuR1dSiMYg6KU/dtemJHqNTX0A=="
},
"dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@ -23113,6 +23109,12 @@
"integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==",
"optional": true
},
"prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true
},
"pretty-format": {
"version": "29.1.2",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.1.2.tgz",

View File

@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@ -3,7 +3,6 @@ import { AP } from 'activitypub-core-types';
import { generateKeyPair } from 'activitypub-core-utilities';
import { DeliveryService } from '../src';
describe('DeliveryService', () => {
describe('signAndSendToForeignActorInbox', () => {
const fetch = jest.fn(async () => {

View File

@ -1,3 +1,7 @@
import { DeliveryService } from '.';
import { AP } from 'activitypub-core-types';
export declare function broadcast(this: DeliveryService, activity: AP.Activity, actor: AP.Actor): Promise<any[]>;
export declare function broadcast(
this: DeliveryService,
activity: AP.Activity,
actor: AP.Actor,
): Promise<any[]>;

View File

@ -10,9 +10,10 @@ async function broadcast(activity, actor) {
throw new Error('Not an activity?');
}
const recipients = await this.getRecipientInboxUrls(activity, actor);
return await Promise.all(recipients.map(async (recipient) => {
const results = await Promise.all(recipients.map(async (recipient) => {
return await this.signAndSendToForeignActorInbox(recipient, actor, publicActivity);
}));
return results;
}
exports.broadcast = broadcast;
//# sourceMappingURL=broadcast.js.map

View File

@ -1 +1 @@
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":";;;AAEA,2EAAwD;AACxD,2EAAwD;AACxD,2EAA4D;AAMrD,KAAK,UAAU,SAAS,CAE7B,QAAqB,EACrB,KAAe;IAEf,MAAM,cAAc,GAAG,IAAA,uCAAU,EAAC,IAAA,uCAAU,EAAC,IAAA,2CAAc,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExE,IAAI,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IAED,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAErE,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACjC,OAAO,MAAM,IAAI,CAAC,8BAA8B,CAC9C,SAAS,EACT,KAAK,EACL,cAAc,CACf,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAtBD,8BAsBC"}
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":";;;AAEA,2EAAwD;AACxD,2EAAwD;AACxD,2EAA4D;AAMrD,KAAK,UAAU,SAAS,CAE7B,QAAqB,EACrB,KAAe;IAEf,MAAM,cAAc,GAAG,IAAA,uCAAU,EAAC,IAAA,uCAAU,EAAC,IAAA,2CAAc,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExE,IAAI,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IAED,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACjC,OAAO,MAAM,IAAI,CAAC,8BAA8B,CAC9C,SAAS,EACT,KAAK,EACL,cAAc,CACf,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAxBD,8BAwBC"}

View File

@ -1,3 +1,6 @@
import { DeliveryService } from '.';
import { AP } from 'activitypub-core-types';
export declare function getPrivateKey(this: DeliveryService, actor: AP.Actor): Promise<any>;
export declare function getPrivateKey(
this: DeliveryService,
actor: AP.Actor,
): Promise<any>;

View File

@ -1,4 +1,8 @@
/// <reference types="node" />
import { DeliveryService } from '.';
import { AP } from 'activitypub-core-types';
export declare function getRecipientInboxUrls(this: DeliveryService, activity: AP.Activity, actor: AP.Actor): Promise<URL[]>;
export declare function getRecipientInboxUrls(
this: DeliveryService,
activity: AP.Activity,
actor: AP.Actor,
): Promise<URL[]>;

View File

@ -1,4 +1,7 @@
/// <reference types="node" />
import { AP } from 'activitypub-core-types';
import { DeliveryService } from '.';
export declare function getRecipientsList(this: DeliveryService, to: AP.EntityReference | AP.EntityReference[]): Promise<URL[]>;
export declare function getRecipientsList(
this: DeliveryService,
to: AP.EntityReference | AP.EntityReference[],
): Promise<URL[]>;

View File

@ -1,4 +1,9 @@
/// <reference types="node" />
import { AP } from 'activitypub-core-types';
import { DeliveryService } from '.';
export declare function signAndSendToForeignActorInbox(this: DeliveryService, foreignActorInbox: URL, actor: AP.Actor, activity: AP.Activity): Promise<any>;
export declare function signAndSendToForeignActorInbox(
this: DeliveryService,
foreignActorInbox: URL,
actor: AP.Actor,
activity: AP.Activity,
): Promise<any>;

View File

@ -20,7 +20,8 @@
"scripts": {
"tsc": "tsc --project tsconfig.json",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
"dev": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch"
"dev": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch",
"format": "prettier --config .prettierrc \"**/*.ts\" --write"
},
"bugs": {
"url": "https://github.com/michaelcpuckett/activitypub-core/issues"
@ -35,6 +36,7 @@
"@types/jsonld": "^1.5.6",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}

View File

@ -21,7 +21,7 @@ export async function broadcast(
const recipients = await this.getRecipientInboxUrls(activity, actor);
return await Promise.all(
const results = await Promise.all(
recipients.map(async (recipient) => {
return await this.signAndSendToForeignActorInbox(
recipient,
@ -30,4 +30,6 @@ export async function broadcast(
);
}),
);
return results;
}

View File

@ -3,7 +3,7 @@ import * as crypto from 'crypto';
import {
CONTENT_TYPE_HEADER,
ACTIVITYSTREAMS_CONTENT_TYPE,
ACCEPT_HEADER
ACCEPT_HEADER,
} from 'activitypub-core-utilities';
import { DeliveryService } from '.';

View File

@ -0,0 +1,3 @@
import { ServiceAccount } from 'firebase-admin';
declare const _default: ServiceAccount;
export default _default;

View File

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const serviceAccount = {
type: 'service_account',
project_id: 'socialweb-id',
private_key_id: 'a80ec37ff2f96f01a5aa4177af90e090bb48343f',
private_key: '-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC6dRuTSRujvUiR\npWlwwoqb/2yRpmLcLIg/kBbUBnRCYiwRHPvOtUwKFCgHXOqAuumZIC+yr84Cb0lI\nFCnRYUqqUYPBAi4uoUDNYJX16zGrTtSPLIdJoeuRPQ493RmRpXNK28Yz6VGCmEsl\nB3LdZ9ATMh5mnHx9I13uVStPG5X9YULU/vOpPwJRa7HRnvEixBP4cQMAUk+5nXpi\nQebryZ6/C2wOcD1JB8gFUegklLQ76BPZZK/U7Nh9u9nAzA5c5FMmmklv+nZxSpMR\nB7cBKXzgM/uoT4R8Vgh18vJpTnGktENDLA9US5wZrkQXwkzKEmuib1/Wv3rJEdON\noLuO4MJRAgMBAAECggEAD6G7wxhQ9zmU45OriFGMT1HAUgxR+MV0Ur02EhEhyWLz\nm30DkKvbCR6cJdSLWxQl0LmbEMRJECPbpUL+J9ib6uAp8edzObjjzD65s8PuW79L\nILRfTzQCTMstQ3si0UwT+LBTfeH5/GnfeuY/TK05tjJFzDJ4WVa6tugbA7x7UaJO\nCmpyNy3KTLltxbgou/2vEnx/glwqzeHW6PJYV2eJcVGmfg6xVFDR49YtxgeeZlC+\nD4XMKuEQuGhJ77+zcgIudCie7IOWDq/ejDsjDYNiZBKTiBkYTfnXe1tYM93Qf09p\nDwjZw39ElXfbChDcwZHKESMoUe68U1XKJQmNQLQKNQKBgQDt2vcTiubcXbQK1utw\n4XXe04MACuAnkZyQWlEOnGiqOsXjD5vF94147nPkAHkz8XZjpFMcH5R9d8rJ5DvM\nkN2/vBJwSPzSRBuPlJSNJfWVg+v0aBb8blQpF3a/zZ9Ih8RU8f70MHw6zTKO3wEh\ntFEu5EyMbdE2cgLX0djCMLMoUwKBgQDIrmcFXTrNmjVejPYT0zt1Y4JdhwzO9WN8\nDKKGAbKUFykzFziD6eS/+GBbMu/ap3Qb8zkiPMAbVsfnZrLt1WSQev1+LhiHueoz\nHZG3MMZKEhspZ0yQPIAyd49+DHSDd6yt63OMmCMO4yFm0vfMto30bt6/OxCMNwcm\nGFR0lIYGSwKBgQCQ/7s/np2+GSF4uiwtVESW4jop/HdJp+rZ1TU0wwTLQakBErLT\nrGYCIttjUyaQE9MoSzSfIGFVW4G0Mf6CZo3IJM7YxKXbSMnEbb9hjJJ540IkbJAW\nsut7YWJy6tb/UETPw/a4xhX1gsIfdrMp6NLU0zgXI5s2pao2BycsuqN9IQKBgCt1\nGPogZkt/yW7gN6mzZHzXP7PhOvTWTuTeF5PNak6HdXSK4sIuNEseDj+xmB9Rg+NJ\nmGXBohhJgqCprLW0MELZX2ujr8w0hnLrRFLXTRldMmSU6g+SCnDjUz+IkvKlR8+h\n3TPk/jKLHQCXTvIV1kfIepQOxlaW1AV7304fm6ZhAoGBAKIa5MUGzrK8SYGawwrV\nExDDr4oV/Fq9HZRMY0xWa2PshYEqGFB4FLc+rl6/SLTzxDehwYqXsqkLfqm2xjCf\nP1rFBnJsQhoxNQ1+b51sI+8dftrFJ7zEz7NAZ2YWtXqtu5gGyzf3qIeTkLxTpVTO\naqLRlxdKtEp0TMizftnlVl6R\n-----END PRIVATE KEY-----\n',
client_email: 'firebase-adminsdk-o0j5x@socialweb-id.iam.gserviceaccount.com',
client_id: '110281511136422720421',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url: 'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o0j5x%40socialweb-id.iam.gserviceaccount.com',
};
exports.default = serviceAccount;
//# sourceMappingURL=credentials.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":";;AAEA,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,iBAAiB;IACvB,UAAU,EAAE,cAAc;IAC1B,cAAc,EAAE,0CAA0C;IAC1D,WAAW,EACT,ssDAAssD;IACxsD,YAAY,EAAE,8DAA8D;IAC5E,SAAS,EAAE,uBAAuB;IAClC,QAAQ,EAAE,2CAA2C;IACrD,SAAS,EAAE,qCAAqC;IAChD,2BAA2B,EAAE,4CAA4C;IACzE,oBAAoB,EAClB,kHAAkH;CACrH,CAAC;AAEF,kBAAe,cAAgC,CAAC"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,46 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const express_1 = __importDefault(require("express"));
const activitypub_core_express_middleware_1 = require("activitypub-core-express-middleware");
const activitypub_core_jsx_components_1 = require("activitypub-core-jsx-components");
const server_1 = require("react-dom/server");
const credentials_1 = __importDefault(require("./credentials"));
const activitypub_core_mongodb_1 = require("activitypub-core-mongodb");
const activitypub_core_delivery_1 = require("activitypub-core-delivery");
(async () => {
const app = (0, express_1.default)();
const databaseService = await new activitypub_core_mongodb_1.MongoDatabaseService().connect();
const deliveryService = new activitypub_core_delivery_1.DeliveryService(databaseService);
app.use(express_1.default.static('node_modules/activitypub-core-jsx-components/static'));
app.use((0, activitypub_core_express_middleware_1.activityPub)({
renderIndex: async () => {
return `
<!doctype html>
${(0, server_1.renderToString)(react_1.default.createElement(activitypub_core_jsx_components_1.IndexPage, null))}`;
},
renderEntity: async ({ entity, actor }) => {
return `
<!doctype html>
${(0, server_1.renderToString)(react_1.default.createElement(activitypub_core_jsx_components_1.EntityPage, { entity: entity, actor: actor }))}
`;
},
renderHome: async ({ actor }) => {
return `
<!doctype html>
${(0, server_1.renderToString)(react_1.default.createElement(activitypub_core_jsx_components_1.HomePage, { actor: actor }))}
`;
},
}, {
databaseService,
deliveryService,
serviceAccount: credentials_1.default
}));
app.listen(process.env.PORT ?? 3001, () => {
console.log('Running...');
});
})();
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,sDAA8B;AAC9B,6FAAkE;AAClE,qFAAkF;AAClF,6CAAkD;AAClD,gEAA2C;AAC3C,uEAAgE;AAChE,yEAA4D;AAE5D,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IACtB,MAAM,eAAe,GAAG,MAAM,IAAI,+CAAoB,EAAE,CAAC,OAAO,EAAE,CAAC;IACnE,MAAM,eAAe,GAAG,IAAI,2CAAe,CAAC,eAAe,CAAC,CAAC;IAE7D,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,MAAM,CAAC,qDAAqD,CAAC,CAAC,CAAC;IAC/E,GAAG,CAAC,GAAG,CAAC,IAAA,iDAAW,EAAC;QAClB,WAAW,EAAE,KAAK,IAAI,EAAE;YACtB,OAAO;;UAEH,IAAA,uBAAc,EAAC,8BAAC,2CAAS,OAAG,CAAC,EAAE,CAAC;QACtC,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;YACxC,OAAO;;UAEH,IAAA,uBAAc,EAAC,8BAAC,4CAAU,IAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;OAC/D,CAAC;QACJ,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAC9B,OAAO;;UAEH,IAAA,uBAAc,EAAC,8BAAC,0CAAQ,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;OAC7C,CAAC;QACJ,CAAC;KACF,EAAE;QACD,eAAe;QACf,eAAe;QACf,cAAc,EAAd,qBAAc;KACf,CAAC,CAAC,CAAC;IAEJ,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC"}

View File

@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@ -4,17 +4,33 @@ import { AP } from 'activitypub-core-types';
import type { ServiceAccount } from 'firebase-admin';
import { DeliveryService } from 'activitypub-core-delivery';
import type { Database } from 'activitypub-core-types/index';
export declare const activityPub: ({ renderIndex, renderHome, renderEntity, }: {
export declare const activityPub: (
{
renderIndex,
renderHome,
renderEntity,
}: {
renderIndex: () => Promise<string>;
renderHome: ({ actor }: {
actor: AP.Actor;
}) => Promise<string>;
renderEntity: ({ entity, actor }: {
renderHome: ({ actor }: { actor: AP.Actor }) => Promise<string>;
renderEntity: ({
entity,
actor,
}: {
entity: AP.Entity;
actor?: AP.Actor;
}) => Promise<string>;
}, { serviceAccount, databaseService, deliveryService, }: {
},
{
serviceAccount,
databaseService,
deliveryService,
}: {
serviceAccount: ServiceAccount;
databaseService: Database;
deliveryService: DeliveryService;
}) => (req: IncomingMessage, res: ServerResponse, next: NextFunction) => Promise<void>;
},
) => (
req: IncomingMessage,
res: ServerResponse,
next: NextFunction,
) => Promise<void>;

View File

@ -9,6 +9,11 @@ const activityPub = ({ renderIndex, renderHome, renderEntity, }, { serviceAccoun
next();
return;
}
if (req.url === '/sharedInbox' && req.method === 'POST') {
await (0, activitypub_core_1.sharedInboxHandler)(req, res, databaseService, deliveryService);
next();
return;
}
if (req.url.startsWith('/actor/') && req.url.endsWith('/inbox')) {
const result = await (0, activitypub_core_1.inboxHandler)(req, res, serviceAccount, databaseService, deliveryService);
if (result.props && Object.keys(result.props).length) {

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}

View File

@ -13,11 +13,13 @@
"lib"
],
"devDependencies": {
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
},
"scripts": {
"tsc": "tsc --project tsconfig.json",
"dev": "ts-node ./src/index.ts"
"dev": "ts-node ./src/index.ts",
"format": "prettier --config .prettierrc \"**/*.ts\" --write"
},
"dependencies": {
"activitypub-core": "^0.0.54",

View File

@ -1,56 +1,113 @@
import type { NextFunction } from 'express';
import type { IncomingMessage, ServerResponse } from 'http';
import { userPostHandler, homeGetHandler, entityGetHandler, outboxHandler, inboxHandler } from 'activitypub-core';
import {
userPostHandler,
homeGetHandler,
entityGetHandler,
outboxHandler,
inboxHandler,
sharedInboxHandler,
} from 'activitypub-core';
import { AP } from 'activitypub-core-types';
import type { ServiceAccount } from 'firebase-admin';
import { DeliveryService } from 'activitypub-core-delivery';
import type { Database } from 'activitypub-core-types/index';
import { CONTENT_TYPE_HEADER, HTML_CONTENT_TYPE, convertStringsToUrls } from 'activitypub-core-utilities';
import {
CONTENT_TYPE_HEADER,
HTML_CONTENT_TYPE,
convertStringsToUrls,
} from 'activitypub-core-utilities';
export const activityPub = ({
export const activityPub =
(
{
renderIndex,
renderHome,
renderEntity,
}: {
renderIndex: () => Promise<string>,
renderHome: ({ actor }: { actor: AP.Actor }) => Promise<string>,
renderEntity: ({ entity, actor }: { entity: AP.Entity; actor?: AP.Actor; }) => Promise<string>,
}, {
renderIndex: () => Promise<string>;
renderHome: ({ actor }: { actor: AP.Actor }) => Promise<string>;
renderEntity: ({
entity,
actor,
}: {
entity: AP.Entity;
actor?: AP.Actor;
}) => Promise<string>;
},
{
serviceAccount,
databaseService,
deliveryService,
}: {
serviceAccount: ServiceAccount,
databaseService: Database,
deliveryService: DeliveryService,
}) => async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => {
serviceAccount: ServiceAccount;
databaseService: Database;
deliveryService: DeliveryService;
},
) =>
async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => {
if (req.url === '/user' && req.method === 'POST') {
await userPostHandler(req, res, serviceAccount, databaseService);
next();
return;
}
if (req.url === '/sharedInbox' && req.method === 'POST') {
await sharedInboxHandler(req, res, databaseService, deliveryService);
next();
return;
}
if (req.url.startsWith('/actor/') && req.url.endsWith('/inbox')) {
const result = await inboxHandler(req, res, serviceAccount, databaseService, deliveryService);
const result = await inboxHandler(
req,
res,
serviceAccount,
databaseService,
deliveryService,
);
if (result.props && Object.keys(result.props).length) {
res.statusCode = 200;
res.setHeader(CONTENT_TYPE_HEADER, HTML_CONTENT_TYPE);
res.write(await renderEntity(convertStringsToUrls(result.props) as unknown as { entity: AP.Entity; actor?: AP.Actor; }));
res.write(
await renderEntity(
convertStringsToUrls(result.props) as unknown as {
entity: AP.Entity;
actor?: AP.Actor;
},
),
);
res.end();
}
return;
}
if (req.url.startsWith('/actor/') && req.url.endsWith('/outbox')) {
const result = await outboxHandler(req, res, serviceAccount, databaseService, deliveryService);
if (result.props && Object.keys(result.props).length && 'entity' in result.props) {
const result = await outboxHandler(
req,
res,
serviceAccount,
databaseService,
deliveryService,
);
if (
result.props &&
Object.keys(result.props).length &&
'entity' in result.props
) {
res.statusCode = 200;
res.setHeader(CONTENT_TYPE_HEADER, HTML_CONTENT_TYPE);
res.write(await renderEntity({
entity: convertStringsToUrls(result.props.entity as unknown as { [key: string]: unknown }) as AP.Entity,
actor: convertStringsToUrls(result.props.actor as unknown as { [key: string]: unknown }) as AP.Actor,
}));
res.write(
await renderEntity({
entity: convertStringsToUrls(
result.props.entity as unknown as { [key: string]: unknown },
) as AP.Entity,
actor: convertStringsToUrls(
result.props.actor as unknown as { [key: string]: unknown },
) as AP.Actor,
}),
);
res.end();
}
return;
@ -65,7 +122,12 @@ export const activityPub = ({
}
if (req.url === '/home' && req.method === 'GET') {
const result = await homeGetHandler(req, res, serviceAccount, databaseService);
const result = await homeGetHandler(
req,
res,
serviceAccount,
databaseService,
);
if (result.redirect) {
res.statusCode = 200;
@ -78,7 +140,11 @@ export const activityPub = ({
if (result.props && Object.keys(result.props).length) {
res.statusCode = 200;
res.setHeader(CONTENT_TYPE_HEADER, HTML_CONTENT_TYPE);
res.write(await renderHome(convertStringsToUrls(result.props) as { actor: AP.Actor }));
res.write(
await renderHome(
convertStringsToUrls(result.props) as { actor: AP.Actor },
),
);
res.end();
return;
}
@ -88,13 +154,29 @@ export const activityPub = ({
return;
}
if (req.url.startsWith('/object/') || req.url.startsWith('/actor/') || req.url.startsWith('/activity/')) {
const result = await entityGetHandler(req, res, serviceAccount, databaseService);
if (
req.url.startsWith('/object/') ||
req.url.startsWith('/actor/') ||
req.url.startsWith('/activity/')
) {
const result = await entityGetHandler(
req,
res,
serviceAccount,
databaseService,
);
if (result.props && Object.keys(result.props).length) {
res.statusCode = 200;
res.setHeader(CONTENT_TYPE_HEADER, HTML_CONTENT_TYPE);
res.write(await renderEntity(convertStringsToUrls(result.props) as unknown as { entity: AP.Entity; actor?: AP.Actor; }));
res.write(
await renderEntity(
convertStringsToUrls(result.props) as unknown as {
entity: AP.Entity;
actor?: AP.Actor;
},
),
);
res.end();
return;
}

View File

@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function ActivityEntity({ activity, headingLevel }: {
export declare function ActivityEntity({
activity,
headingLevel,
}: {
activity: AP.Activity;
headingLevel: number;
}): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function ActorEntity({ actor, headingLevel }: {
export declare function ActorEntity({
actor,
headingLevel,
}: {
actor: AP.Actor;
headingLevel: number;
}): JSX.Element;

View File

@ -1,6 +1,10 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function CollectionEntity({ collection, actor, headingLevel }: {
export declare function CollectionEntity({
collection,
actor,
headingLevel,
}: {
collection: AP.Collection;
actor: AP.Actor;
headingLevel: number;

View File

@ -1,5 +1,7 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function CollectionPageEntity({ collectionPage }: {
export declare function CollectionPageEntity({
collectionPage,
}: {
collectionPage: AP.CollectionPage;
}): JSX.Element;

View File

@ -1,5 +1,3 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function LinkEntity({ link }: {
link: AP.Link;
}): JSX.Element;
export declare function LinkEntity({ link }: { link: AP.Link }): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function NoteEntity({ note, headingLevel }: {
export declare function NoteEntity({
note,
headingLevel,
}: {
note: AP.Note;
headingLevel: number;
}): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function ObjectEntity({ object, headingLevel }: {
export declare function ObjectEntity({
object,
headingLevel,
}: {
object: AP.ExtendedObject;
headingLevel: number;
}): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function OrderedCollectionEntity({ collection, headingLevel }: {
export declare function OrderedCollectionEntity({
collection,
headingLevel,
}: {
collection: AP.OrderedCollection;
headingLevel: number;
}): JSX.Element;

View File

@ -1,5 +1,7 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function OrderedCollectionPageEntity({ orderedCollectionPage }: {
export declare function OrderedCollectionPageEntity({
orderedCollectionPage,
}: {
orderedCollectionPage: AP.OrderedCollectionPage;
}): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function EntityPage({ entity, actor, }: {
export declare function EntityPage({
entity,
actor,
}: {
entity: AP.Entity;
actor?: AP.Actor;
}): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function CreateForm({ actor, headingLevel }: {
export declare function CreateForm({
actor,
headingLevel,
}: {
actor: AP.Actor;
headingLevel: number;
}): JSX.Element;

View File

@ -1,5 +1,3 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function Sidebar({ actor }: {
actor?: AP.Actor;
}): JSX.Element;
export declare function Sidebar({ actor }: { actor?: AP.Actor }): JSX.Element;

View File

@ -1,6 +1,9 @@
/// <reference types="react" />
import { AP } from 'activitypub-core-types';
export declare function Welcome({ actor, headingLevel }: {
export declare function Welcome({
actor,
headingLevel,
}: {
actor: AP.Actor;
headingLevel: number;
}): JSX.Element;

View File

@ -16,10 +16,12 @@
],
"scripts": {
"tsc": "tsc --project tsconfig.json",
"dev": "ts-node ./src/index.ts"
"dev": "ts-node ./src/index.ts",
"format": "prettier --config .prettierrc \"**/*.ts\" --write"
},
"devDependencies": {
"@types/react": "^18.0.21",
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
},
"dependencies": {

View File

@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@ -36,7 +36,7 @@ describe('DatabaseService', () => {
if (matchingObject._id === collection1Url) {
return {
_id: collection1Url,
...JSON.parse(JSON.stringify(collection1Result))
...JSON.parse(JSON.stringify(collection1Result)),
};
}
@ -50,8 +50,8 @@ describe('DatabaseService', () => {
if (matchingObject._id === item2Url) {
return {
_id: item2Url,
...JSON.parse(JSON.stringify(item2Result))
}
...JSON.parse(JSON.stringify(item2Result)),
};
}
return null;

View File

@ -9,7 +9,7 @@ describe('DatabaseService', () => {
const actor1Url = 'https://test.com/actor/123';
const object1Url = 'https://test.com/object/123';
const activity1: AP.Create = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(activity1Url),
url: new URL(activity1Url),
type: 'Create',
@ -17,7 +17,7 @@ describe('DatabaseService', () => {
object: new URL(object1Url),
};
const actor1: AP.Person = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(actor1Url),
url: new URL(actor1Url),
type: 'Person',
@ -25,14 +25,14 @@ describe('DatabaseService', () => {
outbox: new URL(`${actor1Url}/outbox`),
};
const object1: AP.Note = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(object1Url),
url: new URL(object1Url),
type: 'Note',
content: 'Test',
};
const activity1Result: AP.Create = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(activity1Url),
url: new URL(activity1Url),
type: 'Create',

View File

@ -6,7 +6,7 @@ describe('DatabaseService', () => {
describe('fetchEntityById', () => {
const actor1Url = 'https://foreign.test.com/456';
const actor1Result: AP.Person = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL('https://foreign.test.com/456'),
url: new URL('https://foreign.test.com/456'),
type: 'Person',
@ -24,8 +24,8 @@ describe('DatabaseService', () => {
}
return null;
}
}
},
};
},
});

View File

@ -7,7 +7,7 @@ describe('DatabaseService', () => {
describe('getCollectionItems', () => {
const item1Url = 'https://test.com/activity/456';
const item1Result: AP.Note = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(item1Url),
url: new URL(item1Url),
type: 'Note',
@ -15,7 +15,7 @@ describe('DatabaseService', () => {
};
const item2Url = 'https://test.com/activity/789';
const item2Result: AP.Document = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(item2Url),
url: new URL(item2Url),
type: 'Document',
@ -24,7 +24,7 @@ describe('DatabaseService', () => {
const collection1Url = 'https://test.com/activity/123';
const collection1Result: AP.Collection = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(collection1Url),
url: new URL(collection1Url),
type: 'Collection',

View File

@ -19,11 +19,7 @@ export function mockDatabaseService({
fetchResponder?: (request: Request) => unknown;
}) {
const mockDbInstance = {
collection: jest.fn(
() =>
db ?? {
},
),
collection: jest.fn(() => db ?? {}),
} as unknown as Db;
const fetchMock =

View File

@ -7,7 +7,7 @@ describe('DatabaseService', () => {
describe('queryById', () => {
const object1Url = 'https://test.com/object/123';
const object1Result: AP.Note = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(object1Url),
url: new URL(object1Url),
type: 'Note',
@ -26,8 +26,8 @@ describe('DatabaseService', () => {
}
return null;
}
}
},
};
},
});

View File

@ -8,7 +8,7 @@ describe('DatabaseService', () => {
const date = new Date('2022-01-01');
const object1Url = 'https://test.com/object/123';
const object1: AP.Note = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(object1Url),
url: new URL(object1Url),
type: 'Note',
@ -17,7 +17,7 @@ describe('DatabaseService', () => {
};
const object1Result = {
"@context": ACTIVITYSTREAMS_CONTEXT,
'@context': ACTIVITYSTREAMS_CONTEXT,
id: object1Url,
url: object1Url,
type: 'Note',

View File

@ -1,3 +1,6 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function expandCollection(this: MongoDatabase, collection: AP.EitherCollectionReference): Promise<null | AP.EitherCollection>;
export declare function expandCollection(
this: MongoDatabase,
collection: AP.EitherCollectionReference,
): Promise<null | AP.EitherCollection>;

View File

@ -1,3 +1,6 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function expandEntity(this: MongoDatabase, originalEntity: AP.Entity): Promise<AP.Entity>;
export declare function expandEntity(
this: MongoDatabase,
originalEntity: AP.Entity,
): Promise<AP.Entity>;

View File

@ -1,4 +1,7 @@
/// <reference types="node" />
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function fetchEntityById(this: MongoDatabase, id: URL): Promise<AP.Entity | null>;
export declare function fetchEntityById(
this: MongoDatabase,
id: URL,
): Promise<AP.Entity | null>;

View File

@ -1,5 +1,9 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function findAll(this: MongoDatabase, collection: string, matchingObject: {
export declare function findAll(
this: MongoDatabase,
collection: string,
matchingObject: {
[key: string]: unknown;
}): Promise<AP.Entity[] | null>;
},
): Promise<AP.Entity[] | null>;

View File

@ -1,4 +1,7 @@
/// <reference types="node" />
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function findEntityById(this: MongoDatabase, id: URL): Promise<AP.Entity | null>;
export declare function findEntityById(
this: MongoDatabase,
id: URL,
): Promise<AP.Entity | null>;

View File

@ -1,5 +1,9 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function findOne(this: MongoDatabase, collection: string, matchingObject: {
export declare function findOne(
this: MongoDatabase,
collection: string,
matchingObject: {
[key: string]: unknown;
}): Promise<AP.Entity | null>;
},
): Promise<AP.Entity | null>;

View File

@ -1,2 +1,6 @@
import { MongoDatabase } from '.';
export declare function findStringIdByValue(this: MongoDatabase, dbCollection: string, value: string): Promise<string>;
export declare function findStringIdByValue(
this: MongoDatabase,
dbCollection: string,
value: string,
): Promise<string>;

View File

@ -1,2 +1,6 @@
import { MongoDatabase } from '.';
export declare function findStringValueById(this: MongoDatabase, dbCollection: string, _id: string): Promise<string>;
export declare function findStringValueById(
this: MongoDatabase,
dbCollection: string,
_id: string,
): Promise<string>;

View File

@ -1,4 +1,8 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
import { ServiceAccount } from 'firebase-admin';
export declare function getActorByToken(this: MongoDatabase, token: string, credentials: ServiceAccount): Promise<AP.Actor | null>;
export declare function getActorByToken(
this: MongoDatabase,
token: string,
credentials: ServiceAccount,
): Promise<AP.Actor | null>;

View File

@ -1,3 +1,7 @@
import { MongoDatabase } from '.';
import { ServiceAccount } from 'firebase-admin';
export declare function getAuthenticatedUserIdByToken(this: MongoDatabase, token: string, serviceAccount: ServiceAccount): Promise<string | null>;
export declare function getAuthenticatedUserIdByToken(
this: MongoDatabase,
token: string,
serviceAccount: ServiceAccount,
): Promise<string | null>;

View File

@ -1,4 +1,7 @@
/// <reference types="node" />
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function getCollectionItems(this: MongoDatabase, entity: URL | AP.Collection | AP.OrderedCollection): Promise<AP.EntityReference[]>;
export declare function getCollectionItems(
this: MongoDatabase,
entity: URL | AP.Collection | AP.OrderedCollection,
): Promise<AP.EntityReference[]>;

View File

@ -5,7 +5,12 @@ import { findStringValueById } from './findStringValueById';
import { findStringIdByValue } from './findStringIdByValue';
import { saveEntity } from './saveEntity';
import { saveString } from './saveString';
import { insertItem, removeOrderedItem, insertOrderedItem, removeItem } from './insert';
import {
insertItem,
removeOrderedItem,
insertOrderedItem,
removeItem,
} from './insert';
import { fetchEntityById } from './fetchEntityById';
import { queryById } from './queryById';
import { expandEntity } from './expandEntity';

View File

@ -1,6 +1,22 @@
/// <reference types="node" />
import { MongoDatabase } from '.';
export declare function insertOrderedItem(this: MongoDatabase, path: URL, url: URL): Promise<void>;
export declare function removeOrderedItem(this: MongoDatabase, path: URL, url: URL): Promise<void>;
export declare function insertItem(this: MongoDatabase, path: URL, url: URL): Promise<void>;
export declare function removeItem(this: MongoDatabase, path: URL, url: URL): Promise<void>;
export declare function insertOrderedItem(
this: MongoDatabase,
path: URL,
url: URL,
): Promise<void>;
export declare function removeOrderedItem(
this: MongoDatabase,
path: URL,
url: URL,
): Promise<void>;
export declare function insertItem(
this: MongoDatabase,
path: URL,
url: URL,
): Promise<void>;
export declare function removeItem(
this: MongoDatabase,
path: URL,
url: URL,
): Promise<void>;

View File

@ -1,4 +1,7 @@
/// <reference types="node" />
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function queryById(this: MongoDatabase, id: URL): Promise<AP.Entity | null>;
export declare function queryById(
this: MongoDatabase,
id: URL,
): Promise<AP.Entity | null>;

View File

@ -1,3 +1,6 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
export declare function saveEntity(this: MongoDatabase, entity: AP.Entity): Promise<import("bson").Document | import("mongodb").UpdateResult>;
export declare function saveEntity(
this: MongoDatabase,
entity: AP.Entity,
): Promise<import('bson').Document | import('mongodb').UpdateResult>;

View File

@ -1,2 +1,7 @@
import { MongoDatabase } from '.';
export declare function saveString(this: MongoDatabase, dbCollection: string, _id: string, value: string): Promise<import("bson").Document | import("mongodb").UpdateResult>;
export declare function saveString(
this: MongoDatabase,
dbCollection: string,
_id: string,
value: string,
): Promise<import('bson').Document | import('mongodb').UpdateResult>;

View File

@ -20,7 +20,8 @@
"scripts": {
"tsc": "tsc --project tsconfig.json",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
"dev": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch"
"dev": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch",
"format": "prettier --config .prettierrc \"**/*.ts\" --write"
},
"bugs": {
"url": "https://github.com/michaelcpuckett/activitypub-core/issues"
@ -36,6 +37,7 @@
"@types/jest": "^29.1.2",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}

View File

@ -24,13 +24,12 @@ export async function fetchEntityById(
[CONTENT_TYPE_HEADER]: ACTIVITYSTREAMS_CONTENT_TYPE,
[ACCEPT_HEADER]: ACTIVITYSTREAMS_CONTENT_TYPE,
},
})
.then(
async (response: { json: () => Promise<{ [key: string]: unknown }> }) => {
return await response.json();
},
)
.then(async (response: {
json: () => Promise<{ [key: string]: unknown }>
}) => {
return await response.json();
})
.catch((error: unknown) => {
console.log(String(error));
return null;

View File

@ -50,18 +50,17 @@ export async function getCollectionItems(
const foundEntity = await this.queryById(item);
result.push(
foundEntity ? await this.expandEntity(foundEntity) : {
foundEntity
? await this.expandEntity(foundEntity)
: {
type: AP.CoreObjectTypes.TOMBSTONE,
content: 'Not found',
},
);
} else if (!Array.isArray(item) && item.id instanceof URL) {
const foundEntity = await this.queryById(item.id);
result.push(
foundEntity ?? item
);
result.push(foundEntity ?? item);
}
}

View File

@ -68,7 +68,7 @@ export class MongoDatabase implements Database {
public expandEntity = expandEntity;
public getCollectionItems = getCollectionItems;
public expandCollection = expandCollection;
};
}
export class MongoDatabaseService implements DatabaseService {
async connect() {

View File

@ -1,6 +1,11 @@
import { MongoDatabase } from '.';
import { AP } from 'activitypub-core-types';
import { addContext, cleanProps, convertUrlsToStrings, getCollectionNameByUrl } from 'activitypub-core-utilities';
import {
addContext,
cleanProps,
convertUrlsToStrings,
getCollectionNameByUrl,
} from 'activitypub-core-utilities';
export async function saveEntity(this: MongoDatabase, entity: AP.Entity) {
if (!entity.id) {

View File

@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@ -23,4 +23,4 @@ export type Database = {
export interface DatabaseService {
connect(): Promise<Database>;
};
}

View File

@ -4,7 +4,10 @@ import type { EntityReference } from '.';
import type { StringReferenceMap } from '../util/values';
import type { ImageReference } from '../Extended/ExtendedObject';
import type { LinkReference } from './Link';
import type { CollectionReference, OrderedCollectionReference } from '../Extended/Collection';
import type {
CollectionReference,
OrderedCollectionReference,
} from '../Extended/Collection';
export interface BaseCoreObject extends BaseEntity {
type: typeof CoreObjectTypes[keyof typeof CoreObjectTypes];
attachment?: EntityReference | EntityReference[];

View File

@ -6,7 +6,14 @@ import { Activity } from '../Extended/Activity';
import { Collection, OrderedCollection } from '../Extended/Collection';
import { CollectionPage, OrderedCollectionPage } from '../Extended/Collection';
export type { Link, LinkReference, Mention } from './Link';
export declare type CoreObject = ExtendedObject | Actor | Activity | Collection | OrderedCollection | CollectionPage | OrderedCollectionPage;
export declare type CoreObject =
| ExtendedObject
| Actor
| Activity
| Collection
| OrderedCollection
| CollectionPage
| OrderedCollectionPage;
export declare type CoreObjectReference = URL | CoreObject;
export declare type Entity = CoreObject | Link;
export declare type EntityReference = URL | CoreObject | Link;

View File

@ -102,6 +102,34 @@ export declare type Question = IntransitiveActivity & {
anyOf: EntityReference | EntityReference[];
closed: EntityReference | Date | boolean;
};
export declare type Activity = Accept | Follow | Delete | Create | Arrive | Add | Offer | Like | Leave | Ignore | Join | Reject | Invite | TentativeReject | TentativeAccept | View | Update | Undo | Remove | Read | Listen | Move | Travel | Announce | Block | Flag | Dislike | Question;
export declare type Activity =
| Accept
| Follow
| Delete
| Create
| Arrive
| Add
| Offer
| Like
| Leave
| Ignore
| Join
| Reject
| Invite
| TentativeReject
| TentativeAccept
| View
| Update
| Undo
| Remove
| Read
| Listen
| Move
| Travel
| Announce
| Block
| Flag
| Dislike
| Question;
export declare type ActivityReference = URL | Activity;
export {};

View File

@ -1,7 +1,11 @@
/// <reference types="node" />
import { BaseCoreObject } from '../Core/CoreObject';
import { ActorTypes } from '../util/const';
import { CollectionReference, EitherCollectionReference, OrderedCollectionReference } from './Collection';
import {
CollectionReference,
EitherCollectionReference,
OrderedCollectionReference,
} from './Collection';
import { StringReferenceMap } from '../util/values';
declare type BaseActor = BaseCoreObject & {
type: typeof ActorTypes[keyof typeof ActorTypes];
@ -43,6 +47,11 @@ export declare type Service = BaseActor & {
export declare type Organization = BaseActor & {
type: typeof ActorTypes.ORGANIZATION;
};
export declare type Actor = Application | Service | Group | Organization | Person;
export declare type Actor =
| Application
| Service
| Group
| Organization
| Person;
export declare type ActorReference = URL | Actor;
export {};

View File

@ -4,7 +4,9 @@ import { BaseCoreObject } from '../Core/CoreObject';
import { EntityReference } from '../Core';
import { Link } from '../Core/Link';
declare type BaseCollection = BaseCoreObject & {
type: typeof CollectionTypes[keyof typeof CollectionTypes] | typeof CollectionPageTypes[keyof typeof CollectionPageTypes];
type:
| typeof CollectionTypes[keyof typeof CollectionTypes]
| typeof CollectionPageTypes[keyof typeof CollectionPageTypes];
totalItems?: number;
items?: EntityReference | EntityReference[];
current?: URL | CollectionPage | Link;
@ -35,9 +37,13 @@ export declare type OrderedCollectionPage = BaseCollectionPage & {
export declare type CollectionReference = URL | Collection;
export declare type OrderedCollectionReference = URL | OrderedCollection;
export declare type CollectionPageReference = URL | CollectionPage;
export declare type OrderedCollectionPageReference = URL | OrderedCollectionPage;
export declare type OrderedCollectionPageReference =
| URL
| OrderedCollectionPage;
export declare type EitherCollection = Collection | OrderedCollection;
export declare type EitherCollectionPage = CollectionPage | OrderedCollectionPage;
export declare type EitherCollectionPage =
| CollectionPage
| OrderedCollectionPage;
export declare type EitherCollectionReference = URL | EitherCollection;
export declare type EitherCollectionPageReference = URL | EitherCollectionPage;
export {};

View File

@ -7,7 +7,9 @@ declare type BaseExtendedObject = BaseCoreObject & {
};
export declare type Tombstone = BaseExtendedObject & {
type: typeof ExtendedObjectTypes.TOMBSTONE;
formerType?: typeof AllTypes[keyof typeof AllTypes] | Array<typeof AllTypes[keyof typeof AllTypes]>;
formerType?:
| typeof AllTypes[keyof typeof AllTypes]
| Array<typeof AllTypes[keyof typeof AllTypes]>;
deleted?: Date;
};
export declare type Relationship = BaseExtendedObject & {
@ -53,7 +55,19 @@ export declare type Profile = BaseExtendedObject & {
type: typeof ExtendedObjectTypes.PROFILE;
describes?: CoreObjectReference;
};
export declare type ExtendedObject = Article | Event | Note | Page | Place | Relationship | Tombstone | Profile | Video | Document | Audio | Image;
export declare type ExtendedObject =
| Article
| Event
| Note
| Page
| Place
| Relationship
| Tombstone
| Profile
| Video
| Document
| Audio
| Image;
export declare type ExtendedObjectReference = URL | ExtendedObject;
export declare type ImageReference = URL | Image;
export {};

View File

@ -1,10 +1,72 @@
export type { Activity, ActivityReference, IntransitiveActivity, TransitiveActivity, Accept, Follow, Delete, Create, Arrive, Add, Offer, Like, Leave, Ignore, Join, Reject, Invite, TentativeReject, TentativeAccept, View, Update, Undo, Remove, Read, Listen, Move, Travel, Announce, Block, Flag, Dislike, Question, } from './Activity';
export type { Actor, ActorReference, Person, Service, Group, Organization, Application, } from './Actor';
export type { ExtendedObject, ExtendedObjectReference, Article, Event, Note, Page, Place, Relationship, Tombstone, Profile, Video, Document, Audio, Image, } from './ExtendedObject';
export type {
Activity,
ActivityReference,
IntransitiveActivity,
TransitiveActivity,
Accept,
Follow,
Delete,
Create,
Arrive,
Add,
Offer,
Like,
Leave,
Ignore,
Join,
Reject,
Invite,
TentativeReject,
TentativeAccept,
View,
Update,
Undo,
Remove,
Read,
Listen,
Move,
Travel,
Announce,
Block,
Flag,
Dislike,
Question,
} from './Activity';
export type {
Actor,
ActorReference,
Person,
Service,
Group,
Organization,
Application,
} from './Actor';
export type {
ExtendedObject,
ExtendedObjectReference,
Article,
Event,
Note,
Page,
Place,
Relationship,
Tombstone,
Profile,
Video,
Document,
Audio,
Image,
} from './ExtendedObject';
export type { Collection, CollectionReference } from './Collection';
export type { OrderedCollection, OrderedCollectionReference, } from './Collection';
export type {
OrderedCollection,
OrderedCollectionReference,
} from './Collection';
export type { CollectionPage, CollectionPageReference } from './Collection';
export type { OrderedCollectionPage, OrderedCollectionPageReference, } from './Collection';
export type {
OrderedCollectionPage,
OrderedCollectionPageReference,
} from './Collection';
export type { EitherCollection } from './Collection';
export type { EitherCollectionReference } from './Collection';
export type { EitherCollectionPage } from './Collection';

View File

@ -1,12 +1,89 @@
export { CoreObjectTypes, LinkTypes, TransitiveActivityTypes, IntransitiveActivityTypes, ActivityTypes, ActorTypes, ExtendedObjectTypes, CollectionTypes, CollectionPageTypes, AllTypes, } from './util/const';
export type { Entity, EntityReference, CoreObject, CoreObjectReference, Link, LinkReference, } from './Core';
export type { Activity, ActivityReference, IntransitiveActivity, TransitiveActivity, Accept, Follow, Delete, Create, Arrive, Add, Offer, Like, Leave, Ignore, Join, Reject, Invite, TentativeReject, TentativeAccept, View, Update, Undo, Remove, Read, Listen, Move, Travel, Announce, Block, Flag, Dislike, Question, } from './Extended';
export type { Actor, ActorReference, Person, Service, Group, Organization, Application, } from './Extended';
export type { ExtendedObject, ExtendedObjectReference, Article, Event, Note, Page, Place, Relationship, Tombstone, Profile, Video, Document, Audio, Image, } from './Extended';
export {
CoreObjectTypes,
LinkTypes,
TransitiveActivityTypes,
IntransitiveActivityTypes,
ActivityTypes,
ActorTypes,
ExtendedObjectTypes,
CollectionTypes,
CollectionPageTypes,
AllTypes,
} from './util/const';
export type {
Entity,
EntityReference,
CoreObject,
CoreObjectReference,
Link,
LinkReference,
} from './Core';
export type {
Activity,
ActivityReference,
IntransitiveActivity,
TransitiveActivity,
Accept,
Follow,
Delete,
Create,
Arrive,
Add,
Offer,
Like,
Leave,
Ignore,
Join,
Reject,
Invite,
TentativeReject,
TentativeAccept,
View,
Update,
Undo,
Remove,
Read,
Listen,
Move,
Travel,
Announce,
Block,
Flag,
Dislike,
Question,
} from './Extended';
export type {
Actor,
ActorReference,
Person,
Service,
Group,
Organization,
Application,
} from './Extended';
export type {
ExtendedObject,
ExtendedObjectReference,
Article,
Event,
Note,
Page,
Place,
Relationship,
Tombstone,
Profile,
Video,
Document,
Audio,
Image,
} from './Extended';
export type { Collection, CollectionReference } from './Extended';
export type { OrderedCollection, OrderedCollectionReference } from './Extended';
export type { CollectionPage, CollectionPageReference } from './Extended';
export type { OrderedCollectionPage, OrderedCollectionPageReference, } from './Extended';
export type {
OrderedCollectionPage,
OrderedCollectionPageReference,
} from './Extended';
export type { EitherCollection } from './Extended';
export type { EitherCollectionReference } from './Extended';
export type { EitherCollectionPage } from './Extended';

View File

@ -1,199 +1,199 @@
export declare const ExtendedObjectTypes: {
readonly ARTICLE: "Article";
readonly AUDIO: "Audio";
readonly DOCUMENT: "Document";
readonly EVENT: "Event";
readonly IMAGE: "Image";
readonly NOTE: "Note";
readonly PAGE: "Page";
readonly PLACE: "Place";
readonly PROFILE: "Profile";
readonly RELATIONSHIP: "Relationship";
readonly TOMBSTONE: "Tombstone";
readonly VIDEO: "Video";
readonly ARTICLE: 'Article';
readonly AUDIO: 'Audio';
readonly DOCUMENT: 'Document';
readonly EVENT: 'Event';
readonly IMAGE: 'Image';
readonly NOTE: 'Note';
readonly PAGE: 'Page';
readonly PLACE: 'Place';
readonly PROFILE: 'Profile';
readonly RELATIONSHIP: 'Relationship';
readonly TOMBSTONE: 'Tombstone';
readonly VIDEO: 'Video';
};
export declare const LinkTypes: {
readonly LINK: "Link";
readonly MENTION: "Mention";
readonly LINK: 'Link';
readonly MENTION: 'Mention';
};
export declare const ActorTypes: {
readonly APPLICATION: "Application";
readonly GROUP: "Group";
readonly ORGANIZATION: "Organization";
readonly PERSON: "Person";
readonly SERVICE: "Service";
readonly APPLICATION: 'Application';
readonly GROUP: 'Group';
readonly ORGANIZATION: 'Organization';
readonly PERSON: 'Person';
readonly SERVICE: 'Service';
};
export declare const TransitiveActivityTypes: {
readonly ACCEPT: "Accept";
readonly ADD: "Add";
readonly ANNOUNCE: "Announce";
readonly BLOCK: "Block";
readonly IGNORE: "Ignore";
readonly CREATE: "Create";
readonly DELETE: "Delete";
readonly DISLIKE: "Dislike";
readonly FLAG: "Flag";
readonly FOLLOW: "Follow";
readonly INVITE: "Invite";
readonly JOIN: "Join";
readonly LEAVE: "Leave";
readonly LIKE: "Like";
readonly LISTEN: "Listen";
readonly MOVE: "Move";
readonly OFFER: "Offer";
readonly READ: "Read";
readonly REJECT: "Reject";
readonly REMOVE: "Remove";
readonly TENTATIVE_ACCEPT: "TentativeAccept";
readonly TENTATIVE_REJECT: "TentativeReject";
readonly UNDO: "Undo";
readonly UPDATE: "Update";
readonly VIEW: "View";
readonly ACCEPT: 'Accept';
readonly ADD: 'Add';
readonly ANNOUNCE: 'Announce';
readonly BLOCK: 'Block';
readonly IGNORE: 'Ignore';
readonly CREATE: 'Create';
readonly DELETE: 'Delete';
readonly DISLIKE: 'Dislike';
readonly FLAG: 'Flag';
readonly FOLLOW: 'Follow';
readonly INVITE: 'Invite';
readonly JOIN: 'Join';
readonly LEAVE: 'Leave';
readonly LIKE: 'Like';
readonly LISTEN: 'Listen';
readonly MOVE: 'Move';
readonly OFFER: 'Offer';
readonly READ: 'Read';
readonly REJECT: 'Reject';
readonly REMOVE: 'Remove';
readonly TENTATIVE_ACCEPT: 'TentativeAccept';
readonly TENTATIVE_REJECT: 'TentativeReject';
readonly UNDO: 'Undo';
readonly UPDATE: 'Update';
readonly VIEW: 'View';
};
export declare const IntransitiveActivityTypes: {
readonly ARRIVE: "Arrive";
readonly TRAVEL: "Travel";
readonly QUESTION: "Question";
readonly ARRIVE: 'Arrive';
readonly TRAVEL: 'Travel';
readonly QUESTION: 'Question';
};
export declare const ActivityTypes: {
readonly ARRIVE: "Arrive";
readonly TRAVEL: "Travel";
readonly QUESTION: "Question";
readonly ACCEPT: "Accept";
readonly ADD: "Add";
readonly ANNOUNCE: "Announce";
readonly BLOCK: "Block";
readonly IGNORE: "Ignore";
readonly CREATE: "Create";
readonly DELETE: "Delete";
readonly DISLIKE: "Dislike";
readonly FLAG: "Flag";
readonly FOLLOW: "Follow";
readonly INVITE: "Invite";
readonly JOIN: "Join";
readonly LEAVE: "Leave";
readonly LIKE: "Like";
readonly LISTEN: "Listen";
readonly MOVE: "Move";
readonly OFFER: "Offer";
readonly READ: "Read";
readonly REJECT: "Reject";
readonly REMOVE: "Remove";
readonly TENTATIVE_ACCEPT: "TentativeAccept";
readonly TENTATIVE_REJECT: "TentativeReject";
readonly UNDO: "Undo";
readonly UPDATE: "Update";
readonly VIEW: "View";
readonly ARRIVE: 'Arrive';
readonly TRAVEL: 'Travel';
readonly QUESTION: 'Question';
readonly ACCEPT: 'Accept';
readonly ADD: 'Add';
readonly ANNOUNCE: 'Announce';
readonly BLOCK: 'Block';
readonly IGNORE: 'Ignore';
readonly CREATE: 'Create';
readonly DELETE: 'Delete';
readonly DISLIKE: 'Dislike';
readonly FLAG: 'Flag';
readonly FOLLOW: 'Follow';
readonly INVITE: 'Invite';
readonly JOIN: 'Join';
readonly LEAVE: 'Leave';
readonly LIKE: 'Like';
readonly LISTEN: 'Listen';
readonly MOVE: 'Move';
readonly OFFER: 'Offer';
readonly READ: 'Read';
readonly REJECT: 'Reject';
readonly REMOVE: 'Remove';
readonly TENTATIVE_ACCEPT: 'TentativeAccept';
readonly TENTATIVE_REJECT: 'TentativeReject';
readonly UNDO: 'Undo';
readonly UPDATE: 'Update';
readonly VIEW: 'View';
};
export declare const CollectionTypes: {
readonly COLLECTION: "Collection";
readonly ORDERED_COLLECTION: "OrderedCollection";
readonly COLLECTION: 'Collection';
readonly ORDERED_COLLECTION: 'OrderedCollection';
};
export declare const CollectionPageTypes: {
readonly COLLECTION_PAGE: "CollectionPage";
readonly ORDERED_COLLECTION_PAGE: "OrderedCollectionPage";
readonly COLLECTION_PAGE: 'CollectionPage';
readonly ORDERED_COLLECTION_PAGE: 'OrderedCollectionPage';
};
export declare const CoreObjectTypes: {
readonly COLLECTION_PAGE: "CollectionPage";
readonly ORDERED_COLLECTION_PAGE: "OrderedCollectionPage";
readonly COLLECTION: "Collection";
readonly ORDERED_COLLECTION: "OrderedCollection";
readonly ARRIVE: "Arrive";
readonly TRAVEL: "Travel";
readonly QUESTION: "Question";
readonly ACCEPT: "Accept";
readonly ADD: "Add";
readonly ANNOUNCE: "Announce";
readonly BLOCK: "Block";
readonly IGNORE: "Ignore";
readonly CREATE: "Create";
readonly DELETE: "Delete";
readonly DISLIKE: "Dislike";
readonly FLAG: "Flag";
readonly FOLLOW: "Follow";
readonly INVITE: "Invite";
readonly JOIN: "Join";
readonly LEAVE: "Leave";
readonly LIKE: "Like";
readonly LISTEN: "Listen";
readonly MOVE: "Move";
readonly OFFER: "Offer";
readonly READ: "Read";
readonly REJECT: "Reject";
readonly REMOVE: "Remove";
readonly TENTATIVE_ACCEPT: "TentativeAccept";
readonly TENTATIVE_REJECT: "TentativeReject";
readonly UNDO: "Undo";
readonly UPDATE: "Update";
readonly VIEW: "View";
readonly APPLICATION: "Application";
readonly GROUP: "Group";
readonly ORGANIZATION: "Organization";
readonly PERSON: "Person";
readonly SERVICE: "Service";
readonly ARTICLE: "Article";
readonly AUDIO: "Audio";
readonly DOCUMENT: "Document";
readonly EVENT: "Event";
readonly IMAGE: "Image";
readonly NOTE: "Note";
readonly PAGE: "Page";
readonly PLACE: "Place";
readonly PROFILE: "Profile";
readonly RELATIONSHIP: "Relationship";
readonly TOMBSTONE: "Tombstone";
readonly VIDEO: "Video";
readonly COLLECTION_PAGE: 'CollectionPage';
readonly ORDERED_COLLECTION_PAGE: 'OrderedCollectionPage';
readonly COLLECTION: 'Collection';
readonly ORDERED_COLLECTION: 'OrderedCollection';
readonly ARRIVE: 'Arrive';
readonly TRAVEL: 'Travel';
readonly QUESTION: 'Question';
readonly ACCEPT: 'Accept';
readonly ADD: 'Add';
readonly ANNOUNCE: 'Announce';
readonly BLOCK: 'Block';
readonly IGNORE: 'Ignore';
readonly CREATE: 'Create';
readonly DELETE: 'Delete';
readonly DISLIKE: 'Dislike';
readonly FLAG: 'Flag';
readonly FOLLOW: 'Follow';
readonly INVITE: 'Invite';
readonly JOIN: 'Join';
readonly LEAVE: 'Leave';
readonly LIKE: 'Like';
readonly LISTEN: 'Listen';
readonly MOVE: 'Move';
readonly OFFER: 'Offer';
readonly READ: 'Read';
readonly REJECT: 'Reject';
readonly REMOVE: 'Remove';
readonly TENTATIVE_ACCEPT: 'TentativeAccept';
readonly TENTATIVE_REJECT: 'TentativeReject';
readonly UNDO: 'Undo';
readonly UPDATE: 'Update';
readonly VIEW: 'View';
readonly APPLICATION: 'Application';
readonly GROUP: 'Group';
readonly ORGANIZATION: 'Organization';
readonly PERSON: 'Person';
readonly SERVICE: 'Service';
readonly ARTICLE: 'Article';
readonly AUDIO: 'Audio';
readonly DOCUMENT: 'Document';
readonly EVENT: 'Event';
readonly IMAGE: 'Image';
readonly NOTE: 'Note';
readonly PAGE: 'Page';
readonly PLACE: 'Place';
readonly PROFILE: 'Profile';
readonly RELATIONSHIP: 'Relationship';
readonly TOMBSTONE: 'Tombstone';
readonly VIDEO: 'Video';
};
export declare const AllTypes: {
readonly LINK: "Link";
readonly MENTION: "Mention";
readonly COLLECTION_PAGE: "CollectionPage";
readonly ORDERED_COLLECTION_PAGE: "OrderedCollectionPage";
readonly COLLECTION: "Collection";
readonly ORDERED_COLLECTION: "OrderedCollection";
readonly ARRIVE: "Arrive";
readonly TRAVEL: "Travel";
readonly QUESTION: "Question";
readonly ACCEPT: "Accept";
readonly ADD: "Add";
readonly ANNOUNCE: "Announce";
readonly BLOCK: "Block";
readonly IGNORE: "Ignore";
readonly CREATE: "Create";
readonly DELETE: "Delete";
readonly DISLIKE: "Dislike";
readonly FLAG: "Flag";
readonly FOLLOW: "Follow";
readonly INVITE: "Invite";
readonly JOIN: "Join";
readonly LEAVE: "Leave";
readonly LIKE: "Like";
readonly LISTEN: "Listen";
readonly MOVE: "Move";
readonly OFFER: "Offer";
readonly READ: "Read";
readonly REJECT: "Reject";
readonly REMOVE: "Remove";
readonly TENTATIVE_ACCEPT: "TentativeAccept";
readonly TENTATIVE_REJECT: "TentativeReject";
readonly UNDO: "Undo";
readonly UPDATE: "Update";
readonly VIEW: "View";
readonly APPLICATION: "Application";
readonly GROUP: "Group";
readonly ORGANIZATION: "Organization";
readonly PERSON: "Person";
readonly SERVICE: "Service";
readonly ARTICLE: "Article";
readonly AUDIO: "Audio";
readonly DOCUMENT: "Document";
readonly EVENT: "Event";
readonly IMAGE: "Image";
readonly NOTE: "Note";
readonly PAGE: "Page";
readonly PLACE: "Place";
readonly PROFILE: "Profile";
readonly RELATIONSHIP: "Relationship";
readonly TOMBSTONE: "Tombstone";
readonly VIDEO: "Video";
readonly LINK: 'Link';
readonly MENTION: 'Mention';
readonly COLLECTION_PAGE: 'CollectionPage';
readonly ORDERED_COLLECTION_PAGE: 'OrderedCollectionPage';
readonly COLLECTION: 'Collection';
readonly ORDERED_COLLECTION: 'OrderedCollection';
readonly ARRIVE: 'Arrive';
readonly TRAVEL: 'Travel';
readonly QUESTION: 'Question';
readonly ACCEPT: 'Accept';
readonly ADD: 'Add';
readonly ANNOUNCE: 'Announce';
readonly BLOCK: 'Block';
readonly IGNORE: 'Ignore';
readonly CREATE: 'Create';
readonly DELETE: 'Delete';
readonly DISLIKE: 'Dislike';
readonly FLAG: 'Flag';
readonly FOLLOW: 'Follow';
readonly INVITE: 'Invite';
readonly JOIN: 'Join';
readonly LEAVE: 'Leave';
readonly LIKE: 'Like';
readonly LISTEN: 'Listen';
readonly MOVE: 'Move';
readonly OFFER: 'Offer';
readonly READ: 'Read';
readonly REJECT: 'Reject';
readonly REMOVE: 'Remove';
readonly TENTATIVE_ACCEPT: 'TentativeAccept';
readonly TENTATIVE_REJECT: 'TentativeReject';
readonly UNDO: 'Undo';
readonly UPDATE: 'Update';
readonly VIEW: 'View';
readonly APPLICATION: 'Application';
readonly GROUP: 'Group';
readonly ORGANIZATION: 'Organization';
readonly PERSON: 'Person';
readonly SERVICE: 'Service';
readonly ARTICLE: 'Article';
readonly AUDIO: 'Audio';
readonly DOCUMENT: 'Document';
readonly EVENT: 'Event';
readonly IMAGE: 'Image';
readonly NOTE: 'Note';
readonly PAGE: 'Page';
readonly PLACE: 'Place';
readonly PROFILE: 'Profile';
readonly RELATIONSHIP: 'Relationship';
readonly TOMBSTONE: 'Tombstone';
readonly VIDEO: 'Video';
};

View File

@ -14,9 +14,11 @@
],
"scripts": {
"tsc": "tsc --project tsconfig.json",
"dev": "ts-node ./src/index.ts"
"dev": "ts-node ./src/index.ts",
"format": "prettier --config .prettierrc \"**/*.ts\" --write"
},
"devDependencies": {
"prettier": "^2.7.1",
"ts-node": "^10.9.1"
}
}

View File

@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@ -6,7 +6,7 @@ describe('Utilities', () => {
describe('compressEntity', () => {
const actor1Url = `https://test.com/actor/123`;
const actor1Result: AP.Person = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(actor1Url),
url: new URL(actor1Url),
type: 'Person',
@ -17,7 +17,7 @@ describe('Utilities', () => {
const object1Url = `https://test.com/actor/123`;
const object1Result: AP.Note = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(object1Url),
url: new URL(object1Url),
type: 'Note',
@ -25,7 +25,7 @@ describe('Utilities', () => {
};
const activity1Url = 'https://test.com/activity/456';
const activity1Result: AP.Create = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(activity1Url),
url: new URL(activity1Url),
type: 'Create',

View File

@ -9,27 +9,21 @@ describe('utilities', () => {
const item1Url = 'https://test.com/activity/456';
const item2Url = 'https://test.com/activity/789';
const collection1Result: AP.Collection = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(collection1Url),
url: new URL(collection1Url),
type: 'Collection',
totalItems: 1,
items: [
new URL(item1Url),
new URL(item2Url),
],
items: [new URL(item1Url), new URL(item2Url)],
published: date,
};
const collection1 = {
"@context": ACTIVITYSTREAMS_CONTEXT,
'@context': ACTIVITYSTREAMS_CONTEXT,
id: collection1Url,
url: collection1Url,
type: 'Collection',
totalItems: 1,
items: [
item1Url,
item2Url,
],
items: [item1Url, item2Url],
published: date.toISOString(),
};
it('converts strings to URLS', async () => {

View File

@ -9,27 +9,21 @@ describe('utilities', () => {
const item1Url = 'https://test.com/activity/456';
const item2Url = 'https://test.com/activity/789';
const collection1: AP.Collection = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(collection1Url),
url: new URL(collection1Url),
type: 'Collection',
totalItems: 1,
items: [
new URL(item1Url),
new URL(item2Url),
],
items: [new URL(item1Url), new URL(item2Url)],
published: date,
};
const collection1Result = {
"@context": ACTIVITYSTREAMS_CONTEXT,
'@context': ACTIVITYSTREAMS_CONTEXT,
id: collection1Url,
url: collection1Url,
type: 'Collection',
totalItems: 1,
items: [
item1Url,
item2Url,
],
items: [item1Url, item2Url],
published: date.toISOString(),
};
it('converts', async () => {

View File

@ -6,7 +6,7 @@ describe('utilities', () => {
describe('getId', () => {
const collection1Url = 'https://test.com/activity/123';
const collection1Result: AP.Collection = {
"@context": new URL(ACTIVITYSTREAMS_CONTEXT),
'@context': new URL(ACTIVITYSTREAMS_CONTEXT),
id: new URL(collection1Url),
url: new URL(collection1Url),
type: 'Collection',

View File

@ -1,3 +1,5 @@
/// <reference types="node" />
import { AP } from 'activitypub-core-types';
export declare const getId: (entity?: undefined | null | AP.EntityReference | AP.EntityReference[]) => URL | null;
export declare const getId: (
entity?: undefined | null | AP.EntityReference | AP.EntityReference[],
) => URL | null;

View File

@ -1,4 +1,47 @@
import { AP } from 'activitypub-core-types';
export declare const getTypedEntity: (entity: {
type: string;
}) => AP.Article | AP.Event | AP.Note | AP.Page | AP.Place | AP.Relationship | AP.Tombstone | AP.Profile | AP.Document | AP.Application | AP.Service | AP.Group | AP.Organization | AP.Person | AP.Accept | AP.Follow | AP.Delete | AP.Create | AP.Arrive | AP.Add | AP.Offer | AP.Like | AP.Leave | AP.Ignore | AP.Join | AP.Reject | AP.View | AP.Update | AP.Undo | AP.Remove | AP.Read | AP.Listen | AP.Move | AP.Travel | AP.Announce | AP.Flag | AP.Dislike | AP.Question | AP.Collection | AP.OrderedCollection | AP.CollectionPage | AP.OrderedCollectionPage | import("activitypub-core-types/lib/activitypub/Core/Link").BaseLink;
}) =>
| AP.Article
| AP.Event
| AP.Note
| AP.Page
| AP.Place
| AP.Relationship
| AP.Tombstone
| AP.Profile
| AP.Document
| AP.Application
| AP.Service
| AP.Group
| AP.Organization
| AP.Person
| AP.Accept
| AP.Follow
| AP.Delete
| AP.Create
| AP.Arrive
| AP.Add
| AP.Offer
| AP.Like
| AP.Leave
| AP.Ignore
| AP.Join
| AP.Reject
| AP.View
| AP.Update
| AP.Undo
| AP.Remove
| AP.Read
| AP.Listen
| AP.Move
| AP.Travel
| AP.Announce
| AP.Flag
| AP.Dislike
| AP.Question
| AP.Collection
| AP.OrderedCollection
| AP.CollectionPage
| AP.OrderedCollectionPage
| import('activitypub-core-types/lib/activitypub/Core/Link').BaseLink;

View File

@ -4,21 +4,24 @@ export declare const PROTOCOL: string;
export declare const DB_NAME: string;
export declare const LOCAL_DOMAIN: string;
export declare const MONGO_CLIENT_URL: string;
export declare const CONTEXT = "@context";
export declare const ACTIVITYSTREAMS_CONTEXT = "https://www.w3.org/ns/activitystreams#";
export declare const W3ID_SECURITY_CONTEXT = "https://w3id.org/security/v1";
export declare const RELATIONSHIP_CONTEXT = "http://purl.org/vocab/relationship/";
export declare const CHANGESET_CONTEXT = "http://purl.org/vocab/changeset/schema#";
export declare const CONTEXT = '@context';
export declare const ACTIVITYSTREAMS_CONTEXT =
'https://www.w3.org/ns/activitystreams#';
export declare const W3ID_SECURITY_CONTEXT = 'https://w3id.org/security/v1';
export declare const RELATIONSHIP_CONTEXT =
'http://purl.org/vocab/relationship/';
export declare const CHANGESET_CONTEXT =
'http://purl.org/vocab/changeset/schema#';
export declare const PUBLIC_ACTOR: string;
export declare const LINKED_DATA_CONTENT_TYPE = "application/ld+json";
export declare const SERVER_ACTOR_USERNAME = "bot";
export declare const LINKED_DATA_CONTENT_TYPE = 'application/ld+json';
export declare const SERVER_ACTOR_USERNAME = 'bot';
export declare const SERVER_ACTOR_ID: string;
export declare const SHARED_INBOX_ID: string;
export declare const ACCEPT_HEADER = "Accept";
export declare const CONTENT_TYPE_HEADER = "Content-Type";
export declare const ACCEPT_HEADER = 'Accept';
export declare const CONTENT_TYPE_HEADER = 'Content-Type';
export declare const ACTIVITYSTREAMS_CONTENT_TYPE_WITH_PROFILE: string;
export declare const ACTIVITYSTREAMS_CONTENT_TYPE = "application/activity+json";
export declare const JSON_CONTENT_TYPE = "application/json";
export declare const HTML_CONTENT_TYPE = "text/html";
export declare const ACTIVITYSTREAMS_CONTENT_TYPE = 'application/activity+json';
export declare const JSON_CONTENT_TYPE = 'application/json';
export declare const HTML_CONTENT_TYPE = 'text/html';
export declare const USERNAME_REGEXP: RegExp;
export declare const RESERVED_USERNAMES: string[];

View File

@ -1,4 +1,4 @@
/// <reference types="node" />
import { IncomingMessage } from "http";
import { AP } from "activitypub-core-types";
import { IncomingMessage } from 'http';
import { AP } from 'activitypub-core-types';
export declare function parseStream(req: IncomingMessage): Promise<AP.Entity>;

View File

@ -1,3 +1,5 @@
/// <reference types="node" />
import { IncomingMessage } from 'http';
export declare function streamToString(stream: IncomingMessage): Promise<string>;
export declare function streamToString(
stream: IncomingMessage,
): Promise<string>;

View File

@ -18,9 +18,10 @@
"url": "git+https://github.com/michaelcpuckett/activitypub-core.git"
},
"scripts": {
"tsc": "tsc --project tsconfig.json",
"build": "tsc --project tsconfig.json",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
"dev": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch"
"dev": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch",
"format": "prettier --config .prettierrc \"**/*.ts\" --write"
},
"bugs": {
"url": "https://github.com/michaelcpuckett/activitypub-core/issues"
@ -35,6 +36,7 @@
"@types/jsonld": "^1.5.6",
"dotenv": "^16.0.3",
"jest": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
}

View File

@ -1,12 +1,14 @@
import { AP } from 'activitypub-core-types';
export function compressEntity(
entity: AP.Entity,
): AP.Entity {
export function compressEntity(entity: AP.Entity): AP.Entity {
const compressed: { [key: string]: unknown } = { ...entity };
for (const [key, value] of Object.entries(entity)) {
if (value instanceof URL || value instanceof Date || typeof value === 'string') {
if (
value instanceof URL ||
value instanceof Date ||
typeof value === 'string'
) {
continue;
} else if (Array.isArray(value)) {
compressed[key] = compressArray(value);
@ -27,7 +29,11 @@ export function compressEntity(
function compressArray(array: any[]) {
return array.map((item) => {
if (item instanceof URL || item instanceof Date || typeof item === 'string') {
if (
item instanceof URL ||
item instanceof Date ||
typeof item === 'string'
) {
return item;
} else if (Array.isArray(item)) {
return compressArray(item);

View File

@ -1,6 +1,8 @@
import { AP } from 'activitypub-core-types';
export function convertStringsToUrls(originalEntity: { [key: string]: unknown }): AP.Entity {
export function convertStringsToUrls(originalEntity: {
[key: string]: unknown;
}): AP.Entity {
const entity: { [key: string]: unknown } = { ...originalEntity };
for (const [key, value] of Object.entries(entity)) {
@ -25,7 +27,7 @@ export function convertStringsToUrls(originalEntity: { [key: string]: unknown })
} else if (value instanceof URL || value instanceof Date) {
continue;
} else if (Array.isArray(value)) {
entity[key] = value.map(item => {
entity[key] = value.map((item) => {
if (typeof item === 'string') {
try {
return new URL(item);

View File

@ -3,4 +3,4 @@ import { stringify } from 'superjson';
export const convertUrlsToStrings = (entity: AP.Entity): AP.Entity => {
return JSON.parse(stringify(entity)).json;
}
};

View File

@ -2,7 +2,8 @@ export const PORT = Number(process.env.AP_PORT ?? 3000);
export const LOCAL_HOSTNAME = process.env.AP_HOST_NAME ?? 'localhost';
export const PROTOCOL = process.env.AP_PROTOCOL ?? 'http:';
export const DB_NAME = process.env.AP_DB_NAME ?? 'activitypub';
export const LOCAL_DOMAIN = `${PROTOCOL}//${LOCAL_HOSTNAME}${PORT === 80 ? '' : `:${PORT}`
export const LOCAL_DOMAIN = `${PROTOCOL}//${LOCAL_HOSTNAME}${
PORT === 80 ? '' : `:${PORT}`
}`;
export const MONGO_CLIENT_URL =
process.env.AP_MONGO_CLIENT_URL ?? 'mongodb://localhost:27017';

View File

@ -1,8 +1,10 @@
import { IncomingMessage } from "http";
import { AP } from "activitypub-core-types";
import { convertFromJsonLd } from "./convertFromJsonLd";
import { streamToString } from "./streamToString";
import { IncomingMessage } from 'http';
import { AP } from 'activitypub-core-types';
import { convertFromJsonLd } from './convertFromJsonLd';
import { streamToString } from './streamToString';
export async function parseStream(req: IncomingMessage): Promise<AP.Entity> {
return await convertFromJsonLd(JSON.parse(await streamToString(req))) as AP.Entity;
return (await convertFromJsonLd(
JSON.parse(await streamToString(req)),
)) as AP.Entity;
}

View File

@ -1,7 +1,7 @@
import { AP } from 'activitypub-core-types';
import { addContext } from "./addContext";
import { cleanProps } from "./cleanProps";
import { convertUrlsToStrings } from "./convertUrlsToStrings";
import { addContext } from './addContext';
import { cleanProps } from './cleanProps';
import { convertUrlsToStrings } from './convertUrlsToStrings';
export function stringifyWithContext(entity: AP.Entity) {
return JSON.stringify(convertUrlsToStrings(addContext(cleanProps(entity))));

Some files were not shown because too many files have changed in this diff Show More