@atproto/api 0.6.10 → 0.6.11
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/LICENSE +21 -0
- package/README.md +45 -36
- package/bench/agent.bench.ts +2 -2
- package/build.js +0 -8
- package/definitions/labels.json +7 -1
- package/definitions/locale/en/label-groups.json +1 -1
- package/definitions/locale/en/labels.json +15 -1
- package/definitions/locale/en/proposed-label-groups.json +1 -1
- package/definitions/locale/en/proposed-labels.json +1 -1
- package/definitions/post-moderation-behaviors.json +315 -231
- package/definitions/profile-moderation-behaviors.json +188 -117
- package/definitions/proposed-labels.json +1 -1
- package/dist/client/lexicons.d.ts +33 -0
- package/dist/client/types/app/bsky/actor/createScene.d.ts +32 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts +7 -1
- package/dist/client/types/app/bsky/actor/ref.d.ts +28 -0
- package/dist/client/types/app/bsky/actor/search.d.ts +22 -0
- package/dist/client/types/app/bsky/actor/searchTypeahead.d.ts +20 -0
- package/dist/client/types/app/bsky/actor/updateProfile.d.ts +40 -0
- package/dist/client/types/app/bsky/embed/images.d.ts +9 -0
- package/dist/client/types/app/bsky/feed/feedViewPost.d.ts +28 -0
- package/dist/client/types/app/bsky/feed/getVotes.d.ts +36 -0
- package/dist/client/types/app/bsky/feed/saveFeed.d.ts +17 -0
- package/dist/client/types/app/bsky/feed/setVote.d.ts +25 -0
- package/dist/client/types/app/bsky/feed/trend.d.ts +9 -0
- package/dist/client/types/app/bsky/feed/unsaveFeed.d.ts +17 -0
- package/dist/client/types/app/bsky/feed/vote.d.ts +10 -0
- package/dist/client/types/app/bsky/graph/assertCreator.d.ts +1 -0
- package/dist/client/types/app/bsky/graph/assertMember.d.ts +1 -0
- package/dist/client/types/app/bsky/graph/assertion.d.ts +10 -0
- package/dist/client/types/app/bsky/graph/confirmation.d.ts +11 -0
- package/dist/client/types/app/bsky/graph/getAssertions.d.ts +48 -0
- package/dist/client/types/app/bsky/{actor/getFeedSuggestions.d.ts → graph/getListBlocks.d.ts} +2 -2
- package/dist/client/types/app/bsky/graph/getMembers.d.ts +36 -0
- package/dist/client/types/app/bsky/graph/getMemberships.d.ts +36 -0
- package/dist/client/types/app/bsky/graph/listblock.d.ts +8 -0
- package/dist/client/types/app/bsky/graph/mute.d.ts +17 -0
- package/dist/client/types/app/bsky/graph/subscribeMuteList.d.ts +17 -0
- package/dist/client/types/app/bsky/graph/unmute.d.ts +17 -0
- package/dist/client/types/app/bsky/graph/unsubscribeMuteList.d.ts +17 -0
- package/dist/client/types/app/bsky/notification/getCount.d.ts +17 -0
- package/dist/client/types/app/bsky/notification/list.d.ts +35 -0
- package/dist/client/types/app/bsky/system/actorScene.d.ts +1 -0
- package/dist/client/types/app/bsky/system/actorUser.d.ts +1 -0
- package/dist/client/types/app/bsky/system/declRef.d.ts +8 -0
- package/dist/client/types/app/bsky/system/declaration.d.ts +7 -0
- package/dist/client/types/app/bsky/unspecced/registerPushNotification.d.ts +16 -0
- package/dist/client/types/com/atproto/account/create.d.ts +41 -0
- package/dist/client/types/com/atproto/account/createInviteCode.d.ts +22 -0
- package/dist/client/types/com/atproto/account/delete.d.ts +25 -0
- package/dist/client/types/com/atproto/account/get.d.ts +12 -0
- package/dist/client/types/com/atproto/account/requestDelete.d.ts +13 -0
- package/dist/client/types/com/atproto/account/requestPasswordReset.d.ts +17 -0
- package/dist/client/types/com/atproto/account/resetPassword.d.ts +24 -0
- package/dist/client/types/com/atproto/admin/blob.d.ts +37 -0
- package/dist/client/types/com/atproto/admin/moderationAction.d.ts +60 -0
- package/dist/client/types/com/atproto/admin/moderationReport.d.ts +37 -0
- package/dist/client/types/com/atproto/admin/rebaseRepo.d.ts +24 -0
- package/dist/client/types/com/atproto/admin/record.d.ts +43 -0
- package/dist/client/types/com/atproto/admin/repo.d.ts +45 -0
- package/dist/client/types/com/atproto/blob/upload.d.ts +19 -0
- package/dist/client/types/com/atproto/handle/resolve.d.ts +18 -0
- package/dist/client/types/com/atproto/handle/update.d.ts +17 -0
- package/dist/client/types/com/atproto/repo/batchWrite.d.ts +46 -0
- package/dist/client/types/com/atproto/repo/describe.d.ts +22 -0
- package/dist/client/types/com/atproto/repo/rebaseRepo.d.ts +24 -0
- package/dist/client/types/com/atproto/repo/recordRef.d.ts +8 -0
- package/dist/client/types/com/atproto/repo/repoRef.d.ts +7 -0
- package/dist/client/types/com/atproto/report/create.d.ts +39 -0
- package/dist/client/types/com/atproto/report/reasonType.d.ts +3 -0
- package/dist/client/types/com/atproto/report/subject.d.ts +23 -0
- package/dist/client/types/com/atproto/server/getAccountsConfig.d.ts +27 -0
- package/dist/client/types/com/atproto/session/create.d.ts +29 -0
- package/dist/client/types/com/atproto/session/delete.d.ts +13 -0
- package/dist/client/types/com/atproto/session/get.d.ts +18 -0
- package/dist/client/types/com/atproto/session/refresh.d.ts +24 -0
- package/dist/client/types/com/atproto/sync/getCommitPath.d.ts +20 -0
- package/dist/client/types/com/atproto/sync/getRoot.d.ts +18 -0
- package/dist/client/types/com/atproto/sync/subscribeAllRepos.d.ts +9 -0
- package/dist/client/types/com/atproto/sync/updateRepo.d.ts +15 -0
- package/dist/helpers/bsky.d.ts +20 -0
- package/dist/index.js +941 -1137
- package/dist/index.js.map +4 -4
- package/dist/mixins/bsky.d.ts +23 -0
- package/dist/rich-text/sanitize.d.ts +4 -0
- package/dist/session.d.ts +42 -0
- package/docs/labels.md +43 -27
- package/docs/moderation-behaviors/posts.md +13 -516
- package/docs/moderation-behaviors/profiles.md +14 -174
- package/docs/moderation.md +3 -3
- package/package.json +23 -23
- package/src/client/lexicons.ts +35 -0
- package/src/client/types/app/bsky/actor/defs.ts +19 -0
- package/src/client/types/app/bsky/embed/images.ts +21 -0
- package/src/moderation/const/label-groups.ts +1 -0
- package/src/moderation/const/labels.ts +30 -0
- package/tsconfig.build.json +1 -1
- package/update-pkg.js +0 -14
- /package/dist/client/types/app/bsky/feed/{getFeedSuggestions.d.ts → getSavedFeeds.d.ts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2023 Bluesky PBLLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -34,16 +34,16 @@ import { BskyAgent, AtpSessionEvent, AtpSessionData } from '@atproto/api'
|
|
|
34
34
|
const agent = new BskyAgent({
|
|
35
35
|
service: 'https://example.com',
|
|
36
36
|
persistSession: (evt: AtpSessionEvent, sess?: AtpSessionData) => {
|
|
37
|
-
// store the session-data for reuse
|
|
38
|
-
}
|
|
37
|
+
// store the session-data for reuse
|
|
38
|
+
},
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
await agent.login({identifier: 'alice@mail.com', password: 'hunter2'})
|
|
41
|
+
await agent.login({ identifier: 'alice@mail.com', password: 'hunter2' })
|
|
42
42
|
await agent.resumeSession(savedSessionData)
|
|
43
43
|
await agent.createAccount({
|
|
44
44
|
email: 'alice@mail.com',
|
|
45
45
|
password: 'hunter2',
|
|
46
|
-
handle: 'alice.example.com'
|
|
46
|
+
handle: 'alice.example.com',
|
|
47
47
|
})
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -127,16 +127,18 @@ Some records (ie posts) use the `app.bsky.richtext` lexicon. At the moment richt
|
|
|
127
127
|
ℹ️ It is **strongly** recommended to use this package's `RichText` library. Javascript encodes strings in utf16 while the protocol (and most other programming environments) use utf8. Converting between the two is challenging, but `RichText` handles that for you.
|
|
128
128
|
|
|
129
129
|
```typescript
|
|
130
|
-
import {RichText} from '@atproto/api'
|
|
130
|
+
import { RichText } from '@atproto/api'
|
|
131
131
|
|
|
132
132
|
// creating richtext
|
|
133
|
-
const rt = new RichText({
|
|
133
|
+
const rt = new RichText({
|
|
134
|
+
text: 'Hello @alice.com, check out this link: https://example.com',
|
|
135
|
+
})
|
|
134
136
|
await rt.detectFacets(agent) // automatically detects mentions and links
|
|
135
137
|
const postRecord = {
|
|
136
138
|
$type: 'app.bsky.feed.post',
|
|
137
139
|
text: rt.text,
|
|
138
140
|
facets: rt.facets,
|
|
139
|
-
createdAt: new Date().toISOString()
|
|
141
|
+
createdAt: new Date().toISOString(),
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
// rendering as markdown
|
|
@@ -152,10 +154,10 @@ for (const segment of rt.segments()) {
|
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
// calculating string lengths
|
|
155
|
-
const rt2 = new RichText({text: 'Hello'})
|
|
157
|
+
const rt2 = new RichText({ text: 'Hello' })
|
|
156
158
|
console.log(rt2.length) // => 5
|
|
157
159
|
console.log(rt2.graphemeLength) // => 5
|
|
158
|
-
const rt3 = new RichText({text: '👨👩👧👧'})
|
|
160
|
+
const rt3 = new RichText({ text: '👨👩👧👧' })
|
|
159
161
|
console.log(rt3.length) // => 25
|
|
160
162
|
console.log(rt3.graphemeLength) // => 1
|
|
161
163
|
```
|
|
@@ -171,12 +173,12 @@ Applying the moderation system is a challenging task, but we've done our best to
|
|
|
171
173
|
For more information, see the [Moderation Documentation](./docs/moderation.md) or the associated [Labels Reference](./docs/labels.md).
|
|
172
174
|
|
|
173
175
|
```typescript
|
|
174
|
-
import {moderatePost, moderateProfile} from '@atproto/api'
|
|
176
|
+
import { moderatePost, moderateProfile } from '@atproto/api'
|
|
175
177
|
|
|
176
178
|
// We call the appropriate moderation function for the content
|
|
177
179
|
// =
|
|
178
180
|
|
|
179
|
-
const postMod
|
|
181
|
+
const postMod = moderatePost(postView, getOpts())
|
|
180
182
|
const profileMod = moderateProfile(profileView, getOpts())
|
|
181
183
|
|
|
182
184
|
// We then use the output to decide how to affect rendering
|
|
@@ -235,16 +237,16 @@ function getOpts() {
|
|
|
235
237
|
{
|
|
236
238
|
labeler: {
|
|
237
239
|
did: '...',
|
|
238
|
-
displayName: 'My mod service'
|
|
240
|
+
displayName: 'My mod service',
|
|
239
241
|
},
|
|
240
242
|
labels: {
|
|
241
243
|
porn: 'hide',
|
|
242
244
|
sexual: 'warn',
|
|
243
245
|
nudity: 'ignore',
|
|
244
246
|
// ...
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
]
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
],
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
```
|
|
@@ -258,24 +260,28 @@ The methods above are convenience wrappers. It covers most but not all available
|
|
|
258
260
|
The AT Protocol identifies methods and records with reverse-DNS names. You can use them on the agent as well:
|
|
259
261
|
|
|
260
262
|
```typescript
|
|
261
|
-
const res1 = await agent.com.atproto.repo.createRecord(
|
|
263
|
+
const res1 = await agent.com.atproto.repo.createRecord({
|
|
264
|
+
did: alice.did,
|
|
265
|
+
collection: 'app.bsky.feed.post',
|
|
266
|
+
record: {
|
|
267
|
+
$type: 'app.bsky.feed.post',
|
|
268
|
+
text: 'Hello, world!',
|
|
269
|
+
createdAt: new Date().toISOString(),
|
|
270
|
+
},
|
|
271
|
+
})
|
|
272
|
+
const res2 = await agent.com.atproto.repo.listRecords({
|
|
273
|
+
repo: alice.did,
|
|
274
|
+
collection: 'app.bsky.feed.post',
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
const res3 = await agent.app.bsky.feed.post.create(
|
|
278
|
+
{ repo: alice.did },
|
|
262
279
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
$type: 'app.bsky.feed.post',
|
|
267
|
-
text: 'Hello, world!',
|
|
268
|
-
createdAt: new Date().toISOString()
|
|
269
|
-
}
|
|
270
|
-
}
|
|
280
|
+
text: 'Hello, world!',
|
|
281
|
+
createdAt: new Date().toISOString(),
|
|
282
|
+
},
|
|
271
283
|
)
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
const res3 = await agent.app.bsky.feed.post.create({repo: alice.did}, {
|
|
275
|
-
text: 'Hello, world!',
|
|
276
|
-
createdAt: new Date().toISOString()
|
|
277
|
-
})
|
|
278
|
-
const res4 = await agent.app.bsky.feed.post.list({repo: alice.did})
|
|
284
|
+
const res4 = await agent.app.bsky.feed.post.list({ repo: alice.did })
|
|
279
285
|
```
|
|
280
286
|
|
|
281
287
|
### Generic agent
|
|
@@ -285,7 +291,7 @@ If you want a generic AT Protocol agent without methods related to the Bluesky s
|
|
|
285
291
|
```typescript
|
|
286
292
|
import { AtpAgent } from '@atproto/api'
|
|
287
293
|
|
|
288
|
-
const agent = new AtpAgent({service: 'https://example.com'})
|
|
294
|
+
const agent = new AtpAgent({ service: 'https://example.com' })
|
|
289
295
|
```
|
|
290
296
|
|
|
291
297
|
### Non-browser configuration
|
|
@@ -295,10 +301,13 @@ In non-browser environments you'll need to specify a fetch polyfill. [See the ex
|
|
|
295
301
|
```typescript
|
|
296
302
|
import { BskyAgent } from '@atproto/api'
|
|
297
303
|
|
|
298
|
-
const agent = new BskyAgent({service: 'https://example.com'})
|
|
304
|
+
const agent = new BskyAgent({ service: 'https://example.com' })
|
|
299
305
|
|
|
300
306
|
// provide a custom fetch implementation (shouldnt be needed in node or the browser)
|
|
301
|
-
import {
|
|
307
|
+
import {
|
|
308
|
+
AtpAgentFetchHeaders,
|
|
309
|
+
AtpAgentFetchHandlerResponse,
|
|
310
|
+
} from '@atproto/api'
|
|
302
311
|
BskyAgent.configure({
|
|
303
312
|
async fetch(
|
|
304
313
|
httpUri: string,
|
|
@@ -307,8 +316,8 @@ BskyAgent.configure({
|
|
|
307
316
|
httpReqBody: any,
|
|
308
317
|
): Promise<AtpAgentFetchHandlerResponse> {
|
|
309
318
|
// insert definition here...
|
|
310
|
-
return {status: 200
|
|
311
|
-
}
|
|
319
|
+
return { status: 200 /*...*/ }
|
|
320
|
+
},
|
|
312
321
|
})
|
|
313
322
|
```
|
|
314
323
|
|
package/bench/agent.bench.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BskyAgent } from
|
|
1
|
+
import { BskyAgent } from '@atproto/api'
|
|
2
2
|
|
|
3
3
|
describe('Agent Benchmarks', () => {
|
|
4
4
|
it('Creates new Agent instance 10 times', () => {
|
|
5
5
|
for (let i = 0; i < 10; i++) {
|
|
6
|
-
new BskyAgent({ service: 'https://bsky.social' })
|
|
6
|
+
new BskyAgent({ service: 'https://bsky.social' })
|
|
7
7
|
}
|
|
8
8
|
})
|
|
9
9
|
})
|
package/build.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
const pkgJson = require('@npmcli/package-json')
|
|
2
1
|
const { nodeExternalsPlugin } = require('esbuild-node-externals')
|
|
3
2
|
|
|
4
3
|
const buildShallow =
|
|
5
4
|
process.argv.includes('--shallow') || process.env.ATP_BUILD_SHALLOW === 'true'
|
|
6
5
|
|
|
7
|
-
if (process.argv.includes('--update-main-to-dist')) {
|
|
8
|
-
return pkgJson
|
|
9
|
-
.load(__dirname)
|
|
10
|
-
.then((pkg) => pkg.update({ main: 'dist/index.js' }))
|
|
11
|
-
.then((pkg) => pkg.save())
|
|
12
|
-
}
|
|
13
|
-
|
|
14
6
|
require('esbuild').build({
|
|
15
7
|
logLevel: 'info',
|
|
16
8
|
entryPoints: ['src/index.ts'],
|
package/definitions/labels.json
CHANGED
|
@@ -362,5 +362,19 @@
|
|
|
362
362
|
"name": "Scam Warning",
|
|
363
363
|
"description": "The moderators believe this is fraudulent content."
|
|
364
364
|
}
|
|
365
|
+
},
|
|
366
|
+
"misleading": {
|
|
367
|
+
"settings": {
|
|
368
|
+
"name": "Misleading",
|
|
369
|
+
"description": "Accounts which share misleading information."
|
|
370
|
+
},
|
|
371
|
+
"account": {
|
|
372
|
+
"name": "Misleading",
|
|
373
|
+
"description": "The moderators believe this account is spreading misleading information."
|
|
374
|
+
},
|
|
375
|
+
"content": {
|
|
376
|
+
"name": "Misleading",
|
|
377
|
+
"description": "The moderators believe this account is spreading misleading information."
|
|
378
|
+
}
|
|
365
379
|
}
|
|
366
|
-
}
|
|
380
|
+
}
|