Problem
There's a circular dependency between aio-lib-ims and aio-lib-ims-jwt:
aio-lib-ims
├── imports: aio-lib-ims-jwt (as plugin)
aio-lib-ims-jwt
├── peerDependency: aio-lib-ims (needs ims instance)
└── calls: ims.getApiUrl(), ims.exchangeJwtToken()
This causes:
- npm to install nested old copies (audit false positives)
- Confusing dependency graph
- Difficulty maintaining version compatibility
Analysis
What aio-lib-ims-jwt needs from aio-lib-ims:
ims.getApiUrl(path) - Get IMS API URL with path
ims.exchangeJwtToken(clientId, clientSecret, jwtToken) - Exchange JWT for access token
What aio-lib-ims needs from aio-lib-ims-jwt:
- Plugin interface:
supports(config), canSupport(config), imsLogin(ims, config)
Proposed Solution: Extract @adobe/aio-lib-ims-core
Create a new core package that both packages depend on:
aio-lib-ims-core (NEW)
├── ImsCore class (API URLs, token exchange)
├── Plugin interface definitions
└── Shared types/utilities
aio-lib-ims-jwt
├── depends on: aio-lib-ims-core
└── implements: ImsPlugin interface
aio-lib-ims
├── depends on: aio-lib-ims-core
├── depends on: aio-lib-ims-jwt (as plugin)
└── extends: ImsCore with plugin management
What goes in aio-lib-ims-core:
class ImsCore {
constructor(env) { ... }
// API URL helpers
getApiUrl(path) { ... }
// Token exchange (no plugin dependencies)
exchangeJwtToken(clientId, clientSecret, jwtToken) { ... }
getAccessToken(refreshToken, clientId, clientSecret, scope) { ... }
invalidateToken(token, clientId, clientSecret) { ... }
}
// Plugin interface
interface ImsPlugin {
canSupport(config): Promise<boolean>
supports(config): boolean
imsLogin(ims: ImsCore, config): Promise<string>
}
Benefits
✅ No circular dependency - clean dependency graph
✅ Architecturally correct - separation of concerns
✅ Extensible - easier to add new auth plugins (SAML, API key, etc.)
✅ Reusable - other packages can use core without full ims
✅ Type safety - shared interfaces/types in one place
✅ No audit false positives - no nested old copies
Implementation Strategy
Phase 1: Create core (beta)
- Create
@adobe/aio-lib-ims-core@1.0.0-beta.1
- Extract:
ImsCore class, plugin interfaces, token exchange
- Publish beta
Phase 2: Update jwt (beta)
- Release
@adobe/aio-lib-ims-jwt@6.0.0-beta.1
- Depend on
aio-lib-ims-core instead of peer on aio-lib-ims
- Publish beta
Phase 3: Update ims (beta)
- Release
@adobe/aio-lib-ims@9.0.0-beta.1
- Extend
ImsCore
- Depend on
aio-lib-ims-jwt@^6.0.0-beta
- Publish beta
Phase 4: Stable release
Once validated in beta, release stable versions
Effort Estimate
- Core extraction: 2-3 days
- JWT refactor: 1 day
- IMS refactor: 2-3 days
- Testing: 2-3 days
- Total: ~1-2 weeks
Alternative Considered
Make jwt a peer dependency in aio-lib-ims:
- Simpler but doesn't solve architectural issues
- Makes jwt plugin "special" vs other auth plugins
- Consumers must install both packages manually
Related
Questions
- Is the Adobe team interested in this architectural refactor?
- What's the timeline/priority for this work?
- Should we coordinate with other auth plugin maintainers?
cc @dthampy for visibility
Problem
There's a circular dependency between
aio-lib-imsandaio-lib-ims-jwt:This causes:
Analysis
What aio-lib-ims-jwt needs from aio-lib-ims:
ims.getApiUrl(path)- Get IMS API URL with pathims.exchangeJwtToken(clientId, clientSecret, jwtToken)- Exchange JWT for access tokenWhat aio-lib-ims needs from aio-lib-ims-jwt:
supports(config),canSupport(config),imsLogin(ims, config)Proposed Solution: Extract
@adobe/aio-lib-ims-coreCreate a new core package that both packages depend on:
What goes in
aio-lib-ims-core:Benefits
✅ No circular dependency - clean dependency graph
✅ Architecturally correct - separation of concerns
✅ Extensible - easier to add new auth plugins (SAML, API key, etc.)
✅ Reusable - other packages can use core without full ims
✅ Type safety - shared interfaces/types in one place
✅ No audit false positives - no nested old copies
Implementation Strategy
Phase 1: Create core (beta)
@adobe/aio-lib-ims-core@1.0.0-beta.1ImsCoreclass, plugin interfaces, token exchangePhase 2: Update jwt (beta)
@adobe/aio-lib-ims-jwt@6.0.0-beta.1aio-lib-ims-coreinstead of peer onaio-lib-imsPhase 3: Update ims (beta)
@adobe/aio-lib-ims@9.0.0-beta.1ImsCoreaio-lib-ims-jwt@^6.0.0-betaPhase 4: Stable release
Once validated in beta, release stable versions
Effort Estimate
Alternative Considered
Make jwt a peer dependency in aio-lib-ims:
Related
Questions
cc @dthampy for visibility