zerodrop-client 0.1.0 → 0.1.2
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 +121 -0
- package/package.json +16 -4
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# zerodrop-client
|
|
2
|
+
|
|
3
|
+
Instant temporary email inboxes for testing auth flows, CI pipelines, and QA automation.
|
|
4
|
+
|
|
5
|
+
No signup. No configuration. Works in 4 lines.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install zerodrop-client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Zero-Auth Mode (Local Development)
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { ZeroDrop } from 'zerodrop-client';
|
|
17
|
+
|
|
18
|
+
const mail = new ZeroDrop();
|
|
19
|
+
const inbox = mail.generateInbox();
|
|
20
|
+
// → "swift-x7k29@zerodrop-sandbox.online"
|
|
21
|
+
|
|
22
|
+
const email = await mail.waitForLatest(inbox, { timeout: 10000 });
|
|
23
|
+
console.log(email.subject); // "Reset your password"
|
|
24
|
+
console.log(email.body); // "Click here to reset..."
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## CI Pipeline Mode (Playwright / Cypress)
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { ZeroDrop } from 'zerodrop-client';
|
|
31
|
+
|
|
32
|
+
const mail = new ZeroDrop(process.env.ZERODROP_API_KEY);
|
|
33
|
+
|
|
34
|
+
test('password reset flow', async ({ page }) => {
|
|
35
|
+
const inbox = mail.generateInbox();
|
|
36
|
+
|
|
37
|
+
await page.goto('/forgot-password');
|
|
38
|
+
await page.fill('[name="email"]', inbox);
|
|
39
|
+
await page.click('[type="submit"]');
|
|
40
|
+
|
|
41
|
+
const email = await mail.waitForLatest(inbox, { timeout: 15000 });
|
|
42
|
+
expect(email.subject).toContain('Reset your password');
|
|
43
|
+
|
|
44
|
+
const resetLink = email.body.match(/https?:\/\/[^\s]+/)[0];
|
|
45
|
+
await page.goto(resetLink);
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Webhook Mode (Staging Servers)
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const mail = new ZeroDrop(process.env.ZERODROP_API_KEY);
|
|
53
|
+
|
|
54
|
+
await mail.onReceived('qa-test@yourcompany.com', 'https://your-server.com/webhook');
|
|
55
|
+
// ZeroDrop POSTs the email JSON to your URL when it arrives
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
### `new ZeroDrop(apiKey?, options?)`
|
|
61
|
+
- `apiKey` — optional. Omit for free sandbox mode.
|
|
62
|
+
- `options.baseUrl` — override the API base URL.
|
|
63
|
+
|
|
64
|
+
### `mail.generateInbox(): string`
|
|
65
|
+
Returns a ready-to-use email address instantly. No network request.
|
|
66
|
+
|
|
67
|
+
### `mail.fetchLatest(inbox): Promise<ZeroDropEmail | null>`
|
|
68
|
+
Returns the latest email or null if inbox is empty.
|
|
69
|
+
|
|
70
|
+
### `mail.waitForLatest(inbox, options?): Promise<ZeroDropEmail>`
|
|
71
|
+
Polls until an email arrives. Throws `ZeroDropTimeoutError` on timeout.
|
|
72
|
+
- `options.timeout` — ms to wait (default: 10000)
|
|
73
|
+
- `options.pollInterval` — ms between polls (default: 2000)
|
|
74
|
+
|
|
75
|
+
### `mail.onReceived(inbox, webhookUrl): Promise<{ registered: boolean }>`
|
|
76
|
+
Registers a webhook. Requires API key (Workspace tier).
|
|
77
|
+
|
|
78
|
+
## Types
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
interface ZeroDropEmail {
|
|
82
|
+
id: string;
|
|
83
|
+
from: string;
|
|
84
|
+
to: string;
|
|
85
|
+
subject: string;
|
|
86
|
+
body: string;
|
|
87
|
+
rawBody: string;
|
|
88
|
+
receivedAt: Date;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Error Handling
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
import { ZeroDrop, ZeroDropTimeoutError } from 'zerodrop-client';
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
const email = await mail.waitForLatest(inbox, { timeout: 10000 });
|
|
99
|
+
} catch (err) {
|
|
100
|
+
if (err instanceof ZeroDropTimeoutError) {
|
|
101
|
+
console.error('No email received — check your app is sending correctly');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Free vs Workspace
|
|
107
|
+
|
|
108
|
+
| | Free | Workspace |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| Inbox generation | ✓ | ✓ |
|
|
111
|
+
| Email retention | 30 min | 7 days |
|
|
112
|
+
| Custom domains | ✗ | ✓ |
|
|
113
|
+
| API key | ✗ | ✓ |
|
|
114
|
+
| Webhooks | ✗ | ✓ |
|
|
115
|
+
| AI spam filter | On | Off |
|
|
116
|
+
|
|
117
|
+
Get a Workspace at [zerodrop.dev](https://zerodrop.dev)
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zerodrop-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Instant temporary email inboxes for CI pipelines and QA testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
8
11
|
"scripts": {
|
|
9
12
|
"build": "tsc",
|
|
10
13
|
"dev": "tsc --watch"
|
|
11
14
|
},
|
|
12
|
-
"keywords": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"email",
|
|
17
|
+
"testing",
|
|
18
|
+
"ci",
|
|
19
|
+
"playwright",
|
|
20
|
+
"cypress",
|
|
21
|
+
"qa",
|
|
22
|
+
"temporary-email",
|
|
23
|
+
"sandbox"
|
|
24
|
+
],
|
|
13
25
|
"author": "ZeroDrop",
|
|
14
26
|
"license": "MIT",
|
|
15
27
|
"devDependencies": {
|
|
16
28
|
"typescript": "^6.0.3"
|
|
17
29
|
}
|
|
18
|
-
}
|
|
30
|
+
}
|