@layr-labs/ecloud-sdk 0.2.1-dev → 0.2.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.
@@ -1,7 +1,52 @@
1
- import { A as AppId } from './index-D5oW73Dx.cjs';
2
- export { O as AlreadyActiveResponse, h as AppConfig, C as AppProfile, F as AppProfileResponse, t as AppRecord, B as BillingEnvironmentConfig, X as CancelResponse, V as CancelSuccessResponse, J as ChainID, N as CheckoutCreatedResponse, M as CreateSubscriptionResponse, D as DeployAppOpts, u as DeployOptions, v as DeployResult, y as DockerImageConfig, w as EnvironmentConfig, E as EstimateGasOptions, n as ExecuteDeployResult, o as ExecuteUpgradeResult, G as GasEstimate, m as GasOpts, I as ImageDigestResult, L as LifecycleOpts, z as Logger, W as NoActiveSubscriptionResponse, x as ParsedEnvironment, Q as PaymentIssueResponse, j as PrepareDeployFromVerifiableBuildOpts, P as PrepareDeployOpts, k as PrepareUpgradeFromVerifiableBuildOpts, i as PrepareUpgradeOpts, r as PreparedDeploy, p as PreparedDeployData, s as PreparedUpgrade, q as PreparedUpgradeData, H as ProductID, Y as ProductSubscriptionResponse, R as Release, T as SubscribeResponse, K as SubscriptionLineItem, Z as SubscriptionOpts, S as SubscriptionStatus, U as UpgradeAppOpts, e as estimateTransactionGas, f as formatETH, c as getActiveAppCount, g as getAllAppsByDeveloper, a as getAppsByCreator, b as getAppsByDeveloper, d as getMaxActiveAppsPerUser, l as logVisibility } from './index-D5oW73Dx.cjs';
3
- export { A as AppInfo, D as AppInfoResponse, B as AppMetrics, z as AppProfileInfo, C as CreateAppParams, F as EstimateBatchGasOptions, G as GeneratedKey, L as LogVisibility, w as LogsParams, U as UserApiClient, e as assertValidImageReference, k as assertValidPrivateKey, E as estimateBatchGas, f as extractAppNameFromImage, y as generateNewPrivateKey, a as getAvailableEnvironments, b as getBuildType, g as getEnvironmentConfig, i as isEnvironmentAvailable, c as isMainnet, x as isSubscriptionActive, s as sanitizeString, q as sanitizeURL, r as sanitizeXURL, o as validateAppID, v as validateAppName, t as validateCreateAppParams, n as validateDescription, d as validateImageReference, h as validateInstanceTypeSKU, p as validateLogVisibility, u as validateLogsParams, j as validatePrivateKeyFormat, l as validateURL, m as validateXURL } from './eip7702-DeqoCP5b.cjs';
4
- import 'viem';
1
+ import { A as AppId } from './index-DeQzn_yM.cjs';
2
+ export { al as AlreadyActiveResponse, w as AppConfig, ac as AppProfile, ad as AppProfileResponse, a2 as AppRecord, K as BatchedDeployResult, a5 as BillingEnvironmentConfig, C as CalculateAppIDOptions, aq as CancelResponse, ao as CancelSuccessResponse, af as ChainID, ak as CheckoutCreatedResponse, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, D as DeployAppOptions, N as DeployAppOpts, a3 as DeployOptions, at as DeployProgressCallback, a4 as DeployResult, au as DeployStep, aa as DockerImageConfig, a6 as EnvironmentConfig, E as EstimateGasOptions, J as ExecuteDeployBatchedOptions, X as ExecuteDeployResult, H as ExecuteDeploySequentialOptions, Y as ExecuteUpgradeResult, G as GasEstimate, W as GasOpts, a9 as ImageDigestResult, I as IsDelegatedOptions, a1 as LifecycleOpts, ab as Logger, ap as NoActiveSubscriptionResponse, a8 as ParsedEnvironment, am as PaymentIssueResponse, P as PrepareDeployBatchOptions, T as PrepareDeployFromVerifiableBuildOpts, Q as PrepareDeployOpts, x as PrepareUpgradeBatchOptions, V as PrepareUpgradeFromVerifiableBuildOpts, R as PrepareUpgradeOpts, $ as PreparedDeploy, y as PreparedDeployBatch, Z as PreparedDeployData, a0 as PreparedUpgrade, z as PreparedUpgradeBatch, _ as PreparedUpgradeData, ae as ProductID, ar as ProductSubscriptionResponse, a7 as Release, S as SendTransactionOptions, av as SequentialDeployResult, an as SubscribeResponse, ah as SubscriptionLineItem, as as SubscriptionOpts, ag as SubscriptionStatus, B as SuspendOptions, F as UndelegateOptions, U as UpgradeAppOptions, O as UpgradeAppOpts, j as calculateAppID, i as deployApp, e as estimateTransactionGas, h as executeDeployBatch, l as executeDeployBatched, k as executeDeploySequential, o as executeUpgradeBatch, f as formatETH, c as getActiveAppCount, g as getAllAppsByDeveloper, a as getAppsByCreator, b as getAppsByDeveloper, d as getMaxActiveAppsPerUser, r as isDelegated, M as logVisibility, L as noopLogger, p as prepareDeployBatch, n as prepareUpgradeBatch, q as sendAndWaitForTransaction, m as supportsEIP5792, s as supportsEIP7702, t as suspend, v as undelegate, u as upgradeApp } from './index-DeQzn_yM.cjs';
3
+ import { C as ComputeApiConfig, S as SessionInfo, a as SessionError, b as SiweMessageParams } from './helpers-CEvhJz7f.cjs';
4
+ export { F as AppInfo, J as AppInfoResponse, I as AppMetrics, H as AppProfileInfo, K as BillingApiClient, z as CreateAppParams, P as EstimateBatchGasOptions, Q as ExecuteBatchOptions, R as Execution, G as GeneratedKey, L as LogVisibility, a3 as LoginRequest, a2 as LoginResult, A as LogsParams, Z as SiweMessageResult, U as UserApiClient, E as UserApiClientOptions, a5 as addHexPrefix, j as assertValidImageReference, n as assertValidPrivateKey, O as checkERC7702Delegation, T as createSiweMessage, M as estimateBatchGas, N as executeBatch, k as extractAppNameFromImage, D as generateNewPrivateKey, W as generateNonce, d as getAvailableEnvironments, c as getBillingEnvironmentConfig, e as getBuildType, a4 as getChainFromID, a0 as getComputeApiSession, g as getEnvironmentConfig, i as isEnvironmentAvailable, f as isMainnet, a1 as isSessionValid, X as isSiweMessageExpired, Y as isSiweMessageNotYetValid, B as isSubscriptionActive, _ as loginToComputeApi, $ as logoutFromComputeApi, V as parseSiweMessage, t as sanitizeString, u as sanitizeURL, w as sanitizeXURL, a6 as stripHexPrefix, r as validateAppID, v as validateAppName, x as validateCreateAppParams, q as validateDescription, h as validateImageReference, l as validateInstanceTypeSKU, s as validateLogVisibility, y as validateLogsParams, m as validatePrivateKeyFormat, o as validateURL, p as validateXURL } from './helpers-CEvhJz7f.cjs';
5
+ import { WalletClient, Address, Hex } from 'viem';
6
+ import { Buffer as Buffer$1 } from 'buffer';
7
+
8
+ /**
9
+ * Build API Client to manage verifiable builds and provenance
10
+ *
11
+ * This is a standalone HTTP client that talks to the (compute) UserAPI host.
12
+ */
13
+
14
+ declare class BuildApiClient {
15
+ private readonly baseUrl;
16
+ private readonly walletClient?;
17
+ private readonly clientId?;
18
+ constructor(options: {
19
+ baseUrl: string;
20
+ walletClient?: WalletClient;
21
+ clientId?: string;
22
+ });
23
+ /**
24
+ * Get the address of the connected wallet
25
+ */
26
+ get address(): Address;
27
+ submitBuild(payload: {
28
+ repo_url: string;
29
+ git_ref: string;
30
+ dockerfile_path: string;
31
+ caddyfile_path?: string;
32
+ build_context_path: string;
33
+ dependencies: string[];
34
+ }): Promise<{
35
+ build_id: string;
36
+ }>;
37
+ getBuild(buildId: string): Promise<any>;
38
+ getBuildByDigest(digest: string): Promise<any>;
39
+ verify(identifier: string): Promise<any>;
40
+ getLogs(buildId: string): Promise<string>;
41
+ listBuilds(params: {
42
+ billing_address: string;
43
+ limit?: number;
44
+ offset?: number;
45
+ }): Promise<any[]>;
46
+ private publicJsonRequest;
47
+ private authenticatedJsonRequest;
48
+ private authenticatedTextRequest;
49
+ }
5
50
 
6
51
  /**
7
52
  * Browser-safe app action encoders
@@ -23,6 +68,158 @@ declare function encodeStopAppData(appId: AppId): `0x${string}`;
23
68
  */
24
69
  declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
25
70
 
71
+ /**
72
+ * React Hook for Compute API Session Management
73
+ *
74
+ * This hook provides a convenient way to manage compute API sessions in React applications.
75
+ * It handles session state, auto-refresh, and provides login/logout methods.
76
+ *
77
+ * IMPORTANT: This hook requires React 18+ as a peer dependency.
78
+ * Make sure your application has React installed.
79
+ */
80
+
81
+ interface UseComputeSessionConfig extends ComputeApiConfig {
82
+ /**
83
+ * Interval in milliseconds to check session validity
84
+ * Set to 0 to disable auto-refresh
85
+ * @default 60000 (1 minute)
86
+ */
87
+ refreshInterval?: number;
88
+ /**
89
+ * Whether to automatically check session on mount
90
+ * @default true
91
+ */
92
+ checkOnMount?: boolean;
93
+ /**
94
+ * Callback when session expires or becomes invalid
95
+ */
96
+ onSessionExpired?: () => void;
97
+ /**
98
+ * Callback when session is successfully refreshed/validated
99
+ */
100
+ onSessionRefreshed?: (session: SessionInfo) => void;
101
+ /**
102
+ * Callback when an error occurs
103
+ */
104
+ onError?: (error: SessionError) => void;
105
+ }
106
+ interface UseComputeSessionReturn {
107
+ /** Current session information */
108
+ session: SessionInfo | null;
109
+ /** Whether the session is currently being loaded/checked */
110
+ isLoading: boolean;
111
+ /** Any error that occurred during session operations */
112
+ error: SessionError | null;
113
+ /** Whether the user is authenticated */
114
+ isAuthenticated: boolean;
115
+ /**
116
+ * Login to compute API with SIWE
117
+ *
118
+ * @param params - SIWE message parameters (address, chainId required)
119
+ * @param signMessage - Function to sign the message (from wagmi's useSignMessage)
120
+ * @returns Login result
121
+ */
122
+ login: (params: Omit<SiweMessageParams, "domain" | "uri"> & {
123
+ domain?: string;
124
+ uri?: string;
125
+ }, signMessage: (args: {
126
+ message: string;
127
+ }) => Promise<Hex>) => Promise<SessionInfo>;
128
+ /**
129
+ * Logout from compute API
130
+ */
131
+ logout: () => Promise<void>;
132
+ /**
133
+ * Manually refresh/check session status
134
+ */
135
+ refresh: () => Promise<SessionInfo>;
136
+ /**
137
+ * Clear any error state
138
+ */
139
+ clearError: () => void;
140
+ }
141
+ /**
142
+ * React hook for managing compute API sessions with SIWE authentication
143
+ *
144
+ * @param config - Configuration options including baseUrl and refresh settings
145
+ * @returns Session state and methods for login/logout/refresh
146
+ *
147
+ * @example
148
+ * ```tsx
149
+ * import { useComputeSession } from "@layr-labs/ecloud-sdk/browser";
150
+ * import { useSignMessage, useAccount } from "wagmi";
151
+ *
152
+ * function MyComponent() {
153
+ * const { address, chainId } = useAccount();
154
+ * const { signMessageAsync } = useSignMessage();
155
+ *
156
+ * const {
157
+ * session,
158
+ * isLoading,
159
+ * isAuthenticated,
160
+ * login,
161
+ * logout,
162
+ * error,
163
+ * } = useComputeSession({
164
+ * baseUrl: "https://api.eigencloud.xyz",
165
+ * onSessionExpired: () => console.log("Session expired!"),
166
+ * });
167
+ *
168
+ * const handleLogin = async () => {
169
+ * if (!address || !chainId) return;
170
+ * await login(
171
+ * { address, chainId },
172
+ * signMessageAsync
173
+ * );
174
+ * };
175
+ *
176
+ * if (isLoading) return <div>Loading...</div>;
177
+ *
178
+ * return (
179
+ * <div>
180
+ * {isAuthenticated ? (
181
+ * <>
182
+ * <p>Logged in as {session?.address}</p>
183
+ * <button onClick={logout}>Logout</button>
184
+ * </>
185
+ * ) : (
186
+ * <button onClick={handleLogin}>Login</button>
187
+ * )}
188
+ * {error && <p>Error: {error.message}</p>}
189
+ * </div>
190
+ * );
191
+ * }
192
+ * ```
193
+ */
194
+ declare function useComputeSession(config: UseComputeSessionConfig): UseComputeSessionReturn;
195
+
196
+ /**
197
+ * KMS encryption utilities
198
+ * Implements RSA-OAEP-256 + AES-256-GCM encryption using JWE format
199
+ */
200
+
201
+ /**
202
+ * Get app protected headers for encryption
203
+ */
204
+ declare function getAppProtectedHeaders(appID: string): Record<string, string>;
205
+ /**
206
+ * Encrypt data using RSA-OAEP-256 for key encryption and AES-256-GCM for data encryption
207
+ * Uses jose library which properly implements JWE with RSA-OAEP-256
208
+ */
209
+ declare function encryptRSAOAEPAndAES256GCM(encryptionKeyPEM: string | Buffer$1, plaintext: Buffer$1, protectedHeaders?: Record<string, string> | null): Promise<string>;
210
+
211
+ /**
212
+ * KMS key loading utilities
213
+ */
214
+ type BuildType = "dev" | "prod";
215
+ /**
216
+ * Get KMS keys for environment
217
+ */
218
+ declare function getKMSKeysForEnvironment(environment: string, build?: BuildType): {
219
+ encryptionKey: Buffer;
220
+ signingKey: Buffer;
221
+ };
222
+
26
223
  /**
27
224
  * Browser-safe SDK entry point
28
225
  *
@@ -39,4 +236,4 @@ declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
39
236
 
40
237
  type Environment = "sepolia" | "sepolia-dev" | "mainnet-alpha";
41
238
 
42
- export { AppId, type Environment, encodeStartAppData, encodeStopAppData, encodeTerminateAppData };
239
+ export { AppId, BuildApiClient, ComputeApiConfig, type Environment, SessionError, SessionInfo, SiweMessageParams, type UseComputeSessionConfig, type UseComputeSessionReturn, encodeStartAppData, encodeStopAppData, encodeTerminateAppData, encryptRSAOAEPAndAES256GCM, getAppProtectedHeaders, getKMSKeysForEnvironment, useComputeSession };
package/dist/browser.d.ts CHANGED
@@ -1,7 +1,52 @@
1
- import { A as AppId } from './index-D5oW73Dx.js';
2
- export { O as AlreadyActiveResponse, h as AppConfig, C as AppProfile, F as AppProfileResponse, t as AppRecord, B as BillingEnvironmentConfig, X as CancelResponse, V as CancelSuccessResponse, J as ChainID, N as CheckoutCreatedResponse, M as CreateSubscriptionResponse, D as DeployAppOpts, u as DeployOptions, v as DeployResult, y as DockerImageConfig, w as EnvironmentConfig, E as EstimateGasOptions, n as ExecuteDeployResult, o as ExecuteUpgradeResult, G as GasEstimate, m as GasOpts, I as ImageDigestResult, L as LifecycleOpts, z as Logger, W as NoActiveSubscriptionResponse, x as ParsedEnvironment, Q as PaymentIssueResponse, j as PrepareDeployFromVerifiableBuildOpts, P as PrepareDeployOpts, k as PrepareUpgradeFromVerifiableBuildOpts, i as PrepareUpgradeOpts, r as PreparedDeploy, p as PreparedDeployData, s as PreparedUpgrade, q as PreparedUpgradeData, H as ProductID, Y as ProductSubscriptionResponse, R as Release, T as SubscribeResponse, K as SubscriptionLineItem, Z as SubscriptionOpts, S as SubscriptionStatus, U as UpgradeAppOpts, e as estimateTransactionGas, f as formatETH, c as getActiveAppCount, g as getAllAppsByDeveloper, a as getAppsByCreator, b as getAppsByDeveloper, d as getMaxActiveAppsPerUser, l as logVisibility } from './index-D5oW73Dx.js';
3
- export { A as AppInfo, D as AppInfoResponse, B as AppMetrics, z as AppProfileInfo, C as CreateAppParams, F as EstimateBatchGasOptions, G as GeneratedKey, L as LogVisibility, w as LogsParams, U as UserApiClient, e as assertValidImageReference, k as assertValidPrivateKey, E as estimateBatchGas, f as extractAppNameFromImage, y as generateNewPrivateKey, a as getAvailableEnvironments, b as getBuildType, g as getEnvironmentConfig, i as isEnvironmentAvailable, c as isMainnet, x as isSubscriptionActive, s as sanitizeString, q as sanitizeURL, r as sanitizeXURL, o as validateAppID, v as validateAppName, t as validateCreateAppParams, n as validateDescription, d as validateImageReference, h as validateInstanceTypeSKU, p as validateLogVisibility, u as validateLogsParams, j as validatePrivateKeyFormat, l as validateURL, m as validateXURL } from './eip7702-CXCYfOnk.js';
4
- import 'viem';
1
+ import { A as AppId } from './index-DeQzn_yM.js';
2
+ export { al as AlreadyActiveResponse, w as AppConfig, ac as AppProfile, ad as AppProfileResponse, a2 as AppRecord, K as BatchedDeployResult, a5 as BillingEnvironmentConfig, C as CalculateAppIDOptions, aq as CancelResponse, ao as CancelSuccessResponse, af as ChainID, ak as CheckoutCreatedResponse, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, D as DeployAppOptions, N as DeployAppOpts, a3 as DeployOptions, at as DeployProgressCallback, a4 as DeployResult, au as DeployStep, aa as DockerImageConfig, a6 as EnvironmentConfig, E as EstimateGasOptions, J as ExecuteDeployBatchedOptions, X as ExecuteDeployResult, H as ExecuteDeploySequentialOptions, Y as ExecuteUpgradeResult, G as GasEstimate, W as GasOpts, a9 as ImageDigestResult, I as IsDelegatedOptions, a1 as LifecycleOpts, ab as Logger, ap as NoActiveSubscriptionResponse, a8 as ParsedEnvironment, am as PaymentIssueResponse, P as PrepareDeployBatchOptions, T as PrepareDeployFromVerifiableBuildOpts, Q as PrepareDeployOpts, x as PrepareUpgradeBatchOptions, V as PrepareUpgradeFromVerifiableBuildOpts, R as PrepareUpgradeOpts, $ as PreparedDeploy, y as PreparedDeployBatch, Z as PreparedDeployData, a0 as PreparedUpgrade, z as PreparedUpgradeBatch, _ as PreparedUpgradeData, ae as ProductID, ar as ProductSubscriptionResponse, a7 as Release, S as SendTransactionOptions, av as SequentialDeployResult, an as SubscribeResponse, ah as SubscriptionLineItem, as as SubscriptionOpts, ag as SubscriptionStatus, B as SuspendOptions, F as UndelegateOptions, U as UpgradeAppOptions, O as UpgradeAppOpts, j as calculateAppID, i as deployApp, e as estimateTransactionGas, h as executeDeployBatch, l as executeDeployBatched, k as executeDeploySequential, o as executeUpgradeBatch, f as formatETH, c as getActiveAppCount, g as getAllAppsByDeveloper, a as getAppsByCreator, b as getAppsByDeveloper, d as getMaxActiveAppsPerUser, r as isDelegated, M as logVisibility, L as noopLogger, p as prepareDeployBatch, n as prepareUpgradeBatch, q as sendAndWaitForTransaction, m as supportsEIP5792, s as supportsEIP7702, t as suspend, v as undelegate, u as upgradeApp } from './index-DeQzn_yM.js';
3
+ import { C as ComputeApiConfig, S as SessionInfo, a as SessionError, b as SiweMessageParams } from './helpers-CQuBwQnu.js';
4
+ export { F as AppInfo, J as AppInfoResponse, I as AppMetrics, H as AppProfileInfo, K as BillingApiClient, z as CreateAppParams, P as EstimateBatchGasOptions, Q as ExecuteBatchOptions, R as Execution, G as GeneratedKey, L as LogVisibility, a3 as LoginRequest, a2 as LoginResult, A as LogsParams, Z as SiweMessageResult, U as UserApiClient, E as UserApiClientOptions, a5 as addHexPrefix, j as assertValidImageReference, n as assertValidPrivateKey, O as checkERC7702Delegation, T as createSiweMessage, M as estimateBatchGas, N as executeBatch, k as extractAppNameFromImage, D as generateNewPrivateKey, W as generateNonce, d as getAvailableEnvironments, c as getBillingEnvironmentConfig, e as getBuildType, a4 as getChainFromID, a0 as getComputeApiSession, g as getEnvironmentConfig, i as isEnvironmentAvailable, f as isMainnet, a1 as isSessionValid, X as isSiweMessageExpired, Y as isSiweMessageNotYetValid, B as isSubscriptionActive, _ as loginToComputeApi, $ as logoutFromComputeApi, V as parseSiweMessage, t as sanitizeString, u as sanitizeURL, w as sanitizeXURL, a6 as stripHexPrefix, r as validateAppID, v as validateAppName, x as validateCreateAppParams, q as validateDescription, h as validateImageReference, l as validateInstanceTypeSKU, s as validateLogVisibility, y as validateLogsParams, m as validatePrivateKeyFormat, o as validateURL, p as validateXURL } from './helpers-CQuBwQnu.js';
5
+ import { WalletClient, Address, Hex } from 'viem';
6
+ import { Buffer as Buffer$1 } from 'buffer';
7
+
8
+ /**
9
+ * Build API Client to manage verifiable builds and provenance
10
+ *
11
+ * This is a standalone HTTP client that talks to the (compute) UserAPI host.
12
+ */
13
+
14
+ declare class BuildApiClient {
15
+ private readonly baseUrl;
16
+ private readonly walletClient?;
17
+ private readonly clientId?;
18
+ constructor(options: {
19
+ baseUrl: string;
20
+ walletClient?: WalletClient;
21
+ clientId?: string;
22
+ });
23
+ /**
24
+ * Get the address of the connected wallet
25
+ */
26
+ get address(): Address;
27
+ submitBuild(payload: {
28
+ repo_url: string;
29
+ git_ref: string;
30
+ dockerfile_path: string;
31
+ caddyfile_path?: string;
32
+ build_context_path: string;
33
+ dependencies: string[];
34
+ }): Promise<{
35
+ build_id: string;
36
+ }>;
37
+ getBuild(buildId: string): Promise<any>;
38
+ getBuildByDigest(digest: string): Promise<any>;
39
+ verify(identifier: string): Promise<any>;
40
+ getLogs(buildId: string): Promise<string>;
41
+ listBuilds(params: {
42
+ billing_address: string;
43
+ limit?: number;
44
+ offset?: number;
45
+ }): Promise<any[]>;
46
+ private publicJsonRequest;
47
+ private authenticatedJsonRequest;
48
+ private authenticatedTextRequest;
49
+ }
5
50
 
6
51
  /**
7
52
  * Browser-safe app action encoders
@@ -23,6 +68,158 @@ declare function encodeStopAppData(appId: AppId): `0x${string}`;
23
68
  */
24
69
  declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
25
70
 
71
+ /**
72
+ * React Hook for Compute API Session Management
73
+ *
74
+ * This hook provides a convenient way to manage compute API sessions in React applications.
75
+ * It handles session state, auto-refresh, and provides login/logout methods.
76
+ *
77
+ * IMPORTANT: This hook requires React 18+ as a peer dependency.
78
+ * Make sure your application has React installed.
79
+ */
80
+
81
+ interface UseComputeSessionConfig extends ComputeApiConfig {
82
+ /**
83
+ * Interval in milliseconds to check session validity
84
+ * Set to 0 to disable auto-refresh
85
+ * @default 60000 (1 minute)
86
+ */
87
+ refreshInterval?: number;
88
+ /**
89
+ * Whether to automatically check session on mount
90
+ * @default true
91
+ */
92
+ checkOnMount?: boolean;
93
+ /**
94
+ * Callback when session expires or becomes invalid
95
+ */
96
+ onSessionExpired?: () => void;
97
+ /**
98
+ * Callback when session is successfully refreshed/validated
99
+ */
100
+ onSessionRefreshed?: (session: SessionInfo) => void;
101
+ /**
102
+ * Callback when an error occurs
103
+ */
104
+ onError?: (error: SessionError) => void;
105
+ }
106
+ interface UseComputeSessionReturn {
107
+ /** Current session information */
108
+ session: SessionInfo | null;
109
+ /** Whether the session is currently being loaded/checked */
110
+ isLoading: boolean;
111
+ /** Any error that occurred during session operations */
112
+ error: SessionError | null;
113
+ /** Whether the user is authenticated */
114
+ isAuthenticated: boolean;
115
+ /**
116
+ * Login to compute API with SIWE
117
+ *
118
+ * @param params - SIWE message parameters (address, chainId required)
119
+ * @param signMessage - Function to sign the message (from wagmi's useSignMessage)
120
+ * @returns Login result
121
+ */
122
+ login: (params: Omit<SiweMessageParams, "domain" | "uri"> & {
123
+ domain?: string;
124
+ uri?: string;
125
+ }, signMessage: (args: {
126
+ message: string;
127
+ }) => Promise<Hex>) => Promise<SessionInfo>;
128
+ /**
129
+ * Logout from compute API
130
+ */
131
+ logout: () => Promise<void>;
132
+ /**
133
+ * Manually refresh/check session status
134
+ */
135
+ refresh: () => Promise<SessionInfo>;
136
+ /**
137
+ * Clear any error state
138
+ */
139
+ clearError: () => void;
140
+ }
141
+ /**
142
+ * React hook for managing compute API sessions with SIWE authentication
143
+ *
144
+ * @param config - Configuration options including baseUrl and refresh settings
145
+ * @returns Session state and methods for login/logout/refresh
146
+ *
147
+ * @example
148
+ * ```tsx
149
+ * import { useComputeSession } from "@layr-labs/ecloud-sdk/browser";
150
+ * import { useSignMessage, useAccount } from "wagmi";
151
+ *
152
+ * function MyComponent() {
153
+ * const { address, chainId } = useAccount();
154
+ * const { signMessageAsync } = useSignMessage();
155
+ *
156
+ * const {
157
+ * session,
158
+ * isLoading,
159
+ * isAuthenticated,
160
+ * login,
161
+ * logout,
162
+ * error,
163
+ * } = useComputeSession({
164
+ * baseUrl: "https://api.eigencloud.xyz",
165
+ * onSessionExpired: () => console.log("Session expired!"),
166
+ * });
167
+ *
168
+ * const handleLogin = async () => {
169
+ * if (!address || !chainId) return;
170
+ * await login(
171
+ * { address, chainId },
172
+ * signMessageAsync
173
+ * );
174
+ * };
175
+ *
176
+ * if (isLoading) return <div>Loading...</div>;
177
+ *
178
+ * return (
179
+ * <div>
180
+ * {isAuthenticated ? (
181
+ * <>
182
+ * <p>Logged in as {session?.address}</p>
183
+ * <button onClick={logout}>Logout</button>
184
+ * </>
185
+ * ) : (
186
+ * <button onClick={handleLogin}>Login</button>
187
+ * )}
188
+ * {error && <p>Error: {error.message}</p>}
189
+ * </div>
190
+ * );
191
+ * }
192
+ * ```
193
+ */
194
+ declare function useComputeSession(config: UseComputeSessionConfig): UseComputeSessionReturn;
195
+
196
+ /**
197
+ * KMS encryption utilities
198
+ * Implements RSA-OAEP-256 + AES-256-GCM encryption using JWE format
199
+ */
200
+
201
+ /**
202
+ * Get app protected headers for encryption
203
+ */
204
+ declare function getAppProtectedHeaders(appID: string): Record<string, string>;
205
+ /**
206
+ * Encrypt data using RSA-OAEP-256 for key encryption and AES-256-GCM for data encryption
207
+ * Uses jose library which properly implements JWE with RSA-OAEP-256
208
+ */
209
+ declare function encryptRSAOAEPAndAES256GCM(encryptionKeyPEM: string | Buffer$1, plaintext: Buffer$1, protectedHeaders?: Record<string, string> | null): Promise<string>;
210
+
211
+ /**
212
+ * KMS key loading utilities
213
+ */
214
+ type BuildType = "dev" | "prod";
215
+ /**
216
+ * Get KMS keys for environment
217
+ */
218
+ declare function getKMSKeysForEnvironment(environment: string, build?: BuildType): {
219
+ encryptionKey: Buffer;
220
+ signingKey: Buffer;
221
+ };
222
+
26
223
  /**
27
224
  * Browser-safe SDK entry point
28
225
  *
@@ -39,4 +236,4 @@ declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
39
236
 
40
237
  type Environment = "sepolia" | "sepolia-dev" | "mainnet-alpha";
41
238
 
42
- export { AppId, type Environment, encodeStartAppData, encodeStopAppData, encodeTerminateAppData };
239
+ export { AppId, BuildApiClient, ComputeApiConfig, type Environment, SessionError, SessionInfo, SiweMessageParams, type UseComputeSessionConfig, type UseComputeSessionReturn, encodeStartAppData, encodeStopAppData, encodeTerminateAppData, encryptRSAOAEPAndAES256GCM, getAppProtectedHeaders, getKMSKeysForEnvironment, useComputeSession };