@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
package/README.md
CHANGED
|
@@ -127,18 +127,27 @@ console.log(status.restrictions.maxSendsPerDay); // 10 (unclaimed) or 500 (cl
|
|
|
127
127
|
|
|
128
128
|
```ts
|
|
129
129
|
// Create and fully provision an identity
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
// createIdentity atomically provisions the mailbox AND the tunnel —
|
|
131
|
+
// both come back on the response. Phone numbers stay opt-in.
|
|
132
|
+
const identity = await inkbox.createIdentity("sales-bot", {
|
|
133
|
+
displayName: "Sales Bot",
|
|
134
|
+
description: "Sales-outreach agent",
|
|
135
|
+
});
|
|
136
|
+
const phone = await identity.provisionPhoneNumber({ type: "toll_free" });
|
|
132
137
|
|
|
133
|
-
console.log(identity.emailAddress);
|
|
138
|
+
console.log(identity.emailAddress); // sales-bot@inkboxmail.com
|
|
139
|
+
console.log(identity.tunnel?.publicHost); // sales-bot.inkboxwire.com
|
|
134
140
|
console.log(phone.number);
|
|
135
141
|
|
|
136
142
|
// Pin the identity's mailbox to a verified custom sending domain
|
|
137
143
|
// (bare name; see "Custom Sending Domains" below).
|
|
138
|
-
await inkbox.createIdentity("sales-bot", { sendingDomain: "mail.acme.com" });
|
|
144
|
+
await inkbox.createIdentity("sales-bot-2", { sendingDomain: "mail.acme.com" });
|
|
145
|
+
|
|
146
|
+
// Provision a passthrough tunnel (tls_mode is fixed at create time)
|
|
147
|
+
await inkbox.createIdentity("sales-bot-pt", { tunnel: { tlsMode: "passthrough" } });
|
|
139
148
|
|
|
140
|
-
// Link an existing
|
|
141
|
-
|
|
149
|
+
// Link an existing phone number to an identity (mailbox + tunnel are
|
|
150
|
+
// 1:1 with their identity and cannot be relinked).
|
|
142
151
|
await identity.assignPhoneNumber("phone-number-uuid-here");
|
|
143
152
|
|
|
144
153
|
// Get an existing identity (returned with current channel state)
|
|
@@ -152,8 +161,8 @@ const allIdentities = await inkbox.listIdentities();
|
|
|
152
161
|
await identity.update({ status: "paused" });
|
|
153
162
|
await identity.update({ newHandle: "sales-bot-v2" });
|
|
154
163
|
|
|
155
|
-
// Unlink
|
|
156
|
-
|
|
164
|
+
// Unlink phone number (without releasing it). Mailbox is 1:1 with the
|
|
165
|
+
// identity and cannot be unlinked — delete the identity instead.
|
|
157
166
|
await identity.unlinkPhoneNumber();
|
|
158
167
|
|
|
159
168
|
// Delete
|
|
@@ -229,7 +238,7 @@ for (const m of thread.messages) {
|
|
|
229
238
|
```ts
|
|
230
239
|
// Place an outbound call — stream audio over WebSocket
|
|
231
240
|
const call = await identity.placeCall({
|
|
232
|
-
toNumber: "+
|
|
241
|
+
toNumber: "+15551234567",
|
|
233
242
|
clientWebsocketUrl: "wss://your-agent.example.com/ws",
|
|
234
243
|
});
|
|
235
244
|
console.log(call.status, call.rateLimit.callsRemaining);
|
|
@@ -279,7 +288,7 @@ Send and receive SMS/MMS through the identity's assigned phone number.
|
|
|
279
288
|
- Outbound SMS is currently allowed only from **local** numbers, not toll-free.
|
|
280
289
|
- Each sender phone number is rate-limited to **15 outbound texts per rolling 24-hour window**.
|
|
281
290
|
- A new local number takes **~10-15 minutes** for the 10DLC campaign to propagate at the carrier — `phoneNumber.smsStatus` reads `"pending"` until then, and sends will return `409 sender_sms_pending`.
|
|
282
|
-
- The recipient must have texted **`START`** to any number within your organization to opt in. Unknown recipients will fail with `403 recipient_not_opted_in`; recipients who later send `STOP` flip to `403 recipient_opted_out`.
|
|
291
|
+
- The recipient must have texted **`START`** to any number within your organization to opt in. Unknown recipients will fail with `403 recipient_not_opted_in`; recipients who later send `STOP` flip to `403 recipient_opted_out`. You can inspect consent state directly via `inkbox.smsOptIns` — see [SMS Opt-Ins](#sms-opt-ins).
|
|
283
292
|
|
|
284
293
|
**Coming soon:**
|
|
285
294
|
|
|
@@ -290,7 +299,7 @@ Send and receive SMS/MMS through the identity's assigned phone number.
|
|
|
290
299
|
// Send an SMS. Returns a queued TextMessage; final delivery state arrives
|
|
291
300
|
// via the incomingTextWebhookUrl configured on the sender.
|
|
292
301
|
const sent = await identity.sendText({
|
|
293
|
-
to: "+
|
|
302
|
+
to: "+15551234567",
|
|
294
303
|
text: "Hello from Inkbox",
|
|
295
304
|
});
|
|
296
305
|
console.log(sent.id, sent.deliveryStatus); // "queued"
|
|
@@ -320,11 +329,11 @@ for (const c of convos) {
|
|
|
320
329
|
}
|
|
321
330
|
|
|
322
331
|
// Get messages in a specific conversation
|
|
323
|
-
const msgs = await identity.getTextConversation("+
|
|
332
|
+
const msgs = await identity.getTextConversation("+15551234567", { limit: 50 });
|
|
324
333
|
|
|
325
334
|
// Mark as read
|
|
326
335
|
await identity.markTextRead("text-uuid");
|
|
327
|
-
await identity.markTextConversationRead("+
|
|
336
|
+
await identity.markTextConversationRead("+15551234567");
|
|
328
337
|
|
|
329
338
|
// Org-level: search and delete
|
|
330
339
|
const results = await inkbox.texts.search(phone.id, { q: "invoice", limit: 20 });
|
|
@@ -333,6 +342,41 @@ await inkbox.texts.update(phone.id, "text-uuid", { status: "deleted" });
|
|
|
333
342
|
|
|
334
343
|
---
|
|
335
344
|
|
|
345
|
+
## SMS Opt-Ins
|
|
346
|
+
|
|
347
|
+
Per-recipient SMS consent state, keyed by `(your org, recipient number)`. The
|
|
348
|
+
registry is updated automatically when recipients text `START` / `STOP` to any
|
|
349
|
+
of your numbers (`source: "sms"`).
|
|
350
|
+
|
|
351
|
+
**Reads** — open to admin API keys and Clerk JWT.
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
import { SmsOptInStatus } from "@inkbox/sdk";
|
|
355
|
+
|
|
356
|
+
// List the org's consent rows (newest-updated first; server caps limit at 200)
|
|
357
|
+
const rows = await inkbox.smsOptIns.list({ limit: 50 });
|
|
358
|
+
const optedOut = await inkbox.smsOptIns.list({ status: SmsOptInStatus.OPTED_OUT });
|
|
359
|
+
|
|
360
|
+
// Look up one recipient — 404 → InkboxAPIError if no row exists
|
|
361
|
+
const row = await inkbox.smsOptIns.get("+15551234567");
|
|
362
|
+
console.log(row.status, row.source, row.optedInAt, row.optedOutAt);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**Writes** — admin-only, and only if your org runs its own active, customer-managed 10DLC
|
|
366
|
+
campaign. Orgs on the Inkbox-default campaign share consent state and get a
|
|
367
|
+
`409 customer_campaign_required` on write attempts. Writes record an audit
|
|
368
|
+
event with `source: "api"`.
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
// Record consent captured outside of STOP/START (signup form, paper waiver, etc.)
|
|
372
|
+
await inkbox.smsOptIns.optIn("+15551234567");
|
|
373
|
+
|
|
374
|
+
// Honor an opt-out collected outside of inbound STOP
|
|
375
|
+
await inkbox.smsOptIns.optOut("+15551234567");
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
336
380
|
## Credentials
|
|
337
381
|
|
|
338
382
|
Access credentials stored in the vault through the agent-facing `credentials` surface. The vault must be unlocked first.
|
|
@@ -538,7 +582,7 @@ const call = await inkbox.calls.get("phone-number-uuid", "call-uuid");
|
|
|
538
582
|
// Place an outbound call
|
|
539
583
|
const placed = await inkbox.calls.place({
|
|
540
584
|
fromNumber: "phone-number-uuid",
|
|
541
|
-
toNumber: "+
|
|
585
|
+
toNumber: "+15551234567",
|
|
542
586
|
clientWebsocketUrl: "wss://example.com/ws",
|
|
543
587
|
});
|
|
544
588
|
|
|
@@ -553,31 +597,26 @@ for (const t of segments) {
|
|
|
553
597
|
|
|
554
598
|
## Org-level Mailboxes
|
|
555
599
|
|
|
556
|
-
|
|
600
|
+
Mailboxes are provisioned atomically by `inkbox.createIdentity(...)` and
|
|
601
|
+
removed by `identity.delete()` (cascade). The `inkbox.mailboxes`
|
|
602
|
+
surface is read + update + search only.
|
|
557
603
|
|
|
558
604
|
```ts
|
|
559
605
|
// List all mailboxes in the organisation
|
|
560
606
|
const mailboxes = await inkbox.mailboxes.list();
|
|
561
607
|
|
|
562
608
|
// Get a specific mailbox
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
// Create a mailbox linked to an agent identity
|
|
566
|
-
const mb = await inkbox.mailboxes.create({
|
|
567
|
-
agentHandle: "support-agent",
|
|
568
|
-
displayName: "Support Inbox",
|
|
569
|
-
});
|
|
609
|
+
const mb = await inkbox.mailboxes.get("abc-xyz@inkboxmail.com");
|
|
570
610
|
console.log(mb.emailAddress);
|
|
571
611
|
console.log(mb.sendingDomain); // bare domain the mailbox sends from
|
|
612
|
+
console.log(mb.agentIdentityId); // non-null for live customer mailboxes (1:1 invariant)
|
|
572
613
|
|
|
573
|
-
//
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
// Update display name or webhook URL
|
|
578
|
-
await inkbox.mailboxes.update(mb.emailAddress, { displayName: "New Name" });
|
|
614
|
+
// Update webhook URL or filter mode. Note: display_name has moved to
|
|
615
|
+
// the agent identity — set it via identity.update({ displayName: ... }).
|
|
616
|
+
// The mailbox PATCH endpoint hard-rejects display_name with a 422.
|
|
579
617
|
await inkbox.mailboxes.update(mb.emailAddress, { webhookUrl: "https://example.com/hook" });
|
|
580
618
|
await inkbox.mailboxes.update(mb.emailAddress, { webhookUrl: null }); // remove webhook
|
|
619
|
+
await inkbox.mailboxes.update(mb.emailAddress, { filterMode: "whitelist" }); // admin-scoped key only
|
|
581
620
|
|
|
582
621
|
// Full-text search across messages in a mailbox
|
|
583
622
|
const results = await inkbox.mailboxes.search(mb.emailAddress, { q: "invoice", limit: 20 });
|
|
@@ -585,15 +624,16 @@ for (const msg of results) {
|
|
|
585
624
|
console.log(msg.subject, msg.fromAddress);
|
|
586
625
|
}
|
|
587
626
|
|
|
588
|
-
//
|
|
589
|
-
|
|
627
|
+
// To remove a mailbox, delete its owning identity (cascades to the
|
|
628
|
+
// linked mailbox AND tunnel; revokes scoped API keys):
|
|
629
|
+
await (await inkbox.getIdentity("support-agent")).delete();
|
|
590
630
|
```
|
|
591
631
|
|
|
592
632
|
---
|
|
593
633
|
|
|
594
634
|
## Custom Sending Domains
|
|
595
635
|
|
|
596
|
-
If your org has registered custom sending domains in the console, list them and (admin-only) set the org default. New mailboxes inherit the org default unless you pass `
|
|
636
|
+
If your org has registered custom sending domains in the console, list them and (admin-only) set the org default. New mailboxes inherit the org default unless you pass `sendingDomain` to `createIdentity`. Domain registration, DNS records, verification, DKIM rotation, and deletion stay in the console.
|
|
597
637
|
|
|
598
638
|
```ts
|
|
599
639
|
import { SendingDomainStatus } from "@inkbox/sdk";
|
package/dist/agent_identity.d.ts
CHANGED
|
@@ -15,23 +15,31 @@ import { ForwardMode, MessageDirection } from "./mail/types.js";
|
|
|
15
15
|
import type { Message, MessageDetail, ThreadDetail } from "./mail/types.js";
|
|
16
16
|
import type { PhoneCall, PhoneCallWithRateLimit, PhoneTranscript, TextConversationSummary, TextMessage } from "./phone/types.js";
|
|
17
17
|
import type { _AgentIdentityData, IdentityMailbox, IdentityPhoneNumber } from "./identities/types.js";
|
|
18
|
+
import type { Tunnel } from "./tunnels/types.js";
|
|
18
19
|
import type { Inkbox } from "./inkbox.js";
|
|
19
20
|
export declare class AgentIdentity {
|
|
20
21
|
private _data;
|
|
21
22
|
private readonly _inkbox;
|
|
22
23
|
private _mailbox;
|
|
23
24
|
private _phoneNumber;
|
|
25
|
+
private _tunnel;
|
|
24
26
|
private _credentials;
|
|
25
27
|
private _credentialsVaultRef;
|
|
26
28
|
constructor(data: _AgentIdentityData, inkbox: Inkbox);
|
|
27
29
|
get agentHandle(): string;
|
|
28
30
|
get id(): string;
|
|
31
|
+
/** Human-readable display name. Defaults server-side to `agentHandle` if unset. */
|
|
32
|
+
get displayName(): string | null;
|
|
33
|
+
/** Free-form org-internal description, or `null` if unset. Never surfaces in outbound mail. */
|
|
34
|
+
get description(): string | null;
|
|
29
35
|
/** Email address assigned at creation time. Always trust this value — do not derive it from `agentHandle`. */
|
|
30
36
|
get emailAddress(): string | null;
|
|
31
|
-
/** The mailbox currently assigned to this identity
|
|
37
|
+
/** The mailbox currently assigned to this identity. Non-null for live identities (1:1 invariant). */
|
|
32
38
|
get mailbox(): IdentityMailbox | null;
|
|
33
39
|
/** The phone number currently assigned to this identity, or `null` if none. */
|
|
34
40
|
get phoneNumber(): IdentityPhoneNumber | null;
|
|
41
|
+
/** The tunnel currently assigned to this identity. Non-null for live identities (1:1 invariant). */
|
|
42
|
+
get tunnel(): Tunnel | null;
|
|
35
43
|
/**
|
|
36
44
|
* Identity-scoped credential access.
|
|
37
45
|
*
|
|
@@ -106,34 +114,6 @@ export declare class AgentIdentity {
|
|
|
106
114
|
* @param secretId - UUID of the secret to delete.
|
|
107
115
|
*/
|
|
108
116
|
deleteSecret(secretId: string): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* Create a new mailbox and link it to this identity.
|
|
111
|
-
*
|
|
112
|
-
* @param options.displayName - Optional human-readable sender name.
|
|
113
|
-
* @param options.emailLocalPart - Optional requested mailbox local part.
|
|
114
|
-
* @param options.sendingDomainId - Optional sending-domain selector by row id
|
|
115
|
-
* (e.g. `"sending_domain_<uuid>"`). Omit to inherit the org's default
|
|
116
|
-
* custom domain (or fall through to the platform default if none).
|
|
117
|
-
* Pass `null` to force the platform default. Pass a verified domain's id
|
|
118
|
-
* to bind this mailbox to it.
|
|
119
|
-
*/
|
|
120
|
-
createMailbox(options?: {
|
|
121
|
-
displayName?: string;
|
|
122
|
-
emailLocalPart?: string;
|
|
123
|
-
sendingDomainId?: string | null;
|
|
124
|
-
}): Promise<IdentityMailbox>;
|
|
125
|
-
/**
|
|
126
|
-
* Link an existing mailbox to this identity.
|
|
127
|
-
*
|
|
128
|
-
* @param mailboxId - UUID of the mailbox to link. Obtain via
|
|
129
|
-
* `inkbox.mailboxes.list()` or `inkbox.mailboxes.get()`.
|
|
130
|
-
* @returns The linked {@link IdentityMailbox}.
|
|
131
|
-
*/
|
|
132
|
-
assignMailbox(mailboxId: string): Promise<IdentityMailbox>;
|
|
133
|
-
/**
|
|
134
|
-
* Unlink this identity's mailbox (does not delete the mailbox).
|
|
135
|
-
*/
|
|
136
|
-
unlinkMailbox(): Promise<void>;
|
|
137
117
|
/**
|
|
138
118
|
* Provision a new phone number and link it to this identity.
|
|
139
119
|
*
|
|
@@ -385,12 +365,23 @@ export declare class AgentIdentity {
|
|
|
385
365
|
updatedCount: number;
|
|
386
366
|
}>;
|
|
387
367
|
/**
|
|
388
|
-
* Update this identity's handle.
|
|
368
|
+
* Update this identity's handle, display name, description, and/or status.
|
|
369
|
+
*
|
|
370
|
+
* Only provided fields are applied; omitted fields are left unchanged.
|
|
371
|
+
* For `displayName` and `description`, explicit `null` clears the column;
|
|
372
|
+
* omitting the key leaves it untouched.
|
|
389
373
|
*
|
|
390
374
|
* @param options.newHandle - New agent handle.
|
|
375
|
+
* @param options.displayName - New display name, or `null` to clear.
|
|
376
|
+
* @param options.description - New description, or `null` to clear.
|
|
377
|
+
* @param options.status - `"active"` or `"paused"`. Call `delete()`
|
|
378
|
+
* to remove the identity; `"deleted"` is rejected here.
|
|
391
379
|
*/
|
|
392
380
|
update(options: {
|
|
393
381
|
newHandle?: string;
|
|
382
|
+
displayName?: string | null;
|
|
383
|
+
description?: string | null;
|
|
384
|
+
status?: "active" | "paused";
|
|
394
385
|
}): Promise<void>;
|
|
395
386
|
/**
|
|
396
387
|
* Re-fetch this identity from the API and update cached channels.
|
|
@@ -402,7 +393,13 @@ export declare class AgentIdentity {
|
|
|
402
393
|
* @returns `this` for chaining.
|
|
403
394
|
*/
|
|
404
395
|
refresh(): Promise<AgentIdentity>;
|
|
405
|
-
/**
|
|
396
|
+
/**
|
|
397
|
+
* Delete this identity.
|
|
398
|
+
*
|
|
399
|
+
* Cascades: flips the linked mailbox to `deleted`, force-finalizes the
|
|
400
|
+
* linked tunnel to `deleted`, revokes any identity-scoped API keys, and
|
|
401
|
+
* unassigns (but does not delete) any linked phone number.
|
|
402
|
+
*/
|
|
406
403
|
delete(): Promise<void>;
|
|
407
404
|
private _requireVaultUnlocked;
|
|
408
405
|
private _requireMailbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_identity.d.ts","sourceRoot":"","sources":["../src/agent_identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAA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AM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOxD;;;;;OAKG;IACG,wBAAwB,CAC5B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IAahF;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,OAAO,EAAE;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC9B,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBjB;;;;;;;;OAQG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAUvC;;;;;;OAMG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ7B,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,aAAa;CAQtB"}
|
package/dist/agent_identity.js
CHANGED
|
@@ -15,6 +15,7 @@ export class AgentIdentity {
|
|
|
15
15
|
_inkbox;
|
|
16
16
|
_mailbox;
|
|
17
17
|
_phoneNumber;
|
|
18
|
+
_tunnel;
|
|
18
19
|
_credentials = null;
|
|
19
20
|
_credentialsVaultRef = null; // tracks which _unlocked built the cache
|
|
20
21
|
constructor(data, inkbox) {
|
|
@@ -22,18 +23,25 @@ export class AgentIdentity {
|
|
|
22
23
|
this._inkbox = inkbox;
|
|
23
24
|
this._mailbox = data.mailbox;
|
|
24
25
|
this._phoneNumber = data.phoneNumber;
|
|
26
|
+
this._tunnel = data.tunnel;
|
|
25
27
|
}
|
|
26
28
|
// ------------------------------------------------------------------
|
|
27
29
|
// Identity properties
|
|
28
30
|
// ------------------------------------------------------------------
|
|
29
31
|
get agentHandle() { return this._data.agentHandle; }
|
|
30
32
|
get id() { return this._data.id; }
|
|
33
|
+
/** Human-readable display name. Defaults server-side to `agentHandle` if unset. */
|
|
34
|
+
get displayName() { return this._data.displayName; }
|
|
35
|
+
/** Free-form org-internal description, or `null` if unset. Never surfaces in outbound mail. */
|
|
36
|
+
get description() { return this._data.description; }
|
|
31
37
|
/** Email address assigned at creation time. Always trust this value — do not derive it from `agentHandle`. */
|
|
32
38
|
get emailAddress() { return this._data.emailAddress; }
|
|
33
|
-
/** The mailbox currently assigned to this identity
|
|
39
|
+
/** The mailbox currently assigned to this identity. Non-null for live identities (1:1 invariant). */
|
|
34
40
|
get mailbox() { return this._mailbox; }
|
|
35
41
|
/** The phone number currently assigned to this identity, or `null` if none. */
|
|
36
42
|
get phoneNumber() { return this._phoneNumber; }
|
|
43
|
+
/** The tunnel currently assigned to this identity. Non-null for live identities (1:1 invariant). */
|
|
44
|
+
get tunnel() { return this._tunnel; }
|
|
37
45
|
/**
|
|
38
46
|
* Identity-scoped credential access.
|
|
39
47
|
*
|
|
@@ -155,60 +163,6 @@ export class AgentIdentity {
|
|
|
155
163
|
// ------------------------------------------------------------------
|
|
156
164
|
// Channel management
|
|
157
165
|
// ------------------------------------------------------------------
|
|
158
|
-
/**
|
|
159
|
-
* Create a new mailbox and link it to this identity.
|
|
160
|
-
*
|
|
161
|
-
* @param options.displayName - Optional human-readable sender name.
|
|
162
|
-
* @param options.emailLocalPart - Optional requested mailbox local part.
|
|
163
|
-
* @param options.sendingDomainId - Optional sending-domain selector by row id
|
|
164
|
-
* (e.g. `"sending_domain_<uuid>"`). Omit to inherit the org's default
|
|
165
|
-
* custom domain (or fall through to the platform default if none).
|
|
166
|
-
* Pass `null` to force the platform default. Pass a verified domain's id
|
|
167
|
-
* to bind this mailbox to it.
|
|
168
|
-
*/
|
|
169
|
-
async createMailbox(options = {}) {
|
|
170
|
-
const mailbox = await this._inkbox._mailboxes.create({
|
|
171
|
-
agentHandle: this.agentHandle,
|
|
172
|
-
...options,
|
|
173
|
-
});
|
|
174
|
-
const linked = {
|
|
175
|
-
id: mailbox.id,
|
|
176
|
-
emailAddress: mailbox.emailAddress,
|
|
177
|
-
sendingDomain: mailbox.sendingDomain,
|
|
178
|
-
displayName: mailbox.displayName,
|
|
179
|
-
filterMode: mailbox.filterMode,
|
|
180
|
-
agentIdentityId: mailbox.agentIdentityId,
|
|
181
|
-
createdAt: mailbox.createdAt,
|
|
182
|
-
updatedAt: mailbox.updatedAt,
|
|
183
|
-
filterModeChangeNotice: mailbox.filterModeChangeNotice,
|
|
184
|
-
};
|
|
185
|
-
this._mailbox = linked;
|
|
186
|
-
this._data.emailAddress = mailbox.emailAddress;
|
|
187
|
-
return linked;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Link an existing mailbox to this identity.
|
|
191
|
-
*
|
|
192
|
-
* @param mailboxId - UUID of the mailbox to link. Obtain via
|
|
193
|
-
* `inkbox.mailboxes.list()` or `inkbox.mailboxes.get()`.
|
|
194
|
-
* @returns The linked {@link IdentityMailbox}.
|
|
195
|
-
*/
|
|
196
|
-
async assignMailbox(mailboxId) {
|
|
197
|
-
const data = await this._inkbox._idsResource.assignMailbox(this.agentHandle, {
|
|
198
|
-
mailboxId,
|
|
199
|
-
});
|
|
200
|
-
this._mailbox = data.mailbox;
|
|
201
|
-
this._data = data;
|
|
202
|
-
return this._mailbox;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Unlink this identity's mailbox (does not delete the mailbox).
|
|
206
|
-
*/
|
|
207
|
-
async unlinkMailbox() {
|
|
208
|
-
this._requireMailbox();
|
|
209
|
-
await this._inkbox._idsResource.unlinkMailbox(this.agentHandle);
|
|
210
|
-
this._mailbox = null;
|
|
211
|
-
}
|
|
212
166
|
/**
|
|
213
167
|
* Provision a new phone number and link it to this identity.
|
|
214
168
|
*
|
|
@@ -487,9 +441,17 @@ export class AgentIdentity {
|
|
|
487
441
|
// Identity management
|
|
488
442
|
// ------------------------------------------------------------------
|
|
489
443
|
/**
|
|
490
|
-
* Update this identity's handle.
|
|
444
|
+
* Update this identity's handle, display name, description, and/or status.
|
|
445
|
+
*
|
|
446
|
+
* Only provided fields are applied; omitted fields are left unchanged.
|
|
447
|
+
* For `displayName` and `description`, explicit `null` clears the column;
|
|
448
|
+
* omitting the key leaves it untouched.
|
|
491
449
|
*
|
|
492
450
|
* @param options.newHandle - New agent handle.
|
|
451
|
+
* @param options.displayName - New display name, or `null` to clear.
|
|
452
|
+
* @param options.description - New description, or `null` to clear.
|
|
453
|
+
* @param options.status - `"active"` or `"paused"`. Call `delete()`
|
|
454
|
+
* to remove the identity; `"deleted"` is rejected here.
|
|
493
455
|
*/
|
|
494
456
|
async update(options) {
|
|
495
457
|
const result = await this._inkbox._idsResource.update(this.agentHandle, options);
|
|
@@ -497,7 +459,14 @@ export class AgentIdentity {
|
|
|
497
459
|
...result,
|
|
498
460
|
mailbox: this._mailbox,
|
|
499
461
|
phoneNumber: this._phoneNumber,
|
|
462
|
+
tunnel: this._tunnel,
|
|
500
463
|
};
|
|
464
|
+
if (options.newHandle !== undefined && this._tunnel != null) {
|
|
465
|
+
// The server renames the linked tunnel in the same transaction
|
|
466
|
+
// under the unified handle namespace; refresh to pick up the
|
|
467
|
+
// new tunnelName / publicHost on the cached tunnel.
|
|
468
|
+
await this.refresh();
|
|
469
|
+
}
|
|
501
470
|
}
|
|
502
471
|
/**
|
|
503
472
|
* Re-fetch this identity from the API and update cached channels.
|
|
@@ -513,10 +482,17 @@ export class AgentIdentity {
|
|
|
513
482
|
this._data = data;
|
|
514
483
|
this._mailbox = data.mailbox;
|
|
515
484
|
this._phoneNumber = data.phoneNumber;
|
|
485
|
+
this._tunnel = data.tunnel;
|
|
516
486
|
this._credentials = null;
|
|
517
487
|
return this;
|
|
518
488
|
}
|
|
519
|
-
/**
|
|
489
|
+
/**
|
|
490
|
+
* Delete this identity.
|
|
491
|
+
*
|
|
492
|
+
* Cascades: flips the linked mailbox to `deleted`, force-finalizes the
|
|
493
|
+
* linked tunnel to `deleted`, revokes any identity-scoped API keys, and
|
|
494
|
+
* unassigns (but does not delete) any linked phone number.
|
|
495
|
+
*/
|
|
520
496
|
async delete() {
|
|
521
497
|
await this._inkbox._idsResource.delete(this.agentHandle);
|
|
522
498
|
}
|
|
@@ -530,7 +506,7 @@ export class AgentIdentity {
|
|
|
530
506
|
}
|
|
531
507
|
_requireMailbox() {
|
|
532
508
|
if (!this._mailbox) {
|
|
533
|
-
throw new InkboxError(`Identity '${this.agentHandle}' has no mailbox
|
|
509
|
+
throw new InkboxError(`Identity '${this.agentHandle}' has no mailbox — this should only be reachable on a deleted identity.`);
|
|
534
510
|
}
|
|
535
511
|
}
|
|
536
512
|
_requirePhone() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_identity.js","sourceRoot":"","sources":["../src/agent_identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAkB,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoB/C,MAAM,OAAO,aAAa;IAChB,KAAK,CAAqB;IACjB,OAAO,CAAS;IACzB,QAAQ,CAAyB;IACjC,YAAY,CAA6B;IACzC,YAAY,GAAuB,IAAI,CAAC;IACxC,oBAAoB,GAAkB,IAAI,CAAC,CAAC,yCAAyC;IAE7F,YAAY,IAAwB,EAAE,MAAc;QAClD,IAAI,CAAC,KAAK,GAAgB,IAAI,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAc,MAAM,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAa,IAAI,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,YAAY,GAAS,IAAI,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"agent_identity.js","sourceRoot":"","sources":["../src/agent_identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAkB,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD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C;QAC9B,IAAI,CAAC,QAAQ,GAAY,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,YAAY,GAAQ,IAAI,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAa,IAAI,CAAC,MAAM,CAAC;QACrC,IAAI,CAAC,YAAY,GAAQ,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED,qEAAqE;IACrE,kBAAkB;IAClB,qEAAqE;IAE7D,qBAAqB;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YACnD,MAAM,IAAI,WAAW,CACnB,gGAAgG,CACjG,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,WAAW,CACnB,aAAa,IAAI,CAAC,WAAW,yEAAyE,CACvG,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,WAAW,CACnB,aAAa,IAAI,CAAC,WAAW,6GAA6G,CAC3I,CAAC;QACJ,CAAC;IACH,CAAC;CAEF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-identities/exceptions.ts
|
|
3
|
+
*
|
|
4
|
+
* Typed exceptions for the identities surface.
|
|
5
|
+
*/
|
|
6
|
+
import { InkboxAPIError, type InkboxAPIErrorDetail } from "../_http.js";
|
|
7
|
+
/** Which namespace blocked the handle on a 409 from create / rename. */
|
|
8
|
+
export type BlockingNamespace = "identities" | "tunnels" | "mail" | null;
|
|
9
|
+
/**
|
|
10
|
+
* Raised by `identities.create()` / `identities.update()` (and the
|
|
11
|
+
* `inkbox.createIdentity` / `identity.update` wrappers) when the
|
|
12
|
+
* requested agent_handle collides with the global handle namespace.
|
|
13
|
+
*
|
|
14
|
+
* The unified namespace check runs across identities, tunnels, and the
|
|
15
|
+
* platform-mailbox local part; `blockingNamespace` reports which side
|
|
16
|
+
* rejected so callers can render an appropriate message.
|
|
17
|
+
*/
|
|
18
|
+
export declare class HandleUnavailableError extends InkboxAPIError {
|
|
19
|
+
readonly blockingNamespace: BlockingNamespace;
|
|
20
|
+
constructor(statusCode: number, detail: InkboxAPIErrorDetail, blockingNamespace: BlockingNamespace);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Inspect a 409 error detail for a `blocking_namespace` field. Returns
|
|
24
|
+
* the parsed value when present, else `null`. (Servers running 1.0+ set
|
|
25
|
+
* this on every `agent_handle_unavailable` 409 from identity-create or
|
|
26
|
+
* identity-rename.)
|
|
27
|
+
*/
|
|
28
|
+
export declare function readBlockingNamespace(detail: InkboxAPIErrorDetail): BlockingNamespace;
|
|
29
|
+
/**
|
|
30
|
+
* If `err` is a 409 collision error from the identities endpoints,
|
|
31
|
+
* return a `HandleUnavailableError`; otherwise return the original
|
|
32
|
+
* error untouched so it propagates as-is.
|
|
33
|
+
*/
|
|
34
|
+
export declare function mapIdentityConflictError(err: InkboxAPIError): Error;
|
|
35
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/identities/exceptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExE,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;AAEzE;;;;;;;;GAQG;AACH,qBAAa,sBAAuB,SAAQ,cAAc;IACxD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;gBAG5C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,oBAAoB,EAC5B,iBAAiB,EAAE,iBAAiB;CAMvC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,iBAAiB,CAMrF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,GAAG,KAAK,CASnE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-identities/exceptions.ts
|
|
3
|
+
*
|
|
4
|
+
* Typed exceptions for the identities surface.
|
|
5
|
+
*/
|
|
6
|
+
import { InkboxAPIError } from "../_http.js";
|
|
7
|
+
/**
|
|
8
|
+
* Raised by `identities.create()` / `identities.update()` (and the
|
|
9
|
+
* `inkbox.createIdentity` / `identity.update` wrappers) when the
|
|
10
|
+
* requested agent_handle collides with the global handle namespace.
|
|
11
|
+
*
|
|
12
|
+
* The unified namespace check runs across identities, tunnels, and the
|
|
13
|
+
* platform-mailbox local part; `blockingNamespace` reports which side
|
|
14
|
+
* rejected so callers can render an appropriate message.
|
|
15
|
+
*/
|
|
16
|
+
export class HandleUnavailableError extends InkboxAPIError {
|
|
17
|
+
blockingNamespace;
|
|
18
|
+
constructor(statusCode, detail, blockingNamespace) {
|
|
19
|
+
super(statusCode, detail);
|
|
20
|
+
this.name = "HandleUnavailableError";
|
|
21
|
+
this.blockingNamespace = blockingNamespace;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Inspect a 409 error detail for a `blocking_namespace` field. Returns
|
|
26
|
+
* the parsed value when present, else `null`. (Servers running 1.0+ set
|
|
27
|
+
* this on every `agent_handle_unavailable` 409 from identity-create or
|
|
28
|
+
* identity-rename.)
|
|
29
|
+
*/
|
|
30
|
+
export function readBlockingNamespace(detail) {
|
|
31
|
+
if (detail && typeof detail === "object" && !Array.isArray(detail)) {
|
|
32
|
+
const v = detail["blocking_namespace"];
|
|
33
|
+
if (v === "identities" || v === "tunnels" || v === "mail")
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* If `err` is a 409 collision error from the identities endpoints,
|
|
40
|
+
* return a `HandleUnavailableError`; otherwise return the original
|
|
41
|
+
* error untouched so it propagates as-is.
|
|
42
|
+
*/
|
|
43
|
+
export function mapIdentityConflictError(err) {
|
|
44
|
+
if (err.statusCode === 409) {
|
|
45
|
+
return new HandleUnavailableError(err.statusCode, err.detail, readBlockingNamespace(err.detail));
|
|
46
|
+
}
|
|
47
|
+
return err;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/identities/exceptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAA6B,MAAM,aAAa,CAAC;AAKxE;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAuB,SAAQ,cAAc;IAC/C,iBAAiB,CAAoB;IAE9C,YACE,UAAkB,EAClB,MAA4B,EAC5B,iBAAoC;QAEpC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA4B;IAChE,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,GAAI,MAAkC,CAAC,oBAAoB,CAAC,CAAC;QACpE,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,MAAM;YAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAmB;IAC1D,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;QAC3B,OAAO,IAAI,sBAAsB,CAC/B,GAAG,CAAC,UAAU,EACd,GAAG,CAAC,MAAM,EACV,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAClC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|