feat: Swift and Kotlin credential storage tests#271
Conversation
kotlin/walletkit/src/main/kotlin/org/world/walletkit/storage/AndroidAtomicBlobStore.kt
Show resolved
Hide resolved
kotlin/walletkit/src/main/kotlin/org/world/walletkit/storage/AndroidAtomicBlobStore.kt
Outdated
Show resolved
Hide resolved
Made-with: Cursor
…ign-tests-v2 Made-with: Cursor # Conflicts: # swift/tests/WalletKitTests/LoggingTests.swift
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
kotlin/walletkit/src/main/kotlin/org/world/walletkit/storage/AndroidDeviceKeystore.kt
Show resolved
Hide resolved
|
@codex review |
| } | ||
| } | ||
|
|
||
| public func openSealed(associatedData: Data, ciphertext: Data) throws -> Data { |
There was a problem hiding this comment.
@forceunwrap @NnnOooPppEee could you help double check this is how we should do things?
| override fun seal(associatedData: ByteArray, plaintext: ByteArray): ByteArray { | ||
| try { | ||
| val key = getOrCreateKey() | ||
| val cipher = Cipher.getInstance("AES/GCM/NoPadding") |
There was a problem hiding this comment.
@Guardiola31337 @NnnOooPppEee this warrants particular attention
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1bc22854b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!temp.renameTo(file)) { | ||
| throw StorageException.BlobStore("failed to atomically replace existing file") |
There was a problem hiding this comment.
Handle overwrite when atomic write target already exists
writeAtomic writes to a temp file and then throws if temp.renameTo(file) returns false, but File.renameTo is allowed to fail when the destination already exists. In environments/filesystems where that happens, any rewrite of an existing blob path will fail, so callers cannot safely update previously written data even though writeAtomic is expected to replace atomically. Use a replace-capable move (REPLACE_EXISTING/ATOMIC_MOVE where available) or an explicit overwrite fallback.
Useful? React with 👍 / 👎.
| if addStatus == errSecMissingEntitlement { | ||
| Self.setFallbackKey(id: fallbackKeyId(), data: keyData) | ||
| return SymmetricKey(data: keyData) | ||
| } |
There was a problem hiding this comment.
Avoid persisting data behind in-memory entitlement fallback
When SecItemAdd returns errSecMissingEntitlement, the code stores the key only in static in-memory state and still proceeds, which allows writing encrypted blobs that cannot be reopened after process restart (the fallback map is empty on next launch). In entitlement-missing environments this causes silent creation of unrecoverable on-disk credential data; this path should fail fast or use a persistable key mechanism instead of continuing.
Useful? React with 👍 / 👎.

Note
High Risk
Introduces new encryption/key-management and on-disk blob storage code for Android and iOS, which is security- and data-integrity sensitive. Incorrect error handling or atomic-write semantics could lead to lost/undecryptable credentials.
Overview
Adds end-to-end storage coverage for WalletKit across Kotlin and Swift.
On Android, introduces
AndroidDeviceKeystore(AES-GCM via AndroidKeyStore),AndroidAtomicBlobStore(atomic temp-file writes), andAndroidStorageProvider/WalletKitStorage.defaultProviderto wire paths, keystore, and blob store under aworldiddirectory.On iOS/Swift, adds
IOSDeviceKeystore(AES-GCM with Keychain-backed symmetric key plus entitlement-missing fallback),IOSAtomicBlobStore(atomic file writes), andIOSStorageProvider/WalletKitStorage.makeDefaultProvider, along with new Swift and Kotlin test suites covering blob read/write/delete, credential store init/persist/reopen + Merkle cache TTL behavior, and renaming/polishing of logging tests (including more robust Swift polling).Written by Cursor Bugbot for commit c1bc228. This will update automatically on new commits. Configure here.