@jack-kernel/sdk 1.0.0 → 1.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/dist/cjs/index.js +125 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lifi/chain-map.js +39 -0
- package/dist/cjs/lifi/chain-map.js.map +1 -0
- package/dist/cjs/lifi/fallback.js +135 -0
- package/dist/cjs/lifi/fallback.js.map +1 -0
- package/dist/cjs/lifi/index.js +34 -0
- package/dist/cjs/lifi/index.js.map +1 -0
- package/dist/cjs/lifi/lifi-provider.js +496 -0
- package/dist/cjs/lifi/lifi-provider.js.map +1 -0
- package/dist/cjs/lifi/token-map.js +75 -0
- package/dist/cjs/lifi/token-map.js.map +1 -0
- package/dist/cjs/lifi/types.js +3 -0
- package/dist/cjs/lifi/types.js.map +1 -0
- package/dist/cjs/lifi/utils.js +45 -0
- package/dist/cjs/lifi/utils.js.map +1 -0
- package/dist/cjs/yellow/channel-state-manager.js +167 -0
- package/dist/cjs/yellow/channel-state-manager.js.map +1 -0
- package/dist/cjs/yellow/clear-node-connection.js +390 -0
- package/dist/cjs/yellow/clear-node-connection.js.map +1 -0
- package/dist/cjs/yellow/event-mapper.js +254 -0
- package/dist/cjs/yellow/event-mapper.js.map +1 -0
- package/dist/cjs/yellow/serialization.js +130 -0
- package/dist/cjs/yellow/serialization.js.map +1 -0
- package/dist/cjs/yellow/session-key-manager.js +308 -0
- package/dist/cjs/yellow/session-key-manager.js.map +1 -0
- package/dist/cjs/yellow/types.js +12 -0
- package/dist/cjs/yellow/types.js.map +1 -0
- package/dist/cjs/yellow/yellow-provider.js +1545 -0
- package/dist/cjs/yellow/yellow-provider.js.map +1 -0
- package/dist/esm/index.js +102 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lifi/chain-map.js +35 -0
- package/dist/esm/lifi/chain-map.js.map +1 -0
- package/dist/esm/lifi/fallback.js +128 -0
- package/dist/esm/lifi/fallback.js.map +1 -0
- package/dist/esm/lifi/index.js +19 -0
- package/dist/esm/lifi/index.js.map +1 -0
- package/dist/esm/lifi/lifi-provider.js +492 -0
- package/dist/esm/lifi/lifi-provider.js.map +1 -0
- package/dist/esm/lifi/token-map.js +71 -0
- package/dist/esm/lifi/token-map.js.map +1 -0
- package/dist/esm/lifi/types.js +2 -0
- package/dist/esm/lifi/types.js.map +1 -0
- package/dist/esm/lifi/utils.js +41 -0
- package/dist/esm/lifi/utils.js.map +1 -0
- package/dist/esm/yellow/channel-state-manager.js +163 -0
- package/dist/esm/yellow/channel-state-manager.js.map +1 -0
- package/dist/esm/yellow/clear-node-connection.js +385 -0
- package/dist/esm/yellow/clear-node-connection.js.map +1 -0
- package/dist/esm/yellow/event-mapper.js +248 -0
- package/dist/esm/yellow/event-mapper.js.map +1 -0
- package/dist/esm/yellow/serialization.js +125 -0
- package/dist/esm/yellow/serialization.js.map +1 -0
- package/dist/esm/yellow/session-key-manager.js +302 -0
- package/dist/esm/yellow/session-key-manager.js.map +1 -0
- package/dist/esm/yellow/types.js +11 -0
- package/dist/esm/yellow/types.js.map +1 -0
- package/dist/esm/yellow/yellow-provider.js +1538 -0
- package/dist/esm/yellow/yellow-provider.js.map +1 -0
- package/dist/types/index.d.ts +104 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifi/chain-map.d.ts +27 -0
- package/dist/types/lifi/chain-map.d.ts.map +1 -0
- package/dist/types/lifi/fallback.d.ts +58 -0
- package/dist/types/lifi/fallback.d.ts.map +1 -0
- package/dist/types/lifi/index.d.ts +18 -0
- package/dist/types/lifi/index.d.ts.map +1 -0
- package/dist/types/lifi/lifi-provider.d.ts +133 -0
- package/dist/types/lifi/lifi-provider.d.ts.map +1 -0
- package/dist/types/lifi/token-map.d.ts +34 -0
- package/dist/types/lifi/token-map.d.ts.map +1 -0
- package/dist/types/lifi/types.d.ts +52 -0
- package/dist/types/lifi/types.d.ts.map +1 -0
- package/dist/types/lifi/utils.d.ts +29 -0
- package/dist/types/lifi/utils.d.ts.map +1 -0
- package/dist/types/yellow/channel-state-manager.d.ts +106 -0
- package/dist/types/yellow/channel-state-manager.d.ts.map +1 -0
- package/dist/types/yellow/clear-node-connection.d.ts +202 -0
- package/dist/types/yellow/clear-node-connection.d.ts.map +1 -0
- package/dist/types/yellow/event-mapper.d.ts +74 -0
- package/dist/types/yellow/event-mapper.d.ts.map +1 -0
- package/dist/types/yellow/serialization.d.ts +52 -0
- package/dist/types/yellow/serialization.d.ts.map +1 -0
- package/dist/types/yellow/session-key-manager.d.ts +179 -0
- package/dist/types/yellow/session-key-manager.d.ts.map +1 -0
- package/dist/types/yellow/types.d.ts +177 -0
- package/dist/types/yellow/types.d.ts.map +1 -0
- package/dist/types/yellow/yellow-provider.d.ts +303 -0
- package/dist/types/yellow/yellow-provider.d.ts.map +1 -0
- package/package.json +4 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel State Manager for Yellow Network Integration
|
|
3
|
+
*
|
|
4
|
+
* Tracks local channel state and provides on-chain query capabilities.
|
|
5
|
+
* Maintains a local cache of channel states from ClearNode messages and
|
|
6
|
+
* falls back to on-chain queries via viem PublicClient when the WebSocket
|
|
7
|
+
* is disconnected.
|
|
8
|
+
*
|
|
9
|
+
* Requirements: 7.1, 7.2, 7.3, 7.4
|
|
10
|
+
*/
|
|
11
|
+
import type { PublicClient } from 'viem';
|
|
12
|
+
import type { ChannelState } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Manages local channel state cache and provides on-chain query capabilities.
|
|
15
|
+
*
|
|
16
|
+
* The ChannelStateManager serves two purposes:
|
|
17
|
+
* 1. Maintains a local cache of channel states received from ClearNode messages,
|
|
18
|
+
* enabling fast lookups without network calls.
|
|
19
|
+
* 2. Provides on-chain balance queries via viem PublicClient for when the
|
|
20
|
+
* WebSocket connection is unavailable (Requirement 7.4) or when authoritative
|
|
21
|
+
* on-chain data is needed (Requirement 7.2).
|
|
22
|
+
*
|
|
23
|
+
* Requirements: 7.1, 7.2, 7.3, 7.4
|
|
24
|
+
*/
|
|
25
|
+
export declare class ChannelStateManager {
|
|
26
|
+
private readonly publicClient;
|
|
27
|
+
private readonly custodyAddress;
|
|
28
|
+
private readonly channels;
|
|
29
|
+
/**
|
|
30
|
+
* @param publicClient - viem PublicClient for on-chain balance queries
|
|
31
|
+
* @param custodyAddress - Address of the custody contract holding channel collateral
|
|
32
|
+
*/
|
|
33
|
+
constructor(publicClient: PublicClient, custodyAddress: `0x${string}`);
|
|
34
|
+
/**
|
|
35
|
+
* Update the local cache with a channel state from a ClearNode response.
|
|
36
|
+
*
|
|
37
|
+
* This is called when the YellowProvider receives channel state updates
|
|
38
|
+
* from ClearNode messages (create, resize, close, or get_ledger_balances).
|
|
39
|
+
*
|
|
40
|
+
* Requirement 7.1: Maintain local channel state from ClearNode responses.
|
|
41
|
+
*
|
|
42
|
+
* @param channelId - The channel identifier
|
|
43
|
+
* @param state - The channel state to cache
|
|
44
|
+
*/
|
|
45
|
+
updateChannel(channelId: string, state: ChannelState): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get a locally cached channel state by channel ID.
|
|
48
|
+
*
|
|
49
|
+
* Returns undefined if the channel is not in the local cache.
|
|
50
|
+
* For authoritative on-chain data, use queryOnChainBalances instead.
|
|
51
|
+
*
|
|
52
|
+
* Requirement 7.2: Query specific channel status by channel ID.
|
|
53
|
+
*
|
|
54
|
+
* @param channelId - The channel identifier
|
|
55
|
+
* @returns The cached channel state, or undefined if not found
|
|
56
|
+
*/
|
|
57
|
+
getChannel(channelId: string): ChannelState | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Get all locally cached channel states.
|
|
60
|
+
*
|
|
61
|
+
* Returns a snapshot array of all channels currently in the cache.
|
|
62
|
+
* The returned array is a copy; modifications do not affect the cache.
|
|
63
|
+
*
|
|
64
|
+
* Requirement 7.1: Return list of channels with their statuses and allocations.
|
|
65
|
+
*
|
|
66
|
+
* @returns Array of all cached channel states
|
|
67
|
+
*/
|
|
68
|
+
getAllChannels(): ChannelState[];
|
|
69
|
+
/**
|
|
70
|
+
* Query on-chain channel balances from the custody contract.
|
|
71
|
+
*
|
|
72
|
+
* Uses viem PublicClient.readContract to call the custody contract's
|
|
73
|
+
* getChannelBalances function. This provides authoritative on-chain data
|
|
74
|
+
* and is used as a fallback when the ClearNode WebSocket is disconnected.
|
|
75
|
+
*
|
|
76
|
+
* Requirement 7.2: Query on-chain custody contract for channel balances.
|
|
77
|
+
* Requirement 7.4: Fall back to on-chain queries when WebSocket is disconnected.
|
|
78
|
+
*
|
|
79
|
+
* @param channelId - The channel identifier (bytes32 hex string)
|
|
80
|
+
* @param tokens - Array of token addresses to query balances for
|
|
81
|
+
* @returns Array of token balances as bigint values, one per token
|
|
82
|
+
* @throws Error if the on-chain query fails
|
|
83
|
+
*/
|
|
84
|
+
queryOnChainBalances(channelId: string, tokens: string[]): Promise<bigint[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Find an open (ACTIVE) channel for a given token address.
|
|
87
|
+
*
|
|
88
|
+
* Searches the local cache for a channel with status 'ACTIVE' that
|
|
89
|
+
* matches the specified token address. Returns the first match found.
|
|
90
|
+
*
|
|
91
|
+
* This is used by the YellowProvider to reuse existing channels
|
|
92
|
+
* when executing intents, avoiding unnecessary channel creation.
|
|
93
|
+
*
|
|
94
|
+
* @param token - The token address to find an open channel for
|
|
95
|
+
* @returns The first matching ACTIVE channel, or undefined if none found
|
|
96
|
+
*/
|
|
97
|
+
findOpenChannel(token: string): ChannelState | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Clear all cached channel states.
|
|
100
|
+
*
|
|
101
|
+
* This is typically called when the provider disconnects or when
|
|
102
|
+
* a full state refresh is needed.
|
|
103
|
+
*/
|
|
104
|
+
clear(): void;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=channel-state-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-state-manager.d.ts","sourceRoot":"","sources":["../../../src/yellow/channel-state-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA+B/C;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IAErD;;;OAGG;gBACS,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE;IAMrE;;;;;;;;;;OAUG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAI3D;;;;;;;;;;OAUG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIvD;;;;;;;;;OASG;IACH,cAAc,IAAI,YAAY,EAAE;IAIhC;;;;;;;;;;;;;;OAcG;IACG,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBlF;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IASxD;;;;;OAKG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClearNode WebSocket Connection Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages the WebSocket connection to Yellow Network's ClearNode relay server
|
|
5
|
+
* with reconnection logic, request-response correlation, and event emission.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Exponential backoff reconnection: delay = initialDelay * 2^(attempt-1)
|
|
9
|
+
* - Request-response correlation using method name matching
|
|
10
|
+
* - EventEmitter pattern for connected/disconnected events
|
|
11
|
+
* - Cleanup of all pending handlers on disconnect
|
|
12
|
+
*
|
|
13
|
+
* Requirements: 10.1, 10.2, 10.3, 10.4, 10.5
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Configuration options for the ClearNodeConnection.
|
|
17
|
+
*/
|
|
18
|
+
export interface ConnectionOptions {
|
|
19
|
+
/** Maximum number of reconnection attempts before giving up. Default: 5 */
|
|
20
|
+
maxReconnectAttempts?: number;
|
|
21
|
+
/** Initial reconnection delay in milliseconds. Default: 1000 */
|
|
22
|
+
reconnectDelay?: number;
|
|
23
|
+
/** Timeout for sendAndWait responses in milliseconds. Default: 30000 */
|
|
24
|
+
messageTimeout?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Minimal WebSocket interface used internally.
|
|
28
|
+
*
|
|
29
|
+
* Compatible with both the Node.js global WebSocket (Node 22+) and the `ws` package.
|
|
30
|
+
* This abstraction avoids a hard dependency on `@types/ws` while remaining type-safe.
|
|
31
|
+
*/
|
|
32
|
+
interface IWebSocket {
|
|
33
|
+
readonly readyState: number;
|
|
34
|
+
send(data: string): void;
|
|
35
|
+
close(): void;
|
|
36
|
+
onopen: ((event: unknown) => void) | null;
|
|
37
|
+
onclose: ((event: unknown) => void) | null;
|
|
38
|
+
onerror: ((event: unknown) => void) | null;
|
|
39
|
+
onmessage: ((event: {
|
|
40
|
+
data: unknown;
|
|
41
|
+
}) => void) | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Factory type for creating WebSocket instances.
|
|
45
|
+
* Defaults to the global WebSocket constructor.
|
|
46
|
+
* Can be overridden for testing.
|
|
47
|
+
*/
|
|
48
|
+
type WebSocketFactory = (url: string) => IWebSocket;
|
|
49
|
+
/**
|
|
50
|
+
* Calculate the exponential backoff delay for a given reconnection attempt.
|
|
51
|
+
*
|
|
52
|
+
* Formula: delay = initialDelay * 2^(attempt - 1)
|
|
53
|
+
*
|
|
54
|
+
* This is exported as a pure function so it can be independently tested
|
|
55
|
+
* (including via property-based tests).
|
|
56
|
+
*
|
|
57
|
+
* @param initialDelay - The base delay in milliseconds
|
|
58
|
+
* @param attempt - The attempt number (1-based)
|
|
59
|
+
* @returns The delay in milliseconds before the given attempt
|
|
60
|
+
*/
|
|
61
|
+
export declare function calculateBackoffDelay(initialDelay: number, attempt: number): number;
|
|
62
|
+
/**
|
|
63
|
+
* Manages a WebSocket connection to Yellow Network's ClearNode.
|
|
64
|
+
*
|
|
65
|
+
* Provides:
|
|
66
|
+
* - connect/disconnect lifecycle management
|
|
67
|
+
* - send (fire-and-forget) and sendAndWait (request-response correlation)
|
|
68
|
+
* - Automatic reconnection with exponential backoff
|
|
69
|
+
* - Event emission for 'connected' and 'disconnected' events
|
|
70
|
+
* - Cleanup of pending handlers on disconnect
|
|
71
|
+
*
|
|
72
|
+
* Requirements: 10.1, 10.2, 10.3, 10.4, 10.5
|
|
73
|
+
*/
|
|
74
|
+
export declare class ClearNodeConnection {
|
|
75
|
+
private readonly url;
|
|
76
|
+
private readonly maxReconnectAttempts;
|
|
77
|
+
private readonly reconnectDelay;
|
|
78
|
+
private readonly messageTimeout;
|
|
79
|
+
private readonly wsFactory;
|
|
80
|
+
private ws;
|
|
81
|
+
private emitter;
|
|
82
|
+
private pendingRequests;
|
|
83
|
+
private messageHandlers;
|
|
84
|
+
private _isConnected;
|
|
85
|
+
private _isDisposed;
|
|
86
|
+
private reconnectAttempt;
|
|
87
|
+
private reconnectTimer;
|
|
88
|
+
/**
|
|
89
|
+
* @param url - The ClearNode WebSocket URL
|
|
90
|
+
* @param options - Connection configuration options
|
|
91
|
+
* @param wsFactory - Optional WebSocket factory for testing. Defaults to global WebSocket.
|
|
92
|
+
*/
|
|
93
|
+
constructor(url: string, options?: ConnectionOptions, wsFactory?: WebSocketFactory);
|
|
94
|
+
/**
|
|
95
|
+
* Establish a WebSocket connection to ClearNode.
|
|
96
|
+
*
|
|
97
|
+
* Resolves when the connection is open and ready.
|
|
98
|
+
* Rejects if the connection fails to establish.
|
|
99
|
+
*
|
|
100
|
+
* Requirement 10.1: Emit a connected event on successful connection.
|
|
101
|
+
*/
|
|
102
|
+
connect(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Close the WebSocket connection and clean up all resources.
|
|
105
|
+
*
|
|
106
|
+
* Requirement 10.4: Clean up all pending message handlers on disconnect.
|
|
107
|
+
*/
|
|
108
|
+
disconnect(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Send a message and wait for a correlated response.
|
|
111
|
+
*
|
|
112
|
+
* The response is matched by method name: when a message is received
|
|
113
|
+
* that contains a matching method field, the promise resolves with that response.
|
|
114
|
+
*
|
|
115
|
+
* Requirement 10.5: Request-response correlation using method name matching.
|
|
116
|
+
*
|
|
117
|
+
* @param message - The message string to send
|
|
118
|
+
* @param method - The method name to correlate the response with
|
|
119
|
+
* @param timeout - Optional timeout in ms (defaults to messageTimeout)
|
|
120
|
+
* @returns The parsed response data
|
|
121
|
+
* @throws Error if the connection is not open, the request times out, or the connection drops
|
|
122
|
+
*/
|
|
123
|
+
sendAndWait<T>(message: string, method: string, timeout?: number): Promise<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Send a message without waiting for a response (fire-and-forget).
|
|
126
|
+
*
|
|
127
|
+
* @param message - The message string to send
|
|
128
|
+
* @throws Error if the connection is not open
|
|
129
|
+
*/
|
|
130
|
+
send(message: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Register a handler for incoming messages.
|
|
133
|
+
*
|
|
134
|
+
* Handlers receive the parsed message data for all incoming messages
|
|
135
|
+
* (including those that match pending requests).
|
|
136
|
+
*
|
|
137
|
+
* @param handler - Callback invoked with the parsed message data
|
|
138
|
+
*/
|
|
139
|
+
onMessage(handler: (data: unknown) => void): void;
|
|
140
|
+
/**
|
|
141
|
+
* Whether the WebSocket connection is currently open and ready.
|
|
142
|
+
*/
|
|
143
|
+
get isConnected(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Register an event listener for connection lifecycle events.
|
|
146
|
+
*
|
|
147
|
+
* Supported events: 'connected', 'disconnected'
|
|
148
|
+
*/
|
|
149
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
150
|
+
/**
|
|
151
|
+
* Remove an event listener.
|
|
152
|
+
*/
|
|
153
|
+
off(event: string, handler: (...args: unknown[]) => void): void;
|
|
154
|
+
/**
|
|
155
|
+
* Handle an incoming WebSocket message.
|
|
156
|
+
*
|
|
157
|
+
* Parses the message as JSON and checks for method-based correlation
|
|
158
|
+
* with pending requests. Also dispatches to all registered message handlers.
|
|
159
|
+
*/
|
|
160
|
+
private handleMessage;
|
|
161
|
+
/**
|
|
162
|
+
* Extract the method name from a parsed message object.
|
|
163
|
+
*
|
|
164
|
+
* Supports common message formats:
|
|
165
|
+
* - { method: "..." }
|
|
166
|
+
* - { type: "..." }
|
|
167
|
+
* - Nested: { response: { method: "..." } }
|
|
168
|
+
*/
|
|
169
|
+
private extractMethod;
|
|
170
|
+
/**
|
|
171
|
+
* Handle an unexpected WebSocket disconnection.
|
|
172
|
+
*
|
|
173
|
+
* Cleans up state and initiates reconnection with exponential backoff.
|
|
174
|
+
*
|
|
175
|
+
* Requirement 10.2: Exponential backoff reconnection.
|
|
176
|
+
* Requirement 10.3: Emit disconnected and mark unavailable when retries exhausted.
|
|
177
|
+
*/
|
|
178
|
+
private handleDisconnect;
|
|
179
|
+
/**
|
|
180
|
+
* Attempt to reconnect with exponential backoff.
|
|
181
|
+
*
|
|
182
|
+
* Requirement 10.2: delay = initialDelay * 2^(attempt-1)
|
|
183
|
+
* Requirement 10.3: Mark provider unavailable when all retries exhausted.
|
|
184
|
+
*/
|
|
185
|
+
private attemptReconnect;
|
|
186
|
+
/**
|
|
187
|
+
* Cancel any pending reconnection timer.
|
|
188
|
+
*/
|
|
189
|
+
private cancelReconnect;
|
|
190
|
+
/**
|
|
191
|
+
* Reject all pending requests with the given error and clean up timers.
|
|
192
|
+
*
|
|
193
|
+
* Requirement 10.4: Clean up all pending message handlers on disconnect.
|
|
194
|
+
*/
|
|
195
|
+
private cleanupPendingRequests;
|
|
196
|
+
/**
|
|
197
|
+
* Remove a specific pending request from the list.
|
|
198
|
+
*/
|
|
199
|
+
private removePendingRequest;
|
|
200
|
+
}
|
|
201
|
+
export {};
|
|
202
|
+
//# sourceMappingURL=clear-node-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear-node-connection.d.ts","sourceRoot":"","sources":["../../../src/yellow/clear-node-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,UAAU,UAAU;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1C,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3C,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CACxD;AAMD;;;;GAIG;AACH,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU,CAAC;AAYpD;;;;;;;;;;;GAWG;A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AE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI;IAI9D;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI;IAQ/D;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAuCrB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IAsBrB;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IA4BxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAU9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAM7B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yellow Network Event-to-Status Mapper
|
|
3
|
+
*
|
|
4
|
+
* Maps Yellow Network events, channel statuses, and state intents to JACK
|
|
5
|
+
* ExecutionStatus values. These are pure functions with no side effects,
|
|
6
|
+
* extracted from the dashboard's route.ts mapping tables into SDK-level
|
|
7
|
+
* reusable functions.
|
|
8
|
+
*
|
|
9
|
+
* Requirements: 9.1, 9.2, 9.3, 9.4, 9.5, 9.6
|
|
10
|
+
*/
|
|
11
|
+
import { ExecutionStatus } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Represents a mapped Yellow Network event with its corresponding JACK
|
|
14
|
+
* execution status, step label, step status, and terminal flag.
|
|
15
|
+
*/
|
|
16
|
+
export interface MappedEvent {
|
|
17
|
+
executionStatus: ExecutionStatus;
|
|
18
|
+
stepLabel: string;
|
|
19
|
+
stepStatus: 'COMPLETED' | 'IN_PROGRESS' | 'PENDING' | 'FAILED';
|
|
20
|
+
isTerminal: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Map a Yellow Network event name to a JACK MappedEvent.
|
|
24
|
+
*
|
|
25
|
+
* Accepts event names in any casing; normalizes to lowercase with underscores.
|
|
26
|
+
* Returns undefined for unknown events.
|
|
27
|
+
*
|
|
28
|
+
* @param event - The Yellow Network event name (e.g., "quote_accepted", "settled")
|
|
29
|
+
* @returns The corresponding MappedEvent, or undefined if the event is unknown
|
|
30
|
+
*
|
|
31
|
+
* Requirements: 9.1, 9.2, 9.3, 9.4, 9.5
|
|
32
|
+
*/
|
|
33
|
+
export declare function mapYellowEvent(event: string): MappedEvent | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Map a channel status to a JACK MappedEvent.
|
|
36
|
+
*
|
|
37
|
+
* Accepts channel statuses in any casing (e.g., "ACTIVE", "active", "Active").
|
|
38
|
+
* Returns undefined for unknown statuses.
|
|
39
|
+
*
|
|
40
|
+
* @param status - The ERC-7824 channel status (e.g., "VOID", "ACTIVE", "FINAL")
|
|
41
|
+
* @returns The corresponding MappedEvent, or undefined if the status is unknown
|
|
42
|
+
*
|
|
43
|
+
* Requirement: 9.6
|
|
44
|
+
*/
|
|
45
|
+
export declare function mapChannelStatus(status: string): MappedEvent | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Map a state intent to a JACK MappedEvent.
|
|
48
|
+
*
|
|
49
|
+
* Accepts state intents in any casing (e.g., "FINALIZE", "finalize", "Finalize").
|
|
50
|
+
* Returns undefined for unknown intents.
|
|
51
|
+
*
|
|
52
|
+
* @param intent - The ERC-7824 state intent (e.g., "INITIALIZE", "OPERATE", "FINALIZE")
|
|
53
|
+
* @returns The corresponding MappedEvent, or undefined if the intent is unknown
|
|
54
|
+
*
|
|
55
|
+
* Requirement: 9.6
|
|
56
|
+
*/
|
|
57
|
+
export declare function mapStateIntent(intent: string): MappedEvent | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Infer the best mapping from a notification payload.
|
|
60
|
+
*
|
|
61
|
+
* Checks fields in priority order: event → channelStatus → stateIntent.
|
|
62
|
+
* Returns the first successful mapping, or undefined if no field matches.
|
|
63
|
+
*
|
|
64
|
+
* @param notification - An object with optional event, channelStatus, and stateIntent fields
|
|
65
|
+
* @returns The best matching MappedEvent, or undefined if no mapping is found
|
|
66
|
+
*
|
|
67
|
+
* Requirements: 9.1, 9.2, 9.3, 9.4, 9.5, 9.6
|
|
68
|
+
*/
|
|
69
|
+
export declare function inferMapping(notification: {
|
|
70
|
+
event?: string;
|
|
71
|
+
channelStatus?: string;
|
|
72
|
+
stateIntent?: string;
|
|
73
|
+
}): MappedEvent | undefined;
|
|
74
|
+
//# sourceMappingURL=event-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-mapper.d.ts","sourceRoot":"","sources":["../../../src/yellow/event-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/D,UAAU,EAAE,OAAO,CAAC;CACrB;AA+KD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,WAAW,GAAG,SAAS,CAiB1B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yellow Network Integration - BigInt Serialization Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides helpers to ensure all BigInt values from NitroliteClient responses
|
|
5
|
+
* are converted to string representations in public-facing types, making
|
|
6
|
+
* ChannelState and YellowQuote objects fully JSON-serializable via JSON.stringify.
|
|
7
|
+
*
|
|
8
|
+
* Requirements: 11.1, 11.2, 11.5
|
|
9
|
+
*/
|
|
10
|
+
import type { ChannelState, YellowQuote } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Recursively converts any BigInt values in an object (or nested objects/arrays)
|
|
13
|
+
* to their string representation. All other value types are left unchanged.
|
|
14
|
+
*
|
|
15
|
+
* This is the foundational utility used by the type-specific helpers below.
|
|
16
|
+
* It handles the case where NitroliteClient responses may contain raw BigInt
|
|
17
|
+
* values that would cause JSON.stringify to throw.
|
|
18
|
+
*
|
|
19
|
+
* @param value - Any value that may contain BigInt values at any nesting level
|
|
20
|
+
* @returns A new value with all BigInt instances replaced by their string form
|
|
21
|
+
*
|
|
22
|
+
* Requirement 11.5: Convert BigInt values to string representation for JSON compatibility
|
|
23
|
+
*/
|
|
24
|
+
export declare function serializeBigIntToString<T>(value: T): T;
|
|
25
|
+
/**
|
|
26
|
+
* Ensures a ChannelState object is fully JSON-serializable.
|
|
27
|
+
*
|
|
28
|
+
* Converts any BigInt values that may be present in the ChannelState
|
|
29
|
+
* (particularly in allocation amounts, challengePeriod, challengeExpiration,
|
|
30
|
+
* stateVersion, chainId, createdAt, updatedAt) to their appropriate
|
|
31
|
+
* JSON-compatible types (string for amounts, number for numeric fields).
|
|
32
|
+
*
|
|
33
|
+
* @param state - A ChannelState that may contain BigInt values from NitroliteClient
|
|
34
|
+
* @returns A new ChannelState with all values JSON-serializable
|
|
35
|
+
*
|
|
36
|
+
* Requirements: 11.1, 11.5
|
|
37
|
+
*/
|
|
38
|
+
export declare function toSerializableChannelState(state: ChannelState): ChannelState;
|
|
39
|
+
/**
|
|
40
|
+
* Ensures a YellowQuote object is fully JSON-serializable.
|
|
41
|
+
*
|
|
42
|
+
* Converts any BigInt values that may be present in the YellowQuote
|
|
43
|
+
* (particularly amountIn and amountOut from solver responses) to their
|
|
44
|
+
* string representation.
|
|
45
|
+
*
|
|
46
|
+
* @param quote - A YellowQuote that may contain BigInt values from ClearNode
|
|
47
|
+
* @returns A new YellowQuote with all values JSON-serializable
|
|
48
|
+
*
|
|
49
|
+
* Requirement 11.2
|
|
50
|
+
*/
|
|
51
|
+
export declare function toSerializableYellowQuote(quote: YellowQuote): YellowQuote;
|
|
52
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/yellow/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAM/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAuBtD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAiB5E;AAuBD;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAazE"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Key Manager for Yellow Network ClearNode Authentication
|
|
3
|
+
*
|
|
4
|
+
* Handles session key generation, EIP-712 authentication flow, and session lifecycle.
|
|
5
|
+
*
|
|
6
|
+
* Authentication flow:
|
|
7
|
+
* 1. Generate session keypair via viem's generatePrivateKey + privateKeyToAccount
|
|
8
|
+
* 2. Send auth_request message with session key address, allowances, expiry, scope
|
|
9
|
+
* 3. Receive auth_challenge from ClearNode
|
|
10
|
+
* 4. Sign challenge with main wallet via EIP-712 typed data
|
|
11
|
+
* 5. Send auth_verify with signed challenge
|
|
12
|
+
* 6. Receive confirmation and store session state
|
|
13
|
+
*
|
|
14
|
+
* Requirements: 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
|
|
15
|
+
*/
|
|
16
|
+
import type { WalletClient, Hex } from 'viem';
|
|
17
|
+
import type { ClearNodeConnection } from './clear-node-connection.js';
|
|
18
|
+
/**
|
|
19
|
+
* Signer function type used for signing messages.
|
|
20
|
+
* Compatible with @erc7824/nitrolite's MessageSigner type.
|
|
21
|
+
*/
|
|
22
|
+
export type MessageSigner = (payload: Uint8Array) => Promise<Hex>;
|
|
23
|
+
/**
|
|
24
|
+
* Parameters for creating an auth request message.
|
|
25
|
+
*/
|
|
26
|
+
interface AuthRequestParams {
|
|
27
|
+
wallet: string;
|
|
28
|
+
participant: string;
|
|
29
|
+
allowances: Array<{
|
|
30
|
+
asset: string;
|
|
31
|
+
amount: string;
|
|
32
|
+
}>;
|
|
33
|
+
expire: number;
|
|
34
|
+
scope: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parameters for authenticating with ClearNode.
|
|
38
|
+
*/
|
|
39
|
+
export interface AuthParams {
|
|
40
|
+
/** Token allowances for the session */
|
|
41
|
+
allowances: Array<{
|
|
42
|
+
asset: string;
|
|
43
|
+
amount: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** Unix timestamp when the session expires. Default: now + 3600 seconds */
|
|
46
|
+
expiresAt?: number;
|
|
47
|
+
/** Application scope identifier. Default: "jack-kernel" */
|
|
48
|
+
scope?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Information about the current authenticated session.
|
|
52
|
+
*/
|
|
53
|
+
export interface SessionInfo {
|
|
54
|
+
/** The session key's Ethereum address */
|
|
55
|
+
sessionAddress: string;
|
|
56
|
+
/** Unix timestamp when the session expires */
|
|
57
|
+
expiresAt: number;
|
|
58
|
+
/** Whether the session is currently authenticated */
|
|
59
|
+
authenticated: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create an auth_request message for ClearNode.
|
|
63
|
+
*
|
|
64
|
+
* This is a local implementation matching the @erc7824/nitrolite
|
|
65
|
+
* createAuthRequestMessage API. It constructs a JSON-RPC style message
|
|
66
|
+
* with the session key details and allowances.
|
|
67
|
+
*
|
|
68
|
+
* @param params - Auth request parameters
|
|
69
|
+
* @returns JSON string of the auth_request message
|
|
70
|
+
*/
|
|
71
|
+
export declare function createAuthRequestMessage(params: AuthRequestParams): string;
|
|
72
|
+
/**
|
|
73
|
+
* Create an EIP-712 auth message signer using the provided wallet client.
|
|
74
|
+
*
|
|
75
|
+
* This is a local implementation matching the @erc7824/nitrolite
|
|
76
|
+
* createEIP712AuthMessageSigner API. It returns a function that signs
|
|
77
|
+
* a challenge string using EIP-712 typed data via the wallet client.
|
|
78
|
+
*
|
|
79
|
+
* The EIP-712 domain and types follow the Yellow Network auth protocol:
|
|
80
|
+
* - Domain: { name: "Yellow ClearNode", version: "1" }
|
|
81
|
+
* - Types: { Auth: [{ name: "challenge", type: "string" }] }
|
|
82
|
+
*
|
|
83
|
+
* @param walletClient - The viem WalletClient to sign with
|
|
84
|
+
* @returns A function that takes a challenge string and returns the EIP-712 signature
|
|
85
|
+
*/
|
|
86
|
+
export declare function createEIP712AuthMessageSigner(walletClient: WalletClient): (challenge: string) => Promise<Hex>;
|
|
87
|
+
/**
|
|
88
|
+
* Manages session key generation, ClearNode authentication, and session lifecycle.
|
|
89
|
+
*
|
|
90
|
+
* The SessionKeyManager generates ephemeral session keypairs for signing offchain
|
|
91
|
+
* messages, authenticates them with ClearNode via EIP-712, and tracks session expiry
|
|
92
|
+
* to support automatic re-authentication when the session expires.
|
|
93
|
+
*
|
|
94
|
+
* Requirements: 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
|
|
95
|
+
*/
|
|
96
|
+
export declare class SessionKeyManager {
|
|
97
|
+
private readonly walletClient;
|
|
98
|
+
private readonly connection;
|
|
99
|
+
private sessionAccount;
|
|
100
|
+
private sessionPrivateKey;
|
|
101
|
+
private _sessionInfo;
|
|
102
|
+
private lastAuthParams;
|
|
103
|
+
/**
|
|
104
|
+
* @param walletClient - The main wallet's viem WalletClient for EIP-712 signing
|
|
105
|
+
* @param connection - The ClearNodeConnection for sending/receiving auth messages
|
|
106
|
+
*/
|
|
107
|
+
constructor(walletClient: WalletClient, connection: ClearNodeConnection);
|
|
108
|
+
/**
|
|
109
|
+
* Generate a session keypair and authenticate with ClearNode.
|
|
110
|
+
*
|
|
111
|
+
* Flow:
|
|
112
|
+
* 1. Generate session keypair (Requirement 2.1)
|
|
113
|
+
* 2. Send auth_request with session address, allowances, expiry, scope (Requirement 2.2)
|
|
114
|
+
* 3. Receive auth_challenge from ClearNode
|
|
115
|
+
* 4. Sign challenge with main wallet via EIP-712 (Requirement 2.3)
|
|
116
|
+
* 5. Send auth_verify with signed challenge
|
|
117
|
+
* 6. Receive confirmation and store session state (Requirement 2.4)
|
|
118
|
+
*
|
|
119
|
+
* @param params - Authentication parameters including allowances and optional expiry/scope
|
|
120
|
+
* @returns Session information including address, expiry, and authentication status
|
|
121
|
+
* @throws Error if authentication fails or times out (Requirement 2.5)
|
|
122
|
+
*/
|
|
123
|
+
authenticate(params: AuthParams): Promise<SessionInfo>;
|
|
124
|
+
/**
|
|
125
|
+
* Check if the current session is valid and not expired.
|
|
126
|
+
*
|
|
127
|
+
* Returns false if:
|
|
128
|
+
* - No session has been established
|
|
129
|
+
* - The session has been invalidated
|
|
130
|
+
* - The session has expired (Requirement 2.6)
|
|
131
|
+
*/
|
|
132
|
+
get isAuthenticated(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Get the session signer function for signing offchain messages.
|
|
135
|
+
*
|
|
136
|
+
* The returned function signs arbitrary payloads using the session private key.
|
|
137
|
+
* This is used for signing state channel messages without exposing the main wallet.
|
|
138
|
+
*
|
|
139
|
+
* @throws Error if no authenticated session exists
|
|
140
|
+
*/
|
|
141
|
+
get sessionSigner(): MessageSigner;
|
|
142
|
+
/**
|
|
143
|
+
* Get the session key's Ethereum address.
|
|
144
|
+
*
|
|
145
|
+
* @throws Error if no session key has been generated
|
|
146
|
+
*/
|
|
147
|
+
get sessionAddress(): string;
|
|
148
|
+
/**
|
|
149
|
+
* Invalidate the current session.
|
|
150
|
+
*
|
|
151
|
+
* Clears all session state including the keypair and authentication status.
|
|
152
|
+
* After invalidation, a new authenticate() call is required.
|
|
153
|
+
*/
|
|
154
|
+
invalidate(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Re-authenticate using the last authentication parameters.
|
|
157
|
+
*
|
|
158
|
+
* This is called internally when a session has expired and a new operation
|
|
159
|
+
* requires an active session (Requirement 2.6).
|
|
160
|
+
*
|
|
161
|
+
* @returns Session information from the new authentication
|
|
162
|
+
* @throws Error if no previous auth params exist or re-authentication fails
|
|
163
|
+
*/
|
|
164
|
+
reauthenticate(): Promise<SessionInfo>;
|
|
165
|
+
/**
|
|
166
|
+
* Ensure the session is authenticated, re-authenticating if expired.
|
|
167
|
+
*
|
|
168
|
+
* This is a convenience method for use by other components that need
|
|
169
|
+
* to ensure an active session before performing operations.
|
|
170
|
+
*
|
|
171
|
+
* Requirement 2.6: Auto-reauthentication on next operation when expired.
|
|
172
|
+
*
|
|
173
|
+
* @returns The current or newly created session info
|
|
174
|
+
* @throws Error if authentication fails
|
|
175
|
+
*/
|
|
176
|
+
ensureAuthenticated(): Promise<SessionInfo>;
|
|
177
|
+
}
|
|
178
|
+
export {};
|
|
179
|
+
//# sourceMappingURL=session-key-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-key-manager.d.ts","sourceRoot":"","sources":["../../../src/yellow/session-key-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAgB,MAAM,MAAM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