Skip to content

Use the github.com/x6c-co/rypt module for API calls - #2

Merged
levidurfee merged 1 commit into
mainfrom
feature/use-rypt-sdk
Oct 16, 2026
Merged

levidurfee merged 1 commit into
mainfrom
feature/use-rypt-sdk

Conversation

@levidurfee

Copy link
Copy Markdown
Contributor

Summary

Replaces internal/client with the new Go SDK, github.com/x6c-co/rypt v0.1.0, so the CLI and other projects share one API client.

The SDK keeps all of internal/client's hardening:

  • https only, with plain http allowed only to a loopback host
  • no redirects followed, and no plain-HTTP requests sent through a proxy
  • server text sanitized and the token redacted in errors
  • bounded response bodies, and response buffers cleared
  • the same retries for wrap and unwrap: up to 3 attempts, on a connection failure or HTTP 502, 503 or 504

internal/client's tests moved to the SDK along with the code.

One behavior change

The SDK passes wrapped as decoded bytes. encrypt encodes it back into the header as standard padded base64, the same string the API sent, so the file format is unchanged. decrypt decodes the header's value before unwrapping.

As a result, a header whose wrapped DEK is not base64 is now refused locally as a damaged header: exit code 4, and no API operation is spent. Before, it was sent to the API and refused there, exit code 1. TestHeaderRejected covers this with three new cases: not base64, unpadded, and line breaks only. The README and docs/api-notes.md are updated to match.

Other changes

  • scripts/probe.go checks RYPT_API_URL with rypt.NewClient instead of client.ParseBaseURL.
  • The User-Agent is now rypt-cli/<version> rypt-go/v0.1.0.

Testing

  • make vet test race passes: every existing internal/cli mock-API test and cmd/rypt end-to-end test is unchanged and green against the SDK.
  • make integration was not run against the live API.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NTEjHbdKp83qgQgmqR1BJ6

Replace internal/client with the rypt Go SDK v0.1.0, which carries over
its hardening: https only, no redirects, no plain-HTTP proxying,
sanitized server text with the token redacted, bounded responses, and
the same retries for wrap and unwrap.

The SDK passes the wrapped DEK as bytes, so encrypt writes it to the
header as standard padded base64, the same string the API sent, and
decrypt decodes it before unwrapping. A header whose wrapped DEK is not
base64 cannot have come from the API: it is now refused locally as a
damaged header, exit code 4, without spending an operation, where it
used to be sent to the API and refused there with exit code 1.

scripts/probe.go checks RYPT_API_URL with rypt.NewClient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NTEjHbdKp83qgQgmqR1BJ6
@levidurfee
levidurfee merged commit efed7f8 into main Oct 16, 2026
2 checks passed
@levidurfee
levidurfee deleted the feature/use-rypt-sdk branch October 16, 2026 00:44
@levidurfee levidurfee mentioned this pull request Oct 16, 2026
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.

1 participant