@atproto/pds 0.4.217 → 0.4.219

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 (126) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/account-manager/oauth-store.d.ts.map +1 -1
  3. package/dist/account-manager/oauth-store.js +1 -1
  4. package/dist/account-manager/oauth-store.js.map +1 -1
  5. package/dist/actor-store/blob/transactor.d.ts +6 -6
  6. package/dist/actor-store/blob/transactor.d.ts.map +1 -1
  7. package/dist/actor-store/blob/transactor.js +1 -4
  8. package/dist/actor-store/blob/transactor.js.map +1 -1
  9. package/dist/api/com/atproto/repo/importRepo.js +1 -1
  10. package/dist/api/com/atproto/repo/importRepo.js.map +1 -1
  11. package/dist/api/com/atproto/repo/putRecord.js.map +1 -1
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +7 -3
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/env.d.ts +4 -0
  16. package/dist/config/env.d.ts.map +1 -1
  17. package/dist/config/env.js +4 -0
  18. package/dist/config/env.js.map +1 -1
  19. package/dist/lexicons/app/bsky/actor/defs.defs.d.ts +1 -0
  20. package/dist/lexicons/app/bsky/actor/defs.defs.d.ts.map +1 -1
  21. package/dist/lexicons/app/bsky/actor/defs.defs.js +1 -0
  22. package/dist/lexicons/app/bsky/actor/defs.defs.js.map +1 -1
  23. package/dist/lexicons/app/bsky/actor/profile.defs.d.ts.map +1 -1
  24. package/dist/lexicons/app/bsky/actor/profile.defs.js +2 -10
  25. package/dist/lexicons/app/bsky/actor/profile.defs.js.map +1 -1
  26. package/dist/lexicons/app/bsky/embed/external.defs.d.ts.map +1 -1
  27. package/dist/lexicons/app/bsky/embed/external.defs.js +1 -1
  28. package/dist/lexicons/app/bsky/embed/external.defs.js.map +1 -1
  29. package/dist/lexicons/app/bsky/embed/images.defs.d.ts +3 -0
  30. package/dist/lexicons/app/bsky/embed/images.defs.d.ts.map +1 -1
  31. package/dist/lexicons/app/bsky/embed/images.defs.js +1 -5
  32. package/dist/lexicons/app/bsky/embed/images.defs.js.map +1 -1
  33. package/dist/lexicons/app/bsky/embed/video.defs.d.ts.map +1 -1
  34. package/dist/lexicons/app/bsky/embed/video.defs.js +2 -6
  35. package/dist/lexicons/app/bsky/embed/video.defs.js.map +1 -1
  36. package/dist/lexicons/app/bsky/feed/generator.defs.d.ts.map +1 -1
  37. package/dist/lexicons/app/bsky/feed/generator.defs.js +1 -5
  38. package/dist/lexicons/app/bsky/feed/generator.defs.js.map +1 -1
  39. package/dist/lexicons/app/bsky/graph/list.defs.d.ts.map +1 -1
  40. package/dist/lexicons/app/bsky/graph/list.defs.js +1 -5
  41. package/dist/lexicons/app/bsky/graph/list.defs.js.map +1 -1
  42. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.d.ts +3 -0
  43. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.d.ts.map +1 -0
  44. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.defs.d.ts +22 -0
  45. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.defs.d.ts.map +1 -0
  46. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.defs.js +53 -0
  47. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.defs.js.map +1 -0
  48. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.js +45 -0
  49. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscover.js.map +1 -0
  50. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.d.ts +3 -0
  51. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.d.ts.map +1 -0
  52. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.defs.d.ts +31 -0
  53. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.defs.d.ts.map +1 -0
  54. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.defs.js +20 -0
  55. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.defs.js.map +1 -0
  56. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.js +45 -0
  57. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForDiscoverSkeleton.js.map +1 -0
  58. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.d.ts +3 -0
  59. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.d.ts.map +1 -0
  60. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.defs.d.ts +24 -0
  61. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.defs.d.ts.map +1 -0
  62. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.defs.js +54 -0
  63. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.defs.js.map +1 -0
  64. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.js +45 -0
  65. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExplore.js.map +1 -0
  66. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.d.ts +3 -0
  67. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.d.ts.map +1 -0
  68. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.defs.d.ts +33 -0
  69. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.defs.d.ts.map +1 -0
  70. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.defs.js +21 -0
  71. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.defs.js.map +1 -0
  72. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.js +45 -0
  73. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForExploreSkeleton.js.map +1 -0
  74. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.d.ts +3 -0
  75. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.d.ts.map +1 -0
  76. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.defs.d.ts +24 -0
  77. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.defs.d.ts.map +1 -0
  78. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.defs.js +54 -0
  79. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.defs.js.map +1 -0
  80. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.js +45 -0
  81. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMore.js.map +1 -0
  82. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.d.ts +3 -0
  83. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.d.ts.map +1 -0
  84. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.defs.d.ts +33 -0
  85. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.defs.d.ts.map +1 -0
  86. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.defs.js +21 -0
  87. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.defs.js.map +1 -0
  88. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.js +45 -0
  89. package/dist/lexicons/app/bsky/unspecced/getSuggestedUsersForSeeMoreSkeleton.js.map +1 -0
  90. package/dist/lexicons/app/bsky/unspecced.d.ts +6 -0
  91. package/dist/lexicons/app/bsky/unspecced.d.ts.map +1 -1
  92. package/dist/lexicons/app/bsky/unspecced.js +7 -1
  93. package/dist/lexicons/app/bsky/unspecced.js.map +1 -1
  94. package/dist/lexicons/app/bsky/video/defs.defs.js +1 -1
  95. package/dist/lexicons/app/bsky/video/defs.defs.js.map +1 -1
  96. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +2 -6
  97. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
  98. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +1 -1
  99. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
  100. package/dist/pipethrough.d.ts.map +1 -1
  101. package/dist/pipethrough.js +11 -7
  102. package/dist/pipethrough.js.map +1 -1
  103. package/dist/read-after-write/viewer.d.ts.map +1 -1
  104. package/dist/read-after-write/viewer.js +7 -6
  105. package/dist/read-after-write/viewer.js.map +1 -1
  106. package/dist/repo/prepare.d.ts.map +1 -1
  107. package/dist/repo/prepare.js.map +1 -1
  108. package/dist/repo/types.d.ts +3 -3
  109. package/dist/repo/types.d.ts.map +1 -1
  110. package/dist/repo/types.js.map +1 -1
  111. package/package.json +13 -13
  112. package/src/account-manager/oauth-store.ts +2 -1
  113. package/src/actor-store/blob/transactor.ts +9 -15
  114. package/src/api/com/atproto/repo/importRepo.ts +1 -1
  115. package/src/api/com/atproto/repo/putRecord.ts +2 -2
  116. package/src/config/config.ts +13 -3
  117. package/src/config/env.ts +4 -0
  118. package/src/pipethrough.ts +15 -5
  119. package/src/read-after-write/viewer.ts +10 -7
  120. package/src/repo/prepare.ts +2 -2
  121. package/src/repo/types.ts +3 -3
  122. package/tests/_oauth_client_assets_middleware.ts +23 -0
  123. package/tests/_puppeteer.ts +71 -17
  124. package/tests/file-uploads.test.ts +17 -9
  125. package/tests/oauth.test.ts +52 -115
  126. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"unspecced.d.ts","sourceRoot":"","sources":["../../../../src/lexicons/app/bsky/unspecced.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,oBA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E,OAAO,KAAK,gBAAgB,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,oBAAoB,MAAM,qCAAqC,CAAA;AAC3E,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAA;AACzE,OAAO,KAAK,0BAA0B,MAAM,2CAA2C,CAAA"}
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.searchStarterPacksSkeleton = exports.searchPostsSkeleton = exports.searchActorsSkeleton = exports.initAgeAssurance = exports.getTrendsSkeleton = exports.getTrends = exports.getTrendingTopics = exports.getTaggedSuggestions = exports.getSuggestionsSkeleton = exports.getSuggestedUsersSkeleton = exports.getSuggestedUsers = exports.getSuggestedStarterPacksSkeleton = exports.getSuggestedStarterPacks = exports.getSuggestedOnboardingUsers = exports.getSuggestedFeedsSkeleton = exports.getSuggestedFeeds = exports.getPostThreadV2 = exports.getPostThreadOtherV2 = exports.getPopularFeedGenerators = exports.getOnboardingSuggestedUsersSkeleton = exports.getOnboardingSuggestedStarterPacksSkeleton = exports.getOnboardingSuggestedStarterPacks = exports.getConfig = exports.getAgeAssuranceState = exports.defs = void 0;
39
+ exports.searchStarterPacksSkeleton = exports.searchPostsSkeleton = exports.searchActorsSkeleton = exports.initAgeAssurance = exports.getTrendsSkeleton = exports.getTrends = exports.getTrendingTopics = exports.getTaggedSuggestions = exports.getSuggestionsSkeleton = exports.getSuggestedUsersSkeleton = exports.getSuggestedUsersForSeeMoreSkeleton = exports.getSuggestedUsersForSeeMore = exports.getSuggestedUsersForExploreSkeleton = exports.getSuggestedUsersForExplore = exports.getSuggestedUsersForDiscoverSkeleton = exports.getSuggestedUsersForDiscover = exports.getSuggestedUsers = exports.getSuggestedStarterPacksSkeleton = exports.getSuggestedStarterPacks = exports.getSuggestedOnboardingUsers = exports.getSuggestedFeedsSkeleton = exports.getSuggestedFeeds = exports.getPostThreadV2 = exports.getPostThreadOtherV2 = exports.getPopularFeedGenerators = exports.getOnboardingSuggestedUsersSkeleton = exports.getOnboardingSuggestedStarterPacksSkeleton = exports.getOnboardingSuggestedStarterPacks = exports.getConfig = exports.getAgeAssuranceState = exports.defs = void 0;
40
40
  exports.defs = __importStar(require("./unspecced/defs.js"));
41
41
  exports.getAgeAssuranceState = __importStar(require("./unspecced/getAgeAssuranceState.js"));
42
42
  exports.getConfig = __importStar(require("./unspecced/getConfig.js"));
@@ -52,6 +52,12 @@ exports.getSuggestedOnboardingUsers = __importStar(require("./unspecced/getSugge
52
52
  exports.getSuggestedStarterPacks = __importStar(require("./unspecced/getSuggestedStarterPacks.js"));
53
53
  exports.getSuggestedStarterPacksSkeleton = __importStar(require("./unspecced/getSuggestedStarterPacksSkeleton.js"));
54
54
  exports.getSuggestedUsers = __importStar(require("./unspecced/getSuggestedUsers.js"));
55
+ exports.getSuggestedUsersForDiscover = __importStar(require("./unspecced/getSuggestedUsersForDiscover.js"));
56
+ exports.getSuggestedUsersForDiscoverSkeleton = __importStar(require("./unspecced/getSuggestedUsersForDiscoverSkeleton.js"));
57
+ exports.getSuggestedUsersForExplore = __importStar(require("./unspecced/getSuggestedUsersForExplore.js"));
58
+ exports.getSuggestedUsersForExploreSkeleton = __importStar(require("./unspecced/getSuggestedUsersForExploreSkeleton.js"));
59
+ exports.getSuggestedUsersForSeeMore = __importStar(require("./unspecced/getSuggestedUsersForSeeMore.js"));
60
+ exports.getSuggestedUsersForSeeMoreSkeleton = __importStar(require("./unspecced/getSuggestedUsersForSeeMoreSkeleton.js"));
55
61
  exports.getSuggestedUsersSkeleton = __importStar(require("./unspecced/getSuggestedUsersSkeleton.js"));
56
62
  exports.getSuggestionsSkeleton = __importStar(require("./unspecced/getSuggestionsSkeleton.js"));
57
63
  exports.getTaggedSuggestions = __importStar(require("./unspecced/getTaggedSuggestions.js"));
@@ -1 +1 @@
1
- {"version":3,"file":"unspecced.js","sourceRoot":"","sources":["../../../../src/lexicons/app/bsky/unspecced.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAA2C;AAC3C,4FAA2E;AAC3E,sEAAqD;AACrD,wHAAuG;AACvG,wIAAuH;AACvH,0HAAyG;AACzG,oGAAmF;AACnF,4FAA2E;AAC3E,kFAAiE;AACjE,sFAAqE;AACrE,sGAAqF;AACrF,0GAAyF;AACzF,oGAAmF;AACnF,oHAAmG;AACnG,sFAAqE;AACrE,sGAAqF;AACrF,gGAA+E;AAC/E,4FAA2E;AAC3E,sFAAqE;AACrE,sEAAqD;AACrD,sFAAqE;AACrE,oFAAmE;AACnE,4FAA2E;AAC3E,0FAAyE;AACzE,wGAAuF","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as defs from './unspecced/defs.js'\nexport * as getAgeAssuranceState from './unspecced/getAgeAssuranceState.js'\nexport * as getConfig from './unspecced/getConfig.js'\nexport * as getOnboardingSuggestedStarterPacks from './unspecced/getOnboardingSuggestedStarterPacks.js'\nexport * as getOnboardingSuggestedStarterPacksSkeleton from './unspecced/getOnboardingSuggestedStarterPacksSkeleton.js'\nexport * as getOnboardingSuggestedUsersSkeleton from './unspecced/getOnboardingSuggestedUsersSkeleton.js'\nexport * as getPopularFeedGenerators from './unspecced/getPopularFeedGenerators.js'\nexport * as getPostThreadOtherV2 from './unspecced/getPostThreadOtherV2.js'\nexport * as getPostThreadV2 from './unspecced/getPostThreadV2.js'\nexport * as getSuggestedFeeds from './unspecced/getSuggestedFeeds.js'\nexport * as getSuggestedFeedsSkeleton from './unspecced/getSuggestedFeedsSkeleton.js'\nexport * as getSuggestedOnboardingUsers from './unspecced/getSuggestedOnboardingUsers.js'\nexport * as getSuggestedStarterPacks from './unspecced/getSuggestedStarterPacks.js'\nexport * as getSuggestedStarterPacksSkeleton from './unspecced/getSuggestedStarterPacksSkeleton.js'\nexport * as getSuggestedUsers from './unspecced/getSuggestedUsers.js'\nexport * as getSuggestedUsersSkeleton from './unspecced/getSuggestedUsersSkeleton.js'\nexport * as getSuggestionsSkeleton from './unspecced/getSuggestionsSkeleton.js'\nexport * as getTaggedSuggestions from './unspecced/getTaggedSuggestions.js'\nexport * as getTrendingTopics from './unspecced/getTrendingTopics.js'\nexport * as getTrends from './unspecced/getTrends.js'\nexport * as getTrendsSkeleton from './unspecced/getTrendsSkeleton.js'\nexport * as initAgeAssurance from './unspecced/initAgeAssurance.js'\nexport * as searchActorsSkeleton from './unspecced/searchActorsSkeleton.js'\nexport * as searchPostsSkeleton from './unspecced/searchPostsSkeleton.js'\nexport * as searchStarterPacksSkeleton from './unspecced/searchStarterPacksSkeleton.js'\n"]}
1
+ {"version":3,"file":"unspecced.js","sourceRoot":"","sources":["../../../../src/lexicons/app/bsky/unspecced.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAA2C;AAC3C,4FAA2E;AAC3E,sEAAqD;AACrD,wHAAuG;AACvG,wIAAuH;AACvH,0HAAyG;AACzG,oGAAmF;AACnF,4FAA2E;AAC3E,kFAAiE;AACjE,sFAAqE;AACrE,sGAAqF;AACrF,0GAAyF;AACzF,oGAAmF;AACnF,oHAAmG;AACnG,sFAAqE;AACrE,4GAA2F;AAC3F,4HAA2G;AAC3G,0GAAyF;AACzF,0HAAyG;AACzG,0GAAyF;AACzF,0HAAyG;AACzG,sGAAqF;AACrF,gGAA+E;AAC/E,4FAA2E;AAC3E,sFAAqE;AACrE,sEAAqD;AACrD,sFAAqE;AACrE,oFAAmE;AACnE,4FAA2E;AAC3E,0FAAyE;AACzE,wGAAuF","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as defs from './unspecced/defs.js'\nexport * as getAgeAssuranceState from './unspecced/getAgeAssuranceState.js'\nexport * as getConfig from './unspecced/getConfig.js'\nexport * as getOnboardingSuggestedStarterPacks from './unspecced/getOnboardingSuggestedStarterPacks.js'\nexport * as getOnboardingSuggestedStarterPacksSkeleton from './unspecced/getOnboardingSuggestedStarterPacksSkeleton.js'\nexport * as getOnboardingSuggestedUsersSkeleton from './unspecced/getOnboardingSuggestedUsersSkeleton.js'\nexport * as getPopularFeedGenerators from './unspecced/getPopularFeedGenerators.js'\nexport * as getPostThreadOtherV2 from './unspecced/getPostThreadOtherV2.js'\nexport * as getPostThreadV2 from './unspecced/getPostThreadV2.js'\nexport * as getSuggestedFeeds from './unspecced/getSuggestedFeeds.js'\nexport * as getSuggestedFeedsSkeleton from './unspecced/getSuggestedFeedsSkeleton.js'\nexport * as getSuggestedOnboardingUsers from './unspecced/getSuggestedOnboardingUsers.js'\nexport * as getSuggestedStarterPacks from './unspecced/getSuggestedStarterPacks.js'\nexport * as getSuggestedStarterPacksSkeleton from './unspecced/getSuggestedStarterPacksSkeleton.js'\nexport * as getSuggestedUsers from './unspecced/getSuggestedUsers.js'\nexport * as getSuggestedUsersForDiscover from './unspecced/getSuggestedUsersForDiscover.js'\nexport * as getSuggestedUsersForDiscoverSkeleton from './unspecced/getSuggestedUsersForDiscoverSkeleton.js'\nexport * as getSuggestedUsersForExplore from './unspecced/getSuggestedUsersForExplore.js'\nexport * as getSuggestedUsersForExploreSkeleton from './unspecced/getSuggestedUsersForExploreSkeleton.js'\nexport * as getSuggestedUsersForSeeMore from './unspecced/getSuggestedUsersForSeeMore.js'\nexport * as getSuggestedUsersForSeeMoreSkeleton from './unspecced/getSuggestedUsersForSeeMoreSkeleton.js'\nexport * as getSuggestedUsersSkeleton from './unspecced/getSuggestedUsersSkeleton.js'\nexport * as getSuggestionsSkeleton from './unspecced/getSuggestionsSkeleton.js'\nexport * as getTaggedSuggestions from './unspecced/getTaggedSuggestions.js'\nexport * as getTrendingTopics from './unspecced/getTrendingTopics.js'\nexport * as getTrends from './unspecced/getTrends.js'\nexport * as getTrendsSkeleton from './unspecced/getTrendsSkeleton.js'\nexport * as initAgeAssurance from './unspecced/initAgeAssurance.js'\nexport * as searchActorsSkeleton from './unspecced/searchActorsSkeleton.js'\nexport * as searchPostsSkeleton from './unspecced/searchPostsSkeleton.js'\nexport * as searchStarterPacksSkeleton from './unspecced/searchStarterPacksSkeleton.js'\n"]}
@@ -12,7 +12,7 @@ const jobStatus = lex_1.l.typedObject($nsid, 'jobStatus', lex_1.l.object({
12
12
  did: lex_1.l.string({ format: 'did' }),
13
13
  state: lex_1.l.string(),
14
14
  progress: lex_1.l.optional(lex_1.l.integer({ minimum: 0, maximum: 100 })),
15
- blob: lex_1.l.optional(lex_1.l.blob({ allowLegacy: false })),
15
+ blob: lex_1.l.optional(lex_1.l.blob()),
16
16
  error: lex_1.l.optional(lex_1.l.string()),
17
17
  message: lex_1.l.optional(lex_1.l.string()),
18
18
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"defs.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/app/bsky/video/defs.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAgC;AAEhC,MAAM,KAAK,GAAG,qBAAqB,CAAA;AAE1B,sBAAK;AAuBd,MAAM,SAAS,GAAG,OAAC,CAAC,WAAW,CAC7B,KAAK,EACL,WAAW,EACX,OAAC,CAAC,MAAM,CAAC;IACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChC,KAAK,EAAE,OAAC,CAAC,MAAM,EAEX;IACJ,QAAQ,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IAChD,KAAK,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CACH,CAAA;AAEQ,8BAAS","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\n\nconst $nsid = 'app.bsky.video.defs'\n\nexport { $nsid }\n\ntype JobStatus = {\n $type?: 'app.bsky.video.defs#jobStatus'\n jobId: string\n did: l.DidString\n\n /**\n * The state of the video processing job. All values not listed as a known value indicate that the job is in process.\n */\n state: 'JOB_STATE_COMPLETED' | 'JOB_STATE_FAILED' | l.UnknownString\n\n /**\n * Progress within the current processing state.\n */\n progress?: number\n blob?: l.BlobRef\n error?: string\n message?: string\n}\n\nexport type { JobStatus }\n\nconst jobStatus = l.typedObject<JobStatus>(\n $nsid,\n 'jobStatus',\n l.object({\n jobId: l.string(),\n did: l.string({ format: 'did' }),\n state: l.string<{\n knownValues: ['JOB_STATE_COMPLETED', 'JOB_STATE_FAILED']\n }>(),\n progress: l.optional(l.integer({ minimum: 0, maximum: 100 })),\n blob: l.optional(l.blob({ allowLegacy: false })),\n error: l.optional(l.string()),\n message: l.optional(l.string()),\n }),\n)\n\nexport { jobStatus }\n"]}
1
+ {"version":3,"file":"defs.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/app/bsky/video/defs.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAgC;AAEhC,MAAM,KAAK,GAAG,qBAAqB,CAAA;AAE1B,sBAAK;AAuBd,MAAM,SAAS,GAAG,OAAC,CAAC,WAAW,CAC7B,KAAK,EACL,WAAW,EACX,OAAC,CAAC,MAAM,CAAC;IACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChC,KAAK,EAAE,OAAC,CAAC,MAAM,EAEX;IACJ,QAAQ,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,IAAI,EAAE,CAAC;IAC1B,KAAK,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CACH,CAAA;AAEQ,8BAAS","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\n\nconst $nsid = 'app.bsky.video.defs'\n\nexport { $nsid }\n\ntype JobStatus = {\n $type?: 'app.bsky.video.defs#jobStatus'\n jobId: string\n did: l.DidString\n\n /**\n * The state of the video processing job. All values not listed as a known value indicate that the job is in process.\n */\n state: 'JOB_STATE_COMPLETED' | 'JOB_STATE_FAILED' | l.UnknownString\n\n /**\n * Progress within the current processing state.\n */\n progress?: number\n blob?: l.BlobRef\n error?: string\n message?: string\n}\n\nexport type { JobStatus }\n\nconst jobStatus = l.typedObject<JobStatus>(\n $nsid,\n 'jobStatus',\n l.object({\n jobId: l.string(),\n did: l.string({ format: 'did' }),\n state: l.string<{\n knownValues: ['JOB_STATE_COMPLETED', 'JOB_STATE_FAILED']\n }>(),\n progress: l.optional(l.integer({ minimum: 0, maximum: 100 })),\n blob: l.optional(l.blob()),\n error: l.optional(l.string()),\n message: l.optional(l.string()),\n }),\n)\n\nexport { jobStatus }\n"]}
@@ -3,9 +3,7 @@ declare const $nsid = "com.atproto.repo.uploadBlob";
3
3
  export { $nsid };
4
4
  /** Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS. */
5
5
  declare const main: l.Procedure<"com.atproto.repo.uploadBlob", l.ParamsSchema<{}>, l.Payload<"*/*", undefined>, l.Payload<"application/json", l.ObjectSchema<{
6
- blob: l.BlobSchema<{
7
- allowLegacy: false;
8
- }>;
6
+ blob: l.BlobSchema<{}>;
9
7
  }>>, undefined>;
10
8
  export { main };
11
9
  export type $Params = l.InferMethodParams<typeof main>;
@@ -14,8 +12,6 @@ export type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<typeof main, B
14
12
  export type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>;
15
13
  export type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<typeof main, B>;
16
14
  export declare const $lxm: "com.atproto.repo.uploadBlob", $params: l.ParamsSchema<{}>, $input: l.Payload<"*/*", undefined>, $output: l.Payload<"application/json", l.ObjectSchema<{
17
- blob: l.BlobSchema<{
18
- allowLegacy: false;
19
- }>;
15
+ blob: l.BlobSchema<{}>;
20
16
  }>>;
21
17
  //# sourceMappingURL=uploadBlob.defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadBlob.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/uploadBlob.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAEhC,QAAA,MAAM,KAAK,gCAAgC,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,gRAAgR;AAChR,QAAA,MAAM,IAAI;;;;eAKT,CAAA;AACD,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACtD,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAA;AACzE,MAAM,MAAM,U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AC,CAAC,CAAA;AAC3E,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,qBAAqB,CACjE,OAAO,IAAI,EACX,CAAC,CACF,CAAA;AAED,eAAO,MAAM,IAAI,+BAAY,EAC3B,OAAO,oBAAkB,EACzB,MAAM,6BAAa,EACnB,OAAO;;GAAc,CAAA"}
@@ -8,7 +8,7 @@ const lex_1 = require("@atproto/lex");
8
8
  const $nsid = 'com.atproto.repo.uploadBlob';
9
9
  exports.$nsid = $nsid;
10
10
  /** Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS. */
11
- const main = lex_1.l.procedure($nsid, lex_1.l.params(), lex_1.l.payload('*/*'), lex_1.l.jsonPayload({ blob: lex_1.l.blob({ allowLegacy: false }) }));
11
+ const main = lex_1.l.procedure($nsid, lex_1.l.params(), lex_1.l.payload('*/*'), lex_1.l.jsonPayload({ blob: lex_1.l.blob() }));
12
12
  exports.main = main;
13
13
  exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
14
14
  //# sourceMappingURL=uploadBlob.defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadBlob.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/uploadBlob.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAgC;AAEhC,MAAM,KAAK,GAAG,6BAA6B,CAAA;AAElC,sBAAK;AAEd,gRAAgR;AAChR,MAAM,IAAI,GAAG,OAAC,CAAC,SAAS,CACtB,KAAK,EACL,OAAC,CAAC,MAAM,EAAE,EACV,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAChB,OAAC,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CACxD,CAAA;AACQ,oBAAI;AAcA,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,EAC3B,QAAA,OAAO,GAAG,IAAI,CAAC,UAAU,EACzB,QAAA,MAAM,GAAG,IAAI,CAAC,KAAK,EACnB,QAAA,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\n\nconst $nsid = 'com.atproto.repo.uploadBlob'\n\nexport { $nsid }\n\n/** Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS. */\nconst main = l.procedure(\n $nsid,\n l.params(),\n l.payload('*/*'),\n l.jsonPayload({ blob: l.blob({ allowLegacy: false }) }),\n)\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Input<B = l.BinaryData> = l.InferMethodInput<typeof main, B>\nexport type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<\n typeof main,\n B\n>\nexport type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>\nexport type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<\n typeof main,\n B\n>\n\nexport const $lxm = main.nsid,\n $params = main.parameters,\n $input = main.input,\n $output = main.output\n"]}
1
+ {"version":3,"file":"uploadBlob.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/uploadBlob.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAgC;AAEhC,MAAM,KAAK,GAAG,6BAA6B,CAAA;AAElC,sBAAK;AAEd,gRAAgR;AAChR,MAAM,IAAI,GAAG,OAAC,CAAC,SAAS,CACtB,KAAK,EACL,OAAC,CAAC,MAAM,EAAE,EACV,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAChB,OAAC,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAClC,CAAA;AACQ,oBAAI;AAcA,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,EAC3B,QAAA,OAAO,GAAG,IAAI,CAAC,UAAU,EACzB,QAAA,MAAM,GAAG,IAAI,CAAC,KAAK,EACnB,QAAA,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\n\nconst $nsid = 'com.atproto.repo.uploadBlob'\n\nexport { $nsid }\n\n/** Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS. */\nconst main = l.procedure(\n $nsid,\n l.params(),\n l.payload('*/*'),\n l.jsonPayload({ blob: l.blob() }),\n)\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Input<B = l.BinaryData> = l.InferMethodInput<typeof main, B>\nexport type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<\n typeof main,\n B\n>\nexport type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>\nexport type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<\n typeof main,\n B\n>\n\nexport const $lxm = main.nsid,\n $params = main.parameters,\n $input = main.input,\n $output = main.output\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pipethrough.d.ts","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAkB,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAe,QAAQ,EAAY,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AASjC,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,wBAAwB,EAIxB,SAAS,IAAI,eAAe,EAG7B,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,UAAU,EAA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;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAkB;gBACtB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IAInC,GAAG,CAAC,GAAG,EAAE,MAAM;IAGd,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC;CAGvC;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAEvC;AAED,eAAO,MAAM,iBAAiB,QAe5B,CAAA;AAEF,eAAO,MAAM,kBAAkB,QAG7B,CAAA;AAKF,eAAO,MAAM,iBAAiB,QAiB5B,CAAA;AA8DF,qBAAa,wBAAyB,SAAQ,eAAe;IAEzD,QAAQ,CAAC,QAAQ,EAAE;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE,mBAAmB,CAAA;KAC7B;gBAHQ,QAAQ,EAAE;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE,mBAAmB,CAAA;KAC7B,EACD,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAC7C,OAAO,CAAC,EAAE,YAAY;IAUxB,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpC;IAED,IAAI,KAAK,uBAER;CACF"}
@@ -60,7 +60,7 @@ const proxyHandler = (ctx) => {
60
60
  body,
61
61
  headers,
62
62
  };
63
- await pipethroughStream(ctx, dispatchOptions, (upstream) => {
63
+ await pipethroughStream(ctx, req, dispatchOptions, (upstream) => {
64
64
  res.status(upstream.statusCode);
65
65
  for (const [name, val] of responseHeaders(upstream.headers)) {
66
66
  res.setHeader(name, val);
@@ -113,7 +113,7 @@ async function pipethrough(ctx, req, options) {
113
113
  // while processing read-after-write operations.
114
114
  highWaterMark: 2 * 65536, // twice the default (64KiB)
115
115
  };
116
- const { headers, body } = await pipethroughRequest(ctx, dispatchOptions);
116
+ const { headers, body } = await pipethroughRequest(ctx, req, dispatchOptions);
117
117
  return {
118
118
  encoding: safeString(headers['content-type']) ?? 'application/json',
119
119
  headers: Object.fromEntries(responseHeaders(headers)),
@@ -185,7 +185,7 @@ exports.parseProxyHeader = parseProxyHeader;
185
185
  * more efficient than "pipethroughRequest" when a writable stream to pipe the
186
186
  * upstream response to is available.
187
187
  */
188
- async function pipethroughStream(ctx, dispatchOptions, successStreamFactory) {
188
+ async function pipethroughStream(ctx, req, dispatchOptions, successStreamFactory) {
189
189
  return new Promise((resolve, reject) => {
190
190
  void ctx.proxyAgent
191
191
  .stream(dispatchOptions, (upstream) => {
@@ -213,7 +213,7 @@ async function pipethroughStream(ctx, dispatchOptions, successStreamFactory) {
213
213
  // or writable stream errors. In the latter case, the promise will already
214
214
  // be resolved, and reject()ing it there after will have no effect. Those
215
215
  // error would still be logged by the successStreamFactory() function.
216
- .catch(handleUpstreamRequestError)
216
+ .catch(handleUpstreamRequestError.bind(req))
217
217
  .catch(reject);
218
218
  });
219
219
  }
@@ -221,12 +221,12 @@ async function pipethroughStream(ctx, dispatchOptions, successStreamFactory) {
221
221
  * Utility function that wraps the undici request() function and handles request
222
222
  * and response errors by wrapping them in XRPCError instances.
223
223
  */
224
- async function pipethroughRequest(ctx, dispatchOptions) {
224
+ async function pipethroughRequest(ctx, req, dispatchOptions) {
225
225
  // HandlerPipeThroughStream requires a readable stream to be returned, so we
226
226
  // use the (less efficient) request() function instead.
227
227
  const upstream = await ctx.proxyAgent
228
228
  .request(dispatchOptions)
229
- .catch(handleUpstreamRequestError);
229
+ .catch(handleUpstreamRequestError.bind(req));
230
230
  if (upstream.statusCode >= 400) {
231
231
  const parsed = await tryParsingError(upstream.headers, upstream.body);
232
232
  throw new PipethroughUpstreamError(upstream, parsed, {
@@ -236,11 +236,15 @@ async function pipethroughRequest(ctx, dispatchOptions) {
236
236
  return upstream;
237
237
  }
238
238
  function handleUpstreamRequestError(err, message = 'Upstream service unreachable') {
239
- logger_1.httpLogger.error({ err }, message);
239
+ const logger = isPinoHttpRequest(this) ? this.log : logger_1.httpLogger;
240
+ logger.error({ err }, message);
240
241
  throw new xrpc_server_1.XRPCError(xrpc_server_1.ResponseType.UpstreamFailure, message, undefined, {
241
242
  cause: err,
242
243
  });
243
244
  }
245
+ function isPinoHttpRequest(req) {
246
+ return typeof req.log?.error === 'function';
247
+ }
244
248
  // Request parsing/forwarding
245
249
  // -------------------
246
250
  function isJsonContentType(contentType) {
@@ -1 +1 @@
1
- {"version":3,"file":"pipethrough.js","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":";;;AAqIA,kCAgEC;AAKD,wCAcC;AAED,wCAcC;AA6ID,8CAGC;AAkED,kDAWC;AA8DD,oCAEC;AApgBD,6CAA6D;AAG7D,4CAKwB;AAExB,sDAU6B;AAC7B,yDAAsE;AACtE,6CAAiD;AAEjD,kDAAsD;AACtD,qCAAqC;AAE9B,MAAM,YAAY,GAAG,CAAC,GAAe,EAAmB,EAAE;IAC/D,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAqB;QACrE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC;KACtE,CAAC,CAAA;IAEF,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC9B,eAAe;QACf,IAAI,CAAC;YACH,IACE,GAAG,CAAC,MAAM,KAAK,KAAK;gBACpB,GAAG,CAAC,MAAM,KAAK,MAAM;gBACrB,GAAG,CAAC,MAAM,KAAK,MAAM,EACrB,CAAC;gBACD,MAAM,IAAI,uBAAe,CACvB,0BAAY,CAAC,cAAc,EAC3B,0CAA0C,CAC3C,CAAA;YACH,CAAC;YAED,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,C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AAQ,uBAAe;IAC3D,YACW,QAGR,EACD,OAA6C,EAC7C,OAAsB;QAEtB,MAAM,MAAM,GACV,QAAQ,CAAC,UAAU,KAAK,GAAG;YACzB,CAAC,CAAC,0BAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAA;QAEzB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAZtD;;;;mBAAS,QAAQ;WAGhB;IAUH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAA;IAC9C,CAAC;CACF;AAxBD,4DAwBC","sourcesContent":["import { IncomingHttpHeaders, ServerResponse } from 'node:http'\nimport { PassThrough, Readable, finished } from 'node:stream'\nimport { Request } from 'express'\nimport { Dispatcher } from 'undici'\nimport {\n decodeStream,\n getServiceEndpoint,\n omit,\n streamToNodeBuffer,\n} from '@atproto/common'\nimport { RpcPermissionMatch } from '@atproto/oauth-scopes'\nimport {\n CatchallHandler,\n HandlerPipeThroughBuffer,\n HandlerPipeThroughStream,\n InternalServerError,\n InvalidRequestError,\n ResponseType,\n XRPCError as XRPCServerError,\n excludeErrorResult,\n parseReqNsid,\n} from '@atproto/xrpc-server'\nimport { buildProxiedContentEncoding } from '@atproto-labs/xrpc-utils'\nimport { isAccessPrivileged } from './auth-scope'\nimport { AppContext } from './context'\nimport { chat, com, tools } from './lexicons/index.js'\nimport { httpLogger } from './logger'\n\nexport const proxyHandler = (ctx: AppContext): CatchallHandler => {\n const performAuth = ctx.authVerifier.authorization<RpcPermissionMatch>({\n authorize: (permissions, { params }) => permissions.assertRpc(params),\n })\n\n return async (req, res, next) => {\n // /!\\ Hot path\n try {\n if (\n req.method !== 'GET' &&\n req.method !== 'HEAD' &&\n req.method !== 'POST'\n ) {\n throw new XRPCServerError(\n ResponseType.InvalidRequest,\n 'XRPC requests only supports GET and POST',\n )\n }\n\n const body = req.method === 'POST' ? req : undefined\n if (body != null && !body.readable) {\n // Body was already consumed by a previous middleware\n throw new InternalServerError('Request body is not readable')\n }\n\n const lxm = parseReqNsid(req)\n if (PROTECTED_METHODS.has(lxm)) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const authResult = await performAuth({ req, res, params: { lxm, aud } })\n\n const { credentials } = excludeErrorResult(authResult)\n\n if (\n credentials.type === 'access' &&\n !isAccessPrivileged(credentials.scope) &&\n PRIVILEGED_METHODS.has(lxm)\n ) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const headers: IncomingHttpHeaders = {\n 'accept-encoding': req.headers['accept-encoding'] || 'identity',\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n 'content-type': body && req.headers['content-type'],\n 'content-encoding': body && req.headers['content-encoding'],\n 'content-length': body && req.headers['content-length'],\n\n authorization: `Bearer ${await ctx.serviceAuthJwt(credentials.did, aud, lxm)}`,\n }\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n body,\n headers,\n }\n\n await pipethroughStream(ctx, dispatchOptions, (upstream) => {\n res.status(upstream.statusCode)\n\n for (const [name, val] of responseHeaders(upstream.headers)) {\n res.setHeader(name, val)\n }\n\n // Note that we should not need to manually handle errors here (e.g. by\n // destroying the response), as the http server will handle them for us.\n res.on('error', logResponseError)\n\n // Tell undici to write the upstream response directly to the response\n return res\n })\n } catch (err) {\n next(err)\n }\n }\n}\n\nexport type PipethroughOptions = {\n /**\n * Specify the issuer (requester) for service auth. If not provided, no\n * authorization headers will be added to the request.\n */\n iss?: string\n\n /**\n * Override the audience for service auth. If not provided, the audience will\n * be determined based on the proxy service.\n */\n aud?: string\n\n /**\n * Override the lexicon method for service auth. If not provided, the lexicon\n * method will be determined based on the request path.\n */\n lxm?: string\n}\n\nexport async function pipethrough(\n ctx: AppContext,\n req: Request,\n options?: PipethroughOptions,\n): Promise<\n HandlerPipeThroughStream & {\n stream: Readable\n headers: Record<string, string>\n encoding: string\n }\n> {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n // pipethrough() is used from within xrpcServer handlers, which means that\n // the request body either has been parsed or is a readable stream that has\n // been piped for decoding & size limiting. Because of this, forwarding the\n // request body requires re-encoding it. Since we currently do not use\n // pipethrough() with procedures, proxying of request body is not\n // implemented.\n throw new InternalServerError(\n `Proxying of ${req.method} requests is not supported`,\n )\n }\n\n const lxm = parseReqNsid(req)\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n headers: {\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n // Because we sometimes need to interpret the response (e.g. during\n // read-after-write, through asPipeThroughBuffer()), we need to ask the\n // upstream server for an encoding that both the requester and the PDS can\n // understand. Since we might have to do the decoding ourselves, we will\n // use our own preferences (and weight) to negotiate the encoding.\n 'accept-encoding': buildProxiedContentEncoding(\n req.headers['accept-encoding'],\n ctx.cfg.proxy.preferCompressed,\n ),\n\n authorization: options?.iss\n ? `Bearer ${await ctx.serviceAuthJwt(options.iss, options.aud ?? aud, options.lxm ?? lxm)}`\n : undefined,\n },\n\n // Use a high water mark to buffer more data while performing async\n // operations before this stream is consumed. This is especially useful\n // while processing read-after-write operations.\n highWaterMark: 2 * 65536, // twice the default (64KiB)\n }\n\n const { headers, body } = await pipethroughRequest(ctx, dispatchOptions)\n\n return {\n encoding: safeString(headers['content-type']) ?? 'application/json',\n headers: Object.fromEntries(responseHeaders(headers)),\n stream: body,\n }\n}\n\n// Request setup/formatting\n// -------------------\n\nexport function computeProxyTo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): string {\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return proxyToHeader\n\n const service = defaultService(ctx, lxm)\n if (service.serviceInfo) {\n return `${service.serviceInfo.did}#${service.serviceId}`\n }\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport async function parseProxyInfo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): Promise<{ url: string; did: string }> {\n // /!\\ Hot path\n\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return parseProxyHeader(ctx, proxyToHeader)\n\n const { serviceInfo } = defaultService(ctx, lxm)\n if (serviceInfo) return serviceInfo\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport const parseProxyHeader = async (\n // Using subset of AppContext for testing purposes\n ctx: Pick<AppContext, 'cfg' | 'idResolver'>,\n proxyTo: string,\n): Promise<{ did: string; url: string }> => {\n // /!\\ Hot path\n\n const hashIndex = proxyTo.indexOf('#')\n\n if (hashIndex === 0) {\n throw new InvalidRequestError('no did specified in proxy header')\n }\n\n if (hashIndex === -1 || hashIndex === proxyTo.length - 1) {\n throw new InvalidRequestError('no service id specified in proxy header')\n }\n\n // More than one hash\n if (proxyTo.indexOf('#', hashIndex + 1) !== -1) {\n throw new InvalidRequestError('invalid proxy header format')\n }\n\n // Basic validation\n if (proxyTo.includes(' ')) {\n throw new InvalidRequestError('proxy header cannot contain spaces')\n }\n\n const did = proxyTo.slice(0, hashIndex)\n\n // Special case a configured appview, while still proxying correctly any other appview\n if (\n ctx.cfg.bskyAppView &&\n proxyTo === `${ctx.cfg.bskyAppView.did}#bsky_appview`\n ) {\n return { did, url: ctx.cfg.bskyAppView.url }\n }\n\n const didDoc = await ctx.idResolver.did.resolve(did)\n if (!didDoc) {\n throw new InvalidRequestError('could not resolve proxy did')\n }\n\n const serviceId = proxyTo.slice(hashIndex)\n const url = getServiceEndpoint(didDoc, { id: serviceId })\n if (!url) {\n throw new InvalidRequestError('could not resolve proxy did service url')\n }\n\n return { did, url }\n}\n\n/**\n * Utility function that wraps the undici stream() function and handles request\n * and response errors by wrapping them in XRPCError instances. This function is\n * more efficient than \"pipethroughRequest\" when a writable stream to pipe the\n * upstream response to is available.\n */\nasync function pipethroughStream(\n ctx: AppContext,\n dispatchOptions: Dispatcher.RequestOptions,\n successStreamFactory: Dispatcher.StreamFactory,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n void ctx.proxyAgent\n .stream(dispatchOptions, (upstream) => {\n if (upstream.statusCode >= 400) {\n const passThrough = new PassThrough()\n\n void tryParsingError(upstream.headers, passThrough).then((parsed) => {\n const xrpcError = new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n\n reject(xrpcError)\n }, reject)\n\n return passThrough\n }\n\n const writable = successStreamFactory(upstream)\n\n // As soon as the control was passed to the writable stream (i.e. by\n // returning the writable hereafter), pipethroughStream() is considered\n // to have succeeded. Any error occurring while writing upstream data to\n // the writable stream should be handled through the stream's error\n // state (i.e. successStreamFactory() must ensure that error events on\n // the returned writable will be handled).\n resolve()\n\n return writable\n })\n // The following catch block will be triggered with either network errors\n // or writable stream errors. In the latter case, the promise will already\n // be resolved, and reject()ing it there after will have no effect. Those\n // error would still be logged by the successStreamFactory() function.\n .catch(handleUpstreamRequestError)\n .catch(reject)\n })\n}\n\n/**\n * Utility function that wraps the undici request() function and handles request\n * and response errors by wrapping them in XRPCError instances.\n */\nasync function pipethroughRequest(\n ctx: AppContext,\n dispatchOptions: Dispatcher.RequestOptions,\n) {\n // HandlerPipeThroughStream requires a readable stream to be returned, so we\n // use the (less efficient) request() function instead.\n\n const upstream = await ctx.proxyAgent\n .request(dispatchOptions)\n .catch(handleUpstreamRequestError)\n\n if (upstream.statusCode >= 400) {\n const parsed = await tryParsingError(upstream.headers, upstream.body)\n\n throw new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n }\n\n return upstream\n}\n\nfunction handleUpstreamRequestError(\n err: unknown,\n message = 'Upstream service unreachable',\n): never {\n httpLogger.error({ err }, message)\n throw new XRPCServerError(ResponseType.UpstreamFailure, message, undefined, {\n cause: err,\n })\n}\n\n// Request parsing/forwarding\n// -------------------\n\nexport function isJsonContentType(contentType?: string): boolean | undefined {\n if (!contentType) return undefined\n return /application\\/(?:\\w+\\+)?json/i.test(contentType)\n}\n\nasync function tryParsingError(\n headers: IncomingHttpHeaders,\n readable: Readable,\n): Promise<{ error?: string; message?: string }> {\n if (isJsonContentType(headers['content-type']) === false) {\n // We don't known how to parse non JSON content types so we can discard the\n // whole response.\n\n // Since we don't care about the response, we would normally just destroy\n // the stream. However, if the underlying HTTP connection is an HTTP/1.1\n // connection, this also destroys the underlying (keep-alive) TCP socket. In\n // order to avoid destroying the TCP socket, while avoiding the cost of\n // consuming too much IO, we give it a chance to finish first.\n\n // @NOTE we need to listen (and ignore) \"error\" events, otherwise the\n // process could crash (since we drain the stream asynchronously here). This\n // is performed through the \"finished\" call below.\n\n const to = setTimeout(() => {\n readable.destroy()\n }, 100)\n finished(readable, (_err) => {\n clearTimeout(to)\n })\n readable.resume()\n\n return {}\n }\n\n try {\n const buffer = await bufferUpstreamResponse(\n readable,\n headers['content-encoding'],\n )\n\n const errInfo: unknown = JSON.parse(buffer.toString('utf8'))\n return {\n error: safeString(errInfo?.['error']),\n message: safeString(errInfo?.['message']),\n }\n } catch (err) {\n // Failed to read, decode, buffer or parse. No big deal.\n return {}\n }\n}\n\nasync function bufferUpstreamResponse(\n readable: Readable,\n contentEncoding?: string | string[],\n): Promise<Buffer> {\n try {\n return await streamToNodeBuffer(decodeStream(readable, contentEncoding))\n } catch (err) {\n if (!readable.destroyed) readable.destroy()\n\n throw new XRPCServerError(\n ResponseType.UpstreamFailure,\n err instanceof TypeError ? err.message : 'unable to decode request body',\n undefined,\n { cause: err },\n )\n }\n}\n\nexport async function asPipeThroughBuffer(\n input: HandlerPipeThroughStream,\n): Promise<HandlerPipeThroughBuffer> {\n return {\n buffer: await bufferUpstreamResponse(\n input.stream,\n input.headers?.['content-encoding'],\n ),\n headers: omit(input.headers, ['content-encoding', 'content-length']),\n encoding: input.encoding,\n }\n}\n\n// Response parsing/forwarding\n// -------------------\n\nconst RES_HEADERS_TO_FORWARD = [\n 'atproto-repo-rev',\n 'atproto-content-labelers',\n 'retry-after',\n]\n\nfunction* responseHeaders(\n headers: IncomingHttpHeaders,\n includeContentHeaders = true,\n): Generator<[string, string]> {\n if (includeContentHeaders) {\n const length = headers['content-length']\n if (length) yield ['content-length', length]\n\n const encoding = headers['content-encoding']\n if (encoding) yield ['content-encoding', encoding]\n\n const type = headers['content-type']\n if (type) yield ['content-type', type]\n\n const language = headers['content-language']\n if (language) yield ['content-language', language]\n }\n\n for (let i = 0; i < RES_HEADERS_TO_FORWARD.length; i++) {\n const name = RES_HEADERS_TO_FORWARD[i]\n const val = headers[name]\n\n if (val != null) {\n const value: string = Array.isArray(val) ? val.join(',') : val\n yield [name, value]\n }\n }\n}\n\n// Utils\n// -------------------\n\n/**\n * Performs lexicon method matching on a set of methods,\n * taking into account that they are treated case-insensitively.\n */\nexport class LxmSet {\n private inner: Set<string>\n private original: Iterable<string>\n constructor(items: Iterable<string>) {\n this.inner = new Set(Array.from(items, normalizeLxm))\n this.original = items\n }\n has(lxm: string) {\n return this.inner.has(normalizeLxm(lxm))\n }\n *[Symbol.iterator](): Iterator<string> {\n yield* this.original\n }\n}\n\nexport function normalizeLxm(lxm: string) {\n return lxm.toLowerCase()\n}\n\nexport const CHAT_BSKY_METHODS = new LxmSet([\n chat.bsky.actor.deleteAccount.$lxm,\n chat.bsky.actor.exportAccountData.$lxm,\n chat.bsky.convo.deleteMessageForSelf.$lxm,\n chat.bsky.convo.getConvo.$lxm,\n chat.bsky.convo.getConvoForMembers.$lxm,\n chat.bsky.convo.getLog.$lxm,\n chat.bsky.convo.getMessages.$lxm,\n chat.bsky.convo.leaveConvo.$lxm,\n chat.bsky.convo.listConvos.$lxm,\n chat.bsky.convo.muteConvo.$lxm,\n chat.bsky.convo.sendMessage.$lxm,\n chat.bsky.convo.sendMessageBatch.$lxm,\n chat.bsky.convo.unmuteConvo.$lxm,\n chat.bsky.convo.updateRead.$lxm,\n])\n\nexport const PRIVILEGED_METHODS = new LxmSet([\n ...CHAT_BSKY_METHODS,\n com.atproto.server.createAccount.$lxm,\n])\n\n// These endpoints are related to account management and must be used directly,\n// not proxied or service-authed. Service auth may be utilized between PDS and\n// entryway for these methods.\nexport const PROTECTED_METHODS = new LxmSet([\n com.atproto.admin.sendEmail.$lxm,\n com.atproto.identity.requestPlcOperationSignature.$lxm,\n com.atproto.identity.signPlcOperation.$lxm,\n com.atproto.identity.updateHandle.$lxm,\n com.atproto.server.activateAccount.$lxm,\n com.atproto.server.confirmEmail.$lxm,\n com.atproto.server.createAppPassword.$lxm,\n com.atproto.server.deactivateAccount.$lxm,\n com.atproto.server.getAccountInviteCodes.$lxm,\n com.atproto.server.getSession.$lxm,\n com.atproto.server.listAppPasswords.$lxm,\n com.atproto.server.requestAccountDelete.$lxm,\n com.atproto.server.requestEmailConfirmation.$lxm,\n com.atproto.server.requestEmailUpdate.$lxm,\n com.atproto.server.revokeAppPassword.$lxm,\n com.atproto.server.updateEmail.$lxm,\n])\n\nconst defaultService = (\n ctx: AppContext,\n nsid: string,\n): {\n serviceId: string\n serviceInfo: { url: string; did: string } | null\n} => {\n switch (nsid) {\n case tools.ozone.communication.createTemplate.$lxm:\n case tools.ozone.communication.deleteTemplate.$lxm:\n case tools.ozone.communication.listTemplates.$lxm:\n case tools.ozone.communication.updateTemplate.$lxm:\n case tools.ozone.moderation.cancelScheduledActions.$lxm:\n case tools.ozone.moderation.emitEvent.$lxm:\n case tools.ozone.moderation.getAccountTimeline.$lxm:\n case tools.ozone.moderation.getEvent.$lxm:\n case tools.ozone.moderation.getRecord.$lxm:\n case tools.ozone.moderation.getRepo.$lxm:\n case tools.ozone.moderation.listScheduledActions.$lxm:\n case tools.ozone.moderation.queryEvents.$lxm:\n case tools.ozone.moderation.queryStatuses.$lxm:\n case tools.ozone.moderation.scheduleAction.$lxm:\n case tools.ozone.moderation.searchRepos.$lxm:\n case tools.ozone.safelink.addRule.$lxm:\n case tools.ozone.safelink.queryEvents.$lxm:\n case tools.ozone.safelink.queryRules.$lxm:\n case tools.ozone.safelink.removeRule.$lxm:\n case tools.ozone.safelink.updateRule.$lxm:\n case tools.ozone.team.addMember.$lxm:\n case tools.ozone.team.deleteMember.$lxm:\n case tools.ozone.team.listMembers.$lxm:\n case tools.ozone.team.updateMember.$lxm:\n case tools.ozone.verification.grantVerifications.$lxm:\n case tools.ozone.verification.listVerifications.$lxm:\n case tools.ozone.verification.revokeVerifications.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.modService,\n }\n case com.atproto.moderation.createReport.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.reportService,\n }\n default:\n return {\n serviceId: 'bsky_appview',\n serviceInfo: ctx.cfg.bskyAppView,\n }\n }\n}\n\nconst safeString = (str: unknown): string | undefined => {\n return typeof str === 'string' ? str : undefined\n}\n\nfunction logResponseError(this: ServerResponse, err: unknown): void {\n httpLogger.warn({ err }, 'error forwarding upstream response')\n}\n\nexport class PipethroughUpstreamError extends XRPCServerError {\n constructor(\n readonly upstream: {\n statusCode: number\n headers: IncomingHttpHeaders\n },\n payload: { message?: string; error?: string },\n options?: ErrorOptions,\n ) {\n const status =\n upstream.statusCode === 500\n ? ResponseType.UpstreamFailure\n : upstream.statusCode\n\n super(status, payload.message, payload.error, options)\n }\n\n get headers(): Record<string, string> {\n return Object.fromEntries(responseHeaders(this.upstream.headers, false))\n }\n\n get error() {\n return this.customErrorName ?? this.typeName\n }\n}\n"]}
1
+ {"version":3,"file":"pipethrough.js","sourceRoot":"","sources":["../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,QAGR,EACD,OAA6C,EAC7C,OAAsB;QAEtB,MAAM,MAAM,GACV,QAAQ,CAAC,UAAU,KAAK,GAAG;YACzB,CAAC,CAAC,0BAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAA;QAEzB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAZtD;;;;mBAAS,QAAQ;WAGhB;IAUH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAA;IAC9C,CAAC;CACF;AAxBD,4DAwBC","sourcesContent":["import { IncomingHttpHeaders, ServerResponse } from 'node:http'\nimport { PassThrough, Readable, finished } from 'node:stream'\nimport { Request } from 'express'\nimport { Dispatcher } from 'undici'\nimport {\n decodeStream,\n getServiceEndpoint,\n omit,\n streamToNodeBuffer,\n} from '@atproto/common'\nimport { RpcPermissionMatch } from '@atproto/oauth-scopes'\nimport {\n CatchallHandler,\n HandlerPipeThroughBuffer,\n HandlerPipeThroughStream,\n InternalServerError,\n InvalidRequestError,\n ResponseType,\n XRPCError as XRPCServerError,\n excludeErrorResult,\n parseReqNsid,\n} from '@atproto/xrpc-server'\nimport { buildProxiedContentEncoding } from '@atproto-labs/xrpc-utils'\nimport { isAccessPrivileged } from './auth-scope'\nimport { AppContext } from './context'\nimport { chat, com, tools } from './lexicons/index.js'\nimport { httpLogger } from './logger'\n\nexport const proxyHandler = (ctx: AppContext): CatchallHandler => {\n const performAuth = ctx.authVerifier.authorization<RpcPermissionMatch>({\n authorize: (permissions, { params }) => permissions.assertRpc(params),\n })\n\n return async (req, res, next) => {\n // /!\\ Hot path\n try {\n if (\n req.method !== 'GET' &&\n req.method !== 'HEAD' &&\n req.method !== 'POST'\n ) {\n throw new XRPCServerError(\n ResponseType.InvalidRequest,\n 'XRPC requests only supports GET and POST',\n )\n }\n\n const body = req.method === 'POST' ? req : undefined\n if (body != null && !body.readable) {\n // Body was already consumed by a previous middleware\n throw new InternalServerError('Request body is not readable')\n }\n\n const lxm = parseReqNsid(req)\n if (PROTECTED_METHODS.has(lxm)) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const authResult = await performAuth({ req, res, params: { lxm, aud } })\n\n const { credentials } = excludeErrorResult(authResult)\n\n if (\n credentials.type === 'access' &&\n !isAccessPrivileged(credentials.scope) &&\n PRIVILEGED_METHODS.has(lxm)\n ) {\n throw new InvalidRequestError('Bad token method', 'InvalidToken')\n }\n\n const headers: IncomingHttpHeaders = {\n 'accept-encoding': req.headers['accept-encoding'] || 'identity',\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n 'content-type': body && req.headers['content-type'],\n 'content-encoding': body && req.headers['content-encoding'],\n 'content-length': body && req.headers['content-length'],\n\n authorization: `Bearer ${await ctx.serviceAuthJwt(credentials.did, aud, lxm)}`,\n }\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n body,\n headers,\n }\n\n await pipethroughStream(ctx, req, dispatchOptions, (upstream) => {\n res.status(upstream.statusCode)\n\n for (const [name, val] of responseHeaders(upstream.headers)) {\n res.setHeader(name, val)\n }\n\n // Note that we should not need to manually handle errors here (e.g. by\n // destroying the response), as the http server will handle them for us.\n res.on('error', logResponseError)\n\n // Tell undici to write the upstream response directly to the response\n return res\n })\n } catch (err) {\n next(err)\n }\n }\n}\n\nexport type PipethroughOptions = {\n /**\n * Specify the issuer (requester) for service auth. If not provided, no\n * authorization headers will be added to the request.\n */\n iss?: string\n\n /**\n * Override the audience for service auth. If not provided, the audience will\n * be determined based on the proxy service.\n */\n aud?: string\n\n /**\n * Override the lexicon method for service auth. If not provided, the lexicon\n * method will be determined based on the request path.\n */\n lxm?: string\n}\n\nexport async function pipethrough(\n ctx: AppContext,\n req: Request,\n options?: PipethroughOptions,\n): Promise<\n HandlerPipeThroughStream & {\n stream: Readable\n headers: Record<string, string>\n encoding: string\n }\n> {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n // pipethrough() is used from within xrpcServer handlers, which means that\n // the request body either has been parsed or is a readable stream that has\n // been piped for decoding & size limiting. Because of this, forwarding the\n // request body requires re-encoding it. Since we currently do not use\n // pipethrough() with procedures, proxying of request body is not\n // implemented.\n throw new InternalServerError(\n `Proxying of ${req.method} requests is not supported`,\n )\n }\n\n const lxm = parseReqNsid(req)\n\n const { url: origin, did: aud } = await parseProxyInfo(ctx, req, lxm)\n\n const dispatchOptions: Dispatcher.RequestOptions = {\n origin,\n method: req.method,\n path: req.originalUrl,\n headers: {\n 'accept-language': req.headers['accept-language'],\n 'atproto-accept-labelers': req.headers['atproto-accept-labelers'],\n 'x-bsky-topics': req.headers['x-bsky-topics'],\n\n // Because we sometimes need to interpret the response (e.g. during\n // read-after-write, through asPipeThroughBuffer()), we need to ask the\n // upstream server for an encoding that both the requester and the PDS can\n // understand. Since we might have to do the decoding ourselves, we will\n // use our own preferences (and weight) to negotiate the encoding.\n 'accept-encoding': buildProxiedContentEncoding(\n req.headers['accept-encoding'],\n ctx.cfg.proxy.preferCompressed,\n ),\n\n authorization: options?.iss\n ? `Bearer ${await ctx.serviceAuthJwt(options.iss, options.aud ?? aud, options.lxm ?? lxm)}`\n : undefined,\n },\n\n // Use a high water mark to buffer more data while performing async\n // operations before this stream is consumed. This is especially useful\n // while processing read-after-write operations.\n highWaterMark: 2 * 65536, // twice the default (64KiB)\n }\n\n const { headers, body } = await pipethroughRequest(ctx, req, dispatchOptions)\n\n return {\n encoding: safeString(headers['content-type']) ?? 'application/json',\n headers: Object.fromEntries(responseHeaders(headers)),\n stream: body,\n }\n}\n\n// Request setup/formatting\n// -------------------\n\nexport function computeProxyTo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): string {\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return proxyToHeader\n\n const service = defaultService(ctx, lxm)\n if (service.serviceInfo) {\n return `${service.serviceInfo.did}#${service.serviceId}`\n }\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport async function parseProxyInfo(\n ctx: AppContext,\n req: Request,\n lxm: string,\n): Promise<{ url: string; did: string }> {\n // /!\\ Hot path\n\n const proxyToHeader = req.header('atproto-proxy')\n if (proxyToHeader) return parseProxyHeader(ctx, proxyToHeader)\n\n const { serviceInfo } = defaultService(ctx, lxm)\n if (serviceInfo) return serviceInfo\n\n throw new InvalidRequestError(`No service configured for ${lxm}`)\n}\n\nexport const parseProxyHeader = async (\n // Using subset of AppContext for testing purposes\n ctx: Pick<AppContext, 'cfg' | 'idResolver'>,\n proxyTo: string,\n): Promise<{ did: string; url: string }> => {\n // /!\\ Hot path\n\n const hashIndex = proxyTo.indexOf('#')\n\n if (hashIndex === 0) {\n throw new InvalidRequestError('no did specified in proxy header')\n }\n\n if (hashIndex === -1 || hashIndex === proxyTo.length - 1) {\n throw new InvalidRequestError('no service id specified in proxy header')\n }\n\n // More than one hash\n if (proxyTo.indexOf('#', hashIndex + 1) !== -1) {\n throw new InvalidRequestError('invalid proxy header format')\n }\n\n // Basic validation\n if (proxyTo.includes(' ')) {\n throw new InvalidRequestError('proxy header cannot contain spaces')\n }\n\n const did = proxyTo.slice(0, hashIndex)\n\n // Special case a configured appview, while still proxying correctly any other appview\n if (\n ctx.cfg.bskyAppView &&\n proxyTo === `${ctx.cfg.bskyAppView.did}#bsky_appview`\n ) {\n return { did, url: ctx.cfg.bskyAppView.url }\n }\n\n const didDoc = await ctx.idResolver.did.resolve(did)\n if (!didDoc) {\n throw new InvalidRequestError('could not resolve proxy did')\n }\n\n const serviceId = proxyTo.slice(hashIndex)\n const url = getServiceEndpoint(didDoc, { id: serviceId })\n if (!url) {\n throw new InvalidRequestError('could not resolve proxy did service url')\n }\n\n return { did, url }\n}\n\n/**\n * Utility function that wraps the undici stream() function and handles request\n * and response errors by wrapping them in XRPCError instances. This function is\n * more efficient than \"pipethroughRequest\" when a writable stream to pipe the\n * upstream response to is available.\n */\nasync function pipethroughStream(\n ctx: AppContext,\n req: Request,\n dispatchOptions: Dispatcher.RequestOptions,\n successStreamFactory: Dispatcher.StreamFactory,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n void ctx.proxyAgent\n .stream(dispatchOptions, (upstream) => {\n if (upstream.statusCode >= 400) {\n const passThrough = new PassThrough()\n\n void tryParsingError(upstream.headers, passThrough).then((parsed) => {\n const xrpcError = new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n\n reject(xrpcError)\n }, reject)\n\n return passThrough\n }\n\n const writable = successStreamFactory(upstream)\n\n // As soon as the control was passed to the writable stream (i.e. by\n // returning the writable hereafter), pipethroughStream() is considered\n // to have succeeded. Any error occurring while writing upstream data to\n // the writable stream should be handled through the stream's error\n // state (i.e. successStreamFactory() must ensure that error events on\n // the returned writable will be handled).\n resolve()\n\n return writable\n })\n // The following catch block will be triggered with either network errors\n // or writable stream errors. In the latter case, the promise will already\n // be resolved, and reject()ing it there after will have no effect. Those\n // error would still be logged by the successStreamFactory() function.\n .catch(handleUpstreamRequestError.bind(req))\n .catch(reject)\n })\n}\n\n/**\n * Utility function that wraps the undici request() function and handles request\n * and response errors by wrapping them in XRPCError instances.\n */\nasync function pipethroughRequest(\n ctx: AppContext,\n req: Request,\n dispatchOptions: Dispatcher.RequestOptions,\n) {\n // HandlerPipeThroughStream requires a readable stream to be returned, so we\n // use the (less efficient) request() function instead.\n\n const upstream = await ctx.proxyAgent\n .request(dispatchOptions)\n .catch(handleUpstreamRequestError.bind(req))\n\n if (upstream.statusCode >= 400) {\n const parsed = await tryParsingError(upstream.headers, upstream.body)\n\n throw new PipethroughUpstreamError(upstream, parsed, {\n cause: dispatchOptions,\n })\n }\n\n return upstream\n}\n\nfunction handleUpstreamRequestError(\n this: Request,\n err: unknown,\n message = 'Upstream service unreachable',\n): never {\n const logger = isPinoHttpRequest(this) ? this.log : httpLogger\n logger.error({ err }, message)\n throw new XRPCServerError(ResponseType.UpstreamFailure, message, undefined, {\n cause: err,\n })\n}\n\nfunction isPinoHttpRequest(req: Request): req is Request & {\n log: { error: (obj: unknown, msg: string) => void }\n} {\n return typeof (req as { log?: any }).log?.error === 'function'\n}\n\n// Request parsing/forwarding\n// -------------------\n\nexport function isJsonContentType(contentType?: string): boolean | undefined {\n if (!contentType) return undefined\n return /application\\/(?:\\w+\\+)?json/i.test(contentType)\n}\n\nasync function tryParsingError(\n headers: IncomingHttpHeaders,\n readable: Readable,\n): Promise<{ error?: string; message?: string }> {\n if (isJsonContentType(headers['content-type']) === false) {\n // We don't known how to parse non JSON content types so we can discard the\n // whole response.\n\n // Since we don't care about the response, we would normally just destroy\n // the stream. However, if the underlying HTTP connection is an HTTP/1.1\n // connection, this also destroys the underlying (keep-alive) TCP socket. In\n // order to avoid destroying the TCP socket, while avoiding the cost of\n // consuming too much IO, we give it a chance to finish first.\n\n // @NOTE we need to listen (and ignore) \"error\" events, otherwise the\n // process could crash (since we drain the stream asynchronously here). This\n // is performed through the \"finished\" call below.\n\n const to = setTimeout(() => {\n readable.destroy()\n }, 100)\n finished(readable, (_err) => {\n clearTimeout(to)\n })\n readable.resume()\n\n return {}\n }\n\n try {\n const buffer = await bufferUpstreamResponse(\n readable,\n headers['content-encoding'],\n )\n\n const errInfo: unknown = JSON.parse(buffer.toString('utf8'))\n return {\n error: safeString(errInfo?.['error']),\n message: safeString(errInfo?.['message']),\n }\n } catch (err) {\n // Failed to read, decode, buffer or parse. No big deal.\n return {}\n }\n}\n\nasync function bufferUpstreamResponse(\n readable: Readable,\n contentEncoding?: string | string[],\n): Promise<Buffer> {\n try {\n return await streamToNodeBuffer(decodeStream(readable, contentEncoding))\n } catch (err) {\n if (!readable.destroyed) readable.destroy()\n\n throw new XRPCServerError(\n ResponseType.UpstreamFailure,\n err instanceof TypeError ? err.message : 'unable to decode request body',\n undefined,\n { cause: err },\n )\n }\n}\n\nexport async function asPipeThroughBuffer(\n input: HandlerPipeThroughStream,\n): Promise<HandlerPipeThroughBuffer> {\n return {\n buffer: await bufferUpstreamResponse(\n input.stream,\n input.headers?.['content-encoding'],\n ),\n headers: omit(input.headers, ['content-encoding', 'content-length']),\n encoding: input.encoding,\n }\n}\n\n// Response parsing/forwarding\n// -------------------\n\nconst RES_HEADERS_TO_FORWARD = [\n 'atproto-repo-rev',\n 'atproto-content-labelers',\n 'retry-after',\n]\n\nfunction* responseHeaders(\n headers: IncomingHttpHeaders,\n includeContentHeaders = true,\n): Generator<[string, string]> {\n if (includeContentHeaders) {\n const length = headers['content-length']\n if (length) yield ['content-length', length]\n\n const encoding = headers['content-encoding']\n if (encoding) yield ['content-encoding', encoding]\n\n const type = headers['content-type']\n if (type) yield ['content-type', type]\n\n const language = headers['content-language']\n if (language) yield ['content-language', language]\n }\n\n for (let i = 0; i < RES_HEADERS_TO_FORWARD.length; i++) {\n const name = RES_HEADERS_TO_FORWARD[i]\n const val = headers[name]\n\n if (val != null) {\n const value: string = Array.isArray(val) ? val.join(',') : val\n yield [name, value]\n }\n }\n}\n\n// Utils\n// -------------------\n\n/**\n * Performs lexicon method matching on a set of methods,\n * taking into account that they are treated case-insensitively.\n */\nexport class LxmSet {\n private inner: Set<string>\n private original: Iterable<string>\n constructor(items: Iterable<string>) {\n this.inner = new Set(Array.from(items, normalizeLxm))\n this.original = items\n }\n has(lxm: string) {\n return this.inner.has(normalizeLxm(lxm))\n }\n *[Symbol.iterator](): Iterator<string> {\n yield* this.original\n }\n}\n\nexport function normalizeLxm(lxm: string) {\n return lxm.toLowerCase()\n}\n\nexport const CHAT_BSKY_METHODS = new LxmSet([\n chat.bsky.actor.deleteAccount.$lxm,\n chat.bsky.actor.exportAccountData.$lxm,\n chat.bsky.convo.deleteMessageForSelf.$lxm,\n chat.bsky.convo.getConvo.$lxm,\n chat.bsky.convo.getConvoForMembers.$lxm,\n chat.bsky.convo.getLog.$lxm,\n chat.bsky.convo.getMessages.$lxm,\n chat.bsky.convo.leaveConvo.$lxm,\n chat.bsky.convo.listConvos.$lxm,\n chat.bsky.convo.muteConvo.$lxm,\n chat.bsky.convo.sendMessage.$lxm,\n chat.bsky.convo.sendMessageBatch.$lxm,\n chat.bsky.convo.unmuteConvo.$lxm,\n chat.bsky.convo.updateRead.$lxm,\n])\n\nexport const PRIVILEGED_METHODS = new LxmSet([\n ...CHAT_BSKY_METHODS,\n com.atproto.server.createAccount.$lxm,\n])\n\n// These endpoints are related to account management and must be used directly,\n// not proxied or service-authed. Service auth may be utilized between PDS and\n// entryway for these methods.\nexport const PROTECTED_METHODS = new LxmSet([\n com.atproto.admin.sendEmail.$lxm,\n com.atproto.identity.requestPlcOperationSignature.$lxm,\n com.atproto.identity.signPlcOperation.$lxm,\n com.atproto.identity.updateHandle.$lxm,\n com.atproto.server.activateAccount.$lxm,\n com.atproto.server.confirmEmail.$lxm,\n com.atproto.server.createAppPassword.$lxm,\n com.atproto.server.deactivateAccount.$lxm,\n com.atproto.server.getAccountInviteCodes.$lxm,\n com.atproto.server.getSession.$lxm,\n com.atproto.server.listAppPasswords.$lxm,\n com.atproto.server.requestAccountDelete.$lxm,\n com.atproto.server.requestEmailConfirmation.$lxm,\n com.atproto.server.requestEmailUpdate.$lxm,\n com.atproto.server.revokeAppPassword.$lxm,\n com.atproto.server.updateEmail.$lxm,\n])\n\nconst defaultService = (\n ctx: AppContext,\n nsid: string,\n): {\n serviceId: string\n serviceInfo: { url: string; did: string } | null\n} => {\n switch (nsid) {\n case tools.ozone.communication.createTemplate.$lxm:\n case tools.ozone.communication.deleteTemplate.$lxm:\n case tools.ozone.communication.listTemplates.$lxm:\n case tools.ozone.communication.updateTemplate.$lxm:\n case tools.ozone.moderation.cancelScheduledActions.$lxm:\n case tools.ozone.moderation.emitEvent.$lxm:\n case tools.ozone.moderation.getAccountTimeline.$lxm:\n case tools.ozone.moderation.getEvent.$lxm:\n case tools.ozone.moderation.getRecord.$lxm:\n case tools.ozone.moderation.getRepo.$lxm:\n case tools.ozone.moderation.listScheduledActions.$lxm:\n case tools.ozone.moderation.queryEvents.$lxm:\n case tools.ozone.moderation.queryStatuses.$lxm:\n case tools.ozone.moderation.scheduleAction.$lxm:\n case tools.ozone.moderation.searchRepos.$lxm:\n case tools.ozone.safelink.addRule.$lxm:\n case tools.ozone.safelink.queryEvents.$lxm:\n case tools.ozone.safelink.queryRules.$lxm:\n case tools.ozone.safelink.removeRule.$lxm:\n case tools.ozone.safelink.updateRule.$lxm:\n case tools.ozone.team.addMember.$lxm:\n case tools.ozone.team.deleteMember.$lxm:\n case tools.ozone.team.listMembers.$lxm:\n case tools.ozone.team.updateMember.$lxm:\n case tools.ozone.verification.grantVerifications.$lxm:\n case tools.ozone.verification.listVerifications.$lxm:\n case tools.ozone.verification.revokeVerifications.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.modService,\n }\n case com.atproto.moderation.createReport.$lxm:\n return {\n serviceId: 'atproto_labeler',\n serviceInfo: ctx.cfg.reportService,\n }\n default:\n return {\n serviceId: 'bsky_appview',\n serviceInfo: ctx.cfg.bskyAppView,\n }\n }\n}\n\nconst safeString = (str: unknown): string | undefined => {\n return typeof str === 'string' ? str : undefined\n}\n\nfunction logResponseError(this: ServerResponse, err: unknown): void {\n httpLogger.warn({ err }, 'error forwarding upstream response')\n}\n\nexport class PipethroughUpstreamError extends XRPCServerError {\n constructor(\n readonly upstream: {\n statusCode: number\n headers: IncomingHttpHeaders\n },\n payload: { message?: string; error?: string },\n options?: ErrorOptions,\n ) {\n const status =\n upstream.statusCode === 500\n ? ResponseType.UpstreamFailure\n : upstream.statusCode\n\n super(status, payload.message, payload.error, options)\n }\n\n get headers(): Record<string, string> {\n return Object.fromEntries(responseHeaders(this.upstream.headers, false))\n }\n\n get error() {\n return this.customErrorName ?? this.typeName\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../src/read-after-write/viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAS,SAAS,EAAgC,MAAM,iBAAiB,CAAA;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEtD,KAAK,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,gBAAgB,GAAG,eAAe,CAAA;AAEhF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,gBAAgB,EAAE,gBAAgB,KAC/B,WAAW,CAAA;AAEhB,qBAAa,WAAW;aAEJ,gBAAgB,EAAE,gBAAgB;aAClC,cAAc,EAAE,cAAc;aAC9B,eAAe,EAAE,eAAe;aAChC,WAAW,CAAC,EAAE,WAAW;gBAHzB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,WAAW,CAAC,EAAE,WAAW,YAAA;IAG3C,IAAI,GAAG,IAC+B,SAAS,CAC9C;IAED,MAAM,CAAC,OAAO,CACZ,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,WAAW,CAAC,EAAE,WAAW,GACxB,kBAAkB;IAKrB,WAAW,CAAC,OAAO,EAAE,gBAAgB,EAAE,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AAK,CAAC,IAAI,CAAC,WAAW,EACnC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;IAOlD,qBAAqB,CAAC,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,EACrE,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,GAClC,CAAC;CAQL"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalViewer = void 0;
4
+ const lex_1 = require("@atproto/lex");
4
5
  const syntax_1 = require("@atproto/syntax");
5
6
  const xrpc_server_1 = require("@atproto/xrpc-server");
6
7
  const index_js_1 = require("../lexicons/index.js");
@@ -67,7 +68,7 @@ class LocalViewer {
67
68
  handle: (accountRes.handle ?? syntax_1.INVALID_HANDLE),
68
69
  displayName: profileRes?.displayName,
69
70
  avatar: profileRes?.avatar
70
- ? this.getImageUrl('avatar', profileRes.avatar.ref.toString())
71
+ ? this.getImageUrl('avatar', (0, lex_1.getBlobCidString)(profileRes.avatar))
71
72
  : undefined,
72
73
  };
73
74
  }
@@ -132,8 +133,8 @@ class LocalViewer {
132
133
  }
133
134
  formatImageEmbed(embed) {
134
135
  const images = embed.images.map((img) => ({
135
- thumb: this.getImageUrl('feed_thumbnail', img.image.ref.toString()),
136
- fullsize: this.getImageUrl('feed_fullsize', img.image.ref.toString()),
136
+ thumb: this.getImageUrl('feed_thumbnail', (0, lex_1.getBlobCidString)(img.image)),
137
+ fullsize: this.getImageUrl('feed_fullsize', (0, lex_1.getBlobCidString)(img.image)),
137
138
  aspectRatio: img.aspectRatio,
138
139
  alt: img.alt,
139
140
  }));
@@ -147,7 +148,7 @@ class LocalViewer {
147
148
  title,
148
149
  description,
149
150
  thumb: thumb
150
- ? this.getImageUrl('feed_thumbnail', thumb.ref.toString())
151
+ ? this.getImageUrl('feed_thumbnail', (0, lex_1.getBlobCidString)(thumb))
151
152
  : undefined,
152
153
  },
153
154
  });
@@ -214,7 +215,7 @@ class LocalViewer {
214
215
  ...view,
215
216
  displayName: record.displayName,
216
217
  avatar: record.avatar
217
- ? this.getImageUrl('avatar', record.avatar.ref.toString())
218
+ ? this.getImageUrl('avatar', (0, lex_1.getBlobCidString)(record.avatar))
218
219
  : undefined,
219
220
  };
220
221
  }
@@ -228,7 +229,7 @@ class LocalViewer {
228
229
  return {
229
230
  ...this.updateProfileView(view, record),
230
231
  banner: record.banner
231
- ? this.getImageUrl('banner', record.banner.ref.toString())
232
+ ? this.getImageUrl('banner', (0, lex_1.getBlobCidString)(record.banner))
232
233
  : undefined,
233
234
  };
234
235
  }
@@ -1 +1 @@
1
- {"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/read-after-write/viewer.ts"],"names":[],"mappings":";;;AACA,4CAAgF;AAChF,sDAA+D;AAK/D,mDAA0C;AAS1C,MAAa,WAAW;IACtB,YACkB,gBAAkC,EAClC,cAA8B,EAC9B,eAAgC,EAChC,WAAyB;QAHzC;;;;mBAAgB,gBAAgB;WAAkB;QAClD;;;;mBAAgB,cAAc;WAAgB;QAC9C;;;;mBAAgB,eAAe;WAAiB;QAChD;;;;mBAAgB,WAAW;WAAc;IACxC,CAAC;IAEJ,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAgB,CAAA;IAC/C,CAAC;IAED,MAAM,CAAC,OAAO,CACZ,cAA8B,EAC9B,eAAgC,EAChC,WAAyB;QAEzB,OAAO,CAAC,UAAU,EAAE,EAAE,CACpB,IAAI,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,CAAC,CAAA;IAC7E,CAAC;IAED,WAAW,CAAC,OAAyB,EAAE,GAAW;QAChD,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE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AAW,EAAE,MAAM,CAAC,WAAW;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACnB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAC1D,CAAC,CAAC,SAAS;SACd,CAAA;IACH,CAAC;IAED,iBAAiB,CAKf,IAAO,EAAE,MAAmC;QAC5C,OAAO;YACL,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC;YAC5C,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAA;IACH,CAAC;IAED,qBAAqB,CACnB,IAAO,EACP,MAAmC;QAEnC,OAAO;YACL,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACnB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAC1D,CAAC,CAAC,SAAS;SACd,CAAA;IACH,CAAC;CACF;AA9QD,kCA8QC","sourcesContent":["import { LexMap, UriString } from '@atproto/lex'\nimport { AtUri, DidString, HandleString, INVALID_HANDLE } from '@atproto/syntax'\nimport { createServiceAuthHeaders } from '@atproto/xrpc-server'\nimport { AccountManager } from '../account-manager/account-manager'\nimport { ActorStoreReader } from '../actor-store/actor-store-reader'\nimport { BskyAppView } from '../bsky-app-view'\nimport { ImageUrlBuilder } from '../image/image-url-builder'\nimport { app } from '../lexicons/index.js'\nimport { LocalRecords, RecordDescript } from './types'\n\ntype CommonSignedUris = 'avatar' | 'banner' | 'feed_thumbnail' | 'feed_fullsize'\n\nexport type LocalViewerCreator = (\n actorStoreReader: ActorStoreReader,\n) => LocalViewer\n\nexport class LocalViewer {\n constructor(\n public readonly actorStoreReader: ActorStoreReader,\n public readonly accountManager: AccountManager,\n public readonly imageUrlBuilder: ImageUrlBuilder,\n public readonly bskyAppView?: BskyAppView,\n ) {}\n\n get did() {\n return this.actorStoreReader.did as DidString\n }\n\n static creator(\n accountManager: AccountManager,\n imageUrlBuilder: ImageUrlBuilder,\n bskyAppView?: BskyAppView,\n ): LocalViewerCreator {\n return (actorStore) =>\n new LocalViewer(actorStore, accountManager, imageUrlBuilder, bskyAppView)\n }\n\n getImageUrl(pattern: CommonSignedUris, cid: string) {\n return this.imageUrlBuilder.build(pattern, this.did, cid) as UriString\n }\n\n async serviceAuthHeaders(did: string, lxm: string) {\n if (!this.bskyAppView) {\n throw new Error('Could not find bsky appview did')\n }\n const keypair = await this.actorStoreReader.keypair()\n\n return createServiceAuthHeaders({\n iss: did,\n aud: this.bskyAppView.did,\n lxm,\n keypair,\n })\n }\n\n async getRecordsSinceRev(rev: string): Promise<LocalRecords> {\n return this.actorStoreReader.record.getRecordsSinceRev(rev)\n }\n\n async getProfileBasic(): Promise<app.bsky.actor.defs.ProfileViewBasic | null> {\n const [profileRes, accountRes] = await Promise.all([\n this.actorStoreReader.record.getProfileRecord(),\n this.accountManager.getAccount(this.did),\n ])\n\n if (!accountRes) return null\n\n return {\n did: this.did,\n handle: (accountRes.handle ?? INVALID_HANDLE) as HandleString,\n displayName: profileRes?.displayName,\n avatar: profileRes?.avatar\n ? this.getImageUrl('avatar', profileRes.avatar.ref.toString())\n : undefined,\n }\n }\n\n async formatAndInsertPostsInFeed(\n feed: app.bsky.feed.defs.FeedViewPost[],\n posts: RecordDescript<app.bsky.feed.post.Main>[],\n ): Promise<app.bsky.feed.defs.FeedViewPost[]> {\n if (posts.length === 0) {\n return feed\n }\n const lastTime = feed.at(-1)?.post.indexedAt ?? new Date(0).toISOString()\n const inFeed = posts.filter((p) => p.indexedAt > lastTime)\n const newestToOldest = inFeed.reverse()\n const maybeFormatted = await Promise.all(\n newestToOldest.map((p) => this.getPost(p)),\n )\n const formatted = maybeFormatted.filter(\n (p) => p !== null,\n ) as app.bsky.feed.defs.PostView[]\n for (const post of formatted) {\n const idx = feed.findIndex((fi) => fi.post.indexedAt < post.indexedAt)\n if (idx >= 0) {\n feed.splice(idx, 0, { post })\n } else {\n feed.push({ post })\n }\n }\n return feed\n }\n\n async getPost(\n descript: RecordDescript<app.bsky.feed.post.Main>,\n ): Promise<app.bsky.feed.defs.PostView | null> {\n const { uri, cid, indexedAt, record } = descript\n const author = await this.getProfileBasic()\n if (!author) return null\n const embed = record.embed ? await this.formatPostEmbed(record) : undefined\n return {\n uri: uri.toString(),\n cid: cid.toString(),\n likeCount: 0, // counts presumed to be 0 directly after post creation\n replyCount: 0,\n repostCount: 0,\n quoteCount: 0,\n author,\n record: record as LexMap,\n embed,\n indexedAt,\n }\n }\n\n async formatPostEmbed(post: app.bsky.feed.post.Main) {\n const embed = post.embed\n if (!embed) return undefined\n if (app.bsky.embed.images.$isTypeOf(embed)) {\n return this.formatImageEmbed(embed)\n } else if (app.bsky.embed.external.$isTypeOf(embed)) {\n return this.formatExternalEmbed(embed)\n } else if (app.bsky.embed.record.$isTypeOf(embed)) {\n return this.formatRecordEmbed(embed)\n } else if (app.bsky.embed.recordWithMedia.$isTypeOf(embed)) {\n return this.formatRecordWithMediaEmbed(embed)\n } else {\n return undefined\n }\n }\n\n formatImageEmbed(embed: app.bsky.embed.images.Main) {\n const images = embed.images.map(\n (img): app.bsky.embed.images.ViewImage => ({\n thumb: this.getImageUrl('feed_thumbnail', img.image.ref.toString()),\n fullsize: this.getImageUrl('feed_fullsize', img.image.ref.toString()),\n aspectRatio: img.aspectRatio,\n alt: img.alt,\n }),\n )\n return app.bsky.embed.images.view.$build({ images })\n }\n\n formatExternalEmbed(embed: app.bsky.embed.external.Main) {\n const { uri, title, description, thumb } = embed.external\n return app.bsky.embed.external.view.$build({\n external: {\n uri,\n title,\n description,\n thumb: thumb\n ? this.getImageUrl('feed_thumbnail', thumb.ref.toString())\n : undefined,\n },\n })\n }\n\n async formatRecordEmbed(embed: app.bsky.embed.record.Main) {\n const view = await this.formatRecordEmbedInternal(embed)\n return app.bsky.embed.record.view.$build({\n record:\n view ??\n app.bsky.embed.record.viewNotFound.$build({\n uri: embed.record.uri,\n notFound: true,\n }),\n })\n }\n\n private async formatRecordEmbedInternal(embed: app.bsky.embed.record.Main) {\n if (!this.bskyAppView) {\n return undefined\n }\n const collection = new AtUri(embed.record.uri).collection\n if (collection === app.bsky.feed.post.$type) {\n const { headers } = await this.serviceAuthHeaders(\n this.did,\n app.bsky.feed.getPosts.$lxm,\n )\n const data = await this.bskyAppView.client.call(\n app.bsky.feed.getPosts,\n { uris: [embed.record.uri] },\n { headers },\n )\n const post = data.posts[0]\n if (!post) return undefined\n\n return app.bsky.embed.record.viewRecord.$build({\n uri: post.uri,\n cid: post.cid,\n author: post.author,\n value: post.record,\n labels: post.labels,\n embeds: post.embed ? [post.embed] : undefined,\n indexedAt: post.indexedAt,\n })\n } else if (collection === app.bsky.feed.generator.$type) {\n const { headers } = await this.serviceAuthHeaders(\n this.did,\n app.bsky.feed.getFeedGenerator.$lxm,\n )\n const data = await this.bskyAppView.client.call(\n app.bsky.feed.getFeedGenerator,\n { feed: embed.record.uri },\n { headers },\n )\n return app.bsky.feed.defs.generatorView.$build(data.view)\n } else if (collection === app.bsky.graph.list.$type) {\n const { headers } = await this.serviceAuthHeaders(\n this.did,\n app.bsky.graph.getList.$lxm,\n )\n const data = await this.bskyAppView.client.call(\n app.bsky.graph.getList,\n { list: embed.record.uri },\n { headers },\n )\n return app.bsky.graph.defs.listView.$build(data.list)\n }\n return undefined\n }\n\n async formatRecordWithMediaEmbed(embed: app.bsky.embed.recordWithMedia.Main) {\n const media = app.bsky.embed.images.$isTypeOf(embed.media)\n ? this.formatImageEmbed(embed.media)\n : app.bsky.embed.external.$isTypeOf(embed.media)\n ? this.formatExternalEmbed(embed.media)\n : null\n\n if (!media) return undefined\n\n const record = await this.formatRecordEmbed(embed.record)\n return app.bsky.embed.recordWithMedia.view.$build({\n record,\n media,\n })\n }\n\n updateProfileViewBasic<\n T extends\n | app.bsky.actor.defs.ProfileViewDetailed\n | app.bsky.actor.defs.ProfileViewBasic\n | app.bsky.actor.defs.ProfileView,\n >(view: T, record: app.bsky.actor.profile.Main): T {\n return {\n ...view,\n displayName: record.displayName,\n avatar: record.avatar\n ? this.getImageUrl('avatar', record.avatar.ref.toString())\n : undefined,\n }\n }\n\n updateProfileView<\n T extends\n | app.bsky.actor.defs.ProfileViewDetailed\n | app.bsky.actor.defs.ProfileViewBasic\n | app.bsky.actor.defs.ProfileView,\n >(view: T, record: app.bsky.actor.profile.Main): T {\n return {\n ...this.updateProfileViewBasic(view, record),\n description: record.description,\n }\n }\n\n updateProfileDetailed<T extends app.bsky.actor.defs.ProfileViewDetailed>(\n view: T,\n record: app.bsky.actor.profile.Main,\n ): T {\n return {\n ...this.updateProfileView(view, record),\n banner: record.banner\n ? this.getImageUrl('banner', record.banner.ref.toString())\n : undefined,\n }\n }\n}\n"]}
1
+ {"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/read-after-write/viewer.ts"],"names":[],"mappings":";;;AAAA,sCAAkE;AAClE,4CAAgF;AAChF,sDAA+D;AAK/D,mDAA0C;AAS1C,MAAa,WAAW;IACtB,YACkB,gBAAkC,EAClC,cAA8B,EAC9B,eAAgC,EAChC,WAAyB;QAHzC;;;;mBAAgB,gBAAgB;WAAkB;QAClD;;;;mBAAgB,cAAc;WAAgB;QAC9C;;;;mBAAgB,eAAe;WAAiB;QAChD;;;;mBAAgB,WAAW;WAAc;IACxC,CAAC;IAEJ,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAgB,CAAA;IAC/C,CAAC;IAED,MAAM,CAAC,OAAO,CACZ,cAA8B,EAC9B,eAAgC,EAChC,WAAyB;QAEzB,OAAO,CAAC,UAAU,EAAE,EAAE,CACpB,IAAI,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,CAAC,CAAA;IAC7E,CAAC;IAED,WAAW,CAAC,OAAyB,E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AAE,MAAmC;QAC5C,OAAO;YACL,GAAG,IAAI;YACP,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACnB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAA,sBAAgB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC7D,CAAC,CAAC,SAAS;SACd,CAAA;IACH,CAAC;IAED,iBAAiB,CAKf,IAAO,EAAE,MAAmC;QAC5C,OAAO;YACL,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC;YAC5C,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAA;IACH,CAAC;IAED,qBAAqB,CACnB,IAAO,EACP,MAAmC;QAEnC,OAAO;YACL,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACnB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAA,sBAAgB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC7D,CAAC,CAAC,SAAS;SACd,CAAA;IACH,CAAC;CACF;AAjRD,kCAiRC","sourcesContent":["import { LexMap, UriString, getBlobCidString } from '@atproto/lex'\nimport { AtUri, DidString, HandleString, INVALID_HANDLE } from '@atproto/syntax'\nimport { createServiceAuthHeaders } from '@atproto/xrpc-server'\nimport { AccountManager } from '../account-manager/account-manager'\nimport { ActorStoreReader } from '../actor-store/actor-store-reader'\nimport { BskyAppView } from '../bsky-app-view'\nimport { ImageUrlBuilder } from '../image/image-url-builder'\nimport { app } from '../lexicons/index.js'\nimport { LocalRecords, RecordDescript } from './types'\n\ntype CommonSignedUris = 'avatar' | 'banner' | 'feed_thumbnail' | 'feed_fullsize'\n\nexport type LocalViewerCreator = (\n actorStoreReader: ActorStoreReader,\n) => LocalViewer\n\nexport class LocalViewer {\n constructor(\n public readonly actorStoreReader: ActorStoreReader,\n public readonly accountManager: AccountManager,\n public readonly imageUrlBuilder: ImageUrlBuilder,\n public readonly bskyAppView?: BskyAppView,\n ) {}\n\n get did() {\n return this.actorStoreReader.did as DidString\n }\n\n static creator(\n accountManager: AccountManager,\n imageUrlBuilder: ImageUrlBuilder,\n bskyAppView?: BskyAppView,\n ): LocalViewerCreator {\n return (actorStore) =>\n new LocalViewer(actorStore, accountManager, imageUrlBuilder, bskyAppView)\n }\n\n getImageUrl(pattern: CommonSignedUris, cid: string) {\n return this.imageUrlBuilder.build(pattern, this.did, cid) as UriString\n }\n\n async serviceAuthHeaders(did: string, lxm: string) {\n if (!this.bskyAppView) {\n throw new Error('Could not find bsky appview did')\n }\n const keypair = await this.actorStoreReader.keypair()\n\n return createServiceAuthHeaders({\n iss: did,\n aud: this.bskyAppView.did,\n lxm,\n keypair,\n })\n }\n\n async getRecordsSinceRev(rev: string): Promise<LocalRecords> {\n return this.actorStoreReader.record.getRecordsSinceRev(rev)\n }\n\n async getProfileBasic(): Promise<app.bsky.actor.defs.ProfileViewBasic | null> {\n const [profileRes, accountRes] = await Promise.all([\n this.actorStoreReader.record.getProfileRecord(),\n this.accountManager.getAccount(this.did),\n ])\n\n if (!accountRes) return null\n\n return {\n did: this.did,\n handle: (accountRes.handle ?? INVALID_HANDLE) as HandleString,\n displayName: profileRes?.displayName,\n avatar: profileRes?.avatar\n ? this.getImageUrl('avatar', getBlobCidString(profileRes.avatar))\n : undefined,\n }\n }\n\n async formatAndInsertPostsInFeed(\n feed: app.bsky.feed.defs.FeedViewPost[],\n posts: RecordDescript<app.bsky.feed.post.Main>[],\n ): Promise<app.bsky.feed.defs.FeedViewPost[]> {\n if (posts.length === 0) {\n return feed\n }\n const lastTime = feed.at(-1)?.post.indexedAt ?? new Date(0).toISOString()\n const inFeed = posts.filter((p) => p.indexedAt > lastTime)\n const newestToOldest = inFeed.reverse()\n const maybeFormatted = await Promise.all(\n newestToOldest.map((p) => this.getPost(p)),\n )\n const formatted = maybeFormatted.filter(\n (p) => p !== null,\n ) as app.bsky.feed.defs.PostView[]\n for (const post of formatted) {\n const idx = feed.findIndex((fi) => fi.post.indexedAt < post.indexedAt)\n if (idx >= 0) {\n feed.splice(idx, 0, { post })\n } else {\n feed.push({ post })\n }\n }\n return feed\n }\n\n async getPost(\n descript: RecordDescript<app.bsky.feed.post.Main>,\n ): Promise<app.bsky.feed.defs.PostView | null> {\n const { uri, cid, indexedAt, record } = descript\n const author = await this.getProfileBasic()\n if (!author) return null\n const embed = record.embed ? await this.formatPostEmbed(record) : undefined\n return {\n uri: uri.toString(),\n cid: cid.toString(),\n likeCount: 0, // counts presumed to be 0 directly after post creation\n replyCount: 0,\n repostCount: 0,\n quoteCount: 0,\n author,\n record: record as LexMap,\n embed,\n indexedAt,\n }\n }\n\n async formatPostEmbed(post: app.bsky.feed.post.Main) {\n const embed = post.embed\n if (!embed) return undefined\n if (app.bsky.embed.images.$isTypeOf(embed)) {\n return this.formatImageEmbed(embed)\n } else if (app.bsky.embed.external.$isTypeOf(embed)) {\n return this.formatExternalEmbed(embed)\n } else if (app.bsky.embed.record.$isTypeOf(embed)) {\n return this.formatRecordEmbed(embed)\n } else if (app.bsky.embed.recordWithMedia.$isTypeOf(embed)) {\n return this.formatRecordWithMediaEmbed(embed)\n } else {\n return undefined\n }\n }\n\n formatImageEmbed(embed: app.bsky.embed.images.Main) {\n const images = embed.images.map(\n (img): app.bsky.embed.images.ViewImage => ({\n thumb: this.getImageUrl('feed_thumbnail', getBlobCidString(img.image)),\n fullsize: this.getImageUrl(\n 'feed_fullsize',\n getBlobCidString(img.image),\n ),\n aspectRatio: img.aspectRatio,\n alt: img.alt,\n }),\n )\n return app.bsky.embed.images.view.$build({ images })\n }\n\n formatExternalEmbed(embed: app.bsky.embed.external.Main) {\n const { uri, title, description, thumb } = embed.external\n return app.bsky.embed.external.view.$build({\n external: {\n uri,\n title,\n description,\n thumb: thumb\n ? this.getImageUrl('feed_thumbnail', getBlobCidString(thumb))\n : undefined,\n },\n })\n }\n\n async formatRecordEmbed(embed: app.bsky.embed.record.Main) {\n const view = await this.formatRecordEmbedInternal(embed)\n return app.bsky.embed.record.view.$build({\n record:\n view ??\n app.bsky.embed.record.viewNotFound.$build({\n uri: embed.record.uri,\n notFound: true,\n }),\n })\n }\n\n private async formatRecordEmbedInternal(embed: app.bsky.embed.record.Main) {\n if (!this.bskyAppView) {\n return undefined\n }\n const collection = new AtUri(embed.record.uri).collection\n if (collection === app.bsky.feed.post.$type) {\n const { headers } = await this.serviceAuthHeaders(\n this.did,\n app.bsky.feed.getPosts.$lxm,\n )\n const data = await this.bskyAppView.client.call(\n app.bsky.feed.getPosts,\n { uris: [embed.record.uri] },\n { headers },\n )\n const post = data.posts[0]\n if (!post) return undefined\n\n return app.bsky.embed.record.viewRecord.$build({\n uri: post.uri,\n cid: post.cid,\n author: post.author,\n value: post.record,\n labels: post.labels,\n embeds: post.embed ? [post.embed] : undefined,\n indexedAt: post.indexedAt,\n })\n } else if (collection === app.bsky.feed.generator.$type) {\n const { headers } = await this.serviceAuthHeaders(\n this.did,\n app.bsky.feed.getFeedGenerator.$lxm,\n )\n const data = await this.bskyAppView.client.call(\n app.bsky.feed.getFeedGenerator,\n { feed: embed.record.uri },\n { headers },\n )\n return app.bsky.feed.defs.generatorView.$build(data.view)\n } else if (collection === app.bsky.graph.list.$type) {\n const { headers } = await this.serviceAuthHeaders(\n this.did,\n app.bsky.graph.getList.$lxm,\n )\n const data = await this.bskyAppView.client.call(\n app.bsky.graph.getList,\n { list: embed.record.uri },\n { headers },\n )\n return app.bsky.graph.defs.listView.$build(data.list)\n }\n return undefined\n }\n\n async formatRecordWithMediaEmbed(embed: app.bsky.embed.recordWithMedia.Main) {\n const media = app.bsky.embed.images.$isTypeOf(embed.media)\n ? this.formatImageEmbed(embed.media)\n : app.bsky.embed.external.$isTypeOf(embed.media)\n ? this.formatExternalEmbed(embed.media)\n : null\n\n if (!media) return undefined\n\n const record = await this.formatRecordEmbed(embed.record)\n return app.bsky.embed.recordWithMedia.view.$build({\n record,\n media,\n })\n }\n\n updateProfileViewBasic<\n T extends\n | app.bsky.actor.defs.ProfileViewDetailed\n | app.bsky.actor.defs.ProfileViewBasic\n | app.bsky.actor.defs.ProfileView,\n >(view: T, record: app.bsky.actor.profile.Main): T {\n return {\n ...view,\n displayName: record.displayName,\n avatar: record.avatar\n ? this.getImageUrl('avatar', getBlobCidString(record.avatar))\n : undefined,\n }\n }\n\n updateProfileView<\n T extends\n | app.bsky.actor.defs.ProfileViewDetailed\n | app.bsky.actor.defs.ProfileViewBasic\n | app.bsky.actor.defs.ProfileView,\n >(view: T, record: app.bsky.actor.profile.Main): T {\n return {\n ...this.updateProfileViewBasic(view, record),\n description: record.description,\n }\n }\n\n updateProfileDetailed<T extends app.bsky.actor.defs.ProfileViewDetailed>(\n view: T,\n record: app.bsky.actor.profile.Main,\n ): T {\n return {\n ...this.updateProfileView(view, record),\n banner: record.banner\n ? this.getImageUrl('banner', getBlobCidString(record.banner))\n : undefined,\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/repo/prepare.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,GAAG,EACH,MAAM,EAKP,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EAEd,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,SAAS,EACT,UAAU,EACV,eAAe,EAEhB,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EAEL,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EAEd,MAAM,SAAS,CAAA;AAyEhB,eAAO,MAAM,aAAa,GAAU,MAAM;IACxC,GAAG,EAAE,SAAS,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,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