@tokamakdev/plugin-secure-storage 0.1.0-beta.55 → 0.1.0-beta.57

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.
@@ -121,12 +121,9 @@ final class TokamakSecureStoragePlugin: TokamakPlugin {
121
121
  return String(decoding: data, as: UTF8.self)
122
122
  }
123
123
 
124
- /// Reads attributes only, which needs no authentication.
125
124
  private func keys() throws(TokamakPluginError) -> [String] {
126
- var items = serviceQuery()
125
+ var items = attributesQuery(serviceQuery())
127
126
  items[kSecMatchLimit] = kSecMatchLimitAll
128
- items[kSecReturnAttributes] = true
129
- items[kSecUseAuthenticationContext] = nonInteractiveContext()
130
127
  var attributes: CFTypeRef?
131
128
  let status = SecItemCopyMatching(items as CFDictionary, &attributes)
132
129
  if status == errSecItemNotFound {
@@ -146,12 +143,8 @@ final class TokamakSecureStoragePlugin: TokamakPlugin {
146
143
  }
147
144
  }
148
145
 
149
- /// Reads attributes only, which needs no authentication.
150
146
  private func exists(_ name: String) throws(TokamakPluginError) -> Bool {
151
- var item = query(name)
152
- item[kSecReturnAttributes] = true
153
- item[kSecUseAuthenticationContext] = nonInteractiveContext()
154
- let status = SecItemCopyMatching(item as CFDictionary, nil)
147
+ let status = SecItemCopyMatching(attributesQuery(query(name)) as CFDictionary, nil)
155
148
  if status == errSecItemNotFound {
156
149
  return false
157
150
  }
@@ -159,10 +152,13 @@ final class TokamakSecureStoragePlugin: TokamakPlugin {
159
152
  return true
160
153
  }
161
154
 
162
- private func nonInteractiveContext() -> LAContext {
155
+ /// `query` reading attributes only, which needs no authentication.
156
+ private func attributesQuery(_ query: [CFString: Any]) -> [CFString: Any] {
163
157
  let context = LAContext()
164
158
  context.interactionNotAllowed = true
165
- return context
159
+ return query.merging([kSecReturnAttributes: true, kSecUseAuthenticationContext: context]) {
160
+ _, attribute in attribute
161
+ }
166
162
  }
167
163
 
168
164
  /// All of the plugin's items. The data protection keychain is the only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokamakdev/plugin-secure-storage",
3
- "version": "0.1.0-beta.55",
3
+ "version": "0.1.0-beta.57",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/mantty/tokamak.git",
@@ -11,7 +11,7 @@
11
11
  ".": "./src/index.ts"
12
12
  },
13
13
  "dependencies": {
14
- "@tokamakdev/plugin": "0.1.0-beta.55"
14
+ "@tokamakdev/plugin": "0.1.0-beta.57"
15
15
  },
16
16
  "files": [
17
17
  "android",