mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
utils: remove unused sha256 text function
This commit is contained in:
parent
c5bcf1d4a3
commit
23bedd82a0
1 changed files with 1 additions and 15 deletions
16
src/utils.ts
16
src/utils.ts
|
|
@ -64,20 +64,6 @@ function findTag(tags: string[][], name: string): string[] | undefined {
|
|||
return tags.find((tag) => tag[0] === name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sha256 hash (hex) of some text.
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#converting_a_digest_to_a_hex_string
|
||||
*/
|
||||
async function sha256(message: string): Promise<string> {
|
||||
const msgUint8 = new TextEncoder().encode(message);
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray
|
||||
.map((b) => b.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
return hashHex;
|
||||
}
|
||||
|
||||
/** Test whether the value is a Nostr ID. */
|
||||
function isNostrId(value: unknown): boolean {
|
||||
return n.id().safeParse(value).success;
|
||||
|
|
@ -88,6 +74,6 @@ function isURL(value: unknown): boolean {
|
|||
return z.string().url().safeParse(value).success;
|
||||
}
|
||||
|
||||
export { bech32ToPubkey, eventAge, findTag, isNostrId, isURL, type Nip05, nostrDate, nostrNow, parseNip05, sha256 };
|
||||
export { bech32ToPubkey, eventAge, findTag, isNostrId, isURL, type Nip05, nostrDate, nostrNow, parseNip05 };
|
||||
|
||||
export { Time } from '@/utils/time.ts';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue