diff --git a/.changeset/wicked-clouds-glow.md b/.changeset/wicked-clouds-glow.md new file mode 100644 index 00000000000..203857a1b58 --- /dev/null +++ b/.changeset/wicked-clouds-glow.md @@ -0,0 +1,5 @@ +--- +"@atproto/sync": patch +--- + +Pass through options to websocket diff --git a/packages/sync/package.json b/packages/sync/package.json index 4a26c909ca5..d2a3fde68f8 100644 --- a/packages/sync/package.json +++ b/packages/sync/package.json @@ -29,7 +29,8 @@ "@atproto/syntax": "workspace:^", "@atproto/xrpc-server": "workspace:^", "multiformats": "^9.9.0", - "p-queue": "^6.6.2" + "p-queue": "^6.6.2", + "ws": "^8.12.0" }, "devDependencies": { "jest": "^28.1.2", diff --git a/packages/sync/src/firehose/index.ts b/packages/sync/src/firehose/index.ts index 377c8c57289..4a03382e6c1 100644 --- a/packages/sync/src/firehose/index.ts +++ b/packages/sync/src/firehose/index.ts @@ -14,6 +14,7 @@ import { } from '@atproto/repo' import { AtUri } from '@atproto/syntax' import { Subscription } from '@atproto/xrpc-server' +import type { ClientOptions } from 'ws' import { type Account, type Commit, @@ -37,7 +38,7 @@ import { CID } from 'multiformats/cid' import { EventRunner } from '../runner' import { didAndSeqForEvt } from '../util' -export type FirehoseOptions = { +export type FirehoseOptions = ClientOptions & { idResolver: IdResolver handleEvent: (evt: Event) => Awaited @@ -70,6 +71,7 @@ export class Firehose { throw new Error('Must set only `getCursor` or `runner`') } this.sub = new Subscription({ + ...opts, service: opts.service ?? 'wss://bsky.network', method: 'com.atproto.sync.subscribeRepos', signal: this.abortController.signal, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 424882fc84c..0abdcf7ada4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1465,6 +1465,9 @@ importers: p-queue: specifier: ^6.6.2 version: 6.6.2 + ws: + specifier: ^8.12.0 + version: 8.18.0 devDependencies: jest: specifier: ^28.1.2 @@ -1675,7 +1678,7 @@ packages: '@connectrpc/connect': 1.3.0(@bufbuild/protobuf@1.6.0) '@connectrpc/connect-node': 1.3.0(@bufbuild/protobuf@1.6.0)(@connectrpc/connect@1.3.0) '@did-plc/lib': 0.0.1 - better-sqlite3: 9.4.5 + better-sqlite3: 9.6.0 bytes: 3.1.2 compression: 1.7.4 cors: 2.8.5 @@ -4058,7 +4061,7 @@ packages: '@babel/traverse': 7.22.10 '@babel/types': 7.22.10 convert-source-map: 1.9.0 - debug: 4.3.4 + debug: 4.3.7 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -4337,7 +4340,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.22.10 '@babel/types': 7.22.10 - debug: 4.3.4 + debug: 4.3.7 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -5591,7 +5594,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} dependencies: '@gar/promisify': 1.1.3 - semver: 7.6.0 + semver: 7.6.3 dev: true /@npmcli/move-file@2.0.1: @@ -6662,7 +6665,7 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} dependencies: - debug: 4.3.4 + debug: 4.3.7 transitivePeerDependencies: - supports-color dev: true @@ -6931,15 +6934,10 @@ packages: transitivePeerDependencies: - debug - /b4a@1.6.4: - resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==} - dev: true - /b4a@1.6.7: resolution: {integrity: sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==} requiresBuild: true dev: true - optional: true /babel-jest@28.1.3(@babel/core@7.18.6): resolution: {integrity: sha512-epUaPOEWMk3cWX0M/sPvCHHCe9fMFAa/9hXEgKP8nFfNl/jlGkE9ucq9NqkZGXLDduCJYS0UvSlPUwC0S+rH6Q==} @@ -7078,21 +7076,12 @@ packages: prebuild-install: 7.1.2 dev: false - /better-sqlite3@9.4.5: - resolution: {integrity: sha512-uFVyoyZR9BNcjSca+cp3MWCv6upAv+tbMC4SWM51NIMhoQOm4tjIkyxFO/ZsYdGAF61WJBgdzyJcz4OokJi0gQ==} - requiresBuild: true - dependencies: - bindings: 1.5.0 - prebuild-install: 7.1.2 - dev: true - /better-sqlite3@9.6.0: resolution: {integrity: sha512-yR5HATnqeYNVnkaUTf4bOP2dJSnyhP4puJN/QPRyx4YkBEEUxib422n2XzPqDEHjQQqazoYoADdAm5vE15+dAQ==} requiresBuild: true dependencies: bindings: 1.5.0 prebuild-install: 7.1.2 - dev: false /big-integer@1.6.51: resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==} @@ -7992,11 +7981,6 @@ packages: engines: {node: '>=8'} dev: true - /detect-libc@2.0.2: - resolution: {integrity: sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==} - engines: {node: '>=8'} - dev: true - /detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -9375,7 +9359,7 @@ packages: dependencies: '@tootallnate/once': 2.0.0 agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.7 transitivePeerDependencies: - supports-color dev: true @@ -9404,7 +9388,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.7 transitivePeerDependencies: - supports-color dev: true @@ -9819,7 +9803,7 @@ packages: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} dependencies: - debug: 4.3.4 + debug: 4.3.7 istanbul-lib-coverage: 3.2.0 source-map: 0.6.1 transitivePeerDependencies: @@ -10359,7 +10343,7 @@ packages: lodash.isstring: 4.0.1 lodash.once: 4.1.1 ms: 2.1.3 - semver: 7.6.0 + semver: 7.6.3 dev: true /jwa@1.4.1: @@ -10600,7 +10584,7 @@ packages: resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} engines: {node: '>=10'} dependencies: - semver: 7.6.0 + semver: 7.6.3 dev: true /make-error@1.3.6: @@ -10910,18 +10894,11 @@ packages: engines: {node: '>= 0.4.0'} dev: true - /node-abi@3.47.0: - resolution: {integrity: sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==} - engines: {node: '>=10'} - dependencies: - semver: 7.6.0 - dev: true - /node-abi@3.57.0: resolution: {integrity: sha512-Dp+A9JWxRaKuHP35H77I4kCKesDy5HUDEmScia2FyncMTOXASMyg251F5PhFoDA5uqBrDDffiLpbqnrZmNXW+g==} engines: {node: '>=10'} dependencies: - semver: 7.6.0 + semver: 7.6.3 /node-abort-controller@3.1.1: resolution: {integrity: sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==} @@ -11917,25 +11894,6 @@ packages: resolution: {integrity: sha512-1qWaGAzwMpaXJP9opRa23nPnt2Egi7RMNoNBptEE/XwHbcn4fC2b/4U4bKc5arkGkIh2ZabpF2bEb+c5GNHEKA==} dev: false - /prebuild-install@7.1.1: - resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==} - engines: {node: '>=10'} - hasBin: true - dependencies: - detect-libc: 2.0.2 - expand-template: 2.0.3 - github-from-package: 0.0.0 - minimist: 1.2.8 - mkdirp-classic: 0.5.3 - napi-build-utils: 1.0.2 - node-abi: 3.47.0 - pump: 3.0.0 - rc: 1.2.8 - simple-get: 4.0.1 - tar-fs: 2.1.1 - tunnel-agent: 0.6.0 - dev: true - /prebuild-install@7.1.2: resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==} engines: {node: '>=10'} @@ -12571,6 +12529,7 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 + dev: true /semver@7.6.3: resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} @@ -12627,12 +12586,12 @@ packages: requiresBuild: true dependencies: color: 4.2.3 - detect-libc: 2.0.2 + detect-libc: 2.0.3 node-addon-api: 6.1.0 - prebuild-install: 7.1.1 - semver: 7.5.4 + prebuild-install: 7.1.2 + semver: 7.6.3 simple-get: 4.0.1 - tar-fs: 3.0.4 + tar-fs: 3.0.6 tunnel-agent: 0.6.0 dev: true @@ -12763,7 +12722,7 @@ packages: engines: {node: '>= 10'} dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.7 socks: 2.7.1 transitivePeerDependencies: - supports-color @@ -12932,13 +12891,6 @@ packages: mixme: 0.5.9 dev: true - /streamx@2.15.5: - resolution: {integrity: sha512-9thPGMkKC2GctCzyCUjME3yR03x2xNo0GPKGkRw2UMYN+gqWa9uqpyNWhmsNCutU5zHmkUum0LsCRQTXUgUCAg==} - dependencies: - fast-fifo: 1.3.2 - queue-tick: 1.0.1 - dev: true - /streamx@2.20.1: resolution: {integrity: sha512-uTa0mU6WUC65iUvzKH4X9hEdvSW7rbPxPtwfWiLMSj3qTdQbAiUboZTxauKfpFuGIGa1C2BYijZ7wgdUXICJhA==} requiresBuild: true @@ -12949,7 +12901,6 @@ packages: optionalDependencies: bare-events: 2.5.0 dev: true - optional: true /string-hash@1.1.3: resolution: {integrity: sha512-kJUvRUFK49aub+a7T1nNE66EJbZBMnBgoC1UbCZ5n6bsZKBRga4KgBRTMn/pFkeCZSYtNeSyMxPDM0AXWELk2A==} @@ -13190,14 +13141,6 @@ packages: pump: 3.0.0 tar-stream: 2.2.0 - /tar-fs@3.0.4: - resolution: {integrity: sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==} - dependencies: - mkdirp-classic: 0.5.3 - pump: 3.0.0 - tar-stream: 3.1.6 - dev: true - /tar-fs@3.0.6: resolution: {integrity: sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==} dependencies: @@ -13221,9 +13164,9 @@ packages: /tar-stream@3.1.6: resolution: {integrity: sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==} dependencies: - b4a: 1.6.4 + b4a: 1.6.7 fast-fifo: 1.3.2 - streamx: 2.15.5 + streamx: 2.20.1 dev: true /tar@6.1.15: @@ -13277,7 +13220,6 @@ packages: dependencies: b4a: 1.6.7 dev: true - optional: true /text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -13855,7 +13797,6 @@ packages: optional: true utf-8-validate: optional: true - dev: true /xmlbuilder@13.0.2: resolution: {integrity: sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==}