kausalayer-mcp 1.0.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 +201 -0
- package/README.md +82 -0
- package/dist/api/maze-client.d.ts +128 -0
- package/dist/api/maze-client.d.ts.map +1 -0
- package/dist/api/maze-client.js +187 -0
- package/dist/api/maze-client.js.map +1 -0
- package/dist/auth/api-key.d.ts +51 -0
- package/dist/auth/api-key.d.ts.map +1 -0
- package/dist/auth/api-key.js +105 -0
- package/dist/auth/api-key.js.map +1 -0
- package/dist/auth/tier.d.ts +47 -0
- package/dist/auth/tier.d.ts.map +1 -0
- package/dist/auth/tier.js +102 -0
- package/dist/auth/tier.js.map +1 -0
- package/dist/db/database.d.ts +54 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/database.js +180 -0
- package/dist/db/database.js.map +1 -0
- package/dist/http-server.d.ts +7 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +207 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +181 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/check-route-status.d.ts +11 -0
- package/dist/tools/check-route-status.d.ts.map +1 -0
- package/dist/tools/check-route-status.js +51 -0
- package/dist/tools/check-route-status.js.map +1 -0
- package/dist/tools/create-pocket.d.ts +11 -0
- package/dist/tools/create-pocket.d.ts.map +1 -0
- package/dist/tools/create-pocket.js +68 -0
- package/dist/tools/create-pocket.js.map +1 -0
- package/dist/tools/estimate-fee.d.ts +10 -0
- package/dist/tools/estimate-fee.d.ts.map +1 -0
- package/dist/tools/estimate-fee.js +61 -0
- package/dist/tools/estimate-fee.js.map +1 -0
- package/dist/tools/export-pocket-key.d.ts +11 -0
- package/dist/tools/export-pocket-key.d.ts.map +1 -0
- package/dist/tools/export-pocket-key.js +51 -0
- package/dist/tools/export-pocket-key.js.map +1 -0
- package/dist/tools/get-pocket-info.d.ts +11 -0
- package/dist/tools/get-pocket-info.d.ts.map +1 -0
- package/dist/tools/get-pocket-info.js +43 -0
- package/dist/tools/get-pocket-info.js.map +1 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +38 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-pockets.d.ts +11 -0
- package/dist/tools/list-pockets.d.ts.map +1 -0
- package/dist/tools/list-pockets.js +51 -0
- package/dist/tools/list-pockets.js.map +1 -0
- package/dist/tools/maze-route.d.ts +11 -0
- package/dist/tools/maze-route.d.ts.map +1 -0
- package/dist/tools/maze-route.js +81 -0
- package/dist/tools/maze-route.js.map +1 -0
- package/dist/tools/recover-route.d.ts +11 -0
- package/dist/tools/recover-route.d.ts.map +1 -0
- package/dist/tools/recover-route.js +58 -0
- package/dist/tools/recover-route.js.map +1 -0
- package/dist/tools/retry-route.d.ts +11 -0
- package/dist/tools/retry-route.d.ts.map +1 -0
- package/dist/tools/retry-route.js +41 -0
- package/dist/tools/retry-route.js.map +1 -0
- package/dist/tools/sweep-pocket.d.ts +11 -0
- package/dist/tools/sweep-pocket.d.ts.map +1 -0
- package/dist/tools/sweep-pocket.js +62 -0
- package/dist/tools/sweep-pocket.js.map +1 -0
- package/dist/types/index.d.ts +240 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +48 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# KausaLayer MCP Server
|
|
2
|
+
|
|
3
|
+
Privacy infrastructure for AI agents on Solana. Route SOL privately via dynamic maze routing.
|
|
4
|
+
|
|
5
|
+
> ⚠️ **IN DEVELOPMENT** - This project is under active development and not yet ready for production use. APIs may change without notice.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
KausaLayer MCP exposes privacy tools via the Model Context Protocol (MCP), enabling AI agents like Claude, Cursor, and custom trading bots to perform private Solana transactions.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **maze_route** - Send SOL privately via dynamic maze routing (A → maze → B)
|
|
14
|
+
- **create_pocket** - Create stealth wallets funded via maze routing
|
|
15
|
+
- **sweep_pocket** - Withdraw funds from pockets via maze routing
|
|
16
|
+
- **export_pocket_key** - Export private keys for Phantom/Solflare import
|
|
17
|
+
- **estimate_fee** - Estimate fees before executing
|
|
18
|
+
|
|
19
|
+
## API Endpoints
|
|
20
|
+
|
|
21
|
+
| Endpoint | Method | Description |
|
|
22
|
+
|----------|--------|-------------|
|
|
23
|
+
| `/health` | GET | Health check |
|
|
24
|
+
| `/tools` | GET | List available MCP tools |
|
|
25
|
+
| `/register` | POST | Register API key |
|
|
26
|
+
| `/call` | POST | Execute a tool |
|
|
27
|
+
| `/tier` | GET | Get user tier info |
|
|
28
|
+
|
|
29
|
+
## Authentication
|
|
30
|
+
|
|
31
|
+
1. Sign message with your Solana wallet: `KausaLayer MCP Access\nWallet: <pubkey>\nTimestamp: <unix>`
|
|
32
|
+
2. POST to `/register` with `wallet_address` and `signature`
|
|
33
|
+
3. Receive API key (format: `kl_xxxxxxxx`)
|
|
34
|
+
4. Include `x-api-key` header in subsequent requests
|
|
35
|
+
|
|
36
|
+
## Tier System
|
|
37
|
+
|
|
38
|
+
| Tier | KAUSA Required | Fee | Daily Routes |
|
|
39
|
+
|------|---------------|-----|--------------|
|
|
40
|
+
| FREE | 0 | 1.0% | 10 |
|
|
41
|
+
| BASIC | 1,000 | 0.5% | 50 |
|
|
42
|
+
| PRO | 10,000 | 0.25% | 200 |
|
|
43
|
+
| ENTERPRISE | 100,000 | 0.1% | Unlimited |
|
|
44
|
+
|
|
45
|
+
Hold $KAUSA tokens to unlock lower fees and higher limits.
|
|
46
|
+
|
|
47
|
+
**KAUSA Token:** `BWXSNRBKMviG68MqavyssnzDq4qSArcN7eNYjqEfpump`
|
|
48
|
+
|
|
49
|
+
## Usage Example
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Register API key
|
|
53
|
+
curl -X POST https://mcp.kausalayer.com/register \
|
|
54
|
+
-H "Content-Type: application/json" \
|
|
55
|
+
-d '{"wallet_address": "YOUR_PUBKEY", "signature": "YOUR_SIGNATURE"}'
|
|
56
|
+
|
|
57
|
+
# Estimate fee
|
|
58
|
+
curl -X POST https://mcp.kausalayer.com/call \
|
|
59
|
+
-H "Content-Type: application/json" \
|
|
60
|
+
-H "x-api-key: kl_your_api_key" \
|
|
61
|
+
-d '{"tool": "estimate_fee", "arguments": {"amount_sol": 1.0, "operation": "route"}}'
|
|
62
|
+
|
|
63
|
+
# Create private route
|
|
64
|
+
curl -X POST https://mcp.kausalayer.com/call \
|
|
65
|
+
-H "Content-Type: application/json" \
|
|
66
|
+
-H "x-api-key: kl_your_api_key" \
|
|
67
|
+
-d '{"tool": "maze_route", "arguments": {"destination": "DEST_PUBKEY", "amount_sol": 1.0}}'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## MCP Client Integration
|
|
71
|
+
|
|
72
|
+
> 🚧 **Coming Soon** - npm package will be published for easy integration with Claude Desktop, Cursor, and other MCP-compatible clients.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
Apache 2.0
|
|
77
|
+
|
|
78
|
+
## Links
|
|
79
|
+
|
|
80
|
+
- Website: https://kausalayer.com
|
|
81
|
+
- Docs: https://docs.kausalayer.com
|
|
82
|
+
- Twitter: https://x.com/kausalayer
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KausaLayer MCP - Maze API Client
|
|
3
|
+
* HTTP client for sdp-mazepocket REST API
|
|
4
|
+
*/
|
|
5
|
+
import { CreatePocketResponse, PocketInfo, PocketDetailInfo, SweepResponse, StatusResponse, RecoverResponse, Complexity } from '../types';
|
|
6
|
+
export declare class MazeApiClient {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
constructor(baseUrl: string);
|
|
9
|
+
/**
|
|
10
|
+
* Convert complexity to maze config
|
|
11
|
+
*/
|
|
12
|
+
private complexityToConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Make HTTP request
|
|
15
|
+
*/
|
|
16
|
+
private request;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new pocket
|
|
19
|
+
*/
|
|
20
|
+
createPocket(metaAddress: string, amountSol: number, complexity?: Complexity): Promise<CreatePocketResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* List all pockets for a user
|
|
23
|
+
*/
|
|
24
|
+
listPockets(metaAddress: string): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
pockets: PocketInfo[];
|
|
27
|
+
count: number;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Get pocket details (including private key)
|
|
31
|
+
*/
|
|
32
|
+
getPocket(pocketId: string, metaAddress: string): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
pocket?: PocketDetailInfo;
|
|
35
|
+
message?: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Sweep pocket funds to destination
|
|
39
|
+
*/
|
|
40
|
+
sweepPocket(pocketId: string, metaAddress: string, destination: string, complexity?: Complexity): Promise<SweepResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a pocket (soft delete)
|
|
43
|
+
*/
|
|
44
|
+
deletePocket(pocketId: string, metaAddress: string): Promise<{
|
|
45
|
+
success: boolean;
|
|
46
|
+
message: string;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Get funding request status
|
|
50
|
+
*/
|
|
51
|
+
getFundingStatus(requestId: string): Promise<StatusResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Get sweep status
|
|
54
|
+
*/
|
|
55
|
+
getSweepStatus(sweepId: string): Promise<StatusResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Resume a failed sweep
|
|
58
|
+
*/
|
|
59
|
+
resumeSweep(sweepId: string): Promise<SweepResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Recover stuck funding
|
|
62
|
+
*/
|
|
63
|
+
recoverFunding(pocketId: string, metaAddress: string): Promise<RecoverResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Recover stuck sweep
|
|
66
|
+
*/
|
|
67
|
+
recoverSweep(sweepId: string, metaAddress: string): Promise<RecoverResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Add destination wallet
|
|
70
|
+
*/
|
|
71
|
+
addWallet(metaAddress: string, slot: number, walletAddress: string): Promise<{
|
|
72
|
+
success: boolean;
|
|
73
|
+
slot: number;
|
|
74
|
+
wallet_address: string;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* List saved wallets
|
|
78
|
+
*/
|
|
79
|
+
listWallets(metaAddress: string): Promise<{
|
|
80
|
+
success: boolean;
|
|
81
|
+
wallets: {
|
|
82
|
+
slot: number;
|
|
83
|
+
address: string;
|
|
84
|
+
}[];
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Delete saved wallet
|
|
88
|
+
*/
|
|
89
|
+
deleteWallet(slot: number, metaAddress: string): Promise<{
|
|
90
|
+
success: boolean;
|
|
91
|
+
deleted: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Get protocol stats
|
|
95
|
+
*/
|
|
96
|
+
getStats(): Promise<{
|
|
97
|
+
total_nodes_alltime: number;
|
|
98
|
+
total_hops_alltime: number;
|
|
99
|
+
nodes_24h: number;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Health check
|
|
103
|
+
*/
|
|
104
|
+
healthCheck(): Promise<{
|
|
105
|
+
status: string;
|
|
106
|
+
service: string;
|
|
107
|
+
version: string;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Create a direct route (A -> maze -> B)
|
|
111
|
+
*/
|
|
112
|
+
createRoute(metaAddress: string, amountSol: number, destination: string, complexity?: Complexity): Promise<{
|
|
113
|
+
success: boolean;
|
|
114
|
+
route_id: string;
|
|
115
|
+
deposit_address: string;
|
|
116
|
+
destination: string;
|
|
117
|
+
amount_lamports: number;
|
|
118
|
+
fee_lamports: number;
|
|
119
|
+
total_deposit: number;
|
|
120
|
+
expires_at: number;
|
|
121
|
+
maze_info: {
|
|
122
|
+
nodes: number;
|
|
123
|
+
levels: number;
|
|
124
|
+
estimated_time_seconds: number;
|
|
125
|
+
};
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=maze-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maze-client.d.ts","sourceRoot":"","sources":["../../src/api/maze-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAEhB,aAAa,EACb,cAAc,EAEd,eAAe,EAEf,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM;IAI3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;OAEG;YACW,OAAO;IAoCrB;;OAEG;IACG,YAAY,CAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,UAAqB,GAChC,OAAO,CAAC,oBAAoB,CAAC;IAUhC;;OAEG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9C,OAAO,EAAE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
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* KausaLayer MCP - Maze API Client
|
|
4
|
+
* HTTP client for sdp-mazepocket REST API
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MazeApiClient = void 0;
|
|
8
|
+
class MazeApiClient {
|
|
9
|
+
baseUrl;
|
|
10
|
+
constructor(baseUrl) {
|
|
11
|
+
this.baseUrl = baseUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Convert complexity to maze config
|
|
15
|
+
*/
|
|
16
|
+
complexityToConfig(complexity) {
|
|
17
|
+
const configs = {
|
|
18
|
+
low: { hop_count: 5, delay_pattern: 'random' },
|
|
19
|
+
medium: { hop_count: 8, delay_pattern: 'random' },
|
|
20
|
+
high: { hop_count: 12, delay_pattern: 'fibonacci' },
|
|
21
|
+
};
|
|
22
|
+
return configs[complexity];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Make HTTP request
|
|
26
|
+
*/
|
|
27
|
+
async request(method, path, body, query) {
|
|
28
|
+
let url = `${this.baseUrl}${path}`;
|
|
29
|
+
if (query) {
|
|
30
|
+
const params = new URLSearchParams(query);
|
|
31
|
+
url += `?${params.toString()}`;
|
|
32
|
+
}
|
|
33
|
+
const options = {
|
|
34
|
+
method,
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
if (body) {
|
|
40
|
+
options.body = JSON.stringify(body);
|
|
41
|
+
}
|
|
42
|
+
const response = await fetch(url, options);
|
|
43
|
+
const data = await response.json();
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new Error(data.error || `API error: ${response.status}`);
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
// ============ POCKET OPERATIONS ============
|
|
50
|
+
/**
|
|
51
|
+
* Create a new pocket
|
|
52
|
+
*/
|
|
53
|
+
async createPocket(metaAddress, amountSol, complexity = 'medium') {
|
|
54
|
+
const mazeConfig = this.complexityToConfig(complexity);
|
|
55
|
+
return this.request('POST', '/pocket', {
|
|
56
|
+
meta_address: metaAddress,
|
|
57
|
+
amount_sol: amountSol,
|
|
58
|
+
maze_config: mazeConfig,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* List all pockets for a user
|
|
63
|
+
*/
|
|
64
|
+
async listPockets(metaAddress) {
|
|
65
|
+
return this.request('GET', '/pockets', undefined, {
|
|
66
|
+
meta_address: metaAddress,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get pocket details (including private key)
|
|
71
|
+
*/
|
|
72
|
+
async getPocket(pocketId, metaAddress) {
|
|
73
|
+
return this.request('GET', `/pocket/${pocketId}`, undefined, {
|
|
74
|
+
meta_address: metaAddress,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sweep pocket funds to destination
|
|
79
|
+
*/
|
|
80
|
+
async sweepPocket(pocketId, metaAddress, destination, complexity = 'medium') {
|
|
81
|
+
const mazeConfig = this.complexityToConfig(complexity);
|
|
82
|
+
return this.request('POST', `/pocket/${pocketId}/sweep`, {
|
|
83
|
+
meta_address: metaAddress,
|
|
84
|
+
destination,
|
|
85
|
+
maze_config: mazeConfig,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Delete a pocket (soft delete)
|
|
90
|
+
*/
|
|
91
|
+
async deletePocket(pocketId, metaAddress) {
|
|
92
|
+
return this.request('DELETE', `/pocket/${pocketId}`, {
|
|
93
|
+
meta_address: metaAddress,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// ============ STATUS OPERATIONS ============
|
|
97
|
+
/**
|
|
98
|
+
* Get funding request status
|
|
99
|
+
*/
|
|
100
|
+
async getFundingStatus(requestId) {
|
|
101
|
+
return this.request('GET', `/status/${requestId}`);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get sweep status
|
|
105
|
+
*/
|
|
106
|
+
async getSweepStatus(sweepId) {
|
|
107
|
+
return this.request('GET', `/sweep/${sweepId}/status`);
|
|
108
|
+
}
|
|
109
|
+
// ============ RECOVERY OPERATIONS ============
|
|
110
|
+
/**
|
|
111
|
+
* Resume a failed sweep
|
|
112
|
+
*/
|
|
113
|
+
async resumeSweep(sweepId) {
|
|
114
|
+
return this.request('POST', `/sweep/${sweepId}/resume`);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Recover stuck funding
|
|
118
|
+
*/
|
|
119
|
+
async recoverFunding(pocketId, metaAddress) {
|
|
120
|
+
return this.request('POST', `/pocket/${pocketId}/recover`, {
|
|
121
|
+
meta_address: metaAddress,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Recover stuck sweep
|
|
126
|
+
*/
|
|
127
|
+
async recoverSweep(sweepId, metaAddress) {
|
|
128
|
+
return this.request('POST', `/sweep/${sweepId}/recover`, {
|
|
129
|
+
meta_address: metaAddress,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// ============ WALLET OPERATIONS ============
|
|
133
|
+
/**
|
|
134
|
+
* Add destination wallet
|
|
135
|
+
*/
|
|
136
|
+
async addWallet(metaAddress, slot, walletAddress) {
|
|
137
|
+
return this.request('POST', '/wallet', {
|
|
138
|
+
meta_address: metaAddress,
|
|
139
|
+
slot,
|
|
140
|
+
wallet_address: walletAddress,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* List saved wallets
|
|
145
|
+
*/
|
|
146
|
+
async listWallets(metaAddress) {
|
|
147
|
+
return this.request('GET', '/wallets', undefined, {
|
|
148
|
+
meta_address: metaAddress,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Delete saved wallet
|
|
153
|
+
*/
|
|
154
|
+
async deleteWallet(slot, metaAddress) {
|
|
155
|
+
return this.request('DELETE', `/wallet/${slot}`, undefined, {
|
|
156
|
+
meta_address: metaAddress,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// ============ STATS ============
|
|
160
|
+
/**
|
|
161
|
+
* Get protocol stats
|
|
162
|
+
*/
|
|
163
|
+
async getStats() {
|
|
164
|
+
return this.request('GET', '/stats');
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Health check
|
|
168
|
+
*/
|
|
169
|
+
async healthCheck() {
|
|
170
|
+
return this.request('GET', '/health');
|
|
171
|
+
}
|
|
172
|
+
// ============ DIRECT ROUTE ============
|
|
173
|
+
/**
|
|
174
|
+
* Create a direct route (A -> maze -> B)
|
|
175
|
+
*/
|
|
176
|
+
async createRoute(metaAddress, amountSol, destination, complexity = 'medium') {
|
|
177
|
+
const mazeConfig = this.complexityToConfig(complexity);
|
|
178
|
+
return this.request('POST', '/route', {
|
|
179
|
+
meta_address: metaAddress,
|
|
180
|
+
amount_sol: amountSol,
|
|
181
|
+
destination,
|
|
182
|
+
maze_config: mazeConfig,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.MazeApiClient = MazeApiClient;
|
|
187
|
+
//# sourceMappingURL=maze-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maze-client.js","sourceRoot":"","sources":["../../src/api/maze-client.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH,MAAa,aAAa;IAChB,OAAO,CAAS;IAExB,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB;IACrE,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,UAAsB;QAC/C,MAAM,OAAO,GAAmC;YAC9C,GAAG,EAAE,EAAE,S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Q,EAAE,WAAW,IAAI,EAAE,EAAE,SAAS,EAAE;YAC1D,YAAY,EAAE,WAAW;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,kCAAkC;IAElC;;OAEG;IACH,KAAK,CAAC,QAAQ;QAKZ,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QAKf,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,yCAAyC;IAEzC;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,WAAmB,EACnB,SAAiB,EACjB,WAAmB,EACnB,aAAyB,QAAQ;QAgBjC,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE;YACpC,YAAY,EAAE,WAAW;YACzB,UAAU,EAAE,SAAS;YACrB,WAAW;YACX,WAAW,EAAE,UAAU;SACxB,CAAC,CAAC;IACL,CAAC;CACF;AA1RD,sCA0RC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KausaLayer MCP - API Key Authentication Module
|
|
3
|
+
*/
|
|
4
|
+
import { MCPDatabase } from '../db/database';
|
|
5
|
+
import { TierManager } from './tier';
|
|
6
|
+
import { Tier, TierLimits } from '../types';
|
|
7
|
+
export interface AuthContext {
|
|
8
|
+
walletAddress: string;
|
|
9
|
+
tier: Tier;
|
|
10
|
+
limits: TierLimits;
|
|
11
|
+
kausaBalance: number;
|
|
12
|
+
routesToday: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class ApiKeyAuth {
|
|
15
|
+
private db;
|
|
16
|
+
private tierManager;
|
|
17
|
+
constructor(db: MCPDatabase, tierManager: TierManager);
|
|
18
|
+
/**
|
|
19
|
+
* Generate API key from wallet signature
|
|
20
|
+
* Message format: "KausaLayer MCP Access\nWallet: <pubkey>\nTimestamp: <unix>"
|
|
21
|
+
*/
|
|
22
|
+
static generateApiKey(signature: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Register a new API key for a wallet
|
|
25
|
+
*/
|
|
26
|
+
registerApiKey(apiKey: string, walletAddress: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Validate API key and return full auth context
|
|
29
|
+
*/
|
|
30
|
+
authenticate(apiKey: string): Promise<AuthContext | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if user can make a route (rate limit check)
|
|
33
|
+
*/
|
|
34
|
+
canMakeRoute(authContext: AuthContext): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Increment route count after successful route creation
|
|
37
|
+
*/
|
|
38
|
+
incrementRouteCount(walletAddress: string): number;
|
|
39
|
+
/**
|
|
40
|
+
* Validate route parameters against tier limits
|
|
41
|
+
*/
|
|
42
|
+
validateRouteParams(authContext: AuthContext, amountSol: number, complexity: 'low' | 'medium' | 'high'): {
|
|
43
|
+
valid: boolean;
|
|
44
|
+
error?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Get meta_address hash for REST API calls
|
|
48
|
+
*/
|
|
49
|
+
static getMetaAddress(walletAddress: string): string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=api-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/auth/api-key.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,UAAU,CAAC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