@appzung/react-native-code-push 9.0.2 → 10.0.0-rc1

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/CodePush.js +22 -19
  2. package/LICENSE.md +1 -1
  3. package/README.md +159 -298
  4. package/android/app/.gradle/config.properties +2 -0
  5. package/android/app/build.gradle +1 -1
  6. package/android/app/local.properties +8 -0
  7. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +27 -21
  8. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +5 -5
  9. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -1
  10. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +1 -1
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +2 -2
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +2 -2
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +1 -1
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +2 -2
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +5 -5
  16. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +2 -2
  17. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +14 -14
  18. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +2 -2
  19. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +1 -1
  20. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +2 -2
  21. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +1 -1
  22. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +1 -1
  23. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +1 -1
  24. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +1 -1
  25. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +1 -1
  26. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +1 -1
  27. package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +1 -1
  28. package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +1 -1
  29. package/android/build.gradle +1 -1
  30. package/android/codepush.gradle +3 -3
  31. package/docs/advanced-usage.md +56 -0
  32. package/docs/api-android.md +12 -75
  33. package/docs/api-ios.md +5 -17
  34. package/docs/api-js.md +18 -55
  35. package/docs/setup-android.md +15 -397
  36. package/docs/setup-ios.md +24 -198
  37. package/docs/setup-windows.md +7 -74
  38. package/ios/CodePush/CodePush.h +4 -4
  39. package/ios/CodePush/CodePush.m +8 -8
  40. package/ios/CodePush/CodePushConfig.m +14 -11
  41. package/ios/CodePush/CodePushPackage.m +60 -60
  42. package/ios/CodePush/CodePushTelemetryManager.m +13 -13
  43. package/ios/CodePush.xcodeproj/project.pbxproj +1 -562
  44. package/package.json +27 -24
  45. package/react-native.config.js +1 -1
  46. package/scripts/generateBundledResourcesHash.js +1 -1
  47. package/scripts/getFilesInFolder.js +1 -1
  48. package/scripts/recordFilesBeforeBundleCommand.js +1 -1
  49. package/typings/react-native-code-push.d.ts +22 -22
  50. package/windows/CodePush/CodePushConfig.cpp +3 -3
  51. package/windows/CodePush/CodePushConfig.h +3 -3
  52. package/windows/CodePush/CodePushNativeModule.cpp +27 -27
  53. package/windows/CodePush/CodePushNativeModule.h +4 -4
  54. package/windows/CodePush/CodePushTelemetryManager.cpp +12 -12
  55. package/windows/CodePush/CodePushTelemetryManager.h +1 -1
  56. package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
  57. package/.azurepipelines/test-rn-code-push.yml +0 -94
  58. package/.config/CredScanSuppressions.json +0 -14
  59. package/SECURITY.md +0 -41
  60. package/docs/multi-deployment-testing-android.md +0 -148
  61. package/docs/multi-deployment-testing-ios.md +0 -59
  62. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
  63. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
  64. package/ios/CodePush/Base64/README.md +0 -47
  65. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
  66. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
  67. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
  68. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
  69. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
  70. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
  71. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
  72. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
  73. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
  74. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
  75. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
  76. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
  77. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
  78. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
  79. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
  80. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
  83. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
  84. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
  85. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
  86. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
  87. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
  88. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
  89. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
  91. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
  92. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
  93. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
  94. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
  95. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
  96. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
  97. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
  101. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
  102. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
  103. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
  104. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
  105. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
  106. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
  107. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
  108. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
  109. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
  110. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
  111. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
  112. package/ios/CodePush/JWT/LICENSE +0 -19
  113. package/ios/CodePush/JWT/README.md +0 -489
  114. package/ios/CodePush/SSZipArchive/Info.plist +0 -26
  115. package/ios/CodePush/SSZipArchive/README.md +0 -1
  116. package/ios/CodePush/SSZipArchive/SSZipArchive.h +0 -178
  117. package/ios/CodePush/SSZipArchive/SSZipArchive.m +0 -1496
  118. package/ios/CodePush/SSZipArchive/SSZipCommon.h +0 -71
  119. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +0 -23
  120. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +0 -25
  121. package/ios/CodePush/SSZipArchive/minizip/LICENSE +0 -17
  122. package/ios/CodePush/SSZipArchive/minizip/mz.h +0 -273
  123. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +0 -1306
  124. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +0 -346
  125. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +0 -187
  126. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +0 -65
  127. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +0 -526
  128. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +0 -348
  129. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +0 -176
  130. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +0 -350
  131. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +0 -556
  132. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +0 -132
  133. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +0 -383
  134. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +0 -42
  135. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +0 -269
  136. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +0 -48
  137. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +0 -40
  138. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +0 -203
  139. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +0 -334
  140. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +0 -46
  141. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +0 -429
  142. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +0 -43
  143. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +0 -360
  144. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +0 -46
  145. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +0 -389
  146. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +0 -43
  147. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +0 -2782
  148. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +0 -262
  149. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +0 -1942
  150. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +0 -285
  151. package/scripts/postlink/android/postlink.js +0 -87
  152. package/scripts/postlink/ios/postlink.js +0 -116
  153. package/scripts/postlink/run.js +0 -11
  154. package/scripts/postunlink/android/postunlink.js +0 -74
  155. package/scripts/postunlink/ios/postunlink.js +0 -87
  156. package/scripts/postunlink/run.js +0 -11
  157. package/scripts/tools/linkToolsAndroid.js +0 -57
  158. package/scripts/tools/linkToolsIos.js +0 -130
  159. package/windows-legacy/CodePush/CodePush.csproj +0 -128
  160. package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
  161. package/windows-legacy/CodePush/FileUtils.cs +0 -40
  162. package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
  163. package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
  164. package/windows-legacy/CodePush/UpdateManager.cs +0 -305
  165. package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
  166. package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
  167. package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
  168. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
  169. package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
  170. package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
  171. package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
  172. package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
  173. package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
  174. package/windows-legacy/CodePush.Net46/packages.config +0 -5
  175. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
  176. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
  177. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
  178. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
  179. package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
  180. package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
  181. package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
  182. package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
  183. package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
  184. package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
  185. package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
  186. package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
  187. package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
  188. package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
  189. package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
  190. package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
  191. package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
@@ -1,252 +0,0 @@
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
@@ -1,47 +0,0 @@
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
@@ -1,69 +0,0 @@
1
- //
2
- // JWTAlgorithm.h
3
- // JWT
4
- //
5
- // Created by Klaas Pieter Annema on 31-05-13.
6
- // Copyright (c) 2013 Karma. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import "JWTDeprecations.h"
11
-
12
- @protocol JWTAlgorithm <NSObject>
13
-
14
- @required
15
- /**
16
- Signs data using provided secret data.
17
- @param hash The data to sign.
18
- @param key The secret to use for signing.
19
- @param error The inout error.
20
- */
21
- - (NSData *)signHash:(NSData *)hash key:(NSData *)key error:(NSError *__autoreleasing*)error;
22
- /**
23
- Verifies data using.
24
- @param hash The data to sign.
25
- @param signature The secret to use for signing.
26
- @param error The inout error.
27
- */
28
- - (BOOL)verifyHash:(NSData *)hash signature:(NSData *)signature key:(NSData *)key error:(NSError *__autoreleasing*)error;
29
-
30
- //@required
31
-
32
- @property (nonatomic, readonly, copy) NSString *name;
33
-
34
- /**
35
- Encodes and encrypts the provided payload using the provided secret key
36
- @param theString The string to encode
37
- @param theSecret The secret to use for encryption
38
- @return An NSData object containing the encrypted payload, or nil if something went wrong.
39
- */
40
- - (NSData *)encodePayload:(NSString *)theString withSecret:(NSString *)theSecret __deprecated_and_will_be_removed_in_release_version(JWTVersion_3_0_0);
41
-
42
- /**
43
- Verifies the provided signature using the signed input and verification key
44
- @param input The header and payload encoded string
45
- @param signature The JWT provided signature
46
- @param verificationKey The key to use for verifying the signature
47
- @return YES if the provided signature is valid, NO otherwise
48
- */
49
- - (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKey:(NSString *)verificationKey __deprecated_and_will_be_removed_in_release_version(JWTVersion_3_0_0);
50
-
51
- @optional
52
-
53
- /**
54
- Encodes and encrypts the provided payload using the provided secret key
55
- @param theStringData The data to encode
56
- @param theSecretData The secret data to use for encryption
57
- @return An NSData object containing the encrypted payload, or nil if something went wrong.
58
- */
59
- - (NSData *)encodePayloadData:(NSData *)theStringData withSecret:(NSData *)theSecretData;
60
-
61
- /**
62
- Verifies the provided signature using the signed input and verification key (as data)
63
- @param input The header and payload encoded string
64
- @param signature The JWT provided signature
65
- @param verificationKeyData The key data to use for verifying the signature
66
- @return YES if the provided signature is valid, NO otherwise
67
- */
68
- - (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKeyData:(NSData *)verificationKeyData;
69
- @end
@@ -1,16 +0,0 @@
1
- //
2
- // JWTAlgorithmFactory.h
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 07.10.15.
6
- // Copyright © 2015 Karma. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import "JWTAlgorithm.h"
11
- @interface JWTAlgorithmFactory : NSObject
12
-
13
- + (NSArray *)algorithms;
14
- + (id<JWTAlgorithm>)algorithmByName:(NSString *)name;
15
-
16
- @end
@@ -1,51 +0,0 @@
1
- //
2
- // JWTAlgorithmFactory.m
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 07.10.15.
6
- // Copyright © 2015 Karma. All rights reserved.
7
- //
8
-
9
- #import "JWTAlgorithmFactory.h"
10
- #import "JWTAlgorithmHSBase.h"
11
- #import "JWTAlgorithmRSBase.h"
12
- #import "JWTAlgorithmNone.h"
13
-
14
- // not implemented.
15
- NSString *const JWTAlgorithmNameES256 = @"ES256";
16
- NSString *const JWTAlgorithmNameES384 = @"ES384";
17
- NSString *const JWTAlgorithmNameES512 = @"ES512";
18
-
19
- @implementation JWTAlgorithmFactory
20
-
21
- + (NSArray *)algorithms {
22
- return @[
23
- [JWTAlgorithmNone new],
24
- [JWTAlgorithmHSBase algorithm256],
25
- [JWTAlgorithmHSBase algorithm384],
26
- [JWTAlgorithmHSBase algorithm512],
27
- [JWTAlgorithmRSBase algorithm256],
28
- [JWTAlgorithmRSBase algorithm384],
29
- [JWTAlgorithmRSBase algorithm512]
30
- ];
31
-
32
- }
33
-
34
- + (id<JWTAlgorithm>)algorithmByName:(NSString *)name {
35
- id<JWTAlgorithm> algorithm = nil;
36
-
37
- NSString *algName = [name copy];
38
-
39
- NSUInteger index = [[self algorithms] indexOfObjectPassingTest:^BOOL(id<JWTAlgorithm> obj, NSUInteger idx, BOOL *stop) {
40
- // lowercase comparison
41
- return [obj.name.lowercaseString isEqualToString:algName.lowercaseString];
42
- }];
43
-
44
- if (index != NSNotFound) {
45
- algorithm = [self algorithms][index];
46
- }
47
-
48
- return algorithm;
49
- }
50
-
51
- @end
@@ -1,15 +0,0 @@
1
- //
2
- // JWTAlgorithmNone.h
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 16.10.15.
6
- // Copyright © 2015 Karma. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import "JWTAlgorithm.h"
11
- extern NSString *const JWTAlgorithmNameNone;
12
-
13
- @interface JWTAlgorithmNone : NSObject <JWTAlgorithm>
14
-
15
- @end
@@ -1,55 +0,0 @@
1
- //
2
- // JWTAlgorithmNone.m
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 16.10.15.
6
- // Copyright © 2015 Karma. All rights reserved.
7
- //
8
-
9
- #import "JWTAlgorithmNone.h"
10
- NSString *const JWTAlgorithmNameNone = @"none";
11
-
12
- @implementation JWTAlgorithmNone
13
-
14
- - (NSString *)name {
15
- return JWTAlgorithmNameNone;
16
- }
17
-
18
- - (NSData *)signHash:(NSData *)hash key:(NSData *)key error:(NSError *__autoreleasing *)error {
19
- return [NSData data];
20
- }
21
-
22
- - (BOOL)verifyHash:(NSData *)hash signature:(NSData *)signature key:(NSData *)key error:(NSError *__autoreleasing *)error {
23
- //if a secret is provided, this isn't the None algorithm
24
- if (key && key.length > 0) {
25
- return NO;
26
- }
27
-
28
- //If the signature isn't blank, this isn't the None algorithm
29
- if (signature && signature.length > 0) {
30
- return NO;
31
- }
32
-
33
- return YES;
34
- }
35
-
36
- - (NSData *)encodePayload:(NSString *)theString withSecret:(NSString *)theSecret {
37
- return [self encodePayloadData:[theSecret dataUsingEncoding:NSUTF8StringEncoding] withSecret:[theSecret dataUsingEncoding:NSUTF8StringEncoding]];
38
- }
39
-
40
- - (NSData *)encodePayloadData:(NSData *)theStringData withSecret:(NSData *)theSecretData
41
- {
42
- return [self signHash:theStringData key:theSecretData error:nil];
43
- }
44
-
45
- - (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKey:(NSString *)verificationKey
46
- {
47
- return [self verifySignedInput:input withSignature:signature verificationKeyData:verificationKey];
48
- }
49
-
50
- - (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKeyData:(NSData *)verificationKeyData
51
- {
52
- return [self verifyHash:[input dataUsingEncoding:NSUTF8StringEncoding] signature:[signature dataUsingEncoding:NSUTF8StringEncoding] key:verificationKeyData error:nil];
53
- }
54
-
55
- @end
@@ -1,24 +0,0 @@
1
- //
2
- // JWTAlgorithmESBase.h
3
- // Pods
4
- //
5
- // Created by Lobanov Dmitry on 12.02.17.
6
- //
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import "JWTRSAlgorithm.h"
11
- extern NSString *const JWTAlgorithmNameES256;
12
- extern NSString *const JWTAlgorithmNameES384;
13
- extern NSString *const JWTAlgorithmNameES512;
14
- @interface JWTAlgorithmESBase : NSObject @end
15
-
16
- @interface JWTAlgorithmESBase (JWTAsymmetricKeysAlgorithm) <JWTAsymmetricKeysAlgorithm> @end
17
-
18
- @interface JWTAlgorithmESBase (Create)
19
-
20
- + (instancetype)algorithm256;
21
- + (instancetype)algorithm384;
22
- + (instancetype)algorithm512;
23
-
24
- @end
@@ -1,41 +0,0 @@
1
- //
2
- // JWTAlgorithmESBase.m
3
- // Pods
4
- //
5
- // Created by Lobanov Dmitry on 12.02.17.
6
- //
7
- //
8
-
9
- #import "JWTAlgorithmESBase.h"
10
- #import <CommonCrypto/CommonCryptor.h>
11
- @interface JWTAlgorithmESBase ()
12
-
13
- @end
14
- @implementation JWTAlgorithmESBase
15
- @synthesize keyExtractorType;
16
- @synthesize signKey;
17
- @synthesize verifyKey;
18
- @end
19
-
20
- // thanks! https://github.com/soyersoyer/SwCrypt
21
- @interface JWTAlgorithmESBase (ImportKeys)
22
- - (void)importKey;
23
- //importKey(publicKey, format: .importKeyBinary, keyType: .keyPublic)
24
- @end
25
- @implementation JWTAlgorithmESBase (ImportKeys)
26
- - (void)importKey {
27
- return;
28
- }
29
- @end
30
-
31
- @implementation JWTAlgorithmESBase (JWTAsymmetricKeysAlgorithm)
32
- - (NSString *)name {
33
- return @"ESBase";
34
- }
35
- - (NSData *)signHash:(NSData *)hash key:(NSData *)key error:(NSError *__autoreleasing *)error {
36
- return nil;
37
- }
38
- - (BOOL)verifyHash:(NSData *)hash signature:(NSData *)signature key:(NSData *)key error:(NSError *__autoreleasing *)error {
39
- return NO;
40
- }
41
- @end
@@ -1,28 +0,0 @@
1
- //
2
- // JWTAlgorithmHSBase.h
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 13.03.16.
6
- // Copyright © 2016 Karma. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import "JWTAlgorithm.h"
11
- extern NSString *const JWTAlgorithmNameHS256;
12
- extern NSString *const JWTAlgorithmNameHS384;
13
- extern NSString *const JWTAlgorithmNameHS512;
14
-
15
- @interface JWTAlgorithmHSBase : NSObject <JWTAlgorithm>
16
-
17
- @property (assign, nonatomic, readonly) size_t ccSHANumberDigestLength;
18
- @property (assign, nonatomic, readonly) uint32_t ccHmacAlgSHANumber;
19
-
20
- @end
21
-
22
- @interface JWTAlgorithmHSBase (Create)
23
-
24
- + (instancetype)algorithm256;
25
- + (instancetype)algorithm384;
26
- + (instancetype)algorithm512;
27
-
28
- @end