Skip to content

Commit

Permalink
add authentication token
Browse files Browse the repository at this point in the history
  • Loading branch information
scobru committed Oct 6, 2024
1 parent ea9f52b commit eb49abb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions gun-eth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ Gun.chain.setToken = function (token) {
return this;
};

Gun.on("opt", function (ctx) {
if (ctx.once) {
return;
}
ctx.on("out", function (msg) {
var to = this.to;
// Usa il token personalizzato
msg.headers = {
token: customToken,
};
to.next(msg); // passa al prossimo middleware
});
ctx.on("put", function (msg) {
const to = this.to;
// Usa il token personalizzato
msg.headers = {
token: customToken,
};
to.next(msg); // passa al prossimo middleware
});

// Aggiungi il metodo alla catena di Gun
Expand Down
2 changes: 1 addition & 1 deletion gun-eth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gun-eth",
"version": "1.2.5",
"version": "1.2.6",
"description": "A GunDB plugin for Ethereum, and Web3",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit eb49abb

Please sign in to comment.