Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Crypto API to v3 #1789

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MatrixSDK/MXEnumConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Matrix content respository path
*/
NSString *const kMXContentUriScheme = @"mxc://";
NSString *const kMXContentPrefixPath = @"_matrix/media/r0";
NSString *const kMXContentPrefixPath = @"_matrix/media/v3";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related to crypto?


/**
Prefix used in path of antivirus server API requests.
Expand Down
38 changes: 19 additions & 19 deletions MatrixSDK/MXRestClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ -(id)initWithCredentials:(MXCredentials*)inCredentials
self = [super init];
if (self)
{
apiPathPrefix = kMXAPIPrefixPathR0;
apiPathPrefix = kMXAPIPrefixPathV3;
antivirusServerPathPrefix = kMXAntivirusAPIPrefixPathUnstable;
contentPathPrefix = kMXContentPrefixPath;

Expand Down Expand Up @@ -4817,7 +4817,7 @@ - (MXHTTPOperation*)uploadKeys:(NSDictionary*)deviceKeys
success:(void (^)(MXKeysUploadResponse *keysUploadResponse))success
failure:(void (^)(NSError *error))failure
{
NSString *path = deviceId ? [NSString stringWithFormat:@"%@/keys/upload/%@", kMXAPIPrefixPathR0, [deviceId stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]] : [NSString stringWithFormat:@"%@/keys/upload", kMXAPIPrefixPathR0];
NSString *path = deviceId ? [NSString stringWithFormat:@"%@/keys/upload/%@", kMXAPIPrefixPathV3, [deviceId stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]] : [NSString stringWithFormat:@"%@/keys/upload", kMXAPIPrefixPathV3];

NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
if (deviceKeys)
Expand Down Expand Up @@ -4862,7 +4862,7 @@ - (MXHTTPOperation*)uploadKeySignatures:(NSDictionary*)signatures
{
MXWeakify(self);
return [httpClient requestWithMethod:@"POST"
path:[NSString stringWithFormat:@"%@/keys/signatures/upload", kMXAPIPrefixPathR0]
path:[NSString stringWithFormat:@"%@/keys/signatures/upload", kMXAPIPrefixPathV3]
parameters:signatures
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
Expand All @@ -4885,7 +4885,7 @@ - (MXHTTPOperation*)downloadKeysForUsers:(NSArray<NSString*>*)userIds
success:(void (^)(MXKeysQueryResponse *keysQueryResponse))success
failure:(void (^)(NSError *error))failure
{
NSString *path = [NSString stringWithFormat:@"%@/keys/query", kMXAPIPrefixPathR0];
NSString *path = [NSString stringWithFormat:@"%@/keys/query", kMXAPIPrefixPathV3];

NSMutableDictionary *downloadQuery = [NSMutableDictionary dictionary];
for (NSString *userID in userIds)
Expand Down Expand Up @@ -4927,7 +4927,7 @@ - (MXHTTPOperation*)downloadKeysForUsers:(NSArray<NSString*>*)userIds

- (MXHTTPOperation *)claimOneTimeKeysForUsersDevices:(MXUsersDevicesMap<NSString *> *)usersDevicesKeyTypesMap success:(void (^)(MXKeysClaimResponse *))success failure:(void (^)(NSError *))failure
{
NSString *path = [NSString stringWithFormat:@"%@/keys/claim", kMXAPIPrefixPathR0];
NSString *path = [NSString stringWithFormat:@"%@/keys/claim", kMXAPIPrefixPathV3];

NSDictionary *parameters = @{
@"one_time_keys": usersDevicesKeyTypesMap.map
Expand Down Expand Up @@ -4963,7 +4963,7 @@ - (MXHTTPOperation *)keyChangesFrom:(NSString *)fromToken to:(NSString *)toToken
{
MXWeakify(self);
return [httpClient requestWithMethod:@"GET"
path:[NSString stringWithFormat:@"%@/keys/changes", kMXAPIPrefixPathR0]
path:[NSString stringWithFormat:@"%@/keys/changes", kMXAPIPrefixPathV3]
parameters:@{
@"from": fromToken,
@"to": toToken
Expand Down Expand Up @@ -5065,7 +5065,7 @@ - (MXHTTPOperation*)createKeyBackupVersion:(MXKeyBackupVersion*)keyBackupVersion
{
MXWeakify(self);
return [httpClient requestWithMethod:@"POST"
path:[NSString stringWithFormat:@"%@/room_keys/version", kMXAPIPrefixPathR0]
path:[NSString stringWithFormat:@"%@/room_keys/version", kMXAPIPrefixPathV3]
parameters:keyBackupVersion.JSONDictionary
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
Expand All @@ -5089,7 +5089,7 @@ - (MXHTTPOperation*)updateKeyBackupVersion:(MXKeyBackupVersion*)keyBackupVersion
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure
{
return [self updateKeyBackupVersion:keyBackupVersion withPath:kMXAPIPrefixPathR0 success:success failure:failure];
return [self updateKeyBackupVersion:keyBackupVersion withPath:kMXAPIPrefixPathV3 success:success failure:failure];
}

- (MXHTTPOperation*)updateKeyBackupVersion:(MXKeyBackupVersion*)keyBackupVersion
Expand Down Expand Up @@ -5121,7 +5121,7 @@ - (MXHTTPOperation*)deleteKeyBackupVersion:(NSString*)version
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure
{
NSMutableString *path = [NSMutableString stringWithFormat:@"%@/room_keys/version", kMXAPIPrefixPathR0];
NSMutableString *path = [NSMutableString stringWithFormat:@"%@/room_keys/version", kMXAPIPrefixPathV3];
if (version)
{
[path appendFormat:@"/%@", version];
Expand Down Expand Up @@ -5151,7 +5151,7 @@ - (MXHTTPOperation*)keyBackupVersion:(NSString*)version
success:(void (^)(MXKeyBackupVersion *keyBackupVersion))success
failure:(void (^)(NSError *error))failure;
{
NSMutableString *path = [NSMutableString stringWithFormat:@"%@/room_keys/version", kMXAPIPrefixPathR0];
NSMutableString *path = [NSMutableString stringWithFormat:@"%@/room_keys/version", kMXAPIPrefixPathV3];
if (version)
{
[path appendFormat:@"/%@", version];
Expand Down Expand Up @@ -5470,7 +5470,7 @@ - (NSString*)keyBackupPath:(NSString*)roomId session:(NSString*)sessionId versio
return nil;
}

NSMutableString *path = [NSMutableString stringWithFormat:@"%@/room_keys/keys", kMXAPIPrefixPathR0];
NSMutableString *path = [NSMutableString stringWithFormat:@"%@/room_keys/keys", kMXAPIPrefixPathV3];

if (sessionId)
{
Expand Down Expand Up @@ -5504,7 +5504,7 @@ - (MXHTTPOperation*)sendToDevice:(MXToDevicePayload *)payload
{

// Prepare the path by adding a random transaction id (This id is used to prevent duplicated event).
NSString *path = [NSString stringWithFormat:@"%@/sendToDevice/%@/%@", kMXAPIPrefixPathR0, payload.eventType, payload.transactionId];
NSString *path = [NSString stringWithFormat:@"%@/sendToDevice/%@/%@", kMXAPIPrefixPathV3, payload.eventType, payload.transactionId];

NSDictionary *content = @{
@"messages": payload.messages
Expand All @@ -5530,7 +5530,7 @@ - (MXHTTPOperation*)devices:(void (^)(NSArray<MXDevice *> *))success
{
MXWeakify(self);
return [httpClient requestWithMethod:@"GET"
path:[NSString stringWithFormat:@"%@/devices", kMXAPIPrefixPathR0]
path:[NSString stringWithFormat:@"%@/devices", kMXAPIPrefixPathV3]
parameters:nil
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
Expand All @@ -5556,7 +5556,7 @@ - (MXHTTPOperation*)deviceByDeviceId:(NSString *)deviceId
{
MXWeakify(self);
return [httpClient requestWithMethod:@"GET"
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathR0, deviceId]
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathV3, deviceId]
parameters:nil
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
Expand Down Expand Up @@ -5589,7 +5589,7 @@ - (MXHTTPOperation*)setDeviceName:(NSString *)deviceName

MXWeakify(self);
return [httpClient requestWithMethod:@"PUT"
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathR0, deviceId]
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathV3, deviceId]
parameters:parameters
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
Expand All @@ -5608,7 +5608,7 @@ - (MXHTTPOperation*)getSessionToDeleteDeviceByDeviceId:(NSString *)deviceId
// The request will fail with Unauthorized status code, but the auth session will be available in response data.
MXWeakify(self);
return [httpClient requestWithMethod:@"DELETE"
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathR0, [MXTools encodeURIComponent:deviceId]]
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathV3, [MXTools encodeURIComponent:deviceId]]
parameters:nil
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
Expand Down Expand Up @@ -5665,7 +5665,7 @@ - (MXHTTPOperation*)deleteDeviceByDeviceId:(NSString *)deviceId

MXWeakify(self);
return [httpClient requestWithMethod:@"DELETE"
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathR0, [MXTools encodeURIComponent:deviceId]]
path:[NSString stringWithFormat:@"%@/devices/%@", kMXAPIPrefixPathV3, [MXTools encodeURIComponent:deviceId]]
parameters:nil
data:payloadData
headers:@{@"Content-Type": @"application/json"}
Expand Down Expand Up @@ -5693,7 +5693,7 @@ - (MXHTTPOperation*)deleteDevicesByDeviceIds:(NSArray<NSString*>*)deviceIds

MXWeakify(self);
return [httpClient requestWithMethod:@"POST"
path:[NSString stringWithFormat:@"%@/delete_devices", kMXAPIPrefixPathR0]
path:[NSString stringWithFormat:@"%@/delete_devices", kMXAPIPrefixPathV3]
parameters:nil
data:payloadData
headers:@{@"Content-Type": @"application/json"}
Expand Down Expand Up @@ -6266,7 +6266,7 @@ - (MXHTTPOperation*)getSpaceChildrenForSpaceWithId:(NSString*)spaceId
- (MXHTTPOperation*)homeServerCapabilitiesWithSuccess:(void (^)(MXHomeserverCapabilities *capabilities))success
failure:(void (^)(NSError *error))failure
{
NSString *path = [NSString stringWithFormat:@"%@/capabilities", kMXAPIPrefixPathR0];
NSString *path = [NSString stringWithFormat:@"%@/capabilities", kMXAPIPrefixPathV3];

MXWeakify(self);
return [httpClient requestWithMethod:@"GET"
Expand Down
1 change: 1 addition & 0 deletions changelog.d/7557.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updating crypto API endpoint to v3.