@olane/o-core 0.7.29 → 0.7.33

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.
@@ -2,5 +2,6 @@ export * from './o-notification-event.js';
2
2
  export * from './node-events.js';
3
3
  export * from './hierarchy-events.js';
4
4
  export * from './connection-events.js';
5
+ export * from './peer-events.js';
5
6
  export * from '../interfaces/notification-types.js';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qCAAqC,CAAC"}
@@ -2,4 +2,5 @@ export * from './o-notification-event.js';
2
2
  export * from './node-events.js';
3
3
  export * from './hierarchy-events.js';
4
4
  export * from './connection-events.js';
5
+ export * from './peer-events.js';
5
6
  export * from '../interfaces/notification-types.js';
@@ -0,0 +1,48 @@
1
+ import { oAddress } from '../../../router/o-address.js';
2
+ import { oNotificationEvent } from './o-notification-event.js';
3
+ /**
4
+ * Low-level peer connection event (protocol layer)
5
+ * Emitted when a libp2p peer connection is established
6
+ * Contains raw peer ID before address resolution
7
+ */
8
+ export declare class PeerConnectedEvent extends oNotificationEvent {
9
+ readonly peerId: string;
10
+ readonly connectionMetadata: Record<string, any>;
11
+ constructor(config: {
12
+ source: oAddress;
13
+ peerId: string;
14
+ connectionMetadata?: Record<string, any>;
15
+ });
16
+ protected getEventData(): Record<string, any>;
17
+ }
18
+ /**
19
+ * Low-level peer disconnection event (protocol layer)
20
+ * Emitted when a libp2p peer connection is closed
21
+ * Contains raw peer ID before address resolution
22
+ */
23
+ export declare class PeerDisconnectedEvent extends oNotificationEvent {
24
+ readonly peerId: string;
25
+ readonly reason?: string;
26
+ constructor(config: {
27
+ source: oAddress;
28
+ peerId: string;
29
+ reason?: string;
30
+ });
31
+ protected getEventData(): Record<string, any>;
32
+ }
33
+ /**
34
+ * Low-level peer discovery event (protocol layer)
35
+ * Emitted when a libp2p peer is discovered
36
+ * Contains raw peer ID and multiaddrs before address resolution
37
+ */
38
+ export declare class PeerDiscoveredEvent extends oNotificationEvent {
39
+ readonly peerId: string;
40
+ readonly multiaddrs?: string[];
41
+ constructor(config: {
42
+ source: oAddress;
43
+ peerId: string;
44
+ multiaddrs?: string[];
45
+ });
46
+ protected getEventData(): Record<string, any>;
47
+ }
48
+ //# sourceMappingURL=peer-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer-events.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/events/peer-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAErC,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,kBAAkB;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;gBAEnB,MAAM,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB;IAUD,SAAS,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAM9C"}
@@ -0,0 +1,67 @@
1
+ import { oNotificationEvent, } from './o-notification-event.js';
2
+ /**
3
+ * Low-level peer connection event (protocol layer)
4
+ * Emitted when a libp2p peer connection is established
5
+ * Contains raw peer ID before address resolution
6
+ */
7
+ export class PeerConnectedEvent extends oNotificationEvent {
8
+ constructor(config) {
9
+ super({
10
+ type: 'peer:connected',
11
+ source: config.source,
12
+ metadata: config.connectionMetadata || {},
13
+ });
14
+ this.peerId = config.peerId;
15
+ this.connectionMetadata = config.connectionMetadata || {};
16
+ }
17
+ getEventData() {
18
+ return {
19
+ peerId: this.peerId,
20
+ connectionMetadata: this.connectionMetadata,
21
+ };
22
+ }
23
+ }
24
+ /**
25
+ * Low-level peer disconnection event (protocol layer)
26
+ * Emitted when a libp2p peer connection is closed
27
+ * Contains raw peer ID before address resolution
28
+ */
29
+ export class PeerDisconnectedEvent extends oNotificationEvent {
30
+ constructor(config) {
31
+ super({
32
+ type: 'peer:disconnected',
33
+ source: config.source,
34
+ metadata: { reason: config.reason },
35
+ });
36
+ this.peerId = config.peerId;
37
+ this.reason = config.reason;
38
+ }
39
+ getEventData() {
40
+ return {
41
+ peerId: this.peerId,
42
+ reason: this.reason,
43
+ };
44
+ }
45
+ }
46
+ /**
47
+ * Low-level peer discovery event (protocol layer)
48
+ * Emitted when a libp2p peer is discovered
49
+ * Contains raw peer ID and multiaddrs before address resolution
50
+ */
51
+ export class PeerDiscoveredEvent extends oNotificationEvent {
52
+ constructor(config) {
53
+ super({
54
+ type: 'peer:discovered',
55
+ source: config.source,
56
+ metadata: { multiaddrs: config.multiaddrs },
57
+ });
58
+ this.peerId = config.peerId;
59
+ this.multiaddrs = config.multiaddrs;
60
+ }
61
+ getEventData() {
62
+ return {
63
+ peerId: this.peerId,
64
+ multiaddrs: this.multiaddrs,
65
+ };
66
+ }
67
+ }
@@ -28,7 +28,7 @@ export class oHierarchyManager extends oObject {
28
28
  // remove child if it exists
29
29
  this.removeChild(address);
30
30
  // deduplicate
31
- this.children = this.deduplicate([...this.children, address]);
31
+ this.children = this.deduplicate([address, ...this.children]);
32
32
  }
33
33
  getChild(address) {
34
34
  return this.children.find((a) => a.toStaticAddress().toString() === address.toStaticAddress().toString());
@@ -39,7 +39,7 @@ export class oHierarchyManager extends oObject {
39
39
  ]);
40
40
  }
41
41
  addParent(address) {
42
- this.parents = this.deduplicate([...this.parents, address]);
42
+ this.parents = this.deduplicate([address, ...this.parents]);
43
43
  }
44
44
  removeParent(address) {
45
45
  this.parents = this.deduplicate([
@@ -155,7 +155,7 @@ export declare abstract class oCore extends oObject {
155
155
  protected onNotification(eventType: string, handler: NotificationHandler, filter?: EventFilter): Subscription;
156
156
  initialize(): Promise<void>;
157
157
  get isRunning(): boolean;
158
- hookStartFinished(): Promise<void>;
158
+ protected hookStartFinished(): Promise<void>;
159
159
  /**
160
160
  * Starts the node by transitioning through initialization and registration phases.
161
161
  *
@@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EAAE,CAEnC;IAEK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;CAQ7B"}
@@ -5,7 +5,6 @@ import { oDependency } from './o-dependency.js';
5
5
  import { oError } from '../error/o-error.js';
6
6
  import { oObject } from './o-object.js';
7
7
  import { oMetrics } from './lib/o-metrics.js';
8
- import { oHierarchyManager } from './lib/o-hierarchy.manager.js';
9
8
  import { oRequestManager } from './lib/o-request.manager.js';
10
9
  import { oRequest } from '../connection/o-request.js';
11
10
  import { ResponseBuilder } from '../response/response-builder.js';
@@ -23,10 +22,6 @@ export class oCore extends oObject {
23
22
  config.address.validateNotNested();
24
23
  }
25
24
  this.address = config.address || new oAddress('o://node');
26
- this.hierarchyManager = new oHierarchyManager({
27
- leaders: this.config.leader ? [this.config.leader] : [],
28
- parents: this.config.parent ? [this.config.parent] : [],
29
- });
30
25
  }
31
26
  get isLeader() {
32
27
  return this.config.type === NodeType.LEADER;
@@ -252,11 +247,7 @@ export class oCore extends oObject {
252
247
  return this.notificationManager.on(eventType, handler, filter);
253
248
  }
254
249
  // initialize
255
- async initialize() {
256
- // Create and initialize notification manager
257
- this.notificationManager = this.createNotificationManager();
258
- await this.notificationManager.initialize();
259
- }
250
+ async initialize() { }
260
251
  get isRunning() {
261
252
  return (this.state === NodeState.RUNNING ||
262
253
  this.state === NodeState.STOPPING ||
@@ -415,10 +406,7 @@ export class oCore extends oObject {
415
406
  // Reset address to config address with no transports
416
407
  this.address = new oAddress(this.config.address.toStaticAddress().value, []);
417
408
  // Reset hierarchy manager to initial state
418
- this.hierarchyManager = new oHierarchyManager({
419
- leaders: this.config.leader ? [this.config.leader] : [],
420
- parents: this.config.parent ? [this.config.parent] : [],
421
- });
409
+ this.hierarchyManager.clear();
422
410
  }
423
411
  get dependencies() {
424
412
  return this.config.dependencies?.map((d) => new oDependency(d)) || [];
@@ -32,6 +32,14 @@ export declare class CoreUtils extends oObject {
32
32
  * @param stream - The stream to send the response through
33
33
  */
34
34
  static sendResponse(response: oResponse, stream: Stream): Promise<void>;
35
+ /**
36
+ * Sends a response through a stream using length-prefixed encoding
37
+ * Uses lpStream for proper message boundaries (libp2p v3 best practice)
38
+ *
39
+ * @param response - The response to send
40
+ * @param stream - The stream to send the response through
41
+ */
42
+ static sendResponseLP(response: oResponse, stream: Stream): Promise<void>;
35
43
  /**
36
44
  * @deprecated Use sendResponse instead - both methods are now identical
37
45
  * Sends a streaming response through a stream
@@ -39,6 +47,15 @@ export declare class CoreUtils extends oObject {
39
47
  */
40
48
  static sendStreamResponse(response: oResponse, stream: Stream): Promise<void>;
41
49
  static processStream(event: any): Promise<any>;
50
+ /**
51
+ * Processes a length-prefixed stream event
52
+ * With length-prefixing, messages are guaranteed to be complete and not concatenated
53
+ * This eliminates the need for the '}{' splitting hack
54
+ *
55
+ * @param event - The stream event containing message data
56
+ * @returns The parsed message object
57
+ */
58
+ static processStreamLP(event: any): Promise<any>;
42
59
  static processStreamRequest(event: any): Promise<oRequest>;
43
60
  static processStreamResponse(event: any): Promise<oResponse>;
44
61
  static toCID(data: any): Promise<CID>;
@@ -1 +1 @@
1
- {"version":3,"file":"core.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/core.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAGP,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,SAAU,SAAQ,OAAO;WACvB,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAK3C,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;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AC,QAAQ,CAAC;WAKnD,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;WAQrD,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAMnD"}
@@ -1,4 +1,4 @@
1
- import { generateKeyPairFromSeed, createEd25519PeerId, Uint8ArrayList, } from '@olane/o-config';
1
+ import { generateKeyPairFromSeed, createEd25519PeerId, Uint8ArrayList, lpStream, } from '@olane/o-config';
2
2
  import { createHash } from 'crypto';
3
3
  import { oAddress } from '../router/o-address.js';
4
4
  import { oResponse } from '../connection/o-response.js';
@@ -95,6 +95,28 @@ export class CoreUtils extends oObject {
95
95
  utils.logger.error('Error sending response: ', error);
96
96
  }
97
97
  }
98
+ /**
99
+ * Sends a response through a stream using length-prefixed encoding
100
+ * Uses lpStream for proper message boundaries (libp2p v3 best practice)
101
+ *
102
+ * @param response - The response to send
103
+ * @param stream - The stream to send the response through
104
+ */
105
+ static async sendResponseLP(response, stream) {
106
+ const utils = new CoreUtils();
107
+ if (!stream || stream.status !== 'open') {
108
+ utils.logger.warn('Stream is not open. Status: ' + (stream?.status || 'undefined'));
109
+ return;
110
+ }
111
+ try {
112
+ const lp = lpStream(stream);
113
+ const data = new TextEncoder().encode(response.toString());
114
+ await lp.write(data);
115
+ }
116
+ catch (error) {
117
+ utils.logger.error('Error sending length-prefixed response: ', error);
118
+ }
119
+ }
98
120
  /**
99
121
  * @deprecated Use sendResponse instead - both methods are now identical
100
122
  * Sends a streaming response through a stream
@@ -125,6 +147,32 @@ export class CoreUtils extends oObject {
125
147
  return decoded;
126
148
  }
127
149
  }
150
+ /**
151
+ * Processes a length-prefixed stream event
152
+ * With length-prefixing, messages are guaranteed to be complete and not concatenated
153
+ * This eliminates the need for the '}{' splitting hack
154
+ *
155
+ * @param event - The stream event containing message data
156
+ * @returns The parsed message object
157
+ */
158
+ static async processStreamLP(event) {
159
+ const bytes = event.data instanceof Uint8ArrayList ? event.data.subarray() : event.data;
160
+ const decoded = new TextDecoder().decode(bytes);
161
+ const utils = new CoreUtils();
162
+ try {
163
+ // With length-prefixing, no need to check for concatenated messages
164
+ if (decoded.startsWith('{')) {
165
+ return JSON.parse(decoded);
166
+ }
167
+ else {
168
+ return decoded;
169
+ }
170
+ }
171
+ catch (error) {
172
+ utils.logger.error('[ERROR] Error processing length-prefixed stream event: ', error, decoded);
173
+ return decoded;
174
+ }
175
+ }
128
176
  static async processStreamRequest(event) {
129
177
  const req = await CoreUtils.processStream(event);
130
178
  return new oRequest(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-core",
3
- "version": "0.7.29",
3
+ "version": "0.7.33",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -63,12 +63,12 @@
63
63
  "typescript": "^5.8.3"
64
64
  },
65
65
  "dependencies": {
66
- "@olane/o-protocol": "0.7.29",
66
+ "@olane/o-protocol": "0.7.33",
67
67
  "chalk": "^5.4.1",
68
68
  "debug": "^4.4.1",
69
69
  "dotenv": "^16.5.0",
70
70
  "multiformats": "^13.3.7",
71
71
  "stream-json": "^1.9.1"
72
72
  },
73
- "gitHead": "3aaf809d720ac59971d636d3dbdf6c4eadd83bca"
73
+ "gitHead": "a1a218ce3cb7ffca90b442b07baff4ef15844318"
74
74
  }