refactor: remove deprecated url.parse() method (#7751)
This commit is contained in:
@@ -14,20 +14,23 @@ const authData = {
|
||||
const { Parse } = require('parse/node');
|
||||
const crypto = require('crypto');
|
||||
const https = require('https');
|
||||
const url = require('url');
|
||||
|
||||
const cache = {}; // (publicKey -> cert) cache
|
||||
|
||||
function verifyPublicKeyUrl(publicKeyUrl) {
|
||||
const parsedUrl = url.parse(publicKeyUrl);
|
||||
if (parsedUrl.protocol !== 'https:') {
|
||||
try {
|
||||
const parsedUrl = new URL(publicKeyUrl);
|
||||
if (parsedUrl.protocol !== 'https:') {
|
||||
return false;
|
||||
}
|
||||
const hostnameParts = parsedUrl.hostname.split('.');
|
||||
const length = hostnameParts.length;
|
||||
const domainParts = hostnameParts.slice(length - 2, length);
|
||||
const domain = domainParts.join('.');
|
||||
return domain === 'apple.com';
|
||||
} catch(error) {
|
||||
return false;
|
||||
}
|
||||
const hostnameParts = parsedUrl.hostname.split('.');
|
||||
const length = hostnameParts.length;
|
||||
const domainParts = hostnameParts.slice(length - 2, length);
|
||||
const domain = domainParts.join('.');
|
||||
return domain === 'apple.com';
|
||||
}
|
||||
|
||||
function convertX509CertToPEM(X509Cert) {
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
*/
|
||||
|
||||
const Parse = require('parse/node').Parse;
|
||||
const url = require('url');
|
||||
const querystring = require('querystring');
|
||||
const httpsRequest = require('./httpsRequest');
|
||||
|
||||
@@ -112,7 +111,7 @@ function requestTokenInfo(options, access_token) {
|
||||
if (!options || !options.tokenIntrospectionEndpointUrl) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, MISSING_URL);
|
||||
}
|
||||
const parsedUrl = url.parse(options.tokenIntrospectionEndpointUrl);
|
||||
const parsedUrl = new URL(options.tokenIntrospectionEndpointUrl);
|
||||
const postData = querystring.stringify({
|
||||
token: access_token,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user