@capacitor/ios
Advanced tools
Comparing version 6.0.0-dev-20231222T034502.0 to 6.0.0-dev-8046d907.0
@@ -114,9 +114,5 @@ | ||
const formData = await convertFormData(body); | ||
const boundary = `${Date.now()}`; | ||
return { | ||
data: formData, | ||
type: 'formData', | ||
headers: { | ||
'Content-Type': `multipart/form-data; boundary=--${boundary}`, | ||
}, | ||
}; | ||
@@ -134,2 +130,22 @@ } | ||
}; | ||
const CAPACITOR_HTTP_INTERCEPTOR = '/_capacitor_http_interceptor_'; | ||
const CAPACITOR_HTTPS_INTERCEPTOR = '/_capacitor_https_interceptor_'; | ||
// TODO: export as Cap function | ||
const isRelativeOrProxyUrl = (url) => !url || | ||
!(url.startsWith('http:') || url.startsWith('https:')) || | ||
url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1 || | ||
url.indexOf(CAPACITOR_HTTPS_INTERCEPTOR) > -1; | ||
// TODO: export as Cap function | ||
const createProxyUrl = (url, win) => { | ||
var _a, _b; | ||
if (isRelativeOrProxyUrl(url)) | ||
return url; | ||
const proxyUrl = new URL(url); | ||
const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : ''); | ||
const isHttps = proxyUrl.protocol === 'https:'; | ||
bridgeUrl.search = proxyUrl.search; | ||
bridgeUrl.hash = proxyUrl.hash; | ||
bridgeUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${encodeURIComponent(proxyUrl.host)}${proxyUrl.pathname}`; | ||
return bridgeUrl.toString(); | ||
}; | ||
const initBridge = (w) => { | ||
@@ -364,11 +380,11 @@ const getPlatformId = (win) => { | ||
const serializeConsoleMessage = (msg) => { | ||
if (typeof msg === 'object') { | ||
try { | ||
try { | ||
if (typeof msg === 'object') { | ||
msg = JSON.stringify(msg); | ||
} | ||
catch (e) { | ||
// ignore | ||
} | ||
return String(msg); | ||
} | ||
return String(msg); | ||
catch (e) { | ||
return ''; | ||
} | ||
}; | ||
@@ -482,2 +498,15 @@ const platform = getPlatformId(win); | ||
} | ||
if (!(options === null || options === void 0 ? void 0 : options.method) || | ||
options.method.toLocaleUpperCase() === 'GET' || | ||
options.method.toLocaleUpperCase() === 'HEAD' || | ||
options.method.toLocaleUpperCase() === 'OPTIONS' || | ||
options.method.toLocaleUpperCase() === 'TRACE') { | ||
if (typeof resource === 'string') { | ||
return await win.CapacitorWebFetch(createProxyUrl(resource, win), options); | ||
} | ||
else if (resource instanceof Request) { | ||
const modifiedRequest = new Request(createProxyUrl(resource.url, win), resource); | ||
return await win.CapacitorWebFetch(modifiedRequest, options); | ||
} | ||
} | ||
const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`; | ||
@@ -552,3 +581,2 @@ console.time(tag); | ||
const prototype = win.CapacitorWebXMLHttpRequest.prototype; | ||
const isRelativeURL = (url) => !url || !(url.startsWith('http:') || url.startsWith('https:')); | ||
const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' && | ||
@@ -558,3 +586,3 @@ ProgressEvent.prototype instanceof Event; | ||
prototype.abort = function () { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.abort.call(this); | ||
@@ -570,6 +598,14 @@ } | ||
prototype.open = function (method, url) { | ||
this._method = method.toLocaleUpperCase(); | ||
this._url = url; | ||
this._method = method; | ||
if (isRelativeURL(url)) { | ||
return win.CapacitorWebXMLHttpRequest.open.call(this, method, url); | ||
if (!this._method || | ||
this._method === 'GET' || | ||
this._method === 'HEAD' || | ||
this._method === 'OPTIONS' || | ||
this._method === 'TRACE') { | ||
if (isRelativeOrProxyUrl(url)) { | ||
return win.CapacitorWebXMLHttpRequest.open.call(this, method, url); | ||
} | ||
this._url = createProxyUrl(this._url, win); | ||
return win.CapacitorWebXMLHttpRequest.open.call(this, method, this._url); | ||
} | ||
@@ -583,3 +619,3 @@ setTimeout(() => { | ||
prototype.setRequestHeader = function (header, value) { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.setRequestHeader.call(this, header, value); | ||
@@ -591,3 +627,3 @@ } | ||
prototype.send = function (body) { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.send.call(this, body); | ||
@@ -654,3 +690,4 @@ } | ||
} | ||
this.responseText = ((_a = nativeResponse.headers['Content-Type']) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) | ||
this.responseText = ((_a = (nativeResponse.headers['Content-Type'] || | ||
nativeResponse.headers['content-type'])) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) | ||
? JSON.stringify(nativeResponse.data) | ||
@@ -712,3 +749,3 @@ : nativeResponse.data; | ||
prototype.getAllResponseHeaders = function () { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.getAllResponseHeaders.call(this); | ||
@@ -726,3 +763,3 @@ } | ||
prototype.getResponseHeader = function (name) { | ||
if (isRelativeURL(this._url)) { | ||
if (isRelativeOrProxyUrl(this._url)) { | ||
return win.CapacitorWebXMLHttpRequest.getResponseHeader.call(this, name); | ||
@@ -729,0 +766,0 @@ } |
{ | ||
"name": "@capacitor/ios", | ||
"version": "6.0.0-dev-20231222T034502.0", | ||
"version": "6.0.0-dev-8046d907.0", | ||
"description": "Capacitor: Cross-platform apps with JavaScript and the web", | ||
@@ -23,3 +23,3 @@ "homepage": "https://capacitorjs.com", | ||
"scripts": { | ||
"verify": "npm run xc:build:Capacitor && npm run xc:build:CapacitorCordova && pod lib lint --allow-warnings Capacitor.podspec && pod lib lint --allow-warnings CapacitorCordova.podspec", | ||
"verify": "npm run xc:build:Capacitor && npm run xc:build:CapacitorCordova", | ||
"xc:build:Capacitor": "cd Capacitor && xcodebuild -workspace Capacitor.xcworkspace -scheme Capacitor && cd ..", | ||
@@ -30,7 +30,8 @@ "xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd ..", | ||
"peerDependencies": { | ||
"@capacitor/core": "^6.0.0-dev-20231222T034502.0" | ||
"@capacitor/core": "^6.0.0-rc.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
}, | ||
"gitHead": "8046d907d2d2c0779316adbcabda426acee2dfc3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
375378
104
1007
1