Compare commits

..

No commits in common. "7eafac691622bd0b4f61e1662fecf4a2c768273a" and "53233bffeaa8c57272cfeb37ea7edfe30b8d1314" have entirely different histories.

13 changed files with 94 additions and 170 deletions

View File

@ -1,15 +1,17 @@
# TOTPFIT # TOTPFIT
### Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4 with Google Authenticator migration Support ### Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4
![alt text](docs/assets/image2.png) ![alt text](docs/assets/image2.png)
### Features: ### Features:
- Supports of 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 app - Addition/Edition/Deletion of TOTPs from mobile settings app
- Support of google migration links formated: ```otpauth-migration://offline?data=...``` (At this stage with only 6 digits and only 30 seconds period)
### Guides: ### Google Migration Support:
- Support of google migration links formated: ```otpauth-migration://offline?data=...``` (BETA)
[How to add 2FA TOTP records (keys) on app](/docs/guides/how-to-add-totps/README.md) ### Screenshots:
#### This repo has mirror for issues on [GitHub](https://github.com/Lisoveliy/totpfit) ![alt text](docs/assets/image2.png)
![alt text](docs/assets/image.png)

View File

@ -6,7 +6,7 @@
"appType": "app", "appType": "app",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.3" "name": "1.2.2"
}, },
"icon": "icon.png", "icon": "icon.png",
"vender": "zepp", "vender": "zepp",

View File

@ -1,37 +0,0 @@
# How to add 2FA TOTP records (keys) on app
### If you use default 2FA otpauth:// links
To add 2FA TOTP records using 2FA TOTP QR-Codes, you must scan QR-Code of service providing 2FA and scan (decode) it to a URI. If you have screenshot of QR-Code -- scan it on any app providing scan from image, ex: Search screen on Google Assistant. For example, this QR-Code will represent next URI string:
![QR Code with URI](image.png)
Copy this URI string and paste it to app using button *"Add new TOTP record"*:
![Add new TOTP record popup](image-2.png)
Then press OK, record will appear on page
![Added record](image-4.png)
You can edit your otpauth:// records using button "Change TOTP link". Your previous record will be replaced with a new otpauth:// link entered on text field, and previous link will not be shown on field.
### If you use google migrations (otpauth-migration:// links)
To add 2FA TOTP recods using migration from Google Authenticator app, you must go to menu, select "Transfer accounts" -> "Export accounts"
Select codes then screenshot QR code and and scan (decode) it to a URI. Use any app providing scan from image, ex: "Search screen" function (Google Lens) on Google Assistant.
For example, this QR-Code will represent next URI string:
![Google lens scan from Google Authenticator](image-5.png)
After scaning copy this URI string and paste it to app using button *"Add new TOTP record"*:
![Add new TOTP record using otpauth-migration](image-6.png)
Then press OK, all selected records on Google Authenticator will appear on page
![Added records from otpauth-migration](image-7.png)
You can edit your records using button "Change TOTP link". Your previous record will be replaced with a new otpauth:// link entered on text field, and previous link will not be shown on field.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,5 +1,5 @@
export function decodeVarint(buffer, offset) { export function decodeVarint(buffer, offset) {
let res = 0; let res = this.BigInt(0);
let shift = 0; let shift = 0;
let byte = 0; let byte = 0;
@ -10,8 +10,8 @@ export function decodeVarint(buffer, offset) {
byte = buffer[offset++]; byte = buffer[offset++];
const multiplier = 2 ** shift; const multiplier = this.BigInt(2) ** this.BigInt(shift);
const thisByteValue = (byte & 0x7f) * multiplier; const thisByteValue = this.BigInt(byte & 0x7f) * multiplier;
shift += 7; shift += 7;
res = res + thisByteValue; res = res + thisByteValue;
} while (byte >= 0x80); } while (byte >= 0x80);

View File

@ -1,6 +1,6 @@
{ {
"name": "totpfit", "name": "totpfit",
"version": "1.3", "version": "1.2.2",
"description": "Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4", "description": "Another 2FAuthenticator based on TOTP for Zepp Amazfit GTS 4",
"main": "app.js", "main": "app.js",
"author": "Lisoveliy", "author": "Lisoveliy",

View File

@ -2,16 +2,6 @@ import { getTOTPByLink } from "./utils/queryParser.js";
let _props = null; let _props = null;
const colors = {
bg: "#101010",
linkBg: "#ffffffc0",
secondaryBg: "#282828",
text: "#fafafa",
alert: "#ad3c23",
notify: "#555555",
bigText: "#fafafa"
};
AppSettingsPage({ AppSettingsPage({
build(props) { build(props) {
_props = props; _props = props;
@ -19,23 +9,9 @@ AppSettingsPage({
props.settingsStorage.getItem("TOTPs") ?? "[]" props.settingsStorage.getItem("TOTPs") ?? "[]"
); );
const totpEntrys = GetTOTPList(storage); const totpEntrys = GetTOTPList(storage);
const addTOTPsHint = storage.length < 1 ?
Text({
paragraph: true,
align: "center",
style: {
paddingTop: "10px",
marginBottom: "10px",
color: colors.text,
fontSize: 16,
verticalAlign: "middle",
},
},
"For add a 2FA TOTP record you must have otpauth:// link or otpauth-migration:// link from Google Authenticator Migration QR-Code"
) : null;
const createButton = TextInput({ const createButton = TextInput({
placeholder: "otpauth(-migration)://", placeholder: "otpauth://",
label: "Add new TOTP record", label: "Add new OTP Link",
onChange: (changes) => { onChange: (changes) => {
let link = getTOTPByLink(changes); let link = getTOTPByLink(changes);
if (link == null) { if (link == null) {
@ -50,25 +26,22 @@ AppSettingsPage({
updateStorage(storage); updateStorage(storage);
}, },
labelStyle: { labelStyle: {
backgroundColor: colors.notify, backgroundColor: "#14213D",
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
margin: "10px", margin: "10px",
flexGrow: 1,
fontSize: "20px", fontSize: "20px",
color: colors.text, color: "#FFFFFF",
borderRadius: "5px", borderRadius: "5px",
position: storage.length < 1 ? "absolute" : null, //TODO: Сделать что-то с этим кошмаром
bottom: storage.length < 1 ? "0px" : null,
left: storage.length < 1 ? "0px" : null,
right: storage.length < 1 ? "0px" : null
}, },
}); });
var body = Section( var body = Section(
{ {
style: { style: {
backgroundColor: colors.bg, backgroundColor: "black",
minHeight: "100vh", minHeight: "100vh",
}, },
}, },
@ -79,34 +52,22 @@ AppSettingsPage({
textAlign: "center", textAlign: "center",
}, },
}, },
storage.length < 1 ? addTOTPsHint : Text( Text(
{ {
align: "center", align: "center",
paragraph: true, paragraph: true,
style: { style: {
marginBottom: "10px", marginBottom: "10px",
color: colors.bigText, color: "#fff",
fontSize: 23, fontSize: 23,
fontWeight: "500",
verticalAlign: "middle", verticalAlign: "middle",
}, },
}, },
"TOTP records:" "TOTPS:"
) )
), ),
...totpEntrys, ...totpEntrys,
createButton, createButton,
View({
style: {
display: "flex",
justifyContent: "center"
}
},
Link({
source: "https://github.com/Lisoveliy/totpfit/blob/main/docs/guides/how-to-add-totps/README.md"
},
"Instruction | Report issue (GitHub)")
),
] ]
); );
return body; return body;
@ -119,8 +80,8 @@ function GetTOTPList(storage) {
storage.forEach((element) => { storage.forEach((element) => {
const elementId = counter; const elementId = counter;
const textInput = TextInput({ const textInput = TextInput({
placeholder: "otpauth(-migration)://", placeholder: "otpauth://",
label: "Change TOTP link", label: "Change OTP link",
onChange: (changes) => { onChange: (changes) => {
try { try {
let link = getTOTPByLink(changes); let link = getTOTPByLink(changes);
@ -134,7 +95,7 @@ function GetTOTPList(storage) {
} }
}, },
labelStyle: { labelStyle: {
backgroundColor: colors.notify, backgroundColor: "#14213D",
textAlign: "center", textAlign: "center",
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
@ -142,7 +103,7 @@ function GetTOTPList(storage) {
margin: "10px", margin: "10px",
flexGrow: 1, flexGrow: 1,
fontSize: "20px", fontSize: "20px",
color: colors.text, color: "#E5E5E5",
borderRadius: "5px", borderRadius: "5px",
}, },
}); });
@ -150,9 +111,8 @@ function GetTOTPList(storage) {
{ {
align: "center", align: "center",
style: { style: {
color: colors.text, color: "#ffffff",
fontSize: "18px", fontSize: "16px",
fontWeight: "500"
}, },
paragraph: true, paragraph: true,
}, },
@ -166,30 +126,29 @@ function GetTOTPList(storage) {
updateStorage(storage); updateStorage(storage);
}, },
style: { style: {
backgroundColor: colors.alert, backgroundColor: "#ba181b",
fontSize: "18px", fontSize: "18px",
color: colors.text, color: "#ffffff",
height: "fit-content", height: "fit-content",
margin: "10px", margin: "10px",
}, },
label: "Delete", label: "DEL",
}); });
const text = Text( const text = Text(
{ {
style: { style: {
color: colors.text, color: "#ffffff",
fontSize: "14px", fontSize: "14px",
}, },
align: "center", align: "center",
}, },
`${element.hashType} | ${element.digits} digits | ${element.fetchTime} seconds | ${element.timeOffset} sec offset` `${element.hashType} | ${element.digits} digits | ${element.fetchTime} seconds | offset ${element.timeOffset} seconds`
); );
const view = View( const view = View(
{ {
style: { style: {
textAlign: "center", textAlign: "center",
backgroundColor: colors.secondaryBg, border: "2px solid white",
//border: "2px solid white",
borderRadius: "5px", borderRadius: "5px",
margin: "10px", margin: "10px",
}, },

View File

@ -31,7 +31,7 @@ function getByOtpauthScheme(link) {
args[3].split(":")[0]?.split("?")[0]; //Returns client args[3].split(":")[0]?.split("?")[0]; //Returns client
let secret = args[3].split("secret=")[1]?.split("&")[0]; //Returns secret let secret = args[3].split("secret=")[1]?.split("&")[0]; //Returns secret
let period = args[3].split("period=")[1]?.split("&")[0]; //Returns period let period = args[3].split("period=")[1]?.split("&")[0]; //Returns period
let digits = args[3].split("digit=")[1]?.split("&")[0]; //Returns digits let digits = args[3].split("digits=")[1]?.split("&")[0]; //Returns digits
let algorithm = args[3].split("algorithm=")[1]?.split("&")[0]; //Returns algorithm let algorithm = args[3].split("algorithm=")[1]?.split("&")[0]; //Returns algorithm
let offset = args[3].split("offset=")[1]?.split("&")[0] ?? 0; //Returns offset let offset = args[3].split("offset=")[1]?.split("&")[0] ?? 0; //Returns offset
@ -51,8 +51,8 @@ function getByOtpauthScheme(link) {
secret, secret,
issuer, issuer,
client, client,
Number(digits), digits,
Number(period), period,
Number(offset), Number(offset),
getHashType(algorithm) getHashType(algorithm)
); );