feat: adding protobuf decoder for parse of google auth migrations
This commit is contained in:
@@ -1,10 +1,29 @@
|
||||
import { decodeProto } from "../../lib/protobuf-decoder/protobufDecoder";
|
||||
import { TOTP } from "../../lib/totp-quickjs";
|
||||
import { base64decode } from "../../lib/totp-quickjs/base32decoder";
|
||||
|
||||
const otpScheme = "otpauth:/";
|
||||
const otpauthScheme = "otpauth:/";
|
||||
const googleMigrationScheme = "otpauth-migration:/";
|
||||
|
||||
export function getTOTPByLink(link) {
|
||||
if(link.includes(otpauthScheme))
|
||||
return getByOtpauthScheme(link)
|
||||
if(link.includes(googleMigrationScheme))
|
||||
return getByGoogleMigrationScheme(link)
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getHashType(algorithm) {
|
||||
if (algorithm == "SHA1") return "SHA-1";
|
||||
if (algorithm == "SHA256") return "SHA-256";
|
||||
if (algorithm == "SHA512") return "SHA-512";
|
||||
else return "SHA-1";
|
||||
}
|
||||
|
||||
function getByOtpauthScheme(link){
|
||||
try {
|
||||
let args = link.split("/", otpScheme.length);
|
||||
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 =
|
||||
@@ -42,9 +61,9 @@ export function getTOTPByLink(link) {
|
||||
}
|
||||
}
|
||||
|
||||
function getHashType(algorithm) {
|
||||
if (algorithm == "SHA1") return "SHA-1";
|
||||
if (algorithm == "SHA256") return "SHA-256";
|
||||
if (algorithm == "SHA512") return "SHA-512";
|
||||
else return "SHA-1";
|
||||
}
|
||||
function getByGoogleMigrationScheme(link){
|
||||
console.log("Hello")
|
||||
let data = link.split("data=")[1]; //Returns secret
|
||||
let decodedProto = decodeProto(base64decode(data));
|
||||
console.log(decodedProto)
|
||||
}
|
||||
Reference in New Issue
Block a user