@layr-labs/ecloud-sdk 1.0.0-dev.2 → 1.0.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { E as EnvironmentConfig, a4 as SubscriptionStatus, f as BillingEnvironmentConfig, Y as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, y as GetSubscriptionOptions, Z as ProductSubscriptionResponse, G as GasEstimate, F as Logger } from './index-U2vKBrry.js';
1
+ import { E as EnvironmentConfig, a7 as SubscriptionStatus, f as BillingEnvironmentConfig, $ as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, z as GetSubscriptionOptions, a0 as ProductSubscriptionResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse, G as GasEstimate, H as Logger } from './index-Bac4HjC0.cjs';
2
2
  import { Address, Hex, WalletClient, PublicClient, SignAuthorizationReturnType, Chain } from 'viem';
3
3
 
4
4
  /**
@@ -733,6 +733,8 @@ interface BillingApiClientOptions {
733
733
  * When false (default), uses EIP-712 typed data signatures for each request.
734
734
  */
735
735
  useSession?: boolean;
736
+ /** Log request/response details to stderr */
737
+ verbose?: boolean;
736
738
  }
737
739
  /**
738
740
  * BillingAPI Client for managing product subscriptions.
@@ -796,6 +798,8 @@ declare class BillingApiClient {
796
798
  createSubscription(productId?: ProductID, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
797
799
  getSubscription(productId?: ProductID, options?: GetSubscriptionOptions): Promise<ProductSubscriptionResponse>;
798
800
  cancelSubscription(productId?: ProductID): Promise<void>;
801
+ getPaymentMethods(): Promise<PaymentMethodsResponse>;
802
+ purchaseCredits(amountCents: number, paymentMethodId?: string): Promise<CreditPurchaseResponse>;
799
803
  /**
800
804
  * Make an authenticated request to the billing API
801
805
  *
@@ -1,4 +1,4 @@
1
- import { E as EnvironmentConfig, a4 as SubscriptionStatus, f as BillingEnvironmentConfig, Y as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, y as GetSubscriptionOptions, Z as ProductSubscriptionResponse, G as GasEstimate, F as Logger } from './index-U2vKBrry.cjs';
1
+ import { E as EnvironmentConfig, a7 as SubscriptionStatus, f as BillingEnvironmentConfig, $ as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, z as GetSubscriptionOptions, a0 as ProductSubscriptionResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse, G as GasEstimate, H as Logger } from './index-Bac4HjC0.js';
2
2
  import { Address, Hex, WalletClient, PublicClient, SignAuthorizationReturnType, Chain } from 'viem';
3
3
 
4
4
  /**
@@ -733,6 +733,8 @@ interface BillingApiClientOptions {
733
733
  * When false (default), uses EIP-712 typed data signatures for each request.
734
734
  */
735
735
  useSession?: boolean;
736
+ /** Log request/response details to stderr */
737
+ verbose?: boolean;
736
738
  }
737
739
  /**
738
740
  * BillingAPI Client for managing product subscriptions.
@@ -796,6 +798,8 @@ declare class BillingApiClient {
796
798
  createSubscription(productId?: ProductID, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
797
799
  getSubscription(productId?: ProductID, options?: GetSubscriptionOptions): Promise<ProductSubscriptionResponse>;
798
800
  cancelSubscription(productId?: ProductID): Promise<void>;
801
+ getPaymentMethods(): Promise<PaymentMethodsResponse>;
802
+ purchaseCredits(amountCents: number, paymentMethodId?: string): Promise<CreditPurchaseResponse>;
799
803
  /**
800
804
  * Make an authenticated request to the billing API
801
805
  *
@@ -749,6 +749,22 @@ interface SubscriptionOpts {
749
749
  /** URL to redirect to if checkout is canceled */
750
750
  cancelUrl?: string;
751
751
  }
752
+ interface PaymentMethod {
753
+ id: string;
754
+ stripePaymentMethodId: string;
755
+ brand: string;
756
+ last4: string;
757
+ createdAt: string;
758
+ }
759
+ interface PaymentMethodsResponse {
760
+ paymentMethods: PaymentMethod[];
761
+ }
762
+ interface CreditPurchaseResponse {
763
+ purchaseId?: string;
764
+ checkoutSessionId?: string;
765
+ checkoutUrl?: string;
766
+ amountCents: string;
767
+ }
752
768
  interface BillingEnvironmentConfig {
753
769
  billingApiServerURL: string;
754
770
  }
@@ -776,4 +792,4 @@ interface SequentialDeployResult {
776
792
  };
777
793
  }
778
794
 
779
- export { type SendTransactionOptions as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type Logger as F, type GasEstimate as G, type PaymentIssueResponse as H, type ImageDigestResult as I, type PrepareDeployBatchOptions as J, type PrepareDeployFromVerifiableBuildOpts as K, type LifecycleOpts as L, type PrepareDeployOpts as M, type NoActiveSubscriptionResponse as N, type PrepareUpgradeBatchOptions as O, type ParsedEnvironment as P, type PrepareUpgradeFromVerifiableBuildOpts as Q, type PrepareUpgradeOpts as R, type PreparedDeploy as S, type PreparedDeployBatch as T, type PreparedDeployData as U, type PreparedUpgrade as V, type PreparedUpgradeBatch as W, type PreparedUpgradeData as X, type ProductID as Y, type ProductSubscriptionResponse as Z, type Release as _, type AlreadyActiveResponse as a, type SequentialDeployResult as a0, type SubscribeResponse as a1, type SubscriptionLineItem as a2, type SubscriptionOpts as a3, type SubscriptionStatus as a4, type SuspendOptions as a5, type UndelegateOptions as a6, type UpgradeAppOptions as a7, type UpgradeAppOpts as a8, calculateAppID as a9, getBlockTimestamps as aA, deployApp as aa, estimateTransactionGas as ab, executeDeployBatch as ac, executeDeployBatched as ad, executeDeploySequential as ae, executeUpgradeBatch as af, formatETH as ag, getActiveAppCount as ah, getAllAppsByDeveloper as ai, getAppsByBillingAccount as aj, getAppsByCreator as ak, getAppsByDeveloper as al, getBillingType as am, getMaxActiveAppsPerUser as an, isDelegated as ao, type logVisibility as ap, noopLogger as aq, prepareDeployBatch as ar, prepareUpgradeBatch as as, sendAndWaitForTransaction as at, supportsEIP5792 as au, supportsEIP7702 as av, suspend as aw, undelegate as ax, upgradeApp as ay, getAppLatestReleaseBlockNumbers as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type DeployAppOpts as m, type DeployOptions as n, type DeployProgressCallback as o, type DeployResult as p, type DeployStep as q, type DockerImageConfig as r, type EstimateGasOptions as s, type ExecuteDeployBatchedOptions as t, type ExecuteDeployResult as u, type ExecuteDeploySequentialOptions as v, type ExecuteUpgradeResult as w, type GasOpts as x, type GetSubscriptionOptions as y, type IsDelegatedOptions as z };
795
+ export { type ProductID as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type IsDelegatedOptions as F, type GasEstimate as G, type Logger as H, type ImageDigestResult as I, type PaymentIssueResponse as J, type PaymentMethod as K, type LifecycleOpts as L, type PaymentMethodsResponse as M, type NoActiveSubscriptionResponse as N, type PrepareDeployBatchOptions as O, type ParsedEnvironment as P, type PrepareDeployFromVerifiableBuildOpts as Q, type PrepareDeployOpts as R, type PrepareUpgradeBatchOptions as S, type PrepareUpgradeFromVerifiableBuildOpts as T, type PrepareUpgradeOpts as U, type PreparedDeploy as V, type PreparedDeployBatch as W, type PreparedDeployData as X, type PreparedUpgrade as Y, type PreparedUpgradeBatch as Z, type PreparedUpgradeData as _, type AlreadyActiveResponse as a, type ProductSubscriptionResponse as a0, type Release as a1, type SendTransactionOptions as a2, type SequentialDeployResult as a3, type SubscribeResponse as a4, type SubscriptionLineItem as a5, type SubscriptionOpts as a6, type SubscriptionStatus as a7, type SuspendOptions as a8, type UndelegateOptions as a9, undelegate as aA, upgradeApp as aB, getAppLatestReleaseBlockNumbers as aC, getBlockTimestamps as aD, type UpgradeAppOptions as aa, type UpgradeAppOpts as ab, calculateAppID as ac, deployApp as ad, estimateTransactionGas as ae, executeDeployBatch as af, executeDeployBatched as ag, executeDeploySequential as ah, executeUpgradeBatch as ai, formatETH as aj, getActiveAppCount as ak, getAllAppsByDeveloper as al, getAppsByBillingAccount as am, getAppsByCreator as an, getAppsByDeveloper as ao, getBillingType as ap, getMaxActiveAppsPerUser as aq, isDelegated as ar, type logVisibility as as, noopLogger as at, prepareDeployBatch as au, prepareUpgradeBatch as av, sendAndWaitForTransaction as aw, supportsEIP5792 as ax, supportsEIP7702 as ay, suspend as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type CreditPurchaseResponse as m, type DeployAppOpts as n, type DeployOptions as o, type DeployProgressCallback as p, type DeployResult as q, type DeployStep as r, type DockerImageConfig as s, type EstimateGasOptions as t, type ExecuteDeployBatchedOptions as u, type ExecuteDeployResult as v, type ExecuteDeploySequentialOptions as w, type ExecuteUpgradeResult as x, type GasOpts as y, type GetSubscriptionOptions as z };
@@ -749,6 +749,22 @@ interface SubscriptionOpts {
749
749
  /** URL to redirect to if checkout is canceled */
750
750
  cancelUrl?: string;
751
751
  }
752
+ interface PaymentMethod {
753
+ id: string;
754
+ stripePaymentMethodId: string;
755
+ brand: string;
756
+ last4: string;
757
+ createdAt: string;
758
+ }
759
+ interface PaymentMethodsResponse {
760
+ paymentMethods: PaymentMethod[];
761
+ }
762
+ interface CreditPurchaseResponse {
763
+ purchaseId?: string;
764
+ checkoutSessionId?: string;
765
+ checkoutUrl?: string;
766
+ amountCents: string;
767
+ }
752
768
  interface BillingEnvironmentConfig {
753
769
  billingApiServerURL: string;
754
770
  }
@@ -776,4 +792,4 @@ interface SequentialDeployResult {
776
792
  };
777
793
  }
778
794
 
779
- export { type SendTransactionOptions as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type Logger as F, type GasEstimate as G, type PaymentIssueResponse as H, type ImageDigestResult as I, type PrepareDeployBatchOptions as J, type PrepareDeployFromVerifiableBuildOpts as K, type LifecycleOpts as L, type PrepareDeployOpts as M, type NoActiveSubscriptionResponse as N, type PrepareUpgradeBatchOptions as O, type ParsedEnvironment as P, type PrepareUpgradeFromVerifiableBuildOpts as Q, type PrepareUpgradeOpts as R, type PreparedDeploy as S, type PreparedDeployBatch as T, type PreparedDeployData as U, type PreparedUpgrade as V, type PreparedUpgradeBatch as W, type PreparedUpgradeData as X, type ProductID as Y, type ProductSubscriptionResponse as Z, type Release as _, type AlreadyActiveResponse as a, type SequentialDeployResult as a0, type SubscribeResponse as a1, type SubscriptionLineItem as a2, type SubscriptionOpts as a3, type SubscriptionStatus as a4, type SuspendOptions as a5, type UndelegateOptions as a6, type UpgradeAppOptions as a7, type UpgradeAppOpts as a8, calculateAppID as a9, getBlockTimestamps as aA, deployApp as aa, estimateTransactionGas as ab, executeDeployBatch as ac, executeDeployBatched as ad, executeDeploySequential as ae, executeUpgradeBatch as af, formatETH as ag, getActiveAppCount as ah, getAllAppsByDeveloper as ai, getAppsByBillingAccount as aj, getAppsByCreator as ak, getAppsByDeveloper as al, getBillingType as am, getMaxActiveAppsPerUser as an, isDelegated as ao, type logVisibility as ap, noopLogger as aq, prepareDeployBatch as ar, prepareUpgradeBatch as as, sendAndWaitForTransaction as at, supportsEIP5792 as au, supportsEIP7702 as av, suspend as aw, undelegate as ax, upgradeApp as ay, getAppLatestReleaseBlockNumbers as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type DeployAppOpts as m, type DeployOptions as n, type DeployProgressCallback as o, type DeployResult as p, type DeployStep as q, type DockerImageConfig as r, type EstimateGasOptions as s, type ExecuteDeployBatchedOptions as t, type ExecuteDeployResult as u, type ExecuteDeploySequentialOptions as v, type ExecuteUpgradeResult as w, type GasOpts as x, type GetSubscriptionOptions as y, type IsDelegatedOptions as z };
795
+ export { type ProductID as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type IsDelegatedOptions as F, type GasEstimate as G, type Logger as H, type ImageDigestResult as I, type PaymentIssueResponse as J, type PaymentMethod as K, type LifecycleOpts as L, type PaymentMethodsResponse as M, type NoActiveSubscriptionResponse as N, type PrepareDeployBatchOptions as O, type ParsedEnvironment as P, type PrepareDeployFromVerifiableBuildOpts as Q, type PrepareDeployOpts as R, type PrepareUpgradeBatchOptions as S, type PrepareUpgradeFromVerifiableBuildOpts as T, type PrepareUpgradeOpts as U, type PreparedDeploy as V, type PreparedDeployBatch as W, type PreparedDeployData as X, type PreparedUpgrade as Y, type PreparedUpgradeBatch as Z, type PreparedUpgradeData as _, type AlreadyActiveResponse as a, type ProductSubscriptionResponse as a0, type Release as a1, type SendTransactionOptions as a2, type SequentialDeployResult as a3, type SubscribeResponse as a4, type SubscriptionLineItem as a5, type SubscriptionOpts as a6, type SubscriptionStatus as a7, type SuspendOptions as a8, type UndelegateOptions as a9, undelegate as aA, upgradeApp as aB, getAppLatestReleaseBlockNumbers as aC, getBlockTimestamps as aD, type UpgradeAppOptions as aa, type UpgradeAppOpts as ab, calculateAppID as ac, deployApp as ad, estimateTransactionGas as ae, executeDeployBatch as af, executeDeployBatched as ag, executeDeploySequential as ah, executeUpgradeBatch as ai, formatETH as aj, getActiveAppCount as ak, getAllAppsByDeveloper as al, getAppsByBillingAccount as am, getAppsByCreator as an, getAppsByDeveloper as ao, getBillingType as ap, getMaxActiveAppsPerUser as aq, isDelegated as ar, type logVisibility as as, noopLogger as at, prepareDeployBatch as au, prepareUpgradeBatch as av, sendAndWaitForTransaction as aw, supportsEIP5792 as ax, supportsEIP7702 as ay, suspend as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type CreditPurchaseResponse as m, type DeployAppOpts as n, type DeployOptions as o, type DeployProgressCallback as p, type DeployResult as q, type DeployStep as r, type DockerImageConfig as s, type EstimateGasOptions as t, type ExecuteDeployBatchedOptions as u, type ExecuteDeployResult as v, type ExecuteDeploySequentialOptions as w, type ExecuteUpgradeResult as x, type GasOpts as y, type GetSubscriptionOptions as z };
package/dist/index.cjs CHANGED
@@ -4986,7 +4986,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4986
4986
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4987
4987
  var CanUpdateAppProfilePermission = "0x036fef61";
4988
4988
  function getDefaultClientId() {
4989
- const version = true ? "1.0.0-dev.2" : "0.0.0";
4989
+ const version = true ? "1.0.0-dev.3" : "0.0.0";
4990
4990
  return `ecloud-sdk/v${version}`;
4991
4991
  }
4992
4992
  var UserApiClient = class {
@@ -5831,7 +5831,13 @@ function getEnvironmentConfig(environment, chainID) {
5831
5831
  return {
5832
5832
  ...env,
5833
5833
  chainID: BigInt(resolvedChainID),
5834
- ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
5834
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {},
5835
+ ...process.env.ECLOUD_USER_API_URL && {
5836
+ userApiServerURL: process.env.ECLOUD_USER_API_URL
5837
+ },
5838
+ ...process.env.ECLOUD_RPC_URL && {
5839
+ defaultRPCURL: process.env.ECLOUD_RPC_URL
5840
+ }
5835
5841
  };
5836
5842
  }
5837
5843
  function getBillingEnvironmentConfig(build) {
@@ -5843,7 +5849,12 @@ function getBillingEnvironmentConfig(build) {
5843
5849
  if (apiUrlOverride) {
5844
5850
  return { billingApiServerURL: apiUrlOverride };
5845
5851
  }
5846
- return config;
5852
+ return {
5853
+ ...config,
5854
+ ...process.env.ECLOUD_BILLING_API_URL && {
5855
+ billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
5856
+ }
5857
+ };
5847
5858
  }
5848
5859
  function getBuildType() {
5849
5860
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -6148,6 +6159,20 @@ var BillingApiClient = class {
6148
6159
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
6149
6160
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
6150
6161
  }
6162
+ async getPaymentMethods() {
6163
+ const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
6164
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
6165
+ return resp.json();
6166
+ }
6167
+ async purchaseCredits(amountCents, paymentMethodId) {
6168
+ const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
6169
+ const body = { amountCents };
6170
+ if (paymentMethodId) {
6171
+ body.paymentMethodId = paymentMethodId;
6172
+ }
6173
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
6174
+ return resp.json();
6175
+ }
6151
6176
  // ==========================================================================
6152
6177
  // Internal Methods
6153
6178
  // ==========================================================================
@@ -6157,10 +6182,22 @@ var BillingApiClient = class {
6157
6182
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
6158
6183
  */
6159
6184
  async makeAuthenticatedRequest(url, method, productId, body) {
6160
- if (this.useSession) {
6161
- return this.makeSessionAuthenticatedRequest(url, method, body);
6185
+ if (this.options.verbose) {
6186
+ console.debug(`[BillingAPI] ${method} ${url}`);
6187
+ if (body) {
6188
+ console.debug(`[BillingAPI] Payload:`, JSON.stringify(body, null, 2));
6189
+ }
6190
+ }
6191
+ const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
6192
+ if (this.options.verbose) {
6193
+ const data = await resp.json();
6194
+ console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
6195
+ return {
6196
+ json: async () => data,
6197
+ text: async () => JSON.stringify(data)
6198
+ };
6162
6199
  }
6163
- return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
6200
+ return resp;
6164
6201
  }
6165
6202
  /**
6166
6203
  * Make a request using session-based authentication (cookies)
@@ -8349,7 +8386,7 @@ function createBillingModule(config) {
8349
8386
  const address = walletClient.account.address;
8350
8387
  const logger = getLogger(verbose);
8351
8388
  const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
8352
- const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
8389
+ const billingApi = new BillingApiClient(billingEnvConfig, walletClient, { verbose });
8353
8390
  const environmentConfig = getEnvironmentConfig(environment);
8354
8391
  const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
8355
8392
  if (!usdcCreditsAddress) {
@@ -8513,6 +8550,12 @@ function createBillingModule(config) {
8513
8550
  };
8514
8551
  }
8515
8552
  );
8553
+ },
8554
+ async getPaymentMethods() {
8555
+ return billingApi.getPaymentMethods();
8556
+ },
8557
+ async purchaseCredits(amountCents, paymentMethodId) {
8558
+ return billingApi.purchaseCredits(amountCents, paymentMethodId);
8516
8559
  }
8517
8560
  };
8518
8561
  return module2;