@spotify-confidence/openfeature-server-provider-local 0.5.1 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0](https://github.com/spotify/confidence-resolver/compare/openfeature-provider-js-v0.6.0...openfeature-provider-js-v0.7.0) (2026-01-22)
4
+
5
+
6
+ ### Features
7
+
8
+ * inlined WASM for improved portability ([#243](https://github.com/spotify/confidence-resolver/issues/243)) ([8d86283](https://github.com/spotify/confidence-resolver/commit/8d862837244ffd9099bfeb56b42e203212e73a96))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * rust-guest bumped from 0.1.12 to 0.1.13
16
+
17
+ ## [0.6.0](https://github.com/spotify/confidence-resolver/compare/openfeature-provider-js-v0.5.1...openfeature-provider-js-v0.6.0) (2026-01-15)
18
+
19
+
20
+ ### Features
21
+
22
+ * **js:** add stateUpdateInterval option for configurable state polling ([#224](https://github.com/spotify/confidence-resolver/issues/224)) ([5687847](https://github.com/spotify/confidence-resolver/commit/56878478d3d508870ac0f3172f897c8728e8a85d))
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * prevent split bundle ([#212](https://github.com/spotify/confidence-resolver/issues/212)) ([80cfd0d](https://github.com/spotify/confidence-resolver/commit/80cfd0d0128af4c65b1ae50539f2b1d0d959c02e))
28
+
3
29
  ## [0.5.1](https://github.com/spotify/confidence-resolver/compare/openfeature-provider-js-v0.5.0...openfeature-provider-js-v0.5.1) (2026-01-12)
4
30
 
5
31
 
package/README.md CHANGED
@@ -3,12 +3,14 @@
3
3
  OpenFeature provider for the Spotify Confidence resolver (local mode, powered by WebAssembly). It periodically fetches resolver state, evaluates flags locally, and flushes evaluation logs to the Confidence backend.
4
4
 
5
5
  ## Features
6
+
6
7
  - Local flag evaluation via WASM (no per-eval network calls)
7
8
  - Automatic state refresh and batched flag log flushing
8
9
  - Pluggable `fetch` with retries, timeouts and routing
9
10
  - Optional logging using `debug`
10
11
 
11
12
  ## Requirements
13
+
12
14
  - Node.js 18+ (built-in `fetch`) or provide a compatible `fetch`
13
15
  - WebAssembly support (Node 18+/modern browsers)
14
16
 
@@ -24,6 +26,7 @@ yarn add debug
24
26
  ```
25
27
 
26
28
  Notes:
29
+
27
30
  - `debug` is an optional peer. Install it if you want logs. Without it, logging is a no-op.
28
31
  - Types and bundling are ESM-first; Node is supported, and a browser build is provided for modern bundlers.
29
32
 
@@ -34,6 +37,7 @@ Notes:
34
37
  You'll need a **client secret** from Confidence to use this provider.
35
38
 
36
39
  **📖 See the [Integration Guide: Getting Your Credentials](../INTEGRATION_GUIDE.md#getting-your-credentials)** for step-by-step instructions on:
40
+
37
41
  - How to navigate the Confidence dashboard
38
42
  - Creating a Backend integration
39
43
  - Creating a test flag for verification
@@ -50,6 +54,7 @@ import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-
50
54
  const provider = createConfidenceServerProvider({
51
55
  flagClientSecret: process.env.CONFIDENCE_FLAG_CLIENT_SECRET!,
52
56
  // initializeTimeout?: number
57
+ // stateUpdateInterval?: number
53
58
  // flushInterval?: number
54
59
  // fetch?: typeof fetch (Node <18 or custom transport)
55
60
  });
@@ -103,6 +108,7 @@ const context = {
103
108
  The provider uses a **default value fallback** pattern - when evaluation fails, it returns your specified default value instead of throwing an error.
104
109
 
105
110
  **📖 See the [Integration Guide: Error Handling](../INTEGRATION_GUIDE.md#error-handling)** for:
111
+
106
112
  - Common failure scenarios
107
113
  - Error codes and meanings
108
114
  - Production best practices
@@ -118,8 +124,8 @@ const enabled = await client.getBooleanValue('my-flag.enabled', false, context);
118
124
  // For detailed error information, use getBooleanDetails()
119
125
  const details = await client.getBooleanDetails('my-flag.enabled', false, context);
120
126
  if (details.errorCode) {
121
- console.error('Flag evaluation error:', details.errorMessage);
122
- console.log('Reason:', details.reason);
127
+ console.error('Flag evaluation error:', details.errorMessage);
128
+ console.log('Reason:', details.reason);
123
129
  }
124
130
  ```
125
131
 
@@ -129,12 +135,73 @@ if (details.errorCode) {
129
135
 
130
136
  - `flagClientSecret` (string, required): The flag client secret used during evaluation and authentication.
131
137
  - `initializeTimeout` (number, optional): Max ms to wait for initial state fetch. Defaults to 30_000.
138
+ - `stateUpdateInterval` (number, optional): Interval in ms between state polling updates. Defaults to 30_000.
132
139
  - `flushInterval` (number, optional): Interval in ms for sending evaluation logs. Defaults to 10_000.
133
140
  - `fetch` (optional): Custom `fetch` implementation. Required for Node < 18; for Node 18+ you can omit.
134
141
 
135
142
  The provider periodically:
136
- - Refreshes resolver state (default every 30s)
137
- - Flushes flag evaluation logs to the backend
143
+
144
+ - Refreshes resolver state (configurable via `stateUpdateInterval`, default every 30s)
145
+ - Flushes flag evaluation logs to the backend (configurable via `flushInterval`, default every 10s)
146
+
147
+ ---
148
+
149
+ ## Exports and WASM Loading
150
+
151
+ The package provides multiple exports for different environments:
152
+
153
+ ### Default export (recommended)
154
+
155
+ ```ts
156
+ import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider-local';
157
+ ```
158
+
159
+ The WASM is **inlined as a data URL** — this is the most portable option and should work across virtually all environments. The tradeoff is a larger bundle (~700kB), but this isn't a problem for the intended server-side usage.
160
+
161
+ No configuration needed.
162
+
163
+ ### `./node` — Traditional Node.js
164
+
165
+ ```ts
166
+ import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider-local/node';
167
+ ```
168
+
169
+ Uses `fs.readFile()` to load WASM from the installed package. Works well in a regular Node.js environment with node_modules.
170
+
171
+ You can customize the WASM path if needed:
172
+
173
+ ```ts
174
+ const provider = createConfidenceServerProvider({
175
+ flagClientSecret: '...',
176
+ wasmPath: '/custom/path/to/confidence_resolver.wasm',
177
+ });
178
+ ```
179
+
180
+ ### `./fetch` — Modern and standards compliant environments
181
+
182
+ ```ts
183
+ import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider-local/fetch';
184
+ ```
185
+
186
+ Uses `fetch()` with `import.meta.url` to load WASM. Works in Deno, Bun, and browsers with bundlers that properly handle asset URLs (Vite, Rollup, etc.).
187
+
188
+ You can customize the WASM URL if needed:
189
+
190
+ ```ts
191
+ const provider = createConfidenceServerProvider({
192
+ flagClientSecret: '...',
193
+ wasmUrl: '/assets/confidence_resolver.wasm',
194
+ });
195
+ ```
196
+
197
+ ### A note on browser usage
198
+
199
+ While browsers are mentioned in this doc, this package is intended for server-side use only. Two concerns for browser usage:
200
+
201
+ - Size: The WASM+JS is currently ~270kb gzipped, too large for typical client bundles.
202
+ - Security: In a browser, all flag rules and variants are exposed to users.
203
+
204
+ That said, the package does work in browsers, and there may be specialized use cases where these tradeoffs are acceptable.
138
205
 
139
206
  ---
140
207
 
@@ -162,11 +229,13 @@ const provider = createConfidenceServerProvider({
162
229
  ```
163
230
 
164
231
  **When to use**:
232
+
165
233
  - You need sticky assignments or materialized segments but don't want to manage storage infrastructure
166
234
  - Quick prototyping or getting started
167
235
  - Lower-volume applications where network latency is acceptable
168
236
 
169
237
  **Trade-offs**:
238
+
170
239
  - Additional network calls during flag resolution (adds latency)
171
240
  - Lower performance compared to local storage implementations (Redis, DynamoDB, etc.)
172
241
 
@@ -198,6 +267,7 @@ For read-only stores (e.g., pre-populated materialized segments without sticky a
198
267
  ### When to Use Materialization Stores
199
268
 
200
269
  Consider implementing a materialization store if:
270
+
201
271
  - You need to support sticky variant assignments for experiments
202
272
  - You use materialized segments for custom targeting
203
273
  - You want to minimize network latency during flag resolution
@@ -212,10 +282,12 @@ If you don't use sticky assignments or materialized segments, the default behavi
212
282
  Logging uses the `debug` library if present; otherwise, all log calls are no-ops.
213
283
 
214
284
  Namespaces:
285
+
215
286
  - Core: `cnfd:*`
216
287
  - Fetch/middleware: `cnfd:fetch:*` (e.g. retries, auth renewals, request summaries)
217
288
 
218
289
  Log levels are hierarchical:
290
+
219
291
  - `cnfd:debug` enables debug, info, warn, and error
220
292
  - `cnfd:info` enables info, warn, and error
221
293
  - `cnfd:warn` enables warn and error
@@ -224,6 +296,7 @@ Log levels are hierarchical:
224
296
  Enable logs:
225
297
 
226
298
  - Node:
299
+
227
300
  ```bash
228
301
  DEBUG=cnfd:* node app.js
229
302
  # or narrower
@@ -231,6 +304,7 @@ DEBUG=cnfd:info,cnfd:fetch:* node app.js
231
304
  ```
232
305
 
233
306
  - Browser (in DevTools console):
307
+
234
308
  ```js
235
309
  localStorage.debug = 'cnfd:*';
236
310
  ```
@@ -243,19 +317,6 @@ yarn add debug
243
317
 
244
318
  ---
245
319
 
246
- ## WebAssembly asset notes
247
-
248
- - Node: the WASM (`confidence_resolver.wasm`) is resolved from the installed package automatically; no extra config needed.
249
- - Browser: the ESM build resolves the WASM via `new URL('confidence_resolver.wasm', import.meta.url)` so modern bundlers (Vite/Rollup/Webpack 5 asset modules) will include it. If your bundler does not, configure it to treat the `.wasm` file as a static asset.
250
-
251
- ---
252
-
253
- ## Using in browsers
254
-
255
- The package exports a browser ESM build that compiles the WASM via streaming and uses the global `fetch`. Integrate it with your OpenFeature SDK variant for the web similarly to Node, then register the provider before evaluation. Credentials must be available to the runtime (e.g. through your app’s configuration layer).
256
-
257
- ---
258
-
259
320
  ## Testing
260
321
 
261
322
  - You can inject a custom `fetch` via the `fetch` option to stub network behavior in tests.
Binary file