@vhyxvoid/protocol 1.0.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/dist/canonical.d.ts +28 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +63 -0
- package/dist/canonical.js.map +1 -0
- package/dist/constants.d.ts +40 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +46 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +146 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +8 -0
- package/dist/messages.js.map +1 -0
- package/dist/serializer.d.ts +14 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +53 -0
- package/dist/serializer.js.map +1 -0
- package/package.json +20 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface CanonicalParams {
|
|
2
|
+
method: string;
|
|
3
|
+
path: string;
|
|
4
|
+
query: string;
|
|
5
|
+
body: string;
|
|
6
|
+
requestId: string;
|
|
7
|
+
ts: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Build the canonical string that both sides sign/verify.
|
|
11
|
+
* Format: METHOD|PATH|QUERY|BODY_SHA256|REQUEST_ID|TIMESTAMP_MS
|
|
12
|
+
*
|
|
13
|
+
* All fields are always present (empty string if absent).
|
|
14
|
+
* Order is fixed — SDK and Hub must agree exactly.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildCanonical(params: CanonicalParams): string;
|
|
17
|
+
/**
|
|
18
|
+
* Sign a canonical string with HMAC-SHA256.
|
|
19
|
+
* secretHash = HMAC-SHA256(rawSecret, SERVER_HMAC_PEPPER) — stored in DB.
|
|
20
|
+
* Agent signs using the same secretHash.
|
|
21
|
+
*/
|
|
22
|
+
export declare function signCanonical(canonical: string, secretHash: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Timing-safe HMAC verification.
|
|
25
|
+
* Returns false if lengths differ (prevents length-extension attacks).
|
|
26
|
+
*/
|
|
27
|
+
export declare function verifyCanonical(canonical: string, signature: string, secretHash: string): boolean;
|
|
28
|
+
//# sourceMappingURL=canonical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAa9D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK3E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAUT"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// packages/protocol/src/canonical.ts
|
|
4
|
+
// Canonical string builder — identical in Hub (verify) and SDK (sign).
|
|
5
|
+
// Query string is included to prevent query-parameter injection attacks.
|
|
6
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.buildCanonical = buildCanonical;
|
|
12
|
+
exports.signCanonical = signCanonical;
|
|
13
|
+
exports.verifyCanonical = verifyCanonical;
|
|
14
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
15
|
+
/**
|
|
16
|
+
* Build the canonical string that both sides sign/verify.
|
|
17
|
+
* Format: METHOD|PATH|QUERY|BODY_SHA256|REQUEST_ID|TIMESTAMP_MS
|
|
18
|
+
*
|
|
19
|
+
* All fields are always present (empty string if absent).
|
|
20
|
+
* Order is fixed — SDK and Hub must agree exactly.
|
|
21
|
+
*/
|
|
22
|
+
function buildCanonical(params) {
|
|
23
|
+
const bodyHash = params.body
|
|
24
|
+
? crypto_1.default.createHash("sha256").update(params.body, "utf8").digest("hex")
|
|
25
|
+
: "";
|
|
26
|
+
return [
|
|
27
|
+
params.method.toUpperCase(),
|
|
28
|
+
params.path,
|
|
29
|
+
params.query,
|
|
30
|
+
bodyHash,
|
|
31
|
+
params.requestId,
|
|
32
|
+
params.ts.toString(),
|
|
33
|
+
].join("|");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sign a canonical string with HMAC-SHA256.
|
|
37
|
+
* secretHash = HMAC-SHA256(rawSecret, SERVER_HMAC_PEPPER) — stored in DB.
|
|
38
|
+
* Agent signs using the same secretHash.
|
|
39
|
+
*/
|
|
40
|
+
function signCanonical(canonical, secretHash) {
|
|
41
|
+
return crypto_1.default
|
|
42
|
+
.createHmac("sha256", secretHash)
|
|
43
|
+
.update(canonical)
|
|
44
|
+
.digest("hex");
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Timing-safe HMAC verification.
|
|
48
|
+
* Returns false if lengths differ (prevents length-extension attacks).
|
|
49
|
+
*/
|
|
50
|
+
function verifyCanonical(canonical, signature, secretHash) {
|
|
51
|
+
try {
|
|
52
|
+
const expected = signCanonical(canonical, secretHash);
|
|
53
|
+
const a = Buffer.from(expected, "hex");
|
|
54
|
+
const b = Buffer.from(signature, "hex");
|
|
55
|
+
if (a.length !== b.length)
|
|
56
|
+
return false;
|
|
57
|
+
return crypto_1.default.timingSafeEqual(a, b);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=canonical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.js","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,qCAAqC;AACrC,uEAAuE;AACvE,yEAAyE;AACzE,gFAAgF;;;;;AAoBhF,wCAaC;AAOD,sCAKC;AAMD,0CAcC;AA/DD,oDAA4B;AAW5B;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,MAAuB;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI;QAC1B,CAAC,CAAC,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACvE,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;QAC3B,MAAM,CAAC,IAAI;QACX,MAAM,CAAC,KAAK;QACZ,QAAQ;QACR,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;KACrB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,SAAiB,EAAE,UAAkB;IACjE,OAAO,gBAAM;SACV,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC;SAChC,MAAM,CAAC,SAAS,CAAC;SACjB,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAC7B,SAAiB,EACjB,SAAiB,EACjB,UAAkB;IAElB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QACxC,OAAO,gBAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const PROTOCOL_VERSION: "1";
|
|
2
|
+
export declare const TIMING: {
|
|
3
|
+
/** How long hub waits for agent response before timing out the SDK request */
|
|
4
|
+
readonly REQUEST_TIMEOUT_MS: 30000;
|
|
5
|
+
/** Buffer over REQUEST_TIMEOUT_MS for hub:pending Redis TTL */
|
|
6
|
+
readonly PENDING_TTL_MS: 32000;
|
|
7
|
+
/** Hub pings every N ms */
|
|
8
|
+
readonly HEARTBEAT_INTERVAL_MS: 15000;
|
|
9
|
+
/** Miss this many pings → agent evicted */
|
|
10
|
+
readonly MAX_MISSED_PINGS: 6;
|
|
11
|
+
/** Redis presence key TTL (must be > HEARTBEAT_INTERVAL_MS) */
|
|
12
|
+
readonly AGENT_PRESENCE_TTL_SEC: 25;
|
|
13
|
+
/** Agent reconnect: initial delay */
|
|
14
|
+
readonly RECONNECT_INITIAL_MS: 1000;
|
|
15
|
+
/** Agent reconnect: maximum delay cap */
|
|
16
|
+
readonly RECONNECT_MAX_MS: 300000;
|
|
17
|
+
/** Signature timestamp tolerance */
|
|
18
|
+
readonly SIGNATURE_WINDOW_MS: 60000;
|
|
19
|
+
/** MessageBatcher flush window */
|
|
20
|
+
readonly BATCH_WINDOW_MS: 50;
|
|
21
|
+
/** MessageBatcher max items before immediate flush */
|
|
22
|
+
readonly BATCH_MAX_SIZE: 100;
|
|
23
|
+
/** LocalAgentDiscovery timeout */
|
|
24
|
+
readonly LOCAL_DISCOVERY_TIMEOUT_MS: 50;
|
|
25
|
+
};
|
|
26
|
+
export declare const LIMITS: {
|
|
27
|
+
/** Max WS message size (10MB) */
|
|
28
|
+
readonly MAX_PAYLOAD_BYTES: number;
|
|
29
|
+
/** Port agent broadcasts for local discovery */
|
|
30
|
+
readonly LOCAL_AGENT_DISCOVERY_PORT: 4242;
|
|
31
|
+
/** Max retry attempts for queue items */
|
|
32
|
+
readonly QUEUE_MAX_ATTEMPTS_OUTBOUND: 10;
|
|
33
|
+
readonly QUEUE_MAX_ATTEMPTS_INBOUND: 5;
|
|
34
|
+
};
|
|
35
|
+
export declare const PLAN_AGENT_LIMITS: {
|
|
36
|
+
readonly FREE: 1;
|
|
37
|
+
readonly PRO: 5;
|
|
38
|
+
readonly ENTERPRISE: number;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,EAAG,GAAY,CAAC;AAE7C,eAAO,MAAM,MAAM;IACjB,8EAA8E;;IAE9E,+DAA+D;;IAE/D,2BAA2B;;IAE3B,2CAA2C;;IAE3C,+DAA+D;;IAE/D,qCAAqC;;IAErC,yCAAyC;;IAEzC,oCAAoC;;IAEpC,kCAAkC;;IAElC,sDAAsD;;IAEtD,kCAAkC;;CAE1B,CAAC;AAEX,eAAO,MAAM,MAAM;IACjB,iCAAiC;;IAEjC,gDAAgD;;IAEhD,yCAAyC;;;CAGjC,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// packages/protocol/src/constants.ts
|
|
4
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PLAN_AGENT_LIMITS = exports.LIMITS = exports.TIMING = exports.PROTOCOL_VERSION = void 0;
|
|
7
|
+
exports.PROTOCOL_VERSION = "1";
|
|
8
|
+
exports.TIMING = {
|
|
9
|
+
/** How long hub waits for agent response before timing out the SDK request */
|
|
10
|
+
REQUEST_TIMEOUT_MS: 30_000,
|
|
11
|
+
/** Buffer over REQUEST_TIMEOUT_MS for hub:pending Redis TTL */
|
|
12
|
+
PENDING_TTL_MS: 32_000,
|
|
13
|
+
/** Hub pings every N ms */
|
|
14
|
+
HEARTBEAT_INTERVAL_MS: 15_000,
|
|
15
|
+
/** Miss this many pings → agent evicted */
|
|
16
|
+
MAX_MISSED_PINGS: 6,
|
|
17
|
+
/** Redis presence key TTL (must be > HEARTBEAT_INTERVAL_MS) */
|
|
18
|
+
AGENT_PRESENCE_TTL_SEC: 25,
|
|
19
|
+
/** Agent reconnect: initial delay */
|
|
20
|
+
RECONNECT_INITIAL_MS: 1_000,
|
|
21
|
+
/** Agent reconnect: maximum delay cap */
|
|
22
|
+
RECONNECT_MAX_MS: 300_000,
|
|
23
|
+
/** Signature timestamp tolerance */
|
|
24
|
+
SIGNATURE_WINDOW_MS: 60_000,
|
|
25
|
+
/** MessageBatcher flush window */
|
|
26
|
+
BATCH_WINDOW_MS: 50,
|
|
27
|
+
/** MessageBatcher max items before immediate flush */
|
|
28
|
+
BATCH_MAX_SIZE: 100,
|
|
29
|
+
/** LocalAgentDiscovery timeout */
|
|
30
|
+
LOCAL_DISCOVERY_TIMEOUT_MS: 50,
|
|
31
|
+
};
|
|
32
|
+
exports.LIMITS = {
|
|
33
|
+
/** Max WS message size (10MB) */
|
|
34
|
+
MAX_PAYLOAD_BYTES: 10 * 1024 * 1024,
|
|
35
|
+
/** Port agent broadcasts for local discovery */
|
|
36
|
+
LOCAL_AGENT_DISCOVERY_PORT: 4242,
|
|
37
|
+
/** Max retry attempts for queue items */
|
|
38
|
+
QUEUE_MAX_ATTEMPTS_OUTBOUND: 10,
|
|
39
|
+
QUEUE_MAX_ATTEMPTS_INBOUND: 5,
|
|
40
|
+
};
|
|
41
|
+
exports.PLAN_AGENT_LIMITS = {
|
|
42
|
+
FREE: 1,
|
|
43
|
+
PRO: 5,
|
|
44
|
+
ENTERPRISE: Infinity,
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,qCAAqC;AACrC,gFAAgF;;;AAEnE,QAAA,gBAAgB,GAAG,GAAY,CAAC;AAEhC,QAAA,MAAM,GAAG;IACpB,8EAA8E;IAC9E,kBAAkB,EAAE,MAAM;IAC1B,+DAA+D;IAC/D,cAAc,EAAE,MAAM;IACtB,2BAA2B;IAC3B,qBAAqB,EAAE,MAAM;IAC7B,2CAA2C;IAC3C,gBAAgB,EAAE,CAAC;IACnB,+DAA+D;IAC/D,sBAAsB,EAAE,EAAE;IAC1B,qCAAqC;IACrC,oBAAoB,EAAE,KAAK;IAC3B,yCAAyC;IACzC,gBAAgB,EAAE,OAAO;IACzB,oCAAoC;IACpC,mBAAmB,EAAE,MAAM;IAC3B,kCAAkC;IAClC,eAAe,EAAE,EAAE;IACnB,sDAAsD;IACtD,cAAc,EAAE,GAAG;IACnB,kCAAkC;IAClC,0BAA0B,EAAE,EAAE;CACtB,CAAC;AAEE,QAAA,MAAM,GAAG;IACpB,iCAAiC;IACjC,iBAAiB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IACnC,gDAAgD;IAChD,0BAA0B,EAAE,IAAI;IAChC,yCAAyC;IACzC,2BAA2B,EAAE,EAAE;IAC/B,0BAA0B,EAAE,CAAC;CACrB,CAAC;AAEE,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,QAAQ;CACZ,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type HubErrorCode = "AUTH_FAILED" | "KEY_REVOKED" | "KEY_EXPIRED" | "SCOPE_MISSING" | "VERSION_UNSUPPORTED" | "RATE_LIMITED" | "AGENT_LIMIT_REACHED" | "INVALID_MESSAGE" | "INTERNAL_ERROR";
|
|
2
|
+
export type TunnelErrorCode = "AGENT_NOT_FOUND" | "AGENT_DISCONNECTED" | "AGENT_TIMEOUT" | "BACKEND_UNAVAILABLE" | "BACKEND_ERROR" | "PAYLOAD_TOO_LARGE" | "FORBIDDEN_SCOPE" | "SEND_FAILED";
|
|
3
|
+
/** WS close codes (4000-4999 = application level) */
|
|
4
|
+
export declare const WS_CLOSE_CODES: {
|
|
5
|
+
readonly AUTH_FAILED: 4001;
|
|
6
|
+
readonly VERSION_UNSUPPORTED: 4002;
|
|
7
|
+
readonly AGENT_LIMIT_REACHED: 4003;
|
|
8
|
+
readonly RATE_LIMITED: 4004;
|
|
9
|
+
readonly INTERNAL_ERROR: 4999;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,aAAa,GACb,aAAa,GACb,eAAe,GACf,qBAAqB,GACrB,cAAc,GACd,qBAAqB,GACrB,iBAAiB,GACjB,gBAAgB,CAAC;AAErB,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,oBAAoB,GACpB,eAAe,GACf,qBAAqB,GACrB,eAAe,GACf,mBAAmB,GACnB,iBAAiB,GACjB,aAAa,CAAC;AAElB,qDAAqD;AACrD,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// packages/protocol/src/errors.ts
|
|
4
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WS_CLOSE_CODES = void 0;
|
|
7
|
+
/** WS close codes (4000-4999 = application level) */
|
|
8
|
+
exports.WS_CLOSE_CODES = {
|
|
9
|
+
AUTH_FAILED: 4001,
|
|
10
|
+
VERSION_UNSUPPORTED: 4002,
|
|
11
|
+
AGENT_LIMIT_REACHED: 4003,
|
|
12
|
+
RATE_LIMITED: 4004,
|
|
13
|
+
INTERNAL_ERROR: 4999,
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,kCAAkC;AAClC,gFAAgF;;;AAuBhF,qDAAqD;AACxC,QAAA,cAAc,GAAG;IAC5B,WAAW,EAAE,IAAI;IACjB,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,IAAI;CACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// packages/protocol/src/index.ts
|
|
3
|
+
// Single source of truth for the entire tunnel protocol.
|
|
4
|
+
// Imported by Hub, Agent, and SDK. Never duplicated.
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./messages"), exports);
|
|
21
|
+
__exportStar(require("./canonical"), exports);
|
|
22
|
+
__exportStar(require("./serializer"), exports);
|
|
23
|
+
__exportStar(require("./constants"), exports);
|
|
24
|
+
__exportStar(require("./errors"), exports);
|
|
25
|
+
// // Re-export for consumers that need the constant in canonical.ts
|
|
26
|
+
// import { PROTOCOL_VERSION } from "./constants";
|
|
27
|
+
// import type { HubErrorCode } from "./errors";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,yDAAyD;AACzD,qDAAqD;;;;;;;;;;;;;;;;AAErD,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB;AAEzB,oEAAoE;AACpE,kDAAkD;AAClD,gDAAgD"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { HubErrorCode, TunnelErrorCode } from "./errors";
|
|
2
|
+
export interface AgentRegisterMsg {
|
|
3
|
+
v: "1";
|
|
4
|
+
type: "agent:register";
|
|
5
|
+
keyId: string;
|
|
6
|
+
label: string;
|
|
7
|
+
rawSecret: string;
|
|
8
|
+
agentVersion: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentPongMsg {
|
|
11
|
+
v: "1";
|
|
12
|
+
type: "agent:pong";
|
|
13
|
+
agentId: string;
|
|
14
|
+
ts: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TunnelResponseMsg {
|
|
17
|
+
v: "1";
|
|
18
|
+
type: "tunnel:response";
|
|
19
|
+
requestId: string;
|
|
20
|
+
status: number;
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
body: string | null;
|
|
23
|
+
durationMs: number;
|
|
24
|
+
}
|
|
25
|
+
export interface TunnelAgentErrorMsg {
|
|
26
|
+
v: "1";
|
|
27
|
+
type: "tunnel:agent-error";
|
|
28
|
+
requestId: string;
|
|
29
|
+
code: TunnelErrorCode;
|
|
30
|
+
message: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AgentBatchMsg {
|
|
33
|
+
v: "1";
|
|
34
|
+
type: "agent:batch";
|
|
35
|
+
messages: Array<TunnelResponseMsg | TunnelAgentErrorMsg | AgentPongMsg>;
|
|
36
|
+
}
|
|
37
|
+
export interface HubRegisteredMsg {
|
|
38
|
+
v: "1";
|
|
39
|
+
type: "hub:registered";
|
|
40
|
+
agentId: string;
|
|
41
|
+
accountId: string;
|
|
42
|
+
replayPending: boolean;
|
|
43
|
+
tunnelUrl?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface HubPingMsg {
|
|
46
|
+
v: "1";
|
|
47
|
+
type: "hub:ping";
|
|
48
|
+
ts: number;
|
|
49
|
+
}
|
|
50
|
+
export interface TunnelForwardMsg {
|
|
51
|
+
v: "1";
|
|
52
|
+
type: "tunnel:forward";
|
|
53
|
+
requestId: string;
|
|
54
|
+
method: string;
|
|
55
|
+
path: string;
|
|
56
|
+
query: string;
|
|
57
|
+
headers: Record<string, string>;
|
|
58
|
+
body: string | null;
|
|
59
|
+
timeoutMs: number;
|
|
60
|
+
}
|
|
61
|
+
export interface HubErrorMsg {
|
|
62
|
+
v: "1";
|
|
63
|
+
type: "hub:error";
|
|
64
|
+
code: HubErrorCode;
|
|
65
|
+
message: string;
|
|
66
|
+
requestId?: string;
|
|
67
|
+
fatal: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface SdkRegisterMsg {
|
|
70
|
+
v: "1";
|
|
71
|
+
type: "sdk:register";
|
|
72
|
+
keyId: string;
|
|
73
|
+
requestId: string;
|
|
74
|
+
ts: number;
|
|
75
|
+
signature: string;
|
|
76
|
+
}
|
|
77
|
+
export interface SdkRequestMsg {
|
|
78
|
+
v: "1";
|
|
79
|
+
type: "sdk:request";
|
|
80
|
+
keyId: string;
|
|
81
|
+
requestId: string;
|
|
82
|
+
ts: number;
|
|
83
|
+
signature: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
method: string;
|
|
86
|
+
path: string;
|
|
87
|
+
query: string;
|
|
88
|
+
headers: Record<string, string>;
|
|
89
|
+
body: string | null;
|
|
90
|
+
}
|
|
91
|
+
export interface SdkRegisteredMsg {
|
|
92
|
+
v: "1";
|
|
93
|
+
type: "sdk:registered";
|
|
94
|
+
sessionId: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SdkResponseMsg {
|
|
97
|
+
v: "1";
|
|
98
|
+
type: "sdk:response";
|
|
99
|
+
requestId: string;
|
|
100
|
+
status: number;
|
|
101
|
+
headers: Record<string, string>;
|
|
102
|
+
body: string | null;
|
|
103
|
+
durationMs: number;
|
|
104
|
+
}
|
|
105
|
+
export interface SdkErrorMsg {
|
|
106
|
+
v: "1";
|
|
107
|
+
type: "sdk:error";
|
|
108
|
+
requestId: string;
|
|
109
|
+
code: TunnelErrorCode | HubErrorCode;
|
|
110
|
+
message: string;
|
|
111
|
+
retryable: boolean;
|
|
112
|
+
}
|
|
113
|
+
export type AgentToHubMsg = AgentRegisterMsg | AgentPongMsg | TunnelResponseMsg | TunnelAgentErrorMsg | AgentBatchMsg | TunnelWsMessageMsg | TunnelWsCloseMsg;
|
|
114
|
+
export type HubToAgentMsg = HubRegisteredMsg | HubPingMsg | TunnelForwardMsg | HubErrorMsg | TunnelWsOpenMsg | TunnelWsMessageMsg | TunnelWsCloseMsg;
|
|
115
|
+
export type SdkToHubMsg = SdkRegisterMsg | SdkRequestMsg;
|
|
116
|
+
export type HubToSdkMsg = SdkRegisteredMsg | SdkResponseMsg | SdkErrorMsg;
|
|
117
|
+
export type AnyHubMsg = AgentToHubMsg | HubToAgentMsg | SdkToHubMsg | HubToSdkMsg | TunnelWsErrorMsg;
|
|
118
|
+
export interface TunnelWsOpenMsg {
|
|
119
|
+
v: "1";
|
|
120
|
+
type: "tunnel:ws:open";
|
|
121
|
+
connectionId: string;
|
|
122
|
+
path: string;
|
|
123
|
+
query: string;
|
|
124
|
+
headers: Record<string, string>;
|
|
125
|
+
}
|
|
126
|
+
export interface TunnelWsMessageMsg {
|
|
127
|
+
v: "1";
|
|
128
|
+
type: "tunnel:ws:message";
|
|
129
|
+
connectionId: string;
|
|
130
|
+
data: string;
|
|
131
|
+
isBinary: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface TunnelWsCloseMsg {
|
|
134
|
+
v: "1";
|
|
135
|
+
type: "tunnel:ws:close";
|
|
136
|
+
connectionId: string;
|
|
137
|
+
code: number;
|
|
138
|
+
reason: string;
|
|
139
|
+
}
|
|
140
|
+
export interface TunnelWsErrorMsg {
|
|
141
|
+
v: "1";
|
|
142
|
+
type: "tunnel:ws:error";
|
|
143
|
+
connectionId: string;
|
|
144
|
+
message: string;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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a,GACb,aAAa,GACb,WAAW,GACX,WAAW,GACX,gBAAgB,CAAC;AAIrB,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,GAAG,CAAC;IACP,IAAI,EAAE,gBAAgB,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,GAAG,CAAC;IACP,IAAI,EAAE,mBAAmB,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,GAAG,CAAC;IACP,IAAI,EAAE,iBAAiB,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,GAAG,CAAC;IACP,IAAI,EAAE,iBAAiB,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// packages/protocol/src/messages.ts
|
|
4
|
+
// All messages as strict discriminated unions.
|
|
5
|
+
// Both Hub and Agent import these — no duplication.
|
|
6
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,+CAA+C;AAC/C,oDAAoD;AACpD,gFAAgF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HubErrorCode } from "./errors";
|
|
2
|
+
import { AnyHubMsg } from "./messages";
|
|
3
|
+
export declare function serialize(msg: AnyHubMsg): string;
|
|
4
|
+
export declare function deserialize<T = AnyHubMsg>(data: Buffer | string): T;
|
|
5
|
+
/**
|
|
6
|
+
* Parse and validate that a message has required base fields.
|
|
7
|
+
* Throws a typed error on malformed input so routers can reject cleanly.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseMessage(data: Buffer | string): AnyHubMsg;
|
|
10
|
+
export declare class ProtocolError extends Error {
|
|
11
|
+
readonly code: HubErrorCode;
|
|
12
|
+
constructor(code: HubErrorCode, message: string);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=serializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAgB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAEhD;AAED,wBAAgB,WAAW,CAAC,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAGnE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAyB7D;AAED,qBAAa,aAAc,SAAQ,KAAK;aAEpB,IAAI,EAAE,YAAY;gBAAlB,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM;CAKlB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// packages/protocol/src/serializer.ts
|
|
4
|
+
// Single abstraction over serialization format.
|
|
5
|
+
// Phase 1: JSON (debug-friendly).
|
|
6
|
+
// Phase 2: swap to msgpackr here — zero other changes.
|
|
7
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProtocolError = void 0;
|
|
10
|
+
exports.serialize = serialize;
|
|
11
|
+
exports.deserialize = deserialize;
|
|
12
|
+
exports.parseMessage = parseMessage;
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
function serialize(msg) {
|
|
15
|
+
return JSON.stringify(msg);
|
|
16
|
+
}
|
|
17
|
+
function deserialize(data) {
|
|
18
|
+
const str = Buffer.isBuffer(data) ? data.toString("utf8") : data;
|
|
19
|
+
return JSON.parse(str);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse and validate that a message has required base fields.
|
|
23
|
+
* Throws a typed error on malformed input so routers can reject cleanly.
|
|
24
|
+
*/
|
|
25
|
+
function parseMessage(data) {
|
|
26
|
+
let msg;
|
|
27
|
+
try {
|
|
28
|
+
msg = deserialize(data);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
throw new ProtocolError("INVALID_MESSAGE", "Message is not valid JSON");
|
|
32
|
+
}
|
|
33
|
+
if (!msg || typeof msg !== "object") {
|
|
34
|
+
throw new ProtocolError("INVALID_MESSAGE", "Message must be a JSON object");
|
|
35
|
+
}
|
|
36
|
+
if (msg.v !== constants_1.PROTOCOL_VERSION) {
|
|
37
|
+
throw new ProtocolError("VERSION_UNSUPPORTED", `Protocol version "${msg.v}" is not supported. Expected "${constants_1.PROTOCOL_VERSION}".`);
|
|
38
|
+
}
|
|
39
|
+
if (!msg.type || typeof msg.type !== "string") {
|
|
40
|
+
throw new ProtocolError("INVALID_MESSAGE", 'Message missing required "type" field');
|
|
41
|
+
}
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
class ProtocolError extends Error {
|
|
45
|
+
code;
|
|
46
|
+
constructor(code, message) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.code = code;
|
|
49
|
+
this.name = "ProtocolError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ProtocolError = ProtocolError;
|
|
53
|
+
//# sourceMappingURL=serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,sCAAsC;AACtC,gDAAgD;AAChD,kCAAkC;AAClC,uDAAuD;AACvD,gFAAgF;;;AAMhF,8BAEC;AAED,kCAGC;AAMD,oCAyBC;AA1CD,2CAA+C;AAI/C,SAAgB,SAAS,CAAC,GAAc;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,WAAW,CAAgB,IAAqB;IAC9D,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAM,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,IAAqB;IAChD,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAE,+BAA+B,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,GAAG,CAAC,CAAC,KAAK,4BAAgB,EAAE,CAAC;QAC/B,MAAM,IAAI,aAAa,CACrB,qBAAqB,EACrB,qBAAqB,GAAG,CAAC,CAAC,iCAAiC,4BAAgB,IAAI,CAChF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,aAAa,CACrB,iBAAiB,EACjB,uCAAuC,CACxC,CAAC;IACJ,CAAC;IAED,OAAO,GAAgB,CAAC;AAC1B,CAAC;AAED,MAAa,aAAc,SAAQ,KAAK;IAEpB;IADlB,YACkB,IAAkB,EAClC,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAc;QAIlC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AARD,sCAQC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vhyxvoid/protocol",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared WebSocket message types and canonical string builder for the tunnel system",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -b",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^24.10.1",
|
|
18
|
+
"typescript": "^5.4.0"
|
|
19
|
+
}
|
|
20
|
+
}
|