Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/omnichannel-amsclient

Package Overview
Dependencies
Maintainers
5
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/omnichannel-amsclient - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2-main.6e7f0dc

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

## [Unreleased]
### Fixed
- Update logic to use MIME types to decide whether image or document endpoint to be used

@@ -7,0 +9,0 @@ ## [0.1.1] - 2022-08-31

8

lib/API.d.ts

@@ -8,7 +8,7 @@ import AMSCreateObjectResponse from "./AMSCreateObjectResponse";

skypeTokenAuth: (chatToken: OmnichannelChatToken) => Promise<Response>;
createObject: (id: string, file: File, chatToken: OmnichannelChatToken) => Promise<AMSCreateObjectResponse>;
uploadDocument: (documentId: string, file: AMSFileInfo | File, chatToken: OmnichannelChatToken) => Promise<FileMetadata>;
getViewStatus: (fileMetadata: FileMetadata, chatToken: OmnichannelChatToken) => Promise<AMSViewStatusResponse>;
getView: (fileMetadata: FileMetadata, viewLocation: string, chatToken: OmnichannelChatToken) => Promise<Blob>;
createObject: (id: string, file: File, chatToken: OmnichannelChatToken, supportedImagesMimeTypes?: string[] | undefined) => Promise<AMSCreateObjectResponse>;
uploadDocument: (documentId: string, file: AMSFileInfo | File, chatToken: OmnichannelChatToken, supportedImagesMimeTypes?: string[] | undefined) => Promise<FileMetadata>;
getViewStatus: (fileMetadata: FileMetadata, chatToken: OmnichannelChatToken, supportedImagesMimeTypes?: string[] | undefined) => Promise<AMSViewStatusResponse>;
getView: (fileMetadata: FileMetadata, viewLocation: string, chatToken: OmnichannelChatToken, supportedImagesMimeTypes?: string[] | undefined) => Promise<Blob>;
};
export default _default;

@@ -51,2 +51,14 @@ "use strict";

var GlobalConfiguration_1 = require("./GlobalConfiguration");
var AmsApiOperation;
(function (AmsApiOperation) {
AmsApiOperation["Create"] = "Create";
AmsApiOperation["Upload"] = "Upload";
})(AmsApiOperation || (AmsApiOperation = {}));
var DocumentTypes;
(function (DocumentTypes) {
DocumentTypes["CreateDocumentType"] = "sharing/file";
DocumentTypes["UploadDocumentType"] = "original";
DocumentTypes["CreateImageType"] = "pish/image";
DocumentTypes["UploadImageType"] = "imgpsh";
})(DocumentTypes || (DocumentTypes = {}));
var HeadersName;

@@ -74,3 +86,3 @@ (function (HeadersName) {

})(AMSFileStatus || (AMSFileStatus = {}));
var validImageTypes = ['jpeg', 'jpg', 'gif', 'png', 'bmp', 'tiff', 'jfif', 'webp'];
var defaultSupportedImagesMimeTypes = ["image/jpeg", "image/png", "image/gif"];
var patchChatToken = function (chatToken) {

@@ -127,4 +139,16 @@ // Temporary

}); };
var createObject = function (id, file, chatToken) { return __awaiter(void 0, void 0, void 0, function () {
var permissions, body, url, headers, request, response, jsonResponse, error_2;
var defineSupportedImagesMimeTypes = function (supportedImagesMimeTypes) {
return (supportedImagesMimeTypes && supportedImagesMimeTypes.length > 0) ?
supportedImagesMimeTypes :
defaultSupportedImagesMimeTypes;
};
var defineTypeForOperation = function (fileType, apiOperation, supportedImagesMimeTypes) {
var mimeTypes = defineSupportedImagesMimeTypes(supportedImagesMimeTypes);
if (mimeTypes.includes(fileType.toLowerCase())) {
return apiOperation === AmsApiOperation.Create ? DocumentTypes.CreateImageType : DocumentTypes.UploadImageType;
}
return apiOperation === AmsApiOperation.Create ? DocumentTypes.CreateDocumentType : DocumentTypes.UploadDocumentType;
};
var createObject = function (id, file, chatToken, supportedImagesMimeTypes) { return __awaiter(void 0, void 0, void 0, function () {
var permissions, typeObject, body, url, headers, request, response, jsonResponse, error_2;
var _a, _b;

@@ -139,6 +163,7 @@ var _c;

_a);
typeObject = defineTypeForOperation(file.type, AmsApiOperation.Create, supportedImagesMimeTypes);
body = {
filename: file.name,
permissions: permissions,
type: file.type.includes('image') ? 'pish/image' : 'sharing/file'
type: typeObject
};

@@ -172,4 +197,4 @@ patchChatToken(chatToken);

}); };
var uploadDocument = function (documentId, file, chatToken) { return __awaiter(void 0, void 0, void 0, function () {
var url, headers, request, fileMetadata, error_3;
var uploadDocument = function (documentId, file, chatToken, supportedImagesMimeTypes) { return __awaiter(void 0, void 0, void 0, function () {
var typeObject, url, headers, request, fileMetadata, error_3;
var _a;

@@ -182,3 +207,4 @@ var _b;

patchChatToken(chatToken);
url = (chatToken.amsEndpoint || ((_b = chatToken === null || chatToken === void 0 ? void 0 : chatToken.regionGTMS) === null || _b === void 0 ? void 0 : _b.ams)) + "/v1/objects/" + documentId + "/content/" + (file.type.includes('image') ? 'imgpsh' : 'original');
typeObject = defineTypeForOperation(file.type, AmsApiOperation.Upload, supportedImagesMimeTypes);
url = (chatToken.amsEndpoint || ((_b = chatToken === null || chatToken === void 0 ? void 0 : chatToken.regionGTMS) === null || _b === void 0 ? void 0 : _b.ams)) + "/v1/objects/" + documentId + "/content/" + typeObject;
headers = __assign(__assign({}, createDefaultHeaders(chatToken.token)), (_a = {}, _a[HeadersName.ContentType] = MIMEType.applicationFormUrlEncoded, _a));

@@ -213,3 +239,3 @@ request = {

}); };
var getViewStatus = function (fileMetadata, chatToken) { return __awaiter(void 0, void 0, void 0, function () {
var getViewStatus = function (fileMetadata, chatToken, supportedImagesMimeTypes) { return __awaiter(void 0, void 0, void 0, function () {
var url, headers, request, response, jsonResponse, content_state, view_state, view_location, error_4;

@@ -222,3 +248,3 @@ var _a;

patchChatToken(chatToken);
url = (chatToken.amsEndpoint || ((_a = chatToken === null || chatToken === void 0 ? void 0 : chatToken.regionGTMS) === null || _a === void 0 ? void 0 : _a.ams)) + "/v1/objects/" + fileMetadata.id + "/views/" + (validImageTypes.includes(fileMetadata.type) ? 'imgpsh_fullsize_anim' : 'original') + "/status";
url = (chatToken.amsEndpoint || ((_a = chatToken === null || chatToken === void 0 ? void 0 : chatToken.regionGTMS) === null || _a === void 0 ? void 0 : _a.ams)) + "/v1/objects/" + fileMetadata.id + "/views/" + (defineSupportedImagesMimeTypes(supportedImagesMimeTypes).includes(fileMetadata.type) ? 'imgpsh_fullsize_anim' : 'original') + "/status";
headers = createDefaultHeaders(chatToken.token);

@@ -257,3 +283,3 @@ request = {

}); };
var getView = function (fileMetadata, viewLocation, chatToken) { return __awaiter(void 0, void 0, void 0, function () {
var getView = function (fileMetadata, viewLocation, chatToken, supportedImagesMimeTypes) { return __awaiter(void 0, void 0, void 0, function () {
var url, headers, request, response, blobResponse, error_5;

@@ -267,3 +293,3 @@ return __generator(this, function (_a) {

headers = createDefaultHeaders(chatToken.token);
if (validImageTypes.includes(fileMetadata.type)) {
if (defineSupportedImagesMimeTypes(supportedImagesMimeTypes).includes(fileMetadata.type)) {
headers[HeadersName.Accept] = 'image/webp,image/ *,*/*;q=0.8';

@@ -270,0 +296,0 @@ headers[HeadersName.AcceptEncoding] = 'gzip, deflate, sdch, br';

@@ -1,1 +0,1 @@

exports.baseUrl = 'https://comms.omnichannelengagementhub.com/ams'; exports.sdkVersion = '0.1.1';
exports.baseUrl = 'https://comms.omnichannelengagementhub.com/ams'; exports.sdkVersion = '0.1.2-main.6e7f0dc';

@@ -25,6 +25,6 @@ import AMSFileInfo from "./AMSFileInfo";

skypeTokenAuth(chatToken?: OmnichannelChatToken | null): Promise<void>;
createObject(id: string, file: File, chatToken?: OmnichannelChatToken | null): Promise<void>;
uploadDocument(documentId: string, file: File | AMSFileInfo, chatToken?: OmnichannelChatToken | null): Promise<void>;
getViewStatus(fileMetadata: FileMetadata, chatToken?: OmnichannelChatToken | null): Promise<void>;
getView(fileMetadata: FileMetadata, viewLocation: string, chatToken?: OmnichannelChatToken | null): Promise<void>;
createObject(id: string, file: File, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<void>;
uploadDocument(documentId: string, file: File | AMSFileInfo, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<void>;
getViewStatus(fileMetadata: FileMetadata, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<void>;
getView(fileMetadata: FileMetadata, viewLocation: string, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<void>;
fetchBlob(contentUrl: string): Promise<Blob>;

@@ -31,0 +31,0 @@ onMessageEvent(cb: (event: MessageEvent) => void): void;

@@ -139,4 +139,5 @@ "use strict";

};
FramedClient.prototype.createObject = function (id, file, chatToken) {
FramedClient.prototype.createObject = function (id, file, chatToken, supportedImagesMimeTypes) {
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -153,3 +154,4 @@ var data;

file: file,
chatToken: chatToken || this.chatToken
chatToken: chatToken || this.chatToken,
supportedImagesMimeTypes: supportedImagesMimeTypes
};

@@ -166,4 +168,5 @@ return [4 /*yield*/, this.loadIframe()];

};
FramedClient.prototype.uploadDocument = function (documentId, file, chatToken) {
FramedClient.prototype.uploadDocument = function (documentId, file, chatToken, supportedImagesMimeTypes) {
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -180,3 +183,4 @@ var data;

file: file,
chatToken: chatToken || this.chatToken
chatToken: chatToken || this.chatToken,
supportedImagesMimeTypes: supportedImagesMimeTypes
};

@@ -193,4 +197,5 @@ return [4 /*yield*/, this.loadIframe()];

};
FramedClient.prototype.getViewStatus = function (fileMetadata, chatToken) {
FramedClient.prototype.getViewStatus = function (fileMetadata, chatToken, supportedImagesMimeTypes) {
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -204,3 +209,4 @@ var data;

fileMetadata: fileMetadata,
chatToken: chatToken || this.chatToken
chatToken: chatToken || this.chatToken,
supportedImagesMimeTypes: supportedImagesMimeTypes
};

@@ -217,4 +223,5 @@ return [4 /*yield*/, this.loadIframe()];

};
FramedClient.prototype.getView = function (fileMetadata, viewLocation, chatToken) {
FramedClient.prototype.getView = function (fileMetadata, viewLocation, chatToken, supportedImagesMimeTypes) {
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -229,3 +236,4 @@ var data;

viewLocation: viewLocation,
chatToken: chatToken || this.chatToken
chatToken: chatToken || this.chatToken,
supportedImagesMimeTypes: supportedImagesMimeTypes
};

@@ -232,0 +240,0 @@ return [4 /*yield*/, this.loadIframe()];

@@ -17,8 +17,8 @@ import AMSCreateObjectResponse from "./AMSCreateObjectResponse";

skypeTokenAuth(chatToken?: OmnichannelChatToken | null): Promise<Response>;
createObject(id: string, file: File, chatToken?: OmnichannelChatToken | null): Promise<AMSCreateObjectResponse>;
uploadDocument(documentId: string, file: File | AMSFileInfo, chatToken?: OmnichannelChatToken | null): Promise<FileMetadata>;
getViewStatus(fileMetadata: FileMetadata, chatToken?: OmnichannelChatToken | null): Promise<AMSViewStatusResponse>;
getView(fileMetadata: FileMetadata, viewLocation: string, chatToken?: OmnichannelChatToken | null): Promise<Blob>;
createObject(id: string, file: File, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<AMSCreateObjectResponse>;
uploadDocument(documentId: string, file: File | AMSFileInfo, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<FileMetadata>;
getViewStatus(fileMetadata: FileMetadata, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<AMSViewStatusResponse>;
getView(fileMetadata: FileMetadata, viewLocation: string, chatToken?: OmnichannelChatToken | null, supportedImagesMimeTypes?: string[]): Promise<Blob>;
fetchBlob(contentUrl: string): Promise<Blob>;
}
export default FramedlessClient;

@@ -115,5 +115,6 @@ "use strict";

};
FramedlessClient.prototype.createObject = function (id, file, chatToken) {
FramedlessClient.prototype.createObject = function (id, file, chatToken, supportedImagesMimeTypes) {
var _a;
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -125,3 +126,3 @@ var response, error_2;

_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, API_1.default.createObject(id, file, chatToken || this.chatToken)];
return [4 /*yield*/, API_1.default.createObject(id, file, chatToken || this.chatToken, supportedImagesMimeTypes)];
case 1:

@@ -143,5 +144,6 @@ response = _b.sent();

};
FramedlessClient.prototype.uploadDocument = function (documentId, file, chatToken) {
FramedlessClient.prototype.uploadDocument = function (documentId, file, chatToken, supportedImagesMimeTypes) {
var _a;
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -153,3 +155,3 @@ var response, error_3;

_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, API_1.default.uploadDocument(documentId, file, chatToken || this.chatToken)];
return [4 /*yield*/, API_1.default.uploadDocument(documentId, file, chatToken || this.chatToken, supportedImagesMimeTypes)];
case 1:

@@ -171,5 +173,6 @@ response = _b.sent();

};
FramedlessClient.prototype.getViewStatus = function (fileMetadata, chatToken) {
FramedlessClient.prototype.getViewStatus = function (fileMetadata, chatToken, supportedImagesMimeTypes) {
var _a;
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -181,3 +184,3 @@ var response, error_4;

_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, API_1.default.getViewStatus(fileMetadata, chatToken || this.chatToken)];
return [4 /*yield*/, API_1.default.getViewStatus(fileMetadata, chatToken || this.chatToken, supportedImagesMimeTypes)];
case 1:

@@ -199,5 +202,6 @@ response = _b.sent();

};
FramedlessClient.prototype.getView = function (fileMetadata, viewLocation, chatToken) {
FramedlessClient.prototype.getView = function (fileMetadata, viewLocation, chatToken, supportedImagesMimeTypes) {
var _a;
if (chatToken === void 0) { chatToken = null; }
if (supportedImagesMimeTypes === void 0) { supportedImagesMimeTypes = []; }
return __awaiter(this, void 0, void 0, function () {

@@ -209,3 +213,3 @@ var response, error_5;

_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, API_1.default.getView(fileMetadata, viewLocation, chatToken || this.chatToken)];
return [4 /*yield*/, API_1.default.getView(fileMetadata, viewLocation, chatToken || this.chatToken, supportedImagesMimeTypes)];
case 1:

@@ -212,0 +216,0 @@ response = _b.sent();

{
"name": "@microsoft/omnichannel-amsclient",
"version": "0.1.1",
"version": "0.1.2-main.6e7f0dc",
"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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc