@fxz26284407/yuanma-gateway 0.1.4 → 0.1.5
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/server.js +5 -2
- package/dist/version.js +2 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GATEWAY_VERSION } from './version.js';
|
|
1
2
|
import Database from 'better-sqlite3';
|
|
2
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
4
|
import { ProjectAccess } from './project-access.js';
|
|
@@ -173,7 +174,7 @@ export async function startGateway(options) {
|
|
|
173
174
|
}
|
|
174
175
|
await projectAccess.sync(true);
|
|
175
176
|
const supports = (key) => requireValue(current().backend.capabilities[key], 'UNSUPPORTED_COMMAND', 'Backend does not support ' + key, 400);
|
|
176
|
-
const backendStatus = () => ({ protocolVersion: 1, backendReady: current().backend.ready, backendKind: current().backend.kind, readOnly: current().backend.readOnly === true, uploadLimits, capabilities: { ...current().backend.capabilities, createThreads: !!current().backend.createThread }, availableBackends: [...contexts.keys()] });
|
|
177
|
+
const backendStatus = () => ({ gatewayVersion: GATEWAY_VERSION, protocolVersion: 1, backendReady: current().backend.ready, backendKind: current().backend.kind, readOnly: current().backend.readOnly === true, uploadLimits, capabilities: { ...current().backend.capabilities, createThreads: !!current().backend.createThread }, availableBackends: [...contexts.keys()] });
|
|
177
178
|
let stopping = false;
|
|
178
179
|
const pending = new Set();
|
|
179
180
|
const track = (p) => { pending.add(p); void p.finally(() => pending.delete(p)).catch(() => { }); return p; };
|
|
@@ -511,6 +512,8 @@ export async function startGateway(options) {
|
|
|
511
512
|
async function secureRequest(req, binding) {
|
|
512
513
|
const data = req.body ?? {};
|
|
513
514
|
const path = req.path;
|
|
515
|
+
if (req.method === 'GET' && path === '/v1/gateway-info')
|
|
516
|
+
return { gatewayVersion: GATEWAY_VERSION };
|
|
514
517
|
const value = (prefix) => req.authorization?.startsWith(prefix) ? req.authorization.slice(prefix.length) : '';
|
|
515
518
|
if (req.method === 'POST' && path === '/v1/pairings/claim')
|
|
516
519
|
return auth.claim(data, binding);
|
|
@@ -687,7 +690,7 @@ export async function startGateway(options) {
|
|
|
687
690
|
if (req.method === 'POST' && url.pathname === '/local/pairings/open') {
|
|
688
691
|
await projectAccess.sync(true);
|
|
689
692
|
const b = await body(req);
|
|
690
|
-
send(res, 200, { requestId, data: { ...auth.openPairing(b.grants), publicKey: identity.publicKey.toString('base64url'), profile: NOISE_PROFILE, relayUrl: options.relayUrl ?? null } });
|
|
693
|
+
send(res, 200, { requestId, data: { ...auth.openPairing(b.grants), publicKey: identity.publicKey.toString('base64url'), profile: NOISE_PROFILE, gatewayVersion: GATEWAY_VERSION, relayUrl: options.relayUrl ?? null } });
|
|
691
694
|
return;
|
|
692
695
|
}
|
|
693
696
|
if (req.method === 'GET' && url.pathname === '/local/pairings') {
|
package/dist/version.js
ADDED