File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @ixo/matrix-bot-sdk" ,
3- "version" : " 0.8.0-ixo.5 " ,
3+ "version" : " 0.8.0-ixo.6 " ,
44 "description" : " TypeScript/JavaScript SDK for Matrix bots and appservices (ixo fork)" ,
55 "repository" : {
66 "type" : " git" ,
Original file line number Diff line number Diff line change @@ -125,13 +125,20 @@ export class BackupManager {
125125 * @returns The recovery key in Base64 format
126126 */
127127 public static decodeRecoveryKey ( recoveryKey : string ) : string {
128- // Check if it looks like Base58 (contains spaces or matches Base58 pattern)
129- const hasSpaces = recoveryKey . includes ( " " ) ;
130- const looksLikeBase64 = recoveryKey . includes ( "=" ) || recoveryKey . includes ( "+" ) || recoveryKey . includes ( "/" ) ;
131-
132- if ( ! hasSpaces && looksLikeBase64 ) {
133- // Already Base64, return as-is
134- return recoveryKey ;
128+ // Try Base64 first: if it decodes to exactly 32 bytes, it's a raw backup key
129+ if ( ! recoveryKey . includes ( " " ) ) {
130+ try {
131+ const decoded = Buffer . from ( recoveryKey , "base64" ) ;
132+ if ( decoded . length === KEY_SIZE ) {
133+ // Verify it's actually base64 and not just coincidence by re-encoding
134+ const reencoded = decoded . toString ( "base64" ) ;
135+ if ( reencoded === recoveryKey || reencoded . replace ( / = + $ / , "" ) === recoveryKey . replace ( / = + $ / , "" ) ) {
136+ return recoveryKey ;
137+ }
138+ }
139+ } catch {
140+ // Not valid base64, fall through to Base58
141+ }
135142 }
136143
137144 // Decode from Base58
You can’t perform that action at this time.
0 commit comments