|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the Ping JavaScript SDK - a monorepo containing multiple packages for web applications integrating with the Ping platform. The SDK provides APIs for user authentication, device management, and accessing Ping-secured resources. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Core Commands |
| 12 | + |
| 13 | +- `pnpm build` - Build all affected packages |
| 14 | +- `pnpm test` - Run tests for all affected packages |
| 15 | +- `pnpm lint` - Lint all affected packages |
| 16 | +- `pnpm format` - Format code using Prettier |
| 17 | +- `pnpm nx typecheck` - Run TypeScript type checking |
| 18 | + |
| 19 | +### Package Management |
| 20 | + |
| 21 | +- `pnpm create-package` - Generate a new library package using Nx |
| 22 | +- `pnpm nx serve <package-name>` - Serve a specific package in development |
| 23 | +- `pnpm nx test <package-name> --watch` - Run tests for a specific package in watch mode |
| 24 | + |
| 25 | +### E2E Testing |
| 26 | + |
| 27 | +- `pnpm test:e2e` - Run end-to-end tests for affected packages |
| 28 | +- Individual e2e apps are in `e2e/` directory with their own test suites |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +### Monorepo Structure |
| 33 | + |
| 34 | +The repository uses **Nx** as the monorepo tool with the following structure: |
| 35 | + |
| 36 | +``` |
| 37 | +packages/ |
| 38 | +├── davinci-client/ # DaVinci flow orchestration client |
| 39 | +├── device-client/ # Device management (binding, profiles, WebAuthn) |
| 40 | +├── oidc-client/ # OpenID Connect authentication client |
| 41 | +├── protect/ # Ping Protect fraud detection |
| 42 | +├── sdk-effects/ # Effect-based utilities (logger, storage, etc.) |
| 43 | +│ ├── iframe-manager/ |
| 44 | +│ ├── logger/ |
| 45 | +│ ├── oidc/ |
| 46 | +│ ├── sdk-request-middleware/ |
| 47 | +│ └── storage/ |
| 48 | +├── sdk-types/ # Shared TypeScript types |
| 49 | +└── sdk-utilities/ # Common utilities (PKCE, URL handling) |
| 50 | +``` |
| 51 | + |
| 52 | +### Key Packages |
| 53 | + |
| 54 | +- **davinci-client**: State management for DaVinci authentication flows using Redux Toolkit |
| 55 | +- **oidc-client**: OIDC authentication with token management and storage |
| 56 | +- **device-client**: Device binding, profiles, OATH, Push, and WebAuthn capabilities |
| 57 | +- **protect**: Fraud detection and risk assessment integration |
| 58 | +- **sdk-effects**: Effect-based architecture packages for common functionalities |
| 59 | + |
| 60 | +### Technology Stack |
| 61 | + |
| 62 | +- **Package Manager**: pnpm with workspace configuration |
| 63 | +- **Build Tool**: Vite for building and bundling |
| 64 | +- **Testing**: Vitest for unit tests, Playwright for e2e tests |
| 65 | +- **State Management**: Redux Toolkit (in davinci-client) |
| 66 | +- **TypeScript**: Strict typing with composite project configuration |
| 67 | +- **Linting**: ESLint with Prettier integration |
| 68 | + |
| 69 | +### Nx Configuration |
| 70 | + |
| 71 | +- Uses target defaults for build, test, lint, and typecheck |
| 72 | +- Caching enabled for build and test targets |
| 73 | +- Workspace layout configured for packages and e2e apps |
| 74 | +- Parallel execution limited to 1 for consistency |
| 75 | + |
| 76 | +### Package Dependencies |
| 77 | + |
| 78 | +Packages use workspace references (`workspace:*`) for internal dependencies and catalog references (`catalog:`) for shared external dependencies like `@reduxjs/toolkit`. |
| 79 | + |
| 80 | +### Testing Strategy |
| 81 | + |
| 82 | +- Unit tests: Vitest with coverage reporting |
| 83 | +- E2E tests: Playwright with dedicated test apps in `e2e/` directory |
| 84 | +- Mock API server available in `e2e/mock-api-v2/` for testing |
| 85 | + |
| 86 | +## Development Notes |
| 87 | + |
| 88 | +- All packages are built as ES modules with TypeScript declarations |
| 89 | +- Use `pnpm nx affected` commands to run tasks only on changed packages |
| 90 | +- The repository uses conventional commits and automated releases via changesets |
| 91 | +- Individual packages can be tested independently using their specific build/test scripts |
0 commit comments