@defra/flood-webchat 0.0.1-beta.4 → 0.0.1-beta.41

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 (48) hide show
  1. package/README.md +83 -1
  2. package/dist/client.js +2146 -472
  3. package/dist/client.js.map +1 -1
  4. package/dist/server.js +181 -241
  5. package/dist/server.js.map +1 -1
  6. package/main.scss +10 -6
  7. package/package.json +6 -2
  8. package/src/client/components/availability/availability.jsx +71 -54
  9. package/src/client/components/availability/availability.scss +15 -33
  10. package/src/client/components/chat/chat.jsx +233 -0
  11. package/src/client/components/chat/chat.scss +233 -0
  12. package/src/client/components/errorSummary/error-summary.jsx +34 -0
  13. package/src/client/components/live-region.jsx +55 -0
  14. package/src/client/components/message/message.jsx +20 -0
  15. package/src/client/components/panel/panel-footer.jsx +9 -0
  16. package/src/client/components/panel/panel-header.jsx +54 -14
  17. package/src/client/components/panel/panel.jsx +128 -71
  18. package/src/client/components/panel/panel.scss +63 -22
  19. package/src/client/components/screens/end-chat.jsx +77 -0
  20. package/src/client/components/screens/feedback.jsx +66 -0
  21. package/src/client/components/screens/pre-chat.jsx +50 -30
  22. package/src/client/components/screens/request-chat.jsx +177 -4
  23. package/src/client/components/screens/settings.jsx +97 -0
  24. package/src/client/components/screens/unavailable.jsx +23 -0
  25. package/src/client/components/skip-link.jsx +42 -0
  26. package/src/client/hooks/useFocusedElements.js +80 -0
  27. package/src/client/hooks/useTextareaAutosize.js +13 -0
  28. package/src/client/index.jsx +15 -1
  29. package/src/client/lib/agent-status-headline.js +17 -0
  30. package/src/client/lib/check-availability.js +1 -0
  31. package/src/client/lib/history.js +13 -0
  32. package/src/client/lib/message-notification.js +36 -0
  33. package/src/client/lib/transform-messages.js +34 -0
  34. package/src/client/scss/_objects.scss +33 -0
  35. package/src/client/scss/_settings.scss +101 -0
  36. package/src/client/scss/_tools.scss +33 -0
  37. package/src/client/scss/_utilities.scss +25 -0
  38. package/src/client/store/AppProvider.jsx +187 -0
  39. package/src/client/store/actions-map.js +152 -0
  40. package/src/client/store/constants.js +3 -0
  41. package/src/client/store/reducer.js +31 -0
  42. package/src/client/store/useApp.js +5 -0
  43. package/src/client/store/useChatSdk.js +37 -0
  44. package/src/server/index.js +15 -6
  45. package/src/server/lib/client.js +31 -35
  46. package/src/server/lib/utils.js +16 -8
  47. package/src/client/lib/external-stores.js +0 -4
  48. package/src/client/lib/external-sync-store.js +0 -42
@@ -0,0 +1,101 @@
1
+ .wc-heading {
2
+ @extend %govuk-heading-m;
3
+ font-size: 19px;
4
+ margin-bottom: 15px;
5
+ }
6
+
7
+ .wc-list {
8
+ @extend %govuk-list;
9
+ @extend %govuk-list--bullet;
10
+ font-size: 16px;
11
+ line-height: 1.25;
12
+ }
13
+
14
+ .wc-body p {
15
+ font-size: 16px;
16
+ line-height: 1.25;
17
+ margin-bottom: 15px;
18
+ @extend %govuk-body-s;
19
+ }
20
+
21
+ .wc-body .govuk-error-message {
22
+ color: govuk-colour('red');
23
+ font-weight: 700;
24
+ }
25
+
26
+ .wc-link,
27
+ .wc-button,
28
+ .govuk-button-group .wc-button,
29
+ .govuk-button-group .wc-link {
30
+ font-size: 16px;
31
+ }
32
+
33
+ .wc-button[aria-disabled="true"] {
34
+ cursor: not-allowed;
35
+ opacity: 0.5;
36
+ }
37
+
38
+ .wc-label {
39
+ font-size: 16px;
40
+ line-height: 1.25;
41
+ }
42
+
43
+ .wc-form-group {
44
+ margin-bottom: 15px;
45
+ }
46
+
47
+ .wc-hint {
48
+ font-size: 16px;
49
+ line-height: 1.25;
50
+ }
51
+
52
+ .wc-inset-text {
53
+ margin: 0 0 20px;
54
+ padding: 5px 5px 5px 15px;
55
+ font-size: 16px;
56
+ border-left-width: 5px;
57
+ }
58
+
59
+ .wc-error-summary__title {
60
+ font-size: 19px;
61
+ line-height: 1.25;
62
+ margin-bottom: 15px;
63
+ }
64
+
65
+ .wc-error-summary__list,
66
+ .wc-error-message {
67
+ font-size: 16px;
68
+ line-height: 1.25;
69
+ }
70
+
71
+ .wc-input, .wc-textarea {
72
+ font-size: 16px;
73
+ line-height: 1.25;
74
+ }
75
+
76
+ .wc-back-link {
77
+ font-size: 16px;
78
+ line-height: 1.25;
79
+ margin: 0 0 25px;
80
+ }
81
+
82
+ // stylelint-disable declaration-no-important
83
+ .wc-live {
84
+ position: absolute !important;
85
+ width: 1px !important;
86
+ height: 1px !important;
87
+ margin: 0 !important;
88
+ padding: 0 !important;
89
+ overflow: hidden !important;
90
+ clip: rect(0 0 0 0) !important;
91
+ -webkit-clip-path: inset(50%) !important;
92
+ clip-path: inset(50%) !important;
93
+ border: 0 !important;
94
+ white-space: nowrap !important;
95
+
96
+ &::before,
97
+ &::after {
98
+ content: ' ';
99
+ }
100
+ }
101
+ // stylelint-enable declaration-no-important
@@ -0,0 +1,33 @@
1
+ // Check there is ot already similar functinality in GOV.UK Frontend
2
+
3
+ @mixin defra-visually-hidden() {
4
+ position: absolute;
5
+ width: 1px;
6
+ height: 1px;
7
+ margin: 0;
8
+ padding: 0;
9
+ overflow: hidden;
10
+ clip: rect(0 0 0 0);
11
+ -webkit-clip-path: inset(50%);
12
+ clip-path: inset(50%);
13
+ border: 0;
14
+ white-space: nowrap;
15
+ }
16
+
17
+ // Map specific mixins
18
+ @mixin focus($glow: 8px, $strong: 5px, $background: 2px, $inset: 0) {
19
+ position:absolute;
20
+ content:'';
21
+ left: 5px;
22
+ right: 5px;
23
+ top: 5px;
24
+ bottom: 5px;
25
+ box-shadow:
26
+ 0 0 0 $background #ffffff,
27
+ inset 0 0 0 $inset govuk-colour('black'),
28
+ 0 0 0 $strong govuk-colour('black'),
29
+ 0 0 0 $glow $govuk-focus-colour;
30
+ outline: 3px solid transparent;
31
+ pointer-events: none;
32
+ z-index: 99;
33
+ }
@@ -0,0 +1,25 @@
1
+ .wc-u-html {
2
+ @include mq ($until: tablet) {
3
+ height: 100vh;
4
+ overflow: hidden;
5
+ }
6
+ }
7
+
8
+ .wc-u-body {
9
+ @include mq ($until: tablet) {
10
+ position: fixed;
11
+ overflow: hidden;
12
+ top:0;
13
+ right:0;
14
+ bottom:0;
15
+ left:0;
16
+ }
17
+ }
18
+
19
+ .wc-u-hidden {
20
+ visibility: hidden;
21
+ }
22
+
23
+ .wc-u-scroll-padding {
24
+ scroll-padding-bottom: calc(2rem + 20px);
25
+ }
@@ -0,0 +1,187 @@
1
+ import React, { createContext, useEffect, useReducer, useMemo } from 'react'
2
+ import { ChatEvent } from '@nice-devone/nice-cxone-chat-web-sdk'
3
+
4
+ import { messageNotification } from '../lib/message-notification.js'
5
+
6
+ import { initialState, reducer } from './reducer.js'
7
+ import { CUSTOMER_ID_STORAGE_KEY, THREAD_ID_STORAGE_KEY, SETTINGS_STORAGE_KEY } from './constants.js'
8
+
9
+ export const AppContext = createContext(initialState)
10
+
11
+ export const AppProvider = ({ sdk, availability, options, children }) => {
12
+ const [state, dispatch] = useReducer(reducer, initialState)
13
+
14
+ const playSound = messageNotification(options.audioUrl)
15
+
16
+ /**
17
+ * SDK event handlers
18
+ */
19
+ const onLiveChatRecovered = e => {
20
+ dispatch({ type: 'SET_AGENT', payload: e.detail.data.inboxAssignee })
21
+ dispatch({ type: 'SET_AGENT_STATUS', payload: e.detail.data.contact.status })
22
+ dispatch({ type: 'SET_UNSEEN_COUNT', payload: e.detail.data.contact.customerStatistics.unseenMessagesCount })
23
+ }
24
+
25
+ const onAssignedAgentChanged = e => {
26
+ dispatch({ type: 'SET_AGENT', payload: e.detail.data.inboxAssignee })
27
+ dispatch({ type: 'SET_AGENT_STATUS', payload: e.detail.data.case.status })
28
+ }
29
+
30
+ const onAgentTypingStarted = () => {
31
+ dispatch({ type: 'SET_AGENT_TYPING', payload: true })
32
+ }
33
+
34
+ const onAgentTypingEnded = () => {
35
+ dispatch({ type: 'SET_AGENT_TYPING', payload: false })
36
+ dispatch({ type: 'SET_LIVE_REGION_TEXT' })
37
+ }
38
+
39
+ const onMessageCreated = e => {
40
+ dispatch({ type: 'SET_MESSAGE', payload: e.detail.data.message })
41
+ dispatch({ type: 'SET_AGENT_STATUS', payload: e.detail.data.case.status })
42
+ dispatch({ type: 'SET_UNSEEN_COUNT', payload: e.detail.data.case.customerStatistics.unseenMessagesCount })
43
+
44
+ const isAudioOn = JSON.parse(window.localStorage.getItem(SETTINGS_STORAGE_KEY)).audio
45
+
46
+ if (isAudioOn && e.detail.data.message.direction === 'outbound') {
47
+ playSound()
48
+ }
49
+ }
50
+
51
+ const onContactStatusChanged = e => {
52
+ dispatch({ type: 'SET_AGENT_STATUS', payload: e.detail.data.case.status })
53
+ }
54
+
55
+ const onMatchMedia = e => {
56
+ dispatch({ type: 'TOGGLE_IS_MOBILE', payload: e.matches })
57
+ }
58
+
59
+ const onKeydown = () => {
60
+ dispatch({ type: 'TOGGLE_IS_KEYBOARD', payload: true })
61
+ }
62
+
63
+ const onPointerdown = () => {
64
+ dispatch({ type: 'TOGGLE_IS_KEYBOARD', payload: false })
65
+ }
66
+
67
+ useEffect(() => {
68
+ sdk.onChatEvent(ChatEvent.LIVECHAT_RECOVERED, onLiveChatRecovered)
69
+ sdk.onChatEvent(ChatEvent.MESSAGE_CREATED, onMessageCreated)
70
+ sdk.onChatEvent(ChatEvent.AGENT_TYPING_STARTED, onAgentTypingStarted)
71
+ sdk.onChatEvent(ChatEvent.AGENT_TYPING_ENDED, onAgentTypingEnded)
72
+ sdk.onChatEvent(ChatEvent.ASSIGNED_AGENT_CHANGED, onAssignedAgentChanged)
73
+ sdk.onChatEvent(ChatEvent.CONTACT_STATUS_CHANGED, onContactStatusChanged)
74
+ // We need to know if it is a mobile and if it is a keyboard interaction
75
+ window.matchMedia('(max-width: 640px)').addEventListener('change', onMatchMedia)
76
+ window.addEventListener('keydown', onKeydown)
77
+ window.addEventListener('pointerdown', onPointerdown)
78
+ // Tidying up
79
+ return () => {
80
+ window.removeEventListener('change', onMatchMedia)
81
+ window.removeEventListener('keydown', onKeydown)
82
+ window.removeEventListener('pointerdown', onPointerdown)
83
+ }
84
+ }, [sdk])
85
+
86
+ /**
87
+ * Initialize customerId, threadId and whether the webchat should be open
88
+ */
89
+ useEffect(() => {
90
+ dispatch({ type: 'SET_AVAILABILITY', payload: availability })
91
+
92
+ setCustomerId(window.localStorage.getItem(CUSTOMER_ID_STORAGE_KEY))
93
+ setThreadId(window.localStorage.getItem(THREAD_ID_STORAGE_KEY))
94
+ setSettings(JSON.parse(window.localStorage.getItem(SETTINGS_STORAGE_KEY)) || state.settings)
95
+ }, [])
96
+
97
+ /**
98
+ * Set browser history on start chat click
99
+ */
100
+ useEffect(() => {
101
+ if (window.location.hash === '#webchat') {
102
+ setChatVisibility(true)
103
+ }
104
+
105
+ const onBrowserNavigation = () => {
106
+ if (window.location.hash === '#webchat') {
107
+ setChatVisibility(true)
108
+ } else {
109
+ setChatVisibility(false)
110
+ }
111
+ }
112
+
113
+ window.addEventListener('popstate', onBrowserNavigation)
114
+
115
+ return () => {
116
+ window.removeEventListener('popstate', onBrowserNavigation)
117
+ }
118
+ }, [])
119
+
120
+ /**
121
+ * State update functions
122
+ */
123
+ const setChatVisibility = payload => {
124
+ dispatch({ type: 'SET_CHAT_VISIBILITY', payload })
125
+ }
126
+
127
+ const setCustomerId = customerId => {
128
+ dispatch({ type: 'SET_CUSTOMER_ID', payload: customerId })
129
+ }
130
+
131
+ const setThreadId = threadId => {
132
+ dispatch({ type: 'SET_THREAD_ID', payload: threadId })
133
+ }
134
+
135
+ const setThread = thread => {
136
+ dispatch({ type: 'SET_THREAD', payload: thread })
137
+ }
138
+
139
+ const setMessages = messages => {
140
+ dispatch({ type: 'SET_MESSAGES', payload: messages })
141
+ }
142
+
143
+ const setSettings = data => {
144
+ dispatch({ type: 'SET_SETTINGS', payload: data })
145
+ }
146
+
147
+ const setUnseenCount = unseenCount => {
148
+ dispatch({ type: 'SET_UNSEEN_COUNT', payload: unseenCount })
149
+ }
150
+
151
+ const setInstigatorId = id => {
152
+ dispatch({ type: 'SET_INSTIGATOR_ID', payload: id })
153
+ }
154
+
155
+ const setLiveRegionText = text => {
156
+ dispatch({ type: 'SET_LIVE_REGION_TEXT', payload: text })
157
+ }
158
+
159
+ /**
160
+ * Application-wide state and state functions
161
+ */
162
+ const store = useMemo(() => ({
163
+ ...state,
164
+ sdk,
165
+ setSettings,
166
+ setCustomerId,
167
+ setThreadId,
168
+ setThread,
169
+ setMessages,
170
+ setUnseenCount,
171
+ setChatVisibility,
172
+ setInstigatorId,
173
+ setLiveRegionText,
174
+ onLiveChatRecovered,
175
+ onAssignedAgentChanged,
176
+ onAgentTypingStarted,
177
+ onAgentTypingEnded,
178
+ onMessageCreated,
179
+ onContactStatusChanged
180
+ }))
181
+
182
+ return (
183
+ <AppContext.Provider value={store}>
184
+ {children}
185
+ </AppContext.Provider>
186
+ )
187
+ }
@@ -0,0 +1,152 @@
1
+ import { transformMessages, transformMessage } from '../lib/transform-messages'
2
+ import { CUSTOMER_ID_STORAGE_KEY, THREAD_ID_STORAGE_KEY, SETTINGS_STORAGE_KEY } from './constants'
3
+
4
+ const setSettings = (state, payload) => {
5
+ if (payload) {
6
+ window.localStorage.setItem(SETTINGS_STORAGE_KEY, JSON.stringify(payload))
7
+ } else {
8
+ window.localStorage.removeItem(SETTINGS_STORAGE_KEY)
9
+ }
10
+
11
+ return {
12
+ ...state,
13
+ settings: payload
14
+ }
15
+ }
16
+
17
+ const setCustomerId = (state, payload) => {
18
+ if (payload) {
19
+ window.localStorage.setItem(CUSTOMER_ID_STORAGE_KEY, payload)
20
+ } else {
21
+ window.localStorage.removeItem(CUSTOMER_ID_STORAGE_KEY)
22
+ }
23
+
24
+ return {
25
+ ...state,
26
+ customerId: payload
27
+ }
28
+ }
29
+
30
+ const setThreadId = (state, payload) => {
31
+ if (payload) {
32
+ window.localStorage.setItem(THREAD_ID_STORAGE_KEY, payload)
33
+ } else {
34
+ window.localStorage.removeItem(THREAD_ID_STORAGE_KEY)
35
+ }
36
+
37
+ return {
38
+ ...state,
39
+ threadId: payload
40
+ }
41
+ }
42
+
43
+ const setChatVisibility = (state, payload) => {
44
+ return {
45
+ ...state,
46
+ isChatOpen: payload
47
+ }
48
+ }
49
+
50
+ const setAvailability = (state, payload) => {
51
+ return {
52
+ ...state,
53
+ availability: payload
54
+ }
55
+ }
56
+
57
+ const setThread = (state, payload) => {
58
+ return {
59
+ ...state,
60
+ thread: payload
61
+ }
62
+ }
63
+
64
+ const setMessages = (state, payload) => {
65
+ return {
66
+ ...state,
67
+ messages: transformMessages(payload).reverse()
68
+ }
69
+ }
70
+
71
+ const setMessage = (state, payload) => {
72
+ return {
73
+ ...state,
74
+ message: transformMessage(payload),
75
+ messages: [...state.messages, transformMessage(payload)]
76
+ }
77
+ }
78
+
79
+ const setAgent = (state, payload) => {
80
+ return {
81
+ ...state,
82
+ agent: payload
83
+ }
84
+ }
85
+
86
+ const setAgentIsTyping = (state, payload) => {
87
+ return {
88
+ ...state,
89
+ isAgentTyping: payload
90
+ }
91
+ }
92
+
93
+ const setAgentStatus = (state, payload) => {
94
+ return {
95
+ ...state,
96
+ agentStatus: payload
97
+ }
98
+ }
99
+
100
+ const setUnseenCount = (state, payload) => {
101
+ return {
102
+ ...state,
103
+ unseenCount: payload
104
+ }
105
+ }
106
+
107
+ const setInstigatorId = (state, payload) => {
108
+ return {
109
+ ...state,
110
+ instigatorId: payload
111
+ }
112
+ }
113
+
114
+ const setLiveRegionText = (state, payload) => {
115
+ return {
116
+ ...state,
117
+ liveRegionText: payload
118
+ }
119
+ }
120
+
121
+ const toggleIsMobile = (state, payload) => {
122
+ return {
123
+ ...state,
124
+ isMobile: payload
125
+ }
126
+ }
127
+
128
+ const toggleIsKeyboard = (state, payload) => {
129
+ return {
130
+ ...state,
131
+ isKeyboard: payload
132
+ }
133
+ }
134
+
135
+ export const actionsMap = {
136
+ SET_CHAT_VISIBILITY: setChatVisibility,
137
+ SET_AVAILABILITY: setAvailability,
138
+ SET_SETTINGS: setSettings,
139
+ SET_CUSTOMER_ID: setCustomerId,
140
+ SET_THREAD_ID: setThreadId,
141
+ SET_THREAD: setThread,
142
+ SET_MESSAGE: setMessage,
143
+ SET_MESSAGES: setMessages,
144
+ SET_AGENT: setAgent,
145
+ SET_AGENT_TYPING: setAgentIsTyping,
146
+ SET_AGENT_STATUS: setAgentStatus,
147
+ SET_UNSEEN_COUNT: setUnseenCount,
148
+ SET_INSTIGATOR_ID: setInstigatorId,
149
+ SET_LIVE_REGION_TEXT: setLiveRegionText,
150
+ TOGGLE_IS_MOBILE: toggleIsMobile,
151
+ TOGGLE_IS_KEYBOARD: toggleIsKeyboard
152
+ }
@@ -0,0 +1,3 @@
1
+ export const SETTINGS_STORAGE_KEY = 'webchat_settings'
2
+ export const CUSTOMER_ID_STORAGE_KEY = 'webchat_customer_id'
3
+ export const THREAD_ID_STORAGE_KEY = 'webchat_thread_id'
@@ -0,0 +1,31 @@
1
+ import { actionsMap } from './actions-map'
2
+
3
+ export const initialState = {
4
+ availability: null,
5
+ customerId: null,
6
+ threadId: null,
7
+ thread: null,
8
+ messages: [],
9
+ unseenCount: 0,
10
+ instigatorId: null,
11
+ agent: null,
12
+ agentStatus: null,
13
+ isAgentTyping: false,
14
+ isChatOpen: false,
15
+ isMobile: window.matchMedia('(max-width: 640px)').matches,
16
+ isKeyboard: false,
17
+ settings: { audio: true, scroll: true }
18
+ }
19
+
20
+ export const reducer = (state, action) => {
21
+ const { type, payload } = action
22
+
23
+ const fn = actionsMap[type]
24
+
25
+ if (fn) {
26
+ const actionFunction = fn.bind(this, state, payload)
27
+ return actionFunction()
28
+ }
29
+
30
+ return state
31
+ }
@@ -0,0 +1,5 @@
1
+ import { useContext } from 'react'
2
+
3
+ import { AppContext } from './AppProvider.jsx'
4
+
5
+ export const useApp = () => useContext(AppContext)
@@ -0,0 +1,37 @@
1
+ export const useChatSdk = sdk => {
2
+ const connect = async () => sdk.authorize()
3
+
4
+ const fetchCustomerId = async () => {
5
+ const response = await connect()
6
+ return response?.consumerIdentity.idOnExternalPlatform
7
+ }
8
+
9
+ const fetchThread = async threadId => {
10
+ await connect()
11
+ return sdk.getThread(threadId)
12
+ }
13
+
14
+ const fetchMessages = async (thread, threadId) => {
15
+ await connect()
16
+
17
+ const recovered = await thread.recover(threadId)
18
+
19
+ const allMessages = []
20
+ let fetchedMessages = recovered.messages
21
+
22
+ while (fetchedMessages.length) {
23
+ fetchedMessages.map(msg => allMessages.push(msg))
24
+
25
+ try {
26
+ const response = await thread.loadMoreMessages()
27
+ fetchedMessages = response.data.messages
28
+ } catch (err) {
29
+ fetchedMessages = []
30
+ }
31
+ }
32
+
33
+ return allMessages
34
+ }
35
+
36
+ return { connect, fetchCustomerId, fetchThread, fetchMessages }
37
+ }
@@ -1,4 +1,4 @@
1
- const { authenticate, getHost, getIsOpen, getActivity } = require('./lib/client.js')
1
+ const { authenticate, getApiBaseUrl, getIsOpen, getActivity } = require('./lib/client.js')
2
2
 
3
3
  /**
4
4
  * Returns webchat availability
@@ -9,6 +9,8 @@ const { authenticate, getHost, getIsOpen, getActivity } = require('./lib/client.
9
9
  * @param options.accessSecret {string}
10
10
  * @param options.skillEndpoint {string}
11
11
  * @param options.hoursEndpoint {string}
12
+ * @param options.authenticationUri {string}
13
+ * @param options.wellKnownUri {string}
12
14
  * @param options.maxQueueCount {string}
13
15
  * @returns {Promise<{date: Date, availability: (string)}>}
14
16
  */
@@ -17,20 +19,27 @@ module.exports = async function getAvailability ({
17
19
  clientSecret,
18
20
  accessKey,
19
21
  accessSecret,
22
+ maxQueueCount,
20
23
  skillEndpoint,
21
24
  hoursEndpoint,
22
- maxQueueCount
25
+ wellKnownUri = 'https://cxone.niceincontact.com/.well-known/cxone-configuration',
26
+ authenticationUri = 'https://cxone.niceincontact.com/auth/token'
23
27
  }) {
24
28
  const authorisation = 'Basic ' + Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret)}`).toString('base64')
25
29
 
26
30
  // Cache authentication and re-authenticate when needed (lasts 1 hour?)
27
- const { tenantId, token, tokenType } = await authenticate({ authorisation, accessKey, accessSecret })
31
+ const { tenantId, token, tokenType } = await authenticate({
32
+ authenticationUri,
33
+ authorisation,
34
+ accessKey,
35
+ accessSecret
36
+ })
28
37
 
29
- const host = await getHost({ tenantId })
38
+ const apiBaseUrl = await getApiBaseUrl({ wellKnownUri, tenantId })
30
39
 
31
40
  const [{ hasCapacity, hasAgentsAvailable }, isOpen] = await Promise.all([
32
- getActivity({ tokenType, token, host, skillEndpoint, maxQueueCount }),
33
- getIsOpen({ token, tokenType, host, hoursEndpoint })
41
+ getActivity({ baseUrl: apiBaseUrl, tokenType, token, skillEndpoint, maxQueueCount }),
42
+ getIsOpen({ baseUrl: apiBaseUrl, token, tokenType, hoursEndpoint })
34
43
  ])
35
44
 
36
45
  const isAvailable = isOpen && hasAgentsAvailable && hasCapacity