@atproto/bsky 0.0.225 → 0.0.226
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/bookmark/getBookmarks.d.ts.map +1 -1
- package/dist/api/app/bsky/bookmark/getBookmarks.js +1 -1
- package/dist/api/app/bsky/bookmark/getBookmarks.js.map +1 -1
- package/dist/api/app/bsky/contact/getMatches.d.ts.map +1 -1
- package/dist/api/app/bsky/contact/getMatches.js +1 -1
- package/dist/api/app/bsky/contact/getMatches.js.map +1 -1
- package/dist/api/app/bsky/feed/getTimeline.d.ts +2 -4
- package/dist/api/app/bsky/feed/getTimeline.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getTimeline.js +1 -1
- package/dist/api/app/bsky/feed/getTimeline.js.map +1 -1
- package/dist/api/app/bsky/graph/getBlocks.d.ts.map +1 -1
- package/dist/api/app/bsky/graph/getBlocks.js +1 -1
- package/dist/api/app/bsky/graph/getBlocks.js.map +1 -1
- package/dist/api/app/bsky/graph/getKnownFollowers.d.ts.map +1 -1
- package/dist/api/app/bsky/graph/getKnownFollowers.js +1 -1
- package/dist/api/app/bsky/graph/getKnownFollowers.js.map +1 -1
- package/dist/api/app/bsky/graph/getListBlocks.d.ts.map +1 -1
- package/dist/api/app/bsky/graph/getListBlocks.js +1 -1
- package/dist/api/app/bsky/graph/getListBlocks.js.map +1 -1
- package/dist/api/app/bsky/graph/getListMutes.d.ts.map +1 -1
- package/dist/api/app/bsky/graph/getListMutes.js +1 -1
- package/dist/api/app/bsky/graph/getListMutes.js.map +1 -1
- package/dist/api/app/bsky/graph/getListsWithMembership.js +1 -1
- package/dist/api/app/bsky/graph/getListsWithMembership.js.map +1 -1
- package/dist/api/app/bsky/graph/getMutes.d.ts.map +1 -1
- package/dist/api/app/bsky/graph/getMutes.js +1 -1
- package/dist/api/app/bsky/graph/getMutes.js.map +1 -1
- package/dist/api/app/bsky/graph/getStarterPacksWithMembership.js +1 -1
- package/dist/api/app/bsky/graph/getStarterPacksWithMembership.js.map +1 -1
- package/dist/api/app/bsky/notification/listActivitySubscriptions.js +1 -1
- package/dist/api/app/bsky/notification/listActivitySubscriptions.js.map +1 -1
- package/dist/api/app/bsky/notification/listNotifications.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/listNotifications.js +1 -1
- package/dist/api/app/bsky/notification/listNotifications.js.map +1 -1
- package/dist/data-plane/client/index.d.ts.map +1 -1
- package/dist/data-plane/client/index.js +2 -0
- package/dist/data-plane/client/index.js.map +1 -1
- package/dist/data-plane/client/util.d.ts +2 -1
- package/dist/data-plane/client/util.d.ts.map +1 -1
- package/dist/data-plane/client/util.js +6 -1
- package/dist/data-plane/client/util.js.map +1 -1
- package/dist/data-plane/client/util.test.d.ts +2 -0
- package/dist/data-plane/client/util.test.d.ts.map +1 -0
- package/dist/data-plane/client/util.test.js +33 -0
- package/dist/data-plane/client/util.test.js.map +1 -0
- package/dist/hydration/hydrator.d.ts +3 -0
- package/dist/hydration/hydrator.d.ts.map +1 -1
- package/dist/hydration/hydrator.js.map +1 -1
- package/package.json +7 -7
- package/src/api/app/bsky/bookmark/getBookmarks.ts +3 -6
- package/src/api/app/bsky/contact/getMatches.ts +3 -6
- package/src/api/app/bsky/feed/getTimeline.ts +3 -6
- package/src/api/app/bsky/graph/getBlocks.ts +3 -6
- package/src/api/app/bsky/graph/getKnownFollowers.ts +3 -6
- package/src/api/app/bsky/graph/getListBlocks.ts +3 -6
- package/src/api/app/bsky/graph/getListMutes.ts +3 -6
- package/src/api/app/bsky/graph/getListsWithMembership.ts +3 -3
- package/src/api/app/bsky/graph/getMutes.ts +3 -6
- package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +3 -3
- package/src/api/app/bsky/notification/listActivitySubscriptions.ts +3 -3
- package/src/api/app/bsky/notification/listNotifications.ts +3 -6
- package/src/data-plane/client/index.ts +2 -0
- package/src/data-plane/client/util.test.ts +39 -0
- package/src/data-plane/client/util.ts +9 -1
- package/src/hydration/hydrator.ts +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
2
2
|
import { DidString } from '@atproto/lex'
|
|
3
3
|
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
|
-
import {
|
|
5
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
6
6
|
import { app } from '../../../../lexicons/index.js'
|
|
7
7
|
import {
|
|
8
8
|
HydrationFnInput,
|
|
@@ -31,10 +31,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
31
31
|
viewer,
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
const result = await getKnownFollowers(
|
|
35
|
-
{ ...params, hydrateCtx: hydrateCtx.copy({ viewer }) },
|
|
36
|
-
ctx,
|
|
37
|
-
)
|
|
34
|
+
const result = await getKnownFollowers({ ...params, hydrateCtx }, ctx)
|
|
38
35
|
|
|
39
36
|
return {
|
|
40
37
|
encoding: 'application/json',
|
|
@@ -113,7 +110,7 @@ type Context = {
|
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
type Params = app.bsky.graph.getKnownFollowers.$Params & {
|
|
116
|
-
hydrateCtx:
|
|
113
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
type SkeletonState = {
|
|
@@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
2
2
|
import { AtUriString } from '@atproto/lex'
|
|
3
3
|
import { Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
|
-
import {
|
|
5
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
6
6
|
import { app } from '../../../../lexicons/index.js'
|
|
7
7
|
import {
|
|
8
8
|
HydrationFnInput,
|
|
@@ -27,10 +27,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
27
27
|
const viewer = auth.credentials.iss
|
|
28
28
|
const labelers = ctx.reqLabelers(req)
|
|
29
29
|
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
|
|
30
|
-
const result = await getListBlocks(
|
|
31
|
-
{ ...params, hydrateCtx: hydrateCtx.copy({ viewer }) },
|
|
32
|
-
ctx,
|
|
33
|
-
)
|
|
30
|
+
const result = await getListBlocks({ ...params, hydrateCtx }, ctx)
|
|
34
31
|
return {
|
|
35
32
|
encoding: 'application/json',
|
|
36
33
|
body: result,
|
|
@@ -78,7 +75,7 @@ type Context = {
|
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
type Params = app.bsky.graph.getListBlocks.$Params & {
|
|
81
|
-
hydrateCtx:
|
|
78
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
type SkeletonState = {
|
|
@@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
2
2
|
import { AtUriString } from '@atproto/lex'
|
|
3
3
|
import { Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
|
-
import {
|
|
5
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
6
6
|
import { app } from '../../../../lexicons/index.js'
|
|
7
7
|
import {
|
|
8
8
|
HydrationFnInput,
|
|
@@ -27,10 +27,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
27
27
|
const viewer = auth.credentials.iss
|
|
28
28
|
const labelers = ctx.reqLabelers(req)
|
|
29
29
|
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
|
|
30
|
-
const result = await getListMutes(
|
|
31
|
-
{ ...params, hydrateCtx: hydrateCtx.copy({ viewer }) },
|
|
32
|
-
ctx,
|
|
33
|
-
)
|
|
30
|
+
const result = await getListMutes({ ...params, hydrateCtx }, ctx)
|
|
34
31
|
return {
|
|
35
32
|
encoding: 'application/json',
|
|
36
33
|
body: result,
|
|
@@ -78,7 +75,7 @@ type Context = {
|
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
type Params = app.bsky.graph.getListBlocks.$Params & {
|
|
81
|
-
hydrateCtx:
|
|
78
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
type SkeletonState = {
|
|
@@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
2
2
|
import { AtUriString, DidString } from '@atproto/lex'
|
|
3
3
|
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
|
-
import {
|
|
5
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
6
6
|
import { parseString } from '../../../../hydration/util'
|
|
7
7
|
import { app } from '../../../../lexicons/index.js'
|
|
8
8
|
import {
|
|
@@ -35,7 +35,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
35
35
|
viewer,
|
|
36
36
|
})
|
|
37
37
|
const result = await getListsWithMembership(
|
|
38
|
-
{ ...params, hydrateCtx
|
|
38
|
+
{ ...params, hydrateCtx },
|
|
39
39
|
ctx,
|
|
40
40
|
)
|
|
41
41
|
|
|
@@ -133,7 +133,7 @@ type Context = {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
type Params = app.bsky.graph.getListsWithMembership.$Params & {
|
|
136
|
-
hydrateCtx:
|
|
136
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
type SkeletonState = {
|
|
@@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
2
2
|
import { DidString } from '@atproto/lex'
|
|
3
3
|
import { Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
|
-
import {
|
|
5
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
6
6
|
import { app } from '../../../../lexicons/index.js'
|
|
7
7
|
import {
|
|
8
8
|
HydrationFnInput,
|
|
@@ -22,10 +22,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
22
22
|
const viewer = auth.credentials.iss
|
|
23
23
|
const labelers = ctx.reqLabelers(req)
|
|
24
24
|
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
|
|
25
|
-
const result = await getMutes(
|
|
26
|
-
{ ...params, hydrateCtx: hydrateCtx.copy({ viewer }) },
|
|
27
|
-
ctx,
|
|
28
|
-
)
|
|
25
|
+
const result = await getMutes({ ...params, hydrateCtx }, ctx)
|
|
29
26
|
return {
|
|
30
27
|
encoding: 'application/json',
|
|
31
28
|
body: result,
|
|
@@ -78,7 +75,7 @@ type Context = {
|
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
type Params = app.bsky.graph.getMutes.$Params & {
|
|
81
|
-
hydrateCtx:
|
|
78
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
type SkeletonState = {
|
|
@@ -3,7 +3,7 @@ import { AtUriString, DidString } from '@atproto/syntax'
|
|
|
3
3
|
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
HydrateCtxWithViewer,
|
|
7
7
|
Hydrator,
|
|
8
8
|
mergeManyStates,
|
|
9
9
|
} from '../../../../hydration/hydrator'
|
|
@@ -35,7 +35,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
35
35
|
viewer,
|
|
36
36
|
})
|
|
37
37
|
const result = await getStarterPacksWithMembership(
|
|
38
|
-
{ ...params, hydrateCtx
|
|
38
|
+
{ ...params, hydrateCtx },
|
|
39
39
|
ctx,
|
|
40
40
|
)
|
|
41
41
|
|
|
@@ -126,7 +126,7 @@ type Context = {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
type Params = app.bsky.graph.getStarterPacksWithMembership.$Params & {
|
|
129
|
-
hydrateCtx:
|
|
129
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
type SkeletonState = {
|
|
@@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
|
|
|
2
2
|
import { DidString } from '@atproto/syntax'
|
|
3
3
|
import { Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { AppContext } from '../../../../context'
|
|
5
|
-
import {
|
|
5
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
6
6
|
import { app } from '../../../../lexicons/index.js'
|
|
7
7
|
import {
|
|
8
8
|
HydrationFnInput,
|
|
@@ -32,7 +32,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
const result = await listActivitySubscriptions(
|
|
35
|
-
{ ...params, hydrateCtx
|
|
35
|
+
{ ...params, hydrateCtx },
|
|
36
36
|
ctx,
|
|
37
37
|
)
|
|
38
38
|
|
|
@@ -103,7 +103,7 @@ type Context = {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
type Params = app.bsky.notification.listActivitySubscriptions.$Params & {
|
|
106
|
-
hydrateCtx:
|
|
106
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
type SkeletonState = {
|
|
@@ -3,7 +3,7 @@ import { AtUriString, DatetimeString, DidString } from '@atproto/syntax'
|
|
|
3
3
|
import { InvalidRequestError, Server } from '@atproto/xrpc-server'
|
|
4
4
|
import { ServerConfig } from '../../../../config'
|
|
5
5
|
import { AppContext } from '../../../../context'
|
|
6
|
-
import {
|
|
6
|
+
import { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator'
|
|
7
7
|
import { app } from '../../../../lexicons/index.js'
|
|
8
8
|
import {
|
|
9
9
|
HydrationFnInput,
|
|
@@ -31,10 +31,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
31
31
|
const viewer = auth.credentials.iss
|
|
32
32
|
const labelers = ctx.reqLabelers(req)
|
|
33
33
|
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
|
|
34
|
-
const result = await listNotifications(
|
|
35
|
-
{ ...params, hydrateCtx: hydrateCtx.copy({ viewer }) },
|
|
36
|
-
ctx,
|
|
37
|
-
)
|
|
34
|
+
const result = await listNotifications({ ...params, hydrateCtx }, ctx)
|
|
38
35
|
return {
|
|
39
36
|
encoding: 'application/json',
|
|
40
37
|
body: result,
|
|
@@ -254,7 +251,7 @@ type Context = {
|
|
|
254
251
|
}
|
|
255
252
|
|
|
256
253
|
type Params = app.bsky.notification.listNotifications.$Params & {
|
|
257
|
-
hydrateCtx:
|
|
254
|
+
hydrateCtx: HydrateCtxWithViewer
|
|
258
255
|
}
|
|
259
256
|
|
|
260
257
|
type SkeletonState = {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import { createGrpcTransport } from '@connectrpc/connect-node'
|
|
11
11
|
import { Service } from '../../proto/bsky_connect'
|
|
12
12
|
import { HostList } from './hosts'
|
|
13
|
+
import { callerInterceptor } from './util'
|
|
13
14
|
|
|
14
15
|
export * from './hosts'
|
|
15
16
|
export * from './util'
|
|
@@ -105,6 +106,7 @@ const createBaseClient = (
|
|
|
105
106
|
httpVersion,
|
|
106
107
|
acceptCompression: [],
|
|
107
108
|
nodeOptions: { rejectUnauthorized },
|
|
109
|
+
interceptors: [callerInterceptor('appview')],
|
|
108
110
|
})
|
|
109
111
|
return createPromiseClient(Service, transport)
|
|
110
112
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { callerInterceptor } from './util'
|
|
3
|
+
|
|
4
|
+
describe('callerInterceptor', () => {
|
|
5
|
+
it('sets x-atlantis-caller header on the request', async () => {
|
|
6
|
+
const interceptor = callerInterceptor('appview')
|
|
7
|
+
const expectedResponse = { status: 'ok' }
|
|
8
|
+
const next = jest.fn().mockResolvedValue(expectedResponse)
|
|
9
|
+
|
|
10
|
+
const req = { header: new Headers() }
|
|
11
|
+
const handler = interceptor(next)
|
|
12
|
+
const res = await handler(req as any)
|
|
13
|
+
|
|
14
|
+
expect(req.header.get('x-atlantis-caller')).toBe('appview')
|
|
15
|
+
expect(next).toHaveBeenCalledWith(req)
|
|
16
|
+
expect(res).toBe(expectedResponse)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('uses the provided caller value', async () => {
|
|
20
|
+
const interceptor = callerInterceptor('feed-generator')
|
|
21
|
+
const next = jest.fn().mockResolvedValue({})
|
|
22
|
+
|
|
23
|
+
const req = { header: new Headers() }
|
|
24
|
+
await interceptor(next)(req as any)
|
|
25
|
+
|
|
26
|
+
expect(req.header.get('x-atlantis-caller')).toBe('feed-generator')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('does not overwrite other existing headers', async () => {
|
|
30
|
+
const interceptor = callerInterceptor('appview')
|
|
31
|
+
const next = jest.fn().mockResolvedValue({})
|
|
32
|
+
|
|
33
|
+
const req = { header: new Headers({ 'x-other': 'value' }) }
|
|
34
|
+
await interceptor(next)(req as any)
|
|
35
|
+
|
|
36
|
+
expect(req.header.get('x-atlantis-caller')).toBe('appview')
|
|
37
|
+
expect(req.header.get('x-other')).toBe('value')
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { Code, ConnectError } from '@connectrpc/connect'
|
|
1
|
+
import { Code, ConnectError, Interceptor } from '@connectrpc/connect'
|
|
2
2
|
import * as ui8 from 'uint8arrays'
|
|
3
3
|
import { getDidKeyFromMultibase } from '@atproto/identity'
|
|
4
4
|
|
|
5
|
+
export const callerInterceptor =
|
|
6
|
+
(caller: string): Interceptor =>
|
|
7
|
+
(next) =>
|
|
8
|
+
(req) => {
|
|
9
|
+
req.header.set('x-atlantis-caller', caller)
|
|
10
|
+
return next(req)
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
export const isDataplaneError = (
|
|
6
14
|
err: unknown,
|
|
7
15
|
code?: Code,
|