nostr-components 0.2.6 → 0.3.0
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/README.md +105 -185
- package/dist/assets/{base-styles-CBypR3FR.js → base-styles-DC0ilu4S.js} +2 -2
- package/dist/assets/{base-styles-CBypR3FR.js.map → base-styles-DC0ilu4S.js.map} +1 -1
- package/dist/assets/{copy-delegation-C4uvRTVM.js → copy-delegation-CcagQMIW.js} +2 -2
- package/dist/assets/{copy-delegation-C4uvRTVM.js.map → copy-delegation-CcagQMIW.js.map} +1 -1
- package/dist/assets/{dialog-component-Da1ZIYh9.js → dialog-component-Dqg0QU9I.js} +2 -7
- package/dist/assets/dialog-component-Dqg0QU9I.js.map +1 -0
- package/dist/assets/{dialog-likers-BjiCHFan.js → dialog-likers-D3c7WIMp.js} +5 -5
- package/dist/assets/dialog-likers-D3c7WIMp.js.map +1 -0
- package/dist/assets/index.esm-ByUtE_cm.js +2159 -0
- package/dist/assets/index.esm-ByUtE_cm.js.map +1 -0
- package/dist/assets/nip05-utils-BNBHUmkr.js.map +1 -1
- package/dist/assets/nostr-login-service-D2FmscPI.js +2 -0
- package/dist/assets/nostr-login-service-D2FmscPI.js.map +1 -0
- package/dist/assets/nostr-service-m3Hgc5Xx.js +266 -0
- package/dist/assets/nostr-service-m3Hgc5Xx.js.map +1 -0
- package/dist/assets/nostr-user-component-XEnanH-d.js +2 -0
- package/dist/assets/nostr-user-component-XEnanH-d.js.map +1 -0
- package/dist/assets/{pure-jrVhRVpB.js → pure-laCRX9eG.js} +2 -2
- package/dist/assets/pure-laCRX9eG.js.map +1 -0
- package/dist/assets/theme-C1r1Zw8r.js.map +1 -1
- package/dist/assets/{user-resolver-C-E6KdwY.js → user-resolver-DqI5KGh6.js} +2 -2
- package/dist/assets/{user-resolver-C-E6KdwY.js.map → user-resolver-DqI5KGh6.js.map} +1 -1
- package/dist/assets/utils--bxLbhGF.js.map +1 -1
- package/dist/assets/zap-utils-BZcaCsT_.js +2 -0
- package/dist/assets/zap-utils-BZcaCsT_.js.map +1 -0
- package/dist/components/nostr-comment.es.js +26 -26
- package/dist/components/nostr-comment.es.js.map +1 -1
- package/dist/components/nostr-dm.es.js +2 -2
- package/dist/components/nostr-dm.es.js.map +1 -1
- package/dist/components/nostr-follow-button.es.js +6 -7
- package/dist/components/nostr-follow-button.es.js.map +1 -1
- package/dist/components/nostr-like.es.js +16 -16
- package/dist/components/nostr-like.es.js.map +1 -1
- package/dist/components/nostr-live-chat.es.js +2 -2
- package/dist/components/nostr-live-chat.es.js.map +1 -1
- package/dist/components/nostr-post.es.js +19 -19
- package/dist/components/nostr-post.es.js.map +1 -1
- package/dist/components/nostr-profile-badge.es.js +1 -1
- package/dist/components/nostr-profile-badge.es.js.map +1 -1
- package/dist/components/nostr-profile.es.js +1 -1
- package/dist/components/nostr-profile.es.js.map +1 -1
- package/dist/components/nostr-zap.es.js +24 -24
- package/dist/components/nostr-zap.es.js.map +1 -1
- package/dist/nostr-components.es.js +1 -1
- package/dist/nostr-components.umd.js +2644 -305
- package/dist/nostr-components.umd.js.map +1 -1
- package/package.json +5 -2
- package/dist/assets/dark-nostrich-running.gif +0 -0
- package/dist/assets/default_dp-NQ3TGrtT.png +0 -0
- package/dist/assets/default_dp.png +0 -0
- package/dist/assets/default_dp_32.png +0 -0
- package/dist/assets/dialog-component-Da1ZIYh9.js.map +0 -1
- package/dist/assets/dialog-likers-BjiCHFan.js.map +0 -1
- package/dist/assets/light-nostrich-running.gif +0 -0
- package/dist/assets/nostr-service-pr_crY62.js +0 -78
- package/dist/assets/nostr-service-pr_crY62.js.map +0 -1
- package/dist/assets/nostr-user-component-BOdux8_6.js +0 -2
- package/dist/assets/nostr-user-component-BOdux8_6.js.map +0 -1
- package/dist/assets/pure-jrVhRVpB.js.map +0 -1
- package/dist/assets/zap-utils-B1sz0Abx.js +0 -2
- package/dist/assets/zap-utils-B1sz0Abx.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/nostr-comment.d.ts +0 -4
- package/dist/nostr-dm.d.ts +0 -4
- package/dist/nostr-follow-button.d.ts +0 -4
- package/dist/nostr-like.d.ts +0 -4
- package/dist/nostr-live-chat.d.ts +0 -4
- package/dist/nostr-post.d.ts +0 -4
- package/dist/nostr-profile-badge.d.ts +0 -4
- package/dist/nostr-profile.d.ts +0 -4
- package/dist/nostr-zap.d.ts +0 -4
- package/dist/src/base/base-component/nostr-base-component.d.ts +0 -116
- package/dist/src/base/copy-delegation.d.ts +0 -5
- package/dist/src/base/dialog-component/dialog-component.d.ts +0 -67
- package/dist/src/base/dialog-component/style.d.ts +0 -5
- package/dist/src/base/event-component/nostr-event-component.d.ts +0 -53
- package/dist/src/base/render-options.d.ts +0 -5
- package/dist/src/base/resolvers/event-resolver.d.ts +0 -20
- package/dist/src/base/resolvers/user-resolver.d.ts +0 -19
- package/dist/src/base/text-row/render-name.d.ts +0 -7
- package/dist/src/base/text-row/render-nip05.d.ts +0 -1
- package/dist/src/base/text-row/render-npub.d.ts +0 -1
- package/dist/src/base/text-row/render-text-row.d.ts +0 -9
- package/dist/src/base/user-component/nostr-user-component.d.ts +0 -43
- package/dist/src/common/base-styles.d.ts +0 -44
- package/dist/src/common/constants.d.ts +0 -4
- package/dist/src/common/date-utils.d.ts +0 -9
- package/dist/src/common/icons.d.ts +0 -7
- package/dist/src/common/nip05-utils.d.ts +0 -13
- package/dist/src/common/nostr-service.d.ts +0 -40
- package/dist/src/common/theme.d.ts +0 -4
- package/dist/src/common/types.d.ts +0 -1
- package/dist/src/common/utils.d.ts +0 -34
- package/dist/src/index.d.ts +0 -32
- package/dist/src/nostr-comment/nostr-comment.d.ts +0 -60
- package/dist/src/nostr-comment/render.d.ts +0 -15
- package/dist/src/nostr-comment/utils.d.ts +0 -81
- package/dist/src/nostr-dm/nostr-dm.d.ts +0 -34
- package/dist/src/nostr-dm/render.d.ts +0 -15
- package/dist/src/nostr-follow-button/nostr-follow-button.d.ts +0 -24
- package/dist/src/nostr-follow-button/render.d.ts +0 -11
- package/dist/src/nostr-follow-button/style.d.ts +0 -1
- package/dist/src/nostr-like/dialog-help-style.d.ts +0 -1
- package/dist/src/nostr-like/dialog-help.d.ts +0 -2
- package/dist/src/nostr-like/dialog-likers-style.d.ts +0 -1
- package/dist/src/nostr-like/dialog-likers.d.ts +0 -24
- package/dist/src/nostr-like/like-utils.d.ts +0 -52
- package/dist/src/nostr-like/nostr-like.d.ts +0 -49
- package/dist/src/nostr-like/render.d.ts +0 -10
- package/dist/src/nostr-like/style.d.ts +0 -1
- package/dist/src/nostr-live-chat/nostr-live-chat.d.ts +0 -65
- package/dist/src/nostr-live-chat/render.d.ts +0 -31
- package/dist/src/nostr-post/nostr-post.d.ts +0 -25
- package/dist/src/nostr-post/parse-text.d.ts +0 -8
- package/dist/src/nostr-post/render-content.d.ts +0 -5
- package/dist/src/nostr-post/render.d.ts +0 -19
- package/dist/src/nostr-post/style.d.ts +0 -1
- package/dist/src/nostr-profile/nostr-profile.d.ts +0 -24
- package/dist/src/nostr-profile/render-stats.d.ts +0 -1
- package/dist/src/nostr-profile/render.d.ts +0 -22
- package/dist/src/nostr-profile/style.d.ts +0 -1
- package/dist/src/nostr-profile-badge/nostr-profile-badge.d.ts +0 -34
- package/dist/src/nostr-profile-badge/render.d.ts +0 -11
- package/dist/src/nostr-profile-badge/style.d.ts +0 -1
- package/dist/src/nostr-zap/dialog-help-style.d.ts +0 -5
- package/dist/src/nostr-zap/dialog-help.d.ts +0 -2
- package/dist/src/nostr-zap/dialog-zap-style.d.ts +0 -6
- package/dist/src/nostr-zap/dialog-zap.d.ts +0 -31
- package/dist/src/nostr-zap/dialog-zappers-style.d.ts +0 -1
- package/dist/src/nostr-zap/dialog-zappers.d.ts +0 -25
- package/dist/src/nostr-zap/nostr-zap.d.ts +0 -45
- package/dist/src/nostr-zap/render.d.ts +0 -9
- package/dist/src/nostr-zap/style.d.ts +0 -1
- package/dist/src/nostr-zap/zap-utils.d.ts +0 -53
- package/dist/vite.config.d.ts +0 -2
- package/dist/vite.config.esm.d.ts +0 -2
- package/dist/vite.config.umd.d.ts +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var l=Object.defineProperty;var p=(i,r,e)=>r in i?l(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var n=(i,r,e)=>p(i,typeof r!="symbol"?r+"":r,e);import{N as h,a as o}from"./base-styles-CBypR3FR.js";import{U as c}from"./user-resolver-C-E6KdwY.js";const d="nc:user";class C extends h{constructor(e=!0){super(e);n(this,"user",null);n(this,"profile",null);n(this,"userStatus",this.channel("user"));n(this,"loadSeq",0);n(this,"resolver",new c(this.nostrService))}static get observedAttributes(){return[...super.observedAttributes,"npub","pubkey","nip05"]}connectedCallback(){var e;(e=super.connectedCallback)==null||e.call(this),this.userStatus.get()==o.Idle&&this.initChannelStatus("user",o.Loading,{reflectOverall:!1}),this.validateInputs()&&this.resolveUserAndProfile().catch(t=>{console.error("[NostrUserComponent] init failed:",t)})}attributeChangedCallback(e,t,s){var u;t!==s&&((u=super.attributeChangedCallback)==null||u.call(this,e,t,s),(e==="npub"||e==="nip05"||e==="pubkey")&&this.validateInputs()&&this.resolveUserAndProfile())}validateInputs(){if(!super.validateInputs())return this.userStatus.set(o.Idle),!1;const e=this.getAttribute("npub"),t=this.getAttribute("pubkey"),s=this.getAttribute("nip05"),u=this.tagName.toLowerCase(),a=this.resolver.validateInputs({npub:e,pubkey:t,nip05:s});return a?(this.userStatus.set(o.Error,a),console.error(`Nostr-Components: ${u}: ${a}`),!1):(this.errorMessage="",!0)}async resolveUserAndProfile(){const e=++this.loadSeq;try{await this.ensureNostrConnected()}catch(t){if(e!==this.loadSeq)return;console.error("[NostrUserComponent] Relay connect failed before user/profile load:",t);return}this.userStatus.set(o.Loading);try{const{user:t,profile:s}=await this.resolver.resolveUser({npub:this.getAttribute("npub"),pubkey:this.getAttribute("pubkey"),nip05:this.getAttribute("nip05")});if(e!==this.loadSeq)return;if(s==null){this.userStatus.set(o.Error,"Profile not found");return}this.user=t,this.profile=s,this.userStatus.set(o.Ready),this.dispatchEvent(new CustomEvent(d,{detail:{user:this.user,profile:this.profile},bubbles:!0,composed:!0})),this.onUserReady(this.user,this.profile)}catch(t){if(e!==this.loadSeq)return;const s=t instanceof Error?t.message:"Failed to load user/profile";console.error("[NostrUserComponent] "+s,t),this.userStatus.set(o.Error,s)}}renderContent(){}onUserReady(e,t){}}export{C as N};
|
|
2
|
-
//# sourceMappingURL=nostr-user-component-BOdux8_6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nostr-user-component-BOdux8_6.js","sources":["../../src/base/user-component/nostr-user-component.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n\nimport { NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk';\nimport { NostrBaseComponent, NCStatus } from '../base-component/nostr-base-component';\nimport { UserResolver } from '../resolvers/user-resolver';\n\nconst EVT_USER = 'nc:user';\n\n/**\n * NostrUserComponent\n * ==================\n * Extension of `NostrBaseComponent` that resolves and manages a Nostr user.\n *\n * Overview\n * - Accepts identity attributes (`npub`, `nip05`, or `pubkey`) and validates them.\n * - Resolves an `NDKUser` via the shared `nostrService` and fetches its profile.\n * - Exposes resolved `user` and `profile` to subclasses for rendering or logic.\n * - Emits lifecycle events for status and user readiness.\n *\n * Observed attributes\n * - `npub` — user's Nostr public key (bech32 npub)\n * - `nip05` — NIP-05 identifier (e.g. `alice@example.com`)\n * - `pubkey` — raw hex-encoded public key\n *\n * Events\n * - `nc:status` — from base, reflects connection and user/profile loading status\n * - `nc:user` — fired when a user and profile are successfully resolved\n */\n\nexport class NostrUserComponent extends NostrBaseComponent {\n\n protected user: NDKUser | null = null;\n protected profile: NDKUserProfile | null = null;\n\n protected userStatus = this.channel('user');\n\n // guard to ignore stale user fetches\n private loadSeq = 0;\n\n private resolver = new UserResolver(this.nostrService);\n\n constructor(shadow: boolean = true) {\n super(shadow);\n }\n\n /** Lifecycle methods */\n static get observedAttributes() {\n return [\n ...super.observedAttributes,\n 'npub',\n 'pubkey',\n 'nip05',\n ];\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n\n if (this.userStatus.get() == NCStatus.Idle) {\n this.initChannelStatus('user', NCStatus.Loading, { reflectOverall: false });\n }\n\n if (this.validateInputs()) {\n this.resolveUserAndProfile().catch(e => {\n console.error('[NostrUserComponent] init failed:', e);\n });\n }\n }\n\n attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string | null\n ) {\n if (oldValue === newValue) return;\n super.attributeChangedCallback?.(name, oldValue, newValue);\n\n if (name === 'npub' || name === 'nip05' || name === 'pubkey') {\n if (this.validateInputs()) {\n // Re-resolve user + profile on identity changes\n void this.resolveUserAndProfile();\n }\n }\n }\n\n /** Protected methods */\n protected validateInputs(): boolean {\n\n if (!super.validateInputs()) {\n this.userStatus.set(NCStatus.Idle);\n return false;\n }\n\n const npub = this.getAttribute(\"npub\");\n const pubkey = this.getAttribute(\"pubkey\");\n const nip05 = this.getAttribute(\"nip05\");\n const tagName = this.tagName.toLowerCase();\n\n const err = this.resolver.validateInputs({\n npub: npub,\n pubkey: pubkey,\n nip05: nip05,\n });\n\n if (err) {\n this.userStatus.set(NCStatus.Error, err);\n console.error(`Nostr-Components: ${tagName}: ${err}`);\n return false;\n }\n\n this.errorMessage = \"\";\n return true;\n\n }\n\n protected async resolveUserAndProfile(): Promise<void> {\n const seq = ++this.loadSeq; // token to prevent stale writes\n\n // Ensure relays are connected; handle failure inside to avoid unhandled rejection\n try {\n await this.ensureNostrConnected();\n } catch (e) {\n if (seq !== this.loadSeq) return; // stale\n // Base already set status=Error, but make the failure explicit here too\n console.error('[NostrUserComponent] Relay connect failed before user/profile load:', e);\n return;\n }\n\n this.userStatus.set(NCStatus.Loading);\n\n try {\n const { user, profile } = await this.resolver.resolveUser({\n npub: this.getAttribute('npub'),\n pubkey: this.getAttribute('pubkey'),\n nip05: this.getAttribute('nip05'),\n });\n\n // stale call check\n if (seq !== this.loadSeq) return;\n\n if (profile == null) {\n this.userStatus.set(NCStatus.Error, \"Profile not found\");\n return;\n }\n\n this.user = user;\n this.profile = profile;\n this.userStatus.set(NCStatus.Ready);\n // Notify listeners that user + profile are available\n this.dispatchEvent(new CustomEvent(EVT_USER, {\n detail: { user: this.user, profile: this.profile },\n bubbles: true,\n composed: true,\n }));\n this.onUserReady(this.user!, this.profile);\n } catch (err) {\n if (seq !== this.loadSeq) return; // stale\n const msg = err instanceof Error ? err.message : 'Failed to load user/profile';\n console.error('[NostrUserComponent] ' + msg, err);\n this.userStatus.set(NCStatus.Error, msg);\n }\n }\n\n protected renderContent() { }\n\n /** Hook for subclasses to react when user/profile are ready (e.g., render). */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected onUserReady(_user: NDKUser, _profile: NDKUserProfile | null) { }\n}\n"],"names":["EVT_USER","NostrUserComponent","NostrBaseComponent","shadow","__publicField","UserResolver","_a","NCStatus","e","name","oldValue","newValue","npub","pubkey","nip05","tagName","err","seq","user","profile","msg","_user","_profile"],"mappings":"yQAMA,MAAMA,EAAW,UAuBV,MAAMC,UAA2BC,CAAmB,CAYzD,YAAYC,EAAkB,GAAM,CAClC,MAAMA,CAAM,EAXJC,EAAA,YAAuB,MACvBA,EAAA,eAAiC,MAEjCA,EAAA,kBAAa,KAAK,QAAQ,MAAM,GAGlCA,EAAA,eAAU,GAEVA,EAAA,gBAAW,IAAIC,EAAa,KAAK,YAAY,EAGvC,CAId,WAAW,oBAAqB,CACvB,MAAA,CACL,GAAG,MAAM,mBACT,OACA,SACA,OACF,CAAA,CAGF,mBAAoB,QAClBC,EAAA,MAAM,oBAAN,MAAAA,EAAA,WAEI,KAAK,WAAW,IAAI,GAAKC,EAAS,MACpC,KAAK,kBAAkB,OAAQA,EAAS,QAAS,CAAE,eAAgB,GAAO,EAGxE,KAAK,kBACF,KAAA,sBAAA,EAAwB,MAAWC,GAAA,CAC9B,QAAA,MAAM,oCAAqCA,CAAC,CAAA,CAC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,EAAS,KAAK,EAE7B,KAAA,cAAc,IAAI,YAAYP,EAAU,CAC3C,OAAQ,CAAE,KAAM,KAAK,KAAM,QAAS,KAAK,OAAQ,EACjD,QAAS,GACT,SAAU,EAAA,CACX,CAAC,EACF,KAAK,YAAY,KAAK,KAAO,KAAK,OAAO,QAClCgB,EAAK,CACR,GAAAC,IAAQ,KAAK,QAAS,OAC1B,MAAMG,EAAMJ,aAAe,MAAQA,EAAI,QAAU,8BACzC,QAAA,MAAM,wBAA0BI,EAAKJ,CAAG,EAChD,KAAK,WAAW,IAAIT,EAAS,MAAOa,CAAG,CAAA,CACzC,CAGQ,eAAgB,CAAA,CAIhB,YAAYC,EAAgBC,EAAiC,CAAA,CACzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pure-jrVhRVpB.js","sources":["../../node_modules/nostr-tools/lib/esm/pure.js"],"sourcesContent":["// pure.ts\nimport { schnorr } from \"@noble/curves/secp256k1\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\n\n// core.ts\nvar verifiedSymbol = Symbol(\"verified\");\nvar isRecord = (obj) => obj instanceof Object;\nfunction validateEvent(event) {\n if (!isRecord(event))\n return false;\n if (typeof event.kind !== \"number\")\n return false;\n if (typeof event.content !== \"string\")\n return false;\n if (typeof event.created_at !== \"number\")\n return false;\n if (typeof event.pubkey !== \"string\")\n return false;\n if (!event.pubkey.match(/^[a-f0-9]{64}$/))\n return false;\n if (!Array.isArray(event.tags))\n return false;\n for (let i2 = 0; i2 < event.tags.length; i2++) {\n let tag = event.tags[i2];\n if (!Array.isArray(tag))\n return false;\n for (let j = 0; j < tag.length; j++) {\n if (typeof tag[j] === \"object\")\n return false;\n }\n }\n return true;\n}\nfunction sortEvents(events) {\n return events.sort((a, b) => {\n if (a.created_at !== b.created_at) {\n return b.created_at - a.created_at;\n }\n return a.id.localeCompare(b.id);\n });\n}\n\n// pure.ts\nimport { sha256 } from \"@noble/hashes/sha256\";\n\n// utils.ts\nvar utf8Decoder = new TextDecoder(\"utf-8\");\nvar utf8Encoder = new TextEncoder();\n\n// pure.ts\nvar JS = class {\n generateSecretKey() {\n return schnorr.utils.randomPrivateKey();\n }\n getPublicKey(secretKey) {\n return bytesToHex(schnorr.getPublicKey(secretKey));\n }\n finalizeEvent(t, secretKey) {\n const event = t;\n event.pubkey = bytesToHex(schnorr.getPublicKey(secretKey));\n event.id = getEventHash(event);\n event.sig = bytesToHex(schnorr.sign(getEventHash(event), secretKey));\n event[verifiedSymbol] = true;\n return event;\n }\n verifyEvent(event) {\n if (typeof event[verifiedSymbol] === \"boolean\")\n return event[verifiedSymbol];\n const hash = getEventHash(event);\n if (hash !== event.id) {\n event[verifiedSymbol] = false;\n return false;\n }\n try {\n const valid = schnorr.verify(event.sig, hash, event.pubkey);\n event[verifiedSymbol] = valid;\n return valid;\n } catch (err) {\n event[verifiedSymbol] = false;\n return false;\n }\n }\n};\nfunction serializeEvent(evt) {\n if (!validateEvent(evt))\n throw new Error(\"can't serialize event with wrong or missing properties\");\n return JSON.stringify([0, evt.pubkey, evt.created_at, evt.kind, evt.tags, evt.content]);\n}\nfunction getEventHash(event) {\n let eventHash = sha256(utf8Encoder.encode(serializeEvent(event)));\n return bytesToHex(eventHash);\n}\nvar i = new JS();\nvar generateSecretKey = i.generateSecretKey;\nvar getPublicKey = i.getPublicKey;\nvar finalizeEvent = i.finalizeEvent;\nvar verifyEvent = i.verifyEvent;\nexport {\n finalizeEvent,\n generateSecretKey,\n getEventHash,\n getPublicKey,\n serializeEvent,\n sortEvents,\n validateEvent,\n verifiedSymbol,\n verifyEvent\n};\n"],"names":["verifiedSymbol","isRecord","obj","validateEvent","event","i2","tag","j","utf8Encoder","JS","schnorr","secretKey","bytesToHex","t","getEventHash","hash","valid","serializeEvent","evt","eventHash","sha256","i","generateSecretKey","getPublicKey","finalizeEvent"],"mappings":"8DAKG,IAACA,EAAiB,OAAO,UAAU,EAClCC,EAAYC,GAAQA,aAAe,OACvC,SAASC,EAAcC,EA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CAAc,EAAIgB,EACjBA,CACR,MAAa,CACZ,OAAAZ,EAAMJ,CAAc,EAAI,GACjB,EACb,CACA,CACA,EACA,SAASiB,EAAeC,EAAK,CAC3B,GAAI,CAACf,EAAce,CAAG,EACpB,MAAM,IAAI,MAAM,wDAAwD,EAC1E,OAAO,KAAK,UAAU,CAAC,EAAGA,EAAI,OAAQA,EAAI,WAAYA,EAAI,KAAMA,EAAI,KAAMA,EAAI,OAAO,CAAC,CACxF,CACA,SAASJ,EAAaV,EAAO,CAC3B,IAAIe,EAAYC,EAAOZ,EAAY,OAAOS,EAAeb,CAAK,CAAC,CAAC,EAChE,OAAOQ,EAAWO,CAAS,CAC7B,CACA,IAAIE,EAAI,IAAIZ,EACRa,EAAoBD,EAAE,kBACtBE,EAAeF,EAAE,aACjBG,EAAgBH,EAAE,cACJA,EAAE","x_google_ignoreList":[0]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as E,n as N,f as P}from"./nostr-service-pr_crY62.js";import{n as k}from"./utils--bxLbhGF.js";const m={},$=async t=>{if(m[t])return m[t];const n=new E,e=["wss://relay.nostr.band","wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{const a=await n.get(e,{authors:[t],kinds:[0]});return m[t]=a,a}finally{n.close(e)}},O=async t=>{const n=t.filter(r=>!m[r]);if(n.length===0)return t.map(r=>({id:r,profile:m[r]}));const e=new E,a=["wss://relay.nostr.band","wss://purplepag.es","wss://relay.damus.io","wss://nostr.wine"];try{return(await e.querySync(a,{authors:n,kinds:[0]})).forEach(o=>{m[o.pubkey]=o}),t.map(o=>({id:o,profile:m[o]||null}))}finally{e.close(a)}},x=t=>{try{return JSON.parse((t==null?void 0:t.content)||"{}")}catch{return{}}},z=async t=>{const n=await N.getZapEndpoint(t);if(!n)throw new Error("Failed to retrieve zap LNURL");return n},S=async(t,n)=>{if(R())try{const e=window.nostr;if(e!=null&&e.signEvent)return await e.signEvent(t)}catch{}return P(t,C())},Z=async({profile:t,nip19Target:n,amount:e,relays:a,comment:r,anon:c,url:o})=>{const p={profile:t,amount:e,relays:a,comment:r||""},i=N.makeZapRequest(p);return o&&(i.tags.push(["k","web"]),i.tags.push(["i",k(o)])),(!R()||c)&&i.tags.push(["anon"]),S(i)},D=async({zapEndpoint:t,amount:n,comment:e,authorId:a,nip19Target:r,normalizedRelays:c,anon:o,url:p})=>{const i=await Z({profile:a,nip19Target:r,amount:n,relays:c,comment:e??"",anon:o,url:p});let d=`${t}?amount=${n}&nostr=${encodeURIComponent(JSON.stringify(i))}`;e&&(d+=`&comment=${encodeURIComponent(e??"")}`);const l=await fetch(d,{method:"GET"});if(!l.ok)throw new Error(`LNURL request failed: ${l.status} ${l.statusText}`);let u;try{u=await l.json()}catch{throw new Error("Invalid JSON from LNURL endpoint")}const{pr:h,reason:v,status:g}=u||{};if(h)return h;throw g==="ERROR"?new Error(v??"Unable to fetch invoice"):new Error("Unable to fetch invoice")},C=()=>{const t=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else{console.warn("crypto.getRandomValues not available, using Math.random as fallback");for(let n=0;n<32;n++)t[n]=Math.floor(Math.random()*256)}return t},R=()=>typeof window<"u"&&!!window.nostr,J=async({pubkey:t,relays:n,url:e})=>{var p,i,d,l;const a=e?k(e):void 0,r=new E;let c=0;const o=[];try{const u={kinds:[9735],"#p":[t],limit:1e3},h=await r.querySync(n,u);for(const v of h){const g=(p=v.tags)==null?void 0:p.find(s=>s[0]==="description");if(g!=null&&g[1])try{const s=JSON.parse(g[1]),w=(i=s==null?void 0:s.tags)==null?void 0:i.find(f=>f[0]==="amount");if(a){const f=(d=s==null?void 0:s.tags)==null?void 0:d.find(y=>y[0]==="k"),b=(l=s==null?void 0:s.tags)==null?void 0:l.find(y=>y[0]==="i"),U=b!=null&&b[1]?k(b[1]):"";if((f==null?void 0:f[1])==="web"&&U===a&&(w!=null&&w[1])){const y=parseInt(w[1],10);y>0&&(c+=y,o.push({amount:y/1e3,date:new Date(v.created_at*1e3),authorPubkey:s.pubkey,comment:s.content}))}}else if(w!=null&&w[1]){const f=parseInt(w[1],10);f>0&&(c+=f,o.push({amount:f/1e3,date:new Date(v.created_at*1e3),authorPubkey:s.pubkey,comment:s.content}))}}catch(s){console.error("Nostr-Components: Zap button: Could not parse zap request from description tag",s)}}}catch(u){console.error("Nostr-Components: Zap button: Error fetching zap receipts",u)}finally{r.close(n)}return o.sort((u,h)=>h.date.getTime()-u.date.getTime()),{totalAmount:c/1e3,zapDetails:o}},M=({relays:t,receiversPubKey:n,invoice:e,onSuccess:a})=>{const r=new E,c=Array.from(new Set([...t,"wss://relay.nostr.band"])),o=Math.floor((Date.now()-24*60*60*1e3)/1e3);r.subscribe(c,{kinds:[9735],"#p":[n],since:o},{onevent(i){i.tags.some(l=>l[0]==="bolt11"&&l[1]===e)&&(a(),p())}});const p=()=>{r.close(c)};return p};export{x as extractProfileMetadataContent,D as fetchInvoice,J as fetchTotalZapAmount,O as getBatchedProfileMetadata,$ as getProfileMetadata,z as getZapEndpoint,R as isNip07ExtAvailable,M as listenForZapReceipt};
|
|
2
|
-
//# sourceMappingURL=zap-utils-B1sz0Abx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zap-utils-B1sz0Abx.js","sources":["../../src/nostr-zap/zap-utils.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n\nimport {\n nip57,\n nip05,\n finalizeEvent,\n SimplePool,\n} from 'nostr-tools';\nimport { decodeNip19Entity } from '../common/utils';\n\n/**\n * Helper utilities for Nostr zap operations (adapted from the original `nostr-zap` repo).\n * These are deliberately kept self-contained so `nostr-zap` Web Component can import\n * everything from a single module without polluting the rest of the codebase.\n */\n\n// Basic in-memory cache – sufficient for component lifetime.\nconst profileCache: Record<string, any> = {};\n\nexport const getProfileMetadata = async (authorId: string) => {\n if (profileCache[authorId]) return profileCache[authorId];\n\n const pool = new SimplePool();\n const relays = [\n 'wss://relay.nostr.band',\n 'wss://purplepag.es',\n 'wss://relay.damus.io',\n 'wss://nostr.wine',\n ];\n\n try {\n const event = await pool.get(relays, {\n authors: [authorId],\n kinds: [0],\n });\n profileCache[authorId] = event;\n return event;\n } finally {\n pool.close(relays);\n }\n};\n\nexport const getBatchedProfileMetadata = async (authorIds: string[]) => {\n // Filter out already cached profiles\n const uncachedIds = authorIds.filter(id => !profileCache[id]);\n\n // If all profiles are cached, return them\n if (uncachedIds.length === 0) {\n return authorIds.map(id => ({ id, profile: profileCache[id] }));\n }\n\n const pool = new SimplePool();\n const relays = [\n 'wss://relay.nostr.band',\n 'wss://purplepag.es',\n 'wss://relay.damus.io',\n 'wss://nostr.wine',\n ];\n\n try {\n // Fetch all uncached profiles in a single query\n const events = await pool.querySync(relays, {\n authors: uncachedIds,\n kinds: [0],\n });\n\n // Cache the fetched profiles\n events.forEach(event => {\n profileCache[event.pubkey] = event;\n });\n\n // Combine cached and newly fetched profiles\n const allProfiles = authorIds.map(id => ({\n id,\n profile: profileCache[id] || null\n }));\n\n return allProfiles;\n } finally {\n pool.close(relays);\n }\n};\n\nexport const extractProfileMetadataContent = (profileMetadata: any) => {\n try {\n return JSON.parse(profileMetadata?.content || '{}');\n } catch {\n return {};\n }\n};\n\nexport const getZapEndpoint = async (profileMetadata: any) => {\n const endpoint = await nip57.getZapEndpoint(profileMetadata);\n if (!endpoint) throw new Error('Failed to retrieve zap LNURL');\n return endpoint;\n};\n\ninterface NostrExtension {\n signEvent(event: any): Promise<{\n id: string;\n sig: string;\n kind: number;\n tags: string[][];\n pubkey: string;\n content: string;\n created_at: number;\n }>;\n}\n\nconst signEvent = async (zapEvent: any, anon?: boolean) => {\n if (isNip07ExtAvailable() && !anon) {\n try {\n const ext = (window as { nostr?: NostrExtension }).nostr;\n if (ext?.signEvent) return await ext.signEvent(zapEvent);\n } catch {\n /* fall-through -> anonymous */\n }\n }\n return finalizeEvent(zapEvent, generateRandomPrivKey());\n};\n\nconst makeZapEvent = async ({\n profile,\n nip19Target,\n amount,\n relays,\n comment,\n anon,\n url,\n}: {\n profile: string;\n nip19Target?: string;\n amount: number;\n relays: string[];\n comment?: string;\n anon?: boolean;\n url?: string;\n}) => {\n const req: any = {\n profile,\n amount,\n relays,\n comment: comment || '',\n };\n if (nip19Target?.startsWith('note')) {\n req.event = decodeNip19Entity(nip19Target);\n }\n const event = nip57.makeZapRequest(req);\n\n if (nip19Target?.startsWith('naddr')) {\n const naddrData: any = decodeNip19Entity(nip19Target);\n const relayTag = naddrData?.relays?.join(',') ?? '';\n event.tags.push(['a', `${naddrData.kind}:${naddrData.pubkey}:${naddrData.identifier}`, relayTag]);\n }\n\n // Add URL-based zap tags if URL is provided\n if (url) {\n event.tags.push(['k', 'web']);\n event.tags.push(['i', normalizeURL(url)]);\n }\n\n if (!isNip07ExtAvailable() || anon) {\n event.tags.push(['anon']);\n }\n\n return signEvent(event, anon);\n};\n\nexport const fetchInvoice = async ({\n zapEndpoint,\n amount,\n comment,\n authorId,\n nip19Target,\n normalizedRelays,\n anon,\n url,\n}: {\n zapEndpoint: string;\n amount: number;\n comment?: string;\n authorId: string;\n nip19Target?: string;\n normalizedRelays: string[];\n anon?: boolean;\n url?: string;\n}): Promise<string> => {\n const zapEvent = await makeZapEvent({\n profile: authorId,\n nip19Target,\n amount,\n relays: normalizedRelays,\n comment: comment ?? '',\n anon,\n url,\n });\n\n\n let invoiceUrl = `${zapEndpoint}?amount=${amount}&nostr=${encodeURIComponent(\n JSON.stringify(zapEvent)\n )}`;\n if (comment) invoiceUrl += `&comment=${encodeURIComponent(comment ?? '')}`;\n\n const res = await fetch(invoiceUrl, { method: 'GET' });\n if (!res.ok) {\n throw new Error(`LNURL request failed: ${res.status} ${res.statusText}`);\n }\n let json: any;\n try {\n json = await res.json();\n } catch {\n throw new Error('Invalid JSON from LNURL endpoint');\n }\n const { pr: invoice, reason, status } = json || {};\n if (invoice) return invoice;\n if (status === 'ERROR') throw new Error(reason ?? 'Unable to fetch invoice');\n throw new Error('Unable to fetch invoice');\n};\n\nconst generateRandomPrivKey = (): Uint8Array => {\n const bytes = new Uint8Array(32);\n if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {\n crypto.getRandomValues(bytes);\n } else {\n // Node.js fallback during build – use Math.random (not cryptographically strong but acceptable for anon zaps)\n console.warn('crypto.getRandomValues not available, using Math.random as fallback');\n for (let i = 0; i < 32; i++) bytes[i] = Math.floor(Math.random() * 256);\n }\n return bytes;\n};\n\nexport const isNip07ExtAvailable = (): boolean => typeof window !== 'undefined' && !!(window as any).nostr;\n\n// ---------------------------------------------------------------------------\n// nip05 resolution helper – very lightweight fetch to /.well-known/nostr.json\n// ---------------------------------------------------------------------------\n\n\n\nexport async function resolveNip05(nip05Identifier: string): Promise<string | null> {\n try {\n const profile = await nip05.queryProfile(nip05Identifier);\n return profile?.pubkey || null;\n } catch (error) {\n console.error(`Failed to resolve NIP-05 ${nip05Identifier}:`, error);\n return null;\n }\n}\n\n// Import necessary types from nostr-tools\nimport type { Filter, Event } from 'nostr-tools';\nimport { normalizeURL } from '../nostr-comment/utils';\n\n// Augment the SimplePool type to include our usage\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ndeclare module 'nostr-tools' {\n interface SimplePool {\n subscribe(\n relays: string[],\n filter: Filter,\n params: {\n onevent: (event: Event) => void;\n onclose?: () => void;\n id?: string;\n maxWait?: number;\n }\n ): {\n close: () => void;\n };\n }\n}\n\nexport interface ZapDetails {\n amount: number;\n date: Date;\n authorPubkey: string;\n comment?: string;\n}\n\nexport interface ZapAmountResult {\n totalAmount: number;\n zapDetails: ZapDetails[];\n}\n\nexport const fetchTotalZapAmount = async ({\n pubkey,\n relays,\n url,\n}: {\n pubkey: string;\n relays: string[];\n url?: string;\n}): Promise<ZapAmountResult> => {\n // Normalize URL at the beginning for consistent comparison with tags\n const normalizedUrl = url ? normalizeURL(url) : undefined;\n \n const pool = new SimplePool();\n let totalAmount = 0;\n const zapDetails: ZapDetails[] = [];\n\n try {\n // Build filter for zap receipt events\n const filter: any = {\n kinds: [9735], // Zap receipt\n '#p': [pubkey],\n limit: 1000,\n };\n\n // Add URL-based filtering if URL is provided\n // TODO: These tags doesn't appear in zap receipt event.\n // They goes into the description tag, which has the zap request JSON.\n /*\n if (normalizedUrl) {\n filter['#k'] = ['web'];\n filter['#i'] = [normalizedUrl];\n }\n */\n\n // Use pool.querySync to fetch multiple zap receipt events\n const events = await pool.querySync(relays, filter);\n\n for (const event of events) {\n const descriptionTag = event.tags?.find((tag: string[]) => tag[0] === 'description');\n if (descriptionTag?.[1]) {\n try {\n const zapRequest = JSON.parse(descriptionTag[1]);\n const amountTag = zapRequest?.tags?.find((tag: string[]) => tag[0] === 'amount');\n \n // If URL is provided, check for URL-based zap tags\n // TODO: Too much work, since #k and #i tags doesn't appear in zap receipt event.\n // This is not a practical solution, but it's working for now!\n if (normalizedUrl) {\n const kTag = zapRequest?.tags?.find((tag: string[]) => tag[0] === 'k');\n const iTag = zapRequest?.tags?.find((tag: string[]) => tag[0] === 'i');\n \n const iTagNormalized = iTag?.[1] ? normalizeURL(iTag[1]) : '';\n if (kTag?.[1] === 'web' && iTagNormalized === normalizedUrl && amountTag?.[1]) {\n const amount = parseInt(amountTag[1], 10);\n if (amount > 0) {\n totalAmount += amount;\n zapDetails.push({\n amount: amount / 1000, // convert from msats to sats\n date: new Date(event.created_at * 1000),\n authorPubkey: zapRequest.pubkey,\n comment: zapRequest.content,\n });\n }\n }\n } else {\n // No URL filtering - count all zaps\n if (amountTag?.[1]) {\n const amount = parseInt(amountTag[1], 10);\n if (amount > 0) {\n totalAmount += amount;\n zapDetails.push({\n amount: amount / 1000, // convert from msats to sats\n date: new Date(event.created_at * 1000),\n authorPubkey: zapRequest.pubkey,\n comment: zapRequest.content,\n });\n }\n }\n }\n } catch (e) {\n console.error(\"Nostr-Components: Zap button: Could not parse zap request from description tag\", e);\n }\n }\n }\n } catch (error) {\n console.error(\"Nostr-Components: Zap button: Error fetching zap receipts\", error);\n } finally {\n pool.close(relays);\n }\n\n // Sort zap details by date (newest first)\n zapDetails.sort((a, b) => b.date.getTime() - a.date.getTime());\n\n return {\n totalAmount: totalAmount / 1000, // convert from msats to sats\n zapDetails,\n };\n};\n\nexport const listenForZapReceipt = ({\n relays,\n receiversPubKey,\n invoice,\n onSuccess,\n}: {\n relays: string[];\n receiversPubKey: string,\n invoice: string;\n onSuccess: () => void;\n}) => {\n const pool = new SimplePool();\n const normalizedRelays = Array.from(new Set([...relays, 'wss://relay.nostr.band']));\n const since = Math.floor((Date.now() - 24 * 60 * 60 * 1000) / 1000); // current time - 24 hours\n\n pool.subscribe(\n normalizedRelays,\n {\n kinds: [9735],\n '#p': [receiversPubKey],\n since,\n },\n {\n onevent(event: Event) {\n const tags = event.tags as [string, string][];\n if (tags.some(t => t[0] === 'bolt11' && t[1] === invoice)) {\n onSuccess();\n cleanup();\n }\n }\n }\n );\n\n const cleanup = () => {\n pool.close(normalizedRelays);\n };\n\n return cleanup;\n};\n"],"names":["profileCache","getProfileMetadata","authorId","pool","SimplePool","relays","event","getBatchedProfileMetadata","authorIds","uncachedIds","id","extractProfileMetadataContent","profileMetadata","getZapEndpoint","endpoint","nip57","signEvent","zapEvent","anon","isNip07ExtAvailable","ext","finalizeEvent","generateRandomPrivKey","makeZapEvent","profile","nip19Target","amount","comment","url","req","normalizeURL","fetchInvoice","zapEndpoint","normalizedRelays","invoiceUrl","res","json","invoice","reason","status","bytes","i","fetchTotalZapAmount","pubkey","normalizedUrl","totalAmount","zapDetails","filter","events","descriptionTag","_a","tag","zapRequest","amountTag","_b","kTag","_c","iTag","_d","iTagNormalized","e","error","a","b","listenForZapReceipt","receiversPubKey","onSuccess","since","t","cleanup"],"mappings":"sGAiBA,MAAMA,EAAoC,CAAC,EAE9BC,EAAqB,MAAOC,GAAqB,CAC5D,GAAIF,EAAaE,CAAQ,EAAG,OAAOF,EAAaE,CAAQ,EAElD,MAAAC,EAAO,IAAIC,EACXC,EAAS,CACb,yBACA,qBACA,uBACA,kBAC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,EAAQ,wBAAwB,CAAC,CAAC,EAC5E8D,EAAQ,KAAK,OAAO,KAAK,MAAQ,GAAK,GAAK,GAAK,KAAQ,GAAI,EAE7DhE,EAAA,UACH8B,EACA,CACE,MAAO,CAAC,IAAI,EACZ,KAAM,CAACgC,CAAe,EACtB,MAAAE,CACF,EACA,CACE,QAAQ7D,EAAc,CACPA,EAAM,KACV,KAAK8D,GAAKA,EAAE,CAAC,IAAM,UAAYA,EAAE,CAAC,IAAM/B,CAAO,IAC5C6B,EAAA,EACFG,EAAA,EACV,CACF,CAEJ,EAEA,MAAMA,EAAU,IAAM,CACpBlE,EAAK,MAAM8B,CAAgB,CAC7B,EAEO,OAAAoC,CACT"}
|
package/dist/index.d.ts
DELETED
package/dist/nostr-comment.d.ts
DELETED
package/dist/nostr-dm.d.ts
DELETED
package/dist/nostr-like.d.ts
DELETED
package/dist/nostr-post.d.ts
DELETED
package/dist/nostr-profile.d.ts
DELETED
package/dist/nostr-zap.d.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { NostrService } from '../../common/nostr-service';
|
|
2
|
-
import { Theme } from '../../common/types';
|
|
3
|
-
export declare enum NCStatus {
|
|
4
|
-
Idle = 0,// 0
|
|
5
|
-
Loading = 1,// 1
|
|
6
|
-
Ready = 2,// 2
|
|
7
|
-
Error = 3
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* NostrBaseComponent
|
|
11
|
-
* ==================
|
|
12
|
-
* Foundation for all Nostr web components in this library.
|
|
13
|
-
*
|
|
14
|
-
* Overview
|
|
15
|
-
* - Manages relay connectivity via a shared `NostrService`.
|
|
16
|
-
* - Parses common attributes (`theme`, `relays`) and applies theme.
|
|
17
|
-
* - Provides a generic status management logic, that is extensible by derived classes.
|
|
18
|
-
* - Offers small utilities useful to subclasses (event delegation, error snippet).
|
|
19
|
-
*
|
|
20
|
-
* Observed attributes
|
|
21
|
-
* - `data-theme` — "light" | "dark"
|
|
22
|
-
* - `relays` — CSV of relay URLs
|
|
23
|
-
*
|
|
24
|
-
* Events
|
|
25
|
-
* - `nc:status` — from base, reflects connection and user/profile loading status
|
|
26
|
-
*
|
|
27
|
-
* TODO: Is this class doing too much work? Time to split into smaller components?
|
|
28
|
-
*/
|
|
29
|
-
export declare abstract class NostrBaseComponent extends HTMLElement {
|
|
30
|
-
protected nostrService: NostrService;
|
|
31
|
-
protected theme: Theme;
|
|
32
|
-
protected errorMessage: string;
|
|
33
|
-
protected nostrReady: Promise<void>;
|
|
34
|
-
protected nostrReadyResolve?: () => void;
|
|
35
|
-
protected nostrReadyReject?: (e: unknown) => void;
|
|
36
|
-
protected conn: {
|
|
37
|
-
set: (s: NCStatus, e?: string) => void;
|
|
38
|
-
get: () => NCStatus;
|
|
39
|
-
};
|
|
40
|
-
private _statuses;
|
|
41
|
-
private _overall;
|
|
42
|
-
private connectSeq;
|
|
43
|
-
constructor(shadow?: boolean);
|
|
44
|
-
/** Lifecycle methods */
|
|
45
|
-
static get observedAttributes(): string[];
|
|
46
|
-
connectedCallback(): void;
|
|
47
|
-
disconnectedCallback(): void;
|
|
48
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
49
|
-
/** Status map API */
|
|
50
|
-
protected setStatusFor(key: string, next: NCStatus, error?: string): void;
|
|
51
|
-
protected getStatusFor(key: string): NCStatus;
|
|
52
|
-
protected snapshotStatuses(): Record<string, NCStatus>;
|
|
53
|
-
/** Overall status change hook */
|
|
54
|
-
protected onStatusChange(_overall: NCStatus): void;
|
|
55
|
-
/** Hook for subclasses to react when relays are connected */
|
|
56
|
-
protected onNostrRelaysConnected(): void;
|
|
57
|
-
protected computeOverall(): NCStatus;
|
|
58
|
-
/**
|
|
59
|
-
* Before first channel.set(), the map won't be set and hence get() will return `idle`.
|
|
60
|
-
* In some cases (or maybe in all cases), this is not ideal.
|
|
61
|
-
* In UserComponent, 'user' not set and hence returning `idle`, while
|
|
62
|
-
* 'connect' switched between idle -> loading -> ready
|
|
63
|
-
* and then
|
|
64
|
-
* 'user' switches to loading -> ready,
|
|
65
|
-
* results in loading -> ready -> loading -> ready in profile-badge onStatusChange.
|
|
66
|
-
*
|
|
67
|
-
* To avoid this, this function is called from UserComponent constructor,
|
|
68
|
-
* to set default value as 'loading' without emitting onStatusChange event.
|
|
69
|
-
*
|
|
70
|
-
* Makes sense?
|
|
71
|
-
* Try commenting this function call in UserComponent()
|
|
72
|
-
* and add a log in ProfileBadge :: onStatusChange. You will get it.
|
|
73
|
-
*/
|
|
74
|
-
protected initChannelStatus(key: string, status: NCStatus, opts?: {
|
|
75
|
-
reflectOverall: boolean;
|
|
76
|
-
}): void;
|
|
77
|
-
protected channel(key: string): {
|
|
78
|
-
set: (s: NCStatus, e?: string) => void;
|
|
79
|
-
get: () => NCStatus;
|
|
80
|
-
};
|
|
81
|
-
/** Protected methods */
|
|
82
|
-
protected validateInputs(): boolean;
|
|
83
|
-
protected connectToNostr(): Promise<void>;
|
|
84
|
-
protected ensureNostrConnected(): Promise<void>;
|
|
85
|
-
protected getRelays(): string[];
|
|
86
|
-
protected getTheme(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Delegate events within shadow DOM.
|
|
89
|
-
* Example: this.delegateEvent('click', '#npub-copy', (e) => this.copyNpub(e));
|
|
90
|
-
*/
|
|
91
|
-
protected delegateEvent<K extends keyof HTMLElementEventMap>(type: K, selector: string, handler: (event: HTMLElementEventMap[K]) => void): void;
|
|
92
|
-
protected addDelegatedListener<K extends keyof HTMLElementEventMap>(type: K, selector: string, handler: (event: HTMLElementEventMap[K]) => void): void;
|
|
93
|
-
protected renderError(errorMessage: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* Updates host element classes based on component status
|
|
96
|
-
* This is a common pattern used by all components
|
|
97
|
-
*/
|
|
98
|
-
protected updateHostClasses(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Base render method that handles common render logic
|
|
101
|
-
* Subclasses should override renderContent() instead of render()
|
|
102
|
-
*/
|
|
103
|
-
protected render(): void;
|
|
104
|
-
/**
|
|
105
|
-
* Handles click events with njump.me default action
|
|
106
|
-
* Creates custom event, dispatches it, and opens njump.me if not prevented
|
|
107
|
-
*/
|
|
108
|
-
protected handleNjumpClick(eventType: string, detail: any, njumpPath: string): void;
|
|
109
|
-
/**
|
|
110
|
-
* Abstract method for component-specific rendering
|
|
111
|
-
* Must be implemented by subclasses
|
|
112
|
-
*/
|
|
113
|
-
protected abstract renderContent(): void;
|
|
114
|
-
/** Private methods */
|
|
115
|
-
private resetNostrReadyBarrier;
|
|
116
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base dialog component that extends HTMLElement
|
|
3
|
-
* Provides common dialog functionality with header, close button, and content area
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* ```typescript
|
|
7
|
-
* const dialog = document.createElement('dialog-component');
|
|
8
|
-
* dialog.setAttribute('header', 'Dialog Title');
|
|
9
|
-
* dialog.innerHTML = '<p>Your content goes here</p>';
|
|
10
|
-
* dialog.showModal(); // Don't append to body, just call showModal()
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Header with customizable text
|
|
15
|
-
* - Close button
|
|
16
|
-
* - Click outside to close
|
|
17
|
-
* - ESC key to close
|
|
18
|
-
* - Automatic cleanup on close
|
|
19
|
-
*
|
|
20
|
-
* Important: Only one instance of this component should be added to the DOM at any time.
|
|
21
|
-
* Multiple instances may cause conflicts with event listeners and cleanup behavior.
|
|
22
|
-
*/
|
|
23
|
-
export declare class DialogComponent extends HTMLElement {
|
|
24
|
-
private dialog;
|
|
25
|
-
constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Observed attributes for the component
|
|
28
|
-
*/
|
|
29
|
-
static get observedAttributes(): string[];
|
|
30
|
-
/**
|
|
31
|
-
* Inject dialog styles into document head
|
|
32
|
-
* Prevents duplicate injection by checking for existing styles
|
|
33
|
-
*/
|
|
34
|
-
private injectStyles;
|
|
35
|
-
/**
|
|
36
|
-
* Render the dialog
|
|
37
|
-
*/
|
|
38
|
-
private render;
|
|
39
|
-
/**
|
|
40
|
-
* Setup event listeners for closing the dialog
|
|
41
|
-
*/
|
|
42
|
-
private setupEventListeners;
|
|
43
|
-
/**
|
|
44
|
-
* Show the dialog (alias for showModal)
|
|
45
|
-
*/
|
|
46
|
-
show(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Show the dialog as modal
|
|
49
|
-
*/
|
|
50
|
-
showModal(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Close the dialog
|
|
53
|
-
*/
|
|
54
|
-
close(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Cleanup when dialog is closed
|
|
57
|
-
*/
|
|
58
|
-
private cleanup;
|
|
59
|
-
/**
|
|
60
|
-
* Called when component is removed from DOM
|
|
61
|
-
*/
|
|
62
|
-
disconnectedCallback(): void;
|
|
63
|
-
/**
|
|
64
|
-
* Called when observed attributes change
|
|
65
|
-
*/
|
|
66
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
67
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { NDKEvent, NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
2
|
-
import { NostrBaseComponent, NCStatus } from '../base-component/nostr-base-component';
|
|
3
|
-
/**
|
|
4
|
-
* NostrEventComponent
|
|
5
|
-
* ==================
|
|
6
|
-
* Extension of `NostrBaseComponent` that resolves and manages a Nostr Event.
|
|
7
|
-
*
|
|
8
|
-
* Overview
|
|
9
|
-
* - Accepts identity attributes (`hex`, `noteid`, or `eventid`) and validates them.
|
|
10
|
-
* - Resolves an `NDKEvent` via the shared `nostrService` and fetches the event.
|
|
11
|
-
* - Exposes resolved `event` to subclasses for rendering or logic.
|
|
12
|
-
* - Emits lifecycle events for status and event readiness.
|
|
13
|
-
*
|
|
14
|
-
* Observed attributes
|
|
15
|
-
* - `hex` — raw hex-encoded event ID
|
|
16
|
-
* - `noteid` — bech32-encoded event ID starting with 'note1...'
|
|
17
|
-
* - `eventid` — bech32-encoded event pointer starting with 'nevent1...' (encodes extra metadata)
|
|
18
|
-
*
|
|
19
|
-
* Events
|
|
20
|
-
* - `nc:status` — from base, reflects connection and event loading status
|
|
21
|
-
* - `nc:event` — fired when an event is successfully resolved
|
|
22
|
-
*/
|
|
23
|
-
export declare class NostrEventComponent extends NostrBaseComponent {
|
|
24
|
-
protected event: NDKEvent | null;
|
|
25
|
-
protected author: NDKUser | null;
|
|
26
|
-
protected authorProfile: NDKUserProfile | null;
|
|
27
|
-
protected formattedDate: string;
|
|
28
|
-
protected eventStatus: {
|
|
29
|
-
set: (s: NCStatus, e?: string) => void;
|
|
30
|
-
get: () => NCStatus;
|
|
31
|
-
};
|
|
32
|
-
protected authorStatus: {
|
|
33
|
-
set: (s: NCStatus, e?: string) => void;
|
|
34
|
-
get: () => NCStatus;
|
|
35
|
-
};
|
|
36
|
-
private loadSeq;
|
|
37
|
-
private eventResolver;
|
|
38
|
-
private userResolver;
|
|
39
|
-
constructor(shadow?: boolean);
|
|
40
|
-
/** Lifecycle methods */
|
|
41
|
-
static get observedAttributes(): string[];
|
|
42
|
-
connectedCallback(): void;
|
|
43
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
44
|
-
/** Protected methods */
|
|
45
|
-
protected validateInputs(): boolean;
|
|
46
|
-
protected resolveEventAndLoad(): Promise<void>;
|
|
47
|
-
private loadAuthorProfile;
|
|
48
|
-
private checkEventAndAuthorReady;
|
|
49
|
-
private formatEventDate;
|
|
50
|
-
protected renderContent(): void;
|
|
51
|
-
/** Hook for subclasses to react when event is ready (e.g., render). */
|
|
52
|
-
protected onEventReady(_event: NDKEvent): void;
|
|
53
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
|
2
|
-
import { NostrService } from '../../common/nostr-service';
|
|
3
|
-
export declare class EventResolver {
|
|
4
|
-
private nostrService;
|
|
5
|
-
constructor(nostrService: NostrService);
|
|
6
|
-
validateInputs({ hex, noteid, eventid }: {
|
|
7
|
-
hex?: string | null;
|
|
8
|
-
noteid?: string | null;
|
|
9
|
-
eventid?: string | null;
|
|
10
|
-
}): string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Normalize bech32 identifiers to hex format
|
|
13
|
-
*/
|
|
14
|
-
private normalizeToHex;
|
|
15
|
-
resolveEvent({ hex, noteid, eventid }: {
|
|
16
|
-
hex?: string | null;
|
|
17
|
-
noteid?: string | null;
|
|
18
|
-
eventid?: string | null;
|
|
19
|
-
}): Promise<NDKEvent>;
|
|
20
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
2
|
-
import { NostrService } from '../../common/nostr-service';
|
|
3
|
-
export declare class UserResolver {
|
|
4
|
-
private nostrService;
|
|
5
|
-
constructor(nostrService: NostrService);
|
|
6
|
-
validateInputs({ npub, pubkey, nip05 }: {
|
|
7
|
-
npub?: string | null;
|
|
8
|
-
pubkey?: string | null;
|
|
9
|
-
nip05?: string | null;
|
|
10
|
-
}): string | null;
|
|
11
|
-
resolveUser({ npub, pubkey, nip05 }: {
|
|
12
|
-
npub?: string | null;
|
|
13
|
-
pubkey?: string | null;
|
|
14
|
-
nip05?: string | null;
|
|
15
|
-
}): Promise<{
|
|
16
|
-
user: NDKUser;
|
|
17
|
-
profile: NDKUserProfile | null;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function renderNip05(nip05: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function renderNpub(npub: string): string;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
|
2
|
-
import { NostrBaseComponent, NCStatus } from '../base-component/nostr-base-component';
|
|
3
|
-
/**
|
|
4
|
-
* NostrUserComponent
|
|
5
|
-
* ==================
|
|
6
|
-
* Extension of `NostrBaseComponent` that resolves and manages a Nostr user.
|
|
7
|
-
*
|
|
8
|
-
* Overview
|
|
9
|
-
* - Accepts identity attributes (`npub`, `nip05`, or `pubkey`) and validates them.
|
|
10
|
-
* - Resolves an `NDKUser` via the shared `nostrService` and fetches its profile.
|
|
11
|
-
* - Exposes resolved `user` and `profile` to subclasses for rendering or logic.
|
|
12
|
-
* - Emits lifecycle events for status and user readiness.
|
|
13
|
-
*
|
|
14
|
-
* Observed attributes
|
|
15
|
-
* - `npub` — user's Nostr public key (bech32 npub)
|
|
16
|
-
* - `nip05` — NIP-05 identifier (e.g. `alice@example.com`)
|
|
17
|
-
* - `pubkey` — raw hex-encoded public key
|
|
18
|
-
*
|
|
19
|
-
* Events
|
|
20
|
-
* - `nc:status` — from base, reflects connection and user/profile loading status
|
|
21
|
-
* - `nc:user` — fired when a user and profile are successfully resolved
|
|
22
|
-
*/
|
|
23
|
-
export declare class NostrUserComponent extends NostrBaseComponent {
|
|
24
|
-
protected user: NDKUser | null;
|
|
25
|
-
protected profile: NDKUserProfile | null;
|
|
26
|
-
protected userStatus: {
|
|
27
|
-
set: (s: NCStatus, e?: string) => void;
|
|
28
|
-
get: () => NCStatus;
|
|
29
|
-
};
|
|
30
|
-
private loadSeq;
|
|
31
|
-
private resolver;
|
|
32
|
-
constructor(shadow?: boolean);
|
|
33
|
-
/** Lifecycle methods */
|
|
34
|
-
static get observedAttributes(): string[];
|
|
35
|
-
connectedCallback(): void;
|
|
36
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
37
|
-
/** Protected methods */
|
|
38
|
-
protected validateInputs(): boolean;
|
|
39
|
-
protected resolveUserAndProfile(): Promise<void>;
|
|
40
|
-
protected renderContent(): void;
|
|
41
|
-
/** Hook for subclasses to react when user/profile are ready (e.g., render). */
|
|
42
|
-
protected onUserReady(_user: NDKUser, _profile: NDKUserProfile | null): void;
|
|
43
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Styles Utility for Nostr Components
|
|
3
|
-
* =========================================
|
|
4
|
-
*
|
|
5
|
-
* This utility provides common base styles that can be shared across components.
|
|
6
|
-
* It includes design tokens, common patterns, and utility functions.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Generates minimal base styles for any Nostr component
|
|
10
|
-
* Includes only essential design tokens and base component styles
|
|
11
|
-
* Uses generic CSS variables that can be overridden by data-theme
|
|
12
|
-
*/
|
|
13
|
-
export declare function getBaseStyles(): string;
|
|
14
|
-
/**
|
|
15
|
-
* Generates component-specific styles by combining base styles with custom styles
|
|
16
|
-
* Uses CSS theme variables instead of theme prop
|
|
17
|
-
*/
|
|
18
|
-
export declare function getComponentStyles(customStyles: string): string;
|
|
19
|
-
export declare const styleUtils: {
|
|
20
|
-
/**
|
|
21
|
-
* Generates error state styles
|
|
22
|
-
*/
|
|
23
|
-
error: () => string;
|
|
24
|
-
/**
|
|
25
|
-
* Generates skeleton loading styles
|
|
26
|
-
*/
|
|
27
|
-
skeleton: () => string;
|
|
28
|
-
/**
|
|
29
|
-
* Generates copy button styles
|
|
30
|
-
*/
|
|
31
|
-
copyButton: () => string;
|
|
32
|
-
/**
|
|
33
|
-
* Generates profile name styles
|
|
34
|
-
*/
|
|
35
|
-
profileName: () => string;
|
|
36
|
-
/**
|
|
37
|
-
* Generates text row styles
|
|
38
|
-
*/
|
|
39
|
-
textRow: () => string;
|
|
40
|
-
/**
|
|
41
|
-
* Generates error icon styles
|
|
42
|
-
*/
|
|
43
|
-
errorIcon: () => string;
|
|
44
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_RELAYS: readonly ["wss://relay.damus.io", "wss://nostr.wine", "wss://relay.nostr.net", "wss://relay.nostr.band", "wss://nos.lol", "wss://nostr-pub.wellorder.net", "wss://relay.getalby.com", "wss://relay.primal.net"];
|
|
2
|
-
export declare const MILLISATS_PER_SAT = 1000;
|
|
3
|
-
export declare const NPUB_LENGTH = 63;
|
|
4
|
-
export declare const DEFAULT_PROFILE_IMAGE = "./assets/default_dp.png";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared date formatting utilities for Nostr components
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Formats a Unix timestamp to a readable date string
|
|
6
|
-
* @param createdAt Unix timestamp in seconds
|
|
7
|
-
* @returns Formatted date string (e.g., "Jan 15, 2024")
|
|
8
|
-
*/
|
|
9
|
-
export declare function formatEventDate(createdAt: number | undefined): string;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Theme } from './types';
|
|
2
|
-
export declare const replyIcon = "\n <svg width=\"18\" height=\"18\" fill=\"#00b3ff\">\n <path xmlns=\"http://www.w3.org/2000/svg\" d=\"M12.2197 1.65717C7.73973 1.25408 5.14439 0.940234 3.12891 2.6623C0.948817 4.52502 0.63207 7.66213 2.35603 9.88052C3.01043 10.7226 4.28767 11.9877 5.51513 13.1462C6.75696 14.3184 7.99593 15.426 8.60692 15.9671C8.61074 15.9705 8.61463 15.9739 8.61859 15.9774C8.67603 16.0283 8.74753 16.0917 8.81608 16.1433C8.89816 16.2052 9.01599 16.2819 9.17334 16.3288C9.38253 16.3912 9.60738 16.3912 9.81656 16.3288C9.97391 16.2819 10.0917 16.2052 10.1738 16.1433C10.2424 16.0917 10.3139 16.0283 10.3713 15.9774C10.3753 15.9739 10.3792 15.9705 10.383 15.9671C10.994 15.426 12.2329 14.3184 13.4748 13.1462C14.7022 11.9877 15.9795 10.7226 16.6339 9.88052C18.3512 7.67065 18.0834 4.50935 15.8532 2.65572C13.8153 0.961905 11.2476 1.25349 9.49466 2.78774Z\"/>\n </svg>\n";
|
|
3
|
-
export declare const heartIcon = "\n <svg width=\"18\" height=\"18\">\n <g xmlns=\"http://www.w3.org/2000/svg\">\n <path fill=\"#ff006d\" d=\"M12.2197 1.65717C7.73973 1.25408 5.14439 0.940234 3.12891 2.6623C0.948817 4.52502 0.63207 7.66213 2.35603 9.88052C3.01043 10.7226 4.28767 11.9877 5.51513 13.1462C6.75696 14.3184 7.99593 15.426 8.60692 15.9671C8.61074 15.9705 8.61463 15.9739 8.61859 15.9774C8.67603 16.0283 8.74753 16.0917 8.81608 16.1433C8.89816 16.2052 9.01599 16.2819 9.17334 16.3288C9.38253 16.3912 9.60738 16.3912 9.81656 16.3288C9.97391 16.2819 10.0917 16.2052 10.1738 16.1433C10.2424 16.0917 10.3139 16.0283 10.3713 15.9774C10.3753 15.9739 10.3792 15.9705 10.383 15.9671C10.994 15.426 12.2329 14.3184 13.4748 13.1462C14.7022 11.9877 15.9795 10.7226 16.6339 9.88052C18.3512 7.67065 18.0834 4.50935 15.8532 2.65572C13.8153 0.961905 11.2476 1.25349 9.49466 2.78774Z\"/>\n </g>\n </svg>\n";
|
|
4
|
-
export declare const copyIcon = "\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z\" fill=\"currentColor\"/>\n </svg>\n";
|
|
5
|
-
export declare const checkmarkIcon: (theme?: Theme) => string;
|
|
6
|
-
export declare const nostrLogo: (width?: number, height?: number) => string;
|
|
7
|
-
export declare const loadingNostrich: () => string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NIP-05 utility functions for resolving nostr identifiers
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Resolves a NIP-05 identifier to a nostr public key
|
|
6
|
-
* Includes input validation and request timeout for security
|
|
7
|
-
*
|
|
8
|
-
* @param nip05 - NIP-05 identifier in format username@domain.com
|
|
9
|
-
* @param timeoutMs - Timeout in milliseconds (default: 5000)
|
|
10
|
-
* @returns Resolved public key
|
|
11
|
-
* @throws Error if validation fails, timeout occurs, or resolution fails
|
|
12
|
-
*/
|
|
13
|
-
export declare function resolveNip05(nip05: string, timeoutMs?: number): Promise<string>;
|