@capacitor/ios 5.2.3-nightly-20230724T150520.0 → 5.2.3

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.
@@ -19,13 +19,6 @@ internal struct JSCall {
19
19
  let pluginId: String
20
20
  let method: String
21
21
  let callbackId: String
22
-
23
- init(options: [String: Any], pluginId: String, method: String, callbackId: String) {
24
- self.options = options
25
- self.pluginId = pluginId
26
- self.method = method
27
- self.callbackId = callbackId
28
- }
29
22
  }
30
23
 
31
24
  internal protocol JSResultProtocol {
@@ -64,11 +57,6 @@ internal struct JSResult: JSResultProtocol {
64
57
  let call: JSCall
65
58
  let result: PluginCallResult?
66
59
 
67
- init(call: JSCall, result: PluginCallResult?) {
68
- self.call = call
69
- self.result = result
70
- }
71
-
72
60
  func jsonPayload() -> String {
73
61
  guard let result = result else {
74
62
  return SerializationResult.undefined.rawValue
@@ -101,14 +89,6 @@ internal struct JSResultError: JSResultProtocol {
101
89
  let errorCode: String?
102
90
  let result: PluginCallResult
103
91
 
104
- init(call: JSCall, errorMessage: String, errorDescription: String, errorCode: String?, result: PluginCallResult) {
105
- self.call = call
106
- self.errorMessage = errorMessage
107
- self.errorDescription = errorDescription
108
- self.errorCode = errorCode
109
- self.result = result
110
- }
111
-
112
92
  func jsonPayload() -> String {
113
93
  var errorDictionary: [String: Any] = [
114
94
  "message": self.errorMessage,
@@ -77,7 +77,9 @@ public class CapacitorCookieManager {
77
77
  let jar = HTTPCookieStorage.shared
78
78
  if let cookies = jar.cookies(for: url) {
79
79
  for cookie in cookies {
80
- cookiesMap[cookie.name] = cookie.value
80
+ if !cookie.isHTTPOnly {
81
+ cookiesMap[cookie.name] = cookie.value
82
+ }
81
83
  }
82
84
  }
83
85
  return cookiesMap
@@ -88,7 +90,8 @@ public class CapacitorCookieManager {
88
90
  let jar = HTTPCookieStorage.shared
89
91
  guard let url = self.getServerUrl() else { return "" }
90
92
  guard let cookies = jar.cookies(for: url) else { return "" }
91
- return cookies.map({"\($0.name)=\($0.value)"}).joined(separator: "; ")
93
+ let filteredCookies = cookies.filter { !$0.isHTTPOnly }
94
+ return filteredCookies.map({"\($0.name)=\($0.value)"}).joined(separator: "; ")
92
95
  }
93
96
 
94
97
  public func deleteCookie(_ url: URL, _ key: String) {
@@ -349,6 +349,7 @@ var nativeBridge = (function (exports) {
349
349
  if (doPatchCookies) {
350
350
  Object.defineProperty(document, 'cookie', {
351
351
  get: function () {
352
+ var _a, _b, _c;
352
353
  if (platform === 'ios') {
353
354
  // Use prompt to synchronously get cookies.
354
355
  // https://stackoverflow.com/questions/29249132/wkwebview-complex-communication-between-javascript-native-code/49474323#49474323
@@ -359,7 +360,8 @@ var nativeBridge = (function (exports) {
359
360
  return res;
360
361
  }
361
362
  else if (typeof win.CapacitorCookiesAndroidInterface !== 'undefined') {
362
- return win.CapacitorCookiesAndroidInterface.getCookies();
363
+ // return original document.cookie since Android does not support filtering of `httpOnly` cookies
364
+ return (_c = (_b = (_a = win.CapacitorCookiesDescriptor) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.call(document)) !== null && _c !== void 0 ? _c : '';
363
365
  }
364
366
  },
365
367
  set: function (val) {
@@ -494,29 +496,15 @@ var nativeBridge = (function (exports) {
494
496
  });
495
497
  },
496
498
  },
497
- response: {
498
- value: '',
499
- writable: true,
500
- },
501
- responseText: {
502
- value: '',
503
- writable: true,
504
- },
505
- responseURL: {
506
- value: '',
507
- writable: true,
508
- },
509
- status: {
510
- value: 0,
511
- writable: true,
512
- },
513
499
  });
514
500
  xhr.readyState = 0;
515
501
  const prototype = win.CapacitorWebXMLHttpRequest.prototype;
502
+ const isRelativeURL = (url) => !url || !(url.startsWith('http:') || url.startsWith('https:'));
503
+ const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' &&
504
+ ProgressEvent.prototype instanceof Event;
516
505
  // XHR patch abort
517
506
  prototype.abort = function () {
518
- if (this._url == null ||
519
- !(this._url.startsWith('http:') || this._url.startsWith('https:'))) {
507
+ if (isRelativeURL(this._url)) {
520
508
  return win.CapacitorWebXMLHttpRequest.abort.call(this);
521
509
  }
522
510
  this.readyState = 0;
@@ -529,7 +517,7 @@ var nativeBridge = (function (exports) {
529
517
  prototype.open = function (method, url) {
530
518
  this._url = url;
531
519
  this._method = method;
532
- if (!(url.startsWith('http:') || url.toString().startsWith('https:'))) {
520
+ if (isRelativeURL(url)) {
533
521
  return win.CapacitorWebXMLHttpRequest.open.call(this, method, url);
534
522
  }
535
523
  setTimeout(() => {
@@ -539,22 +527,38 @@ var nativeBridge = (function (exports) {
539
527
  };
540
528
  // XHR patch set request header
541
529
  prototype.setRequestHeader = function (header, value) {
542
- if (this._url == null ||
543
- !(this._url.startsWith('http:') || this._url.startsWith('https:'))) {
530
+ if (isRelativeURL(this._url)) {
544
531
  return win.CapacitorWebXMLHttpRequest.setRequestHeader.call(this, header, value);
545
532
  }
546
533
  this._headers[header] = value;
547
534
  };
548
535
  // XHR patch send
549
536
  prototype.send = function (body) {
550
- if (this._url == null ||
551
- !(this._url.startsWith('http:') || this._url.startsWith('https:'))) {
537
+ if (isRelativeURL(this._url)) {
552
538
  return win.CapacitorWebXMLHttpRequest.send.call(this, body);
553
539
  }
554
540
  const tag = `CapacitorHttp XMLHttpRequest ${Date.now()} ${this._url}`;
555
541
  console.time(tag);
556
542
  try {
557
543
  this.readyState = 2;
544
+ Object.defineProperties(this, {
545
+ response: {
546
+ value: '',
547
+ writable: true,
548
+ },
549
+ responseText: {
550
+ value: '',
551
+ writable: true,
552
+ },
553
+ responseURL: {
554
+ value: '',
555
+ writable: true,
556
+ },
557
+ status: {
558
+ value: 0,
559
+ writable: true,
560
+ },
561
+ });
558
562
  convertBody(body).then(({ data, type, headers }) => {
559
563
  const otherHeaders = this._headers != null && Object.keys(this._headers).length > 0
560
564
  ? this._headers
@@ -573,11 +577,13 @@ var nativeBridge = (function (exports) {
573
577
  // intercept & parse response before returning
574
578
  if (this.readyState == 2) {
575
579
  //TODO: Add progress event emission on native side
576
- this.dispatchEvent(new ProgressEvent('progress', {
577
- lengthComputable: true,
578
- loaded: nativeResponse.data.length,
579
- total: nativeResponse.data.length,
580
- }));
580
+ if (isProgressEventAvailable()) {
581
+ this.dispatchEvent(new ProgressEvent('progress', {
582
+ lengthComputable: true,
583
+ loaded: nativeResponse.data.length,
584
+ total: nativeResponse.data.length,
585
+ }));
586
+ }
581
587
  this._headers = nativeResponse.headers;
582
588
  this.status = nativeResponse.status;
583
589
  if (this.responseType === '' ||
@@ -609,11 +615,13 @@ var nativeBridge = (function (exports) {
609
615
  this.responseText = JSON.stringify(error.data);
610
616
  this.responseURL = error.url;
611
617
  this.readyState = 4;
612
- this.dispatchEvent(new ProgressEvent('progress', {
613
- lengthComputable: false,
614
- loaded: 0,
615
- total: 0,
616
- }));
618
+ if (isProgressEventAvailable()) {
619
+ this.dispatchEvent(new ProgressEvent('progress', {
620
+ lengthComputable: false,
621
+ loaded: 0,
622
+ total: 0,
623
+ }));
624
+ }
617
625
  setTimeout(() => {
618
626
  this.dispatchEvent(new Event('error'));
619
627
  this.dispatchEvent(new Event('loadend'));
@@ -629,11 +637,13 @@ var nativeBridge = (function (exports) {
629
637
  this.responseText = error.toString();
630
638
  this.responseURL = this._url;
631
639
  this.readyState = 4;
632
- this.dispatchEvent(new ProgressEvent('progress', {
633
- lengthComputable: false,
634
- loaded: 0,
635
- total: 0,
636
- }));
640
+ if (isProgressEventAvailable()) {
641
+ this.dispatchEvent(new ProgressEvent('progress', {
642
+ lengthComputable: false,
643
+ loaded: 0,
644
+ total: 0,
645
+ }));
646
+ }
637
647
  setTimeout(() => {
638
648
  this.dispatchEvent(new Event('error'));
639
649
  this.dispatchEvent(new Event('loadend'));
@@ -643,8 +653,7 @@ var nativeBridge = (function (exports) {
643
653
  };
644
654
  // XHR patch getAllResponseHeaders
645
655
  prototype.getAllResponseHeaders = function () {
646
- if (this._url == null ||
647
- !(this._url.startsWith('http:') || this._url.startsWith('https:'))) {
656
+ if (isRelativeURL(this._url)) {
648
657
  return win.CapacitorWebXMLHttpRequest.getAllResponseHeaders.call(this);
649
658
  }
650
659
  let returnString = '';
@@ -657,8 +666,7 @@ var nativeBridge = (function (exports) {
657
666
  };
658
667
  // XHR patch getResponseHeader
659
668
  prototype.getResponseHeader = function (name) {
660
- if (this._url == null ||
661
- !(this._url.startsWith('http:') || this._url.startsWith('https:'))) {
669
+ if (isRelativeURL(this._url)) {
662
670
  return win.CapacitorWebXMLHttpRequest.getResponseHeader.call(this, name);
663
671
  }
664
672
  return this._headers[name];
@@ -894,6 +902,7 @@ var nativeBridge = (function (exports) {
894
902
  });
895
903
  });
896
904
  };
905
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
897
906
  cap.withPlugin = (_pluginId, _fn) => dummy;
898
907
  cap.Exception = CapacitorException;
899
908
  initEvents(win, cap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/ios",
3
- "version": "5.2.3-nightly-20230724T150520.0",
3
+ "version": "5.2.3",
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)",
@@ -25,7 +25,7 @@
25
25
  "xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd .."
26
26
  },
27
27
  "peerDependencies": {
28
- "@capacitor/core": "^5.2.0-nightly-20230724T150520.0"
28
+ "@capacitor/core": "^5.2.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"