@webex/webex-core 3.8.0-next.2 → 3.8.0-next.20
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.
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/service-catalog.js +23 -68
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +1 -1
- package/dist/lib/services-v2/constants.js +17 -0
- package/dist/lib/services-v2/constants.js.map +1 -0
- package/dist/lib/services-v2/index.js +58 -0
- package/dist/lib/services-v2/index.js.map +1 -0
- package/dist/lib/services-v2/interceptors/hostmap.js +64 -0
- package/dist/lib/services-v2/interceptors/hostmap.js.map +1 -0
- package/dist/lib/services-v2/interceptors/server-error.js +77 -0
- package/dist/lib/services-v2/interceptors/server-error.js.map +1 -0
- package/dist/lib/services-v2/interceptors/service.js +137 -0
- package/dist/lib/services-v2/interceptors/service.js.map +1 -0
- package/dist/lib/services-v2/metrics.js +12 -0
- package/dist/lib/services-v2/metrics.js.map +1 -0
- package/dist/lib/services-v2/service-catalog.js +433 -0
- package/dist/lib/services-v2/service-catalog.js.map +1 -0
- package/dist/lib/services-v2/service-fed-ramp.js +13 -0
- package/dist/lib/services-v2/service-fed-ramp.js.map +1 -0
- package/dist/lib/services-v2/service-url.js +119 -0
- package/dist/lib/services-v2/service-url.js.map +1 -0
- package/dist/lib/services-v2/services-v2.js +963 -0
- package/dist/lib/services-v2/services-v2.js.map +1 -0
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/dist/webex-core.js.map +1 -1
- package/package.json +13 -13
- package/src/index.js +10 -0
- package/src/lib/services/service-catalog.js +14 -54
- package/src/lib/services-v2/README.md +3 -0
- package/src/lib/services-v2/constants.js +21 -0
- package/src/lib/services-v2/index.js +23 -0
- package/src/lib/services-v2/interceptors/hostmap.js +36 -0
- package/src/lib/services-v2/interceptors/server-error.js +48 -0
- package/src/lib/services-v2/interceptors/service.js +101 -0
- package/src/lib/services-v2/metrics.js +4 -0
- package/src/lib/services-v2/service-catalog.js +455 -0
- package/src/lib/services-v2/service-fed-ramp.js +5 -0
- package/src/lib/services-v2/service-url.js +124 -0
- package/src/lib/services-v2/services-v2.js +971 -0
- package/test/fixtures/host-catalog-v2.js +247 -0
- package/test/unit/spec/services/service-catalog.js +30 -90
- package/test/unit/spec/services-v2/services-v2.js +564 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
export const serviceHostmapV2 = {
|
|
2
|
+
activeServices: {
|
|
3
|
+
conversation: 'urn:TEAM:us-east-2_a:conversation',
|
|
4
|
+
idbroker: 'urn:TEAM:us-east-2_a:idbroker',
|
|
5
|
+
locus: 'urn:TEAM:us-east-2_a:locus',
|
|
6
|
+
mercury: 'urn:TEAM:us-east-2_a:mercury',
|
|
7
|
+
},
|
|
8
|
+
services: [
|
|
9
|
+
{
|
|
10
|
+
id: 'urn:TEAM:us-east-2_a:conversation',
|
|
11
|
+
serviceName: 'conversation',
|
|
12
|
+
serviceUrls: [
|
|
13
|
+
{
|
|
14
|
+
baseUrl: 'https://prod-achm-message.svc.webex.com/conversation/api/v1',
|
|
15
|
+
priority: 1,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
baseUrl: 'https://conv-a.wbx2.com/conversation/api/v1',
|
|
19
|
+
priority: 2,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'urn:TEAM:me-central-1_d:conversation',
|
|
25
|
+
serviceName: 'conversation',
|
|
26
|
+
serviceUrls: [
|
|
27
|
+
{
|
|
28
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/conversation/api/v1',
|
|
29
|
+
priority: 1,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
baseUrl: 'https://conv-d.wbx2.com/conversation/api/v1',
|
|
33
|
+
priority: 2,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'urn:TEAM:us-east-2_a:idbroker',
|
|
39
|
+
serviceName: 'idbroker',
|
|
40
|
+
serviceUrls: [
|
|
41
|
+
{
|
|
42
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/idbroker/api/v1',
|
|
43
|
+
priority: 1,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
baseUrl: 'https://idbroker.webex.com/idb/api/v1',
|
|
47
|
+
priority: 2,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'urn:TEAM:me-central-1_d:idbroker',
|
|
53
|
+
serviceName: 'idbroker',
|
|
54
|
+
serviceUrls: [
|
|
55
|
+
{
|
|
56
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/idbroker/api/v1',
|
|
57
|
+
priority: 1,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
baseUrl: 'https://conv-d.wbx2.com/idbroker/api/v1',
|
|
61
|
+
priority: 2,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'urn:TEAM:us-east-2_a:locus',
|
|
67
|
+
serviceName: 'locus',
|
|
68
|
+
serviceUrls: [
|
|
69
|
+
{
|
|
70
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/locus/api/v1',
|
|
71
|
+
priority: 1,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
baseUrl: 'https://locus-a.wbx2.com/locus/api/v1',
|
|
75
|
+
priority: 2,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'urn:TEAM:me-central-1_d:locus',
|
|
81
|
+
serviceName: 'locus',
|
|
82
|
+
serviceUrls: [
|
|
83
|
+
{
|
|
84
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/locus/api/v1',
|
|
85
|
+
priority: 1,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
baseUrl: 'https://conv-d.wbx2.com/locus/api/v1',
|
|
89
|
+
priority: 2,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'urn:TEAM:us-east-2_a:mercury',
|
|
95
|
+
serviceName: 'mercury',
|
|
96
|
+
serviceUrls: [
|
|
97
|
+
{
|
|
98
|
+
baseUrl: 'https://mercury-a.wbx2.com/mercury/api/v1',
|
|
99
|
+
priority: 1,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: 'urn:TEAM:me-central-1_d:mercury',
|
|
105
|
+
serviceName: 'mercury',
|
|
106
|
+
serviceUrls: [
|
|
107
|
+
{
|
|
108
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/mercury/api/v1',
|
|
109
|
+
priority: 1,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
baseUrl: 'https://conv-d.wbx2.com/mercury/api/v1',
|
|
113
|
+
priority: 2,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
orgId: '3e0e410f-f83f-4ee4-ac32-12692e99355c',
|
|
119
|
+
timestamp: '1745533341',
|
|
120
|
+
format: 'U2Cv2',
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const formattedServiceHostmapV2 = [
|
|
124
|
+
{
|
|
125
|
+
id: 'urn:TEAM:us-east-2_a:conversation',
|
|
126
|
+
serviceName: 'conversation',
|
|
127
|
+
serviceUrls: [
|
|
128
|
+
{
|
|
129
|
+
baseUrl: 'https://prod-achm-message.svc.webex.com/conversation/api/v1',
|
|
130
|
+
host: 'prod-achm-message.svc.webex.com',
|
|
131
|
+
priority: 1,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
baseUrl: 'https://conv-a.wbx2.com/conversation/api/v1',
|
|
135
|
+
host: 'conv-a.wbx2.com',
|
|
136
|
+
priority: 2,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 'urn:TEAM:me-central-1_d:conversation',
|
|
142
|
+
serviceName: 'conversation',
|
|
143
|
+
serviceUrls: [
|
|
144
|
+
{
|
|
145
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/conversation/api/v1',
|
|
146
|
+
host: 'prod-adxb-message.svc.webex.com',
|
|
147
|
+
priority: 1,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
baseUrl: 'https://conv-d.wbx2.com/conversation/api/v1',
|
|
151
|
+
host: 'conv-d.wbx2.com',
|
|
152
|
+
priority: 2,
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'urn:TEAM:us-east-2_a:idbroker',
|
|
158
|
+
serviceName: 'idbroker',
|
|
159
|
+
serviceUrls: [
|
|
160
|
+
{
|
|
161
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/idbroker/api/v1',
|
|
162
|
+
host: 'prod-adxb-message.svc.webex.com',
|
|
163
|
+
priority: 1,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
baseUrl: 'https://idbroker.webex.com/idb/api/v1',
|
|
167
|
+
host: 'idbroker.webex.com',
|
|
168
|
+
priority: 2,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: 'urn:TEAM:me-central-1_d:idbroker',
|
|
174
|
+
serviceName: 'idbroker',
|
|
175
|
+
serviceUrls: [
|
|
176
|
+
{
|
|
177
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/idbroker/api/v1',
|
|
178
|
+
host: 'prod-adxb-message.svc.webex.com',
|
|
179
|
+
priority: 1,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
baseUrl: 'https://conv-d.wbx2.com/idbroker/api/v1',
|
|
183
|
+
host: 'conv-d.wbx2.com',
|
|
184
|
+
priority: 2,
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: 'urn:TEAM:us-east-2_a:locus',
|
|
190
|
+
serviceName: 'locus',
|
|
191
|
+
serviceUrls: [
|
|
192
|
+
{
|
|
193
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/locus/api/v1',
|
|
194
|
+
host: 'prod-adxb-message.svc.webex.com',
|
|
195
|
+
priority: 1,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
baseUrl: 'https://locus-a.wbx2.com/locus/api/v1',
|
|
199
|
+
host: 'locus-a.wbx2.com',
|
|
200
|
+
priority: 2,
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: 'urn:TEAM:me-central-1_d:locus',
|
|
206
|
+
serviceName: 'locus',
|
|
207
|
+
serviceUrls: [
|
|
208
|
+
{
|
|
209
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/locus/api/v1',
|
|
210
|
+
host: 'prod-adxb-message.svc.webex.com',
|
|
211
|
+
priority: 1,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
baseUrl: 'https://conv-d.wbx2.com/locus/api/v1',
|
|
215
|
+
host: 'conv-d.wbx2.com',
|
|
216
|
+
priority: 2,
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: 'urn:TEAM:us-east-2_a:mercury',
|
|
222
|
+
serviceName: 'mercury',
|
|
223
|
+
serviceUrls: [
|
|
224
|
+
{
|
|
225
|
+
baseUrl: 'https://mercury-a.wbx2.com/mercury/api/v1',
|
|
226
|
+
host: 'mercury-a.wbx2.com',
|
|
227
|
+
priority: 1,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: 'urn:TEAM:me-central-1_d:mercury',
|
|
233
|
+
serviceName: 'mercury',
|
|
234
|
+
serviceUrls: [
|
|
235
|
+
{
|
|
236
|
+
baseUrl: 'https://prod-adxb-message.svc.webex.com/mercury/api/v1',
|
|
237
|
+
host: 'prod-adxb-message.svc.webex.com',
|
|
238
|
+
priority: 1,
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
baseUrl: 'https://conv-d.wbx2.com/mercury/api/v1',
|
|
242
|
+
host: 'conv-d.wbx2.com',
|
|
243
|
+
priority: 2,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
];
|
|
@@ -208,108 +208,48 @@ describe('webex-core', () => {
|
|
|
208
208
|
hosts: [{host: 'example1.com'}, {host: 'example2.com'}],
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
it(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
211
|
+
it.each([
|
|
212
|
+
'discovery',
|
|
213
|
+
'preauth',
|
|
214
|
+
'signin',
|
|
215
|
+
'postauth',
|
|
216
|
+
'override'
|
|
217
|
+
])('matches a default url correctly', (serviceGroup) => {
|
|
218
|
+
const url = 'https://example.com/resource/id';
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const exampleService = {
|
|
222
|
+
defaultUrl: 'https://example.com/resource',
|
|
223
|
+
hosts: [{host: 'example1.com'}, {host: 'example2.com'}],
|
|
223
224
|
};
|
|
224
225
|
|
|
225
|
-
|
|
226
|
-
assert.deepEqual(result, {defaultUrl: 'https://signin.example.com', hosts: []});
|
|
227
|
-
});
|
|
226
|
+
catalog.serviceGroups[serviceGroup].push(otherService, exampleService);
|
|
228
227
|
|
|
229
|
-
|
|
230
|
-
catalog.serviceGroups = {
|
|
231
|
-
discovery: [{defaultUrl: 'https://discovery.example.com', hosts: []}],
|
|
232
|
-
preauth: [{defaultUrl: 'https://preauth.example.com', hosts: []}],
|
|
233
|
-
signin: [{defaultUrl: 'https://signin.example.com', hosts: []}],
|
|
234
|
-
postauth: [{defaultUrl: 'https://postauth.example.com', hosts: []}],
|
|
235
|
-
override: [{defaultUrl: 'https://override.example.com', hosts: []}],
|
|
236
|
-
};
|
|
228
|
+
const service = catalog.findServiceUrlFromUrl(url);
|
|
237
229
|
|
|
238
|
-
|
|
239
|
-
assert.isFalse(result);
|
|
230
|
+
assert.equal(service, exampleService);
|
|
240
231
|
});
|
|
241
232
|
|
|
242
|
-
it(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
233
|
+
it.each([
|
|
234
|
+
'discovery',
|
|
235
|
+
'preauth',
|
|
236
|
+
'signin',
|
|
237
|
+
'postauth',
|
|
238
|
+
'override'
|
|
239
|
+
])('matches an alternate host url', (serviceGroup) => {
|
|
240
|
+
const url = 'https://example2.com/resource/id';
|
|
250
241
|
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
it('should skip service URLs with invalid default URLs', () => {
|
|
256
|
-
catalog.serviceGroups = {
|
|
257
|
-
discovery: [{defaultUrl: 'invalid-url', hosts: []}],
|
|
258
|
-
preauth: [{defaultUrl: 'https://preauth.example.com', hosts: []}],
|
|
259
|
-
signin: [{defaultUrl: 'https://signin.example.com', hosts: []}],
|
|
260
|
-
postauth: [{defaultUrl: 'https://postauth.example.com', hosts: []}],
|
|
261
|
-
override: [{defaultUrl: 'https://override.example.com', hosts: []}],
|
|
242
|
+
const exampleService = {
|
|
243
|
+
defaultUrl: 'https://example.com/resource',
|
|
244
|
+
hosts: [{host: 'example1.com'}, {host: 'example2.com'}],
|
|
262
245
|
};
|
|
263
246
|
|
|
264
|
-
|
|
265
|
-
assert.deepEqual(result, {defaultUrl: 'https://signin.example.com', hosts: []});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should skip alternate hostnames with invalid URLs', () => {
|
|
269
|
-
catalog.serviceGroups = {
|
|
270
|
-
discovery: [{defaultUrl: 'https://discovery.example.com', hosts: [{host: 'invalid-url'}]}],
|
|
271
|
-
preauth: [{defaultUrl: 'https://preauth.example.com', hosts: []}],
|
|
272
|
-
signin: [{defaultUrl: 'https://signin.example.com', hosts: []}],
|
|
273
|
-
postauth: [{defaultUrl: 'https://postauth.example.com', hosts: []}],
|
|
274
|
-
override: [{defaultUrl: 'https://override.example.com', hosts: []}],
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
const result = catalog.findServiceUrlFromUrl('https://signin.example.com/resource');
|
|
278
|
-
assert.deepEqual(result, {defaultUrl: 'https://signin.example.com', hosts: []});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('should return the service URL object if found with a different protocol', () => {
|
|
282
|
-
catalog.serviceGroups = {
|
|
283
|
-
discovery: [{defaultUrl: 'https://discovery.example.com', hosts: []}],
|
|
284
|
-
preauth: [{defaultUrl: 'https://preauth.example.com', hosts: []}],
|
|
285
|
-
signin: [{defaultUrl: 'https://signin.example.com', hosts: []}],
|
|
286
|
-
postauth: [{defaultUrl: 'https://postauth.example.com', hosts: []}],
|
|
287
|
-
override: [{defaultUrl: 'https://override.example.com', hosts: []}],
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
const result = catalog.findServiceUrlFromUrl('wss://signin.example.com/resource');
|
|
291
|
-
assert.deepEqual(result, {defaultUrl: 'https://signin.example.com', hosts: []});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('should return the exact protocol service URL object if both protocols are present', () => {
|
|
295
|
-
catalog.serviceGroups = {
|
|
296
|
-
discovery: [{defaultUrl: 'https://discovery.example.com', hosts: []}],
|
|
297
|
-
preauth: [{defaultUrl: 'https://preauth.example.com', hosts: []}],
|
|
298
|
-
signin: [
|
|
299
|
-
{defaultUrl: 'https://signin.example.com', hosts: []},
|
|
300
|
-
{defaultUrl: 'wss://signin.example.com', hosts: []},
|
|
301
|
-
],
|
|
302
|
-
postauth: [{defaultUrl: 'https://postauth.example.com', hosts: []}],
|
|
303
|
-
override: [{defaultUrl: 'https://override.example.com', hosts: []}],
|
|
304
|
-
};
|
|
247
|
+
catalog.serviceGroups[serviceGroup].push(otherService, exampleService);
|
|
305
248
|
|
|
306
|
-
const
|
|
307
|
-
const resultWss = catalog.findServiceUrlFromUrl('wss://signin.example.com/resource');
|
|
249
|
+
const service = catalog.findServiceUrlFromUrl(url);
|
|
308
250
|
|
|
309
|
-
assert.
|
|
310
|
-
assert.deepEqual(resultWss, {defaultUrl: 'wss://signin.example.com', hosts: []});
|
|
251
|
+
assert.equal(service, exampleService);
|
|
311
252
|
});
|
|
312
|
-
|
|
313
253
|
});
|
|
314
254
|
});
|
|
315
255
|
});
|