Skip to content

Conversation

@amrography
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.48%. Comparing base (6c40588) to head (d8d68a5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   48.78%   50.48%   +1.70%     
==========================================
  Files           2        2              
  Lines         205      208       +3     
  Branches       53       49       -4     
==========================================
+ Hits          100      105       +5     
  Misses        103      103              
+ Partials        2        0       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…t 19 compatibility

- Updated TypeScript compiler options:
  - "target": "ES2020"
  - "module": "ESNext"
  - "outDir": "./dist"
  - Enabled esModuleInterop, strict mode, and proper module resolution
- Ensures proper ESM output for Vite and React 19 projects
- Keeps type declarations in "dist" folder
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces deprecated Node.js crypto usage with browser-compatible alternatives to support client-side authentication. The changes migrate from crypto and jsonwebtoken packages to jose, jwt-decode, and js-sha256, while also modernizing the TypeScript configuration.

Key Changes:

  • Replaced Node.js crypto module with js-sha256 for hashing and custom random string generation
  • Migrated from jsonwebtoken to jose and jwt-decode for JWT operations
  • Updated TypeScript target to ES2020 and module system to ESNext

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 4 comments.

File Description
package.json Removed deprecated crypto and jsonwebtoken dependencies; added jose, js-sha256, and jwt-decode as replacements; updated TypeScript to v5.9.3
tsconfig.json Modernized compiler options with ES2020 target, ESNext modules, and additional strict mode settings for better type safety
src/AuthManager.ts Implemented browser-compatible crypto alternatives: custom random string generator for PKCE, js-sha256 for hashing, and split JWT operations between jose (verify) and jwt-decode (decode); updated return types to allow null values
package-lock.json Dependency tree updates reflecting the package changes with removal of jsonwebtoken-related dependencies and addition of new crypto libraries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SirNarsh SirNarsh requested a review from Copilot November 18, 2025 20:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 7 out of 10 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

expect(localStorage.setItem).toHaveBeenCalledWith('codeChallenge', expect.anything());
});

const loginCallback = vi.fn()
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after vi.fn(). This is inconsistent with other similar lines in the file (e.g., lines 33, 44, 106) and standard JavaScript/TypeScript conventions.

Suggested change
const loginCallback = vi.fn()
const loginCallback = vi.fn();

Copilot uses AI. Check for mistakes.

describe('AuthManager Tests isolated ', () => {
it("doesn't refresh access token when its not expired", async () => {
const stateChange = vi.fn()
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after vi.fn(). This is inconsistent with other similar lines in the file and standard JavaScript/TypeScript conventions.

Suggested change
const stateChange = vi.fn()
const stateChange = vi.fn();

Copilot uses AI. Check for mistakes.
it('throws an error when no refresh token is found', async () => {
localStorage.removeItem('refresh_token');

const loginCallback = vi.fn()
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after vi.fn(). This is inconsistent with other similar lines in the file and standard JavaScript/TypeScript conventions.

Suggested change
const loginCallback = vi.fn()
const loginCallback = vi.fn();

Copilot uses AI. Check for mistakes.



const loginCallback = vi.fn()
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after vi.fn(). This is inconsistent with other similar lines in the file and standard JavaScript/TypeScript conventions.

Copilot uses AI. Check for mistakes.
it('logs out and clears local storage', async () => {
mock.onPost('http://auth-server.com/auth/logout').reply(200);

const loginCallback = vi.fn()
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after vi.fn(). This is inconsistent with other similar lines in the file and standard JavaScript/TypeScript conventions.

Suggested change
const loginCallback = vi.fn()
const loginCallback = vi.fn();

Copilot uses AI. Check for mistakes.

const manager = AuthManager.initialize('http://auth-server.com/', 'example-realm', 'http://myapp.com/callback', stateChange);
const currentCallCount = (localStorage.getItem as Mock)
.mock?.calls?.length;
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional chaining on .mock?.calls?.length could return undefined, but currentCallCount is used in arithmetic at line 125. This will result in NaN if the mock hasn't been called yet. Consider using a fallback value: const currentCallCount = (localStorage.getItem as Mock).mock?.calls?.length ?? 0;

Suggested change
.mock?.calls?.length;
.mock?.calls?.length ?? 0;

Copilot uses AI. Check for mistakes.
let nodeCrypto: typeof import("crypto") | undefined;

if (typeof window === "undefined") {
nodeCrypto = await import("crypto");
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Top-level await is used here, which requires the module system to support it. While this works with modern ESM, consider wrapping this in a try-catch block to handle potential import failures gracefully, especially since this is a critical initialization step.

Copilot uses AI. Check for mistakes.
@SirNarsh SirNarsh merged commit e4de60f into main Nov 18, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants