@gvnrdao/dh-sdk 0.0.214 → 0.0.216

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.
Files changed (3) hide show
  1. package/dist/index.js +806 -880
  2. package/dist/index.mjs +806 -880
  3. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -12685,93 +12685,504 @@ var require_elliptic = __commonJS({
12685
12685
  }
12686
12686
  });
12687
12687
 
12688
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/pkp-info.i.js
12689
- var require_pkp_info_i = __commonJS({
12690
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/pkp-info.i.js"(exports) {
12691
- "use strict";
12692
- Object.defineProperty(exports, "__esModule", { value: true });
12693
- }
12694
- });
12695
-
12696
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js
12697
- var require_lit_action_config_i = __commonJS({
12698
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-config.i.js"(exports) {
12699
- "use strict";
12700
- Object.defineProperty(exports, "__esModule", { value: true });
12701
- }
12702
- });
12703
-
12704
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js
12705
- var require_diamond_hands_lit_actions_i = __commonJS({
12706
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.js"(exports) {
12707
- "use strict";
12708
- Object.defineProperty(exports, "__esModule", { value: true });
12709
- }
12710
- });
12711
-
12712
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js
12713
- var require_lit_action_registry_i = __commonJS({
12714
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/chunks/lit-action-registry.i.js"(exports) {
12715
- "use strict";
12716
- Object.defineProperty(exports, "__esModule", { value: true });
12717
- }
12718
- });
12719
-
12720
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js
12721
- var require_interfaces = __commonJS({
12722
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/interfaces/index.js"(exports) {
12688
+ // ../lit-actions/pkg-dist/pkg-src/index.js
12689
+ var require_pkg_src = __commonJS({
12690
+ "../lit-actions/pkg-dist/pkg-src/index.js"(exports, module2) {
12723
12691
  "use strict";
12724
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
12725
- if (k2 === void 0)
12726
- k2 = k;
12727
- var desc = Object.getOwnPropertyDescriptor(m, k);
12728
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12729
- desc = { enumerable: true, get: function() {
12730
- return m[k];
12731
- } };
12732
- }
12733
- Object.defineProperty(o, k2, desc);
12734
- } : function(o, m, k, k2) {
12735
- if (k2 === void 0)
12736
- k2 = k;
12737
- o[k2] = m[k];
12692
+ var __defProp2 = Object.defineProperty;
12693
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
12694
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
12695
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
12696
+ var __esm2 = (fn, res) => function __init() {
12697
+ return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
12698
+ };
12699
+ var __export2 = (target, all) => {
12700
+ for (var name in all)
12701
+ __defProp2(target, name, { get: all[name], enumerable: true });
12702
+ };
12703
+ var __copyProps2 = (to, from, except, desc) => {
12704
+ if (from && typeof from === "object" || typeof from === "function") {
12705
+ for (let key2 of __getOwnPropNames2(from))
12706
+ if (!__hasOwnProp2.call(to, key2) && key2 !== except)
12707
+ __defProp2(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc2(from, key2)) || desc.enumerable });
12708
+ }
12709
+ return to;
12710
+ };
12711
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
12712
+ function configureDebugLogging(config) {
12713
+ debugConfig = { ...debugConfig, ...config };
12714
+ }
12715
+ function getTimestamp() {
12716
+ return (/* @__PURE__ */ new Date()).toISOString();
12717
+ }
12718
+ function formatMessage(level, component, message, metadata) {
12719
+ const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
12720
+ const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
12721
+ return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
12722
+ }
12723
+ function debugError(component, message, metadata) {
12724
+ if (debugConfig.level >= 0) {
12725
+ console.error(formatMessage("ERROR", component, message, metadata));
12726
+ }
12727
+ }
12728
+ function debugWarn(component, message, metadata) {
12729
+ if (debugConfig.level >= 1) {
12730
+ console.warn(formatMessage("WARN", component, message, metadata));
12731
+ }
12732
+ }
12733
+ function debugInfo(component, message, metadata) {
12734
+ if (debugConfig.level >= 2) {
12735
+ console.log(formatMessage("INFO", component, message, metadata));
12736
+ }
12737
+ }
12738
+ function debugLog(component, message, metadata) {
12739
+ if (debugConfig.level >= 3) {
12740
+ console.log(formatMessage("DEBUG", component, message, metadata));
12741
+ }
12742
+ }
12743
+ function debugTrace(component, message, metadata) {
12744
+ if (debugConfig.level >= 4) {
12745
+ console.log(formatMessage("TRACE", component, message, metadata));
12746
+ }
12747
+ }
12748
+ function logRequest(component, operation, params) {
12749
+ if (!debugConfig.enableRequestLogging)
12750
+ return;
12751
+ debugLog(component, `\u{1F504} Request: ${operation}`, {
12752
+ operation,
12753
+ params: JSON.stringify(params, null, 2)
12754
+ });
12755
+ }
12756
+ function logResponse(component, operation, response, duration) {
12757
+ if (!debugConfig.enableRequestLogging)
12758
+ return;
12759
+ debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
12760
+ operation,
12761
+ duration,
12762
+ response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
12763
+ });
12764
+ }
12765
+ function logError(component, operation, error, duration) {
12766
+ const durationStr = duration ? ` (${duration}ms)` : "";
12767
+ debugError(component, `\u274C Error: ${operation}${durationStr}`, {
12768
+ operation,
12769
+ duration,
12770
+ error: error?.message || error?.toString() || "Unknown error",
12771
+ stack: error?.stack
12772
+ });
12773
+ }
12774
+ function logConnectionAttempt(network, attempt, maxAttempts) {
12775
+ debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
12776
+ }
12777
+ function logConnectionSuccess(network, latency) {
12778
+ debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
12779
+ networkMetrics.recordRequest(`connection-${network}`, true, latency);
12780
+ }
12781
+ function logConnectionFailure(network, error, attempt) {
12782
+ debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
12783
+ networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
12784
+ }
12785
+ function logPkpOperation(operation, pkpId, details) {
12786
+ const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
12787
+ debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
12788
+ }
12789
+ function logSessionSignatures(count, expiration) {
12790
+ debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
12791
+ }
12792
+ function logLitActionExecution(cid, params) {
12793
+ debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
12794
+ cid,
12795
+ params
12796
+ });
12797
+ }
12798
+ function logLitActionResult(cid, success2, duration, result) {
12799
+ const status = success2 ? "\u2705" : "\u274C";
12800
+ debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
12801
+ cid,
12802
+ success: success2,
12803
+ duration,
12804
+ result: success2 && result ? JSON.stringify(result, null, 2) : void 0
12805
+ });
12806
+ }
12807
+ function logTestStart(testName) {
12808
+ debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
12809
+ return new PerformanceTracker(testName);
12810
+ }
12811
+ function logTestEnd(testName, success2, duration) {
12812
+ const status = success2 ? "\u2705" : "\u274C";
12813
+ debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
12814
+ networkMetrics.printSummary();
12815
+ }
12816
+ var LogLevel2;
12817
+ var DEFAULT_DEBUG_CONFIG;
12818
+ var debugConfig;
12819
+ var PerformanceTracker;
12820
+ var NetworkMetricsCollector;
12821
+ var networkMetrics;
12822
+ var init_debug_logger = __esm2({
12823
+ "pkg-src/utils/chunks/debug-logger.ts"() {
12824
+ "use strict";
12825
+ LogLevel2 = /* @__PURE__ */ ((LogLevel22) => {
12826
+ LogLevel22[LogLevel22["ERROR"] = 0] = "ERROR";
12827
+ LogLevel22[LogLevel22["WARN"] = 1] = "WARN";
12828
+ LogLevel22[LogLevel22["INFO"] = 2] = "INFO";
12829
+ LogLevel22[LogLevel22["DEBUG"] = 3] = "DEBUG";
12830
+ LogLevel22[LogLevel22["TRACE"] = 4] = "TRACE";
12831
+ return LogLevel22;
12832
+ })(LogLevel2 || {});
12833
+ DEFAULT_DEBUG_CONFIG = {
12834
+ level: 2,
12835
+ enableTimestamps: true,
12836
+ enablePerformanceMetrics: true,
12837
+ enableRequestLogging: true,
12838
+ enableNetworkMetrics: true
12839
+ };
12840
+ debugConfig = { ...DEFAULT_DEBUG_CONFIG };
12841
+ PerformanceTracker = class {
12842
+ constructor(operationName) {
12843
+ this.operationName = operationName;
12844
+ this.markers = /* @__PURE__ */ new Map();
12845
+ this.startTime = Date.now();
12846
+ this.log("PERF", `Started: ${operationName}`);
12847
+ }
12848
+ mark(label) {
12849
+ const elapsed = Date.now() - this.startTime;
12850
+ this.markers.set(label, elapsed);
12851
+ this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
12852
+ }
12853
+ end(success2 = true) {
12854
+ const totalTime = Date.now() - this.startTime;
12855
+ const status = success2 ? "SUCCESS" : "FAILED";
12856
+ this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
12857
+ if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
12858
+ console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
12859
+ for (const [label, time] of this.markers) {
12860
+ console.log(` ${label}: ${time}ms`);
12861
+ }
12862
+ console.log(` Total: ${totalTime}ms`);
12863
+ }
12864
+ return totalTime;
12865
+ }
12866
+ log(level, message) {
12867
+ if (debugConfig.enablePerformanceMetrics) {
12868
+ console.log(formatMessage(level, "PERFORMANCE", message));
12869
+ }
12870
+ }
12871
+ };
12872
+ NetworkMetricsCollector = class {
12873
+ constructor() {
12874
+ this.metrics = /* @__PURE__ */ new Map();
12875
+ }
12876
+ getMetrics(operation) {
12877
+ if (!this.metrics.has(operation)) {
12878
+ this.metrics.set(operation, {
12879
+ requestCount: 0,
12880
+ successCount: 0,
12881
+ failureCount: 0,
12882
+ averageLatency: 0,
12883
+ startTime: Date.now()
12884
+ });
12885
+ }
12886
+ return this.metrics.get(operation);
12887
+ }
12888
+ recordRequest(operation, success2, latency, error) {
12889
+ const metrics = this.getMetrics(operation);
12890
+ metrics.requestCount++;
12891
+ if (success2) {
12892
+ metrics.successCount++;
12893
+ metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
12894
+ } else {
12895
+ metrics.failureCount++;
12896
+ if (error)
12897
+ metrics.lastError = error;
12898
+ }
12899
+ if (debugConfig.enableNetworkMetrics) {
12900
+ const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
12901
+ debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
12902
+ }
12903
+ }
12904
+ printSummary() {
12905
+ if (!debugConfig.enableNetworkMetrics)
12906
+ return;
12907
+ console.log("\n\u{1F4C8} Network Metrics Summary:");
12908
+ for (const [operation, metrics] of this.metrics) {
12909
+ const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
12910
+ const runtime = Date.now() - metrics.startTime;
12911
+ console.log(` ${operation}:`);
12912
+ console.log(` Requests: ${metrics.requestCount}`);
12913
+ console.log(` Success Rate: ${successRate}%`);
12914
+ console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
12915
+ console.log(` Runtime: ${runtime}ms`);
12916
+ if (metrics.lastError) {
12917
+ console.log(` Last Error: ${metrics.lastError}`);
12918
+ }
12919
+ }
12920
+ }
12921
+ };
12922
+ networkMetrics = new NetworkMetricsCollector();
12923
+ }
12738
12924
  });
12739
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
12740
- for (var p in m)
12741
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
12742
- __createBinding(exports2, m, p);
12743
- };
12744
- Object.defineProperty(exports, "__esModule", { value: true });
12745
- __exportStar(require_pkp_info_i(), exports);
12746
- __exportStar(require_lit_action_config_i(), exports);
12747
- __exportStar(require_diamond_hands_lit_actions_i(), exports);
12748
- __exportStar(require_lit_action_registry_i(), exports);
12749
- }
12750
- });
12751
-
12752
- // node_modules/base-x/src/cjs/index.cjs
12753
- var require_cjs = __commonJS({
12754
- "node_modules/base-x/src/cjs/index.cjs"(exports) {
12755
- "use strict";
12756
- Object.defineProperty(exports, "__esModule", { value: true });
12757
- function base2(ALPHABET) {
12758
- if (ALPHABET.length >= 255) {
12925
+ var session_signature_cache_exports = {};
12926
+ __export2(session_signature_cache_exports, {
12927
+ DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
12928
+ clearSessionSignatureCache: () => clearSessionSignatureCache,
12929
+ configureSessionSignatureCache: () => configureSessionSignatureCache,
12930
+ generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
12931
+ getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
12932
+ sessionSignatureCache: () => sessionSignatureCache
12933
+ });
12934
+ async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
12935
+ const cached = sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
12936
+ if (cached) {
12937
+ return cached;
12938
+ }
12939
+ debugInfo("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
12940
+ const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
12941
+ const expiration = new Date(sessionConfig.expiration);
12942
+ sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
12943
+ const sigCount = Object.keys(sessionSigs).length;
12944
+ debugInfo("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
12945
+ return sessionSigs;
12946
+ }
12947
+ function configureSessionSignatureCache(config) {
12948
+ Object.assign(sessionSignatureCache["config"], config);
12949
+ }
12950
+ function clearSessionSignatureCache() {
12951
+ sessionSignatureCache.clear();
12952
+ }
12953
+ function getSessionSignatureCacheStats() {
12954
+ return sessionSignatureCache.getStats();
12955
+ }
12956
+ var DEFAULT_CACHE_CONFIG;
12957
+ var SessionSignatureCache;
12958
+ var sessionSignatureCache;
12959
+ var init_session_signature_cache = __esm2({
12960
+ "pkg-src/utils/chunks/session-signature-cache.ts"() {
12961
+ "use strict";
12962
+ init_debug_logger();
12963
+ DEFAULT_CACHE_CONFIG = {
12964
+ maxEntries: 50,
12965
+ bufferTimeMs: 6e4,
12966
+ // 1 minute buffer before expiration
12967
+ enableLogging: true
12968
+ };
12969
+ SessionSignatureCache = class {
12970
+ constructor(config = {}) {
12971
+ this.cache = /* @__PURE__ */ new Map();
12972
+ this.config = { ...DEFAULT_CACHE_CONFIG, ...config };
12973
+ }
12974
+ /**
12975
+ * Generate cache key from PKP and context
12976
+ */
12977
+ generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
12978
+ return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
12979
+ }
12980
+ /**
12981
+ * Check if cache entry is still valid
12982
+ */
12983
+ isEntryValid(entry) {
12984
+ const now2 = /* @__PURE__ */ new Date();
12985
+ const expirationWithBuffer = new Date(
12986
+ entry.expiration.getTime() - this.config.bufferTimeMs
12987
+ );
12988
+ return now2 < expirationWithBuffer;
12989
+ }
12990
+ /**
12991
+ * Clean expired entries from cache
12992
+ */
12993
+ cleanExpiredEntries() {
12994
+ const now2 = /* @__PURE__ */ new Date();
12995
+ let cleanedCount = 0;
12996
+ for (const [key2, entry] of this.cache.entries()) {
12997
+ if (now2 >= entry.expiration) {
12998
+ this.cache.delete(key2);
12999
+ cleanedCount++;
13000
+ }
13001
+ }
13002
+ if (cleanedCount > 0 && this.config.enableLogging) {
13003
+ debugInfo("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
13004
+ }
13005
+ }
13006
+ /**
13007
+ * Enforce cache size limits
13008
+ */
13009
+ enforceCacheSize() {
13010
+ if (this.cache.size <= this.config.maxEntries) {
13011
+ return;
13012
+ }
13013
+ const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
13014
+ const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
13015
+ for (const [key2] of toRemove) {
13016
+ this.cache.delete(key2);
13017
+ }
13018
+ if (this.config.enableLogging) {
13019
+ debugInfo("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
13020
+ }
13021
+ }
13022
+ /**
13023
+ * Get cached session signatures if valid
13024
+ */
13025
+ get(pkpTokenId, litActionCid, signerAddress, network) {
13026
+ this.cleanExpiredEntries();
13027
+ const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
13028
+ const entry = this.cache.get(cacheKey);
13029
+ if (!entry) {
13030
+ if (this.config.enableLogging) {
13031
+ debugLog("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
13032
+ }
13033
+ return null;
13034
+ }
13035
+ if (!this.isEntryValid(entry)) {
13036
+ this.cache.delete(cacheKey);
13037
+ if (this.config.enableLogging) {
13038
+ debugWarn("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
13039
+ }
13040
+ return null;
13041
+ }
13042
+ if (this.config.enableLogging) {
13043
+ const timeUntilExpiry = entry.expiration.getTime() - Date.now();
13044
+ debugInfo("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
13045
+ }
13046
+ return entry.sessionSigs;
13047
+ }
13048
+ /**
13049
+ * Cache session signatures
13050
+ */
13051
+ set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
13052
+ const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
13053
+ const entry = {
13054
+ sessionSigs,
13055
+ expiration,
13056
+ pkpTokenId,
13057
+ litActionCid,
13058
+ signerAddress,
13059
+ network,
13060
+ createdAt: /* @__PURE__ */ new Date()
13061
+ };
13062
+ this.cache.set(cacheKey, entry);
13063
+ if (this.config.enableLogging) {
13064
+ const timeUntilExpiry = expiration.getTime() - Date.now();
13065
+ debugInfo("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
13066
+ }
13067
+ this.enforceCacheSize();
13068
+ }
13069
+ /**
13070
+ * Clear all cached session signatures
13071
+ */
13072
+ clear() {
13073
+ const size = this.cache.size;
13074
+ this.cache.clear();
13075
+ if (this.config.enableLogging) {
13076
+ debugInfo("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
13077
+ }
13078
+ }
13079
+ /**
13080
+ * Get cache statistics
13081
+ */
13082
+ getStats() {
13083
+ this.cleanExpiredEntries();
13084
+ return {
13085
+ size: this.cache.size,
13086
+ maxEntries: this.config.maxEntries,
13087
+ utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
13088
+ };
13089
+ }
13090
+ /**
13091
+ * Remove specific cache entry
13092
+ */
13093
+ delete(pkpTokenId, litActionCid, signerAddress, network) {
13094
+ const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
13095
+ const deleted = this.cache.delete(cacheKey);
13096
+ if (deleted && this.config.enableLogging) {
13097
+ debugInfo("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
13098
+ }
13099
+ return deleted;
13100
+ }
13101
+ };
13102
+ sessionSignatureCache = new SessionSignatureCache();
13103
+ }
13104
+ });
13105
+ var index_exports = {};
13106
+ __export2(index_exports, {
13107
+ CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
13108
+ DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
13109
+ DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
13110
+ DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
13111
+ DH_LIT_ACTIONS_CHIPOTLE: () => DH_LIT_ACTIONS_CHIPOTLE3,
13112
+ ErrorCategory: () => ErrorCategory2,
13113
+ LogLevel: () => LogLevel2,
13114
+ NETWORK_TIMEOUTS: () => NETWORK_TIMEOUTS,
13115
+ PerformanceTracker: () => PerformanceTracker,
13116
+ RetryStrategy: () => RetryStrategy,
13117
+ analyzeError: () => analyzeError,
13118
+ calculateDelay: () => calculateDelay,
13119
+ cidToHex: () => cidToHex,
13120
+ classifyError: () => classifyError,
13121
+ clearSessionSignatureCache: () => clearSessionSignatureCache,
13122
+ configureDebugLogging: () => configureDebugLogging,
13123
+ configureSessionSignatureCache: () => configureSessionSignatureCache,
13124
+ connectLitContracts: () => connectLitContracts,
13125
+ connectLitNodeClient: () => connectLitNodeClient,
13126
+ createErrorReport: () => createErrorReport,
13127
+ debugError: () => debugError,
13128
+ debugInfo: () => debugInfo,
13129
+ debugLog: () => debugLog,
13130
+ debugTrace: () => debugTrace,
13131
+ debugWarn: () => debugWarn,
13132
+ executeLitAction: () => executeLitAction,
13133
+ executePkpOperation: () => executePkpOperation,
13134
+ generateSessionSignatures: () => generateSessionSignatures,
13135
+ generateSessionSignaturesWithCache: () => generateSessionSignaturesWithCache,
13136
+ getDeployedActions: () => getDeployedActions,
13137
+ getDeploymentsForNetwork: () => getDeploymentsForNetwork,
13138
+ getLitActionCID: () => getLitActionCID,
13139
+ getLitActionConfig: () => getLitActionConfig,
13140
+ getNetworkTimeouts: () => getNetworkTimeouts,
13141
+ getPKPValidatorSetup: () => getPKPValidatorSetup,
13142
+ getRetryConfigFromClassification: () => getRetryConfigFromClassification,
13143
+ getSessionSignatureCacheStats: () => getSessionSignatureCacheStats,
13144
+ isLitActionDeployed: () => isLitActionDeployed,
13145
+ isRetryableError: () => isRetryableError,
13146
+ litProtocolErrors: () => litProtocolErrors,
13147
+ logConnectionAttempt: () => logConnectionAttempt,
13148
+ logConnectionFailure: () => logConnectionFailure,
13149
+ logConnectionSuccess: () => logConnectionSuccess,
13150
+ logError: () => logError,
13151
+ logLitActionExecution: () => logLitActionExecution,
13152
+ logLitActionResult: () => logLitActionResult,
13153
+ logPkpOperation: () => logPkpOperation,
13154
+ logRequest: () => logRequest,
13155
+ logResponse: () => logResponse,
13156
+ logSessionSignatures: () => logSessionSignatures,
13157
+ logTestEnd: () => logTestEnd,
13158
+ logTestStart: () => logTestStart,
13159
+ networkMetrics: () => networkMetrics,
13160
+ sessionSignatureCache: () => sessionSignatureCache,
13161
+ sleep: () => sleep,
13162
+ validateDeployedActions: () => validateDeployedActions,
13163
+ validateLitNodeConnection: () => validateLitNodeConnection,
13164
+ validateLitNodeReadiness: () => validateLitNodeReadiness,
13165
+ withRetry: () => withRetry
13166
+ });
13167
+ module2.exports = __toCommonJS2(index_exports);
13168
+ function base2(ALPHABET2) {
13169
+ if (ALPHABET2.length >= 255) {
12759
13170
  throw new TypeError("Alphabet too long");
12760
13171
  }
12761
13172
  const BASE_MAP = new Uint8Array(256);
12762
13173
  for (let j = 0; j < BASE_MAP.length; j++) {
12763
13174
  BASE_MAP[j] = 255;
12764
13175
  }
12765
- for (let i = 0; i < ALPHABET.length; i++) {
12766
- const x = ALPHABET.charAt(i);
13176
+ for (let i = 0; i < ALPHABET2.length; i++) {
13177
+ const x = ALPHABET2.charAt(i);
12767
13178
  const xc = x.charCodeAt(0);
12768
13179
  if (BASE_MAP[xc] !== 255) {
12769
13180
  throw new TypeError(x + " is ambiguous");
12770
13181
  }
12771
13182
  BASE_MAP[xc] = i;
12772
13183
  }
12773
- const BASE = ALPHABET.length;
12774
- const LEADER = ALPHABET.charAt(0);
13184
+ const BASE = ALPHABET2.length;
13185
+ const LEADER = ALPHABET2.charAt(0);
12775
13186
  const FACTOR = Math.log(BASE) / Math.log(256);
12776
13187
  const iFACTOR = Math.log(256) / Math.log(BASE);
12777
13188
  function encode4(source) {
@@ -12817,7 +13228,7 @@ var require_cjs = __commonJS({
12817
13228
  }
12818
13229
  let str = LEADER.repeat(zeroes);
12819
13230
  for (; it2 < size; ++it2) {
12820
- str += ALPHABET.charAt(b58[it2]);
13231
+ str += ALPHABET2.charAt(b58[it2]);
12821
13232
  }
12822
13233
  return str;
12823
13234
  }
@@ -12882,38 +13293,13 @@ var require_cjs = __commonJS({
12882
13293
  decode: decode3
12883
13294
  };
12884
13295
  }
12885
- exports.default = base2;
12886
- }
12887
- });
12888
-
12889
- // node_modules/bs58/src/cjs/index.cjs
12890
- var require_cjs2 = __commonJS({
12891
- "node_modules/bs58/src/cjs/index.cjs"(exports) {
12892
- "use strict";
12893
- var __importDefault = exports && exports.__importDefault || function(mod) {
12894
- return mod && mod.__esModule ? mod : { "default": mod };
12895
- };
12896
- Object.defineProperty(exports, "__esModule", { value: true });
12897
- var base_x_1 = __importDefault(require_cjs());
13296
+ var esm_default = base2;
12898
13297
  var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
12899
- exports.default = (0, base_x_1.default)(ALPHABET);
12900
- }
12901
- });
12902
-
12903
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js
12904
- var require_cid_utils = __commonJS({
12905
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/cid-utils.js"(exports) {
12906
- "use strict";
12907
- var __importDefault = exports && exports.__importDefault || function(mod) {
12908
- return mod && mod.__esModule ? mod : { "default": mod };
12909
- };
12910
- Object.defineProperty(exports, "__esModule", { value: true });
12911
- exports.cidToHex = cidToHex;
12912
- var bs58_1 = __importDefault(require_cjs2());
13298
+ var esm_default2 = esm_default(ALPHABET);
12913
13299
  function cidToHex(cid) {
12914
13300
  try {
12915
13301
  if (cid.startsWith("Qm")) {
12916
- const bytes = bs58_1.default.decode(cid);
13302
+ const bytes = esm_default2.decode(cid);
12917
13303
  return "0x" + Buffer.from(bytes).toString("hex");
12918
13304
  } else if (cid.startsWith("0x")) {
12919
13305
  return cid;
@@ -12927,21 +13313,12 @@ var require_cid_utils = __commonJS({
12927
13313
  throw new Error(`Failed to convert CID ${cid} to hex: ${error instanceof Error ? error.message : String(error)}`);
12928
13314
  }
12929
13315
  }
12930
- }
12931
- });
12932
-
12933
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js
12934
- var require_lit_actions_registry = __commonJS({
12935
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js"(exports) {
12936
- "use strict";
12937
- Object.defineProperty(exports, "__esModule", { value: true });
12938
- exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
12939
- exports.getDeploymentsForNetwork = getDeploymentsForNetwork;
12940
- var cid_utils_1 = require_cid_utils();
12941
- exports.DH_LIT_ACTIONS_CHIPOTLE = {
13316
+ var DH_LIT_ACTIONS_CHIPOTLE3 = {
12942
13317
  authorizationDummy: {
12943
13318
  cid: "QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN",
12944
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN"),
13319
+ authorizedCidHex: cidToHex(
13320
+ "QmXPh5RTReLqjqZDRNhgVKi1TWMJK2vS9QSRPkWPhLBQJN"
13321
+ ),
12945
13322
  name: "Authorization Dummy",
12946
13323
  description: "Production Authorization Dummy",
12947
13324
  version: "1.0.0",
@@ -12952,7 +13329,9 @@ var require_lit_actions_registry = __commonJS({
12952
13329
  },
12953
13330
  authorizationDummyB: {
12954
13331
  cid: "QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua",
12955
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua"),
13332
+ authorizedCidHex: cidToHex(
13333
+ "QmQXTcAU9tr4YAVrzHujEJw9moJgM1o5gnJU2ojcvhigua"
13334
+ ),
12956
13335
  name: "Authorization Dummy B",
12957
13336
  description: "Production Authorization Dummy B",
12958
13337
  version: "1.0.0",
@@ -12963,7 +13342,9 @@ var require_lit_actions_registry = __commonJS({
12963
13342
  },
12964
13343
  pkpValidator: {
12965
13344
  cid: "QmSo9fkRJA5rS2AnkpKyFgE7ADdGRC2mXvcXVUPaSBRxv1",
12966
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmSo9fkRJA5rS2AnkpKyFgE7ADdGRC2mXvcXVUPaSBRxv1"),
13345
+ authorizedCidHex: cidToHex(
13346
+ "QmSo9fkRJA5rS2AnkpKyFgE7ADdGRC2mXvcXVUPaSBRxv1"
13347
+ ),
12967
13348
  name: "Pkp Validator",
12968
13349
  description: "Production Pkp Validator",
12969
13350
  version: "1.0.0",
@@ -12979,7 +13360,9 @@ var require_lit_actions_registry = __commonJS({
12979
13360
  },
12980
13361
  btcTransactionSigner: {
12981
13362
  cid: "QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG",
12982
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG"),
13363
+ authorizedCidHex: cidToHex(
13364
+ "QmYSvuDcn2EPjRoDsPBLK2e3PGYEUHtWAPxwB51s4unkaG"
13365
+ ),
12983
13366
  name: "Btc Transaction Signer",
12984
13367
  description: "Production Btc Transaction Signer",
12985
13368
  version: "1.0.0",
@@ -12990,7 +13373,9 @@ var require_lit_actions_registry = __commonJS({
12990
13373
  },
12991
13374
  ucdMintValidator: {
12992
13375
  cid: "QmRrL2oTyEyAsTNQQDbq7LpMtU6EJJCbmnLGKGJM4ULr1h",
12993
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmRrL2oTyEyAsTNQQDbq7LpMtU6EJJCbmnLGKGJM4ULr1h"),
13376
+ authorizedCidHex: cidToHex(
13377
+ "QmRrL2oTyEyAsTNQQDbq7LpMtU6EJJCbmnLGKGJM4ULr1h"
13378
+ ),
12994
13379
  name: "Ucd Mint Validator",
12995
13380
  description: "Production Ucd Mint Validator",
12996
13381
  version: "1.0.0",
@@ -13006,7 +13391,9 @@ var require_lit_actions_registry = __commonJS({
13006
13391
  },
13007
13392
  processPaymentValidator: {
13008
13393
  cid: "QmR7rT7iG74YeSVoavTSTgBtZqcmCKG3Tf3hmzQ3zTFUb3",
13009
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmR7rT7iG74YeSVoavTSTgBtZqcmCKG3Tf3hmzQ3zTFUb3"),
13394
+ authorizedCidHex: cidToHex(
13395
+ "QmR7rT7iG74YeSVoavTSTgBtZqcmCKG3Tf3hmzQ3zTFUb3"
13396
+ ),
13010
13397
  name: "Process Payment Validator",
13011
13398
  description: "Production Process Payment Validator",
13012
13399
  version: "1.0.0",
@@ -13022,7 +13409,9 @@ var require_lit_actions_registry = __commonJS({
13022
13409
  },
13023
13410
  extendPositionValidator: {
13024
13411
  cid: "QmZGWWnjVcfHzSBQzgXfMmxQJUYXKt9jsCXrCPZXzuPxPv",
13025
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmZGWWnjVcfHzSBQzgXfMmxQJUYXKt9jsCXrCPZXzuPxPv"),
13412
+ authorizedCidHex: cidToHex(
13413
+ "QmZGWWnjVcfHzSBQzgXfMmxQJUYXKt9jsCXrCPZXzuPxPv"
13414
+ ),
13026
13415
  name: "Extend Position Validator",
13027
13416
  description: "Production Extend Position Validator",
13028
13417
  version: "1.0.0",
@@ -13038,7 +13427,9 @@ var require_lit_actions_registry = __commonJS({
13038
13427
  },
13039
13428
  btcWithdrawal: {
13040
13429
  cid: "QmX9HxZsogBTBSurQPnopMtGDQRXtd3HynHxkqgq23u3rm",
13041
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmX9HxZsogBTBSurQPnopMtGDQRXtd3HynHxkqgq23u3rm"),
13430
+ authorizedCidHex: cidToHex(
13431
+ "QmX9HxZsogBTBSurQPnopMtGDQRXtd3HynHxkqgq23u3rm"
13432
+ ),
13042
13433
  name: "Btc Withdrawal",
13043
13434
  description: "Production Btc Withdrawal",
13044
13435
  version: "1.0.0",
@@ -13054,7 +13445,9 @@ var require_lit_actions_registry = __commonJS({
13054
13445
  },
13055
13446
  liquidationValidator: {
13056
13447
  cid: "QmbufZa57vL7k3eeeFs9vy6LPry5XMYjJrYw7wCHzc3TWH",
13057
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmbufZa57vL7k3eeeFs9vy6LPry5XMYjJrYw7wCHzc3TWH"),
13448
+ authorizedCidHex: cidToHex(
13449
+ "QmbufZa57vL7k3eeeFs9vy6LPry5XMYjJrYw7wCHzc3TWH"
13450
+ ),
13058
13451
  name: "Liquidation Validator",
13059
13452
  description: "Production Liquidation Validator",
13060
13453
  version: "1.0.0",
@@ -13070,7 +13463,9 @@ var require_lit_actions_registry = __commonJS({
13070
13463
  },
13071
13464
  priceOracle: {
13072
13465
  cid: "QmXKfK7JJFixFPvm48uwgVVW7s3eoE3sEyFEbZZ3dfNK1e",
13073
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmXKfK7JJFixFPvm48uwgVVW7s3eoE3sEyFEbZZ3dfNK1e"),
13466
+ authorizedCidHex: cidToHex(
13467
+ "QmXKfK7JJFixFPvm48uwgVVW7s3eoE3sEyFEbZZ3dfNK1e"
13468
+ ),
13074
13469
  name: "Price Oracle",
13075
13470
  description: "Production Price Oracle (Chipotle main+getPrivateKey)",
13076
13471
  version: "1.1.0",
@@ -13086,7 +13481,9 @@ var require_lit_actions_registry = __commonJS({
13086
13481
  },
13087
13482
  loanVaultBtcBalance: {
13088
13483
  cid: "QmUdw25GDYMY6gm7nChBxpHtkwtoSEMjf66QWJ1dCikWkt",
13089
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmUdw25GDYMY6gm7nChBxpHtkwtoSEMjf66QWJ1dCikWkt"),
13484
+ authorizedCidHex: cidToHex(
13485
+ "QmUdw25GDYMY6gm7nChBxpHtkwtoSEMjf66QWJ1dCikWkt"
13486
+ ),
13090
13487
  name: "Loan Vault Btc Balance",
13091
13488
  description: "Production Loan Vault Btc Balance",
13092
13489
  version: "1.0.0",
@@ -13102,7 +13499,9 @@ var require_lit_actions_registry = __commonJS({
13102
13499
  },
13103
13500
  adminLiquidationValidator: {
13104
13501
  cid: "QmYBpkLWKZbEBgdZnfFMabszmPYQJsfdVsqwVyJqdrMnP4",
13105
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmYBpkLWKZbEBgdZnfFMabszmPYQJsfdVsqwVyJqdrMnP4"),
13502
+ authorizedCidHex: cidToHex(
13503
+ "QmYBpkLWKZbEBgdZnfFMabszmPYQJsfdVsqwVyJqdrMnP4"
13504
+ ),
13106
13505
  name: "Admin Liquidation Validator",
13107
13506
  description: "Production Admin Liquidation Validator",
13108
13507
  version: "1.0.0",
@@ -13118,7 +13517,9 @@ var require_lit_actions_registry = __commonJS({
13118
13517
  },
13119
13518
  alwaysSigner: {
13120
13519
  cid: "QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs",
13121
- authorizedCidHex: (0, cid_utils_1.cidToHex)("QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs"),
13520
+ authorizedCidHex: cidToHex(
13521
+ "QmXQjybSsdE19Da66to9Hh7X2dLFwpZPhjoqojxbpk7Nvs"
13522
+ ),
13122
13523
  name: "Always Signer",
13123
13524
  description: "Production Always Signer",
13124
13525
  version: "1.0.0",
@@ -13130,336 +13531,80 @@ var require_lit_actions_registry = __commonJS({
13130
13531
  };
13131
13532
  function getDeploymentsForNetwork(network) {
13132
13533
  if (network === "chipotle")
13133
- return exports.DH_LIT_ACTIONS_CHIPOTLE;
13534
+ return DH_LIT_ACTIONS_CHIPOTLE3;
13134
13535
  throw new Error(`Unsupported LIT network: ${network}`);
13135
13536
  }
13136
- exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE;
13137
- }
13138
- });
13139
-
13140
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js
13141
- var require_lit_action_helpers = __commonJS({
13142
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/lit-action-helpers.js"(exports) {
13143
- "use strict";
13144
- Object.defineProperty(exports, "__esModule", { value: true });
13145
- exports.getLitActionCID = getLitActionCID;
13146
- exports.getLitActionConfig = getLitActionConfig;
13147
- exports.isLitActionDeployed = isLitActionDeployed;
13148
- exports.validateDeployedActions = validateDeployedActions;
13149
- exports.getDeployedActions = getDeployedActions;
13150
- var lit_actions_registry_1 = require_lit_actions_registry();
13537
+ var CHIPOTLE_DEPLOYMENTS = DH_LIT_ACTIONS_CHIPOTLE3;
13151
13538
  function getLitActionCID(litNetwork = "chipotle", actionName) {
13152
- const deployments = (0, lit_actions_registry_1.getDeploymentsForNetwork)(litNetwork);
13539
+ const deployments = getDeploymentsForNetwork(litNetwork);
13153
13540
  const action = deployments[actionName];
13154
13541
  if (!action || !action.deployed || !action.cid) {
13155
- throw new Error(`LIT Action '${actionName}' not deployed on network '${litNetwork}'. Check deployment status.`);
13542
+ throw new Error(
13543
+ `LIT Action '${actionName}' not deployed on network '${litNetwork}'. Check deployment status.`
13544
+ );
13156
13545
  }
13157
13546
  return action.cid;
13158
13547
  }
13159
13548
  function getLitActionConfig(actionName, litNetwork = "chipotle") {
13160
- const deployments = (0, lit_actions_registry_1.getDeploymentsForNetwork)(litNetwork);
13549
+ const deployments = getDeploymentsForNetwork(litNetwork);
13161
13550
  const action = deployments[actionName];
13162
13551
  if (!action) {
13163
- throw new Error(`LIT Action '${actionName}' not found in registry for network '${litNetwork}'.`);
13552
+ throw new Error(
13553
+ `LIT Action '${actionName}' not found in registry for network '${litNetwork}'.`
13554
+ );
13164
13555
  }
13165
13556
  return action;
13166
13557
  }
13167
13558
  function isLitActionDeployed(actionName, litNetwork = "chipotle") {
13168
- const deployments = (0, lit_actions_registry_1.getDeploymentsForNetwork)(litNetwork);
13559
+ const deployments = getDeploymentsForNetwork(litNetwork);
13169
13560
  const action = deployments[actionName];
13170
13561
  return !!(action && action.deployed && action.cid);
13171
13562
  }
13172
13563
  function validateDeployedActions(requiredActions, litNetwork = "chipotle") {
13173
- return requiredActions.every((actionName) => isLitActionDeployed(actionName, litNetwork));
13564
+ return requiredActions.every(
13565
+ (actionName) => isLitActionDeployed(actionName, litNetwork)
13566
+ );
13174
13567
  }
13175
13568
  function getDeployedActions(litNetwork = "chipotle") {
13176
- const deployments = (0, lit_actions_registry_1.getDeploymentsForNetwork)(litNetwork);
13177
- return Object.values(deployments).filter((action) => action && action.deployed);
13569
+ const deployments = getDeploymentsForNetwork(litNetwork);
13570
+ return Object.values(deployments).filter(
13571
+ (action) => action && action.deployed
13572
+ );
13178
13573
  }
13179
- }
13180
- });
13181
-
13182
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js
13183
- var require_pkp_setup = __commonJS({
13184
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/pkp-setup.js"(exports) {
13185
- "use strict";
13186
- Object.defineProperty(exports, "__esModule", { value: true });
13187
- exports.getPKPValidatorSetup = getPKPValidatorSetup;
13188
- var lit_actions_registry_1 = require_lit_actions_registry();
13189
13574
  function getPKPValidatorSetup(litNetwork = "chipotle") {
13190
- const deployments = (0, lit_actions_registry_1.getDeploymentsForNetwork)(litNetwork);
13575
+ const deployments = getDeploymentsForNetwork(litNetwork);
13191
13576
  const litAction = deployments.pkpValidator;
13192
13577
  if (!litAction || !litAction.pkp) {
13193
- throw new Error(`PKP validator setup is not available for litNetwork='${litNetwork}'. Ensure the pkpValidator action (with pkp attached) is defined in the registry.`);
13578
+ throw new Error(
13579
+ `PKP validator setup is not available for litNetwork='${litNetwork}'. Ensure the pkpValidator action (with pkp attached) is defined in the registry.`
13580
+ );
13194
13581
  }
13195
13582
  return {
13196
13583
  litAction,
13197
13584
  pkp: litAction.pkp
13198
13585
  };
13199
13586
  }
13200
- }
13201
- });
13202
-
13203
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/debug-logger.js
13204
- var require_debug_logger = __commonJS({
13205
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/debug-logger.js"(exports) {
13206
- "use strict";
13207
- Object.defineProperty(exports, "__esModule", { value: true });
13208
- exports.networkMetrics = exports.PerformanceTracker = exports.DEFAULT_DEBUG_CONFIG = exports.LogLevel = void 0;
13209
- exports.configureDebugLogging = configureDebugLogging;
13210
- exports.debugError = debugError;
13211
- exports.debugWarn = debugWarn;
13212
- exports.debugInfo = debugInfo;
13213
- exports.debugLog = debugLog;
13214
- exports.debugTrace = debugTrace;
13215
- exports.logRequest = logRequest;
13216
- exports.logResponse = logResponse;
13217
- exports.logError = logError;
13218
- exports.logConnectionAttempt = logConnectionAttempt;
13219
- exports.logConnectionSuccess = logConnectionSuccess;
13220
- exports.logConnectionFailure = logConnectionFailure;
13221
- exports.logPkpOperation = logPkpOperation;
13222
- exports.logSessionSignatures = logSessionSignatures;
13223
- exports.logLitActionExecution = logLitActionExecution;
13224
- exports.logLitActionResult = logLitActionResult;
13225
- exports.logTestStart = logTestStart;
13226
- exports.logTestEnd = logTestEnd;
13227
- var LogLevel2;
13228
- (function(LogLevel3) {
13229
- LogLevel3[LogLevel3["ERROR"] = 0] = "ERROR";
13230
- LogLevel3[LogLevel3["WARN"] = 1] = "WARN";
13231
- LogLevel3[LogLevel3["INFO"] = 2] = "INFO";
13232
- LogLevel3[LogLevel3["DEBUG"] = 3] = "DEBUG";
13233
- LogLevel3[LogLevel3["TRACE"] = 4] = "TRACE";
13234
- })(LogLevel2 || (exports.LogLevel = LogLevel2 = {}));
13235
- exports.DEFAULT_DEBUG_CONFIG = {
13236
- level: LogLevel2.INFO,
13237
- enableTimestamps: true,
13238
- enablePerformanceMetrics: true,
13239
- enableRequestLogging: true,
13240
- enableNetworkMetrics: true
13241
- };
13242
- var debugConfig = { ...exports.DEFAULT_DEBUG_CONFIG };
13243
- function configureDebugLogging(config) {
13244
- debugConfig = { ...debugConfig, ...config };
13245
- }
13246
- function getTimestamp() {
13247
- return (/* @__PURE__ */ new Date()).toISOString();
13248
- }
13249
- function formatMessage(level, component, message, metadata) {
13250
- const timestamp = debugConfig.enableTimestamps ? `[${getTimestamp()}] ` : "";
13251
- const metadataStr = metadata ? ` ${JSON.stringify(metadata)}` : "";
13252
- return `${timestamp}[${level}] [${component}] ${message}${metadataStr}`;
13253
- }
13254
- var PerformanceTracker = class {
13255
- constructor(operationName) {
13256
- this.operationName = operationName;
13257
- this.markers = /* @__PURE__ */ new Map();
13258
- this.startTime = Date.now();
13259
- this.log("PERF", `Started: ${operationName}`);
13260
- }
13261
- mark(label) {
13262
- const elapsed = Date.now() - this.startTime;
13263
- this.markers.set(label, elapsed);
13264
- this.log("PERF", `${this.operationName} - ${label}: ${elapsed}ms`);
13265
- }
13266
- end(success2 = true) {
13267
- const totalTime = Date.now() - this.startTime;
13268
- const status = success2 ? "SUCCESS" : "FAILED";
13269
- this.log("PERF", `${this.operationName} - ${status}: ${totalTime}ms`);
13270
- if (debugConfig.enablePerformanceMetrics && this.markers.size > 0) {
13271
- console.log(`\u{1F4CA} Performance Breakdown for ${this.operationName}:`);
13272
- for (const [label, time] of this.markers) {
13273
- console.log(` ${label}: ${time}ms`);
13274
- }
13275
- console.log(` Total: ${totalTime}ms`);
13276
- }
13277
- return totalTime;
13278
- }
13279
- log(level, message) {
13280
- if (debugConfig.enablePerformanceMetrics) {
13281
- console.log(formatMessage(level, "PERFORMANCE", message));
13282
- }
13283
- }
13284
- };
13285
- exports.PerformanceTracker = PerformanceTracker;
13286
- var NetworkMetricsCollector = class {
13287
- constructor() {
13288
- this.metrics = /* @__PURE__ */ new Map();
13289
- }
13290
- getMetrics(operation) {
13291
- if (!this.metrics.has(operation)) {
13292
- this.metrics.set(operation, {
13293
- requestCount: 0,
13294
- successCount: 0,
13295
- failureCount: 0,
13296
- averageLatency: 0,
13297
- startTime: Date.now()
13298
- });
13299
- }
13300
- return this.metrics.get(operation);
13301
- }
13302
- recordRequest(operation, success2, latency, error) {
13303
- const metrics = this.getMetrics(operation);
13304
- metrics.requestCount++;
13305
- if (success2) {
13306
- metrics.successCount++;
13307
- metrics.averageLatency = (metrics.averageLatency * (metrics.successCount - 1) + latency) / metrics.successCount;
13308
- } else {
13309
- metrics.failureCount++;
13310
- if (error)
13311
- metrics.lastError = error;
13312
- }
13313
- if (debugConfig.enableNetworkMetrics) {
13314
- const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
13315
- debugLog("NETWORK", `${operation} - Success: ${success2}, Latency: ${latency}ms, Success Rate: ${successRate}%`);
13316
- }
13317
- }
13318
- printSummary() {
13319
- if (!debugConfig.enableNetworkMetrics)
13320
- return;
13321
- console.log("\n\u{1F4C8} Network Metrics Summary:");
13322
- for (const [operation, metrics] of this.metrics) {
13323
- const successRate = (metrics.successCount / metrics.requestCount * 100).toFixed(1);
13324
- const runtime = Date.now() - metrics.startTime;
13325
- console.log(` ${operation}:`);
13326
- console.log(` Requests: ${metrics.requestCount}`);
13327
- console.log(` Success Rate: ${successRate}%`);
13328
- console.log(` Avg Latency: ${metrics.averageLatency.toFixed(0)}ms`);
13329
- console.log(` Runtime: ${runtime}ms`);
13330
- if (metrics.lastError) {
13331
- console.log(` Last Error: ${metrics.lastError}`);
13332
- }
13333
- }
13334
- }
13335
- };
13336
- exports.networkMetrics = new NetworkMetricsCollector();
13337
- function debugError(component, message, metadata) {
13338
- if (debugConfig.level >= LogLevel2.ERROR) {
13339
- console.error(formatMessage("ERROR", component, message, metadata));
13340
- }
13341
- }
13342
- function debugWarn(component, message, metadata) {
13343
- if (debugConfig.level >= LogLevel2.WARN) {
13344
- console.warn(formatMessage("WARN", component, message, metadata));
13345
- }
13346
- }
13347
- function debugInfo(component, message, metadata) {
13348
- if (debugConfig.level >= LogLevel2.INFO) {
13349
- console.log(formatMessage("INFO", component, message, metadata));
13350
- }
13351
- }
13352
- function debugLog(component, message, metadata) {
13353
- if (debugConfig.level >= LogLevel2.DEBUG) {
13354
- console.log(formatMessage("DEBUG", component, message, metadata));
13355
- }
13356
- }
13357
- function debugTrace(component, message, metadata) {
13358
- if (debugConfig.level >= LogLevel2.TRACE) {
13359
- console.log(formatMessage("TRACE", component, message, metadata));
13360
- }
13361
- }
13362
- function logRequest(component, operation, params) {
13363
- if (!debugConfig.enableRequestLogging)
13364
- return;
13365
- debugLog(component, `\u{1F504} Request: ${operation}`, {
13366
- operation,
13367
- params: JSON.stringify(params, null, 2)
13368
- });
13369
- }
13370
- function logResponse(component, operation, response, duration) {
13371
- if (!debugConfig.enableRequestLogging)
13372
- return;
13373
- debugLog(component, `\u2705 Response: ${operation} (${duration}ms)`, {
13374
- operation,
13375
- duration,
13376
- response: typeof response === "object" ? JSON.stringify(response, null, 2) : response
13377
- });
13378
- }
13379
- function logError(component, operation, error, duration) {
13380
- const durationStr = duration ? ` (${duration}ms)` : "";
13381
- debugError(component, `\u274C Error: ${operation}${durationStr}`, {
13382
- operation,
13383
- duration,
13384
- error: error?.message || error?.toString() || "Unknown error",
13385
- stack: error?.stack
13386
- });
13387
- }
13388
- function logConnectionAttempt(network, attempt, maxAttempts) {
13389
- debugInfo("CONNECTION", `\u{1F517} Connecting to ${network} (attempt ${attempt}/${maxAttempts})`);
13390
- }
13391
- function logConnectionSuccess(network, latency) {
13392
- debugInfo("CONNECTION", `\u2705 Connected to ${network} (${latency}ms)`);
13393
- exports.networkMetrics.recordRequest(`connection-${network}`, true, latency);
13394
- }
13395
- function logConnectionFailure(network, error, attempt) {
13396
- debugError("CONNECTION", `\u274C Connection failed to ${network} (attempt ${attempt})`, { error });
13397
- exports.networkMetrics.recordRequest(`connection-${network}`, false, 0, error);
13398
- }
13399
- function logPkpOperation(operation, pkpId, details) {
13400
- const pkpStr = pkpId ? ` (PKP: ${pkpId.slice(0, 8)}...)` : "";
13401
- debugInfo("PKP", `\u{1F511} ${operation}${pkpStr}`, details);
13402
- }
13403
- function logSessionSignatures(count, expiration) {
13404
- debugInfo("SESSION", `\u{1F510} Generated ${count} session signatures (expires: ${expiration})`);
13405
- }
13406
- function logLitActionExecution(cid, params) {
13407
- debugInfo("LIT_ACTION", `\u26A1 Executing LIT Action: ${cid}`, {
13408
- cid,
13409
- params
13410
- });
13411
- }
13412
- function logLitActionResult(cid, success2, duration, result) {
13413
- const status = success2 ? "\u2705" : "\u274C";
13414
- debugInfo("LIT_ACTION", `${status} LIT Action completed: ${cid} (${duration}ms)`, {
13415
- cid,
13416
- success: success2,
13417
- duration,
13418
- result: success2 && result ? JSON.stringify(result, null, 2) : void 0
13419
- });
13420
- }
13421
- function logTestStart(testName) {
13422
- debugInfo("TEST", `\u{1F9EA} Starting test: ${testName}`);
13423
- return new PerformanceTracker(testName);
13424
- }
13425
- function logTestEnd(testName, success2, duration) {
13426
- const status = success2 ? "\u2705" : "\u274C";
13427
- debugInfo("TEST", `${status} Test completed: ${testName} (${duration}ms)`);
13428
- exports.networkMetrics.printSummary();
13429
- }
13430
- }
13431
- });
13432
-
13433
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js
13434
- var require_error_classification = __commonJS({
13435
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/error-classification.js"(exports) {
13436
- "use strict";
13437
- Object.defineProperty(exports, "__esModule", { value: true });
13438
- exports.litProtocolErrors = exports.RetryStrategy = exports.ErrorCategory = void 0;
13439
- exports.classifyError = classifyError;
13440
- exports.getRetryConfigFromClassification = getRetryConfigFromClassification;
13441
- exports.analyzeError = analyzeError;
13442
- exports.createErrorReport = createErrorReport;
13443
- var ErrorCategory2;
13444
- (function(ErrorCategory3) {
13445
- ErrorCategory3["NETWORK"] = "network";
13446
- ErrorCategory3["PROTOCOL"] = "protocol";
13447
- ErrorCategory3["AUTHENTICATION"] = "authentication";
13448
- ErrorCategory3["RESOURCE"] = "resource";
13449
- ErrorCategory3["VALIDATION"] = "validation";
13450
- ErrorCategory3["TIMEOUT"] = "timeout";
13451
- ErrorCategory3["RATE_LIMIT"] = "rate_limit";
13452
- ErrorCategory3["CONFIGURATION"] = "configuration";
13453
- ErrorCategory3["UNKNOWN"] = "unknown";
13454
- })(ErrorCategory2 || (exports.ErrorCategory = ErrorCategory2 = {}));
13455
- var RetryStrategy;
13456
- (function(RetryStrategy2) {
13587
+ init_debug_logger();
13588
+ var ErrorCategory2 = /* @__PURE__ */ ((ErrorCategory22) => {
13589
+ ErrorCategory22["NETWORK"] = "network";
13590
+ ErrorCategory22["PROTOCOL"] = "protocol";
13591
+ ErrorCategory22["AUTHENTICATION"] = "authentication";
13592
+ ErrorCategory22["RESOURCE"] = "resource";
13593
+ ErrorCategory22["VALIDATION"] = "validation";
13594
+ ErrorCategory22["TIMEOUT"] = "timeout";
13595
+ ErrorCategory22["RATE_LIMIT"] = "rate_limit";
13596
+ ErrorCategory22["CONFIGURATION"] = "configuration";
13597
+ ErrorCategory22["UNKNOWN"] = "unknown";
13598
+ return ErrorCategory22;
13599
+ })(ErrorCategory2 || {});
13600
+ var RetryStrategy = /* @__PURE__ */ ((RetryStrategy2) => {
13457
13601
  RetryStrategy2["AGGRESSIVE"] = "aggressive";
13458
13602
  RetryStrategy2["CONSERVATIVE"] = "conservative";
13459
13603
  RetryStrategy2["EXPONENTIAL"] = "exponential";
13460
13604
  RetryStrategy2["LINEAR"] = "linear";
13461
13605
  RetryStrategy2["NONE"] = "none";
13462
- })(RetryStrategy || (exports.RetryStrategy = RetryStrategy = {}));
13606
+ return RetryStrategy2;
13607
+ })(RetryStrategy || {});
13463
13608
  var LIT_ERROR_PATTERNS = {
13464
13609
  // Network and connection errors
13465
13610
  network: [
@@ -13552,31 +13697,46 @@ var require_error_classification = __commonJS({
13552
13697
  ]
13553
13698
  };
13554
13699
  var RETRY_STRATEGIES = {
13555
- [RetryStrategy.AGGRESSIVE]: {
13700
+ [
13701
+ "aggressive"
13702
+ /* AGGRESSIVE */
13703
+ ]: {
13556
13704
  maxAttempts: 5,
13557
13705
  baseDelayMs: 500,
13558
13706
  maxDelayMs: 5e3,
13559
13707
  multiplier: 1.5
13560
13708
  },
13561
- [RetryStrategy.CONSERVATIVE]: {
13709
+ [
13710
+ "conservative"
13711
+ /* CONSERVATIVE */
13712
+ ]: {
13562
13713
  maxAttempts: 3,
13563
13714
  baseDelayMs: 3e3,
13564
13715
  maxDelayMs: 3e4,
13565
13716
  multiplier: 2.5
13566
13717
  },
13567
- [RetryStrategy.EXPONENTIAL]: {
13718
+ [
13719
+ "exponential"
13720
+ /* EXPONENTIAL */
13721
+ ]: {
13568
13722
  maxAttempts: 4,
13569
13723
  baseDelayMs: 1e3,
13570
13724
  maxDelayMs: 15e3,
13571
13725
  multiplier: 2
13572
13726
  },
13573
- [RetryStrategy.LINEAR]: {
13727
+ [
13728
+ "linear"
13729
+ /* LINEAR */
13730
+ ]: {
13574
13731
  maxAttempts: 3,
13575
13732
  baseDelayMs: 2e3,
13576
13733
  maxDelayMs: 1e4,
13577
13734
  multiplier: 1
13578
13735
  },
13579
- [RetryStrategy.NONE]: {
13736
+ [
13737
+ "none"
13738
+ /* NONE */
13739
+ ]: {
13580
13740
  maxAttempts: 1,
13581
13741
  baseDelayMs: 0,
13582
13742
  maxDelayMs: 0,
@@ -13584,11 +13744,17 @@ var require_error_classification = __commonJS({
13584
13744
  }
13585
13745
  };
13586
13746
  var CLASSIFICATION_RULES = {
13587
- [ErrorCategory2.NETWORK]: {
13588
- category: ErrorCategory2.NETWORK,
13589
- retryStrategy: RetryStrategy.AGGRESSIVE,
13747
+ [
13748
+ "network"
13749
+ /* NETWORK */
13750
+ ]: {
13751
+ category: "network",
13752
+ retryStrategy: "aggressive",
13590
13753
  isRetryable: true,
13591
- ...RETRY_STRATEGIES[RetryStrategy.AGGRESSIVE],
13754
+ ...RETRY_STRATEGIES[
13755
+ "aggressive"
13756
+ /* AGGRESSIVE */
13757
+ ],
13592
13758
  description: "Network connectivity or communication error",
13593
13759
  troubleshooting: [
13594
13760
  "Check internet connection",
@@ -13597,11 +13763,17 @@ var require_error_classification = __commonJS({
13597
13763
  "Try connecting to different node endpoints"
13598
13764
  ]
13599
13765
  },
13600
- [ErrorCategory2.PROTOCOL]: {
13601
- category: ErrorCategory2.PROTOCOL,
13602
- retryStrategy: RetryStrategy.CONSERVATIVE,
13766
+ [
13767
+ "protocol"
13768
+ /* PROTOCOL */
13769
+ ]: {
13770
+ category: "protocol",
13771
+ retryStrategy: "conservative",
13603
13772
  isRetryable: true,
13604
- ...RETRY_STRATEGIES[RetryStrategy.CONSERVATIVE],
13773
+ ...RETRY_STRATEGIES[
13774
+ "conservative"
13775
+ /* CONSERVATIVE */
13776
+ ],
13605
13777
  description: "LIT Protocol specific operational error",
13606
13778
  troubleshooting: [
13607
13779
  "Check LIT Protocol network status",
@@ -13610,11 +13782,17 @@ var require_error_classification = __commonJS({
13610
13782
  "Wait for network consensus"
13611
13783
  ]
13612
13784
  },
13613
- [ErrorCategory2.AUTHENTICATION]: {
13614
- category: ErrorCategory2.AUTHENTICATION,
13615
- retryStrategy: RetryStrategy.EXPONENTIAL,
13785
+ [
13786
+ "authentication"
13787
+ /* AUTHENTICATION */
13788
+ ]: {
13789
+ category: "authentication",
13790
+ retryStrategy: "exponential",
13616
13791
  isRetryable: true,
13617
- ...RETRY_STRATEGIES[RetryStrategy.EXPONENTIAL],
13792
+ ...RETRY_STRATEGIES[
13793
+ "exponential"
13794
+ /* EXPONENTIAL */
13795
+ ],
13618
13796
  maxAttempts: 2,
13619
13797
  // Override: limited retries for auth issues
13620
13798
  description: "Authentication or authorization error",
@@ -13625,11 +13803,17 @@ var require_error_classification = __commonJS({
13625
13803
  "Check PKP authorization status"
13626
13804
  ]
13627
13805
  },
13628
- [ErrorCategory2.RESOURCE]: {
13629
- category: ErrorCategory2.RESOURCE,
13630
- retryStrategy: RetryStrategy.LINEAR,
13806
+ [
13807
+ "resource"
13808
+ /* RESOURCE */
13809
+ ]: {
13810
+ category: "resource",
13811
+ retryStrategy: "linear",
13631
13812
  isRetryable: true,
13632
- ...RETRY_STRATEGIES[RetryStrategy.LINEAR],
13813
+ ...RETRY_STRATEGIES[
13814
+ "linear"
13815
+ /* LINEAR */
13816
+ ],
13633
13817
  maxAttempts: 2,
13634
13818
  // Override: limited retries for resource issues
13635
13819
  description: "Resource not found or validation error",
@@ -13640,11 +13824,17 @@ var require_error_classification = __commonJS({
13640
13824
  "Wait for resource propagation"
13641
13825
  ]
13642
13826
  },
13643
- [ErrorCategory2.VALIDATION]: {
13644
- category: ErrorCategory2.VALIDATION,
13645
- retryStrategy: RetryStrategy.NONE,
13827
+ [
13828
+ "validation"
13829
+ /* VALIDATION */
13830
+ ]: {
13831
+ category: "validation",
13832
+ retryStrategy: "none",
13646
13833
  isRetryable: false,
13647
- ...RETRY_STRATEGIES[RetryStrategy.NONE],
13834
+ ...RETRY_STRATEGIES[
13835
+ "none"
13836
+ /* NONE */
13837
+ ],
13648
13838
  description: "Input validation or schema error",
13649
13839
  troubleshooting: [
13650
13840
  "Check input parameters format",
@@ -13653,11 +13843,17 @@ var require_error_classification = __commonJS({
13653
13843
  "Review API documentation"
13654
13844
  ]
13655
13845
  },
13656
- [ErrorCategory2.TIMEOUT]: {
13657
- category: ErrorCategory2.TIMEOUT,
13658
- retryStrategy: RetryStrategy.CONSERVATIVE,
13846
+ [
13847
+ "timeout"
13848
+ /* TIMEOUT */
13849
+ ]: {
13850
+ category: "timeout",
13851
+ retryStrategy: "conservative",
13659
13852
  isRetryable: true,
13660
- ...RETRY_STRATEGIES[RetryStrategy.CONSERVATIVE],
13853
+ ...RETRY_STRATEGIES[
13854
+ "conservative"
13855
+ /* CONSERVATIVE */
13856
+ ],
13661
13857
  description: "Operation timeout error",
13662
13858
  troubleshooting: [
13663
13859
  "Increase timeout values",
@@ -13666,11 +13862,17 @@ var require_error_classification = __commonJS({
13666
13862
  "Split operations into smaller chunks"
13667
13863
  ]
13668
13864
  },
13669
- [ErrorCategory2.RATE_LIMIT]: {
13670
- category: ErrorCategory2.RATE_LIMIT,
13671
- retryStrategy: RetryStrategy.CONSERVATIVE,
13865
+ [
13866
+ "rate_limit"
13867
+ /* RATE_LIMIT */
13868
+ ]: {
13869
+ category: "rate_limit",
13870
+ retryStrategy: "conservative",
13672
13871
  isRetryable: true,
13673
- ...RETRY_STRATEGIES[RetryStrategy.CONSERVATIVE],
13872
+ ...RETRY_STRATEGIES[
13873
+ "conservative"
13874
+ /* CONSERVATIVE */
13875
+ ],
13674
13876
  maxAttempts: 2,
13675
13877
  // Override: limited retries to avoid further rate limiting
13676
13878
  baseDelayMs: 5e3,
@@ -13683,11 +13885,17 @@ var require_error_classification = __commonJS({
13683
13885
  "Wait for quota reset"
13684
13886
  ]
13685
13887
  },
13686
- [ErrorCategory2.CONFIGURATION]: {
13687
- category: ErrorCategory2.CONFIGURATION,
13688
- retryStrategy: RetryStrategy.NONE,
13888
+ [
13889
+ "configuration"
13890
+ /* CONFIGURATION */
13891
+ ]: {
13892
+ category: "configuration",
13893
+ retryStrategy: "none",
13689
13894
  isRetryable: false,
13690
- ...RETRY_STRATEGIES[RetryStrategy.NONE],
13895
+ ...RETRY_STRATEGIES[
13896
+ "none"
13897
+ /* NONE */
13898
+ ],
13691
13899
  description: "Configuration or setup error",
13692
13900
  troubleshooting: [
13693
13901
  "Check environment variables",
@@ -13696,11 +13904,17 @@ var require_error_classification = __commonJS({
13696
13904
  "Check required dependencies"
13697
13905
  ]
13698
13906
  },
13699
- [ErrorCategory2.UNKNOWN]: {
13700
- category: ErrorCategory2.UNKNOWN,
13701
- retryStrategy: RetryStrategy.EXPONENTIAL,
13907
+ [
13908
+ "unknown"
13909
+ /* UNKNOWN */
13910
+ ]: {
13911
+ category: "unknown",
13912
+ retryStrategy: "exponential",
13702
13913
  isRetryable: true,
13703
- ...RETRY_STRATEGIES[RetryStrategy.EXPONENTIAL],
13914
+ ...RETRY_STRATEGIES[
13915
+ "exponential"
13916
+ /* EXPONENTIAL */
13917
+ ],
13704
13918
  maxAttempts: 2,
13705
13919
  // Override: conservative retries for unknown errors
13706
13920
  description: "Unknown or unclassified error",
@@ -13726,7 +13940,10 @@ var require_error_classification = __commonJS({
13726
13940
  }
13727
13941
  }
13728
13942
  }
13729
- const unknownClassification = CLASSIFICATION_RULES[ErrorCategory2.UNKNOWN];
13943
+ const unknownClassification = CLASSIFICATION_RULES[
13944
+ "unknown"
13945
+ /* UNKNOWN */
13946
+ ];
13730
13947
  return {
13731
13948
  ...unknownClassification,
13732
13949
  description: `${unknownClassification.description}: ${errorMessage.slice(0, 100)}`
@@ -13777,258 +13994,17 @@ var require_error_classification = __commonJS({
13777
13994
  }
13778
13995
  return report.join("\n");
13779
13996
  }
13780
- exports.litProtocolErrors = {
13781
- isNetworkError: (error) => classifyError(error).category === ErrorCategory2.NETWORK,
13782
- isProtocolError: (error) => classifyError(error).category === ErrorCategory2.PROTOCOL,
13783
- isAuthenticationError: (error) => classifyError(error).category === ErrorCategory2.AUTHENTICATION,
13784
- isResourceError: (error) => classifyError(error).category === ErrorCategory2.RESOURCE,
13785
- isTimeoutError: (error) => classifyError(error).category === ErrorCategory2.TIMEOUT,
13786
- isRateLimitError: (error) => classifyError(error).category === ErrorCategory2.RATE_LIMIT,
13787
- isConfigurationError: (error) => classifyError(error).category === ErrorCategory2.CONFIGURATION,
13997
+ var litProtocolErrors = {
13998
+ isNetworkError: (error) => classifyError(error).category === "network",
13999
+ isProtocolError: (error) => classifyError(error).category === "protocol",
14000
+ isAuthenticationError: (error) => classifyError(error).category === "authentication",
14001
+ isResourceError: (error) => classifyError(error).category === "resource",
14002
+ isTimeoutError: (error) => classifyError(error).category === "timeout",
14003
+ isRateLimitError: (error) => classifyError(error).category === "rate_limit",
14004
+ isConfigurationError: (error) => classifyError(error).category === "configuration",
13788
14005
  isRetryable: (error) => classifyError(error).isRetryable
13789
14006
  };
13790
- }
13791
- });
13792
-
13793
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js
13794
- var require_session_signature_cache = __commonJS({
13795
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/session-signature-cache.js"(exports) {
13796
- "use strict";
13797
- Object.defineProperty(exports, "__esModule", { value: true });
13798
- exports.sessionSignatureCache = exports.DEFAULT_CACHE_CONFIG = void 0;
13799
- exports.generateSessionSignaturesWithCache = generateSessionSignaturesWithCache;
13800
- exports.configureSessionSignatureCache = configureSessionSignatureCache;
13801
- exports.clearSessionSignatureCache = clearSessionSignatureCache;
13802
- exports.getSessionSignatureCacheStats = getSessionSignatureCacheStats;
13803
- var debug_logger_1 = require_debug_logger();
13804
- exports.DEFAULT_CACHE_CONFIG = {
13805
- maxEntries: 50,
13806
- bufferTimeMs: 6e4,
13807
- // 1 minute buffer before expiration
13808
- enableLogging: true
13809
- };
13810
- var SessionSignatureCache = class {
13811
- constructor(config = {}) {
13812
- this.cache = /* @__PURE__ */ new Map();
13813
- this.config = { ...exports.DEFAULT_CACHE_CONFIG, ...config };
13814
- }
13815
- /**
13816
- * Generate cache key from PKP and context
13817
- */
13818
- generateCacheKey(pkpTokenId, litActionCid, signerAddress, network) {
13819
- return `${signerAddress}-${network}-${pkpTokenId}-${litActionCid}`;
13820
- }
13821
- /**
13822
- * Check if cache entry is still valid
13823
- */
13824
- isEntryValid(entry) {
13825
- const now2 = /* @__PURE__ */ new Date();
13826
- const expirationWithBuffer = new Date(entry.expiration.getTime() - this.config.bufferTimeMs);
13827
- return now2 < expirationWithBuffer;
13828
- }
13829
- /**
13830
- * Clean expired entries from cache
13831
- */
13832
- cleanExpiredEntries() {
13833
- const now2 = /* @__PURE__ */ new Date();
13834
- let cleanedCount = 0;
13835
- for (const [key2, entry] of this.cache.entries()) {
13836
- if (now2 >= entry.expiration) {
13837
- this.cache.delete(key2);
13838
- cleanedCount++;
13839
- }
13840
- }
13841
- if (cleanedCount > 0 && this.config.enableLogging) {
13842
- (0, debug_logger_1.debugInfo)("CACHE", `\u{1F9F9} Cleaned ${cleanedCount} expired session signature entries`);
13843
- }
13844
- }
13845
- /**
13846
- * Enforce cache size limits
13847
- */
13848
- enforceCacheSize() {
13849
- if (this.cache.size <= this.config.maxEntries) {
13850
- return;
13851
- }
13852
- const entries = Array.from(this.cache.entries()).sort(([, a], [, b]) => a.createdAt.getTime() - b.createdAt.getTime());
13853
- const toRemove = entries.slice(0, this.cache.size - this.config.maxEntries);
13854
- for (const [key2] of toRemove) {
13855
- this.cache.delete(key2);
13856
- }
13857
- if (this.config.enableLogging) {
13858
- (0, debug_logger_1.debugInfo)("CACHE", `\u{1F4E6} Removed ${toRemove.length} oldest cache entries to maintain size limit`);
13859
- }
13860
- }
13861
- /**
13862
- * Get cached session signatures if valid
13863
- */
13864
- get(pkpTokenId, litActionCid, signerAddress, network) {
13865
- this.cleanExpiredEntries();
13866
- const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
13867
- const entry = this.cache.get(cacheKey);
13868
- if (!entry) {
13869
- if (this.config.enableLogging) {
13870
- (0, debug_logger_1.debugLog)("CACHE", `\u274C Session signatures cache miss: ${cacheKey}`);
13871
- }
13872
- return null;
13873
- }
13874
- if (!this.isEntryValid(entry)) {
13875
- this.cache.delete(cacheKey);
13876
- if (this.config.enableLogging) {
13877
- (0, debug_logger_1.debugWarn)("CACHE", `\u23F0 Session signatures expired: ${cacheKey}`);
13878
- }
13879
- return null;
13880
- }
13881
- if (this.config.enableLogging) {
13882
- const timeUntilExpiry = entry.expiration.getTime() - Date.now();
13883
- (0, debug_logger_1.debugInfo)("CACHE", `\u2705 Session signatures cache hit: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
13884
- }
13885
- return entry.sessionSigs;
13886
- }
13887
- /**
13888
- * Cache session signatures
13889
- */
13890
- set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration) {
13891
- const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
13892
- const entry = {
13893
- sessionSigs,
13894
- expiration,
13895
- pkpTokenId,
13896
- litActionCid,
13897
- signerAddress,
13898
- network,
13899
- createdAt: /* @__PURE__ */ new Date()
13900
- };
13901
- this.cache.set(cacheKey, entry);
13902
- if (this.config.enableLogging) {
13903
- const timeUntilExpiry = expiration.getTime() - Date.now();
13904
- (0, debug_logger_1.debugInfo)("CACHE", `\u{1F4BE} Cached session signatures: ${cacheKey} (expires in ${Math.round(timeUntilExpiry / 1e3)}s)`);
13905
- }
13906
- this.enforceCacheSize();
13907
- }
13908
- /**
13909
- * Clear all cached session signatures
13910
- */
13911
- clear() {
13912
- const size = this.cache.size;
13913
- this.cache.clear();
13914
- if (this.config.enableLogging) {
13915
- (0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Cleared ${size} cached session signature entries`);
13916
- }
13917
- }
13918
- /**
13919
- * Get cache statistics
13920
- */
13921
- getStats() {
13922
- this.cleanExpiredEntries();
13923
- return {
13924
- size: this.cache.size,
13925
- maxEntries: this.config.maxEntries,
13926
- utilizationPercent: Math.round(this.cache.size / this.config.maxEntries * 100)
13927
- };
13928
- }
13929
- /**
13930
- * Remove specific cache entry
13931
- */
13932
- delete(pkpTokenId, litActionCid, signerAddress, network) {
13933
- const cacheKey = this.generateCacheKey(pkpTokenId, litActionCid, signerAddress, network);
13934
- const deleted = this.cache.delete(cacheKey);
13935
- if (deleted && this.config.enableLogging) {
13936
- (0, debug_logger_1.debugInfo)("CACHE", `\u{1F5D1}\uFE0F Removed session signatures from cache: ${cacheKey}`);
13937
- }
13938
- return deleted;
13939
- }
13940
- };
13941
- exports.sessionSignatureCache = new SessionSignatureCache();
13942
- async function generateSessionSignaturesWithCache(litNodeClient, sessionConfig, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
13943
- const cached = exports.sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
13944
- if (cached) {
13945
- return cached;
13946
- }
13947
- (0, debug_logger_1.debugInfo)("CACHE", "\u{1F510} Generating new session signatures (cache miss)...");
13948
- const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
13949
- const expiration = new Date(sessionConfig.expiration);
13950
- exports.sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
13951
- const sigCount = Object.keys(sessionSigs).length;
13952
- (0, debug_logger_1.debugInfo)("CACHE", `\u2705 Generated and cached ${sigCount} session signatures`);
13953
- return sessionSigs;
13954
- }
13955
- function configureSessionSignatureCache(config) {
13956
- Object.assign(exports.sessionSignatureCache["config"], config);
13957
- }
13958
- function clearSessionSignatureCache() {
13959
- exports.sessionSignatureCache.clear();
13960
- }
13961
- function getSessionSignatureCacheStats() {
13962
- return exports.sessionSignatureCache.getStats();
13963
- }
13964
- }
13965
- });
13966
-
13967
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js
13968
- var require_connection_helpers = __commonJS({
13969
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/chunks/connection-helpers.js"(exports) {
13970
- "use strict";
13971
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
13972
- if (k2 === void 0)
13973
- k2 = k;
13974
- var desc = Object.getOwnPropertyDescriptor(m, k);
13975
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13976
- desc = { enumerable: true, get: function() {
13977
- return m[k];
13978
- } };
13979
- }
13980
- Object.defineProperty(o, k2, desc);
13981
- } : function(o, m, k, k2) {
13982
- if (k2 === void 0)
13983
- k2 = k;
13984
- o[k2] = m[k];
13985
- });
13986
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
13987
- Object.defineProperty(o, "default", { enumerable: true, value: v });
13988
- } : function(o, v) {
13989
- o["default"] = v;
13990
- });
13991
- var __importStar = exports && exports.__importStar || function() {
13992
- var ownKeys = function(o) {
13993
- ownKeys = Object.getOwnPropertyNames || function(o2) {
13994
- var ar = [];
13995
- for (var k in o2)
13996
- if (Object.prototype.hasOwnProperty.call(o2, k))
13997
- ar[ar.length] = k;
13998
- return ar;
13999
- };
14000
- return ownKeys(o);
14001
- };
14002
- return function(mod) {
14003
- if (mod && mod.__esModule)
14004
- return mod;
14005
- var result = {};
14006
- if (mod != null) {
14007
- for (var k = ownKeys(mod), i = 0; i < k.length; i++)
14008
- if (k[i] !== "default")
14009
- __createBinding(result, mod, k[i]);
14010
- }
14011
- __setModuleDefault(result, mod);
14012
- return result;
14013
- };
14014
- }();
14015
- Object.defineProperty(exports, "__esModule", { value: true });
14016
- exports.NETWORK_TIMEOUTS = exports.DEFAULT_RETRY_CONFIG = void 0;
14017
- exports.sleep = sleep;
14018
- exports.isRetryableError = isRetryableError;
14019
- exports.calculateDelay = calculateDelay;
14020
- exports.withRetry = withRetry;
14021
- exports.connectLitNodeClient = connectLitNodeClient;
14022
- exports.connectLitContracts = connectLitContracts;
14023
- exports.validateLitNodeConnection = validateLitNodeConnection;
14024
- exports.generateSessionSignatures = generateSessionSignatures;
14025
- exports.validateLitNodeReadiness = validateLitNodeReadiness;
14026
- exports.executeLitAction = executeLitAction;
14027
- exports.executePkpOperation = executePkpOperation;
14028
- exports.getNetworkTimeouts = getNetworkTimeouts;
14029
- var debug_logger_1 = require_debug_logger();
14030
- var error_classification_1 = require_error_classification();
14031
- exports.DEFAULT_RETRY_CONFIG = {
14007
+ var DEFAULT_RETRY_CONFIG = {
14032
14008
  maxAttempts: 5,
14033
14009
  // Increased from 3 for PKP operations
14034
14010
  initialDelayMs: 2e3,
@@ -14062,80 +14038,85 @@ var require_connection_helpers = __commonJS({
14062
14038
  function sleep(ms) {
14063
14039
  return new Promise((resolve) => setTimeout(resolve, ms));
14064
14040
  }
14065
- function isRetryableError(error, retryableErrors = exports.DEFAULT_RETRY_CONFIG.retryableErrors) {
14041
+ function isRetryableError(error, retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors) {
14066
14042
  if (!error)
14067
14043
  return false;
14068
- const classification = (0, error_classification_1.classifyError)(error);
14044
+ const classification = classifyError(error);
14069
14045
  if (classification.isRetryable !== void 0) {
14070
- (0, debug_logger_1.debugInfo)("ERROR_CLASSIFICATION", `Error classified as: ${classification.category} (retryable: ${classification.isRetryable})`);
14046
+ debugInfo("ERROR_CLASSIFICATION", `Error classified as: ${classification.category} (retryable: ${classification.isRetryable})`);
14071
14047
  return classification.isRetryable;
14072
14048
  }
14073
14049
  const errorMessage = error.message || error.toString() || "";
14074
14050
  const errorLower = errorMessage.toLowerCase();
14075
- return retryableErrors.some((pattern) => errorLower.includes(pattern.toLowerCase()));
14051
+ return retryableErrors.some(
14052
+ (pattern) => errorLower.includes(pattern.toLowerCase())
14053
+ );
14076
14054
  }
14077
14055
  function calculateDelay(attempt, config) {
14078
- const exponentialDelay = Math.min(config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1), config.maxDelayMs);
14056
+ const exponentialDelay = Math.min(
14057
+ config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1),
14058
+ config.maxDelayMs
14059
+ );
14079
14060
  const jitter = exponentialDelay * 0.25 * (Math.random() - 0.5);
14080
14061
  return Math.max(100, exponentialDelay + jitter);
14081
14062
  }
14082
14063
  async function withRetry(operation, config = {}, operationName = "operation") {
14083
- let finalConfig = { ...exports.DEFAULT_RETRY_CONFIG, ...config };
14084
- const tracker = new debug_logger_1.PerformanceTracker(`Retry ${operationName}`);
14064
+ let finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
14065
+ const tracker = new PerformanceTracker(`Retry ${operationName}`);
14085
14066
  let lastError;
14086
14067
  let errorClassification = null;
14087
14068
  for (let attempt = 1; attempt <= finalConfig.maxAttempts; attempt++) {
14088
14069
  try {
14089
- (0, debug_logger_1.debugInfo)("RETRY", `\u{1F504} [${operationName}] Attempt ${attempt}/${finalConfig.maxAttempts}`);
14070
+ debugInfo("RETRY", `\u{1F504} [${operationName}] Attempt ${attempt}/${finalConfig.maxAttempts}`);
14090
14071
  const startTime = Date.now();
14091
14072
  const result = await operation();
14092
14073
  const duration = Date.now() - startTime;
14093
- (0, debug_logger_1.debugInfo)("RETRY", `\u2705 [${operationName}] Success after ${duration}ms (attempt ${attempt})`);
14094
- debug_logger_1.networkMetrics.recordRequest(operationName, true, duration);
14074
+ debugInfo("RETRY", `\u2705 [${operationName}] Success after ${duration}ms (attempt ${attempt})`);
14075
+ networkMetrics.recordRequest(operationName, true, duration);
14095
14076
  tracker.end(true);
14096
14077
  return result;
14097
14078
  } catch (error) {
14098
14079
  lastError = error;
14099
14080
  const errorMessage = error?.message || error?.toString() || "Unknown error";
14100
- errorClassification = (0, error_classification_1.classifyError)(error);
14081
+ errorClassification = classifyError(error);
14101
14082
  if (attempt === 1 && errorClassification) {
14102
- const intelligentConfig = (0, error_classification_1.getRetryConfigFromClassification)(errorClassification);
14083
+ const intelligentConfig = getRetryConfigFromClassification(errorClassification);
14103
14084
  finalConfig = {
14104
14085
  ...finalConfig,
14105
14086
  ...intelligentConfig,
14106
14087
  maxAttempts: Math.min(finalConfig.maxAttempts, intelligentConfig.maxAttempts)
14107
14088
  };
14108
- (0, debug_logger_1.debugInfo)("RETRY", `\u{1F9E0} Intelligent retry strategy applied: ${errorClassification.category} (${errorClassification.retryStrategy})`);
14109
- (0, debug_logger_1.debugInfo)("RETRY", `\u{1F4CA} Adjusted config: max=${finalConfig.maxAttempts}, delay=${finalConfig.initialDelayMs}ms`);
14089
+ debugInfo("RETRY", `\u{1F9E0} Intelligent retry strategy applied: ${errorClassification.category} (${errorClassification.retryStrategy})`);
14090
+ debugInfo("RETRY", `\u{1F4CA} Adjusted config: max=${finalConfig.maxAttempts}, delay=${finalConfig.initialDelayMs}ms`);
14110
14091
  }
14111
- (0, debug_logger_1.debugWarn)("RETRY", `\u26A0\uFE0F [${operationName}] Attempt ${attempt} failed:`, {
14092
+ debugWarn("RETRY", `\u26A0\uFE0F [${operationName}] Attempt ${attempt} failed:`, {
14112
14093
  error: errorMessage,
14113
14094
  attempt,
14114
14095
  category: errorClassification.category,
14115
14096
  retryable: errorClassification.isRetryable
14116
14097
  });
14117
- debug_logger_1.networkMetrics.recordRequest(operationName, false, 0, errorMessage);
14098
+ networkMetrics.recordRequest(operationName, false, 0, errorMessage);
14118
14099
  if (attempt >= finalConfig.maxAttempts) {
14119
- (0, debug_logger_1.debugError)("RETRY", `\u274C [${operationName}] All attempts failed. Last error:`, { error: errorMessage });
14100
+ debugError("RETRY", `\u274C [${operationName}] All attempts failed. Last error:`, { error: errorMessage });
14120
14101
  if (errorClassification) {
14121
- const errorReport = (0, error_classification_1.createErrorReport)(error);
14122
- (0, debug_logger_1.debugError)("RETRY", `\u{1F4CB} Error Analysis Report:
14102
+ const errorReport = createErrorReport(error);
14103
+ debugError("RETRY", `\u{1F4CB} Error Analysis Report:
14123
14104
  ${errorReport}`);
14124
14105
  }
14125
14106
  tracker.end(false);
14126
14107
  break;
14127
14108
  }
14128
14109
  if (!errorClassification.isRetryable) {
14129
- (0, debug_logger_1.debugError)("RETRY", `\u{1F6AB} [${operationName}] Non-retryable error (${errorClassification.category}):`, { error: errorMessage });
14110
+ debugError("RETRY", `\u{1F6AB} [${operationName}] Non-retryable error (${errorClassification.category}):`, { error: errorMessage });
14130
14111
  if (errorClassification.troubleshooting) {
14131
- (0, debug_logger_1.debugInfo)("RETRY", `\u{1F4A1} Troubleshooting suggestions:
14112
+ debugInfo("RETRY", `\u{1F4A1} Troubleshooting suggestions:
14132
14113
  ${errorClassification.troubleshooting.join("\n ")}`);
14133
14114
  }
14134
14115
  tracker.end(false);
14135
14116
  break;
14136
14117
  }
14137
14118
  const delayMs = calculateDelay(attempt, finalConfig);
14138
- (0, debug_logger_1.debugInfo)("RETRY", `\u23F3 [${operationName}] Waiting ${delayMs}ms before retry... (${errorClassification.retryStrategy} strategy)`);
14119
+ debugInfo("RETRY", `\u23F3 [${operationName}] Waiting ${delayMs}ms before retry... (${errorClassification.retryStrategy} strategy)`);
14139
14120
  await sleep(delayMs);
14140
14121
  }
14141
14122
  }
@@ -14143,36 +14124,44 @@ ${errorReport}`);
14143
14124
  }
14144
14125
  async function connectLitNodeClient(litNodeClient, config = {}) {
14145
14126
  const network = litNodeClient?.config?.litNetwork || "unknown";
14146
- return withRetry(async () => {
14147
- if (!litNodeClient) {
14148
- throw new Error("LIT Node Client is null or undefined");
14149
- }
14150
- const startTime = Date.now();
14151
- (0, debug_logger_1.logConnectionAttempt)(network, 1, config.maxAttempts || exports.DEFAULT_RETRY_CONFIG.maxAttempts);
14152
- await litNodeClient.connect();
14153
- (0, debug_logger_1.debugInfo)("CONNECTION", `\u23F3 Waiting for LIT Node Client to be ready...`);
14154
- const readyTimeout = 3e4;
14155
- const readyStartTime = Date.now();
14156
- while (!litNodeClient.ready && Date.now() - readyStartTime < readyTimeout) {
14157
- await sleep(500);
14158
- }
14159
- if (!litNodeClient.ready) {
14160
- throw new Error(`LIT Node Client failed to become ready within ${readyTimeout}ms`);
14161
- }
14162
- const latency = Date.now() - startTime;
14163
- (0, debug_logger_1.debugInfo)("CONNECTION", `\u2705 LIT Node Client is ready (${litNodeClient.ready})`);
14164
- (0, debug_logger_1.logConnectionSuccess)(network, latency);
14165
- }, config, "LIT Node Client Connection");
14127
+ return withRetry(
14128
+ async () => {
14129
+ if (!litNodeClient) {
14130
+ throw new Error("LIT Node Client is null or undefined");
14131
+ }
14132
+ const startTime = Date.now();
14133
+ logConnectionAttempt(network, 1, config.maxAttempts || DEFAULT_RETRY_CONFIG.maxAttempts);
14134
+ await litNodeClient.connect();
14135
+ debugInfo("CONNECTION", `\u23F3 Waiting for LIT Node Client to be ready...`);
14136
+ const readyTimeout = 3e4;
14137
+ const readyStartTime = Date.now();
14138
+ while (!litNodeClient.ready && Date.now() - readyStartTime < readyTimeout) {
14139
+ await sleep(500);
14140
+ }
14141
+ if (!litNodeClient.ready) {
14142
+ throw new Error(`LIT Node Client failed to become ready within ${readyTimeout}ms`);
14143
+ }
14144
+ const latency = Date.now() - startTime;
14145
+ debugInfo("CONNECTION", `\u2705 LIT Node Client is ready (${litNodeClient.ready})`);
14146
+ logConnectionSuccess(network, latency);
14147
+ },
14148
+ config,
14149
+ "LIT Node Client Connection"
14150
+ );
14166
14151
  }
14167
14152
  async function connectLitContracts(litContracts, config = {}) {
14168
- return withRetry(async () => {
14169
- if (!litContracts) {
14170
- throw new Error("LIT Contracts is null or undefined");
14171
- }
14172
- console.log(`\u{1F517} Connecting to LIT Contracts: ${litContracts.network || "unknown"}`);
14173
- await litContracts.connect();
14174
- console.log("\u2705 LIT Contracts connected successfully");
14175
- }, config, "LIT Contracts Connection");
14153
+ return withRetry(
14154
+ async () => {
14155
+ if (!litContracts) {
14156
+ throw new Error("LIT Contracts is null or undefined");
14157
+ }
14158
+ console.log(`\u{1F517} Connecting to LIT Contracts: ${litContracts.network || "unknown"}`);
14159
+ await litContracts.connect();
14160
+ console.log("\u2705 LIT Contracts connected successfully");
14161
+ },
14162
+ config,
14163
+ "LIT Contracts Connection"
14164
+ );
14176
14165
  }
14177
14166
  async function validateLitNodeConnection(litNodeClient) {
14178
14167
  try {
@@ -14192,33 +14181,37 @@ ${errorReport}`);
14192
14181
  }
14193
14182
  async function generateSessionSignatures(litNodeClient, sessionConfig, config = {}, pkpTokenId, litActionCid, signerAddress, network = "chipotle") {
14194
14183
  if (pkpTokenId && litActionCid && signerAddress) {
14195
- const { sessionSignatureCache } = await Promise.resolve().then(() => __importStar(require_session_signature_cache()));
14196
- const cached = sessionSignatureCache.get(pkpTokenId, litActionCid, signerAddress, network);
14184
+ const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
14185
+ const cached = sessionSignatureCache2.get(pkpTokenId, litActionCid, signerAddress, network);
14197
14186
  if (cached) {
14198
14187
  const sigCount = Object.keys(cached).length;
14199
- (0, debug_logger_1.debugInfo)("SESSION", `\u{1F504} Using cached session signatures (${sigCount} sigs)`);
14188
+ debugInfo("SESSION", `\u{1F504} Using cached session signatures (${sigCount} sigs)`);
14200
14189
  return cached;
14201
14190
  }
14202
14191
  }
14203
- return withRetry(async () => {
14204
- (0, debug_logger_1.debugInfo)("SESSION", "\u{1F510} Generating new session signatures...");
14205
- const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
14206
- const sigCount = Object.keys(sessionSigs).length;
14207
- if (pkpTokenId && litActionCid && signerAddress) {
14208
- const { sessionSignatureCache } = await Promise.resolve().then(() => __importStar(require_session_signature_cache()));
14209
- const expiration = new Date(sessionConfig.expiration);
14210
- sessionSignatureCache.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
14211
- }
14212
- (0, debug_logger_1.debugInfo)("SESSION", `\u2705 Generated ${sigCount} session signatures`);
14213
- return sessionSigs;
14214
- }, config, "Session Signature Generation");
14192
+ return withRetry(
14193
+ async () => {
14194
+ debugInfo("SESSION", "\u{1F510} Generating new session signatures...");
14195
+ const sessionSigs = await litNodeClient.getSessionSigs(sessionConfig);
14196
+ const sigCount = Object.keys(sessionSigs).length;
14197
+ if (pkpTokenId && litActionCid && signerAddress) {
14198
+ const { sessionSignatureCache: sessionSignatureCache2 } = await Promise.resolve().then(() => (init_session_signature_cache(), session_signature_cache_exports));
14199
+ const expiration = new Date(sessionConfig.expiration);
14200
+ sessionSignatureCache2.set(pkpTokenId, litActionCid, signerAddress, network, sessionSigs, expiration);
14201
+ }
14202
+ debugInfo("SESSION", `\u2705 Generated ${sigCount} session signatures`);
14203
+ return sessionSigs;
14204
+ },
14205
+ config,
14206
+ "Session Signature Generation"
14207
+ );
14215
14208
  }
14216
14209
  async function validateLitNodeReadiness(litNodeClient) {
14217
14210
  if (!litNodeClient) {
14218
14211
  throw new Error("LIT Node Client is null or undefined");
14219
14212
  }
14220
14213
  if (!litNodeClient.ready) {
14221
- (0, debug_logger_1.debugWarn)("CONNECTION", "\u26A0\uFE0F LIT Node Client not ready, attempting to reconnect...");
14214
+ debugWarn("CONNECTION", "\u26A0\uFE0F LIT Node Client not ready, attempting to reconnect...");
14222
14215
  await litNodeClient.connect();
14223
14216
  const readyTimeout = 15e3;
14224
14217
  const startTime = Date.now();
@@ -14229,32 +14222,36 @@ ${errorReport}`);
14229
14222
  throw new Error("LIT Node Client is not ready for operations");
14230
14223
  }
14231
14224
  }
14232
- (0, debug_logger_1.debugInfo)("CONNECTION", "\u2705 LIT Node Client readiness validated");
14225
+ debugInfo("CONNECTION", "\u2705 LIT Node Client readiness validated");
14233
14226
  }
14234
14227
  async function executeLitAction(litNodeClient, executionConfig, config = {}) {
14235
14228
  const cid = executionConfig.ipfsId;
14236
- return withRetry(async () => {
14237
- const startTime = Date.now();
14238
- await validateLitNodeReadiness(litNodeClient);
14239
- (0, debug_logger_1.logLitActionExecution)(cid, executionConfig.jsParams);
14240
- (0, debug_logger_1.logRequest)("LIT_ACTION", "executeJs", executionConfig);
14241
- const result = await litNodeClient.executeJs(executionConfig);
14242
- const duration = Date.now() - startTime;
14243
- if (!result.response) {
14244
- (0, debug_logger_1.logError)("LIT_ACTION", "executeJs", new Error("No response from LIT Action"), duration);
14245
- throw new Error("No response from LIT Action");
14246
- }
14247
- (0, debug_logger_1.logResponse)("LIT_ACTION", "executeJs", result, duration);
14248
- (0, debug_logger_1.logLitActionResult)(cid, true, duration, result);
14249
- return result;
14250
- }, config, "LIT Action Execution");
14229
+ return withRetry(
14230
+ async () => {
14231
+ const startTime = Date.now();
14232
+ await validateLitNodeReadiness(litNodeClient);
14233
+ logLitActionExecution(cid, executionConfig.jsParams);
14234
+ logRequest("LIT_ACTION", "executeJs", executionConfig);
14235
+ const result = await litNodeClient.executeJs(executionConfig);
14236
+ const duration = Date.now() - startTime;
14237
+ if (!result.response) {
14238
+ logError("LIT_ACTION", "executeJs", new Error("No response from LIT Action"), duration);
14239
+ throw new Error("No response from LIT Action");
14240
+ }
14241
+ logResponse("LIT_ACTION", "executeJs", result, duration);
14242
+ logLitActionResult(cid, true, duration, result);
14243
+ return result;
14244
+ },
14245
+ config,
14246
+ "LIT Action Execution"
14247
+ );
14251
14248
  }
14252
14249
  async function executePkpOperation(operation, operationName, config = {}) {
14253
14250
  const pkpConfig = {
14254
- ...exports.DEFAULT_RETRY_CONFIG,
14251
+ ...DEFAULT_RETRY_CONFIG,
14255
14252
  ...config,
14256
14253
  retryableErrors: [
14257
- ...exports.DEFAULT_RETRY_CONFIG.retryableErrors,
14254
+ ...DEFAULT_RETRY_CONFIG.retryableErrors,
14258
14255
  "pkp validation",
14259
14256
  "signing shares",
14260
14257
  "resource validation",
@@ -14263,7 +14260,7 @@ ${errorReport}`);
14263
14260
  };
14264
14261
  return withRetry(operation, pkpConfig, `PKP ${operationName}`);
14265
14262
  }
14266
- exports.NETWORK_TIMEOUTS = {
14263
+ var NETWORK_TIMEOUTS = {
14267
14264
  chipotle: {
14268
14265
  connection: 6e4,
14269
14266
  operation: 12e4,
@@ -14271,82 +14268,10 @@ ${errorReport}`);
14271
14268
  }
14272
14269
  };
14273
14270
  function getNetworkTimeouts(network) {
14274
- return exports.NETWORK_TIMEOUTS[network] || exports.NETWORK_TIMEOUTS["chipotle"];
14271
+ return NETWORK_TIMEOUTS[network] || NETWORK_TIMEOUTS["chipotle"];
14275
14272
  }
14276
- }
14277
- });
14278
-
14279
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js
14280
- var require_utils4 = __commonJS({
14281
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/utils/index.js"(exports) {
14282
- "use strict";
14283
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
14284
- if (k2 === void 0)
14285
- k2 = k;
14286
- var desc = Object.getOwnPropertyDescriptor(m, k);
14287
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14288
- desc = { enumerable: true, get: function() {
14289
- return m[k];
14290
- } };
14291
- }
14292
- Object.defineProperty(o, k2, desc);
14293
- } : function(o, m, k, k2) {
14294
- if (k2 === void 0)
14295
- k2 = k;
14296
- o[k2] = m[k];
14297
- });
14298
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
14299
- for (var p in m)
14300
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
14301
- __createBinding(exports2, m, p);
14302
- };
14303
- Object.defineProperty(exports, "__esModule", { value: true });
14304
- __exportStar(require_lit_action_helpers(), exports);
14305
- __exportStar(require_pkp_setup(), exports);
14306
- __exportStar(require_cid_utils(), exports);
14307
- __exportStar(require_connection_helpers(), exports);
14308
- __exportStar(require_debug_logger(), exports);
14309
- __exportStar(require_error_classification(), exports);
14310
- __exportStar(require_session_signature_cache(), exports);
14311
- }
14312
- });
14313
-
14314
- // node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js
14315
- var require_pkg_src = __commonJS({
14316
- "node_modules/@gvnrdao/dh-lit-actions/pkg-dist/pkg-src/index.js"(exports) {
14317
- "use strict";
14318
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
14319
- if (k2 === void 0)
14320
- k2 = k;
14321
- var desc = Object.getOwnPropertyDescriptor(m, k);
14322
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14323
- desc = { enumerable: true, get: function() {
14324
- return m[k];
14325
- } };
14326
- }
14327
- Object.defineProperty(o, k2, desc);
14328
- } : function(o, m, k, k2) {
14329
- if (k2 === void 0)
14330
- k2 = k;
14331
- o[k2] = m[k];
14332
- });
14333
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
14334
- for (var p in m)
14335
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
14336
- __createBinding(exports2, m, p);
14337
- };
14338
- Object.defineProperty(exports, "__esModule", { value: true });
14339
- exports.CHIPOTLE_DEPLOYMENTS = exports.DH_LIT_ACTIONS_CHIPOTLE = void 0;
14340
- __exportStar(require_interfaces(), exports);
14341
- __exportStar(require_lit_actions_registry(), exports);
14342
- __exportStar(require_utils4(), exports);
14343
- var lit_actions_registry_1 = require_lit_actions_registry();
14344
- Object.defineProperty(exports, "DH_LIT_ACTIONS_CHIPOTLE", { enumerable: true, get: function() {
14345
- return lit_actions_registry_1.DH_LIT_ACTIONS_CHIPOTLE;
14346
- } });
14347
- Object.defineProperty(exports, "CHIPOTLE_DEPLOYMENTS", { enumerable: true, get: function() {
14348
- return lit_actions_registry_1.CHIPOTLE_DEPLOYMENTS;
14349
- } });
14273
+ init_debug_logger();
14274
+ init_session_signature_cache();
14350
14275
  }
14351
14276
  });
14352
14277
 
@@ -14384,7 +14309,7 @@ var init_deployment_addresses = __esm({
14384
14309
  PriceFeedConsumer: "0xb3Dc64501935a6f0334779126Ee37bE463cee318",
14385
14310
  PositionManagerCoreModule: "0xfFAA39a08887FeFB697eBC8691A8630CbCC33391",
14386
14311
  TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
14387
- LoanOperationsManagerModule: "0xD3ADCCe9b46287763f723dC9a3FCfa59ab74b8bB",
14312
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
14388
14313
  CollateralManagerModule: "0x967E92c976Fc0fa8268D37D4d6B7245d912aA7dB",
14389
14314
  LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76",
14390
14315
  CircuitBreakerModule: "0x3D0B2cAE481821E57BA9CC3807bCC0d0D7F18bd8",
@@ -14470,9 +14395,9 @@ var init_deployment_addresses = __esm({
14470
14395
  reason: "Shared upgrade script: PositionManagerCoreModule implementation update"
14471
14396
  },
14472
14397
  CollateralManagerModule: {
14473
- previousImplementation: "0xB82d53282a87A39FBab72A203b314fEd1A33A516",
14474
- newImplementation: "0xb26039e5FF9771b2899D54b6dE879D493616502c",
14475
- upgradedAt: "2026-04-20T16:09:13.333Z",
14398
+ previousImplementation: "0xb26039e5FF9771b2899D54b6dE879D493616502c",
14399
+ newImplementation: "0x84C5B89f60415F8df3Fee46Ef1a10a6484aa8e0A",
14400
+ upgradedAt: "2026-04-29T12:13:12.465Z",
14476
14401
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
14477
14402
  reason: "Shared upgrade script: CollateralManagerModule implementation update"
14478
14403
  },
@@ -14610,7 +14535,7 @@ var init_deployment_addresses = __esm({
14610
14535
  PriceFeedConsumer: "0xb3Dc64501935a6f0334779126Ee37bE463cee318",
14611
14536
  PositionManagerCoreModule: "0xfFAA39a08887FeFB697eBC8691A8630CbCC33391",
14612
14537
  TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
14613
- LoanOperationsManagerModule: "0xD3ADCCe9b46287763f723dC9a3FCfa59ab74b8bB",
14538
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
14614
14539
  CollateralManagerModule: "0x967E92c976Fc0fa8268D37D4d6B7245d912aA7dB",
14615
14540
  LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76",
14616
14541
  CircuitBreakerModule: "0x3D0B2cAE481821E57BA9CC3807bCC0d0D7F18bd8",
@@ -36440,7 +36365,7 @@ var DiamondHandsGraph = class {
36440
36365
  }
36441
36366
 
36442
36367
  ${shouldQuery.mint ? `
36443
- ucdMintEvents(
36368
+ ucdmintEvents(
36444
36369
  ${buildPositionWhereClause()}
36445
36370
  first: $limit,
36446
36371
  orderBy: timestamp,
@@ -36629,7 +36554,7 @@ var DiamondHandsGraph = class {
36629
36554
  commitTimestamp: result.position.liquidation.commitTimestamp,
36630
36555
  revealDelay: result.position.liquidation.revealDelay
36631
36556
  } : void 0;
36632
- const mints = (result.ucdMintEvents || []).map((m) => ({
36557
+ const mints = (result.ucdmintEvents || []).map((m) => ({
36633
36558
  id: m.id,
36634
36559
  positionId,
36635
36560
  amount: m.amount,
@@ -37272,6 +37197,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
37272
37197
  network: config.litNetwork || DEFAULT_LIT_NETWORK,
37273
37198
  signer: config.mode === "standalone" ? config.litOpsSigner : void 0,
37274
37199
  serviceEndpoint: isServiceModeConfig(config) ? config.serviceEndpoint : void 0,
37200
+ serviceAuthToken: isServiceModeConfig(config) ? config.serviceAuthToken : void 0,
37275
37201
  debug: config.debug,
37276
37202
  litNodeConnectTimeoutMs: config.litNodeConnectTimeoutMs
37277
37203
  // TODO Round 2: Add litActionExecution config when added to config.i.ts interface