@atproto/sync 0.1.39 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE.txt +1 -1
- package/dist/events.d.ts +12 -13
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +0 -1
- package/dist/events.js.map +1 -1
- package/dist/firehose/index.d.ts +8 -8
- package/dist/firehose/index.d.ts.map +1 -1
- package/dist/firehose/index.js +23 -13
- package/dist/firehose/index.js.map +1 -1
- package/dist/lexicons/com/atproto/sync/subscribeRepos.d.ts +3 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.d.ts +152 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.js +75 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.js +45 -0
- package/dist/lexicons/com/atproto/sync/subscribeRepos.js.map +1 -0
- package/dist/lexicons/com/atproto/sync.d.ts +2 -0
- package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync.js +41 -0
- package/dist/lexicons/com/atproto/sync.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +2 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -0
- package/dist/lexicons/com/atproto.js +41 -0
- package/dist/lexicons/com/atproto.js.map +1 -0
- package/dist/lexicons/com.d.ts +2 -0
- package/dist/lexicons/com.d.ts.map +1 -0
- package/dist/lexicons/com.js +41 -0
- package/dist/lexicons/com.js.map +1 -0
- package/dist/lexicons/index.d.ts +2 -0
- package/dist/lexicons/index.d.ts.map +1 -0
- package/dist/lexicons/index.js +41 -0
- package/dist/lexicons/index.js.map +1 -0
- package/dist/util.d.ts +2 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +7 -3
- package/dist/util.js.map +1 -1
- package/package.json +9 -8
- package/src/events.ts +12 -15
- package/src/firehose/index.ts +53 -45
- package/src/util.ts +10 -10
- package/tests/firehose.test.ts +11 -8
- package/tests/runner.test.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +4 -1
- package/tsconfig.tests.json +8 -0
- package/dist/firehose/lexicons.d.ts +0 -105
- package/dist/firehose/lexicons.d.ts.map +0 -1
- package/dist/firehose/lexicons.js +0 -299
- package/dist/firehose/lexicons.js.map +0 -1
- package/src/firehose/lexicons.ts +0 -446
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @atproto/sync
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4408](https://github.com/bluesky-social/atproto/pull/4408) [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use `Cid` from `@atproto/lex` instead of `CID` from `multiformats` to represent CIDs.
|
|
8
|
+
|
|
9
|
+
- [#4408](https://github.com/bluesky-social/atproto/pull/4408) [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove dependency on `multiformats`
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`0dbea15`](https://github.com/bluesky-social/atproto/commit/0dbea15da48a6ca913cc3a3a2d8c0ffe64d7c69a), [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c), [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c), [`4f11fc3`](https://github.com/bluesky-social/atproto/commit/4f11fc341a770e907b0e84ec267aafafeec5ff88), [`527f5d4`](https://github.com/bluesky-social/atproto/commit/527f5d4c5d0c9264c2ff6f23ad06a41163fc6809), [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c), [`1479c87`](https://github.com/bluesky-social/atproto/commit/1479c87c6bf352694fdf298083e4f95287700c8e), [`1479c87`](https://github.com/bluesky-social/atproto/commit/1479c87c6bf352694fdf298083e4f95287700c8e), [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c), [`d0c136c`](https://github.com/bluesky-social/atproto/commit/d0c136cba2ec8fa97017849b1023d5af5d2cc60c), [`527f5d4`](https://github.com/bluesky-social/atproto/commit/527f5d4c5d0c9264c2ff6f23ad06a41163fc6809)]:
|
|
14
|
+
- @atproto/syntax@0.5.2
|
|
15
|
+
- @atproto/repo@0.9.0
|
|
16
|
+
- @atproto/xrpc-server@0.10.18
|
|
17
|
+
- @atproto/lex@0.0.23
|
|
18
|
+
|
|
19
|
+
## 0.1.40
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#4705](https://github.com/bluesky-social/atproto/pull/4705) [`138f0a0`](https://github.com/bluesky-social/atproto/commit/138f0a0b374c0d78372d5095237061d46db75a32) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix test flakiness
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd), [`e8969b6`](https://github.com/bluesky-social/atproto/commit/e8969b6b3d3fed8912be53fd72b4d5288ca34766), [`52834ab`](https://github.com/bluesky-social/atproto/commit/52834aba182da8df3611fd9dff924e6c6a3973a7), [`f7c2610`](https://github.com/bluesky-social/atproto/commit/f7c26103a6d4e24e5bedbb6fd908be140420e0dd)]:
|
|
26
|
+
- @atproto/syntax@0.5.0
|
|
27
|
+
- @atproto/common@0.5.14
|
|
28
|
+
- @atproto/xrpc-server@0.10.15
|
|
29
|
+
- @atproto/lexicon@0.6.2
|
|
30
|
+
|
|
3
31
|
## 0.1.39
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2026 Bluesky Social PBC, and Contributors
|
|
4
4
|
|
|
5
5
|
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
6
|
|
package/dist/events.d.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import type { CID } from 'multiformats/cid';
|
|
2
1
|
import { DidDocument } from '@atproto/identity';
|
|
3
|
-
import
|
|
2
|
+
import { Cid, LexMap } from '@atproto/lex';
|
|
4
3
|
import { BlockMap } from '@atproto/repo';
|
|
5
|
-
import { AtUri } from '@atproto/syntax';
|
|
4
|
+
import { AtUri, DidString } from '@atproto/syntax';
|
|
6
5
|
export type Event = CommitEvt | SyncEvt | IdentityEvt | AccountEvt;
|
|
7
6
|
export type CommitMeta = {
|
|
8
7
|
seq: number;
|
|
9
8
|
time: string;
|
|
10
|
-
commit:
|
|
9
|
+
commit: Cid;
|
|
11
10
|
blocks: BlockMap;
|
|
12
11
|
rev: string;
|
|
13
12
|
uri: AtUri;
|
|
14
|
-
did:
|
|
13
|
+
did: DidString;
|
|
15
14
|
collection: string;
|
|
16
15
|
rkey: string;
|
|
17
16
|
};
|
|
18
17
|
export type CommitEvt = Create | Update | Delete;
|
|
19
18
|
export type Create = CommitMeta & {
|
|
20
19
|
event: 'create';
|
|
21
|
-
record:
|
|
22
|
-
cid:
|
|
20
|
+
record: LexMap;
|
|
21
|
+
cid: Cid;
|
|
23
22
|
};
|
|
24
23
|
export type Update = CommitMeta & {
|
|
25
24
|
event: 'update';
|
|
26
|
-
record:
|
|
27
|
-
cid:
|
|
25
|
+
record: LexMap;
|
|
26
|
+
cid: Cid;
|
|
28
27
|
};
|
|
29
28
|
export type Delete = CommitMeta & {
|
|
30
29
|
event: 'delete';
|
|
@@ -33,8 +32,8 @@ export type SyncEvt = {
|
|
|
33
32
|
seq: number;
|
|
34
33
|
time: string;
|
|
35
34
|
event: 'sync';
|
|
36
|
-
did:
|
|
37
|
-
cid:
|
|
35
|
+
did: DidString;
|
|
36
|
+
cid: Cid;
|
|
38
37
|
rev: string;
|
|
39
38
|
blocks: BlockMap;
|
|
40
39
|
};
|
|
@@ -42,7 +41,7 @@ export type IdentityEvt = {
|
|
|
42
41
|
seq: number;
|
|
43
42
|
time: string;
|
|
44
43
|
event: 'identity';
|
|
45
|
-
did:
|
|
44
|
+
did: DidString;
|
|
46
45
|
handle?: string;
|
|
47
46
|
didDocument?: DidDocument;
|
|
48
47
|
};
|
|
@@ -50,7 +49,7 @@ export type AccountEvt = {
|
|
|
50
49
|
seq: number;
|
|
51
50
|
time: string;
|
|
52
51
|
event: 'account';
|
|
53
|
-
did:
|
|
52
|
+
did: DidString;
|
|
54
53
|
active: boolean;
|
|
55
54
|
status?: AccountStatus;
|
|
56
55
|
};
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAA;AAElE,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,GAAG,CAAA;IACX,MAAM,EAAE,QAAQ,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,KAAK,CAAA;IACV,GAAG,EAAE,SAAS,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAEhD,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG;IAChC,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG;IAChC,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG;IAChC,KAAK,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,SAAS,CAAA;IACd,GAAG,EAAE,GAAG,CAAA;IACR,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,QAAQ,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,UAAU,CAAA;IACjB,GAAG,EAAE,SAAS,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,CAAA;IAChB,GAAG,EAAE,SAAS,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,WAAW,GACX,SAAS,GACT,aAAa,CAAA"}
|
package/dist/events.js
CHANGED
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"","sourcesContent":["import { DidDocument } from '@atproto/identity'\nimport { Cid, LexMap } from '@atproto/lex'\nimport { BlockMap } from '@atproto/repo'\nimport { AtUri, DidString } from '@atproto/syntax'\n\nexport type Event = CommitEvt | SyncEvt | IdentityEvt | AccountEvt\n\nexport type CommitMeta = {\n seq: number\n time: string\n commit: Cid\n blocks: BlockMap\n rev: string\n uri: AtUri\n did: DidString\n collection: string\n rkey: string\n}\n\nexport type CommitEvt = Create | Update | Delete\n\nexport type Create = CommitMeta & {\n event: 'create'\n record: LexMap\n cid: Cid\n}\n\nexport type Update = CommitMeta & {\n event: 'update'\n record: LexMap\n cid: Cid\n}\n\nexport type Delete = CommitMeta & {\n event: 'delete'\n}\n\nexport type SyncEvt = {\n seq: number\n time: string\n event: 'sync'\n did: DidString\n cid: Cid\n rev: string\n blocks: BlockMap\n}\n\nexport type IdentityEvt = {\n seq: number\n time: string\n event: 'identity'\n did: DidString\n handle?: string\n didDocument?: DidDocument\n}\n\nexport type AccountEvt = {\n seq: number\n time: string\n event: 'account'\n did: DidString\n active: boolean\n status?: AccountStatus\n}\n\nexport type AccountStatus =\n | 'takendown'\n | 'suspended'\n | 'deleted'\n | 'deactivated'\n"]}
|
package/dist/firehose/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ClientOptions } from 'ws';
|
|
2
2
|
import { IdResolver } from '@atproto/identity';
|
|
3
3
|
import { AccountEvt, CommitEvt, Event, IdentityEvt, SyncEvt } from '../events';
|
|
4
|
+
import { com } from '../lexicons/index.js';
|
|
4
5
|
import { EventRunner } from '../runner';
|
|
5
|
-
import { type Account, type Commit, type Identity, type RepoEvent, type Sync } from './lexicons';
|
|
6
6
|
export type FirehoseOptions = ClientOptions & {
|
|
7
7
|
idResolver: IdResolver;
|
|
8
8
|
handleEvent: (evt: Event) => Awaited<void>;
|
|
@@ -31,18 +31,18 @@ export declare class Firehose {
|
|
|
31
31
|
private processEvt;
|
|
32
32
|
destroy(): Promise<void>;
|
|
33
33
|
}
|
|
34
|
-
export declare const parseCommitAuthenticated: (idResolver: IdResolver, evt: Commit, matchCollection?: ((col: string) => boolean) | null, forceKeyRefresh?: boolean) => Promise<CommitEvt[]>;
|
|
35
|
-
export declare const parseCommitUnauthenticated: (evt: Commit, matchCollection?: ((col: string) => boolean) | null) => Promise<CommitEvt[]>;
|
|
36
|
-
export declare const parseSync: (evt: Sync) => Promise<SyncEvt | null>;
|
|
37
|
-
export declare const parseIdentity: (idResolver: IdResolver, evt: Identity, unauthenticated?: boolean) => Promise<IdentityEvt | null>;
|
|
38
|
-
export declare const parseAccount: (evt: Account) => AccountEvt | undefined;
|
|
34
|
+
export declare const parseCommitAuthenticated: (idResolver: IdResolver, evt: com.atproto.sync.subscribeRepos.Commit, matchCollection?: ((col: string) => boolean) | null, forceKeyRefresh?: boolean) => Promise<CommitEvt[]>;
|
|
35
|
+
export declare const parseCommitUnauthenticated: (evt: com.atproto.sync.subscribeRepos.Commit, matchCollection?: ((col: string) => boolean) | null) => Promise<CommitEvt[]>;
|
|
36
|
+
export declare const parseSync: (evt: com.atproto.sync.subscribeRepos.Sync) => Promise<SyncEvt | null>;
|
|
37
|
+
export declare const parseIdentity: (idResolver: IdResolver, evt: com.atproto.sync.subscribeRepos.Identity, unauthenticated?: boolean) => Promise<IdentityEvt | null>;
|
|
38
|
+
export declare const parseAccount: (evt: com.atproto.sync.subscribeRepos.Account) => AccountEvt | undefined;
|
|
39
39
|
export declare class FirehoseValidationError extends Error {
|
|
40
40
|
value: unknown;
|
|
41
41
|
constructor(err: unknown, value: unknown);
|
|
42
42
|
}
|
|
43
43
|
export declare class FirehoseParseError extends Error {
|
|
44
|
-
event:
|
|
45
|
-
constructor(err: unknown, event:
|
|
44
|
+
event: com.atproto.sync.subscribeRepos.$Message;
|
|
45
|
+
constructor(err: unknown, event: com.atproto.sync.subscribeRepos.$Message);
|
|
46
46
|
}
|
|
47
47
|
export declare class FirehoseSubscriptionError extends Error {
|
|
48
48
|
constructor(err: unknown);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAEvC,OAAO,EAEL,UAAU,EAEX,MAAM,mBAAmB,CAAA;AAa1B,OAAO,EACL,UAAU,EAEV,SAA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,KAAK;gBADnB,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,KAAK;CAItB"}
|
package/dist/firehose/index.js
CHANGED
|
@@ -6,8 +6,8 @@ const identity_1 = require("@atproto/identity");
|
|
|
6
6
|
const repo_1 = require("@atproto/repo");
|
|
7
7
|
const syntax_1 = require("@atproto/syntax");
|
|
8
8
|
const xrpc_server_1 = require("@atproto/xrpc-server");
|
|
9
|
+
const index_js_1 = require("../lexicons/index.js");
|
|
9
10
|
const util_1 = require("../util");
|
|
10
|
-
const lexicons_1 = require("./lexicons");
|
|
11
11
|
class Firehose {
|
|
12
12
|
constructor(opts) {
|
|
13
13
|
Object.defineProperty(this, "opts", {
|
|
@@ -69,7 +69,7 @@ class Firehose {
|
|
|
69
69
|
this.sub = new xrpc_server_1.Subscription({
|
|
70
70
|
...opts,
|
|
71
71
|
service: opts.service ?? 'wss://bsky.network',
|
|
72
|
-
method:
|
|
72
|
+
method: index_js_1.com.atproto.sync.subscribeRepos.$lxm,
|
|
73
73
|
signal: this.abortController.signal,
|
|
74
74
|
getParams: async () => {
|
|
75
75
|
const getCursorFn = () => this.opts.runner?.getCursor() ?? this.opts.getCursor;
|
|
@@ -80,11 +80,12 @@ class Firehose {
|
|
|
80
80
|
return { cursor };
|
|
81
81
|
},
|
|
82
82
|
validate: (value) => {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
const result = index_js_1.com.atproto.sync.subscribeRepos.$message.safeParse(value);
|
|
84
|
+
if (result.success) {
|
|
85
|
+
return result.value;
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
-
this.opts.onError(new FirehoseValidationError(
|
|
87
|
+
else {
|
|
88
|
+
this.opts.onError(new FirehoseValidationError(result.reason, value));
|
|
88
89
|
}
|
|
89
90
|
},
|
|
90
91
|
});
|
|
@@ -126,20 +127,28 @@ class Firehose {
|
|
|
126
127
|
}
|
|
127
128
|
async parseEvt(evt) {
|
|
128
129
|
try {
|
|
129
|
-
if (
|
|
130
|
+
if (index_js_1.com.atproto.sync.subscribeRepos.commit.$isTypeOf(evt)) {
|
|
131
|
+
if (this.opts.excludeCommit)
|
|
132
|
+
return [];
|
|
130
133
|
return this.opts.unauthenticatedCommits
|
|
131
134
|
? await (0, exports.parseCommitUnauthenticated)(evt, this.matchCollection)
|
|
132
135
|
: await (0, exports.parseCommitAuthenticated)(this.opts.idResolver, evt, this.matchCollection);
|
|
133
136
|
}
|
|
134
|
-
else if (
|
|
137
|
+
else if (index_js_1.com.atproto.sync.subscribeRepos.account.$isTypeOf(evt)) {
|
|
138
|
+
if (this.opts.excludeAccount)
|
|
139
|
+
return [];
|
|
135
140
|
const parsed = (0, exports.parseAccount)(evt);
|
|
136
141
|
return parsed ? [parsed] : [];
|
|
137
142
|
}
|
|
138
|
-
else if (
|
|
143
|
+
else if (index_js_1.com.atproto.sync.subscribeRepos.identity.$isTypeOf(evt)) {
|
|
144
|
+
if (this.opts.excludeIdentity)
|
|
145
|
+
return [];
|
|
139
146
|
const parsed = await (0, exports.parseIdentity)(this.opts.idResolver, evt, this.opts.unauthenticatedHandles);
|
|
140
147
|
return parsed ? [parsed] : [];
|
|
141
148
|
}
|
|
142
|
-
else if (
|
|
149
|
+
else if (index_js_1.com.atproto.sync.subscribeRepos.sync.$isTypeOf(evt)) {
|
|
150
|
+
if (this.opts.excludeSync)
|
|
151
|
+
return [];
|
|
143
152
|
const parsed = await (0, exports.parseSync)(evt);
|
|
144
153
|
return parsed ? [parsed] : [];
|
|
145
154
|
}
|
|
@@ -199,11 +208,12 @@ const parseCommitAuthenticated = async (idResolver, evt, matchCollection, forceK
|
|
|
199
208
|
throw err;
|
|
200
209
|
}
|
|
201
210
|
const verifiedOps = ops.filter((op) => {
|
|
211
|
+
const verifiedCid = verifiedCids[op.path];
|
|
202
212
|
if (op.action === 'delete') {
|
|
203
|
-
return
|
|
213
|
+
return verifiedCid === null;
|
|
204
214
|
}
|
|
205
215
|
else {
|
|
206
|
-
return op.cid
|
|
216
|
+
return (op.cid != null && verifiedCid != null && verifiedCid.equals(op.cid));
|
|
207
217
|
}
|
|
208
218
|
});
|
|
209
219
|
return formatCommitOps(evt, verifiedOps, {
|
|
@@ -236,7 +246,7 @@ const formatCommitOps = async (evt, ops, options) => {
|
|
|
236
246
|
blocks: car.blocks,
|
|
237
247
|
rev: evt.rev,
|
|
238
248
|
uri,
|
|
239
|
-
did: uri.
|
|
249
|
+
did: uri.did,
|
|
240
250
|
collection: uri.collection,
|
|
241
251
|
rkey: uri.rkey,
|
|
242
252
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":";;;AAEA,4CAAoE;AACpE,gDAI0B;AAC1B,wCAQsB;AACtB,4CAAuC;AACvC,sDAAmD;AAWnD,kCAAyC;AACzC,yCAYmB;AAwBnB,MAAa,QAAQ;IAMnB,YAAmB,IAAqB;QAA5B;;;;mBAAO,IAAI;WAAiB;QALhC;;;;;WAA4B;QAC5B;;;;;WAAgC;QAChC;;;;;WAAwB;QACxB;;;;mBAAqD,IAAI;WAAA;QAG/D,IAAI,CAAC,YAAY,GAAG,IAAA,yBAAgB,GAAE,CAAA;QACtC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;QAC5C,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;YAC/B,MAAM,QAAQ,GAAa,EAAE,CAAA;YAE7B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC7C,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC3B,QAAQ,CAAC,IAAI,CA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;;mBAAO,KAAK;WAAW;IAGzB,CAAC;CACF;AAPD,gDAOC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,GAAY;QACtB,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CACF;AAJD,8DAIC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YACE,GAAY,EACL,KAAY;QAEnB,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAFxD;;;;mBAAO,KAAK;WAAO;IAGrB,CAAC;CACF;AAPD,oDAOC","sourcesContent":["import { CID } from 'multiformats/cid'\nimport type { ClientOptions } from 'ws'\nimport { Deferrable, createDeferrable, wait } from '@atproto/common'\nimport {\n DidDocument,\n IdResolver,\n parseToAtprotoDocument,\n} from '@atproto/identity'\nimport {\n RepoVerificationError,\n cborToLexRecord,\n formatDataKey,\n parseDataKey,\n readCar,\n readCarWithRoot,\n verifyProofs,\n} from '@atproto/repo'\nimport { AtUri } from '@atproto/syntax'\nimport { Subscription } from '@atproto/xrpc-server'\nimport {\n AccountEvt,\n AccountStatus,\n CommitEvt,\n CommitMeta,\n Event,\n IdentityEvt,\n SyncEvt,\n} from '../events'\nimport { EventRunner } from '../runner'\nimport { didAndSeqForEvt } from '../util'\nimport {\n type Account,\n type Commit,\n type Identity,\n type RepoEvent,\n RepoOp,\n type Sync,\n isAccount,\n isCommit,\n isIdentity,\n isSync,\n isValidRepoEvent,\n} from './lexicons'\n\nexport type FirehoseOptions = ClientOptions & {\n idResolver: IdResolver\n\n handleEvent: (evt: Event) => Awaited<void>\n onError: (err: Error) => void\n getCursor?: () => Awaited<number | undefined>\n\n runner?: EventRunner // should only set getCursor *or* runner\n\n service?: string\n subscriptionReconnectDelay?: number\n\n unauthenticatedCommits?: boolean\n unauthenticatedHandles?: boolean\n\n filterCollections?: string[]\n excludeIdentity?: boolean\n excludeAccount?: boolean\n excludeCommit?: boolean\n excludeSync?: boolean\n}\n\nexport class Firehose {\n private sub: Subscription<RepoEvent>\n private abortController: AbortController\n private destoryDefer: Deferrable\n private matchCollection: ((col: string) => boolean) | null = null\n\n constructor(public opts: FirehoseOptions) {\n this.destoryDefer = createDeferrable()\n this.abortController = new AbortController()\n if (this.opts.getCursor && this.opts.runner) {\n throw new Error('Must set only `getCursor` or `runner`')\n }\n if (opts.filterCollections) {\n const exact = new Set<string>()\n const prefixes: string[] = []\n\n for (const pattern of opts.filterCollections) {\n if (pattern.endsWith('.*')) {\n prefixes.push(pattern.slice(0, -2))\n } else {\n exact.add(pattern)\n }\n }\n this.matchCollection = (col: string): boolean => {\n if (exact.has(col)) return true\n for (const prefix of prefixes) {\n if (col.startsWith(prefix)) return true\n }\n return false\n }\n }\n this.sub = new Subscription({\n ...opts,\n service: opts.service ?? 'wss://bsky.network',\n method: 'com.atproto.sync.subscribeRepos',\n signal: this.abortController.signal,\n getParams: async () => {\n const getCursorFn = () =>\n this.opts.runner?.getCursor() ?? this.opts.getCursor\n if (!getCursorFn) {\n return undefined\n }\n const cursor = await getCursorFn()\n return { cursor }\n },\n validate: (value: unknown) => {\n try {\n return isValidRepoEvent(value)\n } catch (err) {\n this.opts.onError(new FirehoseValidationError(err, value))\n }\n },\n })\n }\n\n async start() {\n try {\n for await (const evt of this.sub) {\n if (this.opts.runner) {\n const parsed = didAndSeqForEvt(evt)\n if (!parsed) {\n continue\n }\n this.opts.runner.trackEvent(parsed.did, parsed.seq, async () => {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n })\n } else {\n await this.processEvt(evt)\n }\n }\n } catch (err) {\n if (err && err['name'] === 'AbortError') {\n this.destoryDefer.resolve()\n return\n }\n this.opts.onError(new FirehoseSubscriptionError(err))\n await wait(this.opts.subscriptionReconnectDelay ?? 3000)\n return this.start()\n }\n }\n\n private async parseEvt(evt: RepoEvent): Promise<Event[]> {\n try {\n if (isCommit(evt) && !this.opts.excludeCommit) {\n return this.opts.unauthenticatedCommits\n ? await parseCommitUnauthenticated(evt, this.matchCollection)\n : await parseCommitAuthenticated(\n this.opts.idResolver,\n evt,\n this.matchCollection,\n )\n } else if (isAccount(evt) && !this.opts.excludeAccount) {\n const parsed = parseAccount(evt)\n return parsed ? [parsed] : []\n } else if (isIdentity(evt) && !this.opts.excludeIdentity) {\n const parsed = await parseIdentity(\n this.opts.idResolver,\n evt,\n this.opts.unauthenticatedHandles,\n )\n return parsed ? [parsed] : []\n } else if (isSync(evt) && !this.opts.excludeSync) {\n const parsed = await parseSync(evt)\n return parsed ? [parsed] : []\n } else {\n return []\n }\n } catch (err) {\n this.opts.onError(new FirehoseParseError(err, evt))\n return []\n }\n }\n\n private async processEvt(evt: RepoEvent) {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n }\n\n async destroy(): Promise<void> {\n this.abortController.abort()\n await this.destoryDefer.complete\n }\n}\n\nexport const parseCommitAuthenticated = async (\n idResolver: IdResolver,\n evt: Commit,\n matchCollection?: ((col: string) => boolean) | null,\n forceKeyRefresh = false,\n): Promise<CommitEvt[]> => {\n const did = evt.repo\n const ops = maybeFilterOps(evt.ops, matchCollection)\n if (ops.length === 0) {\n return []\n }\n const claims = ops.map((op) => {\n const { collection, rkey } = parseDataKey(op.path)\n return {\n collection,\n rkey,\n cid: op.action === 'delete' ? null : op.cid,\n }\n })\n const key = await idResolver.did.resolveAtprotoKey(did, forceKeyRefresh)\n const verifiedCids: Record<string, CID | null> = {}\n try {\n const results = await verifyProofs(evt.blocks, claims, did, key)\n results.verified.forEach((op) => {\n const path = formatDataKey(op.collection, op.rkey)\n verifiedCids[path] = op.cid\n })\n } catch (err) {\n if (err instanceof RepoVerificationError && !forceKeyRefresh) {\n return parseCommitAuthenticated(idResolver, evt, matchCollection, true)\n }\n throw err\n }\n const verifiedOps: RepoOp[] = ops.filter((op) => {\n if (op.action === 'delete') {\n return verifiedCids[op.path] === null\n } else {\n return op.cid !== null && op.cid.equals(verifiedCids[op.path])\n }\n })\n return formatCommitOps(evt, verifiedOps, {\n skipCidVerification: true, // already checked via verifyProofs()\n })\n}\n\nexport const parseCommitUnauthenticated = async (\n evt: Commit,\n matchCollection?: ((col: string) => boolean) | null,\n): Promise<CommitEvt[]> => {\n const ops = maybeFilterOps(evt.ops, matchCollection)\n return formatCommitOps(evt, ops)\n}\n\nconst maybeFilterOps = (\n ops: RepoOp[],\n matchCollection?: ((col: string) => boolean) | null,\n): RepoOp[] => {\n if (!matchCollection) return ops\n return ops.filter((op) => {\n const { collection } = parseDataKey(op.path)\n return matchCollection(collection)\n })\n}\n\nconst formatCommitOps = async (\n evt: Commit,\n ops: RepoOp[],\n options?: { skipCidVerification: boolean },\n) => {\n const car = await readCar(evt.blocks, options)\n\n const evts: CommitEvt[] = []\n\n for (const op of ops) {\n const uri = AtUri.make(evt.repo, op.path)\n\n const meta: CommitMeta = {\n seq: evt.seq,\n time: evt.time,\n commit: evt.commit,\n blocks: car.blocks,\n rev: evt.rev,\n uri,\n did: uri.host,\n collection: uri.collection,\n rkey: uri.rkey,\n }\n\n if (op.action === 'create' || op.action === 'update') {\n if (!op.cid) continue\n const recordBytes = car.blocks.get(op.cid)\n if (!recordBytes) continue\n const record = cborToLexRecord(recordBytes)\n evts.push({\n ...meta,\n event: op.action as 'create' | 'update',\n cid: op.cid,\n record,\n })\n }\n\n if (op.action === 'delete') {\n evts.push({\n ...meta,\n event: 'delete',\n })\n }\n }\n\n return evts\n}\n\nexport const parseSync = async (evt: Sync): Promise<SyncEvt | null> => {\n const car = await readCarWithRoot(evt.blocks)\n\n return {\n event: 'sync',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n cid: car.root,\n rev: evt.rev,\n blocks: car.blocks,\n }\n}\n\nexport const parseIdentity = async (\n idResolver: IdResolver,\n evt: Identity,\n unauthenticated = false,\n): Promise<IdentityEvt | null> => {\n const res = await idResolver.did.resolve(evt.did)\n const handle =\n res && !unauthenticated\n ? await verifyHandle(idResolver, evt.did, res)\n : undefined\n\n return {\n event: 'identity',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n handle,\n didDocument: res ?? undefined,\n }\n}\n\nconst verifyHandle = async (\n idResolver: IdResolver,\n did: string,\n didDoc: DidDocument,\n): Promise<string | undefined> => {\n const { handle } = parseToAtprotoDocument(didDoc)\n if (!handle) {\n return undefined\n }\n const res = await idResolver.handle.resolve(handle)\n return res === did ? handle : undefined\n}\n\nexport const parseAccount = (evt: Account): AccountEvt | undefined => {\n if (evt.status && !isValidStatus(evt.status)) return\n return {\n event: 'account',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n active: evt.active,\n status: evt.status as AccountStatus | undefined,\n }\n}\n\nconst isValidStatus = (str: string): str is AccountStatus => {\n return ['takendown', 'suspended', 'deleted', 'deactivated'].includes(str)\n}\n\nexport class FirehoseValidationError extends Error {\n constructor(\n err: unknown,\n public value: unknown,\n ) {\n super('error in firehose event lexicon validation', { cause: err })\n }\n}\n\nexport class FirehoseParseError extends Error {\n constructor(\n err: unknown,\n public event: RepoEvent,\n ) {\n super('error in parsing and authenticating firehose event', { cause: err })\n }\n}\n\nexport class FirehoseSubscriptionError extends Error {\n constructor(err: unknown) {\n super('error on firehose subscription', { cause: err })\n }\n}\n\nexport class FirehoseHandlerError extends Error {\n constructor(\n err: unknown,\n public event: Event,\n ) {\n super('error in firehose event handler', { cause: err })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":";;;AACA,4CAAoE;AACpE,gDAI0B;AAE1B,wCAQsB;AACtB,4CAAuC;AACvC,sDAAmD;AAUnD,mDAA0C;AAE1C,kCAAyC;AAwBzC,MAAa,QAAQ;IAMnB,YAAmB,IAAqB;QAA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;mBAAO,KAAK;WAA0C;IAGxD,CAAC;CACF;AAPD,gDAOC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,GAAY;QACtB,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CACF;AAJD,8DAIC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YACE,GAAY,EACL,KAAY;QAEnB,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAFxD;;;;mBAAO,KAAK;WAAO;IAGrB,CAAC;CACF;AAPD,oDAOC","sourcesContent":["import type { ClientOptions } from 'ws'\nimport { Deferrable, createDeferrable, wait } from '@atproto/common'\nimport {\n DidDocument,\n IdResolver,\n parseToAtprotoDocument,\n} from '@atproto/identity'\nimport { Cid } from '@atproto/lex'\nimport {\n RepoVerificationError,\n cborToLexRecord,\n formatDataKey,\n parseDataKey,\n readCar,\n readCarWithRoot,\n verifyProofs,\n} from '@atproto/repo'\nimport { AtUri } from '@atproto/syntax'\nimport { Subscription } from '@atproto/xrpc-server'\nimport {\n AccountEvt,\n AccountStatus,\n CommitEvt,\n CommitMeta,\n Event,\n IdentityEvt,\n SyncEvt,\n} from '../events'\nimport { com } from '../lexicons/index.js'\nimport { EventRunner } from '../runner'\nimport { didAndSeqForEvt } from '../util'\n\nexport type FirehoseOptions = ClientOptions & {\n idResolver: IdResolver\n\n handleEvent: (evt: Event) => Awaited<void>\n onError: (err: Error) => void\n getCursor?: () => Awaited<number | undefined>\n\n runner?: EventRunner // should only set getCursor *or* runner\n\n service?: string\n subscriptionReconnectDelay?: number\n\n unauthenticatedCommits?: boolean\n unauthenticatedHandles?: boolean\n\n filterCollections?: string[]\n excludeIdentity?: boolean\n excludeAccount?: boolean\n excludeCommit?: boolean\n excludeSync?: boolean\n}\n\nexport class Firehose {\n private sub: Subscription<com.atproto.sync.subscribeRepos.$Message>\n private abortController: AbortController\n private destoryDefer: Deferrable\n private matchCollection: ((col: string) => boolean) | null = null\n\n constructor(public opts: FirehoseOptions) {\n this.destoryDefer = createDeferrable()\n this.abortController = new AbortController()\n if (this.opts.getCursor && this.opts.runner) {\n throw new Error('Must set only `getCursor` or `runner`')\n }\n if (opts.filterCollections) {\n const exact = new Set<string>()\n const prefixes: string[] = []\n\n for (const pattern of opts.filterCollections) {\n if (pattern.endsWith('.*')) {\n prefixes.push(pattern.slice(0, -2))\n } else {\n exact.add(pattern)\n }\n }\n this.matchCollection = (col: string): boolean => {\n if (exact.has(col)) return true\n for (const prefix of prefixes) {\n if (col.startsWith(prefix)) return true\n }\n return false\n }\n }\n this.sub = new Subscription({\n ...opts,\n service: opts.service ?? 'wss://bsky.network',\n method: com.atproto.sync.subscribeRepos.$lxm,\n signal: this.abortController.signal,\n getParams: async () => {\n const getCursorFn = () =>\n this.opts.runner?.getCursor() ?? this.opts.getCursor\n if (!getCursorFn) {\n return undefined\n }\n const cursor = await getCursorFn()\n return { cursor }\n },\n validate: (value: unknown) => {\n const result = com.atproto.sync.subscribeRepos.$message.safeParse(value)\n if (result.success) {\n return result.value\n } else {\n this.opts.onError(new FirehoseValidationError(result.reason, value))\n }\n },\n })\n }\n\n async start() {\n try {\n for await (const evt of this.sub) {\n if (this.opts.runner) {\n const parsed = didAndSeqForEvt(evt)\n if (!parsed) {\n continue\n }\n this.opts.runner.trackEvent(parsed.did, parsed.seq, async () => {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n })\n } else {\n await this.processEvt(evt)\n }\n }\n } catch (err) {\n if (err && err['name'] === 'AbortError') {\n this.destoryDefer.resolve()\n return\n }\n this.opts.onError(new FirehoseSubscriptionError(err))\n await wait(this.opts.subscriptionReconnectDelay ?? 3000)\n return this.start()\n }\n }\n\n private async parseEvt(\n evt: com.atproto.sync.subscribeRepos.$Message,\n ): Promise<Event[]> {\n try {\n if (com.atproto.sync.subscribeRepos.commit.$isTypeOf(evt)) {\n if (this.opts.excludeCommit) return []\n\n return this.opts.unauthenticatedCommits\n ? await parseCommitUnauthenticated(evt, this.matchCollection)\n : await parseCommitAuthenticated(\n this.opts.idResolver,\n evt,\n this.matchCollection,\n )\n } else if (com.atproto.sync.subscribeRepos.account.$isTypeOf(evt)) {\n if (this.opts.excludeAccount) return []\n\n const parsed = parseAccount(evt)\n return parsed ? [parsed] : []\n } else if (com.atproto.sync.subscribeRepos.identity.$isTypeOf(evt)) {\n if (this.opts.excludeIdentity) return []\n\n const parsed = await parseIdentity(\n this.opts.idResolver,\n evt,\n this.opts.unauthenticatedHandles,\n )\n return parsed ? [parsed] : []\n } else if (com.atproto.sync.subscribeRepos.sync.$isTypeOf(evt)) {\n if (this.opts.excludeSync) return []\n\n const parsed = await parseSync(evt)\n return parsed ? [parsed] : []\n } else {\n return []\n }\n } catch (err) {\n this.opts.onError(new FirehoseParseError(err, evt))\n return []\n }\n }\n\n private async processEvt(evt: com.atproto.sync.subscribeRepos.$Message) {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n }\n\n async destroy(): Promise<void> {\n this.abortController.abort()\n await this.destoryDefer.complete\n }\n}\n\nexport const parseCommitAuthenticated = async (\n idResolver: IdResolver,\n evt: com.atproto.sync.subscribeRepos.Commit,\n matchCollection?: ((col: string) => boolean) | null,\n forceKeyRefresh = false,\n): Promise<CommitEvt[]> => {\n const did = evt.repo\n const ops = maybeFilterOps(evt.ops, matchCollection)\n if (ops.length === 0) {\n return []\n }\n const claims = ops.map((op) => {\n const { collection, rkey } = parseDataKey(op.path)\n return {\n collection,\n rkey,\n cid: op.action === 'delete' ? null : op.cid,\n }\n })\n const key = await idResolver.did.resolveAtprotoKey(did, forceKeyRefresh)\n const verifiedCids: Record<string, Cid | null> = {}\n try {\n const results = await verifyProofs(evt.blocks, claims, did, key)\n results.verified.forEach((op) => {\n const path = formatDataKey(op.collection, op.rkey)\n verifiedCids[path] = op.cid\n })\n } catch (err) {\n if (err instanceof RepoVerificationError && !forceKeyRefresh) {\n return parseCommitAuthenticated(idResolver, evt, matchCollection, true)\n }\n throw err\n }\n const verifiedOps: com.atproto.sync.subscribeRepos.RepoOp[] = ops.filter(\n (op) => {\n const verifiedCid = verifiedCids[op.path]\n if (op.action === 'delete') {\n return verifiedCid === null\n } else {\n return (\n op.cid != null && verifiedCid != null && verifiedCid.equals(op.cid)\n )\n }\n },\n )\n return formatCommitOps(evt, verifiedOps, {\n skipCidVerification: true, // already checked via verifyProofs()\n })\n}\n\nexport const parseCommitUnauthenticated = async (\n evt: com.atproto.sync.subscribeRepos.Commit,\n matchCollection?: ((col: string) => boolean) | null,\n): Promise<CommitEvt[]> => {\n const ops = maybeFilterOps(evt.ops, matchCollection)\n return formatCommitOps(evt, ops)\n}\n\nconst maybeFilterOps = (\n ops: com.atproto.sync.subscribeRepos.RepoOp[],\n matchCollection?: ((col: string) => boolean) | null,\n): com.atproto.sync.subscribeRepos.RepoOp[] => {\n if (!matchCollection) return ops\n return ops.filter((op) => {\n const { collection } = parseDataKey(op.path)\n return matchCollection(collection)\n })\n}\n\nconst formatCommitOps = async (\n evt: com.atproto.sync.subscribeRepos.Commit,\n ops: com.atproto.sync.subscribeRepos.RepoOp[],\n options?: { skipCidVerification: boolean },\n) => {\n const car = await readCar(evt.blocks, options)\n\n const evts: CommitEvt[] = []\n\n for (const op of ops) {\n const uri = AtUri.make(evt.repo, op.path)\n\n const meta: CommitMeta = {\n seq: evt.seq,\n time: evt.time,\n commit: evt.commit,\n blocks: car.blocks,\n rev: evt.rev,\n uri,\n did: uri.did,\n collection: uri.collection,\n rkey: uri.rkey,\n }\n\n if (op.action === 'create' || op.action === 'update') {\n if (!op.cid) continue\n const recordBytes = car.blocks.get(op.cid)\n if (!recordBytes) continue\n const record = cborToLexRecord(recordBytes)\n evts.push({\n ...meta,\n event: op.action as 'create' | 'update',\n cid: op.cid,\n record,\n })\n }\n\n if (op.action === 'delete') {\n evts.push({\n ...meta,\n event: 'delete',\n })\n }\n }\n\n return evts\n}\n\nexport const parseSync = async (\n evt: com.atproto.sync.subscribeRepos.Sync,\n): Promise<SyncEvt | null> => {\n const car = await readCarWithRoot(evt.blocks)\n\n return {\n event: 'sync',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n cid: car.root,\n rev: evt.rev,\n blocks: car.blocks,\n }\n}\n\nexport const parseIdentity = async (\n idResolver: IdResolver,\n evt: com.atproto.sync.subscribeRepos.Identity,\n unauthenticated = false,\n): Promise<IdentityEvt | null> => {\n const res = await idResolver.did.resolve(evt.did)\n const handle =\n res && !unauthenticated\n ? await verifyHandle(idResolver, evt.did, res)\n : undefined\n\n return {\n event: 'identity',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n handle,\n didDocument: res ?? undefined,\n }\n}\n\nconst verifyHandle = async (\n idResolver: IdResolver,\n did: string,\n didDoc: DidDocument,\n): Promise<string | undefined> => {\n const { handle } = parseToAtprotoDocument(didDoc)\n if (!handle) {\n return undefined\n }\n const res = await idResolver.handle.resolve(handle)\n return res === did ? handle : undefined\n}\n\nexport const parseAccount = (\n evt: com.atproto.sync.subscribeRepos.Account,\n): AccountEvt | undefined => {\n if (evt.status && !isValidStatus(evt.status)) return\n return {\n event: 'account',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n active: evt.active,\n status: evt.status as AccountStatus | undefined,\n }\n}\n\nconst isValidStatus = (str: string): str is AccountStatus => {\n return ['takendown', 'suspended', 'deleted', 'deactivated'].includes(str)\n}\n\nexport class FirehoseValidationError extends Error {\n constructor(\n err: unknown,\n public value: unknown,\n ) {\n super('error in firehose event lexicon validation', { cause: err })\n }\n}\n\nexport class FirehoseParseError extends Error {\n constructor(\n err: unknown,\n public event: com.atproto.sync.subscribeRepos.$Message,\n ) {\n super('error in parsing and authenticating firehose event', { cause: err })\n }\n}\n\nexport class FirehoseSubscriptionError extends Error {\n constructor(err: unknown) {\n super('error on firehose subscription', { cause: err })\n }\n}\n\nexport class FirehoseHandlerError extends Error {\n constructor(\n err: unknown,\n public event: Event,\n ) {\n super('error in firehose event handler', { cause: err })\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribeRepos.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { l } from '@atproto/lex';
|
|
2
|
+
declare const $nsid = "com.atproto.sync.subscribeRepos";
|
|
3
|
+
export { $nsid };
|
|
4
|
+
/** Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay. */
|
|
5
|
+
declare const main: l.Subscription<"com.atproto.sync.subscribeRepos", l.ParamsSchema<{
|
|
6
|
+
readonly cursor: l.OptionalSchema<l.IntegerSchema>;
|
|
7
|
+
}>, l.TypedUnionSchema<readonly [l.TypedRefSchema<l.TypedObjectValidator<Commit, Commit>>, l.TypedRefSchema<l.TypedObjectValidator<Sync, Sync>>, l.TypedRefSchema<l.TypedObjectValidator<Identity, Identity>>, l.TypedRefSchema<l.TypedObjectValidator<Account, Account>>, l.TypedRefSchema<l.TypedObjectValidator<Info, Info>>], false>, readonly ["FutureCursor", "ConsumerTooSlow"]>;
|
|
8
|
+
export { main };
|
|
9
|
+
export type $Params = l.InferMethodParams<typeof main>;
|
|
10
|
+
export type $Message = l.InferSubscriptionMessage<typeof main>;
|
|
11
|
+
export declare const $lxm: "com.atproto.sync.subscribeRepos", $params: l.ParamsSchema<{
|
|
12
|
+
readonly cursor: l.OptionalSchema<l.IntegerSchema>;
|
|
13
|
+
}>, $message: l.TypedUnionSchema<readonly [l.TypedRefSchema<l.TypedObjectValidator<Commit, Commit>>, l.TypedRefSchema<l.TypedObjectValidator<Sync, Sync>>, l.TypedRefSchema<l.TypedObjectValidator<Identity, Identity>>, l.TypedRefSchema<l.TypedObjectValidator<Account, Account>>, l.TypedRefSchema<l.TypedObjectValidator<Info, Info>>], false>;
|
|
14
|
+
/** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */
|
|
15
|
+
type Commit = {
|
|
16
|
+
$type?: 'com.atproto.sync.subscribeRepos#commit';
|
|
17
|
+
/**
|
|
18
|
+
* The stream sequence number of this message.
|
|
19
|
+
*/
|
|
20
|
+
seq: number;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated unused
|
|
23
|
+
*/
|
|
24
|
+
rebase: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.
|
|
27
|
+
*/
|
|
28
|
+
tooBig: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The repo this event comes from. Note that all other message types name this field 'did'.
|
|
31
|
+
*/
|
|
32
|
+
repo: l.DidString;
|
|
33
|
+
/**
|
|
34
|
+
* Repo commit object CID.
|
|
35
|
+
*/
|
|
36
|
+
commit: l.Cid;
|
|
37
|
+
/**
|
|
38
|
+
* The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.
|
|
39
|
+
*/
|
|
40
|
+
rev: l.TidString;
|
|
41
|
+
/**
|
|
42
|
+
* The rev of the last emitted commit from this repo (if any).
|
|
43
|
+
*/
|
|
44
|
+
since: l.TidString | null;
|
|
45
|
+
/**
|
|
46
|
+
* CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.
|
|
47
|
+
*/
|
|
48
|
+
blocks: Uint8Array;
|
|
49
|
+
ops: RepoOp[];
|
|
50
|
+
blobs: l.Cid[];
|
|
51
|
+
/**
|
|
52
|
+
* The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.
|
|
53
|
+
*/
|
|
54
|
+
prevData?: l.Cid;
|
|
55
|
+
/**
|
|
56
|
+
* Timestamp of when this message was originally broadcast.
|
|
57
|
+
*/
|
|
58
|
+
time: l.DatetimeString;
|
|
59
|
+
};
|
|
60
|
+
export type { Commit };
|
|
61
|
+
/** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */
|
|
62
|
+
declare const commit: l.TypedObjectSchema<"com.atproto.sync.subscribeRepos#commit", l.Validator<Commit, Commit>>;
|
|
63
|
+
export { commit };
|
|
64
|
+
/** Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. */
|
|
65
|
+
type Sync = {
|
|
66
|
+
$type?: 'com.atproto.sync.subscribeRepos#sync';
|
|
67
|
+
/**
|
|
68
|
+
* The stream sequence number of this message.
|
|
69
|
+
*/
|
|
70
|
+
seq: number;
|
|
71
|
+
/**
|
|
72
|
+
* The account this repo event corresponds to. Must match that in the commit object.
|
|
73
|
+
*/
|
|
74
|
+
did: l.DidString;
|
|
75
|
+
/**
|
|
76
|
+
* CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.
|
|
77
|
+
*/
|
|
78
|
+
blocks: Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* The rev of the commit. This value must match that in the commit object.
|
|
81
|
+
*/
|
|
82
|
+
rev: string;
|
|
83
|
+
/**
|
|
84
|
+
* Timestamp of when this message was originally broadcast.
|
|
85
|
+
*/
|
|
86
|
+
time: l.DatetimeString;
|
|
87
|
+
};
|
|
88
|
+
export type { Sync };
|
|
89
|
+
/** Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. */
|
|
90
|
+
declare const sync: l.TypedObjectSchema<"com.atproto.sync.subscribeRepos#sync", l.Validator<Sync, Sync>>;
|
|
91
|
+
export { sync };
|
|
92
|
+
/** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */
|
|
93
|
+
type Identity = {
|
|
94
|
+
$type?: 'com.atproto.sync.subscribeRepos#identity';
|
|
95
|
+
seq: number;
|
|
96
|
+
did: l.DidString;
|
|
97
|
+
time: l.DatetimeString;
|
|
98
|
+
/**
|
|
99
|
+
* The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.
|
|
100
|
+
*/
|
|
101
|
+
handle?: l.HandleString;
|
|
102
|
+
};
|
|
103
|
+
export type { Identity };
|
|
104
|
+
/** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */
|
|
105
|
+
declare const identity: l.TypedObjectSchema<"com.atproto.sync.subscribeRepos#identity", l.Validator<Identity, Identity>>;
|
|
106
|
+
export { identity };
|
|
107
|
+
/** Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. */
|
|
108
|
+
type Account = {
|
|
109
|
+
$type?: 'com.atproto.sync.subscribeRepos#account';
|
|
110
|
+
seq: number;
|
|
111
|
+
did: l.DidString;
|
|
112
|
+
time: l.DatetimeString;
|
|
113
|
+
/**
|
|
114
|
+
* Indicates that the account has a repository which can be fetched from the host that emitted this event.
|
|
115
|
+
*/
|
|
116
|
+
active: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* If active=false, this optional field indicates a reason for why the account is not active.
|
|
119
|
+
*/
|
|
120
|
+
status?: 'takendown' | 'suspended' | 'deleted' | 'deactivated' | 'desynchronized' | 'throttled' | l.UnknownString;
|
|
121
|
+
};
|
|
122
|
+
export type { Account };
|
|
123
|
+
/** Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. */
|
|
124
|
+
declare const account: l.TypedObjectSchema<"com.atproto.sync.subscribeRepos#account", l.Validator<Account, Account>>;
|
|
125
|
+
export { account };
|
|
126
|
+
type Info = {
|
|
127
|
+
$type?: 'com.atproto.sync.subscribeRepos#info';
|
|
128
|
+
name: 'OutdatedCursor' | l.UnknownString;
|
|
129
|
+
message?: string;
|
|
130
|
+
};
|
|
131
|
+
export type { Info };
|
|
132
|
+
declare const info: l.TypedObjectSchema<"com.atproto.sync.subscribeRepos#info", l.Validator<Info, Info>>;
|
|
133
|
+
export { info };
|
|
134
|
+
/** A repo operation, ie a mutation of a single record. */
|
|
135
|
+
type RepoOp = {
|
|
136
|
+
$type?: 'com.atproto.sync.subscribeRepos#repoOp';
|
|
137
|
+
action: 'create' | 'update' | 'delete' | l.UnknownString;
|
|
138
|
+
path: string;
|
|
139
|
+
/**
|
|
140
|
+
* For creates and updates, the new record CID. For deletions, null.
|
|
141
|
+
*/
|
|
142
|
+
cid: l.Cid | null;
|
|
143
|
+
/**
|
|
144
|
+
* For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.
|
|
145
|
+
*/
|
|
146
|
+
prev?: l.Cid;
|
|
147
|
+
};
|
|
148
|
+
export type { RepoOp };
|
|
149
|
+
/** A repo operation, ie a mutation of a single record. */
|
|
150
|
+
declare const repoOp: l.TypedObjectSchema<"com.atproto.sync.subscribeRepos#repoOp", l.Validator<RepoOp, RepoOp>>;
|
|
151
|
+
export { repoOp };
|
|
152
|
+
//# sourceMappingURL=subscribeRepos.defs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribeRepos.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lex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