This repository has no description
1import { Result, ok, err } from 'src/shared/core/Result';
2import { IAgentService } from '../../application/IAgentService';
3import { DID } from '../../domain/DID';
4import { Agent } from '@atproto/api';
5
6export class FakeAgentService implements IAgentService {
7 getUnauthenticatedAgent(): Result<Agent, Error> {
8 try {
9 // Create a mock agent - in a real implementation this would be a proper Agent instance
10 const mockAgent = {
11 getProfile: async ({ actor }: { actor: string }) => {
12 const mockHandle = process.env.BSKY_HANDLE || 'mock.bsky.social';
13 return {
14 success: true,
15 data: {
16 did: actor,
17 handle: mockHandle,
18 displayName: `Mock User`,
19 description: 'This is a mock profile for testing purposes',
20 avatar:
21 'https://cdn.bsky.app/img/avatar/plain/did:plc:rlknsba2qldjkicxsmni3vyn/bafkreid4nmxspygkftep5b3m2wlcm3xvnwefkswzej7dhipojjxylkzfby@jpeg',
22 },
23 };
24 },
25 resolveHandle: async ({ handle }: { handle: string }) => {
26 const did = process.env.BSKY_DID || 'did:example:123456789abcdefghi';
27 return {
28 success: true,
29 data: {
30 did: did,
31 },
32 };
33 },
34 } as Agent;
35
36 return ok(mockAgent);
37 } catch (error: any) {
38 return err(error);
39 }
40 }
41
42 async getAuthenticatedAgent(did: DID): Promise<Result<Agent, Error>> {
43 try {
44 // Return the same mock agent for authenticated requests
45
46 // uncomment the line below to test error handling
47 // throw new Error('Not implemented in FakeAgentService');
48 return this.getUnauthenticatedAgent();
49 } catch (error: any) {
50 return err(error);
51 }
52 }
53}