@hashgraphonline/standards-sdk 0.1.180 → 0.1.181
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/services/registry-broker/client/base-client.d.ts +3 -0
- package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/types.d.ts +3 -0
- package/dist/browser/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts +3 -0
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/types.d.ts +3 -0
- package/dist/browser-root/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser-root/standards-sdk.root-browser.js +340 -104
- package/dist/browser-root/standards-sdk.root-browser.js.map +1 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +3 -0
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +3 -0
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts +3 -0
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +3 -0
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +10 -7
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es106.js +1 -1
- package/dist/es/standards-sdk.es108.js +1 -1
- package/dist/es/standards-sdk.es11.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es116.js +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es127.js +2 -2
- package/dist/es/standards-sdk.es142.js +1 -1
- package/dist/es/standards-sdk.es145.js +43 -14
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +3 -3
- package/dist/es/standards-sdk.es148.js +4 -81
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +71 -77
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es150.js +80 -53
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +53 -152
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +159 -7
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +7 -86
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +64 -43
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +65 -30
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +30 -34
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +34 -48
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +48 -138
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +133 -37
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +2 -2
- package/dist/es/standards-sdk.es160.js +42 -2352
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +2352 -672
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +15 -54
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +63 -71
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +48 -192
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +79 -15
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +181 -54
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +653 -120
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +111 -303
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +297 -225
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +239 -176
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +178 -101
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +4 -4
- package/dist/es/standards-sdk.es180.js +75 -108
- package/dist/es/standards-sdk.es180.js.map +1 -1
- package/dist/es/standards-sdk.es181.js +116 -148
- package/dist/es/standards-sdk.es181.js.map +1 -1
- package/dist/es/standards-sdk.es182.js +143 -439
- package/dist/es/standards-sdk.es182.js.map +1 -1
- package/dist/es/standards-sdk.es183.js +661 -162
- package/dist/es/standards-sdk.es183.js.map +1 -1
- package/dist/es/standards-sdk.es184.js +156 -206
- package/dist/es/standards-sdk.es184.js.map +1 -1
- package/dist/es/standards-sdk.es185.js +219 -223
- package/dist/es/standards-sdk.es185.js.map +1 -1
- package/dist/es/standards-sdk.es186.js +242 -0
- package/dist/es/standards-sdk.es186.js.map +1 -0
- package/dist/es/standards-sdk.es19.js +2 -2
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es27.js +4 -4
- package/dist/es/standards-sdk.es35.js +2 -2
- package/dist/es/standards-sdk.es36.js +2 -2
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es56.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es67.js +3 -3
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es71.js +1 -1
- package/dist/es/standards-sdk.es72.js +2 -2
- package/dist/es/standards-sdk.es75.js +2 -2
- package/dist/es/standards-sdk.es76.js +1 -1
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es83.js +1 -1
- package/dist/es/standards-sdk.es84.js +2 -2
- package/dist/es/standards-sdk.es85.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es90.js +1 -1
- package/dist/es/standards-sdk.es94.js +3 -3
- package/dist/es/standards-sdk.es98.js +1 -1
- package/dist/es/standards-sdk.es99.js +1 -1
- package/package.json +1 -1
|
@@ -1,483 +1,187 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"guard session response"
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
async function getGuardEntitlements(client) {
|
|
13
|
-
const raw = await client.requestJson("/guard/entitlements", {
|
|
14
|
-
method: "GET"
|
|
15
|
-
});
|
|
16
|
-
return client.parseWithSchema(
|
|
17
|
-
raw,
|
|
18
|
-
guardSessionResponseSchema,
|
|
19
|
-
"guard entitlements response"
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
async function getGuardBillingBalance(client) {
|
|
23
|
-
const raw = await client.requestJson("/guard/billing/balance", {
|
|
24
|
-
method: "GET"
|
|
25
|
-
});
|
|
26
|
-
return client.parseWithSchema(
|
|
27
|
-
raw,
|
|
28
|
-
guardBalanceResponseSchema,
|
|
29
|
-
"guard billing balance response"
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
async function getGuardFeed(client, limit) {
|
|
33
|
-
const params = new URLSearchParams();
|
|
34
|
-
if (typeof limit === "number" && Number.isFinite(limit) && Math.trunc(limit) > 0) {
|
|
35
|
-
params.set("limit", String(Math.trunc(limit)));
|
|
1
|
+
import { creditBalanceResponseSchema, creditProvidersResponseSchema, hbarPurchaseIntentResponseSchema, creditPurchaseResponseSchema, x402MinimumsResponseSchema, x402CreditPurchaseResponseSchema } from "./standards-sdk.es162.js";
|
|
2
|
+
import { normalizeHexPrivateKey } from "./standards-sdk.es186.js";
|
|
3
|
+
import { optionalImport } from "./standards-sdk.es164.js";
|
|
4
|
+
async function getCreditsBalance(client, params = {}) {
|
|
5
|
+
const query = new URLSearchParams();
|
|
6
|
+
const normalizedAccountId = params.accountId?.trim();
|
|
7
|
+
if (normalizedAccountId) {
|
|
8
|
+
query.set("accountId", normalizedAccountId);
|
|
36
9
|
}
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const raw = await client.requestJson(`/guard/feed${suffix}`, {
|
|
10
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
11
|
+
const raw = await client.requestJson(`/credits/balance${suffix}`, {
|
|
40
12
|
method: "GET"
|
|
41
13
|
});
|
|
42
14
|
return client.parseWithSchema(
|
|
43
15
|
raw,
|
|
44
|
-
|
|
45
|
-
"
|
|
16
|
+
creditBalanceResponseSchema,
|
|
17
|
+
"credit balance response"
|
|
46
18
|
);
|
|
47
19
|
}
|
|
48
|
-
async function
|
|
49
|
-
const raw = await client.requestJson("/
|
|
20
|
+
async function getCreditProviders(client) {
|
|
21
|
+
const raw = await client.requestJson("/credits/providers", {
|
|
50
22
|
method: "GET"
|
|
51
23
|
});
|
|
52
24
|
return client.parseWithSchema(
|
|
53
25
|
raw,
|
|
54
|
-
|
|
55
|
-
"
|
|
26
|
+
creditProvidersResponseSchema,
|
|
27
|
+
"credit providers response"
|
|
56
28
|
);
|
|
57
29
|
}
|
|
58
|
-
async function
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
30
|
+
async function createHbarPurchaseIntent(client, payload) {
|
|
31
|
+
const body = {};
|
|
32
|
+
const normalizedAccountId = payload.accountId?.trim();
|
|
33
|
+
if (normalizedAccountId) {
|
|
34
|
+
body.accountId = normalizedAccountId;
|
|
62
35
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{ method: "GET" }
|
|
66
|
-
);
|
|
67
|
-
return client.parseWithSchema(
|
|
68
|
-
raw,
|
|
69
|
-
guardTrustByHashResponseSchema,
|
|
70
|
-
"guard trust by hash response"
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
async function resolveGuardTrust(client, query) {
|
|
74
|
-
const params = new URLSearchParams();
|
|
75
|
-
if (query.ecosystem?.trim()) {
|
|
76
|
-
params.set("ecosystem", query.ecosystem.trim());
|
|
36
|
+
if (payload.credits !== void 0) {
|
|
37
|
+
body.credits = payload.credits;
|
|
77
38
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
39
|
+
if (payload.hbarAmount !== void 0) {
|
|
40
|
+
body.hbarAmount = payload.hbarAmount;
|
|
80
41
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
42
|
+
if (payload.memo?.trim()) {
|
|
43
|
+
body.memo = payload.memo.trim();
|
|
83
44
|
}
|
|
84
|
-
const suffix = params.size > 0 ? `?${params.toString()}` : "";
|
|
85
45
|
const raw = await client.requestJson(
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"guard trust resolve response"
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
async function getGuardRevocations(client) {
|
|
96
|
-
const raw = await client.requestJson("/guard/revocations", {
|
|
97
|
-
method: "GET"
|
|
98
|
-
});
|
|
99
|
-
return client.parseWithSchema(
|
|
100
|
-
raw,
|
|
101
|
-
guardRevocationResponseSchema,
|
|
102
|
-
"guard revocations response"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
async function fetchGuardAdvisories(client) {
|
|
106
|
-
const raw = await client.requestJson("/guard/advisories", {
|
|
107
|
-
method: "GET"
|
|
108
|
-
});
|
|
109
|
-
return client.parseWithSchema(
|
|
110
|
-
raw,
|
|
111
|
-
guardRevocationResponseSchema,
|
|
112
|
-
"guard advisories response"
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
async function fetchGuardPolicy(client) {
|
|
116
|
-
const raw = await client.requestJson("/guard/policy/fetch", {
|
|
117
|
-
method: "GET"
|
|
118
|
-
});
|
|
119
|
-
return client.parseWithSchema(
|
|
120
|
-
raw,
|
|
121
|
-
guardPolicySchema,
|
|
122
|
-
"guard policy response"
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
async function getGuardInventory(client) {
|
|
126
|
-
const raw = await client.requestJson("/guard/inventory", {
|
|
127
|
-
method: "GET"
|
|
128
|
-
});
|
|
129
|
-
return client.parseWithSchema(
|
|
130
|
-
raw,
|
|
131
|
-
guardInventoryResponseSchema,
|
|
132
|
-
"guard inventory response"
|
|
46
|
+
"/credits/payments/hbar/intent",
|
|
47
|
+
{
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: { "content-type": "application/json" },
|
|
50
|
+
body
|
|
51
|
+
}
|
|
133
52
|
);
|
|
134
|
-
}
|
|
135
|
-
async function getGuardReceiptHistory(client) {
|
|
136
|
-
const raw = await client.requestJson("/guard/history", {
|
|
137
|
-
method: "GET"
|
|
138
|
-
});
|
|
139
53
|
return client.parseWithSchema(
|
|
140
54
|
raw,
|
|
141
|
-
|
|
142
|
-
"
|
|
55
|
+
hbarPurchaseIntentResponseSchema,
|
|
56
|
+
"hbar purchase intent response"
|
|
143
57
|
);
|
|
144
58
|
}
|
|
145
|
-
async function
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
59
|
+
async function loadX402Dependencies(client) {
|
|
60
|
+
const [{ default: axios }, x402Axios, x402Types] = await Promise.all([
|
|
61
|
+
import("axios"),
|
|
62
|
+
optionalImport("x402-axios"),
|
|
63
|
+
optionalImport("x402/types")
|
|
64
|
+
]);
|
|
65
|
+
if (!x402Axios || !x402Types) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
"x402-axios and x402/types are required for X402 flows. Install them to enable ledger payments."
|
|
68
|
+
);
|
|
149
69
|
}
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
return
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
async function exportGuardArtifactAbom(client, artifactId) {
|
|
171
|
-
const normalizedArtifactId = artifactId.trim();
|
|
172
|
-
if (!normalizedArtifactId) {
|
|
173
|
-
throw new Error("artifactId is required");
|
|
70
|
+
const withPaymentInterceptor = x402Axios.withPaymentInterceptor;
|
|
71
|
+
const decodePaymentResponse = x402Axios.decodeXPaymentResponse;
|
|
72
|
+
const createX402Signer = x402Types.createSigner;
|
|
73
|
+
const createPaymentClient = (walletClient) => {
|
|
74
|
+
const axiosClient = axios.create({
|
|
75
|
+
baseURL: client.baseUrl,
|
|
76
|
+
headers: {
|
|
77
|
+
...client.getDefaultHeaders(),
|
|
78
|
+
"content-type": "application/json"
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const paymentClient = withPaymentInterceptor(axiosClient, walletClient);
|
|
82
|
+
return paymentClient;
|
|
83
|
+
};
|
|
84
|
+
return { createPaymentClient, decodePaymentResponse, createX402Signer };
|
|
85
|
+
}
|
|
86
|
+
function calculateHbarAmountParam(hbarAmount) {
|
|
87
|
+
const tinybars = Math.ceil(hbarAmount * 1e8);
|
|
88
|
+
if (tinybars <= 0) {
|
|
89
|
+
throw new Error("Calculated purchase amount must be positive");
|
|
174
90
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
raw,
|
|
191
|
-
guardReceiptExportResponseSchema,
|
|
192
|
-
"guard receipt export response"
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
async function getGuardInventoryDiff(client) {
|
|
196
|
-
const raw = await client.requestJson("/guard/inventory/diff", {
|
|
197
|
-
method: "GET"
|
|
198
|
-
});
|
|
199
|
-
return client.parseWithSchema(
|
|
200
|
-
raw,
|
|
201
|
-
guardInventoryDiffResponseSchema,
|
|
202
|
-
"guard inventory diff response"
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
async function getGuardDevices(client) {
|
|
206
|
-
const raw = await client.requestJson("/guard/devices", {
|
|
207
|
-
method: "GET"
|
|
208
|
-
});
|
|
209
|
-
return client.parseWithSchema(
|
|
210
|
-
raw,
|
|
211
|
-
guardDeviceListResponseSchema,
|
|
212
|
-
"guard devices response"
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
async function getGuardAlertPreferences(client) {
|
|
216
|
-
const raw = await client.requestJson("/guard/alerts/preferences", {
|
|
217
|
-
method: "GET"
|
|
218
|
-
});
|
|
219
|
-
return client.parseWithSchema(
|
|
220
|
-
raw,
|
|
221
|
-
guardAlertPreferencesSchema,
|
|
222
|
-
"guard alert preferences response"
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
async function updateGuardAlertPreferences(client, payload) {
|
|
226
|
-
const raw = await client.requestJson("/guard/alerts/preferences", {
|
|
227
|
-
method: "PUT",
|
|
228
|
-
body: payload
|
|
229
|
-
});
|
|
230
|
-
return client.parseWithSchema(
|
|
231
|
-
raw,
|
|
232
|
-
guardAlertPreferencesSchema,
|
|
233
|
-
"guard alert preferences response"
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
async function getGuardExceptions(client) {
|
|
237
|
-
const raw = await client.requestJson("/guard/exceptions", {
|
|
238
|
-
method: "GET"
|
|
239
|
-
});
|
|
240
|
-
return client.parseWithSchema(
|
|
241
|
-
raw,
|
|
242
|
-
guardExceptionListResponseSchema,
|
|
243
|
-
"guard exceptions response"
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
async function getGuardWatchlist(client) {
|
|
247
|
-
const raw = await client.requestJson("/guard/watchlist", {
|
|
248
|
-
method: "GET"
|
|
249
|
-
});
|
|
250
|
-
return client.parseWithSchema(
|
|
251
|
-
raw,
|
|
252
|
-
guardWatchlistResponseSchema,
|
|
253
|
-
"guard watchlist response"
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
async function lookupGuardWatchlist(client, payload) {
|
|
257
|
-
const raw = await client.requestJson("/guard/watchlist/lookup", {
|
|
91
|
+
return tinybars / 1e8;
|
|
92
|
+
}
|
|
93
|
+
async function purchaseCreditsWithHbar(client, params) {
|
|
94
|
+
const body = {
|
|
95
|
+
accountId: params.accountId,
|
|
96
|
+
payerKey: params.privateKey,
|
|
97
|
+
hbarAmount: calculateHbarAmountParam(params.hbarAmount)
|
|
98
|
+
};
|
|
99
|
+
if (params.memo) {
|
|
100
|
+
body.memo = params.memo;
|
|
101
|
+
}
|
|
102
|
+
if (params.metadata) {
|
|
103
|
+
body.metadata = params.metadata;
|
|
104
|
+
}
|
|
105
|
+
const raw = await client.requestJson("/credits/purchase", {
|
|
258
106
|
method: "POST",
|
|
259
|
-
|
|
107
|
+
headers: { "content-type": "application/json" },
|
|
108
|
+
body
|
|
260
109
|
});
|
|
261
110
|
return client.parseWithSchema(
|
|
262
111
|
raw,
|
|
263
|
-
|
|
264
|
-
"
|
|
112
|
+
creditPurchaseResponseSchema,
|
|
113
|
+
"credit purchase response"
|
|
265
114
|
);
|
|
266
115
|
}
|
|
267
|
-
async function
|
|
268
|
-
const raw = await client.requestJson("/guard/signals/pain", {
|
|
269
|
-
method: "GET"
|
|
270
|
-
});
|
|
271
|
-
return client.parseWithSchema(
|
|
272
|
-
raw,
|
|
273
|
-
guardPainSignalListResponseSchema,
|
|
274
|
-
"guard pain signals response"
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
async function getGuardAggregatedPainSignals(client) {
|
|
116
|
+
async function getX402Minimums(client) {
|
|
278
117
|
const raw = await client.requestJson(
|
|
279
|
-
"/
|
|
280
|
-
{
|
|
281
|
-
method: "GET"
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
return client.parseWithSchema(
|
|
285
|
-
raw,
|
|
286
|
-
guardPainSignalAggregateResponseSchema,
|
|
287
|
-
"guard aggregated pain signals response"
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
async function getGuardPreflightVerdict(client, path, payload) {
|
|
291
|
-
const raw = await client.requestJson(path, {
|
|
292
|
-
method: "POST",
|
|
293
|
-
body: payload
|
|
294
|
-
});
|
|
295
|
-
return client.parseWithSchema(
|
|
296
|
-
raw,
|
|
297
|
-
guardPreflightVerdictResponseSchema,
|
|
298
|
-
"guard preflight verdict response"
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
async function getGuardPreInstallVerdict(client, payload) {
|
|
302
|
-
return getGuardPreflightVerdict(
|
|
303
|
-
client,
|
|
304
|
-
"/guard/verdict/pre-install",
|
|
305
|
-
payload
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
async function getGuardPreExecutionVerdict(client, payload) {
|
|
309
|
-
return getGuardPreflightVerdict(
|
|
310
|
-
client,
|
|
311
|
-
"/guard/verdict/pre-execution",
|
|
312
|
-
payload
|
|
118
|
+
"/credits/purchase/x402/minimums",
|
|
119
|
+
{ method: "GET" }
|
|
313
120
|
);
|
|
314
|
-
}
|
|
315
|
-
async function ingestGuardPainSignals(client, items) {
|
|
316
|
-
const raw = await client.requestJson("/guard/signals/pain", {
|
|
317
|
-
method: "POST",
|
|
318
|
-
body: { items }
|
|
319
|
-
});
|
|
320
121
|
return client.parseWithSchema(
|
|
321
122
|
raw,
|
|
322
|
-
|
|
323
|
-
"
|
|
123
|
+
x402MinimumsResponseSchema,
|
|
124
|
+
"x402 minimums response"
|
|
324
125
|
);
|
|
325
126
|
}
|
|
326
|
-
async function
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
});
|
|
331
|
-
return client.parseWithSchema(
|
|
332
|
-
raw,
|
|
333
|
-
guardReceiptSyncResponseSchema,
|
|
334
|
-
"guard receipt submit response"
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
async function addGuardWatchlistItem(client, payload) {
|
|
338
|
-
const raw = await client.requestJson("/guard/watchlist", {
|
|
339
|
-
method: "POST",
|
|
340
|
-
body: payload
|
|
341
|
-
});
|
|
342
|
-
return client.parseWithSchema(
|
|
343
|
-
raw,
|
|
344
|
-
guardWatchlistResponseSchema,
|
|
345
|
-
"guard watchlist response"
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
async function removeGuardWatchlistItem(client, artifactId) {
|
|
349
|
-
const normalizedArtifactId = artifactId.trim();
|
|
350
|
-
if (!normalizedArtifactId) {
|
|
351
|
-
throw new Error("artifactId is required");
|
|
127
|
+
async function purchaseCreditsWithX402(client, params) {
|
|
128
|
+
const { createPaymentClient, decodePaymentResponse } = await loadX402Dependencies(client);
|
|
129
|
+
if (!Number.isFinite(params.credits) || params.credits <= 0) {
|
|
130
|
+
throw new Error("credits must be a positive number");
|
|
352
131
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
{ method: "DELETE" }
|
|
356
|
-
);
|
|
357
|
-
return client.parseWithSchema(
|
|
358
|
-
raw,
|
|
359
|
-
guardWatchlistResponseSchema,
|
|
360
|
-
"guard watchlist response"
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
async function addGuardException(client, payload) {
|
|
364
|
-
const raw = await client.requestJson("/guard/exceptions", {
|
|
365
|
-
method: "POST",
|
|
366
|
-
body: payload
|
|
367
|
-
});
|
|
368
|
-
return client.parseWithSchema(
|
|
369
|
-
raw,
|
|
370
|
-
guardExceptionListResponseSchema,
|
|
371
|
-
"guard exceptions response"
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
async function requestGuardException(client, payload) {
|
|
375
|
-
const raw = await client.requestJson("/guard/exceptions/request", {
|
|
376
|
-
method: "POST",
|
|
377
|
-
body: payload
|
|
378
|
-
});
|
|
379
|
-
return client.parseWithSchema(
|
|
380
|
-
raw,
|
|
381
|
-
guardExceptionListResponseSchema,
|
|
382
|
-
"guard exception request response"
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
async function syncGuardInventory(client, payload) {
|
|
386
|
-
const raw = await client.requestJson("/guard/inventory/sync", {
|
|
387
|
-
method: "POST",
|
|
388
|
-
body: payload
|
|
389
|
-
});
|
|
390
|
-
return client.parseWithSchema(
|
|
391
|
-
raw,
|
|
392
|
-
guardReceiptSyncResponseSchema,
|
|
393
|
-
"guard inventory sync response"
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
async function removeGuardException(client, exceptionId) {
|
|
397
|
-
const normalizedExceptionId = exceptionId.trim();
|
|
398
|
-
if (!normalizedExceptionId) {
|
|
399
|
-
throw new Error("exceptionId is required");
|
|
132
|
+
if (params.usdAmount !== void 0 && (!Number.isFinite(params.usdAmount) || params.usdAmount <= 0)) {
|
|
133
|
+
throw new Error("usdAmount must be a positive number when provided");
|
|
400
134
|
}
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
135
|
+
const body = {
|
|
136
|
+
accountId: params.accountId,
|
|
137
|
+
credits: params.credits
|
|
138
|
+
};
|
|
139
|
+
if (params.usdAmount !== void 0) {
|
|
140
|
+
body.usdAmount = params.usdAmount;
|
|
141
|
+
}
|
|
142
|
+
if (params.description) {
|
|
143
|
+
body.description = params.description;
|
|
144
|
+
}
|
|
145
|
+
if (params.metadata) {
|
|
146
|
+
body.metadata = params.metadata;
|
|
147
|
+
}
|
|
148
|
+
const paymentClient = createPaymentClient(params.walletClient);
|
|
149
|
+
const response = await paymentClient.post("/credits/purchase/x402", body);
|
|
150
|
+
const parsed = client.parseWithSchema(
|
|
151
|
+
response.data,
|
|
152
|
+
x402CreditPurchaseResponseSchema,
|
|
153
|
+
"x402 credit purchase response"
|
|
154
|
+
);
|
|
155
|
+
const responseHeaders = response.headers ?? {};
|
|
156
|
+
const paymentHeader = typeof responseHeaders["x-payment-response"] === "string" ? responseHeaders["x-payment-response"] : void 0;
|
|
157
|
+
const decodedPayment = paymentHeader !== void 0 ? decodePaymentResponse(paymentHeader) : void 0;
|
|
158
|
+
return {
|
|
159
|
+
...parsed,
|
|
160
|
+
paymentResponseHeader: paymentHeader,
|
|
161
|
+
paymentResponse: decodedPayment
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
async function buyCreditsWithX402(client, params) {
|
|
165
|
+
const network = params.network ?? "base";
|
|
166
|
+
const { createX402Signer } = await loadX402Dependencies(client);
|
|
167
|
+
const normalizedKey = normalizeHexPrivateKey(params.evmPrivateKey);
|
|
168
|
+
const walletClient = await createX402Signer(network, normalizedKey);
|
|
169
|
+
return purchaseCreditsWithX402(client, {
|
|
170
|
+
accountId: params.accountId,
|
|
171
|
+
credits: params.credits,
|
|
172
|
+
usdAmount: params.usdAmount,
|
|
173
|
+
description: params.description,
|
|
174
|
+
metadata: params.metadata,
|
|
175
|
+
walletClient
|
|
436
176
|
});
|
|
437
|
-
return client.parseWithSchema(
|
|
438
|
-
raw,
|
|
439
|
-
guardReceiptSyncResponseSchema,
|
|
440
|
-
"guard receipt sync response"
|
|
441
|
-
);
|
|
442
177
|
}
|
|
443
178
|
export {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
getGuardAggregatedPainSignals,
|
|
452
|
-
getGuardAlertPreferences,
|
|
453
|
-
getGuardArtifactTimeline,
|
|
454
|
-
getGuardBillingBalance,
|
|
455
|
-
getGuardDevices,
|
|
456
|
-
getGuardEntitlements,
|
|
457
|
-
getGuardExceptions,
|
|
458
|
-
getGuardFeed,
|
|
459
|
-
getGuardInventory,
|
|
460
|
-
getGuardInventoryDiff,
|
|
461
|
-
getGuardOverview,
|
|
462
|
-
getGuardPainSignals,
|
|
463
|
-
getGuardPreExecutionVerdict,
|
|
464
|
-
getGuardPreInstallVerdict,
|
|
465
|
-
getGuardReceiptHistory,
|
|
466
|
-
getGuardRevocations,
|
|
467
|
-
getGuardSession,
|
|
468
|
-
getGuardTeamPolicyPack,
|
|
469
|
-
getGuardTrustByHash,
|
|
470
|
-
getGuardWatchlist,
|
|
471
|
-
ingestGuardPainSignals,
|
|
472
|
-
lookupGuardWatchlist,
|
|
473
|
-
removeGuardException,
|
|
474
|
-
removeGuardWatchlistItem,
|
|
475
|
-
requestGuardException,
|
|
476
|
-
resolveGuardTrust,
|
|
477
|
-
submitGuardReceipts,
|
|
478
|
-
syncGuardInventory,
|
|
479
|
-
syncGuardReceipts,
|
|
480
|
-
updateGuardAlertPreferences,
|
|
481
|
-
updateGuardTeamPolicyPack
|
|
179
|
+
buyCreditsWithX402,
|
|
180
|
+
createHbarPurchaseIntent,
|
|
181
|
+
getCreditProviders,
|
|
182
|
+
getCreditsBalance,
|
|
183
|
+
getX402Minimums,
|
|
184
|
+
purchaseCreditsWithHbar,
|
|
185
|
+
purchaseCreditsWithX402
|
|
482
186
|
};
|
|
483
187
|
//# sourceMappingURL=standards-sdk.es182.js.map
|