Compare commits
48 Commits
profile_in
...
registrati
| Author | SHA1 | Date | |
|---|---|---|---|
| 631aa468e6 | |||
| ee29b517ce | |||
| f34c567ab4 | |||
| bd072d95eb | |||
| 030960dd59 | |||
| b138441d10 | |||
|
|
ca1190aa47 | ||
| de45e83ffb | |||
|
|
f38ec1daff | ||
|
|
ec2cab768b | ||
| ba587471f9 | |||
| 2f05d27b51 | |||
| 40c8189c51 | |||
| cd7755979f | |||
| 4fa8c8f4cb | |||
|
|
1eeb013638 | ||
|
|
3e5e2cd0bb | ||
|
|
d87f44b75d | ||
| 2c7cb9333e | |||
| fa8956fb38 | |||
|
|
1499211018 | ||
|
|
25e37cc415 | ||
|
|
d339f1a274 | ||
|
|
c2e7531554 | ||
| aa64f426f3 | |||
|
|
e6f0c7a079 | ||
| 2b9b43d08f | |||
|
|
5f8d1fc8c6 | ||
|
|
c9082fa57b | ||
| a7608429be | |||
|
|
4a1249d166 | ||
|
|
6225cd7f8f | ||
|
|
dde37e73e1 | ||
|
|
83c0c18db2 | ||
|
|
5780d96cdc | ||
|
|
e67c97821a | ||
|
|
40fa38a9ce | ||
|
|
96e4d3c394 | ||
|
|
c4f2bb5e3a | ||
|
|
f51408e32a | ||
|
|
8827c4a973 | ||
| 528a68ef6c | |||
| 8991b36a56 | |||
| 6f5661d61c | |||
|
|
e5ad71505c | ||
| 19f0c270d3 | |||
|
|
693173f09d | ||
|
|
a1388539c1 |
@@ -617,7 +617,8 @@ The Electron build process follows a multi-stage approach:
|
||||
#### **Stage 2: Capacitor Sync**
|
||||
|
||||
- Copies web assets to Electron app directory
|
||||
- Syncs Capacitor configuration and plugins
|
||||
- Uses Electron-specific Capacitor configuration (not copied from main config)
|
||||
- Syncs Capacitor plugins for Electron platform
|
||||
- Prepares native module bindings
|
||||
|
||||
#### **Stage 3: TypeScript Compile**
|
||||
|
||||
181
doc/seed-phrase-reminder-implementation.md
Normal file
181
doc/seed-phrase-reminder-implementation.md
Normal file
@@ -0,0 +1,181 @@
|
||||
# Seed Phrase Backup Reminder Implementation
|
||||
|
||||
## Overview
|
||||
|
||||
This implementation adds a modal dialog that reminds users to back up their seed phrase if they haven't done so yet. The reminder appears after specific user actions and includes a 24-hour cooldown to avoid being too intrusive.
|
||||
|
||||
## Features
|
||||
|
||||
- **Modal Dialog**: Uses the existing notification group modal system from `App.vue`
|
||||
- **Smart Timing**: Only shows when `hasBackedUpSeed = false`
|
||||
- **24-Hour Cooldown**: Uses localStorage to prevent showing more than once per day
|
||||
- **Action-Based Triggers**: Shows after specific user actions
|
||||
- **User Choice**: "Backup Identifier Seed" or "Remind me Later" options
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Core Utility (`src/utils/seedPhraseReminder.ts`)
|
||||
|
||||
The main utility provides:
|
||||
|
||||
- `shouldShowSeedReminder(hasBackedUpSeed)`: Checks if reminder should be shown
|
||||
- `markSeedReminderShown()`: Updates localStorage timestamp
|
||||
- `createSeedReminderNotification()`: Creates the modal configuration
|
||||
- `showSeedPhraseReminder(hasBackedUpSeed, notifyFunction)`: Main function to show reminder
|
||||
|
||||
### Trigger Points
|
||||
|
||||
The reminder is shown after these user actions:
|
||||
|
||||
**Note**: The reminder is triggered by **claim creation** actions, not claim confirmations. This focuses on when users are actively creating new content rather than just confirming existing claims.
|
||||
|
||||
1. **Profile Saving** (`AccountViewView.vue`)
|
||||
- After clicking "Save Profile" button
|
||||
- Only when profile save is successful
|
||||
|
||||
2. **Claim Creation** (Multiple views)
|
||||
- `ClaimAddRawView.vue`: After submitting raw claims
|
||||
- `GiftedDialog.vue`: After creating gifts/claims
|
||||
- `GiftedDetailsView.vue`: After recording gifts/claims
|
||||
- `OfferDialog.vue`: After creating offers
|
||||
|
||||
3. **QR Code Views Exit**
|
||||
- `ContactQRScanFullView.vue`: When exiting via back button
|
||||
- `ContactQRScanShowView.vue`: When exiting via back button
|
||||
|
||||
### Modal Configuration
|
||||
|
||||
```typescript
|
||||
{
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Backup Your Identifier Seed?",
|
||||
text: "It looks like you haven't backed up your identifier seed yet. It's important to back it up as soon as possible to secure your identity.",
|
||||
yesText: "Backup Identifier Seed",
|
||||
noText: "Remind me Later",
|
||||
onYes: () => navigate to /seed-backup,
|
||||
onNo: () => mark as shown for 24 hours,
|
||||
onCancel: () => mark as shown for 24 hours
|
||||
}
|
||||
```
|
||||
|
||||
**Important**: The modal is configured with `timeout: -1` to ensure it stays open until the user explicitly interacts with one of the buttons. This prevents the dialog from closing automatically.
|
||||
|
||||
### Cooldown Mechanism
|
||||
|
||||
- **Storage Key**: `seedPhraseReminderLastShown`
|
||||
- **Cooldown Period**: 24 hours (24 * 60 * 60 * 1000 milliseconds)
|
||||
- **Implementation**: localStorage with timestamp comparison
|
||||
- **Fallback**: Shows reminder if timestamp is invalid or missing
|
||||
|
||||
## User Experience
|
||||
|
||||
### When Reminder Appears
|
||||
|
||||
- User has not backed up their seed phrase (`hasBackedUpSeed = false`)
|
||||
- At least 24 hours have passed since last reminder
|
||||
- User performs one of the trigger actions
|
||||
- **1-second delay** after the success message to allow users to see the confirmation
|
||||
|
||||
### User Options
|
||||
|
||||
1. **"Backup Identifier Seed"**: Navigates to `/seed-backup` page
|
||||
2. **"Remind me Later"**: Dismisses and won't show again for 24 hours
|
||||
3. **Cancel/Close**: Same behavior as "Remind me Later"
|
||||
|
||||
### Frequency Control
|
||||
|
||||
- **First Time**: Always shows if user hasn't backed up
|
||||
- **Subsequent**: Only shows after 24-hour cooldown
|
||||
- **Automatic Reset**: When user completes seed backup (`hasBackedUpSeed = true`)
|
||||
|
||||
## Technical Implementation
|
||||
|
||||
### Error Handling
|
||||
|
||||
- Graceful fallback if localStorage operations fail
|
||||
- Logging of errors for debugging
|
||||
- Non-blocking implementation (doesn't affect main functionality)
|
||||
|
||||
### Integration Points
|
||||
|
||||
- **Platform Service**: Uses `$accountSettings()` to check backup status
|
||||
- **Notification System**: Integrates with existing `$notify` system
|
||||
- **Router**: Uses `window.location.href` for navigation
|
||||
|
||||
### Performance Considerations
|
||||
|
||||
- Minimal localStorage operations
|
||||
- No blocking operations
|
||||
- Efficient timestamp comparisons
|
||||
- **Timing Behavior**: 1-second delay before showing reminder to improve user experience flow
|
||||
|
||||
## Testing
|
||||
|
||||
### Manual Testing Scenarios
|
||||
|
||||
1. **First Time User**
|
||||
- Create new account
|
||||
- Perform trigger action (save profile, create claim, exit QR view)
|
||||
- Verify reminder appears
|
||||
|
||||
2. **Repeat User (Within 24h)**
|
||||
- Perform trigger action
|
||||
- Verify reminder does NOT appear
|
||||
|
||||
3. **Repeat User (After 24h)**
|
||||
- Wait 24+ hours
|
||||
- Perform trigger action
|
||||
- Verify reminder appears again
|
||||
|
||||
4. **User Who Has Backed Up**
|
||||
- Complete seed backup
|
||||
- Perform trigger action
|
||||
- Verify reminder does NOT appear
|
||||
|
||||
5. **QR Code View Exit**
|
||||
- Navigate to QR code view (full or show)
|
||||
- Exit via back button
|
||||
- Verify reminder appears (if conditions are met)
|
||||
|
||||
### Browser Testing
|
||||
|
||||
- Test localStorage functionality
|
||||
- Verify timestamp handling
|
||||
- Check navigation to seed backup page
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Potential Improvements
|
||||
|
||||
1. **Customizable Cooldown**: Allow users to set reminder frequency
|
||||
2. **Progressive Urgency**: Increase reminder frequency over time
|
||||
3. **Analytics**: Track reminder effectiveness and user response
|
||||
4. **A/B Testing**: Test different reminder messages and timing
|
||||
|
||||
### Configuration Options
|
||||
|
||||
- Reminder frequency settings
|
||||
- Custom reminder messages
|
||||
- Different trigger conditions
|
||||
- Integration with other notification systems
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Monitoring
|
||||
|
||||
- Check localStorage usage in browser dev tools
|
||||
- Monitor user feedback about reminder frequency
|
||||
- Track navigation success to seed backup page
|
||||
|
||||
### Updates
|
||||
|
||||
- Modify reminder text in `createSeedReminderNotification()`
|
||||
- Adjust cooldown period in `REMINDER_COOLDOWN_MS` constant
|
||||
- Add new trigger points as needed
|
||||
|
||||
## Conclusion
|
||||
|
||||
This implementation provides a non-intrusive way to remind users about seed phrase backup while respecting their preferences and avoiding notification fatigue. The 24-hour cooldown ensures users aren't overwhelmed while maintaining the importance of the security reminder.
|
||||
|
||||
The feature is fully integrated with the existing codebase architecture and follows established patterns for notifications, error handling, and user interaction.
|
||||
116
electron/capacitor.config.ts
Normal file
116
electron/capacitor.config.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import { CapacitorConfig } from '@capacitor/cli';
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'app.timesafari',
|
||||
appName: 'TimeSafari',
|
||||
webDir: 'dist',
|
||||
server: {
|
||||
cleartext: true
|
||||
},
|
||||
plugins: {
|
||||
App: {
|
||||
appUrlOpen: {
|
||||
handlers: [
|
||||
{
|
||||
url: 'timesafari://*',
|
||||
autoVerify: true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
SplashScreen: {
|
||||
launchShowDuration: 3000,
|
||||
launchAutoHide: true,
|
||||
backgroundColor: '#ffffff',
|
||||
androidSplashResourceName: 'splash',
|
||||
androidScaleType: 'CENTER_CROP',
|
||||
showSpinner: false,
|
||||
androidSpinnerStyle: 'large',
|
||||
iosSpinnerStyle: 'small',
|
||||
spinnerColor: '#999999',
|
||||
splashFullScreen: true,
|
||||
splashImmersive: true
|
||||
},
|
||||
CapSQLite: {
|
||||
iosDatabaseLocation: 'Library/CapacitorDatabase',
|
||||
iosIsEncryption: false,
|
||||
iosBiometric: {
|
||||
biometricAuth: false,
|
||||
biometricTitle: 'Biometric login for TimeSafari'
|
||||
},
|
||||
androidIsEncryption: false,
|
||||
androidBiometric: {
|
||||
biometricAuth: false,
|
||||
biometricTitle: 'Biometric login for TimeSafari'
|
||||
},
|
||||
electronIsEncryption: false
|
||||
}
|
||||
},
|
||||
ios: {
|
||||
contentInset: 'never',
|
||||
allowsLinkPreview: true,
|
||||
scrollEnabled: true,
|
||||
limitsNavigationsToAppBoundDomains: true,
|
||||
backgroundColor: '#ffffff',
|
||||
allowNavigation: [
|
||||
'*.timesafari.app',
|
||||
'*.jsdelivr.net',
|
||||
'api.endorser.ch'
|
||||
]
|
||||
},
|
||||
android: {
|
||||
allowMixedContent: true,
|
||||
captureInput: true,
|
||||
webContentsDebuggingEnabled: false,
|
||||
allowNavigation: [
|
||||
'*.timesafari.app',
|
||||
'*.jsdelivr.net',
|
||||
'api.endorser.ch',
|
||||
'10.0.2.2:3000'
|
||||
]
|
||||
},
|
||||
electron: {
|
||||
deepLinking: {
|
||||
schemes: ['timesafari']
|
||||
},
|
||||
buildOptions: {
|
||||
appId: 'app.timesafari',
|
||||
productName: 'TimeSafari',
|
||||
directories: {
|
||||
output: 'dist-electron-packages'
|
||||
},
|
||||
files: [
|
||||
'dist/**/*',
|
||||
'electron/**/*'
|
||||
],
|
||||
mac: {
|
||||
category: 'public.app-category.productivity',
|
||||
target: [
|
||||
{
|
||||
target: 'dmg',
|
||||
arch: ['x64', 'arm64']
|
||||
}
|
||||
]
|
||||
},
|
||||
win: {
|
||||
target: [
|
||||
{
|
||||
target: 'nsis',
|
||||
arch: ['x64']
|
||||
}
|
||||
]
|
||||
},
|
||||
linux: {
|
||||
target: [
|
||||
{
|
||||
target: 'AppImage',
|
||||
arch: ['x64']
|
||||
}
|
||||
],
|
||||
category: 'Utility'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
1
electron/package-lock.json
generated
1
electron/package-lock.json
generated
@@ -56,7 +56,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"
|
||||
},
|
||||
|
||||
@@ -50,6 +50,7 @@ process.stderr.on('error', (err) => {
|
||||
const trayMenuTemplate: (MenuItemConstructorOptions | MenuItem)[] = [new MenuItem({ label: 'Quit App', role: 'quit' })];
|
||||
const appMenuBarMenuTemplate: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||
{ role: process.platform === 'darwin' ? 'appMenu' : 'fileMenu' },
|
||||
{ role: 'editMenu' },
|
||||
{ role: 'viewMenu' },
|
||||
];
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ export class ElectronCapacitorApp {
|
||||
];
|
||||
private AppMenuBarMenuTemplate: (MenuItem | MenuItemConstructorOptions)[] = [
|
||||
{ role: process.platform === 'darwin' ? 'appMenu' : 'fileMenu' },
|
||||
{ role: 'editMenu' },
|
||||
{ role: 'viewMenu' },
|
||||
];
|
||||
private mainWindowState;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"include": ["./src/**/*", "./capacitor.config.ts", "./capacitor.config.js"],
|
||||
"include": ["./src/**/*"],
|
||||
"compilerOptions": {
|
||||
"outDir": "./build",
|
||||
"importHelpers": true,
|
||||
|
||||
@@ -181,7 +181,7 @@ sync_capacitor() {
|
||||
copy_web_assets() {
|
||||
log_info "Copying web assets to Electron"
|
||||
safe_execute "Copying assets" "cp -r dist/* electron/app/"
|
||||
safe_execute "Copying config" "cp capacitor.config.json electron/capacitor.config.json"
|
||||
# Note: Electron has its own capacitor.config.ts file, so we don't copy the main config
|
||||
}
|
||||
|
||||
# Compile TypeScript
|
||||
|
||||
@@ -16,6 +16,12 @@ messages * - Conditional UI based on platform capabilities * * @component *
|
||||
:to="{ name: 'seed-backup' }"
|
||||
:class="backupButtonClasses"
|
||||
>
|
||||
<!-- Notification dot - show while the user has not yet backed up their seed phrase -->
|
||||
<font-awesome
|
||||
v-if="!hasBackedUpSeed"
|
||||
icon="circle"
|
||||
class="absolute -right-[8px] -top-[8px] text-rose-500 text-[14px] border border-white rounded-full"
|
||||
></font-awesome>
|
||||
Backup Identifier Seed
|
||||
</router-link>
|
||||
|
||||
@@ -98,6 +104,12 @@ export default class DataExportSection extends Vue {
|
||||
*/
|
||||
isExporting = false;
|
||||
|
||||
/**
|
||||
* Flag indicating if the user has backed up their seed phrase
|
||||
* Used to control the visibility of the notification dot
|
||||
*/
|
||||
hasBackedUpSeed = false;
|
||||
|
||||
/**
|
||||
* Notification helper for consistent notification patterns
|
||||
* Created as a getter to ensure $notify is available when called
|
||||
@@ -129,7 +141,7 @@ export default class DataExportSection extends Vue {
|
||||
* CSS classes for the backup button (router link)
|
||||
*/
|
||||
get backupButtonClasses(): string {
|
||||
return "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 mb-2 mt-2";
|
||||
return "block relative 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 mb-2 mt-2";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,6 +230,22 @@ export default class DataExportSection extends Vue {
|
||||
|
||||
created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
this.loadSeedBackupStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the seed backup status from account settings
|
||||
* Updates the hasBackedUpSeed flag to control notification dot visibility
|
||||
*/
|
||||
private async loadSeedBackupStatus(): Promise<void> {
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
this.hasBackedUpSeed = !!settings.hasBackedUpSeed;
|
||||
} catch (err: unknown) {
|
||||
logger.error("Failed to load seed backup status:", err);
|
||||
// Default to false (show notification dot) if we can't load the setting
|
||||
this.hasBackedUpSeed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -82,6 +82,7 @@ import GiftDetailsStep from "../components/GiftDetailsStep.vue";
|
||||
import { PlanData } from "../interfaces/records";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS, NotifyFunction } from "@/utils/notify";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
import {
|
||||
NOTIFY_GIFT_ERROR_NEGATIVE_AMOUNT,
|
||||
NOTIFY_GIFT_ERROR_NO_DESCRIPTION,
|
||||
@@ -411,6 +412,15 @@ export default class GiftedDialog extends Vue {
|
||||
);
|
||||
} else {
|
||||
this.safeNotify.success("That gift was recorded.", TIMEOUTS.VERY_LONG);
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
|
||||
if (this.callbackOnSuccess) {
|
||||
this.callbackOnSuccess(amount);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ import * as libsUtil from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
import {
|
||||
NOTIFY_OFFER_SETTINGS_ERROR,
|
||||
NOTIFY_OFFER_RECORDING,
|
||||
@@ -299,6 +300,14 @@ export default class OfferDialog extends Vue {
|
||||
);
|
||||
} else {
|
||||
this.notify.success(NOTIFY_OFFER_SUCCESS.message, TIMEOUTS.VERY_LONG);
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -84,7 +84,8 @@ export default class UserNameDialog extends Vue {
|
||||
*/
|
||||
async open(aCallback?: (name?: string) => void) {
|
||||
this.callback = aCallback || this.callback;
|
||||
const settings = await this.$settings();
|
||||
// Load from account-specific settings instead of master settings
|
||||
const settings = await this.$accountSettings();
|
||||
this.givenName = settings.firstName || "";
|
||||
this.visible = true;
|
||||
}
|
||||
@@ -95,7 +96,18 @@ export default class UserNameDialog extends Vue {
|
||||
*/
|
||||
async onClickSaveChanges() {
|
||||
try {
|
||||
await this.$updateSettings({ firstName: this.givenName });
|
||||
// Get the current active DID to save to user-specific settings
|
||||
const settings = await this.$accountSettings();
|
||||
const activeDid = settings.activeDid;
|
||||
|
||||
if (activeDid) {
|
||||
// Save to user-specific settings for the current identity
|
||||
await this.$saveUserSettings(activeDid, { firstName: this.givenName });
|
||||
} else {
|
||||
// Fallback to master settings if no active DID
|
||||
await this.$saveSettings({ firstName: this.givenName });
|
||||
}
|
||||
|
||||
this.visible = false;
|
||||
this.callback(this.givenName);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1689,3 +1689,11 @@ export const NOTIFY_CONTACTS_ADDED_CONFIRM = {
|
||||
title: "They're Added To Your List",
|
||||
message: "Would you like to go to the main page now?",
|
||||
};
|
||||
|
||||
// ImportAccountView.vue specific constants
|
||||
// Used in: ImportAccountView.vue (onImportClick method - duplicate account warning)
|
||||
export const NOTIFY_DUPLICATE_ACCOUNT_IMPORT = {
|
||||
title: "Account Already Imported",
|
||||
message:
|
||||
"This account has already been imported. Please use a different seed phrase or check your existing accounts.",
|
||||
};
|
||||
|
||||
@@ -124,6 +124,12 @@ const MIGRATIONS = [
|
||||
ALTER TABLE contacts ADD COLUMN iViewContent BOOLEAN DEFAULT TRUE;
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "003_add_hasBackedUpSeed_to_settings",
|
||||
sql: `
|
||||
ALTER TABLE settings ADD COLUMN hasBackedUpSeed BOOLEAN DEFAULT FALSE;
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ export type Settings = {
|
||||
finishedOnboarding?: boolean; // the user has completed the onboarding process
|
||||
|
||||
firstName?: string; // user's full name, may be null if unwanted for a particular account
|
||||
hasBackedUpSeed?: boolean; // tracks whether the user has backed up their seed phrase
|
||||
hideRegisterPromptOnNewContact?: boolean;
|
||||
isRegistered?: boolean;
|
||||
// imageServer?: string; // if we want to allow modification then we should make image functionality optional -- or at least customizable
|
||||
|
||||
@@ -1313,6 +1313,28 @@ export const capitalizeAndInsertSpacesBeforeCaps = (text: string) => {
|
||||
: text[0].toUpperCase() + text.substr(1).replace(/([A-Z])/g, " $1");
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats type string for display by adding spaces before capitals
|
||||
* and optionally adds an appropriate article prefix (a/an)
|
||||
*
|
||||
* @param text - Text to format
|
||||
* @returns Formatted string with article prefix
|
||||
*/
|
||||
export const capitalizeAndInsertSpacesBeforeCapsWithAPrefix = (
|
||||
text: string,
|
||||
): string => {
|
||||
const word = capitalizeAndInsertSpacesBeforeCaps(text);
|
||||
if (word) {
|
||||
// if the word starts with a vowel, use "an" instead of "a"
|
||||
const firstLetter = word[0].toLowerCase();
|
||||
const vowels = ["a", "e", "i", "o", "u"];
|
||||
const particle = vowels.includes(firstLetter) ? "an" : "a";
|
||||
return particle + " " + word;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
return readable summary of claim, or something generic
|
||||
|
||||
|
||||
175
src/libs/util.ts
175
src/libs/util.ts
@@ -160,6 +160,41 @@ export const isGiveAction = (
|
||||
return isGiveClaimType(veriClaim.claimType);
|
||||
};
|
||||
|
||||
export interface OfferFulfillment {
|
||||
offerHandleId: string;
|
||||
offerType: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract offer fulfillment information from the fulfills field
|
||||
* Handles both array and single object cases
|
||||
*/
|
||||
export const extractOfferFulfillment = (fulfills: any): OfferFulfillment | null => {
|
||||
if (!fulfills) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Handle both array and single object cases
|
||||
let offerFulfill = null;
|
||||
|
||||
if (Array.isArray(fulfills)) {
|
||||
// Find the Offer in the fulfills array
|
||||
offerFulfill = fulfills.find((item) => item["@type"] === "Offer");
|
||||
} else if (fulfills["@type"] === "Offer") {
|
||||
// fulfills is a single Offer object
|
||||
offerFulfill = fulfills;
|
||||
}
|
||||
|
||||
if (offerFulfill) {
|
||||
return {
|
||||
offerHandleId: offerFulfill.identifier,
|
||||
offerType: offerFulfill["@type"],
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const shortDid = (did: string) => {
|
||||
if (did.startsWith("did:peer:")) {
|
||||
return (
|
||||
@@ -614,57 +649,64 @@ export const retrieveAllAccountsMetadata = async (): Promise<
|
||||
return result;
|
||||
};
|
||||
|
||||
export const DUPLICATE_ACCOUNT_ERROR = "Cannot import duplicate account.";
|
||||
|
||||
/**
|
||||
* Saves a new identity to both SQL and Dexie databases
|
||||
* Saves a new identity to SQL database
|
||||
*/
|
||||
export async function saveNewIdentity(
|
||||
identity: IIdentifier,
|
||||
mnemonic: string,
|
||||
derivationPath: string,
|
||||
): Promise<void> {
|
||||
try {
|
||||
// add to the new sql db
|
||||
const platformService = await getPlatformService();
|
||||
// add to the new sql db
|
||||
const platformService = await getPlatformService();
|
||||
|
||||
const secrets = await platformService.dbQuery(
|
||||
`SELECT secretBase64 FROM secret`,
|
||||
);
|
||||
if (!secrets?.values?.length || !secrets.values[0]?.length) {
|
||||
throw new Error(
|
||||
"No initial encryption supported. We recommend you clear your data and start over.",
|
||||
);
|
||||
}
|
||||
// Check if account already exists before attempting to save
|
||||
const existingAccount = await platformService.dbQuery(
|
||||
"SELECT did FROM accounts WHERE did = ?",
|
||||
[identity.did],
|
||||
);
|
||||
|
||||
const secretBase64 = secrets.values[0][0] as string;
|
||||
|
||||
const secret = base64ToArrayBuffer(secretBase64);
|
||||
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);
|
||||
|
||||
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 platformService.updateDefaultSettings({ activeDid: identity.did });
|
||||
|
||||
await platformService.insertNewDidIntoSettings(identity.did);
|
||||
} catch (error) {
|
||||
logger.error("Failed to update default settings:", error);
|
||||
if (existingAccount?.values?.length) {
|
||||
throw new Error(
|
||||
"Failed to set default settings. Please try again or restart the app.",
|
||||
`Account with DID ${identity.did} already exists. ${DUPLICATE_ACCOUNT_ERROR}`,
|
||||
);
|
||||
}
|
||||
|
||||
const secrets = await platformService.dbQuery(
|
||||
`SELECT secretBase64 FROM secret`,
|
||||
);
|
||||
if (!secrets?.values?.length || !secrets.values[0]?.length) {
|
||||
throw new Error(
|
||||
"No initial encryption supported. We recommend you clear your data and start over.",
|
||||
);
|
||||
}
|
||||
|
||||
const secretBase64 = secrets.values[0][0] as string;
|
||||
|
||||
const secret = base64ToArrayBuffer(secretBase64);
|
||||
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);
|
||||
|
||||
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 platformService.updateDefaultSettings({ activeDid: identity.did });
|
||||
|
||||
await platformService.insertNewDidIntoSettings(identity.did);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1032,3 +1074,58 @@ export async function importFromMnemonic(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an account with the given DID already exists in the database
|
||||
*
|
||||
* @param did - The DID to check for duplicates
|
||||
* @returns Promise<boolean> - True if account already exists, false otherwise
|
||||
* @throws Error if database query fails
|
||||
*/
|
||||
export async function checkForDuplicateAccount(did: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Checks if an account with the given DID already exists in the database
|
||||
*
|
||||
* @param mnemonic - The mnemonic phrase to derive DID from
|
||||
* @param derivationPath - The derivation path to use
|
||||
* @returns Promise<boolean> - True if account already exists, false otherwise
|
||||
* @throws Error if database query fails
|
||||
*/
|
||||
export async function checkForDuplicateAccount(
|
||||
mnemonic: string,
|
||||
derivationPath: string,
|
||||
): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Implementation of checkForDuplicateAccount with overloaded signatures
|
||||
*/
|
||||
export async function checkForDuplicateAccount(
|
||||
didOrMnemonic: string,
|
||||
derivationPath?: string,
|
||||
): Promise<boolean> {
|
||||
let didToCheck: string;
|
||||
|
||||
if (derivationPath) {
|
||||
// Derive the DID from mnemonic and derivation path
|
||||
const [address, privateHex, publicHex] = deriveAddress(
|
||||
didOrMnemonic.trim().toLowerCase(),
|
||||
derivationPath,
|
||||
);
|
||||
|
||||
const newId = newIdentifier(address, privateHex, publicHex, derivationPath);
|
||||
didToCheck = newId.did;
|
||||
} else {
|
||||
// Use the provided DID directly
|
||||
didToCheck = didOrMnemonic;
|
||||
}
|
||||
|
||||
// Check if an account with this DID already exists
|
||||
const platformService = await getPlatformService();
|
||||
const existingAccount = await platformService.dbQuery(
|
||||
"SELECT did FROM accounts WHERE did = ?",
|
||||
[didToCheck],
|
||||
);
|
||||
|
||||
return (existingAccount?.values?.length ?? 0) > 0;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
// Generate a short random ID for this scanner instance
|
||||
this.id = Math.random().toString(36).substring(2, 8).toUpperCase();
|
||||
this.options = options ?? {};
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Initializing scanner with options:`,
|
||||
{
|
||||
...this.options,
|
||||
@@ -49,7 +49,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
this.context = this.canvas.getContext("2d", { willReadFrequently: true });
|
||||
this.video = document.createElement("video");
|
||||
this.video.setAttribute("playsinline", "true"); // Required for iOS
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] DOM elements created successfully`,
|
||||
);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
this.cameraStateListeners.forEach((listener) => {
|
||||
try {
|
||||
listener.onStateChange(state, message);
|
||||
logger.info(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Camera state changed to: ${state}`,
|
||||
{
|
||||
state,
|
||||
@@ -89,7 +89,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
async checkPermissions(): Promise<boolean> {
|
||||
try {
|
||||
this.updateCameraState("initializing", "Checking camera permissions...");
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Checking camera permissions...`,
|
||||
);
|
||||
|
||||
@@ -99,7 +99,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
const permissions = await navigator.permissions.query({
|
||||
name: "camera" as PermissionName,
|
||||
});
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Permission state from Permissions API:`,
|
||||
permissions.state,
|
||||
);
|
||||
@@ -165,7 +165,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
"initializing",
|
||||
"Requesting camera permissions...",
|
||||
);
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Requesting camera permissions...`,
|
||||
);
|
||||
|
||||
@@ -175,7 +175,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
(device) => device.kind === "videoinput",
|
||||
);
|
||||
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Found video devices:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Found video devices:`, {
|
||||
count: videoDevices.length,
|
||||
devices: videoDevices.map((d) => ({ id: d.deviceId, label: d.label })),
|
||||
userAgent: navigator.userAgent,
|
||||
@@ -188,7 +188,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
}
|
||||
|
||||
// Try to get a stream with specific constraints
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Requesting camera stream with constraints:`,
|
||||
{
|
||||
facingMode: "environment",
|
||||
@@ -210,7 +210,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
|
||||
// Stop the test stream immediately
|
||||
stream.getTracks().forEach((track) => {
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Stopping test track:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Stopping test track:`, {
|
||||
kind: track.kind,
|
||||
label: track.label,
|
||||
readyState: track.readyState,
|
||||
@@ -275,12 +275,12 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
|
||||
async isSupported(): Promise<boolean> {
|
||||
try {
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Checking browser support...`,
|
||||
);
|
||||
// Check for secure context first
|
||||
if (!window.isSecureContext) {
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Camera access requires HTTPS (secure context)`,
|
||||
);
|
||||
return false;
|
||||
@@ -300,7 +300,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
(device) => device.kind === "videoinput",
|
||||
);
|
||||
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Device support check:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Device support check:`, {
|
||||
hasSecureContext: window.isSecureContext,
|
||||
hasMediaDevices: !!navigator.mediaDevices,
|
||||
hasGetUserMedia: !!navigator.mediaDevices?.getUserMedia,
|
||||
@@ -379,7 +379,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
|
||||
// Log scan attempt every 100 frames or 1 second
|
||||
if (this.scanAttempts % 100 === 0 || timeSinceLastScan >= 1000) {
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Scanning frame:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Scanning frame:`, {
|
||||
attempt: this.scanAttempts,
|
||||
dimensions: {
|
||||
width: this.canvas.width,
|
||||
@@ -421,7 +421,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
!code.data ||
|
||||
code.data.length === 0;
|
||||
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] QR Code detected:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] QR Code detected:`, {
|
||||
data: code.data,
|
||||
location: code.location,
|
||||
attempts: this.scanAttempts,
|
||||
@@ -512,13 +512,13 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
this.scanAttempts = 0;
|
||||
this.lastScanTime = Date.now();
|
||||
this.updateCameraState("initializing", "Starting camera...");
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Starting scan with options:`,
|
||||
this.options,
|
||||
);
|
||||
|
||||
// Get camera stream with options
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Requesting camera stream...`,
|
||||
);
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({
|
||||
@@ -531,7 +531,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
|
||||
this.updateCameraState("active", "Camera is active");
|
||||
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Camera stream obtained:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Camera stream obtained:`, {
|
||||
tracks: this.stream.getTracks().map((t) => ({
|
||||
kind: t.kind,
|
||||
label: t.label,
|
||||
@@ -550,14 +550,14 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
this.video.style.display = "none";
|
||||
}
|
||||
await this.video.play();
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Video element started playing`,
|
||||
);
|
||||
}
|
||||
|
||||
// Emit stream to component
|
||||
this.events.emit("stream", this.stream);
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Stream event emitted`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Stream event emitted`);
|
||||
|
||||
// Start QR code scanning
|
||||
this.scanQRCode();
|
||||
@@ -595,7 +595,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
}
|
||||
|
||||
try {
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Stopping scan`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Stopping scan`, {
|
||||
scanAttempts: this.scanAttempts,
|
||||
duration: Date.now() - this.lastScanTime,
|
||||
});
|
||||
@@ -604,7 +604,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
if (this.animationFrameId !== null) {
|
||||
cancelAnimationFrame(this.animationFrameId);
|
||||
this.animationFrameId = null;
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Animation frame cancelled`,
|
||||
);
|
||||
}
|
||||
@@ -613,13 +613,13 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
if (this.video) {
|
||||
this.video.pause();
|
||||
this.video.srcObject = null;
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Video element stopped`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Video element stopped`);
|
||||
}
|
||||
|
||||
// Stop all tracks in the stream
|
||||
if (this.stream) {
|
||||
this.stream.getTracks().forEach((track) => {
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Stopping track:`, {
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Stopping track:`, {
|
||||
kind: track.kind,
|
||||
label: track.label,
|
||||
readyState: track.readyState,
|
||||
@@ -631,7 +631,7 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
|
||||
// Emit stream stopped event
|
||||
this.events.emit("stream", null);
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Stream stopped event emitted`,
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -643,17 +643,17 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
throw error;
|
||||
} finally {
|
||||
this.isScanning = false;
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Scan stopped successfully`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Scan stopped successfully`);
|
||||
}
|
||||
}
|
||||
|
||||
addListener(listener: ScanListener): void {
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Adding scan listener`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Adding scan listener`);
|
||||
this.scanListener = listener;
|
||||
}
|
||||
|
||||
onStream(callback: (stream: MediaStream | null) => void): void {
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Adding stream event listener`,
|
||||
);
|
||||
this.events.on("stream", callback);
|
||||
@@ -661,24 +661,24 @@ export class WebInlineQRScanner implements QRScannerService {
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
try {
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Starting cleanup`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Starting cleanup`);
|
||||
await this.stopScan();
|
||||
this.events.removeAllListeners();
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Event listeners removed`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Event listeners removed`);
|
||||
|
||||
// Clean up DOM elements
|
||||
if (this.video) {
|
||||
this.video.remove();
|
||||
this.video = null;
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Video element removed`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Video element removed`);
|
||||
}
|
||||
if (this.canvas) {
|
||||
this.canvas.remove();
|
||||
this.canvas = null;
|
||||
logger.error(`[WebInlineQRScanner:${this.id}] Canvas element removed`);
|
||||
logger.debug(`[WebInlineQRScanner:${this.id}] Canvas element removed`);
|
||||
}
|
||||
this.context = null;
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`[WebInlineQRScanner:${this.id}] Cleanup completed successfully`,
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
90
src/utils/seedPhraseReminder.ts
Normal file
90
src/utils/seedPhraseReminder.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { NotificationIface } from "@/constants/app";
|
||||
|
||||
const SEED_REMINDER_KEY = "seedPhraseReminderLastShown";
|
||||
const REMINDER_COOLDOWN_MS = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
|
||||
|
||||
/**
|
||||
* Checks if the seed phrase backup reminder should be shown
|
||||
* @param hasBackedUpSeed - Whether the user has backed up their seed phrase
|
||||
* @returns true if the reminder should be shown, false otherwise
|
||||
*/
|
||||
export function shouldShowSeedReminder(hasBackedUpSeed: boolean): boolean {
|
||||
// Don't show if user has already backed up
|
||||
if (hasBackedUpSeed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check localStorage for last shown time
|
||||
const lastShown = localStorage.getItem(SEED_REMINDER_KEY);
|
||||
if (!lastShown) {
|
||||
return true; // First time, show the reminder
|
||||
}
|
||||
|
||||
try {
|
||||
const lastShownTime = parseInt(lastShown, 10);
|
||||
const now = Date.now();
|
||||
const timeSinceLastShown = now - lastShownTime;
|
||||
|
||||
// Show if more than 24 hours have passed
|
||||
return timeSinceLastShown >= REMINDER_COOLDOWN_MS;
|
||||
} catch (error) {
|
||||
// If there's an error parsing the timestamp, show the reminder
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the seed phrase reminder as shown by updating localStorage
|
||||
*/
|
||||
export function markSeedReminderShown(): void {
|
||||
localStorage.setItem(SEED_REMINDER_KEY, Date.now().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the seed phrase backup reminder notification
|
||||
* @returns NotificationIface configuration for the reminder modal
|
||||
*/
|
||||
export function createSeedReminderNotification(): NotificationIface {
|
||||
return {
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Backup Your Identifier Seed?",
|
||||
text: "It looks like you haven't backed up your identifier seed yet. It's important to back it up as soon as possible to secure your identity.",
|
||||
yesText: "Backup Identifier Seed",
|
||||
noText: "Remind me Later",
|
||||
onYes: async () => {
|
||||
// Navigate to seed backup page
|
||||
window.location.href = "/seed-backup";
|
||||
},
|
||||
onNo: async () => {
|
||||
// Mark as shown so it won't appear again for 24 hours
|
||||
markSeedReminderShown();
|
||||
},
|
||||
onCancel: async () => {
|
||||
// Mark as shown so it won't appear again for 24 hours
|
||||
markSeedReminderShown();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the seed phrase backup reminder if conditions are met
|
||||
* @param hasBackedUpSeed - Whether the user has backed up their seed phrase
|
||||
* @param notifyFunction - Function to show notifications
|
||||
* @returns true if the reminder was shown, false otherwise
|
||||
*/
|
||||
export function showSeedPhraseReminder(
|
||||
hasBackedUpSeed: boolean,
|
||||
notifyFunction: (notification: NotificationIface, timeout?: number) => void,
|
||||
): boolean {
|
||||
if (shouldShowSeedReminder(hasBackedUpSeed)) {
|
||||
const notification = createSeedReminderNotification();
|
||||
// Add 1-second delay before showing the modal to allow success message to be visible
|
||||
setTimeout(() => {
|
||||
// Pass -1 as timeout to ensure modal stays open until user interaction
|
||||
notifyFunction(notification, -1);
|
||||
}, 1000);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -811,6 +811,7 @@ import { logger } from "../utils/logger";
|
||||
import { PlatformServiceMixin } from "../utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { ACCOUNT_VIEW_CONSTANTS } from "@/constants/accountView";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
import {
|
||||
AccountSettings,
|
||||
isApiError,
|
||||
@@ -1695,6 +1696,14 @@ export default class AccountViewView extends Vue {
|
||||
);
|
||||
if (success) {
|
||||
this.notify.success(ACCOUNT_VIEW_CONSTANTS.SUCCESS.PROFILE_SAVED);
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
} else {
|
||||
this.notify.error(ACCOUNT_VIEW_CONSTANTS.ERRORS.PROFILE_SAVE_ERROR);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import { Router, RouteLocationNormalizedLoaded } from "vue-router";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
|
||||
// Type guard for API responses
|
||||
function isApiResponse(response: unknown): response is AxiosResponse {
|
||||
@@ -223,6 +224,14 @@ export default class ClaimAddRawView extends Vue {
|
||||
);
|
||||
if (result.success) {
|
||||
this.notify.success("Claim submitted.", TIMEOUTS.LONG);
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
} else {
|
||||
logger.error("Got error submitting the claim:", result);
|
||||
this.notify.error(
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
<div class="flex columns-3">
|
||||
<h2 class="text-md font-bold w-full">
|
||||
{{
|
||||
capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType || "")
|
||||
serverUtil.capitalizeAndInsertSpacesBeforeCaps(
|
||||
veriClaim.claimType || "",
|
||||
)
|
||||
}}
|
||||
<button
|
||||
v-if="canEditClaim"
|
||||
@@ -106,77 +108,91 @@
|
||||
</div>
|
||||
|
||||
<!-- Fullfills Links -->
|
||||
|
||||
<!-- fullfills links for a give -->
|
||||
<div v-if="detailsForGive?.fulfillsPlanHandleId" class="mt-4">
|
||||
<router-link
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(detailsForGive?.fulfillsPlanHandleId)
|
||||
"
|
||||
class="text-blue-500 mt-2"
|
||||
>
|
||||
Fulfills a bigger plan...
|
||||
</router-link>
|
||||
</div>
|
||||
<!-- if there's another, it's probably fulfilling an offer, too -->
|
||||
<div
|
||||
v-if="
|
||||
detailsForGive?.fulfillsType &&
|
||||
detailsForGive?.fulfillsType !== 'PlanAction' &&
|
||||
detailsForGive?.fulfillsHandleId
|
||||
"
|
||||
>
|
||||
<!-- router-link to /claim/ only changes URL path -->
|
||||
<a
|
||||
class="text-blue-500 mt-4 cursor-pointer"
|
||||
@click="
|
||||
showDifferentClaimPage(detailsForGive?.fulfillsHandleId)
|
||||
"
|
||||
>
|
||||
Fulfills
|
||||
{{
|
||||
capitalizeAndInsertSpacesBeforeCaps(
|
||||
detailsForGive.fulfillsType,
|
||||
)
|
||||
}}...
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- fullfills links for an offer -->
|
||||
<div v-if="detailsForOffer?.fulfillsPlanHandleId">
|
||||
<router-link
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(detailsForOffer?.fulfillsPlanHandleId)
|
||||
"
|
||||
class="text-blue-500 mt-4"
|
||||
>
|
||||
Offered to a bigger plan...
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<!-- Providers -->
|
||||
<div v-if="providersForGive?.length > 0" class="mt-4">
|
||||
<span>Other assistance provided by:</span>
|
||||
<ul class="ml-4">
|
||||
<li
|
||||
v-for="provider of providersForGive"
|
||||
:key="provider.identifier"
|
||||
class="list-disc ml-4"
|
||||
<div class="mt-4 empty:hidden">
|
||||
<!-- fullfills links for a give -->
|
||||
<div v-if="detailsForGive?.fulfillsPlanHandleId">
|
||||
<router-link
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(detailsForGive?.fulfillsPlanHandleId)
|
||||
"
|
||||
class="text-blue-500 mt-2"
|
||||
>
|
||||
<div class="flex gap-4">
|
||||
<div class="grow overflow-hidden">
|
||||
<a
|
||||
class="text-blue-500 mt-4 cursor-pointer"
|
||||
@click="handleProviderClick(provider)"
|
||||
>
|
||||
an activity...
|
||||
</a>
|
||||
This fulfills a bigger plan
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<!-- Show offer fulfillment if this give fulfills an offer -->
|
||||
<div v-if="detailsForGiveOfferFulfillment?.offerHandleId">
|
||||
<!-- router-link to /claim/ only changes URL path -->
|
||||
<a
|
||||
class="text-blue-500 mt-4 cursor-pointer"
|
||||
@click="
|
||||
showDifferentClaimPage(
|
||||
detailsForGiveOfferFulfillment.offerHandleId,
|
||||
)
|
||||
"
|
||||
>
|
||||
This fulfills
|
||||
{{
|
||||
serverUtil.capitalizeAndInsertSpacesBeforeCapsWithAPrefix(
|
||||
detailsForGiveOfferFulfillment.offerType || "Offer",
|
||||
)
|
||||
}}
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- fullfills links for an offer -->
|
||||
<div v-if="detailsForOffer?.fulfillsPlanHandleId">
|
||||
<router-link
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(detailsForOffer?.fulfillsPlanHandleId)
|
||||
"
|
||||
class="text-blue-500 mt-4"
|
||||
>
|
||||
Offered to a bigger plan
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<!-- Providers -->
|
||||
<div v-if="providersForGive?.length > 0">
|
||||
<span>Other assistance provided by:</span>
|
||||
<ul class="ml-4">
|
||||
<li
|
||||
v-for="provider of providersForGive"
|
||||
:key="provider.identifier"
|
||||
class="list-disc ml-4"
|
||||
>
|
||||
<div class="flex gap-4">
|
||||
<div class="grow overflow-hidden">
|
||||
<a
|
||||
class="text-blue-500 mt-4 cursor-pointer"
|
||||
@click="handleProviderClick(provider)"
|
||||
>
|
||||
an activity
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -556,6 +572,17 @@ export default class ClaimView extends Vue {
|
||||
fulfillsPlanHandleId?: string;
|
||||
fulfillsType?: string;
|
||||
fulfillsHandleId?: string;
|
||||
fullClaim?: {
|
||||
fulfills?: Array<{
|
||||
"@type": string;
|
||||
identifier?: string;
|
||||
}>;
|
||||
};
|
||||
} | null = null;
|
||||
// Additional offer information extracted from the fulfills array
|
||||
detailsForGiveOfferFulfillment: {
|
||||
offerHandleId?: string;
|
||||
offerType?: string;
|
||||
} | null = null;
|
||||
detailsForOffer: { fulfillsPlanHandleId?: string } | null = null;
|
||||
// Project information for fulfillsPlanHandleId
|
||||
@@ -689,6 +716,7 @@ export default class ClaimView extends Vue {
|
||||
this.confsVisibleToIdList = [];
|
||||
this.detailsForGive = null;
|
||||
this.detailsForOffer = null;
|
||||
this.detailsForGiveOfferFulfillment = null;
|
||||
this.projectInfo = null;
|
||||
this.fullClaim = null;
|
||||
this.fullClaimDump = "";
|
||||
@@ -701,6 +729,15 @@ export default class ClaimView extends Vue {
|
||||
this.veriClaimDidsVisible = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract offer fulfillment information from the fulfills array
|
||||
*/
|
||||
extractOfferFulfillment() {
|
||||
this.detailsForGiveOfferFulfillment = libsUtil.extractOfferFulfillment(
|
||||
this.detailsForGive?.fullClaim?.fulfills
|
||||
);
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// UTILITY METHODS
|
||||
// =================================================
|
||||
@@ -758,13 +795,6 @@ export default class ClaimView extends Vue {
|
||||
this.canShare = !!navigator.share;
|
||||
}
|
||||
|
||||
// insert a space before any capital letters except the initial letter
|
||||
// (and capitalize initial letter, just in case)
|
||||
capitalizeAndInsertSpacesBeforeCaps(text: string): string {
|
||||
if (!text) return "";
|
||||
return text[0].toUpperCase() + text.substr(1).replace(/([A-Z])/g, " $1");
|
||||
}
|
||||
|
||||
totalConfirmers() {
|
||||
return (
|
||||
this.numConfsNotVisible +
|
||||
@@ -821,6 +851,8 @@ export default class ClaimView extends Vue {
|
||||
});
|
||||
if (giveResp.status === 200 && giveResp.data.data?.length > 0) {
|
||||
this.detailsForGive = giveResp.data.data[0];
|
||||
// Extract offer information from the fulfills array
|
||||
this.extractOfferFulfillment();
|
||||
} else {
|
||||
await this.$logError(
|
||||
"Error getting detailed give info: " + JSON.stringify(giveResp),
|
||||
|
||||
@@ -96,50 +96,50 @@
|
||||
</div>
|
||||
|
||||
<!-- Fullfills Links -->
|
||||
<div class="mt-4">
|
||||
<!-- fullfills links for a give -->
|
||||
<div v-if="giveDetails?.fulfillsPlanHandleId">
|
||||
<router-link
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(
|
||||
giveDetails?.fulfillsPlanHandleId || '',
|
||||
)
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
>
|
||||
This fulfills a bigger plan
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<!-- fullfills links for a give -->
|
||||
<div v-if="giveDetails?.fulfillsPlanHandleId" class="mt-2">
|
||||
<router-link
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(giveDetails?.fulfillsPlanHandleId || '')
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
>
|
||||
This fulfills a bigger plan
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
<!-- if there's another, it's probably fulfilling an offer, too -->
|
||||
<div
|
||||
v-if="
|
||||
giveDetails?.fulfillsType &&
|
||||
giveDetails?.fulfillsType !== 'PlanAction' &&
|
||||
giveDetails?.fulfillsHandleId
|
||||
"
|
||||
>
|
||||
<!-- router-link to /claim/ only changes URL path -->
|
||||
<router-link
|
||||
:to="
|
||||
'/claim/' +
|
||||
encodeURIComponent(giveDetails?.fulfillsHandleId || '')
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
>
|
||||
This fulfills
|
||||
{{
|
||||
capitalizeAndInsertSpacesBeforeCapsWithAPrefix(
|
||||
giveDetails?.fulfillsType || "",
|
||||
)
|
||||
}}
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</router-link>
|
||||
<!-- Show offer fulfillment if this give fulfills an offer -->
|
||||
<div v-if="giveDetailsOfferFulfillment?.offerHandleId">
|
||||
<!-- router-link to /claim/ only changes URL path -->
|
||||
<router-link
|
||||
:to="
|
||||
'/claim/' +
|
||||
encodeURIComponent(
|
||||
giveDetailsOfferFulfillment.offerHandleId || '',
|
||||
)
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
>
|
||||
This fulfills
|
||||
{{
|
||||
serverUtil.capitalizeAndInsertSpacesBeforeCapsWithAPrefix(
|
||||
giveDetailsOfferFulfillment.offerType || "Offer",
|
||||
)
|
||||
}}
|
||||
<font-awesome
|
||||
icon="arrow-up-right-from-square"
|
||||
class="fa-fw"
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -493,6 +493,11 @@ export default class ConfirmGiftView extends Vue {
|
||||
confsVisibleErrorMessage = "";
|
||||
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
|
||||
giveDetails?: GiveSummaryRecord;
|
||||
// Additional offer information extracted from the fulfills array
|
||||
giveDetailsOfferFulfillment: {
|
||||
offerHandleId?: string;
|
||||
offerType?: string;
|
||||
} | null = null;
|
||||
giverName = "";
|
||||
issuerName = "";
|
||||
isLoading = false;
|
||||
@@ -648,6 +653,8 @@ export default class ConfirmGiftView extends Vue {
|
||||
|
||||
if (resp.status === 200) {
|
||||
this.giveDetails = resp.data.data[0];
|
||||
// Extract offer information from the fulfills array
|
||||
this.extractOfferFulfillment();
|
||||
} else {
|
||||
throw new Error("Error getting detailed give info: " + resp.status);
|
||||
}
|
||||
@@ -707,6 +714,15 @@ export default class ConfirmGiftView extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract offer fulfillment information from the fulfills array
|
||||
*/
|
||||
private extractOfferFulfillment() {
|
||||
this.giveDetailsOfferFulfillment = libsUtil.extractOfferFulfillment(
|
||||
this.giveDetails?.fullClaim?.fulfills
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches confirmer information for the claim
|
||||
*/
|
||||
@@ -849,27 +865,6 @@ export default class ConfirmGiftView extends Vue {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats type string for display by adding spaces before capitals
|
||||
* Optionally adds a prefix
|
||||
*
|
||||
* @param text - Text to format
|
||||
* @param prefix - Optional prefix to add
|
||||
* @returns Formatted string
|
||||
*/
|
||||
capitalizeAndInsertSpacesBeforeCapsWithAPrefix(text: string): string {
|
||||
const word = this.capitalizeAndInsertSpacesBeforeCaps(text);
|
||||
if (word) {
|
||||
// if the word starts with a vowel, use "an" instead of "a"
|
||||
const firstLetter = word[0].toLowerCase();
|
||||
const vowels = ["a", "e", "i", "o", "u"];
|
||||
const particle = vowels.includes(firstLetter) ? "an" : "a";
|
||||
return particle + " " + word;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates sharing of claim information
|
||||
* Handles share functionality based on platform capabilities
|
||||
@@ -894,11 +889,5 @@ export default class ConfirmGiftView extends Vue {
|
||||
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
||||
this.veriClaimDump = "";
|
||||
}
|
||||
|
||||
capitalizeAndInsertSpacesBeforeCaps(text: string) {
|
||||
return !text
|
||||
? ""
|
||||
: text[0].toUpperCase() + text.substr(1).replace(/([A-Z])/g, " $1");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -144,6 +144,7 @@ import {
|
||||
QR_TIMEOUT_LONG,
|
||||
} from "@/constants/notifications";
|
||||
import { createNotifyHelpers, NotifyFunction } from "../utils/notify";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
|
||||
interface QRScanResult {
|
||||
rawValue?: string;
|
||||
@@ -622,6 +623,15 @@ export default class ContactQRScanFull extends Vue {
|
||||
*/
|
||||
async handleBack() {
|
||||
await this.cleanupScanner();
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
|
||||
this.$router.back();
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ import { QRScannerFactory } from "@/services/QRScanner/QRScannerFactory";
|
||||
import { CameraState } from "@/services/QRScanner/types";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers } from "@/utils/notify";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
import {
|
||||
NOTIFY_QR_INITIALIZATION_ERROR,
|
||||
NOTIFY_QR_CAMERA_IN_USE,
|
||||
@@ -319,6 +320,15 @@ export default class ContactQRScanShow extends Vue {
|
||||
|
||||
async handleBack(): Promise<void> {
|
||||
await this.cleanupScanner();
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
|
||||
this.$router.back();
|
||||
}
|
||||
|
||||
@@ -738,24 +748,17 @@ export default class ContactQRScanShow extends Vue {
|
||||
!contact.registered
|
||||
) {
|
||||
setTimeout(() => {
|
||||
this.notify.confirm(
|
||||
"Do you want to register them?",
|
||||
this.$notify(
|
||||
{
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Register",
|
||||
text: "Do you want to register them?",
|
||||
onCancel: async (stopAsking?: boolean) => {
|
||||
if (stopAsking) {
|
||||
await this.$updateSettings({
|
||||
hideRegisterPromptOnNewContact: stopAsking,
|
||||
});
|
||||
this.hideRegisterPromptOnNewContact = stopAsking;
|
||||
}
|
||||
await this.handleRegistrationPromptResponse(stopAsking);
|
||||
},
|
||||
onNo: async (stopAsking?: boolean) => {
|
||||
if (stopAsking) {
|
||||
await this.$updateSettings({
|
||||
hideRegisterPromptOnNewContact: stopAsking,
|
||||
});
|
||||
this.hideRegisterPromptOnNewContact = stopAsking;
|
||||
}
|
||||
await this.handleRegistrationPromptResponse(stopAsking);
|
||||
},
|
||||
onYes: async () => {
|
||||
await this.register(contact);
|
||||
@@ -885,6 +888,17 @@ export default class ContactQRScanShow extends Vue {
|
||||
videoElement.style.transform = shouldMirror ? "scaleX(-1)" : "none";
|
||||
}
|
||||
}
|
||||
|
||||
private async handleRegistrationPromptResponse(
|
||||
stopAsking?: boolean,
|
||||
): Promise<void> {
|
||||
if (stopAsking) {
|
||||
await this.$saveSettings({
|
||||
hideRegisterPromptOnNewContact: stopAsking,
|
||||
});
|
||||
this.hideRegisterPromptOnNewContact = stopAsking;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -71,22 +71,22 @@
|
||||
contactFromDid?.seesMe && contactFromDid.did !== activeDid
|
||||
"
|
||||
class="text-sm uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mx-0.5 my-0.5 px-2 py-1.5 rounded-md"
|
||||
title="They can see you"
|
||||
title="They can see your activity"
|
||||
@click="confirmSetVisibility(contactFromDid, false)"
|
||||
>
|
||||
<font-awesome icon="eye" class="fa-fw" />
|
||||
<font-awesome icon="arrow-up" class="fa-fw" />
|
||||
<font-awesome icon="eye" class="fa-fw" />
|
||||
</button>
|
||||
<button
|
||||
v-else-if="
|
||||
!contactFromDid?.seesMe && contactFromDid?.did !== activeDid
|
||||
"
|
||||
class="text-sm uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mx-0.5 my-0.5 px-2 py-1.5 rounded-md"
|
||||
title="They cannot see you"
|
||||
title="They cannot see your activity"
|
||||
@click="confirmSetVisibility(contactFromDid, true)"
|
||||
>
|
||||
<font-awesome icon="eye-slash" class="fa-fw" />
|
||||
<font-awesome icon="arrow-up" class="fa-fw" />
|
||||
<font-awesome icon="eye-slash" class="fa-fw" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
@@ -95,11 +95,11 @@
|
||||
contactFromDid.did !== activeDid
|
||||
"
|
||||
class="text-sm uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mx-0.5 my-0.5 px-2 py-1.5 rounded-md"
|
||||
title="I view their content"
|
||||
title="You watch their activity"
|
||||
@click="confirmViewContent(contactFromDid, false)"
|
||||
>
|
||||
<font-awesome icon="eye" class="fa-fw" />
|
||||
<font-awesome icon="arrow-down" class="fa-fw" />
|
||||
<font-awesome icon="eye" class="fa-fw" />
|
||||
</button>
|
||||
<button
|
||||
v-else-if="
|
||||
@@ -107,11 +107,11 @@
|
||||
contactFromDid?.did !== activeDid
|
||||
"
|
||||
class="text-sm uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mx-0.5 my-0.5 px-2 py-1.5 rounded-md"
|
||||
title="I do not view their content"
|
||||
title="You do not watch their activity"
|
||||
@click="confirmViewContent(contactFromDid, true)"
|
||||
>
|
||||
<font-awesome icon="eye-slash" class="fa-fw" />
|
||||
<font-awesome icon="arrow-down" class="fa-fw" />
|
||||
<font-awesome icon="eye-slash" class="fa-fw" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
@@ -280,6 +280,7 @@ import { logger } from "../utils/logger";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { showSeedPhraseReminder } from "@/utils/seedPhraseReminder";
|
||||
import {
|
||||
NOTIFY_GIFTED_DETAILS_RETRIEVAL_ERROR,
|
||||
NOTIFY_GIFTED_DETAILS_DELETE_IMAGE_CONFIRM,
|
||||
@@ -770,6 +771,15 @@ export default class GiftedDetails extends Vue {
|
||||
NOTIFY_GIFTED_DETAILS_GIFT_RECORDED.message,
|
||||
TIMEOUTS.SHORT,
|
||||
);
|
||||
|
||||
// Show seed phrase backup reminder if needed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
showSeedPhraseReminder(!!settings.hasBackedUpSeed, this.$notify);
|
||||
} catch (error) {
|
||||
logger.error("Error checking seed backup status:", error);
|
||||
}
|
||||
|
||||
localStorage.removeItem("imageUrl");
|
||||
if (this.destinationPathAfter) {
|
||||
(this.$router as Router).push({ path: this.destinationPathAfter });
|
||||
|
||||
@@ -319,8 +319,9 @@
|
||||
<ul class="list-disc list-outside ml-4">
|
||||
<li>
|
||||
Go to Your Identity <font-awesome icon="circle-user" class="fa-fw" /> page,
|
||||
click Advanced, and follow the instructions for the Contacts & Settings Database "Import".
|
||||
Beware that this will erase your existing contact & settings.
|
||||
click Advanced, and follow the instructions to "Import Contacts".
|
||||
(There is currently no way to import other settings, so you'll have to recreate
|
||||
by hand your search area, filters, etc.)
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -336,14 +337,18 @@
|
||||
|
||||
<h2 class="text-xl font-semibold">How do I erase my data from my device?</h2>
|
||||
<p>
|
||||
Before doing this, you may want to back up your data with the instructions above.
|
||||
Before doing this, you should back up your data with the instructions above.
|
||||
Note that this does not erase data sent to our servers (see contact info below)
|
||||
</p>
|
||||
<ul>
|
||||
<li class="list-disc list-outside ml-4">
|
||||
Mobile
|
||||
<ul>
|
||||
<li class="list-disc list-outside ml-4">
|
||||
Home Screen: hold down on the icon, and choose to delete it
|
||||
App Store app: hold down on the icon, then uninstall it
|
||||
</li>
|
||||
<li class="list-disc list-outside ml-4">
|
||||
Home Screen PWA: hold down on the icon, and delete it
|
||||
</li>
|
||||
<li class="list-disc list-outside ml-4">
|
||||
Chrome: Settings -> Privacy and Security -> Clear Browsing Data
|
||||
@@ -415,15 +420,6 @@
|
||||
different page.
|
||||
</p>
|
||||
|
||||
<h2 class="text-xl font-semibold">
|
||||
Where do I get help with notifications?
|
||||
</h2>
|
||||
<p>
|
||||
<router-link class="text-blue-500" to="/help-notifications"
|
||||
>Here.</router-link
|
||||
>
|
||||
</p>
|
||||
|
||||
<h2 class="text-xl font-semibold">
|
||||
This app is misbehaving, like showing me a blank screen or failing to show my personal data.
|
||||
What can I do?
|
||||
@@ -434,10 +430,13 @@
|
||||
</p>
|
||||
<ul class="list-disc list-outside ml-4">
|
||||
<li>
|
||||
Drag down on the screen to refresh it; do that multiple times, because
|
||||
For mobile apps, make sure you're connected to the internet.
|
||||
</li>
|
||||
<li>
|
||||
For PWAs, drag down on the screen to refresh it; do that multiple times, because
|
||||
it sometimes takes multiple tries for the app to refresh to the latest version.
|
||||
You can see the version information at the bottom of this page; the best
|
||||
way to determine the latest version is to open this page in an incognito/private
|
||||
way to determine the latest version is to open TimeSafari.app in an incognito/private
|
||||
browser window and look at the version there.
|
||||
</li>
|
||||
<li>
|
||||
@@ -468,9 +467,6 @@
|
||||
</ul>
|
||||
Then reload Time Safari.
|
||||
</li>
|
||||
<li>
|
||||
Restart your device.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
If you still have problems, you can clear the cache (see "erase my data" above)
|
||||
@@ -508,16 +504,12 @@
|
||||
</p>
|
||||
<ul class="list-disc list-outside ml-4">
|
||||
<li>
|
||||
If using notifications, a server stores push token data. That can be revoked at any time
|
||||
by disabling notifications on the Profile <font-awesome icon="circle-user" class="fa-fw" /> page.
|
||||
</li>
|
||||
<li>
|
||||
If sending images, a server stores them, too. They can be removed by editing the claim
|
||||
and deleting them.
|
||||
If sending images, a server stores them. They can be removed by editing each claim
|
||||
and deleting the image.
|
||||
</li>
|
||||
<li>
|
||||
If sending other partner system data (eg. to Trustroots) a public key and message
|
||||
data are stored on a server. Those can be removed via direct personal request.
|
||||
data are stored on a server. Those can be removed via direct personal request (via contact below).
|
||||
</li>
|
||||
<li>
|
||||
For all other claim data,
|
||||
|
||||
@@ -88,9 +88,15 @@ import { Router } from "vue-router";
|
||||
|
||||
import { AppString, NotificationIface } from "../constants/app";
|
||||
import { DEFAULT_ROOT_DERIVATION_PATH } from "../libs/crypto";
|
||||
import { retrieveAccountCount, importFromMnemonic } from "../libs/util";
|
||||
import {
|
||||
retrieveAccountCount,
|
||||
importFromMnemonic,
|
||||
checkForDuplicateAccount,
|
||||
DUPLICATE_ACCOUNT_ERROR,
|
||||
} from "../libs/util";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { NOTIFY_DUPLICATE_ACCOUNT_IMPORT } from "@/constants/notifications";
|
||||
|
||||
/**
|
||||
* Import Account View Component
|
||||
@@ -198,6 +204,19 @@ export default class ImportAccountView extends Vue {
|
||||
}
|
||||
|
||||
try {
|
||||
// Check for duplicate account before importing
|
||||
const isDuplicate = await checkForDuplicateAccount(
|
||||
this.mnemonic,
|
||||
this.derivationPath,
|
||||
);
|
||||
if (isDuplicate) {
|
||||
this.notify.warning(
|
||||
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await importFromMnemonic(
|
||||
this.mnemonic,
|
||||
this.derivationPath,
|
||||
@@ -223,9 +242,20 @@ export default class ImportAccountView extends Vue {
|
||||
this.$router.push({ name: "account" });
|
||||
} catch (error: unknown) {
|
||||
this.$logError("Import failed: " + error);
|
||||
|
||||
// Check if this is a duplicate account error from saveNewIdentity
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
if (errorMessage.includes(DUPLICATE_ACCOUNT_ERROR)) {
|
||||
this.notify.warning(
|
||||
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.notify.error(
|
||||
(error instanceof Error ? error.message : String(error)) ||
|
||||
"Failed to import account.",
|
||||
errorMessage || "Failed to import account.",
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ import {
|
||||
retrieveAllAccountsMetadata,
|
||||
retrieveFullyDecryptedAccount,
|
||||
saveNewIdentity,
|
||||
checkForDuplicateAccount,
|
||||
} from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { Account, AccountEncrypted } from "../db/tables/accounts";
|
||||
@@ -171,6 +172,16 @@ export default class ImportAccountView extends Vue {
|
||||
const newId = newIdentifier(address, publicHex, privateHex, newDerivPath);
|
||||
|
||||
try {
|
||||
// Check for duplicate account before creating
|
||||
const isDuplicate = await checkForDuplicateAccount(newId.did);
|
||||
if (isDuplicate) {
|
||||
this.notify.warning(
|
||||
"This derived account already exists. Please try a different derivation path.",
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await saveNewIdentity(newId, mne, newDerivPath);
|
||||
|
||||
// record that as the active DID
|
||||
|
||||
@@ -110,10 +110,22 @@ export default class NewEditAccountView extends Vue {
|
||||
* @async
|
||||
*/
|
||||
async onClickSaveChanges() {
|
||||
await this.$updateSettings({
|
||||
firstName: this.givenName,
|
||||
lastName: "", // deprecated, pre v 0.1.3
|
||||
});
|
||||
// Get the current active DID to save to user-specific settings
|
||||
const settings = await this.$accountSettings();
|
||||
const activeDid = settings.activeDid;
|
||||
|
||||
if (activeDid) {
|
||||
// Save to user-specific settings for the current identity
|
||||
await this.$saveUserSettings(activeDid, {
|
||||
firstName: this.givenName,
|
||||
});
|
||||
} else {
|
||||
// Fallback to master settings if no active DID
|
||||
await this.$saveSettings({
|
||||
firstName: this.givenName,
|
||||
});
|
||||
}
|
||||
|
||||
this.$router.back();
|
||||
}
|
||||
|
||||
|
||||
@@ -243,13 +243,19 @@
|
||||
:project-name="name"
|
||||
/>
|
||||
|
||||
<h3 class="text-lg font-bold leading-tight mb-3">Offered To This Idea</h3>
|
||||
<h3 class="text-lg font-bold leading-tight mb-3">
|
||||
Offered To This Idea
|
||||
</h3>
|
||||
|
||||
<div v-if="offersToThis.length === 0" class="text-sm">
|
||||
(None yet.<span v-if="activeDid && isRegistered"> Wanna
|
||||
<span class="cursor-pointer text-blue-500" @click="openOfferDialog()"
|
||||
>offer something… especially if others join you</span
|
||||
>?</span>)
|
||||
(None yet.<span v-if="activeDid && isRegistered">
|
||||
Wanna
|
||||
<span
|
||||
class="cursor-pointer text-blue-500"
|
||||
@click="openOfferDialog()"
|
||||
>offer something… especially if others join you</span
|
||||
>?</span
|
||||
>)
|
||||
</div>
|
||||
|
||||
<ul v-else class="text-sm border-t border-slate-300">
|
||||
@@ -325,7 +331,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="text-lg font-bold leading-tight mb-3">Given To This Project</h3>
|
||||
<h3 class="text-lg font-bold leading-tight mb-3">
|
||||
Given To This Project
|
||||
</h3>
|
||||
|
||||
<div v-if="givesToThis.length === 0" class="text-sm">
|
||||
(None yet. If you've seen something, say something by clicking a
|
||||
@@ -498,7 +506,9 @@
|
||||
Benefitted From This Project
|
||||
</h3>
|
||||
|
||||
<div v-if="givesProvidedByThis.length === 0" class="text-sm">(None yet.)</div>
|
||||
<div v-if="givesProvidedByThis.length === 0" class="text-sm">
|
||||
(None yet.)
|
||||
</div>
|
||||
|
||||
<ul v-else class="text-sm border-t border-slate-300">
|
||||
<li
|
||||
|
||||
@@ -69,10 +69,17 @@
|
||||
<div v-if="claimCountWithHidden > 0" class="border-b border-slate-300 pb-2">
|
||||
<span>
|
||||
{{ claimCountWithHiddenText }}
|
||||
so if you expected but do not see details from someone then ask them to
|
||||
check that their activity is visible to you on their Contacts
|
||||
<font-awesome icon="users" class="text-slate-500" />
|
||||
page.
|
||||
If you don't see expected info above for someone, ask them to check that
|
||||
their activity is visible to you (
|
||||
<font-awesome icon="arrow-up" class="fa-fw" />
|
||||
<font-awesome icon="eye" class="fa-fw" />
|
||||
) on
|
||||
<a
|
||||
class="text-blue-500 underline cursor-pointer"
|
||||
@click="copyContactsLinkToClipboard"
|
||||
>
|
||||
this page </a
|
||||
>.
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="claimCountByUser > 0" class="border-b border-slate-300 pb-2">
|
||||
@@ -120,10 +127,11 @@ import { DateTime } from "luxon";
|
||||
import * as R from "ramda";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import TopMessage from "../components/TopMessage.vue";
|
||||
import { NotificationIface } from "../constants/app";
|
||||
import { NotificationIface, APP_SERVER } from "../constants/app";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import {
|
||||
GenericCredWrapper,
|
||||
@@ -148,6 +156,7 @@ import {
|
||||
NOTIFY_ALL_CONFIRMATIONS_ERROR,
|
||||
NOTIFY_GIVE_SEND_ERROR,
|
||||
NOTIFY_CLAIMS_SEND_ERROR,
|
||||
NOTIFY_COPIED_TO_CLIPBOARD,
|
||||
createConfirmationSuccessMessage,
|
||||
createCombinedSuccessMessage,
|
||||
} from "@/constants/notifications";
|
||||
@@ -195,8 +204,8 @@ export default class QuickActionBvcEndView extends Vue {
|
||||
get claimCountWithHiddenText() {
|
||||
if (this.claimCountWithHidden === 0) return "";
|
||||
return this.claimCountWithHidden === 1
|
||||
? "There is 1 other claim with hidden details,"
|
||||
: `There are ${this.claimCountWithHidden} other claims with hidden details,`;
|
||||
? "There is 1 other claim with hidden details."
|
||||
: `There are ${this.claimCountWithHidden} other claims with hidden details.`;
|
||||
}
|
||||
|
||||
get claimCountByUserText() {
|
||||
@@ -296,6 +305,25 @@ export default class QuickActionBvcEndView extends Vue {
|
||||
(this.$router as Router).push(route);
|
||||
}
|
||||
|
||||
copyContactsLinkToClipboard() {
|
||||
const deepLinkUrl = `${APP_SERVER}/deep-link/did/${this.activeDid}`;
|
||||
useClipboard()
|
||||
.copy(deepLinkUrl)
|
||||
.then(() => {
|
||||
this.notify.success(
|
||||
NOTIFY_COPIED_TO_CLIPBOARD.message("Your info link"),
|
||||
TIMEOUTS.SHORT,
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error("Failed to copy to clipboard:", error);
|
||||
this.notify.error(
|
||||
"Failed to copy link to clipboard. Please try again.",
|
||||
TIMEOUTS.SHORT,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async record() {
|
||||
try {
|
||||
if (this.claimsToConfirmSelected.length > 0) {
|
||||
|
||||
@@ -231,9 +231,24 @@ export default class SeedBackupView extends Vue {
|
||||
/**
|
||||
* Reveals the seed phrase to the user
|
||||
* Sets showSeed to true to display the sensitive seed phrase data
|
||||
* Updates the hasBackedUpSeed setting to true to track that user has backed up
|
||||
*/
|
||||
revealSeed(): void {
|
||||
async revealSeed(): Promise<void> {
|
||||
this.showSeed = true;
|
||||
|
||||
// Update the account setting to track that user has backed up their seed
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
if (settings.activeDid) {
|
||||
await this.$saveUserSettings(settings.activeDid, {
|
||||
hasBackedUpSeed: true,
|
||||
});
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
logger.error("Failed to update hasBackedUpSeed setting:", err);
|
||||
// Don't show error to user as this is not critical to the main functionality
|
||||
// The seed phrase is still revealed, just the tracking won't work
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,8 +69,7 @@
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { UNNAMED_ENTITY_NAME } from '../src/constants/entities';
|
||||
import { deleteContact, generateAndRegisterEthrUser, importUser } from './testUtils';
|
||||
import { createContactName, generateNewEthrUser, importUser, importUserFromAccount } from './testUtils';
|
||||
import { NOTIFY_CONTACT_INVALID_DID } from '../src/constants/notifications';
|
||||
|
||||
test('Check activity feed - check that server is running', async ({ page }) => {
|
||||
@@ -185,35 +184,20 @@ test('Check invalid DID shows error and redirects', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('Check User 0 can register a random person', async ({ page }) => {
|
||||
await importUser(page, '00');
|
||||
const newDid = await generateAndRegisterEthrUser(page);
|
||||
expect(newDid).toContain('did:ethr:');
|
||||
const newDid = await generateNewEthrUser(page); // generate a new user
|
||||
|
||||
await page.goto('./');
|
||||
await page.getByTestId('closeOnboardingAndFinish').click();
|
||||
await page.getByRole('button', { name: 'Person' }).click();
|
||||
await page.getByRole('listitem').filter({ hasText: UNNAMED_ENTITY_NAME }).locator('svg').click();
|
||||
await page.getByPlaceholder('What was given').fill('Gave me access!');
|
||||
await page.getByRole('button', { name: 'Sign & Send' }).click();
|
||||
await expect(page.getByText('That gift was recorded.')).toBeVisible();
|
||||
// now ensure that alert goes away
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss alert
|
||||
await expect(page.getByText('That gift was recorded.')).toBeHidden();
|
||||
await importUserFromAccount(page, "00"); // switch to User Zero
|
||||
|
||||
// now delete the contact to test that pages still do reasonable things
|
||||
await deleteContact(page, newDid);
|
||||
// go the activity page for this new person
|
||||
await page.goto('./did/' + encodeURIComponent(newDid));
|
||||
// maybe replace by: const popupPromise = page.waitForEvent('popup');
|
||||
let error;
|
||||
try {
|
||||
await page.waitForSelector('div[role="alert"]', { timeout: 2000 });
|
||||
error = new Error('Error alert should not show.');
|
||||
} catch (error) {
|
||||
// success
|
||||
} finally {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// As User Zero, add the new user as a contact
|
||||
await page.goto('./contacts');
|
||||
const contactName = createContactName(newDid);
|
||||
await page.getByPlaceholder('URL or DID, Name, Public Key').fill(`${newDid}, ${contactName}`);
|
||||
await expect(page.locator('button > svg.fa-plus')).toBeVisible();
|
||||
await page.locator('button > svg.fa-plus').click();
|
||||
await expect(page.locator('div[role="alert"] h4:has-text("Success")')).toBeVisible(); // wait for info alert to be visible…
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // …and dismiss it
|
||||
await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone
|
||||
await page.locator('div[role="alert"] button:text-is("Yes")').click(); // Register new contact
|
||||
await page.locator('div[role="alert"] button:text-is("No, Not Now")').click(); // Dismiss export data prompt
|
||||
await expect(page.locator("li", { hasText: contactName })).toBeVisible();
|
||||
});
|
||||
|
||||
63
test-playwright/03-duplicate-import-test.spec.ts
Normal file
63
test-playwright/03-duplicate-import-test.spec.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { importUserFromAccount, getTestUserData } from './testUtils';
|
||||
import { NOTIFY_DUPLICATE_ACCOUNT_IMPORT } from '../src/constants/notifications';
|
||||
|
||||
/**
|
||||
* Test duplicate account import functionality
|
||||
*
|
||||
* This test verifies that:
|
||||
* 1. A user can successfully import an account the first time
|
||||
* 2. Attempting to import the same account again shows a warning message
|
||||
* 3. The duplicate import is prevented
|
||||
*/
|
||||
test.describe('Duplicate Account Import', () => {
|
||||
test('should prevent importing the same account twice', async ({ page }) => {
|
||||
const userData = getTestUserData("00");
|
||||
|
||||
// First import - should succeed
|
||||
await page.goto("./start");
|
||||
await page.getByText("You have a seed").click();
|
||||
await page.getByPlaceholder("Seed Phrase").fill(userData.seedPhrase);
|
||||
await page.getByRole("button", { name: "Import" }).click();
|
||||
|
||||
// Verify first import was successful
|
||||
await expect(page.getByRole("code")).toContainText(userData.did);
|
||||
|
||||
// Navigate back to start page for second import attempt
|
||||
await page.goto("./start");
|
||||
await page.getByText("You have a seed").click();
|
||||
await page.getByPlaceholder("Seed Phrase").fill(userData.seedPhrase);
|
||||
await page.getByRole("button", { name: "Import" }).click();
|
||||
|
||||
// Verify duplicate import shows warning message
|
||||
// The warning can appear either from the pre-check or from the saveNewIdentity error handling
|
||||
await expect(page.getByText(NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message)).toBeVisible();
|
||||
|
||||
// Verify we're still on the import page (not redirected to account)
|
||||
await expect(page.getByPlaceholder("Seed Phrase")).toBeVisible();
|
||||
});
|
||||
|
||||
test('should allow importing different accounts', async ({ page }) => {
|
||||
const userZeroData = getTestUserData("00");
|
||||
const userOneData = getTestUserData("01");
|
||||
|
||||
// Import first user
|
||||
await page.goto("./start");
|
||||
await page.getByText("You have a seed").click();
|
||||
await page.getByPlaceholder("Seed Phrase").fill(userZeroData.seedPhrase);
|
||||
await page.getByRole("button", { name: "Import" }).click();
|
||||
|
||||
// Verify first import was successful
|
||||
await expect(page.getByRole("code")).toContainText(userZeroData.did);
|
||||
|
||||
// Navigate back to start page for second user import
|
||||
await page.goto("./start");
|
||||
await page.getByText("You have a seed").click();
|
||||
await page.getByPlaceholder("Seed Phrase").fill(userOneData.seedPhrase);
|
||||
await page.getByRole("button", { name: "Import" }).click();
|
||||
|
||||
// Verify second import was successful (should not show duplicate warning)
|
||||
await expect(page.getByRole("code")).toContainText(userOneData.did);
|
||||
await expect(page.getByText(NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message)).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,7 @@
|
||||
* - Custom expiration date
|
||||
* 2. The invitation appears in the list after creation
|
||||
* 3. A new user can accept the invitation and become connected
|
||||
* 4. The new user can create gift records from the front page
|
||||
*
|
||||
* Test Flow:
|
||||
* 1. Imports User 0 (test account)
|
||||
@@ -19,6 +20,8 @@
|
||||
* 4. Creates a new user with Ethr DID
|
||||
* 5. Accepts the invitation as the new user
|
||||
* 6. Verifies the connection is established
|
||||
* 7. Tests that the new user can create gift records from the front page
|
||||
* 8. Verifies the gift appears in the home view
|
||||
*
|
||||
* Related Files:
|
||||
* - Frontend invite handling: src/libs/endorserServer.ts
|
||||
@@ -29,7 +32,7 @@
|
||||
* @requires ./testUtils - For user management utilities
|
||||
*/
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { deleteContact, generateNewEthrUser, generateRandomString, importUser, switchToUser } from './testUtils';
|
||||
import { createGiftFromFrontPageForNewUser, deleteContact, generateNewEthrUser, generateRandomString, importUser, switchToUser } from './testUtils';
|
||||
|
||||
test('Check User 0 can invite someone', async ({ page }) => {
|
||||
await importUser(page, '00');
|
||||
@@ -58,4 +61,7 @@ test('Check User 0 can invite someone', async ({ page }) => {
|
||||
await page.locator('button:has-text("Save")').click();
|
||||
await expect(page.locator('button:has-text("Save")')).toBeHidden();
|
||||
await expect(page.locator(`li:has-text("My pal User #0")`)).toBeVisible();
|
||||
|
||||
// Verify the new user can create a gift record from the front page
|
||||
const giftTitle = await createGiftFromFrontPageForNewUser(page, `Gift from new user ${neighborNum}`);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { expect, Page } from "@playwright/test";
|
||||
import { UNNAMED_ENTITY_NAME } from '../src/constants/entities';
|
||||
|
||||
// Get test user data based on the ID.
|
||||
// '01' -> user 111
|
||||
@@ -109,7 +110,7 @@ export async function switchToUser(page: Page, did: string): Promise<void> {
|
||||
await page.getByTestId("didWrapper").locator('code:has-text("did:")');
|
||||
}
|
||||
|
||||
function createContactName(did: string): string {
|
||||
export function createContactName(did: string): string {
|
||||
return "User " + did.slice(11, 14);
|
||||
}
|
||||
|
||||
@@ -144,30 +145,6 @@ export async function generateNewEthrUser(page: Page): Promise<string> {
|
||||
return newDid;
|
||||
}
|
||||
|
||||
// Generate a new random user and register them.
|
||||
// Note that this makes 000 the active user. Use switchToUser to switch to this DID.
|
||||
export async function generateAndRegisterEthrUser(page: Page): Promise<string> {
|
||||
const newDid = await generateNewEthrUser(page);
|
||||
|
||||
await importUser(page, "000"); // switch to user 000
|
||||
|
||||
await page.goto("./contacts");
|
||||
const contactName = createContactName(newDid);
|
||||
await page
|
||||
.getByPlaceholder("URL or DID, Name, Public Key")
|
||||
.fill(`${newDid}, ${contactName}`);
|
||||
await page.locator("button > svg.fa-plus").click();
|
||||
// register them
|
||||
await page.locator('div[role="alert"] button:text-is("Yes")').click();
|
||||
// wait for it to disappear because the next steps may depend on alerts being gone
|
||||
await expect(
|
||||
page.locator('div[role="alert"] button:text-is("Yes")')
|
||||
).toBeHidden();
|
||||
await expect(page.locator("li", { hasText: contactName })).toBeVisible();
|
||||
|
||||
return newDid;
|
||||
}
|
||||
|
||||
// Function to generate a random string of specified length
|
||||
export async function generateRandomString(length: number): Promise<string> {
|
||||
return Math.random()
|
||||
@@ -239,3 +216,44 @@ export function isResourceIntensiveTest(testPath: string): boolean {
|
||||
testPath.includes("40-add-contact")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gift record from the front page
|
||||
* @param page - Playwright page object
|
||||
* @param giftTitle - Optional custom title, defaults to "Gift " + random string
|
||||
* @param amount - Optional amount, defaults to random 1-99
|
||||
* @returns Promise resolving to the created gift title
|
||||
*/
|
||||
export async function createGiftFromFrontPageForNewUser(
|
||||
page: Page,
|
||||
giftTitle?: string,
|
||||
amount?: number
|
||||
): Promise<void> {
|
||||
// Generate random values if not provided
|
||||
const randomString = Math.random().toString(36).substring(2, 6);
|
||||
const finalTitle = giftTitle || `Gift ${randomString}`;
|
||||
const finalAmount = amount || Math.floor(Math.random() * 99) + 1;
|
||||
|
||||
// Navigate to home page and close onboarding
|
||||
await page.goto('./');
|
||||
await page.getByTestId('closeOnboardingAndFinish').click();
|
||||
|
||||
// Start gift creation flow
|
||||
await page.getByRole('button', { name: 'Person' }).click();
|
||||
await page.getByRole('listitem').filter({ hasText: UNNAMED_ENTITY_NAME }).locator('svg').click();
|
||||
|
||||
// Fill gift details
|
||||
await page.getByPlaceholder('What was given').fill(finalTitle);
|
||||
await page.getByRole('spinbutton').fill(finalAmount.toString());
|
||||
|
||||
// Submit gift
|
||||
await page.getByRole('button', { name: 'Sign & Send' }).click();
|
||||
|
||||
// Verify success
|
||||
await expect(page.getByText('That gift was recorded.')).toBeVisible();
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
||||
|
||||
// Verify the gift appears in the home view
|
||||
await page.goto('./');
|
||||
await expect(page.locator('ul#listLatestActivity li').filter({ hasText: giftTitle })).toBeVisible();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user