Skip to content

Conversation

@mondoreale
Copy link
Contributor

@mondoreale mondoreale commented Dec 15, 2025

This PR removes "dom" from SDK's TypeScript lib configuration to avoid pulling browser-specific types into the default scope. The SDK is not primarily a browser environment, and having DOM types globally available was masking environment boundaries and weakening type safety.

The remaining changes are necessary follow-ups to keep the codebase compiling and to make environment assumptions more explicit.

Changes

TypeScript configuration:

  • Removed "dom" from the lib array in both tsconfig.json and tsconfig.jest.json to better reflect the intended runtime environment and prevent accidental reliance on browser-only APIs.

Type safety and cryptographic key handling:

  • Updated cachedJWK in ECDSAKeyPairIdentity from JsonWebKey to webcrypto.JsonWebKey.

  • Explicitly imported the webcrypto type from Node’s crypto module to avoid relying on DOM-provided global types and to clarify the source of the API.

This ensures cryptographic types are correctly scoped and remain available after removing the DOM lib.

Documentation and environment targeting:

  • Added a @todo comment and a local dom lib reference in RSAKeyPair.ts to document that the file currently mixes browser and Node.js code.

  • This makes the environment dependency explicit and flags the file for future refactoring into environment-specific implementations.

@github-actions github-actions bot added the sdk label Dec 15, 2025
Base automatically changed from detach-jest-tsconfigs-from-build to main December 16, 2025 14:15
@mondoreale mondoreale force-pushed the clean-libs-in-sdks-tsconfigs branch from 330c33c to b3f9c28 Compare December 16, 2025 14:17
@mondoreale mondoreale requested a review from Copilot December 16, 2025 14:18
@mondoreale mondoreale marked this pull request as ready for review December 16, 2025 14:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves type safety in the SDK by removing the "dom" library from TypeScript's lib configuration. Since the SDK is not primarily a browser environment, having DOM types globally available was weakening type safety and masking environment boundaries. The PR updates cryptographic type references to explicitly use Node.js's webcrypto types and adds proper documentation for files that genuinely need DOM types.

  • Removed "dom" from TypeScript lib configuration in both main and test configs
  • Updated cryptographic type references to use explicit webcrypto namespace from Node.js crypto module
  • Added triple-slash directive and documentation for files that mix browser and Node.js code

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/sdk/tsconfig.json Removed "dom" from lib array to prevent global DOM type availability
packages/sdk/tsconfig.jest.json Removed "dom" from lib array in Jest configuration for consistency
packages/sdk/src/identity/ECDSAKeyPairIdentity.ts Added explicit webcrypto type import and updated cachedJWK type from JsonWebKey to webcrypto.JsonWebKey
packages/sdk/src/encryption/RSAKeyPair.ts Added triple-slash DOM lib reference and TODO comment documenting the file's mixed environment usage, added explicit webcrypto type import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mondoreale mondoreale merged commit fe18df1 into main Dec 16, 2025
29 checks passed
@mondoreale mondoreale deleted the clean-libs-in-sdks-tsconfigs branch December 16, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants