Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
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
extern NSString *__nonnull const kFIRMessagingKeychainWildcardIdentifier;
20
 
21
NS_ASSUME_NONNULL_BEGIN
22
 
23
/**
24
 *  Wrapper around storing FCM auth data in iOS keychain.
25
 */
26
@interface FIRMessagingAuthKeychain : NSObject
27
 
28
/**
29
 *  Designated Initializer. Init a generic `SecClassGenericPassword` keychain with `identifier`
30
 *  as the `kSecAttrGeneric`.
31
 *
32
 *  @param identifier The generic attribute to be used by the keychain.
33
 *
34
 *  @return A Keychain object with `kSecAttrGeneric` attribute set to identifier.
35
 */
36
- (instancetype)initWithIdentifier:(NSString *)identifier;
37
 
38
/**
39
 *  Get keychain items matching the given service and account. The service and/or account
40
 *  can be a wildcard (`kFIRMessagingKeychainWildcardIdentifier`), which case the query
41
 *  will include all items matching any services and/or accounts.
42
 *
43
 *  @param service The kSecAttrService used to save the password. Can be wildcard.
44
 *  @param account The kSecAttrAccount used to save the password. Can be wildcard.
45
 *
46
 *  @return An array of |NSData|s matching the provided inputs.
47
 */
48
- (NSArray<NSData *> *)itemsMatchingService:(NSString *)service account:(NSString *)account;
49
 
50
/**
51
 *  Get keychain item for a given service and account.
52
 *
53
 *  @param service The kSecAttrService used to save the password.
54
 *  @param account The kSecAttrAccount used to save the password.
55
 *
56
 *  @return A cached keychain item for a given account and service, or nil if it was not
57
 *          found or could not be retrieved.
58
 */
59
- (NSData *)dataForService:(NSString *)service account:(NSString *)account;
60
 
61
/**
62
 *  Remove the cached items from the keychain matching the service, account and access group.
63
 *  In case the items do not exist, YES is returned but with a valid error object with code
64
 *  `errSecItemNotFound`.
65
 *
66
 *  @param service The kSecAttrService used to save the password.
67
 *  @param account The kSecAttrAccount used to save the password.
68
 *  @param handler The callback handler which is invoked when the remove operation is complete, with
69
 *                 an error if there is any.
70
 */
71
- (void)removeItemsMatchingService:(NSString *)service
72
                           account:(NSString *)account
73
                           handler:(nullable void (^)(NSError *error))handler;
74
 
75
/**
76
 *  Set the data for a given service and account.
77
 *  We use `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly` which
78
 *  prevents backup and restore to iCloud, and works for app extension that can
79
 *  execute right after a device is restarted (and not unlocked).
80
 *
81
 *  @param data          The data to save.
82
 *  @param service       The `kSecAttrService` used to save the password.
83
 *  @param account       The `kSecAttrAccount` used to save the password.
84
 *  @param handler       The callback handler which is invoked when the add operation is complete,
85
 *                       with an error if there is any.
86
 *
87
 */
88
- (void)setData:(NSData *)data
89
     forService:(NSString *)service
90
        account:(NSString *)account
91
        handler:(nullable void (^)(NSError *))handler;
92
 
93
/*
94
 * This method only sets the cache data of token.
95
 * It is only used when users still use InstanceID to update token info
96
 * After token refreshed by InstanceID, the storage is already updated but not the cache.
97
 * use this method to update the cache.
98
 */
99
- (void)setCacheData:(NSData *)data forService:(NSString *)service account:(NSString *)account;
100
 
101
@end
102
 
103
NS_ASSUME_NONNULL_END