Skip to content

feat: Remove CoreManager SERVER_AUTH_TYPE and SERVER_AUTH_TOKEN infavor of REQUEST_HEADERS #2639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/CoreManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@ const config: Config & Record<string, any> = {
REQUEST_BATCH_SIZE: 20,
REQUEST_HEADERS: {},
SERVER_URL: 'https://api.parse.com/1',
SERVER_AUTH_TYPE: null,
SERVER_AUTH_TOKEN: null,
LIVEQUERY_SERVER_URL: null,
ENCRYPTED_KEY: null,
VERSION: 'js' + process.env.npm_package_version,
Expand Down
22 changes: 0 additions & 22 deletions src/Parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,28 +226,6 @@ const Parse = {
return CoreManager.get('SERVER_URL');
},

/**
* @property {string} Parse.serverAuthToken
* @static
*/
set serverAuthToken(value) {
CoreManager.set('SERVER_AUTH_TOKEN', value);
},
get serverAuthToken() {
return CoreManager.get('SERVER_AUTH_TOKEN');
},

/**
* @property {string} Parse.serverAuthType
* @static
*/
set serverAuthType(value) {
CoreManager.set('SERVER_AUTH_TYPE', value);
},
get serverAuthType() {
return CoreManager.get('SERVER_AUTH_TYPE');
},

/**
* @property {ParseLiveQuery} Parse.LiveQuery
* @static
Expand Down
4 changes: 0 additions & 4 deletions src/RESTController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ const RESTController = {
if (isIdempotent) {
headers['X-Parse-Request-Id'] = requestId;
}
if (CoreManager.get('SERVER_AUTH_TYPE') && CoreManager.get('SERVER_AUTH_TOKEN')) {
headers['Authorization'] =
CoreManager.get('SERVER_AUTH_TYPE') + ' ' + CoreManager.get('SERVER_AUTH_TOKEN');
}
const customHeaders = CoreManager.get('REQUEST_HEADERS');
for (const key in customHeaders) {
headers[key] = customHeaders[key];
Expand Down
10 changes: 0 additions & 10 deletions src/__tests__/Parse-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ describe('Parse module', () => {
expect(Parse.liveQueryServerURL).toBe('https://example.com');
});

it('can set auth type and token', () => {
Parse.serverAuthType = 'bearer';
expect(CoreManager.get('SERVER_AUTH_TYPE')).toBe('bearer');
expect(Parse.serverAuthType).toBe('bearer');

Parse.serverAuthToken = 'some_token';
expect(CoreManager.get('SERVER_AUTH_TOKEN')).toBe('some_token');
expect(Parse.serverAuthToken).toBe('some_token');
});

it('can set idempotency', () => {
expect(Parse.idempotency).toBe(false);
Parse.idempotency = true;
Expand Down
10 changes: 0 additions & 10 deletions src/__tests__/RESTController-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,6 @@ describe('RESTController', () => {
}).toThrow('Cannot use the Master Key, it has not been provided.');
});

it('sends auth header when the auth type and token flags are set', async () => {
CoreManager.set('SERVER_AUTH_TYPE', 'Bearer');
CoreManager.set('SERVER_AUTH_TOKEN', 'some_random_token');
mockFetch([{ status: 200, response: { results: [] } }]);
await RESTController.request('GET', 'classes/MyObject', {}, {});
expect(fetch.mock.calls[0][1].headers['Authorization']).toEqual('Bearer some_random_token');
CoreManager.set('SERVER_AUTH_TYPE', null);
CoreManager.set('SERVER_AUTH_TOKEN', null);
});

it('reports upload/download progress of the AJAX request when callback is provided', async () => {
mockFetch([{ status: 200, response: { success: true } }], { 'Content-Length': 10 });
const options = {
Expand Down
10 changes: 0 additions & 10 deletions types/Parse.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,6 @@ declare const Parse: {
* @static
*/
serverURL: any;
/**
* @property {string} Parse.serverAuthToken
* @static
*/
serverAuthToken: any;
/**
* @property {string} Parse.serverAuthType
* @static
*/
serverAuthType: any;
/**
* @property {ParseLiveQuery} Parse.LiveQuery
* @static
Expand Down