- Overview
- Architecture Overview
- Core Components
- Webex Object Creation Process
- Plugin System Architecture
- HTTP Request Pipeline
- Storage System
- Configuration Management
- Event System
- Detailed Code Flow Analysis
The Webex Core package (@webex/webex-core) serves as the foundational infrastructure for the Webex JavaScript SDK. It provides the basic framework for plugin registration, HTTP request handling, authentication, storage management, and event-driven architecture that all other Webex SDK functionality builds upon.
This technical documentation provides a comprehensive overview of the Webex Core package infrastructure, explaining the foundational systems that enable the entire Webex JavaScript SDK ecosystem. The architecture demonstrates a well-designed separation of concerns with clear plugin boundaries, robust HTTP handling, and flexible configuration management.
The Webex Core follows a layered architecture with clear separation of concerns:
┌─────────────────────────────────────────┐
│ Webex SDK │
│ (Public API - webex/src/webex.js) │
├─────────────────────────────────────────┤
│ Plugin Layer │
│ - Public Plugins (meetings, people) │
│ - Internal Plugins (device, mercury) │
├─────────────────────────────────────────┤
│ Webex Core Layer │
│ - HTTP Pipeline & Interceptors │
│ - Authentication & Credentials │
│ - Storage Management │
│ - Configuration System │
├─────────────────────────────────────────┤
│ Foundation Layer │
│ - AmpersandState (State Management) │
│ - EventEmitter (Event System) │
│ - HTTP Core (Network Layer) │
└─────────────────────────────────────────┘
Primary Functions:
constructor()- Initializes WebexCore with credential normalizationinitialize()- Sets up configuration, interceptors, and event listenersrefresh()- Delegates to credentials.refresh() for token refreshtransform()- Applies payload transformations bidirectionallyapplyNamedTransform()- Applies specific transform by namegetWindow()- Returns browser window objectsetConfig()- Updates configuration dynamicallybearerValidator()- Validates and corrects access token formatinspect()- Provides debug representationlogout()- Orchestrates complete logout processmeasure()- Sends metrics via metrics pluginupload()- Handles file uploads with three-phase process_uploadPhaseInitialize()- Initiates upload session_uploadPhaseUpload()- Performs actual file upload_uploadPhaseFinalize()- Completes upload session_uploadAbortSession()- Aborts upload if size limit exceeded_uploadApplySession()- Applies session configuration
Derived Properties:
boundedStorage- Storage with size limitsunboundedStorage- Unlimited storageready- Indicates all plugins are initialized
Session Properties:
config- Configuration objectloaded- Initial load completion statusrequest- HTTP request functionsessionId- Unique session identifier
Primary Functions:
inspect()- Debug representation of internal plugins
Derived Properties:
ready- Aggregates readiness of all internal plugins
Primary Functions:
initialize()- Plugin initialization with datatype bindingclear()- Clears plugin state while preserving parent referenceinspect()- Debug representationrequest()- Delegates to webex.request()upload()- Delegates to webex.upload()when()- Promise-based event waiting_filterSetParameters()- Normalizes set() parameters
Derived Properties:
boundedStorage- Plugin-specific bounded storageunboundedStorage- Plugin-specific unbounded storageconfig- Plugin-specific configurationlogger- Plugin-specific loggerwebex- Reference to root Webex instance
Session Properties:
parent- Parent object referenceready- Plugin readiness status
Function: Webex.init(attrs)
- Merges default configuration with provided attributes
- Sets
sdkType: 'webex'in configuration - Creates new Webex instance by extending WebexCore
- Automatically requires all public plugins:
@webex/plugin-authorization@webex/plugin-meetings@webex/plugin-people@webex/plugin-rooms@webex/plugin-messages- And many others...
Function: WebexCore.constructor(attrs, options)
-
Credential Normalization: Handles various token input formats
- String tokens converted to credential objects
- Multiple token path variations normalized
- Bearer token validation and correction via
bearerValidator()
-
AmpersandState Initialization: Calls parent constructor
Function: WebexCore.initialize(attrs)
- Configuration Merge: Combines default config with provided attributes
- Event Setup: Establishes loaded/ready event handlers
- Child Event Propagation: Sets up nested event bubbling
- Interceptor Chain Setup: Builds HTTP request interceptor pipeline
- Request Function Creation: Creates configured request function
- Session ID Generation: Creates unique tracking ID
Function: mixinWebexCorePlugins() and mixinWebexInternalCorePlugins()
- Plugin Registration: Each plugin registers via
registerPlugin() - Child Relationship: Plugins added to
_childrencollection - Proxy Creation: Public API methods proxied if specified
- Configuration Merge: Plugin configs merged into main config
- Interceptor Registration: Plugin interceptors added to pipeline
Function: registerPlugin(name, constructor, options)
Registration Options:
proxies- Array of methods to proxy to root levelinterceptors- HTTP interceptors to add to pipelineconfig- Configuration to mergepayloadTransformer.predicates- Transform predicatespayloadTransformer.transforms- Transform functionsonBeforeLogout- Cleanup handlers for logout
Plugin Types:
- Public Plugins: Registered on WebexCore directly
- Internal Plugins: Registered on WebexInternalCore
- Registration: Plugin constructor added to
_children - Instantiation: AmpersandState creates plugin instances
- Initialization: Plugin
initialize()method called - Configuration: Plugin receives namespace-specific config
- Ready State: Plugin sets
readyproperty when initialized
Class: People extends WebexPlugin
namespace: 'People'- Configuration namespacechildren: { batcher: PeopleBatcher }- Sub-componentsget(person)- Retrieve person by IDlist(options)- List people with filtersinferPersonIdFromUuid(id)- UUID to Hydra ID conversion_getMe()- Fetch current user (@oneFlight decorated)
Interceptor Order:
-
Pre-Interceptors: Run before main processing
ResponseLoggerInterceptorRequestTimingInterceptorRequestEventInterceptorWebexTrackingIdInterceptorRateLimitInterceptor
-
Core Interceptors: Main request processing
ServiceInterceptorUserAgentInterceptorWebexUserAgentInterceptorAuthInterceptorPayloadTransformerInterceptorRedirectInterceptor
-
Post-Interceptors: Run after main processing
HttpStatusInterceptorNetworkTimingInterceptorEmbargoInterceptorRequestLoggerInterceptorRateLimitInterceptor
AuthInterceptor (interceptors/auth.js):
onRequest()- Adds authorization headersrequiresCredentials()- Determines if auth is neededonResponseError()- Handles 401 responsesshouldAttemptReauth()- Decides on token refreshreplay()- Retries failed requests after refresh
RequestTimingInterceptor:
- Measures request duration
- Adds timing metadata
PayloadTransformerInterceptor:
- Applies bidirectional data transformations
- Handles encryption/decryption
Functions:
makeWebexStore(type, webex)- Creates storage instancemakeWebexPluginStore(type, plugin)- Creates plugin-specific storage
Storage Types:
- Bounded Storage: Size-limited, typically for frequently accessed data
- Unbounded Storage: No size limits, for archival data
Default Adapters:
MemoryStoreAdapter- In-memory storage (default)LocalStorageAdapter- Browser localStorageSessionStorageAdapter- Browser sessionStorage
Storage Methods:
get(key)- Retrieve valueset(key, value)- Store valuedel(key)- Delete valueclear()- Clear all values
File: config.js
- Default configuration values
- Service discovery URLs
- Storage adapter configuration
- Interceptor settings
- Security settings
Key Configuration Sections:
maxAppLevelRedirects: 10maxLocusRedirects: 5maxAuthenticationReplays: 1services.discovery- Service discovery URLsservices.validateDomains- Domain validation settingsstorage- Storage adapter configurationpayloadTransformer- Transform configuration
Configuration Merge Process:
- Default config loaded from
config.js - Plugin configs merged during registration
- User-provided config merged during initialization
- Runtime config updates via
setConfig()
Base Events (WebexCore):
loaded- Data loaded from storageready- All plugins initializedchange:config- Configuration changedclient:logout- Logout completed
Event Propagation:
- Child events bubble to parent with namespace prefix
- Example:
change:peoplewhen People plugin changes
Event Methods:
trigger(event, ...args)- Emit eventlistenTo(target, event, handler)- Listen to target's eventslistenToAndRun(target, event, handler)- Listen and run immediatelystopListening(target, event, handler)- Stop listeningwhen(event)- Promise-based event waiting
Lifecycle Events:
- Plugins emit
changeevents on state changes - Parent automatically propagates child events
- Ready state changes trigger parent ready recalculation
- Entry:
Webex.init({credentials: 'token'}) - Config Merge: Default + user config merged
- Constructor: WebexCore constructor called
- Token Normalization: Various token formats standardized
- AmpersandState Init: Base state management initialized
- WebexCore Init: Core initialization begins
- Config Setup: Final config object created
- Event Handlers: Ready/loaded event handlers established
- Interceptor Chain: HTTP interceptor pipeline built
- Request Function: Configured request function created
- Session ID: Unique session identifier generated
- Plugin Loading: All registered plugins instantiated
- Plugin Init: Each plugin's initialize() called
- Ready State: System ready when all plugins ready
- Request Initiated:
webex.request(options)called - Pre-Interceptors: Logging, timing, tracking setup
- Auth Interceptor: Authorization header added if needed
- Service Interceptor: Service URL resolution
- Payload Transform: Request data transformation
- HTTP Core: Actual HTTP request execution
- Response Processing: Status, timing, logging
- Error Handling: 401 handling, token refresh, retry
- Response Transform: Response data transformation
- Result Return: Final response returned to caller
- Method Call:
webex.people.get('personId') - Plugin Resolution: WebexCore resolves 'people' child
- Method Execution: People.get() method called
- Request Delegation: Plugin calls
this.request() - Core Request: Delegates to webex.request()
- Interceptor Pipeline: Full HTTP pipeline executed
- Response Processing: Plugin processes response
- Result Return: Processed result returned to caller
- Storage Access:
webex.boundedStorage.get('key') - Adapter Resolution: Storage adapter determined
- Key Namespacing: Key prefixed with namespace
- Adapter Method: Actual storage operation performed
- Result Processing: Raw result processed if needed
- Return: Final value returned to caller
This technical documentation provides a comprehensive overview of the Webex Core package infrastructure, explaining the foundational systems that enable the entire Webex JavaScript SDK ecosystem. The architecture demonstrates a well-designed separation of concerns with clear plugin boundaries, robust HTTP handling, and flexible configuration management.