@microsoft/omnichannel-amsclient
Advanced tools
Comparing version 0.1.0-main.294e9eb to 0.1.0-main.a4f0d5f
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
## [Unreleased] | ||
## [Unreleased] | ||
### Added | ||
- Prevent multiple iframes being loaded |
@@ -1,1 +0,1 @@ | ||
exports.baseUrl = 'https://comms-test.omnichannelengagementhub.com/ams'; exports.sdkVersion = '0.1.0-main.294e9eb'; | ||
exports.baseUrl = 'https://comms.omnichannelengagementhub.com/ams'; exports.sdkVersion = '0.1.0-main.a4f0d5f'; |
export default interface FileMetadata { | ||
fileSharingProtocolType: number; | ||
fileSharingProtocolType?: number; | ||
id: string; | ||
name: string; | ||
size: number; | ||
name?: string; | ||
size?: number; | ||
type: string; | ||
url: string; | ||
url?: string; | ||
} |
@@ -28,5 +28,5 @@ import AMSFileInfo from "./AMSFileInfo"; | ||
postMessage(eventType: PostMessageEventType, eventName: PostMessageEventName, data?: PostMessageRequestData, resolve?: CallableFunction, reject?: CallableFunction): void; | ||
handleEvent(event: MessageEvent<any>): Promise<void>; | ||
private createIframe; | ||
handleEvent(event: MessageEvent): Promise<void>; | ||
private loadIframe; | ||
} | ||
export default FramedClient; |
@@ -81,3 +81,3 @@ "use strict"; | ||
} | ||
return [4 /*yield*/, this.createIframe()]; | ||
return [4 /*yield*/, this.loadIframe()]; | ||
case 1: | ||
@@ -103,10 +103,16 @@ _a.sent(); | ||
return __generator(this, function (_a) { | ||
/* istanbul ignore next */ | ||
this.debug && console.log("[FramedClient][skypeAuth]"); | ||
data = { | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.SkypeTokenAuth, data, resolve, reject); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
/* istanbul ignore next */ | ||
this.debug && console.log("[FramedClient][skypeAuth]"); | ||
data = { | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [4 /*yield*/, this.loadIframe()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.SkypeTokenAuth, data, resolve, reject); | ||
})]; | ||
} | ||
}); | ||
@@ -121,12 +127,18 @@ }); | ||
return __generator(this, function (_a) { | ||
/* istanbul ignore next */ | ||
this.debug && console.log("[FramedClient][createObject]"); | ||
data = { | ||
id: id, | ||
file: file, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.CreateObject, data, resolve, reject); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
/* istanbul ignore next */ | ||
this.debug && console.log("[FramedClient][createObject]"); | ||
data = { | ||
id: id, | ||
file: file, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [4 /*yield*/, this.loadIframe()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.CreateObject, data, resolve, reject); | ||
})]; | ||
} | ||
}); | ||
@@ -141,12 +153,18 @@ }); | ||
return __generator(this, function (_a) { | ||
/* istanbul ignore next */ | ||
this.debug && console.log("[FramedClient][uploadDocument]"); | ||
data = { | ||
documentId: documentId, | ||
file: file, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.UploadDocument, data, resolve, reject); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
/* istanbul ignore next */ | ||
this.debug && console.log("[FramedClient][uploadDocument]"); | ||
data = { | ||
documentId: documentId, | ||
file: file, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [4 /*yield*/, this.loadIframe()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.UploadDocument, data, resolve, reject); | ||
})]; | ||
} | ||
}); | ||
@@ -161,9 +179,15 @@ }); | ||
return __generator(this, function (_a) { | ||
data = { | ||
fileMetadata: fileMetadata, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.GetViewStatus, data, resolve, reject); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
data = { | ||
fileMetadata: fileMetadata, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [4 /*yield*/, this.loadIframe()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.GetViewStatus, data, resolve, reject); | ||
})]; | ||
} | ||
}); | ||
@@ -178,10 +202,16 @@ }); | ||
return __generator(this, function (_a) { | ||
data = { | ||
fileMetadata: fileMetadata, | ||
viewLocation: viewLocation, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.GetView, data, resolve, reject); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
data = { | ||
fileMetadata: fileMetadata, | ||
viewLocation: viewLocation, | ||
chatToken: chatToken || this.chatToken | ||
}; | ||
return [4 /*yield*/, this.loadIframe()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
_this.postMessage(PostMessageEventType_1.default.Request, PostMessageEventName_1.default.GetView, data, resolve, reject); | ||
})]; | ||
} | ||
}); | ||
@@ -225,2 +255,6 @@ }); | ||
}; | ||
if (!this.targetWindow) { | ||
console.error('Target window not found!'); | ||
return; | ||
} | ||
this.targetWindow.postMessage(__assign({ requestId: requestId, | ||
@@ -240,3 +274,6 @@ eventType: eventType, | ||
this.debug && console.log(event); | ||
this.targetWindow = event.source; // Finds target window to post message back | ||
// Finds target window to post message back | ||
if (event.source) { | ||
this.targetWindow = event.source; | ||
} | ||
if (event.data.eventType === PostMessageEventType_1.default.Response) { | ||
@@ -274,3 +311,3 @@ /* istanbul ignore next */ | ||
}; | ||
FramedClient.prototype.createIframe = function () { | ||
FramedClient.prototype.loadIframe = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -282,2 +319,8 @@ var iframeId; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var iframeElements = Array.from(document.getElementsByTagName('iframe')); | ||
var foundIframeElement = iframeElements.filter(function (iframeElement) { return iframeElement.id == iframeId; }); | ||
// Avoid duplicate load | ||
if (foundIframeElement.length) { | ||
return resolve(); | ||
} | ||
var iframeElement = document.createElement('iframe'); | ||
@@ -284,0 +327,0 @@ iframeElement.id = iframeId; |
{ | ||
"name": "@microsoft/omnichannel-amsclient", | ||
"version": "0.1.0-main.294e9eb", | ||
"version": "0.1.0-main.a4f0d5f", | ||
"description": "Microsoft Omnichannel AMSClient", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
207363
1609