mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2025-12-27 16:10:17 +07:00
node_modules: update (#246)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
65
node_modules/nodemailer/lib/xoauth2/index.js
generated
vendored
65
node_modules/nodemailer/lib/xoauth2/index.js
generated
vendored
@@ -72,6 +72,9 @@ class XOAuth2 extends Stream {
|
||||
let timeout = Math.max(Number(this.options.timeout) || 0, 0);
|
||||
this.expires = (timeout && Date.now() + timeout * 1000) || 0;
|
||||
}
|
||||
|
||||
this.renewing = false; // Track if renewal is in progress
|
||||
this.renewalQueue = []; // Queue for pending requests during renewal
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,14 +85,61 @@ class XOAuth2 extends Stream {
|
||||
*/
|
||||
getToken(renew, callback) {
|
||||
if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) {
|
||||
this.logger.debug(
|
||||
{
|
||||
tnx: 'OAUTH2',
|
||||
user: this.options.user,
|
||||
action: 'reuse'
|
||||
},
|
||||
'Reusing existing access token for %s',
|
||||
this.options.user
|
||||
);
|
||||
return callback(null, this.accessToken);
|
||||
}
|
||||
|
||||
let generateCallback = (...args) => {
|
||||
if (args[0]) {
|
||||
// check if it is possible to renew, if not, return the current token or error
|
||||
if (!this.provisionCallback && !this.options.refreshToken && !this.options.serviceClient) {
|
||||
if (this.accessToken) {
|
||||
this.logger.debug(
|
||||
{
|
||||
tnx: 'OAUTH2',
|
||||
user: this.options.user,
|
||||
action: 'reuse'
|
||||
},
|
||||
'Reusing existing access token (no refresh capability) for %s',
|
||||
this.options.user
|
||||
);
|
||||
return callback(null, this.accessToken);
|
||||
}
|
||||
this.logger.error(
|
||||
{
|
||||
tnx: 'OAUTH2',
|
||||
user: this.options.user,
|
||||
action: 'renew'
|
||||
},
|
||||
'Cannot renew access token for %s: No refresh mechanism available',
|
||||
this.options.user
|
||||
);
|
||||
return callback(new Error("Can't create new access token for user"));
|
||||
}
|
||||
|
||||
// If renewal already in progress, queue this request instead of starting another
|
||||
if (this.renewing) {
|
||||
return this.renewalQueue.push({ renew, callback });
|
||||
}
|
||||
|
||||
this.renewing = true;
|
||||
|
||||
// Handles token renewal completion - processes queued requests and cleans up
|
||||
const generateCallback = (err, accessToken) => {
|
||||
this.renewalQueue.forEach(item => item.callback(err, accessToken));
|
||||
this.renewalQueue = [];
|
||||
this.renewing = false;
|
||||
|
||||
if (err) {
|
||||
this.logger.error(
|
||||
{
|
||||
err: args[0],
|
||||
err,
|
||||
tnx: 'OAUTH2',
|
||||
user: this.options.user,
|
||||
action: 'renew'
|
||||
@@ -108,7 +158,8 @@ class XOAuth2 extends Stream {
|
||||
this.options.user
|
||||
);
|
||||
}
|
||||
callback(...args);
|
||||
// Complete original request
|
||||
callback(err, accessToken);
|
||||
};
|
||||
|
||||
if (this.provisionCallback) {
|
||||
@@ -166,8 +217,8 @@ class XOAuth2 extends Stream {
|
||||
let token;
|
||||
try {
|
||||
token = this.jwtSignRS256(tokenData);
|
||||
} catch (err) {
|
||||
return callback(new Error('Can\x27t generate token. Check your auth options'));
|
||||
} catch (_err) {
|
||||
return callback(new Error("Can't generate token. Check your auth options"));
|
||||
}
|
||||
|
||||
urlOptions = {
|
||||
@@ -181,7 +232,7 @@ class XOAuth2 extends Stream {
|
||||
};
|
||||
} else {
|
||||
if (!this.options.refreshToken) {
|
||||
return callback(new Error('Can\x27t create new access token for user'));
|
||||
return callback(new Error("Can't create new access token for user"));
|
||||
}
|
||||
|
||||
// web app - https://developers.google.com/identity/protocols/OAuth2WebServer
|
||||
|
||||
Reference in New Issue
Block a user