commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
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 |
|
a0a843
|
18 |
// TODO: this is temporary. clean up after refactoring scribe layer |
H |
19 |
#import <TwitterCore/TWTRSessionStore.h> |
|
20 |
#import "TWTRScribeService.h" |
|
21 |
|
|
22 |
@class TWTRAuthConfig; |
|
23 |
@protocol TWTRAPIServiceConfig; |
|
24 |
@protocol TWTRRefreshStrategies; |
|
25 |
|
|
26 |
NS_ASSUME_NONNULL_BEGIN |
|
27 |
|
|
28 |
typedef void (^TWTRSessionStoreLogoutHook)(NSString *userID); |
|
29 |
|
|
30 |
/** |
|
31 |
* Completion block called when login succeeds or fails. |
|
32 |
* |
|
33 |
* @param session Contains the OAuth tokens and minimal information associated with the logged in user or nil. |
|
34 |
* @param error Error that will be non nil if the authentication request fails. |
|
35 |
*/ |
|
36 |
typedef void (^TWTRSessionLogInCompletion)(id<TWTRAuthSession> _Nullable session, NSError *_Nullable error); |
|
37 |
|
|
38 |
typedef void (^TWTRSessionStoreUserSessionSavedCompletion)(id<TWTRAuthSession> session); |
|
39 |
|
|
40 |
@protocol TWTRUserSessionStore_Private <TWTRSessionStore> |
|
41 |
|
|
42 |
/** |
|
43 |
* Saves the existing session to the store after validations. |
|
44 |
* |
|
45 |
* @param session The user session to save |
|
46 |
* @param withVerification Whether to verify against the backend before saving this session |
|
47 |
* @param completion Completion block to call when the save request succeeds or fails |
|
48 |
*/ |
|
49 |
- (void)saveSession:(id<TWTRAuthSession>)session withVerification:(BOOL)withVerification completion:(TWTRSessionStoreSaveCompletion)completion; |
|
50 |
|
|
51 |
/** |
|
52 |
* Triggers user authentication with Twitter. |
|
53 |
* |
|
54 |
* @param completion Completion block to call when authentication succeeds or fails. |
|
55 |
*/ |
|
56 |
- (void)logInWithSystemAccountsCompletion:(TWTRSessionLogInCompletion)completion __TVOS_UNAVAILABLE; |
|
57 |
|
|
58 |
@end |
|
59 |
|
|
60 |
@protocol TWTRSessionStore_Private <TWTRUserSessionStore_Private> |
|
61 |
|
|
62 |
/** |
|
63 |
* The current guest session. |
|
64 |
* |
|
65 |
* @note This might not always reflect the latest state of the guest session. Use `fetchGuestSessionWithCompletion:` to get the latest guest session. |
|
66 |
*/ |
|
67 |
@property (nonatomic, readwrite, nullable) TWTRGuestSession *guestSession; |
|
68 |
|
|
69 |
@end |
|
70 |
|
|
71 |
@interface TWTRSessionStore () <TWTRSessionStore_Private> |
|
72 |
|
|
73 |
/** |
|
74 |
* Logger for logging important session lifecycle events. |
|
75 |
* Scribe service used to log events. |
|
76 |
*/ |
|
77 |
@property (nonatomic, readonly) id<TWTRErrorLogger> errorLogger; |
|
78 |
|
|
79 |
/** |
|
80 |
* Service config for configuring endpoints to make auth requests against. |
|
81 |
*/ |
|
82 |
@property (nonatomic, readonly) id<TWTRAPIServiceConfig> APIServiceConfig; |
|
83 |
|
|
84 |
/* |
|
85 |
* Called when the logoutUserID: method is called. |
|
86 |
*/ |
|
87 |
@property (nonatomic, copy, nullable) TWTRSessionStoreLogoutHook userLogoutHook; |
|
88 |
|
|
89 |
/** |
|
90 |
* Completion block invoked whenever a user session is saved to the store. |
|
91 |
*/ |
|
92 |
@property (nonatomic, copy, nullable) TWTRSessionStoreUserSessionSavedCompletion userSessionSavedCompletion; |
|
93 |
|
|
94 |
/** |
|
95 |
* Designated initializer for creating a new session store. |
|
96 |
* |
|
97 |
* @param authConfig (required) Auth config containing the app `consumerKey` and `consumerSecret` |
|
98 |
* @param APIServiceConfig (required) API service config for specifying server endpoints |
|
99 |
* @param refreshStrategies (required) Strategies to use to refresh sessions |
|
100 |
* @param URLSession (required) URL session used to make authentication requests |
|
101 |
* @param eventLogger (required) Logger for logging important session lifecycle events. **This should be removed before we hit production** |
|
102 |
* @param accessGroup (optional) An optional access group to use for persistence to the store. |
|
103 |
* |
|
104 |
* @return A fully initialized session store. |
|
105 |
*/ |
|
106 |
- (instancetype)initWithAuthConfig:(TWTRAuthConfig *)authConfig APIServiceConfig:(id<TWTRAPIServiceConfig>)APIServiceConfig refreshStrategies:(NSArray *)refreshStrategies URLSession:(NSURLSession *)URLSession errorLogger:(id<TWTRErrorLogger>)errorLogger; |
|
107 |
- (instancetype)initWithAuthConfig:(TWTRAuthConfig *)authConfig APIServiceConfig:(id<TWTRAPIServiceConfig>)APIServiceConfig refreshStrategies:(NSArray *)refreshStrategies URLSession:(NSURLSession *)URLSession errorLogger:(id<TWTRErrorLogger>)errorLogger accessGroup:(nullable NSString *)accessGroup NS_DESIGNATED_INITIALIZER; |
|
108 |
|
655e66
|
109 |
- (NSString *)userSessionServiceName; |
H |
110 |
- (NSString *)guestSessionServiceName; |
|
111 |
|
a0a843
|
112 |
@end |
H |
113 |
|
|
114 |
NS_ASSUME_NONNULL_END |