-
Notifications
You must be signed in to change notification settings - Fork 5
chore: make applications reject older wallets #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * Compares two semantic version strings | ||
| * @param version1 - First version string (e.g., "0.4.0") | ||
| * @param version2 - Second version string (e.g., "0.3.0") | ||
| * @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2 | ||
| */ | ||
| export function compareVersions(version1: string, version2: string): number { | ||
| const v1Parts = version1.split('.').map(Number); | ||
| const v2Parts = version2.split('.').map(Number); | ||
|
|
||
| for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { | ||
| const v1Part = v1Parts[i] || 0; | ||
| const v2Part = v2Parts[i] || 0; | ||
|
|
||
| if (v1Part < v2Part) return -1; | ||
| if (v1Part > v2Part) return 1; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
Comment on lines
+7
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Handle invalid version strings to prevent NaN comparison bugs. The function uses Apply this diff to add validation: export function compareVersions(version1: string, version2: string): number {
const v1Parts = version1.split('.').map(Number);
const v2Parts = version2.split('.').map(Number);
+
+ // Validate that all parts are valid numbers
+ if (v1Parts.some(isNaN) || v2Parts.some(isNaN)) {
+ throw new Error('Invalid version format: versions must contain only numeric segments');
+ }
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
const v1Part = v1Parts[i] || 0;
const v2Part = v2Parts[i] || 0;
if (v1Part < v2Part) return -1;
if (v1Part > v2Part) return 1;
}
return 0;
}🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Checks if the app version meets the minimum required version | ||
| * @param appVersion - The version from the app (e.g., "0.4.0") | ||
| * @param minVersion - The minimum required version (e.g., "0.4.0") | ||
| * @returns true if appVersion >= minVersion, false otherwise | ||
| */ | ||
| export function isVersionValid(appVersion: string, minVersion: string): boolean { | ||
| return compareVersions(appVersion, minVersion) >= 0; | ||
| } | ||
|
Comment on lines
+7
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Major: Consolidate duplicated version utilities into a shared module. This exact implementation is duplicated across 5 platform APIs (dreamsync-api, evoting-api, group-charter-manager-api, pictique-api, and blabsy-w3ds-auth-api). This violates DRY principles and creates maintenance burden—any bug fix or enhancement must be applied to all 5 copies. Consider extracting these utilities into a shared package (e.g., |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * Compares two semantic version strings | ||
| * @param version1 - First version string (e.g., "0.4.0") | ||
| * @param version2 - Second version string (e.g., "0.3.0") | ||
| * @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2 | ||
| */ | ||
| export function compareVersions(version1: string, version2: string): number { | ||
| const v1Parts = version1.split('.').map(Number); | ||
| const v2Parts = version2.split('.').map(Number); | ||
|
|
||
| for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { | ||
| const v1Part = v1Parts[i] || 0; | ||
| const v2Part = v2Parts[i] || 0; | ||
|
|
||
| if (v1Part < v2Part) return -1; | ||
| if (v1Part > v2Part) return 1; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
Comment on lines
+7
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add input validation and handle malformed version strings. The function doesn't validate inputs or handle non-numeric segments. When Apply this diff to add validation: export function compareVersions(version1: string, version2: string): number {
+ if (!version1 || !version2) {
+ throw new Error('Version strings cannot be null or empty');
+ }
+
const v1Parts = version1.split('.').map(Number);
const v2Parts = version2.split('.').map(Number);
+
+ if (v1Parts.some(isNaN) || v2Parts.some(isNaN)) {
+ throw new Error('Version strings must contain only numeric segments');
+ }
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Checks if the app version meets the minimum required version | ||
| * @param appVersion - The version from the app (e.g., "0.4.0") | ||
| * @param minVersion - The minimum required version (e.g., "0.4.0") | ||
| * @returns true if appVersion >= minVersion, false otherwise | ||
| */ | ||
| export function isVersionValid(appVersion: string, minVersion: string): boolean { | ||
| return compareVersions(appVersion, minVersion) >= 0; | ||
| } | ||
|
|
||
|
|
||
|
Comment on lines
+1
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Extract duplicated version utilities to a shared package. This exact implementation is duplicated across at least 5 services in the codebase. In a monorepo, shared utilities should be extracted to a common package (e.g., Consider creating a shared package structure: // packages/shared-utils/src/version.ts
export function compareVersions(version1: string, version2: string): number {
// implementation
}
export function isVersionValid(appVersion: string, minVersion: string): boolean {
// implementation
}Then import in each service: import { isVersionValid } from '@metastate/shared-utils/version';🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,6 +46,7 @@ | |||||||||
| "lucide-react": "^0.453.0", | ||||||||||
| "next": "15.4.2", | ||||||||||
| "next-qrcode": "^2.5.1", | ||||||||||
| "next.js": "^1.0.3", | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove incorrect dependency - wrong package name. The dependency "next.js" is NOT the official Next.js package. The official package is "next" (which is already present on line 47). The "next.js" package on npm is an outdated, unofficial package that was last published 10 years ago. Apply this diff to remove the incorrect dependency: "next": "15.4.2",
"next-qrcode": "^2.5.1",
- "next.js": "^1.0.3",
"qrcode.react": "^4.2.0",📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| "qrcode.react": "^4.2.0", | ||||||||||
| "react": "19.1.0", | ||||||||||
| "react-day-picker": "^9.11.1", | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug console.log statement.
This debug logging statement should be removed before merging to production. Logging the entire request body can expose sensitive data (ename, session tokens, etc.) in production logs.
📝 Committable suggestion
🤖 Prompt for AI Agents