@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
package/dist/browser.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,148 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// src/client/common/auth/session.ts
|
|
34
|
-
var session_exports = {};
|
|
35
|
-
__export(session_exports, {
|
|
36
|
-
SessionError: () => SessionError,
|
|
37
|
-
getComputeApiSession: () => getComputeApiSession,
|
|
38
|
-
isSessionValid: () => isSessionValid,
|
|
39
|
-
loginToComputeApi: () => loginToComputeApi,
|
|
40
|
-
logoutFromComputeApi: () => logoutFromComputeApi
|
|
41
|
-
});
|
|
42
|
-
function stripHexPrefix2(hex) {
|
|
43
|
-
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
44
|
-
}
|
|
45
|
-
async function parseErrorResponse(response) {
|
|
46
|
-
try {
|
|
47
|
-
const data = await response.json();
|
|
48
|
-
return data.error || response.statusText;
|
|
49
|
-
} catch {
|
|
50
|
-
return response.statusText;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async function loginToComputeApi(config, request) {
|
|
54
|
-
let response;
|
|
55
|
-
try {
|
|
56
|
-
response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
|
|
57
|
-
method: "POST",
|
|
58
|
-
credentials: "include",
|
|
59
|
-
// Include cookies for session management
|
|
60
|
-
headers: {
|
|
61
|
-
"Content-Type": "application/json"
|
|
62
|
-
},
|
|
63
|
-
body: JSON.stringify({
|
|
64
|
-
message: request.message,
|
|
65
|
-
signature: stripHexPrefix2(request.signature)
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw new SessionError(
|
|
70
|
-
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
71
|
-
"NETWORK_ERROR"
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
const errorMessage = await parseErrorResponse(response);
|
|
76
|
-
const status = response.status;
|
|
77
|
-
if (status === 400) {
|
|
78
|
-
if (errorMessage.toLowerCase().includes("siwe")) {
|
|
79
|
-
throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
80
|
-
}
|
|
81
|
-
throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
82
|
-
}
|
|
83
|
-
if (status === 401) {
|
|
84
|
-
throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
|
|
85
|
-
}
|
|
86
|
-
throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
|
|
87
|
-
}
|
|
88
|
-
const data = await response.json();
|
|
89
|
-
return {
|
|
90
|
-
success: data.success,
|
|
91
|
-
address: data.address
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
async function getComputeApiSession(config) {
|
|
95
|
-
let response;
|
|
96
|
-
try {
|
|
97
|
-
response = await fetch(`${config.baseUrl}/auth/session`, {
|
|
98
|
-
method: "GET",
|
|
99
|
-
credentials: "include",
|
|
100
|
-
// Include cookies for session management
|
|
101
|
-
headers: {
|
|
102
|
-
"Content-Type": "application/json"
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
} catch {
|
|
106
|
-
return {
|
|
107
|
-
authenticated: false
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
if (response.status === 401) {
|
|
111
|
-
return {
|
|
112
|
-
authenticated: false
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
const errorMessage = await parseErrorResponse(response);
|
|
117
|
-
throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
|
|
118
|
-
}
|
|
119
|
-
const data = await response.json();
|
|
120
|
-
return {
|
|
121
|
-
authenticated: data.authenticated,
|
|
122
|
-
address: data.address,
|
|
123
|
-
chainId: data.chain_id
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
async function logoutFromComputeApi(config) {
|
|
127
|
-
let response;
|
|
128
|
-
try {
|
|
129
|
-
response = await fetch(`${config.baseUrl}/auth/logout`, {
|
|
130
|
-
method: "POST",
|
|
131
|
-
credentials: "include",
|
|
132
|
-
// Include cookies for session management
|
|
133
|
-
headers: {
|
|
134
|
-
"Content-Type": "application/json"
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
} catch (error) {
|
|
138
|
-
throw new SessionError(
|
|
139
|
-
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
140
|
-
"NETWORK_ERROR"
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
if (response.status === 401) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (!response.ok) {
|
|
147
|
-
const errorMessage = await parseErrorResponse(response);
|
|
148
|
-
throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
async function isSessionValid(config) {
|
|
152
|
-
const session = await getComputeApiSession(config);
|
|
153
|
-
return session.authenticated;
|
|
154
|
-
}
|
|
155
|
-
var SessionError;
|
|
156
|
-
var init_session = __esm({
|
|
157
|
-
"src/client/common/auth/session.ts"() {
|
|
158
|
-
"use strict";
|
|
159
|
-
SessionError = class extends Error {
|
|
160
|
-
constructor(message, code, statusCode) {
|
|
161
|
-
super(message);
|
|
162
|
-
this.code = code;
|
|
163
|
-
this.statusCode = statusCode;
|
|
164
|
-
this.name = "SessionError";
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
30
|
// src/browser.ts
|
|
171
31
|
var browser_exports = {};
|
|
172
32
|
__export(browser_exports, {
|
|
173
33
|
BillingApiClient: () => BillingApiClient,
|
|
174
|
-
BillingSessionError: () => BillingSessionError,
|
|
175
34
|
BuildApiClient: () => BuildApiClient,
|
|
176
35
|
SessionError: () => SessionError,
|
|
177
36
|
UserApiClient: () => UserApiClient,
|
|
@@ -203,7 +62,6 @@ __export(browser_exports, {
|
|
|
203
62
|
getAppsByCreator: () => getAppsByCreator,
|
|
204
63
|
getAppsByDeveloper: () => getAppsByDeveloper,
|
|
205
64
|
getAvailableEnvironments: () => getAvailableEnvironments,
|
|
206
|
-
getBillingApiSession: () => getBillingApiSession,
|
|
207
65
|
getBillingEnvironmentConfig: () => getBillingEnvironmentConfig,
|
|
208
66
|
getBuildType: () => getBuildType,
|
|
209
67
|
getChainFromID: () => getChainFromID,
|
|
@@ -211,7 +69,6 @@ __export(browser_exports, {
|
|
|
211
69
|
getEnvironmentConfig: () => getEnvironmentConfig,
|
|
212
70
|
getKMSKeysForEnvironment: () => getKMSKeysForEnvironment,
|
|
213
71
|
getMaxActiveAppsPerUser: () => getMaxActiveAppsPerUser,
|
|
214
|
-
isBillingSessionValid: () => isBillingSessionValid,
|
|
215
72
|
isDelegated: () => isDelegated,
|
|
216
73
|
isEnvironmentAvailable: () => isEnvironmentAvailable,
|
|
217
74
|
isMainnet: () => isMainnet,
|
|
@@ -219,11 +76,7 @@ __export(browser_exports, {
|
|
|
219
76
|
isSiweMessageExpired: () => isSiweMessageExpired,
|
|
220
77
|
isSiweMessageNotYetValid: () => isSiweMessageNotYetValid,
|
|
221
78
|
isSubscriptionActive: () => isSubscriptionActive,
|
|
222
|
-
loginToBillingApi: () => loginToBillingApi,
|
|
223
|
-
loginToBothApis: () => loginToBothApis,
|
|
224
79
|
loginToComputeApi: () => loginToComputeApi,
|
|
225
|
-
logoutFromBillingApi: () => logoutFromBillingApi,
|
|
226
|
-
logoutFromBothApis: () => logoutFromBothApis,
|
|
227
80
|
logoutFromComputeApi: () => logoutFromComputeApi,
|
|
228
81
|
noopLogger: () => noopLogger,
|
|
229
82
|
parseSiweMessage: () => parseSiweMessage,
|
|
@@ -658,8 +511,130 @@ async function calculateBillingAuthSignature(options) {
|
|
|
658
511
|
return { signature, expiry };
|
|
659
512
|
}
|
|
660
513
|
|
|
514
|
+
// src/client/common/auth/session.ts
|
|
515
|
+
var SessionError = class extends Error {
|
|
516
|
+
constructor(message, code, statusCode) {
|
|
517
|
+
super(message);
|
|
518
|
+
this.code = code;
|
|
519
|
+
this.statusCode = statusCode;
|
|
520
|
+
this.name = "SessionError";
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
function stripHexPrefix2(hex) {
|
|
524
|
+
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
525
|
+
}
|
|
526
|
+
async function parseErrorResponse(response) {
|
|
527
|
+
try {
|
|
528
|
+
const data = await response.json();
|
|
529
|
+
return data.error || response.statusText;
|
|
530
|
+
} catch {
|
|
531
|
+
return response.statusText;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
async function loginToComputeApi(config, request) {
|
|
535
|
+
let response;
|
|
536
|
+
try {
|
|
537
|
+
response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
|
|
538
|
+
method: "POST",
|
|
539
|
+
credentials: "include",
|
|
540
|
+
// Include cookies for session management
|
|
541
|
+
headers: {
|
|
542
|
+
"Content-Type": "application/json"
|
|
543
|
+
},
|
|
544
|
+
body: JSON.stringify({
|
|
545
|
+
message: request.message,
|
|
546
|
+
signature: stripHexPrefix2(request.signature)
|
|
547
|
+
})
|
|
548
|
+
});
|
|
549
|
+
} catch (error) {
|
|
550
|
+
throw new SessionError(
|
|
551
|
+
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
552
|
+
"NETWORK_ERROR"
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
if (!response.ok) {
|
|
556
|
+
const errorMessage = await parseErrorResponse(response);
|
|
557
|
+
const status = response.status;
|
|
558
|
+
if (status === 400) {
|
|
559
|
+
if (errorMessage.toLowerCase().includes("siwe")) {
|
|
560
|
+
throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
561
|
+
}
|
|
562
|
+
throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
563
|
+
}
|
|
564
|
+
if (status === 401) {
|
|
565
|
+
throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
|
|
566
|
+
}
|
|
567
|
+
throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
|
|
568
|
+
}
|
|
569
|
+
const data = await response.json();
|
|
570
|
+
return {
|
|
571
|
+
success: data.success,
|
|
572
|
+
address: data.address
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
async function getComputeApiSession(config) {
|
|
576
|
+
let response;
|
|
577
|
+
try {
|
|
578
|
+
response = await fetch(`${config.baseUrl}/auth/session`, {
|
|
579
|
+
method: "GET",
|
|
580
|
+
credentials: "include",
|
|
581
|
+
// Include cookies for session management
|
|
582
|
+
headers: {
|
|
583
|
+
"Content-Type": "application/json"
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
} catch {
|
|
587
|
+
return {
|
|
588
|
+
authenticated: false
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
if (response.status === 401) {
|
|
592
|
+
return {
|
|
593
|
+
authenticated: false
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (!response.ok) {
|
|
597
|
+
const errorMessage = await parseErrorResponse(response);
|
|
598
|
+
throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
|
|
599
|
+
}
|
|
600
|
+
const data = await response.json();
|
|
601
|
+
return {
|
|
602
|
+
authenticated: data.authenticated,
|
|
603
|
+
address: data.address,
|
|
604
|
+
chainId: data.chain_id
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
async function logoutFromComputeApi(config) {
|
|
608
|
+
let response;
|
|
609
|
+
try {
|
|
610
|
+
response = await fetch(`${config.baseUrl}/auth/logout`, {
|
|
611
|
+
method: "POST",
|
|
612
|
+
credentials: "include",
|
|
613
|
+
// Include cookies for session management
|
|
614
|
+
headers: {
|
|
615
|
+
"Content-Type": "application/json"
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
} catch (error) {
|
|
619
|
+
throw new SessionError(
|
|
620
|
+
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
621
|
+
"NETWORK_ERROR"
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
if (response.status === 401) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (!response.ok) {
|
|
628
|
+
const errorMessage = await parseErrorResponse(response);
|
|
629
|
+
throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
async function isSessionValid(config) {
|
|
633
|
+
const session = await getComputeApiSession(config);
|
|
634
|
+
return session.authenticated;
|
|
635
|
+
}
|
|
636
|
+
|
|
661
637
|
// src/client/common/utils/userapi.ts
|
|
662
|
-
init_session();
|
|
663
638
|
function isJsonObject(value) {
|
|
664
639
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
665
640
|
}
|
|
@@ -676,7 +651,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
|
676
651
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
677
652
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
678
653
|
function getDefaultClientId() {
|
|
679
|
-
const version = true ? "0.3.
|
|
654
|
+
const version = true ? "0.3.1-dev" : "0.0.0";
|
|
680
655
|
return `ecloud-sdk/v${version}`;
|
|
681
656
|
}
|
|
682
657
|
var UserApiClient = class {
|
|
@@ -1014,233 +989,21 @@ function transformAppRelease(raw) {
|
|
|
1014
989
|
|
|
1015
990
|
// src/client/common/utils/billingapi.ts
|
|
1016
991
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
1017
|
-
|
|
1018
|
-
// src/client/common/auth/billingSession.ts
|
|
1019
|
-
var BillingSessionError = class extends Error {
|
|
1020
|
-
constructor(message, code, statusCode) {
|
|
1021
|
-
super(message);
|
|
1022
|
-
this.code = code;
|
|
1023
|
-
this.statusCode = statusCode;
|
|
1024
|
-
this.name = "BillingSessionError";
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
function stripHexPrefix3(hex) {
|
|
1028
|
-
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
1029
|
-
}
|
|
1030
|
-
async function parseErrorResponse2(response) {
|
|
1031
|
-
try {
|
|
1032
|
-
const data = await response.json();
|
|
1033
|
-
return data.error || response.statusText;
|
|
1034
|
-
} catch {
|
|
1035
|
-
return response.statusText;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
async function loginToBillingApi(config, request) {
|
|
1039
|
-
let response;
|
|
1040
|
-
try {
|
|
1041
|
-
response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
|
|
1042
|
-
method: "POST",
|
|
1043
|
-
credentials: "include",
|
|
1044
|
-
// Include cookies for session management
|
|
1045
|
-
headers: {
|
|
1046
|
-
"Content-Type": "application/json"
|
|
1047
|
-
},
|
|
1048
|
-
body: JSON.stringify({
|
|
1049
|
-
message: request.message,
|
|
1050
|
-
signature: stripHexPrefix3(request.signature)
|
|
1051
|
-
})
|
|
1052
|
-
});
|
|
1053
|
-
} catch (error) {
|
|
1054
|
-
throw new BillingSessionError(
|
|
1055
|
-
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
1056
|
-
"NETWORK_ERROR"
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
if (!response.ok) {
|
|
1060
|
-
const errorMessage = await parseErrorResponse2(response);
|
|
1061
|
-
const status = response.status;
|
|
1062
|
-
if (status === 400) {
|
|
1063
|
-
if (errorMessage.toLowerCase().includes("siwe")) {
|
|
1064
|
-
throw new BillingSessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
1065
|
-
}
|
|
1066
|
-
throw new BillingSessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
1067
|
-
}
|
|
1068
|
-
if (status === 401) {
|
|
1069
|
-
throw new BillingSessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
|
|
1070
|
-
}
|
|
1071
|
-
throw new BillingSessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
|
|
1072
|
-
}
|
|
1073
|
-
const data = await response.json();
|
|
1074
|
-
return {
|
|
1075
|
-
success: data.success,
|
|
1076
|
-
address: data.address
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
async function getBillingApiSession(config) {
|
|
1080
|
-
let response;
|
|
1081
|
-
try {
|
|
1082
|
-
response = await fetch(`${config.baseUrl}/auth/session`, {
|
|
1083
|
-
method: "GET",
|
|
1084
|
-
credentials: "include",
|
|
1085
|
-
// Include cookies for session management
|
|
1086
|
-
headers: {
|
|
1087
|
-
"Content-Type": "application/json"
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
} catch {
|
|
1091
|
-
return {
|
|
1092
|
-
authenticated: false
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
if (response.status === 401) {
|
|
1096
|
-
return {
|
|
1097
|
-
authenticated: false
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
if (!response.ok) {
|
|
1101
|
-
const errorMessage = await parseErrorResponse2(response);
|
|
1102
|
-
throw new BillingSessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
|
|
1103
|
-
}
|
|
1104
|
-
const data = await response.json();
|
|
1105
|
-
return {
|
|
1106
|
-
authenticated: data.authenticated,
|
|
1107
|
-
address: data.address,
|
|
1108
|
-
chainId: data.chainId,
|
|
1109
|
-
authenticatedAt: data.authenticatedAt
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
async function logoutFromBillingApi(config) {
|
|
1113
|
-
let response;
|
|
1114
|
-
try {
|
|
1115
|
-
response = await fetch(`${config.baseUrl}/auth/logout`, {
|
|
1116
|
-
method: "POST",
|
|
1117
|
-
credentials: "include",
|
|
1118
|
-
// Include cookies for session management
|
|
1119
|
-
headers: {
|
|
1120
|
-
"Content-Type": "application/json"
|
|
1121
|
-
}
|
|
1122
|
-
});
|
|
1123
|
-
} catch (error) {
|
|
1124
|
-
throw new BillingSessionError(
|
|
1125
|
-
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
1126
|
-
"NETWORK_ERROR"
|
|
1127
|
-
);
|
|
1128
|
-
}
|
|
1129
|
-
if (response.status === 401) {
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
1132
|
-
if (!response.ok) {
|
|
1133
|
-
const errorMessage = await parseErrorResponse2(response);
|
|
1134
|
-
throw new BillingSessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
async function isBillingSessionValid(config) {
|
|
1138
|
-
const session = await getBillingApiSession(config);
|
|
1139
|
-
return session.authenticated;
|
|
1140
|
-
}
|
|
1141
|
-
async function loginToBothApis(computeConfig, billingConfig, request) {
|
|
1142
|
-
const { loginToComputeApi: loginToComputeApi2 } = await Promise.resolve().then(() => (init_session(), session_exports));
|
|
1143
|
-
const [compute, billing] = await Promise.all([
|
|
1144
|
-
loginToComputeApi2(computeConfig, request),
|
|
1145
|
-
loginToBillingApi(billingConfig, request)
|
|
1146
|
-
]);
|
|
1147
|
-
return { compute, billing };
|
|
1148
|
-
}
|
|
1149
|
-
async function logoutFromBothApis(computeConfig, billingConfig) {
|
|
1150
|
-
const { logoutFromComputeApi: logoutFromComputeApi2 } = await Promise.resolve().then(() => (init_session(), session_exports));
|
|
1151
|
-
await Promise.all([
|
|
1152
|
-
logoutFromComputeApi2(computeConfig),
|
|
1153
|
-
logoutFromBillingApi(billingConfig)
|
|
1154
|
-
]);
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// src/client/common/utils/billingapi.ts
|
|
1158
992
|
var BillingApiClient = class {
|
|
1159
|
-
constructor(config, walletClient
|
|
993
|
+
constructor(config, walletClient) {
|
|
1160
994
|
this.config = config;
|
|
1161
995
|
this.walletClient = walletClient;
|
|
1162
|
-
this.options = options;
|
|
1163
|
-
this.useSession = options.useSession ?? false;
|
|
1164
|
-
if (!this.useSession && !walletClient) {
|
|
1165
|
-
throw new Error("WalletClient is required when not using session authentication");
|
|
1166
|
-
}
|
|
1167
996
|
}
|
|
1168
997
|
/**
|
|
1169
998
|
* Get the address of the connected wallet
|
|
1170
|
-
* Returns undefined if using session auth without a wallet client
|
|
1171
999
|
*/
|
|
1172
1000
|
get address() {
|
|
1173
|
-
const account = this.walletClient
|
|
1001
|
+
const account = this.walletClient.account;
|
|
1174
1002
|
if (!account) {
|
|
1175
|
-
|
|
1176
|
-
throw new Error("WalletClient must have an account attached");
|
|
1177
|
-
}
|
|
1178
|
-
return void 0;
|
|
1003
|
+
throw new Error("WalletClient must have an account attached");
|
|
1179
1004
|
}
|
|
1180
1005
|
return account.address;
|
|
1181
1006
|
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Get the base URL of the billing API
|
|
1184
|
-
*/
|
|
1185
|
-
get baseUrl() {
|
|
1186
|
-
return this.config.billingApiServerURL;
|
|
1187
|
-
}
|
|
1188
|
-
// ==========================================================================
|
|
1189
|
-
// SIWE Session Methods
|
|
1190
|
-
// ==========================================================================
|
|
1191
|
-
/**
|
|
1192
|
-
* Login to the billing API using SIWE
|
|
1193
|
-
*
|
|
1194
|
-
* This establishes a session with the billing API by verifying the SIWE message
|
|
1195
|
-
* and signature. On success, a session cookie is set in the browser.
|
|
1196
|
-
*
|
|
1197
|
-
* @param request - Login request containing SIWE message and signature
|
|
1198
|
-
* @returns Login result with the authenticated address
|
|
1199
|
-
*
|
|
1200
|
-
* @example
|
|
1201
|
-
* ```typescript
|
|
1202
|
-
* const { message } = createSiweMessage({
|
|
1203
|
-
* address: userAddress,
|
|
1204
|
-
* chainId: 11155111,
|
|
1205
|
-
* domain: window.location.host,
|
|
1206
|
-
* uri: window.location.origin,
|
|
1207
|
-
* });
|
|
1208
|
-
*
|
|
1209
|
-
* const signature = await signMessageAsync({ message });
|
|
1210
|
-
* const result = await billingClient.siweLogin({ message, signature });
|
|
1211
|
-
* ```
|
|
1212
|
-
*/
|
|
1213
|
-
async siweLogin(request) {
|
|
1214
|
-
return loginToBillingApi({ baseUrl: this.baseUrl }, request);
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* Logout from the billing API
|
|
1218
|
-
*
|
|
1219
|
-
* This destroys the current session and clears the session cookie.
|
|
1220
|
-
*/
|
|
1221
|
-
async siweLogout() {
|
|
1222
|
-
return logoutFromBillingApi({ baseUrl: this.baseUrl });
|
|
1223
|
-
}
|
|
1224
|
-
/**
|
|
1225
|
-
* Get the current session status from the billing API
|
|
1226
|
-
*
|
|
1227
|
-
* @returns Session information including authentication status and address
|
|
1228
|
-
*/
|
|
1229
|
-
async getSession() {
|
|
1230
|
-
return getBillingApiSession({ baseUrl: this.baseUrl });
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Check if there is a valid session
|
|
1234
|
-
*
|
|
1235
|
-
* @returns True if session is authenticated, false otherwise
|
|
1236
|
-
*/
|
|
1237
|
-
async isSessionValid() {
|
|
1238
|
-
const session = await this.getSession();
|
|
1239
|
-
return session.authenticated;
|
|
1240
|
-
}
|
|
1241
|
-
// ==========================================================================
|
|
1242
|
-
// Subscription Methods
|
|
1243
|
-
// ==========================================================================
|
|
1244
1007
|
async createSubscription(productId = "compute", options) {
|
|
1245
1008
|
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
1246
1009
|
const body = options ? {
|
|
@@ -1259,72 +1022,10 @@ var BillingApiClient = class {
|
|
|
1259
1022
|
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
1260
1023
|
await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
|
|
1261
1024
|
}
|
|
1262
|
-
// ==========================================================================
|
|
1263
|
-
// Internal Methods
|
|
1264
|
-
// ==========================================================================
|
|
1265
1025
|
/**
|
|
1266
1026
|
* Make an authenticated request to the billing API
|
|
1267
|
-
*
|
|
1268
|
-
* Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
|
|
1269
1027
|
*/
|
|
1270
1028
|
async makeAuthenticatedRequest(url, method, productId, body) {
|
|
1271
|
-
if (this.useSession) {
|
|
1272
|
-
return this.makeSessionAuthenticatedRequest(url, method, body);
|
|
1273
|
-
}
|
|
1274
|
-
return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
1275
|
-
}
|
|
1276
|
-
/**
|
|
1277
|
-
* Make a request using session-based authentication (cookies)
|
|
1278
|
-
*/
|
|
1279
|
-
async makeSessionAuthenticatedRequest(url, method, body) {
|
|
1280
|
-
const headers = {};
|
|
1281
|
-
if (body) {
|
|
1282
|
-
headers["Content-Type"] = "application/json";
|
|
1283
|
-
}
|
|
1284
|
-
try {
|
|
1285
|
-
const response = await fetch(url, {
|
|
1286
|
-
method,
|
|
1287
|
-
credentials: "include",
|
|
1288
|
-
// Include cookies for session management
|
|
1289
|
-
headers,
|
|
1290
|
-
body: body ? JSON.stringify(body) : void 0
|
|
1291
|
-
});
|
|
1292
|
-
const status = response.status;
|
|
1293
|
-
const statusText = status >= 200 && status < 300 ? "OK" : "Error";
|
|
1294
|
-
if (status < 200 || status >= 300) {
|
|
1295
|
-
let errorBody;
|
|
1296
|
-
try {
|
|
1297
|
-
errorBody = await response.text();
|
|
1298
|
-
} catch {
|
|
1299
|
-
errorBody = statusText;
|
|
1300
|
-
}
|
|
1301
|
-
throw new Error(`BillingAPI request failed: ${status} ${statusText} - ${errorBody}`);
|
|
1302
|
-
}
|
|
1303
|
-
const responseData = await response.json();
|
|
1304
|
-
return {
|
|
1305
|
-
json: async () => responseData,
|
|
1306
|
-
text: async () => JSON.stringify(responseData)
|
|
1307
|
-
};
|
|
1308
|
-
} catch (error) {
|
|
1309
|
-
if (error.name === "TypeError" || error.message?.includes("fetch")) {
|
|
1310
|
-
throw new Error(
|
|
1311
|
-
`Failed to connect to BillingAPI at ${url}: ${error.message}
|
|
1312
|
-
Please check:
|
|
1313
|
-
1. Your internet connection
|
|
1314
|
-
2. The API server is accessible: ${this.config.billingApiServerURL}
|
|
1315
|
-
3. Firewall/proxy settings`
|
|
1316
|
-
);
|
|
1317
|
-
}
|
|
1318
|
-
throw error;
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Make a request using EIP-712 signature authentication
|
|
1323
|
-
*/
|
|
1324
|
-
async makeSignatureAuthenticatedRequest(url, method, productId, body) {
|
|
1325
|
-
if (!this.walletClient) {
|
|
1326
|
-
throw new Error("WalletClient is required for signature authentication");
|
|
1327
|
-
}
|
|
1328
1029
|
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
|
|
1329
1030
|
const { signature } = await calculateBillingAuthSignature({
|
|
1330
1031
|
walletClient: this.walletClient,
|
|
@@ -1411,22 +1112,9 @@ async function requestWithRetry(config) {
|
|
|
1411
1112
|
}
|
|
1412
1113
|
var BuildApiClient = class {
|
|
1413
1114
|
constructor(options) {
|
|
1414
|
-
|
|
1415
|
-
while (url.endsWith("/")) {
|
|
1416
|
-
url = url.slice(0, -1);
|
|
1417
|
-
}
|
|
1418
|
-
this.baseUrl = url;
|
|
1115
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
1419
1116
|
this.clientId = options.clientId;
|
|
1420
1117
|
this.walletClient = options.walletClient;
|
|
1421
|
-
this.useSession = options.useSession ?? false;
|
|
1422
|
-
this.billingSessionId = options.billingSessionId;
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
* Update the billing session ID.
|
|
1426
|
-
* Call this after logging into the billing API to enable session-based auth for builds.
|
|
1427
|
-
*/
|
|
1428
|
-
setBillingSessionId(sessionId) {
|
|
1429
|
-
this.billingSessionId = sessionId;
|
|
1430
1118
|
}
|
|
1431
1119
|
/**
|
|
1432
1120
|
* Get the address of the connected wallet
|
|
@@ -1438,17 +1126,8 @@ var BuildApiClient = class {
|
|
|
1438
1126
|
}
|
|
1439
1127
|
return account.address;
|
|
1440
1128
|
}
|
|
1441
|
-
/**
|
|
1442
|
-
* Submit a new build request.
|
|
1443
|
-
* Supports two auth modes (session auth is tried first when billingSessionId is available):
|
|
1444
|
-
* 1. Session-based auth: X-Billing-Session header (forwarded billing_session cookie)
|
|
1445
|
-
* 2. Signature-based auth: Authorization + X-Account + X-eigenx-expiry headers (requires walletClient)
|
|
1446
|
-
*/
|
|
1447
1129
|
async submitBuild(payload) {
|
|
1448
|
-
|
|
1449
|
-
return this.billingSessionAuthJsonRequest("/builds", "POST", payload);
|
|
1450
|
-
}
|
|
1451
|
-
return this.signatureAuthJsonRequest("/builds", "POST", payload);
|
|
1130
|
+
return this.authenticatedJsonRequest("/builds", "POST", payload);
|
|
1452
1131
|
}
|
|
1453
1132
|
async getBuild(buildId) {
|
|
1454
1133
|
return this.publicJsonRequest(`/builds/${encodeURIComponent(buildId)}`);
|
|
@@ -1459,11 +1138,8 @@ var BuildApiClient = class {
|
|
|
1459
1138
|
async verify(identifier) {
|
|
1460
1139
|
return this.publicJsonRequest(`/builds/verify/${encodeURIComponent(identifier)}`);
|
|
1461
1140
|
}
|
|
1462
|
-
/**
|
|
1463
|
-
* Get build logs. Supports session auth (identity verification only, no billing check).
|
|
1464
|
-
*/
|
|
1465
1141
|
async getLogs(buildId) {
|
|
1466
|
-
return this.
|
|
1142
|
+
return this.authenticatedTextRequest(`/builds/${encodeURIComponent(buildId)}/logs`);
|
|
1467
1143
|
}
|
|
1468
1144
|
async listBuilds(params) {
|
|
1469
1145
|
const res = await requestWithRetry({
|
|
@@ -1471,9 +1147,7 @@ var BuildApiClient = class {
|
|
|
1471
1147
|
method: "GET",
|
|
1472
1148
|
params,
|
|
1473
1149
|
headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
|
|
1474
|
-
timeout: 6e4
|
|
1475
|
-
validateStatus: () => true,
|
|
1476
|
-
withCredentials: this.useSession
|
|
1150
|
+
timeout: 6e4
|
|
1477
1151
|
});
|
|
1478
1152
|
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1479
1153
|
return res.data;
|
|
@@ -1483,18 +1157,12 @@ var BuildApiClient = class {
|
|
|
1483
1157
|
url: `${this.baseUrl}${path}`,
|
|
1484
1158
|
method: "GET",
|
|
1485
1159
|
headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
|
|
1486
|
-
timeout: 6e4
|
|
1487
|
-
validateStatus: () => true,
|
|
1488
|
-
withCredentials: this.useSession
|
|
1160
|
+
timeout: 6e4
|
|
1489
1161
|
});
|
|
1490
1162
|
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1491
1163
|
return res.data;
|
|
1492
1164
|
}
|
|
1493
|
-
|
|
1494
|
-
* Make a request that ALWAYS requires signature auth (for billing verification).
|
|
1495
|
-
* Used for endpoints like POST /builds that need to verify subscription status.
|
|
1496
|
-
*/
|
|
1497
|
-
async signatureAuthJsonRequest(path, method, body) {
|
|
1165
|
+
async authenticatedJsonRequest(path, method, body) {
|
|
1498
1166
|
if (!this.walletClient?.account) {
|
|
1499
1167
|
throw new Error("WalletClient with account required for authenticated requests");
|
|
1500
1168
|
}
|
|
@@ -1516,69 +1184,32 @@ var BuildApiClient = class {
|
|
|
1516
1184
|
method,
|
|
1517
1185
|
headers,
|
|
1518
1186
|
data: body,
|
|
1519
|
-
timeout: 6e4
|
|
1520
|
-
validateStatus: () => true,
|
|
1521
|
-
withCredentials: this.useSession
|
|
1187
|
+
timeout: 6e4
|
|
1522
1188
|
});
|
|
1523
1189
|
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1524
1190
|
return res.data;
|
|
1525
1191
|
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
* Used for endpoints that need to verify subscription status when using session-based auth.
|
|
1530
|
-
*/
|
|
1531
|
-
async billingSessionAuthJsonRequest(path, method, body) {
|
|
1532
|
-
if (!this.billingSessionId) {
|
|
1533
|
-
throw new Error("billingSessionId required for session-based billing auth");
|
|
1192
|
+
async authenticatedTextRequest(path) {
|
|
1193
|
+
if (!this.walletClient?.account) {
|
|
1194
|
+
throw new Error("WalletClient with account required for authenticated requests");
|
|
1534
1195
|
}
|
|
1535
|
-
const headers = {
|
|
1536
|
-
"Content-Type": "application/json",
|
|
1537
|
-
"X-Billing-Session": this.billingSessionId
|
|
1538
|
-
};
|
|
1539
|
-
if (this.clientId) headers["x-client-id"] = this.clientId;
|
|
1540
|
-
const res = await requestWithRetry({
|
|
1541
|
-
url: `${this.baseUrl}${path}`,
|
|
1542
|
-
method,
|
|
1543
|
-
headers,
|
|
1544
|
-
data: body,
|
|
1545
|
-
timeout: 6e4,
|
|
1546
|
-
validateStatus: () => true,
|
|
1547
|
-
withCredentials: this.useSession
|
|
1548
|
-
});
|
|
1549
|
-
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1550
|
-
return res.data;
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
* Make an authenticated request that can use session OR signature auth.
|
|
1554
|
-
* When useSession is true, relies on cookies for identity verification.
|
|
1555
|
-
* Used for endpoints that only need identity verification (not billing).
|
|
1556
|
-
*/
|
|
1557
|
-
async sessionOrSignatureTextRequest(path) {
|
|
1558
1196
|
const headers = {};
|
|
1559
1197
|
if (this.clientId) headers["x-client-id"] = this.clientId;
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
});
|
|
1570
|
-
headers.Authorization = `Bearer ${signature}`;
|
|
1571
|
-
headers["X-eigenx-expiry"] = expiry.toString();
|
|
1572
|
-
headers["X-Account"] = this.address;
|
|
1573
|
-
}
|
|
1198
|
+
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
|
|
1199
|
+
const { signature } = await calculateBillingAuthSignature({
|
|
1200
|
+
walletClient: this.walletClient,
|
|
1201
|
+
product: "compute",
|
|
1202
|
+
expiry
|
|
1203
|
+
});
|
|
1204
|
+
headers.Authorization = `Bearer ${signature}`;
|
|
1205
|
+
headers["X-eigenx-expiry"] = expiry.toString();
|
|
1206
|
+
headers["X-Account"] = this.address;
|
|
1574
1207
|
const res = await requestWithRetry({
|
|
1575
1208
|
url: `${this.baseUrl}${path}`,
|
|
1576
1209
|
method: "GET",
|
|
1577
1210
|
headers,
|
|
1578
1211
|
timeout: 6e4,
|
|
1579
|
-
responseType: "text"
|
|
1580
|
-
validateStatus: () => true,
|
|
1581
|
-
withCredentials: this.useSession
|
|
1212
|
+
responseType: "text"
|
|
1582
1213
|
});
|
|
1583
1214
|
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1584
1215
|
return typeof res.data === "string" ? res.data : JSON.stringify(res.data);
|
|
@@ -2648,7 +2279,7 @@ function encodeExecuteBatchData(executions) {
|
|
|
2648
2279
|
});
|
|
2649
2280
|
}
|
|
2650
2281
|
async function estimateBatchGas(options) {
|
|
2651
|
-
const { publicClient, account, executions
|
|
2282
|
+
const { publicClient, account, executions } = options;
|
|
2652
2283
|
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2653
2284
|
const [gasTipCap, block, estimatedGas] = await Promise.all([
|
|
2654
2285
|
publicClient.estimateMaxPriorityFeePerGas(),
|
|
@@ -2656,8 +2287,7 @@ async function estimateBatchGas(options) {
|
|
|
2656
2287
|
publicClient.estimateGas({
|
|
2657
2288
|
account,
|
|
2658
2289
|
to: account,
|
|
2659
|
-
data: executeBatchData
|
|
2660
|
-
authorizationList
|
|
2290
|
+
data: executeBatchData
|
|
2661
2291
|
})
|
|
2662
2292
|
]);
|
|
2663
2293
|
const baseFee = block.baseFeePerGas ?? 0n;
|
|
@@ -2681,15 +2311,7 @@ async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
|
|
|
2681
2311
|
return code.toLowerCase() === expectedCode.toLowerCase();
|
|
2682
2312
|
}
|
|
2683
2313
|
async function executeBatch(options, logger = noopLogger) {
|
|
2684
|
-
const {
|
|
2685
|
-
walletClient,
|
|
2686
|
-
publicClient,
|
|
2687
|
-
environmentConfig,
|
|
2688
|
-
executions,
|
|
2689
|
-
pendingMessage,
|
|
2690
|
-
gas,
|
|
2691
|
-
authorizationList: providedAuthList
|
|
2692
|
-
} = options;
|
|
2314
|
+
const { walletClient, publicClient, environmentConfig, executions, pendingMessage, gas } = options;
|
|
2693
2315
|
const account = walletClient.account;
|
|
2694
2316
|
if (!account) {
|
|
2695
2317
|
throw new Error("Wallet client must have an account");
|
|
@@ -2699,29 +2321,27 @@ async function executeBatch(options, logger = noopLogger) {
|
|
|
2699
2321
|
throw new Error("Wallet client must have a chain");
|
|
2700
2322
|
}
|
|
2701
2323
|
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
authorizationList = [signedAuthorization];
|
|
2724
|
-
}
|
|
2324
|
+
const isDelegated2 = await checkERC7702Delegation(
|
|
2325
|
+
publicClient,
|
|
2326
|
+
account.address,
|
|
2327
|
+
environmentConfig.erc7702DelegatorAddress
|
|
2328
|
+
);
|
|
2329
|
+
let authorizationList = [];
|
|
2330
|
+
if (!isDelegated2) {
|
|
2331
|
+
const transactionNonce = await publicClient.getTransactionCount({
|
|
2332
|
+
address: account.address,
|
|
2333
|
+
blockTag: "pending"
|
|
2334
|
+
});
|
|
2335
|
+
const chainId = await publicClient.getChainId();
|
|
2336
|
+
const authorizationNonce = transactionNonce + 1;
|
|
2337
|
+
logger.debug("Using wallet client signing for EIP-7702 authorization");
|
|
2338
|
+
const signedAuthorization = await walletClient.signAuthorization({
|
|
2339
|
+
account: account.address,
|
|
2340
|
+
contractAddress: environmentConfig.erc7702DelegatorAddress,
|
|
2341
|
+
chainId,
|
|
2342
|
+
nonce: Number(authorizationNonce)
|
|
2343
|
+
});
|
|
2344
|
+
authorizationList = [signedAuthorization];
|
|
2725
2345
|
}
|
|
2726
2346
|
if (pendingMessage) {
|
|
2727
2347
|
logger.info(pendingMessage);
|
|
@@ -2736,9 +2356,6 @@ async function executeBatch(options, logger = noopLogger) {
|
|
|
2736
2356
|
if (authorizationList.length > 0) {
|
|
2737
2357
|
txRequest.authorizationList = authorizationList;
|
|
2738
2358
|
}
|
|
2739
|
-
if (gas?.gasLimit) {
|
|
2740
|
-
txRequest.gas = gas.gasLimit;
|
|
2741
|
-
}
|
|
2742
2359
|
if (gas?.maxFeePerGas) {
|
|
2743
2360
|
txRequest.maxFeePerGas = gas.maxFeePerGas;
|
|
2744
2361
|
}
|
|
@@ -4456,8 +4073,7 @@ async function executeDeployBatch(data, context, gas, logger = noopLogger) {
|
|
|
4456
4073
|
environmentConfig: context.environmentConfig,
|
|
4457
4074
|
executions: data.executions,
|
|
4458
4075
|
pendingMessage,
|
|
4459
|
-
gas
|
|
4460
|
-
authorizationList: data.authorizationList
|
|
4076
|
+
gas
|
|
4461
4077
|
},
|
|
4462
4078
|
logger
|
|
4463
4079
|
);
|
|
@@ -4736,8 +4352,7 @@ async function executeUpgradeBatch(data, context, gas, logger = noopLogger) {
|
|
|
4736
4352
|
environmentConfig: context.environmentConfig,
|
|
4737
4353
|
executions: data.executions,
|
|
4738
4354
|
pendingMessage,
|
|
4739
|
-
gas
|
|
4740
|
-
authorizationList: data.authorizationList
|
|
4355
|
+
gas
|
|
4741
4356
|
},
|
|
4742
4357
|
logger
|
|
4743
4358
|
);
|
|
@@ -5083,12 +4698,8 @@ function isSiweMessageNotYetValid(params) {
|
|
|
5083
4698
|
return /* @__PURE__ */ new Date() < params.notBefore;
|
|
5084
4699
|
}
|
|
5085
4700
|
|
|
5086
|
-
// src/browser.ts
|
|
5087
|
-
init_session();
|
|
5088
|
-
|
|
5089
4701
|
// src/client/common/hooks/useComputeSession.ts
|
|
5090
4702
|
var import_react = require("react");
|
|
5091
|
-
init_session();
|
|
5092
4703
|
function useComputeSession(config) {
|
|
5093
4704
|
const {
|
|
5094
4705
|
baseUrl,
|
|
@@ -5346,7 +4957,6 @@ function getKMSKeysForEnvironment(environment, build = "prod") {
|
|
|
5346
4957
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5347
4958
|
0 && (module.exports = {
|
|
5348
4959
|
BillingApiClient,
|
|
5349
|
-
BillingSessionError,
|
|
5350
4960
|
BuildApiClient,
|
|
5351
4961
|
SessionError,
|
|
5352
4962
|
UserApiClient,
|
|
@@ -5378,7 +4988,6 @@ function getKMSKeysForEnvironment(environment, build = "prod") {
|
|
|
5378
4988
|
getAppsByCreator,
|
|
5379
4989
|
getAppsByDeveloper,
|
|
5380
4990
|
getAvailableEnvironments,
|
|
5381
|
-
getBillingApiSession,
|
|
5382
4991
|
getBillingEnvironmentConfig,
|
|
5383
4992
|
getBuildType,
|
|
5384
4993
|
getChainFromID,
|
|
@@ -5386,7 +4995,6 @@ function getKMSKeysForEnvironment(environment, build = "prod") {
|
|
|
5386
4995
|
getEnvironmentConfig,
|
|
5387
4996
|
getKMSKeysForEnvironment,
|
|
5388
4997
|
getMaxActiveAppsPerUser,
|
|
5389
|
-
isBillingSessionValid,
|
|
5390
4998
|
isDelegated,
|
|
5391
4999
|
isEnvironmentAvailable,
|
|
5392
5000
|
isMainnet,
|
|
@@ -5394,11 +5002,7 @@ function getKMSKeysForEnvironment(environment, build = "prod") {
|
|
|
5394
5002
|
isSiweMessageExpired,
|
|
5395
5003
|
isSiweMessageNotYetValid,
|
|
5396
5004
|
isSubscriptionActive,
|
|
5397
|
-
loginToBillingApi,
|
|
5398
|
-
loginToBothApis,
|
|
5399
5005
|
loginToComputeApi,
|
|
5400
|
-
logoutFromBillingApi,
|
|
5401
|
-
logoutFromBothApis,
|
|
5402
5006
|
logoutFromComputeApi,
|
|
5403
5007
|
noopLogger,
|
|
5404
5008
|
parseSiweMessage,
|