{"id":19998032,"url":"https://github.com/stanfordspezi/spezistorage","last_synced_at":"2026-03-08T22:32:23.997Z","repository":{"id":151694509,"uuid":"624084354","full_name":"StanfordSpezi/SpeziStorage","owner":"StanfordSpezi","description":"Spezi module to store information and credentials encrypted at rest","archived":false,"fork":false,"pushed_at":"2024-10-30T17:12:54.000Z","size":130,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-12T12:54:17.554Z","etag":null,"topics":["encryption","spezi","stanford","storage","swift","xcode"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/StanfordSpezi/SpeziStorage/documentation/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StanfordSpezi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"custom":["spezi.sites.stanford.edu"]}},"created_at":"2023-04-05T17:58:18.000Z","updated_at":"2024-11-03T01:00:33.000Z","dependencies_parsed_at":"2023-12-20T22:24:24.620Z","dependency_job_id":null,"html_url":"https://github.com/StanfordSpezi/SpeziStorage","commit_stats":{"total_commits":15,"total_committers":3,"mean_commits":5.0,"dds":0.2666666666666667,"last_synced_commit":"e9be3c2743e462894bf56d41339b040f4060b567"},"previous_names":["StanfordBDHG/CardinalKitStorage","stanfordbdhg/cardinalkitstorage"],"tags_count":12,"template":false,"template_full_name":"StanfordBDHG/SwiftPackageTemplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordSpezi%2FSpeziStorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordSpezi%2FSpeziStorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordSpezi%2FSpeziStorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordSpezi%2FSpeziStorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StanfordSpezi","download_url":"https://codeload.github.com/StanfordSpezi/SpeziStorage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224393941,"owners_count":17303725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encryption","spezi","stanford","storage","swift","xcode"],"created_at":"2024-11-13T05:07:06.575Z","updated_at":"2025-12-11T22:53:10.494Z","avatar_url":"https://github.com/StanfordSpezi.png","language":"Swift","funding_links":["spezi.sites.stanford.edu"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n\nThis source file is part of the Stanford Spezi open-source project.\n\nSPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)\n\nSPDX-License-Identifier: MIT\n  \n--\u003e\n\n# Spezi Storage\n\n[![Build and Test](https://github.com/StanfordSpezi/SpeziStorage/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/StanfordSpezi/SpeziStorage/actions/workflows/build-and-test.yml)\n[![codecov](https://codecov.io/gh/StanfordSpezi/SpeziStorage/branch/main/graph/badge.svg?token=XJ8IJuc0hj)](https://codecov.io/gh/StanfordSpezi/SpeziStorage)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7804028.svg)](https://doi.org/10.5281/zenodo.7804028)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordSpezi%2FSpeziStorage%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/StanfordSpezi/SpeziStorage)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordSpezi%2FSpeziStorage%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/StanfordSpezi/SpeziStorage)\n\nThe Spezi Storage framework provides two Modules that enable on-disk storage of information.\nThe  [`LocalStorage`](https://swiftpackageindex.com/stanfordspezi/spezistorage/documentation/spezilocalstorage/localstorage) module can be used to store information that does not need to be encrypted.\nCredentials, keys, and other sensitive information that needs to be encrypted may be stored by using the [`KeychainStorage`](https://swiftpackageindex.com/StanfordSpezi/SpeziStorage/documentation/spezikeychainstorage) module.\n\n\n## Setup\n\nYou need to add the Spezi Storage Swift package to\n[your app in Xcode](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app#) or\n[Swift package](https://developer.apple.com/documentation/xcode/creating-a-standalone-swift-package-with-xcode#Add-a-dependency-on-another-Swift-package).\n\n\u003e [!IMPORTANT]\n\u003e If your application is not yet configured to use Spezi, follow the [Spezi setup article](https://swiftpackageindex.com/stanfordspezi/spezi/documentation/spezi/initial-setup) to set up the core Spezi infrastructure.\n\nYou can configure the [`LocalStorage`](https://swiftpackageindex.com/stanfordspezi/spezistorage/documentation/spezilocalstorage/localstorage) or [`KeychainStorage`](https://swiftpackageindex.com/StanfordSpezi/SpeziStorage/documentation/spezikeychainstorage) module in the [`SpeziAppDelegate`](https://swiftpackageindex.com/stanfordspezi/spezi/documentation/spezi/speziappdelegate).\n\n\u003e [!IMPORTANT]\n\u003e If you use SpeziStorage on the macOS platform, ensure to add the [`Keychain Access Groups` entitlement](https://developer.apple.com/documentation/bundleresources/entitlements/keychain-access-groups) to the enclosing Xcode project via *PROJECT_NAME \u003e Signing\u0026Capabilities \u003e + Capability*. The array of keychain groups can be left empty, only the base entitlement is required.\n\n```swift\nimport Spezi\nimport SpeziLocalStorage\nimport SpeziKeychainStorage\n\nclass ExampleDelegate: SpeziAppDelegate {\n    override var configuration: Configuration {\n        Configuration {\n            LocalStorage()\n            KeychainStorage()\n            // ...\n        }\n    }\n}\n```\n\nYou can then use the `LocalStorage` or `KeychainStorage` class in any SwiftUI view.\n\n```swift\nstruct ExampleStorageView: View {\n    @Environment(LocalStorage.self) var localStorage\n    @Environment(KeychainStorage.self) var keychainStorage\n    \n    var body: some View {\n        // ...\n    }\n}\n```\n\nAlternatively, it is common to use the `LocalStorage` or `KeychainStorage` module in other modules as a dependency: [Spezi Module dependencies](https://swiftpackageindex.com/stanfordspezi/spezi/documentation/spezi/module-dependency).\n\n\n## Local Storage\n\nThe `LocalStorage` module enables the on-disk storage of data in mobile applications.\n\nThe `LocalStorage` module defaults to storing data encrypted supported by the `KeychainStorage` module.\nThe [`LocalStorageKey`](https://swiftpackageindex.com/stanfordspezi/spezistorage/documentation/spezilocalstorage/localstoragekey) type is used to define storage entries, and specify how data should be persisted.\n\n\n## Keychain Storage\n\nThe `KeychainStorage` module allows for the encrypted storage of small chunks of sensitive user data, such as usernames and passwords for internet services, or cryptographic keys, using Apple's [Keychain documentation](https://developer.apple.com/documentation/security/keychain_services/keychain_items/using_the_keychain_to_manage_user_secrets). \n\nCredentials can be stored in the Secure Enclave (if available) or the Keychain. Credentials stored in the Keychain can be made synchronizable between different instances of user devices.\n\n### Handling Credentials\n\nUse the `KeychainStorage` module to store a set of [`Credentials`](https://swiftpackageindex.com/stanfordspezi/spezistorage/documentation/spezikeychainstorage/credentials) instances in the Keychain associated with a server that is synchronizable between different devices.\n\n\n\n### Handling Keys\n\nSimilar to `Credentials` instances, you can also use the `KeychainStorage` module to interact with cryptographic keys.\n\n\n\nFor more information, please refer to the [API documentation](https://swiftpackageindex.com/StanfordSpezi/SpeziStorage/documentation).\n\n\n## The Spezi Template Application\n\nThe [Spezi Template Application](https://github.com/StanfordSpezi/SpeziTemplateApplication) provides a great starting point and example using the Spezi Storage module.\n\n\n## Contributing\n\nContributions to this project are welcome. Please make sure to read the [contribution guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md) and the [contributor covenant code of conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) first.\n\n\n## License\n\nThis project is licensed under the MIT License. See [Licenses](https://github.com/StanfordSpezi/SpeziStorage/tree/main/LICENSES) for more information.\n\n![Spezi Footer](https://raw.githubusercontent.com/StanfordSpezi/.github/main/assets/FooterLight.png#gh-light-mode-only)\n![Spezi Footer](https://raw.githubusercontent.com/StanfordSpezi/.github/main/assets/FooterDark.png#gh-dark-mode-only)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanfordspezi%2Fspezistorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanfordspezi%2Fspezistorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanfordspezi%2Fspezistorage/lists"}