@splitsoftware/splitio-commons 1.2.1-rc.6 → 1.2.1-rc.7

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SSEClient = void 0;
4
+ var lang_1 = require("../../../utils/lang");
4
5
  var VERSION = '1.1';
5
6
  var CONTROL_CHANNEL_REGEX = /^control_/;
6
7
  /**
@@ -11,7 +12,7 @@ var CONTROL_CHANNEL_REGEX = /^control_/;
11
12
  */
12
13
  function buildSSEHeaders(settings) {
13
14
  var headers = {
14
- SplitSDKClientKey: settings.core.authorizationKey.slice(-4),
15
+ SplitSDKClientKey: (0, lang_1.isString)(settings.core.authorizationKey) ? settings.core.authorizationKey.slice(-4) : '',
15
16
  SplitSDKVersion: settings.version,
16
17
  };
17
18
  // ip and hostname are false if IPAddressesEnabled is false
@@ -1,3 +1,4 @@
1
+ import { isString } from '../../../utils/lang';
1
2
  var VERSION = '1.1';
2
3
  var CONTROL_CHANNEL_REGEX = /^control_/;
3
4
  /**
@@ -8,7 +9,7 @@ var CONTROL_CHANNEL_REGEX = /^control_/;
8
9
  */
9
10
  function buildSSEHeaders(settings) {
10
11
  var headers = {
11
- SplitSDKClientKey: settings.core.authorizationKey.slice(-4),
12
+ SplitSDKClientKey: isString(settings.core.authorizationKey) ? settings.core.authorizationKey.slice(-4) : '',
12
13
  SplitSDKVersion: settings.version,
13
14
  };
14
15
  // ip and hostname are false if IPAddressesEnabled is false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.2.1-rc.6",
3
+ "version": "1.2.1-rc.7",
4
4
  "description": "Split Javascript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -1,5 +1,6 @@
1
1
  import { IEventSourceConstructor } from '../../../services/types';
2
2
  import { ISettings } from '../../../types';
3
+ import { isString } from '../../../utils/lang';
3
4
  import { IAuthTokenPushEnabled } from '../AuthClient/types';
4
5
  import { ISSEClient, ISseEventHandler } from './types';
5
6
 
@@ -15,7 +16,7 @@ const CONTROL_CHANNEL_REGEX = /^control_/;
15
16
  */
16
17
  function buildSSEHeaders(settings: ISettings) {
17
18
  const headers: Record<string, string> = {
18
- SplitSDKClientKey: settings.core.authorizationKey.slice(-4),
19
+ SplitSDKClientKey: isString(settings.core.authorizationKey) ? settings.core.authorizationKey.slice(-4) : '',
19
20
  SplitSDKVersion: settings.version,
20
21
  };
21
22
 
@@ -1,11 +1,12 @@
1
1
  import { ERROR_INVALID_CONFIG_PARAM } from '../../logger/constants';
2
2
  import { ILogger } from '../../logger/types';
3
+ import { ConsentStatus } from '../../types';
3
4
  import { CONSENT_DECLINED, CONSENT_GRANTED, CONSENT_UNKNOWN } from '../constants';
4
5
  import { stringToUpperCase } from '../lang';
5
6
 
6
7
  const userConsentValues = [CONSENT_DECLINED, CONSENT_GRANTED, CONSENT_UNKNOWN];
7
8
 
8
- export function validateConsent({ userConsent, log }: { userConsent: any, log: ILogger }) {
9
+ export function validateConsent({ userConsent, log }: { userConsent?: any, log: ILogger }): ConsentStatus {
9
10
  userConsent = stringToUpperCase(userConsent);
10
11
 
11
12
  if (userConsentValues.indexOf(userConsent) > -1) return userConsent;
@@ -1,5 +1,6 @@
1
1
  import { ILogger } from '../../logger/types';
2
+ import { ConsentStatus } from '../../types';
2
3
  export declare function validateConsent({ userConsent, log }: {
3
- userConsent: any;
4
+ userConsent?: any;
4
5
  log: ILogger;
5
- }): any;
6
+ }): ConsentStatus;