{"id":19233679,"url":"https://github.com/brightdigit/stealthystash","last_synced_at":"2025-04-21T04:33:22.088Z","repository":{"id":158536286,"uuid":"618187362","full_name":"brightdigit/StealthyStash","owner":"brightdigit","description":"A Swifty database interface into the Keychain Services.","archived":false,"fork":false,"pushed_at":"2024-03-27T01:07:28.000Z","size":2850,"stargazers_count":11,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T15:43:57.574Z","etag":null,"topics":["keychain","keychain-wrapper","password","security","swift"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/brightdigit/StealthyStash","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/brightdigit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-23T23:46:17.000Z","updated_at":"2025-02-10T01:26:19.000Z","dependencies_parsed_at":"2023-06-28T20:00:52.893Z","dependency_job_id":null,"html_url":"https://github.com/brightdigit/StealthyStash","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FStealthyStash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FStealthyStash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FStealthyStash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FStealthyStash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brightdigit","download_url":"https://codeload.github.com/brightdigit/StealthyStash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249996238,"owners_count":21358094,"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":["keychain","keychain-wrapper","password","security","swift"],"created_at":"2024-11-09T16:11:29.993Z","updated_at":"2025-04-21T04:33:21.514Z","avatar_url":"https://github.com/brightdigit.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"StealthyStash\" title=\"StealthyStash\" src=\"Sources/StealthyStash/Documentation.docc/Resources/SleathlyStash-Icon.png\" height=\"125\"\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eStealthyStash\u003c/h1\u003e\n\nA Swifty database interface into the Keychain Services.\n\n[![SwiftPM](https://img.shields.io/badge/SPM-Linux%20%7C%20iOS%20%7C%20macOS%20%7C%20watchOS%20%7C%20tvOS-success?logo=swift)](https://swift.org)\n[![Twitter](https://img.shields.io/badge/twitter-@brightdigit-blue.svg?style=flat)](http://twitter.com/brightdigit)\n![GitHub](https://img.shields.io/github/license/brightdigit/StealthyStash)\n![GitHub issues](https://img.shields.io/github/issues/brightdigit/StealthyStash)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/brightdigit/StealthyStash/StealthyStash.yml?label=actions\u0026logo=github\u0026?branch=main)\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fbrightdigit%2FStealthyStash%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/brightdigit/StealthyStash)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fbrightdigit%2FStealthyStash%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/brightdigit/StealthyStash)\n\n\n[![Codecov](https://img.shields.io/codecov/c/github/brightdigit/StealthyStash)](https://codecov.io/gh/brightdigit/StealthyStash)\n[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/brightdigit/StealthyStash)](https://www.codefactor.io/repository/github/brightdigit/StealthyStash)\n[![codebeat badge](https://codebeat.co/badges/54695d4b-98c8-4f0f-855e-215500163094)](https://codebeat.co/projects/github-com-brightdigit-StealthyStash-main)\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/brightdigit/StealthyStash)](https://codeclimate.com/github/brightdigit/StealthyStash)\n[![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/brightdigit/StealthyStash?label=debt)](https://codeclimate.com/github/brightdigit/StealthyStash)\n[![Code Climate issues](https://img.shields.io/codeclimate/issues/brightdigit/StealthyStash)](https://codeclimate.com/github/brightdigit/StealthyStash)\n[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)\n\n# Table of Contents\n\n* [Introduction](#introduction)\n   * [Requirements](#requirements)\n   * [Installation](#installation)\n* [Usage](#usage)\n   * [Further Documentation](#further-documentation)     \n* [References](#references)\n* [License](#license)\n\n# Introduction\n\n**StealthyStash** provides an pluggable easy abstract layer for accessing Keychain data as well as an API for encoding and decoding complex data in the Keychain. \n\n## Requirements \n\n**Apple Platforms**\n\n- Xcode 14.3.1 or later\n- Swift 5.8 or later\n- iOS 14 / watchOS 7 / tvOS 14 / macOS 12 or later deployment targets\n\n**Linux**\n\n- Ubuntu 18.04 or later\n- Swift 5.8 or later\n\n## Installation\n\nUse the Swift Package Manager to install this library via the repository url:\n\n```\nhttps://github.com/brightdigit/StealthyStash.git\n```\n\nUse version up to `1.0`.\n\n# Usage\n\n## Accessing the Keychain like a Database\n\n**StealthyStash** supports the adding, updating, and querying for both generic and internet passwords. To do this you need to create a ``KeychainRepository`` to access the database to.\n\n```\nlet repository = KeychainRepository(\n  defaultServiceName: \"com.brightdigit.KeychainSyncDemo\",\n  defaultServerName: \"com.brightdigit.KeychainSyncDemo\",\n  defaultAccessGroup: \"MLT7M394S7.com.brightdigit.KeychainSyncDemo\"\n)\n```\n\nTo call ``KeychainRepository.init(defaultServiceName:defaultServerName:defaultAccessGroup:defaultSynchronizable:logger:)`` you need to supply a the default ``InternetPasswordItem/server`` and ``GenericPasswordItem/service`` which is required by both types to query and create.\n\n\u003e You can also supply a `logger` to use for logging as well as an ``InternetPasswordItem.accessGroup`` for your ``InternetPasswordItem`` and ``GenericPasswordItem.accessGroup`` for your ``GenericPasswordItem``\n\nTo query, update, or add a new password, check out the documentation under ``StealthyRepository``.\n\n## Using `StealthyModel` for Composite Objects\n\nIn many cases, you may want to use multiple items to store a single object such as the user's password with ``InternetPasswordItem`` as well as their token via ``GenericPasswordItem``. In this case, you'll want to use a ``StealthyModel``:\n\n```swift\nstruct CompositeCredentials: StealthyModel {\n  typealias QueryBuilder = CompositeCredentialsQueryBuilder\n\n  internal init(userName: String, password: String?, token: String?) {\n    self.userName = userName\n    self.password = password\n    self.token = token\n  }\n\n  let userName: String\n\n  let password: String?\n\n  let token: String?\n}\n```\n\nThis is the perfect use case for ``StealthyModel`` and it only requires the implementation of a ``ModelQueryBuilder`` which defines how to build the queries for creating, updating, and deleting ``StealthyModel`` objects from the keychain:\n\n* ``ModelQueryBuilder.updates(from:to:)`` require you to build an array of ``StealthyPropertyUpdate`` object which define the previous and new properties for the Keychain. Both the previous and new are optional in case you are only adding a new item as part of the update or only removing an old item.\n\n* ``ModelQueryBuilder.properties(from:for:)`` is for creating a new model and requires the individual ``AnyStealthyProperty`` for each item to add to the keychain.\n\n* ``ModelQueryBuilder.model(from:)`` builds the ``StealthyModel`` based on the ``AnyStealthyProperty`` items\n\n* ``ModelQueryBuilder.queries(from:)`` builds a query dictionary depending the ``ModelQueryBuilder.QueryType`` passed. The keys to the query dictionary will be used by ``ModelQueryBuilder.model(from:)`` to define the keys of their resulting ``AnyStealthyProperty``. If there's only one object in your app, you can define ``ModelQueryBuilder.QueryType`` as `Void`:\n\n```\nstatic func queries(from _: Void) -\u003e [String: Query] {\n  [\n    \"password\": TypeQuery(type: .internet),\n    \"token\": TypeQuery(type: .generic)\n  ]\n}\n```\n\nFor more help, take a look at the [`Sample` projects located in the Swift Package.](https://github.com/brightdigit/StealthyStash/tree/main/Samples)\n\n## Further Documentation\n\nFurther documentation is available at [the Swift Package Index.](https://swiftpackageindex.com/brightdigit/StealthyStash/1.0.0/documentation/stealthystash)\n\n# References\n\n* [Using the Keychain to Manage User Secret](https://developer.apple.com/documentation/security/keychain_services/keychain_items/using_the_keychain_to_manage_user_secrets)\n\n# License \n\nThis code is distributed under the MIT license. See the [LICENSE](https://github.com/brightdigit/StealthyStash/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightdigit%2Fstealthystash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightdigit%2Fstealthystash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightdigit%2Fstealthystash/lists"}