Skip to content
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

Generate and submit registrationId, fixes #25 #26

Merged
merged 1 commit into from
May 14, 2014
Merged
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
7 changes: 4 additions & 3 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var API = new function() {
};

this.confirmCode = function(code, number, password,
signaling_key, single_device,
signaling_key, registrationId, single_device,
success_callback, error_callback) {
var call = single_device ? 'accounts' : 'devices';
var urlPrefix = single_device ? '/code/' : '/';
Expand All @@ -115,8 +115,9 @@ var API = new function() {
user : number,
password : password,
jsonData : { signalingKey : btoa(getString(signaling_key)),
supportsSms : false,
fetchesMessages : true },
supportsSms : false,
fetchesMessages : true,
registrationId: registrationId},
}).then(function(response) {
if (success_callback !== undefined)
success_callback(response);
Expand Down
4 changes: 3 additions & 1 deletion js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var single_device = false;
var signaling_key = window.crypto.getRandomBytes(32 + 20);
var password = btoa(getString(window.crypto.getRandomBytes(16)));
password = password.substring(0, password.length - 2);
var registrationId = new Uint16Array(window.crypto.getRandomBytes(2))[0];
registrationId = registrationId & 0x3fff;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 0x3fff instead of 7?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 7?? server api docs say it should be a 14 bit number.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have api docs???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


$('#init-go-single-client').click(function() {
if (numberMatches()) {
Expand Down Expand Up @@ -73,7 +75,7 @@ $('#init-go').click(function() {
$('#verify4done').html('');
$('#verify').show();

API.confirmCode($('#code').val(), number, password, signaling_key, single_device,
API.confirmCode($('#code').val(), number, password, signaling_key, registrationId, single_device,
function(response) {
if (single_device)
response = 1;
Expand Down