@ic-reactor/react 3.11.0 → 3.12.1

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.
@@ -87,7 +87,8 @@ export interface DefineReactorSharedParameters
87
87
  * When omitted, a ClientManager is created from the agent options below.
88
88
  *
89
89
  * A supplied or adopted manager brings its own agent and QueryClient, so
90
- * `agentOptions` and `queryClient` apply only when this call creates one.
90
+ * `agentOptions`, `queryClient` and `allowEnvConfig` apply only when this
91
+ * call creates one.
91
92
  */
92
93
  clientManager?: ClientManager
93
94
  /**
@@ -183,6 +184,8 @@ export function defineReactor<Service = BaseActor>(
183
184
  auth,
184
185
  display,
185
186
  agentOptions,
187
+ allowEnvConfig,
188
+ allowEnvRootKey,
186
189
  name,
187
190
  idlFactory,
188
191
  canisterId,
@@ -215,12 +218,38 @@ export function defineReactor<Service = BaseActor>(
215
218
  )
216
219
  }
217
220
 
221
+ // Same reasoning as `auth`, and it matters more here: an ignored
222
+ // `allowEnvConfig: false` reads as "I locked the cookie out" while the
223
+ // supplied manager carries whatever decision it was built with.
224
+ if (
225
+ (providedClientManager || providedAuthentication) &&
226
+ (allowEnvConfig !== undefined || allowEnvRootKey !== undefined)
227
+ ) {
228
+ const passed = [
229
+ allowEnvConfig !== undefined && "allowEnvConfig",
230
+ allowEnvRootKey !== undefined && "allowEnvRootKey",
231
+ ]
232
+ .filter(Boolean)
233
+ .join(", ")
234
+ throw new Error(
235
+ `[ic-reactor] defineReactor("${name}") received both a ClientManager and \`${passed}\`. ` +
236
+ `That option is resolved when a ClientManager is constructed, so the supplied one already carries its own ` +
237
+ `decision and this would be ignored — silently changing nothing about whether the ic_env cookie is trusted. ` +
238
+ `Pass it where that ClientManager is created, or drop \`clientManager\` to build one here.`
239
+ )
240
+ }
241
+
218
242
  const clientManager =
219
243
  providedClientManager ??
220
244
  providedAuthentication?.clientManager ??
221
245
  new ClientManager({
222
246
  queryClient: providedQueryClient ?? createDefaultQueryClient(),
223
247
  agentOptions,
248
+ // Forwarded, not dropped: the type has always accepted these (it extends
249
+ // ClientManagerParameters) while the call ignored them, so the one
250
+ // documented setup path silently discarded the ic_env opt-in it advertised.
251
+ allowEnvConfig,
252
+ allowEnvRootKey,
224
253
  })
225
254
 
226
255
  // Always report the QueryClient actually in use: when a ClientManager is