@layr-labs/ecloud-sdk 0.2.0 → 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.
- package/VERSION +2 -2
- package/dist/billing.cjs +48 -43
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +6 -3
- package/dist/billing.d.ts +6 -3
- package/dist/billing.js +519 -4
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +5034 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +239 -0
- package/dist/browser.d.ts +239 -0
- package/dist/browser.js +4924 -0
- package/dist/browser.js.map +1 -0
- package/dist/{compute-CF2HOXed.d.ts → compute-BYhSs8en.d.ts} +15 -96
- package/dist/{compute-CbmjA8kJ.d.cts → compute-Bpjb3hYD.d.cts} +15 -96
- package/dist/compute.cjs +875 -846
- 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 +7009 -8
- package/dist/compute.js.map +1 -1
- package/dist/helpers-CEvhJz7f.d.cts +742 -0
- package/dist/helpers-CQuBwQnu.d.ts +742 -0
- package/dist/index-DeQzn_yM.d.cts +739 -0
- package/dist/index-DeQzn_yM.d.ts +739 -0
- package/dist/index.cjs +1958 -1758
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -414
- package/dist/index.d.ts +69 -414
- package/dist/index.js +7977 -134
- package/dist/index.js.map +1 -1
- package/package.json +17 -2
- package/dist/chunk-CA5Y4OVI.js +0 -744
- package/dist/chunk-CA5Y4OVI.js.map +0 -1
- package/dist/chunk-ZDXN2WKP.js +0 -434
- package/dist/chunk-ZDXN2WKP.js.map +0 -1
- package/dist/chunk-ZTLKZMSW.js +0 -6719
- package/dist/chunk-ZTLKZMSW.js.map +0 -1
- package/dist/index-D2QufVB9.d.cts +0 -342
- package/dist/index-D2QufVB9.d.ts +0 -342
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Browser-safe app action encoders
|
|
53
|
+
*
|
|
54
|
+
* These functions encode calldata for app lifecycle operations.
|
|
55
|
+
* They only depend on viem and are safe to use in browser environments.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Encode start app call data for gas estimation or transaction
|
|
60
|
+
*/
|
|
61
|
+
declare function encodeStartAppData(appId: AppId): `0x${string}`;
|
|
62
|
+
/**
|
|
63
|
+
* Encode stop app call data for gas estimation or transaction
|
|
64
|
+
*/
|
|
65
|
+
declare function encodeStopAppData(appId: AppId): `0x${string}`;
|
|
66
|
+
/**
|
|
67
|
+
* Encode terminate app call data for gas estimation or transaction
|
|
68
|
+
*/
|
|
69
|
+
declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
|
|
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
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Browser-safe SDK entry point
|
|
225
|
+
*
|
|
226
|
+
* This module exports only code that can run in browser environments.
|
|
227
|
+
* It excludes Node.js-only dependencies like:
|
|
228
|
+
* - dockerode (Docker API)
|
|
229
|
+
* - @napi-rs/keyring (OS keychain)
|
|
230
|
+
* - fs operations (file system)
|
|
231
|
+
* - @inquirer/prompts (CLI prompts)
|
|
232
|
+
*
|
|
233
|
+
* Use this entry point in React/Next.js/browser applications:
|
|
234
|
+
* import { ... } from "@layr-labs/ecloud-sdk/browser"
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
type Environment = "sepolia" | "sepolia-dev" | "mainnet-alpha";
|
|
238
|
+
|
|
239
|
+
export { AppId, BuildApiClient, ComputeApiConfig, type Environment, SessionError, SessionInfo, SiweMessageParams, type UseComputeSessionConfig, type UseComputeSessionReturn, encodeStartAppData, encodeStopAppData, encodeTerminateAppData, encryptRSAOAEPAndAES256GCM, getAppProtectedHeaders, getKMSKeysForEnvironment, useComputeSession };
|
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Browser-safe app action encoders
|
|
53
|
+
*
|
|
54
|
+
* These functions encode calldata for app lifecycle operations.
|
|
55
|
+
* They only depend on viem and are safe to use in browser environments.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Encode start app call data for gas estimation or transaction
|
|
60
|
+
*/
|
|
61
|
+
declare function encodeStartAppData(appId: AppId): `0x${string}`;
|
|
62
|
+
/**
|
|
63
|
+
* Encode stop app call data for gas estimation or transaction
|
|
64
|
+
*/
|
|
65
|
+
declare function encodeStopAppData(appId: AppId): `0x${string}`;
|
|
66
|
+
/**
|
|
67
|
+
* Encode terminate app call data for gas estimation or transaction
|
|
68
|
+
*/
|
|
69
|
+
declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
|
|
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
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Browser-safe SDK entry point
|
|
225
|
+
*
|
|
226
|
+
* This module exports only code that can run in browser environments.
|
|
227
|
+
* It excludes Node.js-only dependencies like:
|
|
228
|
+
* - dockerode (Docker API)
|
|
229
|
+
* - @napi-rs/keyring (OS keychain)
|
|
230
|
+
* - fs operations (file system)
|
|
231
|
+
* - @inquirer/prompts (CLI prompts)
|
|
232
|
+
*
|
|
233
|
+
* Use this entry point in React/Next.js/browser applications:
|
|
234
|
+
* import { ... } from "@layr-labs/ecloud-sdk/browser"
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
type Environment = "sepolia" | "sepolia-dev" | "mainnet-alpha";
|
|
238
|
+
|
|
239
|
+
export { AppId, BuildApiClient, ComputeApiConfig, type Environment, SessionError, SessionInfo, SiweMessageParams, type UseComputeSessionConfig, type UseComputeSessionReturn, encodeStartAppData, encodeStopAppData, encodeTerminateAppData, encryptRSAOAEPAndAES256GCM, getAppProtectedHeaders, getKMSKeysForEnvironment, useComputeSession };
|