Skip to content

Commit

Permalink
actor endpoints setting
Browse files Browse the repository at this point in the history
  • Loading branch information
wmurphyrd committed Jan 2, 2021
1 parent 986cc6d commit 22a48d4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ collectionParam | String. Express route parameter used for collection id (defaul
pageParam | String. Query parameter used for collection page identifier (defaults to `page`)
itemsPerPage | Number. Count of items in each collection page (default `20`)
context | String, Array. JSON-LD context for your app. Defaults to AcivityStreams + Security vocabs
endpoints | Object. Optional system-wide api endpoint URLs included in [actor objects](https://www.w3.org/TR/activitypub/#actor-objects): `proxyUrl`, `oauthAuthorizationEndpoint`, `oauthTokenEndpoint`, `provideClientKey`, `signClientKey`, `sharedInbox`, `uploadMedia`
store | Replace the default storage model & database backend with your own (see `store/interface.js` for API)
threadDepth | Controls how far up apex will follow links in incoming activities in order to display the conversation thread & check for inbox forwarding needs (default 10)
systemUser | Actor object representing system and used for signing GETs (see below)
Expand Down
6 changes: 6 additions & 0 deletions pub/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ async function createActor (username, displayName, summary, icon, type = 'Person
if (icon) {
actor.icon = icon
}
if (this.settings.endpoints) {
actor.endpoints = {
id: `${id}#endpoints`,
...this.settings.endpoints
}
}
actor = await this.fromJSONLD(actor)
actor._meta = { privateKey: pair.privateKey }
return actor
Expand Down
6 changes: 5 additions & 1 deletion spec/helpers/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ global.initApex = async function initApex () {
actorParam: 'actor',
objectParam: 'id',
activityParam: 'id',
routes
routes,
endpoints: {
uploadMedia: 'https://localhost/upload',
oauthAuthorizationEndpoint: 'https://localhost/auth/authorize'
}
})

app.use(express.json({ type: apex.consts.jsonldTypes }), apex)
Expand Down
35 changes: 35 additions & 0 deletions spec/unit/actor.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* global describe, beforeAll, beforeEach, it, expect */

describe('actor utils', function () {
let testUser
let app
let apex
let client
beforeAll(async function () {
const init = await global.initApex()
testUser = init.testUser
app = init.app
apex = init.apex
client = init.client
app.route('/outbox/:actor')
.get(apex.net.outbox.get)
.post(apex.net.outbox.post)
})
beforeEach(function () {
return global.resetDb(apex, client, testUser)
})
describe('createActor', function () {
it('includes endpoints', async function () {
expect(testUser.endpoints).toEqual([{
id: 'https://localhost/u/test#endpoints',
uploadMedia: ['https://localhost/upload'],
oauthAuthorizationEndpoint: ['https://localhost/auth/authorize']
}])
expect((await apex.toJSONLD(testUser)).endpoints).toEqual({
id: 'https://localhost/u/test#endpoints',
uploadMedia: 'https://localhost/upload',
oauthAuthorizationEndpoint: 'https://localhost/auth/authorize'
})
})
})
})

0 comments on commit 22a48d4

Please sign in to comment.