versacall-core-library-react 2.0.70 → 2.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/components/CoreAlert/CoreAlert.js +85 -0
  2. package/dist/components/CoreAlert/index.js +13 -0
  3. package/dist/components/CoreAlert/readme.md +21 -0
  4. package/dist/components/CoreAppBar/CoreAppBar.js +364 -0
  5. package/dist/components/CoreAppBar/CoreAppBarDrawer.js +134 -0
  6. package/dist/components/CoreAppBar/README.md +27 -0
  7. package/dist/components/CoreAppBar/index.js +13 -0
  8. package/dist/components/CoreAppBar/screenshot.png +0 -0
  9. package/dist/components/CoreAppSelector/AppLink.js +101 -0
  10. package/dist/components/CoreAppSelector/CoreAppSelector.js +155 -0
  11. package/dist/components/CoreAppSelector/index.js +13 -0
  12. package/dist/components/CoreDialogueToolBar/CoreDialogueToolBar.js +123 -0
  13. package/dist/components/CoreDialogueToolBar/index.js +13 -0
  14. package/dist/components/CoreDrawer/CoreDrawer.js +236 -0
  15. package/dist/components/CoreDrawer/README.md +36 -0
  16. package/dist/components/CoreDrawer/index.js +13 -0
  17. package/dist/components/CoreDrawer/screenshot_collapsed.png +0 -0
  18. package/dist/components/CoreDrawer/screenshot_expanded.png +0 -0
  19. package/dist/components/CoreDropDownTextfield/CoreDropDownTextfield.js +85 -0
  20. package/dist/components/CoreDropDownTextfield/index.js +13 -0
  21. package/dist/components/CoreElapsedTime/CoreElapsedTime.js +57 -0
  22. package/dist/components/CoreElapsedTime/index.js +13 -0
  23. package/dist/components/CoreFrame/CoreFrame.js +64 -0
  24. package/dist/components/CoreFrame/index.js +13 -0
  25. package/dist/components/CoreImportDialog/CoreImportDialog.js +350 -0
  26. package/dist/components/CoreImportDialog/index.js +13 -0
  27. package/dist/components/CoreImportResultsDialog/CoreImportResultsDialog.js +103 -0
  28. package/dist/components/CoreImportResultsDialog/index.js +13 -0
  29. package/dist/components/CoreImporting/CoreImporting.js +60 -0
  30. package/dist/components/CoreImporting/index.js +13 -0
  31. package/dist/components/CorePlugin/CorePlugin.js +134 -0
  32. package/dist/components/CorePlugin/OldCorePlugin.js +124 -0
  33. package/dist/components/CorePlugin/index.js +13 -0
  34. package/dist/components/CoreSaveChangesDialog/CoreSaveChangesDialog.js +62 -0
  35. package/dist/components/CoreSaveChangesDialog/index.js +13 -0
  36. package/dist/components/CoreShiftTagFilter/CoreShiftTagFilter.js +350 -0
  37. package/dist/components/CoreShiftTagFilter/OldCoreShiftTagFilter.js +208 -0
  38. package/dist/components/CoreShiftTagFilter/index.js +13 -0
  39. package/dist/components/CoreSideBar/CoreSideBar.js +737 -0
  40. package/dist/components/CoreSideBar/CoreSideBarDrawer.js +172 -0
  41. package/dist/components/CoreSideBar/index.js +13 -0
  42. package/dist/components/CoreSnackBar/CoreSnackBar.js +116 -0
  43. package/dist/components/CoreSnackBar/index.js +13 -0
  44. package/dist/components/CoreSnackBar/readme.md +23 -0
  45. package/dist/components/CoreTable/CoreTable.js +315 -0
  46. package/dist/components/CoreTable/CoreTableChips.js +50 -0
  47. package/dist/components/CoreTable/CoreTableHead.js +175 -0
  48. package/dist/components/CoreTable/CoreTableToolbar.js +108 -0
  49. package/dist/components/CoreTable/index.js +13 -0
  50. package/dist/components/CoreTable/readMe.md +79 -0
  51. package/dist/components/CoreTagFilter/CoreTagFilter.js +275 -0
  52. package/dist/components/CoreTagFilter/OldCoreTagFilter.js +341 -0
  53. package/dist/components/CoreTagFilter/OldTagChip.js +44 -0
  54. package/dist/components/CoreTagFilter/OldTagFilterSelector.js +105 -0
  55. package/dist/components/CoreTagFilter/OldTagOption.js +53 -0
  56. package/dist/components/CoreTagFilter/TagFilterBuilder.js +487 -0
  57. package/dist/components/CoreTagFilter/index.js +13 -0
  58. package/dist/components/CoreTextField/CoreTextField.js +109 -0
  59. package/dist/components/CoreTextField/index.js +13 -0
  60. package/dist/components/CoreTheme/CoreTheme.css +9 -0
  61. package/dist/components/CoreTheme/CoreTheme.js +51 -0
  62. package/dist/components/CoreTheme/README.md +3 -0
  63. package/dist/components/CoreTheme/index.js +13 -0
  64. package/dist/components/CoreTile/CoreTile.js +62 -0
  65. package/dist/components/CoreTile/CoreTileToolbar.js +62 -0
  66. package/dist/components/CoreTile/index.js +13 -0
  67. package/dist/components/CoreTimerInput/CoreTimerInput.js +203 -0
  68. package/dist/components/CoreTimerInput/CoreTimerInputOld.js +146 -0
  69. package/dist/components/CoreTimerInput/index.js +13 -0
  70. package/dist/components/CoreToolbar/CoreToolbar.js +205 -0
  71. package/dist/components/CoreToolbar/index.js +13 -0
  72. package/dist/components/CoreTracker/CoreTracker.js +52 -0
  73. package/dist/components/CoreTracker/index.js +13 -0
  74. package/dist/components/CoreTranslate/CoreTranslate.js +62 -0
  75. package/dist/components/CoreTranslate/README.md +5 -0
  76. package/dist/components/CoreTranslate/index.js +13 -0
  77. package/dist/components/CoreTranslate/translations/en.json +451 -0
  78. package/dist/components/CoreTranslate/translations/es.json +433 -0
  79. package/dist/components/CoreTranslateWrapper/CoreTranslateWrapper.js +36 -0
  80. package/dist/components/CoreTranslateWrapper/index.js +13 -0
  81. package/dist/components/CoreWidget/CoreWidget.js +120 -0
  82. package/dist/components/CoreWidget/index.js +13 -0
  83. package/dist/components/CoreWrapper/CoreWrapper.js +51 -0
  84. package/dist/components/CoreWrapper/README.md +41 -0
  85. package/dist/components/CoreWrapper/index.js +13 -0
  86. package/dist/components/index.js +202 -0
  87. package/dist/constants/index.js +20 -0
  88. package/dist/constants/testOrganization.js +31 -0
  89. package/dist/constants/testToken.js +33 -0
  90. package/dist/context/Authentication/AuthenticationContext.js +10 -0
  91. package/dist/context/Authentication/AuthenticationProvider.js +225 -0
  92. package/dist/context/Authentication/README.md +47 -0
  93. package/dist/context/Authentication/index.js +27 -0
  94. package/dist/context/Authentication/withAuthentication.js +15 -0
  95. package/dist/context/Channels/ChannelsConsumer.js +42 -0
  96. package/dist/context/Channels/ChannelsContext.js +10 -0
  97. package/dist/context/Channels/ChannelsProvider.js +258 -0
  98. package/dist/context/Channels/DataChannel.js +68 -0
  99. package/dist/context/Channels/EntityChannel.js +69 -0
  100. package/dist/context/Channels/EveryoneChannel.js +55 -0
  101. package/dist/context/Channels/OrganizationChannel.js +69 -0
  102. package/dist/context/Channels/README.md +52 -0
  103. package/dist/context/Channels/UserChannel.js +60 -0
  104. package/dist/context/Channels/index.js +69 -0
  105. package/dist/context/Channels/withChannels.js +15 -0
  106. package/dist/context/Core/CoreContext.js +10 -0
  107. package/dist/context/Core/CoreProvider.js +107 -0
  108. package/dist/context/Core/README.md +43 -0
  109. package/dist/context/Core/index.js +27 -0
  110. package/dist/context/Core/withCore.js +15 -0
  111. package/dist/context/Organization/OrganizationContext.js +10 -0
  112. package/dist/context/Organization/OrganizationProvider.js +108 -0
  113. package/dist/context/Organization/README.md +82 -0
  114. package/dist/context/Organization/index.js +27 -0
  115. package/dist/context/Organization/withOrganization.js +15 -0
  116. package/dist/context/Plugin/PluginContext.js +10 -0
  117. package/dist/context/Plugin/PluginProvider.js +78 -0
  118. package/dist/context/Plugin/index.js +27 -0
  119. package/dist/context/Plugin/withPlugin.js +15 -0
  120. package/dist/context/index.js +60 -0
  121. package/dist/css/index.js +20 -0
  122. package/dist/css/junk.module.css +3 -0
  123. package/dist/css/scrollbar.css +35 -0
  124. package/dist/css/scrollbar.module.css +37 -0
  125. package/dist/functions/TagEvaluator.js +165 -0
  126. package/dist/functions/compareObjects.js +27 -0
  127. package/dist/functions/formatElapsedTime.js +18 -0
  128. package/dist/functions/formatNameFileSafe.js +16 -0
  129. package/dist/functions/getIconUrl.js +15 -0
  130. package/dist/functions/getParameterByName.js +34 -0
  131. package/dist/functions/getProperty.js +17 -0
  132. package/dist/functions/getUrl.js +15 -0
  133. package/dist/functions/index.js +62 -0
  134. package/dist/icons/CopyIcon.js +42 -0
  135. package/dist/icons/DeleteIcon.js +42 -0
  136. package/dist/icons/DuplicateIcon.js +42 -0
  137. package/dist/icons/EditIcon.js +42 -0
  138. package/dist/icons/FabAddIcon.js +78 -0
  139. package/dist/icons/PasteIcon.js +42 -0
  140. package/dist/icons/index.js +48 -0
  141. package/dist/index.js +71 -0
  142. package/package.json +2 -2
@@ -0,0 +1,41 @@
1
+ # CoreWrapper
2
+
3
+ This is a component which adds all the commonly used wrappers to your application.
4
+
5
+ Providers : [CoreProvider](../../context/Core), [AuthenticationProvider](../../context/Authentication), [OrganizationProvider](../../context/Organization), [ChannelsProvider](../../context/Channels)
6
+
7
+ Others: [CoreTheme](../CoreTheme), [CoreTranslate](../CoreTranslate)
8
+
9
+ ## Props
10
+ - baseUrl : Forwards this prop to [CoreProvider](../../context/Core)
11
+ - logLevel : Forwards this prop to [CoreProvider](../../context/Core)
12
+ - messages : Forwards this prop to [AuthenticationProvider](../../context/Authentication)
13
+
14
+ Example use:
15
+
16
+ ```
17
+ import React from 'react'
18
+ import ReactDOM from 'react-dom'
19
+ import { CoreWrapper } from 'core-library-react'
20
+
21
+ import messages_en from "./translations/en.json"
22
+ import messages_es from "./translations/es.json"
23
+ import App from './App'
24
+
25
+ const messages = {
26
+ 'en': messages_en,
27
+ 'es': messages_es
28
+ }
29
+
30
+ const baseUrl = process.env.NODE_ENV === 'production' ?
31
+ window.location.protocol + '//' + window.location.hostname + (window.location.port === '' ? '' : ':' + window.location.port)
32
+ :
33
+ 'http://docker-node-1';
34
+
35
+ ReactDOM.render(
36
+ <CoreWrapper baseUrl={ baseUrl } locale="en" messages={ messages } logLevel={5}>
37
+ <App />
38
+ </CoreWrapper>,
39
+ document.getElementById('root')
40
+ )
41
+ ```
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _CoreWrapper.default;
10
+ }
11
+ });
12
+ var _CoreWrapper = _interopRequireDefault(require("./CoreWrapper"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CoreAlert", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _CoreAlert.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "CoreAppBar", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _CoreAppBar.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "CoreAppSelector", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _CoreAppSelector.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "CoreDialogueToolBar", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _CoreDialogueToolBar.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "CoreDrawer", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _CoreDrawer.default;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "CoreDropDownTextfield", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _CoreDropDownTextfield.default;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "CoreElapsedTime", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _CoreElapsedTime.default;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "CoreFrame", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _CoreFrame.default;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "CoreImportDialog", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _CoreImportDialog.default;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "CoreImportResultsDialog", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _CoreImportResultsDialog.default;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "CoreImporting", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _CoreImporting.default;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "CorePlugin", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _CorePlugin.default;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "CoreSaveChangesDialog", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _CoreSaveChangesDialog.default;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "CoreShiftTagFilter", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _CoreShiftTagFilter.default;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "CoreSideBar", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _CoreSideBar.default;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "CoreSnackBar", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _CoreSnackBar.default;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "CoreTable", {
103
+ enumerable: true,
104
+ get: function () {
105
+ return _CoreTable.default;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "CoreTagFilter", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _CoreTagFilter.default;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "CoreTextField", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _CoreTextField.default;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "CoreTheme", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _CoreTheme.default;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "CoreTile", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _CoreTile.default;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "CoreTimerInput", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _CoreTimerInput.default;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "CoreToolbar", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _CoreToolbar.default;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "CoreTracker", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _CoreTracker.default;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "CoreTranslate", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _CoreTranslate.default;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "CoreTranslateWrapper", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _CoreTranslateWrapper.default;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "CoreWidget", {
163
+ enumerable: true,
164
+ get: function () {
165
+ return _CoreWidget.default;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "CoreWrapper", {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _CoreWrapper.default;
172
+ }
173
+ });
174
+ var _CoreAlert = _interopRequireDefault(require("./CoreAlert"));
175
+ var _CoreAppBar = _interopRequireDefault(require("./CoreAppBar"));
176
+ var _CoreAppSelector = _interopRequireDefault(require("./CoreAppSelector"));
177
+ var _CoreDialogueToolBar = _interopRequireDefault(require("./CoreDialogueToolBar"));
178
+ var _CoreDrawer = _interopRequireDefault(require("./CoreDrawer"));
179
+ var _CoreDropDownTextfield = _interopRequireDefault(require("./CoreDropDownTextfield"));
180
+ var _CoreElapsedTime = _interopRequireDefault(require("./CoreElapsedTime"));
181
+ var _CoreFrame = _interopRequireDefault(require("./CoreFrame"));
182
+ var _CoreImportDialog = _interopRequireDefault(require("./CoreImportDialog"));
183
+ var _CoreImporting = _interopRequireDefault(require("./CoreImporting"));
184
+ var _CoreImportResultsDialog = _interopRequireDefault(require("./CoreImportResultsDialog"));
185
+ var _CorePlugin = _interopRequireDefault(require("./CorePlugin"));
186
+ var _CoreSaveChangesDialog = _interopRequireDefault(require("./CoreSaveChangesDialog"));
187
+ var _CoreShiftTagFilter = _interopRequireDefault(require("./CoreShiftTagFilter"));
188
+ var _CoreSideBar = _interopRequireDefault(require("./CoreSideBar"));
189
+ var _CoreSnackBar = _interopRequireDefault(require("./CoreSnackBar"));
190
+ var _CoreTable = _interopRequireDefault(require("./CoreTable"));
191
+ var _CoreTagFilter = _interopRequireDefault(require("./CoreTagFilter"));
192
+ var _CoreTextField = _interopRequireDefault(require("./CoreTextField"));
193
+ var _CoreTheme = _interopRequireDefault(require("./CoreTheme"));
194
+ var _CoreTile = _interopRequireDefault(require("./CoreTile"));
195
+ var _CoreTimerInput = _interopRequireDefault(require("./CoreTimerInput"));
196
+ var _CoreToolbar = _interopRequireDefault(require("./CoreToolbar"));
197
+ var _CoreTracker = _interopRequireDefault(require("./CoreTracker"));
198
+ var _CoreTranslate = _interopRequireDefault(require("./CoreTranslate"));
199
+ var _CoreTranslateWrapper = _interopRequireDefault(require("./CoreTranslateWrapper"));
200
+ var _CoreWidget = _interopRequireDefault(require("./CoreWidget"));
201
+ var _CoreWrapper = _interopRequireDefault(require("./CoreWrapper"));
202
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "testOrganization", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _testOrganization.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "testToken", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _testToken.default;
16
+ }
17
+ });
18
+ var _testOrganization = _interopRequireDefault(require("./testOrganization"));
19
+ var _testToken = _interopRequireDefault(require("./testToken"));
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const testOrganization = {
8
+ organization: {
9
+ name: 'ACME Corp',
10
+ id: 'Organization/257199',
11
+ revision: '_YKj8xQe--_',
12
+ key: '257199'
13
+ },
14
+ entity: {
15
+ organization: null,
16
+ name: 'Las Vegas, NV',
17
+ type: 'site',
18
+ timeZone: {
19
+ id: 'pacific_standard_time',
20
+ environment: {
21
+ react: 'America/Los_Angeles',
22
+ linux: 'America/Los_Angeles',
23
+ windows: 'Pacific Standard Time'
24
+ }
25
+ },
26
+ id: 'Entity/257299',
27
+ revision: '_YKkfQeC--_',
28
+ key: '257299'
29
+ }
30
+ };
31
+ var _default = exports.default = testOrganization;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const testToken = {
8
+ id: 'User/d67ceb54-6bdf-4c38-b588-fa50bfbbb2e6',
9
+ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJVc2VyL2Q2N2NlYjU0LTZiZGYtNGMzOC1iNTg4LWZhNTBiZmJiYjJlNiIsImdpdmVuX25hbWUiOiJNaWNoYWVsIiwiZmFtaWx5X25hbWUiOiJQYWNoZWNv' + 'IiwiZW1haWwiOiJwYWNoZWNvQHZlcnNhY2FsbC5jb20iLCJsYW5ndWFnZSI6ImVuIiwicGVybWlzc2lvbnMiOiJbe1wiT2JqZWN0SWRzXCI6W1wiT3JnYW5pemF0aW9uLzEyOTEyOVwiXSxcIlJpZ2h0c1wiOntcImFkbWluaXN0' + 'cmF0aW9uLWFwaS1wYWNrYWdlLmVudGl0aWVzXCI6XCJhLWQtZVwiLFwiYWRtaW5pc3RyYXRpb24tYXBpLXBhY2thZ2Uucm9sZXNcIjpcImEtZC1lXCIsXCJhZG1pbmlzdHJhdGlvbi1hcGktcGFja2FnZS51c2Vyc1wiOlwiYS1k' + 'LWVcIn19LHtcIk9iamVjdElkc1wiOltcIkVudGl0eS8xMjkxODNcIl0sXCJSaWdodHNcIjp7XCJjb250YWN0cy1hcGktcGFja2FnZS5jb250YWN0c1wiOlwiYS1kLWVcIn19LHtcIk9iamVjdElkc1wiOltcIkVudGl0eS8wYWRl' + 'YTA0YS05NWY0LTQyNzEtODI1NC0yZGU3NmIwMTcyYTVcIixcIkVudGl0eS8xMTQ0NjA3XCJdLFwiUmlnaHRzXCI6e319XSIsImV4cCI6MTU0ODc5MDQxOCwiYXVkIjoiOjpmZmZmOjEwLjAuMC40MiJ9.vTxRpmSDnFjA7n9He7k' + 'XF1qcYzRWzoZxAGgjG40u7Ck',
10
+ userInfo: {
11
+ emailAddress: 'pacheco@versacall.com',
12
+ firstName: 'Michael',
13
+ lastName: 'Pacheco'
14
+ },
15
+ language: 'en',
16
+ permissions: [{
17
+ objectIds: ['Organization/129129'],
18
+ rights: {
19
+ 'administration-api-package.entities': 'a-d-e',
20
+ 'administration-api-package.roles': 'a-d-e',
21
+ 'administration-api-package.users': 'a-d-e'
22
+ }
23
+ }, {
24
+ objectIds: ['Entity/129183'],
25
+ rights: {
26
+ 'contacts-api-package.contacts': 'a-d-e'
27
+ }
28
+ }, {
29
+ objectIds: ['Entity/0adea04a-95f4-4271-8254-2de76b0172a5', 'Entity/1144607'],
30
+ rights: {}
31
+ }]
32
+ };
33
+ var _default = exports.default = testToken;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const AuthenticationContext = /*#__PURE__*/_react.default.createContext();
10
+ var _default = exports.default = AuthenticationContext;
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _axios = _interopRequireDefault(require("axios"));
10
+ var _AuthenticationContext = _interopRequireDefault(require("./AuthenticationContext"));
11
+ var _functions = require("../../functions");
12
+ var _constants = require("../../constants");
13
+ var _Core = require("../Core");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
+ const namespace = 'AuthenticationProvider';
17
+ const authenticationTokenLocalStorage = 'authenticationTokenLocalStorage';
18
+ function getToken() {
19
+ const token = localStorage.getItem(authenticationTokenLocalStorage);
20
+ return token ? JSON.parse(token) : null;
21
+ }
22
+ function setToken(token) {
23
+ localStorage.setItem(authenticationTokenLocalStorage, JSON.stringify(token));
24
+ }
25
+ function deleteToken() {
26
+ localStorage.removeItem(authenticationTokenLocalStorage);
27
+ }
28
+ function compareTokens(tr1, tr2) {
29
+ if (tr1 === null || tr2 === null) {
30
+ return tr1 === tr2;
31
+ }
32
+ return tr1.id === tr2.id;
33
+ }
34
+ function checkRight(right, value) {
35
+ if (right !== undefined) {
36
+ const valuesArray = right.split('-');
37
+ const found = valuesArray.find(x => x === value);
38
+ if (found !== undefined) {
39
+ return true;
40
+ }
41
+ }
42
+ return false;
43
+ }
44
+ class AuthenticationProvider extends _react.Component {
45
+ constructor(props) {
46
+ super(props);
47
+ this.state = {
48
+ authenticated: false,
49
+ token: null,
50
+ apiKey: null
51
+ };
52
+ if (props.test) {
53
+ this.state.authenticated = true;
54
+ this.state.token = _constants.testToken;
55
+ } else {
56
+ const token = getToken();
57
+ const apiKey = (0, _functions.getParameterByName)('apiKey');
58
+ if (token !== null) {
59
+ this.state.authenticated = true;
60
+ this.state.token = token;
61
+ } else if (process.env.NODE_ENV === 'development') {
62
+ let param = (0, _functions.getParameterByName)('authentication');
63
+ if (param !== null && param !== undefined && param.length > 0) {
64
+ param = JSON.parse(param.replace(/%22/g, '"').replace(/%20/g, ' '));
65
+ this.state.authenticated = param.authenticated;
66
+ this.state.token = param.token;
67
+ }
68
+ } else if (apiKey && apiKey.length > 0) {
69
+ this.state.apiKey = apiKey;
70
+ // TODO - Make call to get token from Api Key...
71
+ } else {
72
+ this.redirectToLogin();
73
+ }
74
+ }
75
+ }
76
+ componentDidMount() {
77
+ this.onReceiveMessageBinded = this.onReceiveMessage.bind(this);
78
+ this.onLocalStorageChangeBinded = this.onLocalStorageChange.bind(this);
79
+ window.addEventListener('message', this.onReceiveMessageBinded);
80
+ window.addEventListener('storage', this.onLocalStorageChangeBinded);
81
+ }
82
+ componentWillUnmount() {
83
+ window.removeEventListener('message', this.onReceiveMessageBinded);
84
+ window.removeEventListener('storage', this.onLocalStorageChangeBinded);
85
+ }
86
+ onReceiveMessage(event) {
87
+ if (event.data && event.data.shellAuthentication) {
88
+ this.setState({
89
+ authenticated: event.data.shellAuthentication.authenticated,
90
+ token: event.data.shellAuthentication.token
91
+ });
92
+ }
93
+ }
94
+ onLocalStorageChange(event) {
95
+ if (event.key === authenticationTokenLocalStorage) {
96
+ const value = event.newValue;
97
+ // console.log('authentication changed', value);
98
+ if (value) {
99
+ this.setState({
100
+ authenticated: true,
101
+ token: JSON.parse(value)
102
+ });
103
+ } else {
104
+ // this.setState({ authenticated: false, token: null });
105
+ this.logout();
106
+ }
107
+ }
108
+ }
109
+ getRight(objectId, key) {
110
+ if (this.state.token !== null && this.state.token.permissions !== undefined) {
111
+ const permission = this.state.token.permissions.find(x => x.objectIds.indexOf(objectId) > -1);
112
+ if (permission !== undefined) {
113
+ const right = permission.rights[key];
114
+ return right;
115
+ }
116
+ }
117
+ return undefined;
118
+ }
119
+ didChange(prevContext) {
120
+ // NOTE: Might also need to check apiKey...
121
+ return !compareTokens(this.state.token, prevContext.token);
122
+ }
123
+ logout() {
124
+ this.setState({
125
+ authenticated: false,
126
+ token: null
127
+ });
128
+ deleteToken();
129
+ this.redirectToLogin();
130
+ }
131
+ http(configuration) {
132
+ const methodName = 'http()';
133
+ if (!this.state.authenticated) {
134
+ return Promise.reject(new Error({
135
+ response: {
136
+ status: 401
137
+ }
138
+ }));
139
+ }
140
+ let configurationCombined = Object.assign(configuration, {
141
+ headers: {
142
+ Authorization: "Bearer ".concat(this.state.token.token)
143
+ }
144
+ });
145
+ // NOTE: If we have an ApiKey, might want to include a "X-API-Key" header...
146
+ if (this.state.apiKey) {
147
+ configurationCombined.headers['X-API-Key'] = this.state.apiKey;
148
+ }
149
+ return new Promise((resolve, reject) => {
150
+ (0, _axios.default)(configurationCombined).then(results => {
151
+ resolve(results);
152
+ }).catch(error => {
153
+ if (error.response !== undefined && error.response.status === 401) {
154
+ this.props.core.log('debug', namespace, methodName, 'Attempting to Renew Token');
155
+ _axios.default.post("".concat(this.props.core.urlServer, "/api/authentication/renew"), JSON.stringify(this.state.token.token), {
156
+ headers: {
157
+ 'Content-Type': 'application/json'
158
+ }
159
+ }).then(results => {
160
+ setToken(results.data);
161
+ this.setState({
162
+ authenticated: true,
163
+ token: results.data
164
+ });
165
+ configurationCombined = Object.assign(configuration, {
166
+ headers: {
167
+ Authorization: "Bearer ".concat(results.data.token)
168
+ }
169
+ });
170
+ (0, _axios.default)(configurationCombined).then(resultsSecond => {
171
+ resolve(resultsSecond);
172
+ }).catch(errorSecond => {
173
+ this.props.core.log('warning', namespace, 'Second error', errorSecond);
174
+ reject(errorSecond);
175
+ });
176
+ }).catch(errorRenew => {
177
+ this.props.core.log('warning', namespace, 'Renew Error', errorRenew);
178
+ this.logout();
179
+ });
180
+ } else {
181
+ reject(error);
182
+ }
183
+ });
184
+ });
185
+ }
186
+ checkPermission(objectId, key, value) {
187
+ const right = this.getRight(objectId, key);
188
+ return checkRight(right, value);
189
+ }
190
+ redirectToLogin() {
191
+ // Need to encode the redirect URL since we are passing it as a parameter
192
+ const redirect = encodeURIComponent(window.location);
193
+ window.location = "".concat(this.props.core.baseUrl, "/login?redirect=").concat(redirect);
194
+ }
195
+ render() {
196
+ const {
197
+ authenticated,
198
+ token,
199
+ apiKey
200
+ } = this.state;
201
+ return /*#__PURE__*/_react.default.createElement(_AuthenticationContext.default.Provider, {
202
+ value: {
203
+ authenticated: authenticated,
204
+ token: token,
205
+ apiKey: apiKey,
206
+ logout: () => this.logout(),
207
+ http: config => this.http(config),
208
+ httpRequest: config => this.http(config),
209
+ didChange: prevContext => this.didChange(prevContext),
210
+ checkRight: (right, value) => checkRight(right, value),
211
+ getRight: (objectId, key) => this.getRight(objectId, key),
212
+ checkPermission: (objectId, key, value) => this.checkPermission(objectId, key, value)
213
+ }
214
+ }, authenticated && this.props.children);
215
+ }
216
+ }
217
+ AuthenticationProvider.propTypes = {
218
+ test: _propTypes.default.bool,
219
+ core: _propTypes.default.shape().isRequired,
220
+ children: _propTypes.default.node.isRequired
221
+ };
222
+ AuthenticationProvider.defaultProps = {
223
+ test: false
224
+ };
225
+ var _default = exports.default = (0, _Core.withCore)(AuthenticationProvider);
@@ -0,0 +1,47 @@
1
+ # Authentication Context
2
+
3
+ Utilizes React Context API to keep track of authentication. Also provides function for performing HTTP requests that add authentication token.
4
+
5
+ ## Adding to your application
6
+
7
+ First the provider needs to be added to your application. This is done in index.js. Can add AuthenticationProvider directly but most commonly is done by adding [CoreWrapper](../../components/CoreWrapper).
8
+
9
+ ```
10
+ import React from 'react'
11
+ import ReactDOM from 'react-dom'
12
+ import { CoreWrapper } from 'core-library-react'
13
+ import messages_en from "./translations/en.json"
14
+ import messages_es from "./translations/es.json"
15
+ import App from './App'
16
+
17
+ const messages = {
18
+ 'en': messages_en,
19
+ 'es': messages_es
20
+ }
21
+
22
+ ReactDOM.render(
23
+ <CoreWrapper messages={ messages } logLevel={5}>
24
+ <App />
25
+ </CoreWrapper>,
26
+ document.getElementById('root')
27
+ )
28
+ ```
29
+
30
+ ## Using in your application
31
+
32
+ Use the withAuthentication HOC function to add functionality to your component.
33
+ ```
34
+ import { withAuthentication } from 'core-library-react';
35
+ ...
36
+ export default withAuthentication(MyComponent);
37
+ ```
38
+
39
+ To access objects/functions of AuthenticationProvider, use this.props.authentication.<whatever>.
40
+ - authenticated: Returns true if we have a token.
41
+ - token: Get the object that contains the token. This is what is returned from [authentication-api](https://github.com/versacall/authentication-api).
42
+ - logout(): This function will delete the token and redirect to [login-app](http://github.com/versacall/login-app).
43
+ - http(config): This function will make an HTTP request. It is based on axios. Adds bearer token and tries 1 time to renew token on a 401 error.
44
+ - didChange(prevContext)
45
+ - checkPermission(objectId, key, value)
46
+ - getRight(objectId, key)
47
+ - checkRight(right, value)
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AuthenticationContext", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _AuthenticationContext.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "AuthenticationProvider", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _AuthenticationProvider.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "withAuthentication", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _withAuthentication.default;
22
+ }
23
+ });
24
+ var _AuthenticationProvider = _interopRequireDefault(require("./AuthenticationProvider"));
25
+ var _AuthenticationContext = _interopRequireDefault(require("./AuthenticationContext"));
26
+ var _withAuthentication = _interopRequireDefault(require("./withAuthentication"));
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = withAuthentication;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _AuthenticationContext = _interopRequireDefault(require("./AuthenticationContext"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
11
+ function withAuthentication(Component) {
12
+ return props => /*#__PURE__*/_react.default.createElement(_AuthenticationContext.default.Consumer, null, authentication => /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
13
+ authentication: authentication
14
+ })));
15
+ }