@cortexkit/opencode-antigravity-auth 3.0.31 → 3.0.33
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/cli.js +117 -36
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +168 -58
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +10 -10
- package/dist/server.js +168 -58
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +47 -3
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/dist/src/common-auth-embedded/routing-accessor/index.js +122 -33
- package/dist/src/common-auth-embedded/source-output.json +18 -18
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/package.json +2 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +47 -3
- package/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/src/common-auth-embedded/routing-accessor/index.js +122 -33
- package/src/common-auth-embedded/source-output.json +18 -18
package/dist/cli.js
CHANGED
|
@@ -1677,7 +1677,9 @@ function jsonBytes(bytes) {
|
|
|
1677
1677
|
throw new AccountMigrationError("malformed or non-UTF8 durable JSON");
|
|
1678
1678
|
}
|
|
1679
1679
|
}
|
|
1680
|
-
async function syncFile(path2) {
|
|
1680
|
+
async function syncFile(path2, boundary, role = "recovery-copy") {
|
|
1681
|
+
if (boundary)
|
|
1682
|
+
await boundary(`before-file-sync:${role}`);
|
|
1681
1683
|
await secureRead(path2);
|
|
1682
1684
|
const access = process.platform === "win32" ? constants.O_RDWR : constants.O_RDONLY;
|
|
1683
1685
|
const handle = await open(path2, access | constants.O_NOFOLLOW);
|
|
@@ -1687,6 +1689,8 @@ async function syncFile(path2) {
|
|
|
1687
1689
|
await handle.close();
|
|
1688
1690
|
}
|
|
1689
1691
|
await secureRead(path2);
|
|
1692
|
+
if (boundary)
|
|
1693
|
+
await boundary(`after-file-sync:${role}`);
|
|
1690
1694
|
}
|
|
1691
1695
|
function accountMigrationDurability(platform = process.platform) {
|
|
1692
1696
|
return platform === "win32" ? "windows-reopened-no-directory-power-loss-guarantee" : "posix-directory-synced";
|
|
@@ -1703,7 +1707,9 @@ async function syncDirectory(path2, boundary) {
|
|
|
1703
1707
|
}
|
|
1704
1708
|
await boundary?.("after-directory-sync");
|
|
1705
1709
|
}
|
|
1706
|
-
async function exclusiveBytes(path2, bytes, expectedHash, boundary, pointerStage = false) {
|
|
1710
|
+
async function exclusiveBytes(path2, bytes, expectedHash, boundary, pointerStage = false, role = "recovery-copy") {
|
|
1711
|
+
if (boundary)
|
|
1712
|
+
await boundary(`before-exclusive-write:${role}`);
|
|
1707
1713
|
let handle;
|
|
1708
1714
|
try {
|
|
1709
1715
|
if (windowsPrivateFiles) {
|
|
@@ -1718,7 +1724,11 @@ async function exclusiveBytes(path2, bytes, expectedHash, boundary, pointerStage
|
|
|
1718
1724
|
if (handle !== void 0) {
|
|
1719
1725
|
try {
|
|
1720
1726
|
await handle.writeFile(bytes);
|
|
1727
|
+
if (boundary)
|
|
1728
|
+
await boundary(`before-file-sync:${role}`);
|
|
1721
1729
|
await handle.sync();
|
|
1730
|
+
if (boundary)
|
|
1731
|
+
await boundary(`after-file-sync:${role}`);
|
|
1722
1732
|
} finally {
|
|
1723
1733
|
await handle.close();
|
|
1724
1734
|
}
|
|
@@ -1727,8 +1737,10 @@ async function exclusiveBytes(path2, bytes, expectedHash, boundary, pointerStage
|
|
|
1727
1737
|
if (digest(reopened) !== expectedHash || !reopened.equals(bytes))
|
|
1728
1738
|
throw new AccountMigrationError("exclusive backup or recovery copy differs");
|
|
1729
1739
|
if (handle === void 0 || !pointerStage)
|
|
1730
|
-
await syncFile(path2);
|
|
1740
|
+
await syncFile(path2, boundary, role);
|
|
1731
1741
|
await syncDirectory(dirname2(path2), boundary);
|
|
1742
|
+
if (boundary)
|
|
1743
|
+
await boundary(`after-exclusive-write:${role}`);
|
|
1732
1744
|
}
|
|
1733
1745
|
async function readJournal(paths) {
|
|
1734
1746
|
if (!await exists(paths.storeDir))
|
|
@@ -1745,6 +1757,8 @@ async function readJournal(paths) {
|
|
|
1745
1757
|
return journal;
|
|
1746
1758
|
}
|
|
1747
1759
|
async function saveJournal(modules, paths, lease, journal, initial = false, boundary) {
|
|
1760
|
+
if (boundary)
|
|
1761
|
+
await boundary("before-journal-write");
|
|
1748
1762
|
decodeAccountMigrationJournal(journalJson(journal));
|
|
1749
1763
|
const stage = journal.id;
|
|
1750
1764
|
const journalTemp = `${paths.migrationPath}.${stage}.tmp`;
|
|
@@ -1765,16 +1779,18 @@ async function saveJournal(modules, paths, lease, journal, initial = false, boun
|
|
|
1765
1779
|
const owned = typeof initial === "string" ? current?.id === initial && current.status === "inactive" : initial ? current === void 0 : current?.id === journal.id;
|
|
1766
1780
|
if (!owned)
|
|
1767
1781
|
throw new AccountMigrationError("journal ownership changed before write");
|
|
1768
|
-
await syncFile(`${paths.migrationPath}.${stage}.tmp
|
|
1782
|
+
await syncFile(`${paths.migrationPath}.${stage}.tmp`, boundary, "journal-stage");
|
|
1769
1783
|
await lease.assertOwned();
|
|
1770
1784
|
}
|
|
1771
1785
|
});
|
|
1772
|
-
await syncFile(paths.migrationPath);
|
|
1786
|
+
await syncFile(paths.migrationPath, boundary, "journal");
|
|
1773
1787
|
await syncDirectory(paths.storeDir, boundary);
|
|
1774
1788
|
const reopened = await readJournal(paths);
|
|
1775
1789
|
if (!reopened || !isDeepStrictEqual(journalJson(reopened), journalJson(journal)))
|
|
1776
1790
|
throw new AccountMigrationError("journal readback differs");
|
|
1777
1791
|
await lease.assertOwned();
|
|
1792
|
+
if (boundary)
|
|
1793
|
+
await boundary("after-journal-write");
|
|
1778
1794
|
}
|
|
1779
1795
|
function openMigrationStore(modules, paths, now, onStep) {
|
|
1780
1796
|
return modules.store.openPoolStore({
|
|
@@ -1939,10 +1955,10 @@ function verifyRelocationSnapshot(backup, journal) {
|
|
|
1939
1955
|
throw new AccountMigrationError("moved source snapshot belongs to another generation");
|
|
1940
1956
|
}
|
|
1941
1957
|
async function synchronizedSnapshot(paths, boundary) {
|
|
1942
|
-
await syncFile(paths.configPath);
|
|
1958
|
+
await syncFile(paths.configPath, boundary, "config");
|
|
1943
1959
|
const statePresent = await exists(paths.statePath);
|
|
1944
1960
|
if (statePresent)
|
|
1945
|
-
await syncFile(paths.statePath);
|
|
1961
|
+
await syncFile(paths.statePath, boundary, "state");
|
|
1946
1962
|
await syncDirectory(paths.storeDir, boundary);
|
|
1947
1963
|
return {
|
|
1948
1964
|
config: await secureRead(paths.configPath),
|
|
@@ -2247,7 +2263,7 @@ async function capture(modules, paths, lease, options, previous) {
|
|
|
2247
2263
|
const manifest = parseLegacyAccountStorage(new TextDecoder("utf-8", { fatal: true }).decode(bytes), options.now());
|
|
2248
2264
|
const sourceSha256 = digest(bytes);
|
|
2249
2265
|
await options.onBoundary?.("capture:before-backup");
|
|
2250
|
-
await exclusiveBytes(join2(paths.backupsDir, `${sourceSha256}.json`), bytes, sourceSha256, options.onBoundary);
|
|
2266
|
+
await exclusiveBytes(join2(paths.backupsDir, `${sourceSha256}.json`), bytes, sourceSha256, options.onBoundary, false, "backup");
|
|
2251
2267
|
const journal = {
|
|
2252
2268
|
schemaVersion: 1,
|
|
2253
2269
|
id: pathGenerationId(paths),
|
|
@@ -2268,13 +2284,13 @@ async function capture(modules, paths, lease, options, previous) {
|
|
|
2268
2284
|
const captureBytes = Buffer.from(`${JSON.stringify(captureJson(journal), null, 2)}
|
|
2269
2285
|
`);
|
|
2270
2286
|
journal.captureSha256 = digest(captureBytes);
|
|
2271
|
-
await exclusiveBytes(join2(paths.transfersDir, `${journal.id}.capture.json`), captureBytes, journal.captureSha256, options.onBoundary);
|
|
2287
|
+
await exclusiveBytes(join2(paths.transfersDir, `${journal.id}.capture.json`), captureBytes, journal.captureSha256, options.onBoundary, false, "capture-record");
|
|
2272
2288
|
await accountsLease.assertOwned();
|
|
2273
2289
|
await lease.assertOwned();
|
|
2274
2290
|
if (previous !== void 0) {
|
|
2275
2291
|
const archived = Buffer.from(`${JSON.stringify(journalJson(previous), null, 2)}
|
|
2276
2292
|
`);
|
|
2277
|
-
await exclusiveBytes(join2(paths.transfersDir, `${previous.id}.journal.json`), archived, digest(archived), options.onBoundary);
|
|
2293
|
+
await exclusiveBytes(join2(paths.transfersDir, `${previous.id}.journal.json`), archived, digest(archived), options.onBoundary, false, "archived-journal");
|
|
2278
2294
|
}
|
|
2279
2295
|
await saveJournal(modules, paths, lease, journal, true, options.onBoundary);
|
|
2280
2296
|
return journal;
|
|
@@ -2286,7 +2302,7 @@ async function build(store, modules, paths, lease, journal, options) {
|
|
|
2286
2302
|
await assertStateOwnership(paths, journal, false);
|
|
2287
2303
|
if (!journal.mapping.length && !await exists(paths.configPath)) {
|
|
2288
2304
|
const bootstrap = Buffer.from('{"version":1,"accounts":[]}\n');
|
|
2289
|
-
await exclusiveBytes(paths.configPath, bootstrap, digest(bootstrap), options.onBoundary);
|
|
2305
|
+
await exclusiveBytes(paths.configPath, bootstrap, digest(bootstrap), options.onBoundary, false, "config");
|
|
2290
2306
|
}
|
|
2291
2307
|
await store.initialize();
|
|
2292
2308
|
const known = await rowsOf(store);
|
|
@@ -2494,7 +2510,7 @@ function createAccountMigrationFactory(modules) {
|
|
|
2494
2510
|
return await withParentTopology(modules, options.legacyPath, async (parentLease) => {
|
|
2495
2511
|
const prior = await readPointer(options.legacyPath);
|
|
2496
2512
|
if (prior)
|
|
2497
|
-
await finishPointerPublication(options.legacyPath, prior, parentLease);
|
|
2513
|
+
await finishPointerPublication(options.legacyPath, prior, parentLease, options.onBoundary);
|
|
2498
2514
|
let paths = prior ? generationPaths(options.legacyPath, prior.id) : void 0;
|
|
2499
2515
|
let previous;
|
|
2500
2516
|
if (paths) {
|
|
@@ -2787,13 +2803,13 @@ async function replaceRelocationPointer(modules, anchor, prior, next, id, leases
|
|
|
2787
2803
|
await assertOwned();
|
|
2788
2804
|
if (!isDeepStrictEqual(await readPointerRecord(anchor), prior))
|
|
2789
2805
|
throw new AccountMigrationError("source pointer changed before rename");
|
|
2790
|
-
await syncFile(stage);
|
|
2806
|
+
await syncFile(stage, boundary, "pointer-stage");
|
|
2791
2807
|
await boundary?.(`${prefix}:before-rename`);
|
|
2792
2808
|
}
|
|
2793
2809
|
});
|
|
2794
2810
|
await boundary?.(`${prefix}:after-rename-before-sync`);
|
|
2795
2811
|
}
|
|
2796
|
-
await syncFile(path2);
|
|
2812
|
+
await syncFile(path2, boundary, "pointer");
|
|
2797
2813
|
await syncDirectory(dirname2(anchor));
|
|
2798
2814
|
if (!isDeepStrictEqual(await readPointerRecord(anchor), next))
|
|
2799
2815
|
throw new AccountMigrationError("relocation pointer readback differs");
|
|
@@ -2815,7 +2831,7 @@ function createAccountRelocationFactory(modules) {
|
|
|
2815
2831
|
if (!sourceRecord)
|
|
2816
2832
|
throw new AccountMigrationError("relocation source pointer missing");
|
|
2817
2833
|
if (sourceRecord.schemaVersion === 1)
|
|
2818
|
-
await finishPointerPublication(options.legacyPath, sourceRecord, sourceParent);
|
|
2834
|
+
await finishPointerPublication(options.legacyPath, sourceRecord, sourceParent, options.onBoundary);
|
|
2819
2835
|
const source = generationPaths(options.legacyPath, sourceRecord.id);
|
|
2820
2836
|
if (await exists(source.legacyPath) || await exists(options.targetPath))
|
|
2821
2837
|
throw new AccountMigrationError("relocation refuses a reappeared pool file");
|
|
@@ -2825,7 +2841,7 @@ function createAccountRelocationFactory(modules) {
|
|
|
2825
2841
|
throw new AccountMigrationError("relocation source journal missing");
|
|
2826
2842
|
const prior = await readPointer(options.targetPath);
|
|
2827
2843
|
if (prior)
|
|
2828
|
-
await finishPointerPublication(options.targetPath, prior, targetParent);
|
|
2844
|
+
await finishPointerPublication(options.targetPath, prior, targetParent, options.onBoundary);
|
|
2829
2845
|
let paths = prior ? generationPaths(options.targetPath, prior.id) : void 0;
|
|
2830
2846
|
let existing = paths ? await readJournal(paths) : void 0;
|
|
2831
2847
|
if (prior && (existing?.sourceKind !== "generation" || relocationOf(existing).source.legacyPath !== source.legacyPath || relocationOf(existing).source.journalId !== sourceJournal.id))
|
|
@@ -3115,10 +3131,10 @@ async function reverseRelocation(modules, options, sourceParent, targetParent) {
|
|
|
3115
3131
|
stageName: () => journal.id,
|
|
3116
3132
|
beforeRename: async () => {
|
|
3117
3133
|
await lease.assertOwned();
|
|
3118
|
-
await syncFile(stage);
|
|
3134
|
+
await syncFile(stage, options.onBoundary, "reverse-progress-stage");
|
|
3119
3135
|
}
|
|
3120
3136
|
});
|
|
3121
|
-
await syncFile(progressPath);
|
|
3137
|
+
await syncFile(progressPath, options.onBoundary, "reverse-progress");
|
|
3122
3138
|
await syncDirectory(paths.transfersDir);
|
|
3123
3139
|
if (!isDeepStrictEqual(jsonBytes(await secureRead(progressPath)), record3))
|
|
3124
3140
|
throw new AccountMigrationError("reverse progress readback differs");
|
|
@@ -3157,7 +3173,7 @@ async function reverseRelocation(modules, options, sourceParent, targetParent) {
|
|
|
3157
3173
|
await exclusiveBytes(stage, bytes, digest(bytes), options.onBoundary);
|
|
3158
3174
|
await assertOwned();
|
|
3159
3175
|
await rename2(stage, path2);
|
|
3160
|
-
await syncFile(path2);
|
|
3176
|
+
await syncFile(path2, options.onBoundary, "restored-copy");
|
|
3161
3177
|
await syncDirectory(original.storeDir);
|
|
3162
3178
|
};
|
|
3163
3179
|
if (snapshot2.state !== void 0)
|
|
@@ -3177,7 +3193,7 @@ async function reverseRelocation(modules, options, sourceParent, targetParent) {
|
|
|
3177
3193
|
const originalStore = openMigrationStore(modules, original, options.now, async (step, info) => {
|
|
3178
3194
|
await originalLease.assertOwned();
|
|
3179
3195
|
if (step.startsWith("after-")) {
|
|
3180
|
-
await syncFile(step.includes("config") ? original.configPath : original.statePath);
|
|
3196
|
+
await syncFile(step.includes("config") ? original.configPath : original.statePath, options.onBoundary, step.includes("config") ? "config" : "state");
|
|
3181
3197
|
await syncDirectory(original.storeDir);
|
|
3182
3198
|
}
|
|
3183
3199
|
await options.onBoundary?.(`back:public:${info.operation}:${step}`);
|
|
@@ -3513,7 +3529,7 @@ async function initializeFreshAccountStore(modules, options) {
|
|
|
3513
3529
|
await assertSourceAbsent(resolveAccountStorePaths(options.legacyPath));
|
|
3514
3530
|
const pointer = await readPointer(options.legacyPath);
|
|
3515
3531
|
if (pointer)
|
|
3516
|
-
await finishPointerPublication(options.legacyPath, pointer, parentLease);
|
|
3532
|
+
await finishPointerPublication(options.legacyPath, pointer, parentLease, options.onBoundary);
|
|
3517
3533
|
const physical = pointer ? generationPaths(options.legacyPath, pointer.id) : await allocateGeneration(options.legacyPath);
|
|
3518
3534
|
return modules.fs.withLock(physical.configPath, {
|
|
3519
3535
|
name: MANAGEMENT_LOCK_NAME,
|
|
@@ -3701,9 +3717,9 @@ async function initializePrivateEmptyGeneration(modules, paths, parentLease, man
|
|
|
3701
3717
|
await exclusiveUnpublishedBytes(paths.migrationPath, Buffer.from(`${JSON.stringify(journalJson(journal), null, 2)}
|
|
3702
3718
|
`));
|
|
3703
3719
|
await boundary?.("empty-stage:after-journal");
|
|
3704
|
-
await syncFile(paths.configPath);
|
|
3720
|
+
await syncFile(paths.configPath, boundary, "config");
|
|
3705
3721
|
await boundary?.("empty-stage:after-config-sync");
|
|
3706
|
-
await syncFile(paths.migrationPath);
|
|
3722
|
+
await syncFile(paths.migrationPath, boundary, "journal");
|
|
3707
3723
|
await boundary?.("empty-stage:after-journal-sync");
|
|
3708
3724
|
for (const [name, path3] of [
|
|
3709
3725
|
["backups", paths.backupsDir],
|
|
@@ -3739,7 +3755,11 @@ async function initializePrivateEmptyGeneration(modules, paths, parentLease, man
|
|
|
3739
3755
|
if (stageHandle) {
|
|
3740
3756
|
try {
|
|
3741
3757
|
await stageHandle.writeFile(bytes);
|
|
3758
|
+
if (boundary)
|
|
3759
|
+
await boundary("before-file-sync:pointer-stage");
|
|
3742
3760
|
await stageHandle.sync();
|
|
3761
|
+
if (boundary)
|
|
3762
|
+
await boundary("after-file-sync:pointer-stage");
|
|
3743
3763
|
} finally {
|
|
3744
3764
|
await stageHandle.close();
|
|
3745
3765
|
}
|
|
@@ -3747,7 +3767,7 @@ async function initializePrivateEmptyGeneration(modules, paths, parentLease, man
|
|
|
3747
3767
|
if (!(await secureRead(stage)).equals(bytes))
|
|
3748
3768
|
throw new AccountMigrationError("exclusive pointer stage differs");
|
|
3749
3769
|
if (!stageHandle)
|
|
3750
|
-
await syncFile(stage);
|
|
3770
|
+
await syncFile(stage, boundary, "pointer-stage");
|
|
3751
3771
|
await boundary?.("empty-stage:after-pointer-stage");
|
|
3752
3772
|
await syncDirectory(dirname2(path2));
|
|
3753
3773
|
await boundary?.("empty-stage:after-parent-prelink-sync");
|
|
@@ -3800,7 +3820,7 @@ async function publishGenerationPointer(modules, paths, journal, parentLease, ma
|
|
|
3800
3820
|
if (!currentJournal || currentJournal.id !== journal.id || !isDeepStrictEqual(journalJson(currentJournal), journalJson(journal)))
|
|
3801
3821
|
throw new AccountMigrationError("publication requires its complete synced canonical journal");
|
|
3802
3822
|
if (journalSavedBy !== managementLease) {
|
|
3803
|
-
await syncFile(paths.migrationPath);
|
|
3823
|
+
await syncFile(paths.migrationPath, boundary, "journal");
|
|
3804
3824
|
await syncDirectory(paths.storeDir);
|
|
3805
3825
|
}
|
|
3806
3826
|
const pointer = {
|
|
@@ -3813,7 +3833,7 @@ async function publishGenerationPointer(modules, paths, journal, parentLease, ma
|
|
|
3813
3833
|
const stage = `${path2}.${journal.id}.tmp`;
|
|
3814
3834
|
const bytes = Buffer.from(`${JSON.stringify(pointer, null, 2)}
|
|
3815
3835
|
`);
|
|
3816
|
-
await exclusiveBytes(stage, bytes, digest(bytes),
|
|
3836
|
+
await exclusiveBytes(stage, bytes, digest(bytes), boundary, true, "pointer-stage");
|
|
3817
3837
|
await parentLease.assertOwned();
|
|
3818
3838
|
await managementLease.assertOwned();
|
|
3819
3839
|
await boundary?.("pointer:before-link");
|
|
@@ -3857,10 +3877,10 @@ async function publishGenerationPointer(modules, paths, journal, parentLease, ma
|
|
|
3857
3877
|
await managementLease.assertOwned();
|
|
3858
3878
|
if (!isDeepStrictEqual(await readPointer(paths.legacyPath), prior) || (reversed ? !isDeepStrictEqual(await readJournal(oldPaths), oldJournal) : (await readJournal(oldPaths))?.status !== "inactive"))
|
|
3859
3879
|
throw new AccountMigrationError("inactive pointer changed before transition");
|
|
3860
|
-
await syncFile(`${path2}.${stageName}.tmp
|
|
3880
|
+
await syncFile(`${path2}.${stageName}.tmp`, boundary, "pointer-stage");
|
|
3861
3881
|
}
|
|
3862
3882
|
});
|
|
3863
|
-
await syncFile(path2);
|
|
3883
|
+
await syncFile(path2, boundary, "pointer");
|
|
3864
3884
|
await syncDirectory(dirname2(path2));
|
|
3865
3885
|
}
|
|
3866
3886
|
await parentLease.assertOwned();
|
|
@@ -3879,7 +3899,7 @@ function writeObserver(paths, lease, boundary) {
|
|
|
3879
3899
|
await lease.assertOwned();
|
|
3880
3900
|
await assertPublishedAccountStoreGeneration(paths);
|
|
3881
3901
|
if (step.startsWith("after-")) {
|
|
3882
|
-
await syncFile(step.includes("config") ? paths.configPath : paths.statePath);
|
|
3902
|
+
await syncFile(step.includes("config") ? paths.configPath : paths.statePath, boundary, step.includes("config") ? "config" : "state");
|
|
3883
3903
|
await syncDirectory(paths.storeDir, boundary);
|
|
3884
3904
|
}
|
|
3885
3905
|
await boundary?.(`public:${info.operation}:${step}`);
|
|
@@ -3887,9 +3907,9 @@ function writeObserver(paths, lease, boundary) {
|
|
|
3887
3907
|
await assertPublishedAccountStoreGeneration(paths);
|
|
3888
3908
|
};
|
|
3889
3909
|
}
|
|
3890
|
-
async function finishPointerPublication(legacyPath, pointer, lease) {
|
|
3910
|
+
async function finishPointerPublication(legacyPath, pointer, lease, boundary) {
|
|
3891
3911
|
const path2 = accountStorePointerPath(legacyPath);
|
|
3892
|
-
await syncFile(path2);
|
|
3912
|
+
await syncFile(path2, boundary, "pointer");
|
|
3893
3913
|
await syncDirectory(dirname2(path2));
|
|
3894
3914
|
if (await cleanupPointerStage(legacyPath, pointer, lease))
|
|
3895
3915
|
await syncDirectory(dirname2(path2));
|
|
@@ -8693,9 +8713,37 @@ var init_atomic_write2 = __esm({
|
|
|
8693
8713
|
|
|
8694
8714
|
// ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
|
|
8695
8715
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
8696
|
-
import { lstat as lstat3, mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3 } from "node:fs/promises";
|
|
8716
|
+
import { link as link2, lstat as lstat3, mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3 } from "node:fs/promises";
|
|
8697
8717
|
import { dirname as dirname7, join as join5 } from "node:path";
|
|
8698
8718
|
async function createExclusiveText(path2, text2) {
|
|
8719
|
+
const tempPath = `${path2}.${randomUUID7()}.tmp`;
|
|
8720
|
+
let handle;
|
|
8721
|
+
try {
|
|
8722
|
+
handle = await open4(tempPath, "wx", 384);
|
|
8723
|
+
try {
|
|
8724
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
8725
|
+
await leaseCreationTestHooks.beforeWrite(tempPath);
|
|
8726
|
+
await handle.writeFile(text2, "utf8");
|
|
8727
|
+
} finally {
|
|
8728
|
+
await handle.close();
|
|
8729
|
+
}
|
|
8730
|
+
try {
|
|
8731
|
+
if (leaseCreationTestHooks?.beforeLink)
|
|
8732
|
+
await leaseCreationTestHooks.beforeLink(tempPath, path2);
|
|
8733
|
+
await link2(tempPath, path2);
|
|
8734
|
+
} catch (error) {
|
|
8735
|
+
const code2 = error.code;
|
|
8736
|
+
if (code2 !== "EPERM" && code2 !== "ENOTSUP" && code2 !== "EOPNOTSUPP" && code2 !== "EXDEV")
|
|
8737
|
+
throw error;
|
|
8738
|
+
await writeExclusiveText(path2, text2);
|
|
8739
|
+
}
|
|
8740
|
+
} finally {
|
|
8741
|
+
if (handle)
|
|
8742
|
+
await rm4(tempPath, { force: true }).catch(() => {
|
|
8743
|
+
});
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8746
|
+
async function writeExclusiveText(path2, text2) {
|
|
8699
8747
|
const handle = await open4(path2, "wx", 384);
|
|
8700
8748
|
let createdStat;
|
|
8701
8749
|
try {
|
|
@@ -8704,6 +8752,8 @@ async function createExclusiveText(path2, text2) {
|
|
|
8704
8752
|
createdStat = void 0;
|
|
8705
8753
|
}
|
|
8706
8754
|
try {
|
|
8755
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
8756
|
+
await leaseCreationTestHooks.beforeWrite(path2);
|
|
8707
8757
|
await handle.writeFile(text2, "utf8");
|
|
8708
8758
|
} catch (error) {
|
|
8709
8759
|
try {
|
|
@@ -9074,7 +9124,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9074
9124
|
if (windowsPrivateFiles)
|
|
9075
9125
|
await createPrivateBytes(evictOwnerPath, bytes);
|
|
9076
9126
|
else
|
|
9077
|
-
await
|
|
9127
|
+
await writeExclusiveText(evictOwnerPath, bytes);
|
|
9078
9128
|
} catch (error) {
|
|
9079
9129
|
const stillOurs = await removeOwnMarkerAfterFailedOwnerWrite(created, deadline);
|
|
9080
9130
|
if (isLostMarkerRaceError(error) && !stillOurs)
|
|
@@ -9479,7 +9529,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9479
9529
|
}
|
|
9480
9530
|
};
|
|
9481
9531
|
}
|
|
9482
|
-
var setRefreshLockRenewalTimeout, clearRefreshLockRenewalTimeout, evictionMarkerTestHooks, OWNERLESS_MARKER_GRACE_MS;
|
|
9532
|
+
var leaseCreationTestHooks, setRefreshLockRenewalTimeout, clearRefreshLockRenewalTimeout, evictionMarkerTestHooks, OWNERLESS_MARKER_GRACE_MS;
|
|
9483
9533
|
var init_refresh_file_lock = __esm({
|
|
9484
9534
|
"../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
|
|
9485
9535
|
"use strict";
|
|
@@ -28278,7 +28328,7 @@ init_private_files2();
|
|
|
28278
28328
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
28279
28329
|
init_private_files2();
|
|
28280
28330
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
28281
|
-
import { lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat12 } from "node:fs/promises";
|
|
28331
|
+
import { link as link3, lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat12 } from "node:fs/promises";
|
|
28282
28332
|
import { dirname as dirname18, join as join17 } from "node:path";
|
|
28283
28333
|
|
|
28284
28334
|
// src/common-auth-embedded/fs/with-lock.js
|
|
@@ -28296,7 +28346,36 @@ var LockOwnershipError2 = class extends Error {
|
|
|
28296
28346
|
};
|
|
28297
28347
|
|
|
28298
28348
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
28349
|
+
var leaseCreationTestHooks2;
|
|
28299
28350
|
async function createExclusiveText2(path2, text2) {
|
|
28351
|
+
const tempPath = `${path2}.${randomUUID14()}.tmp`;
|
|
28352
|
+
let handle;
|
|
28353
|
+
try {
|
|
28354
|
+
handle = await open9(tempPath, "wx", 384);
|
|
28355
|
+
try {
|
|
28356
|
+
if (leaseCreationTestHooks2?.beforeWrite)
|
|
28357
|
+
await leaseCreationTestHooks2.beforeWrite(tempPath);
|
|
28358
|
+
await handle.writeFile(text2, "utf8");
|
|
28359
|
+
} finally {
|
|
28360
|
+
await handle.close();
|
|
28361
|
+
}
|
|
28362
|
+
try {
|
|
28363
|
+
if (leaseCreationTestHooks2?.beforeLink)
|
|
28364
|
+
await leaseCreationTestHooks2.beforeLink(tempPath, path2);
|
|
28365
|
+
await link3(tempPath, path2);
|
|
28366
|
+
} catch (error) {
|
|
28367
|
+
const code2 = error.code;
|
|
28368
|
+
if (code2 !== "EPERM" && code2 !== "ENOTSUP" && code2 !== "EOPNOTSUPP" && code2 !== "EXDEV")
|
|
28369
|
+
throw error;
|
|
28370
|
+
await writeExclusiveText2(path2, text2);
|
|
28371
|
+
}
|
|
28372
|
+
} finally {
|
|
28373
|
+
if (handle)
|
|
28374
|
+
await rm6(tempPath, { force: true }).catch(() => {
|
|
28375
|
+
});
|
|
28376
|
+
}
|
|
28377
|
+
}
|
|
28378
|
+
async function writeExclusiveText2(path2, text2) {
|
|
28300
28379
|
const handle = await open9(path2, "wx", 384);
|
|
28301
28380
|
let createdStat;
|
|
28302
28381
|
try {
|
|
@@ -28305,6 +28384,8 @@ async function createExclusiveText2(path2, text2) {
|
|
|
28305
28384
|
createdStat = void 0;
|
|
28306
28385
|
}
|
|
28307
28386
|
try {
|
|
28387
|
+
if (leaseCreationTestHooks2?.beforeWrite)
|
|
28388
|
+
await leaseCreationTestHooks2.beforeWrite(path2);
|
|
28308
28389
|
await handle.writeFile(text2, "utf8");
|
|
28309
28390
|
} catch (error) {
|
|
28310
28391
|
try {
|
|
@@ -28679,7 +28760,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28679
28760
|
if (windowsPrivateFiles2)
|
|
28680
28761
|
await createPrivateBytes2(evictOwnerPath, bytes);
|
|
28681
28762
|
else
|
|
28682
|
-
await
|
|
28763
|
+
await writeExclusiveText2(evictOwnerPath, bytes);
|
|
28683
28764
|
} catch (error) {
|
|
28684
28765
|
const stillOurs = await removeOwnMarkerAfterFailedOwnerWrite(created, deadline);
|
|
28685
28766
|
if (isLostMarkerRaceError2(error) && !stillOurs)
|