Compare commits
5 Commits
Kordophone
...
Kordophone
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40fb964cb3 | ||
|
|
d814c2e4f6 | ||
| 7a3303da06 | |||
| 641e4c53fa | |||
|
|
4d51ba7dd2 |
@@ -4081,6 +4081,38 @@ __attribute__((visibility("default"))) @interface IMService : NSObject { }
|
||||
|
||||
@end
|
||||
|
||||
// Monterey
|
||||
#if 0
|
||||
@interface IMChatRegistry ()
|
||||
- (IMChat *)chatWithHandle:(IMHandle *)handle;
|
||||
- (IMChat *)chatWithHandle:(IMHandle *)handle lastAddressedHandle:(NSString *)lastAddressedHandle lastAddressedSIMID:(NSString *)lastAddressedSIMID;
|
||||
- (IMChat *)chatWithHandles:(NSArray<IMHandle *> *)handles;
|
||||
- (IMChat *)chatWithHandles:(NSArray<IMHandle *> *)handles lastAddressedHandle:(NSString *)lastAddressedHandle lastAddressedSIMID:(NSString *)lastAddressedSIMID;
|
||||
- (IMChat *)chatWithHandles:(NSArray<IMHandle *> *)handles displayName:(NSString *)displayName joinedChatsOnly:(BOOL)joinedChatsOnly;
|
||||
- (IMChat *)chatWithHandles:(NSArray<IMHandle *> *)handles displayName:(NSString *)displayName joinedChatsOnly:(BOOL)joinedChatsOnly lastAddressedHandle:(NSString *)lastAddressedHandle lastAddressedSIMID:(NSString *)lastAddressedSIMID;
|
||||
- (NSArray<NSString *> *)allGUIDsForChat:(IMChat *)chat;
|
||||
|
||||
- (IMChat *)existingChatWithHandle:(IMHandle *)handle;
|
||||
- (IMChat *)existingChatWithHandle:(IMHandle *)handle allowAlternativeService:(BOOL)allowAlternativeService;
|
||||
- (IMChat *)existingChatWithHandles:(NSArray<IMHandle *> *)handles;
|
||||
- (IMChat *)existingChatWithHandles:(NSArray<IMHandle *> *)handles allowAlternativeService:(BOOL)allowAlternativeService;
|
||||
|
||||
- (IMChat *)existingChatWithHandles:(NSArray<IMHandle *> *)handles allowAlternativeService:(BOOL)allowAlternativeService groupID:(NSString *)groupID;
|
||||
|
||||
- (IMChat *)existingChatWithHandles:(NSArray *)handles allowAlternativeService:(BOOL)allowAlternativeService groupID:(NSString *)groupID displayName:(NSString *)displayName joinedChatsOnly:(BOOL)joinedChatsOnly;
|
||||
|
||||
- (IMChat *)existingChatWithPinningIdentifier:(NSString *)pinningIdentifier;
|
||||
- (IMChat *)existingChatWithDeviceIndependentID:(NSString *)deviceIndependentID;
|
||||
|
||||
- (IMChat *)existingChatWithPersonID:(NSString *)personID;
|
||||
- (IMChat *)existingChatWithDisplayName:(NSString *)displayName;
|
||||
- (IMChat *)existingChatWithAddresses:(NSArray<NSString *> *)addresses allowAlternativeService:(BOOL)allowAlternativeService bestHandles:(NSArray<IMHandle *> **)outBestHandles;
|
||||
- (IMChat *)existingChatWithContacts:(NSSet *)contacts bestHandles:(NSArray<IMHandle *> **)outBestHandles;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
||||
@interface IMSimulatedChat : IMChat // <IMSimulatedChatDelegate, IMSimulatedDaemonListener>
|
||||
{
|
||||
// id <IMSimulatedChatDelegate> _delegate;
|
||||
|
||||
@@ -1898,3 +1898,29 @@ typedef void (^CDUnknownBlockType)(void); // return type and parameters are unkn
|
||||
- (void)differencesFromArray:(id)arg1 removedIndexes:(id *)arg2 insertedIndexes:(id *)arg3;
|
||||
@end
|
||||
|
||||
extern BOOL IMStringIsEmail (NSString *string);
|
||||
|
||||
extern NSString* IMStripFormattingFromAddress (NSString *address);
|
||||
|
||||
typedef void(^IMChatCalculateServiceForSendingCompletionBlock) (BOOL allAddressesiMessageCapable,
|
||||
NSDictionary *availabilityPerRecipient,
|
||||
BOOL checkedServer,
|
||||
NSError *error);
|
||||
|
||||
extern void IMChatCalculateServiceForSendingNewComposeMaybeForce (NSArray *addresses,
|
||||
NSString *senderLastAddressedHandle,
|
||||
NSString *senderLastAddressedSIMID,
|
||||
BOOL forceMMS,
|
||||
BOOL hasEmailRecipients,
|
||||
BOOL lastSentMessageWasNotDelivered,
|
||||
BOOL conversationWasDowngraded,
|
||||
BOOL hasConversationHistory,
|
||||
IMService *previousService,
|
||||
IMChatCalculateServiceForSendingCompletionBlock completion);
|
||||
|
||||
|
||||
// IDS
|
||||
|
||||
extern NSString *IDSCopyIDForPhoneNumber(NSString *phoneNumber);
|
||||
extern NSString *IDSCopyIDForEmailAddress(NSString *emailAddress);
|
||||
|
||||
|
||||
@@ -745,19 +745,6 @@ struct __va_list_tag {
|
||||
|
||||
@end
|
||||
|
||||
@interface IMImageUtilities : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
+ (struct CGImage *)newThumbnailForTargetSize:(struct CGSize)arg1 imageSize:(struct CGSize)arg2 imageSource:(struct CGImageSource *)arg3 atIndex:(unsigned long long)arg4 mode:(long long)arg5 scale:(double)arg6;
|
||||
+ (struct CGImage *)newThumbnailForTargetSize:(struct CGSize)arg1 imageSize:(struct CGSize)arg2 imageSource:(struct CGImageSource *)arg3 mode:(long long)arg4 scale:(double)arg5;
|
||||
+ (BOOL)persistCPBitmapWithImage:(struct CGImage *)arg1 url:(id)arg2;
|
||||
+ (void)sampleImageEdges:(char *)arg1 usingRect:(struct CGRect)arg2 forMostlyWhitePixels:(unsigned long long *)arg3 otherPixels:(unsigned long long *)arg4 bytesPerRow:(long long)arg5;
|
||||
+ (struct CGSize)imageRefPxSize:(struct CGImage *)arg1;
|
||||
+ (struct CGSize)imageSourcePxSize:(struct CGImageSource *)arg1;
|
||||
|
||||
@end
|
||||
|
||||
@interface IMOneTimeCodeUtilities : NSObject
|
||||
{
|
||||
}
|
||||
@@ -1426,17 +1413,6 @@ struct __va_list_tag {
|
||||
|
||||
@end
|
||||
|
||||
@interface IMImagePreviewGenerator : IMPreviewGenerator <IMPreviewGeneratorProtocol, IMUTITypeInformation>
|
||||
{
|
||||
}
|
||||
|
||||
+ (struct CGImage *)newThumbnailFillToSize:(struct CGSize)arg1 imagePxSize:(struct CGSize)arg2 imageSource:(struct CGImageSource *)arg3 scale:(double)arg4;
|
||||
+ (struct CGImage *)newPreviewFromSourceURL:(id)arg1 withPreviewConstraints:(struct IMPreviewConstraints)arg2 error:(id *)arg3;
|
||||
+ (id)UTITypes;
|
||||
+ (id)fetchUTITypes;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface IMAKAppleIDAuthenticationController : NSObject
|
||||
{
|
||||
|
||||
13
Makefile
Normal file
13
Makefile
Normal 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
|
||||
@@ -73,12 +73,16 @@
|
||||
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A3219FF22700E7DD22 /* IMMessageItem+Encoded.m */; };
|
||||
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */; };
|
||||
CD14F1AD219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */; };
|
||||
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */; };
|
||||
CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */; };
|
||||
CD602056219B5DFD0024D9C5 /* MBIMBridgeOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */; };
|
||||
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */; };
|
||||
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */; };
|
||||
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 */; };
|
||||
CDD8C98426977D2A00551AE5 /* MBIMAliasValidationOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDD8C98326977D2A00551AE5 /* MBIMAliasValidationOperation.m */; };
|
||||
CDD8C9862697996800551AE5 /* IDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDD8C9852697996700551AE5 /* IDS.framework */; };
|
||||
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 */; };
|
||||
@@ -217,6 +221,10 @@
|
||||
CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMUpdateQueue.m; sourceTree = "<group>"; };
|
||||
CD14F1AB219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMConcurrentHTTPServer.h; sourceTree = "<group>"; };
|
||||
CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMConcurrentHTTPServer.m; sourceTree = "<group>"; };
|
||||
CD2ECEC0269539100055E302 /* MBIMAuthenticateOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAuthenticateOperation.h; sourceTree = "<group>"; };
|
||||
CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAuthenticateOperation.m; sourceTree = "<group>"; };
|
||||
CD2ECEC326953F2A0055E302 /* MBIMAuthToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAuthToken.h; sourceTree = "<group>"; };
|
||||
CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAuthToken.m; sourceTree = "<group>"; };
|
||||
CD602054219B5DFD0024D9C5 /* MBIMBridgeOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMBridgeOperation.h; sourceTree = "<group>"; };
|
||||
CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMBridgeOperation.m; sourceTree = "<group>"; };
|
||||
CD60205A219B623F0024D9C5 /* MBIMMessagesListOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMessagesListOperation.h; sourceTree = "<group>"; };
|
||||
@@ -230,6 +238,9 @@
|
||||
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>"; };
|
||||
CDD8C98226977D2A00551AE5 /* MBIMAliasValidationOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAliasValidationOperation.h; sourceTree = "<group>"; };
|
||||
CDD8C98326977D2A00551AE5 /* MBIMAliasValidationOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAliasValidationOperation.m; sourceTree = "<group>"; };
|
||||
CDD8C9852697996700551AE5 /* IDS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IDS.framework; path = System/Library/PrivateFrameworks/IDS.framework; sourceTree = SDKROOT; };
|
||||
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>"; };
|
||||
@@ -268,6 +279,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CDD8C9862697996800551AE5 /* IDS.framework in Frameworks */,
|
||||
1A257CCB23A8681200A4A2C8 /* Security.framework in Frameworks */,
|
||||
1ACFCFDF219EB31400E2C237 /* CocoaHTTPServer.framework in Frameworks */,
|
||||
1A257CC923A867EF00A4A2C8 /* IMCore.framework in Frameworks */,
|
||||
@@ -315,6 +327,7 @@
|
||||
1A0C445E219A45B400F2AC00 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CDD8C9852697996700551AE5 /* IDS.framework */,
|
||||
1A257CCA23A8681200A4A2C8 /* Security.framework */,
|
||||
1A257CC823A867EF00A4A2C8 /* IMCore.framework */,
|
||||
);
|
||||
@@ -328,13 +341,14 @@
|
||||
1A0C4469219A4BC300F2AC00 /* MBIMBridge.h */,
|
||||
1AAB32AC21F8212E004A2A72 /* MBIMBridge_Private.h */,
|
||||
1A0C446A219A4BC300F2AC00 /* MBIMBridge.m */,
|
||||
CD2ECEC326953F2A0055E302 /* MBIMAuthToken.h */,
|
||||
CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */,
|
||||
CD14F1A8219FF3B800E7DD22 /* MBIMUpdateQueue.h */,
|
||||
CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */,
|
||||
CD14F1AB219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.h */,
|
||||
CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */,
|
||||
1ACFCFE2219EB45300E2C237 /* MBIMHTTPConnection.h */,
|
||||
1ACFCFE3219EB45300E2C237 /* MBIMHTTPConnection.m */,
|
||||
1AAB32A921F81AD0004A2A72 /* Security */,
|
||||
);
|
||||
path = Bridge;
|
||||
sourceTree = "<group>";
|
||||
@@ -352,13 +366,6 @@
|
||||
path = Utilities;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AAB32A921F81AD0004A2A72 /* Security */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Security;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AAB32AE21F82E73004A2A72 /* Utilities */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -522,6 +529,10 @@
|
||||
1AA43E90219EBB3400EDF1A7 /* Utilities */,
|
||||
CD602054219B5DFD0024D9C5 /* MBIMBridgeOperation.h */,
|
||||
CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */,
|
||||
CDD8C98226977D2A00551AE5 /* MBIMAliasValidationOperation.h */,
|
||||
CDD8C98326977D2A00551AE5 /* MBIMAliasValidationOperation.m */,
|
||||
CD2ECEC0269539100055E302 /* MBIMAuthenticateOperation.h */,
|
||||
CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */,
|
||||
CD60205A219B623F0024D9C5 /* MBIMMessagesListOperation.h */,
|
||||
CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */,
|
||||
CD60205D219B674B0024D9C5 /* MBIMConversationListOperation.h */,
|
||||
@@ -831,12 +842,14 @@
|
||||
CDF62339219A8A5600690038 /* MBIMBridge.h in Sources */,
|
||||
1AA43E95219EC38E00EDF1A7 /* MBIMHTTPUtilities.m in Sources */,
|
||||
CDE455A421A5308D0041F5DD /* MBIMFetchAttachmentOperation.m in Sources */,
|
||||
CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */,
|
||||
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */,
|
||||
1AAB32B121F82EB7004A2A72 /* MBIMLogging.m in Sources */,
|
||||
1AD8936E21EFD986009B599A /* MBIMUploadAttachmentOperation.m in Sources */,
|
||||
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */,
|
||||
CDF62335219A895D00690038 /* main.m in Sources */,
|
||||
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */,
|
||||
CDD8C98426977D2A00551AE5 /* MBIMAliasValidationOperation.m in Sources */,
|
||||
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */,
|
||||
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */,
|
||||
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */,
|
||||
@@ -847,6 +860,7 @@
|
||||
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */,
|
||||
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */,
|
||||
1AA43E8F219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m in Sources */,
|
||||
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
26
kordophone/Bridge/MBIMAuthToken.h
Normal file
26
kordophone/Bridge/MBIMAuthToken.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// MBIMAuthToken.h
|
||||
// MBIMAuthToken
|
||||
//
|
||||
// Created by James Magahern on 7/6/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMAuthToken : NSObject
|
||||
@property (nonatomic, readonly) NSString *username;
|
||||
@property (nonatomic, readonly) NSString *jwtToken;
|
||||
@property (nonatomic, readonly) NSDate *expirationDate;
|
||||
|
||||
- (instancetype)initWithUsername:(NSString *)username NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithTokenString:(NSString *)tokenString NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (BOOL)isValid;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
149
kordophone/Bridge/MBIMAuthToken.m
Normal file
149
kordophone/Bridge/MBIMAuthToken.m
Normal file
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// MBIMAuthToken.m
|
||||
// MBIMAuthToken
|
||||
//
|
||||
// Created by James Magahern on 7/6/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMAuthToken.h"
|
||||
#import <CommonCrypto/CommonHMAC.h>
|
||||
|
||||
#define HOUR 3600
|
||||
#define DAY (24*HOUR)
|
||||
|
||||
static const NSTimeInterval ExpirationTime = 15 * DAY;
|
||||
static const char *SecretKey = "709E7CD8-4983-4D5F-B7BF-8B1C6341D2DB";
|
||||
|
||||
static NSString *const kUsernamePayloadKey = @"user";
|
||||
static NSString *const kIssuerPayloadKey = @"iss";
|
||||
static NSString *const kExpirationDatePayloadKey = @"exp";
|
||||
|
||||
static NSString *const kIssuerPayloadValue = @"kordophone";
|
||||
|
||||
@interface MBIMAuthToken ()
|
||||
@property (nonatomic, copy) NSString *username;
|
||||
@property (nonatomic, copy) NSString *jwtToken;
|
||||
@property (nonatomic, copy) NSDate *expirationDate;
|
||||
|
||||
// JWT Payload data
|
||||
@property (nonatomic, copy) NSString *headerString;
|
||||
@property (nonatomic, copy) NSString *payloadString;
|
||||
@property (nonatomic, copy) NSData *signatureData;
|
||||
@end
|
||||
|
||||
@implementation MBIMAuthToken
|
||||
|
||||
- (instancetype)initWithUsername:(NSString *)username
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.username = username;
|
||||
self.expirationDate = [NSDate dateWithTimeIntervalSinceNow:ExpirationTime];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTokenString:(NSString *)tokenString
|
||||
{
|
||||
NSArray<NSString *> *components = [tokenString componentsSeparatedByString:@"."];
|
||||
if (components.count != 3) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *header = components[0];
|
||||
NSString *payload = components[1];
|
||||
NSString *signature = components[2];
|
||||
|
||||
NSData *payloadData = [[NSData alloc] initWithBase64EncodedString:payload options:0];
|
||||
NSDictionary *decodedPayload = [NSJSONSerialization JSONObjectWithData:payloadData options:0 error:nil];
|
||||
if (!decodedPayload) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![decodedPayload[kIssuerPayloadKey] isEqualToString:@"kordophone"]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_headerString = header;
|
||||
_payloadString = payload;
|
||||
_signatureData = [[NSData alloc] initWithBase64EncodedString:signature options:0];
|
||||
|
||||
_username = decodedPayload[kUsernamePayloadKey];
|
||||
|
||||
NSTimeInterval expirationDate = [decodedPayload[kExpirationDatePayloadKey] floatValue];
|
||||
_expirationDate = [NSDate dateWithTimeIntervalSince1970:expirationDate];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
return (_username.hash ^ _expirationDate.hash);
|
||||
}
|
||||
|
||||
- (NSString *)jwtToken
|
||||
{
|
||||
if (!_jwtToken) {
|
||||
NSDictionary *header = @{
|
||||
@"alg" : @"HS256",
|
||||
@"typ" : @"jwt"
|
||||
};
|
||||
|
||||
NSData *headerData = [NSJSONSerialization dataWithJSONObject:header options:0 error:nil];
|
||||
NSString *headerStr = [headerData base64EncodedStringWithOptions:0];
|
||||
|
||||
NSInteger expirationDate = [_expirationDate timeIntervalSince1970];
|
||||
NSDictionary *payload = @{
|
||||
kUsernamePayloadKey : _username,
|
||||
kIssuerPayloadKey : kIssuerPayloadValue,
|
||||
kExpirationDatePayloadKey : [NSString stringWithFormat:@"%ld", expirationDate]
|
||||
};
|
||||
NSData *payloadData = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil];
|
||||
NSString *payloadStr = [payloadData base64EncodedStringWithOptions:0];
|
||||
|
||||
NSString *jwtDataStr = [NSString stringWithFormat:@"%@.%@", headerStr, payloadStr];
|
||||
NSData *jwtData = [jwtDataStr dataUsingEncoding:NSASCIIStringEncoding];
|
||||
|
||||
unsigned char signature[CC_SHA256_DIGEST_LENGTH];
|
||||
CCHmac(kCCHmacAlgSHA256, SecretKey, sizeof(SecretKey), jwtData.bytes, jwtData.length, signature);
|
||||
|
||||
NSData *signatureData = [NSData dataWithBytes:signature length:CC_SHA256_DIGEST_LENGTH];
|
||||
NSString *signatureStr = [signatureData base64EncodedStringWithOptions:0];
|
||||
|
||||
_jwtToken = [NSString stringWithFormat:@"%@.%@", jwtDataStr, signatureStr];
|
||||
}
|
||||
|
||||
return _jwtToken;
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
// Verify expiration date
|
||||
BOOL expirationDateValid = [_expirationDate timeIntervalSinceNow] > 0;
|
||||
if (!expirationDateValid) {
|
||||
MBIMLogInfo(@"Auth token expired.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Verify signature
|
||||
NSString *verificationDataStr = [NSString stringWithFormat:@"%@.%@", _headerString, _payloadString];
|
||||
NSData *verificationData = [verificationDataStr dataUsingEncoding:NSASCIIStringEncoding];
|
||||
|
||||
unsigned char computedSignature[CC_SHA256_DIGEST_LENGTH];
|
||||
CCHmac(kCCHmacAlgSHA256, SecretKey, sizeof(SecretKey), verificationData.bytes, verificationData.length, computedSignature);
|
||||
|
||||
NSData *computedSignatureData = [NSData dataWithBytes:computedSignature length:CC_SHA256_DIGEST_LENGTH];
|
||||
if (![computedSignatureData isEqualToData:_signatureData]) {
|
||||
MBIMLogInfo(@"Auth token signature verification failed.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -11,8 +11,14 @@
|
||||
#import "MBIMBridge.h"
|
||||
#import "MBIMBridge_Private.h"
|
||||
#import "MBIMBridgeOperation.h"
|
||||
#import "MBIMAuthToken.h"
|
||||
|
||||
#import <Security/Security.h>
|
||||
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||
|
||||
@interface HTTPConnection (/* INTERNAL */)
|
||||
- (BOOL)isAuthenticated;
|
||||
@end
|
||||
|
||||
@implementation MBIMHTTPConnection {
|
||||
NSMutableData *_bodyData;
|
||||
@@ -31,7 +37,15 @@
|
||||
|
||||
- (BOOL)isPasswordProtected:(NSString *)path
|
||||
{
|
||||
return [[MBIMBridge sharedInstance] usesAccessControl];
|
||||
if ([[MBIMBridge sharedInstance] usesAccessControl]) {
|
||||
NSURL *url = [NSURL URLWithString:path];
|
||||
NSString *endpointName = [url lastPathComponent];
|
||||
|
||||
Class operationClass = [MBIMBridgeOperation operationClassForEndpointName:endpointName];
|
||||
return [operationClass requiresAuthentication];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)passwordForUser:(NSString *)username
|
||||
@@ -41,7 +55,23 @@
|
||||
return bridge.authPassword;
|
||||
}
|
||||
|
||||
return @"";
|
||||
// nil means "user not in system"
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)isAuthenticated
|
||||
{
|
||||
NSString *authInfo = [request headerField:@"Authorization"];
|
||||
if ([authInfo hasPrefix:@"Bearer"]) {
|
||||
NSArray *bearerAuthTuple = [authInfo componentsSeparatedByString:@" "];
|
||||
if ([bearerAuthTuple count] == 2) {
|
||||
NSString *jwtToken = [bearerAuthTuple objectAtIndex:1];
|
||||
MBIMAuthToken *authToken = [[MBIMAuthToken alloc] initWithTokenString:jwtToken];
|
||||
return [authToken isValid];
|
||||
}
|
||||
}
|
||||
|
||||
return [super isAuthenticated];
|
||||
}
|
||||
|
||||
- (BOOL)useDigestAccessAuthentication
|
||||
|
||||
17
kordophone/Bridge/Operations/MBIMAliasValidationOperation.h
Normal file
17
kordophone/Bridge/Operations/MBIMAliasValidationOperation.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMAliasValidationOperation.h
|
||||
// MBIMAliasValidationOperation
|
||||
//
|
||||
// Created by James Magahern on 7/8/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMAliasValidationOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
69
kordophone/Bridge/Operations/MBIMAliasValidationOperation.m
Normal file
69
kordophone/Bridge/Operations/MBIMAliasValidationOperation.m
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// MBIMAliasValidationOperation.m
|
||||
// MBIMAliasValidationOperation
|
||||
//
|
||||
// Created by James Magahern on 7/8/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMAliasValidationOperation.h"
|
||||
|
||||
#import "IMCore_ClassDump.h"
|
||||
#import "IMFoundation_ClassDump.h"
|
||||
|
||||
@implementation MBIMAliasValidationOperation
|
||||
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
+ (NSString *)endpointName
|
||||
{
|
||||
return @"validate";
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSString *address = [self valueForQueryItemWithName:@"address"];
|
||||
if ([address length] == 0) {
|
||||
self.serverCompletionBlock([[HTTPErrorResponse alloc] initWithErrorCode:401]);
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *unformattedAddress = IMStripFormattingFromAddress(address);
|
||||
BOOL isEmailAddress = IMStringIsEmail(unformattedAddress);
|
||||
|
||||
NSString *IDSaddress = isEmailAddress ? IDSCopyIDForEmailAddress(unformattedAddress)
|
||||
: IDSCopyIDForPhoneNumber(unformattedAddress);
|
||||
|
||||
if (!IDSaddress) {
|
||||
MBIMLogError(@"Could not get IDS address for: %@", unformattedAddress);
|
||||
self.serverCompletionBlock([[HTTPErrorResponse alloc] initWithErrorCode:401]);
|
||||
return;
|
||||
}
|
||||
|
||||
__block IMChat *existingChat = nil;
|
||||
dispatch_sync([[self class] sharedIMAccessQueue], ^{
|
||||
IMAccount *iMessageAccount = [[IMAccountController sharedInstance] bestAccountForService:[IMServiceImpl iMessageService]];
|
||||
IMHandle *handle = [iMessageAccount imHandleWithID:unformattedAddress];
|
||||
|
||||
if (handle) {
|
||||
existingChat = [[IMChatRegistry sharedInstance] existingChatForIMHandle:handle];
|
||||
}
|
||||
});
|
||||
|
||||
IMChatCalculateServiceForSendingNewComposeMaybeForce(
|
||||
@[ IDSaddress ], nil, nil, NO, isEmailAddress, YES, NO, NO, nil,
|
||||
^(BOOL allAddressesiMessageCapable, NSDictionary *availabilityPerRecipient, BOOL checkedServer, NSError *error) {
|
||||
NSMutableDictionary *response = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"capable" : @(allAddressesiMessageCapable),
|
||||
@"idsAddress" : IDSaddress,
|
||||
}];
|
||||
|
||||
if ([existingChat guid]) {
|
||||
[response setObject:[existingChat guid] forKey:@"existingGuid"];
|
||||
}
|
||||
|
||||
self.serverCompletionBlock([MBIMJSONDataResponse responseWithJSONObject:response]);
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
17
kordophone/Bridge/Operations/MBIMAuthenticateOperation.h
Normal file
17
kordophone/Bridge/Operations/MBIMAuthenticateOperation.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMAuthenticateOperation.h
|
||||
// MBIMAuthenticateOperation
|
||||
//
|
||||
// Created by James Magahern on 7/6/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMAuthenticateOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
77
kordophone/Bridge/Operations/MBIMAuthenticateOperation.m
Normal file
77
kordophone/Bridge/Operations/MBIMAuthenticateOperation.m
Normal file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// MBIMAuthenticateOperation.m
|
||||
// MBIMAuthenticateOperation
|
||||
//
|
||||
// Created by James Magahern on 7/6/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMAuthenticateOperation.h"
|
||||
#import "MBIMBridge.h"
|
||||
#import "MBIMAuthToken.h"
|
||||
|
||||
@implementation MBIMAuthenticateOperation
|
||||
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
+ (NSString *)endpointName
|
||||
{
|
||||
return @"authenticate";
|
||||
}
|
||||
|
||||
+ (BOOL)requiresAuthentication
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSObject<HTTPResponse> *response = nil;
|
||||
|
||||
if (self.requestBodyData.length == 0) {
|
||||
self.serverCompletionBlock([[HTTPErrorResponse alloc] initWithErrorCode:400]);
|
||||
return;
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
NSDictionary *args = [NSJSONSerialization JSONObjectWithData:self.requestBodyData options:0 error:&error];
|
||||
if (error || args.count == 0) {
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:400];
|
||||
} else {
|
||||
do {
|
||||
NSString *username = [args objectForKey:@"username"];
|
||||
NSString *password = [args objectForKey:@"password"];
|
||||
|
||||
if (!username || !password) {
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:400];
|
||||
break;
|
||||
}
|
||||
|
||||
if (![MBIMBridge.sharedInstance.authUsername isEqualToString:username]) {
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:401];
|
||||
break;
|
||||
}
|
||||
|
||||
if (![MBIMBridge.sharedInstance.authPassword isEqualToString:password]) {
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:401];
|
||||
break;
|
||||
}
|
||||
|
||||
MBIMAuthToken *token = [[MBIMAuthToken alloc] initWithUsername:username];
|
||||
|
||||
// All systems go
|
||||
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);
|
||||
}
|
||||
|
||||
self.serverCompletionBlock(response);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -18,6 +18,7 @@ typedef void (^MBIMBridgeOperationCompletionBlock)(NSObject<HTTPResponse> * _Nul
|
||||
|
||||
@interface MBIMBridgeOperation : NSOperation
|
||||
@property (class, nonatomic, readonly) NSString *endpointName;
|
||||
@property (class, nonatomic, readonly) BOOL requiresAuthentication; // default YES
|
||||
|
||||
@property (nonatomic, strong) NSData *requestBodyData;
|
||||
@property (nonatomic, readonly) NSURL *requestURL;
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
return [[self _operationClassMapping] objectForKey:endpointName];
|
||||
}
|
||||
|
||||
+ (BOOL)requiresAuthentication
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithRequestURL:(NSURL *)requestURL completion:(MBIMBridgeOperationCompletionBlock)completionBlock
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
@@ -19,40 +19,95 @@
|
||||
return @"sendMessage";
|
||||
}
|
||||
|
||||
- (BOOL)_sendMessage:(NSString *)messageBody toHandles:(NSArray<NSString *> *)handleIDs attachmentGUIDs:(NSArray<NSString *> *)guids
|
||||
{
|
||||
__block BOOL result = YES;
|
||||
dispatch_sync([[self class] sharedIMAccessQueue], ^{
|
||||
IMAccount *iMessageAccount = [[IMAccountController sharedInstance] bestAccountForService:[IMServiceImpl iMessageService]];
|
||||
|
||||
NSMutableArray<IMHandle *> *handles = [NSMutableArray array];
|
||||
for (NSString *handleID in handleIDs) {
|
||||
IMHandle *handle = [iMessageAccount imHandleWithID:handleID];
|
||||
if (handle) {
|
||||
[handles addObject:handle];
|
||||
} else {
|
||||
MBIMLogError(@"MBIMSendMessageOperation: Invalid handle ID: %@", handleID);
|
||||
}
|
||||
}
|
||||
|
||||
IMChat *chat = nil;
|
||||
if (handles.count == 1) {
|
||||
// Single recipient
|
||||
IMHandle *handle = [handles firstObject];
|
||||
chat = [[IMChatRegistry sharedInstance] existingChatForIMHandle:handle];
|
||||
if (chat == nil) {
|
||||
MBIMLogInfo(@"MBIMSendMessageOperation: Creating chat with handle: %@", handle);
|
||||
chat = [[IMChatRegistry sharedInstance] chatForIMHandle:handle];
|
||||
}
|
||||
} else if (handles.count > 1) {
|
||||
// Group chat
|
||||
chat = [[IMChatRegistry sharedInstance] existingChatForIMHandles:handles allowRetargeting:NO groupID:nil displayName:nil joinedChatsOnly:YES];
|
||||
if (chat == nil) {
|
||||
MBIMLogInfo(@"MBIMSendMessageOperation: Creating group chat with handles: %@", handles);
|
||||
chat = [[IMChatRegistry sharedInstance] chatForIMHandles:handles];
|
||||
}
|
||||
} else {
|
||||
// No handles?
|
||||
result = NO;
|
||||
}
|
||||
|
||||
if (chat) {
|
||||
result = [self _sendMessage:messageBody toChat:chat attachmentGUIDs:guids];
|
||||
} else {
|
||||
result = NO;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL)_sendMessage:(NSString *)messageBody toChatWithGUID:(NSString *)chatGUID attachmentGUIDs:(NSArray<NSString *> *)guids
|
||||
{
|
||||
__block BOOL result = YES;
|
||||
|
||||
dispatch_sync([[self class] sharedIMAccessQueue], ^{
|
||||
IMChat *chat = [[IMChatRegistry sharedInstance] existingChatWithGUID:chatGUID];
|
||||
|
||||
// TODO: chat might not be an iMessage chat!
|
||||
IMAccount *iMessageAccount = [[IMAccountController sharedInstance] bestAccountForService:[IMServiceImpl iMessageService]];
|
||||
IMHandle *senderHandle = [iMessageAccount loginIMHandle];
|
||||
|
||||
NSAttributedString *replyAttrString = [[NSAttributedString alloc] initWithString:messageBody];
|
||||
NSAttributedString *attrStringWithFileTransfers = IMCreateSuperFormatStringWithAppendedFileTransfers(replyAttrString, guids);
|
||||
|
||||
IMMessage *reply = [IMMessage fromMeIMHandle:senderHandle
|
||||
withText:attrStringWithFileTransfers
|
||||
fileTransferGUIDs:guids
|
||||
flags:(kIMMessageFinished | kIMMessageIsFromMe)];
|
||||
|
||||
for (NSString *guid in [reply fileTransferGUIDs]) {
|
||||
[[IMFileTransferCenter sharedInstance] assignTransfer:guid toHandle:chat.recipient];
|
||||
}
|
||||
|
||||
if (!chat) {
|
||||
MBIMLogInfo(@"Chat does not exist: %@", chatGUID);
|
||||
result = NO;
|
||||
} else {
|
||||
[chat sendMessage:reply];
|
||||
result = [self _sendMessage:messageBody toChat:chat attachmentGUIDs:guids];
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL)_sendMessage:(NSString *)messageBody toChat:(IMChat *)chat attachmentGUIDs:(NSArray<NSString *> *)guids
|
||||
{
|
||||
dispatch_assert_queue([[self class] sharedIMAccessQueue]);
|
||||
|
||||
BOOL result = YES;
|
||||
|
||||
// TODO: chat might not be an iMessage chat!
|
||||
IMAccount *iMessageAccount = [[IMAccountController sharedInstance] bestAccountForService:[IMServiceImpl iMessageService]];
|
||||
IMHandle *senderHandle = [iMessageAccount loginIMHandle];
|
||||
|
||||
NSAttributedString *replyAttrString = [[NSAttributedString alloc] initWithString:messageBody];
|
||||
NSAttributedString *attrStringWithFileTransfers = IMCreateSuperFormatStringWithAppendedFileTransfers(replyAttrString, guids);
|
||||
|
||||
IMMessage *reply = [IMMessage fromMeIMHandle:senderHandle
|
||||
withText:attrStringWithFileTransfers
|
||||
fileTransferGUIDs:guids
|
||||
flags:(kIMMessageFinished | kIMMessageIsFromMe)];
|
||||
|
||||
for (NSString *guid in [reply fileTransferGUIDs]) {
|
||||
[[IMFileTransferCenter sharedInstance] assignTransfer:guid toHandle:chat.recipient];
|
||||
}
|
||||
|
||||
[chat sendMessage:reply];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSObject<HTTPResponse> *response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
@@ -64,9 +119,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *guid = [args objectForKey:@"guid"];
|
||||
NSString *messageBody = [args objectForKey:@"body"];
|
||||
if (!guid || !messageBody) {
|
||||
if (!messageBody) {
|
||||
self.serverCompletionBlock(response);
|
||||
return;
|
||||
}
|
||||
@@ -76,7 +130,15 @@
|
||||
transferGUIDs = @[];
|
||||
}
|
||||
|
||||
BOOL result = [self _sendMessage:messageBody toChatWithGUID:guid attachmentGUIDs:transferGUIDs];
|
||||
BOOL result = NO;
|
||||
NSString *guid = [args objectForKey:@"guid"];
|
||||
NSArray<NSString *> *handles = [args objectForKey:@"handles"];
|
||||
if (guid) {
|
||||
result = [self _sendMessage:messageBody toChatWithGUID:guid attachmentGUIDs:transferGUIDs];
|
||||
} else if ([handles count] > 0) {
|
||||
result = [self _sendMessage:messageBody toHandles:handles attachmentGUIDs:transferGUIDs];
|
||||
}
|
||||
|
||||
if (result) {
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:200];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMDataResponse : HTTPDataResponse
|
||||
@property (nonatomic, readonly) NSMutableDictionary *httpHeaders;
|
||||
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
|
||||
@end
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
@implementation MBIMDataResponse {
|
||||
NSString *_contentType;
|
||||
NSMutableDictionary *_httpHeaders;
|
||||
}
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
|
||||
@@ -17,6 +18,9 @@
|
||||
self = [super initWithData:data];
|
||||
if (self) {
|
||||
_contentType = contentType;
|
||||
_httpHeaders = [@{
|
||||
@"Content-Type" : _contentType ?: @"application/octet-stream"
|
||||
} mutableCopy];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -24,9 +28,7 @@
|
||||
|
||||
- (NSDictionary *)httpHeaders
|
||||
{
|
||||
return @{
|
||||
@"Content-Type" : _contentType ?: @"application/octet-stream"
|
||||
};
|
||||
return _httpHeaders;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#import "MBIMBridge.h"
|
||||
|
||||
void printUsage()
|
||||
static void printUsage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: kordophoned [-h] [-s | -c (certificate.p12)] [-a (access control file)\n");
|
||||
fprintf(stderr, "\t-h \t Show this help message\n");
|
||||
|
||||
Reference in New Issue
Block a user