botframework-webchat-core 4.14.1 → 4.15.0

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.
Files changed (75) hide show
  1. package/.eslintrc.yml +4 -198
  2. package/.prettierrc.yml +1 -1
  3. package/lib/actions/setNotification.js +1 -1
  4. package/lib/createStore.d.ts.map +1 -1
  5. package/lib/createStore.js +5 -5
  6. package/lib/index.d.ts +2 -1
  7. package/lib/index.d.ts.map +1 -1
  8. package/lib/index.js +10 -2
  9. package/lib/reducers/notifications.js +21 -14
  10. package/lib/sagas/connectionStatusToNotificationSaga.js +1 -1
  11. package/lib/sagas/queueIncomingActivitySaga.js +1 -1
  12. package/lib/sagas/sendMessageBackToPostActivitySaga.js +1 -1
  13. package/lib/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +1 -1
  14. package/lib/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +1 -1
  15. package/lib/sagas/startSpeakActivityOnPostActivitySaga.js +1 -1
  16. package/lib/sagas/stopSpeakingActivityOnInputSaga.js +1 -1
  17. package/lib/sagas/submitSendBoxSaga.js +1 -1
  18. package/lib/selectors/combineSelectors.js +7 -2
  19. package/lib/types/external/DirectLineActivity.d.ts +1 -1
  20. package/lib/types/external/DirectLineActivity.d.ts.map +1 -1
  21. package/lib/types/external/DirectLineAnimationCard.d.ts.map +1 -1
  22. package/lib/types/external/DirectLineAttachment.d.ts.map +1 -1
  23. package/lib/types/external/DirectLineAudioCard.d.ts.map +1 -1
  24. package/lib/types/external/DirectLineHeroCard.d.ts.map +1 -1
  25. package/lib/types/external/DirectLineJSBotConnection.d.ts.map +1 -1
  26. package/lib/types/external/DirectLineOAuthCard.d.ts.map +1 -1
  27. package/lib/types/external/DirectLineReceiptCard.d.ts.map +1 -1
  28. package/lib/types/external/DirectLineSignInCard.d.ts.map +1 -1
  29. package/lib/types/external/DirectLineSuggestedAction.d.ts.map +1 -1
  30. package/lib/types/external/DirectLineThumbnailCard.d.ts.map +1 -1
  31. package/lib/types/external/DirectLineVideoCard.d.ts.map +1 -1
  32. package/lib/utils/deleteKey.js +2 -3
  33. package/lib/utils/isForbiddenPropertyName.d.ts +2 -0
  34. package/lib/utils/isForbiddenPropertyName.d.ts.map +1 -0
  35. package/lib/utils/isForbiddenPropertyName.js +21 -0
  36. package/lib/utils/mime-wrapper.js +2 -4
  37. package/lib/utils/uniqueID.js +1 -1
  38. package/package.json +6 -13
  39. package/src/__tests__/detectSlowConnectionSaga.spec.js +1 -1
  40. package/src/__tests__/observeOnce.spec.js +3 -3
  41. package/src/actions/setNotification.js +8 -2
  42. package/src/createStore.ts +4 -4
  43. package/src/index.ts +2 -0
  44. package/src/reducers/notifications.js +22 -16
  45. package/src/sagas/connectionStatusToNotificationSaga.js +1 -1
  46. package/src/sagas/queueIncomingActivitySaga.js +40 -39
  47. package/src/sagas/sendMessageBackToPostActivitySaga.js +0 -1
  48. package/src/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +1 -1
  49. package/src/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +1 -1
  50. package/src/sagas/startSpeakActivityOnPostActivitySaga.js +1 -1
  51. package/src/sagas/stopSpeakingActivityOnInputSaga.js +1 -1
  52. package/src/sagas/submitSendBoxSaga.js +1 -1
  53. package/src/selectors/combineSelectors.js +9 -1
  54. package/src/types/external/DirectLineActivity.ts +3 -2
  55. package/src/types/external/DirectLineAnimationCard.ts +0 -1
  56. package/src/types/external/DirectLineAttachment.ts +0 -1
  57. package/src/types/external/DirectLineAudioCard.ts +0 -1
  58. package/src/types/external/DirectLineHeroCard.ts +0 -1
  59. package/src/types/external/DirectLineJSBotConnection.ts +0 -1
  60. package/src/types/external/DirectLineOAuthCard.ts +0 -1
  61. package/src/types/external/DirectLineReceiptCard.ts +0 -1
  62. package/src/types/external/DirectLineSignInCard.ts +0 -1
  63. package/src/types/external/DirectLineSuggestedAction.ts +0 -1
  64. package/src/types/external/DirectLineThumbnailCard.ts +0 -1
  65. package/src/types/external/DirectLineVideoCard.ts +0 -1
  66. package/src/utils/dateToLocaleISOString.chatham.spec.js +1 -0
  67. package/src/utils/dateToLocaleISOString.japan.spec.js +1 -0
  68. package/src/utils/dateToLocaleISOString.pacific.spec.js +1 -0
  69. package/src/utils/dateToLocaleISOString.utc.spec.js +2 -0
  70. package/src/utils/deleteKey.js +1 -3
  71. package/src/utils/isForbiddenPropertyName.spec.js +6 -0
  72. package/src/utils/isForbiddenPropertyName.ts +33 -0
  73. package/src/utils/mime-wrapper.js +1 -2
  74. package/src/utils/uniqueID.js +1 -6
  75. package/.eslintignore +0 -9
@@ -1,8 +1,16 @@
1
+ import isForbiddenPropertyName from '../utils/isForbiddenPropertyName';
2
+
1
3
  export default function combineSelectors(selectors) {
2
4
  if (Array.isArray(selectors)) {
3
5
  return state => selectors.reduce((combinedState, selector) => [...combinedState, selector(state)], []);
4
6
  }
5
7
 
6
8
  return state =>
7
- Object.keys(selectors).reduce((combinedState, key) => ({ ...combinedState, [key]: selectors[key](state) }), {});
9
+ Object.keys(selectors).reduce(
10
+ (combinedState, key) =>
11
+ // Mitigated through denylisting.
12
+ // eslint-disable-next-line security/detect-object-injection
13
+ isForbiddenPropertyName(key) ? combinedState : { ...combinedState, [key]: selectors[key](state) },
14
+ {}
15
+ );
8
16
  }
@@ -1,6 +1,7 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- type DirectLineActivity = any;
3
+ // Until we fully typed out DirectLineActivity, we need to use "any" here.
4
+ // We only know the DirectLineActivity must be a map, and not other primitive types.
5
+ type DirectLineActivity = Exclude<any, [] | boolean | Function | number | string>;
5
6
 
6
7
  export default DirectLineActivity;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineAnimationCard = any;
5
4
 
6
5
  export default DirectLineAnimationCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineAttachment = any;
5
4
 
6
5
  export default DirectLineAttachment;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineAudioCard = any;
5
4
 
6
5
  export default DirectLineAudioCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineHeroCard = any;
5
4
 
6
5
  export default DirectLineHeroCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineJSBotConnection = any;
5
4
 
6
5
  export default DirectLineJSBotConnection;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineOAuthCard = any;
5
4
 
6
5
  export default DirectLineOAuthCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineReceiptCard = any;
5
4
 
6
5
  export default DirectLineReceiptCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineSignInCard = any;
5
4
 
6
5
  export default DirectLineSignInCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineSuggestedAction = any;
5
4
 
6
5
  export default DirectLineSuggestedAction;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineThumbnailCard = any;
5
4
 
6
5
  export default DirectLineThumbnailCard;
@@ -1,6 +1,5 @@
1
1
  // TODO: [P1] #3953 We should fully type it out.
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  type DirectLineVideoCard = any;
5
4
 
6
5
  export default DirectLineVideoCard;
@@ -6,6 +6,7 @@
6
6
  import dateToLocaleISOString from './dateToLocaleISOString';
7
7
 
8
8
  test('formatting a time in Chatham Islands timezone', () => {
9
+ // eslint-disable-next-line no-magic-numbers
9
10
  const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
10
11
  const actual = dateToLocaleISOString(date);
11
12
 
@@ -6,6 +6,7 @@
6
6
  import dateToLocaleISOString from './dateToLocaleISOString';
7
7
 
8
8
  test('formatting a time in Japan timezone', () => {
9
+ // eslint-disable-next-line no-magic-numbers
9
10
  const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
10
11
  const actual = dateToLocaleISOString(date);
11
12
 
@@ -6,6 +6,7 @@
6
6
  import dateToLocaleISOString from './dateToLocaleISOString';
7
7
 
8
8
  test('formatting a time in Pacific Standard Time timezone', () => {
9
+ // eslint-disable-next-line no-magic-numbers
9
10
  const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
10
11
  const actual = dateToLocaleISOString(date);
11
12
 
@@ -6,6 +6,7 @@
6
6
  import dateToLocaleISOString from './dateToLocaleISOString';
7
7
 
8
8
  test('formatting a time in UTC timezone', () => {
9
+ // eslint-disable-next-line no-magic-numbers
9
10
  const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 567));
10
11
  const actual = dateToLocaleISOString(date);
11
12
 
@@ -13,6 +14,7 @@ test('formatting a time in UTC timezone', () => {
13
14
  });
14
15
 
15
16
  test('formatting a time in UTC timezone with zero milliseconds', () => {
17
+ // eslint-disable-next-line no-magic-numbers
16
18
  const date = new Date(Date.UTC(2000, 0, 1, 0, 12, 34, 0));
17
19
  const actual = dateToLocaleISOString(date);
18
20
 
@@ -1,11 +1,9 @@
1
- /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^deleted$" }] */
2
-
3
1
  export default function deleteKey(map, key) {
4
2
  if (!map) {
5
3
  return map;
6
4
  }
7
5
 
8
- const { [key]: deleted, ...nextMap } = map;
6
+ const { [key]: _deleted, ...nextMap } = map;
9
7
 
10
8
  return nextMap;
11
9
  }
@@ -0,0 +1,6 @@
1
+ import isForbiddenPropertyName from './isForbiddenPropertyName';
2
+
3
+ test('should forbid "__proto__"', () => expect(isForbiddenPropertyName('__proto__')).toBeTruthy());
4
+ test('should forbid "constructor"', () => expect(isForbiddenPropertyName('constructor')).toBeTruthy());
5
+ test('should forbid "prototype"', () => expect(isForbiddenPropertyName('prototype')).toBeTruthy());
6
+ test('should not forbid "abc"', () => expect(isForbiddenPropertyName('abc')).toBeFalsy());
@@ -0,0 +1,33 @@
1
+ let FORBIDDEN_PROPERTY_NAMES;
2
+
3
+ function getForbiddenPropertyNames(): string[] {
4
+ return (
5
+ FORBIDDEN_PROPERTY_NAMES ||
6
+ (FORBIDDEN_PROPERTY_NAMES = Object.freeze(
7
+ Array.from(
8
+ new Set([
9
+ // As-of writing, `Object.prototype` includes:
10
+ // __defineGetter__
11
+ // __defineSetter__
12
+ // __lookupGetter__
13
+ // __lookupSetter
14
+ // __proto__
15
+ // constructor
16
+ // hasOwnProperty
17
+ // isPrototypeOf
18
+ // propertyIsEnumerable
19
+ // toLocaleString
20
+ // toString
21
+ // valueOf
22
+ ...Object.getOwnPropertyNames(Object.prototype),
23
+
24
+ 'prototype'
25
+ ])
26
+ )
27
+ ))
28
+ );
29
+ }
30
+
31
+ export default function isForbiddenPropertyName(propertyName: string): boolean {
32
+ return getForbiddenPropertyNames().includes(propertyName);
33
+ }
@@ -1,5 +1,4 @@
1
- /* eslint no-undef: "off"*/
2
- /* eslint node/global-require: "off"*/
1
+ /* eslint no-undef: "off" */
3
2
 
4
3
  // We adopted the work from mime-wrapper, at https://github.com/marlon360/mime-wrapper.
5
4
 
@@ -3,10 +3,5 @@
3
3
  import random from 'math-random';
4
4
 
5
5
  export default function uniqueID() {
6
- return (
7
- Date.now() +
8
- random()
9
- .toString(36)
10
- .substr(2)
11
- );
6
+ return Date.now() + random().toString(36).substr(2);
12
7
  }
package/.eslintignore DELETED
@@ -1,9 +0,0 @@
1
- /src/__tests__/**/*
2
- /src/**/*.spec.js
3
- /src/**/*.spec.jsx
4
- /src/**/*.spec.ts
5
- /src/**/*.spec.tsx
6
- /src/**/*.test.js
7
- /src/**/*.test.jsx
8
- /src/**/*.test.ts
9
- /src/**/*.test.tsx