Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f4565c1
docs: design for ConnectRPC + well-known KAS discovery (CWT)
arkavo-com May 30, 2026
6b8ecdb
docs: implementation plan for ConnectRPC KAS migration
arkavo-com May 30, 2026
5862ab6
feat(kas): add OpenTDFConfiguration discovery types + builders
arkavo-com Jun 1, 2026
1fa25a3
feat(kas): add validateKasURL with HTTPS + SSRF guard
arkavo-com Jun 1, 2026
dbcc368
refactor(kas): explicit Sendable on KASDiscoveryError + reject empty …
arkavo-com Jun 1, 2026
b3c608b
feat(kas): add KasEndpoints resolution (Connect-preferred)
arkavo-com Jun 1, 2026
387de8a
feat(kas): add fetchWellKnown + MockURLProtocol; DRY trailing-slash trim
arkavo-com Jun 1, 2026
423bf97
refactor(kas): KasEndpoints Equatable + type DocC comments
arkavo-com Jun 1, 2026
a73405d
feat(kas): add Connect error-envelope parsing
arkavo-com Jun 1, 2026
f256f7a
refactor(kas): carry a reason string on authenticationFailed
arkavo-com Jun 1, 2026
3e4b8c2
feat(kas): route client transport through resolved KasEndpoints
arkavo-com Jun 2, 2026
52d333c
fix(kas): send Connect-Protocol-Version only on connect transport
arkavo-com Jun 2, 2026
6258d1c
feat(cli): resolve KAS config via well-known (Connect, REST fallback)
arkavo-com Jun 2, 2026
d163fc0
refactor(cli): remove dead extractCompressedKeyFromPEM
arkavo-com Jun 2, 2026
8807b9d
test(kas): migrate clients to init(configuration:)
arkavo-com Jun 2, 2026
1e3eb82
feat(kas)!: require OpenTDFConfiguration in KASRewrapClient init
arkavo-com Jun 2, 2026
916a882
test(kas): Connect public-key fetch + rewrap error envelope
arkavo-com Jun 2, 2026
328f8a2
test(kas): live Connect platform integration tests (opt-in)
arkavo-com Jun 2, 2026
453c60d
docs: note ConnectRPC + well-known KAS discovery in CLAUDE.md
arkavo-com Jun 2, 2026
a510d88
test(kas): fix stale unwrapKey HKDF salt round-trip test
arkavo-com Jun 2, 2026
3d139e1
test(kas): use plain placeholder bearer in live test (avoid secret sc…
arkavo-com Jun 2, 2026
0cb6f05
ci: pin swiftformat via .swiftformat config and lint the tree
arkavo-com Jun 2, 2026
213065b
style: apply swiftformat across the repository
arkavo-com Jun 2, 2026
e34ebca
review: address Gitar feedback on #39
arkavo-com Jun 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/swift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
run: brew install swiftformat

- name: Run SwiftFormat
run: swiftformat --swiftversion 6.2 . --lint
# Rules and Swift version are pinned in the repo's .swiftformat config.
run: swiftformat --lint .

# - name: Run SwiftLint
# run: swiftlint --strict
Expand Down
14 changes: 14 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SwiftFormat configuration for OpenTDFKit
# Pinned so `swiftformat .` and the CI lint check agree.

# Match the package's declared language version (Package.swift: swift-tools-version:6.2).
--swiftversion 6.2

# Force-unwraps in tests/benchmarks are intentional here: a nil in a test is a
# legitimate, immediate failure. The autocorrect for this rule rewrites `!` to
# `try XCTUnwrap(...)`, which breaks compilation in non-throwing benchmark
# functions, so the rule is disabled rather than auto-applied.
--disable noForceUnwrapInTests

# Never touch build artifacts.
--exclude .build
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ OpenTDFKit is composed of several key components that work together to implement

- **PublicKeyStore**: Manages only public keys for sharing with peers. Allows secure distribution of one-time use TDF keys.

- **KASRewrapClient**: Client for interacting with KAS rewrap endpoints. Implements JWT signing (ES256), PEM parsing, and key unwrapping protocols. Supports both NanoTDF (EC key wrapping) and TDF (Archive Envelope) (RSA key wrapping) rewrap requests. Designed with protocol-based architecture for testability.
- **KASRewrapClient**: Client for interacting with KAS rewrap endpoints. Implements JWT signing (ES256), PEM parsing, and key unwrapping protocols. Supports both NanoTDF (EC key wrapping) and TDF (Archive Envelope) (RSA key wrapping) rewrap requests. Designed with protocol-based architecture for testability. Resolves transport endpoints from an `OpenTDFConfiguration` (well-known discovery via `fetchWellKnown`, or `OpenTDFConfiguration.forKasConnect`), preferring ConnectRPC `/kas.AccessService/*` and falling back to legacy REST `/kas/v2/*`; the rewrap client follows no redirects and parses Connect error envelopes. Bearer tokens are opaque (a JWT or a base64url-encoded CWT — the platform decides validation).

- **KASDiscovery**: ConnectRPC/well-known discovery support. Provides `OpenTDFConfiguration`/`KasConfig`/`IdpConfig` Codable types, `KasEndpoints` resolution (Connect-preferred, REST-fallback) with HTTPS/SSRF URL validation, Connect error-envelope parsing, and `fetchWellKnown` for `/.well-known/opentdf-configuration`.

### TDF (Archive Envelope) Components

Expand Down
5 changes: 2 additions & 3 deletions OpenTDFKit/BinaryParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ public class BinaryParser {
else {
throw ParsingError.invalidPayload("Failed to read ciphertext or payload MAC")
}
let payload = Payload(length: length, iv: iv, ciphertext: ciphertext, mac: payloadMAC)
return payload
return Payload(length: length, iv: iv, ciphertext: ciphertext, mac: payloadMAC)
}

public func parseSignature(config: SignatureAndPayloadConfig) throws -> Signature? {
Expand Down Expand Up @@ -394,7 +393,7 @@ public class BinaryParser {
}
}

// see https://github.com/opentdf/spec/tree/main/schema/nanotdf
/// see https://github.com/opentdf/spec/tree/main/schema/nanotdf
enum FieldSize {
static let magicNumberSize = 2
static let versionSize = 1
Expand Down
4 changes: 2 additions & 2 deletions OpenTDFKit/CryptoHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public actor CryptoHelper {
publicKey.compressedRepresentation
}

// Note: `activeSessions` is declared but not currently used in the provided methods.
// It might be intended for future stateful operations.
/// Note: `activeSessions` is declared but not currently used in the provided methods.
/// It might be intended for future stateful operations.
private var activeSessions: [String: EphemeralKeyPair] = [:]

/// Generates a new ephemeral key pair for the specified elliptic curve.
Expand Down
Loading
Loading