@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/dist/browser.js CHANGED
@@ -1,150 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __esm = (fn, res) => function __init() {
4
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
- };
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
-
11
- // src/client/common/auth/session.ts
12
- var session_exports = {};
13
- __export(session_exports, {
14
- SessionError: () => SessionError,
15
- getComputeApiSession: () => getComputeApiSession,
16
- isSessionValid: () => isSessionValid,
17
- loginToComputeApi: () => loginToComputeApi,
18
- logoutFromComputeApi: () => logoutFromComputeApi
19
- });
20
- function stripHexPrefix2(hex) {
21
- return hex.startsWith("0x") ? hex.slice(2) : hex;
22
- }
23
- async function parseErrorResponse(response) {
24
- try {
25
- const data = await response.json();
26
- return data.error || response.statusText;
27
- } catch {
28
- return response.statusText;
29
- }
30
- }
31
- async function loginToComputeApi(config, request) {
32
- let response;
33
- try {
34
- response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
35
- method: "POST",
36
- credentials: "include",
37
- // Include cookies for session management
38
- headers: {
39
- "Content-Type": "application/json"
40
- },
41
- body: JSON.stringify({
42
- message: request.message,
43
- signature: stripHexPrefix2(request.signature)
44
- })
45
- });
46
- } catch (error) {
47
- throw new SessionError(
48
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
49
- "NETWORK_ERROR"
50
- );
51
- }
52
- if (!response.ok) {
53
- const errorMessage = await parseErrorResponse(response);
54
- const status = response.status;
55
- if (status === 400) {
56
- if (errorMessage.toLowerCase().includes("siwe")) {
57
- throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
58
- }
59
- throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
60
- }
61
- if (status === 401) {
62
- throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
63
- }
64
- throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
65
- }
66
- const data = await response.json();
67
- return {
68
- success: data.success,
69
- address: data.address
70
- };
71
- }
72
- async function getComputeApiSession(config) {
73
- let response;
74
- try {
75
- response = await fetch(`${config.baseUrl}/auth/session`, {
76
- method: "GET",
77
- credentials: "include",
78
- // Include cookies for session management
79
- headers: {
80
- "Content-Type": "application/json"
81
- }
82
- });
83
- } catch {
84
- return {
85
- authenticated: false
86
- };
87
- }
88
- if (response.status === 401) {
89
- return {
90
- authenticated: false
91
- };
92
- }
93
- if (!response.ok) {
94
- const errorMessage = await parseErrorResponse(response);
95
- throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
96
- }
97
- const data = await response.json();
98
- return {
99
- authenticated: data.authenticated,
100
- address: data.address,
101
- chainId: data.chain_id
102
- };
103
- }
104
- async function logoutFromComputeApi(config) {
105
- let response;
106
- try {
107
- response = await fetch(`${config.baseUrl}/auth/logout`, {
108
- method: "POST",
109
- credentials: "include",
110
- // Include cookies for session management
111
- headers: {
112
- "Content-Type": "application/json"
113
- }
114
- });
115
- } catch (error) {
116
- throw new SessionError(
117
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
118
- "NETWORK_ERROR"
119
- );
120
- }
121
- if (response.status === 401) {
122
- return;
123
- }
124
- if (!response.ok) {
125
- const errorMessage = await parseErrorResponse(response);
126
- throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
127
- }
128
- }
129
- async function isSessionValid(config) {
130
- const session = await getComputeApiSession(config);
131
- return session.authenticated;
132
- }
133
- var SessionError;
134
- var init_session = __esm({
135
- "src/client/common/auth/session.ts"() {
136
- "use strict";
137
- SessionError = class extends Error {
138
- constructor(message, code, statusCode) {
139
- super(message);
140
- this.code = code;
141
- this.statusCode = statusCode;
142
- this.name = "SessionError";
143
- }
144
- };
145
- }
146
- });
147
-
148
1
  // src/client/common/types/index.ts
149
2
  var noopLogger = {
150
3
  debug: () => {
@@ -549,8 +402,130 @@ async function calculateBillingAuthSignature(options) {
549
402
  return { signature, expiry };
550
403
  }
551
404
 
405
+ // src/client/common/auth/session.ts
406
+ var SessionError = class extends Error {
407
+ constructor(message, code, statusCode) {
408
+ super(message);
409
+ this.code = code;
410
+ this.statusCode = statusCode;
411
+ this.name = "SessionError";
412
+ }
413
+ };
414
+ function stripHexPrefix2(hex) {
415
+ return hex.startsWith("0x") ? hex.slice(2) : hex;
416
+ }
417
+ async function parseErrorResponse(response) {
418
+ try {
419
+ const data = await response.json();
420
+ return data.error || response.statusText;
421
+ } catch {
422
+ return response.statusText;
423
+ }
424
+ }
425
+ async function loginToComputeApi(config, request) {
426
+ let response;
427
+ try {
428
+ response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
429
+ method: "POST",
430
+ credentials: "include",
431
+ // Include cookies for session management
432
+ headers: {
433
+ "Content-Type": "application/json"
434
+ },
435
+ body: JSON.stringify({
436
+ message: request.message,
437
+ signature: stripHexPrefix2(request.signature)
438
+ })
439
+ });
440
+ } catch (error) {
441
+ throw new SessionError(
442
+ `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
443
+ "NETWORK_ERROR"
444
+ );
445
+ }
446
+ if (!response.ok) {
447
+ const errorMessage = await parseErrorResponse(response);
448
+ const status = response.status;
449
+ if (status === 400) {
450
+ if (errorMessage.toLowerCase().includes("siwe")) {
451
+ throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
452
+ }
453
+ throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
454
+ }
455
+ if (status === 401) {
456
+ throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
457
+ }
458
+ throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
459
+ }
460
+ const data = await response.json();
461
+ return {
462
+ success: data.success,
463
+ address: data.address
464
+ };
465
+ }
466
+ async function getComputeApiSession(config) {
467
+ let response;
468
+ try {
469
+ response = await fetch(`${config.baseUrl}/auth/session`, {
470
+ method: "GET",
471
+ credentials: "include",
472
+ // Include cookies for session management
473
+ headers: {
474
+ "Content-Type": "application/json"
475
+ }
476
+ });
477
+ } catch {
478
+ return {
479
+ authenticated: false
480
+ };
481
+ }
482
+ if (response.status === 401) {
483
+ return {
484
+ authenticated: false
485
+ };
486
+ }
487
+ if (!response.ok) {
488
+ const errorMessage = await parseErrorResponse(response);
489
+ throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
490
+ }
491
+ const data = await response.json();
492
+ return {
493
+ authenticated: data.authenticated,
494
+ address: data.address,
495
+ chainId: data.chain_id
496
+ };
497
+ }
498
+ async function logoutFromComputeApi(config) {
499
+ let response;
500
+ try {
501
+ response = await fetch(`${config.baseUrl}/auth/logout`, {
502
+ method: "POST",
503
+ credentials: "include",
504
+ // Include cookies for session management
505
+ headers: {
506
+ "Content-Type": "application/json"
507
+ }
508
+ });
509
+ } catch (error) {
510
+ throw new SessionError(
511
+ `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
512
+ "NETWORK_ERROR"
513
+ );
514
+ }
515
+ if (response.status === 401) {
516
+ return;
517
+ }
518
+ if (!response.ok) {
519
+ const errorMessage = await parseErrorResponse(response);
520
+ throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
521
+ }
522
+ }
523
+ async function isSessionValid(config) {
524
+ const session = await getComputeApiSession(config);
525
+ return session.authenticated;
526
+ }
527
+
552
528
  // src/client/common/utils/userapi.ts
553
- init_session();
554
529
  function isJsonObject(value) {
555
530
  return typeof value === "object" && value !== null && !Array.isArray(value);
556
531
  }
@@ -567,7 +542,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
567
542
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
568
543
  var CanUpdateAppProfilePermission = "0x036fef61";
569
544
  function getDefaultClientId() {
570
- const version = true ? "0.3.0-dev.0" : "0.0.0";
545
+ const version = true ? "0.3.1-dev" : "0.0.0";
571
546
  return `ecloud-sdk/v${version}`;
572
547
  }
573
548
  var UserApiClient = class {
@@ -905,233 +880,21 @@ function transformAppRelease(raw) {
905
880
 
906
881
  // src/client/common/utils/billingapi.ts
907
882
  import axios2 from "axios";
908
-
909
- // src/client/common/auth/billingSession.ts
910
- var BillingSessionError = class extends Error {
911
- constructor(message, code, statusCode) {
912
- super(message);
913
- this.code = code;
914
- this.statusCode = statusCode;
915
- this.name = "BillingSessionError";
916
- }
917
- };
918
- function stripHexPrefix3(hex) {
919
- return hex.startsWith("0x") ? hex.slice(2) : hex;
920
- }
921
- async function parseErrorResponse2(response) {
922
- try {
923
- const data = await response.json();
924
- return data.error || response.statusText;
925
- } catch {
926
- return response.statusText;
927
- }
928
- }
929
- async function loginToBillingApi(config, request) {
930
- let response;
931
- try {
932
- response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
933
- method: "POST",
934
- credentials: "include",
935
- // Include cookies for session management
936
- headers: {
937
- "Content-Type": "application/json"
938
- },
939
- body: JSON.stringify({
940
- message: request.message,
941
- signature: stripHexPrefix3(request.signature)
942
- })
943
- });
944
- } catch (error) {
945
- throw new BillingSessionError(
946
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
947
- "NETWORK_ERROR"
948
- );
949
- }
950
- if (!response.ok) {
951
- const errorMessage = await parseErrorResponse2(response);
952
- const status = response.status;
953
- if (status === 400) {
954
- if (errorMessage.toLowerCase().includes("siwe")) {
955
- throw new BillingSessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
956
- }
957
- throw new BillingSessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
958
- }
959
- if (status === 401) {
960
- throw new BillingSessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
961
- }
962
- throw new BillingSessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
963
- }
964
- const data = await response.json();
965
- return {
966
- success: data.success,
967
- address: data.address
968
- };
969
- }
970
- async function getBillingApiSession(config) {
971
- let response;
972
- try {
973
- response = await fetch(`${config.baseUrl}/auth/session`, {
974
- method: "GET",
975
- credentials: "include",
976
- // Include cookies for session management
977
- headers: {
978
- "Content-Type": "application/json"
979
- }
980
- });
981
- } catch {
982
- return {
983
- authenticated: false
984
- };
985
- }
986
- if (response.status === 401) {
987
- return {
988
- authenticated: false
989
- };
990
- }
991
- if (!response.ok) {
992
- const errorMessage = await parseErrorResponse2(response);
993
- throw new BillingSessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
994
- }
995
- const data = await response.json();
996
- return {
997
- authenticated: data.authenticated,
998
- address: data.address,
999
- chainId: data.chainId,
1000
- authenticatedAt: data.authenticatedAt
1001
- };
1002
- }
1003
- async function logoutFromBillingApi(config) {
1004
- let response;
1005
- try {
1006
- response = await fetch(`${config.baseUrl}/auth/logout`, {
1007
- method: "POST",
1008
- credentials: "include",
1009
- // Include cookies for session management
1010
- headers: {
1011
- "Content-Type": "application/json"
1012
- }
1013
- });
1014
- } catch (error) {
1015
- throw new BillingSessionError(
1016
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
1017
- "NETWORK_ERROR"
1018
- );
1019
- }
1020
- if (response.status === 401) {
1021
- return;
1022
- }
1023
- if (!response.ok) {
1024
- const errorMessage = await parseErrorResponse2(response);
1025
- throw new BillingSessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
1026
- }
1027
- }
1028
- async function isBillingSessionValid(config) {
1029
- const session = await getBillingApiSession(config);
1030
- return session.authenticated;
1031
- }
1032
- async function loginToBothApis(computeConfig, billingConfig, request) {
1033
- const { loginToComputeApi: loginToComputeApi2 } = await Promise.resolve().then(() => (init_session(), session_exports));
1034
- const [compute, billing] = await Promise.all([
1035
- loginToComputeApi2(computeConfig, request),
1036
- loginToBillingApi(billingConfig, request)
1037
- ]);
1038
- return { compute, billing };
1039
- }
1040
- async function logoutFromBothApis(computeConfig, billingConfig) {
1041
- const { logoutFromComputeApi: logoutFromComputeApi2 } = await Promise.resolve().then(() => (init_session(), session_exports));
1042
- await Promise.all([
1043
- logoutFromComputeApi2(computeConfig),
1044
- logoutFromBillingApi(billingConfig)
1045
- ]);
1046
- }
1047
-
1048
- // src/client/common/utils/billingapi.ts
1049
883
  var BillingApiClient = class {
1050
- constructor(config, walletClient, options = {}) {
884
+ constructor(config, walletClient) {
1051
885
  this.config = config;
1052
886
  this.walletClient = walletClient;
1053
- this.options = options;
1054
- this.useSession = options.useSession ?? false;
1055
- if (!this.useSession && !walletClient) {
1056
- throw new Error("WalletClient is required when not using session authentication");
1057
- }
1058
887
  }
1059
888
  /**
1060
889
  * Get the address of the connected wallet
1061
- * Returns undefined if using session auth without a wallet client
1062
890
  */
1063
891
  get address() {
1064
- const account = this.walletClient?.account;
892
+ const account = this.walletClient.account;
1065
893
  if (!account) {
1066
- if (!this.useSession) {
1067
- throw new Error("WalletClient must have an account attached");
1068
- }
1069
- return void 0;
894
+ throw new Error("WalletClient must have an account attached");
1070
895
  }
1071
896
  return account.address;
1072
897
  }
1073
- /**
1074
- * Get the base URL of the billing API
1075
- */
1076
- get baseUrl() {
1077
- return this.config.billingApiServerURL;
1078
- }
1079
- // ==========================================================================
1080
- // SIWE Session Methods
1081
- // ==========================================================================
1082
- /**
1083
- * Login to the billing API using SIWE
1084
- *
1085
- * This establishes a session with the billing API by verifying the SIWE message
1086
- * and signature. On success, a session cookie is set in the browser.
1087
- *
1088
- * @param request - Login request containing SIWE message and signature
1089
- * @returns Login result with the authenticated address
1090
- *
1091
- * @example
1092
- * ```typescript
1093
- * const { message } = createSiweMessage({
1094
- * address: userAddress,
1095
- * chainId: 11155111,
1096
- * domain: window.location.host,
1097
- * uri: window.location.origin,
1098
- * });
1099
- *
1100
- * const signature = await signMessageAsync({ message });
1101
- * const result = await billingClient.siweLogin({ message, signature });
1102
- * ```
1103
- */
1104
- async siweLogin(request) {
1105
- return loginToBillingApi({ baseUrl: this.baseUrl }, request);
1106
- }
1107
- /**
1108
- * Logout from the billing API
1109
- *
1110
- * This destroys the current session and clears the session cookie.
1111
- */
1112
- async siweLogout() {
1113
- return logoutFromBillingApi({ baseUrl: this.baseUrl });
1114
- }
1115
- /**
1116
- * Get the current session status from the billing API
1117
- *
1118
- * @returns Session information including authentication status and address
1119
- */
1120
- async getSession() {
1121
- return getBillingApiSession({ baseUrl: this.baseUrl });
1122
- }
1123
- /**
1124
- * Check if there is a valid session
1125
- *
1126
- * @returns True if session is authenticated, false otherwise
1127
- */
1128
- async isSessionValid() {
1129
- const session = await this.getSession();
1130
- return session.authenticated;
1131
- }
1132
- // ==========================================================================
1133
- // Subscription Methods
1134
- // ==========================================================================
1135
898
  async createSubscription(productId = "compute", options) {
1136
899
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
1137
900
  const body = options ? {
@@ -1150,72 +913,10 @@ var BillingApiClient = class {
1150
913
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
1151
914
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
1152
915
  }
1153
- // ==========================================================================
1154
- // Internal Methods
1155
- // ==========================================================================
1156
916
  /**
1157
917
  * Make an authenticated request to the billing API
1158
- *
1159
- * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
1160
918
  */
1161
919
  async makeAuthenticatedRequest(url, method, productId, body) {
1162
- if (this.useSession) {
1163
- return this.makeSessionAuthenticatedRequest(url, method, body);
1164
- }
1165
- return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1166
- }
1167
- /**
1168
- * Make a request using session-based authentication (cookies)
1169
- */
1170
- async makeSessionAuthenticatedRequest(url, method, body) {
1171
- const headers = {};
1172
- if (body) {
1173
- headers["Content-Type"] = "application/json";
1174
- }
1175
- try {
1176
- const response = await fetch(url, {
1177
- method,
1178
- credentials: "include",
1179
- // Include cookies for session management
1180
- headers,
1181
- body: body ? JSON.stringify(body) : void 0
1182
- });
1183
- const status = response.status;
1184
- const statusText = status >= 200 && status < 300 ? "OK" : "Error";
1185
- if (status < 200 || status >= 300) {
1186
- let errorBody;
1187
- try {
1188
- errorBody = await response.text();
1189
- } catch {
1190
- errorBody = statusText;
1191
- }
1192
- throw new Error(`BillingAPI request failed: ${status} ${statusText} - ${errorBody}`);
1193
- }
1194
- const responseData = await response.json();
1195
- return {
1196
- json: async () => responseData,
1197
- text: async () => JSON.stringify(responseData)
1198
- };
1199
- } catch (error) {
1200
- if (error.name === "TypeError" || error.message?.includes("fetch")) {
1201
- throw new Error(
1202
- `Failed to connect to BillingAPI at ${url}: ${error.message}
1203
- Please check:
1204
- 1. Your internet connection
1205
- 2. The API server is accessible: ${this.config.billingApiServerURL}
1206
- 3. Firewall/proxy settings`
1207
- );
1208
- }
1209
- throw error;
1210
- }
1211
- }
1212
- /**
1213
- * Make a request using EIP-712 signature authentication
1214
- */
1215
- async makeSignatureAuthenticatedRequest(url, method, productId, body) {
1216
- if (!this.walletClient) {
1217
- throw new Error("WalletClient is required for signature authentication");
1218
- }
1219
920
  const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
1220
921
  const { signature } = await calculateBillingAuthSignature({
1221
922
  walletClient: this.walletClient,
@@ -1302,22 +1003,9 @@ async function requestWithRetry(config) {
1302
1003
  }
1303
1004
  var BuildApiClient = class {
1304
1005
  constructor(options) {
1305
- let url = options.baseUrl;
1306
- while (url.endsWith("/")) {
1307
- url = url.slice(0, -1);
1308
- }
1309
- this.baseUrl = url;
1006
+ this.baseUrl = options.baseUrl.replace(/\/+$/, "");
1310
1007
  this.clientId = options.clientId;
1311
1008
  this.walletClient = options.walletClient;
1312
- this.useSession = options.useSession ?? false;
1313
- this.billingSessionId = options.billingSessionId;
1314
- }
1315
- /**
1316
- * Update the billing session ID.
1317
- * Call this after logging into the billing API to enable session-based auth for builds.
1318
- */
1319
- setBillingSessionId(sessionId) {
1320
- this.billingSessionId = sessionId;
1321
1009
  }
1322
1010
  /**
1323
1011
  * Get the address of the connected wallet
@@ -1329,17 +1017,8 @@ var BuildApiClient = class {
1329
1017
  }
1330
1018
  return account.address;
1331
1019
  }
1332
- /**
1333
- * Submit a new build request.
1334
- * Supports two auth modes (session auth is tried first when billingSessionId is available):
1335
- * 1. Session-based auth: X-Billing-Session header (forwarded billing_session cookie)
1336
- * 2. Signature-based auth: Authorization + X-Account + X-eigenx-expiry headers (requires walletClient)
1337
- */
1338
1020
  async submitBuild(payload) {
1339
- if (this.useSession && this.billingSessionId) {
1340
- return this.billingSessionAuthJsonRequest("/builds", "POST", payload);
1341
- }
1342
- return this.signatureAuthJsonRequest("/builds", "POST", payload);
1021
+ return this.authenticatedJsonRequest("/builds", "POST", payload);
1343
1022
  }
1344
1023
  async getBuild(buildId) {
1345
1024
  return this.publicJsonRequest(`/builds/${encodeURIComponent(buildId)}`);
@@ -1350,11 +1029,8 @@ var BuildApiClient = class {
1350
1029
  async verify(identifier) {
1351
1030
  return this.publicJsonRequest(`/builds/verify/${encodeURIComponent(identifier)}`);
1352
1031
  }
1353
- /**
1354
- * Get build logs. Supports session auth (identity verification only, no billing check).
1355
- */
1356
1032
  async getLogs(buildId) {
1357
- return this.sessionOrSignatureTextRequest(`/builds/${encodeURIComponent(buildId)}/logs`);
1033
+ return this.authenticatedTextRequest(`/builds/${encodeURIComponent(buildId)}/logs`);
1358
1034
  }
1359
1035
  async listBuilds(params) {
1360
1036
  const res = await requestWithRetry({
@@ -1362,9 +1038,7 @@ var BuildApiClient = class {
1362
1038
  method: "GET",
1363
1039
  params,
1364
1040
  headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
1365
- timeout: 6e4,
1366
- validateStatus: () => true,
1367
- withCredentials: this.useSession
1041
+ timeout: 6e4
1368
1042
  });
1369
1043
  if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
1370
1044
  return res.data;
@@ -1374,18 +1048,12 @@ var BuildApiClient = class {
1374
1048
  url: `${this.baseUrl}${path}`,
1375
1049
  method: "GET",
1376
1050
  headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
1377
- timeout: 6e4,
1378
- validateStatus: () => true,
1379
- withCredentials: this.useSession
1051
+ timeout: 6e4
1380
1052
  });
1381
1053
  if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
1382
1054
  return res.data;
1383
1055
  }
1384
- /**
1385
- * Make a request that ALWAYS requires signature auth (for billing verification).
1386
- * Used for endpoints like POST /builds that need to verify subscription status.
1387
- */
1388
- async signatureAuthJsonRequest(path, method, body) {
1056
+ async authenticatedJsonRequest(path, method, body) {
1389
1057
  if (!this.walletClient?.account) {
1390
1058
  throw new Error("WalletClient with account required for authenticated requests");
1391
1059
  }
@@ -1407,69 +1075,32 @@ var BuildApiClient = class {
1407
1075
  method,
1408
1076
  headers,
1409
1077
  data: body,
1410
- timeout: 6e4,
1411
- validateStatus: () => true,
1412
- withCredentials: this.useSession
1078
+ timeout: 6e4
1413
1079
  });
1414
1080
  if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
1415
1081
  return res.data;
1416
1082
  }
1417
- /**
1418
- * Make a request using billing session auth (for billing verification without wallet signature).
1419
- * Forwards the billing_session cookie value via X-Billing-Session header.
1420
- * Used for endpoints that need to verify subscription status when using session-based auth.
1421
- */
1422
- async billingSessionAuthJsonRequest(path, method, body) {
1423
- if (!this.billingSessionId) {
1424
- throw new Error("billingSessionId required for session-based billing auth");
1083
+ async authenticatedTextRequest(path) {
1084
+ if (!this.walletClient?.account) {
1085
+ throw new Error("WalletClient with account required for authenticated requests");
1425
1086
  }
1426
- const headers = {
1427
- "Content-Type": "application/json",
1428
- "X-Billing-Session": this.billingSessionId
1429
- };
1430
- if (this.clientId) headers["x-client-id"] = this.clientId;
1431
- const res = await requestWithRetry({
1432
- url: `${this.baseUrl}${path}`,
1433
- method,
1434
- headers,
1435
- data: body,
1436
- timeout: 6e4,
1437
- validateStatus: () => true,
1438
- withCredentials: this.useSession
1439
- });
1440
- if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
1441
- return res.data;
1442
- }
1443
- /**
1444
- * Make an authenticated request that can use session OR signature auth.
1445
- * When useSession is true, relies on cookies for identity verification.
1446
- * Used for endpoints that only need identity verification (not billing).
1447
- */
1448
- async sessionOrSignatureTextRequest(path) {
1449
1087
  const headers = {};
1450
1088
  if (this.clientId) headers["x-client-id"] = this.clientId;
1451
- if (!this.useSession) {
1452
- if (!this.walletClient?.account) {
1453
- throw new Error("WalletClient with account required for authenticated requests");
1454
- }
1455
- const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
1456
- const { signature } = await calculateBillingAuthSignature({
1457
- walletClient: this.walletClient,
1458
- product: "compute",
1459
- expiry
1460
- });
1461
- headers.Authorization = `Bearer ${signature}`;
1462
- headers["X-eigenx-expiry"] = expiry.toString();
1463
- headers["X-Account"] = this.address;
1464
- }
1089
+ const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
1090
+ const { signature } = await calculateBillingAuthSignature({
1091
+ walletClient: this.walletClient,
1092
+ product: "compute",
1093
+ expiry
1094
+ });
1095
+ headers.Authorization = `Bearer ${signature}`;
1096
+ headers["X-eigenx-expiry"] = expiry.toString();
1097
+ headers["X-Account"] = this.address;
1465
1098
  const res = await requestWithRetry({
1466
1099
  url: `${this.baseUrl}${path}`,
1467
1100
  method: "GET",
1468
1101
  headers,
1469
1102
  timeout: 6e4,
1470
- responseType: "text",
1471
- validateStatus: () => true,
1472
- withCredentials: this.useSession
1103
+ responseType: "text"
1473
1104
  });
1474
1105
  if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
1475
1106
  return typeof res.data === "string" ? res.data : JSON.stringify(res.data);
@@ -2539,7 +2170,7 @@ function encodeExecuteBatchData(executions) {
2539
2170
  });
2540
2171
  }
2541
2172
  async function estimateBatchGas(options) {
2542
- const { publicClient, account, executions, authorizationList } = options;
2173
+ const { publicClient, account, executions } = options;
2543
2174
  const executeBatchData = encodeExecuteBatchData(executions);
2544
2175
  const [gasTipCap, block, estimatedGas] = await Promise.all([
2545
2176
  publicClient.estimateMaxPriorityFeePerGas(),
@@ -2547,8 +2178,7 @@ async function estimateBatchGas(options) {
2547
2178
  publicClient.estimateGas({
2548
2179
  account,
2549
2180
  to: account,
2550
- data: executeBatchData,
2551
- authorizationList
2181
+ data: executeBatchData
2552
2182
  })
2553
2183
  ]);
2554
2184
  const baseFee = block.baseFeePerGas ?? 0n;
@@ -2572,15 +2202,7 @@ async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
2572
2202
  return code.toLowerCase() === expectedCode.toLowerCase();
2573
2203
  }
2574
2204
  async function executeBatch(options, logger = noopLogger) {
2575
- const {
2576
- walletClient,
2577
- publicClient,
2578
- environmentConfig,
2579
- executions,
2580
- pendingMessage,
2581
- gas,
2582
- authorizationList: providedAuthList
2583
- } = options;
2205
+ const { walletClient, publicClient, environmentConfig, executions, pendingMessage, gas } = options;
2584
2206
  const account = walletClient.account;
2585
2207
  if (!account) {
2586
2208
  throw new Error("Wallet client must have an account");
@@ -2590,29 +2212,27 @@ async function executeBatch(options, logger = noopLogger) {
2590
2212
  throw new Error("Wallet client must have a chain");
2591
2213
  }
2592
2214
  const executeBatchData = encodeExecuteBatchData(executions);
2593
- let authorizationList = providedAuthList || [];
2594
- if (authorizationList.length === 0) {
2595
- const isDelegated2 = await checkERC7702Delegation(
2596
- publicClient,
2597
- account.address,
2598
- environmentConfig.erc7702DelegatorAddress
2599
- );
2600
- if (!isDelegated2) {
2601
- const transactionNonce = await publicClient.getTransactionCount({
2602
- address: account.address,
2603
- blockTag: "pending"
2604
- });
2605
- const chainId = await publicClient.getChainId();
2606
- const authorizationNonce = transactionNonce + 1;
2607
- logger.debug("Using wallet client signing for EIP-7702 authorization");
2608
- const signedAuthorization = await walletClient.signAuthorization({
2609
- account,
2610
- contractAddress: environmentConfig.erc7702DelegatorAddress,
2611
- chainId,
2612
- nonce: Number(authorizationNonce)
2613
- });
2614
- authorizationList = [signedAuthorization];
2615
- }
2215
+ const isDelegated2 = await checkERC7702Delegation(
2216
+ publicClient,
2217
+ account.address,
2218
+ environmentConfig.erc7702DelegatorAddress
2219
+ );
2220
+ let authorizationList = [];
2221
+ if (!isDelegated2) {
2222
+ const transactionNonce = await publicClient.getTransactionCount({
2223
+ address: account.address,
2224
+ blockTag: "pending"
2225
+ });
2226
+ const chainId = await publicClient.getChainId();
2227
+ const authorizationNonce = transactionNonce + 1;
2228
+ logger.debug("Using wallet client signing for EIP-7702 authorization");
2229
+ const signedAuthorization = await walletClient.signAuthorization({
2230
+ account: account.address,
2231
+ contractAddress: environmentConfig.erc7702DelegatorAddress,
2232
+ chainId,
2233
+ nonce: Number(authorizationNonce)
2234
+ });
2235
+ authorizationList = [signedAuthorization];
2616
2236
  }
2617
2237
  if (pendingMessage) {
2618
2238
  logger.info(pendingMessage);
@@ -2627,9 +2247,6 @@ async function executeBatch(options, logger = noopLogger) {
2627
2247
  if (authorizationList.length > 0) {
2628
2248
  txRequest.authorizationList = authorizationList;
2629
2249
  }
2630
- if (gas?.gasLimit) {
2631
- txRequest.gas = gas.gasLimit;
2632
- }
2633
2250
  if (gas?.maxFeePerGas) {
2634
2251
  txRequest.maxFeePerGas = gas.maxFeePerGas;
2635
2252
  }
@@ -4347,8 +3964,7 @@ async function executeDeployBatch(data, context, gas, logger = noopLogger) {
4347
3964
  environmentConfig: context.environmentConfig,
4348
3965
  executions: data.executions,
4349
3966
  pendingMessage,
4350
- gas,
4351
- authorizationList: data.authorizationList
3967
+ gas
4352
3968
  },
4353
3969
  logger
4354
3970
  );
@@ -4627,8 +4243,7 @@ async function executeUpgradeBatch(data, context, gas, logger = noopLogger) {
4627
4243
  environmentConfig: context.environmentConfig,
4628
4244
  executions: data.executions,
4629
4245
  pendingMessage,
4630
- gas,
4631
- authorizationList: data.authorizationList
4246
+ gas
4632
4247
  },
4633
4248
  logger
4634
4249
  );
@@ -4974,11 +4589,7 @@ function isSiweMessageNotYetValid(params) {
4974
4589
  return /* @__PURE__ */ new Date() < params.notBefore;
4975
4590
  }
4976
4591
 
4977
- // src/browser.ts
4978
- init_session();
4979
-
4980
4592
  // src/client/common/hooks/useComputeSession.ts
4981
- init_session();
4982
4593
  import { useCallback, useEffect, useRef, useState } from "react";
4983
4594
  function useComputeSession(config) {
4984
4595
  const {
@@ -5236,7 +4847,6 @@ function getKMSKeysForEnvironment(environment, build = "prod") {
5236
4847
  }
5237
4848
  export {
5238
4849
  BillingApiClient,
5239
- BillingSessionError,
5240
4850
  BuildApiClient,
5241
4851
  SessionError,
5242
4852
  UserApiClient,
@@ -5268,7 +4878,6 @@ export {
5268
4878
  getAppsByCreator,
5269
4879
  getAppsByDeveloper,
5270
4880
  getAvailableEnvironments,
5271
- getBillingApiSession,
5272
4881
  getBillingEnvironmentConfig,
5273
4882
  getBuildType,
5274
4883
  getChainFromID,
@@ -5276,7 +4885,6 @@ export {
5276
4885
  getEnvironmentConfig,
5277
4886
  getKMSKeysForEnvironment,
5278
4887
  getMaxActiveAppsPerUser,
5279
- isBillingSessionValid,
5280
4888
  isDelegated,
5281
4889
  isEnvironmentAvailable,
5282
4890
  isMainnet,
@@ -5284,11 +4892,7 @@ export {
5284
4892
  isSiweMessageExpired,
5285
4893
  isSiweMessageNotYetValid,
5286
4894
  isSubscriptionActive,
5287
- loginToBillingApi,
5288
- loginToBothApis,
5289
4895
  loginToComputeApi,
5290
- logoutFromBillingApi,
5291
- logoutFromBothApis,
5292
4896
  logoutFromComputeApi,
5293
4897
  noopLogger,
5294
4898
  parseSiweMessage,