@atproto/tap 0.1.2 → 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 +29 -0
- package/LICENSE.txt +1 -1
- package/dist/channel.d.ts +2 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +23 -14
- package/dist/channel.js.map +1 -1
- package/dist/lex-indexer.d.ts.map +1 -1
- package/dist/lex-indexer.js +8 -6
- package/dist/lex-indexer.js.map +1 -1
- package/dist/types.d.ts +107 -258
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +33 -30
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +9 -0
- package/dist/util.js.map +1 -1
- package/package.json +8 -9
- package/src/channel.ts +28 -19
- package/src/lex-indexer.ts +14 -8
- package/src/types.ts +41 -37
- package/src/util.ts +9 -0
- package/tests/_util.ts +24 -1
- package/tests/channel.test.ts +40 -48
- package/tests/client.test.ts +6 -5
- package/tests/lex-indexer.test.ts +4 -1
- package/tests/simple-indexer.test.ts +1 -0
- package/tests/util.test.ts +1 -0
- package/tsconfig.json +4 -1
- package/tsconfig.tests.json +9 -0
- package/vitest.config.ts +5 -0
- package/jest.config.js +0 -10
package/dist/types.d.ts
CHANGED
|
@@ -1,286 +1,135 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, {
|
|
21
|
-
did: string;
|
|
22
|
-
rev: string;
|
|
23
|
-
collection: string;
|
|
24
|
-
rkey: string;
|
|
25
|
-
action: "create" | "update" | "delete";
|
|
26
|
-
live: boolean;
|
|
27
|
-
record?: Record<string, unknown> | undefined;
|
|
28
|
-
cid?: string | undefined;
|
|
1
|
+
import { LexMap, LexValue, l } from '@atproto/lex';
|
|
2
|
+
import { DidString, HandleString, NsidString } from '@atproto/syntax';
|
|
3
|
+
export declare const recordEventDataSchema: l.ObjectSchema<{
|
|
4
|
+
readonly did: l.StringSchema<{
|
|
5
|
+
readonly format: "did";
|
|
6
|
+
}>;
|
|
7
|
+
readonly rev: l.StringSchema<{}>;
|
|
8
|
+
readonly collection: l.StringSchema<{
|
|
9
|
+
readonly format: "nsid";
|
|
10
|
+
}>;
|
|
11
|
+
readonly rkey: l.StringSchema<{
|
|
12
|
+
readonly format: "record-key";
|
|
13
|
+
}>;
|
|
14
|
+
readonly action: l.EnumSchema<"create" | "update" | "delete">;
|
|
15
|
+
readonly record: l.OptionalSchema<l.UnknownObjectSchema>;
|
|
16
|
+
readonly cid: l.OptionalSchema<l.StringSchema<{
|
|
17
|
+
readonly format: "cid";
|
|
18
|
+
}>>;
|
|
19
|
+
readonly live: l.BooleanSchema;
|
|
29
20
|
}>;
|
|
30
|
-
export declare const identityEventDataSchema:
|
|
31
|
-
did:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
is_active: boolean;
|
|
40
|
-
}, {
|
|
41
|
-
did: string;
|
|
42
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
43
|
-
handle: string;
|
|
44
|
-
is_active: boolean;
|
|
21
|
+
export declare const identityEventDataSchema: l.ObjectSchema<{
|
|
22
|
+
readonly did: l.StringSchema<{
|
|
23
|
+
readonly format: "did";
|
|
24
|
+
}>;
|
|
25
|
+
readonly handle: l.StringSchema<{
|
|
26
|
+
readonly format: "handle";
|
|
27
|
+
}>;
|
|
28
|
+
readonly is_active: l.BooleanSchema;
|
|
29
|
+
readonly status: l.EnumSchema<"active" | "takendown" | "suspended" | "deactivated" | "deleted">;
|
|
45
30
|
}>;
|
|
46
|
-
export declare const recordEventSchema:
|
|
47
|
-
id:
|
|
48
|
-
type:
|
|
49
|
-
record:
|
|
50
|
-
did:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
cid?: string | undefined;
|
|
67
|
-
}, {
|
|
68
|
-
did: string;
|
|
69
|
-
rev: string;
|
|
70
|
-
collection: string;
|
|
71
|
-
rkey: string;
|
|
72
|
-
action: "create" | "update" | "delete";
|
|
73
|
-
live: boolean;
|
|
74
|
-
record?: Record<string, unknown> | undefined;
|
|
75
|
-
cid?: string | undefined;
|
|
31
|
+
export declare const recordEventSchema: l.ObjectSchema<{
|
|
32
|
+
readonly id: l.IntegerSchema;
|
|
33
|
+
readonly type: l.LiteralSchema<"record">;
|
|
34
|
+
readonly record: l.ObjectSchema<{
|
|
35
|
+
readonly did: l.StringSchema<{
|
|
36
|
+
readonly format: "did";
|
|
37
|
+
}>;
|
|
38
|
+
readonly rev: l.StringSchema<{}>;
|
|
39
|
+
readonly collection: l.StringSchema<{
|
|
40
|
+
readonly format: "nsid";
|
|
41
|
+
}>;
|
|
42
|
+
readonly rkey: l.StringSchema<{
|
|
43
|
+
readonly format: "record-key";
|
|
44
|
+
}>;
|
|
45
|
+
readonly action: l.EnumSchema<"create" | "update" | "delete">;
|
|
46
|
+
readonly record: l.OptionalSchema<l.UnknownObjectSchema>;
|
|
47
|
+
readonly cid: l.OptionalSchema<l.StringSchema<{
|
|
48
|
+
readonly format: "cid";
|
|
49
|
+
}>>;
|
|
50
|
+
readonly live: l.BooleanSchema;
|
|
76
51
|
}>;
|
|
77
|
-
}, "strip", z.ZodTypeAny, {
|
|
78
|
-
type: "record";
|
|
79
|
-
record: {
|
|
80
|
-
did: string;
|
|
81
|
-
rev: string;
|
|
82
|
-
collection: string;
|
|
83
|
-
rkey: string;
|
|
84
|
-
action: "create" | "update" | "delete";
|
|
85
|
-
live: boolean;
|
|
86
|
-
record?: Record<string, unknown> | undefined;
|
|
87
|
-
cid?: string | undefined;
|
|
88
|
-
};
|
|
89
|
-
id: number;
|
|
90
|
-
}, {
|
|
91
|
-
type: "record";
|
|
92
|
-
record: {
|
|
93
|
-
did: string;
|
|
94
|
-
rev: string;
|
|
95
|
-
collection: string;
|
|
96
|
-
rkey: string;
|
|
97
|
-
action: "create" | "update" | "delete";
|
|
98
|
-
live: boolean;
|
|
99
|
-
record?: Record<string, unknown> | undefined;
|
|
100
|
-
cid?: string | undefined;
|
|
101
|
-
};
|
|
102
|
-
id: number;
|
|
103
52
|
}>;
|
|
104
|
-
export declare const identityEventSchema:
|
|
105
|
-
id:
|
|
106
|
-
type:
|
|
107
|
-
identity:
|
|
108
|
-
did:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
is_active: boolean;
|
|
117
|
-
}, {
|
|
118
|
-
did: string;
|
|
119
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
120
|
-
handle: string;
|
|
121
|
-
is_active: boolean;
|
|
53
|
+
export declare const identityEventSchema: l.ObjectSchema<{
|
|
54
|
+
readonly id: l.IntegerSchema;
|
|
55
|
+
readonly type: l.LiteralSchema<"identity">;
|
|
56
|
+
readonly identity: l.ObjectSchema<{
|
|
57
|
+
readonly did: l.StringSchema<{
|
|
58
|
+
readonly format: "did";
|
|
59
|
+
}>;
|
|
60
|
+
readonly handle: l.StringSchema<{
|
|
61
|
+
readonly format: "handle";
|
|
62
|
+
}>;
|
|
63
|
+
readonly is_active: l.BooleanSchema;
|
|
64
|
+
readonly status: l.EnumSchema<"active" | "takendown" | "suspended" | "deactivated" | "deleted">;
|
|
122
65
|
}>;
|
|
123
|
-
}, "strip", z.ZodTypeAny, {
|
|
124
|
-
type: "identity";
|
|
125
|
-
id: number;
|
|
126
|
-
identity: {
|
|
127
|
-
did: string;
|
|
128
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
129
|
-
handle: string;
|
|
130
|
-
is_active: boolean;
|
|
131
|
-
};
|
|
132
|
-
}, {
|
|
133
|
-
type: "identity";
|
|
134
|
-
id: number;
|
|
135
|
-
identity: {
|
|
136
|
-
did: string;
|
|
137
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
138
|
-
handle: string;
|
|
139
|
-
is_active: boolean;
|
|
140
|
-
};
|
|
141
66
|
}>;
|
|
142
|
-
export declare const tapEventSchema:
|
|
143
|
-
id:
|
|
144
|
-
type:
|
|
145
|
-
record:
|
|
146
|
-
did:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
cid?: string | undefined;
|
|
163
|
-
}, {
|
|
164
|
-
did: string;
|
|
165
|
-
rev: string;
|
|
166
|
-
collection: string;
|
|
167
|
-
rkey: string;
|
|
168
|
-
action: "create" | "update" | "delete";
|
|
169
|
-
live: boolean;
|
|
170
|
-
record?: Record<string, unknown> | undefined;
|
|
171
|
-
cid?: string | undefined;
|
|
67
|
+
export declare const tapEventSchema: l.DiscriminatedUnionSchema<"type", readonly [l.ObjectSchema<{
|
|
68
|
+
readonly id: l.IntegerSchema;
|
|
69
|
+
readonly type: l.LiteralSchema<"record">;
|
|
70
|
+
readonly record: l.ObjectSchema<{
|
|
71
|
+
readonly did: l.StringSchema<{
|
|
72
|
+
readonly format: "did";
|
|
73
|
+
}>;
|
|
74
|
+
readonly rev: l.StringSchema<{}>;
|
|
75
|
+
readonly collection: l.StringSchema<{
|
|
76
|
+
readonly format: "nsid";
|
|
77
|
+
}>;
|
|
78
|
+
readonly rkey: l.StringSchema<{
|
|
79
|
+
readonly format: "record-key";
|
|
80
|
+
}>;
|
|
81
|
+
readonly action: l.EnumSchema<"create" | "update" | "delete">;
|
|
82
|
+
readonly record: l.OptionalSchema<l.UnknownObjectSchema>;
|
|
83
|
+
readonly cid: l.OptionalSchema<l.StringSchema<{
|
|
84
|
+
readonly format: "cid";
|
|
85
|
+
}>>;
|
|
86
|
+
readonly live: l.BooleanSchema;
|
|
172
87
|
}>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
id: number;
|
|
186
|
-
}, {
|
|
187
|
-
type: "record";
|
|
188
|
-
record: {
|
|
189
|
-
did: string;
|
|
190
|
-
rev: string;
|
|
191
|
-
collection: string;
|
|
192
|
-
rkey: string;
|
|
193
|
-
action: "create" | "update" | "delete";
|
|
194
|
-
live: boolean;
|
|
195
|
-
record?: Record<string, unknown> | undefined;
|
|
196
|
-
cid?: string | undefined;
|
|
197
|
-
};
|
|
198
|
-
id: number;
|
|
199
|
-
}>, z.ZodObject<{
|
|
200
|
-
id: z.ZodNumber;
|
|
201
|
-
type: z.ZodLiteral<"identity">;
|
|
202
|
-
identity: z.ZodObject<{
|
|
203
|
-
did: z.ZodString;
|
|
204
|
-
handle: z.ZodString;
|
|
205
|
-
is_active: z.ZodBoolean;
|
|
206
|
-
status: z.ZodEnum<["active", "takendown", "suspended", "deactivated", "deleted"]>;
|
|
207
|
-
}, "strip", z.ZodTypeAny, {
|
|
208
|
-
did: string;
|
|
209
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
210
|
-
handle: string;
|
|
211
|
-
is_active: boolean;
|
|
212
|
-
}, {
|
|
213
|
-
did: string;
|
|
214
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
215
|
-
handle: string;
|
|
216
|
-
is_active: boolean;
|
|
88
|
+
}>, l.ObjectSchema<{
|
|
89
|
+
readonly id: l.IntegerSchema;
|
|
90
|
+
readonly type: l.LiteralSchema<"identity">;
|
|
91
|
+
readonly identity: l.ObjectSchema<{
|
|
92
|
+
readonly did: l.StringSchema<{
|
|
93
|
+
readonly format: "did";
|
|
94
|
+
}>;
|
|
95
|
+
readonly handle: l.StringSchema<{
|
|
96
|
+
readonly format: "handle";
|
|
97
|
+
}>;
|
|
98
|
+
readonly is_active: l.BooleanSchema;
|
|
99
|
+
readonly status: l.EnumSchema<"active" | "takendown" | "suspended" | "deactivated" | "deleted">;
|
|
217
100
|
}>;
|
|
218
|
-
}, "strip", z.ZodTypeAny, {
|
|
219
|
-
type: "identity";
|
|
220
|
-
id: number;
|
|
221
|
-
identity: {
|
|
222
|
-
did: string;
|
|
223
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
224
|
-
handle: string;
|
|
225
|
-
is_active: boolean;
|
|
226
|
-
};
|
|
227
|
-
}, {
|
|
228
|
-
type: "identity";
|
|
229
|
-
id: number;
|
|
230
|
-
identity: {
|
|
231
|
-
did: string;
|
|
232
|
-
status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
|
|
233
|
-
handle: string;
|
|
234
|
-
is_active: boolean;
|
|
235
|
-
};
|
|
236
101
|
}>]>;
|
|
237
102
|
export type RecordEvent = {
|
|
238
103
|
id: number;
|
|
239
104
|
type: 'record';
|
|
240
105
|
action: 'create' | 'update' | 'delete';
|
|
241
|
-
did:
|
|
106
|
+
did: DidString;
|
|
242
107
|
rev: string;
|
|
243
|
-
collection:
|
|
108
|
+
collection: NsidString;
|
|
244
109
|
rkey: string;
|
|
245
|
-
record?:
|
|
110
|
+
record?: LexMap;
|
|
246
111
|
cid?: string;
|
|
247
112
|
live: boolean;
|
|
248
113
|
};
|
|
249
114
|
export type IdentityEvent = {
|
|
250
115
|
id: number;
|
|
251
116
|
type: 'identity';
|
|
252
|
-
did:
|
|
253
|
-
handle:
|
|
117
|
+
did: DidString;
|
|
118
|
+
handle: HandleString;
|
|
254
119
|
isActive: boolean;
|
|
255
120
|
status: RepoStatus;
|
|
256
121
|
};
|
|
257
122
|
export type RepoStatus = 'active' | 'takendown' | 'suspended' | 'deactivated' | 'deleted';
|
|
258
123
|
export type TapEvent = IdentityEvent | RecordEvent;
|
|
259
|
-
export declare const parseTapEvent: (data:
|
|
260
|
-
export declare const repoInfoSchema:
|
|
261
|
-
did:
|
|
262
|
-
handle:
|
|
263
|
-
state:
|
|
264
|
-
rev:
|
|
265
|
-
records:
|
|
266
|
-
error:
|
|
267
|
-
retries:
|
|
268
|
-
}, "strip", z.ZodTypeAny, {
|
|
269
|
-
did: string;
|
|
270
|
-
rev: string;
|
|
271
|
-
handle: string;
|
|
272
|
-
state: string;
|
|
273
|
-
records: number;
|
|
274
|
-
error?: string | undefined;
|
|
275
|
-
retries?: number | undefined;
|
|
276
|
-
}, {
|
|
277
|
-
did: string;
|
|
278
|
-
rev: string;
|
|
279
|
-
handle: string;
|
|
280
|
-
state: string;
|
|
281
|
-
records: number;
|
|
282
|
-
error?: string | undefined;
|
|
283
|
-
retries?: number | undefined;
|
|
124
|
+
export declare const parseTapEvent: (data: LexValue) => TapEvent;
|
|
125
|
+
export declare const repoInfoSchema: l.ObjectSchema<{
|
|
126
|
+
readonly did: l.StringSchema<{}>;
|
|
127
|
+
readonly handle: l.StringSchema<{}>;
|
|
128
|
+
readonly state: l.StringSchema<{}>;
|
|
129
|
+
readonly rev: l.StringSchema<{}>;
|
|
130
|
+
readonly records: l.IntegerSchema;
|
|
131
|
+
readonly error: l.OptionalSchema<l.StringSchema<{}>>;
|
|
132
|
+
readonly retries: l.OptionalSchema<l.IntegerSchema>;
|
|
284
133
|
}>;
|
|
285
|
-
export type RepoInfo =
|
|
134
|
+
export type RepoInfo = l.Infer<typeof repoInfoSchema>;
|
|
286
135
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAErE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;EAShC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;EAWlC,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAI5B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;EAI9B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGzB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACtC,GAAG,EAAE,SAAS,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,UAAU,CAAA;IAChB,GAAG,EAAE,SAAS,CAAA;IACd,MAAM,EAAE,YAAY,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,WAAW,GACX,WAAW,GACX,aAAa,GACb,SAAS,CAAA;AAEb,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,WAAW,CAAA;AAElD,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,KAAG,QAyB9C,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;EAQzB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
package/dist/types.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.repoInfoSchema = exports.parseTapEvent = exports.tapEventSchema = exports.identityEventSchema = exports.recordEventSchema = exports.identityEventDataSchema = exports.recordEventDataSchema = void 0;
|
|
4
|
-
const
|
|
5
|
-
exports.recordEventDataSchema =
|
|
6
|
-
did:
|
|
7
|
-
rev:
|
|
8
|
-
collection:
|
|
9
|
-
rkey:
|
|
10
|
-
action:
|
|
11
|
-
record:
|
|
12
|
-
cid:
|
|
13
|
-
live:
|
|
4
|
+
const lex_1 = require("@atproto/lex");
|
|
5
|
+
exports.recordEventDataSchema = lex_1.l.object({
|
|
6
|
+
did: lex_1.l.string({ format: 'did' }),
|
|
7
|
+
rev: lex_1.l.string(),
|
|
8
|
+
collection: lex_1.l.string({ format: 'nsid' }),
|
|
9
|
+
rkey: lex_1.l.string({ format: 'record-key' }),
|
|
10
|
+
action: lex_1.l.enum(['create', 'update', 'delete']),
|
|
11
|
+
record: lex_1.l.optional(lex_1.l.unknownObject()),
|
|
12
|
+
cid: lex_1.l.optional(lex_1.l.string({ format: 'cid' })),
|
|
13
|
+
live: lex_1.l.boolean(),
|
|
14
14
|
});
|
|
15
|
-
exports.identityEventDataSchema =
|
|
16
|
-
did:
|
|
17
|
-
handle:
|
|
18
|
-
is_active:
|
|
19
|
-
status:
|
|
15
|
+
exports.identityEventDataSchema = lex_1.l.object({
|
|
16
|
+
did: lex_1.l.string({ format: 'did' }),
|
|
17
|
+
handle: lex_1.l.string({ format: 'handle' }),
|
|
18
|
+
is_active: lex_1.l.boolean(),
|
|
19
|
+
status: lex_1.l.enum([
|
|
20
20
|
'active',
|
|
21
21
|
'takendown',
|
|
22
22
|
'suspended',
|
|
@@ -24,17 +24,20 @@ exports.identityEventDataSchema = zod_1.z.object({
|
|
|
24
24
|
'deleted',
|
|
25
25
|
]),
|
|
26
26
|
});
|
|
27
|
-
exports.recordEventSchema =
|
|
28
|
-
id:
|
|
29
|
-
type:
|
|
27
|
+
exports.recordEventSchema = lex_1.l.object({
|
|
28
|
+
id: lex_1.l.integer(),
|
|
29
|
+
type: lex_1.l.literal('record'),
|
|
30
30
|
record: exports.recordEventDataSchema,
|
|
31
31
|
});
|
|
32
|
-
exports.identityEventSchema =
|
|
33
|
-
id:
|
|
34
|
-
type:
|
|
32
|
+
exports.identityEventSchema = lex_1.l.object({
|
|
33
|
+
id: lex_1.l.integer(),
|
|
34
|
+
type: lex_1.l.literal('identity'),
|
|
35
35
|
identity: exports.identityEventDataSchema,
|
|
36
36
|
});
|
|
37
|
-
exports.tapEventSchema =
|
|
37
|
+
exports.tapEventSchema = lex_1.l.discriminatedUnion('type', [
|
|
38
|
+
exports.recordEventSchema,
|
|
39
|
+
exports.identityEventSchema,
|
|
40
|
+
]);
|
|
38
41
|
const parseTapEvent = (data) => {
|
|
39
42
|
const parsed = exports.tapEventSchema.parse(data);
|
|
40
43
|
if (parsed.type === 'identity') {
|
|
@@ -63,13 +66,13 @@ const parseTapEvent = (data) => {
|
|
|
63
66
|
}
|
|
64
67
|
};
|
|
65
68
|
exports.parseTapEvent = parseTapEvent;
|
|
66
|
-
exports.repoInfoSchema =
|
|
67
|
-
did:
|
|
68
|
-
handle:
|
|
69
|
-
state:
|
|
70
|
-
rev:
|
|
71
|
-
records:
|
|
72
|
-
error:
|
|
73
|
-
retries:
|
|
69
|
+
exports.repoInfoSchema = lex_1.l.object({
|
|
70
|
+
did: lex_1.l.string(),
|
|
71
|
+
handle: lex_1.l.string(),
|
|
72
|
+
state: lex_1.l.string(),
|
|
73
|
+
rev: lex_1.l.string(),
|
|
74
|
+
records: lex_1.l.integer(),
|
|
75
|
+
error: lex_1.l.optional(lex_1.l.string()),
|
|
76
|
+
retries: lex_1.l.optional(lex_1.l.integer()),
|
|
74
77
|
});
|
|
75
78
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,sCAAkD;AAGrC,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACxC,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,aAAa,EAAE,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5C,IAAI,EAAE,OAAC,CAAC,OAAO,EAAE;CAClB,CAAC,CAAA;AAE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Q,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;YACnC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;SAC/B,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;YAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;YACpC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;YACxB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;YAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;SACzB,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAzBY,QAAA,aAAa,iBAyBzB;AAEY,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;CACjC,CAAC,CAAA","sourcesContent":["import { LexMap, LexValue, l } from '@atproto/lex'\nimport { DidString, HandleString, NsidString } from '@atproto/syntax'\n\nexport const recordEventDataSchema = l.object({\n did: l.string({ format: 'did' }),\n rev: l.string(),\n collection: l.string({ format: 'nsid' }),\n rkey: l.string({ format: 'record-key' }),\n action: l.enum(['create', 'update', 'delete']),\n record: l.optional(l.unknownObject()),\n cid: l.optional(l.string({ format: 'cid' })),\n live: l.boolean(),\n})\n\nexport const identityEventDataSchema = l.object({\n did: l.string({ format: 'did' }),\n handle: l.string({ format: 'handle' }),\n is_active: l.boolean(),\n status: l.enum([\n 'active',\n 'takendown',\n 'suspended',\n 'deactivated',\n 'deleted',\n ]),\n})\n\nexport const recordEventSchema = l.object({\n id: l.integer(),\n type: l.literal('record'),\n record: recordEventDataSchema,\n})\n\nexport const identityEventSchema = l.object({\n id: l.integer(),\n type: l.literal('identity'),\n identity: identityEventDataSchema,\n})\n\nexport const tapEventSchema = l.discriminatedUnion('type', [\n recordEventSchema,\n identityEventSchema,\n])\n\nexport type RecordEvent = {\n id: number\n type: 'record'\n action: 'create' | 'update' | 'delete'\n did: DidString\n rev: string\n collection: NsidString\n rkey: string\n record?: LexMap\n cid?: string\n live: boolean\n}\n\nexport type IdentityEvent = {\n id: number\n type: 'identity'\n did: DidString\n handle: HandleString\n isActive: boolean\n status: RepoStatus\n}\n\nexport type RepoStatus =\n | 'active'\n | 'takendown'\n | 'suspended'\n | 'deactivated'\n | 'deleted'\n\nexport type TapEvent = IdentityEvent | RecordEvent\n\nexport const parseTapEvent = (data: LexValue): TapEvent => {\n const parsed = tapEventSchema.parse(data)\n if (parsed.type === 'identity') {\n return {\n id: parsed.id,\n type: parsed.type,\n did: parsed.identity.did,\n handle: parsed.identity.handle,\n isActive: parsed.identity.is_active,\n status: parsed.identity.status,\n }\n } else {\n return {\n id: parsed.id,\n type: parsed.type,\n action: parsed.record.action,\n did: parsed.record.did,\n rev: parsed.record.rev,\n collection: parsed.record.collection,\n rkey: parsed.record.rkey,\n record: parsed.record.record,\n cid: parsed.record.cid,\n live: parsed.record.live,\n }\n }\n}\n\nexport const repoInfoSchema = l.object({\n did: l.string(),\n handle: l.string(),\n state: l.string(),\n rev: l.string(),\n records: l.integer(),\n error: l.optional(l.string()),\n retries: l.optional(l.integer()),\n})\n\nexport type RepoInfo = l.Infer<typeof repoInfoSchema>\n"]}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const formatAdminAuthHeader: (password: string) => string;
|
|
2
2
|
export declare const parseAdminAuthHeader: (header: string) => string;
|
|
3
3
|
export declare const assureAdminAuth: (expectedPassword: string, header: string) => void;
|
|
4
|
+
export declare function isCausedBySignal(err: unknown, signal: AbortSignal): boolean;
|
|
4
5
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,WAErD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,WASlD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,kBAAkB,MAAM,EAAE,QAAQ,MAAM,SAMvE,CAAA"}
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,WAErD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,WASlD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,kBAAkB,MAAM,EAAE,QAAQ,MAAM,SAMvE,CAAA;AAaD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,WAOjE"}
|
package/dist/util.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assureAdminAuth = exports.parseAdminAuthHeader = exports.formatAdminAuthHeader = void 0;
|
|
4
|
+
exports.isCausedBySignal = isCausedBySignal;
|
|
4
5
|
const formatAdminAuthHeader = (password) => {
|
|
5
6
|
return 'Basic ' + Buffer.from(`admin:${password}`).toString('base64');
|
|
6
7
|
};
|
|
@@ -34,4 +35,12 @@ const timingSafeEqual = (a, b) => {
|
|
|
34
35
|
}
|
|
35
36
|
return bufA.compare(bufB) === 0;
|
|
36
37
|
};
|
|
38
|
+
function isCausedBySignal(err, signal) {
|
|
39
|
+
if (!signal.aborted)
|
|
40
|
+
return false;
|
|
41
|
+
if (signal.reason == null)
|
|
42
|
+
return false; // Ignore nullish reasons
|
|
43
|
+
return (err === signal.reason ||
|
|
44
|
+
(err instanceof Error && err.cause === signal.reason));
|
|
45
|
+
}
|
|
37
46
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAkCA,4CAOC;AAzCM,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACxD,OAAO,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACvE,CAAC,CAAA;AAFY,QAAA,qBAAqB,yBAEjC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,EAAE;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IACvE,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;SACzD,QAAQ,EAAE;SACV,KAAK,CAAC,GAAG,CAAC,CAAA;IACb,IAAI,QAAQ,KAAK,OAAO,EAA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AY,KAAK,IAAI,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,CACtD,CAAA;AACH,CAAC","sourcesContent":["export const formatAdminAuthHeader = (password: string) => {\n return 'Basic ' + Buffer.from(`admin:${password}`).toString('base64')\n}\n\nexport const parseAdminAuthHeader = (header: string) => {\n const noPrefix = header.startsWith('Basic ') ? header.slice(6) : header\n const [username, password] = Buffer.from(noPrefix, 'base64')\n .toString()\n .split(':')\n if (username !== 'admin') {\n throw new Error(\"Unexpected username in admin headers. Expected 'admin'\")\n }\n return password\n}\n\nexport const assureAdminAuth = (expectedPassword: string, header: string) => {\n const headerPassword = parseAdminAuthHeader(header)\n const passEqual = timingSafeEqual(headerPassword, expectedPassword)\n if (!passEqual) {\n throw new Error('Invalid admin password')\n }\n}\n\nconst timingSafeEqual = (a: string, b: string): boolean => {\n const bufA = Buffer.from(a)\n const bufB = Buffer.from(b)\n if (bufA.length !== bufB.length) {\n // Compare against self to maintain constant time even with length mismatch\n Buffer.from(a).compare(Buffer.from(a))\n return false\n }\n return bufA.compare(bufB) === 0\n}\n\nexport function isCausedBySignal(err: unknown, signal: AbortSignal) {\n if (!signal.aborted) return false\n if (signal.reason == null) return false // Ignore nullish reasons\n return (\n err === signal.reason ||\n (err instanceof Error && err.cause === signal.reason)\n )\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/tap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "atproto tap client",
|
|
6
6
|
"keywords": [
|
|
@@ -23,22 +23,21 @@
|
|
|
23
23
|
"types": "dist/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"ws": "^8.12.0",
|
|
26
|
-
"
|
|
27
|
-
"@atproto/
|
|
28
|
-
"@atproto/
|
|
29
|
-
"@atproto/syntax": "^0.4.2",
|
|
26
|
+
"@atproto/common": "^0.5.9",
|
|
27
|
+
"@atproto/lex": "^0.0.12",
|
|
28
|
+
"@atproto/syntax": "^0.4.3",
|
|
30
29
|
"@atproto/ws-client": "^0.0.4"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
32
|
"@types/express": "^4.17.17",
|
|
34
33
|
"@types/ws": "^8.5.4",
|
|
35
34
|
"express": "^4.18.2",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
35
|
+
"typescript": "^5.6.3",
|
|
36
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
37
|
+
"vitest": "^4.0.16"
|
|
39
38
|
},
|
|
40
39
|
"scripts": {
|
|
41
40
|
"build": "tsc --build tsconfig.build.json",
|
|
42
|
-
"test": "
|
|
41
|
+
"test": "vitest run"
|
|
43
42
|
}
|
|
44
43
|
}
|