@gvnrdao/dh-lit-actions 0.0.3 → 0.0.5
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/package.json +3 -3
- package/pkg-dist/utils/chunks/connection-helpers.d.ts +99 -0
- package/pkg-dist/utils/chunks/connection-helpers.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/connection-helpers.js +362 -0
- package/pkg-dist/utils/chunks/connection-helpers.js.map +1 -0
- package/pkg-dist/utils/chunks/debug-logger.d.ts +93 -0
- package/pkg-dist/utils/chunks/debug-logger.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/debug-logger.js +264 -0
- package/pkg-dist/utils/chunks/debug-logger.js.map +1 -0
- package/pkg-dist/utils/chunks/error-classification.d.ts +97 -0
- package/pkg-dist/utils/chunks/error-classification.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/error-classification.js +385 -0
- package/pkg-dist/utils/chunks/error-classification.js.map +1 -0
- package/pkg-dist/utils/chunks/session-signature-cache.d.ts +84 -0
- package/pkg-dist/utils/chunks/session-signature-cache.d.ts.map +1 -0
- package/pkg-dist/utils/chunks/session-signature-cache.js +194 -0
- package/pkg-dist/utils/chunks/session-signature-cache.js.map +1 -0
- package/pkg-dist/utils/index.d.ts +4 -0
- package/pkg-dist/utils/index.d.ts.map +1 -1
- package/pkg-dist/utils/index.js +4 -0
- package/pkg-dist/utils/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-lit-actions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Diamond Hands Protocol LIT Actions - Deterministic, Auditable Builds",
|
|
5
5
|
"main": "pkg-dist/index.js",
|
|
6
6
|
"types": "pkg-dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"test:coverage": "jest --coverage"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lit-protocol/contracts-sdk": "^7.3.
|
|
31
|
-
"@lit-protocol/lit-node-client": "^7.3.
|
|
30
|
+
"@lit-protocol/contracts-sdk": "^7.3.1",
|
|
31
|
+
"@lit-protocol/lit-node-client": "^7.3.1",
|
|
32
32
|
"axios": "1.7.7",
|
|
33
33
|
"bs58": "^6.0.0",
|
|
34
34
|
"dotenv": "16.4.7",
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIT Protocol Connection Helpers
|
|
3
|
+
* Provides retry logic, error handling, and connection validation utilities
|
|
4
|
+
* for robust LIT Protocol operations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Retry configuration options
|
|
8
|
+
*/
|
|
9
|
+
export interface RetryConfig {
|
|
10
|
+
maxAttempts: number;
|
|
11
|
+
initialDelayMs: number;
|
|
12
|
+
maxDelayMs: number;
|
|
13
|
+
backoffMultiplier: number;
|
|
14
|
+
retryableErrors: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Default retry configuration optimized for LIT Protocol operations
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Connection validation result
|
|
22
|
+
*/
|
|
23
|
+
export interface ConnectionValidationResult {
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
latencyMs?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sleep utility for retry delays
|
|
30
|
+
*/
|
|
31
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if an error is retryable using enhanced classification system
|
|
34
|
+
*/
|
|
35
|
+
export declare function isRetryableError(error: any, retryableErrors?: string[]): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Calculate exponential backoff delay with jitter
|
|
38
|
+
*/
|
|
39
|
+
export declare function calculateDelay(attempt: number, config: RetryConfig): number;
|
|
40
|
+
/**
|
|
41
|
+
* Enhanced retry wrapper with intelligent error classification
|
|
42
|
+
*/
|
|
43
|
+
export declare function withRetry<T>(operation: () => Promise<T>, config?: Partial<RetryConfig>, operationName?: string): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Enhanced LIT Node Client connector with retry logic and readiness validation
|
|
46
|
+
*/
|
|
47
|
+
export declare function connectLitNodeClient(litNodeClient: any, config?: Partial<RetryConfig>): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Enhanced LIT Contracts connector with retry logic
|
|
50
|
+
*/
|
|
51
|
+
export declare function connectLitContracts(litContracts: any, config?: Partial<RetryConfig>): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Validate LIT Node Client connection health
|
|
54
|
+
*/
|
|
55
|
+
export declare function validateLitNodeConnection(litNodeClient: any): Promise<ConnectionValidationResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Enhanced session signature generator with retry logic and caching
|
|
58
|
+
*/
|
|
59
|
+
export declare function generateSessionSignatures(litNodeClient: any, sessionConfig: any, config?: Partial<RetryConfig>, pkpTokenId?: string, litActionCid?: string, signerAddress?: string, network?: string): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Validate LIT Node Client readiness before operations
|
|
62
|
+
*/
|
|
63
|
+
export declare function validateLitNodeReadiness(litNodeClient: any): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Enhanced LIT Action executor with retry logic and readiness validation
|
|
66
|
+
*/
|
|
67
|
+
export declare function executeLitAction(litNodeClient: any, executionConfig: any, config?: Partial<RetryConfig>): Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* PKP operation wrapper with enhanced error handling
|
|
70
|
+
*/
|
|
71
|
+
export declare function executePkpOperation<T>(operation: () => Promise<T>, operationName: string, config?: Partial<RetryConfig>): Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* Network-specific timeout configurations
|
|
74
|
+
*/
|
|
75
|
+
export declare const NETWORK_TIMEOUTS: {
|
|
76
|
+
readonly datil: {
|
|
77
|
+
readonly connection: 60000;
|
|
78
|
+
readonly operation: 120000;
|
|
79
|
+
readonly pkpValidation: 180000;
|
|
80
|
+
};
|
|
81
|
+
readonly 'datil-test': {
|
|
82
|
+
readonly connection: 30000;
|
|
83
|
+
readonly operation: 60000;
|
|
84
|
+
readonly pkpValidation: 90000;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Get network-specific timeout configuration
|
|
89
|
+
*/
|
|
90
|
+
export declare function getNetworkTimeouts(network: string): {
|
|
91
|
+
readonly connection: 60000;
|
|
92
|
+
readonly operation: 120000;
|
|
93
|
+
readonly pkpValidation: 180000;
|
|
94
|
+
} | {
|
|
95
|
+
readonly connection: 30000;
|
|
96
|
+
readonly operation: 60000;
|
|
97
|
+
readonly pkpValidation: 90000;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=connection-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-helpers.d.ts","sourceRoot":"","sources":["../../../pkg-src/utils/chunks/connection-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WA2BlC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAA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,EAAE,GAAG,EACpB,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAChC,OAAO,CAAC,GAAG,CAAC,CA4Bd;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAChC,OAAO,CAAC,CAAC,CAAC,CAcZ;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;CAWnB,CAAC;AAEX;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM;;;;;;;;EAEjD"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LIT Protocol Connection Helpers
|
|
4
|
+
* Provides retry logic, error handling, and connection validation utilities
|
|
5
|
+
* for robust LIT Protocol operations
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.NETWORK_TIMEOUTS = exports.DEFAULT_RETRY_CONFIG = void 0;
|
|
42
|
+
exports.sleep = sleep;
|
|
43
|
+
exports.isRetryableError = isRetryableError;
|
|
44
|
+
exports.calculateDelay = calculateDelay;
|
|
45
|
+
exports.withRetry = withRetry;
|
|
46
|
+
exports.connectLitNodeClient = connectLitNodeClient;
|
|
47
|
+
exports.connectLitContracts = connectLitContracts;
|
|
48
|
+
exports.validateLitNodeConnection = validateLitNodeConnection;
|
|
49
|
+
exports.generateSessionSignatures = generateSessionSignatures;
|
|
50
|
+
exports.validateLitNodeReadiness = validateLitNodeReadiness;
|
|
51
|
+
exports.executeLitAction = executeLitAction;
|
|
52
|
+
exports.executePkpOperation = executePkpOperation;
|
|
53
|
+
exports.getNetworkTimeouts = getNetworkTimeouts;
|
|
54
|
+
const debug_logger_1 = require("./debug-logger");
|
|
55
|
+
const error_classification_1 = require("./error-classification");
|
|
56
|
+
/**
|
|
57
|
+
* Default retry configuration optimized for LIT Protocol operations
|
|
58
|
+
*/
|
|
59
|
+
exports.DEFAULT_RETRY_CONFIG = {
|
|
60
|
+
maxAttempts: 5, // Increased from 3 for PKP operations
|
|
61
|
+
initialDelayMs: 2000, // Increased from 1000ms for PKP operations
|
|
62
|
+
maxDelayMs: 60000, // Increased from 30000ms for PKP operations
|
|
63
|
+
backoffMultiplier: 2,
|
|
64
|
+
retryableErrors: [
|
|
65
|
+
'request_timeout',
|
|
66
|
+
'network error',
|
|
67
|
+
'connection failed',
|
|
68
|
+
'ENOTFOUND',
|
|
69
|
+
'ECONNREFUSED',
|
|
70
|
+
'ETIMEDOUT',
|
|
71
|
+
'socket hang up',
|
|
72
|
+
'timeout',
|
|
73
|
+
// PKP-specific errors
|
|
74
|
+
'signing shares',
|
|
75
|
+
'There was an error getting the signing shares',
|
|
76
|
+
'PKP validation',
|
|
77
|
+
'pkp validation failed',
|
|
78
|
+
'resource validation',
|
|
79
|
+
'ipfs propagation',
|
|
80
|
+
'session.*expired',
|
|
81
|
+
'NodeError',
|
|
82
|
+
'Response from the nodes',
|
|
83
|
+
'consensus',
|
|
84
|
+
'threshold'
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Sleep utility for retry delays
|
|
89
|
+
*/
|
|
90
|
+
function sleep(ms) {
|
|
91
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if an error is retryable using enhanced classification system
|
|
95
|
+
*/
|
|
96
|
+
function isRetryableError(error, retryableErrors = exports.DEFAULT_RETRY_CONFIG.retryableErrors) {
|
|
97
|
+
if (!error)
|
|
98
|
+
return false;
|
|
99
|
+
// Use enhanced error classification for LIT Protocol specific errors
|
|
100
|
+
const classification = (0, error_classification_1.classifyError)(error);
|
|
101
|
+
// If classification determined retryability, use that
|
|
102
|
+
if (classification.isRetryable !== undefined) {
|
|
103
|
+
(0, debug_logger_1.debugInfo)('ERROR_CLASSIFICATION', `Error classified as: ${classification.category} (retryable: ${classification.isRetryable})`);
|
|
104
|
+
return classification.isRetryable;
|
|
105
|
+
}
|
|
106
|
+
// Fallback to legacy pattern matching
|
|
107
|
+
const errorMessage = error.message || error.toString() || '';
|
|
108
|
+
const errorLower = errorMessage.toLowerCase();
|
|
109
|
+
return retryableErrors.some(pattern => errorLower.includes(pattern.toLowerCase()));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Calculate exponential backoff delay with jitter
|
|
113
|
+
*/
|
|
114
|
+
function calculateDelay(attempt, config) {
|
|
115
|
+
const exponentialDelay = Math.min(config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1), config.maxDelayMs);
|
|
116
|
+
// Add jitter (±25%) to avoid thundering herd
|
|
117
|
+
const jitter = exponentialDelay * 0.25 * (Math.random() - 0.5);
|
|
118
|
+
return Math.max(100, exponentialDelay + jitter);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Enhanced retry wrapper with intelligent error classification
|
|
122
|
+
*/
|
|
123
|
+
async function withRetry(operation, config = {}, operationName = 'operation') {
|
|
124
|
+
let finalConfig = { ...exports.DEFAULT_RETRY_CONFIG, ...config };
|
|
125
|
+
const tracker = new debug_logger_1.PerformanceTracker(`Retry ${operationName}`);
|
|
126
|
+
let lastError;
|
|
127
|
+
let errorClassification = null;
|
|
128
|
+
for (let attempt = 1; attempt <= finalConfig.maxAttempts; attempt++) {
|
|
129
|
+
try {
|
|
130
|
+
(0, debug_logger_1.debugInfo)('RETRY', `🔄 [${operationName}] Attempt ${attempt}/${finalConfig.maxAttempts}`);
|
|
131
|
+
const startTime = Date.now();
|
|
132
|
+
const result = await operation();
|
|
133
|
+
const duration = Date.now() - startTime;
|
|
134
|
+
(0, debug_logger_1.debugInfo)('RETRY', `✅ [${operationName}] Success after ${duration}ms (attempt ${attempt})`);
|
|
135
|
+
debug_logger_1.networkMetrics.recordRequest(operationName, true, duration);
|
|
136
|
+
tracker.end(true);
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
lastError = error;
|
|
141
|
+
const errorMessage = error?.message || error?.toString() || 'Unknown error';
|
|
142
|
+
// Classify error and potentially adjust retry strategy
|
|
143
|
+
errorClassification = (0, error_classification_1.classifyError)(error);
|
|
144
|
+
// Update config with intelligent retry settings if this is the first error
|
|
145
|
+
if (attempt === 1 && errorClassification) {
|
|
146
|
+
const intelligentConfig = (0, error_classification_1.getRetryConfigFromClassification)(errorClassification);
|
|
147
|
+
finalConfig = {
|
|
148
|
+
...finalConfig,
|
|
149
|
+
...intelligentConfig,
|
|
150
|
+
maxAttempts: Math.min(finalConfig.maxAttempts, intelligentConfig.maxAttempts)
|
|
151
|
+
};
|
|
152
|
+
(0, debug_logger_1.debugInfo)('RETRY', `🧠 Intelligent retry strategy applied: ${errorClassification.category} (${errorClassification.retryStrategy})`);
|
|
153
|
+
(0, debug_logger_1.debugInfo)('RETRY', `📊 Adjusted config: max=${finalConfig.maxAttempts}, delay=${finalConfig.initialDelayMs}ms`);
|
|
154
|
+
}
|
|
155
|
+
(0, debug_logger_1.debugWarn)('RETRY', `⚠️ [${operationName}] Attempt ${attempt} failed:`, {
|
|
156
|
+
error: errorMessage,
|
|
157
|
+
attempt,
|
|
158
|
+
category: errorClassification.category,
|
|
159
|
+
retryable: errorClassification.isRetryable
|
|
160
|
+
});
|
|
161
|
+
debug_logger_1.networkMetrics.recordRequest(operationName, false, 0, errorMessage);
|
|
162
|
+
// Check if we've exceeded the (possibly adjusted) max attempts
|
|
163
|
+
if (attempt >= finalConfig.maxAttempts) {
|
|
164
|
+
(0, debug_logger_1.debugError)('RETRY', `❌ [${operationName}] All attempts failed. Last error:`, { error: errorMessage });
|
|
165
|
+
// Generate detailed error report
|
|
166
|
+
if (errorClassification) {
|
|
167
|
+
const errorReport = (0, error_classification_1.createErrorReport)(error);
|
|
168
|
+
(0, debug_logger_1.debugError)('RETRY', `📋 Error Analysis Report:\n${errorReport}`);
|
|
169
|
+
}
|
|
170
|
+
tracker.end(false);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (!errorClassification.isRetryable) {
|
|
174
|
+
(0, debug_logger_1.debugError)('RETRY', `🚫 [${operationName}] Non-retryable error (${errorClassification.category}):`, { error: errorMessage });
|
|
175
|
+
// Show troubleshooting tips for non-retryable errors
|
|
176
|
+
if (errorClassification.troubleshooting) {
|
|
177
|
+
(0, debug_logger_1.debugInfo)('RETRY', `💡 Troubleshooting suggestions:\n ${errorClassification.troubleshooting.join('\n ')}`);
|
|
178
|
+
}
|
|
179
|
+
tracker.end(false);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
const delayMs = calculateDelay(attempt, finalConfig);
|
|
183
|
+
(0, debug_logger_1.debugInfo)('RETRY', `⏳ [${operationName}] Waiting ${delayMs}ms before retry... (${errorClassification.retryStrategy} strategy)`);
|
|
184
|
+
await sleep(delayMs);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
throw lastError;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Enhanced LIT Node Client connector with retry logic and readiness validation
|
|
191
|
+
*/
|
|
192
|
+
async function connectLitNodeClient(litNodeClient, config = {}) {
|
|
193
|
+
const network = litNodeClient?.config?.litNetwork || 'unknown';
|
|
194
|
+
return withRetry(async () => {
|
|
195
|
+
if (!litNodeClient) {
|
|
196
|
+
throw new Error('LIT Node Client is null or undefined');
|
|
197
|
+
}
|
|
198
|
+
const startTime = Date.now();
|
|
199
|
+
(0, debug_logger_1.logConnectionAttempt)(network, 1, config.maxAttempts || exports.DEFAULT_RETRY_CONFIG.maxAttempts);
|
|
200
|
+
// First connect to the network
|
|
201
|
+
await litNodeClient.connect();
|
|
202
|
+
// Wait for client to be ready
|
|
203
|
+
(0, debug_logger_1.debugInfo)('CONNECTION', `⏳ Waiting for LIT Node Client to be ready...`);
|
|
204
|
+
const readyTimeout = 30000; // 30 seconds timeout for readiness
|
|
205
|
+
const readyStartTime = Date.now();
|
|
206
|
+
while (!litNodeClient.ready && (Date.now() - readyStartTime) < readyTimeout) {
|
|
207
|
+
await sleep(500); // Check every 500ms
|
|
208
|
+
}
|
|
209
|
+
if (!litNodeClient.ready) {
|
|
210
|
+
throw new Error(`LIT Node Client failed to become ready within ${readyTimeout}ms`);
|
|
211
|
+
}
|
|
212
|
+
const latency = Date.now() - startTime;
|
|
213
|
+
(0, debug_logger_1.debugInfo)('CONNECTION', `✅ LIT Node Client is ready (${litNodeClient.ready})`);
|
|
214
|
+
(0, debug_logger_1.logConnectionSuccess)(network, latency);
|
|
215
|
+
}, config, 'LIT Node Client Connection');
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Enhanced LIT Contracts connector with retry logic
|
|
219
|
+
*/
|
|
220
|
+
async function connectLitContracts(litContracts, config = {}) {
|
|
221
|
+
return withRetry(async () => {
|
|
222
|
+
if (!litContracts) {
|
|
223
|
+
throw new Error('LIT Contracts is null or undefined');
|
|
224
|
+
}
|
|
225
|
+
console.log(`🔗 Connecting to LIT Contracts: ${litContracts.network || 'unknown'}`);
|
|
226
|
+
await litContracts.connect();
|
|
227
|
+
console.log('✅ LIT Contracts connected successfully');
|
|
228
|
+
}, config, 'LIT Contracts Connection');
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Validate LIT Node Client connection health
|
|
232
|
+
*/
|
|
233
|
+
async function validateLitNodeConnection(litNodeClient) {
|
|
234
|
+
try {
|
|
235
|
+
const startTime = Date.now();
|
|
236
|
+
if (!litNodeClient) {
|
|
237
|
+
return { isValid: false, error: 'LIT Node Client is null or undefined' };
|
|
238
|
+
}
|
|
239
|
+
// Try to get the latest block hash as a health check
|
|
240
|
+
await litNodeClient.getLatestBlockhash();
|
|
241
|
+
const latencyMs = Date.now() - startTime;
|
|
242
|
+
return { isValid: true, latencyMs };
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
return {
|
|
246
|
+
isValid: false,
|
|
247
|
+
error: error?.message || error?.toString() || 'Unknown validation error'
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Enhanced session signature generator with retry logic and caching
|
|
253
|
+
*/
|
|
254
|
+
async function generateSessionSignatures(litNodeClient, sessionConfig, config = {}, pkpTokenId, litActionCid, signerAddress, network = 'datil') {
|
|
255
|
+
// If caching parameters are provided, try cache first
|
|
256
|
+
if (pkpTokenId && litActionCid && signerAddress) {
|
|
257
|
+
const { sessionSignatureCache } = await Promise.resolve().then(() => __importStar(require('./session-signature-cache')));
|
|
258
|
+
const cached = sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
|
|
259
|
+
if (cached) {
|
|
260
|
+
const sigCount = Object.keys(cached).length;
|
|
261
|
+
(0, debug_logger_1.debugInfo)('SESSION', `🔄 Using cached session signatures (${sigCount} sigs)`);
|
|
262
|
+
return cached;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return withRetry(async () => {
|
|
266
|
+
(0, debug_logger_1.debugInfo)('SESSION', '🔐 Generating new session signatures...');
|
|
267
|
+
const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
|
|
268
|
+
const sigCount = Object.keys(sessionSigs).length;
|
|
269
|
+
// Cache if parameters provided
|
|
270
|
+
if (pkpTokenId && litActionCid && signerAddress) {
|
|
271
|
+
const { sessionSignatureCache } = await Promise.resolve().then(() => __importStar(require('./session-signature-cache')));
|
|
272
|
+
const expiration = new Date(sessionConfig.expiration);
|
|
273
|
+
sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
|
|
274
|
+
}
|
|
275
|
+
(0, debug_logger_1.debugInfo)('SESSION', `✅ Generated ${sigCount} session signatures`);
|
|
276
|
+
return sessionSigs;
|
|
277
|
+
}, config, 'Session Signature Generation');
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Validate LIT Node Client readiness before operations
|
|
281
|
+
*/
|
|
282
|
+
async function validateLitNodeReadiness(litNodeClient) {
|
|
283
|
+
if (!litNodeClient) {
|
|
284
|
+
throw new Error('LIT Node Client is null or undefined');
|
|
285
|
+
}
|
|
286
|
+
// Check if client is connected
|
|
287
|
+
if (!litNodeClient.ready) {
|
|
288
|
+
(0, debug_logger_1.debugWarn)('CONNECTION', '⚠️ LIT Node Client not ready, attempting to reconnect...');
|
|
289
|
+
await litNodeClient.connect();
|
|
290
|
+
// Wait for readiness with timeout
|
|
291
|
+
const readyTimeout = 15000; // 15 seconds
|
|
292
|
+
const startTime = Date.now();
|
|
293
|
+
while (!litNodeClient.ready && (Date.now() - startTime) < readyTimeout) {
|
|
294
|
+
await sleep(500);
|
|
295
|
+
}
|
|
296
|
+
if (!litNodeClient.ready) {
|
|
297
|
+
throw new Error('LIT Node Client is not ready for operations');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
(0, debug_logger_1.debugInfo)('CONNECTION', '✅ LIT Node Client readiness validated');
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Enhanced LIT Action executor with retry logic and readiness validation
|
|
304
|
+
*/
|
|
305
|
+
async function executeLitAction(litNodeClient, executionConfig, config = {}) {
|
|
306
|
+
const cid = executionConfig.ipfsId;
|
|
307
|
+
return withRetry(async () => {
|
|
308
|
+
const startTime = Date.now();
|
|
309
|
+
// Validate client readiness before execution
|
|
310
|
+
await validateLitNodeReadiness(litNodeClient);
|
|
311
|
+
(0, debug_logger_1.logLitActionExecution)(cid, executionConfig.jsParams);
|
|
312
|
+
(0, debug_logger_1.logRequest)('LIT_ACTION', 'executeJs', executionConfig);
|
|
313
|
+
const result = await litNodeClient.executeJs(executionConfig);
|
|
314
|
+
const duration = Date.now() - startTime;
|
|
315
|
+
if (!result.response) {
|
|
316
|
+
(0, debug_logger_1.logError)('LIT_ACTION', 'executeJs', new Error('No response from LIT Action'), duration);
|
|
317
|
+
throw new Error('No response from LIT Action');
|
|
318
|
+
}
|
|
319
|
+
(0, debug_logger_1.logResponse)('LIT_ACTION', 'executeJs', result, duration);
|
|
320
|
+
(0, debug_logger_1.logLitActionResult)(cid, true, duration, result);
|
|
321
|
+
return result;
|
|
322
|
+
}, config, 'LIT Action Execution');
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* PKP operation wrapper with enhanced error handling
|
|
326
|
+
*/
|
|
327
|
+
async function executePkpOperation(operation, operationName, config = {}) {
|
|
328
|
+
const pkpConfig = {
|
|
329
|
+
...exports.DEFAULT_RETRY_CONFIG,
|
|
330
|
+
...config,
|
|
331
|
+
retryableErrors: [
|
|
332
|
+
...exports.DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
333
|
+
'pkp validation',
|
|
334
|
+
'signing shares',
|
|
335
|
+
'resource validation',
|
|
336
|
+
'ipfs propagation'
|
|
337
|
+
]
|
|
338
|
+
};
|
|
339
|
+
return withRetry(operation, pkpConfig, `PKP ${operationName}`);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Network-specific timeout configurations
|
|
343
|
+
*/
|
|
344
|
+
exports.NETWORK_TIMEOUTS = {
|
|
345
|
+
'datil': {
|
|
346
|
+
connection: 60000, // 60 seconds
|
|
347
|
+
operation: 120000, // 2 minutes
|
|
348
|
+
pkpValidation: 180000 // 3 minutes
|
|
349
|
+
},
|
|
350
|
+
'datil-test': {
|
|
351
|
+
connection: 30000, // 30 seconds
|
|
352
|
+
operation: 60000, // 1 minute
|
|
353
|
+
pkpValidation: 90000 // 1.5 minutes
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Get network-specific timeout configuration
|
|
358
|
+
*/
|
|
359
|
+
function getNetworkTimeouts(network) {
|
|
360
|
+
return exports.NETWORK_TIMEOUTS[network] || exports.NETWORK_TIMEOUTS['datil'];
|
|
361
|
+
}
|
|
362
|
+
//# sourceMappingURL=connection-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-helpers.js","sourceRoot":"","sources":["../../../pkg-src/utils/chunks/connection-helpers.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFH,sBAEC;AAKD,4CA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BAAgB,GAAG;IAC9B,OAAO,EAAE;QACP,UAAU,EAAE,KAAK,EAAK,aAAa;QACnC,SAAS,EAAE,MAAM,EAAK,YAAY;QAClC,aAAa,EAAE,MAAM,CAAC,YAAY;KACnC;IACD,YAAY,EAAE;QACZ,UAAU,EAAE,KAAK,EAAK,aAAa;QACnC,SAAS,EAAE,KAAK,EAAM,WAAW;QACjC,aAAa,EAAE,KAAK,CAAE,cAAc;KACrC;CACO,CAAC;AAEX;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,OAAO,wBAAgB,CAAC,OAAwC,CAAC,IAAI,wBAAgB,CAAC,OAAO,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Debug Logger for LIT Protocol Operations
|
|
3
|
+
* Provides detailed logging for debugging network and protocol issues
|
|
4
|
+
*/
|
|
5
|
+
export declare enum LogLevel {
|
|
6
|
+
ERROR = 0,
|
|
7
|
+
WARN = 1,
|
|
8
|
+
INFO = 2,
|
|
9
|
+
DEBUG = 3,
|
|
10
|
+
TRACE = 4
|
|
11
|
+
}
|
|
12
|
+
export interface DebugConfig {
|
|
13
|
+
level: LogLevel;
|
|
14
|
+
enableTimestamps: boolean;
|
|
15
|
+
enablePerformanceMetrics: boolean;
|
|
16
|
+
enableRequestLogging: boolean;
|
|
17
|
+
enableNetworkMetrics: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_DEBUG_CONFIG: DebugConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Configure debug logging
|
|
22
|
+
*/
|
|
23
|
+
export declare function configureDebugLogging(config: Partial<DebugConfig>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Performance metrics tracker
|
|
26
|
+
*/
|
|
27
|
+
export declare class PerformanceTracker {
|
|
28
|
+
private operationName;
|
|
29
|
+
private startTime;
|
|
30
|
+
private markers;
|
|
31
|
+
constructor(operationName: string);
|
|
32
|
+
mark(label: string): void;
|
|
33
|
+
end(success?: boolean): number;
|
|
34
|
+
private log;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Network metrics collector
|
|
38
|
+
*/
|
|
39
|
+
export interface NetworkMetrics {
|
|
40
|
+
requestCount: number;
|
|
41
|
+
successCount: number;
|
|
42
|
+
failureCount: number;
|
|
43
|
+
averageLatency: number;
|
|
44
|
+
lastError?: string;
|
|
45
|
+
startTime: number;
|
|
46
|
+
}
|
|
47
|
+
declare class NetworkMetricsCollector {
|
|
48
|
+
private metrics;
|
|
49
|
+
getMetrics(operation: string): NetworkMetrics;
|
|
50
|
+
recordRequest(operation: string, success: boolean, latency: number, error?: string): void;
|
|
51
|
+
printSummary(): void;
|
|
52
|
+
}
|
|
53
|
+
export declare const networkMetrics: NetworkMetricsCollector;
|
|
54
|
+
/**
|
|
55
|
+
* Debug logging functions
|
|
56
|
+
*/
|
|
57
|
+
export declare function debugError(component: string, message: string, metadata?: any): void;
|
|
58
|
+
export declare function debugWarn(component: string, message: string, metadata?: any): void;
|
|
59
|
+
export declare function debugInfo(component: string, message: string, metadata?: any): void;
|
|
60
|
+
export declare function debugLog(component: string, message: string, metadata?: any): void;
|
|
61
|
+
export declare function debugTrace(component: string, message: string, metadata?: any): void;
|
|
62
|
+
/**
|
|
63
|
+
* Request/Response logger for LIT Protocol operations
|
|
64
|
+
*/
|
|
65
|
+
export declare function logRequest(component: string, operation: string, params: any): void;
|
|
66
|
+
export declare function logResponse(component: string, operation: string, response: any, duration: number): void;
|
|
67
|
+
export declare function logError(component: string, operation: string, error: any, duration?: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Network connection logger
|
|
70
|
+
*/
|
|
71
|
+
export declare function logConnectionAttempt(network: string, attempt: number, maxAttempts: number): void;
|
|
72
|
+
export declare function logConnectionSuccess(network: string, latency: number): void;
|
|
73
|
+
export declare function logConnectionFailure(network: string, error: string, attempt: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* PKP operation logger
|
|
76
|
+
*/
|
|
77
|
+
export declare function logPkpOperation(operation: string, pkpId?: string, details?: any): void;
|
|
78
|
+
/**
|
|
79
|
+
* Session signature logger
|
|
80
|
+
*/
|
|
81
|
+
export declare function logSessionSignatures(count: number, expiration: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* LIT Action execution logger
|
|
84
|
+
*/
|
|
85
|
+
export declare function logLitActionExecution(cid: string, params: any): void;
|
|
86
|
+
export declare function logLitActionResult(cid: string, success: boolean, duration: number, result?: any): void;
|
|
87
|
+
/**
|
|
88
|
+
* Test lifecycle logger
|
|
89
|
+
*/
|
|
90
|
+
export declare function logTestStart(testName: string): PerformanceTracker;
|
|
91
|
+
export declare function logTestEnd(testName: string, success: boolean, duration: number): void;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=debug-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-logger.d.ts","sourceRoot":"","sources":["../../../pkg-src/utils/chunks/debug-logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,KAAK,IAAI;CACV;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,QAAQ,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wBAAwB,EAAE,OAAO,CAAC;IAClC,oBAAoB,EAAE,OAAO,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,oBAAoB,EAAE,WAMlC,CAAC;AAIF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAExE;AAkBD;;GAEG;AACH,qBAAa,kBAAkB;IAIjB,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAkC;gBAE7B,aA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