agentfootprint 6.9.0 → 6.10.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/adapters/identity/agentcore.js +84 -0
- package/dist/adapters/identity/agentcore.js.map +1 -0
- package/dist/esm/adapters/identity/agentcore.js +80 -0
- package/dist/esm/adapters/identity/agentcore.js.map +1 -0
- package/dist/esm/identity/staticTokens.js +33 -0
- package/dist/esm/identity/staticTokens.js.map +1 -0
- package/dist/esm/identity/types.js +30 -0
- package/dist/esm/identity/types.js.map +1 -0
- package/dist/esm/identity.js +29 -0
- package/dist/esm/identity.js.map +1 -0
- package/dist/identity/staticTokens.js +37 -0
- package/dist/identity/staticTokens.js.map +1 -0
- package/dist/identity/types.js +34 -0
- package/dist/identity/types.js.map +1 -0
- package/dist/identity.js +35 -0
- package/dist/identity.js.map +1 -0
- package/dist/types/adapters/identity/agentcore.d.ts +57 -0
- package/dist/types/adapters/identity/agentcore.d.ts.map +1 -0
- package/dist/types/identity/staticTokens.d.ts +24 -0
- package/dist/types/identity/staticTokens.d.ts.map +1 -0
- package/dist/types/identity/types.d.ts +65 -0
- package/dist/types/identity/types.d.ts.map +1 -0
- package/dist/types/identity.d.ts +30 -0
- package/dist/types/identity.d.ts.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentCoreIdentity — AWS Bedrock AgentCore Identity adapter (peer-dep
|
|
4
|
+
* `@aws-sdk/client-bedrock-agentcore`).
|
|
5
|
+
*
|
|
6
|
+
* import { agentCoreIdentity } from 'agentfootprint/identity';
|
|
7
|
+
* const credentials = agentCoreIdentity({ region: 'us-east-1' });
|
|
8
|
+
*
|
|
9
|
+
* Maps the {@link CredentialProvider} port onto AgentCore Identity's
|
|
10
|
+
* `GetResourceOauth2Token` (the SDK's `@requires_access_token` underneath):
|
|
11
|
+
* - request.mode 'machine' → `M2M`; 'user' → `USER_FEDERATION`
|
|
12
|
+
* - request.service → the configured OAuth2 credential-provider name
|
|
13
|
+
* - a returned access token → `{ status: 'token' }`
|
|
14
|
+
* - a returned auth URL → `{ status: 'authorization-required' }` (3LO consent)
|
|
15
|
+
*
|
|
16
|
+
* The token vault + refresh-token handling live in AgentCore, so repeat calls
|
|
17
|
+
* usually return a token directly (no consent round-trip).
|
|
18
|
+
*
|
|
19
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the AWS SDK is required only when
|
|
20
|
+
* `getCredential` first runs (or never, if you inject `_client`). NOTE: confirm
|
|
21
|
+
* the SDK command/field names against your installed
|
|
22
|
+
* `@aws-sdk/client-bedrock-agentcore` version — this adapter targets the
|
|
23
|
+
* `GetResourceOauth2Token` shape and is structured so the request→result mapping
|
|
24
|
+
* is unit-tested via the `_client` seam independent of the SDK.
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.agentCoreIdentity = void 0;
|
|
28
|
+
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
29
|
+
function resolveClient(options) {
|
|
30
|
+
if (options._client)
|
|
31
|
+
return options._client;
|
|
32
|
+
// Lazy peer-dep: only loaded when no _client is injected and getCredential runs.
|
|
33
|
+
const sdk = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-bedrock-agentcore');
|
|
34
|
+
const Ctor = sdk.BedrockAgentCoreClient;
|
|
35
|
+
if (!Ctor) {
|
|
36
|
+
throw new Error('agentCoreIdentity: @aws-sdk/client-bedrock-agentcore did not expose BedrockAgentCoreClient. ' +
|
|
37
|
+
'Install/upgrade the SDK, or pass `_client` for a custom integration.');
|
|
38
|
+
}
|
|
39
|
+
const client = new Ctor({ ...(options.region && { region: options.region }) });
|
|
40
|
+
if (typeof client.getResourceOauth2Token !== 'function') {
|
|
41
|
+
throw new Error('agentCoreIdentity: the SDK client has no getResourceOauth2Token. Confirm the ' +
|
|
42
|
+
'@aws-sdk/client-bedrock-agentcore version, or pass `_client`.');
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
getResourceOauth2Token: (input) => client.getResourceOauth2Token(input),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Build a {@link CredentialProvider} backed by AWS Bedrock AgentCore Identity. */
|
|
49
|
+
function agentCoreIdentity(options = {}) {
|
|
50
|
+
let client;
|
|
51
|
+
const getClient = () => (client ??= resolveClient(options));
|
|
52
|
+
return {
|
|
53
|
+
id: options.id ?? 'agentcore-identity',
|
|
54
|
+
async getCredential(req) {
|
|
55
|
+
const res = await getClient().getResourceOauth2Token({
|
|
56
|
+
resourceCredentialProviderName: req.service,
|
|
57
|
+
scopes: req.scopes ?? [],
|
|
58
|
+
oauth2Flow: req.mode === 'user' ? 'USER_FEDERATION' : 'M2M',
|
|
59
|
+
forceAuthentication: req.forceReauth ?? false,
|
|
60
|
+
...(options.workloadIdentityToken && {
|
|
61
|
+
workloadIdentityToken: options.workloadIdentityToken,
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
if (res.accessToken) {
|
|
65
|
+
return {
|
|
66
|
+
status: 'token',
|
|
67
|
+
token: res.accessToken,
|
|
68
|
+
...(res.expiresAt !== undefined && { expiresAt: res.expiresAt }),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (res.authorizationUrl) {
|
|
72
|
+
return {
|
|
73
|
+
status: 'authorization-required',
|
|
74
|
+
authorizationUrl: res.authorizationUrl,
|
|
75
|
+
sessionId: res.sessionId ?? '',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`agentCoreIdentity: GetResourceOauth2Token for '${req.service}' returned neither ` +
|
|
79
|
+
'an access token nor an authorization URL.');
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.agentCoreIdentity = agentCoreIdentity;
|
|
84
|
+
//# sourceMappingURL=agentcore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/identity/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,6DAAuD;AAuCvD,SAAS,aAAa,CAAC,OAAiC;IACtD,IAAI,OAAO,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAC5C,iFAAiF;IACjF,MAAM,GAAG,GAAG,IAAA,4BAAW,EAA0B,mCAAmC,CAAC,CAAC;IACtF,MAAM,IAAI,GAAG,GAAG,CAAC,sBAEJ,CAAC;IACd,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,8FAA8F;YAC5F,sEAAsE,CACzE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,CAE5E,CAAC;IACF,IAAI,OAAO,MAAM,CAAC,sBAAsB,KAAK,UAAU,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CACb,+EAA+E;YAC7E,+DAA+D,CAClE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAChC,MAAM,CAAC,sBAAuB,CAAC,KAAK,CAAoC;KAC3E,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,SAAgB,iBAAiB,CAAC,UAAoC,EAAE;IACtE,IAAI,MAA+C,CAAC;IACpD,MAAM,SAAS,GAAG,GAAgC,EAAE,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzF,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,oBAAoB;QACtC,KAAK,CAAC,aAAa,CAAC,GAAsB;YACxC,MAAM,GAAG,GAAG,MAAM,SAAS,EAAE,CAAC,sBAAsB,CAAC;gBACnD,8BAA8B,EAAE,GAAG,CAAC,OAAO;gBAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;gBACxB,UAAU,EAAE,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK;gBAC3D,mBAAmB,EAAE,GAAG,CAAC,WAAW,IAAI,KAAK;gBAC7C,GAAG,CAAC,OAAO,CAAC,qBAAqB,IAAI;oBACnC,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;iBACrD,CAAC;aACH,CAAC,CAAC;YAEH,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACpB,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG,CAAC,WAAW;oBACtB,GAAG,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;iBACjE,CAAC;YACJ,CAAC;YACD,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;gBACzB,OAAO;oBACL,MAAM,EAAE,wBAAwB;oBAChC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;oBACtC,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE;iBAC/B,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CACb,kDAAkD,GAAG,CAAC,OAAO,qBAAqB;gBAChF,2CAA2C,CAC9C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AArCD,8CAqCC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentCoreIdentity — AWS Bedrock AgentCore Identity adapter (peer-dep
|
|
3
|
+
* `@aws-sdk/client-bedrock-agentcore`).
|
|
4
|
+
*
|
|
5
|
+
* import { agentCoreIdentity } from 'agentfootprint/identity';
|
|
6
|
+
* const credentials = agentCoreIdentity({ region: 'us-east-1' });
|
|
7
|
+
*
|
|
8
|
+
* Maps the {@link CredentialProvider} port onto AgentCore Identity's
|
|
9
|
+
* `GetResourceOauth2Token` (the SDK's `@requires_access_token` underneath):
|
|
10
|
+
* - request.mode 'machine' → `M2M`; 'user' → `USER_FEDERATION`
|
|
11
|
+
* - request.service → the configured OAuth2 credential-provider name
|
|
12
|
+
* - a returned access token → `{ status: 'token' }`
|
|
13
|
+
* - a returned auth URL → `{ status: 'authorization-required' }` (3LO consent)
|
|
14
|
+
*
|
|
15
|
+
* The token vault + refresh-token handling live in AgentCore, so repeat calls
|
|
16
|
+
* usually return a token directly (no consent round-trip).
|
|
17
|
+
*
|
|
18
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the AWS SDK is required only when
|
|
19
|
+
* `getCredential` first runs (or never, if you inject `_client`). NOTE: confirm
|
|
20
|
+
* the SDK command/field names against your installed
|
|
21
|
+
* `@aws-sdk/client-bedrock-agentcore` version — this adapter targets the
|
|
22
|
+
* `GetResourceOauth2Token` shape and is structured so the request→result mapping
|
|
23
|
+
* is unit-tested via the `_client` seam independent of the SDK.
|
|
24
|
+
*/
|
|
25
|
+
import { lazyRequire } from '../../lib/lazyRequire.js';
|
|
26
|
+
function resolveClient(options) {
|
|
27
|
+
if (options._client)
|
|
28
|
+
return options._client;
|
|
29
|
+
// Lazy peer-dep: only loaded when no _client is injected and getCredential runs.
|
|
30
|
+
const sdk = lazyRequire('@aws-sdk/client-bedrock-agentcore');
|
|
31
|
+
const Ctor = sdk.BedrockAgentCoreClient;
|
|
32
|
+
if (!Ctor) {
|
|
33
|
+
throw new Error('agentCoreIdentity: @aws-sdk/client-bedrock-agentcore did not expose BedrockAgentCoreClient. ' +
|
|
34
|
+
'Install/upgrade the SDK, or pass `_client` for a custom integration.');
|
|
35
|
+
}
|
|
36
|
+
const client = new Ctor({ ...(options.region && { region: options.region }) });
|
|
37
|
+
if (typeof client.getResourceOauth2Token !== 'function') {
|
|
38
|
+
throw new Error('agentCoreIdentity: the SDK client has no getResourceOauth2Token. Confirm the ' +
|
|
39
|
+
'@aws-sdk/client-bedrock-agentcore version, or pass `_client`.');
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
getResourceOauth2Token: (input) => client.getResourceOauth2Token(input),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Build a {@link CredentialProvider} backed by AWS Bedrock AgentCore Identity. */
|
|
46
|
+
export function agentCoreIdentity(options = {}) {
|
|
47
|
+
let client;
|
|
48
|
+
const getClient = () => (client ??= resolveClient(options));
|
|
49
|
+
return {
|
|
50
|
+
id: options.id ?? 'agentcore-identity',
|
|
51
|
+
async getCredential(req) {
|
|
52
|
+
const res = await getClient().getResourceOauth2Token({
|
|
53
|
+
resourceCredentialProviderName: req.service,
|
|
54
|
+
scopes: req.scopes ?? [],
|
|
55
|
+
oauth2Flow: req.mode === 'user' ? 'USER_FEDERATION' : 'M2M',
|
|
56
|
+
forceAuthentication: req.forceReauth ?? false,
|
|
57
|
+
...(options.workloadIdentityToken && {
|
|
58
|
+
workloadIdentityToken: options.workloadIdentityToken,
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
if (res.accessToken) {
|
|
62
|
+
return {
|
|
63
|
+
status: 'token',
|
|
64
|
+
token: res.accessToken,
|
|
65
|
+
...(res.expiresAt !== undefined && { expiresAt: res.expiresAt }),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (res.authorizationUrl) {
|
|
69
|
+
return {
|
|
70
|
+
status: 'authorization-required',
|
|
71
|
+
authorizationUrl: res.authorizationUrl,
|
|
72
|
+
sessionId: res.sessionId ?? '',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`agentCoreIdentity: GetResourceOauth2Token for '${req.service}' returned neither ` +
|
|
76
|
+
'an access token nor an authorization URL.');
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=agentcore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/identity/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAuCvD,SAAS,aAAa,CAAC,OAAiC;IACtD,IAAI,OAAO,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAC5C,iFAAiF;IACjF,MAAM,GAAG,GAAG,WAAW,CAA0B,mCAAmC,CAAC,CAAC;IACtF,MAAM,IAAI,GAAG,GAAG,CAAC,sBAEJ,CAAC;IACd,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,8FAA8F;YAC5F,sEAAsE,CACzE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,CAE5E,CAAC;IACF,IAAI,OAAO,MAAM,CAAC,sBAAsB,KAAK,UAAU,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CACb,+EAA+E;YAC7E,+DAA+D,CAClE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAChC,MAAM,CAAC,sBAAuB,CAAC,KAAK,CAAoC;KAC3E,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,iBAAiB,CAAC,UAAoC,EAAE;IACtE,IAAI,MAA+C,CAAC;IACpD,MAAM,SAAS,GAAG,GAAgC,EAAE,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzF,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,oBAAoB;QACtC,KAAK,CAAC,aAAa,CAAC,GAAsB;YACxC,MAAM,GAAG,GAAG,MAAM,SAAS,EAAE,CAAC,sBAAsB,CAAC;gBACnD,8BAA8B,EAAE,GAAG,CAAC,OAAO;gBAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;gBACxB,UAAU,EAAE,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK;gBAC3D,mBAAmB,EAAE,GAAG,CAAC,WAAW,IAAI,KAAK;gBAC7C,GAAG,CAAC,OAAO,CAAC,qBAAqB,IAAI;oBACnC,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;iBACrD,CAAC;aACH,CAAC,CAAC;YAEH,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACpB,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG,CAAC,WAAW;oBACtB,GAAG,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;iBACjE,CAAC;YACJ,CAAC;YACD,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;gBACzB,OAAO;oBACL,MAAM,EAAE,wBAAwB;oBAChC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;oBACtC,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE;iBAC/B,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CACb,kDAAkD,GAAG,CAAC,OAAO,qBAAqB;gBAChF,2CAA2C,CAC9C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* staticTokens — a dev/test {@link CredentialProvider} backed by canned tokens.
|
|
3
|
+
*
|
|
4
|
+
* No network, no SDK. Use it to develop tools that need credentials without
|
|
5
|
+
* standing up AgentCore Identity (or any IdP). Production swaps it for
|
|
6
|
+
* `agentCoreIdentity()` — the tool code never changes.
|
|
7
|
+
*
|
|
8
|
+
* const credentials = staticTokens({ github: 'ghp_dev_xxx', slack: 'xoxb-dev' });
|
|
9
|
+
* const r = await credentials.getCredential({ service: 'github' });
|
|
10
|
+
* if (r.status === 'token') useHeader(`Bearer ${r.token}`);
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Build a {@link CredentialProvider} from a `service → token` map. Always 2-legged
|
|
14
|
+
* (returns the token directly); throws if a requested service has no token.
|
|
15
|
+
*/
|
|
16
|
+
export function staticTokens(tokens, options = {}) {
|
|
17
|
+
return {
|
|
18
|
+
id: options.id ?? 'static-tokens',
|
|
19
|
+
getCredential(req) {
|
|
20
|
+
const token = tokens[req.service];
|
|
21
|
+
if (!token) {
|
|
22
|
+
return Promise.reject(new Error(`staticTokens: no token configured for service '${req.service}'. ` +
|
|
23
|
+
`Known services: ${Object.keys(tokens).join(', ') || '(none)'}.`));
|
|
24
|
+
}
|
|
25
|
+
return Promise.resolve({
|
|
26
|
+
status: 'token',
|
|
27
|
+
token,
|
|
28
|
+
...(options.expiresAt !== undefined && { expiresAt: options.expiresAt }),
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=staticTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticTokens.js","sourceRoot":"","sources":["../../../src/identity/staticTokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAwC,EACxC,UAA+B,EAAE;IAEjC,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,eAAe;QACjC,aAAa,CAAC,GAAG;YACf,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,kDAAkD,GAAG,CAAC,OAAO,KAAK;oBAChE,mBAAmB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG,CACnE,CACF,CAAC;YACJ,CAAC;YACD,OAAO,OAAO,CAAC,OAAO,CAAC;gBACrB,MAAM,EAAE,OAAO;gBACf,KAAK;gBACL,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;aACzE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/identity — the CredentialProvider port.
|
|
3
|
+
*
|
|
4
|
+
* OUTBOUND auth: vend a credential/token so a tool can call a downstream service
|
|
5
|
+
* (GitHub, Slack, Google…) on behalf of the agent or the end user. This is
|
|
6
|
+
* DISTINCT from `agentfootprint/security` (authorization — "is this tool
|
|
7
|
+
* allowed"); identity answers "get me a token to call X".
|
|
8
|
+
*
|
|
9
|
+
* Pattern: Port (Hexagonal). Vendors plug in as adapters:
|
|
10
|
+
* - `agentCoreIdentity()` — AWS Bedrock AgentCore Identity (token vault + OAuth)
|
|
11
|
+
* - `staticTokens()` — dev/test (canned tokens, no network)
|
|
12
|
+
*
|
|
13
|
+
* Two flows, mirroring OAuth (and AgentCore's `M2M` vs `USER_FEDERATION`):
|
|
14
|
+
* - `mode: 'machine'` (2-legged) — client-credentials; returns a token directly.
|
|
15
|
+
* - `mode: 'user'` (3-legged) — user-delegated; may need consent. When it
|
|
16
|
+
* does, the provider returns `authorization-required` with a URL; the agent
|
|
17
|
+
* surfaces it to the human (e.g. via pause/resume) and retries after consent.
|
|
18
|
+
* (Most calls skip consent — providers cache refresh tokens.)
|
|
19
|
+
*
|
|
20
|
+
* **Security invariant:** a vended token is a SECRET. Callers MUST use it locally
|
|
21
|
+
* (e.g. as an HTTP header inside a tool's `execute`) and MUST NOT write it to
|
|
22
|
+
* tracked scope (`setValue`) — tracked writes flow to the commit log, recorders,
|
|
23
|
+
* and observability exporters, which would leak the token into the trace. Pair
|
|
24
|
+
* with `RedactionPolicy` for defence in depth.
|
|
25
|
+
*/
|
|
26
|
+
/** Narrow a {@link CredentialResult} to the token branch. */
|
|
27
|
+
export function isCredentialToken(r) {
|
|
28
|
+
return r.status === 'token';
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAyCH,6DAA6D;AAC7D,MAAM,UAAU,iBAAiB,CAAC,CAAmB;IACnD,OAAO,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/identity — outbound credential vending for agent tools.
|
|
3
|
+
*
|
|
4
|
+
* The {@link CredentialProvider} port + adapters. A tool calls
|
|
5
|
+
* `provider.getCredential({ service })` to get a token for a downstream service;
|
|
6
|
+
* `agentCoreIdentity()` backs it with AWS Bedrock AgentCore Identity, or
|
|
7
|
+
* `staticTokens()` for dev/test.
|
|
8
|
+
*
|
|
9
|
+
* SECURITY: a vended token is a secret — use it locally inside a tool's
|
|
10
|
+
* `execute` (e.g. an HTTP header); never write it to tracked scope. See
|
|
11
|
+
* `./identity/types` for the full invariant.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { agentCoreIdentity } from 'agentfootprint/identity';
|
|
16
|
+
*
|
|
17
|
+
* const credentials = agentCoreIdentity({ region: 'us-east-1' });
|
|
18
|
+
* const r = await credentials.getCredential({ service: 'github', mode: 'user', scopes: ['repo'] });
|
|
19
|
+
* if (r.status === 'authorization-required') {
|
|
20
|
+
* // surface r.authorizationUrl to the user (e.g. pause the run), then retry.
|
|
21
|
+
* } else {
|
|
22
|
+
* callGitHub({ headers: { authorization: `Bearer ${r.token}` } });
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { isCredentialToken } from './identity/types.js';
|
|
27
|
+
export { staticTokens } from './identity/staticTokens.js';
|
|
28
|
+
export { agentCoreIdentity, } from './adapters/identity/agentcore.js';
|
|
29
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,iBAAiB,GAIlB,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* staticTokens — a dev/test {@link CredentialProvider} backed by canned tokens.
|
|
4
|
+
*
|
|
5
|
+
* No network, no SDK. Use it to develop tools that need credentials without
|
|
6
|
+
* standing up AgentCore Identity (or any IdP). Production swaps it for
|
|
7
|
+
* `agentCoreIdentity()` — the tool code never changes.
|
|
8
|
+
*
|
|
9
|
+
* const credentials = staticTokens({ github: 'ghp_dev_xxx', slack: 'xoxb-dev' });
|
|
10
|
+
* const r = await credentials.getCredential({ service: 'github' });
|
|
11
|
+
* if (r.status === 'token') useHeader(`Bearer ${r.token}`);
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.staticTokens = void 0;
|
|
15
|
+
/**
|
|
16
|
+
* Build a {@link CredentialProvider} from a `service → token` map. Always 2-legged
|
|
17
|
+
* (returns the token directly); throws if a requested service has no token.
|
|
18
|
+
*/
|
|
19
|
+
function staticTokens(tokens, options = {}) {
|
|
20
|
+
return {
|
|
21
|
+
id: options.id ?? 'static-tokens',
|
|
22
|
+
getCredential(req) {
|
|
23
|
+
const token = tokens[req.service];
|
|
24
|
+
if (!token) {
|
|
25
|
+
return Promise.reject(new Error(`staticTokens: no token configured for service '${req.service}'. ` +
|
|
26
|
+
`Known services: ${Object.keys(tokens).join(', ') || '(none)'}.`));
|
|
27
|
+
}
|
|
28
|
+
return Promise.resolve({
|
|
29
|
+
status: 'token',
|
|
30
|
+
token,
|
|
31
|
+
...(options.expiresAt !== undefined && { expiresAt: options.expiresAt }),
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.staticTokens = staticTokens;
|
|
37
|
+
//# sourceMappingURL=staticTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticTokens.js","sourceRoot":"","sources":["../../src/identity/staticTokens.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAWH;;;GAGG;AACH,SAAgB,YAAY,CAC1B,MAAwC,EACxC,UAA+B,EAAE;IAEjC,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,eAAe;QACjC,aAAa,CAAC,GAAG;YACf,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,kDAAkD,GAAG,CAAC,OAAO,KAAK;oBAChE,mBAAmB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG,CACnE,CACF,CAAC;YACJ,CAAC;YACD,OAAO,OAAO,CAAC,OAAO,CAAC;gBACrB,MAAM,EAAE,OAAO;gBACf,KAAK;gBACL,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;aACzE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAvBD,oCAuBC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentfootprint/identity — the CredentialProvider port.
|
|
4
|
+
*
|
|
5
|
+
* OUTBOUND auth: vend a credential/token so a tool can call a downstream service
|
|
6
|
+
* (GitHub, Slack, Google…) on behalf of the agent or the end user. This is
|
|
7
|
+
* DISTINCT from `agentfootprint/security` (authorization — "is this tool
|
|
8
|
+
* allowed"); identity answers "get me a token to call X".
|
|
9
|
+
*
|
|
10
|
+
* Pattern: Port (Hexagonal). Vendors plug in as adapters:
|
|
11
|
+
* - `agentCoreIdentity()` — AWS Bedrock AgentCore Identity (token vault + OAuth)
|
|
12
|
+
* - `staticTokens()` — dev/test (canned tokens, no network)
|
|
13
|
+
*
|
|
14
|
+
* Two flows, mirroring OAuth (and AgentCore's `M2M` vs `USER_FEDERATION`):
|
|
15
|
+
* - `mode: 'machine'` (2-legged) — client-credentials; returns a token directly.
|
|
16
|
+
* - `mode: 'user'` (3-legged) — user-delegated; may need consent. When it
|
|
17
|
+
* does, the provider returns `authorization-required` with a URL; the agent
|
|
18
|
+
* surfaces it to the human (e.g. via pause/resume) and retries after consent.
|
|
19
|
+
* (Most calls skip consent — providers cache refresh tokens.)
|
|
20
|
+
*
|
|
21
|
+
* **Security invariant:** a vended token is a SECRET. Callers MUST use it locally
|
|
22
|
+
* (e.g. as an HTTP header inside a tool's `execute`) and MUST NOT write it to
|
|
23
|
+
* tracked scope (`setValue`) — tracked writes flow to the commit log, recorders,
|
|
24
|
+
* and observability exporters, which would leak the token into the trace. Pair
|
|
25
|
+
* with `RedactionPolicy` for defence in depth.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.isCredentialToken = void 0;
|
|
29
|
+
/** Narrow a {@link CredentialResult} to the token branch. */
|
|
30
|
+
function isCredentialToken(r) {
|
|
31
|
+
return r.status === 'token';
|
|
32
|
+
}
|
|
33
|
+
exports.isCredentialToken = isCredentialToken;
|
|
34
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/identity/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAyCH,6DAA6D;AAC7D,SAAgB,iBAAiB,CAAC,CAAmB;IACnD,OAAO,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC;AAC9B,CAAC;AAFD,8CAEC"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentfootprint/identity — outbound credential vending for agent tools.
|
|
4
|
+
*
|
|
5
|
+
* The {@link CredentialProvider} port + adapters. A tool calls
|
|
6
|
+
* `provider.getCredential({ service })` to get a token for a downstream service;
|
|
7
|
+
* `agentCoreIdentity()` backs it with AWS Bedrock AgentCore Identity, or
|
|
8
|
+
* `staticTokens()` for dev/test.
|
|
9
|
+
*
|
|
10
|
+
* SECURITY: a vended token is a secret — use it locally inside a tool's
|
|
11
|
+
* `execute` (e.g. an HTTP header); never write it to tracked scope. See
|
|
12
|
+
* `./identity/types` for the full invariant.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { agentCoreIdentity } from 'agentfootprint/identity';
|
|
17
|
+
*
|
|
18
|
+
* const credentials = agentCoreIdentity({ region: 'us-east-1' });
|
|
19
|
+
* const r = await credentials.getCredential({ service: 'github', mode: 'user', scopes: ['repo'] });
|
|
20
|
+
* if (r.status === 'authorization-required') {
|
|
21
|
+
* // surface r.authorizationUrl to the user (e.g. pause the run), then retry.
|
|
22
|
+
* } else {
|
|
23
|
+
* callGitHub({ headers: { authorization: `Bearer ${r.token}` } });
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.agentCoreIdentity = exports.staticTokens = exports.isCredentialToken = void 0;
|
|
29
|
+
var types_js_1 = require("./identity/types.js");
|
|
30
|
+
Object.defineProperty(exports, "isCredentialToken", { enumerable: true, get: function () { return types_js_1.isCredentialToken; } });
|
|
31
|
+
var staticTokens_js_1 = require("./identity/staticTokens.js");
|
|
32
|
+
Object.defineProperty(exports, "staticTokens", { enumerable: true, get: function () { return staticTokens_js_1.staticTokens; } });
|
|
33
|
+
var agentcore_js_1 = require("./adapters/identity/agentcore.js");
|
|
34
|
+
Object.defineProperty(exports, "agentCoreIdentity", { enumerable: true, get: function () { return agentcore_js_1.agentCoreIdentity; } });
|
|
35
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AASH,gDAAwD;AAA/C,6GAAA,iBAAiB,OAAA;AAC1B,8DAAoF;AAA3E,+GAAA,YAAY,OAAA;AACrB,iEAK0C;AAJxC,iHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentCoreIdentity — AWS Bedrock AgentCore Identity adapter (peer-dep
|
|
3
|
+
* `@aws-sdk/client-bedrock-agentcore`).
|
|
4
|
+
*
|
|
5
|
+
* import { agentCoreIdentity } from 'agentfootprint/identity';
|
|
6
|
+
* const credentials = agentCoreIdentity({ region: 'us-east-1' });
|
|
7
|
+
*
|
|
8
|
+
* Maps the {@link CredentialProvider} port onto AgentCore Identity's
|
|
9
|
+
* `GetResourceOauth2Token` (the SDK's `@requires_access_token` underneath):
|
|
10
|
+
* - request.mode 'machine' → `M2M`; 'user' → `USER_FEDERATION`
|
|
11
|
+
* - request.service → the configured OAuth2 credential-provider name
|
|
12
|
+
* - a returned access token → `{ status: 'token' }`
|
|
13
|
+
* - a returned auth URL → `{ status: 'authorization-required' }` (3LO consent)
|
|
14
|
+
*
|
|
15
|
+
* The token vault + refresh-token handling live in AgentCore, so repeat calls
|
|
16
|
+
* usually return a token directly (no consent round-trip).
|
|
17
|
+
*
|
|
18
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the AWS SDK is required only when
|
|
19
|
+
* `getCredential` first runs (or never, if you inject `_client`). NOTE: confirm
|
|
20
|
+
* the SDK command/field names against your installed
|
|
21
|
+
* `@aws-sdk/client-bedrock-agentcore` version — this adapter targets the
|
|
22
|
+
* `GetResourceOauth2Token` shape and is structured so the request→result mapping
|
|
23
|
+
* is unit-tested via the `_client` seam independent of the SDK.
|
|
24
|
+
*/
|
|
25
|
+
import type { CredentialProvider } from '../../identity/types.js';
|
|
26
|
+
/** Raw result shape we consume from the AgentCore identity client. */
|
|
27
|
+
export interface AgentCoreOauthResponse {
|
|
28
|
+
readonly accessToken?: string;
|
|
29
|
+
readonly authorizationUrl?: string;
|
|
30
|
+
readonly sessionId?: string;
|
|
31
|
+
/** Unix seconds. */
|
|
32
|
+
readonly expiresAt?: number;
|
|
33
|
+
}
|
|
34
|
+
/** The minimal client surface the adapter calls — wraps `GetResourceOauth2Token`.
|
|
35
|
+
* The real AWS SDK client is adapted to this; tests inject a fake via `_client`. */
|
|
36
|
+
export interface AgentCoreIdentityClientLike {
|
|
37
|
+
getResourceOauth2Token(input: {
|
|
38
|
+
readonly resourceCredentialProviderName: string;
|
|
39
|
+
readonly scopes: readonly string[];
|
|
40
|
+
readonly oauth2Flow: 'M2M' | 'USER_FEDERATION';
|
|
41
|
+
readonly forceAuthentication: boolean;
|
|
42
|
+
readonly workloadIdentityToken?: string;
|
|
43
|
+
}): Promise<AgentCoreOauthResponse>;
|
|
44
|
+
}
|
|
45
|
+
export interface AgentCoreIdentityOptions {
|
|
46
|
+
readonly region?: string;
|
|
47
|
+
/** The agent's workload access token (AgentCore Runtime injects one in-container;
|
|
48
|
+
* supply it explicitly when running elsewhere). */
|
|
49
|
+
readonly workloadIdentityToken?: string;
|
|
50
|
+
/** Stable provider id (default 'agentcore-identity'). */
|
|
51
|
+
readonly id?: string;
|
|
52
|
+
/** Test seam — inject a client implementing {@link AgentCoreIdentityClientLike}. */
|
|
53
|
+
readonly _client?: AgentCoreIdentityClientLike;
|
|
54
|
+
}
|
|
55
|
+
/** Build a {@link CredentialProvider} backed by AWS Bedrock AgentCore Identity. */
|
|
56
|
+
export declare function agentCoreIdentity(options?: AgentCoreIdentityOptions): CredentialProvider;
|
|
57
|
+
//# sourceMappingURL=agentcore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.d.ts","sourceRoot":"","sources":["../../../../src/adapters/identity/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;qFACqF;AACrF,MAAM,WAAW,2BAA2B;IAC1C,sBAAsB,CAAC,KAAK,EAAE;QAC5B,QAAQ,CAAC,8BAA8B,EAAE,MAAM,CAAC;QAChD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;QACnC,QAAQ,CAAC,UAAU,EAAE,KAAK,GAAG,iBAAiB,CAAC;QAC/C,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;QACtC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;KACzC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;wDACoD;IACpD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,CAAC,EAAE,2BAA2B,CAAC;CAChD;AA8BD,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,kBAAkB,CAqC5F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* staticTokens — a dev/test {@link CredentialProvider} backed by canned tokens.
|
|
3
|
+
*
|
|
4
|
+
* No network, no SDK. Use it to develop tools that need credentials without
|
|
5
|
+
* standing up AgentCore Identity (or any IdP). Production swaps it for
|
|
6
|
+
* `agentCoreIdentity()` — the tool code never changes.
|
|
7
|
+
*
|
|
8
|
+
* const credentials = staticTokens({ github: 'ghp_dev_xxx', slack: 'xoxb-dev' });
|
|
9
|
+
* const r = await credentials.getCredential({ service: 'github' });
|
|
10
|
+
* if (r.status === 'token') useHeader(`Bearer ${r.token}`);
|
|
11
|
+
*/
|
|
12
|
+
import type { CredentialProvider } from './types.js';
|
|
13
|
+
export interface StaticTokensOptions {
|
|
14
|
+
/** Optional id (defaults to 'static-tokens'). */
|
|
15
|
+
readonly id?: string;
|
|
16
|
+
/** Optional fixed expiry (unix seconds) applied to every token. */
|
|
17
|
+
readonly expiresAt?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build a {@link CredentialProvider} from a `service → token` map. Always 2-legged
|
|
21
|
+
* (returns the token directly); throws if a requested service has no token.
|
|
22
|
+
*/
|
|
23
|
+
export declare function staticTokens(tokens: Readonly<Record<string, string>>, options?: StaticTokensOptions): CredentialProvider;
|
|
24
|
+
//# sourceMappingURL=staticTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticTokens.d.ts","sourceRoot":"","sources":["../../../src/identity/staticTokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,YAAY,CAAC;AAEvE,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACxC,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CAoBpB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/identity — the CredentialProvider port.
|
|
3
|
+
*
|
|
4
|
+
* OUTBOUND auth: vend a credential/token so a tool can call a downstream service
|
|
5
|
+
* (GitHub, Slack, Google…) on behalf of the agent or the end user. This is
|
|
6
|
+
* DISTINCT from `agentfootprint/security` (authorization — "is this tool
|
|
7
|
+
* allowed"); identity answers "get me a token to call X".
|
|
8
|
+
*
|
|
9
|
+
* Pattern: Port (Hexagonal). Vendors plug in as adapters:
|
|
10
|
+
* - `agentCoreIdentity()` — AWS Bedrock AgentCore Identity (token vault + OAuth)
|
|
11
|
+
* - `staticTokens()` — dev/test (canned tokens, no network)
|
|
12
|
+
*
|
|
13
|
+
* Two flows, mirroring OAuth (and AgentCore's `M2M` vs `USER_FEDERATION`):
|
|
14
|
+
* - `mode: 'machine'` (2-legged) — client-credentials; returns a token directly.
|
|
15
|
+
* - `mode: 'user'` (3-legged) — user-delegated; may need consent. When it
|
|
16
|
+
* does, the provider returns `authorization-required` with a URL; the agent
|
|
17
|
+
* surfaces it to the human (e.g. via pause/resume) and retries after consent.
|
|
18
|
+
* (Most calls skip consent — providers cache refresh tokens.)
|
|
19
|
+
*
|
|
20
|
+
* **Security invariant:** a vended token is a SECRET. Callers MUST use it locally
|
|
21
|
+
* (e.g. as an HTTP header inside a tool's `execute`) and MUST NOT write it to
|
|
22
|
+
* tracked scope (`setValue`) — tracked writes flow to the commit log, recorders,
|
|
23
|
+
* and observability exporters, which would leak the token into the trace. Pair
|
|
24
|
+
* with `RedactionPolicy` for defence in depth.
|
|
25
|
+
*/
|
|
26
|
+
/** What a tool/agent asks for. `service` ↔ the provider's downstream service id. */
|
|
27
|
+
export interface CredentialRequest {
|
|
28
|
+
/** Downstream service id, e.g. 'github', 'slack', 'google'. */
|
|
29
|
+
readonly service: string;
|
|
30
|
+
/** OAuth scopes to request. */
|
|
31
|
+
readonly scopes?: readonly string[];
|
|
32
|
+
/** `machine` = 2-legged (M2M); `user` = 3-legged (on behalf of a user). Default `machine`. */
|
|
33
|
+
readonly mode?: 'machine' | 'user';
|
|
34
|
+
/** The principal/tenant the token is for (the agent + end-user identity). */
|
|
35
|
+
readonly identity?: {
|
|
36
|
+
readonly principal?: string;
|
|
37
|
+
readonly tenant?: string;
|
|
38
|
+
};
|
|
39
|
+
/** Force a fresh authorization, bypassing any cached/refresh token. */
|
|
40
|
+
readonly forceReauth?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** A ready-to-use credential. `token` is a SECRET — see the security invariant. */
|
|
43
|
+
export interface CredentialToken {
|
|
44
|
+
readonly status: 'token';
|
|
45
|
+
readonly token: string;
|
|
46
|
+
/** Unix seconds when the token expires, if known. */
|
|
47
|
+
readonly expiresAt?: number;
|
|
48
|
+
}
|
|
49
|
+
/** 3-legged consent is required: surface `authorizationUrl` to the user, then
|
|
50
|
+
* retry `getCredential` after they authorize (`sessionId` correlates the flow). */
|
|
51
|
+
export interface CredentialAuthorizationRequired {
|
|
52
|
+
readonly status: 'authorization-required';
|
|
53
|
+
readonly authorizationUrl: string;
|
|
54
|
+
readonly sessionId: string;
|
|
55
|
+
}
|
|
56
|
+
export type CredentialResult = CredentialToken | CredentialAuthorizationRequired;
|
|
57
|
+
/** The port. An adapter implements this against a specific identity backend. */
|
|
58
|
+
export interface CredentialProvider {
|
|
59
|
+
/** Stable id (for logging / "which provider vended this"). */
|
|
60
|
+
readonly id: string;
|
|
61
|
+
getCredential(req: CredentialRequest): Promise<CredentialResult>;
|
|
62
|
+
}
|
|
63
|
+
/** Narrow a {@link CredentialResult} to the token branch. */
|
|
64
|
+
export declare function isCredentialToken(r: CredentialResult): r is CredentialToken;
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9E,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;oFACoF;AACpF,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,+BAA+B,CAAC;AAEjF,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAClE;AAED,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,IAAI,eAAe,CAE3E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/identity — outbound credential vending for agent tools.
|
|
3
|
+
*
|
|
4
|
+
* The {@link CredentialProvider} port + adapters. A tool calls
|
|
5
|
+
* `provider.getCredential({ service })` to get a token for a downstream service;
|
|
6
|
+
* `agentCoreIdentity()` backs it with AWS Bedrock AgentCore Identity, or
|
|
7
|
+
* `staticTokens()` for dev/test.
|
|
8
|
+
*
|
|
9
|
+
* SECURITY: a vended token is a secret — use it locally inside a tool's
|
|
10
|
+
* `execute` (e.g. an HTTP header); never write it to tracked scope. See
|
|
11
|
+
* `./identity/types` for the full invariant.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { agentCoreIdentity } from 'agentfootprint/identity';
|
|
16
|
+
*
|
|
17
|
+
* const credentials = agentCoreIdentity({ region: 'us-east-1' });
|
|
18
|
+
* const r = await credentials.getCredential({ service: 'github', mode: 'user', scopes: ['repo'] });
|
|
19
|
+
* if (r.status === 'authorization-required') {
|
|
20
|
+
* // surface r.authorizationUrl to the user (e.g. pause the run), then retry.
|
|
21
|
+
* } else {
|
|
22
|
+
* callGitHub({ headers: { authorization: `Bearer ${r.token}` } });
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type { CredentialProvider, CredentialRequest, CredentialResult, CredentialToken, CredentialAuthorizationRequired, } from './identity/types.js';
|
|
27
|
+
export { isCredentialToken } from './identity/types.js';
|
|
28
|
+
export { staticTokens, type StaticTokensOptions } from './identity/staticTokens.js';
|
|
29
|
+
export { agentCoreIdentity, type AgentCoreIdentityOptions, type AgentCoreIdentityClientLike, type AgentCoreOauthResponse, } from './adapters/identity/agentcore.js';
|
|
30
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,GAC5B,MAAM,kCAAkC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentfootprint",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sanjay Krishna Anbalagan",
|
|
@@ -145,6 +145,11 @@
|
|
|
145
145
|
"import": "./dist/esm/security/index.js",
|
|
146
146
|
"require": "./dist/security/index.js"
|
|
147
147
|
},
|
|
148
|
+
"./identity": {
|
|
149
|
+
"types": "./dist/types/identity.d.ts",
|
|
150
|
+
"import": "./dist/esm/identity.js",
|
|
151
|
+
"require": "./dist/identity.js"
|
|
152
|
+
},
|
|
148
153
|
"./reliability": {
|
|
149
154
|
"types": "./dist/types/reliability/index.d.ts",
|
|
150
155
|
"import": "./dist/esm/reliability/index.js",
|