зеркало из https://github.com/mozilla/fxa.git
rebasing
This commit is contained in:
Коммит
cdc186785e
|
@ -8,6 +8,10 @@
|
|||
|
||||
`grunt debug` - builds the regular library, runs test, watches for changes. Helpful when you are debugging.
|
||||
|
||||
`grunt release` - will prepare a new release of this library.
|
||||
After the task, push the repositories in `build` and `docs` directories. Tag it on GitHub using the Releases feature.
|
||||
|
||||
|
||||
### SJCL Notes
|
||||
|
||||
Currently [SJCL](http://bitwiseshiftleft.github.io/sjcl/) is built with `./configure --without-random --without-ocb2 --without-gcm --without-ccm`.
|
||||
|
|
|
@ -26,6 +26,9 @@ module.exports = function (grunt) {
|
|||
grunt.registerTask('default',
|
||||
['build']);
|
||||
|
||||
grunt.registerTask('release',
|
||||
['build', 'yuidoc', 'buildcontrol']);
|
||||
|
||||
grunt.registerTask('dev',
|
||||
['watch:dev']);
|
||||
|
||||
|
|
|
@ -5,15 +5,10 @@ fxa-js-client
|
|||
|
||||
Web client that talks to the Firefox Accounts API server
|
||||
|
||||
[__Download Library__](https://github.com/mozilla/fxa-js-client/releases)
|
||||
|
||||
## Build Library
|
||||
Install using [Bower](http://bower.io/): `bower install git://github.com/mozilla/fxa-js-client`
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
The `build` directory should have `fxa-client.js` and `fxa-client.min.js`.
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -26,7 +21,18 @@ client.signUp(email, password);
|
|||
client.signIn(email, password);
|
||||
```
|
||||
|
||||
See [Library Documentation](http://mozilla.github.io/fxa-js-client/docs/classes/FxAccountClient.html) for more.
|
||||
See [Library Documentation](http://mozilla.github.io/fxa-js-client/classes/FxAccountClient.html) for more.
|
||||
|
||||
|
||||
## Build Library
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
The `build` directory should have `fxa-client.js` and `fxa-client.min.js`.
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
define(['./lib/request', '../components/sjcl/sjcl', './lib/credentials'], function (Request, sjcl, credentials) {
|
||||
define(['./lib/request', '../components/sjcl/sjcl', './lib/credentials', './lib/hawkCredentials'], function (Request, sjcl, credentials, hawkCredentials) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
|
@ -79,6 +79,19 @@ define(['./lib/request', '../components/sjcl/sjcl', './lib/credentials'], functi
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @method recoveryEmailStatus
|
||||
* @param {String} sessionToken sessionToken obtained from signIn
|
||||
* @return {Promise} A promise that will be fulfilled with `result` of an XHR request
|
||||
*/
|
||||
FxAccountClient.prototype.recoveryEmailStatus = function(sessionToken) {
|
||||
var self = this;
|
||||
return hawkCredentials(sessionToken, "sessionToken", 2 * 32)
|
||||
.then(function(creds) {
|
||||
return self.request.send("/recovery_email/status", "GET", creds);
|
||||
});
|
||||
};
|
||||
|
||||
return FxAccountClient;
|
||||
});
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ define(['../../components/sjcl/sjcl', '../../components/p/p'], function (sjcl, P
|
|||
* @method derive
|
||||
* @param {bitArray} input The password hex buffer.
|
||||
* @param {bitArray} salt The salt string buffer.
|
||||
* @return {bitArray} the derived key bit array.
|
||||
* @return {int} iterations the derived key bit array.
|
||||
*/
|
||||
derive: function(input, salt, iterations, len) {
|
||||
var result = sjcl.misc.pbkdf2(input, salt, iterations, len, sjcl.misc.hmac);
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
//this snippet. Ask almond to synchronously require the
|
||||
//module value for 'main' here and return it as the
|
||||
//value to use for the public API for the built file.
|
||||
return require('client/FxAccountClient');
|
||||
return requirejs('client/FxAccountClient');
|
||||
}));
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"intern": "~1.3.2",
|
||||
"xmlhttprequest": "git://github.com/zaach/node-XMLHttpRequest.git#onerror",
|
||||
"grunt-contrib-yuidoc": "~0.5.0",
|
||||
"grunt-open": "~0.2.2"
|
||||
"grunt-open": "~0.2.2",
|
||||
"grunt-build-control": "~0.1.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ module.exports = function (grunt) {
|
|||
options: {
|
||||
baseUrl: '.',
|
||||
include: ['client/FxAccountClient'],
|
||||
insertRequire: ['client/FxAccountClient'],
|
||||
name: 'components/almond/almond',
|
||||
wrap: {
|
||||
startFile: 'config/start.frag',
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
module.exports = function (grunt) {
|
||||
var fs = require('fs');
|
||||
var exec = require('child_process').exec;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'tests/addons/sinon'
|
||||
], function (Sinon) {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'tests/lib/main',
|
||||
'tests/lib/request',
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
See Console....
|
||||
|
||||
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script src="../build/fxa-client.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.9/require.min.js"></script>
|
||||
|
||||
<script>
|
||||
var email = 'example' + Date.now() + '@example.com';
|
||||
var password = 'allyourbasearebelongtous';
|
||||
|
@ -37,5 +38,14 @@ See Console....
|
|||
client.signIn($('#email').val(),$('#password').val());
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
require([
|
||||
'../build/fxa-client'
|
||||
],
|
||||
function(fxa) {
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Learn more about configuring this file at <https://github.com/theintern/intern/wiki/Configuring-Intern>.
|
||||
// These default settings work OK for most people. The options that *must* be changed below are the
|
||||
// packages, suites, excludeInstrumentation, and (if you want functional tests) functionalSuites.
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'./intern'
|
||||
], function (intern) {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'./intern'
|
||||
], function (intern) {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'intern!tdd',
|
||||
'intern/chai!assert',
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'intern!tdd',
|
||||
'intern/chai!assert',
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'intern!tdd',
|
||||
'intern/chai!assert',
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'intern!tdd',
|
||||
'intern/chai!assert',
|
||||
|
@ -103,6 +107,70 @@ define([
|
|||
})
|
||||
});
|
||||
|
||||
test('#check verification status', function () {
|
||||
var user = 'test4' + Date.now();
|
||||
var email = user + '@restmail.net';
|
||||
var password = 'iliketurtles';
|
||||
var uid;
|
||||
var sessionToken;
|
||||
|
||||
setTimeout(function() {
|
||||
SinonResponder.respond(requests[0], RequestMocks.signUp);
|
||||
}, 200);
|
||||
|
||||
return client.signUp(email, password)
|
||||
.then(function (result) {
|
||||
uid = result.uid;
|
||||
assert.ok(uid, "uid is returned");
|
||||
|
||||
setTimeout(function() {
|
||||
SinonResponder.respond(requests[1], RequestMocks.signIn);
|
||||
}, 200);
|
||||
|
||||
return client.signIn(email, password);
|
||||
})
|
||||
.then(function (result) {
|
||||
assert.ok(result.sessionToken, "sessionToken is returned");
|
||||
sessionToken = result.sessionToken;
|
||||
|
||||
setTimeout(function() {
|
||||
SinonResponder.respond(requests[2], RequestMocks.recoveryEmailUnverified);
|
||||
}, 200);
|
||||
|
||||
return client.recoveryEmailStatus(sessionToken);
|
||||
})
|
||||
.then(function (result) {
|
||||
assert.equal(result.verified, false, "Email should not be verified.");
|
||||
|
||||
setTimeout(function() {
|
||||
SinonResponder.respond(requests[3], RequestMocks.mail);
|
||||
}, 200);
|
||||
|
||||
return waitForEmail(user);
|
||||
})
|
||||
.then(function (emails) {
|
||||
|
||||
setTimeout(function() {
|
||||
SinonResponder.respond(requests[4], RequestMocks.verifyCode);
|
||||
}, 200);
|
||||
|
||||
var code = emails[0].html.match(/code=([A-Za-z0-9]+)/)[1];
|
||||
assert.ok(code, "code is returned: " + code);
|
||||
return client.verifyCode(uid, code);
|
||||
})
|
||||
.then(function (result) {
|
||||
setTimeout(function() {
|
||||
SinonResponder.respond(requests[5], RequestMocks.recoveryEmailVerified);
|
||||
}, 200);
|
||||
|
||||
return client.recoveryEmailStatus(sessionToken);
|
||||
})
|
||||
.then(function (result) {
|
||||
assert.equal(result.verified, true, "Email should be verified.");
|
||||
return true;
|
||||
})
|
||||
});
|
||||
|
||||
// utility function that waits for a restmail email to arrive
|
||||
function waitForEmail(user) {
|
||||
return restmailClient.send('/mail/' + user, 'GET')
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([
|
||||
'intern!tdd',
|
||||
'intern/chai!assert',
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
define([], function () {
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
define([], function () {
|
||||
return {
|
||||
signUp: {
|
||||
status: 200,
|
||||
|
@ -21,6 +25,14 @@ define([], function () {
|
|||
mail: {
|
||||
status: 200,
|
||||
body: '[{"html":"Mocked code=9001"}]'
|
||||
},
|
||||
recoveryEmailUnverified: {
|
||||
status: 200,
|
||||
body: '{"verified": false}'
|
||||
},
|
||||
recoveryEmailVerified: {
|
||||
status: 200,
|
||||
body: '{"verified": true}'
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче