@powerhousedao/reactor-api 6.0.0-dev.109 → 6.0.0-dev.110
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/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/dist/test/benchmarks/load.bench.d.ts +0 -2
- package/dist/test/benchmarks/load.bench.d.ts.map +0 -1
- package/dist/test/benchmarks/load.bench.js +0 -73
- package/dist/test/benchmarks/load.bench.js.map +0 -1
- package/dist/test/benchmarks/sync.bench.d.ts +0 -2
- package/dist/test/benchmarks/sync.bench.d.ts.map +0 -1
- package/dist/test/benchmarks/sync.bench.js +0 -119
- package/dist/test/benchmarks/sync.bench.js.map +0 -1
- package/dist/test/identity-integration.test.d.ts +0 -2
- package/dist/test/identity-integration.test.d.ts.map +0 -1
- package/dist/test/identity-integration.test.js +0 -349
- package/dist/test/identity-integration.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/reactor-api",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.110",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"read-pkg": "10.1.0",
|
|
72
72
|
"ws": "^8.18.3",
|
|
73
73
|
"zod": "4.3.6",
|
|
74
|
-
"@powerhousedao/analytics-engine-core": "6.0.0-dev.
|
|
75
|
-
"@powerhousedao/analytics-engine-graphql": "6.0.0-dev.
|
|
76
|
-
"@powerhousedao/config": "6.0.0-dev.
|
|
77
|
-
"@powerhousedao/reactor": "6.0.0-dev.
|
|
78
|
-
"@powerhousedao/
|
|
79
|
-
"@powerhousedao/
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"document-model": "6.0.0-dev.
|
|
74
|
+
"@powerhousedao/analytics-engine-core": "6.0.0-dev.110",
|
|
75
|
+
"@powerhousedao/analytics-engine-graphql": "6.0.0-dev.110",
|
|
76
|
+
"@powerhousedao/config": "6.0.0-dev.110",
|
|
77
|
+
"@powerhousedao/reactor": "6.0.0-dev.110",
|
|
78
|
+
"@powerhousedao/analytics-engine-pg": "6.0.0-dev.110",
|
|
79
|
+
"@powerhousedao/reactor-mcp": "6.0.0-dev.110",
|
|
80
|
+
"@powerhousedao/shared": "6.0.0-dev.110",
|
|
81
|
+
"@renown/sdk": "6.0.0-dev.110",
|
|
82
|
+
"document-model": "6.0.0-dev.110"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@graphql-codegen/cli": "6.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.bench.d.ts","sourceRoot":"","sources":["../../../test/benchmarks/load.bench.ts"],"names":[],"mappings":""}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// import { RealWorldAssets } from "@sky-ph/atlas/document-models";
|
|
2
|
-
// import { generateUUID, ReactorBuilder } from "document-drive";
|
|
3
|
-
// import {
|
|
4
|
-
// DocumentDriveServer,
|
|
5
|
-
// driveDocumentModelModule,
|
|
6
|
-
// generateAddNodeAction,
|
|
7
|
-
// generateUUID,
|
|
8
|
-
// MemoryStorage,
|
|
9
|
-
// } from "document-drive";
|
|
10
|
-
// import { DocumentModelModule } from "@powerhousedao/shared/document-model";
|
|
11
|
-
export {};
|
|
12
|
-
// import { bench, describe } from "vitest";
|
|
13
|
-
// describe("Document Drive", async () => {
|
|
14
|
-
// const documentModels = [
|
|
15
|
-
// driveDocumentModelModule,
|
|
16
|
-
// RealWorldAssets,
|
|
17
|
-
// ] as DocumentModelModule[];
|
|
18
|
-
// const document = await RealWorldAssets.utils.loadFromFile(
|
|
19
|
-
// "test/data/BlocktowerAndromeda.zip",
|
|
20
|
-
// );
|
|
21
|
-
// bench(
|
|
22
|
-
// "Load PHDM into Document Drive",
|
|
23
|
-
// async () => {
|
|
24
|
-
// const server = new ReactorBuilder(documentModels).build();
|
|
25
|
-
// await server.initialize();
|
|
26
|
-
// const driveId = generateUUID();
|
|
27
|
-
// const documentId = generateUUID();
|
|
28
|
-
// const drive = await server.addDrive({
|
|
29
|
-
// global: {
|
|
30
|
-
// id: driveId,
|
|
31
|
-
// name: "Test Drive",
|
|
32
|
-
// icon: null,
|
|
33
|
-
// slug: null,
|
|
34
|
-
// },
|
|
35
|
-
// local: {
|
|
36
|
-
// availableOffline: false,
|
|
37
|
-
// sharingType: "PRIVATE",
|
|
38
|
-
// listeners: [],
|
|
39
|
-
// triggers: [],
|
|
40
|
-
// },
|
|
41
|
-
// });
|
|
42
|
-
// // adds file node for document
|
|
43
|
-
// const addFileAction = generateAddNodeAction(
|
|
44
|
-
// drive.state.global,
|
|
45
|
-
// {
|
|
46
|
-
// documentType: document.documentType,
|
|
47
|
-
// id: documentId,
|
|
48
|
-
// name: "BlocktowerAndromeda",
|
|
49
|
-
// },
|
|
50
|
-
// ["global"],
|
|
51
|
-
// );
|
|
52
|
-
// await server.addDriveAction(driveId, addFileAction);
|
|
53
|
-
// // adds document operations
|
|
54
|
-
// const result = await server.addOperations(
|
|
55
|
-
// driveId,
|
|
56
|
-
// documentId,
|
|
57
|
-
// document.operations.global,
|
|
58
|
-
// );
|
|
59
|
-
// if (result.error) {
|
|
60
|
-
// throw result.error;
|
|
61
|
-
// }
|
|
62
|
-
// const lastOperation = document.operations.global.at(-1);
|
|
63
|
-
// const lastLoadedOperation = result.operations.at(-1);
|
|
64
|
-
// if (
|
|
65
|
-
// JSON.stringify(lastOperation) !== JSON.stringify(lastLoadedOperation)
|
|
66
|
-
// ) {
|
|
67
|
-
// throw new Error("Document operations mismatch");
|
|
68
|
-
// }
|
|
69
|
-
// },
|
|
70
|
-
// { throws: true },
|
|
71
|
-
// );
|
|
72
|
-
// });
|
|
73
|
-
//# sourceMappingURL=load.bench.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.bench.js","sourceRoot":"","sources":["../../../test/benchmarks/load.bench.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,iEAAiE;AACjE,WAAW;AACX,yBAAyB;AACzB,8BAA8B;AAC9B,2BAA2B;AAC3B,kBAAkB;AAClB,mBAAmB;AACnB,2BAA2B;AAC3B,8EAA8E;;AAE9E,4CAA4C;AAE5C,2CAA2C;AAC3C,6BAA6B;AAC7B,gCAAgC;AAChC,uBAAuB;AACvB,gCAAgC;AAChC,+DAA+D;AAC/D,2CAA2C;AAC3C,OAAO;AAEP,WAAW;AACX,uCAAuC;AACvC,oBAAoB;AACpB,mEAAmE;AACnE,mCAAmC;AAEnC,wCAAwC;AACxC,2CAA2C;AAE3C,8CAA8C;AAC9C,oBAAoB;AACpB,yBAAyB;AACzB,gCAAgC;AAChC,wBAAwB;AACxB,wBAAwB;AACxB,aAAa;AACb,mBAAmB;AACnB,qCAAqC;AACrC,oCAAoC;AACpC,2BAA2B;AAC3B,0BAA0B;AAC1B,aAAa;AACb,YAAY;AAEZ,uCAAuC;AACvC,qDAAqD;AACrD,8BAA8B;AAC9B,YAAY;AACZ,iDAAiD;AACjD,4BAA4B;AAC5B,yCAAyC;AACzC,aAAa;AACb,sBAAsB;AACtB,WAAW;AACX,6DAA6D;AAE7D,oCAAoC;AACpC,mDAAmD;AACnD,mBAAmB;AACnB,sBAAsB;AACtB,sCAAsC;AACtC,WAAW;AAEX,4BAA4B;AAC5B,8BAA8B;AAC9B,UAAU;AAEV,iEAAiE;AACjE,8DAA8D;AAC9D,aAAa;AACb,gFAAgF;AAChF,YAAY;AACZ,4DAA4D;AAC5D,UAAU;AACV,SAAS;AACT,wBAAwB;AACxB,OAAO;AACP,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync.bench.d.ts","sourceRoot":"","sources":["../../../test/benchmarks/sync.bench.ts"],"names":[],"mappings":""}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// import { RealWorldAssets } from "@sky-ph/atlas/document-models";
|
|
2
|
-
// import {
|
|
3
|
-
// driveDocumentModelModule,
|
|
4
|
-
// generateAddNodeAction,
|
|
5
|
-
// generateUUID,
|
|
6
|
-
// InternalTransmitterUpdate,
|
|
7
|
-
// IProcessor,
|
|
8
|
-
// ListenerFilter,
|
|
9
|
-
// ReactorBuilder,
|
|
10
|
-
// } from "document-drive";
|
|
11
|
-
// import { DocumentModelModule, PHDocument } from "@powerhousedao/shared/document-model";
|
|
12
|
-
export {};
|
|
13
|
-
// import { beforeAll, bench, describe } from "vitest";
|
|
14
|
-
// class TestReceiver implements IProcessor {
|
|
15
|
-
// async onStrands(strands: InternalTransmitterUpdate<PHDocument>[]) {
|
|
16
|
-
// return Promise.resolve();
|
|
17
|
-
// }
|
|
18
|
-
// async onDisconnect() {
|
|
19
|
-
// return Promise.resolve();
|
|
20
|
-
// }
|
|
21
|
-
// }
|
|
22
|
-
// beforeAll(async () => {});
|
|
23
|
-
// describe("Document Drive", async () => {
|
|
24
|
-
// const documentModels = Object.values([
|
|
25
|
-
// driveDocumentModelModule,
|
|
26
|
-
// RealWorldAssets,
|
|
27
|
-
// ]) as DocumentModelModule[];
|
|
28
|
-
// const document = await RealWorldAssets.utils.loadFromFile(
|
|
29
|
-
// "test/data/BlocktowerAndromeda.zip",
|
|
30
|
-
// );
|
|
31
|
-
// bench(
|
|
32
|
-
// "Load PHDM into Document Drive",
|
|
33
|
-
// async () => {
|
|
34
|
-
// const serverA = new ReactorBuilder(documentModels).build();
|
|
35
|
-
// await serverA.initialize();
|
|
36
|
-
// const serverB = new ReactorBuilder(documentModels).build();
|
|
37
|
-
// await serverB.initialize();
|
|
38
|
-
// const driveAId = generateUUID();
|
|
39
|
-
// const documentId = generateUUID();
|
|
40
|
-
// const driveA = await serverA.addDrive({
|
|
41
|
-
// global: {
|
|
42
|
-
// id: driveAId,
|
|
43
|
-
// name: "Test Drive",
|
|
44
|
-
// icon: null,
|
|
45
|
-
// slug: null,
|
|
46
|
-
// },
|
|
47
|
-
// local: {
|
|
48
|
-
// availableOffline: false,
|
|
49
|
-
// sharingType: "PRIVATE",
|
|
50
|
-
// listeners: [],
|
|
51
|
-
// triggers: [],
|
|
52
|
-
// },
|
|
53
|
-
// });
|
|
54
|
-
// const driveBId = generateUUID();
|
|
55
|
-
// const driveB = await serverB.addDrive({
|
|
56
|
-
// global: {
|
|
57
|
-
// id: driveBId,
|
|
58
|
-
// name: "Test Drive",
|
|
59
|
-
// icon: null,
|
|
60
|
-
// slug: null,
|
|
61
|
-
// },
|
|
62
|
-
// local: {
|
|
63
|
-
// availableOffline: false,
|
|
64
|
-
// sharingType: "PRIVATE",
|
|
65
|
-
// listeners: [],
|
|
66
|
-
// triggers: [],
|
|
67
|
-
// },
|
|
68
|
-
// });
|
|
69
|
-
// // listener!
|
|
70
|
-
// const filter: ListenerFilter = {
|
|
71
|
-
// branch: ["*"],
|
|
72
|
-
// documentId: ["*"],
|
|
73
|
-
// documentType: ["*"],
|
|
74
|
-
// scope: ["*"],
|
|
75
|
-
// };
|
|
76
|
-
// const receiver = new TestReceiver();
|
|
77
|
-
// await serverA.addInternalListener(driveAId, receiver, {
|
|
78
|
-
// listenerId: generateUUID(),
|
|
79
|
-
// label: "Test Listener",
|
|
80
|
-
// block: false,
|
|
81
|
-
// filter,
|
|
82
|
-
// });
|
|
83
|
-
// await serverB.addInternalListener(driveBId, receiver, {
|
|
84
|
-
// listenerId: generateUUID(),
|
|
85
|
-
// label: "Test Listener",
|
|
86
|
-
// block: false,
|
|
87
|
-
// filter,
|
|
88
|
-
// });
|
|
89
|
-
// // loads document in drive A
|
|
90
|
-
// const addFileAction = generateAddNodeAction(
|
|
91
|
-
// driveA.state.global,
|
|
92
|
-
// {
|
|
93
|
-
// documentType: document.documentType,
|
|
94
|
-
// id: documentId,
|
|
95
|
-
// name: "BlocktowerAndromeda",
|
|
96
|
-
// },
|
|
97
|
-
// ["global"],
|
|
98
|
-
// );
|
|
99
|
-
// await serverA.addDriveAction(driveAId, addFileAction);
|
|
100
|
-
// const result = await serverA.addOperations(
|
|
101
|
-
// driveAId,
|
|
102
|
-
// documentId,
|
|
103
|
-
// document.operations.global,
|
|
104
|
-
// );
|
|
105
|
-
// if (result.error) {
|
|
106
|
-
// throw result.error;
|
|
107
|
-
// }
|
|
108
|
-
// const lastOperation = document.operations.global.at(-1);
|
|
109
|
-
// const lastLoadedOperation = result.operations.at(-1);
|
|
110
|
-
// if (
|
|
111
|
-
// JSON.stringify(lastOperation) !== JSON.stringify(lastLoadedOperation)
|
|
112
|
-
// ) {
|
|
113
|
-
// throw new Error("Document operations mismatch");
|
|
114
|
-
// }
|
|
115
|
-
// },
|
|
116
|
-
// { throws: true },
|
|
117
|
-
// );
|
|
118
|
-
// });
|
|
119
|
-
//# sourceMappingURL=sync.bench.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync.bench.js","sourceRoot":"","sources":["../../../test/benchmarks/sync.bench.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,WAAW;AACX,8BAA8B;AAC9B,2BAA2B;AAC3B,kBAAkB;AAClB,+BAA+B;AAC/B,gBAAgB;AAChB,oBAAoB;AACpB,oBAAoB;AACpB,2BAA2B;AAC3B,0FAA0F;;AAE1F,uDAAuD;AAEvD,6CAA6C;AAC7C,wEAAwE;AACxE,gCAAgC;AAChC,MAAM;AAEN,2BAA2B;AAC3B,gCAAgC;AAChC,MAAM;AACN,IAAI;AAEJ,6BAA6B;AAE7B,2CAA2C;AAC3C,2CAA2C;AAC3C,gCAAgC;AAChC,uBAAuB;AACvB,iCAAiC;AACjC,+DAA+D;AAC/D,2CAA2C;AAC3C,OAAO;AAEP,WAAW;AACX,uCAAuC;AACvC,oBAAoB;AACpB,oEAAoE;AACpE,oCAAoC;AAEpC,oEAAoE;AACpE,oCAAoC;AAEpC,yCAAyC;AACzC,2CAA2C;AAE3C,gDAAgD;AAChD,oBAAoB;AACpB,0BAA0B;AAC1B,gCAAgC;AAChC,wBAAwB;AACxB,wBAAwB;AACxB,aAAa;AACb,mBAAmB;AACnB,qCAAqC;AACrC,oCAAoC;AACpC,2BAA2B;AAC3B,0BAA0B;AAC1B,aAAa;AACb,YAAY;AAEZ,yCAAyC;AACzC,gDAAgD;AAChD,oBAAoB;AACpB,0BAA0B;AAC1B,gCAAgC;AAChC,wBAAwB;AACxB,wBAAwB;AACxB,aAAa;AACb,mBAAmB;AACnB,qCAAqC;AACrC,oCAAoC;AACpC,2BAA2B;AAC3B,0BAA0B;AAC1B,aAAa;AACb,YAAY;AAEZ,qBAAqB;AACrB,yCAAyC;AACzC,yBAAyB;AACzB,6BAA6B;AAC7B,+BAA+B;AAC/B,wBAAwB;AACxB,WAAW;AAEX,6CAA6C;AAC7C,gEAAgE;AAChE,sCAAsC;AACtC,kCAAkC;AAClC,wBAAwB;AACxB,kBAAkB;AAClB,YAAY;AAEZ,gEAAgE;AAChE,sCAAsC;AACtC,kCAAkC;AAClC,wBAAwB;AACxB,kBAAkB;AAClB,YAAY;AAEZ,qCAAqC;AACrC,qDAAqD;AACrD,+BAA+B;AAC/B,YAAY;AACZ,iDAAiD;AACjD,4BAA4B;AAC5B,yCAAyC;AACzC,aAAa;AACb,sBAAsB;AACtB,WAAW;AACX,+DAA+D;AAE/D,oDAAoD;AACpD,oBAAoB;AACpB,sBAAsB;AACtB,sCAAsC;AACtC,WAAW;AAEX,4BAA4B;AAC5B,8BAA8B;AAC9B,UAAU;AAEV,iEAAiE;AACjE,8DAA8D;AAC9D,aAAa;AACb,gFAAgF;AAChF,YAAY;AACZ,4DAA4D;AAC5D,UAAU;AACV,SAAS;AACT,wBAAwB;AACxB,OAAO;AACP,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity-integration.test.d.ts","sourceRoot":"","sources":["../../test/identity-integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
describe("nothing", () => {
|
|
3
|
-
it("does nothing", () => {
|
|
4
|
-
expect(true).toBe(true);
|
|
5
|
-
});
|
|
6
|
-
});
|
|
7
|
-
// /**
|
|
8
|
-
// * Integration tests for identity-based authentication and signed actions.
|
|
9
|
-
// *
|
|
10
|
-
// * This test demonstrates the full flow:
|
|
11
|
-
// * 1. Starting reactor-api with initializeAndStartAPI
|
|
12
|
-
// * 2. Setting up a test identity (keypair) programmatically
|
|
13
|
-
// * 3. Using ConnectCrypto to get bearer tokens
|
|
14
|
-
// * 4. Pushing authenticated requests to reactor-api
|
|
15
|
-
// */
|
|
16
|
-
// import { PGlite } from "@electric-sql/pglite";
|
|
17
|
-
// import {
|
|
18
|
-
// type Database,
|
|
19
|
-
// EventBus,
|
|
20
|
-
// ReactorBuilder as NewReactorBuilder,
|
|
21
|
-
// ReactorClientBuilder,
|
|
22
|
-
// SyncBuilder,
|
|
23
|
-
// } from "@powerhousedao/reactor";
|
|
24
|
-
// import {
|
|
25
|
-
// ConnectCrypto,
|
|
26
|
-
// type IConnectCrypto,
|
|
27
|
-
// type JsonWebKeyPairStorage,
|
|
28
|
-
// type JwkKeyPair,
|
|
29
|
-
// } from "@renown/sdk";
|
|
30
|
-
// import type { IDocumentDriveServer } from "document-drive";
|
|
31
|
-
// import {
|
|
32
|
-
// InMemoryCache,
|
|
33
|
-
// MemoryStorage,
|
|
34
|
-
// ReactorBuilder,
|
|
35
|
-
// driveDocumentModelModule,
|
|
36
|
-
// } from "document-drive";
|
|
37
|
-
// import type { DocumentModelModule } from "@powerhousedao/shared/document-model";
|
|
38
|
-
// import { documentModelDocumentModelModule } from "document-model";
|
|
39
|
-
// import { Kysely } from "kysely";
|
|
40
|
-
// import { PGliteDialect } from "kysely-pglite-dialect";
|
|
41
|
-
// import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
42
|
-
// import { getUniqueDocumentModels, initializeAndStartAPI } from "../src/index.js";
|
|
43
|
-
// /**
|
|
44
|
-
// * In-memory key storage for testing.
|
|
45
|
-
// */
|
|
46
|
-
// class TestKeyStorage implements JsonWebKeyPairStorage {
|
|
47
|
-
// private keyPair: JwkKeyPair | undefined;
|
|
48
|
-
// async loadKeyPair(): Promise<JwkKeyPair | undefined> {
|
|
49
|
-
// return this.keyPair;
|
|
50
|
-
// }
|
|
51
|
-
// async saveKeyPair(keyPair: JwkKeyPair): Promise<void> {
|
|
52
|
-
// this.keyPair = keyPair;
|
|
53
|
-
// }
|
|
54
|
-
// getStoredKeyPair(): JwkKeyPair | undefined {
|
|
55
|
-
// return this.keyPair;
|
|
56
|
-
// }
|
|
57
|
-
// }
|
|
58
|
-
// // Use a random port to avoid conflicts
|
|
59
|
-
// const TEST_PORT = 14000 + Math.floor(Math.random() * 1000);
|
|
60
|
-
// const BASE_URL = `http://localhost:${TEST_PORT}`;
|
|
61
|
-
// describe("Identity Integration with startAPI", () => {
|
|
62
|
-
// let connectCrypto: IConnectCrypto;
|
|
63
|
-
// let testKeyStorage: TestKeyStorage;
|
|
64
|
-
// beforeAll(async () => {
|
|
65
|
-
// // Set up test identity
|
|
66
|
-
// testKeyStorage = new TestKeyStorage();
|
|
67
|
-
// connectCrypto = new ConnectCrypto(testKeyStorage);
|
|
68
|
-
// await connectCrypto.did();
|
|
69
|
-
// // Set up storage
|
|
70
|
-
// const cache = new InMemoryCache();
|
|
71
|
-
// const storage = new MemoryStorage();
|
|
72
|
-
// // Initialize drive server function
|
|
73
|
-
// const initializeDriveServer = async (
|
|
74
|
-
// documentModels: DocumentModelModule[],
|
|
75
|
-
// ) => {
|
|
76
|
-
// const driveServer = new ReactorBuilder(
|
|
77
|
-
// getUniqueDocumentModels([
|
|
78
|
-
// documentModelDocumentModelModule,
|
|
79
|
-
// driveDocumentModelModule,
|
|
80
|
-
// ...documentModels,
|
|
81
|
-
// ] as unknown as DocumentModelModule[]),
|
|
82
|
-
// )
|
|
83
|
-
// .withStorage(storage)
|
|
84
|
-
// .withCache(cache)
|
|
85
|
-
// .build();
|
|
86
|
-
// await driveServer.initialize();
|
|
87
|
-
// return driveServer;
|
|
88
|
-
// };
|
|
89
|
-
// // Initialize client function
|
|
90
|
-
// const initializeClient = async (
|
|
91
|
-
// _driveServer: IDocumentDriveServer,
|
|
92
|
-
// documentModels: DocumentModelModule[],
|
|
93
|
-
// ) => {
|
|
94
|
-
// const eventBus = new EventBus();
|
|
95
|
-
// const pglite = new PGlite();
|
|
96
|
-
// const kysely = new Kysely<Database>({
|
|
97
|
-
// dialect: new PGliteDialect(pglite),
|
|
98
|
-
// });
|
|
99
|
-
// const builder = new NewReactorBuilder()
|
|
100
|
-
// .withEventBus(eventBus)
|
|
101
|
-
// .withDocumentModels(
|
|
102
|
-
// getUniqueDocumentModels([
|
|
103
|
-
// documentModelDocumentModelModule,
|
|
104
|
-
// driveDocumentModelModule,
|
|
105
|
-
// ...documentModels,
|
|
106
|
-
// ] as unknown as DocumentModelModule[]),
|
|
107
|
-
// )
|
|
108
|
-
// .withLegacyStorage(storage)
|
|
109
|
-
// .withSync(new SyncBuilder())
|
|
110
|
-
// .withFeatures({
|
|
111
|
-
// legacyStorageEnabled: true,
|
|
112
|
-
// })
|
|
113
|
-
// .withKysely(kysely);
|
|
114
|
-
// const module = await new ReactorClientBuilder()
|
|
115
|
-
// .withReactorBuilder(builder)
|
|
116
|
-
// .buildModule();
|
|
117
|
-
// const syncManager = module.reactorModule?.syncModule?.syncManager;
|
|
118
|
-
// if (!syncManager) {
|
|
119
|
-
// throw new Error("SyncManager not available from ReactorClientBuilder");
|
|
120
|
-
// }
|
|
121
|
-
// return { client: module.client, syncManager };
|
|
122
|
-
// };
|
|
123
|
-
// // Start the API server
|
|
124
|
-
// await initializeAndStartAPI(initializeDriveServer, initializeClient, {
|
|
125
|
-
// port: TEST_PORT,
|
|
126
|
-
// dbPath: undefined, // Use in-memory database
|
|
127
|
-
// auth: {
|
|
128
|
-
// enabled: false, // Disable auth for basic tests
|
|
129
|
-
// admins: [],
|
|
130
|
-
// users: [],
|
|
131
|
-
// guests: [],
|
|
132
|
-
// freeEntry: true,
|
|
133
|
-
// },
|
|
134
|
-
// });
|
|
135
|
-
// }, 30000);
|
|
136
|
-
// afterAll(async () => {
|
|
137
|
-
// // The server will be cleaned up when the test process exits
|
|
138
|
-
// });
|
|
139
|
-
// describe("Server Health", () => {
|
|
140
|
-
// it("should have the GraphQL endpoint available", async () => {
|
|
141
|
-
// const response = await fetch(`${BASE_URL}/graphql`, {
|
|
142
|
-
// method: "POST",
|
|
143
|
-
// headers: {
|
|
144
|
-
// "Content-Type": "application/json",
|
|
145
|
-
// },
|
|
146
|
-
// body: JSON.stringify({
|
|
147
|
-
// query: `{ __typename }`,
|
|
148
|
-
// }),
|
|
149
|
-
// });
|
|
150
|
-
// expect(response.ok).toBe(true);
|
|
151
|
-
// const data = await response.json();
|
|
152
|
-
// expect(data.data).toBeDefined();
|
|
153
|
-
// });
|
|
154
|
-
// });
|
|
155
|
-
// describe("Identity Setup", () => {
|
|
156
|
-
// it("should generate a DID for the test identity", async () => {
|
|
157
|
-
// const did = await connectCrypto.did();
|
|
158
|
-
// expect(did).toMatch(/^did:key:/);
|
|
159
|
-
// });
|
|
160
|
-
// it("should be able to get issuer for signing", async () => {
|
|
161
|
-
// const issuer = await connectCrypto.getIssuer();
|
|
162
|
-
// expect(issuer).toBeDefined();
|
|
163
|
-
// expect(typeof issuer.did).toBe("string");
|
|
164
|
-
// expect(typeof issuer.signer).toBe("function");
|
|
165
|
-
// });
|
|
166
|
-
// it("should generate a bearer token", async () => {
|
|
167
|
-
// const token = await connectCrypto.getBearerToken(BASE_URL, undefined);
|
|
168
|
-
// expect(token).toBeDefined();
|
|
169
|
-
// expect(typeof token).toBe("string");
|
|
170
|
-
// });
|
|
171
|
-
// });
|
|
172
|
-
// describe("GraphQL Queries", () => {
|
|
173
|
-
// it("should query document models", async () => {
|
|
174
|
-
// const response = await fetch(`${BASE_URL}/graphql`, {
|
|
175
|
-
// method: "POST",
|
|
176
|
-
// headers: {
|
|
177
|
-
// "Content-Type": "application/json",
|
|
178
|
-
// },
|
|
179
|
-
// body: JSON.stringify({
|
|
180
|
-
// query: `
|
|
181
|
-
// query {
|
|
182
|
-
// documentModels {
|
|
183
|
-
// results {
|
|
184
|
-
// documentModel {
|
|
185
|
-
// name
|
|
186
|
-
// id
|
|
187
|
-
// }
|
|
188
|
-
// }
|
|
189
|
-
// }
|
|
190
|
-
// }
|
|
191
|
-
// `,
|
|
192
|
-
// }),
|
|
193
|
-
// });
|
|
194
|
-
// expect(response.ok).toBe(true);
|
|
195
|
-
// const data = (await response.json()) as {
|
|
196
|
-
// data?: { documentModels?: { results?: unknown[] } };
|
|
197
|
-
// };
|
|
198
|
-
// expect(data.data?.documentModels?.results).toBeDefined();
|
|
199
|
-
// });
|
|
200
|
-
// it("should query system info", async () => {
|
|
201
|
-
// const response = await fetch(`${BASE_URL}/graphql`, {
|
|
202
|
-
// method: "POST",
|
|
203
|
-
// headers: {
|
|
204
|
-
// "Content-Type": "application/json",
|
|
205
|
-
// },
|
|
206
|
-
// body: JSON.stringify({
|
|
207
|
-
// query: `
|
|
208
|
-
// query {
|
|
209
|
-
// system {
|
|
210
|
-
// auth {
|
|
211
|
-
// me {
|
|
212
|
-
// address
|
|
213
|
-
// }
|
|
214
|
-
// }
|
|
215
|
-
// }
|
|
216
|
-
// }
|
|
217
|
-
// `,
|
|
218
|
-
// }),
|
|
219
|
-
// });
|
|
220
|
-
// expect(response.ok).toBe(true);
|
|
221
|
-
// const data = await response.json();
|
|
222
|
-
// expect(data.data).toBeDefined();
|
|
223
|
-
// });
|
|
224
|
-
// });
|
|
225
|
-
// describe("Authenticated Requests", () => {
|
|
226
|
-
// it("should make authenticated GraphQL request with bearer token", async () => {
|
|
227
|
-
// const token = await connectCrypto.getBearerToken(BASE_URL, undefined);
|
|
228
|
-
// const response = await fetch(`${BASE_URL}/graphql`, {
|
|
229
|
-
// method: "POST",
|
|
230
|
-
// headers: {
|
|
231
|
-
// "Content-Type": "application/json",
|
|
232
|
-
// Authorization: `Bearer ${token}`,
|
|
233
|
-
// },
|
|
234
|
-
// body: JSON.stringify({
|
|
235
|
-
// query: `
|
|
236
|
-
// query {
|
|
237
|
-
// documentModels {
|
|
238
|
-
// results {
|
|
239
|
-
// documentModel {
|
|
240
|
-
// name
|
|
241
|
-
// }
|
|
242
|
-
// }
|
|
243
|
-
// }
|
|
244
|
-
// }
|
|
245
|
-
// `,
|
|
246
|
-
// }),
|
|
247
|
-
// });
|
|
248
|
-
// expect(response.ok).toBe(true);
|
|
249
|
-
// const data = await response.json();
|
|
250
|
-
// expect(data.data).toBeDefined();
|
|
251
|
-
// });
|
|
252
|
-
// });
|
|
253
|
-
// describe("Action Signing", () => {
|
|
254
|
-
// it("should sign action data with identity", async () => {
|
|
255
|
-
// const issuer = await connectCrypto.getIssuer();
|
|
256
|
-
// // Simulate signing an action
|
|
257
|
-
// const actionData = JSON.stringify({
|
|
258
|
-
// type: "SET_NAME",
|
|
259
|
-
// scope: "global",
|
|
260
|
-
// input: { name: "Test Document" },
|
|
261
|
-
// });
|
|
262
|
-
// const signature = await issuer.signer(actionData);
|
|
263
|
-
// expect(signature).toBeDefined();
|
|
264
|
-
// expect(typeof signature).toBe("string");
|
|
265
|
-
// expect((signature as string).length).toBeGreaterThan(0);
|
|
266
|
-
// });
|
|
267
|
-
// it("should produce signatures for data", async () => {
|
|
268
|
-
// const issuer = await connectCrypto.getIssuer();
|
|
269
|
-
// const testData = "test data";
|
|
270
|
-
// const signature1 = await issuer.signer(testData);
|
|
271
|
-
// const signature2 = await issuer.signer(testData);
|
|
272
|
-
// // ECDSA signatures include randomness, so they may differ
|
|
273
|
-
// // but both should be valid strings
|
|
274
|
-
// expect(signature1).toBeDefined();
|
|
275
|
-
// expect(signature2).toBeDefined();
|
|
276
|
-
// });
|
|
277
|
-
// });
|
|
278
|
-
// describe("Full Workflow", () => {
|
|
279
|
-
// it("should demonstrate complete identity-based API interaction", async () => {
|
|
280
|
-
// // 1. Get identity DID
|
|
281
|
-
// const did = await connectCrypto.did();
|
|
282
|
-
// expect(did).toMatch(/^did:key:/);
|
|
283
|
-
// // 2. Get bearer token for API authentication
|
|
284
|
-
// const token = await connectCrypto.getBearerToken(BASE_URL, undefined);
|
|
285
|
-
// expect(token).toBeDefined();
|
|
286
|
-
// // 3. Get issuer for signing operations
|
|
287
|
-
// const issuer = await connectCrypto.getIssuer();
|
|
288
|
-
// expect(issuer.did).toBe(did);
|
|
289
|
-
// // 4. Make authenticated API call
|
|
290
|
-
// const response = await fetch(`${BASE_URL}/graphql`, {
|
|
291
|
-
// method: "POST",
|
|
292
|
-
// headers: {
|
|
293
|
-
// "Content-Type": "application/json",
|
|
294
|
-
// Authorization: `Bearer ${token}`,
|
|
295
|
-
// },
|
|
296
|
-
// body: JSON.stringify({
|
|
297
|
-
// query: `{ __typename }`,
|
|
298
|
-
// }),
|
|
299
|
-
// });
|
|
300
|
-
// expect(response.ok).toBe(true);
|
|
301
|
-
// // 5. Sign operation data (for when submitting signed operations)
|
|
302
|
-
// const operationData = JSON.stringify({
|
|
303
|
-
// type: "CREATE_DOCUMENT",
|
|
304
|
-
// scope: "global",
|
|
305
|
-
// input: { documentType: "powerhouse/document-model" },
|
|
306
|
-
// });
|
|
307
|
-
// const signature = await issuer.signer(operationData);
|
|
308
|
-
// expect(signature).toBeDefined();
|
|
309
|
-
// });
|
|
310
|
-
// });
|
|
311
|
-
// });
|
|
312
|
-
// /**
|
|
313
|
-
// * Usage Guide:
|
|
314
|
-
// *
|
|
315
|
-
// * This test demonstrates how to integrate identity-based authentication with reactor-api.
|
|
316
|
-
// *
|
|
317
|
-
// * Prerequisites:
|
|
318
|
-
// * 1. User runs `ph login` to authenticate with Renown
|
|
319
|
-
// * 2. This creates `.auth.json` (user credentials) and `.keypair.json` (signing keys)
|
|
320
|
-
// *
|
|
321
|
-
// * Programmatic Flow:
|
|
322
|
-
// * ```typescript
|
|
323
|
-
// * import { ConnectCrypto, type JsonWebKeyPairStorage } from "@renown/sdk";
|
|
324
|
-
// *
|
|
325
|
-
// * // 1. Create key storage (or use existing from ph login)
|
|
326
|
-
// * class MyKeyStorage implements JsonWebKeyPairStorage {
|
|
327
|
-
// * async loadKeyPair() { return loadFromFile('.keypair.json'); }
|
|
328
|
-
// * async saveKeyPair(kp) { saveToFile('.keypair.json', kp); }
|
|
329
|
-
// * }
|
|
330
|
-
// *
|
|
331
|
-
// * // 2. Initialize ConnectCrypto
|
|
332
|
-
// * const crypto = new ConnectCrypto(new MyKeyStorage());
|
|
333
|
-
// * const did = await crypto.did(); // Generates keypair if none exists
|
|
334
|
-
// *
|
|
335
|
-
// * // 3. Get bearer token for API
|
|
336
|
-
// * const token = await crypto.getBearerToken("http://localhost:4000", undefined);
|
|
337
|
-
// *
|
|
338
|
-
// * // 4. Make authenticated requests
|
|
339
|
-
// * fetch("http://localhost:4000/graphql", {
|
|
340
|
-
// * headers: { "Authorization": `Bearer ${token}` },
|
|
341
|
-
// * // ...
|
|
342
|
-
// * });
|
|
343
|
-
// *
|
|
344
|
-
// * // 5. Sign operations (for operation-level signatures)
|
|
345
|
-
// * const issuer = await crypto.getIssuer();
|
|
346
|
-
// * const signature = await issuer.signer(JSON.stringify(action));
|
|
347
|
-
// * ```
|
|
348
|
-
// */
|
|
349
|
-
//# sourceMappingURL=identity-integration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity-integration.test.js","sourceRoot":"","sources":["../../test/identity-integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM;AACN,6EAA6E;AAC7E,KAAK;AACL,2CAA2C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