26 Commits

Author SHA1 Message Date
6a2ab542b9 feat: v1.3.0 final cut 2025-07-24 04:35:43 +03:00
3aaedec7f6 chore: updated docs 2025-07-24 04:24:53 +03:00
70841349b7 chore: updated docs 2025-07-24 04:24:00 +03:00
7eafac6916 Merge pull request 'v1.3 Fix of Google Authenticator migration support' (#9) from dev into main
Reviewed-on: http://git.lisoveliy.su/Lisoveliy/TOTPFit/pulls/9
2025-07-24 03:18:36 +02:00
08b11a3d09 chore: updated readme 2025-07-24 04:16:21 +03:00
acc3218df6 fix: fixed digit parameter resolve 2025-07-24 04:13:19 +03:00
0aeeebfb3d feat: added new color palette for settings app, fixed typos, added guide, added link to guide 2025-07-24 03:56:39 +03:00
684aff7131 fix: fix of BigInt issue of protobuf decoder (special thanks: silver.zepp) 2025-07-24 02:24:17 +03:00
6d15fe9b72 fix: fix of BigInt issue of protobuf decoder (special thanks: silver.zepp) 2025-07-24 02:23:40 +03:00
53233bffea chore: updated version in json files 2025-07-07 20:53:45 +03:00
640ebb0600 fix: fixed screenshots, fixed offset parse, fixed first render of app 2025-07-07 20:48:52 +03:00
Savely Savianok
90be9c4606 chore: small changes, updated version 1.2.1 2025-03-17 15:44:01 +03:00
Pavel-Savely Savianok
dd32a6eac7 Merge pull request 'Added google migration support (BETA) v.1.2.0' (#8) from dev into main
Reviewed-on: http://git.lisoveliy.su/Lisoveliy/TOTPFit/pulls/8
2025-03-17 13:32:50 +01:00
Savely Savianok
21c7646c71 feat: added google migration support (BETA) v.1.2.0 2025-03-17 15:30:03 +03:00
Savely Savianok
fb6ece773c feat: ported protobuf decoder 2025-03-17 13:37:12 +03:00
Savely Savianok
ba4b8cc29e feat(staging): adding protobuf decoder (part 2) 2025-03-01 22:58:48 +03:00
Savely Savianok
bd490d4642 feat: adding protobuf decoder for parse of google auth migrations 2025-02-28 23:32:54 +03:00
Savely Savianok
ccfd422061 fix: final fix of parsing issuer and client 2025-02-26 02:46:16 +03:00
Savely Savianok
ca342bf6e4 fix: fixed cleanup of issuer for "%20" 2025-02-26 02:36:43 +03:00
Savely Savianok
8ab87fe8e9 fix: fixed parse of issuer 2025-02-26 02:28:30 +03:00
Pavel-Savely Savianok
096051b49d Merge pull request 'feat: updated icons for application (v1.1.1)' (#4) from dev into main
Reviewed-on: http://git.lisoveliy.su/Lisoveliy/TOTPFit/pulls/4
2025-02-26 00:17:06 +01:00
Savely Savianok
ca1936d20d feat: updated icons for application 2025-02-26 02:16:06 +03:00
Pavel-Savely Savianok
b12eacb5e1 Merge pull request 'v1.1.0 Release' (#3) from dev into main
Reviewed-on: http://git.lisoveliy.su/Lisoveliy/TOTPFit/pulls/3
2025-02-26 00:01:56 +01:00
Savely Savianok
430e45fb6f chore: update README.md 2025-02-26 02:00:05 +03:00
Savely Savianok
43af7e2055 chore: cleanup, v1.1.0 2025-02-26 01:58:11 +03:00
Savely Savianok
5fa5455e00 feat: added local storage for save totp directly on watches 2025-02-26 01:22:47 +03:00
28 changed files with 498 additions and 71 deletions

View File

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

View File

@@ -6,14 +6,15 @@
"appType": "app",
"version": {
"code": 1,
"name": "1.0.1"
"name": "1.3.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"
"data:os.device.info",
"device:os.local_storage"
],
"runtime": {
"apiVersion": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 76 KiB

BIN
docs/assets/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
docs/assets/image2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,37 @@
# 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.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
docs/screenshots/scr1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/screenshots/scr2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
docs/screenshots/scr3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
icon_for_appstore.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -0,0 +1,36 @@
import { Buffer } from 'buffer'
export function parseInput(input) {
const normalizedInput = input.replace(/\s/g, "");
const normalizedHexInput = normalizedInput.replace(/0x/g, "").toLowerCase();
if (isHex(normalizedHexInput)) {
return Buffer.from(normalizedHexInput, "hex");
} else {
return Buffer.from(normalizedInput, "base64");
}
}
export function isHex(string) {
let result = true;
for (const char of string) {
if (!((char >= "a" && char <= "f") || (char >= "0" && char <= "9"))) {
result = false;
}
}
return result;
}
export function bufferLeToBeHex(buffer) {
let output = "";
for (const v of buffer) {
const hex = v.toString(16);
if (hex.length === 1) {
output = "0" + hex + output;
} else {
output = hex + output;
}
}
return output;
}
export const bufferToPrettyHex = b => [...b].map(c => c.toString(16).padStart(2, '0')).join(' ');

View File

@@ -0,0 +1,132 @@
import { decodeVarint } from "./varintUtils";
export class BufferReader {
constructor(buffer) {
this.buffer = buffer;
this.offset = 0;
}
readVarInt() {
const result = decodeVarint(this.buffer, this.offset);
this.offset += result.length;
return result.value;
}
readBuffer(length) {
this.checkByte(length);
const result = this.buffer.slice(this.offset, this.offset + length);
this.offset += length;
return result;
}
// gRPC has some additional header - remove it
trySkipGrpcHeader() {
const backupOffset = this.offset;
if (this.buffer[this.offset] === 0 && this.leftBytes() >= 5) {
this.offset++;
const length = this.buffer.readInt32BE(this.offset);
this.offset += 4;
if (length > this.leftBytes()) {
// Something is wrong, revert
this.offset = backupOffset;
}
}
}
leftBytes() {
return this.buffer.length - this.offset;
}
checkByte(length) {
const bytesAvailable = this.leftBytes();
if (length > bytesAvailable) {
throw new Error(
"Not enough bytes left. Requested: " +
length +
" left: " +
bytesAvailable
);
}
}
checkpoint() {
this.savedOffset = this.offset;
}
resetToCheckpoint() {
this.offset = this.savedOffset;
}
}
export const TYPES = {
VARINT: 0,
FIXED64: 1,
LENDELIM: 2,
FIXED32: 5
};
export function decodeProto(buffer) {
const reader = new BufferReader(buffer);
const parts = [];
reader.trySkipGrpcHeader();
try {
while (reader.leftBytes() > 0) {
reader.checkpoint();
const byteRange = [reader.offset];
const indexType = parseInt(reader.readVarInt().toString());
const type = indexType & 0b111;
const index = indexType >> 3;
let value;
if (type === TYPES.VARINT) {
value = reader.readVarInt().toString();
} else if (type === TYPES.LENDELIM) {
const length = parseInt(reader.readVarInt().toString());
value = reader.readBuffer(length);
} else if (type === TYPES.FIXED32) {
value = reader.readBuffer(4);
} else if (type === TYPES.FIXED64) {
value = reader.readBuffer(8);
} else {
throw new Error("Unknown type: " + type);
}
byteRange.push(reader.offset);
parts.push({
byteRange,
index,
type,
value
});
}
} catch (err) {
reader.resetToCheckpoint();
console.log(err);
}
return {
parts,
leftOver: reader.readBuffer(reader.leftBytes())
};
}
export function typeToString(type, subType) {
switch (type) {
case TYPES.VARINT:
return "varint";
case TYPES.LENDELIM:
return subType || "len_delim";
case TYPES.FIXED32:
return "fixed32";
case TYPES.FIXED64:
return "fixed64";
default:
return "unknown";
}
}

View File

@@ -0,0 +1,23 @@
export function decodeVarint(buffer, offset) {
let res = 0;
let shift = 0;
let byte = 0;
do {
if (offset >= buffer.length) {
throw new RangeError("Index out of bound decoding varint");
}
byte = buffer[offset++];
const multiplier = 2 ** shift;
const thisByteValue = (byte & 0x7f) * multiplier;
shift += 7;
res = res + thisByteValue;
} while (byte >= 0x80);
return {
value: res,
length: shift / 7
};
}

View File

@@ -24,3 +24,57 @@ function leftpad(str, len, pad) {
str
);
}
export function encode(bytes) {
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
let bits = 0;
let value = 0;
let output = '';
for (let i = 0; i < bytes.length; i++) {
value = (value << 8) | bytes[i];
bits += 8;
while (bits >= 5) {
output += alphabet[(value >>> (bits - 5)) & 0x1F];
bits -= 5;
}
}
if (bits > 0) {
output += alphabet[(value << (5 - bits)) & 0x1F];
}
const paddingLength = (8 - (output.length % 8)) % 8;
output += '='.repeat(paddingLength);
return output;
}
export function base64decode(base64) {
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
let result = [];
let i = 0, j = 0;
let b1, b2, b3, b4;
while (i < base64.length) {
b1 = chars.indexOf(base64.charAt(i++));
b2 = chars.indexOf(base64.charAt(i++));
b3 = chars.indexOf(base64.charAt(i++));
b4 = chars.indexOf(base64.charAt(i++));
if (b1 === -1 || b2 === -1) break;
result[j++] = (b1 << 2) | (b2 >> 4);
if (b3 !== -1) {
result[j++] = ((b2 & 15) << 4) | (b3 >> 2);
}
if (b4 !== -1) {
result[j++] = ((b3 & 3) << 6) | b4;
}
}
return result.slice(0, j);
}

View File

@@ -1,12 +1,9 @@
{
"name": "totpfit",
"version": "1.0.0",
"description": "TOTP Authenticator for Amazfit devices",
"version": "1.3.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"

View File

@@ -1,19 +1,37 @@
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;
Page(
BasePage({
onInit() {
this.getTOTPData()
.then((x) => {
app._options.globalData.TOTPS = JSON.parse(x) ?? [];
let localStorage = new LocalStorage();
localStorage.setItem(
"TOTPs",
JSON.stringify(app._options.globalData.TOTPS)
);
this.initPage();
})
.catch((x) => {
console.log(`Init failed: ${x}`);
try{
let localStorage = new LocalStorage();
app._options.globalData.TOTPS = JSON.parse(
localStorage.getItem("TOTPs", [])
);
}
catch{
app._options.globalData.TOTPS = [];
}
this.initPage();
});
},

View File

@@ -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();

View File

@@ -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

View File

@@ -2,43 +2,73 @@ import { getTOTPByLink } from "./utils/queryParser.js";
let _props = null;
const colors = {
bg: "#101010",
linkBg: "#ffffffc0",
secondaryBg: "#282828",
text: "#fafafa",
alert: "#ad3c23",
notify: "#555555",
bigText: "#fafafa"
};
AppSettingsPage({
build(props) {
_props = props;
const storage = JSON.parse(
props.settingsStorage.getItem("TOTPs") ?? "[]"
);
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({
placeholder: "otpauth://",
label: "Add new OTP Link",
placeholder: "otpauth(-migration)://",
label: "Add new TOTP record",
onChange: (changes) => {
var link = getTOTPByLink(changes);
let link = getTOTPByLink(changes);
if (link == null) {
console.log("link is invalid");
return;
}
storage.push(link);
if (Array.isArray(link))
storage.push(...link);
else storage.push(link);
updateStorage(storage);
},
labelStyle: {
backgroundColor: "#14213D",
backgroundColor: colors.notify,
display: "flex",
alignItems: "center",
justifyContent: "center",
margin: "10px",
flexGrow: 1,
fontSize: "20px",
color: "#FFFFFF",
color: colors.text,
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(
{
style: {
backgroundColor: "black",
backgroundColor: colors.bg,
minHeight: "100vh",
},
},
@@ -49,22 +79,34 @@ AppSettingsPage({
textAlign: "center",
},
},
Text(
storage.length < 1 ? addTOTPsHint : Text(
{
align: "center",
paragraph: true,
style: {
marginBottom: "10px",
color: "#fff",
color: colors.bigText,
fontSize: 23,
fontWeight: "500",
verticalAlign: "middle",
},
},
"TOTPS:"
"TOTP records:"
)
),
...totpEntrys,
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;
@@ -77,18 +119,22 @@ function GetTOTPList(storage) {
storage.forEach((element) => {
const elementId = counter;
const textInput = TextInput({
placeholder: "otpauth://",
label: "Change OTP link",
placeholder: "otpauth(-migration)://",
label: "Change TOTP link",
onChange: (changes) => {
try {
storage[elementId] = getTOTPByLink(changes);
let link = getTOTPByLink(changes);
if (Array.isArray(link))
return;
storage[elementId] = link;
updateStorage(storage);
} catch (err) {
console.log(err);
}
},
labelStyle: {
backgroundColor: "#14213D",
backgroundColor: colors.notify,
textAlign: "center",
display: "flex",
alignItems: "center",
@@ -96,7 +142,7 @@ function GetTOTPList(storage) {
margin: "10px",
flexGrow: 1,
fontSize: "20px",
color: "#E5E5E5",
color: colors.text,
borderRadius: "5px",
},
});
@@ -104,8 +150,9 @@ function GetTOTPList(storage) {
{
align: "center",
style: {
color: "#ffffff",
fontSize: "16px",
color: colors.text,
fontSize: "18px",
fontWeight: "500"
},
paragraph: true,
},
@@ -119,29 +166,30 @@ function GetTOTPList(storage) {
updateStorage(storage);
},
style: {
backgroundColor: "#ba181b",
backgroundColor: colors.alert,
fontSize: "18px",
color: "#ffffff",
color: colors.text,
height: "fit-content",
margin: "10px",
},
label: "DEL",
label: "Delete",
});
const text = Text(
{
style: {
color: "#ffffff",
color: colors.text,
fontSize: "14px",
},
align: "center",
},
`${element.hashType} | ${element.digits} digits | ${element.fetchTime} seconds | offset ${element.timeOffset} seconds`
`${element.hashType} | ${element.digits} digits | ${element.fetchTime} seconds | ${element.timeOffset} sec offset`
);
const view = View(
{
style: {
textAlign: "center",
border: "2px solid white",
backgroundColor: colors.secondaryBg,
//border: "2px solid white",
borderRadius: "5px",
margin: "10px",
},

View File

@@ -1,40 +1,17 @@
import { decodeProto, TYPES } from "../../lib/protobuf-decoder/protobufDecoder";
import { TOTP } from "../../lib/totp-quickjs";
import { base64decode, encode } from "../../lib/totp-quickjs/base32decoder";
const otpScheme = "otpauth:/";
const otpauthScheme = "otpauth:/";
const googleMigrationScheme = "otpauth-migration:/";
export function getTOTPByLink(link) {
try {
let args = link.split("/", otpScheme.length);
let type = args[2]; //Returns 'hotp' or 'totp'
let issuer = args[3].split(":")[0]?.split("?")[0]; //Returns issuer
let client =
args[3].split(":")[1]?.split("?")[0] ??
args[3].split(":")[0]?.split("?")[0]; //Returns client
let secret = args[3].split("secret=")[1]?.split("&")[0]; //Returns secret
let period = args[3].split("period=")[1]?.split("&")[0]; //Returns period
let digits = args[3].split("digits=")[1]?.split("&")[0]; //Returns digits
let algorithm = args[3].split("algorithm=")[1]?.split("&")[0]; //Returns algorithm
if (link.includes(otpauthScheme))
return getByOtpauthScheme(link)
if (link.includes(googleMigrationScheme))
return getByGoogleMigrationScheme(link)
if (type.toLowerCase() != "totp")
throw new Error("Type is not valid, requires 'TOTP'");
if (secret === undefined) throw new Error("Secret not defined");
issuer = issuer.replace("%20", " ");
client = client.replace("%20", " ");
return new TOTP(
secret,
issuer,
client,
digits,
period,
0,
getHashType(algorithm)
);
} catch (err) {
return null;
}
}
function getHashType(algorithm) {
@@ -43,3 +20,95 @@ function getHashType(algorithm) {
if (algorithm == "SHA512") return "SHA-512";
else return "SHA-1";
}
function getByOtpauthScheme(link) {
try {
let args = link.split("/", otpauthScheme.length);
let type = args[2]; //Returns 'hotp' or 'totp'
let issuer = args[3].split(":")[0]?.split("?")[0]; //Returns issuer
let client =
args[3].split(":")[1]?.split("?")[0] ??
args[3].split(":")[0]?.split("?")[0]; //Returns client
let secret = args[3].split("secret=")[1]?.split("&")[0]; //Returns secret
let period = args[3].split("period=")[1]?.split("&")[0]; //Returns period
let digits = args[3].split("digit=")[1]?.split("&")[0]; //Returns digits
let algorithm = args[3].split("algorithm=")[1]?.split("&")[0]; //Returns algorithm
let offset = args[3].split("offset=")[1]?.split("&")[0] ?? 0; //Returns offset
if (type.toLowerCase() != "totp")
throw new Error("Type is not valid, requires 'TOTP'");
if (secret === undefined) throw new Error("Secret not defined");
if (issuer == client) {
issuer = args[3].split("issuer=")[1]?.split("&")[0];
}
issuer = decodeURIComponent(issuer);
client = decodeURIComponent(client);
return new TOTP(
secret,
issuer,
client,
Number(digits),
Number(period),
Number(offset),
getHashType(algorithm)
);
} catch (err) {
console.log(err)
return null;
}
}
function getByGoogleMigrationScheme(link) {
let data = link.split("data=")[1]; //Returns base64 encoded data
data = decodeURIComponent(data);
let decode = base64decode(data);
let proto = decodeProto(decode);
let protoTotps = [];
proto.parts.forEach(part => {
if (part.type == TYPES.LENDELIM) {
protoTotps.push(decodeProto(part.value));
}
});
let totps = [];
protoTotps.forEach(x => {
let type = x.parts.filter(x => x.index == 6)[0]; //find type of OTP
if (type.value !== '2') {
console.log("ERR: it's a not TOTP record")
return;
}
let secret = x.parts.filter(x => x.index == 1)[0].value;
secret = encode(secret);
let name = bytesToString(x.parts.filter(x => x.index == 2)[0].value);
let issuer = bytesToString(x.parts.filter(x => x.index == 3)[0].value);
totps.push(new TOTP(
secret,
issuer,
name,
6,
30,
0,
"SHA-1"
));
});
return totps;
}
function bytesToString(bytes) {
let str = '';
for (let i = 0; i < bytes.length; i++) {
str += String.fromCharCode(bytes[i]);
}
return str;
}