commit | author | age
|
a6c014
|
1 |
/* |
L |
2 |
* Copyright 2019 Google |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
|
|
17 |
#import <Foundation/Foundation.h> |
|
18 |
|
|
19 |
NS_ASSUME_NONNULL_BEGIN |
|
20 |
|
|
21 |
FOUNDATION_EXPORT NSString *const kGULKeychainUtilsErrorDomain; |
|
22 |
|
aca600
|
23 |
/// A collection of helper functions that abstract away common Keychain operations. |
L |
24 |
/// |
|
25 |
/// When using this API on macOS, the corresponding target must be signed with a provisioning |
|
26 |
/// profile that has the Keychain Sharing capability enabled. |
a6c014
|
27 |
@interface GULKeychainUtils : NSObject |
L |
28 |
|
|
29 |
/** Fetches a keychain item data matching to the provided query. |
|
30 |
* @param query A dictionary with Keychain query parameters. See docs for `SecItemCopyMatching` for |
|
31 |
* details. |
|
32 |
* @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be |
|
33 |
* assigned with an error if there is. |
|
34 |
* @returns Data for the first Keychain Item matching the provided query or `nil` if there is not |
|
35 |
* such an item (`outError` will be `nil` in this case) or an error occurred. |
|
36 |
*/ |
|
37 |
+ (nullable NSData *)getItemWithQuery:(NSDictionary *)query |
|
38 |
error:(NSError *_Nullable *_Nullable)outError; |
|
39 |
|
|
40 |
/** Stores data to a Keychain Item matching to the provided query. An existing Keychain Item |
|
41 |
* matching the query parameters will be updated or a new will be created. |
|
42 |
* @param item A Keychain Item data to store. |
|
43 |
* @param query A dictionary with Keychain query parameters. See docs for `SecItemAdd` and |
|
44 |
* `SecItemUpdate` for details. |
|
45 |
* @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be |
|
46 |
* assigned with an error if there is. |
|
47 |
* @returns `YES` when data was successfully stored, `NO` otherwise. |
|
48 |
*/ |
|
49 |
+ (BOOL)setItem:(NSData *)item |
|
50 |
withQuery:(NSDictionary *)query |
|
51 |
error:(NSError *_Nullable *_Nullable)outError; |
|
52 |
|
|
53 |
/** Removes a Keychain Item matching to the provided query. |
|
54 |
* @param query A dictionary with Keychain query parameters. See docs for `SecItemDelete` for |
|
55 |
* details. |
|
56 |
* @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be |
|
57 |
* assigned with an error if there is. |
|
58 |
* @returns `YES` if the item was removed successfully or doesn't exist, `NO` otherwise. |
|
59 |
*/ |
|
60 |
+ (BOOL)removeItemWithQuery:(NSDictionary *)query error:(NSError *_Nullable *_Nullable)outError; |
|
61 |
|
|
62 |
@end |
|
63 |
|
|
64 |
NS_ASSUME_NONNULL_END |