launchdarkly-node-client-sdk 3.0.2 → 3.2.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.
@@ -0,0 +1,10 @@
1
+ name: 'Close stale issues and PRs'
2
+ on:
3
+ workflow_dispatch:
4
+ schedule:
5
+ # Happen once per day at 1:30 AM
6
+ - cron: '30 1 * * *'
7
+
8
+ jobs:
9
+ sdk-close-stale:
10
+ uses: launchdarkly/gh-actions/.github/workflows/sdk-stale.yml@main
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 1,
3
+ "sdks": {
4
+ "node-client-sdk": {
5
+ "name": "Node.js Client SDK",
6
+ "type": "client-side",
7
+ "languages": [
8
+ "JavaScript", "TypeScript"
9
+ ]
10
+ }
11
+ }
12
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to the LaunchDarkly Client-Side SDK for Node.js will be documented in this file.
4
4
 
5
+ ## [3.1.0] - 2024-03-19
6
+ ### Changed:
7
+ - Redact anonymous attributes within feature events
8
+ - Always inline contexts for feature events
9
+
10
+ ## [3.0.2] - 2023-03-21
11
+ ### Changed:
12
+ - Update `LDContext` to allow for key to be optional. This is used when making an anonymous context with a generated key.
13
+
5
14
  ## [3.0.1] - 2023-02-15
6
15
  ### Changed:
7
16
  - Upgrade to `js-sdk-common` version `5.0.2`. This removes usage of optional chaining (`?.`) to allow for use with older transpilers.
@@ -9,10 +18,6 @@ All notable changes to the LaunchDarkly Client-Side SDK for Node.js will be docu
9
18
  ## [3.0.0] - 2023-01-12
10
19
  The latest version of this SDK supports LaunchDarkly's new custom contexts feature. Contexts are an evolution of a previously-existing concept, "users." Contexts let you create targeting rules for feature flags based on a variety of different information, including attributes pertaining to users, organizations, devices, and more. You can even combine contexts to create "multi-contexts."
11
20
 
12
- This feature is only available to members of LaunchDarkly's Early Access Program (EAP). If you're in the EAP, you can use contexts by updating your SDK to the latest version and, if applicable, updating your Relay Proxy. Outdated SDK versions do not support contexts, and will cause unpredictable flag evaluation behavior.
13
-
14
- If you are not in the EAP, only use single contexts of kind "user", or continue to use the user type if available. If you try to create contexts, the context will be sent to LaunchDarkly, but any data not related to the user object will be ignored.
15
-
16
21
  For detailed information about this version, please refer to the list below. For information on how to upgrade from the previous version, please read the [migration guide](https://docs.launchdarkly.com/sdk/client-side/node-js/migration-2-to-3).
17
22
 
18
23
  ### Added:
package/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # Repository Maintainers
2
+ * @launchdarkly/team-sdk
package/README.md CHANGED
@@ -6,11 +6,11 @@
6
6
 
7
7
  The LaunchDarkly Client-Side SDK for Node.js is designed primarily for use by code that is deployed to an end user, such as in a desktop application or a smart device. It follows the client-side LaunchDarkly model for single-user contexts (much like our mobile or JavaScript SDKs). It is not intended for use in multi-user systems such as web servers and applications.
8
8
 
9
- For using LaunchDarkly in *server-side* Node.js applications, refer to our [Server-side Node.js SDK](https://github.com/launchdarkly/node-server-sdk).
9
+ For using LaunchDarkly in *server-side* Node.js applications, refer to our [Server-side Node.js SDK](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/server-node).
10
10
 
11
11
  ## LaunchDarkly overview
12
12
 
13
- [LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
13
+ [LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
14
14
 
15
15
  [![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
16
16
 
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Reporting and Fixing Security Issues
2
+
3
+ Please report all security issues to the LaunchDarkly security team by submitting a bug bounty report to our [HackerOne program](https://hackerone.com/launchdarkly?type=team). LaunchDarkly will triage and address all valid security issues following the response targets defined in our program policy. Valid security issues may be eligible for a bounty.
4
+
5
+ Please do not open issues or pull requests for security issues. This makes the problem immediately visible to everyone, including potentially malicious actors.
@@ -24,6 +24,8 @@ app.get('/', (req, res) => {
24
24
  'service-endpoints',
25
25
  'tags',
26
26
  'user-type',
27
+ 'inline-context',
28
+ 'anonymous-redaction',
27
29
  ],
28
30
  });
29
31
  });
@@ -19,7 +19,7 @@ function makeSdkConfig(options, tag) {
19
19
  useReport: options.clientSide.useReport,
20
20
  sendEventsOnlyForVariation: true,
21
21
  };
22
-
22
+
23
23
  if (options.serviceEndpoints) {
24
24
  cf.streamUrl = options.serviceEndpoints.streaming;
25
25
  cf.baseUrl = options.serviceEndpoints.polling;
@@ -72,7 +72,7 @@ async function newSdkClientEntity(options) {
72
72
  const log = Log(options.tag);
73
73
 
74
74
  log.info('Creating client with configuration: ' + JSON.stringify(options.configuration));
75
-
75
+
76
76
  const timeout =
77
77
  options.configuration.startWaitTimeMs !== null && options.configuration.startWaitTimeMs !== undefined
78
78
  ? options.configuration.startWaitTimeMs
@@ -88,10 +88,10 @@ async function newSdkClientEntity(options) {
88
88
  );
89
89
  let failed = false;
90
90
  try {
91
- await Promise.race([client.waitForInitialization(), new Promise((resolve, reject) => setTimeout(reject, timeout))]);
91
+ await client.waitForInitialization(timeout);
92
92
  } catch (_) {
93
- // we get here if waitForInitialization() rejects or if we timed out
94
- failed = true
93
+ // we get here if waitForInitialization(5) rejects or if we timed out
94
+ failed = true;
95
95
  }
96
96
  if (failed && !options.configuration.initCanFail) {
97
97
  client.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchdarkly-node-client-sdk",
3
- "version": "3.0.2",
3
+ "version": "3.2.0",
4
4
  "description": "LaunchDarkly Client-Side SDK for Node.js",
5
5
  "author": "LaunchDarkly <team@launchdarkly.com>",
6
6
  "license": "Apache-2.0",
@@ -64,8 +64,8 @@
64
64
  "outputName": "junit.xml"
65
65
  },
66
66
  "dependencies": {
67
- "launchdarkly-eventsource": "1.4.3",
68
- "launchdarkly-js-sdk-common": "5.0.3",
67
+ "launchdarkly-eventsource": "2.0.2",
68
+ "launchdarkly-js-sdk-common": "5.2.0",
69
69
  "node-localstorage": "^1.3.1"
70
70
  },
71
71
  "repository": {
@@ -18,7 +18,7 @@ describe('LDClient', () => {
18
18
  const client = LDClient.initialize(envName, context, config);
19
19
  await withCloseable(client, async () => {
20
20
  const data = { thing: 'stuff' };
21
- await client.waitForInitialization();
21
+ await client.waitForInitialization(5);
22
22
 
23
23
  client.track('eventkey', data);
24
24
  await client.flush();
@@ -36,7 +36,7 @@ describe('LDClient streaming', () => {
36
36
  };
37
37
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
38
38
  const changeEvents = eventSink(client, 'change:flag');
39
- await client.waitForInitialization();
39
+ await client.waitForInitialization(5);
40
40
 
41
41
  const value = await changeEvents.take();
42
42
  expect(value).toEqual(['yes', undefined]); // second parameter to change event is old value
@@ -64,7 +64,7 @@ describe('LDClient streaming', () => {
64
64
  };
65
65
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
66
66
  const changeEvents = eventSink(client, 'change:flag');
67
- await client.waitForInitialization();
67
+ await client.waitForInitialization(5);
68
68
 
69
69
  const value = await changeEvents.take();
70
70
  expect(value).toEqual(['yes', undefined]); // second parameter to change event is old value
@@ -21,7 +21,7 @@ describe('LDClient', () => {
21
21
  server.byDefault(TestHttpHandlers.respondJson({}));
22
22
  const config = { baseUrl: server.url, sendEvents: false };
23
23
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
24
- await client.waitForInitialization();
24
+ await client.waitForInitialization(5);
25
25
  });
26
26
  });
27
27
  });
@@ -31,7 +31,7 @@ describe('LDClient', () => {
31
31
  server.byDefault(TestHttpHandlers.respondJson({}));
32
32
  const config = { baseUrl: server.url, sendEvents: false };
33
33
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
34
- await client.waitForInitialization();
34
+ await client.waitForInitialization(5);
35
35
 
36
36
  expect(server.requestCount()).toEqual(1);
37
37
  const req = await server.nextRequest();
@@ -51,7 +51,7 @@ describe('LDClient', () => {
51
51
  };
52
52
  const config = { bootstrap: {}, sendEvents: false, logger: logger };
53
53
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
54
- await client.waitForInitialization();
54
+ await client.waitForInitialization(5);
55
55
 
56
56
  client.track('whatever');
57
57
  expect(logger.warn).not.toHaveBeenCalled();
@@ -32,7 +32,7 @@ describe('LDClient TLS configuration', () => {
32
32
  diagnosticOptOut: true,
33
33
  };
34
34
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
35
- await client.waitForInitialization();
35
+ await client.waitForInitialization(5);
36
36
  });
37
37
  });
38
38
  });
@@ -47,7 +47,7 @@ describe('LDClient TLS configuration', () => {
47
47
  diagnosticOptOut: true,
48
48
  };
49
49
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
50
- await expect(client.waitForInitialization()).rejects.toThrow(/network error.*self[- ]signed/);
50
+ await expect(client.waitForInitialization(5)).rejects.toThrow(/network error.*self[- ]signed/);
51
51
  });
52
52
  });
53
53
  });
@@ -71,7 +71,7 @@ describe('LDClient TLS configuration', () => {
71
71
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
72
72
  const changeEvents = eventSink(client, 'change:flag');
73
73
 
74
- await client.waitForInitialization();
74
+ await client.waitForInitialization(5);
75
75
 
76
76
  const value = await changeEvents.take();
77
77
  expect(value).toEqual(['yes', undefined]); // second parameter to change event is old value
@@ -92,7 +92,7 @@ describe('LDClient TLS configuration', () => {
92
92
  diagnosticOptOut: true,
93
93
  };
94
94
  await withCloseable(LDClient.initialize(envName, context, config), async client => {
95
- await client.waitForInitialization();
95
+ await client.waitForInitialization(5);
96
96
  await client.flush();
97
97
 
98
98
  expect(server.requestCount()).toEqual(1);
package/test-types.ts CHANGED
@@ -75,7 +75,7 @@ const multiContext: ld.LDContext = {
75
75
  const client: ld.LDClient = ld.initialize('env', user, allOptions);
76
76
 
77
77
  client.waitUntilReady().then(() => {});
78
- client.waitForInitialization().then(() => {});
78
+ client.waitForInitialization(5).then(() => {});
79
79
 
80
80
  client.identify(user).then(() => {});
81
81
  client.identify(user, undefined, () => {});