Skip to content

Commit 13f2bef

Browse files
committed
fix: snyk issue
1 parent 38439b9 commit 13f2bef

File tree

7 files changed

+26
-447
lines changed

7 files changed

+26
-447
lines changed

lib/core/oauthHandler.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,18 @@ export default class OAuthHandler {
6161
const base64String = btoa(String.fromCharCode(...hashArray));
6262
return base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); // URL-safe Base64
6363
} else {
64-
// Use crypto-browserify in Node.js environment
65-
const crypto = require('crypto-browserify');
64+
// In Node.js: Use the native `crypto` module for hashing
65+
const crypto = require('crypto');
66+
6667
const hash = crypto.createHash('sha256');
6768
hash.update(codeVerifier);
6869
const hashBuffer = hash.digest();
69-
const base64String = hashBuffer.toString('base64');
70+
71+
// Convert to Base64 and URL-safe Base64
72+
let base64String = hashBuffer.toString('base64');
7073
return base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); // URL-safe Base64
71-
}
72-
}
74+
}
75+
}
7376

7477
/**
7578
* @description Authorize the user by redirecting to the OAuth provider's authorization page

0 commit comments

Comments
 (0)