@rainfall-devkit/sdk 0.1.8 → 0.2.1
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 +51 -0
- package/dist/chunk-7MRE4ZVI.mjs +662 -0
- package/dist/chunk-AQFC7YAX.mjs +27 -0
- package/dist/chunk-EI7SJH5K.mjs +85 -0
- package/dist/chunk-NTTAVKRT.mjs +89 -0
- package/dist/chunk-RVKW5KBT.mjs +269 -0
- package/dist/chunk-V5QWJVLC.mjs +662 -0
- package/dist/chunk-VDPKDC3R.mjs +869 -0
- package/dist/chunk-WOITG5TG.mjs +84 -0
- package/dist/chunk-XAHJQRBJ.mjs +269 -0
- package/dist/chunk-XEQ6U3JQ.mjs +269 -0
- package/dist/cli/index.js +3797 -632
- package/dist/cli/index.mjs +453 -36
- package/dist/config-7UT7GYSN.mjs +16 -0
- package/dist/config-DDTQQBN7.mjs +14 -0
- package/dist/config-MD45VGWD.mjs +14 -0
- package/dist/config-ZKNHII2A.mjs +8 -0
- package/dist/daemon/index.d.mts +168 -0
- package/dist/daemon/index.d.ts +168 -0
- package/dist/daemon/index.js +3182 -0
- package/dist/daemon/index.mjs +1548 -0
- package/dist/errors-BMPseAnM.d.mts +47 -0
- package/dist/errors-BMPseAnM.d.ts +47 -0
- package/dist/errors-CZdRoYyw.d.ts +332 -0
- package/dist/errors-Chjq1Mev.d.mts +332 -0
- package/dist/index.d.mts +249 -2
- package/dist/index.d.ts +249 -2
- package/dist/index.js +1247 -3
- package/dist/index.mjs +227 -2
- package/dist/listeners-B5Vy9Ao5.d.ts +372 -0
- package/dist/listeners-BbYIaNCs.d.mts +372 -0
- package/dist/listeners-CP2A9J_2.d.ts +372 -0
- package/dist/listeners-CTRSofnm.d.mts +372 -0
- package/dist/listeners-CYI-YwIF.d.mts +372 -0
- package/dist/listeners-DRwITBW_.d.mts +372 -0
- package/dist/listeners-DrMrvFT5.d.ts +372 -0
- package/dist/listeners-MNAnpZj-.d.mts +372 -0
- package/dist/listeners-PZI7iT85.d.ts +372 -0
- package/dist/listeners-QJeEtLbV.d.ts +372 -0
- package/dist/listeners-hp0Ib2Ox.d.ts +372 -0
- package/dist/listeners-jLwetUnx.d.mts +372 -0
- package/dist/mcp.d.mts +7 -2
- package/dist/mcp.d.ts +7 -2
- package/dist/mcp.js +92 -1
- package/dist/mcp.mjs +1 -1
- package/dist/sdk-4OvXPr8E.d.mts +1054 -0
- package/dist/sdk-4OvXPr8E.d.ts +1054 -0
- package/dist/sdk-CJ9g5lFo.d.mts +772 -0
- package/dist/sdk-CJ9g5lFo.d.ts +772 -0
- package/dist/sdk-CN1ezZrI.d.mts +1054 -0
- package/dist/sdk-CN1ezZrI.d.ts +1054 -0
- package/dist/sdk-DD1OeGRJ.d.mts +871 -0
- package/dist/sdk-DD1OeGRJ.d.ts +871 -0
- package/dist/sdk-Xw0BjsLd.d.mts +1054 -0
- package/dist/sdk-Xw0BjsLd.d.ts +1054 -0
- package/dist/types-GnRAfH-h.d.mts +489 -0
- package/dist/types-GnRAfH-h.d.ts +489 -0
- package/package.json +17 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,251 @@
|
|
|
1
|
-
|
|
1
|
+
import { l as RainfallClient } from './sdk-4OvXPr8E.js';
|
|
2
|
+
export { A as AI, b as ApiError, c as ApiResponse, d as Articles, D as Data, I as Integrations, M as Memory, a as Rainfall, R as RainfallConfig, e as RateLimitInfo, f as RequestOptions, T as ToolSchema, U as Utils, W as Web } from './sdk-4OvXPr8E.js';
|
|
3
|
+
export { A as AuthenticationError, N as NetworkError, a as NotFoundError, R as RainfallError, b as RateLimitError, S as ServerError, T as TimeoutError, c as ToolNotFoundError, V as ValidationError } from './errors-BMPseAnM.js';
|
|
4
|
+
export { C as ContextOptions, c as CronTriggerConfig, E as EdgeNodeRegistration, F as FileWatcherConfig, L as ListenerEvent, d as ListenerRegistry, M as MemoryEntry, N as NetworkedExecutorOptions, e as NodeCapabilities, Q as QueuedJob, a as RainfallDaemonContext, b as RainfallListenerRegistry, R as RainfallNetworkedExecutor, S as SessionContext, T as ToolExecutionRecord, f as createCronWorkflow, g as createFileWatcherWorkflow } from './listeners-B5Vy9Ao5.js';
|
|
5
|
+
import 'ws';
|
|
6
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
7
|
+
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
8
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Edge Node Security Module
|
|
12
|
+
*
|
|
13
|
+
* Provides:
|
|
14
|
+
* - JWT token generation/validation for edge node authentication
|
|
15
|
+
* - ACL enforcement for job routing (same-subscriber only)
|
|
16
|
+
* - Libsodium-based encryption for job parameters
|
|
17
|
+
* - Key pair generation for edge nodes
|
|
18
|
+
*/
|
|
19
|
+
interface EdgeNodeJWT {
|
|
20
|
+
sub: string;
|
|
21
|
+
iss: string;
|
|
22
|
+
iat: number;
|
|
23
|
+
exp: number;
|
|
24
|
+
jti: string;
|
|
25
|
+
scope: string[];
|
|
26
|
+
}
|
|
27
|
+
interface JWTPayload {
|
|
28
|
+
edgeNodeId: string;
|
|
29
|
+
subscriberId: string;
|
|
30
|
+
scopes: string[];
|
|
31
|
+
expiresAt: number;
|
|
32
|
+
}
|
|
33
|
+
interface ACLCheck {
|
|
34
|
+
edgeNodeId: string;
|
|
35
|
+
subscriberId: string;
|
|
36
|
+
jobSubscriberId: string;
|
|
37
|
+
action: 'claim' | 'submit' | 'queue' | 'heartbeat';
|
|
38
|
+
}
|
|
39
|
+
interface ACLResult {
|
|
40
|
+
allowed: boolean;
|
|
41
|
+
reason?: string;
|
|
42
|
+
}
|
|
43
|
+
interface EncryptedPayload {
|
|
44
|
+
ciphertext: string;
|
|
45
|
+
nonce: string;
|
|
46
|
+
ephemeralPublicKey: string;
|
|
47
|
+
}
|
|
48
|
+
interface KeyPair {
|
|
49
|
+
publicKey: string;
|
|
50
|
+
privateKey: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Edge Node Security Manager
|
|
54
|
+
*/
|
|
55
|
+
declare class EdgeNodeSecurity {
|
|
56
|
+
private sodiumReady;
|
|
57
|
+
private backendSecret?;
|
|
58
|
+
private keyPair?;
|
|
59
|
+
constructor(options?: {
|
|
60
|
+
backendSecret?: string;
|
|
61
|
+
keyPair?: KeyPair;
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Initialize libsodium
|
|
65
|
+
*/
|
|
66
|
+
initialize(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Generate a JWT token for an edge node
|
|
69
|
+
* Note: In production, this is done by the backend. This is for testing.
|
|
70
|
+
*/
|
|
71
|
+
generateJWT(edgeNodeId: string, subscriberId: string, expiresInDays?: number): string;
|
|
72
|
+
/**
|
|
73
|
+
* Validate a JWT token
|
|
74
|
+
*/
|
|
75
|
+
validateJWT(token: string): JWTPayload;
|
|
76
|
+
/**
|
|
77
|
+
* Extract bearer token from Authorization header
|
|
78
|
+
*/
|
|
79
|
+
extractBearerToken(authHeader: string | undefined): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Check if an edge node is allowed to perform an action on a job
|
|
82
|
+
* Rule: Edge nodes can only access jobs for their own subscriber
|
|
83
|
+
*/
|
|
84
|
+
checkACL(check: ACLCheck): ACLResult;
|
|
85
|
+
/**
|
|
86
|
+
* Middleware-style ACL check for job operations
|
|
87
|
+
*/
|
|
88
|
+
requireSameSubscriber(edgeNodeSubscriberId: string, jobSubscriberId: string, operation: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Generate a new Ed25519 key pair for an edge node
|
|
91
|
+
*/
|
|
92
|
+
generateKeyPair(): Promise<KeyPair>;
|
|
93
|
+
/**
|
|
94
|
+
* Encrypt job parameters for a target edge node using its public key
|
|
95
|
+
*/
|
|
96
|
+
encryptForEdgeNode(plaintext: string, targetPublicKeyBase64: string): Promise<EncryptedPayload>;
|
|
97
|
+
/**
|
|
98
|
+
* Decrypt job parameters received from the backend
|
|
99
|
+
*/
|
|
100
|
+
decryptFromBackend(encrypted: EncryptedPayload): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Encrypt job parameters for local storage (using secretbox)
|
|
103
|
+
*/
|
|
104
|
+
encryptLocal(plaintext: string, key: string): Promise<{
|
|
105
|
+
ciphertext: string;
|
|
106
|
+
nonce: string;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Decrypt locally stored job parameters
|
|
110
|
+
*/
|
|
111
|
+
decryptLocal(encrypted: {
|
|
112
|
+
ciphertext: string;
|
|
113
|
+
nonce: string;
|
|
114
|
+
}, key: string): Promise<string>;
|
|
115
|
+
private generateTokenId;
|
|
116
|
+
private base64UrlEncode;
|
|
117
|
+
private base64UrlDecode;
|
|
118
|
+
private hmacSha256;
|
|
119
|
+
private timingSafeEqual;
|
|
120
|
+
private bytesToBase64;
|
|
121
|
+
private base64ToBytes;
|
|
122
|
+
private deriveKey;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create security manager from environment or config
|
|
126
|
+
*/
|
|
127
|
+
declare function createEdgeNodeSecurity(options?: {
|
|
128
|
+
backendSecret?: string;
|
|
129
|
+
keyPair?: KeyPair;
|
|
130
|
+
}): Promise<EdgeNodeSecurity>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Secure Edge Node Client
|
|
134
|
+
*
|
|
135
|
+
* Handles secure communication with the Rainfall backend:
|
|
136
|
+
* - JWT authentication on all requests
|
|
137
|
+
* - ACL validation
|
|
138
|
+
* - Job parameter encryption/decryption
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
interface SecureEdgeConfig {
|
|
142
|
+
/** Rainfall client instance */
|
|
143
|
+
client: RainfallClient;
|
|
144
|
+
/** Edge node ID from backend registration */
|
|
145
|
+
edgeNodeId: string;
|
|
146
|
+
/** JWT secret from backend */
|
|
147
|
+
edgeNodeSecret: string;
|
|
148
|
+
/** Path to key directory (contains edge-node.pub and edge-node.key) */
|
|
149
|
+
keysPath: string;
|
|
150
|
+
/** Backend secret for JWT validation (optional, for testing) */
|
|
151
|
+
backendSecret?: string;
|
|
152
|
+
}
|
|
153
|
+
interface SecureJob {
|
|
154
|
+
id: string;
|
|
155
|
+
subscriberId: string;
|
|
156
|
+
type: string;
|
|
157
|
+
params?: string;
|
|
158
|
+
encrypted?: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface JobResult {
|
|
161
|
+
jobId: string;
|
|
162
|
+
success: boolean;
|
|
163
|
+
output?: string;
|
|
164
|
+
error?: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Secure Edge Node Client
|
|
168
|
+
*
|
|
169
|
+
* Wraps the Rainfall Client with security features for edge node operation.
|
|
170
|
+
*/
|
|
171
|
+
declare class SecureEdgeClient {
|
|
172
|
+
private client;
|
|
173
|
+
private security;
|
|
174
|
+
private edgeNodeId;
|
|
175
|
+
private edgeNodeSecret;
|
|
176
|
+
private keysPath;
|
|
177
|
+
private jwtPayload?;
|
|
178
|
+
private keyPair?;
|
|
179
|
+
constructor(config: SecureEdgeConfig);
|
|
180
|
+
/**
|
|
181
|
+
* Initialize the secure client
|
|
182
|
+
*/
|
|
183
|
+
initialize(): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Load key pair from disk
|
|
186
|
+
*/
|
|
187
|
+
private loadKeyPair;
|
|
188
|
+
/**
|
|
189
|
+
* Get public key for sharing with backend
|
|
190
|
+
*/
|
|
191
|
+
getPublicKey(): string;
|
|
192
|
+
/**
|
|
193
|
+
* Send heartbeat with authentication
|
|
194
|
+
*/
|
|
195
|
+
heartbeat(): Promise<{
|
|
196
|
+
status: string;
|
|
197
|
+
timestamp: number;
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* Claim a job from the queue
|
|
201
|
+
*/
|
|
202
|
+
claimJob(): Promise<SecureJob | null>;
|
|
203
|
+
/**
|
|
204
|
+
* Submit job result
|
|
205
|
+
*/
|
|
206
|
+
submitJobResult(result: JobResult): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Queue a job for processing
|
|
209
|
+
*/
|
|
210
|
+
queueJob(type: string, params: Record<string, unknown>, targetPublicKey?: string): Promise<{
|
|
211
|
+
jobId: string;
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Decrypt job params received from backend
|
|
215
|
+
*/
|
|
216
|
+
private decryptJobParams;
|
|
217
|
+
/**
|
|
218
|
+
* Encrypt job result for sending to backend
|
|
219
|
+
*/
|
|
220
|
+
private encryptJobResult;
|
|
221
|
+
/**
|
|
222
|
+
* Encrypt job params for a specific target edge node
|
|
223
|
+
*/
|
|
224
|
+
private encryptJobParamsForTarget;
|
|
225
|
+
/**
|
|
226
|
+
* Check if client is authenticated
|
|
227
|
+
*/
|
|
228
|
+
private requireAuth;
|
|
229
|
+
/**
|
|
230
|
+
* Get current authentication status
|
|
231
|
+
*/
|
|
232
|
+
getAuthStatus(): {
|
|
233
|
+
authenticated: boolean;
|
|
234
|
+
edgeNodeId?: string;
|
|
235
|
+
subscriberId?: string;
|
|
236
|
+
expiresAt?: number;
|
|
237
|
+
scopes?: string[];
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Factory function to create secure edge client from config
|
|
242
|
+
*/
|
|
243
|
+
declare function createSecureEdgeClient(client: RainfallClient, options: {
|
|
244
|
+
edgeNodeId: string;
|
|
245
|
+
edgeNodeSecret: string;
|
|
246
|
+
keysPath: string;
|
|
247
|
+
backendSecret?: string;
|
|
248
|
+
}): Promise<SecureEdgeClient>;
|
|
2
249
|
|
|
3
250
|
/**
|
|
4
251
|
* Rainfall SDK - Official SDK for Rainfall API
|
|
@@ -26,4 +273,4 @@ export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as Authentic
|
|
|
26
273
|
|
|
27
274
|
declare const VERSION = "0.1.0";
|
|
28
275
|
|
|
29
|
-
export { VERSION };
|
|
276
|
+
export { type ACLCheck, type ACLResult, type EdgeNodeJWT, EdgeNodeSecurity, type EncryptedPayload, type JWTPayload, type JobResult, type KeyPair, RainfallClient, SecureEdgeClient, type SecureEdgeConfig, type SecureJob, VERSION, createEdgeNodeSecurity, createSecureEdgeClient };
|