@chipmobilesdk/rn-local-db 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +137 -0
- package/README.md +69 -8
- package/lib/commonjs/adapter/budgets.js +79 -0
- package/lib/commonjs/adapter/budgets.js.map +1 -0
- package/lib/commonjs/adapter/collection.js +236 -0
- package/lib/commonjs/adapter/collection.js.map +1 -0
- package/lib/commonjs/adapter/deletion.js +291 -0
- package/lib/commonjs/adapter/deletion.js.map +1 -0
- package/lib/commonjs/adapter/handle.js +259 -0
- package/lib/commonjs/adapter/handle.js.map +1 -0
- package/lib/commonjs/adapter/index.js +67 -0
- package/lib/commonjs/adapter/index.js.map +1 -0
- package/lib/commonjs/adapter/lifecycle.js +176 -0
- package/lib/commonjs/adapter/lifecycle.js.map +1 -0
- package/lib/commonjs/adapter/schema-sync.js +124 -0
- package/lib/commonjs/adapter/schema-sync.js.map +1 -0
- package/lib/commonjs/adapter/transaction.js +58 -0
- package/lib/commonjs/adapter/transaction.js.map +1 -0
- package/lib/commonjs/artifacts/availability.js +90 -0
- package/lib/commonjs/artifacts/availability.js.map +1 -0
- package/lib/commonjs/artifacts/cascade.js +80 -0
- package/lib/commonjs/artifacts/cascade.js.map +1 -0
- package/lib/commonjs/artifacts/paths.js +31 -0
- package/lib/commonjs/artifacts/paths.js.map +1 -0
- package/lib/commonjs/artifacts/reconcile.js +55 -0
- package/lib/commonjs/artifacts/reconcile.js.map +1 -0
- package/lib/commonjs/artifacts/store.js +300 -0
- package/lib/commonjs/artifacts/store.js.map +1 -0
- package/lib/commonjs/contract/adapter.js +6 -0
- package/lib/commonjs/contract/adapter.js.map +1 -0
- package/lib/commonjs/contract/attachment.js +2 -0
- package/lib/commonjs/contract/attachment.js.map +1 -0
- package/lib/commonjs/contract/backup.js +2 -0
- package/lib/commonjs/contract/backup.js.map +1 -0
- package/lib/commonjs/contract/config.js +31 -0
- package/lib/commonjs/contract/config.js.map +1 -0
- package/lib/commonjs/contract/encryption.js +6 -0
- package/lib/commonjs/contract/encryption.js.map +1 -0
- package/lib/commonjs/contract/errors.js +64 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/migration.js +6 -0
- package/lib/commonjs/contract/migration.js.map +1 -0
- package/lib/commonjs/contract/query.js +6 -0
- package/lib/commonjs/contract/query.js.map +1 -0
- package/lib/commonjs/contract/record.js +6 -0
- package/lib/commonjs/contract/record.js.map +1 -0
- package/lib/commonjs/contract/schema.js +2 -0
- package/lib/commonjs/contract/schema.js.map +1 -0
- package/lib/commonjs/contract/scope.js +2 -0
- package/lib/commonjs/contract/scope.js.map +1 -0
- package/lib/commonjs/contract/transaction.js +6 -0
- package/lib/commonjs/contract/transaction.js.map +1 -0
- package/lib/commonjs/crypto/chunked-cipher.js +147 -0
- package/lib/commonjs/crypto/chunked-cipher.js.map +1 -0
- package/lib/commonjs/crypto/derive.js +61 -0
- package/lib/commonjs/crypto/derive.js.map +1 -0
- package/lib/commonjs/crypto/key-provider.js +70 -0
- package/lib/commonjs/crypto/key-provider.js.map +1 -0
- package/lib/commonjs/crypto/provider.js +54 -0
- package/lib/commonjs/crypto/provider.js.map +1 -0
- package/lib/commonjs/diagnostics/dev-log.js +127 -0
- package/lib/commonjs/diagnostics/dev-log.js.map +1 -0
- package/lib/commonjs/diagnostics/errors.js +57 -0
- package/lib/commonjs/diagnostics/errors.js.map +1 -0
- package/lib/commonjs/diagnostics/faults.js +54 -0
- package/lib/commonjs/diagnostics/faults.js.map +1 -0
- package/lib/commonjs/diagnostics/map-native.js +98 -0
- package/lib/commonjs/diagnostics/map-native.js.map +1 -0
- package/lib/commonjs/diagnostics/redact.js +110 -0
- package/lib/commonjs/diagnostics/redact.js.map +1 -0
- package/lib/commonjs/index.js +70 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/migration/executor.js +136 -0
- package/lib/commonjs/migration/executor.js.map +1 -0
- package/lib/commonjs/migration/ledger.js +64 -0
- package/lib/commonjs/migration/ledger.js.map +1 -0
- package/lib/commonjs/migration/validate-chain.js +76 -0
- package/lib/commonjs/migration/validate-chain.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/platform/backup-android-verify.js +76 -0
- package/lib/commonjs/platform/backup-android-verify.js.map +1 -0
- package/lib/commonjs/platform/backup-ios.js +50 -0
- package/lib/commonjs/platform/backup-ios.js.map +1 -0
- package/lib/commonjs/platform/bytes.js +158 -0
- package/lib/commonjs/platform/bytes.js.map +1 -0
- package/lib/commonjs/platform/fs.js +59 -0
- package/lib/commonjs/platform/fs.js.map +1 -0
- package/lib/commonjs/platform/location.js +129 -0
- package/lib/commonjs/platform/location.js.map +1 -0
- package/lib/commonjs/query/budgets.js +95 -0
- package/lib/commonjs/query/budgets.js.map +1 -0
- package/lib/commonjs/query/compare.js +97 -0
- package/lib/commonjs/query/compare.js.map +1 -0
- package/lib/commonjs/query/cursor.js +97 -0
- package/lib/commonjs/query/cursor.js.map +1 -0
- package/lib/commonjs/query/filter.js +82 -0
- package/lib/commonjs/query/filter.js.map +1 -0
- package/lib/commonjs/query/paginate.js +48 -0
- package/lib/commonjs/query/paginate.js.map +1 -0
- package/lib/commonjs/query/sort.js +61 -0
- package/lib/commonjs/query/sort.js.map +1 -0
- package/lib/commonjs/query/validate.js +180 -0
- package/lib/commonjs/query/validate.js.map +1 -0
- package/lib/commonjs/schema/declare.js +47 -0
- package/lib/commonjs/schema/declare.js.map +1 -0
- package/lib/commonjs/schema/validate-config.js +115 -0
- package/lib/commonjs/schema/validate-config.js.map +1 -0
- package/lib/commonjs/scope/hash.js +107 -0
- package/lib/commonjs/scope/hash.js.map +1 -0
- package/lib/commonjs/scope/normalize.js +73 -0
- package/lib/commonjs/scope/normalize.js.map +1 -0
- package/lib/commonjs/scope/validate.js +81 -0
- package/lib/commonjs/scope/validate.js.map +1 -0
- package/lib/commonjs/sqlite/adapter.js +31 -0
- package/lib/commonjs/sqlite/adapter.js.map +1 -0
- package/lib/commonjs/sqlite/batch.js +218 -0
- package/lib/commonjs/sqlite/batch.js.map +1 -0
- package/lib/commonjs/sqlite/catalog.js +81 -0
- package/lib/commonjs/sqlite/catalog.js.map +1 -0
- package/lib/commonjs/sqlite/connection.js +210 -0
- package/lib/commonjs/sqlite/connection.js.map +1 -0
- package/lib/commonjs/sqlite/index-coverage.js +42 -0
- package/lib/commonjs/sqlite/index-coverage.js.map +1 -0
- package/lib/commonjs/sqlite/native.js +54 -0
- package/lib/commonjs/sqlite/native.js.map +1 -0
- package/lib/commonjs/sqlite/row-codec.js +192 -0
- package/lib/commonjs/sqlite/row-codec.js.map +1 -0
- package/lib/commonjs/sqlite/sql-builder.js +253 -0
- package/lib/commonjs/sqlite/sql-builder.js.map +1 -0
- package/lib/commonjs/sqlite/statements.js +54 -0
- package/lib/commonjs/sqlite/statements.js.map +1 -0
- package/lib/commonjs/sqlite/transaction-queue.js +79 -0
- package/lib/commonjs/sqlite/transaction-queue.js.map +1 -0
- package/lib/commonjs/sqlite/transactions.js +33 -0
- package/lib/commonjs/sqlite/transactions.js.map +1 -0
- package/lib/commonjs/sqlite/values.js +31 -0
- package/lib/commonjs/sqlite/values.js.map +1 -0
- package/lib/commonjs/testing/conformance/attachments.js +180 -0
- package/lib/commonjs/testing/conformance/attachments.js.map +1 -0
- package/lib/commonjs/testing/conformance/encryption.js +187 -0
- package/lib/commonjs/testing/conformance/encryption.js.map +1 -0
- package/lib/commonjs/testing/conformance/index.js +103 -0
- package/lib/commonjs/testing/conformance/index.js.map +1 -0
- package/lib/commonjs/testing/conformance/lifecycle.js +134 -0
- package/lib/commonjs/testing/conformance/lifecycle.js.map +1 -0
- package/lib/commonjs/testing/conformance/migrations.js +167 -0
- package/lib/commonjs/testing/conformance/migrations.js.map +1 -0
- package/lib/commonjs/testing/conformance/queries.js +278 -0
- package/lib/commonjs/testing/conformance/queries.js.map +1 -0
- package/lib/commonjs/testing/conformance/records.js +224 -0
- package/lib/commonjs/testing/conformance/records.js.map +1 -0
- package/lib/commonjs/testing/conformance/scopes.js +107 -0
- package/lib/commonjs/testing/conformance/scopes.js.map +1 -0
- package/lib/commonjs/testing/conformance/transactions.js +228 -0
- package/lib/commonjs/testing/conformance/transactions.js.map +1 -0
- package/lib/commonjs/testing/faults.js +38 -0
- package/lib/commonjs/testing/faults.js.map +1 -0
- package/lib/commonjs/testing/index.js +59 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/attachments.js +145 -0
- package/lib/commonjs/testing/memory-adapter/attachments.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/collection.js +224 -0
- package/lib/commonjs/testing/memory-adapter/collection.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/index.js +366 -0
- package/lib/commonjs/testing/memory-adapter/index.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/migrations.js +126 -0
- package/lib/commonjs/testing/memory-adapter/migrations.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/reset.js +49 -0
- package/lib/commonjs/testing/memory-adapter/reset.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/store.js +107 -0
- package/lib/commonjs/testing/memory-adapter/store.js.map +1 -0
- package/lib/module/adapter/budgets.js +51 -0
- package/lib/module/adapter/budgets.js.map +1 -0
- package/lib/module/adapter/collection.js +232 -0
- package/lib/module/adapter/collection.js.map +1 -0
- package/lib/module/adapter/deletion.js +280 -0
- package/lib/module/adapter/deletion.js.map +1 -0
- package/lib/module/adapter/handle.js +254 -0
- package/lib/module/adapter/handle.js.map +1 -0
- package/lib/module/adapter/index.js +59 -0
- package/lib/module/adapter/index.js.map +1 -0
- package/lib/module/adapter/lifecycle.js +172 -0
- package/lib/module/adapter/lifecycle.js.map +1 -0
- package/lib/module/adapter/schema-sync.js +121 -0
- package/lib/module/adapter/schema-sync.js.map +1 -0
- package/lib/module/adapter/transaction.js +54 -0
- package/lib/module/adapter/transaction.js.map +1 -0
- package/lib/module/artifacts/availability.js +86 -0
- package/lib/module/artifacts/availability.js.map +1 -0
- package/lib/module/artifacts/cascade.js +75 -0
- package/lib/module/artifacts/cascade.js.map +1 -0
- package/lib/module/artifacts/paths.js +26 -0
- package/lib/module/artifacts/paths.js.map +1 -0
- package/lib/module/artifacts/reconcile.js +51 -0
- package/lib/module/artifacts/reconcile.js.map +1 -0
- package/lib/module/artifacts/store.js +289 -0
- package/lib/module/artifacts/store.js.map +1 -0
- package/lib/module/contract/adapter.js +4 -0
- package/lib/module/contract/adapter.js.map +1 -0
- package/lib/module/contract/attachment.js +2 -0
- package/lib/module/contract/attachment.js.map +1 -0
- package/lib/module/contract/backup.js +2 -0
- package/lib/module/contract/backup.js.map +1 -0
- package/lib/module/contract/config.js +27 -0
- package/lib/module/contract/config.js.map +1 -0
- package/lib/module/contract/encryption.js +4 -0
- package/lib/module/contract/encryption.js.map +1 -0
- package/lib/module/contract/errors.js +60 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/migration.js +4 -0
- package/lib/module/contract/migration.js.map +1 -0
- package/lib/module/contract/query.js +4 -0
- package/lib/module/contract/query.js.map +1 -0
- package/lib/module/contract/record.js +4 -0
- package/lib/module/contract/record.js.map +1 -0
- package/lib/module/contract/schema.js +2 -0
- package/lib/module/contract/schema.js.map +1 -0
- package/lib/module/contract/scope.js +2 -0
- package/lib/module/contract/scope.js.map +1 -0
- package/lib/module/contract/transaction.js +4 -0
- package/lib/module/contract/transaction.js.map +1 -0
- package/lib/module/crypto/chunked-cipher.js +134 -0
- package/lib/module/crypto/chunked-cipher.js.map +1 -0
- package/lib/module/crypto/derive.js +56 -0
- package/lib/module/crypto/derive.js.map +1 -0
- package/lib/module/crypto/key-provider.js +67 -0
- package/lib/module/crypto/key-provider.js.map +1 -0
- package/lib/module/crypto/provider.js +49 -0
- package/lib/module/crypto/provider.js.map +1 -0
- package/lib/module/diagnostics/dev-log.js +120 -0
- package/lib/module/diagnostics/dev-log.js.map +1 -0
- package/lib/module/diagnostics/errors.js +44 -0
- package/lib/module/diagnostics/errors.js.map +1 -0
- package/lib/module/diagnostics/faults.js +47 -0
- package/lib/module/diagnostics/faults.js.map +1 -0
- package/lib/module/diagnostics/map-native.js +93 -0
- package/lib/module/diagnostics/map-native.js.map +1 -0
- package/lib/module/diagnostics/redact.js +102 -0
- package/lib/module/diagnostics/redact.js.map +1 -0
- package/lib/module/index.js +28 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/migration/executor.js +132 -0
- package/lib/module/migration/executor.js.map +1 -0
- package/lib/module/migration/ledger.js +57 -0
- package/lib/module/migration/ledger.js.map +1 -0
- package/lib/module/migration/validate-chain.js +70 -0
- package/lib/module/migration/validate-chain.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/platform/backup-android-verify.js +69 -0
- package/lib/module/platform/backup-android-verify.js.map +1 -0
- package/lib/module/platform/backup-ios.js +44 -0
- package/lib/module/platform/backup-ios.js.map +1 -0
- package/lib/module/platform/bytes.js +148 -0
- package/lib/module/platform/bytes.js.map +1 -0
- package/lib/module/platform/fs.js +54 -0
- package/lib/module/platform/fs.js.map +1 -0
- package/lib/module/platform/location.js +120 -0
- package/lib/module/platform/location.js.map +1 -0
- package/lib/module/query/budgets.js +88 -0
- package/lib/module/query/budgets.js.map +1 -0
- package/lib/module/query/compare.js +90 -0
- package/lib/module/query/compare.js.map +1 -0
- package/lib/module/query/cursor.js +91 -0
- package/lib/module/query/cursor.js.map +1 -0
- package/lib/module/query/filter.js +78 -0
- package/lib/module/query/filter.js.map +1 -0
- package/lib/module/query/paginate.js +40 -0
- package/lib/module/query/paginate.js.map +1 -0
- package/lib/module/query/sort.js +53 -0
- package/lib/module/query/sort.js.map +1 -0
- package/lib/module/query/validate.js +173 -0
- package/lib/module/query/validate.js.map +1 -0
- package/lib/module/schema/declare.js +37 -0
- package/lib/module/schema/declare.js.map +1 -0
- package/lib/module/schema/validate-config.js +111 -0
- package/lib/module/schema/validate-config.js.map +1 -0
- package/lib/module/scope/hash.js +102 -0
- package/lib/module/scope/hash.js.map +1 -0
- package/lib/module/scope/normalize.js +67 -0
- package/lib/module/scope/normalize.js.map +1 -0
- package/lib/module/scope/validate.js +76 -0
- package/lib/module/scope/validate.js.map +1 -0
- package/lib/module/sqlite/adapter.js +27 -0
- package/lib/module/sqlite/adapter.js.map +1 -0
- package/lib/module/sqlite/batch.js +214 -0
- package/lib/module/sqlite/batch.js.map +1 -0
- package/lib/module/sqlite/catalog.js +72 -0
- package/lib/module/sqlite/catalog.js.map +1 -0
- package/lib/module/sqlite/connection.js +206 -0
- package/lib/module/sqlite/connection.js.map +1 -0
- package/lib/module/sqlite/index-coverage.js +38 -0
- package/lib/module/sqlite/index-coverage.js.map +1 -0
- package/lib/module/sqlite/native.js +48 -0
- package/lib/module/sqlite/native.js.map +1 -0
- package/lib/module/sqlite/row-codec.js +176 -0
- package/lib/module/sqlite/row-codec.js.map +1 -0
- package/lib/module/sqlite/sql-builder.js +247 -0
- package/lib/module/sqlite/sql-builder.js.map +1 -0
- package/lib/module/sqlite/statements.js +49 -0
- package/lib/module/sqlite/statements.js.map +1 -0
- package/lib/module/sqlite/transaction-queue.js +75 -0
- package/lib/module/sqlite/transaction-queue.js.map +1 -0
- package/lib/module/sqlite/transactions.js +29 -0
- package/lib/module/sqlite/transactions.js.map +1 -0
- package/lib/module/sqlite/values.js +24 -0
- package/lib/module/sqlite/values.js.map +1 -0
- package/lib/module/testing/conformance/attachments.js +176 -0
- package/lib/module/testing/conformance/attachments.js.map +1 -0
- package/lib/module/testing/conformance/encryption.js +183 -0
- package/lib/module/testing/conformance/encryption.js.map +1 -0
- package/lib/module/testing/conformance/index.js +97 -0
- package/lib/module/testing/conformance/index.js.map +1 -0
- package/lib/module/testing/conformance/lifecycle.js +130 -0
- package/lib/module/testing/conformance/lifecycle.js.map +1 -0
- package/lib/module/testing/conformance/migrations.js +163 -0
- package/lib/module/testing/conformance/migrations.js.map +1 -0
- package/lib/module/testing/conformance/queries.js +274 -0
- package/lib/module/testing/conformance/queries.js.map +1 -0
- package/lib/module/testing/conformance/records.js +220 -0
- package/lib/module/testing/conformance/records.js.map +1 -0
- package/lib/module/testing/conformance/scopes.js +103 -0
- package/lib/module/testing/conformance/scopes.js.map +1 -0
- package/lib/module/testing/conformance/transactions.js +224 -0
- package/lib/module/testing/conformance/transactions.js.map +1 -0
- package/lib/module/testing/faults.js +16 -0
- package/lib/module/testing/faults.js.map +1 -0
- package/lib/module/testing/index.js +16 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/memory-adapter/attachments.js +142 -0
- package/lib/module/testing/memory-adapter/attachments.js.map +1 -0
- package/lib/module/testing/memory-adapter/collection.js +220 -0
- package/lib/module/testing/memory-adapter/collection.js.map +1 -0
- package/lib/module/testing/memory-adapter/index.js +351 -0
- package/lib/module/testing/memory-adapter/index.js.map +1 -0
- package/lib/module/testing/memory-adapter/migrations.js +122 -0
- package/lib/module/testing/memory-adapter/migrations.js.map +1 -0
- package/lib/module/testing/memory-adapter/reset.js +44 -0
- package/lib/module/testing/memory-adapter/reset.js.map +1 -0
- package/lib/module/testing/memory-adapter/store.js +94 -0
- package/lib/module/testing/memory-adapter/store.js.map +1 -0
- package/lib/typescript/commonjs/adapter/budgets.d.ts +19 -0
- package/lib/typescript/commonjs/adapter/budgets.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/collection.d.ts +25 -0
- package/lib/typescript/commonjs/adapter/collection.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/deletion.d.ts +48 -0
- package/lib/typescript/commonjs/adapter/deletion.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/handle.d.ts +30 -0
- package/lib/typescript/commonjs/adapter/handle.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/index.d.ts +30 -0
- package/lib/typescript/commonjs/adapter/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/lifecycle.d.ts +25 -0
- package/lib/typescript/commonjs/adapter/lifecycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/schema-sync.d.ts +19 -0
- package/lib/typescript/commonjs/adapter/schema-sync.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/transaction.d.ts +32 -0
- package/lib/typescript/commonjs/adapter/transaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/availability.d.ts +19 -0
- package/lib/typescript/commonjs/artifacts/availability.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/cascade.d.ts +26 -0
- package/lib/typescript/commonjs/artifacts/cascade.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/paths.d.ts +16 -0
- package/lib/typescript/commonjs/artifacts/paths.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/reconcile.d.ts +23 -0
- package/lib/typescript/commonjs/artifacts/reconcile.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/store.d.ts +45 -0
- package/lib/typescript/commonjs/artifacts/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/adapter.d.ts +55 -0
- package/lib/typescript/commonjs/contract/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/attachment.d.ts +84 -0
- package/lib/typescript/commonjs/contract/attachment.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/backup.d.ts +26 -0
- package/lib/typescript/commonjs/contract/backup.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/config.d.ts +50 -0
- package/lib/typescript/commonjs/contract/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/encryption.d.ts +31 -0
- package/lib/typescript/commonjs/contract/encryption.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +50 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/migration.d.ts +37 -0
- package/lib/typescript/commonjs/contract/migration.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/query.d.ts +79 -0
- package/lib/typescript/commonjs/contract/query.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/record.d.ts +43 -0
- package/lib/typescript/commonjs/contract/record.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/schema.d.ts +33 -0
- package/lib/typescript/commonjs/contract/schema.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/scope.d.ts +33 -0
- package/lib/typescript/commonjs/contract/scope.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/transaction.d.ts +66 -0
- package/lib/typescript/commonjs/contract/transaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/chunked-cipher.d.ts +57 -0
- package/lib/typescript/commonjs/crypto/chunked-cipher.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/derive.d.ts +28 -0
- package/lib/typescript/commonjs/crypto/derive.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/key-provider.d.ts +30 -0
- package/lib/typescript/commonjs/crypto/key-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/provider.d.ts +35 -0
- package/lib/typescript/commonjs/crypto/provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/dev-log.d.ts +35 -0
- package/lib/typescript/commonjs/diagnostics/dev-log.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts +34 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/faults.d.ts +26 -0
- package/lib/typescript/commonjs/diagnostics/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/map-native.d.ts +31 -0
- package/lib/typescript/commonjs/diagnostics/map-native.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts +70 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +30 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/migration/executor.d.ts +40 -0
- package/lib/typescript/commonjs/migration/executor.d.ts.map +1 -0
- package/lib/typescript/commonjs/migration/ledger.d.ts +34 -0
- package/lib/typescript/commonjs/migration/ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/migration/validate-chain.d.ts +20 -0
- package/lib/typescript/commonjs/migration/validate-chain.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/platform/backup-android-verify.d.ts +30 -0
- package/lib/typescript/commonjs/platform/backup-android-verify.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/backup-ios.d.ts +26 -0
- package/lib/typescript/commonjs/platform/backup-ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/bytes.d.ts +36 -0
- package/lib/typescript/commonjs/platform/bytes.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/fs.d.ts +47 -0
- package/lib/typescript/commonjs/platform/fs.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/location.d.ts +53 -0
- package/lib/typescript/commonjs/platform/location.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/budgets.d.ts +23 -0
- package/lib/typescript/commonjs/query/budgets.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/compare.d.ts +42 -0
- package/lib/typescript/commonjs/query/compare.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/cursor.d.ts +27 -0
- package/lib/typescript/commonjs/query/cursor.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/filter.d.ts +11 -0
- package/lib/typescript/commonjs/query/filter.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/paginate.d.ts +15 -0
- package/lib/typescript/commonjs/query/paginate.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/sort.d.ts +19 -0
- package/lib/typescript/commonjs/query/sort.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/validate.d.ts +15 -0
- package/lib/typescript/commonjs/query/validate.d.ts.map +1 -0
- package/lib/typescript/commonjs/schema/declare.d.ts +20 -0
- package/lib/typescript/commonjs/schema/declare.d.ts.map +1 -0
- package/lib/typescript/commonjs/schema/validate-config.d.ts +11 -0
- package/lib/typescript/commonjs/schema/validate-config.d.ts.map +1 -0
- package/lib/typescript/commonjs/scope/hash.d.ts +24 -0
- package/lib/typescript/commonjs/scope/hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/scope/normalize.d.ts +46 -0
- package/lib/typescript/commonjs/scope/normalize.d.ts.map +1 -0
- package/lib/typescript/commonjs/scope/validate.d.ts +15 -0
- package/lib/typescript/commonjs/scope/validate.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/adapter.d.ts +16 -0
- package/lib/typescript/commonjs/sqlite/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/batch.d.ts +25 -0
- package/lib/typescript/commonjs/sqlite/batch.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/catalog.d.ts +34 -0
- package/lib/typescript/commonjs/sqlite/catalog.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/connection.d.ts +58 -0
- package/lib/typescript/commonjs/sqlite/connection.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/index-coverage.d.ts +18 -0
- package/lib/typescript/commonjs/sqlite/index-coverage.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/native.d.ts +48 -0
- package/lib/typescript/commonjs/sqlite/native.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/row-codec.d.ts +69 -0
- package/lib/typescript/commonjs/sqlite/row-codec.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/sql-builder.d.ts +34 -0
- package/lib/typescript/commonjs/sqlite/sql-builder.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/statements.d.ts +26 -0
- package/lib/typescript/commonjs/sqlite/statements.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/transaction-queue.d.ts +31 -0
- package/lib/typescript/commonjs/sqlite/transaction-queue.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/transactions.d.ts +26 -0
- package/lib/typescript/commonjs/sqlite/transactions.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/values.d.ts +13 -0
- package/lib/typescript/commonjs/sqlite/values.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/attachments.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/attachments.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/encryption.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/encryption.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts +58 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/lifecycle.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/lifecycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/migrations.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/migrations.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/queries.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/queries.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/records.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/records.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/scopes.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/scopes.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/transactions.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/transactions.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/faults.d.ts +13 -0
- package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +13 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/attachments.d.ts +23 -0
- package/lib/typescript/commonjs/testing/memory-adapter/attachments.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/collection.d.ts +19 -0
- package/lib/typescript/commonjs/testing/memory-adapter/collection.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/index.d.ts +22 -0
- package/lib/typescript/commonjs/testing/memory-adapter/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/migrations.d.ts +11 -0
- package/lib/typescript/commonjs/testing/memory-adapter/migrations.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/reset.d.ts +23 -0
- package/lib/typescript/commonjs/testing/memory-adapter/reset.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/store.d.ts +54 -0
- package/lib/typescript/commonjs/testing/memory-adapter/store.d.ts.map +1 -0
- package/lib/typescript/module/adapter/budgets.d.ts +19 -0
- package/lib/typescript/module/adapter/budgets.d.ts.map +1 -0
- package/lib/typescript/module/adapter/collection.d.ts +25 -0
- package/lib/typescript/module/adapter/collection.d.ts.map +1 -0
- package/lib/typescript/module/adapter/deletion.d.ts +48 -0
- package/lib/typescript/module/adapter/deletion.d.ts.map +1 -0
- package/lib/typescript/module/adapter/handle.d.ts +30 -0
- package/lib/typescript/module/adapter/handle.d.ts.map +1 -0
- package/lib/typescript/module/adapter/index.d.ts +30 -0
- package/lib/typescript/module/adapter/index.d.ts.map +1 -0
- package/lib/typescript/module/adapter/lifecycle.d.ts +25 -0
- package/lib/typescript/module/adapter/lifecycle.d.ts.map +1 -0
- package/lib/typescript/module/adapter/schema-sync.d.ts +19 -0
- package/lib/typescript/module/adapter/schema-sync.d.ts.map +1 -0
- package/lib/typescript/module/adapter/transaction.d.ts +32 -0
- package/lib/typescript/module/adapter/transaction.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/availability.d.ts +19 -0
- package/lib/typescript/module/artifacts/availability.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/cascade.d.ts +26 -0
- package/lib/typescript/module/artifacts/cascade.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/paths.d.ts +16 -0
- package/lib/typescript/module/artifacts/paths.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/reconcile.d.ts +23 -0
- package/lib/typescript/module/artifacts/reconcile.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/store.d.ts +45 -0
- package/lib/typescript/module/artifacts/store.d.ts.map +1 -0
- package/lib/typescript/module/contract/adapter.d.ts +55 -0
- package/lib/typescript/module/contract/adapter.d.ts.map +1 -0
- package/lib/typescript/module/contract/attachment.d.ts +84 -0
- package/lib/typescript/module/contract/attachment.d.ts.map +1 -0
- package/lib/typescript/module/contract/backup.d.ts +26 -0
- package/lib/typescript/module/contract/backup.d.ts.map +1 -0
- package/lib/typescript/module/contract/config.d.ts +50 -0
- package/lib/typescript/module/contract/config.d.ts.map +1 -0
- package/lib/typescript/module/contract/encryption.d.ts +31 -0
- package/lib/typescript/module/contract/encryption.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +50 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/migration.d.ts +37 -0
- package/lib/typescript/module/contract/migration.d.ts.map +1 -0
- package/lib/typescript/module/contract/query.d.ts +79 -0
- package/lib/typescript/module/contract/query.d.ts.map +1 -0
- package/lib/typescript/module/contract/record.d.ts +43 -0
- package/lib/typescript/module/contract/record.d.ts.map +1 -0
- package/lib/typescript/module/contract/schema.d.ts +33 -0
- package/lib/typescript/module/contract/schema.d.ts.map +1 -0
- package/lib/typescript/module/contract/scope.d.ts +33 -0
- package/lib/typescript/module/contract/scope.d.ts.map +1 -0
- package/lib/typescript/module/contract/transaction.d.ts +66 -0
- package/lib/typescript/module/contract/transaction.d.ts.map +1 -0
- package/lib/typescript/module/crypto/chunked-cipher.d.ts +57 -0
- package/lib/typescript/module/crypto/chunked-cipher.d.ts.map +1 -0
- package/lib/typescript/module/crypto/derive.d.ts +28 -0
- package/lib/typescript/module/crypto/derive.d.ts.map +1 -0
- package/lib/typescript/module/crypto/key-provider.d.ts +30 -0
- package/lib/typescript/module/crypto/key-provider.d.ts.map +1 -0
- package/lib/typescript/module/crypto/provider.d.ts +35 -0
- package/lib/typescript/module/crypto/provider.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/dev-log.d.ts +35 -0
- package/lib/typescript/module/diagnostics/dev-log.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/errors.d.ts +34 -0
- package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/faults.d.ts +26 -0
- package/lib/typescript/module/diagnostics/faults.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/map-native.d.ts +31 -0
- package/lib/typescript/module/diagnostics/map-native.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/redact.d.ts +70 -0
- package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +30 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/migration/executor.d.ts +40 -0
- package/lib/typescript/module/migration/executor.d.ts.map +1 -0
- package/lib/typescript/module/migration/ledger.d.ts +34 -0
- package/lib/typescript/module/migration/ledger.d.ts.map +1 -0
- package/lib/typescript/module/migration/validate-chain.d.ts +20 -0
- package/lib/typescript/module/migration/validate-chain.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/platform/backup-android-verify.d.ts +30 -0
- package/lib/typescript/module/platform/backup-android-verify.d.ts.map +1 -0
- package/lib/typescript/module/platform/backup-ios.d.ts +26 -0
- package/lib/typescript/module/platform/backup-ios.d.ts.map +1 -0
- package/lib/typescript/module/platform/bytes.d.ts +36 -0
- package/lib/typescript/module/platform/bytes.d.ts.map +1 -0
- package/lib/typescript/module/platform/fs.d.ts +47 -0
- package/lib/typescript/module/platform/fs.d.ts.map +1 -0
- package/lib/typescript/module/platform/location.d.ts +53 -0
- package/lib/typescript/module/platform/location.d.ts.map +1 -0
- package/lib/typescript/module/query/budgets.d.ts +23 -0
- package/lib/typescript/module/query/budgets.d.ts.map +1 -0
- package/lib/typescript/module/query/compare.d.ts +42 -0
- package/lib/typescript/module/query/compare.d.ts.map +1 -0
- package/lib/typescript/module/query/cursor.d.ts +27 -0
- package/lib/typescript/module/query/cursor.d.ts.map +1 -0
- package/lib/typescript/module/query/filter.d.ts +11 -0
- package/lib/typescript/module/query/filter.d.ts.map +1 -0
- package/lib/typescript/module/query/paginate.d.ts +15 -0
- package/lib/typescript/module/query/paginate.d.ts.map +1 -0
- package/lib/typescript/module/query/sort.d.ts +19 -0
- package/lib/typescript/module/query/sort.d.ts.map +1 -0
- package/lib/typescript/module/query/validate.d.ts +15 -0
- package/lib/typescript/module/query/validate.d.ts.map +1 -0
- package/lib/typescript/module/schema/declare.d.ts +20 -0
- package/lib/typescript/module/schema/declare.d.ts.map +1 -0
- package/lib/typescript/module/schema/validate-config.d.ts +11 -0
- package/lib/typescript/module/schema/validate-config.d.ts.map +1 -0
- package/lib/typescript/module/scope/hash.d.ts +24 -0
- package/lib/typescript/module/scope/hash.d.ts.map +1 -0
- package/lib/typescript/module/scope/normalize.d.ts +46 -0
- package/lib/typescript/module/scope/normalize.d.ts.map +1 -0
- package/lib/typescript/module/scope/validate.d.ts +15 -0
- package/lib/typescript/module/scope/validate.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/adapter.d.ts +16 -0
- package/lib/typescript/module/sqlite/adapter.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/batch.d.ts +25 -0
- package/lib/typescript/module/sqlite/batch.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/catalog.d.ts +34 -0
- package/lib/typescript/module/sqlite/catalog.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/connection.d.ts +58 -0
- package/lib/typescript/module/sqlite/connection.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/index-coverage.d.ts +18 -0
- package/lib/typescript/module/sqlite/index-coverage.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/native.d.ts +48 -0
- package/lib/typescript/module/sqlite/native.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/row-codec.d.ts +69 -0
- package/lib/typescript/module/sqlite/row-codec.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/sql-builder.d.ts +34 -0
- package/lib/typescript/module/sqlite/sql-builder.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/statements.d.ts +26 -0
- package/lib/typescript/module/sqlite/statements.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/transaction-queue.d.ts +31 -0
- package/lib/typescript/module/sqlite/transaction-queue.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/transactions.d.ts +26 -0
- package/lib/typescript/module/sqlite/transactions.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/values.d.ts +13 -0
- package/lib/typescript/module/sqlite/values.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/attachments.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/attachments.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/encryption.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/encryption.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/index.d.ts +58 -0
- package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/lifecycle.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/lifecycle.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/migrations.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/migrations.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/queries.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/queries.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/records.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/records.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/scopes.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/scopes.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/transactions.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/transactions.d.ts.map +1 -0
- package/lib/typescript/module/testing/faults.d.ts +13 -0
- package/lib/typescript/module/testing/faults.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +13 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/attachments.d.ts +23 -0
- package/lib/typescript/module/testing/memory-adapter/attachments.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/collection.d.ts +19 -0
- package/lib/typescript/module/testing/memory-adapter/collection.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/index.d.ts +22 -0
- package/lib/typescript/module/testing/memory-adapter/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/migrations.d.ts +11 -0
- package/lib/typescript/module/testing/memory-adapter/migrations.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/reset.d.ts +23 -0
- package/lib/typescript/module/testing/memory-adapter/reset.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/store.d.ts +54 -0
- package/lib/typescript/module/testing/memory-adapter/store.d.ts.map +1 -0
- package/package.json +51 -16
- package/src/crypto/provider.ts +7 -3
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Artifacts: the file on disk and the reference to it.
|
|
5
|
+
*
|
|
6
|
+
* The reference lives in the scope's own database, so a reference created
|
|
7
|
+
* inside a transaction rolls back with it (FR-072) — no bookkeeping required,
|
|
8
|
+
* because the connection routes through the transaction in flight.
|
|
9
|
+
*
|
|
10
|
+
* The file does not roll back. A filesystem write is not part of a SQL
|
|
11
|
+
* transaction and cannot be made part of one, so a rolled-back transaction
|
|
12
|
+
* leaves an artifact on disk with nothing pointing at it. That is not a bug
|
|
13
|
+
* to be engineered away; it is why reconciliation exists (FR-073d), and why
|
|
14
|
+
* the write order is deliberate: **the file completes first, then the
|
|
15
|
+
* reference**. The reverse order would produce a reference to a file that
|
|
16
|
+
* does not exist, which is the failure a consumer cannot recover from — it
|
|
17
|
+
* looks like data the app has and does not.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { Budgets } from "../contract/config.js";
|
|
21
|
+
import { DiagnosticCodes } from "../contract/errors.js";
|
|
22
|
+
import { isStorageError, raise } from "../diagnostics/errors.js";
|
|
23
|
+
import { throwIfFaulted } from "../diagnostics/faults.js";
|
|
24
|
+
import { raiseNative } from "../diagnostics/map-native.js";
|
|
25
|
+
import { fileSystem, removeIfPresent } from "../platform/fs.js";
|
|
26
|
+
import { base64ToBytes, bytesToBase64, concatBytes } from "../platform/bytes.js";
|
|
27
|
+
import { assertArtifactWithinBudget } from "../query/budgets.js";
|
|
28
|
+
import { HEADER_BYTES, TAG_BYTES, chunkOffset, chunkPlaintextLength, decodeHeader, decryptChunk, encodeHeader, encryptChunk, headerFor } from "../crypto/chunked-cipher.js";
|
|
29
|
+
import { maybeNum, num, text } from "../sqlite/values.js";
|
|
30
|
+
import { artifactPath, artifactsDirectory } from "./paths.js";
|
|
31
|
+
const CREATE_ATTACHMENTS = `CREATE TABLE IF NOT EXISTS _attachments (
|
|
32
|
+
id TEXT PRIMARY KEY,
|
|
33
|
+
owner_collection TEXT,
|
|
34
|
+
owner_id TEXT,
|
|
35
|
+
content_type TEXT NOT NULL,
|
|
36
|
+
size INTEGER NOT NULL,
|
|
37
|
+
chunk_size INTEGER,
|
|
38
|
+
chunk_count INTEGER,
|
|
39
|
+
created_at INTEGER NOT NULL
|
|
40
|
+
)`;
|
|
41
|
+
const CREATE_OWNER_INDEX = 'CREATE INDEX IF NOT EXISTS _attachments_owner ON _attachments (owner_collection, owner_id)';
|
|
42
|
+
export async function ensureAttachmentTable(executor) {
|
|
43
|
+
await executor.execute(CREATE_ATTACHMENTS);
|
|
44
|
+
await executor.execute(CREATE_OWNER_INDEX);
|
|
45
|
+
}
|
|
46
|
+
function toReference(row) {
|
|
47
|
+
const reference = {
|
|
48
|
+
id: text(row.id),
|
|
49
|
+
contentType: text(row.content_type),
|
|
50
|
+
size: num(row.size),
|
|
51
|
+
createdAt: num(row.created_at)
|
|
52
|
+
};
|
|
53
|
+
if (row.owner_collection != null && row.owner_id != null) {
|
|
54
|
+
reference.owner = {
|
|
55
|
+
collection: text(row.owner_collection),
|
|
56
|
+
id: text(row.owner_id)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const chunkSize = maybeNum(row.chunk_size);
|
|
60
|
+
if (chunkSize !== null) {
|
|
61
|
+
reference.chunkSize = chunkSize;
|
|
62
|
+
reference.chunkCount = num(row.chunk_count);
|
|
63
|
+
}
|
|
64
|
+
return reference;
|
|
65
|
+
}
|
|
66
|
+
export async function readReference(executor, id) {
|
|
67
|
+
const result = await executor.execute('SELECT * FROM _attachments WHERE id = ?', [id]);
|
|
68
|
+
const row = result.rows[0];
|
|
69
|
+
return row ? toReference(row) : null;
|
|
70
|
+
}
|
|
71
|
+
export async function listReferences(executor) {
|
|
72
|
+
const result = await executor.execute('SELECT * FROM _attachments ORDER BY id ASC');
|
|
73
|
+
return result.rows.map(toReference);
|
|
74
|
+
}
|
|
75
|
+
export async function listReferencesFor(executor, owner) {
|
|
76
|
+
const result = await executor.execute('SELECT * FROM _attachments WHERE owner_collection = ? AND owner_id = ? ORDER BY id ASC', [owner.collection, owner.id]);
|
|
77
|
+
return result.rows.map(toReference);
|
|
78
|
+
}
|
|
79
|
+
async function insertReference(executor, reference) {
|
|
80
|
+
await executor.execute(`INSERT INTO _attachments
|
|
81
|
+
(id, owner_collection, owner_id, content_type, size, chunk_size, chunk_count, created_at)
|
|
82
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
83
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
84
|
+
owner_collection = excluded.owner_collection,
|
|
85
|
+
owner_id = excluded.owner_id,
|
|
86
|
+
content_type = excluded.content_type,
|
|
87
|
+
size = excluded.size,
|
|
88
|
+
chunk_size = excluded.chunk_size,
|
|
89
|
+
chunk_count = excluded.chunk_count,
|
|
90
|
+
created_at = excluded.created_at`, [reference.id, reference.owner?.collection ?? null, reference.owner?.id ?? null, reference.contentType, reference.size, reference.chunkSize ?? null, reference.chunkCount ?? null, reference.createdAt]);
|
|
91
|
+
}
|
|
92
|
+
export async function deleteReference(executor, id) {
|
|
93
|
+
const result = await executor.execute('DELETE FROM _attachments WHERE id = ?', [id]);
|
|
94
|
+
return result.rowsAffected > 0;
|
|
95
|
+
}
|
|
96
|
+
async function writePlaintext(path, content) {
|
|
97
|
+
await fileSystem().writeFile(path, content, 'base64');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Where an artifact's bytes come from: how many, and any one chunk of them. */
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Encrypted write, one chunk in flight.
|
|
104
|
+
*
|
|
105
|
+
* The header goes down first because its contents — chunk size, chunk count,
|
|
106
|
+
* plaintext length — are all known from the input length before any
|
|
107
|
+
* encryption happens. Only the tags depend on the ciphertext, and they follow
|
|
108
|
+
* their own chunk, so the whole write is append-only and peak memory is one
|
|
109
|
+
* chunk regardless of artifact size when the source is a file (FR-107a).
|
|
110
|
+
*/
|
|
111
|
+
async function writeEncrypted(path, key, source) {
|
|
112
|
+
const header = headerFor(source.size, Budgets.ARTIFACT_CHUNK_BYTES);
|
|
113
|
+
await fileSystem().writeFile(path, bytesToBase64(encodeHeader(header)), 'base64');
|
|
114
|
+
for (let index = 0; index < header.chunkCount; index += 1) {
|
|
115
|
+
const chunk = await source.chunk(index * header.chunkSize, chunkPlaintextLength(header, index));
|
|
116
|
+
await fileSystem().appendFile(path, bytesToBase64(encryptChunk(key, index, chunk)), 'base64');
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
chunkSize: header.chunkSize,
|
|
120
|
+
chunkCount: header.chunkCount
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function sourceFileOf(input) {
|
|
124
|
+
if (typeof input.sourcePath !== 'string') {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return input.sourcePath.startsWith('file://') ? input.sourcePath.slice('file://'.length) : input.sourcePath;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The input as something to read from. A base64 `content` is decoded whole,
|
|
132
|
+
* which is the cost of that form; a `sourcePath` is only measured here and
|
|
133
|
+
* read a chunk at a time, or not read by JS at all (LDB-09).
|
|
134
|
+
*/
|
|
135
|
+
async function byteSourceFor(input) {
|
|
136
|
+
const file = sourceFileOf(input);
|
|
137
|
+
if (file === null) {
|
|
138
|
+
if (typeof input.content !== 'string') {
|
|
139
|
+
raise(DiagnosticCodes.CONFIG_INVALID, {
|
|
140
|
+
message: 'an attachment needs content or sourcePath',
|
|
141
|
+
detail: {
|
|
142
|
+
attachmentId: input.id
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const plaintext = base64ToBytes(input.content);
|
|
147
|
+
return {
|
|
148
|
+
size: plaintext.length,
|
|
149
|
+
chunk: async (offset, length) => plaintext.subarray(offset, offset + length)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
let size;
|
|
153
|
+
try {
|
|
154
|
+
size = (await fileSystem().stat(file)).size;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
raiseNative(error, {
|
|
157
|
+
operation: 'attachment'
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
size,
|
|
162
|
+
chunk: async (offset, length) => base64ToBytes(await fileSystem().read(file, length, offset, 'base64'))
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export async function writeArtifact(context, input) {
|
|
166
|
+
throwIfFaulted('attachmentWrite');
|
|
167
|
+
const source = await byteSourceFor(input);
|
|
168
|
+
assertArtifactWithinBudget(input.id, source.size);
|
|
169
|
+
const path = artifactPath(context.layout, context.scopeKey, input.id);
|
|
170
|
+
const key = context.artifactKey(input.id);
|
|
171
|
+
const file = sourceFileOf(input);
|
|
172
|
+
let chunking;
|
|
173
|
+
try {
|
|
174
|
+
await fileSystem().mkdir(artifactsDirectory(context.layout, context.scopeKey));
|
|
175
|
+
if (key) {
|
|
176
|
+
chunking = await writeEncrypted(path, key, source);
|
|
177
|
+
} else if (file !== null) {
|
|
178
|
+
await fileSystem().copyFile(file, path);
|
|
179
|
+
} else {
|
|
180
|
+
await writePlaintext(path, input.content);
|
|
181
|
+
}
|
|
182
|
+
} catch (error) {
|
|
183
|
+
// A partial file with no reference is an orphan reconciliation can
|
|
184
|
+
// find; a reference to a partial file is data the app believes it has.
|
|
185
|
+
await removeIfPresent(path);
|
|
186
|
+
raiseNative(error, {
|
|
187
|
+
operation: 'attachment'
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const reference = {
|
|
191
|
+
id: input.id,
|
|
192
|
+
contentType: input.contentType,
|
|
193
|
+
size: source.size,
|
|
194
|
+
createdAt: context.now()
|
|
195
|
+
};
|
|
196
|
+
if (input.owner) {
|
|
197
|
+
reference.owner = input.owner;
|
|
198
|
+
}
|
|
199
|
+
if (chunking) {
|
|
200
|
+
reference.chunkSize = chunking.chunkSize;
|
|
201
|
+
reference.chunkCount = chunking.chunkCount;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Only now. See the note at the top of this file.
|
|
205
|
+
await insertReference(context.executor(), reference);
|
|
206
|
+
return reference;
|
|
207
|
+
}
|
|
208
|
+
async function readPlaintext(path, range) {
|
|
209
|
+
if (!range) {
|
|
210
|
+
return fileSystem().readFile(path, 'base64');
|
|
211
|
+
}
|
|
212
|
+
return fileSystem().read(path, range.length, range.offset, 'base64');
|
|
213
|
+
}
|
|
214
|
+
async function readEncrypted(path, key, range) {
|
|
215
|
+
const headerBytes = base64ToBytes(await fileSystem().read(path, HEADER_BYTES, 0, 'base64'));
|
|
216
|
+
const header = decodeHeader(headerBytes);
|
|
217
|
+
const from = range?.offset ?? 0;
|
|
218
|
+
const to = range ? Math.min(header.plaintextSize, from + range.length) : header.plaintextSize;
|
|
219
|
+
if (to <= from) {
|
|
220
|
+
return '';
|
|
221
|
+
}
|
|
222
|
+
const first = Math.floor(from / header.chunkSize);
|
|
223
|
+
const last = Math.floor((to - 1) / header.chunkSize);
|
|
224
|
+
const pieces = [];
|
|
225
|
+
for (let index = first; index <= last; index += 1) {
|
|
226
|
+
const stored = base64ToBytes(await fileSystem().read(path, chunkPlaintextLength(header, index) + TAG_BYTES, chunkOffset(header, index), 'base64'));
|
|
227
|
+
const decrypted = decryptChunk(key, index, stored);
|
|
228
|
+
const chunkStart = index * header.chunkSize;
|
|
229
|
+
pieces.push(decrypted.subarray(Math.max(0, from - chunkStart), Math.min(decrypted.length, to - chunkStart)));
|
|
230
|
+
}
|
|
231
|
+
return bytesToBase64(concatBytes(pieces));
|
|
232
|
+
}
|
|
233
|
+
export async function readArtifact(context, id, range) {
|
|
234
|
+
const path = artifactPath(context.layout, context.scopeKey, id);
|
|
235
|
+
const key = context.artifactKey(id);
|
|
236
|
+
try {
|
|
237
|
+
return key ? await readEncrypted(path, key, range) : await readPlaintext(path, range);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
// A typed error the package already classified — an unreadable header,
|
|
240
|
+
// a failing tag — says something more specific than "missing" and must
|
|
241
|
+
// survive. Anything else reaching here is the file not being there.
|
|
242
|
+
if (isStorageError(error)) {
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
raise(DiagnosticCodes.ATTACHMENT_MISSING, {
|
|
246
|
+
message: 'artifact is missing',
|
|
247
|
+
detail: {
|
|
248
|
+
attachmentId: id
|
|
249
|
+
},
|
|
250
|
+
cause: error
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Collects file removals until the transaction that deleted their references
|
|
257
|
+
* commits. A file unlinked inside the transaction is gone even if the
|
|
258
|
+
* transaction then rolls back and the reference returns — a dangling
|
|
259
|
+
* reference to data nobody can recover.
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
export async function removeArtifact(context, id, deferred) {
|
|
263
|
+
const path = artifactPath(context.layout, context.scopeKey, id);
|
|
264
|
+
if (deferred) {
|
|
265
|
+
// Inside a transaction: the reference goes now and rolls back with it;
|
|
266
|
+
// the file goes once the transaction commits.
|
|
267
|
+
const hadReference = await deleteReference(context.executor(), id);
|
|
268
|
+
if (hadReference) {
|
|
269
|
+
deferred.add(path);
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
removedRecords: 0,
|
|
273
|
+
removedArtifacts: hadReference ? [id] : [],
|
|
274
|
+
orphanedReferences: [],
|
|
275
|
+
failedRemovals: []
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const removed = await removeIfPresent(path);
|
|
279
|
+
const hadReference = await deleteReference(context.executor(), id);
|
|
280
|
+
return {
|
|
281
|
+
removedRecords: 0,
|
|
282
|
+
removedArtifacts: removed ? [id] : [],
|
|
283
|
+
// A reference with no file left behind is worth reporting rather than
|
|
284
|
+
// rounding up to success (FR-071).
|
|
285
|
+
orphanedReferences: !removed && hadReference ? [id] : [],
|
|
286
|
+
failedRemovals: []
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Budgets","DiagnosticCodes","isStorageError","raise","throwIfFaulted","raiseNative","fileSystem","removeIfPresent","base64ToBytes","bytesToBase64","concatBytes","assertArtifactWithinBudget","HEADER_BYTES","TAG_BYTES","chunkOffset","chunkPlaintextLength","decodeHeader","decryptChunk","encodeHeader","encryptChunk","headerFor","maybeNum","num","text","artifactPath","artifactsDirectory","CREATE_ATTACHMENTS","CREATE_OWNER_INDEX","ensureAttachmentTable","executor","execute","toReference","row","reference","id","contentType","content_type","size","createdAt","created_at","owner_collection","owner_id","owner","collection","chunkSize","chunk_size","chunkCount","chunk_count","readReference","result","rows","listReferences","map","listReferencesFor","insertReference","deleteReference","rowsAffected","writePlaintext","path","content","writeFile","writeEncrypted","key","source","header","ARTIFACT_CHUNK_BYTES","index","chunk","appendFile","sourceFileOf","input","sourcePath","startsWith","slice","length","byteSourceFor","file","CONFIG_INVALID","message","detail","attachmentId","plaintext","offset","subarray","stat","error","operation","read","writeArtifact","context","layout","scopeKey","artifactKey","chunking","mkdir","copyFile","now","readPlaintext","range","readFile","readEncrypted","headerBytes","from","to","Math","min","plaintextSize","first","floor","last","pieces","stored","decrypted","chunkStart","push","max","readArtifact","ATTACHMENT_MISSING","cause","removeArtifact","deferred","hadReference","add","removedRecords","removedArtifacts","orphanedReferences","failedRemovals","removed"],"sourceRoot":"../../../src","sources":["artifacts/store.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,OAAO,QAAQ,uBAAoB;AAC5C,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASC,cAAc,EAAEC,KAAK,QAAQ,0BAAuB;AAC7D,SAASC,cAAc,QAAQ,0BAAuB;AACtD,SAASC,WAAW,QAAQ,8BAA2B;AACvD,SAASC,UAAU,EAAEC,eAAe,QAAQ,mBAAgB;AAC5D,SAASC,aAAa,EAAEC,aAAa,EAAEC,WAAW,QAAQ,sBAAmB;AAE7E,SAASC,0BAA0B,QAAQ,qBAAkB;AAC7D,SACCC,YAAY,EACZC,SAAS,EACTC,WAAW,EACXC,oBAAoB,EACpBC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,SAAS,QACH,6BAA0B;AAEjC,SAASC,QAAQ,EAAEC,GAAG,EAAEC,IAAI,QAAQ,qBAAkB;AACtD,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,YAAS;AAE1D,MAAMC,kBAAkB,GAAG;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AAEF,MAAMC,kBAAkB,GACvB,4FAA4F;AAW7F,OAAO,eAAeC,qBAAqBA,CAACC,QAAkB,EAAiB;EAC9E,MAAMA,QAAQ,CAACC,OAAO,CAACJ,kBAAkB,CAAC;EAC1C,MAAMG,QAAQ,CAACC,OAAO,CAACH,kBAAkB,CAAC;AAC3C;AAEA,SAASI,WAAWA,CAACC,GAA4B,EAAuB;EACvE,MAAMC,SAA8B,GAAG;IACtCC,EAAE,EAAEX,IAAI,CAACS,GAAG,CAACE,EA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ACzCvC,OAAO,EAAE,qBAAqB;MAC9BC,MAAM,EAAE;QAAEC,YAAY,EAAE9C;MAAG,CAAC;MAC5BoF,KAAK,EAAEjC;IACR,CAAC,CAAC;EACH;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,eAAekC,cAAcA,CACnC9B,OAAwB,EACxBvD,EAAU,EACVsF,QAA0B,EACC;EAC3B,MAAM9D,IAAI,GAAGlC,YAAY,CAACiE,OAAO,CAACC,MAAM,EAAED,OAAO,CAACE,QAAQ,EAAEzD,EAAE,CAAC;EAC/D,IAAIsF,QAAQ,EAAE;IACb;IACA;IACA,MAAMC,YAAY,GAAG,MAAMlE,eAAe,CAACkC,OAAO,CAAC5D,QAAQ,CAAC,CAAC,EAAEK,EAAE,CAAC;IAClE,IAAIuF,YAAY,EAAE;MACjBD,QAAQ,CAACE,GAAG,CAAChE,IAAI,CAAC;IACnB;IACA,OAAO;MACNiE,cAAc,EAAE,CAAC;MACjBC,gBAAgB,EAAEH,YAAY,GAAG,CAACvF,EAAE,CAAC,GAAG,EAAE;MAC1C2F,kBAAkB,EAAE,EAAE;MACtBC,cAAc,EAAE;IACjB,CAAC;EACF;EACA,MAAMC,OAAO,GAAG,MAAMxH,eAAe,CAACmD,IAAI,CAAC;EAC3C,MAAM+D,YAAY,GAAG,MAAMlE,eAAe,CAACkC,OAAO,CAAC5D,QAAQ,CAAC,CAAC,EAAEK,EAAE,CAAC;EAElE,OAAO;IACNyF,cAAc,EAAE,CAAC;IACjBC,gBAAgB,EAAEG,OAAO,GAAG,CAAC7F,EAAE,CAAC,GAAG,EAAE;IACrC;IACA;IACA2F,kBAAkB,EAAE,CAACE,OAAO,IAAIN,YAAY,GAAG,CAACvF,EAAE,CAAC,GAAG,EAAE;IACxD4F,cAAc,EAAE;EACjB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/adapter.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/attachment.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/backup.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Database configuration: everything an app supplies at open time.
|
|
5
|
+
*
|
|
6
|
+
* Immutable for the handle's lifetime. Scope in particular is bound here and
|
|
7
|
+
* never changes (FR-008a) — there is no switchScope, and no operation takes a
|
|
8
|
+
* scope argument, which is what makes cross-scope leakage inexpressible
|
|
9
|
+
* rather than merely prevented.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Phase-one budgets (FR-088). Confirmed against the harness during validation. */
|
|
13
|
+
export const Budgets = {
|
|
14
|
+
MAX_RECORDS_PER_COLLECTION: 100_000,
|
|
15
|
+
MAX_RECORD_BYTES: 256 * 1024,
|
|
16
|
+
MAX_BATCH_OPERATIONS: 1_000,
|
|
17
|
+
MAX_PAGE_SIZE: 500,
|
|
18
|
+
MAX_COLLECTIONS_PER_DATABASE: 50,
|
|
19
|
+
MAX_ATTACHMENT_REFERENCES_PER_SCOPE: 50_000,
|
|
20
|
+
MAX_ARTIFACT_BYTES: 100 * 1024 * 1024,
|
|
21
|
+
MAX_OPEN_HANDLES: 8,
|
|
22
|
+
/** Plaintext chunk size for encrypted artifacts (research.md R4). */
|
|
23
|
+
ARTIFACT_CHUNK_BYTES: 256 * 1024
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Names a scope for the operations that legitimately need to (FR-059). */
|
|
27
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Budgets","MAX_RECORDS_PER_COLLECTION","MAX_RECORD_BYTES","MAX_BATCH_OPERATIONS","MAX_PAGE_SIZE","MAX_COLLECTIONS_PER_DATABASE","MAX_ATTACHMENT_REFERENCES_PER_SCOPE","MAX_ARTIFACT_BYTES","MAX_OPEN_HANDLES","ARTIFACT_CHUNK_BYTES"],"sourceRoot":"../../../src","sources":["contract/config.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA,OAAO,MAAMA,OAAO,GAAG;EACtBC,0BAA0B,EAAE,OAAO;EACnCC,gBAAgB,EAAE,GAAG,GAAG,IAAI;EAC5BC,oBAAoB,EAAE,KAAK;EAC3BC,aAAa,EAAE,GAAG;EAClBC,4BAA4B,EAAE,EAAE;EAChCC,mCAAmC,EAAE,MAAM;EAC3CC,kBAAkB,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;EACrCC,gBAAgB,EAAE,CAAC;EACnB;EACAC,oBAAoB,EAAE,GAAG,GAAG;AAC7B,CAAU;;AAiBV","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/encryption.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Diagnostic codes.
|
|
5
|
+
*
|
|
6
|
+
* Stable identifiers so an app can choose a response without parsing a
|
|
7
|
+
* message (FR-074, FR-082). Disk-full, filesystem-access, and corruption stay
|
|
8
|
+
* distinct rather than collapsing into a generic write failure (FR-076) —
|
|
9
|
+
* an app frees space for one, retries after unlock for another, and offers a
|
|
10
|
+
* reset for the third.
|
|
11
|
+
*
|
|
12
|
+
* Full table with recommended recovery per code:
|
|
13
|
+
* specs/008-rn-local-db-package/contracts/errors.md
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const DiagnosticCodes = {
|
|
17
|
+
// Configuration and scope
|
|
18
|
+
CONFIG_INVALID: 'CONFIG_INVALID',
|
|
19
|
+
INVALID_SCOPE: 'INVALID_SCOPE',
|
|
20
|
+
MIGRATION_CONFIG_INVALID: 'MIGRATION_CONFIG_INVALID',
|
|
21
|
+
// Open and lifecycle
|
|
22
|
+
OPEN_FAILED: 'OPEN_FAILED',
|
|
23
|
+
CLOSED_HANDLE: 'CLOSED_HANDLE',
|
|
24
|
+
SCOPE_DELETED: 'SCOPE_DELETED',
|
|
25
|
+
CORRUPTION: 'CORRUPTION',
|
|
26
|
+
STORAGE_ACCESS: 'STORAGE_ACCESS',
|
|
27
|
+
// Migration
|
|
28
|
+
MIGRATION_FAILED: 'MIGRATION_FAILED',
|
|
29
|
+
SCHEMA_DOWNGRADE: 'SCHEMA_DOWNGRADE',
|
|
30
|
+
// Records and writes
|
|
31
|
+
RECORD_NOT_FOUND: 'RECORD_NOT_FOUND',
|
|
32
|
+
RECORD_CONFLICT: 'RECORD_CONFLICT',
|
|
33
|
+
RECORD_TOO_LARGE: 'RECORD_TOO_LARGE',
|
|
34
|
+
BATCH_TOO_LARGE: 'BATCH_TOO_LARGE',
|
|
35
|
+
DISK_FULL: 'DISK_FULL',
|
|
36
|
+
WRITE_FAILED: 'WRITE_FAILED',
|
|
37
|
+
// Query
|
|
38
|
+
QUERY_INVALID: 'QUERY_INVALID',
|
|
39
|
+
PAGE_SIZE_INVALID: 'PAGE_SIZE_INVALID',
|
|
40
|
+
CURSOR_INVALID: 'CURSOR_INVALID',
|
|
41
|
+
// Transaction
|
|
42
|
+
TRANSACTION_FAILED: 'TRANSACTION_FAILED',
|
|
43
|
+
TRANSACTION_STATE: 'TRANSACTION_STATE',
|
|
44
|
+
// Attachments
|
|
45
|
+
ATTACHMENT_MISSING: 'ATTACHMENT_MISSING',
|
|
46
|
+
ATTACHMENT_OUT_OF_BOUNDS: 'ATTACHMENT_OUT_OF_BOUNDS',
|
|
47
|
+
ATTACHMENT_WRITE_FAILED: 'ATTACHMENT_WRITE_FAILED',
|
|
48
|
+
ATTACHMENT_UNDECRYPTABLE: 'ATTACHMENT_UNDECRYPTABLE',
|
|
49
|
+
// Encryption
|
|
50
|
+
KEY_INVALID: 'KEY_INVALID',
|
|
51
|
+
KEY_PROVIDER_FAILED: 'KEY_PROVIDER_FAILED',
|
|
52
|
+
ENCRYPTION_MISMATCH: 'ENCRYPTION_MISMATCH',
|
|
53
|
+
ENCRYPTION_UNAVAILABLE: 'ENCRYPTION_UNAVAILABLE'
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Codes worth retrying. `KEY_PROVIDER_FAILED` is here because a locked device
|
|
57
|
+
* is an expected condition, not a bug (FR-102).
|
|
58
|
+
*/
|
|
59
|
+
export const RETRYABLE_CODES = new Set([DiagnosticCodes.OPEN_FAILED, DiagnosticCodes.DISK_FULL, DiagnosticCodes.WRITE_FAILED, DiagnosticCodes.STORAGE_ACCESS, DiagnosticCodes.TRANSACTION_FAILED, DiagnosticCodes.MIGRATION_FAILED, DiagnosticCodes.ATTACHMENT_WRITE_FAILED, DiagnosticCodes.KEY_PROVIDER_FAILED]);
|
|
60
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DiagnosticCodes","CONFIG_INVALID","INVALID_SCOPE","MIGRATION_CONFIG_INVALID","OPEN_FAILED","CLOSED_HANDLE","SCOPE_DELETED","CORRUPTION","STORAGE_ACCESS","MIGRATION_FAILED","SCHEMA_DOWNGRADE","RECORD_NOT_FOUND","RECORD_CONFLICT","RECORD_TOO_LARGE","BATCH_TOO_LARGE","DISK_FULL","WRITE_FAILED","QUERY_INVALID","PAGE_SIZE_INVALID","CURSOR_INVALID","TRANSACTION_FAILED","TRANSACTION_STATE","ATTACHMENT_MISSING","ATTACHMENT_OUT_OF_BOUNDS","ATTACHMENT_WRITE_FAILED","ATTACHMENT_UNDECRYPTABLE","KEY_INVALID","KEY_PROVIDER_FAILED","ENCRYPTION_MISMATCH","ENCRYPTION_UNAVAILABLE","RETRYABLE_CODES","Set"],"sourceRoot":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S,gBAAgB,EAChCT,eAAe,CAACwB,uBAAuB,EACvCxB,eAAe,CAAC2B,mBAAmB,CACnC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/migration.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/query.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/record.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/schema.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/scope.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["contract/transaction.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The chunked AES-256-GCM artifact format.
|
|
5
|
+
*
|
|
6
|
+
* Whole-file encryption was rejected because a 100 MB artifact would have to
|
|
7
|
+
* be held in memory twice — plaintext and ciphertext — which breaks FR-107a's
|
|
8
|
+
* flat memory bound and every PERF-001 budget along with it (research.md R4).
|
|
9
|
+
* Chunking keeps exactly one 256 KB chunk in flight regardless of artifact
|
|
10
|
+
* size.
|
|
11
|
+
*
|
|
12
|
+
* ```text
|
|
13
|
+
* [ header 22 bytes ] magic | format version | chunk size | chunk count | plaintext size
|
|
14
|
+
* [ chunk 0 ] ciphertext(≤ chunkSize) | auth tag (16)
|
|
15
|
+
* [ chunk 1 ] …
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The auth tag follows each chunk rather than sitting in the header, which is
|
|
19
|
+
* a deliberate departure from the sketch in storage-layout.md. A tag is only
|
|
20
|
+
* known after its chunk has been encrypted, and the filesystem peer appends —
|
|
21
|
+
* it cannot seek back to patch a header. Collecting every tag before writing
|
|
22
|
+
* anything would mean buffering the whole ciphertext, which is the thing this
|
|
23
|
+
* format exists to avoid. Inline tags keep the write append-only and leave
|
|
24
|
+
* every chunk at a computable offset.
|
|
25
|
+
*
|
|
26
|
+
* A failing tag on read is `ATTACHMENT_UNDECRYPTABLE`, deliberately distinct
|
|
27
|
+
* from `ATTACHMENT_MISSING` (FR-107c): one is a wrong key or a tampered file
|
|
28
|
+
* and may be recoverable, the other is data that is simply gone.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { Budgets } from "../contract/config.js";
|
|
32
|
+
import { DiagnosticCodes } from "../contract/errors.js";
|
|
33
|
+
import { raise } from "../diagnostics/errors.js";
|
|
34
|
+
import { nonceForChunk } from "./derive.js";
|
|
35
|
+
import { cipherModule } from "./provider.js";
|
|
36
|
+
import { asciiAt, concatBytes } from "../platform/bytes.js";
|
|
37
|
+
export const MAGIC = 'LDB1';
|
|
38
|
+
export const FORMAT_VERSION = 1;
|
|
39
|
+
export const HEADER_BYTES = 22;
|
|
40
|
+
export const TAG_BYTES = 16;
|
|
41
|
+
export const ALGORITHM = 'aes-256-gcm';
|
|
42
|
+
export function chunkCountFor(plaintextSize, chunkSize) {
|
|
43
|
+
return plaintextSize === 0 ? 0 : Math.ceil(plaintextSize / chunkSize);
|
|
44
|
+
}
|
|
45
|
+
export function encodeHeader(header) {
|
|
46
|
+
const bytes = new Uint8Array(HEADER_BYTES);
|
|
47
|
+
for (let index = 0; index < 4; index += 1) {
|
|
48
|
+
bytes[index] = MAGIC.charCodeAt(index);
|
|
49
|
+
}
|
|
50
|
+
// Big-endian, as DataView writes by default; the on-disk format is unchanged.
|
|
51
|
+
const view = new DataView(bytes.buffer);
|
|
52
|
+
view.setUint16(4, header.formatVersion);
|
|
53
|
+
view.setUint32(6, header.chunkSize);
|
|
54
|
+
view.setUint32(10, header.chunkCount);
|
|
55
|
+
// Split across two 32-bit writes: artifact sizes stay well inside the safe
|
|
56
|
+
// integer range, and this avoids depending on BigInt in Hermes.
|
|
57
|
+
view.setUint32(14, Math.floor(header.plaintextSize / 0x100000000));
|
|
58
|
+
view.setUint32(18, header.plaintextSize % 0x100000000);
|
|
59
|
+
return bytes;
|
|
60
|
+
}
|
|
61
|
+
export function decodeHeader(bytes) {
|
|
62
|
+
if (bytes.length < HEADER_BYTES || asciiAt(bytes, 0, 4) !== MAGIC) {
|
|
63
|
+
raise(DiagnosticCodes.ATTACHMENT_UNDECRYPTABLE, {
|
|
64
|
+
message: 'artifact header is not a recognised encrypted artifact'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, HEADER_BYTES);
|
|
68
|
+
return {
|
|
69
|
+
formatVersion: view.getUint16(4),
|
|
70
|
+
chunkSize: view.getUint32(6),
|
|
71
|
+
chunkCount: view.getUint32(10),
|
|
72
|
+
plaintextSize: view.getUint32(14) * 0x100000000 + view.getUint32(18)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Plaintext length of chunk `index`; the last one is usually short. */
|
|
77
|
+
export function chunkPlaintextLength(header, index) {
|
|
78
|
+
const start = index * header.chunkSize;
|
|
79
|
+
return Math.max(0, Math.min(header.chunkSize, header.plaintextSize - start));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Byte offset of chunk `index` in the file.
|
|
84
|
+
*
|
|
85
|
+
* Every chunk but the last is full, so the offset is arithmetic rather than a
|
|
86
|
+
* table lookup — which is what lets a range read seek straight to the chunk
|
|
87
|
+
* it needs instead of walking the file.
|
|
88
|
+
*/
|
|
89
|
+
export function chunkOffset(header, index) {
|
|
90
|
+
return HEADER_BYTES + index * (header.chunkSize + TAG_BYTES);
|
|
91
|
+
}
|
|
92
|
+
export function encryptedLength(header) {
|
|
93
|
+
if (header.chunkCount === 0) {
|
|
94
|
+
return HEADER_BYTES;
|
|
95
|
+
}
|
|
96
|
+
const lastIndex = header.chunkCount - 1;
|
|
97
|
+
return chunkOffset(header, lastIndex) + chunkPlaintextLength(header, lastIndex) + TAG_BYTES;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** One chunk in, ciphertext with its tag appended out. */
|
|
101
|
+
export function encryptChunk(key, index, plaintext) {
|
|
102
|
+
const cipher = cipherModule().createCipheriv(ALGORITHM, key, nonceForChunk(index));
|
|
103
|
+
return concatBytes([new Uint8Array(cipher.update(plaintext)), new Uint8Array(cipher.final()), new Uint8Array(cipher.getAuthTag())]);
|
|
104
|
+
}
|
|
105
|
+
export function decryptChunk(key, index, stored) {
|
|
106
|
+
if (stored.length < TAG_BYTES) {
|
|
107
|
+
raise(DiagnosticCodes.ATTACHMENT_UNDECRYPTABLE, {
|
|
108
|
+
message: 'artifact chunk is truncated'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const body = stored.subarray(0, stored.length - TAG_BYTES);
|
|
112
|
+
const tag = stored.subarray(stored.length - TAG_BYTES);
|
|
113
|
+
const decipher = cipherModule().createDecipheriv(ALGORITHM, key, nonceForChunk(index));
|
|
114
|
+
decipher.setAuthTag(tag);
|
|
115
|
+
try {
|
|
116
|
+
return concatBytes([new Uint8Array(decipher.update(body)), new Uint8Array(decipher.final())]);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// A failing tag is the only signal that separates "exists but will not
|
|
119
|
+
// decrypt" from "missing", and an app responds to them differently.
|
|
120
|
+
raise(DiagnosticCodes.ATTACHMENT_UNDECRYPTABLE, {
|
|
121
|
+
message: 'artifact chunk failed authentication',
|
|
122
|
+
cause: error
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function headerFor(plaintextSize, chunkSize = Budgets.ARTIFACT_CHUNK_BYTES) {
|
|
127
|
+
return {
|
|
128
|
+
formatVersion: FORMAT_VERSION,
|
|
129
|
+
chunkSize,
|
|
130
|
+
chunkCount: chunkCountFor(plaintextSize, chunkSize),
|
|
131
|
+
plaintextSize
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=chunked-cipher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Budgets","DiagnosticCodes","raise","nonceForChunk","cipherModule","asciiAt","concatBytes","MAGIC","FORMAT_VERSION","HEADER_BYTES","TAG_BYTES","ALGORITHM","chunkCountFor","plaintextSize","chunkSize","Math","ceil","encodeHeader","header","bytes","Uint8Array","index","charCodeAt","view","DataView","buffer","setUint16","formatVersion","setUint32","chunkCount","floor","decodeHeader","length","ATTACHMENT_UNDECRYPTABLE","message","byteOffset","getUint16","getUint32","chunkPlaintextLength","start","max","min","chunkOffset","encryptedLength","lastIndex","encryptChunk","key","plaintext","cipher","createCipheriv","update","final","getAuthTag","decryptChunk","stored","body","subarray","tag","decipher","createDecipheriv","setAuthTag","error","cause","headerFor","ARTIFACT_CHUNK_BYTES"],"sourceRoot":"../../../src","sources":["crypto/chunked-cipher.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,uBAAoB;AAC5C,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASC,KAAK,QAAQ,0BAAuB;AAC7C,SAASC,aAAa,QAAQ,aAAU;AACxC,SAASC,YAAY,QAAQ,eAAY;AACzC,SAASC,OAAO,EAAEC,WAAW,QAAQ,sBAAmB;AAExD,OAAO,MAAMC,KAAK,GAAG,MAAM;AAC3B,OAAO,MAAMC,cAAc,GAAG,CAAC;AAC/B,OAAO,MAAMC,YAAY,GAAG,EAAE;AAC9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