Skip to content

Commit 74a7555

Browse files
authored
Merge branch 'alpha' into use-graphLookup
2 parents 28c340a + 95da5d6 commit 74a7555

20 files changed

+267
-74
lines changed

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@
2525
"space-infix-ops": "error",
2626
"no-useless-escape": "off",
2727
"require-atomic-updates": "off"
28+
},
29+
"globals": {
30+
"Parse": true
2831
}
2932
}

changelogs/CHANGELOG_alpha.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# [6.3.0-alpha.6](https://github.com/parse-community/parse-server/compare/6.3.0-alpha.5...6.3.0-alpha.6) (2023-07-17)
2+
3+
4+
### Bug Fixes
5+
6+
* Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](https://github.com/parse-community/parse-server/issues/8688)) ([6a4a00c](https://github.com/parse-community/parse-server/commit/6a4a00ca7af1163ea74b047b85cd6817366b824b))
7+
8+
# [6.3.0-alpha.5](https://github.com/parse-community/parse-server/compare/6.3.0-alpha.4...6.3.0-alpha.5) (2023-07-05)
9+
10+
11+
### Features
12+
13+
* Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](https://github.com/parse-community/parse-server/issues/8670)) ([a9d376b](https://github.com/parse-community/parse-server/commit/a9d376b61f5b07806eafbda91c4e36c322f09298))
14+
15+
# [6.3.0-alpha.4](https://github.com/parse-community/parse-server/compare/6.3.0-alpha.3...6.3.0-alpha.4) (2023-07-04)
16+
17+
18+
### Bug Fixes
19+
20+
* Server does not start via CLI when `auth` option is set ([#8666](https://github.com/parse-community/parse-server/issues/8666)) ([4e2000b](https://github.com/parse-community/parse-server/commit/4e2000bc563324389584ace3c090a5c1a7796a64))
21+
122
# [6.3.0-alpha.3](https://github.com/parse-community/parse-server/compare/6.3.0-alpha.2...6.3.0-alpha.3) (2023-06-23)
223

324

package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-server",
3-
"version": "6.3.0-alpha.3",
3+
"version": "6.3.0-alpha.6",
44
"description": "An express module providing a Parse-compatible API server",
55
"main": "lib/index.js",
66
"repository": {
@@ -48,7 +48,7 @@
4848
"mime": "3.0.0",
4949
"mongodb": "4.10.0",
5050
"mustache": "4.2.0",
51-
"otpauth": "9.0.2",
51+
"otpauth": "9.1.2",
5252
"parse": "4.1.0",
5353
"path-to-regexp": "6.2.1",
5454
"pg-monitor": "2.0.0",

spec/AuthenticationAdapters.spec.js

+54-10
Original file line numberDiff line numberDiff line change
@@ -2445,9 +2445,9 @@ describe('OTP TOTP auth adatper', () => {
24452445
const response = user.get('authDataResponse');
24462446
expect(response.mfa).toBeDefined();
24472447
expect(response.mfa.recovery).toBeDefined();
2448-
expect(response.mfa.recovery.length).toEqual(2);
2448+
expect(response.mfa.recovery.split(',').length).toEqual(2);
24492449
await user.fetch();
2450-
expect(user.get('authData').mfa).toEqual({ enabled: true });
2450+
expect(user.get('authData').mfa).toEqual({ status: 'enabled' });
24512451
});
24522452

24532453
it('can login with valid token', async () => {
@@ -2473,13 +2473,15 @@ describe('OTP TOTP auth adatper', () => {
24732473
username: 'username',
24742474
password: 'password',
24752475
authData: {
2476-
mfa: totp.generate(),
2476+
mfa: {
2477+
token: totp.generate(),
2478+
},
24772479
},
24782480
}),
24792481
}).then(res => res.data);
24802482
expect(response.objectId).toEqual(user.id);
24812483
expect(response.sessionToken).toBeDefined();
2482-
expect(response.authData).toEqual({ mfa: { enabled: true } });
2484+
expect(response.authData).toEqual({ mfa: { status: 'enabled' } });
24832485
expect(Object.keys(response).sort()).toEqual(
24842486
[
24852487
'objectId',
@@ -2528,6 +2530,42 @@ describe('OTP TOTP auth adatper', () => {
25282530
expect(user.get('authData').mfa.secret).toEqual(new_secret.base32);
25292531
});
25302532

2533+
it('cannot change OTP with invalid token', async () => {
2534+
const user = await Parse.User.signUp('username', 'password');
2535+
const OTPAuth = require('otpauth');
2536+
const secret = new OTPAuth.Secret();
2537+
const totp = new OTPAuth.TOTP({
2538+
algorithm: 'SHA1',
2539+
digits: 6,
2540+
period: 30,
2541+
secret,
2542+
});
2543+
const token = totp.generate();
2544+
await user.save(
2545+
{ authData: { mfa: { secret: secret.base32, token } } },
2546+
{ sessionToken: user.getSessionToken() }
2547+
);
2548+
2549+
const new_secret = new OTPAuth.Secret();
2550+
const new_totp = new OTPAuth.TOTP({
2551+
algorithm: 'SHA1',
2552+
digits: 6,
2553+
period: 30,
2554+
secret: new_secret,
2555+
});
2556+
const new_token = new_totp.generate();
2557+
await expectAsync(
2558+
user.save(
2559+
{
2560+
authData: { mfa: { secret: new_secret.base32, token: new_token, old: '123' } },
2561+
},
2562+
{ sessionToken: user.getSessionToken() }
2563+
)
2564+
).toBeRejectedWith(new Parse.Error(Parse.Error.OTHER_CAUSE, 'Invalid MFA token'));
2565+
await user.fetch({ useMasterKey: true });
2566+
expect(user.get('authData').mfa.secret).toEqual(secret.base32);
2567+
});
2568+
25312569
it('future logins require TOTP token', async () => {
25322570
const user = await Parse.User.signUp('username', 'password');
25332571
const OTPAuth = require('otpauth');
@@ -2572,7 +2610,9 @@ describe('OTP TOTP auth adatper', () => {
25722610
username: 'username',
25732611
password: 'password',
25742612
authData: {
2575-
mfa: 'abcd',
2613+
mfa: {
2614+
token: 'abcd',
2615+
},
25762616
},
25772617
}),
25782618
}).catch(e => {
@@ -2619,7 +2659,7 @@ describe('OTP SMS auth adatper', () => {
26192659
const spy = spyOn(mfa, 'sendSMS').and.callThrough();
26202660
await user.save({ authData: { mfa: { mobile: '+11111111111' } } }, { sessionToken });
26212661
await user.fetch({ sessionToken });
2622-
expect(user.get('authData')).toEqual({ mfa: { enabled: false } });
2662+
expect(user.get('authData')).toEqual({ mfa: { status: 'disabled' } });
26232663
expect(spy).toHaveBeenCalledWith(code, '+11111111111');
26242664
await user.fetch({ useMasterKey: true });
26252665
const authData = user.get('authData').mfa?.pending;
@@ -2629,7 +2669,7 @@ describe('OTP SMS auth adatper', () => {
26292669

26302670
await user.save({ authData: { mfa: { mobile, token: code } } }, { sessionToken });
26312671
await user.fetch({ sessionToken });
2632-
expect(user.get('authData')).toEqual({ mfa: { enabled: true } });
2672+
expect(user.get('authData')).toEqual({ mfa: { status: 'enabled' } });
26332673
});
26342674

26352675
it('future logins require SMS code', async () => {
@@ -2658,7 +2698,9 @@ describe('OTP SMS auth adatper', () => {
26582698
username: 'username',
26592699
password: 'password',
26602700
authData: {
2661-
mfa: true,
2701+
mfa: {
2702+
token: 'request',
2703+
},
26622704
},
26632705
}),
26642706
}).catch(e => e.data);
@@ -2672,13 +2714,15 @@ describe('OTP SMS auth adatper', () => {
26722714
username: 'username',
26732715
password: 'password',
26742716
authData: {
2675-
mfa: code,
2717+
mfa: {
2718+
token: code,
2719+
},
26762720
},
26772721
}),
26782722
}).then(res => res.data);
26792723
expect(response.objectId).toEqual(user.id);
26802724
expect(response.sessionToken).toBeDefined();
2681-
expect(response.authData).toEqual({ mfa: { enabled: true } });
2725+
expect(response.authData).toEqual({ mfa: { status: 'enabled' } });
26822726
expect(Object.keys(response).sort()).toEqual(
26832727
[
26842728
'objectId',

spec/CLI.spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,25 @@ describe('execution', () => {
302302
done.fail(data.toString());
303303
});
304304
});
305+
306+
it('can start Parse Server with auth via CLI', done => {
307+
const env = { ...process.env };
308+
env.NODE_OPTIONS = '--dns-result-order=ipv4first';
309+
childProcess = spawn(
310+
binPath,
311+
['--databaseURI', databaseURI, './spec/configs/CLIConfigAuth.json'],
312+
{ env }
313+
);
314+
childProcess.stdout.on('data', data => {
315+
data = data.toString();
316+
console.log(data);
317+
if (data.includes('parse-server running on')) {
318+
done();
319+
}
320+
});
321+
childProcess.stderr.on('data', data => {
322+
data = data.toString();
323+
done.fail(data.toString());
324+
});
325+
});
305326
});

spec/CloudCode.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ describe('Cloud Code', () => {
103103
expect(currentConfig.silent).toBeFalse();
104104
});
105105

106+
it('can get curent version', () => {
107+
const version = require('../package.json').version;
108+
const currentConfig = Config.get('test');
109+
expect(Parse.Server.version).toBeDefined();
110+
expect(currentConfig.version).toBeDefined();
111+
expect(Parse.Server.version).toEqual(version);
112+
});
113+
106114
it('show warning on duplicate cloud functions', done => {
107115
const logger = require('../lib/logger').logger;
108116
spyOn(logger, 'warn').and.callFake(() => {});

spec/DefinedSchemas.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ describe('DefinedSchemas', () => {
554554
});
555555
});
556556

557-
it('should not delete automatically classes', async () => {
557+
it('should not delete classes automatically', async () => {
558558
await reconfigureServer({
559559
schema: { definitions: [{ className: '_User' }, { className: 'Test' }] },
560560
});

spec/ParseFile.spec.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ describe('Parse.File testing', () => {
13681368
await reconfigureServer({
13691369
fileUpload: {
13701370
enableForPublic: true,
1371-
fileExtensions: ['jpg'],
1371+
fileExtensions: ['jpg', 'wav'],
13721372
},
13731373
});
13741374
await expectAsync(
@@ -1387,6 +1387,30 @@ describe('Parse.File testing', () => {
13871387
).toBeRejectedWith(
13881388
new Parse.Error(Parse.Error.FILE_SAVE_ERROR, `File upload of extension html is disabled.`)
13891389
);
1390+
await expectAsync(
1391+
request({
1392+
method: 'POST',
1393+
url: 'http://localhost:8378/1/files/file',
1394+
body: JSON.stringify({
1395+
_ApplicationId: 'test',
1396+
_JavaScriptKey: 'test',
1397+
_ContentType: 'image/jpg',
1398+
base64: 'PGh0bWw+PC9odG1sPgo=',
1399+
}),
1400+
})
1401+
).toBeResolved();
1402+
await expectAsync(
1403+
request({
1404+
method: 'POST',
1405+
url: 'http://localhost:8378/1/files/file',
1406+
body: JSON.stringify({
1407+
_ApplicationId: 'test',
1408+
_JavaScriptKey: 'test',
1409+
_ContentType: 'audio/wav',
1410+
base64: 'UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA',
1411+
}),
1412+
})
1413+
).toBeResolved();
13901414
});
13911415

13921416
it('works with array without Content-Type', async () => {

spec/configs/CLIConfigAuth.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"appName": "test",
3+
"appId": "test",
4+
"masterKey": "test",
5+
"logLevel": "error",
6+
"auth": {
7+
"facebook": {
8+
"appIds": "test"
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)