@cortexkit/opencode-antigravity-auth 3.0.15 → 3.0.16
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 +257 -57
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +257 -57
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +8 -8
- package/dist/server.js +257 -57
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/storage.d.ts +17 -0
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +44 -10
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/runtime-paths.d.ts +2 -1
- package/dist/src/runtime-paths.d.ts.map +1 -1
- package/dist/src/runtime-paths.js +5 -5
- package/dist/src/runtime-paths.js.map +1 -1
- package/dist/types/src/plugin/storage.d.ts +17 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -1
- package/dist/types/src/runtime-paths.d.ts +2 -1
- package/dist/types/src/runtime-paths.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.meta.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"format": "esm"
|
|
28
28
|
},
|
|
29
29
|
"../core/dist/account-migration.js": {
|
|
30
|
-
"bytes":
|
|
30
|
+
"bytes": 138752,
|
|
31
31
|
"imports": [
|
|
32
32
|
{
|
|
33
33
|
"path": "node:crypto",
|
|
@@ -2917,7 +2917,7 @@
|
|
|
2917
2917
|
"format": "esm"
|
|
2918
2918
|
},
|
|
2919
2919
|
"src/plugin/storage.ts": {
|
|
2920
|
-
"bytes":
|
|
2920
|
+
"bytes": 25208,
|
|
2921
2921
|
"imports": [
|
|
2922
2922
|
{
|
|
2923
2923
|
"path": "node:fs",
|
|
@@ -2969,7 +2969,7 @@
|
|
|
2969
2969
|
"format": "esm"
|
|
2970
2970
|
},
|
|
2971
2971
|
"src/runtime-paths.ts": {
|
|
2972
|
-
"bytes":
|
|
2972
|
+
"bytes": 10719,
|
|
2973
2973
|
"imports": [
|
|
2974
2974
|
{
|
|
2975
2975
|
"path": "node:crypto",
|
|
@@ -4265,7 +4265,7 @@
|
|
|
4265
4265
|
"imports": [],
|
|
4266
4266
|
"exports": [],
|
|
4267
4267
|
"inputs": {},
|
|
4268
|
-
"bytes":
|
|
4268
|
+
"bytes": 2714464
|
|
4269
4269
|
},
|
|
4270
4270
|
"dist/cli.js": {
|
|
4271
4271
|
"imports": [
|
|
@@ -5267,7 +5267,7 @@
|
|
|
5267
5267
|
"bytesInOutput": 73008
|
|
5268
5268
|
},
|
|
5269
5269
|
"../core/dist/account-migration.js": {
|
|
5270
|
-
"bytesInOutput":
|
|
5270
|
+
"bytesInOutput": 113447
|
|
5271
5271
|
},
|
|
5272
5272
|
"../core/dist/account-repository-types.js": {
|
|
5273
5273
|
"bytesInOutput": 1238
|
|
@@ -5372,10 +5372,10 @@
|
|
|
5372
5372
|
"bytesInOutput": 13872
|
|
5373
5373
|
},
|
|
5374
5374
|
"src/runtime-paths.ts": {
|
|
5375
|
-
"bytesInOutput":
|
|
5375
|
+
"bytesInOutput": 3684
|
|
5376
5376
|
},
|
|
5377
5377
|
"src/plugin/storage.ts": {
|
|
5378
|
-
"bytesInOutput":
|
|
5378
|
+
"bytesInOutput": 8633
|
|
5379
5379
|
},
|
|
5380
5380
|
"src/version-fence.ts": {
|
|
5381
5381
|
"bytesInOutput": 5982
|
|
@@ -5510,7 +5510,7 @@
|
|
|
5510
5510
|
"bytesInOutput": 1771
|
|
5511
5511
|
}
|
|
5512
5512
|
},
|
|
5513
|
-
"bytes":
|
|
5513
|
+
"bytes": 1087195
|
|
5514
5514
|
}
|
|
5515
5515
|
}
|
|
5516
5516
|
}
|
package/dist/index.js
CHANGED
|
@@ -14635,14 +14635,52 @@ function decodeAccountStorePointer(value, legacyPath) {
|
|
|
14635
14635
|
throw new AccountMigrationError("pointer directory basename differs from its derived generation");
|
|
14636
14636
|
return { schemaVersion: 1, id, directoryBasename: basename(paths.storeDir) };
|
|
14637
14637
|
}
|
|
14638
|
-
|
|
14638
|
+
function decodeAccountStorePointerRecord(value, legacyPath) {
|
|
14639
|
+
if (object(value, "pointer").schemaVersion !== 2)
|
|
14640
|
+
return decodeAccountStorePointer(value, legacyPath);
|
|
14641
|
+
const raw = exact(value, ["schemaVersion", "id", "directoryBasename", "relocatedTo"], "forward");
|
|
14642
|
+
const id = text(raw.id, UUID, "forward source generation");
|
|
14643
|
+
const paths = generationPaths(legacyPath, id);
|
|
14644
|
+
if (raw.directoryBasename !== basename(paths.storeDir))
|
|
14645
|
+
throw new AccountMigrationError("forward directory basename differs from its derived generation");
|
|
14646
|
+
const target = exact(raw.relocatedTo, ["legacyPath", "id"], "forward target");
|
|
14647
|
+
if (typeof target.legacyPath !== "string")
|
|
14648
|
+
throw new AccountMigrationError("forward target path is invalid");
|
|
14649
|
+
const targetId = text(target.id, UUID, "forward target generation");
|
|
14650
|
+
const targetPaths = generationPaths(target.legacyPath, targetId);
|
|
14651
|
+
if (sameFilesystemPath(targetPaths.legacyPath, legacyPath))
|
|
14652
|
+
throw new AccountMigrationError("forward names its own anchor");
|
|
14653
|
+
return {
|
|
14654
|
+
schemaVersion: 2,
|
|
14655
|
+
id,
|
|
14656
|
+
directoryBasename: basename(paths.storeDir),
|
|
14657
|
+
relocatedTo: {
|
|
14658
|
+
legacyPath: targetPaths.legacyPath,
|
|
14659
|
+
id: targetId
|
|
14660
|
+
}
|
|
14661
|
+
};
|
|
14662
|
+
}
|
|
14663
|
+
async function readPointerRecord(legacyPath) {
|
|
14639
14664
|
const logical = resolveAccountStorePaths(legacyPath);
|
|
14640
14665
|
if (await exists(logical.storeDir))
|
|
14641
14666
|
throw new AccountMigrationError("foreign logical store directory is not pointer authority");
|
|
14642
14667
|
const path5 = accountStorePointerPath(legacyPath);
|
|
14643
14668
|
if (!await exists(path5))
|
|
14644
14669
|
return void 0;
|
|
14645
|
-
return
|
|
14670
|
+
return decodeAccountStorePointerRecord(jsonBytes(await secureRead(path5)), legacyPath);
|
|
14671
|
+
}
|
|
14672
|
+
async function readPointer(legacyPath) {
|
|
14673
|
+
const record3 = await readPointerRecord(legacyPath);
|
|
14674
|
+
if (record3?.schemaVersion === 2)
|
|
14675
|
+
throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; this operation does not follow a moved store`);
|
|
14676
|
+
return record3;
|
|
14677
|
+
}
|
|
14678
|
+
async function forwardTarget(legacyPath, forward) {
|
|
14679
|
+
const target = forward.relocatedTo.legacyPath;
|
|
14680
|
+
const published = await readPointerRecord(target);
|
|
14681
|
+
if (published?.schemaVersion !== 1 || published.id !== forward.relocatedTo.id)
|
|
14682
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(legacyPath)} names generation ${forward.relocatedTo.id}, which ${accountStorePointerPath(target)} does not publish`);
|
|
14683
|
+
return target;
|
|
14646
14684
|
}
|
|
14647
14685
|
async function resolvePublishedAccountStorePaths(legacyPath) {
|
|
14648
14686
|
const pointer = await readPointer(legacyPath);
|
|
@@ -14898,7 +14936,7 @@ function decodeAccountStoreGeneration(value) {
|
|
|
14898
14936
|
"sourceKind",
|
|
14899
14937
|
"initialManifestSha256"
|
|
14900
14938
|
], "generation");
|
|
14901
|
-
if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent")
|
|
14939
|
+
if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent" && raw.sourceKind !== "generation")
|
|
14902
14940
|
throw new AccountMigrationError("generation schema is invalid");
|
|
14903
14941
|
const id = text(raw.id, UUID, "generation id");
|
|
14904
14942
|
const paths = generationPaths(raw.legacyPath, id);
|
|
@@ -14997,7 +15035,8 @@ function decodeAccountMigrationJournal(value) {
|
|
|
14997
15035
|
"verification",
|
|
14998
15036
|
"retiredSha256",
|
|
14999
15037
|
"rollback",
|
|
15000
|
-
"cancelled"
|
|
15038
|
+
"cancelled",
|
|
15039
|
+
"relocation"
|
|
15001
15040
|
], "journal");
|
|
15002
15041
|
if (raw.schemaVersion !== 1)
|
|
15003
15042
|
throw new AccountMigrationError("unsupported journal schema");
|
|
@@ -15017,10 +15056,10 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15017
15056
|
if (phase === void 0)
|
|
15018
15057
|
throw new AccountMigrationError("journal phase is invalid");
|
|
15019
15058
|
const sourceKind = raw.sourceKind;
|
|
15020
|
-
if (sourceKind !== "file" && sourceKind !== "absent")
|
|
15059
|
+
if (sourceKind !== "file" && sourceKind !== "absent" && sourceKind !== "generation")
|
|
15021
15060
|
throw new AccountMigrationError("journal source kind is invalid");
|
|
15022
|
-
const sourceSha256 = sourceKind
|
|
15023
|
-
const captureSha256 = sourceKind
|
|
15061
|
+
const sourceSha256 = sourceKind !== "absent" ? text(raw.sourceSha256, SHA256, "journal.sourceSha256") : void 0;
|
|
15062
|
+
const captureSha256 = sourceKind !== "absent" ? text(raw.captureSha256, SHA256, "journal.captureSha256") : void 0;
|
|
15024
15063
|
if (sourceKind === "absent" && Object.hasOwn(raw, "captureSha256"))
|
|
15025
15064
|
throw new AccountMigrationError("absent source cannot claim a captured file snapshot");
|
|
15026
15065
|
if (sourceKind === "absent" && Object.hasOwn(raw, "sourceSha256"))
|
|
@@ -15037,7 +15076,7 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15037
15076
|
const sourceVersion = m.sourceVersion;
|
|
15038
15077
|
if (sourceVersion !== null && sourceVersion !== 1 && sourceVersion !== 2 && sourceVersion !== 3 && sourceVersion !== 4)
|
|
15039
15078
|
throw new AccountMigrationError("manifest source version is invalid");
|
|
15040
|
-
if (sourceKind === "file" && sourceVersion === null || sourceKind
|
|
15079
|
+
if (sourceKind === "file" && sourceVersion === null || sourceKind !== "file" && sourceVersion !== null)
|
|
15041
15080
|
throw new AccountMigrationError("manifest version differs from source kind");
|
|
15042
15081
|
if (!finite(m.normalizationClock) || !finite(m.effectiveActiveIndex))
|
|
15043
15082
|
throw new AccountMigrationError("manifest clock or cursor is invalid");
|
|
@@ -15067,6 +15106,10 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15067
15106
|
schemaVersion: 1
|
|
15068
15107
|
}) || manifest.effectiveActiveIndex !== 0))
|
|
15069
15108
|
throw new AccountMigrationError("absent-source manifest must be explicitly empty with no invented cursors");
|
|
15109
|
+
if (sourceKind === "generation" && (accounts.length || !isDeepStrictEqual(encodeRoutingSettings(manifest.routing), {
|
|
15110
|
+
schemaVersion: 1
|
|
15111
|
+
}) || manifest.effectiveActiveIndex !== 0))
|
|
15112
|
+
throw new AccountMigrationError("moved-store manifest must be explicitly empty");
|
|
15070
15113
|
const effective = accounts.length ? Math.max(0, Math.min(manifest.routing.activeIndex ?? 0, accounts.length - 1)) : 0;
|
|
15071
15114
|
if (effective !== manifest.effectiveActiveIndex)
|
|
15072
15115
|
throw new AccountMigrationError("manifest effective cursor differs");
|
|
@@ -15114,6 +15157,24 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15114
15157
|
throw new AccountMigrationError("absent source cannot claim retired bytes");
|
|
15115
15158
|
if (retiredSha256 !== void 0 && retiredSha256 !== sourceSha256)
|
|
15116
15159
|
throw new AccountMigrationError("retired bytes are not associated with source");
|
|
15160
|
+
const relocation = decodeRelocation(raw, sourceKind, paths.legacyPath);
|
|
15161
|
+
if (sourceKind === "generation") {
|
|
15162
|
+
if (retiredSha256 !== void 0)
|
|
15163
|
+
throw new AccountMigrationError("moved source cannot claim retired pool-file bytes");
|
|
15164
|
+
if (relocation === void 0)
|
|
15165
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15166
|
+
if (operation === "rollback")
|
|
15167
|
+
throw new AccountMigrationError("a moved account store is not rolled back; move it back first with `antigravity-auth store relocate --back --offline`");
|
|
15168
|
+
if (relocation.sourceForwarded && !relocation.sourceTombstoned)
|
|
15169
|
+
throw new AccountMigrationError("source forward precedes its management tombstone");
|
|
15170
|
+
if ((relocation.sourceTombstoned || relocation.sourceForwarded) && (!verification || phase !== "retire" && phase !== "activate"))
|
|
15171
|
+
throw new AccountMigrationError("source tombstone or forward precedes durable verification");
|
|
15172
|
+
if (status === "active" && !relocation.sourceForwarded)
|
|
15173
|
+
throw new AccountMigrationError("active moved store lacks its source forward");
|
|
15174
|
+
if (phase === "activate" && !relocation.sourceForwarded)
|
|
15175
|
+
throw new AccountMigrationError("moved-store activation lacks its source forward");
|
|
15176
|
+
}
|
|
15177
|
+
const retirementRecorded = sourceKind === "file" ? retiredSha256 !== void 0 : sourceKind === "absent" ? raw.sourceAbsenceVerified === true : relocation?.sourceForwarded === true;
|
|
15117
15178
|
let rollback;
|
|
15118
15179
|
if (Object.hasOwn(raw, "rollback")) {
|
|
15119
15180
|
const r = exact(raw.rollback, ["id", "snapshotSha256", "exportSha256", "rows", "successorInactive"], "rollback");
|
|
@@ -15139,13 +15200,13 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15139
15200
|
throw new AccountMigrationError("verification acknowledged an incomplete import");
|
|
15140
15201
|
if (operation === "migrate" && (retiredSha256 !== void 0 || raw.sourceAbsenceVerified === true) && (!verification || phase !== "retire" && phase !== "activate"))
|
|
15141
15202
|
throw new AccountMigrationError("retirement association precedes durable verification");
|
|
15142
|
-
if (operation === "migrate" && phase === "activate" &&
|
|
15203
|
+
if (operation === "migrate" && phase === "activate" && !retirementRecorded)
|
|
15143
15204
|
throw new AccountMigrationError("activation lacks its actual source retirement association");
|
|
15144
|
-
if (status === "active" && (operation !== "migrate" || phase !== "activate" ||
|
|
15205
|
+
if (status === "active" && (operation !== "migrate" || phase !== "activate" || !retirementRecorded || rollback !== void 0 || cancelled))
|
|
15145
15206
|
throw new AccountMigrationError("active receipt is incomplete");
|
|
15146
15207
|
if (operation === "rollback" && rollback === void 0 && !cancelled)
|
|
15147
15208
|
throw new AccountMigrationError("rollback lacks its current-credential snapshot");
|
|
15148
|
-
if (operation === "rollback" && !cancelled && (verification === void 0 ||
|
|
15209
|
+
if (operation === "rollback" && !cancelled && (verification === void 0 || !retirementRecorded))
|
|
15149
15210
|
throw new AccountMigrationError("rollback lacks the original verified retirement");
|
|
15150
15211
|
if (status === "inactive" && !cancelled && (operation !== "rollback" || phase !== "activate" || rollback === void 0))
|
|
15151
15212
|
throw new AccountMigrationError("inactive receipt lacks a completed rollback");
|
|
@@ -15169,7 +15230,53 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15169
15230
|
...verification === void 0 ? {} : { verification },
|
|
15170
15231
|
...retiredSha256 === void 0 ? {} : { retiredSha256 },
|
|
15171
15232
|
...rollback === void 0 ? {} : { rollback },
|
|
15172
|
-
...cancelled ? { cancelled: true } : {}
|
|
15233
|
+
...cancelled ? { cancelled: true } : {},
|
|
15234
|
+
...relocation === void 0 ? {} : { relocation }
|
|
15235
|
+
};
|
|
15236
|
+
}
|
|
15237
|
+
function decodeRelocation(raw, sourceKind, legacyPath) {
|
|
15238
|
+
if (!Object.hasOwn(raw, "relocation"))
|
|
15239
|
+
return void 0;
|
|
15240
|
+
if (sourceKind !== "generation")
|
|
15241
|
+
throw new AccountMigrationError("only a moved store records relocation evidence");
|
|
15242
|
+
const r = exact(raw.relocation, ["source", "rows", "sourceTombstoned", "sourceForwarded"], "relocation");
|
|
15243
|
+
const s = exact(r.source, [
|
|
15244
|
+
"legacyPath",
|
|
15245
|
+
"storeDir",
|
|
15246
|
+
"journalId",
|
|
15247
|
+
"configSha256",
|
|
15248
|
+
"stateSha256",
|
|
15249
|
+
"statePresent"
|
|
15250
|
+
], "relocation source");
|
|
15251
|
+
if (typeof s.legacyPath !== "string")
|
|
15252
|
+
throw new AccountMigrationError("relocation source path is invalid");
|
|
15253
|
+
const journalId = text(s.journalId, UUID, "relocation source journal");
|
|
15254
|
+
const source = generationPaths(s.legacyPath, journalId);
|
|
15255
|
+
if (s.storeDir !== source.storeDir)
|
|
15256
|
+
throw new AccountMigrationError("relocation source association differs");
|
|
15257
|
+
if (sameFilesystemPath(source.legacyPath, legacyPath))
|
|
15258
|
+
throw new AccountMigrationError("relocation source and target share one anchor");
|
|
15259
|
+
if (typeof s.statePresent !== "boolean")
|
|
15260
|
+
throw new AccountMigrationError("relocation state presence is invalid");
|
|
15261
|
+
if (!s.statePresent && Object.hasOwn(s, "stateSha256"))
|
|
15262
|
+
throw new AccountMigrationError("absent source state cannot claim a file hash");
|
|
15263
|
+
const rows = list(r.rows, "relocation rows").map((id) => text(id, UUID, "relocation row id"));
|
|
15264
|
+
if (new Set(rows).size !== rows.length)
|
|
15265
|
+
throw new AccountMigrationError("relocation rows are duplicated");
|
|
15266
|
+
if (typeof r.sourceTombstoned !== "boolean" || typeof r.sourceForwarded !== "boolean")
|
|
15267
|
+
throw new AccountMigrationError("relocation progress flags are invalid");
|
|
15268
|
+
return {
|
|
15269
|
+
source: {
|
|
15270
|
+
legacyPath: source.legacyPath,
|
|
15271
|
+
storeDir: source.storeDir,
|
|
15272
|
+
journalId,
|
|
15273
|
+
configSha256: text(s.configSha256, SHA256, "relocation config hash"),
|
|
15274
|
+
...s.statePresent ? { stateSha256: text(s.stateSha256, SHA256, "relocation state hash") } : {},
|
|
15275
|
+
statePresent: s.statePresent
|
|
15276
|
+
},
|
|
15277
|
+
rows,
|
|
15278
|
+
sourceTombstoned: r.sourceTombstoned,
|
|
15279
|
+
sourceForwarded: r.sourceForwarded
|
|
15173
15280
|
};
|
|
15174
15281
|
}
|
|
15175
15282
|
function pendingLockFailure(modules, error) {
|
|
@@ -15459,6 +15566,8 @@ async function verifyCopies(paths, journal, retired) {
|
|
|
15459
15566
|
const capture2 = await secureRead(join(paths.transfersDir, `${journal.id}.capture.json`));
|
|
15460
15567
|
if (digest(capture2) !== journal.captureSha256 || !isDeepStrictEqual(jsonBytes(capture2), captureJson(journal)))
|
|
15461
15568
|
throw new AccountMigrationError("journal differs from its exclusive capture snapshot");
|
|
15569
|
+
if (journal.sourceKind === "generation")
|
|
15570
|
+
return verifyRelocationSnapshot(backup, journal);
|
|
15462
15571
|
const expected = parseLegacyAccountStorage(new TextDecoder("utf-8", { fatal: true }).decode(backup), journal.manifest.normalizationClock);
|
|
15463
15572
|
if (!isDeepStrictEqual(manifestJson(expected), manifestJson(journal.manifest)))
|
|
15464
15573
|
throw new AccountMigrationError("captured manifest differs from its verified original source");
|
|
@@ -15477,9 +15586,40 @@ function captureJson(journal) {
|
|
|
15477
15586
|
sourceKind: journal.sourceKind,
|
|
15478
15587
|
sourceSha256: journal.sourceSha256,
|
|
15479
15588
|
manifest: manifestJson(journal.manifest),
|
|
15480
|
-
mapping: journal.mapping
|
|
15589
|
+
mapping: journal.mapping,
|
|
15590
|
+
...journal.relocation === void 0 ? {} : { relocation: { source: journal.relocation.source } }
|
|
15481
15591
|
};
|
|
15482
15592
|
}
|
|
15593
|
+
function base64Bytes(value, path5) {
|
|
15594
|
+
if (typeof value !== "string")
|
|
15595
|
+
throw new AccountMigrationError(`${path5} is invalid`);
|
|
15596
|
+
const bytes = Buffer.from(value, "base64");
|
|
15597
|
+
if (bytes.toString("base64") !== value)
|
|
15598
|
+
throw new AccountMigrationError(`${path5} is not canonical base64`);
|
|
15599
|
+
return bytes;
|
|
15600
|
+
}
|
|
15601
|
+
function decodeRelocationSnapshot(value) {
|
|
15602
|
+
const raw = exact(value, ["config", "state", "journal"], "moved snapshot");
|
|
15603
|
+
return {
|
|
15604
|
+
config: base64Bytes(raw.config, "moved snapshot config"),
|
|
15605
|
+
...Object.hasOwn(raw, "state") ? { state: base64Bytes(raw.state, "moved snapshot state") } : {},
|
|
15606
|
+
journal: base64Bytes(raw.journal, "moved snapshot journal")
|
|
15607
|
+
};
|
|
15608
|
+
}
|
|
15609
|
+
function verifyRelocationSnapshot(backup, journal) {
|
|
15610
|
+
const source = journal.relocation?.source;
|
|
15611
|
+
if (source === void 0)
|
|
15612
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15613
|
+
const snapshot2 = decodeRelocationSnapshot(jsonBytes(backup));
|
|
15614
|
+
if (digest(snapshot2.config) !== source.configSha256 || snapshot2.state !== void 0 !== source.statePresent || snapshot2.state !== void 0 && digest(snapshot2.state) !== source.stateSha256)
|
|
15615
|
+
throw new AccountMigrationError("moved source snapshot differs from its recorded hashes");
|
|
15616
|
+
const copied = decodeAccountMigrationJournal(jsonBytes(snapshot2.journal));
|
|
15617
|
+
if (copied.id !== source.journalId || copied.legacyPath !== source.legacyPath || copied.storeDir !== source.storeDir || copied.status !== "active")
|
|
15618
|
+
throw new AccountMigrationError("moved source snapshot is not the active source generation");
|
|
15619
|
+
const config = object(jsonBytes(snapshot2.config), "moved source config");
|
|
15620
|
+
if (!isDeepStrictEqual(decodeAccountStoreGeneration(config[ACCOUNT_STORE_GENERATION_SETTINGS_KEY]), generationJson(copied)))
|
|
15621
|
+
throw new AccountMigrationError("moved source snapshot belongs to another generation");
|
|
15622
|
+
}
|
|
15483
15623
|
async function synchronizedSnapshot(paths, boundary) {
|
|
15484
15624
|
await syncFile(paths.configPath);
|
|
15485
15625
|
const statePresent = await exists(paths.statePath);
|
|
@@ -15551,7 +15691,7 @@ function receipt(journal) {
|
|
|
15551
15691
|
storeDir: journal.storeDir,
|
|
15552
15692
|
sourceKind: journal.sourceKind,
|
|
15553
15693
|
durability: journal.verification?.durability ?? accountMigrationDurability(),
|
|
15554
|
-
restartRequired: journal.sourceKind
|
|
15694
|
+
restartRequired: journal.sourceKind !== "absent" || journal.operation === "rollback"
|
|
15555
15695
|
};
|
|
15556
15696
|
}
|
|
15557
15697
|
async function currentSuccessor(store, paths, journal) {
|
|
@@ -15635,35 +15775,13 @@ async function trustedCurrentGeneration(store, paths, journal) {
|
|
|
15635
15775
|
}
|
|
15636
15776
|
async function readAccountStoreBinding(legacyPath, modules, now, expectedGeneration) {
|
|
15637
15777
|
try {
|
|
15638
|
-
const
|
|
15639
|
-
if (
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
throw new AccountMigrationError("published binding journal missing");
|
|
15644
|
-
if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
|
|
15645
|
-
throw new AccountMigrationError("bound repository generation differs from pointer");
|
|
15646
|
-
if (journal.status === "pending")
|
|
15647
|
-
return {
|
|
15648
|
-
status: "pending",
|
|
15649
|
-
phase: journal.phase,
|
|
15650
|
-
operation: journal.operation
|
|
15651
|
-
};
|
|
15652
|
-
if (journal.status === "inactive")
|
|
15653
|
-
return { status: "inactive", id: journal.id };
|
|
15654
|
-
if (await exists(legacyPath))
|
|
15655
|
-
throw new AccountMigrationError("legacy source was recreated after activation");
|
|
15656
|
-
await verifyCopies(paths, journal, true);
|
|
15657
|
-
const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
|
|
15658
|
-
const pending = settings[MANAGEMENT_SETTINGS_KEY];
|
|
15659
|
-
if (pending !== void 0) {
|
|
15660
|
-
const record3 = object(pending, "repository management");
|
|
15661
|
-
if (record3.kind === "migration")
|
|
15662
|
-
return { status: "pending", phase: "activate", operation: "migrate" };
|
|
15663
|
-
if (record3.kind !== "clear" && record3.kind !== "replace-pool")
|
|
15664
|
-
throw new AccountMigrationError("unknown management owner prevents binding");
|
|
15778
|
+
const record3 = await readPointerRecord(legacyPath);
|
|
15779
|
+
if (record3?.schemaVersion === 2) {
|
|
15780
|
+
if (await exists(legacyPath))
|
|
15781
|
+
throw new AccountMigrationError(`a pool file reappeared at ${legacyPath} after the account store moved to ${record3.relocatedTo.legacyPath}`);
|
|
15782
|
+
return await bindPublishedGeneration(await forwardTarget(legacyPath, record3), modules, now, expectedGeneration, legacyPath);
|
|
15665
15783
|
}
|
|
15666
|
-
return
|
|
15784
|
+
return await bindPublishedGeneration(legacyPath, modules, now, expectedGeneration);
|
|
15667
15785
|
} catch (error) {
|
|
15668
15786
|
return {
|
|
15669
15787
|
status: "error",
|
|
@@ -15671,6 +15789,65 @@ async function readAccountStoreBinding(legacyPath, modules, now, expectedGenerat
|
|
|
15671
15789
|
};
|
|
15672
15790
|
}
|
|
15673
15791
|
}
|
|
15792
|
+
async function assertSourceForwarded(journal, forwardedFrom) {
|
|
15793
|
+
const source = journal.relocation?.source;
|
|
15794
|
+
if (source === void 0)
|
|
15795
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15796
|
+
const pointer = accountStorePointerPath(source.legacyPath);
|
|
15797
|
+
if (forwardedFrom !== void 0 && forwardedFrom !== source.legacyPath)
|
|
15798
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store moved from ${source.legacyPath}`);
|
|
15799
|
+
if (await exists(source.legacyPath))
|
|
15800
|
+
throw new AccountMigrationError(`a pool file reappeared at ${source.legacyPath} after the account store moved to ${journal.legacyPath}`);
|
|
15801
|
+
const record3 = await readPointerRecord(source.legacyPath);
|
|
15802
|
+
if (record3 === void 0)
|
|
15803
|
+
throw new AccountMigrationError(`the forwarding pointer ${pointer} to the moved account store at ${journal.storeDir} is missing; restore it`);
|
|
15804
|
+
if (record3.schemaVersion === 1)
|
|
15805
|
+
throw new AccountMigrationError(`the account store in ${dirname(source.legacyPath)} was reactivated: ${pointer} publishes generation ${record3.id} while the moved store at ${journal.storeDir} is active; restore the forwarding pointer, or run \`antigravity-auth store relocate\``);
|
|
15806
|
+
if (record3.id !== source.journalId || record3.relocatedTo.legacyPath !== journal.legacyPath || record3.relocatedTo.id !== journal.id)
|
|
15807
|
+
throw new AccountMigrationError(`the forwarding pointer ${pointer} names another store than the moved account store at ${journal.storeDir}`);
|
|
15808
|
+
}
|
|
15809
|
+
async function bindPublishedGeneration(legacyPath, modules, now, expectedGeneration, forwardedFrom) {
|
|
15810
|
+
const paths = await resolvePublishedAccountStorePaths(legacyPath);
|
|
15811
|
+
if (!paths) {
|
|
15812
|
+
if (forwardedFrom !== void 0)
|
|
15813
|
+
throw new AccountMigrationError("forwarded anchor publishes no generation");
|
|
15814
|
+
return await exists(legacyPath) ? { status: "pending" } : { status: "initialization-required" };
|
|
15815
|
+
}
|
|
15816
|
+
const journal = await readJournal(paths);
|
|
15817
|
+
if (!journal)
|
|
15818
|
+
throw new AccountMigrationError("published binding journal missing");
|
|
15819
|
+
if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
|
|
15820
|
+
throw new AccountMigrationError("bound repository generation differs from pointer");
|
|
15821
|
+
if (forwardedFrom !== void 0 && journal.sourceKind !== "generation")
|
|
15822
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store that was not moved there`);
|
|
15823
|
+
if (journal.sourceKind === "generation" && journal.status === "pending")
|
|
15824
|
+
throw new AccountMigrationError(`a move of the account store to ${journal.storeDir} is unfinished; finish it with the version that started it`);
|
|
15825
|
+
if (journal.status === "pending")
|
|
15826
|
+
return {
|
|
15827
|
+
status: "pending",
|
|
15828
|
+
phase: journal.phase,
|
|
15829
|
+
operation: journal.operation
|
|
15830
|
+
};
|
|
15831
|
+
if (journal.status === "inactive")
|
|
15832
|
+
return { status: "inactive", id: journal.id };
|
|
15833
|
+
if (await exists(legacyPath))
|
|
15834
|
+
throw new AccountMigrationError("legacy source was recreated after activation");
|
|
15835
|
+
await verifyCopies(paths, journal, true);
|
|
15836
|
+
if (journal.sourceKind === "generation")
|
|
15837
|
+
await assertSourceForwarded(journal, forwardedFrom);
|
|
15838
|
+
const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
|
|
15839
|
+
const pending = settings[MANAGEMENT_SETTINGS_KEY];
|
|
15840
|
+
if (pending !== void 0) {
|
|
15841
|
+
const record3 = object(pending, "repository management");
|
|
15842
|
+
if (record3.kind === "migration" && record3.id !== journal.id)
|
|
15843
|
+
throw new AccountMigrationError(`the account store at ${paths.storeDir} was moved to generation ${String(record3.id)}, but ${accountStorePointerPath(legacyPath)} publishes the old store again; restore the forwarding pointer, or run \`antigravity-auth store relocate\``);
|
|
15844
|
+
if (record3.kind === "migration")
|
|
15845
|
+
return { status: "pending", phase: "activate", operation: "migrate" };
|
|
15846
|
+
if (record3.kind !== "clear" && record3.kind !== "replace-pool")
|
|
15847
|
+
throw new AccountMigrationError("unknown management owner prevents binding");
|
|
15848
|
+
}
|
|
15849
|
+
return { status: "bound", receipt: receipt(journal), paths };
|
|
15850
|
+
}
|
|
15674
15851
|
async function readAccountStoreAdmission(legacyPath, modules, now, expectedGeneration) {
|
|
15675
15852
|
const binding = await readAccountStoreBinding(legacyPath, modules, now, expectedGeneration);
|
|
15676
15853
|
if (binding.status !== "bound")
|
|
@@ -15964,6 +16141,8 @@ function createAccountMigrationFactory(modules) {
|
|
|
15964
16141
|
const existing = await readJournal(paths);
|
|
15965
16142
|
if (!existing)
|
|
15966
16143
|
throw new AccountMigrationError("published generation journal missing");
|
|
16144
|
+
if (existing.sourceKind === "generation")
|
|
16145
|
+
throw new AccountMigrationError("a moved account store is finished by `antigravity-auth store relocate`, not by migrate");
|
|
15967
16146
|
if (existing.status === "inactive") {
|
|
15968
16147
|
previous = existing;
|
|
15969
16148
|
await modules.fs.withLock(paths.configPath, {
|
|
@@ -16139,6 +16318,9 @@ function createAccountRollbackFactory(modules) {
|
|
|
16139
16318
|
throw new AccountMigrationError("stopped processes and timers must be explicitly confirmed");
|
|
16140
16319
|
try {
|
|
16141
16320
|
return await withParentTopology(modules, options.legacyPath, async () => {
|
|
16321
|
+
const record3 = await readPointerRecord(options.legacyPath);
|
|
16322
|
+
if (record3?.schemaVersion === 2)
|
|
16323
|
+
throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; move it back with \`antigravity-auth store relocate --back --offline\` before rolling it back`);
|
|
16142
16324
|
const paths = await resolvePublishedAccountStorePaths(options.legacyPath);
|
|
16143
16325
|
if (!paths)
|
|
16144
16326
|
throw new AccountMigrationError("rollback requires a published generation");
|
|
@@ -16151,6 +16333,8 @@ function createAccountRollbackFactory(modules) {
|
|
|
16151
16333
|
const initialJournal = await readJournal(paths);
|
|
16152
16334
|
if (!initialJournal)
|
|
16153
16335
|
throw new AccountMigrationError("rollback requires an owned migration generation");
|
|
16336
|
+
if (initialJournal.sourceKind === "generation")
|
|
16337
|
+
throw new AccountMigrationError(`this account store was moved here from ${initialJournal.relocation?.source.legacyPath}; move it back with \`antigravity-auth store relocate --back --offline\` before rolling it back`);
|
|
16154
16338
|
let journal = initialJournal;
|
|
16155
16339
|
const store = openMigrationStore(modules, paths, options.now, writeObserver(paths, lease, options.onBoundary));
|
|
16156
16340
|
if (journal.status === "inactive") {
|
|
@@ -28134,23 +28318,37 @@ function migrateLegacyWindowsConfig() {
|
|
|
28134
28318
|
return false;
|
|
28135
28319
|
}
|
|
28136
28320
|
}
|
|
28321
|
+
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
28322
|
+
const standard = resolve12(newPath);
|
|
28323
|
+
const legacy = resolve12(legacyPath);
|
|
28324
|
+
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
28325
|
+
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
28326
|
+
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
28327
|
+
if (standardPointer && legacyPointer) {
|
|
28328
|
+
throw new Error(
|
|
28329
|
+
`Two migrated account stores exist: one is published at ${newPath} and another at ${legacyPath}. Keep one store and remove the other, then restart OpenCode.`
|
|
28330
|
+
);
|
|
28331
|
+
}
|
|
28332
|
+
if (legacyPointer && !standardPointer) return legacyPath;
|
|
28333
|
+
if (!existsSync3(standard) && existsSync3(legacy)) return legacyPath;
|
|
28334
|
+
return newPath;
|
|
28335
|
+
}
|
|
28137
28336
|
function getStoragePathWithMigration() {
|
|
28138
28337
|
const newPath = join10(getConfigDir(), "antigravity-accounts.json");
|
|
28139
28338
|
if (process.platform === "win32") {
|
|
28140
28339
|
migrateLegacyWindowsConfig();
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
28145
|
-
|
|
28146
|
-
|
|
28147
|
-
|
|
28148
|
-
|
|
28149
|
-
|
|
28150
|
-
|
|
28151
|
-
return legacyPath;
|
|
28152
|
-
}
|
|
28340
|
+
const legacyPath = join10(
|
|
28341
|
+
getLegacyWindowsConfigDir(),
|
|
28342
|
+
"antigravity-accounts.json"
|
|
28343
|
+
);
|
|
28344
|
+
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
28345
|
+
if (resolve12(anchored).toLowerCase() !== resolve12(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve12(anchored)))) {
|
|
28346
|
+
log5.info("Using legacy Windows config path (migration failed)", {
|
|
28347
|
+
legacyPath,
|
|
28348
|
+
newPath
|
|
28349
|
+
});
|
|
28153
28350
|
}
|
|
28351
|
+
return anchored;
|
|
28154
28352
|
}
|
|
28155
28353
|
return newPath;
|
|
28156
28354
|
}
|
|
@@ -28544,9 +28742,11 @@ function stateHomeLogsDir() {
|
|
|
28544
28742
|
}
|
|
28545
28743
|
function legacyAccountFile(configDir = getConfigDir()) {
|
|
28546
28744
|
const standard = join12(configDir, ACCOUNT_FILE_NAME);
|
|
28547
|
-
if (process.platform !== "win32"
|
|
28548
|
-
|
|
28549
|
-
|
|
28745
|
+
if (process.platform !== "win32") return standard;
|
|
28746
|
+
return resolveWindowsAccountAnchor(
|
|
28747
|
+
standard,
|
|
28748
|
+
join12(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
|
|
28749
|
+
);
|
|
28550
28750
|
}
|
|
28551
28751
|
function legacyVaultDir(accountFile) {
|
|
28552
28752
|
return join12(dirname16(accountFile), VAULT_DIR_NAME);
|