@olane/o-core 0.4.1 → 0.4.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../../../src/core/core.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,YAAY,EACZ,SAAS,EAET,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,8BAAsB,SAAS;IAmBjB,QAAQ,CAAC,MAAM,EAAE,UAAU;IAlBhC,OAAO,EAAG,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,QAAQ,CAAC;IACzB,SAAgB,aAAa,EAAE,QAAQ,CAAC;IACjC,MAAM,EAAG,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,CAAqB;IACrC,MAAM,EAAE,KAAK,EAAE,CAAM;IACrB,iBAAiB,EAAG,kBAAkB,CAAC;IACvC,OAAO,EA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,SAAS,EAAE;IAsCvC,8BAA8B,CAClC,YAAY,EAAE,QAAQ,GACrB,OAAO,CAAC,QAAQ,CAAC;IAgCd,gBAAgB,CAAC,2BAA2B,EAAE,QAAQ,GAAG,OAAO,CAAC;QACrE,cAAc,EAAE,QAAQ,CAAC;QACzB,aAAa,EAAE,QAAQ,CAAC;KACzB,CAAC;IAiCF,iBAAiB,CAAC,2BAA2B,EAAE,QAAQ,GAAG,OAAO;IAuBjE;;;;;;OAMG;IACG,GAAG,CACP,2BAA2B,EAAE,QAAQ,EACrC,IAAI,EAAE;QACJ,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;KACjC,GACA,OAAO,CAAC,SAAS,CAAC;IA+Bf,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCzB,OAAO,CACX,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,QAAQ,GACtB,OAAO,CAAC,WAAW,CAAC;IA2BV,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtC;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBnC;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAanC"}
|
|
@@ -91,6 +91,7 @@ export class oCoreNode {
|
|
|
91
91
|
}
|
|
92
92
|
async handleStaticAddressTranslation(addressInput) {
|
|
93
93
|
let result = addressInput;
|
|
94
|
+
this.logger.debug('Handling static address translation...', result.toString());
|
|
94
95
|
// handle static address translation
|
|
95
96
|
if (result.value.indexOf('o://leader') === -1) {
|
|
96
97
|
// TODO: we need to be more dynamic around the o://leader prefix
|
|
@@ -160,9 +161,13 @@ export class oCoreNode {
|
|
|
160
161
|
* @returns
|
|
161
162
|
*/
|
|
162
163
|
async use(addressWithLeaderTransports, data) {
|
|
164
|
+
if (!addressWithLeaderTransports.validate()) {
|
|
165
|
+
throw new Error('Invalid address');
|
|
166
|
+
}
|
|
163
167
|
const { nextHopAddress, targetAddress } = await this.translateAddress(addressWithLeaderTransports);
|
|
164
168
|
this.logger.debug('Using address, target: ', targetAddress.toString(), 'nextHop: ', nextHopAddress.toString());
|
|
165
169
|
const connection = await this.connect(nextHopAddress, targetAddress);
|
|
170
|
+
this.logger.debug('Connected to: ', targetAddress.toString(), ' sending data: ', data);
|
|
166
171
|
// communicate the payload to the target node
|
|
167
172
|
const response = await connection.send({
|
|
168
173
|
address: targetAddress?.toString() || '',
|
|
@@ -243,10 +248,6 @@ export class oCoreNode {
|
|
|
243
248
|
}
|
|
244
249
|
async teardown() {
|
|
245
250
|
this.logger.debug('Tearing down node...');
|
|
246
|
-
// TODO: improve this with a network listener from parent
|
|
247
|
-
await this.unregister().catch((error) => {
|
|
248
|
-
this.logger.warn('Failed to unregister node:', error.message);
|
|
249
|
-
});
|
|
250
251
|
if (this.p2pNode) {
|
|
251
252
|
await this.p2pNode.stop();
|
|
252
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAKZ,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAIL,QAAQ,EAER,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAKnC,8BAAsB,KAAM,SAAQ,SAAS;IACpC,eAAe,EAAG,eAAe,CAAC;IAClC,UAAU,EAAE,KAAK,EAAE,CAAM;IACzB,cAAc,EAAE,QAAQ,EAAE,CAAM;IAEvC,QAAQ,IAAI,IAAI;
|
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AC;IA2C9B,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpD,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAYtD,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAK/B,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAIlC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IA4ElC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B,uBAAuB,CAAC,KAAK,EAAE,GAAG;IAexC,IAAI,QAAQ,IAAI,OAAO,CAItB;IAEK,kBAAkB;IAgCxB,sBAAsB;IAIhB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAOhC"}
|
package/dist/src/node/node.js
CHANGED
|
@@ -20,6 +20,9 @@ export class oNode extends oCoreNode {
|
|
|
20
20
|
if (this.p2pNode && this.state !== NodeState.STOPPED) {
|
|
21
21
|
throw new Error('Node is not in a valid state to be initialized');
|
|
22
22
|
}
|
|
23
|
+
if (!this.address.validate()) {
|
|
24
|
+
throw new Error('Invalid address');
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
async _tool_handshake(handshake) {
|
|
25
28
|
this.logger.debug('Performing handshake with intent: ', handshake.params.intent);
|
|
@@ -61,6 +64,7 @@ export class oNode extends oCoreNode {
|
|
|
61
64
|
async _tool_route(request) {
|
|
62
65
|
const { payload } = request.params;
|
|
63
66
|
const { address } = request.params;
|
|
67
|
+
this.logger.debug('Routing request to: ', address, ' with payload: ', payload);
|
|
64
68
|
const destinationAddress = new oAddress(address);
|
|
65
69
|
// determine the next hop address from the encapsulated address
|
|
66
70
|
const nextHopAddress = await this.addressResolution.resolve(destinationAddress);
|
|
@@ -99,6 +103,9 @@ export class oNode extends oCoreNode {
|
|
|
99
103
|
if (!isAtDestination) {
|
|
100
104
|
forwardRequest = new oRequest(request);
|
|
101
105
|
}
|
|
106
|
+
else {
|
|
107
|
+
this.logger.debug('At destination!');
|
|
108
|
+
}
|
|
102
109
|
const pushableStream = pushable();
|
|
103
110
|
pushableStream.push(new TextEncoder().encode(forwardRequest.toString()));
|
|
104
111
|
pushableStream.end();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultLibp2pConfig } from '@olane/o-config';
|
|
2
2
|
import { oNode } from '../node/node.js';
|
|
3
3
|
export class oVirtualNode extends oNode {
|
|
4
4
|
/**
|
|
@@ -7,6 +7,6 @@ export class oVirtualNode extends oNode {
|
|
|
7
7
|
* @returns The transports for the virtual node
|
|
8
8
|
*/
|
|
9
9
|
configureTransports() {
|
|
10
|
-
return [
|
|
10
|
+
return [...(defaultLibp2pConfig.transports || [])];
|
|
11
11
|
}
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -35,8 +35,6 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@eslint/eslintrc": "^3.3.1",
|
|
37
37
|
"@eslint/js": "^9.29.0",
|
|
38
|
-
"@olane/o-config": "file:./packages/o-config",
|
|
39
|
-
"@olane/o-protocol": "file:./packages/o-protocol",
|
|
40
38
|
"@tsconfig/node20": "^20.1.6",
|
|
41
39
|
"@types/jest": "^30.0.0",
|
|
42
40
|
"@types/uuid": "^10.0.0",
|
|
@@ -56,8 +54,8 @@
|
|
|
56
54
|
"typescript": "^5.8.3"
|
|
57
55
|
},
|
|
58
56
|
"peerDependencies": {
|
|
59
|
-
"@olane/o-config": "^0.4.
|
|
60
|
-
"@olane/o-protocol": "^0.4.
|
|
57
|
+
"@olane/o-config": "^0.4.2",
|
|
58
|
+
"@olane/o-protocol": "^0.4.2"
|
|
61
59
|
},
|
|
62
60
|
"dependencies": {
|
|
63
61
|
"chalk": "^5.4.1",
|