@webex/webex-core 3.0.0-beta.14 → 3.0.0-beta.15
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/config.js.map +1 -1
- package/dist/credentials-config.js +44 -44
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +4 -4
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +21 -6
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +19 -5
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +2 -0
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +2 -2
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +1 -1
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +6 -6
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +9 -7
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/index.js +2 -2
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +2 -2
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
- package/src/config.js +9 -11
- package/src/credentials-config.js +110 -72
- package/src/index.js +4 -14
- package/src/interceptors/auth.js +36 -37
- package/src/interceptors/default-options.js +0 -1
- package/src/interceptors/embargo.js +1 -1
- package/src/interceptors/payload-transformer.js +1 -2
- package/src/interceptors/rate-limit.js +8 -5
- package/src/interceptors/redirect.js +14 -8
- package/src/interceptors/request-event.js +4 -8
- package/src/interceptors/request-logger.js +8 -5
- package/src/interceptors/response-logger.js +11 -8
- package/src/interceptors/user-agent.js +1 -2
- package/src/interceptors/webex-user-agent.js +3 -9
- package/src/lib/batcher.js +70 -69
- package/src/lib/credentials/credentials.js +112 -122
- package/src/lib/credentials/grant-errors.js +6 -7
- package/src/lib/credentials/index.js +1 -4
- package/src/lib/credentials/scope.js +1 -4
- package/src/lib/credentials/token-collection.js +1 -1
- package/src/lib/credentials/token.js +86 -80
- package/src/lib/page.js +10 -11
- package/src/lib/services/constants.js +3 -13
- package/src/lib/services/index.js +2 -2
- package/src/lib/services/interceptors/server-error.js +12 -7
- package/src/lib/services/interceptors/service.js +6 -5
- package/src/lib/services/metrics.js +1 -1
- package/src/lib/services/service-catalog.js +110 -100
- package/src/lib/services/service-fed-ramp.js +1 -2
- package/src/lib/services/service-host.js +10 -17
- package/src/lib/services/service-registry.js +69 -96
- package/src/lib/services/service-state.js +4 -6
- package/src/lib/services/service-url.js +24 -23
- package/src/lib/services/services.js +260 -251
- package/src/lib/stateless-webex-plugin.js +4 -2
- package/src/lib/storage/decorators.js +68 -66
- package/src/lib/storage/index.js +4 -6
- package/src/lib/storage/make-webex-plugin-store.js +34 -21
- package/src/lib/storage/make-webex-store.js +6 -7
- package/src/lib/storage/memory-store-adapter.js +3 -3
- package/src/lib/webex-core-plugin-mixin.js +10 -7
- package/src/lib/webex-http-error.js +7 -8
- package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
- package/src/lib/webex-plugin.js +41 -34
- package/src/plugins/logger.js +8 -3
- package/src/webex-core.js +185 -116
- package/src/webex-internal-core.js +15 -9
- package/test/integration/spec/credentials/credentials.js +26 -30
- package/test/integration/spec/credentials/token.js +36 -33
- package/test/integration/spec/services/service-catalog.js +177 -156
- package/test/integration/spec/services/services.js +313 -304
- package/test/integration/spec/webex-core.js +98 -86
- package/test/unit/spec/_setup.js +26 -18
- package/test/unit/spec/credentials/credentials.js +189 -154
- package/test/unit/spec/credentials/token.js +94 -76
- package/test/unit/spec/interceptors/auth.js +291 -243
- package/test/unit/spec/interceptors/default-options.js +36 -24
- package/test/unit/spec/interceptors/embargo.js +32 -27
- package/test/unit/spec/interceptors/network-timing.js +2 -2
- package/test/unit/spec/interceptors/payload-transformer.js +61 -52
- package/test/unit/spec/interceptors/rate-limit.js +104 -75
- package/test/unit/spec/interceptors/redirect.js +22 -20
- package/test/unit/spec/interceptors/request-timing.js +18 -22
- package/test/unit/spec/interceptors/user-agent.js +28 -16
- package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
- package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
- package/test/unit/spec/lib/batcher.js +36 -32
- package/test/unit/spec/lib/page.js +36 -32
- package/test/unit/spec/lib/webex-plugin.js +1 -1
- package/test/unit/spec/services/interceptors/server-error.js +67 -90
- package/test/unit/spec/services/interceptors/service.js +17 -28
- package/test/unit/spec/services/service-catalog.js +19 -27
- package/test/unit/spec/services/service-host.js +29 -26
- package/test/unit/spec/services/service-registry.js +128 -170
- package/test/unit/spec/services/service-state.js +13 -22
- package/test/unit/spec/services/service-url.js +24 -43
- package/test/unit/spec/services/services.js +85 -41
- package/test/unit/spec/storage/persist.js +6 -9
- package/test/unit/spec/storage/wait-for-value.js +22 -21
- package/test/unit/spec/webex-core.js +78 -57
- package/test/unit/spec/webex-internal-core.js +56 -31
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["maxAppLevelRedirects","maxLocusRedirects","maxAuthenticationReplays","maxReconnectAttempts","onBeforeLogout","trackingIdPrefix","trackingIdSuffix","AlternateLogger","undefined","credentials","CredentialsConfig","fedramp","process","env","ENABLE_FEDRAMP","services","discovery","hydra","HYDRA_SERVICE_URL","u2c","U2C_SERVICE_URL","validateDomains","servicesNotNeedValidation","allowedDomains","device","preDiscoveryServices","hydraServiceUrl","metrics","type","payloadTransformer","predicates","transforms","storage","boundedAdapter","MemoryStoreAdapter","unboundedAdapter"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint camelcase: [0] */\n\nimport {MemoryStoreAdapter} from './lib/storage';\nimport CredentialsConfig from './credentials-config';\n\nexport default {\n maxAppLevelRedirects: 10,\n maxLocusRedirects: 5,\n maxAuthenticationReplays: 1,\n maxReconnectAttempts: 1,\n onBeforeLogout: [],\n trackingIdPrefix: 'webex-js-sdk',\n trackingIdSuffix: '',\n AlternateLogger: undefined,\n credentials: new CredentialsConfig(),\n fedramp: process.env.ENABLE_FEDRAMP || false,\n services: {\n /**\n * A list of services that are available prior to catalog collection.\n *\n * @type {Object}\n */\n discovery: {\n /**\n * The hydra discovery url.\n *\n * @type {string}\n */\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n\n /**\n * The u2c discovery url\n *\n * @type {string}\n */\n u2c: process.env.U2C_SERVICE_URL || 'https://u2c.wbx2.com/u2c/api/v1'
|
|
1
|
+
{"version":3,"names":["maxAppLevelRedirects","maxLocusRedirects","maxAuthenticationReplays","maxReconnectAttempts","onBeforeLogout","trackingIdPrefix","trackingIdSuffix","AlternateLogger","undefined","credentials","CredentialsConfig","fedramp","process","env","ENABLE_FEDRAMP","services","discovery","hydra","HYDRA_SERVICE_URL","u2c","U2C_SERVICE_URL","validateDomains","servicesNotNeedValidation","allowedDomains","device","preDiscoveryServices","hydraServiceUrl","metrics","type","payloadTransformer","predicates","transforms","storage","boundedAdapter","MemoryStoreAdapter","unboundedAdapter"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint camelcase: [0] */\n\nimport {MemoryStoreAdapter} from './lib/storage';\nimport CredentialsConfig from './credentials-config';\n\nexport default {\n maxAppLevelRedirects: 10,\n maxLocusRedirects: 5,\n maxAuthenticationReplays: 1,\n maxReconnectAttempts: 1,\n onBeforeLogout: [],\n trackingIdPrefix: 'webex-js-sdk',\n trackingIdSuffix: '',\n AlternateLogger: undefined,\n credentials: new CredentialsConfig(),\n fedramp: process.env.ENABLE_FEDRAMP || false,\n services: {\n /**\n * A list of services that are available prior to catalog collection.\n *\n * @type {Object}\n */\n discovery: {\n /**\n * The hydra discovery url.\n *\n * @type {string}\n */\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n\n /**\n * The u2c discovery url\n *\n * @type {string}\n */\n u2c: process.env.U2C_SERVICE_URL || 'https://u2c.wbx2.com/u2c/api/v1',\n },\n\n /**\n * When true, considers all urls in `allowedDomains` as safe for auth tokens\n *\n * @type {boolean}\n */\n validateDomains: true,\n\n /**\n * services that don't need auth validation\n */\n\n servicesNotNeedValidation: ['webex-appapi-service'],\n\n /**\n * Contains a list of allowed domain host addresses.\n *\n * @type {Array<string>}\n */\n allowedDomains: [\n 'wbx2.com',\n 'ciscospark.com',\n 'webex.com',\n 'webexapis.com',\n 'broadcloudpbx.com',\n 'broadcloud.eu',\n 'broadcloud.com.au',\n 'broadcloudpbx.net',\n ],\n },\n device: {\n preDiscoveryServices: {\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n hydraServiceUrl: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n },\n validateDomains: true,\n },\n metrics: {\n type: ['behavioral', 'operational'],\n },\n payloadTransformer: {\n predicates: [],\n transforms: [],\n },\n storage: {\n boundedAdapter: MemoryStoreAdapter,\n unboundedAdapter: MemoryStoreAdapter,\n },\n};\n"],"mappings":";;;;;;;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;;AAEA;eAKe;EACbA,oBAAoB,EAAE,EADT;EAEbC,iBAAiB,EAAE,CAFN;EAGbC,wBAAwB,EAAE,CAHb;EAIbC,oBAAoB,EAAE,CAJT;EAKbC,cAAc,EAAE,EALH;EAMbC,gBAAgB,EAAE,cANL;EAObC,gBAAgB,EAAE,EAPL;EAQbC,eAAe,EAAEC,SARJ;EASbC,WAAW,EAAE,IAAIC,0BAAJ,EATA;EAUbC,OAAO,EAAEC,OAAO,CAACC,GAAR,CAAYC,cAAZ,IAA8B,KAV1B;EAWbC,QAAQ,EAAE;IACR;AACJ;AACA;AACA;AACA;IACIC,SAAS,EAAE;MACT;AACN;AACA;AACA;AACA;MACMC,KAAK,EAAEL,OAAO,CAACC,GAAR,CAAYK,iBAAZ,IAAiC,+BAN/B;;MAQT;AACN;AACA;AACA;AACA;MACMC,GAAG,EAAEP,OAAO,CAACC,GAAR,CAAYO,eAAZ,IAA+B;IAb3B,CANH;;IAsBR;AACJ;AACA;AACA;AACA;IACIC,eAAe,EAAE,IA3BT;;IA6BR;AACJ;AACA;IAEIC,yBAAyB,EAAE,CAAC,sBAAD,CAjCnB;;IAmCR;AACJ;AACA;AACA;AACA;IACIC,cAAc,EAAE,CACd,UADc,EAEd,gBAFc,EAGd,WAHc,EAId,eAJc,EAKd,mBALc,EAMd,eANc,EAOd,mBAPc,EAQd,mBARc;EAxCR,CAXG;EA8DbC,MAAM,EAAE;IACNC,oBAAoB,EAAE;MACpBR,KAAK,EAAEL,OAAO,CAACC,GAAR,CAAYK,iBAAZ,IAAiC,+BADpB;MAEpBQ,eAAe,EAAEd,OAAO,CAACC,GAAR,CAAYK,iBAAZ,IAAiC;IAF9B,CADhB;IAKNG,eAAe,EAAE;EALX,CA9DK;EAqEbM,OAAO,EAAE;IACPC,IAAI,EAAE,CAAC,YAAD,EAAe,aAAf;EADC,CArEI;EAwEbC,kBAAkB,EAAE;IAClBC,UAAU,EAAE,EADM;IAElBC,UAAU,EAAE;EAFM,CAxEP;EA4EbC,OAAO,EAAE;IACPC,cAAc,EAAEC,2BADT;IAEPC,gBAAgB,EAAED;EAFX;AA5EI,C"}
|
|
@@ -40,10 +40,10 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
40
40
|
}],
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
* This is the authorization url displayed on the
|
|
44
|
+
* {@link developer portal|https://developer.webex.com}
|
|
45
|
+
* @type {string}
|
|
46
|
+
*/
|
|
47
47
|
authorizationString: ['string', false, process.env.WEBEX_AUTHORIZATION_STRING || process.env.AUTHORIZATION_STRING],
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -56,42 +56,42 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
56
56
|
authorizeUrl: ['string', false, process.env.WEBEX_AUTHORIZE_URL || "".concat(process.env.IDBROKER_BASE_URL || 'https://idbroker.webex.com', "/idb/oauth2/v1/authorize")],
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
* {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}
|
|
60
|
+
* @type {string}
|
|
61
|
+
*/
|
|
62
62
|
client_id: ['string', false, process.env.WEBEX_CLIENT_ID || process.env.COMMON_IDENTITY_CLIENT_ID || process.env.CLIENT_ID],
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
* {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}
|
|
66
|
+
* @type {string}
|
|
67
|
+
*/
|
|
68
68
|
client_secret: ['string', false, process.env.WEBEX_CLIENT_SECRET || process.env.COMMON_IDENTITY_CLIENT_SECRET || process.env.CLIENT_SECRET],
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
* {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}
|
|
72
|
+
* @type {string}
|
|
73
|
+
*/
|
|
74
74
|
redirect_uri: ['string', false, process.env.WEBEX_REDIRECT_URI || process.env.COMMON_IDENTITY_REDIRECT_URI || process.env.REDIRECT_URI],
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
* {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}
|
|
78
|
+
* @type {string}
|
|
79
|
+
*/
|
|
80
80
|
scope: ['string', false, process.env.WEBEX_SCOPE || process.env.WEBEX_SCOPES || process.env.COMMON_IDENTITY_SCOPE || process.env.SCOPE],
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
* Controls the UI of the CI login page.
|
|
84
|
+
* @private
|
|
85
|
+
* @type {string}
|
|
86
|
+
*/
|
|
87
87
|
cisService: ['string', false, 'webex']
|
|
88
88
|
},
|
|
89
89
|
derived: {
|
|
90
90
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
* User activation URL
|
|
92
|
+
* {@link config.credentials.activationUrl}
|
|
93
|
+
* @type {string}
|
|
94
|
+
*/
|
|
95
95
|
activationUrl: {
|
|
96
96
|
deps: ['idbroker.url'],
|
|
97
97
|
fn: function fn() {
|
|
@@ -101,10 +101,10 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
101
101
|
},
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
* Generate OTP URL
|
|
105
|
+
* {@link config.credentials.generateOtpUrl}
|
|
106
|
+
* @type {string}
|
|
107
|
+
*/
|
|
108
108
|
generateOtpUrl: {
|
|
109
109
|
deps: ['idbroker.url'],
|
|
110
110
|
fn: function fn() {
|
|
@@ -114,10 +114,10 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
114
114
|
},
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
* Validate OTP URL
|
|
118
|
+
* {@link config.credentials.validateOtpUrl}
|
|
119
|
+
* @type {string}
|
|
120
|
+
*/
|
|
121
121
|
validateOtpUrl: {
|
|
122
122
|
deps: ['idbroker.url'],
|
|
123
123
|
fn: function fn() {
|
|
@@ -128,9 +128,9 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
128
128
|
// TODO does hydra also have an access_token endpoint?
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
* Token URL used for token refresh and auth code exchange
|
|
132
|
+
* @type {string}
|
|
133
|
+
*/
|
|
134
134
|
tokenUrl: {
|
|
135
135
|
deps: ['idbroker.url'],
|
|
136
136
|
fn: function fn() {
|
|
@@ -140,9 +140,9 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
140
140
|
},
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
* URL to revoke token
|
|
144
|
+
* @type {string}
|
|
145
|
+
*/
|
|
146
146
|
revokeUrl: {
|
|
147
147
|
deps: ['idbroker.url'],
|
|
148
148
|
fn: function fn() {
|
|
@@ -152,9 +152,9 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
152
152
|
},
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
* URL to load when the app logs out
|
|
156
|
+
* @type {string}
|
|
157
|
+
*/
|
|
158
158
|
logoutUrl: {
|
|
159
159
|
deps: ['idbroker.url'],
|
|
160
160
|
fn: function fn() {
|
|
@@ -164,9 +164,9 @@ var CredentialsConfig = _ampersandState.default.extend({
|
|
|
164
164
|
},
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
* Set password URL
|
|
168
|
+
* @type {string}
|
|
169
|
+
*/
|
|
170
170
|
setPasswordUrl: {
|
|
171
171
|
deps: ['identity.url'],
|
|
172
172
|
fn: function fn() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CredentialsConfig","AmpState","extend","extraProperties","props","idbroker","url","process","env","IDBROKER_BASE_URL","identity","IDENTITY_BASE_URL","authorizationString","WEBEX_AUTHORIZATION_STRING","AUTHORIZATION_STRING","authorizeUrl","WEBEX_AUTHORIZE_URL","client_id","WEBEX_CLIENT_ID","COMMON_IDENTITY_CLIENT_ID","CLIENT_ID","client_secret","WEBEX_CLIENT_SECRET","COMMON_IDENTITY_CLIENT_SECRET","CLIENT_SECRET","redirect_uri","WEBEX_REDIRECT_URI","COMMON_IDENTITY_REDIRECT_URI","REDIRECT_URI","scope","WEBEX_SCOPE","WEBEX_SCOPES","COMMON_IDENTITY_SCOPE","SCOPE","cisService","derived","activationUrl","deps","fn","cache","generateOtpUrl","validateOtpUrl","tokenUrl","TOKEN_URL","revokeUrl","REVOKE_URL","logoutUrl","setPasswordUrl"],"sources":["credentials-config.js"],"sourcesContent":["import AmpState from 'ampersand-state';\n\n// The credentials config which includes the CI server info and derived\n// URL properties from them for the various CI services. The URL's\n// will be updated when the CI changes.\nconst CredentialsConfig = AmpState.extend({\n
|
|
1
|
+
{"version":3,"names":["CredentialsConfig","AmpState","extend","extraProperties","props","idbroker","url","process","env","IDBROKER_BASE_URL","identity","IDENTITY_BASE_URL","authorizationString","WEBEX_AUTHORIZATION_STRING","AUTHORIZATION_STRING","authorizeUrl","WEBEX_AUTHORIZE_URL","client_id","WEBEX_CLIENT_ID","COMMON_IDENTITY_CLIENT_ID","CLIENT_ID","client_secret","WEBEX_CLIENT_SECRET","COMMON_IDENTITY_CLIENT_SECRET","CLIENT_SECRET","redirect_uri","WEBEX_REDIRECT_URI","COMMON_IDENTITY_REDIRECT_URI","REDIRECT_URI","scope","WEBEX_SCOPE","WEBEX_SCOPES","COMMON_IDENTITY_SCOPE","SCOPE","cisService","derived","activationUrl","deps","fn","cache","generateOtpUrl","validateOtpUrl","tokenUrl","TOKEN_URL","revokeUrl","REVOKE_URL","logoutUrl","setPasswordUrl"],"sources":["credentials-config.js"],"sourcesContent":["import AmpState from 'ampersand-state';\n\n// The credentials config which includes the CI server info and derived\n// URL properties from them for the various CI services. The URL's\n// will be updated when the CI changes.\nconst CredentialsConfig = AmpState.extend({\n // we need to allow extra props for dynamic props like jwtRefreshCallback\n extraProperties: 'allow',\n\n props: {\n /**\n * The idbroker base host name\n * @returns {object}\n */\n idbroker: [\n 'object',\n false,\n () => ({\n url: process.env.IDBROKER_BASE_URL || 'https://idbroker.webex.com',\n }),\n ],\n\n /**\n * The identity base host name\n * @returns {object}\n */\n identity: [\n 'object',\n false,\n () => ({\n url: process.env.IDENTITY_BASE_URL || 'https://identity.webex.com',\n }),\n ],\n\n /**\n * This is the authorization url displayed on the\n * {@link developer portal|https://developer.webex.com}\n * @type {string}\n */\n authorizationString: [\n 'string',\n false,\n process.env.WEBEX_AUTHORIZATION_STRING || process.env.AUTHORIZATION_STRING,\n ],\n\n /**\n * Authorization URL which prompts for user's password. Inferred from\n * {@link config.credentials.authorizationString}. This config value will\n * be automatically set if `authorizationString` config value is specified.\n *\n * @type {string}\n */\n authorizeUrl: [\n 'string',\n false,\n process.env.WEBEX_AUTHORIZE_URL ||\n `${process.env.IDBROKER_BASE_URL || 'https://idbroker.webex.com'}/idb/oauth2/v1/authorize`,\n ],\n\n /**\n * {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}\n * @type {string}\n */\n client_id: [\n 'string',\n false,\n process.env.WEBEX_CLIENT_ID || process.env.COMMON_IDENTITY_CLIENT_ID || process.env.CLIENT_ID,\n ],\n\n /**\n * {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}\n * @type {string}\n */\n client_secret: [\n 'string',\n false,\n process.env.WEBEX_CLIENT_SECRET ||\n process.env.COMMON_IDENTITY_CLIENT_SECRET ||\n process.env.CLIENT_SECRET,\n ],\n\n /**\n * {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}\n * @type {string}\n */\n redirect_uri: [\n 'string',\n false,\n process.env.WEBEX_REDIRECT_URI ||\n process.env.COMMON_IDENTITY_REDIRECT_URI ||\n process.env.REDIRECT_URI,\n ],\n\n /**\n * {@see https://tools.ietf.org/html/rfc6749#section-4.1.4}\n * @type {string}\n */\n scope: [\n 'string',\n false,\n process.env.WEBEX_SCOPE ||\n process.env.WEBEX_SCOPES ||\n process.env.COMMON_IDENTITY_SCOPE ||\n process.env.SCOPE,\n ],\n\n /**\n * Controls the UI of the CI login page.\n * @private\n * @type {string}\n */\n cisService: ['string', false, 'webex'],\n },\n\n derived: {\n /**\n * User activation URL\n * {@link config.credentials.activationUrl}\n * @type {string}\n */\n activationUrl: {\n deps: ['idbroker.url'],\n fn() {\n return `${\n this.idbroker.url || 'https://idbroker.webex.com'\n }/idb/token/v1/actions/UserActivation/invoke`;\n },\n cache: false,\n },\n\n /**\n * Generate OTP URL\n * {@link config.credentials.generateOtpUrl}\n * @type {string}\n */\n generateOtpUrl: {\n deps: ['idbroker.url'],\n fn() {\n return `${\n this.idbroker.url || 'https://idbroker.webex.com'\n }/idb/token/v1/actions/UserOTP/Generate/invoke`;\n },\n cache: false,\n },\n\n /**\n * Validate OTP URL\n * {@link config.credentials.validateOtpUrl}\n * @type {string}\n */\n validateOtpUrl: {\n deps: ['idbroker.url'],\n fn() {\n return `${\n this.idbroker.url || 'https://idbroker.webex.com'\n }/idb/token/v1/actions/UserOTP/Validate/invoke`;\n },\n cache: false,\n },\n\n // TODO does hydra also have an access_token endpoint?\n /**\n * Token URL used for token refresh and auth code exchange\n * @type {string}\n */\n tokenUrl: {\n deps: ['idbroker.url'],\n fn() {\n return process.env.TOKEN_URL || `${this.idbroker.url}/idb/oauth2/v1/access_token`;\n },\n cache: false,\n },\n\n /**\n * URL to revoke token\n * @type {string}\n */\n revokeUrl: {\n deps: ['idbroker.url'],\n fn() {\n return process.env.REVOKE_URL || `${this.idbroker.url}/idb/oauth2/v1/revoke`;\n },\n cache: false,\n },\n\n /**\n * URL to load when the app logs out\n * @type {string}\n */\n logoutUrl: {\n deps: ['idbroker.url'],\n fn() {\n return `${this.idbroker.url}/idb/oauth2/v1/logout`;\n },\n cache: false,\n },\n\n /**\n * Set password URL\n * @type {string}\n */\n setPasswordUrl: {\n deps: ['identity.url'],\n fn() {\n return `${this.identity.url || 'https://identity.webex.com'}/identity/scim/v1/Users`;\n },\n cache: false,\n },\n },\n});\n\nexport default CredentialsConfig;\n"],"mappings":";;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA,IAAMA,iBAAiB,GAAGC,uBAAA,CAASC,MAAT,CAAgB;EACxC;EACAC,eAAe,EAAE,OAFuB;EAIxCC,KAAK,EAAE;IACL;AACJ;AACA;AACA;IACIC,QAAQ,EAAE,CACR,QADQ,EAER,KAFQ,EAGR;MAAA,OAAO;QACLC,GAAG,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gBAEJ;QACH,OAAO/B,OAAO,CAACC,GAAR,CAAYqC,UAAZ,cAA6B,KAAKxC,QAAL,CAAcC,GAA3C,0BAAP;MACD,CAJQ;MAKTiC,KAAK,EAAE;IALE,CA/DJ;;IAuEP;AACJ;AACA;AACA;IACIO,SAAS,EAAE;MACTT,IAAI,EAAE,CAAC,cAAD,CADG;MAETC,EAFS,gBAEJ;QACH,iBAAU,KAAKjC,QAAL,CAAcC,GAAxB;MACD,CAJQ;MAKTiC,KAAK,EAAE;IALE,CA3EJ;;IAmFP;AACJ;AACA;AACA;IACIQ,cAAc,EAAE;MACdV,IAAI,EAAE,CAAC,cAAD,CADQ;MAEdC,EAFc,gBAET;QACH,iBAAU,KAAK5B,QAAL,CAAcJ,GAAd,IAAqB,4BAA/B;MACD,CAJa;MAKdiC,KAAK,EAAE;IALO;EAvFT;AA7G+B,CAAhB,CAA1B;;eA8MevC,iB"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n *\n * Services is currently a part of webex-core due to how the contents of\n * the original internal-plugin-services needed to be accessed when webex-core\n * is initialized. As a plugin outside of webex-core, it would initialize after\n * credentials, causing all requests prior to its initialization to fail\n * federation requirements, and instead send requests to the environmentally-\n * assigned urls.\n */\n\nimport './plugins/logger';\nimport './lib/credentials';\nimport './lib/services';\n\nexport {
|
|
1
|
+
{"version":3,"names":[],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n *\n * Services is currently a part of webex-core due to how the contents of\n * the original internal-plugin-services needed to be accessed when webex-core\n * is initialized. As a plugin outside of webex-core, it would initialize after\n * credentials, causing all requests prior to its initialization to fail\n * federation requirements, and instead send requests to the environmentally-\n * assigned urls.\n */\n\nimport './plugins/logger';\nimport './lib/credentials';\nimport './lib/services';\n\nexport {Credentials, filterScope, grantErrors, sortScope, Token} from './lib/credentials';\n\nexport {\n constants as serviceConstants,\n ServiceCatalog,\n ServiceRegistry,\n ServiceState,\n ServiceInterceptor,\n ServerErrorInterceptor,\n Services,\n ServiceHost,\n ServiceUrl,\n} from './lib/services';\n\nexport {\n makeWebexStore,\n makeWebexPluginStore,\n MemoryStoreAdapter,\n NotFoundError,\n persist,\n StorageError,\n waitForValue,\n} from './lib/storage';\n\nexport {default, registerPlugin, registerInternalPlugin} from './webex-core';\n\nexport {default as WebexHttpError} from './lib/webex-http-error';\nexport {default as StatelessWebexPlugin} from './lib/stateless-webex-plugin';\nexport {default as WebexPlugin} from './lib/webex-plugin';\nexport {default as AuthInterceptor} from './interceptors/auth';\nexport {default as NetworkTimingInterceptor} from './interceptors/network-timing';\nexport {default as PayloadTransformerInterceptor} from './interceptors/payload-transformer';\nexport {default as RedirectInterceptor} from './interceptors/redirect';\nexport {default as ResponseLoggerInterceptor} from './interceptors/response-logger';\nexport {default as RequestEventInterceptor} from './interceptors/request-event';\nexport {default as RequestLoggerInterceptor} from './interceptors/request-logger';\nexport {default as RequestTimingInterceptor} from './interceptors/request-timing';\nexport {default as UserAgentInterceptor} from './interceptors/user-agent';\nexport {default as WebexTrackingIdInterceptor} from './interceptors/webex-tracking-id';\nexport {default as WebexUserAgentInterceptor} from './interceptors/webex-user-agent';\nexport {default as RateLimitInterceptor} from './interceptors/rate-limit';\nexport {default as EmbargoInterceptor} from './interceptors/embargo';\nexport {default as DefaultOptionsInterceptor} from './interceptors/default-options';\n\nexport {default as Batcher} from './lib/batcher';\nexport {default as Page} from './lib/page';\nexport {default as config} from './config';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;AACA;;AACA;;AAgBA;;AAUA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AuthInterceptor","options","headers","authorization","resolve","requiresCredentials","then","requires","webex","credentials","getUserToken","token","toString","addAuthHeader","internal","services","details","getServiceFromUrl","uri","name","resource","service","api","includes","validateDomains","hasAllowedDomains","isAllowedDomainUrl","waitForService","url","detectedUrl","catch","error","logger","warn","reason","shouldAttemptReauth","info","canRefresh","refresh","replay","reject","replayCount","config","maxAuthenticationReplays","Error","request","shouldRefreshAccessToken","statusCode","Interceptor"],"sources":["auth.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class AuthInterceptor extends Interceptor {\n /**\n * @returns {AuthInterceptor}\n */\n static create() {\n return new AuthInterceptor({webex: this});\n }\n\n /**\n * @see {@link Interceptor#onRequest}\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n options.headers = options.headers || {};\n\n // If Authorizations is already set, don't overwrite it\n if ('authorization' in options.headers || 'auth' in options) {\n // If Authorization is set to null, false, or undefined, delete it to\n // prevent a CORS preflight.\n if (!options.headers.authorization) {\n Reflect.deleteProperty(options.headers, 'authorization');\n }\n\n return Promise.resolve(options);\n }\n\n return this.requiresCredentials(options)
|
|
1
|
+
{"version":3,"names":["AuthInterceptor","options","headers","authorization","resolve","requiresCredentials","then","requires","webex","credentials","getUserToken","token","toString","addAuthHeader","internal","services","details","getServiceFromUrl","uri","name","resource","service","api","includes","validateDomains","hasAllowedDomains","isAllowedDomainUrl","waitForService","url","detectedUrl","catch","error","logger","warn","reason","shouldAttemptReauth","info","canRefresh","refresh","replay","reject","replayCount","config","maxAuthenticationReplays","Error","request","shouldRefreshAccessToken","statusCode","Interceptor"],"sources":["auth.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class AuthInterceptor extends Interceptor {\n /**\n * @returns {AuthInterceptor}\n */\n static create() {\n return new AuthInterceptor({webex: this});\n }\n\n /**\n * @see {@link Interceptor#onRequest}\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n options.headers = options.headers || {};\n\n // If Authorizations is already set, don't overwrite it\n if ('authorization' in options.headers || 'auth' in options) {\n // If Authorization is set to null, false, or undefined, delete it to\n // prevent a CORS preflight.\n if (!options.headers.authorization) {\n Reflect.deleteProperty(options.headers, 'authorization');\n }\n\n return Promise.resolve(options);\n }\n\n return this.requiresCredentials(options).then((requires) => {\n if (!requires) {\n return options;\n }\n\n return this.webex.credentials.getUserToken().then((token) => {\n options.headers.authorization = token.toString();\n\n return options;\n });\n });\n }\n\n /**\n * Determines if the provided options object needs an authorization header.\n *\n * @param {Object} options\n * @returns {Promise<boolean>}\n */\n requiresCredentials(options) {\n // Validate that authorization is necessary.\n if (options.addAuthHeader === false) {\n return Promise.resolve(false);\n }\n\n // Validate that the services plugin has been loaded before proceeding.\n if (!this.webex.internal.services) {\n return Promise.resolve(false);\n }\n\n // Destructure webex instance to isolate services plugin.\n const {services} = this.webex.internal;\n\n // Store the current service details if available and destructure details.\n const details = services.getServiceFromUrl(options.uri || '');\n const {name} = details || {};\n const {resource, uri} = options;\n const service = options.service || options.api;\n\n // Unique validation for the u2c service.\n if ((service && service === 'u2c') || (name && name === 'u2c')) {\n if ((resource && resource.includes('limited')) || (uri && uri.includes('limited'))) {\n return Promise.resolve(false);\n }\n\n return Promise.resolve(true);\n }\n\n // Validate that the allowed domains can be utilized.\n if (\n services.validateDomains &&\n services.hasAllowedDomains() &&\n uri &&\n services.isAllowedDomainUrl(uri)\n ) {\n return Promise.resolve(true);\n }\n\n // Perform an additional validation in case the service does not exist yet.\n return services\n .waitForService({name: service, url: uri})\n .then((detectedUrl) => {\n // Validate that the url exists in the catalog.\n if (services.getServiceFromUrl(detectedUrl)) {\n return true;\n }\n\n // Return false to indicate authentication is not required.\n return false;\n })\n .catch((error) => {\n this.webex.logger.warn(\n 'auth-interceptor: failed to validate service exists in catalog',\n error\n );\n\n return false;\n });\n }\n\n /**\n * @see {@link Interceptor#onResponseError}\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n return this.shouldAttemptReauth(reason, options).then((shouldAttemptReauth) => {\n if (shouldAttemptReauth) {\n this.webex.logger.info('auth: received 401, attempting to reauthenticate');\n\n if (reason.options.headers) {\n Reflect.deleteProperty(reason.options.headers, 'authorization');\n }\n\n if (this.webex.credentials.canRefresh) {\n return this.webex.credentials.refresh().then(() => this.replay(options));\n }\n }\n\n return Promise.reject(reason);\n });\n }\n\n /**\n * Replays the request\n * @param {Object} options\n * @returns {Object}\n */\n replay(options) {\n if (options.replayCount) {\n options.replayCount += 1;\n } else {\n options.replayCount = 1;\n }\n\n if (options.replayCount > this.webex.config.maxAuthenticationReplays) {\n this.webex.logger.error(\n `auth: failed after ${this.webex.config.maxAuthenticationReplays} replay attempts`\n );\n\n return Promise.reject(\n new Error(`Failed after ${this.webex.config.maxAuthenticationReplays} replay attempts`)\n );\n }\n\n this.webex.logger.info(`auth: replaying request ${options.replayCount} time`);\n\n return this.webex.request(options);\n }\n\n /**\n * Indicates whether or not the current request should refresh its access\n * token in event of a 401\n * @param {Error} reason\n * @param {Object} options\n * @returns {Promise<boolean>}\n */\n shouldAttemptReauth(reason, options) {\n if (options && options.shouldRefreshAccessToken === false) {\n return Promise.resolve(false);\n }\n\n if (reason.statusCode === 401) {\n return Promise.resolve(true);\n }\n\n return Promise.resolve(false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAEA;AACA;AACA;IACqBA,e;;;;;;;;;;;;;IAQnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MAAA;;MACjBA,OAAO,CAACC,OAAR,GAAkBD,OAAO,CAACC,OAAR,IAAmB,EAArC,CADiB,CAGjB;;MACA,IAAI,mBAAmBD,OAAO,CAACC,OAA3B,IAAsC,UAAUD,OAApD,EAA6D;QAC3D;QACA;QACA,IAAI,CAACA,OAAO,CAACC,OAAR,CAAgBC,aAArB,EAAoC;UAClC,6BAAuBF,OAAO,CAACC,OAA/B,EAAwC,eAAxC;QACD;;QAED,OAAO,iBAAQE,OAAR,CAAgBH,OAAhB,CAAP;MACD;;MAED,OAAO,KAAKI,mBAAL,CAAyBJ,OAAzB,EAAkCK,IAAlC,CAAuC,UAACC,QAAD,EAAc;QAC1D,IAAI,CAACA,QAAL,EAAe;UACb,OAAON,OAAP;QACD;;QAED,OAAO,KAAI,CAACO,KAAL,CAAWC,WAAX,CAAuBC,YAAvB,GAAsCJ,IAAtC,CAA2C,UAACK,KAAD,EAAW;UAC3DV,OAAO,CAACC,OAAR,CAAgBC,aAAhB,GAAgCQ,KAAK,CAACC,QAAN,EAAhC;UAEA,OAAOX,OAAP;QACD,CAJM,CAAP;MAKD,CAVM,CAAP;IAWD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,6BAAoBA,OAApB,EAA6B;MAAA;;MAC3B;MACA,IAAIA,OAAO,CAACY,aAAR,KAA0B,KAA9B,EAAqC;QACnC,OAAO,iBAAQT,OAAR,CAAgB,KAAhB,CAAP;MACD,CAJ0B,CAM3B;;;MACA,IAAI,CAAC,KAAKI,KAAL,CAAWM,QAAX,CAAoBC,QAAzB,EAAmC;QACjC,OAAO,iBAAQX,OAAR,C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kBC,wBAA5C,EAAsE;QACpE,KAAKnC,KAAL,CAAWwB,MAAX,CAAkBD,KAAlB,8BACwB,KAAKvB,KAAL,CAAWkC,MAAX,CAAkBC,wBAD1C;QAIA,OAAO,iBAAQH,MAAR,CACL,IAAII,KAAJ,wBAA0B,KAAKpC,KAAL,CAAWkC,MAAX,CAAkBC,wBAA5C,sBADK,CAAP;MAGD;;MAED,KAAKnC,KAAL,CAAWwB,MAAX,CAAkBI,IAAlB,mCAAkDnC,OAAO,CAACwC,WAA1D;MAEA,OAAO,KAAKjC,KAAL,CAAWqC,OAAX,CAAmB5C,OAAnB,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;WACE,6BAAoBiC,MAApB,EAA4BjC,OAA5B,EAAqC;MACnC,IAAIA,OAAO,IAAIA,OAAO,CAAC6C,wBAAR,KAAqC,KAApD,EAA2D;QACzD,OAAO,iBAAQ1C,OAAR,CAAgB,KAAhB,CAAP;MACD;;MAED,IAAI8B,MAAM,CAACa,UAAP,KAAsB,GAA1B,EAA+B;QAC7B,OAAO,iBAAQ3C,OAAR,CAAgB,IAAhB,CAAP;MACD;;MAED,OAAO,iBAAQA,OAAR,CAAgB,KAAhB,CAAP;IACD;;;;IA9KD;AACF;AACA;IACE,kBAAgB;MACd,OAAO,IAAIJ,eAAJ,CAAoB;QAACQ,KAAK,EAAE;MAAR,CAApB,CAAP;IACD;;;EAN0CwC,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DefaultOptionsInterceptor","options","defaultOptions","webex","config","defaultRequestOptions","forEach","key","includes","Interceptor"],"sources":["default-options.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n
|
|
1
|
+
{"version":3,"names":["DefaultOptionsInterceptor","options","defaultOptions","webex","config","defaultRequestOptions","forEach","key","includes","Interceptor"],"sources":["default-options.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * Allows the user of the SDK to set default options that apply every http request made by the SDK\n * For example a default timeout could be set for all requests like this :\n *\n * webex = WebexSdk.init({\n * credentials: {\n * supertoken: superToken\n * },\n * config: {\n * credentials: {\n * client_id,\n * client_secret\n * },\n * defaultRequestOptions: {\n * timeout: 15000\n * }\n * }\n * });\n */\nexport default class DefaultOptionsInterceptor extends Interceptor {\n /**\n * @returns {DefaultOptionsInterceptor}\n */\n static create() {\n return new DefaultOptionsInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const {defaultRequestOptions: defaultOptions} = this.webex.config;\n\n if (!defaultOptions) {\n return options;\n }\n\n Object.keys(defaultOptions).forEach((key) => {\n // don't override any existing option properties\n if (!Object.keys(options).includes(key)) {\n options[key] = defaultOptions[key];\n }\n });\n\n return options;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACqBA,yB;;;;;;;;;;;;;IAQnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MACjB,IAA8BC,cAA9B,GAAgD,KAAKC,KAAL,CAAWC,MAA3D,CAAOC,qBAAP;;MAEA,IAAI,CAACH,cAAL,EAAqB;QACnB,OAAOD,OAAP;MACD;;MAED,mBAAYC,cAAZ,EAA4BI,OAA5B,CAAoC,UAACC,GAAD,EAAS;QAC3C;QACA,IAAI,CAAC,mBAAYN,OAAZ,EAAqBO,QAArB,CAA8BD,GAA9B,CAAL,EAAyC;UACvCN,OAAO,CAACM,GAAD,CAAP,GAAeL,cAAc,CAACK,GAAD,CAA7B;QACD;MACF,CALD;MAOA,OAAON,OAAP;IACD;;;;IA3BD;AACF;AACA;IACE,kBAAgB;MACd,OAAO,IAAID,yBAAJ,CAA8B;QAACG,KAAK,EAAE;MAAR,CAA9B,CAAP;IACD;;;EANoDM,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EmbargoInterceptor","options","reason","statusCode","device","webex","internal","loggerMessage","join","clear","credentials","logger","info","reject","Interceptor"],"sources":["embargo.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class EmbargoInterceptor extends Interceptor {\n /**\n * @returns {EmbargoInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new EmbargoInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onResponseError\n * @param {Object} options\n * @param {Error} reason\n * @returns {Promise}\n */\n onResponseError(options, reason) {\n if (reason.statusCode === 451) {\n const {device} = this.webex.internal;\n const loggerMessage = [\n 'Received `HTTP 451 Unavailable For Legal Reasons`, ',\n 'discarding credentials and device registration'
|
|
1
|
+
{"version":3,"names":["EmbargoInterceptor","options","reason","statusCode","device","webex","internal","loggerMessage","join","clear","credentials","logger","info","reject","Interceptor"],"sources":["embargo.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class EmbargoInterceptor extends Interceptor {\n /**\n * @returns {EmbargoInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new EmbargoInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onResponseError\n * @param {Object} options\n * @param {Error} reason\n * @returns {Promise}\n */\n onResponseError(options, reason) {\n if (reason.statusCode === 451) {\n const {device} = this.webex.internal;\n const loggerMessage = [\n 'Received `HTTP 451 Unavailable For Legal Reasons`, ',\n 'discarding credentials and device registration',\n ].join('');\n\n if (device) {\n this.webex.internal.device.clear();\n }\n\n this.webex.credentials.clear();\n this.webex.logger.info(loggerMessage);\n }\n\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAEA;AACA;AACA;IACqBA,kB;;;;;;;;;;;;;IASnB;AACF;AACA;AACA;AACA;AACA;IACE,yBAAgBC,OAAhB,EAAyBC,MAAzB,EAAiC;MAC/B,IAAIA,MAAM,CAACC,UAAP,KAAsB,GAA1B,EAA+B;QAC7B,IAAOC,MAAP,GAAiB,KAAKC,KAAL,CAAWC,QAA5B,CAAOF,MAAP;QACA,IAAMG,aAAa,GAAG,CACpB,qDADoB,EAEpB,gDAFoB,EAGpBC,IAHoB,CAGf,EAHe,CAAtB;;QAKA,IAAIJ,MAAJ,EAAY;UACV,KAAKC,KAAL,CAAWC,QAAX,CAAoBF,MAApB,CAA2BK,KAA3B;QACD;;QAED,KAAKJ,KAAL,CAAWK,WAAX,CAAuBD,KAAvB;QACA,KAAKJ,KAAL,CAAWM,MAAX,CAAkBC,IAAlB,CAAuBL,aAAvB;MACD;;MAED,OAAO,iBAAQM,MAAR,CAAeX,MAAf,CAAP;IACD;;;;IA/BD;AACF;AACA;IACE,kBAAgB;MACd;MACA,OAAO,IAAIF,kBAAJ,CAAuB;QAACK,KAAK,EAAE;MAAR,CAAvB,CAAP;IACD;;;EAP6CS,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PayloadTransformerInterceptor","options","noTransform","webex","transform","response","disableTransform","reason","then","r","reject","Interceptor"],"sources":["payload-transformer.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class PayloadTransformerInterceptor extends Interceptor {\n /**\n * @param {Object} options\n * @returns {PayloadTransformerInterceptor}\n */\n static create() {\n return new PayloadTransformerInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n if (options.noTransform) {\n return options;\n }\n\n return this.webex.transform('outbound', options);\n }\n\n /**\n * @see Interceptor#onResponse\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n if (options.disableTransform) {\n return response;\n }\n\n return this.webex.transform('inbound', response);\n }\n\n /**\n * @see Interceptor#onResponseError\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n return this.webex.transform('inbound', reason)
|
|
1
|
+
{"version":3,"names":["PayloadTransformerInterceptor","options","noTransform","webex","transform","response","disableTransform","reason","then","r","reject","Interceptor"],"sources":["payload-transformer.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class PayloadTransformerInterceptor extends Interceptor {\n /**\n * @param {Object} options\n * @returns {PayloadTransformerInterceptor}\n */\n static create() {\n return new PayloadTransformerInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n if (options.noTransform) {\n return options;\n }\n\n return this.webex.transform('outbound', options);\n }\n\n /**\n * @see Interceptor#onResponse\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n if (options.disableTransform) {\n return response;\n }\n\n return this.webex.transform('inbound', response);\n }\n\n /**\n * @see Interceptor#onResponseError\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n return this.webex.transform('inbound', reason).then((r) => Promise.reject(r || reason));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAEA;AACA;AACA;IACqBA,6B;;;;;;;;;;;;;IASnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MACjB,IAAIA,OAAO,CAACC,WAAZ,EAAyB;QACvB,OAAOD,OAAP;MACD;;MAED,OAAO,KAAKE,KAAL,CAAWC,SAAX,CAAqB,UAArB,EAAiCH,OAAjC,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,oBAAWA,OAAX,EAAoBI,QAApB,EAA8B;MAC5B,IAAIJ,OAAO,CAACK,gBAAZ,EAA8B;QAC5B,OAAOD,QAAP;MACD;;MAED,OAAO,KAAKF,KAAL,CAAWC,SAAX,CAAqB,SAArB,EAAgCC,QAAhC,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,yBAAgBJ,OAAhB,EAAyBM,MAAzB,EAAiC;MAC/B,OAAO,KAAKJ,KAAL,CAAWC,SAAX,CAAqB,SAArB,EAAgCG,MAAhC,EAAwCC,IAAxC,CAA6C,UAACC,CAAD;QAAA,OAAO,iBAAQC,MAAR,CAAeD,CAAC,IAAIF,MAApB,CAAP;MAAA,CAA7C,CAAP;IACD;;;;IA3CD;AACF;AACA;AACA;IACE,kBAAgB;MACd,OAAO,IAAIP,6BAAJ,CAAkC;QAACG,KAAK,EAAE;MAAR,CAAlC,CAAP;IACD;;;EAPwDQ,qB"}
|
|
@@ -51,10 +51,10 @@ var RateLimitInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
|
51
51
|
var _super = _createSuper(RateLimitInterceptor);
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
* constructor
|
|
55
|
+
* @param {mixed} args
|
|
56
|
+
* @returns {Exception}
|
|
57
|
+
*/
|
|
58
58
|
function RateLimitInterceptor() {
|
|
59
59
|
var _this;
|
|
60
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["rateLimitExpiryTime","idBrokerRegex","RateLimitInterceptor","args","set","options","isRateLimited","uri","reject","Error","resolve","reason","statusCode","includes","setRateLimitExpiry","extractRetryAfterTime","milliMultiplier","retryAfter","headers","apiName","getApiName","currTimeMilli","Date","getTime","expiry","dict","get","expiryTime","undefined","results","match","getRateLimitStatus","webex","Interceptor"],"sources":["rate-limit.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n// contains the system time in milliseconds at which the retry after associated with a 429 expires\n// mapped by the API name, e.g.: idbroker.webex.com/doStuff would be mapped as 'doStuff'\nconst rateLimitExpiryTime = new WeakMap();\n\n// extracts the common identity API being called\nconst idBrokerRegex = /.*(idbroker|identity)(bts)?.ciscospark.com\\/([^/]+)/;\n\n/**\n * @class\n */\nexport default class RateLimitInterceptor extends Interceptor {\n /**\n * @returns {RateLimitInterceptor}\n */\n static create() {\n return new RateLimitInterceptor({webex: this});\n }\n\n /**\n
|
|
1
|
+
{"version":3,"names":["rateLimitExpiryTime","idBrokerRegex","RateLimitInterceptor","args","set","options","isRateLimited","uri","reject","Error","resolve","reason","statusCode","includes","setRateLimitExpiry","extractRetryAfterTime","milliMultiplier","retryAfter","headers","apiName","getApiName","currTimeMilli","Date","getTime","expiry","dict","get","expiryTime","undefined","results","match","getRateLimitStatus","webex","Interceptor"],"sources":["rate-limit.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\n// contains the system time in milliseconds at which the retry after associated with a 429 expires\n// mapped by the API name, e.g.: idbroker.webex.com/doStuff would be mapped as 'doStuff'\nconst rateLimitExpiryTime = new WeakMap();\n\n// extracts the common identity API being called\nconst idBrokerRegex = /.*(idbroker|identity)(bts)?.ciscospark.com\\/([^/]+)/;\n\n/**\n * @class\n */\nexport default class RateLimitInterceptor extends Interceptor {\n /**\n * @returns {RateLimitInterceptor}\n */\n static create() {\n return new RateLimitInterceptor({webex: this});\n }\n\n /**\n * constructor\n * @param {mixed} args\n * @returns {Exception}\n */\n constructor(...args) {\n super(...args);\n rateLimitExpiryTime.set(this, new Map());\n }\n\n /**\n * @see {@link Interceptor#onRequest}\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n if (this.isRateLimited(options.uri)) {\n return Promise.reject(new Error(`API rate limited ${options.uri}`));\n }\n\n return Promise.resolve(options);\n }\n\n /**\n * @see {@link Interceptor#onResponseError}\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n if (\n reason.statusCode === 429 &&\n (options.uri.includes('idbroker') || options.uri.includes('identity'))\n ) {\n // set the retry after in the map, setting to milliseconds\n this.setRateLimitExpiry(options.uri, this.extractRetryAfterTime(options));\n }\n\n return Promise.reject(reason);\n }\n\n /**\n * @param {object} options associated with the request\n * @returns {number} retry after time in milliseconds\n */\n extractRetryAfterTime(options) {\n // 1S * 1K === 1MS\n const milliMultiplier = 1000;\n const retryAfter = options.headers['retry-after'] || null;\n\n // set 60 retry if no usable time defined\n if (retryAfter === null || retryAfter <= 0) {\n return 60 * milliMultiplier;\n }\n // set max to 3600 S (1 hour) if greater than 1 hour\n if (retryAfter > 3600) {\n return 3600 * milliMultiplier;\n }\n\n return retryAfter * milliMultiplier;\n }\n\n /**\n * Set the system time at which the rate limiting\n * will expire in the rateLimitExpiryTime map.\n * Assumes retryAfter is in milliseconds\n * @param {string} uri API issuing the rate limiting\n * @param {number} retryAfter milliseconds until rate limiting expires\n * @returns {bool} true is value was successfully set\n */\n setRateLimitExpiry(uri, retryAfter) {\n const apiName = this.getApiName(uri);\n\n if (!apiName) {\n return false;\n }\n\n const currTimeMilli = new Date().getTime();\n const expiry = currTimeMilli + retryAfter;\n const dict = rateLimitExpiryTime.get(this);\n\n return dict.set(apiName, expiry);\n }\n\n /**\n * returns true if the API is currently rate limited\n * @param {string} uri\n * @returns {Boolean} indicates whether or not the API is rate currently rate limited\n */\n getRateLimitStatus(uri) {\n const apiName = this.getApiName(uri);\n\n if (!apiName) {\n return false;\n }\n\n const currTimeMilli = new Date().getTime();\n const dict = rateLimitExpiryTime.get(this);\n const expiryTime = dict.get(apiName);\n\n // if no rate limit expiry has been registered in the map, return false.\n if (expiryTime === undefined) {\n return false;\n }\n\n // return true, indicating rate limiting, if the system time is less than the expiry time\n return currTimeMilli < dict.get(apiName);\n }\n\n /**\n * split the URI and returns the API name of idBroker\n * @param {string} uri\n * @returns {string}\n */\n getApiName(uri) {\n if (!uri) {\n return null;\n }\n\n const results = uri.match(idBrokerRegex);\n\n if (!results) {\n return null;\n }\n\n // group 0 = full match of URL, group 1 = identity or idbroker base\n // group 2 = api name\n return results[2];\n }\n\n /**\n * check URI against list of currently rate limited\n * URIs, and determines if retry-after\n * @param {String} uri pattern to check\n * @returns {bool}\n */\n isRateLimited(uri) {\n // determine if the URI is associated with a common identity API\n if (uri && (uri.includes('idbroker') || uri.includes('identity'))) {\n return this.getRateLimitStatus(uri);\n }\n\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAEA;AACA;AACA,IAAMA,mBAAmB,GAAG,sBAA5B,C,CAEA;;AACA,IAAMC,aAAa,GAAG,qDAAtB;AAEA;AACA;AACA;;IACqBC,oB;;;;;EAQnB;AACF;AACA;AACA;AACA;EACE,gCAAqB;IAAA;;IAAA;;IAAA,kCAANC,IAAM;MAANA,IAAM;IAAA;;IACnB,gDAASA,IAAT;IACAH,mBAAmB,CAACI,GAApB,8CAA8B,kBAA9B;IAFmB;EAGpB;EAED;AACF;AACA;AACA;AACA;;;;;WACE,mBAAUC,OAAV,EAAmB;MACjB,IAAI,KAAKC,aAAL,CAAmBD,OAAO,CAACE,GAA3B,CAAJ,EAAqC;QACnC,OAAO,iBAAQC,MAAR,CAAe,IAAIC,KAAJ,4BAA8BJ,OAAO,CAACE,GAAtC,EAAf,CAAP;MACD;;MAED,OAAO,iBAAQG,OAAR,CAAgBL,OAAhB,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,yBAAgBA,OAAhB,EAAyBM,MAAzB,EAAiC;MAC/B,IACEA,MAAM,CAACC,UAAP,KAAs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b,GAAhB,CAAhB;;MAEA,IAAI,CAACY,OAAL,EAAc;QACZ,OAAO,KAAP;MACD;;MAED,IAAME,aAAa,GAAG,IAAIC,IAAJ,GAAWC,OAAX,EAAtB;MACA,IAAME,IAAI,GAAGzB,mBAAmB,CAAC0B,GAApB,CAAwB,IAAxB,CAAb;MACA,IAAMC,UAAU,GAAGF,IAAI,CAACC,GAAL,CAASP,OAAT,CAAnB,CATsB,CAWtB;;MACA,IAAIQ,UAAU,KAAKC,SAAnB,EAA8B;QAC5B,OAAO,KAAP;MACD,CAdqB,CAgBtB;;;MACA,OAAOP,aAAa,GAAGI,IAAI,CAACC,GAAL,CAASP,OAAT,CAAvB;IACD;IAED;AACF;AACA;AACA;AACA;;;;WACE,oBAAWZ,GAAX,EAAgB;MACd,IAAI,CAACA,GAAL,EAAU;QACR,OAAO,IAAP;MACD;;MAED,IAAMsB,OAAO,GAAGtB,GAAG,CAACuB,KAAJ,CAAU7B,aAAV,CAAhB;;MAEA,IAAI,CAAC4B,OAAL,EAAc;QACZ,OAAO,IAAP;MACD,CATa,CAWd;MACA;;;MACA,OAAOA,OAAO,CAAC,CAAD,CAAd;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,uBAActB,GAAd,EAAmB;MACjB;MACA,IAAIA,GAAG,KAAKA,GAAG,CAACM,QAAJ,CAAa,UAAb,KAA4BN,GAAG,CAACM,QAAJ,CAAa,UAAb,CAAjC,CAAP,EAAmE;QACjE,OAAO,KAAKkB,kBAAL,CAAwBxB,GAAxB,CAAP;MACD;;MAED,OAAO,KAAP;IACD;;;;IAtJD;AACF;AACA;IACE,kBAAgB;MACd,OAAO,IAAIL,oBAAJ,CAAyB;QAAC8B,KAAK,EAAE;MAAR,CAAzB,CAAP;IACD;;;EAN+CC,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["requestHeaderName","responseHeaderName","LOCUS_REDIRECT_ERROR","RedirectInterceptor","options","uri","includes","webex","config","credentials","samlUrl","tokenUrl","authorizeUrl","headers","$redirectCount","response","maxAppLevelRedirects","reject","Error","request","body","errorCode","location","logger","warn","qs","newUrl","split","maxLocusRedirects","Interceptor"],"sources":["redirect.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {clone} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\n\nconst requestHeaderName = 'cisco-no-http-redirect';\nconst responseHeaderName = 'cisco-location';\nconst LOCUS_REDIRECT_ERROR = 2000002;\n\n/**\n * @class\n */\nexport default class RedirectInterceptor extends Interceptor {\n /**\n * @returns {RedirectInterceptor}\n */\n static create() {\n return new RedirectInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n if (options && options.uri && typeof options.uri === 'string') {\n if (options.uri.includes('https://idbroker') ||\n options.uri.includes(this.webex.config.credentials.samlUrl) ||\n options.uri.includes(this.webex.config.credentials.tokenUrl) ||\n options.uri.includes(this.webex.config.credentials.authorizeUrl)) {\n return options;\n }\n }\n\n // If cisco-no-http-redirect is already set, don't overwrite it\n if (requestHeaderName in options.headers) {\n // If cisco-no-http-redirect is set to null, false, or undefined, delete\n // it to prevent a CORS preflight.\n if (!options.headers[requestHeaderName]) {\n Reflect.deleteProperty(options.headers, requestHeaderName);\n }\n\n return options;\n }\n options.headers[requestHeaderName] = true;\n options.$redirectCount = options.$redirectCount || 0;\n\n return options;\n }\n\n /**\n * @see Interceptor#onResponse\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n /* eslint-disable no-else-return */\n if (response.headers && response.headers[responseHeaderName]) {\n options = clone(options);\n options.uri = response.headers[responseHeaderName];\n options.$redirectCount += 1;\n if (options.$redirectCount > this.webex.config.maxAppLevelRedirects) {\n return Promise.reject(new Error('Maximum redirects exceeded'));\n }\n\n return this.webex.request(options);\n }
|
|
1
|
+
{"version":3,"names":["requestHeaderName","responseHeaderName","LOCUS_REDIRECT_ERROR","RedirectInterceptor","options","uri","includes","webex","config","credentials","samlUrl","tokenUrl","authorizeUrl","headers","$redirectCount","response","maxAppLevelRedirects","reject","Error","request","body","errorCode","location","logger","warn","qs","newUrl","split","maxLocusRedirects","Interceptor"],"sources":["redirect.js"],"sourcesContent":["/* eslint-disable prefer-destructuring */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {clone} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\n\nconst requestHeaderName = 'cisco-no-http-redirect';\nconst responseHeaderName = 'cisco-location';\nconst LOCUS_REDIRECT_ERROR = 2000002;\n\n/**\n * @class\n */\nexport default class RedirectInterceptor extends Interceptor {\n /**\n * @returns {RedirectInterceptor}\n */\n static create() {\n return new RedirectInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n if (options && options.uri && typeof options.uri === 'string') {\n if (\n options.uri.includes('https://idbroker') ||\n options.uri.includes(this.webex.config.credentials.samlUrl) ||\n options.uri.includes(this.webex.config.credentials.tokenUrl) ||\n options.uri.includes(this.webex.config.credentials.authorizeUrl)\n ) {\n return options;\n }\n }\n\n // If cisco-no-http-redirect is already set, don't overwrite it\n if (requestHeaderName in options.headers) {\n // If cisco-no-http-redirect is set to null, false, or undefined, delete\n // it to prevent a CORS preflight.\n if (!options.headers[requestHeaderName]) {\n Reflect.deleteProperty(options.headers, requestHeaderName);\n }\n\n return options;\n }\n options.headers[requestHeaderName] = true;\n options.$redirectCount = options.$redirectCount || 0;\n\n return options;\n }\n\n /**\n * @see Interceptor#onResponse\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n /* eslint-disable no-else-return */\n if (response.headers && response.headers[responseHeaderName]) {\n options = clone(options);\n options.uri = response.headers[responseHeaderName];\n options.$redirectCount += 1;\n if (options.$redirectCount > this.webex.config.maxAppLevelRedirects) {\n return Promise.reject(new Error('Maximum redirects exceeded'));\n }\n\n return this.webex.request(options);\n } else if (\n response.headers &&\n response.body &&\n response.body.errorCode === LOCUS_REDIRECT_ERROR &&\n response.body.location\n ) {\n options = clone(options);\n\n this.webex.logger.warn('redirect: url redirects needed from', options.uri);\n if (response.options && response.options.qs) {\n // for POST requests\n const newUrl = response.body.location.split('?');\n\n options.uri = newUrl[0]; // params are already present in the qs\n } else {\n // for GET requests\n options.uri = response.body.location;\n }\n\n this.webex.logger.warn('redirect: url redirects needed to', options.uri);\n options.$redirectCount += 1;\n if (options.$redirectCount > this.webex.config.maxLocusRedirects) {\n return Promise.reject(new Error('Maximum redirects exceeded'));\n }\n\n return this.webex.request(options);\n }\n /* eslint-enable no-else-return */\n\n return response;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;;;;;AAEA,IAAMA,iBAAiB,GAAG,wBAA1B;AACA,IAAMC,kBAAkB,GAAG,gBAA3B;AACA,IAAMC,oBAAoB,GAAG,OAA7B;AAEA;AACA;AACA;;IACqBC,mB;;;;;;;;;;;;;IAQnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MACjB,IAAIA,OAAO,IAAIA,OAAO,CAACC,GAAnB,IAA0B,OAAOD,OAAO,CAACC,GAAf,KAAuB,QAArD,EAA+D;QAC7D,IACED,OAAO,CAACC,GAAR,CAAYC,QAAZ,CAAqB,kBAArB,KACAF,OAAO,CAACC,GAAR,CAAYC,QAAZ,CAAqB,KAAKC,KAAL,CAAWC,MAAX,CAAkBC,WAAlB,CAA8BC,OAAnD,CADA,IAEAN,OAAO,CAACC,GAAR,CAAYC,QAAZ,CAAqB,KAAKC,KAAL,CAAWC,MAAX,CAAkBC,WAAlB,CAA8BE,QAAnD,CAFA,IAGAP,OAAO,CAACC,GAAR,CAAYC,QAAZ,CAAqB,KAAKC,KAAL,CAAWC,MAAX,CAAkBC,WAAlB,CAA8BG,YAAnD,CAJF,EAKE;UAC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OAAO,CAACC,GAAtE;;QACA,IAAIU,QAAQ,CAACX,OAAT,IAAoBW,QAAQ,CAACX,OAAT,CAAiBqB,EAAzC,EAA6C;UAC3C;UACA,IAAMC,MAAM,GAAGX,QAAQ,CAACK,IAAT,CAAcE,QAAd,CAAuBK,KAAvB,CAA6B,GAA7B,CAAf;UAEAvB,OAAO,CAACC,GAAR,GAAcqB,MAAM,CAAC,CAAD,CAApB,CAJ2C,CAIlB;QAC1B,CALD,MAKO;UACL;UACAtB,OAAO,CAACC,GAAR,GAAcU,QAAQ,CAACK,IAAT,CAAcE,QAA5B;QACD;;QAED,KAAKf,KAAL,CAAWgB,MAAX,CAAkBC,IAAlB,CAAuB,mCAAvB,EAA4DpB,OAAO,CAACC,GAApE;QACAD,OAAO,CAACU,cAAR,IAA0B,CAA1B;;QACA,IAAIV,OAAO,CAACU,cAAR,GAAyB,KAAKP,KAAL,CAAWC,MAAX,CAAkBoB,iBAA/C,EAAkE;UAChE,OAAO,iBAAQX,MAAR,CAAe,IAAIC,KAAJ,CAAU,4BAAV,CAAf,CAAP;QACD;;QAED,OAAO,KAAKX,KAAL,CAAWY,OAAX,CAAmBf,OAAnB,CAAP;MACD;MACD;;;MAEA,OAAOW,QAAP;IACD;;;;IAvFD;AACF;AACA;IACE,kBAAgB;MACd,OAAO,IAAIZ,mBAAJ,CAAwB;QAACI,KAAK,EAAE;MAAR,CAAxB,CAAP;IACD;;;EAN8CsB,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RequestEventInterceptor","options","logger","console","webex","trigger","error","warn","resolve","reason","reject","response","Interceptor"],"sources":["request-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class RequestEventInterceptor extends Interceptor {\n /**\n * @returns {RequestEventInterceptor}\n */\n static create() {\n return new RequestEventInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const logger = get(this, 'webex.logger', console);\n\n try {\n this.webex.trigger('request:start', options);\n }
|
|
1
|
+
{"version":3,"names":["RequestEventInterceptor","options","logger","console","webex","trigger","error","warn","resolve","reason","reject","response","Interceptor"],"sources":["request-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class RequestEventInterceptor extends Interceptor {\n /**\n * @returns {RequestEventInterceptor}\n */\n static create() {\n return new RequestEventInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const logger = get(this, 'webex.logger', console);\n\n try {\n this.webex.trigger('request:start', options);\n } catch (error) {\n logger.warn('event handler for request:start failed ', error);\n }\n\n return Promise.resolve(options);\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onRequestError(options, reason) {\n // We need to do the normal onRequest logging, but then log how the request\n // failed since the response logger won't be called.\n const logger = get(this, 'webex.logger', console);\n\n try {\n this.webex.trigger('request:end', options, reason);\n this.webex.trigger('request:failure', options, reason);\n } catch (error) {\n logger.warn('event handler for request:end failed ', error);\n }\n\n return Promise.reject(reason);\n }\n\n /**\n * @see Interceptor#onResponse\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n const logger = get(this, 'webex.logger', console);\n\n try {\n this.webex.trigger('request:success', response.options, response);\n } catch (error) {\n logger.warn('event handler for request:success failed ', error);\n }\n\n return Promise.resolve(response);\n }\n\n /**\n * @see Interceptor#onResponseError\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n const logger = get(this, 'webex.logger', console);\n\n try {\n this.webex.trigger('request:end', options, reason);\n this.webex.trigger('request:failure', options, reason);\n } catch (error) {\n logger.warn('event handler for request:failure failed ', error);\n }\n\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;;AAEA;AACA;AACA;IACqBA,uB;;;;;;;;;;;;;IAQnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MACjB,IAAMC,MAAM,GAAG,mBAAI,IAAJ,EAAU,cAAV,EAA0BC,OAA1B,CAAf;;MAEA,IAAI;QACF,KAAKC,KAAL,CAAWC,OAAX,CAAmB,eAAnB,EAAoCJ,OAApC;MACD,CAFD,CAEE,OAAOK,KAAP,EAAc;QACdJ,MAAM,CAACK,IAAP,CAAY,yCAAZ,EAAuDD,KAAvD;MACD;;MAED,OAAO,iBAAQE,OAAR,CAAgBP,OAAhB,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,wBAAeA,OAAf,EAAwBQ,MAAxB,EAAgC;MAC9B;MACA;MACA,IAAMP,MAAM,GAAG,mBAAI,IAAJ,EAAU,cAAV,EAA0BC,OAA1B,CAAf;;MAEA,IAAI;QACF,KAAKC,KAAL,CAAWC,OAAX,CAAmB,aAAnB,EAAkCJ,OAAlC,EAA2CQ,MAA3C;QACA,KAAKL,KAAL,CAAWC,OAAX,CAAmB,iBAAnB,EAAsCJ,OAAtC,EAA+CQ,MAA/C;MACD,CAHD,CAGE,OAAOH,KAAP,EAAc;QACdJ,MAAM,CAACK,IAAP,CAAY,uCAAZ,EAAqDD,KAArD;MACD;;MAED,OAAO,iBAAQI,MAAR,CAAeD,MAAf,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,oBAAWR,OAAX,EAAoBU,QAApB,EAA8B;MAC5B,IAAMT,MAAM,GAAG,mBAAI,IAAJ,EAAU,cAAV,EAA0BC,OAA1B,CAAf;;MAEA,IAAI;QACF,KAAKC,KAAL,CAAWC,OAAX,CAAmB,iBAAnB,EAAsCM,QAAQ,CAACV,OAA/C,EAAwDU,QAAxD;MACD,CAFD,CAEE,OAAOL,KAAP,EAAc;QACdJ,MAAM,CAACK,IAAP,CAAY,2CAAZ,EAAyDD,KAAzD;MACD;;MAED,OAAO,iBAAQE,OAAR,CAAgBG,QAAhB,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,yBAAgBV,OAAhB,EAAyBQ,MAAzB,EAAiC;MAC/B,IAAMP,MAAM,GAAG,mBAAI,IAAJ,EAAU,cAAV,EAA0BC,OAA1B,CAAf;;MAEA,IAAI;QACF,KAAKC,KAAL,CAAWC,OAAX,CAAmB,aAAnB,EAAkCJ,OAAlC,EAA2CQ,MAA3C;QACA,KAAKL,KAAL,CAAWC,OAAX,CAAmB,iBAAnB,EAAsCJ,OAAtC,EAA+CQ,MAA/C;MACD,CAHD,CAGE,OAAOH,KAAP,EAAc;QACdJ,MAAM,CAACK,IAAP,CAAY,2CAAZ,EAAyDD,KAAzD;MACD;;MAED,OAAO,iBAAQI,MAAR,CAAeD,MAAf,CAAP;IACD;;;;IAhFD;AACF;AACA;IACE,kBAAgB;MACd,OAAO,IAAIT,uBAAJ,CAA4B;QAACI,KAAK,EAAE;MAAR,CAA5B,CAAP;IACD;;;EANkDQ,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RequestLoggerInterceptor","options","logger","console","info","method","uri","now","Date","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","getTime","toISOString","body","length","util","inspect","depth","e","warn","resolve","reason","onRequest","error","stack","reject","webex","Interceptor"],"sources":["request-logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\nimport {get, has, isArray, isString, omit} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class RequestLoggerInterceptor extends Interceptor {\n /**\n * @returns {RequestLoggerInterceptor}\n */\n static create() {\n return new RequestLoggerInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const logger = get(this, 'webex.logger', console);\n\n logger.info('/**********************************************************************\\\\ ');\n logger.info('Request:', options.method || 'GET', options.uri);\n logger.info('WEBEX_TRACKINGID: ', get(options, 'headers.trackingid'));\n /* istanbul ignore next */\n if (has(options, 'headers.x-trans-id')) {\n logger.info('X-Trans-ID: ', get(options, 'headers.x-trans-id'));\n }\n const now = new Date();\n\n if (process.env.ENABLE_VERBOSE_NETWORK_LOGGING) {\n logger.info('timestamp (start): ', now.getTime(), now.toISOString());\n try {\n // Determine if body is a buffer without relying on Buffer to avoid\n // node/browser conflicts.\n if (options.body
|
|
1
|
+
{"version":3,"names":["RequestLoggerInterceptor","options","logger","console","info","method","uri","now","Date","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","getTime","toISOString","body","length","util","inspect","depth","e","warn","resolve","reason","onRequest","error","stack","reject","webex","Interceptor"],"sources":["request-logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\nimport {get, has, isArray, isString, omit} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\n\n/**\n * @class\n */\nexport default class RequestLoggerInterceptor extends Interceptor {\n /**\n * @returns {RequestLoggerInterceptor}\n */\n static create() {\n return new RequestLoggerInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const logger = get(this, 'webex.logger', console);\n\n logger.info('/**********************************************************************\\\\ ');\n logger.info('Request:', options.method || 'GET', options.uri);\n logger.info('WEBEX_TRACKINGID: ', get(options, 'headers.trackingid'));\n /* istanbul ignore next */\n if (has(options, 'headers.x-trans-id')) {\n logger.info('X-Trans-ID: ', get(options, 'headers.x-trans-id'));\n }\n const now = new Date();\n\n if (process.env.ENABLE_VERBOSE_NETWORK_LOGGING) {\n logger.info('timestamp (start): ', now.getTime(), now.toISOString());\n try {\n // Determine if body is a buffer without relying on Buffer to avoid\n // node/browser conflicts.\n if (\n options.body &&\n options.body.length &&\n !isArray(options.body) &&\n !isString(options.body)\n ) {\n logger.info('Request Options:', util.inspect(omit(options, 'body'), {depth: null}));\n } else {\n logger.info('Request Options:', util.inspect(options, {depth: null}));\n }\n } catch (e) {\n logger.warn('Could not stringify request options:', e);\n }\n }\n\n return Promise.resolve(options);\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @param {Error} reason\n * @returns {Object}\n */\n onRequestError(options, reason) {\n // We need to do the normal onRequest logging, but then log how the request\n // failed since the response logger won't be called.\n this.onRequest(options);\n const logger = get(this, 'webex.logger', console);\n\n logger.error('Request Failed: ', reason.stack);\n logger.info('\\\\**********************************************************************/');\n\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAGA;;;;;;AAEA;AACA;AACA;IACqBA,wB;;;;;;;;;;;;;IAQnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MACjB,IAAMC,MAAM,GAAG,mBAAI,IAAJ,EAAU,cAAV,EAA0BC,OAA1B,CAAf;MAEAD,MAAM,CAACE,IAAP,CAAY,4EAAZ;MACAF,MAAM,CAACE,IAAP,CAAY,UAAZ,EAAwBH,OAAO,CAACI,MAAR,IAAkB,KAA1C,EAAiDJ,OAAO,CAACK,GAAzD;MACAJ,MAAM,CAACE,IAAP,CAAY,oBAAZ,EAAkC,mBAAIH,OAAJ,EAAa,oBAAb,CAAlC;MACA;;MACA,IAAI,mBAAIA,OAAJ,EAAa,oBAAb,CAAJ,EAAwC;QACtCC,MAAM,CAACE,IAAP,CAAY,cAAZ,EAA4B,mBAAIH,OAAJ,EAAa,oBAAb,CAA5B;MACD;;MACD,IAAMM,GAAG,GAAG,IAAIC,IAAJ,EAAZ;;MAEA,IAAIC,OAAO,CAACC,GAAR,CAAYC,8BAAhB,EAAg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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ResponseLoggerInterceptor","options","response","now","Date","printResponseHeader","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","getTime","toISOString","body","isBuffer","util","inspect","depth","err","reason","error","reject","statusCode","$timings","networkEnd","networkStart","requestEnd","requestStart","webex","Interceptor"],"sources":["response-logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\nimport {get, omit} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\nimport {isBuffer} from '@webex/common';\n\n/**\n * @class\n */\nexport default class ResponseLoggerInterceptor extends Interceptor {\n /**\n * @returns {ResponseLoggerInterceptor}\n */\n static create() {\n return new ResponseLoggerInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n const now = new Date();\n\n this.printResponseHeader(options, response);\n\n const logger = get(this, 'webex.logger', console);\n\n if (process.env.ENABLE_VERBOSE_NETWORK_LOGGING) {\n logger.info('timestamp (end): ', now.getTime(), now.toISOString());\n if (typeof response.body === 'string' || isBuffer(response.body)) {\n logger.info('Response: ', 'Not printed, it`s probably a file');\n }
|
|
1
|
+
{"version":3,"names":["ResponseLoggerInterceptor","options","response","now","Date","printResponseHeader","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","getTime","toISOString","body","isBuffer","util","inspect","depth","err","reason","error","reject","statusCode","$timings","networkEnd","networkStart","requestEnd","requestStart","webex","Interceptor"],"sources":["response-logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\nimport {get, omit} from 'lodash';\nimport {Interceptor} from '@webex/http-core';\nimport {isBuffer} from '@webex/common';\n\n/**\n * @class\n */\nexport default class ResponseLoggerInterceptor extends Interceptor {\n /**\n * @returns {ResponseLoggerInterceptor}\n */\n static create() {\n return new ResponseLoggerInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Object}\n */\n onResponse(options, response) {\n const now = new Date();\n\n this.printResponseHeader(options, response);\n\n const logger = get(this, 'webex.logger', console);\n\n if (process.env.ENABLE_VERBOSE_NETWORK_LOGGING) {\n logger.info('timestamp (end): ', now.getTime(), now.toISOString());\n if (typeof response.body === 'string' || isBuffer(response.body)) {\n logger.info('Response: ', 'Not printed, it`s probably a file');\n } else if (typeof response.body === 'object') {\n try {\n logger.info('Response: ', util.inspect(omit(response.body, 'features'), {depth: null}));\n } catch (err) {\n logger.info('Response: ', '[Not Serializable]', err);\n }\n }\n }\n logger.info('\\\\**********************************************************************/');\n\n return response;\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @param {Object} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n const now = new Date();\n\n this.printResponseHeader(options, reason);\n\n const logger = get(this, 'webex.logger', console);\n\n if (process.env.ENABLE_VERBOSE_NETWORK_LOGGING) {\n logger.info('timestamp (end): ', now.getTime(), now.toISOString());\n try {\n logger.error('Response: ', util.inspect(reason.body, {depth: null}));\n } catch (err) {\n logger.error('Response: ', reason.body);\n }\n }\n logger.info('\\\\**********************************************************************/');\n\n return Promise.reject(reason);\n }\n\n /**\n * Prints the basic header\n * @param {Object} options\n * @param {HttpResponse|WebexHttpError} response\n * @returns {undefined}\n */\n printResponseHeader(options, response) {\n const logger = get(this, 'webex.logger', console);\n\n logger.info('Status Code:', response.statusCode);\n logger.info(\n 'WEBEX_TRACKINGID:',\n get(options, 'headers.trackingid') || get(response, 'headers.trackingid')\n );\n logger.info('Network duration:', options.$timings.networkEnd - options.$timings.networkStart);\n logger.info(\n 'Processing duration:',\n options.$timings.requestEnd - options.$timings.requestStart\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAGA;;AACA;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IAAI5B,yBAAJ,CAA8B;QAAC6B,KAAK,EAAE;MAAR,CAA9B,CAAP;IACD;;;EANoDC,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["strings","UserAgentInterceptor","options","appName","appVersion","set","inBrowser","headers","get","webex","Interceptor"],"sources":["user-agent.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\nimport {Interceptor} from '@webex/http-core';\nimport {get} from 'lodash';\n\nconst strings = new WeakMap();\n\n/**\n * Sets a 'user-agent' header on all requests if one is not present.\n * Defaults to '@webex/http-core' though a custom user-agent can be set\n * using the appName and appVersion configuration. e.g.\n *\n * webex = WebexSdk.init({\n * credentials: {\n * supertoken: superToken\n * },\n * config: {\n * credentials: {\n * client_id,\n * client_secret\n * },\n * appName: 'custom-user-agent',\n * appVersion: '1.0',\n * }\n * });\n */\nexport default class UserAgentInterceptor extends Interceptor {\n /**\n * @param {Object} [options={}]\n * @param {WebexCore} [options.webex]\n * @private\n * @returns {UserAgentInterceptor}\n */\n constructor(options = {}) {\n const appName = get(options, 'webex.config.appName');\n const appVersion = get(options, 'webex.config.appVersion') || '0.0';\n\n super(options);\n if (appName) {\n strings.set(this, `${appName}/${appVersion}`);\n }
|
|
1
|
+
{"version":3,"names":["strings","UserAgentInterceptor","options","appName","appVersion","set","inBrowser","headers","get","webex","Interceptor"],"sources":["user-agent.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\nimport {Interceptor} from '@webex/http-core';\nimport {get} from 'lodash';\n\nconst strings = new WeakMap();\n\n/**\n * Sets a 'user-agent' header on all requests if one is not present.\n * Defaults to '@webex/http-core' though a custom user-agent can be set\n * using the appName and appVersion configuration. e.g.\n *\n * webex = WebexSdk.init({\n * credentials: {\n * supertoken: superToken\n * },\n * config: {\n * credentials: {\n * client_id,\n * client_secret\n * },\n * appName: 'custom-user-agent',\n * appVersion: '1.0',\n * }\n * });\n */\nexport default class UserAgentInterceptor extends Interceptor {\n /**\n * @param {Object} [options={}]\n * @param {WebexCore} [options.webex]\n * @private\n * @returns {UserAgentInterceptor}\n */\n constructor(options = {}) {\n const appName = get(options, 'webex.config.appName');\n const appVersion = get(options, 'webex.config.appVersion') || '0.0';\n\n super(options);\n if (appName) {\n strings.set(this, `${appName}/${appVersion}`);\n } else {\n strings.set(this, '@webex/http-core'); // Using the traditional default from http-core\n }\n }\n\n /**\n * @returns {UserAgentInterceptor}\n */\n static create() {\n return new UserAgentInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n // Do not set a custom user-agent for browsers\n if (inBrowser) {\n return options;\n }\n\n options.headers = options.headers || {};\n\n if ('user-agent' in options.headers && options.headers['spark-user-agent']) {\n return options;\n }\n\n options.headers['user-agent'] = strings.get(this);\n\n return options;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;;;;;AAGA,IAAMA,OAAO,GAAG,sBAAhB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;IACqBC,oB;;;;;EACnB;AACF;AACA;AACA;AACA;AACA;EACE,gCAA0B;IAAA;;IAAA,IAAdC,OAAc,uEAAJ,EAAI;IAAA;IACxB,IAAMC,OAAO,GAAG,mBAAID,OAAJ,EAAa,sBAAb,CAAhB;IACA,IAAME,UAAU,GAAG,mBAAIF,OAAJ,EAAa,yBAAb,KAA2C,KAA9D;IAEA,0BAAMA,OAAN;;IACA,IAAIC,OAAJ,EAAa;MACXH,OAAO,CAACK,GAAR,wDAAqBF,OAArB,cAAgCC,UAAhC;IACD,CAFD,MAEO;MACLJ,OAAO,CAACK,GAAR,8CAAkB,kBAAlB,EADK,CACkC;IACxC;;IATuB;EAUzB;EAED;AACF;AACA;;;;;;IAKE;AACF;AACA;AACA;AACA;IACE,mBAAUH,OAAV,EAAmB;MACjB;MACA,IAAII,iBAAJ,EAAe;QACb,OAAOJ,OAAP;MACD;;MAEDA,OAAO,CAACK,OAAR,GAAkBL,OAAO,CAACK,OAAR,IAAmB,EAArC;;MAEA,IAAI,gBAAgBL,OAAO,CAACK,OAAxB,IAAmCL,OAAO,CAACK,OAAR,CAAgB,kBAAhB,CAAvC,EAA4E;QAC1E,OAAOL,OAAP;MACD;;MAEDA,OAAO,CAACK,OAAR,CAAgB,YAAhB,IAAgCP,OAAO,CAACQ,GAAR,CAAY,IAAZ,CAAhC;MAEA,OAAON,OAAP;IACD;;;WAxBD,kBAAgB;MACd,OAAO,IAAID,oBAAJ,CAAyB;QAACQ,KAAK,EAAE;MAAR,CAAzB,CAAP;IACD;;;EAxB+CC,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["strings","WebexUserAgentInterceptor","options","libName","libVersion","set","inBrowser","headers","webex","config","appName","appVersion","appPlatform","sparkUserAgent","get","uri","includes","credentials","samlUrl","tokenUrl","authorizeUrl","Interceptor"],"sources":["webex-user-agent.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\nimport {Interceptor} from '@webex/http-core';\nimport {get} from 'lodash';\n\nconst strings = new WeakMap();\n\n/**\n * @class\n */\nexport default class WebexUserAgentInterceptor extends Interceptor {\n /**\n * @param {Object} [options={}]\n * @param {WebexCore} [options.webex]\n * @private\n * @returns {WebexUserAgentInterceptor}\n */\n constructor(options = {}) {\n const libName = get(options, 'webex.webex', false) ? 'webex' : 'webex-js-sdk';\n const libVersion = get(options, 'webex.version', 'development');\n\n super(options);\n strings.set(this, `${libName}/${libVersion} (${inBrowser ? 'web' : 'node'})`);\n }\n\n /**\n * @returns {WebexUserAgentInterceptor}\n */\n static create() {\n return new WebexUserAgentInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n options.headers = options.headers || {};\n const {
|
|
1
|
+
{"version":3,"names":["strings","WebexUserAgentInterceptor","options","libName","libVersion","set","inBrowser","headers","webex","config","appName","appVersion","appPlatform","sparkUserAgent","get","uri","includes","credentials","samlUrl","tokenUrl","authorizeUrl","Interceptor"],"sources":["webex-user-agent.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\nimport {Interceptor} from '@webex/http-core';\nimport {get} from 'lodash';\n\nconst strings = new WeakMap();\n\n/**\n * @class\n */\nexport default class WebexUserAgentInterceptor extends Interceptor {\n /**\n * @param {Object} [options={}]\n * @param {WebexCore} [options.webex]\n * @private\n * @returns {WebexUserAgentInterceptor}\n */\n constructor(options = {}) {\n const libName = get(options, 'webex.webex', false) ? 'webex' : 'webex-js-sdk';\n const libVersion = get(options, 'webex.version', 'development');\n\n super(options);\n strings.set(this, `${libName}/${libVersion} (${inBrowser ? 'web' : 'node'})`);\n }\n\n /**\n * @returns {WebexUserAgentInterceptor}\n */\n static create() {\n return new WebexUserAgentInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n options.headers = options.headers || {};\n const {appName, appVersion, appPlatform} = this.webex?.config ?? {};\n let sparkUserAgent = `${strings.get(this)}`;\n\n if (appName) {\n sparkUserAgent += ` ${appName}/${appVersion ?? '0.0'}`;\n }\n\n if (appPlatform) {\n sparkUserAgent += ` ${appPlatform}`;\n }\n\n if (options.uri && options.uri.includes('https://idbroker')) {\n return options;\n }\n\n if (\n options.uri &&\n (options.uri.includes(this.webex.config.credentials.samlUrl) ||\n options.uri.includes(this.webex.config.credentials.tokenUrl) ||\n options.uri.includes(this.webex.config.credentials.authorizeUrl))\n ) {\n return options;\n }\n\n if ('spark-user-agent' in options.headers) {\n if (!options.headers['spark-user-agent']) {\n Reflect.deleteProperty(options.headers, 'spark-user-agent');\n }\n\n return options;\n }\n\n options.headers['spark-user-agent'] = sparkUserAgent;\n\n return options;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;;;;;AAGA,IAAMA,OAAO,GAAG,sBAAhB;AAEA;AACA;AACA;;IACqBC,yB;;;;;EACnB;AACF;AACA;AACA;AACA;AACA;EACE,qCAA0B;IAAA;;IAAA,IAAdC,OAAc,uEAAJ,EAAI;IAAA;IACxB,IAAMC,OAAO,GAAG,mBAAID,OAAJ,EAAa,aAAb,EAA4B,KAA5B,IAAqC,OAArC,GAA+C,cAA/D;IACA,IAAME,UAAU,GAAG,mBAAIF,OAAJ,EAAa,eAAb,EAA8B,aAA9B,CAAnB;IAEA,0BAAMA,OAAN;IACAF,OAAO,CAACK,GAAR,wDAAqBF,OAArB,cAAgCC,UAAhC,eAA+CE,iBAAA,GAAY,KAAZ,GAAoB,MAAnE;IALwB;EAMzB;EAED;AACF;AACA;;;;;;IAKE;AACF;AACA;AACA;AACA;IACE,mBAAUJ,OAAV,EAAmB;MAAA;;MACjBA,OAAO,CAACK,OAAR,GAAkBL,OAAO,CAACK,OAAR,IAAmB,EAArC;;MACA,gDAA2C,KAAKC,KAAhD,gDAA2C,YAAYC,MAAvD,mEAAiE,EAAjE;MAAA,IAAOC,OAAP,QAAOA,OAAP;MAAA,IAAgBC,UAAhB,QAAgBA,UAAhB;MAAA,IAA4BC,WAA5B,QAA4BA,WAA5B;;MACA,IAAIC,cAAc,aAAMb,OAAO,CAACc,GAAR,CAAY,IAAZ,CAAN,CAAlB;;MAEA,IAAIJ,OAAJ,EAAa;QACXG,cAAc,eAAQH,OAAR,cAAmBC,UAAnB,aAAmBA,UAAnB,cAAmBA,UAAnB,GAAiC,KAAjC,CAAd;MACD;;MAED,IAAIC,WAAJ,EAAiB;QACfC,cAAc,eAAQD,WAAR,CAAd;MACD;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