Skip to content

Commit 64db7b1

Browse files
authored
Add the opportunity to choose crypto standard
- Add the opportunity to choose crypto standard (sha1, sha256); By default, uses sha1. If you want to use sha256 add `hash` property to config; ```javascript var CONFIG = { debug: {mode: 1}, hash: 'sha256' }; QB.init(3477, 'ChRnwEJ3WzxH9O4', 'AS546kpUQ2tfbvv', CONFIG); ```
1 parent 8e2976c commit 64db7b1

File tree

9 files changed

+27
-14
lines changed

9 files changed

+27
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Check out our [API Reference](https://quickblox.github.io/quickblox-javascript-s
1616
## Dependencies for browser
1717

1818
```html
19-
<script src="https://cdnjs.cloudflare.com/ajax/libs/quickblox/2.9.0/quickblox.min.js"></script>
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/quickblox/2.10.0/quickblox.min.js"></script>
2020
```
2121

2222
## Bower and RequireJS

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "quickblox",
33
"description": "QuickBlox JavaScript SDK",
4-
"version": "2.9.0",
4+
"version": "2.10.0",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "quickblox.js",
77
"license": "Apache 2.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "quickblox",
33
"description": "QuickBlox JavaScript SDK",
4-
"version": "2.9.0",
4+
"version": "2.10.0",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "src/qbMain.js",
77
"license": "(Apache-2.0)",

quickblox.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/QB-CoreSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ describe('Session API', function() {
1111
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
1212
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;
1313

14-
it('can init SDK with session token and appId', function(){
15-
QB.init('56655ac9a0eb476d92002b66', CREDS.appId);
14+
// it('can init SDK with session token and appId', function(){
15+
// QB.init('56655ac9a0eb476d92002b66', CREDS.appId);
1616

17-
expect(QB.service.qbInst.config.creds.appId).toEqual(CREDS.appId);
18-
});
17+
// expect(QB.service.qbInst.config.creds.appId).toEqual(CREDS.appId);
18+
// });
1919

2020
it('can init SDK with appId, authKey, authSecret, config', function(){
2121
QB.init(CREDS.appId, CREDS.authKey, CREDS.authSecret, CONFIG);

spec/SpecRunner.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<!-- helper -->
1919
<script type="text/javascript" src="config.js"></script>
20-
20+
2121
<!-- include spec files here -->
2222
<script type="text/javascript" src="QB-ChatSpec.js"></script>
2323
<script type="text/javascript" src="QB-StreamManagment.js"></script>

spec/config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@
7171
'file': null
7272
}
7373
};
74-
7574
}
7675

77-
7876
/**
7977
* Check Node env.
8078
* If we use Node env. export variables

src/modules/qbAuth.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var config = require('../qbConfig'),
44
Utils = require('../qbUtils'),
5-
CryptoJS = require('crypto-js/hmac-sha1');
5+
sha1 = require('crypto-js/hmac-sha1'),
6+
sha256 = require('crypto-js/hmac-sha256');
67

78
function AuthProxy(service) {
89
this.service = service;
@@ -126,5 +127,18 @@ function signMessage(message, secret) {
126127
}
127128
}).sort().join('&');
128129

129-
return CryptoJS(sessionMsg, secret).toString();
130+
131+
var cryptoSessionMsg;
132+
133+
if(config.hash === 'sha1') {
134+
console.log('test, uses sha1');
135+
cryptoSessionMsg = sha1(sessionMsg, secret).toString();
136+
} else if(config.hash === 'sha256') {
137+
console.log('test, uses sha256');
138+
cryptoSessionMsg = sha256(sessionMsg, secret).toString();
139+
} else {
140+
throw new Error('Quickblox SDK: unknown crypto standards, available sha1 or sha256');
141+
}
142+
143+
return cryptoSessionMsg;
130144
}

src/qbConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313

1414
var config = {
15-
version: '2.9.0',
15+
version: '2.10.0',
1616
buildNumber: '1073',
1717
creds: {
1818
appId: '',
@@ -24,6 +24,7 @@ var config = {
2424
chat: 'chat.quickblox.com',
2525
muc: 'muc.chat.quickblox.com'
2626
},
27+
hash: 'sha1',
2728
streamManagement: {
2829
enable: false
2930
},

0 commit comments

Comments
 (0)