@cortexkit/antigravity-auth-core 3.0.3 → 3.0.4
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/agy-request-metadata.d.ts.map +1 -1
- package/dist/agy-request-metadata.js +9 -0
- package/dist/agy-request-metadata.js.map +1 -1
- package/dist/common-auth-embedded/claustrum/enrollment.d.ts +3 -2
- package/dist/common-auth-embedded/claustrum/enrollment.js +84 -42
- package/dist/common-auth-embedded/claustrum/roster.js +2 -2
- package/dist/common-auth-embedded/fs/atomic-write.d.ts +5 -0
- package/dist/common-auth-embedded/fs/atomic-write.js +21 -0
- package/dist/common-auth-embedded/fs/index.d.ts +2 -0
- package/dist/common-auth-embedded/fs/index.js +1 -0
- package/dist/common-auth-embedded/fs/private-files.d.ts +66 -0
- package/dist/common-auth-embedded/fs/private-files.js +302 -0
- package/dist/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
- package/dist/common-auth-embedded/fs/refresh-file-lock.js +254 -37
- package/dist/common-auth-embedded/fs/with-lock.d.ts +3 -0
- package/dist/common-auth-embedded/fs/with-lock.js +4 -0
- package/dist/common-auth-embedded/logger/engine.d.ts +6 -8
- package/dist/common-auth-embedded/logger/engine.js +126 -11
- package/dist/common-auth-embedded/pi-slot/slot.d.ts +2 -0
- package/dist/common-auth-embedded/pi-slot/slot.js +34 -6
- package/dist/common-auth-embedded/source-output.json +83 -67
- package/dist/common-auth-embedded/store/mutate.js +2 -2
- package/dist/common-auth-embedded/store/pool.d.ts +1 -0
- package/dist/common-auth-embedded/store/pool.js +3 -0
- package/dist/common-auth-embedded/store/refresh-lock.d.ts +4 -0
- package/dist/common-auth-embedded/store/refresh-lock.js +5 -0
- package/dist/fingerprint.d.ts +2 -2
- package/dist/fingerprint.js +2 -2
- package/dist/model-registry.d.ts +4 -1
- package/dist/model-registry.d.ts.map +1 -1
- package/dist/model-registry.js +61 -104
- package/dist/model-registry.js.map +1 -1
- package/dist/quota-manager.d.ts.map +1 -1
- package/dist/quota-manager.js +3 -1
- package/dist/quota-manager.js.map +1 -1
- package/dist/transform/agy-generation.d.ts.map +1 -1
- package/dist/transform/agy-generation.js +11 -2
- package/dist/transform/agy-generation.js.map +1 -1
- package/dist/transform/model-resolver.d.ts.map +1 -1
- package/dist/transform/model-resolver.js +18 -4
- package/dist/transform/model-resolver.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { appendFileSync, chmodSync, existsSync, renameSync, statSync, } from 'node:fs';
|
|
2
|
+
import { open } from 'node:fs/promises';
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
import { createPrivateBytes, ensurePrivateDirectory, privateOperation, replaceWindowsFile, verifyPrivate, windowsPrivateFiles, } from '../fs/private-files.js';
|
|
2
5
|
import { createRedactor } from './redact.js';
|
|
3
6
|
const ORDER = {
|
|
4
7
|
error: 0,
|
|
@@ -36,6 +39,75 @@ function rotateIfNeeded(f) {
|
|
|
36
39
|
/* never throw */
|
|
37
40
|
}
|
|
38
41
|
}
|
|
42
|
+
async function closeWindowsFile(sink) {
|
|
43
|
+
const { file, handle } = sink;
|
|
44
|
+
sink.file = undefined;
|
|
45
|
+
sink.handle = undefined;
|
|
46
|
+
if (file && handle)
|
|
47
|
+
await privateOperation(file, 'log-close', () => handle.close());
|
|
48
|
+
}
|
|
49
|
+
async function openWindowsFile(sink, file) {
|
|
50
|
+
await ensurePrivateDirectory(dirname(file));
|
|
51
|
+
try {
|
|
52
|
+
await verifyPrivate(file, 'file', true);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code !== 'ENOENT')
|
|
56
|
+
throw error;
|
|
57
|
+
try {
|
|
58
|
+
await createPrivateBytes(file, '');
|
|
59
|
+
}
|
|
60
|
+
catch (creationError) {
|
|
61
|
+
if (creationError.code !== 'EEXIST')
|
|
62
|
+
throw creationError;
|
|
63
|
+
await verifyPrivate(file, 'file', true);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// The safe-parent policy denies other ordinary users the ability to create, replace or link entries between verification and fs.open.
|
|
67
|
+
// This protects against other ordinary users, not the owner or administrators, whose ability to change that namespace is outside our threat model.
|
|
68
|
+
sink.handle = await privateOperation(file, 'log-open', () => open(file, 'a'));
|
|
69
|
+
sink.file = file;
|
|
70
|
+
return sink.handle;
|
|
71
|
+
}
|
|
72
|
+
async function flushWindowsFile(sink, file, text) {
|
|
73
|
+
file = resolve(file);
|
|
74
|
+
try {
|
|
75
|
+
if (sink.file !== file)
|
|
76
|
+
await closeWindowsFile(sink);
|
|
77
|
+
let handle = sink.handle ?? (await openWindowsFile(sink, file));
|
|
78
|
+
const info = await privateOperation(file, 'log-stat', () => handle.stat());
|
|
79
|
+
if (info.size >= MAX_BYTES) {
|
|
80
|
+
await closeWindowsFile(sink);
|
|
81
|
+
for (let i = ROTATE_KEEP - 1; i >= 0; i--) {
|
|
82
|
+
const source = i === 0 ? file : `${file}.${i}`;
|
|
83
|
+
const target = `${file}.${i + 1}`;
|
|
84
|
+
try {
|
|
85
|
+
await verifyPrivate(source, 'file', true);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error.code === 'ENOENT')
|
|
89
|
+
continue;
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
await verifyPrivate(target, 'file', true);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error.code !== 'ENOENT')
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
await replaceWindowsFile(source, target);
|
|
100
|
+
await verifyPrivate(target, 'file');
|
|
101
|
+
}
|
|
102
|
+
handle = await openWindowsFile(sink, file);
|
|
103
|
+
}
|
|
104
|
+
await privateOperation(file, 'log-append', () => handle.appendFile(text, 'utf8'));
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
await closeWindowsFile(sink).catch(() => { });
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
39
111
|
function safeSerialize(data) {
|
|
40
112
|
try {
|
|
41
113
|
return ` ${JSON.stringify(data)}`;
|
|
@@ -63,7 +135,19 @@ function createEngine(options) {
|
|
|
63
135
|
let captureSink;
|
|
64
136
|
let buffer = [];
|
|
65
137
|
let timer;
|
|
138
|
+
let orderedSink = Promise.resolve();
|
|
139
|
+
let sinkError;
|
|
140
|
+
const windowsFile = {};
|
|
141
|
+
function queueWindows(operation) {
|
|
142
|
+
const next = orderedSink.then(operation);
|
|
143
|
+
orderedSink = next.catch((error) => {
|
|
144
|
+
sinkError = error;
|
|
145
|
+
});
|
|
146
|
+
return next;
|
|
147
|
+
}
|
|
66
148
|
function configure(next) {
|
|
149
|
+
if (windowsPrivateFiles && next.file !== logFileSource)
|
|
150
|
+
void queueWindows(() => closeWindowsFile(windowsFile)).catch(() => { });
|
|
67
151
|
logFileSource = next.file;
|
|
68
152
|
initLevelSource = next.level;
|
|
69
153
|
redactor = createRedactor(next);
|
|
@@ -89,25 +173,49 @@ function createEngine(options) {
|
|
|
89
173
|
return floor;
|
|
90
174
|
return 'info';
|
|
91
175
|
}
|
|
92
|
-
function flushLogs() {
|
|
176
|
+
function flushLogs(close = true) {
|
|
93
177
|
if (timer) {
|
|
94
178
|
clearTimeout(timer);
|
|
95
179
|
timer = undefined;
|
|
96
180
|
}
|
|
97
|
-
if (!buffer.length)
|
|
181
|
+
if (!buffer.length) {
|
|
182
|
+
if (windowsPrivateFiles)
|
|
183
|
+
return queueWindows(async () => {
|
|
184
|
+
if (close)
|
|
185
|
+
await closeWindowsFile(windowsFile);
|
|
186
|
+
if (sinkError)
|
|
187
|
+
throw sinkError;
|
|
188
|
+
});
|
|
98
189
|
return;
|
|
190
|
+
}
|
|
99
191
|
let file;
|
|
100
192
|
try {
|
|
101
193
|
file = logFilePath();
|
|
102
194
|
}
|
|
103
195
|
catch {
|
|
104
196
|
buffer = [];
|
|
197
|
+
if (windowsPrivateFiles && close)
|
|
198
|
+
return queueWindows(() => closeWindowsFile(windowsFile));
|
|
105
199
|
return;
|
|
106
200
|
}
|
|
107
201
|
const text = buffer.join('');
|
|
108
202
|
buffer = [];
|
|
109
|
-
if (!file)
|
|
203
|
+
if (!file) {
|
|
204
|
+
if (windowsPrivateFiles && close)
|
|
205
|
+
return queueWindows(() => closeWindowsFile(windowsFile));
|
|
110
206
|
return;
|
|
207
|
+
}
|
|
208
|
+
if (windowsPrivateFiles) {
|
|
209
|
+
return queueWindows(async () => {
|
|
210
|
+
try {
|
|
211
|
+
await flushWindowsFile(windowsFile, file, text);
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
if (close)
|
|
215
|
+
await closeWindowsFile(windowsFile);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
111
219
|
try {
|
|
112
220
|
rotateIfNeeded(file);
|
|
113
221
|
if (existsSync(file))
|
|
@@ -122,7 +230,9 @@ function createEngine(options) {
|
|
|
122
230
|
if (!timer)
|
|
123
231
|
timer = setTimeout(() => {
|
|
124
232
|
timer = undefined;
|
|
125
|
-
flushLogs();
|
|
233
|
+
const flushed = flushLogs(false);
|
|
234
|
+
if (flushed instanceof Promise)
|
|
235
|
+
void flushed.catch(() => { });
|
|
126
236
|
}, 500);
|
|
127
237
|
}
|
|
128
238
|
function emit(channel, level, message, data) {
|
|
@@ -157,8 +267,11 @@ function createEngine(options) {
|
|
|
157
267
|
if (logFileSource === undefined)
|
|
158
268
|
return;
|
|
159
269
|
buffer.push(line);
|
|
160
|
-
if (buffer.length >= 50)
|
|
161
|
-
flushLogs();
|
|
270
|
+
if (buffer.length >= 50) {
|
|
271
|
+
const flushed = flushLogs(false);
|
|
272
|
+
if (flushed instanceof Promise)
|
|
273
|
+
void flushed.catch(() => { });
|
|
274
|
+
}
|
|
162
275
|
else
|
|
163
276
|
schedule();
|
|
164
277
|
}
|
|
@@ -176,6 +289,9 @@ function createEngine(options) {
|
|
|
176
289
|
};
|
|
177
290
|
}
|
|
178
291
|
function reset() {
|
|
292
|
+
if (windowsPrivateFiles)
|
|
293
|
+
void queueWindows(() => closeWindowsFile(windowsFile)).catch(() => { });
|
|
294
|
+
sinkError = undefined;
|
|
179
295
|
buffer = [];
|
|
180
296
|
if (timer) {
|
|
181
297
|
clearTimeout(timer);
|
|
@@ -222,18 +338,17 @@ export function setLogLevel(l) {
|
|
|
222
338
|
defaultEngine.setLogLevel(l);
|
|
223
339
|
}
|
|
224
340
|
/**
|
|
225
|
-
* Write whatever the default logger has buffered.
|
|
226
|
-
*
|
|
227
|
-
* shutdown.
|
|
341
|
+
* Write whatever the default logger has buffered. On Windows await the
|
|
342
|
+
* promise before shutdown; POSIX keeps synchronous process-exit flushing.
|
|
228
343
|
*/
|
|
229
344
|
export function flushLogs() {
|
|
230
|
-
defaultEngine.flushLogs();
|
|
345
|
+
return defaultEngine.flushLogs();
|
|
231
346
|
}
|
|
232
347
|
export function createLogger(channel) {
|
|
233
348
|
return defaultEngine.createLogger(channel);
|
|
234
349
|
}
|
|
235
350
|
export async function flushForTest() {
|
|
236
|
-
defaultEngine.flushLogs();
|
|
351
|
+
return defaultEngine.flushLogs();
|
|
237
352
|
}
|
|
238
353
|
/**
|
|
239
354
|
* Return the default logger to its uninitialised state. Only a test needs
|
|
@@ -5,6 +5,8 @@ export declare class PiSlotError extends Error {
|
|
|
5
5
|
constructor(code: PiSlotErrorCode);
|
|
6
6
|
}
|
|
7
7
|
export interface PiSlotOptions {
|
|
8
|
+
/** Windows checks safe ancestry and creates missing parents owner-only, regardless of this option. POSIX keeps its existing directory policy. */
|
|
9
|
+
privateParents?: boolean;
|
|
8
10
|
authPath: string;
|
|
9
11
|
provider: string;
|
|
10
12
|
/**
|
|
@@ -4,6 +4,7 @@ import { lstat, mkdir, open, unlink } from 'node:fs/promises';
|
|
|
4
4
|
import { dirname, resolve } from 'node:path';
|
|
5
5
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
6
6
|
import { writeJsonAtomic } from '../fs/atomic-write.js';
|
|
7
|
+
import { ensurePrivateDirectory, PrivateFileError, readPrivateBuffer, windowsPrivateFiles, } from '../fs/private-files.js';
|
|
7
8
|
import { acquirePiLock } from './lock.js';
|
|
8
9
|
/** Errors deliberately contain neither paths nor credentials nor underlying error messages. */
|
|
9
10
|
export class PiSlotError extends Error {
|
|
@@ -96,6 +97,21 @@ function code(error) {
|
|
|
96
97
|
return object(error) ? error.code : undefined;
|
|
97
98
|
}
|
|
98
99
|
async function safeRead(path, privateFile = false, afterReadCheck) {
|
|
100
|
+
if (windowsPrivateFiles) {
|
|
101
|
+
try {
|
|
102
|
+
await afterReadCheck?.(path);
|
|
103
|
+
const bytes = await readPrivateBuffer(path, true);
|
|
104
|
+
const text = bytes.toString('utf8');
|
|
105
|
+
if (!bytes.equals(Buffer.from(text)))
|
|
106
|
+
throw new PiSlotError(privateFile ? 'invalid-stash' : 'invalid-auth');
|
|
107
|
+
return text;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (code(error) === 'ENOENT')
|
|
111
|
+
return undefined;
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
99
115
|
let file;
|
|
100
116
|
try {
|
|
101
117
|
file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
@@ -188,6 +204,10 @@ function replaceEntry(auth, provider, next) {
|
|
|
188
204
|
return `${text.slice(0, offset)}${last ? ',' : ''}${JSON.stringify(provider)}:${next}${text.slice(offset)}`;
|
|
189
205
|
}
|
|
190
206
|
async function syncDir(path) {
|
|
207
|
+
// Windows flushes file bytes before rename but cannot promise persisted
|
|
208
|
+
// directory metadata, so this Pi transition deliberately skips directory sync.
|
|
209
|
+
if (windowsPrivateFiles)
|
|
210
|
+
return;
|
|
191
211
|
const dir = await open(path, 'r');
|
|
192
212
|
try {
|
|
193
213
|
await dir.sync();
|
|
@@ -200,6 +220,7 @@ async function atomicWrite(path, text, assertLock, beforeRename) {
|
|
|
200
220
|
await writeJsonAtomic(path, null, {
|
|
201
221
|
serialize: () => text,
|
|
202
222
|
durable: true,
|
|
223
|
+
durability: windowsPrivateFiles ? 'file-only-on-windows' : undefined,
|
|
203
224
|
beforeRename: async () => {
|
|
204
225
|
await beforeRename?.(path);
|
|
205
226
|
assertLock();
|
|
@@ -274,7 +295,10 @@ export function createPiSlot(options, onStep, hooks) {
|
|
|
274
295
|
throw new PiSlotError('lock-compromised');
|
|
275
296
|
};
|
|
276
297
|
try {
|
|
277
|
-
|
|
298
|
+
if (windowsPrivateFiles)
|
|
299
|
+
await ensurePrivateDirectory(dirname(authPath));
|
|
300
|
+
else
|
|
301
|
+
await mkdir(dirname(authPath), { recursive: true, mode: 0o700 });
|
|
278
302
|
const deadline = Date.now() + timeout;
|
|
279
303
|
let retry = 0;
|
|
280
304
|
while (!release) {
|
|
@@ -300,7 +324,7 @@ export function createPiSlot(options, onStep, hooks) {
|
|
|
300
324
|
return result;
|
|
301
325
|
}
|
|
302
326
|
catch (error) {
|
|
303
|
-
if (error instanceof PiSlotError)
|
|
327
|
+
if (error instanceof PiSlotError || error instanceof PrivateFileError)
|
|
304
328
|
throw error;
|
|
305
329
|
throw new PiSlotError('io');
|
|
306
330
|
}
|
|
@@ -342,10 +366,14 @@ export function createPiSlot(options, onStep, hooks) {
|
|
|
342
366
|
if (stash && digest(auth.entry) !== stash.sha256)
|
|
343
367
|
throw new PiSlotError('conflict');
|
|
344
368
|
if (!stash) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
369
|
+
if (windowsPrivateFiles)
|
|
370
|
+
await ensurePrivateDirectory(dirname(stashPath));
|
|
371
|
+
else {
|
|
372
|
+
await mkdir(dirname(stashPath), { recursive: true, mode: 0o700 });
|
|
373
|
+
const dir = await lstat(dirname(stashPath));
|
|
374
|
+
if (!dir.isDirectory() || (dir.mode & 0o777) !== 0o700)
|
|
375
|
+
throw new PiSlotError('unsafe-path');
|
|
376
|
+
}
|
|
349
377
|
const saved = {
|
|
350
378
|
version: 1,
|
|
351
379
|
provider,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"artifactStatus": "released",
|
|
6
6
|
"publicRoots": {
|
|
7
7
|
"./store": {
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"import": "./dist/pi-slot/index.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.
|
|
41
|
-
"tarballSha256": "
|
|
42
|
-
"sri": "sha512-
|
|
43
|
-
"canonicalFiles":
|
|
44
|
-
"canonicalBytes":
|
|
40
|
+
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.15.0.tgz",
|
|
41
|
+
"tarballSha256": "a23db89b43bedba8d371cd9d45e5f35306040cda3f425efb49fbce5610aa9c6b",
|
|
42
|
+
"sri": "sha512-1EQVggxbrijCtfdyv4z60eSl0dmZRGO6i1q2m8w20VxwdowWkUV0Y/7kErhp1/2ZNvmDZK65RICMiTcokidxiw==",
|
|
43
|
+
"canonicalFiles": 131,
|
|
44
|
+
"canonicalBytes": 730840,
|
|
45
45
|
"generator": {
|
|
46
46
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
47
47
|
"version": 3,
|
|
48
|
-
"sha256": "
|
|
48
|
+
"sha256": "158eda37ce92ca20155ccf2c74aca00072a600d976e7d74d8bce0059ea351867"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
{
|
|
@@ -243,17 +243,17 @@
|
|
|
243
243
|
{
|
|
244
244
|
"source": "package/dist/claustrum/enrollment.d.ts",
|
|
245
245
|
"output": "claustrum/enrollment.d.ts",
|
|
246
|
-
"bytes":
|
|
247
|
-
"sourceSha256": "
|
|
248
|
-
"outputSha256": "
|
|
246
|
+
"bytes": 7528,
|
|
247
|
+
"sourceSha256": "5b2f01bd0a6dd5f92a8450c43619717f08d1ca9aea0ed20f3f7071cc94c1c1bf",
|
|
248
|
+
"outputSha256": "5b2f01bd0a6dd5f92a8450c43619717f08d1ca9aea0ed20f3f7071cc94c1c1bf",
|
|
249
249
|
"transform": "verbatim"
|
|
250
250
|
},
|
|
251
251
|
{
|
|
252
252
|
"source": "package/dist/claustrum/enrollment.js",
|
|
253
253
|
"output": "claustrum/enrollment.js",
|
|
254
|
-
"bytes":
|
|
255
|
-
"sourceSha256": "
|
|
256
|
-
"outputSha256": "
|
|
254
|
+
"bytes": 33305,
|
|
255
|
+
"sourceSha256": "e03e33e3f43daf5563d7e2138450c6a5347017a82627c5b8e1d1998b4ce4c42f",
|
|
256
|
+
"outputSha256": "e03e33e3f43daf5563d7e2138450c6a5347017a82627c5b8e1d1998b4ce4c42f",
|
|
257
257
|
"transform": "verbatim"
|
|
258
258
|
},
|
|
259
259
|
{
|
|
@@ -331,9 +331,9 @@
|
|
|
331
331
|
{
|
|
332
332
|
"source": "package/dist/claustrum/roster.js",
|
|
333
333
|
"output": "claustrum/roster.js",
|
|
334
|
-
"bytes":
|
|
335
|
-
"sourceSha256": "
|
|
336
|
-
"outputSha256": "
|
|
334
|
+
"bytes": 23840,
|
|
335
|
+
"sourceSha256": "8f9d247e7d614e997cebb9728eaeb96fd0f32955cebfccc3d016351ad39a3947",
|
|
336
|
+
"outputSha256": "8f9d247e7d614e997cebb9728eaeb96fd0f32955cebfccc3d016351ad39a3947",
|
|
337
337
|
"transform": "verbatim"
|
|
338
338
|
},
|
|
339
339
|
{
|
|
@@ -435,33 +435,33 @@
|
|
|
435
435
|
{
|
|
436
436
|
"source": "package/dist/fs/atomic-write.d.ts",
|
|
437
437
|
"output": "fs/atomic-write.d.ts",
|
|
438
|
-
"bytes":
|
|
439
|
-
"sourceSha256": "
|
|
440
|
-
"outputSha256": "
|
|
438
|
+
"bytes": 1465,
|
|
439
|
+
"sourceSha256": "d2117894a4fe94d3786dd7a126bce1d72748ba4c8f5838bcb880607b376886c4",
|
|
440
|
+
"outputSha256": "d2117894a4fe94d3786dd7a126bce1d72748ba4c8f5838bcb880607b376886c4",
|
|
441
441
|
"transform": "verbatim"
|
|
442
442
|
},
|
|
443
443
|
{
|
|
444
444
|
"source": "package/dist/fs/atomic-write.js",
|
|
445
445
|
"output": "fs/atomic-write.js",
|
|
446
|
-
"bytes":
|
|
447
|
-
"sourceSha256": "
|
|
448
|
-
"outputSha256": "
|
|
446
|
+
"bytes": 3450,
|
|
447
|
+
"sourceSha256": "80779a8078e673ef68deaa7fdee3a0e1322078521a1f4156c0a595814c374044",
|
|
448
|
+
"outputSha256": "80779a8078e673ef68deaa7fdee3a0e1322078521a1f4156c0a595814c374044",
|
|
449
449
|
"transform": "verbatim"
|
|
450
450
|
},
|
|
451
451
|
{
|
|
452
452
|
"source": "package/dist/fs/index.d.ts",
|
|
453
453
|
"output": "fs/index.d.ts",
|
|
454
|
-
"bytes":
|
|
455
|
-
"sourceSha256": "
|
|
456
|
-
"outputSha256": "
|
|
454
|
+
"bytes": 626,
|
|
455
|
+
"sourceSha256": "31ad80c3a005dfd3c78d1b8d1a2d4c23ce9d47dd9f6b5b8c3b9ec4f07c4b5cdb",
|
|
456
|
+
"outputSha256": "31ad80c3a005dfd3c78d1b8d1a2d4c23ce9d47dd9f6b5b8c3b9ec4f07c4b5cdb",
|
|
457
457
|
"transform": "verbatim"
|
|
458
458
|
},
|
|
459
459
|
{
|
|
460
460
|
"source": "package/dist/fs/index.js",
|
|
461
461
|
"output": "fs/index.js",
|
|
462
|
-
"bytes":
|
|
463
|
-
"sourceSha256": "
|
|
464
|
-
"outputSha256": "
|
|
462
|
+
"bytes": 509,
|
|
463
|
+
"sourceSha256": "26127c5a818c2ff0f66374f2dbbd93f57c6de7266acb2b2f61117e6e17e57f2b",
|
|
464
|
+
"outputSha256": "26127c5a818c2ff0f66374f2dbbd93f57c6de7266acb2b2f61117e6e17e57f2b",
|
|
465
465
|
"transform": "verbatim"
|
|
466
466
|
},
|
|
467
467
|
{
|
|
@@ -480,36 +480,52 @@
|
|
|
480
480
|
"outputSha256": "cd60090325fa8c4c17dddfc216a4ed326f2a6e48525e724a4dd260bf88041231",
|
|
481
481
|
"transform": "verbatim"
|
|
482
482
|
},
|
|
483
|
+
{
|
|
484
|
+
"source": "package/dist/fs/private-files.d.ts",
|
|
485
|
+
"output": "fs/private-files.d.ts",
|
|
486
|
+
"bytes": 3228,
|
|
487
|
+
"sourceSha256": "1882d869cfebb3cebc8b9db47fb15083f8300c51c26c71666e898377fcd9a1ba",
|
|
488
|
+
"outputSha256": "1882d869cfebb3cebc8b9db47fb15083f8300c51c26c71666e898377fcd9a1ba",
|
|
489
|
+
"transform": "verbatim"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"source": "package/dist/fs/private-files.js",
|
|
493
|
+
"output": "fs/private-files.js",
|
|
494
|
+
"bytes": 12025,
|
|
495
|
+
"sourceSha256": "4b46f7b37c11da02f655a6ca841fa51189ceefffaa4476f4fa7a27f953c54ad4",
|
|
496
|
+
"outputSha256": "4b46f7b37c11da02f655a6ca841fa51189ceefffaa4476f4fa7a27f953c54ad4",
|
|
497
|
+
"transform": "verbatim"
|
|
498
|
+
},
|
|
483
499
|
{
|
|
484
500
|
"source": "package/dist/fs/refresh-file-lock.d.ts",
|
|
485
501
|
"output": "fs/refresh-file-lock.d.ts",
|
|
486
|
-
"bytes":
|
|
487
|
-
"sourceSha256": "
|
|
488
|
-
"outputSha256": "
|
|
502
|
+
"bytes": 1765,
|
|
503
|
+
"sourceSha256": "72996a1247d498a34ac157d23c34ef03bcbdb68c79e8751be4874885aed7e843",
|
|
504
|
+
"outputSha256": "72996a1247d498a34ac157d23c34ef03bcbdb68c79e8751be4874885aed7e843",
|
|
489
505
|
"transform": "verbatim"
|
|
490
506
|
},
|
|
491
507
|
{
|
|
492
508
|
"source": "package/dist/fs/refresh-file-lock.js",
|
|
493
509
|
"output": "fs/refresh-file-lock.js",
|
|
494
|
-
"bytes":
|
|
495
|
-
"sourceSha256": "
|
|
496
|
-
"outputSha256": "
|
|
510
|
+
"bytes": 28985,
|
|
511
|
+
"sourceSha256": "6bf0f944bd70c60f1679bdc4c2764d19ed0047c77dbf737c13088bb8c478e5e2",
|
|
512
|
+
"outputSha256": "6bf0f944bd70c60f1679bdc4c2764d19ed0047c77dbf737c13088bb8c478e5e2",
|
|
497
513
|
"transform": "verbatim"
|
|
498
514
|
},
|
|
499
515
|
{
|
|
500
516
|
"source": "package/dist/fs/with-lock.d.ts",
|
|
501
517
|
"output": "fs/with-lock.d.ts",
|
|
502
|
-
"bytes":
|
|
503
|
-
"sourceSha256": "
|
|
504
|
-
"outputSha256": "
|
|
518
|
+
"bytes": 1153,
|
|
519
|
+
"sourceSha256": "a0509ca4ee64b392b69c7a8555c7b33c0c223a8e58aec48848c3216350f1ba0c",
|
|
520
|
+
"outputSha256": "a0509ca4ee64b392b69c7a8555c7b33c0c223a8e58aec48848c3216350f1ba0c",
|
|
505
521
|
"transform": "verbatim"
|
|
506
522
|
},
|
|
507
523
|
{
|
|
508
524
|
"source": "package/dist/fs/with-lock.js",
|
|
509
525
|
"output": "fs/with-lock.js",
|
|
510
|
-
"bytes":
|
|
511
|
-
"sourceSha256": "
|
|
512
|
-
"outputSha256": "
|
|
526
|
+
"bytes": 1697,
|
|
527
|
+
"sourceSha256": "35b4ed6dec77ffcb7850e655a35957da15c14a0fa27b6f3d1d634e243de43456",
|
|
528
|
+
"outputSha256": "35b4ed6dec77ffcb7850e655a35957da15c14a0fa27b6f3d1d634e243de43456",
|
|
513
529
|
"transform": "verbatim"
|
|
514
530
|
},
|
|
515
531
|
{
|
|
@@ -531,17 +547,17 @@
|
|
|
531
547
|
{
|
|
532
548
|
"source": "package/dist/logger/engine.d.ts",
|
|
533
549
|
"output": "logger/engine.d.ts",
|
|
534
|
-
"bytes":
|
|
535
|
-
"sourceSha256": "
|
|
536
|
-
"outputSha256": "
|
|
550
|
+
"bytes": 4612,
|
|
551
|
+
"sourceSha256": "48e339153dcd7f5389ce9c10e4ad4a06066bcece866d62c70c0fa39f87f0bb1a",
|
|
552
|
+
"outputSha256": "48e339153dcd7f5389ce9c10e4ad4a06066bcece866d62c70c0fa39f87f0bb1a",
|
|
537
553
|
"transform": "verbatim"
|
|
538
554
|
},
|
|
539
555
|
{
|
|
540
556
|
"source": "package/dist/logger/engine.js",
|
|
541
557
|
"output": "logger/engine.js",
|
|
542
|
-
"bytes":
|
|
543
|
-
"sourceSha256": "
|
|
544
|
-
"outputSha256": "
|
|
558
|
+
"bytes": 12539,
|
|
559
|
+
"sourceSha256": "03d858547caa2e6f0e9c36759f11f442dfd6c11a20a6714eae35dea832f1444f",
|
|
560
|
+
"outputSha256": "03d858547caa2e6f0e9c36759f11f442dfd6c11a20a6714eae35dea832f1444f",
|
|
545
561
|
"transform": "verbatim"
|
|
546
562
|
},
|
|
547
563
|
{
|
|
@@ -603,17 +619,17 @@
|
|
|
603
619
|
{
|
|
604
620
|
"source": "package/dist/pi-slot/slot.d.ts",
|
|
605
621
|
"output": "pi-slot/slot.d.ts",
|
|
606
|
-
"bytes":
|
|
607
|
-
"sourceSha256": "
|
|
608
|
-
"outputSha256": "
|
|
622
|
+
"bytes": 2394,
|
|
623
|
+
"sourceSha256": "b92f1590f1f0e4dbbc6331923b9d2cf95e3200936063d5ed192a186f3271eb17",
|
|
624
|
+
"outputSha256": "b92f1590f1f0e4dbbc6331923b9d2cf95e3200936063d5ed192a186f3271eb17",
|
|
609
625
|
"transform": "verbatim"
|
|
610
626
|
},
|
|
611
627
|
{
|
|
612
628
|
"source": "package/dist/pi-slot/slot.js",
|
|
613
629
|
"output": "pi-slot/slot.js",
|
|
614
|
-
"bytes":
|
|
615
|
-
"sourceSha256": "
|
|
616
|
-
"outputSha256": "
|
|
630
|
+
"bytes": 15120,
|
|
631
|
+
"sourceSha256": "13a7d5941b79c6d444cf9dc6f23263cf9237146c7dd5de7d162dbc21e015532c",
|
|
632
|
+
"outputSha256": "13a7d5941b79c6d444cf9dc6f23263cf9237146c7dd5de7d162dbc21e015532c",
|
|
617
633
|
"transform": "verbatim"
|
|
618
634
|
},
|
|
619
635
|
{
|
|
@@ -883,25 +899,25 @@
|
|
|
883
899
|
{
|
|
884
900
|
"source": "package/dist/store/mutate.js",
|
|
885
901
|
"output": "store/mutate.js",
|
|
886
|
-
"bytes":
|
|
887
|
-
"sourceSha256": "
|
|
888
|
-
"outputSha256": "
|
|
902
|
+
"bytes": 19981,
|
|
903
|
+
"sourceSha256": "095842664fb1d805159902223b7765dd4a7349ad1a5bbb5e2c135c654739a434",
|
|
904
|
+
"outputSha256": "095842664fb1d805159902223b7765dd4a7349ad1a5bbb5e2c135c654739a434",
|
|
889
905
|
"transform": "verbatim"
|
|
890
906
|
},
|
|
891
907
|
{
|
|
892
908
|
"source": "package/dist/store/pool.d.ts",
|
|
893
909
|
"output": "store/pool.d.ts",
|
|
894
|
-
"bytes":
|
|
895
|
-
"sourceSha256": "
|
|
896
|
-
"outputSha256": "
|
|
910
|
+
"bytes": 10754,
|
|
911
|
+
"sourceSha256": "901b2881e94f067c6b454002f1e3922b75f248f2a25ef7548c399cafd9611159",
|
|
912
|
+
"outputSha256": "901b2881e94f067c6b454002f1e3922b75f248f2a25ef7548c399cafd9611159",
|
|
897
913
|
"transform": "verbatim"
|
|
898
914
|
},
|
|
899
915
|
{
|
|
900
916
|
"source": "package/dist/store/pool.js",
|
|
901
917
|
"output": "store/pool.js",
|
|
902
|
-
"bytes":
|
|
903
|
-
"sourceSha256": "
|
|
904
|
-
"outputSha256": "
|
|
918
|
+
"bytes": 5713,
|
|
919
|
+
"sourceSha256": "678cca0578ac32eb1d9e45408614c6a7b56a6dcb94672a961c8c13bca55171fd",
|
|
920
|
+
"outputSha256": "678cca0578ac32eb1d9e45408614c6a7b56a6dcb94672a961c8c13bca55171fd",
|
|
905
921
|
"transform": "verbatim"
|
|
906
922
|
},
|
|
907
923
|
{
|
|
@@ -955,17 +971,17 @@
|
|
|
955
971
|
{
|
|
956
972
|
"source": "package/dist/store/refresh-lock.d.ts",
|
|
957
973
|
"output": "store/refresh-lock.d.ts",
|
|
958
|
-
"bytes":
|
|
959
|
-
"sourceSha256": "
|
|
960
|
-
"outputSha256": "
|
|
974
|
+
"bytes": 2442,
|
|
975
|
+
"sourceSha256": "5b4230fad8b94abc23d9b4a9c72cf21d7c961ac6359561a4da28e1e807bcb0ca",
|
|
976
|
+
"outputSha256": "5b4230fad8b94abc23d9b4a9c72cf21d7c961ac6359561a4da28e1e807bcb0ca",
|
|
961
977
|
"transform": "verbatim"
|
|
962
978
|
},
|
|
963
979
|
{
|
|
964
980
|
"source": "package/dist/store/refresh-lock.js",
|
|
965
981
|
"output": "store/refresh-lock.js",
|
|
966
|
-
"bytes":
|
|
967
|
-
"sourceSha256": "
|
|
968
|
-
"outputSha256": "
|
|
982
|
+
"bytes": 4681,
|
|
983
|
+
"sourceSha256": "035a03e02a0690ec51d92df0b61e2ae6abb7b8d6a141112640f8d649eb583949",
|
|
984
|
+
"outputSha256": "035a03e02a0690ec51d92df0b61e2ae6abb7b8d6a141112640f8d649eb583949",
|
|
969
985
|
"transform": "verbatim"
|
|
970
986
|
},
|
|
971
987
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
1
|
import { setTimeout as snapshotDelay } from 'node:timers/promises';
|
|
3
2
|
import { AtomicSyncError, syncJsonFile, writeJsonAtomic, writeJsonAtomicTracked, } from '../fs/atomic-write.js';
|
|
3
|
+
import { readPrivateText, windowsPrivateFiles } from '../fs/private-files.js';
|
|
4
4
|
import { LockContentionError, LockOwnershipError } from '../fs/with-lock.js';
|
|
5
5
|
import { PoolOperationError, } from './errors.js';
|
|
6
6
|
import { callFailureHook } from './hooks.js';
|
|
@@ -10,7 +10,7 @@ import { CREDENTIAL_STAMP_KEY, classifyConfig, classifyState, ensureEntries, ent
|
|
|
10
10
|
import { completeTornRows, loadRows } from './torn.js';
|
|
11
11
|
async function readText(path) {
|
|
12
12
|
try {
|
|
13
|
-
return await
|
|
13
|
+
return await readPrivateText(path, windowsPrivateFiles);
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
16
|
if (error.code === 'ENOENT')
|
|
@@ -66,6 +66,7 @@ export interface OpenPoolStoreOptions {
|
|
|
66
66
|
hold?: (point: HoldPoint, rowId: string) => void | Promise<void>;
|
|
67
67
|
onLockEvent?: LockEnvironment['onLockEvent'];
|
|
68
68
|
onLockStep?: LockEnvironment['onLockStep'];
|
|
69
|
+
onRenewalTimer?: LockEnvironment['onRenewalTimer'];
|
|
69
70
|
}
|
|
70
71
|
export type PoolLoad = {
|
|
71
72
|
status: 'ready';
|
|
@@ -60,6 +60,9 @@ export function openPoolStore(options) {
|
|
|
60
60
|
now: options.now ?? Date.now,
|
|
61
61
|
...(options.onLockEvent ? { onLockEvent: options.onLockEvent } : {}),
|
|
62
62
|
...(options.onLockStep ? { onLockStep: options.onLockStep } : {}),
|
|
63
|
+
...(options.onRenewalTimer
|
|
64
|
+
? { onRenewalTimer: options.onRenewalTimer }
|
|
65
|
+
: {}),
|
|
63
66
|
},
|
|
64
67
|
removedIds: memory.removedIds,
|
|
65
68
|
requireCredentialStamps: options.requireCredentialStamps === true,
|
|
@@ -30,6 +30,10 @@ export interface LockEnvironment {
|
|
|
30
30
|
name: string;
|
|
31
31
|
path: string;
|
|
32
32
|
}, step: LockStep) => void | Promise<void>;
|
|
33
|
+
onRenewalTimer?: (lock: {
|
|
34
|
+
name: string;
|
|
35
|
+
path: string;
|
|
36
|
+
}, event: 'scheduled' | 'cancelled') => void;
|
|
33
37
|
}
|
|
34
38
|
export interface HeldLock {
|
|
35
39
|
readonly name: string;
|
|
@@ -45,6 +45,11 @@ export async function acquirePoolLock(spec, defaults, env) {
|
|
|
45
45
|
now: env.now,
|
|
46
46
|
renew: options.renew,
|
|
47
47
|
onContended: () => emit('contended'),
|
|
48
|
+
...(env.onRenewalTimer
|
|
49
|
+
? {
|
|
50
|
+
onRenewalTimer: (event) => env.onRenewalTimer?.({ name: spec.name, path: spec.path }, event),
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
48
53
|
...(options.renewIntervalMs !== undefined
|
|
49
54
|
? { renewIntervalMs: options.renewIntervalMs }
|
|
50
55
|
: {}),
|