@atproto/dev-env 0.5.13 → 0.5.15
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/dist/bin.js +2 -1
- package/dist/bin.js.map +1 -1
- package/dist/bsky.d.ts +1 -0
- package/dist/bsky.d.ts.map +1 -1
- package/dist/bsky.js +26 -6
- package/dist/bsky.js.map +1 -1
- package/dist/feed-gen.d.ts +4 -1
- package/dist/feed-gen.d.ts.map +1 -1
- package/dist/feed-gen.js +10 -11
- package/dist/feed-gen.js.map +1 -1
- package/dist/introspect.d.ts +1 -0
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +4 -2
- package/dist/introspect.js.map +1 -1
- package/dist/network.d.ts +1 -0
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +22 -8
- package/dist/network.js.map +1 -1
- package/dist/ozone.d.ts +1 -0
- package/dist/ozone.d.ts.map +1 -1
- package/dist/ozone.js +9 -2
- package/dist/ozone.js.map +1 -1
- package/dist/pds.d.ts +1 -0
- package/dist/pds.d.ts.map +1 -1
- package/dist/pds.js +3 -0
- package/dist/pds.js.map +1 -1
- package/dist/seed/basic.d.ts +1 -2
- package/dist/seed/basic.d.ts.map +1 -1
- package/dist/seed/basic.js +2 -2
- package/dist/seed/basic.js.map +1 -1
- package/dist/seed/users-bulk.d.ts +1 -2
- package/dist/seed/users-bulk.d.ts.map +1 -1
- package/dist/seed/users-bulk.js +2 -2
- package/dist/seed/users-bulk.js.map +1 -1
- package/dist/seed/users.d.ts +1 -2
- package/dist/seed/users.d.ts.map +1 -1
- package/dist/seed/users.js +2 -2
- package/dist/seed/users.js.map +1 -1
- package/package.json +12 -11
- package/src/bin.ts +2 -2
- package/src/bsky.ts +23 -6
- package/src/feed-gen.ts +16 -10
- package/src/introspect.ts +7 -3
- package/src/network.ts +21 -8
- package/src/ozone.ts +9 -2
- package/src/pds.ts +4 -0
- package/src/seed/basic.ts +2 -2
- package/src/seed/users-bulk.ts +1 -1
- package/src/seed/users.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @atproto/dev-env
|
|
2
2
|
|
|
3
|
+
## 0.5.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`ef3adfa`](https://github.com/bluesky-social/atproto/commit/ef3adfaa0731a57780ccf6f1f81183c1938e1af4), [`5206b3a`](https://github.com/bluesky-social/atproto/commit/5206b3aae30b1efe39cff8cccbabb5932cd49a3d)]:
|
|
8
|
+
- @atproto/api@0.20.18
|
|
9
|
+
- @atproto/bsky@0.0.245
|
|
10
|
+
- @atproto/pds@0.5.7
|
|
11
|
+
|
|
12
|
+
## 0.5.14
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#5116](https://github.com/bluesky-social/atproto/pull/5116) [`39f5c01`](https://github.com/bluesky-social/atproto/commit/39f5c018791ae70391fc86f44be283075dfa206b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update undici dependency to v8.5.0
|
|
17
|
+
|
|
18
|
+
- [#5117](https://github.com/bluesky-social/atproto/pull/5117) [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Don't await for firehose events to be processed in `processAll()` when firehose subscription is stopped
|
|
19
|
+
|
|
20
|
+
- [#5117](https://github.com/bluesky-social/atproto/pull/5117) [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Make tests less flaky in CI
|
|
21
|
+
|
|
22
|
+
- [#5117](https://github.com/bluesky-social/atproto/pull/5117) [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use http-terminator to close http server
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [[`3002e9f`](https://github.com/bluesky-social/atproto/commit/3002e9f195df9715395cb72cd3e613f6e5239679), [`39f5c01`](https://github.com/bluesky-social/atproto/commit/39f5c018791ae70391fc86f44be283075dfa206b), [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b), [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b), [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b), [`7011bdb`](https://github.com/bluesky-social/atproto/commit/7011bdb1905cb81b10a3ca6ddbc0a6afffc23a70), [`cab3ac3`](https://github.com/bluesky-social/atproto/commit/cab3ac321bf939a4c8ba29aed3f632d8a91790bf), [`8a4c88b`](https://github.com/bluesky-social/atproto/commit/8a4c88b0f63fb2d82b1391d64c54e0c760fac48b)]:
|
|
25
|
+
- @atproto/bsky@0.0.244
|
|
26
|
+
- @atproto/ozone@0.2.6
|
|
27
|
+
- @atproto/pds@0.5.7
|
|
28
|
+
- @atproto/sync@0.3.3
|
|
29
|
+
- @atproto/api@0.20.17
|
|
30
|
+
- @atproto/bsync@0.0.30
|
|
31
|
+
|
|
3
32
|
## 0.5.13
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/bin.js
CHANGED
|
@@ -47,8 +47,9 @@ const run = async () => {
|
|
|
47
47
|
for (const fg of network.feedGens) {
|
|
48
48
|
console.log(`🤖 Feed Generator (${fg.did}) http://localhost:${fg.port}`);
|
|
49
49
|
}
|
|
50
|
+
console.time('✅ Dev environment is ready');
|
|
50
51
|
await generateMockSetup(network);
|
|
51
|
-
console.
|
|
52
|
+
console.timeEnd('✅ Dev environment is ready');
|
|
52
53
|
};
|
|
53
54
|
run();
|
|
54
55
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED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AAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IACxE,OAAO,CAAC,GAAG,CAAC,oCAAoC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IACpE,OAAO,CAAC,GAAG,CAAC,uBAAuB,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IAC5D,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,GAAG,sBAAsB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1E,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;IAC1C,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAA;AAC/C,CAAC,CAAA;AAED,GAAG,EAAE,CAAA","sourcesContent":["import './env.js'\nimport { generateMockSetup } from './mock/index.js'\nimport { TestNetwork } from './network.js'\nimport { mockMailer } from './util.js'\n\nconst run = async () => {\n console.log(`\n██████╗\n██╔═══██╗\n██║██╗██║\n██║██║██║\n╚█║████╔╝\n ╚╝╚═══╝ protocol\n\n[ created by Bluesky ]`)\n\n const network = await TestNetwork.create({\n pds: {\n port: 2583,\n hostname: 'localhost',\n enableDidDocWithSession: true,\n },\n bsky: {\n dbPostgresSchema: 'bsky',\n port: 2584,\n publicUrl: 'http://localhost:2584',\n },\n plc: { port: 2582 },\n ozone: {\n port: 2587,\n chatUrl: 'http://localhost:2590', // must run separate chat service\n chatDid: 'did:example:chat',\n dbMaterializedViewRefreshIntervalMs: 30_000,\n },\n introspect: { port: 2581 },\n })\n mockMailer(network.pds)\n\n if (network.introspect) {\n console.log(\n `🔍 Dev-env introspection server http://localhost:${network.introspect.port}`,\n )\n }\n console.log(`👤 DID Placeholder server http://localhost:${network.plc.port}`)\n console.log(`🌞 Main PDS http://localhost:${network.pds.port}`)\n console.log(`🌞 Main PDS account DB`, network.pds.ctx.cfg.db.accountDbLoc)\n console.log(\n `🔨 Lexicon authority DID ${network.pds.ctx.cfg.lexicon.didAuthority}`,\n )\n console.log(`🗼 Ozone server http://localhost:${network.ozone.port}`)\n console.log(`🗼 Ozone service DID ${network.ozone.ctx.cfg.service.did}`)\n console.log(`🌅 Bsky Appview http://localhost:${network.bsky.port}`)\n console.log(`🌅 Bsky Appview DID ${network.bsky.serverDid}`)\n for (const fg of network.feedGens) {\n console.log(`🤖 Feed Generator (${fg.did}) http://localhost:${fg.port}`)\n }\n\n console.time('✅ Dev environment is ready')\n await generateMockSetup(network)\n console.timeEnd('✅ Dev environment is ready')\n}\n\nrun()\n"]}
|
package/dist/bsky.d.ts
CHANGED
package/dist/bsky.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bsky.d.ts","sourceRoot":"","sources":["../src/bsky.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,cAAc,eAAe,CAAA;AAE7B,qBAAa,QAAQ;IAEV,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI,CAAC,QAAQ;IACjB,MAAM,EAAE,IAAI,CAAC,WAAW;IACxB,SAAS,EAAE,IAAI,CAAC,eAAe;IAC/B,KAAK,EAAE,IAAI,CAAC,SAAS;IACrB,GAAG,EAAE,IAAI,CAAC,gBAAgB;IAC1B,SAAS,EAAE,MAAM;IAR1B,YACS,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,IAAI,CAAC,QAAQ,EACjB,MAAM,EAAE,IAAI,CAAC,WAAW,EACxB,SA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AM,EACtB;IAEJ,OAAa,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwGtD;IAED,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAEzB;IAED,QAAQ,IAAI,QAAQ,CAInB;IAED,SAAS,IAAI,MAAM,CAIlB;IAED,SAAS,IAAI,MAAM,CAMlB;IAED,gBAAgB;QAEZ,aAAa;MAEhB;IAEK,KAAK,kBAmBV;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,kBAE1B;CACF"}
|
package/dist/bsky.js
CHANGED
|
@@ -104,7 +104,7 @@ export class TestBsky {
|
|
|
104
104
|
idResolver: dataplane.idResolver,
|
|
105
105
|
});
|
|
106
106
|
await server.start();
|
|
107
|
-
sub.start();
|
|
107
|
+
void sub.start();
|
|
108
108
|
return new TestBsky(url, port, db, server, dataplane, bsync, sub, serverDid);
|
|
109
109
|
}
|
|
110
110
|
get ctx() {
|
|
@@ -131,11 +131,31 @@ export class TestBsky {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
async close() {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
// @TODO Use disposable stack when it becomes available (Node24+)
|
|
135
|
+
try {
|
|
136
|
+
await this.server.destroy();
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
try {
|
|
140
|
+
await this.bsync.destroy();
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
try {
|
|
144
|
+
await this.dataplane.destroy();
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
try {
|
|
148
|
+
await this.sub.destroy();
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
await this.db.close();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async [Symbol.asyncDispose]() {
|
|
158
|
+
await this.close();
|
|
139
159
|
}
|
|
140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,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAA;QAC9C,OAAO,CACL,QAAQ;YACR,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,QAAQ,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,CAAC,CACvE,CAAA;IACH,CAAC;IAED,gBAAgB;QACd,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE;SAChC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,iEAAiE;QACjE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAA;YAC5B,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;gBAChC,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC;wBACH,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;oBAC1B,CAAC;4BAAS,CAAC;wBACT,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;oBACvB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["import { Client as PlcClient } from '@did-plc/lib'\nimport getPort from 'get-port'\nimport * as ui8 from 'uint8arrays'\nimport { AtpAgent } from '@atproto/api'\nimport * as bsky from '@atproto/bsky'\nimport { Secp256k1Keypair } from '@atproto/crypto'\nimport { Client } from '@atproto/lex'\nimport { ADMIN_PASSWORD, EXAMPLE_LABELER } from './const.js'\nimport { BskyConfig } from './types.js'\nexport * from '@atproto/bsky'\n\nexport class TestBsky {\n constructor(\n public url: string,\n public port: number,\n public db: bsky.Database,\n public server: bsky.BskyAppView,\n public dataplane: bsky.DataPlaneServer,\n public bsync: bsky.MockBsync,\n public sub: bsky.RepoSubscription,\n public serverDid: string,\n ) {}\n\n static async create(cfg: BskyConfig): Promise<TestBsky> {\n const serviceKeypair = cfg.privateKey\n ? await Secp256k1Keypair.import(cfg.privateKey)\n : await Secp256k1Keypair.create()\n const plcClient = new PlcClient(cfg.plcUrl)\n\n const port = cfg.port || (await getPort())\n const url = `http://localhost:${port}`\n const serverDid = await plcClient.createDid({\n signingKey: serviceKeypair.did(),\n rotationKeys: [serviceKeypair.did()],\n handle: 'bsky.test',\n pds: `http://localhost:${port}`,\n signer: serviceKeypair,\n })\n\n const endpoint = `http://localhost:${port}`\n\n await plcClient.updateData(serverDid, serviceKeypair, (x) => {\n x.services['bsky_notif'] = {\n type: 'BskyNotificationService',\n endpoint,\n }\n x.services['bsky_appview'] = {\n type: 'BskyAppView',\n endpoint,\n }\n return x\n })\n\n // shared across server, ingester, and indexer in order to share pool, avoid too many pg connections.\n const db = new bsky.Database({\n url: cfg.dbPostgresUrl,\n schema: cfg.dbPostgresSchema,\n poolSize: 10,\n })\n\n const dataplanePort = await getPort()\n const dataplane = await bsky.DataPlaneServer.create(\n db,\n dataplanePort,\n cfg.plcUrl,\n )\n\n const bsyncPort = await getPort()\n const bsync = await bsky.MockBsync.create(db, bsyncPort)\n\n const config = new bsky.ServerConfig({\n version: 'unknown',\n port,\n didPlcUrl: cfg.plcUrl,\n publicUrl: 'https://bsky.public.url',\n serverDid,\n alternateAudienceDids: [],\n dataplaneUrls: [`http://localhost:${dataplanePort}`],\n dataplaneHttpVersion: '1.1',\n bsyncUrl: `http://localhost:${bsyncPort}`,\n bsyncHttpVersion: '1.1',\n modServiceDid: cfg.modServiceDid ?? 'did:example:invalidMod',\n labelsFromIssuerDids: [EXAMPLE_LABELER],\n bigThreadUris: new Set(),\n maxThreadParents: cfg.maxThreadParents ?? 50,\n disableSsrfProtection: true,\n searchTagsHide: new Set(),\n threadTagsBumpDown: new Set(),\n threadTagsHide: new Set(),\n visibilityTagHide: '',\n visibilityTagRankPrefix: '',\n debugFieldAllowedDids: new Set(),\n draftsLimit: 500,\n ...cfg,\n adminPasswords: [ADMIN_PASSWORD],\n etcdHosts: [],\n })\n\n // Separate migration db in case migration changes some connection state that we need in the tests, e.g. \"alter database ... set ...\"\n const migrationDb = new bsky.Database({\n url: cfg.dbPostgresUrl,\n schema: cfg.dbPostgresSchema,\n })\n if (cfg.migration) {\n await migrationDb.migrateToOrThrow(cfg.migration)\n } else {\n await migrationDb.migrateToLatestOrThrow()\n }\n await migrationDb.close()\n\n // api server\n const server = bsky.BskyAppView.create({\n config,\n signingKey: serviceKeypair,\n })\n\n const sub = new bsky.RepoSubscription({\n service: cfg.repoProvider,\n db,\n idResolver: dataplane.idResolver,\n })\n\n await server.start()\n\n void sub.start()\n\n return new TestBsky(url, port, db, server, dataplane, bsync, sub, serverDid)\n }\n\n get ctx(): bsky.AppContext {\n return this.server.ctx\n }\n\n getAgent(): AtpAgent {\n const agent = new AtpAgent({ service: this.url })\n agent.configureLabelers([EXAMPLE_LABELER])\n return agent\n }\n\n getClient(): Client {\n const client = new Client({ service: this.url })\n client.setLabelers([EXAMPLE_LABELER])\n return client\n }\n\n adminAuth(): string {\n const [password] = this.ctx.cfg.adminPasswords\n return (\n 'Basic ' +\n ui8.toString(ui8.fromString(`admin:${password}`, 'utf8'), 'base64pad')\n )\n }\n\n adminAuthHeaders() {\n return {\n authorization: this.adminAuth(),\n }\n }\n\n async close() {\n // @TODO Use disposable stack when it becomes available (Node24+)\n try {\n await this.server.destroy()\n } finally {\n try {\n await this.bsync.destroy()\n } finally {\n try {\n await this.dataplane.destroy()\n } finally {\n try {\n await this.sub.destroy()\n } finally {\n await this.db.close()\n }\n }\n }\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n"]}
|
package/dist/feed-gen.d.ts
CHANGED
|
@@ -4,9 +4,12 @@ export declare class TestFeedGen {
|
|
|
4
4
|
port: number;
|
|
5
5
|
server: http.Server;
|
|
6
6
|
did: string;
|
|
7
|
-
|
|
7
|
+
private terminator;
|
|
8
|
+
private terminatorPromise?;
|
|
9
|
+
get destroyed(): boolean;
|
|
8
10
|
constructor(port: number, server: http.Server, did: string);
|
|
9
11
|
static create(plcUrl: string, feeds: Record<string, SkeletonHandler>): Promise<TestFeedGen>;
|
|
10
12
|
close(): Promise<void>;
|
|
13
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=feed-gen.d.ts.map
|
package/dist/feed-gen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed-gen.d.ts","sourceRoot":"","sources":["../src/feed-gen.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"feed-gen.d.ts","sourceRoot":"","sources":["../src/feed-gen.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAM5B,OAAO,EAAE,eAAe,EAAO,MAAM,cAAc,CAAA;AAInD,qBAAa,WAAW;IASb,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,IAAI,CAAC,MAAM;IACnB,GAAG,EAAE,MAAM;IAVpB,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,iBAAiB,CAAC,CAAe;IAEzC,IAAI,SAAS,YAEZ;IAED,YACS,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,GAAG,EAAE,MAAM,EAGnB;IAED,OAAa,MAAM,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACrC,OAAO,CAAC,WAAW,CAAC,CA4BtB;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,kBAE1B;CACF"}
|
package/dist/feed-gen.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import events from 'node:events';
|
|
2
2
|
import * as plc from '@did-plc/lib';
|
|
3
3
|
import getPort from 'get-port';
|
|
4
|
+
// eslint-disable-next-line import/default, import/no-named-as-default-member
|
|
5
|
+
import httpTerminator from 'http-terminator';
|
|
4
6
|
import { Secp256k1Keypair } from '@atproto/crypto';
|
|
5
7
|
import { app } from '@atproto/pds';
|
|
6
8
|
import { InvalidRequestError, createServer } from '@atproto/xrpc-server';
|
|
7
9
|
export class TestFeedGen {
|
|
10
|
+
get destroyed() {
|
|
11
|
+
return this.terminatorPromise != null;
|
|
12
|
+
}
|
|
8
13
|
constructor(port, server, did) {
|
|
9
14
|
this.port = port;
|
|
10
15
|
this.server = server;
|
|
11
16
|
this.did = did;
|
|
12
|
-
this.
|
|
17
|
+
this.terminator = httpTerminator.createHttpTerminator({ server });
|
|
13
18
|
}
|
|
14
19
|
static async create(plcUrl, feeds) {
|
|
15
20
|
const port = await getPort();
|
|
@@ -38,16 +43,10 @@ export class TestFeedGen {
|
|
|
38
43
|
return new TestFeedGen(port, httpServer, did);
|
|
39
44
|
}
|
|
40
45
|
close() {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (err)
|
|
46
|
-
return reject(err);
|
|
47
|
-
this.destroyed = true;
|
|
48
|
-
resolve();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
46
|
+
return (this.terminatorPromise ??= this.terminator.terminate());
|
|
47
|
+
}
|
|
48
|
+
async [Symbol.asyncDispose]() {
|
|
49
|
+
await this.close();
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
const createFgDid = async (plcUrl, port) => {
|
package/dist/feed-gen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed-gen.js","sourceRoot":"","sources":["../src/feed-gen.ts"],"names":[],"mappings":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EACQ,EAAE;IACtB,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,CAAA;IAC/C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,aAAa,CAChC;QACE,IAAI,EAAE,eAAe;QACrB,mBAAmB,EAAE;YACnB,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;SACvB;QACD,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7B,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP,IAAI,EAAE,mBAAmB;gBACzB,QAAQ,EAAE,oBAAoB,IAAI,EAAE;aACrC;SACF;QACD,IAAI,EAAE,IAAI;KACX,EACD,OAAO,CACR,CAAA;IACD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;IACxC,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IACtC,OAAO,GAAgB,CAAA;AACzB,CAAC,CAAA","sourcesContent":["import events from 'node:events'\nimport http from 'node:http'\nimport * as plc from '@did-plc/lib'\nimport getPort from 'get-port'\n// eslint-disable-next-line import/default, import/no-named-as-default-member\nimport httpTerminator from 'http-terminator'\nimport { Secp256k1Keypair } from '@atproto/crypto'\nimport { SkeletonHandler, app } from '@atproto/pds'\nimport { AtUriString, DidString } from '@atproto/syntax'\nimport { InvalidRequestError, createServer } from '@atproto/xrpc-server'\n\nexport class TestFeedGen {\n private terminator: httpTerminator.HttpTerminator\n private terminatorPromise?: Promise<void>\n\n get destroyed() {\n return this.terminatorPromise != null\n }\n\n constructor(\n public port: number,\n public server: http.Server,\n public did: string,\n ) {\n this.terminator = httpTerminator.createHttpTerminator({ server })\n }\n\n static async create(\n plcUrl: string,\n feeds: Record<string, SkeletonHandler>,\n ): Promise<TestFeedGen> {\n const port = await getPort()\n const did = await createFgDid(plcUrl, port)\n const xrpcServer = createServer()\n\n xrpcServer.add(app.bsky.feed.getFeedSkeleton, async (args) => {\n const handler = feeds[args.params.feed]\n if (!handler) {\n throw new InvalidRequestError('unknown feed', 'UnknownFeed')\n }\n return handler(args)\n })\n\n xrpcServer.add(app.bsky.feed.describeFeedGenerator, async () => {\n return {\n encoding: 'application/json' as const,\n body: {\n did: did as DidString,\n feeds: (Object.keys(feeds) as AtUriString[]).map((uri) => ({\n uri,\n })),\n },\n }\n })\n\n const httpServer = xrpcServer.listen(port)\n await events.once(httpServer, 'listening')\n return new TestFeedGen(port, httpServer, did)\n }\n\n close(): Promise<void> {\n return (this.terminatorPromise ??= this.terminator.terminate())\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n\nconst createFgDid = async (\n plcUrl: string,\n port: number,\n): Promise<DidString> => {\n const keypair = await Secp256k1Keypair.create()\n const plcClient = new plc.Client(plcUrl)\n const op = await plc.signOperation(\n {\n type: 'plc_operation',\n verificationMethods: {\n atproto: keypair.did(),\n },\n rotationKeys: [keypair.did()],\n alsoKnownAs: [],\n services: {\n bsky_fg: {\n type: 'BskyFeedGenerator',\n endpoint: `http://localhost:${port}`,\n },\n },\n prev: null,\n },\n keypair,\n )\n const did = await plc.didForCreateOp(op)\n await plcClient.sendOperation(did, op)\n return did as DidString\n}\n"]}
|
package/dist/introspect.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { TestPlc } from './plc.js';
|
|
|
6
6
|
export declare class IntrospectServer {
|
|
7
7
|
port: number;
|
|
8
8
|
server: http.Server;
|
|
9
|
+
private terminator;
|
|
9
10
|
constructor(port: number, server: http.Server);
|
|
10
11
|
static start(port: number, plc: TestPlc, pds: TestPds, bsky: TestBsky, ozone: TestOzone): Promise<IntrospectServer>;
|
|
11
12
|
close(): Promise<void>;
|
package/dist/introspect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,qBAAa,gBAAgB;IAGlB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,IAAI,CAAC,MAAM;IAH5B,OAAO,CAAC,UAAU,CAA+B;IACjD,YACS,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,IAAI,CAAC,MAAM,EAG3B;IAED,OAAa,KAAK,CAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,6BA4BjB;IAEK,KAAK,kBAEV;CACF"}
|
package/dist/introspect.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import events from 'node:events';
|
|
2
2
|
import express from 'express';
|
|
3
|
+
// eslint-disable-next-line import/default
|
|
4
|
+
import httpTerminator from 'http-terminator';
|
|
3
5
|
export class IntrospectServer {
|
|
4
6
|
constructor(port, server) {
|
|
5
7
|
this.port = port;
|
|
6
8
|
this.server = server;
|
|
9
|
+
this.terminator = httpTerminator.createHttpTerminator({ server });
|
|
7
10
|
}
|
|
8
11
|
static async start(port, plc, pds, bsky, ozone) {
|
|
9
12
|
const app = express();
|
|
@@ -34,8 +37,7 @@ export class IntrospectServer {
|
|
|
34
37
|
return new IntrospectServer(port, server);
|
|
35
38
|
}
|
|
36
39
|
async close() {
|
|
37
|
-
this.
|
|
38
|
-
await events.once(this.server, 'close');
|
|
40
|
+
await this.terminator.terminate();
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
//# sourceMappingURL=introspect.js.map
|
package/dist/introspect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,0CAA0C;AAC1C,OAAO,cAAc,MAAM,iBAAiB,CAAA;AAM5C,MAAM,OAAO,gBAAgB;IAE3B,YACS,IAAY,EACZ,MAAmB;oBADnB,IAAI;sBACJ,MAAM;QAEb,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,IAAY,EACZ,GAAY,EACZ,GAAY,EACZ,IAAc,EACd,KAAgB;QAEhB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAA;QACrB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACzB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,GAAG,EAAE;oBACH,GAAG,EAAE,GAAG,CAAC,GAAG;iBACb;gBACD,GAAG,EAAE;oBACH,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;iBAC7B;gBACD,IAAI,EAAE;oBACJ,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS;iBAC5B;gBACD,KAAK,EAAE;oBACL,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;iBAC/B;gBACD,EAAE,EAAE;oBACF,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW;iBAClC;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QACtC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAA;IACnC,CAAC;CACF","sourcesContent":["import events from 'node:events'\nimport http from 'node:http'\nimport express from 'express'\n// eslint-disable-next-line import/default\nimport httpTerminator from 'http-terminator'\nimport { TestBsky } from './bsky.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\n\nexport class IntrospectServer {\n private terminator: httpTerminator.HttpTerminator\n constructor(\n public port: number,\n public server: http.Server,\n ) {\n this.terminator = httpTerminator.createHttpTerminator({ server })\n }\n\n static async start(\n port: number,\n plc: TestPlc,\n pds: TestPds,\n bsky: TestBsky,\n ozone: TestOzone,\n ) {\n const app = express()\n app.get('/', (_req, res) => {\n res.status(200).send({\n plc: {\n url: plc.url,\n },\n pds: {\n url: pds.url,\n did: pds.ctx.cfg.service.did,\n },\n bsky: {\n url: bsky.url,\n did: bsky.ctx.cfg.serverDid,\n },\n ozone: {\n url: ozone.url,\n did: ozone.ctx.cfg.service.did,\n },\n db: {\n url: ozone.ctx.cfg.db.postgresUrl,\n },\n })\n })\n const server = app.listen(port)\n await events.once(server, 'listening')\n return new IntrospectServer(port, server)\n }\n\n async close() {\n await this.terminator.terminate()\n }\n}\n"]}
|
package/dist/network.d.ts
CHANGED
package/dist/network.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C,qBAAa,WAAY,SAAQ,oBAAoB;IAE1C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,SAAS;IAChB,UAAU,CAAC,EAAE,gBAAgB;IALtC,YACS,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,EAChB,UAAU,CAAC,EAAE,gBAAgB,YAAA,EAGrC;IAED,OAAa,MAAM,CACjB,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,GACrC,OAAO,CAAC,WAAW,CAAC,CAoHtB;IAEK,uBAAuB,CAAC,OAAO,SAAO,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C,qBAAa,WAAY,SAAQ,oBAAoB;IAE1C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,SAAS;IAChB,UAAU,CAAC,EAAE,gBAAgB;IALtC,YACS,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,EAChB,UAAU,CAAC,EAAE,gBAAgB,YAAA,EAGrC;IAED,OAAa,MAAM,CACjB,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,GACrC,OAAO,CAAC,WAAW,CAAC,CAoHtB;IAEK,uBAAuB,CAAC,OAAO,SAAO,iBAmB3C;IAEK,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,iBAIhC;IAEK,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;;OAS1D;IAEK,YAAY,CAAC,EACjB,QAAyB,EACzB,QAAyB,GAC1B,EAAE;QACD,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB;;OASA;IAEK,KAAK,kBAaV;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,kBAE1B;CACF"}
|
package/dist/network.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import getPort from 'get-port';
|
|
3
3
|
import * as uint8arrays from 'uint8arrays';
|
|
4
|
-
import { wait } from '@atproto/common-web';
|
|
4
|
+
import { allFulfilled, wait } from '@atproto/common-web';
|
|
5
5
|
import { createServiceJwt } from '@atproto/xrpc-server';
|
|
6
6
|
import { TestBsky } from './bsky.js';
|
|
7
7
|
import { EXAMPLE_LABELER } from './const.js';
|
|
@@ -114,13 +114,17 @@ export class TestNetwork extends TestNetworkNoAppView {
|
|
|
114
114
|
}
|
|
115
115
|
async processFullSubscription(timeout = 5000) {
|
|
116
116
|
const sub = this.bsky.sub;
|
|
117
|
+
// If the subscription is not running, there is no point in
|
|
118
|
+
// waiting for it to process events
|
|
119
|
+
if (!sub.running)
|
|
120
|
+
return;
|
|
117
121
|
const start = Date.now();
|
|
118
122
|
const lastSeq = await this.pds.ctx.sequencer.curr();
|
|
119
123
|
if (!lastSeq)
|
|
120
124
|
return;
|
|
121
125
|
while (Date.now() - start < timeout) {
|
|
122
126
|
await sub.processAll();
|
|
123
|
-
const runnerCursor = await sub.
|
|
127
|
+
const runnerCursor = await sub.getCursor();
|
|
124
128
|
// if subscription claims to be done, ensure we are at the most recent cursor from PDS, else wait to process again
|
|
125
129
|
// (the subscription may claim to be finished before the PDS has even emitted it's event)
|
|
126
130
|
if (runnerCursor && runnerCursor >= lastSeq) {
|
|
@@ -152,12 +156,22 @@ export class TestNetwork extends TestNetworkNoAppView {
|
|
|
152
156
|
};
|
|
153
157
|
}
|
|
154
158
|
async close() {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
try {
|
|
160
|
+
await this.processAll();
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
await allFulfilled([
|
|
164
|
+
...this.feedGens.map(async (fg) => fg.close()),
|
|
165
|
+
this.ozone.close(),
|
|
166
|
+
this.bsky.close(),
|
|
167
|
+
this.pds.close(),
|
|
168
|
+
this.plc.close(),
|
|
169
|
+
this.introspect?.close(),
|
|
170
|
+
]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async [Symbol.asyncDispose]() {
|
|
174
|
+
await this.close();
|
|
161
175
|
}
|
|
162
176
|
}
|
|
163
177
|
//# sourceMappingURL=network.js.map
|
package/dist/network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,WAAW,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,cAAc,GAAG,OAAO,CAAA;AAC9B,MAAM,cAAc,GAAG,YAAY,CAAA;AAEnC,MAAM,OAAO,WAAY,SAAQ,oBAAoB;IACnD,YACS,GAAY,EACZ,GAAY,EACZ,IAAc,EACd,KAAgB,EAChB,UAA6B;QAEpC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;mBANR,GAAG;mBACH,GAAG;oBACH,IAAI;qBACJ,KAAK;0BACL,UAAU;IAGnB,CAAC;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AW,EAAE,GAAY;QACzD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC1D,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC;YACjC,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS;YACvC,GAAG;YACH,OAAO;SACR,CAAC,CAAA;QACF,OAAO,EAAE,aAAa,EAAE,UAAU,GAAG,EAAE,EAAE,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EACjB,QAAQ,GAAG,cAAc,EACzB,QAAQ,GAAG,cAAc,GAI1B;QACC,OAAO;YACL,aAAa,EACX,QAAQ;gBACR,WAAW,CAAC,QAAQ,CAClB,WAAW,CAAC,UAAU,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,EACzD,WAAW,CACZ;SACJ,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACxD,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACxB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QACvB,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;QACtB,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;QACtB,MAAM,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAA;IAChC,CAAC;CACF","sourcesContent":["import assert from 'node:assert'\nimport getPort from 'get-port'\nimport * as uint8arrays from 'uint8arrays'\nimport { wait } from '@atproto/common-web'\nimport { createServiceJwt } from '@atproto/xrpc-server'\nimport { TestBsky } from './bsky.js'\nimport { EXAMPLE_LABELER } from './const.js'\nimport { IntrospectServer } from './introspect.js'\nimport { TestNetworkNoAppView } from './network-no-appview.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\nimport { LexiconAuthorityProfile } from './service-profile-lexicon.js'\nimport { OzoneServiceProfile } from './service-profile-ozone.js'\nimport { TestServerParams } from './types.js'\nimport { mockNetworkUtilities } from './util.js'\n\nconst ADMIN_USERNAME = 'admin'\nconst ADMIN_PASSWORD = 'admin-pass'\n\nexport class TestNetwork extends TestNetworkNoAppView {\n constructor(\n public plc: TestPlc,\n public pds: TestPds,\n public bsky: TestBsky,\n public ozone: TestOzone,\n public introspect?: IntrospectServer,\n ) {\n super(plc, pds)\n }\n\n static async create(\n params: Partial<TestServerParams> = {},\n ): Promise<TestNetwork> {\n const redisHost = process.env.REDIS_HOST\n const dbPostgresUrl = params.dbPostgresUrl || process.env.DB_POSTGRES_URL\n assert(dbPostgresUrl, 'Missing postgres url for tests')\n assert(redisHost, 'Missing redis host for tests')\n const dbPostgresSchema =\n params.dbPostgresSchema || process.env.DB_POSTGRES_SCHEMA\n\n const plc = await TestPlc.create(params.plc ?? {})\n\n const bskyPort = params.bsky?.port ?? (await getPort())\n const pdsPort = params.pds?.port ?? (await getPort())\n const ozonePort = params.ozone?.port ?? (await getPort())\n\n const thirdPartyPds = await TestPds.create({\n didPlcUrl: plc.url,\n ...params.pds,\n inviteRequired: false,\n port: await getPort(),\n })\n\n const ozoneUrl = `http://localhost:${ozonePort}`\n\n // @TODO (?) rework the ServiceProfile to live on a separate PDS instead of\n // requiring to migrate to the main PDS\n const ozoneServiceProfile = await OzoneServiceProfile.create(\n thirdPartyPds,\n ozoneUrl,\n )\n const lexiconAuthorityProfile =\n await LexiconAuthorityProfile.create(thirdPartyPds)\n\n const bsky = await TestBsky.create({\n port: bskyPort,\n plcUrl: plc.url,\n pdsPort,\n rolodexUrl: process.env.BSKY_ROLODEX_URL,\n rolodexIgnoreBadTls: true,\n repoProvider: `ws://localhost:${pdsPort}`,\n dbPostgresSchema: `appview_${dbPostgresSchema}`,\n dbPostgresUrl,\n redisHost,\n modServiceDid: ozoneServiceProfile.did,\n labelsFromIssuerDids: [ozoneServiceProfile.did, EXAMPLE_LABELER],\n // Using a static private key results in a static DID, which is useful for e2e tests with the social-app repo.\n privateKey:\n '3f916c70dc69e4c5e83877f013325b11ecac31742e6a42f5c4fb240d0703d9d5=',\n ...params.bsky,\n })\n\n const pds = await TestPds.create({\n port: pdsPort,\n didPlcUrl: plc.url,\n bskyAppViewUrl: bsky.url,\n bskyAppViewDid: bsky.ctx.cfg.serverDid,\n modServiceUrl: ozoneUrl,\n modServiceDid: ozoneServiceProfile.did,\n lexiconDidAuthority: lexiconAuthorityProfile.did,\n ...params.pds,\n })\n\n // mock before any events start flowing from pds so that we don't miss e.g. any handle resolutions.\n mockNetworkUtilities(pds, bsky)\n\n const ozone = await TestOzone.create({\n port: ozonePort,\n plcUrl: plc.url,\n signingKey: ozoneServiceProfile.key,\n serverDid: ozoneServiceProfile.did,\n dbPostgresSchema: `ozone_${dbPostgresSchema || 'db'}`,\n dbPostgresUrl,\n appviewUrl: bsky.url,\n appviewDid: bsky.ctx.cfg.serverDid,\n appviewPushEvents: true,\n pdsUrl: pds.url,\n pdsDid: pds.ctx.cfg.service.did,\n verifierDid: ozoneServiceProfile.did,\n verifierUrl: pds.url,\n verifierPassword: 'temp',\n ...params.ozone,\n })\n\n await ozoneServiceProfile.migrateTo(pds)\n await ozoneServiceProfile.createRecords()\n\n await lexiconAuthorityProfile.migrateTo(pds)\n await lexiconAuthorityProfile.createRecords()\n\n await ozone.addAdminDid(ozoneServiceProfile.did)\n await ozone.createPolicies()\n\n await thirdPartyPds.processAll()\n await pds.processAll()\n await ozone.processAll()\n await bsky.sub.processAll()\n await thirdPartyPds.close()\n\n // Weird but if we do this before pds.processAll() somehow appview loses this user and tests in different parts fail because appview doesn't return this user in various contexts anymore\n const ozoneVerifierPassword =\n await ozoneServiceProfile.createAppPasswordForVerification()\n if (ozone.daemon.ctx.cfg.verifier) {\n ozone.daemon.ctx.cfg.verifier.password = ozoneVerifierPassword\n }\n\n let introspect: IntrospectServer | undefined = undefined\n if (params.introspect?.port) {\n introspect = await IntrospectServer.start(\n params.introspect.port,\n plc,\n pds,\n bsky,\n ozone,\n )\n }\n\n return new TestNetwork(plc, pds, bsky, ozone, introspect)\n }\n\n async processFullSubscription(timeout = 5000) {\n const sub = this.bsky.sub\n const start = Date.now()\n const lastSeq = await this.pds.ctx.sequencer.curr()\n if (!lastSeq) return\n while (Date.now() - start < timeout) {\n await sub.processAll()\n const runnerCursor = await sub.runner.getCursor()\n // if subscription claims to be done, ensure we are at the most recent cursor from PDS, else wait to process again\n // (the subscription may claim to be finished before the PDS has even emitted it's event)\n if (runnerCursor && runnerCursor >= lastSeq) {\n return\n }\n await wait(5)\n }\n throw new Error(`Sequence was not processed within ${timeout}ms`)\n }\n\n async processAll(timeout?: number) {\n await this.pds.processAll()\n await this.ozone.processAll()\n await this.processFullSubscription(timeout)\n }\n\n async serviceHeaders(did: string, lxm: string, aud?: string) {\n const keypair = await this.pds.ctx.actorStore.keypair(did)\n const jwt = await createServiceJwt({\n iss: did,\n aud: aud ?? this.bsky.ctx.cfg.serverDid,\n lxm,\n keypair,\n })\n return { authorization: `Bearer ${jwt}` }\n }\n\n async adminHeaders({\n username = ADMIN_USERNAME,\n password = ADMIN_PASSWORD,\n }: {\n username?: string\n password?: string\n }) {\n return {\n authorization:\n 'Basic ' +\n uint8arrays.toString(\n uint8arrays.fromString(`${username}:${password}`, 'utf8'),\n 'base64pad',\n ),\n }\n }\n\n async close() {\n await Promise.all(this.feedGens.map((fg) => fg.close()))\n await this.ozone.close()\n await this.bsky.close()\n await this.pds.close()\n await this.plc.close()\n await this.introspect?.close()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[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,CAAC,CAAA;QAC1D,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC;YACjC,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS;YACvC,GAAG;YACH,OAAO;SACR,CAAC,CAAA;QACF,OAAO,EAAE,aAAa,EAAE,UAAU,GAAG,EAAE,EAAE,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EACjB,QAAQ,GAAG,cAAc,EACzB,QAAQ,GAAG,cAAc,GAI1B;QACC,OAAO;YACL,aAAa,EACX,QAAQ;gBACR,WAAW,CAAC,QAAQ,CAClB,WAAW,CAAC,UAAU,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,EACzD,WAAW,CACZ;SACJ,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QACzB,CAAC;gBAAS,CAAC;YACT,MAAM,YAAY,CAAC;gBACjB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;gBAC9C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;gBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACjB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;aACzB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["import assert from 'node:assert'\nimport getPort from 'get-port'\nimport * as uint8arrays from 'uint8arrays'\nimport { allFulfilled, wait } from '@atproto/common-web'\nimport { createServiceJwt } from '@atproto/xrpc-server'\nimport { TestBsky } from './bsky.js'\nimport { EXAMPLE_LABELER } from './const.js'\nimport { IntrospectServer } from './introspect.js'\nimport { TestNetworkNoAppView } from './network-no-appview.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\nimport { LexiconAuthorityProfile } from './service-profile-lexicon.js'\nimport { OzoneServiceProfile } from './service-profile-ozone.js'\nimport { TestServerParams } from './types.js'\nimport { mockNetworkUtilities } from './util.js'\n\nconst ADMIN_USERNAME = 'admin'\nconst ADMIN_PASSWORD = 'admin-pass'\n\nexport class TestNetwork extends TestNetworkNoAppView {\n constructor(\n public plc: TestPlc,\n public pds: TestPds,\n public bsky: TestBsky,\n public ozone: TestOzone,\n public introspect?: IntrospectServer,\n ) {\n super(plc, pds)\n }\n\n static async create(\n params: Partial<TestServerParams> = {},\n ): Promise<TestNetwork> {\n const redisHost = process.env.REDIS_HOST\n const dbPostgresUrl = params.dbPostgresUrl || process.env.DB_POSTGRES_URL\n assert(dbPostgresUrl, 'Missing postgres url for tests')\n assert(redisHost, 'Missing redis host for tests')\n const dbPostgresSchema =\n params.dbPostgresSchema || process.env.DB_POSTGRES_SCHEMA\n\n const plc = await TestPlc.create(params.plc ?? {})\n\n const bskyPort = params.bsky?.port ?? (await getPort())\n const pdsPort = params.pds?.port ?? (await getPort())\n const ozonePort = params.ozone?.port ?? (await getPort())\n\n const thirdPartyPds = await TestPds.create({\n didPlcUrl: plc.url,\n ...params.pds,\n inviteRequired: false,\n port: await getPort(),\n })\n\n const ozoneUrl = `http://localhost:${ozonePort}`\n\n // @TODO (?) rework the ServiceProfile to live on a separate PDS instead of\n // requiring to migrate to the main PDS\n const ozoneServiceProfile = await OzoneServiceProfile.create(\n thirdPartyPds,\n ozoneUrl,\n )\n const lexiconAuthorityProfile =\n await LexiconAuthorityProfile.create(thirdPartyPds)\n\n const bsky = await TestBsky.create({\n port: bskyPort,\n plcUrl: plc.url,\n pdsPort,\n rolodexUrl: process.env.BSKY_ROLODEX_URL,\n rolodexIgnoreBadTls: true,\n repoProvider: `ws://localhost:${pdsPort}`,\n dbPostgresSchema: `appview_${dbPostgresSchema}`,\n dbPostgresUrl,\n redisHost,\n modServiceDid: ozoneServiceProfile.did,\n labelsFromIssuerDids: [ozoneServiceProfile.did, EXAMPLE_LABELER],\n // Using a static private key results in a static DID, which is useful for e2e tests with the social-app repo.\n privateKey:\n '3f916c70dc69e4c5e83877f013325b11ecac31742e6a42f5c4fb240d0703d9d5=',\n ...params.bsky,\n })\n\n const pds = await TestPds.create({\n port: pdsPort,\n didPlcUrl: plc.url,\n bskyAppViewUrl: bsky.url,\n bskyAppViewDid: bsky.ctx.cfg.serverDid,\n modServiceUrl: ozoneUrl,\n modServiceDid: ozoneServiceProfile.did,\n lexiconDidAuthority: lexiconAuthorityProfile.did,\n ...params.pds,\n })\n\n // mock before any events start flowing from pds so that we don't miss e.g. any handle resolutions.\n mockNetworkUtilities(pds, bsky)\n\n const ozone = await TestOzone.create({\n port: ozonePort,\n plcUrl: plc.url,\n signingKey: ozoneServiceProfile.key,\n serverDid: ozoneServiceProfile.did,\n dbPostgresSchema: `ozone_${dbPostgresSchema || 'db'}`,\n dbPostgresUrl,\n appviewUrl: bsky.url,\n appviewDid: bsky.ctx.cfg.serverDid,\n appviewPushEvents: true,\n pdsUrl: pds.url,\n pdsDid: pds.ctx.cfg.service.did,\n verifierDid: ozoneServiceProfile.did,\n verifierUrl: pds.url,\n verifierPassword: 'temp',\n ...params.ozone,\n })\n\n await ozoneServiceProfile.migrateTo(pds)\n await ozoneServiceProfile.createRecords()\n\n await lexiconAuthorityProfile.migrateTo(pds)\n await lexiconAuthorityProfile.createRecords()\n\n await ozone.addAdminDid(ozoneServiceProfile.did)\n await ozone.createPolicies()\n\n await thirdPartyPds.processAll()\n await pds.processAll()\n await ozone.processAll()\n await bsky.sub.processAll()\n await thirdPartyPds.close()\n\n // Weird but if we do this before pds.processAll() somehow appview loses this user and tests in different parts fail because appview doesn't return this user in various contexts anymore\n const ozoneVerifierPassword =\n await ozoneServiceProfile.createAppPasswordForVerification()\n if (ozone.daemon.ctx.cfg.verifier) {\n ozone.daemon.ctx.cfg.verifier.password = ozoneVerifierPassword\n }\n\n let introspect: IntrospectServer | undefined = undefined\n if (params.introspect?.port) {\n introspect = await IntrospectServer.start(\n params.introspect.port,\n plc,\n pds,\n bsky,\n ozone,\n )\n }\n\n return new TestNetwork(plc, pds, bsky, ozone, introspect)\n }\n\n async processFullSubscription(timeout = 5000) {\n const sub = this.bsky.sub\n // If the subscription is not running, there is no point in\n // waiting for it to process events\n if (!sub.running) return\n const start = Date.now()\n const lastSeq = await this.pds.ctx.sequencer.curr()\n if (!lastSeq) return\n while (Date.now() - start < timeout) {\n await sub.processAll()\n const runnerCursor = await sub.getCursor()\n // if subscription claims to be done, ensure we are at the most recent cursor from PDS, else wait to process again\n // (the subscription may claim to be finished before the PDS has even emitted it's event)\n if (runnerCursor && runnerCursor >= lastSeq) {\n return\n }\n await wait(5)\n }\n throw new Error(`Sequence was not processed within ${timeout}ms`)\n }\n\n async processAll(timeout?: number) {\n await this.pds.processAll()\n await this.ozone.processAll()\n await this.processFullSubscription(timeout)\n }\n\n async serviceHeaders(did: string, lxm: string, aud?: string) {\n const keypair = await this.pds.ctx.actorStore.keypair(did)\n const jwt = await createServiceJwt({\n iss: did,\n aud: aud ?? this.bsky.ctx.cfg.serverDid,\n lxm,\n keypair,\n })\n return { authorization: `Bearer ${jwt}` }\n }\n\n async adminHeaders({\n username = ADMIN_USERNAME,\n password = ADMIN_PASSWORD,\n }: {\n username?: string\n password?: string\n }) {\n return {\n authorization:\n 'Basic ' +\n uint8arrays.toString(\n uint8arrays.fromString(`${username}:${password}`, 'utf8'),\n 'base64pad',\n ),\n }\n }\n\n async close() {\n try {\n await this.processAll()\n } finally {\n await allFulfilled([\n ...this.feedGens.map(async (fg) => fg.close()),\n this.ozone.close(),\n this.bsky.close(),\n this.pds.close(),\n this.plc.close(),\n this.introspect?.close(),\n ])\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n"]}
|
package/dist/ozone.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare class TestOzone {
|
|
|
25
25
|
}>;
|
|
26
26
|
processAll(): Promise<void>;
|
|
27
27
|
close(): Promise<void>;
|
|
28
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
28
29
|
}
|
|
29
30
|
export declare const createOzoneDid: (plcUrl: string, keypair: Keypair) => Promise<string>;
|
|
30
31
|
//# sourceMappingURL=ozone.d.ts.map
|
package/dist/ozone.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ozone.d.ts","sourceRoot":"","sources":["../src/ozone.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,OAAO,EAAoB,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGnD,qBAAa,SAAS;IAEX,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,KAAK,CAAC,YAAY;IAC1B,MAAM,EAAE,KAAK,CAAC,WAAW;IACzB,UAAU,EAAE,SAAS;IACrB,cAAc,EAAE,SAAS;IACzB,WAAW,EAAE,SAAS;IAP/B,YACS,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,CAAC,YAAY,EAC1B,MAAM,EAAE,KAAK,CAAC,WAAW,EACzB,UAAU,EAAE,SAAS,EACrB,cAAc,EAAE,SAAS,EACzB,WAAW,EAAE,SAAS,EAC3B;IAEJ,OAAa,MAAM,CAAC,MAAM,EA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,CAAC,SAAS,CAAC,CA4E3D;IAED,IAAI,GAAG,IAAI,KAAK,CAAC,UAAU,CAE1B;IAED,QAAQ,IAAI,QAAQ,CAInB;IAED,YAAY,oBAEX;IAEK,WAAW,CAAC,GAAG,EAAE,MAAM,iBAU5B;IAEK,eAAe,CAAC,GAAG,EAAE,MAAM,iBAUhC;IAEK,YAAY,CAAC,GAAG,EAAE,MAAM,iBAU7B;IAEK,cAAc,kBAsEnB;IAEK,UAAU,CACd,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,OAAO,GAAG,WAAW,GAAG,QAAsB;;OAerD;IAEK,UAAU,kBAGf;IAEK,KAAK,kBAMV;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,kBAE1B;CACF;AAED,eAAO,MAAM,cAAc,WACjB,MAAM,WACL,OAAO,KACf,OAAO,CAAC,MAAM,CAuBhB,CAAA"}
|
package/dist/ozone.js
CHANGED
|
@@ -219,8 +219,15 @@ export class TestOzone {
|
|
|
219
219
|
await this.daemon.processAll();
|
|
220
220
|
}
|
|
221
221
|
async close() {
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
try {
|
|
223
|
+
await this.server.destroy();
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
await this.daemon.destroy();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async [Symbol.asyncDispose]() {
|
|
230
|
+
await this.close();
|
|
224
231
|
}
|
|
225
232
|
}
|
|
226
233
|
export const createOzoneDid = async (plcUrl, keypair) => {
|
package/dist/ozone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ozone.js","sourceRoot":"","sources":["../src/ozone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAA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I,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,MAAc,EACd,OAAgB,EACC,EAAE;IACnB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CACnC;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7B,mBAAmB,EAAE;YACnB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;SAC7B;QACD,QAAQ,EAAE;YACR,eAAe,EAAE;gBACf,IAAI,EAAE,gBAAgB;gBACtB,QAAQ,EAAE,0BAA0B;aACrC;SACF;QACD,IAAI,EAAE,IAAI;KACX,EACD,OAAO,CACR,CAAA;IACD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAC3C,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import * as plc from '@did-plc/lib'\nimport getPort from 'get-port'\nimport * as ui8 from 'uint8arrays'\nimport { AtpAgent } from '@atproto/api'\nimport { Keypair, Secp256k1Keypair } from '@atproto/crypto'\nimport * as ozone from '@atproto/ozone'\nimport { createServiceJwt } from '@atproto/xrpc-server'\nimport { ADMIN_PASSWORD, EXAMPLE_LABELER } from './const.js'\nimport { ModeratorClient } from './moderator-client.js'\nimport { DidAndKey, OzoneConfig } from './types.js'\nimport { createDidAndKey } from './util.js'\n\nexport class TestOzone {\n constructor(\n public url: string,\n public port: number,\n public server: ozone.OzoneService,\n public daemon: ozone.OzoneDaemon,\n public adminAccnt: DidAndKey,\n public moderatorAccnt: DidAndKey,\n public triageAccnt: DidAndKey,\n ) {}\n\n static async create(config: OzoneConfig): Promise<TestOzone> {\n const serviceKeypair =\n config.signingKey ?? (await Secp256k1Keypair.create({ exportable: true }))\n const signingKeyHex = ui8.toString(await serviceKeypair.export(), 'hex')\n let serverDid = config.serverDid\n if (!serverDid) {\n serverDid = await createOzoneDid(config.plcUrl, serviceKeypair)\n }\n\n const admin = await createDidAndKey({\n plcUrl: config.plcUrl,\n handle: 'admin.ozone',\n pds: 'https://pds.invalid',\n })\n\n const moderator = await createDidAndKey({\n plcUrl: config.plcUrl,\n handle: 'moderator.ozone',\n pds: 'https://pds.invalid',\n })\n\n const triage = await createDidAndKey({\n plcUrl: config.plcUrl,\n handle: 'triage.ozone',\n pds: 'https://pds.invalid',\n })\n\n const port = config.port || (await getPort())\n const url = `http://localhost:${port}`\n\n const env: ozone.OzoneEnvironment = {\n devMode: true,\n version: '0.0.0',\n port,\n didPlcUrl: config.plcUrl,\n publicUrl: url,\n serverDid,\n signingKeyHex,\n ...config,\n adminPassword: ADMIN_PASSWORD,\n adminDids: [...(config.adminDids ?? []), admin.did],\n moderatorDids: [\n ...(config.moderatorDids ?? []),\n config.appviewDid,\n moderator.did,\n ],\n triageDids: [...(config.triageDids ?? []), triage.did],\n }\n\n // Separate migration db in case migration changes some connection state that we need in the tests, e.g. \"alter database ... set ...\"\n const migrationDb = new ozone.Database({\n schema: config.dbPostgresSchema,\n url: config.dbPostgresUrl,\n })\n if (config.migration) {\n await migrationDb.migrateToOrThrow(config.migration)\n } else {\n await migrationDb.migrateToLatestOrThrow()\n }\n await migrationDb.close()\n\n const cfg = ozone.envToCfg(env)\n const secrets = ozone.envToSecrets(env)\n\n // api server\n const server = await ozone.OzoneService.create(cfg, secrets, {\n imgInvalidator: config.imgInvalidator,\n })\n await server.start()\n\n const daemon = await ozone.OzoneDaemon.create(cfg, secrets)\n await daemon.start()\n // don't do event reversal in dev-env\n await daemon.ctx.eventReverser.destroy()\n\n return new TestOzone(url, port, server, daemon, admin, moderator, triage)\n }\n\n get ctx(): ozone.AppContext {\n return this.server.ctx\n }\n\n getAgent(): AtpAgent {\n const agent = new AtpAgent({ service: this.url })\n agent.configureLabelers([EXAMPLE_LABELER])\n return agent\n }\n\n getModClient() {\n return new ModeratorClient(this)\n }\n\n async addAdminDid(did: string) {\n await this.ctx.teamService(this.ctx.db).create({\n did,\n disabled: false,\n handle: null,\n displayName: null,\n lastUpdatedBy: this.ctx.cfg.service.did,\n role: 'tools.ozone.team.defs#roleAdmin',\n })\n this.ctx.cfg.access.admins.push(did)\n }\n\n async addModeratorDid(did: string) {\n await this.ctx.teamService(this.ctx.db).create({\n did,\n disabled: false,\n handle: null,\n displayName: null,\n lastUpdatedBy: this.ctx.cfg.service.did,\n role: 'tools.ozone.team.defs#roleModerator',\n })\n this.ctx.cfg.access.moderators.push(did)\n }\n\n async addTriageDid(did: string) {\n await this.ctx.teamService(this.ctx.db).create({\n did,\n disabled: false,\n handle: null,\n displayName: null,\n lastUpdatedBy: this.ctx.cfg.service.did,\n role: 'tools.ozone.team.defs#roleTriage',\n })\n this.ctx.cfg.access.triage.push(did)\n }\n\n async createPolicies() {\n const now = new Date()\n const defaultOptions = {\n managerRole: 'tools.ozone.team.defs#roleAdmin' as const,\n scope: 'instance' as const,\n did: this.ctx.cfg.service.did,\n lastUpdatedBy: this.ctx.cfg.service.did,\n createdBy: this.ctx.cfg.service.did,\n createdAt: now,\n updatedAt: now,\n }\n await this.ctx.settingService(this.ctx.db).upsert({\n ...defaultOptions,\n key: 'tools.ozone.setting.severityLevels',\n value: {\n 'sev-2': {\n strikeCount: 2,\n expiryInDays: 90,\n },\n 'sev-4': {\n strikeCount: 4,\n expiryInDays: 365,\n },\n 'sev-7': {\n needsTakedown: true,\n description: 'Sever violation, immedate account takedown',\n },\n 'custom-sev': {\n strikeCount: 4,\n firstOccurrenceStrikeCount: 8,\n description: 'First offense harsher penalty, on subsequent less',\n },\n },\n description: 'Severity levels and strike count mapping for policies',\n })\n await this.ctx.settingService(this.ctx.db).upsert({\n ...defaultOptions,\n key: 'tools.ozone.setting.policyList',\n value: {\n 'policy-one': {\n name: 'Policy One',\n description: 'Policy for handling user behavior',\n severityLevels: {\n 'sev-1': {\n description: 'Minor infraction',\n isDefault: true,\n },\n 'sev-2': {\n description: 'Moderate infraction',\n isDefault: false,\n },\n },\n },\n 'policy-two': {\n name: 'Policy Two',\n description: 'Policy for handling user action',\n severityLevels: {\n 'sev-4': {\n description: 'Moderate infraction',\n isDefault: false,\n },\n 'sev-5': {\n description: 'Severe infraction',\n isDefault: false,\n },\n },\n },\n },\n description: 'Moderation policies to be associated with actions',\n })\n }\n\n async modHeaders(\n lxm: string,\n role: 'admin' | 'moderator' | 'triage' = 'moderator',\n ) {\n const account =\n role === 'admin'\n ? this.adminAccnt\n : role === 'moderator'\n ? this.moderatorAccnt\n : this.triageAccnt\n const jwt = await createServiceJwt({\n iss: account.did,\n aud: this.ctx.cfg.service.did,\n lxm,\n keypair: account.key,\n })\n return { authorization: `Bearer ${jwt}` }\n }\n\n async processAll() {\n await this.ctx.backgroundQueue.processAll()\n await this.daemon.processAll()\n }\n\n async close() {\n await this.daemon.destroy()\n await this.server.destroy()\n }\n}\n\nexport const createOzoneDid = async (\n plcUrl: string,\n keypair: Keypair,\n): Promise<string> => {\n const plcClient = new plc.Client(plcUrl)\n const plcOp = await plc.signOperation(\n {\n type: 'plc_operation',\n alsoKnownAs: [],\n rotationKeys: [keypair.did()],\n verificationMethods: {\n atproto_label: keypair.did(),\n },\n services: {\n atproto_labeler: {\n type: 'AtprotoLabeler',\n endpoint: 'https://ozone.public.url',\n },\n },\n prev: null,\n },\n keypair,\n )\n const did = await plc.didForCreateOp(plcOp)\n await plcClient.sendOperation(did, plcOp)\n return did\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ozone.js","sourceRoot":"","sources":["../src/ozone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAA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AK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,MAAc,EACd,OAAgB,EACC,EAAE;IACnB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CACnC;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7B,mBAAmB,EAAE;YACnB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;SAC7B;QACD,QAAQ,EAAE;YACR,eAAe,EAAE;gBACf,IAAI,EAAE,gBAAgB;gBACtB,QAAQ,EAAE,0BAA0B;aACrC;SACF;QACD,IAAI,EAAE,IAAI;KACX,EACD,OAAO,CACR,CAAA;IACD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAC3C,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import * as plc from '@did-plc/lib'\nimport getPort from 'get-port'\nimport * as ui8 from 'uint8arrays'\nimport { AtpAgent } from '@atproto/api'\nimport { Keypair, Secp256k1Keypair } from '@atproto/crypto'\nimport * as ozone from '@atproto/ozone'\nimport { createServiceJwt } from '@atproto/xrpc-server'\nimport { ADMIN_PASSWORD, EXAMPLE_LABELER } from './const.js'\nimport { ModeratorClient } from './moderator-client.js'\nimport { DidAndKey, OzoneConfig } from './types.js'\nimport { createDidAndKey } from './util.js'\n\nexport class TestOzone {\n constructor(\n public url: string,\n public port: number,\n public server: ozone.OzoneService,\n public daemon: ozone.OzoneDaemon,\n public adminAccnt: DidAndKey,\n public moderatorAccnt: DidAndKey,\n public triageAccnt: DidAndKey,\n ) {}\n\n static async create(config: OzoneConfig): Promise<TestOzone> {\n const serviceKeypair =\n config.signingKey ?? (await Secp256k1Keypair.create({ exportable: true }))\n const signingKeyHex = ui8.toString(await serviceKeypair.export(), 'hex')\n let serverDid = config.serverDid\n if (!serverDid) {\n serverDid = await createOzoneDid(config.plcUrl, serviceKeypair)\n }\n\n const admin = await createDidAndKey({\n plcUrl: config.plcUrl,\n handle: 'admin.ozone',\n pds: 'https://pds.invalid',\n })\n\n const moderator = await createDidAndKey({\n plcUrl: config.plcUrl,\n handle: 'moderator.ozone',\n pds: 'https://pds.invalid',\n })\n\n const triage = await createDidAndKey({\n plcUrl: config.plcUrl,\n handle: 'triage.ozone',\n pds: 'https://pds.invalid',\n })\n\n const port = config.port || (await getPort())\n const url = `http://localhost:${port}`\n\n const env: ozone.OzoneEnvironment = {\n devMode: true,\n version: '0.0.0',\n port,\n didPlcUrl: config.plcUrl,\n publicUrl: url,\n serverDid,\n signingKeyHex,\n ...config,\n adminPassword: ADMIN_PASSWORD,\n adminDids: [...(config.adminDids ?? []), admin.did],\n moderatorDids: [\n ...(config.moderatorDids ?? []),\n config.appviewDid,\n moderator.did,\n ],\n triageDids: [...(config.triageDids ?? []), triage.did],\n }\n\n // Separate migration db in case migration changes some connection state that we need in the tests, e.g. \"alter database ... set ...\"\n const migrationDb = new ozone.Database({\n schema: config.dbPostgresSchema,\n url: config.dbPostgresUrl,\n })\n if (config.migration) {\n await migrationDb.migrateToOrThrow(config.migration)\n } else {\n await migrationDb.migrateToLatestOrThrow()\n }\n await migrationDb.close()\n\n const cfg = ozone.envToCfg(env)\n const secrets = ozone.envToSecrets(env)\n\n // api server\n const server = await ozone.OzoneService.create(cfg, secrets, {\n imgInvalidator: config.imgInvalidator,\n })\n await server.start()\n\n const daemon = await ozone.OzoneDaemon.create(cfg, secrets)\n await daemon.start()\n // don't do event reversal in dev-env\n await daemon.ctx.eventReverser.destroy()\n\n return new TestOzone(url, port, server, daemon, admin, moderator, triage)\n }\n\n get ctx(): ozone.AppContext {\n return this.server.ctx\n }\n\n getAgent(): AtpAgent {\n const agent = new AtpAgent({ service: this.url })\n agent.configureLabelers([EXAMPLE_LABELER])\n return agent\n }\n\n getModClient() {\n return new ModeratorClient(this)\n }\n\n async addAdminDid(did: string) {\n await this.ctx.teamService(this.ctx.db).create({\n did,\n disabled: false,\n handle: null,\n displayName: null,\n lastUpdatedBy: this.ctx.cfg.service.did,\n role: 'tools.ozone.team.defs#roleAdmin',\n })\n this.ctx.cfg.access.admins.push(did)\n }\n\n async addModeratorDid(did: string) {\n await this.ctx.teamService(this.ctx.db).create({\n did,\n disabled: false,\n handle: null,\n displayName: null,\n lastUpdatedBy: this.ctx.cfg.service.did,\n role: 'tools.ozone.team.defs#roleModerator',\n })\n this.ctx.cfg.access.moderators.push(did)\n }\n\n async addTriageDid(did: string) {\n await this.ctx.teamService(this.ctx.db).create({\n did,\n disabled: false,\n handle: null,\n displayName: null,\n lastUpdatedBy: this.ctx.cfg.service.did,\n role: 'tools.ozone.team.defs#roleTriage',\n })\n this.ctx.cfg.access.triage.push(did)\n }\n\n async createPolicies() {\n const now = new Date()\n const defaultOptions = {\n managerRole: 'tools.ozone.team.defs#roleAdmin' as const,\n scope: 'instance' as const,\n did: this.ctx.cfg.service.did,\n lastUpdatedBy: this.ctx.cfg.service.did,\n createdBy: this.ctx.cfg.service.did,\n createdAt: now,\n updatedAt: now,\n }\n await this.ctx.settingService(this.ctx.db).upsert({\n ...defaultOptions,\n key: 'tools.ozone.setting.severityLevels',\n value: {\n 'sev-2': {\n strikeCount: 2,\n expiryInDays: 90,\n },\n 'sev-4': {\n strikeCount: 4,\n expiryInDays: 365,\n },\n 'sev-7': {\n needsTakedown: true,\n description: 'Sever violation, immedate account takedown',\n },\n 'custom-sev': {\n strikeCount: 4,\n firstOccurrenceStrikeCount: 8,\n description: 'First offense harsher penalty, on subsequent less',\n },\n },\n description: 'Severity levels and strike count mapping for policies',\n })\n await this.ctx.settingService(this.ctx.db).upsert({\n ...defaultOptions,\n key: 'tools.ozone.setting.policyList',\n value: {\n 'policy-one': {\n name: 'Policy One',\n description: 'Policy for handling user behavior',\n severityLevels: {\n 'sev-1': {\n description: 'Minor infraction',\n isDefault: true,\n },\n 'sev-2': {\n description: 'Moderate infraction',\n isDefault: false,\n },\n },\n },\n 'policy-two': {\n name: 'Policy Two',\n description: 'Policy for handling user action',\n severityLevels: {\n 'sev-4': {\n description: 'Moderate infraction',\n isDefault: false,\n },\n 'sev-5': {\n description: 'Severe infraction',\n isDefault: false,\n },\n },\n },\n },\n description: 'Moderation policies to be associated with actions',\n })\n }\n\n async modHeaders(\n lxm: string,\n role: 'admin' | 'moderator' | 'triage' = 'moderator',\n ) {\n const account =\n role === 'admin'\n ? this.adminAccnt\n : role === 'moderator'\n ? this.moderatorAccnt\n : this.triageAccnt\n const jwt = await createServiceJwt({\n iss: account.did,\n aud: this.ctx.cfg.service.did,\n lxm,\n keypair: account.key,\n })\n return { authorization: `Bearer ${jwt}` }\n }\n\n async processAll() {\n await this.ctx.backgroundQueue.processAll()\n await this.daemon.processAll()\n }\n\n async close() {\n try {\n await this.server.destroy()\n } finally {\n await this.daemon.destroy()\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n\nexport const createOzoneDid = async (\n plcUrl: string,\n keypair: Keypair,\n): Promise<string> => {\n const plcClient = new plc.Client(plcUrl)\n const plcOp = await plc.signOperation(\n {\n type: 'plc_operation',\n alsoKnownAs: [],\n rotationKeys: [keypair.did()],\n verificationMethods: {\n atproto_label: keypair.did(),\n },\n services: {\n atproto_labeler: {\n type: 'AtprotoLabeler',\n endpoint: 'https://ozone.public.url',\n },\n },\n prev: null,\n },\n keypair,\n )\n const did = await plc.didForCreateOp(plcOp)\n await plcClient.sendOperation(did, plcOp)\n return did\n}\n"]}
|
package/dist/pds.d.ts
CHANGED
package/dist/pds.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds.d.ts","sourceRoot":"","sources":["../src/pds.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,qBAAa,OAAO;IAET,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,GAAG,CAAC,GAAG;IAHxB,YACS,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,GAAG,CAAC,GAAG,EACpB;IAEJ,OAAa,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAsDvD;IAED,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAExB;IAED,QAAQ,IAAI,QAAQ,CAInB;IAED,SAAS,IAAI,MAAM,CAIlB;IAED,SAAS,IAAI,MAAM,CAQlB;IAED,gBAAgB;QAEZ,aAAa;MAEhB;IAED,YAAY,+BAEX;IAEK,UAAU,kBAEf;IAEK,KAAK,kBAEV;CACF"}
|
|
1
|
+
{"version":3,"file":"pds.d.ts","sourceRoot":"","sources":["../src/pds.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CA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