@auxcode/auxta 1.3.23-beta.5 → 1.3.23-beta.6
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/build/cjs/macros/helpers/AuxGoogleAuth.d.ts +0 -1
- package/build/cjs/macros/helpers/AuxGoogleAuth.js +0 -5
- package/build/cjs/macros/helpers/code.helper.js +1 -1
- package/build/cjs/macros/helpers/emailHelper.d.ts +2 -4
- package/build/cjs/macros/helpers/emailHelper.js +47 -33
- package/build/cjs/macros/helpers/extend-default-page.d.ts +1 -1
- package/build/cjs/macros/helpers/extend-default-page.js +0 -1
- package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +0 -1
- package/build/esm/macros/helpers/AuxGoogleAuth.js +0 -5
- package/build/esm/macros/helpers/code.helper.js +1 -1
- package/build/esm/macros/helpers/emailHelper.d.ts +2 -4
- package/build/esm/macros/helpers/emailHelper.js +47 -33
- package/build/esm/macros/helpers/extend-default-page.d.ts +1 -1
- package/build/esm/macros/helpers/extend-default-page.js +0 -1
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,6 @@ export declare class AuxGoogleAuth {
|
|
|
5
5
|
static get oAuth2Client(): googleType.Auth.OAuth2Client;
|
|
6
6
|
static get googleClient(): googleType.GoogleApis;
|
|
7
7
|
static get gmailClient(): googleType.gmail_v1.Gmail;
|
|
8
|
-
static get currentUser(): currentUser;
|
|
9
8
|
static setup(): Promise<void>;
|
|
10
9
|
private static authorize;
|
|
11
10
|
private static getNewToken;
|
|
@@ -37,11 +37,6 @@ class AuxGoogleAuth {
|
|
|
37
37
|
static get gmailClient() {
|
|
38
38
|
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
39
39
|
}
|
|
40
|
-
static get currentUser() {
|
|
41
|
-
const auth2 = google.auth2.getAuthInstance();
|
|
42
|
-
const profile = auth2.currentUser.get().getBasicProfile();
|
|
43
|
-
return { name: profile.getName(), email: profile.profile.getEmail() };
|
|
44
|
-
}
|
|
45
40
|
static setup() {
|
|
46
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
42
|
yield this.authorize(this.credentialsJson);
|
|
@@ -89,7 +89,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
89
89
|
}
|
|
90
90
|
timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
|
|
91
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
new Promise(r => setTimeout(r, timeout));
|
|
92
|
+
yield new Promise(r => setTimeout(r, timeout));
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { gmail_v1 } from "googleapis";
|
|
2
2
|
export declare class EmailHelper {
|
|
3
|
-
verifyEmail(from_name: string, from_email: string, subject: string, body: string): Promise<{
|
|
4
|
-
id: string;
|
|
5
|
-
threadId: string;
|
|
6
|
-
} | undefined>;
|
|
3
|
+
verifyEmail(from_name: string, from_email: string, subject: string, body: string): Promise<{}>;
|
|
7
4
|
replyEmail(ids: {
|
|
8
5
|
id: string;
|
|
9
6
|
threadId: string;
|
|
10
7
|
}, body: string): Promise<void>;
|
|
11
8
|
private getHeader;
|
|
12
9
|
private getBody;
|
|
10
|
+
private getCurrentUserEmail;
|
|
13
11
|
}
|
|
14
12
|
export interface gmailResponse extends gmail_v1.Gmail {
|
|
15
13
|
}
|
|
@@ -40,12 +40,16 @@ class EmailHelper {
|
|
|
40
40
|
format: 'FULL'
|
|
41
41
|
});
|
|
42
42
|
if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
|
|
43
|
-
const message_sender = this.getHeader('from', gmailResponse
|
|
44
|
-
const message_subject = this.getHeader('subject', gmailResponse
|
|
45
|
-
const message_body = this.getBody(
|
|
43
|
+
const message_sender = this.getHeader('from', gmailResponse);
|
|
44
|
+
const message_subject = this.getHeader('subject', gmailResponse);
|
|
45
|
+
const message_body = this.getBody(subject, gmailResponse);
|
|
46
46
|
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
47
47
|
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
48
48
|
log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
49
|
+
const returnData = {
|
|
50
|
+
id: gmailResponse.data.id.toString(),
|
|
51
|
+
threadId: gmailResponse.data.threadId.toString()
|
|
52
|
+
};
|
|
49
53
|
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
|
|
50
54
|
userId: "me",
|
|
51
55
|
id: gmailResponse.data.id,
|
|
@@ -54,67 +58,77 @@ class EmailHelper {
|
|
|
54
58
|
'removeLabelIds': ['UNREAD']
|
|
55
59
|
}
|
|
56
60
|
});
|
|
57
|
-
return
|
|
61
|
+
return returnData;
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
break;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
|
-
new Promise(r => setTimeout(r,
|
|
67
|
+
yield new Promise(r => setTimeout(r, timeoutCount));
|
|
64
68
|
timeoutCount += 12000;
|
|
65
69
|
}
|
|
66
70
|
yield log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.FAILED);
|
|
71
|
+
return {};
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
74
|
replyEmail(ids, body) {
|
|
70
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
76
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
id: ids.id,
|
|
75
|
-
format: 'FULL'
|
|
76
|
-
});
|
|
77
|
-
if (gmailResponse.data.payload) {
|
|
78
|
-
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
79
|
-
const message_messageID = this.getHeader('Message-ID', gmailResponse.data.payload.headers);
|
|
80
|
-
const reply_to = this.getHeader('reply-to', gmailResponse.data.payload.headers);
|
|
81
|
-
const options = {
|
|
82
|
-
"to": reply_to,
|
|
83
|
-
"from": AuxGoogleAuth_1.AuxGoogleAuth.currentUser.email,
|
|
84
|
-
"subject": `Re: ${message_subject}`,
|
|
85
|
-
"References": message_messageID,
|
|
86
|
-
"In-Reply-To": message_messageID,
|
|
87
|
-
"threadId": ids.threadId,
|
|
88
|
-
"html": body
|
|
89
|
-
};
|
|
90
|
-
const mailComposer = new MailComposer(options);
|
|
91
|
-
const message = yield mailComposer.compile().build();
|
|
92
|
-
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
93
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
|
|
77
|
+
if (ids.id) {
|
|
78
|
+
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
94
79
|
userId: "me",
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
80
|
+
id: ids.id,
|
|
81
|
+
format: 'FULL'
|
|
98
82
|
});
|
|
83
|
+
if (gmailResponse.data.payload) {
|
|
84
|
+
const message_subject = this.getHeader('subject', gmailResponse);
|
|
85
|
+
const message_messageID = this.getHeader('Message-ID', gmailResponse);
|
|
86
|
+
const reply_to = this.getHeader('reply-to', gmailResponse);
|
|
87
|
+
const options = {
|
|
88
|
+
to: reply_to,
|
|
89
|
+
from: this.getCurrentUserEmail(),
|
|
90
|
+
subject: `Re: ${message_subject}`,
|
|
91
|
+
references: message_messageID,
|
|
92
|
+
inReplyTo: [message_messageID],
|
|
93
|
+
html: body
|
|
94
|
+
};
|
|
95
|
+
const mailComposer = new MailComposer(options);
|
|
96
|
+
const message = yield mailComposer.compile().build();
|
|
97
|
+
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
98
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
|
|
99
|
+
userId: "me",
|
|
100
|
+
requestBody: {
|
|
101
|
+
threadId: ids.threadId,
|
|
102
|
+
raw: encodeMessage
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
99
106
|
}
|
|
100
107
|
});
|
|
101
108
|
}
|
|
102
109
|
getHeader(value, headers) {
|
|
103
|
-
for (const header of headers) {
|
|
110
|
+
for (const header of headers.data.payload.headers) {
|
|
104
111
|
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
105
112
|
return header.value.toLocaleLowerCase();
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
|
-
getBody(
|
|
116
|
+
getBody(subject, gmailResponse) {
|
|
110
117
|
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
111
118
|
if (body) {
|
|
112
119
|
return (0, buffer_1.atob)(body).toLocaleLowerCase();
|
|
113
120
|
}
|
|
114
121
|
else {
|
|
115
|
-
throw new Error(`Email
|
|
122
|
+
throw new Error(`Email with subject: ${subject} body is empty`);
|
|
116
123
|
}
|
|
117
124
|
}
|
|
125
|
+
getCurrentUserEmail() {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
128
|
+
const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
|
|
129
|
+
return profile.data.emailAddress;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
118
132
|
}
|
|
119
133
|
exports.EmailHelper = EmailHelper;
|
|
120
134
|
exports.default = new EmailHelper();
|
|
@@ -22,7 +22,6 @@ class ExtendDefaultPage {
|
|
|
22
22
|
}
|
|
23
23
|
extend_page_functions(page, time = this.defaultTimeout) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.defaultTimeout = config_1.config.timeout;
|
|
26
25
|
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
27
26
|
page.goto = function goto(url, options) {
|
|
28
27
|
log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
|
|
@@ -5,7 +5,6 @@ export declare class AuxGoogleAuth {
|
|
|
5
5
|
static get oAuth2Client(): googleType.Auth.OAuth2Client;
|
|
6
6
|
static get googleClient(): googleType.GoogleApis;
|
|
7
7
|
static get gmailClient(): googleType.gmail_v1.Gmail;
|
|
8
|
-
static get currentUser(): currentUser;
|
|
9
8
|
static setup(): Promise<void>;
|
|
10
9
|
private static authorize;
|
|
11
10
|
private static getNewToken;
|
|
@@ -34,11 +34,6 @@ export class AuxGoogleAuth {
|
|
|
34
34
|
static get gmailClient() {
|
|
35
35
|
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
36
36
|
}
|
|
37
|
-
static get currentUser() {
|
|
38
|
-
const auth2 = google.auth2.getAuthInstance();
|
|
39
|
-
const profile = auth2.currentUser.get().getBasicProfile();
|
|
40
|
-
return { name: profile.getName(), email: profile.profile.getEmail() };
|
|
41
|
-
}
|
|
42
37
|
static setup() {
|
|
43
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
39
|
yield this.authorize(this.credentialsJson);
|
|
@@ -83,7 +83,7 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
83
83
|
}
|
|
84
84
|
timeout(timeout = this.defaultTimeout, page = puppeteer.defaultPage) {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
new Promise(r => setTimeout(r, timeout));
|
|
86
|
+
yield new Promise(r => setTimeout(r, timeout));
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer.defaultPage, log_message = true) {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { gmail_v1 } from "googleapis";
|
|
2
2
|
export declare class EmailHelper {
|
|
3
|
-
verifyEmail(from_name: string, from_email: string, subject: string, body: string): Promise<{
|
|
4
|
-
id: string;
|
|
5
|
-
threadId: string;
|
|
6
|
-
} | undefined>;
|
|
3
|
+
verifyEmail(from_name: string, from_email: string, subject: string, body: string): Promise<{}>;
|
|
7
4
|
replyEmail(ids: {
|
|
8
5
|
id: string;
|
|
9
6
|
threadId: string;
|
|
10
7
|
}, body: string): Promise<void>;
|
|
11
8
|
private getHeader;
|
|
12
9
|
private getBody;
|
|
10
|
+
private getCurrentUserEmail;
|
|
13
11
|
}
|
|
14
12
|
export interface gmailResponse extends gmail_v1.Gmail {
|
|
15
13
|
}
|
|
@@ -34,12 +34,16 @@ export class EmailHelper {
|
|
|
34
34
|
format: 'FULL'
|
|
35
35
|
});
|
|
36
36
|
if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
|
|
37
|
-
const message_sender = this.getHeader('from', gmailResponse
|
|
38
|
-
const message_subject = this.getHeader('subject', gmailResponse
|
|
39
|
-
const message_body = this.getBody(
|
|
37
|
+
const message_sender = this.getHeader('from', gmailResponse);
|
|
38
|
+
const message_subject = this.getHeader('subject', gmailResponse);
|
|
39
|
+
const message_body = this.getBody(subject, gmailResponse);
|
|
40
40
|
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
41
41
|
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
42
42
|
log.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.PASSED);
|
|
43
|
+
const returnData = {
|
|
44
|
+
id: gmailResponse.data.id.toString(),
|
|
45
|
+
threadId: gmailResponse.data.threadId.toString()
|
|
46
|
+
};
|
|
43
47
|
yield AuxGoogleAuth.gmailClient.users.messages.modify({
|
|
44
48
|
userId: "me",
|
|
45
49
|
id: gmailResponse.data.id,
|
|
@@ -48,66 +52,76 @@ export class EmailHelper {
|
|
|
48
52
|
'removeLabelIds': ['UNREAD']
|
|
49
53
|
}
|
|
50
54
|
});
|
|
51
|
-
return
|
|
55
|
+
return returnData;
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
break;
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
|
-
new Promise(r => setTimeout(r,
|
|
61
|
+
yield new Promise(r => setTimeout(r, timeoutCount));
|
|
58
62
|
timeoutCount += 12000;
|
|
59
63
|
}
|
|
60
64
|
yield log.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.FAILED);
|
|
65
|
+
return {};
|
|
61
66
|
});
|
|
62
67
|
}
|
|
63
68
|
replyEmail(ids, body) {
|
|
64
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
70
|
yield AuxGoogleAuth.setup();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
id: ids.id,
|
|
69
|
-
format: 'FULL'
|
|
70
|
-
});
|
|
71
|
-
if (gmailResponse.data.payload) {
|
|
72
|
-
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
73
|
-
const message_messageID = this.getHeader('Message-ID', gmailResponse.data.payload.headers);
|
|
74
|
-
const reply_to = this.getHeader('reply-to', gmailResponse.data.payload.headers);
|
|
75
|
-
const options = {
|
|
76
|
-
"to": reply_to,
|
|
77
|
-
"from": AuxGoogleAuth.currentUser.email,
|
|
78
|
-
"subject": `Re: ${message_subject}`,
|
|
79
|
-
"References": message_messageID,
|
|
80
|
-
"In-Reply-To": message_messageID,
|
|
81
|
-
"threadId": ids.threadId,
|
|
82
|
-
"html": body
|
|
83
|
-
};
|
|
84
|
-
const mailComposer = new MailComposer(options);
|
|
85
|
-
const message = yield mailComposer.compile().build();
|
|
86
|
-
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
87
|
-
yield AuxGoogleAuth.gmailClient.users.messages.send({
|
|
71
|
+
if (ids.id) {
|
|
72
|
+
const gmailResponse = yield AuxGoogleAuth.gmailClient.users.messages.get({
|
|
88
73
|
userId: "me",
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
74
|
+
id: ids.id,
|
|
75
|
+
format: 'FULL'
|
|
92
76
|
});
|
|
77
|
+
if (gmailResponse.data.payload) {
|
|
78
|
+
const message_subject = this.getHeader('subject', gmailResponse);
|
|
79
|
+
const message_messageID = this.getHeader('Message-ID', gmailResponse);
|
|
80
|
+
const reply_to = this.getHeader('reply-to', gmailResponse);
|
|
81
|
+
const options = {
|
|
82
|
+
to: reply_to,
|
|
83
|
+
from: this.getCurrentUserEmail(),
|
|
84
|
+
subject: `Re: ${message_subject}`,
|
|
85
|
+
references: message_messageID,
|
|
86
|
+
inReplyTo: [message_messageID],
|
|
87
|
+
html: body
|
|
88
|
+
};
|
|
89
|
+
const mailComposer = new MailComposer(options);
|
|
90
|
+
const message = yield mailComposer.compile().build();
|
|
91
|
+
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
92
|
+
yield AuxGoogleAuth.gmailClient.users.messages.send({
|
|
93
|
+
userId: "me",
|
|
94
|
+
requestBody: {
|
|
95
|
+
threadId: ids.threadId,
|
|
96
|
+
raw: encodeMessage
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
93
100
|
}
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
103
|
getHeader(value, headers) {
|
|
97
|
-
for (const header of headers) {
|
|
104
|
+
for (const header of headers.data.payload.headers) {
|
|
98
105
|
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
99
106
|
return header.value.toLocaleLowerCase();
|
|
100
107
|
}
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
|
-
getBody(
|
|
110
|
+
getBody(subject, gmailResponse) {
|
|
104
111
|
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
105
112
|
if (body) {
|
|
106
113
|
return atob(body).toLocaleLowerCase();
|
|
107
114
|
}
|
|
108
115
|
else {
|
|
109
|
-
throw new Error(`Email
|
|
116
|
+
throw new Error(`Email with subject: ${subject} body is empty`);
|
|
110
117
|
}
|
|
111
118
|
}
|
|
119
|
+
getCurrentUserEmail() {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
yield AuxGoogleAuth.setup();
|
|
122
|
+
const profile = yield AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
|
|
123
|
+
return profile.data.emailAddress;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
112
126
|
}
|
|
113
127
|
export default new EmailHelper();
|
|
@@ -16,7 +16,6 @@ export class ExtendDefaultPage {
|
|
|
16
16
|
}
|
|
17
17
|
extend_page_functions(page, time = this.defaultTimeout) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
this.defaultTimeout = config.timeout;
|
|
20
19
|
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
21
20
|
page.goto = function goto(url, options) {
|
|
22
21
|
log.push('Then', `I go to the '${url}' page`, StatusOfStep.PASSED);
|