@layr-labs/ecloud-sdk 0.3.0-dev.0 → 0.3.1-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 +4 -273
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +1 -1
- package/dist/billing.d.ts +1 -1
- package/dist/billing.js +4 -275
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +173 -569
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +12 -53
- package/dist/browser.d.ts +12 -53
- package/dist/browser.js +173 -569
- package/dist/browser.js.map +1 -1
- package/dist/{compute-BcJuIxc1.d.ts → compute-BYhSs8en.d.ts} +1 -1
- package/dist/{compute-oD9uqLtr.d.cts → compute-Bpjb3hYD.d.cts} +1 -1
- package/dist/compute.cjs +154 -240
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.d.cts +2 -2
- package/dist/compute.d.ts +2 -2
- package/dist/compute.js +154 -242
- package/dist/compute.js.map +1 -1
- package/dist/{helpers-Cp8qGRTb.d.ts → helpers-CEvhJz7f.d.cts} +5 -249
- package/dist/{helpers-BNGcO-VX.d.cts → helpers-CQuBwQnu.d.ts} +5 -249
- package/dist/{index-5y9NG_Id.d.cts → index-DeQzn_yM.d.cts} +1 -9
- package/dist/{index-5y9NG_Id.d.ts → index-DeQzn_yM.d.ts} +1 -9
- package/dist/index.cjs +229 -646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +228 -647
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-
|
|
2
|
-
import { Address, Hex, WalletClient, PublicClient,
|
|
1
|
+
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-DeQzn_yM.cjs';
|
|
2
|
+
import { Address, Hex, WalletClient, PublicClient, Chain } from 'viem';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment configuration for different networks
|
|
@@ -538,273 +538,32 @@ declare class UserApiClient {
|
|
|
538
538
|
getSiweSession(): Promise<SessionInfo>;
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
/**
|
|
542
|
-
* Billing API Session Management
|
|
543
|
-
*
|
|
544
|
-
* This module provides utilities for managing authentication sessions with the billing API
|
|
545
|
-
* using SIWE (Sign-In with Ethereum).
|
|
546
|
-
*
|
|
547
|
-
* The billing API now supports the same SIWE-based session authentication as the compute API,
|
|
548
|
-
* allowing users to sign once and authenticate to both APIs simultaneously.
|
|
549
|
-
*/
|
|
550
|
-
|
|
551
|
-
interface BillingApiConfig {
|
|
552
|
-
/** Base URL of the billing API (e.g., "https://billing.eigencloud.xyz") */
|
|
553
|
-
baseUrl: string;
|
|
554
|
-
}
|
|
555
|
-
interface BillingSessionInfo {
|
|
556
|
-
/** Whether the session is authenticated */
|
|
557
|
-
authenticated: boolean;
|
|
558
|
-
/** Authenticated wallet address (if authenticated) */
|
|
559
|
-
address?: Address;
|
|
560
|
-
/** Chain ID used for authentication (if authenticated) */
|
|
561
|
-
chainId?: number;
|
|
562
|
-
/** Unix timestamp when authentication occurred (if authenticated) */
|
|
563
|
-
authenticatedAt?: number;
|
|
564
|
-
}
|
|
565
|
-
interface BillingLoginResult {
|
|
566
|
-
/** Whether login was successful */
|
|
567
|
-
success: boolean;
|
|
568
|
-
/** Authenticated wallet address */
|
|
569
|
-
address: Address;
|
|
570
|
-
}
|
|
571
|
-
interface BillingLoginRequest {
|
|
572
|
-
/** SIWE message string */
|
|
573
|
-
message: string;
|
|
574
|
-
/** Hex-encoded signature (with or without 0x prefix) */
|
|
575
|
-
signature: Hex | string;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Error thrown when billing session operations fail
|
|
579
|
-
*/
|
|
580
|
-
declare class BillingSessionError extends Error {
|
|
581
|
-
readonly code: "NETWORK_ERROR" | "INVALID_SIGNATURE" | "INVALID_MESSAGE" | "SESSION_EXPIRED" | "UNAUTHORIZED" | "UNKNOWN";
|
|
582
|
-
readonly statusCode?: number | undefined;
|
|
583
|
-
constructor(message: string, code: "NETWORK_ERROR" | "INVALID_SIGNATURE" | "INVALID_MESSAGE" | "SESSION_EXPIRED" | "UNAUTHORIZED" | "UNKNOWN", statusCode?: number | undefined);
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Login to the billing API using SIWE
|
|
587
|
-
*
|
|
588
|
-
* This establishes a session with the billing API by verifying the SIWE message
|
|
589
|
-
* and signature. On success, a session cookie is set in the browser.
|
|
590
|
-
*
|
|
591
|
-
* The billing API accepts the same SIWE message format as the compute API,
|
|
592
|
-
* so users only need to sign once and can send the same message/signature
|
|
593
|
-
* to both APIs.
|
|
594
|
-
*
|
|
595
|
-
* @param config - Billing API configuration
|
|
596
|
-
* @param request - Login request containing SIWE message and signature
|
|
597
|
-
* @returns Login result with the authenticated address
|
|
598
|
-
*
|
|
599
|
-
* @example
|
|
600
|
-
* ```typescript
|
|
601
|
-
* import { createSiweMessage, loginToBillingApi } from "@layr-labs/ecloud-sdk/browser";
|
|
602
|
-
*
|
|
603
|
-
* const { message } = createSiweMessage({
|
|
604
|
-
* address: userAddress,
|
|
605
|
-
* chainId: 11155111,
|
|
606
|
-
* domain: window.location.host,
|
|
607
|
-
* uri: window.location.origin,
|
|
608
|
-
* });
|
|
609
|
-
*
|
|
610
|
-
* const signature = await signMessageAsync({ message });
|
|
611
|
-
*
|
|
612
|
-
* // Can send to both APIs with the same message/signature
|
|
613
|
-
* const [computeResult, billingResult] = await Promise.all([
|
|
614
|
-
* loginToComputeApi({ baseUrl: computeApiUrl }, { message, signature }),
|
|
615
|
-
* loginToBillingApi({ baseUrl: billingApiUrl }, { message, signature }),
|
|
616
|
-
* ]);
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
declare function loginToBillingApi(config: BillingApiConfig, request: BillingLoginRequest): Promise<BillingLoginResult>;
|
|
620
|
-
/**
|
|
621
|
-
* Get the current session status from the billing API
|
|
622
|
-
*
|
|
623
|
-
* @param config - Billing API configuration
|
|
624
|
-
* @returns Session information including authentication status and address
|
|
625
|
-
*
|
|
626
|
-
* @example
|
|
627
|
-
* ```typescript
|
|
628
|
-
* const session = await getBillingApiSession({ baseUrl: "https://billing.eigencloud.xyz" });
|
|
629
|
-
* if (session.authenticated) {
|
|
630
|
-
* console.log(`Logged in as ${session.address}`);
|
|
631
|
-
* }
|
|
632
|
-
* ```
|
|
633
|
-
*/
|
|
634
|
-
declare function getBillingApiSession(config: BillingApiConfig): Promise<BillingSessionInfo>;
|
|
635
|
-
/**
|
|
636
|
-
* Logout from the billing API
|
|
637
|
-
*
|
|
638
|
-
* This destroys the current session and clears the session cookie.
|
|
639
|
-
*
|
|
640
|
-
* @param config - Billing API configuration
|
|
641
|
-
*
|
|
642
|
-
* @example
|
|
643
|
-
* ```typescript
|
|
644
|
-
* await logoutFromBillingApi({ baseUrl: "https://billing.eigencloud.xyz" });
|
|
645
|
-
* ```
|
|
646
|
-
*/
|
|
647
|
-
declare function logoutFromBillingApi(config: BillingApiConfig): Promise<void>;
|
|
648
|
-
/**
|
|
649
|
-
* Check if a billing session is still valid (not expired)
|
|
650
|
-
*
|
|
651
|
-
* This is a convenience function that checks the session status
|
|
652
|
-
* and returns a boolean.
|
|
653
|
-
*
|
|
654
|
-
* @param config - Billing API configuration
|
|
655
|
-
* @returns True if session is authenticated, false otherwise
|
|
656
|
-
*/
|
|
657
|
-
declare function isBillingSessionValid(config: BillingApiConfig): Promise<boolean>;
|
|
658
|
-
/**
|
|
659
|
-
* Login to both compute and billing APIs simultaneously
|
|
660
|
-
*
|
|
661
|
-
* This is a convenience function that sends the same SIWE message and signature
|
|
662
|
-
* to both APIs in parallel, establishing sessions with both services at once.
|
|
663
|
-
*
|
|
664
|
-
* @param computeConfig - Compute API configuration
|
|
665
|
-
* @param billingConfig - Billing API configuration
|
|
666
|
-
* @param request - Login request containing SIWE message and signature
|
|
667
|
-
* @returns Object containing login results for both APIs
|
|
668
|
-
*
|
|
669
|
-
* @example
|
|
670
|
-
* ```typescript
|
|
671
|
-
* import { createSiweMessage, loginToBothApis } from "@layr-labs/ecloud-sdk/browser";
|
|
672
|
-
*
|
|
673
|
-
* const { message } = createSiweMessage({
|
|
674
|
-
* address: userAddress,
|
|
675
|
-
* chainId: 11155111,
|
|
676
|
-
* domain: window.location.host,
|
|
677
|
-
* uri: window.location.origin,
|
|
678
|
-
* });
|
|
679
|
-
*
|
|
680
|
-
* const signature = await signMessageAsync({ message });
|
|
681
|
-
* const { compute, billing } = await loginToBothApis(
|
|
682
|
-
* { baseUrl: computeApiUrl },
|
|
683
|
-
* { baseUrl: billingApiUrl },
|
|
684
|
-
* { message, signature }
|
|
685
|
-
* );
|
|
686
|
-
* ```
|
|
687
|
-
*/
|
|
688
|
-
declare function loginToBothApis(computeConfig: {
|
|
689
|
-
baseUrl: string;
|
|
690
|
-
}, billingConfig: BillingApiConfig, request: BillingLoginRequest): Promise<{
|
|
691
|
-
compute: BillingLoginResult;
|
|
692
|
-
billing: BillingLoginResult;
|
|
693
|
-
}>;
|
|
694
|
-
/**
|
|
695
|
-
* Logout from both compute and billing APIs simultaneously
|
|
696
|
-
*
|
|
697
|
-
* @param computeConfig - Compute API configuration
|
|
698
|
-
* @param billingConfig - Billing API configuration
|
|
699
|
-
*
|
|
700
|
-
* @example
|
|
701
|
-
* ```typescript
|
|
702
|
-
* await logoutFromBothApis(
|
|
703
|
-
* { baseUrl: computeApiUrl },
|
|
704
|
-
* { baseUrl: billingApiUrl }
|
|
705
|
-
* );
|
|
706
|
-
* ```
|
|
707
|
-
*/
|
|
708
|
-
declare function logoutFromBothApis(computeConfig: {
|
|
709
|
-
baseUrl: string;
|
|
710
|
-
}, billingConfig: BillingApiConfig): Promise<void>;
|
|
711
|
-
|
|
712
541
|
/**
|
|
713
542
|
* BillingAPI Client to manage product subscriptions
|
|
714
543
|
* Standalone client - does not depend on chain infrastructure
|
|
715
544
|
*
|
|
716
545
|
* Accepts viem's WalletClient which abstracts over both local accounts
|
|
717
546
|
* (privateKeyToAccount) and external signers (MetaMask, etc.).
|
|
718
|
-
*
|
|
719
|
-
* Supports two authentication modes:
|
|
720
|
-
* 1. EIP-712 signature auth (default) - signs each request with typed data
|
|
721
|
-
* 2. Session auth (optional) - uses SIWE session cookies
|
|
722
547
|
*/
|
|
723
548
|
|
|
724
|
-
interface BillingApiClientOptions {
|
|
725
|
-
/**
|
|
726
|
-
* Use session-based authentication instead of per-request signatures.
|
|
727
|
-
* When true, the client will rely on session cookies set by SIWE login.
|
|
728
|
-
* When false (default), uses EIP-712 typed data signatures for each request.
|
|
729
|
-
*/
|
|
730
|
-
useSession?: boolean;
|
|
731
|
-
}
|
|
732
549
|
/**
|
|
733
550
|
* BillingAPI Client for managing product subscriptions.
|
|
734
551
|
*/
|
|
735
552
|
declare class BillingApiClient {
|
|
736
553
|
private readonly config;
|
|
737
554
|
private readonly walletClient;
|
|
738
|
-
|
|
739
|
-
private readonly useSession;
|
|
740
|
-
constructor(config: BillingEnvironmentConfig, walletClient: WalletClient | null, options?: BillingApiClientOptions);
|
|
555
|
+
constructor(config: BillingEnvironmentConfig, walletClient: WalletClient);
|
|
741
556
|
/**
|
|
742
557
|
* Get the address of the connected wallet
|
|
743
|
-
* Returns undefined if using session auth without a wallet client
|
|
744
558
|
*/
|
|
745
|
-
get address(): Address
|
|
746
|
-
/**
|
|
747
|
-
* Get the base URL of the billing API
|
|
748
|
-
*/
|
|
749
|
-
get baseUrl(): string;
|
|
750
|
-
/**
|
|
751
|
-
* Login to the billing API using SIWE
|
|
752
|
-
*
|
|
753
|
-
* This establishes a session with the billing API by verifying the SIWE message
|
|
754
|
-
* and signature. On success, a session cookie is set in the browser.
|
|
755
|
-
*
|
|
756
|
-
* @param request - Login request containing SIWE message and signature
|
|
757
|
-
* @returns Login result with the authenticated address
|
|
758
|
-
*
|
|
759
|
-
* @example
|
|
760
|
-
* ```typescript
|
|
761
|
-
* const { message } = createSiweMessage({
|
|
762
|
-
* address: userAddress,
|
|
763
|
-
* chainId: 11155111,
|
|
764
|
-
* domain: window.location.host,
|
|
765
|
-
* uri: window.location.origin,
|
|
766
|
-
* });
|
|
767
|
-
*
|
|
768
|
-
* const signature = await signMessageAsync({ message });
|
|
769
|
-
* const result = await billingClient.siweLogin({ message, signature });
|
|
770
|
-
* ```
|
|
771
|
-
*/
|
|
772
|
-
siweLogin(request: BillingLoginRequest): Promise<BillingLoginResult>;
|
|
773
|
-
/**
|
|
774
|
-
* Logout from the billing API
|
|
775
|
-
*
|
|
776
|
-
* This destroys the current session and clears the session cookie.
|
|
777
|
-
*/
|
|
778
|
-
siweLogout(): Promise<void>;
|
|
779
|
-
/**
|
|
780
|
-
* Get the current session status from the billing API
|
|
781
|
-
*
|
|
782
|
-
* @returns Session information including authentication status and address
|
|
783
|
-
*/
|
|
784
|
-
getSession(): Promise<BillingSessionInfo>;
|
|
785
|
-
/**
|
|
786
|
-
* Check if there is a valid session
|
|
787
|
-
*
|
|
788
|
-
* @returns True if session is authenticated, false otherwise
|
|
789
|
-
*/
|
|
790
|
-
isSessionValid(): Promise<boolean>;
|
|
559
|
+
get address(): Address;
|
|
791
560
|
createSubscription(productId?: ProductID, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
|
|
792
561
|
getSubscription(productId?: ProductID): Promise<ProductSubscriptionResponse>;
|
|
793
562
|
cancelSubscription(productId?: ProductID): Promise<void>;
|
|
794
563
|
/**
|
|
795
564
|
* Make an authenticated request to the billing API
|
|
796
|
-
*
|
|
797
|
-
* Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
|
|
798
565
|
*/
|
|
799
566
|
private makeAuthenticatedRequest;
|
|
800
|
-
/**
|
|
801
|
-
* Make a request using session-based authentication (cookies)
|
|
802
|
-
*/
|
|
803
|
-
private makeSessionAuthenticatedRequest;
|
|
804
|
-
/**
|
|
805
|
-
* Make a request using EIP-712 signature authentication
|
|
806
|
-
*/
|
|
807
|
-
private makeSignatureAuthenticatedRequest;
|
|
808
567
|
}
|
|
809
568
|
|
|
810
569
|
/**
|
|
@@ -825,7 +584,6 @@ interface EstimateBatchGasOptions {
|
|
|
825
584
|
publicClient: PublicClient;
|
|
826
585
|
account: Address;
|
|
827
586
|
executions: Execution[];
|
|
828
|
-
authorizationList?: SignAuthorizationReturnType[];
|
|
829
587
|
}
|
|
830
588
|
/**
|
|
831
589
|
* Estimate gas cost for a batch transaction
|
|
@@ -841,8 +599,6 @@ interface ExecuteBatchOptions {
|
|
|
841
599
|
pendingMessage: string;
|
|
842
600
|
/** Optional gas params from estimation */
|
|
843
601
|
gas?: GasEstimate;
|
|
844
|
-
/** Optional pre-created authorization list (skips internal creation if provided) */
|
|
845
|
-
authorizationList?: SignAuthorizationReturnType[];
|
|
846
602
|
}
|
|
847
603
|
/**
|
|
848
604
|
* Check if account is delegated to ERC-7702 delegator
|
|
@@ -983,4 +739,4 @@ declare function addHexPrefix(value: string): Hex;
|
|
|
983
739
|
*/
|
|
984
740
|
declare function stripHexPrefix(value: string): string;
|
|
985
741
|
|
|
986
|
-
export {
|
|
742
|
+
export { logoutFromComputeApi as $, type LogsParams as A, isSubscriptionActive as B, type ComputeApiConfig as C, generateNewPrivateKey as D, type UserApiClientOptions as E, type AppInfo as F, type GeneratedKey as G, type AppProfileInfo as H, type AppMetrics as I, type AppInfoResponse as J, BillingApiClient as K, type LogVisibility as L, estimateBatchGas as M, executeBatch as N, checkERC7702Delegation as O, type EstimateBatchGasOptions as P, type ExecuteBatchOptions as Q, type Execution as R, type SessionInfo as S, createSiweMessage as T, UserApiClient as U, parseSiweMessage as V, generateNonce as W, isSiweMessageExpired as X, isSiweMessageNotYetValid as Y, type SiweMessageResult as Z, loginToComputeApi as _, SessionError as a, getComputeApiSession as a0, isSessionValid as a1, type LoginResult as a2, type LoginRequest as a3, getChainFromID as a4, addHexPrefix as a5, stripHexPrefix as a6, type ResourceUsageMonitoring as a7, createClients as a8, type AppRelease as a9, type AppReleaseBuild as aa, type AppResponse as ab, validateFilePath as ac, assertValidFilePath as ad, validateImagePath as ae, validateResourceUsageMonitoring as af, type DeployParams as ag, validateDeployParams as ah, type UpgradeParams as ai, validateUpgradeParams as aj, type SiweMessageParams as b, getBillingEnvironmentConfig as c, getAvailableEnvironments as d, getBuildType as e, isMainnet as f, getEnvironmentConfig as g, validateImageReference as h, isEnvironmentAvailable as i, assertValidImageReference as j, extractAppNameFromImage as k, validateInstanceTypeSKU as l, validatePrivateKeyFormat as m, assertValidPrivateKey as n, validateURL as o, validateXURL as p, validateDescription as q, validateAppID as r, validateLogVisibility as s, sanitizeString as t, sanitizeURL as u, validateAppName as v, sanitizeXURL as w, validateCreateAppParams as x, validateLogsParams as y, type CreateAppParams as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-
|
|
2
|
-
import { Address, Hex, WalletClient, PublicClient,
|
|
1
|
+
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-DeQzn_yM.js';
|
|
2
|
+
import { Address, Hex, WalletClient, PublicClient, Chain } from 'viem';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment configuration for different networks
|
|
@@ -538,273 +538,32 @@ declare class UserApiClient {
|
|
|
538
538
|
getSiweSession(): Promise<SessionInfo>;
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
/**
|
|
542
|
-
* Billing API Session Management
|
|
543
|
-
*
|
|
544
|
-
* This module provides utilities for managing authentication sessions with the billing API
|
|
545
|
-
* using SIWE (Sign-In with Ethereum).
|
|
546
|
-
*
|
|
547
|
-
* The billing API now supports the same SIWE-based session authentication as the compute API,
|
|
548
|
-
* allowing users to sign once and authenticate to both APIs simultaneously.
|
|
549
|
-
*/
|
|
550
|
-
|
|
551
|
-
interface BillingApiConfig {
|
|
552
|
-
/** Base URL of the billing API (e.g., "https://billing.eigencloud.xyz") */
|
|
553
|
-
baseUrl: string;
|
|
554
|
-
}
|
|
555
|
-
interface BillingSessionInfo {
|
|
556
|
-
/** Whether the session is authenticated */
|
|
557
|
-
authenticated: boolean;
|
|
558
|
-
/** Authenticated wallet address (if authenticated) */
|
|
559
|
-
address?: Address;
|
|
560
|
-
/** Chain ID used for authentication (if authenticated) */
|
|
561
|
-
chainId?: number;
|
|
562
|
-
/** Unix timestamp when authentication occurred (if authenticated) */
|
|
563
|
-
authenticatedAt?: number;
|
|
564
|
-
}
|
|
565
|
-
interface BillingLoginResult {
|
|
566
|
-
/** Whether login was successful */
|
|
567
|
-
success: boolean;
|
|
568
|
-
/** Authenticated wallet address */
|
|
569
|
-
address: Address;
|
|
570
|
-
}
|
|
571
|
-
interface BillingLoginRequest {
|
|
572
|
-
/** SIWE message string */
|
|
573
|
-
message: string;
|
|
574
|
-
/** Hex-encoded signature (with or without 0x prefix) */
|
|
575
|
-
signature: Hex | string;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Error thrown when billing session operations fail
|
|
579
|
-
*/
|
|
580
|
-
declare class BillingSessionError extends Error {
|
|
581
|
-
readonly code: "NETWORK_ERROR" | "INVALID_SIGNATURE" | "INVALID_MESSAGE" | "SESSION_EXPIRED" | "UNAUTHORIZED" | "UNKNOWN";
|
|
582
|
-
readonly statusCode?: number | undefined;
|
|
583
|
-
constructor(message: string, code: "NETWORK_ERROR" | "INVALID_SIGNATURE" | "INVALID_MESSAGE" | "SESSION_EXPIRED" | "UNAUTHORIZED" | "UNKNOWN", statusCode?: number | undefined);
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Login to the billing API using SIWE
|
|
587
|
-
*
|
|
588
|
-
* This establishes a session with the billing API by verifying the SIWE message
|
|
589
|
-
* and signature. On success, a session cookie is set in the browser.
|
|
590
|
-
*
|
|
591
|
-
* The billing API accepts the same SIWE message format as the compute API,
|
|
592
|
-
* so users only need to sign once and can send the same message/signature
|
|
593
|
-
* to both APIs.
|
|
594
|
-
*
|
|
595
|
-
* @param config - Billing API configuration
|
|
596
|
-
* @param request - Login request containing SIWE message and signature
|
|
597
|
-
* @returns Login result with the authenticated address
|
|
598
|
-
*
|
|
599
|
-
* @example
|
|
600
|
-
* ```typescript
|
|
601
|
-
* import { createSiweMessage, loginToBillingApi } from "@layr-labs/ecloud-sdk/browser";
|
|
602
|
-
*
|
|
603
|
-
* const { message } = createSiweMessage({
|
|
604
|
-
* address: userAddress,
|
|
605
|
-
* chainId: 11155111,
|
|
606
|
-
* domain: window.location.host,
|
|
607
|
-
* uri: window.location.origin,
|
|
608
|
-
* });
|
|
609
|
-
*
|
|
610
|
-
* const signature = await signMessageAsync({ message });
|
|
611
|
-
*
|
|
612
|
-
* // Can send to both APIs with the same message/signature
|
|
613
|
-
* const [computeResult, billingResult] = await Promise.all([
|
|
614
|
-
* loginToComputeApi({ baseUrl: computeApiUrl }, { message, signature }),
|
|
615
|
-
* loginToBillingApi({ baseUrl: billingApiUrl }, { message, signature }),
|
|
616
|
-
* ]);
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
declare function loginToBillingApi(config: BillingApiConfig, request: BillingLoginRequest): Promise<BillingLoginResult>;
|
|
620
|
-
/**
|
|
621
|
-
* Get the current session status from the billing API
|
|
622
|
-
*
|
|
623
|
-
* @param config - Billing API configuration
|
|
624
|
-
* @returns Session information including authentication status and address
|
|
625
|
-
*
|
|
626
|
-
* @example
|
|
627
|
-
* ```typescript
|
|
628
|
-
* const session = await getBillingApiSession({ baseUrl: "https://billing.eigencloud.xyz" });
|
|
629
|
-
* if (session.authenticated) {
|
|
630
|
-
* console.log(`Logged in as ${session.address}`);
|
|
631
|
-
* }
|
|
632
|
-
* ```
|
|
633
|
-
*/
|
|
634
|
-
declare function getBillingApiSession(config: BillingApiConfig): Promise<BillingSessionInfo>;
|
|
635
|
-
/**
|
|
636
|
-
* Logout from the billing API
|
|
637
|
-
*
|
|
638
|
-
* This destroys the current session and clears the session cookie.
|
|
639
|
-
*
|
|
640
|
-
* @param config - Billing API configuration
|
|
641
|
-
*
|
|
642
|
-
* @example
|
|
643
|
-
* ```typescript
|
|
644
|
-
* await logoutFromBillingApi({ baseUrl: "https://billing.eigencloud.xyz" });
|
|
645
|
-
* ```
|
|
646
|
-
*/
|
|
647
|
-
declare function logoutFromBillingApi(config: BillingApiConfig): Promise<void>;
|
|
648
|
-
/**
|
|
649
|
-
* Check if a billing session is still valid (not expired)
|
|
650
|
-
*
|
|
651
|
-
* This is a convenience function that checks the session status
|
|
652
|
-
* and returns a boolean.
|
|
653
|
-
*
|
|
654
|
-
* @param config - Billing API configuration
|
|
655
|
-
* @returns True if session is authenticated, false otherwise
|
|
656
|
-
*/
|
|
657
|
-
declare function isBillingSessionValid(config: BillingApiConfig): Promise<boolean>;
|
|
658
|
-
/**
|
|
659
|
-
* Login to both compute and billing APIs simultaneously
|
|
660
|
-
*
|
|
661
|
-
* This is a convenience function that sends the same SIWE message and signature
|
|
662
|
-
* to both APIs in parallel, establishing sessions with both services at once.
|
|
663
|
-
*
|
|
664
|
-
* @param computeConfig - Compute API configuration
|
|
665
|
-
* @param billingConfig - Billing API configuration
|
|
666
|
-
* @param request - Login request containing SIWE message and signature
|
|
667
|
-
* @returns Object containing login results for both APIs
|
|
668
|
-
*
|
|
669
|
-
* @example
|
|
670
|
-
* ```typescript
|
|
671
|
-
* import { createSiweMessage, loginToBothApis } from "@layr-labs/ecloud-sdk/browser";
|
|
672
|
-
*
|
|
673
|
-
* const { message } = createSiweMessage({
|
|
674
|
-
* address: userAddress,
|
|
675
|
-
* chainId: 11155111,
|
|
676
|
-
* domain: window.location.host,
|
|
677
|
-
* uri: window.location.origin,
|
|
678
|
-
* });
|
|
679
|
-
*
|
|
680
|
-
* const signature = await signMessageAsync({ message });
|
|
681
|
-
* const { compute, billing } = await loginToBothApis(
|
|
682
|
-
* { baseUrl: computeApiUrl },
|
|
683
|
-
* { baseUrl: billingApiUrl },
|
|
684
|
-
* { message, signature }
|
|
685
|
-
* );
|
|
686
|
-
* ```
|
|
687
|
-
*/
|
|
688
|
-
declare function loginToBothApis(computeConfig: {
|
|
689
|
-
baseUrl: string;
|
|
690
|
-
}, billingConfig: BillingApiConfig, request: BillingLoginRequest): Promise<{
|
|
691
|
-
compute: BillingLoginResult;
|
|
692
|
-
billing: BillingLoginResult;
|
|
693
|
-
}>;
|
|
694
|
-
/**
|
|
695
|
-
* Logout from both compute and billing APIs simultaneously
|
|
696
|
-
*
|
|
697
|
-
* @param computeConfig - Compute API configuration
|
|
698
|
-
* @param billingConfig - Billing API configuration
|
|
699
|
-
*
|
|
700
|
-
* @example
|
|
701
|
-
* ```typescript
|
|
702
|
-
* await logoutFromBothApis(
|
|
703
|
-
* { baseUrl: computeApiUrl },
|
|
704
|
-
* { baseUrl: billingApiUrl }
|
|
705
|
-
* );
|
|
706
|
-
* ```
|
|
707
|
-
*/
|
|
708
|
-
declare function logoutFromBothApis(computeConfig: {
|
|
709
|
-
baseUrl: string;
|
|
710
|
-
}, billingConfig: BillingApiConfig): Promise<void>;
|
|
711
|
-
|
|
712
541
|
/**
|
|
713
542
|
* BillingAPI Client to manage product subscriptions
|
|
714
543
|
* Standalone client - does not depend on chain infrastructure
|
|
715
544
|
*
|
|
716
545
|
* Accepts viem's WalletClient which abstracts over both local accounts
|
|
717
546
|
* (privateKeyToAccount) and external signers (MetaMask, etc.).
|
|
718
|
-
*
|
|
719
|
-
* Supports two authentication modes:
|
|
720
|
-
* 1. EIP-712 signature auth (default) - signs each request with typed data
|
|
721
|
-
* 2. Session auth (optional) - uses SIWE session cookies
|
|
722
547
|
*/
|
|
723
548
|
|
|
724
|
-
interface BillingApiClientOptions {
|
|
725
|
-
/**
|
|
726
|
-
* Use session-based authentication instead of per-request signatures.
|
|
727
|
-
* When true, the client will rely on session cookies set by SIWE login.
|
|
728
|
-
* When false (default), uses EIP-712 typed data signatures for each request.
|
|
729
|
-
*/
|
|
730
|
-
useSession?: boolean;
|
|
731
|
-
}
|
|
732
549
|
/**
|
|
733
550
|
* BillingAPI Client for managing product subscriptions.
|
|
734
551
|
*/
|
|
735
552
|
declare class BillingApiClient {
|
|
736
553
|
private readonly config;
|
|
737
554
|
private readonly walletClient;
|
|
738
|
-
|
|
739
|
-
private readonly useSession;
|
|
740
|
-
constructor(config: BillingEnvironmentConfig, walletClient: WalletClient | null, options?: BillingApiClientOptions);
|
|
555
|
+
constructor(config: BillingEnvironmentConfig, walletClient: WalletClient);
|
|
741
556
|
/**
|
|
742
557
|
* Get the address of the connected wallet
|
|
743
|
-
* Returns undefined if using session auth without a wallet client
|
|
744
558
|
*/
|
|
745
|
-
get address(): Address
|
|
746
|
-
/**
|
|
747
|
-
* Get the base URL of the billing API
|
|
748
|
-
*/
|
|
749
|
-
get baseUrl(): string;
|
|
750
|
-
/**
|
|
751
|
-
* Login to the billing API using SIWE
|
|
752
|
-
*
|
|
753
|
-
* This establishes a session with the billing API by verifying the SIWE message
|
|
754
|
-
* and signature. On success, a session cookie is set in the browser.
|
|
755
|
-
*
|
|
756
|
-
* @param request - Login request containing SIWE message and signature
|
|
757
|
-
* @returns Login result with the authenticated address
|
|
758
|
-
*
|
|
759
|
-
* @example
|
|
760
|
-
* ```typescript
|
|
761
|
-
* const { message } = createSiweMessage({
|
|
762
|
-
* address: userAddress,
|
|
763
|
-
* chainId: 11155111,
|
|
764
|
-
* domain: window.location.host,
|
|
765
|
-
* uri: window.location.origin,
|
|
766
|
-
* });
|
|
767
|
-
*
|
|
768
|
-
* const signature = await signMessageAsync({ message });
|
|
769
|
-
* const result = await billingClient.siweLogin({ message, signature });
|
|
770
|
-
* ```
|
|
771
|
-
*/
|
|
772
|
-
siweLogin(request: BillingLoginRequest): Promise<BillingLoginResult>;
|
|
773
|
-
/**
|
|
774
|
-
* Logout from the billing API
|
|
775
|
-
*
|
|
776
|
-
* This destroys the current session and clears the session cookie.
|
|
777
|
-
*/
|
|
778
|
-
siweLogout(): Promise<void>;
|
|
779
|
-
/**
|
|
780
|
-
* Get the current session status from the billing API
|
|
781
|
-
*
|
|
782
|
-
* @returns Session information including authentication status and address
|
|
783
|
-
*/
|
|
784
|
-
getSession(): Promise<BillingSessionInfo>;
|
|
785
|
-
/**
|
|
786
|
-
* Check if there is a valid session
|
|
787
|
-
*
|
|
788
|
-
* @returns True if session is authenticated, false otherwise
|
|
789
|
-
*/
|
|
790
|
-
isSessionValid(): Promise<boolean>;
|
|
559
|
+
get address(): Address;
|
|
791
560
|
createSubscription(productId?: ProductID, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
|
|
792
561
|
getSubscription(productId?: ProductID): Promise<ProductSubscriptionResponse>;
|
|
793
562
|
cancelSubscription(productId?: ProductID): Promise<void>;
|
|
794
563
|
/**
|
|
795
564
|
* Make an authenticated request to the billing API
|
|
796
|
-
*
|
|
797
|
-
* Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
|
|
798
565
|
*/
|
|
799
566
|
private makeAuthenticatedRequest;
|
|
800
|
-
/**
|
|
801
|
-
* Make a request using session-based authentication (cookies)
|
|
802
|
-
*/
|
|
803
|
-
private makeSessionAuthenticatedRequest;
|
|
804
|
-
/**
|
|
805
|
-
* Make a request using EIP-712 signature authentication
|
|
806
|
-
*/
|
|
807
|
-
private makeSignatureAuthenticatedRequest;
|
|
808
567
|
}
|
|
809
568
|
|
|
810
569
|
/**
|
|
@@ -825,7 +584,6 @@ interface EstimateBatchGasOptions {
|
|
|
825
584
|
publicClient: PublicClient;
|
|
826
585
|
account: Address;
|
|
827
586
|
executions: Execution[];
|
|
828
|
-
authorizationList?: SignAuthorizationReturnType[];
|
|
829
587
|
}
|
|
830
588
|
/**
|
|
831
589
|
* Estimate gas cost for a batch transaction
|
|
@@ -841,8 +599,6 @@ interface ExecuteBatchOptions {
|
|
|
841
599
|
pendingMessage: string;
|
|
842
600
|
/** Optional gas params from estimation */
|
|
843
601
|
gas?: GasEstimate;
|
|
844
|
-
/** Optional pre-created authorization list (skips internal creation if provided) */
|
|
845
|
-
authorizationList?: SignAuthorizationReturnType[];
|
|
846
602
|
}
|
|
847
603
|
/**
|
|
848
604
|
* Check if account is delegated to ERC-7702 delegator
|
|
@@ -983,4 +739,4 @@ declare function addHexPrefix(value: string): Hex;
|
|
|
983
739
|
*/
|
|
984
740
|
declare function stripHexPrefix(value: string): string;
|
|
985
741
|
|
|
986
|
-
export {
|
|
742
|
+
export { logoutFromComputeApi as $, type LogsParams as A, isSubscriptionActive as B, type ComputeApiConfig as C, generateNewPrivateKey as D, type UserApiClientOptions as E, type AppInfo as F, type GeneratedKey as G, type AppProfileInfo as H, type AppMetrics as I, type AppInfoResponse as J, BillingApiClient as K, type LogVisibility as L, estimateBatchGas as M, executeBatch as N, checkERC7702Delegation as O, type EstimateBatchGasOptions as P, type ExecuteBatchOptions as Q, type Execution as R, type SessionInfo as S, createSiweMessage as T, UserApiClient as U, parseSiweMessage as V, generateNonce as W, isSiweMessageExpired as X, isSiweMessageNotYetValid as Y, type SiweMessageResult as Z, loginToComputeApi as _, SessionError as a, getComputeApiSession as a0, isSessionValid as a1, type LoginResult as a2, type LoginRequest as a3, getChainFromID as a4, addHexPrefix as a5, stripHexPrefix as a6, type ResourceUsageMonitoring as a7, createClients as a8, type AppRelease as a9, type AppReleaseBuild as aa, type AppResponse as ab, validateFilePath as ac, assertValidFilePath as ad, validateImagePath as ae, validateResourceUsageMonitoring as af, type DeployParams as ag, validateDeployParams as ah, type UpgradeParams as ai, validateUpgradeParams as aj, type SiweMessageParams as b, getBillingEnvironmentConfig as c, getAvailableEnvironments as d, getBuildType as e, isMainnet as f, getEnvironmentConfig as g, validateImageReference as h, isEnvironmentAvailable as i, assertValidImageReference as j, extractAppNameFromImage as k, validateInstanceTypeSKU as l, validatePrivateKeyFormat as m, assertValidPrivateKey as n, validateURL as o, validateXURL as p, validateDescription as q, validateAppID as r, validateLogVisibility as s, sanitizeString as t, sanitizeURL as u, validateAppName as v, sanitizeXURL as w, validateCreateAppParams as x, validateLogsParams as y, type CreateAppParams as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicClient, Address, Hex, WalletClient
|
|
1
|
+
import { PublicClient, Address, Hex, WalletClient } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Contract interactions
|
|
@@ -503,8 +503,6 @@ interface PreparedDeployData {
|
|
|
503
503
|
value: bigint;
|
|
504
504
|
callData: Hex;
|
|
505
505
|
}>;
|
|
506
|
-
/** Pre-created authorization list for gas estimation accuracy (optional) */
|
|
507
|
-
authorizationList?: SignAuthorizationReturnType[];
|
|
508
506
|
}
|
|
509
507
|
/** Data-only batch for upgrade (clients provided by module) */
|
|
510
508
|
interface PreparedUpgradeData {
|
|
@@ -516,8 +514,6 @@ interface PreparedUpgradeData {
|
|
|
516
514
|
value: bigint;
|
|
517
515
|
callData: Hex;
|
|
518
516
|
}>;
|
|
519
|
-
/** Pre-created authorization list for gas estimation accuracy (optional) */
|
|
520
|
-
authorizationList?: SignAuthorizationReturnType[];
|
|
521
517
|
}
|
|
522
518
|
/** Prepared deployment ready for execution */
|
|
523
519
|
interface PreparedDeploy {
|
|
@@ -712,10 +708,6 @@ interface ProductSubscriptionResponse {
|
|
|
712
708
|
}
|
|
713
709
|
interface SubscriptionOpts {
|
|
714
710
|
productId?: ProductID;
|
|
715
|
-
/** URL to redirect to after successful checkout */
|
|
716
|
-
successUrl?: string;
|
|
717
|
-
/** URL to redirect to if checkout is canceled */
|
|
718
|
-
cancelUrl?: string;
|
|
719
711
|
}
|
|
720
712
|
interface BillingEnvironmentConfig {
|
|
721
713
|
billingApiServerURL: string;
|