@hashgraphonline/standards-sdk 0.0.52 → 0.0.53

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 (236) hide show
  1. package/dist/es/hcs-10/base-client.d.ts +40 -45
  2. package/dist/es/hcs-10/base-client.d.ts.map +1 -1
  3. package/dist/es/hcs-10/browser.d.ts +8 -10
  4. package/dist/es/hcs-10/browser.d.ts.map +1 -1
  5. package/dist/es/hcs-10/sdk.d.ts +67 -13
  6. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  7. package/dist/es/hcs-10/types.d.ts +0 -7
  8. package/dist/es/hcs-10/types.d.ts.map +1 -1
  9. package/dist/es/hcs-11/index.d.ts +1 -1
  10. package/dist/es/hcs-11/index.d.ts.map +1 -1
  11. package/dist/es/inscribe/types.d.ts +1 -1
  12. package/dist/es/inscribe/types.d.ts.map +1 -1
  13. package/dist/es/services/mirror-node.d.ts.map +1 -1
  14. package/dist/es/standards-sdk.es.js +2 -1
  15. package/dist/es/standards-sdk.es10.js +138 -123
  16. package/dist/es/standards-sdk.es10.js.map +1 -1
  17. package/dist/es/standards-sdk.es100.js +3 -4
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +16 -39
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +5 -40
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +37 -35
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +34 -72
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +37 -3
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +78 -2
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +3 -2
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +2 -34
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es109.js +2 -33
  36. package/dist/es/standards-sdk.es109.js.map +1 -1
  37. package/dist/es/standards-sdk.es110.js +34 -9
  38. package/dist/es/standards-sdk.es110.js.map +1 -1
  39. package/dist/es/standards-sdk.es111.js +31 -32
  40. package/dist/es/standards-sdk.es111.js.map +1 -1
  41. package/dist/es/standards-sdk.es112.js +12 -0
  42. package/dist/es/standards-sdk.es112.js.map +1 -0
  43. package/dist/es/standards-sdk.es113.js +37 -0
  44. package/dist/es/standards-sdk.es113.js.map +1 -0
  45. package/dist/es/standards-sdk.es12.js +3 -2
  46. package/dist/es/standards-sdk.es12.js.map +1 -1
  47. package/dist/es/standards-sdk.es13.js +1 -1
  48. package/dist/es/standards-sdk.es16.js +2 -1
  49. package/dist/es/standards-sdk.es16.js.map +1 -1
  50. package/dist/es/standards-sdk.es17.js +6 -3
  51. package/dist/es/standards-sdk.es17.js.map +1 -1
  52. package/dist/es/standards-sdk.es18.js.map +1 -1
  53. package/dist/es/standards-sdk.es19.js +1767 -3
  54. package/dist/es/standards-sdk.es19.js.map +1 -1
  55. package/dist/es/standards-sdk.es20.js +3 -4167
  56. package/dist/es/standards-sdk.es20.js.map +1 -1
  57. package/dist/es/standards-sdk.es21.js +4086 -960
  58. package/dist/es/standards-sdk.es21.js.map +1 -1
  59. package/dist/es/standards-sdk.es22.js +1041 -36
  60. package/dist/es/standards-sdk.es22.js.map +1 -1
  61. package/dist/es/standards-sdk.es23.js +5 -48
  62. package/dist/es/standards-sdk.es23.js.map +1 -1
  63. package/dist/es/standards-sdk.es24.js +36 -6624
  64. package/dist/es/standards-sdk.es24.js.map +1 -1
  65. package/dist/es/standards-sdk.es25.js +48 -5
  66. package/dist/es/standards-sdk.es25.js.map +1 -1
  67. package/dist/es/standards-sdk.es26.js +6627 -2
  68. package/dist/es/standards-sdk.es26.js.map +1 -1
  69. package/dist/es/standards-sdk.es27.js +2 -101
  70. package/dist/es/standards-sdk.es27.js.map +1 -1
  71. package/dist/es/standards-sdk.es28.js +419 -2
  72. package/dist/es/standards-sdk.es28.js.map +1 -1
  73. package/dist/es/standards-sdk.es29.js +2 -16
  74. package/dist/es/standards-sdk.es29.js.map +1 -1
  75. package/dist/es/standards-sdk.es30.js +120 -4
  76. package/dist/es/standards-sdk.es30.js.map +1 -1
  77. package/dist/es/standards-sdk.es31.js +101 -2282
  78. package/dist/es/standards-sdk.es31.js.map +1 -1
  79. package/dist/es/standards-sdk.es32.js +2 -2
  80. package/dist/es/standards-sdk.es32.js.map +1 -1
  81. package/dist/es/standards-sdk.es33.js +15 -418
  82. package/dist/es/standards-sdk.es33.js.map +1 -1
  83. package/dist/es/standards-sdk.es34.js +409 -2
  84. package/dist/es/standards-sdk.es34.js.map +1 -1
  85. package/dist/es/standards-sdk.es35.js +2282 -120
  86. package/dist/es/standards-sdk.es35.js.map +1 -1
  87. package/dist/es/standards-sdk.es36.js +164 -2
  88. package/dist/es/standards-sdk.es36.js.map +1 -1
  89. package/dist/es/standards-sdk.es37.js +0 -25
  90. package/dist/es/standards-sdk.es37.js.map +1 -1
  91. package/dist/es/standards-sdk.es38.js +2 -362
  92. package/dist/es/standards-sdk.es38.js.map +1 -1
  93. package/dist/es/standards-sdk.es39.js +3 -6
  94. package/dist/es/standards-sdk.es39.js.map +1 -1
  95. package/dist/es/standards-sdk.es4.js +1 -1
  96. package/dist/es/standards-sdk.es40.js +185 -169
  97. package/dist/es/standards-sdk.es40.js.map +1 -1
  98. package/dist/es/standards-sdk.es41.js +437 -80
  99. package/dist/es/standards-sdk.es41.js.map +1 -1
  100. package/dist/es/standards-sdk.es42.js +21 -110
  101. package/dist/es/standards-sdk.es42.js.map +1 -1
  102. package/dist/es/standards-sdk.es43.js +130 -43
  103. package/dist/es/standards-sdk.es43.js.map +1 -1
  104. package/dist/es/standards-sdk.es44.js +17 -9
  105. package/dist/es/standards-sdk.es44.js.map +1 -1
  106. package/dist/es/standards-sdk.es45.js +22 -90
  107. package/dist/es/standards-sdk.es45.js.map +1 -1
  108. package/dist/es/standards-sdk.es46.js +28 -3
  109. package/dist/es/standards-sdk.es46.js.map +1 -1
  110. package/dist/es/standards-sdk.es47.js +21 -2
  111. package/dist/es/standards-sdk.es47.js.map +1 -1
  112. package/dist/es/standards-sdk.es48.js +36 -104
  113. package/dist/es/standards-sdk.es48.js.map +1 -1
  114. package/dist/es/standards-sdk.es49.js +15 -71
  115. package/dist/es/standards-sdk.es49.js.map +1 -1
  116. package/dist/es/standards-sdk.es5.js +410 -134
  117. package/dist/es/standards-sdk.es5.js.map +1 -1
  118. package/dist/es/standards-sdk.es50.js +60 -5
  119. package/dist/es/standards-sdk.es50.js.map +1 -1
  120. package/dist/es/standards-sdk.es51.js +1288 -4
  121. package/dist/es/standards-sdk.es51.js.map +1 -1
  122. package/dist/es/standards-sdk.es52.js +131 -204
  123. package/dist/es/standards-sdk.es52.js.map +1 -1
  124. package/dist/es/standards-sdk.es53.js +89 -56
  125. package/dist/es/standards-sdk.es53.js.map +1 -1
  126. package/dist/es/standards-sdk.es54.js +84 -69
  127. package/dist/es/standards-sdk.es54.js.map +1 -1
  128. package/dist/es/standards-sdk.es55.js +27 -190
  129. package/dist/es/standards-sdk.es55.js.map +1 -1
  130. package/dist/es/standards-sdk.es56.js +5 -437
  131. package/dist/es/standards-sdk.es56.js.map +1 -1
  132. package/dist/es/standards-sdk.es57.js +155 -21
  133. package/dist/es/standards-sdk.es57.js.map +1 -1
  134. package/dist/es/standards-sdk.es58.js +21 -137
  135. package/dist/es/standards-sdk.es58.js.map +1 -1
  136. package/dist/es/standards-sdk.es59.js +788 -13
  137. package/dist/es/standards-sdk.es59.js.map +1 -1
  138. package/dist/es/standards-sdk.es60.js +167 -22
  139. package/dist/es/standards-sdk.es60.js.map +1 -1
  140. package/dist/es/standards-sdk.es61.js +137 -23
  141. package/dist/es/standards-sdk.es61.js.map +1 -1
  142. package/dist/es/standards-sdk.es62.js +358 -15
  143. package/dist/es/standards-sdk.es62.js.map +1 -1
  144. package/dist/es/standards-sdk.es63.js +5 -43
  145. package/dist/es/standards-sdk.es63.js.map +1 -1
  146. package/dist/es/standards-sdk.es64.js +174 -13
  147. package/dist/es/standards-sdk.es64.js.map +1 -1
  148. package/dist/es/standards-sdk.es65.js +76 -56
  149. package/dist/es/standards-sdk.es65.js.map +1 -1
  150. package/dist/es/standards-sdk.es66.js +104 -1279
  151. package/dist/es/standards-sdk.es66.js.map +1 -1
  152. package/dist/es/standards-sdk.es67.js +42 -138
  153. package/dist/es/standards-sdk.es67.js.map +1 -1
  154. package/dist/es/standards-sdk.es68.js +10 -91
  155. package/dist/es/standards-sdk.es68.js.map +1 -1
  156. package/dist/es/standards-sdk.es69.js +89 -76
  157. package/dist/es/standards-sdk.es69.js.map +1 -1
  158. package/dist/es/standards-sdk.es70.js +3 -31
  159. package/dist/es/standards-sdk.es70.js.map +1 -1
  160. package/dist/es/standards-sdk.es71.js +2 -6
  161. package/dist/es/standards-sdk.es71.js.map +1 -1
  162. package/dist/es/standards-sdk.es72.js +99 -145
  163. package/dist/es/standards-sdk.es72.js.map +1 -1
  164. package/dist/es/standards-sdk.es73.js +71 -20
  165. package/dist/es/standards-sdk.es73.js.map +1 -1
  166. package/dist/es/standards-sdk.es74.js +5 -792
  167. package/dist/es/standards-sdk.es74.js.map +1 -1
  168. package/dist/es/standards-sdk.es75.js +4 -142
  169. package/dist/es/standards-sdk.es75.js.map +1 -1
  170. package/dist/es/standards-sdk.es76.js +209 -162
  171. package/dist/es/standards-sdk.es76.js.map +1 -1
  172. package/dist/es/standards-sdk.es77.js +56 -30
  173. package/dist/es/standards-sdk.es77.js.map +1 -1
  174. package/dist/es/standards-sdk.es78.js +69 -63
  175. package/dist/es/standards-sdk.es78.js.map +1 -1
  176. package/dist/es/standards-sdk.es79.js +17 -46
  177. package/dist/es/standards-sdk.es79.js.map +1 -1
  178. package/dist/es/standards-sdk.es8.js +143 -180
  179. package/dist/es/standards-sdk.es8.js.map +1 -1
  180. package/dist/es/standards-sdk.es80.js +25 -8
  181. package/dist/es/standards-sdk.es80.js.map +1 -1
  182. package/dist/es/standards-sdk.es81.js +24 -63
  183. package/dist/es/standards-sdk.es81.js.map +1 -1
  184. package/dist/es/standards-sdk.es82.js +38 -6
  185. package/dist/es/standards-sdk.es82.js.map +1 -1
  186. package/dist/es/standards-sdk.es83.js +30 -13
  187. package/dist/es/standards-sdk.es83.js.map +1 -1
  188. package/dist/es/standards-sdk.es84.js +63 -7
  189. package/dist/es/standards-sdk.es84.js.map +1 -1
  190. package/dist/es/standards-sdk.es85.js +47 -42
  191. package/dist/es/standards-sdk.es85.js.map +1 -1
  192. package/dist/es/standards-sdk.es86.js +10 -2
  193. package/dist/es/standards-sdk.es86.js.map +1 -1
  194. package/dist/es/standards-sdk.es87.js +58 -129
  195. package/dist/es/standards-sdk.es87.js.map +1 -1
  196. package/dist/es/standards-sdk.es88.js +5 -171
  197. package/dist/es/standards-sdk.es88.js.map +1 -1
  198. package/dist/es/standards-sdk.es89.js +14 -20
  199. package/dist/es/standards-sdk.es89.js.map +1 -1
  200. package/dist/es/standards-sdk.es9.js +1 -1
  201. package/dist/es/standards-sdk.es90.js +7 -27
  202. package/dist/es/standards-sdk.es90.js.map +1 -1
  203. package/dist/es/standards-sdk.es91.js +45 -26
  204. package/dist/es/standards-sdk.es91.js.map +1 -1
  205. package/dist/es/standards-sdk.es92.js +2 -38
  206. package/dist/es/standards-sdk.es92.js.map +1 -1
  207. package/dist/es/standards-sdk.es93.js +134 -30
  208. package/dist/es/standards-sdk.es93.js.map +1 -1
  209. package/dist/es/standards-sdk.es94.js +171 -14
  210. package/dist/es/standards-sdk.es94.js.map +1 -1
  211. package/dist/es/standards-sdk.es95.js +13 -4
  212. package/dist/es/standards-sdk.es95.js.map +1 -1
  213. package/dist/es/standards-sdk.es96.js +13 -4
  214. package/dist/es/standards-sdk.es96.js.map +1 -1
  215. package/dist/es/standards-sdk.es97.js +31 -12
  216. package/dist/es/standards-sdk.es97.js.map +1 -1
  217. package/dist/es/standards-sdk.es98.js +15 -13
  218. package/dist/es/standards-sdk.es98.js.map +1 -1
  219. package/dist/es/standards-sdk.es99.js +3 -15
  220. package/dist/es/standards-sdk.es99.js.map +1 -1
  221. package/dist/umd/hcs-10/base-client.d.ts +40 -45
  222. package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
  223. package/dist/umd/hcs-10/browser.d.ts +8 -10
  224. package/dist/umd/hcs-10/browser.d.ts.map +1 -1
  225. package/dist/umd/hcs-10/sdk.d.ts +67 -13
  226. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  227. package/dist/umd/hcs-10/types.d.ts +0 -7
  228. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  229. package/dist/umd/hcs-11/index.d.ts +1 -1
  230. package/dist/umd/hcs-11/index.d.ts.map +1 -1
  231. package/dist/umd/inscribe/types.d.ts +1 -1
  232. package/dist/umd/inscribe/types.d.ts.map +1 -1
  233. package/dist/umd/services/mirror-node.d.ts.map +1 -1
  234. package/dist/umd/standards-sdk.umd.js +23 -19
  235. package/dist/umd/standards-sdk.umd.js.map +1 -1
  236. package/package.json +1 -1
@@ -1,10 +1,17 @@
1
+ import Buffer from "./standards-sdk.es19.js";
1
2
  import { HederaMirrorNode } from "./standards-sdk.es17.js";
2
3
  import { Logger } from "./standards-sdk.es13.js";
3
- import "./standards-sdk.es22.js";
4
4
  import { Registration } from "./standards-sdk.es9.js";
5
5
  import { HCS11Client } from "./standards-sdk.es12.js";
6
6
  import { PublicKey } from "@hashgraph/sdk";
7
- import axios from "./standards-sdk.es23.js";
7
+ import "./standards-sdk.es24.js";
8
+ import axios from "./standards-sdk.es25.js";
9
+ var Hcs10MemoType = /* @__PURE__ */ ((Hcs10MemoType2) => {
10
+ Hcs10MemoType2["INBOUND"] = "inbound";
11
+ Hcs10MemoType2["OUTBOUND"] = "outbound";
12
+ Hcs10MemoType2["CONNECTION"] = "connection";
13
+ return Hcs10MemoType2;
14
+ })(Hcs10MemoType || {});
8
15
  class HCS10BaseClient extends Registration {
9
16
  constructor(config) {
10
17
  super();
@@ -18,7 +25,51 @@ class HCS10BaseClient extends Registration {
18
25
  config.network,
19
26
  this.logger
20
27
  );
21
- this.feeAmount = config.feeAmount || 5;
28
+ this.feeAmount = config.feeAmount || 1e-3;
29
+ }
30
+ /**
31
+ * Get a stream of messages from a connection topic
32
+ * @param topicId The connection topic ID to get messages from
33
+ * @returns A stream of filtered messages valid for connection topics
34
+ */
35
+ async getMessageStream(topicId) {
36
+ try {
37
+ const messages = await this.mirrorNode.getTopicMessages(topicId);
38
+ const validOps = ["message", "close_connection"];
39
+ const filteredMessages = messages.filter((msg) => {
40
+ if (msg.p !== "hcs-10" || !validOps.includes(msg.op)) {
41
+ return false;
42
+ }
43
+ if (msg.op === "message") {
44
+ if (!msg.data) {
45
+ return false;
46
+ }
47
+ if (!msg.operator_id) {
48
+ return false;
49
+ }
50
+ if (!this.isValidOperatorId(msg.operator_id)) {
51
+ return false;
52
+ }
53
+ }
54
+ if (msg.op === "close_connection") {
55
+ if (!msg.operator_id) {
56
+ return false;
57
+ }
58
+ if (!this.isValidOperatorId(msg.operator_id)) {
59
+ return false;
60
+ }
61
+ }
62
+ return true;
63
+ });
64
+ return {
65
+ messages: filteredMessages
66
+ };
67
+ } catch (error) {
68
+ if (this.logger) {
69
+ this.logger.error(`Error fetching messages: ${error.message}`);
70
+ }
71
+ return { messages: [] };
72
+ }
22
73
  }
23
74
  /**
24
75
  * Checks if a user can submit to a topic and determines if a fee is required
@@ -26,7 +77,7 @@ class HCS10BaseClient extends Registration {
26
77
  * @param userAccountId The account ID of the user attempting to submit
27
78
  * @returns Object with canSubmit, requiresFee, and optional reason
28
79
  */
29
- async canSubmitToInboundTopic(topicId, userAccountId) {
80
+ async canSubmitToTopic(topicId, userAccountId) {
30
81
  try {
31
82
  const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
32
83
  if (!topicInfo) {
@@ -57,11 +108,9 @@ class HCS10BaseClient extends Registration {
57
108
  }
58
109
  }
59
110
  } catch (error) {
60
- let errorMessage = String(error);
61
- if (error instanceof Error) {
62
- errorMessage = error.message;
63
- }
64
- this.logger.error(`Key validation error: ${errorMessage}`);
111
+ this.logger.error(
112
+ `Key validation error: ${error instanceof Error ? error.message : String(error)}`
113
+ );
65
114
  }
66
115
  if (topicInfo.fee_schedule_key?.key && topicInfo.custom_fees?.fixed_fees?.length > 0) {
67
116
  return {
@@ -76,10 +125,7 @@ class HCS10BaseClient extends Registration {
76
125
  reason: "User does not have submit permission for this topic"
77
126
  };
78
127
  } catch (error) {
79
- let errorMessage = String(error);
80
- if (error instanceof Error) {
81
- errorMessage = error.message;
82
- }
128
+ const errorMessage = error instanceof Error ? error.message : String(error);
83
129
  this.logger.error(`Topic submission validation error: ${errorMessage}`);
84
130
  return {
85
131
  canSubmit: false,
@@ -88,148 +134,6 @@ class HCS10BaseClient extends Registration {
88
134
  };
89
135
  }
90
136
  }
91
- /**
92
- * The primary method for an agent to send a message to another agent.
93
- * @param {string} connectionTopicId The ID of the connection topic to send the message to
94
- * @param {string} operatorId The operator ID (agentInboundTopicId@accountId) of the message sender in the operatorId format e.g. "0.0.123333@0.0.12345"
95
- * @param {string} data The content of the message
96
- * @param {string} memo An optional memo for the message
97
- * @param {object} options Optional configuration for the message submission
98
- * @param {PrivateKey} submitKey The private key of the account submitting the message
99
- * @returns A promise that resolves to the transaction receipt of the message submission
100
- */
101
- async sendMessage(connectionTopicId, operatorId, data, memo, options, submitKey) {
102
- const { accountId } = this.getAccountAndSigner();
103
- const submissionCheck = await this.canSubmitToInboundTopic(
104
- connectionTopicId,
105
- accountId
106
- );
107
- if (!submissionCheck.canSubmit) {
108
- throw new Error(
109
- `Cannot submit to topic ${connectionTopicId}: ${submissionCheck.reason || "Unknown reason"}`
110
- );
111
- }
112
- const payload = {
113
- p: "hcs-10",
114
- op: "message",
115
- operator_id: operatorId,
116
- data,
117
- m: memo
118
- };
119
- const payloadString = JSON.stringify(payload);
120
- const isLargePayload = Buffer.from(payloadString).length > 1e3;
121
- if (isLargePayload) {
122
- this.logger.info(
123
- "Message payload exceeds 1000 bytes, storing via inscription"
124
- );
125
- try {
126
- const contentBuffer = Buffer.from(data);
127
- const fileFormat = "json";
128
- const fileName = `message-content-${Date.now()}.${fileFormat}`;
129
- const inscriptionResult = await this.inscribeFile(
130
- contentBuffer,
131
- fileName,
132
- options
133
- );
134
- if (inscriptionResult?.topic_id) {
135
- payload.data = `hcs://1/${inscriptionResult.topic_id}`;
136
- this.logger.info(
137
- `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`
138
- );
139
- } else {
140
- throw new Error("Failed to inscribe large message content");
141
- }
142
- } catch (error) {
143
- this.logger.error("Error inscribing large message:", error);
144
- let errorMessage = "Unknown error";
145
- if (error instanceof Error) {
146
- errorMessage = error.message;
147
- }
148
- throw new Error(`Failed to handle large message: ${errorMessage}`);
149
- }
150
- }
151
- this.logger.info("Submitting message to connection topic", payload);
152
- return await this.submitPayload(
153
- connectionTopicId,
154
- payload,
155
- submitKey,
156
- submissionCheck.requiresFee
157
- );
158
- }
159
- /**
160
- * Get a stream of messages from a connection topic
161
- * @param topicId The connection topic ID to get messages from
162
- * @returns A stream of filtered messages valid for connection topics
163
- */
164
- async getMessageStream(topicId) {
165
- try {
166
- const messages = await this.mirrorNode.getTopicMessages(topicId);
167
- const validOps = ["message", "close_connection"];
168
- const filteredMessages = messages.filter((msg) => {
169
- if (msg.p !== "hcs-10" || !validOps.includes(msg.op)) {
170
- return false;
171
- }
172
- if (msg.op === "message") {
173
- if (!msg.data) {
174
- return false;
175
- }
176
- if (!msg.operator_id) {
177
- return false;
178
- }
179
- if (!this.isValidOperatorId(msg.operator_id)) {
180
- return false;
181
- }
182
- }
183
- if (msg.op === "close_connection") {
184
- if (!msg.operator_id) {
185
- return false;
186
- }
187
- if (!this.isValidOperatorId(msg.operator_id)) {
188
- return false;
189
- }
190
- }
191
- return true;
192
- });
193
- return {
194
- messages: filteredMessages
195
- };
196
- } catch (error) {
197
- if (this.logger) {
198
- this.logger.error(`Error fetching messages: ${error.message}`);
199
- }
200
- return { messages: [] };
201
- }
202
- }
203
- /**
204
- * Validates if an operator_id follows the correct format (agentTopicId@accountId)
205
- * @param operatorId The operator ID to validate
206
- * @returns True if the format is valid, false otherwise
207
- */
208
- isValidOperatorId(operatorId) {
209
- if (!operatorId) {
210
- return false;
211
- }
212
- const parts = operatorId.split("@");
213
- if (parts.length !== 2) {
214
- return false;
215
- }
216
- const agentTopicId = parts[0];
217
- const accountId = parts[1];
218
- if (!agentTopicId) {
219
- return false;
220
- }
221
- if (!accountId) {
222
- return false;
223
- }
224
- const hederaIdPattern = /^[0-9]+\.[0-9]+\.[0-9]+$/;
225
- if (!hederaIdPattern.test(accountId)) {
226
- return false;
227
- }
228
- if (!hederaIdPattern.test(agentTopicId)) {
229
- return false;
230
- }
231
- return true;
232
- }
233
137
  /**
234
138
  * Get all messages from a topic
235
139
  * @param topicId The topic ID to get messages from
@@ -264,27 +168,6 @@ class HCS10BaseClient extends Registration {
264
168
  return { messages: [] };
265
169
  }
266
170
  }
267
- async checkRegistrationStatus(transactionId, network, baseUrl) {
268
- try {
269
- const response = await fetch(`${baseUrl}/api/request-confirm`, {
270
- method: "POST",
271
- headers: {
272
- "Content-Type": "application/json",
273
- "X-Network": network
274
- },
275
- body: JSON.stringify({ transaction_id: transactionId })
276
- });
277
- if (!response.ok) {
278
- throw new Error(
279
- `Failed to confirm registration: ${response.statusText}`
280
- );
281
- }
282
- return await response.json();
283
- } catch (error) {
284
- this.logger.error(`Error checking registration status: ${error}`);
285
- throw error;
286
- }
287
- }
288
171
  async requestAccount(account) {
289
172
  try {
290
173
  return await this.mirrorNode.requestAccount(account);
@@ -407,9 +290,6 @@ class HCS10BaseClient extends Registration {
407
290
  return false;
408
291
  }
409
292
  }
410
- clearCache() {
411
- HCS10Cache.getInstance().clear();
412
- }
413
293
  /**
414
294
  * Gets message content, resolving any HRL references if needed
415
295
  * @param data The message data which might be an HRL reference
@@ -470,6 +350,88 @@ class HCS10BaseClient extends Registration {
470
350
  };
471
351
  return await this.submitPayload(outboundTopicId, payload);
472
352
  }
353
+ clearCache() {
354
+ HCS10Cache.getInstance().clear();
355
+ }
356
+ /**
357
+ * Generates a standard HCS-10 memo string.
358
+ * @param type The type of topic memo ('inbound', 'outbound', 'connection').
359
+ * @param options Configuration options for the memo.
360
+ * @returns The formatted memo string.
361
+ * @protected
362
+ */
363
+ _generateHcs10Memo(type, options) {
364
+ const ttl = options.ttl ?? 60;
365
+ switch (type) {
366
+ case "inbound":
367
+ if (!options.accountId) {
368
+ throw new Error("accountId is required for inbound memo");
369
+ }
370
+ return `hcs-10:0:${ttl}:0:${options.accountId}`;
371
+ case "outbound":
372
+ return `hcs-10:0:${ttl}:1`;
373
+ case "connection":
374
+ if (!options.inboundTopicId || options.connectionId === void 0) {
375
+ throw new Error(
376
+ "inboundTopicId and connectionId are required for connection memo"
377
+ );
378
+ }
379
+ return `hcs-10:1:${ttl}:2:${options.inboundTopicId}:${options.connectionId}`;
380
+ default:
381
+ throw new Error(`Invalid HCS-10 memo type: ${type}`);
382
+ }
383
+ }
384
+ async checkRegistrationStatus(transactionId, network, baseUrl) {
385
+ try {
386
+ const response = await fetch(`${baseUrl}/api/request-confirm`, {
387
+ method: "POST",
388
+ headers: {
389
+ "Content-Type": "application/json",
390
+ "X-Network": network
391
+ },
392
+ body: JSON.stringify({ transaction_id: transactionId })
393
+ });
394
+ if (!response.ok) {
395
+ throw new Error(
396
+ `Failed to confirm registration: ${response.statusText}`
397
+ );
398
+ }
399
+ return await response.json();
400
+ } catch (error) {
401
+ this.logger.error(`Error checking registration status: ${error}`);
402
+ throw error;
403
+ }
404
+ }
405
+ /**
406
+ * Validates if an operator_id follows the correct format (agentTopicId@accountId)
407
+ * @param operatorId The operator ID to validate
408
+ * @returns True if the format is valid, false otherwise
409
+ */
410
+ isValidOperatorId(operatorId) {
411
+ if (!operatorId) {
412
+ return false;
413
+ }
414
+ const parts = operatorId.split("@");
415
+ if (parts.length !== 2) {
416
+ return false;
417
+ }
418
+ const agentTopicId = parts[0];
419
+ const accountId = parts[1];
420
+ if (!agentTopicId) {
421
+ return false;
422
+ }
423
+ if (!accountId) {
424
+ return false;
425
+ }
426
+ const hederaIdPattern = /^[0-9]+\.[0-9]+\.[0-9]+$/;
427
+ if (!hederaIdPattern.test(accountId)) {
428
+ return false;
429
+ }
430
+ if (!hederaIdPattern.test(agentTopicId)) {
431
+ return false;
432
+ }
433
+ return true;
434
+ }
473
435
  }
474
436
  class HCS10Cache {
475
437
  constructor() {
@@ -505,6 +467,7 @@ class HCS10Cache {
505
467
  }
506
468
  export {
507
469
  HCS10BaseClient,
508
- HCS10Cache
470
+ HCS10Cache,
471
+ Hcs10MemoType
509
472
  };
510
473
  //# sourceMappingURL=standards-sdk.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es8.js","sources":["../../src/hcs-10/base-client.ts"],"sourcesContent":["import { HederaMirrorNode } from '../services/mirror-node';\nimport { Logger, LogLevel } from '../utils/logger';\nimport axios from 'axios';\nimport { Registration } from './registrations';\nimport { HCS11Client } from '../hcs-11';\nimport { AccountResponse, NetworkType } from '../services/types';\nimport { TopicInfo } from '../services/types';\nimport { TransactionReceipt, PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport { RetrievedInscriptionResult } from '@kiloscribe/inscription-sdk';\nimport { InscriptionProgressCallback, InscriptionProgressData } from './types';\nimport { PayloadSizeError } from './errors';\n\nexport interface HCS10Config {\n network: 'mainnet' | 'testnet';\n logLevel?: LogLevel;\n prettyPrint?: boolean;\n}\n\nexport interface HCSMessage {\n p: 'hcs-10';\n op:\n | 'connection_request'\n | 'connection_created'\n | 'message'\n | 'close_connection';\n data: string;\n created?: Date;\n consensus_timestamp?: string;\n m?: string;\n payer: string;\n outbound_topic_id?: string;\n connection_request_id?: number;\n confirmed_request_id?: number;\n connection_topic_id?: string;\n connected_account_id?: string;\n requesting_account_id?: string;\n connection_id?: number;\n sequence_number: number;\n operator_id?: string;\n reason?: string;\n close_method?: string;\n}\n\nexport interface ProfileResponse {\n profile: any;\n topicInfo?: TopicInfo;\n success: boolean;\n error?: string;\n}\n\nexport abstract class HCS10BaseClient extends Registration {\n protected network: string;\n protected logger: Logger;\n protected mirrorNode: HederaMirrorNode;\n protected feeAmount: number;\n\n constructor(config: HCS10Config & { feeAmount?: number }) {\n super();\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS10-BaseClient',\n prettyPrint: config.prettyPrint,\n });\n this.mirrorNode = new HederaMirrorNode(\n config.network as NetworkType,\n this.logger\n );\n this.feeAmount = config.feeAmount || 5;\n }\n\n abstract getAccountAndSigner(): { accountId: string; signer: any };\n\n abstract submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee?: boolean\n ): Promise<TransactionReceipt>;\n\n abstract inscribeFile(\n buffer: Buffer,\n fileName: string,\n options?: {\n progressCallback?: InscriptionProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n }\n ): Promise<RetrievedInscriptionResult>;\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n async canSubmitToInboundTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n let errorMessage = String(error);\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n this.logger.error(`Key validation error: ${errorMessage}`);\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n let errorMessage = String(error);\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * The primary method for an agent to send a message to another agent.\n * @param {string} connectionTopicId The ID of the connection topic to send the message to\n * @param {string} operatorId The operator ID (agentInboundTopicId@accountId) of the message sender in the operatorId format e.g. \"0.0.123333@0.0.12345\"\n * @param {string} data The content of the message\n * @param {string} memo An optional memo for the message\n * @param {object} options Optional configuration for the message submission\n * @param {PrivateKey} submitKey The private key of the account submitting the message\n * @returns A promise that resolves to the transaction receipt of the message submission\n */\n async sendMessage(\n connectionTopicId: string,\n operatorId: string,\n data: string,\n memo?: string,\n options?: {\n progressCallback?: InscriptionProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n },\n submitKey?: PrivateKey\n ): Promise<TransactionReceipt> {\n const { accountId } = this.getAccountAndSigner();\n const submissionCheck = await this.canSubmitToInboundTopic(\n connectionTopicId,\n accountId\n );\n\n if (!submissionCheck.canSubmit) {\n throw new Error(\n `Cannot submit to topic ${connectionTopicId}: ${\n submissionCheck.reason || 'Unknown reason'\n }`\n );\n }\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription'\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileFormat = 'json';\n const fileName = `message-content-${Date.now()}.${fileFormat}`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName,\n options\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error) {\n this.logger.error('Error inscribing large message:', error);\n let errorMessage = 'Unknown error';\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n throw new Error(`Failed to handle large message: ${errorMessage}`);\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n /**\n * Get a stream of messages from a connection topic\n * @param topicId The connection topic ID to get messages from\n * @returns A stream of filtered messages valid for connection topics\n */\n public async getMessageStream(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n const validOps = ['message', 'close_connection'];\n\n const filteredMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10' || !validOps.includes(msg.op)) {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n if (msg.op === 'close_connection') {\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n return true;\n });\n\n return {\n messages: filteredMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Validates if an operator_id follows the correct format (agentTopicId@accountId)\n * @param operatorId The operator ID to validate\n * @returns True if the format is valid, false otherwise\n */\n protected isValidOperatorId(operatorId: string): boolean {\n if (!operatorId) {\n return false;\n }\n\n const parts = operatorId.split('@');\n\n if (parts.length !== 2) {\n return false;\n }\n\n const agentTopicId = parts[0];\n const accountId = parts[1];\n\n if (!agentTopicId) {\n return false;\n }\n\n if (!accountId) {\n return false;\n }\n\n const hederaIdPattern = /^[0-9]+\\.[0-9]+\\.[0-9]+$/;\n\n if (!hederaIdPattern.test(accountId)) {\n return false;\n }\n\n if (!hederaIdPattern.test(agentTopicId)) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Get all messages from a topic\n * @param topicId The topic ID to get messages from\n * @returns All messages from the topic\n */\n public async getMessages(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n\n const validatedMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10') {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (msg.operator_id) {\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n }\n\n return true;\n });\n\n return {\n messages: validatedMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n protected async checkRegistrationStatus(\n transactionId: string,\n network: string,\n baseUrl: string\n ): Promise<{ status: 'pending' | 'success' | 'failed' }> {\n try {\n const response = await fetch(`${baseUrl}/api/request-confirm`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Network': network,\n },\n body: JSON.stringify({ transaction_id: transactionId }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to confirm registration: ${response.statusText}`\n );\n }\n\n return await response.json();\n } catch (error) {\n this.logger.error(`Error checking registration status: ${error}`);\n throw error;\n }\n }\n\n public async requestAccount(account: string): Promise<AccountResponse> {\n try {\n return await this.mirrorNode.requestAccount(account);\n } catch (e) {\n this.logger.error('Failed to fetch account', e);\n throw e;\n }\n }\n\n public async getAccountMemo(accountId: string): Promise<string | null> {\n return await this.mirrorNode.getAccountMemo(accountId);\n }\n\n public async retrieveProfile(accountId: string): Promise<ProfileResponse> {\n this.logger.info(`Retrieving profile for account: ${accountId}`);\n\n try {\n const hcs11Client = new HCS11Client({\n network: this.network as 'mainnet' | 'testnet',\n auth: {\n operatorId: '0.0.0', // Read-only operations only\n },\n logLevel: 'info',\n });\n\n const profileResult = await hcs11Client.fetchProfileByAccountId(\n accountId,\n this.network\n );\n\n if (!profileResult?.success) {\n this.logger.error(\n `Failed to retrieve profile for account ID: ${accountId}`,\n profileResult?.error\n );\n return {\n profile: null,\n success: false,\n error:\n profileResult?.error ||\n `Failed to retrieve profile for account ID: ${accountId}`,\n };\n }\n\n const profile = profileResult.profile;\n let topicInfo = null;\n\n if (\n profileResult.topicInfo?.inboundTopic &&\n profileResult.topicInfo?.outboundTopic &&\n profileResult.topicInfo?.profileTopicId\n ) {\n topicInfo = {\n inboundTopic: profileResult.topicInfo.inboundTopic,\n outboundTopic: profileResult.topicInfo.outboundTopic,\n profileTopicId: profileResult.topicInfo.profileTopicId,\n };\n\n const cacheKey = `${accountId}-${this.network}`;\n HCS10Cache.getInstance().set(cacheKey, topicInfo);\n }\n\n return {\n profile,\n topicInfo,\n success: true,\n };\n } catch (error) {\n this.logger.error('Failed to retrieve profile:', error);\n return {\n profile: null,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n\n async retrieveOutboundConnectTopic(accountId: string): Promise<TopicInfo> {\n this.logger.info(`Retrieving topics for account: ${accountId}`);\n\n try {\n const profileResponse = await this.retrieveProfile(accountId);\n\n if (!profileResponse?.success) {\n throw new Error(profileResponse.error || 'Failed to retrieve profile');\n }\n\n const profile = profileResponse.profile;\n\n if (!profile.inboundTopicId || !profile.outboundTopicId) {\n throw new Error(\n `Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`\n );\n }\n\n const topicInfo = {\n inboundTopic: profile.inboundTopicId,\n outboundTopic: profile.outboundTopicId,\n profileTopicId: profile.profileTopicId,\n };\n\n const cacheKey = `${accountId}-${this.network}`;\n HCS10Cache.getInstance().set(cacheKey, topicInfo);\n return topicInfo;\n } catch (error) {\n this.logger.error('Failed to retrieve topic info:', error);\n throw error;\n }\n }\n\n public async retrieveOutboundMessages(\n agentAccountId: string\n ): Promise<HCSMessage[]> {\n try {\n const topicInfo = await this.retrieveOutboundConnectTopic(agentAccountId);\n if (!topicInfo) {\n this.logger.warn(\n `No outbound connect topic found for agentAccountId: ${agentAccountId}`\n );\n return [];\n }\n const response = await this.getMessages(topicInfo.outboundTopic);\n return response.messages.filter(\n (msg) =>\n msg.p === 'hcs-10' &&\n (msg.op === 'connection_request' ||\n msg.op === 'connection_created' ||\n msg.op === 'message')\n );\n } catch (error) {\n this.logger.error('Failed to retrieve outbound messages:', error);\n return [];\n }\n }\n\n async hasConnectionCreated(\n agentAccountId: string,\n connectionId: number\n ): Promise<boolean> {\n try {\n const outBoundTopic = await this.retrieveOutboundConnectTopic(\n agentAccountId\n );\n const messages = await this.retrieveOutboundMessages(\n outBoundTopic.outboundTopic\n );\n return messages.some(\n (msg) =>\n msg.op === 'connection_created' && msg.connection_id === connectionId\n );\n } catch (error) {\n this.logger.error('Failed to check connection created:', error);\n return false;\n }\n }\n\n clearCache(): void {\n HCS10Cache.getInstance().clear();\n }\n\n /**\n * Gets message content, resolving any HRL references if needed\n * @param data The message data which might be an HRL reference\n * @returns The resolved content\n */\n async getMessageContent(data: string): Promise<string> {\n const hrlPattern = /^hcs:\\/\\/(\\d+)\\/([0-9.]+)$/;\n const match = data.match(hrlPattern);\n\n if (!match) {\n return data;\n }\n\n const [_, standard, topicId] = match;\n\n this.logger.info(\n `Resolving HRL reference: standard=${standard}, topicId=${topicId}`\n );\n\n try {\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${this.network}`;\n const response = await axios.get(cdnUrl);\n\n if (!response.data) {\n throw new Error(`Failed to fetch content from topic: ${topicId}`);\n }\n\n return (\n response.data.content ||\n response.data.text ||\n JSON.stringify(response.data)\n );\n } catch (error) {\n this.logger.error(\n `Error resolving HRL reference: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n throw new Error(\n `Failed to resolve HRL reference: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n\n /**\n * Records an outbound connection confirmation\n * @param outboundTopicId The ID of the outbound topic\n * @param connectionRequestId The ID of the connection request\n * @param confirmedRequestId The ID of the confirmed request\n * @param connectionTopicId The ID of the connection topic\n * @param operatorId The operator ID of the message sender\n * @param memo An optional memo for the message\n */\n async recordOutboundConnectionConfirmation({\n outboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }): Promise<TransactionReceipt> {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n // Calls the abstract submitPayload, letting the subclass handle implementation\n return await this.submitPayload(outboundTopicId, payload);\n }\n}\n\nexport class HCS10Cache {\n private static instance: HCS10Cache;\n private cache: Map<string, TopicInfo>;\n private cacheExpiry: Map<string, number>;\n private readonly CACHE_TTL = 3600000;\n\n private constructor() {\n this.cache = new Map();\n this.cacheExpiry = new Map();\n }\n\n static getInstance(): HCS10Cache {\n if (!HCS10Cache.instance) {\n HCS10Cache.instance = new HCS10Cache();\n }\n return HCS10Cache.instance;\n }\n\n set(key: string, value: TopicInfo): void {\n this.cache.set(key, value);\n this.cacheExpiry.set(key, Date.now() + this.CACHE_TTL);\n }\n\n get(key: string): TopicInfo | undefined {\n const expiry = this.cacheExpiry.get(key);\n if (expiry && expiry > Date.now()) {\n return this.cache.get(key);\n }\n if (expiry) {\n this.cache.delete(key);\n this.cacheExpiry.delete(key);\n }\n return undefined;\n }\n\n clear(): void {\n this.cache.clear();\n this.cacheExpiry.clear();\n }\n}\n"],"names":[],"mappings":";;;;;;;AAkDO,MAAe,wBAAwB,aAAa;AAAA,EAMzD,YAAY,QAA8C;AAClD,UAAA;AACN,SAAK,UAAU,OAAO;AACjB,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,aAAa,OAAO;AAAA,IAAA,CACrB;AACD,SAAK,aAAa,IAAI;AAAA,MACpB,OAAO;AAAA,MACP,KAAK;AAAA,IACP;AACK,SAAA,YAAY,OAAO,aAAa;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BvC,MAAM,wBACJ,SACA,eACwE;AACpE,QAAA;AACF,YAAM,YAAY,MAAM,KAAK,WAAW,aAAa,OAAO;AAE5D,UAAI,CAAC,WAAW;AACP,eAAA;AAAA,UACL,WAAW;AAAA,UACX,aAAa;AAAA,UACb,QAAQ;AAAA,QACV;AAAA,MAAA;AAGE,UAAA,CAAC,UAAU,YAAY,KAAK;AAC9B,eAAO,EAAE,WAAW,MAAM,aAAa,MAAM;AAAA,MAAA;AAG3C,UAAA;AACF,cAAM,gBAAgB,MAAM,KAAK,WAAW,aAAa,aAAa;AAElE,YAAA,UAAU,WAAW,UAAU,mBAAmB;AACpD,gBAAM,WAAW,OAAO,KAAK,UAAU,WAAW,KAAK,KAAK;AACtD,gBAAA,YAAY,MAAM,KAAK,WAAW;AAAA,YACtC;AAAA,YACA;AAAA,UACF;AAEA,cAAI,WAAW;AACb,mBAAO,EAAE,W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AAA,GAQ8B;AAC9B,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,qBAAqB;AAAA,MACrB,mBAAmB;AAAA,MACnB,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB,aAAa;AAAA,MACb,GAAG;AAAA,IACL;AAEA,WAAO,MAAM,KAAK,cAAc,iBAAiB,OAAO;AAAA,EAAA;AAE5D;AAEO,MAAM,WAAW;AAAA,EAMd,cAAc;AAFtB,SAAiB,YAAY;AAGtB,SAAA,4BAAY,IAAI;AAChB,SAAA,kCAAkB,IAAI;AAAA,EAAA;AAAA,EAG7B,OAAO,cAA0B;AAC3B,QAAA,CAAC,WAAW,UAAU;AACb,iBAAA,WAAW,IAAI,WAAW;AAAA,IAAA;AAEvC,WAAO,WAAW;AAAA,EAAA;AAAA,EAGpB,IAAI,KAAa,OAAwB;AAClC,SAAA,MAAM,IAAI,KAAK,KAAK;AACzB,SAAK,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,SAAS;AAAA,EAAA;AAAA,EAGvD,IAAI,KAAoC;AACtC,UAAM,SAAS,KAAK,YAAY,IAAI,GAAG;AACvC,QAAI,UAAU,SAAS,KAAK,IAAA,GAAO;AAC1B,aAAA,KAAK,MAAM,IAAI,GAAG;AAAA,IAAA;AAE3B,QAAI,QAAQ;AACL,WAAA,MAAM,OAAO,GAAG;AAChB,WAAA,YAAY,OAAO,GAAG;AAAA,IAAA;AAEtB,WAAA;AAAA,EAAA;AAAA,EAGT,QAAc;AACZ,SAAK,MAAM,MAAM;AACjB,SAAK,YAAY,MAAM;AAAA,EAAA;AAE3B;"}
1
+ {"version":3,"file":"standards-sdk.es8.js","sources":["../../src/hcs-10/base-client.ts"],"sourcesContent":["import { HederaMirrorNode } from '../services/mirror-node';\nimport { Logger, LogLevel } from '../utils/logger';\nimport { Registration } from './registrations';\nimport { HCS11Client } from '../hcs-11';\nimport { AccountResponse, NetworkType } from '../services/types';\nimport { TopicInfo } from '../services/types';\nimport { TransactionReceipt, PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport axios from 'axios';\n\nexport enum Hcs10MemoType {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n CONNECTION = 'connection',\n}\n\nexport interface HCS10Config {\n network: 'mainnet' | 'testnet';\n logLevel?: LogLevel;\n prettyPrint?: boolean;\n feeAmount?: number;\n}\n\nexport interface HCSMessage {\n p: 'hcs-10';\n op:\n | 'connection_request'\n | 'connection_created'\n | 'message'\n | 'close_connection';\n data: string;\n created?: Date;\n consensus_timestamp?: string;\n m?: string;\n payer: string;\n outbound_topic_id?: string;\n connection_request_id?: number;\n confirmed_request_id?: number;\n connection_topic_id?: string;\n connected_account_id?: string;\n requesting_account_id?: string;\n connection_id?: number;\n sequence_number: number;\n operator_id?: string;\n reason?: string;\n close_method?: string;\n}\n\nexport interface ProfileResponse {\n profile: any;\n topicInfo?: TopicInfo;\n success: boolean;\n error?: string;\n}\n\nexport abstract class HCS10BaseClient extends Registration {\n protected network: string;\n protected logger: Logger;\n protected mirrorNode: HederaMirrorNode;\n protected feeAmount: number;\n\n constructor(config: HCS10Config) {\n super();\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS10-BaseClient',\n prettyPrint: config.prettyPrint,\n });\n this.mirrorNode = new HederaMirrorNode(\n config.network as NetworkType,\n this.logger\n );\n this.feeAmount = config.feeAmount || 0.001;\n }\n\n abstract submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee?: boolean\n ): Promise<TransactionReceipt>;\n\n abstract getAccountAndSigner(): { accountId: string; signer: any };\n\n /**\n * Get a stream of messages from a connection topic\n * @param topicId The connection topic ID to get messages from\n * @returns A stream of filtered messages valid for connection topics\n */\n public async getMessageStream(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n const validOps = ['message', 'close_connection'];\n\n const filteredMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10' || !validOps.includes(msg.op)) {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n if (msg.op === 'close_connection') {\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n return true;\n });\n\n return {\n messages: filteredMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n public async canSubmitToTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n this.logger.error(\n `Key validation error: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * Get all messages from a topic\n * @param topicId The topic ID to get messages from\n * @returns All messages from the topic\n */\n public async getMessages(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n\n const validatedMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10') {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (msg.operator_id) {\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n }\n\n return true;\n });\n\n return {\n messages: validatedMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n public async requestAccount(account: string): Promise<AccountResponse> {\n try {\n return await this.mirrorNode.requestAccount(account);\n } catch (e) {\n this.logger.error('Failed to fetch account', e);\n throw e;\n }\n }\n\n public async getAccountMemo(accountId: string): Promise<string | null> {\n return await this.mirrorNode.getAccountMemo(accountId);\n }\n\n public async retrieveProfile(accountId: string): Promise<ProfileResponse> {\n this.logger.info(`Retrieving profile for account: ${accountId}`);\n\n try {\n const hcs11Client = new HCS11Client({\n network: this.network as 'mainnet' | 'testnet',\n auth: {\n operatorId: '0.0.0', // Read-only operations only\n },\n logLevel: 'info',\n });\n\n const profileResult = await hcs11Client.fetchProfileByAccountId(\n accountId,\n this.network\n );\n\n if (!profileResult?.success) {\n this.logger.error(\n `Failed to retrieve profile for account ID: ${accountId}`,\n profileResult?.error\n );\n return {\n profile: null,\n success: false,\n error:\n profileResult?.error ||\n `Failed to retrieve profile for account ID: ${accountId}`,\n };\n }\n\n const profile = profileResult.profile;\n let topicInfo = null;\n\n if (\n profileResult.topicInfo?.inboundTopic &&\n profileResult.topicInfo?.outboundTopic &&\n profileResult.topicInfo?.profileTopicId\n ) {\n topicInfo = {\n inboundTopic: profileResult.topicInfo.inboundTopic,\n outboundTopic: profileResult.topicInfo.outboundTopic,\n profileTopicId: profileResult.topicInfo.profileTopicId,\n };\n\n const cacheKey = `${accountId}-${this.network}`;\n HCS10Cache.getInstance().set(cacheKey, topicInfo);\n }\n\n return {\n profile,\n topicInfo,\n success: true,\n };\n } catch (error) {\n this.logger.error('Failed to retrieve profile:', error);\n return {\n profile: null,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n\n public async retrieveOutboundConnectTopic(\n accountId: string\n ): Promise<TopicInfo> {\n this.logger.info(`Retrieving topics for account: ${accountId}`);\n\n try {\n const profileResponse = await this.retrieveProfile(accountId);\n\n if (!profileResponse?.success) {\n throw new Error(profileResponse.error || 'Failed to retrieve profile');\n }\n\n const profile = profileResponse.profile;\n\n if (!profile.inboundTopicId || !profile.outboundTopicId) {\n throw new Error(\n `Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`\n );\n }\n\n const topicInfo = {\n inboundTopic: profile.inboundTopicId,\n outboundTopic: profile.outboundTopicId,\n profileTopicId: profile.profileTopicId,\n };\n\n const cacheKey = `${accountId}-${this.network}`;\n HCS10Cache.getInstance().set(cacheKey, topicInfo);\n return topicInfo;\n } catch (error) {\n this.logger.error('Failed to retrieve topic info:', error);\n throw error;\n }\n }\n\n public async retrieveOutboundMessages(\n agentAccountId: string\n ): Promise<HCSMessage[]> {\n try {\n const topicInfo = await this.retrieveOutboundConnectTopic(agentAccountId);\n if (!topicInfo) {\n this.logger.warn(\n `No outbound connect topic found for agentAccountId: ${agentAccountId}`\n );\n return [];\n }\n const response = await this.getMessages(topicInfo.outboundTopic);\n return response.messages.filter(\n (msg) =>\n msg.p === 'hcs-10' &&\n (msg.op === 'connection_request' ||\n msg.op === 'connection_created' ||\n msg.op === 'message')\n );\n } catch (error) {\n this.logger.error('Failed to retrieve outbound messages:', error);\n return [];\n }\n }\n\n public async hasConnectionCreated(\n agentAccountId: string,\n connectionId: number\n ): Promise<boolean> {\n try {\n const outBoundTopic = await this.retrieveOutboundConnectTopic(\n agentAccountId\n );\n const messages = await this.retrieveOutboundMessages(\n outBoundTopic.outboundTopic\n );\n return messages.some(\n (msg) =>\n msg.op === 'connection_created' && msg.connection_id === connectionId\n );\n } catch (error) {\n this.logger.error('Failed to check connection created:', error);\n return false;\n }\n }\n\n /**\n * Gets message content, resolving any HRL references if needed\n * @param data The message data which might be an HRL reference\n * @returns The resolved content\n */\n async getMessageContent(data: string): Promise<string> {\n const hrlPattern = /^hcs:\\/\\/(\\d+)\\/([0-9.]+)$/;\n const match = data.match(hrlPattern);\n\n if (!match) {\n return data;\n }\n\n const [_, standard, topicId] = match;\n\n this.logger.info(\n `Resolving HRL reference: standard=${standard}, topicId=${topicId}`\n );\n\n try {\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${this.network}`;\n const response = await axios.get(cdnUrl);\n\n if (!response.data) {\n throw new Error(`Failed to fetch content from topic: ${topicId}`);\n }\n\n return (\n response.data.content ||\n response.data.text ||\n JSON.stringify(response.data)\n );\n } catch (error) {\n this.logger.error(\n `Error resolving HRL reference: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n throw new Error(\n `Failed to resolve HRL reference: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n }\n\n /**\n * Records an outbound connection confirmation\n * @param outboundTopicId The ID of the outbound topic\n * @param connectionRequestId The ID of the connection request\n * @param confirmedRequestId The ID of the confirmed request\n * @param connectionTopicId The ID of the connection topic\n * @param operatorId The operator ID of the message sender\n * @param memo An optional memo for the message\n */\n public async recordOutboundConnectionConfirmation({\n outboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }): Promise<TransactionReceipt> {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n return await this.submitPayload(outboundTopicId, payload);\n }\n\n clearCache(): void {\n HCS10Cache.getInstance().clear();\n }\n\n /**\n * Generates a standard HCS-10 memo string.\n * @param type The type of topic memo ('inbound', 'outbound', 'connection').\n * @param options Configuration options for the memo.\n * @returns The formatted memo string.\n * @protected\n */\n protected _generateHcs10Memo(\n type: Hcs10MemoType,\n options: {\n ttl?: number;\n accountId?: string;\n inboundTopicId?: string;\n connectionId?: number;\n }\n ): string {\n const ttl = options.ttl ?? 60; // Default TTL to 60 if not provided\n\n switch (type) {\n case Hcs10MemoType.INBOUND:\n if (!options.accountId) {\n throw new Error('accountId is required for inbound memo');\n }\n return `hcs-10:0:${ttl}:0:${options.accountId}`;\n case Hcs10MemoType.OUTBOUND:\n return `hcs-10:0:${ttl}:1`;\n case Hcs10MemoType.CONNECTION:\n if (!options.inboundTopicId || options.connectionId === undefined) {\n throw new Error(\n 'inboundTopicId and connectionId are required for connection memo'\n );\n }\n return `hcs-10:1:${ttl}:2:${options.inboundTopicId}:${options.connectionId}`;\n default:\n throw new Error(`Invalid HCS-10 memo type: ${type}`);\n }\n }\n\n protected async checkRegistrationStatus(\n transactionId: string,\n network: string,\n baseUrl: string\n ): Promise<{ status: 'pending' | 'success' | 'failed' }> {\n try {\n const response = await fetch(`${baseUrl}/api/request-confirm`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Network': network,\n },\n body: JSON.stringify({ transaction_id: transactionId }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to confirm registration: ${response.statusText}`\n );\n }\n\n return await response.json();\n } catch (error) {\n this.logger.error(`Error checking registration status: ${error}`);\n throw error;\n }\n }\n\n /**\n * Validates if an operator_id follows the correct format (agentTopicId@accountId)\n * @param operatorId The operator ID to validate\n * @returns True if the format is valid, false otherwise\n */\n protected isValidOperatorId(operatorId: string): boolean {\n if (!operatorId) {\n return false;\n }\n\n const parts = operatorId.split('@');\n\n if (parts.length !== 2) {\n return false;\n }\n\n const agentTopicId = parts[0];\n const accountId = parts[1];\n\n if (!agentTopicId) {\n return false;\n }\n\n if (!accountId) {\n return false;\n }\n\n const hederaIdPattern = /^[0-9]+\\.[0-9]+\\.[0-9]+$/;\n\n if (!hederaIdPattern.test(accountId)) {\n return false;\n }\n\n if (!hederaIdPattern.test(agentTopicId)) {\n return false;\n }\n\n return true;\n }\n}\n\nexport class HCS10Cache {\n private static instance: HCS10Cache;\n private cache: Map<string, TopicInfo>;\n private cacheExpiry: Map<string, number>;\n private readonly CACHE_TTL = 3600000;\n\n private constructor() {\n this.cache = new Map();\n this.cacheExpiry = new Map();\n }\n\n static getInstance(): HCS10Cache {\n if (!HCS10Cache.instance) {\n HCS10Cache.instance = new HCS10Cache();\n }\n return HCS10Cache.instance;\n }\n\n set(key: string, value: TopicInfo): void {\n this.cache.set(key, value);\n this.cacheExpiry.set(key, Date.now() + this.CACHE_TTL);\n }\n\n get(key: string): TopicInfo | undefined {\n const expiry = this.cacheExpiry.get(key);\n if (expiry && expiry > Date.now()) {\n return this.cache.get(key);\n }\n if (expiry) {\n this.cache.delete(key);\n this.cacheExpiry.delete(key);\n }\n return undefined;\n }\n\n clear(): void {\n this.cache.clear();\n this.cacheExpiry.clear();\n }\n}\n"],"names":["Hcs10MemoType"],"mappings":";;;;;;;;AASY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,SAAU,IAAA;AACVA,iBAAA,UAAW,IAAA;AACXA,iBAAA,YAAa,IAAA;AAHHA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AA6CL,MA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YAAY,MAAM,CAAC;AAEzB,QAAI,CAAC,cAAc;AACV,aAAA;AAAA,IAAA;AAGT,QAAI,CAAC,WAAW;AACP,aAAA;AAAA,IAAA;AAGT,UAAM,kBAAkB;AAExB,QAAI,CAAC,gBAAgB,KAAK,SAAS,GAAG;AAC7B,aAAA;AAAA,IAAA;AAGT,QAAI,CAAC,gBAAgB,KAAK,YAAY,GAAG;AAChC,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EAAA;AAEX;AAEO,MAAM,WAAW;AAAA,EAMd,cAAc;AAFtB,SAAiB,YAAY;AAGtB,SAAA,4BAAY,IAAI;AAChB,SAAA,kCAAkB,IAAI;AAAA,EAAA;AAAA,EAG7B,OAAO,cAA0B;AAC3B,QAAA,CAAC,WAAW,UAAU;AACb,iBAAA,WAAW,IAAI,WAAW;AAAA,IAAA;AAEvC,WAAO,WAAW;AAAA,EAAA;AAAA,EAGpB,IAAI,KAAa,OAAwB;AAClC,SAAA,MAAM,IAAI,KAAK,KAAK;AACzB,SAAK,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,SAAS;AAAA,EAAA;AAAA,EAGvD,IAAI,KAAoC;AACtC,UAAM,SAAS,KAAK,YAAY,IAAI,GAAG;AACvC,QAAI,UAAU,SAAS,KAAK,IAAA,GAAO;AAC1B,aAAA,KAAK,MAAM,IAAI,GAAG;AAAA,IAAA;AAE3B,QAAI,QAAQ;AACL,WAAA,MAAM,OAAO,GAAG;AAChB,WAAA,YAAY,OAAO,GAAG;AAAA,IAAA;AAEtB,WAAA;AAAA,EAAA;AAAA,EAGT,QAAc;AACZ,SAAK,MAAM,MAAM;AACjB,SAAK,YAAY,MAAM;AAAA,EAAA;AAE3B;"}
@@ -1,13 +1,30 @@
1
- import isAbsoluteURL from "./standards-sdk.es95.js";
2
- import combineURLs from "./standards-sdk.es96.js";
3
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
4
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
5
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
6
- return combineURLs(baseURL, requestedURL);
1
+ function number(n) {
2
+ if (!Number.isSafeInteger(n) || n < 0)
3
+ throw new Error(`Wrong positive integer: ${n}`);
4
+ }
5
+ function bytes(b, ...lengths) {
6
+ if (!(b instanceof Uint8Array))
7
+ throw new Error("Expected Uint8Array");
8
+ if (lengths.length > 0 && !lengths.includes(b.length))
9
+ throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
10
+ }
11
+ function exists(instance, checkFinished = true) {
12
+ if (instance.destroyed)
13
+ throw new Error("Hash instance has been destroyed");
14
+ if (checkFinished && instance.finished)
15
+ throw new Error("Hash#digest() has already been called");
16
+ }
17
+ function output(out, instance) {
18
+ bytes(out);
19
+ const min = instance.outputLen;
20
+ if (out.length < min) {
21
+ throw new Error(`digestInto() expects output buffer of length at least ${min}`);
7
22
  }
8
- return requestedURL;
9
23
  }
10
24
  export {
11
- buildFullPath as default
25
+ bytes,
26
+ exists,
27
+ number,
28
+ output
12
29
  };
13
30
  //# sourceMappingURL=standards-sdk.es80.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es80.js","sources":["../../node_modules/axios/lib/core/buildFullPath.js"],"sourcesContent":["'use strict';\n\nimport isAbsoluteURL from '../helpers/isAbsoluteURL.js';\nimport combineURLs from '../helpers/combineURLs.js';\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n *\n * @returns {string} The combined full path\n */\nexport default function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {\n let isRelativeUrl = !isAbsoluteURL(requestedURL);\n if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n}\n"],"names":[],"mappings":";;AAee,SAAS,cAAc,SAAS,cAAc,mBAAmB;AAC9E,MAAI,gBAAgB,CAAC,cAAc,YAAY;AAC/C,MAAI,YAAY,iBAAiB,qBAAqB,QAAQ;AAC5D,WAAO,YAAY,SAAS,YAAY;AAAA,EAC5C;AACE,SAAO;AACT;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"standards-sdk.es80.js","sources":["../../node_modules/@noble/hashes/esm/_assert.js"],"sourcesContent":["function number(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error(`Wrong positive integer: ${n}`);\n}\nfunction bool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`Expected boolean, not ${b}`);\n}\nfunction bytes(b, ...lengths) {\n if (!(b instanceof Uint8Array))\n throw new Error('Expected Uint8Array');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);\n}\nfunction hash(hash) {\n if (typeof hash !== 'function' || typeof hash.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(hash.outputLen);\n number(hash.blockLen);\n}\nfunction exists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction output(out, instance) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\nexport { number, bool, bytes, hash, exists, output };\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n//# sourceMappingURL=_assert.js.map"],"names":[],"mappings":"AAAA,SAAS,OAAO,GAAG;AACf,MAAI,CAAC,OAAO,cAAc,CAAC,KAAK,IAAI;AAChC,UAAM,IAAI,MAAM,2BAA2B,CAAC,EAAE;AACtD;AAKA,SAAS,MAAM,MAAM,SAAS;AAC1B,MAAI,EAAE,aAAa;AACf,UAAM,IAAI,MAAM,qBAAqB;AACzC,MAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,SAAS,EAAE,MAAM;AAChD,UAAM,IAAI,MAAM,iCAAiC,OAAO,mBAAmB,EAAE,MAAM,EAAE;AAC7F;AAOA,SAAS,OAAO,UAAU,gBAAgB,MAAM;AAC5C,MAAI,SAAS;AACT,UAAM,IAAI,MAAM,kCAAkC;AACtD,MAAI,iBAAiB,SAAS;AAC1B,UAAM,IAAI,MAAM,uCAAuC;AAC/D;AACA,SAAS,OAAO,KAAK,UAAU;AAC3B,QAAM,GAAG;AACT,QAAM,MAAM,SAAS;AACrB,MAAI,IAAI,SAAS,KAAK;AAClB,UAAM,IAAI,MAAM,yDAAyD,GAAG,EAAE;AAAA,EACtF;AACA;","x_google_ignoreList":[0]}