Private
Public Access
1
0

4 Commits

Author SHA1 Message Date
ebad248c1c Adds conversation delete option 2022-05-25 22:34:19 -07:00
e161eedef3 CORS 2022-05-25 21:27:13 -07:00
7a3303da06 Auth: Use Set-Cookie for auth token 2021-07-06 23:41:51 -07:00
641e4c53fa Add Makefile for ez installing 2021-07-06 23:41:39 -07:00
7 changed files with 99 additions and 4 deletions

13
Makefile Normal file
View File

@@ -0,0 +1,13 @@
INSTALL_PATH := /usr/share/kordophone
build/Release/kordophoned:
xcodebuild
.PHONY: install
install: build/Release/kordophoned
install -d $(INSTALL_PATH)
install build/Release/kordophoned $(INSTALL_PATH)
cp -rf build/Release/CocoaHTTPServer.framework $(INSTALL_PATH)
clean:
rm -Rf build

View File

@@ -81,6 +81,7 @@
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD602061219B68950024D9C5 /* MBIMSendMessageOperation.m */; };
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E155219BE10A00F4CCEA /* hooking.m */; };
CD83E166219BE91600F4CCEA /* agentHook.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E165219BE91600F4CCEA /* agentHook.m */; };
CDDCF78D283F398C0087ABDF /* MBIMDeleteConversationOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */; };
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */; };
CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */; };
CDE455A421A5308D0041F5DD /* MBIMFetchAttachmentOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */; };
@@ -236,6 +237,8 @@
CD83E161219BE91500F4CCEA /* libagentHook.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libagentHook.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
CD83E165219BE91600F4CCEA /* agentHook.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = agentHook.m; sourceTree = "<group>"; };
CD83E1B5219BF78E00F4CCEA /* hookAgent.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = hookAgent.sh; sourceTree = "<group>"; };
CDDCF78B283F398C0087ABDF /* MBIMDeleteConversationOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMDeleteConversationOperation.h; sourceTree = "<group>"; };
CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMDeleteConversationOperation.m; sourceTree = "<group>"; };
CDE4556221A3578A0041F5DD /* IMChat+Encoded.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IMChat+Encoded.h"; sourceTree = "<group>"; };
CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "IMChat+Encoded.m"; sourceTree = "<group>"; };
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMarkOperation.h; sourceTree = "<group>"; };
@@ -526,6 +529,8 @@
CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */,
CD60205D219B674B0024D9C5 /* MBIMConversationListOperation.h */,
CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */,
CDDCF78B283F398C0087ABDF /* MBIMDeleteConversationOperation.h */,
CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */,
CDE455A221A5308D0041F5DD /* MBIMFetchAttachmentOperation.h */,
CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */,
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */,
@@ -836,6 +841,7 @@
CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */,
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */,
1AAB32B121F82EB7004A2A72 /* MBIMLogging.m in Sources */,
CDDCF78D283F398C0087ABDF /* MBIMDeleteConversationOperation.m in Sources */,
1AD8936E21EFD986009B599A /* MBIMUploadAttachmentOperation.m in Sources */,
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */,
CDF62335219A895D00690038 /* main.m in Sources */,

View File

@@ -60,9 +60,14 @@
MBIMAuthToken *token = [[MBIMAuthToken alloc] initWithUsername:username];
// All systems go
response = [MBIMJSONDataResponse responseWithJSONObject:@{
MBIMJSONDataResponse *dataResponse = [MBIMJSONDataResponse responseWithJSONObject:@{
@"jwt" : token.jwtToken
}];
// Send a cookie down so we can use httpOnly cookies
dataResponse.httpHeaders[@"Set-Cookie"] = [NSString stringWithFormat:@"auth_token=%@", token.jwtToken];
response = dataResponse;
} while (NO);
}

View File

@@ -0,0 +1,17 @@
//
// MBIMDeleteConversationOperation.h
// kordophoned
//
// Created by James Magahern on 5/25/22.
// Copyright © 2022 James Magahern. All rights reserved.
//
#import "MBIMBridgeOperation.h"
NS_ASSUME_NONNULL_BEGIN
@interface MBIMDeleteConversationOperation : MBIMBridgeOperation
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,49 @@
//
// MBIMDeleteConversationOperation.m
// kordophoned
//
// Created by James Magahern on 5/25/22.
// Copyright © 2022 James Magahern. All rights reserved.
//
#import "MBIMDeleteConversationOperation.h"
#import "IMChat+Encoded.h"
#import "IMCore_ClassDump.h"
@implementation MBIMDeleteConversationOperation
+ (void)load { [super load]; }
+ (NSString *)endpointName
{
return @"delete";
}
- (void)main
{
__block NSObject<HTTPResponse> *response = nil;
do {
NSString *guid = [self valueForQueryItemWithName:@"guid"];
if (!guid) {
MBIMLogInfo(@"No conversation GUID provided.");
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
break;
}
dispatch_sync([[self class] sharedIMAccessQueue], ^{
IMChat *chat = [[IMChatRegistry sharedInstance] existingChatWithGUID:guid];
if (!chat) {
MBIMLogInfo(@"Chat with guid: %@ not found", guid);
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
} else {
[chat remove];
}
});
response = [[HTTPErrorResponse alloc] initWithErrorCode:200];
} while (0);
self.serverCompletionBlock(response);
}
@end

View File

@@ -12,6 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface MBIMDataResponse : HTTPDataResponse
@property (nonatomic, readonly) NSMutableDictionary *httpHeaders;
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
@end

View File

@@ -10,6 +10,7 @@
@implementation MBIMDataResponse {
NSString *_contentType;
NSMutableDictionary *_httpHeaders;
}
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
@@ -17,6 +18,11 @@
self = [super initWithData:data];
if (self) {
_contentType = contentType;
_httpHeaders = [@{
@"Content-Type" : _contentType ?: @"application/octet-stream",
@"Access-Control-Allow-Origin" : @"*", // CORS
@"Access-Control-Allow-Credentials" : @"true"
} mutableCopy];
}
return self;
@@ -24,9 +30,7 @@
- (NSDictionary *)httpHeaders
{
return @{
@"Content-Type" : _contentType ?: @"application/octet-stream"
};
return _httpHeaders;
}
@end