@hashgraphonline/standards-sdk 0.0.51 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/hcs-10/base-client.d.ts +56 -1
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/browser.d.ts +9 -20
- package/dist/es/hcs-10/browser.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +7 -79
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-10/types.d.ts +7 -0
- package/dist/es/hcs-10/types.d.ts.map +1 -1
- package/dist/es/hcs-11/index.d.ts +1 -1
- package/dist/es/hcs-11/index.d.ts.map +1 -1
- package/dist/es/inscribe/types.d.ts +1 -1
- package/dist/es/inscribe/types.d.ts.map +1 -1
- package/dist/es/services/mirror-node.d.ts.map +1 -1
- package/dist/es/standards-sdk.es10.js +122 -115
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +1 -1
- package/dist/es/standards-sdk.es102.js +6 -6
- package/dist/es/standards-sdk.es103.js +3 -3
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es111.js +2 -2
- package/dist/es/standards-sdk.es12.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es17.js +1 -3
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +948 -6531
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +17 -17
- package/dist/es/standards-sdk.es24.js +6624 -2
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +5 -1041
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +2 -5
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +1 -1
- package/dist/es/standards-sdk.es30.js +2 -2
- package/dist/es/standards-sdk.es31.js +2282 -419
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +2 -2
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +412 -113
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +2 -2282
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +120 -2
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +2 -29
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +29 -2
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +346 -68
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +5 -22
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +166 -135
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +72 -82
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +105 -165
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +47 -190
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +10 -438
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +91 -19
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +3 -138
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +2 -18
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +105 -22
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +71 -26
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +112 -444
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +5 -20
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +4 -43
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +216 -13
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +54 -57
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +67 -1287
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +190 -27
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +437 -5
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +21 -155
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +123 -777
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +13 -138
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +26 -24
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +27 -24
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +19 -36
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +39 -357
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +17 -5
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +50 -168
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +1287 -79
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +136 -102
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +85 -46
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +84 -10
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es70.js +26 -91
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +5 -3
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +159 -2
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +21 -110
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +790 -71
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +142 -5
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +173 -4
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +26 -215
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +60 -55
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +50 -69
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +167 -0
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/dist/es/standards-sdk.es80.js +9 -20
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +60 -27
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +6 -63
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +12 -47
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +7 -10
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +41 -61
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +2 -6
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +134 -13
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +171 -6
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +21 -45
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +27 -2
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +26 -136
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +38 -172
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +1 -1
- package/dist/es/standards-sdk.es94.js +3 -3
- package/dist/es/standards-sdk.es99.js +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +56 -1
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/hcs-10/browser.d.ts +9 -20
- package/dist/umd/hcs-10/browser.d.ts.map +1 -1
- package/dist/umd/hcs-10/sdk.d.ts +7 -79
- package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
- package/dist/umd/hcs-10/types.d.ts +7 -0
- package/dist/umd/hcs-10/types.d.ts.map +1 -1
- package/dist/umd/hcs-11/index.d.ts +1 -1
- package/dist/umd/hcs-11/index.d.ts.map +1 -1
- package/dist/umd/inscribe/types.d.ts +1 -1
- package/dist/umd/inscribe/types.d.ts.map +1 -1
- package/dist/umd/services/mirror-node.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { Logger } from "./standards-sdk.es13.js";
|
|
|
3
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
|
+
import { PublicKey } from "@hashgraph/sdk";
|
|
6
7
|
import axios from "./standards-sdk.es23.js";
|
|
7
8
|
class HCS10BaseClient extends Registration {
|
|
8
9
|
constructor(config) {
|
|
@@ -17,6 +18,143 @@ class HCS10BaseClient extends Registration {
|
|
|
17
18
|
config.network,
|
|
18
19
|
this.logger
|
|
19
20
|
);
|
|
21
|
+
this.feeAmount = config.feeAmount || 5;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a user can submit to a topic and determines if a fee is required
|
|
25
|
+
* @param topicId The topic ID to check
|
|
26
|
+
* @param userAccountId The account ID of the user attempting to submit
|
|
27
|
+
* @returns Object with canSubmit, requiresFee, and optional reason
|
|
28
|
+
*/
|
|
29
|
+
async canSubmitToInboundTopic(topicId, userAccountId) {
|
|
30
|
+
try {
|
|
31
|
+
const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
|
|
32
|
+
if (!topicInfo) {
|
|
33
|
+
return {
|
|
34
|
+
canSubmit: false,
|
|
35
|
+
requiresFee: false,
|
|
36
|
+
reason: "Topic does not exist"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (!topicInfo.submit_key?.key) {
|
|
40
|
+
return { canSubmit: true, requiresFee: false };
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);
|
|
44
|
+
if (topicInfo.submit_key._type === "ProtobufEncoded") {
|
|
45
|
+
const keyBytes = Buffer.from(topicInfo.submit_key.key, "hex");
|
|
46
|
+
const hasAccess = await this.mirrorNode.checkKeyListAccess(
|
|
47
|
+
keyBytes,
|
|
48
|
+
userPublicKey
|
|
49
|
+
);
|
|
50
|
+
if (hasAccess) {
|
|
51
|
+
return { canSubmit: true, requiresFee: false };
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);
|
|
55
|
+
if (userPublicKey.toString() === topicSubmitKey.toString()) {
|
|
56
|
+
return { canSubmit: true, requiresFee: false };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} 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}`);
|
|
65
|
+
}
|
|
66
|
+
if (topicInfo.fee_schedule_key?.key && topicInfo.custom_fees?.fixed_fees?.length > 0) {
|
|
67
|
+
return {
|
|
68
|
+
canSubmit: true,
|
|
69
|
+
requiresFee: true,
|
|
70
|
+
reason: "Requires fee payment via HIP-991"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
canSubmit: false,
|
|
75
|
+
requiresFee: false,
|
|
76
|
+
reason: "User does not have submit permission for this topic"
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
let errorMessage = String(error);
|
|
80
|
+
if (error instanceof Error) {
|
|
81
|
+
errorMessage = error.message;
|
|
82
|
+
}
|
|
83
|
+
this.logger.error(`Topic submission validation error: ${errorMessage}`);
|
|
84
|
+
return {
|
|
85
|
+
canSubmit: false,
|
|
86
|
+
requiresFee: false,
|
|
87
|
+
reason: `Error: ${errorMessage}`
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
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
|
+
);
|
|
20
158
|
}
|
|
21
159
|
/**
|
|
22
160
|
* Get a stream of messages from a connection topic
|
|
@@ -303,6 +441,35 @@ class HCS10BaseClient extends Registration {
|
|
|
303
441
|
);
|
|
304
442
|
}
|
|
305
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* Records an outbound connection confirmation
|
|
446
|
+
* @param outboundTopicId The ID of the outbound topic
|
|
447
|
+
* @param connectionRequestId The ID of the connection request
|
|
448
|
+
* @param confirmedRequestId The ID of the confirmed request
|
|
449
|
+
* @param connectionTopicId The ID of the connection topic
|
|
450
|
+
* @param operatorId The operator ID of the message sender
|
|
451
|
+
* @param memo An optional memo for the message
|
|
452
|
+
*/
|
|
453
|
+
async recordOutboundConnectionConfirmation({
|
|
454
|
+
outboundTopicId,
|
|
455
|
+
connectionRequestId,
|
|
456
|
+
confirmedRequestId,
|
|
457
|
+
connectionTopicId,
|
|
458
|
+
operatorId,
|
|
459
|
+
memo
|
|
460
|
+
}) {
|
|
461
|
+
const payload = {
|
|
462
|
+
p: "hcs-10",
|
|
463
|
+
op: "connection_created",
|
|
464
|
+
connection_topic_id: connectionTopicId,
|
|
465
|
+
outbound_topic_id: outboundTopicId,
|
|
466
|
+
confirmed_request_id: confirmedRequestId,
|
|
467
|
+
connection_request_id: connectionRequestId,
|
|
468
|
+
operator_id: operatorId,
|
|
469
|
+
m: memo
|
|
470
|
+
};
|
|
471
|
+
return await this.submitPayload(outboundTopicId, payload);
|
|
472
|
+
}
|
|
306
473
|
}
|
|
307
474
|
class HCS10Cache {
|
|
308
475
|
constructor() {
|
|
@@ -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';\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\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 }\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 * 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\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":";;;;;;AA8CO,MAAe,wBAAwB,aAAa;AAAA,E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,CAAC,SAAS,MAAM;AAClB,cAAM,IAAI,MAAM,uCAAuC,OAAO,EAAE;AAAA,MAAA;AAIhE,aAAA,SAAS,KAAK,WACd,SAAS,KAAK,QACd,KAAK,UAAU,SAAS,IAAI;AAAA,aAEvB,OAAO;AACd,WAAK,OAAO;AAAA,QACV,kCACE,iBAAiB,QAAQ,MAAM,UAAU,eAC3C;AAAA,MACF;AACA,YAAM,IAAI;AAAA,QACR,oCACE,iBAAiB,QAAQ,MAAM,UAAU,eAC3C;AAAA,MACF;AAAA,IAAA;AAAA,EACF;AAEJ;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 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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M,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,24 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.coder = coder;
|
|
10
|
-
}
|
|
11
|
-
defaultValue() {
|
|
12
|
-
return this.coder.defaultValue();
|
|
13
|
-
}
|
|
14
|
-
encode(writer, value) {
|
|
15
|
-
return this.coder.encode(writer, value);
|
|
16
|
-
}
|
|
17
|
-
decode(reader) {
|
|
18
|
-
return this.coder.decode(reader);
|
|
19
|
-
}
|
|
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);
|
|
7
|
+
}
|
|
8
|
+
return requestedURL;
|
|
20
9
|
}
|
|
21
10
|
export {
|
|
22
|
-
|
|
11
|
+
buildFullPath as default
|
|
23
12
|
};
|
|
24
13
|
//# sourceMappingURL=standards-sdk.es80.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es80.js","sources":["../../node_modules/
|
|
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,35 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
serialize: options
|
|
14
|
-
};
|
|
1
|
+
import { VERSION } from "./standards-sdk.es47.js";
|
|
2
|
+
import AxiosError from "./standards-sdk.es49.js";
|
|
3
|
+
const validators = {};
|
|
4
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
5
|
+
validators[type] = function validator2(thing) {
|
|
6
|
+
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
7
|
+
};
|
|
8
|
+
});
|
|
9
|
+
const deprecatedWarnings = {};
|
|
10
|
+
validators.transitional = function transitional(validator2, version, message) {
|
|
11
|
+
function formatMessage(opt, desc) {
|
|
12
|
+
return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
return (value, opt, opts) => {
|
|
15
|
+
if (validator2 === false) {
|
|
16
|
+
throw new AxiosError(
|
|
17
|
+
formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
|
|
18
|
+
AxiosError.ERR_DEPRECATED
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (version && !deprecatedWarnings[opt]) {
|
|
22
|
+
deprecatedWarnings[opt] = true;
|
|
23
|
+
console.warn(
|
|
24
|
+
formatMessage(
|
|
25
|
+
opt,
|
|
26
|
+
" has been deprecated since v" + version + " and will be removed in the near future"
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return validator2 ? validator2(value, opt, opts) : true;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
validators.spelling = function spelling(correctSpelling) {
|
|
34
|
+
return (value, opt) => {
|
|
35
|
+
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
function assertOptions(options, schema, allowUnknown) {
|
|
40
|
+
if (typeof options !== "object") {
|
|
41
|
+
throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE);
|
|
22
42
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
const keys = Object.keys(options);
|
|
44
|
+
let i = keys.length;
|
|
45
|
+
while (i-- > 0) {
|
|
46
|
+
const opt = keys[i];
|
|
47
|
+
const validator2 = schema[opt];
|
|
48
|
+
if (validator2) {
|
|
49
|
+
const value = options[opt];
|
|
50
|
+
const result = value === void 0 || validator2(value, opt, options);
|
|
51
|
+
if (result !== true) {
|
|
52
|
+
throw new AxiosError("option " + opt + " must be " + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (allowUnknown !== true) {
|
|
57
|
+
throw new AxiosError("Unknown option " + opt, AxiosError.ERR_BAD_OPTION);
|
|
27
58
|
}
|
|
28
|
-
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
29
59
|
}
|
|
30
|
-
return url;
|
|
31
60
|
}
|
|
61
|
+
const validator = {
|
|
62
|
+
assertOptions,
|
|
63
|
+
validators
|
|
64
|
+
};
|
|
32
65
|
export {
|
|
33
|
-
|
|
66
|
+
validator as default
|
|
34
67
|
};
|
|
35
68
|
//# sourceMappingURL=standards-sdk.es81.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es81.js","sources":["../../node_modules/axios/lib/helpers/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es81.js","sources":["../../node_modules/axios/lib/helpers/validator.js"],"sourcesContent":["'use strict';\n\nimport {VERSION} from '../env/data.js';\nimport AxiosError from '../core/AxiosError.js';\n\nconst validators = {};\n\n// eslint-disable-next-line func-names\n['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {\n validators[type] = function validator(thing) {\n return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;\n };\n});\n\nconst deprecatedWarnings = {};\n\n/**\n * Transitional option validator\n *\n * @param {function|boolean?} validator - set to false if the transitional option has been removed\n * @param {string?} version - deprecated version / removed since version\n * @param {string?} message - some message with additional info\n *\n * @returns {function}\n */\nvalidators.transitional = function transitional(validator, version, message) {\n function formatMessage(opt, desc) {\n return '[Axios v' + VERSION + '] Transitional option \\'' + opt + '\\'' + desc + (message ? '. ' + message : '');\n }\n\n // eslint-disable-next-line func-names\n return (value, opt, opts) => {\n if (validator === false) {\n throw new AxiosError(\n formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),\n AxiosError.ERR_DEPRECATED\n );\n }\n\n if (version && !deprecatedWarnings[opt]) {\n deprecatedWarnings[opt] = true;\n // eslint-disable-next-line no-console\n console.warn(\n formatMessage(\n opt,\n ' has been deprecated since v' + version + ' and will be removed in the near future'\n )\n );\n }\n\n return validator ? validator(value, opt, opts) : true;\n };\n};\n\nvalidators.spelling = function spelling(correctSpelling) {\n return (value, opt) => {\n // eslint-disable-next-line no-console\n console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);\n return true;\n }\n};\n\n/**\n * Assert object's properties type\n *\n * @param {object} options\n * @param {object} schema\n * @param {boolean?} allowUnknown\n *\n * @returns {object}\n */\n\nfunction assertOptions(options, schema, allowUnknown) {\n if (typeof options !== 'object') {\n throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);\n }\n const keys = Object.keys(options);\n let i = keys.length;\n while (i-- > 0) {\n const opt = keys[i];\n const validator = schema[opt];\n if (validator) {\n const value = options[opt];\n const result = value === undefined || validator(value, opt, options);\n if (result !== true) {\n throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);\n }\n continue;\n }\n if (allowUnknown !== true) {\n throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);\n }\n }\n}\n\nexport default {\n assertOptions,\n validators\n};\n"],"names":["validator"],"mappings":";;AAKA,MAAM,aAAa,CAAE;AAGrB,CAAC,UAAU,WAAW,UAAU,YAAY,UAAU,QAAQ,EAAE,QAAQ,CAAC,MAAM,MAAM;AACnF,aAAW,IAAI,IAAI,SAASA,WAAU,OAAO;AAC3C,WAAO,OAAO,UAAU,QAAQ,OAAO,IAAI,IAAI,OAAO,OAAO;AAAA,EAC9D;AACH,CAAC;AAED,MAAM,qBAAqB,CAAE;AAW7B,WAAW,eAAe,SAAS,aAAaA,YAAW,SAAS,SAAS;AAC3E,WAAS,cAAc,KAAK,MAAM;AAChC,WAAO,aAAa,UAAU,4BAA6B,MAAM,MAAO,QAAQ,UAAU,OAAO,UAAU;AAAA,E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@@ -1,66 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Add a new interceptor to the stack
|
|
8
|
-
*
|
|
9
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
10
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
11
|
-
*
|
|
12
|
-
* @return {Number} An ID used to remove interceptor later
|
|
13
|
-
*/
|
|
14
|
-
use(fulfilled, rejected, options) {
|
|
15
|
-
this.handlers.push({
|
|
16
|
-
fulfilled,
|
|
17
|
-
rejected,
|
|
18
|
-
synchronous: options ? options.synchronous : false,
|
|
19
|
-
runWhen: options ? options.runWhen : null
|
|
20
|
-
});
|
|
21
|
-
return this.handlers.length - 1;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Remove an interceptor from the stack
|
|
25
|
-
*
|
|
26
|
-
* @param {Number} id The ID that was returned by `use`
|
|
27
|
-
*
|
|
28
|
-
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
29
|
-
*/
|
|
30
|
-
eject(id) {
|
|
31
|
-
if (this.handlers[id]) {
|
|
32
|
-
this.handlers[id] = null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Clear all interceptors from the stack
|
|
37
|
-
*
|
|
38
|
-
* @returns {void}
|
|
39
|
-
*/
|
|
40
|
-
clear() {
|
|
41
|
-
if (this.handlers) {
|
|
42
|
-
this.handlers = [];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Iterate over all the registered interceptors
|
|
47
|
-
*
|
|
48
|
-
* This method is particularly useful for skipping over any
|
|
49
|
-
* interceptors that may have become `null` calling `eject`.
|
|
50
|
-
*
|
|
51
|
-
* @param {Function} fn The function to call for each interceptor
|
|
52
|
-
*
|
|
53
|
-
* @returns {void}
|
|
54
|
-
*/
|
|
55
|
-
forEach(fn) {
|
|
56
|
-
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
57
|
-
if (h !== null) {
|
|
58
|
-
fn(h);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
const transitionalDefaults = {
|
|
2
|
+
silentJSONParsing: true,
|
|
3
|
+
forcedJSONParsing: true,
|
|
4
|
+
clarifyTimeoutError: false
|
|
5
|
+
};
|
|
63
6
|
export {
|
|
64
|
-
|
|
7
|
+
transitionalDefaults as default
|
|
65
8
|
};
|
|
66
9
|
//# sourceMappingURL=standards-sdk.es82.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es82.js","sources":["../../node_modules/axios/lib/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es82.js","sources":["../../node_modules/axios/lib/defaults/transitional.js"],"sourcesContent":["'use strict';\n\nexport default {\n silentJSONParsing: true,\n forcedJSONParsing: true,\n clarifyTimeoutError: false\n};\n"],"names":[],"mappings":"AAEA,MAAe,uBAAA;AAAA,EACb,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,qBAAqB;AACvB;","x_google_ignoreList":[0]}
|
|
@@ -1,53 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
if (config.signal && config.signal.aborted) {
|
|
12
|
-
throw new CanceledError(null, config);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function dispatchRequest(config) {
|
|
16
|
-
throwIfCancellationRequested(config);
|
|
17
|
-
config.headers = AxiosHeaders.from(config.headers);
|
|
18
|
-
config.data = transformData.call(
|
|
19
|
-
config,
|
|
20
|
-
config.transformRequest
|
|
21
|
-
);
|
|
22
|
-
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
|
23
|
-
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
24
|
-
}
|
|
25
|
-
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
|
26
|
-
return adapter(config).then(function onAdapterResolution(response) {
|
|
27
|
-
throwIfCancellationRequested(config);
|
|
28
|
-
response.data = transformData.call(
|
|
29
|
-
config,
|
|
30
|
-
config.transformResponse,
|
|
31
|
-
response
|
|
32
|
-
);
|
|
33
|
-
response.headers = AxiosHeaders.from(response.headers);
|
|
34
|
-
return response;
|
|
35
|
-
}, function onAdapterRejection(reason) {
|
|
36
|
-
if (!isCancel(reason)) {
|
|
37
|
-
throwIfCancellationRequested(config);
|
|
38
|
-
if (reason && reason.response) {
|
|
39
|
-
reason.response.data = transformData.call(
|
|
40
|
-
config,
|
|
41
|
-
config.transformResponse,
|
|
42
|
-
reason.response
|
|
43
|
-
);
|
|
44
|
-
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
1
|
+
import utils from "./standards-sdk.es38.js";
|
|
2
|
+
import toFormData from "./standards-sdk.es48.js";
|
|
3
|
+
import platform from "./standards-sdk.es84.js";
|
|
4
|
+
function toURLEncodedForm(data, options) {
|
|
5
|
+
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
6
|
+
visitor: function(value, key, path, helpers) {
|
|
7
|
+
if (platform.isNode && utils.isBuffer(value)) {
|
|
8
|
+
this.append(key, value.toString("base64"));
|
|
9
|
+
return false;
|
|
45
10
|
}
|
|
11
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
46
12
|
}
|
|
47
|
-
|
|
48
|
-
});
|
|
13
|
+
}, options));
|
|
49
14
|
}
|
|
50
15
|
export {
|
|
51
|
-
|
|
16
|
+
toURLEncodedForm as default
|
|
52
17
|
};
|
|
53
18
|
//# sourceMappingURL=standards-sdk.es83.js.map
|