@datacules/agent-identity 0.2.1
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/cjs/approval.js +157 -0
- package/dist/cjs/approval.js.map +1 -0
- package/dist/cjs/attestation.js +89 -0
- package/dist/cjs/attestation.js.map +1 -0
- package/dist/cjs/budget.js +110 -0
- package/dist/cjs/budget.js.map +1 -0
- package/dist/cjs/credentials.js +14 -0
- package/dist/cjs/credentials.js.map +1 -0
- package/dist/cjs/decision.js +30 -0
- package/dist/cjs/decision.js.map +1 -0
- package/dist/cjs/federation.js +55 -0
- package/dist/cjs/federation.js.map +1 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/providers.js +97 -0
- package/dist/cjs/providers.js.map +1 -0
- package/dist/cjs/rotation.js +127 -0
- package/dist/cjs/rotation.js.map +1 -0
- package/dist/cjs/router.js +216 -0
- package/dist/cjs/router.js.map +1 -0
- package/dist/cjs/schemas.js +127 -0
- package/dist/cjs/schemas.js.map +1 -0
- package/dist/cjs/types.js +4 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/approval.js +150 -0
- package/dist/esm/approval.js.map +1 -0
- package/dist/esm/attestation.js +83 -0
- package/dist/esm/attestation.js.map +1 -0
- package/dist/esm/budget.js +105 -0
- package/dist/esm/budget.js.map +1 -0
- package/dist/esm/credentials.js +11 -0
- package/dist/esm/credentials.js.map +1 -0
- package/dist/esm/decision.js +27 -0
- package/dist/esm/decision.js.map +1 -0
- package/dist/esm/federation.js +50 -0
- package/dist/esm/federation.js.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/providers.js +92 -0
- package/dist/esm/providers.js.map +1 -0
- package/dist/esm/react/index.js +2 -0
- package/dist/esm/react/index.js.map +1 -0
- package/dist/esm/react/useAgentIdentity.js +100 -0
- package/dist/esm/react/useAgentIdentity.js.map +1 -0
- package/dist/esm/rotation.js +123 -0
- package/dist/esm/rotation.js.map +1 -0
- package/dist/esm/router.js +208 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/schemas.js +124 -0
- package/dist/esm/schemas.js.map +1 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/approval.d.ts +48 -0
- package/dist/types/approval.d.ts.map +1 -0
- package/dist/types/attestation.d.ts +36 -0
- package/dist/types/attestation.d.ts.map +1 -0
- package/dist/types/budget.d.ts +38 -0
- package/dist/types/budget.d.ts.map +1 -0
- package/dist/types/credentials.d.ts +4 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/decision.d.ts +3 -0
- package/dist/types/decision.d.ts.map +1 -0
- package/dist/types/federation.d.ts +23 -0
- package/dist/types/federation.d.ts.map +1 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/providers.d.ts +13 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +3 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/react/useAgentIdentity.d.ts +58 -0
- package/dist/types/react/useAgentIdentity.d.ts.map +1 -0
- package/dist/types/rotation.d.ts +51 -0
- package/dist/types/rotation.d.ts.map +1 -0
- package/dist/types/router.d.ts +48 -0
- package/dist/types/router.d.ts.map +1 -0
- package/dist/types/schemas.d.ts +434 -0
- package/dist/types/schemas.d.ts.map +1 -0
- package/dist/types/types.d.ts +263 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/approval.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIjH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,OAAO,EAAE,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C,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,MAAM;IAEzC,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB/E;AAID,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAFZ,KAAK,EAAE,aAAa,EACpB,SAAS,GAAE,gBAAgB,EAAO,EAClC,WAAW,CAAC,EAAE,WAAW,YAAA;IAG5C;;;;;OAKG;IACG,OAAO,CACX,GAAG,EAAE,mBAAmB,EACxB,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC;CAkE3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-Trust Credential Attestation — @datacules/agent-identity core
|
|
3
|
+
*
|
|
4
|
+
* Every resolve() call can sign a short-lived JWT attestation using an
|
|
5
|
+
* HMAC-SHA256 key. Downstream services verify the attestation independently
|
|
6
|
+
* without calling agent-identity again — the proof travels with the request.
|
|
7
|
+
*
|
|
8
|
+
* Uses Web Crypto API (crypto.subtle) exclusively — available in:
|
|
9
|
+
* Node.js 18+ (global), browsers, Cloudflare Workers, Deno, Bun.
|
|
10
|
+
* No dynamic imports — compatible with both ESM and CJS builds.
|
|
11
|
+
*/
|
|
12
|
+
import type { AttestationSigner, AttestationPayload, ResolvedCredential, AgentRequestContext } from './types';
|
|
13
|
+
export declare class HmacAttestationSigner implements AttestationSigner {
|
|
14
|
+
private readonly secret;
|
|
15
|
+
private readonly issuer;
|
|
16
|
+
private readonly ttlSeconds;
|
|
17
|
+
constructor(options: {
|
|
18
|
+
secret: string;
|
|
19
|
+
issuer?: string;
|
|
20
|
+
ttlSeconds?: number;
|
|
21
|
+
});
|
|
22
|
+
private base64url;
|
|
23
|
+
private bufToBase64url;
|
|
24
|
+
private hmacSign;
|
|
25
|
+
sign(payload: Record<string, unknown>): Promise<string>;
|
|
26
|
+
verify(token: string): Promise<Record<string, unknown> | null>;
|
|
27
|
+
}
|
|
28
|
+
export interface AttestationOptions {
|
|
29
|
+
signer: AttestationSigner;
|
|
30
|
+
issuer?: string;
|
|
31
|
+
ttlSeconds?: number;
|
|
32
|
+
ruleId?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function buildAttestation(ctx: AgentRequestContext, resolved: ResolvedCredential, options: AttestationOptions): Promise<string>;
|
|
35
|
+
export declare function verifyAttestation(token: string, signer: AttestationSigner): Promise<AttestationPayload | null>;
|
|
36
|
+
//# sourceMappingURL=attestation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../../src/attestation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAI9G,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAM7E,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,cAAc;YAUR,QAAQ;IAahB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAOvD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAerE;AAID,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAejB;AAID,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAMpC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Budget Management — Feature #12 from FEATURE_SUGGESTIONS.md
|
|
3
|
+
*
|
|
4
|
+
* Enforces per-credential usage budgets (hourly resolution count,
|
|
5
|
+
* concurrent sessions, daily spend) at the routing layer — before any
|
|
6
|
+
* call reaches the provider.
|
|
7
|
+
*/
|
|
8
|
+
import type { Credential, AuditLogger } from './types';
|
|
9
|
+
export interface BudgetResult {
|
|
10
|
+
allowed: boolean;
|
|
11
|
+
reason?: 'hourly_limit' | 'session_limit' | 'daily_spend_limit';
|
|
12
|
+
retryAfter?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface BudgetStore {
|
|
15
|
+
getHourlyCount(credentialId: string): Promise<number>;
|
|
16
|
+
incrementHourlyCount(credentialId: string): Promise<void>;
|
|
17
|
+
getConcurrentSessions(credentialId: string): Promise<number>;
|
|
18
|
+
getDailySpend(credentialId: string): Promise<number>;
|
|
19
|
+
resetHourly(credentialId: string): Promise<void>;
|
|
20
|
+
resetDaily(credentialId: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare class MemoryBudgetStore implements BudgetStore {
|
|
23
|
+
private readonly hourlyCounts;
|
|
24
|
+
private readonly dailySpend;
|
|
25
|
+
getHourlyCount(credentialId: string): Promise<number>;
|
|
26
|
+
incrementHourlyCount(credentialId: string): Promise<void>;
|
|
27
|
+
getConcurrentSessions(_credentialId: string): Promise<number>;
|
|
28
|
+
getDailySpend(credentialId: string): Promise<number>;
|
|
29
|
+
resetHourly(credentialId: string): Promise<void>;
|
|
30
|
+
resetDaily(credentialId: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare class BudgetEnforcer {
|
|
33
|
+
private readonly store;
|
|
34
|
+
private readonly auditLogger?;
|
|
35
|
+
constructor(store: BudgetStore, auditLogger?: AuditLogger | undefined);
|
|
36
|
+
check(credential: Credential): Promise<BudgetResult>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../../src/budget.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIvD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,cAAc,GAAG,eAAe,GAAG,mBAAmB,CAAC;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAID,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6D;IAC1F,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IAElD,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrD,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzD,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK7D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpD,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtD;AAID,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;gBADZ,KAAK,EAAE,WAAW,EAClB,WAAW,CAAC,EAAE,WAAW,YAAA;IAGtC,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;CA4D3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,mBAAmB,EAAE,UAAU,EAK3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,WAAW,EAG9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/decision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE/D,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,GAAG,IAAI,CAyB/E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Federation — Cross-Org Identity Chains — Feature #11
|
|
3
|
+
*
|
|
4
|
+
* Carries a signed IdentityChain token across trust boundaries so that
|
|
5
|
+
* the full principal history is verifiable at every hop.
|
|
6
|
+
*
|
|
7
|
+
* Uses only standard Web APIs — no dynamic imports, CJS + ESM compatible.
|
|
8
|
+
*/
|
|
9
|
+
import type { FederationConfig, IdentityChainEntry, AgentRequestContext } from './types';
|
|
10
|
+
export declare class FederationVerifier {
|
|
11
|
+
private readonly config;
|
|
12
|
+
constructor(config: FederationConfig);
|
|
13
|
+
verify(chain: IdentityChainEntry[]): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class FederationIssuer {
|
|
16
|
+
private readonly trustDomain;
|
|
17
|
+
private readonly agentId;
|
|
18
|
+
constructor(trustDomain: string, agentId: string);
|
|
19
|
+
issueEntry(ctx: AgentRequestContext): IdentityChainEntry;
|
|
20
|
+
issueChain(ctx: AgentRequestContext): IdentityChainEntry[];
|
|
21
|
+
extendChain(chain: IdentityChainEntry[], ctx: AgentRequestContext): IdentityChainEntry[];
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=federation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation.d.ts","sourceRoot":"","sources":["../../src/federation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAIzF,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,gBAAgB;IAErD,MAAM,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,OAAO;CAS7C;AAID,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM;IAGlC,UAAU,CAAC,GAAG,EAAE,mBAAmB,GAAG,kBAAkB;IAoBxD,UAAU,CAAC,GAAG,EAAE,mBAAmB,GAAG,kBAAkB,EAAE;IAI1D,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAAG,kBAAkB,EAAE;CAGzF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @datacules/agent-identity — public API
|
|
3
|
+
*
|
|
4
|
+
* Provider-agnostic credential routing and identity management for AI agents.
|
|
5
|
+
* The model/LLM layer never receives raw credentials.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createRouter } from '@datacules/agent-identity';
|
|
10
|
+
* import type { AgentRequestContext } from '@datacules/agent-identity';
|
|
11
|
+
*
|
|
12
|
+
* const router = createRouter(credentials, rules, logger);
|
|
13
|
+
* const resolved = await router.resolveAsync(ctx);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type * from './types';
|
|
17
|
+
export * from './router';
|
|
18
|
+
export * from './providers';
|
|
19
|
+
export * from './credentials';
|
|
20
|
+
export * from './decision';
|
|
21
|
+
export * from './rotation';
|
|
22
|
+
export * from './attestation';
|
|
23
|
+
export * from './approval';
|
|
24
|
+
export * from './budget';
|
|
25
|
+
export * from './federation';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,mBAAmB,SAAS,CAAC;AAG7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProviderAdapter, SupportedProvider } from './types';
|
|
2
|
+
export declare const PROVIDER_ADAPTERS: Record<SupportedProvider, ProviderAdapter>;
|
|
3
|
+
export declare function getAdapter(provider: SupportedProvider): ProviderAdapter;
|
|
4
|
+
/**
|
|
5
|
+
* Registry pattern — register a custom provider adapter without forking core.
|
|
6
|
+
* Registered adapters are available via getAdapter() immediately.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* import { registerProvider } from '@datacules/agent-identity';
|
|
10
|
+
* registerProvider({ id: 'cohere' as SupportedProvider, label: 'Cohere', injectCredential: ... });
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerProvider(adapter: ProviderAdapter): void;
|
|
13
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,eAAe,EAAsB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAwEtG,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAMxE,CAAC;AAEF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,iBAAiB,GAAG,eAAe,CAEvE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAE/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAgentIdentity — production-safe React hook.
|
|
3
|
+
*
|
|
4
|
+
* Exported from @datacules/agent-identity/react.
|
|
5
|
+
*
|
|
6
|
+
* Unlike useCredentials (demo-only), this hook calls POST /api/resolve
|
|
7
|
+
* server-side. The raw credential never touches the browser.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Full loading / error / expiresAt lifecycle
|
|
11
|
+
* - Auto-refresh 60s before credential expiry
|
|
12
|
+
* - Configurable endpoint (works with custom Next.js routes or the Docker sidecar)
|
|
13
|
+
* - onError callback for integration with error boundaries / toast systems
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* import { useAgentIdentity } from '@datacules/agent-identity/react';
|
|
17
|
+
*
|
|
18
|
+
* function AiComposer({ userId }: { userId: string }) {
|
|
19
|
+
* const ctx = {
|
|
20
|
+
* userId,
|
|
21
|
+
* resourceId: 'knowledge-base',
|
|
22
|
+
* resourceKind: 'personal' as const,
|
|
23
|
+
* provider: 'anthropic' as const,
|
|
24
|
+
* model: 'claude-sonnet-4-20250514',
|
|
25
|
+
* action: 'read',
|
|
26
|
+
* traceId: crypto.randomUUID(),
|
|
27
|
+
* requestedAt: new Date().toISOString(),
|
|
28
|
+
* };
|
|
29
|
+
* const { resolvedFor, loading, error, expiresAt } = useAgentIdentity(ctx);
|
|
30
|
+
*
|
|
31
|
+
* if (loading) return <p>Resolving credentials…</p>;
|
|
32
|
+
* if (error) return <p>Auth error: {error.message}</p>;
|
|
33
|
+
* return <div>Ready — acting as {resolvedFor}</div>;
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
import type { AgentRequestContext } from '../types';
|
|
37
|
+
export interface UseAgentIdentityOptions {
|
|
38
|
+
/** Defaults to '/api/resolve' */
|
|
39
|
+
resolveEndpoint?: string;
|
|
40
|
+
/** Re-resolve this many seconds before the credential expires (default: 60) */
|
|
41
|
+
refreshBeforeExpirySeconds?: number;
|
|
42
|
+
/** Called on every error; use for toast / error boundary integration */
|
|
43
|
+
onError?: (err: Error) => void;
|
|
44
|
+
/** Disable auto-refresh on expiry (default: false) */
|
|
45
|
+
disableAutoRefresh?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface AgentIdentityState {
|
|
48
|
+
resolvedFor: string | null;
|
|
49
|
+
expiresAt: string | null;
|
|
50
|
+
loading: boolean;
|
|
51
|
+
error: Error | null;
|
|
52
|
+
}
|
|
53
|
+
export interface UseAgentIdentityReturn extends AgentIdentityState {
|
|
54
|
+
/** Manually trigger a resolve (called automatically when ctx changes) */
|
|
55
|
+
resolve: (ctx: AgentRequestContext) => Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export declare function useAgentIdentity(ctx: AgentRequestContext | null, options?: UseAgentIdentityOptions): UseAgentIdentityReturn;
|
|
58
|
+
//# sourceMappingURL=useAgentIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentIdentity.d.ts","sourceRoot":"","sources":["../../../src/react/useAgentIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,uBAAuB;IACtC,iCAAiC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,wEAAwE;IACxE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,yEAAyE;IACzE,OAAO,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,mBAAmB,GAAG,IAAI,EAC/B,OAAO,GAAE,uBAA4B,GACpC,sBAAsB,CA8ExB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automated Credential Rotation — Feature #4 from FEATURE_SUGGESTIONS.md
|
|
3
|
+
*
|
|
4
|
+
* RotationPolicy on Credential + CredentialRotationScheduler that detects
|
|
5
|
+
* expiring/due credentials and calls registered RotationProvider instances
|
|
6
|
+
* to mint new secrets.
|
|
7
|
+
*/
|
|
8
|
+
import type { Credential, AuditLogger } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* A RotationProvider mints a new secret for a credential and updates the
|
|
11
|
+
* store. Built-in providers: VaultRotationProvider, AwsRotationProvider.
|
|
12
|
+
* Custom providers implement this interface.
|
|
13
|
+
*/
|
|
14
|
+
export interface RotationProvider {
|
|
15
|
+
id: string;
|
|
16
|
+
rotate(credential: Credential): Promise<{
|
|
17
|
+
newRef: string;
|
|
18
|
+
rotatedAt: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* CredentialRepository is a minimal interface over any CredentialStore that
|
|
23
|
+
* supports mutation — listing and updating credentials. The core store
|
|
24
|
+
* interface is read-only for callers; rotation needs write access.
|
|
25
|
+
*/
|
|
26
|
+
export interface RotationRepository {
|
|
27
|
+
listActive(): Promise<Credential[]>;
|
|
28
|
+
update(id: string, patch: Partial<Credential>): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare class CredentialRotationScheduler {
|
|
31
|
+
private readonly repository;
|
|
32
|
+
private readonly auditLogger?;
|
|
33
|
+
private readonly providers;
|
|
34
|
+
private intervalHandle;
|
|
35
|
+
constructor(repository: RotationRepository, auditLogger?: AuditLogger | undefined);
|
|
36
|
+
registerProvider(provider: RotationProvider): void;
|
|
37
|
+
/**
|
|
38
|
+
* Check all active credentials for pending rotation and rotate them.
|
|
39
|
+
* Call this on a schedule (e.g. every hour via cron or setInterval).
|
|
40
|
+
*/
|
|
41
|
+
runOnce(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Start a background rotation loop at the given interval.
|
|
44
|
+
* @param intervalMs Check frequency in milliseconds (default: 3600000 = 1 hour)
|
|
45
|
+
*/
|
|
46
|
+
start(intervalMs?: number): void;
|
|
47
|
+
stop(): void;
|
|
48
|
+
private isRotationDue;
|
|
49
|
+
private maybeEmitWarning;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=rotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../src/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAC;AAIvE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChF;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAID,qBAAa,2BAA2B;IAKpC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuC;IACjE,OAAO,CAAC,cAAc,CAA+C;gBAGlD,UAAU,EAAE,kBAAkB,EAC9B,WAAW,CAAC,EAAE,WAAW,YAAA;IAG5C,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIlD;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8D9B;;;OAGG;IACH,KAAK,CAAC,UAAU,SAAY,GAAG,IAAI;IAOnC,IAAI,IAAI,IAAI;IAOZ,OAAO,CAAC,aAAa;YASP,gBAAgB;CAsB/B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Router — core of @datacules/agent-identity.
|
|
3
|
+
*
|
|
4
|
+
* Key features added in this version:
|
|
5
|
+
* - Canary routing: canaryRef + canaryWeight on RoutingRule
|
|
6
|
+
* - Attestation: optional AttestationSigner on router config
|
|
7
|
+
* - Budget enforcement: BudgetEnforcer check before resolving
|
|
8
|
+
* - Approval gate: ApprovalManager integration on rules with approval policy
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentRequestContext, AuditLogger, Credential, CredentialStore, MigrationContext, ResolvedCredential, ResolvedCredentialPair, RoutingRule, AttestationSigner } from './types';
|
|
11
|
+
import type { BudgetEnforcer } from './budget';
|
|
12
|
+
import type { ApprovalManager } from './approval';
|
|
13
|
+
export interface RouterConfig {
|
|
14
|
+
store: CredentialStore;
|
|
15
|
+
rules: RoutingRule[];
|
|
16
|
+
logger?: AuditLogger;
|
|
17
|
+
/** Sign a JWT attestation and attach it to every ResolvedCredential */
|
|
18
|
+
attestationSigner?: AttestationSigner;
|
|
19
|
+
/** Enforce per-credential budget limits */
|
|
20
|
+
budgetEnforcer?: BudgetEnforcer;
|
|
21
|
+
/** Gate high-risk resolutions behind human approval */
|
|
22
|
+
approvalManager?: ApprovalManager;
|
|
23
|
+
}
|
|
24
|
+
export declare class MemoryCredentialStore implements CredentialStore {
|
|
25
|
+
private readonly creds;
|
|
26
|
+
private readonly reservations;
|
|
27
|
+
constructor(credentials: Credential[]);
|
|
28
|
+
findByRefSync(ref: string): Credential | null;
|
|
29
|
+
findByRef(ref: string): Promise<Credential | null>;
|
|
30
|
+
listActive(): Promise<Credential[]>;
|
|
31
|
+
listByKind(kind: Credential['kind']): Promise<Credential[]>;
|
|
32
|
+
reserve(ref: string, migrationId: string, ttlSeconds: number): Promise<boolean>;
|
|
33
|
+
release(ref: string, migrationId: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare class CredentialRouter {
|
|
36
|
+
private readonly config;
|
|
37
|
+
constructor(config: RouterConfig);
|
|
38
|
+
resolve(ctx: AgentRequestContext): ResolvedCredential | null;
|
|
39
|
+
resolveAsync(ctx: AgentRequestContext): Promise<ResolvedCredential | null>;
|
|
40
|
+
resolvePair(ctx: MigrationContext): ResolvedCredentialPair | null;
|
|
41
|
+
private selectRef;
|
|
42
|
+
private ruleMatches;
|
|
43
|
+
private buildAuditEntry;
|
|
44
|
+
}
|
|
45
|
+
export declare function createRouter(credentials: Credential[], rules: RoutingRule[], logger?: AuditLogger): CredentialRouter;
|
|
46
|
+
export declare function createRouterFromStore(store: CredentialStore, rules: RoutingRule[], logger?: AuditLogger): CredentialRouter;
|
|
47
|
+
export declare function createRouterWithConfig(config: RouterConfig): CredentialRouter;
|
|
48
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,mBAAmB,EAEnB,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,sBAA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