@olane/o-gateway-olane 0.8.2 → 0.8.4
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/README.md +83 -8
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,12 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @olane/o-gateway-olane
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reference implementation of the Olane gateway. Resolves addresses in the `olane` namespace and routes requests through the Olane leader node.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
An Olane gateway is a registry tool. These registries help prevent conflicting namespaces, bridge into walled gardens, broker communication, and much more.
|
|
5
|
+
## Installation
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @olane/o-gateway-olane
|
|
9
|
+
```
|
|
9
10
|
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
The `oGatewayResolver` handles address resolution for the Olane network. When a request arrives, it checks whether the address should be routed through the Olane gateway by examining two conditions:
|
|
14
|
+
|
|
15
|
+
1. **Path-based**: The address path starts with `olane` (e.g., `o://olane/some-tool`)
|
|
16
|
+
2. **Transport-based**: The target address includes the `/olane` custom transport
|
|
17
|
+
|
|
18
|
+
If either condition is met, the resolver routes the request to the Olane leader node at:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
/dns4/leader.olane.com/tcp/3000/tls
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Otherwise, the request is passed through unchanged.
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
### `oGatewayResolver`
|
|
29
|
+
|
|
30
|
+
Extends `oAddressResolver` from `@olane/o-core`.
|
|
31
|
+
|
|
32
|
+
#### Constructor
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const resolver = new oGatewayResolver(address: oAddress);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| Parameter | Type | Description |
|
|
39
|
+
|-----------|------|-------------|
|
|
40
|
+
| `address` | `oAddress` | The address of the resolver node itself |
|
|
41
|
+
|
|
42
|
+
#### `resolve(request: ResolveRequest): Promise<RouteResponse>`
|
|
43
|
+
|
|
44
|
+
Resolves an incoming request to a route response. The `ResolveRequest` contains:
|
|
45
|
+
|
|
46
|
+
- `address` - The address being resolved
|
|
47
|
+
- `node` - The local node handling the request
|
|
48
|
+
- `request` - The original request payload
|
|
49
|
+
- `targetAddress` - The full target address with transport information
|
|
50
|
+
|
|
51
|
+
Returns a `RouteResponse` with `nextHopAddress`, `targetAddress`, and `requestOverride`.
|
|
52
|
+
|
|
53
|
+
#### `customTransports` (getter)
|
|
54
|
+
|
|
55
|
+
Returns `[new oCustomTransport('/olane')]`, declaring that this resolver handles the `/olane` transport.
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { oGatewayResolver } from '@olane/o-gateway-olane';
|
|
61
|
+
import { oAddress } from '@olane/o-core';
|
|
62
|
+
|
|
63
|
+
const resolver = new oGatewayResolver(myNodeAddress);
|
|
64
|
+
|
|
65
|
+
const route = await resolver.resolve({
|
|
66
|
+
address: targetAddress,
|
|
67
|
+
node: localNode,
|
|
68
|
+
request: incomingRequest,
|
|
69
|
+
targetAddress: fullTargetAddress,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// route.nextHopAddress will point to leader.olane.com for olane-bound requests
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Relationship to `@olane/o-gateway-interface`
|
|
76
|
+
|
|
77
|
+
This package is the reference implementation of the gateway concept defined by [`@olane/o-gateway-interface`](https://www.npmjs.com/package/@olane/o-gateway-interface). While `o-gateway-interface` defines the `oGateway` contract (name, transports, description, logo, website), this package provides the actual address resolution logic for the Olane network.
|
|
78
|
+
|
|
79
|
+
## Related Packages
|
|
80
|
+
|
|
81
|
+
- **@olane/o-gateway-interface** - Interface definition that gateways implement
|
|
82
|
+
- **@olane/o-core** - Core types including `oAddress`, `oAddressResolver`, `oCustomTransport`
|
|
83
|
+
- **@olane/o-node** - Node types including `oNodeTransport` used for leader routing
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
(MIT OR Apache-2.0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-gateway-olane",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"typescript": "5.4.5"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@olane/o-config": "0.8.
|
|
55
|
-
"@olane/o-core": "0.8.
|
|
56
|
-
"@olane/o-node": "0.8.
|
|
57
|
-
"@olane/o-protocol": "0.8.
|
|
58
|
-
"@olane/o-tool": "0.8.
|
|
54
|
+
"@olane/o-config": "0.8.4",
|
|
55
|
+
"@olane/o-core": "0.8.4",
|
|
56
|
+
"@olane/o-node": "0.8.4",
|
|
57
|
+
"@olane/o-protocol": "0.8.4",
|
|
58
|
+
"@olane/o-tool": "0.8.4",
|
|
59
59
|
"debug": "^4.4.1",
|
|
60
60
|
"dotenv": "^16.5.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "b53623b1ad4365133911722f80d5597a72b65bf2"
|
|
63
63
|
}
|