Compare commits
70 Commits
sql-absurd
...
master-set
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3881144c62 | ||
| 8609f8458d | |||
| 8f5c34bc5f | |||
| b0d61b95ea | |||
| af7bd236a3 | |||
| d719338bcc | |||
| 6ddf2d1012 | |||
|
|
1b2d4b623a | ||
|
|
16d5c917d2 | ||
| 5976a4995e | |||
| dcd0cc4c20 | |||
| b3ca6c9d91 | |||
| e9d800f601 | |||
| b939a5e592 | |||
| aa62037fae | |||
| 722020ea86 | |||
| 96aa3f4a54 | |||
| c0c5f9842b | |||
| be27ca1855 | |||
| 92e4570672 | |||
| 820ae727ed | |||
| dbeb1c6b4b | |||
| 573e4b206a | |||
| abc05d426e | |||
| 2ea7479d75 | |||
| 9ac9713172 | |||
| 41dad3254d | |||
| 485eac59a0 | |||
|
|
73fc32b75d | ||
|
|
3d8e40e92b | ||
| 38e67f3533 | |||
| 7f63ee7c80 | |||
| 6a47f0d3e7 | |||
| fc50a9d4c6 | |||
|
|
45f43ff363 | ||
|
|
7b1d4c4849 | ||
|
|
c1f2c3951a | ||
| 9d4f726c31 | |||
| 1d7f626645 | |||
| c5228ba7ec | |||
| 6e1fcd8dee | |||
| 5bb563d694 | |||
| a3951c9d66 | |||
| aa177a9b8c | |||
| 03cb4720b8 | |||
|
|
0e65431f43 | ||
| 297c5a2dbb | |||
|
|
92b9c9334c | ||
|
|
706182ca0c | ||
|
|
68e0fc4976 | ||
| 504056eb90 | |||
| 5a1007c49c | |||
|
|
cbc14e21ec | ||
|
|
3e02b3924a | ||
|
|
8b03789941 | ||
|
|
b4a6b99301 | ||
|
|
e839997f91 | ||
|
|
d8d054a0e1 | ||
|
|
efc720e47f | ||
|
|
0a85bea533 | ||
|
|
47501ae917 | ||
|
|
28634839ec | ||
| 1b7c96ed9b | |||
| 41365fab8f | |||
| 5cc42be58a | |||
| 3d1a2eeb8d | |||
| 7b0ee2e44e | |||
| ac018997e8 | |||
| 6f449e9c1f | |||
| 543599a6a1 |
@@ -1,101 +0,0 @@
|
||||
VM5:29 [Preload] Preload script starting...
|
||||
VM5:29 [Preload] Preload script completed successfully
|
||||
main.common-DiOUyXe7.js:27 Platform Object
|
||||
error @ main.common-DiOUyXe7.js:27
|
||||
main.common-DiOUyXe7.js:27 PWA enabled Object
|
||||
error @ main.common-DiOUyXe7.js:27
|
||||
main.common-DiOUyXe7.js:27 [Web] PWA enabled Object
|
||||
error @ main.common-DiOUyXe7.js:27
|
||||
main.common-DiOUyXe7.js:27 [Web] Platform Object
|
||||
error @ main.common-DiOUyXe7.js:27
|
||||
main.common-DiOUyXe7.js:29 Opened!
|
||||
main.common-DiOUyXe7.js:2552 Failed to log to database: Error: no such column: value
|
||||
at E.handleError (main.common-DiOUyXe7.js:27:21133)
|
||||
at E.exec (main.common-DiOUyXe7.js:27:19785)
|
||||
at Rc.processQueue (main.common-DiOUyXe7.js:2379:2368)
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Original message: PWA enabled - [{"pwa_enabled":false}]
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Failed to log to database: Error: no such column: value
|
||||
at E.handleError (main.common-DiOUyXe7.js:27:21133)
|
||||
at E.exec (main.common-DiOUyXe7.js:27:19785)
|
||||
at Rc.processQueue (main.common-DiOUyXe7.js:2379:2368)
|
||||
at main.common-DiOUyXe7.js:2379:2816
|
||||
at new Promise (<anonymous>)
|
||||
at Rc.queueOperation (main.common-DiOUyXe7.js:2379:2685)
|
||||
at Rc.query (main.common-DiOUyXe7.js:2379:3378)
|
||||
at async F7 (main.common-DiOUyXe7.js:2552:117)
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Original message: [Web] PWA enabled - [{"pwa_enabled":false}]
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Failed to log to database: Error: no such column: value
|
||||
at E.handleError (main.common-DiOUyXe7.js:27:21133)
|
||||
at E.exec (main.common-DiOUyXe7.js:27:19785)
|
||||
at Rc.processQueue (main.common-DiOUyXe7.js:2379:2368)
|
||||
at main.common-DiOUyXe7.js:2379:2816
|
||||
at new Promise (<anonymous>)
|
||||
at Rc.queueOperation (main.common-DiOUyXe7.js:2379:2685)
|
||||
at Rc.query (main.common-DiOUyXe7.js:2379:3378)
|
||||
at async F7 (main.common-DiOUyXe7.js:2552:117)
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Original message: [Web] Platform - [{"platform":"web"}]
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Failed to log to database: Error: no such column: value
|
||||
at E.handleError (main.common-DiOUyXe7.js:27:21133)
|
||||
at E.exec (main.common-DiOUyXe7.js:27:19785)
|
||||
at Rc.processQueue (main.common-DiOUyXe7.js:2379:2368)
|
||||
at main.common-DiOUyXe7.js:2379:2816
|
||||
at new Promise (<anonymous>)
|
||||
at Rc.queueOperation (main.common-DiOUyXe7.js:2379:2685)
|
||||
at Rc.query (main.common-DiOUyXe7.js:2379:3378)
|
||||
at async F7 (main.common-DiOUyXe7.js:2552:117)
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2552 Original message: Platform - [{"platform":"web"}]
|
||||
F7 @ main.common-DiOUyXe7.js:2552
|
||||
main.common-DiOUyXe7.js:2100
|
||||
|
||||
|
||||
GET https://api.endorser.ch/api/report/rateLimits 400 (Bad Request)
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2100
|
||||
xhr @ main.common-DiOUyXe7.js:2100
|
||||
p6 @ main.common-DiOUyXe7.js:2102
|
||||
_request @ main.common-DiOUyXe7.js:2103
|
||||
request @ main.common-DiOUyXe7.js:2102
|
||||
Yc.<computed> @ main.common-DiOUyXe7.js:2103
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2098
|
||||
dJ @ main.common-DiOUyXe7.js:2295
|
||||
main.common-DiOUyXe7.js:2100
|
||||
|
||||
|
||||
GET https://api.endorser.ch/api/report/rateLimits 400 (Bad Request)
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2100
|
||||
xhr @ main.common-DiOUyXe7.js:2100
|
||||
p6 @ main.common-DiOUyXe7.js:2102
|
||||
_request @ main.common-DiOUyXe7.js:2103
|
||||
request @ main.common-DiOUyXe7.js:2102
|
||||
Yc.<computed> @ main.common-DiOUyXe7.js:2103
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2098
|
||||
dJ @ main.common-DiOUyXe7.js:2295
|
||||
await in dJ
|
||||
checkRegistrationStatus @ HomeView-DJMSCuMg.js:1
|
||||
mounted @ HomeView-DJMSCuMg.js:1
|
||||
XMLHttpRequest.send
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2100
|
||||
xhr @ main.common-DiOUyXe7.js:2100
|
||||
p6 @ main.common-DiOUyXe7.js:2102
|
||||
_request @ main.common-DiOUyXe7.js:2103
|
||||
request @ main.common-DiOUyXe7.js:2102
|
||||
Yc.<computed> @ main.common-DiOUyXe7.js:2103
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2098
|
||||
ZG @ main.common-DiOUyXe7.js:2295
|
||||
await in ZG
|
||||
initializeIdentity @ HomeView-DJMSCuMg.js:1
|
||||
XMLHttpRequest.send
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2100
|
||||
xhr @ main.common-DiOUyXe7.js:2100
|
||||
p6 @ main.common-DiOUyXe7.js:2102
|
||||
_request @ main.common-DiOUyXe7.js:2103
|
||||
request @ main.common-DiOUyXe7.js:2102
|
||||
Yc.<computed> @ main.common-DiOUyXe7.js:2103
|
||||
(anonymous) @ main.common-DiOUyXe7.js:2098
|
||||
dJ @ main.common-DiOUyXe7.js:2295
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# iOS doesn't like spaces in the app title.
|
||||
TIME_SAFARI_APP_TITLE="TimeSafari_Dev"
|
||||
VITE_APP_SERVER=http://localhost:3000
|
||||
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
|
||||
VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000
|
||||
|
||||
5
.gitignore
vendored
@@ -51,6 +51,7 @@ vendor/
|
||||
# Build logs
|
||||
build_logs/
|
||||
|
||||
android/app/src/main/assets/public
|
||||
android/app/src/main/res
|
||||
# PWA icon files generated by capacitor-assets
|
||||
icons
|
||||
|
||||
|
||||
|
||||
69
BUILDING.md
@@ -9,19 +9,6 @@ For a quick dev environment setup, use [pkgx](https://pkgx.dev).
|
||||
- Node.js (LTS version recommended)
|
||||
- npm (comes with Node.js)
|
||||
- Git
|
||||
- For Android builds: Android Studio with SDK installed
|
||||
- For iOS builds: macOS with Xcode and ruby gems & bundle
|
||||
- `pkgx +rubygems.org sh`
|
||||
|
||||
- ... and you may have to fix these, especially with pkgx
|
||||
|
||||
```bash
|
||||
gem_path=$(which gem)
|
||||
shortened_path="${gem_path:h:h}"
|
||||
export GEM_HOME=$shortened_path
|
||||
export GEM_PATH=$shortened_path
|
||||
```
|
||||
|
||||
- For desktop builds: Additional build tools based on your OS
|
||||
|
||||
## Forks
|
||||
@@ -326,6 +313,32 @@ npm run build:electron-prod && npm run electron:start
|
||||
|
||||
Prerequisites: macOS with Xcode installed
|
||||
|
||||
#### First-time iOS Configuration
|
||||
|
||||
- Generate certificates inside XCode.
|
||||
|
||||
- Right-click on App and under Signing & Capabilities set the Team.
|
||||
|
||||
#### Each Release
|
||||
|
||||
0. First time (or if XCode dependencies change):
|
||||
|
||||
- `pkgx +rubygems.org sh`
|
||||
|
||||
- ... and you may have to fix these, especially with pkgx
|
||||
|
||||
```bash
|
||||
gem_path=$(which gem)
|
||||
shortened_path="${gem_path:h:h}"
|
||||
export GEM_HOME=$shortened_path
|
||||
export GEM_PATH=$shortened_path
|
||||
```
|
||||
|
||||
```bash
|
||||
cd ios/App
|
||||
pod install
|
||||
```
|
||||
|
||||
1. Build the web assets:
|
||||
|
||||
```bash
|
||||
@@ -334,6 +347,7 @@ Prerequisites: macOS with Xcode installed
|
||||
npm run build:capacitor
|
||||
```
|
||||
|
||||
|
||||
2. Update iOS project with latest build:
|
||||
|
||||
```bash
|
||||
@@ -345,7 +359,11 @@ Prerequisites: macOS with Xcode installed
|
||||
3. Copy the assets:
|
||||
|
||||
```bash
|
||||
# It makes no sense why capacitor-assets will not run without these but it actually changes the contents.
|
||||
mkdir -p ios/App/App/Assets.xcassets/AppIcon.appiconset
|
||||
echo '{"images":[]}' > ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json
|
||||
mkdir -p ios/App/App/Assets.xcassets/Splash.imageset
|
||||
echo '{"images":[]}' > ios/App/App/Assets.xcassets/Splash.imageset/Contents.json
|
||||
npx capacitor-assets generate --ios
|
||||
```
|
||||
|
||||
@@ -353,10 +371,10 @@ Prerequisites: macOS with Xcode installed
|
||||
|
||||
```
|
||||
cd ios/App
|
||||
xcrun agvtool new-version 15
|
||||
xcrun agvtool new-version 25
|
||||
# Unfortunately this edits Info.plist directly.
|
||||
#xcrun agvtool new-marketing-version 0.4.5
|
||||
cat App.xcodeproj/project.pbxproj | sed "s/MARKETING_VERSION = .*;/MARKETING_VERSION = 0.4.5;/g" > temp
|
||||
cat App.xcodeproj/project.pbxproj | sed "s/MARKETING_VERSION = .*;/MARKETING_VERSION = 0.5.0;/g" > temp
|
||||
mv temp App.xcodeproj/project.pbxproj
|
||||
cd -
|
||||
```
|
||||
@@ -369,28 +387,25 @@ Prerequisites: macOS with Xcode installed
|
||||
|
||||
6. Use Xcode to build and run on simulator or device.
|
||||
|
||||
* Select Product -> Destination with some Simulator version. Then click the run arrow.
|
||||
|
||||
7. Release
|
||||
|
||||
* Under "General" renamed a bunch of things to "Time Safari"
|
||||
* Choose Product -> Destination -> Build Any iOS
|
||||
* Someday: Under "General" we want to rename a bunch of things to "Time Safari"
|
||||
* Choose Product -> Destination -> Any iOS Device
|
||||
* Choose Product -> Archive
|
||||
* This will trigger a build and take time, needing user's "login" keychain password which is just their login password, repeatedly.
|
||||
* This will trigger a build and take time, needing user's "login" keychain password (user's login password), repeatedly.
|
||||
* If it fails with `building for 'iOS', but linking in dylib (.../.pkgx/zlib.net/v1.3.0/lib/libz.1.3.dylib) built for 'macOS'` then run XCode outside that terminal (ie. not with `npx cap open ios`).
|
||||
* Click Distribute -> App Store Connect
|
||||
* In AppStoreConnect, add the build to the distribution: remove the current build with the "-" when you hover over it, then "Add Build" with the new build.
|
||||
* May have to go to App Review, click Submission, then hover over the build and click "-".
|
||||
* It can take 15 minutes for the build to show up in the list of builds.
|
||||
* You'll probably have to "Manage" something about encryption, disallowed in France.
|
||||
* Then "Save" and "Add to Review" and "Resubmit to App Review".
|
||||
|
||||
#### First-time iOS Configuration
|
||||
|
||||
- Generate certificates inside XCode.
|
||||
|
||||
- Right-click on App and under Signing & Capabilities set the Team.
|
||||
|
||||
### Android Build
|
||||
|
||||
Prerequisites: Android Studio with SDK installed
|
||||
Prerequisites: Android Studio with Java SDK installed
|
||||
|
||||
1. Build the web assets:
|
||||
|
||||
@@ -445,7 +460,9 @@ Prerequisites: Android Studio with SDK installed
|
||||
* Then `bundleRelease`:
|
||||
|
||||
```bash
|
||||
cd android
|
||||
./gradlew bundleRelease -Dlint.baselines.continue=true
|
||||
cd -
|
||||
```
|
||||
|
||||
... and find your `aab` file at app/build/outputs/bundle/release
|
||||
@@ -458,6 +475,8 @@ At play.google.com/console:
|
||||
- Hit "Next".
|
||||
- Save, go to "Publishing Overview" as prompted, and click "Send changes for review".
|
||||
|
||||
- Note that if you add testers, you have to go to "Publishing Overview" and send those changes or your (closed) testers won't see it.
|
||||
|
||||
|
||||
## First-time Android Configuration for deep links
|
||||
|
||||
|
||||
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
|
||||
|
||||
## [0.4.7]
|
||||
### Fixed
|
||||
- Cameras everywhere
|
||||
### Changed
|
||||
- IndexedDB -> SQLite
|
||||
|
||||
|
||||
## [0.4.5] - 2025.02.23
|
||||
### Added
|
||||
- Total amounts of gives on project page
|
||||
|
||||
@@ -31,8 +31,8 @@ android {
|
||||
applicationId "app.timesafari.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 18
|
||||
versionName "0.4.7"
|
||||
versionCode 25
|
||||
versionName "0.5.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
}
|
||||
},
|
||||
"ios": {
|
||||
"contentInset": "always",
|
||||
"contentInset": "never",
|
||||
"allowsLinkPreview": true,
|
||||
"scrollEnabled": true,
|
||||
"limitsNavigationsToAppBoundDomains": true,
|
||||
|
||||
@@ -2,7 +2,7 @@ package app.timesafari;
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
import com.getcapacitor.community.sqlite.SQLite;
|
||||
//import com.getcapacitor.community.sqlite.SQLite;
|
||||
|
||||
public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
@@ -10,6 +10,6 @@ public class MainActivity extends BridgeActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Initialize SQLite
|
||||
registerPlugin(SQLite.class);
|
||||
//registerPlugin(SQLite.class);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package timesafari.app;
|
||||
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {}
|
||||
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<background>
|
||||
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
|
||||
</background>
|
||||
<foreground>
|
||||
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
|
||||
</foreground>
|
||||
</adaptive-icon>
|
||||
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<background>
|
||||
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
|
||||
</background>
|
||||
<foreground>
|
||||
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
|
||||
</foreground>
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 60 KiB |
BIN
assets/icon.png
Normal file
|
After Width: | Height: | Size: 279 KiB |
BIN
assets/splash-dark.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
assets/splash.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
@@ -32,7 +32,7 @@
|
||||
}
|
||||
},
|
||||
"ios": {
|
||||
"contentInset": "always",
|
||||
"contentInset": "never",
|
||||
"allowsLinkPreview": true,
|
||||
"scrollEnabled": true,
|
||||
"limitsNavigationsToAppBoundDomains": true,
|
||||
|
||||
13
ios/.gitignore
vendored
@@ -11,3 +11,16 @@ capacitor-cordova-ios-plugins
|
||||
# Generated Config files
|
||||
App/App/capacitor.config.json
|
||||
App/App/config.xml
|
||||
|
||||
# User-specific Xcode files
|
||||
App/App.xcodeproj/xcuserdata/*.xcuserdatad/
|
||||
App/App.xcodeproj/*.xcuserstate
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
|
||||
# Generated Icons from capacitor-assets (also Contents.json which is confusing; see BUILDING.md)
|
||||
App/App/Assets.xcassets/AppIcon.appiconset
|
||||
App/App/Assets.xcassets/Splash.imageset
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; };
|
||||
504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; };
|
||||
50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };
|
||||
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; };
|
||||
97EF2DC6FD76C3643D680B8D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90DCAFB4D8948F7A50C13800 /* Pods_App.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -27,9 +27,9 @@
|
||||
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
|
||||
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
|
||||
FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
90DCAFB4D8948F7A50C13800 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E2E9297D5D02C549106C77F9 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
|
||||
EAEC6436E595F7CD3A1C9E96 /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -37,17 +37,17 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */,
|
||||
97EF2DC6FD76C3643D680B8D /* Pods_App.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = {
|
||||
4B546315E668C7A13939F417 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */,
|
||||
90DCAFB4D8948F7A50C13800 /* Pods_App.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@@ -57,8 +57,8 @@
|
||||
children = (
|
||||
504EC3061FED79650016851F /* App */,
|
||||
504EC3051FED79650016851F /* Products */,
|
||||
7F8756D8B27F46E3366F6CEA /* Pods */,
|
||||
27E2DDA53C4D2A4D1A88CE4A /* Frameworks */,
|
||||
BA325FFCDCE8D334E5C7AEBE /* Pods */,
|
||||
4B546315E668C7A13939F417 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@@ -85,13 +85,13 @@
|
||||
path = App;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7F8756D8B27F46E3366F6CEA /* Pods */ = {
|
||||
BA325FFCDCE8D334E5C7AEBE /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */,
|
||||
AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */,
|
||||
EAEC6436E595F7CD3A1C9E96 /* Pods-App.debug.xcconfig */,
|
||||
E2E9297D5D02C549106C77F9 /* Pods-App.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
@@ -101,12 +101,13 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */;
|
||||
buildPhases = (
|
||||
6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */,
|
||||
92977BEA1068CC097A57FC77 /* [CP] Check Pods Manifest.lock */,
|
||||
504EC3001FED79650016851F /* Sources */,
|
||||
504EC3011FED79650016851F /* Frameworks */,
|
||||
504EC3021FED79650016851F /* Resources */,
|
||||
9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */,
|
||||
012076E8FFE4BF260A79B034 /* Fix Privacy Manifest */,
|
||||
3525031ED1C96EF4CF6E9959 /* [CP] Embed Pods Frameworks */,
|
||||
96A7EF592DF3366D00084D51 /* Fix Privacy Manifest */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -186,28 +187,10 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PROJECT_DIR}/app_privacy_manifest_fixer/fixer.sh\" ";
|
||||
shellScript = "\"${PROJECT_DIR}/app_privacy_manifest_fixer/fixer.sh\" \n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */ = {
|
||||
3525031ED1C96EF4CF6E9959 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
@@ -222,6 +205,47 @@
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
92977BEA1068CC097A57FC77 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
96A7EF592DF3366D00084D51 /* Fix Privacy Manifest */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Fix Privacy Manifest";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "$PROJECT_DIR/app_privacy_manifest_fixer/fixer.sh\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
@@ -375,11 +399,12 @@
|
||||
};
|
||||
504EC3171FED79650016851F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */;
|
||||
baseConfigurationReference = EAEC6436E595F7CD3A1C9E96 /* Pods-App.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 18;
|
||||
CURRENT_PROJECT_VERSION = 25;
|
||||
DEVELOPMENT_TEAM = GM3FS5JQPH;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
@@ -388,7 +413,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 0.4.7;
|
||||
MARKETING_VERSION = 0.5.0;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.timesafari;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -401,11 +426,12 @@
|
||||
};
|
||||
504EC3181FED79650016851F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */;
|
||||
baseConfigurationReference = E2E9297D5D02C549106C77F9 /* Pods-App.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 18;
|
||||
CURRENT_PROJECT_VERSION = 25;
|
||||
DEVELOPMENT_TEAM = GM3FS5JQPH;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
@@ -414,7 +440,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 0.4.7;
|
||||
MARKETING_VERSION = 0.5.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.timesafari;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
|
||||
|
||||
@@ -9,8 +9,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Initialize SQLite
|
||||
let sqlite = SQLite()
|
||||
sqlite.initialize()
|
||||
//let sqlite = SQLite()
|
||||
//sqlite.initialize()
|
||||
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
|
||||
|
Before Width: | Height: | Size: 116 KiB |
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"idiom": "universal",
|
||||
"size": "1024x1024",
|
||||
"filename": "AppIcon-512@2x.png",
|
||||
"platform": "ios"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"author": "xcode",
|
||||
"version": 1
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "splash-2732x2732-2.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "splash-2732x2732-1.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "splash-2732x2732.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 40 KiB |
@@ -27,4 +27,9 @@ end
|
||||
|
||||
post_install do |installer|
|
||||
assertDeploymentTarget(installer)
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,10 @@ PODS:
|
||||
- Capacitor
|
||||
- CapacitorCamera (6.1.2):
|
||||
- Capacitor
|
||||
- CapacitorCommunitySqlite (6.0.2):
|
||||
- Capacitor
|
||||
- SQLCipher
|
||||
- ZIPFoundation
|
||||
- CapacitorCordova (6.2.1)
|
||||
- CapacitorFilesystem (6.0.3):
|
||||
- Capacitor
|
||||
@@ -73,11 +77,18 @@ PODS:
|
||||
- nanopb/decode (2.30910.0)
|
||||
- nanopb/encode (2.30910.0)
|
||||
- PromisesObjC (2.4.0)
|
||||
- SQLCipher (4.9.0):
|
||||
- SQLCipher/standard (= 4.9.0)
|
||||
- SQLCipher/common (4.9.0)
|
||||
- SQLCipher/standard (4.9.0):
|
||||
- SQLCipher/common
|
||||
- ZIPFoundation (0.9.19)
|
||||
|
||||
DEPENDENCIES:
|
||||
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
|
||||
- "CapacitorApp (from `../../node_modules/@capacitor/app`)"
|
||||
- "CapacitorCamera (from `../../node_modules/@capacitor/camera`)"
|
||||
- "CapacitorCommunitySqlite (from `../../node_modules/@capacitor-community/sqlite`)"
|
||||
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
|
||||
- "CapacitorFilesystem (from `../../node_modules/@capacitor/filesystem`)"
|
||||
- "CapacitorMlkitBarcodeScanning (from `../../node_modules/@capacitor-mlkit/barcode-scanning`)"
|
||||
@@ -98,6 +109,8 @@ SPEC REPOS:
|
||||
- MLKitVision
|
||||
- nanopb
|
||||
- PromisesObjC
|
||||
- SQLCipher
|
||||
- ZIPFoundation
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Capacitor:
|
||||
@@ -106,6 +119,8 @@ EXTERNAL SOURCES:
|
||||
:path: "../../node_modules/@capacitor/app"
|
||||
CapacitorCamera:
|
||||
:path: "../../node_modules/@capacitor/camera"
|
||||
CapacitorCommunitySqlite:
|
||||
:path: "../../node_modules/@capacitor-community/sqlite"
|
||||
CapacitorCordova:
|
||||
:path: "../../node_modules/@capacitor/ios"
|
||||
CapacitorFilesystem:
|
||||
@@ -121,6 +136,7 @@ SPEC CHECKSUMS:
|
||||
Capacitor: c95400d761e376be9da6be5a05f226c0e865cebf
|
||||
CapacitorApp: e1e6b7d05e444d593ca16fd6d76f2b7c48b5aea7
|
||||
CapacitorCamera: 9bc7b005d0e6f1d5f525b8137045b60cffffce79
|
||||
CapacitorCommunitySqlite: 0299d20f4b00c2e6aa485a1d8932656753937b9b
|
||||
CapacitorCordova: 8d93e14982f440181be7304aa9559ca631d77fff
|
||||
CapacitorFilesystem: 59270a63c60836248812671aa3b15df673fbaf74
|
||||
CapacitorMlkitBarcodeScanning: 7652be9c7922f39203a361de735d340ae37e134e
|
||||
@@ -138,7 +154,9 @@ SPEC CHECKSUMS:
|
||||
MLKitVision: 90922bca854014a856f8b649d1f1f04f63fd9c79
|
||||
nanopb: 438bc412db1928dac798aa6fd75726007be04262
|
||||
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
|
||||
SQLCipher: 31878d8ebd27e5c96db0b7cb695c96e9f8ad77da
|
||||
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c
|
||||
|
||||
PODFILE CHECKSUM: 7e7e09e6937de7f015393aecf2cf7823645689b3
|
||||
PODFILE CHECKSUM: f987510f7383b04a1b09ea8472bdadcd88b6c924
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
||||
44
package-lock.json
generated
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "timesafari",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "timesafari",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.8",
|
||||
"dependencies": {
|
||||
"@capacitor-community/sqlite": "^6.0.2",
|
||||
"@capacitor-community/sqlite": "6.0.2",
|
||||
"@capacitor-mlkit/barcode-scanning": "^6.0.0",
|
||||
"@capacitor/android": "^6.2.0",
|
||||
"@capacitor/app": "^6.0.0",
|
||||
@@ -2516,7 +2516,6 @@
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@capacitor-community/sqlite/-/sqlite-6.0.2.tgz",
|
||||
"integrity": "sha512-sj+2SPLu7E/3dM3xxcWwfNomG+aQHuN96/EFGrOtp4Dv30/2y5oIPyi6hZGjQGjPc5GDNoTQwW7vxWNzybjuMg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jeep-sqlite": "^2.7.2"
|
||||
},
|
||||
@@ -8195,7 +8194,6 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
@@ -8208,7 +8206,6 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
@@ -8277,7 +8274,6 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
@@ -8290,7 +8286,6 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
@@ -8373,7 +8368,6 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
@@ -8386,7 +8380,6 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
@@ -8399,7 +8392,6 @@
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
@@ -8426,7 +8418,6 @@
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
@@ -8818,10 +8809,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@stencil/core": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@stencil/core/-/core-4.31.0.tgz",
|
||||
"integrity": "sha512-Ei9MFJ6LPD9BMFs+klkHylbVOOYhG10Jv4bvoFf3GMH15kA41rSYkEdr4DiX84ZdErQE2qtFV/2SUyWoXh0AhA==",
|
||||
"license": "MIT",
|
||||
"version": "4.33.1",
|
||||
"resolved": "https://registry.npmjs.org/@stencil/core/-/core-4.33.1.tgz",
|
||||
"integrity": "sha512-12k9xhAJBkpg598it+NRmaYIdEe6TSnsL/v6/KRXDcUyTK11VYwZQej2eHnMWtqot+znJ+GNTqb5YbiXi+5Low==",
|
||||
"bin": {
|
||||
"stencil": "bin/stencil"
|
||||
},
|
||||
@@ -12173,8 +12163,7 @@
|
||||
"node_modules/browser-fs-access": {
|
||||
"version": "0.35.0",
|
||||
"resolved": "https://registry.npmjs.org/browser-fs-access/-/browser-fs-access-0.35.0.tgz",
|
||||
"integrity": "sha512-sLoadumpRfsjprP8XzVjpQc0jK8yqHBx0PtUTGYj2fftT+P/t+uyDAQdMgGAPKD011in/O+YYGh7fIs0oG/viw==",
|
||||
"license": "Apache-2.0"
|
||||
"integrity": "sha512-sLoadumpRfsjprP8XzVjpQc0jK8yqHBx0PtUTGYj2fftT+P/t+uyDAQdMgGAPKD011in/O+YYGh7fIs0oG/viw=="
|
||||
},
|
||||
"node_modules/browserify-aes": {
|
||||
"version": "1.2.0",
|
||||
@@ -18144,8 +18133,7 @@
|
||||
"node_modules/immediate": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
|
||||
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==",
|
||||
"license": "MIT"
|
||||
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ=="
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.1",
|
||||
@@ -19090,7 +19078,6 @@
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/jeep-sqlite/-/jeep-sqlite-2.8.0.tgz",
|
||||
"integrity": "sha512-FWNUP6OAmrUHwiW7H1xH5YUQ8tN2O4l4psT1sLd7DQtHd5PfrA1nvNdeKPNj+wQBtu7elJa8WoUibTytNTaaCg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@stencil/core": "^4.20.0",
|
||||
"browser-fs-access": "^0.35.0",
|
||||
@@ -19591,7 +19578,6 @@
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
|
||||
"integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==",
|
||||
"license": "(MIT OR GPL-3.0-or-later)",
|
||||
"dependencies": {
|
||||
"lie": "~3.3.0",
|
||||
"pako": "~1.0.2",
|
||||
@@ -19602,20 +19588,17 @@
|
||||
"node_modules/jszip/node_modules/isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
|
||||
"license": "MIT"
|
||||
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
|
||||
},
|
||||
"node_modules/jszip/node_modules/pako": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
|
||||
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
|
||||
"license": "(MIT AND Zlib)"
|
||||
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
|
||||
},
|
||||
"node_modules/jszip/node_modules/readable-stream": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
||||
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
@@ -19629,14 +19612,12 @@
|
||||
"node_modules/jszip/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"license": "MIT"
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"node_modules/jszip/node_modules/string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
@@ -20159,7 +20140,6 @@
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz",
|
||||
"integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"immediate": "~3.0.5"
|
||||
}
|
||||
@@ -20526,7 +20506,6 @@
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz",
|
||||
"integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"lie": "3.1.1"
|
||||
}
|
||||
@@ -20535,7 +20514,6 @@
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
|
||||
"integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"immediate": "~3.0.5"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "timesafari",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.8",
|
||||
"description": "Time Safari Application",
|
||||
"author": {
|
||||
"name": "Time Safari Team"
|
||||
@@ -46,7 +46,7 @@
|
||||
"electron:build-mac-universal": "npm run build:electron-prod && electron-builder --mac --universal"
|
||||
},
|
||||
"dependencies": {
|
||||
"@capacitor-community/sqlite": "^6.0.2",
|
||||
"@capacitor-community/sqlite": "6.0.2",
|
||||
"@capacitor-mlkit/barcode-scanning": "^6.0.0",
|
||||
"@capacitor/android": "^6.2.0",
|
||||
"@capacitor/app": "^6.0.0",
|
||||
@@ -171,7 +171,7 @@
|
||||
},
|
||||
"main": "./dist-electron/main.js",
|
||||
"build": {
|
||||
"appId": "app.timesafari",
|
||||
"appId": "app.timesafari.app",
|
||||
"productName": "TimeSafari",
|
||||
"directories": {
|
||||
"output": "dist-electron-packages"
|
||||
|
||||
@@ -2,5 +2,6 @@ dependencies:
|
||||
- gradle
|
||||
- java
|
||||
- pod
|
||||
- rubygems.org
|
||||
|
||||
# other dependencies are discovered via package.json & requirements.txt & Gemfile (I'm guessing).
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
eth_keys
|
||||
pywebview
|
||||
pyinstaller>=6.12.0
|
||||
setuptools>=69.0.0 # Required for distutils for electron-builder on macOS
|
||||
# For development
|
||||
watchdog>=3.0.0 # For file watching support
|
||||
@@ -51,7 +51,7 @@ const { existsSync } = require('fs');
|
||||
*/
|
||||
function checkCommand(command, errorMessage) {
|
||||
try {
|
||||
execSync(command + ' --version', { stdio: 'ignore' });
|
||||
execSync(command, { stdio: 'ignore' });
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(`❌ ${errorMessage}`);
|
||||
@@ -164,10 +164,10 @@ function main() {
|
||||
|
||||
// Check required command line tools
|
||||
// These are essential for building and testing the application
|
||||
success &= checkCommand('node', 'Node.js is required');
|
||||
success &= checkCommand('npm', 'npm is required');
|
||||
success &= checkCommand('gradle', 'Gradle is required for Android builds');
|
||||
success &= checkCommand('xcodebuild', 'Xcode is required for iOS builds');
|
||||
success &= checkCommand('node --version', 'Node.js is required');
|
||||
success &= checkCommand('npm --version', 'npm is required');
|
||||
success &= checkCommand('gradle --version', 'Gradle is required for Android builds');
|
||||
success &= checkCommand('xcodebuild --help', 'Xcode is required for iOS builds');
|
||||
|
||||
// Check platform-specific development environments
|
||||
success &= checkAndroidSetup();
|
||||
|
||||
@@ -170,7 +170,7 @@ const executeDeeplink = async (url, description, log) => {
|
||||
|
||||
try {
|
||||
// Stop the app before executing the deep link
|
||||
execSync('adb shell am force-stop app.timesafari');
|
||||
execSync('adb shell am force-stop app.timesafari.app');
|
||||
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1s
|
||||
|
||||
execSync(`adb shell am start -W -a android.intent.action.VIEW -d "${url}" -c android.intent.category.BROWSABLE`);
|
||||
|
||||
12
src/App.vue
@@ -4,7 +4,7 @@
|
||||
<!-- Messages in the upper-right - https://github.com/emmanuelsw/notiwind -->
|
||||
<NotificationGroup group="alert">
|
||||
<div
|
||||
class="fixed top-[calc(env(safe-area-inset-top)+1rem)] right-4 left-4 sm:left-auto sm:w-full sm:max-w-sm flex flex-col items-start justify-end"
|
||||
class="fixed z-[90] top-[max(1rem,env(safe-area-inset-top))] right-4 left-4 sm:left-auto sm:w-full sm:max-w-sm flex flex-col items-start justify-end"
|
||||
>
|
||||
<Notification
|
||||
v-slot="{ notifications, close }"
|
||||
@@ -548,13 +548,13 @@ export default class App extends Vue {
|
||||
|
||||
<style>
|
||||
#Content {
|
||||
padding-left: 1.5rem;
|
||||
padding-right: 1.5rem;
|
||||
padding-top: calc(env(safe-area-inset-top) + 1.5rem);
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 1.5rem);
|
||||
padding-left: max(1.5rem, env(safe-area-inset-left));
|
||||
padding-right: max(1.5rem, env(safe-area-inset-right));
|
||||
padding-top: max(1.5rem, env(safe-area-inset-top));
|
||||
padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
#QuickNav ~ #Content {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 6rem);
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 6.333rem);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -14,22 +14,34 @@
|
||||
class="flex items-center justify-between gap-2 text-lg bg-slate-200 border border-slate-300 border-b-0 rounded-t-md px-3 sm:px-4 py-1 sm:py-2"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<div v-if="record.issuerDid">
|
||||
<router-link
|
||||
v-if="record.issuerDid && !isHiddenDid(record.issuerDid)"
|
||||
:to="{
|
||||
path: '/did/' + encodeURIComponent(record.issuerDid),
|
||||
}"
|
||||
title="More details about this person"
|
||||
>
|
||||
<EntityIcon
|
||||
:entity-id="record.issuerDid"
|
||||
class="rounded-full bg-white overflow-hidden !size-[2rem] object-cover"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<font-awesome
|
||||
icon="person-circle-question"
|
||||
class="text-slate-300 text-[2rem]"
|
||||
/>
|
||||
</div>
|
||||
</router-link>
|
||||
<font-awesome
|
||||
v-else-if="isHiddenDid(record.issuerDid)"
|
||||
icon="eye-slash"
|
||||
class="text-slate-400 !size-[2rem] cursor-pointer"
|
||||
@click="notifyHiddenPerson"
|
||||
/>
|
||||
<font-awesome
|
||||
v-else
|
||||
icon="person-circle-question"
|
||||
class="text-slate-400 !size-[2rem] cursor-pointer"
|
||||
@click="notifyUnknownPerson"
|
||||
/>
|
||||
|
||||
<div>
|
||||
<h3 class="font-semibold">
|
||||
{{ record.issuer.known ? record.issuer.displayName : "" }}
|
||||
<h3 v-if="record.issuer.known" class="font-semibold leading-tight">
|
||||
{{ record.issuer.displayName }}
|
||||
</h3>
|
||||
<p class="ms-auto text-xs text-slate-500 italic">
|
||||
{{ friendlyDate }}
|
||||
@@ -37,7 +49,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="cursor-pointer" @click="$emit('loadClaim', record.jwtId)">
|
||||
<a
|
||||
class="cursor-pointer"
|
||||
data-testid="circle-info-link"
|
||||
@click="$emit('loadClaim', record.jwtId)"
|
||||
>
|
||||
<font-awesome icon="circle-info" class="fa-fw text-slate-500" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -46,7 +62,7 @@
|
||||
<!-- Record Image -->
|
||||
<div
|
||||
v-if="record.image"
|
||||
class="bg-cover mb-6 -mt-3 sm:-mt-4 -mx-3 sm:-mx-4"
|
||||
class="bg-cover mb-2 -mt-3 sm:-mt-4 -mx-3 sm:-mx-4"
|
||||
:style="`background-image: url(${record.image});`"
|
||||
>
|
||||
<a
|
||||
@@ -62,29 +78,59 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Description -->
|
||||
<p class="font-medium">
|
||||
<a class="cursor-pointer" @click="$emit('loadClaim', record.jwtId)">
|
||||
{{ description }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div
|
||||
class="relative flex justify-between gap-4 max-w-[40rem] mx-auto mb-5"
|
||||
class="relative flex justify-between gap-4 max-w-[40rem] mx-auto mt-4"
|
||||
>
|
||||
<!-- Source -->
|
||||
<div
|
||||
class="w-[8rem] sm:w-[12rem] text-center bg-white border border-slate-200 rounded p-2 sm:p-3"
|
||||
class="w-[7rem] sm:w-[12rem] text-center bg-white border border-slate-200 rounded p-2 sm:p-3"
|
||||
>
|
||||
<div class="relative w-fit mx-auto">
|
||||
<div>
|
||||
<!-- Project Icon -->
|
||||
<div v-if="record.providerPlanName">
|
||||
<ProjectIcon
|
||||
:entity-id="record.providerPlanName"
|
||||
:icon-size="48"
|
||||
class="rounded size-[3rem] sm:size-[4rem] *:w-full *:h-full"
|
||||
/>
|
||||
<router-link
|
||||
:to="{
|
||||
path:
|
||||
'/project/' +
|
||||
encodeURIComponent(record.providerPlanHandleId || ''),
|
||||
}"
|
||||
title="View project details"
|
||||
>
|
||||
<ProjectIcon
|
||||
:entity-id="record.providerPlanHandleId || ''"
|
||||
:icon-size="48"
|
||||
class="rounded size-[3rem] sm:size-[4rem] *:w-full *:h-full"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
<!-- Identicon for DIDs -->
|
||||
<div v-else-if="record.agentDid">
|
||||
<EntityIcon
|
||||
:entity-id="record.agentDid"
|
||||
:profile-image-url="record.issuer.profileImageUrl"
|
||||
class="rounded-full bg-slate-100 overflow-hidden !size-[3rem] sm:!size-[4rem]"
|
||||
<router-link
|
||||
v-if="!isHiddenDid(record.agentDid)"
|
||||
:to="{
|
||||
path: '/did/' + encodeURIComponent(record.agentDid),
|
||||
}"
|
||||
title="More details about this person"
|
||||
>
|
||||
<EntityIcon
|
||||
:entity-id="record.agentDid"
|
||||
:profile-image-url="record.issuer.profileImageUrl"
|
||||
class="rounded-full bg-slate-100 overflow-hidden !size-[3rem] sm:!size-[4rem]"
|
||||
/>
|
||||
</router-link>
|
||||
<font-awesome
|
||||
v-else
|
||||
icon="eye-slash"
|
||||
class="text-slate-300 !size-[3rem] sm:!size-[4rem]"
|
||||
@click="notifyHiddenPerson"
|
||||
/>
|
||||
</div>
|
||||
<!-- Unknown Person -->
|
||||
@@ -92,6 +138,7 @@
|
||||
<font-awesome
|
||||
icon="person-circle-question"
|
||||
class="text-slate-300 text-[3rem] sm:text-[4rem]"
|
||||
@click="notifyUnknownPerson"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -110,9 +157,11 @@
|
||||
|
||||
<!-- Arrow -->
|
||||
<div
|
||||
class="absolute inset-x-[8rem] sm:inset-x-[12rem] mx-2 top-1/2 -translate-y-1/2"
|
||||
class="absolute inset-x-[7rem] sm:inset-x-[12rem] mx-2 top-1/2 -translate-y-1/2"
|
||||
>
|
||||
<div class="text-sm text-center leading-none font-semibold pe-[15px]">
|
||||
<div
|
||||
class="text-sm text-center leading-none font-semibold pe-2 sm:pe-4"
|
||||
>
|
||||
{{ fetchAmount }}
|
||||
</div>
|
||||
|
||||
@@ -129,24 +178,47 @@
|
||||
|
||||
<!-- Destination -->
|
||||
<div
|
||||
class="w-[8rem] sm:w-[12rem] text-center bg-white border border-slate-200 rounded p-2 sm:p-3"
|
||||
class="w-[7rem] sm:w-[12rem] text-center bg-white border border-slate-200 rounded p-2 sm:p-3"
|
||||
>
|
||||
<div class="relative w-fit mx-auto">
|
||||
<div>
|
||||
<!-- Project Icon -->
|
||||
<div v-if="record.recipientProjectName">
|
||||
<ProjectIcon
|
||||
:entity-id="record.recipientProjectName"
|
||||
:icon-size="48"
|
||||
class="rounded size-[3rem] sm:size-[4rem] *:w-full *:h-full"
|
||||
/>
|
||||
<router-link
|
||||
:to="{
|
||||
path:
|
||||
'/project/' +
|
||||
encodeURIComponent(record.fulfillsPlanHandleId || ''),
|
||||
}"
|
||||
title="View project details"
|
||||
>
|
||||
<ProjectIcon
|
||||
:entity-id="record.fulfillsPlanHandleId || ''"
|
||||
:icon-size="48"
|
||||
class="rounded size-[3rem] sm:size-[4rem] *:w-full *:h-full"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
<!-- Identicon for DIDs -->
|
||||
<div v-else-if="record.recipientDid">
|
||||
<EntityIcon
|
||||
:entity-id="record.recipientDid"
|
||||
:profile-image-url="record.receiver.profileImageUrl"
|
||||
class="rounded-full bg-slate-100 overflow-hidden !size-[3rem] sm:!size-[4rem]"
|
||||
<router-link
|
||||
v-if="!isHiddenDid(record.recipientDid)"
|
||||
:to="{
|
||||
path: '/did/' + encodeURIComponent(record.recipientDid),
|
||||
}"
|
||||
title="More details about this person"
|
||||
>
|
||||
<EntityIcon
|
||||
:entity-id="record.recipientDid"
|
||||
:profile-image-url="record.receiver.profileImageUrl"
|
||||
class="rounded-full bg-slate-100 overflow-hidden !size-[3rem] sm:!size-[4rem]"
|
||||
/>
|
||||
</router-link>
|
||||
<font-awesome
|
||||
v-else
|
||||
icon="eye-slash"
|
||||
class="text-slate-300 !size-[3rem] sm:!size-[4rem]"
|
||||
@click="notifyHiddenPerson"
|
||||
/>
|
||||
</div>
|
||||
<!-- Unknown Person -->
|
||||
@@ -154,6 +226,7 @@
|
||||
<font-awesome
|
||||
icon="person-circle-question"
|
||||
class="text-slate-300 text-[3rem] sm:text-[4rem]"
|
||||
@click="notifyUnknownPerson"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -170,13 +243,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Description -->
|
||||
<p class="font-medium">
|
||||
<a class="cursor-pointer" @click="$emit('loadClaim', record.jwtId)">
|
||||
{{ description }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
@@ -186,8 +252,9 @@ import { Component, Prop, Vue, Emit } from "vue-facing-decorator";
|
||||
import { GiveRecordWithContactInfo } from "../types";
|
||||
import EntityIcon from "./EntityIcon.vue";
|
||||
import { isGiveClaimType, notifyWhyCannotConfirm } from "../libs/util";
|
||||
import { containsHiddenDid } from "../libs/endorserServer";
|
||||
import { containsHiddenDid, isHiddenDid } from "../libs/endorserServer";
|
||||
import ProjectIcon from "./ProjectIcon.vue";
|
||||
import { NotificationIface } from "../constants/app";
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
@@ -202,6 +269,33 @@ export default class ActivityListItem extends Vue {
|
||||
@Prop() activeDid!: string;
|
||||
@Prop() confirmerIdList?: string[];
|
||||
|
||||
isHiddenDid = isHiddenDid;
|
||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||
|
||||
notifyHiddenPerson() {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "warning",
|
||||
title: "Person Outside Your Network",
|
||||
text: "This person is not visible to you.",
|
||||
},
|
||||
3000,
|
||||
);
|
||||
}
|
||||
|
||||
notifyUnknownPerson() {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "warning",
|
||||
title: "Unidentified Person",
|
||||
text: "Nobody specific was recognized.",
|
||||
},
|
||||
3000,
|
||||
);
|
||||
}
|
||||
|
||||
@Emit()
|
||||
cacheImage(image: string) {
|
||||
return image;
|
||||
@@ -222,7 +316,7 @@ export default class ActivityListItem extends Vue {
|
||||
const claim =
|
||||
(this.record.fullClaim as unknown).claim || this.record.fullClaim;
|
||||
|
||||
return `${claim.description}`;
|
||||
return `${claim?.description || ""}`;
|
||||
}
|
||||
|
||||
private displayAmount(code: string, amt: number) {
|
||||
|
||||
@@ -24,9 +24,7 @@ backup and database export, with platform-specific download instructions. * *
|
||||
class="block w-full text-center text-md 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-1.5 py-2 rounded-md"
|
||||
@click="exportDatabase()"
|
||||
>
|
||||
Download Settings & Contacts
|
||||
<br />
|
||||
(excluding Identifier Data)
|
||||
Download Contacts
|
||||
</button>
|
||||
<a
|
||||
ref="downloadLink"
|
||||
@@ -62,14 +60,18 @@ backup and database export, with platform-specific download instructions. * *
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-facing-decorator";
|
||||
import { AppString, NotificationIface, USE_DEXIE_DB } from "../constants/app";
|
||||
import { db } from "../db/index";
|
||||
import { AppString, NotificationIface } from "../constants/app";
|
||||
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "../services/PlatformServiceFactory";
|
||||
import {
|
||||
PlatformService,
|
||||
PlatformCapabilities,
|
||||
} from "../services/PlatformService";
|
||||
import { contactsToExportJson } from "../libs/util";
|
||||
|
||||
/**
|
||||
* @vue-component
|
||||
@@ -131,24 +133,25 @@ export default class DataExportSection extends Vue {
|
||||
*/
|
||||
public async exportDatabase() {
|
||||
try {
|
||||
if (!USE_DEXIE_DB) {
|
||||
throw new Error("Not implemented");
|
||||
let allContacts: Contact[] = [];
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const result = await platformService.dbQuery(`SELECT * FROM contacts`);
|
||||
if (result) {
|
||||
allContacts = databaseUtil.mapQueryResultToValues(
|
||||
result,
|
||||
) as unknown as Contact[];
|
||||
}
|
||||
const blob = await db.export({
|
||||
prettyJson: true,
|
||||
transform: (table, value, key) => {
|
||||
if (table === "contacts") {
|
||||
// Dexie inserts a number 0 when some are undefined, so we need to totally remove them.
|
||||
Object.keys(value).forEach((prop) => {
|
||||
if (value[prop] === undefined) {
|
||||
delete value[prop];
|
||||
}
|
||||
});
|
||||
}
|
||||
return { value, key };
|
||||
},
|
||||
});
|
||||
const fileName = `${AppString.APP_NAME_NO_SPACES}-backup.json`;
|
||||
// if (USE_DEXIE_DB) {
|
||||
// await db.open();
|
||||
// allContacts = await db.contacts.toArray();
|
||||
// }
|
||||
|
||||
// Convert contacts to export format
|
||||
const exportData = contactsToExportJson(allContacts);
|
||||
const jsonStr = JSON.stringify(exportData, null, 2);
|
||||
const blob = new Blob([jsonStr], { type: "application/json" });
|
||||
|
||||
const fileName = `${AppString.APP_NAME_NO_SPACES}-backup-contacts.json`;
|
||||
|
||||
if (this.platformCapabilities.hasFileDownload) {
|
||||
// Web platform: Use download link
|
||||
@@ -160,8 +163,7 @@ export default class DataExportSection extends Vue {
|
||||
setTimeout(() => URL.revokeObjectURL(this.downloadUrl), 1000);
|
||||
} else if (this.platformCapabilities.hasFileSystem) {
|
||||
// Native platform: Write to app directory
|
||||
const content = await blob.text();
|
||||
await this.platformService.writeAndShareFile(fileName, content);
|
||||
await this.platformService.writeAndShareFile(fileName, jsonStr);
|
||||
} else {
|
||||
throw new Error("This platform does not support file downloads.");
|
||||
}
|
||||
@@ -172,10 +174,10 @@ export default class DataExportSection extends Vue {
|
||||
type: "success",
|
||||
title: "Export Successful",
|
||||
text: this.platformCapabilities.hasFileDownload
|
||||
? "See your downloads directory for the backup. It is in the Dexie format."
|
||||
: "You should have been prompted to save your backup file.",
|
||||
? "See your downloads directory for the backup."
|
||||
: "The backup file has been saved.",
|
||||
},
|
||||
-1,
|
||||
3000,
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error("Export Error:", error);
|
||||
|
||||
@@ -320,10 +320,7 @@ export default class GiftedDialog extends Vue {
|
||||
this.fromProjectId,
|
||||
);
|
||||
|
||||
if (
|
||||
result.type === "error" ||
|
||||
this.isGiveCreationError(result.response)
|
||||
) {
|
||||
if (!result.success) {
|
||||
const errorMessage = this.getGiveCreationErrorMessage(result);
|
||||
logger.error("Error with give creation result:", result);
|
||||
this.$notify(
|
||||
@@ -370,15 +367,6 @@ export default class GiftedDialog extends Vue {
|
||||
|
||||
// Helper functions for readability
|
||||
|
||||
/**
|
||||
* @param result response "data" from the server
|
||||
* @returns true if the result indicates an error
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
isGiveCreationError(result: any) {
|
||||
return result.status !== 201 || result.data?.error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result direct response eg. ErrorResult or SuccessResult (potentially with embedded "data")
|
||||
* @returns best guess at an error message
|
||||
|
||||
@@ -48,11 +48,7 @@
|
||||
<span>
|
||||
{{ didInfo(visDid) }}
|
||||
<span v-if="!serverUtil.isEmptyOrHiddenDid(visDid)">
|
||||
<a
|
||||
:href="`/did/${visDid}`"
|
||||
target="_blank"
|
||||
class="text-blue-500"
|
||||
>
|
||||
<a :href="`/did/${visDid}`" class="text-blue-500">
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
<div class="text-lg text-center font-bold relative">
|
||||
<h1 id="ViewHeading" class="text-center font-bold">
|
||||
<span v-if="uploading">Uploading Image…</span>
|
||||
<span v-else-if="blob">Crop Image</span>
|
||||
<span v-else-if="blob">{{
|
||||
crop ? "Crop Image" : "Preview Image"
|
||||
}}</span>
|
||||
<span v-else-if="showCameraPreview">Upload Image</span>
|
||||
<span v-else>Add Photo</span>
|
||||
</h1>
|
||||
@@ -119,12 +121,23 @@
|
||||
playsinline
|
||||
muted
|
||||
></video>
|
||||
<button
|
||||
class="absolute bottom-4 left-1/2 -translate-x-1/2 bg-white text-slate-800 p-3 rounded-full text-2xl leading-none"
|
||||
@click="capturePhoto"
|
||||
<div
|
||||
class="absolute bottom-4 inset-x-0 flex items-center justify-center gap-4"
|
||||
>
|
||||
<font-awesome icon="camera" class="w-[1em]" />
|
||||
</button>
|
||||
<button
|
||||
class="bg-white text-slate-800 p-3 rounded-full text-2xl leading-none"
|
||||
@click="capturePhoto"
|
||||
>
|
||||
<font-awesome icon="camera" class="w-[1em]" />
|
||||
</button>
|
||||
<button
|
||||
v-if="platformCapabilities.isMobile"
|
||||
class="bg-white text-slate-800 p-3 rounded-full text-2xl leading-none"
|
||||
@click="rotateCamera"
|
||||
>
|
||||
<font-awesome icon="rotate" class="w-[1em]" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@@ -229,12 +242,12 @@
|
||||
<p class="mb-2">
|
||||
Before you can upload a photo, a friend needs to register you.
|
||||
</p>
|
||||
<router-link
|
||||
:to="{ name: 'contact-qr' }"
|
||||
<button
|
||||
class="inline-block text-md 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-4 py-2 rounded-md"
|
||||
@click="handleQRCodeClick"
|
||||
>
|
||||
Share Your Info
|
||||
</router-link>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -247,6 +260,7 @@ import axios from "axios";
|
||||
import { ref } from "vue";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import VuePictureCropper, { cropper } from "vue-picture-cropper";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
import {
|
||||
DEFAULT_IMAGE_API_SERVER,
|
||||
NotificationIface,
|
||||
@@ -267,6 +281,11 @@ const inputImageFileNameRef = ref<Blob>();
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
defaultCameraMode: {
|
||||
type: String,
|
||||
default: "environment",
|
||||
validator: (value: string) => ["environment", "user"].includes(value),
|
||||
},
|
||||
},
|
||||
})
|
||||
export default class ImageMethodDialog extends Vue {
|
||||
@@ -308,6 +327,9 @@ export default class ImageMethodDialog extends Vue {
|
||||
/** Camera stream reference */
|
||||
private cameraStream: MediaStream | null = null;
|
||||
|
||||
/** Current camera facing mode */
|
||||
private currentFacingMode: "environment" | "user" = "environment";
|
||||
|
||||
private platformService = PlatformServiceFactory.getInstance();
|
||||
URL = window.URL || window.webkitURL;
|
||||
|
||||
@@ -369,15 +391,16 @@ export default class ImageMethodDialog extends Vue {
|
||||
}
|
||||
|
||||
open(setImageFn: (arg: string) => void, claimType: string, crop?: boolean) {
|
||||
logger.debug("ImageMethodDialog.open called");
|
||||
this.claimType = claimType;
|
||||
this.crop = !!crop;
|
||||
this.imageCallback = setImageFn;
|
||||
this.visible = true;
|
||||
this.currentFacingMode = this.defaultCameraMode as "environment" | "user";
|
||||
|
||||
// Start camera preview immediately if not on mobile
|
||||
if (!this.platformCapabilities.isNativeApp) {
|
||||
this.startCameraPreview();
|
||||
}
|
||||
// Start camera preview immediately
|
||||
logger.debug("Starting camera preview from open()");
|
||||
this.startCameraPreview();
|
||||
}
|
||||
|
||||
async uploadImageFile(event: Event) {
|
||||
@@ -446,46 +469,24 @@ export default class ImageMethodDialog extends Vue {
|
||||
logger.debug("startCameraPreview called");
|
||||
logger.debug("Current showCameraPreview state:", this.showCameraPreview);
|
||||
logger.debug("Platform capabilities:", this.platformCapabilities);
|
||||
logger.debug("MediaDevices available:", !!navigator.mediaDevices);
|
||||
logger.debug(
|
||||
"getUserMedia available:",
|
||||
!!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia),
|
||||
);
|
||||
|
||||
if (this.platformCapabilities.isNativeApp) {
|
||||
logger.debug("Using platform service for mobile device");
|
||||
this.cameraState = "initializing";
|
||||
this.cameraStateMessage = "Using platform camera service...";
|
||||
try {
|
||||
const result = await this.platformService.takePicture();
|
||||
this.blob = result.blob;
|
||||
this.fileName = result.fileName;
|
||||
this.cameraState = "ready";
|
||||
this.cameraStateMessage = "Photo captured successfully";
|
||||
} catch (error) {
|
||||
logger.error("Error taking picture:", error);
|
||||
this.cameraState = "error";
|
||||
this.cameraStateMessage =
|
||||
error instanceof Error ? error.message : "Failed to take picture";
|
||||
this.error =
|
||||
error instanceof Error ? error.message : "Failed to take picture";
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Failed to take picture. Please try again.",
|
||||
},
|
||||
5000,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug("Starting camera preview for desktop browser");
|
||||
try {
|
||||
this.cameraState = "initializing";
|
||||
this.cameraStateMessage = "Requesting camera access...";
|
||||
this.showCameraPreview = true;
|
||||
await this.$nextTick();
|
||||
|
||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
||||
throw new Error("Camera API not available in this browser");
|
||||
}
|
||||
|
||||
const stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: { facingMode: "environment" },
|
||||
video: { facingMode: this.currentFacingMode },
|
||||
});
|
||||
logger.debug("Camera access granted");
|
||||
this.cameraStream = stream;
|
||||
@@ -499,25 +500,36 @@ export default class ImageMethodDialog extends Vue {
|
||||
videoElement.srcObject = stream;
|
||||
await new Promise((resolve) => {
|
||||
videoElement.onloadedmetadata = () => {
|
||||
videoElement.play().then(() => {
|
||||
resolve(true);
|
||||
});
|
||||
videoElement
|
||||
.play()
|
||||
.then(() => {
|
||||
logger.debug("Video element started playing");
|
||||
resolve(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error("Error playing video:", error);
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
});
|
||||
} else {
|
||||
logger.error("Video element not found");
|
||||
throw new Error("Video element not found");
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error("Error starting camera preview:", error);
|
||||
let errorMessage =
|
||||
error instanceof Error ? error.message : "Failed to access camera";
|
||||
if (
|
||||
error.name === "NotReadableError" ||
|
||||
error.name === "TrackStartError"
|
||||
error instanceof Error &&
|
||||
(error.name === "NotReadableError" || error.name === "TrackStartError")
|
||||
) {
|
||||
errorMessage =
|
||||
"Camera is in use by another application. Please close any other apps or browser tabs using the camera and try again.";
|
||||
} else if (
|
||||
error.name === "NotAllowedError" ||
|
||||
error.name === "PermissionDeniedError"
|
||||
error instanceof Error &&
|
||||
(error.name === "NotAllowedError" ||
|
||||
error.name === "PermissionDeniedError")
|
||||
) {
|
||||
errorMessage =
|
||||
"Camera access was denied. Please allow camera access in your browser settings.";
|
||||
@@ -525,6 +537,7 @@ export default class ImageMethodDialog extends Vue {
|
||||
this.cameraState = "error";
|
||||
this.cameraStateMessage = errorMessage;
|
||||
this.error = errorMessage;
|
||||
this.showCameraPreview = false;
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
@@ -534,7 +547,6 @@ export default class ImageMethodDialog extends Vue {
|
||||
},
|
||||
5000,
|
||||
);
|
||||
this.showCameraPreview = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,6 +598,21 @@ export default class ImageMethodDialog extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async rotateCamera() {
|
||||
// Toggle between front and back cameras
|
||||
this.currentFacingMode =
|
||||
this.currentFacingMode === "environment" ? "user" : "environment";
|
||||
|
||||
// Stop current stream
|
||||
if (this.cameraStream) {
|
||||
this.cameraStream.getTracks().forEach((track) => track.stop());
|
||||
this.cameraStream = null;
|
||||
}
|
||||
|
||||
// Start new stream with updated facing mode
|
||||
await this.startCameraPreview();
|
||||
}
|
||||
|
||||
private createBlobURL(blob: Blob): string {
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
@@ -620,6 +647,7 @@ export default class ImageMethodDialog extends Vue {
|
||||
5000,
|
||||
);
|
||||
this.uploading = false;
|
||||
this.close();
|
||||
return;
|
||||
}
|
||||
formData.append("image", this.blob, this.fileName || "photo.jpg");
|
||||
@@ -674,6 +702,7 @@ export default class ImageMethodDialog extends Vue {
|
||||
);
|
||||
this.uploading = false;
|
||||
this.blob = undefined;
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,6 +710,14 @@ export default class ImageMethodDialog extends Vue {
|
||||
toggleDiagnostics() {
|
||||
this.showDiagnostics = !this.showDiagnostics;
|
||||
}
|
||||
|
||||
private handleQRCodeClick() {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
this.$router.push({ name: "contact-qr-scan-full" });
|
||||
} else {
|
||||
this.$router.push({ name: "contact-qr" });
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ export default class MembersList extends Vue {
|
||||
this.decryptedMembers.length === 0 ||
|
||||
this.decryptedMembers[0].member.memberId !== this.members[0].memberId
|
||||
) {
|
||||
return "Your password is not the same as the organizer. Reload or have them check their password.";
|
||||
return "Your password is not the same as the organizer. Retry or have them check their password.";
|
||||
} else {
|
||||
// the first (organizer) member was decrypted OK
|
||||
return "";
|
||||
@@ -342,7 +342,7 @@ export default class MembersList extends Vue {
|
||||
group: "alert",
|
||||
type: "info",
|
||||
title: "Contact Exists",
|
||||
text: "They are in your contacts. If you want to remove them, you must do that from the contacts screen.",
|
||||
text: "They are in your contacts. To remove them, use the contacts page.",
|
||||
},
|
||||
10000,
|
||||
);
|
||||
@@ -352,7 +352,7 @@ export default class MembersList extends Vue {
|
||||
group: "alert",
|
||||
type: "info",
|
||||
title: "Contact Available",
|
||||
text: "This is to add them to your contacts. If you want to remove them later, you must do that from the contacts screen.",
|
||||
text: "This is to add them to your contacts. To remove them later, use the contacts page.",
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
@@ -249,10 +249,7 @@ export default class OfferDialog extends Vue {
|
||||
this.projectId,
|
||||
);
|
||||
|
||||
if (
|
||||
result.type === "error" ||
|
||||
this.isOfferCreationError(result.response)
|
||||
) {
|
||||
if (!result.success) {
|
||||
const errorMessage = this.getOfferCreationErrorMessage(result);
|
||||
logger.error("Error with offer creation result:", result);
|
||||
this.$notify(
|
||||
@@ -296,15 +293,6 @@ export default class OfferDialog extends Vue {
|
||||
|
||||
// Helper functions for readability
|
||||
|
||||
/**
|
||||
* @param result response "data" from the server
|
||||
* @returns true if the result indicates an error
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
isOfferCreationError(result: any) {
|
||||
return result.status !== 201 || result.data?.error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result direct response eg. ErrorResult or SuccessResult (potentially with embedded "data")
|
||||
* @returns best guess at an error message
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<h1 class="text-xl font-bold text-center mb-4 relative">
|
||||
Welcome to Time Safari
|
||||
<br />
|
||||
- Showcasing Gratitude & Magnifying Time
|
||||
- Showcase Impact & Magnify Time
|
||||
<div
|
||||
class="text-lg text-center leading-none absolute right-0 -top-1"
|
||||
@click="onClickClose(true)"
|
||||
@@ -14,6 +14,9 @@
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
The feed underneath this pop-up shows the latest contributions, some from
|
||||
people and some from projects.
|
||||
|
||||
<p v-if="isRegistered" class="mt-4">
|
||||
You can now log things that you've seen:
|
||||
<span v-if="numContacts > 0">
|
||||
@@ -23,14 +26,10 @@
|
||||
<span class="bg-green-600 text-white rounded-full">
|
||||
<font-awesome icon="plus" class="fa-fw" />
|
||||
</span>
|
||||
button to express your appreciation for... whatever -- maybe thanks for
|
||||
showing you all these fascinating stories of
|
||||
<em>gratitude</em>.
|
||||
button to express your appreciation for... whatever.
|
||||
</p>
|
||||
<p v-else class="mt-4">
|
||||
The feed underneath this pop-up shows the latest gifts that others have
|
||||
recognized. Once someone registers you, you can log your appreciation,
|
||||
too.
|
||||
<p class="mt-4">
|
||||
Once someone registers you, you can log your appreciation, too.
|
||||
</p>
|
||||
|
||||
<p class="mt-4">
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<template>
|
||||
<a
|
||||
v-if="linkToFull && imageUrl"
|
||||
v-if="linkToFullImage && imageUrl"
|
||||
:href="imageUrl"
|
||||
target="_blank"
|
||||
class="h-full w-full object-contain"
|
||||
>
|
||||
<div class="h-full w-full object-contain" v-html="generateIdenticon()" />
|
||||
<div class="h-full w-full object-contain" v-html="generateIcon()" />
|
||||
</a>
|
||||
<div
|
||||
v-else
|
||||
class="h-full w-full object-contain"
|
||||
v-html="generateIdenticon()"
|
||||
/>
|
||||
<div v-else class="h-full w-full object-contain" v-html="generateIcon()" />
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { toSvg } from "jdenticon";
|
||||
@@ -35,9 +31,9 @@ export default class ProjectIcon extends Vue {
|
||||
@Prop entityId = "";
|
||||
@Prop iconSize = 0;
|
||||
@Prop imageUrl = "";
|
||||
@Prop linkToFull = false;
|
||||
@Prop linkToFullImage = false;
|
||||
|
||||
generateIdenticon() {
|
||||
generateIcon() {
|
||||
if (this.imageUrl) {
|
||||
return `<img src="${this.imageUrl}" class="w-full h-full object-contain" />`;
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="absolute right-5 top-[calc(env(safe-area-inset-top)+0.75rem)]">
|
||||
<div class="absolute right-5 top-[max(0.75rem,env(safe-area-inset-top))]">
|
||||
<span class="align-center text-red-500 mr-2">{{ message }}</span>
|
||||
<span class="ml-2">
|
||||
<router-link
|
||||
|
||||
@@ -74,7 +74,7 @@ export default class UserNameDialog extends Vue {
|
||||
async onClickSaveChanges() {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec(
|
||||
"UPDATE settings SET firstName = ? WHERE key = ?",
|
||||
"UPDATE settings SET firstName = ? WHERE id = ?",
|
||||
[this.givenName, MASTER_SETTINGS_KEY],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
|
||||
@@ -33,18 +33,18 @@ export const APP_SERVER =
|
||||
|
||||
export const DEFAULT_ENDORSER_API_SERVER =
|
||||
import.meta.env.VITE_DEFAULT_ENDORSER_API_SERVER ||
|
||||
AppString.TEST_ENDORSER_API_SERVER;
|
||||
AppString.PROD_ENDORSER_API_SERVER;
|
||||
|
||||
export const DEFAULT_IMAGE_API_SERVER =
|
||||
import.meta.env.VITE_DEFAULT_IMAGE_API_SERVER ||
|
||||
AppString.TEST_IMAGE_API_SERVER;
|
||||
AppString.PROD_IMAGE_API_SERVER;
|
||||
|
||||
export const DEFAULT_PARTNER_API_SERVER =
|
||||
import.meta.env.VITE_DEFAULT_PARTNER_API_SERVER ||
|
||||
AppString.TEST_PARTNER_API_SERVER;
|
||||
AppString.PROD_PARTNER_API_SERVER;
|
||||
|
||||
export const DEFAULT_PUSH_SERVER =
|
||||
import.meta.env.VITE_DEFAULT_PUSH_SERVER || "https://timesafari.app";
|
||||
import.meta.env.VITE_DEFAULT_PUSH_SERVER || AppString.PROD_PUSH_SERVER;
|
||||
|
||||
export const IMAGE_TYPE_PROFILE = "profile";
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import migrationService from "../services/migrationService";
|
||||
import type { QueryExecResult } from "../interfaces/database";
|
||||
import { DEFAULT_ENDORSER_API_SERVER } from "@/constants/app";
|
||||
import { arrayBufferToBase64 } from "@/libs/crypto";
|
||||
|
||||
@@ -119,16 +118,21 @@ const MIGRATIONS = [
|
||||
},
|
||||
];
|
||||
|
||||
export async function registerMigrations(): Promise<void> {
|
||||
// Register all migrations
|
||||
for (const migration of MIGRATIONS) {
|
||||
await migrationService.registerMigration(migration);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runMigrations(
|
||||
sqlExec: (sql: string, params?: unknown[]) => Promise<Array<QueryExecResult>>,
|
||||
/**
|
||||
* @param sqlExec - A function that executes a SQL statement and returns the result
|
||||
* @param extractMigrationNames - A function that extracts the names (string array) from "select name from migrations"
|
||||
*/
|
||||
export async function runMigrations<T>(
|
||||
sqlExec: (sql: string) => Promise<unknown>,
|
||||
sqlQuery: (sql: string) => Promise<T>,
|
||||
extractMigrationNames: (result: T) => Set<string>,
|
||||
): Promise<void> {
|
||||
await registerMigrations();
|
||||
await migrationService.runMigrations(sqlExec);
|
||||
for (const migration of MIGRATIONS) {
|
||||
migrationService.registerMigration(migration);
|
||||
}
|
||||
await migrationService.runMigrations(
|
||||
sqlExec,
|
||||
sqlQuery,
|
||||
extractMigrationNames,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,20 +55,7 @@ export async function updateAccountSettings(
|
||||
);
|
||||
|
||||
const updateResult = await platform.dbExec(updateSql, updateParams);
|
||||
|
||||
// If no record was updated, insert a new one
|
||||
if (updateResult.changes === 1) {
|
||||
return true;
|
||||
} else {
|
||||
const columns = Object.keys(settingsChanges);
|
||||
const values = Object.values(settingsChanges);
|
||||
const placeholders = values.map(() => "?").join(", ");
|
||||
|
||||
const insertSql = `INSERT INTO settings (${columns.join(", ")}) VALUES (${placeholders})`;
|
||||
const result = await platform.dbExec(insertSql, values);
|
||||
|
||||
return result.changes === 1;
|
||||
}
|
||||
return updateResult.changes === 1;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: Settings = {
|
||||
@@ -80,9 +67,8 @@ const DEFAULT_SETTINGS: Settings = {
|
||||
// retrieves default settings
|
||||
export async function retrieveSettingsForDefaultAccount(): Promise<Settings> {
|
||||
const platform = PlatformServiceFactory.getInstance();
|
||||
const result = await platform.dbQuery("SELECT * FROM settings WHERE id = ?", [
|
||||
MASTER_SETTINGS_KEY,
|
||||
]);
|
||||
const sql = "SELECT * FROM settings WHERE id = ?";
|
||||
const result = await platform.dbQuery(sql, [MASTER_SETTINGS_KEY]);
|
||||
if (!result) {
|
||||
return DEFAULT_SETTINGS;
|
||||
} else {
|
||||
@@ -98,32 +84,71 @@ export async function retrieveSettingsForDefaultAccount(): Promise<Settings> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves settings for the active account, merging with default settings
|
||||
*
|
||||
* @returns Promise<Settings> Combined settings with account-specific overrides
|
||||
* @throws Will log specific errors for debugging but returns default settings on failure
|
||||
*/
|
||||
export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
|
||||
const defaultSettings = await retrieveSettingsForDefaultAccount();
|
||||
if (!defaultSettings.activeDid) {
|
||||
return defaultSettings;
|
||||
} else {
|
||||
const platform = PlatformServiceFactory.getInstance();
|
||||
const result = await platform.dbQuery(
|
||||
"SELECT * FROM settings WHERE accountDid = ?",
|
||||
[defaultSettings.activeDid],
|
||||
);
|
||||
const overrideSettings = result
|
||||
? (mapColumnsToValues(result.columns, result.values)[0] as Settings)
|
||||
: {};
|
||||
const overrideSettingsFiltered = Object.fromEntries(
|
||||
Object.entries(overrideSettings).filter(([_, v]) => v !== null),
|
||||
);
|
||||
const settings = { ...defaultSettings, ...overrideSettingsFiltered };
|
||||
if (settings.searchBoxes) {
|
||||
// @ts-expect-error - the searchBoxes field is a string in the DB
|
||||
settings.searchBoxes = JSON.parse(settings.searchBoxes);
|
||||
try {
|
||||
// Get default settings first
|
||||
const defaultSettings = await retrieveSettingsForDefaultAccount();
|
||||
// If no active DID, return defaults
|
||||
if (!defaultSettings.activeDid) {
|
||||
logConsoleAndDb(
|
||||
"[databaseUtil] No active DID found, returning default settings",
|
||||
);
|
||||
return defaultSettings;
|
||||
}
|
||||
return settings;
|
||||
|
||||
// Get account-specific settings
|
||||
try {
|
||||
const platform = PlatformServiceFactory.getInstance();
|
||||
const result = await platform.dbQuery(
|
||||
"SELECT * FROM settings WHERE accountDid = ?",
|
||||
[defaultSettings.activeDid],
|
||||
);
|
||||
|
||||
if (!result?.values?.length) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] No account-specific settings found for ${defaultSettings.activeDid}`,
|
||||
);
|
||||
return defaultSettings;
|
||||
}
|
||||
|
||||
// Map settings
|
||||
const overrideSettings = mapColumnsToValues(
|
||||
result.columns,
|
||||
result.values,
|
||||
)[0] as Settings;
|
||||
|
||||
// Use the new mergeSettings function for consistency
|
||||
return mergeSettings(defaultSettings, overrideSettings);
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] Failed to retrieve account settings for ${defaultSettings.activeDid}: ${error}`,
|
||||
true,
|
||||
);
|
||||
// Return defaults on error
|
||||
return defaultSettings;
|
||||
}
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] Failed to retrieve default settings: ${error}`,
|
||||
true,
|
||||
);
|
||||
// Return minimal default settings on complete failure
|
||||
return {
|
||||
id: MASTER_SETTINGS_KEY,
|
||||
activeDid: undefined,
|
||||
apiServer: DEFAULT_ENDORSER_API_SERVER,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let lastCleanupDate: string | null = null;
|
||||
export let memoryLogs: string[] = [];
|
||||
|
||||
/**
|
||||
* Logs a message to the database with proper handling of concurrent writes
|
||||
@@ -136,6 +161,7 @@ export async function logToDb(message: string): Promise<void> {
|
||||
const nowKey = new Date().toISOString();
|
||||
|
||||
try {
|
||||
memoryLogs.push(`${new Date().toISOString()} ${message}`);
|
||||
// Try to insert first, if it fails due to UNIQUE constraint, update instead
|
||||
await platform.dbExec("INSERT INTO logs (date, message) VALUES (?, ?)", [
|
||||
nowKey,
|
||||
@@ -148,6 +174,9 @@ export async function logToDb(message: string): Promise<void> {
|
||||
const sevenDaysAgo = new Date(
|
||||
new Date().getTime() - 7 * 24 * 60 * 60 * 1000,
|
||||
);
|
||||
memoryLogs = memoryLogs.filter(
|
||||
(log) => log.split(" ")[0] > sevenDaysAgo.toDateString(),
|
||||
);
|
||||
await platform.dbExec("DELETE FROM logs WHERE date < ?", [
|
||||
sevenDaysAgo.toDateString(),
|
||||
]);
|
||||
@@ -217,10 +246,8 @@ export function generateUpdateStatement(
|
||||
const params: unknown[] = [];
|
||||
|
||||
Object.entries(model).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
setClauses.push(`${key} = ?`);
|
||||
params.push(value);
|
||||
}
|
||||
setClauses.push(`${key} = ?`);
|
||||
params.push(value ?? null);
|
||||
});
|
||||
|
||||
if (setClauses.length === 0) {
|
||||
@@ -265,3 +292,128 @@ export function mapColumnsToValues(
|
||||
return obj;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves settings for a specific account by DID
|
||||
* @param accountDid - The DID of the account to retrieve settings for
|
||||
* @returns Promise<Settings> Combined settings for the specified account
|
||||
*/
|
||||
export async function getSettingsForAccount(accountDid: string): Promise<Settings> {
|
||||
try {
|
||||
// Get default settings first
|
||||
const defaultSettings = await retrieveSettingsForDefaultAccount();
|
||||
|
||||
// Get account-specific settings
|
||||
const platform = PlatformServiceFactory.getInstance();
|
||||
const result = await platform.dbQuery(
|
||||
"SELECT * FROM settings WHERE accountDid = ?",
|
||||
[accountDid],
|
||||
);
|
||||
|
||||
if (!result?.values?.length) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] No account-specific settings found for ${accountDid}`,
|
||||
);
|
||||
return defaultSettings;
|
||||
}
|
||||
|
||||
// Map and merge settings
|
||||
const overrideSettings = mapColumnsToValues(
|
||||
result.columns,
|
||||
result.values,
|
||||
)[0] as Settings;
|
||||
|
||||
return mergeSettings(defaultSettings, overrideSettings);
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] Failed to retrieve settings for account ${accountDid}: ${error}`,
|
||||
true,
|
||||
);
|
||||
// Return default settings on error
|
||||
return await retrieveSettingsForDefaultAccount();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves only account-specific settings for a given DID (without merging with defaults)
|
||||
* @param accountDid - The DID of the account to retrieve settings for
|
||||
* @returns Promise<Settings> Account-specific settings only
|
||||
*/
|
||||
export async function getAccountSpecificSettings(accountDid: string): Promise<Settings> {
|
||||
try {
|
||||
const platform = PlatformServiceFactory.getInstance();
|
||||
const result = await platform.dbQuery(
|
||||
"SELECT * FROM settings WHERE accountDid = ?",
|
||||
[accountDid],
|
||||
);
|
||||
|
||||
if (!result?.values?.length) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] No account-specific settings found for ${accountDid}`,
|
||||
);
|
||||
return {};
|
||||
}
|
||||
|
||||
// Map settings
|
||||
const settings = mapColumnsToValues(
|
||||
result.columns,
|
||||
result.values,
|
||||
)[0] as Settings;
|
||||
|
||||
// Handle searchBoxes parsing
|
||||
if (settings.searchBoxes) {
|
||||
try {
|
||||
// @ts-expect-error - the searchBoxes field is a string in the DB
|
||||
settings.searchBoxes = JSON.parse(settings.searchBoxes);
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] Failed to parse searchBoxes for ${accountDid}: ${error}`,
|
||||
true,
|
||||
);
|
||||
// Reset to empty array on parse failure
|
||||
settings.searchBoxes = [];
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] Failed to retrieve account-specific settings for ${accountDid}: ${error}`,
|
||||
true,
|
||||
);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges default settings with account-specific settings using consistent logic
|
||||
* @param defaultSettings - The default/master settings
|
||||
* @param accountSettings - The account-specific settings to merge
|
||||
* @returns Settings - Merged settings with account-specific overrides
|
||||
*/
|
||||
export function mergeSettings(defaultSettings: Settings, accountSettings: Settings): Settings {
|
||||
// Filter out null values from account settings
|
||||
const accountSettingsFiltered = Object.fromEntries(
|
||||
Object.entries(accountSettings).filter(([_, v]) => v !== null),
|
||||
);
|
||||
|
||||
// Perform shallow merge (account settings override defaults)
|
||||
const mergedSettings = { ...defaultSettings, ...accountSettingsFiltered };
|
||||
|
||||
// Handle searchBoxes parsing if present
|
||||
if (mergedSettings.searchBoxes) {
|
||||
try {
|
||||
// @ts-expect-error - the searchBoxes field is a string in the DB
|
||||
mergedSettings.searchBoxes = JSON.parse(mergedSettings.searchBoxes);
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
`[databaseUtil] Failed to parse searchBoxes during merge: ${error}`,
|
||||
true,
|
||||
);
|
||||
// Reset to empty array on parse failure
|
||||
mergedSettings.searchBoxes = [];
|
||||
}
|
||||
}
|
||||
|
||||
return mergedSettings;
|
||||
}
|
||||
|
||||
@@ -265,6 +265,43 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves settings for a specific account by DID
|
||||
* @param accountDid - The DID of the account to retrieve settings for
|
||||
* @returns Promise<Settings> Combined settings for the specified account
|
||||
*/
|
||||
export async function getSettingsForAccount(accountDid: string): Promise<Settings> {
|
||||
const defaultSettings = await retrieveSettingsForDefaultAccount();
|
||||
const overrideSettings =
|
||||
(await db.settings
|
||||
.where("accountDid")
|
||||
.equals(accountDid)
|
||||
.first()) || {};
|
||||
return R.mergeDeepRight(defaultSettings, overrideSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves only account-specific settings for a given DID (without merging with defaults)
|
||||
* @param accountDid - The DID of the account to retrieve settings for
|
||||
* @returns Promise<Settings> Account-specific settings only
|
||||
*/
|
||||
export async function getAccountSpecificSettings(accountDid: string): Promise<Settings> {
|
||||
return (await db.settings
|
||||
.where("accountDid")
|
||||
.equals(accountDid)
|
||||
.first()) || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges default settings with account-specific settings using consistent logic
|
||||
* @param defaultSettings - The default/master settings
|
||||
* @param accountSettings - The account-specific settings to merge
|
||||
* @returns Settings - Merged settings with account-specific overrides
|
||||
*/
|
||||
export function mergeSettings(defaultSettings: Settings, accountSettings: Settings): Settings {
|
||||
return R.mergeDeepRight(defaultSettings, accountSettings);
|
||||
}
|
||||
|
||||
export async function updateAccountSettings(
|
||||
accountDid: string,
|
||||
settingsChanges: Settings,
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
import { GenericVerifiableCredential } from "./common";
|
||||
/**
|
||||
* Types of Claims
|
||||
*
|
||||
* Note that these are for the claims that get signed.
|
||||
* Records that are the latest edited entities are in the records.ts file.
|
||||
*
|
||||
*/
|
||||
|
||||
export interface AgreeVerifiableCredential {
|
||||
"@context": string;
|
||||
import { ClaimObject } from "./common";
|
||||
|
||||
export interface AgreeActionClaim extends ClaimObject {
|
||||
"@context": "https://schema.org";
|
||||
"@type": string;
|
||||
object: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// Note that previous VCs may have additional fields.
|
||||
// https://endorser.ch/doc/html/transactions.html#id4
|
||||
export interface GiveVerifiableCredential extends GenericVerifiableCredential {
|
||||
export interface GiveActionClaim extends ClaimObject {
|
||||
// context is optional because it might be embedded in another claim, eg. an AgreeAction
|
||||
"@context"?: "https://schema.org";
|
||||
"@type": "GiveAction";
|
||||
agent?: { identifier: string };
|
||||
description?: string;
|
||||
@@ -16,43 +26,21 @@ export interface GiveVerifiableCredential extends GenericVerifiableCredential {
|
||||
identifier?: string;
|
||||
image?: string;
|
||||
object?: { amountOfThisGood: number; unitCode: string };
|
||||
provider?: GenericVerifiableCredential;
|
||||
provider?: ClaimObject;
|
||||
recipient?: { identifier: string };
|
||||
type: string[];
|
||||
issuer: string;
|
||||
issuanceDate: string;
|
||||
credentialSubject: {
|
||||
id: string;
|
||||
type: "GiveAction";
|
||||
offeredBy?: {
|
||||
type: "Person";
|
||||
identifier: string;
|
||||
};
|
||||
offeredTo?: {
|
||||
type: "Person";
|
||||
identifier: string;
|
||||
};
|
||||
offeredToProject?: {
|
||||
type: "Project";
|
||||
identifier: string;
|
||||
};
|
||||
offeredToProjectVisibleToDids?: string[];
|
||||
offeredToVisibleToDids?: string[];
|
||||
offeredByVisibleToDids?: string[];
|
||||
amount: {
|
||||
type: "QuantitativeValue";
|
||||
value: number;
|
||||
unitCode: string;
|
||||
};
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface JoinActionClaim extends ClaimObject {
|
||||
agent?: { identifier: string };
|
||||
event?: { organizer?: { name: string }; name?: string; startTime?: string };
|
||||
}
|
||||
|
||||
// Note that previous VCs may have additional fields.
|
||||
// https://endorser.ch/doc/html/transactions.html#id8
|
||||
export interface OfferVerifiableCredential extends GenericVerifiableCredential {
|
||||
export interface OfferClaim extends ClaimObject {
|
||||
"@context": "https://schema.org";
|
||||
"@type": "Offer";
|
||||
agent?: { identifier: string };
|
||||
description?: string;
|
||||
fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[];
|
||||
identifier?: string;
|
||||
@@ -67,43 +55,18 @@ export interface OfferVerifiableCredential extends GenericVerifiableCredential {
|
||||
name?: string;
|
||||
};
|
||||
};
|
||||
provider?: GenericVerifiableCredential;
|
||||
offeredBy?: {
|
||||
type?: "Person";
|
||||
identifier: string;
|
||||
};
|
||||
provider?: ClaimObject;
|
||||
recipient?: { identifier: string };
|
||||
validThrough?: string;
|
||||
type: string[];
|
||||
issuer: string;
|
||||
issuanceDate: string;
|
||||
credentialSubject: {
|
||||
id: string;
|
||||
type: "Offer";
|
||||
offeredBy?: {
|
||||
type: "Person";
|
||||
identifier: string;
|
||||
};
|
||||
offeredTo?: {
|
||||
type: "Person";
|
||||
identifier: string;
|
||||
};
|
||||
offeredToProject?: {
|
||||
type: "Project";
|
||||
identifier: string;
|
||||
};
|
||||
offeredToProjectVisibleToDids?: string[];
|
||||
offeredToVisibleToDids?: string[];
|
||||
offeredByVisibleToDids?: string[];
|
||||
amount: {
|
||||
type: "QuantitativeValue";
|
||||
value: number;
|
||||
unitCode: string;
|
||||
};
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
};
|
||||
}
|
||||
|
||||
// Note that previous VCs may have additional fields.
|
||||
// https://endorser.ch/doc/html/transactions.html#id7
|
||||
export interface PlanVerifiableCredential extends GenericVerifiableCredential {
|
||||
export interface PlanActionClaim extends ClaimObject {
|
||||
"@context": "https://schema.org";
|
||||
"@type": "PlanAction";
|
||||
name: string;
|
||||
@@ -117,11 +80,18 @@ export interface PlanVerifiableCredential extends GenericVerifiableCredential {
|
||||
}
|
||||
|
||||
// AKA Registration & RegisterAction
|
||||
export interface RegisterVerifiableCredential {
|
||||
"@context": string;
|
||||
export interface RegisterActionClaim extends ClaimObject {
|
||||
"@context": "https://schema.org";
|
||||
"@type": "RegisterAction";
|
||||
agent: { identifier: string };
|
||||
identifier?: string;
|
||||
object: string;
|
||||
object?: string;
|
||||
participant?: { identifier: string };
|
||||
}
|
||||
|
||||
export interface TenureClaim extends ClaimObject {
|
||||
"@context": "https://endorser.ch";
|
||||
"@type": "Tenure";
|
||||
party?: { identifier: string };
|
||||
spatialUnit?: { geo?: { polygon?: string } };
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// similar to VerifiableCredentialSubject... maybe rename this
|
||||
export interface GenericVerifiableCredential {
|
||||
"@context": string | string[];
|
||||
"@context"?: string;
|
||||
"@type": string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -37,23 +37,26 @@ export interface ErrorResult extends ResultWithType {
|
||||
|
||||
export interface KeyMeta {
|
||||
did: string;
|
||||
name?: string;
|
||||
publicKeyHex: string;
|
||||
mnemonic: string;
|
||||
derivationPath: string;
|
||||
registered?: boolean;
|
||||
profileImageUrl?: string;
|
||||
identity?: string; // Stringified IIdentifier object from Veramo
|
||||
derivationPath?: string;
|
||||
passkeyCredIdHex?: string; // The Webauthn credential ID in hex, if this is from a passkey
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface KeyMetaMaybeWithPrivate extends KeyMeta {
|
||||
mnemonic?: string; // 12 or 24 words encoding the seed
|
||||
identity?: string; // Stringified IIdentifier object from Veramo
|
||||
}
|
||||
|
||||
export interface KeyMetaWithPrivate extends KeyMeta {
|
||||
mnemonic: string; // 12 or 24 words encoding the seed
|
||||
identity: string; // Stringified IIdentifier object from Veramo
|
||||
}
|
||||
|
||||
export interface QuantitativeValue extends GenericVerifiableCredential {
|
||||
"@type": "QuantitativeValue";
|
||||
"@context": string | string[];
|
||||
"@context"?: string;
|
||||
amountOfThisGood: number;
|
||||
unitCode: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface AxiosErrorResponse {
|
||||
@@ -87,94 +90,21 @@ export interface CreateAndSubmitClaimResult {
|
||||
handleId?: string;
|
||||
}
|
||||
|
||||
export interface PlanSummaryRecord {
|
||||
handleId: string;
|
||||
issuer: string;
|
||||
claim: GenericVerifiableCredential;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface Agent {
|
||||
identifier?: string;
|
||||
did?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface ClaimObject {
|
||||
"@type": string;
|
||||
"@context"?: string | string[];
|
||||
fulfills?: Array<{
|
||||
"@type": string;
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
}>;
|
||||
object?: GenericVerifiableCredential;
|
||||
agent?: Agent;
|
||||
participant?: {
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
identifier?: string;
|
||||
"@context"?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface VerifiableCredentialClaim {
|
||||
"@context": string | string[];
|
||||
"@context"?: string;
|
||||
"@type": string;
|
||||
type: string[];
|
||||
credentialSubject: ClaimObject;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface GiveVerifiableCredential extends GenericVerifiableCredential {
|
||||
"@type": "GiveAction";
|
||||
"@context": string | string[];
|
||||
object?: GenericVerifiableCredential;
|
||||
agent?: Agent;
|
||||
participant?: {
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
fulfills?: Array<{
|
||||
"@type": string;
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
}>;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface OfferVerifiableCredential extends GenericVerifiableCredential {
|
||||
"@type": "OfferAction";
|
||||
"@context": string | string[];
|
||||
object?: GenericVerifiableCredential;
|
||||
agent?: Agent;
|
||||
participant?: {
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
itemOffered?: {
|
||||
description?: string;
|
||||
isPartOf?: {
|
||||
"@type": string;
|
||||
identifier: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface RegisterVerifiableCredential
|
||||
extends GenericVerifiableCredential {
|
||||
"@type": "RegisterAction";
|
||||
"@context": string | string[];
|
||||
agent: {
|
||||
identifier: string;
|
||||
};
|
||||
object: string;
|
||||
participant?: {
|
||||
identifier: string;
|
||||
};
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,4 @@ export interface DatabaseService {
|
||||
sql: string,
|
||||
params?: unknown[],
|
||||
): Promise<{ changes: number; lastId?: number }>;
|
||||
getOneRow(sql: string, params?: unknown[]): Promise<unknown[] | undefined>;
|
||||
getAll(sql: string, params?: unknown[]): Promise<unknown[][]>;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
/**
|
||||
* Interfaces for the give records with limited contact information, good to show on a feed.
|
||||
**/
|
||||
|
||||
import { GiveSummaryRecord } from "./records";
|
||||
|
||||
// Common interface for contact information
|
||||
// Common interface for views with summary contact information
|
||||
export interface ContactInfo {
|
||||
known: boolean;
|
||||
displayName: string;
|
||||
profileImageUrl?: string;
|
||||
}
|
||||
|
||||
// Define the contact information fields
|
||||
// Define a subset of contact information fields
|
||||
interface GiveContactInfo {
|
||||
giver: ContactInfo;
|
||||
issuer: ContactInfo;
|
||||
@@ -17,5 +21,5 @@ interface GiveContactInfo {
|
||||
image?: string;
|
||||
}
|
||||
|
||||
// Combine GiveSummaryRecord with contact information using intersection type
|
||||
// Combine GiveSummaryRecord with contact information
|
||||
export type GiveRecordWithContactInfo = GiveSummaryRecord & GiveContactInfo;
|
||||
|
||||
@@ -13,9 +13,9 @@ export type {
|
||||
|
||||
export type {
|
||||
// From claims.ts
|
||||
GiveVerifiableCredential,
|
||||
OfferVerifiableCredential,
|
||||
RegisterVerifiableCredential,
|
||||
GiveActionClaim,
|
||||
OfferClaim,
|
||||
RegisterActionClaim,
|
||||
} from "./claims";
|
||||
|
||||
export type {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { GiveVerifiableCredential, OfferVerifiableCredential } from "./claims";
|
||||
import { GiveActionClaim, OfferClaim } from "./claims";
|
||||
|
||||
// a summary record; the VC is found the fullClaim field
|
||||
export interface GiveSummaryRecord {
|
||||
[x: string]: PropertyKey | undefined | GiveVerifiableCredential;
|
||||
[x: string]: PropertyKey | undefined | GiveActionClaim;
|
||||
type?: string;
|
||||
agentDid: string;
|
||||
amount: number;
|
||||
amountConfirmed: number;
|
||||
description: string;
|
||||
fullClaim: GiveVerifiableCredential;
|
||||
fullClaim: GiveActionClaim;
|
||||
fulfillsHandleId: string;
|
||||
fulfillsPlanHandleId?: string;
|
||||
fulfillsType?: string;
|
||||
@@ -26,7 +26,7 @@ export interface OfferSummaryRecord {
|
||||
amount: number;
|
||||
amountGiven: number;
|
||||
amountGivenConfirmed: number;
|
||||
fullClaim: OfferVerifiableCredential;
|
||||
fullClaim: OfferClaim;
|
||||
fulfillsPlanHandleId: string;
|
||||
handleId: string;
|
||||
issuerDid: string;
|
||||
|
||||
@@ -32,7 +32,7 @@ export const newIdentifier = (
|
||||
publicHex: string,
|
||||
privateHex: string,
|
||||
derivationPath: string,
|
||||
): Omit<IIdentifier, keyof "provider"> => {
|
||||
): IIdentifier => {
|
||||
return {
|
||||
did: DEFAULT_DID_PROVIDER_NAME + ":" + address,
|
||||
keys: [
|
||||
|
||||
@@ -17,7 +17,7 @@ import { didEthLocalResolver } from "./did-eth-local-resolver";
|
||||
import { PEER_DID_PREFIX, verifyPeerSignature } from "./didPeer";
|
||||
import { base64urlDecodeString, createDidPeerJwt } from "./passkeyDidPeer";
|
||||
import { urlBase64ToUint8Array } from "./util";
|
||||
import { KeyMeta } from "../../../interfaces/common";
|
||||
import { KeyMeta, KeyMetaWithPrivate } from "../../../interfaces/common";
|
||||
|
||||
export const ETHR_DID_PREFIX = "did:ethr:";
|
||||
export const JWT_VERIFY_FAILED_CODE = "JWT_VERIFY_FAILED";
|
||||
@@ -34,7 +34,7 @@ export function isFromPasskey(keyMeta?: KeyMeta): boolean {
|
||||
}
|
||||
|
||||
export async function createEndorserJwtForKey(
|
||||
account: KeyMeta,
|
||||
account: KeyMetaWithPrivate,
|
||||
payload: object,
|
||||
expiresIn?: number,
|
||||
) {
|
||||
|
||||
@@ -38,7 +38,14 @@ import {
|
||||
getPasskeyExpirationSeconds,
|
||||
} from "../libs/util";
|
||||
import { createEndorserJwtForKey } from "../libs/crypto/vc";
|
||||
import { KeyMeta } from "../interfaces/common";
|
||||
import {
|
||||
GiveActionClaim,
|
||||
JoinActionClaim,
|
||||
OfferClaim,
|
||||
PlanActionClaim,
|
||||
RegisterActionClaim,
|
||||
TenureClaim,
|
||||
} from "../interfaces/claims";
|
||||
|
||||
import {
|
||||
GenericCredWrapper,
|
||||
@@ -46,15 +53,13 @@ import {
|
||||
AxiosErrorResponse,
|
||||
UserInfo,
|
||||
CreateAndSubmitClaimResult,
|
||||
PlanSummaryRecord,
|
||||
GiveVerifiableCredential,
|
||||
OfferVerifiableCredential,
|
||||
RegisterVerifiableCredential,
|
||||
ClaimObject,
|
||||
VerifiableCredentialClaim,
|
||||
Agent,
|
||||
QuantitativeValue,
|
||||
KeyMetaWithPrivate,
|
||||
KeyMetaMaybeWithPrivate,
|
||||
} from "../interfaces/common";
|
||||
import { PlanSummaryRecord } from "../interfaces/records";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
|
||||
@@ -136,7 +141,7 @@ export function isDid(did: string): boolean {
|
||||
* @param {string} did - The DID to check
|
||||
* @returns {boolean} True if DID is hidden
|
||||
*/
|
||||
export function isHiddenDid(did: string): boolean {
|
||||
export function isHiddenDid(did: string | undefined): boolean {
|
||||
return did === HIDDEN_DID;
|
||||
}
|
||||
|
||||
@@ -650,7 +655,7 @@ export async function getNewOffersToUserProjects(
|
||||
* @param lastClaimId supplied when editing a previous claim
|
||||
*/
|
||||
export function hydrateGive(
|
||||
vcClaimOrig?: GiveVerifiableCredential,
|
||||
vcClaimOrig?: GiveActionClaim,
|
||||
fromDid?: string,
|
||||
toDid?: string,
|
||||
description?: string,
|
||||
@@ -662,15 +667,12 @@ export function hydrateGive(
|
||||
imageUrl?: string,
|
||||
providerPlanHandleId?: string,
|
||||
lastClaimId?: string,
|
||||
): GiveVerifiableCredential {
|
||||
const vcClaim: GiveVerifiableCredential = vcClaimOrig
|
||||
): GiveActionClaim {
|
||||
const vcClaim: GiveActionClaim = vcClaimOrig
|
||||
? R.clone(vcClaimOrig)
|
||||
: {
|
||||
"@context": SCHEMA_ORG_CONTEXT,
|
||||
"@type": "GiveAction",
|
||||
object: undefined,
|
||||
agent: undefined,
|
||||
fulfills: [],
|
||||
};
|
||||
|
||||
if (lastClaimId) {
|
||||
@@ -688,8 +690,6 @@ export function hydrateGive(
|
||||
|
||||
if (amount && !isNaN(amount)) {
|
||||
const quantitativeValue: QuantitativeValue = {
|
||||
"@context": SCHEMA_ORG_CONTEXT,
|
||||
"@type": "QuantitativeValue",
|
||||
amountOfThisGood: amount,
|
||||
unitCode: unitCode || "HUR",
|
||||
};
|
||||
@@ -698,7 +698,7 @@ export function hydrateGive(
|
||||
|
||||
// Initialize fulfills array if not present
|
||||
if (!Array.isArray(vcClaim.fulfills)) {
|
||||
vcClaim.fulfills = [];
|
||||
vcClaim.fulfills = vcClaim.fulfills ? [vcClaim.fulfills] : [];
|
||||
}
|
||||
|
||||
// Filter and add fulfills elements
|
||||
@@ -801,7 +801,7 @@ export async function createAndSubmitGive(
|
||||
export async function editAndSubmitGive(
|
||||
axios: Axios,
|
||||
apiServer: string,
|
||||
fullClaim: GenericCredWrapper<GiveVerifiableCredential>,
|
||||
fullClaim: GenericCredWrapper<GiveActionClaim>,
|
||||
issuerDid: string,
|
||||
fromDid?: string,
|
||||
toDid?: string,
|
||||
@@ -842,7 +842,7 @@ export async function editAndSubmitGive(
|
||||
* @param lastClaimId supplied when editing a previous claim
|
||||
*/
|
||||
export function hydrateOffer(
|
||||
vcClaimOrig?: OfferVerifiableCredential,
|
||||
vcClaimOrig?: OfferClaim,
|
||||
fromDid?: string,
|
||||
toDid?: string,
|
||||
itemDescription?: string,
|
||||
@@ -852,24 +852,22 @@ export function hydrateOffer(
|
||||
fulfillsProjectHandleId?: string,
|
||||
validThrough?: string,
|
||||
lastClaimId?: string,
|
||||
): OfferVerifiableCredential {
|
||||
const vcClaim: OfferVerifiableCredential = vcClaimOrig
|
||||
): OfferClaim {
|
||||
const vcClaim: OfferClaim = vcClaimOrig
|
||||
? R.clone(vcClaimOrig)
|
||||
: {
|
||||
"@context": SCHEMA_ORG_CONTEXT,
|
||||
"@type": "OfferAction",
|
||||
object: undefined,
|
||||
agent: undefined,
|
||||
itemOffered: {},
|
||||
"@type": "Offer",
|
||||
};
|
||||
|
||||
if (lastClaimId) {
|
||||
// this is an edit
|
||||
vcClaim.lastClaimId = lastClaimId;
|
||||
delete vcClaim.identifier;
|
||||
}
|
||||
|
||||
if (fromDid) {
|
||||
vcClaim.agent = { identifier: fromDid };
|
||||
vcClaim.offeredBy = { identifier: fromDid };
|
||||
}
|
||||
if (toDid) {
|
||||
vcClaim.recipient = { identifier: toDid };
|
||||
@@ -877,13 +875,10 @@ export function hydrateOffer(
|
||||
vcClaim.description = conditionDescription || undefined;
|
||||
|
||||
if (amount && !isNaN(amount)) {
|
||||
const quantitativeValue: QuantitativeValue = {
|
||||
"@context": SCHEMA_ORG_CONTEXT,
|
||||
"@type": "QuantitativeValue",
|
||||
vcClaim.includesObject = {
|
||||
amountOfThisGood: amount,
|
||||
unitCode: unitCode || "HUR",
|
||||
};
|
||||
vcClaim.object = quantitativeValue;
|
||||
}
|
||||
|
||||
if (itemDescription || fulfillsProjectHandleId) {
|
||||
@@ -936,7 +931,7 @@ export async function createAndSubmitOffer(
|
||||
undefined,
|
||||
);
|
||||
return createAndSubmitClaim(
|
||||
vcClaim as OfferVerifiableCredential,
|
||||
vcClaim as OfferClaim,
|
||||
issuerDid,
|
||||
apiServer,
|
||||
axios,
|
||||
@@ -946,7 +941,7 @@ export async function createAndSubmitOffer(
|
||||
export async function editAndSubmitOffer(
|
||||
axios: Axios,
|
||||
apiServer: string,
|
||||
fullClaim: GenericCredWrapper<OfferVerifiableCredential>,
|
||||
fullClaim: GenericCredWrapper<OfferClaim>,
|
||||
issuerDid: string,
|
||||
itemDescription: string,
|
||||
amount?: number,
|
||||
@@ -969,7 +964,7 @@ export async function editAndSubmitOffer(
|
||||
fullClaim.id,
|
||||
);
|
||||
return createAndSubmitClaim(
|
||||
vcClaim as OfferVerifiableCredential,
|
||||
vcClaim as OfferClaim,
|
||||
issuerDid,
|
||||
apiServer,
|
||||
axios,
|
||||
@@ -1043,7 +1038,7 @@ export async function createAndSubmitClaim(
|
||||
}
|
||||
|
||||
export async function generateEndorserJwtUrlForAccount(
|
||||
account: KeyMeta,
|
||||
account: KeyMetaMaybeWithPrivate,
|
||||
isRegistered: boolean,
|
||||
givenName: string,
|
||||
profileImageUrl: string,
|
||||
@@ -1067,7 +1062,7 @@ export async function generateEndorserJwtUrlForAccount(
|
||||
}
|
||||
|
||||
// Add the next key -- not recommended for the QR code for such a high resolution
|
||||
if (isContact) {
|
||||
if (isContact && account.derivationPath && account.mnemonic) {
|
||||
const newDerivPath = nextDerivationPath(account.derivationPath);
|
||||
const nextPublicHex = deriveAddress(account.mnemonic, newDerivPath)[2];
|
||||
const nextPublicEncKey = Buffer.from(nextPublicHex, "hex");
|
||||
@@ -1089,7 +1084,11 @@ export async function createEndorserJwtForDid(
|
||||
expiresIn?: number,
|
||||
) {
|
||||
const account = await retrieveFullyDecryptedAccount(issuerDid);
|
||||
return createEndorserJwtForKey(account as KeyMeta, payload, expiresIn);
|
||||
return createEndorserJwtForKey(
|
||||
account as KeyMetaWithPrivate,
|
||||
payload,
|
||||
expiresIn,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1186,102 +1185,118 @@ export const claimSpecialDescription = (
|
||||
identifiers: Array<string>,
|
||||
contacts: Array<Contact>,
|
||||
) => {
|
||||
let claim = record.claim;
|
||||
let claim:
|
||||
| GenericVerifiableCredential
|
||||
| GenericCredWrapper<GenericVerifiableCredential> = record.claim;
|
||||
if ("claim" in claim) {
|
||||
// it's a nested GenericCredWrapper
|
||||
claim = claim.claim as GenericVerifiableCredential;
|
||||
}
|
||||
|
||||
const issuer = didInfo(record.issuer, activeDid, identifiers, contacts);
|
||||
const claimObj = claim as ClaimObject;
|
||||
const type = claimObj["@type"] || "UnknownType";
|
||||
const type = claim["@type"] || "UnknownType";
|
||||
|
||||
if (type === "AgreeAction") {
|
||||
return (
|
||||
issuer +
|
||||
" agreed with " +
|
||||
claimSummary(claimObj.object as GenericVerifiableCredential)
|
||||
claimSummary(claim.object as GenericVerifiableCredential)
|
||||
);
|
||||
} else if (isAccept(claim)) {
|
||||
return (
|
||||
issuer +
|
||||
" accepted " +
|
||||
claimSummary(claimObj.object as GenericVerifiableCredential)
|
||||
claimSummary(claim.object as GenericVerifiableCredential)
|
||||
);
|
||||
} else if (type === "GiveAction") {
|
||||
const giveClaim = claim as GiveVerifiableCredential;
|
||||
const agent: Agent = giveClaim.agent || {
|
||||
identifier: undefined,
|
||||
did: undefined,
|
||||
};
|
||||
const agentDid = agent.did || agent.identifier;
|
||||
const contactInfo = agentDid
|
||||
? didInfo(agentDid, activeDid, identifiers, contacts)
|
||||
: "someone";
|
||||
const offering = giveClaim.object
|
||||
? " " + claimSummary(giveClaim.object)
|
||||
const giveClaim = claim as GiveActionClaim;
|
||||
// @ts-expect-error because .did may be found in legacy data, before March 2023
|
||||
const legacyGiverDid = giveClaim.agent?.did;
|
||||
const giver = giveClaim.agent?.identifier || legacyGiverDid;
|
||||
const giverInfo = didInfo(giver, activeDid, identifiers, contacts);
|
||||
let gaveAmount = giveClaim.object?.amountOfThisGood
|
||||
? displayAmount(
|
||||
giveClaim.object.unitCode as string,
|
||||
giveClaim.object.amountOfThisGood as number,
|
||||
)
|
||||
: "";
|
||||
const recipient = giveClaim.participant?.identifier;
|
||||
const recipientInfo = recipient
|
||||
? " to " + didInfo(recipient, activeDid, identifiers, contacts)
|
||||
if (giveClaim.description) {
|
||||
if (gaveAmount) {
|
||||
gaveAmount = gaveAmount + ", and also: ";
|
||||
}
|
||||
gaveAmount = gaveAmount + giveClaim.description;
|
||||
}
|
||||
if (!gaveAmount) {
|
||||
gaveAmount = "something not described";
|
||||
}
|
||||
// @ts-expect-error because .did may be found in legacy data, before March 2023
|
||||
const legacyRecipDid = giveClaim.recipient?.did;
|
||||
const gaveRecipientId = giveClaim.recipient?.identifier || legacyRecipDid;
|
||||
const gaveRecipientInfo = gaveRecipientId
|
||||
? " to " + didInfo(gaveRecipientId, activeDid, identifiers, contacts)
|
||||
: "";
|
||||
return contactInfo + " gave" + offering + recipientInfo;
|
||||
return giverInfo + " gave" + gaveRecipientInfo + ": " + gaveAmount;
|
||||
} else if (type === "JoinAction") {
|
||||
const joinClaim = claim as ClaimObject;
|
||||
const agent: Agent = joinClaim.agent || {
|
||||
identifier: undefined,
|
||||
did: undefined,
|
||||
};
|
||||
const agentDid = agent.did || agent.identifier;
|
||||
const contactInfo = agentDid
|
||||
? didInfo(agentDid, activeDid, identifiers, contacts)
|
||||
: "someone";
|
||||
const object = joinClaim.object as GenericVerifiableCredential;
|
||||
const objectInfo = object ? " " + claimSummary(object) : "";
|
||||
return contactInfo + " joined" + objectInfo;
|
||||
const joinClaim = claim as JoinActionClaim;
|
||||
// @ts-expect-error because .did may be found in legacy data, before March 2023
|
||||
const legacyDid = joinClaim.agent?.did;
|
||||
const agent = joinClaim.agent?.identifier || legacyDid;
|
||||
const contactInfo = didInfo(agent, activeDid, identifiers, contacts);
|
||||
|
||||
let eventOrganizer =
|
||||
joinClaim.event &&
|
||||
joinClaim.event.organizer &&
|
||||
joinClaim.event.organizer.name;
|
||||
eventOrganizer = eventOrganizer || "";
|
||||
let eventName = joinClaim.event && joinClaim.event.name;
|
||||
eventName = eventName ? " " + eventName : "";
|
||||
let fullEvent = eventOrganizer + eventName;
|
||||
fullEvent = fullEvent ? " attended the " + fullEvent : "";
|
||||
|
||||
let eventDate = joinClaim.event && joinClaim.event.startTime;
|
||||
eventDate = eventDate ? " at " + eventDate : "";
|
||||
return contactInfo + fullEvent + eventDate;
|
||||
} else if (isOffer(claim)) {
|
||||
const offerClaim = claim as OfferVerifiableCredential;
|
||||
const agent: Agent = offerClaim.agent || {
|
||||
identifier: undefined,
|
||||
did: undefined,
|
||||
};
|
||||
const agentDid = agent.did || agent.identifier;
|
||||
const contactInfo = agentDid
|
||||
? didInfo(agentDid, activeDid, identifiers, contacts)
|
||||
: "someone";
|
||||
const offering = offerClaim.object
|
||||
? " " + claimSummary(offerClaim.object)
|
||||
: "";
|
||||
const offerRecipientId = offerClaim.participant?.identifier;
|
||||
const offerClaim = claim as OfferClaim;
|
||||
const offerer = offerClaim.offeredBy?.identifier;
|
||||
const contactInfo = didInfo(offerer, activeDid, identifiers, contacts);
|
||||
let offering = "";
|
||||
if (offerClaim.includesObject) {
|
||||
offering +=
|
||||
" " +
|
||||
displayAmount(
|
||||
offerClaim.includesObject.unitCode,
|
||||
offerClaim.includesObject.amountOfThisGood,
|
||||
);
|
||||
}
|
||||
if (offerClaim.itemOffered?.description) {
|
||||
offering += ", saying: " + offerClaim.itemOffered?.description;
|
||||
}
|
||||
// @ts-expect-error because .did may be found in legacy data, before March 2023
|
||||
const legacyDid = offerClaim.recipient?.did;
|
||||
const offerRecipientId = offerClaim.recipient?.identifier || legacyDid;
|
||||
const offerRecipientInfo = offerRecipientId
|
||||
? " to " + didInfo(offerRecipientId, activeDid, identifiers, contacts)
|
||||
: "";
|
||||
return contactInfo + " offered" + offering + offerRecipientInfo;
|
||||
} else if (type === "PlanAction") {
|
||||
const planClaim = claim as ClaimObject;
|
||||
const agent: Agent = planClaim.agent || {
|
||||
identifier: undefined,
|
||||
did: undefined,
|
||||
};
|
||||
const agentDid = agent.did || agent.identifier;
|
||||
const contactInfo = agentDid
|
||||
? didInfo(agentDid, activeDid, identifiers, contacts)
|
||||
: "someone";
|
||||
const object = planClaim.object as GenericVerifiableCredential;
|
||||
const objectInfo = object ? " " + claimSummary(object) : "";
|
||||
return contactInfo + " planned" + objectInfo;
|
||||
const planClaim = claim as PlanActionClaim;
|
||||
const claimer = planClaim.agent?.identifier || record.issuer;
|
||||
const claimerInfo = didInfo(claimer, activeDid, identifiers, contacts);
|
||||
return claimerInfo + " announced a project: " + planClaim.name;
|
||||
} else if (type === "Tenure") {
|
||||
const tenureClaim = claim as ClaimObject;
|
||||
const agent: Agent = tenureClaim.agent || {
|
||||
identifier: undefined,
|
||||
did: undefined,
|
||||
};
|
||||
const agentDid = agent.did || agent.identifier;
|
||||
const contactInfo = agentDid
|
||||
? didInfo(agentDid, activeDid, identifiers, contacts)
|
||||
: "someone";
|
||||
const object = tenureClaim.object as GenericVerifiableCredential;
|
||||
const objectInfo = object ? " " + claimSummary(object) : "";
|
||||
return contactInfo + " has tenure" + objectInfo;
|
||||
const tenureClaim = claim as TenureClaim;
|
||||
// @ts-expect-error because .did may be found in legacy data, before March 2023
|
||||
const legacyDid = tenureClaim.party?.did;
|
||||
const claimer = tenureClaim.party?.identifier || legacyDid;
|
||||
const contactInfo = didInfo(claimer, activeDid, identifiers, contacts);
|
||||
const polygon = tenureClaim.spatialUnit?.geo?.polygon || "";
|
||||
return (
|
||||
contactInfo +
|
||||
" possesses [" +
|
||||
polygon.substring(0, polygon.indexOf(" ")) +
|
||||
"...]"
|
||||
);
|
||||
} else {
|
||||
return issuer + " declared " + claimSummary(claim);
|
||||
}
|
||||
@@ -1323,17 +1338,29 @@ export async function createEndorserJwtVcFromClaim(
|
||||
return createEndorserJwtForDid(issuerDid, vcPayload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JWT for a RegisterAction claim.
|
||||
*
|
||||
* @param activeDid - The DID of the user creating the invite
|
||||
* @param contact - The contact to register, with a 'did' field (all optional for invites)
|
||||
* @param identifier - The identifier for the invite, usually random
|
||||
* @param expiresIn - The number of seconds until the invite expires
|
||||
* @returns The JWT for the RegisterAction claim
|
||||
*/
|
||||
export async function createInviteJwt(
|
||||
activeDid: string,
|
||||
contact: Contact,
|
||||
contact?: Contact,
|
||||
identifier?: string,
|
||||
expiresIn?: number, // in seconds
|
||||
): Promise<string> {
|
||||
const vcClaim: RegisterVerifiableCredential = {
|
||||
const vcClaim: RegisterActionClaim = {
|
||||
"@context": SCHEMA_ORG_CONTEXT,
|
||||
"@type": "RegisterAction",
|
||||
agent: { identifier: activeDid },
|
||||
object: SERVICE_ID,
|
||||
identifier: identifier,
|
||||
};
|
||||
if (contact) {
|
||||
if (contact?.did) {
|
||||
vcClaim.participant = { identifier: contact.did };
|
||||
}
|
||||
|
||||
@@ -1348,7 +1375,7 @@ export async function createInviteJwt(
|
||||
};
|
||||
|
||||
// Create a signature using private key of identity
|
||||
const vcJwt = await createEndorserJwtForDid(activeDid, vcPayload);
|
||||
const vcJwt = await createEndorserJwtForDid(activeDid, vcPayload, expiresIn);
|
||||
return vcJwt;
|
||||
}
|
||||
|
||||
|
||||
270
src/libs/util.ts
@@ -34,14 +34,16 @@ import { containsHiddenDid } from "../libs/endorserServer";
|
||||
import {
|
||||
GenericCredWrapper,
|
||||
GenericVerifiableCredential,
|
||||
KeyMetaWithPrivate,
|
||||
} from "../interfaces/common";
|
||||
import { GiveSummaryRecord } from "../interfaces/records";
|
||||
import { OfferVerifiableCredential } from "../interfaces/claims";
|
||||
import { KeyMeta } from "../interfaces/common";
|
||||
import { OfferClaim } from "../interfaces/claims";
|
||||
import { createPeerDid } from "../libs/crypto/vc/didPeer";
|
||||
import { registerCredential } from "../libs/crypto/vc/passkeyDidPeer";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { sha256 } from "ethereum-cryptography/sha256";
|
||||
import { IIdentifier } from "@veramo/core";
|
||||
|
||||
export interface GiverReceiverInputInfo {
|
||||
did?: string;
|
||||
@@ -80,18 +82,24 @@ export const UNIT_LONG: Record<string, string> = {
|
||||
};
|
||||
/* eslint-enable prettier/prettier */
|
||||
|
||||
const UNIT_CODES: Record<string, Record<string, string>> = {
|
||||
const UNIT_CODES: Record<
|
||||
string,
|
||||
{ name: string; faIcon: string; decimals: number }
|
||||
> = {
|
||||
BTC: {
|
||||
name: "Bitcoin",
|
||||
faIcon: "bitcoin-sign",
|
||||
decimals: 4,
|
||||
},
|
||||
HUR: {
|
||||
name: "hours",
|
||||
faIcon: "clock",
|
||||
decimals: 0,
|
||||
},
|
||||
USD: {
|
||||
name: "US Dollars",
|
||||
faIcon: "dollar",
|
||||
decimals: 2,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -99,6 +107,13 @@ export function iconForUnitCode(unitCode: string) {
|
||||
return UNIT_CODES[unitCode]?.faIcon || "question";
|
||||
}
|
||||
|
||||
export function formattedAmount(amount: number, unitCode: string) {
|
||||
const unit = UNIT_CODES[unitCode];
|
||||
const amountStr = amount.toFixed(unit?.decimals ?? 4);
|
||||
const unitName = unit?.name || "?";
|
||||
return amountStr + " " + unitName;
|
||||
}
|
||||
|
||||
// from https://stackoverflow.com/a/175787/845494
|
||||
// ... though it appears even this isn't precisely right so keep doing "|| 0" or something in sensitive places
|
||||
//
|
||||
@@ -378,17 +393,19 @@ export function base64ToBlob(base64DataUrl: string, sliceSize = 512) {
|
||||
* @param veriClaim is expected to have fields: claim and issuer
|
||||
*/
|
||||
export function offerGiverDid(
|
||||
veriClaim: GenericCredWrapper<GenericVerifiableCredential>,
|
||||
veriClaim: GenericCredWrapper<OfferClaim>,
|
||||
): string | undefined {
|
||||
let giver;
|
||||
const claim = veriClaim.claim as OfferVerifiableCredential;
|
||||
if (
|
||||
claim.credentialSubject.offeredBy?.identifier &&
|
||||
!serverUtil.isHiddenDid(claim.credentialSubject.offeredBy.identifier)
|
||||
) {
|
||||
giver = claim.credentialSubject.offeredBy.identifier;
|
||||
} else if (veriClaim.issuer && !serverUtil.isHiddenDid(veriClaim.issuer)) {
|
||||
giver = veriClaim.issuer;
|
||||
const innerClaim = veriClaim.claim as OfferClaim;
|
||||
let giver: string | undefined = undefined;
|
||||
|
||||
giver = innerClaim.offeredBy?.identifier;
|
||||
if (giver && !serverUtil.isHiddenDid(giver)) {
|
||||
return giver;
|
||||
}
|
||||
|
||||
giver = veriClaim.issuer;
|
||||
if (giver && !serverUtil.isHiddenDid(giver)) {
|
||||
return giver;
|
||||
}
|
||||
return giver;
|
||||
}
|
||||
@@ -399,8 +416,13 @@ export function offerGiverDid(
|
||||
*/
|
||||
export const canFulfillOffer = (
|
||||
veriClaim: GenericCredWrapper<GenericVerifiableCredential>,
|
||||
isRegistered: boolean,
|
||||
) => {
|
||||
return veriClaim.claimType === "Offer" && !!offerGiverDid(veriClaim);
|
||||
return (
|
||||
isRegistered &&
|
||||
veriClaim.claimType === "Offer" &&
|
||||
!!offerGiverDid(veriClaim as GenericCredWrapper<OfferClaim>)
|
||||
);
|
||||
};
|
||||
|
||||
// return object with paths and arrays of DIDs for any keys ending in "VisibleToDid"
|
||||
@@ -469,11 +491,7 @@ export function findAllVisibleToDids(
|
||||
*
|
||||
**/
|
||||
|
||||
export interface AccountKeyInfo
|
||||
extends Omit<Account, "derivationPath">,
|
||||
Omit<KeyMeta, "derivationPath"> {
|
||||
derivationPath?: string; // Make it optional to match Account type
|
||||
}
|
||||
export type AccountKeyInfo = Account & KeyMetaWithPrivate;
|
||||
|
||||
export const retrieveAccountCount = async (): Promise<number> => {
|
||||
let result = 0;
|
||||
@@ -510,12 +528,16 @@ export const retrieveAccountDids = async (): Promise<string[]> => {
|
||||
return allDids;
|
||||
};
|
||||
|
||||
// This is provided and recommended when the full key is not necessary so that
|
||||
// future work could separate this info from the sensitive key material.
|
||||
/**
|
||||
* This is provided and recommended when the full key is not necessary so that
|
||||
* future work could separate this info from the sensitive key material.
|
||||
*
|
||||
* If you need the private key data, use retrieveFullyDecryptedAccount instead.
|
||||
*/
|
||||
export const retrieveAccountMetadata = async (
|
||||
activeDid: string,
|
||||
): Promise<AccountKeyInfo | undefined> => {
|
||||
let result: AccountKeyInfo | undefined = undefined;
|
||||
): Promise<Account | undefined> => {
|
||||
let result: Account | undefined = undefined;
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const dbAccount = await platformService.dbQuery(
|
||||
`SELECT * FROM accounts WHERE did = ?`,
|
||||
@@ -547,32 +569,16 @@ export const retrieveAccountMetadata = async (
|
||||
return result;
|
||||
};
|
||||
|
||||
export const retrieveAllAccountsMetadata = async (): Promise<Account[]> => {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const dbAccounts = await platformService.dbQuery(`SELECT * FROM accounts`);
|
||||
const accounts = databaseUtil.mapQueryResultToValues(dbAccounts) as Account[];
|
||||
let result = accounts.map((account) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { identity, mnemonic, ...metadata } = account;
|
||||
return metadata as Account;
|
||||
});
|
||||
if (USE_DEXIE_DB) {
|
||||
// one of the few times we use accountsDBPromise directly; try to avoid more usage
|
||||
const accountsDB = await accountsDBPromise;
|
||||
const array = await accountsDB.accounts.toArray();
|
||||
result = array.map((account) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { identity, mnemonic, ...metadata } = account;
|
||||
return metadata as Account;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* This contains sensitive data. If possible, use retrieveAccountMetadata instead.
|
||||
*
|
||||
* @param activeDid
|
||||
* @returns account info with private key data decrypted
|
||||
*/
|
||||
export const retrieveFullyDecryptedAccount = async (
|
||||
activeDid: string,
|
||||
): Promise<AccountKeyInfo | undefined> => {
|
||||
let result: AccountKeyInfo | undefined = undefined;
|
||||
): Promise<Account | undefined> => {
|
||||
let result: Account | undefined = undefined;
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const dbSecrets = await platformService.dbQuery(
|
||||
`SELECT secretBase64 from secret`,
|
||||
@@ -620,29 +626,45 @@ export const retrieveFullyDecryptedAccount = async (
|
||||
return result;
|
||||
};
|
||||
|
||||
// let's try and eliminate this
|
||||
export const retrieveAllFullyDecryptedAccounts = async (): Promise<
|
||||
Array<AccountEncrypted>
|
||||
export const retrieveAllAccountsMetadata = async (): Promise<
|
||||
AccountEncrypted[]
|
||||
> => {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const queryResult = await platformService.dbQuery("SELECT * FROM accounts");
|
||||
let allAccounts = databaseUtil.mapQueryResultToValues(
|
||||
queryResult,
|
||||
) as unknown as AccountEncrypted[];
|
||||
const dbAccounts = await platformService.dbQuery(`SELECT * FROM accounts`);
|
||||
const accounts = databaseUtil.mapQueryResultToValues(dbAccounts) as Account[];
|
||||
let result = accounts.map((account) => {
|
||||
return account as AccountEncrypted;
|
||||
});
|
||||
if (USE_DEXIE_DB) {
|
||||
// one of the few times we use accountsDBPromise directly; try to avoid more usage
|
||||
const accountsDB = await accountsDBPromise;
|
||||
allAccounts = (await accountsDB.accounts.toArray()) as AccountEncrypted[];
|
||||
const array = await accountsDB.accounts.toArray();
|
||||
result = array.map((account) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { identity, mnemonic, ...metadata } = account;
|
||||
// This is not accurate because they can't be decrypted, but we're removing Dexie anyway.
|
||||
const identityStr = JSON.stringify(identity);
|
||||
const encryptedAccount = {
|
||||
identityEncrBase64: sha256(
|
||||
new TextEncoder().encode(identityStr),
|
||||
).toString(),
|
||||
mnemonicEncrBase64: sha256(
|
||||
new TextEncoder().encode(account.mnemonic),
|
||||
).toString(),
|
||||
...metadata,
|
||||
};
|
||||
return encryptedAccount as AccountEncrypted;
|
||||
});
|
||||
}
|
||||
return allAccounts;
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Saves a new identity to both SQL and Dexie databases
|
||||
*/
|
||||
export async function saveNewIdentity(
|
||||
identity: string,
|
||||
identity: IIdentifier,
|
||||
mnemonic: string,
|
||||
newId: { did: string; keys: Array<{ publicKeyHex: string }> },
|
||||
derivationPath: string,
|
||||
): Promise<void> {
|
||||
try {
|
||||
@@ -658,23 +680,23 @@ export async function saveNewIdentity(
|
||||
}
|
||||
const secretBase64 = secrets.values[0][0] as string;
|
||||
const secret = base64ToArrayBuffer(secretBase64);
|
||||
const encryptedIdentity = await simpleEncrypt(identity, secret);
|
||||
const identityStr = JSON.stringify(identity);
|
||||
const encryptedIdentity = await simpleEncrypt(identityStr, secret);
|
||||
const encryptedMnemonic = await simpleEncrypt(mnemonic, secret);
|
||||
const encryptedIdentityBase64 = arrayBufferToBase64(encryptedIdentity);
|
||||
const encryptedMnemonicBase64 = arrayBufferToBase64(encryptedMnemonic);
|
||||
await platformService.dbExec(
|
||||
`INSERT INTO accounts (dateCreated, derivationPath, did, identityEncrBase64, mnemonicEncrBase64, publicKeyHex)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`,
|
||||
[
|
||||
new Date().toISOString(),
|
||||
derivationPath,
|
||||
newId.did,
|
||||
encryptedIdentityBase64,
|
||||
encryptedMnemonicBase64,
|
||||
newId.keys[0].publicKeyHex,
|
||||
],
|
||||
);
|
||||
await databaseUtil.updateDefaultSettings({ activeDid: newId.did });
|
||||
const sql = `INSERT INTO accounts (dateCreated, derivationPath, did, identityEncrBase64, mnemonicEncrBase64, publicKeyHex)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`;
|
||||
const params = [
|
||||
new Date().toISOString(),
|
||||
derivationPath,
|
||||
identity.did,
|
||||
encryptedIdentityBase64,
|
||||
encryptedMnemonicBase64,
|
||||
identity.keys[0].publicKeyHex,
|
||||
];
|
||||
await platformService.dbExec(sql, params);
|
||||
await databaseUtil.updateDefaultSettings({ activeDid: identity.did });
|
||||
|
||||
if (USE_DEXIE_DB) {
|
||||
// one of the few times we use accountsDBPromise directly; try to avoid more usage
|
||||
@@ -682,12 +704,12 @@ export async function saveNewIdentity(
|
||||
await accountsDB.accounts.add({
|
||||
dateCreated: new Date().toISOString(),
|
||||
derivationPath: derivationPath,
|
||||
did: newId.did,
|
||||
identity: identity,
|
||||
did: identity.did,
|
||||
identity: identityStr,
|
||||
mnemonic: mnemonic,
|
||||
publicKeyHex: newId.keys[0].publicKeyHex,
|
||||
publicKeyHex: identity.keys[0].publicKeyHex,
|
||||
});
|
||||
await updateDefaultSettings({ activeDid: newId.did });
|
||||
await updateDefaultSettings({ activeDid: identity.did });
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error("Failed to update default settings:", error);
|
||||
@@ -708,9 +730,8 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
|
||||
deriveAddress(mnemonic);
|
||||
|
||||
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
||||
const identity = JSON.stringify(newId);
|
||||
|
||||
await saveNewIdentity(identity, mnemonic, newId, derivationPath);
|
||||
await saveNewIdentity(newId, mnemonic, derivationPath);
|
||||
await databaseUtil.updateAccountSettings(newId.did, { isRegistered: false });
|
||||
if (USE_DEXIE_DB) {
|
||||
await updateAccountSettings(newId.did, { isRegistered: false });
|
||||
@@ -814,3 +835,96 @@ export const sendTestThroughPushServer = async (
|
||||
logger.log("Got response from web push server:", response);
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Contact object to a CSV line string following the established format.
|
||||
* The format matches CONTACT_CSV_HEADER: "name,did,pubKeyBase64,seesMe,registered,contactMethods"
|
||||
* where contactMethods is stored as a stringified JSON array.
|
||||
*
|
||||
* @param contact - The Contact object to convert
|
||||
* @returns A CSV-formatted string representing the contact
|
||||
* @throws {Error} If the contact object is missing required fields
|
||||
*/
|
||||
export const contactToCsvLine = (contact: Contact): string => {
|
||||
if (!contact.did) {
|
||||
throw new Error("Contact must have a did field");
|
||||
}
|
||||
|
||||
// Escape fields that might contain commas or quotes
|
||||
const escapeField = (field: string | boolean | undefined): string => {
|
||||
if (field === undefined) return "";
|
||||
const str = String(field);
|
||||
if (str.includes(",") || str.includes('"')) {
|
||||
return `"${str.replace(/"/g, '""')}"`;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
// Handle contactMethods array by stringifying it
|
||||
const contactMethodsStr = contact.contactMethods
|
||||
? escapeField(JSON.stringify(contact.contactMethods))
|
||||
: "";
|
||||
|
||||
const fields = [
|
||||
escapeField(contact.name),
|
||||
escapeField(contact.did),
|
||||
escapeField(contact.publicKeyBase64),
|
||||
escapeField(contact.seesMe),
|
||||
escapeField(contact.registered),
|
||||
contactMethodsStr,
|
||||
];
|
||||
|
||||
return fields.join(",");
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for the JSON export format of database tables
|
||||
*/
|
||||
export interface TableExportData {
|
||||
tableName: string;
|
||||
rows: Array<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for the complete database export format
|
||||
*/
|
||||
export interface DatabaseExport {
|
||||
data: {
|
||||
data: Array<TableExportData>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) => ({
|
||||
did: contact.did,
|
||||
name: contact.name || null,
|
||||
contactMethods: contact.contactMethods
|
||||
? JSON.stringify(contact.contactMethods)
|
||||
: null,
|
||||
nextPubKeyHashB64: contact.nextPubKeyHashB64 || null,
|
||||
notes: contact.notes || null,
|
||||
profileImageUrl: contact.profileImageUrl || null,
|
||||
publicKeyBase64: contact.publicKeyBase64 || null,
|
||||
seesMe: contact.seesMe || false,
|
||||
registered: contact.registered || false,
|
||||
}));
|
||||
|
||||
return {
|
||||
data: {
|
||||
data: [
|
||||
{
|
||||
tableName: "contacts",
|
||||
rows,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@ import { logger } from "./utils/logger";
|
||||
const platform = process.env.VITE_PLATFORM;
|
||||
const pwa_enabled = process.env.VITE_PWA_ENABLED === "true";
|
||||
|
||||
logger.error("Platform", { platform });
|
||||
logger.error("PWA enabled", { pwa_enabled });
|
||||
logger.log("Platform", JSON.stringify({ platform }));
|
||||
logger.log("PWA enabled", JSON.stringify({ pwa_enabled }));
|
||||
|
||||
// Global Error Handler
|
||||
function setupGlobalErrorHandler(app: VueApp) {
|
||||
|
||||
@@ -5,8 +5,8 @@ import { logger } from "./utils/logger";
|
||||
const platform = process.env.VITE_PLATFORM;
|
||||
const pwa_enabled = process.env.VITE_PWA_ENABLED === "true";
|
||||
|
||||
logger.error("[Web] PWA enabled", { pwa_enabled });
|
||||
logger.error("[Web] Platform", { platform });
|
||||
logger.info("[Web] PWA enabled", { pwa_enabled });
|
||||
logger.info("[Web] Platform", { platform });
|
||||
|
||||
// Only import service worker for web builds
|
||||
if (platform !== "electron" && pwa_enabled) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { DatabaseService, QueryExecResult } from "../interfaces/database";
|
||||
import { logger } from "@/utils/logger";
|
||||
|
||||
interface QueuedOperation {
|
||||
type: "run" | "query" | "getOneRow" | "getAll";
|
||||
type: "run" | "query";
|
||||
sql: string;
|
||||
params: unknown[];
|
||||
resolve: (value: unknown) => void;
|
||||
@@ -84,7 +84,7 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
||||
SQL.FS.mkdir("/sql");
|
||||
SQL.FS.mount(sqlFS, {}, "/sql");
|
||||
|
||||
const path = "/sql/timesafari.sqlite";
|
||||
const path = "/sql/timesafari.absurd-sql";
|
||||
if (typeof SharedArrayBuffer === "undefined") {
|
||||
const stream = SQL.FS.open(path, "a+");
|
||||
await stream.node.contents.readIfFallback();
|
||||
@@ -100,10 +100,20 @@ 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;`);
|
||||
const sqlExec = this.db.exec.bind(this.db);
|
||||
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
|
||||
const extractMigrationNames: (result: QueryExecResult[]) => Set<string> = (
|
||||
result,
|
||||
) => {
|
||||
// Even with the "select name" query, the QueryExecResult may be [] (which doesn't make sense to me).
|
||||
const names = result?.[0]?.values.map((row) => row[0] as string) || [];
|
||||
return new Set(names);
|
||||
};
|
||||
|
||||
// Run migrations
|
||||
await runMigrations(sqlExec);
|
||||
await runMigrations(sqlExec, sqlQuery, extractMigrationNames);
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
@@ -123,7 +133,6 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
||||
if (!operation) continue;
|
||||
|
||||
try {
|
||||
let queryResult: QueryExecResult[] = [];
|
||||
let result: unknown;
|
||||
switch (operation.type) {
|
||||
case "run":
|
||||
@@ -132,14 +141,6 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
||||
case "query":
|
||||
result = await this.db.exec(operation.sql, operation.params);
|
||||
break;
|
||||
case "getOneRow":
|
||||
queryResult = await this.db.exec(operation.sql, operation.params);
|
||||
result = queryResult[0]?.values[0];
|
||||
break;
|
||||
case "getAll":
|
||||
queryResult = await this.db.exec(operation.sql, operation.params);
|
||||
result = queryResult[0]?.values || [];
|
||||
break;
|
||||
}
|
||||
operation.resolve(result);
|
||||
} catch (error) {
|
||||
@@ -222,19 +223,6 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
||||
await this.waitForInitialization();
|
||||
return this.queueOperation<QueryExecResult[]>("query", sql, params);
|
||||
}
|
||||
|
||||
async getOneRow(
|
||||
sql: string,
|
||||
params: unknown[] = [],
|
||||
): Promise<unknown[] | undefined> {
|
||||
await this.waitForInitialization();
|
||||
return this.queueOperation<unknown[] | undefined>("getOneRow", sql, params);
|
||||
}
|
||||
|
||||
async getAll(sql: string, params: unknown[] = []): Promise<unknown[][]> {
|
||||
await this.waitForInitialization();
|
||||
return this.queueOperation<unknown[][]>("getAll", sql, params);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a singleton instance
|
||||
|
||||
@@ -28,6 +28,8 @@ export interface PlatformCapabilities {
|
||||
hasFileDownload: boolean;
|
||||
/** Whether the platform requires special file handling instructions */
|
||||
needsFileHandlingInstructions: boolean;
|
||||
/** Whether the platform is a native app (Capacitor, Electron, etc.) */
|
||||
isNativeApp: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +96,12 @@ export interface PlatformService {
|
||||
*/
|
||||
pickImage(): Promise<ImageResult>;
|
||||
|
||||
/**
|
||||
* Rotates the camera between front and back cameras.
|
||||
* @returns Promise that resolves when the camera is rotated
|
||||
*/
|
||||
rotateCamera(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Handles deep link URLs for the application.
|
||||
* @param url - The deep link URL to handle
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { logger } from "@/utils/logger";
|
||||
import { QueryExecResult } from "../interfaces/database";
|
||||
|
||||
interface Migration {
|
||||
name: string;
|
||||
sql: string;
|
||||
@@ -19,15 +16,20 @@ export class MigrationService {
|
||||
return MigrationService.instance;
|
||||
}
|
||||
|
||||
async registerMigration(migration: Migration): Promise<void> {
|
||||
registerMigration(migration: Migration) {
|
||||
this.migrations.push(migration);
|
||||
}
|
||||
|
||||
async runMigrations(
|
||||
sqlExec: (
|
||||
sql: string,
|
||||
params?: unknown[],
|
||||
) => Promise<Array<QueryExecResult>>,
|
||||
/**
|
||||
* @param sqlExec - A function that executes a SQL statement and returns some update result
|
||||
* @param sqlQuery - A function that executes a SQL query and returns the result in some format
|
||||
* @param extractMigrationNames - A function that extracts the names (string array) from a "select name from migrations" query
|
||||
*/
|
||||
async runMigrations<T>(
|
||||
// note that this does not take parameters because the Capacitor SQLite 'execute' is different
|
||||
sqlExec: (sql: string) => Promise<unknown>,
|
||||
sqlQuery: (sql: string) => Promise<T>,
|
||||
extractMigrationNames: (result: T) => Set<string>,
|
||||
): Promise<void> {
|
||||
// Create migrations table if it doesn't exist
|
||||
await sqlExec(`
|
||||
@@ -39,26 +41,17 @@ export class MigrationService {
|
||||
`);
|
||||
|
||||
// Get list of executed migrations
|
||||
const result: QueryExecResult[] = await sqlExec(
|
||||
"SELECT name FROM migrations;",
|
||||
);
|
||||
let executedMigrations: Set<unknown> = new Set();
|
||||
// Even with that query, the QueryExecResult may be [] (which doesn't make sense to me).
|
||||
if (result.length > 0) {
|
||||
const singleResult = result[0];
|
||||
executedMigrations = new Set(
|
||||
singleResult.values.map((row: unknown[]) => row[0]),
|
||||
);
|
||||
}
|
||||
const result1: T = await sqlQuery("SELECT name FROM migrations;");
|
||||
const executedMigrations = extractMigrationNames(result1);
|
||||
|
||||
// Run pending migrations in order
|
||||
for (const migration of this.migrations) {
|
||||
if (!executedMigrations.has(migration.name)) {
|
||||
await sqlExec(migration.sql);
|
||||
await sqlExec("INSERT INTO migrations (name) VALUES (?)", [
|
||||
migration.name,
|
||||
]);
|
||||
logger.log(`Migration ${migration.name} executed successfully`);
|
||||
|
||||
await sqlExec(
|
||||
`INSERT INTO migrations (name) VALUES ('${migration.name}')`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
import {
|
||||
ImageResult,
|
||||
PlatformService,
|
||||
PlatformCapabilities,
|
||||
} from "../PlatformService";
|
||||
import { Filesystem, Directory, Encoding } from "@capacitor/filesystem";
|
||||
import { Camera, CameraResultType, CameraSource } from "@capacitor/camera";
|
||||
import {
|
||||
Camera,
|
||||
CameraResultType,
|
||||
CameraSource,
|
||||
CameraDirection,
|
||||
} from "@capacitor/camera";
|
||||
import { Share } from "@capacitor/share";
|
||||
import {
|
||||
SQLiteConnection,
|
||||
SQLiteDBConnection,
|
||||
CapacitorSQLite,
|
||||
Changes,
|
||||
capSQLiteChanges,
|
||||
DBSQLiteValues,
|
||||
} from "@capacitor-community/sqlite";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { QueryExecResult, SqlValue } from "@/interfaces/database";
|
||||
import { DEFAULT_ENDORSER_API_SERVER } from "@/constants/app";
|
||||
|
||||
interface Migration {
|
||||
name: string;
|
||||
import { runMigrations } from "@/db-sql/migration";
|
||||
import { QueryExecResult } from "@/interfaces/database";
|
||||
import {
|
||||
ImageResult,
|
||||
PlatformService,
|
||||
PlatformCapabilities,
|
||||
} from "../PlatformService";
|
||||
import { logger } from "../../utils/logger";
|
||||
|
||||
interface QueuedOperation {
|
||||
type: "run" | "query";
|
||||
sql: string;
|
||||
params: unknown[];
|
||||
resolve: (value: unknown) => void;
|
||||
reject: (reason: unknown) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,16 +40,47 @@ interface Migration {
|
||||
* - SQLite database operations
|
||||
*/
|
||||
export class CapacitorPlatformService implements PlatformService {
|
||||
/** Current camera direction */
|
||||
private currentDirection: CameraDirection = "BACK";
|
||||
|
||||
private sqlite: SQLiteConnection;
|
||||
private db: SQLiteDBConnection | null = null;
|
||||
private dbName = "timesafari.db";
|
||||
private dbName = "timesafari.sqlite";
|
||||
private initialized = false;
|
||||
private initializationPromise: Promise<void> | null = null;
|
||||
private operationQueue: Array<QueuedOperation> = [];
|
||||
private isProcessingQueue: boolean = false;
|
||||
|
||||
constructor() {
|
||||
this.sqlite = new SQLiteConnection(CapacitorSQLite);
|
||||
}
|
||||
|
||||
private async initializeDatabase(): Promise<void> {
|
||||
// If already initialized, return immediately
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If initialization is in progress, wait for it
|
||||
if (this.initializationPromise) {
|
||||
return this.initializationPromise;
|
||||
}
|
||||
|
||||
// Start initialization
|
||||
this.initializationPromise = this._initialize();
|
||||
try {
|
||||
await this.initializationPromise;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
"[CapacitorPlatformService] Initialize method failed:",
|
||||
error,
|
||||
);
|
||||
this.initializationPromise = null; // Reset on failure
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private async _initialize(): Promise<void> {
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
@@ -57,136 +98,144 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
await this.db.open();
|
||||
|
||||
// Set journal mode to WAL for better performance
|
||||
await this.db.execute("PRAGMA journal_mode=WAL;");
|
||||
// await this.db.execute("PRAGMA journal_mode=WAL;");
|
||||
|
||||
// Run migrations
|
||||
await this.runMigrations();
|
||||
await this.runCapacitorMigrations();
|
||||
|
||||
this.initialized = true;
|
||||
logger.log("SQLite database initialized successfully");
|
||||
logger.log(
|
||||
"[CapacitorPlatformService] SQLite database initialized successfully",
|
||||
);
|
||||
|
||||
// Start processing the queue after initialization
|
||||
this.processQueue();
|
||||
} catch (error) {
|
||||
logger.error("Error initializing SQLite database:", error);
|
||||
throw new Error("Failed to initialize database");
|
||||
logger.error(
|
||||
"[CapacitorPlatformService] Error initializing SQLite database:",
|
||||
error,
|
||||
);
|
||||
throw new Error(
|
||||
"[CapacitorPlatformService] Failed to initialize database",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async runMigrations(): Promise<void> {
|
||||
private async processQueue(): Promise<void> {
|
||||
if (this.isProcessingQueue || !this.initialized || !this.db) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isProcessingQueue = true;
|
||||
|
||||
while (this.operationQueue.length > 0) {
|
||||
const operation = this.operationQueue.shift();
|
||||
if (!operation) continue;
|
||||
|
||||
try {
|
||||
let result: unknown;
|
||||
switch (operation.type) {
|
||||
case "run": {
|
||||
const runResult = await this.db.run(
|
||||
operation.sql,
|
||||
operation.params,
|
||||
);
|
||||
result = {
|
||||
changes: runResult.changes?.changes || 0,
|
||||
lastId: runResult.changes?.lastId,
|
||||
};
|
||||
break;
|
||||
}
|
||||
case "query": {
|
||||
const queryResult = await this.db.query(
|
||||
operation.sql,
|
||||
operation.params,
|
||||
);
|
||||
result = {
|
||||
columns: Object.keys(queryResult.values?.[0] || {}),
|
||||
values: (queryResult.values || []).map((row) =>
|
||||
Object.values(row),
|
||||
),
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
operation.resolve(result);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
"[CapacitorPlatformService] Error while processing SQL queue:",
|
||||
error,
|
||||
);
|
||||
operation.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
this.isProcessingQueue = false;
|
||||
}
|
||||
|
||||
private async queueOperation<R>(
|
||||
type: QueuedOperation["type"],
|
||||
sql: string,
|
||||
params: unknown[] = [],
|
||||
): Promise<R> {
|
||||
return new Promise<R>((resolve, reject) => {
|
||||
const operation: QueuedOperation = {
|
||||
type,
|
||||
sql,
|
||||
params,
|
||||
resolve: (value: unknown) => resolve(value as R),
|
||||
reject,
|
||||
};
|
||||
this.operationQueue.push(operation);
|
||||
|
||||
// If we're already initialized, start processing the queue
|
||||
if (this.initialized && this.db) {
|
||||
this.processQueue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async waitForInitialization(): Promise<void> {
|
||||
// If we have an initialization promise, wait for it
|
||||
if (this.initializationPromise) {
|
||||
await this.initializationPromise;
|
||||
return;
|
||||
}
|
||||
|
||||
// If not initialized and no promise, start initialization
|
||||
if (!this.initialized) {
|
||||
await this.initializeDatabase();
|
||||
return;
|
||||
}
|
||||
|
||||
// If initialized but no db, something went wrong
|
||||
if (!this.db) {
|
||||
logger.error(
|
||||
"[CapacitorPlatformService] Database not properly initialized after await waitForInitialization() - initialized flag is true but db is null",
|
||||
);
|
||||
throw new Error(
|
||||
"[CapacitorPlatformService] The database could not be initialized. We recommend you restart or reinstall.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async runCapacitorMigrations(): Promise<void> {
|
||||
if (!this.db) {
|
||||
throw new Error("Database not initialized");
|
||||
}
|
||||
|
||||
// Create migrations table if it doesn't exist
|
||||
await this.db.execute(`
|
||||
CREATE TABLE IF NOT EXISTS migrations (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
`);
|
||||
|
||||
// Get list of executed migrations
|
||||
const result = await this.db.query("SELECT name FROM migrations;");
|
||||
const executedMigrations = new Set(
|
||||
result.values?.map((row) => row[0]) || [],
|
||||
);
|
||||
|
||||
// Run pending migrations in order
|
||||
const migrations: Migration[] = [
|
||||
{
|
||||
name: "001_initial",
|
||||
sql: `
|
||||
CREATE TABLE IF NOT EXISTS accounts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
dateCreated TEXT NOT NULL,
|
||||
derivationPath TEXT,
|
||||
did TEXT NOT NULL,
|
||||
identityEncrBase64 TEXT,
|
||||
mnemonicEncrBase64 TEXT,
|
||||
passkeyCredIdHex TEXT,
|
||||
publicKeyHex TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_accounts_did ON accounts(did);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS secret (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
secretBase64 TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS settings (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
accountDid TEXT,
|
||||
activeDid TEXT,
|
||||
apiServer TEXT,
|
||||
filterFeedByNearby BOOLEAN,
|
||||
filterFeedByVisible BOOLEAN,
|
||||
finishedOnboarding BOOLEAN,
|
||||
firstName TEXT,
|
||||
hideRegisterPromptOnNewContact BOOLEAN,
|
||||
isRegistered BOOLEAN,
|
||||
lastName TEXT,
|
||||
lastAckedOfferToUserJwtId TEXT,
|
||||
lastAckedOfferToUserProjectsJwtId TEXT,
|
||||
lastNotifiedClaimId TEXT,
|
||||
lastViewedClaimId TEXT,
|
||||
notifyingNewActivityTime TEXT,
|
||||
notifyingReminderMessage TEXT,
|
||||
notifyingReminderTime TEXT,
|
||||
partnerApiServer TEXT,
|
||||
passkeyExpirationMinutes INTEGER,
|
||||
profileImageUrl TEXT,
|
||||
searchBoxes TEXT,
|
||||
showContactGivesInline BOOLEAN,
|
||||
showGeneralAdvanced BOOLEAN,
|
||||
showShortcutBvc BOOLEAN,
|
||||
vapid TEXT,
|
||||
warnIfProdServer BOOLEAN,
|
||||
warnIfTestServer BOOLEAN,
|
||||
webPushServer TEXT
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_settings_accountDid ON settings(accountDid);
|
||||
|
||||
INSERT INTO settings (id, apiServer) VALUES (1, '${DEFAULT_ENDORSER_API_SERVER}');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS contacts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
did TEXT NOT NULL,
|
||||
name TEXT,
|
||||
contactMethods TEXT,
|
||||
nextPubKeyHashB64 TEXT,
|
||||
notes TEXT,
|
||||
profileImageUrl TEXT,
|
||||
publicKeyBase64 TEXT,
|
||||
seesMe BOOLEAN,
|
||||
registered BOOLEAN
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_contacts_did ON contacts(did);
|
||||
CREATE INDEX IF NOT EXISTS idx_contacts_name ON contacts(name);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS logs (
|
||||
date TEXT PRIMARY KEY,
|
||||
message TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS temp (
|
||||
id TEXT PRIMARY KEY,
|
||||
blobB64 TEXT
|
||||
);
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
for (const migration of migrations) {
|
||||
if (!executedMigrations.has(migration.name)) {
|
||||
await this.db.execute(migration.sql);
|
||||
await this.db.run("INSERT INTO migrations (name) VALUES (?)", [
|
||||
migration.name,
|
||||
]);
|
||||
logger.log(`Migration ${migration.name} executed successfully`);
|
||||
}
|
||||
}
|
||||
const sqlExec: (sql: string) => Promise<capSQLiteChanges> =
|
||||
this.db.execute.bind(this.db);
|
||||
const sqlQuery: (sql: string) => Promise<DBSQLiteValues> =
|
||||
this.db.query.bind(this.db);
|
||||
const extractMigrationNames: (result: DBSQLiteValues) => Set<string> = (
|
||||
result,
|
||||
) => {
|
||||
const names =
|
||||
result.values?.map((row: { name: string }) => row.name) || [];
|
||||
return new Set(names);
|
||||
};
|
||||
runMigrations(sqlExec, sqlQuery, extractMigrationNames);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,6 +250,7 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
isIOS: /iPad|iPhone|iPod/.test(navigator.userAgent),
|
||||
hasFileDownload: false,
|
||||
needsFileHandlingInstructions: true,
|
||||
isNativeApp: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -580,6 +630,7 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Camera,
|
||||
direction: this.currentDirection,
|
||||
});
|
||||
|
||||
const blob = await this.processImageData(image.base64String);
|
||||
@@ -645,6 +696,15 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
return new Blob(byteArrays, { type: "image/jpeg" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the camera between front and back cameras.
|
||||
* @returns Promise that resolves when the camera is rotated
|
||||
*/
|
||||
async rotateCamera(): Promise<void> {
|
||||
this.currentDirection = this.currentDirection === "BACK" ? "FRONT" : "BACK";
|
||||
logger.debug(`Camera rotated to ${this.currentDirection} camera`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles deep link URLs for the application.
|
||||
* Note: Capacitor handles deep links automatically.
|
||||
@@ -660,24 +720,8 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
* @see PlatformService.dbQuery
|
||||
*/
|
||||
async dbQuery(sql: string, params?: unknown[]): Promise<QueryExecResult> {
|
||||
await this.initializeDatabase();
|
||||
if (!this.db) {
|
||||
throw new Error("Database not initialized");
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await this.db.query(sql, params || []);
|
||||
const values = result.values || [];
|
||||
return {
|
||||
columns: [], // SQLite plugin doesn't provide column names in query result
|
||||
values: values as SqlValue[][],
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error("Error executing query:", error);
|
||||
throw new Error(
|
||||
`Database query failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
await this.waitForInitialization();
|
||||
return this.queueOperation<QueryExecResult>("query", sql, params || []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -687,23 +731,11 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
sql: string,
|
||||
params?: unknown[],
|
||||
): Promise<{ changes: number; lastId?: number }> {
|
||||
await this.initializeDatabase();
|
||||
if (!this.db) {
|
||||
throw new Error("Database not initialized");
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await this.db.run(sql, params || []);
|
||||
const changes = result.changes as Changes;
|
||||
return {
|
||||
changes: changes?.changes || 0,
|
||||
lastId: changes?.lastId,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error("Error executing statement:", error);
|
||||
throw new Error(
|
||||
`Database execution failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
await this.waitForInitialization();
|
||||
return this.queueOperation<{ changes: number; lastId?: number }>(
|
||||
"run",
|
||||
sql,
|
||||
params || [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,17 @@ export class ElectronPlatformService implements PlatformService {
|
||||
await this.runMigrations();
|
||||
|
||||
this.initialized = true;
|
||||
logger.log("SQLite database initialized successfully");
|
||||
logger.log(
|
||||
"[ElectronPlatformService] SQLite database initialized successfully",
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error("Error initializing SQLite database:", error);
|
||||
throw new Error("Failed to initialize database");
|
||||
logger.error(
|
||||
"[ElectronPlatformService] Error initializing SQLite database:",
|
||||
error,
|
||||
);
|
||||
throw new Error(
|
||||
"[ElectronPlatformService] Failed to initialize database",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
<div v-if="givenName">
|
||||
<h2 class="text-xl font-semibold mb-2">
|
||||
<span class="whitespace-nowrap">
|
||||
<router-link
|
||||
:to="{ name: 'contact-qr' }"
|
||||
class="bg-slate-500 text-white px-1.5 py-1 rounded-md"
|
||||
<button
|
||||
class="bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-1 mr-1 rounded-md"
|
||||
@click="handleQRCodeClick"
|
||||
>
|
||||
<font-awesome icon="qrcode" class="fa-fw text-xl"></font-awesome>
|
||||
</router-link>
|
||||
<font-awesome icon="qrcode" class="fa-fw text-xl" />
|
||||
</button>
|
||||
</span>
|
||||
{{ givenName }}
|
||||
<router-link :to="{ name: 'new-edit-account' }">
|
||||
@@ -119,6 +119,7 @@
|
||||
<ImageMethodDialog
|
||||
ref="imageMethodDialog"
|
||||
:is-registered="isRegistered"
|
||||
default-camera-mode="user"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
@@ -205,12 +206,12 @@
|
||||
Before you can publicly announce a new project or time commitment, a
|
||||
friend needs to register you.
|
||||
</p>
|
||||
<router-link
|
||||
:to="{ name: 'contact-qr' }"
|
||||
<button
|
||||
class="inline-block text-md 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-4 py-2 rounded-md"
|
||||
@click="handleQRCodeClick"
|
||||
>
|
||||
Share Your Info
|
||||
</router-link>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<section
|
||||
@@ -430,12 +431,16 @@
|
||||
<div class="mb-4 text-center">
|
||||
{{ limitsMessage }}
|
||||
</div>
|
||||
<div>
|
||||
<div v-if="endorserLimits">
|
||||
<p class="text-sm">
|
||||
You have done
|
||||
<b>{{ endorserLimits?.doneClaimsThisWeek || "?" }} claims</b> out of
|
||||
<b>{{ endorserLimits?.maxClaimsPerWeek || "?" }}</b> for this week.
|
||||
Your claims counter resets at
|
||||
<b
|
||||
>{{ endorserLimits?.doneClaimsThisWeek || "?" }} claim{{
|
||||
endorserLimits?.doneClaimsThisWeek === 1 ? "" : "s"
|
||||
}}</b
|
||||
>
|
||||
out of <b>{{ endorserLimits?.maxClaimsPerWeek || "?" }}</b> for this
|
||||
week. Your claims counter resets at
|
||||
<b class="whitespace-nowrap">{{
|
||||
readableDate(endorserLimits?.nextWeekBeginDateTime)
|
||||
}}</b>
|
||||
@@ -446,7 +451,9 @@
|
||||
>{{
|
||||
endorserLimits?.doneRegistrationsThisMonth || "?"
|
||||
}}
|
||||
registrations</b
|
||||
registration{{
|
||||
endorserLimits?.doneRegistrationsThisMonth === 1 ? "" : "s"
|
||||
}}</b
|
||||
>
|
||||
out of
|
||||
<b>{{ endorserLimits?.maxRegistrationsPerMonth || "?" }}</b> for this
|
||||
@@ -459,9 +466,13 @@
|
||||
</p>
|
||||
<p class="mt-3 text-sm">
|
||||
You have uploaded
|
||||
<b>{{ imageLimits?.doneImagesThisWeek || "?" }} images</b> out of
|
||||
<b>{{ imageLimits?.maxImagesPerWeek || "?" }}</b> for this week. Your
|
||||
image counter resets at
|
||||
<b
|
||||
>{{ imageLimits?.doneImagesThisWeek || "?" }} image{{
|
||||
imageLimits?.doneImagesThisWeek === 1 ? "" : "s"
|
||||
}}</b
|
||||
>
|
||||
out of <b>{{ imageLimits?.maxImagesPerWeek || "?" }}</b> for this
|
||||
week. Your image counter resets at
|
||||
<b class="whitespace-nowrap">{{
|
||||
readableDate(imageLimits?.nextWeekBeginDateTime)
|
||||
}}</b>
|
||||
@@ -498,7 +509,7 @@
|
||||
|
||||
<!-- Deep Identity Details -->
|
||||
<span class="text-slate-500 text-sm font-bold mb-2">
|
||||
Deep Identifier Details
|
||||
Identifier Details
|
||||
</span>
|
||||
<div
|
||||
id="sectionDeepIdentifier"
|
||||
@@ -581,21 +592,8 @@
|
||||
Switch Identifier
|
||||
</router-link>
|
||||
|
||||
<div class="flex mt-4">
|
||||
<button>
|
||||
<router-link
|
||||
:to="{ name: 'statistics' }"
|
||||
class="block w-fit text-center text-md bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md mb-2"
|
||||
>
|
||||
See Global Animated History of Giving
|
||||
</router-link>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="sectionImportContactsSettings" class="mt-4">
|
||||
<h2 class="text-slate-500 text-sm font-bold">
|
||||
Import Contacts & Settings Database
|
||||
</h2>
|
||||
<h2 class="text-slate-500 text-sm font-bold">Import Contacts</h2>
|
||||
|
||||
<div class="ml-4 mt-2">
|
||||
<input type="file" class="ml-2" @change="uploadImportFile" />
|
||||
@@ -625,9 +623,7 @@
|
||||
class="block text-center text-md 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-1.5 py-2 rounded-md mb-6"
|
||||
@click="checkContactImports()"
|
||||
>
|
||||
Import Only Contacts
|
||||
<br />
|
||||
after comparing
|
||||
Import Contacts
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -963,6 +959,17 @@
|
||||
>
|
||||
Test Page
|
||||
</router-link>
|
||||
|
||||
<div class="flex mt-2">
|
||||
<button>
|
||||
<router-link
|
||||
:to="{ name: 'statistics' }"
|
||||
class="block w-fit text-center text-md bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md"
|
||||
>
|
||||
See Global Animated History of Giving
|
||||
</router-link>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</template>
|
||||
@@ -984,6 +991,7 @@ import { Component, Vue } from "vue-facing-decorator";
|
||||
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
|
||||
import EntityIcon from "../components/EntityIcon.vue";
|
||||
import ImageMethodDialog from "../components/ImageMethodDialog.vue";
|
||||
@@ -1007,7 +1015,6 @@ import {
|
||||
retrieveSettingsForActiveAccount,
|
||||
updateAccountSettings,
|
||||
} from "../db/index";
|
||||
import { Account } from "../db/tables/accounts";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import {
|
||||
DEFAULT_PASSKEY_EXPIRATION_MINUTES,
|
||||
@@ -1032,7 +1039,6 @@ import {
|
||||
} from "../libs/util";
|
||||
import { UserProfile } from "@/libs/partnerServer";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
|
||||
const inputImportFileNameRef = ref<Blob>();
|
||||
|
||||
@@ -1166,8 +1172,6 @@ export default class AccountViewView extends Vue {
|
||||
5000,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
this.loadingProfile = false;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -1190,6 +1194,8 @@ export default class AccountViewView extends Vue {
|
||||
},
|
||||
5000,
|
||||
);
|
||||
} finally {
|
||||
this.loadingProfile = false;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -1204,7 +1210,6 @@ export default class AccountViewView extends Vue {
|
||||
this.turnOffNotifyingFlags();
|
||||
}
|
||||
}
|
||||
// console.log("Got to the end of 'mounted' call in AccountViewView.");
|
||||
/**
|
||||
* Beware! I've seen where we never get to this point because "ready" never resolves.
|
||||
*/
|
||||
@@ -1350,18 +1355,7 @@ export default class AccountViewView extends Vue {
|
||||
* Processes the identity and updates the component's state.
|
||||
*/
|
||||
async processIdentity() {
|
||||
let account: Account | undefined = undefined;
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const dbAccount = await platformService.dbQuery(
|
||||
"SELECT * FROM accounts WHERE did = ?",
|
||||
[this.activeDid],
|
||||
);
|
||||
if (dbAccount) {
|
||||
account = databaseUtil.mapQueryResultToValues(dbAccount)[0] as Account;
|
||||
}
|
||||
if (USE_DEXIE_DB) {
|
||||
account = await retrieveAccountMetadata(this.activeDid);
|
||||
}
|
||||
const account = await retrieveAccountMetadata(this.activeDid);
|
||||
if (account?.identity) {
|
||||
const identity = JSON.parse(account.identity as string) as IIdentifier;
|
||||
this.publicHex = identity.keys[0].publicKeyHex;
|
||||
@@ -1369,8 +1363,10 @@ export default class AccountViewView extends Vue {
|
||||
this.derivationPath = identity.keys[0].meta?.derivationPath as string;
|
||||
await this.checkLimits();
|
||||
} else if (account?.publicKeyHex) {
|
||||
// use the backup values in the top level of the account object
|
||||
this.publicHex = account.publicKeyHex as string;
|
||||
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64");
|
||||
this.derivationPath = account.derivationPath as string;
|
||||
await this.checkLimits();
|
||||
}
|
||||
}
|
||||
@@ -2226,5 +2222,13 @@ export default class AccountViewView extends Vue {
|
||||
this.savingProfile = false;
|
||||
}
|
||||
}
|
||||
|
||||
private handleQRCodeClick() {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
this.$router.push({ name: "contact-qr-scan-full" });
|
||||
} else {
|
||||
this.$router.push({ name: "contact-qr" });
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
|
||||
<div class="mt-8">
|
||||
<button
|
||||
v-if="libsUtil.canFulfillOffer(veriClaim)"
|
||||
v-if="libsUtil.canFulfillOffer(veriClaim, isRegistered)"
|
||||
class="col-span-1 block w-fit text-center text-md 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-1.5 py-2 rounded-md"
|
||||
@click="openFulfillGiftDialog()"
|
||||
>
|
||||
@@ -292,11 +292,7 @@
|
||||
<div class="text-sm">
|
||||
{{ didInfo(confirmerId) }}
|
||||
<span v-if="!serverUtil.isEmptyOrHiddenDid(confirmerId)">
|
||||
<a
|
||||
:href="`/did/${confirmerId}`"
|
||||
target="_blank"
|
||||
class="text-blue-500"
|
||||
>
|
||||
<a :href="`/did/${confirmerId}`" class="text-blue-500">
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
@@ -333,11 +329,7 @@
|
||||
<div class="text-sm">
|
||||
{{ didInfo(confsVisibleTo) }}
|
||||
<span v-if="!serverUtil.isEmptyOrHiddenDid(confsVisibleTo)">
|
||||
<a
|
||||
:href="`/did/${confsVisibleTo}`"
|
||||
target="_blank"
|
||||
class="text-blue-500"
|
||||
>
|
||||
<a :href="`/did/${confsVisibleTo}`" class="text-blue-500">
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
@@ -451,11 +443,7 @@
|
||||
<span>
|
||||
{{ didInfo(visDid) }}
|
||||
<span v-if="!serverUtil.isEmptyOrHiddenDid(visDid)">
|
||||
<a
|
||||
:href="`/did/${visDid}`"
|
||||
target="_blank"
|
||||
class="text-blue-500"
|
||||
>
|
||||
<a :href="`/did/${visDid}`" class="text-blue-500">
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
@@ -548,11 +536,7 @@ import { db } from "../db/index";
|
||||
import { logConsoleAndDb } from "../db/databaseUtil";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import * as serverUtil from "../libs/endorserServer";
|
||||
import {
|
||||
GenericCredWrapper,
|
||||
OfferVerifiableCredential,
|
||||
ProviderInfo,
|
||||
} from "../interfaces";
|
||||
import { GenericCredWrapper, OfferClaim, ProviderInfo } from "../interfaces";
|
||||
import * as libsUtil from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
@@ -978,7 +962,7 @@ export default class ClaimView extends Vue {
|
||||
openFulfillGiftDialog() {
|
||||
const giver: libsUtil.GiverReceiverInputInfo = {
|
||||
did: libsUtil.offerGiverDid(
|
||||
this.veriClaim as GenericCredWrapper<OfferVerifiableCredential>,
|
||||
this.veriClaim as GenericCredWrapper<OfferClaim>,
|
||||
),
|
||||
};
|
||||
(this.$refs.customGiveDialog as GiftedDialog).open(
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
encodeURIComponent(giveDetails?.fulfillsPlanHandleId || '')
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
target="_blank"
|
||||
>
|
||||
This fulfills a bigger plan
|
||||
<font-awesome
|
||||
@@ -129,7 +128,6 @@
|
||||
encodeURIComponent(giveDetails?.fulfillsHandleId || '')
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
target="_blank"
|
||||
>
|
||||
This fulfills
|
||||
{{
|
||||
|
||||
@@ -124,7 +124,7 @@ import * as databaseUtil from "../db/databaseUtil";
|
||||
import {
|
||||
AgreeVerifiableCredential,
|
||||
GiveSummaryRecord,
|
||||
GiveVerifiableCredential,
|
||||
GiveActionClaim,
|
||||
} from "../interfaces";
|
||||
import {
|
||||
createEndorserJwtVcFromClaim,
|
||||
@@ -276,7 +276,7 @@ export default class ContactAmountssView extends Vue {
|
||||
// Make claim
|
||||
// I use clone here because otherwise it gets a Proxy object.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const origClaim: GiveVerifiableCredential = R.clone(record.fullClaim);
|
||||
const origClaim: GiveActionClaim = R.clone(record.fullClaim);
|
||||
if (record.fullClaim["@context"] == SCHEMA_ORG_CONTEXT) {
|
||||
delete origClaim["@context"];
|
||||
}
|
||||
|
||||
@@ -223,6 +223,76 @@ import { getContactJwtFromJwtUrl } from "../libs/crypto";
|
||||
import { decodeEndorserJwt } from "../libs/crypto/vc";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
|
||||
/**
|
||||
* Interface for contact data as stored in the database
|
||||
* Differs from Contact interface in that contactMethods is stored as a JSON string
|
||||
*/
|
||||
interface ContactDbRecord {
|
||||
did: string;
|
||||
contactMethods: string;
|
||||
name: string;
|
||||
notes: string;
|
||||
profileImageUrl: string;
|
||||
publicKeyBase64: string;
|
||||
nextPubKeyHashB64: string;
|
||||
seesMe: boolean;
|
||||
registered: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures a value is a string, never null or undefined
|
||||
*/
|
||||
function safeString(val: unknown): string {
|
||||
return typeof val === "string" ? val : val == null ? "" : String(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Contact object to a ContactDbRecord for database storage
|
||||
* @param contact The contact object to convert
|
||||
* @returns A ContactDbRecord with contactMethods as a JSON string
|
||||
* @throws Error if contact.did is missing or invalid
|
||||
*/
|
||||
function contactToDbRecord(contact: Contact): ContactDbRecord {
|
||||
if (!contact.did) {
|
||||
throw new Error("Contact must have a DID");
|
||||
}
|
||||
|
||||
// Convert contactMethods array to JSON string, defaulting to empty array
|
||||
const contactMethodsStr =
|
||||
contact.contactMethods != null
|
||||
? JSON.stringify(contact.contactMethods)
|
||||
: "[]";
|
||||
|
||||
return {
|
||||
did: safeString(contact.did), // Required field, must be present
|
||||
contactMethods: contactMethodsStr,
|
||||
name: safeString(contact.name),
|
||||
notes: safeString(contact.notes),
|
||||
profileImageUrl: safeString(contact.profileImageUrl),
|
||||
publicKeyBase64: safeString(contact.publicKeyBase64),
|
||||
nextPubKeyHashB64: safeString(contact.nextPubKeyHashB64),
|
||||
seesMe: contact.seesMe ?? false,
|
||||
registered: contact.registered ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a ContactDbRecord back to a Contact object
|
||||
* @param record The database record to convert
|
||||
* @returns A Contact object with parsed contactMethods array
|
||||
*/
|
||||
function dbRecordToContact(record: ContactDbRecord): Contact {
|
||||
return {
|
||||
...record,
|
||||
name: safeString(record.name),
|
||||
notes: safeString(record.notes),
|
||||
profileImageUrl: safeString(record.profileImageUrl),
|
||||
publicKeyBase64: safeString(record.publicKeyBase64),
|
||||
nextPubKeyHashB64: safeString(record.nextPubKeyHashB64),
|
||||
contactMethods: JSON.parse(record.contactMethods || "[]"),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact Import View Component
|
||||
* @author Matthew Raymer
|
||||
@@ -533,25 +603,39 @@ export default class ContactImportView extends Vue {
|
||||
if (this.contactsSelected[i]) {
|
||||
const contact = this.contactsImporting[i];
|
||||
const existingContact = this.contactsExisting[contact.did];
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
|
||||
// Convert contact to database record format
|
||||
const contactToStore = contactToDbRecord(contact);
|
||||
|
||||
if (existingContact) {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
// @ts-expect-error because we're just using the value to store to the DB
|
||||
contact.contactMethods = JSON.stringify(contact.contactMethods);
|
||||
// Update existing contact
|
||||
const { sql, params } = databaseUtil.generateUpdateStatement(
|
||||
contact as unknown as Record<string, unknown>,
|
||||
contactToStore as unknown as Record<string, unknown>,
|
||||
"contacts",
|
||||
"did = ?",
|
||||
[contact.did],
|
||||
);
|
||||
await platformService.dbExec(sql, params);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.contacts.update(contact.did, contact);
|
||||
// For Dexie, we need to parse the contactMethods back to an array
|
||||
await db.contacts.update(
|
||||
contact.did,
|
||||
dbRecordToContact(contactToStore),
|
||||
);
|
||||
}
|
||||
updatedCount++;
|
||||
} else {
|
||||
// without explicit clone on the Proxy, we get: DataCloneError: Failed to execute 'add' on 'IDBObjectStore': #<Object> could not be cloned.
|
||||
// DataError: Failed to execute 'add' on 'IDBObjectStore': Evaluating the object store's key path yielded a value that is not a valid key.
|
||||
await db.contacts.add(R.clone(contact));
|
||||
// Add new contact
|
||||
const { sql, params } = databaseUtil.generateInsertStatement(
|
||||
contactToStore as unknown as Record<string, unknown>,
|
||||
"contacts",
|
||||
);
|
||||
await platformService.dbExec(sql, params);
|
||||
if (USE_DEXIE_DB) {
|
||||
// For Dexie, we need to parse the contactMethods back to an array
|
||||
await db.contacts.add(dbRecordToContact(contactToStore));
|
||||
}
|
||||
importedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,8 @@ export default class ContactQRScan extends Vue {
|
||||
}
|
||||
|
||||
const contactInfo = decodedJwt.payload.own;
|
||||
if (!contactInfo.did) {
|
||||
const did = contactInfo.did || decodedJwt.payload.iss;
|
||||
if (!did) {
|
||||
logger.warn("Invalid contact info - missing DID");
|
||||
this.$notify({
|
||||
group: "alert",
|
||||
@@ -376,7 +377,7 @@ export default class ContactQRScan extends Vue {
|
||||
|
||||
// Create contact object
|
||||
const contact = {
|
||||
did: contactInfo.did,
|
||||
did: did,
|
||||
name: contactInfo.name || "",
|
||||
email: contactInfo.email || "",
|
||||
phone: contactInfo.phone || "",
|
||||
|
||||
@@ -152,30 +152,6 @@
|
||||
@camera-on="onCameraOn"
|
||||
@camera-off="onCameraOff"
|
||||
/>
|
||||
|
||||
<div
|
||||
class="absolute bottom-4 inset-x-0 flex justify-center items-center"
|
||||
>
|
||||
<!-- Camera Stop Button -->
|
||||
<button
|
||||
class="text-center text-slate-600 leading-none bg-white p-2 rounded-full drop-shadow-lg"
|
||||
title="Stop camera"
|
||||
@click="stopScanning"
|
||||
>
|
||||
<font-awesome icon="xmark" class="size-6" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="flex items-center justify-center aspect-square overflow-hidden bg-slate-800 w-[90vw] max-w-[calc((100vh-env(safe-area-inset-top)-env(safe-area-inset-bottom))*0.4)] mx-auto"
|
||||
>
|
||||
<button
|
||||
class="bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white text-lg px-3 py-2 rounded-lg"
|
||||
@click="startScanning"
|
||||
>
|
||||
Scan QR Code
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -260,6 +236,7 @@ export default class ContactQRScanShow extends Vue {
|
||||
|
||||
// Add property to track if we're on desktop
|
||||
private isDesktop = false;
|
||||
private isFrontCamera = false;
|
||||
|
||||
async created() {
|
||||
try {
|
||||
@@ -511,7 +488,8 @@ export default class ContactQRScanShow extends Vue {
|
||||
}
|
||||
|
||||
const contactInfo = decodedJwt.payload.own;
|
||||
if (!contactInfo.did) {
|
||||
const did = contactInfo.did || decodedJwt.payload.iss;
|
||||
if (!did) {
|
||||
logger.warn("Invalid contact info - missing DID");
|
||||
this.$notify({
|
||||
group: "alert",
|
||||
@@ -524,12 +502,8 @@ export default class ContactQRScanShow extends Vue {
|
||||
|
||||
// Create contact object
|
||||
const contact = {
|
||||
did: contactInfo.did,
|
||||
did: did,
|
||||
name: contactInfo.name || "",
|
||||
email: contactInfo.email || "",
|
||||
phone: contactInfo.phone || "",
|
||||
company: contactInfo.company || "",
|
||||
title: contactInfo.title || "",
|
||||
notes: contactInfo.notes || "",
|
||||
};
|
||||
|
||||
@@ -848,7 +822,7 @@ export default class ContactQRScanShow extends Vue {
|
||||
if (stopAsking) {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec(
|
||||
"UPDATE settings SET hideRegisterPromptOnNewContact = ? WHERE key = ?",
|
||||
"UPDATE settings SET hideRegisterPromptOnNewContact = ? WHERE id = ?",
|
||||
[stopAsking, MASTER_SETTINGS_KEY],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
@@ -863,7 +837,7 @@ export default class ContactQRScanShow extends Vue {
|
||||
if (stopAsking) {
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec(
|
||||
"UPDATE settings SET hideRegisterPromptOnNewContact = ? WHERE key = ?",
|
||||
"UPDATE settings SET hideRegisterPromptOnNewContact = ? WHERE id = ?",
|
||||
[stopAsking, MASTER_SETTINGS_KEY],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
@@ -923,6 +897,8 @@ export default class ContactQRScanShow extends Vue {
|
||||
onCameraOn(): void {
|
||||
this.cameraState = "active";
|
||||
this.isInitializing = false;
|
||||
this.isFrontCamera = this.preferredCamera === "user";
|
||||
this.applyCameraMirroring();
|
||||
}
|
||||
|
||||
onCameraOff(): void {
|
||||
@@ -968,6 +944,8 @@ export default class ContactQRScanShow extends Vue {
|
||||
toggleCamera(): void {
|
||||
this.preferredCamera =
|
||||
this.preferredCamera === "user" ? "environment" : "user";
|
||||
this.isFrontCamera = this.preferredCamera === "user";
|
||||
this.applyCameraMirroring();
|
||||
}
|
||||
|
||||
private handleError(error: unknown): void {
|
||||
@@ -994,14 +972,17 @@ export default class ContactQRScanShow extends Vue {
|
||||
);
|
||||
}
|
||||
|
||||
// Update the computed property for camera mirroring
|
||||
get shouldMirrorCamera(): boolean {
|
||||
// On desktop, always mirror the webcam
|
||||
if (this.isDesktop) {
|
||||
return true;
|
||||
// Add method to apply camera mirroring
|
||||
private applyCameraMirroring(): void {
|
||||
const videoElement = document.querySelector(
|
||||
".qr-scanner video",
|
||||
) as HTMLVideoElement;
|
||||
if (videoElement) {
|
||||
// Mirror if it's desktop or front camera on mobile
|
||||
const shouldMirror =
|
||||
this.isDesktop || (this.isFrontCamera && !this.isDesktop);
|
||||
videoElement.style.transform = shouldMirror ? "scaleX(-1)" : "none";
|
||||
}
|
||||
// On mobile, mirror only for front-facing camera
|
||||
return this.preferredCamera === "user";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1016,8 +997,9 @@ export default class ContactQRScanShow extends Vue {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Remove the default mirroring from CSS since we're handling it in JavaScript */
|
||||
:deep(.qr-scanner video) {
|
||||
transform: scaleX(-1);
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Ensure the canvas for QR detection is not mirrored */
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<span />
|
||||
<span>
|
||||
<a
|
||||
href="/help-onboarding"
|
||||
:href="APP_SERVER + '/help-onboarding'"
|
||||
target="_blank"
|
||||
class="text-xs 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-1.5 py-1 rounded-md ml-1"
|
||||
>
|
||||
@@ -54,17 +54,12 @@
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="flex items-center bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-1 mr-1 rounded-md"
|
||||
class="flex items-center bg-gradient-to-b from-green-400 to-green-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-1 mr-1 rounded-md"
|
||||
>
|
||||
<font-awesome
|
||||
icon="chair"
|
||||
class="fa-fw text-2xl"
|
||||
@click="
|
||||
warning(
|
||||
'You must get registered before you can initiate an onboarding meeting.',
|
||||
'Not Registered',
|
||||
)
|
||||
"
|
||||
@click="$router.push({ name: 'onboard-meeting-list' })"
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
@@ -180,117 +175,124 @@
|
||||
data-testId="contactListItem"
|
||||
>
|
||||
<div class="grow overflow-hidden">
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
v-if="!showGiveNumbers"
|
||||
type="checkbox"
|
||||
:checked="contactsSelected.includes(contact.did)"
|
||||
class="ml-2 h-6 w-6 flex-shrink-0"
|
||||
data-testId="contactCheckOne"
|
||||
@click="
|
||||
contactsSelected.includes(contact.did)
|
||||
? contactsSelected.splice(
|
||||
contactsSelected.indexOf(contact.did),
|
||||
1,
|
||||
)
|
||||
: contactsSelected.push(contact.did)
|
||||
"
|
||||
/>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
v-if="!showGiveNumbers"
|
||||
type="checkbox"
|
||||
:checked="contactsSelected.includes(contact.did)"
|
||||
class="ml-2 h-6 w-6 flex-shrink-0"
|
||||
data-testId="contactCheckOne"
|
||||
@click="
|
||||
contactsSelected.includes(contact.did)
|
||||
? contactsSelected.splice(
|
||||
contactsSelected.indexOf(contact.did),
|
||||
1,
|
||||
)
|
||||
: contactsSelected.push(contact.did)
|
||||
"
|
||||
/>
|
||||
|
||||
<EntityIcon
|
||||
:contact="contact"
|
||||
:icon-size="48"
|
||||
class="inline-block align-text-bottom border border-slate-300 rounded cursor-pointer overflow-hidden"
|
||||
@click="showLargeIdenticon = contact"
|
||||
/>
|
||||
|
||||
<h2 class="text-base font-semibold w-1/3 truncate flex-shrink-0">
|
||||
{{ contactNameNonBreakingSpace(contact.name) }}
|
||||
</h2>
|
||||
|
||||
<span>
|
||||
<div class="flex gap-2 items-center">
|
||||
<router-link
|
||||
:to="{
|
||||
path: '/did/' + encodeURIComponent(contact.did),
|
||||
}"
|
||||
title="See more about this person"
|
||||
>
|
||||
<font-awesome
|
||||
icon="circle-info"
|
||||
class="text-xl text-blue-500"
|
||||
/>
|
||||
</router-link>
|
||||
|
||||
<span class="text-sm overflow-hidden">{{
|
||||
libsUtil.shortDid(contact.did)
|
||||
}}</span>
|
||||
<div
|
||||
class="flex-shrink-0 w-12 h-12 flex items-center justify-center"
|
||||
>
|
||||
<EntityIcon
|
||||
:contact="contact"
|
||||
:icon-size="48"
|
||||
class="inline-block align-text-bottom border border-slate-300 rounded cursor-pointer overflow-hidden"
|
||||
@click="showLargeIdenticon = contact"
|
||||
/>
|
||||
</div>
|
||||
<div class="text-sm">
|
||||
{{ contact.notes }}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="showGiveNumbers && contact.did != activeDid"
|
||||
class="ml-auto flex gap-1.5 mt-2"
|
||||
>
|
||||
<button
|
||||
class="text-sm 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-2 py-1.5 rounded-l-md"
|
||||
:title="givenToMeDescriptions[contact.did] || ''"
|
||||
@click="confirmShowGiftedDialog(contact.did, activeDid)"
|
||||
>
|
||||
From:
|
||||
<br />
|
||||
{{
|
||||
/* eslint-disable prettier/prettier */
|
||||
showGiveTotals
|
||||
? ((givenToMeConfirmed[contact.did] || 0)
|
||||
+ (givenToMeUnconfirmed[contact.did] || 0))
|
||||
: showGiveConfirmed
|
||||
? (givenToMeConfirmed[contact.did] || 0)
|
||||
: (givenToMeUnconfirmed[contact.did] || 0)
|
||||
/* eslint-enable prettier/prettier */
|
||||
}}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="text-sm bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white -ml-1.5 px-2 py-1.5 rounded-r-md border-l"
|
||||
:title="givenByMeDescriptions[contact.did] || ''"
|
||||
@click="confirmShowGiftedDialog(activeDid, contact.did)"
|
||||
>
|
||||
To:
|
||||
<br />
|
||||
{{
|
||||
/* eslint-disable prettier/prettier */
|
||||
showGiveTotals
|
||||
? ((givenByMeConfirmed[contact.did] || 0)
|
||||
+ (givenByMeUnconfirmed[contact.did] || 0))
|
||||
: showGiveConfirmed
|
||||
? (givenByMeConfirmed[contact.did] || 0)
|
||||
: (givenByMeUnconfirmed[contact.did] || 0)
|
||||
/* eslint-enable prettier/prettier */
|
||||
}}
|
||||
</button>
|
||||
<h2 class="text-base font-semibold w-1/3 truncate flex-shrink-0">
|
||||
{{ contactNameNonBreakingSpace(contact.name) }}
|
||||
</h2>
|
||||
|
||||
<button
|
||||
class="text-sm 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-2 py-1.5 rounded-md border border-blue-400"
|
||||
data-testId="offerButton"
|
||||
@click="openOfferDialog(contact.did, contact.name)"
|
||||
>
|
||||
Offer
|
||||
</button>
|
||||
<span>
|
||||
<div class="flex gap-2 items-center">
|
||||
<router-link
|
||||
:to="{
|
||||
path: '/did/' + encodeURIComponent(contact.did),
|
||||
}"
|
||||
title="See more about this person"
|
||||
>
|
||||
<font-awesome
|
||||
icon="circle-info"
|
||||
class="text-xl text-blue-500"
|
||||
/>
|
||||
</router-link>
|
||||
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'contact-amounts',
|
||||
query: { contactDid: contact.did },
|
||||
}"
|
||||
class="text-sm bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-1.5 rounded-md border border-slate-400"
|
||||
title="See more given activity"
|
||||
<span class="text-sm overflow-hidden">{{
|
||||
libsUtil.shortDid(contact.did)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="text-sm">
|
||||
{{ contact.notes }}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showGiveNumbers && contact.did != activeDid"
|
||||
class="flex gap-2 items-center"
|
||||
>
|
||||
<font-awesome icon="file-lines" class="fa-fw" />
|
||||
</router-link>
|
||||
<button
|
||||
class="text-sm 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-2 py-1.5 rounded-l-md"
|
||||
:title="givenToMeDescriptions[contact.did] || ''"
|
||||
@click="confirmShowGiftedDialog(contact.did, activeDid)"
|
||||
>
|
||||
From:
|
||||
<br />
|
||||
{{
|
||||
/* eslint-disable prettier/prettier */
|
||||
showGiveTotals
|
||||
? ((givenToMeConfirmed[contact.did] || 0)
|
||||
+ (givenToMeUnconfirmed[contact.did] || 0))
|
||||
: showGiveConfirmed
|
||||
? (givenToMeConfirmed[contact.did] || 0)
|
||||
: (givenToMeUnconfirmed[contact.did] || 0)
|
||||
/* eslint-enable prettier/prettier */
|
||||
}}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="text-sm bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white -ml-1.5 px-2 py-1.5 rounded-r-md border-l"
|
||||
:title="givenByMeDescriptions[contact.did] || ''"
|
||||
@click="confirmShowGiftedDialog(activeDid, contact.did)"
|
||||
>
|
||||
To:
|
||||
<br />
|
||||
{{
|
||||
/* eslint-disable prettier/prettier */
|
||||
showGiveTotals
|
||||
? ((givenByMeConfirmed[contact.did] || 0)
|
||||
+ (givenByMeUnconfirmed[contact.did] || 0))
|
||||
: showGiveConfirmed
|
||||
? (givenByMeConfirmed[contact.did] || 0)
|
||||
: (givenByMeUnconfirmed[contact.did] || 0)
|
||||
/* eslint-enable prettier/prettier */
|
||||
}}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="text-sm 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-2 py-1.5 rounded-md border border-blue-400"
|
||||
data-testId="offerButton"
|
||||
@click="openOfferDialog(contact.did, contact.name)"
|
||||
>
|
||||
Offer
|
||||
</button>
|
||||
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'contact-amounts',
|
||||
query: { contactDid: contact.did },
|
||||
}"
|
||||
class="text-sm bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-1.5 rounded-md border border-slate-400"
|
||||
title="See more given activity"
|
||||
>
|
||||
<font-awesome icon="file-lines" class="fa-fw" />
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@@ -441,6 +443,7 @@ export default class ContactsView extends Vue {
|
||||
showGiveConfirmed = true;
|
||||
showLargeIdenticon?: Contact;
|
||||
|
||||
APP_SERVER = APP_SERVER;
|
||||
AppString = AppString;
|
||||
libsUtil = libsUtil;
|
||||
|
||||
|
||||