Skip to content

Require encryption setup for synchronized offline mode - #60

Merged
rdlabo merged 2 commits into
mainfrom
fix/offline-encryption-contract
Aug 12, 2026
Merged

Require encryption setup for synchronized offline mode#60
rdlabo merged 2 commits into
mainfrom
fix/offline-encryption-contract

Conversation

@rdlabo

@rdlabo rdlabo commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • require createEncryptionKey at compile time for synchronized offline providers
  • reject the encryption key option in explicit read-cache-only configuration
  • add a compile-time contract test for the synchronized provider shape

Why

Native synchronized persistence cannot operate safely without its encryption-key factory. The previous optional property delayed a configuration error until the SQLite database opened at runtime. The mode-discriminated provider API now makes this requirement explicit for every product adopting the Kit.

Verification

  • focused offline contract tests: 5/5
  • ESLint: pass
  • git diff --check: pass

Open in Devin Review

@netlify

netlify Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploy Preview for rdlabo-ionic-angular-library ready!

Name Link
🔨 Latest commit 161fcd7
🔍 Latest deploy log https://app.netlify.com/projects/rdlabo-ionic-angular-library/deploys/6a7c1eae8c0b3b0008a3d799
😎 Deploy Preview https://deploy-preview-60--rdlabo-ionic-angular-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +52 to +53
/** Read-cache-only mode does not provision an encrypted native Outbox database. */
createEncryptionKey?: never;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 読み取りキャッシュ専用の設定でiOS/Androidの端末内データベースを開けなくなる

読み取りキャッシュ専用モードで暗号鍵の指定が禁止された(createEncryptionKey?: never at projects/kit/offline/src/lib/offline-provider.ts:53)ため、iOS/Androidの端末内データベースを初回に開く時点で鍵が用意できず、起動処理が失敗します。

Impact: 読み取りキャッシュ専用として導入しているアプリは、iOS/Androidで起動時にエラーとなりオフライン機能が全く使えなくなります。

ネイティブ端末ではモードに関わらず暗号化SQLiteが利用される仕組み

provideOffline のリポジトリ選択 (projects/kit/offline/src/lib/offline-provider.ts:100-103) は selectOfflineRepository (projects/kit/offline/src/lib/offline-repository.ts:197-203) を使い、プラットフォームが ios/android なら SqliteOfflineRepository を返します。モード判定は入りません。SqliteOfflineRepository.#opencreateEncryptionKey をそのままドライバへ渡し (projects/kit/offline/src/lib/sqlite-offline-repository.ts:445-448)、初回オープン時に鍵が未取得だと Native offline storage requires a non-empty encryption key on first open を投げます (projects/kit/offline/src/lib/sqlite-offline-repository.ts:106-112)。readCacheOnly が抑止しているのは pull と enqueue のみです (projects/kit/offline/src/lib/offline-replica-pull.service.ts:48, projects/kit/offline/src/lib/offline-sync.service.ts:398)。実際 README の読み取りキャッシュ例は createEncryptionKey を渡しており (projects/kit/README.md:770-777)、この型変更でコンパイルも通らなくなります。

Prompt for agents
読み取りキャッシュ専用モード (ProvideReadCacheOfflineOptions) で createEncryptionKey を `never` として禁止しているが、iOS/Android では mode に関わらず SqliteOfflineRepository が選択され、暗号化SQLiteの初回オープンに鍵ファクトリが必須である。そのため readCacheOnly の製品はネイティブで初期化に失敗する(README のサンプルも createEncryptionKey を渡している)。対応案としては、(a) readCacheOnly でも createEncryptionKey を必須(もしくは任意)のままにする、または (b) readCacheOnly のときはネイティブでも暗号化不要な経路を用意する、のいずれか。型定義・README・テストを整合させること。
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@rdlabo
rdlabo merged commit 577f438 into main Aug 12, 2026
12 checks passed
@rdlabo
rdlabo deleted the fix/offline-encryption-contract branch August 12, 2026 09:01
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