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