@cortexkit/anthropic-auth-core 2.16.3 → 2.16.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.js
CHANGED
|
@@ -2627,6 +2627,8 @@ async function request(operation) {
|
|
|
2627
2627
|
function wrapHostClient(client) {
|
|
2628
2628
|
const watchScoped = client.watchScoped?.bind(client);
|
|
2629
2629
|
const reportUsageScoped = client.reportUsageScoped?.bind(client);
|
|
2630
|
+
const reportCondition = client.reportCondition?.bind(client);
|
|
2631
|
+
const clearCondition = client.clearCondition?.bind(client);
|
|
2630
2632
|
return {
|
|
2631
2633
|
listScoped: (...args) => request(() => client.listScoped(...args)),
|
|
2632
2634
|
getScoped: (...args) => request(() => client.getScoped(...args)),
|
|
@@ -2647,6 +2649,12 @@ function wrapHostClient(client) {
|
|
|
2647
2649
|
...reportUsageScoped && {
|
|
2648
2650
|
reportUsageScoped: (...args) => request(() => reportUsageScoped(...args))
|
|
2649
2651
|
},
|
|
2652
|
+
...reportCondition && {
|
|
2653
|
+
reportCondition: (...args) => request(() => reportCondition(...args))
|
|
2654
|
+
},
|
|
2655
|
+
...clearCondition && {
|
|
2656
|
+
clearCondition: (...args) => request(() => clearCondition(...args))
|
|
2657
|
+
},
|
|
2650
2658
|
...client.insula && {
|
|
2651
2659
|
insula: wrapInsula(client.insula)
|
|
2652
2660
|
}
|
|
@@ -3732,6 +3740,27 @@ function rowFactsOf(row, { includeProviderIds = true } = {}) {
|
|
|
3732
3740
|
authMethod: metadata.authMethod
|
|
3733
3741
|
};
|
|
3734
3742
|
}
|
|
3743
|
+
function isVaultConditionReason(reason) {
|
|
3744
|
+
return reason === "provider_verification_required" || reason === "provider_ineligible";
|
|
3745
|
+
}
|
|
3746
|
+
function vaultConditionOf(row) {
|
|
3747
|
+
const condition = row.condition;
|
|
3748
|
+
if (!condition)
|
|
3749
|
+
return;
|
|
3750
|
+
const { reason, sinceMs } = condition;
|
|
3751
|
+
if (isVaultConditionReason(reason) && Number.isSafeInteger(sinceMs) && sinceMs > 0)
|
|
3752
|
+
return Object.freeze({ reason, sinceMs });
|
|
3753
|
+
return;
|
|
3754
|
+
}
|
|
3755
|
+
function httpsActionUrl(actionUrl) {
|
|
3756
|
+
if (typeof actionUrl !== "string")
|
|
3757
|
+
return;
|
|
3758
|
+
try {
|
|
3759
|
+
if (new URL(actionUrl).protocol === "https:")
|
|
3760
|
+
return actionUrl;
|
|
3761
|
+
} catch {}
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3735
3764
|
function grantReachOf(listed) {
|
|
3736
3765
|
const { grants, grantTuples } = listed;
|
|
3737
3766
|
if (grants === undefined || grantTuples === undefined)
|
|
@@ -3752,6 +3781,10 @@ class ClaustrumScopedCustody {
|
|
|
3752
3781
|
#logger;
|
|
3753
3782
|
#provenance = new WeakMap;
|
|
3754
3783
|
#reports = new WeakMap;
|
|
3784
|
+
#conditionReports = new Map;
|
|
3785
|
+
#conditionClears = new Map;
|
|
3786
|
+
#conditionsUnsupported = false;
|
|
3787
|
+
#pendingConditionCalls = 0;
|
|
3755
3788
|
#kept = new Map;
|
|
3756
3789
|
#keptAttempts = new WeakMap;
|
|
3757
3790
|
#usage;
|
|
@@ -3769,8 +3802,9 @@ class ClaustrumScopedCustody {
|
|
|
3769
3802
|
#probeDelay = 2000;
|
|
3770
3803
|
#closed = false;
|
|
3771
3804
|
#discoveredView;
|
|
3805
|
+
#discoveredConditions = new Map;
|
|
3772
3806
|
#watches = new Set;
|
|
3773
|
-
#
|
|
3807
|
+
#shutdownWork = new Set;
|
|
3774
3808
|
#warnShutdown;
|
|
3775
3809
|
#onDrainTimeout;
|
|
3776
3810
|
#disposing;
|
|
@@ -3820,6 +3854,7 @@ class ClaustrumScopedCustody {
|
|
|
3820
3854
|
if (hasVaultHost() && !isVaultHostClient(next))
|
|
3821
3855
|
throw new ClaustrumUnreachableError;
|
|
3822
3856
|
this.#client = next;
|
|
3857
|
+
this.#conditionsUnsupported = false;
|
|
3823
3858
|
for (const watch of this.#watches)
|
|
3824
3859
|
watch.restart();
|
|
3825
3860
|
}
|
|
@@ -3886,12 +3921,12 @@ class ClaustrumScopedCustody {
|
|
|
3886
3921
|
phase: "token read begin"
|
|
3887
3922
|
});
|
|
3888
3923
|
const pending = this.#readToken();
|
|
3889
|
-
this.#
|
|
3924
|
+
this.#shutdownWork.add(pending);
|
|
3890
3925
|
let value;
|
|
3891
3926
|
try {
|
|
3892
3927
|
value = await pending;
|
|
3893
3928
|
} finally {
|
|
3894
|
-
this.#
|
|
3929
|
+
this.#shutdownWork.delete(pending);
|
|
3895
3930
|
if (phaseDiagnostics.hasSubscribers)
|
|
3896
3931
|
phaseDiagnostics.publish({
|
|
3897
3932
|
logger: this.#logger,
|
|
@@ -3938,6 +3973,11 @@ class ClaustrumScopedCustody {
|
|
|
3938
3973
|
async discover(signal) {
|
|
3939
3974
|
const inventory = await this.#list(signal);
|
|
3940
3975
|
this.#discoveredView = inventory.view;
|
|
3976
|
+
this.#discoveredConditions.clear();
|
|
3977
|
+
for (const { credentialId, condition } of inventory.credentials) {
|
|
3978
|
+
if (condition)
|
|
3979
|
+
this.#discoveredConditions.set(credentialId, condition);
|
|
3980
|
+
}
|
|
3941
3981
|
return inventory;
|
|
3942
3982
|
}
|
|
3943
3983
|
async#list(signal) {
|
|
@@ -4011,6 +4051,7 @@ class ClaustrumScopedCustody {
|
|
|
4011
4051
|
});
|
|
4012
4052
|
continue;
|
|
4013
4053
|
}
|
|
4054
|
+
const condition = vaultConditionOf(row);
|
|
4014
4055
|
credentials.push(Object.freeze({
|
|
4015
4056
|
credentialId: row.id,
|
|
4016
4057
|
credentialType: type,
|
|
@@ -4020,7 +4061,8 @@ class ClaustrumScopedCustody {
|
|
|
4020
4061
|
},
|
|
4021
4062
|
state: row.state,
|
|
4022
4063
|
...row.email !== undefined && { email: row.email },
|
|
4023
|
-
...row.orgName !== undefined && { orgName: row.orgName }
|
|
4064
|
+
...row.orgName !== undefined && { orgName: row.orgName },
|
|
4065
|
+
...condition && { condition }
|
|
4024
4066
|
}));
|
|
4025
4067
|
}
|
|
4026
4068
|
for (const record2 of skipped)
|
|
@@ -4342,6 +4384,81 @@ class ClaustrumScopedCustody {
|
|
|
4342
4384
|
throw error;
|
|
4343
4385
|
}
|
|
4344
4386
|
}
|
|
4387
|
+
reportCondition(attempt, input) {
|
|
4388
|
+
const provenance = this.#provenance.get(attempt);
|
|
4389
|
+
if (!provenance)
|
|
4390
|
+
return Promise.reject(new ClaustrumConsumerError("no-receipt", "Claustrum condition report requires an original dispatch receipt"));
|
|
4391
|
+
const { reason, providerStatus } = input ?? {};
|
|
4392
|
+
if (this.#closed || this.#keptAttempts.has(attempt) || providerStatus !== 403 || !isVaultConditionReason(reason))
|
|
4393
|
+
return Promise.resolve("skipped");
|
|
4394
|
+
const { credentialId, recordVersion } = attempt;
|
|
4395
|
+
const actionUrl = reason === "provider_verification_required" ? httpsActionUrl(input.actionUrl) : undefined;
|
|
4396
|
+
return this.#conditionOnce(this.#conditionReports, JSON.stringify([credentialId, recordVersion, reason]), { credentialId, recordVersion, reason }, (client) => client.reportCondition?.({
|
|
4397
|
+
credentialId,
|
|
4398
|
+
recordVersion,
|
|
4399
|
+
reason,
|
|
4400
|
+
providerStatus,
|
|
4401
|
+
...actionUrl !== undefined && { actionUrl },
|
|
4402
|
+
enrollmentToken: provenance.token
|
|
4403
|
+
}));
|
|
4404
|
+
}
|
|
4405
|
+
clearCondition(attempt) {
|
|
4406
|
+
const provenance = this.#provenance.get(attempt);
|
|
4407
|
+
if (!provenance)
|
|
4408
|
+
return Promise.reject(new ClaustrumConsumerError("no-receipt", "Claustrum condition clear requires an original dispatch receipt"));
|
|
4409
|
+
if (this.#closed || this.#keptAttempts.has(attempt))
|
|
4410
|
+
return Promise.resolve("skipped");
|
|
4411
|
+
const { credentialId, recordVersion } = attempt;
|
|
4412
|
+
const condition = this.#discoveredConditions.get(credentialId);
|
|
4413
|
+
if (!condition)
|
|
4414
|
+
return Promise.resolve("skipped");
|
|
4415
|
+
return this.#conditionOnce(this.#conditionClears, JSON.stringify([credentialId, condition.sinceMs]), { credentialId, recordVersion, reason: condition.reason }, (client) => client.clearCondition?.({
|
|
4416
|
+
credentialId,
|
|
4417
|
+
recordVersion,
|
|
4418
|
+
enrollmentToken: provenance.token
|
|
4419
|
+
}));
|
|
4420
|
+
}
|
|
4421
|
+
#conditionOnce(outcomes, key, details, send) {
|
|
4422
|
+
const previous = outcomes.get(key);
|
|
4423
|
+
if (previous)
|
|
4424
|
+
return previous;
|
|
4425
|
+
if (this.#conditionsUnsupported)
|
|
4426
|
+
return Promise.resolve("unsupported");
|
|
4427
|
+
const pending = Promise.resolve().then(async () => {
|
|
4428
|
+
const client = this.#client;
|
|
4429
|
+
if (this.#conditionsUnsupported)
|
|
4430
|
+
return "unsupported";
|
|
4431
|
+
try {
|
|
4432
|
+
const sent = send(client);
|
|
4433
|
+
if (!sent)
|
|
4434
|
+
return "unsupported";
|
|
4435
|
+
if (await sent === false)
|
|
4436
|
+
this.#debugCondition("scoped login condition not cleared", details);
|
|
4437
|
+
return "reported";
|
|
4438
|
+
} catch (error) {
|
|
4439
|
+
if (error instanceof ClaustrumCredentialError5 && error.code === "unknown_method") {
|
|
4440
|
+
if (client === this.#client)
|
|
4441
|
+
this.#conditionsUnsupported = true;
|
|
4442
|
+
return "unsupported";
|
|
4443
|
+
}
|
|
4444
|
+
this.#debugCondition("scoped login condition update failed", details);
|
|
4445
|
+
return "failed";
|
|
4446
|
+
}
|
|
4447
|
+
});
|
|
4448
|
+
outcomes.set(key, pending);
|
|
4449
|
+
this.#pendingConditionCalls++;
|
|
4450
|
+
this.#shutdownWork.add(pending);
|
|
4451
|
+
pending.then(() => {
|
|
4452
|
+
this.#pendingConditionCalls--;
|
|
4453
|
+
this.#shutdownWork.delete(pending);
|
|
4454
|
+
});
|
|
4455
|
+
return pending;
|
|
4456
|
+
}
|
|
4457
|
+
#debugCondition(message, details) {
|
|
4458
|
+
try {
|
|
4459
|
+
this.#logger.debug(message, details);
|
|
4460
|
+
} catch {}
|
|
4461
|
+
}
|
|
4345
4462
|
watchRoster(options) {
|
|
4346
4463
|
this.#check();
|
|
4347
4464
|
const currentView = options.view ?? (() => this.#discoveredView);
|
|
@@ -4429,15 +4546,17 @@ class ClaustrumScopedCustody {
|
|
|
4429
4546
|
this.#watches.clear();
|
|
4430
4547
|
this.#kept.clear();
|
|
4431
4548
|
const usage = this.#usage.close();
|
|
4549
|
+
const keepClientOpen = usage !== undefined || this.#pendingConditionCalls > 0;
|
|
4432
4550
|
if (usage) {
|
|
4433
|
-
this.#
|
|
4434
|
-
usage.then(() => this.#
|
|
4435
|
-
}
|
|
4551
|
+
this.#shutdownWork.add(usage);
|
|
4552
|
+
usage.then(() => this.#shutdownWork.delete(usage));
|
|
4553
|
+
}
|
|
4554
|
+
if (!keepClientOpen)
|
|
4436
4555
|
this.#client.close();
|
|
4437
|
-
this.#disposing = drainShutdown(this.#
|
|
4556
|
+
this.#disposing = drainShutdown(this.#shutdownWork, (count) => (this.#onDrainTimeout ?? this.#warnShutdown)(count)).finally(() => {
|
|
4438
4557
|
this.#usage.drop();
|
|
4439
4558
|
this.#usageServed.clear();
|
|
4440
|
-
if (
|
|
4559
|
+
if (keepClientOpen)
|
|
4441
4560
|
this.#client.close();
|
|
4442
4561
|
});
|
|
4443
4562
|
}
|
|
@@ -6363,6 +6482,22 @@ class ClaustrumConsumer {
|
|
|
6363
6482
|
throw new ClaustrumConsumerError("no-receipt", "Claustrum dispatch receipt has no active owner");
|
|
6364
6483
|
await this.#custody.reportFailure(attempt, status, source);
|
|
6365
6484
|
}
|
|
6485
|
+
#issuingCustody(attempt) {
|
|
6486
|
+
const custody = this.#hub ? this.#issuedBy.get(attempt)?.custody : this.#custody;
|
|
6487
|
+
if (!custody)
|
|
6488
|
+
throw new ClaustrumConsumerError("no-receipt", "Claustrum dispatch receipt has no active owner");
|
|
6489
|
+
return custody;
|
|
6490
|
+
}
|
|
6491
|
+
async reportCondition(attempt, input) {
|
|
6492
|
+
if (this.#shutdown.signal.aborted)
|
|
6493
|
+
return "skipped";
|
|
6494
|
+
return this.#issuingCustody(attempt).reportCondition(attempt, input);
|
|
6495
|
+
}
|
|
6496
|
+
async clearCondition(attempt) {
|
|
6497
|
+
if (this.#shutdown.signal.aborted)
|
|
6498
|
+
return "skipped";
|
|
6499
|
+
return this.#issuingCustody(attempt).clearCondition(attempt);
|
|
6500
|
+
}
|
|
6366
6501
|
async send(routeId, dispatch, options) {
|
|
6367
6502
|
const signal = options.signal;
|
|
6368
6503
|
let served = await this.authorize(routeId, signal);
|
|
@@ -6885,6 +7020,16 @@ class ClaustrumDiscoveryHub {
|
|
|
6885
7020
|
check();
|
|
6886
7021
|
return custody.reportFailure(attempt, status, source);
|
|
6887
7022
|
},
|
|
7023
|
+
reportCondition: async (attempt, input) => {
|
|
7024
|
+
if (state.released || generation.ended)
|
|
7025
|
+
return "skipped";
|
|
7026
|
+
return custody.reportCondition(attempt, input);
|
|
7027
|
+
},
|
|
7028
|
+
clearCondition: async (attempt) => {
|
|
7029
|
+
if (state.released || generation.ended)
|
|
7030
|
+
return "skipped";
|
|
7031
|
+
return custody.clearCondition(attempt);
|
|
7032
|
+
},
|
|
6888
7033
|
reportUsage: (input) => {
|
|
6889
7034
|
if (!state.released && !generation.ended)
|
|
6890
7035
|
custody.reportUsage(input);
|
|
@@ -7639,8 +7784,6 @@ function candidateView(candidates) {
|
|
|
7639
7784
|
accounts.push({ account_id: accountId, credential_id: credentialId });
|
|
7640
7785
|
}
|
|
7641
7786
|
}
|
|
7642
|
-
if (accounts.length === 0)
|
|
7643
|
-
return;
|
|
7644
7787
|
const lines = accounts.map(({ account_id, credential_id }) => Buffer.from(`${account_id} ${credential_id}
|
|
7645
7788
|
`, "utf8")).sort(Buffer.compare);
|
|
7646
7789
|
const hash2 = createHash4("sha256");
|
|
@@ -7732,7 +7875,7 @@ async function askRouting(input) {
|
|
|
7732
7875
|
request2.warm_credential = warmCredentialId;
|
|
7733
7876
|
}
|
|
7734
7877
|
const candidates = candidateView(input.candidates);
|
|
7735
|
-
if (candidates)
|
|
7878
|
+
if (candidates.accounts.length > 0 || request2.mode === "continue")
|
|
7736
7879
|
request2.candidates = candidates;
|
|
7737
7880
|
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
7738
7881
|
if (!isObject(pending) || typeof pending.then !== "function")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClaustrumReporterSource } from '@cortexkit/claustrum-client';
|
|
2
2
|
import type { QuotaObservation } from '../quota/index.js';
|
|
3
3
|
import type { RoutingRow } from '../routing/index.js';
|
|
4
|
-
import { type ClaustrumFamily, type ClaustrumScopedAttempt, type ClaustrumScopedClient, type IdentityParser, type KeptReceiptState, type VaultGrantReach } from './custody.js';
|
|
4
|
+
import { type ClaustrumFamily, type ClaustrumScopedAttempt, type ClaustrumScopedClient, type IdentityParser, type KeptReceiptState, type VaultConditionOutcome, type VaultConditionReason, type VaultGrantReach } from './custody.js';
|
|
5
5
|
import { type ClaustrumLogger } from './errors.js';
|
|
6
6
|
import type { CustodyLease } from './hub.js';
|
|
7
7
|
import { type InsulaQuotaOptions, type InsulaQuotaResult } from './insula.js';
|
|
@@ -246,6 +246,25 @@ export declare class ClaustrumConsumer<Q = QuotaObservation> {
|
|
|
246
246
|
}): void;
|
|
247
247
|
usageReportState(): ClaustrumUsageReportState;
|
|
248
248
|
reportFailure(attempt: ClaustrumScopedAttempt, status: number, source: ClaustrumReporterSource): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Report a provider login condition through the custody that issued the
|
|
251
|
+
* receipt; see `ClaustrumScopedCustody.reportCondition`. Bookkeeping: call it
|
|
252
|
+
* after handing back the reply, never on the request path. It resolves
|
|
253
|
+
* `skipped` after shutdown and rejects only with `no-receipt` for a receipt
|
|
254
|
+
* no live custody of this consumer issued.
|
|
255
|
+
*/
|
|
256
|
+
reportCondition(attempt: ClaustrumScopedAttempt, input: {
|
|
257
|
+
reason: VaultConditionReason;
|
|
258
|
+
providerStatus: number;
|
|
259
|
+
actionUrl?: string;
|
|
260
|
+
}): Promise<VaultConditionOutcome>;
|
|
261
|
+
/**
|
|
262
|
+
* Clear a listed login condition through the custody that issued the
|
|
263
|
+
* receipt; see `ClaustrumScopedCustody.clearCondition`. Safe to call after
|
|
264
|
+
* every successful reply: it sends nothing unless the login is marked.
|
|
265
|
+
* Same `skipped` and `no-receipt` rules as `reportCondition`.
|
|
266
|
+
*/
|
|
267
|
+
clearCondition(attempt: ClaustrumScopedAttempt): Promise<VaultConditionOutcome>;
|
|
249
268
|
/**
|
|
250
269
|
* Send on a vault route. `dispatch` builds and sends the request with the
|
|
251
270
|
* receipt's token and may be called twice, so it must be able to rebuild
|
|
@@ -3,8 +3,12 @@ import { type ClaustrumLogger } from './errors.js';
|
|
|
3
3
|
import type { InsulaUsageTransport } from './insula.js';
|
|
4
4
|
import { type ClaustrumUsageReading, type ClaustrumUsageReportState, type ScopedUsageSource } from './usage.js';
|
|
5
5
|
import { type ScopedWatchSource, type WatchMode } from './watch.js';
|
|
6
|
-
type ScopedRow = Omit<ScopedInventoryRow, 'authMethod'> & {
|
|
6
|
+
type ScopedRow = Omit<ScopedInventoryRow, 'authMethod' | 'condition'> & {
|
|
7
7
|
readonly authMethod?: string;
|
|
8
|
+
readonly condition?: {
|
|
9
|
+
readonly reason: string;
|
|
10
|
+
readonly sinceMs: number;
|
|
11
|
+
};
|
|
8
12
|
};
|
|
9
13
|
type ScopedInventory = Omit<Awaited<ReturnType<ClaustrumClient['listScoped']>>, 'rows'> & {
|
|
10
14
|
readonly rows: readonly ScopedRow[];
|
|
@@ -12,13 +16,29 @@ type ScopedInventory = Omit<Awaited<ReturnType<ClaustrumClient['listScoped']>>,
|
|
|
12
16
|
/**
|
|
13
17
|
* claustrum-client adds watchScoped in 0.12.0 and reportUsageScoped in 0.14.0.
|
|
14
18
|
* Older clients keep polling and simply do not send reply quota readings.
|
|
19
|
+
* The optional login condition methods match 0.21.0 without requiring it.
|
|
15
20
|
*/
|
|
16
21
|
export type ClaustrumScopedClient = Pick<ClaustrumClient, 'getScoped' | 'reportAuthFailureScoped' | 'close'> & {
|
|
17
22
|
listScoped(enrollmentToken?: string): Promise<ScopedInventory>;
|
|
23
|
+
reportCondition?(input: {
|
|
24
|
+
credentialId: string;
|
|
25
|
+
recordVersion: number;
|
|
26
|
+
reason: string;
|
|
27
|
+
providerStatus: number;
|
|
28
|
+
actionUrl?: string;
|
|
29
|
+
enrollmentToken?: string;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
clearCondition?(input: {
|
|
32
|
+
credentialId: string;
|
|
33
|
+
recordVersion: number;
|
|
34
|
+
enrollmentToken?: string;
|
|
35
|
+
}): Promise<boolean>;
|
|
18
36
|
insula?: InsulaUsageTransport;
|
|
19
37
|
} & ScopedWatchSource & ScopedUsageSource;
|
|
20
38
|
/** The two credential types a plugin's family can hold; routing differs by type. */
|
|
21
39
|
export type VaultCredentialType = 'oauth' | 'api_key';
|
|
40
|
+
export type VaultConditionReason = 'provider_verification_required' | 'provider_ineligible';
|
|
41
|
+
export type VaultConditionOutcome = 'reported' | 'skipped' | 'unsupported' | 'failed';
|
|
22
42
|
/**
|
|
23
43
|
* Which vault rows belong to this plugin. `refreshAdapter` classifies an OAuth
|
|
24
44
|
* row by the protocol it speaks; `category` is the grant that authorizes this
|
|
@@ -69,6 +89,10 @@ export interface VaultCredential {
|
|
|
69
89
|
readonly state: string;
|
|
70
90
|
readonly email?: string;
|
|
71
91
|
readonly orgName?: string;
|
|
92
|
+
readonly condition?: {
|
|
93
|
+
readonly reason: VaultConditionReason;
|
|
94
|
+
readonly sinceMs: number;
|
|
95
|
+
};
|
|
72
96
|
}
|
|
73
97
|
/**
|
|
74
98
|
* Why a listed vault record could not be used. A closed set of fixed codes, so
|
|
@@ -339,6 +363,20 @@ export declare class ClaustrumScopedCustody {
|
|
|
339
363
|
* it. A receipt this custody did not issue is refused rather than reported.
|
|
340
364
|
*/
|
|
341
365
|
reportFailure(attempt: ClaustrumScopedAttempt, status: number, reporterSource: ClaustrumReporterSource): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Report a provider login condition as bookkeeping after handing back the
|
|
368
|
+
* reply, never on the request path. Pass the receipt actually sent with it.
|
|
369
|
+
*/
|
|
370
|
+
reportCondition(attempt: ClaustrumScopedAttempt, input: {
|
|
371
|
+
reason: VaultConditionReason;
|
|
372
|
+
providerStatus: number;
|
|
373
|
+
actionUrl?: string;
|
|
374
|
+
}): Promise<VaultConditionOutcome>;
|
|
375
|
+
/**
|
|
376
|
+
* Clear a listed condition as bookkeeping after handing back a successful
|
|
377
|
+
* reply, never on the request path. Pass the receipt actually sent with it.
|
|
378
|
+
*/
|
|
379
|
+
clearCondition(attempt: ClaustrumScopedAttempt): Promise<VaultConditionOutcome>;
|
|
342
380
|
/**
|
|
343
381
|
* Watch this consumer's visible vault accounts instead of listing them on a
|
|
344
382
|
* short timer. Opens one `watchScoped` on this custody's client and calls
|
|
@@ -111,12 +111,13 @@ export interface ClaustrumHubMemberOptions<_Q = QuotaObservation> {
|
|
|
111
111
|
logger?: ClaustrumLogger;
|
|
112
112
|
}
|
|
113
113
|
/** What a lease may do with the shared custody. */
|
|
114
|
-
export type ClaustrumLeasedCustody = Pick<ClaustrumScopedCustody, 'authorize' | 'reportFailure' | 'reportUsage' | 'usageReportState' | 'forget' | 'keptReceiptState'>;
|
|
114
|
+
export type ClaustrumLeasedCustody = Pick<ClaustrumScopedCustody, 'authorize' | 'reportFailure' | 'reportCondition' | 'clearCondition' | 'reportUsage' | 'usageReportState' | 'forget' | 'keptReceiptState'>;
|
|
115
115
|
/**
|
|
116
116
|
* One acquisition of the hub's shared custody. `custody` throws `closed`
|
|
117
117
|
* after `release()`, and once the connection it belongs to ended for any
|
|
118
118
|
* reason, vault mode going off included. Best-effort `reportUsage` instead
|
|
119
|
-
* ignores reports through an ended lease
|
|
119
|
+
* ignores reports through an ended lease, and the condition calls resolve
|
|
120
|
+
* `skipped` through one. `release()` is idempotent.
|
|
120
121
|
*/
|
|
121
122
|
export interface CustodyLease {
|
|
122
123
|
readonly custody: ClaustrumLeasedCustody;
|
|
@@ -3,7 +3,7 @@ import type { ClaustrumScopedClient } from './custody.js';
|
|
|
3
3
|
export { ClaustrumCredentialError, type ClaustrumReporterSource, type EnrollmentTokenFile, } from '@cortexkit/claustrum-client';
|
|
4
4
|
export { ClaustrumUnreachableError, classifyVaultFailure, VAULT_FAILURE_CLASSES, type VaultFailureClass, } from './availability.js';
|
|
5
5
|
export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchState, DEFAULT_CONNECT_TIMEOUT_MS, type SendOptions, } from './consumer.js';
|
|
6
|
-
export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, VAULT_RECEIPT_WAIT_MS, VAULT_YOUNG_OUTAGE_MS, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
|
|
6
|
+
export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, VAULT_RECEIPT_WAIT_MS, VAULT_YOUNG_OUTAGE_MS, type VaultConditionOutcome, type VaultConditionReason, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
|
|
7
7
|
export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, type ClaustrumRequestedGrant, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, validEnrollmentDisplayName, validEnrollmentRequestedGrants, vaultAuthority, } from './enrollment.js';
|
|
8
8
|
export { ClaustrumConsumerError, type ClaustrumConsumerFailureKind, type ClaustrumLogger, } from './errors.js';
|
|
9
9
|
export { connectVaultHost, hasVaultHost, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from './host.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"prepublishOnly": "bun run build"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cortexkit/common-auth": "0.
|
|
34
|
+
"@cortexkit/common-auth": "0.56.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@cortexkit/claustrum-client": "0.
|
|
37
|
+
"@cortexkit/claustrum-client": "0.21.0",
|
|
38
38
|
"@cortexkit/private-files": "0.2.2",
|
|
39
39
|
"@cortexkit/subc-client": "^0.24",
|
|
40
40
|
"jsonc-parser": "^3.3.1",
|