Use named Atproto API exports
Some checks failed
Deploy / deploy-frontend (push) Has been cancelled
Deploy / deploy-backend (push) Has been cancelled

Atproto 0.20 no longer includes BskyAgent or RichText on its default ESM export, which made BlueskyAgent construction fail at runtime.
This commit is contained in:
Matt Isenhower
2026-08-30 18:47:06 -07:00
parent a142a4f3b5
commit 576fe9f155
2 changed files with 26 additions and 3 deletions

View File

@@ -1,9 +1,7 @@
import atprotoApi from '@atproto/api';
import { BskyAgent, RichText } from '@atproto/api';
import sharp from 'sharp';
import Client from './Client.mjs';
const { BskyAgent, RichText } = atprotoApi;
export default class BlueskyClient extends Client
{
key = 'bluesky';

View File

@@ -0,0 +1,25 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { BskyAgent } from '@atproto/api';
import BlueskyClient from './BlueskyClient.mjs';
describe('BlueskyClient', () => {
afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllEnvs();
});
it('logs in with the current Atproto agent API', async () => {
vi.stubEnv('BLUESKY_SERVICE', 'https://bsky.social');
vi.stubEnv('BLUESKY_IDENTIFIER', 'test.bsky.social');
vi.stubEnv('BLUESKY_PASSWORD', 'test-password');
const login = vi.spyOn(BskyAgent.prototype, 'login').mockResolvedValue();
const client = new BlueskyClient;
await client.login();
expect(login).toHaveBeenCalledWith({
identifier: 'test.bsky.social',
password: 'test-password',
});
});
});