saci.cc 1.2.0 → 1.3.0
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 +20 -5
- package/dist/index.d.ts +16 -1
- package/dist/index.js +7 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ it("signs up with a verification code", () => {
|
|
|
113
113
|
|
|
114
114
|
### `createInbox(options?)`
|
|
115
115
|
|
|
116
|
-
Creates an inbox and returns an `Inbox`. Without `name` the address is random (16 hex characters). With `name: "signup-test"` you get `signup-test@saci.cc`. Either way the inbox belongs to your API key's account for 7 days: only that account can read it, and nobody else can create the same name (a `SaciError` with status 409).
|
|
116
|
+
Creates an inbox and returns an `Inbox`. Without `name` the address is random (16 hex characters). With `name: "signup-test"` you get `signup-test@saci.cc`. Either way the inbox belongs to your API key's account for 7 days (30 on Pro, 90 on Team): only that account can read it, and nobody else can create the same name (a `SaciError` with status 409).
|
|
117
117
|
|
|
118
118
|
### `inbox.waitForCode(options?)`, `inbox.waitForLink(options?)`, `inbox.waitForEmail(options?)`
|
|
119
119
|
|
|
@@ -155,14 +155,29 @@ An email looks like this:
|
|
|
155
155
|
- `new Saci({ apiKey })`: pass the key instead of using `SACI_API_KEY`.
|
|
156
156
|
- `new Saci({ baseUrl, fetch })`: point at another deployment or pass your own `fetch`.
|
|
157
157
|
|
|
158
|
-
Failed requests throw `SaciError`,
|
|
158
|
+
Failed requests throw `SaciError`, with the HTTP `status` and the API's JSON answer in `body`. A missing or revoked key gives a 401. On the Free plan, a 402 means the account created its 1,000 inboxes for the month: `body.resetsAt` says when the count starts over, and it isn't retried.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { SaciError } from "saci.cc";
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
await saci.createInbox();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof SaciError && error.status === 402) {
|
|
167
|
+
console.log(`Out of inboxes until ${error.body?.resetsAt}`);
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
159
172
|
|
|
160
173
|
## Limits
|
|
161
174
|
|
|
162
|
-
-
|
|
175
|
+
- Requests per minute per account, across its keys: 120 on Free, 600 on Pro, 2,000 on Team. The client waits and retries when it gets a 429.
|
|
176
|
+
- Inboxes created with your keys: 1,000 a month on Free, no cap on Pro and Team. Past that, `createInbox` throws a `SaciError` with status 402.
|
|
163
177
|
- Emails are deleted about a day after they arrive.
|
|
164
|
-
- Inboxes created with your key are private to your account for 7 days. Still, it's a service for tests and sign-ups: don't use it for anything sensitive.
|
|
165
|
-
- Want to be told instead of waiting?
|
|
178
|
+
- Inboxes created with your key are private to your account for 7 days (30 on Pro, 90 on Team). Still, it's a service for tests and sign-ups: don't use it for anything sensitive.
|
|
179
|
+
- Want to be told instead of waiting? On Pro and Team, set a webhook on [saci.cc/en/account](https://saci.cc/en/account/) and each email is POSTed to your URL ([format](https://saci.cc/en/docs/#webhooks)).
|
|
180
|
+
- Plans and prices: [saci.cc/en/pricing](https://saci.cc/en/pricing/).
|
|
166
181
|
- Addresses only receive email.
|
|
167
182
|
|
|
168
183
|
The full HTTP API is documented at [saci.cc/en/docs](https://saci.cc/en/docs/). There's also an [MCP server](https://saci.cc/en/mcp/) for AI agents.
|
package/dist/index.d.ts
CHANGED
|
@@ -53,9 +53,24 @@ export interface WaitForLinkOptions extends WaitOptions {
|
|
|
53
53
|
*/
|
|
54
54
|
match?: string | RegExp;
|
|
55
55
|
}
|
|
56
|
+
/** What the API answered with an error: always `error`, plus details for some statuses */
|
|
57
|
+
export interface SaciErrorBody {
|
|
58
|
+
error: string;
|
|
59
|
+
/** 402: the free plan's monthly inboxes */
|
|
60
|
+
limit?: number;
|
|
61
|
+
/** 402: when the monthly count starts over (ISO date) */
|
|
62
|
+
resetsAt?: string;
|
|
63
|
+
/** 402: a paid plan lifts the limit (https://saci.cc/pricing/) */
|
|
64
|
+
upgrade?: boolean;
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
56
67
|
export declare class SaciError extends Error {
|
|
57
68
|
readonly status: number;
|
|
58
|
-
|
|
69
|
+
/** The API's JSON answer, when there was one */
|
|
70
|
+
readonly body: SaciErrorBody | null;
|
|
71
|
+
constructor(message: string, status: number,
|
|
72
|
+
/** The API's JSON answer, when there was one */
|
|
73
|
+
body?: SaciErrorBody | null);
|
|
59
74
|
}
|
|
60
75
|
export declare class SaciTimeoutError extends Error {
|
|
61
76
|
constructor(message: string);
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,13 @@ const MAX_RATE_LIMIT_RETRIES = 3;
|
|
|
9
9
|
const envApiKey = () => globalThis.process?.env?.SACI_API_KEY;
|
|
10
10
|
export class SaciError extends Error {
|
|
11
11
|
status;
|
|
12
|
-
|
|
12
|
+
body;
|
|
13
|
+
constructor(message, status,
|
|
14
|
+
/** The API's JSON answer, when there was one */
|
|
15
|
+
body = null) {
|
|
13
16
|
super(message);
|
|
14
17
|
this.status = status;
|
|
18
|
+
this.body = body;
|
|
15
19
|
this.name = "SaciError";
|
|
16
20
|
}
|
|
17
21
|
}
|
|
@@ -59,8 +63,9 @@ export class Saci {
|
|
|
59
63
|
continue;
|
|
60
64
|
}
|
|
61
65
|
if (!res.ok) {
|
|
66
|
+
// 402 (the free plan's monthly inboxes) isn't retried: it lasts until the month turns
|
|
62
67
|
const body = (await res.json().catch(() => null));
|
|
63
|
-
throw new SaciError(`${method} ${path} failed with ${res.status}: ${body?.error ?? res.statusText}`, res.status);
|
|
68
|
+
throw new SaciError(`${method} ${path} failed with ${res.status}: ${body?.error ?? res.statusText}`, res.status, body);
|
|
64
69
|
}
|
|
65
70
|
return (res.status === 204 ? undefined : await res.json());
|
|
66
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "saci.cc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Temporary email inboxes for end-to-end tests: wait for verification codes and links from saci.cc",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"temporary email",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"homepage": "https://saci.cc/en/docs/",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/
|
|
18
|
+
"url": "git+https://github.com/saci-cc/saci.cc-client.git"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"type": "module",
|