You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement OAuth-based authentication with NodeSource Accounts API, including token storage, validation, and the auth manager orchestrator.
Tasks
Task 5: Implement token storage module — Create token-storage.ts to read/write credentials to ~/.agents/.nodesource-auth.json. Implement secure file permissions (0600). Handle missing file, invalid JSON, and expired tokens. Note: on Windows, chmod 0600 has minimal effect; credential protection relies on directory ACLs.
Depends on: Task 4
Files: packages/core/src/auth/token-storage.ts
Testing: Unit tests for save/load credentials. Test file permissions. Test handling of corrupted file.
Task 6: Implement token validator module — Create token-validator.ts to validate service tokens with Accounts API at /accounts/org/access-token. Handle network errors, 401/403 responses, and timeouts. Return validation result with permissions list.
Depends on: Task 5
Files: packages/core/src/auth/token-validator.ts
Testing: Unit tests with mocked HTTP responses. Test success, 401, 500, and timeout scenarios.
Task 7: Implement OAuth callback server — Create oauth-server.ts to start local HTTP server on port 8765 (with fallback to 8766-8770). Listen for OAuth callback with token and orgId. Implement 5-minute timeout. Return received credentials.
Depends on: Task 4
Files: packages/core/src/auth/oauth-server.ts
Testing: Unit tests for server startup, callback handling, timeout, and port conflicts.
Task 8: Implement auth manager orchestrator — Create auth-manager.ts with ensureAuthenticated() function. Check for existing valid credentials first. If missing/expired, initiate OAuth flow (open browser, start callback server). Validate token with Accounts API. Store credentials. Return Credentials object.
Phase 2: Authentication Module
Implement OAuth-based authentication with NodeSource Accounts API, including token storage, validation, and the auth manager orchestrator.
Tasks
Task 5: Implement token storage module — Create token-storage.ts to read/write credentials to
~/.agents/.nodesource-auth.json. Implement secure file permissions (0600). Handle missing file, invalid JSON, and expired tokens. Note: on Windows,chmod 0600has minimal effect; credential protection relies on directory ACLs.packages/core/src/auth/token-storage.tsTask 6: Implement token validator module — Create token-validator.ts to validate service tokens with Accounts API at
/accounts/org/access-token. Handle network errors, 401/403 responses, and timeouts. Return validation result with permissions list.packages/core/src/auth/token-validator.tsTask 7: Implement OAuth callback server — Create oauth-server.ts to start local HTTP server on port 8765 (with fallback to 8766-8770). Listen for OAuth callback with token and orgId. Implement 5-minute timeout. Return received credentials.
packages/core/src/auth/oauth-server.tsTask 8: Implement auth manager orchestrator — Create auth-manager.ts with
ensureAuthenticated()function. Check for existing valid credentials first. If missing/expired, initiate OAuth flow (open browser, start callback server). Validate token with Accounts API. Store credentials. Return Credentials object.packages/core/src/auth/auth-manager.ts,packages/core/src/auth/index.ts