@atproto/bsky 0.0.92 → 0.0.93
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/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.js +4 -3
- package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
- package/dist/auth-verifier.d.ts +2 -0
- package/dist/auth-verifier.d.ts.map +1 -1
- package/dist/auth-verifier.js +25 -4
- package/dist/auth-verifier.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/hydration/actor.d.ts +1 -0
- package/dist/hydration/actor.d.ts.map +1 -1
- package/dist/hydration/actor.js +1 -0
- package/dist/hydration/actor.js.map +1 -1
- package/dist/hydration/hydrator.d.ts.map +1 -1
- package/dist/hydration/hydrator.js +1 -0
- package/dist/hydration/hydrator.js.map +1 -1
- package/dist/hydration/util.d.ts +1 -0
- package/dist/hydration/util.d.ts.map +1 -1
- package/dist/hydration/util.js +2 -0
- package/dist/hydration/util.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/lexicon/lexicons.js +3 -3
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/views/index.d.ts +11 -1
- package/dist/views/index.d.ts.map +1 -1
- package/dist/views/index.js +36 -13
- package/dist/views/index.js.map +1 -1
- package/package.json +10 -10
- package/src/api/app/bsky/feed/getFeed.ts +5 -3
- package/src/auth-verifier.ts +56 -2
- package/src/config.ts +13 -0
- package/src/hydration/actor.ts +2 -0
- package/src/hydration/hydrator.ts +1 -0
- package/src/hydration/util.ts +3 -0
- package/src/index.ts +5 -1
- package/src/lexicon/lexicons.ts +3 -3
- package/src/views/index.ts +30 -12
- package/tests/auth.test.ts +26 -0
package/src/lexicon/lexicons.ts
CHANGED
|
@@ -1341,7 +1341,7 @@ export const schemaDict = {
|
|
|
1341
1341
|
},
|
|
1342
1342
|
rkey: {
|
|
1343
1343
|
type: 'string',
|
|
1344
|
-
maxLength:
|
|
1344
|
+
maxLength: 512,
|
|
1345
1345
|
},
|
|
1346
1346
|
value: {
|
|
1347
1347
|
type: 'unknown',
|
|
@@ -1450,7 +1450,7 @@ export const schemaDict = {
|
|
|
1450
1450
|
rkey: {
|
|
1451
1451
|
type: 'string',
|
|
1452
1452
|
description: 'The Record Key.',
|
|
1453
|
-
maxLength:
|
|
1453
|
+
maxLength: 512,
|
|
1454
1454
|
},
|
|
1455
1455
|
validate: {
|
|
1456
1456
|
type: 'boolean',
|
|
@@ -1901,7 +1901,7 @@ export const schemaDict = {
|
|
|
1901
1901
|
rkey: {
|
|
1902
1902
|
type: 'string',
|
|
1903
1903
|
description: 'The Record Key.',
|
|
1904
|
-
maxLength:
|
|
1904
|
+
maxLength: 512,
|
|
1905
1905
|
},
|
|
1906
1906
|
validate: {
|
|
1907
1907
|
type: 'boolean',
|
package/src/views/index.ts
CHANGED
|
@@ -75,9 +75,15 @@ import { Notification } from '../proto/bsky_pb'
|
|
|
75
75
|
import { postUriToThreadgateUri, postUriToPostgateUri } from '../util/uris'
|
|
76
76
|
|
|
77
77
|
export class Views {
|
|
78
|
+
public imgUriBuilder: ImageUriBuilder = this.opts.imgUriBuilder
|
|
79
|
+
public videoUriBuilder: VideoUriBuilder = this.opts.videoUriBuilder
|
|
80
|
+
public indexedAtEpoch: Date | undefined = this.opts.indexedAtEpoch
|
|
78
81
|
constructor(
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
private opts: {
|
|
83
|
+
imgUriBuilder: ImageUriBuilder
|
|
84
|
+
videoUriBuilder: VideoUriBuilder
|
|
85
|
+
indexedAtEpoch: Date | undefined
|
|
86
|
+
},
|
|
81
87
|
) {}
|
|
82
88
|
|
|
83
89
|
// Actor
|
|
@@ -182,7 +188,13 @@ export class Views {
|
|
|
182
188
|
return {
|
|
183
189
|
...basicView,
|
|
184
190
|
description: actor.profile?.description || undefined,
|
|
185
|
-
indexedAt:
|
|
191
|
+
indexedAt:
|
|
192
|
+
actor.indexedAt && actor.sortedAt
|
|
193
|
+
? this.indexedAt({
|
|
194
|
+
sortedAt: actor.sortedAt,
|
|
195
|
+
indexedAt: actor.indexedAt,
|
|
196
|
+
}).toISOString()
|
|
197
|
+
: undefined,
|
|
186
198
|
}
|
|
187
199
|
}
|
|
188
200
|
|
|
@@ -330,7 +342,7 @@ export class Views {
|
|
|
330
342
|
creator,
|
|
331
343
|
description: list.record.description,
|
|
332
344
|
descriptionFacets: list.record.descriptionFacets,
|
|
333
|
-
indexedAt: list.
|
|
345
|
+
indexedAt: this.indexedAt(list).toISOString(),
|
|
334
346
|
}
|
|
335
347
|
}
|
|
336
348
|
|
|
@@ -356,7 +368,7 @@ export class Views {
|
|
|
356
368
|
)
|
|
357
369
|
: undefined,
|
|
358
370
|
listItemCount: listAgg?.listItems ?? 0,
|
|
359
|
-
indexedAt: list.
|
|
371
|
+
indexedAt: this.indexedAt(list).toISOString(),
|
|
360
372
|
labels,
|
|
361
373
|
viewer: listViewer
|
|
362
374
|
? {
|
|
@@ -386,7 +398,7 @@ export class Views {
|
|
|
386
398
|
joinedAllTimeCount: agg?.joinedAllTime ?? 0,
|
|
387
399
|
joinedWeekCount: agg?.joinedWeek ?? 0,
|
|
388
400
|
labels,
|
|
389
|
-
indexedAt: sp.
|
|
401
|
+
indexedAt: this.indexedAt(sp).toISOString(),
|
|
390
402
|
}
|
|
391
403
|
}
|
|
392
404
|
|
|
@@ -463,7 +475,7 @@ export class Views {
|
|
|
463
475
|
like: viewer.like,
|
|
464
476
|
}
|
|
465
477
|
: undefined,
|
|
466
|
-
indexedAt: labeler.
|
|
478
|
+
indexedAt: this.indexedAt(labeler).toISOString(),
|
|
467
479
|
labels,
|
|
468
480
|
}
|
|
469
481
|
}
|
|
@@ -551,7 +563,7 @@ export class Views {
|
|
|
551
563
|
like: viewer.like,
|
|
552
564
|
}
|
|
553
565
|
: undefined,
|
|
554
|
-
indexedAt: feedgen.
|
|
566
|
+
indexedAt: this.indexedAt(feedgen).toISOString(),
|
|
555
567
|
}
|
|
556
568
|
}
|
|
557
569
|
|
|
@@ -600,7 +612,7 @@ export class Views {
|
|
|
600
612
|
repostCount: aggs?.reposts ?? 0,
|
|
601
613
|
likeCount: aggs?.likes ?? 0,
|
|
602
614
|
quoteCount: aggs?.quotes ?? 0,
|
|
603
|
-
indexedAt: post.
|
|
615
|
+
indexedAt: this.indexedAt(post).toISOString(),
|
|
604
616
|
viewer: viewer
|
|
605
617
|
? {
|
|
606
618
|
repost: viewer.repost,
|
|
@@ -724,7 +736,7 @@ export class Views {
|
|
|
724
736
|
return {
|
|
725
737
|
$type: 'app.bsky.feed.defs#reasonRepost',
|
|
726
738
|
by: creator,
|
|
727
|
-
indexedAt: repost.
|
|
739
|
+
indexedAt: this.indexedAt(repost).toISOString(),
|
|
728
740
|
}
|
|
729
741
|
}
|
|
730
742
|
|
|
@@ -1170,11 +1182,12 @@ export class Views {
|
|
|
1170
1182
|
} else if (uri.collection === ids.AppBskyActorProfile) {
|
|
1171
1183
|
const actor = state.actors?.get(authorDid)
|
|
1172
1184
|
recordInfo =
|
|
1173
|
-
actor && actor.profile && actor.profileCid
|
|
1185
|
+
actor && actor.profile && actor.profileCid
|
|
1174
1186
|
? {
|
|
1175
1187
|
record: actor.profile,
|
|
1176
1188
|
cid: actor.profileCid,
|
|
1177
|
-
sortedAt: actor.sortedAt,
|
|
1189
|
+
sortedAt: actor.sortedAt ?? new Date(0), // @NOTE will be present since profile record is present
|
|
1190
|
+
indexedAt: actor.indexedAt ?? new Date(0), // @NOTE will be present since profile record is present
|
|
1178
1191
|
takedownRef: actor.profileTakedownRef,
|
|
1179
1192
|
}
|
|
1180
1193
|
: null
|
|
@@ -1202,6 +1215,11 @@ export class Views {
|
|
|
1202
1215
|
labels: [...labels, ...selfLabels],
|
|
1203
1216
|
}
|
|
1204
1217
|
}
|
|
1218
|
+
|
|
1219
|
+
indexedAt({ sortedAt, indexedAt }: { sortedAt: Date; indexedAt: Date }) {
|
|
1220
|
+
if (!this.indexedAtEpoch) return sortedAt
|
|
1221
|
+
return indexedAt && indexedAt > this.indexedAtEpoch ? indexedAt : sortedAt
|
|
1222
|
+
}
|
|
1205
1223
|
}
|
|
1206
1224
|
|
|
1207
1225
|
const getRootUri = (uri: string, post: Post): string => {
|
package/tests/auth.test.ts
CHANGED
|
@@ -9,6 +9,10 @@ describe('auth', () => {
|
|
|
9
9
|
let agent: AtpAgent
|
|
10
10
|
let sc: SeedClient
|
|
11
11
|
|
|
12
|
+
// account dids, for convenience
|
|
13
|
+
let alice: string
|
|
14
|
+
let bob: string
|
|
15
|
+
|
|
12
16
|
beforeAll(async () => {
|
|
13
17
|
network = await TestNetwork.create({
|
|
14
18
|
dbPostgresSchema: 'bsky_auth',
|
|
@@ -17,6 +21,8 @@ describe('auth', () => {
|
|
|
17
21
|
sc = network.getSeedClient()
|
|
18
22
|
await usersSeed(sc)
|
|
19
23
|
await network.processAll()
|
|
24
|
+
alice = sc.dids.alice
|
|
25
|
+
bob = sc.dids.bob
|
|
20
26
|
})
|
|
21
27
|
|
|
22
28
|
afterAll(async () => {
|
|
@@ -63,4 +69,24 @@ describe('auth', () => {
|
|
|
63
69
|
'jwt signature does not match jwt issuer',
|
|
64
70
|
)
|
|
65
71
|
})
|
|
72
|
+
|
|
73
|
+
it('throws if the user key is incorrect', async () => {
|
|
74
|
+
const bobKeypair = await network.pds.ctx.actorStore.keypair(bob)
|
|
75
|
+
|
|
76
|
+
const jwt = await createServiceJwt({
|
|
77
|
+
iss: alice,
|
|
78
|
+
aud: network.bsky.ctx.cfg.serverDid,
|
|
79
|
+
lxm: ids.AppBskyFeedGetTimeline,
|
|
80
|
+
keypair: bobKeypair,
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
await expect(
|
|
84
|
+
agent.api.app.bsky.actor.getProfile(
|
|
85
|
+
{ actor: sc.dids.carol },
|
|
86
|
+
{
|
|
87
|
+
headers: { authorization: `Bearer ${jwt}` },
|
|
88
|
+
},
|
|
89
|
+
),
|
|
90
|
+
).rejects.toThrow()
|
|
91
|
+
})
|
|
66
92
|
})
|