New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

applesauce-core

Package Overview
Dependencies
Maintainers
0
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

applesauce-core - npm Package Compare versions

Comparing version 0.0.0-next-20241114194041 to 0.0.0-next-20241115160057

7

dist/helpers/profile.d.ts
import { NostrEvent } from "nostr-tools";
export declare const ProfileContentSymbol: unique symbol;
declare module "nostr-tools" {
interface Event {
[ProfileContentSymbol]?: ProfileContent | Error;
}
}
export type ProfileContent = {

@@ -24,3 +19,1 @@ name?: string;

export declare function getProfileContent(event: NostrEvent): ProfileContent;
export declare function getProfileContent(event: NostrEvent, quite: false): ProfileContent;
export declare function getProfileContent(event: NostrEvent, quite: true): ProfileContent | Error;

38

dist/helpers/profile.js

@@ -0,28 +1,16 @@

import { getOrComputeCachedValue } from "./cache.js";
export const ProfileContentSymbol = Symbol.for("profile-content");
export function getProfileContent(event, quite = false) {
let cached = event[ProfileContentSymbol];
if (!cached) {
try {
const profile = JSON.parse(event.content);
// ensure nip05 is a string
if (profile.nip05 && typeof profile.nip05 !== "string")
profile.nip05 = String(profile.nip05);
cached = event[ProfileContentSymbol] = profile;
/** Returns the parsed profile content for a kind 0 event */
export function getProfileContent(event) {
return getOrComputeCachedValue(event, ProfileContentSymbol, () => {
const profile = JSON.parse(event.content);
// ensure nip05 is a string
if (profile.nip05 && typeof profile.nip05 !== "string")
profile.nip05 = String(profile.nip05);
// add missing protocol to website
if (profile.website?.startsWith("http") === false) {
profile.website = "https://" + profile.website;
}
catch (e) {
if (e instanceof Error)
cached = event[ProfileContentSymbol] = e;
}
}
if (cached === undefined) {
throw new Error("Failed to parse profile");
}
else if (cached instanceof Error) {
if (!quite)
throw cached;
else
return cached;
}
else
return cached;
return profile;
});
}
{
"name": "applesauce-core",
"version": "0.0.0-next-20241114194041",
"version": "0.0.0-next-20241115160057",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc