shipmail 0.4.12 → 0.4.14
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/LICENSE +1 -1
- package/README.md +13 -13
- package/dist/api-key-scopes.cjs +4 -0
- package/dist/api-key-scopes.cjs.map +1 -1
- package/dist/api-key-scopes.d.cts +1 -1
- package/dist/api-key-scopes.d.ts +1 -1
- package/dist/api-key-scopes.js +4 -0
- package/dist/api-key-scopes.js.map +1 -1
- package/dist/index.cjs +71 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -23
- package/dist/index.d.ts +139 -23
- package/dist/index.js +69 -23
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -53,9 +53,9 @@ pnpm add shipmail
|
|
|
53
53
|
## Quick start
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
|
-
import {
|
|
56
|
+
import { ShipmailClient } from "shipmail";
|
|
57
57
|
|
|
58
|
-
const shipmail = new
|
|
58
|
+
const shipmail = new ShipmailClient({ apiKey: process.env.SHIPMAIL_API_KEY! });
|
|
59
59
|
|
|
60
60
|
const message = await shipmail.messages.send({
|
|
61
61
|
mailbox_id: "mbx_...",
|
|
@@ -76,13 +76,13 @@ The SDK does not auto-read environment variables. Pass the key explicitly.
|
|
|
76
76
|
You can also pass a key string directly:
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
|
-
const shipmail = new
|
|
79
|
+
const shipmail = new ShipmailClient("sm_live_...");
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
## Configuration
|
|
83
83
|
|
|
84
84
|
```ts
|
|
85
|
-
const shipmail = new
|
|
85
|
+
const shipmail = new ShipmailClient({
|
|
86
86
|
apiKey: process.env.SHIPMAIL_API_KEY!,
|
|
87
87
|
baseUrl: "https://shipmail.to/api/v1",
|
|
88
88
|
maxRetries: 2,
|
|
@@ -271,7 +271,7 @@ await shipmail.scheduledMessages.cancel(scheduled.id);
|
|
|
271
271
|
Staged IDs expire after 24 hours and are bound to the API key, organization, mailbox, and file
|
|
272
272
|
metadata that created them.
|
|
273
273
|
|
|
274
|
-
For browser-hosted components that must keep the
|
|
274
|
+
For browser-hosted components that must keep the Shipmail API key off the page, prepare a
|
|
275
275
|
five-minute, single-use upload URL:
|
|
276
276
|
|
|
277
277
|
```ts
|
|
@@ -299,7 +299,7 @@ request. The returned upload URL is a secret and cannot be replayed after a succ
|
|
|
299
299
|
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.
|
|
300
300
|
|
|
301
301
|
```ts
|
|
302
|
-
const testClient = new
|
|
302
|
+
const testClient = new ShipmailClient("sm_test_...");
|
|
303
303
|
|
|
304
304
|
await testClient.messages.send({
|
|
305
305
|
mailbox_id: "mbx_...",
|
|
@@ -506,7 +506,7 @@ const child = await shipmail.partner.createOrganization(
|
|
|
506
506
|
{ idempotencyKey: "operator-123" },
|
|
507
507
|
);
|
|
508
508
|
|
|
509
|
-
const delegated = new
|
|
509
|
+
const delegated = new ShipmailClient({
|
|
510
510
|
apiKey: process.env.SHIPMAIL_API_KEY!,
|
|
511
511
|
organizationId: child.organization_id,
|
|
512
512
|
});
|
|
@@ -668,7 +668,7 @@ await shipmail.messages.send(params, { signal: controller.signal });
|
|
|
668
668
|
Inject a custom fetch implementation for proxies, observability, or testing:
|
|
669
669
|
|
|
670
670
|
```ts
|
|
671
|
-
const shipmail = new
|
|
671
|
+
const shipmail = new ShipmailClient({
|
|
672
672
|
apiKey: process.env.SHIPMAIL_API_KEY!,
|
|
673
673
|
fetch: async (url, init) => {
|
|
674
674
|
const start = Date.now();
|
|
@@ -683,11 +683,11 @@ The custom fetch receives the same arguments as the global `fetch` and must retu
|
|
|
683
683
|
|
|
684
684
|
## Errors
|
|
685
685
|
|
|
686
|
-
The SDK throws typed errors that map to HTTP responses. All inherit from `
|
|
686
|
+
The SDK throws typed errors that map to HTTP responses. All inherit from `ShipmailError`:
|
|
687
687
|
|
|
688
688
|
```ts
|
|
689
689
|
import {
|
|
690
|
-
|
|
690
|
+
ShipmailError,
|
|
691
691
|
AuthenticationError,
|
|
692
692
|
AuthorizationError,
|
|
693
693
|
ValidationError,
|
|
@@ -709,7 +709,7 @@ try {
|
|
|
709
709
|
if (err instanceof RateLimitError) {
|
|
710
710
|
err.retryAfter; // seconds
|
|
711
711
|
}
|
|
712
|
-
if (err instanceof
|
|
712
|
+
if (err instanceof ShipmailError) {
|
|
713
713
|
err.status; // HTTP status
|
|
714
714
|
err.type; // error type string
|
|
715
715
|
err.requestId; // include this when contacting support
|
|
@@ -736,7 +736,7 @@ try {
|
|
|
736
736
|
The SDK retries on `5xx`, `429`, and connection errors with exponential backoff and jitter. `Retry-After` is honored when present. Default is 2 retries (3 total attempts).
|
|
737
737
|
|
|
738
738
|
```ts
|
|
739
|
-
new
|
|
739
|
+
new ShipmailClient({ apiKey, maxRetries: 0 }); // disable retries
|
|
740
740
|
```
|
|
741
741
|
|
|
742
742
|
Retries respect any `AbortSignal` you pass via `MethodOptions.signal`.
|
|
@@ -750,7 +750,7 @@ The package ships ESM and CommonJS via `exports`, with `"sideEffects": false` fo
|
|
|
750
750
|
Mock by injecting a custom `fetch` at construction time:
|
|
751
751
|
|
|
752
752
|
```ts
|
|
753
|
-
const shipmail = new
|
|
753
|
+
const shipmail = new ShipmailClient({
|
|
754
754
|
apiKey: "sm_live_test",
|
|
755
755
|
fetch: async () =>
|
|
756
756
|
new Response(JSON.stringify({ id: "msg_123", status: "queued" }), {
|
package/dist/api-key-scopes.cjs
CHANGED
|
@@ -5,6 +5,8 @@ var API_KEY_SCOPES = [
|
|
|
5
5
|
"*",
|
|
6
6
|
"audiences:read",
|
|
7
7
|
"audiences:write",
|
|
8
|
+
"automations:read",
|
|
9
|
+
"automations:write",
|
|
8
10
|
"booking_pages:read",
|
|
9
11
|
"booking_pages:write",
|
|
10
12
|
"calendar:read",
|
|
@@ -41,6 +43,8 @@ var API_KEY_SCOPE_DESCRIPTIONS = {
|
|
|
41
43
|
"*": "All non-partner API endpoints in this organization.",
|
|
42
44
|
"audiences:read": "List and retrieve newsletter audiences and their subscribers.",
|
|
43
45
|
"audiences:write": "Create audiences and add, update, or remove their subscribers.",
|
|
46
|
+
"automations:read": "List and retrieve assistant automations.",
|
|
47
|
+
"automations:write": "Create, update, and manually run assistant automations.",
|
|
44
48
|
"booking_pages:read": "List and retrieve booking pages.",
|
|
45
49
|
"booking_pages:write": "Create, update, and delete booking pages.",
|
|
46
50
|
"calendar:read": "List and retrieve calendar events and open availability.",
|
|
@@ -1 +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,oBAAA;AAAA,EACA,qBAAA;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,oBAAA,EAAsB,6DAAA;AAAA,EACtB,qBAAA,EAAuB,wEAAA;AAAA,EACvB,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 \"mailbox_rules:read\",\n \"mailbox_rules: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 \"mailbox_rules:read\": \"List deterministic server-side rules for allowed mailboxes.\",\n \"mailbox_rules:write\": \"Create, replace, and remove deterministic rules 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"]}
|
|
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,kBAAA;AAAA,EACA,mBAAA;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,oBAAA;AAAA,EACA,qBAAA;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,kBAAA,EAAoB,0CAAA;AAAA,EACpB,mBAAA,EAAqB,yDAAA;AAAA,EACrB,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,oBAAA,EAAsB,6DAAA;AAAA,EACtB,qBAAA,EAAuB,wEAAA;AAAA,EACvB,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 \"automations:read\",\n \"automations: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 \"mailbox_rules:read\",\n \"mailbox_rules: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 \"automations:read\": \"List and retrieve assistant automations.\",\n \"automations:write\": \"Create, update, and manually run assistant automations.\",\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 \"mailbox_rules:read\": \"List deterministic server-side rules for allowed mailboxes.\",\n \"mailbox_rules:write\": \"Create, replace, and remove deterministic rules 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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
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", "mailbox_rules:read", "mailbox_rules: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"];
|
|
1
|
+
declare const API_KEY_SCOPES: readonly ["*", "audiences:read", "audiences:write", "automations:read", "automations: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", "mailbox_rules:read", "mailbox_rules: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
2
|
type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
|
|
3
3
|
declare const API_KEY_SCOPE_DESCRIPTIONS: Readonly<Record<ApiKeyScope, string>>;
|
|
4
4
|
declare function isApiKeyScope(value: string): value is ApiKeyScope;
|
package/dist/api-key-scopes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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", "mailbox_rules:read", "mailbox_rules: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"];
|
|
1
|
+
declare const API_KEY_SCOPES: readonly ["*", "audiences:read", "audiences:write", "automations:read", "automations: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", "mailbox_rules:read", "mailbox_rules: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
2
|
type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
|
|
3
3
|
declare const API_KEY_SCOPE_DESCRIPTIONS: Readonly<Record<ApiKeyScope, string>>;
|
|
4
4
|
declare function isApiKeyScope(value: string): value is ApiKeyScope;
|
package/dist/api-key-scopes.js
CHANGED
|
@@ -3,6 +3,8 @@ var API_KEY_SCOPES = [
|
|
|
3
3
|
"*",
|
|
4
4
|
"audiences:read",
|
|
5
5
|
"audiences:write",
|
|
6
|
+
"automations:read",
|
|
7
|
+
"automations:write",
|
|
6
8
|
"booking_pages:read",
|
|
7
9
|
"booking_pages:write",
|
|
8
10
|
"calendar:read",
|
|
@@ -39,6 +41,8 @@ var API_KEY_SCOPE_DESCRIPTIONS = {
|
|
|
39
41
|
"*": "All non-partner API endpoints in this organization.",
|
|
40
42
|
"audiences:read": "List and retrieve newsletter audiences and their subscribers.",
|
|
41
43
|
"audiences:write": "Create audiences and add, update, or remove their subscribers.",
|
|
44
|
+
"automations:read": "List and retrieve assistant automations.",
|
|
45
|
+
"automations:write": "Create, update, and manually run assistant automations.",
|
|
42
46
|
"booking_pages:read": "List and retrieve booking pages.",
|
|
43
47
|
"booking_pages:write": "Create, update, and delete booking pages.",
|
|
44
48
|
"calendar:read": "List and retrieve calendar events and open availability.",
|
|
@@ -1 +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,oBAAA;AAAA,EACA,qBAAA;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,oBAAA,EAAsB,6DAAA;AAAA,EACtB,qBAAA,EAAuB,wEAAA;AAAA,EACvB,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 \"mailbox_rules:read\",\n \"mailbox_rules: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 \"mailbox_rules:read\": \"List deterministic server-side rules for allowed mailboxes.\",\n \"mailbox_rules:write\": \"Create, replace, and remove deterministic rules 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"]}
|
|
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,kBAAA;AAAA,EACA,mBAAA;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,oBAAA;AAAA,EACA,qBAAA;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,kBAAA,EAAoB,0CAAA;AAAA,EACpB,mBAAA,EAAqB,yDAAA;AAAA,EACrB,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,oBAAA,EAAsB,6DAAA;AAAA,EACtB,qBAAA,EAAuB,wEAAA;AAAA,EACvB,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 \"automations:read\",\n \"automations: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 \"mailbox_rules:read\",\n \"mailbox_rules: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 \"automations:read\": \"List and retrieve assistant automations.\",\n \"automations:write\": \"Create, update, and manually run assistant automations.\",\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 \"mailbox_rules:read\": \"List deterministic server-side rules for allowed mailboxes.\",\n \"mailbox_rules:write\": \"Create, replace, and remove deterministic rules 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
|
@@ -7,6 +7,8 @@ var API_KEY_SCOPES = [
|
|
|
7
7
|
"*",
|
|
8
8
|
"audiences:read",
|
|
9
9
|
"audiences:write",
|
|
10
|
+
"automations:read",
|
|
11
|
+
"automations:write",
|
|
10
12
|
"booking_pages:read",
|
|
11
13
|
"booking_pages:write",
|
|
12
14
|
"calendar:read",
|
|
@@ -43,6 +45,8 @@ var API_KEY_SCOPE_DESCRIPTIONS = {
|
|
|
43
45
|
"*": "All non-partner API endpoints in this organization.",
|
|
44
46
|
"audiences:read": "List and retrieve newsletter audiences and their subscribers.",
|
|
45
47
|
"audiences:write": "Create audiences and add, update, or remove their subscribers.",
|
|
48
|
+
"automations:read": "List and retrieve assistant automations.",
|
|
49
|
+
"automations:write": "Create, update, and manually run assistant automations.",
|
|
46
50
|
"booking_pages:read": "List and retrieve booking pages.",
|
|
47
51
|
"booking_pages:write": "Create, update, and delete booking pages.",
|
|
48
52
|
"calendar:read": "List and retrieve calendar events and open availability.",
|
|
@@ -85,29 +89,29 @@ function apiKeyScopesGrant(grantedScopes, requiredScope) {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
// src/errors.ts
|
|
88
|
-
var
|
|
92
|
+
var ShipmailError = class extends Error {
|
|
89
93
|
constructor(message, options) {
|
|
90
94
|
super(message);
|
|
91
|
-
this.name = "
|
|
95
|
+
this.name = "ShipmailError";
|
|
92
96
|
this.status = options?.status;
|
|
93
97
|
this.type = options?.type;
|
|
94
98
|
this.requestId = options?.requestId;
|
|
95
99
|
this.retryable = options?.retryable ?? false;
|
|
96
100
|
}
|
|
97
101
|
};
|
|
98
|
-
var AuthenticationError = class extends
|
|
102
|
+
var AuthenticationError = class extends ShipmailError {
|
|
99
103
|
constructor(message, requestId) {
|
|
100
104
|
super(message, { status: 401, type: "authentication_error", requestId, retryable: false });
|
|
101
105
|
this.name = "AuthenticationError";
|
|
102
106
|
}
|
|
103
107
|
};
|
|
104
|
-
var AuthorizationError = class extends
|
|
108
|
+
var AuthorizationError = class extends ShipmailError {
|
|
105
109
|
constructor(message, requestId) {
|
|
106
110
|
super(message, { status: 403, type: "authorization_error", requestId, retryable: false });
|
|
107
111
|
this.name = "AuthorizationError";
|
|
108
112
|
}
|
|
109
113
|
};
|
|
110
|
-
var ValidationError = class extends
|
|
114
|
+
var ValidationError = class extends ShipmailError {
|
|
111
115
|
constructor(message, options) {
|
|
112
116
|
super(message, {
|
|
113
117
|
status: 422,
|
|
@@ -119,19 +123,19 @@ var ValidationError = class extends ShipMailError {
|
|
|
119
123
|
this.details = options?.details;
|
|
120
124
|
}
|
|
121
125
|
};
|
|
122
|
-
var QuotaExceededError = class extends
|
|
126
|
+
var QuotaExceededError = class extends ShipmailError {
|
|
123
127
|
constructor(message, requestId) {
|
|
124
128
|
super(message, { status: 403, type: "quota_exceeded", requestId, retryable: false });
|
|
125
129
|
this.name = "QuotaExceededError";
|
|
126
130
|
}
|
|
127
131
|
};
|
|
128
|
-
var NotFoundError = class extends
|
|
132
|
+
var NotFoundError = class extends ShipmailError {
|
|
129
133
|
constructor(message, requestId) {
|
|
130
134
|
super(message, { status: 404, type: "not_found", requestId, retryable: false });
|
|
131
135
|
this.name = "NotFoundError";
|
|
132
136
|
}
|
|
133
137
|
};
|
|
134
|
-
var RateLimitError = class extends
|
|
138
|
+
var RateLimitError = class extends ShipmailError {
|
|
135
139
|
constructor(message, options) {
|
|
136
140
|
super(message, {
|
|
137
141
|
status: 429,
|
|
@@ -143,25 +147,25 @@ var RateLimitError = class extends ShipMailError {
|
|
|
143
147
|
this.retryAfter = options?.retryAfter;
|
|
144
148
|
}
|
|
145
149
|
};
|
|
146
|
-
var ConflictError = class extends
|
|
150
|
+
var ConflictError = class extends ShipmailError {
|
|
147
151
|
constructor(message, requestId) {
|
|
148
152
|
super(message, { status: 409, type: "conflict", requestId, retryable: false });
|
|
149
153
|
this.name = "ConflictError";
|
|
150
154
|
}
|
|
151
155
|
};
|
|
152
|
-
var InternalServerError = class extends
|
|
156
|
+
var InternalServerError = class extends ShipmailError {
|
|
153
157
|
constructor(message, requestId) {
|
|
154
158
|
super(message, { status: 500, type: "internal_error", requestId, retryable: true });
|
|
155
159
|
this.name = "InternalServerError";
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
|
-
var ConnectionError = class extends
|
|
162
|
+
var ConnectionError = class extends ShipmailError {
|
|
159
163
|
constructor(message) {
|
|
160
164
|
super(message, { retryable: true });
|
|
161
165
|
this.name = "ConnectionError";
|
|
162
166
|
}
|
|
163
167
|
};
|
|
164
|
-
var WebhookVerificationError = class extends
|
|
168
|
+
var WebhookVerificationError = class extends ShipmailError {
|
|
165
169
|
constructor(message) {
|
|
166
170
|
super(message, { retryable: false });
|
|
167
171
|
this.name = "WebhookVerificationError";
|
|
@@ -188,7 +192,7 @@ function mapErrorFromResponse(status, body, requestId) {
|
|
|
188
192
|
case "internal_error":
|
|
189
193
|
return new InternalServerError(error.message, rid);
|
|
190
194
|
default:
|
|
191
|
-
return new
|
|
195
|
+
return new ShipmailError(error.message, {
|
|
192
196
|
status,
|
|
193
197
|
type: error.type,
|
|
194
198
|
requestId: rid,
|
|
@@ -397,6 +401,47 @@ var Audiences = class extends ApiResource {
|
|
|
397
401
|
}
|
|
398
402
|
};
|
|
399
403
|
|
|
404
|
+
// src/resources/automations.ts
|
|
405
|
+
var Automations = class extends ApiResource {
|
|
406
|
+
list(options) {
|
|
407
|
+
return this.client.request({
|
|
408
|
+
method: "GET",
|
|
409
|
+
path: "/automations",
|
|
410
|
+
methodOptions: options
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
create(params, options) {
|
|
414
|
+
return this.client.request({
|
|
415
|
+
method: "POST",
|
|
416
|
+
path: "/automations",
|
|
417
|
+
body: params,
|
|
418
|
+
methodOptions: options
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
get(id, options) {
|
|
422
|
+
return this.client.request({
|
|
423
|
+
method: "GET",
|
|
424
|
+
path: `/automations/${encodeURIComponent(id)}`,
|
|
425
|
+
methodOptions: options
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
update(id, params, options) {
|
|
429
|
+
return this.client.request({
|
|
430
|
+
method: "PATCH",
|
|
431
|
+
path: `/automations/${encodeURIComponent(id)}`,
|
|
432
|
+
body: params,
|
|
433
|
+
methodOptions: options
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
run(id, options) {
|
|
437
|
+
return this.client.request({
|
|
438
|
+
method: "POST",
|
|
439
|
+
path: `/automations/${encodeURIComponent(id)}/run`,
|
|
440
|
+
methodOptions: options
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
400
445
|
// src/resources/booking-pages.ts
|
|
401
446
|
var BookingPages = class extends ApiResource {
|
|
402
447
|
create(params, options) {
|
|
@@ -1568,7 +1613,7 @@ var Webhooks = class extends ApiResource {
|
|
|
1568
1613
|
};
|
|
1569
1614
|
|
|
1570
1615
|
// src/version.ts
|
|
1571
|
-
var VERSION = "0.4.
|
|
1616
|
+
var VERSION = "0.4.14";
|
|
1572
1617
|
|
|
1573
1618
|
// src/client.ts
|
|
1574
1619
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -1598,9 +1643,9 @@ function rawBodyToBlobPart(rawBody) {
|
|
|
1598
1643
|
new Uint8Array(buffer).set(rawBody);
|
|
1599
1644
|
return buffer;
|
|
1600
1645
|
}
|
|
1601
|
-
var
|
|
1646
|
+
var ShipmailClient = class {
|
|
1602
1647
|
/**
|
|
1603
|
-
* Create a new
|
|
1648
|
+
* Create a new Shipmail client.
|
|
1604
1649
|
* @param config - API key string or full configuration object.
|
|
1605
1650
|
*/
|
|
1606
1651
|
constructor(config) {
|
|
@@ -1622,6 +1667,7 @@ var ShipMailClient = class {
|
|
|
1622
1667
|
this.organizationId = config.organizationId;
|
|
1623
1668
|
}
|
|
1624
1669
|
this.audiences = new Audiences(this);
|
|
1670
|
+
this.automations = new Automations(this);
|
|
1625
1671
|
this.bookingPages = new BookingPages(this);
|
|
1626
1672
|
this.capabilities = new Capabilities(this);
|
|
1627
1673
|
this.calendar = new Calendar(this);
|
|
@@ -1674,7 +1720,7 @@ var ShipMailClient = class {
|
|
|
1674
1720
|
}
|
|
1675
1721
|
const targetOrganizationId = methodOpts?.organizationId ?? this.organizationId;
|
|
1676
1722
|
if (targetOrganizationId) {
|
|
1677
|
-
headers["X-
|
|
1723
|
+
headers["X-Shipmail-Organization-Id"] = targetOrganizationId;
|
|
1678
1724
|
}
|
|
1679
1725
|
let body = null;
|
|
1680
1726
|
if (options.rawBody !== void 0) {
|
|
@@ -1708,7 +1754,7 @@ var ShipMailClient = class {
|
|
|
1708
1754
|
if (isApiErrorBody(errorBody)) {
|
|
1709
1755
|
lastError = mapErrorFromResponse(response.status, errorBody);
|
|
1710
1756
|
} else {
|
|
1711
|
-
lastError = new
|
|
1757
|
+
lastError = new ShipmailError(`Request failed with status ${response.status}`, {
|
|
1712
1758
|
status: response.status,
|
|
1713
1759
|
retryable: isRetryableStatus(response.status)
|
|
1714
1760
|
});
|
|
@@ -1717,7 +1763,7 @@ var ShipMailClient = class {
|
|
|
1717
1763
|
throw lastError;
|
|
1718
1764
|
}
|
|
1719
1765
|
}
|
|
1720
|
-
throw lastError ?? new
|
|
1766
|
+
throw lastError ?? new ShipmailError("Request failed after retries");
|
|
1721
1767
|
}
|
|
1722
1768
|
buildUrl(path2, query) {
|
|
1723
1769
|
const url = new URL(`${this.baseUrl}${path2}`);
|
|
@@ -1792,14 +1838,14 @@ async function verifyWebhook(body, headers, secret, options) {
|
|
|
1792
1838
|
const signature = getHeader(headers, "x-shipmail-signature");
|
|
1793
1839
|
const timestampStr = getHeader(headers, "x-shipmail-timestamp");
|
|
1794
1840
|
if (!signature) {
|
|
1795
|
-
throw new WebhookVerificationError("Missing X-
|
|
1841
|
+
throw new WebhookVerificationError("Missing X-Shipmail-Signature header");
|
|
1796
1842
|
}
|
|
1797
1843
|
if (!timestampStr) {
|
|
1798
|
-
throw new WebhookVerificationError("Missing X-
|
|
1844
|
+
throw new WebhookVerificationError("Missing X-Shipmail-Timestamp header");
|
|
1799
1845
|
}
|
|
1800
1846
|
const timestamp = parseInt(timestampStr, 10);
|
|
1801
1847
|
if (isNaN(timestamp)) {
|
|
1802
|
-
throw new WebhookVerificationError("Invalid X-
|
|
1848
|
+
throw new WebhookVerificationError("Invalid X-Shipmail-Timestamp header");
|
|
1803
1849
|
}
|
|
1804
1850
|
const tolerance = options?.toleranceInSeconds ?? DEFAULT_TOLERANCE_SECONDS;
|
|
1805
1851
|
const now = Math.floor(Date.now() / 1e3);
|
|
@@ -1837,15 +1883,15 @@ exports.NotFoundError = NotFoundError;
|
|
|
1837
1883
|
exports.Page = Page;
|
|
1838
1884
|
exports.QuotaExceededError = QuotaExceededError;
|
|
1839
1885
|
exports.RateLimitError = RateLimitError;
|
|
1840
|
-
exports.
|
|
1841
|
-
exports.
|
|
1886
|
+
exports.ShipmailClient = ShipmailClient;
|
|
1887
|
+
exports.ShipmailError = ShipmailError;
|
|
1842
1888
|
exports.ValidationError = ValidationError;
|
|
1843
1889
|
exports.WEBHOOK_DELIVERY_EVENT_TYPES = WEBHOOK_DELIVERY_EVENT_TYPES;
|
|
1844
1890
|
exports.WEBHOOK_DELIVERY_STATUSES = WEBHOOK_DELIVERY_STATUSES;
|
|
1845
1891
|
exports.WEBHOOK_EVENT_TYPES = WEBHOOK_EVENT_TYPES;
|
|
1846
1892
|
exports.WebhookVerificationError = WebhookVerificationError;
|
|
1847
1893
|
exports.apiKeyScopesGrant = apiKeyScopesGrant;
|
|
1848
|
-
exports.default =
|
|
1894
|
+
exports.default = ShipmailClient;
|
|
1849
1895
|
exports.isApiKeyScope = isApiKeyScope;
|
|
1850
1896
|
exports.verifyWebhook = verifyWebhook;
|
|
1851
1897
|
//# sourceMappingURL=index.cjs.map
|