diff --git a/packages/api/src/agent.ts b/packages/api/src/agent.ts index 732d82715e6..5641ac6a777 100644 --- a/packages/api/src/agent.ts +++ b/packages/api/src/agent.ts @@ -53,9 +53,9 @@ export class AtpAgent { static fetch: AtpAgentFetchHandler | undefined = defaultFetchHandler /** - * The moderation authorities to be used across all requests + * The labelers to be used across all requests with the takedown capability */ - static modAuthoritiesHeader: string[] = [BSKY_LABELER_DID] + static appLabelers: string[] = [BSKY_LABELER_DID] /** * Configures the API globally. @@ -64,8 +64,8 @@ export class AtpAgent { if (opts.fetch) { AtpAgent.fetch = opts.fetch } - if (opts.modAuthorities) { - AtpAgent.modAuthoritiesHeader = opts.modAuthorities + if (opts.appLabelers) { + AtpAgent.appLabelers = opts.appLabelers } } @@ -224,23 +224,13 @@ export class AtpAgent { authorization: `Bearer ${this.session.accessJwt}`, } } - if (AtpAgent.modAuthoritiesHeader.length) { - reqHeaders = { - ...reqHeaders, - 'atproto-mod-authorities': AtpAgent.modAuthoritiesHeader - .filter((str) => str.startsWith('did:')) - .slice(0, MAX_MOD_AUTHORITIES) - .join(','), - } - } - if (this.labelersHeader.length) { - reqHeaders = { - ...reqHeaders, - 'atproto-labelers': this.labelersHeader - .filter((str) => str.startsWith('did:')) - .slice(0, MAX_LABELERS) - .join(','), - } + reqHeaders = { + ...reqHeaders, + 'atproto-accept-labelers': AtpAgent.appLabelers + .map((str) => `${str};redact`) + .concat(this.labelersHeader.filter((str) => str.startsWith('did:'))) + .slice(0, MAX_LABELERS) + .join(', '), } return reqHeaders } diff --git a/packages/api/src/types.ts b/packages/api/src/types.ts index 3834d1746c9..0f3c0191b33 100644 --- a/packages/api/src/types.ts +++ b/packages/api/src/types.ts @@ -68,7 +68,7 @@ export type AtpAgentFetchHandler = ( */ export interface AtpAgentGlobalOpts { fetch?: AtpAgentFetchHandler - modAuthorities?: string[] + appLabelers?: string[] } /** diff --git a/packages/api/tests/agent.test.ts b/packages/api/tests/agent.test.ts index e4ee8dd251f..7bc1c1d1fb0 100644 --- a/packages/api/tests/agent.test.ts +++ b/packages/api/tests/agent.test.ts @@ -482,24 +482,27 @@ describe('agent', () => { }) }) - describe('Mod authorities header', () => { - it('adds the authorities header as expected', async () => { + describe('App labelers header', () => { + it('adds the labelers header as expected', async () => { const server = await createHeaderEchoServer(15991) const agent = new AtpAgent({ service: 'http://localhost:15991' }) const agent2 = new AtpAgent({ service: 'http://localhost:15991' }) const res1 = await agent.com.atproto.server.describeServer() - expect(res1.data['atproto-mod-authorities']).toEqual(BSKY_LABELER_DID) + expect(res1.data['atproto-accept-labelers']).toEqual( + `${BSKY_LABELER_DID};redact`, + ) - AtpAgent.configure({ modAuthorities: ['did:plc:test1', 'did:plc:test2'] }) + AtpAgent.configure({ appLabelers: ['did:plc:test1', 'did:plc:test2'] }) const res2 = await agent.com.atproto.server.describeServer() - expect(res2.data['atproto-mod-authorities']).toEqual( - 'did:plc:test1,did:plc:test2', + expect(res2.data['atproto-accept-labelers']).toEqual( + 'did:plc:test1;redact, did:plc:test2;redact', ) const res3 = await agent2.com.atproto.server.describeServer() - expect(res3.data['atproto-mod-authorities']).toEqual( - 'did:plc:test1,did:plc:test2', + expect(res3.data['atproto-accept-labelers']).toEqual( + 'did:plc:test1;redact, did:plc:test2;redact', ) + AtpAgent.configure({ appLabelers: [BSKY_LABELER_DID] }) await new Promise((r) => server.close(r)) }) @@ -512,12 +515,14 @@ describe('agent', () => { agent.configureLabelersHeader(['did:plc:test1']) const res1 = await agent.com.atproto.server.describeServer() - expect(res1.data['atproto-labelers']).toEqual('did:plc:test1') + expect(res1.data['atproto-accept-labelers']).toEqual( + `${BSKY_LABELER_DID};redact, did:plc:test1`, + ) agent.configureLabelersHeader(['did:plc:test1', 'did:plc:test2']) const res2 = await agent.com.atproto.server.describeServer() - expect(res2.data['atproto-labelers']).toEqual( - 'did:plc:test1,did:plc:test2', + expect(res2.data['atproto-accept-labelers']).toEqual( + `${BSKY_LABELER_DID};redact, did:plc:test1, did:plc:test2`, ) await new Promise((r) => server.close(r))