mirror of
https://github.com/vitorpamplona/Nostryfied.git
synced 2025-06-06 18:31:07 +00:00
order of functions
This commit is contained in:
parent
23a501f0e3
commit
0d8073db51
@ -371,6 +371,36 @@ function hexToBytes(hex) {
|
||||
displayRelayStatus(relayStatus)
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function generateNostrEventId(msg) {
|
||||
const digest = [
|
||||
0,
|
||||
msg.pubkey,
|
||||
msg.created_at,
|
||||
msg.kind,
|
||||
msg.tags,
|
||||
msg.content,
|
||||
];
|
||||
const digest_str = JSON.stringify(digest);
|
||||
const hash = await sha256Hex(digest_str);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
function sha256Hex(string) {
|
||||
const utf8 = new TextEncoder().encode(string);
|
||||
|
||||
return crypto.subtle.digest('SHA-256', utf8).then((hashBuffer) => {
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray
|
||||
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
|
||||
return hashHex;
|
||||
});
|
||||
}
|
||||
|
||||
async function signNostrAuthEvent(relay, auth_challenge) {
|
||||
try {
|
||||
|
||||
@ -404,31 +434,3 @@ function hexToBytes(hex) {
|
||||
|
||||
return signed_msg;
|
||||
}
|
||||
|
||||
async function generateNostrEventId(msg) {
|
||||
const digest = [
|
||||
0,
|
||||
msg.pubkey,
|
||||
msg.created_at,
|
||||
msg.kind,
|
||||
msg.tags,
|
||||
msg.content,
|
||||
];
|
||||
const digest_str = JSON.stringify(digest);
|
||||
const hash = await sha256Hex(digest_str);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
function sha256Hex(string) {
|
||||
const utf8 = new TextEncoder().encode(string);
|
||||
|
||||
return crypto.subtle.digest('SHA-256', utf8).then((hashBuffer) => {
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray
|
||||
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
|
||||
return hashHex;
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user