@opengeni/config 1.1.0-canary.0 → 1.1.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/claude-subscription-capacity.d.ts +9 -0
- package/dist/claude-subscription-oauth.d.ts +17 -0
- package/dist/claude-subscription-usage.d.ts +13 -0
- package/dist/index.d.ts +802 -22
- package/dist/index.js +2309 -661
- package/dist/index.js.map +1 -1
- package/dist/managed-user-admission.d.ts +2 -0
- package/dist/subscription-account-selection.d.ts +17 -0
- package/package.json +4 -4
- package/src/claude-subscription-capacity.ts +129 -0
- package/src/claude-subscription-oauth.ts +33 -0
- package/src/claude-subscription-usage.ts +328 -0
- package/src/index.ts +2218 -342
- package/src/managed-user-admission.ts +11 -0
- package/src/subscription-account-selection.ts +36 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Deployment admission for native human accounts; never service credentials. */
|
|
2
|
+
export function managedUserEmailAllowed(
|
|
3
|
+
allowedUserEmails: readonly string[] | undefined,
|
|
4
|
+
email: unknown,
|
|
5
|
+
): boolean {
|
|
6
|
+
return (
|
|
7
|
+
allowedUserEmails === undefined ||
|
|
8
|
+
(typeof email === "string" &&
|
|
9
|
+
allowedUserEmails.some((allowed) => allowed.toLowerCase() === email.trim().toLowerCase()))
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Stable account affinity shared by subscription providers. Candidate order is durable creation order. */
|
|
2
|
+
export function subscriptionAccountShardIndex(sessionId: string, candidateCount: number): number {
|
|
3
|
+
if (!Number.isSafeInteger(candidateCount) || candidateCount <= 0)
|
|
4
|
+
throw new Error("Subscription shard candidate count must be positive");
|
|
5
|
+
let hash = 0x811c9dc5;
|
|
6
|
+
for (let index = 0; index < sessionId.length; index += 1) {
|
|
7
|
+
hash ^= sessionId.charCodeAt(index);
|
|
8
|
+
hash = Math.imul(hash, 0x01000193);
|
|
9
|
+
}
|
|
10
|
+
return (hash >>> 0) % candidateCount;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Manual pins are binding even when unavailable. Policy homes remain sticky only
|
|
15
|
+
* while rotation is on; an exhausted home re-shards over the eligible survivors.
|
|
16
|
+
* Selection never changes the pool's active pointer.
|
|
17
|
+
*/
|
|
18
|
+
export function selectSubscriptionAccount<T extends { id: string }>(input: {
|
|
19
|
+
sessionId: string;
|
|
20
|
+
eligible: readonly T[];
|
|
21
|
+
rotationEnabled: boolean;
|
|
22
|
+
activeCredentialId: string | null;
|
|
23
|
+
pinnedCredentialId: string | null;
|
|
24
|
+
pinSource: "manual" | "policy" | null;
|
|
25
|
+
}): T | null {
|
|
26
|
+
const pinned = input.eligible.find((account) => account.id === input.pinnedCredentialId);
|
|
27
|
+
if (input.pinnedCredentialId && input.pinSource !== "policy") return pinned ?? null;
|
|
28
|
+
if (!input.rotationEnabled)
|
|
29
|
+
return input.eligible.find((account) => account.id === input.activeCredentialId) ?? null;
|
|
30
|
+
return (
|
|
31
|
+
pinned ??
|
|
32
|
+
(input.eligible.length
|
|
33
|
+
? input.eligible[subscriptionAccountShardIndex(input.sessionId, input.eligible.length)]!
|
|
34
|
+
: null)
|
|
35
|
+
);
|
|
36
|
+
}
|