@atproto/api 0.6.20 → 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 +14 -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 +3 -0
- package/dist/client/lexicons.d.ts +43 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts +1 -0
- package/dist/client/types/com/atproto/server/createAccount.d.ts +2 -0
- package/dist/client/types/com/atproto/server/createSession.d.ts +1 -0
- package/dist/client/types/com/atproto/server/refreshSession.d.ts +1 -0
- package/dist/client/types/com/atproto/server/reserveSigningKey.d.ts +18 -0
- package/dist/client/types/com/atproto/sync/listRepos.d.ts +1 -0
- package/dist/index.js +456 -265
- package/dist/index.js.map +3 -3
- package/dist/moderation/accumulator.d.ts +1 -0
- package/docs/moderation-behaviors/profiles.md +17 -0
- package/package.json +8 -7
- package/src/agent.ts +28 -1
- package/src/bsky-agent.ts +43 -0
- package/src/client/index.ts +13 -0
- package/src/client/lexicons.ts +44 -1
- package/src/client/types/app/bsky/actor/defs.ts +1 -0
- package/src/client/types/com/atproto/server/createAccount.ts +2 -0
- package/src/client/types/com/atproto/server/createSession.ts +1 -0
- package/src/client/types/com/atproto/server/refreshSession.ts +1 -0
- package/src/client/types/com/atproto/server/reserveSigningKey.ts +35 -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/tests/agent.test.ts +18 -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;
|
|
@@ -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
|
|
@@ -97,6 +103,7 @@ export class AtpAgent {
|
|
|
97
103
|
email: opts.email,
|
|
98
104
|
emailConfirmed: false,
|
|
99
105
|
}
|
|
106
|
+
this._updateApiEndpoint(res.data.didDoc)
|
|
100
107
|
return res
|
|
101
108
|
} catch (e) {
|
|
102
109
|
this.session = undefined
|
|
@@ -129,6 +136,7 @@ export class AtpAgent {
|
|
|
129
136
|
email: res.data.email,
|
|
130
137
|
emailConfirmed: res.data.emailConfirmed,
|
|
131
138
|
}
|
|
139
|
+
this._updateApiEndpoint(res.data.didDoc)
|
|
132
140
|
return res
|
|
133
141
|
} catch (e) {
|
|
134
142
|
this.session = undefined
|
|
@@ -253,7 +261,7 @@ export class AtpAgent {
|
|
|
253
261
|
}
|
|
254
262
|
|
|
255
263
|
// send the refresh request
|
|
256
|
-
const url = new URL(this.service.origin)
|
|
264
|
+
const url = new URL((this.pdsUrl || this.service).origin)
|
|
257
265
|
url.pathname = `/xrpc/${REFRESH_SESSION}`
|
|
258
266
|
const res = await AtpAgent.fetch(
|
|
259
267
|
url.toString(),
|
|
@@ -277,6 +285,7 @@ export class AtpAgent {
|
|
|
277
285
|
handle: res.body.handle,
|
|
278
286
|
did: res.body.did,
|
|
279
287
|
}
|
|
288
|
+
this._updateApiEndpoint(res.body.didDoc)
|
|
280
289
|
this._persistSession?.('update', this.session)
|
|
281
290
|
}
|
|
282
291
|
// else: other failures should be ignored - the issue will
|
|
@@ -311,6 +320,24 @@ export class AtpAgent {
|
|
|
311
320
|
*/
|
|
312
321
|
createModerationReport: typeof this.api.com.atproto.moderation.createReport =
|
|
313
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
|
+
}
|
|
314
341
|
}
|
|
315
342
|
|
|
316
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
|
@@ -59,6 +59,7 @@ import * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/serve
|
|
|
59
59
|
import * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
60
60
|
import * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
61
61
|
import * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
62
|
+
import * as ComAtprotoServerReserveSigningKey from './types/com/atproto/server/reserveSigningKey'
|
|
62
63
|
import * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
63
64
|
import * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
64
65
|
import * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
@@ -192,6 +193,7 @@ export * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/serve
|
|
|
192
193
|
export * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
|
|
193
194
|
export * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
|
|
194
195
|
export * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
|
|
196
|
+
export * as ComAtprotoServerReserveSigningKey from './types/com/atproto/server/reserveSigningKey'
|
|
195
197
|
export * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
|
|
196
198
|
export * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
|
|
197
199
|
export * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
|
|
@@ -907,6 +909,17 @@ export class ServerNS {
|
|
|
907
909
|
})
|
|
908
910
|
}
|
|
909
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
|
+
|
|
910
923
|
resetPassword(
|
|
911
924
|
data?: ComAtprotoServerResetPassword.InputSchema,
|
|
912
925
|
opts?: ComAtprotoServerResetPassword.CallOptions,
|
package/src/client/lexicons.ts
CHANGED
|
@@ -2315,6 +2315,9 @@ export const schemaDict = {
|
|
|
2315
2315
|
recoveryKey: {
|
|
2316
2316
|
type: 'string',
|
|
2317
2317
|
},
|
|
2318
|
+
plcOp: {
|
|
2319
|
+
type: 'bytes',
|
|
2320
|
+
},
|
|
2318
2321
|
},
|
|
2319
2322
|
},
|
|
2320
2323
|
},
|
|
@@ -2338,6 +2341,9 @@ export const schemaDict = {
|
|
|
2338
2341
|
type: 'string',
|
|
2339
2342
|
format: 'did',
|
|
2340
2343
|
},
|
|
2344
|
+
didDoc: {
|
|
2345
|
+
type: 'unknown',
|
|
2346
|
+
},
|
|
2341
2347
|
},
|
|
2342
2348
|
},
|
|
2343
2349
|
},
|
|
@@ -2563,6 +2569,9 @@ export const schemaDict = {
|
|
|
2563
2569
|
type: 'string',
|
|
2564
2570
|
format: 'did',
|
|
2565
2571
|
},
|
|
2572
|
+
didDoc: {
|
|
2573
|
+
type: 'unknown',
|
|
2574
|
+
},
|
|
2566
2575
|
email: {
|
|
2567
2576
|
type: 'string',
|
|
2568
2577
|
},
|
|
@@ -2879,6 +2888,9 @@ export const schemaDict = {
|
|
|
2879
2888
|
type: 'string',
|
|
2880
2889
|
format: 'did',
|
|
2881
2890
|
},
|
|
2891
|
+
didDoc: {
|
|
2892
|
+
type: 'unknown',
|
|
2893
|
+
},
|
|
2882
2894
|
},
|
|
2883
2895
|
},
|
|
2884
2896
|
},
|
|
@@ -2955,6 +2967,29 @@ export const schemaDict = {
|
|
|
2955
2967
|
},
|
|
2956
2968
|
},
|
|
2957
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
|
+
},
|
|
2958
2993
|
ComAtprotoServerResetPassword: {
|
|
2959
2994
|
lexicon: 1,
|
|
2960
2995
|
id: 'com.atproto.server.resetPassword',
|
|
@@ -3376,7 +3411,7 @@ export const schemaDict = {
|
|
|
3376
3411
|
},
|
|
3377
3412
|
repo: {
|
|
3378
3413
|
type: 'object',
|
|
3379
|
-
required: ['did', 'head'],
|
|
3414
|
+
required: ['did', 'head', 'rev'],
|
|
3380
3415
|
properties: {
|
|
3381
3416
|
did: {
|
|
3382
3417
|
type: 'string',
|
|
@@ -3386,6 +3421,9 @@ export const schemaDict = {
|
|
|
3386
3421
|
type: 'string',
|
|
3387
3422
|
format: 'cid',
|
|
3388
3423
|
},
|
|
3424
|
+
rev: {
|
|
3425
|
+
type: 'string',
|
|
3426
|
+
},
|
|
3389
3427
|
},
|
|
3390
3428
|
},
|
|
3391
3429
|
},
|
|
@@ -3789,6 +3827,10 @@ export const schemaDict = {
|
|
|
3789
3827
|
type: 'string',
|
|
3790
3828
|
format: 'at-uri',
|
|
3791
3829
|
},
|
|
3830
|
+
blockingByList: {
|
|
3831
|
+
type: 'ref',
|
|
3832
|
+
ref: 'lex:app.bsky.graph.defs#listViewBasic',
|
|
3833
|
+
},
|
|
3792
3834
|
following: {
|
|
3793
3835
|
type: 'string',
|
|
3794
3836
|
format: 'at-uri',
|
|
@@ -7379,6 +7421,7 @@ export const ids = {
|
|
|
7379
7421
|
ComAtprotoServerRequestEmailUpdate: 'com.atproto.server.requestEmailUpdate',
|
|
7380
7422
|
ComAtprotoServerRequestPasswordReset:
|
|
7381
7423
|
'com.atproto.server.requestPasswordReset',
|
|
7424
|
+
ComAtprotoServerReserveSigningKey: 'com.atproto.server.reserveSigningKey',
|
|
7382
7425
|
ComAtprotoServerResetPassword: 'com.atproto.server.resetPassword',
|
|
7383
7426
|
ComAtprotoServerRevokeAppPassword: 'com.atproto.server.revokeAppPassword',
|
|
7384
7427
|
ComAtprotoServerUpdateEmail: 'com.atproto.server.updateEmail',
|
|
@@ -16,6 +16,7 @@ export interface InputSchema {
|
|
|
16
16
|
inviteCode?: string
|
|
17
17
|
password: string
|
|
18
18
|
recoveryKey?: string
|
|
19
|
+
plcOp?: Uint8Array
|
|
19
20
|
[k: string]: unknown
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -24,6 +25,7 @@ export interface OutputSchema {
|
|
|
24
25
|
refreshJwt: string
|
|
25
26
|
handle: string
|
|
26
27
|
did: string
|
|
28
|
+
didDoc?: {}
|
|
27
29
|
[k: string]: unknown
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -0,0 +1,35 @@
|
|
|
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 type InputSchema = undefined
|
|
13
|
+
|
|
14
|
+
export interface OutputSchema {
|
|
15
|
+
/** Public signing key in the form of a did:key. */
|
|
16
|
+
signingKey: string
|
|
17
|
+
[k: string]: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CallOptions {
|
|
21
|
+
headers?: Headers
|
|
22
|
+
qp?: QueryParams
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Response {
|
|
26
|
+
success: boolean
|
|
27
|
+
headers: Headers
|
|
28
|
+
data: OutputSchema
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function toKnownErr(e: any) {
|
|
32
|
+
if (e instanceof XRPCError) {
|
|
33
|
+
}
|
|
34
|
+
return e
|
|
35
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AppBskyGraphDefs } from '../client/index'
|
|
2
|
+
import { AtUri } from '@atproto/syntax'
|
|
2
3
|
import {
|
|
3
4
|
Label,
|
|
4
5
|
LabelPreference,
|
|
@@ -28,6 +29,18 @@ export class ModerationCauseAccumulator {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
addBlockingByList(
|
|
33
|
+
blockingByList: AppBskyGraphDefs.ListViewBasic | undefined,
|
|
34
|
+
) {
|
|
35
|
+
if (blockingByList) {
|
|
36
|
+
this.causes.push({
|
|
37
|
+
type: 'blocking',
|
|
38
|
+
source: { type: 'list', list: blockingByList },
|
|
39
|
+
priority: 3,
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
addBlockedBy(blockedBy: boolean | undefined) {
|
|
32
45
|
if (blockedBy) {
|
|
33
46
|
this.causes.push({
|
|
@@ -20,7 +20,13 @@ export function decideAccount(
|
|
|
20
20
|
acc.addMuted(subject.viewer?.muted)
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
if (subject.viewer?.blocking) {
|
|
24
|
+
if (subject.viewer?.blockingByList) {
|
|
25
|
+
acc.addBlockingByList(subject.viewer?.blockingByList)
|
|
26
|
+
} else {
|
|
27
|
+
acc.addBlocking(subject.viewer?.blocking)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
24
30
|
acc.addBlockedBy(subject.viewer?.blockedBy)
|
|
25
31
|
|
|
26
32
|
for (const label of filterAccountLabels(subject.labels)) {
|
package/tests/agent.test.ts
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { defaultFetchHandler } from '@atproto/xrpc'
|
|
2
|
-
import {
|
|
3
|
-
CloseFn,
|
|
4
|
-
runTestServer,
|
|
5
|
-
TestServerInfo,
|
|
6
|
-
} from '@atproto/pds/tests/_util'
|
|
7
2
|
import {
|
|
8
3
|
AtpAgent,
|
|
9
4
|
AtpAgentFetchHandlerResponse,
|
|
10
5
|
AtpSessionEvent,
|
|
11
6
|
AtpSessionData,
|
|
12
7
|
} from '..'
|
|
8
|
+
import { TestNetworkNoAppView } from '@atproto/dev-env'
|
|
13
9
|
|
|
14
10
|
describe('agent', () => {
|
|
15
|
-
let
|
|
16
|
-
let close: CloseFn
|
|
11
|
+
let network: TestNetworkNoAppView
|
|
17
12
|
|
|
18
13
|
beforeAll(async () => {
|
|
19
|
-
|
|
14
|
+
network = await TestNetworkNoAppView.create({
|
|
20
15
|
dbPostgresSchema: 'api_agent',
|
|
16
|
+
pds: {
|
|
17
|
+
enableDidDocWithSession: true,
|
|
18
|
+
},
|
|
21
19
|
})
|
|
22
|
-
close = server.close
|
|
23
20
|
})
|
|
24
21
|
|
|
25
22
|
afterAll(async () => {
|
|
26
|
-
await close()
|
|
23
|
+
await network.close()
|
|
27
24
|
})
|
|
28
25
|
|
|
29
26
|
it('creates a new session on account creation.', async () => {
|
|
@@ -34,7 +31,7 @@ describe('agent', () => {
|
|
|
34
31
|
sessions.push(sess)
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
const agent = new AtpAgent({ service:
|
|
34
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
38
35
|
|
|
39
36
|
const res = await agent.createAccount({
|
|
40
37
|
handle: 'user1.test',
|
|
@@ -74,7 +71,7 @@ describe('agent', () => {
|
|
|
74
71
|
sessions.push(sess)
|
|
75
72
|
}
|
|
76
73
|
|
|
77
|
-
const agent1 = new AtpAgent({ service:
|
|
74
|
+
const agent1 = new AtpAgent({ service: network.pds.url, persistSession })
|
|
78
75
|
|
|
79
76
|
const email = 'user2@test.com'
|
|
80
77
|
await agent1.createAccount({
|
|
@@ -83,7 +80,7 @@ describe('agent', () => {
|
|
|
83
80
|
password: 'password',
|
|
84
81
|
})
|
|
85
82
|
|
|
86
|
-
const agent2 = new AtpAgent({ service:
|
|
83
|
+
const agent2 = new AtpAgent({ service: network.pds.url, persistSession })
|
|
87
84
|
const res1 = await agent2.login({
|
|
88
85
|
identifier: 'user2.test',
|
|
89
86
|
password: 'password',
|
|
@@ -122,7 +119,7 @@ describe('agent', () => {
|
|
|
122
119
|
sessions.push(sess)
|
|
123
120
|
}
|
|
124
121
|
|
|
125
|
-
const agent1 = new AtpAgent({ service:
|
|
122
|
+
const agent1 = new AtpAgent({ service: network.pds.url, persistSession })
|
|
126
123
|
|
|
127
124
|
await agent1.createAccount({
|
|
128
125
|
handle: 'user3.test',
|
|
@@ -133,7 +130,7 @@ describe('agent', () => {
|
|
|
133
130
|
throw new Error('No session created')
|
|
134
131
|
}
|
|
135
132
|
|
|
136
|
-
const agent2 = new AtpAgent({ service:
|
|
133
|
+
const agent2 = new AtpAgent({ service: network.pds.url, persistSession })
|
|
137
134
|
const res1 = await agent2.resumeSession(agent1.session)
|
|
138
135
|
|
|
139
136
|
expect(agent2.hasSession).toEqual(true)
|
|
@@ -165,7 +162,7 @@ describe('agent', () => {
|
|
|
165
162
|
sessions.push(sess)
|
|
166
163
|
}
|
|
167
164
|
|
|
168
|
-
const agent = new AtpAgent({ service:
|
|
165
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
169
166
|
|
|
170
167
|
// create an account and a session with it
|
|
171
168
|
await agent.createAccount({
|
|
@@ -230,7 +227,7 @@ describe('agent', () => {
|
|
|
230
227
|
sessions.push(sess)
|
|
231
228
|
}
|
|
232
229
|
|
|
233
|
-
const agent = new AtpAgent({ service:
|
|
230
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
234
231
|
|
|
235
232
|
// create an account and a session with it
|
|
236
233
|
await agent.createAccount({
|
|
@@ -309,7 +306,7 @@ describe('agent', () => {
|
|
|
309
306
|
sessions.push(sess)
|
|
310
307
|
}
|
|
311
308
|
|
|
312
|
-
const agent = new AtpAgent({ service:
|
|
309
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
313
310
|
|
|
314
311
|
try {
|
|
315
312
|
await agent.login({
|
|
@@ -349,7 +346,7 @@ describe('agent', () => {
|
|
|
349
346
|
sessions.push(sess)
|
|
350
347
|
}
|
|
351
348
|
|
|
352
|
-
const agent = new AtpAgent({ service:
|
|
349
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
353
350
|
|
|
354
351
|
// create an account and a session with it
|
|
355
352
|
await agent.createAccount({
|
|
@@ -420,7 +417,7 @@ describe('agent', () => {
|
|
|
420
417
|
newHandlerCallCount++
|
|
421
418
|
}
|
|
422
419
|
|
|
423
|
-
const agent = new AtpAgent({ service:
|
|
420
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
424
421
|
|
|
425
422
|
await agent.createAccount({
|
|
426
423
|
handle: 'user7.test',
|
|
@@ -452,7 +449,7 @@ describe('agent', () => {
|
|
|
452
449
|
sessions.push(sess)
|
|
453
450
|
}
|
|
454
451
|
|
|
455
|
-
const agent = new AtpAgent({ service:
|
|
452
|
+
const agent = new AtpAgent({ service: network.pds.url, persistSession })
|
|
456
453
|
|
|
457
454
|
await expect(
|
|
458
455
|
agent.createAccount({
|