@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.
Files changed (132) hide show
  1. package/dist/browser/services/registry-broker/client/base-client.d.ts +3 -0
  2. package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
  3. package/dist/browser/services/registry-broker/client/guard.d.ts.map +1 -1
  4. package/dist/browser/services/registry-broker/types.d.ts +3 -0
  5. package/dist/browser/services/registry-broker/types.d.ts.map +1 -1
  6. package/dist/browser-root/services/registry-broker/client/base-client.d.ts +3 -0
  7. package/dist/browser-root/services/registry-broker/client/base-client.d.ts.map +1 -1
  8. package/dist/browser-root/services/registry-broker/client/guard.d.ts.map +1 -1
  9. package/dist/browser-root/services/registry-broker/types.d.ts +3 -0
  10. package/dist/browser-root/services/registry-broker/types.d.ts.map +1 -1
  11. package/dist/browser-root/standards-sdk.root-browser.js +340 -104
  12. package/dist/browser-root/standards-sdk.root-browser.js.map +1 -1
  13. package/dist/cjs/services/registry-broker/client/base-client.d.ts +3 -0
  14. package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
  15. package/dist/cjs/services/registry-broker/client/guard.d.ts.map +1 -1
  16. package/dist/cjs/services/registry-broker/types.d.ts +3 -0
  17. package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
  18. package/dist/cjs/standards-sdk.cjs +1 -1
  19. package/dist/cjs/standards-sdk.cjs.map +1 -1
  20. package/dist/es/services/registry-broker/client/base-client.d.ts +3 -0
  21. package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
  22. package/dist/es/services/registry-broker/client/guard.d.ts.map +1 -1
  23. package/dist/es/services/registry-broker/types.d.ts +3 -0
  24. package/dist/es/services/registry-broker/types.d.ts.map +1 -1
  25. package/dist/es/standards-sdk.es.js +10 -7
  26. package/dist/es/standards-sdk.es.js.map +1 -1
  27. package/dist/es/standards-sdk.es104.js +1 -1
  28. package/dist/es/standards-sdk.es106.js +1 -1
  29. package/dist/es/standards-sdk.es108.js +1 -1
  30. package/dist/es/standards-sdk.es11.js +1 -1
  31. package/dist/es/standards-sdk.es110.js +1 -1
  32. package/dist/es/standards-sdk.es116.js +1 -1
  33. package/dist/es/standards-sdk.es12.js +1 -1
  34. package/dist/es/standards-sdk.es121.js +1 -1
  35. package/dist/es/standards-sdk.es127.js +2 -2
  36. package/dist/es/standards-sdk.es142.js +1 -1
  37. package/dist/es/standards-sdk.es145.js +43 -14
  38. package/dist/es/standards-sdk.es145.js.map +1 -1
  39. package/dist/es/standards-sdk.es147.js +3 -3
  40. package/dist/es/standards-sdk.es148.js +4 -81
  41. package/dist/es/standards-sdk.es148.js.map +1 -1
  42. package/dist/es/standards-sdk.es149.js +71 -77
  43. package/dist/es/standards-sdk.es149.js.map +1 -1
  44. package/dist/es/standards-sdk.es150.js +80 -53
  45. package/dist/es/standards-sdk.es150.js.map +1 -1
  46. package/dist/es/standards-sdk.es151.js +53 -152
  47. package/dist/es/standards-sdk.es151.js.map +1 -1
  48. package/dist/es/standards-sdk.es152.js +159 -7
  49. package/dist/es/standards-sdk.es152.js.map +1 -1
  50. package/dist/es/standards-sdk.es153.js +7 -86
  51. package/dist/es/standards-sdk.es153.js.map +1 -1
  52. package/dist/es/standards-sdk.es154.js +64 -43
  53. package/dist/es/standards-sdk.es154.js.map +1 -1
  54. package/dist/es/standards-sdk.es155.js +65 -30
  55. package/dist/es/standards-sdk.es155.js.map +1 -1
  56. package/dist/es/standards-sdk.es156.js +30 -34
  57. package/dist/es/standards-sdk.es156.js.map +1 -1
  58. package/dist/es/standards-sdk.es157.js +34 -48
  59. package/dist/es/standards-sdk.es157.js.map +1 -1
  60. package/dist/es/standards-sdk.es158.js +48 -138
  61. package/dist/es/standards-sdk.es158.js.map +1 -1
  62. package/dist/es/standards-sdk.es159.js +133 -37
  63. package/dist/es/standards-sdk.es159.js.map +1 -1
  64. package/dist/es/standards-sdk.es16.js +2 -2
  65. package/dist/es/standards-sdk.es160.js +42 -2352
  66. package/dist/es/standards-sdk.es160.js.map +1 -1
  67. package/dist/es/standards-sdk.es162.js +2352 -672
  68. package/dist/es/standards-sdk.es162.js.map +1 -1
  69. package/dist/es/standards-sdk.es163.js +15 -54
  70. package/dist/es/standards-sdk.es163.js.map +1 -1
  71. package/dist/es/standards-sdk.es165.js +63 -71
  72. package/dist/es/standards-sdk.es165.js.map +1 -1
  73. package/dist/es/standards-sdk.es166.js +48 -192
  74. package/dist/es/standards-sdk.es166.js.map +1 -1
  75. package/dist/es/standards-sdk.es167.js +79 -15
  76. package/dist/es/standards-sdk.es167.js.map +1 -1
  77. package/dist/es/standards-sdk.es168.js +181 -54
  78. package/dist/es/standards-sdk.es168.js.map +1 -1
  79. package/dist/es/standards-sdk.es175.js +653 -120
  80. package/dist/es/standards-sdk.es175.js.map +1 -1
  81. package/dist/es/standards-sdk.es176.js +111 -303
  82. package/dist/es/standards-sdk.es176.js.map +1 -1
  83. package/dist/es/standards-sdk.es177.js +297 -225
  84. package/dist/es/standards-sdk.es177.js.map +1 -1
  85. package/dist/es/standards-sdk.es178.js +239 -176
  86. package/dist/es/standards-sdk.es178.js.map +1 -1
  87. package/dist/es/standards-sdk.es179.js +178 -101
  88. package/dist/es/standards-sdk.es179.js.map +1 -1
  89. package/dist/es/standards-sdk.es18.js +4 -4
  90. package/dist/es/standards-sdk.es180.js +75 -108
  91. package/dist/es/standards-sdk.es180.js.map +1 -1
  92. package/dist/es/standards-sdk.es181.js +116 -148
  93. package/dist/es/standards-sdk.es181.js.map +1 -1
  94. package/dist/es/standards-sdk.es182.js +143 -439
  95. package/dist/es/standards-sdk.es182.js.map +1 -1
  96. package/dist/es/standards-sdk.es183.js +661 -162
  97. package/dist/es/standards-sdk.es183.js.map +1 -1
  98. package/dist/es/standards-sdk.es184.js +156 -206
  99. package/dist/es/standards-sdk.es184.js.map +1 -1
  100. package/dist/es/standards-sdk.es185.js +219 -223
  101. package/dist/es/standards-sdk.es185.js.map +1 -1
  102. package/dist/es/standards-sdk.es186.js +242 -0
  103. package/dist/es/standards-sdk.es186.js.map +1 -0
  104. package/dist/es/standards-sdk.es19.js +2 -2
  105. package/dist/es/standards-sdk.es22.js +1 -1
  106. package/dist/es/standards-sdk.es27.js +4 -4
  107. package/dist/es/standards-sdk.es35.js +2 -2
  108. package/dist/es/standards-sdk.es36.js +2 -2
  109. package/dist/es/standards-sdk.es4.js +1 -1
  110. package/dist/es/standards-sdk.es53.js +1 -1
  111. package/dist/es/standards-sdk.es56.js +1 -1
  112. package/dist/es/standards-sdk.es59.js +1 -1
  113. package/dist/es/standards-sdk.es62.js +1 -1
  114. package/dist/es/standards-sdk.es63.js +2 -2
  115. package/dist/es/standards-sdk.es64.js +1 -1
  116. package/dist/es/standards-sdk.es65.js +1 -1
  117. package/dist/es/standards-sdk.es67.js +3 -3
  118. package/dist/es/standards-sdk.es7.js +1 -1
  119. package/dist/es/standards-sdk.es71.js +1 -1
  120. package/dist/es/standards-sdk.es72.js +2 -2
  121. package/dist/es/standards-sdk.es75.js +2 -2
  122. package/dist/es/standards-sdk.es76.js +1 -1
  123. package/dist/es/standards-sdk.es78.js +1 -1
  124. package/dist/es/standards-sdk.es83.js +1 -1
  125. package/dist/es/standards-sdk.es84.js +2 -2
  126. package/dist/es/standards-sdk.es85.js +1 -1
  127. package/dist/es/standards-sdk.es88.js +1 -1
  128. package/dist/es/standards-sdk.es90.js +1 -1
  129. package/dist/es/standards-sdk.es94.js +3 -3
  130. package/dist/es/standards-sdk.es98.js +1 -1
  131. package/dist/es/standards-sdk.es99.js +1 -1
  132. package/package.json +1 -1
@@ -1,483 +1,187 @@
1
- import { guardSessionResponseSchema, guardBalanceResponseSchema, guardFeedResponseSchema, guardOverviewResponseSchema, guardTrustByHashResponseSchema, guardTrustResolveResponseSchema, guardRevocationResponseSchema, guardPolicySchema, guardInventoryResponseSchema, guardReceiptHistoryResponseSchema, guardArtifactTimelineResponseSchema, guardInventoryDiffResponseSchema, guardAbomResponseSchema, guardReceiptExportResponseSchema, guardDeviceListResponseSchema, guardAlertPreferencesSchema, guardExceptionListResponseSchema, guardWatchlistResponseSchema, guardWatchlistLookupResponseSchema, guardPainSignalListResponseSchema, guardPainSignalAggregateResponseSchema, guardReceiptSyncResponseSchema, guardTeamPolicyPackSchema, guardPreflightVerdictResponseSchema } from "./standards-sdk.es160.js";
2
- async function getGuardSession(client) {
3
- const raw = await client.requestJson("/guard/auth/session", {
4
- method: "GET"
5
- });
6
- return client.parseWithSchema(
7
- raw,
8
- guardSessionResponseSchema,
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 query = params.toString();
38
- const suffix = query ? `?${query}` : "";
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
- guardFeedResponseSchema,
45
- "guard feed response"
16
+ creditBalanceResponseSchema,
17
+ "credit balance response"
46
18
  );
47
19
  }
48
- async function getGuardOverview(client) {
49
- const raw = await client.requestJson("/guard/overview", {
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
- guardOverviewResponseSchema,
55
- "guard overview response"
26
+ creditProvidersResponseSchema,
27
+ "credit providers response"
56
28
  );
57
29
  }
58
- async function getGuardTrustByHash(client, sha256) {
59
- const normalizedHash = sha256.trim();
60
- if (!normalizedHash) {
61
- throw new Error("sha256 is required");
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
- const raw = await client.requestJson(
64
- `/guard/trust/by-hash/${encodeURIComponent(normalizedHash)}`,
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 (query.name?.trim()) {
79
- params.set("name", query.name.trim());
39
+ if (payload.hbarAmount !== void 0) {
40
+ body.hbarAmount = payload.hbarAmount;
80
41
  }
81
- if (query.version?.trim()) {
82
- params.set("version", query.version.trim());
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
- `/guard/trust/resolve${suffix}`,
87
- { method: "GET" }
88
- );
89
- return client.parseWithSchema(
90
- raw,
91
- guardTrustResolveResponseSchema,
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
- guardReceiptHistoryResponseSchema,
142
- "guard receipt history response"
55
+ hbarPurchaseIntentResponseSchema,
56
+ "hbar purchase intent response"
143
57
  );
144
58
  }
145
- async function getGuardArtifactTimeline(client, artifactId) {
146
- const normalizedArtifactId = artifactId.trim();
147
- if (!normalizedArtifactId) {
148
- throw new Error("artifactId is required");
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 raw = await client.requestJson(
151
- `/guard/history/${encodeURIComponent(normalizedArtifactId)}`,
152
- { method: "GET" }
153
- );
154
- return client.parseWithSchema(
155
- raw,
156
- guardArtifactTimelineResponseSchema,
157
- "guard artifact timeline response"
158
- );
159
- }
160
- async function exportGuardAbom(client) {
161
- const raw = await client.requestJson("/guard/abom", {
162
- method: "GET"
163
- });
164
- return client.parseWithSchema(
165
- raw,
166
- guardAbomResponseSchema,
167
- "guard abom response"
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
- const raw = await client.requestJson(
176
- `/guard/abom/${encodeURIComponent(normalizedArtifactId)}`,
177
- { method: "GET" }
178
- );
179
- return client.parseWithSchema(
180
- raw,
181
- guardAbomResponseSchema,
182
- "guard artifact abom response"
183
- );
184
- }
185
- async function exportGuardReceipts(client) {
186
- const raw = await client.requestJson("/guard/receipts/export", {
187
- method: "GET"
188
- });
189
- return client.parseWithSchema(
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
- body: payload
107
+ headers: { "content-type": "application/json" },
108
+ body
260
109
  });
261
110
  return client.parseWithSchema(
262
111
  raw,
263
- guardWatchlistLookupResponseSchema,
264
- "guard watchlist lookup response"
112
+ creditPurchaseResponseSchema,
113
+ "credit purchase response"
265
114
  );
266
115
  }
267
- async function getGuardPainSignals(client) {
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
- "/guard/signals/pain/aggregate",
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
- guardPainSignalListResponseSchema,
323
- "guard pain signals response"
123
+ x402MinimumsResponseSchema,
124
+ "x402 minimums response"
324
125
  );
325
126
  }
326
- async function submitGuardReceipts(client, payload) {
327
- const raw = await client.requestJson("/guard/receipts/submit", {
328
- method: "POST",
329
- body: payload
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
- const raw = await client.requestJson(
354
- `/guard/watchlist/${encodeURIComponent(normalizedArtifactId)}`,
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 raw = await client.requestJson(
402
- `/guard/exceptions/${encodeURIComponent(normalizedExceptionId)}`,
403
- { method: "DELETE" }
404
- );
405
- return client.parseWithSchema(
406
- raw,
407
- guardExceptionListResponseSchema,
408
- "guard exceptions response"
409
- );
410
- }
411
- async function getGuardTeamPolicyPack(client) {
412
- const raw = await client.requestJson("/guard/team/policy-pack", {
413
- method: "GET"
414
- });
415
- return client.parseWithSchema(
416
- raw,
417
- guardTeamPolicyPackSchema,
418
- "guard team policy pack response"
419
- );
420
- }
421
- async function updateGuardTeamPolicyPack(client, payload) {
422
- const raw = await client.requestJson("/guard/team/policy-pack", {
423
- method: "PUT",
424
- body: payload
425
- });
426
- return client.parseWithSchema(
427
- raw,
428
- guardTeamPolicyPackSchema,
429
- "guard team policy pack response"
430
- );
431
- }
432
- async function syncGuardReceipts(client, payload) {
433
- const raw = await client.requestJson("/guard/receipts/sync", {
434
- method: "POST",
435
- body: payload
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
- addGuardException,
445
- addGuardWatchlistItem,
446
- exportGuardAbom,
447
- exportGuardArtifactAbom,
448
- exportGuardReceipts,
449
- fetchGuardAdvisories,
450
- fetchGuardPolicy,
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