mcp-google-multi 5.1.2-beta.1 → 5.1.3-alpha.1
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/dist/token-store.js +30 -2
- package/package.json +1 -1
package/dist/token-store.js
CHANGED
|
@@ -6,6 +6,8 @@ const ENC_VERSION = 1;
|
|
|
6
6
|
const ALGO = 'aes-256-gcm';
|
|
7
7
|
const LOCK_TIMEOUT_MS = 5_000;
|
|
8
8
|
const LOCK_RETRY_MS = 10;
|
|
9
|
+
const RENAME_ATTEMPTS = 5;
|
|
10
|
+
const RENAME_RETRY_MS = 20;
|
|
9
11
|
export function deriveKey(masterKey) {
|
|
10
12
|
if (!masterKey) {
|
|
11
13
|
throw new Error('MASTER_KEY is required to encrypt/decrypt tokens. Generate one with: openssl rand -base64 32');
|
|
@@ -144,10 +146,36 @@ function writeTokenAtomic(alias, data) {
|
|
|
144
146
|
finally {
|
|
145
147
|
fs.closeSync(fd);
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
renameWithRetry(tmp, p);
|
|
148
150
|
}
|
|
149
151
|
finally {
|
|
150
|
-
|
|
152
|
+
try {
|
|
153
|
+
fs.rmSync(tmp, { force: true });
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// force only suppresses ENOENT; a Windows handle-holder can make this
|
|
157
|
+
// throw and mask the real write error. The orphan tmp is harmless.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Windows uses classic rename semantics (MoveFileExW without POSIX semantics),
|
|
162
|
+
// so replacing a token file that another process momentarily holds open — a
|
|
163
|
+
// concurrent readToken, antivirus, an indexer — fails with a transient
|
|
164
|
+
// EPERM/EACCES/EBUSY. Reads take no lock, so the token lock cannot prevent
|
|
165
|
+
// this; a short bounded retry absorbs it. POSIX rename never fails this way.
|
|
166
|
+
function renameWithRetry(from, to) {
|
|
167
|
+
for (let attempt = 1;; attempt++) {
|
|
168
|
+
try {
|
|
169
|
+
fs.renameSync(from, to);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
const code = error.code;
|
|
174
|
+
const transient = code === 'EPERM' || code === 'EACCES' || code === 'EBUSY';
|
|
175
|
+
if (!transient || attempt >= RENAME_ATTEMPTS)
|
|
176
|
+
throw error;
|
|
177
|
+
sleep(RENAME_RETRY_MS * attempt);
|
|
178
|
+
}
|
|
151
179
|
}
|
|
152
180
|
}
|
|
153
181
|
export function writeToken(alias, data) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-google-multi",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3-alpha.1",
|
|
4
4
|
"description": "Local MCP server for Google Workspace (Gmail, Drive, Calendar, Sheets, Docs, Contacts, Tasks, Meet, Search Console, +Forms/Chat/Admin) across multiple accounts — OAuth-only, encrypted token storage, deny-by-default writes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|