@hashgraphonline/standards-sdk 0.1.168 → 0.1.169
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/README.md +1 -0
- package/dist/browser/hcs-11/client.d.ts.map +1 -1
- package/dist/browser/hcs-21/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-27/base-client.d.ts +41 -0
- package/dist/browser/hcs-27/base-client.d.ts.map +1 -0
- package/dist/browser/hcs-27/index.d.ts +6 -0
- package/dist/browser/hcs-27/index.d.ts.map +1 -0
- package/dist/browser/hcs-27/memos.d.ts +5 -0
- package/dist/browser/hcs-27/memos.d.ts.map +1 -0
- package/dist/browser/hcs-27/merkle.d.ts +23 -0
- package/dist/browser/hcs-27/merkle.d.ts.map +1 -0
- package/dist/browser/hcs-27/sdk.d.ts +23 -0
- package/dist/browser/hcs-27/sdk.d.ts.map +1 -0
- package/dist/browser/hcs-27/types.d.ts +1611 -0
- package/dist/browser/hcs-27/types.d.ts.map +1 -0
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +29 -5
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser/utils/key-type-detector.d.ts.map +1 -1
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-27/base-client.d.ts +41 -0
- package/dist/cjs/hcs-27/base-client.d.ts.map +1 -0
- package/dist/cjs/hcs-27/index.d.ts +6 -0
- package/dist/cjs/hcs-27/index.d.ts.map +1 -0
- package/dist/cjs/hcs-27/memos.d.ts +5 -0
- package/dist/cjs/hcs-27/memos.d.ts.map +1 -0
- package/dist/cjs/hcs-27/merkle.d.ts +23 -0
- package/dist/cjs/hcs-27/merkle.d.ts.map +1 -0
- package/dist/cjs/hcs-27/sdk.d.ts +23 -0
- package/dist/cjs/hcs-27/sdk.d.ts.map +1 -0
- package/dist/cjs/hcs-27/types.d.ts +1611 -0
- package/dist/cjs/hcs-27/types.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/cjs/utils/key-type-detector.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-27/base-client.d.ts +41 -0
- package/dist/es/hcs-27/base-client.d.ts.map +1 -0
- package/dist/es/hcs-27/index.d.ts +6 -0
- package/dist/es/hcs-27/index.d.ts.map +1 -0
- package/dist/es/hcs-27/memos.d.ts +5 -0
- package/dist/es/hcs-27/memos.d.ts.map +1 -0
- package/dist/es/hcs-27/merkle.d.ts +23 -0
- package/dist/es/hcs-27/merkle.d.ts.map +1 -0
- package/dist/es/hcs-27/sdk.d.ts +23 -0
- package/dist/es/hcs-27/sdk.d.ts.map +1 -0
- package/dist/es/hcs-27/types.d.ts +1611 -0
- package/dist/es/hcs-27/types.d.ts.map +1 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +67 -38
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +2 -2
- package/dist/es/standards-sdk.es103.js +2 -2
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es106.js +1 -1
- package/dist/es/standards-sdk.es108.js +2 -2
- package/dist/es/standards-sdk.es11.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es111.js +2 -2
- package/dist/es/standards-sdk.es112.js +151 -234
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +20 -471
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +263 -104
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +167 -138
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +315 -29
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +250 -10
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +448 -152
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +101 -25
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es120.js +155 -17
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +29 -155
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +9 -200
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +146 -754
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +27 -11
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +19 -564
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +140 -582
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +202 -12
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +790 -2
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +10 -84
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +567 -40
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +626 -2
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +12 -234
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +2 -1140
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +73 -292
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +36 -418
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +2 -355
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +198 -1079
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +1107 -175
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +218 -1479
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es14.js +1 -1
- package/dist/es/standards-sdk.es140.js +422 -1500
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +351 -13
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +1102 -73
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +203 -76
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +1459 -830
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +1499 -59
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +14 -156
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +87 -7
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +74 -79
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +934 -61
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es150.js +60 -30
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +159 -34
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +7 -48
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +70 -122
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +58 -35
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +30 -56
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +34 -84
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +48 -81
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +124 -186
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +34 -12474
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +5 -5
- package/dist/es/standards-sdk.es160.js +12477 -12
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +15 -71
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +48 -542
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +72 -160
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +71 -312
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +187 -333
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +538 -441
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +65 -323
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +162 -66
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +310 -160
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +336 -212
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +437 -223
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +324 -112
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +65 -115
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +151 -140
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +193 -156
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +221 -121
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +81 -293
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +114 -247
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +119 -110
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +12 -12
- package/dist/es/standards-sdk.es180.js +188 -0
- package/dist/es/standards-sdk.es180.js.map +1 -0
- package/dist/es/standards-sdk.es181.js +142 -0
- package/dist/es/standards-sdk.es181.js.map +1 -0
- package/dist/es/standards-sdk.es182.js +334 -0
- package/dist/es/standards-sdk.es182.js.map +1 -0
- package/dist/es/standards-sdk.es183.js +262 -0
- package/dist/es/standards-sdk.es183.js.map +1 -0
- package/dist/es/standards-sdk.es184.js +155 -0
- package/dist/es/standards-sdk.es184.js.map +1 -0
- package/dist/es/standards-sdk.es19.js +9 -9
- package/dist/es/standards-sdk.es2.js +2 -2
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es21.js +1 -1
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es24.js +1 -1
- package/dist/es/standards-sdk.es25.js +1 -1
- package/dist/es/standards-sdk.es26.js +1 -1
- package/dist/es/standards-sdk.es27.js +12 -12
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +2 -2
- package/dist/es/standards-sdk.es31.js +4 -4
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es35.js +6 -6
- package/dist/es/standards-sdk.es36.js +4 -4
- package/dist/es/standards-sdk.es37.js +2 -2
- package/dist/es/standards-sdk.es38.js +2 -2
- package/dist/es/standards-sdk.es39.js +1 -1
- package/dist/es/standards-sdk.es4.js +2 -2
- package/dist/es/standards-sdk.es40.js +1 -1
- package/dist/es/standards-sdk.es41.js +2 -2
- package/dist/es/standards-sdk.es46.js +1 -1
- package/dist/es/standards-sdk.es5.js +2 -2
- package/dist/es/standards-sdk.es51.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es56.js +2 -2
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es6.js +2 -2
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es67.js +7 -7
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es71.js +2 -2
- package/dist/es/standards-sdk.es72.js +3 -3
- package/dist/es/standards-sdk.es75.js +5 -5
- package/dist/es/standards-sdk.es76.js +3 -3
- package/dist/es/standards-sdk.es77.js +2 -2
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es81.js +2 -2
- package/dist/es/standards-sdk.es83.js +2 -2
- package/dist/es/standards-sdk.es84.js +4 -4
- package/dist/es/standards-sdk.es85.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es89.js +2 -2
- package/dist/es/standards-sdk.es9.js +2 -2
- package/dist/es/standards-sdk.es90.js +4 -4
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +3 -3
- package/dist/es/standards-sdk.es96.js +2 -2
- package/dist/es/standards-sdk.es98.js +1 -1
- package/dist/es/standards-sdk.es99.js +3 -3
- package/dist/es/utils/key-type-detector.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,175 +1,325 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { proto } from "@hashgraph/proto";
|
|
2
|
+
import { Long } from "@hashgraph/sdk";
|
|
3
|
+
import { hasTransactionType, parseKey } from "./standards-sdk.es173.js";
|
|
2
4
|
import { Buffer } from "buffer";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
5
|
+
class FileParser {
|
|
6
|
+
/**
|
|
7
|
+
* Parse File Service transaction using unified dual-branch approach
|
|
8
|
+
* This handles both regular transactions and signed transaction variants
|
|
9
|
+
*/
|
|
10
|
+
static parseFileTransaction(transaction, originalBytes) {
|
|
11
|
+
try {
|
|
12
|
+
if (originalBytes || transaction.toBytes) {
|
|
13
|
+
try {
|
|
14
|
+
const bytesToParse = originalBytes || transaction.toBytes();
|
|
15
|
+
const decoded = proto.TransactionList.decode(bytesToParse);
|
|
16
|
+
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
17
|
+
const tx = decoded.transactionList[0];
|
|
18
|
+
let txBody = null;
|
|
19
|
+
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
20
|
+
txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
21
|
+
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
22
|
+
const signedTx = proto.SignedTransaction.decode(
|
|
23
|
+
tx.signedTransactionBytes
|
|
24
|
+
);
|
|
25
|
+
if (signedTx.bodyBytes) {
|
|
26
|
+
txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (txBody) {
|
|
30
|
+
const protoResult = this.parseFromProtobufTxBody(txBody);
|
|
31
|
+
if (protoResult.type && protoResult.type !== "UNKNOWN") {
|
|
32
|
+
return protoResult;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch (protoError) {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return this.parseFromTransactionInternals(transaction);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return { type: "UNKNOWN", humanReadableType: "Unknown File Transaction" };
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Parse file transaction from protobuf TransactionBody
|
|
46
|
+
* Handles all file operations from decoded protobuf data
|
|
47
|
+
*/
|
|
48
|
+
static parseFromProtobufTxBody(txBody) {
|
|
49
|
+
if (txBody.fileCreate) {
|
|
50
|
+
const fileCreate = this.parseFileCreate(txBody.fileCreate);
|
|
51
|
+
if (fileCreate) {
|
|
52
|
+
return {
|
|
53
|
+
type: "FILECREATE",
|
|
54
|
+
humanReadableType: "File Create",
|
|
55
|
+
fileCreate
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (txBody.fileAppend) {
|
|
60
|
+
const fileAppend = this.parseFileAppend(txBody.fileAppend);
|
|
61
|
+
if (fileAppend) {
|
|
62
|
+
return {
|
|
63
|
+
type: "FILEAPPEND",
|
|
64
|
+
humanReadableType: "File Append",
|
|
65
|
+
fileAppend
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (txBody.fileUpdate) {
|
|
70
|
+
const fileUpdate = this.parseFileUpdate(txBody.fileUpdate);
|
|
71
|
+
if (fileUpdate) {
|
|
72
|
+
return {
|
|
73
|
+
type: "FILEUPDATE",
|
|
74
|
+
humanReadableType: "File Update",
|
|
75
|
+
fileUpdate
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (txBody.fileDelete) {
|
|
80
|
+
const fileDelete = this.parseFileDelete(txBody.fileDelete);
|
|
81
|
+
if (fileDelete) {
|
|
82
|
+
return {
|
|
83
|
+
type: "FILEDELETE",
|
|
84
|
+
humanReadableType: "File Delete",
|
|
85
|
+
fileDelete
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {};
|
|
67
90
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Extract file data from Transaction internal fields
|
|
93
|
+
* This handles cases where data is stored in Transaction object internals
|
|
94
|
+
*/
|
|
95
|
+
static parseFromTransactionInternals(transaction) {
|
|
96
|
+
try {
|
|
97
|
+
const tx = transaction;
|
|
98
|
+
if (hasTransactionType(transaction, "fileCreate")) {
|
|
99
|
+
const fileCreate = {};
|
|
100
|
+
if (tx._contents) {
|
|
101
|
+
const contentInfo = this.analyzeContent(tx._contents);
|
|
102
|
+
fileCreate.contents = contentInfo.encoded;
|
|
103
|
+
if (contentInfo.contentType) {
|
|
104
|
+
fileCreate.contentType = contentInfo.contentType;
|
|
105
|
+
}
|
|
106
|
+
if (contentInfo.size) {
|
|
107
|
+
fileCreate.contentSize = contentInfo.size;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (tx._keys && tx._keys.length > 0) {
|
|
111
|
+
const keyList = {
|
|
112
|
+
keys: tx._keys
|
|
113
|
+
};
|
|
114
|
+
fileCreate.keys = parseKey({ keyList });
|
|
115
|
+
}
|
|
116
|
+
if (tx._expirationTime) {
|
|
117
|
+
fileCreate.expirationTime = tx._expirationTime.toString();
|
|
118
|
+
}
|
|
119
|
+
if (tx._memo) {
|
|
120
|
+
fileCreate.memo = tx._memo;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
type: "FILECREATE",
|
|
124
|
+
humanReadableType: "File Create",
|
|
125
|
+
fileCreate
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (hasTransactionType(transaction, "fileAppend")) {
|
|
129
|
+
const fileAppend = {
|
|
130
|
+
fileId: tx._fileId.toString()
|
|
131
|
+
};
|
|
132
|
+
if (tx._contents) {
|
|
133
|
+
const contentInfo = this.analyzeContent(tx._contents);
|
|
134
|
+
fileAppend.contents = contentInfo.encoded;
|
|
135
|
+
if (contentInfo.size) {
|
|
136
|
+
fileAppend.contentSize = contentInfo.size;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
type: "FILEAPPEND",
|
|
141
|
+
humanReadableType: "File Append",
|
|
142
|
+
fileAppend
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (hasTransactionType(transaction, "fileUpdate")) {
|
|
146
|
+
const fileUpdate = {
|
|
147
|
+
fileId: tx._fileId.toString()
|
|
148
|
+
};
|
|
149
|
+
if (tx._contents) {
|
|
150
|
+
const contentInfo = this.analyzeContent(tx._contents);
|
|
151
|
+
fileUpdate.contents = contentInfo.encoded;
|
|
152
|
+
if (contentInfo.size) {
|
|
153
|
+
fileUpdate.contentSize = contentInfo.size;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (tx._keys && tx._keys.length > 0) {
|
|
157
|
+
const keyList = {
|
|
158
|
+
keys: tx._keys
|
|
159
|
+
};
|
|
160
|
+
fileUpdate.keys = parseKey({ keyList });
|
|
161
|
+
}
|
|
162
|
+
if (tx._expirationTime) {
|
|
163
|
+
fileUpdate.expirationTime = tx._expirationTime.toString();
|
|
164
|
+
}
|
|
165
|
+
if (tx._memo) {
|
|
166
|
+
fileUpdate.memo = tx._memo;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
type: "FILEUPDATE",
|
|
170
|
+
humanReadableType: "File Update",
|
|
171
|
+
fileUpdate
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (hasTransactionType(transaction, "fileDelete")) {
|
|
175
|
+
const fileDelete = {
|
|
176
|
+
fileId: tx._fileId.toString()
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
type: "FILEDELETE",
|
|
180
|
+
humanReadableType: "File Delete",
|
|
181
|
+
fileDelete
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {};
|
|
185
|
+
} catch (error) {
|
|
186
|
+
return {};
|
|
187
|
+
}
|
|
71
188
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
189
|
+
/**
|
|
190
|
+
* Enhanced content analysis with type detection and metadata
|
|
191
|
+
*/
|
|
192
|
+
static analyzeContent(contents) {
|
|
193
|
+
const size = contents.length;
|
|
194
|
+
const contentBuffer = Buffer.from(contents);
|
|
195
|
+
let contentType;
|
|
196
|
+
if (size >= 4) {
|
|
197
|
+
const header = contentBuffer.subarray(0, 4);
|
|
198
|
+
const headerHex = header.toString("hex");
|
|
199
|
+
const signatures = {
|
|
200
|
+
"89504e47": "image/png",
|
|
201
|
+
ffd8ffe0: "image/jpeg",
|
|
202
|
+
ffd8ffe1: "image/jpeg",
|
|
203
|
+
"47494638": "image/gif",
|
|
204
|
+
"25504446": "application/pdf",
|
|
205
|
+
"504b0304": "application/zip",
|
|
206
|
+
"7f454c46": "application/x-executable",
|
|
207
|
+
d0cf11e0: "application/msoffice"
|
|
208
|
+
};
|
|
209
|
+
contentType = signatures[headerHex.toLowerCase()];
|
|
210
|
+
}
|
|
211
|
+
if (!contentType) {
|
|
212
|
+
try {
|
|
213
|
+
const textContent = contentBuffer.toString("utf8");
|
|
214
|
+
const hasControlChars = /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(
|
|
215
|
+
textContent
|
|
216
|
+
);
|
|
217
|
+
const hasReplacementChars = textContent.includes("�");
|
|
218
|
+
if (!hasControlChars && !hasReplacementChars) {
|
|
219
|
+
if (textContent.trim().startsWith("{") && textContent.trim().endsWith("}")) {
|
|
220
|
+
contentType = "application/json";
|
|
221
|
+
} else if (textContent.includes("<?xml") || textContent.includes("<html")) {
|
|
222
|
+
contentType = "text/xml";
|
|
223
|
+
} else if (textContent.includes("<!DOCTYPE html")) {
|
|
224
|
+
contentType = "text/html";
|
|
225
|
+
} else {
|
|
226
|
+
contentType = "text/plain";
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
contentType = "application/octet-stream";
|
|
230
|
+
}
|
|
231
|
+
} catch {
|
|
232
|
+
contentType = "application/octet-stream";
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
let encoded;
|
|
236
|
+
if (contentType?.startsWith("text/") || contentType === "application/json") {
|
|
237
|
+
try {
|
|
238
|
+
encoded = contentBuffer.toString("utf8");
|
|
239
|
+
if (encoded.includes("�") || /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(encoded)) {
|
|
240
|
+
encoded = contentBuffer.toString("base64");
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
encoded = contentBuffer.toString("base64");
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
encoded = contentBuffer.toString("base64");
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
encoded,
|
|
250
|
+
contentType,
|
|
251
|
+
size
|
|
252
|
+
};
|
|
80
253
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
254
|
+
static parseFileCreate(body) {
|
|
255
|
+
if (!body) return void 0;
|
|
256
|
+
const data = {};
|
|
257
|
+
if (body.expirationTime?.seconds) {
|
|
258
|
+
data.expirationTime = `${Long.fromValue(
|
|
259
|
+
body.expirationTime.seconds
|
|
260
|
+
).toString()}.${body.expirationTime.nanos}`;
|
|
261
|
+
}
|
|
262
|
+
if (body.keys) {
|
|
263
|
+
data.keys = parseKey({ keyList: body.keys });
|
|
264
|
+
}
|
|
265
|
+
if (body.contents) {
|
|
266
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
267
|
+
}
|
|
268
|
+
if (body.memo) {
|
|
269
|
+
data.memo = body.memo;
|
|
270
|
+
}
|
|
271
|
+
return data;
|
|
86
272
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
uaid: options.uaid
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function createEncryptionApi(client) {
|
|
101
|
-
return {
|
|
102
|
-
registerKey: (payload) => registerEncryptionKey(client, payload),
|
|
103
|
-
generateEphemeralKeyPair: () => client.createEphemeralKeyPair(),
|
|
104
|
-
deriveSharedSecret: (options) => client.deriveSharedSecret(options),
|
|
105
|
-
encryptCipherEnvelope: (options) => client.buildCipherEnvelope(options),
|
|
106
|
-
decryptCipherEnvelope: (options) => client.openCipherEnvelope(options),
|
|
107
|
-
ensureAgentKey: (options) => ensureAgentEncryptionKey(client, options)
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
async function bootstrapEncryptionOptions(client, options) {
|
|
111
|
-
if (!options?.autoRegister || options.autoRegister.enabled === false) {
|
|
112
|
-
return null;
|
|
273
|
+
static parseFileAppend(body) {
|
|
274
|
+
if (!body) return void 0;
|
|
275
|
+
const data = {};
|
|
276
|
+
if (body.fileID) {
|
|
277
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
278
|
+
}
|
|
279
|
+
if (body.contents) {
|
|
280
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
281
|
+
}
|
|
282
|
+
return data;
|
|
113
283
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
284
|
+
static parseFileUpdate(body) {
|
|
285
|
+
if (!body) return void 0;
|
|
286
|
+
const data = {};
|
|
287
|
+
if (body.fileID) {
|
|
288
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
289
|
+
}
|
|
290
|
+
if (body.expirationTime?.seconds) {
|
|
291
|
+
data.expirationTime = `${Long.fromValue(
|
|
292
|
+
body.expirationTime.seconds
|
|
293
|
+
).toString()}.${body.expirationTime.nanos}`;
|
|
294
|
+
}
|
|
295
|
+
if (body.keys) {
|
|
296
|
+
data.keys = parseKey({ keyList: body.keys });
|
|
297
|
+
}
|
|
298
|
+
if (body.contents) {
|
|
299
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
300
|
+
}
|
|
301
|
+
if (body.memo?.value !== void 0) {
|
|
302
|
+
data.memo = body.memo.value;
|
|
303
|
+
}
|
|
304
|
+
return data;
|
|
121
305
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const resolvedPath = options.envPath ? path.resolve(options.envPath) : void 0;
|
|
128
|
-
if (resolvedPath) {
|
|
129
|
-
const fsModule = await getFs();
|
|
130
|
-
if (!fsModule) {
|
|
131
|
-
throw new Error(
|
|
132
|
-
"File system module is not available; cannot write encryption key env file"
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
const envLine = `${envVar}=${privateKey}`;
|
|
136
|
-
if (fsModule.existsSync(resolvedPath)) {
|
|
137
|
-
const content = fsModule.readFileSync(resolvedPath, "utf-8");
|
|
138
|
-
const lineRegex = new RegExp(`^${envVar}=.*$`, "m");
|
|
139
|
-
if (lineRegex.test(content)) {
|
|
140
|
-
if (!options.overwrite) {
|
|
141
|
-
throw new Error(
|
|
142
|
-
`${envVar} already exists in ${resolvedPath}; set overwrite=true to replace it`
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
const updated = content.replace(lineRegex, envLine);
|
|
146
|
-
fsModule.writeFileSync(resolvedPath, updated);
|
|
147
|
-
} else {
|
|
148
|
-
const needsNewline = !content.endsWith("\n");
|
|
149
|
-
fsModule.appendFileSync(
|
|
150
|
-
resolvedPath,
|
|
151
|
-
`${needsNewline ? "\n" : ""}${envLine}
|
|
152
|
-
`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
fsModule.writeFileSync(resolvedPath, `${envLine}
|
|
157
|
-
`);
|
|
306
|
+
static parseFileDelete(body) {
|
|
307
|
+
if (!body) return void 0;
|
|
308
|
+
const data = {};
|
|
309
|
+
if (body.fileID) {
|
|
310
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
158
311
|
}
|
|
312
|
+
return data;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Parse File Service transaction from Transaction object
|
|
316
|
+
* This is the unified entry point that delegates to the comprehensive parsing logic
|
|
317
|
+
*/
|
|
318
|
+
static parseFromTransactionObject(transaction) {
|
|
319
|
+
return this.parseFileTransaction(transaction);
|
|
159
320
|
}
|
|
160
|
-
return {
|
|
161
|
-
privateKey,
|
|
162
|
-
publicKey,
|
|
163
|
-
envPath: resolvedPath,
|
|
164
|
-
envVar
|
|
165
|
-
};
|
|
166
321
|
}
|
|
167
322
|
export {
|
|
168
|
-
|
|
169
|
-
bootstrapEncryptionOptions,
|
|
170
|
-
createEncryptionApi,
|
|
171
|
-
ensureAgentEncryptionKey,
|
|
172
|
-
generateEncryptionKeyPair,
|
|
173
|
-
registerEncryptionKey
|
|
323
|
+
FileParser
|
|
174
324
|
};
|
|
175
325
|
//# sourceMappingURL=standards-sdk.es169.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es169.js","sources":["../../src/services/registry-broker/client/encryption.ts"],"sourcesContent":["import * as path from 'path';\nimport { Buffer } from 'buffer';\nimport { randomBytes } from 'crypto';\nimport { secp256k1 } from '@noble/curves/secp256k1.js';\nimport type {\n AutoRegisterEncryptionKeyOptions,\n CipherEnvelope,\n ClientEncryptionOptions,\n DecryptCipherEnvelopeOptions,\n DeriveSharedSecretOptions,\n EncryptCipherEnvelopeOptions,\n EphemeralKeyPair,\n EnsureAgentKeyOptions,\n RegisterEncryptionKeyPayload,\n RegisterEncryptionKeyResponse,\n SharedSecretInput,\n} from '../types';\nimport { registerEncryptionKeyResponseSchema } from '../schemas';\nimport { optionalImport } from '../../../utils/dynamic-import';\nimport type {\n RegistryBrokerClient,\n GenerateEncryptionKeyPairOptions,\n} from './base-client';\n\ntype FsModule = {\n existsSync: (path: string) => boolean;\n readFileSync: (path: string, encoding: BufferEncoding) => string;\n writeFileSync: (path: string, data: string) => void;\n appendFileSync: (path: string, data: string) => void;\n};\n\nconst getFs = async (): Promise<FsModule | null> => {\n const fsModule = await optionalImport<Partial<FsModule>>('node:fs');\n\n if (\n fsModule &&\n typeof fsModule.existsSync === 'function' &&\n typeof fsModule.readFileSync === 'function' &&\n typeof fsModule.writeFileSync === 'function' &&\n typeof fsModule.appendFileSync === 'function'\n ) {\n return fsModule as FsModule;\n }\n\n return null;\n};\n\nexport interface RegistryBrokerEncryptionApi {\n registerKey: (\n payload: RegisterEncryptionKeyPayload,\n ) => Promise<RegisterEncryptionKeyResponse>;\n generateEphemeralKeyPair: () => EphemeralKeyPair;\n deriveSharedSecret: (options: DeriveSharedSecretOptions) => Buffer;\n encryptCipherEnvelope: (\n options: EncryptCipherEnvelopeOptions,\n ) => CipherEnvelope;\n decryptCipherEnvelope: (options: DecryptCipherEnvelopeOptions) => string;\n ensureAgentKey: (\n options: EnsureAgentKeyOptions,\n ) => Promise<{ publicKey: string; privateKey?: string }>;\n}\n\nexport async function registerEncryptionKey(\n client: RegistryBrokerClient,\n payload: RegisterEncryptionKeyPayload,\n): Promise<RegisterEncryptionKeyResponse> {\n const raw = await client.requestJson('/encryption/keys', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: payload,\n });\n return client.parseWithSchema(\n raw,\n registerEncryptionKeyResponseSchema,\n 'register encryption key response',\n );\n}\n\nfunction normalizeAutoRegisterIdentity(\n config: AutoRegisterEncryptionKeyOptions,\n): Pick<\n RegisterEncryptionKeyPayload,\n 'uaid' | 'ledgerAccountId' | 'ledgerNetwork' | 'email'\n> | null {\n const identity: Pick<\n RegisterEncryptionKeyPayload,\n 'uaid' | 'ledgerAccountId' | 'ledgerNetwork' | 'email'\n > = {};\n if (config.uaid) {\n identity.uaid = config.uaid;\n }\n if (config.ledgerAccountId) {\n identity.ledgerAccountId = config.ledgerAccountId;\n if (config.ledgerNetwork) {\n identity.ledgerNetwork = config.ledgerNetwork;\n }\n }\n if (config.email) {\n identity.email = config.email;\n }\n if (identity.uaid || identity.ledgerAccountId || identity.email) {\n return identity;\n }\n return null;\n}\n\nfunction derivePublicKeyFromPrivateKey(\n client: RegistryBrokerClient,\n privateKey: string,\n): string {\n const normalized = client.hexToBuffer(privateKey);\n const publicKey = secp256k1.getPublicKey(normalized, true);\n return Buffer.from(publicKey).toString('hex');\n}\n\nasync function resolveAutoRegisterKeyMaterial(\n client: RegistryBrokerClient,\n config: AutoRegisterEncryptionKeyOptions,\n): Promise<{ publicKey: string; privateKey?: string } | null> {\n if (config.publicKey?.trim()) {\n return { publicKey: config.publicKey.trim() };\n }\n let privateKey = config.privateKey?.trim();\n const envVar = config.envVar ?? 'RB_ENCRYPTION_PRIVATE_KEY';\n if (!privateKey && envVar && process?.env?.[envVar]?.trim()) {\n privateKey = process.env[envVar]?.trim();\n }\n if (!privateKey && config.generateIfMissing) {\n const pair = await client.generateEncryptionKeyPair({\n keyType: config.keyType ?? 'secp256k1',\n envVar,\n envPath: config.envPath,\n overwrite: config.overwriteEnv,\n });\n return { publicKey: pair.publicKey, privateKey: pair.privateKey };\n }\n if (privateKey) {\n const publicKey = derivePublicKeyFromPrivateKey(client, privateKey);\n return { publicKey, privateKey };\n }\n return null;\n}\n\nexport async function autoRegisterEncryptionKey(\n client: RegistryBrokerClient,\n config: AutoRegisterEncryptionKeyOptions,\n): Promise<{ publicKey: string; privateKey?: string }> {\n const identity = normalizeAutoRegisterIdentity(config);\n if (!identity) {\n throw new Error(\n 'Auto-registration requires uaid, ledgerAccountId, or email',\n );\n }\n const material = await resolveAutoRegisterKeyMaterial(client, config);\n if (!material) {\n throw new Error(\n 'Unable to resolve encryption public key for auto-registration',\n );\n }\n await registerEncryptionKey(client, {\n keyType: config.keyType ?? 'secp256k1',\n publicKey: material.publicKey,\n ...identity,\n });\n return material;\n}\n\nexport async function ensureAgentEncryptionKey(\n client: RegistryBrokerClient,\n options: EnsureAgentKeyOptions,\n): Promise<{ publicKey: string; privateKey?: string }> {\n return autoRegisterEncryptionKey(client, {\n ...options,\n uaid: options.uaid,\n enabled: true,\n });\n}\n\nexport function createEncryptionApi(\n client: RegistryBrokerClient,\n): RegistryBrokerEncryptionApi {\n return {\n registerKey: (payload: RegisterEncryptionKeyPayload) =>\n registerEncryptionKey(client, payload),\n generateEphemeralKeyPair: () => client.createEphemeralKeyPair(),\n deriveSharedSecret: (options: DeriveSharedSecretOptions) =>\n client.deriveSharedSecret(options),\n encryptCipherEnvelope: (options: EncryptCipherEnvelopeOptions) =>\n client.buildCipherEnvelope(options),\n decryptCipherEnvelope: (options: DecryptCipherEnvelopeOptions) =>\n client.openCipherEnvelope(options),\n ensureAgentKey: (options: EnsureAgentKeyOptions) =>\n ensureAgentEncryptionKey(client, options),\n };\n}\n\nexport async function bootstrapEncryptionOptions(\n client: RegistryBrokerClient,\n options?: ClientEncryptionOptions,\n): Promise<{ publicKey: string; privateKey?: string } | null> {\n if (!options?.autoRegister || options.autoRegister.enabled === false) {\n return null;\n }\n return autoRegisterEncryptionKey(client, options.autoRegister);\n}\n\nexport async function generateEncryptionKeyPair(\n client: RegistryBrokerClient,\n options: GenerateEncryptionKeyPairOptions = {},\n): Promise<{\n privateKey: string;\n publicKey: string;\n envPath?: string;\n envVar: string;\n}> {\n client.assertNodeRuntime('generateEncryptionKeyPair');\n\n const keyType = options.keyType ?? 'secp256k1';\n if (keyType !== 'secp256k1') {\n throw new Error('Only secp256k1 key generation is supported currently');\n }\n\n const privateKeyBytes = randomBytes(32);\n const privateKey = Buffer.from(privateKeyBytes).toString('hex');\n const publicKeyBytes = secp256k1.getPublicKey(privateKeyBytes, true);\n const publicKey = Buffer.from(publicKeyBytes).toString('hex');\n\n const envVar = options.envVar ?? 'RB_ENCRYPTION_PRIVATE_KEY';\n const resolvedPath = options.envPath\n ? path.resolve(options.envPath)\n : undefined;\n\n if (resolvedPath) {\n const fsModule = await getFs();\n\n if (!fsModule) {\n throw new Error(\n 'File system module is not available; cannot write encryption key env file',\n );\n }\n\n const envLine = `${envVar}=${privateKey}`;\n if (fsModule.existsSync(resolvedPath)) {\n const content = fsModule.readFileSync(resolvedPath, 'utf-8');\n const lineRegex = new RegExp(`^${envVar}=.*$`, 'm');\n if (lineRegex.test(content)) {\n if (!options.overwrite) {\n throw new Error(\n `${envVar} already exists in ${resolvedPath}; set overwrite=true to replace it`,\n );\n }\n const updated = content.replace(lineRegex, envLine);\n fsModule.writeFileSync(resolvedPath, updated);\n } else {\n const needsNewline = !content.endsWith('\\n');\n fsModule.appendFileSync(\n resolvedPath,\n `${needsNewline ? '\\n' : ''}${envLine}\\n`,\n );\n }\n } else {\n fsModule.writeFileSync(resolvedPath, `${envLine}\\n`);\n }\n }\n\n return {\n privateKey,\n publicKey,\n envPath: resolvedPath,\n envVar,\n };\n}\n"],"names":[],"mappings":";;;;;;AA+BA,MAAM,QAAQ,YAAsC;AAClD,QAAM,WAAW,MAAM,eAAkC,SAAS;AAElE,MACE,YACA,OAAO,SAAS,eAAe,cAC/B,OAAO,SAAS,iBAAiB,cACjC,OAAO,SAAS,kBAAkB,cAClC,OAAO,SAAS,mBAAmB,YACnC;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAiBA,eAAsB,sBACpB,QACA,SACwC;AACxC,QAAM,MAAM,MAAM,OAAO,YAAY,oBAAoB;AAAA,IACvD,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAA;AAAA,IAC3B,MAAM;AAAA,EAAA,CACP;AACD,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,8BACP,QAIO;AACP,QAAM,WAGF,CAAA;AACJ,MAAI,OAAO,MAAM;AACf,aAAS,OAAO,OAAO;AAAA,EACzB;AACA,MAAI,OAAO,iBAAiB;AAC1B,aAAS,kBAAkB,OAAO;AAClC,QAAI,OAAO,eAAe;AACxB,eAAS,gBAAgB,OAAO;AAAA,IAClC;AAAA,EACF;AACA,MAAI,OAAO,OAAO;AAChB,aAAS,QAAQ,OAAO;AAAA,EAC1B;AACA,MAAI,SAAS,QAAQ,SAAS,mBAAmB,SAAS,OAAO;AAC/D,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,8BACP,QACA,YACQ;AACR,QAAM,aAAa,OAAO,YAAY,UAAU;AAChD,QAAM,YAAY,UAAU,aAAa,YAAY,IAAI;AACzD,SAAO,OAAO,KAAK,SAAS,EAAE,SAAS,KAA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,QAAQ,GAAG;AAClD,UAAI,UAAU,KAAK,OAAO,GAAG;AAC3B,YAAI,CAAC,QAAQ,WAAW;AACtB,gBAAM,IAAI;AAAA,YACR,GAAG,MAAM,sBAAsB,YAAY;AAAA,UAAA;AAAA,QAE/C;AACA,cAAM,UAAU,QAAQ,QAAQ,WAAW,OAAO;AAClD,iBAAS,cAAc,cAAc,OAAO;AAAA,MAC9C,OAAO;AACL,cAAM,eAAe,CAAC,QAAQ,SAAS,IAAI;AAC3C,iBAAS;AAAA,UACP;AAAA,UACA,GAAG,eAAe,OAAO,EAAE,GAAG,OAAO;AAAA;AAAA,QAAA;AAAA,MAEzC;AAAA,IACF,OAAO;AACL,eAAS,cAAc,cAAc,GAAG,OAAO;AAAA,CAAI;AAAA,IACrD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es169.js","sources":["../../src/utils/parsers/file-parser.ts"],"sourcesContent":["import { proto } from '@hashgraph/proto';\nimport { Long, Transaction } from '@hashgraph/sdk';\nimport {\n FileCreateData,\n FileAppendData,\n FileUpdateData,\n FileDeleteData,\n} from '../transaction-parser-types';\nimport {\n parseKey,\n extractTransactionBody,\n hasTransactionType,\n} from './parser-utils';\nimport { Buffer } from 'buffer';\nimport { FileId } from '@hashgraph/sdk';\n\n/**\n * File Service Parser\n *\n * Handles parsing for all file-related transaction types including:\n * - File creation, updates, append, and deletion\n * - Proper dual-branch parsing (regular vs signed transactions)\n * - Comprehensive protobuf extraction\n * - Enhanced content handling with type detection\n */\nexport class FileParser {\n /**\n * Parse File Service transaction using unified dual-branch approach\n * This handles both regular transactions and signed transaction variants\n */\n static parseFileTransaction(\n transaction: Transaction,\n originalBytes?: Uint8Array,\n ): {\n type?: string;\n humanReadableType?: string;\n fileCreate?: FileCreateData;\n fileAppend?: FileAppendData;\n fileUpdate?: FileUpdateData;\n fileDelete?: FileDeleteData;\n [key: string]: unknown;\n } {\n try {\n if (originalBytes || transaction.toBytes) {\n try {\n const bytesToParse = originalBytes || transaction.toBytes();\n const decoded = proto.TransactionList.decode(bytesToParse);\n\n if (decoded.transactionList && decoded.transactionList.length > 0) {\n const tx = decoded.transactionList[0];\n let txBody: proto.ITransactionBody | null = null;\n\n if (tx.bodyBytes && tx.bodyBytes.length > 0) {\n txBody = proto.TransactionBody.decode(tx.bodyBytes);\n } else if (\n tx.signedTransactionBytes &&\n tx.signedTransactionBytes.length > 0\n ) {\n const signedTx = proto.SignedTransaction.decode(\n tx.signedTransactionBytes,\n );\n if (signedTx.bodyBytes) {\n txBody = proto.TransactionBody.decode(signedTx.bodyBytes);\n }\n }\n\n if (txBody) {\n const protoResult = this.parseFromProtobufTxBody(txBody);\n if (protoResult.type && protoResult.type !== 'UNKNOWN') {\n return protoResult;\n }\n }\n }\n } catch (protoError) {}\n }\n\n return this.parseFromTransactionInternals(transaction);\n } catch (error) {\n return { type: 'UNKNOWN', humanReadableType: 'Unknown File Transaction' };\n }\n }\n\n /**\n * Parse file transaction from protobuf TransactionBody\n * Handles all file operations from decoded protobuf data\n */\n private static parseFromProtobufTxBody(txBody: proto.ITransactionBody): {\n type?: string;\n humanReadableType?: string;\n [key: string]: unknown;\n } {\n if (txBody.fileCreate) {\n const fileCreate = this.parseFileCreate(txBody.fileCreate);\n if (fileCreate) {\n return {\n type: 'FILECREATE',\n humanReadableType: 'File Create',\n fileCreate,\n };\n }\n }\n\n if (txBody.fileAppend) {\n const fileAppend = this.parseFileAppend(txBody.fileAppend);\n if (fileAppend) {\n return {\n type: 'FILEAPPEND',\n humanReadableType: 'File Append',\n fileAppend,\n };\n }\n }\n\n if (txBody.fileUpdate) {\n const fileUpdate = this.parseFileUpdate(txBody.fileUpdate);\n if (fileUpdate) {\n return {\n type: 'FILEUPDATE',\n humanReadableType: 'File Update',\n fileUpdate,\n };\n }\n }\n\n if (txBody.fileDelete) {\n const fileDelete = this.parseFileDelete(txBody.fileDelete);\n if (fileDelete) {\n return {\n type: 'FILEDELETE',\n humanReadableType: 'File Delete',\n fileDelete,\n };\n }\n }\n\n return {};\n }\n\n /**\n * Extract file data from Transaction internal fields\n * This handles cases where data is stored in Transaction object internals\n */\n private static parseFromTransactionInternals(transaction: Transaction): {\n type?: string;\n humanReadableType?: string;\n [key: string]: unknown;\n } {\n try {\n const tx = transaction as unknown as {\n _fileId?: { toString(): string };\n _contents?: Uint8Array;\n _keys?: unknown[];\n _expirationTime?: { toString(): string };\n _memo?: string;\n constructor?: { name?: string };\n };\n\n if (hasTransactionType(transaction, 'fileCreate')) {\n const fileCreate: FileCreateData = {};\n\n if (tx._contents) {\n const contentInfo = this.analyzeContent(tx._contents);\n fileCreate.contents = contentInfo.encoded;\n if (contentInfo.contentType) {\n fileCreate.contentType = contentInfo.contentType;\n }\n if (contentInfo.size) {\n fileCreate.contentSize = contentInfo.size;\n }\n }\n\n if (tx._keys && tx._keys.length > 0) {\n const keyList: proto.IKeyList = {\n keys: tx._keys as unknown as proto.IKey[],\n };\n fileCreate.keys = parseKey({ keyList });\n }\n\n if (tx._expirationTime) {\n fileCreate.expirationTime = tx._expirationTime.toString();\n }\n\n if (tx._memo) {\n fileCreate.memo = tx._memo;\n }\n\n return {\n type: 'FILECREATE',\n humanReadableType: 'File Create',\n fileCreate,\n };\n }\n\n if (hasTransactionType(transaction, 'fileAppend')) {\n const fileAppend: FileAppendData = {\n fileId: tx._fileId.toString(),\n };\n\n if (tx._contents) {\n const contentInfo = this.analyzeContent(tx._contents);\n fileAppend.contents = contentInfo.encoded;\n if (contentInfo.size) {\n fileAppend.contentSize = contentInfo.size;\n }\n }\n\n return {\n type: 'FILEAPPEND',\n humanReadableType: 'File Append',\n fileAppend,\n };\n }\n\n if (hasTransactionType(transaction, 'fileUpdate')) {\n const fileUpdate: FileUpdateData = {\n fileId: tx._fileId.toString(),\n };\n\n if (tx._contents) {\n const contentInfo = this.analyzeContent(tx._contents);\n fileUpdate.contents = contentInfo.encoded;\n if (contentInfo.size) {\n fileUpdate.contentSize = contentInfo.size;\n }\n }\n\n if (tx._keys && tx._keys.length > 0) {\n const keyList: proto.IKeyList = {\n keys: tx._keys as unknown as proto.IKey[],\n };\n fileUpdate.keys = parseKey({ keyList });\n }\n\n if (tx._expirationTime) {\n fileUpdate.expirationTime = tx._expirationTime.toString();\n }\n\n if (tx._memo) {\n fileUpdate.memo = tx._memo;\n }\n\n return {\n type: 'FILEUPDATE',\n humanReadableType: 'File Update',\n fileUpdate,\n };\n }\n\n if (hasTransactionType(transaction, 'fileDelete')) {\n const fileDelete: FileDeleteData = {\n fileId: tx._fileId.toString(),\n };\n\n return {\n type: 'FILEDELETE',\n humanReadableType: 'File Delete',\n fileDelete,\n };\n }\n\n return {};\n } catch (error) {\n return {};\n }\n }\n\n /**\n * Enhanced content analysis with type detection and metadata\n */\n private static analyzeContent(contents: Uint8Array): {\n encoded: string;\n contentType?: string;\n size: number;\n } {\n const size = contents.length;\n const contentBuffer = Buffer.from(contents);\n\n let contentType: string | undefined;\n\n if (size >= 4) {\n const header = contentBuffer.subarray(0, 4);\n const headerHex = header.toString('hex');\n\n const signatures: Record<string, string> = {\n '89504e47': 'image/png',\n ffd8ffe0: 'image/jpeg',\n ffd8ffe1: 'image/jpeg',\n '47494638': 'image/gif',\n '25504446': 'application/pdf',\n '504b0304': 'application/zip',\n '7f454c46': 'application/x-executable',\n d0cf11e0: 'application/msoffice',\n };\n\n contentType = signatures[headerHex.toLowerCase()];\n }\n\n if (!contentType) {\n try {\n const textContent = contentBuffer.toString('utf8');\n const hasControlChars = /[\\x00-\\x08\\x0B\\x0E-\\x1F\\x7F]/.test(\n textContent,\n );\n const hasReplacementChars = textContent.includes('\\uFFFD');\n\n if (!hasControlChars && !hasReplacementChars) {\n if (\n textContent.trim().startsWith('{') &&\n textContent.trim().endsWith('}')\n ) {\n contentType = 'application/json';\n } else if (\n textContent.includes('<?xml') ||\n textContent.includes('<html')\n ) {\n contentType = 'text/xml';\n } else if (textContent.includes('<!DOCTYPE html')) {\n contentType = 'text/html';\n } else {\n contentType = 'text/plain';\n }\n } else {\n contentType = 'application/octet-stream';\n }\n } catch {\n contentType = 'application/octet-stream';\n }\n }\n\n let encoded: string;\n if (\n contentType?.startsWith('text/') ||\n contentType === 'application/json'\n ) {\n try {\n encoded = contentBuffer.toString('utf8');\n if (\n encoded.includes('\\uFFFD') ||\n /[\\x00-\\x08\\x0B\\x0E-\\x1F\\x7F]/.test(encoded)\n ) {\n encoded = contentBuffer.toString('base64');\n }\n } catch {\n encoded = contentBuffer.toString('base64');\n }\n } else {\n encoded = contentBuffer.toString('base64');\n }\n\n return {\n encoded,\n contentType,\n size,\n };\n }\n static parseFileCreate(\n body: proto.IFileCreateTransactionBody,\n ): FileCreateData | undefined {\n if (!body) return undefined;\n const data: FileCreateData = {};\n if (body.expirationTime?.seconds) {\n data.expirationTime = `${Long.fromValue(\n body.expirationTime.seconds,\n ).toString()}.${body.expirationTime.nanos}`;\n }\n if (body.keys) {\n data.keys = parseKey({ keyList: body.keys });\n }\n if (body.contents) {\n data.contents = Buffer.from(body.contents).toString('base64');\n }\n if (body.memo) {\n data.memo = body.memo;\n }\n return data;\n }\n\n static parseFileAppend(\n body: proto.IFileAppendTransactionBody,\n ): FileAppendData | undefined {\n if (!body) return undefined;\n const data: FileAppendData = {};\n if (body.fileID) {\n data.fileId = `${body.fileID.shardNum ?? 0}.${\n body.fileID.realmNum ?? 0\n }.${body.fileID.fileNum ?? 0}`;\n }\n if (body.contents) {\n data.contents = Buffer.from(body.contents).toString('base64');\n }\n return data;\n }\n\n static parseFileUpdate(\n body: proto.IFileUpdateTransactionBody,\n ): FileUpdateData | undefined {\n if (!body) return undefined;\n const data: FileUpdateData = {};\n if (body.fileID) {\n data.fileId = `${body.fileID.shardNum ?? 0}.${\n body.fileID.realmNum ?? 0\n }.${body.fileID.fileNum ?? 0}`;\n }\n if (body.expirationTime?.seconds) {\n data.expirationTime = `${Long.fromValue(\n body.expirationTime.seconds,\n ).toString()}.${body.expirationTime.nanos}`;\n }\n if (body.keys) {\n data.keys = parseKey({ keyList: body.keys });\n }\n if (body.contents) {\n data.contents = Buffer.from(body.contents).toString('base64');\n }\n if (body.memo?.value !== undefined) {\n data.memo = body.memo.value;\n }\n return data;\n }\n\n static parseFileDelete(\n body: proto.IFileDeleteTransactionBody,\n ): FileDeleteData | undefined {\n if (!body) return undefined;\n const data: FileDeleteData = {};\n if (body.fileID) {\n data.fileId = `${body.fileID.shardNum ?? 0}.${\n body.fileID.realmNum ?? 0\n }.${body.fileID.fileNum ?? 0}`;\n }\n return data;\n }\n\n /**\n * Parse File Service transaction from Transaction object\n * This is the unified entry point that delegates to the comprehensive parsing logic\n */\n static parseFromTransactionObject(transaction: Transaction): {\n type?: string;\n humanReadableType?: string;\n [key: string]: unknown;\n } {\n return this.parseFileTransaction(transaction);\n }\n}\n"],"names":[],"mappings":";;;;AAyBO,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,OAAO,qBACL,aACA,eASA;AACA,QAAI;AACF,UAAI,iBAAiB,YAAY,SAAS;AACxC,YAAI;AACF,gBAAM,eAAe,iBAAiB,YAAY,QAAA;AAClD,gBAAM,UAAU,MAAM,gBAAgB,OAAO,YAAY;AAEzD,cAAI,QAAQ,mBAAmB,QAAQ,gBAAgB,SAAS,GAAG;AACjE,kBAAM,KAAK,QAAQ,gBAAgB,CAAC;AACpC,gBAAI,SAAwC;AAE5C,gBAAI,GAAG,aAAa,GAAG,UAAU,SAAS,GAAG;AAC3C,uBAAS,MAAM,gBAAgB,OAAO,GAAG,SAAS;AAAA,YACpD,WACE,GAAG,0BACH,GAAG,uBAAuB,SAAS,GACnC;AACA,oBAAM,WAAW,MAAM,kBAAkB;AAAA,gBACvC,GAAG;AAAA,cAAA;AAEL,kBAAI,SAAS,WAAW;AACtB,yBAAS,MAAM,gBAAgB,OAAO,SAAS,SAAS;AAAA,cAC1D;AAAA,YACF;AAEA,gBAAI,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