@atproto/api 0.6.19 → 0.6.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +4 -0
- package/definitions/moderation-behaviors.d.ts +1 -0
- package/definitions/profile-moderation-behaviors.json +25 -0
- package/dist/agent.d.ts +2 -0
- package/dist/bsky-agent.d.ts +7 -0
- package/dist/client/index.d.ts +15 -0
- package/dist/client/lexicons.d.ts +142 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts +1 -0
- package/dist/client/types/com/atproto/server/confirmEmail.d.ts +30 -0
- package/dist/client/types/com/atproto/server/createAccount.d.ts +2 -0
- package/dist/client/types/com/atproto/server/createSession.d.ts +2 -0
- package/dist/client/types/com/atproto/server/getSession.d.ts +1 -0
- package/dist/client/types/com/atproto/server/refreshSession.d.ts +1 -0
- package/dist/client/types/com/atproto/server/requestEmailConfirmation.d.ts +13 -0
- package/dist/client/types/com/atproto/server/requestEmailUpdate.d.ts +18 -0
- package/dist/client/types/com/atproto/server/reserveSigningKey.d.ts +18 -0
- package/dist/client/types/com/atproto/server/updateEmail.d.ts +27 -0
- package/dist/client/types/com/atproto/sync/listRepos.d.ts +1 -0
- package/dist/index.js +754 -321
- package/dist/index.js.map +3 -3
- package/dist/moderation/accumulator.d.ts +1 -0
- package/dist/types.d.ts +1 -0
- package/docs/moderation-behaviors/profiles.md +17 -0
- package/package.json +8 -7
- package/src/agent.ts +32 -1
- package/src/bsky-agent.ts +43 -0
- package/src/client/index.ts +65 -0
- package/src/client/lexicons.ts +166 -1
- package/src/client/types/app/bsky/actor/defs.ts +1 -0
- package/src/client/types/com/atproto/server/confirmEmail.ts +61 -0
- package/src/client/types/com/atproto/server/createAccount.ts +2 -0
- package/src/client/types/com/atproto/server/createSession.ts +2 -0
- package/src/client/types/com/atproto/server/getSession.ts +1 -0
- package/src/client/types/com/atproto/server/refreshSession.ts +1 -0
- package/src/client/types/com/atproto/server/requestEmailConfirmation.ts +28 -0
- package/src/client/types/com/atproto/server/requestEmailUpdate.ts +34 -0
- package/src/client/types/com/atproto/server/reserveSigningKey.ts +35 -0
- package/src/client/types/com/atproto/server/updateEmail.ts +55 -0
- package/src/client/types/com/atproto/sync/listRepos.ts +1 -0
- package/src/moderation/accumulator.ts +13 -0
- package/src/moderation/subjects/account.ts +7 -1
- package/src/types.ts +1 -0
- package/tests/agent.test.ts +27 -21
- package/tests/bsky-agent.test.ts +19 -25
- package/tests/errors.test.ts +5 -11
- package/tests/rich-text-detection.test.ts +3 -3
- package/tests/util/index.ts +3 -0
- package/tests/util/moderation-behavior.ts +10 -2
|
@@ -6,6 +6,7 @@ export declare class ModerationCauseAccumulator {
|
|
|
6
6
|
constructor();
|
|
7
7
|
setDid(did: string): void;
|
|
8
8
|
addBlocking(blocking: string | undefined): void;
|
|
9
|
+
addBlockingByList(blockingByList: AppBskyGraphDefs.ListViewBasic | undefined): void;
|
|
9
10
|
addBlockedBy(blockedBy: boolean | undefined): void;
|
|
10
11
|
addBlockOther(blockOther: boolean | undefined): void;
|
|
11
12
|
addLabel(label: Label, opts: ModerationOpts): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface AtpSessionData {
|
|
|
6
6
|
handle: string;
|
|
7
7
|
did: string;
|
|
8
8
|
email?: string;
|
|
9
|
+
emailConfirmed?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare type AtpPersistSessionHandler = (evt: AtpSessionEvent, session: AtpSessionData | undefined) => void | Promise<void>;
|
|
11
12
|
export interface AtpAgentOpts {
|
|
@@ -547,6 +547,23 @@ Key:
|
|
|
547
547
|
</td>
|
|
548
548
|
</tr>
|
|
549
549
|
|
|
550
|
+
<tr>
|
|
551
|
+
<td><strong>Mute/block: Blocking-by-list user</strong></td>
|
|
552
|
+
<td>
|
|
553
|
+
❌
|
|
554
|
+
</td>
|
|
555
|
+
<td>
|
|
556
|
+
|
|
557
|
+
</td>
|
|
558
|
+
<td>
|
|
559
|
+
|
|
560
|
+
</td>
|
|
561
|
+
<td>
|
|
562
|
+
🚫
|
|
563
|
+
|
|
564
|
+
</td>
|
|
565
|
+
</tr>
|
|
566
|
+
|
|
550
567
|
<tr>
|
|
551
568
|
<td><strong>Mute/block: Blocked by user</strong></td>
|
|
552
569
|
<td>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/api",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Client library for atproto and Bluesky",
|
|
6
6
|
"keywords": [
|
|
@@ -19,15 +19,16 @@
|
|
|
19
19
|
"multiformats": "^9.9.0",
|
|
20
20
|
"tlds": "^1.234.0",
|
|
21
21
|
"typed-emitter": "^2.1.0",
|
|
22
|
-
"
|
|
23
|
-
"@atproto/
|
|
24
|
-
"@atproto/
|
|
25
|
-
"@atproto/
|
|
22
|
+
"zod": "^3.21.4",
|
|
23
|
+
"@atproto/common-web": "^0.2.2",
|
|
24
|
+
"@atproto/lexicon": "^0.2.3",
|
|
25
|
+
"@atproto/syntax": "^0.1.3",
|
|
26
|
+
"@atproto/xrpc": "^0.3.3"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"common-tags": "^1.8.2",
|
|
29
|
-
"@atproto/lex-cli": "^0.2.
|
|
30
|
-
"@atproto/
|
|
30
|
+
"@atproto/lex-cli": "^0.2.3",
|
|
31
|
+
"@atproto/dev-env": "^0.2.12"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"codegen": "pnpm docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
|
package/src/agent.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ErrorResponseBody, errorResponseBody } from '@atproto/xrpc'
|
|
2
2
|
import { defaultFetchHandler } from '@atproto/xrpc'
|
|
3
|
+
import { isValidDidDoc, getPdsEndpoint } from '@atproto/common-web'
|
|
3
4
|
import {
|
|
4
5
|
AtpBaseClient,
|
|
5
6
|
AtpServiceClient,
|
|
@@ -30,6 +31,11 @@ export class AtpAgent {
|
|
|
30
31
|
api: AtpServiceClient
|
|
31
32
|
session?: AtpSessionData
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The PDS URL, driven by the did doc. May be undefined.
|
|
36
|
+
*/
|
|
37
|
+
pdsUrl: URL | undefined
|
|
38
|
+
|
|
33
39
|
private _baseClient: AtpBaseClient
|
|
34
40
|
private _persistSession?: AtpPersistSessionHandler
|
|
35
41
|
private _refreshSessionPromise: Promise<void> | undefined
|
|
@@ -95,7 +101,9 @@ export class AtpAgent {
|
|
|
95
101
|
handle: res.data.handle,
|
|
96
102
|
did: res.data.did,
|
|
97
103
|
email: opts.email,
|
|
104
|
+
emailConfirmed: false,
|
|
98
105
|
}
|
|
106
|
+
this._updateApiEndpoint(res.data.didDoc)
|
|
99
107
|
return res
|
|
100
108
|
} catch (e) {
|
|
101
109
|
this.session = undefined
|
|
@@ -126,7 +134,9 @@ export class AtpAgent {
|
|
|
126
134
|
handle: res.data.handle,
|
|
127
135
|
did: res.data.did,
|
|
128
136
|
email: res.data.email,
|
|
137
|
+
emailConfirmed: res.data.emailConfirmed,
|
|
129
138
|
}
|
|
139
|
+
this._updateApiEndpoint(res.data.didDoc)
|
|
130
140
|
return res
|
|
131
141
|
} catch (e) {
|
|
132
142
|
this.session = undefined
|
|
@@ -154,6 +164,7 @@ export class AtpAgent {
|
|
|
154
164
|
}
|
|
155
165
|
this.session.email = res.data.email
|
|
156
166
|
this.session.handle = res.data.handle
|
|
167
|
+
this.session.emailConfirmed = res.data.emailConfirmed
|
|
157
168
|
return res
|
|
158
169
|
} catch (e) {
|
|
159
170
|
this.session = undefined
|
|
@@ -250,7 +261,7 @@ export class AtpAgent {
|
|
|
250
261
|
}
|
|
251
262
|
|
|
252
263
|
// send the refresh request
|
|
253
|
-
const url = new URL(this.service.origin)
|
|
264
|
+
const url = new URL((this.pdsUrl || this.service).origin)
|
|
254
265
|
url.pathname = `/xrpc/${REFRESH_SESSION}`
|
|
255
266
|
const res = await AtpAgent.fetch(
|
|
256
267
|
url.toString(),
|
|
@@ -268,11 +279,13 @@ export class AtpAgent {
|
|
|
268
279
|
} else if (isNewSessionObject(this._baseClient, res.body)) {
|
|
269
280
|
// succeeded, update the session
|
|
270
281
|
this.session = {
|
|
282
|
+
...(this.session || {}),
|
|
271
283
|
accessJwt: res.body.accessJwt,
|
|
272
284
|
refreshJwt: res.body.refreshJwt,
|
|
273
285
|
handle: res.body.handle,
|
|
274
286
|
did: res.body.did,
|
|
275
287
|
}
|
|
288
|
+
this._updateApiEndpoint(res.body.didDoc)
|
|
276
289
|
this._persistSession?.('update', this.session)
|
|
277
290
|
}
|
|
278
291
|
// else: other failures should be ignored - the issue will
|
|
@@ -307,6 +320,24 @@ export class AtpAgent {
|
|
|
307
320
|
*/
|
|
308
321
|
createModerationReport: typeof this.api.com.atproto.moderation.createReport =
|
|
309
322
|
(data, opts) => this.api.com.atproto.moderation.createReport(data, opts)
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Helper to update the pds endpoint dynamically.
|
|
326
|
+
*
|
|
327
|
+
* The session methods (create, resume, refresh) may respond with the user's
|
|
328
|
+
* did document which contains the user's canonical PDS endpoint. That endpoint
|
|
329
|
+
* may differ from the endpoint used to contact the server. We capture that
|
|
330
|
+
* PDS endpoint and update the client to use that given endpoint for future
|
|
331
|
+
* requests. (This helps ensure smooth migrations between PDSes, especially
|
|
332
|
+
* when the PDSes are operated by a single org.)
|
|
333
|
+
*/
|
|
334
|
+
private _updateApiEndpoint(didDoc: unknown) {
|
|
335
|
+
if (isValidDidDoc(didDoc)) {
|
|
336
|
+
const endpoint = getPdsEndpoint(didDoc)
|
|
337
|
+
this.pdsUrl = endpoint ? new URL(endpoint) : undefined
|
|
338
|
+
}
|
|
339
|
+
this.api.xrpc.uri = this.pdsUrl || this.service
|
|
340
|
+
}
|
|
310
341
|
}
|
|
311
342
|
|
|
312
343
|
function isErrorObject(v: unknown): v is ErrorResponseBody {
|
package/src/bsky-agent.ts
CHANGED
|
@@ -258,6 +258,49 @@ export class BskyAgent extends AtpAgent {
|
|
|
258
258
|
return this.api.app.bsky.graph.unmuteActor({ actor })
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
async muteModList(uri: string) {
|
|
262
|
+
return this.api.app.bsky.graph.muteActorList({
|
|
263
|
+
list: uri,
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async unmuteModList(uri: string) {
|
|
268
|
+
return this.api.app.bsky.graph.unmuteActorList({
|
|
269
|
+
list: uri,
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async blockModList(uri: string) {
|
|
274
|
+
if (!this.session) {
|
|
275
|
+
throw new Error('Not logged in')
|
|
276
|
+
}
|
|
277
|
+
return await this.api.app.bsky.graph.listblock.create(
|
|
278
|
+
{ repo: this.session.did },
|
|
279
|
+
{
|
|
280
|
+
subject: uri,
|
|
281
|
+
createdAt: new Date().toISOString(),
|
|
282
|
+
},
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async unblockModList(uri: string) {
|
|
287
|
+
if (!this.session) {
|
|
288
|
+
throw new Error('Not logged in')
|
|
289
|
+
}
|
|
290
|
+
const listInfo = await this.api.app.bsky.graph.getList({
|
|
291
|
+
list: uri,
|
|
292
|
+
limit: 1,
|
|
293
|
+
})
|
|
294
|
+
if (!listInfo.data.list.viewer?.blocked) {
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
const { rkey } = new AtUri(listInfo.data.list.viewer.blocked)
|
|
298
|
+
return await this.api.app.bsky.graph.listblock.delete({
|
|
299
|
+
repo: this.session.did,
|
|
300
|
+
rkey,
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
261
304
|
async updateSeenNotifications(seenAt?: string) {
|
|
262
305
|
seenAt = seenAt || new Date().toISOString()
|
|
263
306
|
return this.api.app.bsky.notification.updateSeen({
|
package/src/client/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords
|
|
|
41
41
|
import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
|
|
42
42
|
import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
|
|
43
43
|
import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
|
|
44
|
+
import * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
|
|
44
45
|
import * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
|
|
45
46
|
import * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
|
|
46
47
|
import * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
|
|
@@ -55,9 +56,13 @@ import * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
|
|
|
55
56
|
import * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
|
|
56
57
|
import * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
|
|
57
58
|
import * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
|
|
59
|
+
import * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
60
|
+
import * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
58
61
|
import * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
62
|
+
import * as ComAtprotoServerReserveSigningKey from './types/com/atproto/server/reserveSigningKey'
|
|
59
63
|
import * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
60
64
|
import * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
65
|
+
import * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
61
66
|
import * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
|
|
62
67
|
import * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
|
|
63
68
|
import * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
|
|
@@ -170,6 +175,7 @@ export * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords
|
|
|
170
175
|
export * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
|
|
171
176
|
export * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
|
|
172
177
|
export * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
|
|
178
|
+
export * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
|
|
173
179
|
export * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
|
|
174
180
|
export * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
|
|
175
181
|
export * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
|
|
@@ -184,9 +190,13 @@ export * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
|
|
|
184
190
|
export * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
|
|
185
191
|
export * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
|
|
186
192
|
export * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
|
|
193
|
+
export * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
194
|
+
export * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
187
195
|
export * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
196
|
+
export * as ComAtprotoServerReserveSigningKey from './types/com/atproto/server/reserveSigningKey'
|
|
188
197
|
export * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
189
198
|
export * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
199
|
+
export * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
190
200
|
export * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
|
|
191
201
|
export * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
|
|
192
202
|
export * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
|
|
@@ -712,6 +722,17 @@ export class ServerNS {
|
|
|
712
722
|
this._service = service
|
|
713
723
|
}
|
|
714
724
|
|
|
725
|
+
confirmEmail(
|
|
726
|
+
data?: ComAtprotoServerConfirmEmail.InputSchema,
|
|
727
|
+
opts?: ComAtprotoServerConfirmEmail.CallOptions,
|
|
728
|
+
): Promise<ComAtprotoServerConfirmEmail.Response> {
|
|
729
|
+
return this._service.xrpc
|
|
730
|
+
.call('com.atproto.server.confirmEmail', opts?.qp, data, opts)
|
|
731
|
+
.catch((e) => {
|
|
732
|
+
throw ComAtprotoServerConfirmEmail.toKnownErr(e)
|
|
733
|
+
})
|
|
734
|
+
}
|
|
735
|
+
|
|
715
736
|
createAccount(
|
|
716
737
|
data?: ComAtprotoServerCreateAccount.InputSchema,
|
|
717
738
|
opts?: ComAtprotoServerCreateAccount.CallOptions,
|
|
@@ -855,6 +876,28 @@ export class ServerNS {
|
|
|
855
876
|
})
|
|
856
877
|
}
|
|
857
878
|
|
|
879
|
+
requestEmailConfirmation(
|
|
880
|
+
data?: ComAtprotoServerRequestEmailConfirmation.InputSchema,
|
|
881
|
+
opts?: ComAtprotoServerRequestEmailConfirmation.CallOptions,
|
|
882
|
+
): Promise<ComAtprotoServerRequestEmailConfirmation.Response> {
|
|
883
|
+
return this._service.xrpc
|
|
884
|
+
.call('com.atproto.server.requestEmailConfirmation', opts?.qp, data, opts)
|
|
885
|
+
.catch((e) => {
|
|
886
|
+
throw ComAtprotoServerRequestEmailConfirmation.toKnownErr(e)
|
|
887
|
+
})
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
requestEmailUpdate(
|
|
891
|
+
data?: ComAtprotoServerRequestEmailUpdate.InputSchema,
|
|
892
|
+
opts?: ComAtprotoServerRequestEmailUpdate.CallOptions,
|
|
893
|
+
): Promise<ComAtprotoServerRequestEmailUpdate.Response> {
|
|
894
|
+
return this._service.xrpc
|
|
895
|
+
.call('com.atproto.server.requestEmailUpdate', opts?.qp, data, opts)
|
|
896
|
+
.catch((e) => {
|
|
897
|
+
throw ComAtprotoServerRequestEmailUpdate.toKnownErr(e)
|
|
898
|
+
})
|
|
899
|
+
}
|
|
900
|
+
|
|
858
901
|
requestPasswordReset(
|
|
859
902
|
data?: ComAtprotoServerRequestPasswordReset.InputSchema,
|
|
860
903
|
opts?: ComAtprotoServerRequestPasswordReset.CallOptions,
|
|
@@ -866,6 +909,17 @@ export class ServerNS {
|
|
|
866
909
|
})
|
|
867
910
|
}
|
|
868
911
|
|
|
912
|
+
reserveSigningKey(
|
|
913
|
+
data?: ComAtprotoServerReserveSigningKey.InputSchema,
|
|
914
|
+
opts?: ComAtprotoServerReserveSigningKey.CallOptions,
|
|
915
|
+
): Promise<ComAtprotoServerReserveSigningKey.Response> {
|
|
916
|
+
return this._service.xrpc
|
|
917
|
+
.call('com.atproto.server.reserveSigningKey', opts?.qp, data, opts)
|
|
918
|
+
.catch((e) => {
|
|
919
|
+
throw ComAtprotoServerReserveSigningKey.toKnownErr(e)
|
|
920
|
+
})
|
|
921
|
+
}
|
|
922
|
+
|
|
869
923
|
resetPassword(
|
|
870
924
|
data?: ComAtprotoServerResetPassword.InputSchema,
|
|
871
925
|
opts?: ComAtprotoServerResetPassword.CallOptions,
|
|
@@ -887,6 +941,17 @@ export class ServerNS {
|
|
|
887
941
|
throw ComAtprotoServerRevokeAppPassword.toKnownErr(e)
|
|
888
942
|
})
|
|
889
943
|
}
|
|
944
|
+
|
|
945
|
+
updateEmail(
|
|
946
|
+
data?: ComAtprotoServerUpdateEmail.InputSchema,
|
|
947
|
+
opts?: ComAtprotoServerUpdateEmail.CallOptions,
|
|
948
|
+
): Promise<ComAtprotoServerUpdateEmail.Response> {
|
|
949
|
+
return this._service.xrpc
|
|
950
|
+
.call('com.atproto.server.updateEmail', opts?.qp, data, opts)
|
|
951
|
+
.catch((e) => {
|
|
952
|
+
throw ComAtprotoServerUpdateEmail.toKnownErr(e)
|
|
953
|
+
})
|
|
954
|
+
}
|
|
890
955
|
}
|
|
891
956
|
|
|
892
957
|
export class SyncNS {
|
package/src/client/lexicons.ts
CHANGED
|
@@ -2242,6 +2242,46 @@ export const schemaDict = {
|
|
|
2242
2242
|
},
|
|
2243
2243
|
},
|
|
2244
2244
|
},
|
|
2245
|
+
ComAtprotoServerConfirmEmail: {
|
|
2246
|
+
lexicon: 1,
|
|
2247
|
+
id: 'com.atproto.server.confirmEmail',
|
|
2248
|
+
defs: {
|
|
2249
|
+
main: {
|
|
2250
|
+
type: 'procedure',
|
|
2251
|
+
description:
|
|
2252
|
+
'Confirm an email using a token from com.atproto.server.requestEmailConfirmation.',
|
|
2253
|
+
input: {
|
|
2254
|
+
encoding: 'application/json',
|
|
2255
|
+
schema: {
|
|
2256
|
+
type: 'object',
|
|
2257
|
+
required: ['email', 'token'],
|
|
2258
|
+
properties: {
|
|
2259
|
+
email: {
|
|
2260
|
+
type: 'string',
|
|
2261
|
+
},
|
|
2262
|
+
token: {
|
|
2263
|
+
type: 'string',
|
|
2264
|
+
},
|
|
2265
|
+
},
|
|
2266
|
+
},
|
|
2267
|
+
},
|
|
2268
|
+
errors: [
|
|
2269
|
+
{
|
|
2270
|
+
name: 'AccountNotFound',
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
name: 'ExpiredToken',
|
|
2274
|
+
},
|
|
2275
|
+
{
|
|
2276
|
+
name: 'InvalidToken',
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
name: 'InvalidEmail',
|
|
2280
|
+
},
|
|
2281
|
+
],
|
|
2282
|
+
},
|
|
2283
|
+
},
|
|
2284
|
+
},
|
|
2245
2285
|
ComAtprotoServerCreateAccount: {
|
|
2246
2286
|
lexicon: 1,
|
|
2247
2287
|
id: 'com.atproto.server.createAccount',
|
|
@@ -2275,6 +2315,9 @@ export const schemaDict = {
|
|
|
2275
2315
|
recoveryKey: {
|
|
2276
2316
|
type: 'string',
|
|
2277
2317
|
},
|
|
2318
|
+
plcOp: {
|
|
2319
|
+
type: 'bytes',
|
|
2320
|
+
},
|
|
2278
2321
|
},
|
|
2279
2322
|
},
|
|
2280
2323
|
},
|
|
@@ -2298,6 +2341,9 @@ export const schemaDict = {
|
|
|
2298
2341
|
type: 'string',
|
|
2299
2342
|
format: 'did',
|
|
2300
2343
|
},
|
|
2344
|
+
didDoc: {
|
|
2345
|
+
type: 'unknown',
|
|
2346
|
+
},
|
|
2301
2347
|
},
|
|
2302
2348
|
},
|
|
2303
2349
|
},
|
|
@@ -2523,9 +2569,15 @@ export const schemaDict = {
|
|
|
2523
2569
|
type: 'string',
|
|
2524
2570
|
format: 'did',
|
|
2525
2571
|
},
|
|
2572
|
+
didDoc: {
|
|
2573
|
+
type: 'unknown',
|
|
2574
|
+
},
|
|
2526
2575
|
email: {
|
|
2527
2576
|
type: 'string',
|
|
2528
2577
|
},
|
|
2578
|
+
emailConfirmed: {
|
|
2579
|
+
type: 'boolean',
|
|
2580
|
+
},
|
|
2529
2581
|
},
|
|
2530
2582
|
},
|
|
2531
2583
|
},
|
|
@@ -2756,6 +2808,9 @@ export const schemaDict = {
|
|
|
2756
2808
|
email: {
|
|
2757
2809
|
type: 'string',
|
|
2758
2810
|
},
|
|
2811
|
+
emailConfirmed: {
|
|
2812
|
+
type: 'boolean',
|
|
2813
|
+
},
|
|
2759
2814
|
},
|
|
2760
2815
|
},
|
|
2761
2816
|
},
|
|
@@ -2833,6 +2888,9 @@ export const schemaDict = {
|
|
|
2833
2888
|
type: 'string',
|
|
2834
2889
|
format: 'did',
|
|
2835
2890
|
},
|
|
2891
|
+
didDoc: {
|
|
2892
|
+
type: 'unknown',
|
|
2893
|
+
},
|
|
2836
2894
|
},
|
|
2837
2895
|
},
|
|
2838
2896
|
},
|
|
@@ -2854,6 +2912,39 @@ export const schemaDict = {
|
|
|
2854
2912
|
},
|
|
2855
2913
|
},
|
|
2856
2914
|
},
|
|
2915
|
+
ComAtprotoServerRequestEmailConfirmation: {
|
|
2916
|
+
lexicon: 1,
|
|
2917
|
+
id: 'com.atproto.server.requestEmailConfirmation',
|
|
2918
|
+
defs: {
|
|
2919
|
+
main: {
|
|
2920
|
+
type: 'procedure',
|
|
2921
|
+
description:
|
|
2922
|
+
'Request an email with a code to confirm ownership of email',
|
|
2923
|
+
},
|
|
2924
|
+
},
|
|
2925
|
+
},
|
|
2926
|
+
ComAtprotoServerRequestEmailUpdate: {
|
|
2927
|
+
lexicon: 1,
|
|
2928
|
+
id: 'com.atproto.server.requestEmailUpdate',
|
|
2929
|
+
defs: {
|
|
2930
|
+
main: {
|
|
2931
|
+
type: 'procedure',
|
|
2932
|
+
description: 'Request a token in order to update email.',
|
|
2933
|
+
output: {
|
|
2934
|
+
encoding: 'application/json',
|
|
2935
|
+
schema: {
|
|
2936
|
+
type: 'object',
|
|
2937
|
+
required: ['tokenRequired'],
|
|
2938
|
+
properties: {
|
|
2939
|
+
tokenRequired: {
|
|
2940
|
+
type: 'boolean',
|
|
2941
|
+
},
|
|
2942
|
+
},
|
|
2943
|
+
},
|
|
2944
|
+
},
|
|
2945
|
+
},
|
|
2946
|
+
},
|
|
2947
|
+
},
|
|
2857
2948
|
ComAtprotoServerRequestPasswordReset: {
|
|
2858
2949
|
lexicon: 1,
|
|
2859
2950
|
id: 'com.atproto.server.requestPasswordReset',
|
|
@@ -2876,6 +2967,29 @@ export const schemaDict = {
|
|
|
2876
2967
|
},
|
|
2877
2968
|
},
|
|
2878
2969
|
},
|
|
2970
|
+
ComAtprotoServerReserveSigningKey: {
|
|
2971
|
+
lexicon: 1,
|
|
2972
|
+
id: 'com.atproto.server.reserveSigningKey',
|
|
2973
|
+
defs: {
|
|
2974
|
+
main: {
|
|
2975
|
+
type: 'procedure',
|
|
2976
|
+
description: 'Reserve a repo signing key for account creation.',
|
|
2977
|
+
output: {
|
|
2978
|
+
encoding: 'application/json',
|
|
2979
|
+
schema: {
|
|
2980
|
+
type: 'object',
|
|
2981
|
+
required: ['signingKey'],
|
|
2982
|
+
properties: {
|
|
2983
|
+
signingKey: {
|
|
2984
|
+
type: 'string',
|
|
2985
|
+
description: 'Public signing key in the form of a did:key.',
|
|
2986
|
+
},
|
|
2987
|
+
},
|
|
2988
|
+
},
|
|
2989
|
+
},
|
|
2990
|
+
},
|
|
2991
|
+
},
|
|
2992
|
+
},
|
|
2879
2993
|
ComAtprotoServerResetPassword: {
|
|
2880
2994
|
lexicon: 1,
|
|
2881
2995
|
id: 'com.atproto.server.resetPassword',
|
|
@@ -2931,6 +3045,44 @@ export const schemaDict = {
|
|
|
2931
3045
|
},
|
|
2932
3046
|
},
|
|
2933
3047
|
},
|
|
3048
|
+
ComAtprotoServerUpdateEmail: {
|
|
3049
|
+
lexicon: 1,
|
|
3050
|
+
id: 'com.atproto.server.updateEmail',
|
|
3051
|
+
defs: {
|
|
3052
|
+
main: {
|
|
3053
|
+
type: 'procedure',
|
|
3054
|
+
description: "Update an account's email.",
|
|
3055
|
+
input: {
|
|
3056
|
+
encoding: 'application/json',
|
|
3057
|
+
schema: {
|
|
3058
|
+
type: 'object',
|
|
3059
|
+
required: ['email'],
|
|
3060
|
+
properties: {
|
|
3061
|
+
email: {
|
|
3062
|
+
type: 'string',
|
|
3063
|
+
},
|
|
3064
|
+
token: {
|
|
3065
|
+
type: 'string',
|
|
3066
|
+
description:
|
|
3067
|
+
"Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed.",
|
|
3068
|
+
},
|
|
3069
|
+
},
|
|
3070
|
+
},
|
|
3071
|
+
},
|
|
3072
|
+
errors: [
|
|
3073
|
+
{
|
|
3074
|
+
name: 'ExpiredToken',
|
|
3075
|
+
},
|
|
3076
|
+
{
|
|
3077
|
+
name: 'InvalidToken',
|
|
3078
|
+
},
|
|
3079
|
+
{
|
|
3080
|
+
name: 'TokenRequired',
|
|
3081
|
+
},
|
|
3082
|
+
],
|
|
3083
|
+
},
|
|
3084
|
+
},
|
|
3085
|
+
},
|
|
2934
3086
|
ComAtprotoSyncGetBlob: {
|
|
2935
3087
|
lexicon: 1,
|
|
2936
3088
|
id: 'com.atproto.sync.getBlob',
|
|
@@ -3259,7 +3411,7 @@ export const schemaDict = {
|
|
|
3259
3411
|
},
|
|
3260
3412
|
repo: {
|
|
3261
3413
|
type: 'object',
|
|
3262
|
-
required: ['did', 'head'],
|
|
3414
|
+
required: ['did', 'head', 'rev'],
|
|
3263
3415
|
properties: {
|
|
3264
3416
|
did: {
|
|
3265
3417
|
type: 'string',
|
|
@@ -3269,6 +3421,9 @@ export const schemaDict = {
|
|
|
3269
3421
|
type: 'string',
|
|
3270
3422
|
format: 'cid',
|
|
3271
3423
|
},
|
|
3424
|
+
rev: {
|
|
3425
|
+
type: 'string',
|
|
3426
|
+
},
|
|
3272
3427
|
},
|
|
3273
3428
|
},
|
|
3274
3429
|
},
|
|
@@ -3672,6 +3827,10 @@ export const schemaDict = {
|
|
|
3672
3827
|
type: 'string',
|
|
3673
3828
|
format: 'at-uri',
|
|
3674
3829
|
},
|
|
3830
|
+
blockingByList: {
|
|
3831
|
+
type: 'ref',
|
|
3832
|
+
ref: 'lex:app.bsky.graph.defs#listViewBasic',
|
|
3833
|
+
},
|
|
3675
3834
|
following: {
|
|
3676
3835
|
type: 'string',
|
|
3677
3836
|
format: 'at-uri',
|
|
@@ -7240,6 +7399,7 @@ export const ids = {
|
|
|
7240
7399
|
ComAtprotoRepoPutRecord: 'com.atproto.repo.putRecord',
|
|
7241
7400
|
ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef',
|
|
7242
7401
|
ComAtprotoRepoUploadBlob: 'com.atproto.repo.uploadBlob',
|
|
7402
|
+
ComAtprotoServerConfirmEmail: 'com.atproto.server.confirmEmail',
|
|
7243
7403
|
ComAtprotoServerCreateAccount: 'com.atproto.server.createAccount',
|
|
7244
7404
|
ComAtprotoServerCreateAppPassword: 'com.atproto.server.createAppPassword',
|
|
7245
7405
|
ComAtprotoServerCreateInviteCode: 'com.atproto.server.createInviteCode',
|
|
@@ -7256,10 +7416,15 @@ export const ids = {
|
|
|
7256
7416
|
ComAtprotoServerRefreshSession: 'com.atproto.server.refreshSession',
|
|
7257
7417
|
ComAtprotoServerRequestAccountDelete:
|
|
7258
7418
|
'com.atproto.server.requestAccountDelete',
|
|
7419
|
+
ComAtprotoServerRequestEmailConfirmation:
|
|
7420
|
+
'com.atproto.server.requestEmailConfirmation',
|
|
7421
|
+
ComAtprotoServerRequestEmailUpdate: 'com.atproto.server.requestEmailUpdate',
|
|
7259
7422
|
ComAtprotoServerRequestPasswordReset:
|
|
7260
7423
|
'com.atproto.server.requestPasswordReset',
|
|
7424
|
+
ComAtprotoServerReserveSigningKey: 'com.atproto.server.reserveSigningKey',
|
|
7261
7425
|
ComAtprotoServerResetPassword: 'com.atproto.server.resetPassword',
|
|
7262
7426
|
ComAtprotoServerRevokeAppPassword: 'com.atproto.server.revokeAppPassword',
|
|
7427
|
+
ComAtprotoServerUpdateEmail: 'com.atproto.server.updateEmail',
|
|
7263
7428
|
ComAtprotoSyncGetBlob: 'com.atproto.sync.getBlob',
|
|
7264
7429
|
ComAtprotoSyncGetBlocks: 'com.atproto.sync.getBlocks',
|
|
7265
7430
|
ComAtprotoSyncGetCheckout: 'com.atproto.sync.getCheckout',
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export interface InputSchema {
|
|
13
|
+
email: string
|
|
14
|
+
token: string
|
|
15
|
+
[k: string]: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CallOptions {
|
|
19
|
+
headers?: Headers
|
|
20
|
+
qp?: QueryParams
|
|
21
|
+
encoding: 'application/json'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Response {
|
|
25
|
+
success: boolean
|
|
26
|
+
headers: Headers
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class AccountNotFoundError extends XRPCError {
|
|
30
|
+
constructor(src: XRPCError) {
|
|
31
|
+
super(src.status, src.error, src.message, src.headers)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ExpiredTokenError extends XRPCError {
|
|
36
|
+
constructor(src: XRPCError) {
|
|
37
|
+
super(src.status, src.error, src.message, src.headers)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class InvalidTokenError extends XRPCError {
|
|
42
|
+
constructor(src: XRPCError) {
|
|
43
|
+
super(src.status, src.error, src.message, src.headers)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class InvalidEmailError extends XRPCError {
|
|
48
|
+
constructor(src: XRPCError) {
|
|
49
|
+
super(src.status, src.error, src.message, src.headers)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function toKnownErr(e: any) {
|
|
54
|
+
if (e instanceof XRPCError) {
|
|
55
|
+
if (e.error === 'AccountNotFound') return new AccountNotFoundError(e)
|
|
56
|
+
if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
|
|
57
|
+
if (e.error === 'InvalidToken') return new InvalidTokenError(e)
|
|
58
|
+
if (e.error === 'InvalidEmail') return new InvalidEmailError(e)
|
|
59
|
+
}
|
|
60
|
+
return e
|
|
61
|
+
}
|