@layr-labs/ecloud-sdk 0.1.1-dev → 0.1.2-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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client/common/auth/keyring.ts","../src/client/common/auth/resolver.ts","../src/client/common/auth/generate.ts","../src/client/common/utils/billingapi.ts","../src/client/modules/billing/index.ts"],"sourcesContent":["/**\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 { Hex } from \"viem\";\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<Hex | 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 Hex;\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 Hex);\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 Hex);\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 Hex);\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): Hex {\n if (!privateKey.startsWith(\"0x\")) {\n return `0x${privateKey}`;\n }\n return privateKey as Hex;\n}\n","/**\n * Private Key Resolution\n *\n * Implements 3-tier priority system for private key retrieval:\n * 1. Command-line flag (--private-key)\n * 2. Environment variable (ECLOUD_PRIVATE_KEY)\n * 3. OS keyring (stored via `ecloud auth login`)\n */\n\nimport { Hex } from \"viem\";\nimport { getPrivateKey, validatePrivateKey } from \"./keyring\";\n\nexport interface PrivateKeySource {\n key: Hex;\n source: string;\n}\n\n/**\n * Get private key from any available source\n *\n * Priority order:\n * 1. Direct parameter (from --private-key flag)\n * 2. Environment variable (ECLOUD_PRIVATE_KEY)\n * 3. OS keyring (single key for all environments)\n *\n * Returns null if no key found\n */\nexport async function getPrivateKeyWithSource(options: {\n privateKey?: string; // From flag\n}): Promise<PrivateKeySource | null> {\n // 1. Check direct parameter (flag)\n if (options.privateKey) {\n if (!validatePrivateKey(options.privateKey)) {\n throw new Error(\n \"Invalid private key format provided via command flag. Please check and try again.\",\n );\n }\n return {\n key: options.privateKey as Hex,\n source: \"command flag\",\n };\n }\n\n // 2. Check environment variable\n const envKey = process.env.ECLOUD_PRIVATE_KEY as Hex;\n if (envKey) {\n if (!validatePrivateKey(envKey)) {\n throw new Error(\n \"Invalid private key format provided via environment variable. Please check and try again.\",\n );\n }\n return {\n key: envKey,\n source: \"environment variable (ECLOUD_PRIVATE_KEY)\",\n };\n }\n\n // 3. Check OS keyring (single key for all environments)\n const keyringKey = await getPrivateKey();\n if (keyringKey) {\n return {\n key: keyringKey,\n source: \"stored credentials\",\n };\n }\n\n return null;\n}\n\n/**\n * Get private key with source or throw error\n */\nexport async function requirePrivateKey(options: {\n privateKey?: string;\n}): Promise<PrivateKeySource> {\n const result = await getPrivateKeyWithSource({\n privateKey: options.privateKey,\n });\n\n if (!result) {\n throw new Error(\n `Private key required. Please provide it via:\\n` +\n ` • Keyring: ecloud auth login\\n` +\n ` • Flag: --private-key YOUR_KEY\\n` +\n ` • Environment: export ECLOUD_PRIVATE_KEY=YOUR_KEY`,\n );\n }\n\n return result;\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 * 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 * 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":";;;;;;;;;;;AAWA,SAAS,YAAY,uBAAuB;AAE5C,SAAS,2BAA2B;AAGpC,IAAM,eAAe;AACrB,IAAM,eAAe;AAGrB,IAAM,sBAAsB;AAC5B,IAAM,0BAA0B;AAChC,IAAM,wBAAwB;AAG9B,IAAM,2BAA2B;AACjC,IAAM,4BAA4B;AAkBlC,eAAsB,gBAAgB,YAAmC;AAEvE,QAAM,gBAAgB,oBAAoB,UAAU;AAGpD,QAAM,UAAU,mBAAmB,aAAa;AAChD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAGA,QAAM,QAAQ,IAAI,WAAW,cAAc,YAAY;AACvD,MAAI;AACF,UAAM,MAAM,YAAY,aAAa;AAAA,EACvC,SAAS,KAAU;AACjB,UAAM,IAAI;AAAA,MACR,sCAAsC,KAAK,WAAW,GAAG;AAAA,IAC3D;AAAA,EACF;AACF;AAQA,eAAsB,gBAAqC;AACzD,QAAM,QAAQ,IAAI,WAAW,cAAc,YAAY;AACvD,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,YAAY;AACpC,QAAI,OAAO,mBAAmB,GAAG,GAAG;AAClC,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AASA,eAAsB,mBAAqC;AACzD,QAAM,QAAQ,IAAI,WAAW,cAAc,YAAY;AACvD,MAAI;AACF,UAAM,MAAM,eAAe;AAC3B,WAAO;AAAA,EACT,QAAQ;AACN,YAAQ,KAAK,yBAAyB;AACtC,WAAO;AAAA,EACT;AACF;AAMA,eAAsB,iBAAuC;AAC3D,QAAM,OAAoB,CAAC;AAE3B,QAA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D,iBAAO,MAAM,wBAAwB,OAAO,kBAAkB,EAAE;AAChE,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,OAAO,MAAM;AACjB,aAAO;AAAA,QACL;AAAA,UACE,cAAc;AAAA,UACd;AAAA;AAAA,UACA,YAAY,EAAE,WAAW,MAAM,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":["privateKeyToAddress"]}
@@ -17,7 +17,7 @@ import {
17
17
  getLogger,
18
18
  stripHexPrefix,
19
19
  withSDKTelemetry
20
- } from "./chunk-AXSYVG7H.js";
20
+ } from "./chunk-JLZOAV5R.js";
21
21
 
22
22
  // src/client/common/contract/eip7702.ts
23
23
  import {
@@ -2756,20 +2756,20 @@ async function prepareDeployBatch(options, logger) {
2756
2756
  environmentConfig
2757
2757
  };
2758
2758
  }
2759
- async function executeDeployBatch(prepared, gas, logger) {
2759
+ async function executeDeployBatch(data, context, gas, logger) {
2760
2760
  const pendingMessage = "Deploying new app...";
2761
2761
  const txHash = await executeBatch(
2762
2762
  {
2763
- walletClient: prepared.walletClient,
2764
- publicClient: prepared.publicClient,
2765
- environmentConfig: prepared.environmentConfig,
2766
- executions: prepared.executions,
2763
+ walletClient: context.walletClient,
2764
+ publicClient: context.publicClient,
2765
+ environmentConfig: context.environmentConfig,
2766
+ executions: data.executions,
2767
2767
  pendingMessage,
2768
2768
  gas
2769
2769
  },
2770
2770
  logger
2771
2771
  );
2772
- return { appId: prepared.appId, txHash };
2772
+ return { appId: data.appId, txHash };
2773
2773
  }
2774
2774
  async function deployApp(options, logger) {
2775
2775
  const prepared = await prepareDeployBatch(
@@ -2783,7 +2783,17 @@ async function deployApp(options, logger) {
2783
2783
  },
2784
2784
  logger
2785
2785
  );
2786
- return executeDeployBatch(prepared, options.gas, logger);
2786
+ const data = {
2787
+ appId: prepared.appId,
2788
+ salt: prepared.salt,
2789
+ executions: prepared.executions
2790
+ };
2791
+ const context = {
2792
+ walletClient: prepared.walletClient,
2793
+ publicClient: prepared.publicClient,
2794
+ environmentConfig: prepared.environmentConfig
2795
+ };
2796
+ return executeDeployBatch(data, context, options.gas, logger);
2787
2797
  }
2788
2798
  async function prepareUpgradeBatch(options) {
2789
2799
  const {
@@ -2879,14 +2889,14 @@ async function prepareUpgradeBatch(options) {
2879
2889
  environmentConfig
2880
2890
  };
2881
2891
  }
2882
- async function executeUpgradeBatch(prepared, gas, logger) {
2883
- const pendingMessage = `Upgrading app ${prepared.appId}...`;
2892
+ async function executeUpgradeBatch(data, context, gas, logger) {
2893
+ const pendingMessage = `Upgrading app ${data.appId}...`;
2884
2894
  const txHash = await executeBatch(
2885
2895
  {
2886
- walletClient: prepared.walletClient,
2887
- publicClient: prepared.publicClient,
2888
- environmentConfig: prepared.environmentConfig,
2889
- executions: prepared.executions,
2896
+ walletClient: context.walletClient,
2897
+ publicClient: context.publicClient,
2898
+ environmentConfig: context.environmentConfig,
2899
+ executions: data.executions,
2890
2900
  pendingMessage,
2891
2901
  gas
2892
2902
  },
@@ -2904,7 +2914,16 @@ async function upgradeApp(options, logger) {
2904
2914
  publicLogs: options.publicLogs,
2905
2915
  needsPermissionChange: options.needsPermissionChange
2906
2916
  });
2907
- return executeUpgradeBatch(prepared, options.gas, logger);
2917
+ const data = {
2918
+ appId: prepared.appId,
2919
+ executions: prepared.executions
2920
+ };
2921
+ const context = {
2922
+ walletClient: prepared.walletClient,
2923
+ publicClient: prepared.publicClient,
2924
+ environmentConfig: prepared.environmentConfig
2925
+ };
2926
+ return executeUpgradeBatch(data, context, options.gas, logger);
2908
2927
  }
2909
2928
  async function sendAndWaitForTransaction(options, logger) {
2910
2929
  const {
@@ -3643,6 +3662,7 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
3643
3662
  tag,
3644
3663
  "-f",
3645
3664
  dockerfilePath,
3665
+ "--load",
3646
3666
  "--progress=plain",
3647
3667
  buildContext
3648
3668
  ];
@@ -3766,9 +3786,9 @@ async function pullDockerImage(docker, imageTag, platform = "linux/amd64", logge
3766
3786
 
3767
3787
  // src/client/common/docker/push.ts
3768
3788
  import * as child_process2 from "child_process";
3769
- import { exec as exec3 } from "child_process";
3789
+ import { execFile } from "child_process";
3770
3790
  import { promisify as promisify2 } from "util";
3771
- var execAsync = promisify2(exec3);
3791
+ var execFileAsync = promisify2(execFile);
3772
3792
  async function pushDockerImage(docker, imageRef, logger) {
3773
3793
  logger?.info?.(`Pushing image ${imageRef}...`);
3774
3794
  return new Promise((resolve2, reject) => {
@@ -3835,7 +3855,7 @@ async function verifyImageExists(imageRef, logger) {
3835
3855
  let retries = 5;
3836
3856
  while (retries > 0) {
3837
3857
  try {
3838
- await execAsync(`docker manifest inspect ${imageRef}`, {
3858
+ await execFileAsync("docker", ["manifest", "inspect", imageRef], {
3839
3859
  maxBuffer: 10 * 1024 * 1024,
3840
3860
  timeout: 1e4
3841
3861
  // 10 second timeout
@@ -4293,10 +4313,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
4293
4313
  // src/client/common/registry/digest.ts
4294
4314
  import * as child_process3 from "child_process";
4295
4315
  import { promisify as promisify3 } from "util";
4296
- var execFileAsync = promisify3(child_process3.execFile);
4316
+ var execFileAsync2 = promisify3(child_process3.execFile);
4297
4317
  async function getImageDigestAndName(imageRef) {
4298
4318
  try {
4299
- const { stdout } = await execFileAsync(
4319
+ const { stdout } = await execFileAsync2(
4300
4320
  "docker",
4301
4321
  ["manifest", "inspect", imageRef],
4302
4322
  { maxBuffer: 10 * 1024 * 1024 }
@@ -4336,7 +4356,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
4336
4356
  }
4337
4357
  async function extractDigestFromSinglePlatform(manifest, imageRef) {
4338
4358
  try {
4339
- const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
4359
+ const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
4340
4360
  maxBuffer: 10 * 1024 * 1024
4341
4361
  });
4342
4362
  const inspectData = JSON.parse(stdout);
@@ -5038,23 +5058,24 @@ async function prepareDeploy(options, logger = defaultLogger) {
5038
5058
  environmentConfig: batch.environmentConfig,
5039
5059
  executions: batch.executions
5040
5060
  });
5061
+ const data = {
5062
+ appId: batch.appId,
5063
+ salt: batch.salt,
5064
+ executions: batch.executions
5065
+ };
5041
5066
  return {
5042
5067
  prepared: {
5043
- batch,
5068
+ data,
5044
5069
  appName,
5045
- imageRef: finalImageRef,
5046
- preflightCtx: {
5047
- privateKey: preflightCtx.privateKey,
5048
- rpcUrl: preflightCtx.rpcUrl,
5049
- environmentConfig: preflightCtx.environmentConfig
5050
- }
5070
+ imageRef: finalImageRef
5051
5071
  },
5052
5072
  gasEstimate
5053
5073
  };
5054
5074
  }
5055
5075
  );
5056
5076
  }
5057
- async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetry) {
5077
+ async function executeDeploy(options) {
5078
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5058
5079
  return withSDKTelemetry(
5059
5080
  {
5060
5081
  functionName: "executeDeploy",
@@ -5062,7 +5083,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetr
5062
5083
  },
5063
5084
  async () => {
5064
5085
  logger.info("Deploying on-chain...");
5065
- const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
5086
+ const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
5066
5087
  return {
5067
5088
  appId,
5068
5089
  txHash,
@@ -5289,23 +5310,23 @@ async function prepareUpgrade(options, logger = defaultLogger) {
5289
5310
  environmentConfig: batch.environmentConfig,
5290
5311
  executions: batch.executions
5291
5312
  });
5313
+ const data = {
5314
+ appId: batch.appId,
5315
+ executions: batch.executions
5316
+ };
5292
5317
  return {
5293
5318
  prepared: {
5294
- batch,
5319
+ data,
5295
5320
  appId: appID,
5296
- imageRef: finalImageRef,
5297
- preflightCtx: {
5298
- privateKey: preflightCtx.privateKey,
5299
- rpcUrl: preflightCtx.rpcUrl,
5300
- environmentConfig: preflightCtx.environmentConfig
5301
- }
5321
+ imageRef: finalImageRef
5302
5322
  },
5303
5323
  gasEstimate
5304
5324
  };
5305
5325
  }
5306
5326
  );
5307
5327
  }
5308
- async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemetry) {
5328
+ async function executeUpgrade(options) {
5329
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5309
5330
  return withSDKTelemetry(
5310
5331
  {
5311
5332
  functionName: "executeUpgrade",
@@ -5313,7 +5334,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemet
5313
5334
  },
5314
5335
  async () => {
5315
5336
  logger.info("Upgrading on-chain...");
5316
- const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
5337
+ const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
5317
5338
  return {
5318
5339
  appId: prepared.appId,
5319
5340
  imageRef: prepared.imageRef,
@@ -5442,10 +5463,10 @@ import * as path6 from "path";
5442
5463
  import * as fs5 from "fs";
5443
5464
  import * as path4 from "path";
5444
5465
  import * as os2 from "os";
5445
- import { exec as exec4, execFile as execFile2 } from "child_process";
5466
+ import { exec as exec3, execFile as execFile3 } from "child_process";
5446
5467
  import { promisify as promisify4 } from "util";
5447
- var execAsync2 = promisify4(exec4);
5448
- var execFileAsync2 = promisify4(execFile2);
5468
+ var execAsync = promisify4(exec3);
5469
+ var execFileAsync3 = promisify4(execFile3);
5449
5470
  async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5450
5471
  if (!repoURL) {
5451
5472
  throw new Error("repoURL is required");
@@ -5454,13 +5475,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5454
5475
  Cloning repo: ${repoURL} \u2192 ${targetDir}
5455
5476
  `);
5456
5477
  try {
5457
- await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5478
+ await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5458
5479
  maxBuffer: 10 * 1024 * 1024
5459
5480
  });
5460
- await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5481
+ await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5461
5482
  maxBuffer: 10 * 1024 * 1024
5462
5483
  });
5463
- await execFileAsync2(
5484
+ await execFileAsync3(
5464
5485
  "git",
5465
5486
  ["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
5466
5487
  { maxBuffer: 10 * 1024 * 1024 }
@@ -5505,14 +5526,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
5505
5526
  }
5506
5527
  async function cloneSparse(repoURL, ref, subPath, tempDir) {
5507
5528
  try {
5508
- await execFileAsync2("git", ["init", tempDir]);
5509
- await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5510
- await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5529
+ await execFileAsync3("git", ["init", tempDir]);
5530
+ await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5531
+ await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5511
5532
  const sparseCheckoutPath = path4.join(tempDir, ".git/info/sparse-checkout");
5512
5533
  fs5.writeFileSync(sparseCheckoutPath, `${subPath}
5513
5534
  `);
5514
- await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
5515
- await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
5535
+ await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
5536
+ await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
5516
5537
  } catch (error) {
5517
5538
  throw new Error(`Failed to clone sparse repository: ${error.message}`);
5518
5539
  }
@@ -6005,7 +6026,14 @@ async function logs(options, logger = defaultLogger, skipTelemetry = false) {
6005
6026
  }
6006
6027
 
6007
6028
  // src/client/modules/compute/app/index.ts
6008
- import { parseAbi, encodeFunctionData as encodeFunctionData3 } from "viem";
6029
+ import {
6030
+ parseAbi,
6031
+ encodeFunctionData as encodeFunctionData3,
6032
+ createWalletClient as createWalletClient2,
6033
+ createPublicClient as createPublicClient4,
6034
+ http as http4
6035
+ } from "viem";
6036
+ import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
6009
6037
  var CONTROLLER_ABI = parseAbi([
6010
6038
  "function startApp(address appId)",
6011
6039
  "function stopApp(address appId)",
@@ -6088,6 +6116,151 @@ function createAppModule(ctx) {
6088
6116
  imageRef: result.imageRef
6089
6117
  };
6090
6118
  },
6119
+ // Granular deploy control
6120
+ async prepareDeploy(opts) {
6121
+ return prepareDeploy(
6122
+ {
6123
+ privateKey,
6124
+ rpcUrl: ctx.rpcUrl,
6125
+ environment: ctx.environment,
6126
+ appName: opts.name,
6127
+ instanceType: opts.instanceType,
6128
+ dockerfilePath: opts.dockerfile,
6129
+ envFilePath: opts.envFile,
6130
+ imageRef: opts.imageRef,
6131
+ logVisibility: opts.logVisibility,
6132
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6133
+ skipTelemetry
6134
+ },
6135
+ logger
6136
+ );
6137
+ },
6138
+ async executeDeploy(prepared, gas) {
6139
+ const account = privateKeyToAccount3(privateKey);
6140
+ const chain = getChainFromID(environment.chainID);
6141
+ const publicClient = createPublicClient4({
6142
+ chain,
6143
+ transport: http4(ctx.rpcUrl)
6144
+ });
6145
+ const walletClient = createWalletClient2({
6146
+ account,
6147
+ chain,
6148
+ transport: http4(ctx.rpcUrl)
6149
+ });
6150
+ const result = await executeDeploy({
6151
+ prepared,
6152
+ context: {
6153
+ walletClient,
6154
+ publicClient,
6155
+ environmentConfig: environment
6156
+ },
6157
+ gas,
6158
+ logger,
6159
+ skipTelemetry
6160
+ });
6161
+ return {
6162
+ appId: result.appId,
6163
+ txHash: result.txHash,
6164
+ appName: result.appName,
6165
+ imageRef: result.imageRef
6166
+ };
6167
+ },
6168
+ async watchDeployment(appId) {
6169
+ return watchDeployment(
6170
+ appId,
6171
+ privateKey,
6172
+ ctx.rpcUrl,
6173
+ ctx.environment,
6174
+ logger,
6175
+ ctx.clientId,
6176
+ skipTelemetry
6177
+ );
6178
+ },
6179
+ // Granular upgrade control
6180
+ async prepareUpgrade(appId, opts) {
6181
+ return prepareUpgrade(
6182
+ {
6183
+ appId,
6184
+ privateKey,
6185
+ rpcUrl: ctx.rpcUrl,
6186
+ environment: ctx.environment,
6187
+ instanceType: opts.instanceType,
6188
+ dockerfilePath: opts.dockerfile,
6189
+ envFilePath: opts.envFile,
6190
+ imageRef: opts.imageRef,
6191
+ logVisibility: opts.logVisibility,
6192
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6193
+ skipTelemetry
6194
+ },
6195
+ logger
6196
+ );
6197
+ },
6198
+ async executeUpgrade(prepared, gas) {
6199
+ const account = privateKeyToAccount3(privateKey);
6200
+ const chain = getChainFromID(environment.chainID);
6201
+ const publicClient = createPublicClient4({
6202
+ chain,
6203
+ transport: http4(ctx.rpcUrl)
6204
+ });
6205
+ const walletClient = createWalletClient2({
6206
+ account,
6207
+ chain,
6208
+ transport: http4(ctx.rpcUrl)
6209
+ });
6210
+ const result = await executeUpgrade({
6211
+ prepared,
6212
+ context: {
6213
+ walletClient,
6214
+ publicClient,
6215
+ environmentConfig: environment
6216
+ },
6217
+ gas,
6218
+ logger,
6219
+ skipTelemetry
6220
+ });
6221
+ return {
6222
+ appId: result.appId,
6223
+ txHash: result.txHash,
6224
+ imageRef: result.imageRef
6225
+ };
6226
+ },
6227
+ async watchUpgrade(appId) {
6228
+ return watchUpgrade(
6229
+ appId,
6230
+ privateKey,
6231
+ ctx.rpcUrl,
6232
+ ctx.environment,
6233
+ logger,
6234
+ ctx.clientId,
6235
+ skipTelemetry
6236
+ );
6237
+ },
6238
+ // Profile management
6239
+ async setProfile(appId, profile) {
6240
+ return withSDKTelemetry(
6241
+ {
6242
+ functionName: "setProfile",
6243
+ skipTelemetry,
6244
+ properties: { environment: ctx.environment }
6245
+ },
6246
+ async () => {
6247
+ const userApiClient = new UserApiClient(
6248
+ environment,
6249
+ privateKey,
6250
+ ctx.rpcUrl,
6251
+ ctx.clientId
6252
+ );
6253
+ return userApiClient.uploadAppProfile(
6254
+ appId,
6255
+ profile.name,
6256
+ profile.website,
6257
+ profile.description,
6258
+ profile.xURL,
6259
+ profile.imagePath
6260
+ );
6261
+ }
6262
+ );
6263
+ },
6091
6264
  async logs(opts) {
6092
6265
  return logs(
6093
6266
  {
@@ -6286,4 +6459,4 @@ export {
6286
6459
  createAppModule,
6287
6460
  createComputeModule
6288
6461
  };
6289
- //# sourceMappingURL=chunk-X4Y6OOUS.js.map
6462
+ //# sourceMappingURL=chunk-XDS4EF4J.js.map