arc-1 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +222 -0
- package/bin/arc1.js +12 -0
- package/dist/adt/btp.d.ts +122 -0
- package/dist/adt/btp.d.ts.map +1 -0
- package/dist/adt/btp.js +392 -0
- package/dist/adt/btp.js.map +1 -0
- package/dist/adt/client.d.ts +89 -0
- package/dist/adt/client.d.ts.map +1 -0
- package/dist/adt/client.js +208 -0
- package/dist/adt/client.js.map +1 -0
- package/dist/adt/codeintel.d.ts +38 -0
- package/dist/adt/codeintel.d.ts.map +1 -0
- package/dist/adt/codeintel.js +61 -0
- package/dist/adt/codeintel.js.map +1 -0
- package/dist/adt/config.d.ts +65 -0
- package/dist/adt/config.d.ts.map +1 -0
- package/dist/adt/config.js +35 -0
- package/dist/adt/config.js.map +1 -0
- package/dist/adt/cookies.d.ts +27 -0
- package/dist/adt/cookies.d.ts.map +1 -0
- package/dist/adt/cookies.js +67 -0
- package/dist/adt/cookies.js.map +1 -0
- package/dist/adt/crud.d.ts +35 -0
- package/dist/adt/crud.d.ts.map +1 -0
- package/dist/adt/crud.js +87 -0
- package/dist/adt/crud.js.map +1 -0
- package/dist/adt/devtools.d.ts +32 -0
- package/dist/adt/devtools.d.ts.map +1 -0
- package/dist/adt/devtools.js +154 -0
- package/dist/adt/devtools.js.map +1 -0
- package/dist/adt/errors.d.ts +49 -0
- package/dist/adt/errors.d.ts.map +1 -0
- package/dist/adt/errors.js +80 -0
- package/dist/adt/errors.js.map +1 -0
- package/dist/adt/features.d.ts +44 -0
- package/dist/adt/features.d.ts.map +1 -0
- package/dist/adt/features.js +173 -0
- package/dist/adt/features.js.map +1 -0
- package/dist/adt/http.d.ts +116 -0
- package/dist/adt/http.d.ts.map +1 -0
- package/dist/adt/http.js +374 -0
- package/dist/adt/http.js.map +1 -0
- package/dist/adt/safety.d.ts +70 -0
- package/dist/adt/safety.d.ts.map +1 -0
- package/dist/adt/safety.js +222 -0
- package/dist/adt/safety.js.map +1 -0
- package/dist/adt/transport.d.ts +18 -0
- package/dist/adt/transport.d.ts.map +1 -0
- package/dist/adt/transport.js +66 -0
- package/dist/adt/transport.js.map +1 -0
- package/dist/adt/types.d.ts +91 -0
- package/dist/adt/types.d.ts.map +1 -0
- package/dist/adt/types.js +9 -0
- package/dist/adt/types.js.map +1 -0
- package/dist/adt/xml-parser.d.ts +109 -0
- package/dist/adt/xml-parser.d.ts.map +1 -0
- package/dist/adt/xml-parser.js +283 -0
- package/dist/adt/xml-parser.js.map +1 -0
- package/dist/cache/cache.d.ts +61 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/dist/cache/cache.js +14 -0
- package/dist/cache/cache.js.map +1 -0
- package/dist/cache/memory.d.ts +25 -0
- package/dist/cache/memory.d.ts.map +1 -0
- package/dist/cache/memory.js +69 -0
- package/dist/cache/memory.js.map +1 -0
- package/dist/cache/sqlite.d.ts +26 -0
- package/dist/cache/sqlite.d.ts.map +1 -0
- package/dist/cache/sqlite.js +130 -0
- package/dist/cache/sqlite.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +101 -0
- package/dist/cli.js.map +1 -0
- package/dist/context/compressor.d.ts +33 -0
- package/dist/context/compressor.d.ts.map +1 -0
- package/dist/context/compressor.js +208 -0
- package/dist/context/compressor.js.map +1 -0
- package/dist/context/contract.d.ts +14 -0
- package/dist/context/contract.d.ts.map +1 -0
- package/dist/context/contract.js +202 -0
- package/dist/context/contract.js.map +1 -0
- package/dist/context/deps.d.ts +32 -0
- package/dist/context/deps.d.ts.map +1 -0
- package/dist/context/deps.js +240 -0
- package/dist/context/deps.js.map +1 -0
- package/dist/context/types.d.ts +56 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/context/types.js +10 -0
- package/dist/context/types.js.map +1 -0
- package/dist/handlers/intent.d.ts +46 -0
- package/dist/handlers/intent.d.ts.map +1 -0
- package/dist/handlers/intent.js +539 -0
- package/dist/handlers/intent.js.map +1 -0
- package/dist/handlers/tools.d.ts +21 -0
- package/dist/handlers/tools.d.ts.map +1 -0
- package/dist/handlers/tools.js +260 -0
- package/dist/handlers/tools.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/lint/lint.d.ts +35 -0
- package/dist/lint/lint.d.ts.map +1 -0
- package/dist/lint/lint.js +67 -0
- package/dist/lint/lint.js.map +1 -0
- package/dist/server/audit.d.ts +96 -0
- package/dist/server/audit.d.ts.map +1 -0
- package/dist/server/audit.js +27 -0
- package/dist/server/audit.js.map +1 -0
- package/dist/server/config.d.ts +19 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +101 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/context.d.ts +20 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +20 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/elicit.d.ts +43 -0
- package/dist/server/elicit.d.ts.map +1 -0
- package/dist/server/elicit.js +183 -0
- package/dist/server/elicit.js.map +1 -0
- package/dist/server/http.d.ts +34 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +328 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server/logger.d.ts +57 -0
- package/dist/server/logger.d.ts.map +1 -0
- package/dist/server/logger.js +129 -0
- package/dist/server/logger.js.map +1 -0
- package/dist/server/server.d.ts +25 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +307 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/sinks/btp-auditlog.d.ts +48 -0
- package/dist/server/sinks/btp-auditlog.d.ts.map +1 -0
- package/dist/server/sinks/btp-auditlog.js +232 -0
- package/dist/server/sinks/btp-auditlog.js.map +1 -0
- package/dist/server/sinks/file.d.ts +22 -0
- package/dist/server/sinks/file.d.ts.map +1 -0
- package/dist/server/sinks/file.js +59 -0
- package/dist/server/sinks/file.js.map +1 -0
- package/dist/server/sinks/stderr.d.ts +19 -0
- package/dist/server/sinks/stderr.d.ts.map +1 -0
- package/dist/server/sinks/stderr.js +63 -0
- package/dist/server/sinks/stderr.js.map +1 -0
- package/dist/server/sinks/types.d.ts +14 -0
- package/dist/server/sinks/types.d.ts.map +1 -0
- package/dist/server/sinks/types.js +8 -0
- package/dist/server/sinks/types.js.map +1 -0
- package/dist/server/types.d.ts +54 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +42 -0
- package/dist/server/types.js.map +1 -0
- package/dist/server/xsuaa.d.ts +77 -0
- package/dist/server/xsuaa.d.ts.map +1 -0
- package/dist/server/xsuaa.js +364 -0
- package/dist/server/xsuaa.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Alice Vinogradova and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# arc1 — SAP ADT MCP Server
|
|
2
|
+
|
|
3
|
+
**ARC-1 (ABAP Relay Connector) — Enterprise-ready proxy between AI clients and SAP systems.**
|
|
4
|
+
|
|
5
|
+
arc1 is a TypeScript MCP server (distributed as an npm package and Docker image) that implements the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) and translates AI tool calls into [SAP ABAP Development Tools (ADT)](https://help.sap.com/docs/abap-cloud/abap-development-tools-user-guide/about-abap-development-tools) REST API requests. It works with Claude, GitHub Copilot, VS Code, and any MCP-compatible client.
|
|
6
|
+
|
|
7
|
+
> **This repository** ([marianfoo/arc-1](https://github.com/marianfoo/arc-1)) is the actively maintained fork, continued from the original [oisee/vibing-steampunk](https://github.com/oisee/vibing-steampunk).
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Why arc1?
|
|
12
|
+
|
|
13
|
+
| | [abap-adt-api](https://github.com/marcellourbani/abap-adt-api) | [mcp-abap-adt](https://github.com/mario-andreschak/mcp-abap-adt) | **arc1** |
|
|
14
|
+
|---|:---:|:---:|:---:|
|
|
15
|
+
| npm package + Docker image | — | — | **Y** |
|
|
16
|
+
| Read-only mode / package whitelist | — | — | **Y** |
|
|
17
|
+
| Transport controls (CTS safety) | — | — | **Y** |
|
|
18
|
+
| HTTP Streamable transport (Copilot Studio) | — | — | **Y** |
|
|
19
|
+
| 11 intent-based tools (~5K schema tokens) | — | — | **Y** |
|
|
20
|
+
| Method-level read/edit (95% token reduction) | — | — | **Y** |
|
|
21
|
+
| Context compression (7–30x) | — | — | **Y** |
|
|
22
|
+
| Works with 8+ MCP clients | — | — | **Y** |
|
|
23
|
+
|
|
24
|
+
As an **admin**, you control what the AI can and cannot do:
|
|
25
|
+
- Restrict to read-only, specific packages, or whitelisted operations
|
|
26
|
+
- Require transport assignments before any write
|
|
27
|
+
- Block free-form SQL execution
|
|
28
|
+
- Allow or deny individual operation types per deployment
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Run directly with npx (no install needed)
|
|
34
|
+
npx arc-1 --url https://your-sap-host:44300 --user YOUR_USER
|
|
35
|
+
|
|
36
|
+
# Or install globally
|
|
37
|
+
npm install -g arc-1
|
|
38
|
+
arc1 --url https://your-sap-host:44300 --user YOUR_USER
|
|
39
|
+
|
|
40
|
+
# Or use Docker
|
|
41
|
+
docker run -e SAP_URL=https://host:44300 -e SAP_USER=dev -e SAP_PASSWORD=secret \
|
|
42
|
+
ghcr.io/marianfoo/arc-1
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Connect Your Client
|
|
46
|
+
|
|
47
|
+
### Claude Desktop
|
|
48
|
+
|
|
49
|
+
Add to `~/.config/claude/claude_desktop_config.json`:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"sap": {
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": ["-y", "arc-1"],
|
|
57
|
+
"env": {
|
|
58
|
+
"SAP_URL": "https://your-sap-host:44300",
|
|
59
|
+
"SAP_USER": "your-username",
|
|
60
|
+
"SAP_PASSWORD": "your-password"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Claude Code
|
|
68
|
+
|
|
69
|
+
Add `.mcp.json` to your project root:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"sap": {
|
|
75
|
+
"command": "npx",
|
|
76
|
+
"args": ["-y", "arc-1"],
|
|
77
|
+
"env": {
|
|
78
|
+
"SAP_URL": "https://your-sap-host:44300",
|
|
79
|
+
"SAP_USER": "your-username",
|
|
80
|
+
"SAP_PASSWORD": "your-password"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### GitHub Copilot / VS Code (HTTP Streamable)
|
|
88
|
+
|
|
89
|
+
Start arc1 as an HTTP server, then point your MCP client to it:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
SAP_URL=https://host:44300 SAP_USER=dev SAP_PASSWORD=secret \
|
|
93
|
+
npx arc-1 --transport http-streamable --port 3000
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Add to VS Code / Copilot MCP config:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"sap": {
|
|
102
|
+
"url": "http://localhost:3000/mcp"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
HTTP Streamable is also the transport for **Copilot Studio** (Microsoft Power Platform integrations).
|
|
109
|
+
|
|
110
|
+
### Other MCP Clients (Gemini CLI, OpenCode, Goose, Qwen, …)
|
|
111
|
+
|
|
112
|
+
All MCP clients that support stdio work out of the box — just point them at `npx arc-1`.
|
|
113
|
+
|
|
114
|
+
## Tools
|
|
115
|
+
|
|
116
|
+
arc1 exposes 11 intent-based tools (~5K schema tokens):
|
|
117
|
+
|
|
118
|
+
| Tool | What it does |
|
|
119
|
+
|------|-------------|
|
|
120
|
+
| **SAPRead** | Read ABAP source, table data, CDS views, message classes, class info |
|
|
121
|
+
| **SAPSearch** | Find objects by name with wildcards |
|
|
122
|
+
| **SAPWrite** | Create/update ABAP source code with auto lock/unlock |
|
|
123
|
+
| **SAPActivate** | Activate (publish) ABAP objects |
|
|
124
|
+
| **SAPNavigate** | Go-to-definition, find references, code completion |
|
|
125
|
+
| **SAPQuery** | Execute ABAP SQL queries against SAP tables |
|
|
126
|
+
| **SAPTransport** | CTS transport management (list, create, release) |
|
|
127
|
+
| **SAPContext** | Compressed dependency context for LLM efficiency |
|
|
128
|
+
| **SAPLint** | ABAP lint and code quality checks |
|
|
129
|
+
| **SAPDiagnose** | Runtime errors (short dumps), profiler traces, SQL traces |
|
|
130
|
+
| **SAPManage** | System feature probing and status |
|
|
131
|
+
|
|
132
|
+
Full tool reference: **[docs/tools.md](docs/tools.md)**
|
|
133
|
+
|
|
134
|
+
## Token Efficiency
|
|
135
|
+
|
|
136
|
+
**Method-level surgery** — read or edit a single method, not the whole class:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
SAPRead(type="CLAS", name="ZCL_CALCULATOR", include="implementations")
|
|
140
|
+
SAPWrite(action="update", type="CLAS", name="ZCL_CALCULATOR", source="...")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Up to 20x fewer tokens vs full-class round-trips.
|
|
144
|
+
|
|
145
|
+
**Context compression** — `SAPContext` auto-appends public API signatures of all referenced classes and interfaces (7–30x compression). One call = source + full dependency context.
|
|
146
|
+
|
|
147
|
+
## Admin Controls (Safety)
|
|
148
|
+
|
|
149
|
+
Configure what the AI is allowed to do before deployment:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Read-only mode — no writes at all
|
|
153
|
+
arc1 --read-only
|
|
154
|
+
|
|
155
|
+
# Restrict to specific packages (wildcards supported)
|
|
156
|
+
arc1 --allowed-packages "ZPROD*,$TMP"
|
|
157
|
+
|
|
158
|
+
# Block free-form SQL
|
|
159
|
+
arc1 --block-free-sql
|
|
160
|
+
|
|
161
|
+
# Whitelist operation types (R=Read, S=Search, Q=Query, …)
|
|
162
|
+
arc1 --allowed-ops "RSQ"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Full safety reference:
|
|
166
|
+
|
|
167
|
+
| Flag / Env | Default | Effect |
|
|
168
|
+
|---|:---:|---|
|
|
169
|
+
| `--read-only` / `SAP_READ_ONLY` | false | Block all write operations |
|
|
170
|
+
| `--block-free-sql` / `SAP_BLOCK_FREE_SQL` | false | Block `RunQuery` execution |
|
|
171
|
+
| `--allowed-ops` / `SAP_ALLOWED_OPS` | (all) | Whitelist operation types |
|
|
172
|
+
| `--disallowed-ops` / `SAP_DISALLOWED_OPS` | (none) | Blacklist operation types |
|
|
173
|
+
| `--allowed-packages` / `SAP_ALLOWED_PACKAGES` | (all) | Restrict to packages (wildcards: `Z*,$TMP`) |
|
|
174
|
+
|
|
175
|
+
## Configuration
|
|
176
|
+
|
|
177
|
+
Priority order: CLI flags > environment variables > `.env` file > defaults.
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Basic
|
|
181
|
+
arc1 --url https://host:44300 --user admin --password secret
|
|
182
|
+
|
|
183
|
+
# Cookie auth (SSO / Fiori Launchpad)
|
|
184
|
+
arc1 --url https://host:44300 --cookie-file cookies.txt
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Full configuration reference: **[CLAUDE.md](CLAUDE.md#configuration)**
|
|
188
|
+
|
|
189
|
+
## Documentation
|
|
190
|
+
|
|
191
|
+
| Doc | Description |
|
|
192
|
+
|-----|-------------|
|
|
193
|
+
| [docs/architecture.md](docs/architecture.md) | System architecture with Mermaid diagrams |
|
|
194
|
+
| [docs/tools.md](docs/tools.md) | Complete tool reference (11 intent-based tools) |
|
|
195
|
+
| [docs/mcp-usage.md](docs/mcp-usage.md) | AI agent usage guide & workflow patterns |
|
|
196
|
+
| [docs/sap-trial-setup.md](docs/sap-trial-setup.md) | SAP BTP trial setup |
|
|
197
|
+
| [docs/docker.md](docs/docker.md) | Docker deployment |
|
|
198
|
+
| [docs/roadmap.md](docs/roadmap.md) | Planned features |
|
|
199
|
+
| [CLAUDE.md](CLAUDE.md) | AI development guidelines (codebase structure, patterns) |
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm ci # install dependencies
|
|
205
|
+
npm run build # TypeScript → dist/
|
|
206
|
+
npm test # unit tests (no SAP system required)
|
|
207
|
+
npm run test:integration # integration tests (skipped if no SAP vars set)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
See [CLAUDE.md](CLAUDE.md) for codebase structure and contribution guidelines.
|
|
211
|
+
|
|
212
|
+
## Credits
|
|
213
|
+
|
|
214
|
+
| Project | Author | Contribution |
|
|
215
|
+
|---------|--------|--------------|
|
|
216
|
+
| [abap-adt-api](https://github.com/marcellourbani/abap-adt-api) | Marcello Urbani | TypeScript ADT library, definitive API reference |
|
|
217
|
+
| [mcp-abap-adt](https://github.com/mario-andreschak/mcp-abap-adt) | Mario Andreschak | First MCP server for ABAP ADT |
|
|
218
|
+
| [abaplint](https://github.com/abaplint/abaplint) | Lars Hvam | ABAP parser/linter (used via @abaplint/core) |
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT
|
package/bin/arc1.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ARC-1 — ABAP Relay Connector
|
|
4
|
+
// CLI entry point — delegates to compiled TypeScript
|
|
5
|
+
//
|
|
6
|
+
// Why a thin JS wrapper instead of direct dist/ reference:
|
|
7
|
+
// The MCP SDK's stdio transport requires the entry process to own stdin/stdout.
|
|
8
|
+
// Using a direct require() (not spawn) ensures no intermediate process layer
|
|
9
|
+
// that could interfere with the JSON-RPC stream.
|
|
10
|
+
// (Learned from fr0ster/mcp-abap-adt bin/mcp-abap-adt.js)
|
|
11
|
+
|
|
12
|
+
import('../dist/index.js');
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BTP Destination Service integration for ARC-1.
|
|
3
|
+
*
|
|
4
|
+
* When running on SAP BTP Cloud Foundry, this module:
|
|
5
|
+
* 1. Parses VCAP_SERVICES to extract service binding credentials
|
|
6
|
+
* 2. Fetches SAP connection details from the BTP Destination Service
|
|
7
|
+
* 3. Configures an HTTP proxy through the Cloud Connector (Connectivity Service)
|
|
8
|
+
*
|
|
9
|
+
* The flow mirrors the Go implementation in pkg/adt/btp.go:
|
|
10
|
+
* - Parse VCAP_SERVICES → get destination/connectivity/xsuaa credentials
|
|
11
|
+
* - Call Destination Service API → get SAP URL, user, password
|
|
12
|
+
* - Create axios proxy config → route through Cloud Connector
|
|
13
|
+
* - Inject Proxy-Authorization header → connectivity service JWT token
|
|
14
|
+
*
|
|
15
|
+
* Token caching: Both destination and connectivity tokens are cached
|
|
16
|
+
* and refreshed 60 seconds before expiry to avoid request failures.
|
|
17
|
+
*/
|
|
18
|
+
/** BTP service binding credentials parsed from VCAP_SERVICES */
|
|
19
|
+
export interface BTPConfig {
|
|
20
|
+
xsuaaUrl: string;
|
|
21
|
+
xsuaaClientId: string;
|
|
22
|
+
xsuaaSecret: string;
|
|
23
|
+
destinationUrl: string;
|
|
24
|
+
destinationClientId: string;
|
|
25
|
+
destinationSecret: string;
|
|
26
|
+
destinationTokenUrl: string;
|
|
27
|
+
connectivityProxyHost: string;
|
|
28
|
+
connectivityProxyPort: string;
|
|
29
|
+
connectivityClientId: string;
|
|
30
|
+
connectivitySecret: string;
|
|
31
|
+
connectivityTokenUrl: string;
|
|
32
|
+
}
|
|
33
|
+
/** Resolved destination from BTP Destination Service */
|
|
34
|
+
export interface Destination {
|
|
35
|
+
Name: string;
|
|
36
|
+
URL: string;
|
|
37
|
+
Authentication: string;
|
|
38
|
+
ProxyType: string;
|
|
39
|
+
User: string;
|
|
40
|
+
Password: string;
|
|
41
|
+
'sap-client'?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Proxy configuration for axios — used by AdtHttpClient */
|
|
44
|
+
export interface BTPProxyConfig {
|
|
45
|
+
host: string;
|
|
46
|
+
port: number;
|
|
47
|
+
protocol: string;
|
|
48
|
+
/** Returns a fresh connectivity proxy JWT token (cached, auto-refreshed) */
|
|
49
|
+
getProxyToken: () => Promise<string>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse VCAP_SERVICES environment variable to extract BTP service credentials.
|
|
53
|
+
* Returns null if not running on BTP (VCAP_SERVICES not set).
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseVCAPServices(): BTPConfig | null;
|
|
56
|
+
/**
|
|
57
|
+
* Look up a destination from the BTP Destination Service.
|
|
58
|
+
* Returns SAP URL, credentials, and proxy type.
|
|
59
|
+
*/
|
|
60
|
+
export declare function lookupDestination(btpConfig: BTPConfig, destinationName: string): Promise<Destination>;
|
|
61
|
+
/**
|
|
62
|
+
* Create a proxy configuration for routing through the Cloud Connector.
|
|
63
|
+
*
|
|
64
|
+
* Returns a BTPProxyConfig with a token getter that caches the connectivity
|
|
65
|
+
* JWT and auto-refreshes it 60 seconds before expiry.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createConnectivityProxy(btpConfig: BTPConfig): BTPProxyConfig | null;
|
|
68
|
+
/**
|
|
69
|
+
* Per-user authentication tokens returned by Destination Service
|
|
70
|
+
* when called with X-User-Token header.
|
|
71
|
+
*
|
|
72
|
+
* For PrincipalPropagation destinations, the Destination Service
|
|
73
|
+
* generates a SAML assertion containing the user identity and returns
|
|
74
|
+
* it as the SAP-Connectivity-Authentication header value.
|
|
75
|
+
*/
|
|
76
|
+
export interface PerUserAuthTokens {
|
|
77
|
+
/** SAP-Connectivity-Authentication header value (SAML assertion for Cloud Connector) */
|
|
78
|
+
sapConnectivityAuth?: string;
|
|
79
|
+
/** Any Bearer token returned by the Destination Service */
|
|
80
|
+
bearerToken?: string;
|
|
81
|
+
/** PP Option 1: jwt-bearer exchanged token for Proxy-Authorization (recommended approach) */
|
|
82
|
+
ppProxyAuth?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Look up a destination with the user's JWT token for principal propagation.
|
|
86
|
+
*
|
|
87
|
+
* This is the key API for per-user SAP authentication:
|
|
88
|
+
* 1. Caller passes the user's JWT (from XSUAA/OIDC)
|
|
89
|
+
* 2. Destination Service validates the JWT and generates auth tokens
|
|
90
|
+
* 3. For PrincipalPropagation destinations: returns SAP-Connectivity-Authentication header
|
|
91
|
+
* 4. For OAuth2SAMLBearerAssertion destinations: returns a Bearer token
|
|
92
|
+
*
|
|
93
|
+
* The returned tokens are per-user and typically valid for 5-10 minutes.
|
|
94
|
+
*
|
|
95
|
+
* Reference: SAP Destination Service REST API "Find Destination" endpoint
|
|
96
|
+
* https://api.sap.com/api/SAP_CP_CF_Connectivity_Destination/resource/Find_a_Destination
|
|
97
|
+
*/
|
|
98
|
+
export declare function lookupDestinationWithUserToken(btpConfig: BTPConfig, destinationName: string, userJwt: string): Promise<{
|
|
99
|
+
destination: Destination;
|
|
100
|
+
authTokens: PerUserAuthTokens;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve BTP destination and connectivity proxy.
|
|
104
|
+
* Called on startup when SAP_BTP_DESTINATION env var is set.
|
|
105
|
+
*
|
|
106
|
+
* Returns the resolved SAP connection config to override defaults.
|
|
107
|
+
*/
|
|
108
|
+
export declare function resolveBTPDestination(destinationName: string): Promise<{
|
|
109
|
+
url: string;
|
|
110
|
+
username: string;
|
|
111
|
+
password: string;
|
|
112
|
+
client: string;
|
|
113
|
+
proxy: BTPProxyConfig | null;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Get the app's public URL from VCAP_APPLICATION.
|
|
117
|
+
*
|
|
118
|
+
* CF sets VCAP_APPLICATION with application_uris containing the app's
|
|
119
|
+
* public route. Returns the first URI as an https URL.
|
|
120
|
+
*/
|
|
121
|
+
export declare function getAppUrl(): string | undefined;
|
|
122
|
+
//# sourceMappingURL=btp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"btp.d.ts","sourceRoot":"","sources":["../../ts-src/adt/btp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,g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