File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " gauth-decode" ,
3
- "version" : " 0.1.0 " ,
3
+ "version" : " 0.1.1 " ,
4
4
"description" : " A package to decode Google Authenticator export data" ,
5
5
"main" : " ./dist/index.js" ,
6
6
"module" : " ./dist/index.mjs" ,
Original file line number Diff line number Diff line change @@ -124,7 +124,15 @@ const decode = async (data: string) => {
124
124
*/
125
125
const makeOtpAuthKey = ( otpData : OtpDataWithBase32 , useBase32Secret : boolean = true ) => {
126
126
// TODO::Proper URI builder for OTP!
127
- return `otpauth://totp/${ otpData . name } ?secret=${ useBase32Secret ? otpData . secretBase32 : otpData . secret } &issuer=${ otpData . issuer } ` ;
127
+
128
+ // The name part should contain the issuer also, to fix this lets just change the issuer if they differ.
129
+ let issuerFromName = otpData . issuer ;
130
+ const nameData = otpData . name . split ( ":" ) ;
131
+ if ( nameData . length === 2 && nameData [ 0 ] !== otpData . issuer ) {
132
+ issuerFromName = nameData [ 0 ] ;
133
+ }
134
+
135
+ return `otpauth://totp/${ otpData . name } ?secret=${ useBase32Secret ? otpData . secretBase32 : otpData . secret } &issuer=${ issuerFromName } ` ;
128
136
} ;
129
137
130
138
export type { OtpDataWithBase32 } ;
You can’t perform that action at this time.
0 commit comments