/**
* GPII Untrusted Local FlowManager
*
* Copyright 2015 OCAD University
* Copyright 2017 OCAD University
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
"use strict";
var fluid = require("infusion"),
gpii = fluid.registerNamespace("gpii");
require("accessRequester");
fluid.require("%gpii-universal/gpii/node_modules/gpii-oauth2/gpii-oauth2-utilities/src/OAuth2Utilities.js");
// The Untrusted or Hybrid (Local) FlowManager is a Local FlowManager which defers to the cloud for the matchMaking
// and Preferences fetch process. The architectural goal of the untrusted FlowManager is that the unfiltered
// user preferences never reach the local device. Therefore the userLogon stages of the "gpii.flowManager.matchMakingRequest"
// are all abridged, and instead we simply receive a final settings payload from a cloudBased flowManager which are
// then directly applied to the local device.
// Described at https://issues.gpii.net/browse/GPII-1224
// Overrides request handlers in "gpii.flowManager.local"
fluid.defaults("gpii.flowManager.untrusted", {
components: {
untrustedSettingsDataSource: {
type: "gpii.flowManager.untrustedSettingsDataSource"
// untrustedSettingsUrl: distributed down from, e.g., gpii.flowManager.untrusted.config.development
// accessTokenUrl: distributed down from, e.g., gpii.flowManager.untrusted.config.development
// clientCredentialFilePath: distributed down from, e.g., gpii.flowManager.untrusted.config.development
}
},
requestHandlers: {
userLogin: {
// NOTE that these gradesNames do not merge as with standard components
gradeNames: "gpii.flowManager.untrusted.stateChangeHandler"
},
proximityTriggered: {
gradeNames: "gpii.flowManager.untrusted.stateChangeHandler"
}
}
});
gpii.flowManager.untrusted.getSettings = function (untrustedSettingsDataSource, userToken, deviceReporterData, onMatchDone, onError) {
var settings = untrustedSettingsDataSource.get(userToken, deviceReporterData);
settings.then(onMatchDone.fire, onError.fire);
};
fluid.defaults("gpii.flowManager.untrusted.stateChangeHandler", {
gradeNames: ["fluid.component", "gpii.flowManager.userLogonHandling.stateChangeHandler"],
invokers: {
getSettings: {
funcName: "gpii.flowManager.untrusted.getSettings",
args: [
"{flowManager}.untrustedSettingsDataSource",
"{that}.userToken",
"{arguments}.0", // device reporter data
"{that}.events.onMatchDone",
"{that}.events.onError"
]
}
},
events: {
onUserToken: null,
onDeviceContext: null
},
listeners: {
"onUserToken.setUserToken": {
listener: "gpii.flowManager.setUserToken",
args: ["{that}", "{arguments}.0"]
},
"onUserToken.getDeviceContext": {
func: "{that}.getDeviceContext",
priority: "after:setUserToken"
},
"onDeviceContext.getSettings": "{that}.getSettings"
}
});
|