@inkbox/sdk 0.2.15 → 0.3.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/README.md +10 -1
- package/dist/_http.d.ts +24 -5
- package/dist/_http.d.ts.map +1 -1
- package/dist/_http.js +21 -11
- package/dist/_http.js.map +1 -1
- package/dist/agent_identity.d.ts +20 -0
- package/dist/agent_identity.d.ts.map +1 -1
- package/dist/agent_identity.js +17 -0
- package/dist/agent_identity.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/inkbox.d.ts +4 -0
- package/dist/inkbox.d.ts.map +1 -1
- package/dist/inkbox.js +5 -0
- package/dist/inkbox.js.map +1 -1
- package/dist/phone/resources/calls.d.ts +8 -0
- package/dist/phone/resources/calls.d.ts.map +1 -1
- package/dist/phone/resources/calls.js +15 -1
- package/dist/phone/resources/calls.js.map +1 -1
- package/dist/phone/resources/texts.d.ts +26 -0
- package/dist/phone/resources/texts.d.ts.map +1 -1
- package/dist/phone/resources/texts.js +42 -2
- package/dist/phone/resources/texts.js.map +1 -1
- package/dist/phone/types.d.ts +18 -0
- package/dist/phone/types.d.ts.map +1 -1
- package/dist/phone/types.js +2 -0
- package/dist/phone/types.js.map +1 -1
- package/dist/tunnels/_validation.d.ts +7 -0
- package/dist/tunnels/_validation.d.ts.map +1 -0
- package/dist/tunnels/_validation.js +27 -0
- package/dist/tunnels/_validation.js.map +1 -0
- package/dist/tunnels/client/_bridge.d.ts +35 -0
- package/dist/tunnels/client/_bridge.d.ts.map +1 -0
- package/dist/tunnels/client/_bridge.js +52 -0
- package/dist/tunnels/client/_bridge.js.map +1 -0
- package/dist/tunnels/client/_callable_streaming.d.ts +25 -0
- package/dist/tunnels/client/_callable_streaming.d.ts.map +1 -0
- package/dist/tunnels/client/_callable_streaming.js +158 -0
- package/dist/tunnels/client/_callable_streaming.js.map +1 -0
- package/dist/tunnels/client/_cert.d.ts +45 -0
- package/dist/tunnels/client/_cert.d.ts.map +1 -0
- package/dist/tunnels/client/_cert.js +193 -0
- package/dist/tunnels/client/_cert.js.map +1 -0
- package/dist/tunnels/client/_dispatch.d.ts +109 -0
- package/dist/tunnels/client/_dispatch.d.ts.map +1 -0
- package/dist/tunnels/client/_dispatch.js +314 -0
- package/dist/tunnels/client/_dispatch.js.map +1 -0
- package/dist/tunnels/client/_envelope.d.ts +55 -0
- package/dist/tunnels/client/_envelope.d.ts.map +1 -0
- package/dist/tunnels/client/_envelope.js +97 -0
- package/dist/tunnels/client/_envelope.js.map +1 -0
- package/dist/tunnels/client/_h1_server.d.ts +37 -0
- package/dist/tunnels/client/_h1_server.d.ts.map +1 -0
- package/dist/tunnels/client/_h1_server.js +433 -0
- package/dist/tunnels/client/_h1_server.js.map +1 -0
- package/dist/tunnels/client/_h2_transcode.d.ts +43 -0
- package/dist/tunnels/client/_h2_transcode.d.ts.map +1 -0
- package/dist/tunnels/client/_h2_transcode.js +488 -0
- package/dist/tunnels/client/_h2_transcode.js.map +1 -0
- package/dist/tunnels/client/_handler.d.ts +62 -0
- package/dist/tunnels/client/_handler.d.ts.map +1 -0
- package/dist/tunnels/client/_handler.js +121 -0
- package/dist/tunnels/client/_handler.js.map +1 -0
- package/dist/tunnels/client/_listener.d.ts +64 -0
- package/dist/tunnels/client/_listener.d.ts.map +1 -0
- package/dist/tunnels/client/_listener.js +113 -0
- package/dist/tunnels/client/_listener.js.map +1 -0
- package/dist/tunnels/client/_protocol.d.ts +67 -0
- package/dist/tunnels/client/_protocol.d.ts.map +1 -0
- package/dist/tunnels/client/_protocol.js +86 -0
- package/dist/tunnels/client/_protocol.js.map +1 -0
- package/dist/tunnels/client/_runtime.d.ts +143 -0
- package/dist/tunnels/client/_runtime.d.ts.map +1 -0
- package/dist/tunnels/client/_runtime.js +1679 -0
- package/dist/tunnels/client/_runtime.js.map +1 -0
- package/dist/tunnels/client/_state.d.ts +45 -0
- package/dist/tunnels/client/_state.d.ts.map +1 -0
- package/dist/tunnels/client/_state.js +165 -0
- package/dist/tunnels/client/_state.js.map +1 -0
- package/dist/tunnels/client/_tls.d.ts +50 -0
- package/dist/tunnels/client/_tls.d.ts.map +1 -0
- package/dist/tunnels/client/_tls.js +139 -0
- package/dist/tunnels/client/_tls.js.map +1 -0
- package/dist/tunnels/client/_upstream_tls.d.ts +25 -0
- package/dist/tunnels/client/_upstream_tls.d.ts.map +1 -0
- package/dist/tunnels/client/_upstream_tls.js +24 -0
- package/dist/tunnels/client/_upstream_tls.js.map +1 -0
- package/dist/tunnels/client/_url_forward.d.ts +92 -0
- package/dist/tunnels/client/_url_forward.d.ts.map +1 -0
- package/dist/tunnels/client/_url_forward.js +255 -0
- package/dist/tunnels/client/_url_forward.js.map +1 -0
- package/dist/tunnels/client/_validation.d.ts +27 -0
- package/dist/tunnels/client/_validation.d.ts.map +1 -0
- package/dist/tunnels/client/_validation.js +96 -0
- package/dist/tunnels/client/_validation.js.map +1 -0
- package/dist/tunnels/client/_ws.d.ts +149 -0
- package/dist/tunnels/client/_ws.d.ts.map +1 -0
- package/dist/tunnels/client/_ws.js +351 -0
- package/dist/tunnels/client/_ws.js.map +1 -0
- package/dist/tunnels/client/_ws_passthrough.d.ts +129 -0
- package/dist/tunnels/client/_ws_passthrough.d.ts.map +1 -0
- package/dist/tunnels/client/_ws_passthrough.js +432 -0
- package/dist/tunnels/client/_ws_passthrough.js.map +1 -0
- package/dist/tunnels/client/_ws_url_bridge.d.ts +71 -0
- package/dist/tunnels/client/_ws_url_bridge.d.ts.map +1 -0
- package/dist/tunnels/client/_ws_url_bridge.js +474 -0
- package/dist/tunnels/client/_ws_url_bridge.js.map +1 -0
- package/dist/tunnels/client/_ws_url_edge_bridge.d.ts +26 -0
- package/dist/tunnels/client/_ws_url_edge_bridge.d.ts.map +1 -0
- package/dist/tunnels/client/_ws_url_edge_bridge.js +256 -0
- package/dist/tunnels/client/_ws_url_edge_bridge.js.map +1 -0
- package/dist/tunnels/client/_wsframe.d.ts +142 -0
- package/dist/tunnels/client/_wsframe.d.ts.map +1 -0
- package/dist/tunnels/client/_wsframe.js +282 -0
- package/dist/tunnels/client/_wsframe.js.map +1 -0
- package/dist/tunnels/client/index.d.ts +101 -0
- package/dist/tunnels/client/index.d.ts.map +1 -0
- package/dist/tunnels/client/index.js +242 -0
- package/dist/tunnels/client/index.js.map +1 -0
- package/dist/tunnels/exceptions.d.ts +31 -0
- package/dist/tunnels/exceptions.d.ts.map +1 -0
- package/dist/tunnels/exceptions.js +68 -0
- package/dist/tunnels/exceptions.js.map +1 -0
- package/dist/tunnels/resources/tunnels.d.ts +73 -0
- package/dist/tunnels/resources/tunnels.d.ts.map +1 -0
- package/dist/tunnels/resources/tunnels.js +173 -0
- package/dist/tunnels/resources/tunnels.js.map +1 -0
- package/dist/tunnels/types.d.ts +99 -0
- package/dist/tunnels/types.d.ts.map +1 -0
- package/dist/tunnels/types.js +76 -0
- package/dist/tunnels/types.js.map +1 -0
- package/package.json +14 -5
- package/protocol/tunnel_protocol_constants.json +65 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-tunnels/exceptions.ts
|
|
3
|
+
*
|
|
4
|
+
* Typed exceptions for the Tunnels SDK surface.
|
|
5
|
+
*/
|
|
6
|
+
import { InkboxAPIError, InkboxError, type InkboxAPIErrorDetail } from "../_http.js";
|
|
7
|
+
export declare class TunnelError extends InkboxError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class TunnelNameInvalid extends TunnelError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class TunnelSecretUnavailable extends TunnelError {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class TunnelRemoved extends TunnelError {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class TunnelStateConflict extends InkboxAPIError {
|
|
20
|
+
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
21
|
+
}
|
|
22
|
+
export declare class TunnelNameUnavailable extends InkboxAPIError {
|
|
23
|
+
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
24
|
+
}
|
|
25
|
+
export declare class TunnelTLSModeMismatch extends InkboxAPIError {
|
|
26
|
+
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
27
|
+
}
|
|
28
|
+
export declare class TunnelCSRStateConflict extends TunnelStateConflict {
|
|
29
|
+
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/tunnels/exceptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,WAAW,EACX,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAErB,qBAAa,WAAY,SAAQ,WAAW;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,uBAAwB,SAAQ,WAAW;gBAC1C,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAgBD,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB;CAI7D;AAED,qBAAa,qBAAsB,SAAQ,cAAc;gBAC3C,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB;CAI7D;AAED,qBAAa,qBAAsB,SAAQ,cAAc;gBAC3C,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB;CAI7D;AAED,qBAAa,sBAAuB,SAAQ,mBAAmB;gBACjD,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB;CAI7D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-tunnels/exceptions.ts
|
|
3
|
+
*
|
|
4
|
+
* Typed exceptions for the Tunnels SDK surface.
|
|
5
|
+
*/
|
|
6
|
+
import { InkboxAPIError, InkboxError, } from "../_http.js";
|
|
7
|
+
export class TunnelError extends InkboxError {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "TunnelError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class TunnelNameInvalid extends TunnelError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "TunnelNameInvalid";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class TunnelSecretUnavailable extends TunnelError {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "TunnelSecretUnavailable";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class TunnelRemoved extends TunnelError {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "TunnelRemoved";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function sanitizeDetail(detail) {
|
|
32
|
+
const sanitizeStr = (s) => s.replace(/delete_pending/g, "pending_removal").replace(/deleted/g, "removed");
|
|
33
|
+
if (typeof detail === "string")
|
|
34
|
+
return sanitizeStr(detail);
|
|
35
|
+
if (detail && typeof detail === "object") {
|
|
36
|
+
const out = {};
|
|
37
|
+
for (const [k, v] of Object.entries(detail)) {
|
|
38
|
+
out[k] = typeof v === "string" ? sanitizeStr(v) : v;
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
return detail;
|
|
43
|
+
}
|
|
44
|
+
export class TunnelStateConflict extends InkboxAPIError {
|
|
45
|
+
constructor(statusCode, detail) {
|
|
46
|
+
super(statusCode, sanitizeDetail(detail));
|
|
47
|
+
this.name = "TunnelStateConflict";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class TunnelNameUnavailable extends InkboxAPIError {
|
|
51
|
+
constructor(statusCode, detail) {
|
|
52
|
+
super(statusCode, detail);
|
|
53
|
+
this.name = "TunnelNameUnavailable";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class TunnelTLSModeMismatch extends InkboxAPIError {
|
|
57
|
+
constructor(statusCode, detail) {
|
|
58
|
+
super(statusCode, detail);
|
|
59
|
+
this.name = "TunnelTLSModeMismatch";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class TunnelCSRStateConflict extends TunnelStateConflict {
|
|
63
|
+
constructor(statusCode, detail) {
|
|
64
|
+
super(statusCode, detail);
|
|
65
|
+
this.name = "TunnelCSRStateConflict";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/tunnels/exceptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,MA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B,SAAQ,cAAc;IACvD,YAAY,UAAkB,EAAE,MAA4B;QAC1D,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAC7D,YAAY,UAAkB,EAAE,MAA4B;QAC1D,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-tunnels/resources/tunnels.ts
|
|
3
|
+
*
|
|
4
|
+
* Control-plane CRUD for tunnels. Wraps `/api/v1/tunnels/*`.
|
|
5
|
+
*/
|
|
6
|
+
import { HttpTransport } from "../../_http.js";
|
|
7
|
+
import { CreatedTunnel, RotatedSecret, SignedCert, TLSMode, Tunnel } from "../types.js";
|
|
8
|
+
export declare const POOL_SIZE_MIN = 1;
|
|
9
|
+
export declare const POOL_SIZE_MAX = 32;
|
|
10
|
+
export interface CreateTunnelOptions {
|
|
11
|
+
tunnelName: string;
|
|
12
|
+
tlsMode?: TLSMode | "edge" | "passthrough";
|
|
13
|
+
description?: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateTunnelOptions {
|
|
16
|
+
/** Pass `null` to clear; omit to leave unchanged. */
|
|
17
|
+
description?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Pass `{}` or `null` to clear (the server's column is non-nullable
|
|
20
|
+
* and collapses both forms to `{}`); omit to leave unchanged.
|
|
21
|
+
*/
|
|
22
|
+
metadata?: Record<string, unknown> | null;
|
|
23
|
+
}
|
|
24
|
+
export declare class TunnelsResource {
|
|
25
|
+
private readonly http;
|
|
26
|
+
constructor(http: HttpTransport);
|
|
27
|
+
list(): Promise<Tunnel[]>;
|
|
28
|
+
get(tunnelId: string): Promise<Tunnel>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new tunnel. Persist the returned `connectSecret` immediately —
|
|
31
|
+
* it is shown ONCE.
|
|
32
|
+
*/
|
|
33
|
+
create(options: CreateTunnelOptions): Promise<CreatedTunnel>;
|
|
34
|
+
/**
|
|
35
|
+
* Update a tunnel. Pass only the fields you want to change.
|
|
36
|
+
*
|
|
37
|
+
* - `description: null` clears the description.
|
|
38
|
+
* - `metadata: {}` clears metadata. `metadata` cannot be `null`
|
|
39
|
+
* (rejected client-side); pass `{}` to clear.
|
|
40
|
+
*/
|
|
41
|
+
update(tunnelId: string, options: UpdateTunnelOptions): Promise<Tunnel>;
|
|
42
|
+
/**
|
|
43
|
+
* Schedule a tunnel for removal. The name is held for 24 hours, during
|
|
44
|
+
* which `restore` brings it back online.
|
|
45
|
+
*/
|
|
46
|
+
delete(tunnelId: string): Promise<Tunnel>;
|
|
47
|
+
/** Bring a scheduled-for-removal tunnel back online. */
|
|
48
|
+
restore(tunnelId: string): Promise<Tunnel>;
|
|
49
|
+
/**
|
|
50
|
+
* Remove a scheduled-for-removal tunnel immediately, skipping the 24-hour
|
|
51
|
+
* window. Requires an admin-scoped API key.
|
|
52
|
+
*/
|
|
53
|
+
forceDelete(tunnelId: string): Promise<Tunnel>;
|
|
54
|
+
/**
|
|
55
|
+
* Rotate the per-tunnel connect secret.
|
|
56
|
+
*
|
|
57
|
+
* The new secret takes effect on the next agent reconnect; existing live
|
|
58
|
+
* connections continue serving traffic with the old secret until they
|
|
59
|
+
* reconnect.
|
|
60
|
+
*/
|
|
61
|
+
rotateSecret(tunnelId: string): Promise<RotatedSecret>;
|
|
62
|
+
/**
|
|
63
|
+
* Sign a CSR for a passthrough tunnel.
|
|
64
|
+
*
|
|
65
|
+
* The server performs DNS validation and cert issuance synchronously
|
|
66
|
+
* inside this request, which can take up to a few minutes. This call
|
|
67
|
+
* uses an elevated 180-second timeout to accommodate that.
|
|
68
|
+
*/
|
|
69
|
+
signCsr(tunnelId: string, options: {
|
|
70
|
+
csrPem: string;
|
|
71
|
+
}): Promise<SignedCert>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=tunnels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnels.d.ts","sourceRoot":"","sources":["../../../src/tunnels/resources/tunnels.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAQ/D,OAAO,EACL,aAAa,EAKb,aAAa,EACb,UAAU,EACV,OAAO,EACP,MAAM,EAKP,MAAM,aAAa,CAAC;AAMrB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,aAAa,KAAK,CAAC;AAkChC,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAI1C,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQzB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO5C;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBlE;;;;;;OAMG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB7E;;;OAGG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO/C,wDAAwD;IAClD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhD;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYpD;;;;;;OAMG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAO5D;;;;;;OAMG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAalF"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-tunnels/resources/tunnels.ts
|
|
3
|
+
*
|
|
4
|
+
* Control-plane CRUD for tunnels. Wraps `/api/v1/tunnels/*`.
|
|
5
|
+
*/
|
|
6
|
+
import { InkboxAPIError } from "../../_http.js";
|
|
7
|
+
import { validateTunnelName } from "../_validation.js";
|
|
8
|
+
import { TunnelCSRStateConflict, TunnelNameUnavailable, TunnelStateConflict, TunnelTLSModeMismatch, } from "../exceptions.js";
|
|
9
|
+
import { TLSMode, parseCreatedTunnel, parseRotatedSecret, parseSignedCert, parseTunnel, } from "../types.js";
|
|
10
|
+
const BASE = "/tunnels";
|
|
11
|
+
const SIGN_CSR_TIMEOUT_MS = 180_000;
|
|
12
|
+
export const POOL_SIZE_MIN = 1;
|
|
13
|
+
export const POOL_SIZE_MAX = 32;
|
|
14
|
+
function detailText(detail) {
|
|
15
|
+
if (typeof detail === "string")
|
|
16
|
+
return detail;
|
|
17
|
+
if (detail && typeof detail === "object") {
|
|
18
|
+
const inner = detail.detail;
|
|
19
|
+
if (typeof inner === "string")
|
|
20
|
+
return inner;
|
|
21
|
+
}
|
|
22
|
+
return String(detail);
|
|
23
|
+
}
|
|
24
|
+
function mapCreateError(err) {
|
|
25
|
+
if (err.statusCode === 409) {
|
|
26
|
+
return new TunnelNameUnavailable(err.statusCode, err.detail);
|
|
27
|
+
}
|
|
28
|
+
return err;
|
|
29
|
+
}
|
|
30
|
+
function mapStateError(err) {
|
|
31
|
+
if (err.statusCode === 409) {
|
|
32
|
+
return new TunnelStateConflict(err.statusCode, err.detail);
|
|
33
|
+
}
|
|
34
|
+
return err;
|
|
35
|
+
}
|
|
36
|
+
function mapSignCsrError(err) {
|
|
37
|
+
if (err.statusCode !== 409)
|
|
38
|
+
return err;
|
|
39
|
+
const text = detailText(err.detail).toLowerCase();
|
|
40
|
+
if (text.includes("edge") || text.includes("tls_mode") || text.includes("passthrough")) {
|
|
41
|
+
return new TunnelTLSModeMismatch(err.statusCode, err.detail);
|
|
42
|
+
}
|
|
43
|
+
return new TunnelCSRStateConflict(err.statusCode, err.detail);
|
|
44
|
+
}
|
|
45
|
+
export class TunnelsResource {
|
|
46
|
+
http;
|
|
47
|
+
constructor(http) {
|
|
48
|
+
this.http = http;
|
|
49
|
+
}
|
|
50
|
+
// --- Reads -----------------------------------------------------------
|
|
51
|
+
async list() {
|
|
52
|
+
const data = await this.http.get(`${BASE}/`);
|
|
53
|
+
const items = Array.isArray(data) ? data : data.tunnels;
|
|
54
|
+
return items.map(parseTunnel);
|
|
55
|
+
}
|
|
56
|
+
async get(tunnelId) {
|
|
57
|
+
const data = await this.http.get(`${BASE}/${tunnelId}`);
|
|
58
|
+
return parseTunnel(data);
|
|
59
|
+
}
|
|
60
|
+
// --- Writes ----------------------------------------------------------
|
|
61
|
+
/**
|
|
62
|
+
* Create a new tunnel. Persist the returned `connectSecret` immediately —
|
|
63
|
+
* it is shown ONCE.
|
|
64
|
+
*/
|
|
65
|
+
async create(options) {
|
|
66
|
+
validateTunnelName(options.tunnelName);
|
|
67
|
+
const body = {
|
|
68
|
+
tunnel_name: options.tunnelName,
|
|
69
|
+
tls_mode: options.tlsMode ?? TLSMode.EDGE,
|
|
70
|
+
};
|
|
71
|
+
if (options.description !== undefined && options.description !== null) {
|
|
72
|
+
body.description = options.description;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const data = await this.http.post(`${BASE}/`, body);
|
|
76
|
+
return parseCreatedTunnel(data);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
if (err instanceof InkboxAPIError)
|
|
80
|
+
throw mapCreateError(err);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Update a tunnel. Pass only the fields you want to change.
|
|
86
|
+
*
|
|
87
|
+
* - `description: null` clears the description.
|
|
88
|
+
* - `metadata: {}` clears metadata. `metadata` cannot be `null`
|
|
89
|
+
* (rejected client-side); pass `{}` to clear.
|
|
90
|
+
*/
|
|
91
|
+
async update(tunnelId, options) {
|
|
92
|
+
const body = {};
|
|
93
|
+
if ("description" in options) {
|
|
94
|
+
body.description = options.description;
|
|
95
|
+
}
|
|
96
|
+
if ("metadata" in options) {
|
|
97
|
+
const m = options.metadata;
|
|
98
|
+
if (m !== null && m !== undefined) {
|
|
99
|
+
if (typeof m !== "object" || Array.isArray(m)) {
|
|
100
|
+
throw new Error("metadata must be a plain object or null");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
body.metadata = m ?? null;
|
|
104
|
+
}
|
|
105
|
+
const data = await this.http.patch(`${BASE}/${tunnelId}`, body);
|
|
106
|
+
return parseTunnel(data);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Schedule a tunnel for removal. The name is held for 24 hours, during
|
|
110
|
+
* which `restore` brings it back online.
|
|
111
|
+
*/
|
|
112
|
+
async delete(tunnelId) {
|
|
113
|
+
const data = await this.http.deleteWithResponse(`${BASE}/${tunnelId}`);
|
|
114
|
+
return parseTunnel(data);
|
|
115
|
+
}
|
|
116
|
+
/** Bring a scheduled-for-removal tunnel back online. */
|
|
117
|
+
async restore(tunnelId) {
|
|
118
|
+
try {
|
|
119
|
+
const data = await this.http.post(`${BASE}/${tunnelId}/restore`);
|
|
120
|
+
return parseTunnel(data);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (err instanceof InkboxAPIError)
|
|
124
|
+
throw mapStateError(err);
|
|
125
|
+
throw err;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Remove a scheduled-for-removal tunnel immediately, skipping the 24-hour
|
|
130
|
+
* window. Requires an admin-scoped API key.
|
|
131
|
+
*/
|
|
132
|
+
async forceDelete(tunnelId) {
|
|
133
|
+
try {
|
|
134
|
+
const data = await this.http.deleteWithResponse(`${BASE}/${tunnelId}/force`);
|
|
135
|
+
return parseTunnel(data);
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
if (err instanceof InkboxAPIError)
|
|
139
|
+
throw mapStateError(err);
|
|
140
|
+
throw err;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Rotate the per-tunnel connect secret.
|
|
145
|
+
*
|
|
146
|
+
* The new secret takes effect on the next agent reconnect; existing live
|
|
147
|
+
* connections continue serving traffic with the old secret until they
|
|
148
|
+
* reconnect.
|
|
149
|
+
*/
|
|
150
|
+
async rotateSecret(tunnelId) {
|
|
151
|
+
const data = await this.http.post(`${BASE}/${tunnelId}/rotate-secret`);
|
|
152
|
+
return parseRotatedSecret(data);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Sign a CSR for a passthrough tunnel.
|
|
156
|
+
*
|
|
157
|
+
* The server performs DNS validation and cert issuance synchronously
|
|
158
|
+
* inside this request, which can take up to a few minutes. This call
|
|
159
|
+
* uses an elevated 180-second timeout to accommodate that.
|
|
160
|
+
*/
|
|
161
|
+
async signCsr(tunnelId, options) {
|
|
162
|
+
try {
|
|
163
|
+
const data = await this.http.post(`${BASE}/${tunnelId}/sign-csr`, { csr_pem: options.csrPem }, { timeoutMs: SIGN_CSR_TIMEOUT_MS });
|
|
164
|
+
return parseSignedCert(data);
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
if (err instanceof InkboxAPIError)
|
|
168
|
+
throw mapSignCsrError(err);
|
|
169
|
+
throw err;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=tunnels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnels.js","sourceRoot":"","sources":["../../../src/tunnels/resources/tunnels.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAQL,OAAO,EAEP,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAEpC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,SAAS,UAAU,CAAC,MAAe;IACjC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,KAAK,GAAI,MAAkC,CAAC,MAAM,CAAC;QACzD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,cAAc,CAAC,GAAmB;IACzC,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG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E = "edge",
|
|
8
|
+
PASSTHROUGH = "passthrough"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Lifecycle state of a tunnel.
|
|
12
|
+
*
|
|
13
|
+
* - `awaiting_cert`: passthrough-only intermediate state. Inbound TLS
|
|
14
|
+
* will fail until you call `tunnels.signCsr(...)`.
|
|
15
|
+
* - `active`: routable end-to-end.
|
|
16
|
+
* - `pending_removal`: `delete` was called; the name is held for 24h
|
|
17
|
+
* during which `tunnels.restore(id)` brings it back. After 24h the
|
|
18
|
+
* tunnel is permanently removed and its name is released. Past that
|
|
19
|
+
* point a `GET` for the tunnel id returns 404; `TunnelRemoved`
|
|
20
|
+
* surfaces that condition for clients holding stale state.
|
|
21
|
+
*/
|
|
22
|
+
export declare enum TunnelStatus {
|
|
23
|
+
AWAITING_CERT = "awaiting_cert",
|
|
24
|
+
ACTIVE = "active",
|
|
25
|
+
PENDING_REMOVAL = "pending_removal"
|
|
26
|
+
}
|
|
27
|
+
export interface Tunnel {
|
|
28
|
+
id: string;
|
|
29
|
+
organizationId: string;
|
|
30
|
+
tunnelName: string;
|
|
31
|
+
description: string | null;
|
|
32
|
+
tlsMode: TLSMode;
|
|
33
|
+
certPem: string | null;
|
|
34
|
+
certFingerprintSha256: string | null;
|
|
35
|
+
certExpiresAt: Date | null;
|
|
36
|
+
status: TunnelStatus;
|
|
37
|
+
lastConnectedAt: Date | null;
|
|
38
|
+
lastConnectedIpAddr: string | null;
|
|
39
|
+
restoreDeadlineAt: Date | null;
|
|
40
|
+
currentlyConnected: boolean;
|
|
41
|
+
publicHost: string | null;
|
|
42
|
+
zone: string | null;
|
|
43
|
+
metadata: Record<string, unknown>;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
}
|
|
47
|
+
export interface CreatedTunnel {
|
|
48
|
+
tunnel: Tunnel;
|
|
49
|
+
/** Shown ONCE — persist immediately. */
|
|
50
|
+
connectSecret: string;
|
|
51
|
+
}
|
|
52
|
+
export interface RotatedSecret {
|
|
53
|
+
/** New secret. Takes effect on the next agent reconnect. */
|
|
54
|
+
connectSecret: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SignedCert {
|
|
57
|
+
certPem: string;
|
|
58
|
+
chainPem: string;
|
|
59
|
+
certFingerprintSha256: string;
|
|
60
|
+
certExpiresAt: Date;
|
|
61
|
+
}
|
|
62
|
+
export interface RawTunnel {
|
|
63
|
+
id: string;
|
|
64
|
+
organization_id: string;
|
|
65
|
+
tunnel_name: string;
|
|
66
|
+
description: string | null;
|
|
67
|
+
tls_mode: string;
|
|
68
|
+
cert_pem: string | null;
|
|
69
|
+
cert_fingerprint_sha256: string | null;
|
|
70
|
+
cert_expires_at: string | null;
|
|
71
|
+
status: string;
|
|
72
|
+
last_connected_at: string | null;
|
|
73
|
+
last_connected_ip_addr: string | null;
|
|
74
|
+
restore_deadline_at: string | null;
|
|
75
|
+
currently_connected: boolean;
|
|
76
|
+
public_host?: string | null;
|
|
77
|
+
zone?: string | null;
|
|
78
|
+
metadata?: Record<string, unknown> | null;
|
|
79
|
+
created_at: string;
|
|
80
|
+
updated_at: string;
|
|
81
|
+
}
|
|
82
|
+
export interface RawCreatedTunnel {
|
|
83
|
+
tunnel: RawTunnel;
|
|
84
|
+
connect_secret: string;
|
|
85
|
+
}
|
|
86
|
+
export interface RawRotatedSecret {
|
|
87
|
+
connect_secret: string;
|
|
88
|
+
}
|
|
89
|
+
export interface RawSignedCert {
|
|
90
|
+
cert_pem: string;
|
|
91
|
+
chain_pem: string;
|
|
92
|
+
cert_fingerprint_sha256: string;
|
|
93
|
+
cert_expires_at: string;
|
|
94
|
+
}
|
|
95
|
+
export declare function parseTunnel(raw: RawTunnel): Tunnel;
|
|
96
|
+
export declare function parseCreatedTunnel(raw: RawCreatedTunnel): CreatedTunnel;
|
|
97
|
+
export declare function parseRotatedSecret(raw: RawRotatedSecret): RotatedSecret;
|
|
98
|
+
export declare function parseSignedCert(raw: RawSignedCert): SignedCert;
|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B,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAwBlD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,CAEvE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,CAEvE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,CAO9D"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-tunnels/types.ts
|
|
3
|
+
*
|
|
4
|
+
* Resource models for the Tunnels SDK surface.
|
|
5
|
+
*/
|
|
6
|
+
export var TLSMode;
|
|
7
|
+
(function (TLSMode) {
|
|
8
|
+
TLSMode["EDGE"] = "edge";
|
|
9
|
+
TLSMode["PASSTHROUGH"] = "passthrough";
|
|
10
|
+
})(TLSMode || (TLSMode = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Lifecycle state of a tunnel.
|
|
13
|
+
*
|
|
14
|
+
* - `awaiting_cert`: passthrough-only intermediate state. Inbound TLS
|
|
15
|
+
* will fail until you call `tunnels.signCsr(...)`.
|
|
16
|
+
* - `active`: routable end-to-end.
|
|
17
|
+
* - `pending_removal`: `delete` was called; the name is held for 24h
|
|
18
|
+
* during which `tunnels.restore(id)` brings it back. After 24h the
|
|
19
|
+
* tunnel is permanently removed and its name is released. Past that
|
|
20
|
+
* point a `GET` for the tunnel id returns 404; `TunnelRemoved`
|
|
21
|
+
* surfaces that condition for clients holding stale state.
|
|
22
|
+
*/
|
|
23
|
+
export var TunnelStatus;
|
|
24
|
+
(function (TunnelStatus) {
|
|
25
|
+
TunnelStatus["AWAITING_CERT"] = "awaiting_cert";
|
|
26
|
+
TunnelStatus["ACTIVE"] = "active";
|
|
27
|
+
TunnelStatus["PENDING_REMOVAL"] = "pending_removal";
|
|
28
|
+
})(TunnelStatus || (TunnelStatus = {}));
|
|
29
|
+
const STATUS_REMAP_TO_PUBLIC = {
|
|
30
|
+
awaiting_cert: TunnelStatus.AWAITING_CERT,
|
|
31
|
+
active: TunnelStatus.ACTIVE,
|
|
32
|
+
delete_pending: TunnelStatus.PENDING_REMOVAL,
|
|
33
|
+
};
|
|
34
|
+
function parseDate(v) {
|
|
35
|
+
if (v === null || v === undefined)
|
|
36
|
+
return null;
|
|
37
|
+
return new Date(v);
|
|
38
|
+
}
|
|
39
|
+
export function parseTunnel(raw) {
|
|
40
|
+
const status = STATUS_REMAP_TO_PUBLIC[raw.status] ?? raw.status;
|
|
41
|
+
return {
|
|
42
|
+
id: String(raw.id),
|
|
43
|
+
organizationId: String(raw.organization_id),
|
|
44
|
+
tunnelName: String(raw.tunnel_name),
|
|
45
|
+
description: raw.description ?? null,
|
|
46
|
+
tlsMode: raw.tls_mode,
|
|
47
|
+
certPem: raw.cert_pem ?? null,
|
|
48
|
+
certFingerprintSha256: raw.cert_fingerprint_sha256 ?? null,
|
|
49
|
+
certExpiresAt: parseDate(raw.cert_expires_at),
|
|
50
|
+
status,
|
|
51
|
+
lastConnectedAt: parseDate(raw.last_connected_at),
|
|
52
|
+
lastConnectedIpAddr: raw.last_connected_ip_addr ?? null,
|
|
53
|
+
restoreDeadlineAt: parseDate(raw.restore_deadline_at),
|
|
54
|
+
currentlyConnected: Boolean(raw.currently_connected),
|
|
55
|
+
publicHost: raw.public_host ?? null,
|
|
56
|
+
zone: raw.zone ?? null,
|
|
57
|
+
metadata: raw.metadata && typeof raw.metadata === "object" ? { ...raw.metadata } : {},
|
|
58
|
+
createdAt: new Date(raw.created_at),
|
|
59
|
+
updatedAt: new Date(raw.updated_at),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function parseCreatedTunnel(raw) {
|
|
63
|
+
return { tunnel: parseTunnel(raw.tunnel), connectSecret: raw.connect_secret };
|
|
64
|
+
}
|
|
65
|
+
export function parseRotatedSecret(raw) {
|
|
66
|
+
return { connectSecret: raw.connect_secret };
|
|
67
|
+
}
|
|
68
|
+
export function parseSignedCert(raw) {
|
|
69
|
+
return {
|
|
70
|
+
certPem: raw.cert_pem,
|
|
71
|
+
chainPem: raw.chain_pem,
|
|
72
|
+
certFingerprintSha256: raw.cert_fingerprint_sha256,
|
|
73
|
+
certExpiresAt: new Date(raw.cert_expires_at),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tunnels/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,sCAA2B,CAAA;AAC7B,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,+CAA+B,CAAA;IAC/B,iCAAiB,CAAA;IACjB,mDAAmC,CAAA;AACrC,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,MAAM,sBAAsB,GAAiC;IAC3D,aAAa,EAAE,YAAY,CAAC,aAAa;IACzC,MAAM,EAAE,YAAY,CAAC,MAAM;IAC3B,cAAc,EAAE,YAAY,CAAC,eAAe;CAC7C,CAAC;AA8EF,SAAS,SAAS,CAAC,CAA4B;IAC7C,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAc;IACxC,MAAM,MAAM,GACV,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAK,GAAG,CAAC,MAAuB,CAAC;IACrE,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC;QAC3C,UAAU,EAA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AAkB;IAChD,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,QAAQ;QACrB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,qBAAqB,EAAE,GAAG,CAAC,uBAAuB;QAClD,aAAa,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC;KAC7C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkbox/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "TypeScript SDK for the Inkbox API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,22 +8,31 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./tunnels/connect": {
|
|
15
|
+
"types": "./dist/tunnels/client/index.d.ts",
|
|
16
|
+
"node": "./dist/tunnels/client/index.js"
|
|
13
17
|
}
|
|
14
18
|
},
|
|
15
19
|
"files": [
|
|
16
20
|
"dist",
|
|
21
|
+
"protocol",
|
|
17
22
|
"README.md"
|
|
18
23
|
],
|
|
19
24
|
"scripts": {
|
|
20
25
|
"build": "tsc",
|
|
21
26
|
"test": "vitest run",
|
|
22
27
|
"test:coverage": "vitest run --coverage",
|
|
28
|
+
"verify:bundle": "node scripts/verify-bundle.mjs",
|
|
23
29
|
"prepublishOnly": "npm run build"
|
|
24
30
|
},
|
|
25
31
|
"dependencies": {
|
|
26
|
-
"
|
|
32
|
+
"@peculiar/x509": "^2.0.0",
|
|
33
|
+
"hash-wasm": "^4.11.0",
|
|
34
|
+
"reflect-metadata": "^0.2.2",
|
|
35
|
+
"undici": "^7.0.0"
|
|
27
36
|
},
|
|
28
37
|
"devDependencies": {
|
|
29
38
|
"@types/node": "^25.5.0",
|
|
@@ -42,6 +51,6 @@
|
|
|
42
51
|
"url": "https://github.com/inkbox-ai/inkbox/issues"
|
|
43
52
|
},
|
|
44
53
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
54
|
+
"node": ">=22"
|
|
46
55
|
}
|
|
47
56
|
}
|