Skip to content

feat(credentials): Implement secure credential storage service#42

Merged
jbdevprimary merged 1 commit into
mainfrom
feat/secure-credential-storage
Jan 18, 2026
Merged

feat(credentials): Implement secure credential storage service#42
jbdevprimary merged 1 commit into
mainfrom
feat/secure-credential-storage

Conversation

@jbdevprimary
Copy link
Copy Markdown
Contributor

Summary

Implements secure credential storage service for Issue #9, providing hardware-backed encryption for API keys and tokens.

Features

  • SecureStore Integration: Uses expo-secure-store with WHEN_UNLOCKED_THIS_DEVICE_ONLY for hardware-backed encryption
  • Biometric Authentication: Optional biometric auth via expo-local-authentication for storing/retrieving credentials
  • API Token Validation: Automatic validation against GitHub, Anthropic, and OpenAI APIs
  • Secure Masking: Credential values are masked for display (e.g., ghp_xxx...xxxx)
  • Credential Lifecycle: Store, retrieve, validate, delete, and revalidate all credentials

API

// Store a credential with validation
await CredentialService.store('github', {
  name: 'My GitHub Token',
  secret: 'ghp_xxxxxxxxxxxx',
});

// Retrieve with biometric auth
const { secret } = await CredentialService.retrieve('github', {
  requireBiometric: true,
});

// Validate all credentials
const results = await CredentialService.revalidateAll();

Supported Providers

  • GitHub (PAT validation via /user endpoint)
  • Anthropic (API key validation via /v1/messages)
  • OpenAI (API key validation via /v1/models)
  • MCP Server (passthrough, no validation)
  • GitLab, Bitbucket (placeholders for future)

Security Model

  • Secrets stored ONLY in SecureStore (hardware-backed)
  • Zustand store contains METADATA only (provider, status, timestamps)
  • No secrets ever written to AsyncStorage or logs
  • Biometric gating available for sensitive operations

Testing

  • 22 unit tests covering all service methods
  • Mocked SecureStore, LocalAuthentication, and fetch
  • Tests for success paths, failures, and edge cases

Closes #9

Test plan

  • All 22 credential service tests pass
  • Biometric availability detection works
  • Store/retrieve/delete lifecycle works
  • API validation for GitHub/Anthropic/OpenAI works
  • Credential masking displays correctly
  • Integration with credentialStore (Zustand) works

🤖 Generated with Claude Code

Implements secure credential management as specified in Issue #9.

## Features:
- **Hardware-backed storage**: Uses Expo SecureStore with WHEN_UNLOCKED_THIS_DEVICE_ONLY
- **Biometric authentication**: Optional biometric unlock via expo-local-authentication
- **API validation**: Validates credentials against GitHub, Anthropic, and OpenAI APIs
- **Secure masking**: Shows masked credential values for display

## CredentialService API:
- `store(type, data, options)`: Store credential with optional validation
- `retrieve(type, options)`: Retrieve credential with optional biometric auth
- `validateCredential(type, secret)`: Validate against respective API
- `delete(type)`: Securely delete credential
- `exists(type)`: Check if credential exists
- `revalidateAll()`: Re-validate all stored credentials
- `isBiometricAvailable()`: Check device biometric support
- `authenticateWithBiometrics()`: Perform biometric authentication

## Security:
- Secrets stored in SecureStore (hardware-backed)
- Metadata tracked in Zustand CredentialStore (no secrets)
- Automatic masking of displayed credentials
- Support for biometric-gated access

## Tests:
- 22 unit tests covering all functionality
- Mocks for SecureStore and LocalAuthentication

Closes #9

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 18, 2026

Warning

Rate limit exceeded

@jbdevprimary has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 14ae953 and 01807ea.

📒 Files selected for processing (5)
  • jest.setup.js
  • src/services/credentials/CredentialService.ts
  • src/services/credentials/__tests__/CredentialService.test.ts
  • src/services/credentials/index.ts
  • src/services/index.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jbdevprimary
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
63.3% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@jbdevprimary jbdevprimary merged commit fd8c9e4 into main Jan 18, 2026
11 of 12 checks passed
@jbdevprimary jbdevprimary deleted the feat/secure-credential-storage branch January 18, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Implement secure credential storage using Expo SecureStore

1 participant