From 5fa5455e0060f1c525d0486432ff9c6186b40b47 Mon Sep 17 00:00:00 2001 From: Savely Savianok <1986developer@gmail.com> Date: Wed, 26 Feb 2025 01:22:47 +0300 Subject: [PATCH 1/3] feat: added local storage for save totp directly on watches --- app.json | 3 ++- page/index.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app.json b/app.json index 128688a..2f24d70 100644 --- a/app.json +++ b/app.json @@ -13,7 +13,8 @@ "description": "TOTP Authenticator for Amazfit devices" }, "permissions": [ - "data:os.device.info" + "data:os.device.info", + "device:os.local_storage" ], "runtime": { "apiVersion": { diff --git a/page/index.js b/page/index.js index 686e917..73ab370 100644 --- a/page/index.js +++ b/page/index.js @@ -1,19 +1,23 @@ import { RenderAddButton } from "./render/totpRenderer"; import { initLoop } from "./render/index/renderer"; import { BasePage } from "@zeppos/zml/base-page"; +import { LocalStorage } from '@zos/storage'; const app = getApp(); let waitForFetch = true; +let localStorage = new LocalStorage(); Page( BasePage({ onInit() { this.getTOTPData() .then((x) => { - app._options.globalData.TOTPS = JSON.parse(x) ?? []; + app._options.globalData.TOTPS = JSON.parse(x) ?? [] + localStorage.setItem('TOTPs', JSON.stringify(app._options.globalData.TOTPS)) this.initPage(); }) .catch((x) => { - app._options.globalData.TOTPS = []; + console.log(`Init failed: ${x}`) + app._options.globalData.TOTPS = JSON.parse(localStorage.getItem('TOTPs', null) ?? []); this.initPage(); }); }, -- 2.47.1 From 43af7e20550cd25e83841e362f78ffe76fc1bea6 Mon Sep 17 00:00:00 2001 From: Savely Savianok <1986developer@gmail.com> Date: Wed, 26 Feb 2025 01:58:11 +0300 Subject: [PATCH 2/3] chore: cleanup, v1.1.0 --- app.json | 4 ++-- package.json | 9 +++------ page/index.js | 17 ++++++++++++----- page/render/index/renderer.js | 2 +- page/render/totpRenderer.js | 1 + 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app.json b/app.json index 2f24d70..5c86e41 100644 --- a/app.json +++ b/app.json @@ -6,11 +6,11 @@ "appType": "app", "version": { "code": 1, - "name": "1.0.1" + "name": "1.1.0" }, "icon": "icon.png", "vender": "zepp", - "description": "TOTP Authenticator for Amazfit devices" + "description": "Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4" }, "permissions": [ "data:os.device.info", diff --git a/package.json b/package.json index b0fceca..65356db 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,9 @@ { "name": "totpfit", - "version": "1.0.0", - "description": "TOTP Authenticator for Amazfit devices", + "version": "1.1.0", + "description": "Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4", "main": "app.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", + "author": "Lisoveliy", "license": "MIT", "devDependencies": { "@zeppos/device-types": "^3.0.0" diff --git a/page/index.js b/page/index.js index 73ab370..776ff07 100644 --- a/page/index.js +++ b/page/index.js @@ -1,23 +1,30 @@ import { RenderAddButton } from "./render/totpRenderer"; import { initLoop } from "./render/index/renderer"; import { BasePage } from "@zeppos/zml/base-page"; -import { LocalStorage } from '@zos/storage'; +import { LocalStorage } from "@zos/storage"; const app = getApp(); + let waitForFetch = true; let localStorage = new LocalStorage(); + Page( BasePage({ onInit() { this.getTOTPData() .then((x) => { - app._options.globalData.TOTPS = JSON.parse(x) ?? [] - localStorage.setItem('TOTPs', JSON.stringify(app._options.globalData.TOTPS)) + app._options.globalData.TOTPS = JSON.parse(x) ?? []; + localStorage.setItem( + "TOTPs", + JSON.stringify(app._options.globalData.TOTPS) + ); this.initPage(); }) .catch((x) => { - console.log(`Init failed: ${x}`) - app._options.globalData.TOTPS = JSON.parse(localStorage.getItem('TOTPs', null) ?? []); + console.log(`Init failed: ${x}`); + app._options.globalData.TOTPS = JSON.parse( + localStorage.getItem("TOTPs", null) ?? [] + ); this.initPage(); }); }, diff --git a/page/render/index/renderer.js b/page/render/index/renderer.js index 7db9e67..7301b3b 100644 --- a/page/render/index/renderer.js +++ b/page/render/index/renderer.js @@ -20,8 +20,8 @@ function renderContainers(buffer) { RenderTOTPContainer(i, buffer[i].issuer, buffer[i].client); } } -const renderData = []; +const renderData = []; function renderTOTPs(buffer) { for (let i = 0; i < buffer.length; i++) { let otpData = TOTP.copy(buffer[i]).getOTP(); diff --git a/page/render/totpRenderer.js b/page/render/totpRenderer.js index be44e40..714d6ed 100644 --- a/page/render/totpRenderer.js +++ b/page/render/totpRenderer.js @@ -7,6 +7,7 @@ import { createWidget, widget, align, text_style } from "@zos/ui"; const { width, height } = getDeviceInfo(); const buttonWidth = width - width / 20; //Width of container const buttonHeight = height / 4; //Height of container + const containerColor = 0x303030; //Color of container const containerRadius = 20; //Corner radius of container -- 2.47.1 From 430e45fb6ff5f3813c193e3b02ea4401c567d521 Mon Sep 17 00:00:00 2001 From: Savely Savianok <1986developer@gmail.com> Date: Wed, 26 Feb 2025 02:00:05 +0300 Subject: [PATCH 3/3] chore: update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d7ea24..25f7017 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# TOTPFIT - Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4 +# TOTPFIT +### Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4 Features: -- Supports otpauth links with parameters "issuer", "algorithm", "digits", "period" +- Supports of otpauth links with parameters "issuer", "algorithm", "digits", "period" +- Addition/Edition/Deletion of TOTPs from mobile settings app \ No newline at end of file -- 2.47.1