Skip to content

Commit

Permalink
Merge branch 'release/1.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasconner committed Jun 29, 2015
2 parents b92c960 + d136695 commit 6ba375a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
### 1.4.1 (2015-06-25)
* Enhancement(MLIBZ-413): Added support for MIC API versioning.

### 1.4.0 (2015-06-25)
* Enhancement(MLIBZ-367): Added support to register a device for push notifications on Titanium.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "kinvey",
"version" : "1.4.0",
"version" : "1.4.1",
"description" : "Kinvey JavaScript Library",
"homepage" : "http://www.kinvey.com",
"bugs" : { "email": "support@kinvey.com" },
Expand Down
29 changes: 26 additions & 3 deletions src/core/mic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var MIC = {
* @param {string} authorizationGrant Authorization Grant.
* @param {string} redirectUri Redirect Uri.
* @param {Object} [options] Options.
* @params {string} [options.micApiVersion] MIC API version to use.
* @params {string} [options.username] Username for the user to be authorized.
* @params {string} [options.password] Password for the user to be authorized.
* @param {boolean} [options.create=true] Create a new user if no user exists.
Expand Down Expand Up @@ -221,10 +222,20 @@ var MIC = {
* @return {Promise} Temp Login Uri.
*/
requestUrl: function(clientId, redirectUri, options) {
var url = Kinvey.MICHostName;
options.micApiVersion = options.micApiVersion || Kinvey.MICAPIVersion;

// Set the MIC API version
if (options.micApiVersion != null) {
var version = options.micApiVersion + '';
version = version.indexOf('v') === 0 ? version : 'v' + version;
url = url + '/' + version;
}

// Create a request
var request = {
method: 'POST',
url: Kinvey.MICHostName + MIC.AUTH_PATH,
url: url + MIC.AUTH_PATH,
data: {
client_id: clientId,
redirect_uri: redirectUri,
Expand Down Expand Up @@ -271,8 +282,18 @@ var MIC = {
requestCodeWithPopup: function(clientId, redirectUri, options) {
var error;
var deferred = Kinvey.Defer.deferred();
var url = Kinvey.MICHostName + MIC.AUTH_PATH + '?client_id=' + encodeURIComponent(clientId) +
'&redirect_uri=' + encodeURIComponent(redirectUri) + '&response_type=code';
var url = Kinvey.MICHostName;
options.micApiVersion = options.micApiVersion || Kinvey.MICAPIVersion;

// Set the MIC API version
if (options.micApiVersion != null) {
var version = options.micApiVersion + '';
version = version.indexOf('v') === 0 ? version : 'v' + version;
url = url + '/' + version;
}

url = url + MIC.AUTH_PATH + '?client_id=' + encodeURIComponent(clientId) +
'&redirect_uri=' + encodeURIComponent(redirectUri) + '&response_type=code';
var deferredResolved = false;
var popup;
var tiWebView;
Expand Down Expand Up @@ -799,6 +820,7 @@ Kinvey.User.MIC = /** @lends Kinvey.User.MIC */ {
* @param {String} redirectUri Where to redirect to after a succesful login. This should be the same value as setup
* in the Kinvey Console for your applicaiton.
* @param {Object} [options] Options.
* @param {String} [options.micApiVersion] MIC API version to use.
* @param {Boolean} [options.create=true] Create a new user if no user exists.
* @param {Number} [options.timeout=300000] How long to wait for a successful authorization. Defaults to 5 minutes.
* @return {Promise} Authorized user.
Expand All @@ -815,6 +837,7 @@ Kinvey.User.MIC = /** @lends Kinvey.User.MIC */ {
* @param {String} redirectUri Where to redirect to after a succesful login. This should be the same value as setup
* in the Kinvey Console for your applicaiton.
* @param {Object} [options] Options.
* @param {String} [options.micApiVersion] MIC API version to use.
* @param {Boolean} [options.create=true] Create a new user if no user exists.
* @return {Promise} Authorized user.
*/
Expand Down
32 changes: 22 additions & 10 deletions src/kinvey.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ Kinvey.API_ENDPOINT = undefined;
*/
Kinvey.MICHostName = '<%= config.auth.protocol %>://<%= config.auth.host %>';

/**
* The MIC API version.
*
* @type {Number}
* @default undefined
*/
Kinvey.MICAPIVersion = undefined;

/**
* The Kinvey API version used when communicating with `Kinvey.APIHostName`.
*
Expand Down Expand Up @@ -231,17 +239,18 @@ Kinvey.setActiveUser = function(user) {
* Initializes the library for use with Kinvey services.
*
* @param {Options} options Options.
* @param {string} [options.clientAppVersion] Client App Version.
* @param {string} [options.clientAppVersion] Client App Version.
* @param {Object} [options.customRequestProperties] Customer request properties.
* @param {string} [options.apiHostName] API Host Name. Must use the `https` protocol
* @param {string} [options.micHostName] MIC Host Name. Must use the `https` protocol
* @param {string} options.appKey App Key.
* @param {string} [options.appSecret] App Secret.
* @param {string} [options.masterSecret] Master Secret. **Never use the
* Master Secret in client-side code.**
* @param {boolean} [options.refresh=true] Refresh the active user (if any).
* @param {Object} [options.sync] Synchronization options.
* @returns {Promise} The active user.
* @param {string} [options.apiHostName] API Host Name. Must use the `https` protocol
* @param {string} [options.micHostName] MIC Host Name. Must use the `https` protocol
* @param {number} [options.micApiVersion] MIC version to use.
* @param {string} options.appKey App Key.
* @param {string} [options.appSecret] App Secret.
* @param {string} [options.masterSecret] Master Secret. **Never use the
* Master Secret in client-side code.**
* @param {boolean} [options.refresh=true] Refresh the active user (if any).
* @param {Object} [options.sync] Synchronization options.
* @returns {Promise} The active user.
*/
Kinvey.init = function(options) {
var error;
Expand Down Expand Up @@ -290,6 +299,9 @@ Kinvey.init = function(options) {
return wrapCallbacks(Kinvey.Defer.reject(error), options);
}

// Set the MIC version
Kinvey.MICAPIVersion = options.micApiVersion || Kinvey.MICAPIVersion;

// Set the Client App Version
if (options.clientAppVersion != null) {
Kinvey.ClientAppVersion.setVersion(options.clientAppVersion);
Expand Down

0 comments on commit 6ba375a

Please sign in to comment.