@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/index.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",
|
|
@@ -6356,7 +6356,7 @@
|
|
|
6356
6356
|
"imports": [],
|
|
6357
6357
|
"exports": [],
|
|
6358
6358
|
"inputs": {},
|
|
6359
|
-
"bytes":
|
|
6359
|
+
"bytes": 4469223
|
|
6360
6360
|
},
|
|
6361
6361
|
"dist/index.js": {
|
|
6362
6362
|
"imports": [
|
|
@@ -7762,7 +7762,7 @@
|
|
|
7762
7762
|
"bytesInOutput": 73131
|
|
7763
7763
|
},
|
|
7764
7764
|
"../core/dist/account-migration.js": {
|
|
7765
|
-
"bytesInOutput":
|
|
7765
|
+
"bytesInOutput": 113451
|
|
7766
7766
|
},
|
|
7767
7767
|
"../core/dist/account-repository-types.js": {
|
|
7768
7768
|
"bytesInOutput": 1238
|
|
@@ -7903,10 +7903,10 @@
|
|
|
7903
7903
|
"bytesInOutput": 17581
|
|
7904
7904
|
},
|
|
7905
7905
|
"src/runtime-paths.ts": {
|
|
7906
|
-
"bytesInOutput":
|
|
7906
|
+
"bytesInOutput": 3789
|
|
7907
7907
|
},
|
|
7908
7908
|
"src/plugin/storage.ts": {
|
|
7909
|
-
"bytesInOutput":
|
|
7909
|
+
"bytesInOutput": 9673
|
|
7910
7910
|
},
|
|
7911
7911
|
"src/version-fence.ts": {
|
|
7912
7912
|
"bytesInOutput": 5982
|
|
@@ -8302,7 +8302,7 @@
|
|
|
8302
8302
|
"bytesInOutput": 0
|
|
8303
8303
|
}
|
|
8304
8304
|
},
|
|
8305
|
-
"bytes":
|
|
8305
|
+
"bytes": 2003305
|
|
8306
8306
|
}
|
|
8307
8307
|
}
|
|
8308
8308
|
}
|
package/dist/server.js
CHANGED
|
@@ -14637,14 +14637,52 @@ function decodeAccountStorePointer(value, legacyPath) {
|
|
|
14637
14637
|
throw new AccountMigrationError("pointer directory basename differs from its derived generation");
|
|
14638
14638
|
return { schemaVersion: 1, id, directoryBasename: basename(paths.storeDir) };
|
|
14639
14639
|
}
|
|
14640
|
-
|
|
14640
|
+
function decodeAccountStorePointerRecord(value, legacyPath) {
|
|
14641
|
+
if (object(value, "pointer").schemaVersion !== 2)
|
|
14642
|
+
return decodeAccountStorePointer(value, legacyPath);
|
|
14643
|
+
const raw = exact(value, ["schemaVersion", "id", "directoryBasename", "relocatedTo"], "forward");
|
|
14644
|
+
const id = text(raw.id, UUID, "forward source generation");
|
|
14645
|
+
const paths = generationPaths(legacyPath, id);
|
|
14646
|
+
if (raw.directoryBasename !== basename(paths.storeDir))
|
|
14647
|
+
throw new AccountMigrationError("forward directory basename differs from its derived generation");
|
|
14648
|
+
const target = exact(raw.relocatedTo, ["legacyPath", "id"], "forward target");
|
|
14649
|
+
if (typeof target.legacyPath !== "string")
|
|
14650
|
+
throw new AccountMigrationError("forward target path is invalid");
|
|
14651
|
+
const targetId = text(target.id, UUID, "forward target generation");
|
|
14652
|
+
const targetPaths = generationPaths(target.legacyPath, targetId);
|
|
14653
|
+
if (sameFilesystemPath(targetPaths.legacyPath, legacyPath))
|
|
14654
|
+
throw new AccountMigrationError("forward names its own anchor");
|
|
14655
|
+
return {
|
|
14656
|
+
schemaVersion: 2,
|
|
14657
|
+
id,
|
|
14658
|
+
directoryBasename: basename(paths.storeDir),
|
|
14659
|
+
relocatedTo: {
|
|
14660
|
+
legacyPath: targetPaths.legacyPath,
|
|
14661
|
+
id: targetId
|
|
14662
|
+
}
|
|
14663
|
+
};
|
|
14664
|
+
}
|
|
14665
|
+
async function readPointerRecord(legacyPath) {
|
|
14641
14666
|
const logical = resolveAccountStorePaths(legacyPath);
|
|
14642
14667
|
if (await exists(logical.storeDir))
|
|
14643
14668
|
throw new AccountMigrationError("foreign logical store directory is not pointer authority");
|
|
14644
14669
|
const path5 = accountStorePointerPath(legacyPath);
|
|
14645
14670
|
if (!await exists(path5))
|
|
14646
14671
|
return void 0;
|
|
14647
|
-
return
|
|
14672
|
+
return decodeAccountStorePointerRecord(jsonBytes(await secureRead(path5)), legacyPath);
|
|
14673
|
+
}
|
|
14674
|
+
async function readPointer(legacyPath) {
|
|
14675
|
+
const record3 = await readPointerRecord(legacyPath);
|
|
14676
|
+
if (record3?.schemaVersion === 2)
|
|
14677
|
+
throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; this operation does not follow a moved store`);
|
|
14678
|
+
return record3;
|
|
14679
|
+
}
|
|
14680
|
+
async function forwardTarget(legacyPath, forward) {
|
|
14681
|
+
const target = forward.relocatedTo.legacyPath;
|
|
14682
|
+
const published = await readPointerRecord(target);
|
|
14683
|
+
if (published?.schemaVersion !== 1 || published.id !== forward.relocatedTo.id)
|
|
14684
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(legacyPath)} names generation ${forward.relocatedTo.id}, which ${accountStorePointerPath(target)} does not publish`);
|
|
14685
|
+
return target;
|
|
14648
14686
|
}
|
|
14649
14687
|
async function resolvePublishedAccountStorePaths(legacyPath) {
|
|
14650
14688
|
const pointer = await readPointer(legacyPath);
|
|
@@ -14900,7 +14938,7 @@ function decodeAccountStoreGeneration(value) {
|
|
|
14900
14938
|
"sourceKind",
|
|
14901
14939
|
"initialManifestSha256"
|
|
14902
14940
|
], "generation");
|
|
14903
|
-
if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent")
|
|
14941
|
+
if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent" && raw.sourceKind !== "generation")
|
|
14904
14942
|
throw new AccountMigrationError("generation schema is invalid");
|
|
14905
14943
|
const id = text(raw.id, UUID, "generation id");
|
|
14906
14944
|
const paths = generationPaths(raw.legacyPath, id);
|
|
@@ -14999,7 +15037,8 @@ function decodeAccountMigrationJournal(value) {
|
|
|
14999
15037
|
"verification",
|
|
15000
15038
|
"retiredSha256",
|
|
15001
15039
|
"rollback",
|
|
15002
|
-
"cancelled"
|
|
15040
|
+
"cancelled",
|
|
15041
|
+
"relocation"
|
|
15003
15042
|
], "journal");
|
|
15004
15043
|
if (raw.schemaVersion !== 1)
|
|
15005
15044
|
throw new AccountMigrationError("unsupported journal schema");
|
|
@@ -15019,10 +15058,10 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15019
15058
|
if (phase === void 0)
|
|
15020
15059
|
throw new AccountMigrationError("journal phase is invalid");
|
|
15021
15060
|
const sourceKind = raw.sourceKind;
|
|
15022
|
-
if (sourceKind !== "file" && sourceKind !== "absent")
|
|
15061
|
+
if (sourceKind !== "file" && sourceKind !== "absent" && sourceKind !== "generation")
|
|
15023
15062
|
throw new AccountMigrationError("journal source kind is invalid");
|
|
15024
|
-
const sourceSha256 = sourceKind
|
|
15025
|
-
const captureSha256 = sourceKind
|
|
15063
|
+
const sourceSha256 = sourceKind !== "absent" ? text(raw.sourceSha256, SHA256, "journal.sourceSha256") : void 0;
|
|
15064
|
+
const captureSha256 = sourceKind !== "absent" ? text(raw.captureSha256, SHA256, "journal.captureSha256") : void 0;
|
|
15026
15065
|
if (sourceKind === "absent" && Object.hasOwn(raw, "captureSha256"))
|
|
15027
15066
|
throw new AccountMigrationError("absent source cannot claim a captured file snapshot");
|
|
15028
15067
|
if (sourceKind === "absent" && Object.hasOwn(raw, "sourceSha256"))
|
|
@@ -15039,7 +15078,7 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15039
15078
|
const sourceVersion = m.sourceVersion;
|
|
15040
15079
|
if (sourceVersion !== null && sourceVersion !== 1 && sourceVersion !== 2 && sourceVersion !== 3 && sourceVersion !== 4)
|
|
15041
15080
|
throw new AccountMigrationError("manifest source version is invalid");
|
|
15042
|
-
if (sourceKind === "file" && sourceVersion === null || sourceKind
|
|
15081
|
+
if (sourceKind === "file" && sourceVersion === null || sourceKind !== "file" && sourceVersion !== null)
|
|
15043
15082
|
throw new AccountMigrationError("manifest version differs from source kind");
|
|
15044
15083
|
if (!finite(m.normalizationClock) || !finite(m.effectiveActiveIndex))
|
|
15045
15084
|
throw new AccountMigrationError("manifest clock or cursor is invalid");
|
|
@@ -15069,6 +15108,10 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15069
15108
|
schemaVersion: 1
|
|
15070
15109
|
}) || manifest.effectiveActiveIndex !== 0))
|
|
15071
15110
|
throw new AccountMigrationError("absent-source manifest must be explicitly empty with no invented cursors");
|
|
15111
|
+
if (sourceKind === "generation" && (accounts.length || !isDeepStrictEqual(encodeRoutingSettings(manifest.routing), {
|
|
15112
|
+
schemaVersion: 1
|
|
15113
|
+
}) || manifest.effectiveActiveIndex !== 0))
|
|
15114
|
+
throw new AccountMigrationError("moved-store manifest must be explicitly empty");
|
|
15072
15115
|
const effective = accounts.length ? Math.max(0, Math.min(manifest.routing.activeIndex ?? 0, accounts.length - 1)) : 0;
|
|
15073
15116
|
if (effective !== manifest.effectiveActiveIndex)
|
|
15074
15117
|
throw new AccountMigrationError("manifest effective cursor differs");
|
|
@@ -15116,6 +15159,24 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15116
15159
|
throw new AccountMigrationError("absent source cannot claim retired bytes");
|
|
15117
15160
|
if (retiredSha256 !== void 0 && retiredSha256 !== sourceSha256)
|
|
15118
15161
|
throw new AccountMigrationError("retired bytes are not associated with source");
|
|
15162
|
+
const relocation = decodeRelocation(raw, sourceKind, paths.legacyPath);
|
|
15163
|
+
if (sourceKind === "generation") {
|
|
15164
|
+
if (retiredSha256 !== void 0)
|
|
15165
|
+
throw new AccountMigrationError("moved source cannot claim retired pool-file bytes");
|
|
15166
|
+
if (relocation === void 0)
|
|
15167
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15168
|
+
if (operation === "rollback")
|
|
15169
|
+
throw new AccountMigrationError("a moved account store is not rolled back; move it back first with `antigravity-auth store relocate --back --offline`");
|
|
15170
|
+
if (relocation.sourceForwarded && !relocation.sourceTombstoned)
|
|
15171
|
+
throw new AccountMigrationError("source forward precedes its management tombstone");
|
|
15172
|
+
if ((relocation.sourceTombstoned || relocation.sourceForwarded) && (!verification || phase !== "retire" && phase !== "activate"))
|
|
15173
|
+
throw new AccountMigrationError("source tombstone or forward precedes durable verification");
|
|
15174
|
+
if (status === "active" && !relocation.sourceForwarded)
|
|
15175
|
+
throw new AccountMigrationError("active moved store lacks its source forward");
|
|
15176
|
+
if (phase === "activate" && !relocation.sourceForwarded)
|
|
15177
|
+
throw new AccountMigrationError("moved-store activation lacks its source forward");
|
|
15178
|
+
}
|
|
15179
|
+
const retirementRecorded = sourceKind === "file" ? retiredSha256 !== void 0 : sourceKind === "absent" ? raw.sourceAbsenceVerified === true : relocation?.sourceForwarded === true;
|
|
15119
15180
|
let rollback;
|
|
15120
15181
|
if (Object.hasOwn(raw, "rollback")) {
|
|
15121
15182
|
const r = exact(raw.rollback, ["id", "snapshotSha256", "exportSha256", "rows", "successorInactive"], "rollback");
|
|
@@ -15141,13 +15202,13 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15141
15202
|
throw new AccountMigrationError("verification acknowledged an incomplete import");
|
|
15142
15203
|
if (operation === "migrate" && (retiredSha256 !== void 0 || raw.sourceAbsenceVerified === true) && (!verification || phase !== "retire" && phase !== "activate"))
|
|
15143
15204
|
throw new AccountMigrationError("retirement association precedes durable verification");
|
|
15144
|
-
if (operation === "migrate" && phase === "activate" &&
|
|
15205
|
+
if (operation === "migrate" && phase === "activate" && !retirementRecorded)
|
|
15145
15206
|
throw new AccountMigrationError("activation lacks its actual source retirement association");
|
|
15146
|
-
if (status === "active" && (operation !== "migrate" || phase !== "activate" ||
|
|
15207
|
+
if (status === "active" && (operation !== "migrate" || phase !== "activate" || !retirementRecorded || rollback !== void 0 || cancelled))
|
|
15147
15208
|
throw new AccountMigrationError("active receipt is incomplete");
|
|
15148
15209
|
if (operation === "rollback" && rollback === void 0 && !cancelled)
|
|
15149
15210
|
throw new AccountMigrationError("rollback lacks its current-credential snapshot");
|
|
15150
|
-
if (operation === "rollback" && !cancelled && (verification === void 0 ||
|
|
15211
|
+
if (operation === "rollback" && !cancelled && (verification === void 0 || !retirementRecorded))
|
|
15151
15212
|
throw new AccountMigrationError("rollback lacks the original verified retirement");
|
|
15152
15213
|
if (status === "inactive" && !cancelled && (operation !== "rollback" || phase !== "activate" || rollback === void 0))
|
|
15153
15214
|
throw new AccountMigrationError("inactive receipt lacks a completed rollback");
|
|
@@ -15171,7 +15232,53 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15171
15232
|
...verification === void 0 ? {} : { verification },
|
|
15172
15233
|
...retiredSha256 === void 0 ? {} : { retiredSha256 },
|
|
15173
15234
|
...rollback === void 0 ? {} : { rollback },
|
|
15174
|
-
...cancelled ? { cancelled: true } : {}
|
|
15235
|
+
...cancelled ? { cancelled: true } : {},
|
|
15236
|
+
...relocation === void 0 ? {} : { relocation }
|
|
15237
|
+
};
|
|
15238
|
+
}
|
|
15239
|
+
function decodeRelocation(raw, sourceKind, legacyPath) {
|
|
15240
|
+
if (!Object.hasOwn(raw, "relocation"))
|
|
15241
|
+
return void 0;
|
|
15242
|
+
if (sourceKind !== "generation")
|
|
15243
|
+
throw new AccountMigrationError("only a moved store records relocation evidence");
|
|
15244
|
+
const r = exact(raw.relocation, ["source", "rows", "sourceTombstoned", "sourceForwarded"], "relocation");
|
|
15245
|
+
const s = exact(r.source, [
|
|
15246
|
+
"legacyPath",
|
|
15247
|
+
"storeDir",
|
|
15248
|
+
"journalId",
|
|
15249
|
+
"configSha256",
|
|
15250
|
+
"stateSha256",
|
|
15251
|
+
"statePresent"
|
|
15252
|
+
], "relocation source");
|
|
15253
|
+
if (typeof s.legacyPath !== "string")
|
|
15254
|
+
throw new AccountMigrationError("relocation source path is invalid");
|
|
15255
|
+
const journalId = text(s.journalId, UUID, "relocation source journal");
|
|
15256
|
+
const source = generationPaths(s.legacyPath, journalId);
|
|
15257
|
+
if (s.storeDir !== source.storeDir)
|
|
15258
|
+
throw new AccountMigrationError("relocation source association differs");
|
|
15259
|
+
if (sameFilesystemPath(source.legacyPath, legacyPath))
|
|
15260
|
+
throw new AccountMigrationError("relocation source and target share one anchor");
|
|
15261
|
+
if (typeof s.statePresent !== "boolean")
|
|
15262
|
+
throw new AccountMigrationError("relocation state presence is invalid");
|
|
15263
|
+
if (!s.statePresent && Object.hasOwn(s, "stateSha256"))
|
|
15264
|
+
throw new AccountMigrationError("absent source state cannot claim a file hash");
|
|
15265
|
+
const rows = list(r.rows, "relocation rows").map((id) => text(id, UUID, "relocation row id"));
|
|
15266
|
+
if (new Set(rows).size !== rows.length)
|
|
15267
|
+
throw new AccountMigrationError("relocation rows are duplicated");
|
|
15268
|
+
if (typeof r.sourceTombstoned !== "boolean" || typeof r.sourceForwarded !== "boolean")
|
|
15269
|
+
throw new AccountMigrationError("relocation progress flags are invalid");
|
|
15270
|
+
return {
|
|
15271
|
+
source: {
|
|
15272
|
+
legacyPath: source.legacyPath,
|
|
15273
|
+
storeDir: source.storeDir,
|
|
15274
|
+
journalId,
|
|
15275
|
+
configSha256: text(s.configSha256, SHA256, "relocation config hash"),
|
|
15276
|
+
...s.statePresent ? { stateSha256: text(s.stateSha256, SHA256, "relocation state hash") } : {},
|
|
15277
|
+
statePresent: s.statePresent
|
|
15278
|
+
},
|
|
15279
|
+
rows,
|
|
15280
|
+
sourceTombstoned: r.sourceTombstoned,
|
|
15281
|
+
sourceForwarded: r.sourceForwarded
|
|
15175
15282
|
};
|
|
15176
15283
|
}
|
|
15177
15284
|
function pendingLockFailure(modules, error) {
|
|
@@ -15461,6 +15568,8 @@ async function verifyCopies(paths, journal, retired) {
|
|
|
15461
15568
|
const capture2 = await secureRead(join(paths.transfersDir, `${journal.id}.capture.json`));
|
|
15462
15569
|
if (digest(capture2) !== journal.captureSha256 || !isDeepStrictEqual(jsonBytes(capture2), captureJson(journal)))
|
|
15463
15570
|
throw new AccountMigrationError("journal differs from its exclusive capture snapshot");
|
|
15571
|
+
if (journal.sourceKind === "generation")
|
|
15572
|
+
return verifyRelocationSnapshot(backup, journal);
|
|
15464
15573
|
const expected = parseLegacyAccountStorage(new TextDecoder("utf-8", { fatal: true }).decode(backup), journal.manifest.normalizationClock);
|
|
15465
15574
|
if (!isDeepStrictEqual(manifestJson(expected), manifestJson(journal.manifest)))
|
|
15466
15575
|
throw new AccountMigrationError("captured manifest differs from its verified original source");
|
|
@@ -15479,9 +15588,40 @@ function captureJson(journal) {
|
|
|
15479
15588
|
sourceKind: journal.sourceKind,
|
|
15480
15589
|
sourceSha256: journal.sourceSha256,
|
|
15481
15590
|
manifest: manifestJson(journal.manifest),
|
|
15482
|
-
mapping: journal.mapping
|
|
15591
|
+
mapping: journal.mapping,
|
|
15592
|
+
...journal.relocation === void 0 ? {} : { relocation: { source: journal.relocation.source } }
|
|
15483
15593
|
};
|
|
15484
15594
|
}
|
|
15595
|
+
function base64Bytes(value, path5) {
|
|
15596
|
+
if (typeof value !== "string")
|
|
15597
|
+
throw new AccountMigrationError(`${path5} is invalid`);
|
|
15598
|
+
const bytes = Buffer.from(value, "base64");
|
|
15599
|
+
if (bytes.toString("base64") !== value)
|
|
15600
|
+
throw new AccountMigrationError(`${path5} is not canonical base64`);
|
|
15601
|
+
return bytes;
|
|
15602
|
+
}
|
|
15603
|
+
function decodeRelocationSnapshot(value) {
|
|
15604
|
+
const raw = exact(value, ["config", "state", "journal"], "moved snapshot");
|
|
15605
|
+
return {
|
|
15606
|
+
config: base64Bytes(raw.config, "moved snapshot config"),
|
|
15607
|
+
...Object.hasOwn(raw, "state") ? { state: base64Bytes(raw.state, "moved snapshot state") } : {},
|
|
15608
|
+
journal: base64Bytes(raw.journal, "moved snapshot journal")
|
|
15609
|
+
};
|
|
15610
|
+
}
|
|
15611
|
+
function verifyRelocationSnapshot(backup, journal) {
|
|
15612
|
+
const source = journal.relocation?.source;
|
|
15613
|
+
if (source === void 0)
|
|
15614
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15615
|
+
const snapshot2 = decodeRelocationSnapshot(jsonBytes(backup));
|
|
15616
|
+
if (digest(snapshot2.config) !== source.configSha256 || snapshot2.state !== void 0 !== source.statePresent || snapshot2.state !== void 0 && digest(snapshot2.state) !== source.stateSha256)
|
|
15617
|
+
throw new AccountMigrationError("moved source snapshot differs from its recorded hashes");
|
|
15618
|
+
const copied = decodeAccountMigrationJournal(jsonBytes(snapshot2.journal));
|
|
15619
|
+
if (copied.id !== source.journalId || copied.legacyPath !== source.legacyPath || copied.storeDir !== source.storeDir || copied.status !== "active")
|
|
15620
|
+
throw new AccountMigrationError("moved source snapshot is not the active source generation");
|
|
15621
|
+
const config = object(jsonBytes(snapshot2.config), "moved source config");
|
|
15622
|
+
if (!isDeepStrictEqual(decodeAccountStoreGeneration(config[ACCOUNT_STORE_GENERATION_SETTINGS_KEY]), generationJson(copied)))
|
|
15623
|
+
throw new AccountMigrationError("moved source snapshot belongs to another generation");
|
|
15624
|
+
}
|
|
15485
15625
|
async function synchronizedSnapshot(paths, boundary) {
|
|
15486
15626
|
await syncFile(paths.configPath);
|
|
15487
15627
|
const statePresent = await exists(paths.statePath);
|
|
@@ -15553,7 +15693,7 @@ function receipt(journal) {
|
|
|
15553
15693
|
storeDir: journal.storeDir,
|
|
15554
15694
|
sourceKind: journal.sourceKind,
|
|
15555
15695
|
durability: journal.verification?.durability ?? accountMigrationDurability(),
|
|
15556
|
-
restartRequired: journal.sourceKind
|
|
15696
|
+
restartRequired: journal.sourceKind !== "absent" || journal.operation === "rollback"
|
|
15557
15697
|
};
|
|
15558
15698
|
}
|
|
15559
15699
|
async function currentSuccessor(store, paths, journal) {
|
|
@@ -15637,35 +15777,13 @@ async function trustedCurrentGeneration(store, paths, journal) {
|
|
|
15637
15777
|
}
|
|
15638
15778
|
async function readAccountStoreBinding(legacyPath, modules, now, expectedGeneration) {
|
|
15639
15779
|
try {
|
|
15640
|
-
const
|
|
15641
|
-
if (
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
throw new AccountMigrationError("published binding journal missing");
|
|
15646
|
-
if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
|
|
15647
|
-
throw new AccountMigrationError("bound repository generation differs from pointer");
|
|
15648
|
-
if (journal.status === "pending")
|
|
15649
|
-
return {
|
|
15650
|
-
status: "pending",
|
|
15651
|
-
phase: journal.phase,
|
|
15652
|
-
operation: journal.operation
|
|
15653
|
-
};
|
|
15654
|
-
if (journal.status === "inactive")
|
|
15655
|
-
return { status: "inactive", id: journal.id };
|
|
15656
|
-
if (await exists(legacyPath))
|
|
15657
|
-
throw new AccountMigrationError("legacy source was recreated after activation");
|
|
15658
|
-
await verifyCopies(paths, journal, true);
|
|
15659
|
-
const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
|
|
15660
|
-
const pending = settings[MANAGEMENT_SETTINGS_KEY];
|
|
15661
|
-
if (pending !== void 0) {
|
|
15662
|
-
const record3 = object(pending, "repository management");
|
|
15663
|
-
if (record3.kind === "migration")
|
|
15664
|
-
return { status: "pending", phase: "activate", operation: "migrate" };
|
|
15665
|
-
if (record3.kind !== "clear" && record3.kind !== "replace-pool")
|
|
15666
|
-
throw new AccountMigrationError("unknown management owner prevents binding");
|
|
15780
|
+
const record3 = await readPointerRecord(legacyPath);
|
|
15781
|
+
if (record3?.schemaVersion === 2) {
|
|
15782
|
+
if (await exists(legacyPath))
|
|
15783
|
+
throw new AccountMigrationError(`a pool file reappeared at ${legacyPath} after the account store moved to ${record3.relocatedTo.legacyPath}`);
|
|
15784
|
+
return await bindPublishedGeneration(await forwardTarget(legacyPath, record3), modules, now, expectedGeneration, legacyPath);
|
|
15667
15785
|
}
|
|
15668
|
-
return
|
|
15786
|
+
return await bindPublishedGeneration(legacyPath, modules, now, expectedGeneration);
|
|
15669
15787
|
} catch (error) {
|
|
15670
15788
|
return {
|
|
15671
15789
|
status: "error",
|
|
@@ -15673,6 +15791,65 @@ async function readAccountStoreBinding(legacyPath, modules, now, expectedGenerat
|
|
|
15673
15791
|
};
|
|
15674
15792
|
}
|
|
15675
15793
|
}
|
|
15794
|
+
async function assertSourceForwarded(journal, forwardedFrom) {
|
|
15795
|
+
const source = journal.relocation?.source;
|
|
15796
|
+
if (source === void 0)
|
|
15797
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15798
|
+
const pointer = accountStorePointerPath(source.legacyPath);
|
|
15799
|
+
if (forwardedFrom !== void 0 && forwardedFrom !== source.legacyPath)
|
|
15800
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store moved from ${source.legacyPath}`);
|
|
15801
|
+
if (await exists(source.legacyPath))
|
|
15802
|
+
throw new AccountMigrationError(`a pool file reappeared at ${source.legacyPath} after the account store moved to ${journal.legacyPath}`);
|
|
15803
|
+
const record3 = await readPointerRecord(source.legacyPath);
|
|
15804
|
+
if (record3 === void 0)
|
|
15805
|
+
throw new AccountMigrationError(`the forwarding pointer ${pointer} to the moved account store at ${journal.storeDir} is missing; restore it`);
|
|
15806
|
+
if (record3.schemaVersion === 1)
|
|
15807
|
+
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\``);
|
|
15808
|
+
if (record3.id !== source.journalId || record3.relocatedTo.legacyPath !== journal.legacyPath || record3.relocatedTo.id !== journal.id)
|
|
15809
|
+
throw new AccountMigrationError(`the forwarding pointer ${pointer} names another store than the moved account store at ${journal.storeDir}`);
|
|
15810
|
+
}
|
|
15811
|
+
async function bindPublishedGeneration(legacyPath, modules, now, expectedGeneration, forwardedFrom) {
|
|
15812
|
+
const paths = await resolvePublishedAccountStorePaths(legacyPath);
|
|
15813
|
+
if (!paths) {
|
|
15814
|
+
if (forwardedFrom !== void 0)
|
|
15815
|
+
throw new AccountMigrationError("forwarded anchor publishes no generation");
|
|
15816
|
+
return await exists(legacyPath) ? { status: "pending" } : { status: "initialization-required" };
|
|
15817
|
+
}
|
|
15818
|
+
const journal = await readJournal(paths);
|
|
15819
|
+
if (!journal)
|
|
15820
|
+
throw new AccountMigrationError("published binding journal missing");
|
|
15821
|
+
if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
|
|
15822
|
+
throw new AccountMigrationError("bound repository generation differs from pointer");
|
|
15823
|
+
if (forwardedFrom !== void 0 && journal.sourceKind !== "generation")
|
|
15824
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store that was not moved there`);
|
|
15825
|
+
if (journal.sourceKind === "generation" && journal.status === "pending")
|
|
15826
|
+
throw new AccountMigrationError(`a move of the account store to ${journal.storeDir} is unfinished; finish it with the version that started it`);
|
|
15827
|
+
if (journal.status === "pending")
|
|
15828
|
+
return {
|
|
15829
|
+
status: "pending",
|
|
15830
|
+
phase: journal.phase,
|
|
15831
|
+
operation: journal.operation
|
|
15832
|
+
};
|
|
15833
|
+
if (journal.status === "inactive")
|
|
15834
|
+
return { status: "inactive", id: journal.id };
|
|
15835
|
+
if (await exists(legacyPath))
|
|
15836
|
+
throw new AccountMigrationError("legacy source was recreated after activation");
|
|
15837
|
+
await verifyCopies(paths, journal, true);
|
|
15838
|
+
if (journal.sourceKind === "generation")
|
|
15839
|
+
await assertSourceForwarded(journal, forwardedFrom);
|
|
15840
|
+
const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
|
|
15841
|
+
const pending = settings[MANAGEMENT_SETTINGS_KEY];
|
|
15842
|
+
if (pending !== void 0) {
|
|
15843
|
+
const record3 = object(pending, "repository management");
|
|
15844
|
+
if (record3.kind === "migration" && record3.id !== journal.id)
|
|
15845
|
+
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\``);
|
|
15846
|
+
if (record3.kind === "migration")
|
|
15847
|
+
return { status: "pending", phase: "activate", operation: "migrate" };
|
|
15848
|
+
if (record3.kind !== "clear" && record3.kind !== "replace-pool")
|
|
15849
|
+
throw new AccountMigrationError("unknown management owner prevents binding");
|
|
15850
|
+
}
|
|
15851
|
+
return { status: "bound", receipt: receipt(journal), paths };
|
|
15852
|
+
}
|
|
15676
15853
|
async function readAccountStoreAdmission(legacyPath, modules, now, expectedGeneration) {
|
|
15677
15854
|
const binding = await readAccountStoreBinding(legacyPath, modules, now, expectedGeneration);
|
|
15678
15855
|
if (binding.status !== "bound")
|
|
@@ -15966,6 +16143,8 @@ function createAccountMigrationFactory(modules) {
|
|
|
15966
16143
|
const existing = await readJournal(paths);
|
|
15967
16144
|
if (!existing)
|
|
15968
16145
|
throw new AccountMigrationError("published generation journal missing");
|
|
16146
|
+
if (existing.sourceKind === "generation")
|
|
16147
|
+
throw new AccountMigrationError("a moved account store is finished by `antigravity-auth store relocate`, not by migrate");
|
|
15969
16148
|
if (existing.status === "inactive") {
|
|
15970
16149
|
previous = existing;
|
|
15971
16150
|
await modules.fs.withLock(paths.configPath, {
|
|
@@ -16141,6 +16320,9 @@ function createAccountRollbackFactory(modules) {
|
|
|
16141
16320
|
throw new AccountMigrationError("stopped processes and timers must be explicitly confirmed");
|
|
16142
16321
|
try {
|
|
16143
16322
|
return await withParentTopology(modules, options.legacyPath, async () => {
|
|
16323
|
+
const record3 = await readPointerRecord(options.legacyPath);
|
|
16324
|
+
if (record3?.schemaVersion === 2)
|
|
16325
|
+
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`);
|
|
16144
16326
|
const paths = await resolvePublishedAccountStorePaths(options.legacyPath);
|
|
16145
16327
|
if (!paths)
|
|
16146
16328
|
throw new AccountMigrationError("rollback requires a published generation");
|
|
@@ -16153,6 +16335,8 @@ function createAccountRollbackFactory(modules) {
|
|
|
16153
16335
|
const initialJournal = await readJournal(paths);
|
|
16154
16336
|
if (!initialJournal)
|
|
16155
16337
|
throw new AccountMigrationError("rollback requires an owned migration generation");
|
|
16338
|
+
if (initialJournal.sourceKind === "generation")
|
|
16339
|
+
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`);
|
|
16156
16340
|
let journal = initialJournal;
|
|
16157
16341
|
const store = openMigrationStore(modules, paths, options.now, writeObserver(paths, lease, options.onBoundary));
|
|
16158
16342
|
if (journal.status === "inactive") {
|
|
@@ -28241,23 +28425,37 @@ function migrateLegacyWindowsConfig() {
|
|
|
28241
28425
|
return false;
|
|
28242
28426
|
}
|
|
28243
28427
|
}
|
|
28428
|
+
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
28429
|
+
const standard = resolve12(newPath);
|
|
28430
|
+
const legacy = resolve12(legacyPath);
|
|
28431
|
+
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
28432
|
+
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
28433
|
+
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
28434
|
+
if (standardPointer && legacyPointer) {
|
|
28435
|
+
throw new Error(
|
|
28436
|
+
`Two migrated account stores exist: one is published at ${newPath} and another at ${legacyPath}. Keep one store and remove the other, then restart OpenCode.`
|
|
28437
|
+
);
|
|
28438
|
+
}
|
|
28439
|
+
if (legacyPointer && !standardPointer) return legacyPath;
|
|
28440
|
+
if (!existsSync3(standard) && existsSync3(legacy)) return legacyPath;
|
|
28441
|
+
return newPath;
|
|
28442
|
+
}
|
|
28244
28443
|
function getStoragePathWithMigration() {
|
|
28245
28444
|
const newPath = join10(getConfigDir(), "antigravity-accounts.json");
|
|
28246
28445
|
if (process.platform === "win32") {
|
|
28247
28446
|
migrateLegacyWindowsConfig();
|
|
28248
|
-
|
|
28249
|
-
|
|
28250
|
-
|
|
28251
|
-
|
|
28252
|
-
|
|
28253
|
-
|
|
28254
|
-
|
|
28255
|
-
|
|
28256
|
-
|
|
28257
|
-
|
|
28258
|
-
return legacyPath;
|
|
28259
|
-
}
|
|
28447
|
+
const legacyPath = join10(
|
|
28448
|
+
getLegacyWindowsConfigDir(),
|
|
28449
|
+
"antigravity-accounts.json"
|
|
28450
|
+
);
|
|
28451
|
+
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
28452
|
+
if (resolve12(anchored).toLowerCase() !== resolve12(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve12(anchored)))) {
|
|
28453
|
+
log5.info("Using legacy Windows config path (migration failed)", {
|
|
28454
|
+
legacyPath,
|
|
28455
|
+
newPath
|
|
28456
|
+
});
|
|
28260
28457
|
}
|
|
28458
|
+
return anchored;
|
|
28261
28459
|
}
|
|
28262
28460
|
return newPath;
|
|
28263
28461
|
}
|
|
@@ -28651,9 +28849,11 @@ function stateHomeLogsDir() {
|
|
|
28651
28849
|
}
|
|
28652
28850
|
function legacyAccountFile(configDir = getConfigDir()) {
|
|
28653
28851
|
const standard = join12(configDir, ACCOUNT_FILE_NAME);
|
|
28654
|
-
if (process.platform !== "win32"
|
|
28655
|
-
|
|
28656
|
-
|
|
28852
|
+
if (process.platform !== "win32") return standard;
|
|
28853
|
+
return resolveWindowsAccountAnchor(
|
|
28854
|
+
standard,
|
|
28855
|
+
join12(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
|
|
28856
|
+
);
|
|
28657
28857
|
}
|
|
28658
28858
|
function legacyVaultDir(accountFile) {
|
|
28659
28859
|
return join12(dirname16(accountFile), VAULT_DIR_NAME);
|