Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

RoomChat'teki OTP versiyonu sistemini DM'e de implemente et. OTP v0 ve v1'i. Default olarak otp_v1 kullan DM'de. Ayrıca Room Chat'te X karakterden büyük anahtarlardaki mesajı şeyini DM'e de implemente et.

RoomChat'e bu OTP versiyon sistemini eklediğimiz commit'in patch dosyası: Buradaki işleyişi analiz et, tasklar oluştur, sonrasında o taskları uygula. Kısaca, versiyonlama eklenecek logic layer'a. Frontend'e gelişmiş ayarlar eklenecek ve otp sürümü seçme eklenecek.
From 2f8da816fffa734075d6e9eaaa3cde4f512ecfbf Mon Sep 17 00:00:00 2001
From: EdgeTypE minefpsgelistirici@gmail.com
Date: Sat, 3 Jan 2026 10:50:32 +0300
Subject: [PATCH] Add OTP algorithm versioning and advanced settings

Introduces a modular OTP algorithm system with support for multiple versions (v0, v1), including a registry and type definitions. Adds advanced settings to room creation and join screens for selecting OTP encryption version. Updates RoomHistoryService, RoomListScreen, RoomChatScreen, enhancedWebSocketService, and roomOtpStore to track and use the selected OTP version per room, ensuring correct key transformation and encryption. Also adds UI for displaying and changing encryption type, and improves room management actions.

src/algorithms/index.ts | 90 +++++++++++++
src/algorithms/otp_v0/index.ts | 65 +++++++++
src/algorithms/otp_v1/index.ts | 157 ++++++++++++++++++++++
src/algorithms/types.ts | 40 ++++++
src/screens/rooms/CreateRoomScreen.tsx | 105 +++++++++++++++
src/screens/rooms/JoinRoomScreen.tsx | 105 +++++++++++++++
src/screens/rooms/RoomChatScreen.tsx | 20 ++-
src/screens/rooms/RoomListScreen.tsx | 162 +++++++++++++++++++++++
src/services/RoomHistoryService.ts | 2 +
src/services/enhancedWebSocketService.ts | 11 +-
src/stores/roomOtpStore.ts | 13 +-
11 files changed, 763 insertions(+), 7 deletions(-)
create mode 100644 src/algorithms/index.ts
create mode 100644 src/algorithms/otp_v0/index.ts
create mode 100644 src/algorithms/otp_v1/index.ts
create mode 100644 src/algorithms/types.ts

diff --git a/src/algorithms/index.ts b/src/algorithms/index.ts
new file mode 100644
index 0000000..6b5361a
--- /dev/null
+++ b/src/algorithms/index.ts
@@ -0,0 +1,90 @@
+// OTP Algorithm Registry
+// Central registry for all OTP algorithm versions
+
+import { OTPAlgorithm, OTPVersion, DEFAULT_OTP_VERSION, LATEST_OTP_VERSION, OTP_VERSION_LABELS, OTP_VERSION_DESCRIPTIONS } from './types';
+import otpV0Algorithm from './otp_v0';
+import otpV1Algorithm from './otp_v1';
+
+// Algorithm registry
+const algorithms: Map<OTPVersion, OTPAlgorithm> = new Map([

  • ['otp_v0', otpV0Algorithm],
  • ['otp_v1', otpV1Algorithm],
    +]);

+/**

    • Get an OTP algorithm by version
  • */
    +export function getAlgorithm(version: OTPVersion): OTPAlgorithm {
  • const algorithm = algorithms.get(version);
  • if (!algorithm) {
  •    console.warn(`Unknown OTP version: ${version}, falling back to ${DEFAULT_OTP_VERSION}`);
    
  •    return algorithms.get(DEFAULT_OTP_VERSION)!;
    
  • }
  • return algorithm;
    +}

+/**

    • Get all available OTP versions
  • */
    +export function getAvailableVersions(): OTPVersion[] {
  • return Array.from(algorithms.keys());
    +}

+/**

    • Check if a version is valid
  • */
    +export function isValidVersion(version: string): version is OTPVersion {
  • return algorithms.has(version as OTPVersion);
    +}

+/**

    • Encrypt a message using the specified OTP version
  • */
    +export function encryptWithVersion(
  • message: string,
  • rawKey: string,
  • offset: number,
  • version: OTPVersion = DEFAULT_OTP_VERSION
    +): string {
  • const algorithm = getAlgorithm(version);
  • const transformedKey = algorithm.transformKey(rawKey);
  • return algorithm.encrypt(message, transformedKey, offset);
    +}

+/**

    • Decrypt a message using the specified OTP version
  • */
    +export function decryptWithVersion(
  • encrypted: string,
  • rawKey: string,
  • offset: number,
  • version: OTPVersion = DEFAULT_OTP_VERSION
    +): string {
  • const algorithm = getAlgorithm(version);
  • const transformedKey = algorithm.transformKey(rawKey);
  • return algorithm.decrypt(encrypted, transformedKey, offset);
    +}

+/**

    • Transform a raw key using the specified OTP version
  • */
    +export function transformKeyWithVersion(
  • rawKey: string,
  • version: OTPVersion = DEFAULT_OTP_VERSION
    +): string {
  • const algorithm = getAlgorithm(version);
  • return algorithm.transformKey(rawKey);
    +}

+// Re-export types and constants
+export {

  • OTPAlgorithm,
  • OTPVersion,
  • DEFAULT_OTP_VERSION,
  • LATEST_OTP_VERSION,
  • OTP_VERSION_LABELS,
  • OTP_VERSION_DESCRIPTIONS,
    +};

+// Export individual algorithms
+export { otpV0Algorithm, otpV1Algorithm };
diff --git a/src/algorithms/otp_v0/index.ts b/src/algorithms/otp_v0/index.ts
new file mode 100644
index 0000000..97f3588
--- /dev/null


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot stopped work on behalf of EdgeTypE due to an error January 5, 2026 21:36
Copilot AI and others added 3 commits January 5, 2026 21:44
…ces and UI

Co-authored-by: EdgeTypE <34396598+EdgeTypE@users.noreply.github.com>
Co-authored-by: EdgeTypE <34396598+EdgeTypE@users.noreply.github.com>
…security

Co-authored-by: EdgeTypE <34396598+EdgeTypE@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants