@atproto/tap 0.0.0-spaces-alpha-20260818163953
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 +372 -0
- package/LICENSE.txt +7 -0
- package/README.md +268 -0
- package/dist/channel.d.ts +57 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +175 -0
- package/dist/channel.js.map +1 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +84 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lex-indexer.d.ts +46 -0
- package/dist/lex-indexer.d.ts.map +1 -0
- package/dist/lex-indexer.js +90 -0
- package/dist/lex-indexer.js.map +1 -0
- package/dist/simple-indexer.d.ts +17 -0
- package/dist/simple-indexer.d.ts.map +1 -0
- package/dist/simple-indexer.js +32 -0
- package/dist/simple-indexer.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +74 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +39 -0
- package/dist/util.js.map +1 -0
- package/package.json +52 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type LexMap, type LexValue, l } from '@atproto/lex';
|
|
2
|
+
import type { 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" | "delete" | "update">;
|
|
15
|
+
readonly record: l.OptionalSchema<l.LexMapSchema>;
|
|
16
|
+
readonly cid: l.OptionalSchema<l.StringSchema<{
|
|
17
|
+
readonly format: "cid";
|
|
18
|
+
}>>;
|
|
19
|
+
readonly live: l.BooleanSchema;
|
|
20
|
+
}>;
|
|
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" | "deactivated" | "deleted" | "suspended" | "takendown">;
|
|
30
|
+
}>;
|
|
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" | "delete" | "update">;
|
|
46
|
+
readonly record: l.OptionalSchema<l.LexMapSchema>;
|
|
47
|
+
readonly cid: l.OptionalSchema<l.StringSchema<{
|
|
48
|
+
readonly format: "cid";
|
|
49
|
+
}>>;
|
|
50
|
+
readonly live: l.BooleanSchema;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
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" | "deactivated" | "deleted" | "suspended" | "takendown">;
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|
|
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" | "delete" | "update">;
|
|
82
|
+
readonly record: l.OptionalSchema<l.LexMapSchema>;
|
|
83
|
+
readonly cid: l.OptionalSchema<l.StringSchema<{
|
|
84
|
+
readonly format: "cid";
|
|
85
|
+
}>>;
|
|
86
|
+
readonly live: l.BooleanSchema;
|
|
87
|
+
}>;
|
|
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" | "deactivated" | "deleted" | "suspended" | "takendown">;
|
|
100
|
+
}>;
|
|
101
|
+
}>]>;
|
|
102
|
+
export type RecordEvent = {
|
|
103
|
+
id: number;
|
|
104
|
+
type: 'record';
|
|
105
|
+
action: 'create' | 'update' | 'delete';
|
|
106
|
+
did: DidString;
|
|
107
|
+
rev: string;
|
|
108
|
+
collection: NsidString;
|
|
109
|
+
rkey: string;
|
|
110
|
+
record?: LexMap;
|
|
111
|
+
cid?: string;
|
|
112
|
+
live: boolean;
|
|
113
|
+
};
|
|
114
|
+
export type IdentityEvent = {
|
|
115
|
+
id: number;
|
|
116
|
+
type: 'identity';
|
|
117
|
+
did: DidString;
|
|
118
|
+
handle: HandleString;
|
|
119
|
+
isActive: boolean;
|
|
120
|
+
status: RepoStatus;
|
|
121
|
+
};
|
|
122
|
+
export type RepoStatus = 'active' | 'takendown' | 'suspended' | 'deactivated' | 'deleted';
|
|
123
|
+
export type TapEvent = IdentityEvent | RecordEvent;
|
|
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>;
|
|
133
|
+
}>;
|
|
134
|
+
export type RepoInfo = l.Infer<typeof repoInfoSchema>;
|
|
135
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.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,aAAa,GAAG,WAAW,CAAA;AAElD,eAAO,MAAM,aAAa,SAAU,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
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { l } from '@atproto/lex';
|
|
2
|
+
export const recordEventDataSchema = l.object({
|
|
3
|
+
did: l.string({ format: 'did' }),
|
|
4
|
+
rev: l.string(),
|
|
5
|
+
collection: l.string({ format: 'nsid' }),
|
|
6
|
+
rkey: l.string({ format: 'record-key' }),
|
|
7
|
+
action: l.enum(['create', 'update', 'delete']),
|
|
8
|
+
record: l.optional(l.lexMap()),
|
|
9
|
+
cid: l.optional(l.string({ format: 'cid' })),
|
|
10
|
+
live: l.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export const identityEventDataSchema = l.object({
|
|
13
|
+
did: l.string({ format: 'did' }),
|
|
14
|
+
handle: l.string({ format: 'handle' }),
|
|
15
|
+
is_active: l.boolean(),
|
|
16
|
+
status: l.enum([
|
|
17
|
+
'active',
|
|
18
|
+
'takendown',
|
|
19
|
+
'suspended',
|
|
20
|
+
'deactivated',
|
|
21
|
+
'deleted',
|
|
22
|
+
]),
|
|
23
|
+
});
|
|
24
|
+
export const recordEventSchema = l.object({
|
|
25
|
+
id: l.integer(),
|
|
26
|
+
type: l.literal('record'),
|
|
27
|
+
record: recordEventDataSchema,
|
|
28
|
+
});
|
|
29
|
+
export const identityEventSchema = l.object({
|
|
30
|
+
id: l.integer(),
|
|
31
|
+
type: l.literal('identity'),
|
|
32
|
+
identity: identityEventDataSchema,
|
|
33
|
+
});
|
|
34
|
+
export const tapEventSchema = l.discriminatedUnion('type', [
|
|
35
|
+
recordEventSchema,
|
|
36
|
+
identityEventSchema,
|
|
37
|
+
]);
|
|
38
|
+
export const parseTapEvent = (data) => {
|
|
39
|
+
const parsed = tapEventSchema.parse(data);
|
|
40
|
+
if (parsed.type === 'identity') {
|
|
41
|
+
return {
|
|
42
|
+
id: parsed.id,
|
|
43
|
+
type: parsed.type,
|
|
44
|
+
did: parsed.identity.did,
|
|
45
|
+
handle: parsed.identity.handle,
|
|
46
|
+
isActive: parsed.identity.is_active,
|
|
47
|
+
status: parsed.identity.status,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return {
|
|
52
|
+
id: parsed.id,
|
|
53
|
+
type: parsed.type,
|
|
54
|
+
action: parsed.record.action,
|
|
55
|
+
did: parsed.record.did,
|
|
56
|
+
rev: parsed.record.rev,
|
|
57
|
+
collection: parsed.record.collection,
|
|
58
|
+
rkey: parsed.record.rkey,
|
|
59
|
+
record: parsed.record.record,
|
|
60
|
+
cid: parsed.record.cid,
|
|
61
|
+
live: parsed.record.live,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export const repoInfoSchema = l.object({
|
|
66
|
+
did: l.string(),
|
|
67
|
+
handle: l.string(),
|
|
68
|
+
state: l.string(),
|
|
69
|
+
rev: l.string(),
|
|
70
|
+
records: l.integer(),
|
|
71
|
+
error: l.optional(l.string()),
|
|
72
|
+
retries: l.optional(l.integer()),
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,CAAC,EAAE,MAAM,cAAc,CAAA;AAG5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAA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AAM,EAAE;IACf,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CACjC,CAAC,CAAA","sourcesContent":["import { type LexMap, type LexValue, l } from '@atproto/lex'\nimport type { 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.lexMap()),\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' | 'takendown' | 'suspended' | 'deactivated' | '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
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const formatAdminAuthHeader: (password: string) => string;
|
|
2
|
+
export declare const parseAdminAuthHeader: (header: string) => string;
|
|
3
|
+
export declare const assureAdminAuth: (expectedPassword: string, header: string) => void;
|
|
4
|
+
export declare function isCausedBySignal(err: unknown, signal: AbortSignal): boolean;
|
|
5
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,aAAc,MAAM,WAErD,CAAA;AAED,eAAO,MAAM,oBAAoB,WAAY,MAAM,WASlD,CAAA;AAED,eAAO,MAAM,eAAe,qBAAsB,MAAM,UAAU,MAAM,SAMvE,CAAA;AAaD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,WAOjE"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const formatAdminAuthHeader = (password) => {
|
|
2
|
+
return 'Basic ' + Buffer.from(`admin:${password}`).toString('base64');
|
|
3
|
+
};
|
|
4
|
+
export const parseAdminAuthHeader = (header) => {
|
|
5
|
+
const noPrefix = header.startsWith('Basic ') ? header.slice(6) : header;
|
|
6
|
+
const [username, password] = Buffer.from(noPrefix, 'base64')
|
|
7
|
+
.toString()
|
|
8
|
+
.split(':');
|
|
9
|
+
if (username !== 'admin') {
|
|
10
|
+
throw new Error("Unexpected username in admin headers. Expected 'admin'");
|
|
11
|
+
}
|
|
12
|
+
return password;
|
|
13
|
+
};
|
|
14
|
+
export const assureAdminAuth = (expectedPassword, header) => {
|
|
15
|
+
const headerPassword = parseAdminAuthHeader(header);
|
|
16
|
+
const passEqual = timingSafeEqual(headerPassword, expectedPassword);
|
|
17
|
+
if (!passEqual) {
|
|
18
|
+
throw new Error('Invalid admin password');
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const timingSafeEqual = (a, b) => {
|
|
22
|
+
const bufA = Buffer.from(a);
|
|
23
|
+
const bufB = Buffer.from(b);
|
|
24
|
+
if (bufA.length !== bufB.length) {
|
|
25
|
+
// Compare against self to maintain constant time even with length mismatch
|
|
26
|
+
Buffer.from(a).compare(Buffer.from(a));
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return bufA.compare(bufB) === 0;
|
|
30
|
+
};
|
|
31
|
+
export function isCausedBySignal(err, signal) {
|
|
32
|
+
if (!signal.aborted)
|
|
33
|
+
return false;
|
|
34
|
+
if (signal.reason == null)
|
|
35
|
+
return false; // Ignore nullish reasons
|
|
36
|
+
return (err === signal.reason ||
|
|
37
|
+
(err instanceof Error && err.cause === signal.reason));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,M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IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,2EAA2E;QAC3E,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACtC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC,CAAA;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAY,EAAE,MAAmB;IAChE,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IACjC,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA,CAAC,yBAAyB;IACjE,OAAO,CACL,GAAG,KAAK,MAAM,CAAC,MAAM;QACrB,CAAC,GAAG,YAAY,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
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atproto/tap",
|
|
3
|
+
"version": "0.0.0-spaces-alpha-20260818163953",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "atproto tap client",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"atproto",
|
|
8
|
+
"tap",
|
|
9
|
+
"sync",
|
|
10
|
+
"firehose",
|
|
11
|
+
"relay"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://atproto.com",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/bluesky-social/atproto",
|
|
17
|
+
"directory": "packages/tap"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"./dist",
|
|
21
|
+
"./README.md",
|
|
22
|
+
"./CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"ws": "^8.12.0",
|
|
36
|
+
"@atproto/lex": "^0.0.0-spaces-alpha-20260818163953",
|
|
37
|
+
"@atproto/syntax": "^0.0.0-spaces-alpha-20260818163953",
|
|
38
|
+
"@atproto/ws-client": "^0.2.0",
|
|
39
|
+
"@atproto/common": "^0.0.0-spaces-alpha-20260818163953"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/express": "^4.17.17",
|
|
43
|
+
"@types/ws": "^8.5.4",
|
|
44
|
+
"express": "^4.18.2",
|
|
45
|
+
"http-terminator": "^3.2.0",
|
|
46
|
+
"vitest": "^4.1.10"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc --build tsconfig.build.json",
|
|
50
|
+
"test": "vitest run"
|
|
51
|
+
}
|
|
52
|
+
}
|