@cortexkit/anthropic-auth-core 2.11.4 → 2.13.0
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/cachekeep.d.ts +5 -0
- package/dist/custom-headers.d.ts +9 -0
- package/dist/gateway.d.ts +188 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16419 -15061
- package/dist/internal-types/fs/canonical-file-path.d.ts +17 -0
- package/dist/internal-types/fs/index.d.ts +1 -0
- package/dist/internal-types/settings/edit.d.ts +1 -0
- package/dist/internal-types/settings/handle.d.ts +2 -1
- package/dist/internal-types/settings/index.d.ts +1 -0
- package/dist/internal-types/settings/update.d.ts +14 -0
- package/dist/native-account-runtime.d.ts +21 -0
- package/dist/native-runtime-settings.d.ts +25 -6
- package/dist/native-runtime.d.ts +2 -2
- package/dist/native-settings-write.d.ts +4 -16
- package/dist/oauth-origin.d.ts +47 -4
- package/dist/pool-store.d.ts +7 -0
- package/dist/relay-location.d.ts +109 -0
- package/dist/relay.d.ts +18 -2
- package/dist/settings-definition.d.ts +38 -0
- package/dist/settings-host-import.d.ts +18 -4
- package/dist/settings-mode.d.ts +22 -0
- package/dist/settings-move-run.d.ts +60 -1
- package/dist/settings-move-source.d.ts +4 -1
- package/dist/settings-move-sources.d.ts +15 -6
- package/dist/settings-protection-copy.d.ts +7 -1
- package/dist/settings-service.d.ts +81 -37
- package/dist/settings-start.d.ts +46 -6
- package/package.json +2 -2
- package/schema/anthropic-auth.schema.json +9 -0
package/dist/settings-mode.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type OwnerOnlyOptions } from './owner-only.ts';
|
|
2
2
|
import { type PathResolutionOptions } from './path-options.ts';
|
|
3
3
|
import type { SettingsHost, SettingsPaths } from './settings-paths.ts';
|
|
4
|
+
import type { SettingsService } from './settings-service.ts';
|
|
4
5
|
export type SettingsMode = 'separate' | 'user-file' | 'legacy';
|
|
5
6
|
/** Injectable filesystem operations for authority checks and marker publication. */
|
|
6
7
|
export interface SettingsModeFs {
|
|
@@ -34,3 +35,24 @@ export declare function hasSettingsImportRecord(target: string, host: SettingsHo
|
|
|
34
35
|
export declare function writeSettingsImportRecord(target: string, host: SettingsHost, options?: SettingsModeOptions): Promise<void>;
|
|
35
36
|
/** Startup/menu/watch/timer work only: request readers consume the cached mode. */
|
|
36
37
|
export declare function resolveSettingsMode(paths: Pick<SettingsPaths, 'target' | 'separate'>, options?: SettingsModeOptions): Promise<SettingsMode>;
|
|
38
|
+
/**
|
|
39
|
+
* Decides, off the request path, whether a running host may start using the
|
|
40
|
+
* settings file through `service` (its own handle on that file). It runs the
|
|
41
|
+
* host's import check, and returns false to keep the host's current
|
|
42
|
+
* authority and ask again at the next check. 'pending' lets the host use a
|
|
43
|
+
* missing file, whose protection comes from the host's own recovery, but
|
|
44
|
+
* the host must pass the check again before it uses a file that appears.
|
|
45
|
+
*/
|
|
46
|
+
export type SettingsAdoptionCheck = (service: SettingsService) => Promise<boolean | 'pending'>;
|
|
47
|
+
/** Attach the check a runtime must pass before adopting the file `service` reads. */
|
|
48
|
+
export declare function setSettingsAdoptionCheck(service: object, check: SettingsAdoptionCheck): void;
|
|
49
|
+
/** The check attached to `service`, if any; read it before retaining the handle. */
|
|
50
|
+
export declare function getSettingsAdoptionCheck(service: object | undefined): SettingsAdoptionCheck | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Record that the host uses `service`'s missing file without having imported
|
|
53
|
+
* its legacy store, so its runtime runs the import check before it uses a
|
|
54
|
+
* file that appears.
|
|
55
|
+
*/
|
|
56
|
+
export declare function markSettingsImportPending(service: object): void;
|
|
57
|
+
/** Whether `service` was marked; read it before retaining the handle. */
|
|
58
|
+
export declare function isSettingsImportPending(service: object | undefined): boolean;
|
|
@@ -3,6 +3,7 @@ import { type SettingsMode, type SettingsModeOptions } from './settings-mode.ts'
|
|
|
3
3
|
import { type SettingsMoveFenceOptions } from './settings-move-fence.ts';
|
|
4
4
|
import { prepareSettingsMoveSources, type SettingsMoveSourcesOptions } from './settings-move-sources.ts';
|
|
5
5
|
import { type SettingsPaths } from './settings-paths.ts';
|
|
6
|
+
import { type SettingsService } from './settings-service.ts';
|
|
6
7
|
export interface SettingsMoveStartupOptions extends SettingsMoveSourcesOptions {
|
|
7
8
|
fence: Pick<SettingsMoveFenceOptions, 'registration' | 'floor' | 'self' | 'liveness' | 'artifacts' | 'readHolders'>;
|
|
8
9
|
authority?: Pick<SettingsModeOptions, 'fs' | 'ownership' | 'now'>;
|
|
@@ -18,9 +19,67 @@ export interface SettingsMoveStartupResult {
|
|
|
18
19
|
mayOpenService: boolean;
|
|
19
20
|
outcome: MoveOutcome | 'marker-present' | 'source-unavailable'
|
|
20
21
|
/** The file is in charge, but this host's legacy store protects more. */
|
|
21
|
-
| 'import-refused'
|
|
22
|
+
| 'import-refused'
|
|
23
|
+
/**
|
|
24
|
+
* The file is in charge, but this host's legacy store could not be read
|
|
25
|
+
* to check it. The host stays legacy, and its runtime checks again.
|
|
26
|
+
*/
|
|
27
|
+
| 'import-unknown'
|
|
28
|
+
/**
|
|
29
|
+
* The file is in charge, but this host's legacy store was never imported
|
|
30
|
+
* and the file can't be checked against it yet: it is empty, unparseable,
|
|
31
|
+
* unreadable, or holds an invalid protection value. The host stays
|
|
32
|
+
* legacy, and its runtime runs the import check again.
|
|
33
|
+
*/
|
|
34
|
+
| 'import-pending';
|
|
22
35
|
move?: MoveResult;
|
|
36
|
+
/**
|
|
37
|
+
* In user-file mode: the file is missing and this host's legacy store was
|
|
38
|
+
* never imported. The host uses the file (its protection comes from this
|
|
39
|
+
* host's own recovery while it is missing), but its runtime must pass the
|
|
40
|
+
* import check before it uses a file that appears.
|
|
41
|
+
*/
|
|
42
|
+
importPending?: boolean;
|
|
23
43
|
}
|
|
44
|
+
/** What a host's import check decided about using the settings file. */
|
|
45
|
+
export type SettingsHostImportOutcome =
|
|
46
|
+
/** The file holds this host's legacy protection. */
|
|
47
|
+
'adopt'
|
|
48
|
+
/**
|
|
49
|
+
* The file is missing and this host's legacy store was never imported. The
|
|
50
|
+
* host may use the file's service now: while the file is missing, its
|
|
51
|
+
* protection comes from this host's applied copy or legacy store, and its
|
|
52
|
+
* own menu write recreates the file carrying that set. Once a file appears
|
|
53
|
+
* again, the host must pass this check before it uses that file's values.
|
|
54
|
+
*/
|
|
55
|
+
| 'pending'
|
|
56
|
+
/**
|
|
57
|
+
* The file exists but can't be checked yet: it is empty, unparseable,
|
|
58
|
+
* unreadable, or holds an invalid protection value. Its protection would
|
|
59
|
+
* replace this host's legacy set as soon as it became usable, so the host
|
|
60
|
+
* keeps its legacy settings and runs the check again later.
|
|
61
|
+
*/
|
|
62
|
+
| 'retry'
|
|
63
|
+
/** Writing the stricter legacy values failed or raced a protection change. */
|
|
64
|
+
| 'refused'
|
|
65
|
+
/** This host's legacy store could not be read, so its protection is unknown. */
|
|
66
|
+
| 'unknown';
|
|
67
|
+
/**
|
|
68
|
+
* The one check a host passes before it starts using a settings file it did
|
|
69
|
+
* not move itself, at startup and when a running legacy host notices the
|
|
70
|
+
* file later. A move under an explicit target imports only the mover's
|
|
71
|
+
* store, and a hand-made file imports none, so the host's legacy store may
|
|
72
|
+
* protect more than the file. For each protection key the file sets no value
|
|
73
|
+
* for this host, a stricter legacy value is written at the host's level
|
|
74
|
+
* first; then the host's import record is written.
|
|
75
|
+
*
|
|
76
|
+
* Never call it on the request path: it reads the legacy store and may write
|
|
77
|
+
* the file. `retry` ends the warnings and says when the check runs again.
|
|
78
|
+
*/
|
|
79
|
+
export declare function importSettingsHostStore(options: SettingsMoveSourcesOptions & {
|
|
80
|
+
paths: SettingsPaths;
|
|
81
|
+
authority?: SettingsMoveStartupOptions['authority'];
|
|
82
|
+
}, service: SettingsService, warn: (message: string) => void, retry: string): Promise<SettingsHostImportOutcome>;
|
|
24
83
|
/**
|
|
25
84
|
* Await once at host startup, before opening the settings service's first resolve.
|
|
26
85
|
* Menu, watch and timer authority checks must not call the mover or retry a failed
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { MoveSource } from "./internal-types/settings/index.js";
|
|
2
2
|
import type { SettingsHost } from './settings-paths.ts';
|
|
3
3
|
import { type SettingsValues } from './settings-service.ts';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Legacy paths by schema key; cache_keep_window combines the two named
|
|
6
|
+
* sibling hours. File-only settings have no legacy path.
|
|
7
|
+
*/
|
|
5
8
|
export declare const SETTINGS_MOVE_PATHS: {
|
|
6
9
|
readonly routing_mode: readonly ["routing", "mode"];
|
|
7
10
|
readonly max_same_account_wait: readonly ["routing", "maxSameAccountWait"];
|
|
@@ -32,12 +32,21 @@ export type SettingsMoveSourcesResult = {
|
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Read the other host's legacy protection for recreating a missing settings
|
|
35
|
-
* file
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
35
|
+
* file, from the store a default-target move would read for it: its default
|
|
36
|
+
* store, through its current custody and state layout, without seeding a
|
|
37
|
+
* vault, taking locks or writing anything. Under the default target, a local
|
|
38
|
+
* store that doesn't exist returns undefined: that host never ran here and
|
|
39
|
+
* has no set to keep.
|
|
40
|
+
*
|
|
41
|
+
* Anything else that can't name or read the peer's set throws, so the
|
|
42
|
+
* caller treats it as unknown and never as "no set":
|
|
43
|
+
* - a store that exists but can't be read, including an unreadable custody
|
|
44
|
+
* or layout, and vault settings that were never seeded;
|
|
45
|
+
* - a private XDG_CONFIG_HOME, for which a move reads only its own store;
|
|
46
|
+
* - the peer's own path overrides set in this process, since the peer may
|
|
47
|
+
* run with them or without them;
|
|
48
|
+
* - under an explicit target, a default store that doesn't exist: a peer
|
|
49
|
+
* sharing that file may keep a private store this process can't see.
|
|
41
50
|
*/
|
|
42
51
|
export declare function readPeerLegacySettingsProtection(options: SettingsPathOptions & {
|
|
43
52
|
host: SettingsHost;
|
|
@@ -6,7 +6,13 @@ export interface SettingsProtectionCopyEntry {
|
|
|
6
6
|
readAt: number;
|
|
7
7
|
values: SettingsProtectionValues;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* This host's complete set from the applied copy. A copy file that doesn't
|
|
11
|
+
* exist, or one without an entry for this host, returns undefined: there is
|
|
12
|
+
* no saved set. A copy that exists but can't be read, isn't valid JSON, or
|
|
13
|
+
* holds an invalid entry for this host throws instead, so callers can tell an
|
|
14
|
+
* unknown set from an absent one. Never returns a partial protection set.
|
|
15
|
+
*/
|
|
10
16
|
export declare function readSettingsProtectionCopy(file: string, host: SettingsHost): Promise<SettingsProtectionValues | undefined>;
|
|
11
17
|
/** Merge only the writer's host while holding the copy's cross-process lock. */
|
|
12
18
|
export declare function writeSettingsProtectionCopy(file: string, host: SettingsHost, entry: SettingsProtectionCopyEntry, lockTimeoutMs?: number, publicationOptions?: PublicationOptions): Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type OpenSettingsOptions, type ReportEntry, type SettingsEdit, type SettingsHandle, type UpdateResult, type ValueOf } from "./internal-types/settings/index.js";
|
|
2
|
+
import { type ClaudeGatewayIgnored } from './gateway.ts';
|
|
2
3
|
import { type SettingsKey, settingsDefinition } from './settings-definition.ts';
|
|
3
4
|
import type { SettingsHost } from './settings-paths.ts';
|
|
4
5
|
import { writeSettingsProtectionCopy } from './settings-protection-copy.ts';
|
|
@@ -6,43 +7,49 @@ export type SettingsValues = {
|
|
|
6
7
|
[K in SettingsKey]: ValueOf<(typeof settingsDefinition.settings)[K]['value']>;
|
|
7
8
|
};
|
|
8
9
|
export declare const SETTINGS_PROTECTION_KEYS: readonly ["max_same_account_wait", "quota_minimum_remaining_five_hour", "quota_minimum_remaining_seven_day", "quota_minimum_remaining_scoped", "quota_fail_closed_on_unknown_quota", "killswitch_enabled", "killswitch_default_five_hour", "killswitch_default_seven_day", "killswitch_default_scoped", "killswitch_account_floors"];
|
|
10
|
+
/**
|
|
11
|
+
* The gateway settings are validated together. Any problem with either one
|
|
12
|
+
* means no gateway at all: model requests go directly to api.anthropic.com,
|
|
13
|
+
* never to a last-good or partly valid gateway.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SETTINGS_GATEWAY_KEYS: readonly ["gateway_url", "gateway_headers"];
|
|
9
16
|
export type SettingsProtectionValues = Pick<SettingsValues, (typeof SETTINGS_PROTECTION_KEYS)[number]>;
|
|
10
17
|
export type SettingsProtectionRung = 0 | 1 | 2 | 3;
|
|
11
18
|
export declare class SettingsRecreationRefusal extends Error {
|
|
12
19
|
constructor(file: string);
|
|
13
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A write into an existing settings file by a host that has not adopted it
|
|
23
|
+
* (its import check has not passed). The file may protect less than the
|
|
24
|
+
* host's legacy store, so the write is refused under the writer lock; the
|
|
25
|
+
* caller reports the same refusal as while the host is held by that check.
|
|
26
|
+
*/
|
|
27
|
+
export declare class SettingsAdoptionRefusal extends Error {
|
|
28
|
+
readonly file: string;
|
|
29
|
+
constructor(file: string);
|
|
30
|
+
}
|
|
14
31
|
export interface SettingsUpdateOptions {
|
|
15
32
|
/** Only menu writes and setup with a <target>.moved marker and no user file may create it. */
|
|
16
33
|
createMissing?: boolean;
|
|
17
34
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The edits were planned from a missing file (a floor list started from
|
|
24
|
-
* the recreation's list). The write is refused as busy if a file exists.
|
|
25
|
-
*/
|
|
26
|
-
expectMissing?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Setup runs while every host is stopped. When the other host then has no
|
|
29
|
-
* recoverable protection set (no applied copy and no legacy store, rather
|
|
30
|
-
* than an unreadable one), recreation carries the writer's set instead of
|
|
31
|
-
* refusing. Running hosts never pass it: a running peer at the strictest
|
|
32
|
-
* set would be loosened.
|
|
35
|
+
* This write is the host's import into the file (the import check, or
|
|
36
|
+
* setup filling the file from the legacy store), which by design runs
|
|
37
|
+
* before the host adopts the file. Every other write by a host lease that
|
|
38
|
+
* has not adopted the file is refused when the file exists.
|
|
33
39
|
*/
|
|
34
|
-
|
|
40
|
+
importing?: boolean;
|
|
35
41
|
}
|
|
36
42
|
export interface SettingsProtectionRecovery {
|
|
37
|
-
/** Return only this host's complete set; missing
|
|
43
|
+
/** Return only this host's complete set; a missing copy returns undefined, an unreadable or corrupt one throws. */
|
|
38
44
|
readAppliedCopy?: (host: SettingsHost) => Promise<SettingsProtectionValues | undefined>;
|
|
39
45
|
/** Read this runtime's local or vault settings store, as selected by its current enrollment mode. */
|
|
40
46
|
readLegacyProtection?: (host: SettingsHost) => Promise<SettingsProtectionValues | undefined>;
|
|
41
47
|
/**
|
|
42
48
|
* Read the other host's own legacy store through that host's current custody
|
|
43
49
|
* (see `readPeerLegacySettingsProtection`). Recreating a missing file uses it
|
|
44
|
-
* to learn the other host's protection
|
|
45
|
-
*
|
|
50
|
+
* to learn the other host's protection. Without it, that host's set is
|
|
51
|
+
* unknown and recreation is refused: an absent reader never means the
|
|
52
|
+
* other host has nothing to protect.
|
|
46
53
|
*/
|
|
47
54
|
readPeerLegacyProtection?: (host: SettingsHost) => Promise<SettingsProtectionValues | undefined>;
|
|
48
55
|
}
|
|
@@ -63,6 +70,12 @@ export interface SettingsFileStatus {
|
|
|
63
70
|
model: string;
|
|
64
71
|
}[];
|
|
65
72
|
readonly duplicateKeys: readonly string[];
|
|
73
|
+
/**
|
|
74
|
+
* Set when the file names a gateway that is not used: the file is not the
|
|
75
|
+
* default settings file of the operating system account, or that
|
|
76
|
+
* account's home folder could not be found.
|
|
77
|
+
*/
|
|
78
|
+
readonly gatewayIgnored?: ClaudeGatewayIgnored;
|
|
66
79
|
}
|
|
67
80
|
export interface SettingsGeneration {
|
|
68
81
|
readonly id: number;
|
|
@@ -76,6 +89,8 @@ export interface SettingsGeneration {
|
|
|
76
89
|
readonly contexts: Readonly<Record<SettingsHost, SettingsContextValues>>;
|
|
77
90
|
readonly report: readonly ReportEntry[];
|
|
78
91
|
readonly fileStatus: SettingsFileStatus;
|
|
92
|
+
/** See SettingsFileStatus.gatewayIgnored. */
|
|
93
|
+
readonly gatewayIgnored?: ClaudeGatewayIgnored;
|
|
79
94
|
/** Recover an unusable set as a whole from last-good values or startup recovery, never per key. */
|
|
80
95
|
readonly protection: Readonly<Record<SettingsHost, {
|
|
81
96
|
readonly usable: boolean;
|
|
@@ -97,7 +112,15 @@ export interface SettingsService {
|
|
|
97
112
|
/** Every underlying user-file watch callback, even if resolved values stay identical. */
|
|
98
113
|
onFileEvent?(listener: () => void): () => void;
|
|
99
114
|
refresh(): Promise<void>;
|
|
100
|
-
update(edits:
|
|
115
|
+
update(edits: SettingsUpdate, host: SettingsHost, options?: SettingsUpdateOptions): Promise<UpdateResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Called once the acting host has passed its import check for this file
|
|
118
|
+
* (after its `adopted` option turned true): the lease records the
|
|
119
|
+
* generation it holds as that host's last-good set at once, before the
|
|
120
|
+
* applied copy is saved, so a failed copy write leaves no stale window.
|
|
121
|
+
* Does nothing while `adopted` still returns false.
|
|
122
|
+
*/
|
|
123
|
+
noteAdoption?(): void;
|
|
101
124
|
dispose(): Promise<void>;
|
|
102
125
|
}
|
|
103
126
|
export type SettingsChangeListener = (generation: SettingsGeneration) => void | Promise<void>;
|
|
@@ -109,6 +132,18 @@ export interface SettingsServiceOptions {
|
|
|
109
132
|
separateInstall?: boolean;
|
|
110
133
|
lockTimeoutMs?: number;
|
|
111
134
|
protection?: SettingsProtectionRecovery;
|
|
135
|
+
/**
|
|
136
|
+
* False while the acting host has not passed its import check for this
|
|
137
|
+
* file (see `importSettingsHostStore`), so it does not use the file yet.
|
|
138
|
+
* Until then the file's values are never this host's last-good protection:
|
|
139
|
+
* a file it has not imported may protect less than its legacy store, so a
|
|
140
|
+
* missing or unusable file recovers this host's set from the ladder (its
|
|
141
|
+
* applied copy, then its legacy store, then the strictest set). Nor does
|
|
142
|
+
* the lease save an applied copy from it, and a write into the existing
|
|
143
|
+
* file is refused unless it is the host's import. Omitted means the host
|
|
144
|
+
* has not adopted the file: every production caller passes it explicitly.
|
|
145
|
+
*/
|
|
146
|
+
adopted?: () => boolean;
|
|
112
147
|
/** Dependency seams for deterministic file-race and no-I/O tests. */
|
|
113
148
|
dependencies?: {
|
|
114
149
|
open?: (options: OpenSettingsOptions) => CoreSettingsHandle;
|
|
@@ -116,21 +151,19 @@ export interface SettingsServiceOptions {
|
|
|
116
151
|
writeAppliedCopy?: typeof writeSettingsProtectionCopy;
|
|
117
152
|
/** Schedule an off-request re-read; return a cancellation function. */
|
|
118
153
|
schedule?: (callback: () => void, delayMs: number) => () => void;
|
|
154
|
+
/** Test seam: the file the gateway is honoured from (gatewaySettingsFile). */
|
|
155
|
+
gatewaySettingsFile?: () => string | undefined | Promise<string | undefined>;
|
|
119
156
|
};
|
|
120
157
|
}
|
|
158
|
+
/** The levels at which a parsed settings document sets each key; values and their validity remain common-auth's responsibility. */
|
|
159
|
+
export declare function settingsFileLevels(raw: Record<string, unknown>): SettingsFileLevels;
|
|
121
160
|
/** One host's whole protection set, as the recreation planner receives it. */
|
|
122
161
|
export interface SettingsRecreationSide {
|
|
123
162
|
host: SettingsHost;
|
|
124
163
|
values: SettingsProtectionValues;
|
|
125
164
|
}
|
|
126
|
-
/**
|
|
127
|
-
|
|
128
|
-
* has no `level`; 0.49 adds it, and only then can a recreation write a value
|
|
129
|
-
* for one host. Until then recreation accepts plans whose edits carry none.
|
|
130
|
-
*/
|
|
131
|
-
export type SettingsLevelEdit = SettingsEdit & {
|
|
132
|
-
level?: 'default' | SettingsHost;
|
|
133
|
-
};
|
|
165
|
+
/** A shared-settings edit, including an explicit default or host level. */
|
|
166
|
+
export type SettingsLevelEdit = SettingsEdit;
|
|
134
167
|
/**
|
|
135
168
|
* The protection edits for a recreated file, as a pure function of both
|
|
136
169
|
* hosts' whole sets, so each host resolves exactly its own set from the new
|
|
@@ -157,7 +190,7 @@ export declare function planSettingsRecreation(writer: SettingsRecreationSide, p
|
|
|
157
190
|
export declare function settingsRecreationForWriter(values: SettingsProtectionValues, host: SettingsHost): SettingsLevelEdit[];
|
|
158
191
|
/**
|
|
159
192
|
* The floor list a recreation writes when the other host applies the same
|
|
160
|
-
* floors as `host
|
|
193
|
+
* floors as `host`.
|
|
161
194
|
*/
|
|
162
195
|
export declare function settingsRecreationFloors(values: SettingsProtectionValues, host: SettingsHost): SettingsProtectionValues['killswitch_account_floors'];
|
|
163
196
|
/** One host's protection set and where it came from, for planning a recreation. */
|
|
@@ -173,16 +206,17 @@ export interface SettingsRecreationInput {
|
|
|
173
206
|
*/
|
|
174
207
|
none?: boolean;
|
|
175
208
|
}
|
|
176
|
-
export type SettingsRecreationRefusalReason = 'own-unknown' | 'peer-unknown'
|
|
209
|
+
export type SettingsRecreationRefusalReason = 'own-unknown' | 'peer-unknown';
|
|
177
210
|
/**
|
|
178
|
-
* What a menu write that finds the file missing does, as a pure
|
|
179
|
-
* both hosts' sets: the protection edits it carries, or why it
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
211
|
+
* What a menu write or setup that finds the file missing does, as a pure
|
|
212
|
+
* function of both hosts' sets: the protection edits it carries, or why it
|
|
213
|
+
* is refused. Only a peer known to have no set (it never ran) takes the
|
|
214
|
+
* writer's. A peer whose set is unknown refuses the write, whether or not
|
|
215
|
+
* the hosts are running, so its protection is never replaced by the
|
|
216
|
+
* writer's. Otherwise both known sets are carried together, with host levels
|
|
217
|
+
* preserving any differing values.
|
|
184
218
|
*/
|
|
185
|
-
export declare function planSettingsFileRecreation(writer: SettingsRecreationInput, peer: SettingsRecreationInput
|
|
219
|
+
export declare function planSettingsFileRecreation(writer: SettingsRecreationInput, peer: SettingsRecreationInput): {
|
|
186
220
|
edits: SettingsLevelEdit[];
|
|
187
221
|
} | {
|
|
188
222
|
refused: SettingsRecreationRefusalReason;
|
|
@@ -192,13 +226,23 @@ export type SettingsWriteState = {
|
|
|
192
226
|
status: 'missing';
|
|
193
227
|
} | {
|
|
194
228
|
status: 'ready';
|
|
229
|
+
document: unknown;
|
|
195
230
|
};
|
|
231
|
+
/** Menu edits run under the writer lock; a missing file also supplies its protection carry. */
|
|
232
|
+
export type SettingsUpdatePlan = (current: SettingsWriteState, carry?: readonly SettingsEdit[]) => readonly SettingsEdit[];
|
|
233
|
+
export type SettingsUpdate = readonly SettingsEdit[] | SettingsUpdatePlan;
|
|
196
234
|
/**
|
|
197
235
|
* The edits for one menu write, as a pure function of the file it finds:
|
|
198
236
|
* protection is carried only into a missing file, and an existing file keeps
|
|
199
237
|
* its own. `carry` throws when recreation must be refused.
|
|
200
238
|
*/
|
|
201
239
|
export declare function planSettingsMenuWrite(current: SettingsWriteState, edits: readonly SettingsEdit[], carry: () => readonly SettingsEdit[]): readonly SettingsEdit[];
|
|
240
|
+
/**
|
|
241
|
+
* Why `host` can't use the file, in plain words for a refused menu write, or
|
|
242
|
+
* undefined when it can (or the file is missing). It names at most a
|
|
243
|
+
* declared setting, never a value: file contents may hold secrets.
|
|
244
|
+
*/
|
|
245
|
+
export declare function settingsFileProblem(generation: SettingsGeneration, host: SettingsHost): string | undefined;
|
|
202
246
|
export declare function mostRestrictiveSettingsProtection(): SettingsProtectionValues;
|
|
203
247
|
/**
|
|
204
248
|
* Rungs 1-3 of the protection ladder, which need no open settings handle:
|
package/dist/settings-start.d.ts
CHANGED
|
@@ -21,8 +21,22 @@ export interface SettingsProtectionFallback {
|
|
|
21
21
|
readonly file: string;
|
|
22
22
|
readonly rung: 1 | 2 | 3;
|
|
23
23
|
readonly values: SettingsProtectionValues;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Off the request path: open the service again and run this host's import
|
|
26
|
+
* check; undefined while either still fails.
|
|
27
|
+
*/
|
|
25
28
|
reopen(): Promise<SettingsService | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* True when the service the last `reopen` returned was adopted for a
|
|
31
|
+
* missing file whose import is still owed: the runtime must pass the
|
|
32
|
+
* import check again before it uses a file that appears.
|
|
33
|
+
*/
|
|
34
|
+
importPending?(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Present with `resolveAuthority`: once it finds legacy mode, open the
|
|
37
|
+
* service only to notice a later move, without adopting the file.
|
|
38
|
+
*/
|
|
39
|
+
reopenLegacy?(): Promise<SettingsService | undefined>;
|
|
26
40
|
/**
|
|
27
41
|
* Present only when startup could not tell which source is in charge and
|
|
28
42
|
* fell back to the file as a precaution. Off the request path, asks again;
|
|
@@ -33,17 +47,35 @@ export interface SettingsProtectionFallback {
|
|
|
33
47
|
}
|
|
34
48
|
export interface StartedSettings {
|
|
35
49
|
mode: SettingsMode;
|
|
36
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* The settings file; empty only when no path could be resolved, which the
|
|
52
|
+
* shared-runtime key treats as "no settings file".
|
|
53
|
+
*/
|
|
37
54
|
file: string;
|
|
38
55
|
/** Open in user-file mode, and in legacy mode to notice another host's move. */
|
|
39
56
|
service?: SettingsService;
|
|
40
57
|
/** Set instead of `service` when the file is in charge but could not open. */
|
|
41
58
|
fallback?: SettingsProtectionFallback;
|
|
42
59
|
/**
|
|
43
|
-
* Set in legacy mode when the service could not open
|
|
44
|
-
*
|
|
60
|
+
* Set in legacy mode when the service could not open, or the enrollment or
|
|
61
|
+
* migration preflight refused: open it again off the request path, so a
|
|
62
|
+
* move another host publishes later is noticed.
|
|
63
|
+
*/
|
|
64
|
+
reopen?: SettingsReopen;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Opens the settings service again off the request path; undefined while it
|
|
68
|
+
* still cannot. `retryDelaysMs` asks the runtime to try sooner than its
|
|
69
|
+
* normal interval, one delay per attempt, before falling back to it.
|
|
70
|
+
*/
|
|
71
|
+
export interface SettingsReopen {
|
|
72
|
+
(): Promise<SettingsService | undefined>;
|
|
73
|
+
readonly retryDelaysMs?: readonly number[];
|
|
74
|
+
/**
|
|
75
|
+
* True once a reopen found that this host is a separate install: it never
|
|
76
|
+
* opens the shared settings file, and the runtime treats it as separate.
|
|
45
77
|
*/
|
|
46
|
-
|
|
78
|
+
readonly separate?: () => boolean;
|
|
47
79
|
}
|
|
48
80
|
/** Tests only: let the next failed start log its one warning again. */
|
|
49
81
|
export declare function __resetSettingsStartWarningForTest(): void;
|
|
@@ -52,6 +84,14 @@ export declare function __resetSettingsStartWarningForTest(): void;
|
|
|
52
84
|
* move, then opens the service. When either fails, a file that is (or may
|
|
53
85
|
* be) in charge gets the protection fallback, never plain legacy values,
|
|
54
86
|
* which may predate protection the user tightened in the file. Only a check
|
|
55
|
-
* that proves no move happened (no file, no marker) returns legacy mode
|
|
87
|
+
* that proves no move happened (no file, no marker) returns legacy mode, or
|
|
88
|
+
* a refused enrollment or migration preflight, while requests are refused.
|
|
89
|
+
*
|
|
90
|
+
* Every service it opens carries the import check (see
|
|
91
|
+
* `setSettingsAdoptionCheck`): a runtime that starts in legacy mode adopts
|
|
92
|
+
* a file that appears later only after that check passes. Until this host
|
|
93
|
+
* has adopted the file, its applied protection copy is not written from the
|
|
94
|
+
* file, so a file whose import is still owed never becomes the copy that
|
|
95
|
+
* recovery trusts.
|
|
56
96
|
*/
|
|
57
97
|
export declare function startSettings(options: StartSettingsOptions): Promise<StartedSettings>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepublishOnly": "bun run build"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cortexkit/common-auth": "0.
|
|
34
|
+
"@cortexkit/common-auth": "0.49.2"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cortexkit/claustrum-client": "0.18.0",
|
|
@@ -1075,6 +1075,15 @@
|
|
|
1075
1075
|
"additionalProperties": false
|
|
1076
1076
|
}
|
|
1077
1077
|
]
|
|
1078
|
+
},
|
|
1079
|
+
"gateway_url": {
|
|
1080
|
+
"type": "string"
|
|
1081
|
+
},
|
|
1082
|
+
"gateway_headers": {
|
|
1083
|
+
"type": "object",
|
|
1084
|
+
"additionalProperties": {
|
|
1085
|
+
"type": "string"
|
|
1086
|
+
}
|
|
1078
1087
|
}
|
|
1079
1088
|
},
|
|
1080
1089
|
"additionalProperties": false
|