shipmail 0.2.3 → 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 CHANGED
@@ -18,6 +18,7 @@ Official TypeScript SDK for the [Shipmail](https://shipmail.to) API. Zero runtim
18
18
  - [Domains](#domains)
19
19
  - [Mailboxes](#mailboxes)
20
20
  - [Messages](#messages)
21
+ - [Scheduled messages and attachments](#scheduled-messages-and-attachments)
21
22
  - [Sandbox](#sandbox)
22
23
  - [Threads](#threads)
23
24
  - [Reply scans](#reply-scans)
@@ -159,8 +160,6 @@ const folder = await shipmail.mailboxes.createFolder("mbx_...", {
159
160
  await shipmail.mailboxes.updateFolder("mbx_...", folder.id, { name: "VIP Clients" });
160
161
  await shipmail.mailboxes.deleteFolder("mbx_...", folder.id);
161
162
  const identities = await shipmail.mailboxes.listIdentities("mbx_...");
162
- const rules = await shipmail.mailboxes.getRules("mbx_...");
163
- await shipmail.mailboxes.updateRules("mbx_...", { rules: rules.rules });
164
163
  await shipmail.mailboxes.updateSpamFilter("mbx_...", { threshold: 8 });
165
164
  await shipmail.mailboxes.delete("mbx_...");
166
165
 
@@ -214,9 +213,69 @@ await shipmail.messages.reply("msg_...", {
214
213
  });
215
214
  ```
216
215
 
216
+ ## Scheduled messages and attachments
217
+
218
+ Stage raw files up to 25 MB, then reference their opaque IDs from send or scheduled-update calls.
219
+ The older base64 `attachments` field still works, but staged IDs avoid putting file bytes in JSON.
220
+
221
+ ```ts
222
+ const bytes = await Bun.file("./invoice.pdf").arrayBuffer();
223
+ const attachment = await shipmail.mailboxes.stageAttachment("mbx_...", {
224
+ filename: "invoice.pdf",
225
+ content_type: "application/pdf",
226
+ data: bytes,
227
+ });
228
+
229
+ const scheduled = await shipmail.messages.send({
230
+ mailbox_id: "mbx_...",
231
+ to: ["customer@example.com"],
232
+ subject: "Invoice",
233
+ text: "Attached.",
234
+ staged_attachment_ids: [attachment.id],
235
+ scheduled_at: "2026-08-01T08:00:00.000Z",
236
+ });
237
+
238
+ const pending = await shipmail.scheduledMessages.list();
239
+ const detail = await shipmail.scheduledMessages.get(scheduled.id);
240
+ await shipmail.scheduledMessages.update(scheduled.id, {
241
+ to: detail.to,
242
+ subject: detail.subject,
243
+ text: detail.text ?? "",
244
+ staged_attachment_ids: [attachment.id],
245
+ scheduled_at: "2026-08-02T08:00:00.000Z",
246
+ });
247
+ await shipmail.scheduledMessages.cancel(scheduled.id);
248
+ ```
249
+
250
+ Staged IDs expire after 24 hours and are bound to the API key, organization, mailbox, and file
251
+ metadata that created them.
252
+
253
+ For browser-hosted components that must keep the ShipMail API key off the page, prepare a
254
+ five-minute, single-use upload URL:
255
+
256
+ ```ts
257
+ const prepared = await shipmail.mailboxes.prepareStagedAttachmentUpload("mbx_...", {
258
+ filename: "invoice.pdf",
259
+ content_type: "application/pdf",
260
+ size: bytes.byteLength,
261
+ sha256: "<lowercase SHA-256 of the exact bytes>",
262
+ });
263
+
264
+ await fetch(prepared.upload_url, {
265
+ method: "POST",
266
+ body: bytes,
267
+ headers: { "Content-Type": prepared.content_type },
268
+ credentials: "omit",
269
+ redirect: "error",
270
+ });
271
+ ```
272
+
273
+ The upload succeeds only when filename, MIME type, byte size, and digest match the preparation
274
+ request. The returned upload URL is a secret and cannot be replayed after a successful upload.
275
+
217
276
  ## Sandbox
218
277
 
219
- Create a test API key (`sm_test_...`) to simulate email without contacting real recipients. Test messages, threads, rules, webhooks, quota, suppressions, and reputation are isolated from live mode.
278
+ Create a test API key (`sm_test_...`) to simulate email without contacting real recipients. Test messages, threads, Assistant automations, webhooks, quota, suppressions, and reputation are isolated from live mode.
220
279
 
221
280
  ```ts
222
281
  const testClient = new ShipMailClient("sm_test_...");
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ // src/api-key-scopes.ts
4
+ var API_KEY_SCOPES = [
5
+ "*",
6
+ "audiences:read",
7
+ "audiences:write",
8
+ "booking_pages:read",
9
+ "booking_pages:write",
10
+ "calendar:read",
11
+ "calendar:write",
12
+ "domains:read",
13
+ "domains:write",
14
+ "mailboxes:read",
15
+ "mailboxes:export",
16
+ "mailboxes:write",
17
+ "mailbox_credentials:read",
18
+ "mailbox_credentials:write",
19
+ "mailbox_forwarding:read",
20
+ "mailbox_forwarding:write",
21
+ "messages:read",
22
+ "messages:write",
23
+ "drafts:write",
24
+ "messages:send",
25
+ "newsletters:read",
26
+ "newsletters:write",
27
+ "threads:read",
28
+ "webhooks:read",
29
+ "webhooks:write",
30
+ "suppressions:read",
31
+ "suppressions:write",
32
+ "partner:organizations:read",
33
+ "partner:organizations:write",
34
+ "partner:organizations:access",
35
+ "partner:mailbox_credentials:issue",
36
+ "partner:usage:read"
37
+ ];
38
+ var API_KEY_SCOPE_DESCRIPTIONS = {
39
+ "*": "All non-partner API endpoints in this organization.",
40
+ "audiences:read": "List and retrieve newsletter audiences and their subscribers.",
41
+ "audiences:write": "Create audiences and add, update, or remove their subscribers.",
42
+ "booking_pages:read": "List and retrieve booking pages.",
43
+ "booking_pages:write": "Create, update, and delete booking pages.",
44
+ "calendar:read": "List and retrieve calendar events and open availability.",
45
+ "calendar:write": "Create, update, and delete calendar events.",
46
+ "domains:read": "List, retrieve, and verify domains.",
47
+ "domains:write": "Create, update, and delete domains.",
48
+ "mailboxes:read": "List and retrieve mailboxes.",
49
+ "mailboxes:export": "Create and download mailbox content exports.",
50
+ "mailboxes:write": "Create, update, suspend, resume, and delete mailboxes.",
51
+ "mailbox_credentials:read": "List revocable app passwords for allowed mailboxes.",
52
+ "mailbox_credentials:write": "Create and revoke app passwords for allowed mailboxes.",
53
+ "mailbox_forwarding:read": "List forwarding destinations for allowed mailboxes.",
54
+ "mailbox_forwarding:write": "Create and remove forwarding destinations for allowed mailboxes.",
55
+ "messages:read": "List and retrieve messages.",
56
+ "messages:write": "Update, move, delete, and inject sandbox messages.",
57
+ "drafts:write": "Create agent-safe reply drafts with server-derived recipients.",
58
+ "messages:send": "Send messages, replies, and approved reply drafts.",
59
+ "newsletters:read": "List and retrieve newsletter drafts and campaigns.",
60
+ "newsletters:write": "Create, update, test, schedule, cancel, and resume newsletters.",
61
+ "threads:read": "List threads and retrieve thread messages.",
62
+ "webhooks:read": "List webhooks, retrieve webhooks, and list deliveries.",
63
+ "webhooks:write": "Create, update, delete, test, and rotate webhooks.",
64
+ "suppressions:read": "List suppressed recipient addresses.",
65
+ "suppressions:write": "Remove addresses from the suppression list.",
66
+ "partner:organizations:read": "List and retrieve this partner's child organizations.",
67
+ "partner:organizations:write": "Create and manage this partner's child organizations.",
68
+ "partner:organizations:access": "Act on an active child using the delegated organization header.",
69
+ "partner:mailbox_credentials:issue": "List and consume operator-approved grants for embedded-webmail credentials.",
70
+ "partner:usage:read": "Read consolidated child and mailbox usage for this partner."
71
+ };
72
+ function isApiKeyScope(value) {
73
+ return API_KEY_SCOPES.some((scope) => scope === value);
74
+ }
75
+ function apiKeyScopesGrant(grantedScopes, requiredScope) {
76
+ if (requiredScope === "public") return true;
77
+ if (requiredScope.startsWith("partner:")) return grantedScopes.includes(requiredScope);
78
+ return grantedScopes.includes("*") || grantedScopes.includes(requiredScope);
79
+ }
80
+
81
+ exports.API_KEY_SCOPES = API_KEY_SCOPES;
82
+ exports.API_KEY_SCOPE_DESCRIPTIONS = API_KEY_SCOPE_DESCRIPTIONS;
83
+ exports.apiKeyScopesGrant = apiKeyScopesGrant;
84
+ exports.isApiKeyScope = isApiKeyScope;
85
+ //# sourceMappingURL=api-key-scopes.cjs.map
86
+ //# sourceMappingURL=api-key-scopes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/api-key-scopes.ts"],"names":[],"mappings":";;;AAAO,IAAM,cAAA,GAAiB;AAAA,EAC5B,GAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,oBAAA;AAAA,EACA,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,0BAAA;AAAA,EACA,2BAAA;AAAA,EACA,yBAAA;AAAA,EACA,0BAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,4BAAA;AAAA,EACA,6BAAA;AAAA,EACA,8BAAA;AAAA,EACA,mCAAA;AAAA,EACA;AACF;AAIO,IAAM,0BAAA,GAAoE;AAAA,EAC/E,GAAA,EAAK,qDAAA;AAAA,EACL,gBAAA,EAAkB,+DAAA;AAAA,EAClB,iBAAA,EAAmB,gEAAA;AAAA,EACnB,oBAAA,EAAsB,kCAAA;AAAA,EACtB,qBAAA,EAAuB,2CAAA;AAAA,EACvB,eAAA,EAAiB,0DAAA;AAAA,EACjB,gBAAA,EAAkB,6CAAA;AAAA,EAClB,cAAA,EAAgB,qCAAA;AAAA,EAChB,eAAA,EAAiB,qCAAA;AAAA,EACjB,gBAAA,EAAkB,8BAAA;AAAA,EAClB,kBAAA,EAAoB,8CAAA;AAAA,EACpB,iBAAA,EAAmB,wDAAA;AAAA,EACnB,0BAAA,EAA4B,qDAAA;AAAA,EAC5B,2BAAA,EAA6B,wDAAA;AAAA,EAC7B,yBAAA,EAA2B,qDAAA;AAAA,EAC3B,0BAAA,EAA4B,kEAAA;AAAA,EAC5B,eAAA,EAAiB,6BAAA;AAAA,EACjB,gBAAA,EAAkB,oDAAA;AAAA,EAClB,cAAA,EAAgB,gEAAA;AAAA,EAChB,eAAA,EAAiB,oDAAA;AAAA,EACjB,kBAAA,EAAoB,oDAAA;AAAA,EACpB,mBAAA,EAAqB,iEAAA;AAAA,EACrB,cAAA,EAAgB,4CAAA;AAAA,EAChB,eAAA,EAAiB,wDAAA;AAAA,EACjB,gBAAA,EAAkB,oDAAA;AAAA,EAClB,mBAAA,EAAqB,sCAAA;AAAA,EACrB,oBAAA,EAAsB,6CAAA;AAAA,EACtB,4BAAA,EAA8B,uDAAA;AAAA,EAC9B,6BAAA,EAA+B,uDAAA;AAAA,EAC/B,8BAAA,EAAgC,iEAAA;AAAA,EAChC,mCAAA,EACE,6EAAA;AAAA,EACF,oBAAA,EAAsB;AACxB;AAEO,SAAS,cAAc,KAAA,EAAqC;AACjE,EAAA,OAAO,cAAA,CAAe,IAAA,CAAK,CAAC,KAAA,KAAU,UAAU,KAAK,CAAA;AACvD;AAEO,SAAS,iBAAA,CACd,eACA,aAAA,EACS;AACT,EAAA,IAAI,aAAA,KAAkB,UAAU,OAAO,IAAA;AACvC,EAAA,IAAI,cAAc,UAAA,CAAW,UAAU,GAAG,OAAO,aAAA,CAAc,SAAS,aAAa,CAAA;AACrF,EAAA,OAAO,cAAc,QAAA,CAAS,GAAG,CAAA,IAAK,aAAA,CAAc,SAAS,aAAa,CAAA;AAC5E","file":"api-key-scopes.cjs","sourcesContent":["export const API_KEY_SCOPES = [\n \"*\",\n \"audiences:read\",\n \"audiences:write\",\n \"booking_pages:read\",\n \"booking_pages:write\",\n \"calendar:read\",\n \"calendar:write\",\n \"domains:read\",\n \"domains:write\",\n \"mailboxes:read\",\n \"mailboxes:export\",\n \"mailboxes:write\",\n \"mailbox_credentials:read\",\n \"mailbox_credentials:write\",\n \"mailbox_forwarding:read\",\n \"mailbox_forwarding:write\",\n \"messages:read\",\n \"messages:write\",\n \"drafts:write\",\n \"messages:send\",\n \"newsletters:read\",\n \"newsletters:write\",\n \"threads:read\",\n \"webhooks:read\",\n \"webhooks:write\",\n \"suppressions:read\",\n \"suppressions:write\",\n \"partner:organizations:read\",\n \"partner:organizations:write\",\n \"partner:organizations:access\",\n \"partner:mailbox_credentials:issue\",\n \"partner:usage:read\",\n] as const;\n\nexport type ApiKeyScope = (typeof API_KEY_SCOPES)[number];\n\nexport const API_KEY_SCOPE_DESCRIPTIONS: Readonly<Record<ApiKeyScope, string>> = {\n \"*\": \"All non-partner API endpoints in this organization.\",\n \"audiences:read\": \"List and retrieve newsletter audiences and their subscribers.\",\n \"audiences:write\": \"Create audiences and add, update, or remove their subscribers.\",\n \"booking_pages:read\": \"List and retrieve booking pages.\",\n \"booking_pages:write\": \"Create, update, and delete booking pages.\",\n \"calendar:read\": \"List and retrieve calendar events and open availability.\",\n \"calendar:write\": \"Create, update, and delete calendar events.\",\n \"domains:read\": \"List, retrieve, and verify domains.\",\n \"domains:write\": \"Create, update, and delete domains.\",\n \"mailboxes:read\": \"List and retrieve mailboxes.\",\n \"mailboxes:export\": \"Create and download mailbox content exports.\",\n \"mailboxes:write\": \"Create, update, suspend, resume, and delete mailboxes.\",\n \"mailbox_credentials:read\": \"List revocable app passwords for allowed mailboxes.\",\n \"mailbox_credentials:write\": \"Create and revoke app passwords for allowed mailboxes.\",\n \"mailbox_forwarding:read\": \"List forwarding destinations for allowed mailboxes.\",\n \"mailbox_forwarding:write\": \"Create and remove forwarding destinations for allowed mailboxes.\",\n \"messages:read\": \"List and retrieve messages.\",\n \"messages:write\": \"Update, move, delete, and inject sandbox messages.\",\n \"drafts:write\": \"Create agent-safe reply drafts with server-derived recipients.\",\n \"messages:send\": \"Send messages, replies, and approved reply drafts.\",\n \"newsletters:read\": \"List and retrieve newsletter drafts and campaigns.\",\n \"newsletters:write\": \"Create, update, test, schedule, cancel, and resume newsletters.\",\n \"threads:read\": \"List threads and retrieve thread messages.\",\n \"webhooks:read\": \"List webhooks, retrieve webhooks, and list deliveries.\",\n \"webhooks:write\": \"Create, update, delete, test, and rotate webhooks.\",\n \"suppressions:read\": \"List suppressed recipient addresses.\",\n \"suppressions:write\": \"Remove addresses from the suppression list.\",\n \"partner:organizations:read\": \"List and retrieve this partner's child organizations.\",\n \"partner:organizations:write\": \"Create and manage this partner's child organizations.\",\n \"partner:organizations:access\": \"Act on an active child using the delegated organization header.\",\n \"partner:mailbox_credentials:issue\":\n \"List and consume operator-approved grants for embedded-webmail credentials.\",\n \"partner:usage:read\": \"Read consolidated child and mailbox usage for this partner.\",\n};\n\nexport function isApiKeyScope(value: string): value is ApiKeyScope {\n return API_KEY_SCOPES.some((scope) => scope === value);\n}\n\nexport function apiKeyScopesGrant(\n grantedScopes: readonly string[],\n requiredScope: ApiKeyScope | \"public\",\n): boolean {\n if (requiredScope === \"public\") return true;\n if (requiredScope.startsWith(\"partner:\")) return grantedScopes.includes(requiredScope);\n return grantedScopes.includes(\"*\") || grantedScopes.includes(requiredScope);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ declare const API_KEY_SCOPES: readonly ["*", "audiences:read", "audiences:write", "booking_pages:read", "booking_pages:write", "calendar:read", "calendar:write", "domains:read", "domains:write", "mailboxes:read", "mailboxes:export", "mailboxes:write", "mailbox_credentials:read", "mailbox_credentials:write", "mailbox_forwarding:read", "mailbox_forwarding:write", "messages:read", "messages:write", "drafts:write", "messages:send", "newsletters:read", "newsletters:write", "threads:read", "webhooks:read", "webhooks:write", "suppressions:read", "suppressions:write", "partner:organizations:read", "partner:organizations:write", "partner:organizations:access", "partner:mailbox_credentials:issue", "partner:usage:read"];
2
+ type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
3
+ declare const API_KEY_SCOPE_DESCRIPTIONS: Readonly<Record<ApiKeyScope, string>>;
4
+ declare function isApiKeyScope(value: string): value is ApiKeyScope;
5
+ declare function apiKeyScopesGrant(grantedScopes: readonly string[], requiredScope: ApiKeyScope | "public"): boolean;
6
+
7
+ export { API_KEY_SCOPES, API_KEY_SCOPE_DESCRIPTIONS, type ApiKeyScope, apiKeyScopesGrant, isApiKeyScope };
@@ -0,0 +1,7 @@
1
+ declare const API_KEY_SCOPES: readonly ["*", "audiences:read", "audiences:write", "booking_pages:read", "booking_pages:write", "calendar:read", "calendar:write", "domains:read", "domains:write", "mailboxes:read", "mailboxes:export", "mailboxes:write", "mailbox_credentials:read", "mailbox_credentials:write", "mailbox_forwarding:read", "mailbox_forwarding:write", "messages:read", "messages:write", "drafts:write", "messages:send", "newsletters:read", "newsletters:write", "threads:read", "webhooks:read", "webhooks:write", "suppressions:read", "suppressions:write", "partner:organizations:read", "partner:organizations:write", "partner:organizations:access", "partner:mailbox_credentials:issue", "partner:usage:read"];
2
+ type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
3
+ declare const API_KEY_SCOPE_DESCRIPTIONS: Readonly<Record<ApiKeyScope, string>>;
4
+ declare function isApiKeyScope(value: string): value is ApiKeyScope;
5
+ declare function apiKeyScopesGrant(grantedScopes: readonly string[], requiredScope: ApiKeyScope | "public"): boolean;
6
+
7
+ export { API_KEY_SCOPES, API_KEY_SCOPE_DESCRIPTIONS, type ApiKeyScope, apiKeyScopesGrant, isApiKeyScope };
@@ -0,0 +1,81 @@
1
+ // src/api-key-scopes.ts
2
+ var API_KEY_SCOPES = [
3
+ "*",
4
+ "audiences:read",
5
+ "audiences:write",
6
+ "booking_pages:read",
7
+ "booking_pages:write",
8
+ "calendar:read",
9
+ "calendar:write",
10
+ "domains:read",
11
+ "domains:write",
12
+ "mailboxes:read",
13
+ "mailboxes:export",
14
+ "mailboxes:write",
15
+ "mailbox_credentials:read",
16
+ "mailbox_credentials:write",
17
+ "mailbox_forwarding:read",
18
+ "mailbox_forwarding:write",
19
+ "messages:read",
20
+ "messages:write",
21
+ "drafts:write",
22
+ "messages:send",
23
+ "newsletters:read",
24
+ "newsletters:write",
25
+ "threads:read",
26
+ "webhooks:read",
27
+ "webhooks:write",
28
+ "suppressions:read",
29
+ "suppressions:write",
30
+ "partner:organizations:read",
31
+ "partner:organizations:write",
32
+ "partner:organizations:access",
33
+ "partner:mailbox_credentials:issue",
34
+ "partner:usage:read"
35
+ ];
36
+ var API_KEY_SCOPE_DESCRIPTIONS = {
37
+ "*": "All non-partner API endpoints in this organization.",
38
+ "audiences:read": "List and retrieve newsletter audiences and their subscribers.",
39
+ "audiences:write": "Create audiences and add, update, or remove their subscribers.",
40
+ "booking_pages:read": "List and retrieve booking pages.",
41
+ "booking_pages:write": "Create, update, and delete booking pages.",
42
+ "calendar:read": "List and retrieve calendar events and open availability.",
43
+ "calendar:write": "Create, update, and delete calendar events.",
44
+ "domains:read": "List, retrieve, and verify domains.",
45
+ "domains:write": "Create, update, and delete domains.",
46
+ "mailboxes:read": "List and retrieve mailboxes.",
47
+ "mailboxes:export": "Create and download mailbox content exports.",
48
+ "mailboxes:write": "Create, update, suspend, resume, and delete mailboxes.",
49
+ "mailbox_credentials:read": "List revocable app passwords for allowed mailboxes.",
50
+ "mailbox_credentials:write": "Create and revoke app passwords for allowed mailboxes.",
51
+ "mailbox_forwarding:read": "List forwarding destinations for allowed mailboxes.",
52
+ "mailbox_forwarding:write": "Create and remove forwarding destinations for allowed mailboxes.",
53
+ "messages:read": "List and retrieve messages.",
54
+ "messages:write": "Update, move, delete, and inject sandbox messages.",
55
+ "drafts:write": "Create agent-safe reply drafts with server-derived recipients.",
56
+ "messages:send": "Send messages, replies, and approved reply drafts.",
57
+ "newsletters:read": "List and retrieve newsletter drafts and campaigns.",
58
+ "newsletters:write": "Create, update, test, schedule, cancel, and resume newsletters.",
59
+ "threads:read": "List threads and retrieve thread messages.",
60
+ "webhooks:read": "List webhooks, retrieve webhooks, and list deliveries.",
61
+ "webhooks:write": "Create, update, delete, test, and rotate webhooks.",
62
+ "suppressions:read": "List suppressed recipient addresses.",
63
+ "suppressions:write": "Remove addresses from the suppression list.",
64
+ "partner:organizations:read": "List and retrieve this partner's child organizations.",
65
+ "partner:organizations:write": "Create and manage this partner's child organizations.",
66
+ "partner:organizations:access": "Act on an active child using the delegated organization header.",
67
+ "partner:mailbox_credentials:issue": "List and consume operator-approved grants for embedded-webmail credentials.",
68
+ "partner:usage:read": "Read consolidated child and mailbox usage for this partner."
69
+ };
70
+ function isApiKeyScope(value) {
71
+ return API_KEY_SCOPES.some((scope) => scope === value);
72
+ }
73
+ function apiKeyScopesGrant(grantedScopes, requiredScope) {
74
+ if (requiredScope === "public") return true;
75
+ if (requiredScope.startsWith("partner:")) return grantedScopes.includes(requiredScope);
76
+ return grantedScopes.includes("*") || grantedScopes.includes(requiredScope);
77
+ }
78
+
79
+ export { API_KEY_SCOPES, API_KEY_SCOPE_DESCRIPTIONS, apiKeyScopesGrant, isApiKeyScope };
80
+ //# sourceMappingURL=api-key-scopes.js.map
81
+ //# sourceMappingURL=api-key-scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/api-key-scopes.ts"],"names":[],"mappings":";AAAO,IAAM,cAAA,GAAiB;AAAA,EAC5B,GAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,oBAAA;AAAA,EACA,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,0BAAA;AAAA,EACA,2BAAA;AAAA,EACA,yBAAA;AAAA,EACA,0BAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,4BAAA;AAAA,EACA,6BAAA;AAAA,EACA,8BAAA;AAAA,EACA,mCAAA;AAAA,EACA;AACF;AAIO,IAAM,0BAAA,GAAoE;AAAA,EAC/E,GAAA,EAAK,qDAAA;AAAA,EACL,gBAAA,EAAkB,+DAAA;AAAA,EAClB,iBAAA,EAAmB,gEAAA;AAAA,EACnB,oBAAA,EAAsB,kCAAA;AAAA,EACtB,qBAAA,EAAuB,2CAAA;AAAA,EACvB,eAAA,EAAiB,0DAAA;AAAA,EACjB,gBAAA,EAAkB,6CAAA;AAAA,EAClB,cAAA,EAAgB,qCAAA;AAAA,EAChB,eAAA,EAAiB,qCAAA;AAAA,EACjB,gBAAA,EAAkB,8BAAA;AAAA,EAClB,kBAAA,EAAoB,8CAAA;AAAA,EACpB,iBAAA,EAAmB,wDAAA;AAAA,EACnB,0BAAA,EAA4B,qDAAA;AAAA,EAC5B,2BAAA,EAA6B,wDAAA;AAAA,EAC7B,yBAAA,EAA2B,qDAAA;AAAA,EAC3B,0BAAA,EAA4B,kEAAA;AAAA,EAC5B,eAAA,EAAiB,6BAAA;AAAA,EACjB,gBAAA,EAAkB,oDAAA;AAAA,EAClB,cAAA,EAAgB,gEAAA;AAAA,EAChB,eAAA,EAAiB,oDAAA;AAAA,EACjB,kBAAA,EAAoB,oDAAA;AAAA,EACpB,mBAAA,EAAqB,iEAAA;AAAA,EACrB,cAAA,EAAgB,4CAAA;AAAA,EAChB,eAAA,EAAiB,wDAAA;AAAA,EACjB,gBAAA,EAAkB,oDAAA;AAAA,EAClB,mBAAA,EAAqB,sCAAA;AAAA,EACrB,oBAAA,EAAsB,6CAAA;AAAA,EACtB,4BAAA,EAA8B,uDAAA;AAAA,EAC9B,6BAAA,EAA+B,uDAAA;AAAA,EAC/B,8BAAA,EAAgC,iEAAA;AAAA,EAChC,mCAAA,EACE,6EAAA;AAAA,EACF,oBAAA,EAAsB;AACxB;AAEO,SAAS,cAAc,KAAA,EAAqC;AACjE,EAAA,OAAO,cAAA,CAAe,IAAA,CAAK,CAAC,KAAA,KAAU,UAAU,KAAK,CAAA;AACvD;AAEO,SAAS,iBAAA,CACd,eACA,aAAA,EACS;AACT,EAAA,IAAI,aAAA,KAAkB,UAAU,OAAO,IAAA;AACvC,EAAA,IAAI,cAAc,UAAA,CAAW,UAAU,GAAG,OAAO,aAAA,CAAc,SAAS,aAAa,CAAA;AACrF,EAAA,OAAO,cAAc,QAAA,CAAS,GAAG,CAAA,IAAK,aAAA,CAAc,SAAS,aAAa,CAAA;AAC5E","file":"api-key-scopes.js","sourcesContent":["export const API_KEY_SCOPES = [\n \"*\",\n \"audiences:read\",\n \"audiences:write\",\n \"booking_pages:read\",\n \"booking_pages:write\",\n \"calendar:read\",\n \"calendar:write\",\n \"domains:read\",\n \"domains:write\",\n \"mailboxes:read\",\n \"mailboxes:export\",\n \"mailboxes:write\",\n \"mailbox_credentials:read\",\n \"mailbox_credentials:write\",\n \"mailbox_forwarding:read\",\n \"mailbox_forwarding:write\",\n \"messages:read\",\n \"messages:write\",\n \"drafts:write\",\n \"messages:send\",\n \"newsletters:read\",\n \"newsletters:write\",\n \"threads:read\",\n \"webhooks:read\",\n \"webhooks:write\",\n \"suppressions:read\",\n \"suppressions:write\",\n \"partner:organizations:read\",\n \"partner:organizations:write\",\n \"partner:organizations:access\",\n \"partner:mailbox_credentials:issue\",\n \"partner:usage:read\",\n] as const;\n\nexport type ApiKeyScope = (typeof API_KEY_SCOPES)[number];\n\nexport const API_KEY_SCOPE_DESCRIPTIONS: Readonly<Record<ApiKeyScope, string>> = {\n \"*\": \"All non-partner API endpoints in this organization.\",\n \"audiences:read\": \"List and retrieve newsletter audiences and their subscribers.\",\n \"audiences:write\": \"Create audiences and add, update, or remove their subscribers.\",\n \"booking_pages:read\": \"List and retrieve booking pages.\",\n \"booking_pages:write\": \"Create, update, and delete booking pages.\",\n \"calendar:read\": \"List and retrieve calendar events and open availability.\",\n \"calendar:write\": \"Create, update, and delete calendar events.\",\n \"domains:read\": \"List, retrieve, and verify domains.\",\n \"domains:write\": \"Create, update, and delete domains.\",\n \"mailboxes:read\": \"List and retrieve mailboxes.\",\n \"mailboxes:export\": \"Create and download mailbox content exports.\",\n \"mailboxes:write\": \"Create, update, suspend, resume, and delete mailboxes.\",\n \"mailbox_credentials:read\": \"List revocable app passwords for allowed mailboxes.\",\n \"mailbox_credentials:write\": \"Create and revoke app passwords for allowed mailboxes.\",\n \"mailbox_forwarding:read\": \"List forwarding destinations for allowed mailboxes.\",\n \"mailbox_forwarding:write\": \"Create and remove forwarding destinations for allowed mailboxes.\",\n \"messages:read\": \"List and retrieve messages.\",\n \"messages:write\": \"Update, move, delete, and inject sandbox messages.\",\n \"drafts:write\": \"Create agent-safe reply drafts with server-derived recipients.\",\n \"messages:send\": \"Send messages, replies, and approved reply drafts.\",\n \"newsletters:read\": \"List and retrieve newsletter drafts and campaigns.\",\n \"newsletters:write\": \"Create, update, test, schedule, cancel, and resume newsletters.\",\n \"threads:read\": \"List threads and retrieve thread messages.\",\n \"webhooks:read\": \"List webhooks, retrieve webhooks, and list deliveries.\",\n \"webhooks:write\": \"Create, update, delete, test, and rotate webhooks.\",\n \"suppressions:read\": \"List suppressed recipient addresses.\",\n \"suppressions:write\": \"Remove addresses from the suppression list.\",\n \"partner:organizations:read\": \"List and retrieve this partner's child organizations.\",\n \"partner:organizations:write\": \"Create and manage this partner's child organizations.\",\n \"partner:organizations:access\": \"Act on an active child using the delegated organization header.\",\n \"partner:mailbox_credentials:issue\":\n \"List and consume operator-approved grants for embedded-webmail credentials.\",\n \"partner:usage:read\": \"Read consolidated child and mailbox usage for this partner.\",\n};\n\nexport function isApiKeyScope(value: string): value is ApiKeyScope {\n return API_KEY_SCOPES.some((scope) => scope === value);\n}\n\nexport function apiKeyScopesGrant(\n grantedScopes: readonly string[],\n requiredScope: ApiKeyScope | \"public\",\n): boolean {\n if (requiredScope === \"public\") return true;\n if (requiredScope.startsWith(\"partner:\")) return grantedScopes.includes(requiredScope);\n return grantedScopes.includes(\"*\") || grantedScopes.includes(requiredScope);\n}\n"]}
package/dist/index.cjs CHANGED
@@ -2,6 +2,84 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ // src/api-key-scopes.ts
6
+ var API_KEY_SCOPES = [
7
+ "*",
8
+ "audiences:read",
9
+ "audiences:write",
10
+ "booking_pages:read",
11
+ "booking_pages:write",
12
+ "calendar:read",
13
+ "calendar:write",
14
+ "domains:read",
15
+ "domains:write",
16
+ "mailboxes:read",
17
+ "mailboxes:export",
18
+ "mailboxes:write",
19
+ "mailbox_credentials:read",
20
+ "mailbox_credentials:write",
21
+ "mailbox_forwarding:read",
22
+ "mailbox_forwarding:write",
23
+ "messages:read",
24
+ "messages:write",
25
+ "drafts:write",
26
+ "messages:send",
27
+ "newsletters:read",
28
+ "newsletters:write",
29
+ "threads:read",
30
+ "webhooks:read",
31
+ "webhooks:write",
32
+ "suppressions:read",
33
+ "suppressions:write",
34
+ "partner:organizations:read",
35
+ "partner:organizations:write",
36
+ "partner:organizations:access",
37
+ "partner:mailbox_credentials:issue",
38
+ "partner:usage:read"
39
+ ];
40
+ var API_KEY_SCOPE_DESCRIPTIONS = {
41
+ "*": "All non-partner API endpoints in this organization.",
42
+ "audiences:read": "List and retrieve newsletter audiences and their subscribers.",
43
+ "audiences:write": "Create audiences and add, update, or remove their subscribers.",
44
+ "booking_pages:read": "List and retrieve booking pages.",
45
+ "booking_pages:write": "Create, update, and delete booking pages.",
46
+ "calendar:read": "List and retrieve calendar events and open availability.",
47
+ "calendar:write": "Create, update, and delete calendar events.",
48
+ "domains:read": "List, retrieve, and verify domains.",
49
+ "domains:write": "Create, update, and delete domains.",
50
+ "mailboxes:read": "List and retrieve mailboxes.",
51
+ "mailboxes:export": "Create and download mailbox content exports.",
52
+ "mailboxes:write": "Create, update, suspend, resume, and delete mailboxes.",
53
+ "mailbox_credentials:read": "List revocable app passwords for allowed mailboxes.",
54
+ "mailbox_credentials:write": "Create and revoke app passwords for allowed mailboxes.",
55
+ "mailbox_forwarding:read": "List forwarding destinations for allowed mailboxes.",
56
+ "mailbox_forwarding:write": "Create and remove forwarding destinations for allowed mailboxes.",
57
+ "messages:read": "List and retrieve messages.",
58
+ "messages:write": "Update, move, delete, and inject sandbox messages.",
59
+ "drafts:write": "Create agent-safe reply drafts with server-derived recipients.",
60
+ "messages:send": "Send messages, replies, and approved reply drafts.",
61
+ "newsletters:read": "List and retrieve newsletter drafts and campaigns.",
62
+ "newsletters:write": "Create, update, test, schedule, cancel, and resume newsletters.",
63
+ "threads:read": "List threads and retrieve thread messages.",
64
+ "webhooks:read": "List webhooks, retrieve webhooks, and list deliveries.",
65
+ "webhooks:write": "Create, update, delete, test, and rotate webhooks.",
66
+ "suppressions:read": "List suppressed recipient addresses.",
67
+ "suppressions:write": "Remove addresses from the suppression list.",
68
+ "partner:organizations:read": "List and retrieve this partner's child organizations.",
69
+ "partner:organizations:write": "Create and manage this partner's child organizations.",
70
+ "partner:organizations:access": "Act on an active child using the delegated organization header.",
71
+ "partner:mailbox_credentials:issue": "List and consume operator-approved grants for embedded-webmail credentials.",
72
+ "partner:usage:read": "Read consolidated child and mailbox usage for this partner."
73
+ };
74
+ function isApiKeyScope(value) {
75
+ return API_KEY_SCOPES.some((scope) => scope === value);
76
+ }
77
+ function apiKeyScopesGrant(grantedScopes, requiredScope) {
78
+ if (requiredScope === "public") return true;
79
+ if (requiredScope.startsWith("partner:")) return grantedScopes.includes(requiredScope);
80
+ return grantedScopes.includes("*") || grantedScopes.includes(requiredScope);
81
+ }
82
+
5
83
  // src/errors.ts
6
84
  var ShipMailError = class extends Error {
7
85
  constructor(message, options) {
@@ -413,6 +491,17 @@ var Calendar = class extends ApiResource {
413
491
  }
414
492
  };
415
493
 
494
+ // src/resources/capabilities.ts
495
+ var Capabilities = class extends ApiResource {
496
+ get(options) {
497
+ return this.client.request({
498
+ method: "GET",
499
+ path: "/capabilities",
500
+ methodOptions: options
501
+ });
502
+ }
503
+ };
504
+
416
505
  // src/resources/domains.ts
417
506
  var Domains = class extends ApiResource {
418
507
  create(params, options) {
@@ -495,6 +584,24 @@ var Domains = class extends ApiResource {
495
584
 
496
585
  // src/resources/mailboxes.ts
497
586
  var Mailboxes = class extends ApiResource {
587
+ prepareStagedAttachmentUpload(id, params, options) {
588
+ return this.client.request({
589
+ method: "POST",
590
+ path: `/mailboxes/${encodeURIComponent(id)}/staged-attachment-upload-tokens`,
591
+ body: params,
592
+ methodOptions: options
593
+ });
594
+ }
595
+ stageAttachment(id, params, options) {
596
+ return this.client.request({
597
+ method: "POST",
598
+ path: `/mailboxes/${encodeURIComponent(id)}/staged-attachments`,
599
+ query: { filename: params.filename },
600
+ rawBody: params.data,
601
+ contentType: params.content_type,
602
+ methodOptions: options
603
+ });
604
+ }
498
605
  injectSandboxInbound(id, params, options) {
499
606
  return this.client.request({
500
607
  method: "POST",
@@ -767,21 +874,6 @@ var Mailboxes = class extends ApiResource {
767
874
  methodOptions: options
768
875
  });
769
876
  }
770
- getRules(id, options) {
771
- return this.client.request({
772
- method: "GET",
773
- path: `/mailboxes/${encodeURIComponent(id)}/rules`,
774
- methodOptions: options
775
- });
776
- }
777
- updateRules(id, params, options) {
778
- return this.client.request({
779
- method: "PUT",
780
- path: `/mailboxes/${encodeURIComponent(id)}/rules`,
781
- body: params,
782
- methodOptions: options
783
- });
784
- }
785
877
  listForwarding(id, options) {
786
878
  return this.client.request({
787
879
  method: "GET",
@@ -1172,6 +1264,44 @@ var ReplyScans = class extends ApiResource {
1172
1264
  }
1173
1265
  };
1174
1266
 
1267
+ // src/resources/scheduled-messages.ts
1268
+ var ScheduledMessages = class extends ApiResource {
1269
+ list(params, options) {
1270
+ return this.client.request({
1271
+ method: "GET",
1272
+ path: "/scheduled-messages",
1273
+ query: {
1274
+ include_held: params?.include_held,
1275
+ search: params?.search,
1276
+ limit: params?.limit
1277
+ },
1278
+ methodOptions: options
1279
+ });
1280
+ }
1281
+ get(id, options) {
1282
+ return this.client.request({
1283
+ method: "GET",
1284
+ path: `/scheduled-messages/${encodeURIComponent(id)}`,
1285
+ methodOptions: options
1286
+ });
1287
+ }
1288
+ update(id, params, options) {
1289
+ return this.client.request({
1290
+ method: "PATCH",
1291
+ path: `/scheduled-messages/${encodeURIComponent(id)}`,
1292
+ body: params,
1293
+ methodOptions: options
1294
+ });
1295
+ }
1296
+ cancel(id, options) {
1297
+ return this.client.request({
1298
+ method: "DELETE",
1299
+ path: `/scheduled-messages/${encodeURIComponent(id)}`,
1300
+ methodOptions: options
1301
+ });
1302
+ }
1303
+ };
1304
+
1175
1305
  // src/resources/status.ts
1176
1306
  var Status = class extends ApiResource {
1177
1307
  get(options) {
@@ -1355,7 +1485,7 @@ var Webhooks = class extends ApiResource {
1355
1485
  };
1356
1486
 
1357
1487
  // src/version.ts
1358
- var VERSION = "0.2.3";
1488
+ var VERSION = "0.4.1";
1359
1489
 
1360
1490
  // src/client.ts
1361
1491
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
@@ -1410,6 +1540,7 @@ var ShipMailClient = class {
1410
1540
  }
1411
1541
  this.audiences = new Audiences(this);
1412
1542
  this.bookingPages = new BookingPages(this);
1543
+ this.capabilities = new Capabilities(this);
1413
1544
  this.calendar = new Calendar(this);
1414
1545
  this.domains = new Domains(this);
1415
1546
  this.mailboxes = new Mailboxes(this);
@@ -1417,6 +1548,7 @@ var ShipMailClient = class {
1417
1548
  this.newsletters = new Newsletters(this);
1418
1549
  this.partner = new Partner(this);
1419
1550
  this.replyScans = new ReplyScans(this);
1551
+ this.scheduledMessages = new ScheduledMessages(this);
1420
1552
  this.suppressions = new Suppressions(this);
1421
1553
  this.threads = new Threads(this);
1422
1554
  this.webhooks = new Webhooks(this);
@@ -1528,7 +1660,6 @@ var WEBHOOK_EVENT_TYPES = [
1528
1660
  "message.bounced",
1529
1661
  "message.complained",
1530
1662
  "thread.needs_reply",
1531
- "mailbox.rule_matched",
1532
1663
  "domain.verified",
1533
1664
  "domain.verification_failed",
1534
1665
  "domain.degraded",
@@ -1556,7 +1687,7 @@ var MESSAGE_SOURCES = [
1556
1687
  "dashboard",
1557
1688
  "inbound",
1558
1689
  "smtp",
1559
- "agent"
1690
+ "assistant"
1560
1691
  ];
1561
1692
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
1562
1693
 
@@ -1608,6 +1739,8 @@ async function verifyWebhook(body, headers, secret, options) {
1608
1739
  return parsed;
1609
1740
  }
1610
1741
 
1742
+ exports.API_KEY_SCOPES = API_KEY_SCOPES;
1743
+ exports.API_KEY_SCOPE_DESCRIPTIONS = API_KEY_SCOPE_DESCRIPTIONS;
1611
1744
  exports.AuthenticationError = AuthenticationError;
1612
1745
  exports.AuthorizationError = AuthorizationError;
1613
1746
  exports.CONFERENCING_PROVIDER_IDS = CONFERENCING_PROVIDER_IDS;
@@ -1628,7 +1761,9 @@ exports.WEBHOOK_DELIVERY_EVENT_TYPES = WEBHOOK_DELIVERY_EVENT_TYPES;
1628
1761
  exports.WEBHOOK_DELIVERY_STATUSES = WEBHOOK_DELIVERY_STATUSES;
1629
1762
  exports.WEBHOOK_EVENT_TYPES = WEBHOOK_EVENT_TYPES;
1630
1763
  exports.WebhookVerificationError = WebhookVerificationError;
1764
+ exports.apiKeyScopesGrant = apiKeyScopesGrant;
1631
1765
  exports.default = ShipMailClient;
1766
+ exports.isApiKeyScope = isApiKeyScope;
1632
1767
  exports.verifyWebhook = verifyWebhook;
1633
1768
  //# sourceMappingURL=index.cjs.map
1634
1769
  //# sourceMappingURL=index.cjs.map