@cortexkit/anthropic-auth-core 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -8
- package/dist/pool-authority.d.ts +16 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export * from './oauth-profile.ts';
|
|
|
66
66
|
export { createWindowsOwnerOnly, ensureWindowsOwnerOnlyDirectory, isOwnerOnly, type OwnerOnlyOptions, } from './owner-only.ts';
|
|
67
67
|
export * from './pkce.ts';
|
|
68
68
|
export type { NativeEmptyInitJournal, NativeLegacyMigrationJournal, NativeMigrationJournal, } from './pool-authority.ts';
|
|
69
|
-
export { nativeMigrationAuthorityPhase, readNativeMigrationJournal, } from './pool-authority.ts';
|
|
69
|
+
export { nativeJournalMayAdoptLaterHostLogin, nativeMigrationAuthorityPhase, readNativeMigrationJournal, } from './pool-authority.ts';
|
|
70
70
|
export type { NativeLocalPoolBinding } from './pool-binding.ts';
|
|
71
71
|
export { captureNativeLocalPoolBinding } from './pool-binding.ts';
|
|
72
72
|
export * from './pool-paths.ts';
|
package/dist/index.js
CHANGED
|
@@ -9558,7 +9558,7 @@ function formatEnrollmentStatus(status, scopedServing = false) {
|
|
|
9558
9558
|
return ["- Enrollment: setup is busy"];
|
|
9559
9559
|
case "unavailable":
|
|
9560
9560
|
return [
|
|
9561
|
-
|
|
9561
|
+
'- Enrollment: this Claustrum vault is too old to connect plugins. Run `ck upgrade` to move to Claustrum v0.2.0 or newer (read "Upgrading from v0.1.3" in its release notes first).'
|
|
9562
9562
|
];
|
|
9563
9563
|
case "pending":
|
|
9564
9564
|
return status.requestId && /^[A-Za-z0-9_-]{1,128}$/.test(status.requestId) ? [`- Enrollment: pending approval (${status.requestId})`, setup] : [
|
|
@@ -20908,6 +20908,9 @@ function nativeMigrationAuthorityPhase(journal) {
|
|
|
20908
20908
|
return;
|
|
20909
20909
|
return journal.phase;
|
|
20910
20910
|
}
|
|
20911
|
+
function nativeJournalMayAdoptLaterHostLogin(journal, host) {
|
|
20912
|
+
return host === "opencode" && journal !== undefined && journal.kind !== "empty-init" && journal.host === "opencode" && journal.phase === "retired" && journal.activation === null;
|
|
20913
|
+
}
|
|
20911
20914
|
async function requireNativePoolAuthority(paths) {
|
|
20912
20915
|
const journal = await readNativeMigrationJournal(paths);
|
|
20913
20916
|
if (!journal)
|
|
@@ -20947,7 +20950,7 @@ async function writeJournal(paths, journal, assertOwned, hooks) {
|
|
|
20947
20950
|
});
|
|
20948
20951
|
await hooks.onWriteStep?.("after-write", snapshot);
|
|
20949
20952
|
}
|
|
20950
|
-
async function beginNativeMigration(paths, input, hooks = {}) {
|
|
20953
|
+
async function beginNativeMigration(paths, input, hooks = {}, replaces) {
|
|
20951
20954
|
try {
|
|
20952
20955
|
requireNativeMigrationDataObject(input);
|
|
20953
20956
|
} catch {
|
|
@@ -20980,6 +20983,12 @@ async function beginNativeMigration(paths, input, hooks = {}) {
|
|
|
20980
20983
|
renew: true
|
|
20981
20984
|
}, async (lock) => {
|
|
20982
20985
|
const current = await readNativeMigrationJournal(paths);
|
|
20986
|
+
if (replaces) {
|
|
20987
|
+
if (initial.version !== 5 || !nativeJournalMayAdoptLaterHostLogin(replaces, initial.host) || !current || nativeMigrationCanonicalJson(current) !== nativeMigrationCanonicalJson(replaces))
|
|
20988
|
+
throw new NativeAuthorityError("journal-conflict");
|
|
20989
|
+
await writeJournal(paths, initial, () => lock.assertOwned(), hooks);
|
|
20990
|
+
return initial;
|
|
20991
|
+
}
|
|
20983
20992
|
if (current?.kind === "empty-init") {
|
|
20984
20993
|
if (current.host !== initial.host)
|
|
20985
20994
|
throw new NativeAuthorityError("journal-conflict");
|
|
@@ -27511,7 +27520,7 @@ async function capture2(input, checkPool = false) {
|
|
|
27511
27520
|
refuse3();
|
|
27512
27521
|
const current = await readNativeMigrationJournal(input.paths);
|
|
27513
27522
|
const emptyInit = current?.kind === "empty-init";
|
|
27514
|
-
|
|
27523
|
+
let journal = current?.kind === "empty-init" ? undefined : current;
|
|
27515
27524
|
if (emptyInit) {
|
|
27516
27525
|
if (current.host !== input.host || input.routingDestinationPath !== resolveLocalRoutingDestination(input.host, input.paths, input.env))
|
|
27517
27526
|
refuse3();
|
|
@@ -27541,6 +27550,11 @@ async function capture2(input, checkPool = false) {
|
|
|
27541
27550
|
refuse3();
|
|
27542
27551
|
if (journal && (journal.host !== input.host || journal.hostAuthPath !== hostAuthPath || journal.routingPaths.source !== routingSourcePath || journal.routingPaths.destination !== routingDestinationPath))
|
|
27543
27552
|
refuse3();
|
|
27553
|
+
let replaces;
|
|
27554
|
+
if (nativeJournalMayAdoptLaterHostLogin(journal, input.host) && entry2.kind === "oauth" && !await nativePoolHoldsAccountData({ paths: input.paths })) {
|
|
27555
|
+
replaces = journal;
|
|
27556
|
+
journal = undefined;
|
|
27557
|
+
}
|
|
27544
27558
|
if (journal?.phase === "committed" || journal?.phase === "retired") {
|
|
27545
27559
|
const missing2 = (role, path2) => ({
|
|
27546
27560
|
role,
|
|
@@ -27575,7 +27589,7 @@ async function capture2(input, checkPool = false) {
|
|
|
27575
27589
|
const config = await readNativeMigrationSource("config", input.legacyConfigPath ?? input.paths.legacyConfig);
|
|
27576
27590
|
const state = await readNativeMigrationSource("state", input.legacyStatePath ?? input.paths.legacyState);
|
|
27577
27591
|
const routing = await readNativeMigrationSource("routing", input.routingSourcePath);
|
|
27578
|
-
const routingDestination = emptyInit || journal?.kind === "legacy-import" ? await readNativeMigrationSource("routing", input.routingDestinationPath) : undefined;
|
|
27592
|
+
const routingDestination = emptyInit || replaces || journal?.kind === "legacy-import" ? await readNativeMigrationSource("routing", input.routingDestinationPath) : undefined;
|
|
27579
27593
|
if (routingDestination)
|
|
27580
27594
|
owned(routingDestination);
|
|
27581
27595
|
for (const source2 of [config, state, routing])
|
|
@@ -27634,6 +27648,7 @@ async function capture2(input, checkPool = false) {
|
|
|
27634
27648
|
routing,
|
|
27635
27649
|
auth,
|
|
27636
27650
|
journal: current,
|
|
27651
|
+
...replaces ? { replaces } : {},
|
|
27637
27652
|
routingDestination,
|
|
27638
27653
|
projection,
|
|
27639
27654
|
seedInput,
|
|
@@ -27838,11 +27853,11 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
27838
27853
|
const captured = await capture2(operation, true);
|
|
27839
27854
|
if (operation.preflight) {
|
|
27840
27855
|
const previous = preflights.get(operation.preflight);
|
|
27841
|
-
if (!previous || operation.preflight.storageId !== paths.storageId || operation.preflight.host !== operation.host || previous.config.digest !== captured.config.digest || previous.state.digest !== captured.state.digest || previous.routing.digest !== captured.routing.digest || previous.routingDestination?.digest !== captured.routingDestination?.digest || inspectNativeHostAuthEntry(operation.host, previous.auth.data).digest !== inspectNativeHostAuthEntry(operation.host, captured.auth.data).digest || previous.hostAuthPath !== captured.hostAuthPath || previous.routingSourcePath !== captured.routingSourcePath || previous.routingDestinationPath !== captured.routingDestinationPath)
|
|
27856
|
+
if (!previous || operation.preflight.storageId !== paths.storageId || operation.preflight.host !== operation.host || previous.config.digest !== captured.config.digest || previous.state.digest !== captured.state.digest || previous.routing.digest !== captured.routing.digest || previous.routingDestination?.digest !== captured.routingDestination?.digest || inspectNativeHostAuthEntry(operation.host, previous.auth.data).digest !== inspectNativeHostAuthEntry(operation.host, captured.auth.data).digest || previous.hostAuthPath !== captured.hostAuthPath || previous.routingSourcePath !== captured.routingSourcePath || previous.routingDestinationPath !== captured.routingDestinationPath || previous.replaces === undefined !== (captured.replaces === undefined))
|
|
27842
27857
|
refuse3();
|
|
27843
27858
|
}
|
|
27844
|
-
const emptyInit = captured.journal?.kind === "empty-init";
|
|
27845
|
-
let journal = captured.journal?.kind === "empty-init" ? undefined : captured.journal;
|
|
27859
|
+
const emptyInit = captured.journal?.kind === "empty-init" || captured.replaces !== undefined;
|
|
27860
|
+
let journal = captured.journal?.kind === "empty-init" || captured.replaces ? undefined : captured.journal;
|
|
27846
27861
|
const store = createNativePoolStore({
|
|
27847
27862
|
paths,
|
|
27848
27863
|
quota: nativeQuotaCodec,
|
|
@@ -27910,7 +27925,7 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
27910
27925
|
destination: captured.routingDestinationPath
|
|
27911
27926
|
},
|
|
27912
27927
|
...operation.requestVaultActivation ? { activation: "requested" } : {}
|
|
27913
|
-
}, journalHooks);
|
|
27928
|
+
}, journalHooks, captured.replaces);
|
|
27914
27929
|
}
|
|
27915
27930
|
let bytes;
|
|
27916
27931
|
let seed;
|
|
@@ -32916,6 +32931,7 @@ export {
|
|
|
32916
32931
|
nativeMigrationAuthorityPhase,
|
|
32917
32932
|
nativeLocalQuotaLineage,
|
|
32918
32933
|
nativeLocalCredentialValidationMatches,
|
|
32934
|
+
nativeJournalMayAdoptLaterHostLogin,
|
|
32919
32935
|
nativeCacheKeepAlways,
|
|
32920
32936
|
nativeAccountPolicy,
|
|
32921
32937
|
nativeAccountCanServe,
|
package/dist/pool-authority.d.ts
CHANGED
|
@@ -142,6 +142,16 @@ export declare function readNativeMigrationJournal(paths: NativePoolPaths, owner
|
|
|
142
142
|
* that admits requests from the journal uses this one predicate.
|
|
143
143
|
*/
|
|
144
144
|
export declare function nativeMigrationAuthorityPhase(journal: NativeMigrationJournal | undefined): 'committed' | 'retired' | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Whether a finished legacy import may be replaced by a fresh import of a
|
|
147
|
+
* later OpenCode login. A first OpenCode 1 setup with no login finishes a
|
|
148
|
+
* legacy import of nothing instead of recording empty-init (only OpenCode 2
|
|
149
|
+
* setup records empty-init). Such a journal stands in for empty-init only when
|
|
150
|
+
* it is retired with no requested or completed vault switch; callers must still
|
|
151
|
+
* prove the pool holds no account data, so a pool with accounts is never
|
|
152
|
+
* re-imported.
|
|
153
|
+
*/
|
|
154
|
+
export declare function nativeJournalMayAdoptLaterHostLogin(journal: NativeMigrationJournal | undefined, host: 'opencode' | 'pi'): journal is NativeLegacyMigrationJournal;
|
|
145
155
|
/** An empty or readable store is not proof that the offline authority flip completed. */
|
|
146
156
|
export declare function requireNativePoolAuthority(paths: NativePoolPaths): Promise<NativeMigrationJournal>;
|
|
147
157
|
interface JournalHooks {
|
|
@@ -154,7 +164,12 @@ interface JournalHooks {
|
|
|
154
164
|
onWriteStep?: (step: 'before-write' | 'after-write', journal: NativeMigrationJournal) => Promise<void>;
|
|
155
165
|
}
|
|
156
166
|
/** Migration resume retains the original digests and resolved paths so a retry cannot adopt changed inputs or redirect writes. */
|
|
157
|
-
export declare function beginNativeMigration(paths: NativePoolPaths, input: NativeMigrationInput, hooks?: JournalHooks
|
|
167
|
+
export declare function beginNativeMigration(paths: NativePoolPaths, input: NativeMigrationInput, hooks?: JournalHooks,
|
|
168
|
+
/**
|
|
169
|
+
* The retired journal a fresh v5 import replaces, as read by the caller.
|
|
170
|
+
* The write refuses unless the journal on disk still equals it exactly.
|
|
171
|
+
*/
|
|
172
|
+
replaces?: NativeLegacyMigrationJournal): Promise<NativeLegacyMigrationJournal>;
|
|
158
173
|
/** Save the expected host-auth entry and routing digests together before changing files, so recovery can recognize completed writes. */
|
|
159
174
|
export declare function recordNativeMigrationExpectations(paths: NativePoolPaths, expectations: NativeMigrationExpectations, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
160
175
|
/**
|