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