-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1319 from matrix-org/langleyd/5292_refresh_tokens
SDK: Refresh Token implementation
- Loading branch information
Showing
34 changed files
with
807 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Copyright 2021 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
/** | ||
`MXRefreshTokenData` used to update `MXCredentials` that it's token data has updated. see `MXCredentialsUpdateTokensNotification`. | ||
*/ | ||
@interface MXRefreshTokenData : NSObject | ||
|
||
/** | ||
The user id. | ||
*/ | ||
@property (nonatomic, readonly, nonnull) NSString *userId; | ||
|
||
/** | ||
The homeserver URL. | ||
*/ | ||
@property (nonatomic, readonly, nonnull) NSString *homeserver; | ||
|
||
|
||
/** | ||
The access token to create a MXRestClient | ||
*/ | ||
@property (nonatomic, readonly, nonnull) NSString *accessToken; | ||
|
||
/** | ||
The timestamp in milliseconds for when the access token will expire | ||
*/ | ||
@property (nonatomic, readonly) uint64_t accessTokenExpiresAt; | ||
|
||
/** | ||
The refresh token, which can be used to obtain new access tokens. (optional) | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSString *refreshToken; | ||
|
||
- (instancetype _Nonnull)initWithUserId:(NSString*_Nonnull)userId | ||
homeserver:(NSString*_Nonnull)homeserver | ||
accessToken:(NSString*_Nonnull)accessToken | ||
refreshToken:(NSString*_Nonnull)refreshToken | ||
accessTokenExpiresAt:(uint64_t)accessTokenExpiresAt; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// MXRefreshTokenData.m | ||
// MatrixSDK | ||
// | ||
// Created by David Langley on 17/12/2021. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "MXRefreshTokenData.h" | ||
|
||
@implementation MXRefreshTokenData | ||
- (instancetype)initWithUserId:(NSString*)userId | ||
homeserver:(NSString*)homeserver | ||
accessToken:(NSString*)accessToken | ||
refreshToken:(NSString*)refreshToken | ||
accessTokenExpiresAt:(uint64_t)accessTokenExpiresAt | ||
{ | ||
self = [super init]; | ||
if (self) | ||
{ | ||
_userId = userId; | ||
_homeserver = homeserver; | ||
_accessToken = accessToken; | ||
_refreshToken = refreshToken; | ||
_accessTokenExpiresAt = accessTokenExpiresAt; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
Oops, something went wrong.