bedrock-agentcore 0.1.1 → 0.2.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/README.md +94 -114
- package/dist/src/_utils/endpoints.d.ts +28 -0
- package/dist/src/_utils/endpoints.d.ts.map +1 -0
- package/dist/src/_utils/endpoints.js +44 -0
- package/dist/src/_utils/endpoints.js.map +1 -0
- package/dist/src/identity/client.d.ts +40 -0
- package/dist/src/identity/client.d.ts.map +1 -0
- package/dist/src/identity/client.js +109 -0
- package/dist/src/identity/client.js.map +1 -0
- package/dist/src/identity/index.d.ts +22 -0
- package/dist/src/identity/index.d.ts.map +1 -0
- package/dist/src/identity/index.js +24 -0
- package/dist/src/identity/index.js.map +1 -0
- package/dist/src/identity/types.d.ts +82 -0
- package/dist/src/identity/types.d.ts.map +1 -0
- package/dist/src/identity/types.js +5 -0
- package/dist/src/identity/types.js.map +1 -0
- package/dist/src/identity/wrappers.d.ts +54 -0
- package/dist/src/identity/wrappers.d.ts.map +1 -0
- package/dist/src/identity/wrappers.js +95 -0
- package/dist/src/identity/wrappers.js.map +1 -0
- package/dist/src/runtime/app.d.ts +144 -0
- package/dist/src/runtime/app.d.ts.map +1 -0
- package/dist/src/runtime/app.js +485 -0
- package/dist/src/runtime/app.js.map +1 -0
- package/dist/src/runtime/client.d.ts +154 -0
- package/dist/src/runtime/client.d.ts.map +1 -0
- package/dist/src/runtime/client.js +319 -0
- package/dist/src/runtime/client.js.map +1 -0
- package/dist/src/runtime/context.d.ts +33 -0
- package/dist/src/runtime/context.d.ts.map +1 -0
- package/dist/src/runtime/context.js +49 -0
- package/dist/src/runtime/context.js.map +1 -0
- package/dist/src/runtime/index.d.ts +8 -0
- package/dist/src/runtime/index.d.ts.map +1 -0
- package/dist/src/runtime/index.js +7 -0
- package/dist/src/runtime/index.js.map +1 -0
- package/dist/src/runtime/types.d.ts +429 -0
- package/dist/src/runtime/types.d.ts.map +1 -0
- package/dist/src/runtime/types.js +26 -0
- package/dist/src/runtime/types.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.d.ts +20 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.js +33 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.d.ts +20 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.js +34 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.d.ts +19 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.js +32 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.d.ts +19 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.js +32 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/index.d.ts +25 -0
- package/dist/src/tools/browser/integrations/strands/index.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/index.js +25 -0
- package/dist/src/tools/browser/integrations/strands/index.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.d.ts +21 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.js +41 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.d.ts +29 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.js +52 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/tools.d.ts +119 -0
- package/dist/src/tools/browser/integrations/strands/tools.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/tools.js +141 -0
- package/dist/src/tools/browser/integrations/strands/tools.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.d.ts +22 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.js +37 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/tools.d.ts +1 -1
- package/dist/src/tools/browser/integrations/vercel-ai/tools.js +1 -1
- package/dist/src/tools/code-interpreter/client.d.ts +2 -0
- package/dist/src/tools/code-interpreter/client.d.ts.map +1 -1
- package/dist/src/tools/code-interpreter/client.js +31 -25
- package/dist/src/tools/code-interpreter/client.js.map +1 -1
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.d.ts +28 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.js +47 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.d.ts +27 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.js +42 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.d.ts +33 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.js +78 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.d.ts +32 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.js +32 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.d.ts +94 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.js +112 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.d.ts +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.js +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.d.ts +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.js +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.d.ts +3 -3
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.js +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.d.ts +1 -1
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.js +1 -1
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.d.ts +1 -1
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.js +1 -1
- package/package.json +46 -11
package/README.md
CHANGED
|
@@ -1,156 +1,136 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
</
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
Bedrock AgentCore SDK
|
|
10
|
-
</h1>
|
|
11
|
-
|
|
12
|
-
<h2>
|
|
13
|
-
Deploy your local AI agent to Bedrock AgentCore with zero infrastructure
|
|
14
|
-
</h2>
|
|
15
|
-
|
|
16
|
-
<div align="center">
|
|
17
|
-
<a href="https://github.com/aws/bedrock-agentcore-sdk-typescript/graphs/commit-activity"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/aws/bedrock-agentcore-sdk-typescript"/></a>
|
|
18
|
-
<a href="https://github.com/aws/bedrock-agentcore-sdk-typescript/issues"><img alt="GitHub open issues" src="https://img.shields.io/github/issues/aws/bedrock-agentcore-sdk-typescript"/></a>
|
|
19
|
-
<a href="https://github.com/aws/bedrock-agentcore-sdk-typescript/pulls"><img alt="GitHub open pull requests" src="https://img.shields.io/github/issues-pr/aws/bedrock-agentcore-sdk-typescript"/></a>
|
|
20
|
-
<a href="https://github.com/aws/bedrock-agentcore-sdk-typescript/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/aws/bedrock-agentcore-sdk-typescript"/></a>
|
|
21
|
-
<a href="https://www.npmjs.com/package/bedrock-agentcore"><img alt="npm version" src="https://img.shields.io/npm/v/bedrock-agentcore"/></a>
|
|
22
|
-
<a href="https://nodejs.org"><img alt="Node.js versions" src="https://img.shields.io/node/v/bedrock-agentcore"/></a>
|
|
23
|
-
</div>
|
|
2
|
+
<a href="https://aws.amazon.com/bedrock/agentcore/">
|
|
3
|
+
<img width="150" height="150" alt="Bedrock AgentCore" src="https://github.com/user-attachments/assets/b8b9456d-c9e2-45e1-ac5b-760f21f1ac18" />
|
|
4
|
+
</a>
|
|
5
|
+
|
|
6
|
+
<h1>Bedrock AgentCore SDK for TypeScript</h1>
|
|
7
|
+
|
|
8
|
+
<p>Deploy AI agents to AWS with VM-level isolation and zero infrastructure</p>
|
|
24
9
|
|
|
25
10
|
<p>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
◆ <a href="https://github.com/aws/bedrock-agentcore-sdk-typescript">TypeScript SDK</a>
|
|
32
|
-
◆ <a href="https://github.com/aws/bedrock-agentcore-starter-toolkit">Starter Toolkit</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/bedrock-agentcore"><img alt="npm version" src="https://img.shields.io/npm/v/bedrock-agentcore"/></a>
|
|
12
|
+
<a href="https://www.typescriptlang.org/"><img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-5.5+-blue"/></a>
|
|
13
|
+
<a href="https://nodejs.org/"><img alt="Node.js" src="https://img.shields.io/badge/Node.js-20+-green"/></a>
|
|
14
|
+
<a href="https://github.com/aws/bedrock-agentcore-sdk-typescript/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-Apache%202.0-blue"/></a>
|
|
15
|
+
</p>
|
|
33
16
|
|
|
17
|
+
<p>
|
|
18
|
+
<a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/what-is-bedrock-agentcore.html">Documentation</a>
|
|
19
|
+
|
|
|
20
|
+
<a href="https://github.com/awslabs/bedrock-agentcore-samples-typescript">Samples</a>
|
|
21
|
+
|
|
|
22
|
+
<a href="https://github.com/aws/bedrock-agentcore-sdk-python">Python SDK</a>
|
|
34
23
|
</p>
|
|
35
24
|
</div>
|
|
36
25
|
|
|
37
|
-
|
|
38
|
-
Amazon Bedrock AgentCore enables you to deploy and operate highly effective agents securely, at scale using any framework and model. With Amazon Bedrock AgentCore, developers can accelerate AI agents into production with the scale, reliability, and security, critical to real-world deployment. AgentCore provides tools and capabilities to make agents more effective and capable, purpose-built infrastructure to securely scale agents, and controls to operate trustworthy agents. Amazon Bedrock AgentCore services are composable and work with popular open-source frameworks and any model, so you don’t have to choose between open-source flexibility and enterprise-grade security and reliability.
|
|
26
|
+
---
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
- ✅ **Keep your agent logic** - Works with Strands, LangGraph, CrewAI, Autogen, custom frameworks
|
|
42
|
-
- ✅ **Zero infrastructure management** - No servers, containers, or scaling concerns
|
|
43
|
-
- ✅ **Enterprise-grade platform** - Built-in auth, memory, observability, security
|
|
44
|
-
- ✅ **Production-ready deployment** - Reliable, scalable, compliant hosting
|
|
28
|
+
## Why AgentCore?
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
- 🌐 **Browser** - Cloud-based web automation: **[Browser Quick Start](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/browser-onboarding.html)**
|
|
52
|
-
- 📊 **Observability** - OpenTelemetry tracing: **[Observability Quick Start](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-get-started.html)**
|
|
53
|
-
- 🔐 **Identity** - AWS & third-party auth: **[Identity Quick Start](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/identity-getting-started-cognito.html)**
|
|
30
|
+
- **Zero infrastructure** — No servers to provision, no containers to manage, no scaling to configure.
|
|
31
|
+
- **Session isolation** — Each agent session runs in its own VM. No shared state, no noisy neighbors.
|
|
32
|
+
- **Long-lived sessions** — Sessions persist across requests. Your agent maintains context without external storage.
|
|
33
|
+
- **Managed tools** — Secure code execution and browser automation, ready to use.
|
|
34
|
+
- **Credential management** — Centralized API keys and OAuth tokens, injected at runtime.
|
|
54
35
|
|
|
55
|
-
|
|
36
|
+
Works with [Strands Agents](https://strandsagents.com), [Vercel AI SDK](https://ai-sdk.dev), or any framework.
|
|
56
37
|
|
|
57
|
-
|
|
38
|
+
---
|
|
58
39
|
|
|
59
|
-
##
|
|
40
|
+
## Quick Start
|
|
60
41
|
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm install bedrock-agentcore @strands-agents/sdk
|
|
44
|
+
```
|
|
63
45
|
|
|
64
46
|
```typescript
|
|
65
|
-
|
|
66
|
-
import {
|
|
67
|
-
|
|
68
|
-
// listFiles, deleteFiles, executeCommand
|
|
69
|
-
```
|
|
47
|
+
import { BedrockAgentCoreApp } from 'bedrock-agentcore/runtime'
|
|
48
|
+
import { Agent, BedrockModel } from '@strands-agents/sdk'
|
|
49
|
+
import { z } from 'zod'
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
|
|
51
|
+
const agent = new Agent({
|
|
52
|
+
model: new BedrockModel({ modelId: 'global.amazon.nova-2-lite-v1:0' }),
|
|
53
|
+
})
|
|
73
54
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
55
|
+
const app = new BedrockAgentCoreApp({
|
|
56
|
+
invocationHandler: {
|
|
57
|
+
requestSchema: z.object({ prompt: z.string() }),
|
|
58
|
+
process: async function* (request) {
|
|
59
|
+
for await (const event of agent.stream(request.prompt)) {
|
|
60
|
+
if (event.delta?.text) yield { text: event.delta.text }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
app.run()
|
|
79
67
|
```
|
|
80
68
|
|
|
81
|
-
|
|
69
|
+
`BedrockAgentCoreApp` creates an AgentCore Runtime-compliant server—handling request parsing, streaming responses, and session management for seamless deployment.
|
|
82
70
|
|
|
83
|
-
|
|
71
|
+
---
|
|
84
72
|
|
|
85
|
-
|
|
73
|
+
## Tools
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
# Install the SDK
|
|
89
|
-
npm install bedrock-agentcore
|
|
75
|
+
Give your agent secure code execution with three lines:
|
|
90
76
|
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
```typescript
|
|
78
|
+
import { CodeInterpreterTools } from 'bedrock-agentcore/tools/code-interpreter/strands'
|
|
79
|
+
import { Agent, BedrockModel } from '@strands-agents/sdk'
|
|
80
|
+
|
|
81
|
+
const codeInterpreter = new CodeInterpreterTools({ region: 'us-east-1' })
|
|
82
|
+
|
|
83
|
+
const agent = new Agent({
|
|
84
|
+
model: new BedrockModel({ modelId: 'global.amazon.nova-2-lite-v1:0' }),
|
|
85
|
+
tools: codeInterpreter.getTools(),
|
|
86
|
+
})
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
npm install playwright
|
|
88
|
+
// Agent can now execute code in a secure sandboxed environment
|
|
96
89
|
```
|
|
97
90
|
|
|
98
|
-
|
|
99
|
-
- Node.js >= 20.0.0
|
|
100
|
-
- [AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) with Bedrock AgentCore access
|
|
101
|
-
- Access to any large language model like models available in AWS Bedrock
|
|
91
|
+
---
|
|
102
92
|
|
|
93
|
+
## Features
|
|
103
94
|
|
|
104
|
-
|
|
95
|
+
- **Runtime** — Secure, session-isolated compute → [Examples](https://github.com/awslabs/bedrock-agentcore-samples-typescript/tree/main/primitives/runtime)
|
|
96
|
+
- **Code Interpreter** — Execute Python/JS/TS in a sandbox → [Examples](https://github.com/awslabs/bedrock-agentcore-samples-typescript/tree/main/primitives/tools/code-interpreter)
|
|
97
|
+
- **Browser** — Cloud-based web automation → [Examples](https://github.com/awslabs/bedrock-agentcore-samples-typescript/tree/main/primitives/tools/browser)
|
|
98
|
+
- **Identity** — Manage API keys and OAuth tokens → [Examples](https://github.com/awslabs/bedrock-agentcore-samples-typescript/tree/main/primitives/identity)
|
|
99
|
+
- **Memory** — Persistent knowledge across sessions (coming soon)
|
|
100
|
+
- **Gateway** — Transform APIs into MCP tools (coming soon)
|
|
101
|
+
- **Observability** — OpenTelemetry tracing (coming soon)
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
import { bedrock } from '@ai-sdk/amazon-bedrock'
|
|
108
|
-
import { ToolLoopAgent } from 'ai'
|
|
109
|
-
import { CodeInterpreterTools } from 'bedrock-agentcore/code-interpreter/vercel-ai'
|
|
110
|
-
import { BrowserTools } from 'bedrock-agentcore/browser/vercel-ai'
|
|
111
|
-
|
|
112
|
-
const codeInterpreter = new CodeInterpreterTools()
|
|
113
|
-
const browser = new BrowserTools()
|
|
114
|
-
|
|
115
|
-
const agent = new ToolLoopAgent({
|
|
116
|
-
model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
117
|
-
tools: {
|
|
118
|
-
...codeInterpreter.tools,
|
|
119
|
-
...browser.tools,
|
|
120
|
-
},
|
|
121
|
-
})
|
|
103
|
+
---
|
|
122
104
|
|
|
123
|
-
|
|
124
|
-
const result = await agent.run({
|
|
125
|
-
prompt: 'Visit news.ycombinator.com, scrape the top 5 stories, and analyze sentiment',
|
|
126
|
-
})
|
|
105
|
+
## Installation
|
|
127
106
|
|
|
128
|
-
|
|
107
|
+
```bash
|
|
108
|
+
npm install bedrock-agentcore
|
|
129
109
|
```
|
|
130
110
|
|
|
131
|
-
> **Note:** If deploying to Vercel, use [Vercel OIDC](https://vercel.com/docs/oidc/aws) for secure AWS credentials.
|
|
132
111
|
|
|
133
|
-
|
|
112
|
+
**Prerequisites:** Node.js 20+, [AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html), [AgentCore access](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-regions.html)
|
|
134
113
|
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
npx tsx examples/agent-with-code-interpreter.ts
|
|
138
|
-
```
|
|
114
|
+
---
|
|
139
115
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
116
|
+
## Deployment
|
|
117
|
+
|
|
118
|
+
- [Sample Applications](https://github.com/awslabs/bedrock-agentcore-samples-typescript) — Working examples with deployment templates
|
|
119
|
+
- [CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/AWS_BedrockAgentCore.html) — Infrastructure as code
|
|
120
|
+
- [AWS CDK](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore-readme.html) — Infrastructure as code
|
|
121
|
+
- [Deployment Guide](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/getting-started-custom.html) — Step-by-step walkthrough
|
|
122
|
+
|
|
123
|
+
---
|
|
144
124
|
|
|
145
|
-
##
|
|
125
|
+
## Resources
|
|
146
126
|
|
|
147
|
-
|
|
127
|
+
- [AgentCore Documentation](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/what-is-bedrock-agentcore.html)
|
|
128
|
+
- [Python SDK](https://github.com/aws/bedrock-agentcore-sdk-python)
|
|
148
129
|
|
|
149
|
-
|
|
130
|
+
---
|
|
150
131
|
|
|
132
|
+
## License
|
|
151
133
|
|
|
152
|
-
|
|
134
|
+
Apache 2.0 — see [LICENSE](LICENSE)
|
|
153
135
|
|
|
154
|
-
|
|
155
|
-
- **Contributing:** See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
156
|
-
- **Security:** See [SECURITY.md](SECURITY.md)
|
|
136
|
+
[Contributing](CONTRIBUTING.md) · [Security](SECURITY.md)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for constructing AWS service endpoints.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Gets the data plane endpoint for the Bedrock AgentCore service.
|
|
6
|
+
*
|
|
7
|
+
* The endpoint can be overridden using the BEDROCK_AGENTCORE_DATA_PLANE_ENDPOINT
|
|
8
|
+
* environment variable. Otherwise, it follows the standard AWS endpoint pattern.
|
|
9
|
+
*
|
|
10
|
+
* @param region - AWS region (e.g., 'us-west-2', 'us-east-1')
|
|
11
|
+
* @returns Full HTTPS endpoint URL
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const endpoint = getDataPlaneEndpoint('us-west-2')
|
|
16
|
+
* // Returns: 'https://bedrock-agentcore.us-west-2.amazonaws.com'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* With environment variable override:
|
|
21
|
+
* ```typescript
|
|
22
|
+
* process.env.BEDROCK_AGENTCORE_DATA_PLANE_ENDPOINT = 'https://custom-endpoint.example.com'
|
|
23
|
+
* const endpoint = getDataPlaneEndpoint('us-west-2')
|
|
24
|
+
* // Returns: 'https://custom-endpoint.example.com'
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDataPlaneEndpoint(region: string): string;
|
|
28
|
+
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/_utils/endpoints.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAc3D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for constructing AWS service endpoints.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Environment variable for overriding the data plane endpoint.
|
|
6
|
+
*/
|
|
7
|
+
const ENDPOINT_OVERRIDE_ENV = 'BEDROCK_AGENTCORE_DATA_PLANE_ENDPOINT';
|
|
8
|
+
/**
|
|
9
|
+
* Gets the data plane endpoint for the Bedrock AgentCore service.
|
|
10
|
+
*
|
|
11
|
+
* The endpoint can be overridden using the BEDROCK_AGENTCORE_DATA_PLANE_ENDPOINT
|
|
12
|
+
* environment variable. Otherwise, it follows the standard AWS endpoint pattern.
|
|
13
|
+
*
|
|
14
|
+
* @param region - AWS region (e.g., 'us-west-2', 'us-east-1')
|
|
15
|
+
* @returns Full HTTPS endpoint URL
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const endpoint = getDataPlaneEndpoint('us-west-2')
|
|
20
|
+
* // Returns: 'https://bedrock-agentcore.us-west-2.amazonaws.com'
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* With environment variable override:
|
|
25
|
+
* ```typescript
|
|
26
|
+
* process.env.BEDROCK_AGENTCORE_DATA_PLANE_ENDPOINT = 'https://custom-endpoint.example.com'
|
|
27
|
+
* const endpoint = getDataPlaneEndpoint('us-west-2')
|
|
28
|
+
* // Returns: 'https://custom-endpoint.example.com'
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function getDataPlaneEndpoint(region) {
|
|
32
|
+
// Validate region is not empty
|
|
33
|
+
if (!region || region.trim() === '') {
|
|
34
|
+
throw new Error('Region cannot be empty');
|
|
35
|
+
}
|
|
36
|
+
// Check for environment variable override
|
|
37
|
+
const override = process.env[ENDPOINT_OVERRIDE_ENV];
|
|
38
|
+
if (override) {
|
|
39
|
+
return override;
|
|
40
|
+
}
|
|
41
|
+
// Return standard AWS endpoint pattern
|
|
42
|
+
return `https://bedrock-agentcore.${region}.amazonaws.com`;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../../src/_utils/endpoints.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,qBAAqB,GAAG,uCAAuC,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,+BAA+B;IAC/B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC3C,CAAC;IAED,0CAA0C;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IACnD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,uCAAuC;IACvC,OAAO,6BAA6B,MAAM,gBAAgB,CAAA;AAC5D,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IdentityClient for AgentCore Identity operations
|
|
3
|
+
*/
|
|
4
|
+
import type { OAuth2TokenRequest, ApiKeyRequest } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Client for interacting with Amazon Bedrock AgentCore Identity service.
|
|
7
|
+
* Provides methods for managing workload identities, credential providers,
|
|
8
|
+
* and retrieving OAuth2 tokens and API keys.
|
|
9
|
+
*/
|
|
10
|
+
export declare class IdentityClient {
|
|
11
|
+
private readonly dataPlaneClient;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new IdentityClient instance
|
|
14
|
+
* @param region - AWS region (defaults to AWS_REGION env var)
|
|
15
|
+
* @throws Error if region cannot be determined
|
|
16
|
+
*/
|
|
17
|
+
constructor(region?: string);
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves an OAuth2 access token from AgentCore Identity.
|
|
20
|
+
* Handles both M2M (immediate) and USER_FEDERATION (polling) flows.
|
|
21
|
+
*
|
|
22
|
+
* @param request - OAuth2 token request parameters
|
|
23
|
+
* @returns OAuth2 access token
|
|
24
|
+
* @throws Error if token retrieval fails or times out
|
|
25
|
+
*/
|
|
26
|
+
getOAuth2Token(request: OAuth2TokenRequest): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Polls for OAuth2 token until available or timeout
|
|
29
|
+
*/
|
|
30
|
+
private pollForToken;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves an API key from AgentCore Identity token vault.
|
|
33
|
+
*
|
|
34
|
+
* @param request - API key request parameters
|
|
35
|
+
* @returns API key string
|
|
36
|
+
* @throws Error if API key retrieval fails
|
|
37
|
+
*/
|
|
38
|
+
getApiKey(request: ApiKeyRequest): Promise<string>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/identity/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAKnE;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwB;IAExD;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM;IAU3B;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAsClE;;OAEG;YACW,YAAY;IA6B1B;;;;;;OAMG;IACG,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;CAczD"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IdentityClient for AgentCore Identity operations
|
|
3
|
+
*/
|
|
4
|
+
import { BedrockAgentCoreClient, GetResourceOauth2TokenCommand, GetResourceApiKeyCommand, } from '@aws-sdk/client-bedrock-agentcore';
|
|
5
|
+
const POLLING_INTERVAL_MS = 5000; // 5 seconds
|
|
6
|
+
const POLLING_TIMEOUT_MS = 600000; // 10 minutes
|
|
7
|
+
/**
|
|
8
|
+
* Client for interacting with Amazon Bedrock AgentCore Identity service.
|
|
9
|
+
* Provides methods for managing workload identities, credential providers,
|
|
10
|
+
* and retrieving OAuth2 tokens and API keys.
|
|
11
|
+
*/
|
|
12
|
+
export class IdentityClient {
|
|
13
|
+
dataPlaneClient;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new IdentityClient instance
|
|
16
|
+
* @param region - AWS region (defaults to AWS_REGION env var)
|
|
17
|
+
* @throws Error if region cannot be determined
|
|
18
|
+
*/
|
|
19
|
+
constructor(region) {
|
|
20
|
+
const resolvedRegion = region || process.env.AWS_REGION;
|
|
21
|
+
if (!resolvedRegion) {
|
|
22
|
+
throw new Error('AWS region must be specified either as a parameter or via AWS_REGION environment variable');
|
|
23
|
+
}
|
|
24
|
+
this.dataPlaneClient = new BedrockAgentCoreClient({ region: resolvedRegion });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves an OAuth2 access token from AgentCore Identity.
|
|
28
|
+
* Handles both M2M (immediate) and USER_FEDERATION (polling) flows.
|
|
29
|
+
*
|
|
30
|
+
* @param request - OAuth2 token request parameters
|
|
31
|
+
* @returns OAuth2 access token
|
|
32
|
+
* @throws Error if token retrieval fails or times out
|
|
33
|
+
*/
|
|
34
|
+
async getOAuth2Token(request) {
|
|
35
|
+
const command = new GetResourceOauth2TokenCommand({
|
|
36
|
+
resourceCredentialProviderName: request.providerName,
|
|
37
|
+
scopes: request.scopes,
|
|
38
|
+
oauth2Flow: request.authFlow,
|
|
39
|
+
workloadIdentityToken: request.workloadIdentityToken,
|
|
40
|
+
resourceOauth2ReturnUrl: request.callbackUrl,
|
|
41
|
+
forceAuthentication: request.forceAuthentication,
|
|
42
|
+
sessionUri: request.sessionUri,
|
|
43
|
+
customState: request.customState,
|
|
44
|
+
customParameters: request.customParameters,
|
|
45
|
+
});
|
|
46
|
+
const response = await this.dataPlaneClient.send(command);
|
|
47
|
+
// M2M flow - token returned immediately
|
|
48
|
+
if (response.accessToken) {
|
|
49
|
+
return response.accessToken;
|
|
50
|
+
}
|
|
51
|
+
// USER_FEDERATION flow - authorization URL returned
|
|
52
|
+
if (response.authorizationUrl) {
|
|
53
|
+
// Invoke callback if provided
|
|
54
|
+
if (request.onAuthUrl) {
|
|
55
|
+
await request.onAuthUrl(response.authorizationUrl);
|
|
56
|
+
}
|
|
57
|
+
// Poll for token
|
|
58
|
+
return this.pollForToken({
|
|
59
|
+
...request,
|
|
60
|
+
sessionUri: response.sessionUri,
|
|
61
|
+
forceAuthentication: false,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
throw new Error('Identity service did not return a token or authorization URL');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Polls for OAuth2 token until available or timeout
|
|
68
|
+
*/
|
|
69
|
+
async pollForToken(request) {
|
|
70
|
+
const startTime = Date.now();
|
|
71
|
+
while (Date.now() - startTime < POLLING_TIMEOUT_MS) {
|
|
72
|
+
await new Promise((resolve) => globalThis.setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
73
|
+
const command = new GetResourceOauth2TokenCommand({
|
|
74
|
+
resourceCredentialProviderName: request.providerName,
|
|
75
|
+
scopes: request.scopes,
|
|
76
|
+
oauth2Flow: request.authFlow,
|
|
77
|
+
workloadIdentityToken: request.workloadIdentityToken,
|
|
78
|
+
sessionUri: request.sessionUri,
|
|
79
|
+
resourceOauth2ReturnUrl: request.callbackUrl,
|
|
80
|
+
customState: request.customState,
|
|
81
|
+
customParameters: request.customParameters,
|
|
82
|
+
});
|
|
83
|
+
const response = await this.dataPlaneClient.send(command);
|
|
84
|
+
if (response.accessToken) {
|
|
85
|
+
return response.accessToken;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`Polling timed out after ${POLLING_TIMEOUT_MS / 1000} seconds. User may not have completed authorization.`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves an API key from AgentCore Identity token vault.
|
|
92
|
+
*
|
|
93
|
+
* @param request - API key request parameters
|
|
94
|
+
* @returns API key string
|
|
95
|
+
* @throws Error if API key retrieval fails
|
|
96
|
+
*/
|
|
97
|
+
async getApiKey(request) {
|
|
98
|
+
const command = new GetResourceApiKeyCommand({
|
|
99
|
+
resourceCredentialProviderName: request.providerName,
|
|
100
|
+
workloadIdentityToken: request.workloadIdentityToken,
|
|
101
|
+
});
|
|
102
|
+
const response = await this.dataPlaneClient.send(command);
|
|
103
|
+
if (!response.apiKey) {
|
|
104
|
+
throw new Error(`No API key returned for provider: ${request.providerName}`);
|
|
105
|
+
}
|
|
106
|
+
return response.apiKey;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/identity/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,mCAAmC,CAAA;AAG1C,MAAM,mBAAmB,GAAG,IAAI,CAAA,CAAC,YAAY;AAC7C,MAAM,kBAAkB,GAAG,MAAM,CAAA,CAAC,aAAa;AAE/C;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACR,eAAe,CAAwB;IAExD;;;;OAIG;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EAAE,OAAO,CAAC,YAAY;YACpD,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;SACrD,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAEzD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;QAC9E,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentCore Identity SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides identity and credential management for AI agents.
|
|
5
|
+
* Supports inbound authentication (SigV4, JWT) and outbound authentication (OAuth2, API keys).
|
|
6
|
+
*
|
|
7
|
+
* @example HOF wrapper usage
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { withAccessToken } from '@aws/bedrock-agentcore-sdk';
|
|
10
|
+
*
|
|
11
|
+
* const myTool = withAccessToken({
|
|
12
|
+
* providerName: 'github',
|
|
13
|
+
* scopes: ['repo'],
|
|
14
|
+
* authFlow: 'M2M',
|
|
15
|
+
* })(async (input: string, token: string) => {
|
|
16
|
+
* // Token automatically injected
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { withAccessToken, withApiKey } from './wrappers.js';
|
|
21
|
+
export * from './types.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG3D,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentCore Identity SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides identity and credential management for AI agents.
|
|
5
|
+
* Supports inbound authentication (SigV4, JWT) and outbound authentication (OAuth2, API keys).
|
|
6
|
+
*
|
|
7
|
+
* @example HOF wrapper usage
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { withAccessToken } from '@aws/bedrock-agentcore-sdk';
|
|
10
|
+
*
|
|
11
|
+
* const myTool = withAccessToken({
|
|
12
|
+
* providerName: 'github',
|
|
13
|
+
* scopes: ['repo'],
|
|
14
|
+
* authFlow: 'M2M',
|
|
15
|
+
* })(async (input: string, token: string) => {
|
|
16
|
+
* // Token automatically injected
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
// Higher-order functions for wrapping tools
|
|
21
|
+
export { withAccessToken, withApiKey } from './wrappers.js';
|
|
22
|
+
// All type definitions
|
|
23
|
+
export * from './types.js';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,4CAA4C;AAC5C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE3D,uBAAuB;AACvB,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for AgentCore Identity SDK
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Request parameters for retrieving an OAuth2 access token
|
|
6
|
+
*/
|
|
7
|
+
export interface OAuth2TokenRequest {
|
|
8
|
+
/** Name of the credential provider */
|
|
9
|
+
providerName: string;
|
|
10
|
+
/** OAuth2 scopes to request */
|
|
11
|
+
scopes: string[];
|
|
12
|
+
/** Authentication flow type */
|
|
13
|
+
authFlow: 'M2M' | 'USER_FEDERATION';
|
|
14
|
+
/** Workload identity token for authentication */
|
|
15
|
+
workloadIdentityToken: string;
|
|
16
|
+
/** OAuth2 callback URL (must be pre-registered) */
|
|
17
|
+
callbackUrl?: string | undefined;
|
|
18
|
+
/** Force re-authentication even if token exists in vault */
|
|
19
|
+
forceAuthentication?: boolean | undefined;
|
|
20
|
+
/** Session URI for polling subsequent requests */
|
|
21
|
+
sessionUri?: string | undefined;
|
|
22
|
+
/** Custom state for callback validation */
|
|
23
|
+
customState?: string | undefined;
|
|
24
|
+
/** Custom parameters for authorization request */
|
|
25
|
+
customParameters?: Record<string, string> | undefined;
|
|
26
|
+
/** Callback invoked when authorization URL is returned */
|
|
27
|
+
onAuthUrl?: ((url: string) => void | Promise<void>) | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Request parameters for retrieving an API key
|
|
31
|
+
*/
|
|
32
|
+
export interface ApiKeyRequest {
|
|
33
|
+
/** Name of the credential provider */
|
|
34
|
+
providerName: string;
|
|
35
|
+
/** Workload identity token for authentication */
|
|
36
|
+
workloadIdentityToken: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for withAccessToken HOF wrapper
|
|
40
|
+
*/
|
|
41
|
+
export interface OAuth2WrapperConfig {
|
|
42
|
+
/**
|
|
43
|
+
* Workload identity token for authentication.
|
|
44
|
+
* Optional - if not provided, automatically falls back to context.workloadAccessToken
|
|
45
|
+
* when called within a request handler. If neither is available, an error is thrown.
|
|
46
|
+
*/
|
|
47
|
+
workloadIdentityToken?: string | undefined;
|
|
48
|
+
/** Name of the credential provider */
|
|
49
|
+
providerName: string;
|
|
50
|
+
/** OAuth2 scopes to request */
|
|
51
|
+
scopes: string[];
|
|
52
|
+
/** Authentication flow type */
|
|
53
|
+
authFlow: 'M2M' | 'USER_FEDERATION';
|
|
54
|
+
/** Callback invoked when authorization URL is returned */
|
|
55
|
+
onAuthUrl?: ((url: string) => void | Promise<void>) | undefined;
|
|
56
|
+
/** Force re-authentication even if token exists in vault */
|
|
57
|
+
forceAuthentication?: boolean | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* OAuth2 callback URL (must be pre-registered).
|
|
60
|
+
* Optional - if not provided, automatically falls back to context.oauth2CallbackUrl
|
|
61
|
+
* when called within a request handler.
|
|
62
|
+
*/
|
|
63
|
+
callbackUrl?: string | undefined;
|
|
64
|
+
/** Custom state for callback validation */
|
|
65
|
+
customState?: string | undefined;
|
|
66
|
+
/** Custom parameters for authorization request */
|
|
67
|
+
customParameters?: Record<string, string> | undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for withApiKey HOF wrapper
|
|
71
|
+
*/
|
|
72
|
+
export interface ApiKeyWrapperConfig {
|
|
73
|
+
/**
|
|
74
|
+
* Workload identity token for authentication.
|
|
75
|
+
* Optional - if not provided, automatically falls back to context.workloadAccessToken
|
|
76
|
+
* when called within a request handler. If neither is available, an error is thrown.
|
|
77
|
+
*/
|
|
78
|
+
workloadIdentityToken?: string | undefined;
|
|
79
|
+
/** Name of the credential provider */
|
|
80
|
+
providerName: string;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAA;IACpB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,KAAK,GAAG,iBAAiB,CAAA;IACnC,iDAAiD;IACjD,qBAAqB,EAAE,MAAM,CAAA;IAC7B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACzC,kDAAk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