@appzung/react-native-code-push 5.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/AlertAdapter.js +24 -0
  2. package/CONTRIBUTING.md +136 -0
  3. package/CodePush.js +666 -0
  4. package/CodePush.podspec +27 -0
  5. package/LICENSE.md +13 -0
  6. package/README.md +386 -0
  7. package/RestartManager.js +59 -0
  8. package/android/app/build.gradle +31 -0
  9. package/android/app/proguard-rules.pro +25 -0
  10. package/android/app/src/main/AndroidManifest.xml +10 -0
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +395 -0
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +34 -0
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
  16. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
  17. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
  18. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
  19. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +641 -0
  20. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
  21. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
  22. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
  23. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +369 -0
  24. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
  25. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +267 -0
  26. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +236 -0
  27. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
  28. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
  29. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +190 -0
  30. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +17 -0
  31. package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
  32. package/android/build.gradle +20 -0
  33. package/android/codepush.gradle +113 -0
  34. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  35. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  36. package/android/gradle.properties +20 -0
  37. package/android/gradlew +164 -0
  38. package/android/gradlew.bat +90 -0
  39. package/android/settings.gradle +1 -0
  40. package/docs/api-android.md +65 -0
  41. package/docs/api-ios.md +31 -0
  42. package/docs/api-js.md +592 -0
  43. package/docs/multi-deployment-testing-android.md +107 -0
  44. package/docs/multi-deployment-testing-ios.md +53 -0
  45. package/docs/setup-android.md +406 -0
  46. package/docs/setup-ios.md +229 -0
  47. package/docs/setup-windows.md +65 -0
  48. package/gulpfile.js +302 -0
  49. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
  50. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
  51. package/ios/CodePush/Base64/README.md +47 -0
  52. package/ios/CodePush/CodePush.h +235 -0
  53. package/ios/CodePush/CodePush.m +1041 -0
  54. package/ios/CodePush/CodePushConfig.m +116 -0
  55. package/ios/CodePush/CodePushDownloadHandler.m +130 -0
  56. package/ios/CodePush/CodePushErrorUtils.m +20 -0
  57. package/ios/CodePush/CodePushPackage.m +598 -0
  58. package/ios/CodePush/CodePushTelemetryManager.m +175 -0
  59. package/ios/CodePush/CodePushUpdateUtils.m +376 -0
  60. package/ios/CodePush/CodePushUtils.m +9 -0
  61. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
  62. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
  63. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
  64. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
  65. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
  66. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
  67. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
  68. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
  69. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
  70. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
  71. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
  72. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
  73. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
  74. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
  75. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
  76. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
  77. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
  78. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
  79. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
  80. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
  83. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
  84. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
  85. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
  86. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
  87. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
  88. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
  89. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
  91. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
  92. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
  93. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
  94. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
  95. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
  96. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
  97. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
  101. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
  102. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
  103. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
  104. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
  105. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
  106. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
  107. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
  108. package/ios/CodePush/JWT/LICENSE +19 -0
  109. package/ios/CodePush/JWT/README.md +489 -0
  110. package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
  111. package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
  112. package/ios/CodePush/SSZipArchive/Common.h +81 -0
  113. package/ios/CodePush/SSZipArchive/README.md +1 -0
  114. package/ios/CodePush/SSZipArchive/SSZipArchive.h +76 -0
  115. package/ios/CodePush/SSZipArchive/SSZipArchive.m +691 -0
  116. package/ios/CodePush/SSZipArchive/aes/aes.h +198 -0
  117. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +541 -0
  118. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +294 -0
  119. package/ios/CodePush/SSZipArchive/aes/aeskey.c +548 -0
  120. package/ios/CodePush/SSZipArchive/aes/aesopt.h +739 -0
  121. package/ios/CodePush/SSZipArchive/aes/aestab.c +391 -0
  122. package/ios/CodePush/SSZipArchive/aes/aestab.h +173 -0
  123. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +126 -0
  124. package/ios/CodePush/SSZipArchive/aes/brg_types.h +219 -0
  125. package/ios/CodePush/SSZipArchive/aes/entropy.c +54 -0
  126. package/ios/CodePush/SSZipArchive/aes/entropy.h +16 -0
  127. package/ios/CodePush/SSZipArchive/aes/fileenc.c +144 -0
  128. package/ios/CodePush/SSZipArchive/aes/fileenc.h +121 -0
  129. package/ios/CodePush/SSZipArchive/aes/hmac.c +145 -0
  130. package/ios/CodePush/SSZipArchive/aes/hmac.h +103 -0
  131. package/ios/CodePush/SSZipArchive/aes/prng.c +155 -0
  132. package/ios/CodePush/SSZipArchive/aes/prng.h +82 -0
  133. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +103 -0
  134. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +57 -0
  135. package/ios/CodePush/SSZipArchive/aes/sha1.c +258 -0
  136. package/ios/CodePush/SSZipArchive/aes/sha1.h +73 -0
  137. package/ios/CodePush/SSZipArchive/minizip/crypt.h +130 -0
  138. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +369 -0
  139. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +175 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mztools.c +284 -0
  141. package/ios/CodePush/SSZipArchive/minizip/mztools.h +31 -0
  142. package/ios/CodePush/SSZipArchive/minizip/unzip.c +1839 -0
  143. package/ios/CodePush/SSZipArchive/minizip/unzip.h +248 -0
  144. package/ios/CodePush/SSZipArchive/minizip/zip.c +1910 -0
  145. package/ios/CodePush/SSZipArchive/minizip/zip.h +202 -0
  146. package/ios/CodePush.xcodeproj/project.pbxproj +937 -0
  147. package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  148. package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  149. package/logging.js +6 -0
  150. package/package-mixins.js +69 -0
  151. package/package.json +47 -0
  152. package/request-fetch-adapter.js +52 -0
  153. package/scripts/generateBundledResourcesHash.js +125 -0
  154. package/scripts/getFilesInFolder.js +19 -0
  155. package/scripts/postlink/android/postlink.js +87 -0
  156. package/scripts/postlink/ios/postlink.js +116 -0
  157. package/scripts/postlink/run.js +11 -0
  158. package/scripts/postunlink/android/postunlink.js +74 -0
  159. package/scripts/postunlink/ios/postunlink.js +87 -0
  160. package/scripts/postunlink/run.js +11 -0
  161. package/scripts/recordFilesBeforeBundleCommand.js +41 -0
  162. package/scripts/tools/linkToolsAndroid.js +57 -0
  163. package/scripts/tools/linkToolsIos.js +130 -0
  164. package/typings/react-native-code-push.d.ts +446 -0
  165. package/windows/CodePush/CodePush.csproj +128 -0
  166. package/windows/CodePush/CodePushUtils.cs +47 -0
  167. package/windows/CodePush/FileUtils.cs +40 -0
  168. package/windows/CodePush/Properties/AssemblyInfo.cs +29 -0
  169. package/windows/CodePush/Properties/CodePush.rd.xml +33 -0
  170. package/windows/CodePush/UpdateManager.cs +305 -0
  171. package/windows/CodePush/UpdateUtils.cs +46 -0
  172. package/windows/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
  173. package/windows/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
  174. package/windows/CodePush.Net46/CodePush.Net46.csproj +103 -0
  175. package/windows/CodePush.Net46/CodePushUtils.cs +158 -0
  176. package/windows/CodePush.Net46/FileUtils.cs +55 -0
  177. package/windows/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
  178. package/windows/CodePush.Net46/UpdateManager.cs +330 -0
  179. package/windows/CodePush.Net46/UpdateUtils.cs +70 -0
  180. package/windows/CodePush.Net46/packages.config +5 -0
  181. package/windows/CodePush.Shared/CodePush.Shared.projitems +22 -0
  182. package/windows/CodePush.Shared/CodePush.Shared.shproj +13 -0
  183. package/windows/CodePush.Shared/CodePushConstants.cs +35 -0
  184. package/windows/CodePush.Shared/CodePushNativeModule.cs +329 -0
  185. package/windows/CodePush.Shared/CodePushReactPackage.cs +235 -0
  186. package/windows/CodePush.Shared/CodePushUtils.cs +70 -0
  187. package/windows/CodePush.Shared/InstallMode.cs +9 -0
  188. package/windows/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
  189. package/windows/CodePush.Shared/SettingsManager.cs +148 -0
  190. package/windows/CodePush.Shared/TelemetryManager.cs +250 -0
  191. package/windows/CodePush.Shared/UpdateState.cs +9 -0
@@ -0,0 +1,252 @@
1
+ //
2
+ // MF_Base64Additions.m
3
+ // Base64 -- RFC 4648 compatible implementation
4
+ // see http://www.ietf.org/rfc/rfc4648.txt for more details
5
+ //
6
+ // Designed to be compiled with Automatic Reference Counting
7
+ //
8
+ // Created by Dave Poirier on 2012-06-14.
9
+ // Public Domain
10
+ // Hosted at https://github.com/ekscrypto/Base64
11
+ //
12
+
13
+ #import "MF_Base64Additions.h"
14
+
15
+ @implementation MF_Base64Codec
16
+
17
+ +(NSString *)base64StringFromBase64UrlEncodedString:(NSString *)base64UrlEncodedString
18
+ {
19
+ NSString *s = base64UrlEncodedString;
20
+ s = [s stringByReplacingOccurrencesOfString:@"-" withString:@"+"];
21
+ s = [s stringByReplacingOccurrencesOfString:@"_" withString:@"/"];
22
+ switch (s.length % 4) {
23
+ case 2:
24
+ s = [s stringByAppendingString:@"=="];
25
+ break;
26
+ case 3:
27
+ s = [s stringByAppendingString:@"="];
28
+ break;
29
+ default:
30
+ break;
31
+ }
32
+ return s;
33
+ }
34
+
35
+ +(NSString *)base64UrlEncodedStringFromBase64String:(NSString *)base64String
36
+ {
37
+ NSString *s = base64String;
38
+ s = [s stringByReplacingOccurrencesOfString:@"=" withString:@""];
39
+ s = [s stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
40
+ s = [s stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
41
+ return s;
42
+ }
43
+
44
+ +(NSData *)dataFromBase64String:(NSString *)encoding
45
+ {
46
+ NSData *data = nil;
47
+ unsigned char *decodedBytes = NULL;
48
+ @try {
49
+ #define __ 255
50
+ static char decodingTable[256] = {
51
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x00 - 0x0F
52
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x10 - 0x1F
53
+ __,__,__,__, __,__,__,__, __,__,__,62, __,__,__,63, // 0x20 - 0x2F
54
+ 52,53,54,55, 56,57,58,59, 60,61,__,__, __, 0,__,__, // 0x30 - 0x3F
55
+ __, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, // 0x40 - 0x4F
56
+ 15,16,17,18, 19,20,21,22, 23,24,25,__, __,__,__,__, // 0x50 - 0x5F
57
+ __,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, // 0x60 - 0x6F
58
+ 41,42,43,44, 45,46,47,48, 49,50,51,__, __,__,__,__, // 0x70 - 0x7F
59
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x80 - 0x8F
60
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x90 - 0x9F
61
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xA0 - 0xAF
62
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xB0 - 0xBF
63
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xC0 - 0xCF
64
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xD0 - 0xDF
65
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xE0 - 0xEF
66
+ __,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xF0 - 0xFF
67
+ };
68
+ encoding = [encoding stringByReplacingOccurrencesOfString:@"=" withString:@""];
69
+ NSData *encodedData = [encoding dataUsingEncoding:NSASCIIStringEncoding];
70
+ unsigned char *encodedBytes = (unsigned char *)[encodedData bytes];
71
+
72
+ NSUInteger encodedLength = [encodedData length];
73
+ if( encodedLength >= (NSUIntegerMax - 3) ) return nil; // NSUInteger overflow check
74
+ NSUInteger encodedBlocks = (encodedLength+3) >> 2;
75
+ NSUInteger expectedDataLength = encodedBlocks * 3;
76
+
77
+ unsigned char decodingBlock[4];
78
+
79
+ decodedBytes = malloc(expectedDataLength);
80
+ if( decodedBytes != NULL ) {
81
+
82
+ NSUInteger i = 0;
83
+ NSUInteger j = 0;
84
+ NSUInteger k = 0;
85
+ unsigned char c;
86
+ while( i < encodedLength ) {
87
+ c = decodingTable[encodedBytes[i]];
88
+ i++;
89
+ if( c != __ ) {
90
+ decodingBlock[j] = c;
91
+ j++;
92
+ if( j == 4 ) {
93
+ decodedBytes[k] = (decodingBlock[0] << 2) | (decodingBlock[1] >> 4);
94
+ decodedBytes[k+1] = (decodingBlock[1] << 4) | (decodingBlock[2] >> 2);
95
+ decodedBytes[k+2] = (decodingBlock[2] << 6) | (decodingBlock[3]);
96
+ j = 0;
97
+ k += 3;
98
+ }
99
+ }
100
+ }
101
+
102
+ // Process left over bytes, if any
103
+ if( j == 3 ) {
104
+ decodedBytes[k] = (decodingBlock[0] << 2) | (decodingBlock[1] >> 4);
105
+ decodedBytes[k+1] = (decodingBlock[1] << 4) | (decodingBlock[2] >> 2);
106
+ k += 2;
107
+ } else if( j == 2 ) {
108
+ decodedBytes[k] = (decodingBlock[0] << 2) | (decodingBlock[1] >> 4);
109
+ k += 1;
110
+ }
111
+ data = [[NSData alloc] initWithBytes:decodedBytes length:k];
112
+ }
113
+ }
114
+ @catch (NSException *exception) {
115
+ data = nil;
116
+ NSLog(@"WARNING: error occured while decoding base 32 string: %@", exception);
117
+ }
118
+ @finally {
119
+ if( decodedBytes != NULL ) {
120
+ free( decodedBytes );
121
+ }
122
+ }
123
+ return data;
124
+ }
125
+ +(NSString *)base64StringFromData:(NSData *)data
126
+ {
127
+ NSString *encoding = nil;
128
+ unsigned char *encodingBytes = NULL;
129
+ @try {
130
+ static char encodingTable[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
131
+ static NSUInteger paddingTable[] = {0,2,1};
132
+ // Table 1: The Base 64 Alphabet
133
+ //
134
+ // Value Encoding Value Encoding Value Encoding Value Encoding
135
+ // 0 A 17 R 34 i 51 z
136
+ // 1 B 18 S 35 j 52 0
137
+ // 2 C 19 T 36 k 53 1
138
+ // 3 D 20 U 37 l 54 2
139
+ // 4 E 21 V 38 m 55 3
140
+ // 5 F 22 W 39 n 56 4
141
+ // 6 G 23 X 40 o 57 5
142
+ // 7 H 24 Y 41 p 58 6
143
+ // 8 I 25 Z 42 q 59 7
144
+ // 9 J 26 a 43 r 60 8
145
+ // 10 K 27 b 44 s 61 9
146
+ // 11 L 28 c 45 t 62 +
147
+ // 12 M 29 d 46 u 63 /
148
+ // 13 N 30 e 47 v
149
+ // 14 O 31 f 48 w (pad) =
150
+ // 15 P 32 g 49 x
151
+ // 16 Q 33 h 50 y
152
+
153
+ NSUInteger dataLength = [data length];
154
+ NSUInteger encodedBlocks = dataLength / 3;
155
+ if( (encodedBlocks + 1) >= (NSUIntegerMax / 4) ) return nil; // NSUInteger overflow check
156
+ NSUInteger padding = paddingTable[dataLength % 3];
157
+ if( padding > 0 ) encodedBlocks++;
158
+ NSUInteger encodedLength = encodedBlocks * 4;
159
+
160
+ encodingBytes = malloc(encodedLength);
161
+ if( encodingBytes != NULL ) {
162
+ NSUInteger rawBytesToProcess = dataLength;
163
+ NSUInteger rawBaseIndex = 0;
164
+ NSUInteger encodingBaseIndex = 0;
165
+ unsigned char *rawBytes = (unsigned char *)[data bytes];
166
+ unsigned char rawByte1, rawByte2, rawByte3;
167
+ while( rawBytesToProcess >= 3 ) {
168
+ rawByte1 = rawBytes[rawBaseIndex];
169
+ rawByte2 = rawBytes[rawBaseIndex+1];
170
+ rawByte3 = rawBytes[rawBaseIndex+2];
171
+ encodingBytes[encodingBaseIndex] = encodingTable[((rawByte1 >> 2) & 0x3F)];
172
+ encodingBytes[encodingBaseIndex+1] = encodingTable[((rawByte1 << 4) & 0x30) | ((rawByte2 >> 4) & 0x0F) ];
173
+ encodingBytes[encodingBaseIndex+2] = encodingTable[((rawByte2 << 2) & 0x3C) | ((rawByte3 >> 6) & 0x03) ];
174
+ encodingBytes[encodingBaseIndex+3] = encodingTable[(rawByte3 & 0x3F)];
175
+
176
+ rawBaseIndex += 3;
177
+ encodingBaseIndex += 4;
178
+ rawBytesToProcess -= 3;
179
+ }
180
+ rawByte2 = 0;
181
+ switch (dataLength-rawBaseIndex) {
182
+ case 2:
183
+ rawByte2 = rawBytes[rawBaseIndex+1];
184
+ case 1:
185
+ rawByte1 = rawBytes[rawBaseIndex];
186
+ encodingBytes[encodingBaseIndex] = encodingTable[((rawByte1 >> 2) & 0x3F)];
187
+ encodingBytes[encodingBaseIndex+1] = encodingTable[((rawByte1 << 4) & 0x30) | ((rawByte2 >> 4) & 0x0F) ];
188
+ encodingBytes[encodingBaseIndex+2] = encodingTable[((rawByte2 << 2) & 0x3C) ];
189
+ // we can skip rawByte3 since we have a partial block it would always be 0
190
+ break;
191
+ }
192
+ // compute location from where to begin inserting padding, it may overwrite some bytes from the partial block encoding
193
+ // if their value was 0 (cases 1-2).
194
+ encodingBaseIndex = encodedLength - padding;
195
+ while( padding-- > 0 ) {
196
+ encodingBytes[encodingBaseIndex++] = '=';
197
+ }
198
+ encoding = [[NSString alloc] initWithBytes:encodingBytes length:encodedLength encoding:NSASCIIStringEncoding];
199
+ }
200
+ }
201
+ @catch (NSException *exception) {
202
+ encoding = nil;
203
+ NSLog(@"WARNING: error occured while tring to encode base 32 data: %@", exception);
204
+ }
205
+ @finally {
206
+ if( encodingBytes != NULL ) {
207
+ free( encodingBytes );
208
+ }
209
+ }
210
+ return encoding;
211
+ }
212
+ @end
213
+
214
+ @implementation NSString (Base64Addition)
215
+ -(NSString *)base64String
216
+ {
217
+ NSData *utf8encoding = [self dataUsingEncoding:NSUTF8StringEncoding];
218
+ return [MF_Base64Codec base64StringFromData:utf8encoding];
219
+ }
220
+ -(NSString *)base64UrlEncodedString
221
+ {
222
+ return [MF_Base64Codec base64UrlEncodedStringFromBase64String:[self base64String]];
223
+ }
224
+ +(NSString *)stringFromBase64String:(NSString *)base64String
225
+ {
226
+ NSData *utf8encoding = [MF_Base64Codec dataFromBase64String:base64String];
227
+ return [[NSString alloc] initWithData:utf8encoding encoding:NSUTF8StringEncoding];
228
+ }
229
+ +(NSString *)stringFromBase64UrlEncodedString:(NSString *)base64UrlEncodedString
230
+ {
231
+ return [self stringFromBase64String:[MF_Base64Codec base64StringFromBase64UrlEncodedString:base64UrlEncodedString]];
232
+ }
233
+ @end
234
+
235
+ @implementation NSData (Base64Addition)
236
+ +(NSData *)dataWithBase64String:(NSString *)base64String
237
+ {
238
+ return [MF_Base64Codec dataFromBase64String:base64String];
239
+ }
240
+ +(NSData *)dataWithBase64UrlEncodedString:(NSString *)base64UrlEncodedString
241
+ {
242
+ return [self dataWithBase64String:[MF_Base64Codec base64StringFromBase64UrlEncodedString:base64UrlEncodedString]];
243
+ }
244
+ -(NSString *)base64String
245
+ {
246
+ return [MF_Base64Codec base64StringFromData:self];
247
+ }
248
+ -(NSString *)base64UrlEncodedString
249
+ {
250
+ return [MF_Base64Codec base64UrlEncodedStringFromBase64String:[self base64String]];
251
+ }
252
+ @end
@@ -0,0 +1,47 @@
1
+ [![CI Status](https://travis-ci.org/ekscrypto/Base64.svg?branch=master)](https://github.com/ekscrypto/Base64)
2
+
3
+ Base64 Additions for Objective-C on Mac OS X and iOS
4
+ =======
5
+
6
+
7
+ Usage
8
+ ----
9
+ Open the Xcode project file, and drag MF_Base64Additions.m/.h into your project.
10
+
11
+ In files where you want to use Base64 encoding/decoding, simply include the header file and use one of the provided NSData or NSString additions.
12
+
13
+ Example use:
14
+ #import "MF_Base64Additions.h"
15
+
16
+ NSString *helloWorld = @"Hello World";
17
+ NSString *helloInBase64 = [helloWorld base64String];
18
+ NSString *helloDecoded = [NSString stringFromBase64String:helloInBase64];
19
+
20
+
21
+
22
+
23
+ Performance
24
+ ----
25
+ * Encoding: Approximately 4 to 5 times faster than using the equivalent SecTransform.
26
+ * Encoding: 30% faster than https://github.com/l4u/NSData-Base64
27
+ * Decoding: 5% faster than using the equivalent SecTransform.
28
+ * Decoding: 5% faster than https://github.com/l4u/NSData-Base64
29
+
30
+
31
+
32
+ Requirements
33
+ -----
34
+ * Compile with Automatic Reference Counting
35
+ * Compatible with Mac OSX 10.6+ and iOS 4.0+
36
+
37
+
38
+
39
+ Implementation
40
+ ----
41
+ * Implemented as per RFC 4648, see http://www.ietf.org/rfc/rfc4648.txt for more details.
42
+
43
+
44
+
45
+ Licensing
46
+ ----
47
+ * Public Domain
@@ -0,0 +1,235 @@
1
+ #if __has_include(<React/RCTEventEmitter.h>)
2
+ #import <React/RCTEventEmitter.h>
3
+ #elif __has_include("RCTEventEmitter.h")
4
+ #import "RCTEventEmitter.h"
5
+ #else
6
+ #import "React/RCTEventEmitter.h" // Required when used as a Pod in a Swift project
7
+ #endif
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ @interface CodePush : RCTEventEmitter
12
+
13
+ + (NSURL *)binaryBundleURL;
14
+ /*
15
+ * This method is used to retrieve the URL for the most recent
16
+ * version of the JavaScript bundle. This could be either the
17
+ * bundle that was packaged with the app binary, or the bundle
18
+ * that was downloaded as part of a CodePush update. The value returned
19
+ * should be used to "bootstrap" the React Native bridge.
20
+ *
21
+ * This method assumes that your JS bundle is named "main.jsbundle"
22
+ * and therefore, if it isn't, you should use either the bundleURLForResource:
23
+ * or bundleURLForResource:withExtension: methods to override that behavior.
24
+ */
25
+ + (NSURL *)bundleURL;
26
+
27
+ + (NSURL *)bundleURLForResource:(NSString *)resourceName;
28
+
29
+ + (NSURL *)bundleURLForResource:(NSString *)resourceName
30
+ withExtension:(NSString *)resourceExtension;
31
+
32
+ + (NSURL *)bundleURLForResource:(NSString *)resourceName
33
+ withExtension:(NSString *)resourceExtension
34
+ subdirectory:(NSString *)resourceSubdirectory;
35
+
36
+ + (NSURL *)bundleURLForResource:(NSString *)resourceName
37
+ withExtension:(NSString *)resourceExtension
38
+ subdirectory:(NSString *)resourceSubdirectory
39
+ bundle:(NSBundle *)resourceBundle;
40
+
41
+ + (NSString *)getApplicationSupportDirectory;
42
+
43
+ + (NSString *)bundleAssetsPath;
44
+
45
+ /*
46
+ * This method allows the version of the app's binary interface
47
+ * to be specified, which would otherwise default to the
48
+ * binary version of the app.
49
+ */
50
+ + (void)overrideAppVersion:(NSString *)appVersion;
51
+
52
+ /*
53
+ * This method allows dynamically setting the app's
54
+ * deployment key, in addition to setting it via
55
+ * the Info.plist file's CodePushDeploymentKey setting.
56
+ */
57
+ + (void)setDeploymentKey:(NSString *)deploymentKey;
58
+
59
+ /*
60
+ * This method checks to see whether a specific package hash
61
+ * has previously failed installation.
62
+ */
63
+ + (BOOL)isFailedHash:(NSString*)packageHash;
64
+
65
+
66
+ /*
67
+ * This method is used to get information about the latest rollback.
68
+ * This information will be used to decide whether the application
69
+ * should ignore the update or not.
70
+ */
71
+ + (NSDictionary*)getRollbackInfo;
72
+ /*
73
+ * This method is used to save information about the latest rollback.
74
+ * This information will be used to decide whether the application
75
+ * should ignore the update or not.
76
+ */
77
+ + (void)setLatestRollbackInfo:(NSString*)packageHash;
78
+ /*
79
+ * This method is used to get the count of rollback for the package
80
+ * using the latest rollback information.
81
+ */
82
+ + (int)getRollbackCountForPackage:(NSString*) packageHash fromLatestRollbackInfo:(NSMutableDictionary*) latestRollbackInfo;
83
+
84
+ /*
85
+ * This method checks to see whether a specific package hash
86
+ * represents a downloaded and installed update, that hasn't
87
+ * been applied yet via an app restart.
88
+ */
89
+ + (BOOL)isPendingUpdate:(NSString*)packageHash;
90
+
91
+ // The below methods are only used during tests.
92
+ + (BOOL)isUsingTestConfiguration;
93
+ + (void)setUsingTestConfiguration:(BOOL)shouldUseTestConfiguration;
94
+ + (void)clearUpdates;
95
+
96
+ @end
97
+
98
+ @interface CodePushConfig : NSObject
99
+
100
+ @property (copy) NSString *appVersion;
101
+ @property (readonly) NSString *buildVersion;
102
+ @property (readonly) NSDictionary *configuration;
103
+ @property (copy) NSString *deploymentKey;
104
+ @property (copy) NSString *serverURL;
105
+ @property (copy) NSString *publicKey;
106
+
107
+ + (instancetype)current;
108
+
109
+ @end
110
+
111
+ @interface CodePushDownloadHandler : NSObject <NSURLConnectionDelegate>
112
+
113
+ @property (strong) NSOutputStream *outputFileStream;
114
+ @property long long expectedContentLength;
115
+ @property long long receivedContentLength;
116
+ @property dispatch_queue_t operationQueue;
117
+ @property (copy) void (^progressCallback)(long long, long long);
118
+ @property (copy) void (^doneCallback)(BOOL);
119
+ @property (copy) void (^failCallback)(NSError *err);
120
+ @property NSString *downloadUrl;
121
+
122
+ - (id)init:(NSString *)downloadFilePath
123
+ operationQueue:(dispatch_queue_t)operationQueue
124
+ progressCallback:(void (^)(long long, long long))progressCallback
125
+ doneCallback:(void (^)(BOOL))doneCallback
126
+ failCallback:(void (^)(NSError *err))failCallback;
127
+
128
+ - (void)download:(NSString*)url;
129
+
130
+ @end
131
+
132
+ @interface CodePushErrorUtils : NSObject
133
+
134
+ + (NSError *)errorWithMessage:(NSString *)errorMessage;
135
+ + (BOOL)isCodePushError:(NSError *)error;
136
+
137
+ @end
138
+
139
+ @interface CodePushPackage : NSObject
140
+
141
+ + (void)downloadPackage:(NSDictionary *)updatePackage
142
+ expectedBundleFileName:(NSString *)expectedBundleFileName
143
+ publicKey:(NSString *)publicKey
144
+ operationQueue:(dispatch_queue_t)operationQueue
145
+ progressCallback:(void (^)(long long, long long))progressCallback
146
+ doneCallback:(void (^)())doneCallback
147
+ failCallback:(void (^)(NSError *err))failCallback;
148
+
149
+ + (NSDictionary *)getCurrentPackage:(NSError **)error;
150
+ + (NSDictionary *)getPreviousPackage:(NSError **)error;
151
+ + (NSString *)getCurrentPackageFolderPath:(NSError **)error;
152
+ + (NSString *)getCurrentPackageBundlePath:(NSError **)error;
153
+ + (NSString *)getCurrentPackageHash:(NSError **)error;
154
+
155
+ + (NSDictionary *)getPackage:(NSString *)packageHash
156
+ error:(NSError **)error;
157
+
158
+ + (NSString *)getPackageFolderPath:(NSString *)packageHash;
159
+
160
+ + (BOOL)installPackage:(NSDictionary *)updatePackage
161
+ removePendingUpdate:(BOOL)removePendingUpdate
162
+ error:(NSError **)error;
163
+
164
+ + (void)rollbackPackage;
165
+
166
+ // The below methods are only used during tests.
167
+ + (void)clearUpdates;
168
+ + (void)downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl;
169
+
170
+ @end
171
+
172
+ @interface CodePushTelemetryManager : NSObject
173
+
174
+ + (NSDictionary *)getBinaryUpdateReport:(NSString *)appVersion;
175
+ + (NSDictionary *)getRetryStatusReport;
176
+ + (NSDictionary *)getRollbackReport:(NSDictionary *)lastFailedPackage;
177
+ + (NSDictionary *)getUpdateReport:(NSDictionary *)currentPackage;
178
+ + (void)recordStatusReported:(NSDictionary *)statusReport;
179
+ + (void)saveStatusReportForRetry:(NSDictionary *)statusReport;
180
+
181
+ @end
182
+
183
+ @interface CodePushUpdateUtils : NSObject
184
+
185
+ + (BOOL)copyEntriesInFolder:(NSString *)sourceFolder
186
+ destFolder:(NSString *)destFolder
187
+ error:(NSError **)error;
188
+
189
+ + (NSString *)findMainBundleInFolder:(NSString *)folderPath
190
+ expectedFileName:(NSString *)expectedFileName
191
+ error:(NSError **)error;
192
+
193
+ + (NSString *)assetsFolderName;
194
+ + (NSString *)getHashForBinaryContents:(NSURL *)binaryBundleUrl
195
+ error:(NSError **)error;
196
+
197
+ + (NSString *)manifestFolderPrefix;
198
+ + (NSString *)modifiedDateStringOfFileAtURL:(NSURL *)fileURL;
199
+
200
+ + (BOOL)isHashIgnoredFor:(NSString *) relativePath;
201
+
202
+ + (BOOL)verifyFolderHash:(NSString *)finalUpdateFolder
203
+ expectedHash:(NSString *)expectedHash
204
+ error:(NSError **)error;
205
+
206
+ // remove BEGIN / END tags and line breaks from public key string
207
+ + (NSString *)getKeyValueFromPublicKeyString:(NSString *)publicKeyString;
208
+
209
+ + (NSString *)getSignatureFilePath:(NSString *)updateFolderPath;
210
+
211
+ + (NSDictionary *) verifyAndDecodeJWT:(NSString *) jwt
212
+ withPublicKey:(NSString *)publicKey
213
+ error:(NSError **)error;
214
+
215
+ + (BOOL)verifyUpdateSignatureFor:(NSString *)updateFolderPath
216
+ expectedHash:(NSString *)newUpdateHash
217
+ withPublicKey:(NSString *)publicKeyString
218
+ error:(NSError **)error;
219
+
220
+ @end
221
+
222
+ void CPLog(NSString *formatString, ...);
223
+
224
+ typedef NS_ENUM(NSInteger, CodePushInstallMode) {
225
+ CodePushInstallModeImmediate,
226
+ CodePushInstallModeOnNextRestart,
227
+ CodePushInstallModeOnNextResume,
228
+ CodePushInstallModeOnNextSuspend
229
+ };
230
+
231
+ typedef NS_ENUM(NSInteger, CodePushUpdateState) {
232
+ CodePushUpdateStateRunning,
233
+ CodePushUpdateStatePending,
234
+ CodePushUpdateStateLatest
235
+ };