mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2474609a5a | ||
|
|
ea5932490a | ||
|
|
3db5148780 | ||
|
|
a0bd6729ae | ||
|
|
05c0ec92f7 |
No files matched your search
Generated
-7
@@ -48,7 +48,6 @@
|
||||
"cmdk": "^1.0.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"embla-carousel-react": "^8.3.0",
|
||||
"idb": "^8.0.3",
|
||||
"input-otp": "^1.2.4",
|
||||
"lucide-react": "^0.462.0",
|
||||
"nostr-tools": "^2.13.0",
|
||||
@@ -5487,12 +5486,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/idb": {
|
||||
"version": "8.0.3",
|
||||
"resolved": "https://registry.npmjs.org/idb/-/idb-8.0.3.tgz",
|
||||
"integrity": "sha512-LtwtVyVYO5BqRvcsKuB2iUMnHwPVByPCXFXOpuU96IZPPoPN6xjOGxZQ74pgSVVLQWtUOYgyeL4GE98BY5D3wg==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ignore": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"cmdk": "^1.0.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"embla-carousel-react": "^8.3.0",
|
||||
"idb": "^8.0.3",
|
||||
"input-otp": "^1.2.4",
|
||||
"lucide-react": "^0.462.0",
|
||||
"nostr-tools": "^2.13.0",
|
||||
|
||||
@@ -57,6 +57,11 @@ export function LoginArea({ className }: LoginAreaProps) {
|
||||
<SignupDialog
|
||||
isOpen={signupDialogOpen}
|
||||
onClose={() => setSignupDialogOpen(false)}
|
||||
onLogin={handleLogin}
|
||||
onOpenLogin={() => {
|
||||
setSignupDialogOpen(false);
|
||||
setLoginDialogOpen(true);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// It is important that all functionality in this file is preserved, and should only be modified if explicitly requested.
|
||||
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { Download, Key, UserPlus, FileText, Shield, User, Sparkles, LogIn, CheckCircle, Upload, Globe } from 'lucide-react';
|
||||
import { Download, CheckCircle, User, Upload } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
@@ -19,17 +19,17 @@ interface SignupDialogProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onComplete?: () => void;
|
||||
onLogin?: () => void;
|
||||
onOpenLogin?: () => void;
|
||||
}
|
||||
|
||||
const sanitizeFilename = (filename: string) => {
|
||||
return filename.replace(/[^a-z0-9_.-]/gi, '_');
|
||||
}
|
||||
|
||||
const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete }) => {
|
||||
const [step, setStep] = useState<'welcome' | 'generate' | 'download' | 'profile' | 'done'>('welcome');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete, onLogin, onOpenLogin }) => {
|
||||
const [step, setStep] = useState<'key' | 'keygen' | 'download' | 'profile' | 'done'>('key');
|
||||
const [nsec, setNsec] = useState('');
|
||||
const [showSparkles, setShowSparkles] = useState(false);
|
||||
const [keySecured, setKeySecured] = useState<'none' | 'downloaded'>('none');
|
||||
const [profileData, setProfileData] = useState({
|
||||
name: '',
|
||||
@@ -41,10 +41,8 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
||||
const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile();
|
||||
const avatarFileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// Generate a proper nsec key using nostr-tools
|
||||
const generateKey = () => {
|
||||
setIsLoading(true);
|
||||
setShowSparkles(true);
|
||||
const handleGenerateKey = () => {
|
||||
setStep('keygen');
|
||||
|
||||
// Add a dramatic pause for the key generation effect
|
||||
setTimeout(() => {
|
||||
@@ -66,13 +64,18 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
||||
description: 'Failed to generate key. Please try again.',
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setShowSparkles(false);
|
||||
setStep('key');
|
||||
}
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
const handleHasKey = () => {
|
||||
onClose();
|
||||
if (onOpenLogin) {
|
||||
onOpenLogin();
|
||||
}
|
||||
};
|
||||
|
||||
const downloadKey = () => {
|
||||
try {
|
||||
// Create a blob with the key text
|
||||
@@ -110,8 +113,6 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const finishKeySetup = () => {
|
||||
try {
|
||||
login.nsec(nsec);
|
||||
@@ -242,302 +243,154 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
||||
};
|
||||
|
||||
const getTitle = () => {
|
||||
if (step === 'welcome') return (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
Create Your Account
|
||||
</span>
|
||||
);
|
||||
if (step === 'generate') return (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
Generating Your Key
|
||||
</span>
|
||||
);
|
||||
if (step === 'download') return (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
Secret Key
|
||||
</span>
|
||||
);
|
||||
if (step === 'profile') return (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
Create Your Profile
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
Welcome!
|
||||
</span>
|
||||
);
|
||||
if (step === 'key') return 'Sign up';
|
||||
if (step === 'keygen') return 'Generating Your Key';
|
||||
if (step === 'download') return 'Secret Key';
|
||||
if (step === 'profile') return 'Create Your Profile';
|
||||
return 'Welcome!';
|
||||
};
|
||||
|
||||
// Reset state when dialog opens
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setStep('welcome');
|
||||
setIsLoading(false);
|
||||
setStep('key');
|
||||
setNsec('');
|
||||
setShowSparkles(false);
|
||||
setKeySecured('none');
|
||||
setProfileData({ name: '', about: '', picture: '' });
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
// Add sparkle animation effect
|
||||
useEffect(() => {
|
||||
if (showSparkles) {
|
||||
const interval = setInterval(() => {
|
||||
// This will trigger re-renders for sparkle animation
|
||||
}, 100);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
}, [showSparkles]);
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent
|
||||
className={cn("max-w-[95vw] sm:max-w-md max-h-[90vh] max-h-[90dvh] p-0 overflow-hidden rounded-2xl flex flex-col")}
|
||||
>
|
||||
<DialogHeader className={cn('px-6 pt-6 pb-1 relative flex-shrink-0')}>
|
||||
<DialogTitle className={cn('font-semibold text-center text-lg')}>
|
||||
<DialogTitle className={cn('font-semibold text-left text-lg')}>
|
||||
{getTitle()}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className='px-6 pt-2 pb-4 space-y-4 overflow-y-scroll flex-1'>
|
||||
{/* Welcome Step - New engaging introduction */}
|
||||
{step === 'welcome' && (
|
||||
<div className='text-center space-y-4'>
|
||||
{/* Hero illustration */}
|
||||
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50'>
|
||||
<div className='flex justify-center items-center space-x-4 mb-3'>
|
||||
<div className='relative'>
|
||||
<UserPlus className='w-12 h-12 text-blue-600' />
|
||||
<Sparkles className='w-4 h-4 text-yellow-500 absolute -top-1 -right-1 animate-pulse' />
|
||||
</div>
|
||||
<Globe className='w-16 h-16 text-blue-700 animate-spin-slow' />
|
||||
<div className='relative'>
|
||||
<FileText className='w-12 h-12 text-blue-600' />
|
||||
<Sparkles className='w-4 h-4 text-yellow-500 absolute -top-1 -left-1 animate-pulse' style={{animationDelay: '0.3s'}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Benefits */}
|
||||
<div className='grid grid-cols-1 gap-2 text-sm'>
|
||||
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
|
||||
<Shield className='w-4 h-4' />
|
||||
Decentralized and censorship-resistant
|
||||
</div>
|
||||
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
|
||||
<User className='w-4 h-4' />
|
||||
You are in control of your data
|
||||
</div>
|
||||
<div className='flex items-center justify-center gap-2 text-blue-700 dark:text-blue-300'>
|
||||
<Globe className='w-4 h-4' />
|
||||
Join a global network
|
||||
</div>
|
||||
<div className='px-6 pt-2 pb-6 space-y-6 flex-1'>
|
||||
{/* Initial Key Step - Soapbox style */}
|
||||
{step === 'key' && (
|
||||
<div className='flex flex-col items-center space-y-6'>
|
||||
<p className='text-center font-semibold'>
|
||||
You need a key to continue
|
||||
</p>
|
||||
|
||||
<div className='rounded-full bg-gray-100 p-8 dark:bg-gray-800'>
|
||||
<div className='text-8xl'>
|
||||
🔑
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='space-y-3'>
|
||||
<div className='flex flex-col items-center space-y-3 w-full'>
|
||||
<Button
|
||||
className='w-full rounded-full py-6 text-lg font-semibold bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 transform transition-all duration-200 hover:scale-105 shadow-lg'
|
||||
onClick={() => setStep('generate')}
|
||||
className='bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-2xl'
|
||||
size='lg'
|
||||
onClick={handleGenerateKey}
|
||||
>
|
||||
<LogIn className='w-5 h-5 mr-2' />
|
||||
Get Started
|
||||
Generate key
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant='ghost'
|
||||
className='text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 rounded-2xl'
|
||||
onClick={handleHasKey}
|
||||
>
|
||||
I already have a key
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Generate Step - Enhanced with animations */}
|
||||
{step === 'generate' && (
|
||||
{/* Key Generation Step */}
|
||||
{step === 'keygen' && (
|
||||
<div className='text-center space-y-4'>
|
||||
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-purple-100 dark:from-blue-950/50 dark:to-purple-950/50 overflow-hidden'>
|
||||
{/* Animated background elements */}
|
||||
{showSparkles && (
|
||||
<div className='absolute inset-0'>
|
||||
{[...Array(12)].map((_, i) => (
|
||||
<Sparkles
|
||||
key={i}
|
||||
className={`absolute w-4 h-4 text-yellow-400 animate-ping`}
|
||||
style={{
|
||||
left: `${Math.random() * 80 + 10}%`,
|
||||
top: `${Math.random() * 80 + 10}%`,
|
||||
animationDelay: `${Math.random() * 2}s`
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='relative z-10'>
|
||||
{isLoading ? (
|
||||
<div className='space-y-3'>
|
||||
<div className='relative'>
|
||||
<Key className='w-20 h-20 text-primary mx-auto animate-pulse' />
|
||||
<div className='absolute inset-0 flex items-center justify-center'>
|
||||
<div className='w-24 h-24 border-4 border-yellow-400 border-t-transparent rounded-full animate-spin'></div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<p className='text-lg font-semibold text-primary flex items-center justify-center gap-2'>
|
||||
<Sparkles className='w-5 h-5' />
|
||||
Generating your secret key...
|
||||
</p>
|
||||
<p className='text-sm text-muted-foreground'>
|
||||
Creating your secure key
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className='space-y-3'>
|
||||
<Key className='w-20 h-20 text-primary mx-auto' />
|
||||
<div className='space-y-2'>
|
||||
<p className='text-lg font-semibold'>
|
||||
Ready to generate your secret key?
|
||||
</p>
|
||||
<p className='text-sm text-muted-foreground px-5'>
|
||||
This key will be your password to access applications within the Nostr network.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<p className='text-lg font-semibold'>
|
||||
Generating your secret key...
|
||||
</p>
|
||||
<p className='text-sm text-muted-foreground'>
|
||||
Creating your secure key
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{!isLoading && (
|
||||
<Button
|
||||
className='w-full rounded-full py-6 text-lg font-semibold bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 transform transition-all duration-200 hover:scale-105 shadow-lg'
|
||||
onClick={generateKey}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Sparkles className='w-5 h-5 mr-2' />
|
||||
Generate My Secret Key
|
||||
</Button>
|
||||
)}
|
||||
<div className='flex justify-center'>
|
||||
<div className='w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full animate-spin'></div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Download Step - Whimsical and magical */}
|
||||
{/* Download Step */}
|
||||
{step === 'download' && (
|
||||
<div className='text-center space-y-4'>
|
||||
{/* Key reveal */}
|
||||
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50 overflow-hidden'>
|
||||
{/* Sparkles */}
|
||||
<div className='absolute inset-0 pointer-events-none'>
|
||||
<Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} />
|
||||
<Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} />
|
||||
<Sparkles className='absolute bottom-4 left-6 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '1s'}} />
|
||||
<Sparkles className='absolute bottom-3 right-4 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '1.5s'}} />
|
||||
</div>
|
||||
|
||||
<div className='relative z-10 flex justify-center items-center mb-3'>
|
||||
<div className='relative'>
|
||||
<div className='w-16 h-16 bg-gradient-to-br from-blue-200 to-indigo-300 rounded-full flex items-center justify-center shadow-lg animate-pulse'>
|
||||
<Key className='w-8 h-8 text-indigo-800' />
|
||||
</div>
|
||||
<div className='absolute -top-1 -right-1 w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center animate-bounce'>
|
||||
<Sparkles className='w-3 h-3 text-white' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='relative z-10 space-y-2'>
|
||||
<p className='text-base font-semibold'>
|
||||
Your secret key has been generated!
|
||||
</p>
|
||||
|
||||
{/* Warning */}
|
||||
<div className='relative mx-auto max-w-sm'>
|
||||
<div className='p-3 bg-gradient-to-r from-amber-100 via-yellow-50 to-amber-100 dark:from-amber-950/40 dark:via-yellow-950/20 dark:to-amber-950/40 rounded-lg border-2 border-amber-300 dark:border-amber-700 shadow-md'>
|
||||
<div className='flex items-center gap-2 mb-1'>
|
||||
<FileText className='w-3 h-3 text-amber-700' />
|
||||
<span className='text-xs font-bold text-amber-800 dark:text-amber-200'>
|
||||
Important Warning
|
||||
</span>
|
||||
</div>
|
||||
<p className='text-xs text-red-700 dark:text-amber-300 italic'>
|
||||
This key is your primary and only means of accessing your account. Store it safely and securely.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<p className='text-lg font-semibold'>
|
||||
Your secret key has been generated!
|
||||
</p>
|
||||
<p className='text-sm text-muted-foreground'>
|
||||
Please download and save your key securely.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Key vault */}
|
||||
|
||||
|
||||
{/* Security options */}
|
||||
<div className='space-y-3'>
|
||||
|
||||
|
||||
<div className='grid grid-cols-1 gap-2'>
|
||||
{/* Download Option */}
|
||||
<Card className={`cursor-pointer transition-all duration-200 ${
|
||||
keySecured === 'downloaded'
|
||||
? 'ring-2 ring-green-500 bg-green-50 dark:bg-green-950/20'
|
||||
: 'hover:bg-primary/5 hover:border-primary/20'
|
||||
}`}>
|
||||
<CardContent className='p-3'>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className='w-full h-auto p-0 justify-start hover:bg-transparent'
|
||||
onClick={downloadKey}
|
||||
>
|
||||
<div className='flex items-center gap-3 w-full'>
|
||||
<div className={`p-1.5 rounded-lg ${
|
||||
keySecured === 'downloaded'
|
||||
? 'bg-green-100 dark:bg-green-900'
|
||||
: 'bg-primary/10'
|
||||
}`}>
|
||||
{keySecured === 'downloaded' ? (
|
||||
<CheckCircle className='w-4 h-4 text-green-600' />
|
||||
) : (
|
||||
<Download className='w-4 h-4 text-primary' />
|
||||
)}
|
||||
</div>
|
||||
<div className='flex-1 text-left'>
|
||||
<div className='font-medium text-sm'>
|
||||
Download as File
|
||||
</div>
|
||||
<div className='text-xs text-muted-foreground'>
|
||||
Save as nostr-nsec-key.txt file
|
||||
</div>
|
||||
</div>
|
||||
{keySecured === 'downloaded' && (
|
||||
<div className='text-xs font-medium text-green-600'>
|
||||
✓ Downloaded
|
||||
</div>
|
||||
)}
|
||||
<Card className={`cursor-pointer transition-all duration-200 ${
|
||||
keySecured === 'downloaded'
|
||||
? 'ring-2 ring-green-500 bg-green-50 dark:bg-green-950/20'
|
||||
: 'hover:bg-primary/5 hover:border-primary/20'
|
||||
}`}>
|
||||
<CardContent className='p-3'>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className='w-full h-auto p-0 justify-start hover:bg-transparent'
|
||||
onClick={downloadKey}
|
||||
>
|
||||
<div className='flex items-center gap-3 w-full'>
|
||||
<div className={`p-1.5 rounded-lg ${
|
||||
keySecured === 'downloaded'
|
||||
? 'bg-green-100 dark:bg-green-900'
|
||||
: 'bg-primary/10'
|
||||
}`}>
|
||||
{keySecured === 'downloaded' ? (
|
||||
<CheckCircle className='w-4 h-4 text-green-600' />
|
||||
) : (
|
||||
<Download className='w-4 h-4 text-primary' />
|
||||
)}
|
||||
</div>
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div className='flex-1 text-left'>
|
||||
<div className='font-medium text-sm'>
|
||||
Download as File
|
||||
</div>
|
||||
<div className='text-xs text-muted-foreground'>
|
||||
Save as nostr-nsec-key.txt file
|
||||
</div>
|
||||
</div>
|
||||
{keySecured === 'downloaded' && (
|
||||
<div className='text-xs font-medium text-green-600'>
|
||||
✓ Downloaded
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{/* Continue button */}
|
||||
<Button
|
||||
className={`w-full rounded-full py-4 text-base font-semibold transform transition-all duration-200 shadow-lg ${
|
||||
keySecured === 'downloaded'
|
||||
? 'bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 dark:from-blue-950/50 dark:to-purple-950/50 hover:scale-105'
|
||||
? 'bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 hover:scale-105'
|
||||
: 'bg-gradient-to-r from-blue-600/60 to-indigo-600/60 text-muted cursor-not-allowed'
|
||||
}`}
|
||||
onClick={finishKeySetup}
|
||||
disabled={keySecured !== 'downloaded'}
|
||||
>
|
||||
<LogIn className='w-4 h-4 mr-2 flex-shrink-0' />
|
||||
<span className="text-center leading-tight">
|
||||
{keySecured === 'none' ? (
|
||||
<>
|
||||
Please download your key first
|
||||
</>
|
||||
'Please download your key first'
|
||||
) : (
|
||||
<>
|
||||
<span className="hidden sm:inline">My Key is Safe - Continue</span>
|
||||
<span className="sm:hidden">Key Secured - Continue</span>
|
||||
</>
|
||||
'My Key is Safe - Continue'
|
||||
)}
|
||||
</span>
|
||||
</Button>
|
||||
@@ -545,38 +398,16 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Profile Step - Optional profile setup */}
|
||||
{/* Profile Setup Step */}
|
||||
{step === 'profile' && (
|
||||
<div className='text-center space-y-4'>
|
||||
{/* Profile setup illustration */}
|
||||
<div className='relative p-6 rounded-2xl bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-950/50 dark:to-indigo-950/50 overflow-hidden'>
|
||||
{/* Sparkles */}
|
||||
<div className='absolute inset-0 pointer-events-none'>
|
||||
<Sparkles className='absolute top-3 left-4 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '0s'}} />
|
||||
<Sparkles className='absolute top-6 right-6 w-3 h-3 text-yellow-500 animate-pulse' style={{animationDelay: '0.5s'}} />
|
||||
<Sparkles className='absolute bottom-4 left-6 w-3 h-3 text-yellow-400 animate-pulse' style={{animationDelay: '1s'}} />
|
||||
</div>
|
||||
|
||||
<div className='relative z-10 flex justify-center items-center mb-3'>
|
||||
<div className='relative'>
|
||||
<div className='w-16 h-16 bg-gradient-to-br from-blue-200 to-indigo-300 rounded-full flex items-center justify-center shadow-lg'>
|
||||
<User className='w-8 h-8 text-blue-800' />
|
||||
</div>
|
||||
<div className='absolute -top-1 -right-1 w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center animate-bounce'>
|
||||
<Sparkles className='w-3 h-3 text-white' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='relative z-10 space-y-2'>
|
||||
<p className='text-base font-semibold'>
|
||||
Almost there! Let's set up your profile
|
||||
</p>
|
||||
|
||||
<p className='text-sm text-muted-foreground'>
|
||||
Your profile is your identity on Nostr.
|
||||
</p>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<p className='text-lg font-semibold'>
|
||||
Almost there! Let's set up your profile
|
||||
</p>
|
||||
<p className='text-sm text-muted-foreground'>
|
||||
Your profile is your identity on Nostr.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Publishing status indicator */}
|
||||
@@ -705,4 +536,4 @@ const SignupDialog: React.FC<SignupDialogProps> = ({ isOpen, onClose, onComplete
|
||||
);
|
||||
};
|
||||
|
||||
export default SignupDialog;
|
||||
export default SignupDialog;
|
||||
@@ -1,193 +0,0 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useNostrPublish } from '@/hooks/useNostrPublish';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
|
||||
interface BaseSendDMParams {
|
||||
recipientPubkey: string;
|
||||
content: string;
|
||||
attachments?: Array<{
|
||||
url: string;
|
||||
mimeType: string;
|
||||
size: number;
|
||||
name: string;
|
||||
tags: string[][];
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for sending direct messages using NIP-04 and NIP-17 protocols
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* const { sendNIP4Message, sendNIP17Message } = useSendDM();
|
||||
*
|
||||
* // Send NIP-04 message
|
||||
* await sendNIP4Message.mutateAsync({
|
||||
* recipientPubkey: 'hex-pubkey',
|
||||
* content: 'Hello!'
|
||||
* });
|
||||
*
|
||||
* // Send NIP-17 message (more secure, uses NIP-44 + gift wrapping)
|
||||
* await sendNIP17Message.mutateAsync({
|
||||
* recipientPubkey: 'hex-pubkey',
|
||||
* content: 'Hello securely!'
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function useSendDM() {
|
||||
const { mutateAsync: createEvent } = useNostrPublish();
|
||||
const { user } = useCurrentUser();
|
||||
const { toast } = useToast();
|
||||
|
||||
// Helper function to prepare content with attachments
|
||||
const prepareMessageContent = (content: string, attachments: BaseSendDMParams['attachments'] = []) => {
|
||||
if (attachments.length === 0) return content;
|
||||
|
||||
const fileUrls = attachments.map(file => file.url).join('\n');
|
||||
return content ? `${content}\n\n${fileUrls}` : fileUrls;
|
||||
};
|
||||
|
||||
// Helper function to create imeta tags for attachments (NIP-92)
|
||||
const createImetaTags = (attachments: BaseSendDMParams['attachments'] = []) => {
|
||||
return attachments.map(file => {
|
||||
const imetaTag = ["imeta"];
|
||||
imetaTag.push(`url ${file.url}`);
|
||||
if (file.mimeType) imetaTag.push(`m ${file.mimeType}`);
|
||||
if (file.size) imetaTag.push(`size ${file.size}`);
|
||||
if (file.name) imetaTag.push(`alt ${file.name}`);
|
||||
|
||||
file.tags.forEach(tag => {
|
||||
if (tag[0] === 'x') imetaTag.push(`x ${tag[1]}`);
|
||||
if (tag[0] === 'ox') imetaTag.push(`ox ${tag[1]}`);
|
||||
});
|
||||
|
||||
return imetaTag;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a NIP-04 encrypted direct message
|
||||
* Uses legacy NIP-04 encryption (nip04.encrypt)
|
||||
*/
|
||||
const sendNIP4Message = useMutation({
|
||||
mutationFn: async ({ recipientPubkey, content, attachments = [] }: BaseSendDMParams) => {
|
||||
if (!user?.signer?.nip04) {
|
||||
console.error('[SendDM] NIP-04 encryption not available');
|
||||
throw new Error('NIP-04 encryption not available');
|
||||
}
|
||||
|
||||
console.log('[SendDM] Sending NIP-04 message');
|
||||
|
||||
const messageContent = prepareMessageContent(content, attachments);
|
||||
const encryptedContent = await user.signer.nip04.encrypt(recipientPubkey, messageContent);
|
||||
|
||||
const tags = [
|
||||
["p", recipientPubkey],
|
||||
...createImetaTags(attachments)
|
||||
];
|
||||
|
||||
const event = await createEvent({
|
||||
kind: 4, // NIP-04 encrypted DM
|
||||
content: encryptedContent,
|
||||
tags,
|
||||
});
|
||||
|
||||
console.log('[SendDM] Created NIP-04 message:', event);
|
||||
return event;
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Failed to send NIP-04 DM:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to send NIP-04 message. Please try again.",
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Send a NIP-17 encrypted direct message (Gift Wrapped)
|
||||
* Uses NIP-44 encryption with gift wrapping (NIP-59) for enhanced privacy
|
||||
*
|
||||
* Creates:
|
||||
* 1. Kind 14 Private DM event (signed by sender)
|
||||
* 2. Kind 13 Seal events (encrypted to recipient and sender)
|
||||
* 3. Kind 1059 Gift Wrap events (for recipient and sender to find messages)
|
||||
*/
|
||||
const sendNIP17Message = useMutation({
|
||||
mutationFn: async ({ recipientPubkey, content, attachments = [] }: BaseSendDMParams) => {
|
||||
if (!user?.signer?.nip44) {
|
||||
console.error('[SendDM] NIP-44 encryption not available for NIP-17');
|
||||
throw new Error('NIP-44 encryption not available for NIP-17');
|
||||
}
|
||||
|
||||
console.log('[SendDM] Sending NIP-17 Gift Wrap message');
|
||||
|
||||
const messageContent = prepareMessageContent(content, attachments);
|
||||
|
||||
// Step 1: Create and sign the Kind 14 Private DM event
|
||||
const privateDMTags = [
|
||||
["p", recipientPubkey],
|
||||
...createImetaTags(attachments)
|
||||
];
|
||||
|
||||
const privateDM = await user.signer.signEvent({
|
||||
kind: 14,
|
||||
content: messageContent,
|
||||
tags: privateDMTags,
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
// Step 2: Create TWO Kind 13 Seal events - one for recipient, one for sender
|
||||
|
||||
// Seal for recipient (encrypted to them)
|
||||
const recipientSeal = await user.signer.signEvent({
|
||||
kind: 13,
|
||||
content: await user.signer.nip44.encrypt(recipientPubkey, JSON.stringify(privateDM)),
|
||||
tags: [], // Seal events typically have no tags
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
// Seal for sender (encrypted to us)
|
||||
const senderSeal = await user.signer.signEvent({
|
||||
kind: 13,
|
||||
content: await user.signer.nip44.encrypt(user.pubkey, JSON.stringify(privateDM)),
|
||||
tags: [], // Seal events typically have no tags
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
// Step 3: Create TWO Kind 1059 Gift Wrap events
|
||||
// One for the recipient, one for myself (so I can see sent messages)
|
||||
|
||||
// Gift Wrap for recipient - they should be able to find it via their pubkey in p tag
|
||||
const recipientGiftWrap = await createEvent({
|
||||
kind: 1059, // Gift Wrap
|
||||
content: await user.signer.nip44.encrypt(recipientPubkey, JSON.stringify(recipientSeal)),
|
||||
tags: [["p", recipientPubkey]], // Recipient can find this via their pubkey
|
||||
});
|
||||
|
||||
// Gift Wrap for myself - I should be able to find it via my pubkey in p tag
|
||||
const myGiftWrap = await createEvent({
|
||||
kind: 1059, // Gift Wrap
|
||||
content: await user.signer.nip44.encrypt(user.pubkey, JSON.stringify(senderSeal)),
|
||||
tags: [["p", user.pubkey]], // I can find this via my pubkey
|
||||
});
|
||||
|
||||
return { recipientGiftWrap, myGiftWrap };
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Failed to send NIP-17 DM:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to send NIP-17 message. Please try again.",
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
sendNIP4Message,
|
||||
sendNIP17Message,
|
||||
};
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import { MESSAGE_PROTOCOL, type MessageProtocol } from '@/types/dm';
|
||||
|
||||
/**
|
||||
* Helper function to determine message protocol from event kind
|
||||
*/
|
||||
export function getMessageProtocol(kind: number): MessageProtocol {
|
||||
switch (kind) {
|
||||
case 4: return MESSAGE_PROTOCOL.NIP04;
|
||||
case 1059: return MESSAGE_PROTOCOL.NIP17; // Gift Wrap
|
||||
case 14: return MESSAGE_PROTOCOL.NIP17; // Private DM (decrypted NIP-17)
|
||||
default: return MESSAGE_PROTOCOL.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Protocol indicator configuration for UI display
|
||||
*/
|
||||
export const PROTOCOL_CONFIG = {
|
||||
[MESSAGE_PROTOCOL.NIP04]: {
|
||||
color: 'bg-orange-500',
|
||||
textColor: 'text-orange-600 dark:text-orange-400',
|
||||
label: 'NIP-04',
|
||||
title: 'NIP-04 encrypted message'
|
||||
},
|
||||
[MESSAGE_PROTOCOL.NIP17]: {
|
||||
color: 'bg-purple-500',
|
||||
textColor: 'text-purple-600 dark:text-purple-400',
|
||||
label: 'NIP-17',
|
||||
title: 'NIP-44/NIP-17 encrypted message'
|
||||
},
|
||||
[MESSAGE_PROTOCOL.UNKNOWN]: {
|
||||
color: 'bg-gray-400',
|
||||
textColor: 'text-gray-600 dark:text-gray-400',
|
||||
label: 'Unknown',
|
||||
title: 'Unknown message type'
|
||||
}
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Constants for consistent naming across the app
|
||||
*/
|
||||
export const PROTOCOL_CONSTANTS = {
|
||||
// localStorage keys
|
||||
NIP17_ENABLED_KEY: 'enableNIP17',
|
||||
|
||||
// Logger prefixes
|
||||
NIP4_LOG_PREFIX: 'DMS: [NIP4]',
|
||||
NIP17_LOG_PREFIX: 'DMS: [NIP17]',
|
||||
DMCHAT_LOG_PREFIX: 'DMS: [DMCHAT]',
|
||||
DIRECT_MESSAGES_LOG_PREFIX: 'DMS: [DirectMessages]',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Message pagination constants
|
||||
*/
|
||||
export const MESSAGES_PER_PAGE = 25;
|
||||
@@ -1,61 +0,0 @@
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
import type { DecryptedMessage, DMConversation } from '@/types/dm';
|
||||
|
||||
/**
|
||||
* Shared validation function for DM events
|
||||
* Validates both NIP-04 (kind 4) and NIP-17 (kind 1059) encrypted DMs
|
||||
*/
|
||||
export function validateDMEvent(event: NostrEvent): boolean {
|
||||
// Accept both NIP-04 (kind 4) and NIP-17 (kind 1059) encrypted DMs
|
||||
if (![4, 1059].includes(event.kind)) return false;
|
||||
|
||||
// Must have a 'p' tag for the recipient
|
||||
const hasP = event.tags.some(([name]) => name === 'p');
|
||||
if (!hasP) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the recipient pubkey from a DM event
|
||||
*/
|
||||
export function getRecipientPubkey(event: NostrEvent): string | null {
|
||||
const pTag = event.tags.find(([name]) => name === 'p');
|
||||
return pTag ? pTag[1] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a message is from the current user
|
||||
*/
|
||||
export function isMessageFromUser(message: DecryptedMessage, userPubkey: string): boolean {
|
||||
return message.pubkey === userPubkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort conversations by last activity (most recent first)
|
||||
*/
|
||||
export function sortConversationsByActivity(conversations: DMConversation[]): DMConversation[] {
|
||||
return [...conversations].sort((a, b) => b.lastMessageTime - a.lastMessageTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter conversations by search query
|
||||
* Searches in decrypted message content and participant info
|
||||
*/
|
||||
export function filterConversationsByQuery(
|
||||
conversations: DMConversation[],
|
||||
query: string
|
||||
): DMConversation[] {
|
||||
if (!query.trim()) return conversations;
|
||||
|
||||
const lowerQuery = query.toLowerCase();
|
||||
return conversations.filter(conv => {
|
||||
// Search in pubkey
|
||||
if (conv.pubkey.toLowerCase().includes(lowerQuery)) return true;
|
||||
|
||||
// Search in last message content
|
||||
if (conv.lastMessage?.decryptedContent?.toLowerCase().includes(lowerQuery)) return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
import { openDB, IDBPDatabase } from 'idb';
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
|
||||
// Match the in-memory structure exactly
|
||||
interface StoredParticipant {
|
||||
messages: NostrEvent[]; // Store only basic NostrEvent in IndexedDB
|
||||
lastActivity: number;
|
||||
hasNIP4: boolean;
|
||||
hasNIP17: boolean;
|
||||
}
|
||||
|
||||
// Store structure: Map<participantPubkey, StoredParticipant>
|
||||
interface MessageStore {
|
||||
participants: Record<string, StoredParticipant>;
|
||||
lastSync: {
|
||||
nip4: number | null;
|
||||
nip17: number | null;
|
||||
};
|
||||
}
|
||||
|
||||
// IndexedDB configuration
|
||||
const DB_NAME = 'nostr-messages';
|
||||
const DB_VERSION = 1;
|
||||
|
||||
/**
|
||||
* Initialize IndexedDB for a specific user
|
||||
* Creates a user-specific store if it doesn't exist
|
||||
*/
|
||||
async function initDB(userNpub: string): Promise<IDBPDatabase> {
|
||||
const storeName = `messages-${userNpub}`;
|
||||
|
||||
return openDB(DB_NAME, DB_VERSION, {
|
||||
upgrade(db, _oldVersion, _newVersion) {
|
||||
// Create store for this user if it doesn't exist
|
||||
if (!db.objectStoreNames.contains(storeName)) {
|
||||
db.createObjectStore(storeName, { keyPath: 'id' });
|
||||
console.log(`DMS: Created store ${storeName} in IndexedDB`);
|
||||
}
|
||||
},
|
||||
blocked() {
|
||||
console.warn('IndexedDB upgrade blocked - another tab may have the database open');
|
||||
},
|
||||
blocking() {
|
||||
console.warn('IndexedDB upgrade blocking - this tab is preventing another tab from upgrading');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all messages from IndexedDB for a specific user
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const messageStore = await readMessagesFromDB('npub1...');
|
||||
* if (messageStore) {
|
||||
* console.log('Loaded messages:', messageStore.participants);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export async function readMessagesFromDB(userNpub: string): Promise<MessageStore | null> {
|
||||
try {
|
||||
const db = await initDB(userNpub);
|
||||
const storeName = `messages-${userNpub}`;
|
||||
|
||||
// Check if the store exists before trying to read from it
|
||||
if (!db.objectStoreNames.contains(storeName)) {
|
||||
console.log(`Store ${storeName} does not exist yet for user ${userNpub.slice(0, 8)}...`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Read the entire store as one object
|
||||
const storeData = await db.get(storeName, 'messageStore');
|
||||
|
||||
if (storeData) {
|
||||
console.log(`Read message store from IndexedDB for user ${userNpub.slice(0, 8)}...`);
|
||||
return storeData as MessageStore;
|
||||
} else {
|
||||
console.log(`DMS: No message store found in IndexedDB for user ${userNpub.slice(0, 8)}...`);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error reading messages from IndexedDB:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write messages to IndexedDB for a specific user
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* await writeMessagesToDB('npub1...', {
|
||||
* participants: {
|
||||
* 'hex-pubkey': {
|
||||
* messages: [...],
|
||||
* lastActivity: Date.now(),
|
||||
* hasNIP4: true,
|
||||
* hasNIP17: false
|
||||
* }
|
||||
* },
|
||||
* lastSync: { nip4: Date.now(), nip17: null }
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export async function writeMessagesToDB(userNpub: string, messageStore: MessageStore): Promise<void> {
|
||||
try {
|
||||
const db = await initDB(userNpub);
|
||||
const storeName = `messages-${userNpub}`;
|
||||
|
||||
// Check if the store exists before trying to write to it
|
||||
if (!db.objectStoreNames.contains(storeName)) {
|
||||
console.log(`Store ${storeName} does not exist yet for user ${userNpub.slice(0, 8)}..., creating it`);
|
||||
// Force a database upgrade to create the store
|
||||
await db.close();
|
||||
const newDb = await openDB(DB_NAME, DB_VERSION + 1, {
|
||||
upgrade(db, _oldVersion, _newVersion) {
|
||||
if (!db.objectStoreNames.contains(storeName)) {
|
||||
db.createObjectStore(storeName, { keyPath: 'id' });
|
||||
console.log(`DMS: Created store ${storeName} in IndexedDB during write`);
|
||||
}
|
||||
},
|
||||
});
|
||||
await newDb.put(storeName, { id: 'messageStore', ...messageStore });
|
||||
await newDb.close();
|
||||
} else {
|
||||
// Store the entire message store as one object
|
||||
await db.put(storeName, { id: 'messageStore', ...messageStore });
|
||||
}
|
||||
|
||||
console.log(`Wrote message store to IndexedDB for user ${userNpub.slice(0, 8)}... (${Object.keys(messageStore.participants).length} participants)`);
|
||||
} catch (error) {
|
||||
console.error('Error writing messages to IndexedDB:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all messages from IndexedDB for a specific user
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* await clearMessagesFromDB('npub1...');
|
||||
* ```
|
||||
*/
|
||||
export async function clearMessagesFromDB(userNpub: string): Promise<void> {
|
||||
try {
|
||||
const db = await initDB(userNpub);
|
||||
const storeName = `messages-${userNpub}`;
|
||||
|
||||
if (db.objectStoreNames.contains(storeName)) {
|
||||
// Clear the entire store
|
||||
const tx = db.transaction(storeName, 'readwrite');
|
||||
const store = tx.objectStore(storeName);
|
||||
await store.clear();
|
||||
await tx.done;
|
||||
|
||||
console.log(`DMS: Cleared message store from IndexedDB for user ${userNpub.slice(0, 8)}...`);
|
||||
} else {
|
||||
console.log(`DMS: Store ${storeName} does not exist for user ${userNpub.slice(0, 8)}..., nothing to clear`);
|
||||
}
|
||||
|
||||
await db.close();
|
||||
} catch (error) {
|
||||
console.error('DMS: Error clearing messages from IndexedDB:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
|
||||
/**
|
||||
* DM Tab Types - for organizing conversations
|
||||
*/
|
||||
export type DMTabType = 'known' | 'newRequests';
|
||||
|
||||
/**
|
||||
* Message Protocol Types
|
||||
*/
|
||||
export const MESSAGE_PROTOCOL = {
|
||||
NIP04: 'NIP04',
|
||||
NIP17: 'NIP17',
|
||||
UNKNOWN: 'UNKNOWN'
|
||||
} as const;
|
||||
|
||||
export type MessageProtocol = typeof MESSAGE_PROTOCOL[keyof typeof MESSAGE_PROTOCOL];
|
||||
|
||||
/**
|
||||
* Decrypted message with additional metadata
|
||||
*/
|
||||
export interface DecryptedMessage extends NostrEvent {
|
||||
decryptedContent?: string;
|
||||
error?: string;
|
||||
isSending?: boolean;
|
||||
clientFirstSeen?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* DM Conversation structure
|
||||
*/
|
||||
export interface DMConversation {
|
||||
id: string; // The other person's pubkey
|
||||
pubkey: string;
|
||||
lastMessage?: DecryptedMessage;
|
||||
lastMessageTime: number;
|
||||
unreadCount: number;
|
||||
// Conversation categorization
|
||||
isKnown?: boolean; // User has sent at least one message to this person
|
||||
isRequest?: boolean; // Other person has sent messages, but user hasn't replied
|
||||
// Reply status tracking
|
||||
lastMessageFromUser?: boolean; // True if user sent the last message, false if other person did
|
||||
}
|
||||
|
||||
/**
|
||||
* Message sending parameters
|
||||
*/
|
||||
export interface SendMessageParams {
|
||||
recipientPubkey: string;
|
||||
content: string;
|
||||
protocol?: MessageProtocol; // Optional - defaults to NIP-04
|
||||
attachments?: Array<{
|
||||
url: string;
|
||||
mimeType: string;
|
||||
size: number;
|
||||
name: string;
|
||||
tags: string[][];
|
||||
}>;
|
||||
}
|
||||
Reference in new issue
Block a user