@xyo-network/bridge-http-express 3.14.0
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/LICENSE +165 -0
- package/README.md +13 -0
- package/dist/neutral/index.mjs +191 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/types/HttpBridge.d.ts +45 -0
- package/dist/types/HttpBridge.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +78 -0
- package/src/HttpBridge.ts +237 -0
- package/src/index.ts +1 -0
- package/src/spec/HttpBridge.baddns.spec.ts +42 -0
- package/src/spec/HttpBridge.copilot.spec.ts +61 -0
- package/src/spec/HttpBridge.host-resolve.spec.ts +86 -0
- package/src/spec/HttpBridge.host.spec.ts +156 -0
- package/src/spec/HttpBridge.legacy.spec.ts +55 -0
- package/src/spec/HttpBridge.spec.ts +202 -0
- package/src/spec/HttpBridge.tests.spec.ts +86 -0
- package/src/spec/HttpBridge.xns.spec.ts +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[![logo][]](https://xyo.network)
|
|
2
|
+
|
|
3
|
+
Part of [sdk-xyo-client-js](https://www.npmjs.com/package/@xyo-network/sdk-xyo-client-js)
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
> See the [LICENSE](LICENSE) file for license details
|
|
8
|
+
|
|
9
|
+
## Credits
|
|
10
|
+
|
|
11
|
+
[Made with 🔥 and ❄️ by XYO](https://xyo.network)
|
|
12
|
+
|
|
13
|
+
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __reflectGet = Reflect.get;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
16
|
+
|
|
17
|
+
// src/HttpBridge.ts
|
|
18
|
+
import { assertEx } from "@xylabs/assert";
|
|
19
|
+
import { exists } from "@xylabs/exists";
|
|
20
|
+
import {
|
|
21
|
+
asyncHandler,
|
|
22
|
+
customPoweredByHeader,
|
|
23
|
+
disableCaseSensitiveRouting,
|
|
24
|
+
disableExpressDefaultPoweredByHeader,
|
|
25
|
+
jsonBodyParser,
|
|
26
|
+
responseProfiler,
|
|
27
|
+
useRequestCounters
|
|
28
|
+
} from "@xylabs/express";
|
|
29
|
+
import { toJsonString } from "@xylabs/object";
|
|
30
|
+
import { isQueryBoundWitness } from "@xyo-network/boundwitness-model";
|
|
31
|
+
import { HttpBridge } from "@xyo-network/bridge-http";
|
|
32
|
+
import {
|
|
33
|
+
creatableModule,
|
|
34
|
+
resolveAddressToInstanceUp
|
|
35
|
+
} from "@xyo-network/module-model";
|
|
36
|
+
import express from "express";
|
|
37
|
+
import { StatusCodes } from "http-status-codes";
|
|
38
|
+
var HttpBridgeExpressConfigSchema = "network.xyo.bridge.http.express.config";
|
|
39
|
+
var HttpBridgeExpress = class extends HttpBridge {
|
|
40
|
+
_app;
|
|
41
|
+
_exposedModules = [];
|
|
42
|
+
_server;
|
|
43
|
+
get app() {
|
|
44
|
+
if (!this._app) this._app = this.initializeApp();
|
|
45
|
+
return assertEx(this._app, () => "App not initialized");
|
|
46
|
+
}
|
|
47
|
+
async exposeChild(mod, options) {
|
|
48
|
+
const { maxDepth = 5 } = options ?? {};
|
|
49
|
+
assertEx(this.config.host, () => "Not configured as a host");
|
|
50
|
+
this._exposedModules.push(new WeakRef(mod));
|
|
51
|
+
const children = maxDepth > 0 ? await mod.publicChildren?.() ?? [] : [];
|
|
52
|
+
this.logger.log(`childrenToExpose [${mod.id}][${mod.address}]: ${toJsonString(children.map((child) => child.id))}`);
|
|
53
|
+
const exposedChildren = (await Promise.all(children.map((child) => this.exposeChild(child, { maxDepth: maxDepth - 1, required: false })))).flat().filter(exists);
|
|
54
|
+
const allExposed = [mod, ...exposedChildren];
|
|
55
|
+
for (const exposedMod of allExposed) this.logger?.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
56
|
+
return allExposed;
|
|
57
|
+
}
|
|
58
|
+
async exposeHandler(address, options) {
|
|
59
|
+
const { required = true } = options ?? {};
|
|
60
|
+
const mod = await resolveAddressToInstanceUp(this, address);
|
|
61
|
+
if (required && !mod) {
|
|
62
|
+
throw new Error(`Unable to find required module: ${address}`);
|
|
63
|
+
}
|
|
64
|
+
if (mod) {
|
|
65
|
+
return this.exposeChild(mod, options);
|
|
66
|
+
}
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
exposedHandler() {
|
|
70
|
+
return this._exposedModules.map((ref) => ref.deref()?.address).filter(exists);
|
|
71
|
+
}
|
|
72
|
+
async startHandler() {
|
|
73
|
+
return await super.startHandler() && await this.startHttpServer();
|
|
74
|
+
}
|
|
75
|
+
async stopHandler(_timeout) {
|
|
76
|
+
return await super.stopHandler() && await this.stopHttpServer();
|
|
77
|
+
}
|
|
78
|
+
async unexposeHandler(address, options) {
|
|
79
|
+
const { maxDepth = 2, required = true } = options ?? {};
|
|
80
|
+
assertEx(this.config.host, () => "Not configured as a host");
|
|
81
|
+
const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref();
|
|
82
|
+
assertEx(!required || mod, () => `Module not exposed: ${address}`);
|
|
83
|
+
this._exposedModules = this._exposedModules.filter((ref) => ref.deref()?.address !== address);
|
|
84
|
+
if (mod) {
|
|
85
|
+
const children = maxDepth > 0 ? await mod.publicChildren?.() ?? [] : [];
|
|
86
|
+
const exposedChildren = (await Promise.all(children.map((child) => this.unexposeHandler(child.address, { maxDepth: maxDepth - 1, required: false })))).flat().filter(exists);
|
|
87
|
+
return [mod, ...exposedChildren];
|
|
88
|
+
}
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
async callLocalModule(address, query, payloads) {
|
|
92
|
+
const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref();
|
|
93
|
+
return mod ? await mod.query(query, payloads) : null;
|
|
94
|
+
}
|
|
95
|
+
async handleGet(req, res) {
|
|
96
|
+
const { address } = req.params;
|
|
97
|
+
try {
|
|
98
|
+
if (address == this.address) {
|
|
99
|
+
res.json(await this.stateQuery(this.account));
|
|
100
|
+
} else {
|
|
101
|
+
const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref();
|
|
102
|
+
if (mod) {
|
|
103
|
+
res.json(await mod.stateQuery(this.account));
|
|
104
|
+
} else {
|
|
105
|
+
res.status(StatusCodes.NOT_FOUND).json({ error: "Module not found" });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch (ex) {
|
|
109
|
+
res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ error: ex.message });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async handlePost(req, res) {
|
|
113
|
+
const { address } = req.params;
|
|
114
|
+
const [bw, payloads = []] = Array.isArray(req.body) ? req.body : [];
|
|
115
|
+
const query = isQueryBoundWitness(bw) ? bw : void 0;
|
|
116
|
+
if (!query) {
|
|
117
|
+
res.status(StatusCodes.BAD_REQUEST).json({ error: "No query provided" });
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
if (address == this.address) {
|
|
122
|
+
const result = await this.query(query, payloads);
|
|
123
|
+
return res.json(result);
|
|
124
|
+
} else {
|
|
125
|
+
const result = await this.callLocalModule(address, query, payloads);
|
|
126
|
+
if (result === null) {
|
|
127
|
+
res.status(StatusCodes.NOT_FOUND).json({ error: "Module not found" });
|
|
128
|
+
} else {
|
|
129
|
+
res.json(result);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch (ex) {
|
|
133
|
+
res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ error: ex.message });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
initializeApp() {
|
|
137
|
+
const app = express();
|
|
138
|
+
app.use(responseProfiler);
|
|
139
|
+
app.use(jsonBodyParser);
|
|
140
|
+
disableExpressDefaultPoweredByHeader(app);
|
|
141
|
+
app.use(customPoweredByHeader);
|
|
142
|
+
disableCaseSensitiveRouting(app);
|
|
143
|
+
useRequestCounters(app);
|
|
144
|
+
app.get("/", (_req, res) => res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${this.address}`));
|
|
145
|
+
app.post("/", (_req, res) => res.redirect(StatusCodes.TEMPORARY_REDIRECT, `/${this.address}`));
|
|
146
|
+
app.get(
|
|
147
|
+
"/:address",
|
|
148
|
+
asyncHandler(async (req, res) => await this.handleGet(req, res))
|
|
149
|
+
);
|
|
150
|
+
app.post(
|
|
151
|
+
"/:address",
|
|
152
|
+
asyncHandler(async (req, res) => {
|
|
153
|
+
await this.handlePost(req, res);
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
return app;
|
|
157
|
+
}
|
|
158
|
+
startHttpServer() {
|
|
159
|
+
if (this.config.host) {
|
|
160
|
+
assertEx(!this._server, () => "Server already started");
|
|
161
|
+
this._server = this.app.listen(this.config.host?.port ?? 3030);
|
|
162
|
+
}
|
|
163
|
+
return Promise.resolve(true);
|
|
164
|
+
}
|
|
165
|
+
stopHttpServer() {
|
|
166
|
+
if (this.config.host) {
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
if (this._server) {
|
|
169
|
+
this._server.close((err) => {
|
|
170
|
+
if (err) {
|
|
171
|
+
reject(err);
|
|
172
|
+
} else {
|
|
173
|
+
this._server = void 0;
|
|
174
|
+
resolve(true);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return Promise.resolve(true);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
__publicField(HttpBridgeExpress, "configSchemas", [...__superGet(HttpBridgeExpress, HttpBridgeExpress, "configSchemas"), HttpBridgeExpressConfigSchema]);
|
|
184
|
+
HttpBridgeExpress = __decorateClass([
|
|
185
|
+
creatableModule()
|
|
186
|
+
], HttpBridgeExpress);
|
|
187
|
+
export {
|
|
188
|
+
HttpBridgeExpress,
|
|
189
|
+
HttpBridgeExpressConfigSchema
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/HttpBridge.ts"],"sourcesContent":["import { Server } from 'node:http'\n\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport {\n asyncHandler,\n customPoweredByHeader,\n disableCaseSensitiveRouting,\n disableExpressDefaultPoweredByHeader,\n jsonBodyParser,\n responseProfiler,\n useRequestCounters,\n} from '@xylabs/express'\nimport { Address } from '@xylabs/hex'\nimport { toJsonString } from '@xylabs/object'\nimport { isQueryBoundWitness, QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { HttpBridge, HttpBridgeConfig } from '@xyo-network/bridge-http'\nimport {\n BridgeExposeOptions, BridgeParams, BridgeUnexposeOptions,\n} from '@xyo-network/bridge-model'\n// import { standardResponses } from '@xyo-network/express-node-middleware'\nimport {\n AnyConfigSchema, creatableModule, ModuleInstance, ModuleQueryResult, resolveAddressToInstanceUp,\n} from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport express, {\n Application, Request, Response,\n} from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\n/**\n * The type of the path parameters for the address path.\n */\ntype AddressPathParams = {\n address: Address\n}\n\n/**\n * The type of the request body for the address path.\n */\ntype PostAddressRequestBody = [QueryBoundWitness, undefined | Payload[]]\n\n// TODO: This does not match the error response shape of the legacy bridge BUT it its the\n// shape this bridge is currently returning. Massage this into the standard\n// error shape constructed via middleware.\n/* type ErrorResponseBody = {\n error: string\n} */\n\nexport const HttpBridgeExpressConfigSchema = 'network.xyo.bridge.http.express.config' as const\nexport type HttpBridgeExpressConfigSchema = typeof HttpBridgeExpressConfigSchema\n\nexport interface HttpBridgeExpressConfig extends HttpBridgeConfig<{}, HttpBridgeExpressConfigSchema> {}\n\nexport interface HttpBridgeExpressParams extends BridgeParams<AnyConfigSchema<HttpBridgeExpressConfig>> {}\n\n@creatableModule()\nexport class HttpBridgeExpress<TParams extends HttpBridgeExpressParams> extends HttpBridge<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, HttpBridgeExpressConfigSchema]\n protected _app?: Application\n protected _exposedModules: WeakRef<ModuleInstance>[] = []\n protected _server?: Server\n\n protected get app() {\n if (!this._app) this._app = this.initializeApp()\n return assertEx(this._app, () => 'App not initialized')\n }\n\n async exposeChild(mod: ModuleInstance, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {\n const { maxDepth = 5 } = options ?? {}\n assertEx(this.config.host, () => 'Not configured as a host')\n this._exposedModules.push(new WeakRef(mod))\n const children = maxDepth > 0 ? ((await mod.publicChildren?.()) ?? []) : []\n this.logger.log(`childrenToExpose [${mod.id}][${mod.address}]: ${toJsonString(children.map(child => child.id))}`)\n const exposedChildren = (await Promise.all(children.map(child => this.exposeChild(child, { maxDepth: maxDepth - 1, required: false }))))\n .flat()\n .filter(exists)\n const allExposed = [mod, ...exposedChildren]\n\n for (const exposedMod of allExposed) this.logger?.log(`exposed: ${exposedMod.address} [${mod.id}]`)\n\n return allExposed\n }\n\n override async exposeHandler(address: Address, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {\n const { required = true } = options ?? {}\n const mod = await resolveAddressToInstanceUp(this, address)\n if (required && !mod) {\n throw new Error(`Unable to find required module: ${address}`)\n }\n if (mod) {\n return this.exposeChild(mod, options)\n }\n return []\n }\n\n override exposedHandler(): Address[] {\n return this._exposedModules.map(ref => ref.deref()?.address).filter(exists)\n }\n\n override async startHandler(): Promise<boolean> {\n return (await super.startHandler()) && (await this.startHttpServer())\n }\n\n override async stopHandler(_timeout?: number | undefined): Promise<boolean> {\n return (await super.stopHandler()) && (await this.stopHttpServer())\n }\n\n override async unexposeHandler(address: Address, options?: BridgeUnexposeOptions | undefined): Promise<ModuleInstance[]> {\n const { maxDepth = 2, required = true } = options ?? {}\n assertEx(this.config.host, () => 'Not configured as a host')\n const mod = this._exposedModules.find(ref => ref.deref()?.address === address)?.deref()\n assertEx(!required || mod, () => `Module not exposed: ${address}`)\n this._exposedModules = this._exposedModules.filter(ref => ref.deref()?.address !== address)\n if (mod) {\n const children = maxDepth > 0 ? ((await mod.publicChildren?.()) ?? []) : []\n const exposedChildren = (\n await Promise.all(children.map(child => this.unexposeHandler(child.address, { maxDepth: maxDepth - 1, required: false })))\n )\n .flat()\n .filter(exists)\n return [mod, ...exposedChildren]\n }\n return []\n }\n\n protected async callLocalModule(address: Address, query: QueryBoundWitness, payloads: Payload[]): Promise<ModuleQueryResult | null> {\n const mod = this._exposedModules.find(ref => ref.deref()?.address === address)?.deref()\n return mod ? await mod.query(query, payloads) : null\n }\n\n protected async handleGet(req: Request<AddressPathParams, ModuleQueryResult, PostAddressRequestBody>, res: Response) {\n const { address } = req.params\n try {\n if (address == this.address) {\n res.json(await this.stateQuery(this.account))\n } else {\n const mod = this._exposedModules.find(ref => ref.deref()?.address === address)?.deref()\n // TODO: Use standard errors middleware\n if (mod) {\n res.json(await mod.stateQuery(this.account))\n } else {\n res.status(StatusCodes.NOT_FOUND).json({ error: 'Module not found' })\n }\n }\n } catch (ex) {\n // TODO: Sanitize message\n res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ error: (ex as Error).message })\n }\n }\n\n protected async handlePost(req: Request<AddressPathParams, ModuleQueryResult, PostAddressRequestBody>, res: Response) {\n const { address } = req.params\n const [bw, payloads = []] = Array.isArray(req.body) ? req.body : []\n const query = isQueryBoundWitness(bw) ? bw : undefined\n if (!query) {\n // TODO: Use standard errors middleware\n res.status(StatusCodes.BAD_REQUEST).json({ error: 'No query provided' })\n return\n }\n try {\n if (address == this.address) {\n const result = await this.query(query, payloads)\n return res.json(result)\n } else {\n const result = await this.callLocalModule(address, query, payloads)\n // TODO: Use standard errors middleware\n if (result === null) {\n res.status(StatusCodes.NOT_FOUND).json({ error: 'Module not found' })\n } else {\n res.json(result)\n }\n }\n } catch (ex) {\n // TODO: Sanitize message\n res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ error: (ex as Error).message })\n }\n }\n\n protected initializeApp() {\n // Create the express app\n const app = express()\n\n // Add middleware\n app.use(responseProfiler)\n app.use(jsonBodyParser)\n // removed for now since this causes a cycle\n // app.use(standardResponses)\n disableExpressDefaultPoweredByHeader(app)\n app.use(customPoweredByHeader)\n disableCaseSensitiveRouting(app)\n useRequestCounters(app)\n\n // Add routes\n // Redirect all requests to the root to this module's address\n app.get('/', (_req, res) => res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${this.address}`))\n app.post('/', (_req, res) => res.redirect(StatusCodes.TEMPORARY_REDIRECT, `/${this.address}`))\n\n app.get<AddressPathParams, ModuleQueryResult>(\n '/:address',\n\n asyncHandler(async (req, res) => await this.handleGet(req, res)),\n )\n app.post<AddressPathParams, ModuleQueryResult, PostAddressRequestBody>(\n '/:address',\n\n asyncHandler(async (req, res) => { await this.handlePost(req, res) }),\n )\n return app\n }\n\n protected startHttpServer(): Promise<boolean> {\n if (this.config.host) {\n assertEx(!this._server, () => 'Server already started')\n this._server = this.app.listen(this.config.host?.port ?? 3030)\n }\n return Promise.resolve(true)\n }\n\n protected stopHttpServer(): Promise<boolean> {\n if (this.config.host) {\n return new Promise((resolve, reject) => {\n if (this._server) {\n this._server.close((err) => {\n if (err) {\n reject(err)\n } else {\n this._server = undefined\n resol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AAS,MAAM,wBAAwB;AACtD,WAAK,UAAU,KAAK,IAAI,OAAO,KAAK,OAAO,MAAM,QAAQ,IAAI;AAAA,IAC/D;AACA,WAAO,QAAQ,QAAQ,IAAI;AAAA,EAC7B;AAAA,EAEU,iBAAmC;AAC3C,QAAI,KAAK,OAAO,MAAM;AACpB,aAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,YAAI,KAAK,SAAS;AAChB,eAAK,QAAQ,MAAM,CAAC,QAAQ;AAC1B,gBAAI,KAAK;AACP,qBAAO,GAAG;AAAA,YACZ,OAAO;AACL,mBAAK,UAAU;AACf,sBAAQ,IAAI;AAAA,YACd;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO,QAAQ,QAAQ,IAAI;AAAA,EAC7B;AACF;AAlLE,cADW,mBACc,iBAA0B,CAAC,GAAG,iDAAM,kBAAe,6BAA6B;AAD9F,oBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Server } from 'node:http';
|
|
2
|
+
import { Address } from '@xylabs/hex';
|
|
3
|
+
import { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
4
|
+
import { HttpBridge, HttpBridgeConfig } from '@xyo-network/bridge-http';
|
|
5
|
+
import { BridgeExposeOptions, BridgeParams, BridgeUnexposeOptions } from '@xyo-network/bridge-model';
|
|
6
|
+
import { AnyConfigSchema, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
7
|
+
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
8
|
+
import express, { Application, Request, Response } from 'express';
|
|
9
|
+
/**
|
|
10
|
+
* The type of the path parameters for the address path.
|
|
11
|
+
*/
|
|
12
|
+
type AddressPathParams = {
|
|
13
|
+
address: Address;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The type of the request body for the address path.
|
|
17
|
+
*/
|
|
18
|
+
type PostAddressRequestBody = [QueryBoundWitness, undefined | Payload[]];
|
|
19
|
+
export declare const HttpBridgeExpressConfigSchema: "network.xyo.bridge.http.express.config";
|
|
20
|
+
export type HttpBridgeExpressConfigSchema = typeof HttpBridgeExpressConfigSchema;
|
|
21
|
+
export interface HttpBridgeExpressConfig extends HttpBridgeConfig<{}, HttpBridgeExpressConfigSchema> {
|
|
22
|
+
}
|
|
23
|
+
export interface HttpBridgeExpressParams extends BridgeParams<AnyConfigSchema<HttpBridgeExpressConfig>> {
|
|
24
|
+
}
|
|
25
|
+
export declare class HttpBridgeExpress<TParams extends HttpBridgeExpressParams> extends HttpBridge<TParams> {
|
|
26
|
+
static readonly configSchemas: Schema[];
|
|
27
|
+
protected _app?: Application;
|
|
28
|
+
protected _exposedModules: WeakRef<ModuleInstance>[];
|
|
29
|
+
protected _server?: Server;
|
|
30
|
+
protected get app(): express.Application;
|
|
31
|
+
exposeChild(mod: ModuleInstance, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]>;
|
|
32
|
+
exposeHandler(address: Address, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]>;
|
|
33
|
+
exposedHandler(): Address[];
|
|
34
|
+
startHandler(): Promise<boolean>;
|
|
35
|
+
stopHandler(_timeout?: number | undefined): Promise<boolean>;
|
|
36
|
+
unexposeHandler(address: Address, options?: BridgeUnexposeOptions | undefined): Promise<ModuleInstance[]>;
|
|
37
|
+
protected callLocalModule(address: Address, query: QueryBoundWitness, payloads: Payload[]): Promise<ModuleQueryResult | null>;
|
|
38
|
+
protected handleGet(req: Request<AddressPathParams, ModuleQueryResult, PostAddressRequestBody>, res: Response): Promise<void>;
|
|
39
|
+
protected handlePost(req: Request<AddressPathParams, ModuleQueryResult, PostAddressRequestBody>, res: Response): Promise<express.Response<any, Record<string, any>> | undefined>;
|
|
40
|
+
protected initializeApp(): import(".store/@types-express-serve-static-core-npm-5.0.6-e41caf262c/package").Express;
|
|
41
|
+
protected startHttpServer(): Promise<boolean>;
|
|
42
|
+
protected stopHttpServer(): Promise<boolean>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=HttpBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpBridge.d.ts","sourceRoot":"","sources":["../../src/HttpBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAalC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAuB,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxF,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EACL,mBAAmB,EAAE,YAAY,EAAE,qBAAqB,EACzD,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,eAAe,EAAmB,cAAc,EAAE,iBAAiB,EACpE,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,OAAO,EAAE,EACd,WAAW,EAAE,OAAO,EAAE,QAAQ,EAC/B,MAAM,SAAS,CAAA;AAGhB;;GAEG;AACH,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,KAAK,sBAAsB,GAAG,CAAC,iBAAiB,EAAE,SAAS,GAAG,OAAO,EAAE,CAAC,CAAA;AASxE,eAAO,MAAM,6BAA6B,EAAG,wCAAiD,CAAA;AAC9F,MAAM,MAAM,6BAA6B,GAAG,OAAO,6BAA6B,CAAA;AAEhF,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB,CAAC,EAAE,EAAE,6BAA6B,CAAC;CAAG;AAEvG,MAAM,WAAW,uBAAwB,SAAQ,YAAY,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;CAAG;AAE1G,qBACa,iBAAiB,CAAC,OAAO,SAAS,uBAAuB,CAAE,SAAQ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C;IAQ7C,SAAS,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAiB7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyo-network/bridge-http-express",
|
|
3
|
+
"version": "3.14.0",
|
|
4
|
+
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
|
+
"homepage": "https://xyo.network",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues",
|
|
8
|
+
"email": "support@xyo.network"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "LGPL-3.0-only",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "XYO Development Team",
|
|
17
|
+
"email": "support@xyo.network",
|
|
18
|
+
"url": "https://xyo.network"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"default": "./dist/neutral/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"module": "dist/neutral/index.mjs",
|
|
30
|
+
"types": "dist/types/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"package.json"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@xylabs/assert": "^4.8.7",
|
|
40
|
+
"@xylabs/exists": "^4.8.7",
|
|
41
|
+
"@xylabs/hex": "^4.8.7",
|
|
42
|
+
"@xylabs/object": "^4.8.7",
|
|
43
|
+
"@xyo-network/account": "^3.14.0",
|
|
44
|
+
"@xyo-network/api-models": "^3.14.0",
|
|
45
|
+
"@xyo-network/boundwitness-model": "^3.14.0",
|
|
46
|
+
"@xyo-network/bridge-abstract": "^3.14.0",
|
|
47
|
+
"@xyo-network/bridge-http": "^3.14.0",
|
|
48
|
+
"@xyo-network/bridge-model": "^3.14.0",
|
|
49
|
+
"@xyo-network/module-model": "^3.14.0",
|
|
50
|
+
"@xyo-network/node-model": "^3.14.0",
|
|
51
|
+
"@xyo-network/payload-model": "^3.14.0",
|
|
52
|
+
"express": "^5.1.0",
|
|
53
|
+
"http-status-codes": "^2.3.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/express": "^5.0.1",
|
|
57
|
+
"@types/node": "^22.15.2",
|
|
58
|
+
"@xylabs/express": "^4.8.7",
|
|
59
|
+
"@xylabs/ts-scripts-yarn3": "^6.3.5",
|
|
60
|
+
"@xylabs/tsconfig": "^6.3.5",
|
|
61
|
+
"@xylabs/vitest-extended": "^4.8.7",
|
|
62
|
+
"@xyo-network/account": "^3.14.0",
|
|
63
|
+
"@xyo-network/archivist-model": "^3.14.0",
|
|
64
|
+
"@xyo-network/bridge-abstract": "^3.14.0",
|
|
65
|
+
"@xyo-network/diviner-model": "^3.14.0",
|
|
66
|
+
"@xyo-network/module-resolver": "^3.14.0",
|
|
67
|
+
"@xyo-network/node-memory": "^3.14.0",
|
|
68
|
+
"@xyo-network/node-model": "^3.14.0",
|
|
69
|
+
"@xyo-network/payload-builder": "^3.14.0",
|
|
70
|
+
"@xyo-network/payload-wrapper": "^3.14.0",
|
|
71
|
+
"get-port-please": "^3.1.2",
|
|
72
|
+
"typescript": "^5.8.3",
|
|
73
|
+
"vitest": "^3.1.2"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
}
|
|
78
|
+
}
|