Compare commits

..

1 Commits

Author SHA1 Message Date
Matthew Raymer
6a622d20b8 feat: centralize debug logging with environment control
- Replace stray console.log statements with logger.debug() for controlled output
- Add VITE_DEBUG_LOGGING environment variable control for all debug messages
- Convert databaseUtil, PlatformServiceFactory, and WebPlatformService to use centralized logger
- Wrap Electron console.log statements with environment variable checks
- Update SQLWorker to use controlled debug messaging instead of direct console.log
- Ensure debug logging is disabled by default for production safety

All debug logging now controlled by VITE_DEBUG_LOGGING=true environment variable.
2025-07-30 10:58:11 +00:00
86 changed files with 2217 additions and 8058 deletions

View File

@@ -8,3 +8,28 @@ alwaysApply: true
✅ remove whitespace at the end of lines
✅ use npm run lint-fix to check for warnings
✅ do not use npm run dev let me handle running and supplying feedback
✅ do not add or commit for the user; let him control that process
always preview changes and commit message to use and allow me to copy and paste
✅ Preferred Commit Message Format
Short summary in the first line (concise and high-level).
Avoid long commit bodies unless truly necessary.
✅ Valued Content in Commit Messages
Specific fixes or features.
Symptoms or problems that were fixed.
Notes about tests passing or TS/linting errors being resolved (briefly).
❌ Avoid in Commit Messages
Vague terms: “improved”, “enhanced”, “better” — especially from AI.
Minor changes: small doc tweaks, one-liners, cleanup, or lint fixes.
Redundant blurbs: repeated across files or too generic.
Multiple overlapping purposes in a single commit — prefer narrow, focused commits.
Long explanations of what can be deduced from good in-line code comments.
Guiding Principle
Let code and inline documentation speak for themselves. Use commits to highlight what isn't obvious from reading the code.

View File

@@ -1,14 +0,0 @@
---
alwaysApply: true
---
# Directive for Documentation Generation
1. Produce a **small, focused set of documents** rather than an overwhelming volume.
2. Ensure the content is **maintainable and worth preserving**, so that humans
are motivated to keep it up to date.
3. Prioritize **educational value**: the documents must clearly explain the
workings of the system.
4. Avoid **shallow, generic, or filler explanations** often found in
AI-generated documentation.
5. Aim for **clarity, depth, and usefulness**, so readers gain genuine understanding.
6. Always check the local system date to determine current date.

View File

@@ -312,21 +312,3 @@ Description of current situation or problem.
**Last Updated**: 2025-07-09
**Version**: 1.0
**Maintainer**: Matthew Raymer
### Heading Uniqueness
- **Rule**: No duplicate heading content at the same level
- **Scope**: Within a single document
- **Rationale**: Maintains clear document structure and navigation
- **Example**:
```markdown
## Features ✅
### Authentication
### Authorization
## Features ❌ (Duplicate heading)
### Security
### Performance
```

View File

@@ -1,96 +1,70 @@
---
description:
globs:
description:
globs:
alwaysApply: true
---
---
description:
globs:
alwaysApply: true
---
# Time Safari Context
## Project Overview
Time Safari is an application designed to foster community building through gifts,
gratitude, and collaborative projects. The app should make it extremely easy and
intuitive for users of any age and capability to recognize contributions, build
trust networks, and organize collective action. It is built on services that
preserve privacy and data sovereignty.
Time Safari is an application designed to foster community building through gifts, gratitude, and collaborative projects. The app should make it extremely easy and intuitive for users of any age and capability to recognize contributions, build trust networks, and organize collective action. It is built on services that preserve privacy and data sovereignty.
The ultimate goals of Time Safari are two-fold:
1. **Connect** Make it easy, rewarding, and non-threatening for people to
connect with others who have similar interests, and to initiate activities
together. This helps people accomplish and learn from other individuals in
less-structured environments; moreover, it helps them discover who they want
to continue to support and with whom they want to maintain relationships.
1. **Connect** Make it easy, rewarding, and non-threatening for people to connect with others who have similar interests, and to initiate activities together. This helps people accomplish and learn from other individuals in less-structured environments; moreover, it helps them discover who they want to continue to support and with whom they want to maintain relationships.
2. **Reveal** Widely advertise the great support and rewards that are being
given and accepted freely, especially non-monetary ones. Using visuals and text,
display the kind of impact that gifts are making in the lives of others. Also
show useful and engaging reports of project statistics and personal accomplishments.
2. **Reveal** Widely advertise the great support and rewards that are being given and accepted freely, especially non-monetary ones. Using visuals and text, display the kind of impact that gifts are making in the lives of others. Also show useful and engaging reports of project statistics and personal accomplishments.
## Core Approaches
Time Safari should help everyday users build meaningful connections and organize
collective efforts by:
Time Safari should help everyday users build meaningful connections and organize collective efforts by:
1. **Recognizing Contributions**: Creating permanent, verifiable records of gifts
and contributions people give to each other and their communities.
1. **Recognizing Contributions**: Creating permanent, verifiable records of gifts and contributions people give to each other and their communities.
2. **Facilitating Collaboration**: Making it ridiculously easy for people to ask
for or propose help on projects and interests that matter to them.
2. **Facilitating Collaboration**: Making it ridiculously easy for people to ask for or propose help on projects and interests that matter to them.
3. **Building Trust Networks**: Enabling users to maintain their network and activity
visibility. Developing reputation through verified contributions and references,
which can be selectively shown to others outside the network.
3. **Building Trust Networks**: Enabling users to maintain their network and activity visibility. Developing reputation through verified contributions and references, which can be selectively shown to others outside the network.
4. **Preserving Privacy**: Ensuring personal identifiers are only shared with
explicitly authorized contacts, allowing private individuals including children
to participate safely.
4. **Preserving Privacy**: Ensuring personal identifiers are only shared with explicitly authorized contacts, allowing private individuals including children to participate safely.
5. **Engaging Content**: Displaying people's records in compelling stories, and
highlighting those projects that are lifting people's lives long-term, both in
physical support and in emotional-spiritual-creative thriving.
5. **Engaging Content**: Displaying people's records in compelling stories, and highlighting those projects that are lifting people's lives long-term, both in physical support and in emotional-spiritual-creative thriving.
## Technical Foundation
This application is built on a privacy-preserving claims architecture (via
endorser.ch) with these key characteristics:
This application is built on a privacy-preserving claims architecture (via endorser.ch) with these key characteristics:
- **Decentralized Identifiers (DIDs)**: User identities are based on public/private
key pairs stored on their devices
- **Cryptographic Verification**: All claims and confirmations are
cryptographically signed
- **User-Controlled Visibility**: Users explicitly control who can see their
identifiers and data
- **Merkle-Chained Claims**: Claims are cryptographically chained for verification
and integrity
- **Native and Web App**: Works on Capacitor (iOS, Android), Desktop (Electron
and CEFPython), and web browsers
- **Decentralized Identifiers (DIDs)**: User identities are based on public/private key pairs stored on their devices
- **Cryptographic Verification**: All claims and confirmations are cryptographically signed
- **User-Controlled Visibility**: Users explicitly control who can see their identifiers and data
- **Merkle-Chained Claims**: Claims are cryptographically chained for verification and integrity
- **Native and Web App**: Works on Capacitor (iOS, Android), Desktop (Electron and CEFPython), and web browsers
## User Journey
The typical progression of usage follows these stages:
1. **Gratitude & Recognition**: Users begin by expressing and recording gratitude
for gifts received, building a foundation of acknowledgment.
1. **Gratitude & Recognition**: Users begin by expressing and recording gratitude for gifts received, building a foundation of acknowledgment.
2. **Project Proposals**: Users propose projects and ideas, reaching out to connect
with others who share similar interests.
2. **Project Proposals**: Users propose projects and ideas, reaching out to connect with others who share similar interests.
3. **Action Triggers**: Offers of help serve as triggers and motivations to execute
proposed projects, moving from ideas to action.
3. **Action Triggers**: Offers of help serve as triggers and motivations to execute proposed projects, moving from ideas to action.
## Context for LLM Development
When developing new functionality for Time Safari, consider these design principles:
1. **Accessibility First**: Features should be usable by non-technical users with
minimal learning curve.
1. **Accessibility First**: Features should be usable by non-technical users with minimal learning curve.
2. **Privacy by Design**: All features must respect user privacy and data sovereignty.
3. **Progressive Enhancement**: Core functionality should work across all devices,
with richer experiences where supported.
3. **Progressive Enhancement**: Core functionality should work across all devices, with richer experiences where supported.
4. **Voluntary Collaboration**: The system should enable but never coerce participation.
@@ -98,40 +72,31 @@ with richer experiences where supported.
6. **Network Effects**: Consider how features scale as more users join the platform.
7. **Low Resource Requirements**: The system should be lightweight enough to run
on inexpensive devices users already own.
7. **Low Resource Requirements**: The system should be lightweight enough to run on inexpensive devices users already own.
## Use Cases to Support
LLM development should focus on enhancing these key use cases:
1. **Community Building**: Tools that help people find others with shared
interests and values.
1. **Community Building**: Tools that help people find others with shared interests and values.
2. **Project Coordination**: Features that make it easy to propose collaborative
projects and to submit suggestions and offers to existing ones.
2. **Project Coordination**: Features that make it easy to propose collaborative projects and to submit suggestions and offers to existing ones.
3. **Reputation Building**: Methods for users to showcase their contributions
and reliability, in contexts where they explicitly reveal that information.
3. **Reputation Building**: Methods for users to showcase their contributions and reliability, in contexts where they explicitly reveal that information.
4. **Governance Experimentation**: Features that facilitate decision-making and
collective governance.
4. **Governance Experimentation**: Features that facilitate decision-making and collective governance.
## Constraints
When developing new features, be mindful of these constraints:
1. **Privacy Preservation**: User identifiers must remain private except when
explicitly shared.
1. **Privacy Preservation**: User identifiers must remain private except when explicitly shared.
2. **Platform Limitations**: Features must work within the constraints of the target
app platforms, while aiming to leverage the best platform technology available.
2. **Platform Limitations**: Features must work within the constraints of the target app platforms, while aiming to leverage the best platform technology available.
3. **Endorser API Limitations**: Backend features are constrained by the endorser.ch
API capabilities.
3. **Endorser API Limitations**: Backend features are constrained by the endorser.ch API capabilities.
4. **Performance on Low-End Devices**: The application should remain performant
on older/simpler devices.
4. **Performance on Low-End Devices**: The application should remain performant on older/simpler devices.
5. **Offline-First When Possible**: Key functionality should work offline when feasible.
@@ -151,14 +116,12 @@ on older/simpler devices.
## Project Architecture
- The application must work on web browser, PWA (Progressive Web Application),
desktop via Electron, and mobile via Capacitor
- The application must work on web browser, PWA (Progressive Web Application), desktop via Electron, and mobile via Capacitor
- Building for each platform is managed via Vite
## Core Development Principles
### DRY development
- **Code Reuse**
- Extract common functionality into utility functions
- Create reusable components for UI patterns
@@ -214,24 +177,14 @@ on older/simpler devices.
- Use shared test configurations
- Create reusable test helpers
- Implement consistent test patterns
- F.I.R.S.T. (for Unit Tests)
F Fast
I Independent
R Repeatable
S Self-validating
T Timely
### SOLID Principles
- **Single Responsibility**: Each class/component should have only one reason to
change
- **Single Responsibility**: Each class/component should have only one reason to change
- Components should focus on one specific feature (e.g., QR scanning, DID management)
- Services should handle one type of functionality (e.g., platform services,
crypto services)
- Services should handle one type of functionality (e.g., platform services, crypto services)
- Utilities should provide focused helper functions
- **Open/Closed**: Software entities should be open for extension but closed for
modification
- **Open/Closed**: Software entities should be open for extension but closed for modification
- Use interfaces for service definitions
- Implement plugin architecture for platform-specific features
- Allow component behavior extension through props and events
@@ -252,7 +205,6 @@ on older/simpler devices.
- Implement factory patterns for component creation
### Law of Demeter
- Components should only communicate with immediate dependencies
- Avoid chaining method calls (e.g., `this.service.getUser().getProfile().getName()`)
- Use mediator patterns for complex component interactions
@@ -260,7 +212,6 @@ on older/simpler devices.
- Keep component communication through defined events and props
### Composition over Inheritance
- Prefer building components through composition
- Use mixins for shared functionality
- Implement feature toggles through props
@@ -268,7 +219,6 @@ on older/simpler devices.
- Use service composition for complex features
### Interface Segregation
- Define clear interfaces for services
- Keep component APIs minimal and focused
- Split large interfaces into smaller, specific ones
@@ -276,7 +226,6 @@ on older/simpler devices.
- Implement role-based interfaces for different use cases
### Fail Fast
- Validate inputs early in the process
- Use TypeScript strict mode
- Implement comprehensive error handling
@@ -284,7 +233,6 @@ on older/simpler devices.
- Use assertions for development-time validation
### Principle of Least Astonishment
- Follow Vue.js conventions consistently
- Use familiar naming patterns
- Implement predictable component behaviors
@@ -292,7 +240,6 @@ on older/simpler devices.
- Keep UI interactions intuitive
### Information Hiding
- Encapsulate implementation details
- Use private class members
- Implement proper access modifiers
@@ -300,7 +247,6 @@ on older/simpler devices.
- Use TypeScript's access modifiers effectively
### Single Source of Truth
- Use Pinia for state management
- Maintain one source for user data
- Centralize configuration management
@@ -308,9 +254,23 @@ on older/simpler devices.
- Implement proper state synchronization
### Principle of Least Privilege
- Implement proper access control
- Use minimal required permissions
- Follow privacy-by-design principles
- Restrict component access to necessary data
- Implement proper authentication/authorization
### Continuous Integration/Continuous Deployment (CI/CD)
- Automated testing on every commit
- Consistent build process across platforms
- Automated deployment pipelines
- Quality gates for code merging
- Environment-specific configurations
This expanded documentation provides:
1. Clear principles for development
2. Practical implementation guidelines
3. Real-world examples
4. TypeScript integration
5. Best practices for Time Safari

View File

@@ -1,122 +0,0 @@
---
alwaysApply: true
---
# Directive: Peaceful Co-Existence with Developers
## 1) Version-Control Ownership
* **MUST NOT** run `git add`, `git commit`, or any write action.
* **MUST** leave staging/committing to the developer.
## 2) Source of Truth for Commit Text
* **MUST** derive messages **only** from:
* files **staged** for commit (primary), and
* files **awaiting staging** (context).
* **MUST** use the **diffs** to inform content.
* **MUST NOT** invent changes or imply work not present in diffs.
## 3) Mandatory Preview Flow
* **ALWAYS** present, before any real commit:
* file list + brief per-file notes,
* a **draft commit message** (copy-paste ready),
* nothing auto-applied.
---
# Commit Message Format (Normative)
## A. Subject Line (required)
```
<type>(<scope>)<!>: <summary>
```
* **type** (lowercase, Conventional Commits): `feat|fix|refactor|perf|docs|test|build|chore|ci|revert`
* **scope**: optional module/package/area (e.g., `api`, `ui/login`, `db`)
* **!**: include when a breaking change is introduced
* **summary**: imperative mood, ≤ 72 chars, no trailing period
**Examples**
* `fix(api): handle null token in refresh path`
* `feat(ui/login)!: require OTP after 3 failed attempts`
## B. Body (optional, when it adds non-obvious value)
* One blank line after subject.
* Wrap at \~72 chars.
* Explain **what** and **why**, not line-by-line “how”.
* Include brief notes like tests passing or TS/lint issues resolved **only if material**.
**Body checklist**
* [ ] Problem/symptom being addressed
* [ ] High-level approach or rationale
* [ ] Risks, tradeoffs, or follow-ups (if any)
## C. Footer (optional)
* Issue refs: `Closes #123`, `Refs #456`
* Breaking change (alternative to `!`):
`BREAKING CHANGE: <impact + migration note>`
* Authors: `Co-authored-by: Name <email>`
* Security: `CVE-XXXX-YYYY: <short note>` (if applicable)
---
## Content Guidance
### Include (when relevant)
* Specific fixes/features delivered
* Symptoms/problems fixed
* Brief note that tests passed or TS/lint errors resolved
### Avoid
* Vague: *improved, enhanced, better*
* Trivialities: tiny docs, one-liners, pure lint cleanups (separate, focused commits if needed)
* Redundancy: generic blurbs repeated across files
* Multi-purpose dumps: keep commits **narrow and focused**
* Long explanations that good inline code comments already cover
**Guiding Principle:** Let code and inline docs speak. Use commits to highlight what isnt obvious.
---
# Copy-Paste Templates
## Minimal (no body)
```text
<type>(<scope>): <summary>
```
## Standard (with body & footer)
```text
<type>(<scope>)<!>: <summary>
<why-this-change?>
<what-it-does?>
<risks-or-follow-ups?>
Closes #<id>
BREAKING CHANGE: <impact + migration>
Co-authored-by: <Name> <email>
```
---
# Assistant Output Checklist (before showing the draft)
* [ ] List changed files + 12 line notes per file
* [ ] Provide **one** focused draft message (subject/body/footer)
* [ ] Subject ≤ 72 chars, imperative mood, correct `type(scope)!` syntax
* [ ] Body only if it adds non-obvious value
* [ ] No invented changes; aligns strictly with diffs
* [ ] Render as a single copy-paste block for the developer

File diff suppressed because it is too large Load Diff

View File

@@ -12,27 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deep link URLs (and other prod settings)
- Error in BVC begin view
## [1.0.6] - 2025.08.09
### Fixed
- Deep link errors where none would validate
## [1.0.5] - 2025.07.24
### Fixed
- Export & import of contacts corrupted contact methods
## [1.0.4] - 2025.07.20 - 002f2407208d56cc59c0aa7c880535ae4cbace8b
### Fixed
- Deep link for invite-one-accept
## [1.0.3] - 2025.07.12 - a9a8ba217cd6015321911e98e6843e988dc2c4ae
## [Unreleased]
### Changed
- Photo is pinned to profile mode
### Fixed
- Deep link URLs (and other prod settings)
- Error in BVC begin view
## [1.0.2] - 2025.06.20 - 276e0a741bc327de3380c4e508cccb7fee58c06d

View File

@@ -113,11 +113,10 @@ appearing in shared links during development.
-**Type-Safe Configuration**: Full TypeScript support
### Quick Reference
```typescript
// For sharing functionality (environment-specific)
import { APP_SERVER } from "@/constants/app";
const shareLink = `${APP_SERVER}/deep-link/claim/123`;
// For sharing functionality (always production)
import { PROD_SHARE_DOMAIN } from "@/constants/app";
const shareLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/123`;
// For internal operations (environment-specific)
import { APP_SERVER } from "@/constants/app";
@@ -125,7 +124,6 @@ const apiUrl = `${APP_SERVER}/api/claim/123`;
```
### Documentation
- [Domain Configuration System](docs/domain-configuration.md) - Complete guide
- [Constants and Configuration](src/constants/app.ts) - Core constants
@@ -137,7 +135,7 @@ See [TESTING.md](test-playwright/TESTING.md) for detailed test instructions.
Application icons are in the `assets` directory, processed by the `capacitor-assets` command.
To add a Font Awesome icon, add to fontawesome.ts and reference with `font-awesome` element and `icon` attribute with the hyphenated name.
To add a Font Awesome icon, add to main.ts and reference with `font-awesome` element and `icon` attribute with the hyphenated name.
## Other

View File

@@ -31,8 +31,8 @@ android {
applicationId "app.timesafari.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 39
versionName "1.0.6"
versionCode 35
versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
@@ -64,14 +64,6 @@ android {
}
}
}
packagingOptions {
jniLibs {
pickFirsts += ['**/lib/x86_64/libbarhopper_v3.so', '**/lib/x86_64/libimage_processing_util_jni.so', '**/lib/x86_64/libsqlcipher.so']
}
}
// Configure for 16 KB page size compatibility
// Enable bundle builds (without which it doesn't work right for bundleDebug vs bundleRelease)
bundle {

View File

@@ -57,14 +57,13 @@
]
},
"android": {
"allowMixedContent": true,
"allowMixedContent": false,
"captureInput": true,
"webContentsDebuggingEnabled": false,
"allowNavigation": [
"*.timesafari.app",
"*.jsdelivr.net",
"api.endorser.ch",
"10.0.2.2:3000"
"api.endorser.ch"
]
},
"electron": {

View File

@@ -7,7 +7,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.12.0'
classpath 'com.android.tools.build:gradle:8.11.1'
classpath 'com.google.gms:google-services:4.4.0'
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -20,4 +20,4 @@ org.gradle.jvmargs=-Xmx1536m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.suppressUnsupportedCompileSdk=36
android.suppressUnsupportedCompileSdk=34

View File

@@ -1,7 +1,7 @@
ext {
minSdkVersion = 22
compileSdkVersion = 36
targetSdkVersion = 36
compileSdkVersion = 34
targetSdkVersion = 34
androidxActivityVersion = '1.8.0'
androidxAppCompatVersion = '1.6.1'
androidxCoordinatorLayoutVersion = '1.2.0'

View File

@@ -57,14 +57,13 @@
]
},
"android": {
"allowMixedContent": true,
"allowMixedContent": false,
"captureInput": true,
"webContentsDebuggingEnabled": false,
"allowNavigation": [
"*.timesafari.app",
"*.jsdelivr.net",
"api.endorser.ch",
"10.0.2.2:3000"
"api.endorser.ch"
]
},
"electron": {

View File

@@ -1,338 +0,0 @@
# Environment Variable Precedence and API Configuration
**Date:** August 4, 2025
**Author:** Matthew Raymer
## Overview
This document explains the order of precedence for environment variables in the
TimeSafari project, how `.env` files are used, and the API configuration scheme
for different environments.
## Order of Precedence (Highest to Lowest)
### 1. Shell Script Overrides (Highest Priority)
Shell scripts can override environment variables for platform-specific needs:
```bash
# scripts/common.sh - setup_build_env()
if [ "$BUILD_MODE" = "development" ]; then
export VITE_DEFAULT_ENDORSER_API_SERVER="http://localhost:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://localhost:3000"
fi
```
### 2. Platform-Specific Overrides (High Priority)
Platform-specific build scripts can override for mobile development:
```bash
# scripts/build-android.sh
if [ "$BUILD_MODE" = "development" ]; then
export VITE_DEFAULT_ENDORSER_API_SERVER="http://10.0.2.2:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://10.0.2.2:3000"
fi
```
### 3. Environment-Specific .env Files (Medium Priority)
Environment-specific `.env` files provide environment-specific defaults:
```bash
# .env.development, .env.test, .env.production
VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000
VITE_DEFAULT_PARTNER_API_SERVER=http://localhost:3000
```
### 4. Fallback .env File (Low Priority)
General `.env` file provides project-wide defaults:
```bash
# .env (if exists)
VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000
```
### 5. app.ts Constants (Lowest Priority - Fallback)
Hardcoded constants in `src/constants/app.ts` provide safety nets:
```typescript
export const DEFAULT_ENDORSER_API_SERVER =
import.meta.env.VITE_DEFAULT_ENDORSER_API_SERVER ||
AppString.PROD_ENDORSER_API_SERVER;
```
## Build Process Flow
### 1. Shell Scripts Set Base Values
```bash
# scripts/common.sh
setup_build_env() {
if [ "$BUILD_MODE" = "development" ]; then
export VITE_DEFAULT_ENDORSER_API_SERVER="http://localhost:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://localhost:3000"
fi
}
```
### 2. Platform-Specific Overrides
```bash
# scripts/build-android.sh
if [ "$BUILD_MODE" = "development" ]; then
export VITE_DEFAULT_ENDORSER_API_SERVER="http://10.0.2.2:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://10.0.2.2:3000"
fi
```
### 3. Load .env Files
```bash
# scripts/build-web.sh
local env_file=".env.$BUILD_MODE" # .env.development, .env.test, .env.production
if [ -f "$env_file" ]; then
load_env_file "$env_file"
fi
# Fallback to .env
if [ -f ".env" ]; then
load_env_file ".env"
fi
```
### 4. Vite Processes Environment
```typescript
// vite.config.common.mts
dotenv.config(); // Loads .env files
```
### 5. Application Uses Values
```typescript
// src/constants/app.ts
export const DEFAULT_ENDORSER_API_SERVER =
import.meta.env.VITE_DEFAULT_ENDORSER_API_SERVER ||
AppString.PROD_ENDORSER_API_SERVER;
```
## API Configuration Scheme
### Environment Configuration Summary
| Environment | Endorser API (Claims) | Partner API | Image API |
|-------------|----------------------|-------------|-----------|
| **Development** | `http://localhost:3000` | `http://localhost:3000` | `https://image-api.timesafari.app` |
| **Test** | `https://test-api.endorser.ch` | `https://test-partner-api.endorser.ch` | `https://image-api.timesafari.app` |
| **Production** | `https://api.endorser.ch` | `https://partner-api.endorser.ch` | `https://image-api.timesafari.app` |
### Mobile Development Overrides
#### Android Development
- **Emulator**: `http://10.0.2.2:3000` (Android emulator default)
- **Physical Device**: `http://{CUSTOM_IP}:3000` (Custom IP for physical device)
#### iOS Development
- **Simulator**: `http://localhost:3000` (iOS simulator default)
- **Physical Device**: `http://{CUSTOM_IP}:3000` (Custom IP for physical device)
## .env File Structure
### .env.development
```bash
# ==========================================
# DEVELOPMENT ENVIRONMENT CONFIGURATION
# ==========================================
# API Server Configuration:
# - Endorser API (Claims): Local development server
# - Partner API: Local development server (aligned with claims)
# - Image API: Test server (shared for development)
# ==========================================
# Only the variables that start with VITE_ are seen in the application import.meta.env in Vue.
# iOS doesn't like spaces in the app title.
TIME_SAFARI_APP_TITLE="TimeSafari_Dev"
VITE_APP_SERVER=http://localhost:8080
# This is the claim ID for actions in the BVC project, with the JWT ID on this environment (not production).
VITE_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01HWE8FWHQ1YGP7GFZYYPS272F
# API Servers (Development - Local)
VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000
VITE_DEFAULT_PARTNER_API_SERVER=http://localhost:3000
# Image API (Test server for development)
VITE_DEFAULT_IMAGE_API_SERVER=https://test-image-api.timesafari.app
# Push Server (disabled for localhost)
#VITE_DEFAULT_PUSH_SERVER... can't be set up with localhost domain
# Feature Flags
VITE_PASSKEYS_ENABLED=true
```
### .env.test
```bash
# ==========================================
# TEST ENVIRONMENT CONFIGURATION
# ==========================================
# API Server Configuration:
# - Endorser API (Claims): Test server
# - Partner API: Test server (aligned with claims)
# - Image API: Test server
# ==========================================
# Only the variables that start with VITE_ are seen in the application import.meta.env in Vue.
# iOS doesn't like spaces in the app title.
TIME_SAFARI_APP_TITLE="TimeSafari_Test"
VITE_APP_SERVER=https://test.timesafari.app
# This is the claim ID for actions in the BVC project, with the JWT ID on this environment (not production).
VITE_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01HWE8FWHQ1YGP7GFZYYPS272F
# API Servers (Test Environment)
VITE_DEFAULT_ENDORSER_API_SERVER=https://test-api.endorser.ch
VITE_DEFAULT_PARTNER_API_SERVER=https://test-partner-api.endorser.ch
# Image API (Test server)
VITE_DEFAULT_IMAGE_API_SERVER=https://test-image-api.timesafari.app
# Push Server (Test)
VITE_DEFAULT_PUSH_SERVER=https://test.timesafari.app
# Feature Flags
VITE_PASSKEYS_ENABLED=true
```
### .env.production
```bash
# ==========================================
# PRODUCTION ENVIRONMENT CONFIGURATION
# ==========================================
# API Server Configuration:
# - Endorser API (Claims): Production server
# - Partner API: Production server (aligned with claims)
# - Image API: Production server
# ==========================================
# Only the variables that start with VITE_ are seen in the application import.meta.env in Vue.
# App Server
VITE_APP_SERVER=https://timesafari.app
# This is the claim ID for actions in the BVC project.
VITE_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01GXYPFF7FA03NXKPYY142PY4H
# API Servers (Production Environment)
VITE_DEFAULT_ENDORSER_API_SERVER=https://api.endorser.ch
VITE_DEFAULT_PARTNER_API_SERVER=https://partner-api.endorser.ch
# Image API (Production server)
VITE_DEFAULT_IMAGE_API_SERVER=https://image-api.timesafari.app
# Push Server (Production)
VITE_DEFAULT_PUSH_SERVER=https://timesafari.app
```
## Key Principles
### 1. API Alignment
- **Partner API** values follow the same pattern as **Claim API** (Endorser API)
- Both APIs use the same environment-specific endpoints
- This ensures consistency across the application
### 2. Platform Flexibility
- Shell scripts can override for platform-specific needs
- Android emulator uses `10.0.2.2:3000`
- iOS simulator uses `localhost:3000`
- Physical devices use custom IP addresses
### 3. Environment Isolation
- Each environment has its own `.env` file
- Test environment uses test APIs
- Development environment uses local APIs
- Production environment uses production APIs
### 4. Safety Nets
- Hardcoded constants in `app.ts` provide fallbacks
- Multiple layers of configuration prevent failures
- Clear precedence order ensures predictable behavior
## Usage Examples
### Development Build
```bash
# Uses .env.development + shell script overrides
npm run build:web -- --mode development
```
### Test Build
```bash
# Uses .env.test + shell script overrides
npm run build:web -- --mode test
```
### Production Build
```bash
# Uses .env.production + shell script overrides
npm run build:web -- --mode production
```
### Android Development
```bash
# Uses .env.development + Android-specific overrides
./scripts/build-android.sh --dev
```
### iOS Development
```bash
# Uses .env.development + iOS-specific overrides
./scripts/build-ios.sh --dev
```
## Troubleshooting
### Environment Variable Debugging
```bash
# Show current environment variables
./scripts/build-web.sh --env
# Check specific variable
echo $VITE_DEFAULT_ENDORSER_API_SERVER
```
### Common Issues
1. **Wrong API Server**: Check if shell script overrides are correct
2. **Missing .env File**: Ensure environment-specific .env file exists
3. **Platform-Specific Issues**: Verify platform overrides in build scripts
4. **Vite Not Loading**: Check if `dotenv.config()` is called
### Validation
```bash
# Validate environment configuration
npm run test-env
```
## Best Practices
1. **Always use environment-specific .env files** for different environments
2. **Keep shell script overrides minimal** and platform-specific
3. **Document API alignment** in .env file headers
4. **Use hardcoded fallbacks** in `app.ts` for safety
5. **Test all environments** before deployment
6. **Validate configuration** with test scripts
## Related Documentation
- [Build System Overview](../build-system/README.md)
- [Android Custom API IP](../platforms/android-custom-api-ip.md)
- [API Configuration](../api-configuration.md)
- [Environment Setup](../environment-setup.md)

View File

@@ -1,322 +0,0 @@
# Mobile Custom API IP Configuration
**Author**: Matthew Raymer
**Date**: 2025-01-27
**Status**: ✅ **COMPLETE** - Custom API IP support for physical device development
## Overview
When deploying TimeSafari to physical Android devices during development, you may need to specify a custom IP address for the claim API server. This is necessary because physical devices cannot access `localhost` or `10.0.2.2` (Android emulator IP) to reach your local development server.
## Problem
During mobile development:
- **Android Emulator**: Uses `10.0.2.2:3000` to access host machine's localhost (Android emulator default)
- **iOS Simulator**: Uses `localhost:3000` to access host machine's localhost (iOS simulator default)
- **Physical Devices**: Cannot access `localhost` or `10.0.2.2` - needs actual IP address for network access
## Solution
The mobile build system uses platform-appropriate defaults and supports specifying a custom IP address for the claim API server when building for physical devices:
- **Android**: Defaults to `10.0.2.2:3000` for emulator development
- **iOS**: Uses Capacitor default (`localhost:3000`) for simulator development
## Usage
### Command Line Usage
```bash
# Android - Default behavior (uses 10.0.2.2 for emulator)
./scripts/build-android.sh --dev
# Android - Custom IP for physical device
./scripts/build-android.sh --dev --api-ip 192.168.1.100
# iOS - Default behavior (uses localhost for simulator)
./scripts/build-ios.sh --dev
# iOS - Custom IP for physical device
./scripts/build-ios.sh --dev --api-ip 192.168.1.100
# Test environment with custom IP
./scripts/build-android.sh --test --api-ip 192.168.1.100
./scripts/build-ios.sh --test --api-ip 192.168.1.100
# Build and auto-run with custom IP
./scripts/build-android.sh --dev --api-ip 192.168.1.100 --auto-run
./scripts/build-ios.sh --dev --api-ip 192.168.1.100 --auto-run
```
### NPM Scripts
```bash
# Android - Default development build (uses 10.0.2.2 for emulator)
npm run build:android:dev
# Android - Development build with custom IP (requires IP parameter)
npm run build:android:dev:custom 192.168.1.100
# iOS - Default development build (uses localhost for simulator)
npm run build:ios:dev
# iOS - Development build with custom IP (requires IP parameter)
npm run build:ios:dev:custom 192.168.1.100
# Test builds with custom IP (requires IP parameter)
npm run build:android:test:custom 192.168.1.100
npm run build:ios:test:custom 192.168.1.100
# Development build + auto-run with custom IP
npm run build:android:dev:run:custom 192.168.1.100
npm run build:ios:dev:run:custom 192.168.1.100
# Test build + auto-run with custom IP
npm run build:android:test:run:custom 192.168.1.100
npm run build:ios:test:run:custom 192.168.1.100
```
## Examples
### Scenario 1: Development on Simulator/Emulator (Default)
```bash
# Android - Default behavior - uses 10.0.2.2 for emulator
npm run build:android:dev
# iOS - Default behavior - uses localhost for simulator
npm run build:ios:dev
# Build and immediately run on simulator/emulator
npm run build:android:dev:run
npm run build:ios:dev:run
```
### Scenario 2: Development on Physical Device
```bash
# Your development server is running on 192.168.1.50:3000
npm run build:android:dev:custom 192.168.1.50
npm run build:ios:dev:custom 192.168.1.50
# Build and immediately run on device
npm run build:android:dev:run:custom 192.168.1.50
npm run build:ios:dev:run:custom 192.168.1.50
```
### Scenario 3: Testing on Physical Device
```bash
# Your test server is running on 192.168.1.75:3000
npm run build:android:test:custom 192.168.1.75
npm run build:ios:test:custom 192.168.1.75
# Build and immediately run on device
npm run build:android:test:run:custom 192.168.1.75
npm run build:ios:test:run:custom 192.168.1.75
```
### Scenario 4: Direct Script Usage
```bash
# Default behavior (uses platform-appropriate defaults)
./scripts/build-android.sh --dev --studio
./scripts/build-ios.sh --dev --studio
# Custom IP for physical device
./scripts/build-android.sh --dev --api-ip 192.168.1.100 --studio
./scripts/build-ios.sh --dev --api-ip 192.168.1.100 --studio
```
## How It Works
### Environment Variable Override
The build system handles API server configuration as follows:
1. **Android default**: Uses Android emulator default (`http://10.0.2.2:3000`)
2. **iOS default**: Uses Capacitor default (`http://localhost:3000`)
3. **Custom IP specified**: Overrides with `http://<custom-ip>:3000` for physical device development
4. **Maintains other APIs**: Image and Partner APIs remain at production URLs
5. **Logs the configuration**: Shows which IP is being used in build logs
### Build Process
```bash
# Development mode with Android emulator default (10.0.2.2)
export VITE_DEFAULT_ENDORSER_API_SERVER="http://10.0.2.2:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://10.0.2.2:3000"
npm run build:capacitor -- --mode development
# Development mode with iOS simulator default (localhost)
export VITE_DEFAULT_ENDORSER_API_SERVER="http://localhost:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://localhost:3000"
npm run build:capacitor -- --mode development
# Development mode with custom IP
export VITE_DEFAULT_ENDORSER_API_SERVER="http://192.168.1.100:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://192.168.1.100:3000"
npm run build:capacitor -- --mode development
```
### Default Behavior
- **Android (no `--api-ip`)**: Uses Android emulator default (`10.0.2.2:3000`)
- **iOS (no `--api-ip`)**: Uses Capacitor default (`localhost:3000`)
- **Custom IP specified**: Uses provided IP address for physical device development
- **Invalid IP format**: Build will fail with clear error message
- **Network unreachable**: App will show connection errors at runtime
## Finding Your IP Address
### On Linux/macOS
```bash
# Find your local IP address
ifconfig | grep "inet " | grep -v 127.0.0.1
# or
ip addr show | grep "inet " | grep -v 127.0.0.1
```
### On Windows
```bash
# Find your local IP address
ipconfig | findstr "IPv4"
```
### Common Network Patterns
- **Home WiFi**: Usually `192.168.1.x` or `192.168.0.x`
- **Office Network**: May be `10.x.x.x` or `172.16.x.x`
- **Mobile Hotspot**: Often `192.168.43.x`
## Troubleshooting
### Common Issues
#### 1. Device Cannot Connect to API
```bash
# Check if your IP is accessible
ping 192.168.1.100
# Check if port 3000 is open
telnet 192.168.1.100 3000
```
#### 2. Build Fails with Invalid IP
```bash
# Ensure IP format is correct
./scripts/build-android.sh --dev --api-ip 192.168.1.100 # ✅ Correct
./scripts/build-android.sh --dev --api-ip localhost # ❌ Wrong
```
#### 3. Firewall Blocking Connection
```bash
# Check firewall settings
sudo ufw status # Ubuntu/Debian
sudo firewall-cmd --list-all # CentOS/RHEL
```
### Debug Mode
```bash
# Enable verbose logging
./scripts/build-android.sh --dev --api-ip 192.168.1.100 --verbose
```
## Best Practices
### 1. Use Consistent IP Addresses
```bash
# Create aliases for common development scenarios
alias build-dev="npm run build:android:dev:custom 192.168.1.100"
alias build-test="npm run build:android:test:custom 192.168.1.100"
```
### 2. Document Your Setup
```bash
# Create a development setup file
echo "DEV_API_IP=192.168.1.100" > .env.development
echo "TEST_API_IP=192.168.1.100" >> .env.development
```
### 3. Network Security
- Ensure your development server is only accessible on your local network
- Use HTTPS in production environments
- Consider VPN for remote development scenarios
### 4. Team Development
```bash
# Share IP configuration with team
# Add to .env.example
DEV_API_IP=192.168.1.100
TEST_API_IP=192.168.1.100
```
## Integration with CI/CD
### Environment Variables
```yaml
# Example CI/CD configuration
variables:
DEV_API_IP: "192.168.1.100"
TEST_API_IP: "192.168.1.100"
build:
script:
- npm run build:android:dev:custom $DEV_API_IP
```
### Automated Testing
```bash
# Test with different IP configurations
npm run build:android:test:custom 192.168.1.100
npm run build:android:test:custom 10.0.0.100
```
## Migration from Legacy
### Previous Workarounds
Before this feature, developers had to:
1. Manually edit environment files
2. Use different build configurations
3. Modify source code for IP addresses
### New Approach
```bash
# Simple one-liner
npm run build:android:dev:custom 192.168.1.100
```
## Future Enhancements
### Planned Features
1. **IP Validation**: Automatic IP format validation
2. **Network Discovery**: Auto-detect available IP addresses
3. **Port Configuration**: Support for custom ports
4. **Multiple APIs**: Support for custom IPs for all API endpoints
### Integration Opportunities
1. **Docker Integration**: Automatic IP detection in containerized environments
2. **Network Profiles**: Save and reuse common network configurations
3. **Hot Reload**: Automatic rebuild when IP changes
---
**Status**: Complete and ready for production use
**Last Updated**: 2025-01-27
**Version**: 1.0
**Maintainer**: Matthew Raymer

View File

@@ -1,84 +0,0 @@
# Contact Sharing - URL Solution
## Overview
Simple implementation to switch ContactQRScanShowView from copying QR value (CSV) to copying a URL for better user experience.
## Problem
The ContactQRScanShowView was copying QR value (CSV content) to clipboard instead of a URL, making contact sharing less user-friendly.
## Solution
Updated the `onCopyUrlToClipboard()` method in ContactQRScanShowView.vue to generate and copy a URL instead of the QR value.
## Changes Made
### ContactQRScanShowView.vue
**Added Imports:**
```typescript
import { generateEndorserJwtUrlForAccount } from "../libs/endorserServer";
import { Account } from "@/db/tables/accounts";
```
**Updated Method:**
```typescript
async onCopyUrlToClipboard() {
try {
// Generate URL for sharing
const account = (await libsUtil.retrieveFullyDecryptedAccount(
this.activeDid,
)) as Account;
const jwtUrl = await generateEndorserJwtUrlForAccount(
account,
this.isRegistered,
this.givenName,
this.profileImageUrl,
true,
);
// Copy the URL to clipboard
useClipboard()
.copy(jwtUrl)
.then(() => {
this.notify.toast(
"Copied",
NOTIFY_QR_URL_COPIED.message,
QR_TIMEOUT_MEDIUM,
);
});
} catch (error) {
logger.error("Failed to generate contact URL:", error);
this.notify.error("Failed to generate contact URL. Please try again.");
}
}
```
## Benefits
1. **Better UX**: Recipients can click the URL to add contact directly
2. **Consistency**: Both ContactQRScanShowView and ContactQRScanFullView now use URL format
3. **Error Handling**: Graceful fallback if URL generation fails
4. **Simple**: Minimal changes, no new components needed
## User Experience
**Before:**
- Click QR code → Copy CSV data to clipboard
- Recipient must paste CSV into input field
**After:**
- Click QR code → Copy URL to clipboard
- Recipient clicks URL → Contact added automatically
## Testing
- ✅ Linting passes
- ✅ Error handling implemented
- ✅ Consistent with ContactQRScanFullView behavior
- ✅ Maintains existing notification system
## Deployment
Ready for deployment. No breaking changes, maintains backward compatibility.

View File

@@ -0,0 +1,178 @@
# Debug Logging Control
## Overview
Debug logging in TimeSafari can be controlled via environment variables to reduce console noise during development and production.
## Current Behavior
By default, debug logging is **disabled** to reduce console noise. Debug logs are very verbose and include detailed information about:
- Camera operations (ImageMethodDialog, PhotoDialog)
- Database operations (CapacitorPlatformService)
- QR Scanner operations
- Platform service operations
- Component lifecycle events
## How to Enable Debug Logging
### Option 1: Environment Variable (Recommended)
Set the `VITE_DEBUG_LOGGING` environment variable to `true`:
```bash
# For development
VITE_DEBUG_LOGGING=true npm run dev
# For web builds
VITE_DEBUG_LOGGING=true npm run build:web:dev
# For Electron builds
VITE_DEBUG_LOGGING=true npm run build:electron:dev
```
### Option 2: .env File
Create or modify `.env.local` file:
```bash
# Enable debug logging
VITE_DEBUG_LOGGING=true
```
### Option 3: Package.json Scripts
Add debug variants to your package.json scripts:
```json
{
"scripts": {
"dev:debug": "VITE_DEBUG_LOGGING=true npm run dev",
"build:web:debug": "VITE_DEBUG_LOGGING=true npm run build:web:dev",
"build:electron:debug": "VITE_DEBUG_LOGGING=true npm run build:electron:dev"
}
}
```
## Debug Logging Rules
Debug logging follows these rules:
1. **Only shows in development mode** (not production)
2. **Only shows for web platform** (not Electron)
3. **Must be explicitly enabled** via `VITE_DEBUG_LOGGING=true`
4. **Never logged to database** (to reduce noise)
5. **Very verbose** - includes detailed component state and operations
## Components with Debug Logging
The following components include debug logging:
- **ImageMethodDialog.vue** - Camera operations, preview state
- **PhotoDialog.vue** - Camera operations, video setup
- **AmountInput.vue** - Input validation, increment/decrement
- **GiftedDialog.vue** - Amount updates, form state
- **CapacitorPlatformService.ts** - Database operations, migrations
- **QRScanner services** - Camera permissions, scanner state
- **PlatformServiceMixin.ts** - Service initialization
## Example Debug Output
When enabled, you'll see output like:
```
[ImageMethodDialog] open called
[ImageMethodDialog] Camera facing mode: user
[ImageMethodDialog] Should mirror video: true
[ImageMethodDialog] Platform capabilities: {isMobile: false, hasCamera: true}
[ImageMethodDialog] Starting camera preview from open()
[ImageMethodDialog] startCameraPreview called
[ImageMethodDialog] Current showCameraPreview state: true
[ImageMethodDialog] MediaDevices available: true
[ImageMethodDialog] getUserMedia constraints: {video: {facingMode: "user"}}
[ImageMethodDialog] Setting video element srcObject
[ImageMethodDialog] Video metadata loaded, starting playback
[ImageMethodDialog] Video element started playing successfully
```
## Disabling Debug Logging
To disable debug logging:
1. **Remove the environment variable:**
```bash
unset VITE_DEBUG_LOGGING
```
2. **Or set it to false:**
```bash
VITE_DEBUG_LOGGING=false npm run dev
```
3. **Or remove from .env file:**
```bash
# Comment out or remove this line
# VITE_DEBUG_LOGGING=true
```
## Production Behavior
In production builds, debug logging is **always disabled** regardless of the environment variable setting. This ensures:
- No debug output in production
- No performance impact from debug logging
- Clean console output for end users
## Troubleshooting
### Debug Logging Not Working
1. **Check environment variable:**
```bash
echo $VITE_DEBUG_LOGGING
```
2. **Verify it's set to "true":**
```bash
VITE_DEBUG_LOGGING=true npm run dev
```
3. **Check if you're in development mode:**
- Debug logging only works in development (`NODE_ENV !== "production"`)
- Production builds always disable debug logging
### Too Much Debug Output
If debug logging is too verbose:
1. **Disable it completely:**
```bash
unset VITE_DEBUG_LOGGING
```
2. **Or modify specific components** to use `logger.log` instead of `logger.debug`
3. **Or add conditional logging** in components:
```typescript
if (process.env.VITE_DEBUG_LOGGING === "true") {
logger.debug("Detailed debug info");
}
```
## Best Practices
1. **Use debug logging sparingly** - only for troubleshooting
2. **Disable in production** - debug logging is automatically disabled
3. **Use specific component prefixes** - makes it easier to filter output
4. **Consider log levels** - use `logger.log` for important info, `logger.debug` for verbose details
5. **Test without debug logging** - ensure your app works without debug output
## Future Improvements
Potential enhancements to the debug logging system:
1. **Component-specific debug flags** - enable debug for specific components only
2. **Log level filtering** - show only certain types of debug messages
3. **Debug UI panel** - in-app debug information display
4. **Structured logging** - JSON format for better parsing
5. **Performance monitoring** - track impact of debug logging

View File

@@ -2,30 +2,33 @@
**Author**: Matthew Raymer
**Date**: 2025-01-27
**Status**: ✅ **UPDATED** - Simplified to use APP_SERVER for all functionality
**Status**: ✅ **COMPLETE** - Domain configuration system implemented
## Overview
TimeSafari uses a centralized domain configuration system to ensure consistent
URL generation across all environments. This system provides a single point of
control for domain changes and uses environment-specific configuration for all
functionality including sharing.
URL generation across all environments. This system prevents localhost URLs from
appearing in shared links during development and provides a single point of
control for domain changes.
## Problem Solved
### Issue: Inconsistent Domain Usage
### Issue: Localhost URLs in Shared Links
Previously, the system used separate constants for different types of URLs:
Previously, copy link buttons and deep link generation used the environment-
specific `APP_SERVER` constant, which resulted in:
- **Internal Operations**: Used `APP_SERVER` (environment-specific)
- **Sharing**: Used separate constants (removed)
- **Development**: `http://localhost:8080/deep-link/claim/123`
- **Test**: `https://test.timesafari.app/deep-link/claim/123`
- **Production**: `https://timesafari.app/deep-link/claim/123`
This created complexity and confusion about when to use which constant.
This caused problems when users in development mode shared links, as the
localhost URLs wouldn't work for other users.
### Solution: Unified Domain Configuration
### Solution: Production Domain for Sharing
All functionality now uses the `APP_SERVER` constant, which provides
environment-specific URLs that can be configured per environment.
All sharing functionality now uses the `PROD_SHARE_DOMAIN` constant, which
always points to the production domain regardless of the current environment.
## Implementation
@@ -40,28 +43,27 @@ export enum AppString {
// ... other constants ...
}
// Environment-specific server URL for all functionality
export const APP_SERVER =
import.meta.env.VITE_APP_SERVER || "https://timesafari.app";
// Production domain for sharing links (always use production URL for sharing)
export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER;
```
### Usage Pattern
All components that generate URLs follow this pattern:
All components that generate shareable links follow this pattern:
```typescript
import { APP_SERVER } from "@/constants/app";
import { PROD_SHARE_DOMAIN } from "@/constants/app";
// In component class
APP_SERVER = APP_SERVER;
PROD_SHARE_DOMAIN = PROD_SHARE_DOMAIN;
// In methods
const deepLink = `${APP_SERVER}/deep-link/claim/${claimId}`;
const deepLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/${claimId}`;
```
### Components Updated
The following components and services use `APP_SERVER`:
The following components and services were updated to use `PROD_SHARE_DOMAIN`:
#### Views
- `ClaimView.vue` - Claim and certificate links
@@ -80,28 +82,17 @@ The following components and services use `APP_SERVER`:
## Configuration Management
### Environment-Specific Configuration
### Changing the Production Domain
The system uses environment variables to configure domains:
To change the production domain for all sharing functionality:
```bash
# Development
VITE_APP_SERVER=http://localhost:8080
# Test
VITE_APP_SERVER=https://test.timesafari.app
# Production
VITE_APP_SERVER=https://timesafari.app
```
### Changing the Domain
To change the domain for all functionality:
1. **Update environment variables** for the target environment:
```bash
VITE_APP_SERVER=https://your-new-domain.com
1. **Update the constant** in `src/constants/app.ts`:
```typescript
export enum AppString {
// ... other constants ...
PROD_PUSH_SERVER = "https://your-new-domain.com",
// ... other constants ...
}
```
2. **Rebuild the application** for all platforms:
@@ -111,32 +102,46 @@ To change the domain for all functionality:
npm run build:electron
```
### Environment-Specific Configuration
The system maintains environment-specific configuration for internal operations
while using production domains for sharing:
```typescript
// Internal operations use environment-specific URLs
export const APP_SERVER =
import.meta.env.VITE_APP_SERVER || "https://timesafari.app";
// Sharing always uses production URLs
export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER;
```
## Benefits
### ✅ Simplified Configuration
### ✅ Consistent User Experience
- Single constant for all URL generation
- No confusion about which constant to use
- Consistent behavior across all functionality
### ✅ Environment Flexibility
- Easy to configure different domains per environment
- Support for development, test, and production environments
- Environment-specific sharing URLs when needed
- All shared links work for all users regardless of environment
- No more broken localhost links in development
- Consistent behavior across all platforms
### ✅ Maintainability
- Single source of truth for domain configuration
- Single source of truth for production domain
- Easy to change domain across entire application
- Clear pattern for implementing new URL functionality
- Clear separation between internal and sharing URLs
### ✅ Developer Experience
- Simple, consistent pattern for URL generation
- Clear documentation and examples
- No need to remember which environment URLs work for sharing
- Clear pattern for implementing new sharing functionality
- Type-safe configuration with TypeScript
### ✅ Security
- No accidental exposure of internal development URLs
- Controlled domain configuration
- Clear audit trail for domain changes
## Testing
### Manual Testing
@@ -145,7 +150,7 @@ To change the domain for all functionality:
```bash
npm run dev
# Navigate to any page with copy link buttons
# Verify links use configured domain
# Verify links use production domain, not localhost
```
2. **Production Build**:
@@ -159,19 +164,27 @@ To change the domain for all functionality:
The implementation includes comprehensive linting to ensure:
- All components properly import `APP_SERVER`
- No hardcoded URLs in functionality
- All components properly import `PROD_SHARE_DOMAIN`
- No hardcoded URLs in sharing functionality
- Consistent usage patterns across the codebase
## Implementation Pattern
## Migration Notes
### Current Approach
### Before Implementation
```typescript
// ✅ Single constant for all functionality
import { APP_SERVER } from "@/constants/app";
const shareLink = `${APP_SERVER}/deep-link/claim/123`;
const apiUrl = `${APP_SERVER}/api/claim/123`;
// ❌ Hardcoded URLs
const deepLink = "https://timesafari.app/deep-link/claim/123";
// ❌ Environment-specific URLs
const deepLink = `${APP_SERVER}/deep-link/claim/123`;
```
### After Implementation
```typescript
// ✅ Configurable production URLs
const deepLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/123`;
```
## Future Enhancements
@@ -195,7 +208,6 @@ const apiUrl = `${APP_SERVER}/api/claim/123`;
```
3. **Platform-Specific Domains**:
```typescript
export const getPlatformShareDomain = () => {
const platform = process.env.VITE_PLATFORM;
@@ -217,5 +229,5 @@ const apiUrl = `${APP_SERVER}/api/claim/123`;
---
**Last Updated**: 2025-01-27
**Version**: 2.0
**Version**: 1.0
**Maintainer**: Matthew Raymer

File diff suppressed because it is too large Load Diff

View File

@@ -1,207 +0,0 @@
# GiftedDialog Entity Types Refactoring
## Overview
This refactoring simplifies the `GiftedDialog` component by replacing the complex `updateEntityTypes()` method with explicit props for entity types. This makes the component more declarative, reusable, and easier to understand.
## Problem
The original `updateEntityTypes()` method used multiple props (`showProjects`, `fromProjectId`, `toProjectId`, `recipientEntityTypeOverride`) to determine entity types through complex conditional logic:
```typescript
updateEntityTypes() {
// Reset and set entity types based on current context
this.giverEntityType = "person";
this.recipientEntityType = "person";
// If recipient entity type is explicitly overridden, use that
if (this.recipientEntityTypeOverride) {
this.recipientEntityType = this.recipientEntityTypeOverride;
}
// Determine entity types based on current context
if (this.showProjects) {
// HomeView "Project" button or ProjectViewView "Given by This"
this.giverEntityType = "project";
// Only override recipient if not already set by recipientEntityTypeOverride
if (!this.recipientEntityTypeOverride) {
this.recipientEntityType = "person";
}
} else if (this.fromProjectId) {
// ProjectViewView "Given by This" button (project is giver)
this.giverEntityType = "project";
// Only override recipient if not already set by recipientEntityTypeOverride
if (!this.recipientEntityTypeOverride) {
this.recipientEntityType = "person";
}
} else if (this.toProjectId) {
// ProjectViewView "Given to This" button (project is recipient)
this.giverEntityType = "person";
// Only override recipient if not already set by recipientEntityTypeOverride
if (!this.recipientEntityTypeOverride) {
this.recipientEntityType = "project";
}
} else {
// HomeView "Person" button
this.giverEntityType = "person";
// Only override recipient if not already set by recipientEntityTypeOverride
if (!this.recipientEntityTypeOverride) {
this.recipientEntityType = "person";
}
}
}
```
### Issues with the Original Approach
1. **Complex Logic**: Nested conditionals that were hard to follow
2. **Tight Coupling**: Views needed to understand internal logic to set the right props
3. **Inflexible**: Adding new entity type combinations required modifying the method
4. **Unclear Intent**: The relationship between props and entity types was not obvious
## Solution
### 1. Explicit Props
Replace the complex logic with explicit props:
```typescript
@Prop({ default: "person" }) giverEntityType = "person" as "person" | "project";
@Prop({ default: "person" }) recipientEntityType = "person" as "person" | "project";
```
### 2. Simple Inline Logic
Views now use simple inline logic to determine entity types:
```vue
<!-- HomeView -->
<GiftedDialog
ref="giftedDialog"
:giver-entity-type="showProjectsDialog ? 'project' : 'person'"
:recipient-entity-type="'person'"
/>
<!-- ProjectViewView -->
<GiftedDialog
ref="giveDialogToThis"
:giver-entity-type="'person'"
:recipient-entity-type="'project'"
:to-project-id="projectId"
:is-from-project-view="true"
/>
<!-- ClaimView -->
<GiftedDialog
ref="customGiveDialog"
:giver-entity-type="'person'"
:recipient-entity-type="projectInfo ? 'project' : 'person'"
:to-project-id="..."
/>
```
## Benefits
### 1. **Declarative**
- Entity types are explicitly declared in the template
- No hidden logic in watchers or complex methods
- Clear intent at the call site
### 2. **Reusable**
- Views can easily specify any combination of entity types
- No need to understand internal logic
- Simple inline logic is easy to understand
### 3. **Maintainable**
- Adding new entity type combinations is straightforward
- Logic is visible directly in the template
- No additional files to maintain
### 4. **Testable**
- Entity type logic is visible and predictable
- No complex state management to test
- Template logic can be easily verified
### 5. **Type Safe**
- TypeScript ensures correct entity type values
- Compile-time validation of entity type combinations
## Migration Guide
### For Views Using GiftedDialog
Simply update the template to use explicit entity type props:
```vue
<!-- Before -->
<GiftedDialog :show-projects="showProjects" />
<!-- After -->
<GiftedDialog
:giver-entity-type="showProjects ? 'project' : 'person'"
:recipient-entity-type="'person'"
/>
```
### Common Patterns
1. **Person-to-Person**: `giver-entity-type="'person'" recipient-entity-type="'person'"`
2. **Project-to-Person**: `giver-entity-type="'project'" recipient-entity-type="'person'"`
3. **Person-to-Project**: `giver-entity-type="'person'" recipient-entity-type="'project'"`
4. **Conditional Project**: `recipient-entity-type="hasProject ? 'project' : 'person'"`
## Files Changed
### Core Changes
- `src/components/GiftedDialog.vue` - Removed `updateEntityTypes()` method, added explicit props
### View Updates
- `src/views/HomeView.vue` - Updated to use inline logic
- `src/views/ProjectViewView.vue` - Updated to use inline logic
- `src/views/ClaimView.vue` - Updated to use inline logic
- `src/views/ContactGiftingView.vue` - Updated to use inline logic
- `src/views/ContactsView.vue` - Updated to use inline logic
## Backward Compatibility
The refactoring maintains backward compatibility by:
- Keeping all existing props that are still needed (`fromProjectId`, `toProjectId`, `isFromProjectView`)
- Preserving the same component API for the `open()` method
- Maintaining the same template structure
## Future Enhancements
1. **Validation**: Add runtime validation for entity type combinations
2. **Documentation**: Add JSDoc comments to the component props
3. **Testing**: Add unit tests for the component with different entity type combinations
## Conclusion
This refactoring transforms `GiftedDialog` from a component with complex internal logic to a declarative, reusable component. The explicit entity type props make the component's behavior clear and predictable, while the simple inline logic keeps the code straightforward and maintainable.
## Bug Fixes
### Issue 1: Entity Type Preservation in Navigation
**Problem**: When navigating from HomeView with `showProjects = true` to ContactGiftingView via "Show All", the entity type information was lost because `showAllQueryParams` returned an empty object for project contexts.
**Solution**: Modified `EntitySelectionStep.vue` to always pass entity type information in the query parameters, even for project contexts.
### Issue 2: Recipient Reset in ContactGiftingView
**Problem**: When selecting a giver in ContactGiftingView, the recipient was always reset to "You" instead of preserving the current recipient.
**Solution**: Updated ContactGiftingView to preserve the existing recipient from the context when selecting a giver, and enhanced the query parameter passing to include both giver and recipient information for better context preservation.
### Issue 3: HomeView Project Button Entity Type Mismatch
**Problem**: When navigating from HomeView Project button → change recipient → Show All → ContactGifting, the giver entity type was incorrectly set to "person" instead of "project".
**Root Cause**: ContactGiftingView was inferring entity types from `fromProjectId` and `toProjectId` instead of using the explicitly passed `giverEntityType` and `recipientEntityType` from the query parameters.
**Solution**: Updated ContactGiftingView to use the explicitly passed entity types from query parameters instead of inferring them from project IDs.
### Files Modified for Bug Fixes
- `src/components/EntitySelectionStep.vue` - Enhanced query parameter passing
- `src/views/ContactGiftingView.vue` - Improved context preservation logic and entity type handling

View File

@@ -14,7 +14,10 @@ import { ElectronCapacitorApp, setupContentSecurityPolicy, setupReloadWatcher }
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
console.log('[Electron] Another instance is already running. Exiting immediately...');
// Debug logging - only show when VITE_DEBUG_LOGGING is enabled
if (process.env.VITE_DEBUG_LOGGING === 'true') {
console.log('[Electron] Another instance is already running. Exiting immediately...');
}
process.exit(0);
}
@@ -90,7 +93,10 @@ if (electronIsDev) {
// Handle second instance launch (focus existing window and show dialog)
app.on('second-instance', (event, commandLine, workingDirectory) => {
console.log('[Electron] Second instance attempted to launch');
// Debug logging - only show when VITE_DEBUG_LOGGING is enabled
if (process.env.VITE_DEBUG_LOGGING === 'true') {
console.log('[Electron] Second instance attempted to launch');
}
// Someone tried to run a second instance, we should focus our window instead
const mainWindow = myCapacitorApp.getMainWindow();
@@ -163,7 +169,10 @@ ipcMain.handle('export-data-to-downloads', async (_event, fileName: string, data
// Write the file to the Downloads directory
await fs.writeFile(filePath, data, 'utf-8');
console.log(`[Electron Main] File exported successfully: ${filePath}`);
// Debug logging - only show when VITE_DEBUG_LOGGING is enabled
if (process.env.VITE_DEBUG_LOGGING === 'true') {
console.log(`[Electron Main] File exported successfully: ${filePath}`);
}
return {
success: true,

View File

@@ -3,7 +3,10 @@ import { contextBridge, ipcRenderer } from 'electron';
require('./rt/electron-rt');
//////////////////////////////
// User Defined Preload scripts below
console.log('User Preload!');
// Debug logging - only show when VITE_DEBUG_LOGGING is enabled
if (process.env.VITE_DEBUG_LOGGING === 'true') {
console.log('User Preload!');
}
/**
* Expose secure IPC APIs to the renderer process.

View File

@@ -403,7 +403,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = GM3FS5JQPH;
ENABLE_APP_SANDBOX = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -413,7 +413,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.6;
MARKETING_VERSION = 1.0.4;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = app.timesafari;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -430,7 +430,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = GM3FS5JQPH;
ENABLE_APP_SANDBOX = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -440,7 +440,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.6;
MARKETING_VERSION = 1.0.4;
PRODUCT_BUNDLE_IDENTIFIER = app.timesafari;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";

3316
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,6 @@
"scripts": {
"lint": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src",
"lint-fix": "eslint --ext .js,.ts,.vue --ignore-path .gitignore --fix src",
"type-check": "tsc --noEmit",
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node sw_combine.js && node scripts/copy-wasm.js",
"test:prerequisites": "node scripts/check-prerequisites.js",
"test:web": "npx playwright test -c playwright.config-local.ts --trace on",
@@ -41,10 +40,6 @@
"build:ios:sync": "./scripts/build-ios.sh --sync",
"build:ios:assets": "./scripts/build-ios.sh --assets",
"build:ios:deploy": "./scripts/build-ios.sh --deploy",
"build:ios:dev:custom": "./scripts/build-ios.sh --dev --api-ip",
"build:ios:test:custom": "./scripts/build-ios.sh --test --api-ip",
"build:ios:dev:run:custom": "./scripts/build-ios.sh --dev --api-ip --auto-run",
"build:ios:test:run:custom": "./scripts/build-ios.sh --test --api-ip --auto-run",
"build:web": "./scripts/build-web.sh",
"build:web:dev": "./scripts/build-web.sh --dev",
"build:web:test": "./scripts/build-web.sh --test",
@@ -92,7 +87,6 @@
"clean:android": "adb uninstall app.timesafari.app || true",
"clean:ios": "rm -rf ios/App/build ios/App/Pods ios/App/output ios/App/App/public ios/DerivedData ios/capacitor-cordova-ios-plugins ios/App/App/capacitor.config.json ios/App/App/config.xml || true",
"clean:electron": "./scripts/build-electron.sh --clean",
"clean:all": "npm run clean:ios && npm run clean:android && npm run clean:electron",
"build:android": "./scripts/build-android.sh",
"build:android:dev": "./scripts/build-android.sh --dev",
"build:android:test": "./scripts/build-android.sh --test",
@@ -109,11 +103,7 @@
"build:android:clean": "./scripts/build-android.sh --clean",
"build:android:sync": "./scripts/build-android.sh --sync",
"build:android:assets": "./scripts/build-android.sh --assets",
"build:android:deploy": "./scripts/build-android.sh --deploy",
"build:android:dev:custom": "./scripts/build-android.sh --dev --api-ip",
"build:android:test:custom": "./scripts/build-android.sh --test --api-ip",
"build:android:dev:run:custom": "./scripts/build-android.sh --dev --api-ip --auto-run",
"build:android:test:run:custom": "./scripts/build-android.sh --test --api-ip --auto-run"
"build:android:deploy": "./scripts/build-android.sh --deploy"
},
"dependencies": {
"@capacitor-community/electron": "^5.0.1",

View File

@@ -35,7 +35,13 @@ export default defineConfig({
baseURL: "http://localhost:8080",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "retain-on-failure"
trace: "retain-on-failure",
// Add request logging
logger: {
isEnabled: (name, severity) => severity === 'error' || name === 'api',
log: (name, severity, message, args) => console.log(`${severity}: ${message}`, args)
}
},
/* Configure projects for major browsers */

81
playwright.config.ts Normal file
View File

@@ -0,0 +1,81 @@
import { defineConfig, devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './test-playwright',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'https://test.timesafari.app',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
permissions: ["clipboard-read"],
},
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command:
// "VITE_PASSKEYS_ENABLED=true VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000 npm run dev",
// url: "http://localhost:8080",
// reuseExistingServer: !process.env.CI,
// },
});

View File

@@ -60,16 +60,12 @@ SYNC_ONLY=false
ASSETS_ONLY=false
DEPLOY_APP=false
AUTO_RUN=false
CUSTOM_API_IP=""
# Function to parse Android-specific arguments
parse_android_args() {
local args=("$@")
local i=0
while [ $i -lt ${#args[@]} ]; do
local arg="${args[$i]}"
for arg in "${args[@]}"; do
case $arg in
--dev|--development)
BUILD_MODE="development"
@@ -110,18 +106,6 @@ parse_android_args() {
--auto-run)
AUTO_RUN=true
;;
--api-ip)
if [ $((i + 1)) -lt ${#args[@]} ]; then
CUSTOM_API_IP="${args[$((i + 1))]}"
i=$((i + 1)) # Skip the next argument
else
log_error "Error: --api-ip requires an IP address"
exit 1
fi
;;
--api-ip=*)
CUSTOM_API_IP="${arg#*=}"
;;
-h|--help)
print_android_usage
exit 0
@@ -133,7 +117,6 @@ parse_android_args() {
log_warn "Unknown argument: $arg"
;;
esac
i=$((i + 1))
done
}
@@ -155,7 +138,6 @@ print_android_usage() {
echo " --assets Generate assets only"
echo " --deploy Deploy APK to connected device"
echo " --auto-run Auto-run app after build"
echo " --api-ip <ip> Custom IP address for claim API (defaults to 10.0.2.2)"
echo ""
echo "Common Options:"
echo " -h, --help Show this help message"
@@ -169,8 +151,6 @@ print_android_usage() {
echo " $0 --clean # Clean only"
echo " $0 --sync # Sync only"
echo " $0 --deploy # Build and deploy to device"
echo " $0 --dev # Dev build with default 10.0.2.2"
echo " $0 --dev --api-ip 192.168.1.100 # Dev build with custom API IP"
echo ""
}
@@ -186,21 +166,6 @@ log_info "Build type: $BUILD_TYPE"
# Setup environment for Capacitor build
setup_build_env "capacitor"
# Override API servers for Android development
if [ "$BUILD_MODE" = "development" ]; then
if [ -n "$CUSTOM_API_IP" ]; then
# Use custom IP for physical device development
export VITE_DEFAULT_ENDORSER_API_SERVER="http://${CUSTOM_API_IP}:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://${CUSTOM_API_IP}:3000"
log_info "Android development mode: Using custom IP ${CUSTOM_API_IP} for physical device"
else
# Use Android emulator IP (10.0.2.2) for Android development
export VITE_DEFAULT_ENDORSER_API_SERVER="http://10.0.2.2:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://10.0.2.2:3000"
log_debug "Android development mode: Using 10.0.2.2 for emulator"
fi
fi
# Setup application directories
setup_app_directories

View File

@@ -22,7 +22,6 @@ SYNC_ONLY=false
ASSETS_ONLY=false
DEPLOY_APP=false
AUTO_RUN=false
CUSTOM_API_IP=""
# Function to print iOS-specific usage
print_ios_usage() {
@@ -42,7 +41,6 @@ print_ios_usage() {
echo " --assets Generate assets only"
echo " --deploy Deploy app to connected device"
echo " --auto-run Auto-run app after build"
echo " --api-ip <ip> Custom IP address for claim API (uses Capacitor default)"
echo ""
echo "Common Options:"
echo " -h, --help Show this help message"
@@ -56,19 +54,12 @@ print_ios_usage() {
echo " $0 --clean # Clean only"
echo " $0 --sync # Sync only"
echo " $0 --deploy # Build and deploy to device"
echo " $0 --dev # Dev build with Capacitor default"
echo " $0 --dev --api-ip 192.168.1.100 # Dev build with custom API IP"
echo ""
}
# Function to parse iOS-specific arguments
parse_ios_args() {
local args=("$@")
local i=0
while [ $i -lt ${#args[@]} ]; do
local arg="${args[$i]}"
for arg in "$@"; do
case $arg in
--dev|--development)
BUILD_MODE="development"
@@ -109,18 +100,6 @@ parse_ios_args() {
--auto-run)
AUTO_RUN=true
;;
--api-ip)
if [ $((i + 1)) -lt ${#args[@]} ]; then
CUSTOM_API_IP="${args[$((i + 1))]}"
i=$((i + 1)) # Skip the next argument
else
log_error "Error: --api-ip requires an IP address"
exit 1
fi
;;
--api-ip=*)
CUSTOM_API_IP="${arg#*=}"
;;
-h|--help)
print_ios_usage
exit 0
@@ -132,7 +111,6 @@ parse_ios_args() {
log_warn "Unknown argument: $arg"
;;
esac
i=$((i + 1))
done
}
@@ -313,14 +291,6 @@ log_info "Build type: $BUILD_TYPE"
# Setup environment for Capacitor build
setup_build_env "capacitor"
# Override API servers for iOS development when custom IP is specified
if [ "$BUILD_MODE" = "development" ] && [ -n "$CUSTOM_API_IP" ]; then
# Use custom IP for physical device development
export VITE_DEFAULT_ENDORSER_API_SERVER="http://${CUSTOM_API_IP}:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://${CUSTOM_API_IP}:3000"
log_info "iOS development mode: Using custom IP ${CUSTOM_API_IP} for physical device"
fi
# Setup application directories
setup_app_directories

View File

@@ -252,25 +252,6 @@ execute_docker_build() {
log_info "Docker image available as: $image_tag:$mode"
}
# Function to run type checking based on build mode
run_type_checking() {
local mode="$1"
# Only run type checking for production and test builds
if [ "$mode" = "production" ] || [ "$mode" = "test" ]; then
log_info "Running TypeScript type checking for $mode mode..."
if ! measure_time npm run type-check; then
log_error "TypeScript type checking failed for $mode mode!"
exit 2
fi
log_success "TypeScript type checking completed for $mode mode"
else
log_debug "Skipping TypeScript type checking for development mode"
fi
}
# Function to start Vite development server
start_dev_server() {
log_info "Starting Vite development server..."
@@ -352,10 +333,7 @@ elif [ "$SERVE_BUILD" = true ]; then
log_info "Cleaning dist directory..."
clean_build_artifacts "dist"
# Step 2: Run type checking (for production/test builds)
safe_execute "Type checking for $BUILD_MODE mode" "run_type_checking $BUILD_MODE" || exit 2
# Step 3: Execute Vite build
# Step 2: Execute Vite build
safe_execute "Vite build for $BUILD_MODE mode" "execute_vite_build $BUILD_MODE" || exit 3
# Step 3: Serve the build
@@ -370,10 +348,7 @@ else
log_info "Cleaning dist directory..."
clean_build_artifacts "dist"
# Step 2: Run type checking (for production/test builds)
safe_execute "Type checking for $BUILD_MODE mode" "run_type_checking $BUILD_MODE" || exit 2
# Step 3: Execute Vite build
# Step 2: Execute Vite build
safe_execute "Vite build for $BUILD_MODE mode" "execute_vite_build $BUILD_MODE" || exit 3
# Step 3: Execute Docker build if requested

View File

@@ -51,18 +51,10 @@ log_step() {
# Function to measure and log execution time
measure_time() {
local start_time=$(date +%s)
if "$@"; then
local end_time=$(date +%s)
local duration=$((end_time - start_time))
log_success "Completed in ${duration} seconds"
return 0
else
local exit_code=$?
local end_time=$(date +%s)
local duration=$((end_time - start_time))
log_error "Failed after ${duration} seconds (exit code: ${exit_code})"
return $exit_code
fi
"$@"
local end_time=$(date +%s)
local duration=$((end_time - start_time))
log_success "Completed in ${duration} seconds"
}
# Function to print section headers
@@ -205,22 +197,20 @@ setup_build_env() {
# Set API server environment variables based on build mode
if [ "$BUILD_MODE" = "development" ]; then
# For Capacitor development, use localhost by default
# Android builds will override this in build-android.sh
export VITE_DEFAULT_ENDORSER_API_SERVER="http://localhost:3000"
export VITE_DEFAULT_PARTNER_API_SERVER="http://localhost:3000"
log_debug "Development mode: Using localhost for Endorser and Partner APIs"
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch"
log_debug "Development mode: Using localhost for Endorser API, production for Image/Partner APIs"
elif [ "$BUILD_MODE" = "test" ]; then
export VITE_DEFAULT_ENDORSER_API_SERVER="https://test-api.endorser.ch"
export VITE_DEFAULT_PARTNER_API_SERVER="https://test-partner-api.endorser.ch"
log_debug "Test mode: Using test Endorser and Partner APIs"
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch"
log_debug "Test mode: Using test Endorser API, production for Image/Partner APIs"
elif [ "$BUILD_MODE" = "production" ]; then
export VITE_DEFAULT_ENDORSER_API_SERVER="https://api.endorser.ch"
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
export VITE_DEFAULT_PARTNER_API_SERVER="https://partner-api.endorser.ch"
log_debug "Production mode: Using production API servers"
export VITE_DEFAULT_IMAGE_API_SERVER="https://image-api.timesafari.app"
fi
# Log environment setup

View File

@@ -251,7 +251,8 @@
import { Component, Prop, Vue, Emit } from "vue-facing-decorator";
import { GiveRecordWithContactInfo } from "@/interfaces/give";
import EntityIcon from "./EntityIcon.vue";
import { isHiddenDid } from "../libs/endorserServer";
import { isGiveClaimType, notifyWhyCannotConfirm } from "../libs/util";
import { containsHiddenDid, isHiddenDid } from "../libs/endorserServer";
import ProjectIcon from "./ProjectIcon.vue";
import { createNotifyHelpers } from "@/utils/notify";
import {
@@ -271,6 +272,7 @@ export default class ActivityListItem extends Vue {
@Prop() lastViewedClaimId?: string;
@Prop() isRegistered!: boolean;
@Prop() activeDid!: string;
@Prop() confirmerIdList?: string[];
/**
* Function prop for handling image caching
@@ -329,6 +331,15 @@ export default class ActivityListItem extends Vue {
return unitCode === "HUR" ? (single ? "hour" : "hours") : unitCode;
}
get canConfirm(): boolean {
if (!this.isRegistered) return false;
if (!isGiveClaimType(this.record.fullClaim?.["@type"])) return false;
if (this.confirmerIdList?.includes(this.activeDid)) return false;
if (this.record.issuerDid === this.activeDid) return false;
if (containsHiddenDid(this.record.fullClaim)) return false;
return true;
}
// Emit methods using @Emit decorator
@Emit("viewImage")
emitViewImage(imageUrl: string) {
@@ -340,6 +351,26 @@ export default class ActivityListItem extends Vue {
return jwtId;
}
@Emit("confirmClaim")
emitConfirmClaim() {
if (!this.canConfirm) {
notifyWhyCannotConfirm(
(msg, timeout) => this.notify.info(msg.text ?? "", timeout),
this.isRegistered,
this.record.fullClaim?.["@type"],
this.record,
this.activeDid,
this.confirmerIdList,
);
return;
}
return this.record;
}
handleConfirmClick() {
this.emitConfirmClaim();
}
get friendlyDate(): string {
const date = new Date(this.record.issuedAt);
return date.toLocaleDateString(undefined, {

View File

@@ -167,7 +167,7 @@ export default class ContactInputForm extends Vue {
*/
@Emit("qr-scan")
private handleQRScan(): void {
console.log("[ContactInputForm] QR scan button clicked");
// QR scan button clicked - event emitted to parent
}
}
</script>

View File

@@ -121,12 +121,6 @@ import { AppString } from "../constants/app";
components: {
EntityIcon,
},
emits: [
"toggle-selection",
"show-identicon",
"show-gifted-dialog",
"open-offer-dialog",
],
})
export default class ContactListItem extends Vue {
@Prop({ required: true }) contact!: Contact;
@@ -157,12 +151,14 @@ export default class ContactListItem extends Vue {
return contact;
}
@Emit("show-gifted-dialog")
emitShowGiftedDialog(fromDid: string, toDid: string) {
this.$emit("show-gifted-dialog", fromDid, toDid);
return { fromDid, toDid };
}
@Emit("open-offer-dialog")
emitOpenOfferDialog(did: string, name: string | undefined) {
this.$emit("open-offer-dialog", did, name);
return { did, name };
}
/**

View File

@@ -54,10 +54,7 @@ messages * - Conditional UI based on platform capabilities * * @component *
<script lang="ts">
import { Component, Prop, Vue } from "vue-facing-decorator";
import * as R from "ramda";
import { AppString, NotificationIface } from "../constants/app";
import { Contact } from "../db/tables/contacts";
import { logger } from "../utils/logger";
import { contactsToExportJson } from "../libs/util";
@@ -182,19 +179,7 @@ export default class DataExportSection extends Vue {
const allContacts = await this.$contacts();
// Convert contacts to export format
const processedContacts: Contact[] = allContacts.map((contact) => {
// first remove the contactMethods field, mostly to cast to a clear type (that will end up with JSON objects)
const exContact: Contact = R.omit(["contactMethods"], contact);
// now add contactMethods as a true array of ContactMethod objects
exContact.contactMethods = contact.contactMethods
? (typeof contact.contactMethods === 'string' && contact.contactMethods.trim() !== ''
? JSON.parse(contact.contactMethods)
: [])
: [];
return exContact;
});
const exportData = contactsToExportJson(processedContacts);
const exportData = contactsToExportJson(allContacts);
const jsonStr = JSON.stringify(exportData, null, 2);
// Use platform service to handle export (no platform-specific logic here!)

View File

@@ -136,20 +136,6 @@ export default class EntitySelectionStep extends Vue {
@Prop()
receiver?: EntityData | null;
/** Form field values to preserve when navigating to "Show All" */
@Prop({ default: "" })
description!: string;
@Prop({ default: "0" })
amountInput!: string;
@Prop({ default: "HUR" })
unitCode!: string;
/** Offer ID for context when fulfilling an offer */
@Prop({ default: "" })
offerId!: string;
/** Notification function from parent component */
@Prop()
notify?: (notification: NotificationIface, timeout?: number) => void;
@@ -234,41 +220,34 @@ export default class EntitySelectionStep extends Vue {
* Query parameters for "Show All" navigation
*/
get showAllQueryParams(): Record<string, string> {
const baseParams = {
if (this.shouldShowProjects) {
return {};
}
return {
stepType: this.stepType,
giverEntityType: this.giverEntityType,
recipientEntityType: this.recipientEntityType,
// Form field values to preserve
description: this.description,
amountInput: this.amountInput,
unitCode: this.unitCode,
offerId: this.offerId,
...(this.stepType === "giver"
? {
recipientProjectId: this.toProjectId || "",
recipientProjectName: this.receiver?.name || "",
recipientProjectImage: this.receiver?.image || "",
recipientProjectHandleId: this.receiver?.handleId || "",
recipientDid: this.receiver?.did || "",
}
: {
giverProjectId: this.fromProjectId || "",
giverProjectName: this.giver?.name || "",
giverProjectImage: this.giver?.image || "",
giverProjectHandleId: this.giver?.handleId || "",
giverDid: this.giver?.did || "",
}),
fromProjectId: this.fromProjectId,
toProjectId: this.toProjectId,
showProjects: this.showProjects.toString(),
isFromProjectView: this.isFromProjectView.toString(),
};
if (this.shouldShowProjects) {
// For project contexts, still pass entity type information
return baseParams;
}
return {
...baseParams,
// Always pass both giver and recipient info for context preservation
giverProjectId: this.fromProjectId || "",
giverProjectName: this.giver?.name || "",
giverProjectImage: this.giver?.image || "",
giverProjectHandleId: this.giver?.handleId || "",
giverDid: this.giverEntityType === "person" ? this.giver?.did || "" : "",
recipientProjectId: this.toProjectId || "",
recipientProjectName: this.receiver?.name || "",
recipientProjectImage: this.receiver?.image || "",
recipientProjectHandleId: this.receiver?.handleId || "",
recipientDid:
this.recipientEntityType === "person" ? this.receiver?.did || "" : "",
};
}
/**

View File

@@ -315,15 +315,16 @@ export default class GiftDetailsStep extends Vue {
giverName: this.giver?.name,
offerId: this.offerId,
fulfillsProjectId:
this.recipientEntityType === "project" ? this.toProjectId : undefined,
this.giverEntityType === "person" &&
this.recipientEntityType === "project"
? this.toProjectId
: undefined,
providerProjectId:
this.giverEntityType === "project"
this.giverEntityType === "project" &&
this.recipientEntityType === "person"
? this.giver?.handleId
: this.fromProjectId,
recipientDid:
this.recipientEntityType === "person"
? this.receiver?.did
: undefined,
recipientDid: this.receiver?.did,
recipientName: this.receiver?.name,
unitCode: this.localUnitCode,
},

View File

@@ -1,19 +1,13 @@
<template>
<div v-if="visible" class="dialog-overlay">
<div
class="dialog"
data-testid="gifted-dialog"
:data-recipient-entity-type="recipientEntityType"
>
<div class="dialog">
<!-- Step 1: Entity Selection -->
<EntitySelectionStep
v-show="firstStep"
:step-type="stepType"
:giver-entity-type="giverEntityType"
:recipient-entity-type="recipientEntityType"
:show-projects="
giverEntityType === 'project' || recipientEntityType === 'project'
"
:show-projects="showProjects"
:is-from-project-view="isFromProjectView"
:projects="projects"
:all-contacts="allContacts"
@@ -24,10 +18,6 @@
:to-project-id="toProjectId"
:giver="giver"
:receiver="receiver"
:description="description"
:amount-input="amountInput"
:unit-code="unitCode"
:offer-id="offerId"
:notify="$notify"
@entity-selected="handleEntitySelected"
@cancel="cancel"
@@ -62,7 +52,7 @@
</template>
<script lang="ts">
import { Vue, Component, Prop } from "vue-facing-decorator";
import { Vue, Component, Prop, Watch } from "vue-facing-decorator";
import {
createAndSubmitGive,
@@ -81,12 +71,6 @@ import GiftDetailsStep from "../components/GiftDetailsStep.vue";
import { PlanData } from "../interfaces/records";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
import {
NOTIFY_GIFT_ERROR_NEGATIVE_AMOUNT,
NOTIFY_GIFT_ERROR_NO_DESCRIPTION,
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER,
NOTIFY_GIFTED_DETAILS_RECORDING_GIVE,
} from "@/constants/notifications";
@Component({
components: {
@@ -113,13 +97,23 @@ export default class GiftedDialog extends Vue {
@Prop() fromProjectId = "";
@Prop() toProjectId = "";
@Prop({ default: false }) showProjects = false;
@Prop() isFromProjectView = false;
@Prop({ default: "person" }) giverEntityType = "person" as
| "person"
| "project";
@Prop({ default: "person" }) recipientEntityType = "person" as
| "person"
| "project";
@Watch("showProjects")
onShowProjectsChange() {
this.updateEntityTypes();
}
@Watch("fromProjectId")
onFromProjectIdChange() {
this.updateEntityTypes();
}
@Watch("toProjectId")
onToProjectIdChange() {
this.updateEntityTypes();
}
activeDid = "";
allContacts: Array<Contact> = [];
@@ -128,19 +122,20 @@ export default class GiftedDialog extends Vue {
amountInput = "0";
callbackOnSuccess?: (amount: number) => void = () => {};
customTitle?: string;
description = "";
firstStep = true; // true = Step 1 (giver/recipient selection), false = Step 2 (amount/description)
giver?: libsUtil.GiverReceiverInputInfo; // undefined means no identified giver agent
offerId = "";
projects: PlanData[] = [];
prompt = "";
receiver?: libsUtil.GiverReceiverInputInfo;
stepType = "giver";
unitCode = "HUR";
visible = false;
libsUtil = libsUtil;
projects: PlanData[] = [];
didInfo = didInfo;
// Computed property to help debug template logic
@@ -194,27 +189,56 @@ export default class GiftedDialog extends Vue {
return false;
}
stepType = "giver";
giverEntityType = "person" as "person" | "project";
recipientEntityType = "person" as "person" | "project";
updateEntityTypes() {
// Reset and set entity types based on current context
this.giverEntityType = "person";
this.recipientEntityType = "person";
// Determine entity types based on current context
if (this.showProjects) {
// HomeView "Project" button or ProjectViewView "Given by This"
this.giverEntityType = "project";
this.recipientEntityType = "person";
} else if (this.fromProjectId) {
// ProjectViewView "Given by This" button (project is giver)
this.giverEntityType = "project";
this.recipientEntityType = "person";
} else if (this.toProjectId) {
// ProjectViewView "Given to This" button (project is recipient)
this.giverEntityType = "person";
this.recipientEntityType = "project";
} else {
// HomeView "Person" button
this.giverEntityType = "person";
this.recipientEntityType = "person";
}
}
async open(
giver?: libsUtil.GiverReceiverInputInfo,
receiver?: libsUtil.GiverReceiverInputInfo,
offerId?: string,
customTitle?: string,
prompt?: string,
description?: string,
amountInput?: string,
unitCode?: string,
callbackOnSuccess: (amount: number) => void = () => {},
) {
this.customTitle = customTitle;
this.giver = giver;
this.receiver = receiver;
this.offerId = offerId || "";
this.prompt = prompt || "";
this.description = description || "";
this.amountInput = amountInput || "0";
this.unitCode = unitCode || "HUR";
this.receiver = receiver;
this.amountInput = "0";
this.callbackOnSuccess = callbackOnSuccess;
this.offerId = offerId || "";
this.firstStep = !giver;
this.stepType = "giver";
// Update entity types based on current props
this.updateEntityTypes();
try {
const settings = await this.$settings();
this.apiServer = settings.apiServer || "";
@@ -294,24 +318,23 @@ export default class GiftedDialog extends Vue {
async confirm() {
if (!this.activeDid) {
this.safeNotify.error(
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER.message,
TIMEOUTS.SHORT,
"You must select an identifier before you can record a give.",
TIMEOUTS.STANDARD,
);
return;
}
if (parseFloat(this.amountInput) < 0) {
this.safeNotify.error(
NOTIFY_GIFT_ERROR_NEGATIVE_AMOUNT.message,
"You may not send a negative number.",
TIMEOUTS.SHORT,
);
return;
}
if (!this.description && !parseFloat(this.amountInput)) {
this.safeNotify.error(
NOTIFY_GIFT_ERROR_NO_DESCRIPTION.message.replace(
"{unit}",
this.libsUtil.UNIT_SHORT[this.unitCode] || this.unitCode,
),
`You must enter a description or some number of ${
this.libsUtil.UNIT_LONG[this.unitCode]
}.`,
TIMEOUTS.SHORT,
);
return;
@@ -327,11 +350,7 @@ export default class GiftedDialog extends Vue {
}
this.close();
this.safeNotify.toast(
NOTIFY_GIFTED_DETAILS_RECORDING_GIVE.message,
undefined,
TIMEOUTS.BRIEF,
);
this.safeNotify.toast("Recording the give...", undefined, TIMEOUTS.BRIEF);
// this is asynchronous, but we don't need to wait for it to complete
await this.recordGive(
(this.giver?.did as string) || null,
@@ -458,13 +477,10 @@ export default class GiftedDialog extends Vue {
name: contact.name || contact.did,
};
} else {
// Only set to "Unnamed" if no giver is currently set
if (!this.giver || !this.giver.did) {
this.giver = {
did: "",
name: "Unnamed",
};
}
this.giver = {
did: "",
name: "Unnamed",
};
}
this.firstStep = false;
}
@@ -474,10 +490,6 @@ export default class GiftedDialog extends Vue {
this.firstStep = true;
}
moveToStep2() {
this.firstStep = false;
}
async loadProjects() {
try {
const response = await fetch(this.apiServer + "/api/v2/report/plans", {
@@ -520,13 +532,10 @@ export default class GiftedDialog extends Vue {
name: contact.name || contact.did,
};
} else {
// Only set to "Unnamed" if no receiver is currently set
if (!this.receiver || !this.receiver.did) {
this.receiver = {
did: "",
name: "Unnamed",
};
}
this.receiver = {
did: "",
name: "Unnamed",
};
}
this.firstStep = false;
}
@@ -550,13 +559,16 @@ export default class GiftedDialog extends Vue {
giverName: this.giver?.name,
offerId: this.offerId,
fulfillsProjectId:
this.recipientEntityType === "project" ? this.toProjectId : undefined,
this.giverEntityType === "person" &&
this.recipientEntityType === "project"
? this.toProjectId
: undefined,
providerProjectId:
this.giverEntityType === "project"
this.giverEntityType === "project" &&
this.recipientEntityType === "person"
? this.giver?.handleId
: this.fromProjectId,
recipientDid:
this.recipientEntityType === "person" ? this.receiver?.did : undefined,
recipientDid: this.receiver?.did,
recipientName: this.receiver?.name,
unitCode: this.unitCode,
};

View File

@@ -159,6 +159,22 @@
</template>
<script lang="ts">
/* TODO: Human Testing Required - PlatformServiceMixin Migration */
// Priority: High | Migrated: 2025-07-06 | Author: Matthew Raymer
//
//
// Test Scenarios Required:
// 1. Load members list with valid meeting password
// 2. Test member admission toggle (organizer role)
// 3. Test adding member as contact
// 4. Test error scenarios: network failure, invalid password, server errors
// 5. Verify error logging appears in console and database
// 6. Cross-platform testing: web, mobile, desktop
//
// Reference: docs/migration-testing/migration-checklist-MembersList.md
// Validation: Passes lint checks and TypeScript compilation
// Navigation: Contacts → Chair Icon → Start/Join Meeting → Members List
import { Component, Vue, Prop, Emit } from "vue-facing-decorator";
import {

View File

@@ -15,25 +15,26 @@ Raymer */
class="block w-full rounded border border-slate-400 mb-2 px-3 py-2"
placeholder="Description of what is offered"
/>
<div class="flex mb-4">
<AmountInput
:value="parseFloat(amountInput) || 0"
:onUpdateValue="handleAmountUpdate"
data-testId="inputOfferAmount"
/>
<select
v-model="amountUnitCode"
class="flex-1 rounded border border-slate-400 ms-2 px-3 py-2"
<div class="flex flex-row mt-2">
<span :class="unitCodeDisplayClasses" @click="changeUnitCode()">
{{ libsUtil.UNIT_SHORT[amountUnitCode] }}
</span>
<div
v-if="showDecrementButton"
:class="controlButtonClasses"
@click="decrement()"
>
<option
v-for="(displayName, code) in unitOptions"
:key="code"
:value="code"
>
{{ displayName }}
</option>
</select>
<font-awesome icon="chevron-left" />
</div>
<input
v-model="amountInput"
data-testId="inputOfferAmount"
type="number"
:class="amountInputClasses"
/>
<div :class="incrementButtonClasses" @click="increment()">
<font-awesome icon="chevron-right" />
</div>
</div>
<div class="mt-4 flex justify-center">
<span>
@@ -72,15 +73,10 @@ import {
NOTIFY_OFFER_CREATION_ERROR,
NOTIFY_OFFER_SUCCESS,
NOTIFY_OFFER_SUBMISSION_ERROR,
NOTIFY_OFFER_ERROR_NEGATIVE_AMOUNT,
} from "@/constants/notifications";
import AmountInput from "./AmountInput.vue";
@Component({
mixins: [PlatformServiceMixin],
components: {
AmountInput,
},
})
export default class OfferDialog extends Vue {
@Prop projectId?: string;
@@ -126,10 +122,35 @@ export default class OfferDialog extends Vue {
}
/**
* Computed property to get unit options for the select dropdown
* CSS classes for unit code selector and increment/decrement buttons
* Reduces template complexity for repeated border and styling patterns
*/
get unitOptions() {
return this.libsUtil.UNIT_SHORT;
get controlButtonClasses(): string {
return "border border-r-0 border-slate-400 bg-slate-200 px-4 py-2";
}
/**
* CSS classes for unit code display span
* Reduces template complexity for unit code button styling
*/
get unitCodeDisplayClasses(): string {
return "rounded-l border border-r-0 border-slate-400 bg-slate-200 w-1/3 text-center text-blue-500 px-2 py-2";
}
/**
* CSS classes for amount input field
* Reduces template complexity for input styling
*/
get amountInputClasses(): string {
return "w-full border border-r-0 border-slate-400 px-2 py-2 text-center";
}
/**
* CSS classes for the right-most increment button
* Reduces template complexity for border styling
*/
get incrementButtonClasses(): string {
return "rounded-r border border-slate-400 bg-slate-200 px-4 py-2";
}
/**
@@ -152,7 +173,13 @@ export default class OfferDialog extends Vue {
};
}
/**
* Whether the decrement button should be visible
* Encapsulates conditional logic from template
*/
get showDecrementButton(): boolean {
return this.amountInput !== "0";
}
// =================================================
// COMPONENT METHODS
@@ -199,14 +226,30 @@ export default class OfferDialog extends Vue {
this.visible = false;
}
/**
* Cycle through available unit codes
*/
changeUnitCode() {
const units = Object.keys(this.libsUtil.UNIT_SHORT);
const index = units.indexOf(this.amountUnitCode);
this.amountUnitCode = units[(index + 1) % units.length];
}
/**
* Handle amount updates from AmountInput component
* @param value - New amount value
* Increment the amount input
*/
handleAmountUpdate(value: number) {
this.amountInput = value.toString();
increment() {
this.amountInput = `${(parseFloat(this.amountInput) || 0) + 1}`;
}
/**
* Decrement the amount input
*/
decrement() {
this.amountInput = `${Math.max(
0,
(parseFloat(this.amountInput) || 1) - 1,
)}`;
}
/**
@@ -230,28 +273,6 @@ export default class OfferDialog extends Vue {
* Confirm and submit the offer
*/
async confirm() {
if (!this.activeDid) {
this.notify.error(NOTIFY_OFFER_IDENTITY_REQUIRED.message, TIMEOUTS.LONG);
return;
}
if (parseFloat(this.amountInput) < 0) {
this.notify.error(
NOTIFY_OFFER_ERROR_NEGATIVE_AMOUNT.message,
TIMEOUTS.SHORT,
);
return;
}
if (!this.description && !parseFloat(this.amountInput)) {
const message = NOTIFY_OFFER_DESCRIPTION_REQUIRED.message.replace(
"{unit}",
this.libsUtil.UNIT_LONG[this.amountUnitCode],
);
this.notify.error(message, TIMEOUTS.SHORT);
return;
}
this.close();
this.notify.toast(NOTIFY_OFFER_RECORDING.text, undefined, TIMEOUTS.BRIEF);
@@ -280,6 +301,20 @@ export default class OfferDialog extends Vue {
unitCode: string = "HUR",
expirationDateInput?: string,
) {
if (!this.activeDid) {
this.notify.error(NOTIFY_OFFER_IDENTITY_REQUIRED.message, TIMEOUTS.LONG);
return;
}
if (!description && !amount) {
const message = NOTIFY_OFFER_DESCRIPTION_REQUIRED.message.replace(
"{unit}",
this.libsUtil.UNIT_LONG[unitCode],
);
this.notify.error(message, TIMEOUTS.MODAL);
return;
}
try {
const result = await createAndSubmitOffer(
this.axios,
@@ -328,7 +363,7 @@ export default class OfferDialog extends Vue {
display: flex;
justify-content: center;
align-items: center;
z-index: 50;
z-index: 1000;
}
.dialog {

View File

@@ -19,8 +19,7 @@ export enum AppString {
PROD_PARTNER_API_SERVER = "https://partner-api.endorser.ch",
TEST_PARTNER_API_SERVER = "https://test-partner-api.endorser.ch",
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
LOCAL_PARTNER_API_SERVER = "http://127.0.0.1:3000",
LOCAL_PARTNER_API_SERVER = "http://127.0.0.1:3002",
PROD_PUSH_SERVER = "https://timesafari.app",
TEST1_PUSH_SERVER = "https://test.timesafari.app",
@@ -47,6 +46,9 @@ export const DEFAULT_PARTNER_API_SERVER =
export const DEFAULT_PUSH_SERVER =
import.meta.env.VITE_DEFAULT_PUSH_SERVER || AppString.PROD_PUSH_SERVER;
// Production domain for sharing links (always use production URL for sharing)
export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER;
export const IMAGE_TYPE_PROFILE = "profile";
export const PASSKEYS_ENABLED =

View File

@@ -1191,6 +1191,17 @@ export const NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER = {
message: "You must select an identifier before you can record a give.",
};
export const NOTIFY_GIFTED_DETAILS_PROJECT_PROVIDER_INFO = {
title: "Project Provider Info",
message:
"To select a project as a provider, you must open this page through a project.",
};
export const NOTIFY_GIFTED_DETAILS_BOTH_PROVIDER_SELECTED = {
title: "Invalid Selection",
message: "You cannot select both a giving project and person.",
};
export const NOTIFY_GIFTED_DETAILS_RECORDING_GIVE = {
title: "",
message: "Recording the give...",

View File

@@ -131,7 +131,7 @@ const MIGRATIONS = [
* @param extractMigrationNames - A function that extracts the names (string array) from "select name from migrations"
*/
export async function runMigrations<T>(
sqlExec: (sql: string, params?: unknown[]) => Promise<void>,
sqlExec: (sql: string, params?: unknown[]) => Promise<unknown>,
sqlQuery: (sql: string, params?: unknown[]) => Promise<T>,
extractMigrationNames: (result: T) => Set<string>,
): Promise<void> {

View File

@@ -273,8 +273,8 @@ export async function logToDb(
// Prevent infinite logging loops - if we're already trying to log to database,
// just log to console instead to break circular dependency
if (isLoggingToDatabase) {
// eslint-disable-next-line no-console
console.log(`[DB-PREVENTED-${level.toUpperCase()}] ${message}`);
// Use logger.debug for controlled debug output instead of direct console.log
logger.debug(`[DB-PREVENTED-${level.toUpperCase()}] ${message}`);
return;
}

View File

@@ -32,17 +32,6 @@ export type ContactWithJsonStrings = Omit<Contact, "contactMethods"> & {
contactMethods?: string;
};
/**
* This is for those cases (eg. with a DB) where field values may be all primitives or may be JSON values.
* See src/db/databaseUtil.ts parseJsonField for more details.
*
* This is so that we can reuse most of the type and don't have to maintain another copy.
* Another approach uses typescript conditionals: https://chatgpt.com/share/6855cdc3-ab5c-8007-8525-726612016eb2
*/
export type ContactMaybeWithJsonStrings = Omit<Contact, "contactMethods"> & {
contactMethods?: string | Array<ContactMethod>;
};
export const ContactSchema = {
contacts: "&did, name", // no need to key by other things
};

View File

@@ -10,8 +10,6 @@ export type BoundingBox = {
/**
* Settings type encompasses user-specific configuration details.
*
* New entries that are boolean should also be added to PlatformServiceMixin._mapColumnsToValues
*/
export type Settings = {
// default entry is keyed with MASTER_SETTINGS_KEY; other entries are linked to an account with account ID

View File

@@ -1,7 +1,10 @@
// similar to VerifiableCredentialSubject... maybe rename this
export interface GenericVerifiableCredential {
"@context"?: string;
"@type"?: string;
"@type": string;
name?: string;
description?: string;
agent?: string | { identifier: string };
[key: string]: unknown;
}
@@ -44,7 +47,7 @@ export interface KeyMetaWithPrivate extends KeyMeta {
}
export interface QuantitativeValue extends GenericVerifiableCredential {
"@type"?: "QuantitativeValue";
"@type": "QuantitativeValue";
"@context"?: string;
amountOfThisGood: number;
unitCode: string;
@@ -94,7 +97,8 @@ export interface ClaimObject {
export interface VerifiableCredentialClaim {
"@context"?: string;
"@type"?: string;
"@type": string;
type: string[];
credentialSubject: ClaimObject;
[key: string]: unknown;
}

View File

@@ -33,6 +33,7 @@ export const deepLinkSchemas = {
id: z.string(),
}),
"claim-add-raw": z.object({
id: z.string(),
claim: z.string().optional(),
claimJwtId: z.string().optional(),
}),

View File

@@ -212,13 +212,13 @@ const testRecursivelyOnStrings = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function containsHiddenDid(obj: any) {
return testRecursivelyOnStrings(obj, isHiddenDid);
return testRecursivelyOnStrings(isHiddenDid, obj);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const containsNonHiddenDid = (obj: any) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return testRecursivelyOnStrings(obj, (s: any) => isDid(s) && !isHiddenDid(s));
return testRecursivelyOnStrings((s: any) => isDid(s) && !isHiddenDid(s), obj);
};
export function stripEndorserPrefix(claimId: string) {
@@ -697,6 +697,7 @@ export function hydrateGive(
if (amount && !isNaN(amount)) {
const quantitativeValue: QuantitativeValue = {
"@type": "QuantitativeValue",
amountOfThisGood: amount,
unitCode: unitCode || "HUR",
};
@@ -1341,6 +1342,7 @@ export async function createEndorserJwtVcFromClaim(
vc: {
"@context": "https://www.w3.org/2018/credentials/v1",
"@type": "VerifiableCredential",
type: ["VerifiableCredential"],
credentialSubject: claim,
},
};
@@ -1378,6 +1380,7 @@ export async function createInviteJwt(
vc: {
"@context": "https://www.w3.org/2018/credentials/v1",
"@type": "VerifiableCredential",
type: ["VerifiableCredential"],
credentialSubject: vcClaim as unknown as ClaimObject, // Type assertion needed due to object being string
},
};

View File

@@ -4,6 +4,6 @@ export interface UserProfile {
locLon?: number;
locLat2?: number;
locLon2?: number;
issuerDid: string;
issuerDid?: string;
rowId?: string; // set on profile retrieved from server
}

View File

@@ -7,7 +7,7 @@ import { useClipboard } from "@vueuse/core";
import { DEFAULT_PUSH_SERVER, NotificationIface } from "../constants/app";
import { Account, AccountEncrypted } from "../db/tables/accounts";
import { Contact } from "../db/tables/contacts";
import { Contact, ContactWithJsonStrings } from "../db/tables/contacts";
import { DEFAULT_PASSKEY_EXPIRATION_MINUTES } from "../db/tables/settings";
import {
arrayBufferToBase64,
@@ -34,7 +34,18 @@ import { PlatformServiceFactory } from "../services/PlatformServiceFactory";
import { IIdentifier } from "@veramo/core";
import { DEFAULT_ROOT_DERIVATION_PATH } from "./crypto";
// Consolidate this with src/utils/PlatformServiceMixin.mapQueryResultToValues
// Consolidate this with src/utils/PlatformServiceMixin._parseJsonField
function parseJsonField<T>(value: unknown, defaultValue: T): T {
if (typeof value === "string") {
try {
return JSON.parse(value);
} catch {
return defaultValue;
}
}
return (value as T) || defaultValue;
}
function mapQueryResultToValues(
record: { columns: string[]; values: unknown[][] } | undefined,
): Array<Record<string, unknown>> {
@@ -57,10 +68,10 @@ async function getPlatformService() {
}
export interface GiverReceiverInputInfo {
did?: string; // only for people
did?: string;
name?: string;
image?: string;
handleId?: string; // only for projects
handleId?: string;
}
export enum OnboardPage {
@@ -180,9 +191,9 @@ export const nameForDid = (
did: string,
): string => {
if (did === activeDid) {
return "You";
return "you";
}
const contact = R.find((con) => con.did === did, contacts);
const contact = R.find((con) => con.did == did, contacts);
return nameForContact(contact);
};
@@ -491,15 +502,7 @@ export function findAllVisibleToDids(
import * as R from 'ramda';
//import { findAllVisibleToDids } from './src/libs/util'; // doesn't work because other dependencies fail so gotta copy-and-paste function
console.log(R.equals(findAllVisibleToDids(null), {}));
console.log(R.equals(findAllVisibleToDids(9), {}));
console.log(R.equals(findAllVisibleToDids([]), {}));
console.log(R.equals(findAllVisibleToDids({}), {}));
console.log(R.equals(findAllVisibleToDids({ issuer: "abc" }), {}));
console.log(R.equals(findAllVisibleToDids({ issuerVisibleToDids: ["abc"] }), { ".issuer": ["abc"] }));
console.log(R.equals(findAllVisibleToDids([{ issuerVisibleToDids: ["abc"] }]), { "[0].issuer": ["abc"] }));
console.log(R.equals(findAllVisibleToDids(["xyz", { fluff: { issuerVisibleToDids: ["abc"] } }]), { "[1].fluff.issuer": ["abc"] }));
console.log(R.equals(findAllVisibleToDids(["xyz", { fluff: { issuerVisibleToDids: ["abc"] }, stuff: [ { did: "HIDDEN", agentDidVisibleToDids: ["def", "ghi"] } ] }]), { "[1].fluff.issuer": ["abc"], "[1].stuff[0].agentDid": ["def", "ghi"] }));
// Test/debug console.log statements removed - use logger.debug() if needed
*
**/
@@ -795,7 +798,7 @@ export const contactToCsvLine = (contact: Contact): string => {
// Handle contactMethods array by stringifying it
const contactMethodsStr = contact.contactMethods
? escapeField(JSON.stringify(contact.contactMethods))
? escapeField(JSON.stringify(parseJsonField(contact.contactMethods, [])))
: "";
const fields = [
@@ -893,19 +896,31 @@ export interface DatabaseExport {
}
/**
* Converts an array of contacts to the export JSON format.
* Converts an array of contacts to the standardized database export JSON format.
* This format is used for data migration and backup purposes.
*
* @param contacts - Array of Contact objects to convert
* @returns DatabaseExport object in the standardized format
*/
export const contactsToExportJson = (contacts: Contact[]): DatabaseExport => {
// Convert each contact to a plain object and ensure all fields are included
const rows = contacts.map((contact) => {
const exContact: ContactWithJsonStrings = R.omit(
["contactMethods"],
contact,
);
exContact.contactMethods = contact.contactMethods
? JSON.stringify(parseJsonField(contact.contactMethods, []))
: undefined;
return exContact;
});
return {
data: {
data: [
{
tableName: "contacts",
rows: contacts,
rows,
},
],
},

View File

@@ -79,7 +79,7 @@ window.addEventListener("unhandledrejection", (event) => {
});
// Electron-specific initialization
if (typeof window !== "undefined" && typeof window.require === "function") {
if (typeof window !== "undefined" && window.require) {
// We're in an Electron renderer process
logger.log("[Electron] Detected Electron renderer process");

View File

@@ -250,6 +250,12 @@ onerror = function (error) {
* Auto-initialize on worker startup (removed to prevent circular dependency)
* Initialization now happens on first database operation
*/
// Use console for critical startup message to avoid circular dependency
// eslint-disable-next-line no-console
console.log("[SQLWorker] Worker loaded, ready to receive messages");
// Use logger.debug for controlled debug output instead of direct console.log
// Note: This is a worker context, so we use a simple debug message
if (typeof self !== "undefined" && self.name) {
// Worker context - use simple debug output
self.postMessage({
type: "debug",
message: "[SQLWorker] Worker loaded, ready to receive messages",
});
}

View File

@@ -338,7 +338,7 @@ router.onError(errorHandler); // Assign the error handler to the router instance
* @param from - Source route
* @param next - Navigation function
*/
router.beforeEach(async (to, _from, next) => {
router.beforeEach(async (to, from, next) => {
try {
// Skip identity check for routes that handle identity creation manually
const skipIdentityRoutes = [

View File

@@ -134,11 +134,7 @@ class AbsurdSqlDatabaseService implements DatabaseService {
// An error is thrown without this pragma: "File has invalid page size. (the first block of a new file must be written first)"
await this.db.exec(`PRAGMA journal_mode=MEMORY;`);
// Create wrapper functions that match the expected signatures
const sqlExec = async (sql: string, params?: unknown[]): Promise<void> => {
await this.db!.run(sql, params);
};
const sqlExec = this.db.run.bind(this.db);
const sqlQuery = this.db.exec.bind(this.db);
// Extract the migration names for the absurd-sql format
@@ -182,6 +178,14 @@ class AbsurdSqlDatabaseService implements DatabaseService {
}
operation.resolve(result);
} catch (error) {
// logger.error( // DISABLED
// "Error while processing SQL queue:",
// error,
// " ... for sql:",
// operation.sql,
// " ... with params:",
// operation.params,
// );
logger.error(
"Error while processing SQL queue:",
error,
@@ -234,6 +238,9 @@ class AbsurdSqlDatabaseService implements DatabaseService {
// If initialized but no db, something went wrong
if (!this.db) {
// logger.error( // DISABLED
// `Database not properly initialized after await waitForInitialization() - initialized flag is true but db is null`,
// );
logger.error(
`Database not properly initialized after await waitForInitialization() - initialized flag is true but db is null`,
);

View File

@@ -42,9 +42,8 @@ export class PlatformServiceFactory {
const platform = process.env.VITE_PLATFORM || "web";
if (!PlatformServiceFactory.creationLogged) {
// Use console for critical startup message to avoid circular dependency
// eslint-disable-next-line no-console
console.log(
// Use logger.debug for controlled debug output instead of direct console.log
logger.debug(
`[PlatformServiceFactory] Creating singleton instance for platform: ${platform}`,
);
PlatformServiceFactory.creationLogged = true;

View File

@@ -103,10 +103,9 @@ export class ProfileService {
{ headers },
);
if (response.status === 201) {
if (response.status === 200) {
return true;
} else {
logger.error("Error saving profile:", response);
throw new Error(ACCOUNT_VIEW_CONSTANTS.ERRORS.PROFILE_NOT_SAVED);
}
} catch (error) {

View File

@@ -149,10 +149,6 @@ export class DeepLinkHandler {
params[routeConfig.paramKey ?? "id"] = pathParams.join("/");
}
// logConsoleAndDb(
// `[DeepLink] Debug: Route Path: ${routePath} Path Params: ${JSON.stringify(params)} Query String: ${JSON.stringify(query)}`,
// false,
// );
return { path: routePath, params, query };
}
@@ -178,7 +174,7 @@ export class DeepLinkHandler {
const validRoute = routeSchema.parse(path) as DeepLinkRoute;
routeName = ROUTE_MAP[validRoute].name;
} catch (error) {
console.error(`[DeepLink] Invalid route path: ${path}`);
logger.error(`[DeepLink] Invalid route path: ${path}`);
// Redirect to error page with information about the invalid link
await this.router.replace({
@@ -199,14 +195,14 @@ export class DeepLinkHandler {
// Continue with parameter validation as before...
const schema = deepLinkSchemas[path as keyof typeof deepLinkSchemas];
let validatedParams;
let validatedParams, validatedQuery;
try {
validatedParams = await schema.parseAsync(params);
validatedQuery = await schema.parseAsync(query);
} catch (error) {
// For parameter validation errors, provide specific error feedback
logConsoleAndDb(
logger.error(
`[DeepLink] Invalid parameters for route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with params: ${JSON.stringify(params)} ... and query: ${JSON.stringify(query)}`,
true,
);
await this.router.replace({
name: "deep-link-error",
@@ -227,11 +223,11 @@ export class DeepLinkHandler {
await this.router.replace({
name: routeName,
params: validatedParams,
query: validatedQuery,
});
} catch (error) {
logConsoleAndDb(
`[DeepLink] Error routing to route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with validated params: ${JSON.stringify(validatedParams)}`,
true,
logger.error(
`[DeepLink] Error routing to route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with validated params: ${JSON.stringify(validatedParams)} ... and validated query: ${JSON.stringify(validatedQuery)}`,
);
// For parameter validation errors, provide specific error feedback
await this.router.replace({
@@ -241,6 +237,7 @@ export class DeepLinkHandler {
originalPath: path,
errorCode: "ROUTING_ERROR",
errorMessage: `Error routing to ${routeName}: ${JSON.stringify(error)}`,
...validatedQuery,
},
});
}
@@ -263,9 +260,8 @@ export class DeepLinkHandler {
await this.validateAndRoute(path, sanitizedParams, query);
} catch (error) {
const deepLinkError = error as DeepLinkError;
logConsoleAndDb(
logger.error(
`[DeepLink] Error (${deepLinkError.code}): ${deepLinkError.details}`,
true,
);
throw {

View File

@@ -11,6 +11,7 @@ import {
SQLiteConnection,
SQLiteDBConnection,
CapacitorSQLite,
capSQLiteChanges,
DBSQLiteValues,
} from "@capacitor-community/sqlite";
@@ -492,17 +493,22 @@ export class CapacitorPlatformService implements PlatformService {
* @param params - Optional parameters for prepared statements
* @returns Promise resolving to execution results
*/
const sqlExec = async (sql: string, params?: unknown[]): Promise<void> => {
const sqlExec = async (
sql: string,
params?: unknown[],
): Promise<capSQLiteChanges> => {
logger.debug(`🔧 [CapacitorMigration] Executing SQL:`, sql);
if (params && params.length > 0) {
// Use run method for parameterized queries (prepared statements)
// This is essential for proper parameter binding and SQL injection prevention
await this.db!.run(sql, params);
const result = await this.db!.run(sql, params);
return result;
} else {
// Use execute method for non-parameterized queries
// This is more efficient for simple DDL statements
await this.db!.execute(sql);
const result = await this.db!.execute(sql);
return result;
}
};

View File

@@ -97,9 +97,8 @@ export class WebPlatformService implements PlatformService {
}
} else {
// We're in a worker context - skip initBackend call
// Use console for critical startup message to avoid circular dependency
// eslint-disable-next-line no-console
console.log(
// Use logger.debug for controlled debug output instead of direct console.log
logger.debug(
"[WebPlatformService] Skipping initBackend call in worker context",
);
}
@@ -693,11 +692,7 @@ export class WebPlatformService implements PlatformService {
const setClause = keys.map((key) => `${key} = ?`).join(", ");
const sql = `UPDATE settings SET ${setClause} WHERE accountDid = ?`;
const params = [...keys.map((key) => settings[key]), did];
console.log(
"[WebPlatformService] updateDidSpecificSettings",
sql,
JSON.stringify(params, null, 2),
);
// Debug logging removed - use logger.debug() if needed
await this.dbExec(sql, params);
}

View File

@@ -11,7 +11,7 @@
class="px-4 py-2 rounded mr-2 transition-colors"
@click="testInsert"
>
Test Contact Insert
Test Insert
</button>
<button
:class="
@@ -22,7 +22,7 @@
class="px-4 py-2 rounded mr-2 transition-colors"
@click="testUpdate"
>
Test Contact Update
Test Update
</button>
<button
:class="
@@ -44,7 +44,7 @@
class="px-4 py-2 rounded mr-2 transition-colors"
@click="testDatabaseStorage"
>
Test SearchBox Database Storage -- Beware: Changes Your Search Box
Test Database Storage Format
</button>
<button
:class="
@@ -86,6 +86,7 @@
import { Component, Vue } from "vue-facing-decorator";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { logger } from "@/utils/logger";
@Component({
mixins: [PlatformServiceMixin],
@@ -267,7 +268,7 @@ This tests the complete save → retrieve cycle with actual database interaction
this.result = `User #0 settings test completed. isRegistered: ${accountSettings.isRegistered}`;
} catch (error) {
this.result = `Error testing User #0 settings: ${error}`;
console.error("Error testing User #0 settings:", error);
logger.error("Error testing User #0 settings:", error);
}
}
}

View File

@@ -1,13 +0,0 @@
declare global {
interface Window {
electronAPI?: {
exportData: (fileName: string, content: string) => Promise<{
success: boolean;
path?: string;
error?: string;
}>;
};
}
}
export {};

View File

@@ -50,7 +50,7 @@ import {
type SettingsWithJsonStrings,
} from "@/db/tables/settings";
import { logger } from "@/utils/logger";
import { Contact, ContactMaybeWithJsonStrings } from "@/db/tables/contacts";
import { Contact } from "@/db/tables/contacts";
import { Account } from "@/db/tables/accounts";
import { Temp } from "@/db/tables/temp";
import { QueryExecResult, DatabaseExecResult } from "@/interfaces/database";
@@ -246,15 +246,6 @@ export const PlatformServiceMixin = {
// Keep null values as null
}
// Handle JSON fields like contactMethods
if (column === "contactMethods" && typeof value === "string") {
try {
value = JSON.parse(value);
} catch {
value = [];
}
}
obj[column] = value;
});
return obj;
@@ -468,10 +459,13 @@ export const PlatformServiceMixin = {
return settings;
} catch (error) {
logger.error(`[Settings Trace] ❌ Failed to get settings:`, {
key,
error,
});
logger.error(
`[${(this as unknown as VueComponentWithMixin).$options.name}] Failed to get settings:`,
{
key,
error,
},
);
return fallback;
}
},
@@ -539,11 +533,14 @@ export const PlatformServiceMixin = {
return mergedSettings;
} catch (error) {
logger.error(`[Settings Trace] ❌ Failed to get merged settings:`, {
defaultKey,
accountDid,
error,
});
logger.error(
`[${(this as unknown as VueComponentWithMixin).$options.name}] Failed to get merged settings:`,
{
defaultKey,
accountDid,
error,
},
);
return defaultFallback;
}
},
@@ -651,81 +648,15 @@ export const PlatformServiceMixin = {
// CACHED SPECIALIZED SHORTCUTS (massive performance boost)
// =================================================
/**
* Normalize contact data by parsing JSON strings into proper objects
* Handles the contactMethods field which can be either a JSON string or an array
* @param rawContacts Raw contact data from database
* @returns Normalized Contact[] array
*/
$normalizeContacts(rawContacts: ContactMaybeWithJsonStrings[]): Contact[] {
return rawContacts.map((contact) => {
// Create a new contact object with proper typing
const normalizedContact: Contact = {
did: contact.did,
iViewContent: contact.iViewContent,
name: contact.name,
nextPubKeyHashB64: contact.nextPubKeyHashB64,
notes: contact.notes,
profileImageUrl: contact.profileImageUrl,
publicKeyBase64: contact.publicKeyBase64,
seesMe: contact.seesMe,
registered: contact.registered,
};
// Handle contactMethods field which can be a JSON string or an array
if (contact.contactMethods !== undefined) {
if (typeof contact.contactMethods === "string") {
// Parse JSON string into array
normalizedContact.contactMethods = this._parseJsonField(
contact.contactMethods,
[],
);
} else if (Array.isArray(contact.contactMethods)) {
// Validate that each item in the array is a proper ContactMethod object
normalizedContact.contactMethods = contact.contactMethods.filter(
(method) => {
const isValid =
method &&
typeof method === "object" &&
typeof method.label === "string" &&
typeof method.type === "string" &&
typeof method.value === "string";
if (!isValid && method !== undefined) {
console.warn(
"[ContactNormalization] Invalid contact method:",
method,
);
}
return isValid;
},
);
} else {
// Invalid data, use empty array
normalizedContact.contactMethods = [];
}
} else {
// No contactMethods, use empty array
normalizedContact.contactMethods = [];
}
return normalizedContact;
});
},
/**
* Load all contacts (always fresh) - $contacts()
* Always fetches fresh data from database for consistency
* Handles JSON string/object duality for contactMethods field
* @returns Promise<Contact[]> Array of normalized contact objects
* @returns Promise<Contact[]> Array of contact objects
*/
async $contacts(): Promise<Contact[]> {
const rawContacts = (await this.$query(
return (await this.$query(
"SELECT * FROM contacts ORDER BY name",
)) as ContactMaybeWithJsonStrings[];
return this.$normalizeContacts(rawContacts);
)) as Contact[];
},
/**
@@ -817,20 +748,22 @@ export const PlatformServiceMixin = {
);
mergedSettings.apiServer = DEFAULT_ENDORSER_API_SERVER;
logger.debug(
`[Electron Settings] Forced API server to: ${DEFAULT_ENDORSER_API_SERVER}`,
);
}
// Merge with any provided defaults (these take highest precedence)
// Filter out undefined and empty string values to prevent overriding real settings
const filteredDefaults = Object.fromEntries(
Object.entries(defaults).filter(
([_, value]) => value !== undefined && value !== "",
),
);
const finalSettings = { ...mergedSettings, ...defaults };
const finalSettings = { ...mergedSettings, ...filteredDefaults };
// Debug logging removed - use logger.debug() if needed
return finalSettings;
} catch (error) {
logger.error("[Settings Trace] ❌ Error in $accountSettings:", error);
logger.error(
"[PlatformServiceMixin] Error in $accountSettings:",
error,
);
// Fallback to defaults on error
return defaults;
@@ -1060,18 +993,12 @@ export const PlatformServiceMixin = {
contact.profileImageUrl !== undefined
? contact.profileImageUrl
: null,
contactMethods:
contact.contactMethods !== undefined
? Array.isArray(contact.contactMethods)
? JSON.stringify(contact.contactMethods)
: contact.contactMethods
: null,
};
await this.$dbExec(
`INSERT OR REPLACE INTO contacts
(did, name, publicKeyBase64, seesMe, registered, nextPubKeyHashB64, profileImageUrl, contactMethods)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
(did, name, publicKeyBase64, seesMe, registered, nextPubKeyHashB64, profileImageUrl)
VALUES (?, ?, ?, ?, ?, ?, ?)`,
[
safeContact.did,
safeContact.name,
@@ -1080,7 +1007,6 @@ export const PlatformServiceMixin = {
safeContact.registered,
safeContact.nextPubKeyHashB64,
safeContact.profileImageUrl,
safeContact.contactMethods,
],
);
return true;
@@ -1108,13 +1034,7 @@ export const PlatformServiceMixin = {
Object.entries(changes).forEach(([key, value]) => {
if (value !== undefined) {
setParts.push(`${key} = ?`);
// Handle contactMethods field - convert array to JSON string
if (key === "contactMethods" && Array.isArray(value)) {
params.push(JSON.stringify(value));
} else {
params.push(value);
}
params.push(value);
}
});
@@ -1136,36 +1056,45 @@ export const PlatformServiceMixin = {
/**
* Get all contacts as typed objects - $getAllContacts()
* Eliminates verbose query + mapping patterns
* Handles JSON string/object duality for contactMethods field
* @returns Promise<Contact[]> Array of normalized contact objects
* @returns Promise<Contact[]> Array of contact objects
*/
async $getAllContacts(): Promise<Contact[]> {
const rawContacts = (await this.$query(
"SELECT * FROM contacts ORDER BY name",
)) as ContactMaybeWithJsonStrings[];
const results = await this.$dbQuery(
"SELECT did, name, publicKeyBase64, seesMe, registered, nextPubKeyHashB64, profileImageUrl FROM contacts ORDER BY name",
);
return this.$normalizeContacts(rawContacts);
return this.$mapResults(results, (row: unknown[]) => ({
did: row[0] as string,
name: row[1] as string,
publicKeyBase64: row[2] as string,
seesMe: Boolean(row[3]),
registered: Boolean(row[4]),
nextPubKeyHashB64: row[5] as string,
profileImageUrl: row[6] as string,
}));
},
/**
* Get single contact by DID - $getContact()
* Eliminates verbose single contact query patterns
* Handles JSON string/object duality for contactMethods field
* @param did Contact DID to retrieve
* @returns Promise<Contact | null> Normalized contact object or null if not found
* @returns Promise<Contact | null> Contact object or null if not found
*/
async $getContact(did: string): Promise<Contact | null> {
const rawContacts = (await this.$query(
const results = await this.$dbQuery(
"SELECT * FROM contacts WHERE did = ?",
[did],
)) as ContactMaybeWithJsonStrings[];
);
if (rawContacts.length === 0) {
if (!results || !results.values || results.values.length === 0) {
return null;
}
const normalizedContacts = this.$normalizeContacts(rawContacts);
return normalizedContacts[0];
const contactData = this._mapColumnsToValues(
results.columns,
results.values,
);
return contactData.length > 0 ? (contactData[0] as Contact) : null;
},
/**
@@ -1760,7 +1689,6 @@ declare module "@vue/runtime-core" {
$contactCount(): Promise<number>;
$settings(defaults?: Settings): Promise<Settings>;
$accountSettings(did?: string, defaults?: Settings): Promise<Settings>;
$normalizeContacts(rawContacts: ContactMaybeWithJsonStrings[]): Contact[];
// Settings update shortcuts (eliminate 90% boilerplate)
$saveSettings(changes: Partial<Settings>): Promise<boolean>;

View File

@@ -45,6 +45,7 @@ export function safeStringify(obj: unknown) {
// Determine if we should suppress verbose logging (for Electron)
const isElectron = process.env.VITE_PLATFORM === "electron";
const isProduction = process.env.NODE_ENV === "production";
const isDebugEnabled = process.env.VITE_DEBUG_LOGGING === "true";
// Track initialization state to prevent circular dependencies
let isInitializing = true;
@@ -108,8 +109,8 @@ async function logToDatabase(
// Enhanced logger with self-contained database methods
export const logger = {
debug: (message: string, ...args: unknown[]) => {
// Debug logs are very verbose - only show in development mode for web
if (!isProduction && !isElectron) {
// Debug logs are very verbose - only show when explicitly enabled
if (isDebugEnabled && !isProduction && !isElectron) {
// eslint-disable-next-line no-console
console.debug(message, ...args);
}

View File

@@ -60,10 +60,8 @@
@share-info="onShareInfo"
/>
<!-- Notifications -->
<!-- Currently disabled because it doesn't work, even on Chrome. If restored, make sure it works or doesn't show on mobile/electron. -->
<section
v-if="false"
v-if="isRegistered"
id="sectionNotifications"
class="bg-slate-100 rounded-md overflow-hidden px-4 py-4 mt-8 mb-8"
aria-labelledby="notificationsHeading"
@@ -1663,12 +1661,14 @@ export default class AccountViewView extends Vue {
}
onShareInfo() {
// Navigate to QR code sharing page - mobile uses full scan, web uses basic
if (Capacitor.isNativePlatform()) {
this.$router.push({ name: "contact-qr-scan-full" });
} else {
this.$router.push({ name: "contact-qr" });
}
// Call the existing logic for sharing info, e.g., open the share dialog
this.openShareDialog();
}
// Placeholder for share dialog logic
openShareDialog() {
// TODO: Implement share dialog logic
this.notify.info("Share dialog not yet implemented.");
}
onRecheckLimits() {

View File

@@ -52,6 +52,7 @@ function isApiResponse(response: unknown): response is AxiosResponse {
);
}
// TODO: Testing Required - Database Operations + Logging Migration to PlatformServiceMixin
// Priority: High | Migrated: 2025-07-06 | Author: Matthew Raymer
//
// MIGRATION DETAILS: Migrated from legacy database utilities + logging to PlatformServiceMixin

View File

@@ -199,16 +199,7 @@
/>
</button>
</div>
<GiftedDialog
ref="customGiveDialog"
:giver-entity-type="'person'"
:recipient-entity-type="projectInfo ? 'project' : 'person'"
:to-project-id="
detailsForGive?.fulfillsPlanHandleId ||
detailsForOffer?.fulfillsPlanHandleId ||
''
"
/>
<GiftedDialog ref="customGiveDialog" />
<div v-if="libsUtil.isGiveAction(veriClaim)">
<div class="flex columns-3">
@@ -558,12 +549,6 @@ export default class ClaimView extends Vue {
fulfillsHandleId?: string;
} | null = null;
detailsForOffer: { fulfillsPlanHandleId?: string } | null = null;
// Project information for fulfillsPlanHandleId
projectInfo: {
name: string;
imageUrl?: string;
issuer: string;
} | null = null;
fullClaim = null;
fullClaimDump = "";
fullClaimMessage = "";
@@ -689,7 +674,6 @@ export default class ClaimView extends Vue {
this.confsVisibleToIdList = [];
this.detailsForGive = null;
this.detailsForOffer = null;
this.projectInfo = null;
this.fullClaim = null;
this.fullClaimDump = "";
this.fullClaimMessage = "";
@@ -867,14 +851,6 @@ export default class ClaimView extends Vue {
}
}
// Load project information if there's a fulfillsPlanHandleId
const planHandleId =
this.detailsForGive?.fulfillsPlanHandleId ||
this.detailsForOffer?.fulfillsPlanHandleId;
if (planHandleId) {
await this.loadProjectInfo(planHandleId, userDid);
}
// retrieve the list of confirmers
const confirmerInfo = await libsUtil.retrieveConfirmerIdList(
this.apiServer,
@@ -902,33 +878,6 @@ export default class ClaimView extends Vue {
}
}
async loadProjectInfo(planHandleId: string, userDid: string) {
const url =
this.apiServer +
"/api/claim/byHandle/" +
encodeURIComponent(planHandleId);
const headers = await serverUtil.getHeaders(userDid);
try {
const resp = await this.axios.get(url, { headers });
if (resp.status === 200) {
this.projectInfo = {
name: resp.data.claim?.name || "(no name)",
imageUrl: resp.data.claim?.image,
issuer: resp.data.issuer,
};
} else {
await this.$logError(
"Error getting project info: " + JSON.stringify(resp),
);
}
} catch (error: unknown) {
await this.$logError(
"Error retrieving project info: " + JSON.stringify(error),
);
}
}
async showFullClaim(claimId: string) {
const url =
this.apiServer + "/api/claim/full/" + encodeURIComponent(claimId);
@@ -1048,52 +997,11 @@ export default class ClaimView extends Vue {
this.veriClaim as GenericCredWrapper<OfferClaim>,
),
};
// Determine recipient based on whether it's a project or person
let recipient: libsUtil.GiverReceiverInputInfo | undefined;
if (this.projectInfo) {
// Recipient is a project
recipient = {
name: this.projectInfo.name,
handleId: this.detailsForOffer?.fulfillsPlanHandleId,
image: this.projectInfo.imageUrl,
};
} else {
// Recipient is a person - we need to determine who that person is
// For offers, the recipient is typically the person who made the offer
const offerClaim = this.veriClaim.claim as OfferClaim;
const recipientDid =
offerClaim.recipient?.identifier || this.veriClaim.issuer;
if (recipientDid) {
const recipientContact = serverUtil.contactForDid(
recipientDid,
this.allContacts,
);
recipient = {
did: recipientDid,
name: recipientContact?.name || recipientDid,
};
}
}
// Extract offer information from the claim
const offerClaim = this.veriClaim.claim as OfferClaim;
const description =
offerClaim.itemOffered?.description || offerClaim.description;
const amount =
offerClaim.includesObject?.amountOfThisGood?.toString() || "0";
const unitCode = offerClaim.includesObject?.unitCode || "HUR";
(this.$refs.customGiveDialog as GiftedDialog).open(
giver,
recipient,
undefined,
this.veriClaim.handleId,
undefined, // prompt
description,
amount,
unitCode,
"Offer fulfilled by " + (giver?.name || "someone not named"),
);
}

View File

@@ -66,11 +66,10 @@
</ul>
<GiftedDialog
ref="giftedDialog"
:giver-entity-type="giverEntityType"
:recipient-entity-type="recipientEntityType"
ref="customDialog"
:from-project-id="fromProjectId"
:to-project-id="toProjectId"
:show-projects="showProjects"
:is-from-project-view="isFromProjectView"
/>
</section>
@@ -103,11 +102,9 @@ export default class ContactGiftingView extends Vue {
activeDid = "";
allContacts: Array<Contact> = [];
apiServer = "";
description = "";
projectId = "";
prompt = "";
description = "";
amountInput = "0";
unitCode = "HUR";
recipientProjectName = "";
recipientProjectImage = "";
recipientProjectHandleId = "";
@@ -126,7 +123,6 @@ export default class ContactGiftingView extends Vue {
toProjectId = "";
showProjects = false;
isFromProjectView = false;
offerId = "";
async created() {
this.notify = createNotifyHelpers(this.$notify);
@@ -147,9 +143,6 @@ export default class ContactGiftingView extends Vue {
this.recipientProjectHandleId =
(this.$route.query["recipientProjectHandleId"] as string) || "";
this.prompt = (this.$route.query["prompt"] as string) ?? this.prompt;
this.description = (this.$route.query["description"] as string) || "";
this.amountInput = (this.$route.query["amountInput"] as string) || "0";
this.unitCode = (this.$route.query["unitCode"] as string) || "HUR";
// Read new context parameters
this.stepType = (this.$route.query["stepType"] as string) || "giver";
@@ -175,7 +168,6 @@ export default class ContactGiftingView extends Vue {
(this.$route.query["showProjects"] as string) === "true";
this.isFromProjectView =
(this.$route.query["isFromProjectView"] as string) === "true";
this.offerId = (this.$route.query["offerId"] as string) || "";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
@@ -190,12 +182,12 @@ export default class ContactGiftingView extends Vue {
openDialog(contact?: GiverReceiverInputInfo | "Unnamed") {
if (contact === "Unnamed") {
// Special case: Handle "Unnamed" contacts for both givers and recipients
// Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected
let recipient: GiverReceiverInputInfo;
let giver: GiverReceiverInputInfo | undefined;
if (this.stepType === "giver") {
// We're selecting a giver, so preserve the existing recipient from context
// We're selecting a giver, so recipient is either a project or the current user
if (this.recipientEntityType === "project") {
recipient = {
did: this.recipientProjectHandleId,
@@ -204,26 +196,64 @@ export default class ContactGiftingView extends Vue {
handleId: this.recipientProjectHandleId,
};
} else {
// Preserve the existing recipient from context
if (this.recipientDid === this.activeDid) {
// Recipient was "You"
recipient = { did: this.activeDid, name: "You" };
} else if (this.recipientDid) {
// Recipient was a regular contact
recipient = {
did: this.recipientDid,
name: this.recipientProjectName || "Someone",
};
} else {
// Fallback to "You" if no recipient was previously selected
recipient = { did: this.activeDid, name: "You" };
}
recipient = { did: this.activeDid, name: "You" };
}
giver = undefined; // Will be set to "Unnamed" in GiftedDialog
} else {
// We're selecting a recipient, so recipient is "Unnamed" and giver is preserved from context
recipient = { did: "", name: "Unnamed" };
// Preserve the existing giver from the context
if (this.giverEntityType === "project") {
giver = {
// no did, because it's a project
name: this.giverProjectName,
image: this.giverProjectImage,
handleId: this.giverProjectHandleId,
};
} else if (this.giverDid) {
giver = {
did: this.giverDid,
name: this.giverProjectName || "Someone",
};
} else {
giver = { did: this.activeDid, name: "You" };
}
}
(this.$refs.customDialog as GiftedDialog).open(
giver,
recipient,
undefined,
this.stepType === "giver" ? "Given by Unnamed" : "Given to Unnamed",
this.prompt,
);
// Immediately select "Unnamed" and move to Step 2
(this.$refs.customDialog as GiftedDialog).selectGiver();
} else {
// Regular case: contact is a GiverReceiverInputInfo
let giver: GiverReceiverInputInfo;
let recipient: GiverReceiverInputInfo;
if (this.stepType === "giver") {
// We're selecting a giver, so the contact becomes the giver
giver = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined
// Recipient is either a project or the current user
if (this.recipientEntityType === "project") {
recipient = {
did: this.recipientProjectHandleId,
name: this.recipientProjectName,
image: this.recipientProjectImage,
handleId: this.recipientProjectHandleId,
};
} else {
recipient = { did: this.activeDid, name: "You" };
}
} else {
// We're selecting a recipient, so the contact becomes the recipient
recipient = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined
// Preserve the existing giver from the context
if (this.giverEntityType === "project") {
giver = {
@@ -242,93 +272,15 @@ export default class ContactGiftingView extends Vue {
}
}
(this.$refs.giftedDialog as GiftedDialog).open(
(this.$refs.customDialog as GiftedDialog).open(
giver,
recipient,
this.offerId,
undefined,
this.stepType === "giver"
? "Given by " + (contact?.name || "someone not named")
: "Given to " + (contact?.name || "someone not named"),
this.prompt,
this.description,
this.amountInput,
this.unitCode,
);
// Move to Step 2 - entities are already set by the open() call
(this.$refs.giftedDialog as GiftedDialog).moveToStep2();
} else {
// Regular case: contact is a GiverReceiverInputInfo
let giver: GiverReceiverInputInfo;
let recipient: GiverReceiverInputInfo;
if (this.stepType === "giver") {
// We're selecting a giver, so the contact becomes the giver
giver = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined
// Preserve the existing recipient from the context
if (this.recipientEntityType === "project") {
recipient = {
did: this.recipientProjectHandleId,
name: this.recipientProjectName,
image: this.recipientProjectImage,
handleId: this.recipientProjectHandleId,
};
} else {
// Check if the preserved recipient was "You" or a regular contact
if (this.recipientDid === this.activeDid) {
// Recipient was "You"
recipient = { did: this.activeDid, name: "You" };
} else if (this.recipientDid) {
// Recipient was a regular contact
recipient = {
did: this.recipientDid,
name: this.recipientProjectName || "Someone",
};
} else {
// Fallback to "Unnamed"
recipient = { did: "", name: "Unnamed" };
}
}
} else {
// We're selecting a recipient, so the contact becomes the recipient
recipient = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined
// Preserve the existing giver from the context
if (this.giverEntityType === "project") {
giver = {
did: this.giverProjectHandleId,
name: this.giverProjectName,
image: this.giverProjectImage,
handleId: this.giverProjectHandleId,
};
} else {
// Check if the preserved giver was "You" or a regular contact
if (this.giverDid === this.activeDid) {
// Giver was "You"
giver = { did: this.activeDid, name: "You" };
} else if (this.giverDid) {
// Giver was a regular contact
giver = {
did: this.giverDid,
name: this.giverProjectName || "Someone",
};
} else {
// Fallback to "Unnamed"
giver = { did: "", name: "Unnamed" };
}
}
}
(this.$refs.giftedDialog as GiftedDialog).open(
giver,
recipient,
this.offerId,
this.prompt,
this.description,
this.amountInput,
this.unitCode,
);
// Move to Step 2 - entities are already set by the open() call
(this.$refs.giftedDialog as GiftedDialog).moveToStep2();
}
}
}

View File

@@ -253,6 +253,22 @@ import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
*
* @component
*/
// TODO: Testing Required - Database Operations + Logging Migration to PlatformServiceMixin
// Priority: Medium | Migrated: 2025-07-06 | Author: Matthew Raymer
//
//
// TESTING NEEDED: Contact import functionality
// 1. Test contact import via URL: /contact-import?contacts=[{"did":"did:example:123","name":"Alice"}]
// 2. Test JWT import via URL path: /contact-import/[JWT_TOKEN]
// 3. Test manual JWT input via textarea
// 4. Test duplicate contact detection and field comparison
// 5. Test error scenarios: invalid JWT, malformed data, network issues
// 6. Verify error logging appears correctly
//
// Test URLs:
// /contact-import (manual input)
// /contact-import?contacts=[{"did":"did:test:123","name":"Test User"}]
@Component({
components: { EntityIcon, OfferDialog, QuickNav },
mixins: [PlatformServiceMixin],

View File

@@ -553,6 +553,11 @@ export default class ContactQRScanFull extends Vue {
return;
}
// Add new contact
// @ts-expect-error because we're just using the value to store to the DB
contact.contactMethods = JSON.stringify(
(this as any)._parseJsonField(contact.contactMethods, []),
);
await this.$insertContact(contact);
if (this.activeDid) {

View File

@@ -151,9 +151,9 @@ import { getContactJwtFromJwtUrl } from "../libs/crypto";
import {
CONTACT_CSV_HEADER,
CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI,
generateEndorserJwtUrlForAccount,
register,
setVisibilityUtil,
generateEndorserJwtUrlForAccount,
} from "../libs/endorserServer";
import { decodeEndorserJwt, ETHR_DID_PREFIX } from "../libs/crypto/vc";
import * as libsUtil from "../libs/util";
@@ -162,6 +162,7 @@ import { logger } from "../utils/logger";
import { QRScannerFactory } from "@/services/QRScanner/QRScannerFactory";
import { CameraState } from "@/services/QRScanner/types";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
import { Account } from "@/db/tables/accounts";
import { createNotifyHelpers } from "@/utils/notify";
import {
NOTIFY_QR_INITIALIZATION_ERROR,
@@ -188,7 +189,6 @@ import {
QR_TIMEOUT_STANDARD,
QR_TIMEOUT_LONG,
} from "@/constants/notifications";
import { Account } from "@/db/tables/accounts";
interface QRScanResult {
rawValue?: string;
@@ -213,11 +213,15 @@ export default class ContactQRScanShow extends Vue {
$router!: Router;
// Notification helper system
notify!: ReturnType<typeof createNotifyHelpers>;
private notify = createNotifyHelpers(this.$notify);
activeDid = "";
apiServer = "";
// Axios instance for API calls
get axios() {
return (this as any).$platformService.axios;
}
givenName = "";
hideRegisterPromptOnNewContact = false;
isRegistered = false;
@@ -284,8 +288,6 @@ export default class ContactQRScanShow extends Vue {
}
async created() {
this.notify = createNotifyHelpers(this.$notify);
try {
const settings = await this.$accountSettings();
this.activeDid = settings.activeDid || "";
@@ -545,7 +547,6 @@ export default class ContactQRScanShow extends Vue {
name: contact.name,
});
this.notify.toast(
"Submitted",
NOTIFY_QR_REGISTRATION_SUBMITTED.message,
QR_TIMEOUT_SHORT,
);
@@ -610,33 +611,21 @@ export default class ContactQRScanShow extends Vue {
}
async onCopyUrlToClipboard() {
try {
// Generate URL for sharing
const account = (await libsUtil.retrieveFullyDecryptedAccount(
this.activeDid,
)) as Account;
const jwtUrl = await generateEndorserJwtUrlForAccount(
account,
this.isRegistered,
this.givenName,
this.profileImageUrl,
true,
);
// Copy the URL to clipboard
useClipboard()
.copy(jwtUrl)
.then(() => {
this.notify.toast(
"Copied",
NOTIFY_QR_URL_COPIED.message,
QR_TIMEOUT_MEDIUM,
);
});
} catch (error) {
logger.error("Failed to generate contact URL:", error);
this.notify.error("Failed to generate contact URL. Please try again.");
}
const account = (await libsUtil.retrieveFullyDecryptedAccount(
this.activeDid,
)) as Account;
const jwtUrl = await generateEndorserJwtUrlForAccount(
account,
this.isRegistered,
this.givenName,
this.profileImageUrl,
true,
);
useClipboard()
.copy(jwtUrl)
.then(() => {
this.notify.toast(NOTIFY_QR_URL_COPIED.message, QR_TIMEOUT_MEDIUM);
});
}
toastQRCodeHelp() {

View File

@@ -107,11 +107,7 @@
@copy-selected="copySelectedContacts"
/>
<GiftedDialog
ref="customGivenDialog"
:giver-entity-type="'person'"
:recipient-entity-type="'person'"
/>
<GiftedDialog ref="customGivenDialog" />
<OfferDialog ref="customOfferDialog" />
<ContactNameDialog ref="contactNameDialog" />
@@ -1053,6 +1049,7 @@ export default class ContactsView extends Vue {
}
let callback: (amount: number) => void;
let customTitle = "";
// choose whether to open dialog to user or from user
if (giverDid == this.activeDid) {
callback = (amount: number) => {
@@ -1060,6 +1057,7 @@ export default class ContactsView extends Vue {
newList[recipientDid] = (newList[recipientDid] || 0) + amount;
this.givenByMeUnconfirmed = newList;
};
customTitle = "Given to " + (receiver?.name || "Someone Unnamed");
} else {
// must be (recipientDid == this.activeDid)
callback = (amount: number) => {
@@ -1067,14 +1065,13 @@ export default class ContactsView extends Vue {
newList[giverDid] = (newList[giverDid] || 0) + amount;
this.givenToMeUnconfirmed = newList;
};
customTitle = "Received from " + (giver?.name || "Someone Unnamed");
}
(this.$refs.customGivenDialog as GiftedDialog).open(
giver,
receiver,
undefined as unknown as string,
undefined as unknown as string,
undefined as unknown as string,
undefined as unknown as string,
customTitle,
undefined as unknown as string,
callback,
);

View File

@@ -7,13 +7,13 @@
<!-- Breadcrumb -->
<div id="ViewBreadcrumb" class="mb-8">
<h1 id="ViewHeading" class="text-lg text-center font-light relative px-7">
<!-- Go to 'contacts' instead of just 'back' because they could get here from an edit page (and going back there is annoying). -->
<router-link
:to="{ name: 'contacts' }"
<!-- Back -->
<button
class="text-lg text-center px-2 py-1 absolute -left-2 -top-1"
@click="goBack"
>
<font-awesome icon="chevron-left" class="fa-fw"></font-awesome>
</router-link>
</button>
Identifier Details
</h1>
</div>
@@ -273,7 +273,6 @@ import {
displayAmount,
getHeaders,
register,
setVisibilityUtil,
} from "../libs/endorserServer";
import * as libsUtil from "../libs/util";
import EntityIcon from "../components/EntityIcon.vue";
@@ -325,7 +324,6 @@ export default class DIDView extends Vue {
apiServer = "";
claims: Array<GenericCredWrapper<GenericVerifiableCredential>> = [];
contactFromDid?: Contact;
contactYaml = "";
hitEnd = false;
isLoading = false;
@@ -724,31 +722,18 @@ export default class DIDView extends Vue {
visibility: boolean,
showSuccessAlert: boolean,
) {
const result = await setVisibilityUtil(
this.activeDid,
this.apiServer,
this.axios,
contact,
visibility,
);
// Update contact visibility using mixin method
await this.$updateContact(contact.did, { seesMe: visibility });
if (result.success) {
if (showSuccessAlert) {
const message =
(contact.name || "That user") +
" can " +
(visibility ? "" : "not ") +
"see your activity.";
this.notify.success(message, TIMEOUTS.SHORT);
}
return true;
} else {
logger.error("Got strange result from setting visibility:", result);
if (showSuccessAlert) {
const message =
(result.error as string) || "Could not set visibility on the server.";
this.notify.error(message, TIMEOUTS.LONG);
return false;
(contact.name || "That user") +
" can " +
(visibility ? "" : "not ") +
"see your activity.";
this.notify.success(message, TIMEOUTS.SHORT);
}
return true;
}
/**

View File

@@ -49,7 +49,6 @@ import {
VALID_DEEP_LINK_ROUTES,
deepLinkSchemas,
} from "../interfaces/deepLinks";
import { logConsoleAndDb } from "../db/databaseUtil";
import { logger } from "../utils/logger";
const route = useRoute();
@@ -106,9 +105,8 @@ const reportIssue = () => {
// Log the error for analytics
onMounted(() => {
logConsoleAndDb(
logger.error(
`[DeepLinkError] Error page displayed for path: ${originalPath.value}, code: ${errorCode.value}, params: ${JSON.stringify(route.params)}, query: ${JSON.stringify(route.query)}`,
true,
);
});
</script>

View File

@@ -48,12 +48,24 @@
placeholder="What was received"
/>
<div class="flex mb-4">
<AmountInput
:value="parseFloat(amountInput) || 0"
:min="0"
input-id="inputGivenAmount"
:on-update-value="handleAmountChange"
<button
class="rounded-s border border-e-0 border-slate-400 bg-slate-200 px-4 py-2"
@click="amountInput === '0' ? null : decrement()"
>
<font-awesome icon="chevron-left" />
</button>
<input
id="inputGivenAmount"
v-model="amountInput"
type="number"
class="flex-1 border border-e-0 border-slate-400 px-2 py-2 text-center w-[1px]"
/>
<button
class="rounded-e border border-slate-400 bg-slate-200 px-4 py-2"
@click="increment()"
>
<font-awesome icon="chevron-right" />
</button>
<select
v-model="unitCode"
@@ -177,7 +189,7 @@
{{
recipientDid
? "This was given to " + recipientName + "."
: "No named individual benefitted."
: "No individual benefitted."
}}
</label>
<font-awesome
@@ -263,7 +275,6 @@ import { RouteLocationNormalizedLoaded, Router } from "vue-router";
import ImageMethodDialog from "../components/ImageMethodDialog.vue";
import QuickNav from "../components/QuickNav.vue";
import TopMessage from "../components/TopMessage.vue";
import AmountInput from "../components/AmountInput.vue";
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "../constants/app";
import { GenericCredWrapper, GiveActionClaim } from "../interfaces";
import {
@@ -285,11 +296,11 @@ import {
NOTIFY_GIFTED_DETAILS_DELETE_IMAGE_CONFIRM,
NOTIFY_GIFTED_DETAILS_DELETE_IMAGE_ERROR,
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER,
NOTIFY_GIFT_ERROR_NEGATIVE_AMOUNT,
NOTIFY_GIFTED_DETAILS_PROJECT_PROVIDER_INFO,
NOTIFY_GIFTED_DETAILS_BOTH_PROVIDER_SELECTED,
NOTIFY_GIFTED_DETAILS_RECORDING_GIVE,
NOTIFY_GIFTED_DETAILS_CREATE_GIVE_ERROR,
NOTIFY_GIFTED_DETAILS_GIFT_RECORDED,
NOTIFY_GIFT_ERROR_NO_DESCRIPTION,
} from "@/constants/notifications";
@Component({
@@ -297,7 +308,6 @@ import {
ImageMethodDialog,
QuickNav,
TopMessage,
AmountInput,
},
mixins: [PlatformServiceMixin],
})
@@ -520,10 +530,6 @@ export default class GiftedDetails extends Vue {
)}`;
}
handleAmountChange(value: number): void {
this.amountInput = value.toString();
}
cancel() {
this.deleteImage(); // not awaiting, so they'll go back immediately
if (this.destinationPathAfter) {
@@ -588,20 +594,10 @@ export default class GiftedDetails extends Vue {
this.imageUrl = "";
} catch (error) {
logger.error("Error deleting image:", error);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if ((error as any)?.response?.status === 404) {
logger.log("Weird: the image was already deleted.", error);
localStorage.removeItem("imageUrl");
this.imageUrl = "";
// it already doesn't exist so we won't say anything to the user
} else {
this.notify.error(
NOTIFY_GIFTED_DETAILS_DELETE_IMAGE_ERROR.message,
TIMEOUTS.LONG,
);
}
this.notify.error(
NOTIFY_GIFTED_DETAILS_DELETE_IMAGE_ERROR.message,
TIMEOUTS.LONG,
);
}
}
@@ -615,17 +611,14 @@ export default class GiftedDetails extends Vue {
}
if (parseFloat(this.amountInput) < 0) {
this.notify.error(
NOTIFY_GIFT_ERROR_NEGATIVE_AMOUNT.message,
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER.message,
TIMEOUTS.SHORT,
);
return;
}
if (!this.description && !parseFloat(this.amountInput)) {
this.notify.error(
NOTIFY_GIFT_ERROR_NO_DESCRIPTION.message.replace(
"{unit}",
this.libsUtil.UNIT_SHORT[this.unitCode] || this.unitCode,
),
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER.message,
TIMEOUTS.SHORT,
);
return;
@@ -633,8 +626,7 @@ export default class GiftedDetails extends Vue {
this.notify.toast(
NOTIFY_GIFTED_DETAILS_RECORDING_GIVE.message,
undefined,
TIMEOUTS.BRIEF,
TIMEOUTS.SHORT,
);
// this is asynchronous, but we don't need to wait for it to complete
@@ -642,32 +634,29 @@ export default class GiftedDetails extends Vue {
}
notifyUserOfGiver() {
// there's no individual giver or there's a provider project
if (!this.giverDid) {
this.notify.warning(
"To assign a giver, you must choose a person in a previous step.",
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER.message,
TIMEOUTS.SHORT,
);
} else {
// must be because providedByProject is true
this.notify.warning(
"You cannot assign both a giver and a project.",
NOTIFY_GIFTED_DETAILS_BOTH_PROVIDER_SELECTED.message,
TIMEOUTS.SHORT,
);
}
}
notifyUserOfRecipient() {
// there's no individual recipient or there's a fulfills project
if (!this.recipientDid) {
this.notify.warning(
"To assign a recipient, you must choose a person in a previous step.",
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER.message,
TIMEOUTS.SHORT,
);
} else {
// must be because givenToProject is true
this.notify.warning(
"You cannot assign both to a recipient and to a project.",
NOTIFY_GIFTED_DETAILS_BOTH_PROVIDER_SELECTED.message,
TIMEOUTS.SHORT,
);
}
@@ -677,13 +666,13 @@ export default class GiftedDetails extends Vue {
// we're here because they clicked and either there is no provider project or there is a giver chosen
if (!this.providerProjectId) {
this.notify.warning(
"To select a project as a provider, you must choose a project in a previous step.",
NOTIFY_GIFTED_DETAILS_PROJECT_PROVIDER_INFO.message,
TIMEOUTS.SHORT,
);
} else {
// no providing project was chosen, so there must be an individual giver
// no providing project was chosen
this.notify.warning(
"You cannot select both a giving project and person.",
NOTIFY_GIFTED_DETAILS_BOTH_PROVIDER_SELECTED.message,
TIMEOUTS.SHORT,
);
}
@@ -693,13 +682,13 @@ export default class GiftedDetails extends Vue {
// we're here because they clicked and either there is no fulfills project or there is a recipient chosen
if (!this.fulfillsProjectId) {
this.notify.warning(
"To assign a project as a recipient, you must choose a project in a previous step.",
NOTIFY_GIFTED_DETAILS_PROJECT_PROVIDER_INFO.message,
TIMEOUTS.SHORT,
);
} else {
// no fulfills project was chosen, so there must be an individual recipient
// no fulfills project was chosen
this.notify.warning(
"You cannot select both a receiving project and person.",
NOTIFY_GIFTED_DETAILS_BOTH_PROVIDER_SELECTED.message,
TIMEOUTS.SHORT,
);
}

View File

@@ -62,6 +62,59 @@
<h2 class="text-xl font-semibold">I want to know more because...</h2>
<ul class="list-disc list-outside ml-4">
<li class="p-2">
<div class="text-blue-500" @click="toggleAlpha">... I'm a member of Alpha chat.</div>
<div v-if="showAlpha">
<p>
This is a project for public benefit. You are invited to add your gratitude
and propose projects on a distributable ledger.
</p>
<p>
The underlying data is on a merkle tree with each verifiable claim, signature and all.
The chain includes individual IDs for discovery & visibility, so not all data is distributed -- yet.
The goal is to eventually distribute the data on people's devices with their chosen network,
where anyone could host their own chain of provenance if they choose.
The formats follow standard schemas (eg. schema.org) to encourage interoperability.
We're currently at the beginning phase where we're trusting the server to keep IDs private.
It's all open-source, and we expect to have a professional audit someday.
</p>
<p>
A person's network of contacts is similar: the server currently knows some of the links between people
to allow discovery and visibility. However, even that will be manageable on personal devices someday.
</p>
<p>
There are no tokens to maintain the chain: the purpose is to create software that communities
and activists can easily join and use. We're betting that this is a case where network
participants have the motivation to run the software. The protocol is meant to be lightweight enough that
non-technical people can run it on inexpensive devices they already own. There may be cases for
MPC or ZKP in the future when they are more widespread and standard,
but our preference is to engineer as simply as possible with "white-magic" cryptography
over those "black-magic" functions.
</p>
<p>
Let's make real distributed computing and shared data happen, starting with our own small networks.
</p>
<p>
... and exemplify the fun along the way.
</p>
</div>
</li>
<li class="p-2">
<div class="text-blue-500" @click="toggleGroup">... I want to find a group I'll enjoy working with.</div>
<div v-if="showGroup">
<p>
This app encourages people to offer small bits of time to one another. It's a way to
run experiments with other people... tests of working together, which can start small
and easy but build into cooperation with people who are like-minded and who work well together.
</p>
<p>
Search the projects and place an offer on an interesting one
-- or create your own project and see who offers to help.
After your first experiment, you can give and get confirmation about the work, which you might choose
to show to future contacts.
</p>
</div>
</li>
<li class="p-2">
<div class="text-blue-500" @click="toggleCommunity">... I want to participate in community projects.</div>
<div v-if="showCommunity">
@@ -135,59 +188,6 @@
</p>
</div>
</li>
<li class="p-2">
<div class="text-blue-500" @click="toggleGroup">... I want to find a group I'll enjoy working with.</div>
<div v-if="showGroup">
<p>
This app encourages people to offer small bits of time to one another. It's a way to
run experiments with other people... tests of working together, which can start small
and easy but build into cooperation with people who are like-minded and who work well together.
</p>
<p>
Search the projects and place an offer on an interesting one
-- or create your own project and see who offers to help.
After your first experiment, you can give and get confirmation about the work, which you might choose
to show to future contacts.
</p>
</div>
</li>
<li class="p-2">
<div class="text-blue-500" @click="toggleAlpha">... I'm a member of Alpha chat.</div>
<div v-if="showAlpha">
<p>
This is a project for public benefit. You are invited to add your gratitude
and propose projects on a distributable ledger.
</p>
<p>
The underlying data is on a merkle tree with each verifiable claim, signature and all.
The chain includes individual IDs for discovery & visibility, so not all data is distributed -- yet.
The goal is to eventually distribute the data on people's devices with their chosen network,
where anyone could host their own chain of provenance if they choose.
The formats follow standard schemas (eg. schema.org) to encourage interoperability.
We're currently at the beginning phase where we're trusting the server to keep IDs private.
It's all open-source, and we expect to have a professional audit someday.
</p>
<p>
A person's network of contacts is similar: the server currently knows some of the links between people
to allow discovery and visibility. However, even that will be manageable on personal devices someday.
</p>
<p>
There are no tokens to maintain the chain: the purpose is to create software that communities
and activists can easily join and use. We're betting that this is a case where network
participants have the motivation to run the software. The protocol is meant to be lightweight enough that
non-technical people can run it on inexpensive devices they already own. There may be cases for
MPC or ZKP in the future when they are more widespread and standard,
but our preference is to engineer as simply as possible with "white-magic" cryptography
over those "black-magic" functions.
</p>
<p>
Let's make real distributed computing and shared data happen, starting with our own small networks.
</p>
<p>
... and exemplify the fun along the way.
</p>
</div>
</li>
</ul>
<h2 class="text-xl font-semibold">How do I get started?</h2>

View File

@@ -132,7 +132,7 @@ Raymer * @version 1.0.0 */
<button
type="button"
class="text-center text-base uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-2 rounded-lg"
@click="openPersonDialog()"
@click="openDialogPerson()"
>
<font-awesome icon="user" />
Person
@@ -151,11 +151,7 @@ Raymer * @version 1.0.0 */
</div>
</div>
<GiftedDialog
ref="giftedDialog"
:giver-entity-type="showProjectsDialog ? 'project' : 'person'"
:recipient-entity-type="'person'"
/>
<GiftedDialog ref="customDialog" :show-projects="showProjectsDialog" />
<GiftedPrompts ref="giftedPrompts" />
<FeedFilters ref="feedFilters" />
@@ -234,9 +230,11 @@ Raymer * @version 1.0.0 */
:last-viewed-claim-id="feedLastViewedClaimId"
:is-registered="isRegistered"
:active-did="activeDid"
:confirmer-id-list="record.confirmerIdList"
:on-image-cache="cacheImageData"
@load-claim="onClickLoadClaim"
@view-image="openImageViewer"
@confirm-claim="confirmClaim"
/>
</ul>
</InfiniteScroll>
@@ -304,11 +302,16 @@ import {
OnboardPage,
} from "../libs/util";
import { GiveSummaryRecord } from "../interfaces/records";
import * as serverUtil from "../libs/endorserServer";
import { logger } from "../utils/logger";
import { GiveRecordWithContactInfo } from "../interfaces/give";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
import { NOTIFY_CONTACT_LOADING_ISSUE } from "@/constants/notifications";
import {
NOTIFY_CONTACT_LOADING_ISSUE,
NOTIFY_FEED_LOADING_ISSUE,
NOTIFY_CONFIRMATION_ERROR,
} from "@/constants/notifications";
import * as Package from "../../package.json";
// consolidate this with GiveActionClaim in src/interfaces/claims.ts
@@ -482,10 +485,6 @@ export default class HomeView extends Vue {
if (newDid !== oldDid) {
// Re-initialize identity with new settings (loads settings internally)
await this.initializeIdentity();
} else {
logger.info(
"[HomeView Settings Trace] 📍 DID unchanged, skipping re-initialization",
);
}
}
@@ -528,7 +527,11 @@ export default class HomeView extends Vue {
// Load settings with better error context using ultra-concise mixin
let settings;
try {
settings = await this.$accountSettings();
settings = await this.$settings({
apiServer: "",
activeDid: "",
isRegistered: false,
});
} catch (error) {
this.$logAndConsole(
`[HomeView] Failed to retrieve settings: ${error}`,
@@ -596,21 +599,65 @@ export default class HomeView extends Vue {
// Ultra-concise settings update with automatic cache invalidation!
await this.$saveMySettings({ isRegistered: true });
this.isRegistered = true;
// Force Vue to re-render the template
await this.$nextTick();
}
} catch (error) {
logger.warn(
"[HomeView Settings Trace] ⚠️ Registration check failed",
{
error: error instanceof Error ? error.message : String(error),
},
);
// Consolidate logging: Only log unexpected errors, not expected 400s
const axiosError = error as any;
if (axiosError?.response?.status !== 400) {
this.$logAndConsole(
`[HomeView] Registration check failed: ${error}`,
true,
);
}
// Continue as unregistered - this is expected for new users
}
}
} catch (err: unknown) {
logger.error("[HomeView Settings Trace] ❌ initializeIdentity() failed", {
error: err instanceof Error ? err.message : String(err),
});
throw err;
// Initialize feed and offers
try {
// Start feed update in background
this.updateAllFeed().catch((error) => {
this.$logAndConsole(
`[HomeView] Background feed update failed: ${error}`,
true,
);
});
// Load new offers if we have an active DID
if (this.activeDid) {
const [offersToUser, offersToProjects] = await Promise.all([
getNewOffersToUser(
this.axios,
this.apiServer,
this.activeDid,
this.lastAckedOfferToUserJwtId,
),
getNewOffersToUserProjects(
this.axios,
this.apiServer,
this.activeDid,
this.lastAckedOfferToUserProjectsJwtId,
),
]);
this.numNewOffersToUser = offersToUser.data.length;
this.newOffersToUserHitLimit = offersToUser.hitLimit;
this.numNewOffersToUserProjects = offersToProjects.data.length;
this.newOffersToUserProjectsHitLimit = offersToProjects.hitLimit;
}
} catch (error) {
this.$logAndConsole(
`[HomeView] Failed to initialize feed/offers: ${error}`,
true,
);
// Don't throw - we can continue with empty feed
this.notify.warning(NOTIFY_FEED_LOADING_ISSUE.message, TIMEOUTS.LONG);
}
} catch (error) {
this.handleError(error);
throw error; // Re-throw to be caught by mounted()
}
}
@@ -634,6 +681,44 @@ export default class HomeView extends Vue {
}
}
/**
* Loads user settings from storage using ultra-concise mixin utilities
* Sets component state for:
* - API server, Active DID, Feed filters and view settings
* - Registration status, Notification acknowledgments
*
* @internal
* Called by mounted() and reloadFeedOnChange()
*/
private async loadSettings() {
// Use the current activeDid (set in initializeIdentity) to get user-specific settings
const settings = await this.$accountSettings(this.activeDid, {
apiServer: "",
activeDid: "",
filterFeedByVisible: false,
filterFeedByNearby: false,
isRegistered: false,
});
this.apiServer = settings.apiServer || "";
// **CRITICAL**: Ensure correct API server for platform
await this.ensureCorrectApiServer();
this.activeDid = settings.activeDid || "";
this.feedLastViewedClaimId = settings.lastViewedClaimId;
this.givenName = settings.firstName || "";
this.isFeedFilteredByVisible = !!settings.filterFeedByVisible;
this.isFeedFilteredByNearby = !!settings.filterFeedByNearby;
this.isRegistered = !!settings.isRegistered;
this.lastAckedOfferToUserJwtId = settings.lastAckedOfferToUserJwtId;
this.lastAckedOfferToUserProjectsJwtId =
settings.lastAckedOfferToUserProjectsJwtId;
this.searchBoxes = settings.searchBoxes || [];
this.showShortcutBvc = !!settings.showShortcutBvc;
this.isAnyFeedFilterOn = checkIsAnyFeedFilterOn(settings);
}
/**
* Loads user contacts from database using ultra-concise mixin
* Used for displaying contact info in feed and actions
@@ -648,6 +733,36 @@ export default class HomeView extends Vue {
.map((c) => c.did);
}
/**
* Verifies user registration status with endorser service
* - Checks if unregistered user can access API
* - Updates registration status if successful
* - Preserves unregistered state on failure
*
* @internal
* Called by mounted() and initializeIdentity()
*/
private async checkRegistrationStatus() {
if (!this.isRegistered && this.activeDid) {
try {
const resp = await fetchEndorserRateLimits(
this.apiServer,
this.axios,
this.activeDid,
);
if (resp.status === 200) {
// Ultra-concise settings update with automatic cache invalidation!
await this.$saveMySettings({ isRegistered: true });
this.isRegistered = true;
// Force Vue to re-render the template
await this.$nextTick();
}
} catch (e) {
// ignore the error... just keep us unregistered
}
}
}
/**
* Initializes feed data
* Triggers updateAllFeed() to populate activity feed
@@ -700,7 +815,7 @@ export default class HomeView extends Vue {
* Called by mounted()
*/
private async checkOnboarding() {
const settings = await this.$accountSettings();
const settings = await this.$settings();
if (!settings.finishedOnboarding) {
(this.$refs.onboardingDialog as OnboardingDialog).open(OnboardPage.Home);
}
@@ -1476,35 +1591,37 @@ export default class HomeView extends Vue {
* openGiftedPrompts() -> openDialog()
*
* @requires
* - this.$refs.giftedDialog
* - this.$refs.customDialog
* - this.activeDid
*
* @param giver Optional contact info for giver
* @param description Optional gift description
*/
openDialog(giver?: GiverReceiverInputInfo | "Unnamed", prompt?: string) {
openDialog(giver?: GiverReceiverInputInfo | "Unnamed", description?: string) {
if (giver === "Unnamed") {
// Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected
(this.$refs.giftedDialog as GiftedDialog).open(
(this.$refs.customDialog as GiftedDialog).open(
undefined,
{
did: this.activeDid,
name: "You",
} as GiverReceiverInputInfo,
undefined,
prompt,
"Given by Unnamed",
description,
);
// Immediately select "Unnamed" and move to Step 2
(this.$refs.giftedDialog as GiftedDialog).selectGiver();
(this.$refs.customDialog as GiftedDialog).selectGiver();
} else {
(this.$refs.giftedDialog as GiftedDialog).open(
(this.$refs.customDialog as GiftedDialog).open(
giver,
{
did: this.activeDid,
name: "You",
} as GiverReceiverInputInfo,
undefined,
prompt,
"Given by " + (giver?.name || "someone not named"),
description,
);
}
}
@@ -1541,6 +1658,17 @@ export default class HomeView extends Vue {
(this.$refs.feedFilters as FeedFilters).open(this.reloadFeedOnChange);
}
/**
* Shows toast notification to user
*
* @internal
* Used for various user notifications
* @param message Message to display
*/
toastUser(message: string) {
this.notify.toast("FYI", message, TIMEOUTS.SHORT);
}
/**
* Computes CSS classes for known person icons
*
@@ -1644,6 +1772,53 @@ export default class HomeView extends Vue {
this.isImageViewerOpen = true;
}
/**
* Handles claim confirmation
*
* @public
* Called by ActivityListItem component
* @param record Record to confirm
*/
async confirmClaim(record: GiveRecordWithContactInfo) {
this.notify.confirm(
"Do you personally confirm that this is true?",
async () => {
const goodClaim = serverUtil.removeSchemaContext(
serverUtil.removeVisibleToDids(
serverUtil.addLastClaimOrHandleAsIdIfMissing(
record.fullClaim,
record.jwtId,
record.handleId,
),
),
);
const confirmationClaim = {
"@context": "https://schema.org",
"@type": "AgreeAction",
object: goodClaim,
};
const result = await serverUtil.createAndSubmitClaim(
confirmationClaim,
this.activeDid,
this.apiServer,
this.axios,
);
if (result.success) {
this.notify.confirmationSubmitted();
// Refresh the feed to show updated confirmation status
await this.updateAllFeed();
} else {
logger.error("Error submitting confirmation:", result);
this.notify.error(NOTIFY_CONFIRMATION_ERROR.message, TIMEOUTS.LONG);
}
},
);
}
private handleQRCodeClick() {
if (Capacitor.isNativePlatform()) {
this.$router.push({ name: "contact-qr-scan-full" });
@@ -1652,17 +1827,17 @@ export default class HomeView extends Vue {
}
}
openPersonDialog(
openDialogPerson(
giver?: GiverReceiverInputInfo | "Unnamed",
prompt?: string,
description?: string,
) {
this.showProjectsDialog = false;
this.openDialog(giver, prompt);
this.openDialog(giver, description);
}
openProjectDialog() {
this.showProjectsDialog = true;
(this.$refs.giftedDialog as GiftedDialog).open();
(this.$refs.customDialog as GiftedDialog).open();
}
/**

View File

@@ -214,10 +214,7 @@ export default class IdentitySwitcherView extends Vue {
}
} catch (err) {
this.notify.error(NOTIFY_ERROR_LOADING_ACCOUNTS.message, TIMEOUTS.LONG);
logger.error(
"[IdentitySwitcher Settings Trace] ❌ Error loading accounts:",
err,
);
logger.error("Telling user to clear cache at page create because:", err);
}
}
@@ -228,35 +225,12 @@ export default class IdentitySwitcherView extends Vue {
// Check if we need to load user-specific settings for the new DID
if (did) {
try {
const newSettings = await this.$accountSettings(did);
logger.info(
"[IdentitySwitcher Settings Trace] ✅ New account settings loaded",
{
did,
settingsKeys: Object.keys(newSettings).filter(
(k) => (newSettings as any)[k] !== undefined,
),
},
);
await this.$accountSettings(did);
} catch (error) {
logger.warn(
"[IdentitySwitcher Settings Trace] ⚠️ Error loading new account settings",
{
did,
error: error instanceof Error ? error.message : String(error),
},
);
// Handle error silently - user settings will be loaded when needed
}
}
logger.info(
"[IdentitySwitcher Settings Trace] 🔄 Navigating to home to trigger watcher",
{
newDid: did,
},
);
// Navigate to home page to trigger the watcher
this.$router.push({ name: "home" });
}

View File

@@ -166,8 +166,10 @@ export default class ImportAccountView extends Vue {
] as string;
const newDerivPath = nextDerivationPath(maxDerivPath);
const mne = selectedArray[0].mnemonic as string;
const [address, privateHex, publicHex] = deriveAddress(mne, newDerivPath);
const newId = newIdentifier(address, publicHex, privateHex, newDerivPath);
try {
@@ -185,10 +187,7 @@ export default class ImportAccountView extends Vue {
);
this.$router.push({ name: "account" });
} catch (err) {
logger.error(
"[ImportDerived Settings Trace] ❌ Error saving mnemonic & updating settings:",
err,
);
logger.error("Error saving mnemonic & updating settings:", err);
this.notify.error(NOTIFY_ACCOUNT_DERIVATION_ERROR.message, TIMEOUTS.LONG);
}
}

View File

@@ -115,8 +115,6 @@ import {
serverMessageForUser,
} from "../libs/endorserServer";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
import { NotificationIface } from "@/constants/app";
interface Meeting {
name: string;
@@ -131,11 +129,19 @@ interface Meeting {
mixins: [PlatformServiceMixin],
})
export default class OnboardMeetingListView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
$notify!: (
notification: {
group: string;
type: string;
title: string;
text: string;
onYes?: () => void;
yesText?: string;
},
timeout?: number,
) => void;
$router!: Router;
notify!: ReturnType<typeof createNotifyHelpers>;
activeDid = "";
apiServer = "";
attendingMeeting: Meeting | null = null;
@@ -147,66 +153,30 @@ export default class OnboardMeetingListView extends Vue {
selectedMeeting: Meeting | null = null;
showPasswordDialog = false;
/**
* Vue lifecycle hook - component initialization
*
* Initializes the component by loading user settings and fetching available
* onboarding meetings. This method is called when the component is created
* and sets up all necessary data for the meeting list interface.
*
* Workflow:
* 1. Initialize notification system using createNotifyHelpers
* 2. Load user account settings (DID, API server, registration status)
* 3. Fetch available onboarding meetings from the server
*
* Dependencies:
* - PlatformServiceMixin for settings access ($accountSettings)
* - Server API for meeting data (fetchMeetings)
*
* Error Handling:
* - Server errors during meeting fetch are handled in fetchMeetings()
*
* @author Matthew Raymer
*/
async created() {
this.notify = createNotifyHelpers(this.$notify);
// Load user account settings
const settings = await this.$accountSettings();
if (settings?.activeDid) {
try {
// Verify database settings are accessible
await this.$query("SELECT * FROM settings WHERE accountDid = ?", [
settings.activeDid,
]);
} catch (error) {
logger.error("Error checking database settings:", error);
}
}
this.activeDid = settings?.activeDid || "";
this.apiServer = settings?.apiServer || "";
this.firstName = settings?.firstName || "";
this.isRegistered = !!settings?.isRegistered;
await this.fetchMeetings();
if (this.isRegistered) {
await this.fetchMeetings();
}
}
/**
* Fetches available onboarding meetings from the server
*
* This method retrieves the list of onboarding meetings that the user can join.
* It first checks if the user is already attending a meeting, and if so,
* displays that meeting instead of the full list.
*
* Workflow:
* 1. Check if user is already attending a meeting (groupOnboardMember endpoint)
* 2. If attending: Fetch meeting details and display single meeting view
* 3. If not attending: Fetch all available meetings (groupsOnboarding endpoint)
* 4. Handle loading states and error conditions
*
* API Endpoints Used:
* - GET /api/partner/groupOnboardMember - Check current attendance
* - GET /api/partner/groupOnboard/{id} - Get meeting details
* - GET /api/partner/groupsOnboarding - Get all available meetings
*
* State Management:
* - Sets isLoading flag during API calls
* - Updates attendingMeeting or meetings array
* - Handles error states with user notifications
*
* @author Matthew Raymer
*/
async fetchMeetings() {
this.isLoading = true;
try {
@@ -256,36 +226,20 @@ export default class OnboardMeetingListView extends Vue {
"Error fetching meetings: " + errorStringForLog(error),
true,
);
this.notify.error(
serverMessageForUser(error) || "There was a problem fetching meetings.",
TIMEOUTS.LONG,
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: serverMessageForUser(error) || "Failed to fetch meetings.",
},
5000,
);
} finally {
this.isLoading = false;
}
}
/**
* Opens the password dialog for joining a meeting
*
* This method initiates the process of joining an onboarding meeting by
* opening a modal dialog that prompts the user for the meeting password.
* The dialog is focused and ready for input when displayed.
*
* Workflow:
* 1. Clear any previous password input
* 2. Store the selected meeting for later use
* 3. Show the password dialog modal
* 4. Focus the password input field for immediate typing
*
* UI State Changes:
* - Sets showPasswordDialog to true (shows modal)
* - Clears password field for fresh input
* - Stores selectedMeeting for password submission
*
* @param meeting - The meeting object the user wants to join
* @author Matthew Raymer
*/
promptPassword(meeting: Meeting) {
this.password = "";
this.selectedMeeting = meeting;
@@ -298,61 +252,12 @@ export default class OnboardMeetingListView extends Vue {
});
}
/**
* Cancels the password dialog and resets state
*
* This method handles the cancellation of the meeting password dialog.
* It cleans up the dialog state and resets all related variables to
* their initial state, ensuring a clean slate for future dialog interactions.
*
* State Cleanup:
* - Clears password input field
* - Removes selected meeting reference
* - Hides password dialog modal
*
* This ensures that if the user reopens the dialog, they start with
* a fresh state without any leftover data from previous attempts.
*
* @author Matthew Raymer
*/
cancelPasswordDialog() {
this.password = "";
this.selectedMeeting = null;
this.showPasswordDialog = false;
}
/**
* Submits the password and joins the selected meeting
*
* This method handles the complete workflow of joining an onboarding meeting.
* It encrypts the user's member data with the provided password and sends
* it to the server to register the user as a meeting participant.
*
* Workflow:
* 1. Validate that a meeting is selected (safety check)
* 2. Create member data object with user information
* 3. Encrypt member data using the meeting password
* 4. Send encrypted data to server via groupOnboardMember endpoint
* 5. On success: Navigate to meeting members view with credentials
* 6. On failure: Show error notification to user
*
* Data Encryption:
* - Member data includes: name, DID, registration status
* - Data is encrypted using the meeting password for security
* - Encrypted data is sent to server for verification
*
* Navigation:
* - On successful join: Redirects to onboard-meeting-members view
* - Passes groupId, password, and memberId as route parameters
* - Allows user to see other meeting participants
*
* Error Handling:
* - Invalid passwords result in server rejection
* - Network errors are caught and displayed to user
* - All errors are logged for debugging purposes
*
* @author Matthew Raymer
*/
async submitPassword() {
if (!this.selectedMeeting) {
// this should never happen
@@ -411,95 +316,69 @@ export default class OnboardMeetingListView extends Vue {
"Error joining meeting: " + errorStringForLog(error),
true,
);
this.notify.error(
serverMessageForUser(error) ||
"There was a problem joining the meeting.",
TIMEOUTS.LONG,
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
serverMessageForUser(error) || "You failed to join the meeting.",
},
5000,
);
}
}
/**
* Prompts user to confirm leaving the current meeting
*
* This method initiates the process of leaving an onboarding meeting.
* It shows a confirmation dialog to prevent accidental departures,
* then handles the server-side removal and UI updates.
*
* Workflow:
* 1. Display confirmation dialog asking user to confirm departure
* 2. On confirmation: Send DELETE request to groupOnboardMember endpoint
* 3. On success: Clear attending meeting state and refresh meeting list
* 4. Show success notification to user
* 5. On failure: Show error notification with details
*
* Server Interaction:
* - DELETE /api/partner/groupOnboardMember - Removes user from meeting
* - Requires authentication headers for user verification
* - Server handles the actual removal from meeting database
*
* State Management:
* - Clears attendingMeeting when successfully left
* - Refreshes meetings list to show updated availability
* - Updates UI to show meeting list instead of single meeting
*
* User Experience:
* - Confirmation prevents accidental departures
* - Clear feedback on success/failure
* - Seamless transition back to meeting list
*
* @author Matthew Raymer
*/
async leaveMeeting() {
this.notify.confirm(
"Are you sure you want to leave this meeting?",
async () => {
try {
const headers = await getHeaders(this.activeDid);
await this.axios.delete(
this.apiServer + "/api/partner/groupOnboardMember",
{ headers },
);
this.$notify(
{
group: "modal",
type: "confirm",
title: "Leave Meeting",
text: "Are you sure you want to leave this meeting?",
onYes: async () => {
try {
const headers = await getHeaders(this.activeDid);
await this.axios.delete(
this.apiServer + "/api/partner/groupOnboardMember",
{ headers },
);
this.attendingMeeting = null;
await this.fetchMeetings();
this.attendingMeeting = null;
await this.fetchMeetings();
this.notify.success("You left the meeting.", TIMEOUTS.LONG);
} catch (error) {
this.$logAndConsole(
"Error leaving meeting: " + errorStringForLog(error),
true,
);
this.notify.error(
serverMessageForUser(error) ||
"There was a problem leaving the meeting.",
TIMEOUTS.LONG,
);
}
this.$notify(
{
group: "alert",
type: "success",
title: "Success",
text: "You left the meeting.",
},
5000,
);
} catch (error) {
this.$logAndConsole(
"Error leaving meeting: " + errorStringForLog(error),
true,
);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
serverMessageForUser(error) ||
"You failed to leave the meeting.",
},
5000,
);
}
},
},
-1,
);
}
/**
* Navigates to the meeting creation page
*
* This method handles the navigation to the meeting setup page where
* registered users can create new onboarding meetings. It's only
* available to users who are registered in the system.
*
* Navigation:
* - Routes to onboard-meeting-setup view
* - Allows user to configure new meeting settings
* - Only accessible to registered users (controlled by template)
*
* User Flow:
* - User clicks "Create Meeting" button
* - System navigates to setup page
* - User can configure meeting name, password, etc.
* - New meeting becomes available to other users
*
* @author Matthew Raymer
*/
createMeeting() {
this.$router.push({ name: "onboard-meeting-setup" });
}

View File

@@ -216,8 +216,6 @@
<GiftedDialog
ref="giveDialogToThis"
:giver-entity-type="'person'"
:recipient-entity-type="'project'"
:to-project-id="projectId"
:is-from-project-view="true"
/>
@@ -488,9 +486,8 @@
</div>
<GiftedDialog
ref="giveDialogFromThis"
:giver-entity-type="'project'"
:recipient-entity-type="'person'"
:from-project-id="projectId"
:show-projects="true"
:is-from-project-view="true"
/>
@@ -1158,6 +1155,7 @@ export default class ProjectViewView extends Vue {
undefined,
undefined,
undefined,
"Given by Unnamed to this project",
);
// Immediately select "Unnamed" and move to Step 2
(this.$refs.giveDialogToThis as GiftedDialog).selectGiver();
@@ -1175,6 +1173,7 @@ export default class ProjectViewView extends Vue {
image: this.imageUrl,
},
undefined,
`Given to ${this.name}`,
);
}
}
@@ -1190,6 +1189,7 @@ export default class ProjectViewView extends Vue {
},
{ did: this.activeDid, name: "You" },
undefined,
`${this.name} gave to you`,
undefined,
undefined,
);
@@ -1237,17 +1237,9 @@ export default class ProjectViewView extends Vue {
};
(this.$refs.giveDialogToThis as GiftedDialog).open(
giver,
{
did: offer.issuerDid,
name: this.name,
handleId: this.projectId,
image: this.imageUrl,
},
offer.handleId,
undefined,
offer.objectDescription,
offer.amount.toString(),
offer.unit,
offer.handleId,
"Given by " + (giver?.name || "someone not named"),
);
}

View File

@@ -638,18 +638,16 @@ export default class ProjectsView extends Vue {
* - Alternative sharing methods for remote users
*/
promptForShareMethod() {
this.$notify(
this.notify.confirm(
NOTIFY_CAMERA_SHARE_METHOD.title,
NOTIFY_CAMERA_SHARE_METHOD.text,
{
group: "modal",
type: "confirm",
title: NOTIFY_CAMERA_SHARE_METHOD.title,
text: NOTIFY_CAMERA_SHARE_METHOD.text,
onYes: () => this.handleQRCodeClick(),
onNo: () => this.$router.push({ name: "share-my-contact-info" }),
yesText: NOTIFY_CAMERA_SHARE_METHOD.yesText,
noText: NOTIFY_CAMERA_SHARE_METHOD.noText,
timeout: TIMEOUTS.MODAL,
},
TIMEOUTS.MODAL,
);
}

View File

@@ -75,9 +75,15 @@ export default class ShareMyContactInfoView extends Vue {
isLoading = false;
async mounted() {
// Debug logging for test diagnosis
const settings = await this.$settings();
const activeDid = settings?.activeDid;
// @ts-expect-error - Debug property for testing contact sharing functionality
window.__SHARE_CONTACT_DEBUG__ = { settings, activeDid };
// eslint-disable-next-line no-console
if (!activeDid) {
// eslint-disable-next-line no-console
this.$router.push({ name: "home" });
}
}

View File

@@ -4,7 +4,9 @@
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noEmit": true
},
"include": ["vite.config.*"]
}

View File

@@ -6,9 +6,7 @@ import path from "path";
import { fileURLToPath } from 'url';
// Load environment variables
console.log('NODE_ENV:', process.env.NODE_ENV)
dotenv.config({ path: `.env.${process.env.NODE_ENV}` })
dotenv.config();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);