@layr-labs/ecloud-sdk 0.1.1-dev → 0.2.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +2 -2
- package/dist/billing.cjs +0 -19
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +1 -2
- package/dist/billing.d.ts +1 -2
- package/dist/billing.js +2 -2
- package/dist/{chunk-AXSYVG7H.js → chunk-34DXGQ35.js} +106 -30
- package/dist/chunk-34DXGQ35.js.map +1 -0
- package/dist/{chunk-X4Y6OOUS.js → chunk-HLH3AMQF.js} +227 -2
- package/dist/chunk-HLH3AMQF.js.map +1 -0
- package/dist/chunk-LINGJMAS.js +180 -0
- package/dist/chunk-LINGJMAS.js.map +1 -0
- package/dist/compute.cjs +79 -1
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.js +2 -2
- package/dist/index.cjs +782 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +303 -86
- package/dist/index.d.ts +303 -86
- package/dist/index.js +616 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2R7M3OXI.js +0 -434
- package/dist/chunk-2R7M3OXI.js.map +0 -1
- package/dist/chunk-AXSYVG7H.js.map +0 -1
- package/dist/chunk-X4Y6OOUS.js.map +0 -1
package/VERSION
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
version=0.
|
|
2
|
-
commit=
|
|
1
|
+
version=0.2.0-dev
|
|
2
|
+
commit=e714b3eda5fb1e98d66e00798bdf2cf18cd03fed
|
package/dist/billing.cjs
CHANGED
|
@@ -242,23 +242,6 @@ function isSubscriptionActive(status) {
|
|
|
242
242
|
return status === "active" || status === "trialing";
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
// src/client/common/auth/keyring.ts
|
|
246
|
-
var import_keyring = require("@napi-rs/keyring");
|
|
247
|
-
var import_accounts3 = require("viem/accounts");
|
|
248
|
-
function getAddressFromPrivateKey(privateKey) {
|
|
249
|
-
const normalized = normalizePrivateKey(privateKey);
|
|
250
|
-
return (0, import_accounts3.privateKeyToAddress)(normalized);
|
|
251
|
-
}
|
|
252
|
-
function normalizePrivateKey(privateKey) {
|
|
253
|
-
if (!privateKey.startsWith("0x")) {
|
|
254
|
-
return `0x${privateKey}`;
|
|
255
|
-
}
|
|
256
|
-
return privateKey;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// src/client/common/auth/generate.ts
|
|
260
|
-
var import_accounts4 = require("viem/accounts");
|
|
261
|
-
|
|
262
245
|
// src/client/common/telemetry/noop.ts
|
|
263
246
|
var NoopClient = class {
|
|
264
247
|
/**
|
|
@@ -458,12 +441,10 @@ async function withSDKTelemetry(options, action) {
|
|
|
458
441
|
function createBillingModule(config) {
|
|
459
442
|
const { verbose = false, skipTelemetry = false } = config;
|
|
460
443
|
const privateKey = addHexPrefix(config.privateKey);
|
|
461
|
-
const address = getAddressFromPrivateKey(privateKey);
|
|
462
444
|
const logger = getLogger(verbose);
|
|
463
445
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
464
446
|
const billingApi = new BillingApiClient(billingEnvConfig, privateKey);
|
|
465
447
|
return {
|
|
466
|
-
address,
|
|
467
448
|
async subscribe(opts) {
|
|
468
449
|
return withSDKTelemetry(
|
|
469
450
|
{
|
package/dist/billing.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/billing.ts","../src/client/common/utils/billingapi.ts","../src/client/common/utils/auth.ts","../src/client/common/config/environment.ts","../src/client/common/utils/logger.ts","../src/client/common/utils/userapi.ts","../src/client/common/utils/helpers.ts","../src/client/common/constants.ts","../src/client/common/utils/billing.ts","../src/client/common/auth/keyring.ts","../src/client/common/auth/generate.ts","../src/client/common/telemetry/noop.ts","../src/client/common/telemetry/posthog.ts","../src/client/common/telemetry/index.ts","../src/client/common/telemetry/metricsContext.ts","../src/client/common/telemetry/wrapper.ts","../src/client/modules/billing/index.ts"],"sourcesContent":["/**\n * Billing module entry point\n *\n * Import from \"@layr-labs/ecloud-sdk/billing\" for direct access to billing module\n */\n\nexport * from \"./client/modules/billing\";\n","/**\n * BillingAPI Client to manage product subscriptions\n * Standalone client - does not depend on chain infrastructure\n */\n\nimport axios, { AxiosResponse } from \"axios\";\nimport { Hex } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { ProductID, CreateSubscriptionResponse, ProductSubscriptionResponse } from \"../types\";\nimport { calculateBillingAuthSignature } from \"./auth\";\nimport { BillingEnvironmentConfig } from \"../types\";\n\nexport class BillingApiClient {\n private readonly account: ReturnType<typeof privateKeyToAccount>;\n private readonly config: BillingEnvironmentConfig;\n\n constructor(config: BillingEnvironmentConfig, privateKey: Hex) {\n this.account = privateKeyToAccount(privateKey);\n this.config = config;\n }\n\n async createSubscription(productId: ProductID = \"compute\"): Promise<CreateSubscriptionResponse> {\n const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;\n const resp = await this.makeAuthenticatedRequest(endpoint, \"POST\", productId);\n return resp.json();\n }\n\n async getSubscription(productId: ProductID = \"compute\"): Promise<ProductSubscriptionResponse> {\n const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;\n const resp = await this.makeAuthenticatedRequest(endpoint, \"GET\", productId);\n return resp.json();\n }\n\n async cancelSubscription(productId: ProductID = \"compute\"): Promise<void> {\n const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;\n await this.makeAuthenticatedRequest(endpoint, \"DELETE\", productId);\n }\n\n /**\n * Make an authenticated request to the billing API\n */\n private async makeAuthenticatedRequest(\n url: string,\n method: \"GET\" | \"POST\" | \"DELETE\",\n productId: ProductID,\n ): Promise<{ json: () => Promise<any>; text: () => Promise<string> }> {\n // Calculate expiry (5 minutes from now)\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60);\n\n // Use EIP-712 typed data signature for billing auth\n const { signature } = await calculateBillingAuthSignature({\n account: this.account,\n product: productId,\n expiry,\n });\n\n // Prepare headers\n const headers: Record<string, string> = {\n Authorization: `Bearer ${signature}`,\n \"X-Account\": this.account.address,\n \"X-Expiry\": expiry.toString(),\n };\n\n try {\n // Use axios to make the request\n const response: AxiosResponse = await axios({\n method,\n url,\n headers,\n timeout: 30_000,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n });\n\n const status = response.status;\n const statusText = status >= 200 && status < 300 ? \"OK\" : \"Error\";\n\n if (status < 200 || status >= 300) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n throw new Error(`BillingAPI request failed: ${status} ${statusText} - ${body}`);\n }\n\n // Return Response-like object for compatibility\n return {\n json: async () => response.data,\n text: async () =>\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data),\n };\n } catch (error: any) {\n // Handle network errors\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to BillingAPI at ${url}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.billingApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n // Re-throw other errors as-is\n throw error;\n }\n }\n}\n","/**\n * Shared authentication utilities for API clients\n */\n\nimport { Hex, parseAbi, type Address } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createPublicClient } from \"viem\";\n\n// Minimal AppController ABI for permission calculation\nconst APP_CONTROLLER_ABI = parseAbi([\n \"function calculateApiPermissionDigestHash(bytes4 permission, uint256 expiry) view returns (bytes32)\",\n]);\n\nexport interface PermissionSignatureOptions {\n permission: Hex;\n expiry: bigint;\n appControllerAddress: Address;\n publicClient: ReturnType<typeof createPublicClient>;\n account: ReturnType<typeof privateKeyToAccount>;\n}\n\nexport interface PermissionSignatureResult {\n signature: string;\n digest: Hex;\n}\n\n/**\n * Calculate permission digest via AppController contract and sign it with EIP-191\n */\nexport async function calculatePermissionSignature(\n options: PermissionSignatureOptions,\n): Promise<PermissionSignatureResult> {\n const { permission, expiry, appControllerAddress, publicClient, account } = options;\n\n // Calculate permission digest hash using AppController contract\n const digest = (await publicClient.readContract({\n address: appControllerAddress,\n abi: APP_CONTROLLER_ABI,\n functionName: \"calculateApiPermissionDigestHash\",\n args: [permission, expiry],\n })) as Hex;\n\n // Sign the digest using EIP-191 (signMessage handles prefixing automatically)\n const signature = await account.signMessage({\n message: { raw: digest },\n });\n\n return { signature, digest };\n}\n\nexport interface BillingAuthSignatureOptions {\n account: ReturnType<typeof privateKeyToAccount>;\n product: string;\n expiry: bigint;\n}\n\nexport interface BillingAuthSignatureResult {\n signature: Hex;\n expiry: bigint;\n}\n\n/**\n * Sign billing authentication message using EIP-712 typed data\n */\nexport async function calculateBillingAuthSignature(\n options: BillingAuthSignatureOptions,\n): Promise<BillingAuthSignatureResult> {\n const { account, product, expiry } = options;\n\n // Sign using EIP-712 typed data\n const signature = await account.signTypedData({\n domain: {\n name: \"EigenCloud Billing API\",\n version: \"1\",\n },\n types: {\n BillingAuth: [\n { name: \"product\", type: \"string\" },\n { name: \"expiry\", type: \"uint256\" },\n ],\n },\n primaryType: \"BillingAuth\",\n message: {\n product,\n expiry,\n },\n });\n\n return { signature, expiry };\n}\n","/**\n * Environment configuration for different networks\n */\n\nimport { BillingEnvironmentConfig, EnvironmentConfig } from \"../types\";\n\n// Chain IDs\nexport const SEPOLIA_CHAIN_ID = 11155111;\nexport const MAINNET_CHAIN_ID = 1;\n\n// Common addresses across all chains\nexport const CommonAddresses: Record<string, string> = {\n ERC7702Delegator: \"0x63c0c19a282a1b52b07dd5a65b58948a07dae32b\",\n};\n\n// Addresses specific to each chain\nexport const ChainAddresses: Record<number, Record<string, string>> = {\n [MAINNET_CHAIN_ID]: {\n PermissionController: \"0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5\",\n },\n [SEPOLIA_CHAIN_ID]: {\n PermissionController: \"0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37\",\n },\n};\n\n// Billing environment configurations (separate from chain environments)\nconst BILLING_ENVIRONMENTS: Record<\"dev\" | \"prod\", BillingEnvironmentConfig> = {\n dev: {\n billingApiServerURL: \"https://billingapi-dev.eigencloud.xyz\",\n },\n prod: {\n billingApiServerURL: \"https://billingapi.eigencloud.xyz\",\n },\n};\n\n// Chain environment configurations\nconst ENVIRONMENTS: Record<string, Omit<EnvironmentConfig, \"chainID\">> = {\n \"sepolia-dev\": {\n name: \"sepolia\",\n build: \"dev\",\n appControllerAddress: \"0xa86DC1C47cb2518327fB4f9A1627F51966c83B92\",\n permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.0.57:8080\",\n userApiServerURL: \"https://userapi-compute-sepolia-dev.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-sepolia-rpc.publicnode.com\",\n },\n sepolia: {\n name: \"sepolia\",\n build: \"prod\",\n appControllerAddress: \"0x0dd810a6ffba6a9820a10d97b659f07d8d23d4E2\",\n permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.15.203:8080\",\n userApiServerURL: \"https://userapi-compute-sepolia-prod.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-sepolia-rpc.publicnode.com\",\n },\n \"mainnet-alpha\": {\n name: \"mainnet-alpha\",\n build: \"prod\",\n appControllerAddress: \"0xc38d35Fc995e75342A21CBd6D770305b142Fbe67\",\n permissionControllerAddress: ChainAddresses[MAINNET_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.0.2:8080\",\n userApiServerURL: \"https://userapi-compute.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-rpc.publicnode.com\",\n },\n};\n\nconst CHAIN_ID_TO_ENVIRONMENT: Record<string, string> = {\n [SEPOLIA_CHAIN_ID.toString()]: \"sepolia\",\n [MAINNET_CHAIN_ID.toString()]: \"mainnet-alpha\",\n};\n\n/**\n * Get environment configuration\n */\nexport function getEnvironmentConfig(environment: string, chainID?: bigint): EnvironmentConfig {\n const env = ENVIRONMENTS[environment];\n if (!env) {\n throw new Error(`Unknown environment: ${environment}`);\n }\n\n // Check if environment is available in current build\n if (!isEnvironmentAvailable(environment)) {\n throw new Error(\n `Environment ${environment} is not available in this build type. ` +\n `Available environments: ${getAvailableEnvironments().join(\", \")}`,\n );\n }\n\n // If chainID provided, validate it matches\n if (chainID) {\n const expectedEnv = CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];\n if (expectedEnv && expectedEnv !== environment) {\n throw new Error(`Environment ${environment} does not match chain ID ${chainID}`);\n }\n }\n\n // Determine chain ID from environment if not provided\n // Both \"sepolia\" and \"sepolia-dev\" use Sepolia chain ID\n const resolvedChainID =\n chainID ||\n (environment === \"sepolia\" || environment === \"sepolia-dev\"\n ? SEPOLIA_CHAIN_ID\n : MAINNET_CHAIN_ID);\n\n return {\n ...env,\n chainID: BigInt(resolvedChainID),\n };\n}\n\n/**\n * Get billing environment configuration\n * @param build - The build type (\"dev\" or \"prod\")\n */\nexport function getBillingEnvironmentConfig(build: \"dev\" | \"prod\"): {\n billingApiServerURL: string;\n} {\n const config = BILLING_ENVIRONMENTS[build];\n if (!config) {\n throw new Error(`Unknown billing environment: ${build}`);\n }\n return config;\n}\n\n/**\n * Detect environment from chain ID\n */\nexport function detectEnvironmentFromChainID(chainID: bigint): string | undefined {\n return CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];\n}\n\n/**\n * Get build type from environment variable or build-time constant (defaults to 'prod')\n * BUILD_TYPE_BUILD_TIME is replaced at build time by tsup's define option\n */\n// @ts-ignore - BUILD_TYPE_BUILD_TIME is injected at build time by tsup\ndeclare const BUILD_TYPE_BUILD_TIME: string | undefined;\n\nexport function getBuildType(): \"dev\" | \"prod\" {\n // First check build-time constant (set by tsup define)\n // @ts-ignore - BUILD_TYPE_BUILD_TIME is injected at build time\n const buildTimeType =\n typeof BUILD_TYPE_BUILD_TIME !== \"undefined\" ? BUILD_TYPE_BUILD_TIME?.toLowerCase() : undefined;\n\n // Fall back to runtime environment variable\n const runtimeType = process.env.BUILD_TYPE?.toLowerCase();\n\n const buildType = buildTimeType || runtimeType;\n\n if (buildType === \"dev\") {\n return \"dev\";\n }\n return \"prod\";\n}\n\n/**\n * Get available environments based on build type\n * - dev: only \"sepolia-dev\"\n * - prod: \"sepolia\" and \"mainnet-alpha\"\n */\nexport function getAvailableEnvironments(): string[] {\n const buildType = getBuildType();\n\n if (buildType === \"dev\") {\n return [\"sepolia-dev\"];\n }\n\n // prod build\n return [\"sepolia\", \"mainnet-alpha\"];\n}\n\n/**\n * Check if an environment is available in the current build\n */\nexport function isEnvironmentAvailable(environment: string): boolean {\n return getAvailableEnvironments().includes(environment);\n}\n\n/**\n * Check if environment is mainnet (chain ID 1)\n */\nexport function isMainnet(environmentConfig: EnvironmentConfig): boolean {\n return environmentConfig.chainID === BigInt(MAINNET_CHAIN_ID);\n}\n","/**\n * Default logger\n */\n\nimport { Logger } from \"../types\";\n\nexport const defaultLogger: Logger = {\n info: (...args) => console.info(...args),\n warn: (...args) => console.warn(...args),\n error: (...args) => console.error(...args),\n debug: (...args) => console.debug(...args),\n};\n\nexport const getLogger: (verbose?: boolean) => Logger = (verbose?: boolean) => ({\n info: (...args) => console.info(...args),\n warn: (...args) => console.warn(...args),\n error: (...args) => console.error(...args),\n debug: (...args) => verbose && console.debug(...args),\n});\n","/**\n * UserAPI Client to manage interactions with the coordinator\n */\n\nimport axios, { AxiosResponse } from \"axios\";\nimport FormData from \"form-data\";\nimport { Address, Hex, createPublicClient, http } from \"viem\";\nimport { calculatePermissionSignature } from \"./auth\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { EnvironmentConfig } from \"../types\";\nimport { addHexPrefix, stripHexPrefix, getChainFromID } from \"./helpers\";\n\nexport interface AppProfileInfo {\n name: string;\n website?: string;\n description?: string;\n xURL?: string;\n imageURL?: string;\n}\n\nexport interface AppMetrics {\n cpu_utilization_percent?: number;\n memory_utilization_percent?: number;\n memory_used_bytes?: number;\n memory_total_bytes?: number;\n}\n\nexport interface DerivedAddress {\n address: string;\n derivationPath: string;\n}\n\nexport interface AppInfo {\n address: Address;\n status: string;\n ip: string;\n machineType: string;\n profile?: AppProfileInfo;\n metrics?: AppMetrics;\n evmAddresses: DerivedAddress[];\n solanaAddresses: DerivedAddress[];\n}\n\nexport interface AppInfoResponse {\n apps: Array<{\n addresses: {\n data: {\n evmAddresses: DerivedAddress[];\n solanaAddresses: DerivedAddress[];\n };\n signature: string;\n };\n app_status: string;\n ip: string;\n machine_type: string;\n profile?: AppProfileInfo;\n metrics?: AppMetrics;\n }>;\n}\n\nconst MAX_ADDRESS_COUNT = 5;\n\n// Permission constants\nexport const CanViewAppLogsPermission = \"0x2fd3f2fe\" as Hex;\nexport const CanViewSensitiveAppInfoPermission = \"0x0e67b22f\" as Hex;\nexport const CanUpdateAppProfilePermission = \"0x036fef61\" as Hex;\n\n/**\n * SDK_VERSION_BUILD_TIME is replaced at build time by tsup's define option\n */\n// @ts-ignore - SDK_VERSION_BUILD_TIME is injected at build time by tsup\ndeclare const SDK_VERSION_BUILD_TIME: string | undefined;\n\n/**\n * Get the default client ID using the build-time version\n */\nfunction getDefaultClientId(): string {\n // @ts-ignore - SDK_VERSION_BUILD_TIME is injected at build time\n const version = typeof SDK_VERSION_BUILD_TIME !== \"undefined\" ? SDK_VERSION_BUILD_TIME : \"0.0.0\";\n return `ecloud-sdk/v${version}`;\n}\n\nexport class UserApiClient {\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n private readonly rpcUrl?: string;\n private readonly clientId: string;\n\n constructor(\n private readonly config: EnvironmentConfig,\n privateKey?: string | Hex,\n rpcUrl?: string,\n clientId?: string,\n ) {\n if (privateKey) {\n const privateKeyHex = addHexPrefix(privateKey);\n this.account = privateKeyToAccount(privateKeyHex);\n }\n this.rpcUrl = rpcUrl;\n this.clientId = clientId || getDefaultClientId();\n }\n\n async getInfos(appIDs: Address[], addressCount = 1): Promise<AppInfo[]> {\n const count = Math.min(addressCount, MAX_ADDRESS_COUNT);\n\n const endpoint = `${this.config.userApiServerURL}/info`;\n const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(\",\") })}`;\n\n const res = await this.makeAuthenticatedRequest(url, CanViewSensitiveAppInfoPermission);\n const result: AppInfoResponse = await res.json();\n\n // optional: verify signatures with KMS key\n // const { signingKey } = getKMSKeysForEnvironment(this.config.name);\n\n // Truncate without mutating the original object\n // API returns apps in the same order as the request, so use appIDs[i] as the address\n return result.apps.map((app, i) => {\n // TODO: Implement signature verification\n // const valid = await verifyKMSSignature(appInfo.addresses, signingKey);\n // if (!valid) {\n // throw new Error(`Invalid signature for app ${appIDs[i]}`);\n // }\n\n // Slice derived addresses to requested count\n const evmAddresses = app.addresses?.data?.evmAddresses?.slice(0, count) || [];\n const solanaAddresses = app.addresses?.data?.solanaAddresses?.slice(0, count) || [];\n\n return {\n address: appIDs[i] as Address,\n status: app.app_status,\n ip: app.ip,\n machineType: app.machine_type,\n profile: app.profile,\n metrics: app.metrics,\n evmAddresses,\n solanaAddresses,\n };\n });\n }\n\n /**\n * Get available SKUs (instance types) from UserAPI\n */\n async getSKUs(): Promise<{\n skus: Array<{ sku: string; description: string }>;\n }> {\n const endpoint = `${this.config.userApiServerURL}/skus`;\n const response = await this.makeAuthenticatedRequest(endpoint);\n\n const result = await response.json();\n\n // Transform response to match expected format\n return {\n skus: result.skus || result.SKUs || [],\n };\n }\n\n /**\n * Get logs for an app\n */\n async getLogs(appID: Address): Promise<string> {\n const endpoint = `${this.config.userApiServerURL}/logs/${appID}`;\n const response = await this.makeAuthenticatedRequest(endpoint, CanViewAppLogsPermission);\n return await response.text();\n }\n\n /**\n * Get statuses for apps\n */\n async getStatuses(appIDs: Address[]): Promise<Array<{ address: Address; status: string }>> {\n const endpoint = `${this.config.userApiServerURL}/status`;\n const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(\",\") })}`;\n const response = await this.makeAuthenticatedRequest(url);\n const result = await response.json();\n\n // Transform response to match expected format\n // The API returns an array of app statuses\n const apps = result.apps || result.Apps || [];\n return apps.map((app: any, i: number) => ({\n address: (app.address || appIDs[i]) as Address,\n status: app.status || app.Status || \"\",\n }));\n }\n\n /**\n * Upload app profile information with optional image\n */\n async uploadAppProfile(\n appAddress: Address,\n name: string,\n website?: string,\n description?: string,\n xURL?: string,\n imagePath?: string,\n ): Promise<{\n name: string;\n website?: string;\n description?: string;\n xURL?: string;\n imageURL?: string;\n }> {\n const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}/profile`;\n\n // Build multipart form data using form-data package\n const formData = new FormData();\n\n // Add required name field\n formData.append(\"name\", name);\n\n // Add optional text fields\n if (website) {\n formData.append(\"website\", website);\n }\n if (description) {\n formData.append(\"description\", description);\n }\n if (xURL) {\n formData.append(\"xURL\", xURL);\n }\n\n // Add optional image file\n if (imagePath) {\n const fs = await import(\"fs\");\n const path = await import(\"path\");\n const fileName = path.basename(imagePath);\n\n // Read file into buffer\n const fileBuffer = fs.readFileSync(imagePath);\n formData.append(\"image\", fileBuffer, fileName);\n }\n\n // Make authenticated POST request\n const headers: Record<string, string> = {\n \"x-client-id\": this.clientId,\n ...formData.getHeaders(),\n };\n\n // Add auth headers (Authorization and X-eigenx-expiry)\n if (this.account) {\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); // 5 minutes\n const authHeaders = await this.generateAuthHeaders(CanUpdateAppProfilePermission, expiry);\n Object.assign(headers, authHeaders);\n }\n\n try {\n // Use axios to post req\n const response: AxiosResponse = await axios.post(endpoint, formData, {\n headers,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n maxContentLength: Infinity, // Allow large file uploads\n maxBodyLength: Infinity, // Allow large file uploads\n });\n\n const status = response.status;\n\n if (status !== 200 && status !== 201) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n\n // Detect Cloudflare challenge page\n if (status === 403 && body.includes(\"Cloudflare\") && body.includes(\"challenge-platform\")) {\n throw new Error(\n `Cloudflare protection is blocking the request. This is likely due to bot detection.\\n` +\n `Status: ${status}`,\n );\n }\n\n throw new Error(\n `UserAPI request failed: ${status} ${status >= 200 && status < 300 ? \"OK\" : \"Error\"} - ${body.substring(0, 500)}${body.length > 500 ? \"...\" : \"\"}`,\n );\n }\n\n return response.data;\n } catch (error: any) {\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to UserAPI at ${endpoint}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.userApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n throw error;\n }\n }\n\n private async makeAuthenticatedRequest(\n url: string,\n permission?: Hex,\n ): Promise<{ json: () => Promise<any>; text: () => Promise<string> }> {\n const headers: Record<string, string> = {\n \"x-client-id\": this.clientId,\n };\n // Add auth headers if permission is specified\n if (permission && this.account) {\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); // 5 minutes\n const authHeaders = await this.generateAuthHeaders(permission, expiry);\n Object.assign(headers, authHeaders);\n }\n\n try {\n // Use axios to match\n const response: AxiosResponse = await axios.get(url, {\n headers,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n });\n\n const status = response.status;\n const statusText = status >= 200 && status < 300 ? \"OK\" : \"Error\";\n\n if (status < 200 || status >= 300) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n throw new Error(`UserAPI request failed: ${status} ${statusText} - ${body}`);\n }\n\n // Return Response-like object for compatibility\n return {\n json: async () => response.data,\n text: async () =>\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data),\n };\n } catch (error: any) {\n // Handle network errors (fetch failed, connection refused, etc.)\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to UserAPI at ${url}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.userApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n // Re-throw other errors as-is\n throw error;\n }\n }\n\n /**\n * Generate authentication headers for UserAPI requests\n */\n private async generateAuthHeaders(\n permission: Hex,\n expiry: bigint,\n ): Promise<Record<string, string>> {\n if (!this.account) {\n throw new Error(\"Private key required for authenticated requests\");\n }\n\n if (!this.rpcUrl) {\n throw new Error(\"RPC URL required for authenticated requests\");\n }\n\n const chain = getChainFromID(this.config.chainID);\n\n const publicClient = createPublicClient({\n chain,\n transport: http(this.rpcUrl),\n });\n\n // Calculate permission signature using shared auth utility\n const { signature } = await calculatePermissionSignature({\n permission,\n expiry,\n appControllerAddress: this.config.appControllerAddress as Address,\n publicClient,\n account: this.account,\n });\n\n // Return auth headers\n return {\n Authorization: `Bearer ${stripHexPrefix(signature)}`,\n \"X-eigenx-expiry\": expiry.toString(),\n };\n }\n}\n","/**\n * General utility helpers\n */\n\nimport { extractChain } from \"viem\";\nimport type { Chain } from \"viem\";\nimport { sepolia } from \"viem/chains\";\nimport { SUPPORTED_CHAINS } from \"../constants\";\n\n/**\n * Get a viem Chain object from a chain ID.\n * Supports mainnet (1) and sepolia (11155111), defaults to the fallback chain for unknown chains.\n */\nexport function getChainFromID(chainID: bigint, fallback: Chain = sepolia): Chain {\n const id = Number(chainID) as (typeof SUPPORTED_CHAINS)[number][\"id\"];\n return extractChain({ chains: SUPPORTED_CHAINS, id }) || fallback;\n}\n\n/**\n * Ensure hex string has 0x prefix\n */\nexport function addHexPrefix(value: string): `0x${string}` {\n return (value.startsWith(\"0x\") ? value : `0x${value}`) as `0x${string}`;\n}\n\n/**\n * Remove 0x prefix from hex string if present\n */\nexport function stripHexPrefix(value: string): string {\n return value.startsWith(\"0x\") ? value.slice(2) : value;\n}\n","/**\n * Constants used throughout the SDK\n */\n\nimport { sepolia, mainnet } from \"viem/chains\";\n\nexport const SUPPORTED_CHAINS = [mainnet, sepolia] as const;\n\nexport const DOCKER_PLATFORM = \"linux/amd64\";\nexport const REGISTRY_PROPAGATION_WAIT_SECONDS = 3;\nexport const LAYERED_DOCKERFILE_NAME = \"Dockerfile.eigencompute\";\nexport const ENV_SOURCE_SCRIPT_NAME = \"compute-source-env.sh\";\nexport const KMS_CLIENT_BINARY_NAME = \"kms-client\";\nexport const KMS_ENCRYPTION_KEY_NAME = \"kms-encryption-public-key.pem\";\nexport const KMS_SIGNING_KEY_NAME = \"kms-signing-public-key.pem\";\nexport const TLS_KEYGEN_BINARY_NAME = \"tls-keygen\";\nexport const CADDYFILE_NAME = \"Caddyfile\";\nexport const TEMP_IMAGE_PREFIX = \"ecloud-temp-\";\nexport const LAYERED_BUILD_DIR_PREFIX = \"ecloud-layered-build\";\nexport const SHA256_PREFIX = \"sha256:\";\nexport const JWT_FILE_PATH = \"/run/container_launcher/attestation_verifier_claims_token\";\n","/**\n * Billing utility functions\n */\n\nimport type { SubscriptionStatus } from \"../types\";\n\n/**\n * Check if subscription status allows deploying apps\n */\nexport function isSubscriptionActive(status: SubscriptionStatus): boolean {\n return status === \"active\" || status === \"trialing\";\n}\n","/**\n * OS Keyring Integration\n *\n * Provides secure storage for private keys using native OS keychains:\n * - macOS: Keychain\n * - Linux: Secret Service API (libsecret/gnome-keyring)\n * - Windows: Credential Manager\n *\n * Uses a single key for all environments.\n */\n\nimport { AsyncEntry, findCredentials } from \"@napi-rs/keyring\";\nimport { privateKeyToAddress } from \"viem/accounts\";\n\n// ecloud keyring identifiers\nconst SERVICE_NAME = \"ecloud\";\nconst ACCOUNT_NAME = \"key\"; // Single key for all environments\n\n// eigenx-cli keyring identifiers (for legacy key detection)\nconst EIGENX_SERVICE_NAME = \"eigenx-cli\";\nconst EIGENX_DEV_SERVICE_NAME = \"eigenx-cli-dev\";\nconst EIGENX_ACCOUNT_PREFIX = \"eigenx-\"; // eigenx-cli prefixes account names\n\n// go-keyring encoding constants (used by eigenx-cli on macOS)\nconst GO_KEYRING_BASE64_PREFIX = \"go-keyring-base64:\";\nconst GO_KEYRING_ENCODED_PREFIX = \"go-keyring-encoded:\"; // legacy hex encoding\n\nexport interface StoredKey {\n address: string;\n}\n\nexport interface LegacyKey {\n environment: string;\n address: string;\n source: \"eigenx\" | \"eigenx-dev\";\n}\n\n/**\n * Store a private key in OS keyring\n *\n * Note: Stores a single key for all environments.\n * The environment parameter is kept for API compatibility but is ignored.\n */\nexport async function storePrivateKey(privateKey: string): Promise<void> {\n // Validate private key format\n const normalizedKey = normalizePrivateKey(privateKey);\n\n // Validate by deriving address (will throw if invalid)\n const isValid = validatePrivateKey(normalizedKey);\n if (!isValid) {\n throw new Error(\"Invalid private key format\");\n }\n\n // Store in single-key format\n const entry = new AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);\n try {\n await entry.setPassword(normalizedKey);\n } catch (err: any) {\n throw new Error(\n `Failed to store key in OS keyring: ${err?.message ?? err}. Ensure keyring service is available.`,\n );\n }\n}\n\n/**\n * Get a private key from OS keyring\n *\n * Note: Returns the single stored key for all environments.\n * The environment parameter is kept for API compatibility but is ignored.\n */\nexport async function getPrivateKey(): Promise<`0x${string}` | null> {\n const entry = new AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);\n try {\n const key = await entry.getPassword();\n if (key && validatePrivateKey(key)) {\n return key as `0x${string}`;\n }\n } catch {\n // Key not found\n }\n\n return null;\n}\n\n/**\n * Delete a private key from OS keyring\n * Returns true if deletion was successful, false otherwise\n *\n * Note: Deletes the single stored key.\n * The environment parameter is kept for API compatibility but is ignored.\n */\nexport async function deletePrivateKey(): Promise<boolean> {\n const entry = new AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);\n try {\n await entry.deletePassword();\n return true;\n } catch {\n console.warn(\"No key found in keyring\");\n return false;\n }\n}\n\n/**\n * List all stored keys\n * Returns an array with the single stored key (if it exists)\n */\nexport async function listStoredKeys(): Promise<StoredKey[]> {\n const keys: StoredKey[] = [];\n\n const creds = findCredentials(SERVICE_NAME);\n for (const cred of creds) {\n if (cred.account === ACCOUNT_NAME) {\n try {\n const address = getAddressFromPrivateKey(cred.password as `0x${string}`);\n keys.push({ address });\n } catch (err) {\n console.warn(`Warning: Invalid key found, skipping: ${err}`);\n }\n }\n }\n\n return keys;\n}\n\n/**\n * Check if a key exists\n *\n * Note: Checks for the single stored key.\n * The environment parameter is kept for API compatibility but is ignored.\n */\nexport async function keyExists(): Promise<boolean> {\n const key = await getPrivateKey();\n return key !== null;\n}\n\n/**\n * Get legacy keys from eigenx-cli\n * Returns an array of keys found in eigenx-cli keyring formats\n */\nexport async function getLegacyKeys(): Promise<LegacyKey[]> {\n const keys: LegacyKey[] = [];\n\n // 1. Check eigenx-cli production keys\n try {\n const eigenxCreds = findCredentials(EIGENX_SERVICE_NAME);\n for (const cred of eigenxCreds) {\n // eigenx-cli stores keys with account name \"eigenx-<environment>\"\n // Strip the prefix to get the environment name\n const accountName = cred.account;\n if (!accountName.startsWith(EIGENX_ACCOUNT_PREFIX)) {\n continue; // Skip if it doesn't have the expected prefix\n }\n const environment = accountName.substring(EIGENX_ACCOUNT_PREFIX.length);\n\n try {\n // Decode go-keyring encoding (used on macOS)\n const decodedKey = decodeGoKeyringValue(cred.password);\n const address = getAddressFromPrivateKey(decodedKey as `0x${string}`);\n keys.push({ environment, address, source: \"eigenx\" });\n } catch (err) {\n console.warn(\n `Warning: Invalid key found for ${environment} (eigenx-cli), skipping: ${err}`,\n );\n }\n }\n } catch {\n // eigenx-cli service not found, that's ok\n }\n\n // 2. Check eigenx-cli dev keys\n try {\n const eigenxDevCreds = findCredentials(EIGENX_DEV_SERVICE_NAME);\n for (const cred of eigenxDevCreds) {\n // eigenx-cli stores keys with account name \"eigenx-<environment>\"\n // Strip the prefix to get the environment name\n const accountName = cred.account;\n if (!accountName.startsWith(EIGENX_ACCOUNT_PREFIX)) {\n continue; // Skip if it doesn't have the expected prefix\n }\n const environment = accountName.substring(EIGENX_ACCOUNT_PREFIX.length);\n\n try {\n // Decode go-keyring encoding (used on macOS)\n const decodedKey = decodeGoKeyringValue(cred.password);\n const address = getAddressFromPrivateKey(decodedKey as `0x${string}`);\n keys.push({ environment, address, source: \"eigenx-dev\" });\n } catch (err) {\n console.warn(\n `Warning: Invalid key found for ${environment} (eigenx-dev), skipping: ${err}`,\n );\n }\n }\n } catch {\n // eigenx-dev service not found, that's ok\n }\n\n return keys;\n}\n\n/**\n * Get a specific legacy private key from eigenx-cli keyring\n */\nexport async function getLegacyPrivateKey(\n environment: string,\n source: \"eigenx\" | \"eigenx-dev\",\n): Promise<string | null> {\n const serviceName = source === \"eigenx\" ? EIGENX_SERVICE_NAME : EIGENX_DEV_SERVICE_NAME;\n\n // eigenx-cli stores keys with account name \"eigenx-<environment>\"\n const accountName = EIGENX_ACCOUNT_PREFIX + environment;\n\n const entry = new AsyncEntry(serviceName, accountName);\n try {\n const rawKey = await entry.getPassword();\n if (rawKey) {\n // Decode go-keyring encoding (used on macOS)\n const decodedKey = decodeGoKeyringValue(rawKey);\n if (validatePrivateKey(decodedKey)) {\n return decodedKey;\n }\n }\n } catch {\n // Key not found\n }\n\n return null;\n}\n\n/**\n * Delete a specific legacy private key from eigenx-cli keyring\n * Returns true if deletion was successful, false otherwise\n */\nexport async function deleteLegacyPrivateKey(\n environment: string,\n source: \"eigenx\" | \"eigenx-dev\",\n): Promise<boolean> {\n const serviceName = source === \"eigenx\" ? EIGENX_SERVICE_NAME : EIGENX_DEV_SERVICE_NAME;\n\n // eigenx-cli stores keys with account name \"eigenx-<environment>\"\n const accountName = EIGENX_ACCOUNT_PREFIX + environment;\n\n const entry = new AsyncEntry(serviceName, accountName);\n try {\n await entry.deletePassword();\n return true;\n } catch {\n console.warn(`No key found for ${environment} in ${source}`);\n return false;\n }\n}\n\n/**\n * Validate private key format\n */\nexport function validatePrivateKey(privateKey: string): boolean {\n try {\n getAddressFromPrivateKey(privateKey);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Get address from private key\n */\nexport function getAddressFromPrivateKey(privateKey: string): string {\n const normalized = normalizePrivateKey(privateKey);\n return privateKeyToAddress(normalized);\n}\n\n/**\n * Decode go-keyring encoded values\n *\n * go-keyring (used by eigenx-cli) stores values with special encoding on macOS:\n * - \"go-keyring-base64:\" prefix + base64-encoded value\n * - \"go-keyring-encoded:\" prefix + hex-encoded value (legacy)\n *\n * This function detects and decodes these formats.\n */\nfunction decodeGoKeyringValue(rawValue: string): string {\n // Check for base64 encoding (primary format)\n if (rawValue.startsWith(GO_KEYRING_BASE64_PREFIX)) {\n const encoded = rawValue.substring(GO_KEYRING_BASE64_PREFIX.length);\n try {\n // Decode base64\n const decoded = Buffer.from(encoded, \"base64\").toString(\"utf8\");\n return decoded;\n } catch (err) {\n console.warn(`Warning: Failed to decode go-keyring base64 value: ${err}`);\n return rawValue; // Return as-is if decoding fails\n }\n }\n\n // Check for hex encoding (legacy format)\n if (rawValue.startsWith(GO_KEYRING_ENCODED_PREFIX)) {\n const encoded = rawValue.substring(GO_KEYRING_ENCODED_PREFIX.length);\n try {\n // Decode hex\n const decoded = Buffer.from(encoded, \"hex\").toString(\"utf8\");\n return decoded;\n } catch (err) {\n console.warn(`Warning: Failed to decode go-keyring hex value: ${err}`);\n return rawValue; // Return as-is if decoding fails\n }\n }\n\n // No encoding detected, return as-is\n return rawValue;\n}\n\n/**\n * Normalize private key (ensure 0x prefix)\n */\nfunction normalizePrivateKey(privateKey: string): `0x${string}` {\n if (!privateKey.startsWith(\"0x\")) {\n return `0x${privateKey}` as `0x${string}`;\n }\n return privateKey as `0x${string}`;\n}\n","/**\n * Private Key Generation\n *\n * Generate new secp256k1 private keys for Ethereum\n */\n\nimport { generatePrivateKey, privateKeyToAddress } from \"viem/accounts\";\n\nexport interface GeneratedKey {\n privateKey: string;\n address: string;\n}\n\n/**\n * Generate a new secp256k1 private key\n */\nexport function generateNewPrivateKey(): GeneratedKey {\n const privateKey = generatePrivateKey();\n const address = privateKeyToAddress(privateKey);\n\n return {\n privateKey,\n address,\n };\n}\n","/**\n * No-op telemetry client implementation\n */\n\nimport { TelemetryClient, Metric } from \"./types\";\n\n/**\n * NoopClient implements the TelemetryClient interface with no-op methods\n */\nexport class NoopClient implements TelemetryClient {\n /**\n * AddMetric implements the TelemetryClient interface\n */\n async addMetric(_metric: Metric): Promise<void> {\n // No-op\n }\n\n /**\n * Close implements the TelemetryClient interface\n */\n async close(): Promise<void> {\n // No-op\n }\n}\n\n/**\n * Check if a client is a NoopClient\n */\nexport function isNoopClient(client: TelemetryClient): boolean {\n return client instanceof NoopClient;\n}\n","/**\n * PostHog telemetry client implementation\n *\n * Uses the official posthog-node library\n */\n\nimport { PostHog } from \"posthog-node\";\nimport { TelemetryClient, Metric, AppEnvironment } from \"./types\";\n\n/**\n * PostHogClient implements the TelemetryClient interface using posthog-node\n */\nexport class PostHogClient implements TelemetryClient {\n private readonly client: PostHog;\n private readonly namespace: string;\n private readonly appEnvironment: AppEnvironment;\n\n constructor(environment: AppEnvironment, namespace: string, apiKey: string, endpoint?: string) {\n this.namespace = namespace;\n this.appEnvironment = environment;\n\n // Initialize PostHog client\n // posthog-node expects the full URL for the host option\n const host = endpoint || \"https://us.i.posthog.com\";\n\n this.client = new PostHog(apiKey, {\n host: host,\n flushAt: 1, // Flush immediately for CLI/SDK usage\n flushInterval: 0, // Disable interval flushing\n });\n\n // Identify the user with their UUID\n this.client.identify({\n distinctId: environment.userUUID,\n properties: {\n os: environment.os,\n arch: environment.arch,\n ...(environment.cliVersion ? { cliVersion: environment.cliVersion } : {}),\n },\n });\n }\n\n /**\n * AddMetric implements the TelemetryClient interface\n */\n async addMetric(metric: Metric): Promise<void> {\n // Never throw errors from telemetry operations\n try {\n // Create properties map starting with base properties\n const props: Record<string, any> = {\n name: metric.name,\n value: metric.value,\n };\n\n // Add metric dimensions\n for (const [k, v] of Object.entries(metric.dimensions)) {\n props[k] = v;\n }\n\n // Capture event using the namespace as the event name\n // With flushAt: 1, events are automatically flushed after each capture\n this.client.capture({\n distinctId: this.appEnvironment.userUUID,\n event: this.namespace,\n properties: props,\n });\n } catch {\n // Silently ignore telemetry errors\n }\n }\n\n /**\n * Close implements the TelemetryClient interface\n */\n async close(): Promise<void> {\n try {\n // Shutdown PostHog client and flush any pending events\n // shutdown() is synchronous but internally handles async cleanup\n this.client.shutdown();\n } catch {\n // Silently ignore errors during shutdown\n }\n }\n}\n\n/**\n * Embedded PostHog API key (can be exposed in TypeScript)\n * This can be set at build time or overridden via environment variable\n */\n// @ts-ignore - POSTHOG_API_KEY_BUILD_TIME is injected at build time by tsup\ndeclare const POSTHOG_API_KEY_BUILD_TIME: string | undefined;\n\n/**\n * Get PostHog API key from environment variable or build-time constant\n */\nexport function getPostHogAPIKey(): string | undefined {\n // Priority order:\n // 1. Environment variable\n // 2. Build-time constant (set at build time)\n // Check environment variable first\n if (process.env.ECLOUD_POSTHOG_KEY) {\n return process.env.ECLOUD_POSTHOG_KEY;\n }\n\n // Return build-time constant if available\n // @ts-ignore - POSTHOG_API_KEY_BUILD_TIME is injected at build time\n return typeof POSTHOG_API_KEY_BUILD_TIME !== \"undefined\" ? POSTHOG_API_KEY_BUILD_TIME : undefined;\n}\n\n/**\n * Get PostHog endpoint from environment variable or default\n */\nexport function getPostHogEndpoint(): string {\n return process.env.ECLOUD_POSTHOG_ENDPOINT || \"https://us.i.posthog.com\";\n}\n","/**\n * Telemetry module for ECloud SDK and CLI\n *\n * Provides telemetry functionality matching the Go implementation.\n * Supports both \"ecloud-cli\" and \"ecloud-sdk\" namespaces.\n */\n\nimport { TelemetryClient, Metric, AppEnvironment } from \"./types\";\nimport { NoopClient, isNoopClient } from \"./noop\";\nimport { PostHogClient, getPostHogAPIKey, getPostHogEndpoint } from \"./posthog\";\nimport * as os from \"os\";\n\nexport * from \"./types\";\nexport * from \"./metricsContext\";\nexport * from \"./noop\";\nexport * from \"./posthog\";\nexport * from \"./wrapper\";\n\n/**\n * Options for creating a telemetry client\n */\nexport interface TelemetryClientOptions {\n /**\n * Whether telemetry is enabled (only enabled if explicitly set to true, defaults to disabled)\n */\n telemetryEnabled?: boolean;\n /**\n * PostHog API key (if not provided, will check environment variables)\n */\n apiKey?: string;\n /**\n * PostHog endpoint (if not provided, will use default)\n */\n endpoint?: string;\n}\n\n/**\n * Create a telemetry client\n *\n * @param environment - Application environment information (must include userUUID)\n * @param namespace - Namespace for telemetry events (\"ecloud-cli\" or \"ecloud-sdk\")\n * @param options - Optional telemetry client options\n * @returns TelemetryClient instance (NoopClient if telemetry is disabled or no API key)\n */\nexport function createTelemetryClient(\n environment: AppEnvironment,\n namespace: \"ecloud-cli\" | \"ecloud-sdk\",\n options?: TelemetryClientOptions,\n): TelemetryClient {\n // Check if telemetry is enabled\n // Only enabled if explicitly set to true\n // If undefined or false, telemetry is disabled\n const telemetryEnabled = options?.telemetryEnabled === true;\n\n // If telemetry is disabled, return noop client\n if (!telemetryEnabled) {\n return new NoopClient();\n }\n\n // Get API key from options, environment variable, or return noop\n const resolvedApiKey = options?.apiKey || getPostHogAPIKey();\n if (!resolvedApiKey) {\n // No API key available, return noop client\n return new NoopClient();\n }\n\n // Get endpoint from options or environment variable\n const endpoint = options?.endpoint || getPostHogEndpoint();\n\n try {\n return new PostHogClient(environment, namespace, resolvedApiKey, endpoint);\n } catch {\n // If initialization fails, return noop client\n return new NoopClient();\n }\n}\n\n/**\n * Create an AppEnvironment from current system information\n *\n * @param userUUID - User UUID for identification (required - no I/O in SDK)\n * @param cliVersion - Optional CLI version (for CLI usage)\n * @param osOverride - Optional OS override (defaults to current platform)\n * @param archOverride - Optional architecture override (defaults to current architecture)\n * @returns AppEnvironment with user UUID, OS, and architecture\n */\nexport function createAppEnvironment(\n userUUID: string,\n cliVersion?: string,\n osOverride?: string,\n archOverride?: string,\n): AppEnvironment {\n return {\n userUUID,\n cliVersion,\n os: osOverride || os.platform(),\n arch: archOverride || os.arch(),\n };\n}\n\n/**\n * Emit metrics from a metrics context\n *\n * @param client - Telemetry client to use\n * @param context - Metrics context containing metrics to emit\n * @returns Promise that resolves when all metrics are emitted\n */\nexport async function emitMetrics(\n client: TelemetryClient,\n context: {\n metrics: Metric[];\n properties: Record<string, string>;\n },\n): Promise<void> {\n if (isNoopClient(client)) {\n return;\n }\n\n // Emit each metric with properties merged into dimensions\n for (const metric of context.metrics) {\n const dimensions = {\n ...metric.dimensions,\n ...context.properties,\n };\n\n const metricWithProperties: Metric = {\n ...metric,\n dimensions,\n };\n\n try {\n await client.addMetric(metricWithProperties);\n } catch {\n // Silently ignore telemetry errors\n }\n }\n}\n","/**\n * MetricsContext management\n */\n\nimport { MetricsContext } from \"./types\";\n\n/**\n * Create a new metrics context\n */\nexport function createMetricsContext(): MetricsContext {\n return {\n startTime: new Date(),\n metrics: [],\n properties: {},\n };\n}\n\n/**\n * Add a metric to the context without dimensions\n */\nexport function addMetric(context: MetricsContext, name: string, value: number): void {\n addMetricWithDimensions(context, name, value, {});\n}\n\n/**\n * Add a metric to the context with dimensions\n */\nexport function addMetricWithDimensions(\n context: MetricsContext,\n name: string,\n value: number,\n dimensions: Record<string, string>,\n): void {\n context.metrics.push({\n name,\n value,\n dimensions,\n });\n}\n","/**\n * Telemetry wrapper utilities for SDK functions\n *\n * Provides helpers to wrap SDK function execution with telemetry tracking\n */\n\nimport {\n createTelemetryClient,\n createAppEnvironment,\n createMetricsContext,\n addMetric,\n addMetricWithDimensions,\n emitMetrics,\n} from \"./index\";\nimport { randomUUID } from \"crypto\";\n\n/**\n * Generate a random UUID for telemetry identification\n * Used when userUUID is not provided (SDK usage outside CLI)\n */\nfunction generateRandomUUID(): string {\n return randomUUID();\n}\n\n/**\n * Options for telemetry wrapper\n */\nexport interface TelemetryWrapperOptions {\n /**\n * Function name for telemetry (e.g., \"deploy\", \"upgrade\", \"createApp\")\n */\n functionName: string;\n /**\n * Skip telemetry if true (used when called from CLI)\n */\n skipTelemetry?: boolean;\n /**\n * Additional properties to include in telemetry\n */\n properties?: Record<string, string>;\n /**\n * User UUID for identification (required if skipTelemetry is false)\n * If not provided and telemetry is enabled, will generate a random UUID for this session\n */\n userUUID?: string;\n /**\n * Whether telemetry is enabled (defaults to true if not provided)\n */\n telemetryEnabled?: boolean;\n /**\n * PostHog API key (optional, will check environment variables if not provided)\n */\n apiKey?: string;\n /**\n * PostHog endpoint (optional, will use default if not provided)\n */\n endpoint?: string;\n}\n\n/**\n * Wrap a function execution with telemetry\n *\n * @param options - Telemetry wrapper options\n * @param action - The function to execute\n * @returns The result of the action\n */\nexport async function withSDKTelemetry<T>(\n options: TelemetryWrapperOptions,\n action: () => Promise<T>,\n): Promise<T> {\n // Skip telemetry if requested (e.g., when called from CLI)\n if (options.skipTelemetry) {\n return action();\n }\n\n // Generate a random UUID if not provided (for SDK usage outside CLI)\n // This ensures each SDK session has a unique identifier\n const userUUID = options.userUUID || generateRandomUUID();\n\n const environment = createAppEnvironment(userUUID);\n const client = createTelemetryClient(environment, \"ecloud-sdk\", {\n telemetryEnabled: options.telemetryEnabled,\n apiKey: options.apiKey,\n endpoint: options.endpoint,\n });\n const metrics = createMetricsContext();\n\n // Set source to identify SDK usage\n metrics.properties[\"source\"] = \"ecloud-sdk\";\n\n // Set function name in properties\n metrics.properties[\"function\"] = options.functionName;\n\n // Add any additional properties\n if (options.properties) {\n Object.assign(metrics.properties, options.properties);\n }\n\n // Add initial count metric\n addMetric(metrics, \"Count\", 1);\n\n let actionError: Error | undefined;\n let result: T;\n\n try {\n result = await action();\n return result;\n } catch (err) {\n actionError = err instanceof Error ? err : new Error(String(err));\n throw err;\n } finally {\n // Add result metric\n const resultValue = actionError ? \"Failure\" : \"Success\";\n const dimensions: Record<string, string> = {};\n if (actionError) {\n dimensions[\"error\"] = actionError.message;\n }\n addMetricWithDimensions(metrics, resultValue, 1, dimensions);\n\n // Add duration metric\n const duration = Date.now() - metrics.startTime.getTime();\n addMetric(metrics, \"DurationMilliseconds\", duration);\n\n // Emit all metrics\n try {\n await emitMetrics(client, metrics);\n await client.close();\n } catch {\n // Silently ignore telemetry errors\n }\n }\n}\n","/**\n * Main Billing namespace entry point\n */\n\nimport { BillingApiClient } from \"../../common/utils/billingapi\";\nimport { getBillingEnvironmentConfig, getBuildType } from \"../../common/config/environment\";\nimport { getLogger, isSubscriptionActive, addHexPrefix } from \"../../common/utils\";\nimport { getAddressFromPrivateKey } from \"../../common/auth\";\nimport { withSDKTelemetry } from \"../../common/telemetry/wrapper\";\n\nimport type { Address, Hex } from \"viem\";\nimport type {\n ProductID,\n SubscriptionOpts,\n SubscribeResponse,\n CancelResponse,\n ProductSubscriptionResponse,\n} from \"../../common/types\";\n\nexport interface BillingModule {\n address: Address;\n subscribe: (opts?: SubscriptionOpts) => Promise<SubscribeResponse>;\n getStatus: (opts?: SubscriptionOpts) => Promise<ProductSubscriptionResponse>;\n cancel: (opts?: SubscriptionOpts) => Promise<CancelResponse>;\n}\n\nexport interface BillingModuleConfig {\n verbose?: boolean;\n privateKey: Hex;\n skipTelemetry?: boolean; // Skip telemetry when called from CLI\n}\n\nexport function createBillingModule(config: BillingModuleConfig): BillingModule {\n const { verbose = false, skipTelemetry = false } = config;\n const privateKey = addHexPrefix(config.privateKey);\n const address = getAddressFromPrivateKey(privateKey) as Address;\n\n const logger = getLogger(verbose);\n\n // Get billing environment configuration\n const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());\n\n // Create billing API client\n const billingApi = new BillingApiClient(billingEnvConfig, privateKey);\n\n return {\n address,\n async subscribe(opts) {\n return withSDKTelemetry(\n {\n functionName: \"subscribe\",\n skipTelemetry: skipTelemetry, // Skip if called from CLI\n properties: { productId: opts?.productId || \"compute\" },\n },\n async () => {\n const productId: ProductID = opts?.productId || \"compute\";\n\n // Check existing subscription status first\n logger.debug(`Checking existing subscription for ${productId}...`);\n const currentStatus = await billingApi.getSubscription(productId);\n\n // If already active or trialing, don't create new checkout\n if (isSubscriptionActive(currentStatus.subscriptionStatus)) {\n logger.debug(`Subscription already active: ${currentStatus.subscriptionStatus}`);\n return {\n type: \"already_active\" as const,\n status: currentStatus.subscriptionStatus,\n };\n }\n\n // If subscription has payment issues, return portal URL instead\n if (\n currentStatus.subscriptionStatus === \"past_due\" ||\n currentStatus.subscriptionStatus === \"unpaid\"\n ) {\n logger.debug(`Subscription has payment issue: ${currentStatus.subscriptionStatus}`);\n return {\n type: \"payment_issue\" as const,\n status: currentStatus.subscriptionStatus,\n portalUrl: currentStatus.portalUrl,\n };\n }\n\n // Create new checkout session\n logger.debug(`Creating subscription for ${productId}...`);\n const result = await billingApi.createSubscription(productId);\n\n logger.debug(`Checkout URL: ${result.checkoutUrl}`);\n return {\n type: \"checkout_created\" as const,\n checkoutUrl: result.checkoutUrl,\n };\n },\n );\n },\n\n async getStatus(opts) {\n return withSDKTelemetry(\n {\n functionName: \"getStatus\",\n skipTelemetry: skipTelemetry, // Skip if called from CLI\n properties: { productId: opts?.productId || \"compute\" },\n },\n async () => {\n const productId: ProductID = opts?.productId || \"compute\";\n logger.debug(`Fetching subscription status for ${productId}...`);\n\n const result = await billingApi.getSubscription(productId);\n\n logger.debug(`Subscription status: ${result.subscriptionStatus}`);\n return result;\n },\n );\n },\n\n async cancel(opts) {\n return withSDKTelemetry(\n {\n functionName: \"cancel\",\n skipTelemetry: skipTelemetry, // Skip if called from CLI\n properties: { productId: opts?.productId || \"compute\" },\n },\n async () => {\n const productId: ProductID = opts?.productId || \"compute\";\n\n // Check existing subscription status first\n logger.debug(`Checking subscription status for ${productId}...`);\n const currentStatus = await billingApi.getSubscription(productId);\n\n // If no active subscription, don't attempt to cancel\n if (!isSubscriptionActive(currentStatus.subscriptionStatus)) {\n logger.debug(`No active subscription to cancel: ${currentStatus.subscriptionStatus}`);\n return {\n type: \"no_active_subscription\" as const,\n status: currentStatus.subscriptionStatus,\n };\n }\n\n // Cancel the subscription\n logger.debug(`Canceling subscription for ${productId}...`);\n await billingApi.cancelSubscription(productId);\n\n logger.debug(`Subscription canceled successfully`);\n return {\n type: \"canceled\" as const,\n };\n },\n );\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,mBAAqC;AAErC,sBAAoC;;;ACHpC,kBAA4C;AAK5C,IAAM,yBAAqB,sBAAS;AAAA,EAClC;AACF,CAAC;AAqDD,eAAsB,8BACpB,SACqC;AACrC,QAAM,EAAE,SAAS,SAAS,OAAO,IAAI;AAGrC,QAAM,YAAY,MAAM,QAAQ,cAAc;AAAA,IAC5C,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,OAAO;AAAA,MACL,aAAa;AAAA,QACX,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,QAClC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,MACpC;AAAA,IACF;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,EAAE,WAAW,OAAO;AAC7B;;;AD7EO,IAAM,mBAAN,MAAuB;AAAA,EAI5B,YAAY,QAAkC,YAAiB;AAC7D,SAAK,cAAU,qCAAoB,UAAU;AAC7C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,mBAAmB,YAAuB,WAAgD;AAC9F,UAAM,WAAW,GAAG,KAAK,OAAO,mBAAmB,aAAa,SAAS;AACzE,UAAM,OAAO,MAAM,KAAK,yBAAyB,UAAU,QAAQ,SAAS;AAC5E,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,MAAM,gBAAgB,YAAuB,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E7C,iBAAO,MAAM,oCAAoC;AACjD,iBAAO;AAAA,YACL,MAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["axios","import_axios","import_viem","import_accounts","import_viem","import_chains","import_accounts","import_accounts"]}
|
|
1
|
+
{"version":3,"sources":["../src/billing.ts","../src/client/common/utils/billingapi.ts","../src/client/common/utils/auth.ts","../src/client/common/config/environment.ts","../src/client/common/utils/logger.ts","../src/client/common/utils/userapi.ts","../src/client/common/utils/helpers.ts","../src/client/common/constants.ts","../src/client/common/utils/billing.ts","../src/client/common/telemetry/noop.ts","../src/client/common/telemetry/posthog.ts","../src/client/common/telemetry/index.ts","../src/client/common/telemetry/metricsContext.ts","../src/client/common/telemetry/wrapper.ts","../src/client/modules/billing/index.ts"],"sourcesContent":["/**\n * Billing module entry point\n *\n * Import from \"@layr-labs/ecloud-sdk/billing\" for direct access to billing module\n */\n\nexport * from \"./client/modules/billing\";\n","/**\n * BillingAPI Client to manage product subscriptions\n * Standalone client - does not depend on chain infrastructure\n */\n\nimport axios, { AxiosResponse } from \"axios\";\nimport { Hex } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { ProductID, CreateSubscriptionResponse, ProductSubscriptionResponse } from \"../types\";\nimport { calculateBillingAuthSignature } from \"./auth\";\nimport { BillingEnvironmentConfig } from \"../types\";\n\nexport class BillingApiClient {\n private readonly account: ReturnType<typeof privateKeyToAccount>;\n private readonly config: BillingEnvironmentConfig;\n\n constructor(config: BillingEnvironmentConfig, privateKey: Hex) {\n this.account = privateKeyToAccount(privateKey);\n this.config = config;\n }\n\n async createSubscription(productId: ProductID = \"compute\"): Promise<CreateSubscriptionResponse> {\n const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;\n const resp = await this.makeAuthenticatedRequest(endpoint, \"POST\", productId);\n return resp.json();\n }\n\n async getSubscription(productId: ProductID = \"compute\"): Promise<ProductSubscriptionResponse> {\n const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;\n const resp = await this.makeAuthenticatedRequest(endpoint, \"GET\", productId);\n return resp.json();\n }\n\n async cancelSubscription(productId: ProductID = \"compute\"): Promise<void> {\n const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;\n await this.makeAuthenticatedRequest(endpoint, \"DELETE\", productId);\n }\n\n /**\n * Make an authenticated request to the billing API\n */\n private async makeAuthenticatedRequest(\n url: string,\n method: \"GET\" | \"POST\" | \"DELETE\",\n productId: ProductID,\n ): Promise<{ json: () => Promise<any>; text: () => Promise<string> }> {\n // Calculate expiry (5 minutes from now)\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60);\n\n // Use EIP-712 typed data signature for billing auth\n const { signature } = await calculateBillingAuthSignature({\n account: this.account,\n product: productId,\n expiry,\n });\n\n // Prepare headers\n const headers: Record<string, string> = {\n Authorization: `Bearer ${signature}`,\n \"X-Account\": this.account.address,\n \"X-Expiry\": expiry.toString(),\n };\n\n try {\n // Use axios to make the request\n const response: AxiosResponse = await axios({\n method,\n url,\n headers,\n timeout: 30_000,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n });\n\n const status = response.status;\n const statusText = status >= 200 && status < 300 ? \"OK\" : \"Error\";\n\n if (status < 200 || status >= 300) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n throw new Error(`BillingAPI request failed: ${status} ${statusText} - ${body}`);\n }\n\n // Return Response-like object for compatibility\n return {\n json: async () => response.data,\n text: async () =>\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data),\n };\n } catch (error: any) {\n // Handle network errors\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to BillingAPI at ${url}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.billingApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n // Re-throw other errors as-is\n throw error;\n }\n }\n}\n","/**\n * Shared authentication utilities for API clients\n */\n\nimport { Hex, parseAbi, type Address } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createPublicClient } from \"viem\";\n\n// Minimal AppController ABI for permission calculation\nconst APP_CONTROLLER_ABI = parseAbi([\n \"function calculateApiPermissionDigestHash(bytes4 permission, uint256 expiry) view returns (bytes32)\",\n]);\n\nexport interface PermissionSignatureOptions {\n permission: Hex;\n expiry: bigint;\n appControllerAddress: Address;\n publicClient: ReturnType<typeof createPublicClient>;\n account: ReturnType<typeof privateKeyToAccount>;\n}\n\nexport interface PermissionSignatureResult {\n signature: string;\n digest: Hex;\n}\n\n/**\n * Calculate permission digest via AppController contract and sign it with EIP-191\n */\nexport async function calculatePermissionSignature(\n options: PermissionSignatureOptions,\n): Promise<PermissionSignatureResult> {\n const { permission, expiry, appControllerAddress, publicClient, account } = options;\n\n // Calculate permission digest hash using AppController contract\n const digest = (await publicClient.readContract({\n address: appControllerAddress,\n abi: APP_CONTROLLER_ABI,\n functionName: \"calculateApiPermissionDigestHash\",\n args: [permission, expiry],\n })) as Hex;\n\n // Sign the digest using EIP-191 (signMessage handles prefixing automatically)\n const signature = await account.signMessage({\n message: { raw: digest },\n });\n\n return { signature, digest };\n}\n\nexport interface BillingAuthSignatureOptions {\n account: ReturnType<typeof privateKeyToAccount>;\n product: string;\n expiry: bigint;\n}\n\nexport interface BillingAuthSignatureResult {\n signature: Hex;\n expiry: bigint;\n}\n\n/**\n * Sign billing authentication message using EIP-712 typed data\n */\nexport async function calculateBillingAuthSignature(\n options: BillingAuthSignatureOptions,\n): Promise<BillingAuthSignatureResult> {\n const { account, product, expiry } = options;\n\n // Sign using EIP-712 typed data\n const signature = await account.signTypedData({\n domain: {\n name: \"EigenCloud Billing API\",\n version: \"1\",\n },\n types: {\n BillingAuth: [\n { name: \"product\", type: \"string\" },\n { name: \"expiry\", type: \"uint256\" },\n ],\n },\n primaryType: \"BillingAuth\",\n message: {\n product,\n expiry,\n },\n });\n\n return { signature, expiry };\n}\n\nexport interface BuildAuthSignatureOptions {\n account: ReturnType<typeof privateKeyToAccount>;\n expiry: bigint;\n}\n\nexport interface BuildAuthSignatureResult {\n signature: Hex;\n expiry: bigint;\n}\n\n/**\n * Sign build authentication message using EIP-712 typed data\n */\nexport async function calculateBuildAuthSignature(\n options: BuildAuthSignatureOptions,\n): Promise<BuildAuthSignatureResult> {\n const { account, expiry } = options;\n\n const signature = await account.signTypedData({\n domain: {\n name: \"EigenCloud Build API\",\n version: \"1\",\n },\n types: {\n BuildAuth: [{ name: \"expiry\", type: \"uint256\" }],\n },\n primaryType: \"BuildAuth\",\n message: {\n expiry,\n },\n });\n\n return { signature, expiry };\n}\n","/**\n * Environment configuration for different networks\n */\n\nimport { BillingEnvironmentConfig, EnvironmentConfig } from \"../types\";\n\n// Chain IDs\nexport const SEPOLIA_CHAIN_ID = 11155111;\nexport const MAINNET_CHAIN_ID = 1;\n\n// Common addresses across all chains\nexport const CommonAddresses: Record<string, string> = {\n ERC7702Delegator: \"0x63c0c19a282a1b52b07dd5a65b58948a07dae32b\",\n};\n\n// Addresses specific to each chain\nexport const ChainAddresses: Record<number, Record<string, string>> = {\n [MAINNET_CHAIN_ID]: {\n PermissionController: \"0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5\",\n },\n [SEPOLIA_CHAIN_ID]: {\n PermissionController: \"0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37\",\n },\n};\n\n// Billing environment configurations (separate from chain environments)\nconst BILLING_ENVIRONMENTS: Record<\"dev\" | \"prod\", BillingEnvironmentConfig> = {\n dev: {\n billingApiServerURL: \"https://billingapi-dev.eigencloud.xyz\",\n },\n prod: {\n billingApiServerURL: \"https://billingapi.eigencloud.xyz\",\n },\n};\n\n// Chain environment configurations\nconst ENVIRONMENTS: Record<string, Omit<EnvironmentConfig, \"chainID\">> = {\n \"sepolia-dev\": {\n name: \"sepolia\",\n build: \"dev\",\n appControllerAddress: \"0xa86DC1C47cb2518327fB4f9A1627F51966c83B92\",\n permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.0.57:8080\",\n userApiServerURL: \"https://userapi-compute-sepolia-dev.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-sepolia-rpc.publicnode.com\",\n },\n sepolia: {\n name: \"sepolia\",\n build: \"prod\",\n appControllerAddress: \"0x0dd810a6ffba6a9820a10d97b659f07d8d23d4E2\",\n permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.15.203:8080\",\n userApiServerURL: \"https://userapi-compute-sepolia-prod.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-sepolia-rpc.publicnode.com\",\n },\n \"mainnet-alpha\": {\n name: \"mainnet-alpha\",\n build: \"prod\",\n appControllerAddress: \"0xc38d35Fc995e75342A21CBd6D770305b142Fbe67\",\n permissionControllerAddress: ChainAddresses[MAINNET_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.0.2:8080\",\n userApiServerURL: \"https://userapi-compute.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-rpc.publicnode.com\",\n },\n};\n\nconst CHAIN_ID_TO_ENVIRONMENT: Record<string, string> = {\n [SEPOLIA_CHAIN_ID.toString()]: \"sepolia\",\n [MAINNET_CHAIN_ID.toString()]: \"mainnet-alpha\",\n};\n\n/**\n * Get environment configuration\n */\nexport function getEnvironmentConfig(environment: string, chainID?: bigint): EnvironmentConfig {\n const env = ENVIRONMENTS[environment];\n if (!env) {\n throw new Error(`Unknown environment: ${environment}`);\n }\n\n // Check if environment is available in current build\n if (!isEnvironmentAvailable(environment)) {\n throw new Error(\n `Environment ${environment} is not available in this build type. ` +\n `Available environments: ${getAvailableEnvironments().join(\", \")}`,\n );\n }\n\n // If chainID provided, validate it matches\n if (chainID) {\n const expectedEnv = CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];\n if (expectedEnv && expectedEnv !== environment) {\n throw new Error(`Environment ${environment} does not match chain ID ${chainID}`);\n }\n }\n\n // Determine chain ID from environment if not provided\n // Both \"sepolia\" and \"sepolia-dev\" use Sepolia chain ID\n const resolvedChainID =\n chainID ||\n (environment === \"sepolia\" || environment === \"sepolia-dev\"\n ? SEPOLIA_CHAIN_ID\n : MAINNET_CHAIN_ID);\n\n return {\n ...env,\n chainID: BigInt(resolvedChainID),\n };\n}\n\n/**\n * Get billing environment configuration\n * @param build - The build type (\"dev\" or \"prod\")\n */\nexport function getBillingEnvironmentConfig(build: \"dev\" | \"prod\"): {\n billingApiServerURL: string;\n} {\n const config = BILLING_ENVIRONMENTS[build];\n if (!config) {\n throw new Error(`Unknown billing environment: ${build}`);\n }\n return config;\n}\n\n/**\n * Detect environment from chain ID\n */\nexport function detectEnvironmentFromChainID(chainID: bigint): string | undefined {\n return CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];\n}\n\n/**\n * Get build type from environment variable or build-time constant (defaults to 'prod')\n * BUILD_TYPE_BUILD_TIME is replaced at build time by tsup's define option\n */\n// @ts-ignore - BUILD_TYPE_BUILD_TIME is injected at build time by tsup\ndeclare const BUILD_TYPE_BUILD_TIME: string | undefined;\n\nexport function getBuildType(): \"dev\" | \"prod\" {\n // First check build-time constant (set by tsup define)\n // @ts-ignore - BUILD_TYPE_BUILD_TIME is injected at build time\n const buildTimeType =\n typeof BUILD_TYPE_BUILD_TIME !== \"undefined\" ? BUILD_TYPE_BUILD_TIME?.toLowerCase() : undefined;\n\n // Fall back to runtime environment variable\n const runtimeType = process.env.BUILD_TYPE?.toLowerCase();\n\n const buildType = buildTimeType || runtimeType;\n\n if (buildType === \"dev\") {\n return \"dev\";\n }\n return \"prod\";\n}\n\n/**\n * Get available environments based on build type\n * - dev: only \"sepolia-dev\"\n * - prod: \"sepolia\" and \"mainnet-alpha\"\n */\nexport function getAvailableEnvironments(): string[] {\n const buildType = getBuildType();\n\n if (buildType === \"dev\") {\n return [\"sepolia-dev\"];\n }\n\n // prod build\n return [\"sepolia\", \"mainnet-alpha\"];\n}\n\n/**\n * Check if an environment is available in the current build\n */\nexport function isEnvironmentAvailable(environment: string): boolean {\n return getAvailableEnvironments().includes(environment);\n}\n\n/**\n * Check if environment is mainnet (chain ID 1)\n */\nexport function isMainnet(environmentConfig: EnvironmentConfig): boolean {\n return environmentConfig.chainID === BigInt(MAINNET_CHAIN_ID);\n}\n","/**\n * Default logger\n */\n\nimport { Logger } from \"../types\";\n\nexport const defaultLogger: Logger = {\n info: (...args) => console.info(...args),\n warn: (...args) => console.warn(...args),\n error: (...args) => console.error(...args),\n debug: (...args) => console.debug(...args),\n};\n\nexport const getLogger: (verbose?: boolean) => Logger = (verbose?: boolean) => ({\n info: (...args) => console.info(...args),\n warn: (...args) => console.warn(...args),\n error: (...args) => console.error(...args),\n debug: (...args) => verbose && console.debug(...args),\n});\n","/**\n * UserAPI Client to manage interactions with the coordinator\n */\n\nimport axios, { AxiosResponse } from \"axios\";\nimport FormData from \"form-data\";\nimport { Address, Hex, createPublicClient, http } from \"viem\";\nimport { calculatePermissionSignature } from \"./auth\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { EnvironmentConfig } from \"../types\";\nimport { addHexPrefix, stripHexPrefix, getChainFromID } from \"./helpers\";\n\nexport interface AppProfileInfo {\n name: string;\n website?: string;\n description?: string;\n xURL?: string;\n imageURL?: string;\n}\n\nexport interface AppMetrics {\n cpu_utilization_percent?: number;\n memory_utilization_percent?: number;\n memory_used_bytes?: number;\n memory_total_bytes?: number;\n}\n\nexport interface DerivedAddress {\n address: string;\n derivationPath: string;\n}\n\nexport interface AppInfo {\n address: Address;\n status: string;\n ip: string;\n machineType: string;\n profile?: AppProfileInfo;\n metrics?: AppMetrics;\n evmAddresses: DerivedAddress[];\n solanaAddresses: DerivedAddress[];\n}\n\nexport interface AppInfoResponse {\n apps: Array<{\n addresses: {\n data: {\n evmAddresses: DerivedAddress[];\n solanaAddresses: DerivedAddress[];\n };\n signature: string;\n };\n app_status: string;\n ip: string;\n machine_type: string;\n profile?: AppProfileInfo;\n metrics?: AppMetrics;\n }>;\n}\n\n// ==================== App Releases (/apps/:id) ====================\n\ntype JsonObject = Record<string, unknown>;\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readString(obj: JsonObject, key: string): string | undefined {\n const v = obj[key];\n return typeof v === \"string\" ? v : undefined;\n}\n\nfunction readNumber(obj: JsonObject, key: string): number | undefined {\n const v = obj[key];\n return typeof v === \"number\" && Number.isFinite(v) ? v : undefined;\n}\n\nexport type AppContractStatus = \"STARTED\" | \"STOPPED\" | \"TERMINATED\" | \"SUSPENDED\" | string;\n\nexport interface AppReleaseBuild {\n buildId?: string;\n billingAddress?: string;\n repoUrl?: string;\n gitRef?: string;\n status?: string;\n buildType?: string;\n imageName?: string;\n imageDigest?: string;\n imageUrl?: string;\n provenanceJson?: unknown;\n provenanceSignature?: string;\n createdAt?: string;\n updatedAt?: string;\n errorMessage?: string;\n dependencies?: Record<string, AppReleaseBuild>;\n}\n\nexport interface AppRelease {\n appId?: string;\n rmsReleaseId?: string;\n imageDigest?: string;\n registryUrl?: string;\n publicEnv?: string;\n encryptedEnv?: string;\n upgradeByTime?: number;\n createdAt?: string;\n createdAtBlock?: string;\n build?: AppReleaseBuild;\n}\n\nexport interface AppResponse {\n id: string;\n creator?: string;\n contractStatus?: AppContractStatus;\n releases: AppRelease[];\n}\n\nconst MAX_ADDRESS_COUNT = 5;\n\n// Permission constants\nexport const CanViewAppLogsPermission = \"0x2fd3f2fe\" as Hex;\nexport const CanViewSensitiveAppInfoPermission = \"0x0e67b22f\" as Hex;\nexport const CanUpdateAppProfilePermission = \"0x036fef61\" as Hex;\n\n/**\n * SDK_VERSION_BUILD_TIME is replaced at build time by tsup's define option\n */\n// @ts-ignore - SDK_VERSION_BUILD_TIME is injected at build time by tsup\ndeclare const SDK_VERSION_BUILD_TIME: string | undefined;\n\n/**\n * Get the default client ID using the build-time version\n */\nfunction getDefaultClientId(): string {\n // @ts-ignore - SDK_VERSION_BUILD_TIME is injected at build time\n const version = typeof SDK_VERSION_BUILD_TIME !== \"undefined\" ? SDK_VERSION_BUILD_TIME : \"0.0.0\";\n return `ecloud-sdk/v${version}`;\n}\n\nexport class UserApiClient {\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n private readonly rpcUrl?: string;\n private readonly clientId: string;\n\n constructor(\n private readonly config: EnvironmentConfig,\n privateKey?: string | Hex,\n rpcUrl?: string,\n clientId?: string,\n ) {\n if (privateKey) {\n const privateKeyHex = addHexPrefix(privateKey);\n this.account = privateKeyToAccount(privateKeyHex);\n }\n this.rpcUrl = rpcUrl;\n this.clientId = clientId || getDefaultClientId();\n }\n\n async getInfos(appIDs: Address[], addressCount = 1): Promise<AppInfo[]> {\n const count = Math.min(addressCount, MAX_ADDRESS_COUNT);\n\n const endpoint = `${this.config.userApiServerURL}/info`;\n const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(\",\") })}`;\n\n const res = await this.makeAuthenticatedRequest(url, CanViewSensitiveAppInfoPermission);\n const result: AppInfoResponse = await res.json();\n\n // optional: verify signatures with KMS key\n // const { signingKey } = getKMSKeysForEnvironment(this.config.name);\n\n // Truncate without mutating the original object\n // API returns apps in the same order as the request, so use appIDs[i] as the address\n return result.apps.map((app, i) => {\n // TODO: Implement signature verification\n // const valid = await verifyKMSSignature(appInfo.addresses, signingKey);\n // if (!valid) {\n // throw new Error(`Invalid signature for app ${appIDs[i]}`);\n // }\n\n // Slice derived addresses to requested count\n const evmAddresses = app.addresses?.data?.evmAddresses?.slice(0, count) || [];\n const solanaAddresses = app.addresses?.data?.solanaAddresses?.slice(0, count) || [];\n\n return {\n address: appIDs[i] as Address,\n status: app.app_status,\n ip: app.ip,\n machineType: app.machine_type,\n profile: app.profile,\n metrics: app.metrics,\n evmAddresses,\n solanaAddresses,\n };\n });\n }\n\n /**\n * Get app details from UserAPI (includes releases and build/provenance info when available).\n *\n * Endpoint: GET /apps/:appAddress\n */\n async getApp(appAddress: Address): Promise<AppResponse> {\n const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}`;\n const res = await this.makeAuthenticatedRequest(endpoint);\n const raw = (await res.json()) as unknown;\n\n if (!isJsonObject(raw)) {\n throw new Error(\"Unexpected /apps/:id response: expected object\");\n }\n\n const id = readString(raw, \"id\");\n if (!id) {\n throw new Error(\"Unexpected /apps/:id response: missing 'id'\");\n }\n\n const releasesRaw = raw.releases;\n const releases = Array.isArray(releasesRaw)\n ? releasesRaw.map((r) => transformAppRelease(r)).filter((r): r is AppRelease => !!r)\n : [];\n\n return {\n id,\n creator: readString(raw, \"creator\"),\n contractStatus: (readString(raw, \"contract_status\") ?? readString(raw, \"contractStatus\")) as\n | AppContractStatus\n | undefined,\n releases,\n };\n }\n\n /**\n * Get available SKUs (instance types) from UserAPI\n */\n async getSKUs(): Promise<{\n skus: Array<{ sku: string; description: string }>;\n }> {\n const endpoint = `${this.config.userApiServerURL}/skus`;\n const response = await this.makeAuthenticatedRequest(endpoint);\n\n const result = await response.json();\n\n // Transform response to match expected format\n return {\n skus: result.skus || result.SKUs || [],\n };\n }\n\n /**\n * Get logs for an app\n */\n async getLogs(appID: Address): Promise<string> {\n const endpoint = `${this.config.userApiServerURL}/logs/${appID}`;\n const response = await this.makeAuthenticatedRequest(endpoint, CanViewAppLogsPermission);\n return await response.text();\n }\n\n /**\n * Get statuses for apps\n */\n async getStatuses(appIDs: Address[]): Promise<Array<{ address: Address; status: string }>> {\n const endpoint = `${this.config.userApiServerURL}/status`;\n const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(\",\") })}`;\n const response = await this.makeAuthenticatedRequest(url);\n const result = await response.json();\n\n // Transform response to match expected format\n // The API returns an array of app statuses\n const apps = result.apps || result.Apps || [];\n return apps.map((app: any, i: number) => ({\n address: (app.address || appIDs[i]) as Address,\n status: app.status || app.Status || \"\",\n }));\n }\n\n /**\n * Upload app profile information with optional image\n */\n async uploadAppProfile(\n appAddress: Address,\n name: string,\n website?: string,\n description?: string,\n xURL?: string,\n imagePath?: string,\n ): Promise<{\n name: string;\n website?: string;\n description?: string;\n xURL?: string;\n imageURL?: string;\n }> {\n const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}/profile`;\n\n // Build multipart form data using form-data package\n const formData = new FormData();\n\n // Add required name field\n formData.append(\"name\", name);\n\n // Add optional text fields\n if (website) {\n formData.append(\"website\", website);\n }\n if (description) {\n formData.append(\"description\", description);\n }\n if (xURL) {\n formData.append(\"xURL\", xURL);\n }\n\n // Add optional image file\n if (imagePath) {\n const fs = await import(\"fs\");\n const path = await import(\"path\");\n const fileName = path.basename(imagePath);\n\n // Read file into buffer\n const fileBuffer = fs.readFileSync(imagePath);\n formData.append(\"image\", fileBuffer, fileName);\n }\n\n // Make authenticated POST request\n const headers: Record<string, string> = {\n \"x-client-id\": this.clientId,\n ...formData.getHeaders(),\n };\n\n // Add auth headers (Authorization and X-eigenx-expiry)\n if (this.account) {\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); // 5 minutes\n const authHeaders = await this.generateAuthHeaders(CanUpdateAppProfilePermission, expiry);\n Object.assign(headers, authHeaders);\n }\n\n try {\n // Use axios to post req\n const response: AxiosResponse = await axios.post(endpoint, formData, {\n headers,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n maxContentLength: Infinity, // Allow large file uploads\n maxBodyLength: Infinity, // Allow large file uploads\n });\n\n const status = response.status;\n\n if (status !== 200 && status !== 201) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n\n // Detect Cloudflare challenge page\n if (status === 403 && body.includes(\"Cloudflare\") && body.includes(\"challenge-platform\")) {\n throw new Error(\n `Cloudflare protection is blocking the request. This is likely due to bot detection.\\n` +\n `Status: ${status}`,\n );\n }\n\n throw new Error(\n `UserAPI request failed: ${status} ${status >= 200 && status < 300 ? \"OK\" : \"Error\"} - ${body.substring(0, 500)}${body.length > 500 ? \"...\" : \"\"}`,\n );\n }\n\n return response.data;\n } catch (error: any) {\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to UserAPI at ${endpoint}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.userApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n throw error;\n }\n }\n\n private async makeAuthenticatedRequest(\n url: string,\n permission?: Hex,\n ): Promise<{ json: () => Promise<any>; text: () => Promise<string> }> {\n const headers: Record<string, string> = {\n \"x-client-id\": this.clientId,\n };\n // Add auth headers if permission is specified\n if (permission && this.account) {\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); // 5 minutes\n const authHeaders = await this.generateAuthHeaders(permission, expiry);\n Object.assign(headers, authHeaders);\n }\n\n try {\n // Use axios to match\n const response: AxiosResponse = await axios.get(url, {\n headers,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n });\n\n const status = response.status;\n const statusText = status >= 200 && status < 300 ? \"OK\" : \"Error\";\n\n if (status < 200 || status >= 300) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n throw new Error(`UserAPI request failed: ${status} ${statusText} - ${body}`);\n }\n\n // Return Response-like object for compatibility\n return {\n json: async () => response.data,\n text: async () =>\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data),\n };\n } catch (error: any) {\n // Handle network errors (fetch failed, connection refused, etc.)\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to UserAPI at ${url}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.userApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n // Re-throw other errors as-is\n throw error;\n }\n }\n\n /**\n * Generate authentication headers for UserAPI requests\n */\n private async generateAuthHeaders(\n permission: Hex,\n expiry: bigint,\n ): Promise<Record<string, string>> {\n if (!this.account) {\n throw new Error(\"Private key required for authenticated requests\");\n }\n\n if (!this.rpcUrl) {\n throw new Error(\"RPC URL required for authenticated requests\");\n }\n\n const chain = getChainFromID(this.config.chainID);\n\n const publicClient = createPublicClient({\n chain,\n transport: http(this.rpcUrl),\n });\n\n // Calculate permission signature using shared auth utility\n const { signature } = await calculatePermissionSignature({\n permission,\n expiry,\n appControllerAddress: this.config.appControllerAddress as Address,\n publicClient,\n account: this.account,\n });\n\n // Return auth headers\n return {\n Authorization: `Bearer ${stripHexPrefix(signature)}`,\n \"X-eigenx-expiry\": expiry.toString(),\n };\n }\n}\n\nfunction transformAppReleaseBuild(raw: unknown): AppReleaseBuild | undefined {\n if (!isJsonObject(raw)) return undefined;\n\n const depsRaw = raw.dependencies;\n const deps: Record<string, AppReleaseBuild> | undefined = isJsonObject(depsRaw)\n ? Object.fromEntries(\n Object.entries(depsRaw).flatMap(([digest, depRaw]) => {\n const parsed = transformAppReleaseBuild(depRaw);\n return parsed ? ([[digest, parsed]] as const) : [];\n }),\n )\n : undefined;\n\n return {\n buildId: readString(raw, \"build_id\") ?? readString(raw, \"buildId\"),\n billingAddress: readString(raw, \"billing_address\") ?? readString(raw, \"billingAddress\"),\n repoUrl: readString(raw, \"repo_url\") ?? readString(raw, \"repoUrl\"),\n gitRef: readString(raw, \"git_ref\") ?? readString(raw, \"gitRef\"),\n status: readString(raw, \"status\"),\n buildType: readString(raw, \"build_type\") ?? readString(raw, \"buildType\"),\n imageName: readString(raw, \"image_name\") ?? readString(raw, \"imageName\"),\n imageDigest: readString(raw, \"image_digest\") ?? readString(raw, \"imageDigest\"),\n imageUrl: readString(raw, \"image_url\") ?? readString(raw, \"imageUrl\"),\n provenanceJson: raw.provenance_json ?? raw.provenanceJson,\n provenanceSignature:\n readString(raw, \"provenance_signature\") ?? readString(raw, \"provenanceSignature\"),\n createdAt: readString(raw, \"created_at\") ?? readString(raw, \"createdAt\"),\n updatedAt: readString(raw, \"updated_at\") ?? readString(raw, \"updatedAt\"),\n errorMessage: readString(raw, \"error_message\") ?? readString(raw, \"errorMessage\"),\n dependencies: deps,\n };\n}\n\nfunction transformAppRelease(raw: unknown): AppRelease | undefined {\n if (!isJsonObject(raw)) return undefined;\n\n return {\n appId: readString(raw, \"appId\") ?? readString(raw, \"app_id\"),\n rmsReleaseId: readString(raw, \"rmsReleaseId\") ?? readString(raw, \"rms_release_id\"),\n imageDigest: readString(raw, \"imageDigest\") ?? readString(raw, \"image_digest\"),\n registryUrl: readString(raw, \"registryUrl\") ?? readString(raw, \"registry_url\"),\n publicEnv: readString(raw, \"publicEnv\") ?? readString(raw, \"public_env\"),\n encryptedEnv: readString(raw, \"encryptedEnv\") ?? readString(raw, \"encrypted_env\"),\n upgradeByTime: readNumber(raw, \"upgradeByTime\") ?? readNumber(raw, \"upgrade_by_time\"),\n createdAt: readString(raw, \"createdAt\") ?? readString(raw, \"created_at\"),\n createdAtBlock: readString(raw, \"createdAtBlock\") ?? readString(raw, \"created_at_block\"),\n build: raw.build ? transformAppReleaseBuild(raw.build) : undefined,\n };\n}\n","/**\n * General utility helpers\n */\n\nimport { extractChain } from \"viem\";\nimport type { Chain } from \"viem\";\nimport { sepolia } from \"viem/chains\";\nimport { SUPPORTED_CHAINS } from \"../constants\";\n\n/**\n * Get a viem Chain object from a chain ID.\n * Supports mainnet (1) and sepolia (11155111), defaults to the fallback chain for unknown chains.\n */\nexport function getChainFromID(chainID: bigint, fallback: Chain = sepolia): Chain {\n const id = Number(chainID) as (typeof SUPPORTED_CHAINS)[number][\"id\"];\n return extractChain({ chains: SUPPORTED_CHAINS, id }) || fallback;\n}\n\n/**\n * Ensure hex string has 0x prefix\n */\nexport function addHexPrefix(value: string): `0x${string}` {\n return (value.startsWith(\"0x\") ? value : `0x${value}`) as `0x${string}`;\n}\n\n/**\n * Remove 0x prefix from hex string if present\n */\nexport function stripHexPrefix(value: string): string {\n return value.startsWith(\"0x\") ? value.slice(2) : value;\n}\n","/**\n * Constants used throughout the SDK\n */\n\nimport { sepolia, mainnet } from \"viem/chains\";\n\nexport const SUPPORTED_CHAINS = [mainnet, sepolia] as const;\n\nexport const DOCKER_PLATFORM = \"linux/amd64\";\nexport const REGISTRY_PROPAGATION_WAIT_SECONDS = 3;\nexport const LAYERED_DOCKERFILE_NAME = \"Dockerfile.eigencompute\";\nexport const ENV_SOURCE_SCRIPT_NAME = \"compute-source-env.sh\";\nexport const KMS_CLIENT_BINARY_NAME = \"kms-client\";\nexport const KMS_ENCRYPTION_KEY_NAME = \"kms-encryption-public-key.pem\";\nexport const KMS_SIGNING_KEY_NAME = \"kms-signing-public-key.pem\";\nexport const TLS_KEYGEN_BINARY_NAME = \"tls-keygen\";\nexport const CADDYFILE_NAME = \"Caddyfile\";\nexport const TEMP_IMAGE_PREFIX = \"ecloud-temp-\";\nexport const LAYERED_BUILD_DIR_PREFIX = \"ecloud-layered-build\";\nexport const SHA256_PREFIX = \"sha256:\";\nexport const JWT_FILE_PATH = \"/run/container_launcher/attestation_verifier_claims_token\";\n","/**\n * Billing utility functions\n */\n\nimport type { SubscriptionStatus } from \"../types\";\n\n/**\n * Check if subscription status allows deploying apps\n */\nexport function isSubscriptionActive(status: SubscriptionStatus): boolean {\n return status === \"active\" || status === \"trialing\";\n}\n","/**\n * No-op telemetry client implementation\n */\n\nimport { TelemetryClient, Metric } from \"./types\";\n\n/**\n * NoopClient implements the TelemetryClient interface with no-op methods\n */\nexport class NoopClient implements TelemetryClient {\n /**\n * AddMetric implements the TelemetryClient interface\n */\n async addMetric(_metric: Metric): Promise<void> {\n // No-op\n }\n\n /**\n * Close implements the TelemetryClient interface\n */\n async close(): Promise<void> {\n // No-op\n }\n}\n\n/**\n * Check if a client is a NoopClient\n */\nexport function isNoopClient(client: TelemetryClient): boolean {\n return client instanceof NoopClient;\n}\n","/**\n * PostHog telemetry client implementation\n *\n * Uses the official posthog-node library\n */\n\nimport { PostHog } from \"posthog-node\";\nimport { TelemetryClient, Metric, AppEnvironment } from \"./types\";\n\n/**\n * PostHogClient implements the TelemetryClient interface using posthog-node\n */\nexport class PostHogClient implements TelemetryClient {\n private readonly client: PostHog;\n private readonly namespace: string;\n private readonly appEnvironment: AppEnvironment;\n\n constructor(environment: AppEnvironment, namespace: string, apiKey: string, endpoint?: string) {\n this.namespace = namespace;\n this.appEnvironment = environment;\n\n // Initialize PostHog client\n // posthog-node expects the full URL for the host option\n const host = endpoint || \"https://us.i.posthog.com\";\n\n this.client = new PostHog(apiKey, {\n host: host,\n flushAt: 1, // Flush immediately for CLI/SDK usage\n flushInterval: 0, // Disable interval flushing\n });\n\n // Identify the user with their UUID\n this.client.identify({\n distinctId: environment.userUUID,\n properties: {\n os: environment.os,\n arch: environment.arch,\n ...(environment.cliVersion ? { cliVersion: environment.cliVersion } : {}),\n },\n });\n }\n\n /**\n * AddMetric implements the TelemetryClient interface\n */\n async addMetric(metric: Metric): Promise<void> {\n // Never throw errors from telemetry operations\n try {\n // Create properties map starting with base properties\n const props: Record<string, any> = {\n name: metric.name,\n value: metric.value,\n };\n\n // Add metric dimensions\n for (const [k, v] of Object.entries(metric.dimensions)) {\n props[k] = v;\n }\n\n // Capture event using the namespace as the event name\n // With flushAt: 1, events are automatically flushed after each capture\n this.client.capture({\n distinctId: this.appEnvironment.userUUID,\n event: this.namespace,\n properties: props,\n });\n } catch {\n // Silently ignore telemetry errors\n }\n }\n\n /**\n * Close implements the TelemetryClient interface\n */\n async close(): Promise<void> {\n try {\n // Shutdown PostHog client and flush any pending events\n // shutdown() is synchronous but internally handles async cleanup\n this.client.shutdown();\n } catch {\n // Silently ignore errors during shutdown\n }\n }\n}\n\n/**\n * Embedded PostHog API key (can be exposed in TypeScript)\n * This can be set at build time or overridden via environment variable\n */\n// @ts-ignore - POSTHOG_API_KEY_BUILD_TIME is injected at build time by tsup\ndeclare const POSTHOG_API_KEY_BUILD_TIME: string | undefined;\n\n/**\n * Get PostHog API key from environment variable or build-time constant\n */\nexport function getPostHogAPIKey(): string | undefined {\n // Priority order:\n // 1. Environment variable\n // 2. Build-time constant (set at build time)\n // Check environment variable first\n if (process.env.ECLOUD_POSTHOG_KEY) {\n return process.env.ECLOUD_POSTHOG_KEY;\n }\n\n // Return build-time constant if available\n // @ts-ignore - POSTHOG_API_KEY_BUILD_TIME is injected at build time\n return typeof POSTHOG_API_KEY_BUILD_TIME !== \"undefined\" ? POSTHOG_API_KEY_BUILD_TIME : undefined;\n}\n\n/**\n * Get PostHog endpoint from environment variable or default\n */\nexport function getPostHogEndpoint(): string {\n return process.env.ECLOUD_POSTHOG_ENDPOINT || \"https://us.i.posthog.com\";\n}\n","/**\n * Telemetry module for ECloud SDK and CLI\n *\n * Provides telemetry functionality matching the Go implementation.\n * Supports both \"ecloud-cli\" and \"ecloud-sdk\" namespaces.\n */\n\nimport { TelemetryClient, Metric, AppEnvironment } from \"./types\";\nimport { NoopClient, isNoopClient } from \"./noop\";\nimport { PostHogClient, getPostHogAPIKey, getPostHogEndpoint } from \"./posthog\";\nimport * as os from \"os\";\n\nexport * from \"./types\";\nexport * from \"./metricsContext\";\nexport * from \"./noop\";\nexport * from \"./posthog\";\nexport * from \"./wrapper\";\n\n/**\n * Options for creating a telemetry client\n */\nexport interface TelemetryClientOptions {\n /**\n * Whether telemetry is enabled (only enabled if explicitly set to true, defaults to disabled)\n */\n telemetryEnabled?: boolean;\n /**\n * PostHog API key (if not provided, will check environment variables)\n */\n apiKey?: string;\n /**\n * PostHog endpoint (if not provided, will use default)\n */\n endpoint?: string;\n}\n\n/**\n * Create a telemetry client\n *\n * @param environment - Application environment information (must include userUUID)\n * @param namespace - Namespace for telemetry events (\"ecloud-cli\" or \"ecloud-sdk\")\n * @param options - Optional telemetry client options\n * @returns TelemetryClient instance (NoopClient if telemetry is disabled or no API key)\n */\nexport function createTelemetryClient(\n environment: AppEnvironment,\n namespace: \"ecloud-cli\" | \"ecloud-sdk\",\n options?: TelemetryClientOptions,\n): TelemetryClient {\n // Check if telemetry is enabled\n // Only enabled if explicitly set to true\n // If undefined or false, telemetry is disabled\n const telemetryEnabled = options?.telemetryEnabled === true;\n\n // If telemetry is disabled, return noop client\n if (!telemetryEnabled) {\n return new NoopClient();\n }\n\n // Get API key from options, environment variable, or return noop\n const resolvedApiKey = options?.apiKey || getPostHogAPIKey();\n if (!resolvedApiKey) {\n // No API key available, return noop client\n return new NoopClient();\n }\n\n // Get endpoint from options or environment variable\n const endpoint = options?.endpoint || getPostHogEndpoint();\n\n try {\n return new PostHogClient(environment, namespace, resolvedApiKey, endpoint);\n } catch {\n // If initialization fails, return noop client\n return new NoopClient();\n }\n}\n\n/**\n * Create an AppEnvironment from current system information\n *\n * @param userUUID - User UUID for identification (required - no I/O in SDK)\n * @param cliVersion - Optional CLI version (for CLI usage)\n * @param osOverride - Optional OS override (defaults to current platform)\n * @param archOverride - Optional architecture override (defaults to current architecture)\n * @returns AppEnvironment with user UUID, OS, and architecture\n */\nexport function createAppEnvironment(\n userUUID: string,\n cliVersion?: string,\n osOverride?: string,\n archOverride?: string,\n): AppEnvironment {\n return {\n userUUID,\n cliVersion,\n os: osOverride || os.platform(),\n arch: archOverride || os.arch(),\n };\n}\n\n/**\n * Emit metrics from a metrics context\n *\n * @param client - Telemetry client to use\n * @param context - Metrics context containing metrics to emit\n * @returns Promise that resolves when all metrics are emitted\n */\nexport async function emitMetrics(\n client: TelemetryClient,\n context: {\n metrics: Metric[];\n properties: Record<string, string>;\n },\n): Promise<void> {\n if (isNoopClient(client)) {\n return;\n }\n\n // Emit each metric with properties merged into dimensions\n for (const metric of context.metrics) {\n const dimensions = {\n ...metric.dimensions,\n ...context.properties,\n };\n\n const metricWithProperties: Metric = {\n ...metric,\n dimensions,\n };\n\n try {\n await client.addMetric(metricWithProperties);\n } catch {\n // Silently ignore telemetry errors\n }\n }\n}\n","/**\n * MetricsContext management\n */\n\nimport { MetricsContext } from \"./types\";\n\n/**\n * Create a new metrics context\n */\nexport function createMetricsContext(): MetricsContext {\n return {\n startTime: new Date(),\n metrics: [],\n properties: {},\n };\n}\n\n/**\n * Add a metric to the context without dimensions\n */\nexport function addMetric(context: MetricsContext, name: string, value: number): void {\n addMetricWithDimensions(context, name, value, {});\n}\n\n/**\n * Add a metric to the context with dimensions\n */\nexport function addMetricWithDimensions(\n context: MetricsContext,\n name: string,\n value: number,\n dimensions: Record<string, string>,\n): void {\n context.metrics.push({\n name,\n value,\n dimensions,\n });\n}\n","/**\n * Telemetry wrapper utilities for SDK functions\n *\n * Provides helpers to wrap SDK function execution with telemetry tracking\n */\n\nimport {\n createTelemetryClient,\n createAppEnvironment,\n createMetricsContext,\n addMetric,\n addMetricWithDimensions,\n emitMetrics,\n} from \"./index\";\nimport { randomUUID } from \"crypto\";\n\n/**\n * Generate a random UUID for telemetry identification\n * Used when userUUID is not provided (SDK usage outside CLI)\n */\nfunction generateRandomUUID(): string {\n return randomUUID();\n}\n\n/**\n * Options for telemetry wrapper\n */\nexport interface TelemetryWrapperOptions {\n /**\n * Function name for telemetry (e.g., \"deploy\", \"upgrade\", \"createApp\")\n */\n functionName: string;\n /**\n * Skip telemetry if true (used when called from CLI)\n */\n skipTelemetry?: boolean;\n /**\n * Additional properties to include in telemetry\n */\n properties?: Record<string, string>;\n /**\n * User UUID for identification (required if skipTelemetry is false)\n * If not provided and telemetry is enabled, will generate a random UUID for this session\n */\n userUUID?: string;\n /**\n * Whether telemetry is enabled (defaults to true if not provided)\n */\n telemetryEnabled?: boolean;\n /**\n * PostHog API key (optional, will check environment variables if not provided)\n */\n apiKey?: string;\n /**\n * PostHog endpoint (optional, will use default if not provided)\n */\n endpoint?: string;\n}\n\n/**\n * Wrap a function execution with telemetry\n *\n * @param options - Telemetry wrapper options\n * @param action - The function to execute\n * @returns The result of the action\n */\nexport async function withSDKTelemetry<T>(\n options: TelemetryWrapperOptions,\n action: () => Promise<T>,\n): Promise<T> {\n // Skip telemetry if requested (e.g., when called from CLI)\n if (options.skipTelemetry) {\n return action();\n }\n\n // Generate a random UUID if not provided (for SDK usage outside CLI)\n // This ensures each SDK session has a unique identifier\n const userUUID = options.userUUID || generateRandomUUID();\n\n const environment = createAppEnvironment(userUUID);\n const client = createTelemetryClient(environment, \"ecloud-sdk\", {\n telemetryEnabled: options.telemetryEnabled,\n apiKey: options.apiKey,\n endpoint: options.endpoint,\n });\n const metrics = createMetricsContext();\n\n // Set source to identify SDK usage\n metrics.properties[\"source\"] = \"ecloud-sdk\";\n\n // Set function name in properties\n metrics.properties[\"function\"] = options.functionName;\n\n // Add any additional properties\n if (options.properties) {\n Object.assign(metrics.properties, options.properties);\n }\n\n // Add initial count metric\n addMetric(metrics, \"Count\", 1);\n\n let actionError: Error | undefined;\n let result: T;\n\n try {\n result = await action();\n return result;\n } catch (err) {\n actionError = err instanceof Error ? err : new Error(String(err));\n throw err;\n } finally {\n // Add result metric\n const resultValue = actionError ? \"Failure\" : \"Success\";\n const dimensions: Record<string, string> = {};\n if (actionError) {\n dimensions[\"error\"] = actionError.message;\n }\n addMetricWithDimensions(metrics, resultValue, 1, dimensions);\n\n // Add duration metric\n const duration = Date.now() - metrics.startTime.getTime();\n addMetric(metrics, \"DurationMilliseconds\", duration);\n\n // Emit all metrics\n try {\n await emitMetrics(client, metrics);\n await client.close();\n } catch {\n // Silently ignore telemetry errors\n }\n }\n}\n","/**\n * Main Billing namespace entry point\n */\n\nimport { BillingApiClient } from \"../../common/utils/billingapi\";\nimport { getBillingEnvironmentConfig, getBuildType } from \"../../common/config/environment\";\nimport { getLogger, isSubscriptionActive, addHexPrefix } from \"../../common/utils\";\nimport { withSDKTelemetry } from \"../../common/telemetry/wrapper\";\n\nimport type { Hex } from \"viem\";\nimport type {\n ProductID,\n SubscriptionOpts,\n SubscribeResponse,\n CancelResponse,\n ProductSubscriptionResponse,\n} from \"../../common/types\";\n\nexport interface BillingModule {\n subscribe: (opts?: SubscriptionOpts) => Promise<SubscribeResponse>;\n getStatus: (opts?: SubscriptionOpts) => Promise<ProductSubscriptionResponse>;\n cancel: (opts?: SubscriptionOpts) => Promise<CancelResponse>;\n}\n\nexport interface BillingModuleConfig {\n verbose?: boolean;\n privateKey: Hex;\n skipTelemetry?: boolean; // Skip telemetry when called from CLI\n}\n\nexport function createBillingModule(config: BillingModuleConfig): BillingModule {\n const { verbose = false, skipTelemetry = false } = config;\n const privateKey = addHexPrefix(config.privateKey);\n\n const logger = getLogger(verbose);\n\n // Get billing environment configuration\n const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());\n\n // Create billing API client\n const billingApi = new BillingApiClient(billingEnvConfig, privateKey);\n\n return {\n async subscribe(opts) {\n return withSDKTelemetry(\n {\n functionName: \"subscribe\",\n skipTelemetry: skipTelemetry, // Skip if called from CLI\n properties: { productId: opts?.productId || \"compute\" },\n },\n async () => {\n const productId: ProductID = opts?.productId || \"compute\";\n\n // Check existing subscription status first\n logger.debug(`Checking existing subscription for ${productId}...`);\n const currentStatus = await billingApi.getSubscription(productId);\n\n // If already active or trialing, don't create new checkout\n if (isSubscriptionActive(currentStatus.subscriptionStatus)) {\n logger.debug(`Subscription already active: ${currentStatus.subscriptionStatus}`);\n return {\n type: \"already_active\" as const,\n status: currentStatus.subscriptionStatus,\n };\n }\n\n // If subscription has payment issues, return portal URL instead\n if (\n currentStatus.subscriptionStatus === \"past_due\" ||\n currentStatus.subscriptionStatus === \"unpaid\"\n ) {\n logger.debug(`Subscription has payment issue: ${currentStatus.subscriptionStatus}`);\n return {\n type: \"payment_issue\" as const,\n status: currentStatus.subscriptionStatus,\n portalUrl: currentStatus.portalUrl,\n };\n }\n\n // Create new checkout session\n logger.debug(`Creating subscription for ${productId}...`);\n const result = await billingApi.createSubscription(productId);\n\n logger.debug(`Checkout URL: ${result.checkoutUrl}`);\n return {\n type: \"checkout_created\" as const,\n checkoutUrl: result.checkoutUrl,\n };\n },\n );\n },\n\n async getStatus(opts) {\n return withSDKTelemetry(\n {\n functionName: \"getStatus\",\n skipTelemetry: skipTelemetry, // Skip if called from CLI\n properties: { productId: opts?.productId || \"compute\" },\n },\n async () => {\n const productId: ProductID = opts?.productId || \"compute\";\n logger.debug(`Fetching subscription status for ${productId}...`);\n\n const result = await billingApi.getSubscription(productId);\n\n logger.debug(`Subscription status: ${result.subscriptionStatus}`);\n return result;\n },\n );\n },\n\n async cancel(opts) {\n return withSDKTelemetry(\n {\n functionName: \"cancel\",\n skipTelemetry: skipTelemetry, // Skip if called from CLI\n properties: { productId: opts?.productId || \"compute\" },\n },\n async () => {\n const productId: ProductID = opts?.productId || \"compute\";\n\n // Check existing subscription status first\n logger.debug(`Checking subscription status for ${productId}...`);\n const currentStatus = await billingApi.getSubscription(productId);\n\n // If no active subscription, don't attempt to cancel\n if (!isSubscriptionActive(currentStatus.subscriptionStatus)) {\n logger.debug(`No active subscription to cancel: ${currentStatus.subscriptionStatus}`);\n return {\n type: \"no_active_subscription\" as const,\n status: currentStatus.subscriptionStatus,\n };\n }\n\n // Cancel the subscription\n logger.debug(`Canceling subscription for ${productId}...`);\n await billingApi.cancelSubscription(productId);\n\n logger.debug(`Subscription canceled successfully`);\n return {\n type: \"canceled\" as const,\n };\n },\n );\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,mBAAqC;AAErC,sBAAoC;;;ACHpC,kBAA4C;AAK5C,IAAM,yBAAqB,sBAAS;AAAA,EAClC;AACF,CAAC;AAqDD,eAAsB,8BACpB,SACqC;AACrC,QAAM,EA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AAM,aAAa,UAAU;AAAA,QACxD;AAAA,QACA,YAAY;AACV,gBAAM,YAAuB,MAAM,aAAa;AAGhD,iBAAO,MAAM,oCAAoC,SAAS,KAAK;AAC/D,gBAAM,gBAAgB,MAAM,WAAW,gBAAgB,SAAS;AAGhE,cAAI,CAAC,qBAAqB,cAAc,kBAAkB,GAAG;AAC3D,mBAAO,MAAM,qCAAqC,cAAc,kBAAkB,EAAE;AACpF,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,QAAQ,cAAc;AAAA,YACxB;AAAA,UACF;AAGA,iBAAO,MAAM,8BAA8B,SAAS,KAAK;AACzD,gBAAM,WAAW,mBAAmB,SAAS;AAE7C,iBAAO,MAAM,oCAAoC;AACjD,iBAAO;AAAA,YACL,MAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["axios","import_axios","import_viem","import_accounts","import_viem","import_chains"]}
|
package/dist/billing.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
2
|
import { s as SubscriptionOpts, o as SubscribeResponse, r as ProductSubscriptionResponse, q as CancelResponse } from './index-D-SUX3IG.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,6 @@ import { s as SubscriptionOpts, o as SubscribeResponse, r as ProductSubscription
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
interface BillingModule {
|
|
9
|
-
address: Address;
|
|
10
9
|
subscribe: (opts?: SubscriptionOpts) => Promise<SubscribeResponse>;
|
|
11
10
|
getStatus: (opts?: SubscriptionOpts) => Promise<ProductSubscriptionResponse>;
|
|
12
11
|
cancel: (opts?: SubscriptionOpts) => Promise<CancelResponse>;
|
package/dist/billing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
2
|
import { s as SubscriptionOpts, o as SubscribeResponse, r as ProductSubscriptionResponse, q as CancelResponse } from './index-D-SUX3IG.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,6 @@ import { s as SubscriptionOpts, o as SubscribeResponse, r as ProductSubscription
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
interface BillingModule {
|
|
9
|
-
address: Address;
|
|
10
9
|
subscribe: (opts?: SubscriptionOpts) => Promise<SubscribeResponse>;
|
|
11
10
|
getStatus: (opts?: SubscriptionOpts) => Promise<ProductSubscriptionResponse>;
|
|
12
11
|
cancel: (opts?: SubscriptionOpts) => Promise<CancelResponse>;
|
package/dist/billing.js
CHANGED
|
@@ -108,6 +108,35 @@ function isMainnet(environmentConfig) {
|
|
|
108
108
|
return environmentConfig.chainID === BigInt(MAINNET_CHAIN_ID);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// src/client/common/utils/helpers.ts
|
|
112
|
+
import { extractChain } from "viem";
|
|
113
|
+
import { sepolia as sepolia2 } from "viem/chains";
|
|
114
|
+
|
|
115
|
+
// src/client/common/constants.ts
|
|
116
|
+
import { sepolia, mainnet } from "viem/chains";
|
|
117
|
+
var SUPPORTED_CHAINS = [mainnet, sepolia];
|
|
118
|
+
var DOCKER_PLATFORM = "linux/amd64";
|
|
119
|
+
var REGISTRY_PROPAGATION_WAIT_SECONDS = 3;
|
|
120
|
+
var LAYERED_DOCKERFILE_NAME = "Dockerfile.eigencompute";
|
|
121
|
+
var ENV_SOURCE_SCRIPT_NAME = "compute-source-env.sh";
|
|
122
|
+
var KMS_CLIENT_BINARY_NAME = "kms-client";
|
|
123
|
+
var KMS_SIGNING_KEY_NAME = "kms-signing-public-key.pem";
|
|
124
|
+
var TLS_KEYGEN_BINARY_NAME = "tls-keygen";
|
|
125
|
+
var CADDYFILE_NAME = "Caddyfile";
|
|
126
|
+
var LAYERED_BUILD_DIR_PREFIX = "ecloud-layered-build";
|
|
127
|
+
|
|
128
|
+
// src/client/common/utils/helpers.ts
|
|
129
|
+
function getChainFromID(chainID, fallback = sepolia2) {
|
|
130
|
+
const id = Number(chainID);
|
|
131
|
+
return extractChain({ chains: SUPPORTED_CHAINS, id }) || fallback;
|
|
132
|
+
}
|
|
133
|
+
function addHexPrefix(value) {
|
|
134
|
+
return value.startsWith("0x") ? value : `0x${value}`;
|
|
135
|
+
}
|
|
136
|
+
function stripHexPrefix(value) {
|
|
137
|
+
return value.startsWith("0x") ? value.slice(2) : value;
|
|
138
|
+
}
|
|
139
|
+
|
|
111
140
|
// src/client/common/utils/userapi.ts
|
|
112
141
|
import axios from "axios";
|
|
113
142
|
import FormData from "form-data";
|
|
@@ -155,43 +184,23 @@ async function calculateBillingAuthSignature(options) {
|
|
|
155
184
|
|
|
156
185
|
// src/client/common/utils/userapi.ts
|
|
157
186
|
import { privateKeyToAccount } from "viem/accounts";
|
|
158
|
-
|
|
159
|
-
|
|
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;
|
|
187
|
+
function isJsonObject(value) {
|
|
188
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
180
189
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
190
|
+
function readString(obj, key) {
|
|
191
|
+
const v = obj[key];
|
|
192
|
+
return typeof v === "string" ? v : void 0;
|
|
183
193
|
}
|
|
184
|
-
function
|
|
185
|
-
|
|
194
|
+
function readNumber(obj, key) {
|
|
195
|
+
const v = obj[key];
|
|
196
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
186
197
|
}
|
|
187
|
-
|
|
188
|
-
// src/client/common/utils/userapi.ts
|
|
189
198
|
var MAX_ADDRESS_COUNT = 5;
|
|
190
199
|
var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
191
200
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
192
201
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
193
202
|
function getDefaultClientId() {
|
|
194
|
-
const version = true ? "0.
|
|
203
|
+
const version = true ? "0.2.0-dev" : "0.0.0";
|
|
195
204
|
return `ecloud-sdk/v${version}`;
|
|
196
205
|
}
|
|
197
206
|
var UserApiClient = class {
|
|
@@ -225,6 +234,31 @@ var UserApiClient = class {
|
|
|
225
234
|
};
|
|
226
235
|
});
|
|
227
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Get app details from UserAPI (includes releases and build/provenance info when available).
|
|
239
|
+
*
|
|
240
|
+
* Endpoint: GET /apps/:appAddress
|
|
241
|
+
*/
|
|
242
|
+
async getApp(appAddress) {
|
|
243
|
+
const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}`;
|
|
244
|
+
const res = await this.makeAuthenticatedRequest(endpoint);
|
|
245
|
+
const raw = await res.json();
|
|
246
|
+
if (!isJsonObject(raw)) {
|
|
247
|
+
throw new Error("Unexpected /apps/:id response: expected object");
|
|
248
|
+
}
|
|
249
|
+
const id = readString(raw, "id");
|
|
250
|
+
if (!id) {
|
|
251
|
+
throw new Error("Unexpected /apps/:id response: missing 'id'");
|
|
252
|
+
}
|
|
253
|
+
const releasesRaw = raw.releases;
|
|
254
|
+
const releases = Array.isArray(releasesRaw) ? releasesRaw.map((r) => transformAppRelease(r)).filter((r) => !!r) : [];
|
|
255
|
+
return {
|
|
256
|
+
id,
|
|
257
|
+
creator: readString(raw, "creator"),
|
|
258
|
+
contractStatus: readString(raw, "contract_status") ?? readString(raw, "contractStatus"),
|
|
259
|
+
releases
|
|
260
|
+
};
|
|
261
|
+
}
|
|
228
262
|
/**
|
|
229
263
|
* Get available SKUs (instance types) from UserAPI
|
|
230
264
|
*/
|
|
@@ -397,6 +431,48 @@ Please check:
|
|
|
397
431
|
};
|
|
398
432
|
}
|
|
399
433
|
};
|
|
434
|
+
function transformAppReleaseBuild(raw) {
|
|
435
|
+
if (!isJsonObject(raw)) return void 0;
|
|
436
|
+
const depsRaw = raw.dependencies;
|
|
437
|
+
const deps = isJsonObject(depsRaw) ? Object.fromEntries(
|
|
438
|
+
Object.entries(depsRaw).flatMap(([digest, depRaw]) => {
|
|
439
|
+
const parsed = transformAppReleaseBuild(depRaw);
|
|
440
|
+
return parsed ? [[digest, parsed]] : [];
|
|
441
|
+
})
|
|
442
|
+
) : void 0;
|
|
443
|
+
return {
|
|
444
|
+
buildId: readString(raw, "build_id") ?? readString(raw, "buildId"),
|
|
445
|
+
billingAddress: readString(raw, "billing_address") ?? readString(raw, "billingAddress"),
|
|
446
|
+
repoUrl: readString(raw, "repo_url") ?? readString(raw, "repoUrl"),
|
|
447
|
+
gitRef: readString(raw, "git_ref") ?? readString(raw, "gitRef"),
|
|
448
|
+
status: readString(raw, "status"),
|
|
449
|
+
buildType: readString(raw, "build_type") ?? readString(raw, "buildType"),
|
|
450
|
+
imageName: readString(raw, "image_name") ?? readString(raw, "imageName"),
|
|
451
|
+
imageDigest: readString(raw, "image_digest") ?? readString(raw, "imageDigest"),
|
|
452
|
+
imageUrl: readString(raw, "image_url") ?? readString(raw, "imageUrl"),
|
|
453
|
+
provenanceJson: raw.provenance_json ?? raw.provenanceJson,
|
|
454
|
+
provenanceSignature: readString(raw, "provenance_signature") ?? readString(raw, "provenanceSignature"),
|
|
455
|
+
createdAt: readString(raw, "created_at") ?? readString(raw, "createdAt"),
|
|
456
|
+
updatedAt: readString(raw, "updated_at") ?? readString(raw, "updatedAt"),
|
|
457
|
+
errorMessage: readString(raw, "error_message") ?? readString(raw, "errorMessage"),
|
|
458
|
+
dependencies: deps
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function transformAppRelease(raw) {
|
|
462
|
+
if (!isJsonObject(raw)) return void 0;
|
|
463
|
+
return {
|
|
464
|
+
appId: readString(raw, "appId") ?? readString(raw, "app_id"),
|
|
465
|
+
rmsReleaseId: readString(raw, "rmsReleaseId") ?? readString(raw, "rms_release_id"),
|
|
466
|
+
imageDigest: readString(raw, "imageDigest") ?? readString(raw, "image_digest"),
|
|
467
|
+
registryUrl: readString(raw, "registryUrl") ?? readString(raw, "registry_url"),
|
|
468
|
+
publicEnv: readString(raw, "publicEnv") ?? readString(raw, "public_env"),
|
|
469
|
+
encryptedEnv: readString(raw, "encryptedEnv") ?? readString(raw, "encrypted_env"),
|
|
470
|
+
upgradeByTime: readNumber(raw, "upgradeByTime") ?? readNumber(raw, "upgrade_by_time"),
|
|
471
|
+
createdAt: readString(raw, "createdAt") ?? readString(raw, "created_at"),
|
|
472
|
+
createdAtBlock: readString(raw, "createdAtBlock") ?? readString(raw, "created_at_block"),
|
|
473
|
+
build: raw.build ? transformAppReleaseBuild(raw.build) : void 0
|
|
474
|
+
};
|
|
475
|
+
}
|
|
400
476
|
|
|
401
477
|
// src/client/common/utils/billing.ts
|
|
402
478
|
function isSubscriptionActive(status) {
|
|
@@ -665,4 +741,4 @@ export {
|
|
|
665
741
|
emitMetrics,
|
|
666
742
|
withSDKTelemetry
|
|
667
743
|
};
|
|
668
|
-
//# sourceMappingURL=chunk-
|
|
744
|
+
//# sourceMappingURL=chunk-34DXGQ35.js.map
|