@capacitor/android 5.4.1-nightly-20230921T150449.0 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  ext {
2
- androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.7.2'
2
+ androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.7.0'
3
3
  androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
4
  androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0'
5
- androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.10.1'
6
- androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.6.1'
7
- androidxWebkitVersion = project.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.7.0'
5
+ androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.10.0'
6
+ androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.5.6'
7
+ androidxWebkitVersion = project.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.6.1'
8
8
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
9
9
  androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
10
10
  androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
@@ -13,7 +13,7 @@ ext {
13
13
 
14
14
 
15
15
  buildscript {
16
- ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.10'
16
+ ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.8.20'
17
17
  repositories {
18
18
  google()
19
19
  mavenCentral()
@@ -22,7 +22,7 @@ buildscript {
22
22
  }
23
23
  }
24
24
  dependencies {
25
- classpath 'com.android.tools.build:gradle:8.1.1'
25
+ classpath 'com.android.tools.build:gradle:8.0.0'
26
26
 
27
27
  if (System.getenv("CAP_PUBLISH") == "true") {
28
28
  classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
@@ -42,10 +42,10 @@ if (System.getenv("CAP_PUBLISH") == "true") {
42
42
 
43
43
  android {
44
44
  namespace "com.getcapacitor.android"
45
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
45
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
46
46
  defaultConfig {
47
47
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
48
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
48
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
49
49
  versionCode 1
50
50
  versionName "1.0"
51
51
  consumerProguardFiles 'proguard-rules.pro'
@@ -64,8 +64,52 @@ var nativeBridge = (function (exports) {
64
64
  }
65
65
  return newFormData;
66
66
  };
67
- const convertBody = async (body) => {
68
- if (body instanceof FormData) {
67
+ const convertBody = async (body, contentType) => {
68
+ if (body instanceof ReadableStream) {
69
+ const reader = body.getReader();
70
+ const chunks = [];
71
+ while (true) {
72
+ const { done, value } = await reader.read();
73
+ if (done)
74
+ break;
75
+ chunks.push(value);
76
+ }
77
+ const concatenated = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
78
+ let position = 0;
79
+ for (const chunk of chunks) {
80
+ concatenated.set(chunk, position);
81
+ position += chunk.length;
82
+ }
83
+ let data = new TextDecoder().decode(concatenated);
84
+ let type;
85
+ if (contentType === 'application/json') {
86
+ try {
87
+ data = JSON.parse(data);
88
+ }
89
+ catch (ignored) {
90
+ // ignore
91
+ }
92
+ type = 'json';
93
+ }
94
+ else if (contentType === 'multipart/form-data') {
95
+ type = 'formData';
96
+ }
97
+ else if (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('image')) {
98
+ type = 'image';
99
+ }
100
+ else if (contentType === 'application/octet-stream') {
101
+ type = 'binary';
102
+ }
103
+ else {
104
+ type = 'text';
105
+ }
106
+ return {
107
+ data,
108
+ type,
109
+ headers: { 'Content-Type': contentType || 'application/octet-stream' },
110
+ };
111
+ }
112
+ else if (body instanceof FormData) {
69
113
  const formData = await convertFormData(body);
70
114
  const boundary = `${Date.now()}`;
71
115
  return {
@@ -432,9 +476,10 @@ var nativeBridge = (function (exports) {
432
476
  const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`;
433
477
  console.time(tag);
434
478
  try {
479
+ // intercept request & pass to the bridge
435
480
  const { body, method } = request;
436
- const { data: requestData, type, headers } = await convertBody(body || undefined);
437
481
  const optionHeaders = Object.fromEntries(request.headers.entries());
482
+ const { data: requestData, type, headers, } = await convertBody((options === null || options === void 0 ? void 0 : options.body) || body || undefined, optionHeaders['Content-Type'] || optionHeaders['content-type']);
438
483
  const nativeResponse = await cap.nativePromise('CapacitorHttp', 'request', {
439
484
  url: request.url,
440
485
  method: method,
@@ -585,12 +630,22 @@ var nativeBridge = (function (exports) {
585
630
  }
586
631
  this._headers = nativeResponse.headers;
587
632
  this.status = nativeResponse.status;
633
+ const responseString = typeof nativeResponse.data !== 'string'
634
+ ? JSON.stringify(nativeResponse.data)
635
+ : nativeResponse.data;
588
636
  if (this.responseType === '' ||
589
637
  this.responseType === 'text') {
590
- this.response =
591
- typeof nativeResponse.data !== 'string'
592
- ? JSON.stringify(nativeResponse.data)
593
- : nativeResponse.data;
638
+ this.response = responseString;
639
+ }
640
+ else if (this.responseType === 'blob') {
641
+ this.response = new Blob([responseString], {
642
+ type: 'application/json',
643
+ });
644
+ }
645
+ else if (this.responseType === 'arraybuffer') {
646
+ const encoder = new TextEncoder();
647
+ const uint8Array = encoder.encode(responseString);
648
+ this.response = uint8Array.buffer;
594
649
  }
595
650
  else {
596
651
  this.response = nativeResponse.data;
@@ -657,7 +712,7 @@ var nativeBridge = (function (exports) {
657
712
  }
658
713
  let returnString = '';
659
714
  for (const key in this._headers) {
660
- if (key != 'Set-Cookie') {
715
+ if (key.toLowerCase() !== 'set-cookie') {
661
716
  returnString += key + ': ' + this._headers[key] + '\r\n';
662
717
  }
663
718
  }
@@ -668,7 +723,12 @@ var nativeBridge = (function (exports) {
668
723
  if (isRelativeURL(this._url)) {
669
724
  return win.CapacitorWebXMLHttpRequest.getResponseHeader.call(this, name);
670
725
  }
671
- return this._headers[name];
726
+ for (const key in this._headers) {
727
+ if (key.toLowerCase() === name.toLowerCase()) {
728
+ return this._headers[key];
729
+ }
730
+ }
731
+ return null;
672
732
  };
673
733
  Object.setPrototypeOf(xhr, prototype);
674
734
  return xhr;
@@ -39,6 +39,11 @@ public class CapacitorCookies extends Plugin {
39
39
  return pluginConfig.getBoolean("enabled", false);
40
40
  }
41
41
 
42
+ private boolean isAllowingInsecureCookies() {
43
+ PluginConfig pluginConfig = getBridge().getConfig().getPluginConfiguration("CapacitorCookies");
44
+ return pluginConfig.getBoolean("androidCustomSchemeAllowInsecureAccess", false);
45
+ }
46
+
42
47
  @JavascriptInterface
43
48
  public void setCookie(String domain, String action) {
44
49
  cookieManager.setCookie(domain, action);
@@ -46,34 +51,44 @@ public class CapacitorCookies extends Plugin {
46
51
 
47
52
  @PluginMethod
48
53
  public void getCookies(PluginCall call) {
49
- this.bridge.eval(
50
- "document.cookie",
51
- value -> {
52
- String cookies = value.substring(1, value.length() - 1);
53
- String[] cookieArray = cookies.split(";");
54
-
55
- JSObject cookieMap = new JSObject();
56
-
57
- for (String cookie : cookieArray) {
58
- if (cookie.length() > 0) {
59
- String[] keyValue = cookie.split("=", 2);
60
-
61
- if (keyValue.length == 2) {
62
- String key = keyValue[0].trim();
63
- String val = keyValue[1].trim();
64
- try {
65
- key = URLDecoder.decode(keyValue[0].trim(), StandardCharsets.UTF_8.name());
66
- val = URLDecoder.decode(keyValue[1].trim(), StandardCharsets.UTF_8.name());
67
- } catch (UnsupportedEncodingException ignored) {}
68
-
69
- cookieMap.put(key, val);
54
+ if (isAllowingInsecureCookies()) {
55
+ String url = call.getString("url");
56
+ JSObject cookiesMap = new JSObject();
57
+ HttpCookie[] cookies = cookieManager.getCookies(url);
58
+ for (HttpCookie cookie : cookies) {
59
+ cookiesMap.put(cookie.getName(), cookie.getValue());
60
+ }
61
+ call.resolve(cookiesMap);
62
+ } else {
63
+ this.bridge.eval(
64
+ "document.cookie",
65
+ value -> {
66
+ String cookies = value.substring(1, value.length() - 1);
67
+ String[] cookieArray = cookies.split(";");
68
+
69
+ JSObject cookieMap = new JSObject();
70
+
71
+ for (String cookie : cookieArray) {
72
+ if (cookie.length() > 0) {
73
+ String[] keyValue = cookie.split("=", 2);
74
+
75
+ if (keyValue.length == 2) {
76
+ String key = keyValue[0].trim();
77
+ String val = keyValue[1].trim();
78
+ try {
79
+ key = URLDecoder.decode(keyValue[0].trim(), StandardCharsets.UTF_8.name());
80
+ val = URLDecoder.decode(keyValue[1].trim(), StandardCharsets.UTF_8.name());
81
+ } catch (UnsupportedEncodingException ignored) {}
82
+
83
+ cookieMap.put(key, val);
84
+ }
70
85
  }
71
86
  }
72
- }
73
87
 
74
- call.resolve(cookieMap);
75
- }
76
- );
88
+ call.resolve(cookieMap);
89
+ }
90
+ );
91
+ }
77
92
  }
78
93
 
79
94
  @PluginMethod
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "5.4.1-nightly-20230921T150449.0",
3
+ "version": "5.4.1",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
@@ -23,7 +23,7 @@
23
23
  "verify": "./gradlew clean lint build test -b capacitor/build.gradle"
24
24
  },
25
25
  "peerDependencies": {
26
- "@capacitor/core": "^5.4.0-nightly-20230921T150449.0"
26
+ "@capacitor/core": "^5.4.0"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"