@bravemobile/react-native-code-push 11.0.0 → 12.0.0-beta.2
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.
- package/CodePush.podspec +5 -5
- package/android/app/build.gradle +2 -0
- package/android/app/src/debug/AndroidManifest.xml +1 -2
- package/android/app/src/main/AndroidManifest.xml +1 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +1 -22
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +0 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +0 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +15 -8
- package/android/build.gradle +3 -0
- package/expo/plugin/withCodePushAndroid.js +1 -22
- package/ios/CodePush/SSZipArchive/Info.plist +26 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -1
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
- package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
- package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
- package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
- package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
- package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +245 -130
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/package.json +1 -1
- package/android/codepush.gradle +0 -162
- package/ios/CodePush/SSZipArchive/Common.h +0 -81
- package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
- package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
- package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
- package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
- package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
- package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
- package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
- package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
- package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
- package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
- package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
- package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
- package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
package/CodePush.podspec
CHANGED
|
@@ -10,18 +10,18 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.homepage = package['homepage']
|
|
12
12
|
s.source = { :git => 'https://github.com/Soomgo-Mobile/react-native-code-push.git', :tag => "v#{s.version}"}
|
|
13
|
-
s.ios.deployment_target = '
|
|
14
|
-
s.tvos.deployment_target = '
|
|
13
|
+
s.ios.deployment_target = '15.5'
|
|
14
|
+
s.tvos.deployment_target = '15.5'
|
|
15
15
|
s.preserve_paths = '*.js'
|
|
16
16
|
s.library = 'z'
|
|
17
17
|
s.source_files = 'ios/CodePush/*.{h,m}'
|
|
18
18
|
s.public_header_files = ['ios/CodePush/CodePush.h']
|
|
19
19
|
|
|
20
|
-
# Note: Even though there are copy/pasted versions of some of these dependencies in the repo,
|
|
21
|
-
# we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and
|
|
20
|
+
# Note: Even though there are copy/pasted versions of some of these dependencies in the repo,
|
|
21
|
+
# we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and
|
|
22
22
|
# linked properly at a parent workspace level.
|
|
23
23
|
s.dependency 'React-Core'
|
|
24
|
-
s.dependency 'SSZipArchive', '~> 2.
|
|
24
|
+
s.dependency 'SSZipArchive', '~> 2.5.5'
|
|
25
25
|
s.dependency 'JWT', '~> 3.0.0-beta.12'
|
|
26
26
|
s.dependency 'Base64', '~> 1.1'
|
|
27
27
|
end
|
package/android/app/build.gradle
CHANGED
|
@@ -6,6 +6,8 @@ def DEFAULT_TARGET_SDK_VERSION = 26
|
|
|
6
6
|
def DEFAULT_MIN_SDK_VERSION = 16
|
|
7
7
|
|
|
8
8
|
android {
|
|
9
|
+
namespace "com.microsoft.codepush.react"
|
|
10
|
+
|
|
9
11
|
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
|
|
10
12
|
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
|
|
11
13
|
|
|
@@ -177,19 +177,6 @@ public class CodePush implements ReactPackage {
|
|
|
177
177
|
return mPublicKey;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
long getBinaryResourcesModifiedTime() {
|
|
181
|
-
try {
|
|
182
|
-
String packageName = this.mContext.getPackageName();
|
|
183
|
-
int codePushApkBuildTimeId = this.mContext.getResources().getIdentifier(CodePushConstants.CODE_PUSH_APK_BUILD_TIME_KEY, "string", packageName);
|
|
184
|
-
// replace double quotes needed for correct restoration of long value from strings.xml
|
|
185
|
-
// https://github.com/microsoft/cordova-plugin-code-push/issues/264
|
|
186
|
-
String codePushApkBuildTime = this.mContext.getResources().getString(codePushApkBuildTimeId).replaceAll("\"","");
|
|
187
|
-
return Long.parseLong(codePushApkBuildTime);
|
|
188
|
-
} catch (Exception e) {
|
|
189
|
-
throw new CodePushUnknownException("Error in getting binary resources modified time", e);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
180
|
public String getPackageFolder() {
|
|
194
181
|
JSONObject codePushLocalPackage = mUpdateManager.getCurrentPackage();
|
|
195
182
|
if (codePushLocalPackage == null) {
|
|
@@ -331,16 +318,8 @@ public class CodePush implements ReactPackage {
|
|
|
331
318
|
|
|
332
319
|
private boolean isPackageBundleLatest(JSONObject packageMetadata) {
|
|
333
320
|
try {
|
|
334
|
-
Long binaryModifiedDateDuringPackageInstall = null;
|
|
335
|
-
String binaryModifiedDateDuringPackageInstallString = packageMetadata.optString(CodePushConstants.BINARY_MODIFIED_TIME_KEY, null);
|
|
336
|
-
if (binaryModifiedDateDuringPackageInstallString != null) {
|
|
337
|
-
binaryModifiedDateDuringPackageInstall = Long.parseLong(binaryModifiedDateDuringPackageInstallString);
|
|
338
|
-
}
|
|
339
321
|
String packageAppVersion = packageMetadata.optString("appVersion", null);
|
|
340
|
-
|
|
341
|
-
return binaryModifiedDateDuringPackageInstall != null &&
|
|
342
|
-
binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
|
|
343
|
-
(isUsingTestConfiguration() || sAppVersion.equals(packageAppVersion));
|
|
322
|
+
return (isUsingTestConfiguration() || sAppVersion.equals(packageAppVersion));
|
|
344
323
|
} catch (NumberFormatException e) {
|
|
345
324
|
throw new CodePushUnknownException("Error in reading binary modified date from package metadata", e);
|
|
346
325
|
}
|
|
@@ -2,7 +2,6 @@ package com.microsoft.codepush.react;
|
|
|
2
2
|
|
|
3
3
|
public class CodePushConstants {
|
|
4
4
|
public static final String ASSETS_BUNDLE_PREFIX = "assets://";
|
|
5
|
-
public static final String BINARY_MODIFIED_TIME_KEY = "binaryModifiedTime";
|
|
6
5
|
public static final String CODE_PUSH_FOLDER_PREFIX = "CodePush";
|
|
7
6
|
public static final String CODE_PUSH_HASH_FILE_NAME = "CodePushHash";
|
|
8
7
|
public static final String CODE_PUSH_OLD_HASH_FILE_NAME = "CodePushHash.json";
|
|
@@ -25,7 +24,6 @@ public class CodePushConstants {
|
|
|
25
24
|
public static final String RELATIVE_BUNDLE_PATH_KEY = "bundlePath";
|
|
26
25
|
public static final String STATUS_FILE = "codepush.json";
|
|
27
26
|
public static final String UNZIPPED_FOLDER_NAME = "unzipped";
|
|
28
|
-
public static final String CODE_PUSH_APK_BUILD_TIME_KEY = "CODE_PUSH_APK_BUILD_TIME";
|
|
29
27
|
public static final String BUNDLE_JWT_FILE = ".codepushrelease";
|
|
30
28
|
public static final String LATEST_ROLLBACK_INFO_KEY = "LATEST_ROLLBACK_INFO";
|
|
31
29
|
public static final String LATEST_ROLLBACK_PACKAGE_HASH_KEY = "packageHash";
|
|
@@ -36,7 +36,6 @@ import org.json.JSONObject;
|
|
|
36
36
|
|
|
37
37
|
import java.io.IOException;
|
|
38
38
|
import java.lang.reflect.Field;
|
|
39
|
-
import java.lang.reflect.Method;
|
|
40
39
|
import java.util.ArrayList;
|
|
41
40
|
import java.util.Date;
|
|
42
41
|
import java.util.HashMap;
|
|
@@ -343,7 +342,6 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
343
342
|
protected Void doInBackground(Void... params) {
|
|
344
343
|
try {
|
|
345
344
|
JSONObject mutableUpdatePackage = CodePushUtils.convertReadableToJsonObject(updatePackage);
|
|
346
|
-
CodePushUtils.setJSONValueForKey(mutableUpdatePackage, CodePushConstants.BINARY_MODIFIED_TIME_KEY, "" + mCodePush.getBinaryResourcesModifiedTime());
|
|
347
345
|
mUpdateManager.downloadPackage(mutableUpdatePackage, mCodePush.getAssetsBundleFileName(), new DownloadProgressCallback() {
|
|
348
346
|
private boolean hasScheduledNextFrame = false;
|
|
349
347
|
private DownloadProgress latestDownloadProgress = null;
|
|
@@ -9,7 +9,6 @@ import com.nimbusds.jwt.SignedJWT;
|
|
|
9
9
|
|
|
10
10
|
import java.security.interfaces.*;
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
import org.json.JSONArray;
|
|
14
13
|
import org.json.JSONException;
|
|
15
14
|
import org.json.JSONObject;
|
|
@@ -86,8 +85,12 @@ public class CodePushUpdateUtils {
|
|
|
86
85
|
throw new CodePushUnknownException("Unable to compute hash of update contents.", e);
|
|
87
86
|
} finally {
|
|
88
87
|
try {
|
|
89
|
-
if (digestInputStream != null)
|
|
90
|
-
|
|
88
|
+
if (digestInputStream != null) {
|
|
89
|
+
digestInputStream.close();
|
|
90
|
+
}
|
|
91
|
+
if (dataStream != null) {
|
|
92
|
+
dataStream.close();
|
|
93
|
+
}
|
|
91
94
|
} catch (IOException e) {
|
|
92
95
|
e.printStackTrace();
|
|
93
96
|
}
|
|
@@ -98,7 +101,11 @@ public class CodePushUpdateUtils {
|
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
public static void copyNecessaryFilesFromCurrentPackage(String diffManifestFilePath, String currentPackageFolderPath, String newPackageFolderPath) throws IOException {
|
|
101
|
-
|
|
104
|
+
if (currentPackageFolderPath == null || !new File(currentPackageFolderPath).exists()) {
|
|
105
|
+
CodePushUtils.log("Unable to copy files from current package during diff update, because currentPackageFolderPath is invalid.");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
FileUtils.copyDirectoryContents(currentPackageFolderPath, newPackageFolderPath);
|
|
102
109
|
JSONObject diffManifest = CodePushUtils.getJsonObjectFromFile(diffManifestFilePath);
|
|
103
110
|
try {
|
|
104
111
|
JSONArray deletedFiles = diffManifest.getJSONArray("deletedFiles");
|
|
@@ -184,7 +191,7 @@ public class CodePushUpdateUtils {
|
|
|
184
191
|
public static Map<String, Object> verifyAndDecodeJWT(String jwt, PublicKey publicKey) {
|
|
185
192
|
try {
|
|
186
193
|
SignedJWT signedJWT = SignedJWT.parse(jwt);
|
|
187
|
-
JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey)publicKey);
|
|
194
|
+
JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey) publicKey);
|
|
188
195
|
if (signedJWT.verify(verifier)) {
|
|
189
196
|
Map<String, Object> claims = signedJWT.getJWTClaimsSet().getClaims();
|
|
190
197
|
CodePushUtils.log("JWT verification succeeded, payload content: " + claims.toString());
|
|
@@ -217,7 +224,7 @@ public class CodePushUpdateUtils {
|
|
|
217
224
|
}
|
|
218
225
|
}
|
|
219
226
|
|
|
220
|
-
public static String getSignatureFilePath(String updateFolderPath){
|
|
227
|
+
public static String getSignatureFilePath(String updateFolderPath) {
|
|
221
228
|
return CodePushUtils.appendPathComponent(
|
|
222
229
|
CodePushUtils.appendPathComponent(updateFolderPath, CodePushConstants.CODE_PUSH_FOLDER_PREFIX),
|
|
223
230
|
CodePushConstants.BUNDLE_JWT_FILE
|
|
@@ -254,7 +261,7 @@ public class CodePushUpdateUtils {
|
|
|
254
261
|
throw new CodePushInvalidUpdateException("The update could not be verified because it was not signed by a trusted party.");
|
|
255
262
|
}
|
|
256
263
|
|
|
257
|
-
final String contentHash = (String)claims.get("contentHash");
|
|
264
|
+
final String contentHash = (String) claims.get("contentHash");
|
|
258
265
|
if (contentHash == null) {
|
|
259
266
|
throw new CodePushInvalidUpdateException("The update could not be verified because the signature did not specify a content hash.");
|
|
260
267
|
}
|
|
@@ -265,4 +272,4 @@ public class CodePushUpdateUtils {
|
|
|
265
272
|
|
|
266
273
|
CodePushUtils.log("The update contents succeeded the code signing check.");
|
|
267
274
|
}
|
|
268
|
-
}
|
|
275
|
+
}
|
package/android/build.gradle
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
function androidApplyImplementation(appBuildGradle) {
|
|
4
|
-
const codePushImplementation = `apply from: "../../node_modules/@bravemobile/react-native-code-push/android/codepush.gradle"`;
|
|
5
|
-
|
|
6
|
-
if (!appBuildGradle.includes(codePushImplementation)) {
|
|
7
|
-
return `${appBuildGradle.trimEnd()}\n${codePushImplementation}\n`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return appBuildGradle;
|
|
11
|
-
}
|
|
1
|
+
const { withMainApplication, WarningAggregator } = require('expo/config-plugins');
|
|
12
2
|
|
|
13
3
|
function androidMainApplicationApplyImplementation(
|
|
14
4
|
mainApplication,
|
|
@@ -38,16 +28,6 @@ function androidMainApplicationApplyImplementation(
|
|
|
38
28
|
return mainApplication;
|
|
39
29
|
}
|
|
40
30
|
|
|
41
|
-
const withAndroidBuildScriptDependency = (config) => {
|
|
42
|
-
return withAppBuildGradle(config, (action) => {
|
|
43
|
-
action.modResults.contents = androidApplyImplementation(
|
|
44
|
-
action.modResults.contents,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
return action;
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
31
|
const withAndroidMainApplicationDependency = (config) => {
|
|
52
32
|
return withMainApplication(config, (action) => {
|
|
53
33
|
action.modResults.contents = androidMainApplicationApplyImplementation(
|
|
@@ -67,6 +47,5 @@ const withAndroidMainApplicationDependency = (config) => {
|
|
|
67
47
|
};
|
|
68
48
|
|
|
69
49
|
module.exports = {
|
|
70
|
-
withAndroidBuildScriptDependency,
|
|
71
50
|
withAndroidMainApplicationDependency,
|
|
72
51
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleSignature</key>
|
|
20
|
+
<string>????</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
23
|
+
<key>NSPrincipalClass</key>
|
|
24
|
+
<string></string>
|
|
25
|
+
</dict>
|
|
26
|
+
</plist>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
The source code in this folder is taken from [https://github.com/ZipArchive/ZipArchive/tree/
|
|
1
|
+
The source code in this folder is taken from [https://github.com/ZipArchive/ZipArchive/tree/2.5.5/SSZipArchive](https://github.com/ZipArchive/ZipArchive/tree/2.5.5/SSZipArchive) which is [MIT licensed](https://github.com/ZipArchive/ZipArchive/blob/2.5.5/LICENSE.txt).
|
|
@@ -3,56 +3,157 @@
|
|
|
3
3
|
// SSZipArchive
|
|
4
4
|
//
|
|
5
5
|
// Created by Sam Soffes on 7/21/10.
|
|
6
|
-
// Copyright (c) Sam Soffes 2010-2015. All rights reserved.
|
|
7
6
|
//
|
|
8
7
|
|
|
9
8
|
#ifndef _SSZIPARCHIVE_H
|
|
10
9
|
#define _SSZIPARCHIVE_H
|
|
11
10
|
|
|
12
11
|
#import <Foundation/Foundation.h>
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
#import "SSZipCommon.h"
|
|
14
|
+
|
|
15
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
16
|
+
|
|
17
|
+
extern NSString *const SSZipArchiveErrorDomain;
|
|
18
|
+
typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) {
|
|
19
|
+
SSZipArchiveErrorCodeFailedOpenZipFile = -1,
|
|
20
|
+
SSZipArchiveErrorCodeFailedOpenFileInZip = -2,
|
|
21
|
+
SSZipArchiveErrorCodeFileInfoNotLoadable = -3,
|
|
22
|
+
SSZipArchiveErrorCodeFileContentNotReadable = -4,
|
|
23
|
+
SSZipArchiveErrorCodeFailedToWriteFile = -5,
|
|
24
|
+
SSZipArchiveErrorCodeInvalidArguments = -6,
|
|
25
|
+
SSZipArchiveErrorCodeSymlinkEscapesTargetDirectory = -7,
|
|
26
|
+
};
|
|
14
27
|
|
|
15
28
|
@protocol SSZipArchiveDelegate;
|
|
16
29
|
|
|
17
30
|
@interface SSZipArchive : NSObject
|
|
18
31
|
|
|
32
|
+
// Password check
|
|
33
|
+
+ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path;
|
|
34
|
+
+ (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError * _Nullable * _Nullable)error NS_SWIFT_NOTHROW;
|
|
35
|
+
|
|
36
|
+
// Total payload size
|
|
37
|
+
+ (NSNumber *)payloadSizeForArchiveAtPath:(NSString *)path error:(NSError **)error;
|
|
38
|
+
|
|
19
39
|
// Unzip
|
|
20
40
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
|
|
21
|
-
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate;
|
|
41
|
+
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(nullable id<SSZipArchiveDelegate>)delegate;
|
|
42
|
+
|
|
43
|
+
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
44
|
+
toDestination:(NSString *)destination
|
|
45
|
+
overwrite:(BOOL)overwrite
|
|
46
|
+
password:(nullable NSString *)password
|
|
47
|
+
error:(NSError * *)error;
|
|
48
|
+
|
|
49
|
+
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
50
|
+
toDestination:(NSString *)destination
|
|
51
|
+
overwrite:(BOOL)overwrite
|
|
52
|
+
password:(nullable NSString *)password
|
|
53
|
+
error:(NSError * *)error
|
|
54
|
+
delegate:(nullable id<SSZipArchiveDelegate>)delegate NS_REFINED_FOR_SWIFT;
|
|
55
|
+
|
|
56
|
+
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
57
|
+
toDestination:(NSString *)destination
|
|
58
|
+
preserveAttributes:(BOOL)preserveAttributes
|
|
59
|
+
overwrite:(BOOL)overwrite
|
|
60
|
+
password:(nullable NSString *)password
|
|
61
|
+
error:(NSError * *)error
|
|
62
|
+
delegate:(nullable id<SSZipArchiveDelegate>)delegate;
|
|
63
|
+
|
|
64
|
+
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
65
|
+
toDestination:(NSString *)destination
|
|
66
|
+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
|
67
|
+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
|
|
22
68
|
|
|
23
|
-
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
24
|
-
|
|
69
|
+
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
70
|
+
toDestination:(NSString *)destination
|
|
71
|
+
overwrite:(BOOL)overwrite
|
|
72
|
+
password:(nullable NSString *)password
|
|
73
|
+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
|
74
|
+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
|
|
25
75
|
|
|
26
76
|
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
77
|
+
toDestination:(NSString *)destination
|
|
78
|
+
preserveAttributes:(BOOL)preserveAttributes
|
|
79
|
+
overwrite:(BOOL)overwrite
|
|
80
|
+
nestedZipLevel:(NSInteger)nestedZipLevel
|
|
81
|
+
password:(nullable NSString *)password
|
|
82
|
+
error:(NSError **)error
|
|
83
|
+
delegate:(nullable id<SSZipArchiveDelegate>)delegate
|
|
84
|
+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
|
85
|
+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
|
|
30
86
|
|
|
31
87
|
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
88
|
+
toDestination:(NSString *)destination
|
|
89
|
+
preserveAttributes:(BOOL)preserveAttributes
|
|
90
|
+
overwrite:(BOOL)overwrite
|
|
91
|
+
symlinksValidWithin:(nullable NSString *)symlinksValidWithin
|
|
92
|
+
nestedZipLevel:(NSInteger)nestedZipLevel
|
|
93
|
+
password:(nullable NSString *)password
|
|
94
|
+
error:(NSError **)error
|
|
95
|
+
delegate:(nullable id<SSZipArchiveDelegate>)delegate
|
|
96
|
+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
|
97
|
+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
|
|
37
98
|
|
|
38
99
|
// Zip
|
|
100
|
+
// default compression level is Z_DEFAULT_COMPRESSION (from "zlib.h")
|
|
101
|
+
// keepParentDirectory: if YES, then unzipping will give `directoryName/fileName`. If NO, then unzipping will just give `fileName`. Default is NO.
|
|
39
102
|
|
|
40
103
|
// without password
|
|
41
|
-
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths;
|
|
104
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths;
|
|
42
105
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
|
|
43
|
-
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirector;
|
|
44
106
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
107
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory;
|
|
108
|
+
|
|
109
|
+
// with optional password, default encryption is AES
|
|
110
|
+
// don't use AES if you need compatibility with native macOS unzip and Archive Utility
|
|
111
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password;
|
|
112
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
|
|
113
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password;
|
|
114
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password;
|
|
115
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path
|
|
116
|
+
withContentsOfDirectory:(NSString *)directoryPath
|
|
117
|
+
keepParentDirectory:(BOOL)keepParentDirectory
|
|
118
|
+
withPassword:(nullable NSString *)password
|
|
119
|
+
andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
|
|
120
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path
|
|
121
|
+
withContentsOfDirectory:(NSString *)directoryPath
|
|
122
|
+
keepParentDirectory:(BOOL)keepParentDirectory
|
|
123
|
+
compressionLevel:(int)compressionLevel
|
|
124
|
+
password:(nullable NSString *)password
|
|
125
|
+
AES:(BOOL)aes
|
|
126
|
+
progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
|
|
127
|
+
//suport symlink compress --file
|
|
128
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password keepSymlinks:(BOOL)keeplinks;
|
|
129
|
+
//suport symlink compress --directory
|
|
130
|
+
+ (BOOL)createZipFileAtPath:(NSString *)path
|
|
131
|
+
withContentsOfDirectory:(NSString *)directoryPath
|
|
132
|
+
keepParentDirectory:(BOOL)keepParentDirectory
|
|
133
|
+
compressionLevel:(int)compressionLevel
|
|
134
|
+
password:(nullable NSString *)password
|
|
135
|
+
AES:(BOOL)aes
|
|
136
|
+
progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler
|
|
137
|
+
keepSymlinks:(BOOL)keeplinks;
|
|
138
|
+
|
|
139
|
+
- (instancetype)init NS_UNAVAILABLE;
|
|
140
|
+
- (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
|
|
141
|
+
- (BOOL)open;
|
|
142
|
+
- (BOOL)openForAppending;
|
|
143
|
+
|
|
144
|
+
/// write empty folder
|
|
145
|
+
- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(nullable NSString *)password;
|
|
146
|
+
/// write file
|
|
147
|
+
- (BOOL)writeFile:(NSString *)path withPassword:(nullable NSString *)password;
|
|
148
|
+
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName withPassword:(nullable NSString *)password;
|
|
149
|
+
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
|
|
150
|
+
///write symlink files
|
|
151
|
+
- (BOOL)writeSymlinkFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
|
|
152
|
+
/// write data
|
|
153
|
+
- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename withPassword:(nullable NSString *)password;
|
|
154
|
+
- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
|
|
155
|
+
|
|
156
|
+
- (BOOL)close;
|
|
56
157
|
|
|
57
158
|
@end
|
|
58
159
|
|
|
@@ -69,8 +170,9 @@
|
|
|
69
170
|
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
|
|
70
171
|
|
|
71
172
|
- (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
|
|
72
|
-
- (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath;
|
|
73
173
|
|
|
74
174
|
@end
|
|
75
175
|
|
|
176
|
+
NS_ASSUME_NONNULL_END
|
|
177
|
+
|
|
76
178
|
#endif /* _SSZIPARCHIVE_H */
|