Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3750e99e61 | ||
|
|
2c1f3265b7 | ||
|
|
7ff8e257dd | ||
|
|
8b6ead1f81 | ||
|
|
38d9a9ef9f | ||
|
|
b55a3f01b6 | ||
|
b7bedf085a
|
|||
|
ff82e41012
|
|||
|
45b1fb58e9
|
|||
|
b535a7b967
|
|||
|
abd4a21f8f
|
@@ -42,25 +42,34 @@ This project uses **standard semver with `v` prefix** (e.g., `v0.0.8`, `v1.2.3`)
|
|||||||
```
|
```
|
||||||
If any step fails, fix issues before proceeding.
|
If any step fails, fix issues before proceeding.
|
||||||
|
|
||||||
6. **Compose a commit message** following this format:
|
6. **Create release zip files** in the `releases/` folder:
|
||||||
|
```
|
||||||
|
mkdir -p releases
|
||||||
|
rm -f releases/plebeian-signer-chrome-v*.zip releases/plebeian-signer-firefox-v*.zip
|
||||||
|
cd dist/chrome && zip -r ../../releases/plebeian-signer-chrome-vX.Y.Z.zip . && cd ../..
|
||||||
|
cd dist/firefox && zip -r ../../releases/plebeian-signer-firefox-vX.Y.Z.zip . && cd ../..
|
||||||
|
```
|
||||||
|
Replace `vX.Y.Z` with the actual version number. Old zip files are deleted to keep only the latest release.
|
||||||
|
|
||||||
|
7. **Compose a commit message** following this format:
|
||||||
- First line: 72 chars max, imperative mood summary (e.g., "Release v0.0.8")
|
- First line: 72 chars max, imperative mood summary (e.g., "Release v0.0.8")
|
||||||
- Blank line
|
- Blank line
|
||||||
- Bullet points describing each significant change
|
- Bullet points describing each significant change
|
||||||
- "Files modified:" section listing affected files
|
- "Files modified:" section listing affected files
|
||||||
- Footer with Claude Code attribution
|
- Footer with Claude Code attribution
|
||||||
|
|
||||||
7. **Stage all changes** with `git add -A`
|
8. **Stage all changes** with `git add -A`
|
||||||
|
|
||||||
8. **Create the commit** with the composed message
|
9. **Create the commit** with the composed message
|
||||||
|
|
||||||
9. **Create a git tag** matching the version (e.g., `v0.0.8`)
|
10. **Create a git tag** matching the version (e.g., `v0.0.8`)
|
||||||
|
|
||||||
10. **Push to origin** with tags:
|
11. **Push to origin** with tags:
|
||||||
```
|
```
|
||||||
git push origin main --tags
|
git push origin main --tags
|
||||||
```
|
```
|
||||||
|
|
||||||
11. **Report completion** with the new version and commit hash
|
12. **Report completion** with the new version and commit hash
|
||||||
|
|
||||||
## Important:
|
## Important:
|
||||||
- This is a browser extension with separate Chrome and Firefox builds
|
- This is a browser extension with separate Chrome and Firefox builds
|
||||||
|
|||||||
112
docs/store/PRIVACY_POLICY.md
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
# Plebeian Signer Privacy Policy
|
||||||
|
|
||||||
|
**Last Updated:** December 20, 2025
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Plebeian Signer is a browser extension for managing Nostr identities and signing cryptographic events. This privacy policy explains how we handle your data.
|
||||||
|
|
||||||
|
## Data Collection
|
||||||
|
|
||||||
|
**We do not collect any personal data.**
|
||||||
|
|
||||||
|
Plebeian Signer operates entirely locally within your browser. We do not:
|
||||||
|
- Collect analytics or telemetry
|
||||||
|
- Track your usage or behavior
|
||||||
|
- Send your data to any external servers
|
||||||
|
- Use cookies or tracking technologies
|
||||||
|
- Share any information with third parties
|
||||||
|
|
||||||
|
## Data Storage
|
||||||
|
|
||||||
|
All data is stored locally in your browser using the browser's built-in storage APIs:
|
||||||
|
|
||||||
|
### What We Store Locally
|
||||||
|
|
||||||
|
1. **Encrypted Vault Data**
|
||||||
|
- Your Nostr private keys (encrypted with Argon2id + AES-256-GCM)
|
||||||
|
- Identity nicknames and metadata
|
||||||
|
- Relay configurations
|
||||||
|
- Site permissions
|
||||||
|
|
||||||
|
2. **Session Data**
|
||||||
|
- Temporary decryption keys (cleared when browser closes or vault locks)
|
||||||
|
- Cached profile metadata
|
||||||
|
|
||||||
|
3. **Extension Settings**
|
||||||
|
- Sync preferences
|
||||||
|
- Reckless mode settings
|
||||||
|
- Whitelisted hosts
|
||||||
|
|
||||||
|
### Encryption
|
||||||
|
|
||||||
|
Your private keys are never stored in plaintext. The vault uses:
|
||||||
|
- **Argon2id** for password-based key derivation (256MB memory, 4 threads, 8 iterations)
|
||||||
|
- **AES-256-GCM** for authenticated encryption
|
||||||
|
- **Random salt and IV** generated for each vault
|
||||||
|
|
||||||
|
## Network Communications
|
||||||
|
|
||||||
|
Plebeian Signer makes the following network requests:
|
||||||
|
|
||||||
|
1. **Nostr Relay Connections**
|
||||||
|
- To fetch your profile metadata (kind 0 events)
|
||||||
|
- To fetch relay lists (kind 10002 events)
|
||||||
|
- Only connects to relays you have configured
|
||||||
|
|
||||||
|
2. **NIP-05 Verification**
|
||||||
|
- Fetches `.well-known/nostr.json` from domains in NIP-05 identifiers
|
||||||
|
- Used only to verify identity claims
|
||||||
|
|
||||||
|
**We do not operate any servers.** All relay connections are made directly to the Nostr network.
|
||||||
|
|
||||||
|
## Permissions Explained
|
||||||
|
|
||||||
|
The extension requests these browser permissions:
|
||||||
|
|
||||||
|
- **`storage`**: To save your encrypted vault and settings
|
||||||
|
- **`activeTab`**: To inject the NIP-07 interface into web pages
|
||||||
|
- **`scripting`**: To enable communication between pages and the extension
|
||||||
|
|
||||||
|
## Data Sharing
|
||||||
|
|
||||||
|
We do not share any data with third parties. The extension:
|
||||||
|
- Has no backend servers
|
||||||
|
- Does not use analytics services
|
||||||
|
- Does not include advertising
|
||||||
|
- Does not sell or monetize your data in any way
|
||||||
|
|
||||||
|
## Your Control
|
||||||
|
|
||||||
|
You have full control over your data:
|
||||||
|
- **Export**: You can export your encrypted vault at any time
|
||||||
|
- **Delete**: Use the "Reset Extension" feature to delete all local data
|
||||||
|
- **Lock**: Lock your vault to clear session data immediately
|
||||||
|
|
||||||
|
## Open Source
|
||||||
|
|
||||||
|
Plebeian Signer is open source software. You can audit the code yourself:
|
||||||
|
- Repository: https://git.mleku.dev/mleku/plebeian-signer
|
||||||
|
|
||||||
|
## Children's Privacy
|
||||||
|
|
||||||
|
This extension is not intended for children under 13 years of age. We do not knowingly collect any information from children.
|
||||||
|
|
||||||
|
## Changes to This Policy
|
||||||
|
|
||||||
|
If we make changes to this privacy policy, we will update the "Last Updated" date at the top of this document. Significant changes will be noted in the extension's release notes.
|
||||||
|
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
For privacy-related questions or concerns, please open an issue on our repository:
|
||||||
|
https://git.mleku.dev/mleku/plebeian-signer/issues
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
- All data stays in your browser
|
||||||
|
- Private keys are encrypted with strong cryptography
|
||||||
|
- No analytics, tracking, or data collection
|
||||||
|
- No external servers (except Nostr relays you configure)
|
||||||
|
- Fully open source and auditable
|
||||||
293
docs/store/PUBLISHING_GUIDE.md
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
# Extension Store Publishing Guide
|
||||||
|
|
||||||
|
This guide walks you through publishing Plebeian Signer to the Chrome Web Store and Firefox Add-ons.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
1. [Assets You Need to Create](#assets-you-need-to-create)
|
||||||
|
2. [Chrome Web Store](#chrome-web-store)
|
||||||
|
3. [Firefox Add-ons](#firefox-add-ons)
|
||||||
|
4. [Ongoing Maintenance](#ongoing-maintenance)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Assets You Need to Create
|
||||||
|
|
||||||
|
Before submitting to either store, prepare these assets:
|
||||||
|
|
||||||
|
### Screenshots (Required for both stores)
|
||||||
|
|
||||||
|
Create 3-5 screenshots showing the extension in action:
|
||||||
|
|
||||||
|
1. **Main popup view** - Show the identity card with profile info
|
||||||
|
2. **Permission prompt** - Show a signing request popup
|
||||||
|
3. **Identity management** - Show the identity list/switching
|
||||||
|
4. **Permissions page** - Show the permissions management
|
||||||
|
5. **Settings page** - Show vault settings and options
|
||||||
|
|
||||||
|
**Specifications:**
|
||||||
|
- Chrome: 1280x800 or 640x400 pixels (PNG or JPEG)
|
||||||
|
- Firefox: 1280x800 recommended (PNG or JPEG)
|
||||||
|
|
||||||
|
**Tips:**
|
||||||
|
- Use a clean browser profile
|
||||||
|
- Show realistic data (not "test" or placeholder text)
|
||||||
|
- Capture the full popup or relevant UI area
|
||||||
|
- Consider adding captions/annotations
|
||||||
|
|
||||||
|
### Promotional Images (Chrome only)
|
||||||
|
|
||||||
|
Chrome Web Store uses promotional tiles:
|
||||||
|
|
||||||
|
| Size | Name | Required |
|
||||||
|
|------|------|----------|
|
||||||
|
| 440x280 | Small promo tile | Optional but recommended |
|
||||||
|
| 920x680 | Large promo tile | Optional |
|
||||||
|
| 1400x560 | Marquee promo tile | Optional |
|
||||||
|
|
||||||
|
**Design tips:**
|
||||||
|
- Include the extension icon/logo
|
||||||
|
- Add a tagline like "Secure Nostr Identity Manager"
|
||||||
|
- Use brand colors
|
||||||
|
- Keep text minimal and readable
|
||||||
|
|
||||||
|
### Icon (Already exists)
|
||||||
|
|
||||||
|
You already have icons in the extension:
|
||||||
|
- `icon-48.png` - 48x48
|
||||||
|
- `icon-128.png` - 128x128
|
||||||
|
|
||||||
|
Chrome also wants a 128x128 icon for the store listing (can use the same one).
|
||||||
|
|
||||||
|
### Privacy Policy URL
|
||||||
|
|
||||||
|
You need to host the privacy policy at a public URL. Options:
|
||||||
|
|
||||||
|
1. **GitHub/Gitea Pages** - Host `PRIVACY_POLICY.md` as a webpage
|
||||||
|
2. **Simple webpage** - Create a basic HTML page
|
||||||
|
3. **Gist** - Create a public GitHub gist
|
||||||
|
|
||||||
|
Example URL format: `https://git.mleku.dev/mleku/plebeian-signer/src/branch/main/docs/store/PRIVACY_POLICY.md`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Chrome Web Store
|
||||||
|
|
||||||
|
### Step 1: Create Developer Account
|
||||||
|
|
||||||
|
1. Go to https://chrome.google.com/webstore/devconsole
|
||||||
|
2. Sign in with a Google account
|
||||||
|
3. Pay the one-time $5 USD registration fee
|
||||||
|
4. Accept the developer agreement
|
||||||
|
|
||||||
|
### Step 2: Create New Item
|
||||||
|
|
||||||
|
1. Click **"New Item"** button
|
||||||
|
2. Upload `releases/plebeian-signer-chrome-v1.0.5.zip`
|
||||||
|
3. Wait for the upload to process
|
||||||
|
|
||||||
|
### Step 3: Fill Store Listing
|
||||||
|
|
||||||
|
**Product Details:**
|
||||||
|
- **Name:** Plebeian Signer
|
||||||
|
- **Summary:** Copy from `STORE_DESCRIPTION.md` (short description, 132 chars max)
|
||||||
|
- **Description:** Copy from `STORE_DESCRIPTION.md` (full description)
|
||||||
|
- **Category:** Productivity
|
||||||
|
- **Language:** English
|
||||||
|
|
||||||
|
**Graphic Assets:**
|
||||||
|
- Upload your screenshots (at least 1 required, up to 5)
|
||||||
|
- Upload promotional tiles if you have them
|
||||||
|
|
||||||
|
**Additional Fields:**
|
||||||
|
- **Official URL:** `https://git.mleku.dev/mleku/plebeian-signer`
|
||||||
|
- **Support URL:** `https://git.mleku.dev/mleku/plebeian-signer/issues`
|
||||||
|
|
||||||
|
### Step 4: Privacy Tab
|
||||||
|
|
||||||
|
- **Single Purpose:** "Manage Nostr identities and sign cryptographic events for web applications"
|
||||||
|
- **Permission Justifications:**
|
||||||
|
- `storage`: "Store encrypted vault containing user's Nostr identities and extension settings"
|
||||||
|
- `activeTab`: "Inject NIP-07 interface into the active tab when user visits Nostr applications"
|
||||||
|
- `scripting`: "Enable communication between web pages and the extension for signing requests"
|
||||||
|
- **Data Usage:** Check "I do not sell or transfer user data to third parties"
|
||||||
|
- **Privacy Policy URL:** Your hosted privacy policy URL
|
||||||
|
|
||||||
|
### Step 5: Distribution
|
||||||
|
|
||||||
|
- **Visibility:** Public
|
||||||
|
- **Distribution:** All regions (or select specific ones)
|
||||||
|
|
||||||
|
### Step 6: Submit for Review
|
||||||
|
|
||||||
|
1. Review all sections show green checkmarks
|
||||||
|
2. Click **"Submit for Review"**
|
||||||
|
3. Wait 1-3 business days (can take longer for first submission)
|
||||||
|
|
||||||
|
### Chrome Review Notes
|
||||||
|
|
||||||
|
Google may ask about:
|
||||||
|
- Why you need each permission
|
||||||
|
- How you handle user data
|
||||||
|
- Your identity/organization
|
||||||
|
|
||||||
|
Be prepared to respond to reviewer questions via the dashboard.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Firefox Add-ons
|
||||||
|
|
||||||
|
### Step 1: Create Developer Account
|
||||||
|
|
||||||
|
1. Go to https://addons.mozilla.org/developers/
|
||||||
|
2. Sign in with a Firefox account (create one if needed)
|
||||||
|
3. No fee required
|
||||||
|
|
||||||
|
### Step 2: Submit New Add-on
|
||||||
|
|
||||||
|
1. Click **"Submit a New Add-on"**
|
||||||
|
2. Select **"On this site"** for hosting
|
||||||
|
3. Upload `releases/plebeian-signer-firefox-v1.0.5.zip`
|
||||||
|
4. Wait for automated validation
|
||||||
|
|
||||||
|
### Step 3: Source Code Submission
|
||||||
|
|
||||||
|
Firefox may request source code because the extension uses bundled/minified JavaScript.
|
||||||
|
|
||||||
|
**If prompted:**
|
||||||
|
1. Create a source code zip (exclude `node_modules`):
|
||||||
|
```bash
|
||||||
|
cd /home/mleku/src/git.mleku.dev/mleku/plebeian-signer
|
||||||
|
zip -r plebeian-signer-source.zip . -x "node_modules/*" -x "dist/*" -x ".git/*"
|
||||||
|
```
|
||||||
|
2. Upload this zip when asked
|
||||||
|
3. Include build instructions (point to CLAUDE.md or add a note):
|
||||||
|
```
|
||||||
|
Build Instructions:
|
||||||
|
1. npm ci
|
||||||
|
2. npm run build:firefox
|
||||||
|
3. Output is in dist/firefox/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 4: Fill Listing Details
|
||||||
|
|
||||||
|
**Basic Information:**
|
||||||
|
- **Name:** Plebeian Signer
|
||||||
|
- **Add-on URL:** `plebeian-signer` (creates addons.mozilla.org/addon/plebeian-signer)
|
||||||
|
- **Summary:** Copy short description from `STORE_DESCRIPTION.md`
|
||||||
|
- **Description:** Copy full description (supports some HTML/Markdown)
|
||||||
|
- **Categories:** Privacy & Security
|
||||||
|
|
||||||
|
**Additional Details:**
|
||||||
|
- **Homepage:** `https://git.mleku.dev/mleku/plebeian-signer`
|
||||||
|
- **Support URL:** `https://git.mleku.dev/mleku/plebeian-signer/issues`
|
||||||
|
- **License:** Select appropriate license
|
||||||
|
- **Privacy Policy:** Paste URL to hosted privacy policy
|
||||||
|
|
||||||
|
**Media:**
|
||||||
|
- **Icon:** Already in the extension manifest
|
||||||
|
- **Screenshots:** Upload your screenshots
|
||||||
|
|
||||||
|
### Step 5: Submit for Review
|
||||||
|
|
||||||
|
1. Ensure all required fields are complete
|
||||||
|
2. Click **"Submit Version"**
|
||||||
|
3. Wait for review (usually hours to a few days)
|
||||||
|
|
||||||
|
### Firefox Review Notes
|
||||||
|
|
||||||
|
Firefox reviewers are generally faster but thorough. They may:
|
||||||
|
- Ask for source code (see Step 3)
|
||||||
|
- Question specific code patterns
|
||||||
|
- Request changes for policy compliance
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ongoing Maintenance
|
||||||
|
|
||||||
|
### Updating the Extension
|
||||||
|
|
||||||
|
**For new releases:**
|
||||||
|
|
||||||
|
1. Build new version: `/release patch` (or `minor`/`major`)
|
||||||
|
2. Upload the new zip to each store
|
||||||
|
3. Add release notes describing changes
|
||||||
|
4. Submit for review
|
||||||
|
|
||||||
|
**Chrome:**
|
||||||
|
- Go to Developer Dashboard → Your extension → Package → Upload new package
|
||||||
|
|
||||||
|
**Firefox:**
|
||||||
|
- Go to Developer Hub → Your extension → Upload a New Version
|
||||||
|
|
||||||
|
### Responding to Reviews
|
||||||
|
|
||||||
|
Both stores may contact you with:
|
||||||
|
- Policy violation notices
|
||||||
|
- User reports
|
||||||
|
- Review questions
|
||||||
|
|
||||||
|
Monitor your developer email and respond promptly.
|
||||||
|
|
||||||
|
### Version Numbering
|
||||||
|
|
||||||
|
Both stores extract the version from `manifest.json`. Your current setup with `v1.0.5` in `package.json` feeds into the manifests correctly.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Checklist
|
||||||
|
|
||||||
|
### Before First Submission
|
||||||
|
|
||||||
|
- [ ] Create 3-5 screenshots
|
||||||
|
- [ ] Create promotional images (Chrome, optional but recommended)
|
||||||
|
- [ ] Host privacy policy at a public URL
|
||||||
|
- [ ] Test the extension zip by loading it unpacked
|
||||||
|
- [ ] Prepare source code zip for Firefox
|
||||||
|
|
||||||
|
### Chrome Web Store
|
||||||
|
|
||||||
|
- [ ] Register developer account ($5)
|
||||||
|
- [ ] Upload extension zip
|
||||||
|
- [ ] Fill all required listing fields
|
||||||
|
- [ ] Add screenshots
|
||||||
|
- [ ] Add privacy policy URL
|
||||||
|
- [ ] Justify all permissions
|
||||||
|
- [ ] Submit for review
|
||||||
|
|
||||||
|
### Firefox Add-ons
|
||||||
|
|
||||||
|
- [ ] Register developer account (free)
|
||||||
|
- [ ] Upload extension zip
|
||||||
|
- [ ] Upload source code if requested
|
||||||
|
- [ ] Fill all required listing fields
|
||||||
|
- [ ] Add screenshots
|
||||||
|
- [ ] Add privacy policy URL
|
||||||
|
- [ ] Submit for review
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Helpful Links
|
||||||
|
|
||||||
|
- Chrome Developer Dashboard: https://chrome.google.com/webstore/devconsole
|
||||||
|
- Chrome Publishing Docs: https://developer.chrome.com/docs/webstore/publish/
|
||||||
|
- Firefox Developer Hub: https://addons.mozilla.org/developers/
|
||||||
|
- Firefox Extension Workshop: https://extensionworkshop.com/documentation/publish/
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Estimated Timeline
|
||||||
|
|
||||||
|
| Task | Time |
|
||||||
|
|------|------|
|
||||||
|
| Create screenshots | 30 min - 1 hour |
|
||||||
|
| Create promotional images | 1-2 hours (optional) |
|
||||||
|
| Host privacy policy | 15 min |
|
||||||
|
| Chrome submission | 30 min |
|
||||||
|
| Chrome review | 1-3 business days |
|
||||||
|
| Firefox submission | 30 min |
|
||||||
|
| Firefox review | Hours to 2 days |
|
||||||
|
|
||||||
|
**Total:** You can have both submissions done in an afternoon, with approvals coming within a week.
|
||||||
88
docs/store/STORE_DESCRIPTION.md
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# Plebeian Signer - Store Description
|
||||||
|
|
||||||
|
Use this content for Chrome Web Store and Firefox Add-ons listings.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Short Description (132 characters max for Chrome)
|
||||||
|
|
||||||
|
Secure Nostr identity manager. Sign events without exposing private keys. Multi-identity support with NIP-07 compatibility.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Full Description
|
||||||
|
|
||||||
|
**Plebeian Signer** is a secure browser extension for managing your Nostr identities and signing events without exposing your private keys to web applications.
|
||||||
|
|
||||||
|
### Key Features
|
||||||
|
|
||||||
|
**Multi-Identity Management**
|
||||||
|
- Create and manage multiple Nostr identities from a single extension
|
||||||
|
- Easily switch between identities with one click
|
||||||
|
- Import existing keys or generate new ones
|
||||||
|
|
||||||
|
**Bank-Grade Security**
|
||||||
|
- Private keys never leave the extension
|
||||||
|
- Vault encrypted with Argon2id + AES-256-GCM (the same algorithms used by password managers)
|
||||||
|
- Automatic vault locking for protection
|
||||||
|
|
||||||
|
**NIP-07 Compatible**
|
||||||
|
- Works with all Nostr web applications that support NIP-07
|
||||||
|
- Supports NIP-04 and NIP-44 encryption/decryption
|
||||||
|
- Relay configuration per identity
|
||||||
|
|
||||||
|
**Permission Control**
|
||||||
|
- Fine-grained permission management per application
|
||||||
|
- Approve or deny signing requests on a per-site basis
|
||||||
|
- Optional "Reckless Mode" for trusted applications
|
||||||
|
- Whitelist trusted hosts for automatic approval
|
||||||
|
|
||||||
|
**User-Friendly Interface**
|
||||||
|
- Clean, intuitive design
|
||||||
|
- Profile metadata display with avatar and banner
|
||||||
|
- NIP-05 verification support
|
||||||
|
- Bookmark your favorite Nostr apps
|
||||||
|
|
||||||
|
### How It Works
|
||||||
|
|
||||||
|
1. Create a password-protected vault
|
||||||
|
2. Add your Nostr identities (import existing or generate new)
|
||||||
|
3. Visit any NIP-07 compatible Nostr application
|
||||||
|
4. Approve signing requests through the extension popup
|
||||||
|
|
||||||
|
### Privacy First
|
||||||
|
|
||||||
|
Plebeian Signer is open source and respects your privacy:
|
||||||
|
- No telemetry or analytics
|
||||||
|
- No external servers (except for profile metadata from Nostr relays)
|
||||||
|
- All cryptographic operations happen locally in your browser
|
||||||
|
- Your private keys are encrypted and never transmitted
|
||||||
|
|
||||||
|
### Supported NIPs
|
||||||
|
|
||||||
|
- NIP-07: Browser Extension for Nostr
|
||||||
|
- NIP-04: Encrypted Direct Messages
|
||||||
|
- NIP-44: Versioned Encryption
|
||||||
|
|
||||||
|
### Links
|
||||||
|
|
||||||
|
- Source Code: https://git.mleku.dev/mleku/plebeian-signer
|
||||||
|
- Report Issues: https://git.mleku.dev/mleku/plebeian-signer/issues
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Category Suggestions
|
||||||
|
|
||||||
|
**Chrome Web Store:**
|
||||||
|
- Primary: Productivity
|
||||||
|
- Secondary: Developer Tools
|
||||||
|
|
||||||
|
**Firefox Add-ons:**
|
||||||
|
- Primary: Privacy & Security
|
||||||
|
- Secondary: Other
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Tags/Keywords
|
||||||
|
|
||||||
|
nostr, nip-07, signing, identity, privacy, encryption, decentralized, keys, wallet, security
|
||||||
129
docs/store/publishing.md
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
# Publishing Checklist
|
||||||
|
|
||||||
|
Developer accounts are set up. This document covers the remaining steps.
|
||||||
|
|
||||||
|
## Privacy Policy URL
|
||||||
|
|
||||||
|
```
|
||||||
|
https://git.mleku.dev/mleku/plebeian-signer/src/branch/main/docs/store/PRIVACY_POLICY.md
|
||||||
|
```
|
||||||
|
|
||||||
|
## Screenshots Needed
|
||||||
|
|
||||||
|
Take 3-5 screenshots (1280x800 or 640x400 PNG/JPEG):
|
||||||
|
|
||||||
|
1. **Identity view** - Main popup showing profile card with avatar/banner
|
||||||
|
2. **Permission prompt** - A signing request popup from a Nostr app
|
||||||
|
3. **Identity list** - Multiple identities with switching UI
|
||||||
|
4. **Permissions page** - Managing site permissions
|
||||||
|
5. **Settings** - Vault/reckless mode settings
|
||||||
|
|
||||||
|
**Tips:**
|
||||||
|
- Load the extension in a clean browser profile
|
||||||
|
- Use real-looking test data, not "test123"
|
||||||
|
- Crop to show just the popup/relevant UI
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Chrome Web Store Submission
|
||||||
|
|
||||||
|
1. Go to https://chrome.google.com/webstore/devconsole
|
||||||
|
2. Click **"New Item"**
|
||||||
|
3. Upload: `releases/plebeian-signer-chrome-v1.0.5.zip`
|
||||||
|
|
||||||
|
### Store Listing Tab
|
||||||
|
|
||||||
|
| Field | Value |
|
||||||
|
|-------|-------|
|
||||||
|
| Name | Plebeian Signer |
|
||||||
|
| Summary | Secure Nostr identity manager. Sign events without exposing private keys. Multi-identity support with NIP-07 compatibility. |
|
||||||
|
| Description | Copy from `docs/store/STORE_DESCRIPTION.md` (full description section) |
|
||||||
|
| Category | Productivity |
|
||||||
|
| Language | English |
|
||||||
|
|
||||||
|
Upload your screenshots.
|
||||||
|
|
||||||
|
### Privacy Tab
|
||||||
|
|
||||||
|
| Field | Value |
|
||||||
|
|-------|-------|
|
||||||
|
| Single Purpose | Manage Nostr identities and sign cryptographic events for web applications |
|
||||||
|
| Privacy Policy URL | `https://git.mleku.dev/mleku/plebeian-signer/src/branch/main/docs/store/PRIVACY_POLICY.md` |
|
||||||
|
|
||||||
|
**Permission Justifications:**
|
||||||
|
|
||||||
|
| Permission | Justification |
|
||||||
|
|------------|---------------|
|
||||||
|
| storage | Store encrypted vault containing user's Nostr identities and extension settings |
|
||||||
|
| activeTab | Inject NIP-07 interface into the active tab when user visits Nostr applications |
|
||||||
|
| scripting | Enable communication between web pages and the extension for signing requests |
|
||||||
|
|
||||||
|
Check: "I do not sell or transfer user data to third parties"
|
||||||
|
|
||||||
|
### Distribution Tab
|
||||||
|
|
||||||
|
- Visibility: Public
|
||||||
|
- Regions: All
|
||||||
|
|
||||||
|
Click **"Submit for Review"**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Firefox Add-ons Submission
|
||||||
|
|
||||||
|
1. Go to https://addons.mozilla.org/developers/
|
||||||
|
2. Click **"Submit a New Add-on"**
|
||||||
|
3. Select **"On this site"**
|
||||||
|
4. Upload: `releases/plebeian-signer-firefox-v1.0.5.zip`
|
||||||
|
|
||||||
|
### If Asked for Source Code
|
||||||
|
|
||||||
|
Run this to create source zip:
|
||||||
|
```bash
|
||||||
|
cd /home/mleku/src/git.mleku.dev/mleku/plebeian-signer
|
||||||
|
zip -r plebeian-signer-source.zip . -x "node_modules/*" -x "dist/*" -x ".git/*" -x "releases/*"
|
||||||
|
```
|
||||||
|
|
||||||
|
Build instructions to provide:
|
||||||
|
```
|
||||||
|
1. npm ci
|
||||||
|
2. npm run build:firefox
|
||||||
|
3. Output is in dist/firefox/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Listing Details
|
||||||
|
|
||||||
|
| Field | Value |
|
||||||
|
|-------|-------|
|
||||||
|
| Name | Plebeian Signer |
|
||||||
|
| Add-on URL | plebeian-signer |
|
||||||
|
| Summary | Secure Nostr identity manager. Sign events without exposing private keys. Multi-identity support with NIP-07 compatibility. |
|
||||||
|
| Description | Copy from `docs/store/STORE_DESCRIPTION.md` |
|
||||||
|
| Categories | Privacy & Security |
|
||||||
|
| Homepage | `https://git.mleku.dev/mleku/plebeian-signer` |
|
||||||
|
| Support URL | `https://git.mleku.dev/mleku/plebeian-signer/issues` |
|
||||||
|
| Privacy Policy | `https://git.mleku.dev/mleku/plebeian-signer/src/branch/main/docs/store/PRIVACY_POLICY.md` |
|
||||||
|
|
||||||
|
Upload your screenshots.
|
||||||
|
|
||||||
|
Click **"Submit Version"**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## After Submission
|
||||||
|
|
||||||
|
- **Chrome:** 1-3 business days review
|
||||||
|
- **Firefox:** Hours to 2 days review
|
||||||
|
|
||||||
|
Check your email for reviewer questions. Both dashboards show review status.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Updating Later
|
||||||
|
|
||||||
|
When you release a new version:
|
||||||
|
|
||||||
|
1. Run `/release patch` (or minor/major)
|
||||||
|
2. Chrome: Dashboard → Your extension → Package → Upload new package
|
||||||
|
3. Firefox: Developer Hub → Your extension → Upload a New Version
|
||||||
|
4. Add release notes, submit for review
|
||||||
11
package.json
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "plebeian-signer",
|
"name": "plebeian-signer",
|
||||||
"version": "v1.0.1",
|
"version": "v1.0.8",
|
||||||
"custom": {
|
"custom": {
|
||||||
"chrome": {
|
"chrome": {
|
||||||
"version": "v1.0.1"
|
"version": "v1.0.8"
|
||||||
},
|
},
|
||||||
"firefox": {
|
"firefox": {
|
||||||
"version": "v1.0.1"
|
"version": "v1.0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -15,10 +15,11 @@
|
|||||||
"clean:firefox": "rimraf dist/firefox",
|
"clean:firefox": "rimraf dist/firefox",
|
||||||
"start:chrome": "ng serve chrome",
|
"start:chrome": "ng serve chrome",
|
||||||
"start:firefox": "ng serve firefox",
|
"start:firefox": "ng serve firefox",
|
||||||
|
"fetch-kinds": "node scripts/fetch-kinds.js",
|
||||||
"prepare:chrome": "./chrome_prepare_manifest.sh",
|
"prepare:chrome": "./chrome_prepare_manifest.sh",
|
||||||
"prepare:firefox": "./firefox_prepare_manifest.sh",
|
"prepare:firefox": "./firefox_prepare_manifest.sh",
|
||||||
"build:chrome": "npm run prepare:chrome && ng build chrome",
|
"build:chrome": "npm run fetch-kinds && npm run prepare:chrome && ng build chrome",
|
||||||
"build:firefox": "npm run prepare:firefox && ng build firefox",
|
"build:firefox": "npm run fetch-kinds && npm run prepare:firefox && ng build firefox",
|
||||||
"watch:chrome": "npm run prepare:chrome && ng build chrome --watch --configuration development",
|
"watch:chrome": "npm run prepare:chrome && ng build chrome --watch --configuration development",
|
||||||
"watch:firefox": "npm run prepare:firefox && ng build firefox --watch --configuration development",
|
"watch:firefox": "npm run prepare:firefox && ng build firefox --watch --configuration development",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Plebeian Signer - Nostr Identity Manager & Signer",
|
"name": "Plebeian Signer - Nostr Identity Manager & Signer",
|
||||||
"description": "Manage and switch between multiple identities while interacting with Nostr apps",
|
"description": "Manage and switch between multiple identities while interacting with Nostr apps",
|
||||||
"version": "1.0.1",
|
"version": "1.0.8",
|
||||||
"homepage_url": "https://git.mleku.dev/mleku/plebeian-signer",
|
"homepage_url": "https://git.mleku.dev/mleku/plebeian-signer",
|
||||||
"options_page": "options.html",
|
"options_page": "options.html",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 983 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -226,7 +226,7 @@
|
|||||||
<!------------->
|
<!------------->
|
||||||
<div class="sam-footer-grid-2">
|
<div class="sam-footer-grid-2">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button id="rejectButton" type="button" class="btn btn-secondary">
|
<button id="rejectOnceButton" type="button" class="btn btn-secondary">
|
||||||
Reject
|
Reject
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@@ -239,16 +239,16 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
<li>
|
<li>
|
||||||
<button id="rejectJustOnceButton" class="dropdown-item">
|
<button id="rejectAlwaysButton" class="dropdown-item">
|
||||||
just once
|
Reject Always
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button id="approveButton" type="button" class="btn btn-primary">
|
<button id="approveAlwaysButton" type="button" class="btn btn-primary">
|
||||||
Approve
|
Approve Always
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -260,8 +260,8 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<button id="approveJustOnceButton" class="dropdown-item" href="#">
|
<button id="approveOnceButton" class="dropdown-item">
|
||||||
just once
|
Approve Once
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { IdentitiesComponent } from './components/home/identities/identities.com
|
|||||||
import { IdentityComponent } from './components/home/identity/identity.component';
|
import { IdentityComponent } from './components/home/identity/identity.component';
|
||||||
import { InfoComponent } from './components/home/info/info.component';
|
import { InfoComponent } from './components/home/info/info.component';
|
||||||
import { SettingsComponent } from './components/home/settings/settings.component';
|
import { SettingsComponent } from './components/home/settings/settings.component';
|
||||||
|
import { LogsComponent } from './components/home/logs/logs.component';
|
||||||
|
import { BookmarksComponent } from './components/home/bookmarks/bookmarks.component';
|
||||||
|
import { WalletComponent } from './components/home/wallet/wallet.component';
|
||||||
import { NewIdentityComponent } from './components/new-identity/new-identity.component';
|
import { NewIdentityComponent } from './components/new-identity/new-identity.component';
|
||||||
import { EditIdentityComponent } from './components/edit-identity/edit-identity.component';
|
import { EditIdentityComponent } from './components/edit-identity/edit-identity.component';
|
||||||
import { HomeComponent as EditIdentityHomeComponent } from './components/edit-identity/home/home.component';
|
import { HomeComponent as EditIdentityHomeComponent } from './components/edit-identity/home/home.component';
|
||||||
@@ -66,6 +69,18 @@ export const routes: Routes = [
|
|||||||
path: 'settings',
|
path: 'settings',
|
||||||
component: SettingsComponent,
|
component: SettingsComponent,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'logs',
|
||||||
|
component: LogsComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'bookmarks',
|
||||||
|
component: BookmarksComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'wallet',
|
||||||
|
component: WalletComponent,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,12 @@
|
|||||||
<span class="text-muted" style="font-size: 12px">
|
<span class="text-muted" style="font-size: 12px">
|
||||||
Nothing configured so far.
|
Nothing configured so far.
|
||||||
</span>
|
</span>
|
||||||
} @for(hostPermissions of hostsPermissions; track hostPermissions) {
|
} @else {
|
||||||
|
<button class="btn btn-danger btn-sm remove-all-btn" (click)="onClickRemoveAllPermissions()">
|
||||||
|
Remove All Permissions
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
@for(hostPermissions of hostsPermissions; track hostPermissions) {
|
||||||
<div class="permissions-card">
|
<div class="permissions-card">
|
||||||
<span style="margin-bottom: 4px; font-weight: 500">
|
<span style="margin-bottom: 4px; font-weight: 500">
|
||||||
{{ hostPermissions.host }}
|
{{ hostPermissions.host }}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.remove-all-btn {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
.permissions-card {
|
.permissions-card {
|
||||||
background: var(--background-light);
|
background: var(--background-light);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ export class PermissionsComponent extends NavComponent implements OnInit {
|
|||||||
this.#buildHostsPermissions(this.identity?.id);
|
this.#buildHostsPermissions(this.identity?.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickRemoveAllPermissions() {
|
||||||
|
const allPermissions = this.hostsPermissions.flatMap(hp => hp.permissions);
|
||||||
|
for (const permission of allPermissions) {
|
||||||
|
await this.#storage.deletePermission(permission.id);
|
||||||
|
}
|
||||||
|
this.#buildHostsPermissions(this.identity?.id);
|
||||||
|
}
|
||||||
|
|
||||||
#initialize(identityId: string) {
|
#initialize(identityId: string) {
|
||||||
this.identity = this.#storage
|
this.identity = this.#storage
|
||||||
.getBrowserSessionHandler()
|
.getBrowserSessionHandler()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-banner">
|
<div class="info-banner">
|
||||||
<i class="bi bi-info-circle"></i>
|
<span class="emoji">💡</span>
|
||||||
<span>These relays are fetched from your NIP-65 relay list (kind 10002). To update your relay list, use a Nostr client that supports NIP-65.</span>
|
<span>These relays are fetched from your NIP-65 relay list (kind 10002). To update your relay list, use a Nostr client that supports NIP-65.</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
||||||
|
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
||||||
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
|
<span>Bookmarks</span>
|
||||||
|
<button class="add-btn" title="Bookmark This Page" (click)="onBookmarkThisPage()">
|
||||||
|
<span class="emoji">➕</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bookmarks-container">
|
||||||
|
@if (isLoading) {
|
||||||
|
<div class="loading-state">Loading...</div>
|
||||||
|
} @else if (bookmarks.length === 0) {
|
||||||
|
<div class="empty-state">
|
||||||
|
<span class="sam-text-muted">
|
||||||
|
No bookmarks yet. Click "Bookmark This Page" to add the current page.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
@for (bookmark of bookmarks; track bookmark.id) {
|
||||||
|
<div class="bookmark-item" (click)="openBookmark(bookmark)">
|
||||||
|
<div class="bookmark-info">
|
||||||
|
<span class="bookmark-title">{{ bookmark.title }}</span>
|
||||||
|
<span class="bookmark-url">{{ getDomain(bookmark.url) }}</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="remove-btn"
|
||||||
|
title="Remove bookmark"
|
||||||
|
(click)="onRemoveBookmark(bookmark); $event.stopPropagation()"
|
||||||
|
>
|
||||||
|
<span class="emoji">✕</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: var(--size);
|
||||||
|
padding-bottom: var(--size);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.add-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--background-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmarks-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state,
|
||||||
|
.loading-state {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--size-h);
|
||||||
|
padding: var(--size-h) var(--size);
|
||||||
|
margin-bottom: var(--size-hh);
|
||||||
|
background: var(--background-light);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--background-light-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-title {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-url {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove-btn {
|
||||||
|
all: unset;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
transition: background-color 0.15s ease, color 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--destructive);
|
||||||
|
color: var(--destructive-foreground);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { Bookmark, LoggerService, SignerMetaData, StorageService } from '@common';
|
||||||
|
import { ChromeMetaHandler } from '../../../common/data/chrome-meta-handler';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-bookmarks',
|
||||||
|
templateUrl: './bookmarks.component.html',
|
||||||
|
styleUrl: './bookmarks.component.scss',
|
||||||
|
imports: [],
|
||||||
|
})
|
||||||
|
export class BookmarksComponent implements OnInit {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #metaHandler = new ChromeMetaHandler();
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
|
bookmarks: Bookmark[] = [];
|
||||||
|
isLoading = true;
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.loadBookmarks();
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadBookmarks() {
|
||||||
|
this.isLoading = true;
|
||||||
|
try {
|
||||||
|
const metaData = await this.#metaHandler.loadFullData() as SignerMetaData;
|
||||||
|
this.#metaHandler.setFullData(metaData);
|
||||||
|
this.bookmarks = this.#metaHandler.getBookmarks();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load bookmarks:', error);
|
||||||
|
} finally {
|
||||||
|
this.isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onBookmarkThisPage() {
|
||||||
|
try {
|
||||||
|
// Get the current tab URL and title
|
||||||
|
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||||
|
if (!tab?.url || !tab?.title) {
|
||||||
|
console.error('Could not get current tab info');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if already bookmarked
|
||||||
|
if (this.bookmarks.some(b => b.url === tab.url)) {
|
||||||
|
console.log('Page already bookmarked');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newBookmark: Bookmark = {
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
url: tab.url,
|
||||||
|
title: tab.title,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
};
|
||||||
|
|
||||||
|
this.bookmarks = [newBookmark, ...this.bookmarks];
|
||||||
|
await this.saveBookmarks();
|
||||||
|
this.#logger.logBookmarkAdded(newBookmark.url, newBookmark.title);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to bookmark page:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onRemoveBookmark(bookmark: Bookmark) {
|
||||||
|
this.bookmarks = this.bookmarks.filter(b => b.id !== bookmark.id);
|
||||||
|
await this.saveBookmarks();
|
||||||
|
this.#logger.logBookmarkRemoved(bookmark.url, bookmark.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
async saveBookmarks() {
|
||||||
|
try {
|
||||||
|
await this.#metaHandler.setBookmarks(this.bookmarks);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to save bookmarks:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openBookmark(bookmark: Bookmark) {
|
||||||
|
chrome.tabs.create({ url: bookmark.url });
|
||||||
|
}
|
||||||
|
|
||||||
|
getDomain(url: string): string {
|
||||||
|
try {
|
||||||
|
return new URL(url).hostname;
|
||||||
|
} catch {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,34 +3,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<a
|
<a class="tab" routerLink="/home/identity" routerLinkActive="active" title="You">
|
||||||
class="tab"
|
<span class="emoji">👤</span>
|
||||||
routerLink="/home/identity"
|
|
||||||
routerLinkActive="active"
|
|
||||||
title="Your selected identity"
|
|
||||||
>
|
|
||||||
<i class="bi bi-person-circle"></i>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a class="tab" routerLink="/home/identities" routerLinkActive="active" title="Identities">
|
||||||
class="tab"
|
<span class="emoji">👥</span>
|
||||||
routerLink="/home/identities"
|
|
||||||
routerLinkActive="active"
|
|
||||||
title="Identities"
|
|
||||||
>
|
|
||||||
<i class="bi bi-people-fill"></i>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a class="tab" routerLink="/home/wallet" routerLinkActive="active" title="Wallet">
|
||||||
class="tab"
|
<span class="emoji">💰</span>
|
||||||
routerLink="/home/settings"
|
|
||||||
routerLinkActive="active"
|
|
||||||
title="Settings"
|
|
||||||
>
|
|
||||||
<i class="bi bi-gear"></i>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="tab" routerLink="/home/info" routerLinkActive="active" title="Info">
|
<a class="tab" routerLink="/home/bookmarks" routerLinkActive="active" title="Bookmarks">
|
||||||
<i class="bi bi-info-circle"></i>
|
<span class="emoji">🔖</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a class="tab" routerLink="/home/settings" routerLinkActive="active" title="Settings">
|
||||||
|
<span class="emoji">⚙️</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,17 +4,17 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.tab-content {
|
.tab-content {
|
||||||
height: calc(100% - 60px);
|
height: calc(100% - 48px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
height: 60px;
|
height: 48px;
|
||||||
min-height: 60px;
|
min-height: 48px;
|
||||||
background: var(--background-light);
|
background: var(--background-light);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
||||||
a {
|
a, button {
|
||||||
all: unset;
|
all: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,14 +23,17 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 24px;
|
|
||||||
|
|
||||||
color: var(--muted-foreground);
|
color: var(--muted-foreground);
|
||||||
border-top: 3px solid transparent;
|
border-top: 2px solid transparent;
|
||||||
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
|
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--background-light-hover);
|
background: var(--background-light-hover);
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
@@ -38,7 +41,7 @@
|
|||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
border-top: 3px solid var(--primary);
|
border-top: 2px solid var(--primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
||||||
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
||||||
<div class="custom-header" style="position: sticky; top: 0">
|
<div class="custom-header" style="position: sticky; top: 0">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span class="text">Identities</span>
|
<span class="text">Identities</span>
|
||||||
|
|
||||||
<button class="button btn btn-primary btn-sm" (click)="onClickNewIdentity()">
|
<button class="add-btn" title="New Identity" (click)="onClickNewIdentity()">
|
||||||
<div class="sam-flex-row gap-h">
|
<span class="emoji">➕</span>
|
||||||
<i class="bi bi-plus-lg"></i>
|
|
||||||
<span>New</span>
|
|
||||||
</div>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
title="Manage whitelisted apps"
|
title="Manage whitelisted apps"
|
||||||
(click)="onClickWhitelistedApps()"
|
(click)="onClickWhitelistedApps()"
|
||||||
>
|
>
|
||||||
<i class="bi bi-gear"></i>
|
<span class="emoji">⚙️</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
/>
|
/>
|
||||||
<span class="name">{{ getDisplayName(identity) }}</span>
|
<span class="name">{{ getDisplayName(identity) }}</span>
|
||||||
<lib-icon-button
|
<lib-icon-button
|
||||||
icon="gear"
|
icon="⚙️"
|
||||||
title="Identity settings"
|
title="Identity settings"
|
||||||
(click)="onClickEditIdentity(identity.id, $event)"
|
(click)="onClickEditIdentity(identity.id, $event)"
|
||||||
></lib-icon-button>
|
></lib-icon-button>
|
||||||
|
|||||||
@@ -3,37 +3,58 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: var(--size);
|
|
||||||
padding-right: var(--size);
|
> *:not(.custom-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
.custom-header {
|
.custom-header {
|
||||||
padding-top: var(--size);
|
height: 48px;
|
||||||
padding-bottom: var(--size);
|
min-height: 48px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
grid-template-rows: auto;
|
grid-template-rows: auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.button {
|
.lock-btn,
|
||||||
grid-column-start: 1;
|
.add-btn {
|
||||||
grid-column-end: 2;
|
position: absolute;
|
||||||
grid-row-start: 1;
|
background: transparent;
|
||||||
grid-row-end: 2;
|
border: none;
|
||||||
justify-self: end;
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--background-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.lock-btn {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-btn {
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
grid-column-start: 1;
|
|
||||||
grid-column-end: 2;
|
|
||||||
grid-row-start: 1;
|
|
||||||
grid-row-end: 2;
|
|
||||||
font-family: var(--font-heading);
|
font-family: var(--font-heading);
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.1rem;
|
letter-spacing: 0.1rem;
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
height: 32px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Router } from '@angular/router';
|
|||||||
import {
|
import {
|
||||||
IconButtonComponent,
|
IconButtonComponent,
|
||||||
Identity_DECRYPTED,
|
Identity_DECRYPTED,
|
||||||
|
LoggerService,
|
||||||
NostrHelper,
|
NostrHelper,
|
||||||
ProfileMetadata,
|
ProfileMetadata,
|
||||||
ProfileMetadataService,
|
ProfileMetadataService,
|
||||||
@@ -20,6 +21,7 @@ export class IdentitiesComponent implements OnInit {
|
|||||||
readonly storage = inject(StorageService);
|
readonly storage = inject(StorageService);
|
||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #profileMetadata = inject(ProfileMetadataService);
|
readonly #profileMetadata = inject(ProfileMetadataService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
// Cache of pubkey -> profile for quick lookup
|
// Cache of pubkey -> profile for quick lookup
|
||||||
#profileCache = new Map<string, ProfileMetadata | null>();
|
#profileCache = new Map<string, ProfileMetadata | null>();
|
||||||
@@ -73,4 +75,10 @@ export class IdentitiesComponent implements OnInit {
|
|||||||
onClickWhitelistedApps() {
|
onClickWhitelistedApps() {
|
||||||
this.#router.navigateByUrl('/whitelisted-apps');
|
this.#router.navigateByUrl('/whitelisted-apps');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
||||||
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
||||||
<div class="sam-text-header">
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span>You</span>
|
<span>You</span>
|
||||||
<button class="edit-btn" title="Edit profile" (click)="onClickEditProfile()">
|
<button class="edit-btn" title="Edit profile" (click)="onClickEditProfile()">
|
||||||
<img src="edit.svg" alt="Edit" class="edit-icon" />
|
<span class="emoji">📝</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,12 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.sam-text-header {
|
.sam-text-header {
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.edit-btn {
|
.edit-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: var(--size);
|
right: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 4px;
|
padding: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -23,10 +21,8 @@
|
|||||||
background-color: var(--background-light);
|
background-color: var(--background-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-icon {
|
.emoji {
|
||||||
width: 20px;
|
font-size: 20px;
|
||||||
height: 20px;
|
|
||||||
filter: brightness(0) invert(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component, inject, OnInit } from '@angular/core';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
Identity_DECRYPTED,
|
Identity_DECRYPTED,
|
||||||
|
LoggerService,
|
||||||
NostrHelper,
|
NostrHelper,
|
||||||
ProfileMetadata,
|
ProfileMetadata,
|
||||||
ProfileMetadataService,
|
ProfileMetadataService,
|
||||||
@@ -29,6 +30,7 @@ export class IdentityComponent implements OnInit {
|
|||||||
readonly #storage = inject(StorageService);
|
readonly #storage = inject(StorageService);
|
||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #profileMetadata = inject(ProfileMetadataService);
|
readonly #profileMetadata = inject(ProfileMetadataService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.#loadData();
|
this.#loadData();
|
||||||
@@ -74,6 +76,12 @@ export class IdentityComponent implements OnInit {
|
|||||||
this.#router.navigateByUrl('/profile-edit');
|
this.#router.navigateByUrl('/profile-edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
|
||||||
async #loadData() {
|
async #loadData() {
|
||||||
try {
|
try {
|
||||||
const selectedIdentityId =
|
const selectedIdentityId =
|
||||||
@@ -136,13 +144,16 @@ export class IdentityComponent implements OnInit {
|
|||||||
const result = await validateNip05(nip05, pubkey);
|
const result = await validateNip05(nip05, pubkey);
|
||||||
this.nip05isValidated = result.valid;
|
this.nip05isValidated = result.valid;
|
||||||
|
|
||||||
if (!result.valid) {
|
if (result.valid) {
|
||||||
console.log('NIP-05 validation failed:', result.error);
|
this.#logger.logNip05ValidationSuccess(nip05, pubkey);
|
||||||
|
} else {
|
||||||
|
this.#logger.logNip05ValidationError(nip05, result.error ?? 'Unknown error');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.validating = false;
|
this.validating = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('NIP-05 validation failed:', error);
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
this.#logger.logNip05ValidationError(nip05, errorMsg);
|
||||||
this.nip05isValidated = false;
|
this.nip05isValidated = false;
|
||||||
this.validating = false;
|
this.validating = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<div class="sam-text-header">
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span> Plebeian Signer </span>
|
<span> Plebeian Signer </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,13 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: var(--size);
|
|
||||||
padding-right: var(--size);
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { LoggerService, StorageService } from '@common';
|
||||||
import packageJson from '../../../../../../../package.json';
|
import packageJson from '../../../../../../../package.json';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -7,5 +9,15 @@ import packageJson from '../../../../../../../package.json';
|
|||||||
styleUrl: './info.component.scss',
|
styleUrl: './info.component.scss',
|
||||||
})
|
})
|
||||||
export class InfoComponent {
|
export class InfoComponent {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
version = packageJson.custom.chrome.version;
|
version = packageJson.custom.chrome.version;
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
|
<span>Logs</span>
|
||||||
|
<div class="logs-actions">
|
||||||
|
<button class="btn btn-sm btn-secondary" title="Refresh logs" (click)="onRefresh()">Refresh</button>
|
||||||
|
<button class="btn btn-sm btn-secondary" title="Clear logs" (click)="onClear()">Clear</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="logs-container">
|
||||||
|
@if (logs.length === 0) {
|
||||||
|
<div class="logs-empty">No activity logged yet</div>
|
||||||
|
}
|
||||||
|
@for (log of logs; track log.timestamp) {
|
||||||
|
<div class="log-entry" [class]="getLevelClass(log.level)">
|
||||||
|
<span class="log-icon emoji">{{ log.icon }}</span>
|
||||||
|
<span class="log-time">{{ log.timestamp | date:'HH:mm:ss' }}</span>
|
||||||
|
<span class="log-message">{{ log.message }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: var(--size);
|
||||||
|
padding-bottom: var(--size);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.logs-actions {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: var(--background-light);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: var(--size-h);
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-empty {
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
text-align: center;
|
||||||
|
padding: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry {
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&.log-error {
|
||||||
|
background: rgba(220, 53, 69, 0.15);
|
||||||
|
color: #ff6b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.log-warn {
|
||||||
|
background: rgba(255, 193, 7, 0.15);
|
||||||
|
color: #ffc107;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.log-debug {
|
||||||
|
background: rgba(108, 117, 125, 0.15);
|
||||||
|
color: #adb5bd;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.log-info {
|
||||||
|
background: rgba(13, 110, 253, 0.1);
|
||||||
|
color: var(--foreground);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-icon {
|
||||||
|
font-size: 14px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-time {
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-message {
|
||||||
|
flex: 1;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { LoggerService, LogEntry, StorageService } from '@common';
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-logs',
|
||||||
|
templateUrl: './logs.component.html',
|
||||||
|
styleUrl: './logs.component.scss',
|
||||||
|
imports: [DatePipe],
|
||||||
|
})
|
||||||
|
export class LogsComponent implements OnInit {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
|
get logs(): LogEntry[] {
|
||||||
|
return this.#logger.logs;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
// Refresh logs from storage to get background script logs
|
||||||
|
this.#logger.refreshLogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onRefresh() {
|
||||||
|
await this.#logger.refreshLogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClear() {
|
||||||
|
await this.#logger.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
getLevelClass(level: LogEntry['level']): string {
|
||||||
|
switch (level) {
|
||||||
|
case 'error':
|
||||||
|
return 'log-error';
|
||||||
|
case 'warn':
|
||||||
|
return 'log-warn';
|
||||||
|
case 'debug':
|
||||||
|
return 'log-debug';
|
||||||
|
default:
|
||||||
|
return 'log-info';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<div class="sam-text-header">
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span> Settings </span>
|
<span> Settings </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -12,6 +15,9 @@
|
|||||||
Import Vault
|
Import Vault
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<lib-nav-item text="🪵 Logs" (click)="navigate('/home/logs')"></lib-nav-item>
|
||||||
|
<lib-nav-item text="💡 Info" (click)="navigate('/home/info')"></lib-nav-item>
|
||||||
|
|
||||||
<div class="sam-flex-grow"></div>
|
<div class="sam-flex-grow"></div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
row-gap: var(--size);
|
row-gap: var(--size);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: var(--size);
|
|
||||||
padding-right: var(--size);
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
.file-input {
|
.file-input {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
BrowserSyncData,
|
BrowserSyncData,
|
||||||
BrowserSyncFlow,
|
BrowserSyncFlow,
|
||||||
ConfirmComponent,
|
ConfirmComponent,
|
||||||
DateHelper,
|
DateHelper,
|
||||||
|
LoggerService,
|
||||||
NavComponent,
|
NavComponent,
|
||||||
|
NavItemComponent,
|
||||||
StartupService,
|
StartupService,
|
||||||
StorageService,
|
StorageService,
|
||||||
} from '@common';
|
} from '@common';
|
||||||
@@ -12,15 +15,17 @@ import { getNewStorageServiceConfig } from '../../../common/data/get-new-storage
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
imports: [ConfirmComponent],
|
imports: [ConfirmComponent, NavItemComponent],
|
||||||
templateUrl: './settings.component.html',
|
templateUrl: './settings.component.html',
|
||||||
styleUrl: './settings.component.scss',
|
styleUrl: './settings.component.scss',
|
||||||
})
|
})
|
||||||
export class SettingsComponent extends NavComponent implements OnInit {
|
export class SettingsComponent extends NavComponent implements OnInit {
|
||||||
|
readonly #router = inject(Router);
|
||||||
syncFlow: string | undefined;
|
syncFlow: string | undefined;
|
||||||
|
|
||||||
readonly #storage = inject(StorageService);
|
readonly #storage = inject(StorageService);
|
||||||
readonly #startup = inject(StartupService);
|
readonly #startup = inject(StartupService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const vault = JSON.stringify(
|
const vault = JSON.stringify(
|
||||||
@@ -44,6 +49,7 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
|
|
||||||
async onResetExtension() {
|
async onResetExtension() {
|
||||||
try {
|
try {
|
||||||
|
this.#logger.logVaultReset();
|
||||||
await this.#storage.resetExtension();
|
await this.#storage.resetExtension();
|
||||||
this.#startup.startOver(getNewStorageServiceConfig());
|
this.#startup.startOver(getNewStorageServiceConfig());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -69,6 +75,7 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
|
|
||||||
await this.#storage.deleteVault(true);
|
await this.#storage.deleteVault(true);
|
||||||
await this.#storage.importVault(vault);
|
await this.#storage.importVault(vault);
|
||||||
|
this.#logger.logVaultImport(file.name);
|
||||||
this.#storage.isInitialized = false;
|
this.#storage.isInitialized = false;
|
||||||
this.#startup.startOver(getNewStorageServiceConfig());
|
this.#startup.startOver(getNewStorageServiceConfig());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -84,6 +91,7 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
const fileName = `Plebeian Signer Chrome - Vault Export - ${dateTimeString}.json`;
|
const fileName = `Plebeian Signer Chrome - Vault Export - ${dateTimeString}.json`;
|
||||||
|
|
||||||
this.#downloadJson(jsonVault, fileName);
|
this.#downloadJson(jsonVault, fileName);
|
||||||
|
this.#logger.logVaultExport(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#downloadJson(jsonString: string, fileName: string) {
|
#downloadJson(jsonString: string, fileName: string) {
|
||||||
@@ -96,4 +104,10 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
downloadAnchorNode.click();
|
downloadAnchorNode.click();
|
||||||
downloadAnchorNode.remove();
|
downloadAnchorNode.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
|
<span>Wallet</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wallet-container">
|
||||||
|
<div class="empty-state">
|
||||||
|
<span class="sam-text-muted">
|
||||||
|
Wallet functionality coming soon.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: var(--size);
|
||||||
|
padding-bottom: var(--size);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { LoggerService, StorageService } from '@common';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-wallet',
|
||||||
|
templateUrl: './wallet.component.html',
|
||||||
|
styleUrl: './wallet.component.scss',
|
||||||
|
imports: [],
|
||||||
|
})
|
||||||
|
export class WalletComponent {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Component, inject, ViewChild } from '@angular/core';
|
import { Component, inject, ViewChild } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { NavComponent, StorageService, DerivingModalComponent } from '@common';
|
import { LoggerService, NavComponent, StorageService, DerivingModalComponent } from '@common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new',
|
selector: 'app-new',
|
||||||
@@ -16,6 +16,7 @@ export class NewComponent extends NavComponent {
|
|||||||
|
|
||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #storage = inject(StorageService);
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
toggleType(element: HTMLInputElement) {
|
toggleType(element: HTMLInputElement) {
|
||||||
if (element.type === 'password') {
|
if (element.type === 'password') {
|
||||||
@@ -35,6 +36,7 @@ export class NewComponent extends NavComponent {
|
|||||||
try {
|
try {
|
||||||
await this.#storage.createNewVault(this.password);
|
await this.#storage.createNewVault(this.password);
|
||||||
this.derivingModal.hide();
|
this.derivingModal.hide();
|
||||||
|
this.#logger.logVaultCreated();
|
||||||
this.#router.navigateByUrl('/home/identities');
|
this.#router.navigateByUrl('/home/identities');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.derivingModal.hide();
|
this.derivingModal.hide();
|
||||||
|
|||||||
@@ -43,23 +43,22 @@
|
|||||||
<span>Sign in</span>
|
<span>Sign in</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
|
||||||
class="sam-mt"
|
|
||||||
(click)="
|
|
||||||
confirm.show(
|
|
||||||
'Do you really want to reset the extension? All data will be lost.',
|
|
||||||
onClickResetExtension.bind(this)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
type="button"
|
|
||||||
class="btn btn-link"
|
|
||||||
>
|
|
||||||
Reset Extension
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="reset-btn"
|
||||||
|
(click)="
|
||||||
|
confirm.show(
|
||||||
|
'Do you really want to reset the extension? All data will be lost.',
|
||||||
|
onClickResetExtension.bind(this)
|
||||||
|
)
|
||||||
|
"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Reset Extension
|
||||||
|
</button>
|
||||||
|
|
||||||
<!----------->
|
<!----------->
|
||||||
<!-- ALERT -->
|
<!-- ALERT -->
|
||||||
<!----------->
|
<!----------->
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.logo-frame {
|
.logo-frame {
|
||||||
border: 2px solid var(--secondary);
|
border: 2px solid var(--secondary);
|
||||||
@@ -16,4 +17,21 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0 var(--size) var(--size) var(--size);
|
padding: 0 var(--size) var(--size) var(--size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reset-btn {
|
||||||
|
position: absolute;
|
||||||
|
bottom: var(--size);
|
||||||
|
right: var(--size);
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px 8px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--foreground);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
|
|||||||
import {
|
import {
|
||||||
ConfirmComponent,
|
ConfirmComponent,
|
||||||
DerivingModalComponent,
|
DerivingModalComponent,
|
||||||
|
LoggerService,
|
||||||
NostrHelper,
|
NostrHelper,
|
||||||
ProfileMetadataService,
|
ProfileMetadataService,
|
||||||
StartupService,
|
StartupService,
|
||||||
@@ -28,6 +29,7 @@ export class VaultLoginComponent implements AfterViewInit {
|
|||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #startup = inject(StartupService);
|
readonly #startup = inject(StartupService);
|
||||||
readonly #profileMetadata = inject(ProfileMetadataService);
|
readonly #profileMetadata = inject(ProfileMetadataService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.passwordInput.nativeElement.focus();
|
this.passwordInput.nativeElement.focus();
|
||||||
@@ -69,6 +71,7 @@ export class VaultLoginComponent implements AfterViewInit {
|
|||||||
// Unlock succeeded - hide modal and navigate
|
// Unlock succeeded - hide modal and navigate
|
||||||
console.log('[login] Hiding modal and navigating');
|
console.log('[login] Hiding modal and navigating');
|
||||||
this.derivingModal.hide();
|
this.derivingModal.hide();
|
||||||
|
this.#logger.logVaultUnlock();
|
||||||
|
|
||||||
// Fetch profile metadata for all identities in the background
|
// Fetch profile metadata for all identities in the background
|
||||||
this.#fetchAllProfiles();
|
this.#fetchAllProfiles();
|
||||||
@@ -102,6 +105,7 @@ export class VaultLoginComponent implements AfterViewInit {
|
|||||||
|
|
||||||
async onClickResetExtension() {
|
async onClickResetExtension() {
|
||||||
try {
|
try {
|
||||||
|
this.#logger.logVaultReset();
|
||||||
await this.#storage.resetExtension();
|
await this.#storage.resetExtension();
|
||||||
this.#startup.startOver(getNewStorageServiceConfig());
|
this.#startup.startOver(getNewStorageServiceConfig());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from '@common';
|
} from '@common';
|
||||||
import { ChromeMetaHandler } from './app/common/data/chrome-meta-handler';
|
import { ChromeMetaHandler } from './app/common/data/chrome-meta-handler';
|
||||||
import { Event, EventTemplate, finalizeEvent, nip04, nip44 } from 'nostr-tools';
|
import { Event, EventTemplate, finalizeEvent, nip04, nip44 } from 'nostr-tools';
|
||||||
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
export const debug = function (message: any) {
|
export const debug = function (message: any) {
|
||||||
const dateString = new Date().toISOString();
|
const dateString = new Date().toISOString();
|
||||||
@@ -66,6 +67,8 @@ export const shouldRecklessModeApprove = async function (
|
|||||||
host: string
|
host: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const signerMetaData = await getSignerMetaData();
|
const signerMetaData = await getSignerMetaData();
|
||||||
|
debug(`shouldRecklessModeApprove: recklessMode=${signerMetaData.recklessMode}, host=${host}`);
|
||||||
|
debug(`Full signerMetaData: ${JSON.stringify(signerMetaData)}`);
|
||||||
|
|
||||||
if (!signerMetaData.recklessMode) {
|
if (!signerMetaData.recklessMode) {
|
||||||
return false;
|
return false;
|
||||||
@@ -223,8 +226,7 @@ export const storePermission = async function (
|
|||||||
// Encrypt permission to store in sync storage (depending on sync flow).
|
// Encrypt permission to store in sync storage (depending on sync flow).
|
||||||
const encryptedPermission = await encryptPermission(
|
const encryptedPermission = await encryptPermission(
|
||||||
permission,
|
permission,
|
||||||
browserSessionData.iv,
|
browserSessionData
|
||||||
browserSessionData.vaultPassword as string
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await savePermissionsToBrowserSyncStorage([
|
await savePermissionsToBrowserSyncStorage([
|
||||||
@@ -321,22 +323,20 @@ export const nip44Decrypt = async function (
|
|||||||
|
|
||||||
const encryptPermission = async function (
|
const encryptPermission = async function (
|
||||||
permission: Permission_DECRYPTED,
|
permission: Permission_DECRYPTED,
|
||||||
iv: string,
|
sessionData: BrowserSessionData
|
||||||
password: string
|
|
||||||
): Promise<Permission_ENCRYPTED> {
|
): Promise<Permission_ENCRYPTED> {
|
||||||
const encryptedPermission: Permission_ENCRYPTED = {
|
const encryptedPermission: Permission_ENCRYPTED = {
|
||||||
id: await encrypt(permission.id, iv, password),
|
id: await encrypt(permission.id, sessionData),
|
||||||
identityId: await encrypt(permission.identityId, iv, password),
|
identityId: await encrypt(permission.identityId, sessionData),
|
||||||
host: await encrypt(permission.host, iv, password),
|
host: await encrypt(permission.host, sessionData),
|
||||||
method: await encrypt(permission.method, iv, password),
|
method: await encrypt(permission.method, sessionData),
|
||||||
methodPolicy: await encrypt(permission.methodPolicy, iv, password),
|
methodPolicy: await encrypt(permission.methodPolicy, sessionData),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof permission.kind !== 'undefined') {
|
if (typeof permission.kind !== 'undefined') {
|
||||||
encryptedPermission.kind = await encrypt(
|
encryptedPermission.kind = await encrypt(
|
||||||
permission.kind.toString(),
|
permission.kind.toString(),
|
||||||
iv,
|
sessionData
|
||||||
password
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +345,30 @@ const encryptPermission = async function (
|
|||||||
|
|
||||||
const encrypt = async function (
|
const encrypt = async function (
|
||||||
value: string,
|
value: string,
|
||||||
iv: string,
|
sessionData: BrowserSessionData
|
||||||
password: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return await CryptoHelper.encrypt(value, iv, password);
|
// v2: Use pre-derived key with AES-GCM directly
|
||||||
|
if (sessionData.vaultKey) {
|
||||||
|
const keyBytes = Buffer.from(sessionData.vaultKey, 'base64');
|
||||||
|
const iv = Buffer.from(sessionData.iv, 'base64');
|
||||||
|
|
||||||
|
const key = await crypto.subtle.importKey(
|
||||||
|
'raw',
|
||||||
|
keyBytes,
|
||||||
|
{ name: 'AES-GCM' },
|
||||||
|
false,
|
||||||
|
['encrypt']
|
||||||
|
);
|
||||||
|
|
||||||
|
const cipherText = await crypto.subtle.encrypt(
|
||||||
|
{ name: 'AES-GCM', iv },
|
||||||
|
key,
|
||||||
|
new TextEncoder().encode(value)
|
||||||
|
);
|
||||||
|
|
||||||
|
return Buffer.from(cipherText).toString('base64');
|
||||||
|
}
|
||||||
|
|
||||||
|
// v1: Use password with PBKDF2
|
||||||
|
return await CryptoHelper.encrypt(value, sessionData.iv, sessionData.vaultPassword!);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { NostrHelper } from '@common';
|
import {
|
||||||
|
backgroundLogNip07Action,
|
||||||
|
backgroundLogPermissionStored,
|
||||||
|
NostrHelper,
|
||||||
|
} from '@common';
|
||||||
import {
|
import {
|
||||||
BackgroundRequestMessage,
|
BackgroundRequestMessage,
|
||||||
checkPermissions,
|
checkPermissions,
|
||||||
@@ -67,6 +71,7 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
|
|
||||||
// Check reckless mode first
|
// Check reckless mode first
|
||||||
const recklessApprove = await shouldRecklessModeApprove(req.host);
|
const recklessApprove = await shouldRecklessModeApprove(req.host);
|
||||||
|
debug(`recklessApprove result: ${recklessApprove}`);
|
||||||
if (recklessApprove) {
|
if (recklessApprove) {
|
||||||
debug('Request auto-approved via reckless mode.');
|
debug('Request auto-approved via reckless mode.');
|
||||||
} else {
|
} else {
|
||||||
@@ -78,6 +83,7 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
req.method,
|
req.method,
|
||||||
req.params
|
req.params
|
||||||
);
|
);
|
||||||
|
debug(`permissionState result: ${permissionState}`);
|
||||||
|
|
||||||
if (permissionState === false) {
|
if (permissionState === false) {
|
||||||
throw new Error('Permission denied');
|
throw new Error('Permission denied');
|
||||||
@@ -107,17 +113,28 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
});
|
});
|
||||||
debug(response);
|
debug(response);
|
||||||
if (response === 'approve' || response === 'reject') {
|
if (response === 'approve' || response === 'reject') {
|
||||||
|
const policy = response === 'approve' ? 'allow' : 'deny';
|
||||||
await storePermission(
|
await storePermission(
|
||||||
browserSessionData,
|
browserSessionData,
|
||||||
currentIdentity,
|
currentIdentity,
|
||||||
req.host,
|
req.host,
|
||||||
req.method,
|
req.method,
|
||||||
response === 'approve' ? 'allow' : 'deny',
|
policy,
|
||||||
|
req.params?.kind
|
||||||
|
);
|
||||||
|
await backgroundLogPermissionStored(
|
||||||
|
req.host,
|
||||||
|
req.method,
|
||||||
|
policy,
|
||||||
req.params?.kind
|
req.params?.kind
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['reject', 'reject-once'].includes(response)) {
|
if (['reject', 'reject-once'].includes(response)) {
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, false, false, {
|
||||||
|
kind: req.params?.kind,
|
||||||
|
peerPubkey: req.params?.peerPubkey,
|
||||||
|
});
|
||||||
throw new Error('Permission denied');
|
throw new Error('Permission denied');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -126,46 +143,71 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const relays: Relays = {};
|
const relays: Relays = {};
|
||||||
|
let result: any;
|
||||||
|
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
case 'getPublicKey':
|
case 'getPublicKey':
|
||||||
return NostrHelper.pubkeyFromPrivkey(currentIdentity.privkey);
|
result = NostrHelper.pubkeyFromPrivkey(currentIdentity.privkey);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove);
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'signEvent':
|
case 'signEvent':
|
||||||
return signEvent(req.params, currentIdentity.privkey);
|
result = signEvent(req.params, currentIdentity.privkey);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
kind: req.params?.kind,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'getRelays':
|
case 'getRelays':
|
||||||
browserSessionData.relays.forEach((x) => {
|
browserSessionData.relays.forEach((x) => {
|
||||||
relays[x.url] = { read: x.read, write: x.write };
|
relays[x.url] = { read: x.read, write: x.write };
|
||||||
});
|
});
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove);
|
||||||
return relays;
|
return relays;
|
||||||
|
|
||||||
case 'nip04.encrypt':
|
case 'nip04.encrypt':
|
||||||
return await nip04Encrypt(
|
result = await nip04Encrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.plaintext
|
req.params.plaintext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'nip44.encrypt':
|
case 'nip44.encrypt':
|
||||||
return await nip44Encrypt(
|
result = await nip44Encrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.plaintext
|
req.params.plaintext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'nip04.decrypt':
|
case 'nip04.decrypt':
|
||||||
return await nip04Decrypt(
|
result = await nip04Decrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.ciphertext
|
req.params.ciphertext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'nip44.decrypt':
|
case 'nip44.decrypt':
|
||||||
return await nip44Decrypt(
|
result = await nip44Decrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.ciphertext
|
req.params.ciphertext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Not supported request method '${req.method}'.`);
|
throw new Error(`Not supported request method '${req.method}'.`);
|
||||||
|
|||||||
@@ -1,14 +1,32 @@
|
|||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
import { Buffer } from 'buffer';
|
|
||||||
import { Nip07Method } from '@common';
|
import { Nip07Method } from '@common';
|
||||||
import { PromptResponse, PromptResponseMessage } from './background-common';
|
import { PromptResponse, PromptResponseMessage } from './background-common';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode base64 string to UTF-8 using native browser APIs.
|
||||||
|
* This avoids race conditions with the Buffer polyfill initialization.
|
||||||
|
*/
|
||||||
|
function base64ToUtf8(base64: string): string {
|
||||||
|
const binaryString = atob(base64);
|
||||||
|
const bytes = Uint8Array.from(binaryString, char => char.charCodeAt(0));
|
||||||
|
return new TextDecoder('utf-8').decode(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
const id = params.get('id') as string;
|
const id = params.get('id') as string;
|
||||||
const method = params.get('method') as Nip07Method;
|
const method = params.get('method') as Nip07Method;
|
||||||
const host = params.get('host') as string;
|
const host = params.get('host') as string;
|
||||||
const nick = params.get('nick') as string;
|
const nick = params.get('nick') as string;
|
||||||
const event = Buffer.from(params.get('event') as string, 'base64').toString();
|
|
||||||
|
let event = '{}';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
let eventParsed: any = {};
|
||||||
|
try {
|
||||||
|
event = base64ToUtf8(params.get('event') as string);
|
||||||
|
eventParsed = JSON.parse(event);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to parse event:', e);
|
||||||
|
}
|
||||||
|
|
||||||
let title = '';
|
let title = '';
|
||||||
switch (method) {
|
switch (method) {
|
||||||
@@ -62,8 +80,8 @@ Array.from(document.getElementsByClassName('host-INSERT')).forEach(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const kindSpanElement = document.getElementById('kindSpan');
|
const kindSpanElement = document.getElementById('kindSpan');
|
||||||
if (kindSpanElement) {
|
if (kindSpanElement && eventParsed.kind !== undefined) {
|
||||||
kindSpanElement.innerText = JSON.parse(event).kind;
|
kindSpanElement.innerText = eventParsed.kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cardGetPublicKeyElement = document.getElementById('cardGetPublicKey');
|
const cardGetPublicKeyElement = document.getElementById('cardGetPublicKey');
|
||||||
@@ -108,9 +126,8 @@ if (cardNip04EncryptElement && card2Nip04EncryptElement) {
|
|||||||
'card2Nip04Encrypt_text'
|
'card2Nip04Encrypt_text'
|
||||||
);
|
);
|
||||||
if (card2Nip04Encrypt_textElement) {
|
if (card2Nip04Encrypt_textElement) {
|
||||||
const eventObject: { peerPubkey: string; plaintext: string } =
|
const eventObject = eventParsed as { peerPubkey: string; plaintext: string };
|
||||||
JSON.parse(event);
|
card2Nip04Encrypt_textElement.innerText = eventObject.plaintext || '';
|
||||||
card2Nip04Encrypt_textElement.innerText = eventObject.plaintext;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cardNip04EncryptElement.style.display = 'none';
|
cardNip04EncryptElement.style.display = 'none';
|
||||||
@@ -126,9 +143,8 @@ if (cardNip44EncryptElement && card2Nip44EncryptElement) {
|
|||||||
'card2Nip44Encrypt_text'
|
'card2Nip44Encrypt_text'
|
||||||
);
|
);
|
||||||
if (card2Nip44Encrypt_textElement) {
|
if (card2Nip44Encrypt_textElement) {
|
||||||
const eventObject: { peerPubkey: string; plaintext: string } =
|
const eventObject = eventParsed as { peerPubkey: string; plaintext: string };
|
||||||
JSON.parse(event);
|
card2Nip44Encrypt_textElement.innerText = eventObject.plaintext || '';
|
||||||
card2Nip44Encrypt_textElement.innerText = eventObject.plaintext;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cardNip44EncryptElement.style.display = 'none';
|
cardNip44EncryptElement.style.display = 'none';
|
||||||
@@ -143,9 +159,8 @@ if (cardNip04DecryptElement && card2Nip04DecryptElement) {
|
|||||||
'card2Nip04Decrypt_text'
|
'card2Nip04Decrypt_text'
|
||||||
);
|
);
|
||||||
if (card2Nip04Decrypt_textElement) {
|
if (card2Nip04Decrypt_textElement) {
|
||||||
const eventObject: { peerPubkey: string; ciphertext: string } =
|
const eventObject = eventParsed as { peerPubkey: string; ciphertext: string };
|
||||||
JSON.parse(event);
|
card2Nip04Decrypt_textElement.innerText = eventObject.ciphertext || '';
|
||||||
card2Nip04Decrypt_textElement.innerText = eventObject.ciphertext;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cardNip04DecryptElement.style.display = 'none';
|
cardNip04DecryptElement.style.display = 'none';
|
||||||
@@ -161,9 +176,8 @@ if (cardNip44DecryptElement && card2Nip44DecryptElement) {
|
|||||||
'card2Nip44Decrypt_text'
|
'card2Nip44Decrypt_text'
|
||||||
);
|
);
|
||||||
if (card2Nip44Decrypt_textElement) {
|
if (card2Nip44Decrypt_textElement) {
|
||||||
const eventObject: { peerPubkey: string; ciphertext: string } =
|
const eventObject = eventParsed as { peerPubkey: string; ciphertext: string };
|
||||||
JSON.parse(event);
|
card2Nip44Decrypt_textElement.innerText = eventObject.ciphertext || '';
|
||||||
card2Nip44Decrypt_textElement.innerText = eventObject.ciphertext;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cardNip44DecryptElement.style.display = 'none';
|
cardNip44DecryptElement.style.display = 'none';
|
||||||
@@ -175,36 +189,38 @@ if (cardNip44DecryptElement && card2Nip44DecryptElement) {
|
|||||||
// Functions
|
// Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
function deliver(response: PromptResponse) {
|
async function deliver(response: PromptResponse) {
|
||||||
const message: PromptResponseMessage = {
|
const message: PromptResponseMessage = {
|
||||||
id,
|
id,
|
||||||
response,
|
response,
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.runtime.sendMessage(message);
|
try {
|
||||||
|
await browser.runtime.sendMessage(message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to send message:', error);
|
||||||
|
}
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const rejectJustOnceButton = document.getElementById('rejectJustOnceButton');
|
const rejectOnceButton = document.getElementById('rejectOnceButton');
|
||||||
rejectJustOnceButton?.addEventListener('click', () => {
|
rejectOnceButton?.addEventListener('click', () => {
|
||||||
deliver('reject-once');
|
deliver('reject-once');
|
||||||
});
|
});
|
||||||
|
|
||||||
const rejectButton = document.getElementById('rejectButton');
|
const rejectAlwaysButton = document.getElementById('rejectAlwaysButton');
|
||||||
rejectButton?.addEventListener('click', () => {
|
rejectAlwaysButton?.addEventListener('click', () => {
|
||||||
deliver('reject');
|
deliver('reject');
|
||||||
});
|
});
|
||||||
|
|
||||||
const approveJustOnceButton = document.getElementById(
|
const approveOnceButton = document.getElementById('approveOnceButton');
|
||||||
'approveJustOnceButton'
|
approveOnceButton?.addEventListener('click', () => {
|
||||||
);
|
|
||||||
approveJustOnceButton?.addEventListener('click', () => {
|
|
||||||
deliver('approve-once');
|
deliver('approve-once');
|
||||||
});
|
});
|
||||||
|
|
||||||
const approveButton = document.getElementById('approveButton');
|
const approveAlwaysButton = document.getElementById('approveAlwaysButton');
|
||||||
approveButton?.addEventListener('click', () => {
|
approveAlwaysButton?.addEventListener('click', () => {
|
||||||
deliver('approve');
|
deliver('approve');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ body {
|
|||||||
background: var(--background);
|
background: var(--background);
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Button styling to match market
|
// Button styling to match market
|
||||||
@@ -128,3 +129,35 @@ button {
|
|||||||
.modal-body {
|
.modal-body {
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom scrollbar styling for Chrome
|
||||||
|
* {
|
||||||
|
// Thin scrollbar
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track - black background, transparent by default
|
||||||
|
&::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thumb - white, transparent by default
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show scrollbar on hover over scrollable area
|
||||||
|
&:hover::-webkit-scrollbar-track {
|
||||||
|
background: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(255, 255, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
<div class="deriving-modal">
|
<div class="deriving-modal">
|
||||||
<div class="deriving-spinner"></div>
|
<div class="deriving-spinner"></div>
|
||||||
<h3>{{ message }}</h3>
|
<h3>{{ message }}</h3>
|
||||||
<div class="deriving-timer">{{ elapsed.toFixed(1) }}s</div>
|
<p class="deriving-note">This may take a few seconds</p>
|
||||||
<p class="deriving-note">This may take 3-6 seconds for security</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,14 +30,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.deriving-timer {
|
|
||||||
font-size: 2.5rem;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #ff3eb5;
|
|
||||||
font-family: monospace;
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.deriving-note {
|
.deriving-note {
|
||||||
margin: 0.5rem 0 0;
|
margin: 0.5rem 0 0;
|
||||||
color: #a1a1a1;
|
color: #a1a1a1;
|
||||||
|
|||||||
@@ -1,23 +1,16 @@
|
|||||||
import {
|
import { Component } from '@angular/core';
|
||||||
Component,
|
|
||||||
OnDestroy,
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deriving-modal',
|
selector: 'app-deriving-modal',
|
||||||
templateUrl: './deriving-modal.component.html',
|
templateUrl: './deriving-modal.component.html',
|
||||||
styleUrl: './deriving-modal.component.scss',
|
styleUrl: './deriving-modal.component.scss',
|
||||||
})
|
})
|
||||||
export class DerivingModalComponent implements OnDestroy {
|
export class DerivingModalComponent {
|
||||||
visible = false;
|
visible = false;
|
||||||
elapsed = 0;
|
|
||||||
message = 'Deriving encryption key';
|
message = 'Deriving encryption key';
|
||||||
|
|
||||||
#startTime: number | null = null;
|
|
||||||
#animationFrame: number | null = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the deriving modal and start the timer
|
* Show the deriving modal
|
||||||
* @param message Optional custom message
|
* @param message Optional custom message
|
||||||
*/
|
*/
|
||||||
show(message?: string): void {
|
show(message?: string): void {
|
||||||
@@ -25,35 +18,12 @@ export class DerivingModalComponent implements OnDestroy {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.elapsed = 0;
|
|
||||||
this.#startTime = performance.now();
|
|
||||||
this.#updateTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide the modal and stop the timer
|
* Hide the modal
|
||||||
*/
|
*/
|
||||||
hide(): void {
|
hide(): void {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.#stopTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.#stopTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
#updateTimer(): void {
|
|
||||||
if (this.#startTime !== null) {
|
|
||||||
this.elapsed = (performance.now() - this.#startTime) / 1000;
|
|
||||||
this.#animationFrame = requestAnimationFrame(() => this.#updateTimer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#stopTimer(): void {
|
|
||||||
this.#startTime = null;
|
|
||||||
if (this.#animationFrame !== null) {
|
|
||||||
cancelAnimationFrame(this.#animationFrame);
|
|
||||||
this.#animationFrame = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
<div class="icon-button">
|
<div class="icon-button">
|
||||||
<i [class]="'bi bi-' + icon"></i>
|
@if (isEmoji) {
|
||||||
|
<span class="emoji">{{ icon }}</span>
|
||||||
|
} @else {
|
||||||
|
<i [class]="'bi bi-' + icon"></i>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,4 +9,9 @@ import { Component, Input } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class IconButtonComponent {
|
export class IconButtonComponent {
|
||||||
@Input({ required: true }) icon!: string;
|
@Input({ required: true }) icon!: string;
|
||||||
|
|
||||||
|
get isEmoji(): boolean {
|
||||||
|
// Check if the icon is an emoji (starts with a non-ASCII character)
|
||||||
|
return this.icon.length > 0 && this.icon.charCodeAt(0) > 255;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1756
projects/common/src/lib/constants/event-kinds.ts
Normal file
@@ -1,22 +1,424 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
declare const chrome: any;
|
||||||
|
|
||||||
|
export type LogCategory =
|
||||||
|
| 'nip07'
|
||||||
|
| 'permission'
|
||||||
|
| 'vault'
|
||||||
|
| 'profile'
|
||||||
|
| 'bookmark'
|
||||||
|
| 'system';
|
||||||
|
|
||||||
|
export interface LogEntry {
|
||||||
|
timestamp: Date;
|
||||||
|
level: 'log' | 'warn' | 'error' | 'debug';
|
||||||
|
category: LogCategory;
|
||||||
|
icon: string;
|
||||||
|
message: string;
|
||||||
|
data?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serializable format for storage
|
||||||
|
interface StoredLogEntry {
|
||||||
|
timestamp: string;
|
||||||
|
level: 'log' | 'warn' | 'error' | 'debug';
|
||||||
|
category: LogCategory;
|
||||||
|
icon: string;
|
||||||
|
message: string;
|
||||||
|
data?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LOGS_STORAGE_KEY = 'extensionLogs';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class LoggerService {
|
export class LoggerService {
|
||||||
#namespace: string | undefined;
|
#namespace: string | undefined;
|
||||||
|
#logs: LogEntry[] = [];
|
||||||
|
#maxLogs = 500;
|
||||||
|
|
||||||
initialize(namespace: string): void {
|
get logs(): LogEntry[] {
|
||||||
this.#namespace = namespace;
|
return this.#logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(value: any) {
|
async initialize(namespace: string): Promise<void> {
|
||||||
|
this.#namespace = namespace;
|
||||||
|
await this.#loadLogsFromStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
async #loadLogsFromStorage(): Promise<void> {
|
||||||
|
try {
|
||||||
|
if (typeof chrome !== 'undefined' && chrome.storage?.session) {
|
||||||
|
const result = await chrome.storage.session.get(LOGS_STORAGE_KEY);
|
||||||
|
if (result[LOGS_STORAGE_KEY]) {
|
||||||
|
// Convert stored format back to LogEntry with Date objects
|
||||||
|
this.#logs = (result[LOGS_STORAGE_KEY] as StoredLogEntry[]).map(
|
||||||
|
(entry) => ({
|
||||||
|
...entry,
|
||||||
|
timestamp: new Date(entry.timestamp),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load logs from storage:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async #saveLogsToStorage(): Promise<void> {
|
||||||
|
try {
|
||||||
|
if (typeof chrome !== 'undefined' && chrome.storage?.session) {
|
||||||
|
// Convert Date to ISO string for storage
|
||||||
|
const storedLogs: StoredLogEntry[] = this.#logs.map((entry) => ({
|
||||||
|
...entry,
|
||||||
|
timestamp: entry.timestamp.toISOString(),
|
||||||
|
}));
|
||||||
|
await chrome.storage.session.set({ [LOGS_STORAGE_KEY]: storedLogs });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to save logs to storage:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async refreshLogs(): Promise<void> {
|
||||||
|
await this.#loadLogsFromStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Generic logging methods
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
log(value: any, data?: any) {
|
||||||
this.#assureInitialized();
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'system', '📝', value, data);
|
||||||
|
this.#consoleLog('log', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
warn(value: any, data?: any) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('warn', 'system', '⚠️', value, data);
|
||||||
|
this.#consoleLog('warn', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
error(value: any, data?: any) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('error', 'system', '❌', value, data);
|
||||||
|
this.#consoleLog('error', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug(value: any, data?: any) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('debug', 'system', '🔍', value, data);
|
||||||
|
this.#consoleLog('debug', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// NIP-07 Action Logging
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
logNip07Action(
|
||||||
|
method: string,
|
||||||
|
host: string,
|
||||||
|
approved: boolean,
|
||||||
|
autoApproved: boolean,
|
||||||
|
details?: { kind?: number; peerPubkey?: string }
|
||||||
|
) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
const approvalType = autoApproved ? 'auto-approved' : approved ? 'approved' : 'denied';
|
||||||
|
const icon = approved ? '✅' : '🚫';
|
||||||
|
|
||||||
|
let message = `${method} from ${host} - ${approvalType}`;
|
||||||
|
if (details?.kind !== undefined) {
|
||||||
|
message += ` (kind: ${details.kind})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#addLog('log', 'nip07', icon, message, {
|
||||||
|
method,
|
||||||
|
host,
|
||||||
|
approved,
|
||||||
|
autoApproved,
|
||||||
|
...details,
|
||||||
|
});
|
||||||
|
this.#consoleLog('log', message);
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip07GetPublicKey(host: string, approved: boolean, autoApproved: boolean) {
|
||||||
|
this.logNip07Action('getPublicKey', host, approved, autoApproved);
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip07SignEvent(
|
||||||
|
host: string,
|
||||||
|
kind: number,
|
||||||
|
approved: boolean,
|
||||||
|
autoApproved: boolean
|
||||||
|
) {
|
||||||
|
this.logNip07Action('signEvent', host, approved, autoApproved, { kind });
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip07Encrypt(
|
||||||
|
method: 'nip04.encrypt' | 'nip44.encrypt',
|
||||||
|
host: string,
|
||||||
|
approved: boolean,
|
||||||
|
autoApproved: boolean,
|
||||||
|
peerPubkey?: string
|
||||||
|
) {
|
||||||
|
this.logNip07Action(method, host, approved, autoApproved, { peerPubkey });
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip07Decrypt(
|
||||||
|
method: 'nip04.decrypt' | 'nip44.decrypt',
|
||||||
|
host: string,
|
||||||
|
approved: boolean,
|
||||||
|
autoApproved: boolean,
|
||||||
|
peerPubkey?: string
|
||||||
|
) {
|
||||||
|
this.logNip07Action(method, host, approved, autoApproved, { peerPubkey });
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip07GetRelays(host: string, approved: boolean, autoApproved: boolean) {
|
||||||
|
this.logNip07Action('getRelays', host, approved, autoApproved);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Permission Logging
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
logPermissionStored(
|
||||||
|
host: string,
|
||||||
|
method: string,
|
||||||
|
policy: string,
|
||||||
|
kind?: number
|
||||||
|
) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
const icon = policy === 'allow' ? '🔓' : '🔒';
|
||||||
|
let message = `Permission stored: ${method} for ${host} - ${policy}`;
|
||||||
|
if (kind !== undefined) {
|
||||||
|
message += ` (kind: ${kind})`;
|
||||||
|
}
|
||||||
|
this.#addLog('log', 'permission', icon, message, { host, method, policy, kind });
|
||||||
|
this.#consoleLog('log', message);
|
||||||
|
}
|
||||||
|
|
||||||
|
logPermissionDeleted(host: string, method: string, kind?: number) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
let message = `Permission deleted: ${method} for ${host}`;
|
||||||
|
if (kind !== undefined) {
|
||||||
|
message += ` (kind: ${kind})`;
|
||||||
|
}
|
||||||
|
this.#addLog('log', 'permission', '🗑️', message, { host, method, kind });
|
||||||
|
this.#consoleLog('log', message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Vault Operations Logging
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
logVaultUnlock() {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'vault', '🔓', 'Vault unlocked', undefined);
|
||||||
|
this.#consoleLog('log', 'Vault unlocked');
|
||||||
|
}
|
||||||
|
|
||||||
|
logVaultLock() {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'vault', '🔒', 'Vault locked', undefined);
|
||||||
|
this.#consoleLog('log', 'Vault locked');
|
||||||
|
}
|
||||||
|
|
||||||
|
logVaultCreated() {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'vault', '🆕', 'Vault created', undefined);
|
||||||
|
this.#consoleLog('log', 'Vault created');
|
||||||
|
}
|
||||||
|
|
||||||
|
logVaultExport(fileName: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'vault', '📤', `Vault exported: ${fileName}`, { fileName });
|
||||||
|
this.#consoleLog('log', `Vault exported: ${fileName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logVaultImport(fileName: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'vault', '📥', `Vault imported: ${fileName}`, { fileName });
|
||||||
|
this.#consoleLog('log', `Vault imported: ${fileName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logVaultReset() {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('warn', 'vault', '🗑️', 'Extension reset', undefined);
|
||||||
|
this.#consoleLog('warn', 'Extension reset');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Profile Operations Logging
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
logProfileFetchError(pubkey: string, error: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
const shortPubkey = pubkey.substring(0, 8) + '...';
|
||||||
|
this.#addLog('error', 'profile', '👤', `Failed to fetch profile for ${shortPubkey}: ${error}`, {
|
||||||
|
pubkey,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
this.#consoleLog('error', `Failed to fetch profile for ${shortPubkey}: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logProfileParseError(pubkey: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
const shortPubkey = pubkey.substring(0, 8) + '...';
|
||||||
|
this.#addLog('error', 'profile', '👤', `Failed to parse profile content for ${shortPubkey}`, {
|
||||||
|
pubkey,
|
||||||
|
});
|
||||||
|
this.#consoleLog('error', `Failed to parse profile content for ${shortPubkey}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip05ValidationError(nip05: string, error: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('error', 'profile', '🔗', `NIP-05 validation failed for ${nip05}: ${error}`, {
|
||||||
|
nip05,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
this.#consoleLog('error', `NIP-05 validation failed for ${nip05}: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logNip05ValidationSuccess(nip05: string, pubkey: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
const shortPubkey = pubkey.substring(0, 8) + '...';
|
||||||
|
this.#addLog('log', 'profile', '✓', `NIP-05 verified: ${nip05} → ${shortPubkey}`, {
|
||||||
|
nip05,
|
||||||
|
pubkey,
|
||||||
|
});
|
||||||
|
this.#consoleLog('log', `NIP-05 verified: ${nip05} → ${shortPubkey}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logProfileEdit(identityNick: string, field: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'profile', '✏️', `Profile edited: ${identityNick} - ${field}`, {
|
||||||
|
identityNick,
|
||||||
|
field,
|
||||||
|
});
|
||||||
|
this.#consoleLog('log', `Profile edited: ${identityNick} - ${field}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logIdentityCreated(nick: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'profile', '🆕', `Identity created: ${nick}`, { nick });
|
||||||
|
this.#consoleLog('log', `Identity created: ${nick}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logIdentityDeleted(nick: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('warn', 'profile', '🗑️', `Identity deleted: ${nick}`, { nick });
|
||||||
|
this.#consoleLog('warn', `Identity deleted: ${nick}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logIdentitySelected(nick: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'profile', '👆', `Identity selected: ${nick}`, { nick });
|
||||||
|
this.#consoleLog('log', `Identity selected: ${nick}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Bookmark Operations Logging
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
logBookmarkAdded(url: string, title: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'bookmark', '🔖', `Bookmark added: ${title}`, { url, title });
|
||||||
|
this.#consoleLog('log', `Bookmark added: ${title}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logBookmarkRemoved(url: string, title: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('log', 'bookmark', '🗑️', `Bookmark removed: ${title}`, { url, title });
|
||||||
|
this.#consoleLog('log', `Bookmark removed: ${title}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// System/Error Logging
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
logRelayFetchError(identityNick: string, error: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('error', 'system', '📡', `Failed to fetch relays for ${identityNick}: ${error}`, {
|
||||||
|
identityNick,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
this.#consoleLog('error', `Failed to fetch relays for ${identityNick}: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logStorageError(operation: string, error: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('error', 'system', '💾', `Storage error (${operation}): ${error}`, {
|
||||||
|
operation,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
this.#consoleLog('error', `Storage error (${operation}): ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logCryptoError(operation: string, error: string) {
|
||||||
|
this.#assureInitialized();
|
||||||
|
this.#addLog('error', 'system', '🔐', `Crypto error (${operation}): ${error}`, {
|
||||||
|
operation,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
this.#consoleLog('error', `Crypto error (${operation}): ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Internal methods
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
async clear(): Promise<void> {
|
||||||
|
this.#logs = [];
|
||||||
|
await this.#saveLogsToStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
#addLog(
|
||||||
|
level: LogEntry['level'],
|
||||||
|
category: LogCategory,
|
||||||
|
icon: string,
|
||||||
|
message: any,
|
||||||
|
data?: any
|
||||||
|
) {
|
||||||
|
const entry: LogEntry = {
|
||||||
|
timestamp: new Date(),
|
||||||
|
level,
|
||||||
|
category,
|
||||||
|
icon,
|
||||||
|
message: typeof message === 'string' ? message : JSON.stringify(message),
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
this.#logs.unshift(entry);
|
||||||
|
|
||||||
|
// Limit stored logs
|
||||||
|
if (this.#logs.length > this.#maxLogs) {
|
||||||
|
this.#logs.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save to storage asynchronously (don't block)
|
||||||
|
this.#saveLogsToStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
#consoleLog(level: 'log' | 'warn' | 'error' | 'debug', message: string) {
|
||||||
const nowString = new Date().toLocaleString();
|
const nowString = new Date().toLocaleString();
|
||||||
|
const formattedMsg = `[${this.#namespace} - ${nowString}] ${message}`;
|
||||||
console.log(`[${this.#namespace} - ${nowString}]`, JSON.stringify(value));
|
switch (level) {
|
||||||
|
case 'warn':
|
||||||
|
console.warn(formattedMsg);
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
console.error(formattedMsg);
|
||||||
|
break;
|
||||||
|
case 'debug':
|
||||||
|
console.debug(formattedMsg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log(formattedMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#assureInitialized() {
|
#assureInitialized() {
|
||||||
@@ -27,3 +429,87 @@ export class LoggerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Standalone functions for background script
|
||||||
|
// (Background script runs in different context without Angular DI)
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
export async function backgroundLog(
|
||||||
|
category: LogCategory,
|
||||||
|
icon: string,
|
||||||
|
level: LogEntry['level'],
|
||||||
|
message: string,
|
||||||
|
data?: any
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
if (typeof chrome === 'undefined' || !chrome.storage?.session) {
|
||||||
|
console.log(`[Background] ${message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await chrome.storage.session.get(LOGS_STORAGE_KEY);
|
||||||
|
const existingLogs: StoredLogEntry[] = result[LOGS_STORAGE_KEY] || [];
|
||||||
|
|
||||||
|
const newEntry: StoredLogEntry = {
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
level,
|
||||||
|
category,
|
||||||
|
icon,
|
||||||
|
message,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
|
||||||
|
const updatedLogs = [newEntry, ...existingLogs].slice(0, 500);
|
||||||
|
await chrome.storage.session.set({ [LOGS_STORAGE_KEY]: updatedLogs });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to add background log:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function backgroundLogNip07Action(
|
||||||
|
method: string,
|
||||||
|
host: string,
|
||||||
|
approved: boolean,
|
||||||
|
autoApproved: boolean,
|
||||||
|
details?: { kind?: number; peerPubkey?: string }
|
||||||
|
): Promise<void> {
|
||||||
|
const approvalType = autoApproved
|
||||||
|
? 'auto-approved'
|
||||||
|
: approved
|
||||||
|
? 'approved'
|
||||||
|
: 'denied';
|
||||||
|
const icon = approved ? '✅' : '🚫';
|
||||||
|
|
||||||
|
let message = `${method} from ${host} - ${approvalType}`;
|
||||||
|
if (details?.kind !== undefined) {
|
||||||
|
message += ` (kind: ${details.kind})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
await backgroundLog('nip07', icon, 'log', message, {
|
||||||
|
method,
|
||||||
|
host,
|
||||||
|
approved,
|
||||||
|
autoApproved,
|
||||||
|
...details,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function backgroundLogPermissionStored(
|
||||||
|
host: string,
|
||||||
|
method: string,
|
||||||
|
policy: string,
|
||||||
|
kind?: number
|
||||||
|
): Promise<void> {
|
||||||
|
const icon = policy === 'allow' ? '🔓' : '🔒';
|
||||||
|
let message = `Permission stored: ${method} for ${host} - ${policy}`;
|
||||||
|
if (kind !== undefined) {
|
||||||
|
message += ` (kind: ${kind})`;
|
||||||
|
}
|
||||||
|
await backgroundLog('permission', icon, 'log', message, {
|
||||||
|
host,
|
||||||
|
method,
|
||||||
|
policy,
|
||||||
|
kind,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { SimplePool } from 'nostr-tools/pool';
|
import { SimplePool } from 'nostr-tools/pool';
|
||||||
import { FALLBACK_PROFILE_RELAYS } from '../../constants/fallback-relays';
|
import { FALLBACK_PROFILE_RELAYS } from '../../constants/fallback-relays';
|
||||||
import { ProfileMetadata, ProfileMetadataCache } from '../storage/types';
|
import { ProfileMetadata, ProfileMetadataCache } from '../storage/types';
|
||||||
|
import { LoggerService } from '../logger/logger.service';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
declare const chrome: any;
|
declare const chrome: any;
|
||||||
@@ -14,6 +15,7 @@ const STORAGE_KEY = 'profileMetadataCache';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ProfileMetadataService {
|
export class ProfileMetadataService {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
#cache: ProfileMetadataCache = {};
|
#cache: ProfileMetadataCache = {};
|
||||||
#pool: SimplePool | null = null;
|
#pool: SimplePool | null = null;
|
||||||
#fetchPromises = new Map<string, Promise<ProfileMetadata | null>>();
|
#fetchPromises = new Map<string, Promise<ProfileMetadata | null>>();
|
||||||
@@ -52,7 +54,8 @@ export class ProfileMetadataService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load profile cache from storage:', error);
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
this.#logger.logStorageError('load profile cache', errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +68,8 @@ export class ProfileMetadataService {
|
|||||||
await chrome.storage.session.set({ [STORAGE_KEY]: this.#cache });
|
await chrome.storage.session.set({ [STORAGE_KEY]: this.#cache });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to save profile cache to storage:', error);
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
this.#logger.logStorageError('save profile cache', errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +213,7 @@ export class ProfileMetadataService {
|
|||||||
this.#cache[pubkey] = profile;
|
this.#cache[pubkey] = profile;
|
||||||
results.set(pubkey, profile);
|
results.set(pubkey, profile);
|
||||||
} catch {
|
} catch {
|
||||||
console.error(`Failed to parse profile for ${pubkey}`);
|
this.#logger.logProfileParseError(pubkey);
|
||||||
results.set(pubkey, null);
|
results.set(pubkey, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,7 +229,8 @@ export class ProfileMetadataService {
|
|||||||
await this.#saveCacheToStorage();
|
await this.#saveCacheToStorage();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch profiles:', error);
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
this.#logger.logProfileFetchError('multiple', errorMsg);
|
||||||
// Set null for all unfetched pubkeys on error
|
// Set null for all unfetched pubkeys on error
|
||||||
for (const pubkey of uncachedPubkeys) {
|
for (const pubkey of uncachedPubkeys) {
|
||||||
if (!results.has(pubkey)) {
|
if (!results.has(pubkey)) {
|
||||||
@@ -283,11 +288,12 @@ export class ProfileMetadataService {
|
|||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
} catch {
|
} catch {
|
||||||
console.error(`Failed to parse profile content for ${pubkey}`);
|
this.#logger.logProfileParseError(pubkey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to fetch profile for ${pubkey}:`, error);
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
this.#logger.logProfileFetchError(pubkey, errorMsg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ export abstract class BrowserSessionHandler {
|
|||||||
this.#browserSessionData = JSON.parse(JSON.stringify(data));
|
this.#browserSessionData = JSON.parse(JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearInMemoryData() {
|
||||||
|
this.#browserSessionData = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persist the full data to the session data storage.
|
* Persist the full data to the session data storage.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -146,12 +146,17 @@ export const decryptPermissions = async function (
|
|||||||
const decryptedPermissions: Permission_DECRYPTED[] = [];
|
const decryptedPermissions: Permission_DECRYPTED[] = [];
|
||||||
|
|
||||||
for (const permission of permissions) {
|
for (const permission of permissions) {
|
||||||
const decryptedPermission = await decryptPermission.call(
|
try {
|
||||||
this,
|
const decryptedPermission = await decryptPermission.call(
|
||||||
permission,
|
this,
|
||||||
withLockedVault
|
permission,
|
||||||
);
|
withLockedVault
|
||||||
decryptedPermissions.push(decryptedPermission);
|
);
|
||||||
|
decryptedPermissions.push(decryptedPermission);
|
||||||
|
} catch (error) {
|
||||||
|
// Skip corrupted permissions (e.g., encrypted with wrong key)
|
||||||
|
console.warn('[vault] Skipping corrupted permission:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return decryptedPermissions;
|
return decryptedPermissions;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { BrowserSyncFlow, SignerMetaData } from './types';
|
import { Bookmark, BrowserSyncFlow, SignerMetaData } from './types';
|
||||||
|
|
||||||
export abstract class SignerMetaHandler {
|
export abstract class SignerMetaHandler {
|
||||||
get signerMetaData(): SignerMetaData | undefined {
|
get signerMetaData(): SignerMetaData | undefined {
|
||||||
@@ -8,7 +8,7 @@ export abstract class SignerMetaHandler {
|
|||||||
|
|
||||||
#signerMetaData?: SignerMetaData;
|
#signerMetaData?: SignerMetaData;
|
||||||
|
|
||||||
readonly metaProperties = ['syncFlow', 'vaultSnapshots', 'recklessMode', 'whitelistedHosts'];
|
readonly metaProperties = ['syncFlow', 'vaultSnapshots', 'recklessMode', 'whitelistedHosts', 'bookmarks'];
|
||||||
/**
|
/**
|
||||||
* Load the full data from the storage. If the storage is used for storing
|
* Load the full data from the storage. If the storage is used for storing
|
||||||
* other data (e.g. browser sync data when the user decided to NOT sync),
|
* other data (e.g. browser sync data when the user decided to NOT sync),
|
||||||
@@ -89,4 +89,26 @@ export abstract class SignerMetaHandler {
|
|||||||
|
|
||||||
await this.saveFullData(this.#signerMetaData);
|
await this.saveFullData(this.#signerMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bookmarks array and immediately saves it.
|
||||||
|
*/
|
||||||
|
async setBookmarks(bookmarks: Bookmark[]): Promise<void> {
|
||||||
|
if (!this.#signerMetaData) {
|
||||||
|
this.#signerMetaData = {
|
||||||
|
bookmarks,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.#signerMetaData.bookmarks = bookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.saveFullData(this.#signerMetaData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current bookmarks.
|
||||||
|
*/
|
||||||
|
getBookmarks(): Bookmark[] {
|
||||||
|
return this.#signerMetaData?.bookmarks ?? [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,14 @@ export class StorageService {
|
|||||||
this.isInitialized = false;
|
this.isInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async lockVault(): Promise<void> {
|
||||||
|
this.assureIsInitialized();
|
||||||
|
await this.getBrowserSessionHandler().clearData();
|
||||||
|
this.getBrowserSessionHandler().clearInMemoryData();
|
||||||
|
// Note: We don't set isInitialized = false here because the sync data
|
||||||
|
// (encrypted vault) is still loaded and we need it to unlock again
|
||||||
|
}
|
||||||
|
|
||||||
async unlockVault(password: string): Promise<void> {
|
async unlockVault(password: string): Promise<void> {
|
||||||
await unlockVault.call(this, password);
|
await unlockVault.call(this, password);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,16 @@ export const SIGNER_META_DATA_KEY = {
|
|||||||
vaultSnapshots: 'vaultSnapshots',
|
vaultSnapshots: 'vaultSnapshots',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bookmark entry for storing user bookmarks
|
||||||
|
*/
|
||||||
|
export interface Bookmark {
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
title: string;
|
||||||
|
createdAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface SignerMetaData {
|
export interface SignerMetaData {
|
||||||
syncFlow?: number; // 0 = no sync, 1 = browser sync, (future: 2 = Signer sync, 3 = Custom sync (bring your own sync))
|
syncFlow?: number; // 0 = no sync, 1 = browser sync, (future: 2 = Signer sync, 3 = Custom sync (bring your own sync))
|
||||||
|
|
||||||
@@ -104,6 +114,9 @@ export interface SignerMetaData {
|
|||||||
|
|
||||||
// Whitelisted hosts: auto-approve all actions from these hosts
|
// Whitelisted hosts: auto-approve all actions from these hosts
|
||||||
whitelistedHosts?: string[];
|
whitelistedHosts?: string[];
|
||||||
|
|
||||||
|
// User bookmarks
|
||||||
|
bookmarks?: Bookmark[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
.sam-text-header {
|
.sam-text-header {
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
padding-top: var(--size);
|
height: 48px;
|
||||||
padding-bottom: var(--size);
|
min-height: 48px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
font-family: var(--font-heading);
|
font-family: var(--font-heading);
|
||||||
@@ -14,6 +15,28 @@
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.1rem;
|
letter-spacing: 0.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lock-btn {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--background-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sam-footer-grid-2 {
|
.sam-footer-grid-2 {
|
||||||
|
|||||||
@@ -84,3 +84,11 @@ h2.font-heading {
|
|||||||
h3.font-heading {
|
h3.font-heading {
|
||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emoji styling
|
||||||
|
.emoji {
|
||||||
|
font-family: var(--font-emoji);
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: normal;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
--font-sans: 'IBM Plex Mono', monospace;
|
--font-sans: 'IBM Plex Mono', monospace;
|
||||||
--font-heading: 'reglisse', sans-serif;
|
--font-heading: 'reglisse', sans-serif;
|
||||||
--font-theylive: 'theylive', sans-serif;
|
--font-theylive: 'theylive', sans-serif;
|
||||||
|
--font-emoji: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Android Emoji', sans-serif;
|
||||||
|
|
||||||
// Border radius (from market)
|
// Border radius (from market)
|
||||||
--radius: 0.25rem;
|
--radius: 0.25rem;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Plebeian Signer",
|
"name": "Plebeian Signer",
|
||||||
"description": "Nostr Identity Manager & Signer",
|
"description": "Nostr Identity Manager & Signer",
|
||||||
"version": "1.0.1",
|
"version": "1.0.8",
|
||||||
"homepage_url": "https://git.mleku.dev/mleku/plebeian-signer",
|
"homepage_url": "https://git.mleku.dev/mleku/plebeian-signer",
|
||||||
"options_page": "options.html",
|
"options_page": "options.html",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 983 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -226,7 +226,7 @@
|
|||||||
<!------------->
|
<!------------->
|
||||||
<div class="sam-footer-grid-2">
|
<div class="sam-footer-grid-2">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button id="rejectButton" type="button" class="btn btn-secondary">
|
<button id="rejectOnceButton" type="button" class="btn btn-secondary">
|
||||||
Reject
|
Reject
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@@ -239,16 +239,16 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
<li>
|
<li>
|
||||||
<button id="rejectJustOnceButton" class="dropdown-item">
|
<button id="rejectAlwaysButton" class="dropdown-item">
|
||||||
just once
|
Reject Always
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button id="approveButton" type="button" class="btn btn-primary">
|
<button id="approveAlwaysButton" type="button" class="btn btn-primary">
|
||||||
Approve
|
Approve Always
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -260,8 +260,8 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<button id="approveJustOnceButton" class="dropdown-item" href="#">
|
<button id="approveOnceButton" class="dropdown-item">
|
||||||
just once
|
Approve Once
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import { IdentitiesComponent } from './components/home/identities/identities.com
|
|||||||
import { IdentityComponent } from './components/home/identity/identity.component';
|
import { IdentityComponent } from './components/home/identity/identity.component';
|
||||||
import { InfoComponent } from './components/home/info/info.component';
|
import { InfoComponent } from './components/home/info/info.component';
|
||||||
import { SettingsComponent } from './components/home/settings/settings.component';
|
import { SettingsComponent } from './components/home/settings/settings.component';
|
||||||
|
import { LogsComponent } from './components/home/logs/logs.component';
|
||||||
|
import { BookmarksComponent } from './components/home/bookmarks/bookmarks.component';
|
||||||
|
import { WalletComponent } from './components/home/wallet/wallet.component';
|
||||||
import { NewIdentityComponent } from './components/new-identity/new-identity.component';
|
import { NewIdentityComponent } from './components/new-identity/new-identity.component';
|
||||||
import { EditIdentityComponent } from './components/edit-identity/edit-identity.component';
|
import { EditIdentityComponent } from './components/edit-identity/edit-identity.component';
|
||||||
import { HomeComponent as EditIdentityHomeComponent } from './components/edit-identity/home/home.component';
|
import { HomeComponent as EditIdentityHomeComponent } from './components/edit-identity/home/home.component';
|
||||||
@@ -66,6 +69,18 @@ export const routes: Routes = [
|
|||||||
path: 'settings',
|
path: 'settings',
|
||||||
component: SettingsComponent,
|
component: SettingsComponent,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'logs',
|
||||||
|
component: LogsComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'bookmarks',
|
||||||
|
component: BookmarksComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'wallet',
|
||||||
|
component: WalletComponent,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
<span class="text-muted" style="font-size: 12px">
|
<span class="text-muted" style="font-size: 12px">
|
||||||
Nothing configured so far.
|
Nothing configured so far.
|
||||||
</span>
|
</span>
|
||||||
} @for(hostPermissions of hostsPermissions; track hostPermissions) {
|
} @else {
|
||||||
|
<button class="btn btn-danger btn-sm remove-all-btn" (click)="onClickRemoveAllPermissions()">
|
||||||
|
Remove All Permissions
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
@for(hostPermissions of hostsPermissions; track hostPermissions) {
|
||||||
<div class="permissions-card">
|
<div class="permissions-card">
|
||||||
<span style="margin-bottom: 4px; font-weight: 500">
|
<span style="margin-bottom: 4px; font-weight: 500">
|
||||||
{{ hostPermissions.host }}
|
{{ hostPermissions.host }}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.remove-all-btn {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
.permissions-card {
|
.permissions-card {
|
||||||
background: var(--background-light);
|
background: var(--background-light);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ export class PermissionsComponent extends NavComponent implements OnInit {
|
|||||||
this.#buildHostsPermissions(this.identity?.id);
|
this.#buildHostsPermissions(this.identity?.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickRemoveAllPermissions() {
|
||||||
|
const allPermissions = this.hostsPermissions.flatMap(hp => hp.permissions);
|
||||||
|
for (const permission of allPermissions) {
|
||||||
|
await this.#storage.deletePermission(permission.id);
|
||||||
|
}
|
||||||
|
this.#buildHostsPermissions(this.identity?.id);
|
||||||
|
}
|
||||||
|
|
||||||
#initialize(identityId: string) {
|
#initialize(identityId: string) {
|
||||||
this.identity = this.#storage
|
this.identity = this.#storage
|
||||||
.getBrowserSessionHandler()
|
.getBrowserSessionHandler()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-banner">
|
<div class="info-banner">
|
||||||
<i class="bi bi-info-circle"></i>
|
<span class="emoji">💡</span>
|
||||||
<span>These relays are fetched from your NIP-65 relay list (kind 10002). To update your relay list, use a Nostr client that supports NIP-65.</span>
|
<span>These relays are fetched from your NIP-65 relay list (kind 10002). To update your relay list, use a Nostr client that supports NIP-65.</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
||||||
|
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
||||||
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
|
<span>Bookmarks</span>
|
||||||
|
<button class="add-btn" title="Bookmark This Page" (click)="onBookmarkThisPage()">
|
||||||
|
<span class="emoji">➕</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bookmarks-container">
|
||||||
|
@if (isLoading) {
|
||||||
|
<div class="loading-state">Loading...</div>
|
||||||
|
} @else if (bookmarks.length === 0) {
|
||||||
|
<div class="empty-state">
|
||||||
|
<span class="sam-text-muted">
|
||||||
|
No bookmarks yet. Click "Bookmark This Page" to add the current page.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
@for (bookmark of bookmarks; track bookmark.id) {
|
||||||
|
<div class="bookmark-item" (click)="openBookmark(bookmark)">
|
||||||
|
<div class="bookmark-info">
|
||||||
|
<span class="bookmark-title">{{ bookmark.title }}</span>
|
||||||
|
<span class="bookmark-url">{{ getDomain(bookmark.url) }}</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="remove-btn"
|
||||||
|
title="Remove bookmark"
|
||||||
|
(click)="onRemoveBookmark(bookmark); $event.stopPropagation()"
|
||||||
|
>
|
||||||
|
<span class="emoji">✕</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: var(--size);
|
||||||
|
padding-bottom: var(--size);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.add-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--background-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmarks-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state,
|
||||||
|
.loading-state {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--size-h);
|
||||||
|
padding: var(--size-h) var(--size);
|
||||||
|
margin-bottom: var(--size-hh);
|
||||||
|
background: var(--background-light);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--background-light-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-title {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-url {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove-btn {
|
||||||
|
all: unset;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
transition: background-color 0.15s ease, color 0.15s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--destructive);
|
||||||
|
color: var(--destructive-foreground);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { Bookmark, LoggerService, SignerMetaData, StorageService } from '@common';
|
||||||
|
import { FirefoxMetaHandler } from '../../../common/data/firefox-meta-handler';
|
||||||
|
import browser from 'webextension-polyfill';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-bookmarks',
|
||||||
|
templateUrl: './bookmarks.component.html',
|
||||||
|
styleUrl: './bookmarks.component.scss',
|
||||||
|
imports: [],
|
||||||
|
})
|
||||||
|
export class BookmarksComponent implements OnInit {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #metaHandler = new FirefoxMetaHandler();
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
|
bookmarks: Bookmark[] = [];
|
||||||
|
isLoading = true;
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.loadBookmarks();
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadBookmarks() {
|
||||||
|
this.isLoading = true;
|
||||||
|
try {
|
||||||
|
const metaData = await this.#metaHandler.loadFullData() as SignerMetaData;
|
||||||
|
this.#metaHandler.setFullData(metaData);
|
||||||
|
this.bookmarks = this.#metaHandler.getBookmarks();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load bookmarks:', error);
|
||||||
|
} finally {
|
||||||
|
this.isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onBookmarkThisPage() {
|
||||||
|
try {
|
||||||
|
// Get the current tab URL and title
|
||||||
|
const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
|
||||||
|
if (!tab?.url || !tab?.title) {
|
||||||
|
console.error('Could not get current tab info');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if already bookmarked
|
||||||
|
if (this.bookmarks.some(b => b.url === tab.url)) {
|
||||||
|
console.log('Page already bookmarked');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newBookmark: Bookmark = {
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
url: tab.url,
|
||||||
|
title: tab.title,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
};
|
||||||
|
|
||||||
|
this.bookmarks = [newBookmark, ...this.bookmarks];
|
||||||
|
await this.saveBookmarks();
|
||||||
|
this.#logger.logBookmarkAdded(newBookmark.url, newBookmark.title);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to bookmark page:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onRemoveBookmark(bookmark: Bookmark) {
|
||||||
|
this.bookmarks = this.bookmarks.filter(b => b.id !== bookmark.id);
|
||||||
|
await this.saveBookmarks();
|
||||||
|
this.#logger.logBookmarkRemoved(bookmark.url, bookmark.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
async saveBookmarks() {
|
||||||
|
try {
|
||||||
|
await this.#metaHandler.setBookmarks(this.bookmarks);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to save bookmarks:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openBookmark(bookmark: Bookmark) {
|
||||||
|
browser.tabs.create({ url: bookmark.url });
|
||||||
|
}
|
||||||
|
|
||||||
|
getDomain(url: string): string {
|
||||||
|
try {
|
||||||
|
return new URL(url).hostname;
|
||||||
|
} catch {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,34 +3,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<a
|
<a class="tab" routerLink="/home/identity" routerLinkActive="active" title="You">
|
||||||
class="tab"
|
<span class="emoji">👤</span>
|
||||||
routerLink="/home/identity"
|
|
||||||
routerLinkActive="active"
|
|
||||||
title="Your selected identity"
|
|
||||||
>
|
|
||||||
<i class="bi bi-person-circle"></i>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a class="tab" routerLink="/home/identities" routerLinkActive="active" title="Identities">
|
||||||
class="tab"
|
<span class="emoji">👥</span>
|
||||||
routerLink="/home/identities"
|
|
||||||
routerLinkActive="active"
|
|
||||||
title="Identities"
|
|
||||||
>
|
|
||||||
<i class="bi bi-people-fill"></i>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a class="tab" routerLink="/home/wallet" routerLinkActive="active" title="Wallet">
|
||||||
class="tab"
|
<span class="emoji">💰</span>
|
||||||
routerLink="/home/settings"
|
|
||||||
routerLinkActive="active"
|
|
||||||
title="Settings"
|
|
||||||
>
|
|
||||||
<i class="bi bi-gear"></i>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="tab" routerLink="/home/info" routerLinkActive="active" title="Info">
|
<a class="tab" routerLink="/home/bookmarks" routerLinkActive="active" title="Bookmarks">
|
||||||
<i class="bi bi-info-circle"></i>
|
<span class="emoji">🔖</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a class="tab" routerLink="/home/settings" routerLinkActive="active" title="Settings">
|
||||||
|
<span class="emoji">⚙️</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,17 +4,17 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.tab-content {
|
.tab-content {
|
||||||
height: calc(100% - 60px);
|
height: calc(100% - 48px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
height: 60px;
|
height: 48px;
|
||||||
min-height: 60px;
|
min-height: 48px;
|
||||||
background: var(--background-light);
|
background: var(--background-light);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
||||||
a {
|
a, button {
|
||||||
all: unset;
|
all: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,14 +23,17 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 24px;
|
|
||||||
|
|
||||||
color: var(--muted-foreground);
|
color: var(--muted-foreground);
|
||||||
border-top: 3px solid transparent;
|
border-top: 2px solid transparent;
|
||||||
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
|
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--background-light-hover);
|
background: var(--background-light-hover);
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
@@ -38,7 +41,7 @@
|
|||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
border-top: 3px solid var(--primary);
|
border-top: 2px solid var(--primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
||||||
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
||||||
<div class="custom-header" style="position: sticky; top: 0">
|
<div class="custom-header" style="position: sticky; top: 0">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span class="text">Identities</span>
|
<span class="text">Identities</span>
|
||||||
|
|
||||||
<button class="button btn btn-primary btn-sm" (click)="onClickNewIdentity()">
|
<button class="add-btn" title="New Identity" (click)="onClickNewIdentity()">
|
||||||
<div class="sam-flex-row gap-h">
|
<span class="emoji">➕</span>
|
||||||
<i class="bi bi-plus-lg"></i>
|
|
||||||
<span>New</span>
|
|
||||||
</div>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
title="Manage whitelisted apps"
|
title="Manage whitelisted apps"
|
||||||
(click)="onClickWhitelistedApps()"
|
(click)="onClickWhitelistedApps()"
|
||||||
>
|
>
|
||||||
<i class="bi bi-gear"></i>
|
<span class="emoji">⚙️</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
/>
|
/>
|
||||||
<span class="name">{{ getDisplayName(identity) }}</span>
|
<span class="name">{{ getDisplayName(identity) }}</span>
|
||||||
<lib-icon-button
|
<lib-icon-button
|
||||||
icon="gear"
|
icon="⚙️"
|
||||||
title="Identity settings"
|
title="Identity settings"
|
||||||
(click)="onClickEditIdentity(identity.id, $event)"
|
(click)="onClickEditIdentity(identity.id, $event)"
|
||||||
></lib-icon-button>
|
></lib-icon-button>
|
||||||
|
|||||||
@@ -3,37 +3,58 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: var(--size);
|
|
||||||
padding-right: var(--size);
|
> *:not(.custom-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
.custom-header {
|
.custom-header {
|
||||||
padding-top: var(--size);
|
height: 48px;
|
||||||
padding-bottom: var(--size);
|
min-height: 48px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
grid-template-rows: auto;
|
grid-template-rows: auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.button {
|
.lock-btn,
|
||||||
grid-column-start: 1;
|
.add-btn {
|
||||||
grid-column-end: 2;
|
position: absolute;
|
||||||
grid-row-start: 1;
|
background: transparent;
|
||||||
grid-row-end: 2;
|
border: none;
|
||||||
justify-self: end;
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--background-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.lock-btn {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-btn {
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
grid-column-start: 1;
|
|
||||||
grid-column-end: 2;
|
|
||||||
grid-row-start: 1;
|
|
||||||
grid-row-end: 2;
|
|
||||||
font-family: var(--font-heading);
|
font-family: var(--font-heading);
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.1rem;
|
letter-spacing: 0.1rem;
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
height: 32px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Router } from '@angular/router';
|
|||||||
import {
|
import {
|
||||||
IconButtonComponent,
|
IconButtonComponent,
|
||||||
Identity_DECRYPTED,
|
Identity_DECRYPTED,
|
||||||
|
LoggerService,
|
||||||
NostrHelper,
|
NostrHelper,
|
||||||
ProfileMetadata,
|
ProfileMetadata,
|
||||||
ProfileMetadataService,
|
ProfileMetadataService,
|
||||||
@@ -20,6 +21,7 @@ export class IdentitiesComponent implements OnInit {
|
|||||||
readonly storage = inject(StorageService);
|
readonly storage = inject(StorageService);
|
||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #profileMetadata = inject(ProfileMetadataService);
|
readonly #profileMetadata = inject(ProfileMetadataService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
// Cache of pubkey -> profile for quick lookup
|
// Cache of pubkey -> profile for quick lookup
|
||||||
#profileCache = new Map<string, ProfileMetadata | null>();
|
#profileCache = new Map<string, ProfileMetadata | null>();
|
||||||
@@ -73,4 +75,10 @@ export class IdentitiesComponent implements OnInit {
|
|||||||
onClickWhitelistedApps() {
|
onClickWhitelistedApps() {
|
||||||
this.#router.navigateByUrl('/whitelisted-apps');
|
this.#router.navigateByUrl('/whitelisted-apps');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
|
||||||
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->
|
||||||
<div class="sam-text-header">
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span>You</span>
|
<span>You</span>
|
||||||
<button class="edit-btn" title="Edit profile" (click)="onClickEditProfile()">
|
<button class="edit-btn" title="Edit profile" (click)="onClickEditProfile()">
|
||||||
<img src="edit.svg" alt="Edit" class="edit-icon" />
|
<span class="emoji">📝</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,12 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.sam-text-header {
|
.sam-text-header {
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.edit-btn {
|
.edit-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: var(--size);
|
right: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 4px;
|
padding: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -23,10 +21,8 @@
|
|||||||
background-color: var(--background-light);
|
background-color: var(--background-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-icon {
|
.emoji {
|
||||||
width: 20px;
|
font-size: 20px;
|
||||||
height: 20px;
|
|
||||||
filter: brightness(0) invert(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component, inject, OnInit } from '@angular/core';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
Identity_DECRYPTED,
|
Identity_DECRYPTED,
|
||||||
|
LoggerService,
|
||||||
NostrHelper,
|
NostrHelper,
|
||||||
ProfileMetadata,
|
ProfileMetadata,
|
||||||
ProfileMetadataService,
|
ProfileMetadataService,
|
||||||
@@ -29,6 +30,7 @@ export class IdentityComponent implements OnInit {
|
|||||||
readonly #storage = inject(StorageService);
|
readonly #storage = inject(StorageService);
|
||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #profileMetadata = inject(ProfileMetadataService);
|
readonly #profileMetadata = inject(ProfileMetadataService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.#loadData();
|
this.#loadData();
|
||||||
@@ -74,6 +76,12 @@ export class IdentityComponent implements OnInit {
|
|||||||
this.#router.navigateByUrl('/profile-edit');
|
this.#router.navigateByUrl('/profile-edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
|
||||||
async #loadData() {
|
async #loadData() {
|
||||||
try {
|
try {
|
||||||
const selectedIdentityId =
|
const selectedIdentityId =
|
||||||
@@ -136,13 +144,16 @@ export class IdentityComponent implements OnInit {
|
|||||||
const result = await validateNip05(nip05, pubkey);
|
const result = await validateNip05(nip05, pubkey);
|
||||||
this.nip05isValidated = result.valid;
|
this.nip05isValidated = result.valid;
|
||||||
|
|
||||||
if (!result.valid) {
|
if (result.valid) {
|
||||||
console.log('NIP-05 validation failed:', result.error);
|
this.#logger.logNip05ValidationSuccess(nip05, pubkey);
|
||||||
|
} else {
|
||||||
|
this.#logger.logNip05ValidationError(nip05, result.error ?? 'Unknown error');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.validating = false;
|
this.validating = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('NIP-05 validation failed:', error);
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
this.#logger.logNip05ValidationError(nip05, errorMsg);
|
||||||
this.nip05isValidated = false;
|
this.nip05isValidated = false;
|
||||||
this.validating = false;
|
this.validating = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<div class="sam-text-header">
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span> Plebeian Signer </span>
|
<span> Plebeian Signer </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,13 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: var(--size);
|
|
||||||
padding-right: var(--size);
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { LoggerService, StorageService } from '@common';
|
||||||
import packageJson from '../../../../../../../package.json';
|
import packageJson from '../../../../../../../package.json';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -7,5 +9,15 @@ import packageJson from '../../../../../../../package.json';
|
|||||||
styleUrl: './info.component.scss',
|
styleUrl: './info.component.scss',
|
||||||
})
|
})
|
||||||
export class InfoComponent {
|
export class InfoComponent {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
version = packageJson.custom.firefox.version;
|
version = packageJson.custom.firefox.version;
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
|
<span>Logs</span>
|
||||||
|
<div class="logs-actions">
|
||||||
|
<button class="btn btn-sm btn-secondary" title="Refresh logs" (click)="onRefresh()">Refresh</button>
|
||||||
|
<button class="btn btn-sm btn-secondary" title="Clear logs" (click)="onClear()">Clear</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="logs-container">
|
||||||
|
@if (logs.length === 0) {
|
||||||
|
<div class="logs-empty">No activity logged yet</div>
|
||||||
|
}
|
||||||
|
@for (log of logs; track log.timestamp) {
|
||||||
|
<div class="log-entry" [class]="getLevelClass(log.level)">
|
||||||
|
<span class="log-icon emoji">{{ log.icon }}</span>
|
||||||
|
<span class="log-time">{{ log.timestamp | date:'HH:mm:ss' }}</span>
|
||||||
|
<span class="log-message">{{ log.message }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: var(--size);
|
||||||
|
padding-bottom: var(--size);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.logs-actions {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: var(--background-light);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: var(--size-h);
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-empty {
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
text-align: center;
|
||||||
|
padding: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry {
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&.log-error {
|
||||||
|
background: rgba(220, 53, 69, 0.15);
|
||||||
|
color: #ff6b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.log-warn {
|
||||||
|
background: rgba(255, 193, 7, 0.15);
|
||||||
|
color: #ffc107;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.log-debug {
|
||||||
|
background: rgba(108, 117, 125, 0.15);
|
||||||
|
color: #adb5bd;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.log-info {
|
||||||
|
background: rgba(13, 110, 253, 0.1);
|
||||||
|
color: var(--foreground);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-icon {
|
||||||
|
font-size: 14px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-time {
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-message {
|
||||||
|
flex: 1;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { LoggerService, LogEntry, StorageService } from '@common';
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-logs',
|
||||||
|
templateUrl: './logs.component.html',
|
||||||
|
styleUrl: './logs.component.scss',
|
||||||
|
imports: [DatePipe],
|
||||||
|
})
|
||||||
|
export class LogsComponent implements OnInit {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
|
get logs(): LogEntry[] {
|
||||||
|
return this.#logger.logs;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
// Refresh logs from storage to get background script logs
|
||||||
|
this.#logger.refreshLogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onRefresh() {
|
||||||
|
await this.#logger.refreshLogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClear() {
|
||||||
|
await this.#logger.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
getLevelClass(level: LogEntry['level']): string {
|
||||||
|
switch (level) {
|
||||||
|
case 'error':
|
||||||
|
return 'log-error';
|
||||||
|
case 'warn':
|
||||||
|
return 'log-warn';
|
||||||
|
case 'debug':
|
||||||
|
return 'log-debug';
|
||||||
|
default:
|
||||||
|
return 'log-info';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<div class="sam-text-header">
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
<span> Settings </span>
|
<span> Settings </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -12,6 +15,9 @@
|
|||||||
Import Vault
|
Import Vault
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<lib-nav-item text="🪵 Logs" (click)="navigate('/home/logs')"></lib-nav-item>
|
||||||
|
<lib-nav-item text="💡 Info" (click)="navigate('/home/info')"></lib-nav-item>
|
||||||
|
|
||||||
<div class="sam-flex-grow"></div>
|
<div class="sam-flex-grow"></div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
row-gap: var(--size);
|
row-gap: var(--size);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-left: var(--size);
|
|
||||||
padding-right: var(--size);
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
.file-input {
|
.file-input {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
BrowserSyncFlow,
|
BrowserSyncFlow,
|
||||||
ConfirmComponent,
|
ConfirmComponent,
|
||||||
DateHelper,
|
DateHelper,
|
||||||
|
LoggerService,
|
||||||
NavComponent,
|
NavComponent,
|
||||||
|
NavItemComponent,
|
||||||
StartupService,
|
StartupService,
|
||||||
StorageService,
|
StorageService,
|
||||||
} from '@common';
|
} from '@common';
|
||||||
@@ -11,15 +14,17 @@ import { getNewStorageServiceConfig } from '../../../common/data/get-new-storage
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
imports: [ConfirmComponent],
|
imports: [ConfirmComponent, NavItemComponent],
|
||||||
templateUrl: './settings.component.html',
|
templateUrl: './settings.component.html',
|
||||||
styleUrl: './settings.component.scss',
|
styleUrl: './settings.component.scss',
|
||||||
})
|
})
|
||||||
export class SettingsComponent extends NavComponent implements OnInit {
|
export class SettingsComponent extends NavComponent implements OnInit {
|
||||||
|
readonly #router = inject(Router);
|
||||||
syncFlow: string | undefined;
|
syncFlow: string | undefined;
|
||||||
|
|
||||||
readonly #storage = inject(StorageService);
|
readonly #storage = inject(StorageService);
|
||||||
readonly #startup = inject(StartupService);
|
readonly #startup = inject(StartupService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const vault = JSON.stringify(
|
const vault = JSON.stringify(
|
||||||
@@ -43,6 +48,7 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
|
|
||||||
async onResetExtension() {
|
async onResetExtension() {
|
||||||
try {
|
try {
|
||||||
|
this.#logger.logVaultReset();
|
||||||
await this.#storage.resetExtension();
|
await this.#storage.resetExtension();
|
||||||
this.#startup.startOver(getNewStorageServiceConfig());
|
this.#startup.startOver(getNewStorageServiceConfig());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -58,6 +64,7 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
const fileName = `Plebeian Signer Firefox - Vault Export - ${dateTimeString}.json`;
|
const fileName = `Plebeian Signer Firefox - Vault Export - ${dateTimeString}.json`;
|
||||||
|
|
||||||
this.#downloadJson(jsonVault, fileName);
|
this.#downloadJson(jsonVault, fileName);
|
||||||
|
this.#logger.logVaultExport(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#downloadJson(jsonString: string, fileName: string) {
|
#downloadJson(jsonString: string, fileName: string) {
|
||||||
@@ -70,4 +77,10 @@ export class SettingsComponent extends NavComponent implements OnInit {
|
|||||||
downloadAnchorNode.click();
|
downloadAnchorNode.click();
|
||||||
downloadAnchorNode.remove();
|
downloadAnchorNode.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<div class="sam-text-header">
|
||||||
|
<button class="lock-btn" title="Lock" (click)="onClickLock()">
|
||||||
|
<span class="emoji">🔒</span>
|
||||||
|
</button>
|
||||||
|
<span>Wallet</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wallet-container">
|
||||||
|
<div class="empty-state">
|
||||||
|
<span class="sam-text-muted">
|
||||||
|
Wallet functionality coming soon.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
:host {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: var(--size);
|
||||||
|
padding-bottom: var(--size);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> *:not(.sam-text-header) {
|
||||||
|
margin-left: var(--size);
|
||||||
|
margin-right: var(--size);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sam-text-header {
|
||||||
|
margin-bottom: var(--size);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { LoggerService, StorageService } from '@common';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-wallet',
|
||||||
|
templateUrl: './wallet.component.html',
|
||||||
|
styleUrl: './wallet.component.scss',
|
||||||
|
imports: [],
|
||||||
|
})
|
||||||
|
export class WalletComponent {
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #router = inject(Router);
|
||||||
|
|
||||||
|
async onClickLock() {
|
||||||
|
this.#logger.logVaultLock();
|
||||||
|
await this.#storage.lockVault();
|
||||||
|
this.#router.navigateByUrl('/vault-login');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Component, inject, ViewChild } from '@angular/core';
|
import { Component, inject, ViewChild } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { NavComponent, StorageService, DerivingModalComponent } from '@common';
|
import { LoggerService, NavComponent, StorageService, DerivingModalComponent } from '@common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new',
|
selector: 'app-new',
|
||||||
@@ -16,6 +16,7 @@ export class NewComponent extends NavComponent {
|
|||||||
|
|
||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #storage = inject(StorageService);
|
readonly #storage = inject(StorageService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
toggleType(element: HTMLInputElement) {
|
toggleType(element: HTMLInputElement) {
|
||||||
if (element.type === 'password') {
|
if (element.type === 'password') {
|
||||||
@@ -35,6 +36,7 @@ export class NewComponent extends NavComponent {
|
|||||||
try {
|
try {
|
||||||
await this.#storage.createNewVault(this.password);
|
await this.#storage.createNewVault(this.password);
|
||||||
this.derivingModal.hide();
|
this.derivingModal.hide();
|
||||||
|
this.#logger.logVaultCreated();
|
||||||
this.#router.navigateByUrl('/home/identities');
|
this.#router.navigateByUrl('/home/identities');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.derivingModal.hide();
|
this.derivingModal.hide();
|
||||||
|
|||||||
@@ -43,23 +43,22 @@
|
|||||||
<span>Sign in</span>
|
<span>Sign in</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
|
||||||
class="sam-mt"
|
|
||||||
(click)="
|
|
||||||
confirm.show(
|
|
||||||
'Do you really want to reset the extension? All data will be lost.',
|
|
||||||
onClickResetExtension.bind(this)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
type="button"
|
|
||||||
class="btn btn-link"
|
|
||||||
>
|
|
||||||
Reset Extension
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="reset-btn"
|
||||||
|
(click)="
|
||||||
|
confirm.show(
|
||||||
|
'Do you really want to reset the extension? All data will be lost.',
|
||||||
|
onClickResetExtension.bind(this)
|
||||||
|
)
|
||||||
|
"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Reset Extension
|
||||||
|
</button>
|
||||||
|
|
||||||
<!----------->
|
<!----------->
|
||||||
<!-- ALERT -->
|
<!-- ALERT -->
|
||||||
<!----------->
|
<!----------->
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.logo-frame {
|
.logo-frame {
|
||||||
border: 2px solid var(--secondary);
|
border: 2px solid var(--secondary);
|
||||||
@@ -16,4 +17,21 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0 var(--size) var(--size) var(--size);
|
padding: 0 var(--size) var(--size) var(--size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reset-btn {
|
||||||
|
position: absolute;
|
||||||
|
bottom: var(--size);
|
||||||
|
right: var(--size);
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px 8px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--foreground);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
|
|||||||
import {
|
import {
|
||||||
ConfirmComponent,
|
ConfirmComponent,
|
||||||
DerivingModalComponent,
|
DerivingModalComponent,
|
||||||
|
LoggerService,
|
||||||
NostrHelper,
|
NostrHelper,
|
||||||
ProfileMetadataService,
|
ProfileMetadataService,
|
||||||
StartupService,
|
StartupService,
|
||||||
@@ -28,6 +29,7 @@ export class VaultLoginComponent implements AfterViewInit {
|
|||||||
readonly #router = inject(Router);
|
readonly #router = inject(Router);
|
||||||
readonly #startup = inject(StartupService);
|
readonly #startup = inject(StartupService);
|
||||||
readonly #profileMetadata = inject(ProfileMetadataService);
|
readonly #profileMetadata = inject(ProfileMetadataService);
|
||||||
|
readonly #logger = inject(LoggerService);
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.passwordInput.nativeElement.focus();
|
this.passwordInput.nativeElement.focus();
|
||||||
@@ -69,6 +71,7 @@ export class VaultLoginComponent implements AfterViewInit {
|
|||||||
// Unlock succeeded - hide modal and navigate
|
// Unlock succeeded - hide modal and navigate
|
||||||
console.log('[login] Hiding modal and navigating');
|
console.log('[login] Hiding modal and navigating');
|
||||||
this.derivingModal.hide();
|
this.derivingModal.hide();
|
||||||
|
this.#logger.logVaultUnlock();
|
||||||
|
|
||||||
// Fetch profile metadata for all identities in the background
|
// Fetch profile metadata for all identities in the background
|
||||||
this.#fetchAllProfiles();
|
this.#fetchAllProfiles();
|
||||||
@@ -102,6 +105,7 @@ export class VaultLoginComponent implements AfterViewInit {
|
|||||||
|
|
||||||
async onClickResetExtension() {
|
async onClickResetExtension() {
|
||||||
try {
|
try {
|
||||||
|
this.#logger.logVaultReset();
|
||||||
await this.#storage.resetExtension();
|
await this.#storage.resetExtension();
|
||||||
this.#startup.startOver(getNewStorageServiceConfig());
|
this.#startup.startOver(getNewStorageServiceConfig());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
import { Event, EventTemplate, finalizeEvent, nip04, nip44 } from 'nostr-tools';
|
import { Event, EventTemplate, finalizeEvent, nip04, nip44 } from 'nostr-tools';
|
||||||
import { FirefoxMetaHandler } from './app/common/data/firefox-meta-handler';
|
import { FirefoxMetaHandler } from './app/common/data/firefox-meta-handler';
|
||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
export const debug = function (message: any) {
|
export const debug = function (message: any) {
|
||||||
const dateString = new Date().toISOString();
|
const dateString = new Date().toISOString();
|
||||||
@@ -67,6 +68,8 @@ export const shouldRecklessModeApprove = async function (
|
|||||||
host: string
|
host: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const signerMetaData = await getSignerMetaData();
|
const signerMetaData = await getSignerMetaData();
|
||||||
|
debug(`shouldRecklessModeApprove: recklessMode=${signerMetaData.recklessMode}, host=${host}`);
|
||||||
|
debug(`Full signerMetaData: ${JSON.stringify(signerMetaData)}`);
|
||||||
|
|
||||||
if (!signerMetaData.recklessMode) {
|
if (!signerMetaData.recklessMode) {
|
||||||
return false;
|
return false;
|
||||||
@@ -228,8 +231,7 @@ export const storePermission = async function (
|
|||||||
// Encrypt permission to store in sync storage (depending on sync flow).
|
// Encrypt permission to store in sync storage (depending on sync flow).
|
||||||
const encryptedPermission = await encryptPermission(
|
const encryptedPermission = await encryptPermission(
|
||||||
permission,
|
permission,
|
||||||
browserSessionData.iv,
|
browserSessionData
|
||||||
browserSessionData.vaultPassword as string
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await savePermissionsToBrowserSyncStorage([
|
await savePermissionsToBrowserSyncStorage([
|
||||||
@@ -326,22 +328,20 @@ export const nip44Decrypt = async function (
|
|||||||
|
|
||||||
const encryptPermission = async function (
|
const encryptPermission = async function (
|
||||||
permission: Permission_DECRYPTED,
|
permission: Permission_DECRYPTED,
|
||||||
iv: string,
|
sessionData: BrowserSessionData
|
||||||
password: string
|
|
||||||
): Promise<Permission_ENCRYPTED> {
|
): Promise<Permission_ENCRYPTED> {
|
||||||
const encryptedPermission: Permission_ENCRYPTED = {
|
const encryptedPermission: Permission_ENCRYPTED = {
|
||||||
id: await encrypt(permission.id, iv, password),
|
id: await encrypt(permission.id, sessionData),
|
||||||
identityId: await encrypt(permission.identityId, iv, password),
|
identityId: await encrypt(permission.identityId, sessionData),
|
||||||
host: await encrypt(permission.host, iv, password),
|
host: await encrypt(permission.host, sessionData),
|
||||||
method: await encrypt(permission.method, iv, password),
|
method: await encrypt(permission.method, sessionData),
|
||||||
methodPolicy: await encrypt(permission.methodPolicy, iv, password),
|
methodPolicy: await encrypt(permission.methodPolicy, sessionData),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof permission.kind !== 'undefined') {
|
if (typeof permission.kind !== 'undefined') {
|
||||||
encryptedPermission.kind = await encrypt(
|
encryptedPermission.kind = await encrypt(
|
||||||
permission.kind.toString(),
|
permission.kind.toString(),
|
||||||
iv,
|
sessionData
|
||||||
password
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,8 +350,30 @@ const encryptPermission = async function (
|
|||||||
|
|
||||||
const encrypt = async function (
|
const encrypt = async function (
|
||||||
value: string,
|
value: string,
|
||||||
iv: string,
|
sessionData: BrowserSessionData
|
||||||
password: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return await CryptoHelper.encrypt(value, iv, password);
|
// v2: Use pre-derived key with AES-GCM directly
|
||||||
|
if (sessionData.vaultKey) {
|
||||||
|
const keyBytes = Buffer.from(sessionData.vaultKey, 'base64');
|
||||||
|
const iv = Buffer.from(sessionData.iv, 'base64');
|
||||||
|
|
||||||
|
const key = await crypto.subtle.importKey(
|
||||||
|
'raw',
|
||||||
|
keyBytes,
|
||||||
|
{ name: 'AES-GCM' },
|
||||||
|
false,
|
||||||
|
['encrypt']
|
||||||
|
);
|
||||||
|
|
||||||
|
const cipherText = await crypto.subtle.encrypt(
|
||||||
|
{ name: 'AES-GCM', iv },
|
||||||
|
key,
|
||||||
|
new TextEncoder().encode(value)
|
||||||
|
);
|
||||||
|
|
||||||
|
return Buffer.from(cipherText).toString('base64');
|
||||||
|
}
|
||||||
|
|
||||||
|
// v1: Use password with PBKDF2
|
||||||
|
return await CryptoHelper.encrypt(value, sessionData.iv, sessionData.vaultPassword!);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { NostrHelper } from '@common';
|
import {
|
||||||
|
backgroundLogNip07Action,
|
||||||
|
backgroundLogPermissionStored,
|
||||||
|
NostrHelper,
|
||||||
|
} from '@common';
|
||||||
import {
|
import {
|
||||||
BackgroundRequestMessage,
|
BackgroundRequestMessage,
|
||||||
checkPermissions,
|
checkPermissions,
|
||||||
@@ -67,6 +71,7 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
|
|
||||||
// Check reckless mode first
|
// Check reckless mode first
|
||||||
const recklessApprove = await shouldRecklessModeApprove(req.host);
|
const recklessApprove = await shouldRecklessModeApprove(req.host);
|
||||||
|
debug(`recklessApprove result: ${recklessApprove}`);
|
||||||
if (recklessApprove) {
|
if (recklessApprove) {
|
||||||
debug('Request auto-approved via reckless mode.');
|
debug('Request auto-approved via reckless mode.');
|
||||||
} else {
|
} else {
|
||||||
@@ -78,6 +83,7 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
req.method,
|
req.method,
|
||||||
req.params
|
req.params
|
||||||
);
|
);
|
||||||
|
debug(`permissionState result: ${permissionState}`);
|
||||||
|
|
||||||
if (permissionState === false) {
|
if (permissionState === false) {
|
||||||
throw new Error('Permission denied');
|
throw new Error('Permission denied');
|
||||||
@@ -107,17 +113,28 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
});
|
});
|
||||||
debug(response);
|
debug(response);
|
||||||
if (response === 'approve' || response === 'reject') {
|
if (response === 'approve' || response === 'reject') {
|
||||||
|
const policy = response === 'approve' ? 'allow' : 'deny';
|
||||||
await storePermission(
|
await storePermission(
|
||||||
browserSessionData,
|
browserSessionData,
|
||||||
currentIdentity,
|
currentIdentity,
|
||||||
req.host,
|
req.host,
|
||||||
req.method,
|
req.method,
|
||||||
response === 'approve' ? 'allow' : 'deny',
|
policy,
|
||||||
|
req.params?.kind
|
||||||
|
);
|
||||||
|
await backgroundLogPermissionStored(
|
||||||
|
req.host,
|
||||||
|
req.method,
|
||||||
|
policy,
|
||||||
req.params?.kind
|
req.params?.kind
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['reject', 'reject-once'].includes(response)) {
|
if (['reject', 'reject-once'].includes(response)) {
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, false, false, {
|
||||||
|
kind: req.params?.kind,
|
||||||
|
peerPubkey: req.params?.peerPubkey,
|
||||||
|
});
|
||||||
throw new Error('Permission denied');
|
throw new Error('Permission denied');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -126,46 +143,71 @@ browser.runtime.onMessage.addListener(async (message /*, sender*/) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const relays: Relays = {};
|
const relays: Relays = {};
|
||||||
|
let result: any;
|
||||||
|
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
case 'getPublicKey':
|
case 'getPublicKey':
|
||||||
return NostrHelper.pubkeyFromPrivkey(currentIdentity.privkey);
|
result = NostrHelper.pubkeyFromPrivkey(currentIdentity.privkey);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove);
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'signEvent':
|
case 'signEvent':
|
||||||
return signEvent(req.params, currentIdentity.privkey);
|
result = signEvent(req.params, currentIdentity.privkey);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
kind: req.params?.kind,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'getRelays':
|
case 'getRelays':
|
||||||
browserSessionData.relays.forEach((x) => {
|
browserSessionData.relays.forEach((x) => {
|
||||||
relays[x.url] = { read: x.read, write: x.write };
|
relays[x.url] = { read: x.read, write: x.write };
|
||||||
});
|
});
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove);
|
||||||
return relays;
|
return relays;
|
||||||
|
|
||||||
case 'nip04.encrypt':
|
case 'nip04.encrypt':
|
||||||
return await nip04Encrypt(
|
result = await nip04Encrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.plaintext
|
req.params.plaintext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'nip44.encrypt':
|
case 'nip44.encrypt':
|
||||||
return await nip44Encrypt(
|
result = await nip44Encrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.plaintext
|
req.params.plaintext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'nip04.decrypt':
|
case 'nip04.decrypt':
|
||||||
return await nip04Decrypt(
|
result = await nip04Decrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.ciphertext
|
req.params.ciphertext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
case 'nip44.decrypt':
|
case 'nip44.decrypt':
|
||||||
return await nip44Decrypt(
|
result = await nip44Decrypt(
|
||||||
currentIdentity.privkey,
|
currentIdentity.privkey,
|
||||||
req.params.peerPubkey,
|
req.params.peerPubkey,
|
||||||
req.params.ciphertext
|
req.params.ciphertext
|
||||||
);
|
);
|
||||||
|
await backgroundLogNip07Action(req.method, req.host, true, recklessApprove, {
|
||||||
|
peerPubkey: req.params.peerPubkey,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Not supported request method '${req.method}'.`);
|
throw new Error(`Not supported request method '${req.method}'.`);
|
||||||
|
|||||||