@webex/internal-plugin-calendar 2.56.0 → 2.57.1

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.
@@ -61,12 +61,16 @@ var EncryptHelper = {
61
61
  });
62
62
  },
63
63
  /**
64
- * Encrypt free-busy request payload
64
+ * Encrypt free-busy request payload, if request payload only includes the sensitive data, like email, need to encrypt these reqeust parameters, and playload includes encrypt url.
65
+ * Otherwise, don't encrypt playload and without encrypt url,Due to calendar serivce will vaild both encrypt url and sensitive that are both present. if not, will return 400 bad reqeust to caller.
65
66
  * @param {object} [ctx] context
66
67
  * @param {object} [data] free busy payload data
67
68
  * @returns {Promise} Resolves with encrypted request payload
68
69
  * */
69
70
  encryptFreeBusyRequest: function encryptFreeBusyRequest(ctx, data) {
71
+ if (!data.emails || !(0, _isArray2.default)(data.emails)) {
72
+ return _promise.default.resolve();
73
+ }
70
74
  if (ctx.encryptionKeyUrl) {
71
75
  return _encryptFreeBusyPayload(data, ctx);
72
76
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_encryptTextProp","ctx","name","key","object","_promise","default","resolve","webex","internal","encryption","encryptText","uri","then","ciphertext","_encryptCalendarEventPayload","data","_assign","encryptionKeyUrl","encryptedAttendees","attendees","map","attendee","all","concat","_encryptFreeBusyPayload","promises","emails","_isArray2","item","index","push","EncryptHelper","encryptCalendarEventRequest","kms","createUnboundKeys","count","keys","_isArray3","encryptFreeBusyRequest","_default","exports"],"sources":["calendar.encrypt.helper.js"],"sourcesContent":["import {isArray} from 'lodash';\n\nconst _encryptTextProp = (ctx, name, key, object) => {\n if (!object[name]) {\n return Promise.resolve();\n }\n\n return ctx.webex.internal.encryption\n .encryptText(key.uri || key, object[name])\n .then((ciphertext) => {\n object[name] = ciphertext;\n });\n};\n\nconst _encryptCalendarEventPayload = (data, ctx) => {\n Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});\n\n const encryptedAttendees = data.attendees\n ? data.attendees.map((attendee) =>\n Promise.all([\n _encryptTextProp(ctx, 'displayName', data.encryptionKeyUrl, attendee),\n _encryptTextProp(ctx, 'email', data.encryptionKeyUrl, attendee),\n ])\n )\n : [];\n\n return Promise.all(\n [\n _encryptTextProp(ctx, 'subject', data.encryptionKeyUrl, data),\n _encryptTextProp(ctx, 'notes', data.encryptionKeyUrl, data),\n _encryptTextProp(ctx, 'webexOptions', data.encryptionKeyUrl, data),\n ].concat([encryptedAttendees])\n );\n};\n\nconst _encryptFreeBusyPayload = (data, ctx) => {\n Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});\n\n const promises = [];\n if (data.emails && Array.isArray(data.emails)) {\n data.emails.map((item, index) =>\n promises.push(\n ctx.webex.internal.encryption\n .encryptText(data.encryptionKeyUrl, item)\n .then((encryptText) => {\n data.emails[index] = encryptText;\n })\n )\n );\n }\n\n return Promise.all(promises);\n};\n\nconst EncryptHelper = {\n /**\n * Encrypt create / update calendar event request payload\n * @param {object} [ctx] context\n * @param {object} [data] meeting payload data\n * @returns {Promise} Resolves with encrypted request payload\n * */\n encryptCalendarEventRequest: (ctx, data) => {\n if (ctx.encryptionKeyUrl) {\n return _encryptCalendarEventPayload(data, ctx);\n }\n\n return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n ctx.encryptionKeyUrl = key.uri;\n\n return _encryptCalendarEventPayload(data, ctx);\n });\n },\n /**\n * Encrypt free-busy request payload\n * @param {object} [ctx] context\n * @param {object} [data] free busy payload data\n * @returns {Promise} Resolves with encrypted request payload\n * */\n encryptFreeBusyRequest: (ctx, data) => {\n if (ctx.encryptionKeyUrl) {\n return _encryptFreeBusyPayload(data, ctx);\n }\n\n return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n ctx.encryptionKeyUrl = key.uri;\n\n return _encryptFreeBusyPayload(data, ctx);\n });\n },\n};\n\nexport default EncryptHelper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CAACwB,GAAG,CAACC,iBAAiB,CAAC;MAACC,KAAK,EAAE;IAAC,CAAC,CAAC,CAACvB,IAAI,CAAC,UAACwB,IAAI,EAAK;MACpF,IAAMlC,GAAG,GAAG,IAAAmC,SAAA,CAAAhC,OAAA,EAAQ+B,IAAI,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAGA,IAAI;MAC1CpC,GAAG,CAACiB,gBAAgB,GAAGf,GAAG,CAACS,GAAG;MAE9B,OAAOG,4BAA4B,CAACC,IAAI,EAAEf,GAAG,CAAC;IAChD,CAAC,CAAC;EACJ,CAAC;EACD;AACF;AACA;AACA;AACA;AACA;EACEsC,sBAAsB,EAAE,SAAAA,uBAACtC,GAAG,EAAEe,IAAI,EAAK;IACrC,IAAIf,GAAG,CAACiB,gBAAgB,EAAE;MACxB,OAAOO,uBAAuB,CAACT,IAAI,EAAEf,GAAG,CAAC;IAC3C;IAEA,OAAOA,GAAG,CAACO,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACwB,GAAG,CAACC,iBAAiB,CAAC;MAACC,KAAK,EAAE;IAAC,CAAC,CAAC,CAACvB,IAAI,CAAC,UAACwB,IAAI,EAAK;MACpF,IAAMlC,GAAG,GAAG,IAAAmC,SAAA,CAAAhC,OAAA,EAAQ+B,IAAI,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAGA,IAAI;MAC1CpC,GAAG,CAACiB,gBAAgB,GAAGf,GAAG,CAACS,GAAG;MAE9B,OAAOa,uBAAuB,CAACT,IAAI,EAAEf,GAAG,CAAC;IAC3C,CAAC,CAAC;EACJ;AACF,CAAC;AAAC,IAAAuC,QAAA,GAEaR,aAAa;AAAAS,OAAA,CAAAnC,OAAA,GAAAkC,QAAA"}
1
+ {"version":3,"names":["_encryptTextProp","ctx","name","key","object","_promise","default","resolve","webex","internal","encryption","encryptText","uri","then","ciphertext","_encryptCalendarEventPayload","data","_assign","encryptionKeyUrl","encryptedAttendees","attendees","map","attendee","all","concat","_encryptFreeBusyPayload","promises","emails","_isArray2","item","index","push","EncryptHelper","encryptCalendarEventRequest","kms","createUnboundKeys","count","keys","_isArray3","encryptFreeBusyRequest","_default","exports"],"sources":["calendar.encrypt.helper.js"],"sourcesContent":["import {isArray} from 'lodash';\n\nconst _encryptTextProp = (ctx, name, key, object) => {\n if (!object[name]) {\n return Promise.resolve();\n }\n\n return ctx.webex.internal.encryption\n .encryptText(key.uri || key, object[name])\n .then((ciphertext) => {\n object[name] = ciphertext;\n });\n};\n\nconst _encryptCalendarEventPayload = (data, ctx) => {\n Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});\n\n const encryptedAttendees = data.attendees\n ? data.attendees.map((attendee) =>\n Promise.all([\n _encryptTextProp(ctx, 'displayName', data.encryptionKeyUrl, attendee),\n _encryptTextProp(ctx, 'email', data.encryptionKeyUrl, attendee),\n ])\n )\n : [];\n\n return Promise.all(\n [\n _encryptTextProp(ctx, 'subject', data.encryptionKeyUrl, data),\n _encryptTextProp(ctx, 'notes', data.encryptionKeyUrl, data),\n _encryptTextProp(ctx, 'webexOptions', data.encryptionKeyUrl, data),\n ].concat([encryptedAttendees])\n );\n};\n\nconst _encryptFreeBusyPayload = (data, ctx) => {\n Object.assign(data, {encryptionKeyUrl: ctx.encryptionKeyUrl});\n\n const promises = [];\n if (data.emails && Array.isArray(data.emails)) {\n data.emails.map((item, index) =>\n promises.push(\n ctx.webex.internal.encryption\n .encryptText(data.encryptionKeyUrl, item)\n .then((encryptText) => {\n data.emails[index] = encryptText;\n })\n )\n );\n }\n\n return Promise.all(promises);\n};\n\nconst EncryptHelper = {\n /**\n * Encrypt create / update calendar event request payload\n * @param {object} [ctx] context\n * @param {object} [data] meeting payload data\n * @returns {Promise} Resolves with encrypted request payload\n * */\n encryptCalendarEventRequest: (ctx, data) => {\n if (ctx.encryptionKeyUrl) {\n return _encryptCalendarEventPayload(data, ctx);\n }\n\n return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n ctx.encryptionKeyUrl = key.uri;\n\n return _encryptCalendarEventPayload(data, ctx);\n });\n },\n /**\n * Encrypt free-busy request payload, if request payload only includes the sensitive data, like email, need to encrypt these reqeust parameters, and playload includes encrypt url.\n * Otherwise, don't encrypt playload and without encrypt url,Due to calendar serivce will vaild both encrypt url and sensitive that are both present. if not, will return 400 bad reqeust to caller.\n * @param {object} [ctx] context\n * @param {object} [data] free busy payload data\n * @returns {Promise} Resolves with encrypted request payload\n * */\n encryptFreeBusyRequest: (ctx, data) => {\n if (!data.emails || !Array.isArray(data.emails)) {\n return Promise.resolve();\n }\n if (ctx.encryptionKeyUrl) {\n return _encryptFreeBusyPayload(data, ctx);\n }\n\n return ctx.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n ctx.encryptionKeyUrl = key.uri;\n\n return _encryptFreeBusyPayload(data, ctx);\n });\n },\n};\n\nexport default EncryptHelper;\n"],"mappings":";;;;;;;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAK;EACnD,IAAI,CAACA,MAAM,CAACF,IAAI,CAAC,EAAE;IACjB,OAAOG,QAAA,CAAAC,OAAA,CAAQC,OAAO,EAAE;EAC1B;EAEA,OAAON,GAAG,CAACO,KAAK,CAACC,QAAQ,CAACC,UAAU,CACjCC,WAAW,CAACR,GAAG,CAACS,GAAG,IAAIT,GAAG,EAAEC,MAAM,CAACF,IAAI,CAAC,CAAC,CACzCW,IAAI,CAAC,UAACC,UAAU,EAAK;IACpBV,MAAM,CAACF,IAAI,CAAC,GAAGY,UAAU;EAC3B,CAAC,CAAC;AACN,CAAC;AAED,IAAMC,4BAA4B,GAAG,SAA/BA,4BAA4BA,CAAIC,IAAI,EAAEf,GAAG,EAAK;EAClD,IAAAgB,OAAA,CAAAX,OAAA,EAAcU,IAAI,EA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C,OAAO,EAAE;IAC1B;IACA,IAAIN,GAAG,CAACiB,gBAAgB,EAAE;MACxB,OAAOO,uBAAuB,CAACT,IAAI,EAAEf,GAAG,CAAC;IAC3C;IAEA,OAAOA,GAAG,CAACO,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACwB,GAAG,CAACC,iBAAiB,CAAC;MAACC,KAAK,EAAE;IAAC,CAAC,CAAC,CAACvB,IAAI,CAAC,UAACwB,IAAI,EAAK;MACpF,IAAMlC,GAAG,GAAG,IAAAmC,SAAA,CAAAhC,OAAA,EAAQ+B,IAAI,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAGA,IAAI;MAC1CpC,GAAG,CAACiB,gBAAgB,GAAGf,GAAG,CAACS,GAAG;MAE9B,OAAOa,uBAAuB,CAACT,IAAI,EAAEf,GAAG,CAAC;IAC3C,CAAC,CAAC;EACJ;AACF,CAAC;AAAC,IAAAuC,QAAA,GAEaR,aAAa;AAAAS,OAAA,CAAAnC,OAAA,GAAAkC,QAAA"}
package/dist/calendar.js CHANGED
@@ -420,7 +420,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
420
420
  throw error;
421
421
  });
422
422
  },
423
- version: "2.56.0"
423
+ version: "2.57.1"
424
424
  });
425
425
  var _default = Calendar;
426
426
  exports.default = _default;
package/package.json CHANGED
@@ -19,27 +19,27 @@
19
19
  "envify"
20
20
  ]
21
21
  },
22
- "version": "2.56.0",
22
+ "version": "2.57.1",
23
23
  "devDependencies": {
24
24
  "@babel/core": "^7.17.10",
25
- "@webex/babel-config-legacy": "2.56.0",
26
- "@webex/eslint-config-legacy": "2.56.0",
27
- "@webex/jest-config-legacy": "2.56.0",
28
- "@webex/legacy-tools": "2.56.0",
29
- "@webex/test-helper-chai": "2.56.0",
30
- "@webex/test-helper-mocha": "2.56.0",
31
- "@webex/test-helper-mock-webex": "2.56.0",
32
- "@webex/test-helper-retry": "2.56.0",
33
- "@webex/test-helper-test-users": "2.56.0",
25
+ "@webex/babel-config-legacy": "2.57.1",
26
+ "@webex/eslint-config-legacy": "2.57.1",
27
+ "@webex/jest-config-legacy": "2.57.1",
28
+ "@webex/legacy-tools": "2.57.1",
29
+ "@webex/test-helper-chai": "2.57.1",
30
+ "@webex/test-helper-mocha": "2.57.1",
31
+ "@webex/test-helper-mock-webex": "2.57.1",
32
+ "@webex/test-helper-retry": "2.57.1",
33
+ "@webex/test-helper-test-users": "2.57.1",
34
34
  "eslint": "^8.24.0",
35
35
  "prettier": "^2.7.1",
36
36
  "sinon": "^9.2.4"
37
37
  },
38
38
  "dependencies": {
39
- "@webex/internal-plugin-conversation": "2.56.0",
40
- "@webex/internal-plugin-device": "2.56.0",
41
- "@webex/internal-plugin-encryption": "2.56.0",
42
- "@webex/webex-core": "2.56.0",
39
+ "@webex/internal-plugin-conversation": "2.57.1",
40
+ "@webex/internal-plugin-device": "2.57.1",
41
+ "@webex/internal-plugin-encryption": "2.57.1",
42
+ "@webex/webex-core": "2.57.1",
43
43
  "lodash": "^4.17.21",
44
44
  "uuid": "^3.3.2"
45
45
  },
@@ -72,12 +72,16 @@ const EncryptHelper = {
72
72
  });
73
73
  },
74
74
  /**
75
- * Encrypt free-busy request payload
75
+ * Encrypt free-busy request payload, if request payload only includes the sensitive data, like email, need to encrypt these reqeust parameters, and playload includes encrypt url.
76
+ * Otherwise, don't encrypt playload and without encrypt url,Due to calendar serivce will vaild both encrypt url and sensitive that are both present. if not, will return 400 bad reqeust to caller.
76
77
  * @param {object} [ctx] context
77
78
  * @param {object} [data] free busy payload data
78
79
  * @returns {Promise} Resolves with encrypted request payload
79
80
  * */
80
81
  encryptFreeBusyRequest: (ctx, data) => {
82
+ if (!data.emails || !Array.isArray(data.emails)) {
83
+ return Promise.resolve();
84
+ }
81
85
  if (ctx.encryptionKeyUrl) {
82
86
  return _encryptFreeBusyPayload(data, ctx);
83
87
  }
@@ -0,0 +1,52 @@
1
+ import sinon from 'sinon';
2
+ import {expect} from '@webex/test-helper-chai';
3
+ import EncryptHelper from '@webex/internal-plugin-calendar/src/calendar.encrypt.helper';
4
+ describe('internal-plugin-calendar', () => {
5
+ describe('encryptHelper', () => {
6
+ let ctx;
7
+ beforeEach(() => {
8
+ ctx = {
9
+ encryptionKeyUrl: 'http://example.com/encryption-key',
10
+ webex: {
11
+ internal: {
12
+ encryption: {
13
+ encryptText: sinon.stub(),
14
+ },
15
+ },
16
+ },
17
+ };
18
+ });
19
+
20
+ afterEach(() => {
21
+ sinon.restore();
22
+ });
23
+
24
+ it('#encryptFreebusyRequestData with emails should ', async () => {
25
+ const freeBusyRequest = {
26
+ start: '20230712T10:20:00Z',
27
+ end: '20230712T20:20:00Z',
28
+ emails: ['test@webex.com'],
29
+ };
30
+ const expectedCiphertext = 'some encrpty data';
31
+ ctx.webex.internal.encryption.encryptText.callsFake((key, ciphertext) =>
32
+ Promise.resolve(expectedCiphertext)
33
+ );
34
+ await EncryptHelper.encryptFreeBusyRequest(ctx, freeBusyRequest);
35
+ expect(freeBusyRequest.emails[0]).to.be.equal(expectedCiphertext);
36
+ });
37
+
38
+ it('#encryptFreebusyRequestData not include emails, but include ids- should b', async () => {
39
+ const freeBusyRequest = {
40
+ start: '20230712T10:20:00Z',
41
+ end: '20230712T20:20:00Z',
42
+ userIds: ['91aee1231'],
43
+ };
44
+ const expectedCiphertext = '91aee1231';
45
+ ctx.webex.internal.encryption.encryptText.callsFake((key, ciphertext) =>
46
+ Promise.resolve(expectedCiphertext)
47
+ );
48
+ await EncryptHelper.encryptFreeBusyRequest(ctx, freeBusyRequest);
49
+ expect(freeBusyRequest.userIds[0]).to.equal(expectedCiphertext);
50
+ });
51
+ });
52
+ });