proxymail-qa 0.3.0 → 0.4.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 CHANGED
@@ -100,6 +100,11 @@ const { delivered, invalid } = await qa.variants(address);
100
100
 
101
101
  // After the app changes the test account's password, keep the saved one in step.
102
102
  await qa.setPassword(address, { password: 'the-new-test-password' });
103
+
104
+ // Check the email that arrived: SPF, DKIM, DMARC, local or http links, where
105
+ // its link goes, a stated expiry and more. Verdicts only, never its content.
106
+ const result = await qa.checkEmail(address, { type: 'link', expectHost: 'staging.example.com' });
107
+ expect(result.failed).toEqual([]);
103
108
  ```
104
109
 
105
110
  When a wait comes back empty, the error says why as far as Proxy Mail QA can
package/dist/index.d.ts CHANGED
@@ -132,6 +132,31 @@ export interface CountOptions {
132
132
  subtype?: CountSubtype | CountSubtype[];
133
133
  }
134
134
  export type CountSubtype = 'otp' | 'coupon' | 'verify' | 'magic_signin' | 'invite' | 'reset' | 'other' | 'any';
135
+ export type CheckId = 'spf' | 'dkim' | 'dmarc' | 'local_links' | 'plain_http' | 'expected_host' | 'expiry' | 'plain_text' | 'size' | 'images_only';
136
+ export interface EmailCheck {
137
+ check: CheckId;
138
+ status: 'pass' | 'fail' | 'warn' | 'skip';
139
+ detail: string;
140
+ }
141
+ export interface EmailChecks {
142
+ address: string;
143
+ email: {
144
+ id: string;
145
+ received_at: string;
146
+ service: string | null;
147
+ service_domain: string | null;
148
+ type: 'code' | 'link' | null;
149
+ subtype: string | null;
150
+ };
151
+ passed: boolean;
152
+ failed: CheckId[];
153
+ warnings: CheckId[];
154
+ checks: EmailCheck[];
155
+ }
156
+ export interface CheckOptions extends CountOptions {
157
+ emailId?: string;
158
+ expectHost?: string;
159
+ }
135
160
  export interface NoEmail {
136
161
  address: string;
137
162
  since: string;
@@ -171,6 +196,7 @@ export declare class ProxyMailQA {
171
196
  limit?: number;
172
197
  }): Promise<Record<string, unknown>[]>;
173
198
  countEmails(address: string, options?: CountOptions): Promise<EmailCount>;
199
+ checkEmail(address: string, options?: CheckOptions): Promise<EmailChecks>;
174
200
  expectNoEmail(address: string, options?: CountOptions & {
175
201
  timeout?: number;
176
202
  }): Promise<NoEmail>;
package/dist/index.js CHANGED
@@ -141,6 +141,18 @@ export class ProxyMailQA {
141
141
  countEmails(address, options = {}) {
142
142
  return this.request('GET', `/addresses/${encodeURIComponent(address)}/count${countQuery(options)}`);
143
143
  }
144
+ // Checks one email the address received: SPF, DKIM and DMARC, links to
145
+ // localhost or plain http, where its link goes (expectHost), a stated
146
+ // expiry, a plain-text part, size and image-only emails. Doesn't wait: wait
147
+ // for the email first. Throws ProxyMailQAError (404) when none matches.
148
+ checkEmail(address, options = {}) {
149
+ const extra = {};
150
+ if (options.emailId)
151
+ extra.email_id = options.emailId;
152
+ if (options.expectHost)
153
+ extra.expect_host = options.expectHost;
154
+ return this.request('GET', `/addresses/${encodeURIComponent(address)}/checks${countQuery(options, extra)}`);
155
+ }
144
156
  // Resolves when no matching email arrives within timeout seconds (default
145
157
  // 30; longer repeats the request), for checks such as "an unsubscribed user
146
158
  // gets nothing". Throws ProxyMailQAError (status 409, code email_arrived)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proxymail-qa",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Disposable test inboxes for Playwright, Cypress and scripts: create an address, then wait for its verification code or link.",
5
5
  "license": "MIT",
6
6
  "author": "Proxy Mail QA <hello@proxymail.qa> (https://proxymail.qa)",