Recompile javascript files

This commit is contained in:
Kyle Corbelli 2017-09-15 20:26:52 -07:00
parent c2df1b1567
commit c9e445375e
12 changed files with 46 additions and 51 deletions

36
dist/actions.js vendored
View File

@ -101,27 +101,6 @@ exports.signOutRequestFailed = function () { return ({
// firstName: 'name'
// },
// }
// extract this service somewhere and unit test it:
var invertHash = function (hash) {
var newHash = {};
for (var key in hash) {
var val = hash[key];
newHash[val] = key;
}
return newHash;
};
// extract this service somewhere and unit test it:
var getUserAttributesFromResponse = function (userAttributes, response) {
var invertedUserAttributes = invertHash(userAttributes);
var userAttributesBackendKeys = Object.keys(invertedUserAttributes);
var userAttributesToReturn = {};
Object.keys(response.data.data).forEach(function (key) {
if (userAttributesBackendKeys.indexOf(key) !== -1) {
userAttributesToReturn[invertedUserAttributes[key]] = response.data.data[key];
}
});
return userAttributesToReturn;
};
var generateAuthActions = function (config) {
var authUrl = config.authUrl, userAttributes = config.userAttributes, userRegistrationAttributes = config.userRegistrationAttributes;
var registerUser = function (userRegistrationDetails) { return function (dispatch) {
@ -154,7 +133,7 @@ var generateAuthActions = function (config) {
auth_1.setAuthHeaders(response.headers);
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
auth_1.persistAuthHeadersInLocalStorage(response.headers);
userAttributesToSave = getUserAttributesFromResponse(userAttributes, response);
userAttributesToSave = auth_1.getUserAttributesFromResponse(userAttributes, response);
dispatch(exports.registrationRequestSucceeded(userAttributesToSave)); // <- need to make this reducer more flexible
return [3 /*break*/, 4];
case 3:
@ -186,7 +165,7 @@ var generateAuthActions = function (config) {
auth_1.setAuthHeaders(response.headers);
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
auth_1.persistAuthHeadersInLocalStorage(response.headers);
userAttributesToSave = getUserAttributesFromResponse(userAttributes, response);
userAttributesToSave = auth_1.getUserAttributesFromResponse(userAttributes, response);
dispatch(exports.verifyTokenRequestSucceeded(userAttributesToSave));
return [3 /*break*/, 4];
case 3:
@ -222,7 +201,7 @@ var generateAuthActions = function (config) {
auth_1.setAuthHeaders(response.headers);
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
auth_1.persistAuthHeadersInLocalStorage(response.headers);
userAttributesToSave = getUserAttributesFromResponse(userAttributes, response);
userAttributesToSave = auth_1.getUserAttributesFromResponse(userAttributes, response);
dispatch(exports.signInRequestSucceeded(userAttributesToSave));
return [3 /*break*/, 4];
case 3:
@ -234,12 +213,17 @@ var generateAuthActions = function (config) {
});
});
}; };
var signOutUser = function (userSignOutCredentials) { return function (dispatch) {
var signOutUser = function () { return function (dispatch) {
return __awaiter(this, void 0, void 0, function () {
var error_4;
var userSignOutCredentials, error_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
userSignOutCredentials = {
'access-token': localStorage.getItem('access-token'),
client: localStorage.getItem('client'),
uid: localStorage.getItem('uid'),
};
dispatch(exports.signOutRequestSent());
_a.label = 1;
case 1:

2
dist/actions.js.map vendored

File diff suppressed because one or more lines are too long

18
dist/index.js vendored
View File

@ -4,22 +4,4 @@ var actions_1 = require("./actions");
exports.generateAuthActions = actions_1.default;
var reducers_1 = require("./reducers");
exports.reduxTokenAuthReducer = reducers_1.default;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Example of how the end-user will import the actions
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// import {
// generateAuthFunctions,
// } from 'redux-token-auth'
//
// const authUrl: string = 'http://www.someapp.com/auth'
// const userAttributes = {
// firstName: 'name',
// imageUrl: 'image_url',
// }
// const {
// registerUser,
// verifyToken,
// signInUser,
// signOutUser,
// } = generateAuthFunctions(authUrl, userAttributes)
//# sourceMappingURL=index.js.map

2
dist/index.js.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAIzC,8BAJK,iBAAmB,CAIL;AAHrB,uCAA8C;AAI5C,gCAJK,kBAAqB,CAIL;AAGvB,wHAAwH;AACxH,sDAAsD;AACtD,wHAAwH;AAExH,WAAW;AACX,2BAA2B;AAC3B,4BAA4B;AAC5B,EAAE;AACF,wDAAwD;AACxD,2BAA2B;AAC3B,uBAAuB;AACvB,2BAA2B;AAC3B,IAAI;AACJ,UAAU;AACV,kBAAkB;AAClB,iBAAiB;AACjB,gBAAgB;AAChB,iBAAiB;AACjB,qDAAqD"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAIzC,8BAJK,iBAAmB,CAIL;AAHrB,uCAA8C;AAI5C,gCAJK,kBAAqB,CAIL"}

View File

@ -29,7 +29,12 @@ var currentUser = function (state, action) {
case types_1.SIGNIN_REQUEST_FAILED:
return __assign({}, state, { isLoading: false, isLoggedIn: false });
case types_1.SIGNOUT_REQUEST_SUCCEEDED:
return __assign({}, state, { attributes: __assign({}, state.attributes, { firstName: null }), isLoading: false, isLoggedIn: false });
var userAttributeKeys = Object.keys(state.attributes);
var allNullUserAttributes = userAttributeKeys.reduce(function (accumulatedNullUserAttributes, currentUserAttributeKey) {
return __assign({}, accumulatedNullUserAttributes, (_a = {}, _a[currentUserAttributeKey] = null, _a));
var _a;
}, {});
return __assign({}, state, { attributes: allNullUserAttributes, isLoading: false, isLoggedIn: false });
case types_1.SIGNOUT_REQUEST_FAILED:
return __assign({}, state, { isLoading: false });
default:

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reducers/current-user/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,qCAeoB;AACpB,qDAA8C;AAG5C,IAAA,iDAAwB,CACV;AAEhB,IAAM,WAAW,GAAG,UAAC,KAAyB,EAAE,MAAmB;IAA9C,sBAAA,EAAA,mBAAyB;IAC5C,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpB,KAAK,iCAAyB,CAAC;QAC/B,KAAK,iCAAyB,CAAC;QAC/B,KAAK,2BAAmB,CAAC;QACzB,KAAK,4BAAoB;YACvB,MAAM,cACD,KAAK,IACR,SAAS,EAAE,IAAI,IAChB;QACH,KAAK,sCAA8B,CAAC;QACpC,KAAK,sCAA8B,CAAC;QACpC,KAAK,gCAAwB;YACnB,IAAA,8CAAc,CAAmB;YACzC,MAAM,cACD,KAAK,IACR,UAAU,eAAO,cAAc,GAC/B,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,IAAI,IACjB;QACH,KAAK,mCAA2B,CAAC;QACjC,KAAK,mCAA2B,CAAC;QACjC,KAAK,6BAAqB;YACxB,MAAM,cACD,KAAK,IACR,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,KAAK,IAClB;QACH,KAAK,iCAAyB;YAC5B,MAAM,cACD,KAAK,IACR,UAAU,eACL,KAAK,CAAC,UAAU,IACnB,SAAS,EAAE,IAAI,KAEjB,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,KAAK,IAClB;QACH,KAAK,8BAAsB;YACzB,MAAM,cACD,KAAK,IACR,SAAS,EAAE,KAAK,IACjB;QACH;YACE,MAAM,CAAC,KAAK,CAAA;IAChB,CAAC;AACH,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reducers/current-user/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,qCAgBoB;AACpB,qDAA8C;AAG5C,IAAA,iDAAwB,CACV;AAEhB,IAAM,WAAW,GAAG,UAAC,KAAyB,EAAE,MAAmB;IAA9C,sBAAA,EAAA,mBAAyB;IAC5C,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpB,KAAK,iCAAyB,CAAC;QAC/B,KAAK,iCAAyB,CAAC;QAC/B,KAAK,2BAAmB,CAAC;QACzB,KAAK,4BAAoB;YACvB,MAAM,cACD,KAAK,IACR,SAAS,EAAE,IAAI,IAChB;QACH,KAAK,sCAA8B,CAAC;QACpC,KAAK,sCAA8B,CAAC;QACpC,KAAK,gCAAwB;YACnB,IAAA,8CAAc,CAAmB;YACzC,MAAM,cACD,KAAK,IACR,UAAU,eAAO,cAAc,GAC/B,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,IAAI,IACjB;QACH,KAAK,mCAA2B,CAAC;QACjC,KAAK,mCAA2B,CAAC;QACjC,KAAK,6BAAqB;YACxB,MAAM,cACD,KAAK,IACR,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,KAAK,IAClB;QACH,KAAK,iCAAyB;YAC5B,IAAM,iBAAiB,GAAa,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;YACjE,IAAM,qBAAqB,GAAmB,iBAAiB,CAAC,MAAM,CACpE,UAAC,6BAA6C,EAAE,uBAA+B;gBAC7E,MAAM,cACD,6BAA6B,eAC/B,uBAAuB,IAAG,IAAI,OAChC;;YACH,CAAC,EACD,EAAE,CACH,CAAA;YACD,MAAM,cACD,KAAK,IACR,UAAU,EAAE,qBAAqB,EACjC,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,KAAK,IAClB;QACH,KAAK,8BAAsB;YACzB,MAAM,cACD,KAAK,IACR,SAAS,EAAE,KAAK,IACjB;QACH;YACE,MAAM,CAAC,KAAK,CAAA;IAChB,CAAC;AACH,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}

12
dist/services/auth.js vendored
View File

@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = require("axios");
var utility_1 = require("./utility");
var authHeaderKeys = [
'access-token',
'token-type',
@ -30,4 +31,15 @@ exports.deleteAuthHeadersFromLocalStorage = function () {
localStorage.removeItem(key);
});
};
exports.getUserAttributesFromResponse = function (userAttributes, response) {
var invertedUserAttributes = utility_1.invertMapKeysAndValues(userAttributes);
var userAttributesBackendKeys = Object.keys(invertedUserAttributes);
var userAttributesToReturn = {};
Object.keys(response.data.data).forEach(function (key) {
if (userAttributesBackendKeys.indexOf(key) !== -1) {
userAttributesToReturn[invertedUserAttributes[key]] = response.data.data[key];
}
});
return userAttributesToReturn;
};
//# sourceMappingURL=auth.js.map

View File

@ -1 +1 @@
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":";;AAAA,+BAAyB;AAGzB,IAAM,cAAc,GAAkB;IACpC,cAAc;IACd,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,KAAK;CACN,CAAA;AAEY,QAAA,cAAc,GAAG,UAAC,OAAoB;IACjD,cAAc,CAAC,OAAO,CAAC,UAAC,GAAW;QACjC,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,iHAAiH;AACpG,QAAA,gCAAgC,GAAG,UAAC,OAAoB;IACnE,cAAc,CAAC,OAAO,CAAC,UAAC,GAAW;QACjC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAEY,QAAA,iBAAiB,GAAG;IAC/B,cAAc,CAAC,OAAO,CAAC,UAAC,GAAW;QACjC,OAAO,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,iHAAiH;AACpG,QAAA,iCAAiC,GAAG;IAC/C,cAAc,CAAC,OAAO,CAAC,UAAC,GAAW;QACjC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":";;AAAA,+BAAyB;AACzB,qCAAkD;AAOlD,IAAM,cAAc,GAAkB;IACpC,cAAc;IACd,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AAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,sBAAsB,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC,CAAC,CAAA;IACF,MAAM,CAAC,sBAAsB,CAAA;AAC/B,CAAC,CAAA"}

11
dist/services/utility.js vendored Normal file
View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.invertMapKeysAndValues = function (stringMap) {
var newStringMap = {};
for (var key in stringMap) {
var val = stringMap[key];
newStringMap[val] = key;
}
return newStringMap;
};
//# sourceMappingURL=utility.js.map

1
dist/services/utility.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/services/utility.ts"],"names":[],"mappings":";;AAEa,QAAA,sBAAsB,GAAG,UAAC,SAA+B;IACpE,IAAM,YAAY,GAAyB,EAAE,CAAA;IAC7C,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC;QAC1B,IAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;QAC1B,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACzB,CAAC;IACD,MAAM,CAAC,YAAY,CAAA;AACrB,CAAC,CAAA"}

2
dist/types.js.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAwCa,QAAA,yBAAyB,GAA8B,4CAA4C,CAAA;AAGnG,QAAA,8BAA8B,GAAmC,iDAAiD,CAAA;AAGlH,QAAA,2BAA2B,GAAgC,8CAA8C,CAAA;AAGzG,QAAA,yBAAyB,GAA8B,4CAA4C,CAAA;AAGnG,QAAA,8BAA8B,GAAmC,iDAAiD,CAAA;AAGlH,QAAA,2BAA2B,GAAgC,8CAA8C,CAAA;AAGzG,QAAA,mBAAmB,GAAwB,sCAAsC,CAAA;AAGjF,QAAA,wBAAwB,GAA6B,2CAA2C,CAAA;AAGhG,QAAA,qBAAqB,GAA0B,wCAAwC,CAAA;AAGvF,QAAA,oBAAoB,GAAyB,uCAAuC,CAAA;AAGpF,QAAA,yBAAyB,GAA8B,4CAA4C,CAAA;AAGnG,QAAA,sBAAsB,GAA2B,yCAAyC,CAAA"}
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAyCa,QAAA,yBAAyB,GAA8B,4CAA4C,CAAA;AAGnG,QAAA,8BAA8B,GAAmC,iDAAiD,CAAA;AAGlH,QAAA,2BAA2B,GAAgC,8CAA8C,CAAA;AAGzG,QAAA,yBAAyB,GAA8B,4CAA4C,CAAA;AAGnG,QAAA,8BAA8B,GAAmC,iDAAiD,CAAA;AAGlH,QAAA,2BAA2B,GAAgC,8CAA8C,CAAA;AAGzG,QAAA,mBAAmB,GAAwB,sCAAsC,CAAA;AAGjF,QAAA,wBAAwB,GAA6B,2CAA2C,CAAA;AAGhG,QAAA,qBAAqB,GAA0B,wCAAwC,CAAA;AAGvF,QAAA,oBAAoB,GAAyB,uCAAuC,CAAA;AAGpF,QAAA,yBAAyB,GAA8B,4CAA4C,CAAA;AAGnG,QAAA,sBAAsB,GAA2B,yCAAyC,CAAA"}

View File

@ -1,6 +1,6 @@
{
"name": "redux-token-auth",
"version": "0.13.0",
"version": "0.14.0",
"description": "Redux actions and reducers to integrate with Devise Token Auth",
"main": "dist/index.js",
"types": "index.d.ts",