Skip to content

Commit 73c6e96

Browse files
committed
fix: address PR comments about token decoding
1 parent 6707a71 commit 73c6e96

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

packages/ide/vscode/src/extension/zenstack-auth-provider.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,8 @@ export class ZenStackAuthenticationProvider implements vscode.AuthenticationProv
204204
throw new Error('Invalid JWT format');
205205
}
206206

207-
// Decode the payload (second part)
208-
const payload = parts[1]!;
209-
// Add padding if needed for base64 decoding
210-
const paddedPayload = payload + '='.repeat((4 - (payload.length % 4)) % 4);
211-
const decoded = atob(paddedPayload);
207+
// Decode the payload (second part) - JWT uses base64url encoding
208+
const decoded = Buffer.from(parts[1]!, 'base64url').toString('utf8');
212209

213210
return JSON.parse(decoded);
214211
} catch (error) {

0 commit comments

Comments
 (0)