@layr-labs/ecloud-sdk 0.1.0-dev.1 → 0.1.0-dev.3

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.
@@ -0,0 +1,668 @@
1
+ // src/client/common/config/environment.ts
2
+ var SEPOLIA_CHAIN_ID = 11155111;
3
+ var MAINNET_CHAIN_ID = 1;
4
+ var CommonAddresses = {
5
+ ERC7702Delegator: "0x63c0c19a282a1b52b07dd5a65b58948a07dae32b"
6
+ };
7
+ var ChainAddresses = {
8
+ [MAINNET_CHAIN_ID]: {
9
+ PermissionController: "0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5"
10
+ },
11
+ [SEPOLIA_CHAIN_ID]: {
12
+ PermissionController: "0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37"
13
+ }
14
+ };
15
+ var BILLING_ENVIRONMENTS = {
16
+ dev: {
17
+ billingApiServerURL: "https://billingapi-dev.eigencloud.xyz"
18
+ },
19
+ prod: {
20
+ billingApiServerURL: "https://billingapi.eigencloud.xyz"
21
+ }
22
+ };
23
+ var ENVIRONMENTS = {
24
+ "sepolia-dev": {
25
+ name: "sepolia",
26
+ build: "dev",
27
+ appControllerAddress: "0xa86DC1C47cb2518327fB4f9A1627F51966c83B92",
28
+ permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,
29
+ erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
30
+ kmsServerURL: "http://10.128.0.57:8080",
31
+ userApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz",
32
+ defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com"
33
+ },
34
+ sepolia: {
35
+ name: "sepolia",
36
+ build: "prod",
37
+ appControllerAddress: "0x0dd810a6ffba6a9820a10d97b659f07d8d23d4E2",
38
+ permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,
39
+ erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
40
+ kmsServerURL: "http://10.128.15.203:8080",
41
+ userApiServerURL: "https://userapi-compute-sepolia-prod.eigencloud.xyz",
42
+ defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com"
43
+ },
44
+ "mainnet-alpha": {
45
+ name: "mainnet-alpha",
46
+ build: "prod",
47
+ appControllerAddress: "0xc38d35Fc995e75342A21CBd6D770305b142Fbe67",
48
+ permissionControllerAddress: ChainAddresses[MAINNET_CHAIN_ID].PermissionController,
49
+ erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
50
+ kmsServerURL: "http://10.128.0.2:8080",
51
+ userApiServerURL: "https://userapi-compute.eigencloud.xyz",
52
+ defaultRPCURL: "https://ethereum-rpc.publicnode.com"
53
+ }
54
+ };
55
+ var CHAIN_ID_TO_ENVIRONMENT = {
56
+ [SEPOLIA_CHAIN_ID.toString()]: "sepolia",
57
+ [MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
58
+ };
59
+ function getEnvironmentConfig(environment, chainID) {
60
+ const env = ENVIRONMENTS[environment];
61
+ if (!env) {
62
+ throw new Error(`Unknown environment: ${environment}`);
63
+ }
64
+ if (!isEnvironmentAvailable(environment)) {
65
+ throw new Error(
66
+ `Environment ${environment} is not available in this build type. Available environments: ${getAvailableEnvironments().join(", ")}`
67
+ );
68
+ }
69
+ if (chainID) {
70
+ const expectedEnv = CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];
71
+ if (expectedEnv && expectedEnv !== environment) {
72
+ throw new Error(`Environment ${environment} does not match chain ID ${chainID}`);
73
+ }
74
+ }
75
+ const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
76
+ return {
77
+ ...env,
78
+ chainID: BigInt(resolvedChainID)
79
+ };
80
+ }
81
+ function getBillingEnvironmentConfig(build) {
82
+ const config = BILLING_ENVIRONMENTS[build];
83
+ if (!config) {
84
+ throw new Error(`Unknown billing environment: ${build}`);
85
+ }
86
+ return config;
87
+ }
88
+ function getBuildType() {
89
+ const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
90
+ const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
91
+ const buildType = buildTimeType || runtimeType;
92
+ if (buildType === "dev") {
93
+ return "dev";
94
+ }
95
+ return "prod";
96
+ }
97
+ function getAvailableEnvironments() {
98
+ const buildType = getBuildType();
99
+ if (buildType === "dev") {
100
+ return ["sepolia-dev"];
101
+ }
102
+ return ["sepolia", "mainnet-alpha"];
103
+ }
104
+ function isEnvironmentAvailable(environment) {
105
+ return getAvailableEnvironments().includes(environment);
106
+ }
107
+ function isMainnet(environmentConfig) {
108
+ return environmentConfig.chainID === BigInt(MAINNET_CHAIN_ID);
109
+ }
110
+
111
+ // src/client/common/utils/userapi.ts
112
+ import axios from "axios";
113
+ import FormData from "form-data";
114
+ import { createPublicClient, http } from "viem";
115
+
116
+ // src/client/common/utils/auth.ts
117
+ import { parseAbi } from "viem";
118
+ var APP_CONTROLLER_ABI = parseAbi([
119
+ "function calculateApiPermissionDigestHash(bytes4 permission, uint256 expiry) view returns (bytes32)"
120
+ ]);
121
+ async function calculatePermissionSignature(options) {
122
+ const { permission, expiry, appControllerAddress, publicClient, account } = options;
123
+ const digest = await publicClient.readContract({
124
+ address: appControllerAddress,
125
+ abi: APP_CONTROLLER_ABI,
126
+ functionName: "calculateApiPermissionDigestHash",
127
+ args: [permission, expiry]
128
+ });
129
+ const signature = await account.signMessage({
130
+ message: { raw: digest }
131
+ });
132
+ return { signature, digest };
133
+ }
134
+ async function calculateBillingAuthSignature(options) {
135
+ const { account, product, expiry } = options;
136
+ const signature = await account.signTypedData({
137
+ domain: {
138
+ name: "EigenCloud Billing API",
139
+ version: "1"
140
+ },
141
+ types: {
142
+ BillingAuth: [
143
+ { name: "product", type: "string" },
144
+ { name: "expiry", type: "uint256" }
145
+ ]
146
+ },
147
+ primaryType: "BillingAuth",
148
+ message: {
149
+ product,
150
+ expiry
151
+ }
152
+ });
153
+ return { signature, expiry };
154
+ }
155
+
156
+ // src/client/common/utils/userapi.ts
157
+ import { privateKeyToAccount } from "viem/accounts";
158
+
159
+ // src/client/common/utils/helpers.ts
160
+ import { extractChain } from "viem";
161
+ import { sepolia as sepolia2 } from "viem/chains";
162
+
163
+ // src/client/common/constants.ts
164
+ import { sepolia, mainnet } from "viem/chains";
165
+ var SUPPORTED_CHAINS = [mainnet, sepolia];
166
+ var DOCKER_PLATFORM = "linux/amd64";
167
+ var REGISTRY_PROPAGATION_WAIT_SECONDS = 3;
168
+ var LAYERED_DOCKERFILE_NAME = "Dockerfile.eigencompute";
169
+ var ENV_SOURCE_SCRIPT_NAME = "compute-source-env.sh";
170
+ var KMS_CLIENT_BINARY_NAME = "kms-client";
171
+ var KMS_SIGNING_KEY_NAME = "kms-signing-public-key.pem";
172
+ var TLS_KEYGEN_BINARY_NAME = "tls-keygen";
173
+ var CADDYFILE_NAME = "Caddyfile";
174
+ var LAYERED_BUILD_DIR_PREFIX = "ecloud-layered-build";
175
+
176
+ // src/client/common/utils/helpers.ts
177
+ function getChainFromID(chainID, fallback = sepolia2) {
178
+ const id = Number(chainID);
179
+ return extractChain({ chains: SUPPORTED_CHAINS, id }) || fallback;
180
+ }
181
+ function addHexPrefix(value) {
182
+ return value.startsWith("0x") ? value : `0x${value}`;
183
+ }
184
+ function stripHexPrefix(value) {
185
+ return value.startsWith("0x") ? value.slice(2) : value;
186
+ }
187
+
188
+ // src/client/common/utils/userapi.ts
189
+ var MAX_ADDRESS_COUNT = 5;
190
+ var CanViewAppLogsPermission = "0x2fd3f2fe";
191
+ var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
192
+ var CanUpdateAppProfilePermission = "0x036fef61";
193
+ function getDefaultClientId() {
194
+ const version = true ? "0.1.0-dev.3" : "0.0.0";
195
+ return `ecloud-sdk/v${version}`;
196
+ }
197
+ var UserApiClient = class {
198
+ constructor(config, privateKey, rpcUrl, clientId) {
199
+ this.config = config;
200
+ if (privateKey) {
201
+ const privateKeyHex = addHexPrefix(privateKey);
202
+ this.account = privateKeyToAccount(privateKeyHex);
203
+ }
204
+ this.rpcUrl = rpcUrl;
205
+ this.clientId = clientId || getDefaultClientId();
206
+ }
207
+ async getInfos(appIDs, addressCount = 1) {
208
+ const count = Math.min(addressCount, MAX_ADDRESS_COUNT);
209
+ const endpoint = `${this.config.userApiServerURL}/info`;
210
+ const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(",") })}`;
211
+ const res = await this.makeAuthenticatedRequest(url, CanViewSensitiveAppInfoPermission);
212
+ const result = await res.json();
213
+ return result.apps.map((app, i) => {
214
+ const evmAddresses = app.addresses?.data?.evmAddresses?.slice(0, count) || [];
215
+ const solanaAddresses = app.addresses?.data?.solanaAddresses?.slice(0, count) || [];
216
+ return {
217
+ address: appIDs[i],
218
+ status: app.app_status,
219
+ ip: app.ip,
220
+ machineType: app.machine_type,
221
+ profile: app.profile,
222
+ metrics: app.metrics,
223
+ evmAddresses,
224
+ solanaAddresses
225
+ };
226
+ });
227
+ }
228
+ /**
229
+ * Get available SKUs (instance types) from UserAPI
230
+ */
231
+ async getSKUs() {
232
+ const endpoint = `${this.config.userApiServerURL}/skus`;
233
+ const response = await this.makeAuthenticatedRequest(endpoint);
234
+ const result = await response.json();
235
+ return {
236
+ skus: result.skus || result.SKUs || []
237
+ };
238
+ }
239
+ /**
240
+ * Get logs for an app
241
+ */
242
+ async getLogs(appID) {
243
+ const endpoint = `${this.config.userApiServerURL}/logs/${appID}`;
244
+ const response = await this.makeAuthenticatedRequest(endpoint, CanViewAppLogsPermission);
245
+ return await response.text();
246
+ }
247
+ /**
248
+ * Get statuses for apps
249
+ */
250
+ async getStatuses(appIDs) {
251
+ const endpoint = `${this.config.userApiServerURL}/status`;
252
+ const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(",") })}`;
253
+ const response = await this.makeAuthenticatedRequest(url);
254
+ const result = await response.json();
255
+ const apps = result.apps || result.Apps || [];
256
+ return apps.map((app, i) => ({
257
+ address: app.address || appIDs[i],
258
+ status: app.status || app.Status || ""
259
+ }));
260
+ }
261
+ /**
262
+ * Upload app profile information with optional image
263
+ */
264
+ async uploadAppProfile(appAddress, name, website, description, xURL, imagePath) {
265
+ const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}/profile`;
266
+ const formData = new FormData();
267
+ formData.append("name", name);
268
+ if (website) {
269
+ formData.append("website", website);
270
+ }
271
+ if (description) {
272
+ formData.append("description", description);
273
+ }
274
+ if (xURL) {
275
+ formData.append("xURL", xURL);
276
+ }
277
+ if (imagePath) {
278
+ const fs = await import("fs");
279
+ const path2 = await import("path");
280
+ const fileName = path2.basename(imagePath);
281
+ const fileBuffer = fs.readFileSync(imagePath);
282
+ formData.append("image", fileBuffer, fileName);
283
+ }
284
+ const headers = {
285
+ "x-client-id": this.clientId,
286
+ ...formData.getHeaders()
287
+ };
288
+ if (this.account) {
289
+ const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
290
+ const authHeaders = await this.generateAuthHeaders(CanUpdateAppProfilePermission, expiry);
291
+ Object.assign(headers, authHeaders);
292
+ }
293
+ try {
294
+ const response = await axios.post(endpoint, formData, {
295
+ headers,
296
+ maxRedirects: 0,
297
+ validateStatus: () => true,
298
+ // Don't throw on any status
299
+ maxContentLength: Infinity,
300
+ // Allow large file uploads
301
+ maxBodyLength: Infinity
302
+ // Allow large file uploads
303
+ });
304
+ const status = response.status;
305
+ if (status !== 200 && status !== 201) {
306
+ const body = typeof response.data === "string" ? response.data : JSON.stringify(response.data);
307
+ if (status === 403 && body.includes("Cloudflare") && body.includes("challenge-platform")) {
308
+ throw new Error(
309
+ `Cloudflare protection is blocking the request. This is likely due to bot detection.
310
+ Status: ${status}`
311
+ );
312
+ }
313
+ throw new Error(
314
+ `UserAPI request failed: ${status} ${status >= 200 && status < 300 ? "OK" : "Error"} - ${body.substring(0, 500)}${body.length > 500 ? "..." : ""}`
315
+ );
316
+ }
317
+ return response.data;
318
+ } catch (error) {
319
+ if (error.message?.includes("fetch failed") || error.message?.includes("ECONNREFUSED") || error.message?.includes("ENOTFOUND") || error.cause) {
320
+ const cause = error.cause?.message || error.cause || error.message;
321
+ throw new Error(
322
+ `Failed to connect to UserAPI at ${endpoint}: ${cause}
323
+ Please check:
324
+ 1. Your internet connection
325
+ 2. The API server is accessible: ${this.config.userApiServerURL}
326
+ 3. Firewall/proxy settings`
327
+ );
328
+ }
329
+ throw error;
330
+ }
331
+ }
332
+ async makeAuthenticatedRequest(url, permission) {
333
+ const headers = {
334
+ "x-client-id": this.clientId
335
+ };
336
+ if (permission && this.account) {
337
+ const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
338
+ const authHeaders = await this.generateAuthHeaders(permission, expiry);
339
+ Object.assign(headers, authHeaders);
340
+ }
341
+ try {
342
+ const response = await axios.get(url, {
343
+ headers,
344
+ maxRedirects: 0,
345
+ validateStatus: () => true
346
+ // Don't throw on any status
347
+ });
348
+ const status = response.status;
349
+ const statusText = status >= 200 && status < 300 ? "OK" : "Error";
350
+ if (status < 200 || status >= 300) {
351
+ const body = typeof response.data === "string" ? response.data : JSON.stringify(response.data);
352
+ throw new Error(`UserAPI request failed: ${status} ${statusText} - ${body}`);
353
+ }
354
+ return {
355
+ json: async () => response.data,
356
+ text: async () => typeof response.data === "string" ? response.data : JSON.stringify(response.data)
357
+ };
358
+ } catch (error) {
359
+ if (error.message?.includes("fetch failed") || error.message?.includes("ECONNREFUSED") || error.message?.includes("ENOTFOUND") || error.cause) {
360
+ const cause = error.cause?.message || error.cause || error.message;
361
+ throw new Error(
362
+ `Failed to connect to UserAPI at ${url}: ${cause}
363
+ Please check:
364
+ 1. Your internet connection
365
+ 2. The API server is accessible: ${this.config.userApiServerURL}
366
+ 3. Firewall/proxy settings`
367
+ );
368
+ }
369
+ throw error;
370
+ }
371
+ }
372
+ /**
373
+ * Generate authentication headers for UserAPI requests
374
+ */
375
+ async generateAuthHeaders(permission, expiry) {
376
+ if (!this.account) {
377
+ throw new Error("Private key required for authenticated requests");
378
+ }
379
+ if (!this.rpcUrl) {
380
+ throw new Error("RPC URL required for authenticated requests");
381
+ }
382
+ const chain = getChainFromID(this.config.chainID);
383
+ const publicClient = createPublicClient({
384
+ chain,
385
+ transport: http(this.rpcUrl)
386
+ });
387
+ const { signature } = await calculatePermissionSignature({
388
+ permission,
389
+ expiry,
390
+ appControllerAddress: this.config.appControllerAddress,
391
+ publicClient,
392
+ account: this.account
393
+ });
394
+ return {
395
+ Authorization: `Bearer ${stripHexPrefix(signature)}`,
396
+ "X-eigenx-expiry": expiry.toString()
397
+ };
398
+ }
399
+ };
400
+
401
+ // src/client/common/utils/billing.ts
402
+ function isSubscriptionActive(status) {
403
+ return status === "active" || status === "trialing";
404
+ }
405
+
406
+ // src/client/common/telemetry/noop.ts
407
+ var NoopClient = class {
408
+ /**
409
+ * AddMetric implements the TelemetryClient interface
410
+ */
411
+ async addMetric(_metric) {
412
+ }
413
+ /**
414
+ * Close implements the TelemetryClient interface
415
+ */
416
+ async close() {
417
+ }
418
+ };
419
+ function isNoopClient(client) {
420
+ return client instanceof NoopClient;
421
+ }
422
+
423
+ // src/client/common/telemetry/posthog.ts
424
+ import { PostHog } from "posthog-node";
425
+ var PostHogClient = class {
426
+ constructor(environment, namespace, apiKey, endpoint) {
427
+ this.namespace = namespace;
428
+ this.appEnvironment = environment;
429
+ const host = endpoint || "https://us.i.posthog.com";
430
+ this.client = new PostHog(apiKey, {
431
+ host,
432
+ flushAt: 1,
433
+ // Flush immediately for CLI/SDK usage
434
+ flushInterval: 0
435
+ // Disable interval flushing
436
+ });
437
+ this.client.identify({
438
+ distinctId: environment.userUUID,
439
+ properties: {
440
+ os: environment.os,
441
+ arch: environment.arch,
442
+ ...environment.cliVersion ? { cliVersion: environment.cliVersion } : {}
443
+ }
444
+ });
445
+ }
446
+ /**
447
+ * AddMetric implements the TelemetryClient interface
448
+ */
449
+ async addMetric(metric) {
450
+ try {
451
+ const props = {
452
+ name: metric.name,
453
+ value: metric.value
454
+ };
455
+ for (const [k, v] of Object.entries(metric.dimensions)) {
456
+ props[k] = v;
457
+ }
458
+ this.client.capture({
459
+ distinctId: this.appEnvironment.userUUID,
460
+ event: this.namespace,
461
+ properties: props
462
+ });
463
+ } catch {
464
+ }
465
+ }
466
+ /**
467
+ * Close implements the TelemetryClient interface
468
+ */
469
+ async close() {
470
+ try {
471
+ this.client.shutdown();
472
+ } catch {
473
+ }
474
+ }
475
+ };
476
+ function getPostHogAPIKey() {
477
+ if (process.env.ECLOUD_POSTHOG_KEY) {
478
+ return process.env.ECLOUD_POSTHOG_KEY;
479
+ }
480
+ return true ? "phc_BiKfywNft5iBI8N7MxmuVCkb4GGZj4mDFXYPmOPUAI8" : void 0;
481
+ }
482
+ function getPostHogEndpoint() {
483
+ return process.env.ECLOUD_POSTHOG_ENDPOINT || "https://us.i.posthog.com";
484
+ }
485
+
486
+ // src/client/common/telemetry/metricsContext.ts
487
+ function createMetricsContext() {
488
+ return {
489
+ startTime: /* @__PURE__ */ new Date(),
490
+ metrics: [],
491
+ properties: {}
492
+ };
493
+ }
494
+ function addMetric(context, name, value) {
495
+ addMetricWithDimensions(context, name, value, {});
496
+ }
497
+ function addMetricWithDimensions(context, name, value, dimensions) {
498
+ context.metrics.push({
499
+ name,
500
+ value,
501
+ dimensions
502
+ });
503
+ }
504
+
505
+ // src/client/common/telemetry/index.ts
506
+ import * as os from "os";
507
+
508
+ // src/client/common/telemetry/wrapper.ts
509
+ import { randomUUID } from "crypto";
510
+ function generateRandomUUID() {
511
+ return randomUUID();
512
+ }
513
+ async function withSDKTelemetry(options, action) {
514
+ if (options.skipTelemetry) {
515
+ return action();
516
+ }
517
+ const userUUID = options.userUUID || generateRandomUUID();
518
+ const environment = createAppEnvironment(userUUID);
519
+ const client = createTelemetryClient(environment, "ecloud-sdk", {
520
+ telemetryEnabled: options.telemetryEnabled,
521
+ apiKey: options.apiKey,
522
+ endpoint: options.endpoint
523
+ });
524
+ const metrics = createMetricsContext();
525
+ metrics.properties["source"] = "ecloud-sdk";
526
+ metrics.properties["function"] = options.functionName;
527
+ if (options.properties) {
528
+ Object.assign(metrics.properties, options.properties);
529
+ }
530
+ addMetric(metrics, "Count", 1);
531
+ let actionError;
532
+ let result;
533
+ try {
534
+ result = await action();
535
+ return result;
536
+ } catch (err) {
537
+ actionError = err instanceof Error ? err : new Error(String(err));
538
+ throw err;
539
+ } finally {
540
+ const resultValue = actionError ? "Failure" : "Success";
541
+ const dimensions = {};
542
+ if (actionError) {
543
+ dimensions["error"] = actionError.message;
544
+ }
545
+ addMetricWithDimensions(metrics, resultValue, 1, dimensions);
546
+ const duration = Date.now() - metrics.startTime.getTime();
547
+ addMetric(metrics, "DurationMilliseconds", duration);
548
+ try {
549
+ await emitMetrics(client, metrics);
550
+ await client.close();
551
+ } catch {
552
+ }
553
+ }
554
+ }
555
+
556
+ // src/client/common/telemetry/index.ts
557
+ function createTelemetryClient(environment, namespace, options) {
558
+ const telemetryEnabled = options?.telemetryEnabled === true;
559
+ if (!telemetryEnabled) {
560
+ return new NoopClient();
561
+ }
562
+ const resolvedApiKey = options?.apiKey || getPostHogAPIKey();
563
+ if (!resolvedApiKey) {
564
+ return new NoopClient();
565
+ }
566
+ const endpoint = options?.endpoint || getPostHogEndpoint();
567
+ try {
568
+ return new PostHogClient(environment, namespace, resolvedApiKey, endpoint);
569
+ } catch {
570
+ return new NoopClient();
571
+ }
572
+ }
573
+ function createAppEnvironment(userUUID, cliVersion, osOverride, archOverride) {
574
+ return {
575
+ userUUID,
576
+ cliVersion,
577
+ os: osOverride || os.platform(),
578
+ arch: archOverride || os.arch()
579
+ };
580
+ }
581
+ async function emitMetrics(client, context) {
582
+ if (isNoopClient(client)) {
583
+ return;
584
+ }
585
+ for (const metric of context.metrics) {
586
+ const dimensions = {
587
+ ...metric.dimensions,
588
+ ...context.properties
589
+ };
590
+ const metricWithProperties = {
591
+ ...metric,
592
+ dimensions
593
+ };
594
+ try {
595
+ await client.addMetric(metricWithProperties);
596
+ } catch {
597
+ }
598
+ }
599
+ }
600
+
601
+ // src/client/common/utils/logger.ts
602
+ var defaultLogger = {
603
+ info: (...args) => console.info(...args),
604
+ warn: (...args) => console.warn(...args),
605
+ error: (...args) => console.error(...args),
606
+ debug: (...args) => console.debug(...args)
607
+ };
608
+ var getLogger = (verbose) => ({
609
+ info: (...args) => console.info(...args),
610
+ warn: (...args) => console.warn(...args),
611
+ error: (...args) => console.error(...args),
612
+ debug: (...args) => verbose && console.debug(...args)
613
+ });
614
+
615
+ // src/client/common/utils/dirname.ts
616
+ import * as path from "path";
617
+ import { fileURLToPath } from "url";
618
+ function getDirname() {
619
+ if (typeof __dirname !== "undefined") {
620
+ return __dirname;
621
+ }
622
+ try {
623
+ const metaUrl = import.meta.url;
624
+ return path.dirname(fileURLToPath(metaUrl));
625
+ } catch {
626
+ return process.cwd();
627
+ }
628
+ }
629
+
630
+ export {
631
+ calculateBillingAuthSignature,
632
+ getEnvironmentConfig,
633
+ getBillingEnvironmentConfig,
634
+ getBuildType,
635
+ getAvailableEnvironments,
636
+ isEnvironmentAvailable,
637
+ isMainnet,
638
+ defaultLogger,
639
+ getLogger,
640
+ DOCKER_PLATFORM,
641
+ REGISTRY_PROPAGATION_WAIT_SECONDS,
642
+ LAYERED_DOCKERFILE_NAME,
643
+ ENV_SOURCE_SCRIPT_NAME,
644
+ KMS_CLIENT_BINARY_NAME,
645
+ KMS_SIGNING_KEY_NAME,
646
+ TLS_KEYGEN_BINARY_NAME,
647
+ CADDYFILE_NAME,
648
+ LAYERED_BUILD_DIR_PREFIX,
649
+ getChainFromID,
650
+ addHexPrefix,
651
+ stripHexPrefix,
652
+ UserApiClient,
653
+ getDirname,
654
+ isSubscriptionActive,
655
+ NoopClient,
656
+ isNoopClient,
657
+ PostHogClient,
658
+ getPostHogAPIKey,
659
+ getPostHogEndpoint,
660
+ createMetricsContext,
661
+ addMetric,
662
+ addMetricWithDimensions,
663
+ createTelemetryClient,
664
+ createAppEnvironment,
665
+ emitMetrics,
666
+ withSDKTelemetry
667
+ };
668
+ //# sourceMappingURL=chunk-6WSXUSKJ.js.map