Skip to content

Commit

Permalink
Merge pull request #4 from msintuneappsdk/release_1_0_1
Browse files Browse the repository at this point in the history
Update to 1.0.1
  • Loading branch information
mikeliddle authored Mar 1, 2023
2 parents 5b1ed6f + 91100a5 commit 4f1609b
Show file tree
Hide file tree
Showing 50 changed files with 224 additions and 392 deletions.
10 changes: 5 additions & 5 deletions MCPCommon.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>MCPCommon.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>MCPCommon.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file modified MCPCommon.xcframework/ios-arm64/MCPCommon.framework/Info.plist
Binary file not shown.
Binary file modified MCPCommon.xcframework/ios-arm64/MCPCommon.framework/MCPCommon
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</data>
<key>Info.plist</key>
<data>
rZWv2TaC7CQ6fKrEaTa4AARe6HU=
VWcJ7VFdUjoB83k5RfqvNQmdowg=
</data>
<key>Modules/module.modulemap</key>
<data>
Expand Down
10 changes: 5 additions & 5 deletions MCPCore.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>MCPCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>MCPCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file modified MCPCore.xcframework/ios-arm64/MCPCore.framework/Info.plist
Binary file not shown.
Binary file modified MCPCore.xcframework/ios-arm64/MCPCore.framework/MCPCore
Binary file not shown.
171 changes: 39 additions & 132 deletions MCPCore.xcframework/ios-arm64/MCPCore.framework/WKInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function mstobject() { // eslint-disable-line no-unused-vars
webkit.messageHandlers.mstCallbackHandler.postMessage({ 'action': 'log', 'content': log });
}

function interceptBody(body, input, options) {
function interceptBody(body, input, options, reenter, passthrough) {

if ((undefined === body) || (null === body)) {
body = '';
}
Expand All @@ -60,7 +61,7 @@ function mstobject() { // eslint-disable-line no-unused-vars
var CRLF = '\r\n';
var blob_parts = [];
var entries_it = body.entries();
while (true) { // eslint-disable-line no-constant-condition
while (true) { // eslint-disable-line no-constant-condition
var it = entries_it.next();
if (it.done) {
break;
Expand All @@ -82,25 +83,31 @@ function mstobject() { // eslint-disable-line no-unused-vars
blob_parts.push('--' + boundary + '--' + CRLF);
sendBody = new Blob(blob_parts);
}
if (body instanceof ReadableStream) {
// TODO: implement stream requests in an async manner, which we don't have a good way to do currently.
return;
if (body instanceof ReadableStream && input instanceof Request) {
var original = input.clone();
return input.text()
.then(b => {
if (!options) {
options = {};
}
options.__mstReadableStreamConvertedToString = b;
return reenter(body, original, options);
});
}
if (body instanceof Blob) {
var outerThis = this;
var filereader = new FileReader();
filereader.onload = function () {
if ((undefined === options) || (null === options)) {
input.body = this.result;
} else {
options.body = this.result;
}
outerThis.fetch(input, options);
};
filereader.readAsArrayBuffer(body);
// The FileReader load is async, so bail from here.
// The recursive call will send in an ArrayBuffer
return;
return new Promise((resolve) => {
var filereader = new FileReader();
filereader.onload = function () {
if (input && (undefined === options) || (null === options)) {
input.body = this.result;
} else {
options.body = this.result;
}
reenter(body, input, options);
resolve();
};
filereader.readAsArrayBuffer(body);
});
}

// ArrayBufferView is a namesake, the real classes are
Expand All @@ -120,7 +127,8 @@ function mstobject() { // eslint-disable-line no-unused-vars
if (body instanceof ArrayBuffer) {
var bytes = new Uint8Array(body);
// Cast off original for actual call to send
sendBody = JSON.parse('{"bytes":[' + bytes.toString() + ']}');
sendBody = body;
body = JSON.parse('{"bytes":[' + bytes.toString() + ']}');
}
}

Expand All @@ -132,7 +140,8 @@ function mstobject() { // eslint-disable-line no-unused-vars
// Only benefit here is that Web Inspector shows a more accurate result
body = sendBody;
}
return sendBody;

return passthrough(body, input, options);
}

self.mstFetch = self.fetch;
Expand All @@ -157,13 +166,13 @@ function mstobject() { // eslint-disable-line no-unused-vars
body = input.body;
}

var result = interceptBody(body, input, options);

if ((undefined === result) || (null === result)) {
return;
if (options && options.__mstReadableStreamConvertedToString) {
body = options.__mstReadableStreamConvertedToString;
}

return this.mstFetch(input, options);
return interceptBody(body, input, options,
(b, i, o) => self.fetch(i, o),
(b, i, o) => self.mstFetch(i, o));
}

XMLHttpRequest.prototype.mstOpen = XMLHttpRequest.prototype.open;
Expand All @@ -183,112 +192,10 @@ function mstobject() { // eslint-disable-line no-unused-vars

XMLHttpRequest.prototype.mstSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function (body) {
// Send can be called without a body, which can result in a 411 if the content length is not set to 0.
// To fix this, we need to set the body to be empty ("") which causes the client to do the right thing.
if ((undefined === body) || (null === body)) {
body = "";
}

// Add code to monitor and honor failed CORS requests here
// Code used to exist that watched for exceptions and attempted to forward events,
// however the existing code was causing issues with SAP apps for both Colgate and Molex.
// Created AC-5156 to track this task.

// There are a few types of input body types:
// - string
// - Document (convert to string)
// - Blob (convert to ArrayBuffer via FileReader)
// - ArrayBufferView (convert to ArrayBuffer)
// - ArrayBuffer (convert to byte array)
// - FormData (needs proper construction)

var sendBody = null;
if (body instanceof Document) {
if (body.documentElement !== null) {
body = body.documentElement.outerHTML;
} else {
body = '';
}
}

if (typeof (body) === "object") {
if (body instanceof FormData) {
var boundary = function () {
function s4() {
var n = Math.floor((1 + Math.random()) * 0x10000);
return n.toString(16).substring(1);
}
return "----WebKitFormBoundary" + s4() + s4() + s4() + s4();
}();

var CRLF = '\r\n';
var blob_parts = [];
var entries_it = body.entries();
while (true) { // eslint-disable-line no-constant-condition
var it = entries_it.next();
if (it.done) {
break;
}
var key = it.value[0];
var value = it.value[1];
blob_parts.push('--' + boundary + CRLF);
blob_parts.push('Content-Disposition: form-data; name="' + key + '"');
if (value instanceof Blob) {
var blobContentType = value.type || 'application/octet-stream';
blob_parts.push('; filename="' + value.name + '"' + CRLF);
blob_parts.push('Content-Type: ' + blobContentType + CRLF + CRLF);
blob_parts.push(value);
blob_parts.push(CRLF);
} else {
blob_parts.push(CRLF + CRLF + value + CRLF);
}
}
blob_parts.push('--' + boundary + '--' + CRLF);
body = new Blob(blob_parts);
}
if (body instanceof Blob) {
var outerThis = this;
var filereader = new FileReader();
filereader.onload = function () {
outerThis.send(this.result);
};
filereader.readAsArrayBuffer(body);
// The FileReader load is async, so bail from here.
// The recursive call will send in an ArrayBuffer
return;
}

// ArrayBufferView is a namesake, the real classes are
if (body instanceof Int8Array ||
body instanceof Uint8Array ||
body instanceof Uint8ClampedArray ||
body instanceof Int16Array ||
body instanceof Uint16Array ||
body instanceof Int32Array ||
body instanceof Uint32Array ||
body instanceof Float32Array ||
body instanceof Float64Array) {
// Get the underlying ArrayBuffer, allow next if statement to process
body = body.buffer;
}
if (body instanceof ArrayBuffer) {
var bytes = new Uint8Array(body);
// Cast off original for actual call to send
sendBody = body;
body = JSON.parse('{"bytes":[' + bytes.toString() + ']}');
}
}

if (typeof (body) === "string") {
webkit.messageHandlers.mstCallbackHandler.postMessage({ 'action': 'ajaxSend', 'tag': this.__mstUrl, 'method': this.__mstMethod, 'content': body });
} else if (typeof (body) === "object") {
webkit.messageHandlers.mstCallbackHandler.postMessage({ 'action': 'ajaxSend', 'tag': this.__mstUrl, 'method': this.__mstMethod, 'content': JSON.stringify(body) });
// Reset original for actual call to send.
// Only benefit here is that Web Inspector shows a more accurate result
body = sendBody;
}

this.mstSend(body);
var outerThis = this;
return interceptBody(body, null, null,
(b) => outerThis.send(b),
(b) => outerThis.mstSend(b));
};

// Save original HTMLFormElement functions to call submit for non-events
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 4f1609b

Please sign in to comment.