launchdarkly-node-client-sdk 3.3.0 → 3.4.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.
@@ -43,5 +43,6 @@ jobs:
43
43
  with:
44
44
  test_service_port: ${{ env.TEST_SERVICE_PORT }}
45
45
  token: ${{ secrets.GITHUB_TOKEN }}
46
+ extra_params: '--skip-from=${{ github.workspace }}/contract-tests/suppressions.txt'
46
47
  - name: Build Docs
47
48
  run: npm run doc
@@ -7,6 +7,9 @@ on:
7
7
  - edited
8
8
  - synchronize
9
9
 
10
+ permissions:
11
+ pull-requests: read
12
+
10
13
  jobs:
11
14
  lint-pr-title:
12
15
  uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
@@ -8,10 +8,13 @@ on:
8
8
  jobs:
9
9
  release-please:
10
10
  runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ pull-requests: write
11
14
  outputs:
12
15
  release_created: ${{ steps.release.outputs.release_created }}
13
16
  steps:
14
- - uses: googleapis/release-please-action@v4
17
+ - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
15
18
  id: release
16
19
  with:
17
20
  token: ${{secrets.GITHUB_TOKEN}}
@@ -28,14 +31,13 @@ jobs:
28
31
 
29
32
  - uses: actions/setup-node@v4
30
33
  with:
31
- node-version: 20.x
34
+ node-version: 24.x
32
35
  registry-url: 'https://registry.npmjs.org'
33
36
 
34
- - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
35
- name: 'Get NPM token'
36
- with:
37
- aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
38
- ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
37
+ - name: Update NPM
38
+ shell: bash
39
+ # Must be greater than 11.5.1 for OIDC.
40
+ run: npm install -g npm@11.6.2
39
41
 
40
42
  - name: Install Dependencies
41
43
  run: npm install
@@ -1,9 +1,13 @@
1
- name: 'Close stale issues and PRs'
1
+ name: "Close stale issues and PRs"
2
2
  on:
3
3
  workflow_dispatch:
4
4
  schedule:
5
5
  # Happen once per day at 1:30 AM
6
- - cron: '30 1 * * *'
6
+ - cron: "30 1 * * *"
7
+
8
+ permissions:
9
+ issues: write
10
+ pull-requests: write
7
11
 
8
12
  jobs:
9
13
  sdk-close-stale:
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "3.3.0"
2
+ ".": "3.4.0"
3
3
  }
@@ -6,7 +6,22 @@
6
6
  "type": "client-side",
7
7
  "languages": [
8
8
  "JavaScript", "TypeScript"
9
- ]
9
+ ],
10
+ "userAgents": ["NodeClientSide"],
11
+ "features": {
12
+ "allFlags": { "introduced": "1.0" },
13
+ "appMetadata": { "introduced": "2.0.4" },
14
+ "bigSegments": { "introduced": "1.0" },
15
+ "bootstrapping": { "introduced": "1.0" },
16
+ "contexts": { "introduced": "3.0" },
17
+ "experimentation": { "introduced": "1.1" },
18
+ "flagChanges": { "introduced": "1.0" },
19
+ "privateAttrs": { "introduced": "1.0" },
20
+ "relayProxyProxy": { "introduced": "1.0" },
21
+ "secureMode": { "introduced": "1.0" },
22
+ "track": { "introduced": "1.0" },
23
+ "variationDetail": { "introduced": "1.0" }
24
+ }
10
25
  }
11
26
  }
12
27
  }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
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.4.0](https://github.com/launchdarkly/node-client-sdk/compare/3.3.1...3.4.0) (2026-05-26)
6
+
7
+
8
+ ### Features
9
+
10
+ * add experimental debug override functionality ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
11
+ * add hook support ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
12
+ * add support for per-context summary events ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
13
+ * add support for plugins ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
14
+ * add support for the afterTrack stage for hooks ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
15
+ * inline context in custom events ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * add hooks to default options to prevent warning ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
21
+ * remove uuid dependency, replace with inline implementation ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
22
+ * update launchdarkly-js-sdk-common to 5.8.1 ([532df60](https://github.com/launchdarkly/node-client-sdk/commit/532df60292372fab03f178827bdadc2166f9da02))
23
+
24
+ ## [3.3.1](https://github.com/launchdarkly/node-client-sdk/compare/3.3.0...3.3.1) (2025-12-02)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * Correct typing and prevents warnings for secure mode hash during initialization. ([#59](https://github.com/launchdarkly/node-client-sdk/issues/59)) ([33c129d](https://github.com/launchdarkly/node-client-sdk/commit/33c129de7b7a8032d2749445058e0aeca9e38b10)), closes [#57](https://github.com/launchdarkly/node-client-sdk/issues/57)
30
+
5
31
  ## [3.3.0](https://github.com/launchdarkly/node-client-sdk/compare/3.2.1...3.3.0) (2024-10-18)
6
32
 
7
33
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # LaunchDarkly Client-Side SDK for Node.js
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/launchdarkly-node-client-sdk.svg?style=flat-square)](https://www.npmjs.com/package/launchdarkly-node-client-sdk)
4
- [![CircleCI](https://circleci.com/gh/launchdarkly/node-client-sdk.svg?style=svg)](https://circleci.com/gh/launchdarkly/node-client-sdk)
4
+ [![Build and Test](https://github.com/launchdarkly/node-client-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/node-client-sdk/actions/workflows/ci.yml)
5
5
  [![Documentation](https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8)](https://launchdarkly.github.io/node-client-sdk)
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.
@@ -0,0 +1,61 @@
1
+ let postChain = Promise.resolve();
2
+
3
+ function safePost(url, body) {
4
+ postChain = postChain.then(() =>
5
+ fetch(url, {
6
+ method: 'POST',
7
+ headers: { 'Content-Type': 'application/json' },
8
+ body: JSON.stringify(body),
9
+ }).catch(() => {})
10
+ );
11
+ }
12
+
13
+ class TestHook {
14
+ constructor(name, endpoint, data, errors) {
15
+ this.hookName = name;
16
+ this.endpoint = endpoint;
17
+ this.hookData = data || {};
18
+ this.hookErrors = errors || {};
19
+ }
20
+
21
+ getMetadata() {
22
+ return { name: this.hookName };
23
+ }
24
+
25
+ beforeEvaluation(hookContext, data) {
26
+ if (this.hookErrors.beforeEvaluation) {
27
+ throw new Error(this.hookErrors.beforeEvaluation);
28
+ }
29
+ safePost(this.endpoint, {
30
+ evaluationSeriesContext: hookContext,
31
+ evaluationSeriesData: data,
32
+ stage: 'beforeEvaluation',
33
+ });
34
+ return { ...data, ...(this.hookData.beforeEvaluation || {}) };
35
+ }
36
+
37
+ afterEvaluation(hookContext, data, detail) {
38
+ if (this.hookErrors.afterEvaluation) {
39
+ throw new Error(this.hookErrors.afterEvaluation);
40
+ }
41
+ safePost(this.endpoint, {
42
+ evaluationSeriesContext: hookContext,
43
+ evaluationSeriesData: data,
44
+ evaluationDetail: detail,
45
+ stage: 'afterEvaluation',
46
+ });
47
+ return { ...data, ...(this.hookData.afterEvaluation || {}) };
48
+ }
49
+
50
+ afterTrack(hookContext) {
51
+ if (this.hookErrors.afterTrack) {
52
+ throw new Error(this.hookErrors.afterTrack);
53
+ }
54
+ safePost(this.endpoint, {
55
+ trackSeriesContext: hookContext,
56
+ stage: 'afterTrack',
57
+ });
58
+ }
59
+ }
60
+
61
+ module.exports = { TestHook };
@@ -25,8 +25,11 @@ app.get('/', (req, res) => {
25
25
  'tags',
26
26
  'user-type',
27
27
  'inline-context',
28
- 'anonymous-redaction',
28
+ 'inline-context-all',
29
29
  'client-prereq-events',
30
+ 'client-per-context-summaries',
31
+ 'evaluation-hooks',
32
+ 'track-hooks',
30
33
  ],
31
34
  });
32
35
  });
@@ -1,6 +1,7 @@
1
1
  const ld = require('launchdarkly-node-client-sdk');
2
2
 
3
3
  const { Log, sdkLogger } = require('./log');
4
+ const { TestHook } = require('./TestHook');
4
5
 
5
6
  const badCommandError = new Error('unsupported command');
6
7
 
@@ -60,6 +61,12 @@ function makeSdkConfig(options, tag) {
60
61
  };
61
62
  }
62
63
 
64
+ if (options.hooks) {
65
+ cf.hooks = options.hooks.hooks.map(
66
+ hook => new TestHook(hook.name, hook.callbackUri, hook.data, hook.errors)
67
+ );
68
+ }
69
+
63
70
  return cf;
64
71
  }
65
72
 
@@ -0,0 +1,2 @@
1
+ hooks/evaluation/executes beforeEvaluation hooks in registration order
2
+ hooks/track/executes afterTrack hooks in registration order
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchdarkly-node-client-sdk",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "LaunchDarkly Client-Side SDK for Node.js",
5
5
  "author": "LaunchDarkly <team@launchdarkly.com>",
6
6
  "license": "Apache-2.0",
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "launchdarkly-eventsource": "2.0.3",
69
- "launchdarkly-js-sdk-common": "5.4.0",
69
+ "launchdarkly-js-sdk-common": "5.8.1",
70
70
  "node-localstorage": "^1.3.1"
71
71
  },
72
72
  "repository": {
@@ -30,7 +30,7 @@ describe('LDClient', () => {
30
30
  const trackEvent = events[1];
31
31
  expect(trackEvent.kind).toEqual('custom');
32
32
  expect(trackEvent.key).toEqual('eventkey');
33
- expect(trackEvent.contextKeys).toEqual({ user: 'user' });
33
+ expect(trackEvent.context).toEqual({ kind: 'user', key: 'user' });
34
34
  expect(trackEvent.data).toEqual(data);
35
35
  expect(trackEvent.url).toEqual(null);
36
36
  });
package/src/index.js CHANGED
@@ -10,6 +10,7 @@ function initialize(env, context, options = {}) {
10
10
  const extraOptionDefs = {
11
11
  localStoragePath: { type: 'string' },
12
12
  tlsParams: { type: 'object' },
13
+ hash: { type: 'string' },
13
14
  };
14
15
  if (!options.logger) {
15
16
  extraOptionDefs.logger = { default: basicLogger() };
package/typings.d.ts CHANGED
@@ -65,6 +65,14 @@ declare module 'launchdarkly-node-client-sdk' {
65
65
  * of the TLS-related parameters supported by `https.request()`, such as `ca`, `cert`, and `key`.
66
66
  */
67
67
  tlsParams?: LDTLSOptions;
68
+
69
+ /**
70
+ * The signed context key for Secure Mode.
71
+ *
72
+ * For more information, see the JavaScript SDK Reference Guide on
73
+ * [Secure mode](https://launchdarkly.com/docs/sdk/features/secure-mode#configure-secure-mode-in-javascript-based-sdks).
74
+ */
75
+ hash?: string;
68
76
  }
69
77
 
70
78
  /**
@@ -1,96 +0,0 @@
1
- version: 2.1
2
-
3
- orbs:
4
- win: circleci/windows@2.4.0
5
-
6
- workflows:
7
- test:
8
- jobs:
9
- # CircleCI's current generation of Node images, cimg/node, allow you to leave the
10
- # patch version unpinned, but require you to specify the minor version. The one
11
- # exception is cimg/node:current, which will always give us the latest release in
12
- # the latest major version-- and the latest major version is where it's most likely
13
- # that there would be a new minor version, anyway.
14
- - build-test-linux:
15
- name: latest Node version
16
- docker-image: cimg/node:current
17
- run-lint: true
18
- - build-test-linux:
19
- name: Node 18.10
20
- docker-image: cimg/node:18.10
21
- - build-test-linux:
22
- name: Node 16.14
23
- docker-image: cimg/node:16.17
24
- - build-test-linux:
25
- name: Node 14.19
26
- docker-image: cimg/node:14.20
27
- - build-test-windows:
28
- name: Windows
29
-
30
- jobs:
31
- build-test-linux:
32
- parameters:
33
- docker-image:
34
- type: string
35
- run-lint:
36
- type: boolean
37
- default: false
38
- run-contract-tests:
39
- type: boolean
40
- default: true
41
-
42
- docker:
43
- - image: <<parameters.docker-image>>
44
-
45
- environment:
46
- NODE_ENV: test
47
-
48
- steps:
49
- - checkout
50
- - run: echo "Node version:" `node --version`
51
-
52
- - run: npm install
53
-
54
- - run: npm run test
55
-
56
- - when:
57
- condition: <<parameters.run-lint>>
58
- steps:
59
- - run: npm run lint:all
60
- - run: npm run check-typescript
61
-
62
- - when:
63
- condition: <<parameters.run-contract-tests>>
64
- steps:
65
- - run:
66
- name: start contact test service
67
- command: npm run contract-test-service
68
- background: true
69
- - run:
70
- name: run contract tests
71
- command: |
72
- mkdir -p reports/junit
73
- TEST_HARNESS_PARAMS="-junit reports/junit/contract-test-results.xml" npm run contract-test-harness
74
-
75
- - run:
76
- name: dependency audit
77
- command: ./scripts/better-audit.sh
78
-
79
- - store_test_results:
80
- path: reports/junit
81
- - store_artifacts:
82
- path: reports/junit
83
-
84
- build-test-windows:
85
- executor:
86
- name: win/default
87
- shell: powershell.exe
88
-
89
- environment:
90
- NODE_ENV: test
91
-
92
- steps:
93
- - checkout
94
- - run: node --version
95
- - run: npm install
96
- - run: npm test
@@ -1,27 +0,0 @@
1
- version: 2
2
-
3
- repo:
4
- public: node-client-sdk
5
- private: node-client-sdk-private
6
-
7
- branches:
8
- - name: main
9
- description: 3.x
10
- - name: 2.x
11
-
12
- publications:
13
- - url: https://www.npmjs.com/package/launchdarkly-node-client-sdk
14
- description: npm
15
-
16
- jobs:
17
- - docker:
18
- image: node:14-buster
19
- template:
20
- name: npm
21
-
22
- documentation:
23
- gitHubPages: true
24
- title: LaunchDarkly Client-Side Node SDK
25
-
26
- sdk:
27
- displayName: "Node.js (client-side)"