shipmail 0.6.2 → 0.6.4
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 +11 -0
- package/dist/index.cjs +60 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -6
- package/dist/index.d.ts +77 -6
- package/dist/index.js +60 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,6 +141,7 @@ await shipmail.mailboxes.resume("mbx_...");
|
|
|
141
141
|
await shipmail.mailboxes.resetPassword("mbx_...", { password: "NewPassword1" });
|
|
142
142
|
const forwarding = await shipmail.mailboxes.createForwarding("mbx_...", {
|
|
143
143
|
destination: "owner@example.net",
|
|
144
|
+
recipient: "support@example.com",
|
|
144
145
|
});
|
|
145
146
|
const forwardingList = await shipmail.mailboxes.listForwarding("mbx_...");
|
|
146
147
|
await shipmail.mailboxes.deleteForwarding("mbx_...", forwarding.id);
|
|
@@ -358,12 +359,21 @@ const webhook = await shipmail.webhooks.create({
|
|
|
358
359
|
url: "https://example.com/webhook",
|
|
359
360
|
events: ["message.received", "message.sent"],
|
|
360
361
|
description: "Incoming email handler",
|
|
362
|
+
// Optional. Sent as the Authorization header of every delivery. Never returned.
|
|
363
|
+
authorization: "Bearer your-endpoint-key",
|
|
364
|
+
// Optional. A whsec_ secret from the receiving service, such as a Grok automation.
|
|
365
|
+
// Deliveries then carry webhook-id, webhook-timestamp and webhook-signature. Never returned.
|
|
366
|
+
standard_webhooks_secret: "whsec_...",
|
|
361
367
|
});
|
|
362
368
|
// webhook.secret is returned only on creation. Store it now.
|
|
369
|
+
// webhook.has_authorization is true when an authorization value is set.
|
|
370
|
+
// webhook.has_standard_webhooks_secret is true when a signing secret is set.
|
|
363
371
|
|
|
364
372
|
await shipmail.webhooks.list();
|
|
365
373
|
await shipmail.webhooks.get("whk_...");
|
|
366
374
|
await shipmail.webhooks.update("whk_...", { active: false });
|
|
375
|
+
await shipmail.webhooks.update("whk_...", { authorization: null }); // remove the header
|
|
376
|
+
await shipmail.webhooks.update("whk_...", { standard_webhooks_secret: null }); // stop signing
|
|
367
377
|
await shipmail.webhooks.delete("whk_...");
|
|
368
378
|
|
|
369
379
|
await shipmail.webhooks.rotateSecret("whk_...");
|
|
@@ -380,6 +390,7 @@ Supported event types:
|
|
|
380
390
|
```
|
|
381
391
|
message.received
|
|
382
392
|
message.sent
|
|
393
|
+
message.delayed
|
|
383
394
|
message.delivered
|
|
384
395
|
message.bounced
|
|
385
396
|
message.complained
|
package/dist/index.cjs
CHANGED
|
@@ -82,6 +82,12 @@ function apiKeyScopesGrant(grantedScopes, requiredScope) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// src/errors.ts
|
|
85
|
+
var ERROR_RECOVERY_REASONS = [
|
|
86
|
+
"owner_confirmation_required",
|
|
87
|
+
"subscription_required",
|
|
88
|
+
"trial_capacity",
|
|
89
|
+
"purchased_capacity"
|
|
90
|
+
];
|
|
85
91
|
var ShipmailError = class extends Error {
|
|
86
92
|
constructor(message, options) {
|
|
87
93
|
super(message);
|
|
@@ -90,6 +96,8 @@ var ShipmailError = class extends Error {
|
|
|
90
96
|
this.type = options?.type;
|
|
91
97
|
this.requestId = options?.requestId;
|
|
92
98
|
this.retryable = options?.retryable ?? false;
|
|
99
|
+
this.reason = options?.reason;
|
|
100
|
+
this.actionUrl = options?.actionUrl;
|
|
93
101
|
}
|
|
94
102
|
};
|
|
95
103
|
var AuthenticationError = class extends ShipmailError {
|
|
@@ -99,8 +107,14 @@ var AuthenticationError = class extends ShipmailError {
|
|
|
99
107
|
}
|
|
100
108
|
};
|
|
101
109
|
var AuthorizationError = class extends ShipmailError {
|
|
102
|
-
constructor(message, requestId) {
|
|
103
|
-
super(message, {
|
|
110
|
+
constructor(message, requestId, recovery) {
|
|
111
|
+
super(message, {
|
|
112
|
+
status: 403,
|
|
113
|
+
type: "authorization_error",
|
|
114
|
+
requestId,
|
|
115
|
+
retryable: false,
|
|
116
|
+
...recovery
|
|
117
|
+
});
|
|
104
118
|
this.name = "AuthorizationError";
|
|
105
119
|
}
|
|
106
120
|
};
|
|
@@ -110,15 +124,23 @@ var ValidationError = class extends ShipmailError {
|
|
|
110
124
|
status: 422,
|
|
111
125
|
type: "validation_error",
|
|
112
126
|
requestId: options?.requestId,
|
|
113
|
-
retryable: false
|
|
127
|
+
retryable: false,
|
|
128
|
+
reason: options?.reason,
|
|
129
|
+
actionUrl: options?.actionUrl
|
|
114
130
|
});
|
|
115
131
|
this.name = "ValidationError";
|
|
116
132
|
this.details = options?.details;
|
|
117
133
|
}
|
|
118
134
|
};
|
|
119
135
|
var QuotaExceededError = class extends ShipmailError {
|
|
120
|
-
constructor(message, requestId) {
|
|
121
|
-
super(message, {
|
|
136
|
+
constructor(message, requestId, recovery) {
|
|
137
|
+
super(message, {
|
|
138
|
+
status: 403,
|
|
139
|
+
type: "quota_exceeded",
|
|
140
|
+
requestId,
|
|
141
|
+
retryable: false,
|
|
142
|
+
...recovery
|
|
143
|
+
});
|
|
122
144
|
this.name = "QuotaExceededError";
|
|
123
145
|
}
|
|
124
146
|
};
|
|
@@ -179,15 +201,23 @@ var WebhookVerificationError = class extends ShipmailError {
|
|
|
179
201
|
function mapErrorFromResponse(status, body, requestId) {
|
|
180
202
|
const error = body.error;
|
|
181
203
|
const rid = error.request_id;
|
|
204
|
+
const recovery = {
|
|
205
|
+
reason: typeof error.reason === "string" ? error.reason : void 0,
|
|
206
|
+
actionUrl: typeof error.action_url === "string" ? error.action_url : void 0
|
|
207
|
+
};
|
|
182
208
|
switch (error.type) {
|
|
183
209
|
case "authentication_error":
|
|
184
210
|
return new AuthenticationError(error.message, rid);
|
|
185
211
|
case "authorization_error":
|
|
186
|
-
return new AuthorizationError(error.message, rid);
|
|
212
|
+
return new AuthorizationError(error.message, rid, recovery);
|
|
187
213
|
case "quota_exceeded":
|
|
188
|
-
return new QuotaExceededError(error.message, rid);
|
|
214
|
+
return new QuotaExceededError(error.message, rid, recovery);
|
|
189
215
|
case "validation_error":
|
|
190
|
-
return new ValidationError(error.message, {
|
|
216
|
+
return new ValidationError(error.message, {
|
|
217
|
+
requestId: rid,
|
|
218
|
+
details: error.details,
|
|
219
|
+
...recovery
|
|
220
|
+
});
|
|
191
221
|
case "not_found":
|
|
192
222
|
return new NotFoundError(error.message, rid);
|
|
193
223
|
case "rate_limit_error":
|
|
@@ -203,7 +233,8 @@ function mapErrorFromResponse(status, body, requestId) {
|
|
|
203
233
|
status,
|
|
204
234
|
type: error.type,
|
|
205
235
|
requestId: rid,
|
|
206
|
-
retryable: status >= 500
|
|
236
|
+
retryable: status >= 500,
|
|
237
|
+
...recovery
|
|
207
238
|
});
|
|
208
239
|
}
|
|
209
240
|
}
|
|
@@ -1370,6 +1401,22 @@ var Newsletters = class extends ApiResource {
|
|
|
1370
1401
|
}
|
|
1371
1402
|
};
|
|
1372
1403
|
|
|
1404
|
+
// src/resources/organization.ts
|
|
1405
|
+
var Organization = class extends ApiResource {
|
|
1406
|
+
/**
|
|
1407
|
+
* Whether the credential's organization can create mailboxes now, with its plan, trial and
|
|
1408
|
+
* mailbox capacity. Poll it after the owner pays: access appears once Shipmail has recorded the
|
|
1409
|
+
* payment.
|
|
1410
|
+
*/
|
|
1411
|
+
access(options) {
|
|
1412
|
+
return this.client.request({
|
|
1413
|
+
method: "GET",
|
|
1414
|
+
path: "/organization/access",
|
|
1415
|
+
methodOptions: options
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1373
1420
|
// src/resources/reply-scans.ts
|
|
1374
1421
|
var ReplyScans = class extends ApiResource {
|
|
1375
1422
|
create(params, options) {
|
|
@@ -1618,7 +1665,7 @@ var Webhooks = class extends ApiResource {
|
|
|
1618
1665
|
};
|
|
1619
1666
|
|
|
1620
1667
|
// src/version.ts
|
|
1621
|
-
var VERSION = "0.6.
|
|
1668
|
+
var VERSION = "0.6.4";
|
|
1622
1669
|
|
|
1623
1670
|
// src/client.ts
|
|
1624
1671
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -1691,6 +1738,7 @@ var ShipmailClient = class {
|
|
|
1691
1738
|
this.members = new Members(this);
|
|
1692
1739
|
this.messages = new Messages(this);
|
|
1693
1740
|
this.newsletters = new Newsletters(this);
|
|
1741
|
+
this.organization = new Organization(this);
|
|
1694
1742
|
this.replyScans = new ReplyScans(this);
|
|
1695
1743
|
this.scheduledMessages = new ScheduledMessages(this);
|
|
1696
1744
|
this.suppressions = new Suppressions(this);
|
|
@@ -1810,6 +1858,7 @@ var CONFERENCING_PROVIDER_IDS = ["zoom", "google_meet"];
|
|
|
1810
1858
|
var WEBHOOK_EVENT_TYPES = [
|
|
1811
1859
|
"message.received",
|
|
1812
1860
|
"message.sent",
|
|
1861
|
+
"message.delayed",
|
|
1813
1862
|
"message.delivered",
|
|
1814
1863
|
"message.bounced",
|
|
1815
1864
|
"message.complained",
|
|
@@ -1909,6 +1958,7 @@ exports.CONFERENCING_PROVIDER_IDS = CONFERENCING_PROVIDER_IDS;
|
|
|
1909
1958
|
exports.ConflictError = ConflictError;
|
|
1910
1959
|
exports.ConnectionError = ConnectionError;
|
|
1911
1960
|
exports.DOMAIN_STATUSES = DOMAIN_STATUSES;
|
|
1961
|
+
exports.ERROR_RECOVERY_REASONS = ERROR_RECOVERY_REASONS;
|
|
1912
1962
|
exports.InternalServerError = InternalServerError;
|
|
1913
1963
|
exports.MESSAGE_SOURCES = MESSAGE_SOURCES;
|
|
1914
1964
|
exports.MESSAGE_STATUSES = MESSAGE_STATUSES;
|