@inkbox/sdk 0.3.2 → 0.4.1
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 +71 -31
- package/dist/agent_identity.d.ts +28 -31
- package/dist/agent_identity.d.ts.map +1 -1
- package/dist/agent_identity.js +34 -58
- package/dist/agent_identity.js.map +1 -1
- package/dist/identities/exceptions.d.ts +35 -0
- package/dist/identities/exceptions.d.ts.map +1 -0
- package/dist/identities/exceptions.js +49 -0
- package/dist/identities/exceptions.js.map +1 -0
- package/dist/identities/resources/identities.d.ts +36 -25
- package/dist/identities/resources/identities.d.ts.map +1 -1
- package/dist/identities/resources/identities.js +61 -31
- package/dist/identities/resources/identities.js.map +1 -1
- package/dist/identities/types.d.ts +38 -12
- package/dist/identities/types.d.ts.map +1 -1
- package/dist/identities/types.js +13 -3
- package/dist/identities/types.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/inkbox.d.ts +26 -9
- package/dist/inkbox.d.ts.map +1 -1
- package/dist/inkbox.js +42 -27
- package/dist/inkbox.js.map +1 -1
- package/dist/mail/resources/mailboxes.d.ts +4 -28
- package/dist/mail/resources/mailboxes.d.ts.map +1 -1
- package/dist/mail/resources/mailboxes.js +4 -37
- package/dist/mail/resources/mailboxes.js.map +1 -1
- package/dist/mail/types.d.ts +4 -7
- package/dist/mail/types.d.ts.map +1 -1
- package/dist/mail/types.js +0 -1
- package/dist/mail/types.js.map +1 -1
- package/dist/phone/resources/smsOptIns.d.ts +37 -0
- package/dist/phone/resources/smsOptIns.d.ts.map +1 -0
- package/dist/phone/resources/smsOptIns.js +60 -0
- package/dist/phone/resources/smsOptIns.js.map +1 -0
- package/dist/phone/types.d.ts +47 -0
- package/dist/phone/types.d.ts.map +1 -1
- package/dist/phone/types.js +31 -0
- package/dist/phone/types.js.map +1 -1
- package/dist/tunnels/_reserved_names.d.ts +22 -0
- package/dist/tunnels/_reserved_names.d.ts.map +1 -0
- package/dist/tunnels/_reserved_names.js +149 -0
- package/dist/tunnels/_reserved_names.js.map +1 -0
- package/dist/tunnels/_validation.d.ts +16 -1
- package/dist/tunnels/_validation.d.ts.map +1 -1
- package/dist/tunnels/_validation.js +33 -8
- package/dist/tunnels/_validation.js.map +1 -1
- package/dist/tunnels/client/_protocol.d.ts +1 -1
- package/dist/tunnels/client/_protocol.js +1 -1
- package/dist/tunnels/client/_protocol.js.map +1 -1
- package/dist/tunnels/client/_runtime.d.ts +3 -2
- package/dist/tunnels/client/_runtime.d.ts.map +1 -1
- package/dist/tunnels/client/_runtime.js +7 -7
- package/dist/tunnels/client/_runtime.js.map +1 -1
- package/dist/tunnels/client/_state.d.ts +0 -13
- package/dist/tunnels/client/_state.d.ts.map +1 -1
- package/dist/tunnels/client/_state.js +0 -27
- package/dist/tunnels/client/_state.js.map +1 -1
- package/dist/tunnels/client/index.d.ts +13 -13
- package/dist/tunnels/client/index.d.ts.map +1 -1
- package/dist/tunnels/client/index.js +20 -65
- package/dist/tunnels/client/index.js.map +1 -1
- package/dist/tunnels/exceptions.d.ts +8 -6
- package/dist/tunnels/exceptions.d.ts.map +1 -1
- package/dist/tunnels/exceptions.js +12 -26
- package/dist/tunnels/exceptions.js.map +1 -1
- package/dist/tunnels/resources/tunnels.d.ts +9 -38
- package/dist/tunnels/resources/tunnels.d.ts.map +1 -1
- package/dist/tunnels/resources/tunnels.js +10 -92
- package/dist/tunnels/resources/tunnels.js.map +1 -1
- package/dist/tunnels/types.d.ts +17 -33
- package/dist/tunnels/types.d.ts.map +1 -1
- package/dist/tunnels/types.js +13 -23
- package/dist/tunnels/types.js.map +1 -1
- package/package.json +1 -1
- package/protocol/tunnel_protocol_constants.json +1 -1
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
* (`@inkbox/sdk`) stays browser-safe; only this subpath gates on Node.
|
|
13
13
|
*/
|
|
14
14
|
import { POOL_SIZE_MAX, POOL_SIZE_MIN } from "../resources/tunnels.js";
|
|
15
|
-
import {
|
|
15
|
+
import { TunnelNotProvisioned, TunnelRemoved, TunnelStateConflict, } from "../exceptions.js";
|
|
16
16
|
import { validateTunnelName } from "../_validation.js";
|
|
17
|
-
import { TLSMode
|
|
17
|
+
import { TLSMode } from "../types.js";
|
|
18
18
|
import { validateForwardTarget, } from "./_validation.js";
|
|
19
|
-
import { defaultStateDir, ensurePrivateStateDir, loadState,
|
|
19
|
+
import { defaultStateDir, ensurePrivateStateDir, loadState, saveState, } from "./_state.js";
|
|
20
20
|
import { TunnelListenerImpl, } from "./_listener.js";
|
|
21
21
|
import { DEFAULT_INBOUND_BODY_BYTES, DEFAULT_OUTBOUND_BODY_BYTES, TunnelRuntime, } from "./_runtime.js";
|
|
22
22
|
export { ForwardTargetRefused, validateEnvelopePath, validateForwardTarget, } from "./_validation.js";
|
|
@@ -30,7 +30,7 @@ export const PROD_ZONE = "inkboxwire.com";
|
|
|
30
30
|
* `wsHandler` set without an HTTP path.
|
|
31
31
|
*
|
|
32
32
|
* Validation runs synchronously before any control-plane writes: a
|
|
33
|
-
* tunnel is never
|
|
33
|
+
* tunnel is never opened for an invalid configuration.
|
|
34
34
|
*/
|
|
35
35
|
export class InvalidConnectOptions extends Error {
|
|
36
36
|
constructor(message) {
|
|
@@ -38,6 +38,7 @@ export class InvalidConnectOptions extends Error {
|
|
|
38
38
|
this.name = "InvalidConnectOptions";
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
export { TunnelNotProvisioned } from "../exceptions.js";
|
|
41
42
|
function validatePoolSize(poolSize) {
|
|
42
43
|
if (poolSize === undefined)
|
|
43
44
|
return;
|
|
@@ -67,15 +68,17 @@ function validateDispatchOptions(opts) {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
function resolveZoneAndHost(opts) {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
opts.serverZone ??
|
|
73
|
-
opts.state?.zone ??
|
|
74
|
-
PROD_ZONE;
|
|
75
|
-
return { zone, publicHost };
|
|
71
|
+
const zone = opts.dataPlaneZoneOverride ?? opts.serverZone;
|
|
72
|
+
return { zone, publicHost: opts.serverPublicHost };
|
|
76
73
|
}
|
|
77
74
|
/**
|
|
78
75
|
* Bring a tunnel online from this Node process.
|
|
76
|
+
*
|
|
77
|
+
* The tunnel must already exist in the calling org (provisioned by
|
|
78
|
+
* `inkbox.createIdentity(...)`). Data-plane authentication uses the
|
|
79
|
+
* same API key the `inkbox` client was constructed with — an
|
|
80
|
+
* identity-scoped key must match the tunnel's identity, or an
|
|
81
|
+
* admin-scoped key in the same org.
|
|
79
82
|
*/
|
|
80
83
|
export async function connect(inkbox, options) {
|
|
81
84
|
// --- Synchronous validation (cheap; runs before any disk or server I/O) ---
|
|
@@ -87,17 +90,9 @@ export async function connect(inkbox, options) {
|
|
|
87
90
|
allowRemoteForwarding: options.allowRemoteForwarding,
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
|
-
const tlsMode = (typeof options.tlsMode === "string"
|
|
91
|
-
? options.tlsMode
|
|
92
|
-
: options.tlsMode) ?? TLSMode.EDGE;
|
|
93
|
-
// Passthrough accepts both http:// and https:// forwardTo URLs.
|
|
94
|
-
// UpstreamUrlDispatch builds undici's tls.connect options from
|
|
95
|
-
// forwardToVerifyTls / forwardToCaBundle for https:// upstreams.
|
|
96
|
-
const onPendingRemoval = options.onPendingRemoval ?? "auto_restore";
|
|
97
93
|
const stateDirPath = options.stateDir ?? defaultStateDir(options.name);
|
|
98
94
|
ensurePrivateStateDir(stateDirPath);
|
|
99
95
|
const state = loadState(stateDirPath);
|
|
100
|
-
let secret = options.secret ?? state?.secret ?? null;
|
|
101
96
|
let tunnel = null;
|
|
102
97
|
if (state?.tunnelId) {
|
|
103
98
|
try {
|
|
@@ -107,7 +102,7 @@ export async function connect(inkbox, options) {
|
|
|
107
102
|
const apiErr = err;
|
|
108
103
|
if (apiErr?.statusCode === 404) {
|
|
109
104
|
throw new TunnelRemoved(`tunnel ${options.name} (id=${state.tunnelId}) has been removed; ` +
|
|
110
|
-
`clear ${stateDirPath} and call inkbox.
|
|
105
|
+
`clear ${stateDirPath} and call inkbox.createIdentity(${JSON.stringify(options.name)}) to start fresh`);
|
|
111
106
|
}
|
|
112
107
|
throw err;
|
|
113
108
|
}
|
|
@@ -117,47 +112,9 @@ export async function connect(inkbox, options) {
|
|
|
117
112
|
tunnel = list.find((t) => t.tunnelName === options.name) ?? null;
|
|
118
113
|
}
|
|
119
114
|
if (!tunnel) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
description: options.description,
|
|
124
|
-
});
|
|
125
|
-
tunnel = created.tunnel;
|
|
126
|
-
secret = created.connectSecret;
|
|
127
|
-
saveState(stateDirPath, {
|
|
128
|
-
tunnelId: tunnel.id,
|
|
129
|
-
name: options.name,
|
|
130
|
-
secret,
|
|
131
|
-
mode: tlsMode,
|
|
132
|
-
zone: tunnel.zone,
|
|
133
|
-
publicHost: tunnel.publicHost,
|
|
134
|
-
});
|
|
135
|
-
printSecretOnce({
|
|
136
|
-
secret,
|
|
137
|
-
statePath: `${stateDirPath}/state.json`,
|
|
138
|
-
printToStderr: options.printSecretToStderr ?? null,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
if (tunnel.tlsMode !== tlsMode) {
|
|
143
|
-
throw new TunnelStateConflict(409, `tls_mode mismatch: requested ${tlsMode} but tunnel reports ${tunnel.tlsMode}. ` +
|
|
144
|
-
"tls_mode is fixed at creation; delete the tunnel and recreate to change it.");
|
|
145
|
-
}
|
|
146
|
-
if (tunnel.status === TunnelStatus.PENDING_REMOVAL) {
|
|
147
|
-
if (onPendingRemoval === "error") {
|
|
148
|
-
throw new TunnelStateConflict(409, `tunnel ${options.name} is in pending_removal; pass ` +
|
|
149
|
-
"onPendingRemoval: 'auto_restore' to bring it back");
|
|
150
|
-
}
|
|
151
|
-
if (!secret) {
|
|
152
|
-
throw new TunnelSecretUnavailable(`connect_secret not available locally for tunnel ${options.name}; ` +
|
|
153
|
-
"pass secret explicitly, or rotate via inkbox.tunnels.rotateSecret(id) first.");
|
|
154
|
-
}
|
|
155
|
-
tunnel = await inkbox.tunnels.restore(tunnel.id);
|
|
156
|
-
}
|
|
157
|
-
if (!secret) {
|
|
158
|
-
throw new TunnelSecretUnavailable(`connect_secret not available locally for tunnel ${options.name}; ` +
|
|
159
|
-
"pass secret explicitly, or rotate via inkbox.tunnels.rotateSecret(id) first.");
|
|
160
|
-
}
|
|
115
|
+
throw new TunnelNotProvisioned(`no tunnel named ${JSON.stringify(options.name)} exists in this org. ` +
|
|
116
|
+
"Tunnels are provisioned atomically by inkbox.createIdentity(<handle>); " +
|
|
117
|
+
`call inkbox.createIdentity(${JSON.stringify(options.name)}) first.`);
|
|
161
118
|
}
|
|
162
119
|
// For passthrough, lazy-load _cert.ts so the edge-mode bundle stays
|
|
163
120
|
// clean of @peculiar/x509. The dynamic import keeps the dep out of
|
|
@@ -171,9 +128,8 @@ export async function connect(inkbox, options) {
|
|
|
171
128
|
const cert = await import("./_cert.js");
|
|
172
129
|
const tls = await import("./_tls.js");
|
|
173
130
|
const keypair = await cert.loadOrCreateKeypair(stateDirPath);
|
|
174
|
-
const tunnelPublicHost = tunnel.publicHost ?? `${options.name}.${PROD_ZONE}`;
|
|
175
131
|
if (await cert.certNeedsSign(stateDirPath, keypair)) {
|
|
176
|
-
const csrPem = await cert.buildCsr(keypair,
|
|
132
|
+
const csrPem = await cert.buildCsr(keypair, tunnel.publicHost);
|
|
177
133
|
const signed = await inkbox.tunnels.signCsr(tunnel.id, { csrPem });
|
|
178
134
|
cert.writeCertChain(stateDirPath, signed.certPem, signed.chainPem);
|
|
179
135
|
}
|
|
@@ -199,20 +155,18 @@ export async function connect(inkbox, options) {
|
|
|
199
155
|
name: options.name,
|
|
200
156
|
serverZone: tunnel.zone,
|
|
201
157
|
serverPublicHost: tunnel.publicHost,
|
|
202
|
-
state,
|
|
203
158
|
dataPlaneZoneOverride: options.dataPlaneZone ?? null,
|
|
204
159
|
});
|
|
205
160
|
saveState(stateDirPath, {
|
|
206
161
|
tunnelId: tunnel.id,
|
|
207
162
|
name: options.name,
|
|
208
|
-
secret,
|
|
209
163
|
mode: tunnel.tlsMode,
|
|
210
164
|
zone,
|
|
211
165
|
publicHost,
|
|
212
166
|
});
|
|
213
167
|
const runtime = new TunnelRuntime({
|
|
214
168
|
tunnelId: tunnel.id,
|
|
215
|
-
|
|
169
|
+
apiKey: inkbox._apiKey,
|
|
216
170
|
zone,
|
|
217
171
|
publicHost,
|
|
218
172
|
poolSize: options.poolSize ?? null,
|
|
@@ -239,4 +193,5 @@ export async function connect(inkbox, options) {
|
|
|
239
193
|
listenerOpts,
|
|
240
194
|
});
|
|
241
195
|
}
|
|
196
|
+
void TunnelStateConflict; // retained for re-export breadth on the surviving surface
|
|
242
197
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tunnels/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tunnels/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAU,MAAM,aAAa,CAAC;AAC9C,OAAO,EAGL,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,eAAe,EACf,qBAAqB,EACr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CAAC;AACL,CAAC;AAED,KAAK,mBAAmB,CAAC,CAAC,0DAA0D"}
|
|
@@ -10,22 +10,24 @@ export declare class TunnelError extends InkboxError {
|
|
|
10
10
|
export declare class TunnelNameInvalid extends TunnelError {
|
|
11
11
|
constructor(message: string);
|
|
12
12
|
}
|
|
13
|
-
export declare class TunnelSecretUnavailable extends TunnelError {
|
|
14
|
-
constructor(message: string);
|
|
15
|
-
}
|
|
16
13
|
export declare class TunnelRemoved extends TunnelError {
|
|
17
14
|
constructor(message: string);
|
|
18
15
|
}
|
|
19
16
|
export declare class TunnelStateConflict extends InkboxAPIError {
|
|
20
17
|
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
21
18
|
}
|
|
22
|
-
export declare class TunnelNameUnavailable extends InkboxAPIError {
|
|
23
|
-
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
24
|
-
}
|
|
25
19
|
export declare class TunnelTLSModeMismatch extends InkboxAPIError {
|
|
26
20
|
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
27
21
|
}
|
|
28
22
|
export declare class TunnelCSRStateConflict extends TunnelStateConflict {
|
|
29
23
|
constructor(statusCode: number, detail: InkboxAPIErrorDetail);
|
|
30
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Raised by `connect()` when no tunnel exists for the supplied name in
|
|
27
|
+
* the calling org. Tunnels are provisioned atomically as part of
|
|
28
|
+
* `inkbox.createIdentity(...)`; they have no standalone create surface.
|
|
29
|
+
*/
|
|
30
|
+
export declare class TunnelNotProvisioned extends TunnelError {
|
|
31
|
+
constructor(message: string);
|
|
32
|
+
}
|
|
31
33
|
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -1 +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,
|
|
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,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,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,sBAAuB,SAAQ,mBAAmB;gBACjD,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB;CAI7D;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -16,41 +16,16 @@ export class TunnelNameInvalid extends TunnelError {
|
|
|
16
16
|
this.name = "TunnelNameInvalid";
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
export class TunnelSecretUnavailable extends TunnelError {
|
|
20
|
-
constructor(message) {
|
|
21
|
-
super(message);
|
|
22
|
-
this.name = "TunnelSecretUnavailable";
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
19
|
export class TunnelRemoved extends TunnelError {
|
|
26
20
|
constructor(message) {
|
|
27
21
|
super(message);
|
|
28
22
|
this.name = "TunnelRemoved";
|
|
29
23
|
}
|
|
30
24
|
}
|
|
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
25
|
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
26
|
constructor(statusCode, detail) {
|
|
52
27
|
super(statusCode, detail);
|
|
53
|
-
this.name = "
|
|
28
|
+
this.name = "TunnelStateConflict";
|
|
54
29
|
}
|
|
55
30
|
}
|
|
56
31
|
export class TunnelTLSModeMismatch extends InkboxAPIError {
|
|
@@ -65,4 +40,15 @@ export class TunnelCSRStateConflict extends TunnelStateConflict {
|
|
|
65
40
|
this.name = "TunnelCSRStateConflict";
|
|
66
41
|
}
|
|
67
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Raised by `connect()` when no tunnel exists for the supplied name in
|
|
45
|
+
* the calling org. Tunnels are provisioned atomically as part of
|
|
46
|
+
* `inkbox.createIdentity(...)`; they have no standalone create surface.
|
|
47
|
+
*/
|
|
48
|
+
export class TunnelNotProvisioned extends TunnelError {
|
|
49
|
+
constructor(message) {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = "TunnelNotProvisioned";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
68
54
|
//# sourceMappingURL=exceptions.js.map
|
|
@@ -1 +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,
|
|
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,aAAc,SAAQ,WAAW;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,YAAY,UAAkB,EAAE,MAA4B;QAC1D,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,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;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* inkbox-tunnels/resources/tunnels.ts
|
|
3
3
|
*
|
|
4
|
-
* Control-plane
|
|
4
|
+
* Control-plane reads + update + sign-csr for tunnels. Tunnels are
|
|
5
|
+
* created and deleted exclusively via identity-create / identity-delete
|
|
6
|
+
* cascades; there is no standalone create / delete / restore /
|
|
7
|
+
* force-delete / rotate-secret surface.
|
|
5
8
|
*/
|
|
6
9
|
import { HttpTransport } from "../../_http.js";
|
|
7
|
-
import {
|
|
10
|
+
import { SignedCert, Tunnel } from "../types.js";
|
|
8
11
|
export declare const POOL_SIZE_MIN = 1;
|
|
9
12
|
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
13
|
export interface UpdateTunnelOptions {
|
|
16
|
-
/** Pass `null` to clear; omit to leave unchanged. */
|
|
17
|
-
description?: string | null;
|
|
18
14
|
/**
|
|
19
15
|
* Pass `{}` or `null` to clear (the server's column is non-nullable
|
|
20
16
|
* and collapses both forms to `{}`); omit to leave unchanged.
|
|
@@ -27,38 +23,13 @@ export declare class TunnelsResource {
|
|
|
27
23
|
list(): Promise<Tunnel[]>;
|
|
28
24
|
get(tunnelId: string): Promise<Tunnel>;
|
|
29
25
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
create(options: CreateTunnelOptions): Promise<CreatedTunnel>;
|
|
34
|
-
/**
|
|
35
|
-
* Update a tunnel. Pass only the fields you want to change.
|
|
26
|
+
* Update a tunnel's metadata. `metadata` is the only mutable field;
|
|
27
|
+
* other tunnel attributes are derived from the owning identity.
|
|
36
28
|
*
|
|
37
|
-
* - `
|
|
38
|
-
* -
|
|
39
|
-
* (rejected client-side); pass `{}` to clear.
|
|
29
|
+
* - `metadata: {}` (or `null`) clears the metadata bag. The server
|
|
30
|
+
* column is non-nullable and collapses both forms to `{}`.
|
|
40
31
|
*/
|
|
41
32
|
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
33
|
/**
|
|
63
34
|
* Sign a CSR for a passthrough tunnel.
|
|
64
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnels.d.ts","sourceRoot":"","sources":["../../../src/tunnels/resources/tunnels.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tunnels.d.ts","sourceRoot":"","sources":["../../../src/tunnels/resources/tunnels.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAK/D,OAAO,EAGL,UAAU,EACV,MAAM,EAGP,MAAM,aAAa,CAAC;AAMrB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,aAAa,KAAK,CAAC;AAoBhC,MAAM,WAAW,mBAAmB;IAClC;;;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;;;;;;OAMG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAe7E;;;;;;OAMG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAalF"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* inkbox-tunnels/resources/tunnels.ts
|
|
3
3
|
*
|
|
4
|
-
* Control-plane
|
|
4
|
+
* Control-plane reads + update + sign-csr for tunnels. Tunnels are
|
|
5
|
+
* created and deleted exclusively via identity-create / identity-delete
|
|
6
|
+
* cascades; there is no standalone create / delete / restore /
|
|
7
|
+
* force-delete / rotate-secret surface.
|
|
5
8
|
*/
|
|
6
9
|
import { InkboxAPIError } from "../../_http.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { TLSMode, parseCreatedTunnel, parseRotatedSecret, parseSignedCert, parseTunnel, } from "../types.js";
|
|
10
|
+
import { TunnelCSRStateConflict, TunnelTLSModeMismatch, } from "../exceptions.js";
|
|
11
|
+
import { parseSignedCert, parseTunnel, } from "../types.js";
|
|
10
12
|
const BASE = "/tunnels";
|
|
11
13
|
const SIGN_CSR_TIMEOUT_MS = 180_000;
|
|
12
14
|
export const POOL_SIZE_MIN = 1;
|
|
@@ -21,18 +23,6 @@ function detailText(detail) {
|
|
|
21
23
|
}
|
|
22
24
|
return String(detail);
|
|
23
25
|
}
|
|
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
26
|
function mapSignCsrError(err) {
|
|
37
27
|
if (err.statusCode !== 409)
|
|
38
28
|
return err;
|
|
@@ -59,40 +49,14 @@ export class TunnelsResource {
|
|
|
59
49
|
}
|
|
60
50
|
// --- Writes ----------------------------------------------------------
|
|
61
51
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
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.
|
|
52
|
+
* Update a tunnel's metadata. `metadata` is the only mutable field;
|
|
53
|
+
* other tunnel attributes are derived from the owning identity.
|
|
86
54
|
*
|
|
87
|
-
* - `
|
|
88
|
-
* -
|
|
89
|
-
* (rejected client-side); pass `{}` to clear.
|
|
55
|
+
* - `metadata: {}` (or `null`) clears the metadata bag. The server
|
|
56
|
+
* column is non-nullable and collapses both forms to `{}`.
|
|
90
57
|
*/
|
|
91
58
|
async update(tunnelId, options) {
|
|
92
59
|
const body = {};
|
|
93
|
-
if ("description" in options) {
|
|
94
|
-
body.description = options.description;
|
|
95
|
-
}
|
|
96
60
|
if ("metadata" in options) {
|
|
97
61
|
const m = options.metadata;
|
|
98
62
|
if (m !== null && m !== undefined) {
|
|
@@ -105,52 +69,6 @@ export class TunnelsResource {
|
|
|
105
69
|
const data = await this.http.patch(`${BASE}/${tunnelId}`, body);
|
|
106
70
|
return parseTunnel(data);
|
|
107
71
|
}
|
|
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
72
|
/**
|
|
155
73
|
* Sign a CSR for a passthrough tunnel.
|
|
156
74
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnels.js","sourceRoot":"","sources":["../../../src/tunnels/resources/tunnels.ts"],"names":[],"mappings":"A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D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAY,GAAG,IAAI,IAAI,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;QAC3E,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,OAA2B;QACzD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAC/B,GAAG,IAAI,IAAI,QAAQ,WAAW,EAC9B,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,EAC3B,EAAE,SAAS,EAAE,mBAAmB,EAAE,CACnC,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,cAAc;gBAAE,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;YAC9D,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
package/dist/tunnels/types.d.ts
CHANGED
|
@@ -13,46 +13,41 @@ export declare enum TLSMode {
|
|
|
13
13
|
* - `awaiting_cert`: passthrough-only intermediate state. Inbound TLS
|
|
14
14
|
* will fail until you call `tunnels.signCsr(...)`.
|
|
15
15
|
* - `active`: routable end-to-end.
|
|
16
|
-
* - `
|
|
17
|
-
*
|
|
18
|
-
* tunnel
|
|
19
|
-
* point a `GET` for the tunnel id returns 404; `TunnelRemoved`
|
|
20
|
-
* surfaces that condition for clients holding stale state.
|
|
16
|
+
* - `deleted`: terminal. The tunnel is offline. Tunnels are deleted
|
|
17
|
+
* exclusively via the identity-delete cascade — there is no direct
|
|
18
|
+
* tunnel-delete surface.
|
|
21
19
|
*/
|
|
22
20
|
export declare enum TunnelStatus {
|
|
23
21
|
AWAITING_CERT = "awaiting_cert",
|
|
24
22
|
ACTIVE = "active",
|
|
25
|
-
|
|
23
|
+
DELETED = "deleted"
|
|
26
24
|
}
|
|
27
25
|
export interface Tunnel {
|
|
28
26
|
id: string;
|
|
29
27
|
organizationId: string;
|
|
30
28
|
tunnelName: string;
|
|
31
|
-
description: string | null;
|
|
32
29
|
tlsMode: TLSMode;
|
|
33
30
|
certPem: string | null;
|
|
34
31
|
certFingerprintSha256: string | null;
|
|
35
32
|
certExpiresAt: Date | null;
|
|
36
|
-
|
|
33
|
+
/**
|
|
34
|
+
* One of the known {@link TunnelStatus} values, or — if the server
|
|
35
|
+
* returns a status the SDK doesn't recognize — the raw string. Future
|
|
36
|
+
* statuses survive parsing without fail-open coercion; callers should
|
|
37
|
+
* handle a `string` default branch alongside the enum cases.
|
|
38
|
+
*/
|
|
39
|
+
status: TunnelStatus | string;
|
|
37
40
|
lastConnectedAt: Date | null;
|
|
38
41
|
lastConnectedIpAddr: string | null;
|
|
39
|
-
restoreDeadlineAt: Date | null;
|
|
40
42
|
currentlyConnected: boolean;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
/** Customer-facing hostname — e.g. `my-agent.inkboxwire.com` in production. Lower environments use a different tunnel zone. Non-null for live tunnels. */
|
|
44
|
+
publicHost: string;
|
|
45
|
+
/** Zone endpoint for the data-plane. Agents connect to `https://{zone}/_system/connect`. In production this is `inkboxwire.com`; lower environments use a different zone. Non-null for live tunnels. */
|
|
46
|
+
zone: string;
|
|
43
47
|
metadata: Record<string, unknown>;
|
|
44
48
|
createdAt: Date;
|
|
45
49
|
updatedAt: Date;
|
|
46
50
|
}
|
|
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
51
|
export interface SignedCert {
|
|
57
52
|
certPem: string;
|
|
58
53
|
chainPem: string;
|
|
@@ -63,7 +58,6 @@ export interface RawTunnel {
|
|
|
63
58
|
id: string;
|
|
64
59
|
organization_id: string;
|
|
65
60
|
tunnel_name: string;
|
|
66
|
-
description: string | null;
|
|
67
61
|
tls_mode: string;
|
|
68
62
|
cert_pem: string | null;
|
|
69
63
|
cert_fingerprint_sha256: string | null;
|
|
@@ -71,21 +65,13 @@ export interface RawTunnel {
|
|
|
71
65
|
status: string;
|
|
72
66
|
last_connected_at: string | null;
|
|
73
67
|
last_connected_ip_addr: string | null;
|
|
74
|
-
restore_deadline_at: string | null;
|
|
75
68
|
currently_connected: boolean;
|
|
76
|
-
public_host
|
|
77
|
-
zone
|
|
69
|
+
public_host: string;
|
|
70
|
+
zone: string;
|
|
78
71
|
metadata?: Record<string, unknown> | null;
|
|
79
72
|
created_at: string;
|
|
80
73
|
updated_at: string;
|
|
81
74
|
}
|
|
82
|
-
export interface RawCreatedTunnel {
|
|
83
|
-
tunnel: RawTunnel;
|
|
84
|
-
connect_secret: string;
|
|
85
|
-
}
|
|
86
|
-
export interface RawRotatedSecret {
|
|
87
|
-
connect_secret: string;
|
|
88
|
-
}
|
|
89
75
|
export interface RawSignedCert {
|
|
90
76
|
cert_pem: string;
|
|
91
77
|
chain_pem: string;
|
|
@@ -93,7 +79,5 @@ export interface RawSignedCert {
|
|
|
93
79
|
cert_expires_at: string;
|
|
94
80
|
}
|
|
95
81
|
export declare function parseTunnel(raw: RawTunnel): Tunnel;
|
|
96
|
-
export declare function parseCreatedTunnel(raw: RawCreatedTunnel): CreatedTunnel;
|
|
97
|
-
export declare function parseRotatedSecret(raw: RawRotatedSecret): RotatedSecret;
|
|
98
82
|
export declare function parseSignedCert(raw: RawSignedCert): SignedCert;
|
|
99
83
|
//# sourceMappingURL=types.d.ts.map
|