UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

90 lines • 6 kB
/** * identity — outbound credential vending for agent tools. * * The {@link CredentialProvider} port + adapters. A tool calls * `provider.getCredential({ service })` to get a token for a downstream service; * `agentCoreIdentity()` backs it with AWS Bedrock AgentCore Identity, or * `staticTokens()` for dev/test. * * SECURITY: a vended token is a secret — use it locally inside a tool's * `execute` (e.g. an HTTP header); never write it to tracked scope. See * `./identity/types` for the full invariant. * * @example * ```ts * import { agentCoreIdentity } from 'agentfootprint/security'; * * const credentials = agentCoreIdentity({ region: 'us-east-1' }); * const r = await credentials.getCredential({ service: 'github', mode: 'user', scopes: ['repo'] }); * if (r.status === 'authorization-required') { * // surface r.authorizationUrl to the user (e.g. pause the run), then retry. * } else { * callGitHub({ headers: r.credential.toHeaders() }); // universal applicator * } * ``` * * Not an import path of its own since 9.0.0. This is the implementation barrel * behind `agentfootprint/security`, which re-exports every name here — same * symbols, one door. Import from the door. */ export { isCredentialIssued, unconfiguredCredentialProvider } from './identity/types.js'; export { bearer, apiKey, basic, headers, } from './identity/kinds.js'; export { staticTokens } from './identity/staticTokens.js'; // Credentials from the INCOMING REQUEST: the host seals the request's secrets // per run (`requestContext`), and `requestCredentials` vends them to a tool's // declared `needs` — only for the run that carries them, failing closed by name. export { requestContext, isRequestContext, } from './identity/requestContext.js'; export { requestCredentials, asBearer, asApiKey, decodedWith, RequestCredentialError, } from './identity/requestCredentials.js'; export { CredentialConsentRequiredError, } from './identity/CredentialConsentRequiredError.js'; export { withCredentialRetry, } from './identity/withCredentialRetry.js'; export { agentCoreIdentity, // The consent handshake (9.66.0) — called from YOUR callback route, not from // the agent run, which is why it is a function of its own rather than a // method on the provider that route never sees. completeAgentCoreAuthorization, } from './adapters/identity/agentcore.js'; // HashiCorp-Vault-compatible KV v2, over plain HTTP (9.8.0) — no SDK, no // vendor client. V1 is token auth + KV v2 + no leases, and every other shape // is refused by name rather than guessed at; see the module docstring. export { vaultCredentials } from './adapters/identity/vault.js'; // Google access tokens from whatever credential the environment already has // (ADC, workload identity, an impersonated service account). Narrow on // purpose: it vends the DEPLOYMENT's identity, and `mode: 'user'` is refused // by name rather than quietly downgraded to a machine token. export { googleIdentity, CLOUD_PLATFORM_SCOPE, } from './adapters/identity/google.js'; // Entra ID tokens from whatever credential the environment already has — // DefaultAzureCredential's chain (env service principal, workload identity, // managed identity, VS Code, az CLI), or any TokenCredential you built // (9.74.0). Same narrowness as googleIdentity: it vends the DEPLOYMENT's // identity; `mode: 'user'` and per-request user tokens are refused by name // until an OBO surface exists. AZURE_AI_SCOPE vs AZURE_MANAGEMENT_SCOPE // matters — a token for one audience does not work on the other, which is // why both constants are exported instead of one "azure scope". export { entraIdentity, AZURE_AI_SCOPE, AZURE_MANAGEMENT_SCOPE, AZURE_COGNITIVE_SERVICES_SCOPE, } from './adapters/identity/azure.js'; // Verifying WHO is calling (9.26.0) — the other half of identity. The rest of // this door vends credentials for calls the agent makes OUTWARD; // `jwksIdentity` checks the credential a caller presents INWARD, against an // identity provider's published key set. Wire it at the hosting door: // `standingAgent({ …, identity: { verify: jwksIdentity({ … }).verify } })`. export { jwksIdentity, MissingJwksSupportError, } from './adapters/identity/jwks.js'; // Sign-in strategies picked by CONFIG (the identity-strategies design). One // strategy per deployment, judged once at boot: `identityFromConfig` refuses a // wrong or missing setting by name, and production must name its strategy. // `oidcIdentity` is the `oidc-token` verifier: jwksIdentity's checks plus // discovery, AD FS's second issuer, and the PERSON test — an application's own // token is not an employee. export { oidcIdentity, } from './adapters/identity/oidc.js'; // Browser sign-in for oidc-token: the authorization-code flow through // `openid-client` (optional peer). PENDING INDEPENDENT REVIEW before a company // install. The person is read from an ACCESS token by the strategy's own verify. export { MissingOpenIdClientError, OidcSignInSetupError, oidcSignIn, } from './adapters/identity/oidcSignIn.js'; export { identityFromConfig, } from './adapters/identity/strategies/choose.js'; // `directory-password`: Active Directory over LDAPS — bind, RFC 4532 // Who-am-I, exactly one entry, its objectGUID. `ldapts` is an optional peer. export { directoryPasswords, } from './adapters/identity/directory/directoryPasswords.js'; export { ldapDirectory, MissingLdaptsError, } from './adapters/identity/directory/ldapDirectory.js'; export { adSubCodeName, escapeFilterValue, } from './adapters/identity/directory/port.js'; // `local-password` (development, tests, demos; refused in production): hashed // entries only, scrypt from node:crypto. `hashPassword` makes an entry. export { hashPassword, localPasswords, LocalPasswordConfigError, SCRYPT_DEFAULT, SCRYPT_FLOOR, } from './adapters/identity/localPassword.js'; export { identityConfigFromEnv, IdentityConfigError, } from './adapters/identity/strategies/config.js'; //# sourceMappingURL=identity.js.map