temp-disposable-email 1.11.5 → 1.11.7
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 +23 -5
- package/cypress.config.ts +1 -0
- package/dist/cjs/utils/getVerificationCode.d.ts +1 -1
- package/dist/cjs/utils/getVerificationCode.d.ts.map +1 -1
- package/dist/cjs/utils/getVerificationCode.js +1 -2
- package/dist/cjs/utils/getVerificationCode.js.map +1 -1
- package/dist/esm/utils/getVerificationCode.d.ts +1 -1
- package/dist/esm/utils/getVerificationCode.d.ts.map +1 -1
- package/dist/esm/utils/getVerificationCode.js +1 -2
- package/dist/esm/utils/getVerificationCode.js.map +1 -1
- package/package.json +2 -2
- package/src/utils/getVerificationCode.ts +3 -4
package/README.md
CHANGED
|
@@ -61,7 +61,11 @@ To use the package, import the functions in your TypeScript or JavaScript projec
|
|
|
61
61
|
#### Using ES Modules (Recommended)
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
|
-
import {
|
|
64
|
+
import {
|
|
65
|
+
createInbox,
|
|
66
|
+
getRecentEmail,
|
|
67
|
+
deleteAccount,
|
|
68
|
+
} from 'temp-disposable-email';
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
#### Using CommonJS
|
|
@@ -69,7 +73,7 @@ import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
|
|
|
69
73
|
```javascript
|
|
70
74
|
const {
|
|
71
75
|
createInbox,
|
|
72
|
-
|
|
76
|
+
getRecentEmail,
|
|
73
77
|
deleteAccount,
|
|
74
78
|
} = require('temp-disposable-email');
|
|
75
79
|
```
|
|
@@ -129,10 +133,24 @@ console.log('Account deleted');
|
|
|
129
133
|
|
|
130
134
|
## Example Workflow
|
|
131
135
|
|
|
136
|
+
### Playwright Example
|
|
137
|
+
|
|
138
|
+
For using temp-disposable-email with Playwright, see the example in the [Playwright folder](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/tree/master/examples/playwright).
|
|
139
|
+
|
|
140
|
+
### Cypress Example
|
|
141
|
+
|
|
142
|
+
For using temp-disposable-email with Cypress, see the example in the [Cypress folder](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/tree/master/examples/cypress).
|
|
143
|
+
|
|
144
|
+
### Node Example
|
|
145
|
+
|
|
132
146
|
Here's a complete example of creating an inbox, retrieving a message, and deleting the account:
|
|
133
147
|
|
|
134
148
|
```typescript
|
|
135
|
-
import {
|
|
149
|
+
import {
|
|
150
|
+
createInbox,
|
|
151
|
+
getRecentEmail,
|
|
152
|
+
deleteAccount,
|
|
153
|
+
} from 'temp-disposable-email';
|
|
136
154
|
|
|
137
155
|
async function run() {
|
|
138
156
|
try {
|
|
@@ -141,7 +159,7 @@ async function run() {
|
|
|
141
159
|
console.log('Created email:', email);
|
|
142
160
|
|
|
143
161
|
// Get the first available message from the inbox
|
|
144
|
-
const message = await
|
|
162
|
+
const message = await getRecentEmail({
|
|
145
163
|
maxWaitTime: 50000,
|
|
146
164
|
waitInterval: 3000,
|
|
147
165
|
logPolling: true,
|
|
@@ -184,7 +202,7 @@ run();
|
|
|
184
202
|
|
|
185
203
|
## Get Email Options
|
|
186
204
|
|
|
187
|
-
You can configure polling behavior by passing an options object to `
|
|
205
|
+
You can configure polling behavior by passing an options object to `getRecentEmail`. The available options are:
|
|
188
206
|
|
|
189
207
|
- `maxWaitTime` (Optional): The maximum time to wait for messages (in milliseconds).
|
|
190
208
|
- `waitInterval` (Optional): The interval between polling attempts (in milliseconds).
|
package/cypress.config.ts
CHANGED
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* const verificationCode = await getVerificationCode(emailContent);
|
|
14
14
|
* console.log(verificationCode); // Output: "123456"
|
|
15
15
|
*/
|
|
16
|
-
export declare const getVerificationCode: (text: string) => Promise<string
|
|
16
|
+
export declare const getVerificationCode: (text: string | undefined) => Promise<string>;
|
|
17
17
|
//# sourceMappingURL=getVerificationCode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVerificationCode.d.ts","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,mBAAmB,SACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"getVerificationCode.d.ts","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,mBAAmB,SACxB,MAAM,GAAG,SAAS,KACvB,OAAO,CAAC,MAAM,CAOhB,CAAC"}
|
|
@@ -22,8 +22,7 @@ const getVerificationCode = async (text) => {
|
|
|
22
22
|
if (matches) {
|
|
23
23
|
return matches[0];
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
return null;
|
|
25
|
+
throw new Error('No verification code found in the provided email content.');
|
|
27
26
|
};
|
|
28
27
|
exports.getVerificationCode = getVerificationCode;
|
|
29
28
|
//# sourceMappingURL=getVerificationCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVerificationCode.js","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEI,MAAM,mBAAmB,GAAG,KAAK,EACtC,
|
|
1
|
+
{"version":3,"file":"getVerificationCode.js","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEI,MAAM,mBAAmB,GAAG,KAAK,EACtC,IAAwB,EACP,EAAE;IACnB,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACzC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;AAC/E,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B"}
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* const verificationCode = await getVerificationCode(emailContent);
|
|
14
14
|
* console.log(verificationCode); // Output: "123456"
|
|
15
15
|
*/
|
|
16
|
-
export declare const getVerificationCode: (text: string) => Promise<string
|
|
16
|
+
export declare const getVerificationCode: (text: string | undefined) => Promise<string>;
|
|
17
17
|
//# sourceMappingURL=getVerificationCode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVerificationCode.d.ts","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,mBAAmB,SACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"getVerificationCode.d.ts","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,mBAAmB,SACxB,MAAM,GAAG,SAAS,KACvB,OAAO,CAAC,MAAM,CAOhB,CAAC"}
|
|
@@ -19,7 +19,6 @@ export const getVerificationCode = async (text) => {
|
|
|
19
19
|
if (matches) {
|
|
20
20
|
return matches[0];
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
return null;
|
|
22
|
+
throw new Error('No verification code found in the provided email content.');
|
|
24
23
|
};
|
|
25
24
|
//# sourceMappingURL=getVerificationCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVerificationCode.js","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,
|
|
1
|
+
{"version":3,"file":"getVerificationCode.js","sourceRoot":"","sources":["../../../src/utils/getVerificationCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,IAAwB,EACP,EAAE;IACnB,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACzC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;AAC/E,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "temp-disposable-email",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.7",
|
|
4
4
|
"description": "Generating Temporary email address for testing, retrieving email from the temporary email address",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"axios": "^1.7.8",
|
|
43
43
|
"dotenv": "^16.4.5",
|
|
44
|
-
"temp-disposable-email": "^1.
|
|
44
|
+
"temp-disposable-email": "^1.11.5",
|
|
45
45
|
"tslib": "^2.8.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
@@ -15,13 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export const getVerificationCode = async (
|
|
18
|
-
text: string
|
|
19
|
-
): Promise<string
|
|
18
|
+
text: string | undefined
|
|
19
|
+
): Promise<string> => {
|
|
20
20
|
console.log('Extracting the verification code from the email content...');
|
|
21
21
|
const matches = text.match(/\b\d{5,}\b/);
|
|
22
22
|
if (matches) {
|
|
23
23
|
return matches[0];
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
return null;
|
|
25
|
+
throw new Error('No verification code found in the provided email content.');
|
|
27
26
|
};
|