@webex/webex-core 3.11.0 → 3.12.0-llmrefactor.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +5 -2
  2. package/dist/config.js +15 -0
  3. package/dist/config.js.map +1 -1
  4. package/dist/credentials-config.js +12 -0
  5. package/dist/credentials-config.js.map +1 -1
  6. package/dist/interceptors/redirect.js +1 -1
  7. package/dist/interceptors/redirect.js.map +1 -1
  8. package/dist/lib/batcher.js +23 -7
  9. package/dist/lib/batcher.js.map +1 -1
  10. package/dist/lib/credentials/credentials.js +48 -4
  11. package/dist/lib/credentials/credentials.js.map +1 -1
  12. package/dist/lib/credentials/token.js +1 -1
  13. package/dist/lib/domains.js +90 -0
  14. package/dist/lib/domains.js.map +1 -0
  15. package/dist/lib/services/service-catalog.js +6 -10
  16. package/dist/lib/services/service-catalog.js.map +1 -1
  17. package/dist/lib/services/services.js +217 -31
  18. package/dist/lib/services/services.js.map +1 -1
  19. package/dist/lib/services-v2/service-catalog.js +6 -12
  20. package/dist/lib/services-v2/service-catalog.js.map +1 -1
  21. package/dist/lib/services-v2/services-v2.js +221 -30
  22. package/dist/lib/services-v2/services-v2.js.map +1 -1
  23. package/dist/plugins/logger.js +1 -1
  24. package/dist/webex-core.js +2 -2
  25. package/dist/webex-core.js.map +1 -1
  26. package/package.json +13 -13
  27. package/src/config.js +17 -0
  28. package/src/credentials-config.js +13 -0
  29. package/src/interceptors/redirect.js +4 -1
  30. package/src/lib/batcher.js +25 -10
  31. package/src/lib/credentials/credentials.js +50 -3
  32. package/src/lib/domains.ts +94 -0
  33. package/src/lib/services/service-catalog.js +6 -10
  34. package/src/lib/services/services.js +192 -17
  35. package/src/lib/services-v2/service-catalog.ts +6 -11
  36. package/src/lib/services-v2/services-v2.ts +195 -17
  37. package/test/fixtures/activation-email.ts +22 -0
  38. package/test/integration/spec/services/services.js +44 -8
  39. package/test/integration/spec/services-v2/services-v2.js +44 -8
  40. package/test/unit/spec/credentials/credentials.js +133 -2
  41. package/test/unit/spec/interceptors/auth.js +56 -0
  42. package/test/unit/spec/lib/batcher.js +56 -0
  43. package/test/unit/spec/services/service-catalog.js +93 -11
  44. package/test/unit/spec/services/services.js +358 -2
  45. package/test/unit/spec/services-v2/service-catalog.ts +93 -11
  46. package/test/unit/spec/services-v2/services-v2.ts +362 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_querystring","_interopRequireDefault","require","_url","_jsonwebtoken","_common","_commonTimers","_lodash","_webexPlugin","_decorators","_grantErrors","_interopRequireWildcard","_scope","_token","_tokenCollection","_constants","_dec","_dec2","_dec3","_dec4","_dec5","_dec6","_obj","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor2","ownKeys","_Object$keys2","_Object$getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","_Object$getOwnPropertyDescriptors","_Object$defineProperties","Credentials","WebexPlugin","extend","oneFlight","keyFactory","scope","waitForValue","persist","whileInFlight","collections","userTokens","TokenCollection","dataTypes","token","makeStateDataType","Token","dataType","derived","canAuthorize","deps","fn","Boolean","supertoken","canRefresh","config","jwtRefreshCallback","isUnverifiedGuest","isGuest","JSON","parse","base64","decode","access_token","split","user_type","_unused","props","prop","namespace","session","isRefreshing","type","ready","refreshTimer","undefined","buildLoginUrl","options","clientType","state","isObject","Error","client_id","redirect_uri","cloneDeep","response_type","_deleteProperty","isEmpty","toBase64Url","_stringify","concat","authorizeUrl","querystring","stringify","getOrgId","logger","info","extractOrgIdFromJWT","_this$supertoken","extractOrgIdFromUserToken","decodedJWT","jwt","realm","fields","buildLogoutUrl","logoutUrl","cisService","service","goto","calcRefreshTimeout","expiration","Math","floor","random","constructor","_this","_dataTypes","_keys","key","bind","_len","args","Array","_key","_apply","downscope","_this2","catch","reason","_reason$body","failReason","body","warn","trace","webex","internal","metrics","submitClientMetrics","METRICS","JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED","requestedScope","_promise","resolve","serialize","parent","getClientToken","_this3","request","method","uri","tokenUrl","form","grant_type","self_contained_token","auth","user","pass","client_secret","sendImmediately","shouldRefreshAccessToken","then","res","statusCode","reject","ErrorConstructor","grantErrors","select","error","_res","getUserToken","_this4","once","filterScope","sortScope","tap","add","initialize","attrs","_this5","authorization","expires","scheduleRefresh","prototype","listenToOnce","authorizationString","parsed","url","query","href","substr","indexOf","invalidate","clearTimeout","unset","err","models","remove","refresh","_this6","tokens","clone","requestAccessTokenFromJwt","services","updateCredentialsConfig","OAuthError","trigger","st","invalidScopes","diffScopes","JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH","all","map","tokenScope","revoke","_this7","expiresIn","_now","timeoutLength","safeSetTimeout","version","_applyDecoratedDescriptor2","_getOwnPropertyDescriptor","_default","exports"],"sources":["credentials.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport querystring from 'querystring';\nimport url from 'url';\n\nimport jwt from 'jsonwebtoken';\nimport {base64, makeStateDataType, oneFlight, tap, whileInFlight} from '@webex/common';\nimport {safeSetTimeout} from '@webex/common-timers';\nimport {clone, cloneDeep, isObject, isEmpty} from 'lodash';\n\nimport WebexPlugin from '../webex-plugin';\nimport {persist, waitForValue} from '../storage/decorators';\n\nimport grantErrors, {OAuthError} from './grant-errors';\nimport {filterScope, diffScopes, sortScope} from './scope';\nimport Token from './token';\nimport TokenCollection from './token-collection';\nimport {METRICS} from '../constants';\n\n/**\n * @class\n */\nconst Credentials = WebexPlugin.extend({\n collections: {\n userTokens: TokenCollection,\n },\n\n dataTypes: {\n token: makeStateDataType(Token, 'token').dataType,\n },\n\n derived: {\n canAuthorize: {\n deps: ['supertoken', 'supertoken.canAuthorize', 'canRefresh'],\n fn() {\n return Boolean((this.supertoken && this.supertoken.canAuthorize) || this.canRefresh);\n },\n },\n canRefresh: {\n deps: ['supertoken', 'supertoken.canRefresh'],\n fn() {\n // If we're operating in JWT mode, we have to delegate to the consumer\n if (this.config.jwtRefreshCallback) {\n return true;\n }\n\n return Boolean(this.supertoken && this.supertoken.canRefresh);\n },\n },\n isUnverifiedGuest: {\n deps: ['supertoken'],\n /**\n * Returns true if the user is an unverified guest\n * @returns {boolean}\n */\n fn() {\n let isGuest = false;\n try {\n isGuest =\n JSON.parse(base64.decode(this.supertoken.access_token.split('.')[1])).user_type ===\n 'guest';\n } catch {\n /* the non-guest token is formatted differently so catch is expected */\n }\n\n return isGuest;\n },\n },\n },\n\n props: {\n supertoken: makeStateDataType(Token, 'token').prop,\n },\n\n namespace: 'Credentials',\n\n session: {\n isRefreshing: {\n default: false,\n type: 'boolean',\n },\n /**\n * Becomes `true` once the {@link loaded} event fires.\n * @see {@link WebexPlugin#ready}\n * @instance\n * @memberof Credentials\n * @type {boolean}\n */\n ready: {\n default: false,\n type: 'boolean',\n },\n refreshTimer: {\n default: undefined,\n type: 'any',\n },\n },\n\n /**\n * Generates an OAuth Login URL. Prefers the api.ciscospark.com proxy if the\n * instance is initialize with an authorizatUrl, but fallsback to idbroker\n * as the base otherwise.\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {string}\n */\n buildLoginUrl(options = {clientType: 'public'}) {\n /* eslint-disable camelcase */\n if (options.state && !isObject(options.state)) {\n throw new Error('if specified, `options.state` must be an object');\n }\n\n options.client_id = this.config.client_id;\n options.redirect_uri = this.config.redirect_uri;\n options.scope = this.config.scope;\n\n options = cloneDeep(options);\n\n if (!options.response_type) {\n options.response_type = options.clientType === 'public' ? 'token' : 'code';\n }\n Reflect.deleteProperty(options, 'clientType');\n\n if (options.state) {\n if (!isEmpty(options.state)) {\n options.state = base64.toBase64Url(JSON.stringify(options.state));\n } else {\n delete options.state;\n }\n }\n\n return `${this.config.authorizeUrl}?${querystring.stringify(options)}`;\n /* eslint-enable camelcase */\n },\n\n /**\n * Get the determined OrgId.\n *\n * @throws {Error} - If the OrgId could not be determined.\n * @returns {string} - The OrgId.\n */\n getOrgId() {\n this.logger.info('credentials: attempting to retrieve the OrgId from token');\n\n try {\n // Attempt to extract a client-authenticated token's OrgId.\n this.logger.info('credentials: trying to extract OrgId from JWT');\n\n return this.extractOrgIdFromJWT(this.supertoken.access_token);\n } catch (e) {\n // Attempt to extract a user token's OrgId.\n this.logger.info('credentials: could not extract OrgId from JWT');\n this.logger.info('credentials: attempting to extract OrgId from user token');\n\n try {\n return this.extractOrgIdFromUserToken(this.supertoken?.access_token);\n } catch (f) {\n this.logger.info('credentials: could not extract OrgId from user token');\n throw f;\n }\n }\n },\n\n /**\n * Extract the OrgId [realm] from a provided JWT.\n *\n * @private\n * @param {string} token - The JWT to extract the OrgId from.\n * @throws {Error} - If the token does not pass JWT general/realm validation.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromJWT(token = '') {\n // Decoded the provided token.\n const decodedJWT = jwt.decode(token);\n\n // Validate that the provided token is a JWT.\n if (!decodedJWT) {\n throw new Error('unable to extract the OrgId from the provided JWT');\n }\n\n if (!decodedJWT.realm) {\n throw new Error('the provided JWT does not contain an OrgId');\n }\n\n // Return the OrgId [realm].\n return decodedJWT.realm;\n },\n\n /**\n * Extract the OrgId [realm] from a provided user token.\n *\n * @private\n * @param {string} token - The user token to extract the OrgId from.\n * @throws {Error} - Will throw an error if the provided token is invalid.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromUserToken(token = '') {\n // Split the provided token into subsections.\n const fields = token.split('_');\n\n // Validate that the provided token has the proper amount of sections.\n if (fields.length !== 3) {\n throw new Error(\n `the provided token is not a valid format, token has ${fields.length} sections`\n );\n }\n\n // Return the token section that contains the OrgId.\n return fields[2];\n },\n\n /**\n * Generates a Logout URL\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {[type]}\n */\n buildLogoutUrl(options = {}) {\n return `${this.config.logoutUrl}?${querystring.stringify({\n cisService: this.config.service,\n goto: this.config.redirect_uri,\n ...options,\n })}`;\n },\n\n /**\n * Generates a number between 60% - 90% of expired value\n * @instance\n * @memberof Credentials\n * @param {number} expiration\n * @private\n * @returns {number}\n */\n calcRefreshTimeout(expiration) {\n return Math.floor(((Math.floor(Math.random() * 4) + 6) / 10) * expiration);\n },\n\n constructor(...args) {\n // HACK to deal with the fact that AmpersandState#dataTypes#set is a pure\n // function.\n this._dataTypes = cloneDeep(this._dataTypes);\n Object.keys(this._dataTypes).forEach((key) => {\n if (this._dataTypes[key].set) {\n this._dataTypes[key].set = this._dataTypes[key].set.bind(this);\n }\n });\n // END HACK\n Reflect.apply(WebexPlugin, this, args);\n },\n\n /**\n * Downscopes a token\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @private\n * @returns {Promise<Token>}\n */\n downscope(scope) {\n return this.supertoken.downscope(scope).catch((reason) => {\n const failReason = reason?.body ?? reason;\n this.logger.warn(`credentials: failed to downscope supertoken to \"${scope}\"`, failReason);\n this.logger.trace(`credentials: falling back to supertoken for ${scope}`);\n this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED, {\n fields: {\n requestedScope: scope,\n failReason,\n },\n });\n\n return Promise.resolve(new Token({scope, ...this.supertoken.serialize()}), {\n parent: this,\n });\n });\n },\n\n /**\n * Requests a client credentials grant and returns the token. Given the\n * limited use for such tokens as this time, this method does not cache its\n * token.\n * @instance\n * @memberof Credentials\n * @param {Object} options\n * @returns {Promise<Token>}\n */\n getClientToken(options = {}) {\n this.logger.info('credentials: requesting client credentials grant');\n\n return this.webex\n .request({\n /* eslint-disable camelcase */\n method: 'POST',\n uri: options.uri || this.config.tokenUrl,\n form: {\n grant_type: 'client_credentials',\n scope: options.scope || 'webexsquare:admin',\n self_contained_token: true,\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true,\n },\n shouldRefreshAccessToken: false,\n /* eslint-enable camelcase */\n })\n .then((res) => new Token(res.body, {parent: this}))\n .catch((res) => {\n if (res.statusCode !== 400) {\n return Promise.reject(res);\n }\n\n const ErrorConstructor = grantErrors.select(res.body.error);\n\n return Promise.reject(new ErrorConstructor(res._res || res));\n });\n },\n\n @oneFlight({keyFactory: (scope) => scope})\n @waitForValue('@')\n /**\n * Resolves with a token with the specified scopes. If no scope is specified,\n * defaults to omit(webex.credentials.scope, 'spark:kms'). If no such token is\n * available, downscopes the supertoken to that scope.\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @returns {Promise<Token>}\n */\n getUserToken(scope) {\n return Promise.resolve(\n !this.isRefreshing ||\n new Promise((resolve) => {\n this.logger.info(\n 'credentials: token refresh inflight; delaying getUserToken until refresh completes'\n );\n this.once('change:isRefreshing', () => {\n this.logger.info('credentials: token refresh complete; reinvoking getUserToken');\n resolve();\n });\n })\n ).then(() => {\n if (!this.canAuthorize) {\n this.logger.info('credentials: cannot produce an access token from current state');\n\n return Promise.reject(new Error('Current state cannot produce an access token'));\n }\n\n if (!scope) {\n scope = filterScope('spark:kms', this.supertoken.scope);\n }\n\n scope = sortScope(scope);\n\n if (scope === sortScope(this.supertoken.scope)) {\n return Promise.resolve(this.supertoken);\n }\n\n const token = this.userTokens.get(scope);\n\n // we should also check for the token.access_token since token object does\n // not get cleared on unsetting while logging out.\n if (!token || !token.access_token) {\n return this.downscope(scope).then(tap((t) => this.userTokens.add(t)));\n }\n\n return Promise.resolve(token);\n });\n },\n\n @persist('@')\n /**\n * Initializer\n * @instance\n * @memberof Credentials\n * @param {Object} attrs\n * @param {Object} options\n * @private\n * @returns {Credentials}\n */\n initialize(attrs, options) {\n if (attrs) {\n if (typeof attrs === 'string') {\n this.supertoken = attrs;\n }\n\n if (attrs.access_token) {\n this.supertoken = attrs;\n }\n\n if (attrs.authorization) {\n if (attrs.authorization.supertoken) {\n this.supertoken = attrs.authorization.supertoken;\n } else {\n this.supertoken = attrs.authorization;\n }\n }\n\n // schedule refresh\n if (this.supertoken && this.supertoken.expires) {\n this.scheduleRefresh(this.supertoken.expires);\n }\n }\n\n Reflect.apply(WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n this.listenToOnce(this.parent, 'change:config', () => {\n if (this.config.authorizationString) {\n const parsed = url.parse(this.config.authorizationString, true);\n\n /* eslint-disable camelcase */\n this.config.client_id = parsed.query.client_id;\n this.config.redirect_uri = parsed.query.redirect_uri;\n this.config.scope = parsed.query.scope;\n this.config.authorizeUrl = parsed.href.substr(0, parsed.href.indexOf('?'));\n /* eslint-enable camelcase */\n }\n });\n\n this.webex.once('loaded', () => {\n this.ready = true;\n });\n },\n\n @oneFlight\n @waitForValue('@')\n /**\n * Clears all tokens from store them from the stores.\n *\n * This is no longer quite the right name for this method, but all of the\n * alternatives I'm coming up with are already taken.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n invalidate() {\n this.logger.info('credentials: invalidating tokens');\n\n // clear refresh timer\n if (this.refreshTimer) {\n clearTimeout(this.refreshTimer);\n this.unset('refreshTimer');\n }\n\n try {\n this.unset('supertoken');\n } catch (err) {\n this.logger.warn('credentials: failed to clear supertoken', err);\n }\n\n while (this.userTokens.models.length) {\n try {\n this.userTokens.remove(this.userTokens.models[0]);\n } catch (err) {\n this.logger.warn('credentials: failed to remove user token', err);\n }\n }\n\n this.logger.info('credentials: finished removing tokens');\n\n // Return a promise to give the storage layer a tick or two to clear\n // localStorage\n return Promise.resolve();\n },\n\n @oneFlight\n @whileInFlight('isRefreshing')\n @waitForValue('@')\n /**\n * Removes the supertoken and child tokens, then refreshes the supertoken;\n * subsequent calls to {@link Credentials#getUserToken()} will re-downscope\n * child tokens. Enqueus revocation of previous previousTokens. Yes, that's\n * the correct number of \"previous\"es.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n refresh() {\n this.logger.info('credentials: refresh requested');\n\n const {supertoken} = this;\n const tokens = clone(this.userTokens.models);\n\n // This is kind of a leaky abstraction, since it relies on the authorization\n // plugin, but the only alternatives I see are\n // 1. put all JWT support in core\n // 2. have separate jwt and non-jwt auth plugins\n // while I like #2 from a code simplicity standpoint, the third-party DX\n // isn't great\n if (this.config.jwtRefreshCallback) {\n return (\n this.config\n .jwtRefreshCallback(this.webex)\n // eslint-disable-next-line no-shadow\n .then((jwt) => this.webex.authorization.requestAccessTokenFromJwt({jwt}))\n );\n }\n\n if (this.webex.internal.services) {\n this.webex.internal.services.updateCredentialsConfig();\n }\n\n return supertoken\n .refresh()\n .catch((error) => {\n if (error instanceof OAuthError) {\n // Error: super token refresh failed with 400 status code.\n // Hence emit an event to the client, an opportunity to logout.\n this.unset('supertoken');\n while (this.userTokens.models.length) {\n try {\n this.userTokens.remove(this.userTokens.models[0]);\n } catch (err) {\n this.logger.warn('credentials: failed to remove user token', err);\n }\n }\n this.webex.trigger('client:InvalidRequestError');\n }\n\n return Promise.reject(error);\n })\n .then((st) => {\n // clear refresh timer\n if (this.refreshTimer) {\n clearTimeout(this.refreshTimer);\n this.unset('refreshTimer');\n }\n this.supertoken = st;\n\n const invalidScopes = diffScopes(this.config.scope, st.scope);\n\n if (invalidScopes !== '') {\n this.logger.warn(\n `credentials: \"${invalidScopes}\" scope(s) are invalid because not listed in the supertoken, they will be excluded from user token requests.`\n );\n this.webex.internal.metrics.submitClientMetrics(\n METRICS.JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH,\n {fields: {invalidScopes}}\n );\n }\n\n return Promise.all(\n tokens.map((token) => {\n const tokenScope = filterScope(diffScopes(token.scope, st.scope), token.scope);\n\n return (\n this.downscope(tokenScope)\n // eslint-disable-next-line max-nested-callbacks\n .then((t) => {\n this.logger.info(`credentials: revoking token for ${token.scope}`);\n\n return token\n .revoke()\n .catch((err) => {\n this.logger.warn('credentials: failed to revoke user token', err);\n })\n .then(() => {\n this.userTokens.remove(token.scope);\n this.userTokens.add(t);\n });\n })\n );\n })\n );\n })\n .then(() => {\n this.scheduleRefresh(this.supertoken.expires);\n });\n },\n\n /**\n * Schedules a token refresh or refreshes the token if token has expired\n * @instance\n * @memberof Credentials\n * @param {number} expires\n * @private\n * @returns {undefined}\n */\n scheduleRefresh(expires) {\n const expiresIn = expires - Date.now();\n\n if (expiresIn > 0) {\n const timeoutLength = this.calcRefreshTimeout(expiresIn);\n\n this.refreshTimer = safeSetTimeout(() => this.refresh(), timeoutLength);\n } else {\n this.refresh();\n }\n },\n});\n\nexport default Credentials;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAEA,IAAAQ,YAAA,GAAAC,uBAAA,CAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,gBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,UAAA,GAAAb,OAAA;AAAqC,IAAAc,IAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,IAAA;AAnBrC;AACA;AACA;AAFA,SAAAX,wBAAAY,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAd,uBAAA,YAAAA,wBAAAY,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,gBAAAW,OAAA,CA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IAAA,GAAAA,IAAA,CA4HX,CAAC;AAAC,IAAAmO,QAAA,GAAAC,OAAA,CAAAzN,OAAA,GAEYyB,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["_querystring","_interopRequireDefault","require","_url","_jsonwebtoken","_common","_commonTimers","_lodash","_webexPlugin","_decorators","_grantErrors","_interopRequireWildcard","_scope","_token","_tokenCollection","_constants","_dec","_dec2","_dec3","_dec4","_dec5","_dec6","_obj","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor2","ownKeys","_Object$keys2","_Object$getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","_Object$getOwnPropertyDescriptors","_Object$defineProperties","Credentials","WebexPlugin","extend","oneFlight","keyFactory","scope","waitForValue","persist","whileInFlight","collections","userTokens","TokenCollection","dataTypes","token","makeStateDataType","Token","dataType","derived","canAuthorize","deps","fn","Boolean","supertoken","canRefresh","config","jwtRefreshCallback","isUnverifiedGuest","isGuest","JSON","parse","base64","decode","access_token","split","user_type","_unused","props","prop","namespace","session","isRefreshing","type","ready","refreshTimer","undefined","buildLoginUrl","options","clientType","state","isObject","Error","client_id","redirect_uri","cloneDeep","response_type","_deleteProperty","isEmpty","encodeState","concat","authorizeUrl","querystring","stringify","getOrgId","logger","info","extractOrgIdFromJWT","_this$supertoken","extractOrgIdFromUserToken","decodedJWT","jwt","realm","fields","buildThirdPartyLoginUrl","oauth2provider","returnURL","query","thirdPartyLoginUrl","buildLogoutUrl","logoutUrl","cisService","service","goto","calcRefreshTimeout","expiration","Math","floor","random","constructor","_this","_dataTypes","_keys","key","bind","_len","args","Array","_key","_apply","downscope","_this2","catch","reason","_reason$body","failReason","body","warn","trace","webex","internal","metrics","submitClientMetrics","METRICS","JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED","requestedScope","_promise","resolve","serialize","parent","getClientToken","_this3","request","method","uri","tokenUrl","form","grant_type","self_contained_token","auth","user","pass","client_secret","sendImmediately","shouldRefreshAccessToken","then","res","statusCode","reject","ErrorConstructor","grantErrors","select","error","_res","getUserToken","_this4","once","filterScope","sortScope","tap","add","initialize","attrs","_this5","authorization","expires","scheduleRefresh","prototype","listenToOnce","authorizationString","parsed","url","href","substr","indexOf","invalidate","clearTimeout","unset","err","models","remove","refresh","_this6","tokens","clone","requestAccessTokenFromJwt","services","updateCredentialsConfig","OAuthError","trigger","st","invalidScopes","diffScopes","JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH","all","map","tokenScope","revoke","_this7","expiresIn","_now","timeoutLength","safeSetTimeout","version","_applyDecoratedDescriptor2","_getOwnPropertyDescriptor","_default","exports"],"sources":["credentials.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport querystring from 'querystring';\nimport url from 'url';\n\nimport jwt from 'jsonwebtoken';\nimport {base64, encodeState, makeStateDataType, oneFlight, tap, whileInFlight} from '@webex/common';\nimport {safeSetTimeout} from '@webex/common-timers';\nimport {clone, cloneDeep, isObject, isEmpty} from 'lodash';\n\nimport WebexPlugin from '../webex-plugin';\nimport {persist, waitForValue} from '../storage/decorators';\n\nimport grantErrors, {OAuthError} from './grant-errors';\nimport {filterScope, diffScopes, sortScope} from './scope';\nimport Token from './token';\nimport TokenCollection from './token-collection';\nimport {METRICS} from '../constants';\n\n/**\n * @class\n */\nconst Credentials = WebexPlugin.extend({\n collections: {\n userTokens: TokenCollection,\n },\n\n dataTypes: {\n token: makeStateDataType(Token, 'token').dataType,\n },\n\n derived: {\n canAuthorize: {\n deps: ['supertoken', 'supertoken.canAuthorize', 'canRefresh'],\n fn() {\n return Boolean((this.supertoken && this.supertoken.canAuthorize) || this.canRefresh);\n },\n },\n canRefresh: {\n deps: ['supertoken', 'supertoken.canRefresh'],\n fn() {\n // If we're operating in JWT mode, we have to delegate to the consumer\n if (this.config.jwtRefreshCallback) {\n return true;\n }\n\n return Boolean(this.supertoken && this.supertoken.canRefresh);\n },\n },\n isUnverifiedGuest: {\n deps: ['supertoken'],\n /**\n * Returns true if the user is an unverified guest\n * @returns {boolean}\n */\n fn() {\n let isGuest = false;\n try {\n isGuest =\n JSON.parse(base64.decode(this.supertoken.access_token.split('.')[1])).user_type ===\n 'guest';\n } catch {\n /* the non-guest token is formatted differently so catch is expected */\n }\n\n return isGuest;\n },\n },\n },\n\n props: {\n supertoken: makeStateDataType(Token, 'token').prop,\n },\n\n namespace: 'Credentials',\n\n session: {\n isRefreshing: {\n default: false,\n type: 'boolean',\n },\n /**\n * Becomes `true` once the {@link loaded} event fires.\n * @see {@link WebexPlugin#ready}\n * @instance\n * @memberof Credentials\n * @type {boolean}\n */\n ready: {\n default: false,\n type: 'boolean',\n },\n refreshTimer: {\n default: undefined,\n type: 'any',\n },\n },\n\n /**\n * Generates an OAuth Login URL. Prefers the api.ciscospark.com proxy if the\n * instance is initialize with an authorizatUrl, but fallsback to idbroker\n * as the base otherwise.\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {string}\n */\n buildLoginUrl(options = {clientType: 'public'}) {\n /* eslint-disable camelcase */\n if (options.state !== undefined && !isObject(options.state)) {\n throw new Error('if specified, `options.state` must be an object');\n }\n\n options.client_id = this.config.client_id;\n options.redirect_uri = this.config.redirect_uri;\n options.scope = this.config.scope;\n\n options = cloneDeep(options);\n\n if (!options.response_type) {\n options.response_type = options.clientType === 'public' ? 'token' : 'code';\n }\n Reflect.deleteProperty(options, 'clientType');\n\n if (options.state) {\n if (!isEmpty(options.state)) {\n options.state = encodeState(options.state);\n } else {\n delete options.state;\n }\n }\n\n return `${this.config.authorizeUrl}?${querystring.stringify(options)}`;\n /* eslint-enable camelcase */\n },\n\n /**\n * Get the determined OrgId.\n *\n * @throws {Error} - If the OrgId could not be determined.\n * @returns {string} - The OrgId.\n */\n getOrgId() {\n this.logger.info('credentials: attempting to retrieve the OrgId from token');\n\n try {\n // Attempt to extract a client-authenticated token's OrgId.\n this.logger.info('credentials: trying to extract OrgId from JWT');\n\n return this.extractOrgIdFromJWT(this.supertoken.access_token);\n } catch (e) {\n // Attempt to extract a user token's OrgId.\n this.logger.info('credentials: could not extract OrgId from JWT');\n this.logger.info('credentials: attempting to extract OrgId from user token');\n\n try {\n return this.extractOrgIdFromUserToken(this.supertoken?.access_token);\n } catch (f) {\n this.logger.info('credentials: could not extract OrgId from user token');\n throw f;\n }\n }\n },\n\n /**\n * Extract the OrgId [realm] from a provided JWT.\n *\n * @private\n * @param {string} token - The JWT to extract the OrgId from.\n * @throws {Error} - If the token does not pass JWT general/realm validation.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromJWT(token = '') {\n // Decoded the provided token.\n const decodedJWT = jwt.decode(token);\n\n // Validate that the provided token is a JWT.\n if (!decodedJWT) {\n throw new Error('unable to extract the OrgId from the provided JWT');\n }\n\n if (!decodedJWT.realm) {\n throw new Error('the provided JWT does not contain an OrgId');\n }\n\n // Return the OrgId [realm].\n return decodedJWT.realm;\n },\n\n /**\n * Extract the OrgId [realm] from a provided user token.\n *\n * @private\n * @param {string} token - The user token to extract the OrgId from.\n * @throws {Error} - Will throw an error if the provided token is invalid.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromUserToken(token = '') {\n // Split the provided token into subsections.\n const fields = token.split('_');\n\n // Validate that the provided token has the proper amount of sections.\n if (fields.length !== 3) {\n throw new Error(\n `the provided token is not a valid format, token has ${fields.length} sections`\n );\n }\n\n // Return the token section that contains the OrgId.\n return fields[2];\n },\n\n /**\n * Generates a Third-Party Login URL pointing at IdBroker's\n * `/idb/ThirdPartyLogin` endpoint. Used by the social-provider sign-in\n * flow (Google / Microsoft / Apple / ...).\n *\n * Mirrors `buildLoginUrl` / `buildLogoutUrl` — pure URL construction,\n * no navigation side effects. Reads from `this.config.thirdPartyLoginUrl`,\n * which is derived from `idbroker.url` in `credentials-config.js`.\n *\n * @instance\n * @memberof Credentials\n * @param {Object} options\n * @param {string} options.oauth2provider - Provider name (`google`,\n * `microsoft`, `apple`, ...). Required.\n * @param {string} options.returnURL - URL IdBroker should send the user\n * back to after the third-party hand-off. Required.\n * @param {Object} [options.state] - Optional state object. When non-empty\n * it is JSON-stringified and base64url-encoded, then emitted as the\n * top-level `state` query param so IdBroker can echo it back unchanged\n * on the callback (mirrors `buildLoginUrl`).\n * @returns {string}\n */\n buildThirdPartyLoginUrl(options = {}) {\n const {oauth2provider, returnURL, state} = options;\n\n if (!oauth2provider) {\n throw new Error('`options.oauth2provider` is required');\n }\n if (!returnURL) {\n throw new Error('`options.returnURL` is required');\n }\n if (state !== undefined && !isObject(state)) {\n throw new Error('if specified, `options.state` must be an object');\n }\n\n const query = {\n oauth2provider,\n returnURL,\n };\n\n if (state && !isEmpty(state)) {\n query.state = encodeState(state);\n }\n\n return `${this.config.thirdPartyLoginUrl}?${querystring.stringify(query)}`;\n },\n\n /**\n * Generates a Logout URL\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {[type]}\n */\n buildLogoutUrl(options = {}) {\n return `${this.config.logoutUrl}?${querystring.stringify({\n cisService: this.config.service,\n goto: this.config.redirect_uri,\n ...options,\n })}`;\n },\n\n /**\n * Generates a number between 60% - 90% of expired value\n * @instance\n * @memberof Credentials\n * @param {number} expiration\n * @private\n * @returns {number}\n */\n calcRefreshTimeout(expiration) {\n return Math.floor(((Math.floor(Math.random() * 4) + 6) / 10) * expiration);\n },\n\n constructor(...args) {\n // HACK to deal with the fact that AmpersandState#dataTypes#set is a pure\n // function.\n this._dataTypes = cloneDeep(this._dataTypes);\n Object.keys(this._dataTypes).forEach((key) => {\n if (this._dataTypes[key].set) {\n this._dataTypes[key].set = this._dataTypes[key].set.bind(this);\n }\n });\n // END HACK\n Reflect.apply(WebexPlugin, this, args);\n },\n\n /**\n * Downscopes a token\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @private\n * @returns {Promise<Token>}\n */\n downscope(scope) {\n return this.supertoken.downscope(scope).catch((reason) => {\n const failReason = reason?.body ?? reason;\n this.logger.warn(`credentials: failed to downscope supertoken to \"${scope}\"`, failReason);\n this.logger.trace(`credentials: falling back to supertoken for ${scope}`);\n this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED, {\n fields: {\n requestedScope: scope,\n failReason,\n },\n });\n\n return Promise.resolve(new Token({scope, ...this.supertoken.serialize()}), {\n parent: this,\n });\n });\n },\n\n /**\n * Requests a client credentials grant and returns the token. Given the\n * limited use for such tokens as this time, this method does not cache its\n * token.\n * @instance\n * @memberof Credentials\n * @param {Object} options\n * @returns {Promise<Token>}\n */\n getClientToken(options = {}) {\n this.logger.info('credentials: requesting client credentials grant');\n\n return this.webex\n .request({\n /* eslint-disable camelcase */\n method: 'POST',\n uri: options.uri || this.config.tokenUrl,\n form: {\n grant_type: 'client_credentials',\n scope: options.scope || 'webexsquare:admin',\n self_contained_token: true,\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true,\n },\n shouldRefreshAccessToken: false,\n /* eslint-enable camelcase */\n })\n .then((res) => new Token(res.body, {parent: this}))\n .catch((res) => {\n if (res.statusCode !== 400) {\n return Promise.reject(res);\n }\n\n const ErrorConstructor = grantErrors.select(res.body.error);\n\n return Promise.reject(new ErrorConstructor(res._res || res));\n });\n },\n\n @oneFlight({keyFactory: (scope) => scope})\n @waitForValue('@')\n /**\n * Resolves with a token with the specified scopes. If no scope is specified,\n * defaults to omit(webex.credentials.scope, 'spark:kms'). If no such token is\n * available, downscopes the supertoken to that scope.\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @returns {Promise<Token>}\n */\n getUserToken(scope) {\n return Promise.resolve(\n !this.isRefreshing ||\n new Promise((resolve) => {\n this.logger.info(\n 'credentials: token refresh inflight; delaying getUserToken until refresh completes'\n );\n this.once('change:isRefreshing', () => {\n this.logger.info('credentials: token refresh complete; reinvoking getUserToken');\n resolve();\n });\n })\n ).then(() => {\n if (!this.canAuthorize) {\n this.logger.info('credentials: cannot produce an access token from current state');\n\n return Promise.reject(new Error('Current state cannot produce an access token'));\n }\n\n if (!scope) {\n scope = filterScope('spark:kms', this.supertoken.scope);\n }\n\n scope = sortScope(scope);\n\n if (scope === sortScope(this.supertoken.scope)) {\n return Promise.resolve(this.supertoken);\n }\n\n const token = this.userTokens.get(scope);\n\n // we should also check for the token.access_token since token object does\n // not get cleared on unsetting while logging out.\n if (!token || !token.access_token) {\n return this.downscope(scope).then(tap((t) => this.userTokens.add(t)));\n }\n\n return Promise.resolve(token);\n });\n },\n\n @persist('@')\n /**\n * Initializer\n * @instance\n * @memberof Credentials\n * @param {Object} attrs\n * @param {Object} options\n * @private\n * @returns {Credentials}\n */\n initialize(attrs, options) {\n if (attrs) {\n if (typeof attrs === 'string') {\n this.supertoken = attrs;\n }\n\n if (attrs.access_token) {\n this.supertoken = attrs;\n }\n\n if (attrs.authorization) {\n if (attrs.authorization.supertoken) {\n this.supertoken = attrs.authorization.supertoken;\n } else {\n this.supertoken = attrs.authorization;\n }\n }\n\n // schedule refresh\n if (this.supertoken && this.supertoken.expires) {\n this.scheduleRefresh(this.supertoken.expires);\n }\n }\n\n Reflect.apply(WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n this.listenToOnce(this.parent, 'change:config', () => {\n if (this.config.authorizationString) {\n const parsed = url.parse(this.config.authorizationString, true);\n\n /* eslint-disable camelcase */\n this.config.client_id = parsed.query.client_id;\n this.config.redirect_uri = parsed.query.redirect_uri;\n this.config.scope = parsed.query.scope;\n this.config.authorizeUrl = parsed.href.substr(0, parsed.href.indexOf('?'));\n /* eslint-enable camelcase */\n }\n });\n\n this.webex.once('loaded', () => {\n this.ready = true;\n });\n },\n\n @oneFlight\n @waitForValue('@')\n /**\n * Clears all tokens from store them from the stores.\n *\n * This is no longer quite the right name for this method, but all of the\n * alternatives I'm coming up with are already taken.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n invalidate() {\n this.logger.info('credentials: invalidating tokens');\n\n // clear refresh timer\n if (this.refreshTimer) {\n clearTimeout(this.refreshTimer);\n this.unset('refreshTimer');\n }\n\n try {\n this.unset('supertoken');\n } catch (err) {\n this.logger.warn('credentials: failed to clear supertoken', err);\n }\n\n while (this.userTokens.models.length) {\n try {\n this.userTokens.remove(this.userTokens.models[0]);\n } catch (err) {\n this.logger.warn('credentials: failed to remove user token', err);\n }\n }\n\n this.logger.info('credentials: finished removing tokens');\n\n // Return a promise to give the storage layer a tick or two to clear\n // localStorage\n return Promise.resolve();\n },\n\n @oneFlight\n @whileInFlight('isRefreshing')\n @waitForValue('@')\n /**\n * Removes the supertoken and child tokens, then refreshes the supertoken;\n * subsequent calls to {@link Credentials#getUserToken()} will re-downscope\n * child tokens. Enqueus revocation of previous previousTokens. Yes, that's\n * the correct number of \"previous\"es.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n refresh() {\n this.logger.info('credentials: refresh requested');\n\n const {supertoken} = this;\n const tokens = clone(this.userTokens.models);\n\n // This is kind of a leaky abstraction, since it relies on the authorization\n // plugin, but the only alternatives I see are\n // 1. put all JWT support in core\n // 2. have separate jwt and non-jwt auth plugins\n // while I like #2 from a code simplicity standpoint, the third-party DX\n // isn't great\n if (this.config.jwtRefreshCallback) {\n return (\n this.config\n .jwtRefreshCallback(this.webex)\n // eslint-disable-next-line no-shadow\n .then((jwt) => this.webex.authorization.requestAccessTokenFromJwt({jwt}))\n );\n }\n\n if (this.webex.internal.services) {\n this.webex.internal.services.updateCredentialsConfig();\n }\n\n return supertoken\n .refresh()\n .catch((error) => {\n if (error instanceof OAuthError) {\n // Error: super token refresh failed with 400 status code.\n // Hence emit an event to the client, an opportunity to logout.\n this.unset('supertoken');\n while (this.userTokens.models.length) {\n try {\n this.userTokens.remove(this.userTokens.models[0]);\n } catch (err) {\n this.logger.warn('credentials: failed to remove user token', err);\n }\n }\n this.webex.trigger('client:InvalidRequestError');\n }\n\n return Promise.reject(error);\n })\n .then((st) => {\n // clear refresh timer\n if (this.refreshTimer) {\n clearTimeout(this.refreshTimer);\n this.unset('refreshTimer');\n }\n this.supertoken = st;\n\n const invalidScopes = diffScopes(this.config.scope, st.scope);\n\n if (invalidScopes !== '') {\n this.logger.warn(\n `credentials: \"${invalidScopes}\" scope(s) are invalid because not listed in the supertoken, they will be excluded from user token requests.`\n );\n this.webex.internal.metrics.submitClientMetrics(\n METRICS.JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH,\n {fields: {invalidScopes}}\n );\n }\n\n return Promise.all(\n tokens.map((token) => {\n const tokenScope = filterScope(diffScopes(token.scope, st.scope), token.scope);\n\n return (\n this.downscope(tokenScope)\n // eslint-disable-next-line max-nested-callbacks\n .then((t) => {\n this.logger.info(`credentials: revoking token for ${token.scope}`);\n\n return token\n .revoke()\n .catch((err) => {\n this.logger.warn('credentials: failed to revoke user token', err);\n })\n .then(() => {\n this.userTokens.remove(token.scope);\n this.userTokens.add(t);\n });\n })\n );\n })\n );\n })\n .then(() => {\n this.scheduleRefresh(this.supertoken.expires);\n });\n },\n\n /**\n * Schedules a token refresh or refreshes the token if token has expired\n * @instance\n * @memberof Credentials\n * @param {number} expires\n * @private\n * @returns {undefined}\n */\n scheduleRefresh(expires) {\n const expiresIn = expires - Date.now();\n\n if (expiresIn > 0) {\n const timeoutLength = this.calcRefreshTimeout(expiresIn);\n\n this.refreshTimer = safeSetTimeout(() => this.refresh(), timeoutLength);\n } else {\n this.refresh();\n }\n },\n});\n\nexport default Credentials;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,YAA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AAC,0BAAA,CAAAzN,OAAA,EAAAX,IAAA,mBAAAN,IAAA,EAAAC,KAAA,OAAA0O,yBAAA,CAAA1N,OAAA,EAAAX,IAAA,mBAAAA,IAAA,OAAAoO,0BAAA,CAAAzN,OAAA,EAAAX,IAAA,iBAAAJ,KAAA,OAAAyO,yBAAA,CAAA1N,OAAA,EAAAX,IAAA,iBAAAA,IAAA,OAAAoO,0BAAA,CAAAzN,OAAA,EAAAX,IAAA,iBArKEuC,iBAAS,EAAA1C,KAAA,OAAAwO,yBAAA,CAAA1N,OAAA,EAAAX,IAAA,iBAAAA,IAAA,OAAAoO,0BAAA,CAAAzN,OAAA,EAAAX,IAAA,cAyCTuC,iBAAS,EAAAzC,KAAA,EAAAC,KAAA,OAAAsO,yBAAA,CAAA1N,OAAA,EAAAX,IAAA,cAAAA,IAAA,GAAAA,IAAA,CA4HX,CAAC;AAAC,IAAAsO,QAAA,GAAAC,OAAA,CAAA5N,OAAA,GAEYyB,WAAW","ignoreList":[]}
@@ -532,7 +532,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
532
532
  return res.body;
533
533
  });
534
534
  },
535
- version: "0.0.0"
535
+ version: "3.12.0-llmrefactor.1"
536
536
  }, (0, _applyDecoratedDescriptor2.default)(_obj, "downscope", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "downscope"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "revoke", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "revoke"), _obj), _obj));
537
537
  var _default = exports.default = Token;
538
538
  //# sourceMappingURL=token.js.map
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.normalizeAllowedDomains = exports.matchAllowedDomain = exports.default = void 0;
9
+ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
10
+ var _url = _interopRequireDefault(require("url"));
11
+ var _lodash = require("lodash");
12
+ // Canonicalise a hostname for comparison: lowercase, drop the brackets around
13
+ // an IPv6 literal, and drop leading/trailing dots. DNS treats `Example.com`,
14
+ // `example.com.` and `example.com` as the same name.
15
+ //
16
+ // Node's `url.domainToASCII` looks like the standard way to do this, but the
17
+ // `url` polyfill this package bundles for the browser does not implement it,
18
+ // so it cannot be used here. It also leaves trailing dots in place.
19
+ var normalizeHostname = function normalizeHostname(value) {
20
+ return typeof value === 'string' ? value.toLowerCase().replace(/^\[|\]$/g, '').replace(/^\.+/, '').replace(/\.+$/, '') : '';
21
+ };
22
+
23
+ /**
24
+ * Canonicalise a list of configured allowed domains, discarding any entry that
25
+ * is not a usable hostname. Callers normalise on the way in so the stored list
26
+ * is already canonical, rather than re-deriving it on every request.
27
+ *
28
+ * @param {Array<string>} allowedDomains - The configured allowed domains.
29
+ * @returns {Array<string>} - Normalized, de-duplicated, non-empty entries.
30
+ */
31
+ var normalizeAllowedDomains = exports.normalizeAllowedDomains = function normalizeAllowedDomains(allowedDomains) {
32
+ return (0, _lodash.uniq)(((0, _isArray.default)(allowedDomains) ? allowedDomains : []).map(normalizeHostname).filter(Boolean));
33
+ };
34
+
35
+ /**
36
+ * Determine if a hostname is covered by an allowed domain, matching only on DNS
37
+ * label boundaries, so that a hostname is allowed only when it is the domain
38
+ * itself or a subdomain of it. Matching on a substring instead would treat
39
+ * unrelated hostnames that merely contain the domain as allowed.
40
+ *
41
+ * @param {string} hostname - Hostname to test. Must not include a port.
42
+ * @param {string} allowedDomain - The configured allowed domain.
43
+ * @returns {boolean} - True when the hostname is the domain or a subdomain of it.
44
+ */
45
+ var hostnameMatchesDomain = function hostnameMatchesDomain(hostname, allowedDomain) {
46
+ // The stored list is normalized on write, but `allowedDomains` is a public
47
+ // property, so normalize again here rather than trust it.
48
+ var host = normalizeHostname(hostname);
49
+ var domain = normalizeHostname(allowedDomain);
50
+ return !!host && !!domain && (host === domain || host.endsWith(".".concat(domain)));
51
+ };
52
+
53
+ /**
54
+ * Find the allowed domain covering a url, or `undefined` if there is none.
55
+ *
56
+ * Parsing lives here rather than in the callers, and deliberately uses both url
57
+ * parsers, because this check gates an `Authorization` header. The two
58
+ * transports behind `@webex/http-core` do not use the same url parser: the
59
+ * browser transport parses per WHATWG, the node transport uses Node's legacy
60
+ * `Url.parse`, and for some inputs the two resolve different hosts.
61
+ *
62
+ * Rather than picking one, require both to agree and fail closed when they do
63
+ * not, so this check can never authorize a host that differs from the one a
64
+ * transport would actually connect to. Do not narrow this to a single parser.
65
+ *
66
+ * @param {string} url - The url to match the allowed domains against.
67
+ * @param {Array<string>} allowedDomains - The configured allowed domains.
68
+ * @returns {string} - The matching allowed domain, or undefined if there is none.
69
+ */
70
+ var matchAllowedDomain = exports.matchAllowedDomain = function matchAllowedDomain(url, allowedDomains) {
71
+ var hostname;
72
+ var legacyHostname;
73
+ try {
74
+ var _URL = new URL(url);
75
+ hostname = _URL.hostname;
76
+ var _Url$parse = _url.default.parse(url);
77
+ legacyHostname = _Url$parse.hostname;
78
+ } catch (_unused) {
79
+ // Not a parsable absolute url, so it cannot belong to an allowed domain.
80
+ return undefined;
81
+ }
82
+ if (normalizeHostname(hostname) !== normalizeHostname(legacyHostname)) {
83
+ return undefined;
84
+ }
85
+ return (allowedDomains || []).find(function (allowedDomain) {
86
+ return hostnameMatchesDomain(hostname, allowedDomain);
87
+ });
88
+ };
89
+ var _default = exports.default = matchAllowedDomain;
90
+ //# sourceMappingURL=domains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_url","_interopRequireDefault","require","_lodash","normalizeHostname","value","toLowerCase","replace","normalizeAllowedDomains","exports","allowedDomains","uniq","_isArray","default","map","filter","Boolean","hostnameMatchesDomain","hostname","allowedDomain","host","domain","endsWith","concat","matchAllowedDomain","url","legacyHostname","_URL","URL","_Url$parse","Url","parse","_unused","undefined","find","_default"],"sources":["domains.ts"],"sourcesContent":["import Url from 'url';\n\nimport {uniq} from 'lodash';\n\n// Canonicalise a hostname for comparison: lowercase, drop the brackets around\n// an IPv6 literal, and drop leading/trailing dots. DNS treats `Example.com`,\n// `example.com.` and `example.com` as the same name.\n//\n// Node's `url.domainToASCII` looks like the standard way to do this, but the\n// `url` polyfill this package bundles for the browser does not implement it,\n// so it cannot be used here. It also leaves trailing dots in place.\nconst normalizeHostname = (value: string): string =>\n typeof value === 'string'\n ? value\n .toLowerCase()\n .replace(/^\\[|\\]$/g, '')\n .replace(/^\\.+/, '')\n .replace(/\\.+$/, '')\n : '';\n\n/**\n * Canonicalise a list of configured allowed domains, discarding any entry that\n * is not a usable hostname. Callers normalise on the way in so the stored list\n * is already canonical, rather than re-deriving it on every request.\n *\n * @param {Array<string>} allowedDomains - The configured allowed domains.\n * @returns {Array<string>} - Normalized, de-duplicated, non-empty entries.\n */\nexport const normalizeAllowedDomains = (allowedDomains: Array<string>): Array<string> =>\n uniq(\n (Array.isArray(allowedDomains) ? allowedDomains : []).map(normalizeHostname).filter(Boolean)\n );\n\n/**\n * Determine if a hostname is covered by an allowed domain, matching only on DNS\n * label boundaries, so that a hostname is allowed only when it is the domain\n * itself or a subdomain of it. Matching on a substring instead would treat\n * unrelated hostnames that merely contain the domain as allowed.\n *\n * @param {string} hostname - Hostname to test. Must not include a port.\n * @param {string} allowedDomain - The configured allowed domain.\n * @returns {boolean} - True when the hostname is the domain or a subdomain of it.\n */\nconst hostnameMatchesDomain = (hostname: string, allowedDomain: string): boolean => {\n // The stored list is normalized on write, but `allowedDomains` is a public\n // property, so normalize again here rather than trust it.\n const host = normalizeHostname(hostname);\n const domain = normalizeHostname(allowedDomain);\n\n return !!host && !!domain && (host === domain || host.endsWith(`.${domain}`));\n};\n\n/**\n * Find the allowed domain covering a url, or `undefined` if there is none.\n *\n * Parsing lives here rather than in the callers, and deliberately uses both url\n * parsers, because this check gates an `Authorization` header. The two\n * transports behind `@webex/http-core` do not use the same url parser: the\n * browser transport parses per WHATWG, the node transport uses Node's legacy\n * `Url.parse`, and for some inputs the two resolve different hosts.\n *\n * Rather than picking one, require both to agree and fail closed when they do\n * not, so this check can never authorize a host that differs from the one a\n * transport would actually connect to. Do not narrow this to a single parser.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @param {Array<string>} allowedDomains - The configured allowed domains.\n * @returns {string} - The matching allowed domain, or undefined if there is none.\n */\nexport const matchAllowedDomain = (\n url: string,\n allowedDomains: Array<string>\n): string | undefined => {\n let hostname: string;\n let legacyHostname: string;\n\n try {\n ({hostname} = new URL(url));\n ({hostname: legacyHostname} = Url.parse(url));\n } catch {\n // Not a parsable absolute url, so it cannot belong to an allowed domain.\n return undefined;\n }\n\n if (normalizeHostname(hostname) !== normalizeHostname(legacyHostname)) {\n return undefined;\n }\n\n return (allowedDomains || []).find((allowedDomain) =>\n hostnameMatchesDomain(hostname, allowedDomain)\n );\n};\n\nexport default matchAllowedDomain;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,KAAa;EAAA,OACtC,OAAOA,KAAK,KAAK,QAAQ,GACrBA,KAAK,CACFC,WAAW,CAAC,CAAC,CACbC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CACvBA,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACnBA,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GACtB,EAAE;AAAA;;AAER;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMC,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,SAA1BA,uBAAuBA,CAAIE,cAA6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CAACvB,cAAc,IAAI,EAAE,EAAEwB,IAAI,CAAC,UAACf,aAAa;IAAA,OAC/CF,qBAAqB,CAACC,QAAQ,EAAEC,aAAa,CAAC;EAAA,CAChD,CAAC;AACH,CAAC;AAAC,IAAAgB,QAAA,GAAA1B,OAAA,CAAAI,OAAA,GAEaW,kBAAkB","ignoreList":[]}
@@ -23,6 +23,7 @@ var _url = _interopRequireDefault(require("url"));
23
23
  var _ampersandState = _interopRequireDefault(require("ampersand-state"));
24
24
  var _lodash = require("lodash");
25
25
  var _serviceUrl = _interopRequireDefault(require("./service-url"));
26
+ var _domains = require("../domains");
26
27
  function ownKeys(e, r) { var t = _Object$keys3(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
28
29
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -283,19 +284,14 @@ var ServiceCatalog = _ampersandState.default.extend({
283
284
  });
284
285
  },
285
286
  /**
286
- * Finds an allowed domain that matches a specific url.
287
+ * Finds an allowed domain that matches a specific url. The url's hostname
288
+ * must be the allowed domain itself or a subdomain of it.
287
289
  *
288
290
  * @param {string} url - The url to match the allowed domains against.
289
291
  * @returns {string} - The matching allowed domain.
290
292
  */
291
293
  findAllowedDomain: function findAllowedDomain(url) {
292
- var urlObj = _url.default.parse(url);
293
- if (!urlObj.host) {
294
- return undefined;
295
- }
296
- return this.allowedDomains.find(function (allowedDomain) {
297
- return urlObj.host.includes(allowedDomain);
298
- });
294
+ return (0, _domains.matchAllowedDomain)(url, this.allowedDomains);
299
295
  },
300
296
  /**
301
297
  * Get a service url from the current services list by name.
@@ -363,7 +359,7 @@ var ServiceCatalog = _ampersandState.default.extend({
363
359
  * @returns {void}
364
360
  */
365
361
  setAllowedDomains: function setAllowedDomains(allowedDomains) {
366
- this.allowedDomains = (0, _toConsumableArray2.default)(allowedDomains);
362
+ this.allowedDomains = (0, _domains.normalizeAllowedDomains)(allowedDomains);
367
363
  },
368
364
  /**
369
365
  *
@@ -371,7 +367,7 @@ var ServiceCatalog = _ampersandState.default.extend({
371
367
  * @returns {void}
372
368
  */
373
369
  addAllowedDomains: function addAllowedDomains(newAllowedDomains) {
374
- this.allowedDomains = (0, _lodash.union)(this.allowedDomains, newAllowedDomains);
370
+ this.allowedDomains = (0, _lodash.union)(this.allowedDomains, (0, _domains.normalizeAllowedDomains)(newAllowedDomains));
375
371
  },
376
372
  /**
377
373
  * Update the current list of `ServiceUrl`s against a provided
@@ -1 +1 @@
1
- {"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","_lodash","_serviceUrl","ownKeys","e","r","t","_Object$keys3","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_createForOfIteratorHelper","_Symbol","_Symbol$iterator","_Array$isArray","_unsupportedIterableToArray","_n","F","s","n","done","value","f","TypeError","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","_Array$from","test","Array","ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","serviceGroup","serviceUrls","concat","_toConsumableArray2","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","_this","existingService","service","_unloadServiceUrls","_this2","splice","indexOf","clean","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","_i","_Object$keys","_keys","key","_iterator","_step","defaultUrl","_iterator2","hosts","_step2","host","hostname","id","err","_iterator3","_step3","homeCluster","undefined","findServiceFromClusterId","_ref","clusterId","_ref$priorityHost","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","startsWith","_iterator4","_step4","alternateUrl","URL","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","_this3","failHost","setAllowedDomains","addAllowedDomains","newAllowedDomains","union","updateServiceUrls","serviceHostmap","_this4","currentServiceUrls","unusedUrls","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","_this5","_promise","resolve","reject","validatedTimeout","timeoutTimer","setTimeout","Error","once","clearTimeout","_default","exports"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport {union} from 'lodash';\nimport ServiceUrl from './service-url';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceCatalog = AmpState.extend({\n namespace: 'ServiceCatalog',\n\n props: {\n serviceGroups: [\n 'object',\n true,\n () => ({\n discovery: [],\n override: [],\n preauth: [],\n postauth: [],\n signin: [],\n }),\n ],\n status: [\n 'object',\n true,\n () => ({\n discovery: {\n ready: false,\n collecting: false,\n },\n override: {\n ready: false,\n collecting: false,\n },\n preauth: {\n ready: false,\n collecting: false,\n },\n postauth: {\n ready: false,\n collecting: false,\n },\n signin: {\n ready: false,\n collecting: false,\n },\n }),\n ],\n isReady: ['boolean', false, false],\n allowedDomains: ['array', false, () => []],\n },\n\n /**\n * @private\n * Search the service url array to locate a `ServiceUrl`\n * class object based on its name.\n * @param {string} name\n * @param {string} [serviceGroup]\n * @returns {ServiceUrl}\n */\n _getUrl(name, serviceGroup) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n return serviceUrls.find((serviceUrl) => serviceUrl.name === name);\n },\n\n /**\n * @private\n * Generate an array of `ServiceUrl`s that is organized from highest auth\n * level to lowest auth level.\n * @returns {Array<ServiceUrl>} - array of `ServiceUrl`s\n */\n _listServiceUrls() {\n return [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n },\n\n /**\n * @private\n * Safely load one or more `ServiceUrl`s into this `Services` instance.\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _loadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (!existingService) {\n this.serviceGroups[serviceGroup].push(service);\n }\n });\n\n return this;\n },\n\n /**\n * @private\n * Safely unload one or more `ServiceUrl`s into this `Services` instance\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _unloadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (existingService) {\n this.serviceGroups[serviceGroup].splice(\n this.serviceGroups[serviceGroup].indexOf(existingService),\n 1\n );\n }\n });\n\n return this;\n },\n\n /**\n * Clear all collected catalog data and reset catalog status.\n *\n * @returns {void}\n */\n clean() {\n this.serviceGroups.preauth.length = 0;\n this.serviceGroups.signin.length = 0;\n this.serviceGroups.postauth.length = 0;\n this.status.preauth = {ready: false};\n this.status.signin = {ready: false};\n this.status.postauth = {ready: false};\n },\n\n /**\n * Search over all service groups to find a cluster id based\n * on a given url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {string} - ClusterId of a given url\n */\n findClusterId(url) {\n const incomingUrlObj = Url.parse(url);\n let serviceUrlObj;\n\n for (const key of Object.keys(this.serviceGroups)) {\n for (const service of this.serviceGroups[key]) {\n serviceUrlObj = Url.parse(service.defaultUrl);\n\n for (const host of service.hosts) {\n if (incomingUrlObj.hostname === host.host && host.id) {\n return host.id;\n }\n }\n\n if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {\n // no exact match, so try to grab the first home cluster\n for (const host of service.hosts) {\n if (host.homeCluster) {\n return host.id;\n }\n }\n\n // no match found still, so return the first entry\n return service.hosts[0].id;\n }\n }\n }\n\n return undefined;\n },\n\n /**\n * Search over all service groups and return a service value from a provided\n * clusterId. Currently, this method will return either a service name, or a\n * service url depending on the `value` parameter. If the `value` parameter\n * is set to `name`, it will return a service name to be utilized within the\n * Services plugin methods.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost = true] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n const identifiedServiceUrl = serviceUrls.find((serviceUrl) =>\n serviceUrl.hosts.find((host) => host.id === clusterId)\n );\n\n if (identifiedServiceUrl) {\n return {\n name: identifiedServiceUrl.name,\n url: identifiedServiceUrl.get(priorityHost, clusterId),\n };\n }\n\n return undefined;\n },\n\n /**\n * Find a service based on the provided url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {serviceUrl} - ServiceUrl assocated with provided url\n */\n findServiceUrlFromUrl(url) {\n const serviceUrls = [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n return serviceUrls.find((serviceUrl) => {\n // Check to see if the URL we are checking starts with the default URL\n if (url.startsWith(serviceUrl.defaultUrl)) {\n return true;\n }\n\n // If not, we check to see if the alternate URLs match\n // These are made by swapping the host of the default URL\n // with that of an alternate host\n for (const host of serviceUrl.hosts) {\n const alternateUrl = new URL(serviceUrl.defaultUrl);\n alternateUrl.host = host.host;\n\n if (url.startsWith(alternateUrl.toString())) {\n return true;\n }\n }\n\n return false;\n });\n },\n\n /**\n * Finds an allowed domain that matches a specific url.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @returns {string} - The matching allowed domain.\n */\n findAllowedDomain(url) {\n const urlObj = Url.parse(url);\n\n if (!urlObj.host) {\n return undefined;\n }\n\n return this.allowedDomains.find((allowedDomain) => urlObj.host.includes(allowedDomain));\n },\n\n /**\n * Get a service url from the current services list by name.\n * @param {string} name\n * @param {boolean} priorityHost\n * @param {string} serviceGroup\n * @returns {string}\n */\n get(name, priorityHost, serviceGroup) {\n const serviceUrl = this._getUrl(name, serviceGroup);\n\n return serviceUrl ? serviceUrl.get(priorityHost) : undefined;\n },\n\n /**\n * Get the current allowed domains list.\n *\n * @returns {Array<string>} - the current allowed domains list.\n */\n getAllowedDomains() {\n return [...this.allowedDomains];\n },\n\n /**\n * Creates an object where the keys are the service names\n * and the values are the service urls.\n * @param {boolean} priorityHost - use the highest priority if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list(priorityHost, serviceGroup) {\n const output = {};\n\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n if (serviceUrls) {\n serviceUrls.forEach((serviceUrl) => {\n output[serviceUrl.name] = serviceUrl.get(priorityHost);\n });\n }\n\n return output;\n },\n\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl(url, noPriorityHosts) {\n const serviceUrl = this._getUrl(\n Object.keys(this.list()).find((key) => this._getUrl(key).failHost(url))\n );\n\n if (!serviceUrl) {\n return undefined;\n }\n\n return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);\n },\n\n /**\n * Set the allowed domains for the catalog.\n *\n * @param {Array<string>} allowedDomains - allowed domains to be assigned.\n * @returns {void}\n */\n setAllowedDomains(allowedDomains) {\n this.allowedDomains = [...allowedDomains];\n },\n\n /**\n *\n * @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains\n * @returns {void}\n */\n addAllowedDomains(newAllowedDomains) {\n this.allowedDomains = union(this.allowedDomains, newAllowedDomains);\n },\n\n /**\n * Update the current list of `ServiceUrl`s against a provided\n * service hostmap.\n * @emits ServiceCatalog#preauthorized\n * @emits ServiceCatalog#postauthorized\n * @param {string} serviceGroup\n * @param {object} serviceHostmap\n * @returns {Services}\n */\n updateServiceUrls(serviceGroup, serviceHostmap) {\n const currentServiceUrls = this.serviceGroups[serviceGroup];\n\n const unusedUrls = currentServiceUrls.filter((serviceUrl) =>\n serviceHostmap.every((item) => item.name !== serviceUrl.name)\n );\n\n this._unloadServiceUrls(serviceGroup, unusedUrls);\n\n serviceHostmap.forEach((serviceObj) => {\n const service = this._getUrl(serviceObj.name, serviceGroup);\n\n if (service) {\n service.defaultUrl = serviceObj.defaultUrl;\n service.hosts = serviceObj.hosts || [];\n } else {\n this._loadServiceUrls(serviceGroup, [\n new ServiceUrl({\n ...serviceObj,\n }),\n ]);\n }\n });\n\n this.status[serviceGroup].ready = true;\n this.trigger(serviceGroup);\n\n return this;\n },\n\n /**\n * Wait until the service catalog is available,\n * or reject after a timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog(serviceGroup, timeout) {\n return new Promise((resolve, reject) => {\n if (this.status[serviceGroup].ready) {\n resolve();\n }\n\n const validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;\n\n const timeoutTimer = setTimeout(\n () =>\n reject(\n new Error(\n `services: timeout occured while waiting for '${serviceGroup}' catalog to populate`\n )\n ),\n validatedTimeout * 1000\n );\n\n this.once(serviceGroup, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceCatalog;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAuC,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,aAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,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A,GAEe8B,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","_lodash","_serviceUrl","_domains","ownKeys","e","r","t","_Object$keys3","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_createForOfIteratorHelper","_Symbol","_Symbol$iterator","_Array$isArray","_unsupportedIterableToArray","_n","F","s","n","done","value","f","TypeError","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","_Array$from","test","Array","ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","serviceGroup","serviceUrls","concat","_toConsumableArray2","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","_this","existingService","service","_unloadServiceUrls","_this2","splice","indexOf","clean","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","_i","_Object$keys","_keys","key","_iterator","_step","defaultUrl","_iterator2","hosts","_step2","host","hostname","id","err","_iterator3","_step3","homeCluster","undefined","findServiceFromClusterId","_ref","clusterId","_ref$priorityHost","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","startsWith","_iterator4","_step4","alternateUrl","URL","findAllowedDomain","matchAllowedDomain","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","_this3","failHost","setAllowedDomains","normalizeAllowedDomains","addAllowedDomains","newAllowedDomains","union","updateServiceUrls","serviceHostmap","_this4","currentServiceUrls","unusedUrls","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","_this5","_promise","resolve","reject","validatedTimeout","timeoutTimer","setTimeout","Error","once","clearTimeout","_default","exports"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport {union} from 'lodash';\nimport ServiceUrl from './service-url';\nimport {matchAllowedDomain, normalizeAllowedDomains} from '../domains';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceCatalog = AmpState.extend({\n namespace: 'ServiceCatalog',\n\n props: {\n serviceGroups: [\n 'object',\n true,\n () => ({\n discovery: [],\n override: [],\n preauth: [],\n postauth: [],\n signin: [],\n }),\n ],\n status: [\n 'object',\n true,\n () => ({\n discovery: {\n ready: false,\n collecting: false,\n },\n override: {\n ready: false,\n collecting: false,\n },\n preauth: {\n ready: false,\n collecting: false,\n },\n postauth: {\n ready: false,\n collecting: false,\n },\n signin: {\n ready: false,\n collecting: false,\n },\n }),\n ],\n isReady: ['boolean', false, false],\n allowedDomains: ['array', false, () => []],\n },\n\n /**\n * @private\n * Search the service url array to locate a `ServiceUrl`\n * class object based on its name.\n * @param {string} name\n * @param {string} [serviceGroup]\n * @returns {ServiceUrl}\n */\n _getUrl(name, serviceGroup) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n return serviceUrls.find((serviceUrl) => serviceUrl.name === name);\n },\n\n /**\n * @private\n * Generate an array of `ServiceUrl`s that is organized from highest auth\n * level to lowest auth level.\n * @returns {Array<ServiceUrl>} - array of `ServiceUrl`s\n */\n _listServiceUrls() {\n return [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n },\n\n /**\n * @private\n * Safely load one or more `ServiceUrl`s into this `Services` instance.\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _loadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (!existingService) {\n this.serviceGroups[serviceGroup].push(service);\n }\n });\n\n return this;\n },\n\n /**\n * @private\n * Safely unload one or more `ServiceUrl`s into this `Services` instance\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _unloadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (existingService) {\n this.serviceGroups[serviceGroup].splice(\n this.serviceGroups[serviceGroup].indexOf(existingService),\n 1\n );\n }\n });\n\n return this;\n },\n\n /**\n * Clear all collected catalog data and reset catalog status.\n *\n * @returns {void}\n */\n clean() {\n this.serviceGroups.preauth.length = 0;\n this.serviceGroups.signin.length = 0;\n this.serviceGroups.postauth.length = 0;\n this.status.preauth = {ready: false};\n this.status.signin = {ready: false};\n this.status.postauth = {ready: false};\n },\n\n /**\n * Search over all service groups to find a cluster id based\n * on a given url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {string} - ClusterId of a given url\n */\n findClusterId(url) {\n const incomingUrlObj = Url.parse(url);\n let serviceUrlObj;\n\n for (const key of Object.keys(this.serviceGroups)) {\n for (const service of this.serviceGroups[key]) {\n serviceUrlObj = Url.parse(service.defaultUrl);\n\n for (const host of service.hosts) {\n if (incomingUrlObj.hostname === host.host && host.id) {\n return host.id;\n }\n }\n\n if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {\n // no exact match, so try to grab the first home cluster\n for (const host of service.hosts) {\n if (host.homeCluster) {\n return host.id;\n }\n }\n\n // no match found still, so return the first entry\n return service.hosts[0].id;\n }\n }\n }\n\n return undefined;\n },\n\n /**\n * Search over all service groups and return a service value from a provided\n * clusterId. Currently, this method will return either a service name, or a\n * service url depending on the `value` parameter. If the `value` parameter\n * is set to `name`, it will return a service name to be utilized within the\n * Services plugin methods.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost = true] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n const identifiedServiceUrl = serviceUrls.find((serviceUrl) =>\n serviceUrl.hosts.find((host) => host.id === clusterId)\n );\n\n if (identifiedServiceUrl) {\n return {\n name: identifiedServiceUrl.name,\n url: identifiedServiceUrl.get(priorityHost, clusterId),\n };\n }\n\n return undefined;\n },\n\n /**\n * Find a service based on the provided url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {serviceUrl} - ServiceUrl assocated with provided url\n */\n findServiceUrlFromUrl(url) {\n const serviceUrls = [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n return serviceUrls.find((serviceUrl) => {\n // Check to see if the URL we are checking starts with the default URL\n if (url.startsWith(serviceUrl.defaultUrl)) {\n return true;\n }\n\n // If not, we check to see if the alternate URLs match\n // These are made by swapping the host of the default URL\n // with that of an alternate host\n for (const host of serviceUrl.hosts) {\n const alternateUrl = new URL(serviceUrl.defaultUrl);\n alternateUrl.host = host.host;\n\n if (url.startsWith(alternateUrl.toString())) {\n return true;\n }\n }\n\n return false;\n });\n },\n\n /**\n * Finds an allowed domain that matches a specific url. The url's hostname\n * must be the allowed domain itself or a subdomain of it.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @returns {string} - The matching allowed domain.\n */\n findAllowedDomain(url) {\n return matchAllowedDomain(url, this.allowedDomains);\n },\n\n /**\n * Get a service url from the current services list by name.\n * @param {string} name\n * @param {boolean} priorityHost\n * @param {string} serviceGroup\n * @returns {string}\n */\n get(name, priorityHost, serviceGroup) {\n const serviceUrl = this._getUrl(name, serviceGroup);\n\n return serviceUrl ? serviceUrl.get(priorityHost) : undefined;\n },\n\n /**\n * Get the current allowed domains list.\n *\n * @returns {Array<string>} - the current allowed domains list.\n */\n getAllowedDomains() {\n return [...this.allowedDomains];\n },\n\n /**\n * Creates an object where the keys are the service names\n * and the values are the service urls.\n * @param {boolean} priorityHost - use the highest priority if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list(priorityHost, serviceGroup) {\n const output = {};\n\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n if (serviceUrls) {\n serviceUrls.forEach((serviceUrl) => {\n output[serviceUrl.name] = serviceUrl.get(priorityHost);\n });\n }\n\n return output;\n },\n\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl(url, noPriorityHosts) {\n const serviceUrl = this._getUrl(\n Object.keys(this.list()).find((key) => this._getUrl(key).failHost(url))\n );\n\n if (!serviceUrl) {\n return undefined;\n }\n\n return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);\n },\n\n /**\n * Set the allowed domains for the catalog.\n *\n * @param {Array<string>} allowedDomains - allowed domains to be assigned.\n * @returns {void}\n */\n setAllowedDomains(allowedDomains) {\n this.allowedDomains = normalizeAllowedDomains(allowedDomains);\n },\n\n /**\n *\n * @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains\n * @returns {void}\n */\n addAllowedDomains(newAllowedDomains) {\n this.allowedDomains = union(this.allowedDomains, normalizeAllowedDomains(newAllowedDomains));\n },\n\n /**\n * Update the current list of `ServiceUrl`s against a provided\n * service hostmap.\n * @emits ServiceCatalog#preauthorized\n * @emits ServiceCatalog#postauthorized\n * @param {string} serviceGroup\n * @param {object} serviceHostmap\n * @returns {Services}\n */\n updateServiceUrls(serviceGroup, serviceHostmap) {\n const currentServiceUrls = this.serviceGroups[serviceGroup];\n\n const unusedUrls = currentServiceUrls.filter((serviceUrl) =>\n serviceHostmap.every((item) => item.name !== serviceUrl.name)\n );\n\n this._unloadServiceUrls(serviceGroup, unusedUrls);\n\n serviceHostmap.forEach((serviceObj) => {\n const service = this._getUrl(serviceObj.name, serviceGroup);\n\n if (service) {\n service.defaultUrl = serviceObj.defaultUrl;\n service.hosts = serviceObj.hosts || [];\n } else {\n this._loadServiceUrls(serviceGroup, [\n new ServiceUrl({\n ...serviceObj,\n }),\n ]);\n }\n });\n\n this.status[serviceGroup].ready = true;\n this.trigger(serviceGroup);\n\n return this;\n },\n\n /**\n * Wait until the service catalog is available,\n * or reject after a timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog(serviceGroup, timeout) {\n return new Promise((resolve, reject) => {\n if (this.status[serviceGroup].ready) {\n resolve();\n }\n\n const validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;\n\n const timeoutTimer = setTimeout(\n () =>\n reject(\n new Error(\n `services: timeout occured while waiting for '${serviceGroup}' catalog to populate`\n )\n ),\n validatedTimeout * 1000\n );\n\n this.once(serviceGroup, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceCatalog;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CA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