Merge branch 'v0l:main' into main
This commit is contained in:
commit
24c840f1c6
@ -1,7 +1,8 @@
|
|||||||
node_modules/
|
**/node_modules/
|
||||||
.github/
|
.github/
|
||||||
.vscode/
|
.vscode/
|
||||||
build/
|
**/build/
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
.husky/
|
.husky/
|
||||||
.git/
|
.git/
|
||||||
|
**/dist/
|
15
.github/workflows/docker.yaml
vendored
15
.github/workflows/docker.yaml
vendored
@ -5,6 +5,9 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: docker/login-action@v1
|
- uses: docker/login-action@v1
|
||||||
@ -12,7 +15,13 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- uses: docker/setup-qemu-action@v1
|
- uses: docker/setup-qemu-action@v2
|
||||||
- uses: docker/setup-buildx-action@v1
|
- uses: docker/setup-buildx-action@v2
|
||||||
- name: Build the Docker image
|
- name: Build the Docker image
|
||||||
run: docker buildx build -t ghcr.io/${{ github.repository_owner }}/snort:latest --platform linux/amd64,linux/arm64 --push .
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
-t ghcr.io/${{ github.repository_owner }}/snort:latest \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
||||||
|
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
||||||
|
--push .
|
||||||
|
4
.github/workflows/tagged.yml
vendored
4
.github/workflows/tagged.yml
vendored
@ -25,8 +25,8 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- uses: docker/setup-qemu-action@v1
|
- uses: docker/setup-qemu-action@v2
|
||||||
- uses: docker/setup-buildx-action@v1
|
- uses: docker/setup-buildx-action@v2
|
||||||
- name: Build the Docker image
|
- name: Build the Docker image
|
||||||
run: |
|
run: |
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
FROM node:16 as build
|
FROM node:16 as build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
|
||||||
|
COPY package.json yarn.lock .
|
||||||
|
COPY packages/app/package.json packages/app/
|
||||||
|
COPY packages/nostr/package.json packages/nostr/
|
||||||
RUN yarn install --network-timeout 1000000
|
RUN yarn install --network-timeout 1000000
|
||||||
|
|
||||||
|
COPY . .
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
FROM nginx:mainline-alpine
|
FROM nginx:mainline-alpine
|
||||||
|
@ -154,6 +154,10 @@
|
|||||||
font-feature-settings: "tnum";
|
font-feature-settings: "tnum";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reaction-pill-icon {
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.reaction-pill .reaction-pill-number {
|
.reaction-pill .reaction-pill-number {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
font-feature-settings: "tnum";
|
font-feature-settings: "tnum";
|
||||||
@ -216,3 +220,15 @@
|
|||||||
.note .reactions-link:hover {
|
.note .reactions-link:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.close-menu {
|
||||||
|
position: absolute;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
top: -400px;
|
||||||
|
left: -600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-menu-container {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
@ -209,6 +209,13 @@ export default function NoteFooter(props: NoteFooterProps) {
|
|||||||
function menuItems() {
|
function menuItems() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div className="close-menu-container">
|
||||||
|
{/* This menu item serves as a "close menu" button;
|
||||||
|
it allows the user to click anywhere nearby the menu to close it. */}
|
||||||
|
<MenuItem>
|
||||||
|
<div className="close-menu" />
|
||||||
|
</MenuItem>
|
||||||
|
</div>
|
||||||
{prefs.enableReactions && (
|
{prefs.enableReactions && (
|
||||||
<MenuItem onClick={() => setShowReactions(true)}>
|
<MenuItem onClick={() => setShowReactions(true)}>
|
||||||
<Heart />
|
<Heart />
|
||||||
|
@ -23,6 +23,10 @@ function findTag(e: TaggedRawEvent, tag: string) {
|
|||||||
|
|
||||||
function getInvoice(zap: TaggedRawEvent) {
|
function getInvoice(zap: TaggedRawEvent) {
|
||||||
const bolt11 = findTag(zap, "bolt11");
|
const bolt11 = findTag(zap, "bolt11");
|
||||||
|
if (!bolt11) {
|
||||||
|
console.debug("Invalid zap: ", zap);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
const decoded = invoiceDecode(bolt11);
|
const decoded = invoiceDecode(bolt11);
|
||||||
|
|
||||||
const amount = decoded.sections.find(section => section.name === "amount")?.value;
|
const amount = decoded.sections.find(section => section.name === "amount")?.value;
|
||||||
@ -66,6 +70,7 @@ export interface ParsedZap {
|
|||||||
content: string;
|
content: string;
|
||||||
zapper?: HexKey;
|
zapper?: HexKey;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
|
zapService: HexKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseZap(zap: TaggedRawEvent): ParsedZap {
|
export function parseZap(zap: TaggedRawEvent): ParsedZap {
|
||||||
@ -81,6 +86,7 @@ export function parseZap(zap: TaggedRawEvent): ParsedZap {
|
|||||||
zapper: zapper.pubkey,
|
zapper: zapper.pubkey,
|
||||||
content: zap.content,
|
content: zap.content,
|
||||||
valid: zapper.isValid,
|
valid: zapper.isValid,
|
||||||
|
zapService: zap.pubkey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,42 @@
|
|||||||
import { NostrPrefix } from "@snort/nostr";
|
import { decodeTLV, NostrPrefix, TLVEntryType } from "@snort/nostr";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { setRelays } from "State/Login";
|
||||||
|
import { eventLink, profileLink } from "Util";
|
||||||
|
|
||||||
export default function NostrLinkHandler() {
|
export default function NostrLinkHandler() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const link = decodeURIComponent(params["*"] ?? "");
|
const link = decodeURIComponent(params["*"] ?? "").toLowerCase();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (link.length > 0) {
|
if (link.length > 0) {
|
||||||
const ls = link.split(":");
|
const entity = link.startsWith("web+nostr:") ? link.split(":")[1] : link;
|
||||||
const entity = ls[1];
|
if (entity.startsWith(NostrPrefix.PublicKey)) {
|
||||||
if (entity.startsWith(NostrPrefix.PublicKey) || entity.startsWith(NostrPrefix.Profile)) {
|
|
||||||
navigate(`/p/${entity}`);
|
navigate(`/p/${entity}`);
|
||||||
} else if (entity.startsWith(NostrPrefix.Event) || entity.startsWith(NostrPrefix.Note)) {
|
} else if (entity.startsWith(NostrPrefix.Note)) {
|
||||||
navigate(`/e/${entity}`);
|
navigate(`/e/${entity}`);
|
||||||
|
} else if (entity.startsWith(NostrPrefix.Profile) || entity.startsWith(NostrPrefix.Event)) {
|
||||||
|
const decoded = decodeTLV(entity);
|
||||||
|
console.debug(decoded);
|
||||||
|
|
||||||
|
const id = decoded.find(a => a.type === TLVEntryType.Special)?.value as string;
|
||||||
|
const relays = decoded.filter(a => a.type === TLVEntryType.Relay);
|
||||||
|
if (relays.length > 0) {
|
||||||
|
const relayObj = {
|
||||||
|
relays: Object.fromEntries(relays.map(a => [a.value, { read: true, write: false }])),
|
||||||
|
createdAt: new Date().getTime(),
|
||||||
|
};
|
||||||
|
dispatch(setRelays(relayObj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.startsWith(NostrPrefix.Profile)) {
|
||||||
|
navigate(profileLink(id));
|
||||||
|
} else if (entity.startsWith(NostrPrefix.Event)) {
|
||||||
|
navigate(eventLink(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [link]);
|
}, [link]);
|
||||||
|
@ -75,6 +75,8 @@ export default function ProfilePage() {
|
|||||||
users: new Map(),
|
users: new Map(),
|
||||||
creator: "",
|
creator: "",
|
||||||
});
|
});
|
||||||
|
const npub = !id.startsWith("npub") ? hexToBech32("npub", id || undefined) : id;
|
||||||
|
|
||||||
const lnurl = extractLnAddress(user?.lud16 || user?.lud06 || "");
|
const lnurl = extractLnAddress(user?.lud16 || user?.lud06 || "");
|
||||||
const website_url =
|
const website_url =
|
||||||
user?.website && !user.website.startsWith("http") ? "https://" + user.website : user?.website || "";
|
user?.website && !user.website.startsWith("http") ? "https://" + user.website : user?.website || "";
|
||||||
@ -121,7 +123,7 @@ export default function ProfilePage() {
|
|||||||
<FollowsYou followsMe={follows.includes(id)} />
|
<FollowsYou followsMe={follows.includes(id)} />
|
||||||
</h2>
|
</h2>
|
||||||
{user?.nip05 && <Nip05 nip05={user.nip05} pubkey={user.pubkey} />}
|
{user?.nip05 && <Nip05 nip05={user.nip05} pubkey={user.pubkey} />}
|
||||||
<Copy text={params.id || ""} />
|
<Copy text={npub} />
|
||||||
{links()}
|
{links()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -86,16 +86,15 @@ export default function RootPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="main-content">{pubKey && <Tabs tabs={tabs} tab={tab} setTab={setTab} />}</div>
|
<div className="main-content">
|
||||||
{isGlobal && globalRelays.length > 0 && (
|
{pubKey && <Tabs tabs={tabs} tab={tab} setTab={setTab} />}
|
||||||
<div className="flex mb10">
|
{isGlobal && globalRelays.length > 0 && (
|
||||||
<div className="f-grow">
|
<div className="flex mb10 f-end">
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Read global from"
|
defaultMessage="Read global from"
|
||||||
description="Label for reading global feed from specific relays"
|
description="Label for reading global feed from specific relays"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<select onChange={e => setRelay(e.target.value)}>
|
<select onChange={e => setRelay(e.target.value)}>
|
||||||
{globalRelays.map(a => (
|
{globalRelays.map(a => (
|
||||||
<option key={a} value={a}>
|
<option key={a} value={a}>
|
||||||
@ -104,8 +103,8 @@ export default function RootPage() {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
</div>
|
||||||
{followHints()}
|
{followHints()}
|
||||||
<Timeline
|
<Timeline
|
||||||
key={tab.value}
|
key={tab.value}
|
||||||
|
@ -41,7 +41,7 @@ export function parseId(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function bech32ToHex(str: string) {
|
export function bech32ToHex(str: string) {
|
||||||
const nKey = bech32.decode(str);
|
const nKey = bech32.decode(str, 1_000);
|
||||||
const buff = bech32.fromWords(nKey.words);
|
const buff = bech32.fromWords(nKey.words);
|
||||||
return secp.utils.bytesToHex(Uint8Array.from(buff));
|
return secp.utils.bytesToHex(Uint8Array.from(buff));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as secp from "@noble/secp256k1";
|
import * as secp from "@noble/secp256k1";
|
||||||
import { bech32 } from "bech32";
|
import { bech32 } from "bech32";
|
||||||
|
import { HexKey } from ".";
|
||||||
|
|
||||||
export enum NostrPrefix {
|
export enum NostrPrefix {
|
||||||
PublicKey = "npub",
|
PublicKey = "npub",
|
||||||
@ -12,10 +13,17 @@ export enum NostrPrefix {
|
|||||||
Relay = "nrelay",
|
Relay = "nrelay",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TLVEntryType {
|
||||||
|
Special = 0,
|
||||||
|
Relay = 1,
|
||||||
|
Author = 2,
|
||||||
|
Kind = 3,
|
||||||
|
}
|
||||||
|
|
||||||
export interface TLVEntry {
|
export interface TLVEntry {
|
||||||
type: number;
|
type: TLVEntryType;
|
||||||
length: number;
|
length: number;
|
||||||
value: string; // hex encoded data
|
value: string | HexKey | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function encodeTLV(hex: string, prefix: NostrPrefix, relays?: string[]) {
|
export function encodeTLV(hex: string, prefix: NostrPrefix, relays?: string[]) {
|
||||||
@ -39,7 +47,7 @@ export function encodeTLV(hex: string, prefix: NostrPrefix, relays?: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function decodeTLV(str: string) {
|
export function decodeTLV(str: string) {
|
||||||
const decoded = bech32.decode(str);
|
const decoded = bech32.decode(str, 1_000);
|
||||||
const data = bech32.fromWords(decoded.words);
|
const data = bech32.fromWords(decoded.words);
|
||||||
|
|
||||||
const entries: TLVEntry[] = [];
|
const entries: TLVEntry[] = [];
|
||||||
@ -51,9 +59,24 @@ export function decodeTLV(str: string) {
|
|||||||
entries.push({
|
entries.push({
|
||||||
type: t,
|
type: t,
|
||||||
length: l,
|
length: l,
|
||||||
value: secp.utils.bytesToHex(new Uint8Array(v)),
|
value: decodeTLVEntry(t, new Uint8Array(v)),
|
||||||
});
|
});
|
||||||
x += 2 + l;
|
x += 2 + l;
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeTLVEntry(type: TLVEntryType, data: Uint8Array) {
|
||||||
|
switch (type) {
|
||||||
|
case TLVEntryType.Special:
|
||||||
|
case TLVEntryType.Author: {
|
||||||
|
return secp.utils.bytesToHex(data);
|
||||||
|
}
|
||||||
|
case TLVEntryType.Kind: {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
case TLVEntryType.Relay: {
|
||||||
|
return new TextDecoder("ASCII").decode(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user