@vela-ventures/aosync-sdk-react 1.0.13 → 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.
- package/dist/walletContext.js +13 -1
- package/package.json +1 -1
package/dist/walletContext.js
CHANGED
|
@@ -97,13 +97,25 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
|
|
|
97
97
|
if (!response.ok) {
|
|
98
98
|
throw new Error("Network response was not ok");
|
|
99
99
|
}
|
|
100
|
-
return signedDataItem;
|
|
100
|
+
return yield extractAndHashId(signedDataItem);
|
|
101
101
|
}
|
|
102
102
|
catch (error) {
|
|
103
103
|
console.error("Error signing AO message:", error);
|
|
104
104
|
throw error;
|
|
105
105
|
}
|
|
106
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
|
+
}
|
|
107
119
|
const sign = (transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
108
120
|
try {
|
|
109
121
|
return yield walletRef.current.sign(transaction);
|