mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Matlab
		
	
| 
											9 years ago
										 | //  Copyright © 2016 Open Whisper Systems. All rights reserved. | ||
|  | 
 | ||
|  | #import "OWSDeviceProvisioningURLParser.h" | ||
|  | #import "NSData+Base64.h" | ||
|  | #import <AxolotlKit/NSData+keyVersionByte.h> | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
|  | NSString *const OWSQueryItemNameEphemeralDeviceIdKey = @"uuid"; | ||
|  | NSString *const OWSQueryItemNameEncodedPublicKeyKey = @"pub_key"; | ||
|  | 
 | ||
|  | @implementation OWSDeviceProvisioningURLParser | ||
|  | 
 | ||
|  | - (instancetype)initWithProvisioningURL:(NSString *)provisioningURL | ||
|  | { | ||
|  |     self = [super init]; | ||
|  |     if (!self) { | ||
|  |         return self; | ||
|  |     } | ||
|  | 
 | ||
|  |     NSURLComponents *components = [NSURLComponents componentsWithString:provisioningURL]; | ||
|  |     for (NSURLQueryItem *queryItem in [components queryItems]) { | ||
|  |         if ([queryItem.name isEqualToString:OWSQueryItemNameEphemeralDeviceIdKey]) { | ||
|  |             _ephemeralDeviceId = queryItem.value; | ||
|  |         } else if ([queryItem.name isEqualToString:OWSQueryItemNameEncodedPublicKeyKey]) { | ||
|  |             NSString *encodedPublicKey = queryItem.value; | ||
|  |             _publicKey = [[NSData dataFromBase64String:encodedPublicKey] removeKeyType]; | ||
|  |         } else { | ||
|  |             DDLogWarn(@"Unkown query item in provisioning string: %@", queryItem.name); | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     _valid = _ephemeralDeviceId && _publicKey; | ||
|  |     return self; | ||
|  | } | ||
|  | 
 | ||
|  | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |