1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 #import <Foundation/Foundation.h> 4 5 @class EXManifestsManifest; 6 7 NS_ASSUME_NONNULL_BEGIN 8 9 typedef void (^EXVerifySignatureSuccessBlock)(BOOL isValid); 10 typedef void (^EXVerifySignatureErrorBlock)(NSError *error); 11 12 @interface EXApiUtil : NSObject 13 14 /** 15 * Verify data using a RSA+SHA256 base64 signature string and the public key at #{publicKeyUrl}. 16 * The public key must be in `pem` format and will be downloaded and cached. 17 * 18 * @param publicKeyUrl Url of the public key 19 * @param data The data string to verify 20 * @param signature The signature string to verify with 21 * @param successBlock Called when the verification is finished with the result 22 * @param errorBlock Called if an error occured, eg. a network error downloading the key 23 */ 24 + (void)verifySignatureWithPublicKeyUrl:(NSURL *)publicKeyUrl 25 data:(NSString *)data 26 signature:(NSString *)signature 27 successBlock:(EXVerifySignatureSuccessBlock)successBlock 28 errorBlock:(EXVerifySignatureErrorBlock)errorBlock; 29 30 + (NSURL *)bundleUrlFromManifest:(EXManifestsManifest *)manifest; 31 + (NSURL *)encodedUrlFromString:(NSString *)urlString; 32 33 @end 34 35 NS_ASSUME_NONNULL_END 36