@hashgraphonline/standards-sdk 0.1.170 → 0.1.172

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 (159) hide show
  1. package/README.md +2 -2
  2. package/dist/browser/services/registry-broker/client/base-client.d.ts +3 -2
  3. package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
  4. package/dist/browser/services/registry-broker/client/search.d.ts +2 -1
  5. package/dist/browser/services/registry-broker/client/search.d.ts.map +1 -1
  6. package/dist/browser/services/registry-broker/client.d.ts +1 -0
  7. package/dist/browser/services/registry-broker/client.d.ts.map +1 -1
  8. package/dist/browser/services/registry-broker/schemas.d.ts +17723 -58
  9. package/dist/browser/services/registry-broker/schemas.d.ts.map +1 -1
  10. package/dist/browser/services/registry-broker/types.d.ts +36 -1
  11. package/dist/browser/services/registry-broker/types.d.ts.map +1 -1
  12. package/dist/browser/standards-sdk.browser.js +64 -1
  13. package/dist/browser/standards-sdk.browser.js.map +1 -1
  14. package/dist/cjs/services/registry-broker/client/base-client.d.ts +3 -2
  15. package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
  16. package/dist/cjs/services/registry-broker/client/search.d.ts +2 -1
  17. package/dist/cjs/services/registry-broker/client/search.d.ts.map +1 -1
  18. package/dist/cjs/services/registry-broker/client.d.ts +1 -0
  19. package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
  20. package/dist/cjs/services/registry-broker/schemas.d.ts +17814 -149
  21. package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
  22. package/dist/cjs/services/registry-broker/types.d.ts +36 -1
  23. package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
  24. package/dist/cjs/standards-sdk.cjs +3 -3
  25. package/dist/cjs/standards-sdk.cjs.map +1 -1
  26. package/dist/es/services/registry-broker/client/base-client.d.ts +3 -2
  27. package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
  28. package/dist/es/services/registry-broker/client/search.d.ts +2 -1
  29. package/dist/es/services/registry-broker/client/search.d.ts.map +1 -1
  30. package/dist/es/services/registry-broker/client.d.ts +1 -0
  31. package/dist/es/services/registry-broker/client.d.ts.map +1 -1
  32. package/dist/es/services/registry-broker/schemas.d.ts +17814 -149
  33. package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
  34. package/dist/es/services/registry-broker/types.d.ts +36 -1
  35. package/dist/es/services/registry-broker/types.d.ts.map +1 -1
  36. package/dist/es/standards-sdk.es.js +20 -9
  37. package/dist/es/standards-sdk.es.js.map +1 -1
  38. package/dist/es/standards-sdk.es104.js +1 -1
  39. package/dist/es/standards-sdk.es106.js +1 -1
  40. package/dist/es/standards-sdk.es108.js +1 -1
  41. package/dist/es/standards-sdk.es11.js +1 -1
  42. package/dist/es/standards-sdk.es110.js +1 -1
  43. package/dist/es/standards-sdk.es116.js +2 -2
  44. package/dist/es/standards-sdk.es12.js +1 -1
  45. package/dist/es/standards-sdk.es121.js +1 -1
  46. package/dist/es/standards-sdk.es127.js +1 -1
  47. package/dist/es/standards-sdk.es128.js +5 -5
  48. package/dist/es/standards-sdk.es138.js +1 -1
  49. package/dist/es/standards-sdk.es139.js +1 -1
  50. package/dist/es/standards-sdk.es140.js +5 -5
  51. package/dist/es/standards-sdk.es142.js +2 -2
  52. package/dist/es/standards-sdk.es143.js +1 -1
  53. package/dist/es/standards-sdk.es145.js +65 -1
  54. package/dist/es/standards-sdk.es145.js.map +1 -1
  55. package/dist/es/standards-sdk.es147.js +250 -78
  56. package/dist/es/standards-sdk.es147.js.map +1 -1
  57. package/dist/es/standards-sdk.es148.js +77 -71
  58. package/dist/es/standards-sdk.es148.js.map +1 -1
  59. package/dist/es/standards-sdk.es149.js +79 -936
  60. package/dist/es/standards-sdk.es149.js.map +1 -1
  61. package/dist/es/standards-sdk.es150.js +934 -53
  62. package/dist/es/standards-sdk.es150.js.map +1 -1
  63. package/dist/es/standards-sdk.es151.js +53 -152
  64. package/dist/es/standards-sdk.es151.js.map +1 -1
  65. package/dist/es/standards-sdk.es152.js +159 -7
  66. package/dist/es/standards-sdk.es152.js.map +1 -1
  67. package/dist/es/standards-sdk.es153.js +7 -86
  68. package/dist/es/standards-sdk.es153.js.map +1 -1
  69. package/dist/es/standards-sdk.es154.js +64 -43
  70. package/dist/es/standards-sdk.es154.js.map +1 -1
  71. package/dist/es/standards-sdk.es155.js +65 -30
  72. package/dist/es/standards-sdk.es155.js.map +1 -1
  73. package/dist/es/standards-sdk.es156.js +30 -34
  74. package/dist/es/standards-sdk.es156.js.map +1 -1
  75. package/dist/es/standards-sdk.es157.js +34 -48
  76. package/dist/es/standards-sdk.es157.js.map +1 -1
  77. package/dist/es/standards-sdk.es158.js +48 -138
  78. package/dist/es/standards-sdk.es158.js.map +1 -1
  79. package/dist/es/standards-sdk.es159.js +133 -37
  80. package/dist/es/standards-sdk.es159.js.map +1 -1
  81. package/dist/es/standards-sdk.es16.js +1 -1
  82. package/dist/es/standards-sdk.es160.js +34 -12474
  83. package/dist/es/standards-sdk.es160.js.map +1 -1
  84. package/dist/es/standards-sdk.es161.js +12479 -53
  85. package/dist/es/standards-sdk.es161.js.map +1 -1
  86. package/dist/es/standards-sdk.es162.js +48 -76
  87. package/dist/es/standards-sdk.es162.js.map +1 -1
  88. package/dist/es/standards-sdk.es163.js +69 -66
  89. package/dist/es/standards-sdk.es163.js.map +1 -1
  90. package/dist/es/standards-sdk.es164.js +61 -180
  91. package/dist/es/standards-sdk.es164.js.map +1 -1
  92. package/dist/es/standards-sdk.es165.js +197 -14
  93. package/dist/es/standards-sdk.es165.js.map +1 -1
  94. package/dist/es/standards-sdk.es166.js +15 -548
  95. package/dist/es/standards-sdk.es166.js.map +1 -1
  96. package/dist/es/standards-sdk.es167.js +66 -165
  97. package/dist/es/standards-sdk.es167.js.map +1 -1
  98. package/dist/es/standards-sdk.es168.js +535 -307
  99. package/dist/es/standards-sdk.es168.js.map +1 -1
  100. package/dist/es/standards-sdk.es169.js +120 -294
  101. package/dist/es/standards-sdk.es169.js.map +1 -1
  102. package/dist/es/standards-sdk.es170.js +191 -322
  103. package/dist/es/standards-sdk.es170.js.map +1 -1
  104. package/dist/es/standards-sdk.es171.js +294 -279
  105. package/dist/es/standards-sdk.es171.js.map +1 -1
  106. package/dist/es/standards-sdk.es172.js +440 -63
  107. package/dist/es/standards-sdk.es172.js.map +1 -1
  108. package/dist/es/standards-sdk.es173.js +323 -65
  109. package/dist/es/standards-sdk.es173.js.map +1 -1
  110. package/dist/es/standards-sdk.es174.js +61 -157
  111. package/dist/es/standards-sdk.es174.js.map +1 -1
  112. package/dist/es/standards-sdk.es175.js +152 -202
  113. package/dist/es/standards-sdk.es175.js.map +1 -1
  114. package/dist/es/standards-sdk.es176.js +219 -223
  115. package/dist/es/standards-sdk.es176.js.map +1 -1
  116. package/dist/es/standards-sdk.es177.js +227 -107
  117. package/dist/es/standards-sdk.es177.js.map +1 -1
  118. package/dist/es/standards-sdk.es178.js +98 -105
  119. package/dist/es/standards-sdk.es178.js.map +1 -1
  120. package/dist/es/standards-sdk.es179.js +105 -140
  121. package/dist/es/standards-sdk.es179.js.map +1 -1
  122. package/dist/es/standards-sdk.es18.js +4 -4
  123. package/dist/es/standards-sdk.es180.js +2 -2
  124. package/dist/es/standards-sdk.es182.js +1 -1
  125. package/dist/es/standards-sdk.es19.js +2 -2
  126. package/dist/es/standards-sdk.es22.js +1 -1
  127. package/dist/es/standards-sdk.es27.js +4 -4
  128. package/dist/es/standards-sdk.es30.js +1 -1
  129. package/dist/es/standards-sdk.es31.js +1 -1
  130. package/dist/es/standards-sdk.es35.js +2 -2
  131. package/dist/es/standards-sdk.es36.js +3 -3
  132. package/dist/es/standards-sdk.es37.js +1 -1
  133. package/dist/es/standards-sdk.es4.js +1 -1
  134. package/dist/es/standards-sdk.es53.js +1 -1
  135. package/dist/es/standards-sdk.es56.js +1 -1
  136. package/dist/es/standards-sdk.es59.js +1 -1
  137. package/dist/es/standards-sdk.es60.js +1 -1
  138. package/dist/es/standards-sdk.es62.js +1 -1
  139. package/dist/es/standards-sdk.es63.js +2 -2
  140. package/dist/es/standards-sdk.es64.js +1 -1
  141. package/dist/es/standards-sdk.es65.js +1 -1
  142. package/dist/es/standards-sdk.es66.js +1 -1
  143. package/dist/es/standards-sdk.es67.js +2 -2
  144. package/dist/es/standards-sdk.es69.js +1 -1
  145. package/dist/es/standards-sdk.es7.js +1 -1
  146. package/dist/es/standards-sdk.es71.js +1 -1
  147. package/dist/es/standards-sdk.es72.js +2 -2
  148. package/dist/es/standards-sdk.es75.js +3 -3
  149. package/dist/es/standards-sdk.es76.js +1 -1
  150. package/dist/es/standards-sdk.es78.js +1 -1
  151. package/dist/es/standards-sdk.es83.js +1 -1
  152. package/dist/es/standards-sdk.es84.js +1 -1
  153. package/dist/es/standards-sdk.es85.js +1 -1
  154. package/dist/es/standards-sdk.es88.js +1 -1
  155. package/dist/es/standards-sdk.es90.js +1 -1
  156. package/dist/es/standards-sdk.es94.js +3 -3
  157. package/dist/es/standards-sdk.es98.js +1 -1
  158. package/dist/es/standards-sdk.es99.js +1 -1
  159. package/package.json +1 -1
@@ -1,941 +1,84 @@
1
- import { Buffer } from "buffer";
2
- import { randomBytes, createHash, createCipheriv, createDecipheriv } from "crypto";
3
- import { secp256k1 } from "@noble/curves/secp256k1.js";
4
- import { ZodError } from "zod";
5
- import { agentFeedbackResponseSchema, agentFeedbackIndexResponseSchema, agentFeedbackEntriesIndexResponseSchema, agentFeedbackEligibilityResponseSchema, agentFeedbackSubmissionResponseSchema, registerAgentResponseSchema } from "./standards-sdk.es145.js";
6
- import { fetchHistorySnapshot, attachDecryptedHistory, registerConversationContextForEncryption, resolveDecryptionContext, decryptHistoryEntryFromContext } from "./standards-sdk.es181.js";
7
- import { createChatApi, createSession, startChat, startConversation, acceptConversation, compactHistory, fetchEncryptionStatus, postEncryptionHandshake, sendMessage, endSession, createPlaintextConversationHandle } from "./standards-sdk.es182.js";
8
- import { EncryptedChatManager } from "./standards-sdk.es183.js";
9
- import { generateEncryptionKeyPair, bootstrapEncryptionOptions, createEncryptionApi } from "./standards-sdk.es174.js";
10
- import { adapters, adaptersDetailed, adapterRegistryCategories, adapterRegistryAdapters, createAdapterRegistryCategory, submitAdapterRegistryAdapter, adapterRegistrySubmissionStatus } from "./standards-sdk.es177.js";
11
- import { resolveUaid, getRegistrationQuote, updateAgent, getRegistrationProgress, waitForRegistrationCompletion, validateUaid, getUaidConnectionStatus, closeUaidConnection, dashboardStats } from "./standards-sdk.es179.js";
12
- import { getRegisterStatus, registerOwnedMoltbookAgent, getVerificationStatus, createVerificationChallenge, getVerificationChallenge, verifyVerificationChallenge, getVerificationOwnership, verifySenderOwnership, verifyUaidDnsTxt, getVerificationDnsStatus } from "./standards-sdk.es184.js";
13
- import { purchaseCreditsWithHbar, getX402Minimums, purchaseCreditsWithX402, buyCreditsWithX402 } from "./standards-sdk.es178.js";
14
- import { createLedgerChallenge, verifyLedgerChallenge, authenticateWithLedger, authenticateWithLedgerCredentials } from "./standards-sdk.es180.js";
15
- import { search, stats, registries, getAdditionalRegistries, popularSearches, listProtocols, detectProtocol, registrySearchByNamespace, vectorSearch, searchStatus, websocketStats, metricsSummary, facets } from "./standards-sdk.es175.js";
16
- import { skillsConfig, listSkills, getSkillSecurityBreakdown, getSkillsCatalog, listSkillVersions, listMySkills, getMySkillsList, quoteSkillPublish, publishSkill, getSkillPublishJob, getSkillOwnership, getRecommendedSkillVersion, setRecommendedSkillVersion, getSkillDeprecations, setSkillDeprecation, getSkillBadge, listSkillTags, listSkillCategories, resolveSkillMarkdown, resolveSkillManifest, getSkillVoteStatus, setSkillVote, requestSkillVerification, getSkillVerificationStatus, createSkillDomainProofChallenge, verifySkillDomainProof } from "./standards-sdk.es166.js";
17
- import { DEFAULT_BASE_URL, normaliseBaseUrl, normaliseHeaderName, isBrowserRuntime, DEFAULT_USER_AGENT, JSON_CONTENT_TYPE, serialiseAgentRegistrationRequest, MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS, createAbortError, isJsonObject, DEFAULT_HISTORY_TOP_UP_HBAR } from "./standards-sdk.es176.js";
18
- import { RegistryBrokerError, RegistryBrokerParseError } from "./standards-sdk.es146.js";
19
- class RegistryBrokerClient {
20
- constructor(options = {}) {
21
- this.encryptionBootstrapPromise = null;
22
- this.chatApi = null;
23
- this.encryptedChatManager = null;
24
- this.encryptionApi = null;
25
- this.conversationContexts = /* @__PURE__ */ new Map();
26
- const {
27
- baseUrl = DEFAULT_BASE_URL,
28
- fetchImplementation,
29
- defaultHeaders,
30
- apiKey,
31
- accountId,
32
- ledgerApiKey,
33
- registrationAutoTopUp,
34
- historyAutoTopUp,
35
- encryption
36
- } = options;
37
- this.baseUrl = normaliseBaseUrl(baseUrl);
38
- const resolvedFetch = fetchImplementation ?? (typeof globalThis.fetch === "function" ? globalThis.fetch : null);
39
- if (!resolvedFetch) {
40
- throw new Error(
41
- "A fetch implementation is required for RegistryBrokerClient"
42
- );
43
- }
44
- this.fetchImpl = resolvedFetch;
45
- this.defaultHeaders = {
46
- ...defaultHeaders ?? {}
47
- };
48
- Object.entries(this.defaultHeaders).forEach(([key, value]) => {
49
- const headerName = normaliseHeaderName(key);
50
- if (headerName !== key) {
51
- delete this.defaultHeaders[key];
52
- this.defaultHeaders[headerName] = value;
53
- }
54
- });
55
- const existingLedgerHeader = this.defaultHeaders["x-ledger-api-key"]?.trim();
56
- if (!this.defaultHeaders["x-api-key"] && existingLedgerHeader) {
57
- this.defaultHeaders["x-api-key"] = existingLedgerHeader;
58
- }
59
- if (apiKey) {
60
- this.defaultHeaders["x-api-key"] = apiKey;
61
- }
62
- if (typeof accountId === "string" && accountId.trim().length > 0) {
63
- this.defaultHeaders["x-account-id"] = accountId.trim();
64
- }
65
- if (ledgerApiKey) {
66
- if (!this.defaultHeaders["x-api-key"]) {
67
- this.defaultHeaders["x-api-key"] = ledgerApiKey;
68
- }
69
- }
70
- this.registrationAutoTopUp = registrationAutoTopUp;
71
- this.historyAutoTopUp = historyAutoTopUp;
72
- this.encryptionOptions = encryption;
73
- if (this.encryptionOptions) {
74
- this.encryptionBootstrapPromise = this.initializeEncryptionBootstrap(
75
- this.encryptionOptions
76
- );
77
- }
78
- }
79
- static async initializeAgent(options) {
80
- const { uaid, ensureEncryptionKey = true, ...clientOptions } = options;
81
- const client = new RegistryBrokerClient(clientOptions);
82
- let encryption = null;
83
- if (ensureEncryptionKey) {
84
- const ensureOptions = typeof ensureEncryptionKey === "object" ? ensureEncryptionKey : { generateIfMissing: true };
85
- encryption = await client.encryption.ensureAgentKey({
86
- uaid,
87
- ...ensureOptions
88
- });
89
- }
90
- return { client, encryption };
91
- }
92
- get chat() {
93
- if (this.chatApi) {
94
- return this.chatApi;
95
- }
96
- const api = createChatApi(this, this.getEncryptedChatManager());
97
- this.chatApi = api;
98
- return api;
99
- }
100
- get encryption() {
101
- if (this.encryptionApi) {
102
- return this.encryptionApi;
103
- }
104
- const api = createEncryptionApi(this);
105
- this.encryptionApi = api;
106
- return api;
107
- }
108
- setApiKey(apiKey) {
109
- this.setDefaultHeader("x-api-key", apiKey);
110
- }
111
- setLedgerApiKey(apiKey) {
112
- this.setDefaultHeader("x-api-key", apiKey);
113
- delete this.defaultHeaders["x-ledger-api-key"];
114
- }
115
- setDefaultHeader(name, value) {
116
- if (!name || name.trim().length === 0) {
117
- return;
118
- }
119
- const headerName = normaliseHeaderName(name);
120
- if (!value || value.trim().length === 0) {
121
- delete this.defaultHeaders[headerName];
122
- return;
123
- }
124
- this.defaultHeaders[headerName] = value.trim();
125
- }
126
- getDefaultHeaders() {
127
- return { ...this.defaultHeaders };
128
- }
129
- async encryptionReady() {
130
- if (!this.encryptionBootstrapPromise) {
131
- return;
132
- }
133
- await this.encryptionBootstrapPromise;
134
- }
135
- buildUrl(path) {
136
- const normalisedPath = path.startsWith("/") ? path : `/${path}`;
137
- return `${this.baseUrl}${normalisedPath}`;
138
- }
139
- async request(path, config) {
140
- const headers = new Headers();
141
- Object.entries(this.defaultHeaders).forEach(([key, value]) => {
142
- headers.set(key, value);
143
- });
144
- if (config.headers) {
145
- Object.entries(config.headers).forEach(([key, value]) => {
146
- headers.set(key, value);
147
- });
148
- }
149
- if (!headers.has("accept")) {
150
- headers.set("accept", "application/json");
151
- }
152
- if (!headers.has("user-agent") && !isBrowserRuntime()) {
153
- headers.set("user-agent", DEFAULT_USER_AGENT);
154
- }
155
- const init = {
156
- method: config.method ?? "GET",
157
- headers
158
- };
159
- if (config.body !== void 0) {
160
- init.body = JSON.stringify(config.body);
161
- if (!headers.has("content-type")) {
162
- headers.set("content-type", "application/json");
163
- }
164
- }
165
- const response = await this.fetchImpl(this.buildUrl(path), init);
166
- if (response.ok) {
167
- return response;
168
- }
169
- const errorBody = await this.extractErrorBody(response);
170
- throw new RegistryBrokerError("Registry broker request failed", {
171
- status: response.status,
172
- statusText: response.statusText,
173
- body: errorBody
174
- });
175
- }
176
- async requestJson(path, config) {
177
- const response = await this.request(path, config);
178
- const contentType = response.headers?.get("content-type") ?? "";
179
- if (!JSON_CONTENT_TYPE.test(contentType)) {
180
- const body = await response.text();
181
- throw new RegistryBrokerParseError(
182
- "Expected JSON response from registry broker",
183
- body
184
- );
185
- }
186
- return await response.json();
187
- }
188
- async getAgentFeedback(uaid, options = {}) {
189
- const normalized = uaid.trim();
190
- if (!normalized) {
191
- throw new Error("uaid is required");
192
- }
193
- const query = options.includeRevoked === true ? "?includeRevoked=true" : "";
194
- const raw = await this.requestJson(
195
- `/agents/${encodeURIComponent(normalized)}/feedback${query}`,
196
- { method: "GET" }
197
- );
198
- return this.parseWithSchema(
199
- raw,
200
- agentFeedbackResponseSchema,
201
- "agent feedback response"
202
- );
203
- }
204
- async listAgentFeedbackIndex(options = {}) {
205
- const params = new URLSearchParams();
206
- if (typeof options.page === "number" && Number.isFinite(options.page)) {
207
- params.set("page", String(Math.trunc(options.page)));
208
- }
209
- if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
210
- params.set("limit", String(Math.trunc(options.limit)));
211
- }
212
- if (options.registries?.length) {
213
- params.set("registry", options.registries.join(","));
214
- }
215
- const suffix = params.size > 0 ? `?${params.toString()}` : "";
216
- const raw = await this.requestJson(`/agents/feedback${suffix}`, {
217
- method: "GET"
218
- });
219
- return this.parseWithSchema(
220
- raw,
221
- agentFeedbackIndexResponseSchema,
222
- "agent feedback index response"
223
- );
224
- }
225
- async listAgentFeedbackEntriesIndex(options = {}) {
226
- const params = new URLSearchParams();
227
- if (typeof options.page === "number" && Number.isFinite(options.page)) {
228
- params.set("page", String(Math.trunc(options.page)));
229
- }
230
- if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
231
- params.set("limit", String(Math.trunc(options.limit)));
232
- }
233
- if (options.registries?.length) {
234
- params.set("registry", options.registries.join(","));
235
- }
236
- const suffix = params.size > 0 ? `?${params.toString()}` : "";
237
- const raw = await this.requestJson(
238
- `/agents/feedback/entries${suffix}`,
239
- { method: "GET" }
240
- );
241
- return this.parseWithSchema(
242
- raw,
243
- agentFeedbackEntriesIndexResponseSchema,
244
- "agent feedback entries index response"
245
- );
246
- }
247
- async checkAgentFeedbackEligibility(uaid, payload) {
248
- const normalized = uaid.trim();
249
- if (!normalized) {
250
- throw new Error("uaid is required");
251
- }
252
- const raw = await this.requestJson(
253
- `/agents/${encodeURIComponent(normalized)}/feedback/eligibility`,
254
- {
255
- method: "POST",
256
- body: payload,
257
- headers: { "content-type": "application/json" }
258
- }
259
- );
260
- return this.parseWithSchema(
261
- raw,
262
- agentFeedbackEligibilityResponseSchema,
263
- "agent feedback eligibility response"
264
- );
265
- }
266
- async submitAgentFeedback(uaid, payload) {
267
- const normalized = uaid.trim();
268
- if (!normalized) {
269
- throw new Error("uaid is required");
270
- }
271
- const raw = await this.requestJson(
272
- `/agents/${encodeURIComponent(normalized)}/feedback`,
273
- {
274
- method: "POST",
275
- body: payload,
276
- headers: { "content-type": "application/json" }
277
- }
278
- );
279
- return this.parseWithSchema(
280
- raw,
281
- agentFeedbackSubmissionResponseSchema,
282
- "agent feedback submission response"
283
- );
284
- }
285
- async search(params = {}) {
286
- return search(this, params);
287
- }
288
- async searchErc8004ByAgentId(params) {
289
- const chainId = Math.floor(params.chainId);
290
- if (!Number.isFinite(chainId) || chainId <= 0) {
291
- throw new Error("chainId must be a positive integer");
292
- }
293
- const rawAgentId = typeof params.agentId === "bigint" ? params.agentId.toString() : String(params.agentId);
294
- const agentId = rawAgentId.trim();
295
- if (!agentId) {
296
- throw new Error("agentId is required");
297
- }
298
- const nativeId = `${chainId}:${agentId}`;
299
- return search(this, {
300
- registries: ["erc-8004"],
301
- limit: params.limit ?? 1,
302
- ...typeof params.page === "number" ? { page: params.page } : {},
303
- ...typeof params.sortBy === "string" ? { sortBy: params.sortBy } : {},
304
- ...typeof params.sortOrder === "string" ? { sortOrder: params.sortOrder } : {},
305
- metadata: {
306
- nativeId: [nativeId],
307
- networkKey: [`eip155:${chainId}`]
308
- }
309
- });
310
- }
311
- async stats() {
312
- return stats(this);
313
- }
314
- async registries() {
315
- return registries(this);
316
- }
317
- async getAdditionalRegistries() {
318
- return getAdditionalRegistries(this);
319
- }
320
- async popularSearches() {
321
- return popularSearches(this);
322
- }
323
- async listProtocols() {
324
- return listProtocols(this);
325
- }
326
- async detectProtocol(message) {
327
- return detectProtocol(this, message);
328
- }
329
- async registrySearchByNamespace(registry, query) {
330
- return registrySearchByNamespace(this, registry, query);
331
- }
332
- async vectorSearch(request) {
333
- return vectorSearch(this, request);
334
- }
335
- async searchStatus() {
336
- return searchStatus(this);
337
- }
338
- async websocketStats() {
339
- return websocketStats(this);
340
- }
341
- async metricsSummary() {
342
- return metricsSummary(this);
343
- }
344
- async facets(adapter) {
345
- return facets(this, adapter);
346
- }
347
- async adapters() {
348
- return adapters(this);
349
- }
350
- async skillsConfig() {
351
- return skillsConfig(this);
352
- }
353
- async listSkills(options) {
354
- return listSkills(this, options);
355
- }
356
- async getSkillSecurityBreakdown(params) {
357
- return getSkillSecurityBreakdown(this, params);
358
- }
359
- async getSkillsCatalog(options) {
360
- return getSkillsCatalog(this, options);
361
- }
362
- async listSkillVersions(params) {
363
- return listSkillVersions(this, params);
364
- }
365
- async listMySkills(params) {
366
- return listMySkills(this, params);
367
- }
368
- async getMySkillsList(params) {
369
- return getMySkillsList(this, params);
370
- }
371
- async quoteSkillPublish(payload) {
372
- return quoteSkillPublish(this, payload);
373
- }
374
- async publishSkill(payload) {
375
- return publishSkill(this, payload);
376
- }
377
- async getSkillPublishJob(jobId, params) {
378
- return getSkillPublishJob(this, jobId, params);
379
- }
380
- async getSkillOwnership(params) {
381
- return getSkillOwnership(this, params);
382
- }
383
- async getRecommendedSkillVersion(params) {
384
- return getRecommendedSkillVersion(this, params);
385
- }
386
- async setRecommendedSkillVersion(payload) {
387
- return setRecommendedSkillVersion(this, payload);
388
- }
389
- async getSkillDeprecations(params) {
390
- return getSkillDeprecations(this, params);
391
- }
392
- async setSkillDeprecation(payload) {
393
- return setSkillDeprecation(this, payload);
394
- }
395
- async getSkillBadge(params) {
396
- return getSkillBadge(this, params);
397
- }
398
- async listSkillTags() {
399
- return listSkillTags(this);
400
- }
401
- async listSkillCategories() {
402
- return listSkillCategories(this);
403
- }
404
- async resolveSkillMarkdown(skillRef) {
405
- return resolveSkillMarkdown(this, skillRef);
406
- }
407
- async resolveSkillManifest(skillRef) {
408
- return resolveSkillManifest(this, skillRef);
409
- }
410
- async getSkillVoteStatus(params) {
411
- return getSkillVoteStatus(this, params);
412
- }
413
- async setSkillVote(payload) {
414
- return setSkillVote(this, payload);
415
- }
416
- async requestSkillVerification(payload) {
417
- return requestSkillVerification(this, payload);
418
- }
419
- async getSkillVerificationStatus(params) {
420
- return getSkillVerificationStatus(this, params);
421
- }
422
- async createSkillDomainProofChallenge(payload) {
423
- return createSkillDomainProofChallenge(this, payload);
424
- }
425
- async verifySkillDomainProof(payload) {
426
- return verifySkillDomainProof(this, payload);
427
- }
428
- async adaptersDetailed() {
429
- return adaptersDetailed(this);
430
- }
431
- async adapterRegistryCategories() {
432
- return adapterRegistryCategories(this);
433
- }
434
- async adapterRegistryAdapters(filters) {
435
- return adapterRegistryAdapters(this, filters);
436
- }
437
- async createAdapterRegistryCategory(payload) {
438
- return createAdapterRegistryCategory(this, payload);
439
- }
440
- async submitAdapterRegistryAdapter(payload) {
441
- return submitAdapterRegistryAdapter(this, payload);
442
- }
443
- async adapterRegistrySubmissionStatus(submissionId) {
444
- return adapterRegistrySubmissionStatus(this, submissionId);
445
- }
446
- async resolveUaid(uaid) {
447
- return resolveUaid(this, uaid);
448
- }
449
- async performRegisterAgent(payload) {
450
- const raw = await this.requestJson("/register", {
451
- method: "POST",
452
- body: serialiseAgentRegistrationRequest(payload),
453
- headers: { "content-type": "application/json" }
454
- });
455
- return this.parseWithSchema(
456
- raw,
457
- registerAgentResponseSchema,
458
- "register agent response"
459
- );
460
- }
461
- calculateHbarAmount(creditsToPurchase, creditsPerHbar) {
462
- if (creditsPerHbar <= 0) {
463
- throw new Error("creditsPerHbar must be positive");
464
- }
465
- if (creditsToPurchase <= 0) {
466
- throw new Error("creditsToPurchase must be positive");
467
- }
468
- const rawHbar = creditsToPurchase / creditsPerHbar;
469
- const tinybars = Math.ceil(rawHbar * 1e8);
470
- return tinybars / 1e8;
471
- }
472
- resolveCreditsToPurchase(shortfallCredits) {
473
- if (!Number.isFinite(shortfallCredits) || shortfallCredits <= 0) {
474
- return 0;
475
- }
476
- return Math.max(
477
- Math.ceil(shortfallCredits),
478
- MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS
479
- );
480
- }
481
- async ensureCreditsForRegistration(payload, autoTopUp) {
482
- const details = autoTopUp ?? null;
483
- if (!details) {
484
- return;
485
- }
486
- if (!details.accountId || !details.accountId.trim()) {
487
- throw new Error("autoTopUp.accountId is required");
488
- }
489
- if (!details.privateKey || !details.privateKey.trim()) {
490
- throw new Error("autoTopUp.privateKey is required");
491
- }
492
- for (let attempt = 0; attempt < 3; attempt += 1) {
493
- const quote = await this.getRegistrationQuote(payload);
494
- const shortfall = quote.shortfallCredits ?? 0;
495
- if (shortfall <= 0) {
496
- return;
497
- }
498
- const creditsToPurchase = this.resolveCreditsToPurchase(shortfall);
499
- if (creditsToPurchase <= 0) {
500
- return;
501
- }
502
- const creditsPerHbar = quote.creditsPerHbar ?? null;
503
- if (!creditsPerHbar || creditsPerHbar <= 0) {
504
- throw new Error("Unable to determine credits per HBAR for auto top-up");
505
- }
506
- const hbarAmount = this.calculateHbarAmount(
507
- creditsToPurchase,
508
- creditsPerHbar
509
- );
510
- await this.purchaseCreditsWithHbar({
511
- accountId: details.accountId.trim(),
512
- privateKey: details.privateKey.trim(),
513
- hbarAmount,
514
- memo: details.memo ?? "Registry Broker auto top-up",
515
- metadata: {
516
- shortfallCredits: shortfall,
517
- requiredCredits: quote.requiredCredits,
518
- purchasedCredits: creditsToPurchase
519
- }
520
- });
521
- }
522
- const finalQuote = await this.getRegistrationQuote(payload);
523
- if ((finalQuote.shortfallCredits ?? 0) > 0) {
524
- throw new Error("Unable to purchase sufficient credits for registration");
525
- }
526
- }
527
- async registerAgent(payload, options) {
528
- const autoTopUp = options?.autoTopUp ?? this.registrationAutoTopUp;
529
- if (!autoTopUp) {
530
- return this.performRegisterAgent(payload);
531
- }
532
- await this.ensureCreditsForRegistration(payload, autoTopUp);
533
- let retried = false;
534
- while (true) {
535
- try {
536
- return await this.performRegisterAgent(payload);
537
- } catch (error) {
538
- const shortfall = this.extractInsufficientCreditsDetails(error);
539
- if (shortfall && !retried) {
540
- await this.ensureCreditsForRegistration(payload, autoTopUp);
541
- retried = true;
542
- continue;
543
- }
544
- throw error;
545
- }
546
- }
547
- }
548
- async getRegistrationQuote(payload) {
549
- return getRegistrationQuote(this, payload);
550
- }
551
- async updateAgent(uaid, payload) {
552
- return updateAgent(this, uaid, payload);
553
- }
554
- async getRegisterStatus(uaid) {
555
- return getRegisterStatus(this, uaid);
556
- }
557
- async registerOwnedMoltbookAgent(uaid, payload) {
558
- return registerOwnedMoltbookAgent(this, uaid, payload);
559
- }
560
- async getRegistrationProgress(attemptId) {
561
- return getRegistrationProgress(this, attemptId);
562
- }
563
- async waitForRegistrationCompletion(attemptId, options) {
564
- return waitForRegistrationCompletion(this, attemptId, options);
565
- }
566
- async validateUaid(uaid) {
567
- return validateUaid(this, uaid);
568
- }
569
- async getUaidConnectionStatus(uaid) {
570
- return getUaidConnectionStatus(this, uaid);
571
- }
572
- async closeUaidConnection(uaid) {
573
- return closeUaidConnection(this, uaid);
574
- }
575
- async dashboardStats() {
576
- return dashboardStats(this);
577
- }
578
- async purchaseCreditsWithHbar(params) {
579
- return purchaseCreditsWithHbar(this, params);
580
- }
581
- async getX402Minimums() {
582
- return getX402Minimums(this);
583
- }
584
- async purchaseCreditsWithX402(params) {
585
- return purchaseCreditsWithX402(this, params);
586
- }
587
- async buyCreditsWithX402(params) {
588
- return buyCreditsWithX402(this, params);
589
- }
590
- async generateEncryptionKeyPair(options = {}) {
591
- return generateEncryptionKeyPair(this, options);
592
- }
593
- async createLedgerChallenge(payload) {
594
- return createLedgerChallenge(this, payload);
595
- }
596
- async verifyLedgerChallenge(payload) {
597
- return verifyLedgerChallenge(this, payload);
598
- }
599
- async authenticateWithLedger(options) {
600
- return authenticateWithLedger(this, options);
601
- }
602
- async authenticateWithLedgerCredentials(options) {
603
- return authenticateWithLedgerCredentials(this, options);
604
- }
605
- async getVerificationStatus(uaid) {
606
- return getVerificationStatus(this, uaid);
607
- }
608
- async createVerificationChallenge(uaid) {
609
- return createVerificationChallenge(this, uaid);
610
- }
611
- async getVerificationChallenge(challengeId) {
612
- return getVerificationChallenge(this, challengeId);
613
- }
614
- async verifyVerificationChallenge(params) {
615
- return verifyVerificationChallenge(this, params);
616
- }
617
- async getVerificationOwnership(uaid) {
618
- return getVerificationOwnership(this, uaid);
619
- }
620
- async verifySenderOwnership(uaid) {
621
- return verifySenderOwnership(this, uaid);
622
- }
623
- async verifyUaidDnsTxt(payload) {
624
- return verifyUaidDnsTxt(this, payload);
625
- }
626
- async getVerificationDnsStatus(uaid, query) {
627
- return getVerificationDnsStatus(this, uaid, query);
628
- }
629
- async fetchHistorySnapshot(sessionId, options) {
630
- return fetchHistorySnapshot(
631
- this.conversationContexts,
632
- this,
633
- sessionId,
634
- options
635
- );
636
- }
637
- attachDecryptedHistory(sessionId, snapshot, options) {
638
- return attachDecryptedHistory(
639
- this.conversationContexts,
640
- this,
641
- sessionId,
642
- snapshot,
643
- options
644
- );
645
- }
646
- registerConversationContextForEncryption(context) {
647
- registerConversationContextForEncryption(
648
- this.conversationContexts,
649
- context
650
- );
651
- }
652
- resolveDecryptionContext(sessionId, options) {
653
- return resolveDecryptionContext(
654
- this.conversationContexts,
655
- this,
656
- sessionId,
657
- options
658
- );
659
- }
660
- decryptHistoryEntryFromContext(_sessionId, entry, context) {
661
- return decryptHistoryEntryFromContext(this, entry, context);
662
- }
663
- async createSession(payload, allowHistoryAutoTopUp = true) {
664
- return createSession(this, payload, allowHistoryAutoTopUp);
665
- }
666
- async startChat(options) {
667
- return startChat(this, this.getEncryptedChatManager(), options);
668
- }
669
- async startConversation(options) {
670
- return startConversation(this, this.getEncryptedChatManager(), options);
671
- }
672
- async acceptConversation(options) {
673
- return acceptConversation(
674
- this,
675
- this.getEncryptedChatManager(),
676
- options
677
- );
678
- }
679
- compactHistory(payload) {
680
- return compactHistory(this, payload);
681
- }
682
- fetchEncryptionStatus(sessionId) {
683
- return fetchEncryptionStatus(this, sessionId);
684
- }
685
- postEncryptionHandshake(sessionId, payload) {
686
- return postEncryptionHandshake(this, sessionId, payload);
687
- }
688
- sendMessage(payload) {
689
- return sendMessage(this, payload);
690
- }
691
- endSession(sessionId) {
692
- return endSession(this, sessionId);
693
- }
694
- createPlaintextConversationHandle(sessionId, summary, defaultAuth, context) {
695
- return createPlaintextConversationHandle(
696
- this,
697
- sessionId,
698
- summary,
699
- defaultAuth,
700
- context
701
- );
702
- }
703
- getEncryptedChatManager() {
704
- if (this.encryptedChatManager) {
705
- return this.encryptedChatManager;
706
- }
707
- const manager = new EncryptedChatManager(this);
708
- this.encryptedChatManager = manager;
709
- return manager;
710
- }
711
- async extractErrorBody(response) {
712
- const contentType = response.headers?.get("content-type") ?? "";
713
- if (JSON_CONTENT_TYPE.test(contentType)) {
714
- try {
715
- return await response.json();
716
- } catch (error) {
717
- return { parseError: String(error) };
718
- }
719
- }
720
- try {
721
- return await response.text();
722
- } catch (error) {
723
- return { parseError: String(error) };
724
- }
725
- }
726
- parseWithSchema(value, schema, context) {
727
- try {
728
- return schema.parse(value);
729
- } catch (error) {
730
- throw new RegistryBrokerParseError(
731
- `Failed to parse ${context}`,
732
- error instanceof ZodError || error instanceof Error ? error : String(error),
733
- value
734
- );
735
- }
736
- }
737
- async delay(ms, signal) {
738
- if (ms <= 0) {
739
- if (signal?.aborted) {
740
- throw createAbortError();
741
- }
742
- return;
743
- }
744
- await new Promise((resolve, reject) => {
745
- const timer = setTimeout(() => {
746
- if (signal) {
747
- signal.removeEventListener("abort", onAbort);
748
- }
749
- resolve();
750
- }, ms);
751
- const onAbort = () => {
752
- clearTimeout(timer);
753
- signal?.removeEventListener("abort", onAbort);
754
- reject(createAbortError());
755
- };
756
- if (signal) {
757
- if (signal.aborted) {
758
- clearTimeout(timer);
759
- reject(createAbortError());
760
- return;
761
- }
762
- signal.addEventListener("abort", onAbort, { once: true });
763
- }
764
- });
765
- }
766
- assertNodeRuntime(feature) {
767
- if (typeof process === "undefined" || !process.versions?.node) {
768
- throw new Error(`${feature} is only available in Node.js environments`);
769
- }
770
- }
771
- createEphemeralKeyPair() {
772
- this.assertNodeRuntime("generateEphemeralKeyPair");
773
- const privateKeyBytes = randomBytes(32);
774
- const publicKey = secp256k1.getPublicKey(privateKeyBytes, true);
775
- return {
776
- privateKey: Buffer.from(privateKeyBytes).toString("hex"),
777
- publicKey: Buffer.from(publicKey).toString("hex")
778
- };
779
- }
780
- deriveSharedSecret(options) {
781
- this.assertNodeRuntime("deriveSharedSecret");
782
- const privateKey = this.hexToBuffer(options.privateKey);
783
- const peerPublicKey = this.hexToBuffer(options.peerPublicKey);
784
- const shared = secp256k1.getSharedSecret(privateKey, peerPublicKey, true);
785
- return createHash("sha256").update(Buffer.from(shared)).digest();
786
- }
787
- buildCipherEnvelope(options) {
788
- this.assertNodeRuntime("encryptCipherEnvelope");
789
- const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
790
- const iv = randomBytes(12);
791
- const cipher = createCipheriv("aes-256-gcm", sharedSecret, iv);
792
- const aadSource = options.associatedData ?? options.sessionId;
793
- const associatedDataEncoded = aadSource ? Buffer.from(aadSource, "utf8").toString("base64") : void 0;
794
- if (aadSource) {
795
- cipher.setAAD(Buffer.from(aadSource, "utf8"));
796
- }
797
- const ciphertext = Buffer.concat([
798
- cipher.update(Buffer.from(options.plaintext, "utf8")),
799
- cipher.final()
800
- ]);
801
- const tag = cipher.getAuthTag();
802
- const payload = Buffer.concat([ciphertext, tag]);
803
- return {
804
- algorithm: "aes-256-gcm",
805
- ciphertext: payload.toString("base64"),
806
- nonce: iv.toString("base64"),
807
- associatedData: associatedDataEncoded,
808
- keyLocator: {
809
- sessionId: options.sessionId,
810
- revision: options.revision ?? 1
811
- },
812
- recipients: options.recipients.map((recipient) => ({
813
- ...recipient,
814
- encryptedShare: ""
815
- }))
816
- };
817
- }
818
- openCipherEnvelope(options) {
819
- this.assertNodeRuntime("decryptCipherEnvelope");
820
- const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
821
- const payload = Buffer.from(options.envelope.ciphertext, "base64");
822
- const nonce = Buffer.from(options.envelope.nonce, "base64");
823
- const ciphertext = payload.slice(0, payload.length - 16);
824
- const tag = payload.slice(payload.length - 16);
825
- const decipher = createDecipheriv("aes-256-gcm", sharedSecret, nonce);
826
- if (options.envelope.associatedData) {
827
- decipher.setAAD(Buffer.from(options.envelope.associatedData, "base64"));
828
- }
829
- decipher.setAuthTag(tag);
830
- const plaintext = Buffer.concat([
831
- decipher.update(ciphertext),
832
- decipher.final()
833
- ]);
834
- return plaintext.toString(options.encoding ?? "utf8");
835
- }
836
- normalizeSharedSecret(input) {
837
- if (Buffer.isBuffer(input)) {
838
- return Buffer.from(input);
839
- }
840
- if (input instanceof Uint8Array) {
841
- return Buffer.from(input);
842
- }
843
- if (typeof input === "string") {
844
- return this.bufferFromString(input);
845
- }
846
- throw new Error("Unsupported shared secret input");
847
- }
848
- bufferFromString(value) {
849
- const trimmed = value.trim();
850
- if (!trimmed) {
851
- throw new Error("sharedSecret string cannot be empty");
852
- }
853
- const normalized = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed;
854
- if (/^[0-9a-fA-F]+$/.test(normalized) && normalized.length % 2 === 0) {
855
- return Buffer.from(normalized, "hex");
856
- }
857
- return Buffer.from(trimmed, "base64");
858
- }
859
- hexToBuffer(value) {
860
- const normalized = value.startsWith("0x") ? value.slice(2) : value;
861
- if (!/^[0-9a-fA-F]+$/.test(normalized) || normalized.length % 2 !== 0) {
862
- throw new Error("Expected hex-encoded value");
863
- }
864
- return Buffer.from(normalized, "hex");
865
- }
866
- extractInsufficientCreditsDetails(error) {
867
- if (!(error instanceof RegistryBrokerError) || error.status !== 402) {
868
- return null;
869
- }
870
- const body = error.body;
871
- if (!body || typeof body !== "object" || Array.isArray(body)) {
872
- return null;
873
- }
874
- const maybeShortfall = body["shortfallCredits"];
875
- if (typeof maybeShortfall !== "number" || maybeShortfall <= 0) {
876
- return null;
877
- }
878
- return { shortfallCredits: maybeShortfall };
879
- }
880
- extractErrorMessage(body) {
881
- if (typeof body === "string") {
882
- return body;
883
- }
884
- if (isJsonObject(body) && typeof body.error === "string") {
885
- return body.error;
886
- }
887
- if (isJsonObject(body) && typeof body.message === "string") {
888
- return body.message;
889
- }
890
- return void 0;
891
- }
892
- shouldAutoTopUpHistory(payload, error) {
893
- if (!this.historyAutoTopUp || payload.historyTtlSeconds === void 0) {
894
- return false;
895
- }
896
- if (!(error instanceof RegistryBrokerError)) {
897
- return false;
898
- }
899
- if (error.status !== 402) {
900
- return false;
901
- }
902
- const message = this.extractErrorMessage(error.body);
903
- if (!message) {
904
- return true;
905
- }
906
- const normalised = message.toLowerCase();
907
- return normalised.includes("history") || normalised.includes("chat history");
908
- }
909
- async executeHistoryAutoTopUp(reason) {
910
- if (!this.historyAutoTopUp) {
911
- return;
912
- }
913
- const hbarAmount = this.historyAutoTopUp.hbarAmount && this.historyAutoTopUp.hbarAmount > 0 ? this.historyAutoTopUp.hbarAmount : DEFAULT_HISTORY_TOP_UP_HBAR;
914
- await this.purchaseCreditsWithHbar({
915
- accountId: this.historyAutoTopUp.accountId,
916
- privateKey: this.historyAutoTopUp.privateKey,
917
- hbarAmount,
918
- memo: this.historyAutoTopUp.memo ?? "registry-broker-client:chat-history-topup",
919
- metadata: {
920
- purpose: "chat-history",
921
- reason
922
- }
923
- });
924
- }
925
- initializeEncryptionBootstrap(options) {
926
- return this.bootstrapEncryptionOptions(options).then(() => void 0);
1
+ import { optionalImportSync, optionalImport } from "./standards-sdk.es163.js";
2
+ const unsupported = (method) => new Error(`${method} is not supported by the in-memory signer`);
3
+ let cachedSdk = null;
4
+ const loadHashgraphSdk = () => {
5
+ if (cachedSdk) {
6
+ return cachedSdk;
7
+ }
8
+ const resolved = optionalImportSync("@hashgraph/sdk");
9
+ if (resolved) {
10
+ cachedSdk = resolved;
11
+ return resolved;
12
+ }
13
+ const message = "@hashgraph/sdk is required for ledger signing. Install it as a dependency to enable createPrivateKeySigner.";
14
+ throw new Error(message);
15
+ };
16
+ const loadHashgraphSdkAsync = async () => {
17
+ if (cachedSdk) {
18
+ return cachedSdk;
927
19
  }
928
- bootstrapEncryptionOptions(options) {
929
- return bootstrapEncryptionOptions(this, options);
20
+ const resolved = await optionalImport("@hashgraph/sdk");
21
+ if (resolved) {
22
+ cachedSdk = resolved;
23
+ return resolved;
930
24
  }
931
- }
932
- const isPendingRegisterAgentResponse = (response) => response.status === "pending";
933
- const isPartialRegisterAgentResponse = (response) => response.status === "partial" && response.success === false;
934
- const isSuccessRegisterAgentResponse = (response) => response.success === true && response.status !== "pending";
25
+ const message = "@hashgraph/sdk is required for ledger signing. Install it as a dependency to enable createPrivateKeySigner.";
26
+ throw new Error(message);
27
+ };
28
+ const buildSigner = (sdk, options) => {
29
+ const { AccountId, LedgerId, PrivateKey, SignerSignature } = sdk;
30
+ if (!options.privateKey) {
31
+ throw new Error("privateKey is required to create a ledger signer.");
32
+ }
33
+ if (!options.accountId) {
34
+ throw new Error("accountId is required to create a ledger signer.");
35
+ }
36
+ const accountId = AccountId.fromString(options.accountId);
37
+ const privateKey = PrivateKey.fromString(options.privateKey);
38
+ const ledgerId = LedgerId.fromString(options.network);
39
+ return {
40
+ getLedgerId: () => ledgerId,
41
+ getAccountId: () => accountId,
42
+ getAccountKey: () => privateKey.publicKey,
43
+ getNetwork: () => ({}),
44
+ getMirrorNetwork: () => [],
45
+ sign: async (messages) => Promise.all(
46
+ messages.map(async (message) => {
47
+ const signature = await privateKey.sign(message);
48
+ return new SignerSignature({
49
+ publicKey: privateKey.publicKey,
50
+ signature,
51
+ accountId
52
+ });
53
+ })
54
+ ),
55
+ getAccountBalance: async () => {
56
+ throw unsupported("getAccountBalance");
57
+ },
58
+ getAccountInfo: async () => {
59
+ throw unsupported("getAccountInfo");
60
+ },
61
+ getAccountRecords: async () => {
62
+ throw unsupported("getAccountRecords");
63
+ },
64
+ signTransaction: async (_) => {
65
+ throw unsupported("signTransaction");
66
+ },
67
+ checkTransaction: async (_) => {
68
+ throw unsupported("checkTransaction");
69
+ },
70
+ populateTransaction: async (_) => {
71
+ throw unsupported("populateTransaction");
72
+ },
73
+ call: async (_request) => {
74
+ throw unsupported("call");
75
+ }
76
+ };
77
+ };
78
+ const createPrivateKeySigner = (options) => buildSigner(loadHashgraphSdk(), options);
79
+ const createPrivateKeySignerAsync = async (options) => buildSigner(await loadHashgraphSdkAsync(), options);
935
80
  export {
936
- RegistryBrokerClient,
937
- isPartialRegisterAgentResponse,
938
- isPendingRegisterAgentResponse,
939
- isSuccessRegisterAgentResponse
81
+ createPrivateKeySigner,
82
+ createPrivateKeySignerAsync
940
83
  };
941
84
  //# sourceMappingURL=standards-sdk.es149.js.map