@algocare/react-native-code-push 12.6.3 → 13.0.0-rc.0

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 (292) hide show
  1. package/CodePush.podspec +6 -8
  2. package/README.md +343 -586
  3. package/android/app/build.gradle +2 -1
  4. package/android/app/proguard-rules.pro +14 -0
  5. package/android/app/src/debug/AndroidManifest.xml +9 -0
  6. package/android/app/src/main/AndroidManifest.xml +1 -2
  7. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -139
  8. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +0 -3
  9. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +108 -63
  10. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +2 -33
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +13 -109
  12. package/android/build.gradle +3 -0
  13. package/app.plugin.js +1 -0
  14. package/bin/code-push.js +6 -0
  15. package/cli/commands/bundleCommand/bundleCodePush.ts +118 -0
  16. package/cli/commands/bundleCommand/index.ts +34 -0
  17. package/cli/commands/createHistoryCommand/createReleaseHistory.ts +37 -0
  18. package/cli/commands/createHistoryCommand/createReleaseHistoryList.ts +40 -0
  19. package/cli/commands/createHistoryCommand/index.ts +44 -0
  20. package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.ts +33 -0
  21. package/cli/commands/createPullRequestHistoryCommand/index.ts +31 -0
  22. package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.ts +71 -0
  23. package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.ts +75 -0
  24. package/cli/commands/createPullRequestReleaseCommand/index.ts +74 -0
  25. package/cli/commands/getPackageHashCommand/index.ts +45 -0
  26. package/cli/commands/initCommand/index.ts +14 -0
  27. package/cli/commands/initCommand/initAndroid.ts +91 -0
  28. package/cli/commands/initCommand/initIos.ts +123 -0
  29. package/cli/commands/initCommand/test/initAndroid.test.ts +128 -0
  30. package/cli/commands/initCommand/test/initIos.test.ts +99 -0
  31. package/cli/commands/releaseCommand/addToReleaseHistory.ts +57 -0
  32. package/cli/commands/releaseCommand/index.ts +90 -0
  33. package/cli/commands/releaseCommand/release.ts +105 -0
  34. package/cli/commands/removePullRequestHistoryCommand/index.ts +37 -0
  35. package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.ts +28 -0
  36. package/cli/commands/showHistoryCommand/index.ts +31 -0
  37. package/cli/commands/updateHistoryCommand/index.ts +55 -0
  38. package/cli/commands/updateHistoryCommand/updateReleaseHistory.ts +42 -0
  39. package/cli/constant.ts +4 -0
  40. package/cli/dist/commands/bundleCommand/bundleCodePush.js +65 -0
  41. package/cli/dist/commands/bundleCommand/index.js +15 -0
  42. package/cli/dist/commands/createHistoryCommand/createReleaseHistory.js +25 -0
  43. package/cli/dist/commands/createHistoryCommand/createReleaseHistoryList.js +27 -0
  44. package/cli/dist/commands/createHistoryCommand/index.js +20 -0
  45. package/cli/dist/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +23 -0
  46. package/cli/dist/commands/createPullRequestHistoryCommand/index.js +15 -0
  47. package/cli/dist/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +51 -0
  48. package/cli/dist/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +39 -0
  49. package/cli/dist/commands/createPullRequestReleaseCommand/index.js +35 -0
  50. package/cli/dist/commands/getPackageHashCommand/index.js +26 -0
  51. package/cli/dist/commands/initCommand/index.js +12 -0
  52. package/cli/dist/commands/initCommand/initAndroid.js +73 -0
  53. package/cli/dist/commands/initCommand/initIos.js +108 -0
  54. package/cli/dist/commands/initCommand/test/initAndroid.test.js +113 -0
  55. package/cli/dist/commands/initCommand/test/initIos.test.js +95 -0
  56. package/cli/dist/commands/releaseCommand/addToReleaseHistory.js +35 -0
  57. package/cli/dist/commands/releaseCommand/index.js +45 -0
  58. package/cli/dist/commands/releaseCommand/release.js +62 -0
  59. package/cli/dist/commands/removePullRequestHistoryCommand/index.js +19 -0
  60. package/cli/dist/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +18 -0
  61. package/cli/dist/commands/showHistoryCommand/index.js +15 -0
  62. package/cli/dist/commands/updateHistoryCommand/index.js +31 -0
  63. package/cli/dist/commands/updateHistoryCommand/updateReleaseHistory.js +28 -0
  64. package/cli/dist/constant.js +4 -0
  65. package/cli/dist/functions/getReactTempDir.js +10 -0
  66. package/cli/{functions → dist/functions}/makeCodePushBundle.js +5 -11
  67. package/cli/{functions → dist/functions}/prepareToBundleJS.js +2 -5
  68. package/cli/dist/functions/runExpoBundleCommand.js +35 -0
  69. package/cli/{functions → dist/functions}/runHermesEmitBinaryCommand.js +36 -71
  70. package/cli/{functions → dist/functions}/runReactNativeBundleCommand.js +19 -24
  71. package/cli/dist/index.js +54 -0
  72. package/cli/dist/utils/datetime.js +17 -0
  73. package/cli/dist/utils/file-utils.js +19 -0
  74. package/cli/dist/utils/fsUtils.js +44 -0
  75. package/cli/{utils → dist/utils}/hash-utils.js +19 -130
  76. package/cli/{utils → dist/utils}/promisfied-fs.js +5 -16
  77. package/cli/dist/utils/showLogo.js +21 -0
  78. package/cli/dist/utils/unzip.js +41 -0
  79. package/cli/{utils → dist/utils}/zip.js +15 -51
  80. package/cli/functions/{getReactTempDir.js → getReactTempDir.ts} +2 -6
  81. package/cli/functions/makeCodePushBundle.ts +26 -0
  82. package/cli/functions/prepareToBundleJS.ts +10 -0
  83. package/cli/functions/runExpoBundleCommand.ts +45 -0
  84. package/cli/functions/runHermesEmitBinaryCommand.ts +203 -0
  85. package/cli/functions/runReactNativeBundleCommand.ts +67 -0
  86. package/cli/index.ts +68 -0
  87. package/cli/package.json +35 -0
  88. package/cli/utils/datetime.ts +19 -0
  89. package/cli/utils/{file-utils.js → file-utils.ts} +4 -21
  90. package/cli/utils/fsUtils.ts +50 -0
  91. package/cli/utils/hash-utils.ts +143 -0
  92. package/cli/utils/promisfied-fs.ts +19 -0
  93. package/cli/utils/{showLogo.js → showLogo.ts} +4 -6
  94. package/cli/utils/unzip.ts +46 -0
  95. package/cli/utils/zip.ts +65 -0
  96. package/expo/plugin/withCodePush.js +14 -0
  97. package/expo/plugin/withCodePushAndroid.js +92 -0
  98. package/expo/plugin/withCodePushIos.js +143 -0
  99. package/ios/CodePush/CodePush.h +0 -16
  100. package/ios/CodePush/CodePush.m +30 -20
  101. package/ios/CodePush/CodePushConfig.m +1 -11
  102. package/ios/CodePush/CodePushPackage.m +12 -69
  103. package/ios/CodePush/CodePushUpdateUtils.m +1 -91
  104. package/ios/CodePush/SSZipArchive/Info.plist +26 -0
  105. package/ios/CodePush/SSZipArchive/README.md +1 -1
  106. package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
  107. package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
  108. package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
  109. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
  110. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
  111. package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
  112. package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
  113. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
  114. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
  115. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
  116. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
  117. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
  118. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
  119. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
  120. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
  121. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
  122. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
  123. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
  124. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
  125. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
  126. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
  127. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
  128. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
  129. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
  130. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
  131. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
  132. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
  133. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
  134. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
  135. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
  136. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
  137. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
  138. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
  139. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
  141. package/ios/CodePush.xcodeproj/project.pbxproj +244 -453
  142. package/ios/PrivacyInfo.xcprivacy +31 -0
  143. package/package.json +67 -41
  144. package/react-native.config.js +1 -1
  145. package/{AlertAdapter.js → src/AlertAdapter.js} +5 -5
  146. package/src/CodePush.js +947 -0
  147. package/{package-mixins.js → src/package-mixins.js} +1 -1
  148. package/{versioning → src/versioning}/BaseVersioning.js +12 -1
  149. package/{versioning → src/versioning}/SemverVersioning.test.js +78 -0
  150. package/typings/react-native-code-push.d.ts +559 -495
  151. package/CONTRIBUTING.md +0 -134
  152. package/CodePush.js +0 -972
  153. package/SECURITY.md +0 -41
  154. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
  155. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -12
  156. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +0 -17
  157. package/android/codepush.gradle +0 -162
  158. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  159. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  160. package/android/gradlew +0 -164
  161. package/android/gradlew.bat +0 -90
  162. package/babel.config.js +0 -3
  163. package/cli/commands/bundleCommand/bundleCodePush.js +0 -57
  164. package/cli/commands/bundleCommand/index.js +0 -55
  165. package/cli/commands/common.js +0 -245
  166. package/cli/commands/createHistoryCommand/createReleaseHistory.js +0 -42
  167. package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +0 -52
  168. package/cli/commands/createHistoryCommand/index.js +0 -95
  169. package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +0 -34
  170. package/cli/commands/createPullRequestHistoryCommand/index.js +0 -29
  171. package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +0 -74
  172. package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +0 -91
  173. package/cli/commands/createPullRequestReleaseCommand/index.js +0 -68
  174. package/cli/commands/getPackageHashCommand/index.js +0 -42
  175. package/cli/commands/releaseCommand/addToReleaseHistory.js +0 -85
  176. package/cli/commands/releaseCommand/index.js +0 -151
  177. package/cli/commands/releaseCommand/release.js +0 -121
  178. package/cli/commands/removePullRequestHistoryCommand/index.js +0 -28
  179. package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +0 -23
  180. package/cli/commands/showHistoryCommand/index.js +0 -88
  181. package/cli/commands/updateHistoryCommand/index.js +0 -123
  182. package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +0 -69
  183. package/cli/constant.js +0 -8
  184. package/cli/index.js +0 -63
  185. package/cli/utils/datetime.js +0 -22
  186. package/cli/utils/fsUtils.js +0 -64
  187. package/cli/utils/version.js +0 -26
  188. package/code-push.config.example.supabase.ts +0 -114
  189. package/code-push.config.js +0 -229
  190. package/code-push.config.ts +0 -175
  191. package/docs/api-android.md +0 -83
  192. package/docs/api-ios.md +0 -31
  193. package/docs/api-js.md +0 -592
  194. package/docs/multi-deployment-testing-android.md +0 -148
  195. package/docs/multi-deployment-testing-ios.md +0 -59
  196. package/docs/setup-android.md +0 -482
  197. package/docs/setup-ios.md +0 -280
  198. package/eslint.config.mjs +0 -32
  199. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
  200. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
  201. package/ios/CodePush/Base64/README.md +0 -47
  202. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
  203. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
  204. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
  205. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
  206. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
  207. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
  208. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
  209. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
  210. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
  211. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
  212. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
  213. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
  214. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
  215. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
  216. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
  217. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
  218. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
  219. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
  220. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
  221. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
  222. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
  223. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
  224. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
  225. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
  226. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
  227. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
  228. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
  229. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
  230. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
  231. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
  232. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
  233. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
  234. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
  235. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
  236. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
  237. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
  238. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
  239. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
  240. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
  241. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
  242. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
  243. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
  244. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
  245. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
  246. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
  247. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
  248. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
  249. package/ios/CodePush/JWT/LICENSE +0 -19
  250. package/ios/CodePush/JWT/README.md +0 -489
  251. package/ios/CodePush/SSZipArchive/Common.h +0 -81
  252. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
  253. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
  254. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
  255. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
  256. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
  257. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
  258. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
  259. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
  260. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
  261. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
  262. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
  263. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
  264. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
  265. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
  266. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
  267. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
  268. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
  269. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
  270. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
  271. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
  272. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
  273. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
  274. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
  275. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
  276. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
  277. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
  278. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
  279. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
  280. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
  281. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
  282. package/scripts/generateBundledResourcesHash.js +0 -125
  283. package/scripts/getFilesInFolder.js +0 -19
  284. package/scripts/recordFilesBeforeBundleCommand.js +0 -41
  285. package/tsconfig.json +0 -20
  286. package/tslint.json +0 -32
  287. /package/{logging.js → src/logging.js} +0 -0
  288. /package/{versioning → src/versioning}/BaseVersioning.test.js +0 -0
  289. /package/{versioning → src/versioning}/IncrementalVersioning.js +0 -0
  290. /package/{versioning → src/versioning}/IncrementalVersioning.test.js +0 -0
  291. /package/{versioning → src/versioning}/SemverVersioning.js +0 -0
  292. /package/{versioning → src/versioning}/index.js +0 -0
@@ -1,230 +0,0 @@
1
- //
2
- // JWTCryptoKey.m
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 04.02.17.
6
- // Copyright © 2017 JWTIO. All rights reserved.
7
- //
8
-
9
- #import "JWTCryptoKey.h"
10
- #import "JWTCryptoSecurity.h"
11
- #import "JWTBase64Coder.h"
12
- @interface JWTCryptoKeyBuilder()
13
- + (NSString *)keyTypeRSA;
14
- + (NSString *)keyTypeEC;
15
- @property (assign, nonatomic, readwrite) BOOL public;
16
- @property (assign, nonatomic, readwrite) NSString *keyType;
17
- @property (nonatomic, readonly) BOOL withKeyTypeRSA;
18
- @property (nonatomic, readonly) BOOL withKeyTypeEC;
19
- @end
20
- @implementation JWTCryptoKeyBuilder
21
- + (NSString *)keyTypeRSA {
22
- return @"RSA";
23
- }
24
- + (NSString *)keyTypeEC {
25
- return @"EC";
26
- }
27
- - (instancetype)keyTypeRSA {
28
- self.keyType = [self.class keyTypeRSA];
29
- return self;
30
- }
31
- - (instancetype)keyTypeEC {
32
- self.keyType = [self.class keyTypeEC];
33
- return self;
34
- }
35
- - (BOOL)withKeyTypeRSA {
36
- return [self.keyType isEqualToString:self.class.keyTypeRSA];
37
- }
38
- - (BOOL)withKeyTypeEC {
39
- return [self.keyType isEqualToString:self.class.keyTypeEC];
40
- }
41
- @end
42
- @interface JWTCryptoKey ()
43
- @property (copy, nonatomic, readwrite) NSString *tag;
44
- @property (assign, nonatomic, readwrite) SecKeyRef key;
45
- @property (copy, nonatomic, readwrite) NSData *rawKey;
46
- @end
47
- @interface JWTCryptoKey (Class)
48
- + (NSString *)uniqueTag;
49
- @end
50
- @implementation JWTCryptoKey (Class)
51
- + (NSString *)uniqueTag {
52
- return [[NSUUID UUID].UUIDString stringByReplacingOccurrencesOfString:@"-" withString:@""].lowercaseString;
53
- }
54
- @end
55
- @implementation JWTCryptoKey (Parameters)
56
- + (NSString *)parametersKeyBuilder {
57
- return NSStringFromSelector(_cmd);
58
- }
59
- @end
60
- @interface JWTCryptoKey (ParametersExtraction)
61
- - (NSString *)extractedSecKeyTypeWithParameters:(NSDictionary *)parameters;
62
- - (JWTCryptoKeyBuilder *)extractedBuilderWithParameters:(NSDictionary *)parameters;
63
- @end
64
- // Consider that both methods in this category should return non-nullable values
65
- @implementation JWTCryptoKey (ParametersExtraction)
66
- // Parameters are nil at that moment, could be used later for some purposes
67
- - (JWTCryptoKeyBuilder *)extractedBuilderWithParameters:(NSDictionary *)parameters {
68
- return (JWTCryptoKeyBuilder *)parameters[[self.class parametersKeyBuilder]] ?: [JWTCryptoKeyBuilder new].keyTypeRSA;
69
- }
70
- // Parameters are nil at that moment, could be used later for some purposes
71
- - (NSString *)extractedSecKeyTypeWithParameters:(NSDictionary *)parameters {
72
- JWTCryptoKeyBuilder *builder = [self extractedBuilderWithParameters:parameters];
73
- NSString *result = nil;
74
- if (builder.withKeyTypeEC) {
75
- result = [JWTCryptoSecurity keyTypeEC];
76
- }
77
- return result ?: [JWTCryptoSecurity keyTypeRSA];
78
- }
79
- @end
80
- @implementation JWTCryptoKey
81
- - (instancetype)initWithData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
82
- return [super init];
83
- }
84
- - (instancetype)initWithBase64String:(NSString *)base64String parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
85
- return [self initWithData:[JWTBase64Coder dataWithBase64UrlEncodedString:base64String] parameters:parameters error:error];
86
- }
87
- - (instancetype)initWithPemEncoded:(NSString *)encoded parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
88
- //TODO: check correctness.
89
- //maybe use clean initWithBase64String and remove ?: encoded tail.
90
- NSString *clean = [JWTCryptoSecurity keyFromPemFileContent:encoded] ?: encoded;//[JWTCryptoSecurity stringByRemovingPemHeadersFromString:encoded];
91
- return [self initWithBase64String:clean parameters:parameters error:error];
92
- }
93
- - (instancetype)initWithPemAtURL:(NSURL *)url parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
94
- // contents of url
95
- NSError *contentsExtractingError = nil;
96
- NSString *pemEncoded = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&contentsExtractingError];
97
- if (error && contentsExtractingError) {
98
- *error = contentsExtractingError;
99
- return nil;
100
- }
101
- return [self initWithPemEncoded:pemEncoded parameters:parameters error:error];
102
- }
103
- @end
104
- @implementation JWTCryptoKeyPublic
105
- - (instancetype)initWithData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
106
- self = [super initWithData:data parameters:parameters error:error];
107
- if (self) {
108
- self.tag = [self.class uniqueTag];
109
-
110
- if (!data) {
111
- return nil;
112
- }
113
-
114
- NSError *removingHeaderError = nil;
115
- // asks builder
116
-
117
- JWTCryptoKeyBuilder *builder = [self extractedBuilderWithParameters:parameters];
118
- NSData *keyData = data;
119
- if (builder.withKeyTypeRSA) {
120
- keyData = [JWTCryptoSecurity dataByRemovingPublicKeyHeader:data error:&removingHeaderError];
121
- if (!keyData || removingHeaderError) {
122
- if (error && removingHeaderError != nil) {
123
- *error = removingHeaderError;
124
- }
125
- return nil;
126
- }
127
- }
128
-
129
- if (builder.withKeyTypeEC) {
130
- // unknown here.
131
- // process keyData before passing it to JWTCryptoSecurity+addKey... method.
132
- }
133
-
134
- NSError *addKeyError = nil;
135
-
136
- self.key = [JWTCryptoSecurity addKeyWithData:keyData asPublic:YES tag:self.tag type:[self extractedSecKeyTypeWithParameters:parameters] error:&addKeyError];
137
- if (!self.key || addKeyError) {
138
- if (error && addKeyError != nil) {
139
- *error = removingHeaderError;
140
- }
141
- return nil;
142
- }
143
- }
144
- return self;
145
- }
146
- - (instancetype)initWithCertificateData:(NSData *)certificateData parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
147
- SecKeyRef key = [JWTCryptoSecurity publicKeyFromCertificate:certificateData];
148
- if (!key) {
149
- // error: Public certificate incorrect.
150
- return nil;
151
- }
152
-
153
- if (self = [super init]) {
154
- self.key = key;
155
- }
156
-
157
- return self;
158
- }
159
- - (instancetype)initWithCertificateBase64String:(NSString *)certificate parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
160
- // cleanup certificate if needed.
161
- // call initWithCertificateData:(NSData *)certificateData
162
- NSData *certificateData = nil;
163
- return [self initWithCertificateData:certificateData parameters:parameters error:error];
164
- }
165
- @end
166
-
167
- @implementation JWTCryptoKeyPrivate
168
- - (instancetype)initWithData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
169
- self = [super initWithData:data parameters:parameters error:error];
170
- if (self) {
171
- self.tag = [self.class uniqueTag];
172
- NSError *addKeyError = nil;
173
- if (!data) {
174
- // error: no data?
175
- // or put it in superclass?
176
- return nil;
177
- }
178
- self.key = [JWTCryptoSecurity addKeyWithData:data asPublic:NO tag:self.tag type:[self extractedSecKeyTypeWithParameters:parameters] error:&addKeyError];
179
- if (!self.key || addKeyError) {
180
- if (error && addKeyError) {
181
- *error = addKeyError;
182
- }
183
- return nil;
184
- }
185
- }
186
- return self;
187
- }
188
- // Exists
189
- - (instancetype)initWithP12AtURL:(NSURL *)url withPassphrase:(NSString *)passphrase parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
190
- // take data.
191
- // cleanup if needed.
192
- NSData *data = [NSData dataWithContentsOfURL:url];
193
- return [self initWithP12Data:data withPassphrase:passphrase parameters:parameters error:error];
194
- }
195
- - (instancetype)initWithP12Data:(NSData *)p12Data withPassphrase:(NSString *)passphrase parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error {
196
- if (p12Data == nil) {
197
- return nil;
198
- }
199
-
200
- // cleanup if needed.
201
- SecIdentityRef identity = nil;
202
- SecTrustRef trust = nil;
203
- [JWTCryptoSecurity extractIdentityAndTrustFromPKCS12:(__bridge CFDataRef)p12Data password:(__bridge CFStringRef)passphrase identity:&identity trust:&trust];
204
- BOOL identityAndTrust = identity && trust;
205
-
206
- if (identityAndTrust) {
207
- self = [super init];
208
- SecKeyRef privateKey;
209
- SecIdentityCopyPrivateKey(identity, &privateKey);
210
- if (self) {
211
- self.key = privateKey;
212
- }
213
- }
214
-
215
- if (identity) {
216
- CFRelease(identity);
217
- }
218
-
219
- if (trust) {
220
- CFRelease(trust);
221
- }
222
-
223
- if (!identityAndTrust) {
224
- //error: no identity and trust.
225
- return nil;
226
- }
227
-
228
- return self;
229
- }
230
- @end
@@ -1,31 +0,0 @@
1
- //
2
- // JWTCryptoKeyExtractor.h
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 04.02.17.
6
- // Copyright © 2017 JWTIO. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import <Security/Security.h>
11
-
12
- @protocol JWTCryptoKeyProtocol;
13
- @protocol JWTCryptoKeyExtractorProtocol <NSObject>
14
- @optional
15
- - (id<JWTCryptoKeyProtocol>)keyFromString:(NSString *)string parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error;
16
- - (id<JWTCryptoKeyProtocol>)keyFromData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing*)error;
17
- @end
18
-
19
- @interface JWTCryptoKeyExtractor : NSObject <JWTCryptoKeyExtractorProtocol>
20
- @property (copy, nonatomic, readonly) NSString *type;
21
- + (NSString *)type;
22
- + (NSString *)parametersKeyCertificatePassphrase;
23
- @end
24
-
25
- @interface JWTCryptoKeyExtractor (ClassCluster)
26
- + (instancetype)publicKeyWithCertificate;
27
- + (instancetype)privateKeyInP12;
28
- + (instancetype)publicKeyWithPEMBase64;
29
- + (instancetype)privateKeyWithPEMBase64;
30
- + (instancetype)createWithType:(NSString *)type;
31
- @end
@@ -1,113 +0,0 @@
1
- //
2
- // JWTCryptoKeyExtractor.m
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 04.02.17.
6
- // Copyright © 2017 JWTIO. All rights reserved.
7
- //
8
-
9
- #import "JWTCryptoKeyExtractor.h"
10
- #import "JWTCryptoKey.h"
11
- #import "JWTBase64Coder.h"
12
-
13
- @implementation JWTCryptoKeyExtractor
14
- - (NSString *)type {
15
- return self.class.type;
16
- }
17
- + (NSString *)type {
18
- return NSStringFromClass(self);
19
- }
20
- + (NSString *)parametersKeyCertificatePassphrase {
21
- return NSStringFromSelector(_cmd);
22
- }
23
- - (id<JWTCryptoKeyProtocol>)keyFromData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
24
- #pragma message "Not Implemented"
25
- if (error) {
26
- *error = [NSError errorWithDomain:@"io.jwt.crypto.rsa" code:-100 userInfo:@{
27
- NSLocalizedDescriptionKey : @"Method not implemented"
28
- }];
29
- }
30
- return nil;
31
- }
32
- - (id<JWTCryptoKeyProtocol>)keyFromString:(NSString *)string parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
33
- if (error) {
34
- *error = [NSError errorWithDomain:@"io.jwt.crypto.rsa" code:-100 userInfo:@{
35
- NSLocalizedDescriptionKey : @"Method not implemented"
36
- }];
37
- }
38
- return nil;
39
- }
40
- @end
41
-
42
- @interface JWTCryptoKeyExtractor_Public_Pem_Certificate : JWTCryptoKeyExtractor @end
43
-
44
- @implementation JWTCryptoKeyExtractor_Public_Pem_Certificate
45
- - (id<JWTCryptoKeyProtocol>)keyFromData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
46
- return [[JWTCryptoKeyPublic alloc] initWithCertificateData:data parameters:parameters error:error];
47
- }
48
- @end
49
-
50
- @interface JWTCryptoKeyExtractor_Private_P12 : JWTCryptoKeyExtractor @end
51
-
52
- @implementation JWTCryptoKeyExtractor_Private_P12
53
- - (id<JWTCryptoKeyProtocol>)keyFromData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
54
- NSString *certificatePassphrase = parameters[self.class.parametersKeyCertificatePassphrase];
55
- if ([certificatePassphrase isEqual:[NSNull null]]) {
56
- certificatePassphrase = nil;
57
- }
58
- return [[JWTCryptoKeyPrivate alloc] initWithP12Data:data withPassphrase:certificatePassphrase parameters:parameters error:error];
59
- }
60
- @end
61
-
62
- @interface JWTCryptoKeyExtractor_Public_Pem_Key : JWTCryptoKeyExtractor @end
63
-
64
- @implementation JWTCryptoKeyExtractor_Public_Pem_Key
65
- - (id<JWTCryptoKeyProtocol>)keyFromData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
66
- return [self keyFromString:[JWTBase64Coder base64UrlEncodedStringWithData:data] parameters:parameters error:error];
67
- }
68
- - (id<JWTCryptoKeyProtocol>)keyFromString:(NSString *)string parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
69
- return [[JWTCryptoKeyPublic alloc] initWithPemEncoded:string parameters:parameters error:error];
70
- }
71
- @end
72
-
73
- @interface JWTCryptoKeyExtractor_Private_Pem_Key : JWTCryptoKeyExtractor @end
74
-
75
- @implementation JWTCryptoKeyExtractor_Private_Pem_Key
76
- - (id<JWTCryptoKeyProtocol>)keyFromData:(NSData *)data parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
77
- return [self keyFromString:[JWTBase64Coder base64UrlEncodedStringWithData:data] parameters:parameters error:error];
78
- }
79
- - (id<JWTCryptoKeyProtocol>)keyFromString:(NSString *)string parameters:(NSDictionary *)parameters error:(NSError *__autoreleasing *)error {
80
- return [[JWTCryptoKeyPrivate alloc] initWithPemEncoded:string parameters:parameters error:error];
81
- }
82
- @end
83
-
84
- @implementation JWTCryptoKeyExtractor (ClassCluster)
85
- + (instancetype)publicKeyWithCertificate {
86
- return [JWTCryptoKeyExtractor_Public_Pem_Certificate new];
87
- }
88
- + (instancetype)privateKeyInP12 {
89
- return [JWTCryptoKeyExtractor_Private_P12 new];
90
- }
91
- + (instancetype)publicKeyWithPEMBase64 {
92
- return [JWTCryptoKeyExtractor_Public_Pem_Key new];
93
- }
94
- + (instancetype)privateKeyWithPEMBase64 {
95
- return [JWTCryptoKeyExtractor_Private_Pem_Key new];
96
- }
97
- + (NSArray *)availableExtractors {
98
- return @[
99
- [self publicKeyWithCertificate],
100
- [self privateKeyInP12],
101
- [self publicKeyWithPEMBase64],
102
- [self privateKeyWithPEMBase64]
103
- ];
104
- }
105
- + (NSDictionary *)typesAndExtractors {
106
- static NSDictionary *dictionary = nil;
107
- return dictionary ?: (dictionary = [[NSDictionary alloc] initWithObjects:[self availableExtractors] forKeys:[[self availableExtractors] valueForKey:@"type"]],
108
- dictionary);
109
- }
110
- + (instancetype)createWithType:(NSString *)type {
111
- return [self typesAndExtractors][type];
112
- }
113
- @end
@@ -1,38 +0,0 @@
1
- //
2
- // JWTCryptoSecurity.h
3
- // JWT
4
- //
5
- // Created by Lobanov Dmitry on 04.02.17.
6
- // Copyright © 2017 JWTIO. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import <Security/Security.h>
11
- // Thanks for https://github.com/TakeScoop/SwiftyRSA!
12
- @interface JWTCryptoSecurity : NSObject
13
- + (NSString *)keyTypeRSA;
14
- + (NSString *)keyTypeEC;
15
- + (SecKeyRef)addKeyWithData:(NSData *)data asPublic:(BOOL)public tag:(NSString *)tag type:(NSString *)type error:(NSError *__autoreleasing*)error;
16
- + (SecKeyRef)addKeyWithData:(NSData *)data asPublic:(BOOL)public tag:(NSString *)tag error:(NSError *__autoreleasing*)error;
17
- + (SecKeyRef)keyByTag:(NSString *)tag error:(NSError *__autoreleasing*)error;
18
- + (void)removeKeyByTag:(NSString *)tag error:(NSError *__autoreleasing*)error;
19
- @end
20
-
21
- @interface JWTCryptoSecurity (Certificates)
22
- + (OSStatus)extractIdentityAndTrustFromPKCS12:(CFDataRef)inPKCS12Data password:(CFStringRef)password identity:(SecIdentityRef *)outIdentity trust:(SecTrustRef *)outTrust;
23
- + (SecKeyRef)publicKeyFromCertificate:(NSData *)certificateData;
24
- @end
25
-
26
- @interface JWTCryptoSecurity (Pem)
27
- + (NSString *)certificateFromPemFileContent:(NSString *)content;
28
- + (NSString *)keyFromPemFileContent:(NSString *)content;
29
- + (NSArray *)itemsFromPemFileContent:(NSString *)content byRegex:(NSRegularExpression *)expression;
30
- + (NSString *)certificateFromPemFileWithName:(NSString *)name;
31
- + (NSString *)keyFromPemFileWithName:(NSString *)name;
32
- + (NSArray *)itemsFromPemFileWithName:(NSString *)name byRegex:(NSRegularExpression *)expression;
33
- + (NSString *)stringByRemovingPemHeadersFromString:(NSString *)string;
34
- @end
35
-
36
- @interface JWTCryptoSecurity (PublicKey)
37
- + (NSData *)dataByRemovingPublicKeyHeader:(NSData *)data error:(NSError *__autoreleasing*)error;
38
- @end