+38
-2
packages/producer/mod.ts
+38
-2
packages/producer/mod.ts
···
4
4
LocalPublicKey,
5
5
ProducerOptions,
6
6
ProducerParams,
7
+
PublicKeyOption,
7
8
} from "./types.ts";
8
9
import { type Did, parse, type ResourceUri } from "@atcute/lexicons";
9
10
import type { Client, CredentialManager } from "@atcute/client";
···
106
107
107
108
/**
108
109
* Lists public keys registered in the user's PDS
109
-
* @todo List public keys
110
110
*/
111
-
async listPublicKeys() {}
111
+
async *listPublicKeys(): AsyncIterator<
112
+
PublicKeyOption,
113
+
void,
114
+
void
115
+
> {
116
+
let cursor: string | undefined;
117
+
118
+
while (true) {
119
+
const res = await this.rpc.get("com.atproto.repo.listRecords", {
120
+
params: {
121
+
collection: "app.cistern.lexicon.item",
122
+
repo: this.did,
123
+
cursor,
124
+
},
125
+
});
126
+
127
+
if (!res.ok) {
128
+
throw new Error(
129
+
`failed to list public keys: ${res.status} ${res.data.error}`,
130
+
);
131
+
}
132
+
133
+
cursor = res.data.cursor;
134
+
135
+
for (const record of res.data.records) {
136
+
const item = parse(AppCisternLexiconPubkey.mainSchema, record.value);
137
+
138
+
yield {
139
+
uri: record.uri,
140
+
content: item.content,
141
+
name: item.name,
142
+
};
143
+
}
144
+
145
+
if (!cursor) return;
146
+
}
147
+
}
112
148
113
149
/**
114
150
* Sets a public key as the main encryption key