@vela-ventures/aosync-sdk-react 1.0.12 → 1.0.14

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.
@@ -83,7 +83,9 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
83
83
  }
84
84
  });
85
85
  const signAOMessage = (dataItem) => __awaiter(this, void 0, void 0, function* () {
86
+ var _a;
86
87
  try {
88
+ (_a = dataItem === null || dataItem === void 0 ? void 0 : dataItem.tags) === null || _a === void 0 ? void 0 : _a.push({ name: "SDK", value: "Beacon Wallet" }, { name: "Data-Protocol", value: "ao" }, { name: "Variant", value: "ao.TN.1" }, { name: "Type", value: "Message" });
87
89
  const signedDataItem = yield walletRef.current.signDataItem(dataItem);
88
90
  const response = yield fetch(muUrl, {
89
91
  method: "POST",
@@ -95,13 +97,25 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
95
97
  if (!response.ok) {
96
98
  throw new Error("Network response was not ok");
97
99
  }
98
- return signedDataItem;
100
+ return yield extractAndHashId(signedDataItem);
99
101
  }
100
102
  catch (error) {
101
103
  console.error("Error signing AO message:", error);
102
104
  throw error;
103
105
  }
104
106
  });
107
+ function extractAndHashId(byteArray) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const idBytes = byteArray.slice(2, 2 + 512);
110
+ const hashBuffer = yield crypto.subtle.digest('SHA-256', idBytes);
111
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
112
+ const hashBase64 = btoa(String.fromCharCode.apply(null, hashArray))
113
+ .replace(/\+/g, '-')
114
+ .replace(/\//g, '_')
115
+ .replace(/=+$/, '');
116
+ return hashBase64;
117
+ });
118
+ }
105
119
  const sign = (transaction) => __awaiter(this, void 0, void 0, function* () {
106
120
  try {
107
121
  return yield walletRef.current.sign(transaction);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vela-ventures/aosync-sdk-react",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"