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