@atproto/bsky 0.0.53 → 0.0.55

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/app/bsky/graph/getLists.d.ts.map +1 -1
  3. package/dist/api/app/bsky/graph/getLists.js +7 -3
  4. package/dist/api/app/bsky/graph/getLists.js.map +1 -1
  5. package/dist/api/com/atproto/admin/getAccountInfos.d.ts.map +1 -1
  6. package/dist/api/com/atproto/admin/getAccountInfos.js.map +1 -1
  7. package/dist/api/com/atproto/label/queryLabels.d.ts +4 -0
  8. package/dist/api/com/atproto/label/queryLabels.d.ts.map +1 -0
  9. package/dist/api/com/atproto/label/queryLabels.js +30 -0
  10. package/dist/api/com/atproto/label/queryLabels.js.map +1 -0
  11. package/dist/api/index.d.ts.map +1 -1
  12. package/dist/api/index.js +2 -0
  13. package/dist/api/index.js.map +1 -1
  14. package/dist/hydration/hydrator.js +1 -1
  15. package/dist/hydration/hydrator.js.map +1 -1
  16. package/dist/hydration/label.d.ts.map +1 -1
  17. package/dist/hydration/label.js.map +1 -1
  18. package/dist/lexicon/lexicons.d.ts +10 -0
  19. package/dist/lexicon/lexicons.d.ts.map +1 -1
  20. package/dist/lexicon/lexicons.js +10 -0
  21. package/dist/lexicon/lexicons.js.map +1 -1
  22. package/dist/lexicon/types/com/atproto/server/createAppPassword.d.ts +3 -0
  23. package/dist/lexicon/types/com/atproto/server/createAppPassword.d.ts.map +1 -1
  24. package/dist/lexicon/types/com/atproto/server/createAppPassword.js.map +1 -1
  25. package/dist/lexicon/types/com/atproto/server/listAppPasswords.d.ts +1 -0
  26. package/dist/lexicon/types/com/atproto/server/listAppPasswords.d.ts.map +1 -1
  27. package/dist/lexicon/types/com/atproto/server/listAppPasswords.js.map +1 -1
  28. package/package.json +4 -4
  29. package/src/api/app/bsky/graph/getLists.ts +7 -3
  30. package/src/api/com/atproto/admin/getAccountInfos.ts +1 -0
  31. package/src/api/com/atproto/label/queryLabels.ts +35 -0
  32. package/src/api/index.ts +2 -0
  33. package/src/hydration/hydrator.ts +1 -1
  34. package/src/hydration/label.ts +1 -0
  35. package/src/lexicon/lexicons.ts +11 -0
  36. package/src/lexicon/types/com/atproto/server/createAppPassword.ts +3 -0
  37. package/src/lexicon/types/com/atproto/server/listAppPasswords.ts +1 -0
  38. package/tests/query-labels.test.ts +87 -0
@@ -9,6 +9,8 @@ export interface QueryParams {
9
9
  export interface InputSchema {
10
10
  /** A short name for the App Password, to help distinguish them. */
11
11
  name: string;
12
+ /** If an app password has 'privileged' access to possibly sensitive account state. Meant for use with trusted clients. */
13
+ privileged?: boolean;
12
14
  [k: string]: unknown;
13
15
  }
14
16
  export type OutputSchema = AppPassword;
@@ -41,6 +43,7 @@ export interface AppPassword {
41
43
  name: string;
42
44
  password: string;
43
45
  createdAt: string;
46
+ privileged?: boolean;
44
47
  [k: string]: unknown;
45
48
  }
46
49
  export declare function isAppPassword(v: unknown): v is AppPassword;
@@ -1 +1 @@
1
- {"version":3,"file":"createAppPassword.d.ts","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/createAppPassword.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAW,MAAM,kBAAkB,CAAA;AAI5D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEtE,MAAM,WAAW,WAAW;CAAG;AAE/B,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,CAAA;AAEtC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,kBAAkB,CAAA;AAC9E,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI;IAC1D,IAAI,EAAE,EAAE,CAAA;IACR,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,YAAY,CAAA;IACnB,GAAG,EAAE,OAAO,CAAC,OAAO,CAAA;IACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAA;CACtB,CAAA;AACD,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI,CACpD,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC,KACnB,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAA;AAE3C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAM1D;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAKhE"}
1
+ {"version":3,"file":"createAppPassword.d.ts","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/createAppPassword.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAW,MAAM,kBAAkB,CAAA;AAI5D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEtE,MAAM,WAAW,WAAW;CAAG;AAE/B,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAA;IACZ,0HAA0H;IAC1H,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,CAAA;AAEtC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,kBAAkB,CAAA;AAC9E,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI;IAC1D,IAAI,EAAE,EAAE,CAAA;IACR,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,YAAY,CAAA;IACnB,GAAG,EAAE,OAAO,CAAC,OAAO,CAAA;IACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAA;CACtB,CAAA;AACD,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI,CACpD,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC,KACnB,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAA;AAE3C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAM1D;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAKhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"createAppPassword.js","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/createAppPassword.ts"],"names":[],"mappings":";;;AAKA,mDAA+C;AAC/C,2CAAiD;AAkDjD,SAAgB,aAAa,CAAC,CAAU;IACtC,OAAO,CACL,IAAA,YAAK,EAAC,CAAC,CAAC;QACR,IAAA,cAAO,EAAC,CAAC,EAAE,OAAO,CAAC;QACnB,CAAC,CAAC,KAAK,KAAK,kDAAkD,CAC/D,CAAA;AACH,CAAC;AAND,sCAMC;AAED,SAAgB,mBAAmB,CAAC,CAAU;IAC5C,OAAO,mBAAQ,CAAC,QAAQ,CACtB,kDAAkD,EAClD,CAAC,CACF,CAAA;AACH,CAAC;AALD,kDAKC"}
1
+ {"version":3,"file":"createAppPassword.js","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/createAppPassword.ts"],"names":[],"mappings":";;;AAKA,mDAA+C;AAC/C,2CAAiD;AAqDjD,SAAgB,aAAa,CAAC,CAAU;IACtC,OAAO,CACL,IAAA,YAAK,EAAC,CAAC,CAAC;QACR,IAAA,cAAO,EAAC,CAAC,EAAE,OAAO,CAAC;QACnB,CAAC,CAAC,KAAK,KAAK,kDAAkD,CAC/D,CAAA;AACH,CAAC;AAND,sCAMC;AAED,SAAgB,mBAAmB,CAAC,CAAU;IAC5C,OAAO,mBAAQ,CAAC,QAAQ,CACtB,kDAAkD,EAClD,CAAC,CACF,CAAA;AACH,CAAC;AALD,kDAKC"}
@@ -36,6 +36,7 @@ export type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) =
36
36
  export interface AppPassword {
37
37
  name: string;
38
38
  createdAt: string;
39
+ privileged?: boolean;
39
40
  [k: string]: unknown;
40
41
  }
41
42
  export declare function isAppPassword(v: unknown): v is AppPassword;
@@ -1 +1 @@
1
- {"version":3,"file":"listAppPasswords.d.ts","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/listAppPasswords.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAW,MAAM,kBAAkB,CAAA;AAI5D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEtE,MAAM,WAAW,WAAW;CAAG;AAE/B,MAAM,MAAM,WAAW,GAAG,SAAS,CAAA;AAEnC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,CAAA;AAEpC,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,kBAAkB,CAAA;AAC9E,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI;IAC1D,IAAI,EAAE,EAAE,CAAA;IACR,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,YAAY,CAAA;IACnB,GAAG,EAAE,OAAO,CAAC,OAAO,CAAA;IACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAA;CACtB,CAAA;AACD,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI,CACpD,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC,KACnB,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAA;AAE3C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAM1D;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAEhE"}
1
+ {"version":3,"file":"listAppPasswords.d.ts","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/listAppPasswords.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAW,MAAM,kBAAkB,CAAA;AAI5D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEtE,MAAM,WAAW,WAAW;CAAG;AAE/B,MAAM,MAAM,WAAW,GAAG,SAAS,CAAA;AAEnC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,CAAA;AAEpC,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,kBAAkB,CAAA;AAC9E,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI;IAC1D,IAAI,EAAE,EAAE,CAAA;IACR,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,YAAY,CAAA;IACnB,GAAG,EAAE,OAAO,CAAC,OAAO,CAAA;IACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAA;CACtB,CAAA;AACD,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,WAAW,GAAG,KAAK,IAAI,CACpD,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC,KACnB,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAA;AAE3C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAM1D;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAEhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"listAppPasswords.js","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/listAppPasswords.ts"],"names":[],"mappings":";;;AAKA,mDAA+C;AAC/C,2CAAiD;AA6CjD,SAAgB,aAAa,CAAC,CAAU;IACtC,OAAO,CACL,IAAA,YAAK,EAAC,CAAC,CAAC;QACR,IAAA,cAAO,EAAC,CAAC,EAAE,OAAO,CAAC;QACnB,CAAC,CAAC,KAAK,KAAK,iDAAiD,CAC9D,CAAA;AACH,CAAC;AAND,sCAMC;AAED,SAAgB,mBAAmB,CAAC,CAAU;IAC5C,OAAO,mBAAQ,CAAC,QAAQ,CAAC,iDAAiD,EAAE,CAAC,CAAC,CAAA;AAChF,CAAC;AAFD,kDAEC"}
1
+ {"version":3,"file":"listAppPasswords.js","sourceRoot":"","sources":["../../../../../../src/lexicon/types/com/atproto/server/listAppPasswords.ts"],"names":[],"mappings":";;;AAKA,mDAA+C;AAC/C,2CAAiD;AA8CjD,SAAgB,aAAa,CAAC,CAAU;IACtC,OAAO,CACL,IAAA,YAAK,EAAC,CAAC,CAAC;QACR,IAAA,cAAO,EAAC,CAAC,EAAE,OAAO,CAAC;QACnB,CAAC,CAAC,KAAK,KAAK,iDAAiD,CAC9D,CAAA;AACH,CAAC;AAND,sCAMC;AAED,SAAgB,mBAAmB,CAAC,CAAU;IAC5C,OAAO,mBAAQ,CAAC,QAAQ,CAAC,iDAAiD,EAAE,CAAC,CAAC,CAAA;AAChF,CAAC;AAFD,kDAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/bsky",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of app.bsky App View (Bluesky API)",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "structured-headers": "^1.0.1",
40
40
  "typed-emitter": "^2.1.0",
41
41
  "uint8arrays": "3.0.0",
42
- "@atproto/api": "^0.12.11",
42
+ "@atproto/api": "^0.12.13",
43
43
  "@atproto/common": "^0.4.0",
44
44
  "@atproto/crypto": "^0.4.0",
45
45
  "@atproto/identity": "^0.4.0",
@@ -61,9 +61,9 @@
61
61
  "axios": "^0.27.2",
62
62
  "jest": "^28.1.2",
63
63
  "ts-node": "^10.8.2",
64
- "@atproto/api": "^0.12.11",
64
+ "@atproto/api": "^0.12.13",
65
65
  "@atproto/lex-cli": "^0.4.0",
66
- "@atproto/pds": "^0.4.23",
66
+ "@atproto/pds": "^0.4.27",
67
67
  "@atproto/xrpc": "^0.5.0"
68
68
  },
69
69
  "scripts": {
@@ -16,11 +16,15 @@ import { clearlyBadCursor, resHeaders } from '../../../util'
16
16
  export default function (server: Server, ctx: AppContext) {
17
17
  const getLists = createPipeline(skeleton, hydration, noRules, presentation)
18
18
  server.app.bsky.graph.getLists({
19
- auth: ctx.authVerifier.standardOptional,
19
+ auth: ctx.authVerifier.optionalStandardOrRole,
20
20
  handler: async ({ params, auth, req }) => {
21
- const viewer = auth.credentials.iss
22
21
  const labelers = ctx.reqLabelers(req)
23
- const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
22
+ const { viewer, includeTakedowns } = ctx.authVerifier.parseCreds(auth)
23
+ const hydrateCtx = await ctx.hydrator.createContext({
24
+ labelers,
25
+ viewer,
26
+ includeTakedowns,
27
+ })
24
28
  const result = await getLists({ ...params, hydrateCtx }, ctx)
25
29
 
26
30
  return {
@@ -20,6 +20,7 @@ export default function (server: Server, ctx: AppContext) {
20
20
  !info.profileTakedownRef || includeTakedowns
21
21
  ? info.profile
22
22
  : undefined
23
+
23
24
  return {
24
25
  did,
25
26
  handle: info.handle ?? INVALID_HANDLE,
@@ -0,0 +1,35 @@
1
+ import { Server } from '../../../../lexicon'
2
+ import AppContext from '../../../../context'
3
+ import { InvalidRequestError } from '@atproto/xrpc-server'
4
+
5
+ export default function (server: Server, ctx: AppContext) {
6
+ server.com.atproto.label.queryLabels(async ({ params }) => {
7
+ const { uriPatterns, sources } = params
8
+
9
+ if (uriPatterns.find((uri) => uri.includes('*'))) {
10
+ throw new InvalidRequestError('wildcards not supported')
11
+ }
12
+
13
+ if (!sources?.length) {
14
+ throw new InvalidRequestError('source dids are required')
15
+ }
16
+
17
+ const labelMap = await ctx.hydrator.label.getLabelsForSubjects(
18
+ uriPatterns,
19
+ // If sources are provided, use them. Otherwise, use the labelers from the request header
20
+ {
21
+ dids: sources,
22
+ redact: new Set(),
23
+ },
24
+ )
25
+ const labels = uriPatterns.flatMap((uri) => labelMap.getBySubject(uri))
26
+
27
+ return {
28
+ encoding: 'application/json',
29
+ body: {
30
+ cursor: undefined,
31
+ labels,
32
+ },
33
+ }
34
+ })
35
+ }
package/src/api/index.ts CHANGED
@@ -46,6 +46,7 @@ import getAccountInfos from './com/atproto/admin/getAccountInfos'
46
46
  import resolveHandle from './com/atproto/identity/resolveHandle'
47
47
  import getRecord from './com/atproto/repo/getRecord'
48
48
  import fetchLabels from './com/atproto/temp/fetchLabels'
49
+ import queryLabels from './com/atproto/label/queryLabels'
49
50
 
50
51
  export * as health from './health'
51
52
 
@@ -102,5 +103,6 @@ export default function (server: Server, ctx: AppContext) {
102
103
  resolveHandle(server, ctx)
103
104
  getRecord(server, ctx)
104
105
  fetchLabels(server, ctx)
106
+ queryLabels(server, ctx)
105
107
  return server
106
108
  }
@@ -219,7 +219,7 @@ export class Hydrator {
219
219
  ctx: HydrateCtx,
220
220
  ): Promise<HydrationState> {
221
221
  const [lists, listViewers, labels] = await Promise.all([
222
- this.graph.getLists(uris),
222
+ this.graph.getLists(uris, ctx.includeTakedowns),
223
223
  ctx.viewer ? this.graph.getListViewerStates(uris, ctx.viewer) : undefined,
224
224
  this.label.getLabelsForSubjects(uris, ctx.labelers),
225
225
  ])
@@ -75,6 +75,7 @@ export class LabelHydrator {
75
75
  subjects,
76
76
  issuers: labelers.dids,
77
77
  })
78
+
78
79
  return res.labels.reduce((acc, cur) => {
79
80
  const parsed = parseJsonBytes(cur) as Label | undefined
80
81
  if (!parsed || parsed.neg) return acc
@@ -2052,6 +2052,11 @@ export const schemaDict = {
2052
2052
  description:
2053
2053
  'A short name for the App Password, to help distinguish them.',
2054
2054
  },
2055
+ privileged: {
2056
+ type: 'boolean',
2057
+ description:
2058
+ "If an app password has 'privileged' access to possibly sensitive account state. Meant for use with trusted clients.",
2059
+ },
2055
2060
  },
2056
2061
  },
2057
2062
  },
@@ -2082,6 +2087,9 @@ export const schemaDict = {
2082
2087
  type: 'string',
2083
2088
  format: 'datetime',
2084
2089
  },
2090
+ privileged: {
2091
+ type: 'boolean',
2092
+ },
2085
2093
  },
2086
2094
  },
2087
2095
  },
@@ -2629,6 +2637,9 @@ export const schemaDict = {
2629
2637
  type: 'string',
2630
2638
  format: 'datetime',
2631
2639
  },
2640
+ privileged: {
2641
+ type: 'boolean',
2642
+ },
2632
2643
  },
2633
2644
  },
2634
2645
  },
@@ -13,6 +13,8 @@ export interface QueryParams {}
13
13
  export interface InputSchema {
14
14
  /** A short name for the App Password, to help distinguish them. */
15
15
  name: string
16
+ /** If an app password has 'privileged' access to possibly sensitive account state. Meant for use with trusted clients. */
17
+ privileged?: boolean
16
18
  [k: string]: unknown
17
19
  }
18
20
 
@@ -51,6 +53,7 @@ export interface AppPassword {
51
53
  name: string
52
54
  password: string
53
55
  createdAt: string
56
+ privileged?: boolean
54
57
  [k: string]: unknown
55
58
  }
56
59
 
@@ -46,6 +46,7 @@ export type Handler<HA extends HandlerAuth = never> = (
46
46
  export interface AppPassword {
47
47
  name: string
48
48
  createdAt: string
49
+ privileged?: boolean
49
50
  [k: string]: unknown
50
51
  }
51
52
 
@@ -0,0 +1,87 @@
1
+ import { AtpAgent } from '@atproto/api'
2
+ import { TestNetwork, SeedClient, basicSeed } from '@atproto/dev-env'
3
+ import axios from 'axios'
4
+
5
+ describe('label hydration', () => {
6
+ let network: TestNetwork
7
+ let agent: AtpAgent
8
+ let pdsAgent: AtpAgent
9
+ let sc: SeedClient
10
+
11
+ let alice: string
12
+ let bob: string
13
+ let carol: string
14
+ let labelerDid: string
15
+
16
+ beforeAll(async () => {
17
+ network = await TestNetwork.create({
18
+ dbPostgresSchema: 'bsky_label_hydration',
19
+ })
20
+ agent = network.bsky.getClient()
21
+ pdsAgent = network.pds.getClient()
22
+ sc = network.getSeedClient()
23
+ await basicSeed(sc)
24
+ alice = sc.dids.alice
25
+ bob = sc.dids.bob
26
+ carol = sc.dids.carol
27
+ labelerDid = network.bsky.ctx.cfg.labelsFromIssuerDids[0]
28
+ await createLabel({ src: alice, uri: carol, cid: '', val: 'spam' })
29
+ await createLabel({ src: bob, uri: carol, cid: '', val: 'impersonation' })
30
+ await createLabel({
31
+ src: labelerDid,
32
+ uri: carol,
33
+ cid: '',
34
+ val: 'misleading',
35
+ })
36
+ await network.processAll()
37
+ })
38
+
39
+ afterAll(async () => {
40
+ await network.close()
41
+ })
42
+
43
+ it('returns labels based for a subject', async () => {
44
+ const { data } = await pdsAgent.api.com.atproto.label.queryLabels(
45
+ { uriPatterns: [carol], sources: [alice] },
46
+ {
47
+ headers: sc.getHeaders(bob),
48
+ },
49
+ )
50
+ expect(data.labels?.length).toBe(1)
51
+ expect(data.labels?.[0].src).toBe(alice)
52
+ expect(data.labels?.[0].val).toBe('spam')
53
+ })
54
+
55
+ it('returns labels from supplied labelers as param', async () => {
56
+ const { data } = await pdsAgent.api.com.atproto.label.queryLabels(
57
+ { uriPatterns: [carol], sources: [alice, labelerDid] },
58
+ {
59
+ headers: sc.getHeaders(bob),
60
+ },
61
+ )
62
+ expect(data.labels?.length).toBe(2)
63
+ expect(data.labels?.find((l) => l.src === alice)?.val).toEqual('spam')
64
+ expect(data.labels?.find((l) => l.src === labelerDid)?.val).toEqual(
65
+ 'misleading',
66
+ )
67
+ })
68
+
69
+ const createLabel = async (opts: {
70
+ src?: string
71
+ uri: string
72
+ cid: string
73
+ val: string
74
+ }) => {
75
+ await network.bsky.db.db
76
+ .insertInto('label')
77
+ .values({
78
+ uri: opts.uri,
79
+ cid: opts.cid,
80
+ val: opts.val,
81
+ cts: new Date().toISOString(),
82
+ neg: false,
83
+ src: opts.src ?? labelerDid,
84
+ })
85
+ .execute()
86
+ }
87
+ })