@bobfrankston/iflow 1.0.30 → 1.0.32
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/imaplib/gmail.js +8 -6
- package/package.json +2 -2
package/imaplib/gmail.js
CHANGED
|
@@ -48,10 +48,11 @@ export function createImapConfig(config) {
|
|
|
48
48
|
const tokenDir = path.join(tokenDirectory, 'tokens', accountDir);
|
|
49
49
|
const getToken = async () => {
|
|
50
50
|
// Serialize concurrent OAuth attempts — only one flow at a time per user
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// Check-and-set must be synchronous to avoid TOCTOU race
|
|
52
|
+
let pending = pendingAuth.get(username);
|
|
53
|
+
if (pending)
|
|
54
|
+
return pending;
|
|
55
|
+
pending = (async () => {
|
|
55
56
|
const token = await authenticateOAuth(credentialsPath, {
|
|
56
57
|
scope: GMAIL_SCOPE,
|
|
57
58
|
tokenDirectory: tokenDir,
|
|
@@ -64,9 +65,10 @@ export function createImapConfig(config) {
|
|
|
64
65
|
throw new Error('Failed to get Gmail access token');
|
|
65
66
|
return token.access_token;
|
|
66
67
|
})();
|
|
67
|
-
|
|
68
|
+
// Set immediately (synchronously) before any await
|
|
69
|
+
pendingAuth.set(username, pending);
|
|
68
70
|
try {
|
|
69
|
-
return await
|
|
71
|
+
return await pending;
|
|
70
72
|
}
|
|
71
73
|
finally {
|
|
72
74
|
pendingAuth.delete(username);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/iflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "IMAP client wrapper library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@bobfrankston/oauthsupport": "^1.0.
|
|
26
|
+
"@bobfrankston/oauthsupport": "^1.0.16",
|
|
27
27
|
"imapflow": "^1.0.187"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|