@inkbox/sdk 0.4.4 → 0.4.6

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.
Files changed (51) hide show
  1. package/README.md +115 -45
  2. package/dist/agent_identity.d.ts +29 -22
  3. package/dist/agent_identity.d.ts.map +1 -1
  4. package/dist/agent_identity.js +25 -17
  5. package/dist/agent_identity.js.map +1 -1
  6. package/dist/identities/types.d.ts +0 -6
  7. package/dist/identities/types.d.ts.map +1 -1
  8. package/dist/identities/types.js +0 -4
  9. package/dist/identities/types.js.map +1 -1
  10. package/dist/index.d.ts +5 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/inkbox.d.ts +13 -0
  14. package/dist/inkbox.d.ts.map +1 -1
  15. package/dist/inkbox.js +15 -0
  16. package/dist/inkbox.js.map +1 -1
  17. package/dist/mail/resources/mailboxes.d.ts +2 -3
  18. package/dist/mail/resources/mailboxes.d.ts.map +1 -1
  19. package/dist/mail/resources/mailboxes.js +2 -5
  20. package/dist/mail/resources/mailboxes.js.map +1 -1
  21. package/dist/mail/types.d.ts +10 -2
  22. package/dist/mail/types.d.ts.map +1 -1
  23. package/dist/mail/types.js +0 -1
  24. package/dist/mail/types.js.map +1 -1
  25. package/dist/phone/resources/numbers.d.ts +0 -2
  26. package/dist/phone/resources/numbers.d.ts.map +1 -1
  27. package/dist/phone/resources/numbers.js +0 -6
  28. package/dist/phone/resources/numbers.js.map +1 -1
  29. package/dist/phone/resources/texts.d.ts +28 -23
  30. package/dist/phone/resources/texts.d.ts.map +1 -1
  31. package/dist/phone/resources/texts.js +42 -20
  32. package/dist/phone/resources/texts.js.map +1 -1
  33. package/dist/phone/types.d.ts +62 -6
  34. package/dist/phone/types.d.ts.map +1 -1
  35. package/dist/phone/types.js +24 -3
  36. package/dist/phone/types.js.map +1 -1
  37. package/dist/webhooks/index.d.ts +8 -0
  38. package/dist/webhooks/index.d.ts.map +1 -0
  39. package/dist/webhooks/index.js +8 -0
  40. package/dist/webhooks/index.js.map +1 -0
  41. package/dist/webhooks/subscriptions.d.ts +87 -0
  42. package/dist/webhooks/subscriptions.d.ts.map +1 -0
  43. package/dist/webhooks/subscriptions.js +153 -0
  44. package/dist/webhooks/subscriptions.js.map +1 -0
  45. package/dist/webhooks/types.d.ts +78 -13
  46. package/dist/webhooks/types.d.ts.map +1 -1
  47. package/package.json +1 -1
  48. package/dist/tunnels/_reserved_names 2.d.ts +0 -22
  49. package/dist/tunnels/_reserved_names 2.d.ts.map +0 -1
  50. package/dist/tunnels/_reserved_names 2.js +0 -149
  51. package/dist/tunnels/_reserved_names 2.js.map +0 -1
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Webhook subscriptions — fan-out per (owner, url, event_types).
3
+ *
4
+ * Replaces the legacy per-resource `webhook_url` columns on mailboxes
5
+ * and phone numbers. Use this resource to attach HTTPS receivers to
6
+ * mail (`message.*`) or phone-text (`text.*`) events. Incoming-call
7
+ * webhooks (`phone.incoming_call`) are still set on the phone-number
8
+ * resource itself — that channel is a synchronous control-plane
9
+ * callback whose response body drives call routing, so fan-out is not
10
+ * meaningful.
11
+ */
12
+ const PATH = "/webhooks/subscriptions";
13
+ export function parseWebhookSubscription(r) {
14
+ return {
15
+ id: r.id,
16
+ organizationId: r.organization_id,
17
+ mailboxId: r.mailbox_id,
18
+ phoneNumberId: r.phone_number_id,
19
+ url: r.url,
20
+ eventTypes: r.event_types,
21
+ status: r.status,
22
+ createdAt: new Date(r.created_at),
23
+ updatedAt: new Date(r.updated_at),
24
+ };
25
+ }
26
+ const INCOMING_CALL = "phone.incoming_call";
27
+ function assertUrlNotNull(url) {
28
+ if (url === null) {
29
+ throw new Error("url must not be null; pass a string, or omit the field to leave it unchanged");
30
+ }
31
+ }
32
+ function assertEventTypesNotNull(eventTypes) {
33
+ if (eventTypes === null) {
34
+ throw new Error("eventTypes must not be null; pass a non-empty array, or omit the field to leave it unchanged");
35
+ }
36
+ }
37
+ function assertEventTypesNonEmptyDistinct(eventTypes) {
38
+ if (eventTypes.length === 0) {
39
+ throw new Error("eventTypes must be a non-empty list");
40
+ }
41
+ const seen = new Set();
42
+ for (const e of eventTypes) {
43
+ if (seen.has(e)) {
44
+ throw new Error(`eventTypes contains duplicate value: '${e}'`);
45
+ }
46
+ seen.add(e);
47
+ }
48
+ }
49
+ function assertNoIncomingCall(eventTypes) {
50
+ if (eventTypes.includes(INCOMING_CALL)) {
51
+ throw new Error(`event_type '${INCOMING_CALL}' is not stored in webhook subscriptions; ` +
52
+ "set it on the phone number's `incomingCallWebhookUrl` field instead");
53
+ }
54
+ }
55
+ function assertChannelCoherence(hasMailbox, eventTypes) {
56
+ const expectedPrefix = hasMailbox ? "message." : "text.";
57
+ const otherPrefix = hasMailbox ? "text." : "message.";
58
+ const otherChannel = hasMailbox ? "phone_number" : "mailbox";
59
+ for (const e of eventTypes) {
60
+ if (e.startsWith(expectedPrefix))
61
+ continue;
62
+ if (e.startsWith(otherPrefix)) {
63
+ throw new Error(`event_type '${e}' does not belong to the ${hasMailbox ? "mailbox" : "phone_number"} ` +
64
+ `channel (it belongs to ${otherChannel})`);
65
+ }
66
+ throw new Error(`event_type '${e}' does not belong to any known channel`);
67
+ }
68
+ // INCOMING_CALL is rejected by assertNoIncomingCall earlier.
69
+ }
70
+ export class WebhookSubscriptionsResource {
71
+ http;
72
+ constructor(http) {
73
+ this.http = http;
74
+ }
75
+ /**
76
+ * List webhook subscriptions visible to the caller. Filters AND-combine;
77
+ * unmatched filters return an empty list. `mailboxId` and `phoneNumberId`
78
+ * are mutually exclusive — passing both yields a 422. Deleted
79
+ * subscriptions are not returned.
80
+ */
81
+ async list(filters = {}) {
82
+ const params = {};
83
+ if (filters.mailboxId !== undefined)
84
+ params["mailbox_id"] = filters.mailboxId;
85
+ if (filters.phoneNumberId !== undefined)
86
+ params["phone_number_id"] = filters.phoneNumberId;
87
+ if (filters.url !== undefined)
88
+ params["url"] = filters.url;
89
+ if (filters.eventType !== undefined)
90
+ params["event_type"] = filters.eventType;
91
+ const data = await this.http.get(PATH, params);
92
+ return data.subscriptions.map(parseWebhookSubscription);
93
+ }
94
+ /** Fetch a single subscription by id. Returns 404 if the subscription has been deleted or is not visible to the caller. */
95
+ async get(subId) {
96
+ const data = await this.http.get(`${PATH}/${subId}`);
97
+ return parseWebhookSubscription(data);
98
+ }
99
+ /**
100
+ * Create a webhook subscription. Exactly one of `mailboxId` /
101
+ * `phoneNumberId` is required; `eventTypes` must be a non-empty list
102
+ * of distinct values belonging to the owner's channel (mailbox →
103
+ * `message.*`, phone number → `text.*`).
104
+ */
105
+ async create(options) {
106
+ const hasMailbox = options.mailboxId !== undefined && options.mailboxId !== null;
107
+ const hasPhoneNumber = options.phoneNumberId !== undefined && options.phoneNumberId !== null;
108
+ if (hasMailbox === hasPhoneNumber) {
109
+ throw new Error("Exactly one of mailboxId or phoneNumberId must be provided");
110
+ }
111
+ assertUrlNotNull(options.url);
112
+ assertEventTypesNotNull(options.eventTypes);
113
+ assertEventTypesNonEmptyDistinct(options.eventTypes);
114
+ assertNoIncomingCall(options.eventTypes);
115
+ assertChannelCoherence(hasMailbox, options.eventTypes);
116
+ const body = {
117
+ url: options.url,
118
+ event_types: options.eventTypes,
119
+ };
120
+ if (hasMailbox)
121
+ body["mailbox_id"] = options.mailboxId;
122
+ if (hasPhoneNumber)
123
+ body["phone_number_id"] = options.phoneNumberId;
124
+ const data = await this.http.post(PATH, body);
125
+ return parseWebhookSubscription(data);
126
+ }
127
+ /**
128
+ * Update the destination URL and/or event-type list of a subscription.
129
+ * Omitting both is a no-op. `eventTypes`, if supplied, replaces the
130
+ * stored list and must be non-empty and distinct. Owner FKs are not
131
+ * mutable.
132
+ */
133
+ async update(subId, options) {
134
+ const body = {};
135
+ if (options.url !== undefined) {
136
+ assertUrlNotNull(options.url);
137
+ body["url"] = options.url;
138
+ }
139
+ if (options.eventTypes !== undefined) {
140
+ assertEventTypesNotNull(options.eventTypes);
141
+ assertEventTypesNonEmptyDistinct(options.eventTypes);
142
+ assertNoIncomingCall(options.eventTypes);
143
+ body["event_types"] = options.eventTypes;
144
+ }
145
+ const data = await this.http.patch(`${PATH}/${subId}`, body);
146
+ return parseWebhookSubscription(data);
147
+ }
148
+ /** Delete a subscription. Subsequent `list` / `get` calls will not return it. */
149
+ async delete(subId) {
150
+ await this.http.delete(`${PATH}/${subId}`);
151
+ }
152
+ }
153
+ //# sourceMappingURL=subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/webhooks/subscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAqCvC,MAAM,UAAU,wBAAwB,CACtC,CAAyB;IAEzB,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,cAAc,EAAE,CAAC,CAAC,eAAe;QACjC,SAAS,EAAE,CAAC,CAAC,UAAU;QACvB,aAAa,EAAE,CAAC,CAAC,eAAe;QAChC,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QACjC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAE5C,SAAS,gBAAgB,CAAC,GAAY;IACpC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,UAAmB;IAClD,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAA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CAAC;QACD,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACrC,uBAAuB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC5C,gCAAgC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACrD,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;QAC3C,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAChC,GAAG,IAAI,IAAI,KAAK,EAAE,EAClB,IAAI,CACL,CAAC;QACF,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,MAAM,CAAC,KAAa;QACxB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -7,7 +7,7 @@
7
7
  * `"inbound" | "outbound"`) rather than the SDK's TS `enum` exports,
8
8
  * since `JSON.parse` produces bare strings.
9
9
  */
10
- import type { RawRateLimitInfo, RawTextMediaItem } from "../phone/types.js";
10
+ import type { RawRateLimitInfo, RawTextMediaItem, RawTextMessageRecipient } from "../phone/types.js";
11
11
  export type MessageDirectionWire = "inbound" | "outbound";
12
12
  export type MessageStatus = "queued" | "sent" | "delivered" | "bounced" | "failed" | "received" | "deleted";
13
13
  export type TextDirectionWire = "inbound" | "outbound";
@@ -18,16 +18,26 @@ export type CallDirectionWire = "outbound" | "inbound";
18
18
  export type CallStatusWire = "initiated" | "ringing" | "answered" | "completed" | "failed" | "canceled";
19
19
  export type HangupReasonWire = "local" | "remote" | "max_duration" | "voicemail" | "rejected";
20
20
  /**
21
- * Address-book match for the single remote party on a phone or text
22
- * webhook event. Optional — `null` means no contact visible to the
23
- * receiving identity. Pass `id` to `inkbox.contacts.get()` to hydrate.
21
+ * Address-book match for a remote party on a phone or text webhook
22
+ * event. Surfaced as a list pass `id` to `inkbox.contacts.get()` to
23
+ * hydrate.
24
24
  */
25
25
  export interface WebhookContact {
26
26
  id: string;
27
27
  name: string;
28
28
  }
29
+ /**
30
+ * Identity match for a remote party on a phone or text webhook event.
31
+ * Set when the remote party is an active agent identity in the same
32
+ * org that is visible to the receiver.
33
+ */
34
+ export interface WebhookAgentIdentity {
35
+ id: string;
36
+ agent_handle: string;
37
+ display_name: string | null;
38
+ }
29
39
  export type MailWebhookEventType = "message.received" | "message.sent" | "message.forwarded" | "message.delivered" | "message.bounced" | "message.failed";
30
- /** Which recipient list a mail webhook contact was matched from. */
40
+ /** Which recipient list a mail webhook contact/identity was matched from. */
31
41
  export type MailContactBucket = "from" | "to" | "cc" | "bcc";
32
42
  /**
33
43
  * Per-recipient address-book match on a mail webhook event.
@@ -47,6 +57,18 @@ export interface WebhookMailContact {
47
57
  id: string;
48
58
  name: string;
49
59
  }
60
+ /**
61
+ * Per-recipient identity match on a mail webhook event. Same shape as
62
+ * `WebhookMailContact` but with `agent_handle` / `display_name`
63
+ * instead of `name`.
64
+ */
65
+ export interface WebhookMailAgentIdentity {
66
+ bucket: MailContactBucket;
67
+ address: string;
68
+ id: string;
69
+ agent_handle: string;
70
+ display_name: string | null;
71
+ }
50
72
  /**
51
73
  * Stored mail message. `message_id` is the RFC 5322 `Message-ID`
52
74
  * header value (not Inkbox's row id — that's `id`). `bcc_addresses` is
@@ -77,26 +99,46 @@ export interface MailWebhookPayload {
77
99
  data: {
78
100
  message: MailWebhookMessage;
79
101
  /**
80
- * Per-recipient matches. Always present, possibly empty. Wire
81
- * order is `from` → `to` → `cc` → `bcc`, then within each bucket
82
- * by source-field order; receivers should pair by
102
+ * Per-recipient address-book matches. Always present, possibly
103
+ * empty. Wire order is `from` → `to` → `cc` → `bcc`, then within
104
+ * each bucket by source-field order; receivers should pair by
83
105
  * `(bucket, address)` rather than relying on the order. Up to 50
84
106
  * distinct normalized addresses are resolved per event; over-cap
85
107
  * inputs and resolver failures both fall back to an empty list.
86
108
  */
87
109
  contacts: WebhookMailContact[];
110
+ /**
111
+ * Per-recipient identity matches. Always present, possibly empty.
112
+ * Same matching rules as `contacts`. A peer can match both a
113
+ * contact and an agent identity — two rows are emitted; receivers
114
+ * decide precedence.
115
+ */
116
+ agent_identities: WebhookMailAgentIdentity[];
88
117
  };
89
118
  }
90
119
  export type TextWebhookEventType = "text.received" | "text.sent" | "text.delivered" | "text.delivery_failed" | "text.delivery_unconfirmed";
91
120
  /**
92
121
  * Stored text message. `is_blocked` is not part of the wire body —
93
122
  * blocked texts never reach the webhook.
123
+ *
124
+ * Field population by traffic shape:
125
+ * - `remote_phone_number`: populated on inbound and on outbound 1:1;
126
+ * `null` on group outbound (per-recipient state lives in
127
+ * `recipients[]`).
128
+ * - `delivery_status`: populated on outbound. On group outbound this
129
+ * is the message-level rollup across `recipients[]`; on inbound it
130
+ * is `null`.
131
+ * - Legacy top-level lifecycle details (`error_code`, `error_detail`,
132
+ * `sent_at`, `delivered_at`, `failed_at`): populated only on
133
+ * outbound 1:1. On group outbound the per-recipient values live in
134
+ * `recipients[]`; on inbound there is no carrier lifecycle to track,
135
+ * so all five are `null`.
94
136
  */
95
137
  export interface TextWebhookMessage {
96
138
  id: string;
97
139
  direction: TextDirectionWire;
98
140
  local_phone_number: string;
99
- remote_phone_number: string;
141
+ remote_phone_number: string | null;
100
142
  text: string | null;
101
143
  type: TextTypeWire;
102
144
  media: RawTextMediaItem[] | null;
@@ -108,6 +150,15 @@ export interface TextWebhookMessage {
108
150
  sent_at: string | null;
109
151
  delivered_at: string | null;
110
152
  failed_at: string | null;
153
+ conversation_id: string | null;
154
+ sender_phone_number: string | null;
155
+ /**
156
+ * `null` on inbound (and rows that didn't eager-load recipients);
157
+ * a one-element list on outbound 1:1 (the legacy 1:1 lifecycle
158
+ * fields above are hoisted from that entry); multiple entries on
159
+ * group outbound.
160
+ */
161
+ recipients: RawTextMessageRecipient[] | null;
111
162
  created_at: string;
112
163
  updated_at: string;
113
164
  }
@@ -116,13 +167,24 @@ export interface TextWebhookPayload {
116
167
  timestamp: string;
117
168
  data: {
118
169
  text_message: TextWebhookMessage;
119
- contact: WebhookContact | null;
170
+ /** Address-book matches for the remote party (or parties). Always present, possibly empty. */
171
+ contacts: WebhookContact[];
172
+ /** Identity matches for the remote party (or parties). Always present, possibly empty. */
173
+ agent_identities: WebhookAgentIdentity[];
174
+ /**
175
+ * For outbound group lifecycle events, the specific recipient this
176
+ * event is about. `null` on inbound and on 1:1 outbound (where
177
+ * `text_message.remote_phone_number` already identifies the
178
+ * recipient).
179
+ */
180
+ recipient_phone_number: string | null;
120
181
  };
121
182
  }
122
183
  /**
123
184
  * Inbound call payload. **Flat** — no `{ event_type, timestamp, data }`
124
- * envelope; `contact` sits at the top level. `is_blocked` is not part
125
- * of the wire body — blocked calls never reach the webhook.
185
+ * envelope; `contacts` / `agent_identities` sit at the top level.
186
+ * `is_blocked` is not part of the wire body — blocked calls never
187
+ * reach the webhook.
126
188
  */
127
189
  export interface PhoneIncomingCallWebhookPayload {
128
190
  id: string;
@@ -139,6 +201,9 @@ export interface PhoneIncomingCallWebhookPayload {
139
201
  created_at: string;
140
202
  updated_at: string;
141
203
  rate_limit: RawRateLimitInfo | null;
142
- contact: WebhookContact | null;
204
+ /** Address-book matches for the remote party. Always present, possibly empty. */
205
+ contacts: WebhookContact[];
206
+ /** Identity matches for the remote party. Always present, possibly empty. */
207
+ agent_identities: WebhookAgentIdentity[];
143
208
  }
144
209
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI5E,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM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,IAAI,CAAC;KACvC,CAAC;CACH;AAID;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,iFAAiF;IACjF,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,6EAA6E;IAC7E,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;CAC1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkbox/sdk",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "TypeScript SDK for the Inkbox API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,22 +0,0 @@
1
- /**
2
- * inkbox-tunnels/_reserved_names.ts
3
- *
4
- * Local mirror of the canonical reserved-name set used by the server's
5
- * handle / tunnel-name / platform-mailbox-local-part validator (see
6
- * `~/servers/src/utils/reserved_names.py` +
7
- * `~/servers/src/data_models/api_contracts/tunnel.py`
8
- * `_TUNNEL_SPECIFIC_RESERVED`).
9
- *
10
- * Drift policy: keep this list snapshot-equivalent to the server source
11
- * of truth. The handle namespace is global so client-side enforcement is
12
- * a UX nicety; the server is authoritative.
13
- */
14
- /**
15
- * Returns true if `name` collides with the reserved set: tunnel-specific
16
- * labels, brand-impersonation labels, the Amplify preview prefixes
17
- * (`pr-*` / `console-pr-*`), or any Inkbox team-member name pattern.
18
- *
19
- * Mirrors `_is_reserved_tunnel_name` in the server source.
20
- */
21
- export declare function isReservedName(name: string): boolean;
22
- //# sourceMappingURL=_reserved_names%202.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_reserved_names 2.d.ts","sourceRoot":"","sources":["../../src/tunnels/_reserved_names 2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA6HH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAWpD"}
@@ -1,149 +0,0 @@
1
- /**
2
- * inkbox-tunnels/_reserved_names.ts
3
- *
4
- * Local mirror of the canonical reserved-name set used by the server's
5
- * handle / tunnel-name / platform-mailbox-local-part validator (see
6
- * `~/servers/src/utils/reserved_names.py` +
7
- * `~/servers/src/data_models/api_contracts/tunnel.py`
8
- * `_TUNNEL_SPECIFIC_RESERVED`).
9
- *
10
- * Drift policy: keep this list snapshot-equivalent to the server source
11
- * of truth. The handle namespace is global so client-side enforcement is
12
- * a UX nicety; the server is authoritative.
13
- */
14
- const INKBOX_BRAND_RESERVED = new Set([
15
- "idenagent",
16
- "inkbox",
17
- "inkboxai",
18
- "inkboxmail",
19
- "inkboxteam",
20
- "getvectorly",
21
- "vectorly",
22
- "vectorlyai",
23
- ]);
24
- const AI_PROVIDER_RESERVED = new Set([
25
- "anthropic",
26
- "anysphere",
27
- "chatgpt",
28
- "claude",
29
- "codex",
30
- "cohere",
31
- "copilot",
32
- "cursor",
33
- "deepmind",
34
- "deepseek",
35
- "gemini",
36
- "grok",
37
- "grokai",
38
- "huggingface",
39
- "llama",
40
- "mistral",
41
- "openai",
42
- "perplexity",
43
- "windsurf",
44
- "xai",
45
- ]);
46
- const MAJOR_TECH_RESERVED = new Set([
47
- "amazon",
48
- "apple",
49
- "aws",
50
- "facebook",
51
- "github",
52
- "google",
53
- "instagram",
54
- "linkedin",
55
- "meta",
56
- "metaai",
57
- "microsoft",
58
- "netflix",
59
- "paypal",
60
- "slack",
61
- "stripe",
62
- "tiktok",
63
- "twitter",
64
- "uber",
65
- "venmo",
66
- ]);
67
- const TUNNEL_SPECIFIC_RESERVED = new Set([
68
- // Inkbox-owned subdomains
69
- "admin", "api", "app", "console", "mail", "mcp", "tunnel", "www",
70
- // Common infra subdomains
71
- "assets", "beta", "blog", "cdn", "css", "dev", "development",
72
- "dns", "docs", "documentation", "ftp", "imap", "img", "images",
73
- "internal", "intranet", "js", "local", "localhost", "media",
74
- "mx", "pop", "pop3", "private", "prod", "production", "proxy",
75
- "smtp", "ssh", "ssl", "stage", "staging", "static", "test",
76
- "tls", "vpn", "webhook", "webhooks",
77
- // Status / monitoring
78
- "grafana", "health", "healthcheck", "kibana", "metrics",
79
- "monitor", "monitoring", "prometheus", "status",
80
- // Auth / identity
81
- "auth", "idp", "login", "mfa", "oauth", "otp", "saml", "signin",
82
- "signup", "sso",
83
- // Support / business
84
- "accounts", "billing", "careers", "compliance", "contact", "help",
85
- "info", "jobs", "legal", "press", "privacy", "sales", "security",
86
- "support",
87
- ]);
88
- const ALL_RESERVED = new Set([
89
- ...INKBOX_BRAND_RESERVED,
90
- ...AI_PROVIDER_RESERVED,
91
- ...MAJOR_TECH_RESERVED,
92
- ...TUNNEL_SPECIFIC_RESERVED,
93
- ]);
94
- /**
95
- * Lowercase `s` and strip every character in `separators`. Mirrors
96
- * `canonicalize()` in the server source. The default `separators="-"`
97
- * is the DNS-label-strict form (DNS labels carry only `-`).
98
- */
99
- function canonicalize(s, separators = "-") {
100
- let out = s.toLowerCase();
101
- for (const sep of separators) {
102
- out = out.split(sep).join("");
103
- }
104
- return out;
105
- }
106
- /**
107
- * Build a regex matching any of `names` as singletons, or any pair of
108
- * `names` in either order with optional `._-` separator.
109
- */
110
- function namePattern(names) {
111
- const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
112
- const singles = names.map(escape).join("|");
113
- const pairs = [];
114
- for (let i = 0; i < names.length; i++) {
115
- for (let j = i + 1; j < names.length; j++) {
116
- const a = escape(names[i]);
117
- const b = escape(names[j]);
118
- pairs.push(`${a}[._-]?${b}`);
119
- pairs.push(`${b}[._-]?${a}`);
120
- }
121
- }
122
- return new RegExp(`^(?:${[singles, ...pairs].join("|")})$`, "i");
123
- }
124
- const TEAM_MEMBER_NAME_PATTERNS = [
125
- namePattern(["ray", "ruizhi", "liao"]),
126
- namePattern(["dima", "dmytro", "vremenko"]),
127
- namePattern(["alex", "alexander", "wilcox"]),
128
- ];
129
- /**
130
- * Returns true if `name` collides with the reserved set: tunnel-specific
131
- * labels, brand-impersonation labels, the Amplify preview prefixes
132
- * (`pr-*` / `console-pr-*`), or any Inkbox team-member name pattern.
133
- *
134
- * Mirrors `_is_reserved_tunnel_name` in the server source.
135
- */
136
- export function isReservedName(name) {
137
- if (name.startsWith("console-pr-") || name.startsWith("pr-")) {
138
- return true;
139
- }
140
- if (ALL_RESERVED.has(canonicalize(name, "-"))) {
141
- return true;
142
- }
143
- for (const pattern of TEAM_MEMBER_NAME_PATTERNS) {
144
- if (pattern.test(name))
145
- return true;
146
- }
147
- return false;
148
- }
149
- //# sourceMappingURL=_reserved_names%202.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_reserved_names 2.js","sourceRoot":"","sources":["../../src/tunnels/_reserved_names 2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,WAAW;IACX,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,UAAU;IACV,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC;IACxD,WAAW;IACX,WAAW;IACX,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,U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